diff options
1099 files changed, 165057 insertions, 165074 deletions
@@ -801,6 +801,544 @@ if (pdf_enable_xfa) { static_library("xfa") { sources = [ + "xfa/fde/css/fde_css.h", + "xfa/fde/css/fde_csscache.cpp", + "xfa/fde/css/fde_csscache.h", + "xfa/fde/css/fde_cssdatatable.cpp", + "xfa/fde/css/fde_cssdatatable.h", + "xfa/fde/css/fde_cssdeclaration.cpp", + "xfa/fde/css/fde_cssdeclaration.h", + "xfa/fde/css/fde_cssstyleselector.cpp", + "xfa/fde/css/fde_cssstyleselector.h", + "xfa/fde/css/fde_cssstylesheet.cpp", + "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", + "xfa/fde/xml/fde_xml_imp.cpp", + "xfa/fde/xml/fde_xml_imp.h", + "xfa/fee/fde_txtedtbuf.cpp", + "xfa/fee/fde_txtedtbuf.h", + "xfa/fee/fde_txtedtengine.cpp", + "xfa/fee/fde_txtedtengine.h", + "xfa/fee/fde_txtedtpage.cpp", + "xfa/fee/fde_txtedtpage.h", + "xfa/fee/fde_txtedtparag.cpp", + "xfa/fee/fde_txtedtparag.h", + "xfa/fee/fx_wordbreak/fx_wordbreak.h", + "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", + "xfa/fgas/crt/fgas_algorithm.h", + "xfa/fgas/crt/fgas_codepage.cpp", + "xfa/fgas/crt/fgas_codepage.h", + "xfa/fgas/crt/fgas_encode.cpp", + "xfa/fgas/crt/fgas_language.h", + "xfa/fgas/crt/fgas_memory.cpp", + "xfa/fgas/crt/fgas_memory.h", + "xfa/fgas/crt/fgas_stream.cpp", + "xfa/fgas/crt/fgas_stream.h", + "xfa/fgas/crt/fgas_system.cpp", + "xfa/fgas/crt/fgas_system.h", + "xfa/fgas/crt/fgas_utils.cpp", + "xfa/fgas/crt/fgas_utils.h", + "xfa/fgas/font/fgas_font.h", + "xfa/fgas/font/fgas_fontutils.cpp", + "xfa/fgas/font/fgas_fontutils.h", + "xfa/fgas/font/fgas_gefont.cpp", + "xfa/fgas/font/fgas_gefont.h", + "xfa/fgas/font/fgas_stdfontmgr.cpp", + "xfa/fgas/font/fgas_stdfontmgr.h", + "xfa/fgas/layout/fgas_linebreak.cpp", + "xfa/fgas/layout/fgas_linebreak.h", + "xfa/fgas/layout/fgas_rtfbreak.cpp", + "xfa/fgas/layout/fgas_rtfbreak.h", + "xfa/fgas/layout/fgas_textbreak.cpp", + "xfa/fgas/layout/fgas_textbreak.h", + "xfa/fgas/layout/fgas_unicode.cpp", + "xfa/fgas/layout/fgas_unicode.h", + "xfa/fgas/localization/fgas_datetime.cpp", + "xfa/fgas/localization/fgas_datetime.h", + "xfa/fgas/localization/fgas_locale.cpp", + "xfa/fgas/localization/fgas_locale.h", + "xfa/fgas/localization/fgas_localeimp.h", + "xfa/fgas/localization/fgas_localemgr.cpp", + "xfa/fgas/localization/fgas_localemgr.h", + "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", + "xfa/fwl/basewidget/fwl_caretimp.h", + "xfa/fwl/basewidget/fwl_checkboximp.cpp", + "xfa/fwl/basewidget/fwl_checkboximp.h", + "xfa/fwl/basewidget/fwl_comboboximp.cpp", + "xfa/fwl/basewidget/fwl_comboboximp.h", + "xfa/fwl/basewidget/fwl_datetimepickerimp.cpp", + "xfa/fwl/basewidget/fwl_datetimepickerimp.h", + "xfa/fwl/basewidget/fwl_editimp.cpp", + "xfa/fwl/basewidget/fwl_editimp.h", + "xfa/fwl/basewidget/fwl_formproxyimp.cpp", + "xfa/fwl/basewidget/fwl_formproxyimp.h", + "xfa/fwl/basewidget/fwl_listboximp.cpp", + "xfa/fwl/basewidget/fwl_listboximp.h", + "xfa/fwl/basewidget/fwl_monthcalendarimp.cpp", + "xfa/fwl/basewidget/fwl_monthcalendarimp.h", + "xfa/fwl/basewidget/fwl_pictureboximp.cpp", + "xfa/fwl/basewidget/fwl_pictureboximp.h", + "xfa/fwl/basewidget/fwl_pushbuttonimp.cpp", + "xfa/fwl/basewidget/fwl_pushbuttonimp.h", + "xfa/fwl/basewidget/fwl_scrollbarimp.cpp", + "xfa/fwl/basewidget/fwl_scrollbarimp.h", + "xfa/fwl/basewidget/fwl_spinbuttonimp.cpp", + "xfa/fwl/basewidget/fwl_spinbuttonimp.h", + "xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp", + "xfa/fwl/basewidget/fwl_tooltipctrlimp.h", + "xfa/fwl/basewidget/fxmath_barcodeimp.cpp", + "xfa/fwl/basewidget/fxmath_barcodeimp.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_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_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_widgetimp.cpp", + "xfa/fwl/core/fwl_widgetimp.h", + "xfa/fwl/core/fwl_widgetmgrimp.cpp", + "xfa/fwl/core/fwl_widgetmgrimp.h", + "xfa/fwl/lightwidget/app.cpp", + "xfa/fwl/lightwidget/barcode.cpp", + "xfa/fwl/lightwidget/caret.cpp", + "xfa/fwl/lightwidget/checkbox.cpp", + "xfa/fwl/lightwidget/combobox.cpp", + "xfa/fwl/lightwidget/datetimepicker.cpp", + "xfa/fwl/lightwidget/edit.cpp", + "xfa/fwl/lightwidget/listbox.cpp", + "xfa/fwl/lightwidget/picturebox.cpp", + "xfa/fwl/lightwidget/pushbutton.cpp", + "xfa/fwl/lightwidget/scrollbar.cpp", + "xfa/fwl/lightwidget/theme.cpp", + "xfa/fwl/lightwidget/tooltipctrl.cpp", + "xfa/fwl/lightwidget/widget.cpp", + "xfa/fwl/theme/barcodetp.cpp", + "xfa/fwl/theme/carettp.cpp", + "xfa/fwl/theme/checkboxtp.cpp", + "xfa/fwl/theme/comboboxtp.cpp", + "xfa/fwl/theme/datetimepickertp.cpp", + "xfa/fwl/theme/edittp.cpp", + "xfa/fwl/theme/formtp.cpp", + "xfa/fwl/theme/listboxtp.cpp", + "xfa/fwl/theme/monthcalendartp.cpp", + "xfa/fwl/theme/pictureboxtp.cpp", + "xfa/fwl/theme/pushbuttontp.cpp", + "xfa/fwl/theme/scrollbartp.cpp", + "xfa/fwl/theme/widgettp.cpp", + "xfa/fxbarcode/BC_BarCode.cpp", + "xfa/fxbarcode/BC_Binarizer.cpp", + "xfa/fxbarcode/BC_Binarizer.h", + "xfa/fxbarcode/BC_BinaryBitmap.cpp", + "xfa/fxbarcode/BC_BinaryBitmap.h", + "xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp", + "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h", + "xfa/fxbarcode/BC_DecoderResult.h", + "xfa/fxbarcode/BC_Dimension.cpp", + "xfa/fxbarcode/BC_Dimension.h", + "xfa/fxbarcode/BC_Library.cpp", + "xfa/fxbarcode/BC_LuminanceSource.cpp", + "xfa/fxbarcode/BC_LuminanceSource.h", + "xfa/fxbarcode/BC_Reader.cpp", + "xfa/fxbarcode/BC_Reader.h", + "xfa/fxbarcode/BC_ResultPoint.cpp", + "xfa/fxbarcode/BC_ResultPoint.h", + "xfa/fxbarcode/BC_TwoDimWriter.cpp", + "xfa/fxbarcode/BC_TwoDimWriter.h", + "xfa/fxbarcode/BC_UtilCodingConvert.cpp", + "xfa/fxbarcode/BC_UtilCodingConvert.h", + "xfa/fxbarcode/BC_UtilRSS.cpp", + "xfa/fxbarcode/BC_UtilRSS.h", + "xfa/fxbarcode/BC_Utils.cpp", + "xfa/fxbarcode/BC_Writer.cpp", + "xfa/fxbarcode/BC_Writer.h", + "xfa/fxbarcode/common/BC_CommonBitArray.cpp", + "xfa/fxbarcode/common/BC_CommonBitArray.h", + "xfa/fxbarcode/common/BC_CommonBitMatrix.cpp", + "xfa/fxbarcode/common/BC_CommonBitMatrix.h", + "xfa/fxbarcode/common/BC_CommonBitSource.cpp", + "xfa/fxbarcode/common/BC_CommonBitSource.h", + "xfa/fxbarcode/common/BC_CommonByteArray.cpp", + "xfa/fxbarcode/common/BC_CommonByteArray.h", + "xfa/fxbarcode/common/BC_CommonByteMatrix.cpp", + "xfa/fxbarcode/common/BC_CommonByteMatrix.h", + "xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp", + "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h", + "xfa/fxbarcode/common/BC_CommonDecoderResult.cpp", + "xfa/fxbarcode/common/BC_CommonDecoderResult.h", + "xfa/fxbarcode/common/BC_CommonECI.cpp", + "xfa/fxbarcode/common/BC_CommonECI.h", + "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.cpp", + "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h", + "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp", + "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h", + "xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp", + "xfa/fxbarcode/common/BC_WhiteRectangleDetector.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h", + "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h", + "xfa/fxbarcode/datamatrix/BC_Base256Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h", + "xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_C40Encoder.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h", + "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.cpp", + "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h", + "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h", + "xfa/fxbarcode/datamatrix/BC_Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_Encoder.h", + "xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp", + "xfa/fxbarcode/datamatrix/BC_EncoderContext.h", + "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp", + "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h", + "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h", + "xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp", + "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h", + "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp", + "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h", + "xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_TextEncoder.h", + "xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_X12Encoder.h", + "xfa/fxbarcode/oned/BC_OneDReader.cpp", + "xfa/fxbarcode/oned/BC_OneDReader.h", + "xfa/fxbarcode/oned/BC_OneDimReader.cpp", + "xfa/fxbarcode/oned/BC_OneDimReader.h", + "xfa/fxbarcode/oned/BC_OneDimWriter.cpp", + "xfa/fxbarcode/oned/BC_OneDimWriter.h", + "xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp", + "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h", + "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp", + "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h", + "xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedCode128Reader.h", + "xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedCode128Writer.h", + "xfa/fxbarcode/oned/BC_OnedCode39Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedCode39Reader.h", + "xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedCode39Writer.h", + "xfa/fxbarcode/oned/BC_OnedEAN13Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h", + "xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h", + "xfa/fxbarcode/oned/BC_OnedEAN8Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h", + "xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h", + "xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp", + "xfa/fxbarcode/oned/BC_OnedUPCAReader.h", + "xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp", + "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h", + "xfa/fxbarcode/pdf417/BC_PDF417.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h", + "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h", + "xfa/fxbarcode/pdf417/BC_PDF417Codeword.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h", + "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Common.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Common.h", + "xfa/fxbarcode/pdf417/BC_PDF417Compaction.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h", + "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h", + "xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Detector.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h", + "xfa/fxbarcode/pdf417/BC_PDF417Dimensions.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h", + "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h", + "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Reader.h", + "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h", + "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Writer.h", + "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp", + "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h", + "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp", + "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h", + "xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp", + "xfa/fxbarcode/qrcode/BC_QRCodeReader.h", + "xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp", + "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h", + "xfa/fxbarcode/qrcode/BC_QRCoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoder.h", + "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h", + "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h", + "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h", + "xfa/fxbarcode/qrcode/BC_QRCoderECB.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderECB.h", + "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h", + "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h", + "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h", + "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMode.h", + "xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h", + "xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp", + "xfa/fxbarcode/qrcode/BC_QRDataBlock.h", + "xfa/fxbarcode/qrcode/BC_QRDataMask.cpp", + "xfa/fxbarcode/qrcode/BC_QRDataMask.h", + "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp", + "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h", + "xfa/fxbarcode/qrcode/BC_QRDetector.cpp", + "xfa/fxbarcode/qrcode/BC_QRDetector.h", + "xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp", + "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h", + "xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp", + "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h", + "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp", + "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h", + "xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp", + "xfa/fxbarcode/qrcode/BC_QRGridSampler.h", + "xfa/fxbarcode/utils.h", + "xfa/fxfa/app/xfa_checksum.cpp", + "xfa/fxfa/app/xfa_checksum.h", + "xfa/fxfa/app/xfa_ffapp.cpp", + "xfa/fxfa/app/xfa_ffapp.h", + "xfa/fxfa/app/xfa_ffbarcode.cpp", + "xfa/fxfa/app/xfa_ffbarcode.h", + "xfa/fxfa/app/xfa_ffcheckbutton.cpp", + "xfa/fxfa/app/xfa_ffcheckbutton.h", + "xfa/fxfa/app/xfa_ffchoicelist.cpp", + "xfa/fxfa/app/xfa_ffchoicelist.h", + "xfa/fxfa/app/xfa_ffdoc.cpp", + "xfa/fxfa/app/xfa_ffdoc.h", + "xfa/fxfa/app/xfa_ffdochandler.cpp", + "xfa/fxfa/app/xfa_ffdochandler.h", + "xfa/fxfa/app/xfa_ffdocview.cpp", + "xfa/fxfa/app/xfa_ffdocview.h", + "xfa/fxfa/app/xfa_ffdraw.cpp", + "xfa/fxfa/app/xfa_ffdraw.h", + "xfa/fxfa/app/xfa_ffexclgroup.cpp", + "xfa/fxfa/app/xfa_ffexclgroup.h", + "xfa/fxfa/app/xfa_fffield.cpp", + "xfa/fxfa/app/xfa_fffield.h", + "xfa/fxfa/app/xfa_ffimage.cpp", + "xfa/fxfa/app/xfa_ffimage.h", + "xfa/fxfa/app/xfa_ffimageedit.cpp", + "xfa/fxfa/app/xfa_ffimageedit.h", + "xfa/fxfa/app/xfa_ffnotify.cpp", + "xfa/fxfa/app/xfa_ffnotify.h", + "xfa/fxfa/app/xfa_ffpageview.cpp", + "xfa/fxfa/app/xfa_ffpageview.h", + "xfa/fxfa/app/xfa_ffpath.cpp", + "xfa/fxfa/app/xfa_ffpath.h", + "xfa/fxfa/app/xfa_ffpushbutton.cpp", + "xfa/fxfa/app/xfa_ffpushbutton.h", + "xfa/fxfa/app/xfa_ffsignature.cpp", + "xfa/fxfa/app/xfa_ffsignature.h", + "xfa/fxfa/app/xfa_ffsubform.cpp", + "xfa/fxfa/app/xfa_ffsubform.h", + "xfa/fxfa/app/xfa_fftext.cpp", + "xfa/fxfa/app/xfa_fftext.h", + "xfa/fxfa/app/xfa_fftextedit.cpp", + "xfa/fxfa/app/xfa_fftextedit.h", + "xfa/fxfa/app/xfa_ffwidget.cpp", + "xfa/fxfa/app/xfa_ffwidget.h", + "xfa/fxfa/app/xfa_ffwidgetacc.cpp", + "xfa/fxfa/app/xfa_ffwidgetacc.h", + "xfa/fxfa/app/xfa_ffwidgethandler.cpp", + "xfa/fxfa/app/xfa_ffwidgethandler.h", + "xfa/fxfa/app/xfa_fontmgr.cpp", + "xfa/fxfa/app/xfa_fontmgr.h", + "xfa/fxfa/app/xfa_fwladapter.cpp", + "xfa/fxfa/app/xfa_fwladapter.h", + "xfa/fxfa/app/xfa_fwltheme.cpp", + "xfa/fxfa/app/xfa_fwltheme.h", + "xfa/fxfa/app/xfa_rendercontext.cpp", + "xfa/fxfa/app/xfa_rendercontext.h", + "xfa/fxfa/app/xfa_textlayout.cpp", + "xfa/fxfa/app/xfa_textlayout.h", + "xfa/fxfa/fm2js/xfa_error.cpp", + "xfa/fxfa/fm2js/xfa_error.h", + "xfa/fxfa/fm2js/xfa_expression.cpp", + "xfa/fxfa/fm2js/xfa_expression.h", + "xfa/fxfa/fm2js/xfa_fm2jsapi.cpp", + "xfa/fxfa/fm2js/xfa_fm2jsapi.h", + "xfa/fxfa/fm2js/xfa_fm2jscontext.cpp", + "xfa/fxfa/fm2js/xfa_fm2jscontext.h", + "xfa/fxfa/fm2js/xfa_fmparse.cpp", + "xfa/fxfa/fm2js/xfa_fmparse.h", + "xfa/fxfa/fm2js/xfa_lexer.cpp", + "xfa/fxfa/fm2js/xfa_lexer.h", + "xfa/fxfa/fm2js/xfa_program.cpp", + "xfa/fxfa/fm2js/xfa_program.h", + "xfa/fxfa/fm2js/xfa_simpleexpression.cpp", + "xfa/fxfa/fm2js/xfa_simpleexpression.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", + "xfa/fxfa/parser/xfa_document_datadescription_imp.h", + "xfa/fxfa/parser/xfa_document_datamerger_imp.cpp", + "xfa/fxfa/parser/xfa_document_datamerger_imp.h", + "xfa/fxfa/parser/xfa_document_imp.cpp", + "xfa/fxfa/parser/xfa_document_layout_imp.cpp", + "xfa/fxfa/parser/xfa_document_layout_imp.h", + "xfa/fxfa/parser/xfa_document_serialize.cpp", + "xfa/fxfa/parser/xfa_document_serialize.h", + "xfa/fxfa/parser/xfa_layout_appadapter.cpp", + "xfa/fxfa/parser/xfa_layout_appadapter.h", + "xfa/fxfa/parser/xfa_layout_itemlayout.cpp", + "xfa/fxfa/parser/xfa_layout_itemlayout.h", + "xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp", + "xfa/fxfa/parser/xfa_layout_pagemgr_new.h", + "xfa/fxfa/parser/xfa_locale.cpp", + "xfa/fxfa/parser/xfa_locale.h", + "xfa/fxfa/parser/xfa_localemgr.cpp", + "xfa/fxfa/parser/xfa_localemgr.h", + "xfa/fxfa/parser/xfa_localevalue.cpp", + "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", + "xfa/fxfa/parser/xfa_script.h", + "xfa/fxfa/parser/xfa_script_datawindow.cpp", + "xfa/fxfa/parser/xfa_script_datawindow.h", + "xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_eventpseudomodel.h", + "xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_hostpseudomodel.h", + "xfa/fxfa/parser/xfa_script_imp.cpp", + "xfa/fxfa/parser/xfa_script_imp.h", + "xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h", + "xfa/fxfa/parser/xfa_script_logpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_logpseudomodel.h", + "xfa/fxfa/parser/xfa_script_nodehelper.cpp", + "xfa/fxfa/parser/xfa_script_nodehelper.h", + "xfa/fxfa/parser/xfa_script_resolveprocessor.cpp", + "xfa/fxfa/parser/xfa_script_resolveprocessor.h", + "xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h", + "xfa/fxfa/parser/xfa_utils.h", + "xfa/fxfa/parser/xfa_utils_imp.cpp", + "xfa/fxgraphics/fx_graphics.cpp", + "xfa/fxgraphics/fx_path_generator.cpp", + "xfa/fxgraphics/fx_path_generator.h", + "xfa/fxgraphics/pre.h", "xfa/include/fwl/adapter/fwl_adapternative.h", "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h", "xfa/include/fwl/adapter/fwl_adaptertimermgr.h", @@ -870,559 +1408,21 @@ if (pdf_enable_xfa) { "xfa/include/fxfa/fxfa_widget.h", "xfa/include/fxgraphics/fx_graphics.h", "xfa/include/fxjse/fxjse.h", - "xfa/src/fde/css/fde_css.h", - "xfa/src/fde/css/fde_csscache.cpp", - "xfa/src/fde/css/fde_csscache.h", - "xfa/src/fde/css/fde_cssdatatable.cpp", - "xfa/src/fde/css/fde_cssdatatable.h", - "xfa/src/fde/css/fde_cssdeclaration.cpp", - "xfa/src/fde/css/fde_cssdeclaration.h", - "xfa/src/fde/css/fde_cssstyleselector.cpp", - "xfa/src/fde/css/fde_cssstyleselector.h", - "xfa/src/fde/css/fde_cssstylesheet.cpp", - "xfa/src/fde/css/fde_cssstylesheet.h", - "xfa/src/fde/css/fde_csssyntax.cpp", - "xfa/src/fde/css/fde_csssyntax.h", - "xfa/src/fde/fde_brush.h", - "xfa/src/fde/fde_devbasic.cpp", - "xfa/src/fde/fde_devbasic.h", - "xfa/src/fde/fde_gedevice.cpp", - "xfa/src/fde/fde_gedevice.h", - "xfa/src/fde/fde_geobject.cpp", - "xfa/src/fde/fde_geobject.h", - "xfa/src/fde/fde_image.h", - "xfa/src/fde/fde_iterator.cpp", - "xfa/src/fde/fde_iterator.h", - "xfa/src/fde/fde_object.cpp", - "xfa/src/fde/fde_object.h", - "xfa/src/fde/fde_path.h", - "xfa/src/fde/fde_pen.h", - "xfa/src/fde/fde_render.cpp", - "xfa/src/fde/fde_render.h", - "xfa/src/fde/fde_renderdevice.h", - "xfa/src/fde/tto/fde_textout.cpp", - "xfa/src/fde/tto/fde_textout.h", - "xfa/src/fde/xml/fde_xml.h", - "xfa/src/fde/xml/fde_xml_imp.cpp", - "xfa/src/fde/xml/fde_xml_imp.h", - "xfa/src/fee/fde_txtedtbuf.cpp", - "xfa/src/fee/fde_txtedtbuf.h", - "xfa/src/fee/fde_txtedtengine.cpp", - "xfa/src/fee/fde_txtedtengine.h", - "xfa/src/fee/fde_txtedtpage.cpp", - "xfa/src/fee/fde_txtedtpage.h", - "xfa/src/fee/fde_txtedtparag.cpp", - "xfa/src/fee/fde_txtedtparag.h", - "xfa/src/fee/fx_wordbreak/fx_wordbreak.h", - "xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.cpp", - "xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h", - "xfa/src/fee/fx_wordbreak/fx_wordbreakdata.cpp", - "xfa/src/fee/ifde_txtedtbuf.h", - "xfa/src/fee/ifde_txtedtengine.h", - "xfa/src/fee/ifde_txtedtpage.h", - "xfa/src/fgas/crt/fgas_algorithm.cpp", - "xfa/src/fgas/crt/fgas_algorithm.h", - "xfa/src/fgas/crt/fgas_codepage.cpp", - "xfa/src/fgas/crt/fgas_codepage.h", - "xfa/src/fgas/crt/fgas_encode.cpp", - "xfa/src/fgas/crt/fgas_language.h", - "xfa/src/fgas/crt/fgas_memory.cpp", - "xfa/src/fgas/crt/fgas_memory.h", - "xfa/src/fgas/crt/fgas_stream.cpp", - "xfa/src/fgas/crt/fgas_stream.h", - "xfa/src/fgas/crt/fgas_system.cpp", - "xfa/src/fgas/crt/fgas_system.h", - "xfa/src/fgas/crt/fgas_utils.cpp", - "xfa/src/fgas/crt/fgas_utils.h", - "xfa/src/fgas/font/fgas_font.h", - "xfa/src/fgas/font/fgas_fontutils.cpp", - "xfa/src/fgas/font/fgas_fontutils.h", - "xfa/src/fgas/font/fgas_gefont.cpp", - "xfa/src/fgas/font/fgas_gefont.h", - "xfa/src/fgas/font/fgas_stdfontmgr.cpp", - "xfa/src/fgas/font/fgas_stdfontmgr.h", - "xfa/src/fgas/layout/fgas_linebreak.cpp", - "xfa/src/fgas/layout/fgas_linebreak.h", - "xfa/src/fgas/layout/fgas_rtfbreak.cpp", - "xfa/src/fgas/layout/fgas_rtfbreak.h", - "xfa/src/fgas/layout/fgas_textbreak.cpp", - "xfa/src/fgas/layout/fgas_textbreak.h", - "xfa/src/fgas/layout/fgas_unicode.cpp", - "xfa/src/fgas/layout/fgas_unicode.h", - "xfa/src/fgas/localization/fgas_datetime.cpp", - "xfa/src/fgas/localization/fgas_datetime.h", - "xfa/src/fgas/localization/fgas_locale.cpp", - "xfa/src/fgas/localization/fgas_locale.h", - "xfa/src/fgas/localization/fgas_localeimp.h", - "xfa/src/fgas/localization/fgas_localemgr.cpp", - "xfa/src/fgas/localization/fgas_localemgr.h", - "xfa/src/fgas/xml/fgas_sax.h", - "xfa/src/fgas/xml/fgas_sax_imp.cpp", - "xfa/src/fgas/xml/fgas_sax_imp.h", - "xfa/src/fwl/basewidget/fwl_barcodeimp.cpp", - "xfa/src/fwl/basewidget/fwl_barcodeimp.h", - "xfa/src/fwl/basewidget/fwl_caretimp.cpp", - "xfa/src/fwl/basewidget/fwl_caretimp.h", - "xfa/src/fwl/basewidget/fwl_checkboximp.cpp", - "xfa/src/fwl/basewidget/fwl_checkboximp.h", - "xfa/src/fwl/basewidget/fwl_comboboximp.cpp", - "xfa/src/fwl/basewidget/fwl_comboboximp.h", - "xfa/src/fwl/basewidget/fwl_datetimepickerimp.cpp", - "xfa/src/fwl/basewidget/fwl_datetimepickerimp.h", - "xfa/src/fwl/basewidget/fwl_editimp.cpp", - "xfa/src/fwl/basewidget/fwl_editimp.h", - "xfa/src/fwl/basewidget/fwl_formproxyimp.cpp", - "xfa/src/fwl/basewidget/fwl_formproxyimp.h", - "xfa/src/fwl/basewidget/fwl_listboximp.cpp", - "xfa/src/fwl/basewidget/fwl_listboximp.h", - "xfa/src/fwl/basewidget/fwl_monthcalendarimp.cpp", - "xfa/src/fwl/basewidget/fwl_monthcalendarimp.h", - "xfa/src/fwl/basewidget/fwl_pictureboximp.cpp", - "xfa/src/fwl/basewidget/fwl_pictureboximp.h", - "xfa/src/fwl/basewidget/fwl_pushbuttonimp.cpp", - "xfa/src/fwl/basewidget/fwl_pushbuttonimp.h", - "xfa/src/fwl/basewidget/fwl_scrollbarimp.cpp", - "xfa/src/fwl/basewidget/fwl_scrollbarimp.h", - "xfa/src/fwl/basewidget/fwl_spinbuttonimp.cpp", - "xfa/src/fwl/basewidget/fwl_spinbuttonimp.h", - "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.cpp", - "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h", - "xfa/src/fwl/basewidget/fxmath_barcodeimp.cpp", - "xfa/src/fwl/basewidget/fxmath_barcodeimp.h", - "xfa/src/fwl/core/fwl_appimp.cpp", - "xfa/src/fwl/core/fwl_appimp.h", - "xfa/src/fwl/core/fwl_contentimp.cpp", - "xfa/src/fwl/core/fwl_contentimp.h", - "xfa/src/fwl/core/fwl_formimp.cpp", - "xfa/src/fwl/core/fwl_formimp.h", - "xfa/src/fwl/core/fwl_gridimp.cpp", - "xfa/src/fwl/core/fwl_gridimp.h", - "xfa/src/fwl/core/fwl_noteimp.cpp", - "xfa/src/fwl/core/fwl_noteimp.h", - "xfa/src/fwl/core/fwl_panelimp.cpp", - "xfa/src/fwl/core/fwl_panelimp.h", - "xfa/src/fwl/core/fwl_sdadapterimp.cpp", - "xfa/src/fwl/core/fwl_targetimp.cpp", - "xfa/src/fwl/core/fwl_targetimp.h", - "xfa/src/fwl/core/fwl_threadimp.cpp", - "xfa/src/fwl/core/fwl_threadimp.h", - "xfa/src/fwl/core/fwl_timerimp.cpp", - "xfa/src/fwl/core/fwl_widgetimp.cpp", - "xfa/src/fwl/core/fwl_widgetimp.h", - "xfa/src/fwl/core/fwl_widgetmgrimp.cpp", - "xfa/src/fwl/core/fwl_widgetmgrimp.h", - "xfa/src/fwl/lightwidget/app.cpp", - "xfa/src/fwl/lightwidget/barcode.cpp", - "xfa/src/fwl/lightwidget/caret.cpp", - "xfa/src/fwl/lightwidget/checkbox.cpp", - "xfa/src/fwl/lightwidget/combobox.cpp", - "xfa/src/fwl/lightwidget/datetimepicker.cpp", - "xfa/src/fwl/lightwidget/edit.cpp", - "xfa/src/fwl/lightwidget/listbox.cpp", - "xfa/src/fwl/lightwidget/picturebox.cpp", - "xfa/src/fwl/lightwidget/pushbutton.cpp", - "xfa/src/fwl/lightwidget/scrollbar.cpp", - "xfa/src/fwl/lightwidget/theme.cpp", - "xfa/src/fwl/lightwidget/tooltipctrl.cpp", - "xfa/src/fwl/lightwidget/widget.cpp", - "xfa/src/fwl/theme/barcodetp.cpp", - "xfa/src/fwl/theme/carettp.cpp", - "xfa/src/fwl/theme/checkboxtp.cpp", - "xfa/src/fwl/theme/comboboxtp.cpp", - "xfa/src/fwl/theme/datetimepickertp.cpp", - "xfa/src/fwl/theme/edittp.cpp", - "xfa/src/fwl/theme/formtp.cpp", - "xfa/src/fwl/theme/listboxtp.cpp", - "xfa/src/fwl/theme/monthcalendartp.cpp", - "xfa/src/fwl/theme/pictureboxtp.cpp", - "xfa/src/fwl/theme/pushbuttontp.cpp", - "xfa/src/fwl/theme/scrollbartp.cpp", - "xfa/src/fwl/theme/widgettp.cpp", - "xfa/src/fxbarcode/BC_BarCode.cpp", - "xfa/src/fxbarcode/BC_Binarizer.cpp", - "xfa/src/fxbarcode/BC_Binarizer.h", - "xfa/src/fxbarcode/BC_BinaryBitmap.cpp", - "xfa/src/fxbarcode/BC_BinaryBitmap.h", - "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp", - "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h", - "xfa/src/fxbarcode/BC_DecoderResult.h", - "xfa/src/fxbarcode/BC_Dimension.cpp", - "xfa/src/fxbarcode/BC_Dimension.h", - "xfa/src/fxbarcode/BC_Library.cpp", - "xfa/src/fxbarcode/BC_LuminanceSource.cpp", - "xfa/src/fxbarcode/BC_LuminanceSource.h", - "xfa/src/fxbarcode/BC_Reader.cpp", - "xfa/src/fxbarcode/BC_Reader.h", - "xfa/src/fxbarcode/BC_ResultPoint.cpp", - "xfa/src/fxbarcode/BC_ResultPoint.h", - "xfa/src/fxbarcode/BC_TwoDimWriter.cpp", - "xfa/src/fxbarcode/BC_TwoDimWriter.h", - "xfa/src/fxbarcode/BC_UtilCodingConvert.cpp", - "xfa/src/fxbarcode/BC_UtilCodingConvert.h", - "xfa/src/fxbarcode/BC_UtilRSS.cpp", - "xfa/src/fxbarcode/BC_UtilRSS.h", - "xfa/src/fxbarcode/BC_Utils.cpp", - "xfa/src/fxbarcode/BC_Writer.cpp", - "xfa/src/fxbarcode/BC_Writer.h", - "xfa/src/fxbarcode/common/BC_CommonBitArray.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitArray.h", - "xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h", - "xfa/src/fxbarcode/common/BC_CommonBitSource.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitSource.h", - "xfa/src/fxbarcode/common/BC_CommonByteArray.cpp", - "xfa/src/fxbarcode/common/BC_CommonByteArray.h", - "xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp", - "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h", - "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp", - "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h", - "xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp", - "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h", - "xfa/src/fxbarcode/common/BC_CommonECI.cpp", - "xfa/src/fxbarcode/common/BC_CommonECI.h", - "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp", - "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h", - "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp", - "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h", - "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp", - "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h", - "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h", - "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h", - "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.cpp", - "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h", - "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.cpp", - "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h", - "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.cpp", - "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h", - "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp", - "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h", - "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h", - "xfa/src/fxbarcode/oned/BC_OneDReader.cpp", - "xfa/src/fxbarcode/oned/BC_OneDReader.h", - "xfa/src/fxbarcode/oned/BC_OneDimReader.cpp", - "xfa/src/fxbarcode/oned/BC_OneDimReader.h", - "xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OneDimWriter.h", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h", - "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h", - "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Common.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h", - "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.cpp", - "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h", - "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h", - "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h", - "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h", - "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h", - "xfa/src/fxbarcode/qrcode/BC_QRDataMask.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h", - "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h", - "xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDetector.h", - "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h", - "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h", - "xfa/src/fxbarcode/utils.h", - "xfa/src/fxfa/app/xfa_checksum.cpp", - "xfa/src/fxfa/app/xfa_checksum.h", - "xfa/src/fxfa/app/xfa_ffapp.cpp", - "xfa/src/fxfa/app/xfa_ffapp.h", - "xfa/src/fxfa/app/xfa_ffbarcode.cpp", - "xfa/src/fxfa/app/xfa_ffbarcode.h", - "xfa/src/fxfa/app/xfa_ffcheckbutton.cpp", - "xfa/src/fxfa/app/xfa_ffcheckbutton.h", - "xfa/src/fxfa/app/xfa_ffchoicelist.cpp", - "xfa/src/fxfa/app/xfa_ffchoicelist.h", - "xfa/src/fxfa/app/xfa_ffdoc.cpp", - "xfa/src/fxfa/app/xfa_ffdoc.h", - "xfa/src/fxfa/app/xfa_ffdochandler.cpp", - "xfa/src/fxfa/app/xfa_ffdochandler.h", - "xfa/src/fxfa/app/xfa_ffdocview.cpp", - "xfa/src/fxfa/app/xfa_ffdocview.h", - "xfa/src/fxfa/app/xfa_ffdraw.cpp", - "xfa/src/fxfa/app/xfa_ffdraw.h", - "xfa/src/fxfa/app/xfa_ffexclgroup.cpp", - "xfa/src/fxfa/app/xfa_ffexclgroup.h", - "xfa/src/fxfa/app/xfa_fffield.cpp", - "xfa/src/fxfa/app/xfa_fffield.h", - "xfa/src/fxfa/app/xfa_ffimage.cpp", - "xfa/src/fxfa/app/xfa_ffimage.h", - "xfa/src/fxfa/app/xfa_ffimageedit.cpp", - "xfa/src/fxfa/app/xfa_ffimageedit.h", - "xfa/src/fxfa/app/xfa_ffnotify.cpp", - "xfa/src/fxfa/app/xfa_ffnotify.h", - "xfa/src/fxfa/app/xfa_ffpageview.cpp", - "xfa/src/fxfa/app/xfa_ffpageview.h", - "xfa/src/fxfa/app/xfa_ffpath.cpp", - "xfa/src/fxfa/app/xfa_ffpath.h", - "xfa/src/fxfa/app/xfa_ffpushbutton.cpp", - "xfa/src/fxfa/app/xfa_ffpushbutton.h", - "xfa/src/fxfa/app/xfa_ffsignature.cpp", - "xfa/src/fxfa/app/xfa_ffsignature.h", - "xfa/src/fxfa/app/xfa_ffsubform.cpp", - "xfa/src/fxfa/app/xfa_ffsubform.h", - "xfa/src/fxfa/app/xfa_fftext.cpp", - "xfa/src/fxfa/app/xfa_fftext.h", - "xfa/src/fxfa/app/xfa_fftextedit.cpp", - "xfa/src/fxfa/app/xfa_fftextedit.h", - "xfa/src/fxfa/app/xfa_ffwidget.cpp", - "xfa/src/fxfa/app/xfa_ffwidget.h", - "xfa/src/fxfa/app/xfa_ffwidgetacc.cpp", - "xfa/src/fxfa/app/xfa_ffwidgetacc.h", - "xfa/src/fxfa/app/xfa_ffwidgethandler.cpp", - "xfa/src/fxfa/app/xfa_ffwidgethandler.h", - "xfa/src/fxfa/app/xfa_fontmgr.cpp", - "xfa/src/fxfa/app/xfa_fontmgr.h", - "xfa/src/fxfa/app/xfa_fwladapter.cpp", - "xfa/src/fxfa/app/xfa_fwladapter.h", - "xfa/src/fxfa/app/xfa_fwltheme.cpp", - "xfa/src/fxfa/app/xfa_fwltheme.h", - "xfa/src/fxfa/app/xfa_rendercontext.cpp", - "xfa/src/fxfa/app/xfa_rendercontext.h", - "xfa/src/fxfa/app/xfa_textlayout.cpp", - "xfa/src/fxfa/app/xfa_textlayout.h", - "xfa/src/fxfa/fm2js/xfa_error.cpp", - "xfa/src/fxfa/fm2js/xfa_error.h", - "xfa/src/fxfa/fm2js/xfa_expression.cpp", - "xfa/src/fxfa/fm2js/xfa_expression.h", - "xfa/src/fxfa/fm2js/xfa_fm2jsapi.cpp", - "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h", - "xfa/src/fxfa/fm2js/xfa_fm2jscontext.cpp", - "xfa/src/fxfa/fm2js/xfa_fm2jscontext.h", - "xfa/src/fxfa/fm2js/xfa_fmparse.cpp", - "xfa/src/fxfa/fm2js/xfa_fmparse.h", - "xfa/src/fxfa/fm2js/xfa_lexer.cpp", - "xfa/src/fxfa/fm2js/xfa_lexer.h", - "xfa/src/fxfa/fm2js/xfa_program.cpp", - "xfa/src/fxfa/fm2js/xfa_program.h", - "xfa/src/fxfa/fm2js/xfa_simpleexpression.cpp", - "xfa/src/fxfa/fm2js/xfa_simpleexpression.h", - "xfa/src/fxfa/parser/xfa_basic_data.cpp", - "xfa/src/fxfa/parser/xfa_basic_data.h", - "xfa/src/fxfa/parser/xfa_basic_imp.cpp", - "xfa/src/fxfa/parser/xfa_basic_imp.h", - "xfa/src/fxfa/parser/xfa_docdata.h", - "xfa/src/fxfa/parser/xfa_doclayout.h", - "xfa/src/fxfa/parser/xfa_document.h", - "xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_datadescription_imp.h", - "xfa/src/fxfa/parser/xfa_document_datamerger_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_datamerger_imp.h", - "xfa/src/fxfa/parser/xfa_document_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_layout_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_layout_imp.h", - "xfa/src/fxfa/parser/xfa_document_serialize.cpp", - "xfa/src/fxfa/parser/xfa_document_serialize.h", - "xfa/src/fxfa/parser/xfa_layout_appadapter.cpp", - "xfa/src/fxfa/parser/xfa_layout_appadapter.h", - "xfa/src/fxfa/parser/xfa_layout_itemlayout.cpp", - "xfa/src/fxfa/parser/xfa_layout_itemlayout.h", - "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.cpp", - "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h", - "xfa/src/fxfa/parser/xfa_locale.cpp", - "xfa/src/fxfa/parser/xfa_locale.h", - "xfa/src/fxfa/parser/xfa_localemgr.cpp", - "xfa/src/fxfa/parser/xfa_localemgr.h", - "xfa/src/fxfa/parser/xfa_localevalue.cpp", - "xfa/src/fxfa/parser/xfa_localevalue.h", - "xfa/src/fxfa/parser/xfa_object.h", - "xfa/src/fxfa/parser/xfa_object_imp.cpp", - "xfa/src/fxfa/parser/xfa_objectacc_imp.cpp", - "xfa/src/fxfa/parser/xfa_parser.h", - "xfa/src/fxfa/parser/xfa_parser_imp.cpp", - "xfa/src/fxfa/parser/xfa_parser_imp.h", - "xfa/src/fxfa/parser/xfa_script.h", - "xfa/src/fxfa/parser/xfa_script_datawindow.cpp", - "xfa/src/fxfa/parser/xfa_script_datawindow.h", - "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_imp.cpp", - "xfa/src/fxfa/parser/xfa_script_imp.h", - "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_logpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_logpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_nodehelper.cpp", - "xfa/src/fxfa/parser/xfa_script_nodehelper.h", - "xfa/src/fxfa/parser/xfa_script_resolveprocessor.cpp", - "xfa/src/fxfa/parser/xfa_script_resolveprocessor.h", - "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h", - "xfa/src/fxfa/parser/xfa_utils.h", - "xfa/src/fxfa/parser/xfa_utils_imp.cpp", - "xfa/src/fxgraphics/fx_graphics.cpp", - "xfa/src/fxgraphics/fx_path_generator.cpp", - "xfa/src/fxgraphics/fx_path_generator.h", - "xfa/src/fxgraphics/pre.h", ] include_dirs = [ "." ] if (pdf_enable_v8) { sources += [ - "xfa/src/fxjse/class.cpp", - "xfa/src/fxjse/class.h", - "xfa/src/fxjse/context.cpp", - "xfa/src/fxjse/context.h", - "xfa/src/fxjse/dynprop.cpp", - "xfa/src/fxjse/runtime.cpp", - "xfa/src/fxjse/runtime.h", - "xfa/src/fxjse/scope_inline.h", - "xfa/src/fxjse/util_inline.h", - "xfa/src/fxjse/value.cpp", - "xfa/src/fxjse/value.h", + "xfa/fxjse/class.cpp", + "xfa/fxjse/class.h", + "xfa/fxjse/context.cpp", + "xfa/fxjse/context.h", + "xfa/fxjse/dynprop.cpp", + "xfa/fxjse/runtime.cpp", + "xfa/fxjse/runtime.h", + "xfa/fxjse/scope_inline.h", + "xfa/fxjse/util_inline.h", + "xfa/fxjse/value.cpp", + "xfa/fxjse/value.h", ] include_dirs += [ "//v8", @@ -1473,8 +1473,8 @@ test("pdfium_unittests") { ] if (pdf_enable_xfa) { sources += [ - "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp", - "xfa/src/fxfa/parser/xfa_utils_imp_unittest.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp", + "xfa/fxfa/parser/xfa_utils_imp_unittest.cpp", ] } configs += [ ":pdfium_config" ] @@ -1502,7 +1502,7 @@ test("pdfium_embeddertests") { "testing/embedder_test.h", "testing/embedder_test_mock_delegate.h", "testing/embedder_test_timer_handling_delegate.h", - "xfa/src/fxfa/parser/xfa_parser_imp_embeddertest.cpp", + "xfa/fxfa/parser/xfa_parser_imp_embeddertest.cpp", ] deps = [ ":pdfium", diff --git a/fpdfsdk/javascript/JS_Runtime.cpp b/fpdfsdk/javascript/JS_Runtime.cpp index d56a8aca39..208348f24b 100644 --- a/fpdfsdk/javascript/JS_Runtime.cpp +++ b/fpdfsdk/javascript/JS_Runtime.cpp @@ -30,7 +30,7 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" -#include "xfa/src/fxjse/value.h" +#include "xfa/fxjse/value.h" #endif // PDF_ENABLE_XFA // static diff --git a/pdfium.gyp b/pdfium.gyp index d1ace6181c..a7cb00d689 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -836,8 +836,8 @@ 'conditions': [ ['pdf_enable_xfa==1', { 'sources': [ - 'xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp', - 'xfa/src/fxfa/parser/xfa_utils_imp_unittest.cpp', + 'xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp', + 'xfa/fxfa/parser/xfa_utils_imp_unittest.cpp', ], }], ], @@ -876,7 +876,7 @@ 'conditions': [ ['pdf_enable_xfa==1', { 'sources': [ - 'xfa/src/fxfa/parser/xfa_parser_imp_embeddertest.cpp', + 'xfa/fxfa/parser/xfa_parser_imp_embeddertest.cpp', ], }], ['pdf_enable_v8==1', { diff --git a/testing/libfuzzer/pdf_fm2js_fuzzer.cc b/testing/libfuzzer/pdf_fm2js_fuzzer.cc index 6a1b8207be..acbbf8fd94 100644 --- a/testing/libfuzzer/pdf_fm2js_fuzzer.cc +++ b/testing/libfuzzer/pdf_fm2js_fuzzer.cc @@ -7,7 +7,7 @@ #include "core/include/fxcrt/fx_basic.h" #include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fxfa/fm2js/xfa_program.h" +#include "xfa/fxfa/fm2js/xfa_program.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size > std::numeric_limits<FX_STRSIZE>::max()) diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc index bd36f72979..50187e6874 100644 --- a/testing/libfuzzer/pdf_xml_fuzzer.cc +++ b/testing/libfuzzer/pdf_xml_fuzzer.cc @@ -9,8 +9,8 @@ #include "core/include/fxcrt/fx_basic.h" #include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_parser_imp.h" +#include "xfa/fxfa/parser/xfa_parser.h" +#include "xfa/fxfa/parser/xfa_parser_imp.h" namespace { @@ -106,544 +106,544 @@ "xfa/include/fxfa/fxfa_widget.h", "xfa/include/fxgraphics/fx_graphics.h", "xfa/include/fxjse/fxjse.h", - "xfa/src/fde/css/fde_css.h", - "xfa/src/fde/css/fde_csscache.cpp", - "xfa/src/fde/css/fde_csscache.h", - "xfa/src/fde/css/fde_cssdatatable.cpp", - "xfa/src/fde/css/fde_cssdatatable.h", - "xfa/src/fde/css/fde_cssdeclaration.cpp", - "xfa/src/fde/css/fde_cssdeclaration.h", - "xfa/src/fde/css/fde_cssstyleselector.cpp", - "xfa/src/fde/css/fde_cssstyleselector.h", - "xfa/src/fde/css/fde_cssstylesheet.cpp", - "xfa/src/fde/css/fde_cssstylesheet.h", - "xfa/src/fde/css/fde_csssyntax.cpp", - "xfa/src/fde/css/fde_csssyntax.h", - "xfa/src/fde/fde_brush.h", - "xfa/src/fde/fde_devbasic.cpp", - "xfa/src/fde/fde_devbasic.h", - "xfa/src/fde/fde_renderdevice.h", - "xfa/src/fde/fde_gedevice.cpp", - "xfa/src/fde/fde_gedevice.h", - "xfa/src/fde/fde_geobject.cpp", - "xfa/src/fde/fde_geobject.h", - "xfa/src/fde/fde_image.h", - "xfa/src/fde/fde_iterator.cpp", - "xfa/src/fde/fde_iterator.h", - "xfa/src/fde/fde_object.cpp", - "xfa/src/fde/fde_object.h", - "xfa/src/fde/fde_path.h", - "xfa/src/fde/fde_pen.h", - "xfa/src/fde/fde_render.cpp", - "xfa/src/fde/fde_render.h", - "xfa/src/fde/tto/fde_textout.cpp", - "xfa/src/fde/tto/fde_textout.h", - "xfa/src/fde/xml/fde_xml.h", - "xfa/src/fde/xml/fde_xml_imp.cpp", - "xfa/src/fde/xml/fde_xml_imp.h", - "xfa/src/fee/fde_txtedtbuf.cpp", - "xfa/src/fee/fde_txtedtbuf.h", - "xfa/src/fee/fde_txtedtengine.cpp", - "xfa/src/fee/fde_txtedtengine.h", - "xfa/src/fee/fde_txtedtpage.cpp", - "xfa/src/fee/fde_txtedtpage.h", - "xfa/src/fee/fde_txtedtparag.cpp", - "xfa/src/fee/fde_txtedtparag.h", - "xfa/src/fee/fx_wordbreak/fx_wordbreak.h", - "xfa/src/fee/fx_wordbreak/fx_wordbreakdata.cpp", - "xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.cpp", - "xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h", - "xfa/src/fee/ifde_txtedtbuf.h", - "xfa/src/fee/ifde_txtedtengine.h", - "xfa/src/fee/ifde_txtedtpage.h", - "xfa/src/fgas/crt/fgas_algorithm.cpp", - "xfa/src/fgas/crt/fgas_algorithm.h", - "xfa/src/fgas/crt/fgas_codepage.cpp", - "xfa/src/fgas/crt/fgas_codepage.h", - "xfa/src/fgas/crt/fgas_encode.cpp", - "xfa/src/fgas/crt/fgas_language.h", - "xfa/src/fgas/crt/fgas_memory.cpp", - "xfa/src/fgas/crt/fgas_memory.h", - "xfa/src/fgas/crt/fgas_stream.cpp", - "xfa/src/fgas/crt/fgas_stream.h", - "xfa/src/fgas/crt/fgas_system.cpp", - "xfa/src/fgas/crt/fgas_system.h", - "xfa/src/fgas/crt/fgas_utils.cpp", - "xfa/src/fgas/crt/fgas_utils.h", - "xfa/src/fgas/font/fgas_font.h", - "xfa/src/fgas/font/fgas_fontutils.cpp", - "xfa/src/fgas/font/fgas_fontutils.h", - "xfa/src/fgas/font/fgas_gefont.cpp", - "xfa/src/fgas/font/fgas_gefont.h", - "xfa/src/fgas/font/fgas_stdfontmgr.cpp", - "xfa/src/fgas/font/fgas_stdfontmgr.h", - "xfa/src/fgas/layout/fgas_linebreak.cpp", - "xfa/src/fgas/layout/fgas_linebreak.h", - "xfa/src/fgas/layout/fgas_rtfbreak.cpp", - "xfa/src/fgas/layout/fgas_rtfbreak.h", - "xfa/src/fgas/layout/fgas_textbreak.cpp", - "xfa/src/fgas/layout/fgas_textbreak.h", - "xfa/src/fgas/layout/fgas_unicode.cpp", - "xfa/src/fgas/layout/fgas_unicode.h", - "xfa/src/fgas/localization/fgas_datetime.cpp", - "xfa/src/fgas/localization/fgas_datetime.h", - "xfa/src/fgas/localization/fgas_locale.cpp", - "xfa/src/fgas/localization/fgas_locale.h", - "xfa/src/fgas/localization/fgas_localeimp.h", - "xfa/src/fgas/localization/fgas_localemgr.cpp", - "xfa/src/fgas/localization/fgas_localemgr.h", - "xfa/src/fgas/xml/fgas_sax.h", - "xfa/src/fgas/xml/fgas_sax_imp.cpp", - "xfa/src/fgas/xml/fgas_sax_imp.h", - "xfa/src/fwl/basewidget/fwl_barcodeimp.cpp", - "xfa/src/fwl/basewidget/fwl_barcodeimp.h", - "xfa/src/fwl/basewidget/fwl_caretimp.cpp", - "xfa/src/fwl/basewidget/fwl_caretimp.h", - "xfa/src/fwl/basewidget/fwl_checkboximp.cpp", - "xfa/src/fwl/basewidget/fwl_checkboximp.h", - "xfa/src/fwl/basewidget/fwl_comboboximp.cpp", - "xfa/src/fwl/basewidget/fwl_comboboximp.h", - "xfa/src/fwl/basewidget/fwl_datetimepickerimp.cpp", - "xfa/src/fwl/basewidget/fwl_datetimepickerimp.h", - "xfa/src/fwl/basewidget/fwl_editimp.cpp", - "xfa/src/fwl/basewidget/fwl_editimp.h", - "xfa/src/fwl/basewidget/fwl_formproxyimp.cpp", - "xfa/src/fwl/basewidget/fwl_formproxyimp.h", - "xfa/src/fwl/basewidget/fwl_listboximp.cpp", - "xfa/src/fwl/basewidget/fwl_listboximp.h", - "xfa/src/fwl/basewidget/fwl_monthcalendarimp.cpp", - "xfa/src/fwl/basewidget/fwl_monthcalendarimp.h", - "xfa/src/fwl/basewidget/fwl_pictureboximp.cpp", - "xfa/src/fwl/basewidget/fwl_pictureboximp.h", - "xfa/src/fwl/basewidget/fwl_pushbuttonimp.cpp", - "xfa/src/fwl/basewidget/fwl_pushbuttonimp.h", - "xfa/src/fwl/basewidget/fwl_scrollbarimp.cpp", - "xfa/src/fwl/basewidget/fwl_scrollbarimp.h", - "xfa/src/fwl/basewidget/fwl_spinbuttonimp.cpp", - "xfa/src/fwl/basewidget/fwl_spinbuttonimp.h", - "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.cpp", - "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h", - "xfa/src/fwl/basewidget/fxmath_barcodeimp.cpp", - "xfa/src/fwl/basewidget/fxmath_barcodeimp.h", - "xfa/src/fwl/core/fwl_appimp.cpp", - "xfa/src/fwl/core/fwl_appimp.h", - "xfa/src/fwl/core/fwl_contentimp.cpp", - "xfa/src/fwl/core/fwl_contentimp.h", - "xfa/src/fwl/core/fwl_formimp.cpp", - "xfa/src/fwl/core/fwl_formimp.h", - "xfa/src/fwl/core/fwl_gridimp.cpp", - "xfa/src/fwl/core/fwl_gridimp.h", - "xfa/src/fwl/core/fwl_noteimp.cpp", - "xfa/src/fwl/core/fwl_noteimp.h", - "xfa/src/fwl/core/fwl_panelimp.cpp", - "xfa/src/fwl/core/fwl_panelimp.h", - "xfa/src/fwl/core/fwl_sdadapterimp.cpp", - "xfa/src/fwl/core/fwl_targetimp.cpp", - "xfa/src/fwl/core/fwl_targetimp.h", - "xfa/src/fwl/core/fwl_threadimp.cpp", - "xfa/src/fwl/core/fwl_threadimp.h", - "xfa/src/fwl/core/fwl_timerimp.cpp", - "xfa/src/fwl/core/fwl_widgetimp.cpp", - "xfa/src/fwl/core/fwl_widgetimp.h", - "xfa/src/fwl/core/fwl_widgetmgrimp.cpp", - "xfa/src/fwl/core/fwl_widgetmgrimp.h", - "xfa/src/fwl/lightwidget/app.cpp", - "xfa/src/fwl/lightwidget/barcode.cpp", - "xfa/src/fwl/lightwidget/caret.cpp", - "xfa/src/fwl/lightwidget/checkbox.cpp", - "xfa/src/fwl/lightwidget/combobox.cpp", - "xfa/src/fwl/lightwidget/datetimepicker.cpp", - "xfa/src/fwl/lightwidget/edit.cpp", - "xfa/src/fwl/lightwidget/listbox.cpp", - "xfa/src/fwl/lightwidget/picturebox.cpp", - "xfa/src/fwl/lightwidget/pushbutton.cpp", - "xfa/src/fwl/lightwidget/scrollbar.cpp", - "xfa/src/fwl/lightwidget/theme.cpp", - "xfa/src/fwl/lightwidget/tooltipctrl.cpp", - "xfa/src/fwl/lightwidget/widget.cpp", - "xfa/src/fwl/theme/barcodetp.cpp", - "xfa/src/fwl/theme/carettp.cpp", - "xfa/src/fwl/theme/checkboxtp.cpp", - "xfa/src/fwl/theme/comboboxtp.cpp", - "xfa/src/fwl/theme/datetimepickertp.cpp", - "xfa/src/fwl/theme/edittp.cpp", - "xfa/src/fwl/theme/formtp.cpp", - "xfa/src/fwl/theme/listboxtp.cpp", - "xfa/src/fwl/theme/monthcalendartp.cpp", - "xfa/src/fwl/theme/pictureboxtp.cpp", - "xfa/src/fwl/theme/pushbuttontp.cpp", - "xfa/src/fwl/theme/scrollbartp.cpp", - "xfa/src/fwl/theme/widgettp.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitArray.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitSource.cpp", - "xfa/src/fxbarcode/common/BC_CommonByteArray.cpp", - "xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp", - "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp", - "xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp", - "xfa/src/fxbarcode/common/BC_CommonECI.cpp", - "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp", - "xfa/src/fxbarcode/common/BC_CommonBitArray.h", - "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h", - "xfa/src/fxbarcode/common/BC_CommonBitSource.h", - "xfa/src/fxbarcode/common/BC_CommonByteArray.h", - "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h", - "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h", - "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h", - "xfa/src/fxbarcode/common/BC_CommonECI.h", - "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h", - "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp", - "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h", - "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp", - "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h", - "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h", - "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h", - "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.cpp", - "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.cpp", - "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.cpp", - "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp", - "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp", - "xfa/src/fxbarcode/datamatrix/BC_Encoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp", - "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h", - "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h", - "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h", - "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h", - "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h", - "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h", - "xfa/src/fxbarcode/datamatrix/BC_Encoder.h", - "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp", - "xfa/src/fxbarcode/oned/BC_OneDimReader.cpp", - "xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OneDReader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp", - "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h", - "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h", - "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h", - "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h", - "xfa/src/fxbarcode/oned/BC_OneDimReader.h", - "xfa/src/fxbarcode/oned/BC_OneDimWriter.h", - "xfa/src/fxbarcode/oned/BC_OneDReader.h", - "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h", - "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Common.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp", - "xfa/src/fxbarcode/pdf417/BC_PDF417.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h", - "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDataMask.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h", - "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h", - "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h", - "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h", - "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h", - "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h", - "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h", - "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h", - "xfa/src/fxbarcode/qrcode/BC_QRDetector.h", - "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h", - "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h", - "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h", - "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.cpp", - "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h", - "xfa/src/fxbarcode/BC_BarCode.cpp", - "xfa/src/fxbarcode/BC_Binarizer.cpp", - "xfa/src/fxbarcode/BC_BinaryBitmap.cpp", - "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp", - "xfa/src/fxbarcode/BC_Dimension.cpp", - "xfa/src/fxbarcode/BC_Library.cpp", - "xfa/src/fxbarcode/BC_LuminanceSource.cpp", - "xfa/src/fxbarcode/BC_Reader.cpp", - "xfa/src/fxbarcode/BC_ResultPoint.cpp", - "xfa/src/fxbarcode/BC_TwoDimWriter.cpp", - "xfa/src/fxbarcode/BC_UtilCodingConvert.cpp", - "xfa/src/fxbarcode/BC_UtilRSS.cpp", - "xfa/src/fxbarcode/BC_Utils.cpp", - "xfa/src/fxbarcode/BC_Writer.cpp", - "xfa/src/fxbarcode/BC_Binarizer.h", - "xfa/src/fxbarcode/BC_BinaryBitmap.h", - "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h", - "xfa/src/fxbarcode/BC_DecoderResult.h", - "xfa/src/fxbarcode/BC_Dimension.h", - "xfa/src/fxbarcode/BC_LuminanceSource.h", - "xfa/src/fxbarcode/BC_Reader.h", - "xfa/src/fxbarcode/BC_ResultPoint.h", - "xfa/src/fxbarcode/BC_TwoDimWriter.h", - "xfa/src/fxbarcode/BC_UtilCodingConvert.h", - "xfa/src/fxbarcode/BC_UtilRSS.h", - "xfa/src/fxbarcode/BC_Writer.h", - "xfa/src/fxbarcode/utils.h", - "xfa/src/fxfa/app/xfa_checksum.cpp", - "xfa/src/fxfa/app/xfa_checksum.h", - "xfa/src/fxfa/app/xfa_ffapp.cpp", - "xfa/src/fxfa/app/xfa_ffapp.h", - "xfa/src/fxfa/app/xfa_ffbarcode.cpp", - "xfa/src/fxfa/app/xfa_ffbarcode.h", - "xfa/src/fxfa/app/xfa_ffcheckbutton.cpp", - "xfa/src/fxfa/app/xfa_ffcheckbutton.h", - "xfa/src/fxfa/app/xfa_ffchoicelist.cpp", - "xfa/src/fxfa/app/xfa_ffchoicelist.h", - "xfa/src/fxfa/app/xfa_ffdoc.cpp", - "xfa/src/fxfa/app/xfa_ffdoc.h", - "xfa/src/fxfa/app/xfa_ffdochandler.cpp", - "xfa/src/fxfa/app/xfa_ffdochandler.h", - "xfa/src/fxfa/app/xfa_ffdocview.cpp", - "xfa/src/fxfa/app/xfa_ffdocview.h", - "xfa/src/fxfa/app/xfa_ffdraw.cpp", - "xfa/src/fxfa/app/xfa_ffdraw.h", - "xfa/src/fxfa/app/xfa_ffexclgroup.cpp", - "xfa/src/fxfa/app/xfa_ffexclgroup.h", - "xfa/src/fxfa/app/xfa_fffield.cpp", - "xfa/src/fxfa/app/xfa_fffield.h", - "xfa/src/fxfa/app/xfa_ffimage.cpp", - "xfa/src/fxfa/app/xfa_ffimage.h", - "xfa/src/fxfa/app/xfa_ffimageedit.cpp", - "xfa/src/fxfa/app/xfa_ffimageedit.h", - "xfa/src/fxfa/app/xfa_ffnotify.cpp", - "xfa/src/fxfa/app/xfa_ffnotify.h", - "xfa/src/fxfa/app/xfa_ffpageview.cpp", - "xfa/src/fxfa/app/xfa_ffpageview.h", - "xfa/src/fxfa/app/xfa_ffpath.cpp", - "xfa/src/fxfa/app/xfa_ffpath.h", - "xfa/src/fxfa/app/xfa_ffpushbutton.cpp", - "xfa/src/fxfa/app/xfa_ffpushbutton.h", - "xfa/src/fxfa/app/xfa_ffsignature.cpp", - "xfa/src/fxfa/app/xfa_ffsignature.h", - "xfa/src/fxfa/app/xfa_ffsubform.cpp", - "xfa/src/fxfa/app/xfa_ffsubform.h", - "xfa/src/fxfa/app/xfa_fftext.cpp", - "xfa/src/fxfa/app/xfa_fftext.h", - "xfa/src/fxfa/app/xfa_fftextedit.cpp", - "xfa/src/fxfa/app/xfa_fftextedit.h", - "xfa/src/fxfa/app/xfa_ffwidget.cpp", - "xfa/src/fxfa/app/xfa_ffwidget.h", - "xfa/src/fxfa/app/xfa_ffwidgetacc.cpp", - "xfa/src/fxfa/app/xfa_ffwidgetacc.h", - "xfa/src/fxfa/app/xfa_ffwidgethandler.cpp", - "xfa/src/fxfa/app/xfa_ffwidgethandler.h", - "xfa/src/fxfa/app/xfa_fontmgr.cpp", - "xfa/src/fxfa/app/xfa_fontmgr.h", - "xfa/src/fxfa/app/xfa_fwladapter.cpp", - "xfa/src/fxfa/app/xfa_fwladapter.h", - "xfa/src/fxfa/app/xfa_fwltheme.cpp", - "xfa/src/fxfa/app/xfa_fwltheme.h", - "xfa/src/fxfa/app/xfa_rendercontext.cpp", - "xfa/src/fxfa/app/xfa_rendercontext.h", - "xfa/src/fxfa/app/xfa_textlayout.cpp", - "xfa/src/fxfa/app/xfa_textlayout.h", - "xfa/src/fxfa/fm2js/xfa_error.cpp", - "xfa/src/fxfa/fm2js/xfa_error.h", - "xfa/src/fxfa/fm2js/xfa_expression.cpp", - "xfa/src/fxfa/fm2js/xfa_expression.h", - "xfa/src/fxfa/fm2js/xfa_fm2jsapi.cpp", - "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h", - "xfa/src/fxfa/fm2js/xfa_fm2jscontext.cpp", - "xfa/src/fxfa/fm2js/xfa_fm2jscontext.h", - "xfa/src/fxfa/fm2js/xfa_fmparse.cpp", - "xfa/src/fxfa/fm2js/xfa_fmparse.h", - "xfa/src/fxfa/fm2js/xfa_lexer.cpp", - "xfa/src/fxfa/fm2js/xfa_lexer.h", - "xfa/src/fxfa/fm2js/xfa_program.cpp", - "xfa/src/fxfa/fm2js/xfa_program.h", - "xfa/src/fxfa/fm2js/xfa_simpleexpression.cpp", - "xfa/src/fxfa/fm2js/xfa_simpleexpression.h", - "xfa/src/fxfa/parser/xfa_basic_data.cpp", - "xfa/src/fxfa/parser/xfa_basic_data.h", - "xfa/src/fxfa/parser/xfa_basic_imp.cpp", - "xfa/src/fxfa/parser/xfa_basic_imp.h", - "xfa/src/fxfa/parser/xfa_docdata.h", - "xfa/src/fxfa/parser/xfa_doclayout.h", - "xfa/src/fxfa/parser/xfa_document.h", - "xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_datadescription_imp.h", - "xfa/src/fxfa/parser/xfa_document_datamerger_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_datamerger_imp.h", - "xfa/src/fxfa/parser/xfa_document_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_layout_imp.cpp", - "xfa/src/fxfa/parser/xfa_document_layout_imp.h", - "xfa/src/fxfa/parser/xfa_document_serialize.cpp", - "xfa/src/fxfa/parser/xfa_document_serialize.h", - "xfa/src/fxfa/parser/xfa_layout_appadapter.cpp", - "xfa/src/fxfa/parser/xfa_layout_appadapter.h", - "xfa/src/fxfa/parser/xfa_layout_itemlayout.cpp", - "xfa/src/fxfa/parser/xfa_layout_itemlayout.h", - "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.cpp", - "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h", - "xfa/src/fxfa/parser/xfa_locale.cpp", - "xfa/src/fxfa/parser/xfa_locale.h", - "xfa/src/fxfa/parser/xfa_localemgr.cpp", - "xfa/src/fxfa/parser/xfa_localemgr.h", - "xfa/src/fxfa/parser/xfa_localevalue.cpp", - "xfa/src/fxfa/parser/xfa_localevalue.h", - "xfa/src/fxfa/parser/xfa_object.h", - "xfa/src/fxfa/parser/xfa_objectacc_imp.cpp", - "xfa/src/fxfa/parser/xfa_object_imp.cpp", - "xfa/src/fxfa/parser/xfa_parser.h", - "xfa/src/fxfa/parser/xfa_parser_imp.cpp", - "xfa/src/fxfa/parser/xfa_parser_imp.h", - "xfa/src/fxfa/parser/xfa_script.h", - "xfa/src/fxfa/parser/xfa_script_datawindow.cpp", - "xfa/src/fxfa/parser/xfa_script_datawindow.h", - "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_imp.cpp", - "xfa/src/fxfa/parser/xfa_script_imp.h", - "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_logpseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_logpseudomodel.h", - "xfa/src/fxfa/parser/xfa_script_nodehelper.cpp", - "xfa/src/fxfa/parser/xfa_script_nodehelper.h", - "xfa/src/fxfa/parser/xfa_script_resolveprocessor.cpp", - "xfa/src/fxfa/parser/xfa_script_resolveprocessor.h", - "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.cpp", - "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h", - "xfa/src/fxfa/parser/xfa_utils.h", - "xfa/src/fxfa/parser/xfa_utils_imp.cpp", - "xfa/src/fxgraphics/fx_graphics.cpp", - "xfa/src/fxgraphics/fx_path_generator.cpp", - "xfa/src/fxgraphics/fx_path_generator.h", - "xfa/src/fxgraphics/pre.h", + "xfa/fde/css/fde_css.h", + "xfa/fde/css/fde_csscache.cpp", + "xfa/fde/css/fde_csscache.h", + "xfa/fde/css/fde_cssdatatable.cpp", + "xfa/fde/css/fde_cssdatatable.h", + "xfa/fde/css/fde_cssdeclaration.cpp", + "xfa/fde/css/fde_cssdeclaration.h", + "xfa/fde/css/fde_cssstyleselector.cpp", + "xfa/fde/css/fde_cssstyleselector.h", + "xfa/fde/css/fde_cssstylesheet.cpp", + "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/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", + "xfa/fde/tto/fde_textout.h", + "xfa/fde/xml/fde_xml.h", + "xfa/fde/xml/fde_xml_imp.cpp", + "xfa/fde/xml/fde_xml_imp.h", + "xfa/fee/fde_txtedtbuf.cpp", + "xfa/fee/fde_txtedtbuf.h", + "xfa/fee/fde_txtedtengine.cpp", + "xfa/fee/fde_txtedtengine.h", + "xfa/fee/fde_txtedtpage.cpp", + "xfa/fee/fde_txtedtpage.h", + "xfa/fee/fde_txtedtparag.cpp", + "xfa/fee/fde_txtedtparag.h", + "xfa/fee/fx_wordbreak/fx_wordbreak.h", + "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", + "xfa/fgas/crt/fgas_algorithm.h", + "xfa/fgas/crt/fgas_codepage.cpp", + "xfa/fgas/crt/fgas_codepage.h", + "xfa/fgas/crt/fgas_encode.cpp", + "xfa/fgas/crt/fgas_language.h", + "xfa/fgas/crt/fgas_memory.cpp", + "xfa/fgas/crt/fgas_memory.h", + "xfa/fgas/crt/fgas_stream.cpp", + "xfa/fgas/crt/fgas_stream.h", + "xfa/fgas/crt/fgas_system.cpp", + "xfa/fgas/crt/fgas_system.h", + "xfa/fgas/crt/fgas_utils.cpp", + "xfa/fgas/crt/fgas_utils.h", + "xfa/fgas/font/fgas_font.h", + "xfa/fgas/font/fgas_fontutils.cpp", + "xfa/fgas/font/fgas_fontutils.h", + "xfa/fgas/font/fgas_gefont.cpp", + "xfa/fgas/font/fgas_gefont.h", + "xfa/fgas/font/fgas_stdfontmgr.cpp", + "xfa/fgas/font/fgas_stdfontmgr.h", + "xfa/fgas/layout/fgas_linebreak.cpp", + "xfa/fgas/layout/fgas_linebreak.h", + "xfa/fgas/layout/fgas_rtfbreak.cpp", + "xfa/fgas/layout/fgas_rtfbreak.h", + "xfa/fgas/layout/fgas_textbreak.cpp", + "xfa/fgas/layout/fgas_textbreak.h", + "xfa/fgas/layout/fgas_unicode.cpp", + "xfa/fgas/layout/fgas_unicode.h", + "xfa/fgas/localization/fgas_datetime.cpp", + "xfa/fgas/localization/fgas_datetime.h", + "xfa/fgas/localization/fgas_locale.cpp", + "xfa/fgas/localization/fgas_locale.h", + "xfa/fgas/localization/fgas_localeimp.h", + "xfa/fgas/localization/fgas_localemgr.cpp", + "xfa/fgas/localization/fgas_localemgr.h", + "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", + "xfa/fwl/basewidget/fwl_caretimp.h", + "xfa/fwl/basewidget/fwl_checkboximp.cpp", + "xfa/fwl/basewidget/fwl_checkboximp.h", + "xfa/fwl/basewidget/fwl_comboboximp.cpp", + "xfa/fwl/basewidget/fwl_comboboximp.h", + "xfa/fwl/basewidget/fwl_datetimepickerimp.cpp", + "xfa/fwl/basewidget/fwl_datetimepickerimp.h", + "xfa/fwl/basewidget/fwl_editimp.cpp", + "xfa/fwl/basewidget/fwl_editimp.h", + "xfa/fwl/basewidget/fwl_formproxyimp.cpp", + "xfa/fwl/basewidget/fwl_formproxyimp.h", + "xfa/fwl/basewidget/fwl_listboximp.cpp", + "xfa/fwl/basewidget/fwl_listboximp.h", + "xfa/fwl/basewidget/fwl_monthcalendarimp.cpp", + "xfa/fwl/basewidget/fwl_monthcalendarimp.h", + "xfa/fwl/basewidget/fwl_pictureboximp.cpp", + "xfa/fwl/basewidget/fwl_pictureboximp.h", + "xfa/fwl/basewidget/fwl_pushbuttonimp.cpp", + "xfa/fwl/basewidget/fwl_pushbuttonimp.h", + "xfa/fwl/basewidget/fwl_scrollbarimp.cpp", + "xfa/fwl/basewidget/fwl_scrollbarimp.h", + "xfa/fwl/basewidget/fwl_spinbuttonimp.cpp", + "xfa/fwl/basewidget/fwl_spinbuttonimp.h", + "xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp", + "xfa/fwl/basewidget/fwl_tooltipctrlimp.h", + "xfa/fwl/basewidget/fxmath_barcodeimp.cpp", + "xfa/fwl/basewidget/fxmath_barcodeimp.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_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_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_widgetimp.cpp", + "xfa/fwl/core/fwl_widgetimp.h", + "xfa/fwl/core/fwl_widgetmgrimp.cpp", + "xfa/fwl/core/fwl_widgetmgrimp.h", + "xfa/fwl/lightwidget/app.cpp", + "xfa/fwl/lightwidget/barcode.cpp", + "xfa/fwl/lightwidget/caret.cpp", + "xfa/fwl/lightwidget/checkbox.cpp", + "xfa/fwl/lightwidget/combobox.cpp", + "xfa/fwl/lightwidget/datetimepicker.cpp", + "xfa/fwl/lightwidget/edit.cpp", + "xfa/fwl/lightwidget/listbox.cpp", + "xfa/fwl/lightwidget/picturebox.cpp", + "xfa/fwl/lightwidget/pushbutton.cpp", + "xfa/fwl/lightwidget/scrollbar.cpp", + "xfa/fwl/lightwidget/theme.cpp", + "xfa/fwl/lightwidget/tooltipctrl.cpp", + "xfa/fwl/lightwidget/widget.cpp", + "xfa/fwl/theme/barcodetp.cpp", + "xfa/fwl/theme/carettp.cpp", + "xfa/fwl/theme/checkboxtp.cpp", + "xfa/fwl/theme/comboboxtp.cpp", + "xfa/fwl/theme/datetimepickertp.cpp", + "xfa/fwl/theme/edittp.cpp", + "xfa/fwl/theme/formtp.cpp", + "xfa/fwl/theme/listboxtp.cpp", + "xfa/fwl/theme/monthcalendartp.cpp", + "xfa/fwl/theme/pictureboxtp.cpp", + "xfa/fwl/theme/pushbuttontp.cpp", + "xfa/fwl/theme/scrollbartp.cpp", + "xfa/fwl/theme/widgettp.cpp", + "xfa/fxbarcode/common/BC_CommonBitArray.cpp", + "xfa/fxbarcode/common/BC_CommonBitMatrix.cpp", + "xfa/fxbarcode/common/BC_CommonBitSource.cpp", + "xfa/fxbarcode/common/BC_CommonByteArray.cpp", + "xfa/fxbarcode/common/BC_CommonByteMatrix.cpp", + "xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp", + "xfa/fxbarcode/common/BC_CommonDecoderResult.cpp", + "xfa/fxbarcode/common/BC_CommonECI.cpp", + "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.cpp", + "xfa/fxbarcode/common/BC_CommonBitArray.h", + "xfa/fxbarcode/common/BC_CommonBitMatrix.h", + "xfa/fxbarcode/common/BC_CommonBitSource.h", + "xfa/fxbarcode/common/BC_CommonByteArray.h", + "xfa/fxbarcode/common/BC_CommonByteMatrix.h", + "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h", + "xfa/fxbarcode/common/BC_CommonDecoderResult.h", + "xfa/fxbarcode/common/BC_CommonECI.h", + "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h", + "xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp", + "xfa/fxbarcode/common/BC_WhiteRectangleDetector.h", + "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp", + "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h", + "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp", + "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h", + "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h", + "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_Base256Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp", + "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp", + "xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp", + "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp", + "xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.cpp", + "xfa/fxbarcode/datamatrix/BC_Encoder.cpp", + "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp", + "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h", + "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h", + "xfa/fxbarcode/datamatrix/BC_C40Encoder.h", + "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h", + "xfa/fxbarcode/datamatrix/BC_EncoderContext.h", + "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h", + "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h", + "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h", + "xfa/fxbarcode/datamatrix/BC_TextEncoder.h", + "xfa/fxbarcode/datamatrix/BC_X12Encoder.h", + "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h", + "xfa/fxbarcode/datamatrix/BC_Encoder.h", + "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h", + "xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp", + "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp", + "xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedCode39Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN13Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN8Reader.cpp", + "xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp", + "xfa/fxbarcode/oned/BC_OneDimReader.cpp", + "xfa/fxbarcode/oned/BC_OneDimWriter.cpp", + "xfa/fxbarcode/oned/BC_OneDReader.cpp", + "xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp", + "xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp", + "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h", + "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h", + "xfa/fxbarcode/oned/BC_OnedCode128Reader.h", + "xfa/fxbarcode/oned/BC_OnedCode128Writer.h", + "xfa/fxbarcode/oned/BC_OnedCode39Reader.h", + "xfa/fxbarcode/oned/BC_OnedCode39Writer.h", + "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h", + "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h", + "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h", + "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h", + "xfa/fxbarcode/oned/BC_OneDimReader.h", + "xfa/fxbarcode/oned/BC_OneDimWriter.h", + "xfa/fxbarcode/oned/BC_OneDReader.h", + "xfa/fxbarcode/oned/BC_OnedUPCAReader.h", + "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h", + "xfa/fxbarcode/pdf417/BC_PDF417.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Codeword.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Common.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Compaction.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Dimensions.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp", + "xfa/fxbarcode/pdf417/BC_PDF417.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h", + "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h", + "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h", + "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h", + "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Common.h", + "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h", + "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h", + "xfa/fxbarcode/pdf417/BC_PDF417Detector.h", + "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h", + "xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h", + "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h", + "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h", + "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Reader.h", + "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h", + "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h", + "xfa/fxbarcode/pdf417/BC_PDF417Writer.h", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp", + "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderECB.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp", + "xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp", + "xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp", + "xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp", + "xfa/fxbarcode/qrcode/BC_QRDataMask.cpp", + "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp", + "xfa/fxbarcode/qrcode/BC_QRDetector.cpp", + "xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp", + "xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp", + "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp", + "xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h", + "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h", + "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h", + "xfa/fxbarcode/qrcode/BC_QRCoder.h", + "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h", + "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h", + "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h", + "xfa/fxbarcode/qrcode/BC_QRCodeReader.h", + "xfa/fxbarcode/qrcode/BC_QRCoderECB.h", + "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h", + "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h", + "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h", + "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h", + "xfa/fxbarcode/qrcode/BC_QRCoderMode.h", + "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h", + "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h", + "xfa/fxbarcode/qrcode/BC_QRDataBlock.h", + "xfa/fxbarcode/qrcode/BC_QRDataMask.h", + "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h", + "xfa/fxbarcode/qrcode/BC_QRDetector.h", + "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h", + "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h", + "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h", + "xfa/fxbarcode/qrcode/BC_QRGridSampler.h", + "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp", + "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h", + "xfa/fxbarcode/BC_BarCode.cpp", + "xfa/fxbarcode/BC_Binarizer.cpp", + "xfa/fxbarcode/BC_BinaryBitmap.cpp", + "xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp", + "xfa/fxbarcode/BC_Dimension.cpp", + "xfa/fxbarcode/BC_Library.cpp", + "xfa/fxbarcode/BC_LuminanceSource.cpp", + "xfa/fxbarcode/BC_Reader.cpp", + "xfa/fxbarcode/BC_ResultPoint.cpp", + "xfa/fxbarcode/BC_TwoDimWriter.cpp", + "xfa/fxbarcode/BC_UtilCodingConvert.cpp", + "xfa/fxbarcode/BC_UtilRSS.cpp", + "xfa/fxbarcode/BC_Utils.cpp", + "xfa/fxbarcode/BC_Writer.cpp", + "xfa/fxbarcode/BC_Binarizer.h", + "xfa/fxbarcode/BC_BinaryBitmap.h", + "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h", + "xfa/fxbarcode/BC_DecoderResult.h", + "xfa/fxbarcode/BC_Dimension.h", + "xfa/fxbarcode/BC_LuminanceSource.h", + "xfa/fxbarcode/BC_Reader.h", + "xfa/fxbarcode/BC_ResultPoint.h", + "xfa/fxbarcode/BC_TwoDimWriter.h", + "xfa/fxbarcode/BC_UtilCodingConvert.h", + "xfa/fxbarcode/BC_UtilRSS.h", + "xfa/fxbarcode/BC_Writer.h", + "xfa/fxbarcode/utils.h", + "xfa/fxfa/app/xfa_checksum.cpp", + "xfa/fxfa/app/xfa_checksum.h", + "xfa/fxfa/app/xfa_ffapp.cpp", + "xfa/fxfa/app/xfa_ffapp.h", + "xfa/fxfa/app/xfa_ffbarcode.cpp", + "xfa/fxfa/app/xfa_ffbarcode.h", + "xfa/fxfa/app/xfa_ffcheckbutton.cpp", + "xfa/fxfa/app/xfa_ffcheckbutton.h", + "xfa/fxfa/app/xfa_ffchoicelist.cpp", + "xfa/fxfa/app/xfa_ffchoicelist.h", + "xfa/fxfa/app/xfa_ffdoc.cpp", + "xfa/fxfa/app/xfa_ffdoc.h", + "xfa/fxfa/app/xfa_ffdochandler.cpp", + "xfa/fxfa/app/xfa_ffdochandler.h", + "xfa/fxfa/app/xfa_ffdocview.cpp", + "xfa/fxfa/app/xfa_ffdocview.h", + "xfa/fxfa/app/xfa_ffdraw.cpp", + "xfa/fxfa/app/xfa_ffdraw.h", + "xfa/fxfa/app/xfa_ffexclgroup.cpp", + "xfa/fxfa/app/xfa_ffexclgroup.h", + "xfa/fxfa/app/xfa_fffield.cpp", + "xfa/fxfa/app/xfa_fffield.h", + "xfa/fxfa/app/xfa_ffimage.cpp", + "xfa/fxfa/app/xfa_ffimage.h", + "xfa/fxfa/app/xfa_ffimageedit.cpp", + "xfa/fxfa/app/xfa_ffimageedit.h", + "xfa/fxfa/app/xfa_ffnotify.cpp", + "xfa/fxfa/app/xfa_ffnotify.h", + "xfa/fxfa/app/xfa_ffpageview.cpp", + "xfa/fxfa/app/xfa_ffpageview.h", + "xfa/fxfa/app/xfa_ffpath.cpp", + "xfa/fxfa/app/xfa_ffpath.h", + "xfa/fxfa/app/xfa_ffpushbutton.cpp", + "xfa/fxfa/app/xfa_ffpushbutton.h", + "xfa/fxfa/app/xfa_ffsignature.cpp", + "xfa/fxfa/app/xfa_ffsignature.h", + "xfa/fxfa/app/xfa_ffsubform.cpp", + "xfa/fxfa/app/xfa_ffsubform.h", + "xfa/fxfa/app/xfa_fftext.cpp", + "xfa/fxfa/app/xfa_fftext.h", + "xfa/fxfa/app/xfa_fftextedit.cpp", + "xfa/fxfa/app/xfa_fftextedit.h", + "xfa/fxfa/app/xfa_ffwidget.cpp", + "xfa/fxfa/app/xfa_ffwidget.h", + "xfa/fxfa/app/xfa_ffwidgetacc.cpp", + "xfa/fxfa/app/xfa_ffwidgetacc.h", + "xfa/fxfa/app/xfa_ffwidgethandler.cpp", + "xfa/fxfa/app/xfa_ffwidgethandler.h", + "xfa/fxfa/app/xfa_fontmgr.cpp", + "xfa/fxfa/app/xfa_fontmgr.h", + "xfa/fxfa/app/xfa_fwladapter.cpp", + "xfa/fxfa/app/xfa_fwladapter.h", + "xfa/fxfa/app/xfa_fwltheme.cpp", + "xfa/fxfa/app/xfa_fwltheme.h", + "xfa/fxfa/app/xfa_rendercontext.cpp", + "xfa/fxfa/app/xfa_rendercontext.h", + "xfa/fxfa/app/xfa_textlayout.cpp", + "xfa/fxfa/app/xfa_textlayout.h", + "xfa/fxfa/fm2js/xfa_error.cpp", + "xfa/fxfa/fm2js/xfa_error.h", + "xfa/fxfa/fm2js/xfa_expression.cpp", + "xfa/fxfa/fm2js/xfa_expression.h", + "xfa/fxfa/fm2js/xfa_fm2jsapi.cpp", + "xfa/fxfa/fm2js/xfa_fm2jsapi.h", + "xfa/fxfa/fm2js/xfa_fm2jscontext.cpp", + "xfa/fxfa/fm2js/xfa_fm2jscontext.h", + "xfa/fxfa/fm2js/xfa_fmparse.cpp", + "xfa/fxfa/fm2js/xfa_fmparse.h", + "xfa/fxfa/fm2js/xfa_lexer.cpp", + "xfa/fxfa/fm2js/xfa_lexer.h", + "xfa/fxfa/fm2js/xfa_program.cpp", + "xfa/fxfa/fm2js/xfa_program.h", + "xfa/fxfa/fm2js/xfa_simpleexpression.cpp", + "xfa/fxfa/fm2js/xfa_simpleexpression.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", + "xfa/fxfa/parser/xfa_document_datadescription_imp.h", + "xfa/fxfa/parser/xfa_document_datamerger_imp.cpp", + "xfa/fxfa/parser/xfa_document_datamerger_imp.h", + "xfa/fxfa/parser/xfa_document_imp.cpp", + "xfa/fxfa/parser/xfa_document_layout_imp.cpp", + "xfa/fxfa/parser/xfa_document_layout_imp.h", + "xfa/fxfa/parser/xfa_document_serialize.cpp", + "xfa/fxfa/parser/xfa_document_serialize.h", + "xfa/fxfa/parser/xfa_layout_appadapter.cpp", + "xfa/fxfa/parser/xfa_layout_appadapter.h", + "xfa/fxfa/parser/xfa_layout_itemlayout.cpp", + "xfa/fxfa/parser/xfa_layout_itemlayout.h", + "xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp", + "xfa/fxfa/parser/xfa_layout_pagemgr_new.h", + "xfa/fxfa/parser/xfa_locale.cpp", + "xfa/fxfa/parser/xfa_locale.h", + "xfa/fxfa/parser/xfa_localemgr.cpp", + "xfa/fxfa/parser/xfa_localemgr.h", + "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", + "xfa/fxfa/parser/xfa_parser_imp.h", + "xfa/fxfa/parser/xfa_script.h", + "xfa/fxfa/parser/xfa_script_datawindow.cpp", + "xfa/fxfa/parser/xfa_script_datawindow.h", + "xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_eventpseudomodel.h", + "xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_hostpseudomodel.h", + "xfa/fxfa/parser/xfa_script_imp.cpp", + "xfa/fxfa/parser/xfa_script_imp.h", + "xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h", + "xfa/fxfa/parser/xfa_script_logpseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_logpseudomodel.h", + "xfa/fxfa/parser/xfa_script_nodehelper.cpp", + "xfa/fxfa/parser/xfa_script_nodehelper.h", + "xfa/fxfa/parser/xfa_script_resolveprocessor.cpp", + "xfa/fxfa/parser/xfa_script_resolveprocessor.h", + "xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp", + "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h", + "xfa/fxfa/parser/xfa_utils.h", + "xfa/fxfa/parser/xfa_utils_imp.cpp", + "xfa/fxgraphics/fx_graphics.cpp", + "xfa/fxgraphics/fx_path_generator.cpp", + "xfa/fxgraphics/fx_path_generator.h", + "xfa/fxgraphics/pre.h", ], "conditions": [ ["clang==1" , { @@ -660,17 +660,17 @@ '<(DEPTH)/v8/include', ], 'sources': [ - "xfa/src/fxjse/class.cpp", - "xfa/src/fxjse/class.h", - "xfa/src/fxjse/context.cpp", - "xfa/src/fxjse/context.h", - "xfa/src/fxjse/dynprop.cpp", - "xfa/src/fxjse/runtime.cpp", - "xfa/src/fxjse/runtime.h", - "xfa/src/fxjse/scope_inline.h", - "xfa/src/fxjse/util_inline.h", - "xfa/src/fxjse/value.cpp", - "xfa/src/fxjse/value.h" + "xfa/fxjse/class.cpp", + "xfa/fxjse/class.h", + "xfa/fxjse/context.cpp", + "xfa/fxjse/context.h", + "xfa/fxjse/dynprop.cpp", + "xfa/fxjse/runtime.cpp", + "xfa/fxjse/runtime.h", + "xfa/fxjse/scope_inline.h", + "xfa/fxjse/util_inline.h", + "xfa/fxjse/value.cpp", + "xfa/fxjse/value.h" ], }], ["OS == 'win'", { diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h new file mode 100644 index 0000000000..4c3e253167 --- /dev/null +++ b/xfa/fde/css/fde_css.h @@ -0,0 +1,1082 @@ +// 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_CSS_FDE_CSS_H_ +#define XFA_FDE_CSS_FDE_CSS_H_ + +#include "core/include/fxge/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 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; + +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, + FDE_CSSPRIMITIVETYPE_Percent = 2, + FDE_CSSPRIMITIVETYPE_EMS = 3, + FDE_CSSPRIMITIVETYPE_EXS = 4, + FDE_CSSPRIMITIVETYPE_PX = 5, + FDE_CSSPRIMITIVETYPE_CM = 6, + FDE_CSSPRIMITIVETYPE_MM = 7, + FDE_CSSPRIMITIVETYPE_IN = 8, + FDE_CSSPRIMITIVETYPE_PT = 9, + FDE_CSSPRIMITIVETYPE_PC = 10, + FDE_CSSPRIMITIVETYPE_String = 19, + FDE_CSSPRIMITIVETYPE_URI = 20, + FDE_CSSPRIMITIVETYPE_RGB = 25, + FDE_CSSPRIMITIVETYPE_Enum, + FDE_CSSPRIMITIVETYPE_Function, +}; +enum FDE_CSSPROPERTYVALUE { + FDE_CSSPROPERTYVALUE_Bolder, + FDE_CSSPROPERTYVALUE_LowerLatin, + FDE_CSSPROPERTYVALUE_Lowercase, + FDE_CSSPROPERTYVALUE_LowerGreek, + FDE_CSSPROPERTYVALUE_Sesame, + FDE_CSSPROPERTYVALUE_None, + FDE_CSSPROPERTYVALUE_NwResize, + FDE_CSSPROPERTYVALUE_WResize, + FDE_CSSPROPERTYVALUE_Dot, + FDE_CSSPROPERTYVALUE_End, + FDE_CSSPROPERTYVALUE_Ltr, + FDE_CSSPROPERTYVALUE_Pre, + FDE_CSSPROPERTYVALUE_Rtl, + FDE_CSSPROPERTYVALUE_Sub, + FDE_CSSPROPERTYVALUE_Top, + FDE_CSSPROPERTYVALUE_Visible, + FDE_CSSPROPERTYVALUE_Filled, + FDE_CSSPROPERTYVALUE_SwResize, + FDE_CSSPROPERTYVALUE_NoRepeat, + FDE_CSSPROPERTYVALUE_Default, + FDE_CSSPROPERTYVALUE_Transparent, + FDE_CSSPROPERTYVALUE_Ridge, + FDE_CSSPROPERTYVALUE_Right, + FDE_CSSPROPERTYVALUE_HorizontalTb, + FDE_CSSPROPERTYVALUE_DistributeLetter, + FDE_CSSPROPERTYVALUE_DoubleCircle, + FDE_CSSPROPERTYVALUE_Ruby, + FDE_CSSPROPERTYVALUE_Collapse, + FDE_CSSPROPERTYVALUE_Normal, + FDE_CSSPROPERTYVALUE_Avoid, + FDE_CSSPROPERTYVALUE_UpperRoman, + FDE_CSSPROPERTYVALUE_Auto, + FDE_CSSPROPERTYVALUE_Text, + FDE_CSSPROPERTYVALUE_XSmall, + FDE_CSSPROPERTYVALUE_Thin, + FDE_CSSPROPERTYVALUE_Repeat, + FDE_CSSPROPERTYVALUE_Small, + FDE_CSSPROPERTYVALUE_NeResize, + FDE_CSSPROPERTYVALUE_NoContent, + FDE_CSSPROPERTYVALUE_Outside, + FDE_CSSPROPERTYVALUE_EResize, + FDE_CSSPROPERTYVALUE_TableRow, + FDE_CSSPROPERTYVALUE_Bottom, + FDE_CSSPROPERTYVALUE_Underline, + FDE_CSSPROPERTYVALUE_CjkIdeographic, + FDE_CSSPROPERTYVALUE_SeResize, + FDE_CSSPROPERTYVALUE_Fixed, + FDE_CSSPROPERTYVALUE_Double, + FDE_CSSPROPERTYVALUE_Solid, + FDE_CSSPROPERTYVALUE_RubyBaseGroup, + FDE_CSSPROPERTYVALUE_OpenQuote, + FDE_CSSPROPERTYVALUE_Lighter, + FDE_CSSPROPERTYVALUE_LowerRoman, + FDE_CSSPROPERTYVALUE_Strict, + FDE_CSSPROPERTYVALUE_TableCaption, + FDE_CSSPROPERTYVALUE_Oblique, + FDE_CSSPROPERTYVALUE_Decimal, + FDE_CSSPROPERTYVALUE_Loose, + FDE_CSSPROPERTYVALUE_Hebrew, + FDE_CSSPROPERTYVALUE_Hidden, + FDE_CSSPROPERTYVALUE_Dashed, + FDE_CSSPROPERTYVALUE_Embed, + FDE_CSSPROPERTYVALUE_TableRowGroup, + FDE_CSSPROPERTYVALUE_TableColumn, + FDE_CSSPROPERTYVALUE_Static, + FDE_CSSPROPERTYVALUE_Outset, + FDE_CSSPROPERTYVALUE_DecimalLeadingZero, + FDE_CSSPROPERTYVALUE_KeepWords, + FDE_CSSPROPERTYVALUE_KatakanaIroha, + FDE_CSSPROPERTYVALUE_Super, + FDE_CSSPROPERTYVALUE_Center, + FDE_CSSPROPERTYVALUE_TableHeaderGroup, + FDE_CSSPROPERTYVALUE_Inside, + FDE_CSSPROPERTYVALUE_XxLarge, + FDE_CSSPROPERTYVALUE_Triangle, + FDE_CSSPROPERTYVALUE_RubyTextGroup, + FDE_CSSPROPERTYVALUE_Circle, + FDE_CSSPROPERTYVALUE_Hiragana, + FDE_CSSPROPERTYVALUE_RepeatX, + FDE_CSSPROPERTYVALUE_RepeatY, + FDE_CSSPROPERTYVALUE_Move, + FDE_CSSPROPERTYVALUE_HiraganaIroha, + FDE_CSSPROPERTYVALUE_RubyBase, + FDE_CSSPROPERTYVALUE_Scroll, + FDE_CSSPROPERTYVALUE_Smaller, + FDE_CSSPROPERTYVALUE_TableFooterGroup, + FDE_CSSPROPERTYVALUE_Baseline, + FDE_CSSPROPERTYVALUE_Separate, + FDE_CSSPROPERTYVALUE_Armenian, + FDE_CSSPROPERTYVALUE_Open, + FDE_CSSPROPERTYVALUE_Relative, + FDE_CSSPROPERTYVALUE_Thick, + FDE_CSSPROPERTYVALUE_Justify, + FDE_CSSPROPERTYVALUE_Middle, + FDE_CSSPROPERTYVALUE_Always, + FDE_CSSPROPERTYVALUE_DistributeSpace, + FDE_CSSPROPERTYVALUE_LineEdge, + FDE_CSSPROPERTYVALUE_PreWrap, + FDE_CSSPROPERTYVALUE_Medium, + FDE_CSSPROPERTYVALUE_NResize, + FDE_CSSPROPERTYVALUE_ListItem, + FDE_CSSPROPERTYVALUE_Show, + FDE_CSSPROPERTYVALUE_Currentcolor, + FDE_CSSPROPERTYVALUE_NoCloseQuote, + FDE_CSSPROPERTYVALUE_VerticalLr, + FDE_CSSPROPERTYVALUE_VerticalRl, + FDE_CSSPROPERTYVALUE_Pointer, + FDE_CSSPROPERTYVALUE_XxSmall, + FDE_CSSPROPERTYVALUE_Bold, + FDE_CSSPROPERTYVALUE_Both, + FDE_CSSPROPERTYVALUE_SmallCaps, + FDE_CSSPROPERTYVALUE_Katakana, + FDE_CSSPROPERTYVALUE_After, + FDE_CSSPROPERTYVALUE_Horizontal, + FDE_CSSPROPERTYVALUE_Dotted, + FDE_CSSPROPERTYVALUE_Disc, + FDE_CSSPROPERTYVALUE_Georgian, + FDE_CSSPROPERTYVALUE_Inline, + FDE_CSSPROPERTYVALUE_Overline, + FDE_CSSPROPERTYVALUE_Wait, + FDE_CSSPROPERTYVALUE_BreakAll, + FDE_CSSPROPERTYVALUE_UpperAlpha, + FDE_CSSPROPERTYVALUE_Capitalize, + FDE_CSSPROPERTYVALUE_Nowrap, + FDE_CSSPROPERTYVALUE_TextBottom, + FDE_CSSPROPERTYVALUE_NoOpenQuote, + FDE_CSSPROPERTYVALUE_Groove, + FDE_CSSPROPERTYVALUE_Progress, + FDE_CSSPROPERTYVALUE_Larger, + FDE_CSSPROPERTYVALUE_CloseQuote, + FDE_CSSPROPERTYVALUE_TableCell, + FDE_CSSPROPERTYVALUE_PreLine, + FDE_CSSPROPERTYVALUE_Absolute, + FDE_CSSPROPERTYVALUE_InlineTable, + FDE_CSSPROPERTYVALUE_BidiOverride, + FDE_CSSPROPERTYVALUE_InlineBlock, + FDE_CSSPROPERTYVALUE_Inset, + FDE_CSSPROPERTYVALUE_Crosshair, + FDE_CSSPROPERTYVALUE_UpperLatin, + FDE_CSSPROPERTYVALUE_Help, + FDE_CSSPROPERTYVALUE_Hide, + FDE_CSSPROPERTYVALUE_Uppercase, + FDE_CSSPROPERTYVALUE_SResize, + FDE_CSSPROPERTYVALUE_Table, + FDE_CSSPROPERTYVALUE_Blink, + FDE_CSSPROPERTYVALUE_Block, + FDE_CSSPROPERTYVALUE_Start, + FDE_CSSPROPERTYVALUE_TableColumnGroup, + FDE_CSSPROPERTYVALUE_Italic, + FDE_CSSPROPERTYVALUE_LineThrough, + FDE_CSSPROPERTYVALUE_KeepAll, + FDE_CSSPROPERTYVALUE_LowerAlpha, + FDE_CSSPROPERTYVALUE_RunIn, + FDE_CSSPROPERTYVALUE_Square, + FDE_CSSPROPERTYVALUE_XLarge, + FDE_CSSPROPERTYVALUE_Large, + FDE_CSSPROPERTYVALUE_Before, + FDE_CSSPROPERTYVALUE_Left, + FDE_CSSPROPERTYVALUE_TextTop, + FDE_CSSPROPERTYVALUE_RubyText, + 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, + FDE_CSSPROPERTY_BorderLeft, + FDE_CSSPROPERTY_ColumnRule, + FDE_CSSPROPERTY_Height, + FDE_CSSPROPERTY_CounterReset, + FDE_CSSPROPERTY_Content, + FDE_CSSPROPERTY_RubyPosition, + FDE_CSSPROPERTY_BackgroundColor, + FDE_CSSPROPERTY_Width, + FDE_CSSPROPERTY_Src, + FDE_CSSPROPERTY_Top, + FDE_CSSPROPERTY_Margin, + FDE_CSSPROPERTY_BorderColor, + FDE_CSSPROPERTY_Widows, + FDE_CSSPROPERTY_BorderBottomColor, + FDE_CSSPROPERTY_TextIndent, + FDE_CSSPROPERTY_Right, + FDE_CSSPROPERTY_TextEmphasisStyle, + FDE_CSSPROPERTY_PaddingLeft, + FDE_CSSPROPERTY_ColumnWidth, + FDE_CSSPROPERTY_MarginLeft, + FDE_CSSPROPERTY_Border, + FDE_CSSPROPERTY_BorderTop, + FDE_CSSPROPERTY_RubyOverhang, + FDE_CSSPROPERTY_PageBreakBefore, + FDE_CSSPROPERTY_MaxHeight, + FDE_CSSPROPERTY_MinWidth, + FDE_CSSPROPERTY_BorderLeftColor, + FDE_CSSPROPERTY_Bottom, + FDE_CSSPROPERTY_Quotes, + FDE_CSSPROPERTY_MaxWidth, + FDE_CSSPROPERTY_PaddingRight, + FDE_CSSPROPERTY_ListStyleImage, + FDE_CSSPROPERTY_WhiteSpace, + FDE_CSSPROPERTY_BorderBottom, + FDE_CSSPROPERTY_ListStyleType, + FDE_CSSPROPERTY_WordBreak, + FDE_CSSPROPERTY_OverflowX, + FDE_CSSPROPERTY_OverflowY, + FDE_CSSPROPERTY_BorderTopColor, + FDE_CSSPROPERTY_FontFamily, + FDE_CSSPROPERTY_Cursor, + FDE_CSSPROPERTY_RubyAlign, + FDE_CSSPROPERTY_ColumnRuleColor, + FDE_CSSPROPERTY_FontWeight, + FDE_CSSPROPERTY_BorderRightStyle, + FDE_CSSPROPERTY_MinHeight, + FDE_CSSPROPERTY_Color, + FDE_CSSPROPERTY_LetterSpacing, + FDE_CSSPROPERTY_EmptyCells, + FDE_CSSPROPERTY_TextAlign, + FDE_CSSPROPERTY_RubySpan, + FDE_CSSPROPERTY_Position, + FDE_CSSPROPERTY_BorderStyle, + FDE_CSSPROPERTY_BorderBottomStyle, + FDE_CSSPROPERTY_BorderCollapse, + FDE_CSSPROPERTY_ColumnCount, + FDE_CSSPROPERTY_BorderRightWidth, + FDE_CSSPROPERTY_UnicodeBidi, + FDE_CSSPROPERTY_VerticalAlign, + FDE_CSSPROPERTY_PaddingTop, + FDE_CSSPROPERTY_Columns, + FDE_CSSPROPERTY_Overflow, + FDE_CSSPROPERTY_TableLayout, + FDE_CSSPROPERTY_FontVariant, + FDE_CSSPROPERTY_ListStyle, + FDE_CSSPROPERTY_BackgroundPosition, + FDE_CSSPROPERTY_BorderWidth, + FDE_CSSPROPERTY_TextEmphasisColor, + FDE_CSSPROPERTY_BorderLeftStyle, + FDE_CSSPROPERTY_PageBreakInside, + FDE_CSSPROPERTY_TextEmphasis, + FDE_CSSPROPERTY_BorderBottomWidth, + FDE_CSSPROPERTY_ColumnGap, + FDE_CSSPROPERTY_Orphans, + FDE_CSSPROPERTY_BorderRight, + FDE_CSSPROPERTY_FontSize, + FDE_CSSPROPERTY_PageBreakAfter, + FDE_CSSPROPERTY_CaptionSide, + FDE_CSSPROPERTY_BackgroundRepeat, + FDE_CSSPROPERTY_BorderTopStyle, + FDE_CSSPROPERTY_BorderSpacing, + FDE_CSSPROPERTY_TextTransform, + FDE_CSSPROPERTY_FontStyle, + FDE_CSSPROPERTY_Font, + FDE_CSSPROPERTY_LineHeight, + FDE_CSSPROPERTY_MarginRight, + FDE_CSSPROPERTY_Float, + FDE_CSSPROPERTY_BorderLeftWidth, + FDE_CSSPROPERTY_Display, + FDE_CSSPROPERTY_Clear, + FDE_CSSPROPERTY_ColumnRuleStyle, + FDE_CSSPROPERTY_TextCombine, + FDE_CSSPROPERTY_ListStylePosition, + FDE_CSSPROPERTY_Visibility, + FDE_CSSPROPERTY_PaddingBottom, + FDE_CSSPROPERTY_BackgroundAttachment, + FDE_CSSPROPERTY_BackgroundImage, + FDE_CSSPROPERTY_LineBreak, + FDE_CSSPROPERTY_Background, + FDE_CSSPROPERTY_BorderTopWidth, + FDE_CSSPROPERTY_WordSpacing, + FDE_CSSPROPERTY_BorderRightColor, + FDE_CSSPROPERTY_CounterIncrement, + FDE_CSSPROPERTY_Left, + FDE_CSSPROPERTY_TextDecoration, + FDE_CSSPROPERTY_Padding, + FDE_CSSPROPERTY_MarginBottom, + FDE_CSSPROPERTY_MarginTop, + 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, + FDE_CSSPERSUDO_NONE +}; +enum FDE_CSSSELECTORTYPE { + FDE_CSSSELECTORTYPE_Element, + FDE_CSSSELECTORTYPE_Descendant, + FDE_CSSSELECTORTYPE_Class, + FDE_CSSSELECTORTYPE_Persudo, + FDE_CSSSELECTORTYPE_ID, +}; +class IFDE_CSSSelector { + public: + virtual ~IFDE_CSSSelector() {} + virtual FDE_CSSSELECTORTYPE GetType() const = 0; + virtual FX_DWORD 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 FX_DWORD 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, + FX_WORD wCodePage, + FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL); + static IFDE_CSSStyleSheet* LoadFromBuffer( + const CFX_WideString& szUrl, + const FX_WCHAR* pBuffer, + int32_t iBufSize, + FX_WORD wCodePage, + FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL); + virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0; + virtual FX_DWORD GetMediaList() const = 0; + virtual FX_WORD GetCodePage() const = 0; + + virtual int32_t CountRules() const = 0; + virtual IFDE_CSSRule* GetRule(int32_t index) = 0; +}; +typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray; +#define FDE_CSSUSERSTYLESHEET (FX_BSTRC("#USERSHEET")) +#define FDE_CSSUAGENTSTYLESHEET (FX_BSTRC("#AGENTSHEET")) +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, + FDE_CSSSYNTAXSTATUS_None, + FDE_CSSSYNTAXSTATUS_Charset, + FDE_CSSSYNTAXSTATUS_ImportRule, + FDE_CSSSYNTAXSTATUS_ImportClose, + FDE_CSSSYNTAXSTATUS_PageRule, + FDE_CSSSYNTAXSTATUS_StyleRule, + FDE_CSSSYNTAXSTATUS_FontFaceRule, + FDE_CSSSYNTAXSTATUS_MediaRule, + FDE_CSSSYNTAXSTATUS_MediaType, + FDE_CSSSYNTAXSTATUS_URI, + FDE_CSSSYNTAXSTATUS_Selector, + FDE_CSSSYNTAXSTATUS_DeclOpen, + FDE_CSSSYNTAXSTATUS_DeclClose, + 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, + FDE_CSSLENGTHUNIT_Normal, + 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, + FDE_CSSBORDERSTYLE_Dotted, + FDE_CSSBORDERSTYLE_Dashed, + FDE_CSSBORDERSTYLE_Solid, + FDE_CSSBORDERSTYLE_Double, + FDE_CSSBORDERSTYLE_Groove, + FDE_CSSBORDERSTYLE_Ridge, + 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, + FDE_CSSDISPLAY_RunIn, + FDE_CSSDISPLAY_Block, + FDE_CSSDISPLAY_Inline, + FDE_CSSDISPLAY_InlineBlock, + FDE_CSSDISPLAY_InlineTable, + FDE_CSSDISPLAY_Table, + FDE_CSSDISPLAY_TableRow, + FDE_CSSDISPLAY_TableCell, + FDE_CSSDISPLAY_TableCaption, + FDE_CSSDISPLAY_TableColumn, + FDE_CSSDISPLAY_TableRowGroup, + FDE_CSSDISPLAY_TableColumnGroup, + FDE_CSSDISPLAY_TableHeaderGroup, + FDE_CSSDISPLAY_TableFooterGroup, + FDE_CSSDISPLAY_Ruby, + FDE_CSSDISPLAY_RubyBase, + FDE_CSSDISPLAY_RubyText, + 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, + FDE_CSSPAGEBREAK_Avoid, + FDE_CSSPAGEBREAK_Left, + FDE_CSSPAGEBREAK_Right, +}; +enum FDE_CSSOVERFLOW { + FDE_CSSOVERFLOW_Visible, + FDE_CSSOVERFLOW_Hidden, + FDE_CSSOVERFLOW_Scroll, + FDE_CSSOVERFLOW_Auto, + 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, + FDE_CSSTEXTEMPHASISMARK_Dot, + FDE_CSSTEXTEMPHASISMARK_Circle, + FDE_CSSTEXTEMPHASISMARK_DoubleCircle, + FDE_CSSTEXTEMPHASISMARK_Triangle, + FDE_CSSTEXTEMPHASISMARK_Sesame, + FDE_CSSTEXTEMPHASISMARK_Custom, +}; +enum FDE_CSSTEXTCOMBINE { + FDE_CSSTEXTCOMBINE_Horizontal, + FDE_CSSTEXTCOMBINE_None, +}; +enum FDE_CSSCURSOR { + FDE_CSSCURSOR_Auto, + FDE_CSSCURSOR_Crosshair, + FDE_CSSCURSOR_Default, + FDE_CSSCURSOR_Pointer, + FDE_CSSCURSOR_Move, + FDE_CSSCURSOR_EResize, + FDE_CSSCURSOR_NeResize, + FDE_CSSCURSOR_NwResize, + FDE_CSSCURSOR_NResize, + FDE_CSSCURSOR_SeResize, + FDE_CSSCURSOR_SwResize, + FDE_CSSCURSOR_SResize, + FDE_CSSCURSOR_WResize, + FDE_CSSCURSOR_Text, + FDE_CSSCURSOR_Wait, + 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, + FDE_CSSCAPTIONSIDE_Left, + FDE_CSSCAPTIONSIDE_Right, + FDE_CSSCAPTIONSIDE_Before, + FDE_CSSCAPTIONSIDE_After, +}; +enum FDE_CSSRUBYALIGN { + FDE_CSSRUBYALIGN_Auto, + FDE_CSSRUBYALIGN_Start, + FDE_CSSRUBYALIGN_Left, + FDE_CSSRUBYALIGN_Center, + FDE_CSSRUBYALIGN_End, + FDE_CSSRUBYALIGN_Right, + FDE_CSSRUBYALIGN_DistributeLetter, + 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, + FDE_CSSTEXTALIGN_Center, + FDE_CSSTEXTALIGN_Justify, + FDE_CSSTEXTALIGN_JustifyAll, +}; +enum FDE_CSSVERTICALALIGN { + FDE_CSSVERTICALALIGN_Baseline, + FDE_CSSVERTICALALIGN_Sub, + FDE_CSSVERTICALALIGN_Super, + FDE_CSSVERTICALALIGN_Top, + FDE_CSSVERTICALALIGN_TextTop, + FDE_CSSVERTICALALIGN_Middle, + FDE_CSSVERTICALALIGN_Bottom, + FDE_CSSVERTICALALIGN_TextBottom, + FDE_CSSVERTICALALIGN_Number, +}; +enum FDE_CSSLISTSTYLETYPE { + FDE_CSSLISTSTYLETYPE_Disc, + FDE_CSSLISTSTYLETYPE_Circle, + FDE_CSSLISTSTYLETYPE_Square, + FDE_CSSLISTSTYLETYPE_Decimal, + FDE_CSSLISTSTYLETYPE_DecimalLeadingZero, + FDE_CSSLISTSTYLETYPE_LowerRoman, + FDE_CSSLISTSTYLETYPE_UpperRoman, + FDE_CSSLISTSTYLETYPE_LowerGreek, + FDE_CSSLISTSTYLETYPE_LowerLatin, + FDE_CSSLISTSTYLETYPE_UpperLatin, + FDE_CSSLISTSTYLETYPE_Armenian, + FDE_CSSLISTSTYLETYPE_Georgian, + FDE_CSSLISTSTYLETYPE_LowerAlpha, + FDE_CSSLISTSTYLETYPE_UpperAlpha, + FDE_CSSLISTSTYLETYPE_None, + FDE_CSSLISTSTYLETYPE_CjkIdeographic, + FDE_CSSLISTSTYLETYPE_Hebrew, + FDE_CSSLISTSTYLETYPE_Hiragana, + FDE_CSSLISTSTYLETYPE_HiraganaIroha, + FDE_CSSLISTSTYLETYPE_Katakana, + FDE_CSSLISTSTYLETYPE_KatakanaIroha, +}; +enum FDE_CSSLISTSTYLEPOSITION { + FDE_CSSLISTSTYLEPOSITION_Outside, + FDE_CSSLISTSTYLEPOSITION_Inside, +}; +enum FDE_CSSWHITESPACE { + FDE_CSSWHITESPACE_Normal, + FDE_CSSWHITESPACE_Pre, + FDE_CSSWHITESPACE_Nowrap, + 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, + FDE_CSSTEXTDECORATION_Overline = 2, + FDE_CSSTEXTDECORATION_LineThrough = 4, + FDE_CSSTEXTDECORATION_Blink = 8, + FDE_CSSTEXTDECORATION_Double = 16, +}; +class IFDE_CSSRubyStyle { + 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; +}; +class IFDE_CSSMultiColumnStyle { + 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; +}; +class IFDE_CSSGeneratedContentStyle { + 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; +}; +class IFDE_CSSFontStyle { + public: + virtual ~IFDE_CSSFontStyle() {} + virtual int32_t CountFontFamilies() const = 0; + virtual const FX_WCHAR* GetFontFamily(int32_t index) const = 0; + virtual FX_WORD GetFontWeight() const = 0; + virtual FDE_CSSFONTVARIANT GetFontVariant() const = 0; + virtual FDE_CSSFONTSTYLE GetFontStyle() const = 0; + virtual FX_FLOAT GetFontSize() const = 0; + virtual FX_ARGB GetColor() const = 0; + virtual void SetFontWeight(FX_WORD wFontWeight) = 0; + virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) = 0; + virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) = 0; + 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 FX_DWORD 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(FX_DWORD 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 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(FX_DWORD 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/xfa/fde/css/fde_csscache.cpp b/xfa/fde/css/fde_csscache.cpp new file mode 100644 index 0000000000..aba863ea70 --- /dev/null +++ b/xfa/fde/css/fde_csscache.cpp @@ -0,0 +1,149 @@ +// 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/css/fde_csscache.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_ext.h" + +FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p) + : pStylesheet(p), dwActivity(0) { + FXSYS_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) + : 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.GetPtr(), wsName.GetLength(), TRUE); + FX_POSITION pos = pTag->GetFirstAttribute(); + while (pos != NULL) { + pTag->GetNextAttribute(pos, wsName, wsValue); + FX_DWORD dwNameHash = + FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); + static const FX_DWORD s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE); + static const FX_DWORD s_dwClassHash = + FX_HashCode_String_GetW(L"class", 5, TRUE); + if (dwNameHash == s_dwClassHash) { + FX_DWORD dwHash = + FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); + dwClassHashs.Add(dwHash); + } else if (dwNameHash == s_dwIDHash) { + dwIDHash = FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); + } + } +} +FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) + : pTag(it.pTag), + pParent(it.pParent), + dwIDHash(it.dwIDHash), + dwTagHash(it.dwTagHash), + iClassIndex(0), + dwClassHashs(1) { + if (it.dwClassHashs.GetSize() > 0) { + dwClassHashs.Copy(it.dwClassHashs); + } +} +void CFDE_CSSAccelerator::OnEnterTag(IFDE_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); + m_Stack.Pop(); +} diff --git a/xfa/fde/css/fde_csscache.h b/xfa/fde/css/fde_csscache.h new file mode 100644 index 0000000000..b886424d64 --- /dev/null +++ b/xfa/fde/css/fde_csscache.h @@ -0,0 +1,85 @@ +// 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_CSS_FDE_CSSCACHE_H_ +#define XFA_FDE_CSS_FDE_CSSCACHE_H_ + +#include <map> + +#include "xfa/fde/css/fde_css.h" +#include "xfa/fgas/crt/fgas_memory.h" + +class FDE_CSSCacheItem : public CFX_Target { + public: + explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); + ~FDE_CSSCacheItem(); + + IFDE_CSSStyleSheet* pStylesheet; + FX_DWORD 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(const FDE_CSSTagCache& it); + FDE_CSSTagCache* GetParent() const { return pParent; } + IFDE_CSSTagProvider* GetTag() const { return pTag; } + FX_DWORD HashID() const { return dwIDHash; } + FX_DWORD HashTag() const { return dwTagHash; } + int32_t CountHashClass() const { return dwClassHashs.GetSize(); } + void SetClassIndex(int32_t index) { iClassIndex = index; } + FX_DWORD HashClass() const { + return iClassIndex < dwClassHashs.GetSize() + ? dwClassHashs.GetAt(iClassIndex) + : 0; + } + + protected: + IFDE_CSSTagProvider* pTag; + FDE_CSSTagCache* pParent; + FX_DWORD dwIDHash; + FX_DWORD dwTagHash; + int32_t iClassIndex; + CFDE_DWordArray dwClassHashs; +}; +typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack; + +class CFDE_CSSAccelerator : public IFDE_CSSAccelerator, public CFX_Target { + public: + virtual void OnEnterTag(IFDE_CSSTagProvider* pTag); + virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag); + void Clear() { m_Stack.RemoveAll(); } + FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); } + + protected: + CFDE_CSSTagStack m_Stack; +}; + +#endif // XFA_FDE_CSS_FDE_CSSCACHE_H_ diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp new file mode 100644 index 0000000000..ef09e99baf --- /dev/null +++ b/xfa/fde/css/fde_cssdatatable.cpp @@ -0,0 +1,889 @@ +// 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/css/fde_cssdatatable.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_algorithm.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/crt/fgas_system.h" + +FX_BOOL FDE_CSSLengthToFloat(const FDE_CSSLENGTH& len, + FX_FLOAT fPercentBase, + FX_FLOAT& fResult) { + switch (len.GetUnit()) { + case FDE_CSSLENGTHUNIT_Point: + fResult = len.GetValue(); + return TRUE; + case FDE_CSSLENGTHUNIT_Percent: + fResult = len.GetValue() * fPercentBase; + return TRUE; + default: + return FALSE; + } +} +CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle, + FX_FLOAT fContainerWidth, + FX_BOOL bPadding, + FX_BOOL bBorder, + FX_BOOL bMargin) { + FXSYS_assert(pBoundStyle != NULL); + FX_FLOAT fResult; + const FDE_CSSRECT* pRect; + CFX_FloatRect rect(0, 0, 0, 0); + if (bPadding) { + pRect = pBoundStyle->GetPaddingWidth(); + if (pRect != NULL) { + if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { + rect.left += fResult; + } + if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { + rect.top += fResult; + } + if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { + rect.right += fResult; + } + if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { + rect.bottom += fResult; + } + } + } + if (bBorder) { + pRect = pBoundStyle->GetBorderWidth(); + if (pRect != NULL) { + if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { + rect.left += fResult; + } + if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { + rect.top += fResult; + } + if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { + rect.right += fResult; + } + if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { + rect.bottom += fResult; + } + } + } + if (bMargin) { + pRect = pBoundStyle->GetMarginWidth(); + if (pRect != NULL) { + if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { + rect.left += fResult; + } + if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { + rect.top += fResult; + } + if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { + rect.right += fResult; + } + if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { + rect.bottom += fResult; + } + } + } + return rect; +} +FX_DWORD FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle* pFontStyle) { + FXSYS_assert(pFontStyle != NULL); + FX_DWORD dwFontStyle = FX_FONTSTYLE_Normal; + if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) { + dwFontStyle |= FX_FONTSTYLE_Italic; + } + if (pFontStyle->GetFontWeight() >= 700) { + dwFontStyle |= FX_FONTSTYLE_Bold; + } + return dwFontStyle; +} +static const FDE_CSSPROPERTYTABLE g_FDE_CSSProperties[] = { + {FDE_CSSPROPERTY_WritingMode, L"writing-mode", 0x01878076, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_ColumnRuleWidth, L"column-rule-width", 0x0200FB00, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderLeft, L"border-left", 0x04080036, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_ColumnRule, L"column-rule", 0x04C83DF3, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_Height, L"height", 0x05A5C519, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_CounterReset, L"counter-reset", 0x0894F9B0, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_Content, L"content", 0x097BE91B, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeURI | FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_RubyPosition, L"ruby-position", 0x09ACD024, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BackgroundColor, L"background-color", 0x09E8E8AC, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_Width, L"width", 0x0A8A8F80, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Src, L"src", 0x0BD37048, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeURI}, + {FDE_CSSPROPERTY_Top, L"top", 0x0BEDAF33, FDE_CSSVALUETYPE_Primitive | + FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Margin, L"margin", 0x0CB016BE, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderColor, L"border-color", 0x0CBB528A, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_Widows, L"widows", 0x1026C59D, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderBottomColor, L"border-bottom-color", 0x121E22EC, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_TextIndent, L"text-indent", 0x169ADB74, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Right, L"right", 0x193ADE3E, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_TextEmphasisStyle, L"text-emphasis-style", 0x20DBAF4A, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_PaddingLeft, L"padding-left", 0x228CF02F, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_ColumnWidth, L"column-width", 0x24C9AC9B, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_MarginLeft, L"margin-left", 0x297C5656, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | + FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Border, L"border", 0x2A23349E, FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_BorderTop, L"border-top", 0x2B866ADE, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_RubyOverhang, L"ruby-overhang", 0x2CCA0D89, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_PageBreakBefore, L"page-break-before", 0x3119B36F, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_MaxHeight, L"max-height", 0x343597EC, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_MinWidth, L"min-width", 0x35832871, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderLeftColor, L"border-left-color", 0x35C64022, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_Bottom, L"bottom", 0x399F02B5, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Quotes, L"quotes", 0x3D8C6A01, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_MaxWidth, L"max-width", 0x3EA274F3, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_PaddingRight, L"padding-right", 0x3F616AC2, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_ListStyleImage, L"list-style-image", 0x42A8A86A, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeURI}, + {FDE_CSSPROPERTY_WhiteSpace, L"white-space", 0x42F0429A, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderBottom, L"border-bottom", 0x452CE780, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_ListStyleType, L"list-style-type", 0x48094789, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_WordBreak, L"word-break", 0x4D74A3CE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_OverflowX, L"overflow-x", 0x4ECEBF99, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_OverflowY, L"overflow-y", 0x4ECEBF9A, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderTopColor, L"border-top-color", 0x5109B8CA, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_FontFamily, L"font-family", 0x574686E6, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_Cursor, L"cursor", 0x59DFCA5E, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_RubyAlign, L"ruby-align", 0x6077BDFA, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_ColumnRuleColor, L"column-rule-color", 0x65DDFD9F, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_FontWeight, L"font-weight", 0x6692F60C, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderRightStyle, L"border-right-style", 0x6920DDA7, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_MinHeight, L"min-height", 0x6AAE312A, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Color, L"color", 0x6E67921F, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_LetterSpacing, L"letter-spacing", 0x70536102, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_EmptyCells, L"empty-cells", 0x7531528F, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_TextAlign, L"text-align", 0x7553F1BD, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_RubySpan, L"ruby-span", 0x76FCFCE1, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeFunction}, + {FDE_CSSPROPERTY_Position, L"position", 0x814F82B5, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderStyle, L"border-style", 0x82A4CD5C, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderBottomStyle, L"border-bottom-style", 0x88079DBE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderCollapse, L"border-collapse", 0x8883C7FE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_ColumnCount, L"column-count", 0x89936A64, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderRightWidth, L"border-right-width", 0x8F5A6036, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_UnicodeBidi, L"unicode-bidi", 0x91670F6C, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_VerticalAlign, L"vertical-align", 0x934A87D2, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_PaddingTop, L"padding-top", 0x959D22B7, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Columns, L"columns", 0x96FA5D81, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_Overflow, L"overflow", 0x97B76B54, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_TableLayout, L"table-layout", 0x9B1CB4B3, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_FontVariant, L"font-variant", 0x9C785779, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_ListStyle, L"list-style", 0x9E6C471A, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_BackgroundPosition, L"background-position", 0xA8846D22, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderWidth, L"border-width", 0xA8DE4FEB, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_TextEmphasisColor, L"text-emphasis-color", 0xAAF23478, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_BorderLeftStyle, L"border-left-style", 0xABAFBAF4, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_PageBreakInside, L"page-break-inside", 0xACB695F8, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_TextEmphasis, L"text-emphasis", 0xAD0E580C, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_BorderBottomWidth, L"border-bottom-width", 0xAE41204D, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_ColumnGap, L"column-gap", 0xB5C1BA73, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Orphans, L"orphans", 0xB716467B, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderRight, L"border-right", 0xB78E9EA9, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_FontSize, L"font-size", 0xB93956DF, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_PageBreakAfter, L"page-break-after", 0xBC358AEE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_CaptionSide, L"caption-side", 0xC03F3560, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BackgroundRepeat, L"background-repeat", 0xC2C2FDCE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderTopStyle, L"border-top-style", 0xC6F3339C, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderSpacing, L"border-spacing", 0xC72030F0, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_TextTransform, L"text-transform", 0xC88EEA6E, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_FontStyle, L"font-style", 0xCB1950F5, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Font, L"font", 0xCD308B77, FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_LineHeight, L"line-height", 0xCFCACE2E, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_MarginRight, L"margin-right", 0xD13C58C9, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | + FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Float, L"float", 0xD1532876, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BorderLeftWidth, L"border-left-width", 0xD1E93D83, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_Display, L"display", 0xD4224C36, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Clear, L"clear", 0xD8ED1467, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_ColumnRuleStyle, L"column-rule-style", 0xDBC77871, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_TextCombine, L"text-combine", 0xDC5207CF, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_ListStylePosition, L"list-style-position", 0xE1A1DE3C, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Visibility, L"visibility", 0xE29F5168, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_PaddingBottom, L"padding-bottom", 0xE555B3B9, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BackgroundAttachment, L"background-attachment", 0xE77981F6, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_BackgroundImage, L"background-image", 0xE9AEB710, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeURI}, + {FDE_CSSPROPERTY_LineBreak, L"line-break", 0xEA2D1D9A, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Background, L"background", 0xEB49DD40, + FDE_CSSVALUETYPE_Shorthand}, + {FDE_CSSPROPERTY_BorderTopWidth, L"border-top-width", 0xED2CB62B, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_WordSpacing, L"word-spacing", 0xEDA63BAE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_BorderRightColor, L"border-right-color", 0xF33762D5, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeColor}, + {FDE_CSSPROPERTY_CounterIncrement, L"counter-increment", 0xF4CFB1B2, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString}, + {FDE_CSSPROPERTY_Left, L"left", 0xF5AD782B, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | + FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_TextDecoration, L"text-decoration", 0xF7C634BA, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Padding, L"padding", 0xF8C373F7, + FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber}, + {FDE_CSSPROPERTY_MarginBottom, L"margin-bottom", 0xF93485A0, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | + FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_MarginTop, L"margin-top", 0xFE51DCFE, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | + FDE_CSSVALUETYPE_MaybeEnum}, + {FDE_CSSPROPERTY_Direction, L"direction", 0xFE746E61, + FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, +}; +static const FDE_CSSPROPERTYVALUETABLE g_FDE_CSSPropertyValues[] = { + {FDE_CSSPROPERTYVALUE_Bolder, L"bolder", 0x009F1058}, + {FDE_CSSPROPERTYVALUE_LowerLatin, L"lower-latin", 0x016014CE}, + {FDE_CSSPROPERTYVALUE_Lowercase, L"lowercase", 0x02ACB805}, + {FDE_CSSPROPERTYVALUE_LowerGreek, L"lower-greek", 0x03D81D64}, + {FDE_CSSPROPERTYVALUE_Sesame, L"sesame", 0x0432ECDE}, + {FDE_CSSPROPERTYVALUE_None, L"none", 0x048B6670}, + {FDE_CSSPROPERTYVALUE_NwResize, L"nw-resize", 0x054B4BE4}, + {FDE_CSSPROPERTYVALUE_WResize, L"w-resize", 0x0A2F8D76}, + {FDE_CSSPROPERTYVALUE_Dot, L"dot", 0x0A48CB27}, + {FDE_CSSPROPERTYVALUE_End, L"end", 0x0A631437}, + {FDE_CSSPROPERTYVALUE_Ltr, L"ltr", 0x0B1B56D2}, + {FDE_CSSPROPERTYVALUE_Pre, L"pre", 0x0B848587}, + {FDE_CSSPROPERTYVALUE_Rtl, L"rtl", 0x0BB92C52}, + {FDE_CSSPROPERTYVALUE_Sub, L"sub", 0x0BD37FAA}, + {FDE_CSSPROPERTYVALUE_Top, L"top", 0x0BEDAF33}, + {FDE_CSSPROPERTYVALUE_Visible, L"visible", 0x0F55D7EE}, + {FDE_CSSPROPERTYVALUE_Filled, L"filled", 0x10827DD0}, + {FDE_CSSPROPERTYVALUE_SwResize, L"sw-resize", 0x10B548E9}, + {FDE_CSSPROPERTYVALUE_NoRepeat, L"no-repeat", 0x1235C18B}, + {FDE_CSSPROPERTYVALUE_Default, L"default", 0x14DA2125}, + {FDE_CSSPROPERTYVALUE_Transparent, L"transparent", 0x17B64DB2}, + {FDE_CSSPROPERTYVALUE_Ridge, L"ridge", 0x18EBEE4B}, + {FDE_CSSPROPERTYVALUE_Right, L"right", 0x193ADE3E}, + {FDE_CSSPROPERTYVALUE_HorizontalTb, L"horizontal-tb", 0x1A66A86D}, + {FDE_CSSPROPERTYVALUE_DistributeLetter, L"distribute-letter", 0x1EDBD75C}, + {FDE_CSSPROPERTYVALUE_DoubleCircle, L"double-circle", 0x1FF082BA}, + {FDE_CSSPROPERTYVALUE_Ruby, L"ruby", 0x20D66C02}, + {FDE_CSSPROPERTYVALUE_Collapse, L"collapse", 0x2128D673}, + {FDE_CSSPROPERTYVALUE_Normal, L"normal", 0x247CF3E9}, + {FDE_CSSPROPERTYVALUE_Avoid, L"avoid", 0x24E684B3}, + {FDE_CSSPROPERTYVALUE_UpperRoman, L"upper-roman", 0x28BAC2B6}, + {FDE_CSSPROPERTYVALUE_Auto, L"auto", 0x2B35B6D9}, + {FDE_CSSPROPERTYVALUE_Text, L"text", 0x2D08AF85}, + {FDE_CSSPROPERTYVALUE_XSmall, L"x-small", 0x2D2FCAFE}, + {FDE_CSSPROPERTYVALUE_Thin, L"thin", 0x2D574D53}, + {FDE_CSSPROPERTYVALUE_Repeat, L"repeat", 0x306614A1}, + {FDE_CSSPROPERTYVALUE_Small, L"small", 0x316A3739}, + {FDE_CSSPROPERTYVALUE_NeResize, L"ne-resize", 0x31FD5E12}, + {FDE_CSSPROPERTYVALUE_NoContent, L"no-content", 0x33A1C545}, + {FDE_CSSPROPERTYVALUE_Outside, L"outside", 0x36DF693D}, + {FDE_CSSPROPERTYVALUE_EResize, L"e-resize", 0x36E19FA4}, + {FDE_CSSPROPERTYVALUE_TableRow, L"table-row", 0x3912A02D}, + {FDE_CSSPROPERTYVALUE_Bottom, L"bottom", 0x399F02B5}, + {FDE_CSSPROPERTYVALUE_Underline, L"underline", 0x3A0273A6}, + {FDE_CSSPROPERTYVALUE_CjkIdeographic, L"cjk-ideographic", 0x3A641CC4}, + {FDE_CSSPROPERTYVALUE_SeResize, L"se-resize", 0x3D675B17}, + {FDE_CSSPROPERTYVALUE_Fixed, L"fixed", 0x3D7DEB10}, + {FDE_CSSPROPERTYVALUE_Double, L"double", 0x3D98515B}, + {FDE_CSSPROPERTYVALUE_Solid, L"solid", 0x40623B5B}, + {FDE_CSSPROPERTYVALUE_RubyBaseGroup, L"ruby-base-group", 0x41014E84}, + {FDE_CSSPROPERTYVALUE_OpenQuote, L"open-quote", 0x44A41E8D}, + {FDE_CSSPROPERTYVALUE_Lighter, L"lighter", 0x45BEB7AF}, + {FDE_CSSPROPERTYVALUE_LowerRoman, L"lower-roman", 0x5044D253}, + {FDE_CSSPROPERTYVALUE_Strict, L"strict", 0x52F4EBD9}, + {FDE_CSSPROPERTYVALUE_TableCaption, L"table-caption", 0x5325CD63}, + {FDE_CSSPROPERTYVALUE_Oblique, L"oblique", 0x53EBDDB1}, + {FDE_CSSPROPERTYVALUE_Decimal, L"decimal", 0x54034C2F}, + {FDE_CSSPROPERTYVALUE_Loose, L"loose", 0x54D3A1E2}, + {FDE_CSSPROPERTYVALUE_Hebrew, L"hebrew", 0x565792DD}, + {FDE_CSSPROPERTYVALUE_Hidden, L"hidden", 0x573CB40C}, + {FDE_CSSPROPERTYVALUE_Dashed, L"dashed", 0x58A3DD29}, + {FDE_CSSPROPERTYVALUE_Embed, L"embed", 0x59C8F27D}, + {FDE_CSSPROPERTYVALUE_TableRowGroup, L"table-row-group", 0x5A43BD07}, + {FDE_CSSPROPERTYVALUE_TableColumn, L"table-column", 0x5E705DA3}, + {FDE_CSSPROPERTYVALUE_Static, L"static", 0x5E7555E8}, + {FDE_CSSPROPERTYVALUE_Outset, L"outset", 0x61236164}, + {FDE_CSSPROPERTYVALUE_DecimalLeadingZero, L"decimal-leading-zero", + 0x61DFC55D}, + {FDE_CSSPROPERTYVALUE_KeepWords, L"keep-words", 0x63964801}, + {FDE_CSSPROPERTYVALUE_KatakanaIroha, L"katakana-iroha", 0x65D7C91C}, + {FDE_CSSPROPERTYVALUE_Super, L"super", 0x6A4F842F}, + {FDE_CSSPROPERTYVALUE_Center, L"center", 0x6C51AFC1}, + {FDE_CSSPROPERTYVALUE_TableHeaderGroup, L"table-header-group", 0x706103D8}, + {FDE_CSSPROPERTYVALUE_Inside, L"inside", 0x709CB0FC}, + {FDE_CSSPROPERTYVALUE_XxLarge, L"xx-large", 0x70BB1508}, + {FDE_CSSPROPERTYVALUE_Triangle, L"triangle", 0x7524EDF6}, + {FDE_CSSPROPERTYVALUE_RubyTextGroup, L"ruby-text-group", 0x78C2B98E}, + {FDE_CSSPROPERTYVALUE_Circle, L"circle", 0x7ABEC0D2}, + {FDE_CSSPROPERTYVALUE_Hiragana, L"hiragana", 0x7BF5E25B}, + {FDE_CSSPROPERTYVALUE_RepeatX, L"repeat-x", 0x7C8F3226}, + {FDE_CSSPROPERTYVALUE_RepeatY, L"repeat-y", 0x7C8F3227}, + {FDE_CSSPROPERTYVALUE_Move, L"move", 0x7DA03417}, + {FDE_CSSPROPERTYVALUE_HiraganaIroha, L"hiragana-iroha", 0x7EE863FB}, + {FDE_CSSPROPERTYVALUE_RubyBase, L"ruby-base", 0x7FD1B1EA}, + {FDE_CSSPROPERTYVALUE_Scroll, L"scroll", 0x84787AEF}, + {FDE_CSSPROPERTYVALUE_Smaller, L"smaller", 0x849769F0}, + {FDE_CSSPROPERTYVALUE_TableFooterGroup, L"table-footer-group", 0x85BDD97E}, + {FDE_CSSPROPERTYVALUE_Baseline, L"baseline", 0x87436BA3}, + {FDE_CSSPROPERTYVALUE_Separate, L"separate", 0x877C66B5}, + {FDE_CSSPROPERTYVALUE_Armenian, L"armenian", 0x889BE4EB}, + {FDE_CSSPROPERTYVALUE_Open, L"open", 0x8B90E1F2}, + {FDE_CSSPROPERTYVALUE_Relative, L"relative", 0x8C995B5C}, + {FDE_CSSPROPERTYVALUE_Thick, L"thick", 0x8CC35EB3}, + {FDE_CSSPROPERTYVALUE_Justify, L"justify", 0x8D269CAE}, + {FDE_CSSPROPERTYVALUE_Middle, L"middle", 0x947FA00F}, + {FDE_CSSPROPERTYVALUE_Always, L"always", 0x959AB231}, + {FDE_CSSPROPERTYVALUE_DistributeSpace, L"distribute-space", 0x97A20E58}, + {FDE_CSSPROPERTYVALUE_LineEdge, L"line-edge", 0x9A845D2A}, + {FDE_CSSPROPERTYVALUE_PreWrap, L"pre-wrap", 0x9D59588E}, + {FDE_CSSPROPERTYVALUE_Medium, L"medium", 0xA084A381}, + {FDE_CSSPROPERTYVALUE_NResize, L"n-resize", 0xA088968D}, + {FDE_CSSPROPERTYVALUE_ListItem, L"list-item", 0xA32382B8}, + {FDE_CSSPROPERTYVALUE_Show, L"show", 0xA66C10C1}, + {FDE_CSSPROPERTYVALUE_Currentcolor, L"currentColor", 0xA7883922}, + {FDE_CSSPROPERTYVALUE_NoCloseQuote, L"no-close-quote", 0xA79CBFFB}, + {FDE_CSSPROPERTYVALUE_VerticalLr, L"vertical-lr", 0xA8673F65}, + {FDE_CSSPROPERTYVALUE_VerticalRl, L"vertical-rl", 0xA8675E25}, + {FDE_CSSPROPERTYVALUE_Pointer, L"pointer", 0xA90929C1}, + {FDE_CSSPROPERTYVALUE_XxSmall, L"xx-small", 0xADE1FC76}, + {FDE_CSSPROPERTYVALUE_Bold, L"bold", 0xB18313A1}, + {FDE_CSSPROPERTYVALUE_Both, L"both", 0xB1833CAD}, + {FDE_CSSPROPERTYVALUE_SmallCaps, L"small-caps", 0xB299428D}, + {FDE_CSSPROPERTYVALUE_Katakana, L"katakana", 0xB421A4BC}, + {FDE_CSSPROPERTYVALUE_After, L"after", 0xB6B44172}, + {FDE_CSSPROPERTYVALUE_Horizontal, L"horizontal", 0xB7732DEA}, + {FDE_CSSPROPERTYVALUE_Dotted, L"dotted", 0xB88652A4}, + {FDE_CSSPROPERTYVALUE_Disc, L"disc", 0xBEBC18C3}, + {FDE_CSSPROPERTYVALUE_Georgian, L"georgian", 0xBEF99E8C}, + {FDE_CSSPROPERTYVALUE_Inline, L"inline", 0xC02D649F}, + {FDE_CSSPROPERTYVALUE_Overline, L"overline", 0xC0EC9FA4}, + {FDE_CSSPROPERTYVALUE_Wait, L"wait", 0xC1613BB5}, + {FDE_CSSPROPERTYVALUE_BreakAll, L"break-all", 0xC3145BAB}, + {FDE_CSSPROPERTYVALUE_UpperAlpha, L"upper-alpha", 0xC52D4A9F}, + {FDE_CSSPROPERTYVALUE_Capitalize, L"capitalize", 0xC5321D46}, + {FDE_CSSPROPERTYVALUE_Nowrap, L"nowrap", 0xC7994417}, + {FDE_CSSPROPERTYVALUE_TextBottom, L"text-bottom", 0xC7D08D87}, + {FDE_CSSPROPERTYVALUE_NoOpenQuote, L"no-open-quote", 0xC8CD7877}, + {FDE_CSSPROPERTYVALUE_Groove, L"groove", 0xCB24A412}, + {FDE_CSSPROPERTYVALUE_Progress, L"progress", 0xCD1D9835}, + {FDE_CSSPROPERTYVALUE_Larger, L"larger", 0xCD3C409D}, + {FDE_CSSPROPERTYVALUE_CloseQuote, L"close-quote", 0xCF8696D1}, + {FDE_CSSPROPERTYVALUE_TableCell, L"table-cell", 0xCFB5E595}, + {FDE_CSSPROPERTYVALUE_PreLine, L"pre-line", 0xD04FEDBC}, + {FDE_CSSPROPERTYVALUE_Absolute, L"absolute", 0xD0B2D55F}, + {FDE_CSSPROPERTYVALUE_InlineTable, L"inline-table", 0xD131F494}, + {FDE_CSSPROPERTYVALUE_BidiOverride, L"bidi-override", 0xD161FDE5}, + {FDE_CSSPROPERTYVALUE_InlineBlock, L"inline-block", 0xD26A8BD7}, + {FDE_CSSPROPERTYVALUE_Inset, L"inset", 0xD6F23243}, + {FDE_CSSPROPERTYVALUE_Crosshair, L"crosshair", 0xD6F8018E}, + {FDE_CSSPROPERTYVALUE_UpperLatin, L"upper-latin", 0xD9D60531}, + {FDE_CSSPROPERTYVALUE_Help, L"help", 0xDA002969}, + {FDE_CSSPROPERTYVALUE_Hide, L"hide", 0xDA69395A}, + {FDE_CSSPROPERTYVALUE_Uppercase, L"uppercase", 0xDAD595A8}, + {FDE_CSSPROPERTYVALUE_SResize, L"s-resize", 0xDB3AADF2}, + {FDE_CSSPROPERTYVALUE_Table, L"table", 0xDB9BE968}, + {FDE_CSSPROPERTYVALUE_Blink, L"blink", 0xDC36E390}, + {FDE_CSSPROPERTYVALUE_Block, L"block", 0xDCD480AB}, + {FDE_CSSPROPERTYVALUE_Start, L"start", 0xE1D9D5AE}, + {FDE_CSSPROPERTYVALUE_TableColumnGroup, L"table-column-group", 0xE2258EFD}, + {FDE_CSSPROPERTYVALUE_Italic, L"italic", 0xE31D5396}, + {FDE_CSSPROPERTYVALUE_LineThrough, L"line-through", 0xE4C5A276}, + {FDE_CSSPROPERTYVALUE_KeepAll, L"keep-all", 0xE704A72B}, + {FDE_CSSPROPERTYVALUE_LowerAlpha, L"lower-alpha", 0xECB75A3C}, + {FDE_CSSPROPERTYVALUE_RunIn, L"run-in", 0xEEC930B9}, + {FDE_CSSPROPERTYVALUE_Square, L"square", 0xEF85D351}, + {FDE_CSSPROPERTYVALUE_XLarge, L"x-large", 0xF008E390}, + {FDE_CSSPROPERTYVALUE_Large, L"large", 0xF4434FCB}, + {FDE_CSSPROPERTYVALUE_Before, L"before", 0xF4FFCE73}, + {FDE_CSSPROPERTYVALUE_Left, L"left", 0xF5AD782B}, + {FDE_CSSPROPERTYVALUE_TextTop, L"text-top", 0xFCB58D45}, + {FDE_CSSPROPERTYVALUE_RubyText, L"ruby-text", 0xFCC77174}, + {FDE_CSSPROPERTYVALUE_NoDisplay, L"no-display", 0xFE482860}, +}; +static const FDE_CSSMEDIATYPETABLE g_FDE_CSSMediaTypes[] = { + {0xF09, 0x02}, {0x4880, 0x20}, {0x536A, 0x80}, + {0x741D, 0x10}, {0x76ED, 0x08}, {0x7CFB, 0x01}, + {0x9578, 0x04}, {0xC8E1, 0x40}, {0xD0F9, 0xFF}, +}; +static const FDE_CSSLENGTHUNITTABLE g_FDE_CSSLengthUnits[] = { + {0x0672, 3}, {0x067D, 4}, {0x1AF7, 8}, {0x2F7A, 7}, + {0x3ED3, 10}, {0x3EE4, 9}, {0x3EE8, 5}, {0xFC30, 6}, +}; +static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = { + {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000}, + {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff}, + {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0}, + {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500}, + {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080}, + {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff}, + {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00}, + {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00}, + {0xF6EFFF31, 0xff008000}, +}; +static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = { + {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC}, + {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D}, +}; +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); + FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); + int32_t iEnd = FDE_CSSPROPERTY_MAX - 1; + int32_t iMid, iStart = 0; + FX_DWORD dwMid; + do { + iMid = (iStart + iEnd) / 2; + dwMid = g_FDE_CSSProperties[iMid].dwHash; + if (dwHash == dwMid) { + return g_FDE_CSSProperties + iMid; + } else if (dwHash > dwMid) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iStart <= iEnd); + return NULL; +} +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); + FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); + int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1; + int32_t iMid, iStart = 0; + FX_DWORD dwMid; + do { + iMid = (iStart + iEnd) / 2; + dwMid = g_FDE_CSSPropertyValues[iMid].dwHash; + if (dwHash == dwMid) { + return g_FDE_CSSPropertyValues + iMid; + } else if (dwHash > dwMid) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iStart <= iEnd); + return NULL; +} +FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( + FDE_CSSPROPERTYVALUE eName) { + 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); + FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE); + int32_t iEnd = + sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1; + int32_t iMid, iStart = 0; + FX_WORD uMid; + do { + iMid = (iStart + iEnd) / 2; + uMid = g_FDE_CSSMediaTypes[iMid].wHash; + if (wHash == uMid) { + return g_FDE_CSSMediaTypes + iMid; + } else if (wHash > uMid) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iStart <= iEnd); + return NULL; +} +FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, + int32_t iLength) { + FXSYS_assert(pszName != NULL && iLength > 0); + FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE); + int32_t iEnd = + sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1; + int32_t iMid, iStart = 0; + FX_WORD wMid; + do { + iMid = (iStart + iEnd) / 2; + wMid = g_FDE_CSSLengthUnits[iMid].wHash; + if (wHash == wMid) { + return g_FDE_CSSLengthUnits + iMid; + } else if (wHash > wMid) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iStart <= iEnd); + return NULL; +} +FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName, + int32_t iLength) { + FXSYS_assert(pszName != NULL && iLength > 0); + FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); + int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1; + int32_t iMid, iStart = 0; + FX_DWORD dwMid; + do { + iMid = (iStart + iEnd) / 2; + dwMid = g_FDE_CSSColors[iMid].dwHash; + if (dwHash == dwMid) { + return g_FDE_CSSColors + iMid; + } else if (dwHash > dwMid) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iStart <= iEnd); + return NULL; +} +FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_FLOAT& fValue, + FDE_CSSPRIMITIVETYPE& eUnit) { + FXSYS_assert(pszValue != NULL && iValueLen > 0); + int32_t iUsedLen = 0; + fValue = FX_wcstof(pszValue, iValueLen, &iUsedLen); + if (iUsedLen <= 0) { + return FALSE; + } + iValueLen -= iUsedLen; + pszValue += iUsedLen; + eUnit = FDE_CSSPRIMITIVETYPE_Number; + if (iValueLen >= 1 && *pszValue == '%') { + eUnit = FDE_CSSPRIMITIVETYPE_Percent; + } else if (iValueLen == 2) { + FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2); + if (pUnit != NULL) { + eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue; + } + } + return TRUE; +} + +FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue, + int32_t iValueLen, + int32_t& iOffset, + int32_t& iLength) { + FXSYS_assert(pszValue != NULL && iValueLen > 0); + iOffset = 0; + iLength = iValueLen; + if (iValueLen >= 2) { + FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1]; + if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) { + iOffset = 1, iLength -= 2; + } + } + return iValueLen > 0; +} + +FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue, + int32_t iValueLen, + int32_t& iOffset, + int32_t& iLength) { + FXSYS_assert(pszValue != NULL && iValueLen > 0); + if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' || + FX_wcsnicmp(L"url(", pszValue, 4)) { + return FALSE; + } + if (FDE_ParseCSSString(pszValue + 4, iValueLen - 5, iOffset, iLength)) { + iOffset += 4; + return TRUE; + } + return FALSE; +} + +FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_ARGB& dwColor) { + FXSYS_assert(pszValue != NULL && iValueLen > 0); + if (*pszValue == '#') { + switch (iValueLen) { + case 4: { + uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]); + uint8_t green = FX_Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]); + uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]); + dwColor = ArgbEncode(255, red, green, blue); + } + return TRUE; + case 7: { + uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]); + uint8_t green = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]); + uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]); + dwColor = ArgbEncode(255, red, green, blue); + } + return TRUE; + } + } else if (iValueLen >= 10) { + if (pszValue[iValueLen - 1] != ')' || FX_wcsnicmp(L"rgb(", pszValue, 4)) { + return FALSE; + } + uint8_t rgb[3] = {0}; + FX_FLOAT fValue; + FDE_CSSPRIMITIVETYPE eType; + CFDE_CSSValueListParser list(pszValue + 4, iValueLen - 5, ','); + for (int32_t i = 0; i < 3; ++i) { + if (!list.NextValue(eType, pszValue, iValueLen)) { + return FALSE; + } + if (eType != FDE_CSSPRIMITIVETYPE_Number) { + return FALSE; + } + if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + return FALSE; + } + rgb[i] = eType == FDE_CSSPRIMITIVETYPE_Percent + ? FXSYS_round(fValue * 2.55f) + : FXSYS_round(fValue); + } + dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]); + return TRUE; + } else { + FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen); + if (pColor != NULL) { + dwColor = pColor->dwValue; + return TRUE; + } + } + return FALSE; +} + +CFDE_CSSValueList::CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore, + const CFDE_CSSValueArray& list) { + m_iCount = list.GetSize(); + int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*); + m_ppList = (IFDE_CSSValue**)pStaticStore->Alloc(iByteCount); + FXSYS_memcpy(m_ppList, list.GetData(), iByteCount); +} +FX_BOOL CFDE_CSSValueListParser::NextValue(FDE_CSSPRIMITIVETYPE& eType, + const FX_WCHAR*& pStart, + int32_t& iLength) { + while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator)) { + ++m_pCur; + } + if (m_pCur >= m_pEnd) { + return FALSE; + } + eType = FDE_CSSPRIMITIVETYPE_Unknown; + pStart = m_pCur; + iLength = 0; + FX_WCHAR wch = *m_pCur; + if (wch == '#') { + iLength = SkipTo(' '); + if (iLength == 4 || iLength == 7) { + eType = FDE_CSSPRIMITIVETYPE_RGB; + } + } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' || + wch == '+') { + while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) { + ++m_pCur; + } + iLength = m_pCur - pStart; + if (iLength > 0) { + eType = FDE_CSSPRIMITIVETYPE_Number; + } + } else if (wch == '\"' || wch == '\'') { + pStart++; + iLength = SkipTo(wch) - 1; + m_pCur++; + eType = FDE_CSSPRIMITIVETYPE_String; + } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') { + if (FX_wcsnicmp(L"url", m_pCur, 3) == 0) { + wch = m_pCur[4]; + if (wch == '\"' || wch == '\'') { + pStart += 5; + iLength = SkipTo(wch) - 6; + m_pCur += 2; + } else { + pStart += 4; + iLength = SkipTo(')') - 4; + m_pCur++; + } + eType = FDE_CSSPRIMITIVETYPE_URI; + } else if (FX_wcsnicmp(L"rgb", m_pCur, 3) == 0) { + iLength = SkipTo(')') + 1; + m_pCur++; + eType = FDE_CSSPRIMITIVETYPE_RGB; + } + } else { + iLength = SkipTo(m_Separator, TRUE, TRUE); + eType = FDE_CSSPRIMITIVETYPE_String; + } + return m_pCur <= m_pEnd && iLength > 0; +} +int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch, + FX_BOOL bWSSeparator, + FX_BOOL bBrContinue) { + const FX_WCHAR* pStart = m_pCur; + if (!bBrContinue) { + if (bWSSeparator) { + while ((++m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) { + continue; + } + } else { + while (++m_pCur < m_pEnd && *m_pCur != wch) { + continue; + } + } + + } else { + int32_t iBracketCount = 0; + if (bWSSeparator) { + while ((m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) { + if (*m_pCur == '(') { + iBracketCount++; + } else if (*m_pCur == ')') { + iBracketCount--; + } + m_pCur++; + } + } else { + while (m_pCur < m_pEnd && *m_pCur != wch) { + if (*m_pCur == '(') { + iBracketCount++; + } else if (*m_pCur == ')') { + iBracketCount--; + } + m_pCur++; + } + } + while (iBracketCount > 0 && m_pCur < m_pEnd) { + if (*m_pCur == ')') { + iBracketCount--; + } + m_pCur++; + } + } + return m_pCur - pStart; +} diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h new file mode 100644 index 0000000000..ef7e0dc704 --- /dev/null +++ b/xfa/fde/css/fde_cssdatatable.h @@ -0,0 +1,200 @@ +// 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_CSS_FDE_CSSDATATABLE_H_ +#define XFA_FDE_CSS_FDE_CSSDATATABLE_H_ + +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fde/css/fde_css.h" +#include "xfa/fgas/crt/fgas_memory.h" + +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); + } + int32_t CountArgs() const { return m_pArgList->CountValues(); } + IFDE_CSSValue* GetArgs(int32_t index) const { + return m_pArgList->GetValue(index); + } + const FX_WCHAR* GetFuncName() const { return m_pszFuncName; } + + protected: + IFDE_CSSValueList* m_pArgList; + const FX_WCHAR* m_pszFuncName; +}; +class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue, + public CFX_Target { + public: + CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src) { *this = src; } + CFDE_CSSPrimitiveValue(FX_ARGB color) + : m_eType(FDE_CSSPRIMITIVETYPE_RGB), m_dwColor(color) {} + CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue) + : m_eType(FDE_CSSPRIMITIVETYPE_Enum), m_eEnum(eValue) {} + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, FX_FLOAT fValue) + : 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); + } + CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction) + : m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {} + + virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const { return m_eType; } + + virtual FX_ARGB GetRGBColor() const { + FXSYS_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); + return m_fNumber; + } + virtual const FX_WCHAR* GetString(int32_t& iLength) const { + FXSYS_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); + return m_eEnum; + } + virtual const FX_WCHAR* GetFuncName() const { + FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function); + return m_pFunction->GetFuncName(); + } + virtual int32_t CountArgs() const { + FXSYS_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); + return m_pFunction->GetArgs(index); + } + + FDE_CSSPRIMITIVETYPE m_eType; + union { + FX_ARGB m_dwColor; + FX_FLOAT m_fNumber; + const FX_WCHAR* m_pString; + FDE_CSSPROPERTYVALUE m_eEnum; + CFDE_CSSFunction* m_pFunction; + }; +}; +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, + const CFDE_CSSValueArray& list); + virtual int32_t CountValues() const { return m_iCount; } + virtual IFDE_CSSValue* GetValue(int32_t index) const { + return m_ppList[index]; + } + + protected: + IFDE_CSSValue** m_ppList; + int32_t m_iCount; +}; +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); + } + FX_BOOL NextValue(FDE_CSSPRIMITIVETYPE& eType, + const FX_WCHAR*& pStart, + int32_t& iLength); + FX_WCHAR m_Separator; + + protected: + int32_t SkipTo(FX_WCHAR wch, + FX_BOOL bWSSeparator = FALSE, + FX_BOOL bBrContinue = FALSE); + const FX_WCHAR* m_pCur; + const FX_WCHAR* m_pEnd; +}; + +#define FDE_CSSVALUETYPE_MaybeNumber 0x0100 +#define FDE_CSSVALUETYPE_MaybeEnum 0x0200 +#define FDE_CSSVALUETYPE_MaybeURI 0x0400 +#define FDE_CSSVALUETYPE_MaybeString 0x0800 +#define FDE_CSSVALUETYPE_MaybeColor 0x1000 +#define FDE_CSSVALUETYPE_MaybeFunction 0x2000 +#define FDE_IsOnlyValue(type, enum) \ + (((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive) +struct FDE_CSSPROPERTYTABLE { + FDE_CSSPROPERTY eName; + const FX_WCHAR* pszName; + FX_DWORD dwHash; + FX_DWORD dwType; +}; +typedef FDE_CSSPROPERTYTABLE const* FDE_LPCCSSPROPERTYTABLE; + +FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName, + int32_t iLength); +FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName); +struct FDE_CSSPROPERTYVALUETABLE { + FDE_CSSPROPERTYVALUE eName; + const FX_WCHAR* pszName; + FX_DWORD dwHash; +}; +typedef FDE_CSSPROPERTYVALUETABLE const* FDE_LPCCSSPROPERTYVALUETABLE; + +FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName( + const FX_WCHAR* pszName, + int32_t iLength); +FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( + FDE_CSSPROPERTYVALUE eName); +struct FDE_CSSMEDIATYPETABLE { + FX_WORD wHash; + FX_WORD wValue; +}; +typedef FDE_CSSMEDIATYPETABLE const* FDE_LPCCSSMEDIATYPETABLE; +FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName, + int32_t iLength); +struct FDE_CSSLENGTHUNITTABLE { + FX_WORD wHash; + FX_WORD wValue; +}; +typedef FDE_CSSLENGTHUNITTABLE const* FDE_LPCCSSLENGTHUNITTABLE; +FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, + int32_t iLength); +struct FDE_CSSCOLORTABLE { + FX_DWORD dwHash; + FX_ARGB dwValue; +}; +typedef FDE_CSSCOLORTABLE const* FDE_LPCCSSCOLORTABLE; +FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName, + int32_t iLength); +struct FDE_CSSPERSUDOTABLE { + FDE_CSSPERSUDO eName; + const FX_WCHAR* pszName; + FX_DWORD dwHash; +}; +typedef FDE_CSSPERSUDOTABLE const* FDE_LPCCSSPERSUDOTABLE; + +FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo); +FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_FLOAT& fValue, + FDE_CSSPRIMITIVETYPE& eUnit); +FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue, + int32_t iValueLen, + int32_t& iOffset, + int32_t& iLength); +FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_ARGB& dwColor); +FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue, + int32_t iValueLen, + int32_t& iOffset, + int32_t& iLength); + +#endif // XFA_FDE_CSS_FDE_CSSDATATABLE_H_ diff --git a/xfa/fde/css/fde_cssdeclaration.cpp b/xfa/fde/css/fde_cssdeclaration.cpp new file mode 100644 index 0000000000..decc397bdc --- /dev/null +++ b/xfa/fde/css/fde_cssdeclaration.cpp @@ -0,0 +1,1377 @@ +// 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/css/fde_cssdeclaration.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_system.h" + +IFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSPROPERTY eProperty, + FX_BOOL& bImportant) const { + for (const FDE_CSSPropertyHolder* pHolder = m_pFirstProperty; pHolder; + pHolder = pHolder->pNext) { + if (pHolder->eProperty == eProperty) { + bImportant = pHolder->bImportant; + return pHolder->pValue; + } + } + return NULL; +} +FX_POSITION CFDE_CSSDeclaration::GetStartPosition() const { + return (FX_POSITION)m_pFirstProperty; +} +void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos, + FDE_CSSPROPERTY& eProperty, + IFDE_CSSValue*& pValue, + FX_BOOL& bImportant) const { + const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos; + FXSYS_assert(pHolder != NULL); + bImportant = pHolder->bImportant; + eProperty = (FDE_CSSPROPERTY)pHolder->eProperty; + pValue = pHolder->pValue; + pos = (FX_POSITION)pHolder->pNext; +} +FX_POSITION CFDE_CSSDeclaration::GetStartCustom() const { + return (FX_POSITION)m_pFirstCustom; +} +void CFDE_CSSDeclaration::GetNextCustom(FX_POSITION& pos, + CFX_WideString& wsName, + CFX_WideString& wsValue) const { + const FDE_CSSCustomProperty* pProperty = (const FDE_CSSCustomProperty*)pos; + if (pProperty == NULL) { + return; + } + wsName = pProperty->pwsName; + wsValue = pProperty->pwsValue; + pos = (FX_POSITION)pProperty->pNext; +} +const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + FXSYS_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); + if (pCache->Lookup(pKey, pszCached)) { + return (const FX_WCHAR*)pszCached; + } + } + FX_WCHAR* psz = + (FX_WCHAR*)pArgs->pStaticStore->Alloc((iValueLen + 1) * sizeof(FX_WCHAR)); + if (psz == NULL) { + return NULL; + } + FXSYS_wcsncpy(psz, pszValue, iValueLen); + psz[iValueLen] = '\0'; + if (pCache) { + pCache->SetAt(pKey, psz); + } + return psz; +} +IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue( + IFX_MEMAllocator* pStaticStore, + FDE_CSSPRIMITIVETYPE eUnit, + FX_FLOAT fValue) const { + static CFDE_CSSPrimitiveValue s_ZeroValue(FDE_CSSPRIMITIVETYPE_Number, 0.0f); + if (eUnit == FDE_CSSPRIMITIVETYPE_Number && FXSYS_fabs(fValue) < 0.001f) { + return &s_ZeroValue; + } + return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eUnit, fValue); +} +inline IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewEnumValue( + IFX_MEMAllocator* pStaticStore, + FDE_CSSPROPERTYVALUE eValue) const { + return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eValue); +} +void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore, + FDE_CSSPROPERTY eProperty, + IFDE_CSSValue* pValue, + FX_BOOL bImportant) { + FDE_CSSPropertyHolder* pHolder = + FXTARGET_NewWith(pStaticStore) FDE_CSSPropertyHolder; + pHolder->bImportant = bImportant; + pHolder->eProperty = eProperty; + pHolder->pValue = pValue; + pHolder->pNext = NULL; + if (m_pLastProperty == NULL) { + m_pLastProperty = m_pFirstProperty = pHolder; + } else { + m_pLastProperty->pNext = pHolder; + m_pLastProperty = pHolder; + } +} +FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + FXSYS_assert(iValueLen > 0); + FX_BOOL bImportant = FALSE; + if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' && + FX_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) { + if ((iValueLen -= 10) == 0) { + return FALSE; + } + bImportant = TRUE; + } + const FX_DWORD dwType = pArgs->pProperty->dwType; + switch (dwType & 0x0F) { + case FDE_CSSVALUETYPE_Primitive: { + static const FX_DWORD g_ValueGuessOrder[] = { + FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum, + FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeURI, + FDE_CSSVALUETYPE_MaybeFunction, FDE_CSSVALUETYPE_MaybeString, + }; + static const int32_t g_ValueGuessCount = + sizeof(g_ValueGuessOrder) / sizeof(FX_DWORD); + for (int32_t i = 0; i < g_ValueGuessCount; ++i) { + const FX_DWORD dwMatch = dwType & g_ValueGuessOrder[i]; + if (dwMatch == 0) { + continue; + } + IFDE_CSSValue* pCSSValue = NULL; + switch (dwMatch) { + case FDE_CSSVALUETYPE_MaybeFunction: + pCSSValue = ParseFunction(pArgs, pszValue, iValueLen); + break; + case FDE_CSSVALUETYPE_MaybeNumber: + pCSSValue = ParseNumber(pArgs, pszValue, iValueLen); + break; + case FDE_CSSVALUETYPE_MaybeEnum: + pCSSValue = ParseEnum(pArgs, pszValue, iValueLen); + break; + case FDE_CSSVALUETYPE_MaybeColor: + pCSSValue = ParseColor(pArgs, pszValue, iValueLen); + break; + case FDE_CSSVALUETYPE_MaybeURI: + pCSSValue = ParseURI(pArgs, pszValue, iValueLen); + break; + case FDE_CSSVALUETYPE_MaybeString: + pCSSValue = ParseString(pArgs, pszValue, iValueLen); + break; + default: + break; + } + if (pCSSValue != NULL) { + AddPropertyHolder(pArgs->pStaticStore, pArgs->pProperty->eName, + pCSSValue, bImportant); + return TRUE; + } + if (FDE_IsOnlyValue(dwType, g_ValueGuessOrder[i])) { + return FALSE; + } + } + } break; + case FDE_CSSVALUETYPE_Shorthand: { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + IFDE_CSSValue *pColor, *pStyle, *pWidth; + switch (pArgs->pProperty->eName) { + case FDE_CSSPROPERTY_Font: + return ParseFontProperty(pArgs, pszValue, iValueLen, bImportant); + case FDE_CSSPROPERTY_Background: + return ParseBackgroundProperty(pArgs, pszValue, iValueLen, + bImportant); + case FDE_CSSPROPERTY_ListStyle: + return ParseListStyleProperty(pArgs, pszValue, iValueLen, bImportant); + case FDE_CSSPROPERTY_Border: + if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, + pStyle, pWidth)) { + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderLeftColor, + FDE_CSSPROPERTY_BorderLeftStyle, + FDE_CSSPROPERTY_BorderLeftWidth); + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderTopColor, + FDE_CSSPROPERTY_BorderTopStyle, + FDE_CSSPROPERTY_BorderTopWidth); + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderRightColor, + FDE_CSSPROPERTY_BorderRightStyle, + FDE_CSSPROPERTY_BorderRightWidth); + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderBottomColor, + FDE_CSSPROPERTY_BorderBottomStyle, + FDE_CSSPROPERTY_BorderBottomWidth); + return TRUE; + } + break; + case FDE_CSSPROPERTY_BorderLeft: + if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, + pStyle, pWidth)) { + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderLeftColor, + FDE_CSSPROPERTY_BorderLeftStyle, + FDE_CSSPROPERTY_BorderLeftWidth); + return TRUE; + } + break; + case FDE_CSSPROPERTY_BorderTop: + if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, + pStyle, pWidth)) { + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderTopColor, + FDE_CSSPROPERTY_BorderTopStyle, + FDE_CSSPROPERTY_BorderTopWidth); + return TRUE; + } + break; + case FDE_CSSPROPERTY_BorderRight: + if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, + pStyle, pWidth)) { + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderRightColor, + FDE_CSSPROPERTY_BorderRightStyle, + FDE_CSSPROPERTY_BorderRightWidth); + return TRUE; + } + break; + case FDE_CSSPROPERTY_BorderBottom: + if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, + pStyle, pWidth)) { + AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, + FDE_CSSPROPERTY_BorderBottomColor, + FDE_CSSPROPERTY_BorderBottomStyle, + FDE_CSSPROPERTY_BorderBottomWidth); + return TRUE; + } + break; + case FDE_CSSPROPERTY_Overflow: + return ParseOverflowProperty(pArgs, pszValue, iValueLen, bImportant); + case FDE_CSSPROPERTY_ColumnRule: + return ParseColumnRuleProperty(pArgs, pszValue, iValueLen, + bImportant); + default: + break; + } + } break; + case FDE_CSSVALUETYPE_List: + switch (pArgs->pProperty->eName) { + case FDE_CSSPROPERTY_CounterIncrement: + case FDE_CSSPROPERTY_CounterReset: + return ParseCounterProperty(pArgs, pszValue, iValueLen, bImportant); + case FDE_CSSPROPERTY_Content: + return ParseContentProperty(pArgs, pszValue, iValueLen, bImportant); + default: + return ParseValueListProperty(pArgs, pszValue, iValueLen, bImportant); + } + default: + FXSYS_assert(FALSE); + break; + } + return FALSE; +} +FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszName, + int32_t iNameLen, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + FDE_CSSCustomProperty* pProperty = + FXTARGET_NewWith(pArgs->pStaticStore) FDE_CSSCustomProperty; + pProperty->pwsName = CopyToLocal(pArgs, pszName, iNameLen); + pProperty->pwsValue = CopyToLocal(pArgs, pszValue, iValueLen); + pProperty->pNext = NULL; + if (m_pLastCustom == NULL) { + m_pLastCustom = m_pFirstCustom = pProperty; + } else { + m_pLastCustom->pNext = pProperty; + m_pLastCustom = pProperty; + } + return TRUE; +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + FX_FLOAT fValue; + FDE_CSSPRIMITIVETYPE eUnit; + if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eUnit)) { + return NULL; + } + return NewNumberValue(pArgs->pStaticStore, eUnit, fValue); +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + return pValue ? NewEnumValue(pArgs->pStaticStore, pValue->eName) : NULL; +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + FX_ARGB dwColor; + if (!FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + return NULL; + } + return FXTARGET_NewWith(pArgs->pStaticStore) CFDE_CSSPrimitiveValue(dwColor); +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + int32_t iOffset; + if (!FDE_ParseCSSURI(pszValue, iValueLen, iOffset, iValueLen)) { + return NULL; + } + if (iValueLen <= 0) { + return NULL; + } + pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen); + return pszValue + ? FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_URI, pszValue) + : NULL; +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseString( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + int32_t iOffset; + if (!FDE_ParseCSSString(pszValue, iValueLen, iOffset, iValueLen)) { + return NULL; + } + if (iValueLen <= 0) { + return NULL; + } + pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen); + return pszValue + ? FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue) + : NULL; +} +IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen) { + if (pszValue[iValueLen - 1] != ')') { + return NULL; + } + int32_t iStartBracket = 0; + while (pszValue[iStartBracket] != '(') { + if (iStartBracket < iValueLen) { + iStartBracket++; + } else { + return NULL; + } + } + if (iStartBracket == 0) { + return NULL; + } + const FX_WCHAR* pszFuncName = CopyToLocal(pArgs, pszValue, iStartBracket); + pszValue += (iStartBracket + 1); + iValueLen -= (iStartBracket + 2); + CFDE_CSSValueArray argumentArr; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ','); + FDE_CSSPRIMITIVETYPE ePrimitiveType; + while (parser.NextValue(ePrimitiveType, pszValue, iValueLen)) { + switch (ePrimitiveType) { + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pPropertyValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pPropertyValue != NULL) { + argumentArr.Add( + NewEnumValue(pArgs->pStaticStore, pPropertyValue->eName)); + continue; + } + IFDE_CSSValue* pFunctionValue = + ParseFunction(pArgs, pszValue, iValueLen); + if (pFunctionValue != NULL) { + argumentArr.Add(pFunctionValue); + continue; + } + argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSPrimitiveValue( + FDE_CSSPRIMITIVETYPE_String, + CopyToLocal(pArgs, pszValue, iValueLen))); + } break; + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, ePrimitiveType)) { + argumentArr.Add( + NewNumberValue(pArgs->pStaticStore, ePrimitiveType, fValue)); + } + } break; + default: + argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSPrimitiveValue( + FDE_CSSPRIMITIVETYPE_String, + CopyToLocal(pArgs, pszValue, iValueLen))); + break; + } + } + IFDE_CSSValueList* pArgumentList = FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSValueList(pArgs->pStaticStore, argumentArr); + CFDE_CSSFunction* pFunction = FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSFunction(pszFuncName, pArgumentList); + return FXTARGET_NewWith(pArgs->pStaticStore) + CFDE_CSSPrimitiveValue(pFunction); +} +FX_BOOL CFDE_CSSDeclaration::ParseContentProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = (IFX_MEMAllocator*)pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + FDE_CSSPRIMITIVETYPE eType; + CFDE_CSSValueArray list; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_URI: + list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + eType, CopyToLocal(pArgs, pszValue, iValueLen))); + break; + case FDE_CSSPRIMITIVETYPE_Number: + return FALSE; + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_Normal: + case FDE_CSSPROPERTYVALUE_None: { + if (list.GetSize() == 0) { + list.Add(NewEnumValue(pStaticStore, pValue->eName)); + } else { + return FALSE; + } + } break; + case FDE_CSSPROPERTYVALUE_OpenQuote: + case FDE_CSSPROPERTYVALUE_CloseQuote: + case FDE_CSSPROPERTYVALUE_NoOpenQuote: + case FDE_CSSPROPERTYVALUE_NoCloseQuote: + list.Add(NewEnumValue(pStaticStore, pValue->eName)); + break; + default: + return FALSE; + } + continue; + } + IFDE_CSSValue* pFunction = ParseFunction(pArgs, pszValue, iValueLen); + if (pFunction != NULL) { + list.Add(pFunction); + continue; + } + list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + eType, CopyToLocal(pArgs, pszValue, iValueLen))); + } break; + case FDE_CSSPRIMITIVETYPE_RGB: + return FALSE; + default: + break; + } + } + if (list.GetSize() == 0) { + return FALSE; + } + AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, + FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, list), + bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseCounterProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + CFDE_CSSValueArray list; + CFDE_CSSValueArray listFull; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + if (list.GetSize() == 1) { + list.Add(NewNumberValue(pStaticStore, eType, fValue)); + listFull.Add(FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, list)); + list.RemoveAll(); + } else { + return FALSE; + } + } + } break; + case FDE_CSSPRIMITIVETYPE_String: { + if (list.GetSize() == 0) { + pszValue = CopyToLocal(pArgs, pszValue, iValueLen); + list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + FDE_CSSPRIMITIVETYPE_String, pszValue)); + } else { + listFull.Add(FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, list)); + list.RemoveAll(); + pszValue = CopyToLocal(pArgs, pszValue, iValueLen); + list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + FDE_CSSPRIMITIVETYPE_String, pszValue)); + } + } break; + default: + break; + } + } + if (list.GetSize() == 1) { + listFull.Add(FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, list)); + } + if (listFull.GetSize() == 0) { + return FALSE; + } + AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, + FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, listFull), + bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + FX_WCHAR separator = + (pArgs->pProperty->eName == FDE_CSSPROPERTY_FontFamily) ? ',' : ' '; + CFDE_CSSValueListParser parser(pszValue, iValueLen, separator); + const FX_DWORD dwType = pArgs->pProperty->dwType; + FDE_CSSPRIMITIVETYPE eType; + CFDE_CSSValueArray list; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_Number: + if (dwType & FDE_CSSVALUETYPE_MaybeNumber) { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + list.Add(NewNumberValue(pStaticStore, eType, fValue)); + } + } + break; + case FDE_CSSPRIMITIVETYPE_String: + if (dwType & FDE_CSSVALUETYPE_MaybeColor) { + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + list.Add(FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue(dwColor)); + continue; + } + } + if (dwType & FDE_CSSVALUETYPE_MaybeEnum) { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + list.Add(NewEnumValue(pStaticStore, pValue->eName)); + continue; + } + } + if (dwType & FDE_CSSVALUETYPE_MaybeString) { + pszValue = CopyToLocal(pArgs, pszValue, iValueLen); + list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + FDE_CSSPRIMITIVETYPE_String, pszValue)); + } + break; + case FDE_CSSPRIMITIVETYPE_RGB: + if (dwType & FDE_CSSVALUETYPE_MaybeColor) { + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + list.Add(FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue(dwColor)); + } + } + break; + default: + break; + } + } + if (list.GetSize() == 0) { + return FALSE; + } + switch (pArgs->pProperty->eName) { + case FDE_CSSPROPERTY_BorderColor: + return Add4ValuesProperty( + pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftColor, + FDE_CSSPROPERTY_BorderTopColor, FDE_CSSPROPERTY_BorderRightColor, + FDE_CSSPROPERTY_BorderBottomColor); + case FDE_CSSPROPERTY_BorderStyle: + return Add4ValuesProperty( + pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftStyle, + FDE_CSSPROPERTY_BorderTopStyle, FDE_CSSPROPERTY_BorderRightStyle, + FDE_CSSPROPERTY_BorderBottomStyle); + case FDE_CSSPROPERTY_BorderWidth: + return Add4ValuesProperty( + pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftWidth, + FDE_CSSPROPERTY_BorderTopWidth, FDE_CSSPROPERTY_BorderRightWidth, + FDE_CSSPROPERTY_BorderBottomWidth); + case FDE_CSSPROPERTY_Margin: + return Add4ValuesProperty( + pStaticStore, list, bImportant, FDE_CSSPROPERTY_MarginLeft, + FDE_CSSPROPERTY_MarginTop, FDE_CSSPROPERTY_MarginRight, + FDE_CSSPROPERTY_MarginBottom); + case FDE_CSSPROPERTY_Padding: + return Add4ValuesProperty( + pStaticStore, list, bImportant, FDE_CSSPROPERTY_PaddingLeft, + FDE_CSSPROPERTY_PaddingTop, FDE_CSSPROPERTY_PaddingRight, + FDE_CSSPROPERTY_PaddingBottom); + default: { + CFDE_CSSValueList* pList = + FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, list); + AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, pList, + bImportant); + return TRUE; + } break; + } + 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) { + switch (list.GetSize()) { + case 1: + AddPropertyHolder(pStaticStore, eLeft, list[0], bImportant); + AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); + AddPropertyHolder(pStaticStore, eRight, list[0], bImportant); + AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant); + return TRUE; + case 2: + AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant); + AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); + AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); + AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant); + return TRUE; + case 3: + AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant); + AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); + AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); + AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant); + return TRUE; + case 4: + AddPropertyHolder(pStaticStore, eLeft, list[3], bImportant); + AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); + AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); + AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant); + return TRUE; + default: + break; + } + return FALSE; +} +FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty( + IFX_MEMAllocator* pStaticStore, + const FX_WCHAR* pszValue, + int32_t iValueLen, + IFDE_CSSValue*& pColor, + IFDE_CSSValue*& pStyle, + IFDE_CSSValue*& pWidth) const { + pColor = pStyle = pWidth = NULL; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_Number: + if (pWidth == NULL) { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + pWidth = NewNumberValue(pStaticStore, eType, fValue); + } + } + break; + case FDE_CSSPRIMITIVETYPE_RGB: + if (pColor == NULL) { + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + pColor = + FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); + } + } + break; + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSCOLORTABLE* pColorItem = + FDE_GetCSSColorByName(pszValue, iValueLen); + if (pColorItem != NULL) { + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue(pColorItem->dwValue); + } + continue; + } + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue == NULL) { + continue; + } + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_Transparent: + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue((FX_ARGB)0); + } + break; + case FDE_CSSPROPERTYVALUE_Thin: + case FDE_CSSPROPERTYVALUE_Thick: + case FDE_CSSPROPERTYVALUE_Medium: + if (pWidth == NULL) { + pWidth = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_None: + case FDE_CSSPROPERTYVALUE_Hidden: + case FDE_CSSPROPERTYVALUE_Dotted: + case FDE_CSSPROPERTYVALUE_Dashed: + case FDE_CSSPROPERTYVALUE_Solid: + case FDE_CSSPROPERTYVALUE_Double: + case FDE_CSSPROPERTYVALUE_Groove: + case FDE_CSSPROPERTYVALUE_Ridge: + case FDE_CSSPROPERTYVALUE_Inset: + case FDE_CSSPROPERTYVALUE_Outset: + if (pStyle == NULL) { + pStyle = NewEnumValue(pStaticStore, pValue->eName); + } + break; + default: + break; + } + }; break; + default: + break; + } + } + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); + } + if (pStyle == NULL) { + pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); + } + if (pWidth == NULL) { + pWidth = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); + } + return TRUE; +} +void CFDE_CSSDeclaration::AddBorderProperty(IFX_MEMAllocator* pStaticStore, + IFDE_CSSValue* pColor, + IFDE_CSSValue* pStyle, + IFDE_CSSValue* pWidth, + FX_BOOL bImportant, + FDE_CSSPROPERTY eColor, + FDE_CSSPROPERTY eStyle, + FDE_CSSPROPERTY eWidth) { + AddPropertyHolder(pStaticStore, eStyle, pStyle, bImportant); + AddPropertyHolder(pStaticStore, eWidth, pWidth, bImportant); + AddPropertyHolder(pStaticStore, eColor, pColor, bImportant); +} +FX_BOOL CFDE_CSSDeclaration::ParseListStyleProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + IFDE_CSSPrimitiveValue *pType = NULL, *pImage = NULL, *pPosition = NULL; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_URI: + if (pImage == NULL) { + pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + eType, CopyToLocal(pArgs, pszValue, iValueLen)); + } + break; + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue == NULL) { + break; + } + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_None: + if (pImage == NULL) { + pImage = NewEnumValue(pStaticStore, pValue->eName); + } else if (pType == NULL) { + pImage = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Inside: + case FDE_CSSPROPERTYVALUE_Outside: + if (pPosition == NULL) { + pPosition = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Disc: + case FDE_CSSPROPERTYVALUE_Circle: + case FDE_CSSPROPERTYVALUE_Square: + case FDE_CSSPROPERTYVALUE_Decimal: + case FDE_CSSPROPERTYVALUE_DecimalLeadingZero: + case FDE_CSSPROPERTYVALUE_LowerRoman: + case FDE_CSSPROPERTYVALUE_UpperRoman: + case FDE_CSSPROPERTYVALUE_LowerGreek: + case FDE_CSSPROPERTYVALUE_LowerLatin: + case FDE_CSSPROPERTYVALUE_UpperLatin: + case FDE_CSSPROPERTYVALUE_Armenian: + case FDE_CSSPROPERTYVALUE_Georgian: + case FDE_CSSPROPERTYVALUE_LowerAlpha: + case FDE_CSSPROPERTYVALUE_UpperAlpha: + if (pType == NULL) { + pType = NewEnumValue(pStaticStore, pValue->eName); + } + break; + default: + break; + } + }; break; + default: + break; + } + } + if (pPosition == NULL) { + pPosition = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Outside); + } + if (pImage == NULL) { + pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); + } + if (pType == NULL) { + pType = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); + } + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStylePosition, pPosition, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleImage, pImage, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleType, pType, + bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + IFDE_CSSPrimitiveValue *pColor = NULL, *pImage = NULL, *pRepeat = NULL; + IFDE_CSSPrimitiveValue *pPosX = NULL, *pPosY = NULL, *pAttachment = NULL; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_URI: + if (pImage == NULL) { + pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + eType, CopyToLocal(pArgs, pszValue, iValueLen)); + } + break; + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + break; + } + if (pPosX == NULL) { + pPosX = NewNumberValue(pStaticStore, eType, fValue); + } else if (pPosY == NULL) { + pPosY = NewNumberValue(pStaticStore, eType, fValue); + } + } break; + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_None: + if (pImage == NULL) { + pImage = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Transparent: + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue((FX_ARGB)0); + } + break; + case FDE_CSSPROPERTYVALUE_Fixed: + case FDE_CSSPROPERTYVALUE_Scroll: + if (pAttachment == NULL) { + pAttachment = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Repeat: + case FDE_CSSPROPERTYVALUE_RepeatX: + case FDE_CSSPROPERTYVALUE_RepeatY: + case FDE_CSSPROPERTYVALUE_NoRepeat: + if (pRepeat == NULL) { + pRepeat = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Left: + case FDE_CSSPROPERTYVALUE_Right: + if (pPosX == NULL) { + pPosX = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Top: + case FDE_CSSPROPERTYVALUE_Bottom: + if (pPosY == NULL) { + pPosX = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Center: + if (pPosX == NULL) { + pPosX = NewEnumValue(pStaticStore, pValue->eName); + } else if (pPosY == NULL) { + pPosX = NewEnumValue(pStaticStore, pValue->eName); + } + break; + default: + break; + } + break; + } + const FDE_CSSCOLORTABLE* pColorItem = + FDE_GetCSSColorByName(pszValue, iValueLen); + if (pColorItem != NULL) { + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue(pColorItem->dwValue); + } + } + } break; + case FDE_CSSPRIMITIVETYPE_RGB: + if (pColor == NULL) { + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + pColor = + FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); + } + } + break; + default: + break; + } + } + if (pColor == NULL) { + pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); + } + if (pImage == NULL) { + pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); + } + if (pRepeat == NULL) { + pRepeat = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Repeat); + } + if (pAttachment == NULL) { + pAttachment = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Scroll); + } + if (pPosX == NULL) { + pPosX = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); + pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); + } else if (pPosY == NULL) { + pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); + } + CFDE_CSSValueArray position; + position.Add(pPosX); + position.Add(pPosY); + CFDE_CSSValueList* pPosList = + FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, position); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundColor, pColor, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundImage, pImage, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundRepeat, pRepeat, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundPosition, pPosList, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundAttachment, + pAttachment, bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, '/'); + IFDE_CSSPrimitiveValue *pStyle = NULL, *pVariant = NULL, *pWeight = NULL; + IFDE_CSSPrimitiveValue *pFontSize = NULL, *pLineHeight = NULL; + CFDE_CSSValueArray familyList; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_XxSmall: + case FDE_CSSPROPERTYVALUE_XSmall: + case FDE_CSSPROPERTYVALUE_Small: + case FDE_CSSPROPERTYVALUE_Medium: + case FDE_CSSPROPERTYVALUE_Large: + case FDE_CSSPROPERTYVALUE_XLarge: + case FDE_CSSPROPERTYVALUE_XxLarge: + case FDE_CSSPROPERTYVALUE_Smaller: + case FDE_CSSPROPERTYVALUE_Larger: + if (pFontSize == NULL) { + pFontSize = NewEnumValue(pStaticStore, pValue->eName); + } + continue; + case FDE_CSSPROPERTYVALUE_Bold: + case FDE_CSSPROPERTYVALUE_Bolder: + case FDE_CSSPROPERTYVALUE_Lighter: + if (pWeight == NULL) { + pWeight = NewEnumValue(pStaticStore, pValue->eName); + } + continue; + case FDE_CSSPROPERTYVALUE_Italic: + case FDE_CSSPROPERTYVALUE_Oblique: + if (pStyle == NULL) { + pStyle = NewEnumValue(pStaticStore, pValue->eName); + } + continue; + case FDE_CSSPROPERTYVALUE_SmallCaps: + if (pVariant == NULL) { + pVariant = NewEnumValue(pStaticStore, pValue->eName); + } + continue; + case FDE_CSSPROPERTYVALUE_Normal: + if (pStyle == NULL) { + pStyle = NewEnumValue(pStaticStore, pValue->eName); + } else if (pVariant == NULL) { + pVariant = NewEnumValue(pStaticStore, pValue->eName); + } else if (pWeight == NULL) { + pWeight = NewEnumValue(pStaticStore, pValue->eName); + } else if (pFontSize == NULL) { + pFontSize = NewEnumValue(pStaticStore, pValue->eName); + } else if (pLineHeight == NULL) { + pLineHeight = NewEnumValue(pStaticStore, pValue->eName); + } + continue; + default: + break; + } + } + if (pFontSize != NULL) { + familyList.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( + eType, CopyToLocal(pArgs, pszValue, iValueLen))); + } + parser.m_Separator = ','; + } break; + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + break; + } + if (eType == FDE_CSSPRIMITIVETYPE_Number) { + switch ((int32_t)fValue) { + case 100: + case 200: + case 300: + case 400: + case 500: + case 600: + case 700: + case 800: + case 900: + if (pWeight == NULL) { + pWeight = NewNumberValue(pStaticStore, + FDE_CSSPRIMITIVETYPE_Number, fValue); + } + continue; + } + } + if (pFontSize == NULL) { + pFontSize = NewNumberValue(pStaticStore, eType, fValue); + } else if (pLineHeight == NULL) { + pLineHeight = NewNumberValue(pStaticStore, eType, fValue); + } + } break; + default: + break; + } + } + if (pStyle == NULL) { + pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); + } + if (pVariant == NULL) { + pVariant = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); + } + if (pWeight == NULL) { + pWeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); + } + if (pFontSize == NULL) { + pFontSize = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium); + } + if (pLineHeight == NULL) { + pLineHeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); + } + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontStyle, pStyle, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontVariant, pVariant, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontWeight, pWeight, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontSize, pFontSize, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_LineHeight, pLineHeight, + bImportant); + if (familyList.GetSize() > 0) { + CFDE_CSSValueList* pList = FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, familyList); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontFamily, pList, + bImportant); + } + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseColumnRuleProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + IFDE_CSSPrimitiveValue* pColumnRuleWidth = NULL; + IFDE_CSSPrimitiveValue* pColumnRuleStyle = NULL; + IFDE_CSSPrimitiveValue* pColumnRuleColor = NULL; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + switch (pValue->eName) { + case FDE_CSSPROPERTYVALUE_None: + case FDE_CSSPROPERTYVALUE_Hidden: + case FDE_CSSPROPERTYVALUE_Dotted: + case FDE_CSSPROPERTYVALUE_Dashed: + case FDE_CSSPROPERTYVALUE_Solid: + case FDE_CSSPROPERTYVALUE_Double: + case FDE_CSSPROPERTYVALUE_Groove: + case FDE_CSSPROPERTYVALUE_Ridge: + case FDE_CSSPROPERTYVALUE_Inset: + case FDE_CSSPROPERTYVALUE_Outset: + if (pColumnRuleStyle == NULL) { + pColumnRuleStyle = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Transparent: + if (pColumnRuleColor == NULL) { + pColumnRuleColor = NewEnumValue(pStaticStore, pValue->eName); + } + break; + case FDE_CSSPROPERTYVALUE_Thin: + case FDE_CSSPROPERTYVALUE_Medium: + case FDE_CSSPROPERTYVALUE_Thick: + if (pColumnRuleWidth == NULL) { + pColumnRuleWidth = NewEnumValue(pStaticStore, pValue->eName); + } + break; + default: + break; + } + continue; + } + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor) && + pColumnRuleColor == NULL) { + pColumnRuleColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue((FX_ARGB)dwColor); + continue; + } + } break; + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType) && + pColumnRuleWidth == NULL) { + pColumnRuleWidth = NewNumberValue(pStaticStore, eType, fValue); + } + } break; + case FDE_CSSPRIMITIVETYPE_RGB: { + FX_ARGB dwColor; + if (pColumnRuleColor == NULL && + FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + pColumnRuleColor = FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue((FX_ARGB)dwColor); + } + } break; + default: + break; + } + } + if (pColumnRuleColor == NULL && pColumnRuleStyle == NULL && + pColumnRuleWidth == NULL) { + return FALSE; + } + if (pColumnRuleStyle == NULL) { + pColumnRuleStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); + } + if (pColumnRuleWidth == NULL) { + pColumnRuleWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium); + } + if (pColumnRuleColor == NULL) { + pColumnRuleColor = + FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); + } + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleStyle, + pColumnRuleStyle, bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleWidth, + pColumnRuleWidth, bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleColor, + pColumnRuleColor, bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseTextEmphasisProperty( + FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + CFDE_CSSValueArray arrEmphasisStyle; + FDE_CSSPRIMITIVETYPE eType; + IFDE_CSSPrimitiveValue* pEmphasisColor = NULL; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + arrEmphasisStyle.Add(NewEnumValue(pStaticStore, pValue->eName)); + continue; + } + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + pEmphasisColor = + FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); + continue; + } + pszValue = CopyToLocal(pArgs, pszValue, iValueLen); + arrEmphasisStyle.Add( + FXTARGET_NewWith(pStaticStore) + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue)); + } break; + case FDE_CSSPRIMITIVETYPE_RGB: { + FX_ARGB dwColor; + if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { + pEmphasisColor = + FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); + } + } break; + default: + break; + } + } + if (arrEmphasisStyle.GetSize() != 0) { + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisStyle, + FXTARGET_NewWith(pStaticStore) + CFDE_CSSValueList(pStaticStore, arrEmphasisStyle), + bImportant); + } + if (pEmphasisColor != NULL) { + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisColor, + pEmphasisColor, bImportant); + } + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseColumnsProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + IFDE_CSSPrimitiveValue* pColumnWidth = NULL; + IFDE_CSSPrimitiveValue* pColumnCount = NULL; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_String: { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue == NULL && pValue->eName == FDE_CSSPROPERTYVALUE_Auto) { + pColumnWidth = NewEnumValue(pStaticStore, pValue->eName); + } + } break; + case FDE_CSSPRIMITIVETYPE_Number: { + FX_FLOAT fValue; + if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { + switch (eType) { + case FDE_CSSPRIMITIVETYPE_Number: + if (pColumnCount == NULL) { + pColumnCount = NewNumberValue(pStaticStore, eType, fValue); + } + break; + default: + if (pColumnWidth == NULL) { + pColumnWidth = NewNumberValue(pStaticStore, eType, fValue); + } + break; + } + } + } break; + default: + break; + } + } + if (pColumnWidth == NULL && pColumnCount == NULL) { + return FALSE; + } else if (pColumnWidth == NULL) { + pColumnWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto); + } else if (pColumnCount == NULL) { + pColumnCount = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto); + } + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnWidth, pColumnWidth, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnCount, pColumnCount, + bImportant); + return TRUE; +} +FX_BOOL CFDE_CSSDeclaration::ParseOverflowProperty( + const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant) { + IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; + CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); + IFDE_CSSPrimitiveValue* pOverflowX = NULL; + IFDE_CSSPrimitiveValue* pOverflowY = NULL; + FDE_CSSPRIMITIVETYPE eType; + while (parser.NextValue(eType, pszValue, iValueLen)) { + if (eType == FDE_CSSPRIMITIVETYPE_String) { + const FDE_CSSPROPERTYVALUETABLE* pValue = + FDE_GetCSSPropertyValueByName(pszValue, iValueLen); + if (pValue != NULL) { + switch (pValue->eName) { + case FDE_CSSOVERFLOW_Visible: + case FDE_CSSOVERFLOW_Hidden: + case FDE_CSSOVERFLOW_Scroll: + case FDE_CSSOVERFLOW_Auto: + case FDE_CSSOVERFLOW_NoDisplay: + case FDE_CSSOVERFLOW_NoContent: + if (pOverflowX != NULL && pOverflowY != NULL) { + return FALSE; + } else if (pOverflowX == NULL) { + pOverflowX = NewEnumValue(pStaticStore, pValue->eName); + } else if (pOverflowY == NULL) { + pOverflowY = NewEnumValue(pStaticStore, pValue->eName); + } + break; + default: + break; + } + } + } + } + if (pOverflowX == NULL && pOverflowY == NULL) { + return FALSE; + } else if (pOverflowY == NULL) { + pOverflowY = NewEnumValue(pStaticStore, pOverflowX->GetEnum()); + } + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowX, pOverflowX, + bImportant); + AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowY, pOverflowY, + bImportant); + return TRUE; +} diff --git a/xfa/fde/css/fde_cssdeclaration.h b/xfa/fde/css/fde_cssdeclaration.h new file mode 100644 index 0000000000..2a3031ea69 --- /dev/null +++ b/xfa/fde/css/fde_cssdeclaration.h @@ -0,0 +1,158 @@ +// 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_CSS_FDE_CSSDECLARATION_H_ +#define XFA_FDE_CSS_FDE_CSSDECLARATION_H_ + +#include "xfa/fde/css/fde_cssdatatable.h" + +class FDE_CSSPropertyHolder : public CFX_Target { + public: + int16_t eProperty; + int16_t bImportant; + IFDE_CSSValue* pValue; + FDE_CSSPropertyHolder* pNext; +}; + +class FDE_CSSCustomProperty : public CFX_Target { + public: + const FX_WCHAR* pwsName; + const FX_WCHAR* pwsValue; + FDE_CSSCustomProperty* pNext; +}; + +struct FDE_CSSPROPERTYARGS { + IFX_MEMAllocator* pStaticStore; + CFX_MapPtrToPtr* pStringCache; + FDE_LPCCSSPROPERTYTABLE pProperty; +}; + +class CFDE_CSSDeclaration : public IFDE_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; + FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszName, + int32_t iNameLen, + const FX_WCHAR* pszValue, + int32_t iValueLen); + + protected: + FX_BOOL ParseTextEmphasisProperty(FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseColumnsProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseColumnRuleProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseOverflowProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseBackgroundProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseListStyleProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseBorderPropoerty(IFX_MEMAllocator* pStaticStore, + const FX_WCHAR* pszValue, + int32_t iValueLen, + IFDE_CSSValue*& pColor, + IFDE_CSSValue*& pStyle, + IFDE_CSSValue*& pWidth) const; + void AddBorderProperty(IFX_MEMAllocator* pStaticStore, + IFDE_CSSValue* pColor, + IFDE_CSSValue* pStyle, + IFDE_CSSValue* pWidth, + FX_BOOL bImportant, + FDE_CSSPROPERTY eColor, + FDE_CSSPROPERTY eStyle, + FDE_CSSPROPERTY eWidth); + FX_BOOL ParseContentProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseCounterProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL ParseValueListProperty(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen, + FX_BOOL bImportant); + FX_BOOL Add4ValuesProperty(IFX_MEMAllocator* pStaticStore, + const CFDE_CSSValueArray& list, + FX_BOOL bImportant, + FDE_CSSPROPERTY eLeft, + FDE_CSSPROPERTY eTop, + FDE_CSSPROPERTY eRight, + FDE_CSSPROPERTY eBottom); + IFDE_CSSValue* ParseNumber(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + IFDE_CSSValue* ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + IFDE_CSSValue* ParseColor(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + IFDE_CSSValue* ParseURI(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + IFDE_CSSValue* ParseString(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + IFDE_CSSValue* ParseFunction(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs, + const FX_WCHAR* pszValue, + int32_t iValueLen); + void AddPropertyHolder(IFX_MEMAllocator* pStaticStore, + FDE_CSSPROPERTY eProperty, + IFDE_CSSValue* pValue, + FX_BOOL bImportant); + IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MEMAllocator* pStaticStore, + FDE_CSSPRIMITIVETYPE eUnit, + FX_FLOAT fValue) const; + IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore, + FDE_CSSPROPERTYVALUE eValue) const; + FDE_CSSPropertyHolder* m_pFirstProperty; + FDE_CSSPropertyHolder* m_pLastProperty; + FDE_CSSCustomProperty* m_pFirstCustom; + FDE_CSSCustomProperty* m_pLastCustom; +}; + +#endif // XFA_FDE_CSS_FDE_CSSDECLARATION_H_ diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp new file mode 100644 index 0000000000..ca3a01c4c7 --- /dev/null +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -0,0 +1,1794 @@ +// 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/css/fde_cssstyleselector.h" + +#include <algorithm> + +#include "xfa/fde/css/fde_csscache.h" +#include "xfa/fde/css/fde_cssdeclaration.h" + +int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) { + int32_t iCount = m_arrCounterData.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) == + 0) { + return i; + } + } + return -1; +} +void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { + if (pList == NULL) { + return; + } + int32_t iCount = pList->CountValues(); + FX_FLOAT fDefValue = 1.0; + FX_BOOL bDefIncrement = TRUE; + if (pList == m_pCounterReset) { + fDefValue = 0.0; + bDefIncrement = FALSE; + } + for (int32_t i = 0; i < iCount; i++) { + IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); + int32_t iLen; + const FX_WCHAR* pszIdentifier = + ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(0)))->GetString(iLen); + FX_FLOAT fValue = fDefValue; + if (pCounter->CountValues() > 1) { + fValue = ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(1)))->GetFloat(); + } + int32_t iIndex = FindIndex(pszIdentifier); + if (iIndex == -1) { + FDE_CSSCOUNTERDATA data; + data.m_pszIdent = pszIdentifier; + if (bDefIncrement) { + data.m_bIncrement = TRUE; + data.m_iIncVal = (int32_t)fValue; + } else { + data.m_iResetVal = (int32_t)fValue; + data.m_bReset = TRUE; + } + m_arrCounterData.Add(data); + } else { + FDE_CSSCOUNTERDATA& data = m_arrCounterData.ElementAt(iIndex); + if (bDefIncrement) { + data.m_bIncrement = TRUE; + data.m_iIncVal += (int32_t)fValue; + } else { + data.m_bReset = TRUE; + data.m_iResetVal = (int32_t)fValue; + } + } + } +} +void CFDE_CSSCounterStyle::UpdateIndex() { + if (!m_bIndexDirty) { + return; + } + m_arrCounterData.RemoveAll(); + DoUpdateIndex(m_pCounterInc); + 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, + FX_DWORD dwPos) + : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) { + static const FX_DWORD s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, + 0x00100000, 0x01000000}; + for (; pSel != NULL; pSel = pSel->GetNextSelector()) { + FDE_CSSSELECTORTYPE eType = pSel->GetType(); + if (eType > FDE_CSSSELECTORTYPE_Descendant || + pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { + dwPriority += s_Specific[eType]; + } + } +} +void CFDE_CSSRuleCollection::Clear() { + m_IDRules.RemoveAll(); + m_TagRules.RemoveAll(); + m_ClassRules.RemoveAll(); + m_pUniversalRules = NULL; + m_pStaticStore = NULL; + m_iSelectors = 0; +} +void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, + FX_DWORD dwMediaList, + IFX_FontMgr* pFontMgr) { + int32_t iSheets = sheets.GetSize(); + for (int32_t i = 0; i < iSheets; ++i) { + IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); + if (FX_DWORD dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { + int32_t iRules = pSheet->CountRules(); + for (int32_t j = 0; j < iRules; j++) { + AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr); + } + } + } +} +void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, + IFDE_CSSRule* pRule, + FX_DWORD dwMediaList, + IFX_FontMgr* pFontMgr) { + switch (pRule->GetType()) { + case FDE_CSSRULETYPE_Style: { + IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule; + IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); + int32_t iSelectors = pStyleRule->CountSelectorLists(); + for (int32_t i = 0; i < iSelectors; ++i) { + IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); + if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { + FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); + AddRuleTo(m_pPersudoRules, pData); + continue; + } + if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) { + AddRuleTo(m_TagRules, pSelector->GetNameHash(), pSelector, + pDeclaration); + continue; + } + IFDE_CSSSelector* pNext = pSelector->GetNextSelector(); + if (pNext == NULL) { + FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); + AddRuleTo(m_pUniversalRules, pData); + continue; + } + switch (pNext->GetType()) { + case FDE_CSSSELECTORTYPE_ID: + AddRuleTo(m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration); + break; + case FDE_CSSSELECTORTYPE_Class: + AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector, + pDeclaration); + break; + case FDE_CSSSELECTORTYPE_Descendant: + case FDE_CSSSELECTORTYPE_Element: + AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration)); + break; + default: + FXSYS_assert(FALSE); + break; + } + } + } break; + case FDE_CSSRULETYPE_Media: { + IFDE_CSSMediaRule* pMediaRule = (IFDE_CSSMediaRule*)pRule; + if (pMediaRule->GetMediaList() & dwMediaList) { + int32_t iRules = pMediaRule->CountRules(); + for (int32_t i = 0; i < iRules; ++i) { + AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList, + pFontMgr); + } + } + } break; + default: + break; + } +} +void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, + FX_DWORD dwKey, + IFDE_CSSSelector* pSel, + IFDE_CSSDeclaration* pDecl) { + void* pKey = (void*)(uintptr_t)dwKey; + FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); + FDE_CSSRuleData* pList = NULL; + if (!map.Lookup(pKey, (void*&)pList)) { + map.SetAt(pKey, pData); + } else if (AddRuleTo(pList, pData)) { + map.SetAt(pKey, pList); + } +} + +FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, + FDE_CSSRuleData* pData) { + if (pList) { + pData->pNext = pList->pNext; + pList->pNext = pData; + return FALSE; + } + + pList = pData; + return TRUE; +} + +FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( + IFDE_CSSSelector* pSel, + IFDE_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), + m_pRuleDataStore(NULL), + m_pInlineStyleStore(NULL), + m_pFixedStyleStore(NULL), + m_pAccelerator(NULL) { + m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; + m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; + 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; + } +} +void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { + m_pFontMgr = pFontMgr; +} +void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { + FXSYS_assert(fFontSize > 0); + m_fDefFontSize = fFontSize; +} +IFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { + if (m_pAccelerator == NULL) { + 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); + } + CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) + CFDE_CSSComputedStyle(m_pFixedStyleStore); + if (pParentStyle) { + pStyle->m_InheritedData = + ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; + } else { + pStyle->m_InheritedData.Reset(); + } + pStyle->m_NonInheritedData.Reset(); + return pStyle; +} +FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, + IFDE_CSSStyleSheet* pSheet) { + FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); + CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; + dest.RemoveAt(0, dest.GetSize()); + if (pSheet != NULL) { + dest.Add(pSheet); + } + return TRUE; +} +FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets( + FDE_CSSSTYLESHEETGROUP eType, + const CFDE_CSSStyleSheetArray* pArray) { + FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); + CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; + if (pArray == NULL) { + dest.RemoveAt(0, dest.GetSize()); + } else { + dest.Copy(*pArray); + } + return TRUE; +} +void CFDE_CSSStyleSelector::SetStylePriority( + FDE_CSSSTYLESHEETGROUP eType, + FDE_CSSSTYLESHEETPRIORITY ePriority) { + m_ePriorities[ePriority] = eType; +} +void CFDE_CSSStyleSelector::UpdateStyleIndex(FX_DWORD dwMediaList) { + Reset(); + m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); + FXSYS_assert(m_pRuleDataStore != NULL); + for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { + CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; + rules.m_pStaticStore = m_pRuleDataStore; + rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); + } +} +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; + } +} +int32_t CFDE_CSSStyleSelector::MatchDeclarations( + IFDE_CSSTagProvider* pTag, + CFDE_CSSDeclarationArray& matchedDecls, + FDE_CSSPERSUDO ePersudoType) { + FXSYS_assert(m_pAccelerator != NULL && pTag != NULL); + FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); + FXSYS_assert(pCache != NULL && 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) { + continue; + } + if (ePersudoType == FDE_CSSPERSUDO_NONE) { + MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType); + if (pCache->HashTag()) { + MatchRules(pCache, rules.GetTagRuleData(pCache->HashTag()), + ePersudoType); + } + int32_t iCount = pCache->CountHashClass(); + for (int32_t i = 0; i < iCount; i++) { + pCache->SetClassIndex(i); + MatchRules(pCache, rules.GetClassRuleData(pCache->HashClass()), + ePersudoType); + } + } else { + MatchRules(pCache, rules.GetPersudoRuleData(), ePersudoType); + } + + std::sort(m_MatchedRules.begin(), m_MatchedRules.end(), + [](const FDE_CSSRuleData* p1, const FDE_CSSRuleData* p2) { + return p1->dwPriority < p2->dwPriority; + }); + for (const auto& rule : m_MatchedRules) + matchedDecls.Add(rule->pDeclaration); + m_MatchedRules.clear(); + } + return matchedDecls.GetSize(); +} + +void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache, + FDE_CSSRuleData* pList, + FDE_CSSPERSUDO ePersudoType) { + while (pList) { + if (MatchSelector(pCache, pList->pSelector, ePersudoType)) + m_MatchedRules.push_back(pList); + pList = pList->pNext; + } +} + +FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, + IFDE_CSSSelector* pSel, + FDE_CSSPERSUDO ePersudoType) { + FX_DWORD dwHash; + while (pSel != NULL && pCache != NULL) { + switch (pSel->GetType()) { + case FDE_CSSSELECTORTYPE_Descendant: + dwHash = pSel->GetNameHash(); + while ((pCache = pCache->GetParent()) != NULL) { + if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { + continue; + } + if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) { + return TRUE; + } + } + return FALSE; + case FDE_CSSSELECTORTYPE_ID: + dwHash = pCache->HashID(); + if (dwHash != pSel->GetNameHash()) { + return FALSE; + } + break; + case FDE_CSSSELECTORTYPE_Class: + dwHash = pCache->HashClass(); + if (dwHash != pSel->GetNameHash()) { + return FALSE; + } + break; + case FDE_CSSSELECTORTYPE_Element: + dwHash = pSel->GetNameHash(); + if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { + return FALSE; + } + break; + case FDE_CSSSELECTORTYPE_Persudo: + dwHash = FDE_GetCSSPersudoByEnum(ePersudoType)->dwHash; + if (dwHash != pSel->GetNameHash()) { + return FALSE; + } + break; + default: + FXSYS_assert(FALSE); + break; + } + pSel = pSel->GetNextSelector(); + } + return pSel == NULL && pCache != NULL; +} + +void CFDE_CSSStyleSelector::ComputeStyle( + IFDE_CSSTagProvider* pTag, + const IFDE_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); + } + CFDE_CSSDeclaration* pDecl = NULL; + CFX_WideStringC wsAttri, wsValue; + FX_DWORD dwAttriHash; + do { + pTag->GetNextAttribute(pos, wsAttri, wsValue); + dwAttriHash = + FX_HashCode_String_GetW(wsAttri.GetPtr(), wsAttri.GetLength(), TRUE); + static const FX_DWORD s_dwStyleHash = + FX_HashCode_String_GetW(L"style", 5, TRUE); + static const FX_DWORD s_dwAlignHash = + FX_HashCode_String_GetW(L"align", 5, TRUE); + if (dwAttriHash == s_dwStyleHash) { + if (pDecl == NULL) { + pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; + } + AppendInlineStyle(pDecl, wsValue.GetPtr(), wsValue.GetLength()); + } else if (dwAttriHash == s_dwAlignHash) { + if (pDecl == NULL) { + pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; + } + FDE_CSSPROPERTYARGS args; + args.pStringCache = NULL; + args.pStaticStore = m_pInlineStyleStore; + args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); + pDecl->AddProperty(&args, wsValue.GetPtr(), wsValue.GetLength()); + } + } while (pos != NULL); + if (pDecl != NULL) { + CFDE_CSSDeclarationArray decls; + decls.SetSize(iDeclCount + 1); + IFDE_CSSDeclaration** ppInline = decls.GetData(); + FXSYS_memcpy(ppInline, ppDeclArray, + iDeclCount * sizeof(IFDE_CSSDeclaration*)); + ppInline[iDeclCount++] = pDecl; + ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount, + pDestStyle); + ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline, + iDeclCount, pDestStyle); + return; + } + } + if (iDeclCount > 0) { + FXSYS_assert(ppDeclArray != NULL); + ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle); + ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle); + } +} +void CFDE_CSSStyleSelector::ApplyDeclarations( + FX_BOOL bPriority, + const IFDE_CSSDeclaration** ppDeclArray, + int32_t iDeclCount, + IFDE_CSSComputedStyle* pDestStyle) { + CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; + IFDE_CSSValue* pVal; + FX_BOOL bImportant; + int32_t i; + if (bPriority) { + IFDE_CSSValue *pLastest = NULL, *pImportant = NULL; + for (i = 0; i < iDeclCount; ++i) { + pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant); + if (pVal == NULL) { + continue; + } else if (bImportant) { + pImportant = pVal; + } else { + pLastest = pVal; + } + } + if (pImportant) { + ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle); + } else if (pLastest) { + ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle); + } + } else { + CFDE_CSSDeclarationArray importants; + const IFDE_CSSDeclaration* pDecl = NULL; + FDE_CSSPROPERTY eProp; + FX_POSITION pos; + for (i = 0; i < iDeclCount; ++i) { + pDecl = ppDeclArray[i]; + pos = pDecl->GetStartPosition(); + while (pos != NULL) { + pDecl->GetNextProperty(pos, eProp, pVal, bImportant); + if (eProp == FDE_CSSPROPERTY_FontSize) { + continue; + } else if (!bImportant) { + ApplyProperty(eProp, pVal, pComputedStyle); + } else if (importants.GetSize() == 0 || + importants[importants.GetUpperBound()] != pDecl) { + importants.Add((IFDE_CSSDeclaration*)pDecl); + } + } + } + iDeclCount = importants.GetSize(); + for (i = 0; i < iDeclCount; ++i) { + pDecl = importants[i]; + pos = pDecl->GetStartPosition(); + while (pos != NULL) { + pDecl->GetNextProperty(pos, eProp, pVal, bImportant); + if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) { + ApplyProperty(eProp, pVal, pComputedStyle); + } + } + } + CFX_WideString wsName, wsValue; + pos = pDecl->GetStartCustom(); + while (pos) { + pDecl->GetNextCustom(pos, wsName, wsValue); + pComputedStyle->AddCustomStyle(wsName, wsValue); + } + } +} +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) { + 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); + } + } + } else { + break; + } + } + } + pSyntax->Release(); +} +#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData) +#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData) +#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize) +void CFDE_CSSStyleSelector::ApplyProperty( + FDE_CSSPROPERTY eProperty, + IFDE_CSSValue* pValue, + CFDE_CSSComputedStyle* pComputedStyle) { + if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { + IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; + FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); + switch (eProperty) { + case FDE_CSSPROPERTY_Display: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eDisplay = ToDisplay(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_FontSize: { + FX_FLOAT& fFontSize = FDE_CSSFONTSIZE; + if (eType >= FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + fFontSize = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); + } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + fFontSize = ToFontSize(pPrimitive->GetEnum(), fFontSize); + } + } break; + case FDE_CSSPROPERTY_LineHeight: + if (eType == FDE_CSSPRIMITIVETYPE_Number) { + FDE_CSSINHERITS.m_fLineHeight = + pPrimitive->GetFloat() * FDE_CSSFONTSIZE; + } else if (eType > FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + FDE_CSSINHERITS.m_fLineHeight = + ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); + } + break; + case FDE_CSSPROPERTY_TextAlign: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eTextAligh = ToTextAlign(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_TextIndent: + SetLengthWithPercent(FDE_CSSINHERITS.m_TextIndent, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_FontWeight: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_wFontWeight = ToFontWeight(pPrimitive->GetEnum()); + } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { + int32_t iValue = (int32_t)pPrimitive->GetFloat() / 100; + if (iValue >= 1 && iValue <= 9) { + FDE_CSSINHERITS.m_wFontWeight = iValue * 100; + } + } + break; + case FDE_CSSPROPERTY_FontStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eFontStyle = ToFontStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_Color: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSINHERITS.m_dwFontColor = pPrimitive->GetRGBColor(); + } + break; + case FDE_CSSPROPERTY_MarginLeft: + FDE_CSSNONINHERITS.m_bHasMargin |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.left, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MarginTop: + FDE_CSSNONINHERITS.m_bHasMargin |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.top, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MarginRight: + FDE_CSSNONINHERITS.m_bHasMargin |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.right, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MarginBottom: + FDE_CSSNONINHERITS.m_bHasMargin |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.bottom, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_PaddingLeft: + FDE_CSSNONINHERITS.m_bHasPadding |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.left, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_PaddingTop: + FDE_CSSNONINHERITS.m_bHasPadding |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.top, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_PaddingRight: + FDE_CSSNONINHERITS.m_bHasPadding |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.right, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_PaddingBottom: + FDE_CSSNONINHERITS.m_bHasPadding |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.bottom, + eType, pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BorderLeftWidth: + FDE_CSSNONINHERITS.m_bHasBorder |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.left, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BorderTopWidth: + FDE_CSSNONINHERITS.m_bHasBorder |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.top, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BorderRightWidth: + FDE_CSSNONINHERITS.m_bHasBorder |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.right, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BorderBottomWidth: + FDE_CSSNONINHERITS.m_bHasBorder |= + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.bottom, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BorderLeftStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBDRLeftStyle = + ToBorderStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BorderTopStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBDRTopStyle = + ToBorderStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BorderRightStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBDRRightStyle = + ToBorderStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BorderBottomStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBDRBottomStyle = + ToBorderStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BorderLeftColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwBDRLeftColor = pPrimitive->GetRGBColor(); + } + break; + case FDE_CSSPROPERTY_BorderTopColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwBDRTopColor = pPrimitive->GetRGBColor(); + } + break; + case FDE_CSSPROPERTY_BorderRightColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwBDRRightColor = pPrimitive->GetRGBColor(); + } + break; + case FDE_CSSPROPERTY_BorderBottomColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwBDRBottomColor = pPrimitive->GetRGBColor(); + } + break; + case FDE_CSSPROPERTY_ListStyleType: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eListStyleType = + ToListStyleType(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_ListStylePosition: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eListStylePosition = + ToListStylePosition(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BackgroundColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwBKGColor = pPrimitive->GetRGBColor(); + } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_dwBKGColor = 0; + } + break; + case FDE_CSSPROPERTY_Visibility: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eVisibility = ToVisibility(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_Width: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cx, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_Height: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cy, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MinWidth: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cx, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MinHeight: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cy, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MaxWidth: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cx, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_MaxHeight: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cy, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_VerticalAlign: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eVerticalAlign = + ToVerticalAlign(pPrimitive->GetEnum()); + } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + FDE_CSSNONINHERITS.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number; + FDE_CSSNONINHERITS.m_fVerticalAlign = + ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); + } + break; + case FDE_CSSPROPERTY_WhiteSpace: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eWhiteSpace = ToWhiteSpace(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_TextTransform: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eTextTransform = + ToTextTransform(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_FontVariant: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eFontVariant = ToFontVariant(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_LetterSpacing: + if (eType == FDE_CSSPRIMITIVETYPE_Percent) { + break; + } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + SetLengthWithPercent(FDE_CSSINHERITS.m_LetterSpacing, eType, + pPrimitive, FDE_CSSFONTSIZE); + } + break; + case FDE_CSSPROPERTY_WordSpacing: + if (eType == FDE_CSSPRIMITIVETYPE_Percent) { + break; + } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + SetLengthWithPercent(FDE_CSSINHERITS.m_WordSpacing, eType, pPrimitive, + FDE_CSSFONTSIZE); + } + break; + case FDE_CSSPROPERTY_Float: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eFloat = ToFloat(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_Clear: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eClear = ToClear(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_WritingMode: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eWritingMode = ToWritingMode(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_WordBreak: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eWordBreak = ToWordBreak(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_Widows: + if (eType == FDE_CSSPRIMITIVETYPE_Number) { + FDE_CSSINHERITS.m_iWidows = (int32_t)pPrimitive->GetFloat(); + } + break; + case FDE_CSSPROPERTY_Orphans: + if (eType == FDE_CSSPRIMITIVETYPE_Number) { + FDE_CSSINHERITS.m_iOrphans = (int32_t)pPrimitive->GetFloat(); + } + break; + case FDE_CSSPROPERTY_TextEmphasisColor: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + switch (pPrimitive->GetEnum()) { + case FDE_CSSPROPERTYVALUE_Transparent: + FDE_CSSINHERITS.m_dwTextEmphasisColor = 0; + FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; + break; + case FDE_CSSPROPERTYVALUE_Currentcolor: + FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = TRUE; + break; + default: + break; + } + } else if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSINHERITS.m_dwTextEmphasisColor = pPrimitive->GetRGBColor(); + FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; + } + break; + case FDE_CSSPROPERTY_PageBreakBefore: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_ePageBreakBefore = + ToPageBreak(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_PageBreakAfter: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_ePageBreakAfter = + ToPageBreak(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_PageBreakInside: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_ePageBreakInside = + ToPageBreak(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_OverflowX: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eOverflowX = ToOverflow(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_OverflowY: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eOverflowY = ToOverflow(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_LineBreak: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eLineBreak = ToLineBreak(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_ColumnCount: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); + } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { + FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Point, + pPrimitive->GetFloat()); + } + break; + case FDE_CSSPROPERTY_ColumnGap: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnGap, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_ColumnRuleColor: + if (eType == FDE_CSSPRIMITIVETYPE_RGB) { + FDE_CSSNONINHERITS.m_dwColumnRuleColor = pPrimitive->GetRGBColor(); + FDE_CSSNONINHERITS.m_bColumnRuleColorSame = FALSE; + } + break; + case FDE_CSSPROPERTY_ColumnRuleStyle: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eColumnRuleStyle = + ToBorderStyle(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_ColumnRuleWidth: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_ColumnWidth: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType, + pPrimitive, FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_BackgroundImage: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_pszBKGImage = NULL; + } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { + int32_t iLength; + FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength); + } + break; + case FDE_CSSPROPERTY_Position: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_Top: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_Bottom: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_Left: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_Right: + SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive, + FDE_CSSFONTSIZE); + break; + case FDE_CSSPROPERTY_ListStyleImage: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_pszListStyleImage = NULL; + } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { + int32_t iLength; + FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength); + } + break; + case FDE_CSSPROPERTY_CaptionSide: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BackgroundRepeat: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBKGRepeat = ToBKGRepeat(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_BackgroundAttachment: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSNONINHERITS.m_eBKGAttachment = + ToBKGAttachment(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_RubyAlign: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eRubyAlign = ToRubyAlign(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_RubyOverhang: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eRubyOverhang = + ToRubyOverhang(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_RubyPosition: + if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + FDE_CSSINHERITS.m_eRubyPosition = + ToRubyPosition(pPrimitive->GetEnum()); + } + break; + case FDE_CSSPROPERTY_RubySpan: + FDE_CSSNONINHERITS.m_pRubySpan = pPrimitive; + break; + default: + break; + } + } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) { + IFDE_CSSValueList* pList = (IFDE_CSSValueList*)pValue; + int32_t iCount = pList->CountValues(); + if (iCount > 0) { + switch (eProperty) { + case FDE_CSSPROPERTY_FontFamily: + FDE_CSSINHERITS.m_pFontFamily = pList; + break; + case FDE_CSSPROPERTY_TextDecoration: + FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList); + break; + case FDE_CSSPROPERTY_CounterIncrement: { + if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { + FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; + } + FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList); + } break; + case FDE_CSSPROPERTY_CounterReset: { + if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { + FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; + } + FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList); + } break; + case FDE_CSSPROPERTY_Content: + FDE_CSSNONINHERITS.m_pContentList = pList; + break; + case FDE_CSSPROPERTY_Quotes: + FDE_CSSINHERITS.m_pQuotes = pList; + break; + case FDE_CSSPROPERTY_TextCombine: { + for (int32_t i = 0; i < pList->CountValues(); i++) { + IFDE_CSSPrimitiveValue* pVal = + (IFDE_CSSPrimitiveValue*)pList->GetValue(i); + switch (pVal->GetPrimitiveType()) { + case FDE_CSSPRIMITIVETYPE_Enum: { + switch (pVal->GetEnum()) { + case FDE_CSSPROPERTYVALUE_None: { + FDE_CSSNONINHERITS.m_eTextCombine = FDE_CSSTEXTCOMBINE_None; + FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; + } break; + case FDE_CSSPROPERTYVALUE_Horizontal: { + FDE_CSSNONINHERITS.m_eTextCombine = + FDE_CSSTEXTCOMBINE_Horizontal; + FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; + } break; + default: + break; + } + } break; + case FDE_CSSPRIMITIVETYPE_Number: + FDE_CSSNONINHERITS.m_fTextCombineNumber = pVal->GetFloat(); + break; + default: + break; + } + } + } break; + case FDE_CSSPROPERTY_TextEmphasisStyle: { + FDE_CSSTEXTEMPHASISFILL eFill; + FDE_CSSTEXTEMPHASISMARK eMark; + for (int32_t i = 0; i < pList->CountValues(); i++) { + IFDE_CSSPrimitiveValue* pVal = + (IFDE_CSSPrimitiveValue*)pList->GetValue(i); + switch (pVal->GetPrimitiveType()) { + case FDE_CSSPRIMITIVETYPE_Enum: { + if (ToTextEmphasisFill(pVal->GetEnum(), eFill)) { + FDE_CSSINHERITS.m_eTextEmphasisFill = eFill; + continue; + } else if (ToTextEmphasisMark(pVal->GetEnum(), eMark)) { + FDE_CSSINHERITS.m_eTextEmphasisMark = eMark; + } + } break; + case FDE_CSSPRIMITIVETYPE_String: { + FDE_CSSINHERITS.m_eTextEmphasisMark = + FDE_CSSTEXTEMPHASISMARK_Custom; + int32_t iLen; + FDE_CSSINHERITS.m_pszTextEmphasisCustomMark = + pVal->GetString(iLen); + } break; + default: + break; + } + } + } break; + default: + break; + } + } + } else { + FXSYS_assert(FALSE); + } +} +FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, + FX_FLOAT fValue, + FX_FLOAT fPercentBase) { + switch (eUnit) { + case FDE_CSSPRIMITIVETYPE_PX: + case FDE_CSSPRIMITIVETYPE_Number: + return fValue * 72 / 96; + case FDE_CSSPRIMITIVETYPE_PT: + return fValue; + case FDE_CSSPRIMITIVETYPE_EMS: + case FDE_CSSPRIMITIVETYPE_EXS: + return fValue * fPercentBase; + case FDE_CSSPRIMITIVETYPE_Percent: + return fValue * fPercentBase / 100.0f; + case FDE_CSSPRIMITIVETYPE_CM: + return fValue * 28.3464f; + case FDE_CSSPRIMITIVETYPE_MM: + return fValue * 2.8346f; + case FDE_CSSPRIMITIVETYPE_IN: + return fValue * 72.0f; + case FDE_CSSPRIMITIVETYPE_PC: + return fValue / 12.0f; + default: + return fValue; + } +} +FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + default: + return FDE_CSSRUBYSPAN_None; + } +} +FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Before: + return FDE_CSSRUBYPOSITION_Before; + case FDE_CSSPROPERTYVALUE_After: + return FDE_CSSRUBYPOSITION_After; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSRUBYPOSITION_Right; + case FDE_CSSPROPERTYVALUE_Inline: + return FDE_CSSRUBYPOSITION_Inline; + default: + return FDE_CSSRUBYPOSITION_Before; + } +} +FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSRUBYOVERHANG_Auto; + case FDE_CSSPROPERTYVALUE_Start: + return FDE_CSSRUBYOVERHANG_Start; + case FDE_CSSPROPERTYVALUE_End: + return FDE_CSSRUBYOVERHANG_End; + case FDE_CSSPROPERTYVALUE_None: + default: + return FDE_CSSRUBYOVERHANG_None; + } +} +FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSRUBYALIGN_Auto; + case FDE_CSSPROPERTYVALUE_Start: + return FDE_CSSRUBYALIGN_Start; + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSRUBYALIGN_End; + case FDE_CSSPROPERTYVALUE_Center: + return FDE_CSSRUBYALIGN_Center; + case FDE_CSSPROPERTYVALUE_End: + return FDE_CSSRUBYALIGN_End; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSRUBYALIGN_Right; + case FDE_CSSPROPERTYVALUE_DistributeLetter: + return FDE_CSSRUBYALIGN_DistributeLetter; + case FDE_CSSPROPERTYVALUE_DistributeSpace: + return FDE_CSSRUBYALIGN_DistributeSpace; + case FDE_CSSPROPERTYVALUE_LineEdge: + return FDE_CSSRUBYALIGN_LineEdge; + default: + return FDE_CSSRUBYALIGN_Auto; + } +} +FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark( + FDE_CSSPROPERTYVALUE eValue, + FDE_CSSTEXTEMPHASISMARK& eMark) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + eMark = FDE_CSSTEXTEMPHASISMARK_None; + return TRUE; + case FDE_CSSPROPERTYVALUE_Dot: + eMark = FDE_CSSTEXTEMPHASISMARK_Dot; + return TRUE; + case FDE_CSSPROPERTYVALUE_Circle: + eMark = FDE_CSSTEXTEMPHASISMARK_Circle; + return TRUE; + case FDE_CSSPROPERTYVALUE_DoubleCircle: + eMark = FDE_CSSTEXTEMPHASISMARK_DoubleCircle; + return TRUE; + case FDE_CSSPROPERTYVALUE_Triangle: + eMark = FDE_CSSTEXTEMPHASISMARK_Triangle; + return TRUE; + case FDE_CSSPROPERTYVALUE_Sesame: + eMark = FDE_CSSTEXTEMPHASISMARK_Sesame; + return TRUE; + default: + return FALSE; + } +} +FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill( + FDE_CSSPROPERTYVALUE eValue, + FDE_CSSTEXTEMPHASISFILL& eFill) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Filled: + eFill = FDE_CSSTEXTEMPHASISFILL_Filled; + return TRUE; + case FDE_CSSPROPERTYVALUE_Open: + eFill = FDE_CSSTEXTEMPHASISFILL_Open; + return TRUE; + default: + return FALSE; + } +} +FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Fixed: + return FDE_CSSBKGATTACHMENT_Fixed; + case FDE_CSSPROPERTYVALUE_Scroll: + return FDE_CSSBKGATTACHMENT_Scroll; + default: + return FDE_CSSBKGATTACHMENT_Fixed; + } +} +FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Top: + return FDE_CSSCAPTIONSIDE_Top; + case FDE_CSSPROPERTYVALUE_Bottom: + return FDE_CSSCAPTIONSIDE_Bottom; + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSCAPTIONSIDE_Left; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSCAPTIONSIDE_Right; + case FDE_CSSPROPERTYVALUE_Before: + return FDE_CSSCAPTIONSIDE_Before; + case FDE_CSSPROPERTYVALUE_After: + return FDE_CSSCAPTIONSIDE_After; + default: + return FDE_CSSCAPTIONSIDE_Top; + } +} +FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Static: + return FDE_CSSPOSITION_Static; + case FDE_CSSPROPERTYVALUE_Relative: + return FDE_CSSPOSITION_Relative; + case FDE_CSSPROPERTYVALUE_Fixed: + return FDE_CSSPOSITION_Fixed; + case FDE_CSSPROPERTYVALUE_Absolute: + return FDE_CSSPOSITION_Absolute; + default: + return FDE_CSSPOSITION_Static; + } +} +FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSCURSOR_Auto; + case FDE_CSSPROPERTYVALUE_Crosshair: + return FDE_CSSCURSOR_Crosshair; + case FDE_CSSPROPERTYVALUE_Default: + return FDE_CSSCURSOR_Default; + case FDE_CSSPROPERTYVALUE_Pointer: + return FDE_CSSCURSOR_Pointer; + case FDE_CSSPROPERTYVALUE_Move: + return FDE_CSSCURSOR_Move; + case FDE_CSSPROPERTYVALUE_EResize: + return FDE_CSSCURSOR_EResize; + case FDE_CSSPROPERTYVALUE_NeResize: + return FDE_CSSCURSOR_NeResize; + case FDE_CSSPROPERTYVALUE_NwResize: + return FDE_CSSCURSOR_NwResize; + case FDE_CSSPROPERTYVALUE_NResize: + return FDE_CSSCURSOR_NResize; + case FDE_CSSPROPERTYVALUE_SeResize: + return FDE_CSSCURSOR_SeResize; + case FDE_CSSPROPERTYVALUE_SwResize: + return FDE_CSSCURSOR_SwResize; + default: + return FDE_CSSCURSOR_Auto; + } +} +FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Repeat: + return FDE_CSSBKGREPEAT_Repeat; + case FDE_CSSPROPERTYVALUE_RepeatX: + return FDE_CSSBKGREPEAT_RepeatX; + case FDE_CSSPROPERTYVALUE_RepeatY: + return FDE_CSSBKGREPEAT_RepeatY; + case FDE_CSSPROPERTYVALUE_NoRepeat: + return FDE_CSSBKGREPEAT_NoRepeat; + default: + return FDE_CSSBKGREPEAT_Repeat; + } +} +FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Horizontal: + return FDE_CSSTEXTCOMBINE_Horizontal; + case FDE_CSSPROPERTYVALUE_None: + default: + return FDE_CSSTEXTCOMBINE_None; + } +} +FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSLINEBREAK_Auto; + case FDE_CSSPROPERTYVALUE_Loose: + return FDE_CSSLINEBREAK_Loose; + case FDE_CSSPROPERTYVALUE_Normal: + return FDE_CSSLINEBREAK_Normal; + case FDE_CSSPROPERTYVALUE_Strict: + return FDE_CSSLINEBREAK_Strict; + default: + return FDE_CSSLINEBREAK_Auto; + } +} +FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Visible: + return FDE_CSSOVERFLOW_Visible; + case FDE_CSSPROPERTYVALUE_Hidden: + return FDE_CSSOVERFLOW_Hidden; + case FDE_CSSPROPERTYVALUE_Scroll: + return FDE_CSSOVERFLOW_Scroll; + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSOVERFLOW_Auto; + case FDE_CSSPROPERTYVALUE_NoDisplay: + return FDE_CSSOVERFLOW_NoDisplay; + case FDE_CSSPROPERTYVALUE_NoContent: + return FDE_CSSOVERFLOW_NoContent; + default: + return FDE_CSSOVERFLOW_Visible; + } +} +FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_HorizontalTb: + return FDE_CSSWRITINGMODE_HorizontalTb; + case FDE_CSSPROPERTYVALUE_VerticalRl: + return FDE_CSSWRITINGMODE_VerticalRl; + case FDE_CSSPROPERTYVALUE_VerticalLr: + return FDE_CSSWRITINGMODE_VerticalLr; + default: + return FDE_CSSWRITINGMODE_HorizontalTb; + } +} +FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Normal: + return FDE_CSSWORDBREAK_Normal; + case FDE_CSSPROPERTYVALUE_KeepAll: + return FDE_CSSWORDBREAK_KeepAll; + case FDE_CSSPROPERTYVALUE_BreakAll: + return FDE_CSSWORDBREAK_BreakAll; + case FDE_CSSPROPERTYVALUE_KeepWords: + return FDE_CSSWORDBREAK_KeepWords; + default: + return FDE_CSSWORDBREAK_Normal; + } +} +FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSFLOAT_Left; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSFLOAT_Right; + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSFLOAT_None; + default: + return FDE_CSSFLOAT_None; + } +} +FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSCLEAR_None; + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSCLEAR_Left; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSCLEAR_Right; + case FDE_CSSPROPERTYVALUE_Both: + return FDE_CSSCLEAR_Both; + default: + return FDE_CSSCLEAR_None; + } +} +FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Avoid: + return FDE_CSSPAGEBREAK_Avoid; + case FDE_CSSPROPERTYVALUE_Auto: + return FDE_CSSPAGEBREAK_Auto; + case FDE_CSSPROPERTYVALUE_Always: + return FDE_CSSPAGEBREAK_Always; + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSPAGEBREAK_Left; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSPAGEBREAK_Right; + default: + return FDE_CSSPAGEBREAK_Auto; + } +} +FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Inline: + return FDE_CSSDISPLAY_Inline; + case FDE_CSSPROPERTYVALUE_Block: + return FDE_CSSDISPLAY_Block; + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSDISPLAY_None; + case FDE_CSSPROPERTYVALUE_ListItem: + return FDE_CSSDISPLAY_ListItem; + case FDE_CSSPROPERTYVALUE_TableCell: + return FDE_CSSDISPLAY_TableCell; + case FDE_CSSPROPERTYVALUE_TableRow: + return FDE_CSSDISPLAY_TableRow; + case FDE_CSSPROPERTYVALUE_Table: + return FDE_CSSDISPLAY_Table; + case FDE_CSSPROPERTYVALUE_TableCaption: + return FDE_CSSDISPLAY_TableCaption; + case FDE_CSSPROPERTYVALUE_TableRowGroup: + return FDE_CSSDISPLAY_TableRowGroup; + case FDE_CSSPROPERTYVALUE_TableHeaderGroup: + return FDE_CSSDISPLAY_TableHeaderGroup; + case FDE_CSSPROPERTYVALUE_TableFooterGroup: + return FDE_CSSDISPLAY_TableFooterGroup; + case FDE_CSSPROPERTYVALUE_TableColumnGroup: + return FDE_CSSDISPLAY_TableColumnGroup; + case FDE_CSSPROPERTYVALUE_TableColumn: + return FDE_CSSDISPLAY_TableColumn; + case FDE_CSSPROPERTYVALUE_InlineTable: + return FDE_CSSDISPLAY_InlineTable; + case FDE_CSSPROPERTYVALUE_InlineBlock: + return FDE_CSSDISPLAY_InlineBlock; + case FDE_CSSPROPERTYVALUE_RunIn: + return FDE_CSSDISPLAY_RunIn; + case FDE_CSSPROPERTYVALUE_Ruby: + return FDE_CSSDISPLAY_Ruby; + case FDE_CSSPROPERTYVALUE_RubyBase: + return FDE_CSSDISPLAY_RubyBase; + case FDE_CSSPROPERTYVALUE_RubyText: + return FDE_CSSDISPLAY_RubyText; + case FDE_CSSPROPERTYVALUE_RubyBaseGroup: + return FDE_CSSDISPLSY_RubyBaseGroup; + case FDE_CSSPROPERTYVALUE_RubyTextGroup: + return FDE_CSSDISPLAY_RubyTextGroup; + default: + return FDE_CSSDISPLAY_Inline; + } +} +FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Left: + return FDE_CSSTEXTALIGN_Left; + case FDE_CSSPROPERTYVALUE_Center: + return FDE_CSSTEXTALIGN_Center; + case FDE_CSSPROPERTYVALUE_Right: + return FDE_CSSTEXTALIGN_Right; + case FDE_CSSPROPERTYVALUE_Justify: + return FDE_CSSTEXTALIGN_Justify; + default: + return FDE_CSSTEXTALIGN_Left; + } +} +FX_WORD CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Normal: + return 400; + case FDE_CSSPROPERTYVALUE_Bold: + return 700; + case FDE_CSSPROPERTYVALUE_Bolder: + return 900; + case FDE_CSSPROPERTYVALUE_Lighter: + return 200; + default: + return 400; + } +} +FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Italic: + case FDE_CSSPROPERTYVALUE_Oblique: + return FDE_CSSFONTSTYLE_Italic; + default: + return FDE_CSSFONTSTYLE_Normal; + } +} +FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSBORDERSTYLE_None; + case FDE_CSSPROPERTYVALUE_Solid: + return FDE_CSSBORDERSTYLE_Solid; + case FDE_CSSPROPERTYVALUE_Hidden: + return FDE_CSSBORDERSTYLE_Hidden; + case FDE_CSSPROPERTYVALUE_Dotted: + return FDE_CSSBORDERSTYLE_Dotted; + case FDE_CSSPROPERTYVALUE_Dashed: + return FDE_CSSBORDERSTYLE_Dashed; + case FDE_CSSPROPERTYVALUE_Double: + return FDE_CSSBORDERSTYLE_Double; + case FDE_CSSPROPERTYVALUE_Groove: + return FDE_CSSBORDERSTYLE_Groove; + case FDE_CSSPROPERTYVALUE_Ridge: + return FDE_CSSBORDERSTYLE_Ridge; + case FDE_CSSPROPERTYVALUE_Inset: + return FDE_CSSBORDERSTYLE_Inset; + case FDE_CSSPROPERTYVALUE_Outset: + return FDE_CSSBORDERSTYLE_outset; + default: + return FDE_CSSBORDERSTYLE_None; + } +} +FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent( + FDE_CSSLENGTH& width, + FDE_CSSPRIMITIVETYPE eType, + IFDE_CSSPrimitiveValue* pPrimitive, + FX_FLOAT fFontSize) { + if (eType == FDE_CSSPRIMITIVETYPE_Percent) { + width.Set(FDE_CSSLENGTHUNIT_Percent, pPrimitive->GetFloat() / 100.0f); + return width.NonZero(); + } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && + eType <= FDE_CSSPRIMITIVETYPE_PC) { + FX_FLOAT fValue = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); + width.Set(FDE_CSSLENGTHUNIT_Point, fValue); + return width.NonZero(); + } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { + switch (pPrimitive->GetEnum()) { + case FDE_CSSPROPERTYVALUE_Auto: + width.Set(FDE_CSSLENGTHUNIT_Auto); + return TRUE; + case FDE_CSSPROPERTYVALUE_None: + width.Set(FDE_CSSLENGTHUNIT_None); + return TRUE; + case FDE_CSSPROPERTYVALUE_Thin: + width.Set(FDE_CSSLENGTHUNIT_Point, 2); + return TRUE; + case FDE_CSSPROPERTYVALUE_Medium: + width.Set(FDE_CSSLENGTHUNIT_Point, 3); + return TRUE; + case FDE_CSSPROPERTYVALUE_Thick: + width.Set(FDE_CSSLENGTHUNIT_Point, 4); + return TRUE; + default: + return FALSE; + } + } + return FALSE; +} +FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue, + FX_FLOAT fCurFontSize) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_XxSmall: + return m_fDefFontSize / 1.2f / 1.2f / 1.2f; + case FDE_CSSPROPERTYVALUE_XSmall: + return m_fDefFontSize / 1.2f / 1.2f; + case FDE_CSSPROPERTYVALUE_Small: + return m_fDefFontSize / 1.2f; + case FDE_CSSPROPERTYVALUE_Medium: + return m_fDefFontSize; + case FDE_CSSPROPERTYVALUE_Large: + return m_fDefFontSize * 1.2f; + case FDE_CSSPROPERTYVALUE_XLarge: + return m_fDefFontSize * 1.2f * 1.2f; + case FDE_CSSPROPERTYVALUE_XxLarge: + return m_fDefFontSize * 1.2f * 1.2f * 1.2f; + case FDE_CSSPROPERTYVALUE_Larger: + return fCurFontSize * 1.2f; + case FDE_CSSPROPERTYVALUE_Smaller: + return fCurFontSize / 1.2f; + default: + return fCurFontSize; + } +} +FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Baseline: + return FDE_CSSVERTICALALIGN_Baseline; + case FDE_CSSPROPERTYVALUE_Middle: + return FDE_CSSVERTICALALIGN_Middle; + case FDE_CSSPROPERTYVALUE_Bottom: + return FDE_CSSVERTICALALIGN_Bottom; + case FDE_CSSPROPERTYVALUE_Super: + return FDE_CSSVERTICALALIGN_Super; + case FDE_CSSPROPERTYVALUE_Sub: + return FDE_CSSVERTICALALIGN_Sub; + case FDE_CSSPROPERTYVALUE_Top: + return FDE_CSSVERTICALALIGN_Top; + case FDE_CSSPROPERTYVALUE_TextTop: + return FDE_CSSVERTICALALIGN_TextTop; + case FDE_CSSPROPERTYVALUE_TextBottom: + return FDE_CSSVERTICALALIGN_TextBottom; + default: + return FDE_CSSVERTICALALIGN_Baseline; + } +} +FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSLISTSTYLETYPE_None; + case FDE_CSSPROPERTYVALUE_Disc: + return FDE_CSSLISTSTYLETYPE_Disc; + case FDE_CSSPROPERTYVALUE_Circle: + return FDE_CSSLISTSTYLETYPE_Circle; + case FDE_CSSPROPERTYVALUE_Square: + return FDE_CSSLISTSTYLETYPE_Square; + case FDE_CSSPROPERTYVALUE_Decimal: + return FDE_CSSLISTSTYLETYPE_Decimal; + case FDE_CSSPROPERTYVALUE_DecimalLeadingZero: + return FDE_CSSLISTSTYLETYPE_DecimalLeadingZero; + case FDE_CSSPROPERTYVALUE_LowerRoman: + return FDE_CSSLISTSTYLETYPE_LowerRoman; + case FDE_CSSPROPERTYVALUE_UpperRoman: + return FDE_CSSLISTSTYLETYPE_UpperRoman; + case FDE_CSSPROPERTYVALUE_LowerGreek: + return FDE_CSSLISTSTYLETYPE_LowerGreek; + case FDE_CSSPROPERTYVALUE_LowerLatin: + return FDE_CSSLISTSTYLETYPE_LowerLatin; + case FDE_CSSPROPERTYVALUE_UpperLatin: + return FDE_CSSLISTSTYLETYPE_UpperLatin; + case FDE_CSSPROPERTYVALUE_Armenian: + return FDE_CSSLISTSTYLETYPE_Armenian; + case FDE_CSSPROPERTYVALUE_Georgian: + return FDE_CSSLISTSTYLETYPE_Georgian; + case FDE_CSSPROPERTYVALUE_LowerAlpha: + return FDE_CSSLISTSTYLETYPE_LowerAlpha; + case FDE_CSSPROPERTYVALUE_UpperAlpha: + return FDE_CSSLISTSTYLETYPE_UpperAlpha; + case FDE_CSSPROPERTYVALUE_CjkIdeographic: + return FDE_CSSLISTSTYLETYPE_CjkIdeographic; + case FDE_CSSPROPERTYVALUE_Hebrew: + return FDE_CSSLISTSTYLETYPE_Hebrew; + case FDE_CSSLISTSTYLETYPE_Hiragana: + return FDE_CSSLISTSTYLETYPE_Hiragana; + case FDE_CSSLISTSTYLETYPE_HiraganaIroha: + return FDE_CSSLISTSTYLETYPE_HiraganaIroha; + case FDE_CSSLISTSTYLETYPE_Katakana: + return FDE_CSSLISTSTYLETYPE_Katakana; + case FDE_CSSLISTSTYLETYPE_KatakanaIroha: + return FDE_CSSLISTSTYLETYPE_KatakanaIroha; + default: + return FDE_CSSLISTSTYLETYPE_Disc; + } +} +FDE_CSSLISTSTYLEPOSITION CFDE_CSSStyleSelector::ToListStylePosition( + FDE_CSSPROPERTYVALUE eValue) { + return eValue == FDE_CSSPROPERTYVALUE_Inside + ? FDE_CSSLISTSTYLEPOSITION_Inside + : FDE_CSSLISTSTYLEPOSITION_Outside; +} +FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Visible: + return FDE_CSSVISIBILITY_Visible; + case FDE_CSSPROPERTYVALUE_Hidden: + return FDE_CSSVISIBILITY_Hidden; + case FDE_CSSPROPERTYVALUE_Collapse: + return FDE_CSSVISIBILITY_Collapse; + default: + return FDE_CSSVISIBILITY_Visible; + } +} +FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_Normal: + return FDE_CSSWHITESPACE_Normal; + case FDE_CSSPROPERTYVALUE_Pre: + return FDE_CSSWHITESPACE_Pre; + case FDE_CSSPROPERTYVALUE_Nowrap: + return FDE_CSSWHITESPACE_Nowrap; + case FDE_CSSPROPERTYVALUE_PreWrap: + return FDE_CSSWHITESPACE_PreWrap; + case FDE_CSSPROPERTYVALUE_PreLine: + return FDE_CSSWHITESPACE_PreLine; + default: + return FDE_CSSWHITESPACE_Normal; + } +} +FX_DWORD CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) { + FX_DWORD dwDecoration = 0; + for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { + IFDE_CSSPrimitiveValue* pPrimitive = + (IFDE_CSSPrimitiveValue*)pValue->GetValue(i); + if (pPrimitive->GetPrimitiveType() == FDE_CSSPRIMITIVETYPE_Enum) { + switch (pPrimitive->GetEnum()) { + case FDE_CSSPROPERTYVALUE_Underline: + dwDecoration |= FDE_CSSTEXTDECORATION_Underline; + break; + case FDE_CSSPROPERTYVALUE_LineThrough: + dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; + break; + case FDE_CSSPROPERTYVALUE_Overline: + dwDecoration |= FDE_CSSTEXTDECORATION_Overline; + break; + case FDE_CSSPROPERTYVALUE_Blink: + dwDecoration |= FDE_CSSTEXTDECORATION_Blink; + break; + case FDE_CSSPROPERTYVALUE_Double: + dwDecoration |= FDE_CSSTEXTDECORATION_Double; + break; + default: + break; + } + } + } + return dwDecoration; +} +FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform( + FDE_CSSPROPERTYVALUE eValue) { + switch (eValue) { + case FDE_CSSPROPERTYVALUE_None: + return FDE_CSSTEXTTRANSFORM_None; + case FDE_CSSPROPERTYVALUE_Capitalize: + return FDE_CSSTEXTTRANSFORM_Capitalize; + case FDE_CSSPROPERTYVALUE_Uppercase: + return FDE_CSSTEXTTRANSFORM_UpperCase; + case FDE_CSSPROPERTYVALUE_Lowercase: + return FDE_CSSTEXTTRANSFORM_LowerCase; + default: + return FDE_CSSTEXTTRANSFORM_None; + } +} +FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( + FDE_CSSPROPERTYVALUE eValue) { + return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps + : FDE_CSSFONTVARIANT_Normal; +} diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h new file mode 100644 index 0000000000..4f8177f5c5 --- /dev/null +++ b/xfa/fde/css/fde_cssstyleselector.h @@ -0,0 +1,901 @@ +// 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_CSS_FDE_CSSSTYLESELECTOR_H_ +#define XFA_FDE_CSS_FDE_CSSSTYLESELECTOR_H_ + +#include <vector> + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fde/css/fde_css.h" +#include "xfa/fde/css/fde_csscache.h" +#include "xfa/fde/css/fde_cssdeclaration.h" +#include "xfa/fgas/crt/fgas_memory.h" +#include "xfa/fgas/crt/fgas_system.h" + +#define FDE_CSSUNIVERSALHASH ('*') + +class FDE_CSSRuleData : public CFX_Target { + public: + FDE_CSSRuleData(IFDE_CSSSelector* pSel, + IFDE_CSSDeclaration* pDecl, + FX_DWORD dwPos); + + IFDE_CSSSelector* pSelector; + IFDE_CSSDeclaration* pDeclaration; + FX_DWORD dwPriority; + FDE_CSSRuleData* pNext; +}; + +class CFDE_CSSRuleCollection : public CFX_Target { + public: + CFDE_CSSRuleCollection() + : m_pStaticStore(nullptr), + m_pUniversalRules(nullptr), + m_pPersudoRules(nullptr), + m_iSelectors(0) {} + ~CFDE_CSSRuleCollection() { Clear(); } + void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, + FX_DWORD dwMediaList, + IFX_FontMgr* pFontMgr); + void Clear(); + + int32_t CountSelectors() const { return m_iSelectors; } + FDE_CSSRuleData* GetIDRuleData(FX_DWORD dwIDHash) { + void* pData; + return m_IDRules.Lookup((void*)(uintptr_t)dwIDHash, pData) + ? (FDE_CSSRuleData*)pData + : NULL; + } + FDE_CSSRuleData* GetTagRuleData(FX_DWORD dwTagHasn) { + void* pData; + return m_TagRules.Lookup((void*)(uintptr_t)dwTagHasn, pData) + ? (FDE_CSSRuleData*)pData + : NULL; + } + FDE_CSSRuleData* GetClassRuleData(FX_DWORD dwIDHash) { + void* pData; + return m_ClassRules.Lookup((void*)(uintptr_t)dwIDHash, pData) + ? (FDE_CSSRuleData*)pData + : NULL; + } + FDE_CSSRuleData* GetUniversalRuleData() { return m_pUniversalRules; } + FDE_CSSRuleData* GetPersudoRuleData() { return m_pPersudoRules; } + IFX_MEMAllocator* m_pStaticStore; + + protected: + void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, + IFDE_CSSRule* pRule, + FX_DWORD dwMediaList, + IFX_FontMgr* pFontMgr); + void AddRuleTo(CFX_MapPtrToPtr& map, + FX_DWORD dwKey, + IFDE_CSSSelector* pSel, + IFDE_CSSDeclaration* pDecl); + FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData); + FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel, + IFDE_CSSDeclaration* pDecl); + CFX_MapPtrToPtr m_IDRules; + CFX_MapPtrToPtr m_TagRules; + CFX_MapPtrToPtr m_ClassRules; + FDE_CSSRuleData* m_pUniversalRules; + FDE_CSSRuleData* m_pPersudoRules; + int32_t m_iSelectors; +}; +class CFDE_CSSAccelerator; +class CFDE_CSSComputedStyle; +class CFDE_CSSStyleSelector : public IFDE_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(FX_DWORD dwMediaList); + virtual IFDE_CSSAccelerator* InitAccelerator(); + virtual 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); + + protected: + void Reset(); + void MatchRules(FDE_CSSTagCache* pCache, + FDE_CSSRuleData* pList, + FDE_CSSPERSUDO ePersudoType); + FX_BOOL MatchSelector(FDE_CSSTagCache* pCache, + IFDE_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, + int32_t iDeclCount, + IFDE_CSSComputedStyle* pDestStyle); + void ApplyProperty(FDE_CSSPROPERTY eProperty, + IFDE_CSSValue* pValue, + CFDE_CSSComputedStyle* pComputedStyle); + + FX_FLOAT ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, + FX_FLOAT fValue, + FX_FLOAT fPercentBase); + FX_BOOL SetLengthWithPercent(FDE_CSSLENGTH& width, + FDE_CSSPRIMITIVETYPE eType, + IFDE_CSSPrimitiveValue* pPrimitive, + FX_FLOAT fFontSize); + FX_FLOAT ToFontSize(FDE_CSSPROPERTYVALUE eValue, FX_FLOAT fCurFontSize); + FDE_CSSDISPLAY ToDisplay(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSTEXTALIGN ToTextAlign(FDE_CSSPROPERTYVALUE eValue); + FX_WORD ToFontWeight(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSFONTSTYLE ToFontStyle(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSBORDERSTYLE ToBorderStyle(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSVERTICALALIGN ToVerticalAlign(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSLISTSTYLETYPE ToListStyleType(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSLISTSTYLEPOSITION ToListStylePosition(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSVISIBILITY ToVisibility(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSWHITESPACE ToWhiteSpace(FDE_CSSPROPERTYVALUE eValue); + FX_DWORD ToTextDecoration(IFDE_CSSValueList* pList); + FDE_CSSTEXTTRANSFORM ToTextTransform(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSFONTVARIANT ToFontVariant(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSFLOAT ToFloat(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSCLEAR ToClear(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSWRITINGMODE ToWritingMode(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSWORDBREAK ToWordBreak(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSPAGEBREAK ToPageBreak(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSOVERFLOW ToOverflow(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSLINEBREAK ToLineBreak(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSTEXTCOMBINE ToTextCombine(FDE_CSSPROPERTYVALUE eValue); + FX_BOOL ToTextEmphasisMark(FDE_CSSPROPERTYVALUE eValue, + FDE_CSSTEXTEMPHASISMARK& eMark); + FX_BOOL ToTextEmphasisFill(FDE_CSSPROPERTYVALUE eValue, + FDE_CSSTEXTEMPHASISFILL& eFill); + FDE_CSSCURSOR ToCursor(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSPOSITION ToPosition(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSCAPTIONSIDE ToCaptionSide(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSBKGREPEAT ToBKGRepeat(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSBKGATTACHMENT ToBKGAttachment(FDE_CSSPROPERTYVALUE eValue); + FDE_CSSRUBYALIGN ToRubyAlign(FDE_CSSPROPERTYVALUE eValue); + 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; + 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; + CFDE_CSSAccelerator* m_pAccelerator; + std::vector<FDE_CSSRuleData*> m_MatchedRules; +}; + +struct FDE_CSSCOUNTERDATA { + public: + FDE_CSSCOUNTERDATA() { FXSYS_memset(this, 0, sizeof(FDE_CSSCOUNTERDATA)); } + FX_BOOL GetCounterIncrement(int32_t& iValue) { + iValue = m_iIncVal; + return m_bIncrement; + } + FX_BOOL GetCounterReset(int32_t& iValue) { + iValue = m_iResetVal; + return m_bReset; + } + + const FX_WCHAR* m_pszIdent; + FX_BOOL m_bIncrement; + FX_BOOL m_bReset; + int32_t m_iIncVal; + int32_t m_iResetVal; +}; + +class CFDE_CSSCounterStyle { + public: + CFDE_CSSCounterStyle() : m_pCounterInc(NULL), m_pCounterReset(NULL) {} + 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; + } + + protected: + 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() { + FXSYS_memset(this, 0, sizeof(CFDE_CSSInheritedData)); + m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_fFontSize = 12.0f; + m_fLineHeight = 14.0f; + m_wFontWeight = 400; + m_dwFontColor = 0xFF000000; + m_iWidows = 2; + m_bTextEmphasisColorCurrent = TRUE; + m_iOrphans = 2; + } + const FX_WCHAR* m_pszListStyleImage; + FDE_CSSLENGTH m_LetterSpacing; + FDE_CSSLENGTH m_WordSpacing; + FDE_CSSLENGTH m_TextIndent; + IFDE_CSSValueList* m_pFontFamily; + IFDE_CSSValueList* m_pQuotes; + IFDE_CSSValueList* m_pCursorUris; + FDE_CSSCURSOR m_eCursor; + FX_FLOAT m_fFontSize; + FX_FLOAT m_fLineHeight; + FX_ARGB m_dwFontColor; + FX_ARGB m_dwTextEmphasisColor; + FX_WORD m_wFontWeight; + int32_t m_iWidows; + int32_t m_iOrphans; + const FX_WCHAR* m_pszTextEmphasisCustomMark; + FX_WORD m_eFontVariant : 1; + FX_WORD m_eFontStyle : 1; + FX_WORD m_bTextEmphasisColorCurrent : 1; + FX_WORD m_eTextAligh : 2; + FX_WORD m_eVisibility : 2; + FX_WORD m_eWhiteSpace : 3; + FX_WORD m_eTextTransform : 2; + FX_WORD m_eWritingMode : 2; + FX_WORD m_eWordBreak : 2; + FX_WORD m_eLineBreak : 2; + FX_WORD m_eTextEmphasisFill : 1; + FX_WORD m_eTextEmphasisMark : 3; + FX_WORD m_eCaptionSide : 3; + + FX_WORD m_eRubyAlign : 4; + FX_WORD m_eRubyOverhang : 2; + FX_WORD m_eRubyPosition : 2; +}; +class CFDE_CSSNonInheritedData { + public: + void Reset() { + FXSYS_memset(this, 0, sizeof(CFDE_CSSNonInheritedData)); + m_MarginWidth = m_BorderWidth = + m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None); + m_eDisplay = FDE_CSSDISPLAY_Inline; + m_fVerticalAlign = 0.0f; + m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); + m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal); + m_bColumnRuleColorSame = TRUE; + m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto); + m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto); + m_eTextCombine = FDE_CSSTEXTCOMBINE_None; + } + + IFDE_CSSValueList* m_pContentList; + CFDE_CSSCounterStyle* m_pCounterStyle; + FDE_CSSRECT m_MarginWidth; + FDE_CSSRECT m_BorderWidth; + FDE_CSSRECT m_PaddingWidth; + FDE_CSSSIZE m_BoxSize; + FDE_CSSSIZE m_MinBoxSize; + FDE_CSSSIZE m_MaxBoxSize; + FDE_CSSPOINT m_BKGPosition; + const FX_WCHAR* m_pszBKGImage; + FX_ARGB m_dwBKGColor; + FX_ARGB m_dwBDRLeftColor; + FX_ARGB m_dwBDRTopColor; + FX_ARGB m_dwBDRRightColor; + FX_ARGB m_dwBDRBottomColor; + IFDE_CSSValue* m_pRubySpan; + FDE_CSSLENGTH m_ColumnCount; + FDE_CSSLENGTH m_ColumnGap; + FDE_CSSLENGTH m_ColumnRuleWidth; + FDE_CSSLENGTH m_ColumnWidth; + FX_ARGB m_dwColumnRuleColor; + FDE_CSSLENGTH m_Top; + FDE_CSSLENGTH m_Bottom; + FDE_CSSLENGTH m_Left; + FDE_CSSLENGTH m_Right; + + FX_FLOAT m_fVerticalAlign; + FX_FLOAT m_fTextCombineNumber; + FX_DWORD m_eBDRLeftStyle : 4; + FX_DWORD m_eBDRTopStyle : 4; + FX_DWORD m_eBDRRightStyle : 4; + FX_DWORD m_eBDRBottomStyle : 4; + FX_DWORD m_eDisplay : 5; + FX_DWORD m_eVerticalAlign : 4; + FX_DWORD m_eListStyleType : 5; + FX_DWORD m_eColumnRuleStyle : 4; + FX_DWORD m_ePageBreakInside : 3; + FX_DWORD m_ePageBreakAfter : 3; + FX_DWORD m_ePageBreakBefore : 3; + FX_DWORD m_ePosition : 2; + FX_DWORD m_eBKGRepeat : 2; + FX_DWORD m_eFloat : 2; + FX_DWORD m_eClear : 2; + FX_DWORD m_eOverflowX : 3; + FX_DWORD m_eOverflowY : 3; + FX_DWORD m_eListStylePosition : 1; + FX_DWORD m_eBKGAttachment : 1; + FX_DWORD m_bHasMargin : 1; + FX_DWORD m_bHasBorder : 1; + FX_DWORD m_bHasPadding : 1; + FX_DWORD m_dwTextDecoration : 5; + FX_DWORD m_eTextCombine : 1; + FX_DWORD m_bColumnRuleColorSame : 1; + FX_DWORD m_bHasTextCombineNumber : 1; +}; +class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle, + public IFDE_CSSFontStyle, + public IFDE_CSSBoundaryStyle, + 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) + : m_dwRefCount(1), m_pAllocator(pAlloc) {} + ~CFDE_CSSComputedStyle() {} + virtual FX_DWORD AddRef() { return ++m_dwRefCount; } + virtual FX_DWORD Release() { + FX_DWORD dwRefCount = --m_dwRefCount; + if (dwRefCount == 0) { + if (m_NonInheritedData.m_pCounterStyle != NULL) { + delete m_NonInheritedData.m_pCounterStyle; + } + FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); + } + return dwRefCount; + } + + virtual void Reset() { + 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; + } + virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const { + return (IFDE_CSSMultiColumnStyle * const) this; + } + virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const { + return (IFDE_CSSGeneratedContentStyle * const) this; + } + virtual IFDE_CSSRubyStyle* GetRubyStyle() const { + return (IFDE_CSSRubyStyle * const) this; + } + virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName, + CFX_WideString& wsValue) const { + for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) { + if (wsName == m_CustomProperties[i]) { + wsValue = m_CustomProperties[i + 1]; + return TRUE; + } + } + 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 { + 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))) + ->GetString(index); + } + virtual FX_WORD GetFontWeight() const { + return m_InheritedData.m_wFontWeight; + } + virtual FDE_CSSFONTVARIANT GetFontVariant() const { + return (FDE_CSSFONTVARIANT)m_InheritedData.m_eFontVariant; + } + virtual FDE_CSSFONTSTYLE GetFontStyle() const { + return (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(FX_WORD wFontWeight) { + m_InheritedData.m_wFontWeight = wFontWeight; + } + virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) { + m_InheritedData.m_eFontVariant = eFontVariant; + } + virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) { + m_InheritedData.m_eFontStyle = eFontStyle; + } + virtual void SetFontSize(FX_FLOAT fFontSize) { + 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; + } + + virtual const FDE_CSSRECT* GetBorderWidth() const { + return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth) + : NULL; + } + virtual const FDE_CSSRECT* GetMarginWidth() const { + return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth) + : NULL; + } + virtual const FDE_CSSRECT* GetPaddingWidth() const { + 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; + } + + 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) { + m_NonInheritedData.m_MarginWidth = rect; + m_NonInheritedData.m_bHasMargin = TRUE; + } + virtual void SetPaddingWidth(const FDE_CSSRECT& rect) { + 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; + } + 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 { + return m_InheritedData.m_fLineHeight; + } + virtual FDE_CSSWHITESPACE GetWhiteSpace() const { + return (FDE_CSSWHITESPACE)m_InheritedData.m_eWhiteSpace; + } + virtual const FDE_CSSLENGTH& GetTextIndent() const { + return m_InheritedData.m_TextIndent; + } + virtual FDE_CSSTEXTALIGN GetTextAlign() const { + return (FDE_CSSTEXTALIGN)m_InheritedData.m_eTextAligh; + } + virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const { + return (FDE_CSSVERTICALALIGN)m_NonInheritedData.m_eVerticalAlign; + } + virtual FX_FLOAT GetNumberVerticalAlign() const { + return m_NonInheritedData.m_fVerticalAlign; + } + virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const { + return (FDE_CSSTEXTTRANSFORM)m_InheritedData.m_eTextTransform; + } + virtual FX_DWORD GetTextDecoration() const { + return m_NonInheritedData.m_dwTextDecoration; + } + virtual const FDE_CSSLENGTH& GetLetterSpacing() const { + 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) { + m_InheritedData.m_fLineHeight = fLineHeight; + } + virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) { + m_InheritedData.m_eWhiteSpace = eWhiteSpace; + } + virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) { + m_InheritedData.m_TextIndent = textIndent; + } + virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) { + m_InheritedData.m_eTextAligh = eTextAlign; + } + virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) { + m_NonInheritedData.m_eVerticalAlign = eVerticalAlign; + } + virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) { + 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(FX_DWORD dwTextDecoration) { + m_NonInheritedData.m_dwTextDecoration = dwTextDecoration; + } + virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) { + 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); + } + FX_DWORD m_dwRefCount; + IFX_MEMAllocator* m_pAllocator; + CFDE_CSSInheritedData m_InheritedData; + CFDE_CSSNonInheritedData m_NonInheritedData; + CFX_WideStringArray m_CustomProperties; +}; + +#endif // XFA_FDE_CSS_FDE_CSSSTYLESELECTOR_H_ diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp new file mode 100644 index 0000000000..561b2f42f3 --- /dev/null +++ b/xfa/fde/css/fde_cssstylesheet.cpp @@ -0,0 +1,509 @@ +// 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/css/fde_cssstylesheet.h" + +#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 = + 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}" + L"li{display:list-item}head{display:none}table{display:table}tr{display:" + L"table-row}thead{display:table-header-group}tbody{display:table-row-" + L"group}tfoot{display:table-footer-group}" + L"col{display:table-column}colgroup{display:table-column-group}td,th{" + L"display:table-cell}caption{display:table-caption}th{font-weight:bolder;" + L"text-align:center}caption{text-align:center}" + L"body{margin:0}h1{font-size:2em;margin:.67em " + L"0}h2{font-size:1.5em;margin:.75em 0}h3{font-size:1.17em;margin:.83em " + L"0}h4,p,blockquote,ul,fieldset,form,ol,dl,dir,menu{margin:1.12em 0}" + L"h5{font-size:.83em;margin:1.5em 0}h6{font-size:.75em;margin:1.67em " + L"0}h1,h2,h3,h4,h5,h6,b,strong{font-weight:bolder}blockquote{margin-left:" + L"40px;margin-right:40px}i,cite,em,var,address{font-style:italic}" + L"pre,tt,code,kbd,samp{font-family:monospace}pre{white-space:pre}button," + L"textarea,input,select{display:inline-block}big{font-size:1.17em}small," + L"sub,sup{font-size:.83em}sub{vertical-align:sub}" + L"sup{vertical-align:super}table{border-spacing:2px}thead,tbody,tfoot{" + L"vertical-align:middle}td,th,tr{vertical-align:inherit}s,strike,del{" + L"text-decoration:line-through}hr{border:1px inset silver}" + L"ol,ul,dir,menu,dd{margin-left:40px}ol{list-style-type:decimal}ol ul,ul " + L"ol,ul ul,ol " + L"ol{margin-top:0;margin-bottom:0}u,ins{text-decoration:underline}center{" + L"text-align:center}" + L"ruby{display:ruby}rt{display:ruby-text;font-size:.5em}rb{display:ruby-" + L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}" + L"q:before{content:open-quote}q:after{content:close-quote}" + L"rp{display:none}"; + return IFDE_CSSStyleSheet::LoadFromBuffer( + CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); +} + +IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( + const CFX_WideString& szUrl, + IFX_Stream* pStream, + FX_WORD wCodePage, + FX_DWORD dwMediaList) { + CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); + if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { + pStyleSheet->Release(); + pStyleSheet = NULL; + } + return pStyleSheet; +} +IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( + const CFX_WideString& szUrl, + const FX_WCHAR* pBuffer, + int32_t iBufSize, + FX_WORD wCodePage, + FX_DWORD dwMediaList) { + CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); + if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { + pStyleSheet->Release(); + pStyleSheet = NULL; + } + return pStyleSheet; +} +CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList) + : m_wCodePage(FX_CODEPAGE_UTF8), + m_wRefCount(1), + m_dwMediaList(dwMediaList), + m_pAllocator(NULL) { + FXSYS_assert(m_dwMediaList > 0); +} +CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() { + Reset(); +} +void CFDE_CSSStyleSheet::Reset() { + for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { + IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); + switch (pRule->GetType()) { + case FDE_CSSRULETYPE_Style: + ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); + break; + case FDE_CSSRULETYPE_Media: + ((CFDE_CSSMediaRule*)pRule)->~CFDE_CSSMediaRule(); + break; + case FDE_CSSRULETYPE_FontFace: + ((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule(); + break; + default: + FXSYS_assert(FALSE); + break; + } + } + m_RuleArray.RemoveAll(); + m_Selectors.RemoveAll(); + m_StringCache.RemoveAll(); + if (m_pAllocator) { + m_pAllocator->Release(); + m_pAllocator = NULL; + } +} +FX_DWORD CFDE_CSSStyleSheet::AddRef() { + return ++m_wRefCount; +} +FX_DWORD CFDE_CSSStyleSheet::Release() { + FX_DWORD dwRefCount = --m_wRefCount; + if (dwRefCount == 0) { + delete this; + } + return dwRefCount; +} +int32_t CFDE_CSSStyleSheet::CountRules() const { + return m_RuleArray.GetSize(); +} +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, + FX_WORD wCodePage) { + FXSYS_assert(pStream != NULL); + IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); + if (pSyntax == NULL) { + return FALSE; + } + if (pStream->GetCodePage() != wCodePage) { + pStream->SetCodePage(wCodePage); + } + FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax); + pSyntax->Release(); + m_wCodePage = wCodePage; + m_szUrl = szUrl; + return bRet; +} +FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl, + const FX_WCHAR* pBuffer, + int32_t iBufSize, + FX_WORD 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(); + m_wCodePage = wCodePage; + m_szUrl = szUrl; + return bRet; +} +FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) { + Reset(); + m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); + if (m_pAllocator == NULL) { + return FALSE; + } + FDE_CSSSYNTAXSTATUS eStatus; + do { + switch (eStatus = pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_StyleRule: + eStatus = LoadStyleRule(pSyntax, m_RuleArray); + break; + case FDE_CSSSYNTAXSTATUS_MediaRule: + eStatus = LoadMediaRule(pSyntax); + break; + case FDE_CSSSYNTAXSTATUS_FontFaceRule: + eStatus = LoadFontFaceRule(pSyntax, m_RuleArray); + break; + case FDE_CSSSYNTAXSTATUS_ImportRule: + eStatus = LoadImportRule(pSyntax); + break; + case FDE_CSSSYNTAXSTATUS_PageRule: + eStatus = LoadPageRule(pSyntax); + break; + default: + break; + } + } while (eStatus >= FDE_CSSSYNTAXSTATUS_None); + m_Selectors.RemoveAll(); + m_StringCache.RemoveAll(); + return eStatus != FDE_CSSSYNTAXSTATUS_Error; +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( + IFDE_CSSSyntaxParser* pSyntax) { + FX_DWORD dwMediaList = 0; + CFDE_CSSMediaRule* pMediaRule = NULL; + for (;;) { + switch (pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_MediaType: { + int32_t iLen; + const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen); + FDE_LPCCSSMEDIATYPETABLE pMediaType = + FDE_GetCSSMediaTypeByName(psz, iLen); + if (pMediaType != NULL) { + dwMediaList |= pMediaType->wValue; + } + } break; + case FDE_CSSSYNTAXSTATUS_StyleRule: + if (pMediaRule == NULL) { + SkipRuleSet(pSyntax); + } else { + FDE_CSSSYNTAXSTATUS eStatus = + LoadStyleRule(pSyntax, pMediaRule->GetArray()); + if (eStatus < FDE_CSSSYNTAXSTATUS_None) { + return eStatus; + } + } + break; + case FDE_CSSSYNTAXSTATUS_DeclOpen: + if ((dwMediaList & m_dwMediaList) > 0 && pMediaRule == NULL) { + pMediaRule = + FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList); + m_RuleArray.Add(pMediaRule); + } + break; + case FDE_CSSSYNTAXSTATUS_DeclClose: + return FDE_CSSSYNTAXSTATUS_None; + FDE_CSSSWITCHDEFAULTS(); + } + } +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule( + IFDE_CSSSyntaxParser* pSyntax, + CFDE_CSSRuleArray& ruleArray) { + m_Selectors.RemoveAt(0, m_Selectors.GetSize()); + CFDE_CSSStyleRule* pStyleRule = NULL; + const FX_WCHAR* pszValue = NULL; + int32_t iValueLen = 0; + FDE_CSSPROPERTYARGS propertyArgs; + propertyArgs.pStaticStore = m_pAllocator; + propertyArgs.pStringCache = &m_StringCache; + propertyArgs.pProperty = NULL; + CFX_WideString wsName; + for (;;) { + switch (pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_Selector: { + pszValue = pSyntax->GetCurrentString(iValueLen); + IFDE_CSSSelector* pSelector = + CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen); + if (pSelector != NULL) { + m_Selectors.Add(pSelector); + } + } break; + case FDE_CSSSYNTAXSTATUS_PropertyName: + pszValue = pSyntax->GetCurrentString(iValueLen); + propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); + if (propertyArgs.pProperty == NULL) { + wsName = CFX_WideStringC(pszValue, iValueLen); + } + break; + case FDE_CSSSYNTAXSTATUS_PropertyValue: + if (propertyArgs.pProperty != NULL) { + pszValue = pSyntax->GetCurrentString(iValueLen); + if (iValueLen > 0) { + pStyleRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, + iValueLen); + } + } else if (iValueLen > 0) { + pszValue = pSyntax->GetCurrentString(iValueLen); + if (iValueLen > 0) { + pStyleRule->GetDeclImp().AddProperty( + &propertyArgs, wsName, wsName.GetLength(), pszValue, iValueLen); + } + } + break; + case FDE_CSSSYNTAXSTATUS_DeclOpen: + if (pStyleRule == NULL && m_Selectors.GetSize() > 0) { + pStyleRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSStyleRule; + pStyleRule->SetSelector(m_pAllocator, m_Selectors); + ruleArray.Add(pStyleRule); + } else { + SkipRuleSet(pSyntax); + return FDE_CSSSYNTAXSTATUS_None; + } + break; + case FDE_CSSSYNTAXSTATUS_DeclClose: + if (pStyleRule != NULL && + pStyleRule->GetDeclImp().GetStartPosition() == NULL) { + pStyleRule->~CFDE_CSSStyleRule(); + ruleArray.RemoveLast(1); + } + return FDE_CSSSYNTAXSTATUS_None; + FDE_CSSSWITCHDEFAULTS(); + } + } +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule( + IFDE_CSSSyntaxParser* pSyntax, + CFDE_CSSRuleArray& ruleArray) { + CFDE_CSSFontFaceRule* pFontFaceRule = NULL; + const FX_WCHAR* pszValue = NULL; + int32_t iValueLen = 0; + FDE_CSSPROPERTYARGS propertyArgs; + propertyArgs.pStaticStore = m_pAllocator; + propertyArgs.pStringCache = &m_StringCache; + propertyArgs.pProperty = NULL; + for (;;) { + switch (pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_PropertyName: + pszValue = pSyntax->GetCurrentString(iValueLen); + propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); + break; + case FDE_CSSSYNTAXSTATUS_PropertyValue: + if (propertyArgs.pProperty != NULL) { + pszValue = pSyntax->GetCurrentString(iValueLen); + if (iValueLen > 0) { + pFontFaceRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, + iValueLen); + } + } + break; + case FDE_CSSSYNTAXSTATUS_DeclOpen: + if (pFontFaceRule == NULL) { + pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule; + ruleArray.Add(pFontFaceRule); + } + break; + case FDE_CSSSYNTAXSTATUS_DeclClose: + return FDE_CSSSYNTAXSTATUS_None; + FDE_CSSSWITCHDEFAULTS(); + } + } + return FDE_CSSSYNTAXSTATUS_None; +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule( + IFDE_CSSSyntaxParser* pSyntax) { + for (;;) { + switch (pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_ImportClose: + return FDE_CSSSYNTAXSTATUS_None; + case FDE_CSSSYNTAXSTATUS_URI: + break; + FDE_CSSSWITCHDEFAULTS(); + } + } +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule( + IFDE_CSSSyntaxParser* pSyntax) { + return SkipRuleSet(pSyntax); +} +FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet( + IFDE_CSSSyntaxParser* pSyntax) { + for (;;) { + switch (pSyntax->DoSyntaxParse()) { + case FDE_CSSSYNTAXSTATUS_Selector: + case FDE_CSSSYNTAXSTATUS_DeclOpen: + case FDE_CSSSYNTAXSTATUS_PropertyName: + case FDE_CSSSYNTAXSTATUS_PropertyValue: + break; + case FDE_CSSSYNTAXSTATUS_DeclClose: + return FDE_CSSSYNTAXSTATUS_None; + FDE_CSSSWITCHDEFAULTS(); + } + } + return FDE_CSSSYNTAXSTATUS_None; +} +void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore, + const CFDE_CSSSelectorArray& list) { + FXSYS_assert(m_ppSelector == NULL); + m_iSelectors = list.GetSize(); + m_ppSelector = (IFDE_CSSSelector**)pStaticStore->Alloc( + m_iSelectors * sizeof(IFDE_CSSSelector*)); + for (int32_t i = 0; i < m_iSelectors; ++i) { + m_ppSelector[i] = list.GetAt(i); + } +} +CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { + for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { + IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); + switch (pRule->GetType()) { + case FDE_CSSRULETYPE_Style: + ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); + break; + default: + FXSYS_assert(FALSE); + break; + } + } +} +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 == ':'); + const FX_WCHAR* pStart = psz; + while (psz < pEnd) { + FX_WCHAR wch = *psz; + if (FDE_IsCSSChar(wch) || wch == ':') { + ++psz; + } else { + break; + } + } + return psz - pStart; +} +int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { + const FX_WCHAR* pStart = psz; + while (psz < pEnd) { + FX_WCHAR wch = *psz; + if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' || + wch == '-') { + ++psz; + } else { + break; + } + } + 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); + const FX_WCHAR* pStart = psz; + const FX_WCHAR* pEnd = psz + iLen; + for (; psz < pEnd; ++psz) { + switch (*psz) { + case '>': + case '[': + case '+': + return NULL; + } + } + CFDE_CSSSelector *pFirst = NULL, *pLast = NULL; + CFDE_CSSSelector *pPersudoFirst = NULL, *pPersudoLast = NULL; + for (psz = pStart; psz < pEnd;) { + FX_WCHAR wch = *psz; + if (wch == '.' || wch == '#') { + if (psz == pStart || psz[-1] == ' ') { + CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) + CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, TRUE); + if (p == NULL) { + return NULL; + } + if (pFirst != NULL) { + pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); + p->SetNext(pFirst); + } + pFirst = pLast = p; + } + FXSYS_assert(pLast != NULL); + int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd); + if (iNameLen == 0) { + return NULL; + } + FDE_CSSSELECTORTYPE eType = + wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID; + CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) + CFDE_CSSSelector(eType, psz, iNameLen, FALSE); + if (p == NULL) { + return NULL; + } + p->SetNext(pLast->GetNextSelector()); + pLast->SetNext(p); + pLast = p; + psz += iNameLen; + } else if (FDE_IsCSSChar(wch) || wch == '*') { + int32_t iNameLen = wch == '*' ? 1 : FDE_GetCSSNameLen(psz, pEnd); + if (iNameLen == 0) { + return NULL; + } + CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) + CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, TRUE); + if (p == NULL) { + return NULL; + } + if (pFirst == NULL) { + pFirst = pLast = p; + } else { + pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); + p->SetNext(pFirst); + pFirst = pLast = p; + } + psz += iNameLen; + } else if (wch == ':') { + int32_t iNameLen = FDE_GetCSSPersudoLen(psz, pEnd); + if (iNameLen == 0) { + return NULL; + } + CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) + CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, TRUE); + if (p == NULL) { + return NULL; + } + if (pPersudoFirst == NULL) { + pPersudoFirst = pPersudoLast = p; + } else { + pPersudoLast->SetNext(p); + pPersudoLast = p; + } + psz += iNameLen; + } else if (wch == ' ') { + psz++; + } else { + return NULL; + } + } + if (pPersudoFirst == NULL) { + return pFirst; + } else { + pPersudoLast->SetNext(pFirst); + return pPersudoFirst; + } +} diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h new file mode 100644 index 0000000000..f39ff1f22a --- /dev/null +++ b/xfa/fde/css/fde_cssstylesheet.h @@ -0,0 +1,141 @@ +// 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_CSS_FDE_CSSSTYLESHEET_H_ +#define XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fde/css/fde_cssdeclaration.h" + +class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target { + public: + CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, + const FX_WCHAR* psz, + int32_t iLen, + FX_BOOL bIgnoreCase) + : m_eType(eType), + m_dwHash(FX_HashCode_String_GetW(psz, iLen, bIgnoreCase)), + m_pNext(NULL) {} + virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; } + + virtual FX_DWORD GetNameHash() const { return m_dwHash; } + + virtual IFDE_CSSSelector* GetNextSelector() const { return m_pNext; } + static IFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore, + const FX_WCHAR* psz, + int32_t iLen); + void SetNext(IFDE_CSSSelector* pNext) { m_pNext = pNext; } + + protected: + static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore, + const FX_WCHAR* psz, + int32_t& iOff, + int32_t iLen, + FDE_CSSSELECTORTYPE eType); + void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; } + FDE_CSSSELECTORTYPE m_eType; + FX_DWORD m_dwHash; + IFDE_CSSSelector* m_pNext; +}; +typedef CFX_ArrayTemplate<IFDE_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 { + return m_ppSelector[index]; + } + + virtual IFDE_CSSDeclaration* GetDeclaration() const { + return (IFDE_CSSDeclaration*)&m_Declaration; + } + CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } + void SetSelector(IFX_MEMAllocator* pStaticStore, + const CFDE_CSSSelectorArray& list); + + protected: + CFDE_CSSDeclaration m_Declaration; + IFDE_CSSSelector** m_ppSelector; + int32_t m_iSelectors; +}; +class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target { + public: + CFDE_CSSMediaRule(FX_DWORD dwMediaList) : m_dwMediaList(dwMediaList) {} + ~CFDE_CSSMediaRule(); + + virtual FX_DWORD GetMediaList() const { return m_dwMediaList; } + + virtual int32_t CountRules() const { return m_RuleArray.GetSize(); } + virtual IFDE_CSSRule* GetRule(int32_t index) { + return m_RuleArray.GetAt(index); + } + CFDE_CSSRuleArray& GetArray() { return m_RuleArray; } + + protected: + FX_DWORD m_dwMediaList; + CFDE_CSSRuleArray m_RuleArray; +}; +class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target { + public: + virtual IFDE_CSSDeclaration* GetDeclaration() const { + return (IFDE_CSSDeclaration*)&m_Declaration; + } + CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } + + protected: + CFDE_CSSDeclaration m_Declaration; +}; +#define FDE_CSSSWITCHDEFAULTS() \ + case FDE_CSSSYNTAXSTATUS_EOS: \ + return FDE_CSSSYNTAXSTATUS_EOS; \ + case FDE_CSSSYNTAXSTATUS_Error: \ + default: \ + return FDE_CSSSYNTAXSTATUS_Error; +class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target { + public: + CFDE_CSSStyleSheet(FX_DWORD dwMediaList); + ~CFDE_CSSStyleSheet(); + virtual FX_DWORD AddRef(); + virtual FX_DWORD Release(); + + virtual FX_BOOL GetUrl(CFX_WideString& szUrl) { + szUrl = m_szUrl; + return szUrl.GetLength() > 0; + } + virtual FX_DWORD GetMediaList() const { return m_dwMediaList; } + virtual FX_WORD GetCodePage() const { return m_wCodePage; } + virtual int32_t CountRules() const; + virtual IFDE_CSSRule* GetRule(int32_t index); + FX_BOOL LoadFromStream(const CFX_WideString& szUrl, + IFX_Stream* pStream, + FX_WORD wCodePage); + FX_BOOL LoadFromBuffer(const CFX_WideString& szUrl, + const FX_WCHAR* pBuffer, + int32_t iBufSize, + FX_WORD wCodePage); + + protected: + void Reset(); + FX_BOOL LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax); + FDE_CSSSYNTAXSTATUS LoadStyleRule(IFDE_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, + CFDE_CSSRuleArray& ruleArray); + FDE_CSSSYNTAXSTATUS SkipRuleSet(IFDE_CSSSyntaxParser* pSyntax); + FX_WORD m_wCodePage; + FX_WORD m_wRefCount; + FX_DWORD m_dwMediaList; + IFX_MEMAllocator* m_pAllocator; + CFDE_CSSRuleArray m_RuleArray; + CFX_WideString m_szUrl; + CFDE_CSSSelectorArray m_Selectors; + CFX_MapPtrToPtr m_StringCache; +}; + +#endif // XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp new file mode 100644 index 0000000000..e03c57c6a8 --- /dev/null +++ b/xfa/fde/css/fde_csssyntax.cpp @@ -0,0 +1,487 @@ +// 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/css/fde_csssyntax.h" + +#include "xfa/fde/css/fde_cssdatatable.h" +#include "xfa/fgas/crt/fgas_codepage.h" + +#ifdef _cplusplus +extern "C" { +#endif + +inline FX_BOOL FDE_IsSelectorStart(FX_WCHAR wch) { + return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') || + (wch >= 'A' && wch <= 'Z'); +} + +#ifdef _cplusplus +}; +#endif + +IFDE_CSSSyntaxParser* IFDE_CSSSyntaxParser::Create() { + return new CFDE_CSSSyntaxParser; +} +CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser() + : m_pStream(NULL), + m_iStreamPos(0), + m_iPlaneSize(0), + m_iTextDatLen(0), + m_dwCheck((FX_DWORD)-1), + m_eMode(FDE_CSSSYNTAXMODE_RuleSet), + m_eStatus(FDE_CSSSYNTAXSTATUS_None) {} +CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() { + m_TextData.Reset(); + m_TextPlane.Reset(); +} +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); + Reset(bOnlyDeclaration); + if (!m_TextData.EstimateSize(iTextDataSize)) { + return FALSE; + } + uint8_t bom[4]; + m_pStream = pStream; + m_iStreamPos = m_pStream->GetBOM(bom); + m_iPlaneSize = iCSSPlaneSize; + return TRUE; +} +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); + Reset(bOnlyDeclaration); + if (!m_TextData.EstimateSize(iTextDatSize)) { + return FALSE; + } + return m_TextPlane.AttachBuffer(pBuffer, iBufferSize); +} +void CFDE_CSSSyntaxParser::Reset(FX_BOOL bOnlyDeclaration) { + m_TextPlane.Reset(); + m_TextData.Reset(); + m_pStream = NULL; + m_iStreamPos = 0; + m_iTextDatLen = 0; + m_dwCheck = (FX_DWORD)-1; + m_eStatus = FDE_CSSSYNTAXSTATUS_None; + m_eMode = bOnlyDeclaration ? FDE_CSSSYNTAXMODE_PropertyName + : FDE_CSSSYNTAXMODE_RuleSet; +} +FDE_CSSSYNTAXSTATUS CFDE_CSSSyntaxParser::DoSyntaxParse() { + while (m_eStatus >= FDE_CSSSYNTAXSTATUS_None) { + if (m_TextPlane.IsEOF()) { + if (m_pStream == NULL) { + if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue && + m_TextData.GetLength() > 0) { + SaveTextData(); + return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue; + } + return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS; + } + FX_BOOL bEOS; + int32_t iLen = m_TextPlane.LoadFromStream(m_pStream, m_iStreamPos, + m_iPlaneSize, bEOS); + m_iStreamPos = m_pStream->GetPosition(); + if (iLen < 1) { + if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue && + m_TextData.GetLength() > 0) { + SaveTextData(); + return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue; + } + return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS; + } + } + FX_WCHAR wch; + while (!m_TextPlane.IsEOF()) { + wch = m_TextPlane.GetChar(); + switch (m_eMode) { + case FDE_CSSSYNTAXMODE_RuleSet: + switch (wch) { + case '@': + m_TextPlane.MoveNext(); + SwitchMode(FDE_CSSSYNTAXMODE_AtRule); + break; + case '}': + m_TextPlane.MoveNext(); + if (RestoreMode()) { + return FDE_CSSSYNTAXSTATUS_DeclClose; + } else { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + break; + case '/': + if (m_TextPlane.GetNextChar() == '*') { + m_ModeStack.Push(m_eMode); + SwitchMode(FDE_CSSSYNTAXMODE_Comment); + break; + } + default: + if (wch <= ' ') { + m_TextPlane.MoveNext(); + } else if (FDE_IsSelectorStart(wch)) { + SwitchMode(FDE_CSSSYNTAXMODE_Selector); + return FDE_CSSSYNTAXSTATUS_StyleRule; + } else { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + break; + } + break; + case FDE_CSSSYNTAXMODE_Selector: + switch (wch) { + case ',': + m_TextPlane.MoveNext(); + SwitchMode(FDE_CSSSYNTAXMODE_Selector); + if (m_iTextDatLen > 0) { + return FDE_CSSSYNTAXSTATUS_Selector; + } + break; + case '{': + if (m_TextData.GetLength() > 0) { + SaveTextData(); + return FDE_CSSSYNTAXSTATUS_Selector; + } else { + m_TextPlane.MoveNext(); + m_ModeStack.Push(FDE_CSSSYNTAXMODE_RuleSet); + SwitchMode(FDE_CSSSYNTAXMODE_PropertyName); + return FDE_CSSSYNTAXSTATUS_DeclOpen; + } + break; + case '/': + if (m_TextPlane.GetNextChar() == '*') { + if (SwitchToComment() > 0) { + return FDE_CSSSYNTAXSTATUS_Selector; + } + break; + } + default: + AppendChar(wch); + break; + } + break; + case FDE_CSSSYNTAXMODE_PropertyName: + switch (wch) { + case ':': + m_TextPlane.MoveNext(); + SwitchMode(FDE_CSSSYNTAXMODE_PropertyValue); + return FDE_CSSSYNTAXSTATUS_PropertyName; + case '}': + m_TextPlane.MoveNext(); + if (RestoreMode()) { + return FDE_CSSSYNTAXSTATUS_DeclClose; + } else { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + break; + case '/': + if (m_TextPlane.GetNextChar() == '*') { + if (SwitchToComment() > 0) { + return FDE_CSSSYNTAXSTATUS_PropertyName; + } + break; + } + default: + AppendChar(wch); + break; + } + break; + case FDE_CSSSYNTAXMODE_PropertyValue: + switch (wch) { + case ';': + m_TextPlane.MoveNext(); + case '}': + SwitchMode(FDE_CSSSYNTAXMODE_PropertyName); + return FDE_CSSSYNTAXSTATUS_PropertyValue; + case '/': + if (m_TextPlane.GetNextChar() == '*') { + if (SwitchToComment() > 0) { + return FDE_CSSSYNTAXSTATUS_PropertyValue; + } + break; + } + default: + AppendChar(wch); + break; + } + break; + case FDE_CSSSYNTAXMODE_Comment: + if (wch == '/' && m_TextData.GetLength() > 0 && + m_TextData.GetAt(m_TextData.GetLength() - 1) == '*') { + RestoreMode(); + } else { + m_TextData.AppendChar(wch); + } + m_TextPlane.MoveNext(); + break; + case FDE_CSSSYNTAXMODE_MediaType: + switch (wch) { + case ',': + m_TextPlane.MoveNext(); + SwitchMode(FDE_CSSSYNTAXMODE_MediaType); + if (m_iTextDatLen > 0) { + return FDE_CSSSYNTAXSTATUS_MediaType; + } + break; + case '{': { + FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); + if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_MediaRule) { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + if (m_TextData.GetLength() > 0) { + SaveTextData(); + return FDE_CSSSYNTAXSTATUS_MediaType; + } else { + m_TextPlane.MoveNext(); + *pMode = FDE_CSSSYNTAXMODE_RuleSet; + SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); + return FDE_CSSSYNTAXSTATUS_DeclOpen; + } + } break; + case ';': { + FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); + if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + if (m_TextData.GetLength() > 0) { + SaveTextData(); + if (IsImportEnabled()) { + return FDE_CSSSYNTAXSTATUS_MediaType; + } + } else { + FX_BOOL bEnabled = IsImportEnabled(); + m_TextPlane.MoveNext(); + m_ModeStack.Pop(); + SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); + if (bEnabled) { + DisableImport(); + return FDE_CSSSYNTAXSTATUS_ImportClose; + } + } + } break; + case '/': + if (m_TextPlane.GetNextChar() == '*') { + if (SwitchToComment() > 0) { + return FDE_CSSSYNTAXSTATUS_MediaType; + } + break; + } + default: + AppendChar(wch); + break; + } + break; + case FDE_CSSSYNTAXMODE_URI: { + FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); + if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) { + return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; + } + if (wch <= ' ' || wch == ';') { + int32_t iURIStart, iURILength = m_TextData.GetLength(); + if (iURILength > 0 && + FDE_ParseCSSURI(m_TextData.GetBuffer(), iURILength, iURIStart, + iURILength)) { + m_TextData.Subtract(iURIStart, iURILength); + SwitchMode(FDE_CSSSYNTAXMODE_MediaType); + if (IsImportEnabled()) { + return FDE_CSSSYNTAXSTATUS_URI; + } else { + break; + } + } + } + AppendChar(wch); + } break; + case FDE_CSSSYNTAXMODE_AtRule: + if (wch > ' ') { + AppendChar(wch); + } else { + int32_t iLen = m_TextData.GetLength(); + const FX_WCHAR* psz = m_TextData.GetBuffer(); + if (FXSYS_wcsncmp(L"charset", psz, iLen) == 0) { + SwitchMode(FDE_CSSSYNTAXMODE_Charset); + } else if (FXSYS_wcsncmp(L"import", psz, iLen) == 0) { + m_ModeStack.Push(FDE_CSSSYNTAXMODE_Import); + SwitchMode(FDE_CSSSYNTAXMODE_URI); + if (IsImportEnabled()) { + return FDE_CSSSYNTAXSTATUS_ImportRule; + } else { + break; + } + } else if (FXSYS_wcsncmp(L"media", psz, iLen) == 0) { + m_ModeStack.Push(FDE_CSSSYNTAXMODE_MediaRule); + SwitchMode(FDE_CSSSYNTAXMODE_MediaType); + return FDE_CSSSYNTAXSTATUS_MediaRule; + } else if (FXSYS_wcsncmp(L"font-face", psz, iLen) == 0) { + SwitchMode(FDE_CSSSYNTAXMODE_Selector); + return FDE_CSSSYNTAXSTATUS_FontFaceRule; + } else if (FXSYS_wcsncmp(L"page", psz, iLen) == 0) { + SwitchMode(FDE_CSSSYNTAXMODE_Selector); + return FDE_CSSSYNTAXSTATUS_PageRule; + } else { + SwitchMode(FDE_CSSSYNTAXMODE_UnknownRule); + } + } + break; + case FDE_CSSSYNTAXMODE_Charset: + if (wch == ';') { + m_TextPlane.MoveNext(); + SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); + if (IsCharsetEnabled()) { + DisableCharset(); + if (m_iTextDatLen > 0) { + if (m_pStream != NULL) { + FX_WORD wCodePage = FX_GetCodePageFormStringW( + m_TextData.GetBuffer(), m_iTextDatLen); + if (wCodePage < 0xFFFF && + m_pStream->GetCodePage() != wCodePage) { + m_pStream->SetCodePage(wCodePage); + } + } + return FDE_CSSSYNTAXSTATUS_Charset; + } + } + } else { + AppendChar(wch); + } + break; + case FDE_CSSSYNTAXMODE_UnknownRule: + if (wch == ';') { + SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); + } + m_TextPlane.MoveNext(); + break; + default: + FXSYS_assert(FALSE); + break; + } + } + } + return m_eStatus; +} +FX_BOOL CFDE_CSSSyntaxParser::IsImportEnabled() const { + if ((m_dwCheck & FDE_CSSSYNTAXCHECK_AllowImport) == 0) { + return FALSE; + } + if (m_ModeStack.GetSize() > 1) { + return FALSE; + } + return TRUE; +} +inline FX_BOOL CFDE_CSSSyntaxParser::AppendChar(FX_WCHAR wch) { + m_TextPlane.MoveNext(); + if (m_TextData.GetLength() > 0 || wch > ' ') { + m_TextData.AppendChar(wch); + return TRUE; + } + return FALSE; +} +inline int32_t CFDE_CSSSyntaxParser::SaveTextData() { + m_iTextDatLen = m_TextData.TrimEnd(); + m_TextData.Clear(); + return m_iTextDatLen; +} +inline void CFDE_CSSSyntaxParser::SwitchMode(FDE_CSSSYNTAXMODE eMode) { + m_eMode = eMode; + SaveTextData(); +} +inline int32_t CFDE_CSSSyntaxParser::SwitchToComment() { + int32_t iLength = m_TextData.GetLength(); + m_ModeStack.Push(m_eMode); + SwitchMode(FDE_CSSSYNTAXMODE_Comment); + return iLength; +} +inline FX_BOOL CFDE_CSSSyntaxParser::RestoreMode() { + FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); + if (pMode == NULL) { + return FALSE; + } + SwitchMode(*pMode); + m_ModeStack.Pop(); + return TRUE; +} +const FX_WCHAR* CFDE_CSSSyntaxParser::GetCurrentString(int32_t& iLength) const { + iLength = m_iTextDatLen; + return m_TextData.GetBuffer(); +} +CFDE_CSSTextBuf::CFDE_CSSTextBuf() + : m_bExtBuf(FALSE), + m_pBuffer(NULL), + m_iBufLen(0), + m_iDatLen(0), + m_iDatPos(0) {} +CFDE_CSSTextBuf::~CFDE_CSSTextBuf() { + Reset(); +} +void CFDE_CSSTextBuf::Reset() { + if (!m_bExtBuf) { + FX_Free(m_pBuffer); + m_pBuffer = NULL; + } + m_iDatPos = m_iDatLen = m_iBufLen; +} +FX_BOOL CFDE_CSSTextBuf::AttachBuffer(const FX_WCHAR* pBuffer, + int32_t iBufLen) { + Reset(); + m_pBuffer = (FX_WCHAR*)pBuffer; + m_iDatLen = m_iBufLen = iBufLen; + return m_bExtBuf = TRUE; +} +FX_BOOL CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) { + FXSYS_assert(iAllocSize > 0); + Clear(); + m_bExtBuf = FALSE; + return ExpandBuf(iAllocSize); +} +int32_t CFDE_CSSTextBuf::LoadFromStream(IFX_Stream* pTxtStream, + int32_t iStreamOffset, + int32_t iMaxChars, + FX_BOOL& bEOS) { + FXSYS_assert(iStreamOffset >= 0 && iMaxChars > 0); + Clear(); + m_bExtBuf = FALSE; + if (!ExpandBuf(iMaxChars)) { + return 0; + } + if (pTxtStream->GetPosition() != iStreamOffset) { + pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset); + } + m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS); + return m_iDatLen; +} +FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) { + if (m_bExtBuf) { + return FALSE; + } + if (!m_pBuffer) { + m_pBuffer = FX_Alloc(FX_WCHAR, iDesiredSize); + } else if (m_iBufLen != iDesiredSize) { + m_pBuffer = FX_Realloc(FX_WCHAR, m_pBuffer, iDesiredSize); + } else { + return TRUE; + } + if (!m_pBuffer) { + m_iBufLen = 0; + return FALSE; + } + m_iBufLen = iDesiredSize; + return TRUE; +} +void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) { + FXSYS_assert(iStart >= 0 && iLength > 0); + if (iLength > m_iDatLen - iStart) { + iLength = m_iDatLen - iStart; + } + if (iLength < 0) { + iLength = 0; + } else { + FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR)); + } + m_iDatLen = iLength; +} diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h new file mode 100644 index 0000000000..a25ab3badd --- /dev/null +++ b/xfa/fde/css/fde_csssyntax.h @@ -0,0 +1,119 @@ +// 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_CSS_FDE_CSSSYNTAX_H_ +#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_ + +#include "xfa/fde/css/fde_css.h" +#include "xfa/fgas/crt/fgas_memory.h" +#include "xfa/fgas/crt/fgas_stream.h" + +class CFDE_CSSTextBuf : public CFX_Target { + public: + CFDE_CSSTextBuf(); + ~CFDE_CSSTextBuf(); + FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen); + FX_BOOL EstimateSize(int32_t iAllocSize); + int32_t LoadFromStream(IFX_Stream* pTxtStream, + int32_t iStreamOffset, + int32_t iMaxChars, + FX_BOOL& bEOS); + FX_BOOL AppendChar(FX_WCHAR wch) { + if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2)) { + return FALSE; + } + return (m_pBuffer[m_iDatLen++] = wch), TRUE; + } + void Clear() { m_iDatPos = m_iDatLen = 0; } + void Reset(); + int32_t TrimEnd() { + while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') { + --m_iDatLen; + } + AppendChar(0); + return --m_iDatLen; + } + void Subtract(int32_t iStart, int32_t iLength); + FX_BOOL IsEOF() const { return m_iDatPos >= m_iDatLen; } + FX_WCHAR GetAt(int32_t index) const { return m_pBuffer[index]; } + FX_WCHAR GetChar() const { return m_pBuffer[m_iDatPos]; } + FX_WCHAR GetNextChar() const { + return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pBuffer[m_iDatPos + 1]; + } + void MoveNext() { m_iDatPos++; } + int32_t GetLength() const { return m_iDatLen; } + const FX_WCHAR* GetBuffer() const { return m_pBuffer; } + + protected: + FX_BOOL ExpandBuf(int32_t iDesiredSize); + FX_BOOL m_bExtBuf; + FX_WCHAR* m_pBuffer; + int32_t m_iBufLen; + int32_t m_iDatLen; + int32_t m_iDatPos; +}; + +#define FDE_CSSSYNTAXCHECK_AllowCharset 1 +#define FDE_CSSSYNTAXCHECK_AllowImport 2 + +enum FDE_CSSSYNTAXMODE { + FDE_CSSSYNTAXMODE_RuleSet, + FDE_CSSSYNTAXMODE_Comment, + FDE_CSSSYNTAXMODE_AtRule, + FDE_CSSSYNTAXMODE_UnknownRule, + FDE_CSSSYNTAXMODE_Charset, + FDE_CSSSYNTAXMODE_Import, + FDE_CSSSYNTAXMODE_MediaRule, + FDE_CSSSYNTAXMODE_URI, + FDE_CSSSYNTAXMODE_MediaType, + FDE_CSSSYNTAXMODE_Selector, + FDE_CSSSYNTAXMODE_PropertyName, + FDE_CSSSYNTAXMODE_PropertyValue, +}; + +class CFDE_CSSSyntaxParser : public IFDE_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; + + protected: + void Reset(FX_BOOL bOnlyDeclaration); + void SwitchMode(FDE_CSSSYNTAXMODE eMode); + int32_t SwitchToComment(); + + FX_BOOL RestoreMode(); + FX_BOOL AppendChar(FX_WCHAR wch); + int32_t SaveTextData(); + FX_BOOL IsCharsetEnabled() const { + return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0; + } + 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; + CFDE_CSSTextBuf m_TextData; + CFDE_CSSTextBuf m_TextPlane; + int32_t m_iTextDatLen; + FX_DWORD m_dwCheck; + FDE_CSSSYNTAXMODE m_eMode; + FDE_CSSSYNTAXSTATUS m_eStatus; + CFX_StackTemplate<FDE_CSSSYNTAXMODE> m_ModeStack; +}; + +#endif // XFA_FDE_CSS_FDE_CSSSYNTAX_H_ diff --git a/xfa/fde/fde_brush.h b/xfa/fde/fde_brush.h new file mode 100644 index 0000000000..898ea01e46 --- /dev/null +++ b/xfa/fde/fde_brush.h @@ -0,0 +1,150 @@ +// 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/include/fxcrt/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/xfa/fde/fde_devbasic.cpp b/xfa/fde/fde_devbasic.cpp new file mode 100644 index 0000000000..c85b125f73 --- /dev/null +++ b/xfa/fde/fde_devbasic.cpp @@ -0,0 +1,550 @@ +// 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/xfa/fde/fde_devbasic.h b/xfa/fde/fde_devbasic.h new file mode 100644 index 0000000000..9c9b25dd3e --- /dev/null +++ b/xfa/fde/fde_devbasic.h @@ -0,0 +1,20 @@ +// 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/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp new file mode 100644 index 0000000000..ab62999118 --- /dev/null +++ b/xfa/fde/fde_gedevice.cpp @@ -0,0 +1,573 @@ +// 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_gedevice.h" + +#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" + +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) + : m_pDevice(pDevice), + m_bOwnerDevice(bOwnerDevice), + m_pCharPos(NULL), + m_iCharCount(0) { + FXSYS_assert(pDevice != NULL); + 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() { + FX_Free(m_pCharPos); + if (m_bOwnerDevice) + delete m_pDevice; +} +int32_t CFDE_FxgeDevice::GetWidth() const { + return m_pDevice->GetWidth(); +} +int32_t CFDE_FxgeDevice::GetHeight() const { + return m_pDevice->GetHeight(); +} +FDE_HDEVICESTATE CFDE_FxgeDevice::SaveState() { + m_pDevice->SaveState(); + return NULL; +} +void CFDE_FxgeDevice::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) { + 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() { + return m_rtClip; +} +FX_BOOL CFDE_FxgeDevice::SetClipPath(const IFDE_Path* pClip) { + return FALSE; +} +IFDE_Path* CFDE_FxgeDevice::GetClipPath() const { + return NULL; +} +FX_FLOAT CFDE_FxgeDevice::GetDpiX() const { + return 96; +} +FX_FLOAT CFDE_FxgeDevice::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); + CFX_RectF srcRect; + if (pSrcRect) { + srcRect = *pSrcRect; + } else { + srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); + } + if (srcRect.IsEmpty()) { + return FALSE; + } + CFX_Matrix dib2fxdev; + if (pImgMatrix) { + dib2fxdev = *pImgMatrix; + } else { + dib2fxdev.SetIdentity(); + } + dib2fxdev.a = dstRect.width; + dib2fxdev.d = -dstRect.height; + dib2fxdev.e = dstRect.left; + dib2fxdev.f = dstRect.bottom(); + if (pDevMatrix) { + dib2fxdev.Concat(*pDevMatrix); + } + void* handle = NULL; + m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, + handle); + while (m_pDevice->ContinueDIBits(handle, NULL)) { + } + 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); + 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_ + FX_DWORD 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(); +#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); +#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.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_ + } +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + FxFont.SetSubstFont(nullptr); + FxFont.SetFace(nullptr); +#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + return TRUE; + } break; + default: + return FALSE; + } +} +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) { + CFX_PointsF points; + points.Add(pt1); + points.Add(pt2); + points.Add(pt3); + points.Add(pt4); + CFDE_Path path; + 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) { + 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) { + 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) { + 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) { + 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) { + CFDE_Path* pGePath = (CFDE_Path*)pPath; + if (pGePath == NULL) { + return FALSE; + } + CFX_GraphStateData graphState; + if (!CreatePen(pPen, fPenWidth, graphState)) { + return FALSE; + } + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + return FALSE; + } + graphState.m_LineCap = (CFX_GraphStateData::LineCap)pPen->GetLineCap(); + graphState.m_LineJoin = (CFX_GraphStateData::LineJoin)pPen->GetLineJoin(); + 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; + } + } + 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) { + 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) { + return FALSE; + } + CFX_DIBitmap mask; + if (!FDE_GetStockHatchMask(iStyle, mask)) { + 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; +} +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/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h new file mode 100644 index 0000000000..68467395e6 --- /dev/null +++ b/xfa/fde/fde_gedevice.h @@ -0,0 +1,136 @@ +// 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_GEDEVICE_H_ +#define XFA_FDE_FDE_GEDEVICE_H_ + +#include "xfa/fde/fde_renderdevice.h" +#include "xfa/fgas/crt/fgas_memory.h" + +class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target { + public: + CFDE_FxgeDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice); + ~CFDE_FxgeDevice(); + virtual void Release() { delete this; } + + 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(); + + virtual FX_FLOAT GetDpiX() const; + virtual 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, + IFX_Font* pFont, + const FXTEXT_CHARPOS* pCharPos, + int32_t iCount, + FX_FLOAT fFontSize, + const CFX_Matrix* pMatrix); + FX_BOOL DrawStringPath(IFDE_Brush* pBrush, + IFX_Font* pFont, + const FXTEXT_CHARPOS* pCharPos, + int32_t iCount, + FX_FLOAT fFontSize, + const CFX_Matrix* pMatrix); + + protected: + FX_BOOL CreatePen(IFDE_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; + FXTEXT_CHARPOS* m_pCharPos; + int32_t m_iCharCount; +}; + +#endif // XFA_FDE_FDE_GEDEVICE_H_ diff --git a/xfa/fde/fde_geobject.cpp b/xfa/fde/fde_geobject.cpp new file mode 100644 index 0000000000..f4aede0ee4 --- /dev/null +++ b/xfa/fde/fde_geobject.cpp @@ -0,0 +1,255 @@ +// 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_geobject.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) { + pPoint->m_Flag |= FXPT_CLOSEFIGURE; + } + return TRUE; +} +FX_PATHPOINT* CFDE_Path::GetLastPoint(int32_t iCount) const { + if (iCount < 1) { + return NULL; + } + int32_t iPoints = m_Path.GetPointCount(); + if (iCount > iPoints) { + return NULL; + } + 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; + } + 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) { + FX_PATHPOINT* p = AddPoints(3); + p[0].m_PointX = p1.x; + p[0].m_PointY = p1.y; + p[0].m_Flag = FXPT_BEZIERTO; + p[1].m_PointX = p2.x; + p[1].m_PointY = p2.y; + p[1].m_Flag = FXPT_BEZIERTO; + p[2].m_PointX = p3.x; + 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, + FX_FLOAT endAngle) { + FX_FLOAT rx = rect.width / 2; + FX_FLOAT ry = rect.height / 2; + FX_FLOAT cx = rect.left + rx; + FX_FLOAT cy = rect.top + ry; + FX_FLOAT alpha = + FXSYS_atan2(rx * FXSYS_sin(startAngle), ry * FXSYS_cos(startAngle)); + FX_FLOAT beta = + FXSYS_atan2(rx * FXSYS_sin(endAngle), ry * FXSYS_cos(endAngle)); + if (FXSYS_fabs(beta - alpha) > FX_PI) { + if (beta > alpha) { + beta -= 2 * FX_PI; + } 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); + FX_FLOAT sin_alpha = FXSYS_sin(alpha); + FX_FLOAT sin_beta = FXSYS_sin(beta); + FX_FLOAT cos_alpha = FXSYS_cos(alpha); + FX_FLOAT cos_beta = FXSYS_cos(beta); + if (bStart) + MoveTo(CFX_PointF(cx + rx * cos_alpha, cy + ry * sin_alpha)); + + BezierTo(CFX_PointF(cx + rx * (cos_alpha - bcp * sin_alpha), + cy + ry * (sin_alpha + bcp * cos_alpha)), + CFX_PointF(cx + rx * (cos_beta + bcp * sin_beta), + cy + ry * (sin_beta - bcp * cos_beta)), + CFX_PointF(cx + rx * cos_beta, cy + ry * sin_beta)); +} + +void CFDE_Path::AddBezier(const CFX_PointsF& points) { + 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) { + return; + } + const CFX_PointF* p = points.GetData(); + const CFX_PointF* pEnd = p + iCount; + MoveTo(p[0]); + 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) { + 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) { + r = bClosed ? (r - iCount) : (iCount - 1); + } + 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) { + return; + } + CFX_PointsF tangents; + GetCurveTangents(points, tangents, bClosed, fTension); + const CFX_PointF* pPoints = points.GetData(); + CFX_PointF* pTangents = tangents.GetData(); + MoveTo(pPoints[0]); + for (int32_t i = 0; i < iLast; ++i) { + BezierTo(CFX_PointF(pPoints[i].x + pTangents[i].x, + pPoints[i].y + pTangents[i].y), + CFX_PointF(pPoints[i + 1].x - pTangents[i + 1].x, + pPoints[i + 1].y - pTangents[i + 1].y), + CFX_PointF(pPoints[i + 1].x, pPoints[i + 1].y)); + } + if (bClosed) { + BezierTo(CFX_PointF(pPoints[iLast].x + pTangents[iLast].x, + pPoints[iLast].y + pTangents[iLast].y), + CFX_PointF(pPoints[0].x - pTangents[0].x, + pPoints[0].y - pTangents[0].y), + CFX_PointF(pPoints[0].x, pPoints[0].y)); + CloseFigure(); + } +} +void CFDE_Path::AddEllipse(const CFX_RectF& rect) { + FX_FLOAT fStartAngle = 0; + FX_FLOAT fEndAngle = FX_PI / 2; + for (int32_t i = 0; i < 4; ++i) { + ArcTo(i == 0, rect, fStartAngle, fEndAngle); + fStartAngle += FX_PI / 2; + fEndAngle += FX_PI / 2; + } + 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 || + FXSYS_fabs(pLast->m_PointY - pt1.y) > 0.001) { + MoveTo(pt1); + } + LineTo(pt2); +} +void CFDE_Path::AddPath(const IFDE_Path* pSrc, FX_BOOL bConnect) { + CFDE_Path* pPath = (CFDE_Path*)pSrc; + if (pPath == NULL) { + return; + } + int32_t iCount = pPath->m_Path.GetPointCount(); + if (iCount < 1) { + return; + } + if (bConnect) { + LineTo(pPath->m_Path.GetPointX(0), pPath->m_Path.GetPointY(0)); + } + m_Path.Append(&pPath->m_Path, NULL); +} +void CFDE_Path::AddPolygon(const CFX_PointsF& points) { + int32_t iCount = points.GetSize(); + if (iCount < 2) { + return; + } + AddLines(points); + const CFX_PointF* p = points.GetData(); + if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f || + FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) { + LineTo(p[0]); + } + CloseFigure(); +} +void CFDE_Path::AddLines(const CFX_PointsF& points) { + int32_t iCount = points.GetSize(); + if (iCount < 2) { + return; + } + const CFX_PointF* p = points.GetData(); + const CFX_PointF* pEnd = p + iCount; + MoveTo(p[0]); + for (++p; p < pEnd; ++p) { + LineTo(*p); + } +} +void CFDE_Path::AddRectangle(const CFX_RectF& rect) { + MoveTo(rect.TopLeft()); + LineTo(rect.TopRight()); + LineTo(rect.BottomRight()); + 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 { + CFX_FloatRect rect = m_Path.GetBoundingBox(fLineWidth, fMiterLimit); + bbox.Set(rect.left, rect.top, rect.Width(), rect.Height()); + bbox.Normalize(); +} diff --git a/xfa/fde/fde_geobject.h b/xfa/fde/fde_geobject.h new file mode 100644 index 0000000000..11819154ab --- /dev/null +++ b/xfa/fde/fde_geobject.h @@ -0,0 +1,57 @@ +// 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/xfa/fde/fde_image.h b/xfa/fde/fde_image.h new file mode 100644 index 0000000000..011f232370 --- /dev/null +++ b/xfa/fde/fde_image.h @@ -0,0 +1,42 @@ +// 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/xfa/fde/fde_iterator.cpp b/xfa/fde/fde_iterator.cpp new file mode 100644 index 0000000000..50018b7942 --- /dev/null +++ b/xfa/fde/fde_iterator.cpp @@ -0,0 +1,98 @@ +// 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_iterator.h" + +#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); + m_CanvasStack.RemoveAll(); + FDE_CANVASITEM canvas; + canvas.hCanvas = NULL; + canvas.pCanvas = pCanvas; + canvas.hPos = pCanvas->GetFirstPosition(NULL); + if (canvas.hPos == NULL) { + return FALSE; + } + return m_CanvasStack.Push(canvas) == 0; +} +FX_BOOL CFDE_VisualSetIterator::FilterObjects(FX_DWORD dwObjects) { + if (m_CanvasStack.GetSize() == 0) { + return FALSE; + } + while (m_CanvasStack.GetSize() > 1) { + m_CanvasStack.Pop(); + } + m_dwFilter = dwObjects & ~(FX_DWORD)FDE_VISUALOBJ_Widget; + if (dwObjects & FDE_VISUALOBJ_Widget) { + m_dwFilter |= 0xFF00; + } + FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement(); + FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL); + pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(NULL); + return pCanvas->hPos != NULL; +} +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) { + break; + } + m_CanvasStack.Pop(); + continue; + } + do { + FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext( + pCanvas->hCanvas, pCanvas->hPos, pVisualSet); + FXSYS_assert(hObj != NULL); + FDE_VISUALOBJTYPE eType = pVisualSet->GetType(); + if (eType == FDE_VISUALOBJ_Canvas) { + FDE_CANVASITEM canvas; + canvas.hCanvas = hObj; + canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet; + canvas.hPos = canvas.pCanvas->GetFirstPosition(hObj); + m_CanvasStack.Push(canvas); + break; + } + FX_DWORD dwObj = + (eType == FDE_VISUALOBJ_Widget) + ? (FX_DWORD)((IFDE_WidgetSet*)pVisualSet)->GetWidgetType(hObj) + : (FX_DWORD)eType; + if ((m_dwFilter & dwObj) != 0) { + if (ppCanvasSet) { + *ppCanvasSet = pCanvas->pCanvas; + } + if (phCanvasObj) { + *phCanvasObj = pCanvas->hCanvas; + } + return hObj; + } + } while (pCanvas->hPos != NULL); + } + if (ppCanvasSet) { + *ppCanvasSet = NULL; + } + if (phCanvasObj) { + *phCanvasObj = NULL; + } + pVisualSet = NULL; + return NULL; +} diff --git a/xfa/fde/fde_iterator.h b/xfa/fde/fde_iterator.h new file mode 100644 index 0000000000..6be6c4c0a5 --- /dev/null +++ b/xfa/fde/fde_iterator.h @@ -0,0 +1,39 @@ +// 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_ITERATOR_H_ +#define XFA_FDE_FDE_ITERATOR_H_ + +#include "xfa/fde/fde_visualset.h" +#include "xfa/fgas/crt/fgas_memory.h" + +struct FDE_CANVASITEM { + IFDE_CanvasSet* pCanvas; + FDE_HVISUALOBJ hCanvas; + FX_POSITION hPos; +}; + +class CFDE_VisualSetIterator : public IFDE_VisualSetIterator, + public CFX_Target { + public: + CFDE_VisualSetIterator(); + ~CFDE_VisualSetIterator(); + virtual void Release() { delete this; } + + virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas); + virtual FX_BOOL FilterObjects(FX_DWORD dwObjects = 0xFFFFFFFF); + + virtual void Reset(); + virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet, + FDE_HVISUALOBJ* phCanvasObj = NULL, + IFDE_CanvasSet** ppCanvasSet = NULL); + + protected: + FX_DWORD m_dwFilter; + CFX_StackTemplate<FDE_CANVASITEM> m_CanvasStack; +}; + +#endif // XFA_FDE_FDE_ITERATOR_H_ diff --git a/xfa/fde/fde_object.cpp b/xfa/fde/fde_object.cpp new file mode 100644 index 0000000000..92b9f8af1f --- /dev/null +++ b/xfa/fde/fde_object.cpp @@ -0,0 +1,25 @@ +// 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/xfa/fde/fde_object.h b/xfa/fde/fde_object.h new file mode 100644 index 0000000000..ae7b95aa32 --- /dev/null +++ b/xfa/fde/fde_object.h @@ -0,0 +1,246 @@ +// 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_OBJECT_H_ +#define XFA_FDE_FDE_OBJECT_H_ + +#include <cstdint> + +#include "core/include/fxge/fx_dib.h" +#include "xfa/fde/fde_brush.h" +#include "xfa/fde/fde_pen.h" +#include "xfa/fgas/crt/fgas_memory.h" + +class CFDE_Pen : public IFDE_Pen, 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_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 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 { + public: + CFDE_TextureBrush() : m_iWrap(0), m_pImage(NULL), m_bAutoRelease(FALSE) { + m_Matrix.SetIdentity(); + } + + 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; + } + + 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; +}; + +#endif // XFA_FDE_FDE_OBJECT_H_ diff --git a/xfa/fde/fde_path.h b/xfa/fde/fde_path.h new file mode 100644 index 0000000000..9ffba6c199 --- /dev/null +++ b/xfa/fde/fde_path.h @@ -0,0 +1,37 @@ +// 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/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/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/xfa/fde/fde_pen.h b/xfa/fde/fde_pen.h new file mode 100644 index 0000000000..4dfdd8ac22 --- /dev/null +++ b/xfa/fde/fde_pen.h @@ -0,0 +1,70 @@ +// 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/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp new file mode 100644 index 0000000000..7d86a7b53e --- /dev/null +++ b/xfa/fde/fde_render.cpp @@ -0,0 +1,290 @@ +// 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_render.h" + +#include "xfa/fde/fde_renderdevice.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, + FX_DWORD 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_Transform(), + m_pCharPos(NULL), + m_iCharPosCount(0), + m_pIterator(NULL) { + m_Transform.SetIdentity(); +} +CFDE_RenderContext::~CFDE_RenderContext() { + StopRender(); +} +FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice, + IFDE_CanvasSet* pCanvasSet, + const CFX_Matrix& tmDoc2Device) { + if (m_pRenderDevice != NULL) { + return FALSE; + } + if (pRenderDevice == NULL) { + return FALSE; + } + if (pCanvasSet == NULL) { + 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); + } + return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); +} +FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { + if (m_pRenderDevice == NULL) { + return FDE_RENDERSTATUS_Failed; + } + if (m_pIterator == NULL) { + return FDE_RENDERSTATUS_Failed; + } + FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused; + CFX_Matrix rm; + rm.SetReverse(m_Transform); + CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect(); + if (rtDocClip.IsEmpty()) { + rtDocClip.left = rtDocClip.top = 0; + rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth(); + rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight(); + } + rm.TransformRect(rtDocClip); + IFDE_VisualSet* pVisualSet; + FDE_HVISUALOBJ hVisualObj; + CFX_RectF rtObj; + int32_t iCount = 0; + while (TRUE) { + hVisualObj = m_pIterator->GetNext(pVisualSet); + if (hVisualObj == NULL || pVisualSet == NULL) { + eStatus = FDE_RENDERSTATUS_Done; + break; + } + rtObj.Empty(); + pVisualSet->GetRect(hVisualObj, 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); + break; + default: + break; + } + if (iCount >= 100 && pPause != NULL && 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; + } + 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); + IFX_Font* pFont = pTextSet->GetFont(hText); + if (pFont == NULL) { + return; + } + int32_t iCount = pTextSet->GetDisplayPos(hText, NULL, 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) { + m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount); + } else if (m_iCharPosCount < iCount) { + m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, 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); + FDE_HDEVICESTATE hState; + FX_BOOL bClip = ApplyClip(pTextSet, hText, hState); + m_pRenderDevice->DrawString(m_pSolidBrush, pFont, m_pCharPos, iCount, + fFontSize, &m_Transform); + 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)) { + return FALSE; + } + CFX_RectF rtObj; + pVisualSet->GetRect(hObj, rtObj); + rtClip.Offset(rtObj.left, rtObj.top); + m_Transform.TransformRect(rtClip); + const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect(); + rtClip.Intersect(rtDevClip); + hState = m_pRenderDevice->SaveState(); + return m_pRenderDevice->SetClipRect(rtClip); +} +void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) { + m_pRenderDevice->RestoreState(hState); +} diff --git a/xfa/fde/fde_render.h b/xfa/fde/fde_render.h new file mode 100644 index 0000000000..2cf7e5cf92 --- /dev/null +++ b/xfa/fde/fde_render.h @@ -0,0 +1,40 @@ +// 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_RENDER_H_ +#define XFA_FDE_FDE_RENDER_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "xfa/fde/fde_visualset.h" + +class IFDE_RenderDevice; + +void FDE_GetPageMatrix(CFX_Matrix& pageMatrix, + const CFX_RectF& docPageRect, + const CFX_Rect& devicePageRect, + int32_t iRotate, + FX_DWORD dwCoordinatesType = 0); +enum FDE_RENDERSTATUS { + FDE_RENDERSTATUS_Reset = 0, + FDE_RENDERSTATUS_Paused, + FDE_RENDERSTATUS_Done, + FDE_RENDERSTATUS_Failed, +}; + +class IFDE_RenderContext { + 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; +}; + +#endif // XFA_FDE_FDE_RENDER_H_ diff --git a/xfa/fde/fde_renderdevice.h b/xfa/fde/fde_renderdevice.h new file mode 100644 index 0000000000..a9e7190c54 --- /dev/null +++ b/xfa/fde/fde_renderdevice.h @@ -0,0 +1,110 @@ +// 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/include/fxcrt/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/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h new file mode 100644 index 0000000000..5da21fb842 --- /dev/null +++ b/xfa/fde/fde_visualset.h @@ -0,0 +1,123 @@ +// 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_VISUALSET_H_ +#define XFA_FDE_FDE_VISUALSET_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/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 "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, +}; + +typedef struct FDE_HVISUALOBJ_ { void* pData; } const* FDE_HVISUALOBJ; + +class IFDE_VisualSet { + public: + virtual ~IFDE_VisualSet() {} + virtual FDE_VISUALOBJTYPE GetType() = 0; + virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) = 0; + virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) = 0; + virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; + virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; +}; + +class IFDE_CanvasSet : public IFDE_VisualSet { + public: + virtual FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) = 0; + virtual FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas, + FX_POSITION& pos, + IFDE_VisualSet*& pVisualSet) = 0; + virtual FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas, + IFDE_VisualSet*& pVisualSet) = 0; +}; + +class IFDE_TextSet : public IFDE_VisualSet { + public: + virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) = 0; + virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText) = 0; + virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) = 0; + virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) = 0; + virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL) = 0; + virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, + 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(FX_DWORD 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/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp new file mode 100644 index 0000000000..2105cf09b0 --- /dev/null +++ b/xfa/fde/tto/fde_textout.cpp @@ -0,0 +1,1120 @@ +// 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/tto/fde_textout.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fde/fde_brush.h" +#include "xfa/fde/fde_pen.h" +#include "xfa/fde/fde_renderdevice.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; + FX_DWORD 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(FX_DWORD 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(FX_DWORD 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(FX_DWORD 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; + FX_DWORD m_dwStyles; + FX_DWORD 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), + m_fLineSpace(m_fFontSize), + m_fLinePos(0.0f), + m_fTolerance(0.0f), + m_iAlignment(0), + m_iTxtBkAlignment(0), + m_pCharWidths(NULL), + m_iChars(0), + m_pEllCharWidths(NULL), + m_iEllChars(0), + m_wParagraphBkChar(L'\n'), + m_TxtColor(0xFF000000), + m_dwStyles(0), + m_dwTxtBkStyles(0), + m_bElliChanged(FALSE), + m_iEllipsisWidth(0), + m_ttoLines(5), + m_iCurLine(0), + 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_Matrix.SetIdentity(); + m_rtClip.Reset(); + m_rtLogicClip.Reset(); +} +CFDE_TextOut::~CFDE_TextOut() { + if (m_pTxtBreak) { + m_pTxtBreak->Release(); + } + 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); + m_pFont = pFont; + m_pTxtBreak->SetFont(pFont); +} +void CFDE_TextOut::SetFontSize(FX_FLOAT fFontSize) { + FXSYS_assert(fFontSize > 0); + m_fFontSize = fFontSize; + m_pTxtBreak->SetFontSize(fFontSize); +} +void CFDE_TextOut::SetTextColor(FX_ARGB color) { + m_TxtColor = color; +} +void CFDE_TextOut::SetStyles(FX_DWORD dwStyles) { + m_dwStyles = dwStyles; + m_dwTxtBkStyles = 0; + if (dwStyles & FDE_TTOSTYLE_SingleLine) { + m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_SingleLine; + } + if (dwStyles & FDE_TTOSTYLE_ExpandTab) { + m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ExpandTab; + } + if (dwStyles & FDE_TTOSTYLE_ArabicShapes) { + m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ArabicShapes; + } + if (dwStyles & FDE_TTOSTYLE_RTL) { + m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_RTLReadingOrder; + } + if (dwStyles & FDE_TTOSTYLE_ArabicContext) { + m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ArabicContext; + } + if (dwStyles & FDE_TTOSTYLE_VerticalLayout) { + m_dwTxtBkStyles |= + (FX_TXTLAYOUTSTYLE_VerticalChars | FX_TXTLAYOUTSTYLE_VerticalLayout); + } + m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles); +} +void CFDE_TextOut::SetTabWidth(FX_FLOAT fTabWidth) { + FXSYS_assert(fTabWidth > 1.0f); + m_pTxtBreak->SetTabWidth(fTabWidth, FALSE); +} +void CFDE_TextOut::SetEllipsisString(const CFX_WideString& wsEllipsis) { + m_bElliChanged = TRUE; + m_wsEllipsis = wsEllipsis; +} +void CFDE_TextOut::SetParagraphBreakChar(FX_WCHAR wch) { + m_wParagraphBkChar = wch; + m_pTxtBreak->SetParagraphBreakChar(wch); +} +void CFDE_TextOut::SetAlignment(int32_t iAlignment) { + m_iAlignment = iAlignment; + switch (m_iAlignment) { + case FDE_TTOALIGNMENT_TopCenter: + case FDE_TTOALIGNMENT_Center: + case FDE_TTOALIGNMENT_BottomCenter: + m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Center; + break; + case FDE_TTOALIGNMENT_TopRight: + case FDE_TTOALIGNMENT_CenterRight: + case FDE_TTOALIGNMENT_BottomRight: + m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Right; + break; + default: + m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Left; + break; + } + m_pTxtBreak->SetAlignment(m_iTxtBkAlignment); +} +void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) { + FXSYS_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); +} +void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) { + FXSYS_assert(pDevice != NULL); + if (m_pRenderDevice != NULL) { + m_pRenderDevice->Release(); + } + m_pRenderDevice = IFDE_RenderDevice::Create(pDevice); +} +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()); +} +void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) { + m_rtClip = rtClip; +} +void CFDE_TextOut::SetLogicClipRect(const CFX_RectF& rtClip) { + m_rtLogicClip = rtClip; +} +void CFDE_TextOut::SetMatrix(const CFX_Matrix& matrix) { + m_Matrix = matrix; +} +void CFDE_TextOut::SetLineBreakTolerance(FX_FLOAT fTolerance) { + m_fTolerance = fTolerance; + m_pTxtBreak->SetLineBreakTolerance(m_fTolerance); +} +int32_t CFDE_TextOut::GetTotalLines() { + return m_iTotalLines; +} +void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_Size& size) { + CFX_RectF rtText; + rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y); + CalcSize(pwsStr, iLength, rtText); + size.x = (int32_t)rtText.Width(); + size.y = (int32_t)rtText.Height(); +} +void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_SizeF& size) { + CFX_RectF rtText; + rtText.Set(0.0f, 0.0f, size.x, size.y); + CalcSize(pwsStr, iLength, rtText); + size.x = rtText.Width(); + size.y = rtText.Height(); +} +void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_Rect& rect) { + CFX_RectF rtText; + rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(), + (FX_FLOAT)rect.Height()); + CalcSize(pwsStr, iLength, rtText); + rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(), + (int32_t)rtText.Height()); +} +void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_RectF& rect) { + if (pwsStr == NULL || iLength < 1) { + rect.width = 0.0f; + rect.height = 0.0f; + } else { + CFX_Matrix rm; + rm.SetReverse(m_Matrix); + rm.TransformRect(rect); + CalcTextSize(pwsStr, iLength, rect); + m_Matrix.TransformRect(rect); + } +} +void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_SizeF& size) { + CFX_RectF rtText; + rtText.Set(0.0f, 0.0f, size.x, size.y); + CalcLogicSize(pwsStr, iLength, rtText); + size.x = rtText.Width(); + size.y = rtText.Height(); +} +void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_RectF& rect) { + if (pwsStr == NULL || iLength < 1) { + rect.width = 0.0f; + rect.height = 0.0f; + } else { + CalcTextSize(pwsStr, iLength, rect); + } +} +void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr, + int32_t iLength, + CFX_RectF& rect) { + FXSYS_assert(m_pFont != NULL && m_fFontSize >= 1.0f); + SetLineWidth(rect); + m_iTotalLines = 0; + const FX_WCHAR* pStr = pwsStr; + FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); + FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); + FX_FLOAT fWidth = 0.0f; + FX_FLOAT fHeight = 0.0f; + FX_FLOAT fStartPos = bVertical ? rect.bottom() : rect.right(); + FX_DWORD dwBreakStatus = 0; + FX_WCHAR wPreChar = 0; + FX_WCHAR wch; + FX_WCHAR wBreak = 0; + while (iLength-- > 0) { + wch = *pStr++; + if (wBreak == 0 && (wch == L'\n' || wch == L'\r')) { + wBreak = wch; + m_pTxtBreak->SetParagraphBreakChar(wch); + } + if (bHotKey && wch == L'&' && wPreChar != L'&') { + wPreChar = wch; + continue; + } + dwBreakStatus = m_pTxtBreak->AppendChar(wch); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight); + } + wPreChar = 0; + } + dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight); + } + m_pTxtBreak->Reset(); + FX_FLOAT fInc = rect.Height() - fHeight; + if (bVertical) { + fInc = rect.Width() - fHeight; + } + if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && + m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { + fInc /= 2.0f; + } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { + fInc = 0.0f; + } + if (bVertical) { + rect.top += fStartPos; + rect.left += fInc; + rect.width = fHeight; + rect.height = std::min(fWidth, rect.Height()); + } else { + rect.left += fStartPos; + rect.top += fInc; + rect.width = std::min(fWidth, rect.Width()); + rect.height = fHeight; + if (m_dwStyles & FDE_TTOSTYLE_LastLineHeight) { + rect.height -= m_fLineSpace - m_fFontSize; + } + } +} +void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) { + if ((m_dwStyles & FDE_TTOSTYLE_SingleLine) == 0) { + FX_FLOAT fLineWidth = 0.0f; + if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) { + if (rect.Height() < 1.0f) { + rect.height = m_fFontSize * 1000.0f; + } + fLineWidth = rect.Height(); + } else { + if (rect.Width() < 1.0f) { + rect.width = m_fFontSize * 1000.0f; + } + fLineWidth = rect.Width(); + } + m_pTxtBreak->SetLineWidth(fLineWidth); + } +} +FX_BOOL CFDE_TextOut::RetrieveLineWidth(FX_DWORD dwBreakStatus, + FX_FLOAT& fStartPos, + FX_FLOAT& fWidth, + FX_FLOAT& fHeight) { + if (dwBreakStatus <= FX_TXTBREAK_PieceBreak) { + return FALSE; + } + FX_FLOAT fLineStep = + (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; + FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); + FX_FLOAT fLineWidth = 0.0f; + int32_t iCount = m_pTxtBreak->CountBreakPieces(); + for (int32_t i = 0; i < iCount; i++) { + const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + fLineWidth += (FX_FLOAT)pPiece->m_iWidth / 20000.0f; + fStartPos = std::min(fStartPos, (FX_FLOAT)pPiece->m_iStartPos / 20000.0f); + } + m_pTxtBreak->ClearBreakPieces(); + if (dwBreakStatus == FX_TXTBREAK_ParagraphBreak) { + m_pTxtBreak->Reset(); + } + if (!bLineWrap && dwBreakStatus == FX_TXTBREAK_LineBreak) { + fWidth += fLineWidth; + } else { + fWidth = std::max(fWidth, fLineWidth); + fHeight += fLineStep; + } + m_iTotalLines++; + return TRUE; +} +void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, + int32_t iLength, + int32_t x, + int32_t y) { + CFX_RectF rtText; + rtText.Set((FX_FLOAT)x, (FX_FLOAT)y, m_fFontSize * 1000.0f, + m_fFontSize * 1000.0f); + DrawText(pwsStr, iLength, rtText); +} +void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, + int32_t iLength, + FX_FLOAT x, + FX_FLOAT y) { + CFX_RectF rtText; + rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + DrawText(pwsStr, iLength, rtText); +} +void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, + int32_t iLength, + const CFX_Rect& rect) { + CFX_RectF rtText; + rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.width, + (FX_FLOAT)rect.height); + DrawText(pwsStr, iLength, rtText); +} +void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, + int32_t iLength, + const CFX_RectF& rect) { + CFX_RectF rtText; + rtText.Set(rect.left, rect.top, rect.width, rect.height); + CFX_Matrix rm; + rm.SetReverse(m_Matrix); + rm.TransformRect(rtText); + DrawText(pwsStr, iLength, rtText, m_rtClip); +} +void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, + int32_t iLength, + FX_FLOAT x, + FX_FLOAT y) { + CFX_RectF rtText; + rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + DrawLogicText(pwsStr, iLength, rtText); +} +void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, + int32_t iLength, + const CFX_RectF& rect) { + CFX_RectF rtClip; + rtClip.Set(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, + m_rtLogicClip.height); + m_Matrix.TransformRect(rtClip); + DrawText(pwsStr, iLength, rect, rtClip); +} +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); + if (pwsStr == NULL || iLength < 1) { + return; + } + if (rect.width < m_fFontSize || rect.height < m_fFontSize) { + return; + } + FX_FLOAT fLineWidth = rect.width; + if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) { + fLineWidth = rect.height; + } + m_pTxtBreak->SetLineWidth(fLineWidth); + m_ttoLines.RemoveAll(TRUE); + m_wsText.Empty(); + LoadText(pwsStr, iLength, rect); + if (m_dwStyles & FDE_TTOSTYLE_Ellipsis) { + ReplaceWidthEllipsis(); + } + Reload(rect); + DoAlignment(rect); + OnDraw(rtClip); +} +void CFDE_TextOut::ExpandBuffer(int32_t iSize, int32_t iType) { + switch (iType) { + case 0: + if (!m_pCharWidths) { + m_pCharWidths = FX_Alloc(int32_t, iSize); + m_iChars = iSize; + } else if (m_iChars < iSize) { + m_pCharWidths = FX_Realloc(int32_t, m_pCharWidths, iSize); + m_iChars = iSize; + } + FXSYS_memset(m_pCharWidths, 0, iSize * sizeof(int32_t)); + break; + case 1: + if (!m_pEllCharWidths) { + m_pEllCharWidths = FX_Alloc(int32_t, iSize); + m_iEllChars = iSize; + } else if (m_iEllChars < iSize) { + m_pEllCharWidths = FX_Realloc(int32_t, m_pEllCharWidths, iSize); + m_iEllChars = iSize; + } + FXSYS_memset(m_pEllCharWidths, 0, iSize * sizeof(int32_t)); + break; + case 2: + if (m_pCharPos == NULL) { + m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iSize); + m_iCharPosSize = iSize; + } else if (m_iCharPosSize < iSize) { + m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iSize); + m_iCharPosSize = iSize; + } + break; + } +} +void CFDE_TextOut::LoadEllipsis() { + if (!m_bElliChanged) { + return; + } + m_bElliChanged = FALSE; + m_iEllipsisWidth = 0; + int32_t iLength = m_wsEllipsis.GetLength(); + if (iLength < 1) { + return; + } + ExpandBuffer(iLength, 1); + const FX_WCHAR* pStr = (const FX_WCHAR*)m_wsEllipsis; + int32_t* pCharWidths = m_pEllCharWidths; + FX_DWORD dwBreakStatus; + FX_WCHAR wch; + while (iLength-- > 0) { + wch = *pStr++; + dwBreakStatus = m_pTxtBreak->AppendChar(wch); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetrieveEllPieces(pCharWidths); + } + } + dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetrieveEllPieces(pCharWidths); + } + m_pTxtBreak->Reset(); +} +void CFDE_TextOut::RetrieveEllPieces(int32_t*& pCharWidths) { + int32_t iCount = m_pTxtBreak->CountBreakPieces(); + CFX_Char* pTC; + for (int32_t i = 0; i < iCount; i++) { + const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + int32_t iPieceChars = pPiece->GetLength(); + for (int32_t j = 0; j < iPieceChars; j++) { + pTC = pPiece->GetCharPtr(j); + if (pTC->m_iCharWidth <= 0) { + *pCharWidths = 0; + } else { + *pCharWidths = pTC->m_iCharWidth; + } + m_iEllipsisWidth += *pCharWidths; + pCharWidths++; + } + } + m_pTxtBreak->ClearBreakPieces(); +} +void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr, + int32_t iLength, + const CFX_RectF& rect) { + FX_WCHAR* pStr = m_wsText.GetBuffer(iLength); + int32_t iTxtLength = iLength; + ExpandBuffer(iTxtLength, 0); + FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); + FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); + FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); + FX_FLOAT fLineStep = + (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; + FX_FLOAT fLineStop = bVertical ? rect.left : rect.bottom(); + m_fLinePos = bVertical ? rect.right() : rect.top; + if (bVertical) { + fLineStep = -fLineStep; + } + m_hotKeys.RemoveAll(); + int32_t iStartChar = 0; + int32_t iChars = 0; + int32_t iPieceWidths = 0; + FX_DWORD dwBreakStatus; + FX_WCHAR wch; + FX_BOOL bRet = FALSE; + while (iTxtLength-- > 0) { + wch = *pwsStr++; + if (wch == L'&' && bHotKey && (pStr - 1) != NULL && *(pStr - 1) != L'&') { + if (iTxtLength > 0) { + m_hotKeys.Add(iChars); + } + continue; + } + *pStr++ = wch; + iChars++; + dwBreakStatus = m_pTxtBreak->AppendChar(wch); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + FX_BOOL bEndofLine = + RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, FALSE, rect); + if (bEndofLine && (bLineWrap || (dwBreakStatus > FX_TXTBREAK_LineBreak && + !bLineWrap))) { + iPieceWidths = 0; + m_iCurLine++; + m_fLinePos += fLineStep; + } + if ((bVertical && m_fLinePos + fLineStep < fLineStop) || + (!bVertical && m_fLinePos + fLineStep > fLineStop)) { + int32_t iCurLine = m_iCurLine; + if (bEndofLine) { + iCurLine--; + } + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iCurLine); + pLine->m_bNewReload = TRUE; + bRet = TRUE; + break; + } + } + } + dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak && !bRet) { + RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, FALSE, rect); + } + m_pTxtBreak->ClearBreakPieces(); + m_pTxtBreak->Reset(); + m_wsText.ReleaseBuffer(iLength); +} +FX_BOOL CFDE_TextOut::RetriecePieces(FX_DWORD dwBreakStatus, + int32_t& iStartChar, + int32_t& iPieceWidths, + FX_BOOL bReload, + const CFX_RectF& rect) { + FX_BOOL bSingleLine = !!(m_dwStyles & FDE_TTOSTYLE_SingleLine); + FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); + FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); + FX_FLOAT fLineStep = + (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; + if (bVertical) { + fLineStep = -fLineStep; + } + CFX_Char* pTC = NULL; + FX_BOOL bNeedReload = FALSE; + FX_FLOAT fLineWidth = bVertical ? rect.Height() : rect.Width(); + int32_t iLineWidth = FXSYS_round(fLineWidth * 20000.0f); + int32_t iCount = m_pTxtBreak->CountBreakPieces(); + for (int32_t i = 0; i < iCount; i++) { + const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + int32_t iPieceChars = pPiece->GetLength(); + int32_t iChar = iStartChar; + int32_t iWidth = 0; + int32_t j = 0; + for (; j < iPieceChars; j++) { + pTC = pPiece->GetCharPtr(j); + int32_t iCurCharWidth = pTC->m_iCharWidth > 0 ? pTC->m_iCharWidth : 0; + if (bSingleLine || !bLineWrap) { + if (iLineWidth - iPieceWidths - iWidth < iCurCharWidth) { + bNeedReload = TRUE; + break; + } + } + iWidth += iCurCharWidth; + m_pCharWidths[iChar++] = iCurCharWidth; + } + if (j == 0 && !bReload) { + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine); + pLine->m_bNewReload = TRUE; + } else if (j > 0) { + CFX_RectF rtPiece; + if (bVertical) { + rtPiece.left = m_fLinePos; + rtPiece.top = rect.top + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; + rtPiece.width = fLineStep; + rtPiece.height = iWidth / 20000.0f; + } else { + rtPiece.left = rect.left + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; + rtPiece.top = m_fLinePos; + rtPiece.width = iWidth / 20000.0f; + rtPiece.height = fLineStep; + } + FDE_TTOPIECE ttoPiece; + ttoPiece.iStartChar = iStartChar; + ttoPiece.iChars = j; + ttoPiece.rtPiece = rtPiece; + ttoPiece.dwCharStyles = pPiece->m_dwCharStyles; + if (FX_IsOdd(pPiece->m_iBidiLevel)) { + ttoPiece.dwCharStyles |= FX_TXTCHARSTYLE_OddBidiLevel; + } + AppendPiece(ttoPiece, bNeedReload, (bReload && i == iCount - 1)); + } + iStartChar += iPieceChars; + iPieceWidths += iWidth; + } + m_pTxtBreak->ClearBreakPieces(); + FX_BOOL bRet = bSingleLine || bLineWrap || (!bLineWrap && bNeedReload) || + dwBreakStatus == FX_TXTBREAK_ParagraphBreak; + return bRet; +} +void CFDE_TextOut::AppendPiece(const FDE_TTOPIECE& ttoPiece, + FX_BOOL bNeedReload, + FX_BOOL bEnd) { + if (m_iCurLine >= m_ttoLines.GetSize()) { + CFDE_TTOLine ttoLine; + ttoLine.m_bNewReload = bNeedReload; + m_iCurPiece = ttoLine.AddPiece(m_iCurPiece, ttoPiece); + m_iCurLine = m_ttoLines.Add(ttoLine); + } else { + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine); + pLine->m_bNewReload = bNeedReload; + m_iCurPiece = pLine->AddPiece(m_iCurPiece, ttoPiece); + if (bEnd) { + int32_t iPieces = pLine->GetSize(); + if (m_iCurPiece < iPieces) { + pLine->RemoveLast(iPieces - m_iCurPiece - 1); + } + } + } + if (!bEnd && bNeedReload) { + m_iCurPiece = 0; + } +} +void CFDE_TextOut::ReplaceWidthEllipsis() { + LoadEllipsis(); + int32_t iLength = m_wsEllipsis.GetLength(); + if (iLength < 1) { + return; + } + int32_t iLines = m_ttoLines.GetSize(); + for (int32_t i = 0; i < iLines; i++) { + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); + if (!pLine->m_bNewReload) { + continue; + } + int32_t iEllipsisCharIndex = iLength - 1; + int32_t iCharWidth = 0; + int32_t iCharCount = 0; + int32_t iPiece = pLine->GetSize(); + while (iPiece-- > 0) { + FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(iPiece); + if (pPiece == NULL) { + break; + } + for (int32_t j = pPiece->iChars - 1; j >= 0; j--) { + if (iEllipsisCharIndex < 0) { + break; + } + int32_t index = pPiece->iStartChar + j; + iCharWidth += m_pCharWidths[index]; + iCharCount++; + if (iCharCount <= iLength) { + m_wsText.SetAt(index, m_wsEllipsis.GetAt(iEllipsisCharIndex)); + m_pCharWidths[index] = m_pEllCharWidths[iEllipsisCharIndex]; + } else if (iCharWidth <= m_iEllipsisWidth) { + m_wsText.SetAt(index, 0); + m_pCharWidths[index] = 0; + } + iEllipsisCharIndex--; + } + if (iEllipsisCharIndex < 0) { + break; + } + } + } +} +void CFDE_TextOut::Reload(const CFX_RectF& rect) { + int32_t iCount = m_ttoLines.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); + if (pLine == NULL || !pLine->m_bNewReload) { + continue; + } + m_iCurLine = i; + m_iCurPiece = 0; + ReloadLinePiece(pLine, rect); + } +} +void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) { + const FX_WCHAR* pwsStr = (const FX_WCHAR*)m_wsText; + FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); + int32_t iPieceWidths = 0; + FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); + int32_t iStartChar = pPiece->iStartChar; + m_fLinePos = bVertical ? pPiece->rtPiece.left : pPiece->rtPiece.top; + int32_t iPieceCount = pLine->GetSize(); + int32_t iPieceIndex = 0; + FX_DWORD dwBreakStatus = 0; + FX_WCHAR wch; + while (iPieceIndex < iPieceCount) { + int32_t iStar = iStartChar; + int32_t iEnd = pPiece->iChars + iStar; + while (iStar < iEnd) { + wch = *(pwsStr + iStar); + dwBreakStatus = m_pTxtBreak->AppendChar(wch); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); + } + iStar++; + } + iPieceIndex++; + pPiece = pLine->GetPtrAt(iPieceIndex); + } + dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); + } + m_pTxtBreak->Reset(); +} +void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { + FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); + FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); + int32_t iLines = m_ttoLines.GetSize(); + if (iLines < 1) { + return; + } + CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1); + FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); + if (pPiece == NULL) { + return; + } + FX_FLOAT fLineStopD = + bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom(); + FX_FLOAT fInc = fLineStopS - fLineStopD; + if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && + m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { + fInc /= 2.0f; + } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { + fInc = 0.0f; + } + if (fInc < 1.0f) { + return; + } + for (int32_t i = 0; i < iLines; i++) { + 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); + if (bVertical) { + pPiece->rtPiece.left += fInc; + } else { + pPiece->rtPiece.top += fInc; + } + } + } +} +void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { + if (m_pRenderDevice == NULL) { + return; + } + int32_t iLines = m_ttoLines.GetSize(); + if (iLines < 1) { + return; + } + IFDE_SolidBrush* pBrush = + (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid); + pBrush->SetColor(m_TxtColor); + IFDE_Pen* pPen = NULL; + FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); + if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { + m_pRenderDevice->SetClipRect(rtClip); + } + for (int32_t i = 0; i < iLines; i++) { + 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); + if (pPiece == NULL) { + continue; + } + int32_t iCount = GetDisplayPos(pPiece); + if (iCount > 0) { + m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, + m_fFontSize, &m_Matrix); + } + DrawLine(pPiece, pPen); + } + } + m_pRenderDevice->RestoreState(hDev); + if (pBrush) { + pBrush->Release(); + } + if (pPen) { + pPen->Release(); + } +} +int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { + FX_TXTRUN tr; + ToTextRun(pPiece, tr); + 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); + 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; + 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; +} +void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_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) { + return; + } + if (pPen == NULL) { + pPen = IFDE_Pen::Create(); + pPen->SetColor(m_TxtColor); + } + IFDE_Path* pPath = IFDE_Path::Create(); + int32_t iLineCount = 0; + CFX_RectF rtText = pPiece->rtPiece; + CFX_PointF pt1, pt2; + if (bUnderLine) { + if (bVertical) { + pt1.x = rtText.left; + pt1.y = rtText.top; + pt2.x = rtText.left; + pt2.y = rtText.bottom(); + } else { + pt1.x = rtText.left; + pt1.y = rtText.bottom(); + pt2.x = rtText.right(); + pt2.y = rtText.bottom(); + } + pPath->AddLine(pt1, pt2); + iLineCount++; + } + if (bStrikeOut) { + if (bVertical) { + pt1.x = rtText.left + rtText.width * 2.0f / 5.0f; + pt1.y = rtText.top; + pt2.x = pt1.x; + pt2.y = rtText.bottom(); + } else { + pt1.x = rtText.left; + pt1.y = rtText.bottom() - rtText.height * 2.0f / 5.0f; + pt2.x = rtText.right(); + pt2.y = pt1.y; + } + pPath->AddLine(pt1, pt2); + iLineCount++; + } + if (bHotKey) { + int32_t iHotKeys = m_hotKeys.GetSize(); + int32_t iCount = GetCharRects(pPiece); + if (iCount > 0) { + for (int32_t i = 0; i < iHotKeys; i++) { + int32_t iCharIndex = m_hotKeys.GetAt(i); + if (iCharIndex >= pPiece->iStartChar && + iCharIndex < pPiece->iStartChar + pPiece->iChars) { + CFX_RectF rect = m_rectArray.GetAt(iCharIndex - pPiece->iStartChar); + if (bVertical) { + pt1.x = rect.left; + pt1.y = rect.top; + pt2.x = rect.left; + pt2.y = rect.bottom(); + } else { + pt1.x = rect.left; + pt1.y = rect.bottom(); + pt2.x = rect.right(); + pt2.y = rect.bottom(); + } + pPath->AddLine(pt1, pt2); + iLineCount++; + } + } + } + } + if (iLineCount > 0) { + m_pRenderDevice->DrawPath(pPen, 1, pPath, &m_Matrix); + } + pPath->Release(); +} +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; + m_iPieceCount++; + } else { + FDE_TTOPIECE& piece = m_pieces.GetAt(index); + piece = ttoPiece; + } + return index; +} +int32_t CFDE_TTOLine::GetSize() const { + return m_iPieceCount; +} +FDE_LPTTOPIECE CFDE_TTOLine::GetPtrAt(int32_t index) { + if (index >= m_iPieceCount) { + return NULL; + } + return m_pieces.GetPtrAt(index); +} +void CFDE_TTOLine::RemoveLast(int32_t iCount) { + m_pieces.RemoveLast(iCount); +} +void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { + m_pieces.RemoveAll(bLeaveMemory); +} diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h new file mode 100644 index 0000000000..c94571b5f8 --- /dev/null +++ b/xfa/fde/tto/fde_textout.h @@ -0,0 +1,102 @@ +// 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_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 "xfa/fgas/font/fgas_font.h" + +#define FDE_TTOSTYLE_Underline 0x0001 +#define FDE_TTOSTYLE_Strikeout 0x0002 +#define FDE_TTOSTYLE_VerticalLayout 0x0004 +#define FDE_TTOSTYLE_SingleLine 0x0010 +#define FDE_TTOSTYLE_ExpandTab 0x0020 +#define FDE_TTOSTYLE_HotKey 0x0040 +#define FDE_TTOSTYLE_Ellipsis 0x0080 +#define FDE_TTOSTYLE_LineWrap 0x0100 +#define FDE_TTOSTYLE_ArabicShapes 0x0200 +#define FDE_TTOSTYLE_RTL 0x0400 +#define FDE_TTOSTYLE_ArabicContext 0x0800 +#define FDE_TTOSTYLE_LastLineHeight 0x1000 +#define FDE_TTOALIGNMENT_TopLeft 0 +#define FDE_TTOALIGNMENT_TopCenter 1 +#define FDE_TTOALIGNMENT_TopRight 2 +#define FDE_TTOALIGNMENT_TopAuto 3 +#define FDE_TTOALIGNMENT_CenterLeft 4 +#define FDE_TTOALIGNMENT_Center 5 +#define FDE_TTOALIGNMENT_CenterRight 6 +#define FDE_TTOALIGNMENT_CenterAuto 7 +#define FDE_TTOALIGNMENT_BottomLeft 8 +#define FDE_TTOALIGNMENT_BottomCenter 9 +#define FDE_TTOALIGNMENT_BottomRight 10 +#define FDE_TTOALIGNMENT_BottomAuto 11 + +class IFDE_TextOut { + 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(FX_DWORD 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; +}; + +#endif // XFA_FDE_TTO_FDE_TEXTOUT_H_ diff --git a/xfa/fde/xml/fde_xml.h b/xfa/fde/xml/fde_xml.h new file mode 100644 index 0000000000..757ebf9be8 --- /dev/null +++ b/xfa/fde/xml/fde_xml.h @@ -0,0 +1,226 @@ +// 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_XML_FDE_XML_H_ +#define XFA_FDE_XML_FDE_XML_H_ + +#include "xfa/fgas/crt/fgas_stream.h" +#include "xfa/fgas/crt/fgas_utils.h" + +class IFDE_XMLNode; +class IFDE_XMLInstruction; +class IFDE_XMLDeclaration; +class IFDE_XMLElement; +class IFDE_XMLText; +class IFDE_XMLDoc; +class IFDE_XMLParser; +class IFDE_XMLSyntaxParser; + +enum FDE_XMLNODETYPE { + FDE_XMLNODE_Unknown = 0, + FDE_XMLNODE_Instruction, + FDE_XMLNODE_Element, + FDE_XMLNODE_Text, + FDE_XMLNODE_CharData, +}; + +struct FDE_XMLNODE { + int32_t iNodeNum; + FDE_XMLNODETYPE eNodeType; +}; +typedef CFX_StackTemplate<FDE_XMLNODE> CFDE_XMLNodeStack; + +FX_BOOL FDE_IsXMLValidChar(FX_WCHAR ch); +FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch); +FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar); + +class IFDE_XMLNode { + public: + virtual ~IFDE_XMLNode() {} + virtual void Release() = 0; + virtual FDE_XMLNODETYPE GetType() const = 0; + virtual int32_t CountChildNodes() const = 0; + virtual IFDE_XMLNode* GetChildNode(int32_t index) const = 0; + virtual int32_t GetChildNodeIndex(IFDE_XMLNode* pNode) const = 0; + virtual IFDE_XMLNode* GetPath(const FX_WCHAR* pPath, + int32_t iLength = -1, + FX_BOOL bQualifiedName = TRUE) const = 0; + virtual int32_t InsertChildNode(IFDE_XMLNode* pNode, int32_t index = -1) = 0; + virtual void RemoveChildNode(IFDE_XMLNode* pNode) = 0; + virtual void DeleteChildren() = 0; + enum NodeItem { + Root = 0, + Parent, + FirstSibling, + PriorSibling, + NextSibling, + LastSibling, + FirstNeighbor, + PriorNeighbor, + NextNeighbor, + LastNeighbor, + FirstChild, + LastChild + }; + virtual IFDE_XMLNode* GetNodeItem(NodeItem eItem) const = 0; + virtual int32_t GetNodeLevel() const = 0; + virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem, + IFDE_XMLNode* pNode) = 0; + virtual IFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) = 0; + virtual IFDE_XMLNode* Clone(FX_BOOL bRecursive) = 0; + virtual void SaveXMLNode(IFX_Stream* pXMLStream) = 0; +}; +class IFDE_XMLInstruction : public IFDE_XMLNode { + public: + static IFDE_XMLInstruction* Create(const CFX_WideString& wsTarget); + virtual void GetTargetName(CFX_WideString& wsTarget) const = 0; + virtual int32_t CountAttributes() const = 0; + virtual FX_BOOL GetAttribute(int32_t index, + CFX_WideString& wsAttriName, + CFX_WideString& wsAttriValue) const = 0; + virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0; + virtual void GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue = NULL) const = 0; + virtual void SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue) = 0; + virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue = 0) const = 0; + virtual void SetInteger(const FX_WCHAR* pwsAttriName, + int32_t iAttriValue) = 0; + virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue = 0) const = 0; + virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0; + virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0; + virtual int32_t CountData() const = 0; + virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const = 0; + virtual void AppendData(const CFX_WideString& wsData) = 0; + virtual void RemoveData(int32_t index) = 0; +}; +class IFDE_XMLElement : public IFDE_XMLNode { + public: + static IFDE_XMLElement* Create(const CFX_WideString& wsTag); + virtual void GetTagName(CFX_WideString& wsTag) const = 0; + virtual void GetLocalTagName(CFX_WideString& wsTag) const = 0; + virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const = 0; + virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const = 0; + virtual int32_t CountAttributes() const = 0; + virtual FX_BOOL GetAttribute(int32_t index, + CFX_WideString& wsAttriName, + CFX_WideString& wsAttriValue) const = 0; + virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0; + virtual void GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue = NULL) const = 0; + virtual void SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue) = 0; + virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue = 0) const = 0; + virtual void SetInteger(const FX_WCHAR* pwsAttriName, + int32_t iAttriValue) = 0; + virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue = 0) const = 0; + virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0; + virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0; + virtual void GetTextData(CFX_WideString& wsText) const = 0; + virtual void SetTextData(const CFX_WideString& wsText) = 0; +}; +class IFDE_XMLText : public IFDE_XMLNode { + public: + static IFDE_XMLText* Create(const CFX_WideString& wsText); + virtual void GetText(CFX_WideString& wsText) const = 0; + virtual void SetText(const CFX_WideString& wsText) = 0; +}; +class IFDE_XMLDeclaration : public IFDE_XMLNode { + public: +}; +class IFDE_XMLCharData : public IFDE_XMLDeclaration { + public: + static IFDE_XMLCharData* Create(const CFX_WideString& wsCData); + virtual ~IFDE_XMLCharData() {} + + virtual void GetCharData(CFX_WideString& wsCData) const = 0; + virtual void SetCharData(const CFX_WideString& wsCData) = 0; +}; + +struct FDE_XMLREADERHANDLER { + void* pData; + void (*OnTagEnter)(FDE_XMLREADERHANDLER* pThis, + FDE_XMLNODETYPE eType, + const CFX_WideString& wsTagName); + void (*OnTagBreak)(FDE_XMLREADERHANDLER* pThis, + const CFX_WideString& wsTagName); + void (*OnTagClose)(FDE_XMLREADERHANDLER* pThis, + const CFX_WideString& wsTagName); + void (*OnAttribute)(FDE_XMLREADERHANDLER* pThis, + const CFX_WideString& wsName, + const CFX_WideString& wsValue); + void (*OnData)(FDE_XMLREADERHANDLER* pThis, + FDE_XMLNODETYPE eType, + const CFX_WideString& wsValue); +}; + +class IFDE_XMLDoc { + public: + static IFDE_XMLDoc* Create(); + virtual ~IFDE_XMLDoc() {} + virtual void Release() = 0; + virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, + int32_t iXMLPlaneSize = 8192, + int32_t iTextDataSize = 256, + FDE_XMLREADERHANDLER* pHandler = NULL) = 0; + virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser) = 0; + virtual int32_t DoLoad(IFX_Pause* pPause = NULL) = 0; + virtual void CloseXML() = 0; + virtual IFDE_XMLNode* GetRoot() const = 0; + virtual void SaveXML(IFX_Stream* pXMLStream = NULL, + FX_BOOL bSaveBOM = TRUE) = 0; + virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode) = 0; +}; +class IFDE_XMLParser { + public: + virtual ~IFDE_XMLParser() {} + virtual void Release() = 0; + virtual int32_t DoParser(IFX_Pause* pPause) = 0; +}; +#define FDE_XMLSYNTAXSTATUS_None 0x00 +#define FDE_XMLSYNTAXSTATUS_InstructionOpen 0x01 +#define FDE_XMLSYNTAXSTATUS_InstructionClose 0x02 +#define FDE_XMLSYNTAXSTATUS_ElementOpen 0x03 +#define FDE_XMLSYNTAXSTATUS_ElementBreak 0x04 +#define FDE_XMLSYNTAXSTATUS_ElementClose 0x05 +#define FDE_XMLSYNTAXSTATUS_TargetName 0x06 +#define FDE_XMLSYNTAXSTATUS_TagName 0x07 +#define FDE_XMLSYNTAXSTATUS_AttriName 0x08 +#define FDE_XMLSYNTAXSTATUS_AttriValue 0x09 +#define FDE_XMLSYNTAXSTATUS_Text 0x0A +#define FDE_XMLSYNTAXSTATUS_CData 0x0B +#define FDE_XMLSYNTAXSTATUS_TargetData 0x0C +#define FDE_XMLSYNTAXSTATUS_Error 0xFE +#define FDE_XMLSYNTAXSTATUS_EOS 0xFF +class IFDE_XMLSyntaxParser { + public: + static IFDE_XMLSyntaxParser* Create(); + virtual ~IFDE_XMLSyntaxParser() {} + virtual void Release() = 0; + virtual void Init(IFX_Stream* pStream, + int32_t iXMLPlaneSize, + int32_t iTextDataSize = 256) = 0; + virtual FX_DWORD DoSyntaxParse() = 0; + virtual int32_t GetStatus() const = 0; + virtual int32_t GetCurrentPos() const = 0; + virtual FX_FILESIZE GetCurrentBinaryPos() const = 0; + virtual int32_t GetCurrentNodeNumber() const = 0; + virtual int32_t GetLastNodeNumber() const = 0; + virtual void GetTargetName(CFX_WideString& wsTarget) const = 0; + virtual void GetTagName(CFX_WideString& wsTag) const = 0; + virtual void GetAttributeName(CFX_WideString& wsAttriName) const = 0; + virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const = 0; + virtual void GetTextData(CFX_WideString& wsText) const = 0; + virtual void GetTargetData(CFX_WideString& wsData) const = 0; +}; + +#endif // XFA_FDE_XML_FDE_XML_H_ diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp new file mode 100644 index 0000000000..ce719dee3a --- /dev/null +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -0,0 +1,2100 @@ +// 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/xml/fde_xml_imp.h" + +#include <algorithm> + +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/crt/fgas_system.h" + +#define FDE_XMLVALIDCHARRANGENUM 5 + +static const FX_WCHAR g_XMLValidCharRange[FDE_XMLVALIDCHARRANGENUM][2] = { + {0x09, 0x09}, + {0x0A, 0x0A}, + {0x0D, 0x0D}, + {0x20, 0xD7FF}, + {0xE000, 0xFFFD}}; + +FX_BOOL FDE_IsXMLValidChar(FX_WCHAR ch) { + int32_t iStart = 0, iEnd = FDE_XMLVALIDCHARRANGENUM - 1, iMid; + while (iStart <= iEnd) { + iMid = (iStart + iEnd) / 2; + if (ch < g_XMLValidCharRange[iMid][0]) { + iEnd = iMid - 1; + } else if (ch > g_XMLValidCharRange[iMid][1]) { + iStart = iMid + 1; + } else { + return TRUE; + } + } + return FALSE; +} +FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch) { + return ch == L' ' || ch == 0x0A || ch == 0x0D || ch == 0x09; +} + +struct FDE_XMLNAMECHAR { + FX_WCHAR wStart; + FX_WCHAR wEnd; + FX_BOOL bStartChar; +}; + +#define FDE_XMLNAMECHARSNUM 20 +static FDE_XMLNAMECHAR g_XMLNameChars[FDE_XMLNAMECHARSNUM] = { + {L'-', L'.', FALSE}, {L'0', L'9', FALSE}, {L':', L':', FALSE}, + {L'A', L'Z', TRUE}, {L'_', L'_', TRUE}, {L'a', L'z', TRUE}, + {0xB7, 0xB7, FALSE}, {0xC0, 0xD6, TRUE}, {0xD8, 0xF6, TRUE}, + {0xF8, 0x02FF, TRUE}, {0x0300, 0x036F, FALSE}, {0x0370, 0x037D, TRUE}, + {0x037F, 0x1FFF, TRUE}, {0x200C, 0x200D, TRUE}, {0x203F, 0x2040, FALSE}, + {0x2070, 0x218F, TRUE}, {0x2C00, 0x2FEF, TRUE}, {0x3001, 0xD7FF, TRUE}, + {0xF900, 0xFDCF, TRUE}, {0xFDF0, 0xFFFD, TRUE}, +}; + +FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar) { + int32_t iStart = 0, iEnd = FDE_XMLNAMECHARSNUM - 1, iMid; + while (iStart <= iEnd) { + iMid = (iStart + iEnd) / 2; + if (ch < g_XMLNameChars[iMid].wStart) { + iEnd = iMid - 1; + } else if (ch > g_XMLNameChars[iMid].wEnd) { + iStart = iMid + 1; + } else { + if (bFirstChar) { + return g_XMLNameChars[iMid].bStartChar; + } + return TRUE; + } + } + return FALSE; +} + +CFDE_XMLNode::CFDE_XMLNode() + : m_pParent(NULL), m_pChild(NULL), m_pPrior(NULL), m_pNext(NULL) {} +CFDE_XMLNode::~CFDE_XMLNode() { + DeleteChildren(); +} +void CFDE_XMLNode::DeleteChildren() { + CFDE_XMLNode *pChild = m_pChild, *pTemp; + while (pChild != NULL) { + pTemp = pChild->m_pNext; + pChild->Release(); + pChild = pTemp; + } + m_pChild = NULL; +} +int32_t CFDE_XMLNode::CountChildNodes() const { + int32_t iCount = 0; + CFDE_XMLNode* pChild = m_pChild; + while (pChild != NULL) { + iCount++; + pChild = pChild->m_pNext; + } + return iCount; +} +CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { + CFDE_XMLNode* pChild = m_pChild; + while (pChild != NULL) { + if (index == 0) { + return pChild; + } + index--; + pChild = pChild->m_pNext; + } + return NULL; +} +int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { + int32_t index = 0; + CFDE_XMLNode* pChild = m_pChild; + while (pChild != NULL) { + if (pChild == pNode) { + return index; + } + index++; + pChild = pChild->m_pNext; + } + return -1; +} +CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, + int32_t iLength, + FX_BOOL bQualifiedName) const { + FXSYS_assert(pPath != NULL); + if (iLength < 0) { + iLength = FXSYS_wcslen(pPath); + } + if (iLength == 0) { + return NULL; + } + CFX_WideString csPath; + const FX_WCHAR* pStart = pPath; + const FX_WCHAR* pEnd = pPath + iLength; + FX_WCHAR ch; + while (pStart < pEnd) { + ch = *pStart++; + if (ch == L'/') { + break; + } else { + csPath += ch; + } + } + iLength -= pStart - pPath; + CFDE_XMLNode* pFind = NULL; + if (csPath.GetLength() < 1) { + pFind = GetNodeItem(IFDE_XMLNode::Root); + } else if (csPath.Compare(L"..") == 0) { + pFind = m_pParent; + } else if (csPath.Compare(L".") == 0) { + pFind = (CFDE_XMLNode*)this; + } else { + CFX_WideString wsTag; + CFDE_XMLNode* pNode = m_pChild; + while (pNode != NULL) { + if (pNode->GetType() == FDE_XMLNODE_Element) { + if (bQualifiedName) { + ((CFDE_XMLElement*)pNode)->GetTagName(wsTag); + } else { + ((CFDE_XMLElement*)pNode)->GetLocalTagName(wsTag); + } + if (wsTag.Compare(csPath) == 0) { + if (iLength < 1) { + pFind = pNode; + } else { + pFind = pNode->GetPath(pStart, iLength, bQualifiedName); + } + if (pFind != NULL) { + return pFind; + } + } + } + pNode = pNode->m_pNext; + } + } + if (pFind == NULL || iLength < 1) { + return pFind; + } + return pFind->GetPath(pStart, iLength, bQualifiedName); +} +int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { + FXSYS_assert(pNode != NULL); + pNode->m_pParent = this; + if (m_pChild == NULL) { + m_pChild = pNode; + pNode->m_pPrior = NULL; + pNode->m_pNext = NULL; + return 0; + } else if (index == 0) { + pNode->m_pNext = m_pChild; + pNode->m_pPrior = NULL; + m_pChild->m_pPrior = pNode; + m_pChild = pNode; + return 0; + } + int32_t iCount = 0; + CFDE_XMLNode* pFind = m_pChild; + while (++iCount != index && pFind->m_pNext != NULL) { + pFind = pFind->m_pNext; + } + pNode->m_pPrior = pFind; + pNode->m_pNext = pFind->m_pNext; + if (pFind->m_pNext != NULL) { + pFind->m_pNext->m_pPrior = pNode; + } + pFind->m_pNext = pNode; + return iCount; +} +void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) { + FXSYS_assert(m_pChild != NULL && pNode != NULL); + if (m_pChild == pNode) { + m_pChild = pNode->m_pNext; + } else { + pNode->m_pPrior->m_pNext = pNode->m_pNext; + } + if (pNode->m_pNext != NULL) { + pNode->m_pNext->m_pPrior = pNode->m_pPrior; + } + pNode->m_pParent = NULL; + pNode->m_pNext = NULL; + pNode->m_pPrior = NULL; +} +CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const { + switch (eItem) { + case IFDE_XMLNode::Root: { + CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; + while (pParent->m_pParent != NULL) { + pParent = pParent->m_pParent; + } + return pParent; + } + case IFDE_XMLNode::Parent: + return m_pParent; + case IFDE_XMLNode::FirstSibling: { + CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; + while (pItem->m_pPrior != NULL) { + pItem = pItem->m_pPrior; + } + return pItem == (CFDE_XMLNode*)this ? NULL : pItem; + } + case IFDE_XMLNode::PriorSibling: + return m_pPrior; + case IFDE_XMLNode::NextSibling: + return m_pNext; + case IFDE_XMLNode::LastSibling: { + CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; + while (pItem->m_pNext != NULL) { + pItem = pItem->m_pNext; + } + return pItem == (CFDE_XMLNode*)this ? NULL : pItem; + } + case IFDE_XMLNode::FirstNeighbor: { + CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; + while (pParent->m_pParent != NULL) { + pParent = pParent->m_pParent; + } + return pParent == (CFDE_XMLNode*)this ? NULL : pParent; + } + case IFDE_XMLNode::PriorNeighbor: { + if (m_pPrior == NULL) { + return m_pParent; + } + CFDE_XMLNode* pItem = m_pPrior; + while (CFDE_XMLNode* pTemp = pItem->m_pChild) { + pItem = pTemp; + while ((pTemp = pItem->m_pNext) != NULL) { + pItem = pTemp; + } + } + return pItem; + } + case IFDE_XMLNode::NextNeighbor: { + if (m_pChild != NULL) { + return m_pChild; + } + if (m_pNext != NULL) { + return m_pNext; + } + CFDE_XMLNode* pItem = m_pParent; + while (pItem != NULL) { + if (pItem->m_pNext != NULL) { + return pItem->m_pNext; + } + pItem = pItem->m_pParent; + } + return NULL; + } + case IFDE_XMLNode::LastNeighbor: { + CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; + while (pItem->m_pParent != NULL) { + pItem = pItem->m_pParent; + } + while (TRUE) { + while (pItem->m_pNext != NULL) { + pItem = pItem->m_pNext; + } + if (pItem->m_pChild == NULL) { + break; + } + pItem = pItem->m_pChild; + } + return pItem == (CFDE_XMLNode*)this ? NULL : pItem; + } + case IFDE_XMLNode::FirstChild: + return m_pChild; + case IFDE_XMLNode::LastChild: { + if (m_pChild == NULL) { + return NULL; + } + CFDE_XMLNode* pChild = m_pChild; + while (pChild->m_pNext != NULL) { + pChild = pChild->m_pNext; + } + return pChild; + } + default: + break; + } + return NULL; +} +int32_t CFDE_XMLNode::GetNodeLevel() const { + int32_t iLevel = 0; + CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; + while ((pItem = pItem->m_pParent) != NULL) { + iLevel++; + } + return iLevel; +} +FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem, + CFDE_XMLNode* pNode) { + FXSYS_assert(pNode != NULL); + switch (eItem) { + case IFDE_XMLNode::NextSibling: { + pNode->m_pParent = m_pParent; + pNode->m_pNext = m_pNext; + pNode->m_pPrior = this; + if (m_pNext) { + m_pNext->m_pPrior = pNode; + } + m_pNext = pNode; + return TRUE; + } + case IFDE_XMLNode::PriorSibling: { + pNode->m_pParent = m_pParent; + pNode->m_pNext = this; + pNode->m_pPrior = m_pPrior; + if (m_pPrior) { + m_pPrior->m_pNext = pNode; + } else if (m_pParent) { + m_pParent->m_pChild = pNode; + } + m_pPrior = pNode; + return TRUE; + } + default: + return FALSE; + } + return FALSE; +} +CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) { + CFDE_XMLNode* pNode = NULL; + switch (eItem) { + case IFDE_XMLNode::NextSibling: + if (m_pNext) { + pNode = m_pNext; + m_pNext = pNode->m_pNext; + if (m_pNext) { + m_pNext->m_pPrior = this; + } + pNode->m_pParent = NULL; + pNode->m_pNext = NULL; + pNode->m_pPrior = NULL; + } + break; + default: + break; + } + return pNode; +} +CFDE_XMLNode* CFDE_XMLNode::Clone(FX_BOOL bRecursive) { + return NULL; +} +void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { + CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; + FXSYS_assert(pXMLStream != NULL && pNode != NULL); + switch (pNode->GetType()) { + case FDE_XMLNODE_Instruction: { + CFX_WideString ws; + CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; + if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { + ws = L"<?xml version=\"1.0\" encoding=\""; + FX_WORD wCodePage = pXMLStream->GetCodePage(); + if (wCodePage == FX_CODEPAGE_UTF16LE) { + ws += L"UTF-16"; + } else if (wCodePage == FX_CODEPAGE_UTF16BE) { + ws += L"UTF-16be"; + } else { + ws += L"UTF-8"; + } + ws += L"\"?>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } else { + ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); + pXMLStream->WriteString(ws, ws.GetLength()); + CFX_WideStringArray& attributes = pInstruction->m_Attributes; + int32_t i, iCount = attributes.GetSize(); + CFX_WideString wsValue; + for (i = 0; i < iCount; i += 2) { + ws = L" "; + ws += attributes[i]; + ws += L"=\""; + wsValue = attributes[i + 1]; + wsValue.Replace(L"&", L"&"); + wsValue.Replace(L"<", L"<"); + wsValue.Replace(L">", L">"); + wsValue.Replace(L"\'", L"'"); + wsValue.Replace(L"\"", L"""); + ws += wsValue; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + CFX_WideStringArray& targetdata = pInstruction->m_TargetData; + iCount = targetdata.GetSize(); + for (i = 0; i < iCount; i++) { + ws = L" \""; + ws += targetdata[i]; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + ws = L"?>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } + } break; + case FDE_XMLNODE_Element: { + CFX_WideString ws; + ws = L"<"; + ws += ((CFDE_XMLElement*)pNode)->m_wsTag; + pXMLStream->WriteString(ws, ws.GetLength()); + CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; + int32_t iCount = attributes.GetSize(); + CFX_WideString wsValue; + for (int32_t i = 0; i < iCount; i += 2) { + ws = L" "; + ws += attributes[i]; + ws += L"=\""; + wsValue = attributes[i + 1]; + wsValue.Replace(L"&", L"&"); + wsValue.Replace(L"<", L"<"); + wsValue.Replace(L">", L">"); + wsValue.Replace(L"\'", L"'"); + wsValue.Replace(L"\"", L"""); + ws += wsValue; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + if (pNode->m_pChild == NULL) { + ws = L"\n/>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } else { + ws = L"\n>"; + pXMLStream->WriteString(ws, ws.GetLength()); + CFDE_XMLNode* pChild = pNode->m_pChild; + while (pChild != NULL) { + pChild->SaveXMLNode(pXMLStream); + pChild = pChild->m_pNext; + } + ws = L"</"; + ws += ((CFDE_XMLElement*)pNode)->m_wsTag; + ws += L"\n>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } + } break; + case FDE_XMLNODE_Text: { + CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; + ws.Replace(L"&", L"&"); + ws.Replace(L"<", L"<"); + ws.Replace(L">", L">"); + ws.Replace(L"\'", L"'"); + ws.Replace(L"\"", L"""); + pXMLStream->WriteString(ws, 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()); + } break; + case FDE_XMLNODE_Unknown: + break; + default: + break; + } +} +void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { + if (!m_pChild) { + return; + } + CFDE_XMLNode* pNext = m_pChild; + CFDE_XMLNode* pCloneNext = pNext->Clone(TRUE); + pClone->InsertChildNode(pCloneNext); + pNext = pNext->m_pNext; + while (pNext) { + CFDE_XMLNode* pChild = pNext->Clone(TRUE); + pCloneNext->InsertNodeItem(IFDE_XMLNode::NextSibling, pChild); + pCloneNext = pChild; + pNext = pNext->m_pNext; + } +} +IFDE_XMLInstruction* IFDE_XMLInstruction::Create( + const CFX_WideString& wsTarget) { + return (IFDE_XMLInstruction*)new CFDE_XMLInstruction(wsTarget); +} +CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) + : m_wsTarget(wsTarget) { + FXSYS_assert(m_wsTarget.GetLength() > 0); +} +CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { + CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); + if (!pClone) { + return pClone; + } + pClone->m_Attributes.Copy(m_Attributes); + pClone->m_TargetData.Copy(m_TargetData); + if (bRecursive) { + CloneChildren(pClone); + } + return pClone; +} +int32_t CFDE_XMLInstruction::CountAttributes() const { + return m_Attributes.GetSize() / 2; +} +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); + for (int32_t i = 0; i < iCount; i += 2) { + if (index == 0) { + wsAttriName = m_Attributes[i]; + wsAttriValue = m_Attributes[i + 1]; + return TRUE; + } + index--; + } + return FALSE; +} +FX_BOOL CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { + int32_t iCount = m_Attributes.GetSize(); + for (int32_t i = 0; i < iCount; i += 2) { + if (m_Attributes[i].Compare(pwsAttriName) == 0) { + return TRUE; + } + } + return FALSE; +} +void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue) const { + int32_t iCount = m_Attributes.GetSize(); + for (int32_t i = 0; i < iCount; i += 2) { + if (m_Attributes[i].Compare(pwsAttriName) == 0) { + wsAttriValue = m_Attributes[i + 1]; + return; + } + } + wsAttriValue = pwsDefValue; +} +void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue) { + FXSYS_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) { + m_Attributes[i] = wsAttriName; + m_Attributes[i + 1] = wsAttriValue; + return; + } + } + m_Attributes.Add(wsAttriName); + m_Attributes.Add(wsAttriValue); +} +int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue) const { + 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 iDefValue; +} +void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, + int32_t iAttriValue) { + CFX_WideString wsValue; + wsValue.Format(L"%d", iAttriValue); + SetString(pwsAttriName, wsValue); +} +FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue) const { + 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 fDefValue; +} +void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fAttriValue) { + CFX_WideString wsValue; + wsValue.Format(L"%f", fAttriValue); + SetString(pwsAttriName, wsValue); +} +void CFDE_XMLInstruction::RemoveAttribute(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) { + m_Attributes.RemoveAt(i + 1); + m_Attributes.RemoveAt(i); + return; + } + } +} +int32_t CFDE_XMLInstruction::CountData() const { + return m_TargetData.GetSize(); +} +FX_BOOL CFDE_XMLInstruction::GetData(int32_t index, + CFX_WideString& wsData) const { + if (index < 0 || index >= m_TargetData.GetSize()) { + return FALSE; + } + wsData = m_TargetData[index]; + return TRUE; +} +void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { + m_TargetData.Add(wsData); +} +void CFDE_XMLInstruction::RemoveData(int32_t index) { + m_TargetData.RemoveAt(index); +} +IFDE_XMLElement* IFDE_XMLElement::Create(const CFX_WideString& wsTag) { + return (IFDE_XMLElement*)new CFDE_XMLElement(wsTag); +} +CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) + : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() { + FXSYS_assert(m_wsTag.GetLength() > 0); +} +CFDE_XMLElement::~CFDE_XMLElement() { + m_Attributes.RemoveAll(); +} +CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { + CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag); + if (!pClone) { + return NULL; + } + pClone->m_Attributes.Copy(m_Attributes); + if (bRecursive) { + CloneChildren(pClone); + } else { + CFX_WideString wsText; + CFDE_XMLNode* pChild = m_pChild; + while (pChild != NULL) { + switch (pChild->GetType()) { + case FDE_XMLNODE_Text: + wsText += ((CFDE_XMLText*)pChild)->m_wsText; + break; + default: + break; + } + pChild = pChild->m_pNext; + } + pClone->SetTextData(wsText); + } + return pClone; +} +void CFDE_XMLElement::GetTagName(CFX_WideString& wsTag) const { + wsTag = m_wsTag; +} +void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { + FX_STRSIZE iFind = m_wsTag.Find(L':', 0); + if (iFind < 0) { + wsTag = m_wsTag; + } else { + wsTag = m_wsTag.Right(m_wsTag.GetLength() - iFind - 1); + } +} +void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { + FX_STRSIZE iFind = m_wsTag.Find(L':', 0); + if (iFind < 0) { + wsPrefix.Empty(); + } else { + wsPrefix = m_wsTag.Left(iFind); + } +} +void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { + CFX_WideString wsAttri(L"xmlns"), wsPrefix; + GetNamespacePrefix(wsPrefix); + if (wsPrefix.GetLength() > 0) { + wsAttri += L":"; + wsAttri += wsPrefix; + } + wsNamespace.Empty(); + 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)) { + pNode = pNode->GetNodeItem(IFDE_XMLNode::Parent); + continue; + } + pElement->GetString(wsAttri, wsNamespace); + break; + } +} +int32_t CFDE_XMLElement::CountAttributes() const { + return m_Attributes.GetSize() / 2; +} +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); + for (int32_t i = 0; i < iCount; i += 2) { + if (index == 0) { + wsAttriName = m_Attributes[i]; + wsAttriValue = m_Attributes[i + 1]; + return TRUE; + } + index--; + } + return FALSE; +} +FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { + int32_t iCount = m_Attributes.GetSize(); + for (int32_t i = 0; i < iCount; i += 2) { + if (m_Attributes[i].Compare(pwsAttriName) == 0) { + return TRUE; + } + } + return FALSE; +} +void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue) const { + int32_t iCount = m_Attributes.GetSize(); + for (int32_t i = 0; i < iCount; i += 2) { + if (m_Attributes[i].Compare(pwsAttriName) == 0) { + wsAttriValue = m_Attributes[i + 1]; + return; + } + } + wsAttriValue = pwsDefValue; +} +void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue) { + FXSYS_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) { + m_Attributes[i] = wsAttriName; + m_Attributes[i + 1] = wsAttriValue; + return; + } + } + m_Attributes.Add(wsAttriName); + m_Attributes.Add(wsAttriValue); +} +int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue) const { + 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 iDefValue; +} +void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, + int32_t iAttriValue) { + CFX_WideString wsValue; + wsValue.Format(L"%d", iAttriValue); + SetString(pwsAttriName, wsValue); +} +FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue) const { + 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 fDefValue; +} +void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fAttriValue) { + CFX_WideString wsValue; + wsValue.Format(L"%f", fAttriValue); + SetString(pwsAttriName, wsValue); +} +void CFDE_XMLElement::RemoveAttribute(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) { + m_Attributes.RemoveAt(i + 1); + m_Attributes.RemoveAt(i); + return; + } + } +} +void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { + CFX_WideTextBuf buffer; + CFDE_XMLNode* pChild = m_pChild; + while (pChild != NULL) { + switch (pChild->GetType()) { + case FDE_XMLNODE_Text: + buffer << ((CFDE_XMLText*)pChild)->m_wsText; + break; + case FDE_XMLNODE_CharData: + buffer << ((CFDE_XMLCharData*)pChild)->m_wsCharData; + break; + default: + break; + } + pChild = pChild->m_pNext; + } + wsText = buffer.GetWideString(); +} +void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { + if (wsText.GetLength() < 1) { + return; + } + InsertChildNode(new CFDE_XMLText(wsText)); +} +IFDE_XMLText* IFDE_XMLText::Create(const CFX_WideString& wsText) { + return (IFDE_XMLText*)new CFDE_XMLText(wsText); +} +CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) + : CFDE_XMLNode(), m_wsText(wsText) {} +CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { + CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); + return pClone; +} +IFDE_XMLCharData* IFDE_XMLCharData::Create(const CFX_WideString& wsCData) { + return (IFDE_XMLCharData*)new CFDE_XMLCharData(wsCData); +} +CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) + : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} +CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { + CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); + return pClone; +} +IFDE_XMLDoc* IFDE_XMLDoc::Create() { + return (IFDE_XMLDoc*)new CFDE_XMLDoc; +} +CFDE_XMLDoc::CFDE_XMLDoc() + : m_pRoot(NULL), m_pSyntaxParser(NULL), m_pXMLParser(NULL) { + Reset(TRUE); + CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml"); + m_pRoot->InsertChildNode(pXML); +} +CFDE_XMLDoc::~CFDE_XMLDoc() { + Reset(FALSE); +} +void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { + m_iStatus = 0; + m_pStream = NULL; + if (bInitRoot) { + if (m_pRoot == NULL) { + m_pRoot = new CFDE_XMLNode; + } else { + m_pRoot->DeleteChildren(); + } + } else { + if (m_pRoot != NULL) { + m_pRoot->Release(); + m_pRoot = NULL; + } + } + ReleaseParser(); +} +void CFDE_XMLDoc::ReleaseParser() { + if (m_pXMLParser != NULL) { + m_pXMLParser->Release(); + m_pXMLParser = NULL; + } + if (m_pSyntaxParser != NULL) { + m_pSyntaxParser->Release(); + m_pSyntaxParser = NULL; + } +} +FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, + int32_t iXMLPlaneSize, + int32_t iTextDataSize, + FDE_XMLREADERHANDLER* pHandler) { + if (pXMLStream == NULL) { + return FALSE; + } + Reset(TRUE); + iXMLPlaneSize = iXMLPlaneSize / 1024; + if (iXMLPlaneSize < 1) { + iXMLPlaneSize = 1; + } + iXMLPlaneSize *= 1024; + if (iXMLPlaneSize < 4096) { + iXMLPlaneSize = 4096; + } + iTextDataSize = iTextDataSize / 128; + if (iTextDataSize < 1) { + iTextDataSize = 1; + } + iTextDataSize *= 128; + if (iTextDataSize < 128) { + iTextDataSize = 128; + } + m_pStream = pXMLStream; + FX_WORD wCodePage = m_pStream->GetCodePage(); + if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && + wCodePage != FX_CODEPAGE_UTF8) { + m_pStream->SetCodePage(FX_CODEPAGE_UTF8); + } + m_pSyntaxParser = IFDE_XMLSyntaxParser::Create(); + if (m_pSyntaxParser == NULL) { + return FALSE; + } + m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize); + if (pHandler == NULL) { + m_pXMLParser = new CFDE_XMLDOMParser(m_pRoot, m_pSyntaxParser); + } else { + m_pXMLParser = new CFDE_XMLSAXParser(pHandler, m_pSyntaxParser); + } + return TRUE; +} +FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) { + if (pXMLParser == NULL) { + return FALSE; + } + Reset(TRUE); + m_pXMLParser = pXMLParser; + return m_pXMLParser != NULL; +} +int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { + if (m_iStatus >= 100) { + return m_iStatus; + } + FXSYS_assert(m_pXMLParser != NULL); + return m_iStatus = m_pXMLParser->DoParser(pPause); +} +void CFDE_XMLDoc::CloseXML() { + ReleaseParser(); +} +void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) { + CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; + FXSYS_assert(pXMLStream != NULL && pNode != NULL); + switch (pNode->GetType()) { + case FDE_XMLNODE_Instruction: { + CFX_WideString ws; + CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; + if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { + ws = L"<?xml version=\"1.0\" encoding=\""; + FX_WORD wCodePage = pXMLStream->GetCodePage(); + if (wCodePage == FX_CODEPAGE_UTF16LE) { + ws += L"UTF-16"; + } else if (wCodePage == FX_CODEPAGE_UTF16BE) { + ws += L"UTF-16be"; + } else { + ws += L"UTF-8"; + } + ws += L"\"?>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } else { + ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); + pXMLStream->WriteString(ws, ws.GetLength()); + CFX_WideStringArray& attributes = pInstruction->m_Attributes; + int32_t i, iCount = attributes.GetSize(); + CFX_WideString wsValue; + for (i = 0; i < iCount; i += 2) { + ws = L" "; + ws += attributes[i]; + ws += L"=\""; + wsValue = attributes[i + 1]; + wsValue.Replace(L"&", L"&"); + wsValue.Replace(L"<", L"<"); + wsValue.Replace(L">", L">"); + wsValue.Replace(L"\'", L"'"); + wsValue.Replace(L"\"", L"""); + ws += wsValue; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + CFX_WideStringArray& targetdata = pInstruction->m_TargetData; + iCount = targetdata.GetSize(); + for (i = 0; i < iCount; i++) { + ws = L" \""; + ws += targetdata[i]; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + ws = L"?>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } + } break; + case FDE_XMLNODE_Element: { + CFX_WideString ws; + ws = L"<"; + ws += ((CFDE_XMLElement*)pNode)->m_wsTag; + pXMLStream->WriteString(ws, ws.GetLength()); + CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; + int32_t iCount = attributes.GetSize(); + CFX_WideString wsValue; + for (int32_t i = 0; i < iCount; i += 2) { + ws = L" "; + ws += attributes[i]; + ws += L"=\""; + wsValue = attributes[i + 1]; + wsValue.Replace(L"&", L"&"); + wsValue.Replace(L"<", L"<"); + wsValue.Replace(L">", L">"); + wsValue.Replace(L"\'", L"'"); + wsValue.Replace(L"\"", L"""); + ws += wsValue; + ws += L"\""; + pXMLStream->WriteString(ws, ws.GetLength()); + } + if (pNode->m_pChild == NULL) { + ws = L"\n/>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } else { + ws = L"\n>"; + pXMLStream->WriteString(ws, ws.GetLength()); + CFDE_XMLNode* pChild = pNode->m_pChild; + while (pChild != NULL) { + SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pChild); + pChild = pChild->m_pNext; + } + ws = L"</"; + ws += ((CFDE_XMLElement*)pNode)->m_wsTag; + ws += L"\n>"; + pXMLStream->WriteString(ws, ws.GetLength()); + } + } break; + case FDE_XMLNODE_Text: { + CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; + ws.Replace(L"&", L"&"); + ws.Replace(L"<", L"<"); + ws.Replace(L">", L">"); + ws.Replace(L"\'", L"'"); + ws.Replace(L"\"", L"""); + pXMLStream->WriteString(ws, 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()); + } break; + case FDE_XMLNODE_Unknown: + break; + default: + break; + } +} +void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { + if (pXMLStream == NULL || pXMLStream == m_pStream) { + 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); + FX_WORD wCodePage = pXMLStream->GetCodePage(); + if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && + wCodePage != FX_CODEPAGE_UTF8) { + wCodePage = FX_CODEPAGE_UTF8; + pXMLStream->SetCodePage(wCodePage); + } + if (bSaveBOM) { + pXMLStream->WriteString(L"\xFEFF", 1); + } + CFDE_XMLNode* pNode = m_pRoot->m_pChild; + while (pNode != NULL) { + SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pNode); + pNode = pNode->m_pNext; + } + if (pXMLStream == m_pStream) { + int32_t iPos = pXMLStream->GetPosition(); + pXMLStream->SetLength(iPos); + } +} +CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, + IFDE_XMLSyntaxParser* pParser) + : m_pParser(pParser), + m_pParent(pRoot), + m_pChild(NULL), + m_NodeStack(16), + m_ws1(), + m_ws2() { + m_NodeStack.Push(m_pParent); +} +CFDE_XMLDOMParser::~CFDE_XMLDOMParser() { + m_NodeStack.RemoveAll(); + m_ws1.Empty(); + m_ws2.Empty(); +} +int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) { + FX_DWORD dwRet; + int32_t iCount = 0; + while (TRUE) { + dwRet = m_pParser->DoSyntaxParse(); + switch (dwRet) { + case FDE_XMLSYNTAXSTATUS_InstructionOpen: + break; + case FDE_XMLSYNTAXSTATUS_InstructionClose: + if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_ElementOpen: + case FDE_XMLSYNTAXSTATUS_ElementBreak: + break; + case FDE_XMLSYNTAXSTATUS_ElementClose: + if (m_pChild->GetType() != FDE_XMLNODE_Element) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pParser->GetTagName(m_ws1); + ((CFDE_XMLElement*)m_pChild)->GetTagName(m_ws2); + if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_ws2) != 0) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_NodeStack.Pop(); + if (m_NodeStack.GetSize() < 1) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pParent = (CFDE_XMLNode*)*m_NodeStack.GetTopElement(); + m_pChild = m_pParent; + iCount++; + break; + case FDE_XMLSYNTAXSTATUS_TargetName: + m_pParser->GetTargetName(m_ws1); + m_pChild = new CFDE_XMLInstruction(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_ws1.Empty(); + break; + case FDE_XMLSYNTAXSTATUS_TagName: + m_pParser->GetTagName(m_ws1); + m_pChild = new CFDE_XMLElement(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_NodeStack.Push(m_pChild); + m_pParent = m_pChild; + break; + case FDE_XMLSYNTAXSTATUS_AttriName: + m_pParser->GetAttributeName(m_ws1); + break; + case FDE_XMLSYNTAXSTATUS_AttriValue: + if (m_pChild == NULL) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pParser->GetAttributeName(m_ws2); + if (m_pChild->GetType() == FDE_XMLNODE_Element) { + ((CFDE_XMLElement*)m_pChild)->SetString(m_ws1, m_ws2); + } else if (m_pChild->GetType() == FDE_XMLNODE_Instruction) { + ((CFDE_XMLInstruction*)m_pChild)->SetString(m_ws1, m_ws2); + } + m_ws1.Empty(); + break; + case FDE_XMLSYNTAXSTATUS_Text: + m_pParser->GetTextData(m_ws1); + m_pChild = new CFDE_XMLText(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_CData: + m_pParser->GetTextData(m_ws1); + m_pChild = new CFDE_XMLCharData(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_TargetData: + if (m_pChild == NULL || + m_pChild->GetType() != FDE_XMLNODE_Instruction) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + if (!m_ws1.IsEmpty()) { + ((CFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + } + m_pParser->GetTargetData(m_ws1); + ((CFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + m_ws1.Empty(); + break; + default: + break; + } + if (dwRet == FDE_XMLSYNTAXSTATUS_Error || + dwRet == FDE_XMLSYNTAXSTATUS_EOS) { + break; + } + if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) { + break; + } + } + return m_pParser->GetStatus(); +} +CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, + IFDE_XMLSyntaxParser* pParser) + : m_pHandler(pHandler), + m_pParser(pParser), + m_TagStack(16), + m_pTagTop(NULL), + m_ws1(), + m_ws2() {} +CFDE_XMLSAXParser::~CFDE_XMLSAXParser() { + m_TagStack.RemoveAll(); + m_ws1.Empty(); + m_ws2.Empty(); +} +int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) { + FX_DWORD dwRet = 0; + int32_t iCount = 0; + while (TRUE) { + dwRet = m_pParser->DoSyntaxParse(); + switch (dwRet) { + case FDE_XMLSYNTAXSTATUS_ElementBreak: + if (m_pTagTop == NULL) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + if (m_pTagTop->eType == FDE_XMLNODE_Element) { + m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName); + } + break; + case FDE_XMLSYNTAXSTATUS_ElementClose: + if (m_pTagTop == NULL || m_pTagTop->eType != FDE_XMLNODE_Element) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pParser->GetTagName(m_ws1); + if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_pTagTop->wsTagName) != 0) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } else if (m_ws1.GetLength() == 0) { + m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName); + } + m_pHandler->OnTagClose(m_pHandler, m_pTagTop->wsTagName); + Pop(); + iCount++; + break; + case FDE_XMLSYNTAXSTATUS_TargetName: { + m_pParser->GetTargetName(m_ws1); + CFDE_XMLTAG xmlTag; + xmlTag.wsTagName = m_ws1; + xmlTag.eType = FDE_XMLNODE_Instruction; + Push(xmlTag); + m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Instruction, + m_pTagTop->wsTagName); + m_ws1.Empty(); + } break; + case FDE_XMLSYNTAXSTATUS_TagName: { + m_pParser->GetTargetName(m_ws1); + CFDE_XMLTAG xmlTag; + xmlTag.wsTagName = m_ws1; + xmlTag.eType = FDE_XMLNODE_Element; + Push(xmlTag); + m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Element, + m_pTagTop->wsTagName); + } break; + case FDE_XMLSYNTAXSTATUS_AttriName: + m_pParser->GetTargetName(m_ws1); + break; + case FDE_XMLSYNTAXSTATUS_AttriValue: + m_pParser->GetAttributeName(m_ws2); + if (m_pTagTop == NULL) { + dwRet = FDE_XMLSYNTAXSTATUS_Error; + break; + } + if (m_pTagTop->eType == FDE_XMLNODE_Element) { + m_pHandler->OnAttribute(m_pHandler, m_ws1, m_ws2); + } + m_ws1.Empty(); + break; + case FDE_XMLSYNTAXSTATUS_CData: + m_pParser->GetTextData(m_ws1); + m_pHandler->OnData(m_pHandler, FDE_XMLNODE_CharData, m_ws1); + break; + case FDE_XMLSYNTAXSTATUS_Text: + m_pParser->GetTextData(m_ws1); + m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Text, m_ws1); + break; + case FDE_XMLSYNTAXSTATUS_TargetData: + m_pParser->GetTargetData(m_ws1); + m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Instruction, m_ws1); + m_ws1.Empty(); + break; + default: + break; + } + if (dwRet == FDE_XMLSYNTAXSTATUS_Error || + dwRet == FDE_XMLSYNTAXSTATUS_EOS) { + break; + } + if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) { + break; + } + } + return m_pParser->GetStatus(); +} +inline void CFDE_XMLSAXParser::Push(const CFDE_XMLTAG& xmlTag) { + m_TagStack.Push(xmlTag); + m_pTagTop = m_TagStack.GetTopElement(); +} +inline void CFDE_XMLSAXParser::Pop() { + m_TagStack.Pop(); + m_pTagTop = m_TagStack.GetTopElement(); +} + +CFDE_BlockBuffer::CFDE_BlockBuffer(int32_t iAllocStep) + : m_iDataLength(0), + m_iBufferSize(0), + m_iAllocStep(iAllocStep), + m_iStartPosition(0) {} +CFDE_BlockBuffer::~CFDE_BlockBuffer() { + ClearBuffer(); +} +FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { + iIndexInBlock = 0; + if (!m_BlockArray.GetSize()) { + return nullptr; + } + int32_t iRealIndex = m_iStartPosition + m_iDataLength; + if (iRealIndex == m_iBufferSize) { + FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); + m_BlockArray.Add(pBlock); + m_iBufferSize += m_iAllocStep; + return pBlock; + } + iIndexInBlock = iRealIndex % m_iAllocStep; + return (FX_WCHAR*)m_BlockArray[iRealIndex / m_iAllocStep]; +} +FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { + ClearBuffer(); + int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1; + for (int32_t i = 0; i < iNumOfBlock; i++) { + m_BlockArray.Add(FX_Alloc(FX_WCHAR, m_iAllocStep)); + } + m_iBufferSize = iNumOfBlock * m_iAllocStep; + return TRUE; +} +void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { + if (iIndex < 0) { + return; + } + int32_t iRealIndex = m_iStartPosition + iIndex; + int32_t iBlockIndex = iRealIndex / m_iAllocStep; + int32_t iInnerIndex = iRealIndex % m_iAllocStep; + int32_t iBlockSize = m_BlockArray.GetSize(); + if (iBlockIndex >= iBlockSize) { + int32_t iNewBlocks = iBlockIndex - iBlockSize + 1; + do { + FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); + m_BlockArray.Add(pBlock); + m_iBufferSize += m_iAllocStep; + } while (--iNewBlocks); + } + FX_WCHAR* pTextData = (FX_WCHAR*)m_BlockArray[iBlockIndex]; + *(pTextData + iInnerIndex) = ch; + if (m_iDataLength <= iIndex) { + m_iDataLength = iIndex + 1; + } +} +int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) { + if (iCount <= 0) { + return m_iDataLength; + } + if (iCount >= m_iDataLength) { + Reset(FALSE); + return 0; + } + if (bDirection) { + m_iStartPosition += iCount; + m_iDataLength -= iCount; + } else { + m_iDataLength -= iCount; + } + return m_iDataLength; +} +void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, + int32_t iStart, + int32_t iLength) const { + wsTextData.Empty(); + int32_t iMaybeDataLength = m_iBufferSize - 1 - m_iStartPosition; + if (iStart < 0 || iStart > iMaybeDataLength) { + return; + } + if (iLength == -1 || iLength > iMaybeDataLength) { + iLength = iMaybeDataLength; + } + if (iLength <= 0) { + return; + } + FX_WCHAR* pBuf = wsTextData.GetBuffer(iLength); + if (!pBuf) { + return; + } + int32_t iStartBlockIndex = 0; + int32_t iStartInnerIndex = 0; + TextDataIndex2BufIndex(iStart, iStartBlockIndex, iStartInnerIndex); + int32_t iEndBlockIndex = 0; + int32_t iEndInnerIndex = 0; + TextDataIndex2BufIndex(iStart + iLength, iEndBlockIndex, iEndInnerIndex); + int32_t iPointer = 0; + for (int32_t i = iStartBlockIndex; i <= iEndBlockIndex; i++) { + int32_t iBufferPointer = 0; + int32_t iCopyLength = m_iAllocStep; + if (i == iStartBlockIndex) { + iCopyLength -= iStartInnerIndex; + iBufferPointer = iStartInnerIndex; + } + if (i == iEndBlockIndex) { + iCopyLength -= ((m_iAllocStep - 1) - iEndInnerIndex); + } + FX_WCHAR* pBlockBuf = (FX_WCHAR*)m_BlockArray[i]; + FXSYS_memcpy(pBuf + iPointer, pBlockBuf + iBufferPointer, + iCopyLength * sizeof(FX_WCHAR)); + iPointer += iCopyLength; + } + wsTextData.ReleaseBuffer(iLength); +} +void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, + int32_t& iBlockIndex, + int32_t& iInnerIndex) const { + FXSYS_assert(iIndex >= 0); + int32_t iRealIndex = m_iStartPosition + iIndex; + iBlockIndex = iRealIndex / m_iAllocStep; + iInnerIndex = iRealIndex % m_iAllocStep; +} +void CFDE_BlockBuffer::ClearBuffer() { + m_iBufferSize = 0; + 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(); +} + +IFDE_XMLSyntaxParser* IFDE_XMLSyntaxParser::Create() { + return new CFDE_XMLSyntaxParser; +} + +CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser() + : m_pStream(nullptr), + m_iXMLPlaneSize(-1), + m_iCurrentPos(0), + m_iCurrentNodeNum(-1), + m_iLastNodeNum(-1), + m_iParsedChars(0), + m_iParsedBytes(0), + m_pBuffer(nullptr), + m_iBufferChars(0), + m_bEOS(FALSE), + m_pStart(nullptr), + m_pEnd(nullptr), + m_XMLNodeStack(16), + m_iAllocStep(m_BlockBuffer.GetAllocStep()), + m_iDataLength(m_BlockBuffer.GetDataLengthRef()), + m_pCurrentBlock(nullptr), + m_iIndexInBlock(0), + m_iTextDataLength(0), + m_dwStatus(FDE_XMLSYNTAXSTATUS_None), + m_dwMode(FDE_XMLSYNTAXMODE_Text), + m_wQuotationMark(0), + m_iEntityStart(-1), + m_SkipStack(16) { + m_CurNode.iNodeNum = -1; + m_CurNode.eNodeType = FDE_XMLNODE_Unknown; +} +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); + int32_t iStreamLength = pStream->GetLength(); + FXSYS_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); + m_pStart = m_pEnd = m_pBuffer; + FXSYS_assert(!m_BlockBuffer.IsInitialized()); + m_BlockBuffer.InitBuffer(); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_iParsedBytes = m_iParsedChars = 0; + m_iBufferChars = 0; +} +FX_DWORD CFDE_XMLSyntaxParser::DoSyntaxParse() { + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || + m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { + return m_dwStatus; + } + FXSYS_assert(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized()); + int32_t iStreamLength = m_pStream->GetLength(); + int32_t iPos; + FX_WCHAR ch; + FX_DWORD dwStatus = FDE_XMLSYNTAXSTATUS_None; + while (TRUE) { + if (m_pStart >= m_pEnd) { + if (m_bEOS || m_iCurrentPos >= iStreamLength) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS; + return m_dwStatus; + } + m_iParsedChars += (m_pEnd - m_pBuffer); + m_iParsedBytes = m_iCurrentPos; + if (m_pStream->GetPosition() != m_iCurrentPos) { + m_pStream->Seek(FX_STREAMSEEK_Begin, m_iCurrentPos); + } + m_iBufferChars = + m_pStream->ReadString(m_pBuffer, m_iXMLPlaneSize, m_bEOS); + iPos = m_pStream->GetPosition(); + if (m_iBufferChars < 1) { + m_iCurrentPos = iStreamLength; + m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS; + return m_dwStatus; + } + m_iCurrentPos = iPos; + m_pStart = m_pBuffer; + m_pEnd = m_pBuffer + m_iBufferChars; + } + while (m_pStart < m_pEnd) { + ch = *m_pStart; + switch (m_dwMode) { + case FDE_XMLSYNTAXMODE_Text: + if (ch == L'<') { + if (m_iDataLength > 0) { + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_iEntityStart = -1; + dwStatus = FDE_XMLSYNTAXSTATUS_Text; + } else { + m_pStart++; + m_dwMode = FDE_XMLSYNTAXMODE_Node; + } + } else { + ParseTextChar(ch); + } + break; + case FDE_XMLSYNTAXMODE_Node: + if (ch == L'!') { + m_pStart++; + m_dwMode = FDE_XMLSYNTAXMODE_SkipCommentOrDecl; + } else if (ch == L'/') { + m_pStart++; + m_dwMode = FDE_XMLSYNTAXMODE_CloseElement; + } else if (ch == L'?') { + m_iLastNodeNum++; + m_iCurrentNodeNum = m_iLastNodeNum; + m_CurNode.iNodeNum = m_iLastNodeNum; + m_CurNode.eNodeType = FDE_XMLNODE_Instruction; + m_XMLNodeStack.Push(m_CurNode); + m_pStart++; + m_dwMode = FDE_XMLSYNTAXMODE_Target; + dwStatus = FDE_XMLSYNTAXSTATUS_InstructionOpen; + } else { + m_iLastNodeNum++; + m_iCurrentNodeNum = m_iLastNodeNum; + m_CurNode.iNodeNum = m_iLastNodeNum; + m_CurNode.eNodeType = FDE_XMLNODE_Element; + m_XMLNodeStack.Push(m_CurNode); + m_dwMode = FDE_XMLSYNTAXMODE_Tag; + dwStatus = FDE_XMLSYNTAXSTATUS_ElementOpen; + } + break; + case FDE_XMLSYNTAXMODE_Target: + case FDE_XMLSYNTAXMODE_Tag: + if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { + if (m_iDataLength < 1) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } else { + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (m_dwMode != FDE_XMLSYNTAXMODE_Target) { + dwStatus = FDE_XMLSYNTAXSTATUS_TagName; + } else { + dwStatus = FDE_XMLSYNTAXSTATUS_TargetName; + } + m_dwMode = FDE_XMLSYNTAXMODE_AttriName; + } + } else { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + m_pStart++; + } + break; + case FDE_XMLSYNTAXMODE_AttriName: + if (m_iDataLength < 1 && FDE_IsXMLWhiteSpace(ch)) { + m_pStart++; + break; + } + if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { + if (m_iDataLength < 1) { + if (m_CurNode.eNodeType == FDE_XMLNODE_Element) { + if (ch == L'>' || ch == L'/') { + m_dwMode = FDE_XMLSYNTAXMODE_BreakElement; + break; + } + } else if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { + if (ch == L'?') { + m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction; + m_pStart++; + } else { + m_dwMode = FDE_XMLSYNTAXMODE_TargetData; + } + break; + } + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } else { + if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { + if (ch != '=' && !FDE_IsXMLWhiteSpace(ch)) { + m_dwMode = FDE_XMLSYNTAXMODE_TargetData; + break; + } + } + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_dwMode = FDE_XMLSYNTAXMODE_AttriEqualSign; + dwStatus = FDE_XMLSYNTAXSTATUS_AttriName; + } + } else { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + m_pStart++; + } + break; + case FDE_XMLSYNTAXMODE_AttriEqualSign: + if (FDE_IsXMLWhiteSpace(ch)) { + m_pStart++; + break; + } + if (ch != L'=') { + if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { + m_dwMode = FDE_XMLSYNTAXMODE_TargetData; + break; + } + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } else { + m_dwMode = FDE_XMLSYNTAXMODE_AttriQuotation; + m_pStart++; + } + break; + case FDE_XMLSYNTAXMODE_AttriQuotation: + if (FDE_IsXMLWhiteSpace(ch)) { + m_pStart++; + break; + } + if (ch != L'\"' && ch != L'\'') { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } else { + m_wQuotationMark = ch; + m_dwMode = FDE_XMLSYNTAXMODE_AttriValue; + m_pStart++; + } + break; + case FDE_XMLSYNTAXMODE_AttriValue: + if (ch == m_wQuotationMark) { + if (m_iEntityStart > -1) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + m_iTextDataLength = m_iDataLength; + m_wQuotationMark = 0; + m_BlockBuffer.Reset(); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_pStart++; + m_dwMode = FDE_XMLSYNTAXMODE_AttriName; + dwStatus = FDE_XMLSYNTAXSTATUS_AttriValue; + } else { + ParseTextChar(ch); + } + break; + case FDE_XMLSYNTAXMODE_CloseInstruction: + if (ch != L'>') { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + m_dwMode = FDE_XMLSYNTAXMODE_TargetData; + } else if (m_iDataLength > 0) { + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; + } else { + m_pStart++; + FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement(); + if (pXMLNode == NULL) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + m_XMLNodeStack.Pop(); + pXMLNode = m_XMLNodeStack.GetTopElement(); + if (pXMLNode == NULL) { + m_CurNode.iNodeNum = -1; + m_CurNode.eNodeType = FDE_XMLNODE_Unknown; + } else { + m_CurNode = *pXMLNode; + } + m_iCurrentNodeNum = m_CurNode.iNodeNum; + m_BlockBuffer.Reset(); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_dwMode = FDE_XMLSYNTAXMODE_Text; + dwStatus = FDE_XMLSYNTAXSTATUS_InstructionClose; + } + break; + case FDE_XMLSYNTAXMODE_BreakElement: + if (ch == L'>') { + m_dwMode = FDE_XMLSYNTAXMODE_Text; + dwStatus = FDE_XMLSYNTAXSTATUS_ElementBreak; + } else if (ch == L'/') { + m_dwMode = FDE_XMLSYNTAXMODE_CloseElement; + } else { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + m_pStart++; + break; + case FDE_XMLSYNTAXMODE_CloseElement: + if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { + if (ch == L'>') { + FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement(); + if (pXMLNode == NULL) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + m_XMLNodeStack.Pop(); + pXMLNode = m_XMLNodeStack.GetTopElement(); + if (pXMLNode == NULL) { + m_CurNode.iNodeNum = -1; + m_CurNode.eNodeType = FDE_XMLNODE_Unknown; + } else { + m_CurNode = *pXMLNode; + } + m_iCurrentNodeNum = m_CurNode.iNodeNum; + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_dwMode = FDE_XMLSYNTAXMODE_Text; + dwStatus = FDE_XMLSYNTAXSTATUS_ElementClose; + } else if (!FDE_IsXMLWhiteSpace(ch)) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + } else { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + } + m_pStart++; + break; + case FDE_XMLSYNTAXMODE_SkipCommentOrDecl: + if (ch == '-') { + m_dwMode = FDE_XMLSYNTAXMODE_SkipComment; + } else { + m_dwMode = FDE_XMLSYNTAXMODE_SkipDeclNode; + m_SkipChar = L'>'; + m_SkipStack.Push(L'>'); + } + break; + case FDE_XMLSYNTAXMODE_SkipDeclNode: + if (m_SkipChar == L'\'' || m_SkipChar == L'\"') { + m_pStart++; + if (ch != m_SkipChar) { + break; + } + m_SkipStack.Pop(); + FX_DWORD* pDWord = m_SkipStack.GetTopElement(); + if (pDWord == NULL) { + m_dwMode = FDE_XMLSYNTAXMODE_Text; + } else { + m_SkipChar = (FX_WCHAR)*pDWord; + } + } else { + switch (ch) { + case L'<': + m_SkipChar = L'>'; + m_SkipStack.Push(L'>'); + break; + case L'[': + m_SkipChar = L']'; + m_SkipStack.Push(L']'); + break; + case L'(': + m_SkipChar = L')'; + m_SkipStack.Push(L')'); + break; + case L'\'': + m_SkipChar = L'\''; + m_SkipStack.Push(L'\''); + break; + case L'\"': + m_SkipChar = L'\"'; + m_SkipStack.Push(L'\"'); + break; + default: + if (ch == m_SkipChar) { + m_SkipStack.Pop(); + FX_DWORD* pDWord = m_SkipStack.GetTopElement(); + if (pDWord == NULL) { + if (m_iDataLength >= 9) { + CFX_WideString wsHeader; + m_BlockBuffer.GetTextData(wsHeader, 0, 7); + if (wsHeader.Equal(FX_WSTRC(L"[CDATA["))) { + CFX_WideString wsTailer; + m_BlockBuffer.GetTextData(wsTailer, m_iDataLength - 2, + 2); + if (wsTailer.Equal(FX_WSTRC(L"]]"))) { + m_BlockBuffer.DeleteTextChars(7, TRUE); + m_BlockBuffer.DeleteTextChars(2, FALSE); + dwStatus = FDE_XMLSYNTAXSTATUS_CData; + } + } + } + m_iTextDataLength = m_iDataLength; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_dwMode = FDE_XMLSYNTAXMODE_Text; + } else { + m_SkipChar = (FX_WCHAR)*pDWord; + } + } + break; + } + if (m_SkipStack.GetSize() > 0) { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + } + m_pStart++; + } + break; + case FDE_XMLSYNTAXMODE_SkipComment: + if (ch == L'-') { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = L'-'; + m_iDataLength++; + } else if (ch == L'>') { + if (m_iDataLength > 1) { + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_dwMode = FDE_XMLSYNTAXMODE_Text; + } + } else { + m_BlockBuffer.Reset(); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + } + m_pStart++; + break; + case FDE_XMLSYNTAXMODE_TargetData: + if (FDE_IsXMLWhiteSpace(ch)) { + if (m_iDataLength < 1) { + m_pStart++; + break; + } else if (m_wQuotationMark == 0) { + m_iTextDataLength = m_iDataLength; + m_wQuotationMark = 0; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_pStart++; + dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; + break; + } + } + if (ch == '?') { + m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction; + m_pStart++; + } else if (ch == '\"') { + if (m_wQuotationMark == 0) { + m_wQuotationMark = ch; + m_pStart++; + } else if (ch == m_wQuotationMark) { + m_iTextDataLength = m_iDataLength; + m_wQuotationMark = 0; + m_BlockBuffer.Reset(); + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_pStart++; + dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; + } else { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + return m_dwStatus; + } + } else { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = + m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return FDE_XMLSYNTAXSTATUS_Error; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + m_pStart++; + } + break; + default: + break; + } + if (dwStatus != FDE_XMLSYNTAXSTATUS_None) { + return dwStatus; + } + } + } + return 0; +} + +CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() { + if (m_pCurrentBlock) { + m_pCurrentBlock = NULL; + } + FX_Free(m_pBuffer); +} + +int32_t CFDE_XMLSyntaxParser::GetStatus() const { + if (m_pStream == NULL) { + return -1; + } + int32_t iStreamLength = m_pStream->GetLength(); + if (iStreamLength < 1) { + return 100; + } + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) { + return -1; + } + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { + return 100; + } + return m_iParsedBytes * 100 / iStreamLength; +} +static int32_t FX_GetUTF8EncodeLength(const FX_WCHAR* pSrc, int32_t iSrcLen) { + FX_DWORD unicode = 0; + int32_t iDstNum = 0; + while (iSrcLen-- > 0) { + unicode = *pSrc++; + int nbytes = 0; + if ((FX_DWORD)unicode < 0x80) { + nbytes = 1; + } else if ((FX_DWORD)unicode < 0x800) { + nbytes = 2; + } else if ((FX_DWORD)unicode < 0x10000) { + nbytes = 3; + } else if ((FX_DWORD)unicode < 0x200000) { + nbytes = 4; + } else if ((FX_DWORD)unicode < 0x4000000) { + nbytes = 5; + } else { + nbytes = 6; + } + iDstNum += nbytes; + } + return iDstNum; +} +FX_FILESIZE CFDE_XMLSyntaxParser::GetCurrentBinaryPos() const { + if (m_pStream == NULL) { + return 0; + } + int32_t nSrcLen = m_pStart - m_pBuffer; + int32_t nDstLen = FX_GetUTF8EncodeLength(m_pBuffer, nSrcLen); + return m_iParsedBytes + nDstLen; +} + +void CFDE_XMLSyntaxParser::ParseTextChar(FX_WCHAR ch) { + if (m_iIndexInBlock == m_iAllocStep) { + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + if (!m_pCurrentBlock) { + return; + } + } + m_pCurrentBlock[m_iIndexInBlock++] = ch; + m_iDataLength++; + if (m_iEntityStart > -1 && ch == L';') { + CFX_WideString csEntity; + m_BlockBuffer.GetTextData(csEntity, m_iEntityStart + 1, + (m_iDataLength - 1) - m_iEntityStart - 1); + int32_t iLen = csEntity.GetLength(); + if (iLen > 0) { + if (csEntity[0] == L'#') { + ch = 0; + FX_WCHAR w; + if (iLen > 1 && csEntity[1] == L'x') { + for (int32_t i = 2; i < iLen; i++) { + w = csEntity[i]; + if (w >= L'0' && w <= L'9') { + ch = (ch << 4) + w - L'0'; + } else if (w >= L'A' && w <= L'F') { + ch = (ch << 4) + w - 55; + } else if (w >= L'a' && w <= L'f') { + ch = (ch << 4) + w - 87; + } else { + break; + } + } + } else { + for (int32_t i = 1; i < iLen; i++) { + w = csEntity[i]; + if (w < L'0' || w > L'9') { + break; + } + ch = ch * 10 + w - L'0'; + } + } + if (ch != 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, ch); + m_iEntityStart++; + } + } else { + if (csEntity.Compare(L"amp") == 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, L'&'); + m_iEntityStart++; + } else if (csEntity.Compare(L"lt") == 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, L'<'); + m_iEntityStart++; + } else if (csEntity.Compare(L"gt") == 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, L'>'); + m_iEntityStart++; + } else if (csEntity.Compare(L"apos") == 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, L'\''); + m_iEntityStart++; + } else if (csEntity.Compare(L"quot") == 0) { + m_BlockBuffer.SetTextChar(m_iEntityStart, L'\"'); + m_iEntityStart++; + } + } + } + m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); + m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); + m_iEntityStart = -1; + } else { + if (m_iEntityStart < 0 && ch == L'&') { + m_iEntityStart = m_iDataLength - 1; + } + } + m_pStart++; +} diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h new file mode 100644 index 0000000000..79d77d93eb --- /dev/null +++ b/xfa/fde/xml/fde_xml_imp.h @@ -0,0 +1,354 @@ +// 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_XML_FDE_XML_IMP_H_ +#define XFA_FDE_XML_FDE_XML_IMP_H_ + +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fde/xml/fde_xml.h" +#include "xfa/fgas/crt/fgas_memory.h" +#include "xfa/fgas/crt/fgas_stream.h" + +class CFDE_BlockBuffer; +class CFDE_XMLInstruction; +class CFDE_XMLElement; +class CFDE_XMLText; +class CFDE_XMLDoc; +class IFDE_XMLParser; +class CFDE_XMLDOMParser; +class CFDE_XMLSAXParser; +class CFDE_XMLSyntaxParser; + +class CFDE_XMLNode : public CFX_Target { + public: + CFDE_XMLNode(); + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } + virtual int32_t CountChildNodes() const; + virtual CFDE_XMLNode* GetChildNode(int32_t index) const; + virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; + virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, + int32_t iLength = -1, + FX_BOOL bQualifiedName = TRUE) const; + virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); + virtual void RemoveChildNode(CFDE_XMLNode* pNode); + virtual void DeleteChildren(); + virtual CFDE_XMLNode* GetNodeItem(IFDE_XMLNode::NodeItem eItem) const; + virtual int32_t GetNodeLevel() const; + virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem, + CFDE_XMLNode* pNode); + virtual CFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem); + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); + virtual void SaveXMLNode(IFX_Stream* pXMLStream); + + public: + ~CFDE_XMLNode(); + void CloneChildren(CFDE_XMLNode* pClone); + CFDE_XMLNode* m_pParent; + CFDE_XMLNode* m_pChild; + CFDE_XMLNode* m_pPrior; + CFDE_XMLNode* m_pNext; +}; +class CFDE_XMLInstruction : public CFDE_XMLNode { + public: + CFDE_XMLInstruction(const CFX_WideString& wsTarget); + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); + virtual void GetTargetName(CFX_WideString& wsTarget) const { + wsTarget = m_wsTarget; + } + virtual int32_t CountAttributes() const; + virtual FX_BOOL GetAttribute(int32_t index, + CFX_WideString& wsAttriName, + CFX_WideString& wsAttriValue) const; + virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; + virtual void GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue = NULL) const; + virtual void SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue); + virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue = 0) const; + virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); + virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue = 0) const; + virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); + virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); + virtual int32_t CountData() const; + virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; + virtual void AppendData(const CFX_WideString& wsData); + virtual void RemoveData(int32_t index); + + public: + ~CFDE_XMLInstruction() {} + CFX_WideString m_wsTarget; + CFX_WideStringArray m_Attributes; + CFX_WideStringArray m_TargetData; +}; +class CFDE_XMLElement : public CFDE_XMLNode { + public: + CFDE_XMLElement(const CFX_WideString& wsTag); + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); + virtual void GetTagName(CFX_WideString& wsTag) const; + virtual void GetLocalTagName(CFX_WideString& wsTag) const; + virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; + virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const; + virtual int32_t CountAttributes() const; + virtual FX_BOOL GetAttribute(int32_t index, + CFX_WideString& wsAttriName, + CFX_WideString& wsAttriValue) const; + virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; + virtual void GetString(const FX_WCHAR* pwsAttriName, + CFX_WideString& wsAttriValue, + const FX_WCHAR* pwsDefValue = NULL) const; + virtual void SetString(const CFX_WideString& wsAttriName, + const CFX_WideString& wsAttriValue); + virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, + int32_t iDefValue = 0) const; + virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); + virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, + FX_FLOAT fDefValue = 0) const; + virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); + virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); + virtual void GetTextData(CFX_WideString& wsText) const; + virtual void SetTextData(const CFX_WideString& wsText); + + public: + ~CFDE_XMLElement(); + CFX_WideString m_wsTag; + CFX_WideStringArray m_Attributes; +}; +class CFDE_XMLText : public CFDE_XMLNode { + public: + CFDE_XMLText(const CFX_WideString& wsText); + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); + virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } + virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } + + public: + ~CFDE_XMLText() {} + CFX_WideString m_wsText; +}; +class CFDE_XMLDeclaration : public CFDE_XMLNode { + public: + CFDE_XMLDeclaration() : CFDE_XMLNode() {} +}; +class CFDE_XMLCharData : public CFDE_XMLDeclaration { + public: + CFDE_XMLCharData(const CFX_WideString& wsCData); + + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); + virtual void GetCharData(CFX_WideString& wsCharData) const { + wsCharData = m_wsCharData; + } + virtual void SetCharData(const CFX_WideString& wsCData) { + m_wsCharData = wsCData; + } + + public: + ~CFDE_XMLCharData() {} + + CFX_WideString m_wsCharData; +}; +class CFDE_XMLDoc : public CFX_Target { + public: + CFDE_XMLDoc(); + ~CFDE_XMLDoc(); + virtual void Release() { delete this; } + virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, + int32_t iXMLPlaneSize = 8192, + int32_t iTextDataSize = 256, + FDE_XMLREADERHANDLER* pHandler = NULL); + virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser); + virtual int32_t DoLoad(IFX_Pause* pPause = NULL); + virtual void CloseXML(); + virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } + virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE); + virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode); + + protected: + IFX_Stream* m_pStream; + int32_t m_iStatus; + CFDE_XMLNode* m_pRoot; + IFDE_XMLSyntaxParser* m_pSyntaxParser; + IFDE_XMLParser* m_pXMLParser; + void Reset(FX_BOOL bInitRoot); + void ReleaseParser(); +}; +typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; +class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target { + public: + CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, IFDE_XMLSyntaxParser* pParser); + ~CFDE_XMLDOMParser(); + + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); + + private: + IFDE_XMLSyntaxParser* m_pParser; + CFDE_XMLNode* m_pParent; + CFDE_XMLNode* m_pChild; + CFDE_XMLDOMNodeStack m_NodeStack; + CFX_WideString m_ws1; + CFX_WideString m_ws2; +}; +class CFDE_XMLTAG : public CFX_Target { + public: + CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {} + CFDE_XMLTAG(const CFDE_XMLTAG& src) + : wsTagName(src.wsTagName), eType(src.eType) {} + CFX_WideString wsTagName; + FDE_XMLNODETYPE eType; +}; +typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; +class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target { + public: + CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, + IFDE_XMLSyntaxParser* pParser); + ~CFDE_XMLSAXParser(); + + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); + + private: + void Push(const CFDE_XMLTAG& xmlTag); + void Pop(); + FDE_XMLREADERHANDLER* m_pHandler; + IFDE_XMLSyntaxParser* m_pParser; + CFDE_XMLTagStack m_TagStack; + CFDE_XMLTAG* m_pTagTop; + CFX_WideString m_ws1; + CFX_WideString m_ws2; +}; + +class CFDE_BlockBuffer : public CFX_Target { + public: + CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); + ~CFDE_BlockBuffer(); + + FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); + FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } + void ReleaseBuffer() { delete this; } + FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); + inline int32_t GetAllocStep() const { return m_iAllocStep; } + inline int32_t& GetDataLengthRef() { return m_iDataLength; } + inline void Reset(FX_BOOL bReserveData = TRUE) { + if (!bReserveData) { + m_iStartPosition = 0; + } + m_iDataLength = 0; + } + void SetTextChar(int32_t iIndex, FX_WCHAR ch); + int32_t DeleteTextChars(int32_t iCount, FX_BOOL bDirection = TRUE); + void GetTextData(CFX_WideString& wsTextData, + int32_t iStart = 0, + int32_t iLength = -1) const; + + protected: + inline void TextDataIndex2BufIndex(const int32_t iIndex, + int32_t& iBlockIndex, + int32_t& iInnerIndex) const; + void ClearBuffer(); + CFX_PtrArray m_BlockArray; + int32_t m_iDataLength; + int32_t m_iBufferSize; + int32_t m_iAllocStep; + int32_t m_iStartPosition; +}; + +#define FDE_XMLSYNTAXMODE_Text 0 +#define FDE_XMLSYNTAXMODE_Node 1 +#define FDE_XMLSYNTAXMODE_Target 2 +#define FDE_XMLSYNTAXMODE_Tag 3 +#define FDE_XMLSYNTAXMODE_AttriName 4 +#define FDE_XMLSYNTAXMODE_AttriEqualSign 5 +#define FDE_XMLSYNTAXMODE_AttriQuotation 6 +#define FDE_XMLSYNTAXMODE_AttriValue 7 +#define FDE_XMLSYNTAXMODE_Entity 8 +#define FDE_XMLSYNTAXMODE_EntityDecimal 9 +#define FDE_XMLSYNTAXMODE_EntityHex 10 +#define FDE_XMLSYNTAXMODE_CloseInstruction 11 +#define FDE_XMLSYNTAXMODE_BreakElement 12 +#define FDE_XMLSYNTAXMODE_CloseElement 13 +#define FDE_XMLSYNTAXMODE_SkipDeclNode 14 +#define FDE_XMLSYNTAXMODE_DeclCharData 15 +#define FDE_XMLSYNTAXMODE_SkipComment 16 +#define FDE_XMLSYNTAXMODE_SkipCommentOrDecl 17 +#define FDE_XMLSYNTAXMODE_TargetData 18 +class CFDE_XMLSyntaxParser : public IFDE_XMLSyntaxParser, public CFX_Target { + public: + CFDE_XMLSyntaxParser(); + ~CFDE_XMLSyntaxParser(); + virtual void Release() { delete this; } + virtual void Init(IFX_Stream* pStream, + int32_t iXMLPlaneSize, + int32_t iTextDataSize = 256); + virtual FX_DWORD DoSyntaxParse(); + virtual int32_t GetStatus() const; + virtual int32_t GetCurrentPos() const { + return m_iParsedChars + (m_pStart - m_pBuffer); + } + virtual FX_FILESIZE GetCurrentBinaryPos() const; + virtual int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } + virtual int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } + + virtual void GetTargetName(CFX_WideString& wsTarget) const { + m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength); + } + virtual void GetTagName(CFX_WideString& wsTag) const { + m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength); + } + virtual void GetAttributeName(CFX_WideString& wsAttriName) const { + m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength); + } + virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const { + m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength); + } + virtual void GetTextData(CFX_WideString& wsText) const { + m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength); + } + virtual void GetTargetData(CFX_WideString& wsData) const { + m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength); + } + + protected: + IFX_Stream* m_pStream; + int32_t m_iXMLPlaneSize; + int32_t m_iCurrentPos; + int32_t m_iCurrentNodeNum; + int32_t m_iLastNodeNum; + int32_t m_iParsedChars; + int32_t m_iParsedBytes; + FX_WCHAR* m_pBuffer; + int32_t m_iBufferChars; + FX_BOOL m_bEOS; + FX_WCHAR* m_pStart; + FX_WCHAR* m_pEnd; + FDE_XMLNODE m_CurNode; + CFDE_XMLNodeStack m_XMLNodeStack; + CFDE_BlockBuffer m_BlockBuffer; + int32_t m_iAllocStep; + int32_t& m_iDataLength; + FX_WCHAR* m_pCurrentBlock; + int32_t m_iIndexInBlock; + int32_t m_iTextDataLength; + FX_DWORD m_dwStatus; + FX_DWORD m_dwMode; + FX_WCHAR m_wQuotationMark; + int32_t m_iEntityStart; + CFX_DWordStack m_SkipStack; + FX_WCHAR m_SkipChar; + inline void ParseTextChar(FX_WCHAR ch); +}; + +#endif // XFA_FDE_XML_FDE_XML_IMP_H_ diff --git a/xfa/fee/fde_txtedtbuf.cpp b/xfa/fee/fde_txtedtbuf.cpp new file mode 100644 index 0000000000..6f638dde09 --- /dev/null +++ b/xfa/fee/fde_txtedtbuf.cpp @@ -0,0 +1,403 @@ +// 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/fee/fde_txtedtbuf.h" + +#include <algorithm> + +#include "xfa/fee/ifde_txtedtbuf.h" +#include "xfa/fee/ifde_txtedtengine.h" + +#define FDE_DEFCHUNKCOUNT 2 +#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9 +#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB +#define FDE_TXTEDT_ZEROWIDTHSPACE 0x200B + +CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias) + : m_pBuf(pBuf), + m_nCurChunk(0), + m_nCurIndex(0), + m_nIndex(0), + m_Alias(wcAlias) { + FXSYS_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; + if (m_nCurIndex > 0) { + m_nCurIndex--; + } else { + while (m_nCurChunk > 0) { + --m_nCurChunk; + lpChunk = + (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk]; + if (lpChunk->nUsed > 0) { + m_nCurIndex = lpChunk->nUsed - 1; + break; + } + } + } + FXSYS_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]; + 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]; + if (lpChunkTemp->nUsed > 0) { + m_nCurIndex = 0; + break; + } + } + } + m_nIndex++; + return TRUE; + } +} +void CFDE_TxtEdtBufIter::SetAt(int32_t nIndex) { + FXSYS_assert(nIndex >= 0 && nIndex < m_pBuf->m_nTotal); + CFDE_TxtEdtBuf::FDE_CHUNKPLACE cp; + m_pBuf->Index2CP(nIndex, cp); + m_nIndex = nIndex; + m_nCurChunk = cp.nChunkIndex; + m_nCurIndex = cp.nCharIndex; +} +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); + 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_Alias; +} +FX_BOOL CFDE_TxtEdtBufIter::IsEOF(FX_BOOL bTail) const { + return bTail ? m_nIndex == (m_pBuf->GetTextLength() - 2) : m_nIndex == 0; +} +IFX_CharIter* CFDE_TxtEdtBufIter::Clone() { + CFDE_TxtEdtBufIter* pIter = new CFDE_TxtEdtBufIter(m_pBuf); + pIter->m_nCurChunk = m_nCurChunk; + pIter->m_nCurIndex = m_nCurIndex; + pIter->m_nIndex = m_nIndex; + pIter->m_Alias = m_Alias; + return pIter; +} +CFDE_TxtEdtBuf::CFDE_TxtEdtBuf(int32_t nDefChunkSize) + : m_nChunkSize(nDefChunkSize), + m_nTotal(0), + m_bChanged(FALSE), + m_pAllocator(NULL) { + FXSYS_assert(m_nChunkSize); + ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize); +} +void CFDE_TxtEdtBuf::Release() { + delete this; +} +CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() { + Clear(TRUE); + m_pAllocator->Release(); + m_Chunks.RemoveAll(); +} +FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) { + FXSYS_assert(nChunkSize); + ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize); + return TRUE; +} +int32_t CFDE_TxtEdtBuf::GetChunkSize() const { + return m_nChunkSize; +} +int32_t CFDE_TxtEdtBuf::GetTextLength() const { + return m_nTotal; +} +void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) { + FXSYS_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)); + lpChunk->nUsed = 0; + m_Chunks.Add(lpChunk); + } + int32_t nTotalCount = m_Chunks.GetSize(); + const FX_WCHAR* lpSrcBuf = wsText.c_str(); + int32_t nLeave = nTextLength; + int32_t nCopyedLength = m_nChunkSize; + for (i = 0; i < nTotalCount && nLeave > 0; i++) { + if (nLeave < nCopyedLength) { + nCopyedLength = nLeave; + } + FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; + FXSYS_memcpy(lpChunk->wChars, lpSrcBuf, nCopyedLength * sizeof(FX_WCHAR)); + nLeave -= nCopyedLength; + lpSrcBuf += nCopyedLength; + lpChunk->nUsed = nCopyedLength; + } + m_nTotal = nTextLength; + m_bChanged = TRUE; +} +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; + 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]; + nTotal += pChunkHeader->nUsed; + if (nTotal > nIndex) { + break; + } + } + FXSYS_assert(pChunkHeader); + return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)]; +} +void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText, + int32_t nBegin, + int32_t nLength) const { + FDE_CHUNKPLACE cp; + Index2CP(nBegin, cp); + int32_t nLeave = nLength; + 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]; + int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex; + FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex; + while (nLeave > 0) { + if (nLeave <= nCopyLength) { + nCopyLength = nLeave; + } + FXSYS_memcpy(lpDstBuf, lpSrcBuf, nCopyLength * sizeof(FX_WCHAR)); + nChunkIndex++; + if (nChunkIndex >= nCount) { + break; + } + lpChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[nChunkIndex]; + lpSrcBuf = lpChunkHeader->wChars; + nLeave -= nCopyLength; + lpDstBuf += nCopyLength; + nCopyLength = lpChunkHeader->nUsed; + } + wsText.ReleaseBuffer(); +} +void CFDE_TxtEdtBuf::Insert(int32_t nPos, + const FX_WCHAR* lpText, + int32_t nLength) { + FXSYS_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]; + int32_t nCopy = lpChunk->nUsed - cp.nCharIndex; + FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex, + nCopy * sizeof(FX_WCHAR)); + lpChunk->nUsed -= nCopy; + cp.nChunkIndex++; + m_Chunks.InsertAt(cp.nChunkIndex, lpNewChunk); + lpNewChunk->nUsed = nCopy; + cp.nCharIndex = 0; + } + if (cp.nChunkIndex != 0) { + FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex - 1]; + if (lpChunk->nUsed != m_nChunkSize) { + cp.nChunkIndex--; + int32_t nFree = m_nChunkSize - lpChunk->nUsed; + int32_t nCopy = std::min(nLengthTemp, nFree); + FXSYS_memcpy(lpChunk->wChars + lpChunk->nUsed, lpText, + nCopy * sizeof(FX_WCHAR)); + lpText += nCopy; + nLengthTemp -= nCopy; + lpChunk->nUsed += nCopy; + cp.nChunkIndex++; + } + } + while (nLengthTemp > 0) { + FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( + sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); + FXSYS_assert(lpChunk); + int32_t nCopy = std::min(nLengthTemp, m_nChunkSize); + FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR)); + lpText += nCopy; + nLengthTemp -= nCopy; + lpChunk->nUsed = nCopy; + m_Chunks.InsertAt(cp.nChunkIndex, lpChunk); + cp.nChunkIndex++; + } + m_nTotal += nLength; + m_bChanged = TRUE; +} +void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) { + FXSYS_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]; + int32_t nFirstPart = cpEnd.nCharIndex + 1; + int32_t nMovePart = lpChunk->nUsed - nFirstPart; + if (nMovePart != 0) { + int32_t nDelete = std::min(nFirstPart, nLength); + FXSYS_memmove(lpChunk->wChars + nFirstPart - nDelete, + lpChunk->wChars + nFirstPart, nMovePart * sizeof(FX_WCHAR)); + lpChunk->nUsed -= nDelete; + nLength -= nDelete; + cpEnd.nChunkIndex--; + } + while (nLength > 0) { + lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex]; + int32_t nDeleted = std::min(lpChunk->nUsed, nLength); + lpChunk->nUsed -= nDeleted; + if (lpChunk->nUsed == 0) { + m_pAllocator->Free(lpChunk); + m_Chunks.RemoveAt(cpEnd.nChunkIndex); + lpChunk = NULL; + } + nLength -= nDeleted; + cpEnd.nChunkIndex--; + } + m_bChanged = TRUE; +} +void CFDE_TxtEdtBuf::Clear(FX_BOOL bRelease) { + int32_t i = 0; + int32_t nCount = m_Chunks.GetSize(); + if (bRelease) { + while (i < nCount) { + m_pAllocator->Free(m_Chunks[i++]); + } + m_Chunks.RemoveAll(); + } else { + while (i < nCount) { + ((FDE_LPCHUNKHEADER)m_Chunks[i++])->nUsed = 0; + } + } + m_nTotal = 0; + m_bChanged = TRUE; +} +FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) { + if (m_bChanged == FALSE) { + return TRUE; + } + if (m_nTotal == 0) { + return TRUE; + } + int32_t nCount = m_Chunks.GetSize(); + if (nCount == 0) { + return TRUE; + } + int32_t i = 0; + for (; i < nCount; i++) { + FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; + if (lpChunk->nUsed == 0) { + m_pAllocator->Free(lpChunk); + m_Chunks.RemoveAt(i); + --i; + --nCount; + } + } + if (pPause != NULL && pPause->NeedToPauseNow()) { + return FALSE; + } + FDE_LPCHUNKHEADER lpPreChunk = (FDE_LPCHUNKHEADER)m_Chunks[0]; + FDE_LPCHUNKHEADER lpCurChunk = NULL; + for (i = 1; i < nCount; i++) { + lpCurChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; + if (lpPreChunk->nUsed + lpCurChunk->nUsed <= m_nChunkSize) { + FXSYS_memcpy(lpPreChunk->wChars + lpPreChunk->nUsed, lpCurChunk->wChars, + lpCurChunk->nUsed * sizeof(FX_WCHAR)); + lpPreChunk->nUsed += lpCurChunk->nUsed; + m_pAllocator->Free(lpCurChunk); + m_Chunks.RemoveAt(i); + --i; + --nCount; + } else { + lpPreChunk = lpCurChunk; + } + if (pPause != NULL && pPause->NeedToPauseNow()) { + return FALSE; + } + } + m_bChanged = FALSE; + return TRUE; +} +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; + } + 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); + lpChunkHeader->nUsed = 0; + m_Chunks.Add(lpChunkHeader); + m_nTotal = 0; +} +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; + } + return nTotal; +} +void CFDE_TxtEdtBuf::Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const { + FXSYS_assert(nIndex <= GetTextLength()); + if (nIndex == m_nTotal) { + cp.nChunkIndex = m_Chunks.GetSize() - 1; + cp.nCharIndex = ((FDE_LPCHUNKHEADER)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; + if (nTotal > nIndex) { + break; + } + } + cp.nChunkIndex = i; + cp.nCharIndex = ((FDE_LPCHUNKHEADER)m_Chunks[i])->nUsed - (nTotal - nIndex); +} diff --git a/xfa/fee/fde_txtedtbuf.h b/xfa/fee/fde_txtedtbuf.h new file mode 100644 index 0000000000..e0598f5244 --- /dev/null +++ b/xfa/fee/fde_txtedtbuf.h @@ -0,0 +1,92 @@ +// 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_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); + + 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(); + + private: + CFDE_TxtEdtBuf* m_pBuf; + int32_t m_nCurChunk; + int32_t m_nCurIndex; + int32_t m_nIndex; + FX_WCHAR m_Alias; +}; +class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf { + friend class CFDE_TxtEdtBufIter; + struct _FDE_CHUNKHEADER { + int32_t nUsed; + FX_WCHAR wChars[1]; + }; + typedef _FDE_CHUNKHEADER FDE_CHUNKHEADER; + typedef _FDE_CHUNKHEADER* FDE_LPCHUNKHEADER; + 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; + + int32_t m_nChunkSize; + + int32_t m_nTotal; + FX_BOOL m_bChanged; + CFX_PtrArray m_Chunks; + IFX_MEMAllocator* m_pAllocator; +}; + +#endif // XFA_FEE_FDE_TXTEDTBUF_H_ diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp new file mode 100644 index 0000000000..3afd20cf80 --- /dev/null +++ b/xfa/fee/fde_txtedtengine.cpp @@ -0,0 +1,1783 @@ +// 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/fee/fde_txtedtengine.h" + +#include <algorithm> + +#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" + +#define FDE_PAGEWIDTH_MAX 0xFFFF +#define FDE_TXTPLATESIZE (1024 * 12) +#define FDE_UNICODE_PARAGRAPH_SPERATOR (0x2029) +#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), + m_nLineCount(0), + m_nAnchorPos(-1), + m_nLayoutPos(0), + m_fCaretPosReserve(0.0), + m_nCaret(0), + m_bBefore(TRUE), + m_nCaretPage(0), + m_dwFindFlags(0), + m_bLock(FALSE), + m_nLimit(0), + m_wcAliasChar(L'*'), + m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto), + m_bAutoLineEnd(TRUE), + m_wLineEnd(FDE_UNICODE_PARAGRAPH_SPERATOR) { + FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF)); + m_pTxtBuf = new CFDE_TxtEdtBuf(); + m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); +} +CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() { + if (m_pTxtBuf) { + m_pTxtBuf->Release(); + m_pTxtBuf = NULL; + } + if (m_pTextBreak) { + m_pTextBreak->Release(); + m_pTextBreak = NULL; + } + RemoveAllParags(); + RemoveAllPages(); + m_Param.pEventSink = NULL; + ClearSelection(); +} +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); + } + FXSYS_memcpy(&m_Param, ¶ms, sizeof(FDE_TXTEDTPARAMS)); + m_wLineEnd = params.wLineBreakChar; + m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); + UpdateTxtBreak(); +} +const FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() const { + return &m_Param; +} +int32_t CFDE_TxtEdtEngine::CountPages() const { + if (m_nLineCount == 0) { + return 0; + } + return ((m_nLineCount - 1) / m_nPageLineCount) + 1; +} +IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) { + if (m_PagePtrArray.GetSize() <= nIndex) { + return NULL; + } + return (IFDE_TxtEdtPage*)m_PagePtrArray[nIndex]; +} +FX_BOOL CFDE_TxtEdtEngine::SetBufChunkSize(int32_t nChunkSize) { + return m_pTxtBuf->SetChunkSize(nChunkSize); +} +void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) { + ResetEngine(); + int32_t nIndex = 0; + if (pStream != NULL && pStream->GetLength()) { + int32_t nStreamLength = pStream->GetLength(); + FX_BOOL bValid = TRUE; + if (m_nLimit > 0 && nStreamLength > m_nLimit) { + bValid = FALSE; + } + FX_BOOL bPreIsCR = FALSE; + if (bValid) { + uint8_t bom[4]; + int32_t nPos = pStream->GetBOM(bom); + pStream->Seek(FX_STREAMSEEK_Begin, nPos); + int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize()); + FX_WCHAR* lpwstr = FX_Alloc(FX_WCHAR, nPlateSize); + FX_BOOL bEos = false; + while (!bEos) { + int32_t nRead = pStream->ReadString(lpwstr, nPlateSize, bEos); + bPreIsCR = ReplaceParagEnd(lpwstr, nRead, bPreIsCR); + m_pTxtBuf->Insert(nIndex, lpwstr, nRead); + nIndex += nRead; + } + FX_Free(lpwstr); + } + } + m_pTxtBuf->Insert(nIndex, &m_wLineEnd, 1); + RebuildParagraphs(); +} +void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) { + ResetEngine(); + int32_t nLength = wsText.GetLength(); + if (nLength > 0) { + CFX_WideString wsTemp; + FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength); + FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR)); + ReplaceParagEnd(lpBuffer, nLength, FALSE); + wsTemp.ReleaseBuffer(nLength); + if (m_nLimit > 0 && nLength > m_nLimit) { + wsTemp.Delete(m_nLimit, nLength - m_nLimit); + nLength = m_nLimit; + } + m_pTxtBuf->SetText(wsTemp); + } + m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1); + RebuildParagraphs(); +} +int32_t CFDE_TxtEdtEngine::GetTextLength() const { + return GetTextBufLength(); +} +void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText, + int32_t nStart, + int32_t nCount) { + int32_t nTextBufLength = GetTextBufLength(); + if (nCount == -1) { + nCount = nTextBufLength - nStart; + } + m_pTxtBuf->GetRange(wsText, nStart, nCount); + RecoverParagEnd(wsText); +} + +void CFDE_TxtEdtEngine::ClearText() { + DeleteRange(0, -1); +} +int32_t CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret) const { + rtCaret = m_rtCaret; + return m_nCaret; +} +int32_t CFDE_TxtEdtEngine::GetCaretPos() const { + if (IsLocked()) { + return 0; + } + return m_nCaret + (m_bBefore ? 0 : 1); +} +int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { + if (IsLocked()) { + return 0; + } + FXSYS_assert(nIndex >= 0 && nIndex <= GetTextBufLength()); + if (m_PagePtrArray.GetSize() <= m_nCaretPage) { + return 0; + } + m_bBefore = bBefore; + m_nCaret = nIndex; + MovePage2Char(m_nCaret); + GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); + if (!m_bBefore) { + m_nCaret++; + m_bBefore = TRUE; + } + m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) + ? m_rtCaret.top + : m_rtCaret.left; + m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); + m_nAnchorPos = -1; + return m_nCaret; +} +int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, + FX_BOOL bShift, + FX_BOOL bCtrl) { + if (IsLocked()) { + return 0; + } + if (m_PagePtrArray.GetSize() <= m_nCaretPage) { + return 0; + } + FX_BOOL bSelChange = FALSE; + if (IsSelect()) { + ClearSelection(); + bSelChange = TRUE; + } + if (bShift) { + if (m_nAnchorPos == -1) { + m_nAnchorPos = m_nCaret; + } + } else { + m_nAnchorPos = -1; + } + FX_BOOL bVertical = m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; + switch (eMoveCaret) { + case MC_Left: { + if (bVertical) { + CFX_PointF ptCaret; + if (MoveUp(ptCaret)) { + UpdateCaretIndex(ptCaret); + } + } else { + FX_BOOL bBefore = TRUE; + int32_t nIndex = MoveBackward(bBefore); + if (nIndex >= 0) { + UpdateCaretRect(nIndex, bBefore); + } + } + } break; + case MC_Right: { + if (bVertical) { + CFX_PointF ptCaret; + if (MoveDown(ptCaret)) { + UpdateCaretIndex(ptCaret); + } + } else { + FX_BOOL bBefore = TRUE; + int32_t nIndex = MoveForward(bBefore); + if (nIndex >= 0) { + UpdateCaretRect(nIndex, bBefore); + } + } + } break; + case MC_Up: { + if (bVertical) { + FX_BOOL bBefore = TRUE; + int32_t nIndex = MoveBackward(bBefore); + if (nIndex >= 0) { + UpdateCaretRect(nIndex, bBefore); + } + } else { + CFX_PointF ptCaret; + if (MoveUp(ptCaret)) { + UpdateCaretIndex(ptCaret); + } + } + } break; + case MC_Down: { + if (bVertical) { + FX_BOOL bBefore = TRUE; + int32_t nIndex = MoveForward(bBefore); + if (nIndex >= 0) { + UpdateCaretRect(nIndex, bBefore); + } + } else { + CFX_PointF ptCaret; + if (MoveDown(ptCaret)) { + UpdateCaretIndex(ptCaret); + } + } + } break; + case MC_WordBackward: + break; + case MC_WordForward: + break; + case MC_LineStart: + MoveLineStart(); + break; + case MC_LineEnd: + MoveLineEnd(); + break; + case MC_ParagStart: + MoveParagStart(); + break; + case MC_ParagEnd: + MoveParagEnd(); + break; + case MC_PageDown: + break; + case MC_PageUp: + break; + case MC_Home: + MoveHome(); + break; + case MC_End: + MoveEnd(); + break; + default: + break; + } + if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { + AddSelRange(std::min(m_nAnchorPos, m_nCaret), + FXSYS_abs(m_nAnchorPos - m_nCaret)); + m_Param.pEventSink->On_SelChanged(this); + } + if (bSelChange) { + m_Param.pEventSink->On_SelChanged(this); + } + return m_nCaret; +} +void CFDE_TxtEdtEngine::Lock() { + m_bLock = TRUE; +} +void CFDE_TxtEdtEngine::Unlock() { + m_bLock = FALSE; +} +FX_BOOL CFDE_TxtEdtEngine::IsLocked() const { + return m_bLock; +} +int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart, + const FX_WCHAR* lpText, + int32_t nLength) { + if (IsLocked()) { + return FDE_TXTEDT_MODIFY_RET_F_Locked; + } + CFX_WideString wsTemp; + FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength); + FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR)); + ReplaceParagEnd(lpBuffer, nLength, FALSE); + wsTemp.ReleaseBuffer(nLength); + FX_BOOL bPart = FALSE; + if (m_nLimit > 0) { + 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); + nTotalLength -= lpSelRange->nCount; + } + int32_t nExpectLength = nTotalLength + nLength; + if (nTotalLength == m_nLimit) { + return FDE_TXTEDT_MODIFY_RET_F_Full; + } + if (nExpectLength > m_nLimit) { + nLength -= (nExpectLength - m_nLimit); + bPart = TRUE; + } + } + if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) || + (m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) { + int32_t nTemp = nLength; + if (m_Param.dwMode & FDE_TEXTEDITMODE_Password) { + CFX_WideString wsText; + while (nLength > 0) { + GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); + int32_t nTotal = wsText.GetLength(); + FX_WCHAR* lpBuf = wsText.GetBuffer(nTotal); + for (int32_t i = 0; i < nTotal; i++) { + lpBuf[i] = m_wcAliasChar; + } + wsText.ReleaseBuffer(nTotal); + if (IsFitArea(wsText)) { + break; + } + nLength--; + } + } else { + CFX_WideString wsText; + while (nLength > 0) { + GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); + if (IsFitArea(wsText)) { + break; + } + nLength--; + } + } + if (nLength == 0) { + return FDE_TXTEDT_MODIFY_RET_F_Full; + } + if (nLength < nTemp) { + bPart = TRUE; + } + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { + CFX_WideString wsText; + GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); + if (!m_Param.pEventSink->On_Validate(this, wsText)) { + return FDE_TXTEDT_MODIFY_RET_F_Invalidate; + } + } + if (IsSelect()) { + DeleteSelect(); + } + if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { + IFDE_TxtEdtDoRecord* pRecord = + new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength); + CFX_ByteString bsDoRecord; + pRecord->Serialize(bsDoRecord); + m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); + pRecord->Release(); + } + GetText(m_ChangeInfo.wsPrevText, 0); + Inner_Insert(m_nCaret, lpBuffer, nLength); + m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; + m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength); + nStart = m_nCaret; + nStart += nLength; + FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); + FX_BOOL bBefore = TRUE; + if (wChar != L'\n' && wChar != L'\r') { + nStart--; + bBefore = FALSE; + } + SetCaretPos(nStart, bBefore); + m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal; +} +int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) { + if (IsLocked()) { + return FDE_TXTEDT_MODIFY_RET_F_Locked; + } + if (IsSelect()) { + DeleteSelect(); + return FDE_TXTEDT_MODIFY_RET_S_Normal; + } + + int32_t nCount = 1; + if (bBackspace) { + if (nStart == 0) { + return FDE_TXTEDT_MODIFY_RET_F_Boundary; + } + if (nStart > 2 && m_pTxtBuf->GetCharByIndex(nStart - 1) == L'\n' && + m_pTxtBuf->GetCharByIndex(nStart - 2) == L'\r') { + nStart--; + nCount++; + } + nStart--; + } else { + if (nStart == GetTextBufLength()) { + return FDE_TXTEDT_MODIFY_RET_F_Full; + } + if ((nStart + 1 < GetTextBufLength()) && + (m_pTxtBuf->GetCharByIndex(nStart) == L'\r') && + (m_pTxtBuf->GetCharByIndex(nStart + 1) == L'\n')) { + nCount++; + } + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { + CFX_WideString wsText; + GetPreDeleteText(wsText, nStart, nCount); + if (!m_Param.pEventSink->On_Validate(this, wsText)) { + return FDE_TXTEDT_MODIFY_RET_F_Invalidate; + } + } + if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { + CFX_WideString wsRange; + m_pTxtBuf->GetRange(wsRange, nStart, nCount); + IFDE_TxtEdtDoRecord* pRecord = + new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange); + CFX_ByteString bsDoRecord; + pRecord->Serialize(bsDoRecord); + m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); + pRecord->Release(); + } + m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; + GetText(m_ChangeInfo.wsDelete, nStart, nCount); + Inner_DeleteRange(nStart, nCount); + SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0), + (bBackspace || nStart == 0)); + m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + return FDE_TXTEDT_MODIFY_RET_S_Normal; +} +int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) { + if (IsLocked()) { + return FDE_TXTEDT_MODIFY_RET_F_Locked; + } + if (nCount == -1) { + nCount = GetTextBufLength(); + } + if (nCount == 0) { + return FDE_TXTEDT_MODIFY_RET_S_Normal; + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { + CFX_WideString wsText; + GetPreDeleteText(wsText, nStart, nCount); + if (!m_Param.pEventSink->On_Validate(this, wsText)) { + return FDE_TXTEDT_MODIFY_RET_F_Invalidate; + } + } + DeleteRange_DoRecord(nStart, nCount); + m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + SetCaretPos(nStart, TRUE); + return FDE_TXTEDT_MODIFY_RET_S_Normal; +} +int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart, + int32_t nLength, + const CFX_WideString& wsReplace) { + if (IsLocked()) { + return FDE_TXTEDT_MODIFY_RET_F_Locked; + } + if (nStart < 0 || (nStart + nLength > GetTextBufLength())) { + return FDE_TXTEDT_MODIFY_RET_F_Boundary; + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { + CFX_WideString wsText; + GetPreReplaceText(wsText, nStart, nLength, wsReplace.c_str(), + wsReplace.GetLength()); + if (!m_Param.pEventSink->On_Validate(this, wsText)) { + return FDE_TXTEDT_MODIFY_RET_F_Invalidate; + } + } + if (IsSelect()) { + ClearSelection(); + } + m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace; + GetText(m_ChangeInfo.wsDelete, nStart, nLength); + if (nLength > 0) { + Inner_DeleteRange(nStart, nLength); + } + int32_t nTextLength = wsReplace.GetLength(); + if (nTextLength > 0) { + Inner_Insert(nStart, wsReplace.c_str(), nTextLength); + } + m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength); + nStart += nTextLength; + FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); + FX_BOOL bBefore = TRUE; + if (wChar != L'\n' && wChar != L'\r') { + nStart--; + bBefore = FALSE; + } + SetCaretPos(nStart, bBefore); + m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + return FDE_TXTEDT_MODIFY_RET_S_Normal; +} +void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) { + m_nLimit = nLimit; +} +void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) { + m_wcAliasChar = wcAlias; +} + +void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) { + FDE_LPTXTEDTSELRANGE lpTemp = NULL; + int32_t nRangeCount = m_SelRangePtrArr.GetSize(); + int32_t i = 0; + for (i = 0; i < nRangeCount; i++) { + lpTemp = m_SelRangePtrArr[i]; + if (lpTemp->nStart == nStart && lpTemp->nCount == nCount) { + delete lpTemp; + m_SelRangePtrArr.RemoveAt(i); + return; + } + } +} + +void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { + if (nCount == -1) { + nCount = GetTextLength() - nStart; + } + int32_t nSize = m_SelRangePtrArr.GetSize(); + if (nSize <= 0) { + FDE_LPTXTEDTSELRANGE 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; + lpTemp = m_SelRangePtrArr[nSize - 1]; + if (nStart >= lpTemp->nStart + lpTemp->nCount) { + FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; + lpSelRange->nStart = nStart; + lpSelRange->nCount = nCount; + m_SelRangePtrArr.Add(lpSelRange); + m_Param.pEventSink->On_SelChanged(this); + return; + } + int32_t nEnd = nStart + nCount - 1; + FX_BOOL bBegin = FALSE; + int32_t nRangeBgn = 0; + int32_t nRangeCnt = 0; + for (int32_t i = 0; i < nSize; i++) { + lpTemp = m_SelRangePtrArr[i]; + int32_t nTempBgn = lpTemp->nStart; + int32_t nTempEnd = nTempBgn + lpTemp->nCount - 1; + if (bBegin) { + if (nEnd < nTempBgn) { + break; + } else if (nStart >= nTempBgn && nStart <= nTempEnd) { + nRangeCnt++; + break; + } + nRangeCnt++; + } else { + if (nStart <= nTempEnd) { + nRangeBgn = i; + if (nEnd < nTempBgn) { + break; + } + nRangeCnt = 1; + bBegin = TRUE; + } + } + } + if (nRangeCnt == 0) { + FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; + lpSelRange->nStart = nStart; + lpSelRange->nCount = nCount; + m_SelRangePtrArr.InsertAt(nRangeBgn, lpSelRange); + } else { + lpTemp = m_SelRangePtrArr[nRangeBgn]; + lpTemp->nStart = nStart; + lpTemp->nCount = nCount; + nRangeCnt--; + nRangeBgn++; + while (nRangeCnt--) { + delete m_SelRangePtrArr[nRangeBgn]; + m_SelRangePtrArr.RemoveAt(nRangeBgn); + } + } + m_Param.pEventSink->On_SelChanged(this); +} + +int32_t CFDE_TxtEdtEngine::CountSelRanges() { + return m_SelRangePtrArr.GetSize(); +} +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; + } + } + m_SelRangePtrArr.RemoveAll(); + if (nCount && m_Param.pEventSink) { + m_Param.pEventSink->On_SelChanged(this); + } +} +FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) { + if (IsLocked()) { + return FALSE; + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) { + return FALSE; + } + IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsRedo); + FXSYS_assert(pDoRecord); + if (pDoRecord == NULL) { + return FALSE; + } + FX_BOOL bOK = pDoRecord->Redo(); + pDoRecord->Release(); + return bOK; +} +FX_BOOL CFDE_TxtEdtEngine::Undo(const CFX_ByteStringC& bsUndo) { + if (IsLocked()) { + return FALSE; + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) { + return FALSE; + } + IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsUndo); + FXSYS_assert(pDoRecord); + if (pDoRecord == NULL) { + return FALSE; + } + FX_BOOL bOK = pDoRecord->Undo(); + pDoRecord->Release(); + return bOK; +} +int32_t CFDE_TxtEdtEngine::StartLayout() { + Lock(); + RemoveAllPages(); + m_nLayoutPos = 0; + m_nLineCount = 0; + return 0; +} +int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) { + int32_t nCount = m_ParagPtrArray.GetSize(); + CFDE_TxtEdtParag* pParag = NULL; + int32_t nLineCount = 0; + for (; m_nLayoutPos < nCount; m_nLayoutPos++) { + pParag = m_ParagPtrArray[m_nLayoutPos]; + pParag->CalcLines(); + nLineCount += pParag->m_nLineCount; + if ((pPause != NULL) && (nLineCount > m_nPageLineCount) && + pPause->NeedToPauseNow()) { + m_nLineCount += nLineCount; + return (++m_nLayoutPos * 100) / nCount; + } + } + m_nLineCount += nLineCount; + return 100; +} +void CFDE_TxtEdtEngine::EndLayout() { + UpdatePages(); + int32_t nLength = GetTextLength(); + if (m_nCaret > nLength) { + m_nCaret = nLength; + } + int32_t nIndex = m_nCaret; + if (!m_bBefore) { + nIndex--; + } + m_rtCaret.Set(0, 0, 1, m_Param.fFontSize); + Unlock(); +} +FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) { + return m_pTxtBuf->Optimize(pPause); +} +IFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const { + return (IFDE_TxtEdtBuf*)m_pTxtBuf; +} +int32_t CFDE_TxtEdtEngine::GetTextBufLength() const { + return m_pTxtBuf->GetTextLength() - 1; +} +IFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const { + return m_pTextBreak; +} +int32_t CFDE_TxtEdtEngine::GetLineCount() const { + return m_nLineCount; +} +int32_t CFDE_TxtEdtEngine::GetPageLineCount() const { + return m_nPageLineCount; +} +int32_t CFDE_TxtEdtEngine::CountParags() const { + return m_ParagPtrArray.GetSize(); +} +IFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const { + return m_ParagPtrArray[nParagIndex]; +} +IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() { + if (!m_pTxtBuf) { + return NULL; + } + return new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf); +} +int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag, + int32_t nStartLineofParag, + int32_t nLineIndex, + int32_t& nStartLine) const { + int32_t nLineTotal = nStartLineofParag; + int32_t nCount = m_ParagPtrArray.GetSize(); + CFDE_TxtEdtParag* pParag = NULL; + int32_t i = nStartParag; + for (; i < nCount; i++) { + pParag = m_ParagPtrArray[i]; + nLineTotal += pParag->m_nLineCount; + if (nLineTotal > nLineIndex) { + break; + } + } + nStartLine = nLineTotal - pParag->m_nLineCount; + return i; +} +void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText, + int32_t nIndex, + int32_t nLength) { + GetText(wsText, 0, GetTextBufLength()); + wsText.Delete(nIndex, nLength); +} +void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText, + int32_t nIndex, + const FX_WCHAR* lpText, + int32_t nLength) { + GetText(wsText, 0, GetTextBufLength()); + int32_t nSelIndex = 0; + int32_t nSelLength = 0; + int32_t nSelCount = CountSelRanges(); + while (nSelCount--) { + nSelLength = GetSelRange(nSelCount, nSelIndex); + wsText.Delete(nSelIndex, nSelLength); + nIndex = nSelIndex; + } + CFX_WideString wsTemp; + int32_t nOldLength = wsText.GetLength(); + const FX_WCHAR* pOldBuffer = wsText.c_str(); + FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength); + FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR)); + FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR)); + FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex, + (nOldLength - nIndex) * sizeof(FX_WCHAR)); + wsTemp.ReleaseBuffer(nOldLength + nLength); + wsText = wsTemp; +} +void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText, + int32_t nIndex, + int32_t nOriginLength, + const FX_WCHAR* lpText, + int32_t nLength) { + GetText(wsText, 0, GetTextBufLength()); + int32_t nSelIndex = 0; + int32_t nSelLength = 0; + int32_t nSelCount = CountSelRanges(); + while (nSelCount--) { + nSelLength = GetSelRange(nSelCount, nSelIndex); + wsText.Delete(nSelIndex, nSelLength); + } + wsText.Delete(nIndex, nOriginLength); + int32_t i = 0; + for (i = 0; i < nLength; i++) { + wsText.Insert(nIndex++, lpText[i]); + } +} +void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, + const FX_WCHAR* lpText, + int32_t nLength) { + FXSYS_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; + } + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; + int32_t nReserveLineCount = pParag->m_nLineCount; + int32_t nReserveCharStart = pParag->m_nCharStart; + int32_t nLeavePart = ParagPos.nCharIndex; + int32_t nCutPart = pParag->m_nCharCount - ParagPos.nCharIndex; + int32_t nTextStart = 0; + FX_WCHAR wCurChar = L' '; + const FX_WCHAR* lpPos = lpText; + FX_BOOL bFirst = TRUE; + int32_t nParagIndex = ParagPos.nParagIndex; + for (i = 0; i < nLength; i++, lpPos++) { + wCurChar = *lpPos; + if (wCurChar == m_wLineEnd) { + if (bFirst) { + pParag->m_nCharCount = nLeavePart + (i - nTextStart + 1); + pParag->m_nLineCount = -1; + nReserveCharStart += pParag->m_nCharCount; + bFirst = FALSE; + } else { + pParag = new CFDE_TxtEdtParag(this); + pParag->m_nLineCount = -1; + pParag->m_nCharCount = i - nTextStart + 1; + pParag->m_nCharStart = nReserveCharStart; + m_ParagPtrArray.InsertAt(++nParagIndex, pParag); + nReserveCharStart += pParag->m_nCharCount; + } + nTextStart = i + 1; + } + } + if (bFirst) { + pParag->m_nCharCount += nLength; + pParag->m_nLineCount = -1; + bFirst = FALSE; + } else { + pParag = new CFDE_TxtEdtParag(this); + pParag->m_nLineCount = -1; + pParag->m_nCharCount = nLength - nTextStart + nCutPart; + pParag->m_nCharStart = nReserveCharStart; + m_ParagPtrArray.InsertAt(++nParagIndex, pParag); + } + m_pTxtBuf->Insert(nStart, lpText, nLength); + int32_t nTotalLineCount = 0; + for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) { + pParag = m_ParagPtrArray[i]; + pParag->CalcLines(); + nTotalLineCount += pParag->m_nLineCount; + } + m_nLineCount += nTotalLineCount - nReserveLineCount; + m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + UpdatePages(); +} + +void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { + if (nCount == -1) { + nCount = m_pTxtBuf->GetTextLength() - nStart; + } + int32_t nEnd = nStart + nCount - 1; + FXSYS_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.nParagIndex < m_ParagPtrArray.GetSize() - 1) { + ParagPosEnd.nParagIndex++; + } else { + bLastParag = TRUE; + } + } + int32_t nTotalLineCount = 0; + int32_t nTotalCharCount = 0; + int32_t i = 0; + for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) { + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i]; + pParag->CalcLines(); + nTotalLineCount += pParag->m_nLineCount; + nTotalCharCount += pParag->m_nCharCount; + } + 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; + m_ParagPtrArray.RemoveAt(nNextParagIndex); + } + if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) { + pParag = m_ParagPtrArray[ParagPosBgn.nParagIndex]; + pParag->m_nCharCount = nTotalCharCount - nCount; + pParag->CalcLines(); + nTotalLineCount -= pParag->m_nLineCount; + } + int32_t nParagCount = m_ParagPtrArray.GetSize(); + for (i = nNextParagIndex; i < nParagCount; i++) { + m_ParagPtrArray[i]->m_nCharStart -= nCount; + } + m_nLineCount -= nTotalLineCount; + UpdatePages(); + int32_t nPageCount = CountPages(); + if (m_nCaretPage >= nPageCount) { + m_nCaretPage = nPageCount - 1; + } + m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); +} +void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart, + int32_t nCount, + FX_BOOL bSel) { + FXSYS_assert(nStart >= 0); + if (nCount == -1) { + nCount = GetTextLength() - nStart; + } + FXSYS_assert((nStart + nCount) <= m_pTxtBuf->GetTextLength()); + + if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { + CFX_WideString wsRange; + m_pTxtBuf->GetRange(wsRange, nStart, nCount); + IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_DeleteRange( + this, nStart, m_nCaret, wsRange, bSel); + CFX_ByteString bsDoRecord; + pRecord->Serialize(bsDoRecord); + m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); + pRecord->Release(); + } + m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; + GetText(m_ChangeInfo.wsDelete, nStart, nCount); + Inner_DeleteRange(nStart, nCount); +} +void CFDE_TxtEdtEngine::ResetEngine() { + RemoveAllPages(); + RemoveAllParags(); + ClearSelection(); + m_nCaret = 0; + m_pTxtBuf->Clear(FALSE); + m_nCaret = 0; +} +void CFDE_TxtEdtEngine::RebuildParagraphs() { + RemoveAllParags(); + FX_WCHAR wChar = L' '; + int32_t nParagStart = 0; + int32_t nIndex = 0; + IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((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; + 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; + } + } + m_ParagPtrArray.RemoveAll(); +} +void CFDE_TxtEdtEngine::RemoveAllPages() { + int32_t nCount = m_PagePtrArray.GetSize(); + int32_t i = 0; + for (i = 0; i < nCount; i++) { + IFDE_TxtEdtPage* pPage = m_PagePtrArray[i]; + if (pPage) { + pPage->Release(); + } + } + m_PagePtrArray.RemoveAll(); +} +void CFDE_TxtEdtEngine::UpdateParags() { + int32_t nCount = m_ParagPtrArray.GetSize(); + if (nCount == 0) { + return; + } + CFDE_TxtEdtParag* pParag = NULL; + int32_t nLineCount = 0; + int32_t i = 0; + for (i = 0; i < nCount; i++) { + pParag = m_ParagPtrArray[i]; + if (pParag->m_nLineCount == -1) { + pParag->CalcLines(); + } + nLineCount += pParag->m_nLineCount; + } + m_nLineCount = nLineCount; +} +void CFDE_TxtEdtEngine::UpdatePages() { + if (m_nLineCount == 0) { + return; + } + int32_t nPageCount = (m_nLineCount - 1) / (m_nPageLineCount) + 1; + int32_t nSize = m_PagePtrArray.GetSize(); + if (nSize == nPageCount) { + return; + } + if (nSize > nPageCount) { + IFDE_TxtEdtPage* pPage = NULL; + int32_t i = 0; + for (i = nSize - 1; i >= nPageCount; i--) { + pPage = m_PagePtrArray[i]; + if (pPage) { + pPage->Release(); + } + m_PagePtrArray.RemoveAt(i); + } + m_Param.pEventSink->On_PageCountChanged(this); + return; + } + if (nSize < nPageCount) { + IFDE_TxtEdtPage* pPage = NULL; + int32_t i = 0; + for (i = nSize; i < nPageCount; i++) { + pPage = IFDE_TxtEdtPage::Create(this, i); + m_PagePtrArray.Add(pPage); + } + m_Param.pEventSink->On_PageCountChanged(this); + return; + } +} +void CFDE_TxtEdtEngine::UpdateTxtBreak() { + FX_DWORD dwStyle = m_pTextBreak->GetLayoutStyles(); + if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines) { + dwStyle &= ~FX_TXTLAYOUTSTYLE_SingleLine; + } else { + dwStyle |= FX_TXTLAYOUTSTYLE_SingleLine; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + dwStyle |= FX_TXTLAYOUTSTYLE_VerticalLayout; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalLayout; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve) { + dwStyle |= FX_TXTLAYOUTSTYLE_ReverseLine; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_ReverseLine; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_RTL) { + dwStyle |= FX_TXTLAYOUTSTYLE_RTLReadingOrder; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_RTLReadingOrder; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) { + dwStyle |= FX_TXTLAYOUTSTYLE_CombText; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_CombText; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CharVertial) { + dwStyle |= FX_TXTLAYOUTSTYLE_VerticalChars; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalChars; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ExpandTab) { + dwStyle |= FX_TXTLAYOUTSTYLE_ExpandTab; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_ExpandTab; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ArabicContext) { + dwStyle |= FX_TXTLAYOUTSTYLE_ArabicContext; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_ArabicContext; + } + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ArabicShapes) { + dwStyle |= FX_TXTLAYOUTSTYLE_ArabicShapes; + } else { + dwStyle &= ~FX_TXTLAYOUTSTYLE_ArabicShapes; + } + m_pTextBreak->SetLayoutStyles(dwStyle); + FX_DWORD dwAligment = 0; + if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Justified) { + dwAligment |= FX_TXTLINEALIGNMENT_Justified; + } else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Distributed) { + dwAligment |= FX_TXTLINEALIGNMENT_Distributed; + } + if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Center) { + dwAligment |= FX_TXTLINEALIGNMENT_Center; + } else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Right) { + dwAligment |= FX_TXTLINEALIGNMENT_Right; + } + m_pTextBreak->SetAlignment(dwAligment); + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { + m_pTextBreak->SetLineWidth(m_Param.fPlateHeight); + } else { + m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX); + } + } else { + if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { + m_pTextBreak->SetLineWidth(m_Param.fPlateWidth); + } else { + m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX); + } + } + m_nPageLineCount = m_Param.nLineCount; + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) { + FX_FLOAT fCombWidth = + m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical + ? m_Param.fPlateHeight + : m_Param.fPlateWidth; + if (m_nLimit > 0) { + fCombWidth /= m_nLimit; + } + m_pTextBreak->SetCombWidth(fCombWidth); + } + m_pTextBreak->SetFont(m_Param.pFont); + m_pTextBreak->SetFontSize(m_Param.fFontSize); + m_pTextBreak->SetTabWidth(m_Param.fTabWidth, m_Param.bTabEquidistant); + m_pTextBreak->SetDefaultChar(m_Param.wDefChar); + m_pTextBreak->SetParagraphBreakChar(m_Param.wLineBreakChar); + m_pTextBreak->SetCharRotation(m_Param.nCharRotation); + m_pTextBreak->SetLineBreakTolerance(m_Param.fFontSize * 0.2f); + m_pTextBreak->SetHorizontalScale(m_Param.nHorzScale); + m_pTextBreak->SetCharSpace(m_Param.fCharSpace); +} +FX_BOOL CFDE_TxtEdtEngine::ReplaceParagEnd(FX_WCHAR*& lpText, + int32_t& nLength, + FX_BOOL bPreIsCR) { + for (int32_t i = 0; i < nLength; i++) { + FX_WCHAR wc = lpText[i]; + switch (wc) { + case L'\r': { + lpText[i] = m_wLineEnd; + bPreIsCR = TRUE; + } break; + case L'\n': { + if (bPreIsCR == TRUE) { + int32_t nNext = i + 1; + if (nNext < nLength) { + FXSYS_memmove(lpText + i, lpText + nNext, + (nLength - nNext) * sizeof(FX_WCHAR)); + } + i--; + nLength--; + bPreIsCR = FALSE; + if (m_bAutoLineEnd) { + m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_CRLF; + m_bAutoLineEnd = FALSE; + } + } else { + lpText[i] = m_wLineEnd; + if (m_bAutoLineEnd) { + m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_LF; + m_bAutoLineEnd = FALSE; + } + } + } break; + default: { + if (bPreIsCR && m_bAutoLineEnd) { + m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_CR; + m_bAutoLineEnd = FALSE; + } + bPreIsCR = FALSE; + } break; + } + } + return bPreIsCR; +} +void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) { + FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r'; + if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) { + CFX_ArrayTemplate<int32_t> PosArr; + int32_t nLength = wsText.GetLength(); + int32_t i = 0; + FX_WCHAR* lpPos = (FX_WCHAR*)(const FX_WCHAR*)wsText; + for (i = 0; i < nLength; i++, lpPos++) { + if (*lpPos == m_wLineEnd) { + *lpPos = wc; + PosArr.Add(i); + } + } + const FX_WCHAR* lpSrcBuf = wsText.c_str(); + CFX_WideString wsTemp; + int32_t nCount = PosArr.GetSize(); + FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount); + int32_t nDstPos = 0; + int32_t nSrcPos = 0; + for (i = 0; i < nCount; i++) { + int32_t nPos = PosArr[i]; + int32_t nCopyLen = nPos - nSrcPos + 1; + FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, + nCopyLen * sizeof(FX_WCHAR)); + nDstPos += nCopyLen; + nSrcPos += nCopyLen; + lpDstBuf[nDstPos] = L'\n'; + nDstPos++; + } + if (nSrcPos < nLength) { + FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, + (nLength - nSrcPos) * sizeof(FX_WCHAR)); + } + wsTemp.ReleaseBuffer(nLength + nCount); + wsText = wsTemp; + } else { + int32_t nLength = wsText.GetLength(); + FX_WCHAR* lpBuf = (FX_WCHAR*)(const FX_WCHAR*)wsText; + for (int32_t i = 0; i < nLength; i++, lpBuf++) { + if (*lpBuf == m_wLineEnd) { + *lpBuf = wc; + } + } + } +} +int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { + FXSYS_assert(nIndex >= 0); + FXSYS_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); + int32_t nPageCharStart = pPage->GetCharStart(); + int32_t nPageCharCount = pPage->GetCharCount(); + if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) { + m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + return m_nCaretPage; + } + m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + } + CFDE_TxtEdtParag* pParag = NULL; + int32_t nLineCount = 0; + int32_t nParagCount = m_ParagPtrArray.GetSize(); + 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)) { + break; + } + nLineCount += pParag->m_nLineCount; + } + pParag->LoadParag(); + int32_t nLineStart = -1; + int32_t nLineCharCount = -1; + for (i = 0; i < pParag->m_nLineCount; i++) { + pParag->GetLineRange(i, nLineStart, nLineCharCount); + if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount)) { + break; + } + } + FXSYS_assert(i < pParag->m_nLineCount); + 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()); + int32_t nCount = m_ParagPtrArray.GetSize(); + int32_t nBgn = 0; + int32_t nMid = 0; + int32_t nEnd = nCount - 1; + while (nEnd > nBgn) { + nMid = (nBgn + nEnd) / 2; + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nMid]; + if (nIndex < pParag->m_nCharStart) { + nEnd = nMid - 1; + } else if (nIndex >= (pParag->m_nCharStart + pParag->m_nCharCount)) { + nBgn = nMid + 1; + } else { + break; + } + } + if (nBgn == nEnd) { + nMid = nBgn; + } + FXSYS_assert(nIndex >= m_ParagPtrArray[nMid]->m_nCharStart && + (nIndex < m_ParagPtrArray[nMid]->m_nCharStart + + m_ParagPtrArray[nMid]->m_nCharCount)); + ParagPos.nParagIndex = nMid; + ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->m_nCharStart; +} +int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) { + if (m_nCaret == m_pTxtBuf->GetTextLength() - 1) { + return -1; + } + int32_t nCaret = m_nCaret; + if ((nCaret + 1 < m_pTxtBuf->GetTextLength()) && + (m_pTxtBuf->GetCharByIndex(nCaret) == L'\r') && + (m_pTxtBuf->GetCharByIndex(nCaret + 1) == L'\n')) { + nCaret++; + } + nCaret++; + bBefore = TRUE; + return nCaret; +} +int32_t CFDE_TxtEdtEngine::MoveBackward(FX_BOOL& bBefore) { + if (m_nCaret == 0) { + return FALSE; + } + int32_t nCaret = m_nCaret; + if (nCaret > 2 && m_pTxtBuf->GetCharByIndex(nCaret - 1) == L'\n' && + m_pTxtBuf->GetCharByIndex(nCaret - 2) == L'\r') { + nCaret--; + } + nCaret--; + bBefore = TRUE; + return nCaret; +} +FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) { + IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage); + const CFX_RectF& rtContent = pPage->GetContentsBox(); + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + ptCaret.x = m_rtCaret.left + m_rtCaret.width / 2 - m_Param.fLineSpace; + ptCaret.y = m_fCaretPosReserve; + FX_BOOL bLineReserve = + m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; + if (ptCaret.x < rtContent.left) { + if (bLineReserve) { + if (m_nCaretPage == CountPages() - 1) { + return FALSE; + } + } else { + if (m_nCaretPage == 0) { + return FALSE; + } + } + if (bLineReserve) { + m_nCaretPage++; + } 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(); + } + } else { + ptCaret.x = m_fCaretPosReserve; + ptCaret.y = m_rtCaret.top + m_rtCaret.height / 2 - m_Param.fLineSpace; + if (ptCaret.y < rtContent.top) { + if (m_nCaretPage == 0) { + return FALSE; + } + 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(); + } + } + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) { + IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage); + const CFX_RectF& rtContent = pPage->GetContentsBox(); + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + ptCaret.x = m_rtCaret.left + m_rtCaret.width / 2 + m_Param.fLineSpace; + ptCaret.y = m_fCaretPosReserve; + if (ptCaret.x >= rtContent.right()) { + FX_BOOL bLineReserve = + m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; + if (bLineReserve) { + if (m_nCaretPage == 0) { + return FALSE; + } + } else { + if (m_nCaretPage == CountPages() - 1) { + return FALSE; + } + } + if (bLineReserve) { + m_nCaretPage--; + } 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; + } + } else { + ptCaret.x = m_fCaretPosReserve; + ptCaret.y = m_rtCaret.top + m_rtCaret.height / 2 + m_Param.fLineSpace; + if (ptCaret.y >= rtContent.bottom()) { + if (m_nCaretPage == CountPages() - 1) { + return FALSE; + } + 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; + } + } + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() { + int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; + FDE_TXTEDTPARAGPOS ParagPos; + TextPos2ParagPos(nIndex, ParagPos); + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; + pParag->LoadParag(); + int32_t nLineCount = pParag->m_nLineCount; + int32_t i = 0; + int32_t nStart = 0; + int32_t nCount = 0; + for (; i < nLineCount; i++) { + pParag->GetLineRange(i, nStart, nCount); + if (nIndex >= nStart && nIndex < nStart + nCount) { + break; + } + } + UpdateCaretRect(nStart, TRUE); + pParag->UnloadParag(); + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() { + int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; + FDE_TXTEDTPARAGPOS ParagPos; + TextPos2ParagPos(nIndex, ParagPos); + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; + pParag->LoadParag(); + int32_t nLineCount = pParag->m_nLineCount; + int32_t i = 0; + int32_t nStart = 0; + int32_t nCount = 0; + for (; i < nLineCount; i++) { + pParag->GetLineRange(i, nStart, nCount); + if (nIndex >= nStart && nIndex < nStart + nCount) { + break; + } + } + nIndex = nStart + nCount - 1; + FXSYS_assert(nIndex <= GetTextBufLength()); + FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex); + FX_BOOL bBefore = FALSE; + if (nIndex <= GetTextBufLength()) { + if (wChar == L'\r') { + bBefore = TRUE; + } else if (wChar == L'\n' && nIndex > nStart) { + bBefore = TRUE; + nIndex--; + wChar = m_pTxtBuf->GetCharByIndex(nIndex); + if (wChar != L'\r') { + nIndex++; + } + } + } + UpdateCaretRect(nIndex, bBefore); + pParag->UnloadParag(); + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() { + int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; + FDE_TXTEDTPARAGPOS ParagPos; + TextPos2ParagPos(nIndex, ParagPos); + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; + UpdateCaretRect(pParag->m_nCharStart, TRUE); + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() { + int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; + FDE_TXTEDTPARAGPOS ParagPos; + TextPos2ParagPos(nIndex, ParagPos); + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; + nIndex = pParag->m_nCharStart + pParag->m_nCharCount - 1; + FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex); + if (wChar == L'\n' && nIndex > 0) { + nIndex--; + wChar = m_pTxtBuf->GetCharByIndex(nIndex); + if (wChar != L'\r') { + nIndex++; + } + } + UpdateCaretRect(nIndex, TRUE); + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveHome() { + UpdateCaretRect(0, TRUE); + return TRUE; +} +FX_BOOL CFDE_TxtEdtEngine::MoveEnd() { + UpdateCaretRect(GetTextBufLength(), TRUE); + return TRUE; +} + +FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) { + IFDE_TextOut* pTextOut = IFDE_TextOut::Create(); + pTextOut->SetLineSpace(m_Param.fLineSpace); + pTextOut->SetFont(m_Param.pFont); + pTextOut->SetFontSize(m_Param.fFontSize); + CFX_RectF rcText; + FXSYS_memset(&rcText, 0, sizeof(rcText)); + FX_DWORD dwStyle = 0; + if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) { + dwStyle |= FDE_TTOSTYLE_SingleLine; + } + if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { + dwStyle |= FDE_TTOSTYLE_LineWrap; + rcText.width = m_Param.fPlateWidth; + } else { + rcText.width = 65535; + } + pTextOut->SetStyles(dwStyle); + wsText += L"\n"; + pTextOut->CalcLogicSize(wsText, wsText.GetLength(), rcText); + pTextOut->Release(); + wsText.Delete(wsText.GetLength() - 1); + if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && + (rcText.width > m_Param.fPlateWidth)) { + return FALSE; + } + if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && + (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { + return FALSE; + } + return TRUE; +} +void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore) { + MovePage2Char(nIndex); + GetCaretRect(m_rtCaret, m_nCaretPage, nIndex, bBefore); + m_nCaret = nIndex; + m_bBefore = bBefore; + if (!m_bBefore) { + m_nCaret++; + m_bBefore = TRUE; + } + m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) + ? m_rtCaret.top + : m_rtCaret.left; + m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); +} +void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, + int32_t nPageIndex, + int32_t nCaret, + FX_BOOL bBefore) { + IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; + m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + FX_BOOL bCombText = m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText; + int32_t nIndexInpage = nCaret - pPage->GetCharStart(); + if (bBefore && bCombText && nIndexInpage > 0) { + nIndexInpage--; + bBefore = FALSE; + } + int32_t nBIDILevel = pPage->GetCharRect(nIndexInpage, rtCaret, bCombText); + if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + if ((!FX_IsOdd(nBIDILevel) && !bBefore) || + (FX_IsOdd(nBIDILevel) && bBefore)) { + rtCaret.Offset(0, rtCaret.height - 1.0f); + } + if (rtCaret.height == 0 && rtCaret.top > 1.0f) { + rtCaret.top -= 1.0f; + } + rtCaret.height = 1.0f; + } else { + if ((!FX_IsOdd(nBIDILevel) && !bBefore) || + (FX_IsOdd(nBIDILevel) && bBefore)) { + rtCaret.Offset(rtCaret.width - 1.0f, 0); + } + if (rtCaret.width == 0 && rtCaret.left > 1.0f) { + rtCaret.left -= 1.0f; + } + rtCaret.width = 1.0f; + } + m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); +} +void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) { + IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; + m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore); + GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); + if (!m_bBefore) { + m_nCaret++; + m_bBefore = TRUE; + } + m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage); + m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); +} +FX_BOOL CFDE_TxtEdtEngine::IsSelect() { + return m_SelRangePtrArr.GetSize() > 0; +} +void CFDE_TxtEdtEngine::DeleteSelect() { + int32_t nCountRange = CountSelRanges(); + if (nCountRange > 0) { + int32_t nSelStart; + int32_t nSelCount; + while (nCountRange > 0) { + nSelCount = GetSelRange(--nCountRange, nSelStart); + FDE_LPTXTEDTSELRANGE lpTemp = m_SelRangePtrArr[nCountRange]; + delete lpTemp; + m_SelRangePtrArr.RemoveAt(nCountRange); + DeleteRange_DoRecord(nSelStart, nSelCount, TRUE); + } + ClearSelection(); + m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + m_Param.pEventSink->On_SelChanged(this); + SetCaretPos(nSelStart, TRUE); + return; + } +} +IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create( + const CFX_ByteStringC& bsDoRecord) { + const FX_CHAR* lpBuf = bsDoRecord.GetCStr(); + int32_t nType = *((int32_t*)lpBuf); + switch (nType) { + 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 NULL; +} +CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( + const CFX_ByteStringC& bsDoRecord) { + Deserialize(bsDoRecord); +} +CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( + CFDE_TxtEdtEngine* pEngine, + int32_t nCaret, + const FX_WCHAR* lpText, + int32_t nLength) + : m_pEngine(pEngine), m_nCaret(nCaret) { + FXSYS_assert(pEngine); + FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength); + FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR)); + m_wsInsert.ReleaseBuffer(); +} +CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {} +void CFDE_TxtEdtDoRecord_Insert::Release() { + delete this; +} +FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() { + if (m_pEngine->IsSelect()) { + m_pEngine->ClearSelection(); + } + m_pEngine->Inner_DeleteRange(m_nCaret, m_wsInsert.GetLength()); + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; + m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nCaret, TRUE); + return TRUE; +} +FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() { + m_pEngine->Inner_Insert(m_nCaret, m_wsInsert.c_str(), m_wsInsert.GetLength()); + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; + m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nCaret, FALSE); + return TRUE; +} +void CFDE_TxtEdtDoRecord_Insert::Serialize(CFX_ByteString& bsDoRecord) const { + CFX_ArchiveSaver ArchiveSaver; + ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_INS); + ArchiveSaver << (int32_t)(uintptr_t)m_pEngine; + ArchiveSaver << m_nCaret; + ArchiveSaver << m_wsInsert; + int32_t nLength = ArchiveSaver.GetLength(); + const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); + FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); + FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); + bsDoRecord.ReleaseBuffer(nLength); +} +void CFDE_TxtEdtDoRecord_Insert::Deserialize( + const CFX_ByteStringC& bsDoRecord) { + CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(), + bsDoRecord.GetLength()); + int32_t nType = 0; + ArchiveLoader >> nType; + FXSYS_assert(nType == FDE_TXTEDT_DORECORD_INS); + int32_t nEngine = 0; + ArchiveLoader >> nEngine; + m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; + ArchiveLoader >> m_nCaret; + ArchiveLoader >> m_wsInsert; +} +CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange( + const CFX_ByteStringC& bsDoRecord) { + Deserialize(bsDoRecord); +} +CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange( + CFDE_TxtEdtEngine* pEngine, + int32_t nIndex, + int32_t nCaret, + const CFX_WideString& wsRange, + FX_BOOL bSel) + : m_pEngine(pEngine), + m_bSel(bSel), + m_nIndex(nIndex), + m_nCaret(nCaret), + m_wsRange(wsRange) { + FXSYS_assert(pEngine); +} +CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {} +void CFDE_TxtEdtDoRecord_DeleteRange::Release() { + delete this; +} +FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() { + if (m_pEngine->IsSelect()) { + m_pEngine->ClearSelection(); + } + m_pEngine->Inner_Insert(m_nIndex, m_wsRange.c_str(), m_wsRange.GetLength()); + if (m_bSel) { + m_pEngine->AddSelRange(m_nIndex, m_wsRange.GetLength()); + } + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; + m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nCaret, TRUE); + return TRUE; +} +FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() { + m_pEngine->Inner_DeleteRange(m_nIndex, m_wsRange.GetLength()); + if (m_bSel) { + m_pEngine->RemoveSelRange(m_nIndex, m_wsRange.GetLength()); + } + FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; + m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; + m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; + Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + m_pEngine->SetCaretPos(m_nIndex, TRUE); + return TRUE; +} +void CFDE_TxtEdtDoRecord_DeleteRange::Serialize( + CFX_ByteString& bsDoRecord) const { + CFX_ArchiveSaver ArchiveSaver; + ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_DEL); + ArchiveSaver << (int32_t)(uintptr_t)m_pEngine; + ArchiveSaver << (int32_t)m_bSel; + ArchiveSaver << m_nIndex; + ArchiveSaver << m_nCaret; + ArchiveSaver << m_wsRange; + int32_t nLength = ArchiveSaver.GetLength(); + const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); + FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); + FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); + bsDoRecord.ReleaseBuffer(nLength); +} +void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize( + const CFX_ByteStringC& bsDoRecord) { + CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(), + bsDoRecord.GetLength()); + int32_t nType = 0; + ArchiveLoader >> nType; + FXSYS_assert(nType == FDE_TXTEDT_DORECORD_DEL); + int32_t nEngine = 0; + ArchiveLoader >> nEngine; + m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; + int32_t iSel = 0; + ArchiveLoader >> iSel; + m_bSel = !!iSel; + ArchiveLoader >> m_nIndex; + ArchiveLoader >> m_nCaret; + ArchiveLoader >> m_wsRange; +} diff --git a/xfa/fee/fde_txtedtengine.h b/xfa/fee/fde_txtedtengine.h new file mode 100644 index 0000000000..9dc4c4eae2 --- /dev/null +++ b/xfa/fee/fde_txtedtengine.h @@ -0,0 +1,247 @@ +// 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_FDE_TXTEDTENGINE_H_ +#define XFA_FEE_FDE_TXTEDTENGINE_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fee/ifde_txtedtbuf.h" +#include "xfa/fee/ifde_txtedtengine.h" + +class IFX_TxtBreak; +class IFX_CharIter; +class CFDE_TxtEdtParag; +class CFDE_TxtEdtDoRecord_Insert; +class CFDE_TxtEdtDoRecord_DeleteRange; + +class IFDE_TxtEdtDoRecord { + public: + static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord); + virtual ~IFDE_TxtEdtDoRecord() {} + virtual void Release() = 0; + virtual FX_BOOL Redo() = 0; + virtual FX_BOOL Undo() = 0; + 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; + + 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 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(); + + virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo); + virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo); + + virtual int32_t StartLayout(); + virtual int32_t DoLayout(IFX_Pause* pPause); + virtual 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; + int32_t GetTextBufLength() const; + IFX_TxtBreak* GetTextBreak() const; + int32_t GetLineCount() const; + int32_t GetPageLineCount() const; + + int32_t Line2Parag(int32_t nStartParag, + int32_t nStartLineofParag, + int32_t nLineIndex, + int32_t& nStartLine) const; + FX_WCHAR GetAliasChar() const { return m_wcAliasChar; } + + protected: + virtual ~CFDE_TxtEdtEngine(); + + private: + void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); + void GetPreDeleteText(CFX_WideString& wsText, + int32_t nIndex, + int32_t nLength); + void GetPreInsertText(CFX_WideString& wsText, + int32_t nIndex, + const FX_WCHAR* lpText, + int32_t nLength); + void GetPreReplaceText(CFX_WideString& wsText, + int32_t nIndex, + int32_t nOriginLength, + const FX_WCHAR* lpText, + int32_t nLength); + + void Inner_DeleteRange(int32_t nStart, int32_t nCount = -1); + void DeleteRange_DoRecord(int32_t nStart, + int32_t nCount, + FX_BOOL bSel = FALSE); + void ResetEngine(); + void RebuildParagraphs(); + void RemoveAllParags(); + void RemoveAllPages(); + void UpdateParags(); + void UpdatePages(); + void UpdateTxtBreak(); + + FX_BOOL ReplaceParagEnd(FX_WCHAR*& lpText, + int32_t& nLength, + FX_BOOL bPreIsCR = FALSE); + void RecoverParagEnd(CFX_WideString& wsText); + int32_t MovePage2Char(int32_t nIndex); + void TextPos2ParagPos(int32_t nIndex, FDE_TXTEDTPARAGPOS& ParagPos) const; + int32_t MoveForward(FX_BOOL& bBefore); + int32_t MoveBackward(FX_BOOL& bBefore); + FX_BOOL MoveUp(CFX_PointF& ptCaret); + FX_BOOL MoveDown(CFX_PointF& ptCaret); + FX_BOOL MoveLineStart(); + FX_BOOL MoveLineEnd(); + FX_BOOL MoveParagStart(); + FX_BOOL MoveParagEnd(); + FX_BOOL MoveHome(); + FX_BOOL MoveEnd(); + FX_BOOL IsFitArea(CFX_WideString& wsText); + void UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore = TRUE); + void GetCaretRect(CFX_RectF& rtCaret, + int32_t nPageIndex, + int32_t nCaret, + FX_BOOL bBefore = TRUE); + void UpdateCaretIndex(const CFX_PointF& ptCaret); + + FX_BOOL IsSelect(); + void DeleteSelect(); + + IFDE_TxtEdtBuf* m_pTxtBuf; + IFX_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; + int32_t m_nPageLineCount; + int32_t m_nLineCount; + int32_t m_nAnchorPos; + int32_t m_nLayoutPos; + FX_FLOAT m_fCaretPosReserve; + int32_t m_nCaret; + FX_BOOL m_bBefore; + int32_t m_nCaretPage; + CFX_RectF m_rtCaret; + FX_DWORD m_dwFindFlags; + FX_BOOL m_bLock; + int32_t m_nLimit; + FX_WCHAR m_wcAliasChar; + int32_t m_nFirstLineEnd; + FX_BOOL m_bAutoLineEnd; + FX_WCHAR m_wLineEnd; + FDE_TXTEDT_TEXTCHANGE_INFO m_ChangeInfo; +}; + +class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord { + public: + CFDE_TxtEdtDoRecord_Insert(const CFX_ByteStringC& bsDoRecord); + CFDE_TxtEdtDoRecord_Insert(CFDE_TxtEdtEngine* pEngine, + int32_t nCaret, + const FX_WCHAR* lpText, + int32_t nLength); + virtual void Release(); + virtual FX_BOOL Undo(); + virtual FX_BOOL Redo(); + virtual void Serialize(CFX_ByteString& bsDoRecord) const; + + protected: + ~CFDE_TxtEdtDoRecord_Insert(); + void Deserialize(const CFX_ByteStringC& bsDoRecord); + + private: + CFDE_TxtEdtEngine* m_pEngine; + int32_t m_nCaret; + CFX_WideString m_wsInsert; +}; + +class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord { + public: + CFDE_TxtEdtDoRecord_DeleteRange(const CFX_ByteStringC& bsDoRecord); + CFDE_TxtEdtDoRecord_DeleteRange(CFDE_TxtEdtEngine* pEngine, + int32_t nIndex, + int32_t nCaret, + const CFX_WideString& wsRange, + FX_BOOL bSel = FALSE); + virtual void Release(); + virtual FX_BOOL Undo(); + virtual FX_BOOL Redo(); + virtual void Serialize(CFX_ByteString& bsDoRecord) const; + + protected: + ~CFDE_TxtEdtDoRecord_DeleteRange(); + void Deserialize(const CFX_ByteStringC& bsDoRecord); + + private: + CFDE_TxtEdtEngine* m_pEngine; + FX_BOOL m_bSel; + int32_t m_nIndex; + int32_t m_nCaret; + CFX_WideString m_wsRange; +}; + +#endif // XFA_FEE_FDE_TXTEDTENGINE_H_ diff --git a/xfa/fee/fde_txtedtpage.cpp b/xfa/fee/fde_txtedtpage.cpp new file mode 100644 index 0000000000..5ecbceaf40 --- /dev/null +++ b/xfa/fee/fde_txtedtpage.cpp @@ -0,0 +1,650 @@ +// 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/fee/fde_txtedtpage.h" + +#include <algorithm> + +#include "xfa/fee/fde_txtedtbuf.h" +#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, + int32_t nIndex) { + return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex); +} +CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage) + : m_pPage(pPage) {} +CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {} +FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() { + return FDE_VISUALOBJ_Text; +} +FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj, + CFX_RectF& bbox) { + return FALSE; +} +FX_BOOL CFDE_TxtEdtTextSet::GetMatrix(FDE_HVISUALOBJ hVisualObj, + CFX_Matrix& matrix) { + return FALSE; +} +FX_BOOL CFDE_TxtEdtTextSet::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { + rt = ((FDE_TEXTEDITPIECE*)(hVisualObj))->rtPiece; + return TRUE; +} +FX_BOOL CFDE_TxtEdtTextSet::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { + return FALSE; +} +int32_t CFDE_TxtEdtTextSet::GetString(FDE_HVISUALOBJ hText, + CFX_WideString& wsText) { + FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; + FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount); + for (int32_t i = 0; i < pPiece->nCount; i++) { + pBuffer[i] = m_pPage->GetChar((void*)hText, i); + } + wsText.ReleaseBuffer(pPiece->nCount); + return pPiece->nCount; +} +IFX_Font* CFDE_TxtEdtTextSet::GetFont(FDE_HVISUALOBJ hText) { + return m_pPage->GetEngine()->GetEditParams()->pFont; +} +FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize(FDE_HVISUALOBJ hText) { + return m_pPage->GetEngine()->GetEditParams()->fFontSize; +} +FX_ARGB CFDE_TxtEdtTextSet::GetFontColor(FDE_HVISUALOBJ hText) { + return m_pPage->GetEngine()->GetEditParams()->dwFontColor; +} +int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode, + CFX_WideString* pWSForms) { + if (hText == NULL) { + return 0; + } + FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; + int32_t nLength = pPiece->nCount; + if (nLength < 1) { + return 0; + } + CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); + const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); + IFX_TxtBreak* pBreak = pEngine->GetTextBreak(); + FX_DWORD 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; + tr.dwStyles = dwLayoutStyle; + tr.iCharRotation = pTextParams->nCharRotation; + tr.dwCharStyles = pPiece->dwCharStyles; + tr.pRect = &(pPiece->rtPiece); + tr.wLineBreakChar = pTextParams->wLineBreakChar; + return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms); +} +int32_t CFDE_TxtEdtTextSet::GetCharRects(FDE_HVISUALOBJ hText, + CFX_RectFArray& rtArray) { + return GetCharRects_Impl(hText, rtArray); +} +int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText, + CFX_RectFArray& rtArray, + FX_BOOL bBBox) { + if (hText == NULL) { + return 0; + } + FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; + CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); + int32_t nLength = pPiece->nCount; + if (nLength < 1) { + return 0; + } + const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); + FX_DWORD dwLayoutStyle = pEngine->GetTextBreak()->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; + tr.dwStyles = dwLayoutStyle; + tr.iCharRotation = pTextParams->nCharRotation; + tr.dwCharStyles = pPiece->dwCharStyles; + tr.pRect = &(pPiece->rtPiece); + tr.wLineBreakChar = pTextParams->wLineBreakChar; + return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox); +} +CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) + : m_pIter(nullptr), + m_pTextSet(nullptr), + m_pBgnParag(nullptr), + m_pEndParag(nullptr), + m_nRefCount(0), + m_nPageStart(-1), + m_nCharCount(0), + m_nPageIndex(nPageIndex), + m_bLoaded(FALSE), + m_pCharWidth(nullptr) { + FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); + FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); + FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); + 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; + } +} +void CFDE_TxtEdtPage::Release() { + delete this; +} +IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { + return (IFDE_TxtEdtEngine*)m_pEditEngine; +} +FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { + return FDE_VISUALOBJ_Text; +} +FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { + return FALSE; +} +FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj, + CFX_Matrix& matrix) { + return FALSE; +} +FX_BOOL CFDE_TxtEdtPage::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { + return FALSE; +} +FX_BOOL CFDE_TxtEdtPage::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { + return FALSE; +} +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); + if (m_nRefCount < 1) { + return 0; + } + int32_t nCount = m_PieceMassArr.GetSize(); + for (int32_t i = 0; i < nCount; i++) { + const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); + if (nIndex >= pPiece->nStart && + nIndex < (pPiece->nStart + pPiece->nCount)) { + CFX_RectFArray rectArr; + if (bBBox) { + m_pTextSet->GetCharRects_Impl((FDE_HVISUALOBJ)pPiece, rectArr, bBBox); + } else { + m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr); + } + rect = rectArr[nIndex - pPiece->nStart]; + return pPiece->nBidiLevel; + } + } + FXSYS_assert(0); + return 0; +} +int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, + FX_BOOL& bBefore) { + FX_BOOL bVertical = m_pEditEngine->GetEditParams()->dwLayoutStyles & + FDE_TEXTEDITLAYOUT_DocVertical; + CFX_PointF ptF = fPoint; + NormalizePt2Rect(ptF, m_rtPageContents, FDE_TXTEDT_TOLERANCE); + int32_t nCount = m_PieceMassArr.GetSize(); + CFX_RectF rtLine; + int32_t nBgn = 0; + int32_t nEnd = 0; + FX_BOOL bInLine = FALSE; + int32_t i = 0; + for (i = 0; i < nCount; i++) { + const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); + if (!bInLine && (bVertical ? (pPiece->rtPiece.left <= ptF.x && + pPiece->rtPiece.right() > ptF.x) + : (pPiece->rtPiece.top <= ptF.y && + pPiece->rtPiece.bottom() > ptF.y))) { + nBgn = nEnd = i; + rtLine = pPiece->rtPiece; + bInLine = TRUE; + } else if (bInLine) { + if (bVertical ? (!(pPiece->rtPiece.left <= ptF.x && + pPiece->rtPiece.right() > ptF.x)) + : (pPiece->rtPiece.bottom() <= ptF.y || + pPiece->rtPiece.top > ptF.y)) { + nEnd = i - 1; + break; + } else { + rtLine.Union(pPiece->rtPiece); + } + } + } + NormalizePt2Rect(ptF, rtLine, FDE_TXTEDT_TOLERANCE); + int32_t nCaret = 0; + FDE_TEXTEDITPIECE* pPiece = NULL; + for (i = nBgn; i <= nEnd; i++) { + pPiece = m_PieceMassArr.GetPtrAt(i); + nCaret = m_nPageStart + pPiece->nStart; + if (pPiece->rtPiece.Contains(ptF)) { + CFX_RectFArray rectArr; + m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr); + int32_t nRtCount = rectArr.GetSize(); + for (int32_t j = 0; j < nRtCount; j++) { + if (rectArr[j].Contains(ptF)) { + nCaret = m_nPageStart + pPiece->nStart + j; + if (nCaret >= m_pEditEngine->GetTextBufLength()) { + bBefore = TRUE; + return m_pEditEngine->GetTextBufLength(); + } + FX_WCHAR wChar = m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret); + if (wChar == L'\n' || wChar == L'\r') { + if (wChar == L'\n') { + if (m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret - 1) == + L'\r') { + nCaret--; + } + } + bBefore = TRUE; + return nCaret; + } + if (bVertical + ? (ptF.y > ((rectArr[j].top + rectArr[j].bottom()) / 2)) + : (ptF.x > ((rectArr[j].left + rectArr[j].right()) / 2))) { + bBefore = FX_IsOdd(pPiece->nBidiLevel); + } else { + bBefore = !FX_IsOdd(pPiece->nBidiLevel); + } + return nCaret; + } + } + } + } + bBefore = TRUE; + return nCaret; +} +int32_t CFDE_TxtEdtPage::GetCharStart() const { + return m_nPageStart; +} +int32_t CFDE_TxtEdtPage::GetCharCount() const { + return m_nCharCount; +} +int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip, + FXTEXT_CHARPOS*& pCharPos, + CFX_RectF* pBBox) const { + pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount); + int32_t nCharPosCount = 0; + FDE_HVISUALOBJ hVisualObj = NULL; + int32_t nVisualObjCount = m_PieceMassArr.GetSize(); + FXTEXT_CHARPOS* pos = pCharPos; + CFX_RectF rtObj; + for (int32_t i = 0; i < nVisualObjCount; i++) { + hVisualObj = (FDE_HVISUALOBJ)m_PieceMassArr.GetPtrAt(i); + m_pTextSet->GetRect(hVisualObj, rtObj); + if (!rtClip.IntersectWith(rtObj)) { + continue; + } + int32_t nCount = m_pTextSet->GetDisplayPos(hVisualObj, pos, FALSE); + nCharPosCount += nCount; + pos += nCount; + } + if ((nCharPosCount * 5) < (m_nCharCount << 2)) { + FXTEXT_CHARPOS* pTemp = FX_Alloc(FXTEXT_CHARPOS, nCharPosCount); + FXSYS_memcpy(pTemp, pCharPos, sizeof(FXTEXT_CHARPOS) * nCharPosCount); + FX_Free(pCharPos); + pCharPos = pTemp; + } + return nCharPosCount; +} +void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart, + int32_t nCount, + CFX_RectFArray& RectFArr) const { + int32_t nPieceCount = m_PieceMassArr.GetSize(); + int32_t nEnd = nStart + nCount - 1; + FX_BOOL bInRange = FALSE; + for (int32_t i = 0; i < nPieceCount; i++) { + FDE_TEXTEDITPIECE* piece = m_PieceMassArr.GetPtrAt(i); + if (!bInRange) { + if (nStart >= piece->nStart && nStart < (piece->nStart + piece->nCount)) { + int32_t nRangeEnd = piece->nCount - 1; + FX_BOOL bEnd = FALSE; + if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { + nRangeEnd = nEnd - piece->nStart; + bEnd = TRUE; + } + CFX_RectFArray rcArr; + m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr); + CFX_RectF rectPiece = rcArr[nStart - piece->nStart]; + rectPiece.Union(rcArr[nRangeEnd]); + RectFArr.Add(rectPiece); + if (bEnd) { + return; + } + bInRange = TRUE; + } + } else { + if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { + CFX_RectFArray rcArr; + m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr); + CFX_RectF rectPiece = rcArr[0]; + rectPiece.Union(rcArr[nEnd - piece->nStart]); + RectFArr.Add(rectPiece); + return; + } + RectFArr.Add(piece->rtPiece); + } + } +} + +int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { + if (m_nRefCount < 0) { + return -1; + } + IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); + FX_BOOL bBefore; + int32_t nIndex = GetCharIndex(fPoint, bBefore); + if (nIndex == m_pEditEngine->GetTextBufLength()) { + nIndex = m_pEditEngine->GetTextBufLength() - 1; + } + if (nIndex < 0) { + return -1; + } + IFX_WordBreak* pIter = FX_WordBreak_Create(); + pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); + pIter->SetAt(nIndex); + nCount = pIter->GetWordLength(); + int32_t nRet = pIter->GetWordPos(); + pIter->Release(); + return nRet; +} +FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { + return m_bLoaded; +} +int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, + IFX_Pause* pPause) { + if (m_nRefCount > 0) { + m_nRefCount++; + return m_nRefCount; + } + IFDE_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(); + pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + pBreak->ClearBreakPieces(); + int32_t nPageLineCount = m_pEditEngine->GetPageLineCount(); + int32_t nStartLine = nPageLineCount * m_nPageIndex; + int32_t nEndLine = std::min((nStartLine + nPageLineCount - 1), + (m_pEditEngine->GetLineCount() - 1)); + int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, + nEndLineInParag; + nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); + m_pBgnParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nBgnParag); + m_pBgnParag->LoadParag(); + m_pBgnParag->GetLineRange(nStartLine - nStartLineInParag, nPageStart, nTemp); + nEndParag = m_pEditEngine->Line2Parag(nBgnParag, nStartLineInParag, nEndLine, + nEndLineInParag); + m_pEndParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nEndParag); + m_pEndParag->LoadParag(); + m_pEndParag->GetLineRange(nEndLine - nEndLineInParag, nPageEnd, nTemp); + nPageEnd += (nTemp - 1); + FX_BOOL bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; + FX_BOOL bLineReserve = + pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; + FX_FLOAT fLineStart = + bVertial + ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f) + : 0.0f; + FX_FLOAT fLineStep = + (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace; + FX_FLOAT fLinePos = fLineStart; + if (m_pTextSet == NULL) { + m_pTextSet = new CFDE_TxtEdtTextSet(this); + } + m_PieceMassArr.RemoveAll(TRUE); + FX_DWORD dwBreakStatus = FX_TXTBREAK_None; + int32_t nPieceStart = 0; + if (m_pCharWidth != NULL) { + delete[] m_pCharWidth; + } + m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1]; + pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + pBreak->ClearBreakPieces(); + m_nPageStart = nPageStart; + m_nCharCount = nPageEnd - nPageStart + 1; + FX_BOOL bReload = FALSE; + FX_FLOAT fDefCharWidth = 0; + IFX_CharIter* pIter = m_pIter->Clone(); + pIter->SetAt(nPageStart); + m_pIter->SetAt(nPageStart); + FX_BOOL bFirstPiece = TRUE; + do { + if (bReload) { + dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } else { + FX_WCHAR wAppend = pIter->GetChar(); + dwBreakStatus = pBreak->AppendChar(wAppend); + } + if (pIter->GetAt() == nPageEnd && dwBreakStatus < FX_TXTBREAK_LineBreak) { + dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + int32_t nPieceCount = pBreak->CountBreakPieces(); + for (int32_t j = 0; j < nPieceCount; j++) { + const CFX_TxtPiece* pPiece = pBreak->GetBreakPiece(j); + FDE_TEXTEDITPIECE TxtEdtPiece; + FXSYS_memset(&TxtEdtPiece, 0, sizeof(FDE_TEXTEDITPIECE)); + TxtEdtPiece.nBidiLevel = pPiece->m_iBidiLevel; + TxtEdtPiece.nCount = pPiece->GetLength(); + TxtEdtPiece.nStart = nPieceStart; + TxtEdtPiece.dwCharStyles = pPiece->m_dwCharStyles; + if (FX_IsOdd(pPiece->m_iBidiLevel)) { + TxtEdtPiece.dwCharStyles |= FX_TXTCHARSTYLE_OddBidiLevel; + } + FX_FLOAT fParaBreakWidth = 0.0f; + if (pPiece->m_dwStatus > FX_TXTBREAK_PieceBreak) { + FX_WCHAR wRtChar = pParams->wLineBreakChar; + if (TxtEdtPiece.nCount >= 2) { + FX_WCHAR wChar = pBuf->GetCharByIndex( + m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 1); + FX_WCHAR wCharPre = pBuf->GetCharByIndex( + m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 2); + if (wChar == wRtChar) { + fParaBreakWidth += fDefCharWidth; + } + if (wCharPre == wRtChar) { + fParaBreakWidth += fDefCharWidth; + } + } else if (TxtEdtPiece.nCount >= 1) { + FX_WCHAR wChar = pBuf->GetCharByIndex( + m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 1); + if (wChar == wRtChar) { + fParaBreakWidth += fDefCharWidth; + } + } + } + if (pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { + TxtEdtPiece.rtPiece.left = fLinePos; + TxtEdtPiece.rtPiece.top = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; + TxtEdtPiece.rtPiece.width = pParams->fLineSpace; + TxtEdtPiece.rtPiece.height = + (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; + } else { + TxtEdtPiece.rtPiece.left = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; + TxtEdtPiece.rtPiece.top = fLinePos; + TxtEdtPiece.rtPiece.width = + (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; + TxtEdtPiece.rtPiece.height = pParams->fLineSpace; + } + if (bFirstPiece) { + m_rtPageContents = TxtEdtPiece.rtPiece; + bFirstPiece = FALSE; + } else { + m_rtPageContents.Union(TxtEdtPiece.rtPiece); + } + nPieceStart += TxtEdtPiece.nCount; + m_PieceMassArr.Add(TxtEdtPiece); + for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) { + CFX_Char* ptc = pPiece->GetCharPtr(k); + m_pCharWidth[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth; + } + } + fLinePos += fLineStep; + pBreak->ClearBreakPieces(); + } + if (pIter->GetAt() == nPageEnd && dwBreakStatus == FX_TXTBREAK_LineBreak) { + bReload = TRUE; + pIter->Next(TRUE); + } + } while (pIter->Next(FALSE) && (pIter->GetAt() <= nPageEnd)); + if (m_rtPageContents.left != 0) { + FX_FLOAT fDelta = 0.0f; + if (m_rtPageContents.width < pParams->fPlateWidth) { + if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Right) { + fDelta = pParams->fPlateWidth - m_rtPageContents.width; + } else if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Center) { + if ((pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) && + m_nCharCount > 1) { + int32_t nCount = m_nCharCount - 1; + int32_t n = (m_pEditEngine->m_nLimit - nCount) / 2; + fDelta = (m_rtPageContents.width / nCount) * n; + } else { + fDelta = (pParams->fPlateWidth - m_rtPageContents.width) / 2; + } + } + } + FX_FLOAT fOffset = m_rtPageContents.left - fDelta; + int32_t nCount = m_PieceMassArr.GetSize(); + for (int32_t i = 0; i < nCount; i++) { + FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); + pPiece->rtPiece.Offset(-fOffset, 0.0f); + } + m_rtPageContents.Offset(-fOffset, 0.0f); + } + if (m_pEditEngine->GetEditParams()->dwLayoutStyles & + FDE_TEXTEDITLAYOUT_LastLineHeight) { + m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize; + int32_t nCount = m_PieceMassArr.GetSize(); + 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); + 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; + } +} + +const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { + return m_rtPageContents; +} +FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) { + if (m_PieceMassArr.GetSize() < 1) { + return NULL; + } + return (FX_POSITION)1; +} +FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas, + FX_POSITION& pos, + IFDE_VisualSet*& pVisualSet) { + if (m_pTextSet == NULL) { + pos = NULL; + return NULL; + } + int32_t nPos = (int32_t)(uintptr_t)pos; + pVisualSet = m_pTextSet; + if (nPos + 1 > m_PieceMassArr.GetSize()) { + pos = NULL; + } else { + pos = (FX_POSITION)(uintptr_t)(nPos + 1); + } + return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1)); +} +FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas, + IFDE_VisualSet*& pVisualSet) { + return NULL; +} +FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const { + int32_t nIndex = + m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index; + if (nIndex != m_pIter->GetAt()) { + m_pIter->SetAt(nIndex); + } + FX_WCHAR wChar = m_pIter->GetChar(); + m_pIter->Next(); + return wChar; +} +int32_t CFDE_TxtEdtPage::GetWidth(void* pIdentity, int32_t index) const { + int32_t nWidth = + m_pCharWidth[((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index]; + return nWidth; +} +void CFDE_TxtEdtPage::NormalizePt2Rect(CFX_PointF& ptF, + const CFX_RectF& rtF, + FX_FLOAT fTolerance) const { + if (rtF.Contains(ptF.x, ptF.y)) { + return; + } + if (ptF.x < rtF.left) { + ptF.x = rtF.left; + } else if (ptF.x >= rtF.right()) { + ptF.x = rtF.right() - fTolerance; + } + if (ptF.y < rtF.top) { + ptF.y = rtF.top; + } else if (ptF.y >= rtF.bottom()) { + ptF.y = rtF.bottom() - fTolerance; + } +} diff --git a/xfa/fee/fde_txtedtpage.h b/xfa/fee/fde_txtedtpage.h new file mode 100644 index 0000000000..66c4c49282 --- /dev/null +++ b/xfa/fee/fde_txtedtpage.h @@ -0,0 +1,168 @@ +// 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_FDE_TXTEDTPAGE_H_ +#define XFA_FEE_FDE_TXTEDTPAGE_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fde/fde_visualset.h" +#include "xfa/fee/ifde_txtedtpage.h" +#include "xfa/fgas/crt/fgas_utils.h" + +class IFX_CharIter; +class CFDE_TxtEdtEngine; +class CFDE_TxtEdtPage; +class CFDE_TxtEdtParag; + +enum FDE_TXTEDT_CHARTYPE { + FDE_TXTEDT_CHARTYPE_Unknown = 0, + FDE_TXTEDT_CHARTYPE_Tab, + FDE_TXTEDT_CHARTYPE_Space, + FDE_TXTEDT_CHARTYPE_Punctuation, + FDE_TXTEDT_CHARTYPE_LineBreak, + FDE_TXTEDT_CHARTYPE_Number, + FDE_TXTEDT_CHARTYPE_Char, + FDE_TXTEDT_CHARTYPE_CJK, +}; + +inline FDE_TXTEDT_CHARTYPE FDE_GetEditSelCharType(FX_WCHAR wChar) { + if (wChar == 0x9) { + return FDE_TXTEDT_CHARTYPE_Tab; + } else if (wChar == 0x20 || wChar == 0xA0) { + return FDE_TXTEDT_CHARTYPE_Space; + } else if (wChar == 0x9 || wChar == 0x20 || wChar == 0xA0 || + (wChar >= L'!' && wChar <= L'/') || + (wChar >= L':' && wChar <= L'@') || + (wChar >= L'[' && wChar <= L'^') || + (wChar >= L'{' && wChar <= L'~') || wChar == 0x60) { + return FDE_TXTEDT_CHARTYPE_Punctuation; + } else if (wChar == 0x0a || wChar == 0x0d) { + return FDE_TXTEDT_CHARTYPE_LineBreak; + } else if (wChar >= '0' && wChar <= '9') { + return FDE_TXTEDT_CHARTYPE_Number; + } else if ((wChar >= 0x2e80 && wChar <= 0x2eff) || + (wChar >= 0x3000 && wChar <= 0x303f) || + (wChar >= 0x31c0 && wChar <= 0x31ef) || + (wChar >= 0x3200 && wChar <= 0x32ff) || + (wChar >= 0x3300 && wChar <= 0x33ff) || + (wChar >= 0x3400 && wChar <= 0x4dbf) || + (wChar >= 0x4e00 && wChar <= 0x9fff) || + (wChar >= 0xf900 && wChar <= 0xfaff) || + (wChar >= 0xfe30 && wChar <= 0xfe4f)) { + return FDE_TXTEDT_CHARTYPE_CJK; + } else { + return FDE_TXTEDT_CHARTYPE_Char; + } +} + +struct FDE_TEXTEDITPIECE { + int32_t nStart; + int32_t nCount; + int32_t nBidiLevel; + CFX_RectF rtPiece; + FX_DWORD dwCharStyles; +}; +typedef CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> CFDE_TXTEDTPieceMassArray; + +class CFDE_TxtEdtTextSet : public IFDE_TextSet { + public: + CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage); + ~CFDE_TxtEdtTextSet(); + + virtual FDE_VISUALOBJTYPE GetType(); + virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox); + virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix); + virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt); + virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt); + virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText); + virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText); + virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText); + virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText); + virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE, + CFX_WideString* pWSForms = NULL); + virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, CFX_RectFArray& rtArray); + virtual int32_t GetCharRects_Impl(FDE_HVISUALOBJ hText, + CFX_RectFArray& rtArray, + FX_BOOL bBBox = FALSE); + + private: + CFDE_TxtEdtPage* m_pPage; +}; + +class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { + public: + CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nLineIndex); + + // IFDE_TxtEditPage: + void Release() override; + IFDE_TxtEdtEngine* GetEngine() const override; + int32_t GetCharRect(int32_t nIndex, + CFX_RectF& rect, + FX_BOOL bBBox = FALSE) const override; + int32_t GetCharIndex(const CFX_PointF& fPoint, FX_BOOL& bBefore) override; + void CalcRangeRectArray(int32_t nStart, + int32_t nCount, + CFX_RectFArray& RectFArr) const override; + int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) override; + int32_t GetCharStart() const override; + int32_t GetCharCount() const override; + int32_t GetDisplayPos(const CFX_RectF& rtClip, + FXTEXT_CHARPOS*& pCharPos, + CFX_RectF* pBBox) const override; + FX_BOOL IsLoaded(const CFX_RectF* pClipBox) override; + int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) override; + void UnloadPage(const CFX_RectF* pClipBox) override; + const CFX_RectF& GetContentsBox() override; + + // IFDE_VisualSet: + FDE_VISUALOBJTYPE GetType() override; + FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override; + FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override; + FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override; + FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override; + + // IFDE_CanvasSet: + FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) override; + FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas, + FX_POSITION& pos, + IFDE_VisualSet*& pVisualSet) override; + FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas, + IFDE_VisualSet*& pVisualSet) override; + + // IFX_TxtAccess: + FX_WCHAR GetChar(void* pIdentity, int32_t index) const override; + int32_t GetWidth(void* pIdentity, int32_t index) const override; + + protected: + virtual ~CFDE_TxtEdtPage(); + + private: + void NormalizePt2Rect(CFX_PointF& ptF, + const CFX_RectF& rtF, + FX_FLOAT fTolerance) const; + + IFX_CharIter* m_pIter; + CFDE_TxtEdtTextSet* m_pTextSet; + CFDE_TxtEdtEngine* m_pEditEngine; + CFDE_TXTEDTPieceMassArray m_PieceMassArr; + CFDE_TxtEdtParag* m_pBgnParag; + CFDE_TxtEdtParag* m_pEndParag; + int32_t m_nRefCount; + int32_t m_nPageStart; + int32_t m_nCharCount; + int32_t m_nPageIndex; + FX_BOOL m_bLoaded; + CFX_RectF m_rtPage; + CFX_RectF m_rtPageMargin; + CFX_RectF m_rtPageContents; + CFX_RectF m_rtPageCanvas; + int32_t* m_pCharWidth; +}; + +#endif // XFA_FEE_FDE_TXTEDTPAGE_H_ diff --git a/xfa/fee/fde_txtedtparag.cpp b/xfa/fee/fde_txtedtparag.cpp new file mode 100644 index 0000000000..427bbbc2ce --- /dev/null +++ b/xfa/fee/fde_txtedtparag.cpp @@ -0,0 +1,150 @@ +// 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/fee/fde_txtedtparag.h" + +#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" + +CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine) + : m_nCharStart(0), + m_nCharCount(0), + m_nLineCount(0), + m_lpData(NULL), + m_pEngine(pEngine) { + FXSYS_assert(m_pEngine); +} +CFDE_TxtEdtParag::~CFDE_TxtEdtParag() { + if (m_lpData != NULL) { + FX_Free(m_lpData); + } +} +void CFDE_TxtEdtParag::LoadParag() { + if (m_lpData != NULL) { + ((int32_t*)m_lpData)[0]++; + return; + } + IFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); + IFDE_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); + pIter->SetAt(m_nCharStart); + int32_t nEndIndex = m_nCharStart + m_nCharCount; + CFX_ArrayTemplate<int32_t> LineBaseArr; + FX_BOOL bReload = FALSE; + FX_DWORD dwBreakStatus = FX_TXTBREAK_None; + do { + if (bReload) { + dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } else { + FX_WCHAR wAppend = pIter->GetChar(); + dwBreakStatus = pTxtBreak->AppendChar(wAppend); + } + if (pIter->GetAt() + 1 == nEndIndex && + dwBreakStatus < FX_TXTBREAK_LineBreak) { + dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + int32_t nCount = pTxtBreak->CountBreakPieces(); + int32_t nTotal = 0; + for (int32_t j = 0; j < nCount; j++) { + const CFX_TxtPiece* Piece = pTxtBreak->GetBreakPiece(j); + nTotal += Piece->GetLength(); + } + LineBaseArr.Add(nTotal); + pTxtBreak->ClearBreakPieces(); + } + if ((pIter->GetAt() + 1 == nEndIndex) && + (dwBreakStatus == FX_TXTBREAK_LineBreak)) { + bReload = TRUE; + pIter->Next(TRUE); + } + } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); + pIter->Release(); + pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + pTxtBreak->ClearBreakPieces(); + int32_t nLineCount = LineBaseArr.GetSize(); + m_nLineCount = nLineCount; + if (m_lpData == NULL) { + m_lpData = FX_Alloc(int32_t, nLineCount + 1); + } else { + m_lpData = FX_Realloc(int32_t, m_lpData, (nLineCount + 1)); + } + int32_t* pIntArr = (int32_t*)m_lpData; + pIntArr[0] = 1; + m_nLineCount = nLineCount; + pIntArr++; + for (int32_t j = 0; j < nLineCount; j++, pIntArr++) { + *pIntArr = LineBaseArr[j]; + } + LineBaseArr.RemoveAll(); +} +void CFDE_TxtEdtParag::UnloadParag() { + FXSYS_assert(m_lpData != NULL); + ((int32_t*)m_lpData)[0]--; + FXSYS_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); + int32_t nCount = 0; + FX_DWORD dwBreakStatus = FX_TXTBREAK_None; + int32_t nEndIndex = m_nCharStart + m_nCharCount; + pIter->SetAt(m_nCharStart); + FX_BOOL bReload = FALSE; + do { + if (bReload) { + dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } else { + FX_WCHAR wAppend = pIter->GetChar(); + dwBreakStatus = pTxtBreak->AppendChar(wAppend); + } + if (pIter->GetAt() + 1 == nEndIndex && + dwBreakStatus < FX_TXTBREAK_LineBreak) { + dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + } + if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { + nCount++; + pTxtBreak->ClearBreakPieces(); + } + if ((pIter->GetAt() + 1 == nEndIndex) && + (dwBreakStatus == FX_TXTBREAK_LineBreak)) { + bReload = TRUE; + pIter->Next(TRUE); + } + } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); + pIter->Release(); + pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); + pTxtBreak->ClearBreakPieces(); + m_nLineCount = nCount; +} +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); + nStart = m_nCharStart; + pLineBaseArr++; + for (int32_t i = 0; i < nLineIndex; i++) { + nStart += *pLineBaseArr; + pLineBaseArr++; + } + nCount = *pLineBaseArr; +} diff --git a/xfa/fee/fde_txtedtparag.h b/xfa/fee/fde_txtedtparag.h new file mode 100644 index 0000000000..39921d5ef7 --- /dev/null +++ b/xfa/fee/fde_txtedtparag.h @@ -0,0 +1,37 @@ +// 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_FDE_TXTEDTPARAG_H_ +#define XFA_FEE_FDE_TXTEDTPARAG_H_ + +#include "xfa/fee/ifde_txtedtengine.h" + +class CFDE_TxtEdtEngine; + +class CFDE_TxtEdtParag : public IFDE_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; + void LoadParag(); + void UnloadParag(); + void CalcLines(); + int32_t m_nCharStart; + int32_t m_nCharCount; + int32_t m_nLineCount; + + private: + void* m_lpData; + CFDE_TxtEdtEngine* m_pEngine; +}; + +#endif // XFA_FEE_FDE_TXTEDTPARAG_H_ diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak.h b/xfa/fee/fx_wordbreak/fx_wordbreak.h new file mode 100644 index 0000000000..0288b5926b --- /dev/null +++ b/xfa/fee/fx_wordbreak/fx_wordbreak.h @@ -0,0 +1,30 @@ +// 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_FX_WORDBREAK_FX_WORDBREAK_H_ +#define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxcrt/fx_system.h" + +class IFX_CharIter; + +class IFX_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; +}; +IFX_WordBreak* FX_WordBreak_Create(); + +#endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp new file mode 100644 index 0000000000..d1b079edb1 --- /dev/null +++ b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp @@ -0,0 +1,238 @@ +// 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/fee/fx_wordbreak/fx_wordbreak_impl.h" + +FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint) { + FX_DWORD dwProperty = + (FX_DWORD)gs_FX_WordBreak_CodePointProperties[wcCodePoint >> 1]; + 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()); +} +CFX_CharIter::~CFX_CharIter() {} +void CFX_CharIter::Release() { + delete this; +} +FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) { + if (bPrev) { + if (m_nIndex <= 0) { + return FALSE; + } + m_nIndex--; + } else { + if (m_nIndex + 1 >= m_wsText.GetLength()) { + return FALSE; + } + m_nIndex++; + } + return TRUE; +} +FX_WCHAR CFX_CharIter::GetChar() { + return m_wsText.GetAt(m_nIndex); +} +void CFX_CharIter::SetAt(int32_t nIndex) { + if (nIndex < 0 || nIndex >= m_wsText.GetLength()) { + return; + } + m_nIndex = nIndex; +} +int32_t CFX_CharIter::GetAt() const { + return m_nIndex; +} +FX_BOOL CFX_CharIter::IsEOF(FX_BOOL bTail) const { + return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0); +} +IFX_CharIter* CFX_CharIter::Clone() { + CFX_CharIter* pIter = new CFX_CharIter(m_wsText); + 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; +} +void CFX_WordBreak::Attach(IFX_CharIter* pIter) { + FXSYS_assert(pIter); + m_pCurIter = pIter; +} +void CFX_WordBreak::Attach(const CFX_WideString& wsText) { + m_pCurIter = 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)) { + return FALSE; + } + pIter->Next(bPrev); + if (!FindNextBreakPos(pIter, bPrev, TRUE)) { + pIter->Release(); + return FALSE; + } + if (bPrev) { + m_pCurIter->Release(); + m_pCurIter = m_pPreIter; + m_pCurIter->Next(TRUE); + m_pPreIter = pIter; + } else { + m_pPreIter->Release(); + m_pPreIter = m_pCurIter; + m_pPreIter->Next(); + m_pCurIter = pIter; + } + return TRUE; +} +void CFX_WordBreak::SetAt(int32_t nIndex) { + if (m_pPreIter) { + m_pPreIter->Release(); + m_pPreIter = NULL; + } + m_pCurIter->SetAt(nIndex); + FindNextBreakPos(m_pCurIter, TRUE, FALSE); + m_pPreIter = m_pCurIter; + m_pCurIter = m_pPreIter->Clone(); + FindNextBreakPos(m_pCurIter, FALSE, FALSE); +} +int32_t CFX_WordBreak::GetWordPos() const { + return m_pPreIter->GetAt(); +} +int32_t CFX_WordBreak::GetWordLength() const { + return m_pCurIter->GetAt() - m_pPreIter->GetAt() + 1; +} +void CFX_WordBreak::GetWord(CFX_WideString& wsWord) const { + int32_t nWordLength = GetWordLength(); + if (nWordLength <= 0) { + return; + } + FX_WCHAR* lpBuf = wsWord.GetBuffer(nWordLength); + 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) { + break; + } + } + pTempIter->Release(); + wsWord.ReleaseBuffer(nWordLength); +} +FX_BOOL CFX_WordBreak::IsEOF(FX_BOOL bTail) const { + return m_pCurIter->IsEOF(bTail); +} +FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter, + FX_BOOL bPrev, + FX_BOOL bFromNext) { + FX_WordBreakProp ePreType = FX_WordBreakProp_None; + FX_WordBreakProp eCurType = FX_WordBreakProp_None; + FX_WordBreakProp eNextType = FX_WordBreakProp_None; + if (pIter->IsEOF(!bPrev)) { + return TRUE; + } + if (!(bFromNext || pIter->IsEOF(bPrev))) { + pIter->Next(!bPrev); + FX_WCHAR wcTemp = pIter->GetChar(); + ePreType = FX_GetWordBreakProperty(wcTemp); + pIter->Next(bPrev); + } + FX_WCHAR wcTemp = pIter->GetChar(); + eCurType = FX_GetWordBreakProperty(wcTemp); + FX_BOOL bFirst = TRUE; + do { + pIter->Next(bPrev); + FX_WCHAR wcTemp = pIter->GetChar(); + eNextType = FX_GetWordBreakProperty(wcTemp); + FX_WORD wBreak = + gs_FX_WordBreak_Table[eCurType] & ((FX_WORD)(1 << eNextType)); + if (wBreak) { + if (pIter->IsEOF(!bPrev)) { + pIter->Next(!bPrev); + return TRUE; + } + if (bFirst) { + int32_t nFlags = 0; + if (eCurType == FX_WordBreakProp_MidLetter) { + if (eNextType == FX_WordBreakProp_ALetter) { + nFlags = 1; + } + } else if (eCurType == FX_WordBreakProp_MidNum) { + if (eNextType == FX_WordBreakProp_Numberic) { + nFlags = 2; + } + } else if (eCurType == FX_WordBreakProp_MidNumLet) { + if (eNextType == FX_WordBreakProp_ALetter) { + nFlags = 1; + } else if (eNextType == FX_WordBreakProp_Numberic) { + nFlags = 2; + } + } + if (nFlags > 0) { + FXSYS_assert(nFlags <= 2); + if (!((nFlags == 1 && ePreType == FX_WordBreakProp_ALetter) || + (nFlags == 2 && ePreType == FX_WordBreakProp_Numberic))) { + pIter->Next(!bPrev); + return TRUE; + } + pIter->Next(bPrev); + wBreak = FALSE; + } + bFirst = FALSE; + } + if (wBreak) { + int32_t nFlags = 0; + if (eNextType == FX_WordBreakProp_MidLetter) { + if (eCurType == FX_WordBreakProp_ALetter) { + nFlags = 1; + } + } else if (eNextType == FX_WordBreakProp_MidNum) { + if (eCurType == FX_WordBreakProp_Numberic) { + nFlags = 2; + } + } else if (eNextType == FX_WordBreakProp_MidNumLet) { + if (eCurType == FX_WordBreakProp_ALetter) { + nFlags = 1; + } else if (eCurType == FX_WordBreakProp_Numberic) { + nFlags = 2; + } + } + if (nFlags <= 0) { + pIter->Next(!bPrev); + return TRUE; + } + FXSYS_assert(nFlags <= 2); + pIter->Next(bPrev); + wcTemp = pIter->GetChar(); + eNextType = (FX_WordBreakProp)FX_GetWordBreakProperty(wcTemp); + if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) || + (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) { + pIter->Next(!bPrev); + pIter->Next(!bPrev); + return TRUE; + } + } + } + ePreType = eCurType; + eCurType = eNextType; + bFirst = FALSE; + } while (!pIter->IsEOF(!bPrev)); + return TRUE; +} +IFX_WordBreak* FX_WordBreak_Create() { + return new CFX_WordBreak; +} diff --git a/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h new file mode 100644 index 0000000000..95f5a43eb0 --- /dev/null +++ b/xfa/fee/fx_wordbreak/fx_wordbreak_impl.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_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_ +#define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_ + +#include <cstdint> + +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fee/fx_wordbreak/fx_wordbreak.h" +#include "xfa/fee/fx_wordbreak/fx_wordbreak_impl.h" +#include "xfa/fee/ifde_txtedtengine.h" + +extern const FX_WORD gs_FX_WordBreak_Table[16]; +extern const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1]; +enum FX_WordBreakProp { + FX_WordBreakProp_None = 0, + FX_WordBreakProp_CR, + FX_WordBreakProp_LF, + FX_WordBreakProp_NewLine, + FX_WordBreakProp_Extend, + FX_WordBreakProp_Format, + FX_WordBreakProp_KataKana, + FX_WordBreakProp_ALetter, + FX_WordBreakProp_MidLetter, + FX_WordBreakProp_MidNum, + FX_WordBreakProp_MidNumLet, + FX_WordBreakProp_Numberic, + 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/xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp b/xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp new file mode 100644 index 0000000000..ffb4889954 --- /dev/null +++ b/xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp @@ -0,0 +1,2748 @@ +// 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/fee/fx_wordbreak/fx_wordbreak_impl.h" + +const FX_WORD gs_FX_WordBreak_Table[16] = { + 0xFFFF, 0xFFF9, 0xFFFB, 0xFFFB, 0xFFFB, 0xFFFB, 0xEFBB, 0xE77B, + 0xFFFB, 0xFFFB, 0xFFFB, 0xE77B, 0xE73B, 0xFFFB, 0xFFFB, 0xFFFB, +}; + +const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1] = + // NOLINTNEXTLINE + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x90, 0xA0, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x89, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x0C, + 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0x05, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x70, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x70, 0x00, + 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x77, 0x77, 0x70, 0x77, + 0x00, 0x77, 0x77, 0x90, 0x00, 0x00, 0x00, 0x78, 0x77, 0x70, 0x70, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x04, 0x44, 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, + 0x07, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x09, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x04, 0x04, 0x40, 0x44, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x70, 0x00, 0x00, 0x77, 0x77, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x40, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x0B, 0x90, 0x77, 0x47, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x44, + 0x44, 0x44, 0x45, 0x44, 0x44, 0x44, 0x47, 0x74, 0x40, 0x44, 0x44, 0x77, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x70, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x74, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x07, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x77, 0x00, + 0x90, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x44, 0x44, 0x74, 0x44, 0x44, 0x44, 0x44, 0x74, 0x44, + 0x74, 0x44, 0x44, 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, 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, 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, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x47, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x40, 0x74, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x07, 0x70, 0x00, 0x00, + 0x07, 0x77, 0x77, 0x77, 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x07, + 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x77, 0x77, 0x70, 0x70, 0x00, 0x77, 0x77, 0x00, 0x47, 0x44, + 0x44, 0x44, 0x40, 0x04, 0x40, 0x04, 0x44, 0x70, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x77, 0x07, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, + 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x07, 0x77, + 0x77, 0x70, 0x00, 0x07, 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x07, 0x70, + 0x77, 0x00, 0x40, 0x44, 0x44, 0x40, 0x00, 0x04, 0x40, 0x04, 0x44, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x07, 0x77, 0x70, 0x70, 0x00, 0x00, 0x00, 0xBB, + 0xBB, 0xBB, 0xBB, 0xBB, 0x44, 0x77, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x07, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, 0x44, 0x44, 0x44, 0x04, + 0x44, 0x04, 0x44, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x07, + 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, + 0x44, 0x44, 0x40, 0x04, 0x40, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x44, + 0x00, 0x00, 0x77, 0x07, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x07, 0x77, + 0x77, 0x70, 0x00, 0x77, 0x70, 0x77, 0x77, 0x00, 0x07, 0x70, 0x70, 0x77, + 0x00, 0x07, 0x70, 0x00, 0x77, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x00, 0x00, 0x44, 0x44, 0x40, 0x00, 0x44, 0x40, 0x44, 0x44, 0x00, + 0x70, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, + 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x77, 0x70, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x07, 0x77, 0x77, 0x00, 0x07, 0x44, 0x44, 0x44, 0x40, 0x44, + 0x40, 0x44, 0x44, 0x00, 0x00, 0x00, 0x04, 0x40, 0x77, 0x00, 0x00, 0x00, + 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x77, + 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, + 0x44, 0x44, 0x40, 0x44, 0x40, 0x44, 0x44, 0x00, 0x00, 0x00, 0x04, 0x40, + 0x00, 0x00, 0x00, 0x70, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, 0x77, + 0x77, 0x77, 0x70, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x00, 0x07, 0x44, 0x44, 0x44, 0x40, 0x44, 0x40, 0x44, 0x44, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x77, 0x44, 0x00, 0xBB, + 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, + 0x00, 0x44, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, + 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x07, 0x77, 0x77, 0x77, 0x77, 0x07, 0x00, 0x77, 0x77, 0x77, 0x70, + 0x00, 0x40, 0x00, 0x04, 0x44, 0x44, 0x40, 0x40, 0x44, 0x44, 0x44, 0x44, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 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, 0x04, 0x00, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x40, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x44, 0x44, + 0x44, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x44, 0x77, 0x77, 0x77, 0x77, + 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x04, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x44, 0x77, 0x77, 0x00, 0x00, + 0x44, 0x44, 0x44, 0x44, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x40, 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, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x40, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x44, 0x40, 0x44, 0x40, 0x04, + 0x44, 0x44, 0x44, 0x00, 0x04, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x04, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x70, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x70, 0x70, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x70, + 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x77, 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, + 0x77, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, + 0x70, 0x44, 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, 0x00, 0x00, 0x55, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x74, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, + 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xB0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 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, 0x04, 0x44, + 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x04, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x44, 0x47, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x47, 0x77, + 0x77, 0x77, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x44, 0x47, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, + 0x44, 0x40, 0x00, 0x77, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x07, 0x77, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x47, 0x77, 0x74, 0x77, 0x77, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x07, 0x07, 0x07, 0x07, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x70, 0x00, 0x77, 0x70, 0x77, + 0x77, 0x77, 0x70, 0x00, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x77, 0x70, 0x77, + 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x55, + 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x08, + 0x33, 0x55, 0x55, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, + 0xC0, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x50, 0x00, 0x00, 0x55, 0x55, 0x55, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x70, 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, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0x00, 0x07, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x00, + 0x07, 0x77, 0x77, 0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x77, 0x77, 0x07, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x00, 0x00, 0x07, 0x77, + 0x77, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, + 0x00, 0x07, 0x77, 0x74, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x70, + 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, + 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, + 0x77, 0x77, 0x77, 0x70, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, + 0x06, 0x66, 0x66, 0x00, 0x00, 0x07, 0x70, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x46, 0x60, 0x00, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0x66, 0x66, 0x00, 0x00, 0x07, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x07, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 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, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 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, 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, 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, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x70, 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, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x74, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x07, 0x70, 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, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, + 0x77, 0x47, 0x77, 0x47, 0x77, 0x74, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x77, 0x77, 0x77, 0x00, 0x07, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, + 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x74, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 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, 0x40, 0x44, 0x40, 0x04, + 0x40, 0x00, 0x00, 0x44, 0x04, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x40, 0x44, 0x00, + 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x07, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x77, 0x77, 0x00, 0x00, 0x07, 0x47, 0x77, 0x77, 0x77, 0x77, + 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x70, 0x70, + 0x77, 0x07, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x90, 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xCC, 0x90, 0xA0, 0x98, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x05, + 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x89, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x0C, 0x07, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x44, 0x77, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, + 0x00, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, + 0x00, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x00, 0x00, +}; diff --git a/xfa/fee/ifde_txtedtbuf.h b/xfa/fee/ifde_txtedtbuf.h new file mode 100644 index 0000000000..0459af4ff8 --- /dev/null +++ b/xfa/fee/ifde_txtedtbuf.h @@ -0,0 +1,39 @@ +// 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/include/fxcrt/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/xfa/fee/ifde_txtedtengine.h b/xfa/fee/ifde_txtedtengine.h new file mode 100644 index 0000000000..47700b04c7 --- /dev/null +++ b/xfa/fee/ifde_txtedtengine.h @@ -0,0 +1,258 @@ +// 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_TXTEDTENGINE_H_ +#define XFA_FEE_IFDE_TXTEDTENGINE_H_ + +#include "core/include/fxge/fx_dib.h" +#include "xfa/fgas/font/fgas_font.h" + +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) +#define FDE_TEXTEDITMODE_LimitArea_Vert (1L << 3) +#define FDE_TEXTEDITMODE_LimitArea_Horz (1L << 4) +#define FDE_TEXTEDITMODE_NoRedoUndo (1L << 5) +#define FDE_TEXTEDITMODE_FIELD_TAB (1L << 6) +#define FDE_TEXTEDITMODE_FIELD_AUTO (1L << 7) +#define FDE_TEXTEDITMODE_Validate (1L << 8) +#define FDE_TEXTEDITMODE_Password (1L << 9) + +#define FDE_TEXTEDITALIGN_Left (0L << 0) +#define FDE_TEXTEDITALIGN_Center (1L << 0) +#define FDE_TEXTEDITALIGN_Right (2L << 0) +#define FDE_TEXTEDITALIGN_Normal (1L << 3) +#define FDE_TEXTEDITALIGN_Justified (1L << 4) +#define FDE_TEXTEDITALIGN_Distributed (1L << 5) + +#define FDE_TEXTEDITLAYOUT_DocVertical (1L << 0) +#define FDE_TEXTEDITLAYOUT_CharVertial (1L << 1) +#define FDE_TEXTEDITLAYOUT_LineReserve (1L << 2) +#define FDE_TEXTEDITLAYOUT_RTL (1L << 3) +#define FDE_TEXTEDITLAYOUT_CombText (1L << 4) +#define FDE_TEXTEDITLAYOUT_ExpandTab (1L << 5) +#define FDE_TEXTEDITLAYOUT_ArabicContext (1L << 6) +#define FDE_TEXTEDITLAYOUT_ArabicShapes (1L << 7) +#define FDE_TEXTEDITLAYOUT_LastLineHeight (1L << 8) + +enum FDE_TXTEDTMOVECARET { + MC_MoveNone = 0, + MC_Left, + MC_Right, + MC_Up, + MC_Down, + MC_WordBackward, + MC_WordForward, + MC_LineStart, + MC_LineEnd, + MC_ParagStart, + MC_ParagEnd, + MC_PageUp, + MC_PageDown, + MC_Home, + MC_End, +}; +enum FDE_TXTEDT_MODIFY_RET { + FDE_TXTEDT_MODIFY_RET_F_Tab = -6, + FDE_TXTEDT_MODIFY_RET_F_Locked = -5, + FDE_TXTEDT_MODIFY_RET_F_Invalidate = -4, + FDE_TXTEDT_MODIFY_RET_F_Boundary = -3, + FDE_TXTEDT_MODIFY_RET_F_Full = -2, + FDE_TXTEDT_MODIFY_RET_F_Normal = -1, + FDE_TXTEDT_MODIFY_RET_S_Normal = 0, + FDE_TXTEDT_MODIFY_RET_S_Full = 1, + FDE_TXTEDT_MODIFY_RET_S_Part = 2, + 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() + : fPlateWidth(0), + fPlateHeight(0), + nLineCount(0), + dwLayoutStyles(0), + dwAlignment(0), + dwMode(0), + pFont(NULL), + fFontSize(10.0f), + dwFontColor(0xff000000), + fLineSpace(10.0f), + fTabWidth(36), + bTabEquidistant(FALSE), + wDefChar(0xFEFF), + wLineBreakChar('\n'), + nCharRotation(0), + nLineEnd(0), + nHorzScale(100), + fCharSpace(0), + pEventSink(NULL) {} + FX_FLOAT fPlateWidth; + FX_FLOAT fPlateHeight; + int32_t nLineCount; + FX_DWORD dwLayoutStyles; + FX_DWORD dwAlignment; + FX_DWORD dwMode; + IFX_Font* pFont; + FX_FLOAT fFontSize; + FX_ARGB dwFontColor; + FX_FLOAT fLineSpace; + FX_FLOAT fTabWidth; + FX_BOOL bTabEquidistant; + FX_WCHAR wDefChar; + FX_WCHAR wLineBreakChar; + int32_t nCharRotation; + int32_t nLineEnd; + int32_t nHorzScale; + FX_FLOAT fCharSpace; + IFDE_TxtEdtEventSink* 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 { + 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; + virtual int32_t GetAt() const = 0; + 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/xfa/fee/ifde_txtedtpage.h b/xfa/fee/ifde_txtedtpage.h new file mode 100644 index 0000000000..ec5912d0f1 --- /dev/null +++ b/xfa/fee/ifde_txtedtpage.h @@ -0,0 +1,42 @@ +// 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_TXTEDTPAGE_H_ +#define XFA_FEE_IFDE_TXTEDTPAGE_H_ + +#include "core/include/fxge/fx_ge.h" +#include "xfa/fde/fde_visualset.h" +#include "xfa/fgas/layout/fgas_textbreak.h" + +class IFDE_TxtEdtEngine; +class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess { + public: + static IFDE_TxtEdtPage* Create(IFDE_TxtEdtEngine* pEngine, int32_t nIndex); + + virtual void Release() = 0; + + virtual IFDE_TxtEdtEngine* GetEngine() const = 0; + virtual int32_t GetCharRect(int32_t nIndex, + CFX_RectF& rect, + FX_BOOL bBBox = FALSE) const = 0; + virtual int32_t GetCharIndex(const CFX_PointF& fPoint, FX_BOOL& bBefore) = 0; + virtual void CalcRangeRectArray(int32_t nStart, + int32_t nCount, + CFX_RectFArray& RectFArr) const = 0; + virtual int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) = 0; + virtual int32_t GetCharStart() const = 0; + virtual int32_t GetCharCount() const = 0; + + virtual int32_t GetDisplayPos(const CFX_RectF& rtClip, + FXTEXT_CHARPOS*& pCharPos, + CFX_RectF* pBBox) const = 0; + virtual FX_BOOL IsLoaded(const CFX_RectF* pClipBox) = 0; + virtual int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) = 0; + virtual void UnloadPage(const CFX_RectF* pClipBox) = 0; + virtual const CFX_RectF& GetContentsBox() = 0; +}; + +#endif // XFA_FEE_IFDE_TXTEDTPAGE_H_ diff --git a/xfa/fgas/crt/fgas_algorithm.cpp b/xfa/fgas/crt/fgas_algorithm.cpp new file mode 100644 index 0000000000..b351292519 --- /dev/null +++ b/xfa/fgas/crt/fgas_algorithm.cpp @@ -0,0 +1,306 @@ +// 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/fgas/crt/fgas_algorithm.h" + +#include "core/include/fxcrt/fx_basic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static const FX_CHAR g_FXBase64EncoderMap[64] = { + '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', + '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', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', +}; + +struct FX_BASE64DATA { + FX_DWORD data1 : 2; + FX_DWORD data2 : 6; + FX_DWORD data3 : 4; + FX_DWORD data4 : 4; + FX_DWORD data5 : 6; + FX_DWORD data6 : 2; + FX_DWORD data7 : 8; +}; + +static void FX_Base64EncodePiece(const FX_BASE64DATA& src, + int32_t iBytes, + FX_CHAR dst[4]) { + dst[0] = g_FXBase64EncoderMap[src.data2]; + FX_DWORD b = src.data1 << 4; + if (iBytes > 1) { + b |= src.data4; + } + dst[1] = g_FXBase64EncoderMap[b]; + if (iBytes > 1) { + b = src.data3 << 2; + if (iBytes > 2) { + b |= src.data6; + } + dst[2] = g_FXBase64EncoderMap[b]; + if (iBytes > 2) { + dst[3] = g_FXBase64EncoderMap[src.data5]; + } else { + dst[3] = '='; + } + } else { + dst[2] = dst[3] = '='; + } +} +int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst) { + FXSYS_assert(pSrc != NULL); + if (iSrcLen < 1) { + return 0; + } + if (pDst == NULL) { + int32_t iDstLen = iSrcLen / 3 * 4; + if ((iSrcLen % 3) != 0) { + iDstLen += 4; + } + return iDstLen; + } + FX_BASE64DATA srcData; + int32_t iBytes = 3; + FX_CHAR* pDstEnd = pDst; + while (iSrcLen > 0) { + if (iSrcLen > 2) { + ((uint8_t*)&srcData)[0] = *pSrc++; + ((uint8_t*)&srcData)[1] = *pSrc++; + ((uint8_t*)&srcData)[2] = *pSrc++; + iSrcLen -= 3; + } else { + *((FX_DWORD*)&srcData) = 0; + ((uint8_t*)&srcData)[0] = *pSrc++; + if (iSrcLen > 1) { + ((uint8_t*)&srcData)[1] = *pSrc++; + } + iBytes = iSrcLen; + iSrcLen = 0; + } + FX_Base64EncodePiece(srcData, iBytes, pDstEnd); + pDstEnd += 4; + } + return pDstEnd - pDst; +} + +static const uint8_t g_FXBase64DecoderMap[256] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, + 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, + 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, +}; +static void FX_Base64DecodePiece(const FX_CHAR src[4], + int32_t iChars, + FX_BASE64DATA& dst, + int32_t& iBytes) { + FXSYS_assert(iChars > 0 && iChars < 5); + iBytes = 1; + dst.data2 = g_FXBase64DecoderMap[(uint8_t)src[0]]; + if (iChars > 1) { + uint8_t b = g_FXBase64DecoderMap[(uint8_t)src[1]]; + dst.data1 = b >> 4; + dst.data4 = b; + if (iChars > 2) { + iBytes = 2; + b = g_FXBase64DecoderMap[(uint8_t)src[2]]; + dst.data3 = b >> 2; + dst.data6 = b; + if (iChars > 3) { + iBytes = 3; + dst.data5 = g_FXBase64DecoderMap[(uint8_t)src[3]]; + } else { + dst.data5 = 0; + } + } else { + dst.data3 = 0; + } + } else { + dst.data1 = 0; + } +} +int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) { + FXSYS_assert(pSrc != NULL); + if (iSrcLen < 1) { + return 0; + } + while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { + iSrcLen--; + } + if (iSrcLen < 1) { + return 0; + } + if (pDst == NULL) { + int32_t iDstLen = iSrcLen / 4 * 3; + iSrcLen %= 4; + if (iSrcLen == 1) { + iDstLen += 1; + } else if (iSrcLen == 2) { + iDstLen += 1; + } else if (iSrcLen == 3) { + iDstLen += 2; + } + return iDstLen; + } + FX_CHAR srcData[4]; + FX_BASE64DATA dstData; + int32_t iChars = 4, iBytes; + uint8_t* pDstEnd = pDst; + while (iSrcLen > 0) { + if (iSrcLen > 3) { + *((FX_DWORD*)srcData) = *((FX_DWORD*)pSrc); + pSrc += 4; + iSrcLen -= 4; + } else { + *((FX_DWORD*)&dstData) = 0; + *((FX_DWORD*)srcData) = 0; + srcData[0] = *pSrc++; + if (iSrcLen > 1) { + srcData[1] = *pSrc++; + } + if (iSrcLen > 2) { + srcData[2] = *pSrc++; + } + iChars = iSrcLen; + iSrcLen = 0; + } + FX_Base64DecodePiece(srcData, iChars, dstData, iBytes); + *pDstEnd++ = ((uint8_t*)&dstData)[0]; + if (iBytes > 1) { + *pDstEnd++ = ((uint8_t*)&dstData)[1]; + } + if (iBytes > 2) { + *pDstEnd++ = ((uint8_t*)&dstData)[2]; + } + } + return pDstEnd - pDst; +} +int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) { + FXSYS_assert(pSrc != NULL); + if (iSrcLen < 1) { + return 0; + } + while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { + iSrcLen--; + } + if (iSrcLen < 1) { + return 0; + } + if (pDst == NULL) { + int32_t iDstLen = iSrcLen / 4 * 3; + iSrcLen %= 4; + if (iSrcLen == 1) { + iDstLen += 1; + } else if (iSrcLen == 2) { + iDstLen += 1; + } else if (iSrcLen == 3) { + iDstLen += 2; + } + return iDstLen; + } + FX_CHAR srcData[4]; + FX_BASE64DATA dstData; + int32_t iChars = 4, iBytes; + uint8_t* pDstEnd = pDst; + while (iSrcLen > 0) { + if (iSrcLen > 3) { + srcData[0] = (FX_CHAR)*pSrc++; + srcData[1] = (FX_CHAR)*pSrc++; + srcData[2] = (FX_CHAR)*pSrc++; + srcData[3] = (FX_CHAR)*pSrc++; + iSrcLen -= 4; + } else { + *((FX_DWORD*)&dstData) = 0; + *((FX_DWORD*)srcData) = 0; + srcData[0] = (FX_CHAR)*pSrc++; + if (iSrcLen > 1) { + srcData[1] = (FX_CHAR)*pSrc++; + } + if (iSrcLen > 2) { + srcData[2] = (FX_CHAR)*pSrc++; + } + iChars = iSrcLen; + iSrcLen = 0; + } + FX_Base64DecodePiece(srcData, iChars, dstData, iBytes); + *pDstEnd++ = ((uint8_t*)&dstData)[0]; + if (iBytes > 1) { + *pDstEnd++ = ((uint8_t*)&dstData)[1]; + } + if (iBytes > 2) { + *pDstEnd++ = ((uint8_t*)&dstData)[2]; + } + } + return pDstEnd - pDst; +} + +static const uint8_t g_FXHex2DecMap[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, + 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, + 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow) { + return (g_FXHex2DecMap[hexHigh] << 4) + g_FXHex2DecMap[hexLow]; +} +int32_t FX_SeparateStringW(const FX_WCHAR* pStr, + int32_t iStrLen, + FX_WCHAR delimiter, + CFX_WideStringArray& pieces) { + if (pStr == NULL) { + return 0; + } + if (iStrLen < 0) { + iStrLen = FXSYS_wcslen(pStr); + } + const FX_WCHAR* pToken = pStr; + const FX_WCHAR* pEnd = pStr + iStrLen; + while (TRUE) { + if (pStr >= pEnd || delimiter == *pStr) { + CFX_WideString sub(pToken, pStr - pToken); + pieces.Add(sub); + pToken = pStr + 1; + if (pStr >= pEnd) { + break; + } + } + pStr++; + } + return pieces.GetSize(); +} +#ifdef __cplusplus +} +#endif diff --git a/xfa/fgas/crt/fgas_algorithm.h b/xfa/fgas/crt/fgas_algorithm.h new file mode 100644 index 0000000000..662b1b62a9 --- /dev/null +++ b/xfa/fgas/crt/fgas_algorithm.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_FGAS_CRT_FGAS_ALGORITHM_H_ +#define XFA_FGAS_CRT_FGAS_ALGORITHM_H_ + +#include <cstdint> + +#include "core/include/fxcrt/fx_basic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); +int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); +int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); +uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); +int32_t FX_SeparateStringW(const FX_WCHAR* pStr, + int32_t iStrLen, + FX_WCHAR delimiter, + CFX_WideStringArray& pieces); +#ifdef __cplusplus +}; +#endif + +template <class baseType> +class CFX_DSPATemplate { + public: + int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { + FXSYS_assert(pArray != NULL); + if (iCount < 1) { + return -1; + } + int32_t iStart = 0, iEnd = iCount - 1, iMid; + do { + iMid = (iStart + iEnd) / 2; + const baseType& v = pArray[iMid]; + if (find == v) { + return iMid; + } else if (find < v) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return -1; + } +}; + +#endif // XFA_FGAS_CRT_FGAS_ALGORITHM_H_ diff --git a/xfa/fgas/crt/fgas_codepage.cpp b/xfa/fgas/crt/fgas_codepage.cpp new file mode 100644 index 0000000000..e717873abe --- /dev/null +++ b/xfa/fgas/crt/fgas_codepage.cpp @@ -0,0 +1,343 @@ +// 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/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/crt/fgas_language.h" + +static const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { + {0, 1252}, {1, 0}, {2, 42}, {77, 10000}, {78, 10001}, + {79, 10003}, {80, 10008}, {81, 10002}, {83, 10005}, {84, 10004}, + {85, 10006}, {86, 10081}, {87, 10021}, {88, 10029}, {89, 10007}, + {128, 932}, {129, 949}, {130, 1361}, {134, 936}, {136, 950}, + {161, 1253}, {162, 1254}, {163, 1258}, {177, 1255}, {178, 1256}, + {186, 1257}, {204, 1251}, {222, 874}, {238, 1250}, {254, 437}, + {255, 850}, +}; +FX_WORD FX_GetCodePageFromCharset(uint8_t charset) { + int32_t iEnd = sizeof(g_FXCharset2CodePageTable) / sizeof(FX_CHARSET_MAP) - 1; + FXSYS_assert(iEnd >= 0); + int32_t iStart = 0, iMid; + do { + iMid = (iStart + iEnd) / 2; + const FX_CHARSET_MAP& cp = g_FXCharset2CodePageTable[iMid]; + if (charset == cp.charset) { + return cp.codepage; + } else if (charset < cp.charset) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return 0xFFFF; +} +static const FX_CHARSET_MAP g_FXCodepage2CharsetTable[] = { + {1, 0}, {2, 42}, {254, 437}, {255, 850}, {222, 874}, + {128, 932}, {134, 936}, {129, 949}, {136, 950}, {238, 1250}, + {204, 1251}, {0, 1252}, {161, 1253}, {162, 1254}, {177, 1255}, + {178, 1256}, {186, 1257}, {163, 1258}, {130, 1361}, {77, 10000}, + {78, 10001}, {79, 10003}, {80, 10008}, {81, 10002}, {83, 10005}, + {84, 10004}, {85, 10006}, {86, 10081}, {87, 10021}, {88, 10029}, + {89, 10007}, +}; +FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage) { + int32_t iEnd = sizeof(g_FXCodepage2CharsetTable) / sizeof(FX_CHARSET_MAP) - 1; + FXSYS_assert(iEnd >= 0); + int32_t iStart = 0, iMid; + do { + iMid = (iStart + iEnd) / 2; + const FX_CHARSET_MAP& cp = g_FXCodepage2CharsetTable[iMid]; + if (codepage == cp.codepage) { + return cp.charset; + } else if (codepage < cp.codepage) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return 0xFFFF; +} +const FX_LANG2CPMAP g_FXLang2CodepageTable[] = { + {FX_LANG_Arabic_SaudiArabia, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Bulgarian_Bulgaria, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Catalan_Catalan, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Chinese_Taiwan, FX_CODEPAGE_ChineseTraditional}, + {FX_LANG_CzechRepublic, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Danish_Denmark, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_German_Germany, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Greek_Greece, FX_CODEPAGE_MSWin_Greek}, + {FX_LANG_English_UnitedStates, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_TraditionalSort, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Finnish_Finland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_France, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Hebrew_Israel, FX_CODEPAGE_MSWin_Hebrew}, + {FX_LANG_Hungarian_Hungary, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Icelandic_Iceland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Italian_Italy, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Japanese_Japan, FX_CODEPAGE_ShiftJIS}, + {FX_LANG_Korean_Korea, FX_CODEPAGE_Korean}, + {FX_LANG_Dutch_Netherlands, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Norwegian_Bokmal, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Polish_Poland, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Portuguese_Brazil, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Romanian_Romania, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Russian_Russia, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Croatian_Croatia, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Slovak_Slovakia, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Albanian_Albania, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Swedish_Sweden, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Thai_Thailand, FX_CODEPAGE_MSDOS_Thai}, + {FX_LANG_Turkish_Turkey, FX_CODEPAGE_MSWin_Turkish}, + {FX_LANG_Urdu_Pakistan, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Indonesian_Indonesia, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Ukrainian_Ukraine, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Belarusian_Belarus, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Slovenian_Slovenia, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Estonian_Estonia, FX_CODEPAGE_MSWin_Baltic}, + {FX_LANG_Latvian_Latvia, FX_CODEPAGE_MSWin_Baltic}, + {FX_LANG_Lithuanian_Lithuania, FX_CODEPAGE_MSWin_Baltic}, + {FX_LANG_Persian, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Vietnamese_Vietnam, FX_CODEPAGE_MSWin_Vietnamese}, + {FX_LANG_Armenian_Armenia, FX_CODEPAGE_DefANSI}, + {FX_LANG_Azerbaijan_Latin, FX_CODEPAGE_MSWin_Turkish}, + {FX_LANG_Basque_Basque, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Macedonian, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Afrikaans_SouthAfrica, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Georgian_Georgia, FX_CODEPAGE_DefANSI}, + {FX_LANG_Faroese_FaroeIslands, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Hindi_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Malay_Malaysia, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Kazakh_Kazakhstan, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Kyrgyz_Kyrgyzstan, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Kiswahili_Kenya, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Uzbek_LatinUzbekistan, FX_CODEPAGE_MSWin_Turkish}, + {FX_LANG_Tatar_Russia, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Punjabi_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Gujarati_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Tamil_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Telugu_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Kannada_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Marathi_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_SanskritIndia, FX_CODEPAGE_DefANSI}, + {FX_LANG_Mongolian_CyrillicMongolia, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Galician_Galician, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Konkani_India, FX_CODEPAGE_DefANSI}, + {FX_LANG_Syriac_Syria, FX_CODEPAGE_DefANSI}, + {FX_LANG_Divehi_Maldives, FX_CODEPAGE_DefANSI}, + {FX_LANG_Arabic_Iraq, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Chinese_PRC, FX_CODEPAGE_ChineseSimplified}, + {FX_LANG_German_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_English_UnitedKingdom, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Mexico, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_Belgium, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Italian_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Dutch_Belgium, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Norwegian_Nynorsk, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Portuguese_Portugal, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_SerbianLatin_Serbia, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_LANG_Swedish_Finland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Azerbaijan_Cyrillic, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Malay_BruneiDarussalam, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Uzbek_CyrillicUzbekistan, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Arabic_Egypt, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Chinese_HongKong, FX_CODEPAGE_ChineseTraditional}, + {FX_LANG_German_Austria, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_English_Australia, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_InternationalSort, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_Canada, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_SerbianCyrillic_Serbia, FX_CODEPAGE_MSWin_Cyrillic}, + {FX_LANG_Arabic_Libya, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Chinese_Singapore, FX_CODEPAGE_ChineseSimplified}, + {FX_LANG_German_Luxembourg, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_English_Canada, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Guatemala, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Algeria, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Chinese_Macao, FX_CODEPAGE_ChineseTraditional}, + {FX_LANG_German_Liechtenstein, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_English_NewZealand, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_CostaRica, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_Luxembourg, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Morocco, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Ireland, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Panama, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_French_Monaco, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Tunisia, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_SouthAfrica, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_DominicanRepublic, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Oman, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Jamaica, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Venezuela, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Yemen, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Caribbean, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Colombia, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Syria, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Belize, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Peru, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Jordan, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_TrinidadTobago, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Argentina, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Lebanon, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Zimbabwe, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Ecuador, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Kuwait, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_English_Philippines, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Chile, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_UAE, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Spanish_Uruguay, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Bahrain, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Spanish_Paraguay, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Arabic_Qatar, FX_CODEPAGE_MSWin_Arabic}, + {FX_LANG_Spanish_Bolivia, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_ElSalvador, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Honduras, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_Nicaragua, FX_CODEPAGE_MSWin_WesternEuropean}, + {FX_LANG_Spanish_PuertoRico, FX_CODEPAGE_MSWin_WesternEuropean}, +}; +FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage) { + int32_t iEnd = sizeof(g_FXLang2CodepageTable) / sizeof(FX_LANG2CPMAP) - 1; + FXSYS_assert(iEnd >= 0); + int32_t iStart = 0, iMid; + do { + iMid = (iStart + iEnd) / 2; + const FX_LANG2CPMAP& cp = g_FXLang2CodepageTable[iMid]; + if (wLanguage == cp.wLanguage) { + return cp.wCodepage; + } else if (wLanguage < cp.wLanguage) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return 0xFFFF; +} +static const FX_STR2CPHASH g_FXCPHashTable[] = { + {0xd45, 0x6faf}, {0xd46, 0x6fb0}, {0xd47, 0x6fb1}, + {0xd48, 0x6fb2}, {0xd49, 0x4e6}, {0xd4d, 0x6fbd}, + {0xe9e, 0x4e4}, {0xc998, 0x1b5}, {0x18ef0, 0x3a8}, + {0x19f85, 0x5182}, {0x2e2335, 0x3b6}, {0x325153, 0x5182}, + {0x145bded, 0x2716}, {0x3c9a5f2, 0xc6f3}, {0x4c45f2d, 0x3a4}, + {0x4c45f4e, 0xc431}, {0x58caf51, 0x4e4}, {0x5a5cd7d, 0x3a8}, + {0x5a6c6a7, 0x4e4}, {0x5a6ca0b, 0x1b5}, {0x5a6cd68, 0x307}, + {0x5a6d8d3, 0x4e4}, {0x5a6d948, 0x354}, {0x5a6d96b, 0x362}, + {0x5a6d984, 0x366}, {0x5a90e35, 0x1b5}, {0x5e0cf00, 0x6fb5}, + {0x609c324, 0x551}, {0x617d97f, 0x5182}, {0x6a6fd91, 0xfde8}, + {0x6a6fd92, 0xfde9}, {0x6b102de, 0xcadc}, {0x6b10f48, 0x4e89}, + {0x1020805f, 0x4e4}, {0x10f0524c, 0x6fb5}, {0x11d558fe, 0x6fb0}, + {0x13898d19, 0xc42d}, {0x13898d3a, 0xc431}, {0x138a319e, 0x6fb1}, + {0x14679c09, 0x96c6}, {0x153f0a3d, 0x6fb2}, {0x1576eeb3, 0x4e20}, + {0x169a0ce6, 0xc6f9}, {0x16f3e2dc, 0x6fb3}, {0x18a8bb7a, 0x6fb4}, + {0x1a5d9419, 0x6fb5}, {0x1a847b48, 0x3a8}, {0x1b762419, 0xcec8}, + {0x1b9d7847, 0x475}, {0x1c126cb9, 0x6fb6}, {0x1ccdbc7d, 0x4f42}, + {0x1d330f5f, 0x2714}, {0x1dc74559, 0x4e6}, {0x1edd80da, 0x4e4}, + {0x23e4b03d, 0xfde8}, {0x24f28a16, 0x4f3d}, {0x286e7a32, 0x2715}, + {0x2c7c18ed, 0x3a8}, {0x2e2103b7, 0x2713}, {0x304bf479, 0x6fb4}, + {0x304bf47d, 0x6fb5}, {0x309bb869, 0xfde8}, {0x309bb86a, 0xfde9}, + {0x33664357, 0x3b6}, {0x352d6b49, 0x3a4}, {0x36f5661c, 0x1b5}, + {0x392e8f48, 0xcadc}, {0x3dc7c64c, 0x47c}, {0x3ed2e8e1, 0x4e4}, + {0x3f0c2fea, 0xcaed}, {0x3f0fef8f, 0xc6f2}, {0x3f5e130f, 0x5182}, + {0x47174d1f, 0x3a8}, {0x49686b7b, 0x6fb4}, {0x4b80b0d9, 0x3a4}, + {0x4dcda97a, 0x4e4}, {0x4dcda9b6, 0x4e4}, {0x4e881e6a, 0x5221}, + {0x4ffdf5a1, 0x36a}, {0x4ffdf5a5, 0x6fbd}, {0x5241ce16, 0x4e8b}, + {0x546bab9d, 0x4e4}, {0x54a3d64e, 0x6fb6}, {0x562179bd, 0x5161}, + {0x57c1df15, 0xc6f7}, {0x61ff6e62, 0x4f36}, {0x6359c7d8, 0x4f35}, + {0x63f3c335, 0x3a8}, {0x645a0f78, 0x477}, {0x691ac2fd, 0x275f}, + {0x6dc2eab0, 0x2d0}, {0x6dc2eeef, 0x35e}, {0x6dc2ef10, 0x36a}, + {0x7103138a, 0x47d}, {0x710dfbd0, 0xc6f5}, {0x7319f6cb, 0x36a}, + {0x745096ad, 0x3a8}, {0x74866229, 0x4e8c}, {0x77185fa5, 0x3a8}, + {0x7953f002, 0x6faf}, {0x7953f003, 0x6fb0}, {0x7953f004, 0x6fb1}, + {0x7953f005, 0x6fb2}, {0x7953f006, 0x6fb7}, {0x7953f00a, 0x6fbd}, + {0x7c577571, 0x2761}, {0x7e8c8ff1, 0x479}, {0x8031f47f, 0x3b5}, + {0x8031f481, 0x3b5}, {0x80c4a710, 0x5187}, {0x857c7e14, 0xfde8}, + {0x857c7e15, 0xfde9}, {0x86b59c90, 0x4e4}, {0x86b59c91, 0x6fb0}, + {0x86b59c92, 0x6fb1}, {0x86b59c93, 0x6fb2}, {0x86b59c94, 0x6fb3}, + {0x86b59c95, 0x6fb4}, {0x86b59c96, 0x6fb5}, {0x86b59c97, 0x4e7}, + {0x86b59c98, 0x4e6}, {0x8b4b24ec, 0x5190}, {0x8face362, 0x4e4}, + {0x8ff9ec2a, 0xfde9}, {0x919d3989, 0xcadc}, {0x9967e5ad, 0x4e22}, + {0x99f8b933, 0x6fbd}, {0x9bd2a380, 0x4fc7}, {0x9befad23, 0x4f38}, + {0x9c7ac649, 0x4f3c}, {0xa02468db, 0xdeae}, {0xa02468ec, 0xdeab}, + {0xa024692a, 0xdeaa}, {0xa0246997, 0xdeb2}, {0xa02469ff, 0xdeb0}, + {0xa0246a3d, 0xdeb1}, {0xa0246a8c, 0xdeaf}, {0xa0246a9a, 0xdeb3}, + {0xa0246b16, 0xdeac}, {0xa0246b1a, 0xdead}, {0xa071addc, 0x4b1}, + {0xa38b62dc, 0x474}, {0xa4c09fed, 0x3a8}, {0xa51e86e5, 0x4e7}, + {0xa67ab13e, 0x3a4}, {0xa7414244, 0x51a9}, {0xa9ddbead, 0xc6fb}, + {0xab24ffab, 0x4e8a}, {0xabef8ac4, 0x2710}, {0xabfa20ac, 0x6fb4}, + {0xad36895e, 0x4e2}, {0xad36895f, 0x4e3}, {0xaf310e90, 0x402}, + {0xaf31166f, 0x4e8}, {0xaf7277a5, 0x3b6}, {0xafc0d8b3, 0x96c6}, + {0xb0fd5dba, 0xcae0}, {0xb0fd5e95, 0xcadc}, {0xb1052893, 0x7149}, + {0xb1e98745, 0x36a}, {0xb277e91c, 0x5166}, {0xb2f7eac5, 0xcae0}, + {0xb2f7eba0, 0xcadc}, {0xb2f7ebc1, 0x3b5}, {0xb53fa77d, 0x3a8}, + {0xb6391138, 0x6fb5}, {0xb7358b7f, 0x6fb6}, {0xb8c42b40, 0x4e4}, + {0xb8c42ea4, 0x1b5}, {0xb8c439e7, 0x2e1}, {0xb8c43a61, 0x307}, + {0xb8c43d6c, 0x4e4}, {0xb8c43ddf, 0x352}, {0xb8c43de1, 0x354}, + {0xb8c43de6, 0x359}, {0xb8c43dff, 0x35d}, {0xb8c43e04, 0x362}, + {0xb8c43e07, 0x365}, {0xbcd29a7f, 0x3a8}, {0xbce34e78, 0x5182}, + {0xbce34e7b, 0x556a}, {0xbce81504, 0x3b5}, {0xbd8a4c95, 0x272d}, + {0xbdd89dad, 0x4e4}, {0xbdd89dae, 0x6fb0}, {0xbdd89daf, 0x6fb1}, + {0xbdd89db0, 0x6fb2}, {0xbdd89db1, 0x4e6}, {0xbdd89db5, 0x6fbd}, + {0xc1756e9f, 0x36b}, {0xc7482444, 0x47a}, {0xc9281c18, 0x4e4}, + {0xc9ef95df, 0x47b}, {0xccc9db0d, 0x4e4}, {0xccc9db0e, 0x6fb0}, + {0xcd73425f, 0x3b6}, {0xce38b40b, 0x4b0}, {0xce99e549, 0x25}, + {0xcf598740, 0x4e7}, {0xcf6d6f78, 0x4e4}, {0xcf758df6, 0x3a4}, + {0xd1266e51, 0x6fb5}, {0xd2910213, 0x2718}, {0xd29196bb, 0x2712}, + {0xd3eb2fc2, 0x476}, {0xd442dc2c, 0x4fc4}, {0xd9da4da4, 0x2711}, + {0xdbad2f42, 0x4e4}, {0xdbad2f43, 0x6fb0}, {0xdbad2f44, 0x6fb1}, + {0xdbad2f45, 0x6fb2}, {0xdbad2f46, 0x6fb3}, {0xdbad2f47, 0x6fb4}, + {0xdbad2f48, 0x6fb5}, {0xdbad2f49, 0x6fb6}, {0xdbad2f4a, 0x4e6}, + {0xdc438033, 0x4f31}, {0xdccb439b, 0x477}, {0xdccdc626, 0x3b5}, + {0xdd80a595, 0x4e4}, {0xdd80a596, 0x6fb0}, {0xdd80a59e, 0x6fb1}, + {0xdd80a5b4, 0x6fb2}, {0xdd80a5d9, 0x6fb5}, {0xdd80a5da, 0x6fb4}, + {0xdd80a5fa, 0x6fb6}, {0xdd80a615, 0x6fb3}, {0xdd80a619, 0x4e6}, + {0xdd80a61a, 0x3b5}, {0xdd80c0f8, 0x4e9f}, {0xdf7e46ff, 0x4fc8}, + {0xdf8680fd, 0x556a}, {0xdfb0bd6e, 0xc42d}, {0xdff05486, 0x2c4}, + {0xe3323399, 0x3a4}, {0xe60412dd, 0x3b5}, {0xeee47add, 0x4b0}, + {0xf021a186, 0x4e2}, {0xf021a187, 0x4e3}, {0xf021a188, 0x4e4}, + {0xf021a189, 0x4e5}, {0xf021a18a, 0x4e6}, {0xf021a18b, 0x4e7}, + {0xf021a18c, 0x4e8}, {0xf021a18d, 0x4e9}, {0xf021a18e, 0x4ea}, + {0xf0700456, 0x6fb3}, {0xf274f175, 0x3b5}, {0xf2a9730b, 0x3a8}, + {0xf3d463c2, 0x3a4}, {0xf52a70a3, 0xc42e}, {0xf5693147, 0x6fb3}, + {0xf637e157, 0x478}, {0xfc213f3a, 0x2717}, {0xff654d14, 0x3b5}, +}; +FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) { + FXSYS_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; + int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1; + FXSYS_assert(iEnd >= 0); + do { + iMid = (iStart + iEnd) / 2; + const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid]; + if (uHash == cp.uHash) { + return (FX_WORD)cp.uCodePage; + } else if (uHash < cp.uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return 0xFFFF; +} +FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength) { + if (iLength < 0) { + iLength = FXSYS_wcslen(pStr); + } + if (iLength == 0) { + return 0xFFFF; + } + CFX_ByteString csStr; + FX_CHAR* pBuf = csStr.GetBuffer(iLength + 1); + for (int32_t i = 0; i < iLength; ++i) { + *pBuf++ = (FX_CHAR)*pStr++; + } + csStr.ReleaseBuffer(iLength); + return FX_GetCodePageFromStringA(csStr, iLength); +} diff --git a/xfa/fgas/crt/fgas_codepage.h b/xfa/fgas/crt/fgas_codepage.h new file mode 100644 index 0000000000..479ad37417 --- /dev/null +++ b/xfa/fgas/crt/fgas_codepage.h @@ -0,0 +1,179 @@ +// 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_CRT_FGAS_CODEPAGE_H_ +#define XFA_FGAS_CRT_FGAS_CODEPAGE_H_ + +#include "core/include/fxcrt/fx_basic.h" + +#define FX_CODEPAGE_DefANSI 0 +#define FX_CODEPAGE_DefOEM 1 +#define FX_CODEPAGE_DefMAC 2 +#define FX_CODEPAGE_Thread 3 +#define FX_CODEPAGE_Symbol 42 +#define FX_CODEPAGE_MSDOS_US 437 +#define FX_CODEPAGE_Arabic_ASMO708 708 +#define FX_CODEPAGE_Arabic_ASMO449Plus 709 +#define FX_CODEPAGE_Arabic_Transparent 710 +#define FX_CODEPAGE_Arabic_NafithaEnhanced 711 +#define FX_CODEPAGE_Arabic_TransparentASMO 720 +#define FX_CODEPAGE_MSDOS_Greek1 737 +#define FX_CODEPAGE_MSDOS_Baltic 775 +#define FX_CODEPAGE_MSWin31_WesternEuropean 819 +#define FX_CODEPAGE_MSDOS_WesternEuropean 850 +#define FX_CODEPAGE_MSDOS_EasternEuropean 852 +#define FX_CODEPAGE_MSDOS_Latin3 853 +#define FX_CODEPAGE_MSDOS_Cyrillic 855 +#define FX_CODEPAGE_MSDOS_Turkish 857 +#define FX_CODEPAGE_MSDOS_Latin1Euro 858 +#define FX_CODEPAGE_MSDOS_Portuguese 860 +#define FX_CODEPAGE_MSDOS_Icelandic 861 +#define FX_CODEPAGE_MSDOS_Hebrew 862 +#define FX_CODEPAGE_MSDOS_FrenchCanadian 863 +#define FX_CODEPAGE_MSDOS_Arabic 864 +#define FX_CODEPAGE_MSDOS_Norwegian 865 +#define FX_CODEPAGE_MSDOS_Russian 866 +#define FX_CODEPAGE_MSDOS_Greek2 869 +#define FX_CODEPAGE_MSDOS_Thai 874 +#define FX_CODEPAGE_MSDOS_KamenickyCS 895 +#define FX_CODEPAGE_ShiftJIS 932 +#define FX_CODEPAGE_ChineseSimplified 936 +#define FX_CODEPAGE_Korean 949 +#define FX_CODEPAGE_ChineseTraditional 950 +#define FX_CODEPAGE_UTF16LE 1200 +#define FX_CODEPAGE_UTF16BE 1201 +#define FX_CODEPAGE_MSWin_EasternEuropean 1250 +#define FX_CODEPAGE_MSWin_Cyrillic 1251 +#define FX_CODEPAGE_MSWin_WesternEuropean 1252 +#define FX_CODEPAGE_MSWin_Greek 1253 +#define FX_CODEPAGE_MSWin_Turkish 1254 +#define FX_CODEPAGE_MSWin_Hebrew 1255 +#define FX_CODEPAGE_MSWin_Arabic 1256 +#define FX_CODEPAGE_MSWin_Baltic 1257 +#define FX_CODEPAGE_MSWin_Vietnamese 1258 +#define FX_CODEPAGE_Johab 1361 +#define FX_CODEPAGE_MAC_Roman 10000 +#define FX_CODEPAGE_MAC_ShiftJIS 10001 +#define FX_CODEPAGE_MAC_ChineseTraditional 10002 +#define FX_CODEPAGE_MAC_Korean 10003 +#define FX_CODEPAGE_MAC_Arabic 10004 +#define FX_CODEPAGE_MAC_Hebrew 10005 +#define FX_CODEPAGE_MAC_Greek 10006 +#define FX_CODEPAGE_MAC_Cyrillic 10007 +#define FX_CODEPAGE_MAC_ChineseSimplified 10008 +#define FX_CODEPAGE_MAC_Thai 10021 +#define FX_CODEPAGE_MAC_EasternEuropean 10029 +#define FX_CODEPAGE_MAC_Turkish 10081 +#define FX_CODEPAGE_UTF32LE 12000 +#define FX_CODEPAGE_UTF32BE 12001 +#define FX_CODEPAGE_ISO8859_1 28591 +#define FX_CODEPAGE_ISO8859_2 28592 +#define FX_CODEPAGE_ISO8859_3 28593 +#define FX_CODEPAGE_ISO8859_4 28594 +#define FX_CODEPAGE_ISO8859_5 28595 +#define FX_CODEPAGE_ISO8859_6 28596 +#define FX_CODEPAGE_ISO8859_7 28597 +#define FX_CODEPAGE_ISO8859_8 28598 +#define FX_CODEPAGE_ISO8859_9 28599 +#define FX_CODEPAGE_ISO8859_10 28600 +#define FX_CODEPAGE_ISO8859_11 28601 +#define FX_CODEPAGE_ISO8859_12 28602 +#define FX_CODEPAGE_ISO8859_13 28603 +#define FX_CODEPAGE_ISO8859_14 28604 +#define FX_CODEPAGE_ISO8859_15 28605 +#define FX_CODEPAGE_ISO8859_16 28606 +#define FX_CODEPAGE_ISCII_Devanagari 57002 +#define FX_CODEPAGE_ISCII_Bengali 57003 +#define FX_CODEPAGE_ISCII_Tamil 57004 +#define FX_CODEPAGE_ISCII_Telugu 57005 +#define FX_CODEPAGE_ISCII_Assamese 57006 +#define FX_CODEPAGE_ISCII_Oriya 57007 +#define FX_CODEPAGE_ISCII_Kannada 57008 +#define FX_CODEPAGE_ISCII_Malayalam 57009 +#define FX_CODEPAGE_ISCII_Gujarati 57010 +#define FX_CODEPAGE_ISCII_Punjabi 57011 +#define FX_CODEPAGE_UTF7 65000 +#define FX_CODEPAGE_UTF8 65001 +#define FX_CHARSET_ANSI 0 +#define FX_CHARSET_Default 1 +#define FX_CHARSET_Symbol 2 +#define FX_CHARSET_MAC_Roman 77 +#define FX_CHARSET_MAC_ShiftJIS 78 +#define FX_CHARSET_MAC_Korean 79 +#define FX_CHARSET_MAC_ChineseSimplified 80 +#define FX_CHARSET_MAC_ChineseTriditional 81 +#define FX_CHARSET_MAC_Johab 82 +#define FX_CHARSET_MAC_Hebrew 83 +#define FX_CHARSET_MAC_Arabic 84 +#define FX_CHARSET_MAC_Greek 85 +#define FX_CHARSET_MAC_Turkish 86 +#define FX_CHARSET_MAC_Thai 87 +#define FX_CHARSET_MAC_EasternEuropean 88 +#define FX_CHARSET_MAC_Cyrillic 89 +#define FX_CHARSET_ShiftJIS 128 +#define FX_CHARSET_Korean 129 +#define FX_CHARSET_Johab 130 +#define FX_CHARSET_ChineseSimplified 134 +#define FX_CHARSET_ChineseTriditional 136 +#define FX_CHARSET_MSWin_Greek 161 +#define FX_CHARSET_MSWin_Turkish 162 +#define FX_CHARSET_MSWin_Vietnamese 163 +#define FX_CHARSET_MSWin_Hebrew 177 +#define FX_CHARSET_MSWin_Arabic 178 +#define FX_CHARSET_ArabicTraditional 179 +#define FX_CHARSET_ArabicUser 180 +#define FX_CHARSET_HebrewUser 181 +#define FX_CHARSET_MSWin_Baltic 186 +#define FX_CHARSET_MSWin_Cyrillic 204 +#define FX_CHARSET_Thai 222 +#define FX_CHARSET_MSWin_EasterEuropean 238 +#define FX_CHARSET_US 254 +#define FX_CHARSET_OEM 255 + +FX_WORD FX_GetCodePageFromCharset(uint8_t charset); +FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage); +FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength); +FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength); +FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage); +void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength); +void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc, + FX_WCHAR* pDst, + int32_t iLength); +void FX_UTF16ToWChar(void* pBuffer, int32_t iLength); +void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16, + FX_WCHAR* pWChar, + int32_t iLength); +void FX_WCharToUTF16(void* pBuffer, int32_t iLength); +void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar, + FX_WORD* pUTF16, + int32_t iLength); +int32_t FX_DecodeString(FX_WORD wCodePage, + const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen, + FX_BOOL bErrBreak = FALSE); +int32_t FX_UTF8Decode(const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen); + +struct FX_STR2CPHASH { + uint32_t uHash; + uint32_t uCodePage; +}; + +struct FX_CHARSET_MAP { + uint16_t charset; + uint16_t codepage; +}; + +struct FX_LANG2CPMAP { + FX_WORD wLanguage; + FX_WORD wCodepage; +}; + +#endif // XFA_FGAS_CRT_FGAS_CODEPAGE_H_ diff --git a/xfa/fgas/crt/fgas_encode.cpp b/xfa/fgas/crt/fgas_encode.cpp new file mode 100644 index 0000000000..138b4b1f5e --- /dev/null +++ b/xfa/fgas/crt/fgas_encode.cpp @@ -0,0 +1,193 @@ +// 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/fgas/crt/fgas_codepage.h" + +void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) { + FXSYS_assert(pStr != NULL); + if (iLength < 0) { + iLength = FXSYS_wcslen(pStr); + } + FX_WORD wch; + if (sizeof(FX_WCHAR) > 2) { + while (iLength-- > 0) { + wch = (FX_WORD)*pStr; + wch = (wch >> 8) | (wch << 8); + wch &= 0x00FF; + *pStr++ = wch; + } + } else { + while (iLength-- > 0) { + wch = (FX_WORD)*pStr; + wch = (wch >> 8) | (wch << 8); + *pStr++ = wch; + } + } +} +void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc, + FX_WCHAR* pDst, + int32_t iLength) { + FXSYS_assert(pSrc != NULL && pDst != NULL); + if (iLength < 0) { + iLength = FXSYS_wcslen(pSrc); + } + FX_WORD wch; + if (sizeof(FX_WCHAR) > 2) { + while (iLength-- > 0) { + wch = (FX_WORD)*pSrc++; + wch = (wch >> 8) | (wch << 8); + wch &= 0x00FF; + *pDst++ = wch; + } + } else { + while (iLength-- > 0) { + wch = (FX_WORD)*pSrc++; + wch = (wch >> 8) | (wch << 8); + *pDst++ = wch; + } + } +} +void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) { + FXSYS_assert(pBuffer != NULL && iLength > 0); + if (sizeof(FX_WCHAR) == 2) { + return; + } + FX_WORD* pSrc = (FX_WORD*)pBuffer; + FX_WCHAR* pDst = (FX_WCHAR*)pBuffer; + while (--iLength >= 0) { + pDst[iLength] = (FX_WCHAR)pSrc[iLength]; + } +} +void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16, + FX_WCHAR* pWChar, + int32_t iLength) { + FXSYS_assert(pUTF16 != NULL && pWChar != NULL && iLength > 0); + if (sizeof(FX_WCHAR) == 2) { + FXSYS_memcpy(pWChar, pUTF16, iLength * sizeof(FX_WCHAR)); + } else { + while (--iLength >= 0) { + pWChar[iLength] = (FX_WCHAR)pUTF16[iLength]; + } + } +} +void FX_WCharToUTF16(void* pBuffer, int32_t iLength) { + FXSYS_assert(pBuffer != NULL && iLength > 0); + if (sizeof(FX_WCHAR) == 2) { + return; + } + const FX_WCHAR* pSrc = (const FX_WCHAR*)pBuffer; + FX_WORD* pDst = (FX_WORD*)pBuffer; + while (--iLength >= 0) { + *pDst++ = (FX_WORD)*pSrc++; + } +} +void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar, + FX_WORD* pUTF16, + int32_t iLength) { + FXSYS_assert(pWChar != NULL && pUTF16 != NULL && iLength > 0); + if (sizeof(FX_WCHAR) == 2) { + FXSYS_memcpy(pUTF16, pWChar, iLength * sizeof(FX_WCHAR)); + } else { + while (--iLength >= 0) { + *pUTF16++ = (FX_WORD)*pWChar++; + } + } +} +inline FX_DWORD FX_DWordFromBytes(const uint8_t* pStr) { + return FXBSTR_ID(pStr[3], pStr[2], pStr[1], pStr[0]); +} +inline FX_WORD FX_WordFromBytes(const uint8_t* pStr) { + return (pStr[1] << 8 | pStr[0]); +} +int32_t FX_DecodeString(FX_WORD wCodePage, + const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen, + FX_BOOL bErrBreak) { + if (wCodePage == FX_CODEPAGE_UTF8) { + return FX_UTF8Decode(pSrc, pSrcLen, pDst, pDstLen); + } + return -1; +} +int32_t FX_UTF8Decode(const FX_CHAR* pSrc, + int32_t* pSrcLen, + FX_WCHAR* pDst, + int32_t* pDstLen) { + if (pSrcLen == NULL || pDstLen == NULL) { + return -1; + } + int32_t iSrcLen = *pSrcLen; + if (iSrcLen < 1) { + *pSrcLen = *pDstLen = 0; + return 1; + } + int32_t iDstLen = *pDstLen; + FX_BOOL bValidDst = (pDst != NULL && iDstLen > 0); + FX_DWORD dwCode = 0; + int32_t iPending = 0; + int32_t iSrcNum = 0, iDstNum = 0; + int32_t k = 0; + int32_t iIndex = 0; + k = 1; + while (iIndex < iSrcLen) { + uint8_t byte = (uint8_t) * (pSrc + iIndex); + if (byte < 0x80) { + iPending = 0; + k = 1; + iDstNum++; + iSrcNum += k; + if (bValidDst) { + *pDst++ = byte; + if (iDstNum >= iDstLen) { + break; + } + } + } else if (byte < 0xc0) { + if (iPending < 1) { + break; + } + iPending--; + dwCode |= (byte & 0x3f) << (iPending * 6); + if (iPending == 0) { + iDstNum++; + iSrcNum += k; + if (bValidDst) { + *pDst++ = dwCode; + if (iDstNum >= iDstLen) { + break; + } + } + } + } else if (byte < 0xe0) { + iPending = 1; + k = 2; + dwCode = (byte & 0x1f) << 6; + } else if (byte < 0xf0) { + iPending = 2; + k = 3; + dwCode = (byte & 0x0f) << 12; + } else if (byte < 0xf8) { + iPending = 3; + k = 4; + dwCode = (byte & 0x07) << 18; + } else if (byte < 0xfc) { + iPending = 4; + k = 5; + dwCode = (byte & 0x03) << 24; + } else if (byte < 0xfe) { + iPending = 5; + k = 6; + dwCode = (byte & 0x01) << 30; + } else { + break; + } + iIndex++; + } + *pSrcLen = iSrcNum; + *pDstLen = iDstNum; + return 1; +} diff --git a/xfa/fgas/crt/fgas_language.h b/xfa/fgas/crt/fgas_language.h new file mode 100644 index 0000000000..21d68e68a1 --- /dev/null +++ b/xfa/fgas/crt/fgas_language.h @@ -0,0 +1,269 @@ +// 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_CRT_FGAS_LANGUAGE_H_ +#define XFA_FGAS_CRT_FGAS_LANGUAGE_H_ + +#define FX_LANG_Neutral 0x0000 +#define FX_LANG_Invariant 0x007f +#define FX_LANG_UserDefault 0x0400 +#define FX_LANG_SystemDefault 0x0800 +#define FX_LANG_Afrikaans_SouthAfrica 0x0436 +#define FX_LANG_Albanian_Albania 0x041c +#define FX_LANG_Alsatian_France 0x0484 +#define FX_LANG_Amharic_Ethiopia 0x045e +#define FX_LANG_Arabic_Algeria 0x1401 +#define FX_LANG_Arabic_Bahrain 0x3c01 +#define FX_LANG_Arabic_Egypt 0x0c01 +#define FX_LANG_Arabic_Iraq 0x0801 +#define FX_LANG_Arabic_Jordan 0x2c01 +#define FX_LANG_Arabic_Kuwait 0x3401 +#define FX_LANG_Arabic_Lebanon 0x3001 +#define FX_LANG_Arabic_Libya 0x1001 +#define FX_LANG_Arabic_Morocco 0x1801 +#define FX_LANG_Arabic_Oman 0x2001 +#define FX_LANG_Arabic_Qatar 0x4001 +#define FX_LANG_Arabic_SaudiArabia 0x0401 +#define FX_LANG_Arabic_Syria 0x2801 +#define FX_LANG_Arabic_Tunisia 0x1c01 +#define FX_LANG_Arabic_UAE 0x3801 +#define FX_LANG_Arabic_Yemen 0x2401 +#define FX_LANG_Armenian_Armenia 0x042b +#define FX_LANG_Assamese_India 0x044d +#define FX_LANG_Azerbaijan_Cyrillic 0x082c +#define FX_LANG_Azerbaijan_Latin 0x042c +#define FX_LANG_Bashkir_Russia 0x046d +#define FX_LANG_Basque_Basque 0x042d +#define FX_LANG_Belarusian_Belarus 0x0423 +#define FX_LANG_Bengali_Bangladesh 0x0845 +#define FX_LANG_Bengali_India 0x0445 +#define FX_LANG_Bosnia_Herzegovina 0x101a +#define FX_LANG_Bosnian_Cyrillic 0x201a +#define FX_LANG_Bosnian_Latin 0x141a +#define FX_LANG_Breton_France 0x047e +#define FX_LANG_Bulgarian_Bulgaria 0x0402 +#define FX_LANG_Burmese 0x0455 +#define FX_LANG_Catalan_Catalan 0x0403 +#define FX_LANG_Cherokee 0x045c +#define FX_LANG_Chinese_HongKong 0x0c04 +#define FX_LANG_Chinese_Macao 0x1404 +#define FX_LANG_Chinese_PRC 0x0804 +#define FX_LANG_Chinese_Singapore 0x1004 +#define FX_LANG_Chinese_Taiwan 0x0404 +#define FX_LANG_Corsican_France 0x0483 +#define FX_LANG_Croatian_Croatia 0x041a +#define FX_LANG_Croatian_Latin 0x101a +#define FX_LANG_CustomCurrent 0x0c00 +#define FX_LANG_CzechRepublic 0x0405 +#define FX_LANG_Danish_Denmark 0x0406 +#define FX_LANG_Dari_Afghanistan 0x048c +#define FX_LANG_Divehi_Maldives 0x0465 +#define FX_LANG_Dutch_Belgium 0x0813 +#define FX_LANG_Dutch_Netherlands 0x0413 +#define FX_LANG_Dutch_Preferred 0x0013 +#define FX_LANG_Dzongkha 0x0851 +#define FX_LANG_Edo 0x0466 +#define FX_LANG_English_Australia 0x0c09 +#define FX_LANG_English_Belize 0x2809 +#define FX_LANG_English_Canada 0x1009 +#define FX_LANG_English_Caribbean 0x2409 +#define FX_LANG_English_HongKong 0x3c09 +#define FX_LANG_English_India 0x4009 +#define FX_LANG_English_Indonesia 0x3809 +#define FX_LANG_English_Ireland 0x1809 +#define FX_LANG_English_Jamaica 0x2009 +#define FX_LANG_English_Malaysia 0x4409 +#define FX_LANG_English_NewZealand 0x1409 +#define FX_LANG_English_Philippines 0x3409 +#define FX_LANG_English_Singapore 0x4809 +#define FX_LANG_English_SouthAfrica 0x1c09 +#define FX_LANG_English_TrinidadTobago 0x2c09 +#define FX_LANG_English_UnitedKingdom 0x0809 +#define FX_LANG_English_UnitedStates 0x0409 +#define FX_LANG_English_Zimbabwe 0x3009 +#define FX_LANG_Estonian_Estonia 0x0425 +#define FX_LANG_Faroese_FaroeIslands 0x0438 +#define FX_LANG_Filipino_Philippines 0x0464 +#define FX_LANG_Finnish_Finland 0x040b +#define FX_LANG_French_Belgium 0x080c +#define FX_LANG_French_Cameroon 0x2c0c +#define FX_LANG_French_Canada 0x0c0c +#define FX_LANG_French_CongoDRC 0x240c +#define FX_LANG_French_CotedIvoire 0x300c +#define FX_LANG_French_France 0x040c +#define FX_LANG_French_Haiti 0x3c0c +#define FX_LANG_French_Luxembourg 0x140c +#define FX_LANG_French_Mali 0x340c +#define FX_LANG_French_Monaco 0x180c +#define FX_LANG_French_Morocco 0x380c +#define FX_LANG_French_Reunion 0x200c +#define FX_LANG_French_Senegal 0x280c +#define FX_LANG_French_Switzerland 0x100c +#define FX_LANG_French_WestIndies 0x1c0c +#define FX_LANG_Frisian_Netherlands 0x0462 +#define FX_LANG_Fulfulde 0x0467 +#define FX_LANG_Gaelic_Ireland 0x083c +#define FX_LANG_Gaelic_Scotland 0x043c +#define FX_LANG_Galician_Galician 0x0456 +#define FX_LANG_Georgian_Georgia 0x0437 +#define FX_LANG_German_Austria 0x0c07 +#define FX_LANG_German_Germany 0x0407 +#define FX_LANG_German_Liechtenstein 0x1407 +#define FX_LANG_German_Luxembourg 0x1007 +#define FX_LANG_German_Switzerland 0x0807 +#define FX_LANG_Greek_Greece 0x0408 +#define FX_LANG_Greenlandic_Greenland 0x046f +#define FX_LANG_Guarani 0x0474 +#define FX_LANG_Gujarati_India 0x0447 +#define FX_LANG_Hausa_LatinNigeria 0x0468 +#define FX_LANG_Hawaiian 0x0475 +#define FX_LANG_Hebrew_Israel 0x040d +#define FX_LANG_Hindi_India 0x0439 +#define FX_LANG_Hungarian_Hungary 0x040e +#define FX_LANG_Ibibio_Nigeria 0x0469 +#define FX_LANG_Icelandic_Iceland 0x040f +#define FX_LANG_Igbo_Nigeria 0x0470 +#define FX_LANG_Indonesian_Indonesia 0x0421 +#define FX_LANG_Inuktitut_LatinCanada 0x085d +#define FX_LANG_Inuktitut_SyllabicsCanada 0x045d +#define FX_LANG_IsiXhosa_SouthAfrica 0x0434 +#define FX_LANG_IsiZulu_SouthAfrica 0x0435 +#define FX_LANG_Italian_Italy 0x0410 +#define FX_LANG_Italian_Switzerland 0x0810 +#define FX_LANG_Japanese_Japan 0x0411 +#define FX_LANG_Kannada_India 0x044b +#define FX_LANG_Kanuri 0x0471 +#define FX_LANG_Kashmiri 0x0860 +#define FX_LANG_Kashmiri_Arabic 0x0460 +#define FX_LANG_Kazakh_Kazakhstan 0x043f +#define FX_LANG_Khmer_Cambodia 0x0453 +#define FX_LANG_Kiche_Guatemala 0x0486 +#define FX_LANG_Kinyarwanda_Rwanda 0x0487 +#define FX_LANG_Kiswahili_Kenya 0x0441 +#define FX_LANG_Konkani_India 0x0457 +#define FX_LANG_Korean_Korea 0x0412 +#define FX_LANG_Kyrgyz_Kyrgyzstan 0x0440 +#define FX_LANG_Lao_LaoPDR 0x0454 +#define FX_LANG_Latin 0x0476 +#define FX_LANG_Latvian_Latvia 0x0426 +#define FX_LANG_Lithuanian_Lithuania 0x0427 +#define FX_LANG_LithuanianTrad 0x0827 +#define FX_LANG_Lower Sorbian_Germany 0x082e +#define FX_LANG_Luxembourgish_Luxembourg 0x046e +#define FX_LANG_Macedonian 0x042f +#define FX_LANG_Malay_BruneiDarussalam 0x083e +#define FX_LANG_Malay_Malaysia 0x043e +#define FX_LANG_Malayalam_India 0x044c +#define FX_LANG_Maldivian 0x0465 +#define FX_LANG_Maltese_Malta 0x043a +#define FX_LANG_Manipuri 0x0458 +#define FX_LANG_Maori_NewZealand 0x0481 +#define FX_LANG_Mapudungun_Chile 0x047a +#define FX_LANG_Marathi_India 0x044e +#define FX_LANG_Mohawk_Mohawk 0x047c +#define FX_LANG_Mongolian_CyrillicMongolia 0x0450 +#define FX_LANG_Mongolian_TraditionalMongolian 0x0850 +#define FX_LANG_Nepali_India 0x0861 +#define FX_LANG_Nepali_Nepal 0x0461 +#define FX_LANG_Norwegian_Bokmal 0x0414 +#define FX_LANG_Norwegian_Nynorsk 0x0814 +#define FX_LANG_Occitan_France 0x0482 +#define FX_LANG_Oriya_India 0x0448 +#define FX_LANG_Oromo 0x0472 +#define FX_LANG_Papiamentu 0x0479 +#define FX_LANG_Pashto_Afghanistan 0x0463 +#define FX_LANG_Persian 0x0429 +#define FX_LANG_Polish_Poland 0x0415 +#define FX_LANG_Portuguese_Brazil 0x0416 +#define FX_LANG_Portuguese_Portugal 0x0816 +#define FX_LANG_Punjabi_India 0x0446 +#define FX_LANG_Punjabi_Pakistan 0x0846 +#define FX_LANG_Quechua_Bolivia 0x046b +#define FX_LANG_Quechua_Ecuador 0x086b +#define FX_LANG_Quechua_Peru 0x0c6b +#define FX_LANG_Romanian_Moldova 0x0818 +#define FX_LANG_Romanian_Romania 0x0418 +#define FX_LANG_Romansh_Switzerland 0x0417 +#define FX_LANG_Russian_Moldova 0x0819 +#define FX_LANG_Russian_Russia 0x0419 +#define FX_LANG_Sami_InariFinland 0x243b +#define FX_LANG_Sami_LuleNorway 0x103b +#define FX_LANG_Sami_LuleSweden 0x143b +#define FX_LANG_Sami_NorthernFinland 0x0c3b +#define FX_LANG_Sami_NorthernNorway 0x043b +#define FX_LANG_Sami_NorthernSweden 0x083b +#define FX_LANG_Sami_SkoltFinland 0x203b +#define FX_LANG_Sami_SouthernNorway 0x183b +#define FX_LANG_Sami_SouthernSweden 0x1c3b +#define FX_LANG_SanskritIndia 0x044f +#define FX_LANG_SerbianCyrillic_BosniaHerzegovina 0x1c1a +#define FX_LANG_SerbianCyrillic_Serbia 0x0c1a +#define FX_LANG_SerbianLatin_BosniaHerzegovina 0x181a +#define FX_LANG_SerbianLatin_Serbia 0x081a +#define FX_LANG_SesothoSaLeboa 0x046c +#define FX_LANG_Setswana_SouthAfrica 0x0432 +#define FX_LANG_Sindhi_Arabic 0x0859 +#define FX_LANG_Sindhi_Devanagari 0x0459 +#define FX_LANG_Sinhala_SriLanka 0x045b +#define FX_LANG_Slovak_Slovakia 0x041b +#define FX_LANG_Slovenian_Slovenia 0x0424 +#define FX_LANG_Somali 0x0477 +#define FX_LANG_Spanish_Argentina 0x2c0a +#define FX_LANG_Spanish_Bolivia 0x400a +#define FX_LANG_Spanish_Chile 0x340a +#define FX_LANG_Spanish_Colombia 0x240a +#define FX_LANG_Spanish_CostaRica 0x140a +#define FX_LANG_Spanish_DominicanRepublic 0x1c0a +#define FX_LANG_Spanish_Ecuador 0x300a +#define FX_LANG_Spanish_ElSalvador 0x440a +#define FX_LANG_Spanish_Guatemala 0x100a +#define FX_LANG_Spanish_Honduras 0x480a +#define FX_LANG_Spanish_Mexico 0x080a +#define FX_LANG_Spanish_Nicaragua 0x4c0a +#define FX_LANG_Spanish_Panama 0x180a +#define FX_LANG_Spanish_Paraguay 0x3c0a +#define FX_LANG_Spanish_Peru 0x280a +#define FX_LANG_Spanish_PuertoRico 0x500a +#define FX_LANG_Spanish_InternationalSort 0x0c0a +#define FX_LANG_Spanish_TraditionalSort 0x040a +#define FX_LANG_Spanish_UnitedStates 0x540a +#define FX_LANG_Spanish_Uruguay 0x380a +#define FX_LANG_Spanish_Venezuela 0x200a +#define FX_LANG_Sutu_SouthAfrica 0x0430 +#define FX_LANG_Swedish_Finland 0x081d +#define FX_LANG_Swedish_Sweden 0x041d +#define FX_LANG_Syriac_Syria 0x045a +#define FX_LANG_Tajik_CyrillicTajikistan 0x0428 +#define FX_LANG_Tamazight_ArabicMorocco 0x045f +#define FX_LANG_Tamazight_LatinAlgeria 0x085f +#define FX_LANG_Tamil_India 0x0449 +#define FX_LANG_Tatar_Russia 0x0444 +#define FX_LANG_Telugu_India 0x044a +#define FX_LANG_Thai_Thailand 0x041e +#define FX_LANG_TibetanPRC 0x0451 +#define FX_LANG_Tigrigna_Eritrea 0x0873 +#define FX_LANG_Tigrigna_Ethiopia 0x0473 +#define FX_LANG_Tsonga 0x0431 +#define FX_LANG_Turkish_Turkey 0x041f +#define FX_LANG_Turkmen_Turkmenistan 0x0442 +#define FX_LANG_UighurPRC 0x0480 +#define FX_LANG_Ukrainian_Ukraine 0x0422 +#define FX_LANG_UpperSorbian_Germany 0x042e +#define FX_LANG_Urdu_Pakistan 0x0420 +#define FX_LANG_Urdu_India 0x0820 +#define FX_LANG_Uzbek_CyrillicUzbekistan 0x0843 +#define FX_LANG_Uzbek_LatinUzbekistan 0x0443 +#define FX_LANG_Venda 0x0433 +#define FX_LANG_Vietnamese_Vietnam 0x042a +#define FX_LANG_Welsh_UnitedKingdom 0x0452 +#define FX_LANG_Wolof_Senegal 0x0488 +#define FX_LANG_Xhosa 0x0434 +#define FX_LANG_Yakut_Russia 0x0485 +#define FX_LANG_YiPRC 0x0478 +#define FX_LANG_Yiddish 0x043d +#define FX_LANG_Yoruba_Nigeria 0x046a + +#endif // XFA_FGAS_CRT_FGAS_LANGUAGE_H_ diff --git a/xfa/fgas/crt/fgas_memory.cpp b/xfa/fgas/crt/fgas_memory.cpp new file mode 100644 index 0000000000..7eda5b9ba6 --- /dev/null +++ b/xfa/fgas/crt/fgas_memory.cpp @@ -0,0 +1,446 @@ +// 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/fgas/crt/fgas_memory.h" + +#include <algorithm> + +namespace { + +class CFX_DefStore : public IFX_MEMAllocator, 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; } +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +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 { + 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; } + + protected: + size_t m_iAllocatedSize; + size_t m_iDefChunkSize; + FX_STATICSTORECHUNK* m_pChunk; + FX_STATICSTORECHUNK* m_pLastChunk; + FX_STATICSTORECHUNK* AllocChunk(size_t size); + 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; } + + FX_FIXEDSTORECHUNK* pNextChunk; + size_t iChunkSize; + size_t iFreeNum; +}; +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(pop) +#endif + +class CFX_FixedStore : public IFX_MEMAllocator, 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; } + + protected: + FX_FIXEDSTORECHUNK* AllocChunk(); + + size_t m_iBlockSize; + size_t m_iDefChunkSize; + 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) + +IFX_MEMAllocator* FX_CreateAllocator(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; + } +} +CFX_StaticStore::CFX_StaticStore(size_t iDefChunkSize) + : m_iAllocatedSize(0), + m_iDefChunkSize(iDefChunkSize), + m_pChunk(NULL), + m_pLastChunk(NULL) { + FXSYS_assert(m_iDefChunkSize != 0); +} +CFX_StaticStore::~CFX_StaticStore() { + FX_STATICSTORECHUNK* pChunk = m_pChunk; + while (pChunk) { + FX_STATICSTORECHUNK* pNext = pChunk->pNextChunk; + FX_Free(pChunk); + pChunk = pNext; + } +} +FX_STATICSTORECHUNK* CFX_StaticStore::AllocChunk(size_t size) { + FXSYS_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) { + m_pChunk = pChunk; + } else { + m_pLastChunk->pNextChunk = pChunk; + } + m_pLastChunk = pChunk; + return pChunk; +} +FX_STATICSTORECHUNK* CFX_StaticStore::FindChunk(size_t size) { + FXSYS_assert(size != 0); + if (m_pLastChunk == NULL || 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); + FX_STATICSTORECHUNK* pChunk = FindChunk(size); + FXSYS_assert(pChunk->iFreeSize >= size); + uint8_t* p = (uint8_t*)pChunk; + p += sizeof(FX_STATICSTORECHUNK) + pChunk->iChunkSize - pChunk->iFreeSize; + pChunk->iFreeSize -= size; + m_iAllocatedSize += size; + return p; +} +size_t CFX_StaticStore::SetDefChunkSize(size_t size) { + FXSYS_assert(size != 0); + size_t v = m_iDefChunkSize; + m_iDefChunkSize = size; + return v; +} +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); +} +CFX_FixedStore::~CFX_FixedStore() { + FX_FIXEDSTORECHUNK* pChunk = m_pChunk; + while (pChunk) { + FX_FIXEDSTORECHUNK* pNext = pChunk->pNextChunk; + FX_Free(pChunk); + pChunk = pNext; + } +} +FX_FIXEDSTORECHUNK* CFX_FixedStore::AllocChunk() { + int32_t iTotalSize = sizeof(FX_FIXEDSTORECHUNK) + m_iDefChunkSize + + m_iBlockSize * m_iDefChunkSize; + FX_FIXEDSTORECHUNK* pChunk = + (FX_FIXEDSTORECHUNK*)FX_Alloc(uint8_t, iTotalSize); + if (pChunk == NULL) { + return NULL; + } + FXSYS_memset(pChunk->FirstFlag(), 0, m_iDefChunkSize); + pChunk->pNextChunk = m_pChunk; + pChunk->iChunkSize = m_iDefChunkSize; + pChunk->iFreeNum = m_iDefChunkSize; + m_pChunk = pChunk; + return pChunk; +} +void* CFX_FixedStore::Alloc(size_t size) { + if (size > m_iBlockSize) { + return NULL; + } + FX_FIXEDSTORECHUNK* pChunk = m_pChunk; + while (pChunk != NULL) { + if (pChunk->iFreeNum > 0) { + break; + } + pChunk = pChunk->pNextChunk; + } + if (pChunk == NULL) { + 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); + 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* pChunk = m_pChunk; + uint8_t* pStart = NULL; + uint8_t* pEnd; + while (pChunk != NULL) { + pStart = pChunk->FirstBlock(); + if (pBlock >= pStart) { + pEnd = pStart + m_iBlockSize * pChunk->iChunkSize; + if (pBlock < pEnd) { + break; + } + } + pPrior = pChunk, pChunk = pChunk->pNextChunk; + } + FXSYS_assert(pChunk != NULL); + size_t iPos = ((uint8_t*)pBlock - pStart) / m_iBlockSize; + FXSYS_assert(iPos < pChunk->iChunkSize); + uint8_t* pFlags = pChunk->FirstFlag(); + if (pFlags[iPos] == 0) { + return; + } + pFlags[iPos] = 0; + pChunk->iFreeNum++; + if (pChunk->iFreeNum == pChunk->iChunkSize) { + if (pPrior == NULL) { + m_pChunk = pChunk->pNextChunk; + } else { + pPrior->pNextChunk = pChunk->pNextChunk; + } + FX_Free(pChunk); + } +} +size_t CFX_FixedStore::SetDefChunkSize(size_t iChunkSize) { + FXSYS_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; +} diff --git a/xfa/fgas/crt/fgas_memory.h b/xfa/fgas/crt/fgas_memory.h new file mode 100644 index 0000000000..a9c5cc97e7 --- /dev/null +++ b/xfa/fgas/crt/fgas_memory.h @@ -0,0 +1,59 @@ +// 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_CRT_FGAS_MEMORY_H_ +#define XFA_FGAS_CRT_FGAS_MEMORY_H_ + +#include "core/include/fxcrt/fx_memory.h" +#include "core/include/fxcrt/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 { + public: + virtual ~IFX_MEMAllocator() {} + virtual void Release() = 0; + 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, + 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) { + return pAllocator->Alloc(size); + } + void operator delete(void* p, IFX_MEMAllocator* pAllocator) { + pAllocator->Free(p); + } + void* operator new(size_t size, void* place) { return place; } + void operator delete(void* p, void* place) {} +}; + +#define FXTARGET_NewWith(__allocator__) new (__allocator__) +#define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ + { \ + (pointer)->~__class__(); \ + (pointer)->operator delete((pointer), (__allocator__)); \ + } + +#endif // XFA_FGAS_CRT_FGAS_MEMORY_H_ diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp new file mode 100644 index 0000000000..6f082dd5f1 --- /dev/null +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -0,0 +1,1626 @@ +// 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/fgas/crt/fgas_stream.h" + +#include <algorithm> + +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/crt/fgas_system.h" + +namespace { + +class CFX_StreamImp { + public: + virtual void Release() { delete this; } + virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } + virtual int32_t GetLength() const = 0; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; + virtual int32_t GetPosition() = 0; + virtual FX_BOOL IsEOF() const = 0; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS) = 0; + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; + virtual void Flush() = 0; + virtual FX_BOOL SetLength(int32_t iLength) = 0; + + protected: + CFX_StreamImp(); + virtual ~CFX_StreamImp() {} + FX_DWORD m_dwAccess; +}; + +class CFX_FileStreamImp : public CFX_StreamImp { + public: + CFX_FileStreamImp(); + virtual ~CFX_FileStreamImp(); + FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + + protected: + FXSYS_FILE* m_hFile; + int32_t m_iLength; +}; + +class CFX_BufferStreamImp : public CFX_StreamImp { + public: + CFX_BufferStreamImp(); + virtual ~CFX_BufferStreamImp() {} + FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + uint8_t* m_pData; + int32_t m_iTotalSize; + int32_t m_iPosition; + int32_t m_iLength; +}; + +class CFX_FileReadStreamImp : public CFX_StreamImp { + public: + CFX_FileReadStreamImp(); + virtual ~CFX_FileReadStreamImp() {} + FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return 0; + } + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { + return 0; + } + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + IFX_FileRead* m_pFileRead; + int32_t m_iPosition; + int32_t m_iLength; +}; + +class CFX_BufferReadStreamImp : public CFX_StreamImp { + public: + CFX_BufferReadStreamImp(); + ~CFX_BufferReadStreamImp(); + FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead); + + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return 0; + } + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { + return 0; + } + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + private: + IFX_BufferRead* m_pBufferRead; + FX_BOOL m_bReleaseBufferRead; + int32_t m_iPosition; + int32_t m_iBufferSize; +}; + +class CFX_FileWriteStreamImp : public CFX_StreamImp { + public: + CFX_FileWriteStreamImp(); + virtual ~CFX_FileWriteStreamImp() {} + FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition() { return m_iPosition; } + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS) { + return 0; + } + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + protected: + IFX_FileWrite* m_pFileWrite; + int32_t m_iPosition; +}; + +enum FX_STREAMTYPE { + FX_SREAMTYPE_Unknown = 0, + FX_STREAMTYPE_File, + FX_STREAMTYPE_Buffer, + FX_STREAMTYPE_Stream, + FX_STREAMTYPE_BufferRead, +}; + +class CFX_Stream : public IFX_Stream { + public: + CFX_Stream(); + ~CFX_Stream(); + FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); + FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); + FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); + FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); + FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead); + virtual void Release(); + virtual IFX_Stream* Retain(); + virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + virtual int32_t GetBOM(uint8_t bom[4]) const; + virtual FX_WORD GetCodePage() const; + virtual FX_WORD SetCodePage(FX_WORD wCodePage); + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength); + + protected: + FX_STREAMTYPE m_eStreamType; + CFX_StreamImp* m_pStreamImp; + FX_DWORD m_dwAccess; + int32_t m_iTotalSize; + int32_t m_iPosition; + int32_t m_iStart; + int32_t m_iLength; + int32_t m_iRefCount; +}; + +class CFX_TextStream : public IFX_Stream { + public: + CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream); + ~CFX_TextStream(); + virtual void Release(); + virtual IFX_Stream* Retain(); + + virtual FX_DWORD GetAccessModes() const; + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); + virtual void Flush(); + virtual FX_BOOL SetLength(int32_t iLength); + + virtual int32_t GetBOM(uint8_t bom[4]) const; + virtual FX_WORD GetCodePage() const; + virtual FX_WORD SetCodePage(FX_WORD wCodePage); + + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength); + + protected: + FX_WORD m_wCodePage; + int32_t m_wBOMLength; + FX_DWORD m_dwBOM; + uint8_t* m_pBuf; + int32_t m_iBufSize; + FX_BOOL m_bDelStream; + IFX_Stream* m_pStreamImp; + int32_t m_iRefCount; + void InitStream(); +}; + +class CFGAS_FileRead : public IFX_FileRead { + public: + CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream); + virtual ~CFGAS_FileRead(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + + protected: + FX_BOOL m_bReleaseStream; + IFX_Stream* m_pStream; +}; + +class CFX_BufferAccImp : public IFX_FileRead { + public: + CFX_BufferAccImp(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize, + FX_BOOL bReleaseStream); + virtual ~CFX_BufferAccImp(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + + protected: + IFX_BufferRead* m_pBufferRead; + FX_BOOL m_bReleaseStream; + FX_FILESIZE m_iBufSize; +}; + +class CFGAS_FileWrite : public IFX_FileWrite { + public: + CFGAS_FileWrite(IFX_Stream* pStream, FX_BOOL bReleaseStream); + virtual ~CFGAS_FileWrite(); + virtual void Release() { delete this; } + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL Flush(); + virtual FX_BOOL WriteBlock(const void* pData, size_t size); + virtual FX_BOOL WriteBlock(const void* pData, + FX_FILESIZE offset, + size_t size); + + protected: + IFX_Stream* m_pStream; + FX_BOOL m_bReleaseStream; +}; + +} // namespace + +IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, + FX_DWORD dwAccess, + int32_t iFileSize, + FX_BOOL bReleaseBufferRead) { + CFX_Stream* pSR = new CFX_Stream; + if (!pSR->LoadBufferRead(pBufferRead, iFileSize, dwAccess, + bReleaseBufferRead)) { + pSR->Release(); + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} +IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, + FX_DWORD dwAccess) { + CFX_Stream* pSR = new CFX_Stream; + if (!pSR->LoadFileRead(pFileRead, dwAccess)) { + pSR->Release(); + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} +IFX_Stream* IFX_Stream::CreateStream(IFX_FileWrite* pFileWrite, + FX_DWORD dwAccess) { + CFX_Stream* pSR = new CFX_Stream; + if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) { + pSR->Release(); + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} +IFX_Stream* IFX_Stream::CreateStream(const FX_WCHAR* pszFileName, + FX_DWORD dwAccess) { + CFX_Stream* pSR = new CFX_Stream; + if (!pSR->LoadFile(pszFileName, dwAccess)) { + pSR->Release(); + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} +IFX_Stream* IFX_Stream::CreateStream(uint8_t* pData, + int32_t length, + FX_DWORD dwAccess) { + CFX_Stream* pSR = new CFX_Stream; + if (!pSR->LoadBuffer(pData, length, dwAccess)) { + pSR->Release(); + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} + +CFX_StreamImp::CFX_StreamImp() : m_dwAccess(0) {} +CFX_FileStreamImp::CFX_FileStreamImp() + : CFX_StreamImp(), m_hFile(NULL), m_iLength(0) {} +CFX_FileStreamImp::~CFX_FileStreamImp() { + if (m_hFile != NULL) { + FXSYS_fclose(m_hFile); + } +} +FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName, + FX_DWORD dwAccess) { + FXSYS_assert(m_hFile == NULL); + FXSYS_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; + if (dwAccess & FX_STREAMACCESS_Write) { + if (dwAccess & FX_STREAMACCESS_Append) { + wsMode = L"a+b"; + } else if (dwAccess & FX_STREAMACCESS_Truncate) { + wsMode = L"w+b"; + } else { + wsMode = L"r+b"; + } + } else { + wsMode = L"rb"; + } + m_hFile = FXSYS_wfopen(pszSrcFileName, wsMode); + + if (!m_hFile) { + if (dwAccess & FX_STREAMACCESS_Write) { + if (dwAccess & FX_STREAMACCESS_Create) + m_hFile = FXSYS_wfopen(pszSrcFileName, L"w+b"); + + if (!m_hFile) { + m_hFile = FXSYS_wfopen(pszSrcFileName, L"r+b"); + if (!m_hFile) + return FALSE; + + if (dwAccess & FX_STREAMACCESS_Truncate) + FX_fsetsize(m_hFile, 0); + } + } else { + return FALSE; + } + } +#else + CFX_ByteString wsMode; + if (dwAccess & FX_STREAMACCESS_Write) { + if (dwAccess & FX_STREAMACCESS_Append) { + wsMode = "a+b"; + } else if (dwAccess & FX_STREAMACCESS_Truncate) { + wsMode = "w+b"; + } else { + wsMode = "r+b"; + } + } else { + wsMode = "rb"; + } + CFX_ByteString szFileName = CFX_ByteString::FromUnicode(pszSrcFileName); + m_hFile = FXSYS_fopen(szFileName, wsMode); + if (m_hFile == NULL) { + if (dwAccess & FX_STREAMACCESS_Write) { + if (dwAccess & FX_STREAMACCESS_Create) { + m_hFile = FXSYS_fopen(szFileName, "w+b"); + } + if (m_hFile == NULL) { + m_hFile = FXSYS_fopen(szFileName, "r+b"); + if (m_hFile == NULL) { + return FALSE; + } + if (dwAccess & FX_STREAMACCESS_Truncate) { + FX_fsetsize(m_hFile, 0); + } + } + } else { + return FALSE; + } + } +#endif + m_dwAccess = dwAccess; + if ((dwAccess & (FX_STREAMACCESS_Write | FX_STREAMACCESS_Truncate)) == + (FX_STREAMACCESS_Write | FX_STREAMACCESS_Truncate)) { + m_iLength = 0; + } else { + m_iLength = FX_filelength(m_hFile); + } + return TRUE; +} +int32_t CFX_FileStreamImp::GetLength() const { + FXSYS_assert(m_hFile != NULL); + return m_iLength; +} +int32_t CFX_FileStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + FXSYS_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); + return FXSYS_ftell(m_hFile); +} +FX_BOOL CFX_FileStreamImp::IsEOF() const { + FXSYS_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); + 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); + if (m_iLength <= 0) { + return 0; + } + int32_t iPosition = FXSYS_ftell(m_hFile); + int32_t iLen = std::min((m_iLength - iPosition) / 2, iMaxLength); + if (iLen <= 0) { + return 0; + } + iLen = FXSYS_fread(pStr, 2, iLen, m_hFile); + int32_t iCount = 0; + while (*pStr != L'\0' && iCount < iLen) { + pStr++, iCount++; + } + iPosition += iCount * 2; + if (FXSYS_ftell(m_hFile) != iPosition) { + FXSYS_fseek(m_hFile, iPosition, 0); + } + bEOS = (iPosition >= m_iLength); + return iCount; +} +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); + int32_t iRet = FXSYS_fwrite(pBuffer, 1, iBufferSize, m_hFile); + if (iRet != 0) { + int32_t iPos = FXSYS_ftell(m_hFile); + if (iPos > m_iLength) { + m_iLength = iPos; + } + } + 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); + int32_t iRet = FXSYS_fwrite(pStr, 2, iLength, m_hFile); + if (iRet != 0) { + int32_t iPos = FXSYS_ftell(m_hFile); + if (iPos > m_iLength) { + m_iLength = iPos; + } + } + return iRet; +} +void CFX_FileStreamImp::Flush() { + FXSYS_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); + FX_BOOL bRet = FX_fsetsize(m_hFile, iLength); + m_iLength = FX_filelength(m_hFile); + return bRet; +} +CFX_FileReadStreamImp::CFX_FileReadStreamImp() + : m_pFileRead(NULL), m_iPosition(0), m_iLength(0) {} +FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_FileRead* pFileRead, + FX_DWORD dwAccess) { + FXSYS_assert(m_pFileRead == NULL && pFileRead != NULL); + if (dwAccess & FX_STREAMACCESS_Write) { + return FALSE; + } + m_pFileRead = pFileRead; + m_iLength = m_pFileRead->GetSize(); + return TRUE; +} +int32_t CFX_FileReadStreamImp::GetLength() const { + return m_iLength; +} +int32_t CFX_FileReadStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + switch (eSeek) { + case FX_STREAMSEEK_Begin: + m_iPosition = iOffset; + break; + case FX_STREAMSEEK_Current: + m_iPosition += iOffset; + break; + case FX_STREAMSEEK_End: + m_iPosition = m_iLength + iOffset; + break; + } + if (m_iPosition < 0) { + m_iPosition = 0; + } else if (m_iPosition >= m_iLength) { + m_iPosition = m_iLength; + } + return m_iPosition; +} +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); + if (iBufferSize > m_iLength - m_iPosition) { + iBufferSize = m_iLength - m_iPosition; + } + if (m_pFileRead->ReadBlock(pBuffer, m_iPosition, iBufferSize)) { + m_iPosition += iBufferSize; + return iBufferSize; + } + return 0; +} +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); + iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; + if (iMaxLength <= 0) { + return 0; + } + int32_t i = 0; + while (i < iMaxLength && pStr[i] != L'\0') { + ++i; + } + bEOS = (m_iPosition >= m_iLength) || pStr[i] == L'\0'; + return i; +} +CFX_BufferReadStreamImp::CFX_BufferReadStreamImp() + : m_pBufferRead(NULL), + m_bReleaseBufferRead(FALSE), + m_iPosition(0), + m_iBufferSize(0) {} +CFX_BufferReadStreamImp::~CFX_BufferReadStreamImp() { + if (m_bReleaseBufferRead && m_pBufferRead != NULL) { + m_pBufferRead->Release(); + } +} +FX_BOOL CFX_BufferReadStreamImp::LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead) { + FXSYS_assert(m_pBufferRead == NULL && pBufferRead != NULL); + if (dwAccess & FX_STREAMACCESS_Write) { + return FALSE; + } + m_bReleaseBufferRead = bReleaseBufferRead; + m_pBufferRead = pBufferRead; + m_iBufferSize = iFileSize; + if (m_iBufferSize >= 0) { + return TRUE; + } + if (!m_pBufferRead->ReadNextBlock(TRUE)) { + return FALSE; + } + m_iBufferSize = m_pBufferRead->GetBlockSize(); + while (!m_pBufferRead->IsEOF()) { + m_pBufferRead->ReadNextBlock(FALSE); + m_iBufferSize += m_pBufferRead->GetBlockSize(); + } + return TRUE; +} +int32_t CFX_BufferReadStreamImp::GetLength() const { + return m_iBufferSize; +} +int32_t CFX_BufferReadStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + int32_t iLength = GetLength(); + switch (eSeek) { + case FX_STREAMSEEK_Begin: + m_iPosition = iOffset; + break; + case FX_STREAMSEEK_Current: + m_iPosition += iOffset; + break; + case FX_STREAMSEEK_End: + m_iPosition = iLength + iOffset; + break; + } + if (m_iPosition < 0) { + m_iPosition = 0; + } else if (m_iPosition >= iLength) { + m_iPosition = iLength; + } + return m_iPosition; +} +FX_BOOL CFX_BufferReadStreamImp::IsEOF() const { + return m_pBufferRead ? m_pBufferRead->IsEOF() : TRUE; +} +int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, + int32_t iBufferSize) { + FXSYS_assert(m_pBufferRead != NULL); + FXSYS_assert(pBuffer != NULL && iBufferSize > 0); + int32_t iLength = GetLength(); + if (m_iPosition >= iLength) { + return 0; + } + if (iBufferSize > iLength - m_iPosition) { + iBufferSize = iLength - m_iPosition; + } + FX_DWORD dwBlockOffset = m_pBufferRead->GetBlockOffset(); + FX_DWORD dwBlockSize = m_pBufferRead->GetBlockSize(); + if (m_iPosition < (int32_t)dwBlockOffset) { + if (!m_pBufferRead->ReadNextBlock(TRUE)) { + return 0; + } + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + dwBlockSize = m_pBufferRead->GetBlockSize(); + } + while (m_iPosition < (int32_t)dwBlockOffset || + m_iPosition >= (int32_t)(dwBlockOffset + dwBlockSize)) { + if (m_pBufferRead->IsEOF() || !m_pBufferRead->ReadNextBlock(FALSE)) { + break; + } + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + dwBlockSize = m_pBufferRead->GetBlockSize(); + } + if (m_iPosition < (int32_t)dwBlockOffset || + m_iPosition >= (int32_t)(dwBlockOffset + dwBlockSize)) { + return 0; + } + const uint8_t* pBufferTmp = m_pBufferRead->GetBlockBuffer(); + FX_DWORD dwOffsetTmp = m_iPosition - dwBlockOffset; + FX_DWORD dwCopySize = + std::min(iBufferSize, (int32_t)(dwBlockSize - dwOffsetTmp)); + FXSYS_memcpy(pBuffer, pBufferTmp + dwOffsetTmp, dwCopySize); + dwOffsetTmp = dwCopySize; + iBufferSize -= dwCopySize; + while (iBufferSize > 0) { + if (!m_pBufferRead->ReadNextBlock(FALSE)) { + break; + } + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + dwBlockSize = m_pBufferRead->GetBlockSize(); + pBufferTmp = m_pBufferRead->GetBlockBuffer(); + dwCopySize = std::min((FX_DWORD)iBufferSize, dwBlockSize); + FXSYS_memcpy(pBuffer + dwOffsetTmp, pBufferTmp, dwCopySize); + dwOffsetTmp += dwCopySize; + iBufferSize -= dwCopySize; + } + m_iPosition += dwOffsetTmp; + return dwOffsetTmp; +} +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); + iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; + if (iMaxLength <= 0) { + return 0; + } + int32_t i = 0; + while (i < iMaxLength && pStr[i] != L'\0') { + ++i; + } + bEOS = (m_iPosition >= GetLength()) || pStr[i] == L'\0'; + return i; +} +CFX_FileWriteStreamImp::CFX_FileWriteStreamImp() + : m_pFileWrite(NULL), m_iPosition(0) {} +FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite(IFX_FileWrite* pFileWrite, + FX_DWORD dwAccess) { + FXSYS_assert(m_pFileWrite == NULL && pFileWrite != NULL); + if (dwAccess & FX_STREAMACCESS_Read) { + return FALSE; + } + if (dwAccess & FX_STREAMACCESS_Append) { + m_iPosition = pFileWrite->GetSize(); + } + m_pFileWrite = pFileWrite; + return TRUE; +} +int32_t CFX_FileWriteStreamImp::GetLength() const { + if (!m_pFileWrite) { + return 0; + } + return (int32_t)m_pFileWrite->GetSize(); +} +int32_t CFX_FileWriteStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + int32_t iLength = GetLength(); + switch (eSeek) { + case FX_STREAMSEEK_Begin: + m_iPosition = iOffset; + break; + case FX_STREAMSEEK_Current: + m_iPosition += iOffset; + break; + case FX_STREAMSEEK_End: + m_iPosition = iLength + iOffset; + break; + } + if (m_iPosition < 0) { + m_iPosition = 0; + } else if (m_iPosition >= iLength) { + m_iPosition = iLength; + } + return m_iPosition; +} +FX_BOOL CFX_FileWriteStreamImp::IsEOF() const { + return m_iPosition >= GetLength(); +} +int32_t CFX_FileWriteStreamImp::WriteData(const uint8_t* pBuffer, + int32_t iBufferSize) { + if (!m_pFileWrite) { + return 0; + } + if (m_pFileWrite->WriteBlock(pBuffer, m_iPosition, iBufferSize)) { + m_iPosition += iBufferSize; + } + return iBufferSize; +} +int32_t CFX_FileWriteStreamImp::WriteString(const FX_WCHAR* pStr, + int32_t iLength) { + return WriteData((const uint8_t*)pStr, iLength * sizeof(FX_WCHAR)); +} +void CFX_FileWriteStreamImp::Flush() { + if (m_pFileWrite) { + m_pFileWrite->Flush(); + } +} +CFX_BufferStreamImp::CFX_BufferStreamImp() + : CFX_StreamImp(), + m_pData(NULL), + m_iTotalSize(0), + m_iPosition(0), + m_iLength(0) {} +FX_BOOL CFX_BufferStreamImp::LoadBuffer(uint8_t* pData, + int32_t iTotalSize, + FX_DWORD dwAccess) { + FXSYS_assert(m_pData == NULL); + FXSYS_assert(pData != NULL && iTotalSize > 0); + m_dwAccess = dwAccess; + m_pData = pData; + m_iTotalSize = iTotalSize; + m_iPosition = 0; + m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iTotalSize; + return TRUE; +} +int32_t CFX_BufferStreamImp::GetLength() const { + FXSYS_assert(m_pData != NULL); + return m_iLength; +} +int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + FXSYS_assert(m_pData != NULL); + if (eSeek == FX_STREAMSEEK_Begin) { + m_iPosition = iOffset; + } else if (eSeek == FX_STREAMSEEK_Current) { + m_iPosition += iOffset; + } else if (eSeek == FX_STREAMSEEK_End) { + m_iPosition = m_iLength + iOffset; + } + if (m_iPosition > m_iLength) { + m_iPosition = m_iLength; + } + if (m_iPosition < 0) { + m_iPosition = 0; + } + return m_iPosition; +} +int32_t CFX_BufferStreamImp::GetPosition() { + FXSYS_assert(m_pData != NULL); + return m_iPosition; +} +FX_BOOL CFX_BufferStreamImp::IsEOF() const { + FXSYS_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); + int32_t iLen = std::min(m_iLength - m_iPosition, iBufferSize); + if (iLen <= 0) { + return 0; + } + FXSYS_memcpy(pBuffer, m_pData + m_iPosition, iLen); + m_iPosition += iLen; + return iLen; +} +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); + int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength); + if (iLen <= 0) { + return 0; + } + const FX_WCHAR* pSrc = (const FX_WCHAR*)(FX_CHAR*)(m_pData + m_iPosition); + int32_t iCount = 0; + while (*pSrc != L'\0' && iCount < iLen) { + *pStr++ = *pSrc++, iCount++; + } + m_iPosition += iCount * 2; + bEOS = (*pSrc == L'\0') || (m_iPosition >= m_iLength); + return iCount; +} +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); + int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize); + if (iLen <= 0) { + return 0; + } + FXSYS_memcpy(m_pData + m_iPosition, pBuffer, iLen); + m_iPosition += iLen; + if (m_iPosition > m_iLength) { + m_iLength = m_iPosition; + } + return iLen; +} +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); + int32_t iLen = std::min((m_iTotalSize - m_iPosition) / 2, iLength); + if (iLen <= 0) { + return 0; + } + FXSYS_memcpy(m_pData + m_iPosition, pStr, iLen * 2); + m_iPosition += iLen * 2; + if (m_iPosition > m_iLength) { + m_iLength = m_iPosition; + } + return iLen; +} +IFX_Stream* IFX_Stream::CreateTextStream(IFX_Stream* pBaseStream, + FX_BOOL bDeleteOnRelease) { + FXSYS_assert(pBaseStream != NULL); + return new CFX_TextStream(pBaseStream, bDeleteOnRelease); +} +CFX_TextStream::CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream) + : m_wCodePage(FX_CODEPAGE_DefANSI), + m_wBOMLength(0), + m_dwBOM(0), + m_pBuf(NULL), + m_iBufSize(0), + m_bDelStream(bDelStream), + m_pStreamImp(pStream), + m_iRefCount(1) { + FXSYS_assert(m_pStreamImp != NULL); + m_pStreamImp->Retain(); + InitStream(); +} +CFX_TextStream::~CFX_TextStream() { + m_pStreamImp->Release(); + if (m_bDelStream) { + m_pStreamImp->Release(); + } + if (m_pBuf != NULL) { + FX_Free(m_pBuf); + } +} +void CFX_TextStream::InitStream() { + int32_t iPosition = m_pStreamImp->GetPosition(); + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, 0); + m_pStreamImp->ReadData((uint8_t*)&m_dwBOM, 3); +#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ + m_dwBOM &= 0x00FFFFFF; + if (m_dwBOM == 0x00BFBBEF) { + m_wBOMLength = 3; + m_wCodePage = FX_CODEPAGE_UTF8; + } else { + m_dwBOM &= 0x0000FFFF; + if (m_dwBOM == 0x0000FFFE) { + m_wBOMLength = 2; + m_wCodePage = FX_CODEPAGE_UTF16BE; + } else if (m_dwBOM == 0x0000FEFF) { + m_wBOMLength = 2; + m_wCodePage = FX_CODEPAGE_UTF16LE; + } else { + m_wBOMLength = 0; + m_dwBOM = 0; + m_wCodePage = FXSYS_GetACP(); + } + } +#else + m_dwBOM &= 0xFFFFFF00; + if (m_dwBOM == 0xEFBBBF00) { + m_wBOMLength = 3; + m_wCodePage = FX_CODEPAGE_UTF8; + } else { + m_dwBOM &= 0xFFFF0000; + if (m_dwBOM == 0xFEFF0000) { + m_wBOMLength = 2; + m_wCodePage = FX_CODEPAGE_UTF16BE; + } else if (m_dwBOM == 0xFFFE0000) { + m_wBOMLength = 2; + m_wCodePage = FX_CODEPAGE_UTF16LE; + } else { + m_wBOMLength = 0; + m_dwBOM = 0; + m_wCodePage = FXSYS_GetACP(); + } + } +#endif + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, std::max(m_wBOMLength, iPosition)); +} +void CFX_TextStream::Release() { + if (--m_iRefCount < 1) { + delete this; + } +} +IFX_Stream* CFX_TextStream::Retain() { + m_iRefCount++; + return this; +} +FX_DWORD CFX_TextStream::GetAccessModes() const { + return m_pStreamImp->GetAccessModes() | FX_STREAMACCESS_Text; +} +int32_t CFX_TextStream::GetLength() const { + return m_pStreamImp->GetLength(); +} +int32_t CFX_TextStream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + return m_pStreamImp->Seek(eSeek, iOffset); +} +int32_t CFX_TextStream::GetPosition() { + return m_pStreamImp->GetPosition(); +} +FX_BOOL CFX_TextStream::IsEOF() const { + return m_pStreamImp->IsEOF(); +} +int32_t CFX_TextStream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { + return m_pStreamImp->ReadData(pBuffer, iBufferSize); +} +int32_t CFX_TextStream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return m_pStreamImp->WriteData(pBuffer, iBufferSize); +} +void CFX_TextStream::Flush() { + m_pStreamImp->Flush(); +} +FX_BOOL CFX_TextStream::SetLength(int32_t iLength) { + return m_pStreamImp->SetLength(iLength); +} +FX_WORD CFX_TextStream::GetCodePage() const { + return m_wCodePage; +} +IFX_Stream* CFX_TextStream::CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength) { + IFX_Stream* pSR = + m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength); + if (pSR == NULL) { + return NULL; + } + if (dwAccess & FX_STREAMACCESS_Text) { + return new CFX_TextStream(pSR, TRUE); + } + return pSR; +} +int32_t CFX_TextStream::GetBOM(uint8_t bom[4]) const { + if (m_wBOMLength < 1) { + return 0; + } + *(FX_DWORD*)bom = m_dwBOM; + return m_wBOMLength; +} +FX_WORD CFX_TextStream::SetCodePage(FX_WORD wCodePage) { + if (m_wBOMLength > 0) { + return m_wCodePage; + } + FX_WORD v = m_wCodePage; + m_wCodePage = wCodePage; + return v; +} +int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize) { + FXSYS_assert(pStr != NULL && iMaxLength > 0); + if (m_pStreamImp == NULL) { + return -1; + } + int32_t iLen; + if (m_wCodePage == FX_CODEPAGE_UTF16LE || + m_wCodePage == FX_CODEPAGE_UTF16BE) { + int32_t iBytes = pByteSize == NULL ? iMaxLength * 2 : *pByteSize; + iLen = m_pStreamImp->ReadData((uint8_t*)pStr, iBytes); + iMaxLength = iLen / 2; + if (sizeof(FX_WCHAR) > 2) { + FX_UTF16ToWChar(pStr, iMaxLength); + } +#if _FX_ENDIAN_ == _FX_BIG_ENDIAN_ + if (m_wCodePage == FX_CODEPAGE_UTF16LE) { + FX_SwapByteOrder(pStr, iMaxLength); + } +#else + if (m_wCodePage == FX_CODEPAGE_UTF16BE) { + FX_SwapByteOrder(pStr, iMaxLength); + } +#endif + } else { + int32_t pos = m_pStreamImp->GetPosition(); + int32_t iBytes = pByteSize == NULL ? iMaxLength : *pByteSize; + iBytes = std::min(iBytes, m_pStreamImp->GetLength() - pos); + if (iBytes > 0) { + if (m_pBuf == NULL) { + m_pBuf = FX_Alloc(uint8_t, iBytes); + m_iBufSize = iBytes; + } else if (iBytes > m_iBufSize) { + m_pBuf = FX_Realloc(uint8_t, m_pBuf, iBytes); + m_iBufSize = iBytes; + } + iLen = m_pStreamImp->ReadData(m_pBuf, iBytes); + int32_t iSrc = iLen; + int32_t iDecode = FX_DecodeString(m_wCodePage, (const FX_CHAR*)m_pBuf, + &iSrc, pStr, &iMaxLength, TRUE); + m_pStreamImp->Seek(FX_STREAMSEEK_Current, iSrc - iLen); + if (iDecode < 1) { + return -1; + } + } else { + iMaxLength = 0; + } + } + bEOS = m_pStreamImp->IsEOF(); + return iMaxLength; +} +int32_t CFX_TextStream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { + FXSYS_assert(pStr != NULL && iLength > 0); + if ((m_pStreamImp->GetAccessModes() & FX_STREAMACCESS_Write) == 0) { + return -1; + } + if (m_wCodePage == FX_CODEPAGE_UTF8) { + int32_t len = iLength; + CFX_UTF8Encoder encoder; + while (len-- > 0) { + encoder.Input(*pStr++); + } + CFX_ByteStringC bsResult = encoder.GetResult(); + m_pStreamImp->WriteData((const uint8_t*)bsResult.GetCStr(), + bsResult.GetLength()); + } + return iLength; +} +CFX_Stream::CFX_Stream() + : m_eStreamType(FX_SREAMTYPE_Unknown), + m_pStreamImp(NULL), + m_dwAccess(0), + m_iTotalSize(0), + m_iPosition(0), + m_iStart(0), + m_iLength(0), + m_iRefCount(1) {} +CFX_Stream::~CFX_Stream() { + if (m_eStreamType != FX_STREAMTYPE_Stream && m_pStreamImp != NULL) { + m_pStreamImp->Release(); + } +} +FX_BOOL CFX_Stream::LoadFile(const FX_WCHAR* pszSrcFileName, + FX_DWORD dwAccess) { + if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { + return FALSE; + } + if (pszSrcFileName == NULL || FXSYS_wcslen(pszSrcFileName) < 1) { + return FALSE; + } + m_pStreamImp = new CFX_FileStreamImp(); + FX_BOOL bRet = + ((CFX_FileStreamImp*)m_pStreamImp)->LoadFile(pszSrcFileName, dwAccess); + if (!bRet) { + m_pStreamImp->Release(); + m_pStreamImp = NULL; + } else { + m_eStreamType = FX_STREAMTYPE_File; + m_dwAccess = dwAccess; + m_iLength = m_pStreamImp->GetLength(); + } + return bRet; +} +FX_BOOL CFX_Stream::LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess) { + if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { + return FALSE; + } + if (pFileRead == NULL) { + return FALSE; + } + m_pStreamImp = new CFX_FileReadStreamImp(); + FX_BOOL bRet = + ((CFX_FileReadStreamImp*)m_pStreamImp)->LoadFileRead(pFileRead, dwAccess); + if (!bRet) { + m_pStreamImp->Release(); + m_pStreamImp = NULL; + } else { + m_eStreamType = FX_STREAMTYPE_File; + m_dwAccess = dwAccess; + m_iLength = m_pStreamImp->GetLength(); + } + return bRet; +} +FX_BOOL CFX_Stream::LoadFileWrite(IFX_FileWrite* pFileWrite, + FX_DWORD dwAccess) { + if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { + return FALSE; + } + if (pFileWrite == NULL) { + return FALSE; + } + m_pStreamImp = new CFX_FileWriteStreamImp(); + FX_BOOL bRet = ((CFX_FileWriteStreamImp*)m_pStreamImp) + ->LoadFileWrite(pFileWrite, dwAccess); + if (!bRet) { + m_pStreamImp->Release(); + m_pStreamImp = NULL; + } else { + m_eStreamType = FX_STREAMTYPE_File; + m_dwAccess = dwAccess; + m_iLength = m_pStreamImp->GetLength(); + } + return bRet; +} +FX_BOOL CFX_Stream::LoadBuffer(uint8_t* pData, + int32_t iTotalSize, + FX_DWORD dwAccess) { + if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { + return FALSE; + } + if (pData == NULL || iTotalSize < 1) { + return FALSE; + } + m_pStreamImp = new CFX_BufferStreamImp(); + FX_BOOL bRet = ((CFX_BufferStreamImp*)m_pStreamImp) + ->LoadBuffer(pData, iTotalSize, dwAccess); + if (!bRet) { + m_pStreamImp->Release(); + m_pStreamImp = NULL; + } else { + m_eStreamType = FX_STREAMTYPE_Buffer; + m_dwAccess = dwAccess; + m_iLength = m_pStreamImp->GetLength(); + } + return bRet; +} +FX_BOOL CFX_Stream::LoadBufferRead(IFX_BufferRead* pBufferRead, + int32_t iFileSize, + FX_DWORD dwAccess, + FX_BOOL bReleaseBufferRead) { + if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { + return FALSE; + } + if (!pBufferRead) { + return FALSE; + } + m_pStreamImp = new CFX_BufferReadStreamImp; + FX_BOOL bRet = ((CFX_BufferReadStreamImp*)m_pStreamImp) + ->LoadBufferRead(pBufferRead, iFileSize, dwAccess, + bReleaseBufferRead); + if (!bRet) { + m_pStreamImp->Release(); + m_pStreamImp = NULL; + } else { + m_eStreamType = FX_STREAMTYPE_BufferRead; + m_dwAccess = dwAccess; + m_iLength = m_pStreamImp->GetLength(); + } + return bRet; +} +void CFX_Stream::Release() { + if (--m_iRefCount < 1) { + delete this; + } +} +IFX_Stream* CFX_Stream::Retain() { + m_iRefCount++; + return this; +} +int32_t CFX_Stream::GetLength() const { + if (m_pStreamImp == NULL) { + return -1; + } + if (m_eStreamType == FX_STREAMTYPE_File || + m_eStreamType == FX_STREAMTYPE_Buffer) { + return m_pStreamImp->GetLength(); + } + return m_iLength; +} +int32_t CFX_Stream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + if (m_pStreamImp == NULL) { + return -1; + } + if (m_eStreamType == FX_STREAMTYPE_File || + m_eStreamType == FX_STREAMTYPE_Buffer) { + return m_iPosition = m_pStreamImp->Seek(eSeek, iOffset); + } + int32_t iEnd = m_iStart + m_iLength; + int32_t iPosition = m_iStart + iOffset; + if (eSeek == FX_STREAMSEEK_Begin) { + m_iPosition = iPosition; + } else if (eSeek == FX_STREAMSEEK_Current) { + m_iPosition += iOffset; + } else if (eSeek == FX_STREAMSEEK_End) { + m_iPosition = iEnd + iOffset; + } + if (m_iPosition > iEnd) { + m_iPosition = iEnd; + } + if (m_iPosition < m_iStart) { + m_iPosition = m_iStart; + } + return m_iPosition - m_iStart; +} +int32_t CFX_Stream::GetPosition() { + if (m_pStreamImp == NULL) { + return -1; + } + if (m_eStreamType == FX_STREAMTYPE_File || + m_eStreamType == FX_STREAMTYPE_Buffer) { + return m_iPosition = m_pStreamImp->GetPosition(); + } + return m_iPosition - m_iStart; +} +FX_BOOL CFX_Stream::IsEOF() const { + if (m_pStreamImp == NULL) { + return TRUE; + } + if (m_eStreamType == FX_STREAMTYPE_File || + m_eStreamType == FX_STREAMTYPE_Buffer) { + return m_pStreamImp->IsEOF(); + } + return m_iPosition >= m_iStart + m_iLength; +} +int32_t CFX_Stream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { + FXSYS_assert(pBuffer != NULL && iBufferSize > 0); + if (m_pStreamImp == NULL) { + return -1; + } + int32_t iLen = std::min(m_iStart + m_iLength - m_iPosition, iBufferSize); + if (iLen <= 0) { + return 0; + } + if (m_pStreamImp->GetPosition() != m_iPosition) { + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); + } + iLen = m_pStreamImp->ReadData(pBuffer, iLen); + m_iPosition = m_pStreamImp->GetPosition(); + return iLen; +} +int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize) { + FXSYS_assert(pStr != NULL && iMaxLength > 0); + if (m_pStreamImp == NULL) { + return -1; + } + int32_t iEnd = m_iStart + m_iLength; + int32_t iLen = iEnd - m_iPosition; + if (pByteSize != NULL) { + iLen = std::min(iLen, *pByteSize); + } + iLen = std::min(iEnd / 2, iMaxLength); + if (iLen <= 0) { + return 0; + } + if (m_pStreamImp->GetPosition() != m_iPosition) { + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); + } + iLen = m_pStreamImp->ReadString(pStr, iLen, bEOS); + m_iPosition = m_pStreamImp->GetPosition(); + if (iLen > 0 && m_iPosition >= iEnd) { + bEOS = TRUE; + } + return iLen; +} +int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + FXSYS_assert(pBuffer != NULL && iBufferSize > 0); + if (m_pStreamImp == NULL) { + return -1; + } + if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { + return -1; + } + int32_t iLen = iBufferSize; + if (m_eStreamType == FX_STREAMTYPE_Stream) { + iLen = std::min(m_iStart + m_iTotalSize - m_iPosition, iBufferSize); + if (iLen <= 0) { + return 0; + } + } + int32_t iEnd = m_iStart + m_iLength; + if (m_pStreamImp->GetPosition() != m_iPosition) { + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); + } + iLen = m_pStreamImp->WriteData(pBuffer, iLen); + m_iPosition = m_pStreamImp->GetPosition(); + if (m_iPosition > iEnd) { + m_iLength = m_iPosition - m_iStart; + } + return iLen; +} +int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { + FXSYS_assert(pStr != NULL && iLength > 0); + if (m_pStreamImp == NULL) { + return -1; + } + if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { + return -1; + } + int32_t iLen = iLength; + if (m_eStreamType == FX_STREAMTYPE_Stream) { + iLen = std::min((m_iStart + m_iTotalSize - m_iPosition) / 2, iLength); + if (iLen <= 0) { + return 0; + } + } + int32_t iEnd = m_iStart + m_iLength; + if (m_pStreamImp->GetPosition() != m_iPosition) { + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); + } + iLen = m_pStreamImp->WriteString(pStr, iLen); + m_iPosition = m_pStreamImp->GetPosition(); + if (m_iPosition > iEnd) { + m_iLength = m_iPosition - m_iStart; + } + return iLen; +} +void CFX_Stream::Flush() { + if (m_pStreamImp == NULL) { + return; + } + if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { + return; + } + m_pStreamImp->Flush(); +} +FX_BOOL CFX_Stream::SetLength(int32_t iLength) { + if (m_pStreamImp == NULL) { + return FALSE; + } + if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { + return FALSE; + } + return m_pStreamImp->SetLength(iLength); +} +int32_t CFX_Stream::GetBOM(uint8_t bom[4]) const { + if (m_pStreamImp == NULL) { + return -1; + } + return 0; +} +FX_WORD CFX_Stream::GetCodePage() const { +#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ + return FX_CODEPAGE_UTF16LE; +#else + return FX_CODEPAGE_UTF16BE; +#endif +} +FX_WORD CFX_Stream::SetCodePage(FX_WORD wCodePage) { +#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ + return FX_CODEPAGE_UTF16LE; +#else + return FX_CODEPAGE_UTF16BE; +#endif +} +IFX_Stream* CFX_Stream::CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength) { + FXSYS_assert(iLength > 0); + if (m_pStreamImp == NULL) { + return NULL; + } + if ((m_dwAccess & FX_STREAMACCESS_Text) != 0 && + (dwAccess & FX_STREAMACCESS_Text) == 0) { + return NULL; + } + if ((m_dwAccess & FX_STREAMACCESS_Write) == 0 && + (dwAccess & FX_STREAMACCESS_Write) != 0) { + return NULL; + } + int32_t iStart = m_iStart + iOffset; + int32_t iTotal = m_iStart + m_iLength; + if (iStart < m_iStart || iStart >= iTotal) { + return NULL; + } + int32_t iEnd = iStart + iLength; + if (iEnd < iStart || iEnd > iTotal) { + return NULL; + } + CFX_Stream* pShared = new CFX_Stream; + pShared->m_eStreamType = FX_STREAMTYPE_Stream; + pShared->m_pStreamImp = m_pStreamImp; + pShared->m_dwAccess = dwAccess; + pShared->m_iTotalSize = iLength; + pShared->m_iPosition = iStart; + pShared->m_iStart = iStart; + pShared->m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iLength; + if (dwAccess & FX_STREAMACCESS_Text) { + return IFX_Stream::CreateTextStream(pShared, TRUE); + } + return pShared; +} +IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream) { + FXSYS_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); +} +CFGAS_FileRead::~CFGAS_FileRead() { + if (m_bReleaseStream) { + m_pStream->Release(); + } +} +FX_FILESIZE CFGAS_FileRead::GetSize() { + return (FX_FILESIZE)m_pStream->GetLength(); +} +FX_BOOL CFGAS_FileRead::ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) { + m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset); + int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size); + return iLen == (int32_t)size; +} + +IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize, + FX_BOOL bReleaseStream) { + if (!pBufferRead) { + return NULL; + } + return new CFX_BufferAccImp(pBufferRead, iFileSize, bReleaseStream); +} +CFX_BufferAccImp::CFX_BufferAccImp(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize, + FX_BOOL bReleaseStream) + : m_pBufferRead(pBufferRead), + m_bReleaseStream(bReleaseStream), + m_iBufSize(iFileSize) { + FXSYS_assert(m_pBufferRead); +} +CFX_BufferAccImp::~CFX_BufferAccImp() { + if (m_bReleaseStream && m_pBufferRead) { + m_pBufferRead->Release(); + } +} +FX_FILESIZE CFX_BufferAccImp::GetSize() { + if (!m_pBufferRead) { + return 0; + } + if (m_iBufSize >= 0) { + return m_iBufSize; + } + if (!m_pBufferRead->ReadNextBlock(TRUE)) { + return 0; + } + m_iBufSize = (FX_FILESIZE)m_pBufferRead->GetBlockSize(); + while (!m_pBufferRead->IsEOF()) { + m_pBufferRead->ReadNextBlock(FALSE); + m_iBufSize += (FX_FILESIZE)m_pBufferRead->GetBlockSize(); + } + return m_iBufSize; +} +FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) { + if (!m_pBufferRead) { + return FALSE; + } + if (!buffer || !size) { + return TRUE; + } + FX_FILESIZE dwBufSize = GetSize(); + if (offset >= dwBufSize) { + return FALSE; + } + size_t dwBlockSize = m_pBufferRead->GetBlockSize(); + FX_FILESIZE dwBlockOffset = m_pBufferRead->GetBlockOffset(); + if (offset < dwBlockOffset) { + if (!m_pBufferRead->ReadNextBlock(TRUE)) { + return FALSE; + } + dwBlockSize = m_pBufferRead->GetBlockSize(); + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + } + while (offset < dwBlockOffset || + offset >= (FX_FILESIZE)(dwBlockOffset + dwBlockSize)) { + if (m_pBufferRead->IsEOF() || !m_pBufferRead->ReadNextBlock(FALSE)) { + break; + } + dwBlockSize = m_pBufferRead->GetBlockSize(); + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + } + if (offset < dwBlockOffset || + offset >= (FX_FILESIZE)(dwBlockOffset + dwBlockSize)) { + return FALSE; + } + const uint8_t* pBuffer = m_pBufferRead->GetBlockBuffer(); + const FX_FILESIZE dwOffset = offset - dwBlockOffset; + size_t dwCopySize = + std::min(size, static_cast<size_t>(dwBlockSize - dwOffset)); + FXSYS_memcpy(buffer, pBuffer + dwOffset, dwCopySize); + offset = dwCopySize; + size -= dwCopySize; + while (size) { + if (!m_pBufferRead->ReadNextBlock(FALSE)) { + break; + } + dwBlockOffset = m_pBufferRead->GetBlockOffset(); + dwBlockSize = m_pBufferRead->GetBlockSize(); + pBuffer = m_pBufferRead->GetBlockBuffer(); + dwCopySize = std::min(size, dwBlockSize); + FXSYS_memcpy(((uint8_t*)buffer) + offset, pBuffer, dwCopySize); + offset += dwCopySize; + size -= dwCopySize; + } + return TRUE; +} + +IFX_FileWrite* FX_CreateFileWrite(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream) { + FXSYS_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); +} +CFGAS_FileWrite::~CFGAS_FileWrite() { + if (m_bReleaseStream) { + m_pStream->Release(); + } +} +FX_FILESIZE CFGAS_FileWrite::GetSize() { + return m_pStream->GetLength(); +} +FX_BOOL CFGAS_FileWrite::Flush() { + m_pStream->Flush(); + return TRUE; +} +FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, size_t size) { + return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) == + (int32_t)size; +} +FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, + FX_FILESIZE offset, + size_t size) { + m_pStream->Seek(FX_STREAMSEEK_Begin, offset); + int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size); + return iLen == (int32_t)size; +} diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h new file mode 100644 index 0000000000..e083886ec7 --- /dev/null +++ b/xfa/fgas/crt/fgas_stream.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_FGAS_CRT_FGAS_STREAM_H_ +#define XFA_FGAS_CRT_FGAS_STREAM_H_ + +#include "core/include/fxcrt/fx_stream.h" +#include "core/include/fxcrt/fx_system.h" + +class IFX_Stream; + +IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream = FALSE); +IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead, + FX_FILESIZE iFileSize = -1, + FX_BOOL bReleaseStream = TRUE); +IFX_FileWrite* FX_CreateFileWrite(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream = FALSE); +enum FX_STREAMACCESS { + FX_STREAMACCESS_Binary = 0x00, + FX_STREAMACCESS_Text = 0x01, + FX_STREAMACCESS_Read = 0x02, + FX_STREAMACCESS_Write = 0x04, + FX_STREAMACCESS_Truncate = 0x10, + FX_STREAMACCESS_Append = 0x20, + FX_STREAMACCESS_Create = 0x80, +}; + +enum FX_STREAMSEEK { + FX_STREAMSEEK_Begin = 0, + FX_STREAMSEEK_Current, + FX_STREAMSEEK_End, +}; + +class IFX_Stream { + public: + static IFX_Stream* CreateStream(IFX_FileRead* pFileRead, FX_DWORD dwAccess); + static IFX_Stream* CreateStream(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); + static IFX_Stream* CreateStream(const FX_WCHAR* pszFileName, + FX_DWORD dwAccess); + static IFX_Stream* CreateStream(uint8_t* pData, + int32_t length, + FX_DWORD dwAccess); + static IFX_Stream* CreateStream(IFX_BufferRead* pBufferRead, + FX_DWORD dwAccess, + int32_t iFileSize = -1, + FX_BOOL bReleaseBufferRead = TRUE); + static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, + FX_BOOL bDeleteOnRelease); + virtual ~IFX_Stream() {} + virtual void Release() = 0; + virtual IFX_Stream* Retain() = 0; + virtual FX_DWORD GetAccessModes() const = 0; + virtual int32_t GetLength() const = 0; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; + virtual int32_t GetPosition() = 0; + virtual FX_BOOL IsEOF() const = 0; + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL) = 0; + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; + virtual void Flush() = 0; + virtual FX_BOOL SetLength(int32_t iLength) = 0; + virtual int32_t GetBOM(uint8_t bom[4]) const = 0; + virtual FX_WORD GetCodePage() const = 0; + virtual FX_WORD SetCodePage(FX_WORD wCodePage) = 0; + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength) = 0; +}; + +#endif // XFA_FGAS_CRT_FGAS_STREAM_H_ diff --git a/xfa/fgas/crt/fgas_system.cpp b/xfa/fgas/crt/fgas_system.cpp new file mode 100644 index 0000000000..9d76a60118 --- /dev/null +++ b/xfa/fgas/crt/fgas_system.cpp @@ -0,0 +1,117 @@ +// 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/fgas/crt/fgas_system.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_system.h" + +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ + _FX_OS_ == _FX_WIN64_ +#include <io.h> +#elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_Mini_ +#include <sys/times.h> +#endif + +namespace { + +inline FX_BOOL FX_isupper(int32_t ch) { + return ch >= 'A' && ch <= 'Z'; +} + +inline int32_t FX_tolower(int32_t ch) { + return FX_isupper(ch) ? (ch + 0x20) : 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); + FX_WCHAR wch1 = 0, wch2 = 0; + while (count-- > 0) { + wch1 = (FX_WCHAR)FX_tolower(*s1++); + wch2 = (FX_WCHAR)FX_tolower(*s2++); + if (wch1 != wch2) { + break; + } + } + return wch1 - wch2; +} + +int32_t FX_filelength(FXSYS_FILE* file) { + FXSYS_assert(file != NULL); +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ + return _filelength(_fileno(file)); +#else + int32_t iPos = FXSYS_ftell(file); + FXSYS_fseek(file, 0, FXSYS_SEEK_END); + int32_t iLen = FXSYS_ftell(file); + FXSYS_fseek(file, iPos, FXSYS_SEEK_SET); + return iLen; +#endif +} + +FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size) { + FXSYS_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_ + HANDLE hFile = _fileno(file); + FX_DWORD dwPos = ::SetFilePointer(hFile, 0, 0, FILE_CURRENT); + ::SetFilePointer(hFile, size, 0, FILE_BEGIN); + FX_BOOL bRet = ::SetEndOfFile(hFile); + ::SetFilePointer(hFile, (int32_t)dwPos, 0, FILE_BEGIN); + return bRet; +#else + return FALSE; +#endif +} + +FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { + FXSYS_assert(pwsStr != NULL); + if (iLength < 0) { + iLength = FXSYS_wcslen(pwsStr); + } + if (iLength == 0) { + return 0.0f; + } + int32_t iUsedLen = 0; + FX_BOOL bNegtive = FALSE; + switch (pwsStr[iUsedLen]) { + case '-': + bNegtive = TRUE; + case '+': + iUsedLen++; + break; + } + FX_FLOAT fValue = 0.0f; + while (iUsedLen < iLength) { + FX_WCHAR wch = pwsStr[iUsedLen]; + if (wch >= L'0' && wch <= L'9') { + fValue = fValue * 10.0f + (wch - L'0'); + } else { + break; + } + iUsedLen++; + } + if (iUsedLen < iLength && pwsStr[iUsedLen] == L'.') { + FX_FLOAT fPrecise = 0.1f; + while (++iUsedLen < iLength) { + FX_WCHAR wch = pwsStr[iUsedLen]; + if (wch >= L'0' && wch <= L'9') { + fValue += (wch - L'0') * fPrecise; + fPrecise *= 0.1f; + } else { + break; + } + } + } + if (pUsedLen) { + *pUsedLen = iUsedLen; + } + return bNegtive ? -fValue : fValue; +} diff --git a/xfa/fgas/crt/fgas_system.h b/xfa/fgas/crt/fgas_system.h new file mode 100644 index 0000000000..4335c35541 --- /dev/null +++ b/xfa/fgas/crt/fgas_system.h @@ -0,0 +1,23 @@ +// 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_CRT_FGAS_SYSTEM_H_ +#define XFA_FGAS_CRT_FGAS_SYSTEM_H_ + +#include "core/include/fxcrt/fx_system.h" + +#define FX_RAD2DEG(r) ((r)*180.0f / FX_PI) +#define FX_DEG2RAD(a) ((a)*FX_PI / 180.0f) + +FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, + int32_t iLength = -1, + int32_t* pUsedLen = NULL); +int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); + +int32_t FX_filelength(FXSYS_FILE* file); +FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size); + +#endif // XFA_FGAS_CRT_FGAS_SYSTEM_H_ diff --git a/xfa/fgas/crt/fgas_utils.cpp b/xfa/fgas/crt/fgas_utils.cpp new file mode 100644 index 0000000000..7a85fbb7ba --- /dev/null +++ b/xfa/fgas/crt/fgas_utils.cpp @@ -0,0 +1,434 @@ +// 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/fgas/crt/fgas_utils.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_basic.h" + +class FX_BASEARRAYDATA : public CFX_Target { + public: + FX_BASEARRAYDATA(int32_t growsize, int32_t blocksize) + : iGrowSize(growsize), + iBlockSize(blocksize), + iTotalCount(0), + iBlockCount(0), + pBuffer(nullptr) {} + + ~FX_BASEARRAYDATA() { FX_Free(pBuffer); } + + int32_t iGrowSize; + int32_t iBlockSize; + int32_t iTotalCount; + int32_t iBlockCount; + uint8_t* pBuffer; +}; +CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) { + FXSYS_assert(iGrowSize > 0 && iBlockSize > 0); + m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize); +} +CFX_BaseArray::~CFX_BaseArray() { + RemoveAll(); + delete m_pData; +} +int32_t CFX_BaseArray::GetSize() const { + return m_pData->iBlockCount; +} +int32_t CFX_BaseArray::GetBlockSize() const { + return m_pData->iBlockSize; +} +uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) { + FXSYS_assert(index > -1); + uint8_t*& pBuffer = m_pData->pBuffer; + int32_t& iTotalCount = m_pData->iTotalCount; + int32_t iBlockSize = m_pData->iBlockSize; + if (index >= iTotalCount) { + int32_t iGrowSize = m_pData->iGrowSize; + iTotalCount = (index / iGrowSize + 1) * iGrowSize; + int32_t iNewSize = iTotalCount * iBlockSize; + if (!pBuffer) { + pBuffer = FX_Alloc(uint8_t, iNewSize); + } else { + pBuffer = FX_Realloc(uint8_t, pBuffer, iNewSize); + } + } + int32_t& iBlockCount = m_pData->iBlockCount; + if (index >= iBlockCount) { + iBlockCount = index + 1; + } + return pBuffer + index * iBlockSize; +} +uint8_t* CFX_BaseArray::GetAt(int32_t index) const { + FXSYS_assert(index > -1 && index < m_pData->iBlockCount); + return m_pData->pBuffer + index * m_pData->iBlockSize; +} +uint8_t* CFX_BaseArray::GetBuffer() const { + return m_pData->pBuffer; +} +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); + int32_t& iBlockCount = m_pData->iBlockCount; + int32_t iAdded = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iAdded); + if (iCount < 0) { + iCount = iAdded; + } + if (iStart + iCount > iAdded) { + iCount = iAdded - iStart; + } + if (iCount < 1) { + return 0; + } + uint8_t* pDst = m_pData->pBuffer + iBlockCount * iBlockSize; + AddSpaceTo(iBlockCount + iCount - 1); + FXSYS_memcpy(pDst, src.m_pData->pBuffer + iStart * iBlockSize, + iCount * iBlockSize); + return iCount; +} +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); + int32_t iCopied = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iCopied); + if (iCount < 0) { + iCount = iCopied; + } + if (iStart + iCount > iCopied) { + iCount = iCopied - iStart; + } + if (iCount < 1) { + return 0; + } + RemoveAll(TRUE); + AddSpaceTo(iCount - 1); + FXSYS_memcpy(m_pData->pBuffer, src.m_pData->pBuffer + iStart * iBlockSize, + iCount * iBlockSize); + return iCount; +} +int32_t CFX_BaseArray::RemoveLast(int32_t iCount) { + int32_t& iBlockCount = m_pData->iBlockCount; + if (iCount < 0 || iCount > iBlockCount) { + iCount = iBlockCount; + iBlockCount = 0; + } else { + iBlockCount -= iCount; + } + return iCount; +} +void CFX_BaseArray::RemoveAll(FX_BOOL bLeaveMemory) { + if (!bLeaveMemory) { + uint8_t*& pBuffer = m_pData->pBuffer; + if (pBuffer != NULL) { + FX_Free(pBuffer); + pBuffer = NULL; + } + m_pData->iTotalCount = 0; + } + m_pData->iBlockCount = 0; +} + +CFX_BaseMassArrayImp::CFX_BaseMassArrayImp(int32_t iChunkSize, + int32_t iBlockSize) + : 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_pData->SetSize(16); +} +CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() { + RemoveAll(); + delete m_pData; +} +uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { + FXSYS_assert(index > -1); + uint8_t* pChunk; + if (index < m_iBlockCount) { + pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); + } else { + int32_t iMemSize = m_iChunkSize * m_iBlockSize; + while (TRUE) { + if (index < m_iChunkCount * m_iChunkSize) { + pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); + break; + } else { + pChunk = FX_Alloc(uint8_t, iMemSize); + if (m_iChunkCount < m_pData->GetSize()) { + m_pData->SetAt(m_iChunkCount, pChunk); + } else { + m_pData->Add(pChunk); + } + m_iChunkCount++; + } + } + } + FXSYS_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); + uint8_t* pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); + FXSYS_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); + int32_t iAdded = src.m_iBlockCount; + FXSYS_assert(iStart > -1 && iStart < iAdded); + if (iCount < 0) { + iCount = iAdded; + } + if (iStart + iCount > iAdded) { + iCount = iAdded - iStart; + } + if (iCount < 1) { + return m_iBlockCount; + } + int32_t iBlockCount = m_iBlockCount; + int32_t iTotal = m_iBlockCount + iCount; + AddSpaceTo(iTotal - 1); + Append(iBlockCount, src, iStart, iCount); + return m_iBlockCount; +} +int32_t CFX_BaseMassArrayImp::Copy(const CFX_BaseMassArrayImp& src, + int32_t iStart, + int32_t iCount) { + FXSYS_assert(m_iBlockSize == src.m_iBlockSize); + int32_t iCopied = src.m_iBlockCount; + FXSYS_assert(iStart > -1); + if (iStart >= iCopied) { + return 0; + } + RemoveAll(TRUE); + if (iCount < 0) { + iCount = iCopied; + } + if (iStart + iCount > iCopied) { + iCount = iCopied - iStart; + } + if (iCount < 1) { + return 0; + } + if (m_iBlockCount < iCount) { + AddSpaceTo(iCount - 1); + } + Append(0, src, iStart, iCount); + return m_iBlockCount; +} + +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); + + int32_t iDstChunkIndex = iDstStart / m_iChunkSize; + int32_t iSrcChunkIndex = iSrcStart / src.m_iChunkSize; + uint8_t* pDstChunk = (uint8_t*)GetAt(iDstStart); + uint8_t* pSrcChunk = (uint8_t*)src.GetAt(iSrcStart); + int32_t iDstChunkSize = m_iChunkSize - (iDstStart % m_iChunkSize); + int32_t iSrcChunkSize = src.m_iChunkSize - (iSrcStart % src.m_iChunkSize); + int32_t iCopySize = + std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); + int32_t iCopyBytes = iCopySize * m_iBlockSize; + while (iSrcCount > 0) { + FXSYS_assert(pDstChunk != NULL && pSrcChunk != NULL); + FXSYS_memcpy(pDstChunk, pSrcChunk, iCopyBytes); + iSrcCount -= iCopySize; + iSrcChunkSize -= iCopySize; + if (iSrcChunkSize < 1) { + iSrcChunkSize = src.m_iChunkSize; + iSrcChunkIndex++; + pSrcChunk = (uint8_t*)src.m_pData->GetAt(iSrcChunkIndex); + } else { + pSrcChunk += iCopyBytes; + } + iDstChunkSize -= iCopySize; + if (iDstChunkSize < 1) { + iDstChunkSize = m_iChunkSize; + iDstChunkIndex++; + pDstChunk = (uint8_t*)m_pData->GetAt(iDstChunkIndex); + } else { + pDstChunk += iCopyBytes; + } + iCopySize = std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); + iCopyBytes = iCopySize * m_iBlockSize; + } +} +int32_t CFX_BaseMassArrayImp::RemoveLast(int32_t iCount) { + if (iCount < 0 || iCount >= m_iBlockCount) { + m_iBlockCount = 0; + } else { + m_iBlockCount -= iCount; + } + return m_iBlockCount; +} +void CFX_BaseMassArrayImp::RemoveAll(FX_BOOL bLeaveMemory) { + if (bLeaveMemory) { + m_iBlockCount = 0; + return; + } + for (int32_t i = 0; i < m_iChunkCount; i++) { + void* p = m_pData->GetAt(i); + if (p == NULL) { + continue; + } + FX_Free(p); + } + m_pData->RemoveAll(); + m_iChunkCount = 0; + m_iBlockCount = 0; +} +CFX_BaseMassArray::CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize) { + m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize); +} +CFX_BaseMassArray::~CFX_BaseMassArray() { + delete m_pData; +} +int32_t CFX_BaseMassArray::GetSize() const { + return m_pData->m_iBlockCount; +} +uint8_t* CFX_BaseMassArray::AddSpaceTo(int32_t index) { + return m_pData->AddSpaceTo(index); +} +uint8_t* CFX_BaseMassArray::GetAt(int32_t index) const { + return m_pData->GetAt(index); +} +int32_t CFX_BaseMassArray::Append(const CFX_BaseMassArray& src, + int32_t iStart, + int32_t iCount) { + return m_pData->Append(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount); +} +int32_t CFX_BaseMassArray::Copy(const CFX_BaseMassArray& src, + int32_t iStart, + int32_t iCount) { + return m_pData->Copy(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount); +} +int32_t CFX_BaseMassArray::RemoveLast(int32_t iCount) { + return m_pData->RemoveLast(iCount); +} +void CFX_BaseMassArray::RemoveAll(FX_BOOL bLeaveMemory) { + m_pData->RemoveAll(bLeaveMemory); +} + +struct FX_BASEDISCRETEARRAYDATA { + int32_t iBlockSize; + int32_t iChunkSize; + int32_t iChunkCount; + CFX_PtrArray ChunkBuffer; +}; + +CFX_BaseDiscreteArray::CFX_BaseDiscreteArray(int32_t iChunkSize, + int32_t iBlockSize) { + FXSYS_assert(iChunkSize > 0 && iBlockSize > 0); + FX_BASEDISCRETEARRAYDATA* pData = new FX_BASEDISCRETEARRAYDATA; + m_pData = pData; + pData->ChunkBuffer.SetSize(16); + pData->iChunkCount = 0; + pData->iChunkSize = iChunkSize; + pData->iBlockSize = iBlockSize; +} +CFX_BaseDiscreteArray::~CFX_BaseDiscreteArray() { + RemoveAll(); + delete static_cast<FX_BASEDISCRETEARRAYDATA*>(m_pData); +} +uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) { + FXSYS_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); + } + if (!pChunk) { + pChunk = FX_Alloc2D(uint8_t, iChunkSize, pData->iBlockSize); + FXSYS_memset(pChunk, 0, iChunkSize * pData->iBlockSize); + pData->ChunkBuffer.SetAtGrow(iChunk, pChunk); + if (iChunkCount <= iChunk) { + iChunkCount = iChunk + 1; + } + } + return pChunk + (index % iChunkSize) * pData->iBlockSize; +} +uint8_t* CFX_BaseDiscreteArray::GetAt(int32_t index) const { + FXSYS_assert(index > -1); + 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; + } + return pChunk + (index % iChunkSize) * pData->iBlockSize; +} +void CFX_BaseDiscreteArray::RemoveAll() { + FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData; + CFX_PtrArray& 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); + } + ChunkBuffer.RemoveAll(); + iChunkCount = 0; +} +CFX_BaseStack::CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize) { + m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize); +} +CFX_BaseStack::~CFX_BaseStack() { + delete (CFX_BaseMassArrayImp*)m_pData; +} +uint8_t* CFX_BaseStack::Push() { + return m_pData->AddSpace(); +} +void CFX_BaseStack::Pop() { + int32_t& iBlockCount = m_pData->m_iBlockCount; + if (iBlockCount < 1) { + return; + } + iBlockCount--; +} +uint8_t* CFX_BaseStack::GetTopElement() const { + int32_t iSize = m_pData->m_iBlockCount; + if (iSize < 1) { + return NULL; + } + return m_pData->GetAt(iSize - 1); +} +int32_t CFX_BaseStack::GetSize() const { + return m_pData->m_iBlockCount; +} +uint8_t* CFX_BaseStack::GetAt(int32_t index) const { + return m_pData->GetAt(index); +} +void CFX_BaseStack::RemoveAll(FX_BOOL bLeaveMemory) { + m_pData->RemoveAll(bLeaveMemory); +} diff --git a/xfa/fgas/crt/fgas_utils.h b/xfa/fgas/crt/fgas_utils.h new file mode 100644 index 0000000000..f03e3983fa --- /dev/null +++ b/xfa/fgas/crt/fgas_utils.h @@ -0,0 +1,737 @@ +// 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_CRT_FGAS_UTILS_H_ +#define XFA_FGAS_CRT_FGAS_UTILS_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "xfa/fgas/crt/fgas_memory.h" + +class FX_BASEARRAYDATA; + +template <class baseType> +class CFX_CPLTree; + +class CFX_BaseArray : public CFX_Target { + protected: + CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); + ~CFX_BaseArray(); + int32_t GetSize() const; + int32_t GetBlockSize() const; + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + uint8_t* GetBuffer() const; + int32_t Append(const CFX_BaseArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t RemoveLast(int32_t iCount = -1); + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + + FX_BASEARRAYDATA* m_pData; +}; + +template <class baseType> +class CFX_BaseArrayTemplate : public CFX_BaseArray { + public: + CFX_BaseArrayTemplate(int32_t iGrowSize = 100) + : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} + CFX_BaseArrayTemplate(int32_t iGrowSize, int32_t iBlockSize) + : CFX_BaseArray(iGrowSize, iBlockSize) {} + int32_t GetSize() const { return CFX_BaseArray::GetSize(); } + int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } + baseType* AddSpace() { + return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize()); + } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseArray::GetSize(); + *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; + return index; + } + baseType* GetBuffer() const { return (baseType*)CFX_BaseArray::GetBuffer(); } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseArray::GetAt(index); + } + void SetAt(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseArray::GetAt(index) = element; + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; + } + int32_t Append(const CFX_BaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseArray::Append(src, iStart, iCount); + } + int32_t Copy(const CFX_BaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseArray::Copy(src, iStart, iCount); + } + int32_t RemoveLast(int32_t iCount = -1) { + return CFX_BaseArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseArray::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_BaseArrayTemplate<void*> CFDE_PtrArray; +typedef CFX_BaseArrayTemplate<FX_DWORD> CFDE_DWordArray; +typedef CFX_BaseArrayTemplate<FX_WORD> CFDE_WordArray; + +template <class baseType> +class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray { + public: + CFX_ObjectBaseArrayTemplate(int32_t iGrowSize = 100) + : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} + ~CFX_ObjectBaseArrayTemplate() { RemoveAll(FALSE); } + int32_t GetSize() const { return CFX_BaseArray::GetSize(); } + int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseArray::GetSize(); + baseType* p = (baseType*)CFX_BaseArray::AddSpaceTo(index); + new ((void*)p) baseType(element); + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseArray::GetAt(index); + } + int32_t Append(const CFX_ObjectBaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + FXSYS_assert(GetBlockSize() == src.GetBlockSize()); + if (iCount == 0) { + return 0; + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + if (iStart + iCount > iSize) { + iCount = iSize - iStart; + } + if (iCount < 1) { + return 0; + } + iSize = CFX_BaseArray::GetSize(); + CFX_BaseArray::AddSpaceTo(iSize + iCount - 1); + uint8_t** pStart = CFX_BaseArray::GetAt(iSize); + int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); + iSize = iStart + iCount; + for (int32_t i = iStart; i < iSize; i++) { + FXTARGET_NewWith((void*)pStart) baseType(src.GetAt(i)); + pStart += iBlockSize; + } + return iCount; + } + int32_t Copy(const CFX_ObjectBaseArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + FXSYS_assert(GetBlockSize() == src.GetBlockSize()); + if (iCount == 0) { + return 0; + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + if (iStart + iCount > iSize) { + iCount = iSize - iStart; + } + if (iCount < 1) { + return 0; + } + RemoveAll(TRUE); + CFX_BaseArray::AddSpaceTo(iCount - 1); + uint8_t** pStart = CFX_BaseArray::GetAt(0); + int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); + iSize = iStart + iCount; + for (int32_t i = iStart; i < iSize; i++) { + new ((void*)pStart) baseType(src.GetAt(i)); + pStart += iBlockSize; + } + return iCount; + } + int32_t RemoveLast(int32_t iCount = -1) { + int32_t iSize = CFX_BaseArray::GetSize(); + if (iCount < 0 || iCount > iSize) { + iCount = iSize; + } + if (iCount == 0) { + return iSize; + } + for (int32_t i = iSize - iCount; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + return CFX_BaseArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseArray::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + CFX_BaseArray::RemoveAll(bLeaveMemory); + } +}; + +class CFX_BaseMassArrayImp : public CFX_Target { + public: + CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseMassArrayImp(); + uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + int32_t Append(const CFX_BaseMassArrayImp& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseMassArrayImp& src, + int32_t iStart = 0, + 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; + + protected: + void Append(int32_t iDstStart, + const CFX_BaseMassArrayImp& src, + int32_t iSrcStart = 0, + int32_t iSrcCount = -1); +}; + +class CFX_BaseMassArray : public CFX_Target { + protected: + CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseMassArray(); + int32_t GetSize() const; + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + int32_t Append(const CFX_BaseMassArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t Copy(const CFX_BaseMassArray& src, + int32_t iStart = 0, + int32_t iCount = -1); + int32_t RemoveLast(int32_t iCount = -1); + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + CFX_BaseMassArrayImp* m_pData; +}; + +template <class baseType> +class CFX_MassArrayTemplate : public CFX_BaseMassArray { + public: + CFX_MassArrayTemplate(int32_t iChunkSize = 100) + : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} + CFX_MassArrayTemplate(int32_t iChunkSize, int32_t iBlockSize) + : CFX_BaseMassArray(iChunkSize, iBlockSize) {} + int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } + baseType* AddSpace() { + return (baseType*)CFX_BaseMassArray::AddSpaceTo( + CFX_BaseMassArray::GetSize()); + } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseMassArray::GetSize(); + *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseMassArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseMassArray::GetAt(index); + } + void SetAt(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseMassArray::GetAt(index) = element; + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; + } + int32_t Append(const CFX_MassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseMassArray::Append(src, iStart, iCount); + } + int32_t Copy(const CFX_MassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + return CFX_BaseMassArray::Copy(src, iStart, iCount); + } + int32_t RemoveLast(int32_t iCount = -1) { + return CFX_BaseMassArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseMassArray::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_MassArrayTemplate<void*> CFX_PtrMassArray; +typedef CFX_MassArrayTemplate<int32_t> CFX_Int32MassArray; +typedef CFX_MassArrayTemplate<FX_DWORD> CFX_DWordMassArray; +typedef CFX_MassArrayTemplate<FX_WORD> CFX_WordMassArray; +typedef CFX_MassArrayTemplate<CFX_Rect> CFX_RectMassArray; +typedef CFX_MassArrayTemplate<CFX_RectF> CFX_RectFMassArray; + +template <class baseType> +class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray { + public: + CFX_ObjectMassArrayTemplate(int32_t iChunkSize = 100) + : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} + ~CFX_ObjectMassArrayTemplate() { RemoveAll(FALSE); } + int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } + int32_t Add(const baseType& element) { + int32_t index = CFX_BaseMassArray::GetSize(); + baseType* p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index); + new ((void*)p) baseType(element); + return index; + } + baseType& GetAt(int32_t index) const { + return *(baseType*)CFX_BaseMassArray::GetAt(index); + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseMassArray::GetAt(index); + } + int32_t Append(const CFX_ObjectMassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseMassArray::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + for (int32_t i = iStart; i < iEnd; i++) { + Add(src.GetAt(i)); + } + return CFX_BaseMassArray::GetSize(); + } + int32_t Copy(const CFX_ObjectMassArrayTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseMassArray::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + RemoveAll(TRUE); + for (int32_t i = iStart; i < iEnd; i++) { + Add(src.GetAt(i)); + } + return CFX_BaseMassArray::GetSize(); + } + int32_t RemoveLast(int32_t iCount = -1) { + int32_t iSize = CFX_BaseMassArray::GetSize(); + if (iCount < 0 || iCount > iSize) { + iCount = iSize; + } + if (iCount == 0) { + return iSize; + } + for (int32_t i = iSize - iCount; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + return CFX_BaseMassArray::RemoveLast(iCount); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseMassArray::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)GetPtrAt(i))->~baseType(); + } + CFX_BaseMassArray::RemoveAll(bLeaveMemory); + } +}; + +class CFX_BaseDiscreteArray : public CFX_Target { + protected: + CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseDiscreteArray(); + uint8_t* AddSpaceTo(int32_t index); + uint8_t* GetAt(int32_t index) const; + void RemoveAll(); + void* m_pData; +}; + +template <class baseType> +class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { + public: + CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) + : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {} + baseType& GetAt(int32_t index, const baseType& defValue) const { + baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); + return p == NULL ? (baseType&)defValue : *p; + } + baseType* GetPtrAt(int32_t index) const { + return (baseType*)CFX_BaseDiscreteArray::GetAt(index); + } + void SetAtGrow(int32_t index, const baseType& element) { + *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; + } + void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } +}; +typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray; +typedef CFX_DiscreteArrayTemplate<FX_DWORD> CFX_DWordDiscreteArray; +typedef CFX_DiscreteArrayTemplate<FX_WORD> CFX_WordDiscreteArray; + +class CFX_BaseStack : public CFX_Target { + protected: + CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize); + ~CFX_BaseStack(); + uint8_t* Push(); + void Pop(); + uint8_t* GetTopElement() const; + int32_t GetSize() const; + uint8_t* GetAt(int32_t index) const; + void RemoveAll(FX_BOOL bLeaveMemory = FALSE); + CFX_BaseMassArrayImp* m_pData; +}; + +template <class baseType> +class CFX_StackTemplate : public CFX_BaseStack { + public: + CFX_StackTemplate(int32_t iChunkSize = 100) + : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} + int32_t Push(const baseType& element) { + int32_t index = CFX_BaseStack::GetSize(); + *(baseType*)CFX_BaseStack::Push() = element; + return index; + } + void Pop() { CFX_BaseStack::Pop(); } + baseType* GetTopElement() const { + return (baseType*)CFX_BaseStack::GetTopElement(); + } + int32_t GetSize() const { return CFX_BaseStack::GetSize(); } + baseType* GetAt(int32_t index) const { + return (baseType*)CFX_BaseStack::GetAt(index); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + CFX_BaseStack::RemoveAll(bLeaveMemory); + } +}; +typedef CFX_StackTemplate<void*> CFX_PtrStack; +typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack; +typedef CFX_StackTemplate<FX_WORD> CFX_WordStack; +typedef CFX_StackTemplate<int32_t> CFX_Int32Stack; + +template <class baseType> +class CFX_ObjectStackTemplate : public CFX_BaseStack { + public: + CFX_ObjectStackTemplate(int32_t iChunkSize = 100) + : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} + ~CFX_ObjectStackTemplate() { RemoveAll(); } + int32_t Push(const baseType& element) { + int32_t index = CFX_BaseStack::GetSize(); + baseType* p = (baseType*)CFX_BaseStack::Push(); + new ((void*)p) baseType(element); + return index; + } + void Pop() { + baseType* p = (baseType*)CFX_BaseStack::GetTopElement(); + if (p != NULL) { + p->~baseType(); + } + CFX_BaseStack::Pop(); + } + baseType* GetTopElement() const { + return (baseType*)CFX_BaseStack::GetTopElement(); + } + int32_t GetSize() const { return CFX_BaseStack::GetSize(); } + baseType* GetAt(int32_t index) const { + return (baseType*)CFX_BaseStack::GetAt(index); + } + void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { + int32_t iSize = CFX_BaseStack::GetSize(); + for (int32_t i = 0; i < iSize; i++) { + ((baseType*)CFX_BaseStack::GetAt(i))->~baseType(); + } + CFX_BaseStack::RemoveAll(bLeaveMemory); + } + int32_t Copy(const CFX_ObjectStackTemplate& src, + int32_t iStart = 0, + int32_t iCount = -1) { + if (iCount == 0) { + return CFX_BaseStack::GetSize(); + } + int32_t iSize = src.GetSize(); + FXSYS_assert(iStart > -1 && iStart < iSize); + if (iCount < 0) { + iCount = iSize; + } + int32_t iEnd = iStart + iCount; + if (iEnd > iSize) { + iEnd = iSize; + } + RemoveAll(TRUE); + for (int32_t i = iStart; i < iEnd; i++) { + Push(*src.GetAt(i)); + } + return CFX_BaseStack::GetSize(); + } +}; + +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/xfa/fgas/font/fgas_font.h b/xfa/fgas/font/fgas_font.h new file mode 100644 index 0000000000..5c362122ba --- /dev/null +++ b/xfa/fgas/font/fgas_font.h @@ -0,0 +1,285 @@ +// 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_FONT_FGAS_FONT_H_ +#define XFA_FGAS_FONT_FGAS_FONT_H_ + +#include "core/include/fxge/fx_font.h" +#include "xfa/fgas/crt/fgas_stream.h" + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +#include "xfa/fgas/crt/fgas_memory.h" +#include "xfa/fgas/crt/fgas_utils.h" +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + +class IFX_Font; +class IFX_FontMgr; + +#define FX_FONTSTYLE_Normal 0x00 +#define FX_FONTSTYLE_FixedPitch 0x01 +#define FX_FONTSTYLE_Serif 0x02 +#define FX_FONTSTYLE_Symbolic 0x04 +#define FX_FONTSTYLE_Script 0x08 +#define FX_FONTSTYLE_Italic 0x40 +#define FX_FONTSTYLE_Bold 0x40000 +#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic) +#define FX_FONTSTYLE_ExactMatch 0x80000000 +#define FX_FONTDECORATION_Underline 0x00000001 +#define FX_FONTDECORATION_Strikeout 0x00000002 +#define FX_FONTDECORATION_Overline 0x00000004 +#define FX_FONTDECORATION_Emphasis 0x00000008 +#define FX_FONTDECORATION_Superscript 0x00000010 +#define FX_FONTDECORATION_Subscript 0x00000020 +#define FX_FONTDECORATION_SmallCapital 0x00000040 +#define FX_FONTDECORATION_Capital 0x00000080 +#define FX_FONTDECORATION_Lowercase 0x000000C0 +#define FX_FONTDECORATION_Raised 0x00000100 +#define FX_FONTDECORATION_Sunken 0x00000200 +#define FX_FONTDECORATION_Shadow 0x00000400 +#define FX_FONTDECORATION_BoundingShape 0x20000000 +#define FX_FONTDECORATION_Hide 0x40000000 +#define FX_FONTDECORATION_StrokeFill 0x80000000 +#define FX_BOUNDINGSHAPE_None 0 +#define FX_BOUNDINGSHAPE_Circle 1 +#define FX_BOUNDINGSHAPE_Square 2 +#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, + FX_DWORD dwFontStyles, + FX_WORD wCodePage, + IFX_FontMgr* pFontMgr); + static IFX_Font* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + IFX_FontMgr* pFontMgr); + static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr); + static IFX_Font* LoadFont(IFX_Stream* pFontStream, + IFX_FontMgr* pFontMgr, + FX_BOOL bSaveStream = FALSE); + static IFX_Font* LoadFont(CFX_Font* pExtFont, + IFX_FontMgr* pFontMgr, + FX_BOOL bTakeOver = FALSE); + virtual ~IFX_Font() {} + virtual void Release() = 0; + virtual IFX_Font* Retain() = 0; + virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0; + virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0; + virtual void GetPsName(CFX_WideString& wsName) const = 0; + virtual FX_DWORD GetFontStyles() const = 0; + virtual uint8_t GetCharSet() const = 0; + virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode = FALSE) = 0; + virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, + FX_BOOL bCharCode = FALSE) = 0; + virtual int32_t GetAscent() const = 0; + virtual int32_t GetDescent() const = 0; + virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, + CFX_Rect& bbox, + FX_BOOL bCharCode = FALSE) = 0; + virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; + virtual int32_t GetItalicAngle() const = 0; + 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; +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0; +#endif +}; +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +struct FX_FONTMATCHPARAMS { + const FX_WCHAR* pwsFamily; + FX_DWORD dwFontStyles; + FX_DWORD dwUSB; + FX_DWORD dwMatchFlags; + FX_WCHAR wUnicode; + FX_WORD wCodePage; +}; +typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS; +typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS; + +struct FX_FONTSIGNATURE { + FX_DWORD fsUsb[4]; + FX_DWORD fsCsb[2]; +}; +inline bool operator==(const FX_FONTSIGNATURE& left, + const FX_FONTSIGNATURE& right) { + return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] && + left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] && + left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1]; +} + +struct FX_FONTDESCRIPTOR { + FX_WCHAR wsFontFace[32]; + FX_DWORD dwFontStyles; + 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) { + return left.uCharSet == right.uCharSet && + left.dwFontStyles == right.dwFontStyles && + left.FontSignature == right.FontSignature && + FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0; +} + +#define FX_FONTMATCHPARA_MacthStyle 0x01 +#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); +FX_LPMatchFont FX_GetDefFontMatchor(); +class IFX_FontMgr { + public: + static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator, + FX_LPMatchFont pMatcher = NULL, + void* pUserData = NULL); + virtual ~IFX_FontMgr() {} + virtual void Release() = 0; + virtual IFX_Font* GetDefFontByCodePage( + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF) = 0; + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0; + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + const FX_WCHAR* pszFontAlias = NULL, + FX_DWORD dwFontStyles = 0, + FX_WORD wCodePage = 0, + FX_BOOL bSaveStream = FALSE) = 0; + virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF) = 0; + 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, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + IFX_FontMgr* pFontMgr, + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + IFX_FontMgr* pFontMgr, + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + IFX_FontMgr* pFontMgr, + FX_WORD wLanguage, + FX_DWORD 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(); +class IFX_FontMgr { + public: + static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum, + IFX_FontMgrDelegate* pDelegate = NULL, + void* pUserData = NULL); + virtual ~IFX_FontMgr() {} + virtual void Release() = 0; + virtual IFX_Font* GetDefFontByCodePage( + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByCharset( + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByUnicode( + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetDefFontByLanguage( + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); + } + virtual IFX_Font* GetFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL) = 0; + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + int32_t iFaceIndex, + int32_t* pFaceCount = NULL) = 0; + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, + int32_t iFaceIndex, + int32_t* pFaceCount = NULL) = 0; + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + int32_t iFaceIndex, + int32_t* pFaceCount = NULL, + FX_BOOL bSaveStream = FALSE) = 0; + + virtual void ClearFontCache() = 0; + virtual void RemoveFont(IFX_Font* pFont) = 0; +}; +#endif + +#endif // XFA_FGAS_FONT_FGAS_FONT_H_ diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp new file mode 100644 index 0000000000..51bba0123e --- /dev/null +++ b/xfa/fgas/font/fgas_fontutils.cpp @@ -0,0 +1,153 @@ +// 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/fgas/font/fgas_fontutils.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/font/fgas_font.h" + +FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles) { + FX_DWORD dwHash = wCodePage; + if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { + dwHash |= 0x00010000; + } + if (dwFontStyles & FX_FONTSTYLE_Serif) { + dwHash |= 0x00020000; + } + if (dwFontStyles & FX_FONTSTYLE_Symbolic) { + dwHash |= 0x00040000; + } + if (dwFontStyles & FX_FONTSTYLE_Script) { + dwHash |= 0x00080000; + } + if (dwFontStyles & FX_FONTSTYLE_Italic) { + dwHash |= 0x00100000; + } + if (dwFontStyles & FX_FONTSTYLE_Bold) { + dwHash |= 0x00200000; + } + return dwHash; +} +FX_DWORD FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + CFX_WideString wsFont(pszFontFamily); + if (dwFontStyles & FX_FONTSTYLE_Bold) { + wsFont += L"Bold"; + } + if (dwFontStyles & FX_FONTSTYLE_Italic) { + wsFont += L"Italic"; + } + wsFont += wCodePage; + return FX_HashCode_String_GetW((const FX_WCHAR*)wsFont, wsFont.GetLength()); +} +static const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { + {0x0000, 0x007F, 0, 1252}, {0x0080, 0x00FF, 1, 1252}, + {0x0100, 0x017F, 2, 1250}, {0x0180, 0x024F, 3, 1250}, + {0x0250, 0x02AF, 4, 0xFFFF}, {0x02B0, 0x02FF, 5, 0xFFFF}, + {0x0300, 0x036F, 6, 0xFFFF}, {0x0370, 0x03FF, 7, 1253}, + {0x0400, 0x04FF, 9, 1251}, {0x0500, 0x052F, 9, 0xFFFF}, + {0x0530, 0x058F, 10, 0xFFFF}, {0x0590, 0x05FF, 11, 1255}, + {0x0600, 0x06FF, 13, 1256}, {0x0700, 0x074F, 71, 0xFFFF}, + {0x0750, 0x077F, 13, 0xFFFF}, {0x0780, 0x07BF, 72, 0xFFFF}, + {0x07C0, 0x07FF, 14, 0xFFFF}, {0x0800, 0x08FF, 999, 0xFFFF}, + {0x0900, 0x097F, 15, 0xFFFF}, {0x0980, 0x09FF, 16, 0xFFFF}, + {0x0A00, 0x0A7F, 17, 0xFFFF}, {0x0A80, 0x0AFF, 18, 0xFFFF}, + {0x0B00, 0x0B7F, 19, 0xFFFF}, {0x0B80, 0x0BFF, 20, 0xFFFF}, + {0x0C00, 0x0C7F, 21, 0xFFFF}, {0x0C80, 0x0CFF, 22, 0xFFFF}, + {0x0D00, 0x0D7F, 23, 0xFFFF}, {0x0D80, 0x0DFF, 73, 0xFFFF}, + {0x0E00, 0x0E7F, 24, 874}, {0x0E80, 0x0EFF, 25, 0xFFFF}, + {0x0F00, 0x0FFF, 70, 0xFFFF}, {0x1000, 0x109F, 74, 0xFFFF}, + {0x10A0, 0x10FF, 26, 0xFFFF}, {0x1100, 0x11FF, 28, 0xFFFF}, + {0x1200, 0x137F, 75, 0xFFFF}, {0x1380, 0x139F, 75, 0xFFFF}, + {0x13A0, 0x13FF, 76, 0xFFFF}, {0x1400, 0x167F, 77, 0xFFFF}, + {0x1680, 0x169F, 78, 0xFFFF}, {0x16A0, 0x16FF, 79, 0xFFFF}, + {0x1700, 0x171F, 84, 0xFFFF}, {0x1720, 0x173F, 84, 0xFFFF}, + {0x1740, 0x175F, 84, 0xFFFF}, {0x1760, 0x177F, 84, 0xFFFF}, + {0x1780, 0x17FF, 80, 0xFFFF}, {0x1800, 0x18AF, 81, 0xFFFF}, + {0x18B0, 0x18FF, 999, 0xFFFF}, {0x1900, 0x194F, 93, 0xFFFF}, + {0x1950, 0x197F, 94, 0xFFFF}, {0x1980, 0x19DF, 95, 0xFFFF}, + {0x19E0, 0x19FF, 80, 0xFFFF}, {0x1A00, 0x1A1F, 96, 0xFFFF}, + {0x1A20, 0x1AFF, 999, 0xFFFF}, {0x1B00, 0x1B7F, 27, 0xFFFF}, + {0x1B80, 0x1BBF, 112, 0xFFFF}, {0x1BC0, 0x1BFF, 999, 0xFFFF}, + {0x1C00, 0x1C4F, 113, 0xFFFF}, {0x1C50, 0x1C7F, 114, 0xFFFF}, + {0x1C80, 0x1CFF, 999, 0xFFFF}, {0x1D00, 0x1D7F, 4, 0xFFFF}, + {0x1D80, 0x1DBF, 4, 0xFFFF}, {0x1DC0, 0x1DFF, 6, 0xFFFF}, + {0x1E00, 0x1EFF, 29, 0xFFFF}, {0x1F00, 0x1FFF, 30, 0xFFFF}, + {0x2000, 0x206F, 31, 0xFFFF}, {0x2070, 0x209F, 32, 0xFFFF}, + {0x20A0, 0x20CF, 33, 0xFFFF}, {0x20D0, 0x20FF, 34, 0xFFFF}, + {0x2100, 0x214F, 35, 0xFFFF}, {0x2150, 0x215F, 36, 0xFFFF}, + {0x2160, 0x216B, 36, 936}, {0x216C, 0x216F, 36, 0xFFFF}, + {0x2170, 0x2179, 36, 936}, {0x217A, 0x218F, 36, 0xFFFF}, + {0x2190, 0x2199, 37, 949}, {0x219A, 0x21FF, 37, 0xFFFF}, + {0x2200, 0x22FF, 38, 0xFFFF}, {0x2300, 0x23FF, 39, 0xFFFF}, + {0x2400, 0x243F, 40, 0xFFFF}, {0x2440, 0x245F, 41, 0xFFFF}, + {0x2460, 0x2473, 42, 932}, {0x2474, 0x249B, 42, 936}, + {0x249C, 0x24E9, 42, 949}, {0x24EA, 0x24FF, 42, 0xFFFF}, + {0x2500, 0x2573, 43, 936}, {0x2574, 0x257F, 43, 0xFFFF}, + {0x2580, 0x2580, 44, 0xFFFF}, {0x2581, 0x258F, 44, 936}, + {0x2590, 0x259F, 44, 0xFFFF}, {0x25A0, 0x25FF, 45, 0xFFFF}, + {0x2600, 0x26FF, 46, 0xFFFF}, {0x2700, 0x27BF, 47, 0xFFFF}, + {0x27C0, 0x27EF, 38, 0xFFFF}, {0x27F0, 0x27FF, 37, 0xFFFF}, + {0x2800, 0x28FF, 82, 0xFFFF}, {0x2900, 0x297F, 37, 0xFFFF}, + {0x2980, 0x29FF, 38, 0xFFFF}, {0x2A00, 0x2AFF, 38, 0xFFFF}, + {0x2B00, 0x2BFF, 37, 0xFFFF}, {0x2C00, 0x2C5F, 97, 0xFFFF}, + {0x2C60, 0x2C7F, 29, 0xFFFF}, {0x2C80, 0x2CFF, 8, 0xFFFF}, + {0x2D00, 0x2D2F, 26, 0xFFFF}, {0x2D30, 0x2D7F, 98, 0xFFFF}, + {0x2D80, 0x2DDF, 75, 0xFFFF}, {0x2DE0, 0x2DFF, 9, 0xFFFF}, + {0x2E00, 0x2E7F, 31, 0xFFFF}, {0x2E80, 0x2EFF, 59, 0xFFFF}, + {0x2F00, 0x2FDF, 59, 0xFFFF}, {0x2FE0, 0x2FEF, 999, 0xFFFF}, + {0x2FF0, 0x2FFF, 59, 0xFFFF}, {0x3000, 0x303F, 48, 0xFFFF}, + {0x3040, 0x309F, 49, 932}, {0x30A0, 0x30FF, 50, 932}, + {0x3100, 0x3129, 51, 936}, {0x312A, 0x312F, 51, 0xFFFF}, + {0x3130, 0x318F, 52, 949}, {0x3190, 0x319F, 59, 0xFFFF}, + {0x31A0, 0x31BF, 51, 0xFFFF}, {0x31C0, 0x31EF, 61, 0xFFFF}, + {0x31F0, 0x31FF, 50, 0xFFFF}, {0x3200, 0x321C, 54, 949}, + {0x321D, 0x325F, 54, 0xFFFF}, {0x3260, 0x327F, 54, 949}, + {0x3280, 0x32FF, 54, 0xFFFF}, {0x3300, 0x3387, 55, 0xFFFF}, + {0x3388, 0x33D0, 55, 949}, {0x33D1, 0x33FF, 55, 0xFFFF}, + {0x3400, 0x4DBF, 59, 0xFFFF}, {0x4DC0, 0x4DFF, 99, 0xFFFF}, + {0x4E00, 0x9FA5, 59, 936}, {0x9FA6, 0x9FFF, 59, 0xFFFF}, + {0xA000, 0xA48F, 83, 0xFFFF}, {0xA490, 0xA4CF, 83, 0xFFFF}, + {0xA4D0, 0xA4FF, 999, 0xFFFF}, {0xA500, 0xA63F, 12, 0xFFFF}, + {0xA640, 0xA69F, 9, 0xFFFF}, {0xA6A0, 0xA6FF, 999, 0xFFFF}, + {0xA700, 0xA71F, 5, 0xFFFF}, {0xA720, 0xA7FF, 29, 0xFFFF}, + {0xA800, 0xA82F, 100, 0xFFFF}, {0xA830, 0xA8FF, 999, 0xFFFF}, + {0xA840, 0xA87F, 53, 0xFFFF}, {0xA880, 0xA8DF, 115, 0xFFFF}, + {0xA8E0, 0xA8FF, 999, 0xFFFF}, {0xA900, 0xA92F, 116, 0xFFFF}, + {0xA930, 0xA95F, 117, 0xFFFF}, {0xA960, 0xA9FF, 999, 0xFFFF}, + {0xAA00, 0xAA5F, 118, 0xFFFF}, {0xAA60, 0xABFF, 999, 0xFFFF}, + {0xAC00, 0xD7AF, 56, 949}, {0xD7B0, 0xD7FF, 999, 0xFFFF}, + {0xD800, 0xDB7F, 57, 0xFFFF}, {0xDB80, 0xDBFF, 57, 0xFFFF}, + {0xDC00, 0xDFFF, 57, 0xFFFF}, {0xE000, 0xE814, 60, 0xFFFF}, + {0xE815, 0xE864, 60, 936}, {0xE865, 0xF8FF, 60, 0xFFFF}, + {0xF900, 0xFA0B, 61, 949}, {0xFA0C, 0xFA0D, 61, 936}, + {0xFA0E, 0xFA2D, 61, 932}, {0xFA2E, 0xFAFF, 61, 0xFFFF}, + {0xFB00, 0xFB4F, 62, 0xFFFF}, {0xFB50, 0xFDFF, 63, 1256}, + {0xFE00, 0xFE0F, 91, 0xFFFF}, {0xFE10, 0xFE1F, 65, 0xFFFF}, + {0xFE20, 0xFE2F, 64, 0xFFFF}, {0xFE30, 0xFE4F, 65, 0xFFFF}, + {0xFE50, 0xFE6F, 66, 0xFFFF}, {0xFE70, 0xFEFF, 67, 1256}, + {0xFF00, 0xFF5F, 68, 936}, {0xFF60, 0xFF9F, 68, 932}, + {0xFFA0, 0xFFEF, 68, 0xFFFF}, +}; + +const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode) { + int32_t iEnd = sizeof(g_FXGdiFontUSBTable) / sizeof(FGAS_FONTUSB) - 1; + FXSYS_assert(iEnd >= 0); + int32_t iStart = 0, iMid; + do { + iMid = (iStart + iEnd) / 2; + const FGAS_FONTUSB& usb = g_FXGdiFontUSBTable[iMid]; + if (wUnicode < usb.wStartUnicode) { + iEnd = iMid - 1; + } else if (wUnicode > usb.wEndUnicode) { + iStart = iMid + 1; + } else { + return &usb; + } + } while (iStart <= iEnd); + return NULL; +} diff --git a/xfa/fgas/font/fgas_fontutils.h b/xfa/fgas/font/fgas_fontutils.h new file mode 100644 index 0000000000..75c50c8d4a --- /dev/null +++ b/xfa/fgas/font/fgas_fontutils.h @@ -0,0 +1,25 @@ +// 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_FONT_FGAS_FONTUTILS_H_ +#define XFA_FGAS_FONT_FGAS_FONTUTILS_H_ + +#include "core/include/fxcrt/fx_string.h" + +struct FGAS_FONTUSB { + FX_WCHAR wStartUnicode; + FX_WCHAR wEndUnicode; + FX_WORD wBitField; + FX_WORD wCodePage; +}; + +FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles); +FX_DWORD FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage); +const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode); + +#endif // XFA_FGAS_FONT_FGAS_FONTUTILS_H_ diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp new file mode 100644 index 0000000000..831da7e7d6 --- /dev/null +++ b/xfa/fgas/font/fgas_gefont.cpp @@ -0,0 +1,572 @@ +// 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/fgas/font/fgas_gefont.h" + +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/font/fgas_fontutils.h" + +IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage, + IFX_FontMgr* pFontMgr) { +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (NULL != pFontMgr) { + return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); + } + return NULL; +#else + CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); + if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) { + pFont->Release(); + return NULL; + } + return pFont; +#endif +} +IFX_Font* IFX_Font::LoadFont(const uint8_t* pBuffer, + int32_t iLength, + IFX_FontMgr* pFontMgr) { +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (NULL != pFontMgr) { + return pFontMgr->LoadFont(pBuffer, iLength, 0, NULL); + } + return NULL; +#else + CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); + if (!pFont->LoadFont(pBuffer, iLength)) { + pFont->Release(); + return NULL; + } + return pFont; +#endif +} +IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFileName, + IFX_FontMgr* pFontMgr) { +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (NULL != pFontMgr) { + return pFontMgr->LoadFont(pszFileName, 0, NULL); + } + return NULL; +#else + CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); + if (!pFont->LoadFont(pszFileName)) { + pFont->Release(); + return NULL; + } + return pFont; +#endif +} +IFX_Font* IFX_Font::LoadFont(IFX_Stream* pFontStream, + IFX_FontMgr* pFontMgr, + FX_BOOL bSaveStream) { +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (NULL != pFontMgr) { + return pFontMgr->LoadFont(pFontStream, 0, NULL); + } + return NULL; +#else + CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); + if (!pFont->LoadFont(pFontStream, bSaveStream)) { + pFont->Release(); + return NULL; + } + return pFont; +#endif +} +IFX_Font* IFX_Font::LoadFont(CFX_Font* pExtFont, + IFX_FontMgr* pFontMgr, + FX_BOOL bTakeOver) { + CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); + if (!pFont->LoadFont(pExtFont, bTakeOver)) { + pFont->Release(); + return NULL; + } + return pFont; +} +CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr) + : +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + m_bUseLogFontStyle(FALSE), + m_dwLogFontStyle(0), +#endif + m_pFont(NULL), + m_pFontMgr(pFontMgr), + m_iRefCount(1), + m_bExtFont(FALSE), + m_pStream(NULL), + m_pFileRead(NULL), + m_pFontEncoding(NULL), + m_pCharWidthMap(NULL), + m_pRectArray(NULL), + m_pBBoxMap(NULL), + m_pProvider(NULL), + m_wCharSet(0xFFFF), + m_SubstFonts(), + m_FontMapper(16) { +} + +CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles) + : +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + m_bUseLogFontStyle(FALSE), + m_dwLogFontStyle(0), +#endif + m_pFont(NULL), + m_pFontMgr(src.m_pFontMgr), + m_iRefCount(1), + m_bExtFont(FALSE), + m_pStream(NULL), + m_pFileRead(NULL), + m_pFontEncoding(NULL), + m_pCharWidthMap(NULL), + m_pRectArray(NULL), + 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); + m_pFont->LoadClone(src.m_pFont); + CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); + if (!pSubst) { + pSubst = new CFX_SubstFont; + m_pFont->SetSubstFont(pSubst); + } + pSubst->m_Weight = + (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; + if (dwFontStyles & FX_FONTSTYLE_Italic) { + pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; + } + 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(); + } + m_SubstFonts.RemoveAll(); + m_FontMapper.RemoveAll(); + if (m_pFileRead != NULL) { + m_pFileRead->Release(); + } + if (m_pStream != NULL) { + 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_pFont; + } +} +void CFX_GEFont::Release() { + if (--m_iRefCount < 1) { + if (m_pFontMgr != NULL) { + m_pFontMgr->RemoveFont(this); + } + delete this; + } +} +IFX_Font* CFX_GEFont::Retain() { + ++m_iRefCount; + return this; +} +FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + if (m_pFont) { + return FALSE; + } + CFX_ByteString csFontFamily; + if (pszFontFamily != NULL) { + csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); + } + FX_DWORD dwFlags = 0; + if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { + dwFlags |= FXFONT_FIXED_PITCH; + } + if (dwFontStyles & FX_FONTSTYLE_Serif) { + dwFlags |= FXFONT_SERIF; + } + if (dwFontStyles & FX_FONTSTYLE_Symbolic) { + dwFlags |= FXFONT_SYMBOLIC; + } + if (dwFontStyles & FX_FONTSTYLE_Script) { + dwFlags |= FXFONT_SCRIPT; + } + if (dwFontStyles & FX_FONTSTYLE_Italic) { + dwFlags |= FXFONT_ITALIC; + } + if (dwFontStyles & FX_FONTSTYLE_Bold) { + dwFlags |= FXFONT_BOLD; + } + if (dwFontStyles & FX_FONTSTYLE_ExactMatch) { + dwFlags |= FXFONT_EXACTMATCH; + } + int32_t iWeight = + (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; + FX_WORD wCharSet = FX_GetCharsetFromCodePage(wCodePage); + if (wCharSet == 0xFFFF) { + wCharSet = FXSYS_GetACP(); + } + m_wCharSet = wCharSet; + m_pFont = new CFX_Font; + if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { + csFontFamily += ",BoldItalic"; + } else if (dwFlags & FXFONT_BOLD) { + csFontFamily += ",Bold"; + } else if (dwFlags & FXFONT_ITALIC) { + csFontFamily += ",Italic"; + } + m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage); + FX_BOOL bRet = m_pFont->GetFace() != nullptr; + if (bRet) { + bRet = InitFont(); + } + return bRet; +} +FX_BOOL CFX_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) { + if (m_pFont) { + return FALSE; + } + m_pFont = new CFX_Font; + FX_BOOL bRet = m_pFont->LoadEmbedded(pBuffer, length); + if (bRet) { + bRet = InitFont(); + } + m_wCharSet = 0xFFFF; + return bRet; +} +FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFileName) { + if (m_pFont || m_pStream || m_pFileRead) { + return FALSE; + } + m_pStream = IFX_Stream::CreateStream( + pszFileName, FX_STREAMACCESS_Binary | FX_STREAMACCESS_Read); + m_pFileRead = FX_CreateFileRead(m_pStream); + FX_BOOL bRet = FALSE; + if (m_pStream && m_pFileRead) { + m_pFont = new CFX_Font; + bRet = m_pFont->LoadFile(m_pFileRead); + if (bRet) { + bRet = InitFont(); + } else { + m_pFileRead->Release(); + m_pFileRead = nullptr; + } + } + m_wCharSet = 0xFFFF; + return bRet; +} +FX_BOOL CFX_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) { + if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) { + return FALSE; + } + if (bSaveStream) { + m_pStream = pFontStream; + } + m_pFileRead = FX_CreateFileRead(pFontStream); + m_pFont = new CFX_Font; + FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead); + if (bRet) { + bRet = InitFont(); + } else { + m_pFileRead->Release(); + m_pFileRead = nullptr; + } + m_wCharSet = 0xFFFF; + return bRet; +} +FX_BOOL CFX_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) { + if (m_pFont || !pExtFont) { + return FALSE; + } + m_pFont = pExtFont; + FX_BOOL bRet = !!m_pFont; + if (bRet) { + m_bExtFont = !bTakeOver; + bRet = InitFont(); + } else { + m_bExtFont = TRUE; + } + m_wCharSet = 0xFFFF; + return bRet; +} +FX_BOOL CFX_GEFont::InitFont() { + if (!m_pFont) { + return FALSE; + } + if (!m_pFontEncoding) { + m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont); + if (!m_pFontEncoding) { + return FALSE; + } + } + if (!m_pCharWidthMap) { + m_pCharWidthMap = new CFX_WordDiscreteArray(1024); + } + if (!m_pRectArray) { + m_pRectArray = new CFX_RectMassArray(16); + } + if (!m_pBBoxMap) { + m_pBBoxMap = new CFX_MapPtrToPtr(16); + } + return TRUE; +} +IFX_Font* CFX_GEFont::Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage) { + if (GetFontStyles() == dwFontStyles) { + return Retain(); + } + return new CFX_GEFont(*this, dwFontStyles); +} +uint8_t CFX_GEFont::GetCharSet() const { + if (m_wCharSet != 0xFFFF) { + return (uint8_t)m_wCharSet; + } + if (!m_pFont->GetSubstFont()) { + return FX_CHARSET_Default; + } + return m_pFont->GetSubstFont()->m_Charset; +} +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()); + } else { + wsFamily = CFX_WideString::FromLocal(m_pFont->GetSubstFont()->m_Family); + } +} +void CFX_GEFont::GetPsName(CFX_WideString& wsName) const { + wsName = m_pFont->GetPsName(); +} +FX_DWORD CFX_GEFont::GetFontStyles() const { + FXSYS_assert(m_pFont != NULL); +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (m_bUseLogFontStyle) { + return m_dwLogFontStyle; + } +#endif + FX_DWORD dwStyles = 0; + if (!m_pFont->GetSubstFont()) { + if (m_pFont->IsBold()) { + dwStyles |= FX_FONTSTYLE_Bold; + } + if (m_pFont->IsItalic()) { + dwStyles |= FX_FONTSTYLE_Italic; + } + } else { + if (m_pFont->GetSubstFont()->m_Weight == FXFONT_FW_BOLD) { + dwStyles |= FX_FONTSTYLE_Bold; + } + if (m_pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_ITALIC) { + dwStyles |= FX_FONTSTYLE_Italic; + } + } + return dwStyles; +} +FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode) { + return GetCharWidth(wUnicode, iWidth, TRUE, bCharCode); +} +FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bRecursive, + FX_BOOL bCharCode) { + FXSYS_assert(m_pCharWidthMap != NULL); + iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); + if (iWidth < 1) { + if (!m_pProvider || + !m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) { + IFX_Font* pFont = NULL; + int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); + if (iGlyph != 0xFFFF && pFont != NULL) { + if (pFont == (IFX_Font*)this) { + iWidth = m_pFont->GetGlyphWidth(iGlyph); + if (iWidth < 0) { + iWidth = -1; + } + } else if (((CFX_GEFont*)pFont) + ->GetCharWidth(wUnicode, iWidth, FALSE, bCharCode)) { + return TRUE; + } + } else { + iWidth = -1; + } + } + m_pCharWidthMap->SetAtGrow(wUnicode, (int16_t)iWidth); + } else if (iWidth == 65535) { + iWidth = -1; + } + return iWidth > 0; +} +FX_BOOL CFX_GEFont::GetCharBBox(FX_WCHAR wUnicode, + CFX_Rect& bbox, + FX_BOOL bCharCode) { + return GetCharBBox(wUnicode, bbox, TRUE, bCharCode); +} +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); + void* pRect = NULL; + if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { + IFX_Font* pFont = NULL; + int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); + if (iGlyph != 0xFFFF && pFont != NULL) { + if (pFont == (IFX_Font*)this) { + FX_RECT rtBBox; + if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { + CFX_Rect rt; + rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); + int32_t index = m_pRectArray->Add(rt); + pRect = m_pRectArray->GetPtrAt(index); + m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); + } + } else if (((CFX_GEFont*)pFont) + ->GetCharBBox(wUnicode, bbox, FALSE, bCharCode)) { + return TRUE; + } + } + } + if (!pRect) + return FALSE; + + bbox = *static_cast<const CFX_Rect*>(pRect); + return TRUE; +} +FX_BOOL CFX_GEFont::GetBBox(CFX_Rect& bbox) { + FX_RECT rt(0, 0, 0, 0); + FX_BOOL bRet = m_pFont->GetBBox(rt); + if (bRet) { + bbox.left = rt.left; + bbox.width = rt.Width(); + bbox.top = rt.bottom; + bbox.height = -rt.Height(); + } + return bRet; +} +int32_t CFX_GEFont::GetItalicAngle() const { + if (!m_pFont->GetSubstFont()) { + return 0; + } + return m_pFont->GetSubstFont()->m_ItalicAngle; +} +int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { + return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode); +} +int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, + FX_BOOL bRecursive, + IFX_Font** ppFont, + FX_BOOL bCharCode) { + FXSYS_assert(m_pFontEncoding != NULL); + int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); + if (iGlyphIndex > 0) { + if (ppFont != NULL) { + *ppFont = (IFX_Font*)this; + } + return iGlyphIndex; + } + const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); + if (pFontUSB == NULL) { + return 0xFFFF; + } + FX_WORD wBitField = pFontUSB->wBitField; + if (wBitField >= 128) { + return 0xFFFF; + } + IFX_Font* pFont = NULL; + m_FontMapper.Lookup((void*)(uintptr_t)wUnicode, (void*&)pFont); + if (pFont != NULL && pFont != (IFX_Font*)this) { + iGlyphIndex = + ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); + if (iGlyphIndex != 0xFFFF) { + int32_t i = m_SubstFonts.Find(pFont); + if (i > -1) { + iGlyphIndex |= ((i + 1) << 24); + if (ppFont != NULL) { + *ppFont = pFont; + } + return iGlyphIndex; + } + } + } + if (m_pFontMgr != NULL && bRecursive) { + CFX_WideString wsFamily; + GetFamilyName(wsFamily); +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + IFX_Font* pFont = m_pFontMgr->GetDefFontByUnicode( + wUnicode, GetFontStyles(), (const FX_WCHAR*)wsFamily); +#else + IFX_Font* pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), + (const FX_WCHAR*)wsFamily); + if (NULL == pFont) { + pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL); + } +#endif + if (pFont != NULL) { + if (pFont == (IFX_Font*)this) { + pFont->Release(); + return 0xFFFF; + } + m_FontMapper.SetAt((void*)(uintptr_t)wUnicode, (void*)pFont); + int32_t i = m_SubstFonts.GetSize(); + m_SubstFonts.Add(pFont); + iGlyphIndex = + ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); + if (iGlyphIndex != 0xFFFF) { + iGlyphIndex |= ((i + 1) << 24); + if (ppFont != NULL) { + *ppFont = pFont; + } + return iGlyphIndex; + } + } + } + return 0xFFFF; +} +int32_t CFX_GEFont::GetAscent() const { + return m_pFont->GetAscent(); +} +int32_t CFX_GEFont::GetDescent() const { + return m_pFont->GetDescent(); +} +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]; + ((CFX_GEFont*)pFont)->Reset(); + } + if (m_pCharWidthMap != NULL) { + m_pCharWidthMap->RemoveAll(); + } + if (m_pBBoxMap != NULL) { + m_pBBoxMap->RemoveAll(); + } + if (m_pRectArray != NULL) { + m_pRectArray->RemoveAll(); + } +} +IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const { + iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24; + return iGlyphIndex == 0 ? (IFX_Font*)this + : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1]; +} diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h new file mode 100644 index 0000000000..034220ef64 --- /dev/null +++ b/xfa/fgas/font/fgas_gefont.h @@ -0,0 +1,92 @@ +// 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_FONT_FGAS_GEFONT_H_ +#define XFA_FGAS_FONT_FGAS_GEFONT_H_ + +#include "xfa/fgas/crt/fgas_utils.h" +#include "xfa/fgas/font/fgas_font.h" + +#define FXFONT_SUBST_ITALIC 0x02 + +class CFX_GEFont : public IFX_Font { + public: + CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles); + CFX_GEFont(IFX_FontMgr* pFontMgr); + ~CFX_GEFont(); + virtual void Release(); + virtual IFX_Font* Retain(); + FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage); + FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length); + FX_BOOL LoadFont(const FX_WCHAR* pszFileName); + FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream); + FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE); + virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0); + virtual void GetFamilyName(CFX_WideString& wsFamily) const; + virtual void GetPsName(CFX_WideString& wsName) const; + virtual FX_DWORD GetFontStyles() const; + virtual uint8_t GetCharSet() const; + virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode = FALSE); + virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE); + virtual int32_t GetAscent() const; + virtual int32_t GetDescent() const; + virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, + CFX_Rect& bbox, + FX_BOOL bCharCode = FALSE); + virtual FX_BOOL GetBBox(CFX_Rect& bbox); + virtual int32_t GetItalicAngle() const; + 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) { + m_pProvider = pProvider; + } +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) { + m_bUseLogFontStyle = TRUE; + m_dwLogFontStyle = dwLogFontStyle; + } +#endif + + protected: +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + FX_BOOL m_bUseLogFontStyle; + FX_DWORD m_dwLogFontStyle; +#endif + CFX_Font* m_pFont; + IFX_FontMgr* m_pFontMgr; + int32_t m_iRefCount; + FX_BOOL m_bExtFont; + IFX_Stream* m_pStream; + IFX_FileRead* m_pFileRead; + CFX_UnicodeEncoding* m_pFontEncoding; + CFX_WordDiscreteArray* m_pCharWidthMap; + CFX_RectMassArray* m_pRectArray; + CFX_MapPtrToPtr* m_pBBoxMap; + IFX_FontProvider* m_pProvider; + FX_WORD m_wCharSet; + CFX_PtrArray m_SubstFonts; + CFX_MapPtrToPtr m_FontMapper; + FX_BOOL InitFont(); + FX_BOOL GetCharBBox(FX_WCHAR wUnicode, + CFX_Rect& bbox, + FX_BOOL bRecursive, + FX_BOOL bCharCode = FALSE); + FX_BOOL GetCharWidth(FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bRecursive, + FX_BOOL bCharCode = FALSE); + int32_t GetGlyphIndex(FX_WCHAR wUnicode, + FX_BOOL bRecursive, + IFX_Font** ppFont, + FX_BOOL bCharCode = FALSE); +}; + +#endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp new file mode 100644 index 0000000000..ffe520dc87 --- /dev/null +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -0,0 +1,1515 @@ +// 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/fgas/font/fgas_stdfontmgr.h" + +#include "core/include/fxcrt/fx_stream.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#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), + 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) { + if (m_pEnumerator != NULL) { + m_pEnumerator(m_FontFaces, m_pUserData, NULL, 0xFEFF); + } + if (m_pMatcher == NULL) { + m_pMatcher = FX_DefFontMatcher; + } + FXSYS_assert(m_pMatcher != NULL); +} +CFX_StdFontMgrImp::~CFX_StdFontMgrImp() { + m_FontFaces.RemoveAll(); + m_CPFonts.RemoveAll(); + m_FamilyFonts.RemoveAll(); + m_UnicodeFonts.RemoveAll(); + m_BufferFonts.RemoveAll(); + 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(); +} +IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage( + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + FX_DWORD dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); + IFX_Font* pFont = NULL; + if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; + } + FX_LPCFONTDESCRIPTOR 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); + pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); + if (pFont != NULL) { + m_Fonts.Add(pFont); + m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + return LoadFont(pFont, dwFontStyles, wCodePage); + } + return NULL; +} +IFX_Font* CFX_StdFontMgrImp::GetDefFontByCharset( + uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, + pszFontFamily); +} + +IFX_Font* CFX_StdFontMgrImp::GetDefFontByUnicode( + FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + const FGAS_FONTUSB* pRet = FGAS_GetUnicodeBitField(wUnicode); + if (pRet->wBitField == 999) + return nullptr; + + FX_DWORD dwHash = + FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); + IFX_Font* pFont = nullptr; + if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) + return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr; + + FX_LPCFONTDESCRIPTOR pFD = + FindFont(pszFontFamily, dwFontStyles, FALSE, pRet->wCodePage, + pRet->wBitField, wUnicode); + if (!pFD && pszFontFamily) { + pFD = FindFont(nullptr, dwFontStyles, FALSE, pRet->wCodePage, + pRet->wBitField, wUnicode); + } + if (!pFD) + return nullptr; + + FX_WORD wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); + const FX_WCHAR* pFontFace = pFD->wsFontFace; + pFont = IFX_Font::LoadFont(pFontFace, dwFontStyles, wCodePage, this); + if (pFont) { + m_Fonts.Add(pFont); + m_UnicodeFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); + m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + dwHash = FGAS_GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + return LoadFont(pFont, dwFontStyles, wCodePage); + } + return nullptr; +} + +IFX_Font* CFX_StdFontMgrImp::GetDefFontByLanguage( + FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), + dwFontStyles, pszFontFamily); +} +IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + FX_DWORD dwHash = + FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); + IFX_Font* pFont = NULL; + if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; + } + FX_LPCFONTDESCRIPTOR pFD = NULL; + if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { + if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == + NULL) { + return NULL; + } + } + FXSYS_assert(pFD != NULL); + if (wCodePage == 0xFFFF) { + wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); + } + pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); + if (pFont != NULL) { + m_Fonts.Add(pFont); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); + m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + return LoadFont(pFont, dwFontStyles, wCodePage); + } + return NULL; +} +IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { + FXSYS_assert(pBuffer != NULL && iLength > 0); + IFX_Font* pFont = NULL; + if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { + if (pFont != NULL) { + return pFont->Retain(); + } + } + pFont = IFX_Font::LoadFont(pBuffer, iLength, this); + if (pFont != NULL) { + m_Fonts.Add(pFont); + m_BufferFonts.SetAt((void*)pBuffer, pFont); + return pFont->Retain(); + } + return NULL; +} +IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { + FXSYS_assert(pszFileName != NULL); + FX_DWORD dwHash = FX_HashCode_String_GetW(pszFileName, -1); + IFX_Font* pFont = NULL; + if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { + if (pFont != NULL) { + return pFont->Retain(); + } + } + pFont = IFX_Font::LoadFont(pszFileName, NULL); + if (pFont != NULL) { + m_Fonts.Add(pFont); + m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + return pFont->Retain(); + } + return NULL; +} +IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, + const FX_WCHAR* pszFontAlias, + FX_DWORD dwFontStyles, + FX_WORD wCodePage, + FX_BOOL bSaveStream) { + FXSYS_assert(pFontStream != NULL && pFontStream->GetLength() > 0); + IFX_Font* pFont = NULL; + if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { + if (pFont != NULL) { + if (pszFontAlias != NULL) { + FX_DWORD dwHash = + FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + } + return LoadFont(pFont, dwFontStyles, wCodePage); + } + } + pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream); + if (pFont != NULL) { + m_Fonts.Add(pFont); + m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); + if (pszFontAlias != NULL) { + FX_DWORD dwHash = + FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + } + return LoadFont(pFont, dwFontStyles, wCodePage); + } + return NULL; +} +IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + FXSYS_assert(pSrcFont != NULL); + if (pSrcFont->GetFontStyles() == dwFontStyles) { + return pSrcFont->Retain(); + } + void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, + (void*)(uintptr_t)wCodePage}; + FX_DWORD dwHash = + FX_HashCode_String_GetA((const FX_CHAR*)buffer, 3 * sizeof(void*)); + IFX_Font* pFont = NULL; + if (m_DeriveFonts.GetCount() > 0) { + m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); + if (pFont != NULL) { + return pFont->Retain(); + } + } + pFont = pSrcFont->Derive(dwFontStyles, wCodePage); + if (pFont != NULL) { + m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + int32_t index = m_Fonts.Find(pFont); + if (index < 0) { + m_Fonts.Add(pFont); + pFont->Retain(); + } + return pFont; + } + 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(); + } + } +} +void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) { + FX_POSITION pos = fontMap.GetStartPosition(); + void* pKey; + void* pFind; + while (pos != NULL) { + pFind = NULL; + fontMap.GetNextAssoc(pos, pKey, pFind); + if (pFind != (void*)pFont) { + continue; + } + fontMap.RemoveKey(pKey); + break; + } +} +void CFX_StdFontMgrImp::RemoveFont(IFX_Font* pFont) { + RemoveFont(m_CPFonts, pFont); + RemoveFont(m_FamilyFonts, pFont); + RemoveFont(m_UnicodeFonts, pFont); + RemoveFont(m_BufferFonts, pFont); + RemoveFont(m_FileFonts, pFont); + RemoveFont(m_StreamFonts, pFont); + RemoveFont(m_DeriveFonts, pFont); + int32_t iFind = m_Fonts.Find(pFont); + if (iFind > -1) { + m_Fonts.RemoveAt(iFind, 1); + } +} +FX_LPCFONTDESCRIPTOR CFX_StdFontMgrImp::FindFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_DWORD dwMatchFlags, + FX_WORD wCodePage, + FX_DWORD dwUSB, + FX_WCHAR wUnicode) { + if (m_pMatcher == NULL) { + return NULL; + } + FX_FONTMATCHPARAMS params; + FXSYS_memset(¶ms, 0, sizeof(params)); + params.dwUSB = dwUSB; + params.wUnicode = wUnicode; + params.wCodePage = wCodePage; + params.pwsFamily = pszFontFamily; + params.dwFontStyles = dwFontStyles; + params.dwMatchFlags = dwMatchFlags; + FX_LPCFONTDESCRIPTOR pDesc = m_pMatcher(¶ms, m_FontFaces, m_pUserData); + if (pDesc) { + return pDesc; + } + if (pszFontFamily && m_pEnumerator) { + CFX_FontDescriptors namedFonts; + m_pEnumerator(namedFonts, m_pUserData, pszFontFamily, wUnicode); + params.pwsFamily = NULL; + pDesc = m_pMatcher(¶ms, namedFonts, m_pUserData); + if (pDesc == NULL) { + return NULL; + } + for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { + FX_LPCFONTDESCRIPTOR pMatch = m_FontFaces.GetPtrAt(i); + if (*pMatch == *pDesc) { + return pMatch; + } + } + int index = m_FontFaces.Add(*pDesc); + return m_FontFaces.GetPtrAt(index); + } + return NULL; +} +FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, + const CFX_FontDescriptors& fonts, + void* pUserData) { + FX_LPCFONTDESCRIPTOR 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); + if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == + FX_FONTSTYLE_BoldItalic) { + continue; + } + if (pParams->pwsFamily) { + if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) { + continue; + } + if (pFont->uCharSet == FX_CHARSET_Symbol) { + return pFont; + } + } + if (pFont->uCharSet == FX_CHARSET_Symbol) { + continue; + } + if (pParams->wCodePage != 0xFFFF) { + if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage) { + continue; + } + } else { + if (pParams->dwUSB < 128) { + FX_DWORD dwByte = pParams->dwUSB / 32; + FX_DWORD dwUSB = 1 << (pParams->dwUSB % 32); + if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) { + continue; + } + } + } + if (bMatchStyle) { + if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) { + return pFont; + } else { + continue; + } + } + if (pParams->pwsFamily != NULL) { + if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { + return pFont; + } + } + int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); + if (iBestSimilar < iSimilarValue) { + iBestSimilar = iSimilarValue; + pBestFont = pFont; + } + } + return iBestSimilar < 1 ? NULL : pBestFont; +} +int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, FX_DWORD dwFontStyles) { + int32_t iValue = 0; + if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == + (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { + iValue += 64; + } + if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == + (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { + iValue += 32; + } + if ((dwFontStyles & FX_FONTSTYLE_Serif) == + (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) { + iValue += 16; + } + if ((dwFontStyles & FX_FONTSTYLE_Script) == + (pFont->dwFontStyles & FX_FONTSTYLE_Script)) { + iValue += 8; + } + return iValue; +} +FX_LPMatchFont FX_GetDefFontMatchor() { + return FX_DefFontMatcher; +} +FX_DWORD FX_GetGdiFontStyles(const LOGFONTW& lf) { + FX_DWORD dwStyles = 0; + if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH) { + dwStyles |= FX_FONTSTYLE_FixedPitch; + } + uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0; + if (nFamilies == FF_ROMAN) { + dwStyles |= FX_FONTSTYLE_Serif; + } + if (nFamilies == FF_SCRIPT) { + dwStyles |= FX_FONTSTYLE_Script; + } + if (lf.lfCharSet == SYMBOL_CHARSET) { + dwStyles |= FX_FONTSTYLE_Symbolic; + } + return dwStyles; +} +static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, + NEWTEXTMETRICEX* lpntme, + DWORD dwFontType, + LPARAM lParam) { + if (dwFontType != TRUETYPE_FONTTYPE) { + return 1; + } + const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont; + if (lf.lfFaceName[0] == L'@') { + return 1; + } + FX_LPFONTDESCRIPTOR pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); + FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); + pFont->uCharSet = lf.lfCharSet; + pFont->dwFontStyles = FX_GetGdiFontStyles(lf); + FXSYS_wcsncpy(pFont->wsFontFace, (const FX_WCHAR*)lf.lfFaceName, 31); + pFont->wsFontFace[31] = 0; + FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, + sizeof(lpntme->ntmFontSig)); + ((CFX_FontDescriptors*)lParam)->Add(*pFont); + FX_Free(pFont); + return 1; +} +static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, + void* pUserData, + const FX_WCHAR* pwsFaceName, + FX_WCHAR wUnicode) { + HDC hDC = ::GetDC(NULL); + LOGFONTW lfFind; + FXSYS_memset(&lfFind, 0, sizeof(lfFind)); + lfFind.lfCharSet = DEFAULT_CHARSET; + if (pwsFaceName) { + FXSYS_wcsncpy((FX_WCHAR*)lfFind.lfFaceName, pwsFaceName, 31); + lfFind.lfFaceName[31] = 0; + } + EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, + (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); + ::ReleaseDC(NULL, hDC); +} +FX_LPEnumAllFonts FX_GetDefFontEnumerator() { + return FX_EnumGdiFonts; +} +#else +const FX_CHAR* g_FontFolders[] = { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ + "/usr/share/fonts", "/usr/share/X11/fonts/Type1", + "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ + "/system/fonts", +#endif +}; + +CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { + for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) + m_FolderPaths.Add(g_FontFolders[i]); +} + +CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { +Restart: + void* pCurHandle = + m_FolderQueue.GetSize() == 0 + ? NULL + : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; + if (NULL == pCurHandle) { + if (m_FolderPaths.GetSize() < 1) { + return ""; + } + pCurHandle = FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1]); + FX_HandleParentPath hpp; + hpp.pFileHandle = pCurHandle; + hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; + m_FolderQueue.Add(hpp); + } + CFX_ByteString bsName; + FX_BOOL bFolder; + CFX_ByteString bsFolderSpearator = + CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); + while (TRUE) { + if (!FX_GetNextFile(pCurHandle, bsName, bFolder)) { + FX_CloseFolder(pCurHandle); + m_FolderQueue.RemoveAt(m_FolderQueue.GetSize() - 1); + if (m_FolderQueue.GetSize() == 0) { + m_FolderPaths.RemoveAt(m_FolderPaths.GetSize() - 1); + if (m_FolderPaths.GetSize() == 0) { + return ""; + } else { + goto Restart; + } + } + pCurHandle = + m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; + continue; + } + if (bsName == "." || bsName == "..") { + continue; + } + if (bFolder) { + FX_HandleParentPath hpp; + hpp.bsParentPath = + m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + + bsFolderSpearator + bsName; + hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath); + if (hpp.pFileHandle == NULL) { + continue; + } + m_FolderQueue.Add(hpp); + pCurHandle = hpp.pFileHandle; + continue; + } + bsName = + m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + + bsFolderSpearator + bsName; + break; + } + return bsName; +} +FX_POSITION CFX_FontSourceEnum_File::GetStartPosition(void* pUserData) { + 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); + 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()) { + return pFontMgr; + } + delete pFontMgr; + return NULL; +} +CFX_FontMgrImp::CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum, + IFX_FontMgrDelegate* pDelegate, + void* pUserData) + : m_pFontSource(pFontEnum), + m_pDelegate(pDelegate), + m_pUserData(pUserData) {} + +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); + pFontStream->Release(); + } + 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(); + IFX_FileAccess* pFontSource = nullptr; + IFX_FileRead* pFontStream = nullptr; + while (pos) { + pFontSource = m_pFontSource->GetNext(pos); + pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); + if (!pFontStream) { + pFontSource->Release(); + continue; + } + RegisterFaces(pFontStream, nullptr); + pFontStream->Release(); + pFontSource->Release(); + } + if (m_InstalledFonts.GetSize() == 0) + return FALSE; + return TRUE; +} +FX_BOOL CFX_FontMgrImp::EnumFonts() { + if (EnumFontsFromFontMapper()) + return TRUE; + return EnumFontsFromFiles(); +} +void CFX_FontMgrImp::Release() { + for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) { + delete m_InstalledFonts[i]; + } + FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + CFX_FontDescriptorInfos* pDescs; + m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); + if (NULL != pDescs) { + delete pDescs; + } + } + pos = m_Hash2Fonts.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + CFX_ArrayTemplate<IFX_Font*>* pFonts; + m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); + if (NULL != pFonts) { + delete pFonts; + } + } + m_Hash2Fonts.RemoveAll(); + pos = m_Hash2FileAccess.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + IFX_FileAccess* pFileAccess; + m_Hash2FileAccess.GetNextAssoc(pos, dwHash, pFileAccess); + if (NULL != pFileAccess) { + pFileAccess->Release(); + } + } + pos = m_FileAccess2IFXFont.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + IFX_Font* pFont; + m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); + if (NULL != pFont) { + pFont->Release(); + } + } + pos = m_IFXFont2FileRead.GetStartPosition(); + while (pos) { + IFX_Font* pFont; + IFX_FileRead* pFileRead; + m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); + pFileRead->Release(); + } + delete this; +} +IFX_Font* CFX_FontMgrImp::GetDefFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByCodePage( + this, wCodePage, dwFontStyles, + pszFontFamily); +} +IFX_Font* CFX_FontMgrImp::GetDefFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return NULL == m_pDelegate ? NULL + : m_pDelegate->GetDefFontByCharset( + this, nCharset, dwFontStyles, pszFontFamily); +} +IFX_Font* CFX_FontMgrImp::GetDefFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return NULL == m_pDelegate ? NULL + : m_pDelegate->GetDefFontByUnicode( + this, wUnicode, dwFontStyles, pszFontFamily); +} +IFX_Font* CFX_FontMgrImp::GetDefFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByLanguage( + this, wLanguage, dwFontStyles, + pszFontFamily); +} +IFX_Font* CFX_FontMgrImp::GetFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + CFX_ByteString bsHash; + bsHash.Format("%d, %d", wCodePage, dwFontStyles); + bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); + FX_DWORD dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); + CFX_ArrayTemplate<IFX_Font*>* pFonts = NULL; + IFX_Font* pFont = NULL; + if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { + if (NULL == pFonts) { + return NULL; + } + if (0 != pFonts->GetSize()) { + return pFonts->GetAt(0)->Retain(); + } + } + if (!pFonts) + pFonts = new CFX_ArrayTemplate<IFX_Font*>; + m_Hash2Fonts.SetAt(dwHash, pFonts); + CFX_FontDescriptorInfos* sortedFonts = NULL; + 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; + } + 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) { + pFont->SetLogicalFontStyle(dwFontStyles); + } + pFonts->Add(pFont); + return pFont; +} +IFX_Font* CFX_FontMgrImp::GetFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, + pszFontFamily); +} +IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily) { + IFX_Font* pFont = nullptr; + if (m_FailedUnicodes2NULL.Lookup(wUnicode, pFont)) + return nullptr; + const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); + FX_WORD wCodePage = x ? x->wCodePage : 0xFFFF; + FX_WORD wBitField = x ? x->wBitField : 0x03E7; + CFX_ByteString bsHash; + if (wCodePage == 0xFFFF) + bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); + else + bsHash.Format("%d, %d", wCodePage, dwFontStyles); + bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); + FX_DWORD dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); + CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr; + if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { + if (!pFonts) + return nullptr; + for (int32_t i = 0; i < pFonts->GetSize(); ++i) { + if (VerifyUnicode(pFonts->GetAt(i), wUnicode)) + return pFonts->GetAt(i)->Retain(); + } + } + if (!pFonts) + pFonts = new CFX_ArrayTemplate<IFX_Font*>; + m_Hash2Fonts.SetAt(dwHash, pFonts); + CFX_FontDescriptorInfos* sortedFonts = nullptr; + if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { + sortedFonts = new CFX_FontDescriptorInfos; + MatchFonts(*sortedFonts, wCodePage, dwFontStyles, + CFX_WideString(pszFontFamily), wUnicode); + m_Hash2CandidateList.SetAt(dwHash, sortedFonts); + } + for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) { + CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont; + if (!VerifyUnicode(pDesc, wUnicode)) + continue; + if (pDesc->m_pFileAccess) + pFont = LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr); + else + pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); + if (!pFont) + continue; + pFont->SetLogicalFontStyle(dwFontStyles); + pFonts->Add(pFont); + return pFont; + } + if (!pszFontFamily) + m_FailedUnicodes2NULL.SetAt(wUnicode, nullptr); + return nullptr; +} +FX_BOOL CFX_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, + FX_WCHAR wcUnicode) { + IFX_FileRead* pFileRead = nullptr; + if (pDesc->m_pFileAccess) + pFileRead = pDesc->m_pFileAccess->CreateFileStream(FX_FILEMODE_ReadOnly); + else + pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); + if (!pFileRead) + return FALSE; + FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); + FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); + FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); + pFileRead->Release(); + if (!pFace) + return FALSE; + if (FXFT_Get_Face_External_Stream(pFace)) + FXFT_Clear_Face_External_Stream(pFace); + FXFT_Done_Face(pFace); + return !retCharmap && retIndex; +} +FX_BOOL CFX_FontMgrImp::VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode) { + if (NULL == 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)) { + return FALSE; + } + if (0 == FXFT_Get_Char_Index(pFace, wcUnicode)) { + FXFT_Set_Charmap(pFace, charmap); + return FALSE; + } + return TRUE; +} +IFX_Font* CFX_FontMgrImp::GetFontByLanguage(FX_WORD wLanguage, + FX_DWORD 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}; + FX_DWORD 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; + } +} +IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName, + int32_t iFaceIndex, + int32_t* pFaceCount) { + CFX_ByteString bsHash; + bsHash += CFX_WideString(pszFileName).UTF8Encode(); + FX_DWORD dwHash = + FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength()); + IFX_FileAccess* pFontAccess = NULL; + 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; + } +} +IFX_Font* CFX_FontMgrImp::LoadFont(IFX_Stream* pFontStream, + int32_t iFaceIndex, + int32_t* pFaceCount, + FX_BOOL bSaveStream) { + void* Hash[1] = {(void*)(uintptr_t)pFontStream}; + FX_DWORD 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; + } +} +IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, + int32_t iFaceIndex, + int32_t* pFaceCount, + FX_BOOL bWantCache) { + FX_DWORD dwHash = 0; + IFX_Font* pFont = NULL; + if (bWantCache) { + CFX_ByteString bsHash; + bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); + dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); + if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { + if (NULL != pFont) { + if (NULL != 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) { + delete pInternalFont; + return NULL; + } + if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { + delete pInternalFont; + pFontStream->Release(); + return NULL; + } + pFont = IFX_Font::LoadFont(pInternalFont, this, TRUE); + if (NULL == pFont) { + delete pInternalFont; + pFontStream->Release(); + return NULL; + } + if (bWantCache) { + m_FileAccess2IFXFont.SetAt(dwHash, pFont); + } + m_IFXFont2FileRead.SetAt(pFont, pFontStream); + if (NULL != 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) { + 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; + 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) { + return 0; + } + IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; + int res = pFile->ReadBlock(buffer, offset, count); + if (res) { + return count; + } + return 0; +} +void _ftStreamClose(FXFT_Stream stream) {} +}; + +FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, + int32_t iFaceIndex) { + if (!pFontStream) + return nullptr; + + CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); + pFontMgr->InitFTLibrary(); + FXFT_Library library = pFontMgr->GetFTLibrary(); + if (!library) + return nullptr; + + FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); + FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); + ftStream->base = NULL; + ftStream->descriptor.pointer = pFontStream; + ftStream->pos = 0; + ftStream->size = (unsigned long)pFontStream->GetSize(); + ftStream->read = _ftStreamRead; + ftStream->close = _ftStreamClose; + + FXFT_Open_Args ftArgs; + FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); + ftArgs.flags |= FT_OPEN_STREAM; + ftArgs.stream = ftStream; + + FXFT_Face pFace = NULL; + if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { + FX_Free(ftStream); + return nullptr; + } + + FXFT_Set_Pixel_Sizes(pFace, 0, 64); + return pFace; +} + +IFX_FileRead* CFX_FontMgrImp::CreateFontStream( + CFX_FontMapper* pFontMapper, + IFX_SystemFontInfo* pSystemFontInfo, + FX_DWORD index) { + int iExact = 0; + void* hFont = pSystemFontInfo->MapFont( + 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact); + if (!hFont) + return nullptr; + FX_DWORD 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); +} + +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) + return CreateFontStream(pFontMapper, pSystemFontInfo, i); + } + return nullptr; +} +int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const CFX_WideString& FontName, + FX_WCHAR wcUnicode) { + MatchedFonts.RemoveAll(); + CFX_WideString wsNormalizedFontName = FontName; + static const int32_t nMax = 0xffff; + CFX_FontDescriptor* pFont = NULL; + 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) { + continue; + } + FX_FontDescriptorInfo FontInfo; + FontInfo.pFont = pFont; + FontInfo.nPenalty = nPenalty; + MatchedFonts.Add(FontInfo); + if (MatchedFonts.GetSize() == nMax) { + break; + } + } + if (MatchedFonts.GetSize() == 0) { + return 0; + } + CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; + ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); + return MatchedFonts.GetSize(); +} +struct FX_BitCodePage { + FX_WORD wBit; + FX_WORD wCodePage; +}; +static const FX_BitCodePage g_Bit2CodePage[] = { + {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, + {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, + {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, + {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, + {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, + {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0}, + {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0}, + {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0}, + {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862}, + {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775}, + {60, 737}, {61, 708}, {62, 850}, {63, 437}, +}; + +FX_WORD FX_GetCodePageBit(FX_WORD wCodePage) { + for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) { + if (g_Bit2CodePage[i].wCodePage == wCodePage) + return g_Bit2CodePage[i].wBit; + } + return (FX_WORD)-1; +} + +FX_WORD FX_GetUnicodeBit(FX_WCHAR wcUnicode) { + const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode); + return x ? x->wBitField : 999; +} + +int32_t CFX_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const CFX_WideString& FontName, + FX_WCHAR wcUnicode) { + int32_t nPenalty = 30000; + if (0 != FontName.GetLength()) { + if (FontName != pInstalled->m_wsFaceName) { + int32_t i; + for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { + if (pInstalled->m_wsFamilyNames[i] == FontName) { + break; + } + } + if (i == pInstalled->m_wsFamilyNames.GetSize()) { + nPenalty += 0xFFFF; + } else { + nPenalty -= 28000; + } + } else { + nPenalty -= 30000; + } + if (30000 == nPenalty && + 0 == IsPartName(pInstalled->m_wsFaceName, FontName)) { + int32_t i; + for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { + if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) { + break; + } + } + if (i == pInstalled->m_wsFamilyNames.GetSize()) { + nPenalty += 0xFFFF; + } else { + nPenalty -= 26000; + } + } else { + nPenalty -= 27000; + } + } + FX_DWORD dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles; + if (dwStyleMask & FX_FONTSTYLE_Bold) { + nPenalty += 4500; + } + if (dwStyleMask & FX_FONTSTYLE_FixedPitch) { + nPenalty += 10000; + } + if (dwStyleMask & FX_FONTSTYLE_Italic) { + nPenalty += 10000; + } + if (dwStyleMask & FX_FONTSTYLE_Serif) { + nPenalty += 500; + } + if (dwStyleMask & FX_FONTSTYLE_Symbolic) { + nPenalty += 0xFFFF; + } + if (nPenalty >= 0xFFFF) { + return 0xFFFF; + } + FX_WORD wBit = + ((0 == wCodePage || 0xFFFF == wCodePage) ? (FX_WORD)-1 + : FX_GetCodePageBit(wCodePage)); + if (wBit != (FX_WORD)-1) { + FXSYS_assert(wBit < 64); + if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) { + nPenalty += 0xFFFF; + } else { + nPenalty -= 60000; + } + } + wBit = + ((0 == wcUnicode || 0xFFFE == wcUnicode) ? (FX_WORD)999 + : FX_GetUnicodeBit(wcUnicode)); + if (wBit != (FX_WORD)999) { + FXSYS_assert(wBit < 128); + if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) { + nPenalty += 0xFFFF; + } else { + nPenalty -= 60000; + } + } + return nPenalty; +} +void CFX_FontMgrImp::ClearFontCache() { + FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + CFX_FontDescriptorInfos* pDescs; + m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); + if (NULL != pDescs) { + delete pDescs; + } + } + pos = m_FileAccess2IFXFont.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + IFX_Font* pFont; + m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); + if (NULL != pFont) { + pFont->Release(); + } + } + pos = m_IFXFont2FileRead.GetStartPosition(); + while (pos) { + IFX_Font* pFont; + IFX_FileRead* pFileRead; + m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); + pFileRead->Release(); + } +} +void CFX_FontMgrImp::RemoveFont(IFX_Font* pEFont) { + if (NULL == pEFont) { + return; + } + IFX_FileRead* pFileRead; + if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { + pFileRead->Release(); + m_IFXFont2FileRead.RemoveKey(pEFont); + } + FX_POSITION pos; + pos = m_FileAccess2IFXFont.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + IFX_Font* pCFont; + m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pCFont); + if (pCFont == pEFont) { + m_FileAccess2IFXFont.RemoveKey(dwHash); + break; + } + } + pos = m_Hash2Fonts.GetStartPosition(); + while (pos) { + FX_DWORD dwHash; + CFX_ArrayTemplate<IFX_Font*>* pFonts; + m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); + if (NULL != pFonts) { + for (int32_t i = 0; i < pFonts->GetSize(); i++) { + if (pFonts->GetAt(i) == pEFont) { + pFonts->SetAt(i, NULL); + } + } + } else { + m_Hash2Fonts.RemoveKey(dwHash); + } + } +} +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)) { + 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_WordArray Charsets; + GetCharsets(pFace, Charsets); + GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); + unsigned long nLength = 0; + FT_ULong dwTag; + uint8_t* pTable = NULL; + 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) { + pTable = FX_Alloc(uint8_t, nLength); + error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL); + if (0 != error) { + FX_Free(pTable); + pTable = NULL; + } + } + GetNames(pTable, pFont->m_wsFamilyNames); + if (NULL != 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_nFaceIndex = pFace->face_index; + if (pFontAccess) + pFont->m_pFileAccess = pFontAccess->Retain(); + else + pFont->m_pFileAccess = nullptr; + Fonts.Add(pFont); +} +void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream, + const CFX_WideString* pFaceName) { + int32_t index = 0; + int32_t num_faces = 0; + do { + FXFT_Face pFace = LoadFace(pFontStream, index++); + if (!pFace) + continue; + // All faces keep number of faces. It can be retrieved from any one face. + if (!num_faces) + num_faces = pFace->num_faces; + RegisterFace(pFace, m_InstalledFonts, pFaceName, nullptr); + if (FXFT_Get_Face_External_Stream(pFace)) + FXFT_Clear_Face_External_Stream(pFace); + FXFT_Done_Face(pFace); + } while (index < num_faces); +} +FX_DWORD CFX_FontMgrImp::GetFlags(FXFT_Face pFace) { + FX_DWORD flag = 0; + if (FT_IS_FIXED_WIDTH(pFace)) { + flag |= FX_FONTSTYLE_FixedPitch; + } + TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); + if (!pOS2) { + return flag; + } + if (pOS2->ulCodePageRange1 & (1 << 31)) { + flag |= FX_FONTSTYLE_Symbolic; + } + if (pOS2->panose[0] == 2) { + uint8_t uSerif = pOS2->panose[1]; + if ((uSerif > 1 && uSerif < 10) || uSerif > 13) { + flag |= FX_FONTSTYLE_Serif; + } + } + return flag; +} +#define GetUInt8(p) ((uint8_t)((p)[0])) +#define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) +#define GetUInt32(p) \ + ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) +void CFX_FontMgrImp::GetNames(const uint8_t* name_table, + CFX_WideStringArray& Names) { + if (NULL == name_table) { + return; + } + uint8_t* lpTable = (uint8_t*)name_table; + CFX_WideString wsFamily; + uint8_t* sp = lpTable + 2; + uint8_t* lpNameRecord = lpTable + 6; + uint16_t nNameCount = GetUInt16(sp); + uint8_t* lpStr = lpTable + GetUInt16(sp + 2); + for (uint16_t j = 0; j < nNameCount; j++) { + uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); + if (nNameID != 1) { + continue; + } + 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(); + if (nPlatformID != 1) { + for (uint16_t k = 0; k < nNameLength / 2; k++) { + FX_WCHAR wcTemp = GetUInt16(lpStr + nNameOffset + k * 2); + wsFamily += wcTemp; + } + Names.Add(wsFamily); + } else { + for (uint16_t k = 0; k < nNameLength; k++) { + FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k); + wsFamily += wcTemp; + } + Names.Add(wsFamily); + } + } +} +#undef GetUInt8 +#undef GetUInt16 +#undef GetUInt32 +struct FX_BIT2CHARSET { + FX_WORD wBit; + FX_WORD wCharset; +}; +FX_BIT2CHARSET g_FX_Bit2Charset1[16] = { + {1 << 0, FX_CHARSET_ANSI}, + {1 << 1, FX_CHARSET_MSWin_EasterEuropean}, + {1 << 2, FX_CHARSET_MSWin_Cyrillic}, + {1 << 3, FX_CHARSET_MSWin_Greek}, + {1 << 4, FX_CHARSET_MSWin_Turkish}, + {1 << 5, FX_CHARSET_MSWin_Hebrew}, + {1 << 6, FX_CHARSET_MSWin_Arabic}, + {1 << 7, FX_CHARSET_MSWin_Baltic}, + {1 << 8, FX_CHARSET_MSWin_Vietnamese}, + {1 << 9, FX_CHARSET_Default}, + {1 << 10, FX_CHARSET_Default}, + {1 << 11, FX_CHARSET_Default}, + {1 << 12, FX_CHARSET_Default}, + {1 << 13, FX_CHARSET_Default}, + {1 << 14, FX_CHARSET_Default}, + {1 << 15, FX_CHARSET_Default}, +}; +FX_BIT2CHARSET g_FX_Bit2Charset2[16] = { + {1 << 0, FX_CHARSET_Thai}, + {1 << 1, FX_CHARSET_ShiftJIS}, + {1 << 2, FX_CHARSET_ChineseSimplified}, + {1 << 3, FX_CHARSET_Korean}, + {1 << 4, FX_CHARSET_ChineseTriditional}, + {1 << 5, FX_CHARSET_Johab}, + {1 << 6, FX_CHARSET_Default}, + {1 << 7, FX_CHARSET_Default}, + {1 << 8, FX_CHARSET_Default}, + {1 << 9, FX_CHARSET_Default}, + {1 << 10, FX_CHARSET_Default}, + {1 << 11, FX_CHARSET_Default}, + {1 << 12, FX_CHARSET_Default}, + {1 << 13, FX_CHARSET_Default}, + {1 << 14, FX_CHARSET_OEM}, + {1 << 15, FX_CHARSET_Symbol}, +}; +FX_BIT2CHARSET g_FX_Bit2Charset3[16] = { + {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, + {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, + {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, + {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, + {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, + {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, + {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, + {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default}, +}; +FX_BIT2CHARSET g_FX_Bit2Charset4[16] = { + {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, + {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, + {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, + {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, + {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, + {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, + {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, + {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US}, +}; +#define CODEPAGERANGE_IMPLEMENT(n) \ + for (int32_t i = 0; i < 16; i++) { \ + if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) { \ + Charsets.Add(g_FX_Bit2Charset##n[i].wCharset); \ + } \ + } +void CFX_FontMgrImp::GetCharsets(FXFT_Face pFace, CFX_WordArray& Charsets) { + Charsets.RemoveAll(); + TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); + if (NULL != pOS2) { + FX_WORD a1, a2, a3, a4; + a1 = pOS2->ulCodePageRange1 & 0x0000ffff; + CODEPAGERANGE_IMPLEMENT(1); + a2 = (pOS2->ulCodePageRange1 >> 16) & 0x0000ffff; + CODEPAGERANGE_IMPLEMENT(2); + a3 = pOS2->ulCodePageRange2 & 0x0000ffff; + CODEPAGERANGE_IMPLEMENT(3); + a4 = (pOS2->ulCodePageRange2 >> 16) & 0x0000ffff; + CODEPAGERANGE_IMPLEMENT(4); + } else { + Charsets.Add(FX_CHARSET_Default); + } +} +#undef CODEPAGERANGE_IMPLEMENT +void CFX_FontMgrImp::GetUSBCSB(FXFT_Face pFace, FX_DWORD* USB, FX_DWORD* CSB) { + TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); + if (NULL != pOS2) { + USB[0] = pOS2->ulUnicodeRange1; + USB[1] = pOS2->ulUnicodeRange2; + USB[2] = pOS2->ulUnicodeRange3; + USB[3] = pOS2->ulUnicodeRange4; + CSB[0] = pOS2->ulCodePageRange1; + CSB[1] = pOS2->ulCodePageRange2; + } else { + USB[0] = 0; + USB[1] = 0; + USB[2] = 0; + USB[3] = 0; + CSB[0] = 0; + CSB[1] = 0; + } +} +int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, + const CFX_WideString& Name2) { + if (Name1.Find((const FX_WCHAR*)Name2) != -1) { + return 1; + } + return 0; +} +#endif diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/fgas_stdfontmgr.h new file mode 100644 index 0000000000..e646c28917 --- /dev/null +++ b/xfa/fgas/font/fgas_stdfontmgr.h @@ -0,0 +1,252 @@ +// 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_FONT_FGAS_STDFONTMGR_H_ +#define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ + +#include "core/include/fxcrt/fx_ext.h" +#include "core/include/fxge/fx_freetype.h" +#include "core/include/fxge/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, FX_DWORD dwFontStyles); +FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, + const CFX_FontDescriptors& fonts, + void* pUserData); + +class CFX_StdFontMgrImp : public IFX_FontMgr { + public: + CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator, + FX_LPMatchFont pMatcher, + void* pUserData); + ~CFX_StdFontMgrImp(); + virtual void Release() { delete this; } + virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF); + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength); + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName); + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + const FX_WCHAR* pszFontAlias = NULL, + FX_DWORD dwFontStyles = 0, + FX_WORD wCodePage = 0, + FX_BOOL bSaveStream = FALSE); + virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF); + virtual void ClearFontCache(); + virtual void RemoveFont(IFX_Font* pFont); + + protected: + FX_LPMatchFont m_pMatcher; + FX_LPEnumAllFonts m_pEnumerator; + CFX_FontDescriptors m_FontFaces; + CFX_PtrArray m_Fonts; + CFX_MapPtrToPtr m_CPFonts; + CFX_MapPtrToPtr m_FamilyFonts; + CFX_MapPtrToPtr m_UnicodeFonts; + CFX_MapPtrToPtr m_BufferFonts; + 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, + FX_DWORD dwFontStyles, + FX_DWORD dwMatchFlags, + FX_WORD wCodePage, + FX_DWORD dwUSB = 999, + FX_WCHAR wUnicode = 0); + IFX_Font* GetFont(FX_LPCFONTDESCRIPTOR pFD, FX_DWORD dwFontStyles); +}; +FX_DWORD FX_GetGdiFontStyles(const LOGFONTW& lf); + +#else + +class CFX_FontDescriptor { + public: + CFX_FontDescriptor() + : m_pFileAccess(NULL), m_nFaceIndex(0), m_dwFontStyles(0) { + m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; + m_dwCsb[0] = m_dwCsb[1] = 0; + } + ~CFX_FontDescriptor() { + if (NULL != m_pFileAccess) { + m_pFileAccess->Release(); + } + } + IFX_FileAccess* m_pFileAccess; + int32_t m_nFaceIndex; + CFX_WideString m_wsFaceName; + CFX_WideStringArray m_wsFamilyNames; + FX_DWORD m_dwFontStyles; + FX_DWORD m_dwUsb[4]; + FX_DWORD m_dwCsb[2]; +}; +typedef CFX_ArrayTemplate<CFX_FontDescriptor*> CFX_FontDescriptors; + +struct FX_FontDescriptorInfo { + public: + CFX_FontDescriptor* pFont; + int32_t nPenalty; + + bool operator>(const FX_FontDescriptorInfo& other) const { + return nPenalty > other.nPenalty; + } + bool operator<(const FX_FontDescriptorInfo& other) const { + return nPenalty < other.nPenalty; + } + bool operator==(const FX_FontDescriptorInfo& other) const { + return nPenalty == other.nPenalty; + } +}; +typedef CFX_ArrayTemplate<FX_FontDescriptorInfo> CFX_FontDescriptorInfos; + +struct FX_HandleParentPath { + FX_HandleParentPath() {} + FX_HandleParentPath(const FX_HandleParentPath& x) { + pFileHandle = x.pFileHandle; + bsParentPath = x.bsParentPath; + } + void* pFileHandle; + CFX_ByteString bsParentPath; +}; + +class CFX_FontSourceEnum_File : public IFX_FontSourceEnum { + 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); + + private: + CFX_ByteString GetNextFile(); + CFX_WideString m_wsNext; + CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue; + CFX_ByteStringArray m_FolderPaths; +}; +typedef CFX_MapPtrTemplate<FX_DWORD, IFX_FileAccess*> CFX_HashFileMap; +typedef CFX_MapPtrTemplate<FX_DWORD, IFX_Font*> CFX_HashFontMap; +typedef CFX_MapPtrTemplate<FX_DWORD, CFX_FontDescriptorInfos*> + CFX_HashFontDescsMap; +typedef CFX_MapPtrTemplate<FX_DWORD, CFX_ArrayTemplate<IFX_Font*>*> + CFX_HashFontsMap; +typedef CFX_MapPtrTemplate<FX_WCHAR, IFX_Font*> CFX_UnicodeFontMap; +typedef CFX_MapPtrTemplate<IFX_FileAccess*, CFX_ArrayTemplate<IFX_Font*>*> + CFX_FileFontMap; +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); + virtual void Release(); + virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetFontByCharset(uint8_t nCharset, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, + FX_DWORD dwFontStyles, + const FX_WCHAR* pszFontFamily = NULL); + virtual IFX_Font* LoadFont(const uint8_t* pBuffer, + int32_t iLength, + int32_t iFaceIndex, + int32_t* pFaceCount); + virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, + int32_t iFaceIndex, + int32_t* pFaceCount); + virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, + int32_t iFaceIndex, + int32_t* pFaceCount, + FX_BOOL bSaveStream = FALSE); + virtual IFX_Font* LoadFont(const CFX_WideString& wsFaceName, + int32_t iFaceIndex, + int32_t* pFaceCount); + virtual void ClearFontCache(); + virtual void RemoveFont(IFX_Font* pFont); + FX_BOOL EnumFonts(); + FX_BOOL EnumFontsFromFontMapper(); + FX_BOOL EnumFontsFromFiles(); + + protected: + void RegisterFace(FXFT_Face pFace, + CFX_FontDescriptors& Fonts, + const CFX_WideString* pFaceName, + IFX_FileAccess* pFontAccess); + void RegisterFaces(IFX_FileRead* pFontStream, + const CFX_WideString* pFaceName); + void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); + void GetCharsets(FXFT_Face pFace, CFX_WordArray& Charsets); + void GetUSBCSB(FXFT_Face pFace, FX_DWORD* USB, FX_DWORD* CSB); + FX_DWORD GetFlags(FXFT_Face pFace); + CFX_FontDescriptors m_InstalledFonts; + FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); + FX_BOOL VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode); + int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); + int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const CFX_WideString& FontName, + FX_WCHAR wcUnicode = 0xFFFE); + int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, + FX_WORD wCodePage, + FX_DWORD dwFontStyles, + const CFX_WideString& FontName, + FX_WCHAR wcUnicode = 0xFFFE); + IFX_Font* LoadFont(IFX_FileAccess* pFontAccess, + int32_t iFaceIndex, + int32_t* pFaceCount, + FX_BOOL bWantCache = FALSE); + FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); + IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, + IFX_SystemFontInfo* pSystemFontInfo, + FX_DWORD 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; +}; +#endif + +#endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ diff --git a/xfa/fgas/layout/fgas_linebreak.cpp b/xfa/fgas/layout/fgas_linebreak.cpp new file mode 100644 index 0000000000..8155af870a --- /dev/null +++ b/xfa/fgas/layout/fgas_linebreak.cpp @@ -0,0 +1,320 @@ +// 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/fgas/layout/fgas_linebreak.h" + +#include "core/include/fxcrt/fx_ucd.h" + +const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32] = { + {FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBPB, FX_LBPB, FX_LBPB, FX_LBCP, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBPB, FX_LBPB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBPB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBPB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBIB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBDB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBDB, FX_LBPB, + FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBPB, FX_LBPB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBPB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, + FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, + FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, + FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, + {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, + FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, +}; + +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + FX_LINEBREAKTYPE* pBrkType, + int32_t iLength) { + if (iLength < 2) { + return; + } + FX_DWORD dwCur, dwNext; + FX_WCHAR wch; + wch = *pwsText++; + dwCur = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; + iLength--; + for (int32_t i = 0; i < iLength; i++) { + wch = *pwsText++; + dwNext = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; + if (dwNext == FX_CBP_SP) { + pBrkType[i] = FX_LBT_PROHIBITED_BRK; + } else { + pBrkType[i] = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (dwCur << 5) + dwNext); + } + dwCur = dwNext; + } + pBrkType[iLength] = FX_LBT_INDIRECT_BRK; +} +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + int32_t iLength, + CFX_Int32MassArray& bp) { + if (iLength < 2) { + return; + } + FX_LINEBREAKTYPE eType; + FX_DWORD dwCur, dwNext; + FX_WCHAR wch; + wch = *pwsText++; + dwCur = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; + iLength--; + for (int32_t i = 0; i < iLength; i++) { + wch = *pwsText++; + dwNext = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; + if (dwNext == FX_CBP_SP) { + eType = FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (dwCur << 5) + dwNext); + } + if (eType == FX_LBT_DIRECT_BRK) { + bp.Add(i); + } + dwCur = dwNext; + } +} diff --git a/xfa/fgas/layout/fgas_linebreak.h b/xfa/fgas/layout/fgas_linebreak.h new file mode 100644 index 0000000000..dc80e0dd67 --- /dev/null +++ b/xfa/fgas/layout/fgas_linebreak.h @@ -0,0 +1,40 @@ +// 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_LAYOUT_FGAS_LINEBREAK_H_ +#define XFA_FGAS_LAYOUT_FGAS_LINEBREAK_H_ + +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fgas/crt/fgas_utils.h" + +enum FX_LINEBREAKTYPE { + FX_LBT_UNKNOWN = 0x00, + FX_LBT_DIRECT_BRK = 0x1A, + FX_LBT_INDIRECT_BRK = 0x2B, + FX_LBT_COM_INDIRECT_BRK = 0x3C, + FX_LBT_COM_PROHIBITED_BRK = 0x4D, + FX_LBT_PROHIBITED_BRK = 0x5E, + FX_LBT_HANGUL_SPACE_BRK = 0x6F, +}; + +#define FX_LBUN FX_LBT_UNKNOWN +#define FX_LBDB FX_LBT_DIRECT_BRK +#define FX_LBIB FX_LBT_INDIRECT_BRK +#define FX_LBCB FX_LBT_COM_INDIRECT_BRK +#define FX_LBCP FX_LBT_COM_PROHIBITED_BRK +#define FX_LBPB FX_LBT_PROHIBITED_BRK +#define FX_LBHS FX_LBT_HANGUL_SPACE_BRK + +extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32]; + +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + FX_LINEBREAKTYPE* pBrkType, + int32_t iLength); +void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, + int32_t iLength, + CFX_Int32MassArray& bp); + +#endif // XFA_FGAS_LAYOUT_FGAS_LINEBREAK_H_ diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp new file mode 100644 index 0000000000..f57a1335fb --- /dev/null +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -0,0 +1,1691 @@ +// 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/fgas/layout/fgas_rtfbreak.h" + +#include <algorithm> + +#include "core/include/fxcrt/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(FX_DWORD dwPolicies); + ~CFX_RTFBreak(); + void Release() override { delete this; } + void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; + void SetLineStartPos(FX_FLOAT fLinePos) override; + FX_DWORD GetLayoutStyles() const override { return m_dwLayoutStyles; } + void SetLayoutStyles(FX_DWORD 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; + FX_DWORD AppendChar(FX_WCHAR wch) override; + FX_DWORD EndBreak(FX_DWORD 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; + FX_DWORD AppendChar_CharCode(FX_WCHAR wch); + FX_DWORD AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); + + protected: + FX_DWORD m_dwPolicies; + IFX_ArabicChar* m_pArabicChar; + int32_t m_iBoundaryStart; + int32_t m_iBoundaryEnd; + FX_DWORD 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; + FX_DWORD m_dwCharType; + FX_DWORD 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(FX_DWORD 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; + FX_DWORD GetUnifiedCharType(FX_DWORD 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, + FX_DWORD dwStatus); + void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); + void EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD dwStatus); +}; + +} // namespace + +IFX_RTFBreak* IFX_RTFBreak::Create(FX_DWORD dwPolicies) { + return new CFX_RTFBreak(dwPolicies); +} +CFX_RTFBreak::CFX_RTFBreak(FX_DWORD dwPolicies) + : m_dwPolicies(dwPolicies), + m_pArabicChar(NULL), + m_iBoundaryStart(0), + m_iBoundaryEnd(2000000), + m_dwLayoutStyles(0), + m_bPagination(FALSE), + m_bVertical(FALSE), + m_bSingleLine(FALSE), + m_bCharCode(FALSE), + m_pFont(NULL), + m_iFontHeight(240), + m_iFontSize(240), + m_iTabWidth(720000), + m_PositionedTabs(), + m_bOrphanLine(FALSE), + m_wDefChar(0xFEFF), + m_iDefChar(0), + m_wLineBreakChar(L'\n'), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_iLineRotation(0), + m_iCharRotation(0), + m_iRotation(0), + m_iCharSpace(0), + m_bWordSpace(FALSE), + m_iWordSpace(0), + m_bRTL(FALSE), + m_iAlignment(FX_RTFLINEALIGNMENT_Left), + m_pUserData(NULL), + m_dwCharType(0), + m_dwIdentity(0), + m_RTFLine1(), + m_RTFLine2(), + 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(); + } +} +void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { + if (fLineStart > fLineEnd) + return; + m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); + m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); + m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); + m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); +} +void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { + int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); + iLinePos = std::min(iLinePos, m_iBoundaryEnd); + iLinePos = std::max(iLinePos, m_iBoundaryStart); + m_pCurLine->m_iStart = iLinePos; +} +void CFX_RTFBreak::SetLayoutStyles(FX_DWORD dwLayoutStyles) { + if (m_dwLayoutStyles == dwLayoutStyles) { + return; + } + SetBreakStatus(); + m_dwLayoutStyles = dwLayoutStyles; + m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; + m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; + m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; + m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; + m_iLineRotation = GetLineRotation(m_dwLayoutStyles); + m_iRotation = m_iLineRotation + m_iCharRotation; + m_iRotation %= 4; +} +void CFX_RTFBreak::SetFont(IFX_Font* pFont) { + if (pFont == NULL) { + return; + } + if (m_pFont == pFont) { + return; + } + SetBreakStatus(); + m_pFont = pFont; + m_iDefChar = 0; + if (m_pFont != NULL) { + m_iFontHeight = m_iFontSize; + if (m_wDefChar != 0xFEFF) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + m_iDefChar *= m_iFontSize; + } + } +} +void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + if (m_iFontSize == iFontSize) { + return; + } + SetBreakStatus(); + m_iFontSize = iFontSize; + m_iDefChar = 0; + if (m_pFont != NULL) { + m_iFontHeight = m_iFontSize; + if (m_wDefChar != 0xFEFF) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + m_iDefChar *= m_iFontSize; + } + } +} +void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { + m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); +} +void CFX_RTFBreak::AddPositionedTab(FX_FLOAT fTabPos) { + int32_t iLineEnd = m_iBoundaryEnd; + int32_t iTabPos = FXSYS_round(fTabPos * 20000.0f) + m_iBoundaryStart; + if (iTabPos > iLineEnd) { + iTabPos = iLineEnd; + } + if (m_PositionedTabs.Find(iTabPos, 0) > -1) { + return; + } + int32_t iCount = m_PositionedTabs.GetSize(); + int32_t iFind = 0; + for (; iFind < iCount; iFind++) { + if (m_PositionedTabs[iFind] > iTabPos) { + break; + } + } + m_PositionedTabs.InsertAt(iFind, iTabPos); + if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { + m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; + } else { + m_bOrphanLine = FALSE; + } +} +void CFX_RTFBreak::SetPositionedTabs(const CFX_FloatArray& tabs) { + m_PositionedTabs.RemoveAll(); + int32_t iCount = tabs.GetSize(); + m_PositionedTabs.SetSize(iCount); + int32_t iLineEnd = m_iBoundaryEnd; + int32_t iTabPos; + for (int32_t i = 0; i < iCount; i++) { + iTabPos = FXSYS_round(tabs[i] * 20000.0f) + m_iBoundaryStart; + if (iTabPos > iLineEnd) { + iTabPos = iLineEnd; + } + m_PositionedTabs[i] = iTabPos; + } + if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { + m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; + } else { + m_bOrphanLine = FALSE; + } +} +void CFX_RTFBreak::ClearPositionedTabs() { + m_PositionedTabs.RemoveAll(); + m_bOrphanLine = FALSE; +} +void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { + m_wDefChar = wch; + m_iDefChar = 0; + if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + if (m_iDefChar < 0) { + m_iDefChar = 0; + } else { + m_iDefChar *= m_iFontSize; + } + } +} +void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { + if (wch != L'\r' && wch != L'\n') { + return; + } + m_wLineBreakChar = wch; +} +void CFX_RTFBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) { + m_iTolerance = FXSYS_round(fTolerance * 20000.0f); +} +void CFX_RTFBreak::SetHorizontalScale(int32_t iScale) { + if (iScale < 0) { + iScale = 0; + } + if (m_iHorizontalScale == iScale) { + return; + } + SetBreakStatus(); + m_iHorizontalScale = iScale; +} +void CFX_RTFBreak::SetVerticalScale(int32_t iScale) { + if (iScale < 0) { + iScale = 0; + } + if (m_iVerticalScale == iScale) { + return; + } + SetBreakStatus(); + m_iVerticalScale = iScale; +} +void CFX_RTFBreak::SetCharRotation(int32_t iCharRotation) { + if (iCharRotation < 0) { + iCharRotation += (-iCharRotation / 4 + 1) * 4; + } else if (iCharRotation > 3) { + iCharRotation -= (iCharRotation / 4) * 4; + } + if (m_iCharRotation == iCharRotation) { + return; + } + SetBreakStatus(); + m_iCharRotation = iCharRotation; + m_iRotation = m_iLineRotation + m_iCharRotation; + m_iRotation %= 4; +} +void CFX_RTFBreak::SetCharSpace(FX_FLOAT fCharSpace) { + m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); +} +void CFX_RTFBreak::SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) { + m_bWordSpace = !bDefault; + m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f); +} +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); + m_iAlignment = iAlignment; +} +void CFX_RTFBreak::SetUserData(IFX_Unknown* pUserData) { + if (m_pUserData == pUserData) { + return; + } + SetBreakStatus(); + if (m_pUserData != NULL) { + m_pUserData->Release(); + } + m_pUserData = pUserData; + if (m_pUserData != NULL) { + m_pUserData->AddRef(); + } +} +static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; +int32_t CFX_RTFBreak::GetLineRotation(FX_DWORD dwStyles) const { + return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; +} +void CFX_RTFBreak::SetBreakStatus() { + m_dwIdentity++; + int32_t iCount = m_pCurLine->CountChars(); + if (iCount < 1) { + return; + } + CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); + if (tc.m_dwStatus == 0) { + tc.m_dwStatus = FX_RTFBREAK_PieceBreak; + } +} +CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { + CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; + int32_t iCount = tca.GetSize(); + if (index < 0 || index >= iCount) { + return NULL; + } + CFX_RTFChar* pTC; + int32_t iStart = iCount - 1; + while (iStart > -1) { + pTC = tca.GetDataPtr(iStart--); + if (pTC->m_iCharWidth >= 0 || + pTC->GetCharType() != FX_CHARTYPE_Combination) { + if (--index < 0) { + return pTC; + } + } + } + return NULL; +} +CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { + if (bReady) { + if (m_iReady == 1) { + return (CFX_RTFLine*)&m_RTFLine1; + } else if (m_iReady == 2) { + return (CFX_RTFLine*)&m_RTFLine2; + } else { + return NULL; + } + } + FXSYS_assert(m_pCurLine != NULL); + return m_pCurLine; +} +CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { + CFX_RTFLine* pRTFLine = GetRTFLine(bReady); + if (pRTFLine == NULL) { + return NULL; + } + return &pRTFLine->m_LinePieces; +} +inline FX_DWORD CFX_RTFBreak::GetUnifiedCharType(FX_DWORD dwType) const { + return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; +} +int32_t CFX_RTFBreak::GetLastPositionedTab() const { + int32_t iCount = m_PositionedTabs.GetSize(); + if (iCount < 1) { + return m_iBoundaryStart; + } + return m_PositionedTabs[iCount - 1]; +} +FX_BOOL CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const { + int32_t iCount = m_PositionedTabs.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + if (m_PositionedTabs[i] > iTabPos) { + iTabPos = m_PositionedTabs[i]; + return TRUE; + } + } + return FALSE; +} +typedef FX_DWORD (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)( + CFX_RTFChar* pCurChar, + int32_t iRotation); +static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = { + &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab, + &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control, + &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others, + &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic, + &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, + &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, + &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, + &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, +}; +FX_DWORD CFX_RTFBreak::AppendChar(FX_WCHAR wch) { + FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL); + if (m_bCharCode) { + return AppendChar_CharCode(wch); + } + FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; + FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); + CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; + CFX_RTFChar* pCurChar = tca.AddSpace(); + pCurChar->m_dwStatus = 0; + pCurChar->m_wCharCode = wch; + pCurChar->m_dwCharProps = dwProps; + pCurChar->m_dwCharStyles = 0; + pCurChar->m_dwLayoutStyles = 0; + pCurChar->m_iFontSize = m_iFontSize; + pCurChar->m_iFontHeight = m_iFontHeight; + pCurChar->m_iHorizontalScale = m_iHorizontalScale; + pCurChar->m_iVertialScale = m_iVerticalScale; + pCurChar->m_nRotation = m_iCharRotation; + pCurChar->m_iCharWidth = 0; + pCurChar->m_dwIdentity = m_dwIdentity; + if (m_pUserData != NULL) { + m_pUserData->AddRef(); + } + pCurChar->m_pUserData = m_pUserData; + FX_DWORD dwRet1 = FX_RTFBREAK_None; + if (dwType != FX_CHARTYPE_Combination && + GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { + if (!m_bSingleLine && !m_bOrphanLine && m_dwCharType > 0 && + m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { + if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { + dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); + int32_t iCount = m_pCurLine->CountChars(); + if (iCount > 0) { + pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); + } + } + } + } + int32_t iRotation = m_iRotation; + if (m_bVertical && (dwProps & 0x8000) != 0) { + iRotation = (iRotation + 1) % 4; + } + FX_DWORD dwRet2 = + (this->*g_FX_RTFBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( + pCurChar, iRotation); + m_dwCharType = dwType; + return std::max(dwRet1, dwRet2); +} +FX_DWORD CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { + FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL); + FXSYS_assert(m_bCharCode); + m_pCurLine->m_iMBCSChars++; + CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; + CFX_RTFChar* pCurChar = tca.AddSpace(); + pCurChar->m_dwStatus = 0; + pCurChar->m_wCharCode = wch; + pCurChar->m_dwCharProps = 0; + pCurChar->m_dwCharStyles = 0; + pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; + pCurChar->m_iFontSize = m_iFontSize; + pCurChar->m_iFontHeight = m_iFontHeight; + pCurChar->m_iHorizontalScale = m_iHorizontalScale; + pCurChar->m_iVertialScale = m_iVerticalScale; + pCurChar->m_nRotation = m_iCharRotation; + pCurChar->m_iCharWidth = 0; + pCurChar->m_dwIdentity = m_dwIdentity; + if (m_pUserData != NULL) { + m_pUserData->AddRef(); + } + pCurChar->m_pUserData = m_pUserData; + int32_t iCharWidth = 0; + if (m_bVertical != FX_IsOdd(m_iRotation)) { + iCharWidth = 1000; + } else { + if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { + iCharWidth = m_iDefChar; + } + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorizontalScale / 100; + iCharWidth += m_iCharSpace; + pCurChar->m_iCharWidth = iCharWidth; + m_pCurLine->m_iWidth += iCharWidth; + m_dwCharType = 0; + if (!m_bSingleLine && + m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { + return EndBreak(FX_RTFBREAK_LineBreak); + } + return FX_RTFBREAK_None; +} +FX_DWORD CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar, + int32_t iRotation) { + int32_t iCharWidth = 0; + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else { + if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, + m_bCharCode)) { + iCharWidth = 0; + } + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorizontalScale / 100; + CFX_RTFChar* pLastChar = GetLastChar(0); + if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { + iCharWidth = -iCharWidth; + } else { + m_dwCharType = FX_CHARTYPE_Combination; + } + pCurChar->m_iCharWidth = iCharWidth; + if (iCharWidth > 0) { + m_pCurLine->m_iWidth += iCharWidth; + } + return FX_RTFBREAK_None; +} +FX_DWORD CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar, + int32_t iRotation) { + if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) { + FX_BOOL bBreak = FALSE; + if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { + bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance); + } + int32_t& iLineWidth = m_pCurLine->m_iWidth; + int32_t iCharWidth = iLineWidth; + if (GetPositionedTab(iCharWidth)) { + iCharWidth -= iLineWidth; + } else { + iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth; + } + pCurChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + if (!m_bSingleLine && !m_bOrphanLine && bBreak) { + return EndBreak(FX_RTFBREAK_LineBreak); + } + } + return FX_RTFBREAK_None; +} +FX_DWORD CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar, + int32_t iRotation) { + FX_DWORD dwRet2 = FX_RTFBREAK_None; + if (!m_bSingleLine) { + switch (pCurChar->m_wCharCode) { + case L'\v': + case 0x2028: + dwRet2 = FX_RTFBREAK_LineBreak; + break; + case L'\f': + dwRet2 = FX_RTFBREAK_PageBreak; + break; + case 0x2029: + dwRet2 = FX_RTFBREAK_ParagraphBreak; + break; + default: + if (pCurChar->m_wCharCode == m_wLineBreakChar) { + dwRet2 = FX_RTFBREAK_ParagraphBreak; + } + break; + } + if (dwRet2 != FX_RTFBREAK_None) { + dwRet2 = EndBreak(dwRet2); + } + } + return dwRet2; +} +FX_DWORD CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, + int32_t iRotation) { + CFX_RTFChar* pLastChar = NULL; + int32_t& iLineWidth = m_pCurLine->m_iWidth; + int32_t iCharWidth = 0; + FX_WCHAR wForm; + FX_BOOL bAlef = FALSE; + if (m_dwCharType >= FX_CHARTYPE_ArabicAlef && + m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { + pLastChar = GetLastChar(1); + if (pLastChar != NULL) { + iLineWidth -= pLastChar->m_iCharWidth; + CFX_RTFChar* pPrevChar = GetLastChar(2); + wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar); + bAlef = (wForm == 0xFEFF && + pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); + int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; + if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { + iLastRotation++; + } + if (m_bVertical != FX_IsOdd(iLastRotation)) { + iCharWidth = 1000; + } else { + if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode)) { + if (!m_pFont->GetCharWidth(pLastChar->m_wCharCode, iCharWidth, + m_bCharCode)) { + iCharWidth = m_iDefChar; + } + } + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorizontalScale / 100; + pLastChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + iCharWidth = 0; + } + } + wForm = + m_pArabicChar->GetFormChar(pCurChar, (bAlef ? NULL : pLastChar), NULL); + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode) && + !m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, + m_bCharCode)) { + iCharWidth = m_iDefChar; + } + + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorizontalScale / 100; + pCurChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + m_pCurLine->m_iArabicChars++; + if (!m_bSingleLine && !m_bOrphanLine && + m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { + return EndBreak(FX_RTFBREAK_LineBreak); + } + return FX_RTFBREAK_None; +} +FX_DWORD CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar, + int32_t iRotation) { + FX_DWORD dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); + FX_WCHAR wForm; + if (dwType == FX_CHARTYPE_Numeric) { + if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) { + wForm = pCurChar->m_wCharCode + 0x0630; + } else { + wForm = pCurChar->m_wCharCode; + } + } else if (m_bRTL || m_bVertical) { + wForm = FX_GetMirrorChar(pCurChar->m_wCharCode, pCurChar->m_dwCharProps, + m_bRTL, m_bVertical); + } else { + wForm = pCurChar->m_wCharCode; + } + int32_t iCharWidth = 0; + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else { + if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode)) { + iCharWidth = m_iDefChar; + } + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorizontalScale / 100; + iCharWidth += m_iCharSpace; + if (dwType == FX_CHARTYPE_Space && m_bWordSpace) { + iCharWidth += m_iWordSpace; + } + pCurChar->m_iCharWidth = iCharWidth; + m_pCurLine->m_iWidth += iCharWidth; + FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || + (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0); + if (!m_bSingleLine && !m_bOrphanLine && bBreak && + m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { + return EndBreak(FX_RTFBREAK_LineBreak); + } + return FX_RTFBREAK_None; +} +FX_DWORD CFX_RTFBreak::EndBreak(FX_DWORD dwStatus) { + FXSYS_assert(dwStatus >= FX_RTFBREAK_PieceBreak && + dwStatus <= FX_RTFBREAK_PageBreak); + m_dwIdentity++; + CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; + int32_t iCount = pCurPieces->GetSize(); + if (iCount > 0) { + CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); + if (dwStatus > FX_RTFBREAK_PieceBreak) { + pLastPiece->m_dwStatus = dwStatus; + } else { + dwStatus = pLastPiece->m_dwStatus; + } + return dwStatus; + } else { + CFX_RTFLine* pLastLine = GetRTFLine(TRUE); + if (pLastLine != NULL) { + pCurPieces = &pLastLine->m_LinePieces; + iCount = pCurPieces->GetSize(); + if (iCount-- > 0) { + CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); + if (dwStatus > FX_RTFBREAK_PieceBreak) { + pLastPiece->m_dwStatus = dwStatus; + } else { + dwStatus = pLastPiece->m_dwStatus; + } + return dwStatus; + } + return FX_RTFBREAK_None; + } + iCount = m_pCurLine->CountChars(); + if (iCount < 1) { + return FX_RTFBREAK_None; + } + CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); + tc.m_dwStatus = dwStatus; + if (dwStatus <= FX_RTFBREAK_PieceBreak) { + return dwStatus; + } + } + m_iReady = (m_pCurLine == &m_RTFLine1) ? 1 : 2; + CFX_RTFLine* pNextLine = + (m_pCurLine == &m_RTFLine1) ? &m_RTFLine2 : &m_RTFLine1; + FX_BOOL bAllChars = (m_iAlignment > FX_RTFLINEALIGNMENT_Right); + CFX_TPOArray tpos; + if (EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) { + goto EndBreak_Ret; + } + if (!m_bCharCode) { + EndBreak_BidiLine(tpos, dwStatus); + } + if (!m_bPagination && m_iAlignment > FX_RTFLINEALIGNMENT_Left) { + EndBreak_Alignment(tpos, bAllChars, dwStatus); + } +EndBreak_Ret: + m_pCurLine = pNextLine; + m_pCurLine->m_iStart = m_iBoundaryStart; + CFX_RTFChar* pTC = GetLastChar(0); + m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); + return dwStatus; +} +FX_BOOL CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, + FX_BOOL bAllChars, + FX_DWORD dwStatus) { + FX_BOOL bDone = FALSE; + if (!m_bSingleLine && !m_bOrphanLine && + m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { + CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); + switch (tc.GetCharType()) { + case FX_CHARTYPE_Tab: + if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { + SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); + bDone = TRUE; + } + break; + case FX_CHARTYPE_Control: + break; + case FX_CHARTYPE_Space: + if ((m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0) { + SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); + bDone = TRUE; + } + break; + default: + SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); + bDone = TRUE; + break; + } + } + if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { + const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); + const CFX_RTFChar* pTC; + CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; + CFX_RTFPiece tp; + tp.m_pChars = &m_pCurLine->m_LineChars; + FX_BOOL bNew = TRUE; + FX_DWORD dwIdentity = (FX_DWORD)-1; + int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; + for (int32_t i = 0; i <= iLast;) { + pTC = pCurChars + i; + if (bNew) { + tp.m_iStartChar = i; + tp.m_iStartPos += tp.m_iWidth; + tp.m_iWidth = 0; + tp.m_dwStatus = pTC->m_dwStatus; + tp.m_iFontSize = pTC->m_iFontSize; + tp.m_iFontHeight = pTC->m_iFontHeight; + tp.m_iHorizontalScale = pTC->m_iHorizontalScale; + tp.m_iVerticalScale = pTC->m_iVertialScale; + tp.m_dwLayoutStyles = pTC->m_dwLayoutStyles; + dwIdentity = pTC->m_dwIdentity; + tp.m_dwIdentity = dwIdentity; + tp.m_pUserData = pTC->m_pUserData; + j = i; + bNew = FALSE; + } + if (i == iLast || pTC->m_dwStatus != FX_RTFBREAK_None || + pTC->m_dwIdentity != dwIdentity) { + tp.m_iChars = i - j; + if (pTC->m_dwIdentity == dwIdentity) { + tp.m_dwStatus = pTC->m_dwStatus; + tp.m_iWidth += pTC->m_iCharWidth; + tp.m_iChars += 1; + i++; + } + pCurPieces->Add(tp); + bNew = TRUE; + } else { + tp.m_iWidth += pTC->m_iCharWidth; + i++; + } + } + return TRUE; + } + if (bAllChars && !bDone) { + int32_t iEndPos = m_pCurLine->GetLineEnd(); + GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, TRUE); + } + return FALSE; +} +void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus) { + FX_TPO tpo; + CFX_RTFPiece tp; + CFX_RTFChar* pTC; + int32_t i, j; + CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; + int32_t iCount = m_pCurLine->CountChars(); + FX_BOOL bDone = (!m_bPagination && !m_bCharCode && + (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); + if (bDone) { + int32_t iBidiNum = 0; + for (i = 0; i < iCount; i++) { + pTC = chars.GetDataPtr(i); + pTC->m_iBidiPos = i; + if (pTC->GetCharType() != FX_CHARTYPE_Control) { + iBidiNum = i; + } + if (i == 0) { + pTC->m_iBidiLevel = 1; + } + } + FX_BidiLine(chars, iBidiNum + 1, m_bRTL ? 1 : 0); + } else { + for (i = 0; i < iCount; i++) { + pTC = chars.GetDataPtr(i); + pTC->m_iBidiLevel = 0; + pTC->m_iBidiPos = 0; + pTC->m_iBidiOrder = 0; + } + } + tp.m_dwStatus = FX_RTFBREAK_PieceBreak; + tp.m_iStartPos = m_pCurLine->m_iStart; + tp.m_pChars = &chars; + CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; + int32_t iBidiLevel = -1, iCharWidth; + FX_DWORD dwIdentity = (FX_DWORD)-1; + i = j = 0; + while (i < iCount) { + pTC = chars.GetDataPtr(i); + if (iBidiLevel < 0) { + iBidiLevel = pTC->m_iBidiLevel; + iCharWidth = pTC->m_iCharWidth; + if (iCharWidth < 1) { + tp.m_iWidth = 0; + } else { + tp.m_iWidth = iCharWidth; + } + tp.m_iBidiLevel = iBidiLevel; + tp.m_iBidiPos = pTC->m_iBidiOrder; + tp.m_iFontSize = pTC->m_iFontSize; + tp.m_iFontHeight = pTC->m_iFontHeight; + tp.m_iHorizontalScale = pTC->m_iHorizontalScale; + tp.m_iVerticalScale = pTC->m_iVertialScale; + dwIdentity = pTC->m_dwIdentity; + tp.m_dwIdentity = dwIdentity; + tp.m_pUserData = pTC->m_pUserData; + tp.m_dwStatus = FX_RTFBREAK_PieceBreak; + i++; + } else if (iBidiLevel != pTC->m_iBidiLevel || + pTC->m_dwIdentity != dwIdentity) { + tp.m_iChars = i - tp.m_iStartChar; + pCurPieces->Add(tp); + tp.m_iStartPos += tp.m_iWidth; + tp.m_iStartChar = i; + tpo.index = j++; + tpo.pos = tp.m_iBidiPos; + tpos.Add(tpo); + iBidiLevel = -1; + } else { + iCharWidth = pTC->m_iCharWidth; + if (iCharWidth > 0) { + tp.m_iWidth += iCharWidth; + } + i++; + } + } + if (i > tp.m_iStartChar) { + tp.m_dwStatus = dwStatus; + tp.m_iChars = i - tp.m_iStartChar; + pCurPieces->Add(tp); + tpo.index = j; + tpo.pos = tp.m_iBidiPos; + tpos.Add(tpo); + } + if (!m_bCharCode) { + j = tpos.GetSize() - 1; + FX_TEXTLAYOUT_PieceSort(tpos, 0, j); + int32_t iStartPos = m_pCurLine->m_iStart; + for (i = 0; i <= j; i++) { + tpo = tpos.GetAt(i); + CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); + ttp.m_iStartPos = iStartPos; + iStartPos += ttp.m_iWidth; + } + } +} +void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD dwStatus) { + CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; + int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; + int32_t iCount = pCurPieces->GetSize(); + FX_BOOL bFind = FALSE; + FX_DWORD dwCharType; + int32_t i, j; + FX_TPO tpo; + for (i = iCount - 1; i > -1; i--) { + tpo = tpos.GetAt(i); + CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); + if (!bFind) { + iNetWidth = ttp.GetEndPos(); + } + FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); + j = bArabic ? 0 : ttp.m_iChars - 1; + while (j > -1 && j < ttp.m_iChars) { + const CFX_RTFChar& tc = ttp.GetChar(j); + if (tc.m_nBreakType == FX_LBT_DIRECT_BRK) { + iGapChars++; + } + if (!bFind || !bAllChars) { + dwCharType = tc.GetCharType(); + if (dwCharType == FX_CHARTYPE_Space || + dwCharType == FX_CHARTYPE_Control) { + if (!bFind) { + iCharWidth = tc.m_iCharWidth; + if (bAllChars && iCharWidth > 0) { + iNetWidth -= iCharWidth; + } + } + } else { + bFind = TRUE; + if (!bAllChars) { + break; + } + } + } + j += bArabic ? 1 : -1; + } + if (!bAllChars && bFind) { + break; + } + } + int32_t iOffset = m_iBoundaryEnd - iNetWidth; + int32_t iLowerAlignment = (m_iAlignment & FX_RTFLINEALIGNMENT_LowerMask); + int32_t iHigherAlignment = (m_iAlignment & FX_RTFLINEALIGNMENT_HigherMask); + if (iGapChars > 0 && (iHigherAlignment == FX_RTFLINEALIGNMENT_Distributed || + (iHigherAlignment == FX_RTFLINEALIGNMENT_Justified && + dwStatus != FX_RTFBREAK_ParagraphBreak))) { + int32_t iStart = -1; + for (i = 0; i < iCount; i++) { + tpo = tpos.GetAt(i); + CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); + if (iStart < 0) { + iStart = ttp.m_iStartPos; + } else { + ttp.m_iStartPos = iStart; + } + int32_t k; + for (j = 0; j < ttp.m_iChars; j++) { + CFX_RTFChar& tc = ttp.GetChar(j); + if (tc.m_nBreakType != FX_LBT_DIRECT_BRK || tc.m_iCharWidth < 0) { + continue; + } + k = iOffset / iGapChars; + tc.m_iCharWidth += k; + ttp.m_iWidth += k; + iOffset -= k; + iGapChars--; + if (iGapChars < 1) { + break; + } + } + iStart += ttp.m_iWidth; + } + } else if (iLowerAlignment > FX_RTFLINEALIGNMENT_Left) { + if (iLowerAlignment == FX_RTFLINEALIGNMENT_Center) { + iOffset /= 2; + } + if (iOffset > 0) { + for (i = 0; i < iCount; i++) { + CFX_RTFPiece& ttp = pCurPieces->GetAt(i); + ttp.m_iStartPos += iOffset; + } + } + } +} +int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, + int32_t& iEndPos, + FX_BOOL bAllChars, + FX_BOOL bOnlyBrk) { + int32_t iLength = tca.GetSize() - 1; + if (iLength < 1) { + return iLength; + } + int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, + iLast = -1, iLastPos = -1; + if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) { + if (!bAllChars || m_bCharCode) { + return iLength; + } + iBreak = iLength; + iBreakPos = iEndPos; + } + CFX_RTFChar* pCharArray = tca.GetData(); + if (m_bCharCode) { + const CFX_RTFChar* pChar; + int32_t iCharWidth; + while (iLength > 0) { + if (iEndPos <= m_iBoundaryEnd) { + break; + } + pChar = pCharArray + iLength--; + iCharWidth = pChar->m_iCharWidth; + if (iCharWidth > 0) { + iEndPos -= iCharWidth; + } + } + return iLength; + } + FX_BOOL bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0; + FX_BOOL bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0; + FX_BOOL bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0; + FX_BOOL bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0; + FX_LINEBREAKTYPE eType; + FX_DWORD nCodeProp, nCur, nNext; + CFX_RTFChar* pCur = pCharArray + iLength--; + if (bAllChars) { + pCur->m_nBreakType = FX_LBT_UNKNOWN; + } + nCodeProp = pCur->m_dwCharProps; + nNext = nCodeProp & 0x003F; + int32_t iCharWidth = pCur->m_iCharWidth; + if (iCharWidth > 0) { + iEndPos -= iCharWidth; + } + while (iLength >= 0) { + pCur = pCharArray + iLength; + nCodeProp = pCur->m_dwCharProps; + nCur = nCodeProp & 0x003F; + FX_BOOL bNeedBreak = FALSE; + if (nCur == FX_CBP_SP) { + bNeedBreak = !bSpaceBreak; + if (nNext == FX_CBP_SP) { + eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (nCur << 5) + nNext); + } + } else if (nCur == FX_CBP_TB) { + bNeedBreak = !bTabBreak; + if (nNext == FX_CBP_TB) { + eType = bTabBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (nCur << 5) + nNext); + } + } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { + eType = FX_LBT_DIRECT_BRK; + } else if (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS) { + eType = FX_LBT_DIRECT_BRK; + } else { + if (nNext == FX_CBP_SP) { + eType = FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (nCur << 5) + nNext); + } + } + if (bAllChars) { + pCur->m_nBreakType = eType; + } + if (!bOnlyBrk) { + iCharWidth = pCur->m_iCharWidth; + FX_BOOL bBreak = FALSE; + if (nCur == FX_CBP_TB && bTabBreak) { + bBreak = iCharWidth > 0 && iEndPos - iCharWidth <= m_iBoundaryEnd; + } else { + bBreak = iEndPos <= m_iBoundaryEnd; + } + if (m_bSingleLine || m_bOrphanLine || bBreak || bNeedBreak) { + if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) { + iBreak = iLength; + iBreakPos = iEndPos; + if (!bAllChars) { + return iLength; + } + } else if (eType == FX_LBT_INDIRECT_BRK && iIndirect < 0) { + iIndirect = iLength; + iIndirectPos = iEndPos; + } + if (iLast < 0) { + iLast = iLength; + iLastPos = iEndPos; + } + } + if (iCharWidth > 0) { + iEndPos -= iCharWidth; + } + } + nNext = nCodeProp & 0x003F; + iLength--; + } + if (bOnlyBrk) { + return 0; + } + if (iBreak > -1) { + iEndPos = iBreakPos; + return iBreak; + } + if (iIndirect > -1) { + iEndPos = iIndirectPos; + return iIndirect; + } + if (iLast > -1) { + iEndPos = iLastPos; + return iLast; + } + return 0; +} +void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, + CFX_RTFLine* pNextLine, + FX_BOOL bAllChars) { + FXSYS_assert(pCurLine != NULL && pNextLine != NULL); + int32_t iCount = pCurLine->CountChars(); + if (iCount < 2) { + return; + } + int32_t iEndPos = pCurLine->GetLineEnd(); + CFX_RTFCharArray& curChars = pCurLine->m_LineChars; + int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); + if (iCharPos < 0) { + iCharPos = 0; + } + iCharPos++; + if (iCharPos >= iCount) { + pNextLine->RemoveAll(TRUE); + CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); + pTC->m_nBreakType = FX_LBT_UNKNOWN; + return; + } + CFX_RTFCharArray& nextChars = pNextLine->m_LineChars; + int cur_size = curChars.GetSize(); + nextChars.SetSize(cur_size - iCharPos); + FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), + (cur_size - iCharPos) * sizeof(CFX_RTFChar)); + iCount -= iCharPos; + cur_size = curChars.GetSize(); + curChars.RemoveAt(cur_size - iCount, iCount); + pNextLine->m_iStart = pCurLine->m_iStart; + pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos; + pCurLine->m_iWidth = iEndPos; + CFX_RTFChar* tc = curChars.GetDataPtr(iCharPos - 1); + tc->m_nBreakType = FX_LBT_UNKNOWN; + iCount = nextChars.GetSize(); + CFX_RTFChar* pNextChars = nextChars.GetData(); + for (int32_t i = 0; i < iCount; i++) { + CFX_RTFChar* tc = pNextChars + i; + if (tc->GetCharType() >= FX_CHARTYPE_ArabicAlef) { + pCurLine->m_iArabicChars--; + pNextLine->m_iArabicChars++; + } + if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { + pCurLine->m_iMBCSChars--; + pNextLine->m_iMBCSChars++; + } + tc->m_dwStatus = 0; + } +} +int32_t CFX_RTFBreak::CountBreakPieces() const { + CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); + if (pRTFPieces == NULL) { + return 0; + } + return pRTFPieces->GetSize(); +} +const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { + CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); + if (pRTFPieces == NULL) { + return NULL; + } + if (index < 0 || index >= pRTFPieces->GetSize()) { + return NULL; + } + return pRTFPieces->GetPtrAt(index); +} +void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { + rect.top = 0; + CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); + if (pRTFLine == NULL) { + rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; + rect.width = rect.height = 0; + return; + } + rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; + rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; + CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; + int32_t iCount = rtfPieces.GetSize(); + if (iCount < 1) { + rect.width = 0; + return; + } + CFX_RTFPiece* pBreakPiece; + int32_t iLineHeight = 0, iMax; + for (int32_t i = 0; i < iCount; i++) { + pBreakPiece = rtfPieces.GetPtrAt(i); + int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * + pBreakPiece->m_iVerticalScale / 100.0f); + iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); + if (i == 0) { + iLineHeight = iMax; + } else if (iLineHeight < iMax) { + iLineHeight = iMax; + } + } + rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; +} +void CFX_RTFBreak::ClearBreakPieces() { + CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); + if (pRTFLine != NULL) { + pRTFLine->RemoveAll(TRUE); + } + m_iReady = 0; +} +void CFX_RTFBreak::Reset() { + m_dwCharType = 0; + m_RTFLine1.RemoveAll(TRUE); + m_RTFLine2.RemoveAll(TRUE); +} +int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode, + CFX_WideString* pWSForms, + FX_AdjustCharDisplayPos pAdjustPos) const { + if (pText == NULL || pText->iLength < 1) { + return 0; + } + FXSYS_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; + IFX_Font* pFont = pText->pFont; + FX_DWORD dwStyles = pText->dwLayoutStyles; + CFX_RectF rtText(*pText->pRect); + FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); + FX_FLOAT fFontSize = pText->fFontSize; + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + int32_t iAscent = pFont->GetAscent(); + int32_t iDescent = pFont->GetDescent(); + int32_t iMaxHeight = iAscent - iDescent; + FX_FLOAT fFontHeight = fFontSize; + FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; + FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; + FX_BOOL bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; + FX_BOOL bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; + FX_BOOL bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0; + FX_BOOL bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; + int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation; + int32_t iCharRotation; + FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm; + int32_t iWidth, iCharWidth, iCharHeight; + FX_FLOAT fX, fY, fCharWidth, fCharHeight; + int32_t iHorScale = pText->iHorizontalScale; + int32_t iVerScale = pText->iVerticalScale; + FX_BOOL bEmptyChar; + FX_DWORD dwProps, dwCharType; + fX = rtText.left; + fY = rtText.top; + if (bVerticalDoc) { + fX += (rtText.width - fFontSize) / 2.0f; + if (bRTLPiece) { + fY = rtText.bottom(); + } + } else { + if (bRTLPiece) { + fX = rtText.right(); + } + fY += fAscent; + } + int32_t iCount = 0; + for (int32_t i = 0; i <= iLength; i++) { + wch = *pStr++; + iWidth = *pWidths++; + if (!bMBCSCode) { + dwProps = FX_GetUnicodeProperties(wch); + dwCharType = (dwProps & FX_CHARTYPEBITSMASK); + if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) { + wPrev = 0xFEFF; + continue; + } + } else { + dwProps = 0; + dwCharType = 0; + } + if (iWidth != 0) { + iCharWidth = iWidth; + if (iCharWidth < 0) { + iCharWidth = -iCharWidth; + } + if (!bMBCSCode) { + bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && + dwCharType <= FX_CHARTYPE_Control); + } else { + bEmptyChar = FALSE; + } + if (!bEmptyChar) { + iCount++; + } + if (pCharPos != NULL) { + iCharWidth /= iFontSize; + wForm = wch; + if (!bMBCSCode) { + if (dwCharType >= FX_CHARTYPE_ArabicAlef) { + if (i < iLength) { + wNext = *pStr; + if (*pWidths < 0) { + if (i + 1 < iLength) { + wNext = pStr[1]; + } + } + } else { + wNext = 0xFEFF; + } + wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext); + } else if (bRTLPiece || bVerticalChar) { + wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar); + } else if (dwCharType == FX_CHARTYPE_Numeric && bArabicNumber) { + wForm = wch + 0x0630; + } + dwProps = FX_GetUnicodeProperties(wForm); + } + iCharRotation = iRotation; + if (!bMBCSCode && bVerticalChar && (dwProps & 0x8000) != 0) { + iCharRotation++; + iCharRotation %= 4; + } + if (!bEmptyChar) { + if (bCharCode) { + pCharPos->m_GlyphIndex = wch; + } else { + pCharPos->m_GlyphIndex = pFont->GetGlyphIndex(wForm, bMBCSCode); + if (pCharPos->m_GlyphIndex == 0xFFFF) { + pCharPos->m_GlyphIndex = pFont->GetGlyphIndex(wch, bMBCSCode); + } + } + pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; + pCharPos->m_FontCharWidth = iCharWidth; + if (pWSForms) { + *pWSForms += wForm; + } + } + if (bVerticalDoc) { + iCharHeight = iCharWidth; + iCharWidth = 1000; + } else { + iCharHeight = 1000; + } + fCharWidth = fFontSize * iCharWidth / 1000.0f; + fCharHeight = fFontSize * iCharHeight / 1000.0f; + if (!bMBCSCode && bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { + if (bVerticalDoc) { + fY -= fCharHeight; + } else { + fX -= fCharWidth; + } + } + if (!bEmptyChar) { + CFX_PointF ptOffset; + FX_BOOL bAdjusted = FALSE; + if (pAdjustPos) { + bAdjusted = pAdjustPos(wForm, bMBCSCode, pFont, fFontSize, + bVerticalChar, ptOffset); + } + if (!pAdjustPos && bVerticalChar && (dwProps & 0x00010000) != 0) { + CFX_Rect rtBBox; + rtBBox.Reset(); + if (pFont->GetCharBBox(wForm, rtBBox, bMBCSCode)) { + ptOffset.x = fFontSize * (850 - rtBBox.right()) / 1000.0f; + ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; + } + } + pCharPos->m_OriginX = fX + ptOffset.x; + pCharPos->m_OriginY = fY - ptOffset.y; + } + if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { + if (bVerticalDoc) { + fY += fCharHeight; + } else { + fX += fCharWidth; + } + } + if (!bEmptyChar) { + pCharPos->m_bGlyphAdjust = TRUE; + if (bVerticalDoc) { + if (iCharRotation == 0) { + pCharPos->m_AdjustMatrix[0] = -1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = 1; + pCharPos->m_OriginY += fAscent * iVerScale / 100.0f; + } else if (iCharRotation == 1) { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = -1; + pCharPos->m_AdjustMatrix[2] = -1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX -= + fDescent + fAscent * iVerScale / 100.0f - fAscent; + } else if (iCharRotation == 2) { + pCharPos->m_AdjustMatrix[0] = 1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = -1; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY += fAscent; + } else { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = 1; + pCharPos->m_AdjustMatrix[2] = 1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX += fAscent; + pCharPos->m_OriginY += fCharWidth; + } + } else { + if (iCharRotation == 0) { + pCharPos->m_AdjustMatrix[0] = -1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = 1; + pCharPos->m_OriginY += fAscent * iVerScale / 100.0f - fAscent; + } else if (iCharRotation == 1) { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = -1; + pCharPos->m_AdjustMatrix[2] = -1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX -= fDescent; + pCharPos->m_OriginY -= fAscent + fDescent; + } else if (iCharRotation == 2) { + pCharPos->m_AdjustMatrix[0] = 1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = -1; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY -= fAscent; + } else { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = 1; + pCharPos->m_AdjustMatrix[2] = 1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX += fAscent * iVerScale / 100.0f; + } + } + if (iHorScale != 100 || iVerScale != 100) { + pCharPos->m_AdjustMatrix[0] = + pCharPos->m_AdjustMatrix[0] * iHorScale / 100.0f; + pCharPos->m_AdjustMatrix[1] = + pCharPos->m_AdjustMatrix[1] * iHorScale / 100.0f; + pCharPos->m_AdjustMatrix[2] = + pCharPos->m_AdjustMatrix[2] * iVerScale / 100.0f; + pCharPos->m_AdjustMatrix[3] = + pCharPos->m_AdjustMatrix[3] * iVerScale / 100.0f; + } + pCharPos++; + } + } + } + if (iWidth > 0) { + wPrev = wch; + } + } + return iCount; +} +int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, + CFX_RectFArray& rtArray, + FX_BOOL bCharBBox) const { + if (pText == NULL || pText->iLength < 1) { + return 0; + } + FXSYS_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; + CFX_RectF rect(*pText->pRect); + FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); + FX_FLOAT fFontSize = pText->fFontSize; + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + FX_FLOAT fScale = fFontSize / 1000.0f; + IFX_Font* pFont = pText->pFont; + if (pFont == NULL) { + bCharBBox = FALSE; + } + CFX_Rect bbox; + bbox.Set(0, 0, 0, 0); + if (bCharBBox) { + bCharBBox = pFont->GetBBox(bbox); + } + FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); + FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); + rtArray.RemoveAll(); + rtArray.SetSize(iLength); + FX_DWORD dwStyles = pText->dwLayoutStyles; + FX_BOOL bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; + FX_BOOL bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; + FX_BOOL bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; + FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar; + int32_t iCharSize; + FX_FLOAT fCharSize, fStart; + if (bVertical) { + fStart = bRTLPiece ? rect.bottom() : rect.top; + } else { + fStart = bRTLPiece ? rect.right() : rect.left; + } + for (int32_t i = 0; i < iLength; i++) { + wch = *pStr++; + iCharSize = *pWidths++; + fCharSize = (FX_FLOAT)iCharSize / 20000.0f; + FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); + if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || + (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { + bRet = FALSE; + } + if (bRet) { + iCharSize = iFontSize * 500; + fCharSize = fFontSize / 2.0f; + } + if (bVertical) { + rect.top = fStart; + if (bRTLPiece) { + rect.top -= fCharSize; + fStart -= fCharSize; + } else { + fStart += fCharSize; + } + rect.height = fCharSize; + } else { + rect.left = fStart; + if (bRTLPiece) { + rect.left -= fCharSize; + fStart -= fCharSize; + } else { + fStart += fCharSize; + } + rect.width = fCharSize; + } + if (bCharBBox && !bRet) { + int32_t iCharWidth = 1000; + pFont->GetCharWidth(wch, iCharWidth); + FX_FLOAT fRTLeft = 0, fCharWidth = 0; + if (iCharWidth > 0) { + fCharWidth = iCharWidth * fScale; + fRTLeft = fLeft; + if (bCombText) { + fRTLeft = (rect.width - fCharWidth) / 2.0f; + } + } + CFX_RectF rtBBoxF; + if (bVertical) { + rtBBoxF.top = rect.left + fRTLeft; + rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; + rtBBoxF.height = fCharWidth; + rtBBoxF.width = fHeight; + rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); + } else { + rtBBoxF.left = rect.left + fRTLeft; + rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; + rtBBoxF.width = fCharWidth; + rtBBoxF.height = fHeight; + rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); + } + rtArray.SetAt(i, rtBBoxF); + continue; + } + rtArray.SetAt(i, rect); + } + return iLength; +} diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h new file mode 100644 index 0000000000..7e395f6918 --- /dev/null +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -0,0 +1,237 @@ +// 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_LAYOUT_FGAS_RTFBREAK_H_ +#define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ + +#include "core/include/fxcrt/fx_ucd.h" +#include "core/include/fxge/fx_ge.h" +#include "xfa/fgas/crt/fgas_memory.h" +#include "xfa/fgas/crt/fgas_utils.h" +#include "xfa/fgas/layout/fgas_textbreak.h" +#include "xfa/fgas/layout/fgas_unicode.h" + +class IFX_Unknown; +class IFX_Font; + +#define FX_RTFBREAKPOLICY_None 0x00 +#define FX_RTFBREAKPOLICY_SpaceBreak 0x01 +#define FX_RTFBREAKPOLICY_NumberBreak 0x02 +#define FX_RTFBREAKPOLICY_InfixBreak 0x04 +#define FX_RTFBREAKPOLICY_TabBreak 0x08 +#define FX_RTFBREAKPOLICY_OrphanPositionedTab 0x10 +#define FX_RTFBREAK_None 0x00 +#define FX_RTFBREAK_PieceBreak 0x01 +#define FX_RTFBREAK_LineBreak 0x02 +#define FX_RTFBREAK_ParagraphBreak 0x03 +#define FX_RTFBREAK_PageBreak 0x04 +#define FX_RTFLAYOUTSTYLE_Pagination 0x01 +#define FX_RTFLAYOUTSTYLE_VerticalLayout 0x02 +#define FX_RTFLAYOUTSTYLE_VerticalChars 0x04 +#define FX_RTFLAYOUTSTYLE_LineDirection 0x08 +#define FX_RTFLAYOUTSTYLE_ExpandTab 0x10 +#define FX_RTFLAYOUTSTYLE_ArabicNumber 0x20 +#define FX_RTFLAYOUTSTYLE_SingleLine 0x40 +#define FX_RTFLAYOUTSTYLE_MBCSCode 0x80 +#define FX_RTFCHARSTYLE_Alignment 0x000F +#define FX_RTFCHARSTYLE_ArabicNumber 0x0010 +#define FX_RTFCHARSTYLE_ArabicShadda 0x0020 +#define FX_RTFCHARSTYLE_OddBidiLevel 0x0040 +#define FX_RTFCHARSTYLE_RTLReadingOrder 0x0080 +#define FX_RTFCHARSTYLE_ArabicContext 0x0300 +#define FX_RTFCHARSTYLE_ArabicIndic 0x0400 +#define FX_RTFCHARSTYLE_ArabicComma 0x0800 +#define FX_RTFLINEALIGNMENT_Left 0 +#define FX_RTFLINEALIGNMENT_Center 1 +#define FX_RTFLINEALIGNMENT_Right 2 +#define FX_RTFLINEALIGNMENT_Justified (1 << 2) +#define FX_RTFLINEALIGNMENT_Distributed (2 << 2) +#define FX_RTFLINEALIGNMENT_JustifiedLeft \ + (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Justified) +#define FX_RTFLINEALIGNMENT_JustifiedCenter \ + (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Justified) +#define FX_RTFLINEALIGNMENT_JustifiedRight \ + (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Justified) +#define FX_RTFLINEALIGNMENT_DistributedLeft \ + (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Distributed) +#define FX_RTFLINEALIGNMENT_DistributedCenter \ + (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Distributed) +#define FX_RTFLINEALIGNMENT_DistributedRight \ + (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Distributed) +#define FX_RTFLINEALIGNMENT_LowerMask 0x03 +#define FX_RTFLINEALIGNMENT_HigherMask 0x0C + +struct FX_RTFTEXTOBJ { + FX_RTFTEXTOBJ() { + pStr = NULL; + pWidths = NULL; + iLength = 0; + pFont = NULL; + fFontSize = 12.0f; + dwLayoutStyles = 0; + iCharRotation = 0; + iBidiLevel = 0; + pRect = NULL; + wLineBreakChar = L'\n'; + iHorizontalScale = 100; + iVerticalScale = 100; + } + + const FX_WCHAR* pStr; + int32_t* pWidths; + int32_t iLength; + IFX_Font* pFont; + FX_FLOAT fFontSize; + FX_DWORD dwLayoutStyles; + int32_t iCharRotation; + int32_t iBidiLevel; + const CFX_RectF* pRect; + FX_WCHAR wLineBreakChar; + int32_t iHorizontalScale; + int32_t iVerticalScale; +}; + +class CFX_RTFPiece : public CFX_Target { + public: + CFX_RTFPiece() + : m_dwStatus(FX_RTFBREAK_PieceBreak), + m_iStartPos(0), + m_iWidth(-1), + m_iStartChar(0), + m_iChars(0), + m_iBidiLevel(0), + m_iBidiPos(0), + m_iFontSize(0), + m_iFontHeight(0), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_dwLayoutStyles(0), + m_dwIdentity(0), + m_pChars(NULL), + m_pUserData(NULL) {} + ~CFX_RTFPiece() { Reset(); } + void AppendChar(const CFX_RTFChar& tc) { + FXSYS_assert(m_pChars != NULL); + m_pChars->Add(tc); + if (m_iWidth < 0) { + m_iWidth = tc.m_iCharWidth; + } else { + m_iWidth += tc.m_iCharWidth; + } + m_iChars++; + } + int32_t GetEndPos() const { + return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; + } + 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); + return *m_pChars->GetDataPtr(m_iStartChar + index); + } + CFX_RTFChar* GetCharPtr(int32_t index) const { + FXSYS_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); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_RTFChar* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pText++ = (FX_WCHAR)pChar->m_wCharCode; + } + } + void GetString(CFX_WideString& wsText) const { + FX_WCHAR* pText = wsText.GetBuffer(m_iChars); + GetString(pText); + wsText.ReleaseBuffer(m_iChars); + } + void GetWidths(int32_t* pWidths) const { + FXSYS_assert(pWidths != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_RTFChar* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pWidths++ = pChar->m_iCharWidth; + } + } + void Reset() { + m_dwStatus = FX_RTFBREAK_PieceBreak; + if (m_iWidth > -1) { + m_iStartPos += m_iWidth; + } + m_iWidth = -1; + m_iStartChar += m_iChars; + m_iChars = 0; + m_iBidiLevel = 0; + m_iBidiPos = 0; + m_iHorizontalScale = 100; + m_iVerticalScale = 100; + } + FX_DWORD m_dwStatus; + int32_t m_iStartPos; + int32_t m_iWidth; + int32_t m_iStartChar; + int32_t m_iChars; + int32_t m_iBidiLevel; + int32_t m_iBidiPos; + int32_t m_iFontSize; + int32_t m_iFontHeight; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + FX_DWORD m_dwLayoutStyles; + FX_DWORD m_dwIdentity; + CFX_RTFCharArray* m_pChars; + IFX_Unknown* m_pUserData; +}; +typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray; + +class IFX_RTFBreak { + public: + static IFX_RTFBreak* Create(FX_DWORD 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 FX_DWORD GetLayoutStyles() const = 0; + virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD AppendChar(FX_WCHAR wch) = 0; + virtual FX_DWORD EndBreak(FX_DWORD 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; +}; + +#endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp new file mode 100644 index 0000000000..0cc41980cb --- /dev/null +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -0,0 +1,1824 @@ +// 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/fgas/layout/fgas_textbreak.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_arb.h" +#include "core/include/fxcrt/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(FX_DWORD dwPolicies); + ~CFX_TxtBreak(); + virtual void Release() { delete this; } + virtual void SetLineWidth(FX_FLOAT fLineWidth); + virtual void SetLinePos(FX_FLOAT fLinePos); + virtual FX_DWORD GetLayoutStyles() const { return m_dwLayoutStyles; } + virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD GetContextCharStyles() const; + virtual void SetContextCharStyles(FX_DWORD dwCharStyles); + virtual void SetCombWidth(FX_FLOAT fCombWidth); + virtual void SetUserData(void* pUserData); + virtual FX_DWORD AppendChar(FX_WCHAR wch); + virtual FX_DWORD EndBreak(FX_DWORD 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, FX_DWORD dwProps); + FX_DWORD AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation); + FX_DWORD AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation); + + protected: + FX_DWORD m_dwPolicies; + FX_BOOL m_bPagination; + IFX_ArabicChar* m_pArabicChar; + int32_t m_iLineWidth; + FX_DWORD 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; + FX_DWORD m_dwContextCharStyles; + int32_t m_iCombWidth; + void* m_pUserData; + FX_DWORD 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(FX_DWORD 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; + FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; + void ResetArabicContext(); + void ResetContextCharStyles(); + void EndBreak_UpdateArabicShapes(); + FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine, + FX_BOOL bAllChars, + FX_DWORD dwStatus); + void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); + void EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD 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(FX_DWORD dwPolicies) { + return new CFX_TxtBreak(dwPolicies); +} +CFX_TxtBreak::CFX_TxtBreak(FX_DWORD dwPolicies) + : m_dwPolicies(dwPolicies), + m_pArabicChar(NULL), + m_iLineWidth(2000000), + m_dwLayoutStyles(0), + m_bVertical(FALSE), + m_bArabicContext(FALSE), + m_bArabicShapes(FALSE), + m_bRTL(FALSE), + m_bSingleLine(FALSE), + m_bCombText(FALSE), + m_iArabicContext(1), + m_iCurArabicContext(1), + m_pFont(NULL), + m_iFontSize(240), + m_bEquidistant(TRUE), + m_iTabWidth(720000), + m_wDefChar(0xFEFF), + m_wParagBreakChar(L'\n'), + m_iDefChar(0), + m_iLineRotation(0), + m_iCharRotation(0), + m_iRotation(0), + m_iAlignment(FX_TXTLINEALIGNMENT_Left), + m_dwContextCharStyles(0), + m_iCombWidth(360000), + m_pUserData(NULL), + m_dwCharType(0), + m_bArabicNumber(FALSE), + m_bArabicComma(FALSE), + m_pCurLine(NULL), + m_iReady(0), + m_iTolerance(0), + m_iHorScale(100), + 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)); + } else { + m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_TxtChar)); + m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_TxtChar)); + } + m_pCurLine = m_pTxtLine1; + ResetArabicContext(); +} +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); +} +void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) { + int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); + if (iLinePos < 0) { + iLinePos = 0; + } + if (iLinePos > m_iLineWidth) { + iLinePos = m_iLineWidth; + } + m_pCurLine->m_iStart = iLinePos; + m_pCurLine->m_iWidth += iLinePos; +} +void CFX_TxtBreak::SetLayoutStyles(FX_DWORD dwLayoutStyles) { + m_dwLayoutStyles = dwLayoutStyles; + m_bVertical = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0; + m_bArabicContext = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicContext) != 0; + m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; + m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; + m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; + m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; + ResetArabicContext(); + m_iLineRotation = GetLineRotation(m_dwLayoutStyles); + m_iRotation = m_iLineRotation + m_iCharRotation; + m_iRotation %= 4; +} +void CFX_TxtBreak::SetFont(IFX_Font* pFont) { + if (pFont == NULL) { + return; + } + if (m_pFont == pFont) { + return; + } + SetBreakStatus(); + m_pFont = pFont; + m_iDefChar = 0; + if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + m_iDefChar *= m_iFontSize; + } +} +void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + if (m_iFontSize == iFontSize) { + return; + } + SetBreakStatus(); + m_iFontSize = iFontSize; + m_iDefChar = 0; + if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + m_iDefChar *= m_iFontSize; + } +} +void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { + m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); + if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { + m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; + } + m_bEquidistant = bEquidistant; +} +void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { + m_wDefChar = wch; + m_iDefChar = 0; + if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); + if (m_iDefChar < 0) { + m_iDefChar = 0; + } else { + m_iDefChar *= m_iFontSize; + } + } +} +void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { + if (wch != L'\r' && wch != L'\n') { + return; + } + m_wParagBreakChar = wch; +} +void CFX_TxtBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) { + m_iTolerance = FXSYS_round(fTolerance * 20000.0f); +} +void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) { + if (iCharRotation < 0) { + iCharRotation += (-iCharRotation / 4 + 1) * 4; + } else if (iCharRotation > 3) { + iCharRotation -= (iCharRotation / 4) * 4; + } + if (m_iCharRotation == iCharRotation) { + return; + } + SetBreakStatus(); + m_iCharRotation = iCharRotation; + m_iRotation = m_iLineRotation + m_iCharRotation; + m_iRotation %= 4; +} +void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { + FXSYS_assert(iAlignment >= FX_TXTLINEALIGNMENT_Left && + iAlignment <= FX_TXTLINEALIGNMENT_Distributed); + m_iAlignment = iAlignment; + ResetArabicContext(); +} +void CFX_TxtBreak::ResetContextCharStyles() { + m_dwContextCharStyles = m_bArabicContext ? m_iCurAlignment : m_iAlignment; + if (m_bArabicNumber) { + m_dwContextCharStyles |= FX_TXTCHARSTYLE_ArabicNumber; + } + if (m_bArabicComma) { + m_dwContextCharStyles |= FX_TXTCHARSTYLE_ArabicComma; + } + if ((m_bArabicContext && m_bCurRTL) || (!m_bArabicContext && m_bRTL)) { + m_dwContextCharStyles |= FX_TXTCHARSTYLE_RTLReadingOrder; + } + m_dwContextCharStyles |= (m_iArabicContext << 8); +} +FX_DWORD CFX_TxtBreak::GetContextCharStyles() const { + return m_dwContextCharStyles; +} +void CFX_TxtBreak::SetContextCharStyles(FX_DWORD dwCharStyles) { + m_iCurAlignment = dwCharStyles & 0x0F; + m_bArabicNumber = (dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; + m_bArabicComma = (dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; + m_bCurRTL = (dwCharStyles & FX_TXTCHARSTYLE_RTLReadingOrder) != 0; + m_iCurArabicContext = m_iArabicContext = ((dwCharStyles & 0x0300) >> 8); + ResetContextCharStyles(); +} +void CFX_TxtBreak::SetCombWidth(FX_FLOAT fCombWidth) { + m_iCombWidth = FXSYS_round(fCombWidth * 20000.0f); +} +void CFX_TxtBreak::SetUserData(void* pUserData) { + if (m_pUserData == pUserData) { + return; + } + SetBreakStatus(); + m_pUserData = pUserData; +} +void CFX_TxtBreak::SetBreakStatus() { + if (m_bPagination) { + return; + } + int32_t iCount = m_pCurLine->CountChars(); + if (iCount < 1) { + return; + } + CFX_TxtChar* pTC = (CFX_TxtChar*)m_pCurLine->GetCharPtr(iCount - 1); + if (pTC->m_dwStatus == 0) { + pTC->m_dwStatus = FX_TXTBREAK_PieceBreak; + } +} +void CFX_TxtBreak::SetHorizontalScale(int32_t iScale) { + if (iScale < 0) { + iScale = 0; + } + if (iScale == m_iHorScale) { + return; + } + SetBreakStatus(); + m_iHorScale = iScale; +} +void CFX_TxtBreak::SetVerticalScale(int32_t iScale) { + if (iScale < 0) { + iScale = 0; + } + if (iScale == m_iHorScale) { + return; + } + SetBreakStatus(); + m_iVerScale = iScale; +} +void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { + m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); +} +static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; +int32_t CFX_TxtBreak::GetLineRotation(FX_DWORD dwStyles) const { + return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; +} +CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { + CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; + int32_t iCount = ca.GetSize(); + if (index < 0 || index >= iCount) { + return NULL; + } + CFX_TxtChar* pTC; + int32_t iStart = iCount - 1; + while (iStart > -1) { + pTC = ca.GetDataPtr(iStart--); + if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { + continue; + } + if (--index < 0) { + return pTC; + } + } + return NULL; +} +CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { + if (!bReady) { + return m_pCurLine; + } + if (m_iReady == 1) { + return m_pTxtLine1; + } else if (m_iReady == 2) { + return m_pTxtLine2; + } else { + return NULL; + } +} +CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { + CFX_TxtLine* pTxtLine = GetTxtLine(bReady); + if (pTxtLine == NULL) { + return NULL; + } + return pTxtLine->m_pLinePieces; +} +inline FX_DWORD CFX_TxtBreak::GetUnifiedCharType(FX_DWORD dwType) const { + return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; +} +void CFX_TxtBreak::ResetArabicContext() { + if (m_bArabicContext) { + m_bCurRTL = m_iCurArabicContext > 1; + m_iCurAlignment = m_iCurArabicContext > 1 ? FX_TXTLINEALIGNMENT_Right + : FX_TXTLINEALIGNMENT_Left; + m_iCurAlignment |= (m_iAlignment & FX_TXTLINEALIGNMENT_HigherMask); + m_bArabicNumber = m_iArabicContext >= 1 && m_bArabicShapes; + } else { + if (m_bPagination) { + m_bCurRTL = FALSE; + m_iCurAlignment = 0; + } else { + m_bCurRTL = m_bRTL; + m_iCurAlignment = m_iAlignment; + } + if (m_bRTL) { + m_bArabicNumber = m_iArabicContext >= 1; + } else { + m_bArabicNumber = m_iArabicContext > 1; + } + m_bArabicNumber = m_bArabicNumber && m_bArabicShapes; + } + m_bArabicComma = m_bArabicNumber; + ResetContextCharStyles(); +} +void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, FX_DWORD dwProps) { + if (!m_bPagination) { + ((CFX_TxtChar*)pCurChar)->m_dwStatus = 0; + ((CFX_TxtChar*)pCurChar)->m_pUserData = m_pUserData; + } + if (m_bArabicContext || m_bArabicShapes) { + int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; + int32_t iArabicContext = + (iBidiCls == FX_BIDICLASS_R || iBidiCls == FX_BIDICLASS_AL) + ? 2 + : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 + : 1); + if (iArabicContext != m_iArabicContext && iArabicContext != 1) { + m_iArabicContext = iArabicContext; + if (m_iCurArabicContext == 1) { + m_iCurArabicContext = iArabicContext; + } + ResetArabicContext(); + if (!m_bPagination) { + CFX_TxtChar* pLastChar = (CFX_TxtChar*)GetLastChar(1, FALSE); + if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { + pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; + } + } + } + } + pCurChar->m_dwCharStyles = m_dwContextCharStyles; +} +FX_DWORD CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar, + int32_t iRotation) { + FXSYS_assert(pCurChar != NULL); + FX_WCHAR wch = pCurChar->m_wCharCode; + FX_WCHAR wForm; + int32_t iCharWidth = 0; + CFX_Char* pLastChar; + pCurChar->m_iCharWidth = -1; + if (m_bCombText) { + iCharWidth = m_iCombWidth; + } else { + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else { + wForm = wch; + if (!m_bPagination) { + pLastChar = GetLastChar(0, FALSE); + if (pLastChar != NULL && + (((CFX_TxtChar*)pLastChar)->m_dwCharStyles & + FX_TXTCHARSTYLE_ArabicShadda) == 0) { + FX_BOOL bShadda = FALSE; + if (wch == 0x0651) { + FX_WCHAR wLast = pLastChar->m_wCharCode; + if (wLast >= 0x064C && wLast <= 0x0650) { + wForm = FX_GetArabicFromShaddaTable(wLast); + bShadda = TRUE; + } + } else if (wch >= 0x064C && wch <= 0x0650) { + if (pLastChar->m_wCharCode == 0x0651) { + wForm = FX_GetArabicFromShaddaTable(wch); + bShadda = TRUE; + } + } + if (bShadda) { + ((CFX_TxtChar*)pLastChar)->m_dwCharStyles |= + FX_TXTCHARSTYLE_ArabicShadda; + ((CFX_TxtChar*)pLastChar)->m_iCharWidth = 0; + ((CFX_TxtChar*)pCurChar)->m_dwCharStyles |= + FX_TXTCHARSTYLE_ArabicShadda; + } + } + } + if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { + iCharWidth = 0; + } + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorScale / 100; + } + pCurChar->m_iCharWidth = -iCharWidth; + return FX_TXTBREAK_None; +} +FX_DWORD CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation) { + m_dwCharType = FX_CHARTYPE_Tab; + if ((m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ExpandTab) == 0) { + return FX_TXTBREAK_None; + } + int32_t& iLineWidth = m_pCurLine->m_iWidth; + int32_t iCharWidth; + if (m_bCombText) { + iCharWidth = m_iCombWidth; + } else { + if (m_bEquidistant) { + iCharWidth = iLineWidth; + iCharWidth = m_iTabWidth * (iCharWidth / m_iTabWidth + 1) - iCharWidth; + if (iCharWidth < FX_TXTBREAK_MinimumTabWidth) { + iCharWidth += m_iTabWidth; + } + } else { + iCharWidth = m_iTabWidth; + } + } + pCurChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + if (!m_bSingleLine && iLineWidth >= m_iLineWidth + m_iTolerance) { + return EndBreak(FX_TXTBREAK_LineBreak); + } + return FX_TXTBREAK_None; +} +FX_DWORD CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar, + int32_t iRotation) { + m_dwCharType = FX_CHARTYPE_Control; + FX_DWORD dwRet = FX_TXTBREAK_None; + if (!m_bSingleLine) { + FX_WCHAR wch = pCurChar->m_wCharCode; + switch (wch) { + case L'\v': + case 0x2028: + dwRet = FX_TXTBREAK_LineBreak; + break; + case L'\f': + dwRet = FX_TXTBREAK_PageBreak; + break; + case 0x2029: + dwRet = FX_TXTBREAK_ParagraphBreak; + break; + default: + if (wch == m_wParagBreakChar) { + dwRet = FX_TXTBREAK_ParagraphBreak; + } + break; + } + if (dwRet != FX_TXTBREAK_None) { + dwRet = EndBreak(dwRet); + } + } + return dwRet; +} +FX_DWORD CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar, + int32_t iRotation) { + FX_DWORD dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); + int32_t& iLineWidth = m_pCurLine->m_iWidth; + FX_WCHAR wForm; + int32_t iCharWidth = 0; + CFX_Char* pLastChar = NULL; + FX_BOOL bAlef = FALSE; + if (!m_bCombText && m_dwCharType >= FX_CHARTYPE_ArabicAlef && + m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { + pLastChar = GetLastChar(1); + if (pLastChar != NULL) { + iCharWidth = pLastChar->m_iCharWidth; + if (iCharWidth > 0) { + iLineWidth -= iCharWidth; + } + CFX_Char* pPrevChar = GetLastChar(2); + wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar); + bAlef = (wForm == 0xFEFF && + pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); + int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; + if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { + iLastRotation++; + } + if (m_bVertical != FX_IsOdd(iLastRotation)) { + iCharWidth = 1000; + } else { + m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); + } + if (wForm == 0xFEFF) { + iCharWidth = m_iDefChar; + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorScale / 100; + pLastChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + iCharWidth = 0; + } + } + m_dwCharType = dwType; + wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); + if (m_bCombText) { + iCharWidth = m_iCombWidth; + } else { + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else { + m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); + } + if (wForm == 0xFEFF) { + iCharWidth = m_iDefChar; + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorScale / 100; + } + pCurChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + m_pCurLine->m_iArabicChars++; + if (!m_bSingleLine && iLineWidth > m_iLineWidth + m_iTolerance) { + return EndBreak(FX_TXTBREAK_LineBreak); + } + return FX_TXTBREAK_None; +} +FX_DWORD CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar, + int32_t iRotation) { + FX_DWORD dwProps = pCurChar->m_dwCharProps; + FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); + int32_t& iLineWidth = m_pCurLine->m_iWidth; + int32_t iCharWidth = 0; + m_dwCharType = dwType; + FX_WCHAR wch = pCurChar->m_wCharCode; + FX_WCHAR wForm = wch; + if (dwType == FX_CHARTYPE_Numeric) { + if (m_bArabicNumber) { + wForm = wch + 0x0630; + pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicIndic; + } + } else if (wch == L',') { + if (m_bArabicShapes && m_iCurArabicContext > 0) { + wForm = 0x060C; + pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicComma; + } + } else if (m_bCurRTL || m_bVertical) { + wForm = FX_GetMirrorChar(wch, dwProps, m_bCurRTL, m_bVertical); + } + if (m_bCombText) { + iCharWidth = m_iCombWidth; + } else { + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { + iCharWidth = m_iDefChar; + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorScale / 100; + } + iCharWidth += m_iCharSpace; + pCurChar->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || + (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0); + if (!m_bSingleLine && bBreak && iLineWidth > m_iLineWidth + m_iTolerance) { + return EndBreak(FX_TXTBREAK_LineBreak); + } + return FX_TXTBREAK_None; +} +typedef FX_DWORD (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)(CFX_Char* pCurChar, + int32_t iRotation); +static const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = { + &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab, + &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control, + &CFX_TxtBreak::AppendChar_Combination, &CFX_TxtBreak::AppendChar_Others, + &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Arabic, + &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic, + &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic, + &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Others, + &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Others, +}; +FX_DWORD CFX_TxtBreak::AppendChar(FX_WCHAR wch) { + FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; + FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); + CFX_TxtChar* pCurChar = m_pCurLine->m_pLineChars->AddSpace(); + pCurChar->m_wCharCode = (FX_WORD)wch; + pCurChar->m_nRotation = m_iCharRotation; + pCurChar->m_dwCharProps = dwProps; + pCurChar->m_dwCharStyles = 0; + pCurChar->m_iCharWidth = 0; + pCurChar->m_iHorizontalScale = m_iHorScale; + pCurChar->m_iVertialScale = m_iVerScale; + pCurChar->m_dwStatus = 0; + pCurChar->m_iBidiClass = 0; + pCurChar->m_iBidiLevel = 0; + pCurChar->m_iBidiPos = 0; + pCurChar->m_iBidiOrder = 0; + pCurChar->m_pUserData = NULL; + AppendChar_PageLoad(pCurChar, dwProps); + FX_DWORD dwRet1 = FX_TXTBREAK_None; + if (dwType != FX_CHARTYPE_Combination && + GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { + if (m_dwCharType > 0 && + m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { + if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { + dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); + int32_t iCount = m_pCurLine->CountChars(); + if (iCount > 0) { + pCurChar = m_pCurLine->m_pLineChars->GetDataPtr(iCount - 1); + } + } + } + } + int32_t iRotation = m_iRotation; + if (m_bVertical && (dwProps & 0x8000) != 0) { + iRotation = (iRotation + 1) % 4; + } + FX_DWORD dwRet2 = + (this->*g_FX_TxtBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( + pCurChar, iRotation); + return std::max(dwRet1, dwRet2); +} +void CFX_TxtBreak::EndBreak_UpdateArabicShapes() { + FXSYS_assert(m_bArabicShapes); + int32_t iCount = m_pCurLine->CountChars(); + if (iCount < 2) { + return; + } + int32_t& iLineWidth = m_pCurLine->m_iWidth; + CFX_Char *pCur, *pNext; + pCur = m_pCurLine->GetCharPtr(0); + FX_BOOL bPrevNum = (pCur->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; + pCur = m_pCurLine->GetCharPtr(1); + FX_WCHAR wch, wForm; + FX_BOOL bNextNum; + int32_t i = 1, iCharWidth, iRotation; + do { + i++; + if (i < iCount) { + pNext = m_pCurLine->GetCharPtr(i); + bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; + } else { + pNext = NULL; + bNextNum = FALSE; + } + wch = pCur->m_wCharCode; + if (wch == L'.') { + if (bPrevNum && bNextNum) { + iRotation = m_iRotation; + if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { + iRotation = ((iRotation + 1) & 0x03); + } + wForm = wch == L'.' ? 0x066B : 0x066C; + iLineWidth -= pCur->m_iCharWidth; + if (m_bCombText) { + iCharWidth = m_iCombWidth; + } else { + if (m_bVertical != FX_IsOdd(iRotation)) { + iCharWidth = 1000; + } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { + iCharWidth = m_iDefChar; + } + iCharWidth *= m_iFontSize; + iCharWidth = iCharWidth * m_iHorScale / 100; + } + pCur->m_iCharWidth = iCharWidth; + iLineWidth += iCharWidth; + } + } + bPrevNum = (pCur->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; + pCur = pNext; + } while (i < iCount); +} +FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, + FX_BOOL bAllChars, + FX_DWORD dwStatus) { + int32_t iCount = m_pCurLine->CountChars(); + FX_BOOL bDone = FALSE; + CFX_Char* pTC; + if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) { + pTC = m_pCurLine->GetCharPtr(iCount - 1); + switch (pTC->GetCharType()) { + case FX_CHARTYPE_Tab: + case FX_CHARTYPE_Control: + break; + case FX_CHARTYPE_Space: + if ((m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0) { + SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); + bDone = TRUE; + } + break; + default: + SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); + bDone = TRUE; + break; + } + } + iCount = m_pCurLine->CountChars(); + CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; + CFX_TxtPiece tp; + if (m_bPagination) { + tp.m_dwStatus = dwStatus; + tp.m_iStartPos = m_pCurLine->m_iStart; + tp.m_iWidth = m_pCurLine->m_iWidth; + tp.m_iStartChar = 0; + tp.m_iChars = iCount; + tp.m_pChars = m_pCurLine->m_pLineChars; + tp.m_pUserData = m_pUserData; + pTC = m_pCurLine->GetCharPtr(0); + tp.m_dwCharStyles = pTC->m_dwCharStyles; + tp.m_iHorizontalScale = pTC->m_iHorizontalScale; + tp.m_iVerticalScale = pTC->m_iVertialScale; + pCurPieces->Add(tp); + m_pCurLine = pNextLine; + m_dwCharType = 0; + return TRUE; + } + if (bAllChars && !bDone) { + int32_t iEndPos = m_pCurLine->m_iWidth; + GetBreakPos(*m_pCurLine->m_pLineChars, iEndPos, bAllChars, TRUE); + } + return FALSE; +} +void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus) { + CFX_TxtPiece tp; + FX_TPO tpo; + CFX_TxtChar* pTC; + int32_t i, j; + CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars; + int32_t iCount = m_pCurLine->CountChars(); + FX_BOOL bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL); + if (!m_bPagination && bDone) { + int32_t iBidiNum = 0; + for (i = 0; i < iCount; i++) { + pTC = chars.GetDataPtr(i); + pTC->m_iBidiPos = i; + if (pTC->GetCharType() != FX_CHARTYPE_Control) { + iBidiNum = i; + } + if (i == 0) { + pTC->m_iBidiLevel = 1; + } + } + FX_BidiLine(chars, iBidiNum + 1, m_bCurRTL ? 1 : 0); + } + CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; + if (!m_bPagination && + (bDone || (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_MutipleFormat) != 0)) { + tp.m_dwStatus = FX_TXTBREAK_PieceBreak; + tp.m_iStartPos = m_pCurLine->m_iStart; + tp.m_pChars = m_pCurLine->m_pLineChars; + int32_t iBidiLevel = -1, iCharWidth; + i = 0, j = -1; + while (i < iCount) { + pTC = chars.GetDataPtr(i); + if (iBidiLevel < 0) { + iBidiLevel = pTC->m_iBidiLevel; + tp.m_iWidth = 0; + tp.m_iBidiLevel = iBidiLevel; + tp.m_iBidiPos = pTC->m_iBidiOrder; + tp.m_dwCharStyles = pTC->m_dwCharStyles; + tp.m_pUserData = pTC->m_pUserData; + tp.m_iHorizontalScale = pTC->m_iHorizontalScale; + tp.m_iVerticalScale = pTC->m_iVertialScale; + tp.m_dwStatus = FX_TXTBREAK_PieceBreak; + } + if (iBidiLevel != pTC->m_iBidiLevel || pTC->m_dwStatus != 0) { + if (iBidiLevel == pTC->m_iBidiLevel) { + tp.m_dwStatus = pTC->m_dwStatus; + iCharWidth = pTC->m_iCharWidth; + if (iCharWidth > 0) { + tp.m_iWidth += iCharWidth; + } + i++; + } + tp.m_iChars = i - tp.m_iStartChar; + pCurPieces->Add(tp); + tp.m_iStartPos += tp.m_iWidth; + tp.m_iStartChar = i; + tpo.index = ++j; + tpo.pos = tp.m_iBidiPos; + tpos.Add(tpo); + iBidiLevel = -1; + } else { + iCharWidth = pTC->m_iCharWidth; + if (iCharWidth > 0) { + tp.m_iWidth += iCharWidth; + } + i++; + } + } + if (i > tp.m_iStartChar) { + tp.m_dwStatus = dwStatus; + tp.m_iChars = i - tp.m_iStartChar; + pCurPieces->Add(tp); + tpo.index = ++j; + tpo.pos = tp.m_iBidiPos; + tpos.Add(tpo); + } + if (j > -1) { + if (j > 0) { + FX_TEXTLAYOUT_PieceSort(tpos, 0, j); + int32_t iStartPos = 0; + for (i = 0; i <= j; i++) { + tpo = tpos.GetAt(i); + CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); + ttp.m_iStartPos = iStartPos; + iStartPos += ttp.m_iWidth; + } + } + CFX_TxtPiece& ttp = pCurPieces->GetAt(j); + ttp.m_dwStatus = dwStatus; + } + } else { + tp.m_dwStatus = dwStatus; + tp.m_iStartPos = m_pCurLine->m_iStart; + tp.m_iWidth = m_pCurLine->m_iWidth; + tp.m_iStartChar = 0; + tp.m_iChars = iCount; + tp.m_pChars = m_pCurLine->m_pLineChars; + tp.m_pUserData = m_pUserData; + pTC = chars.GetDataPtr(0); + tp.m_dwCharStyles = pTC->m_dwCharStyles; + tp.m_iHorizontalScale = pTC->m_iHorizontalScale; + tp.m_iVerticalScale = pTC->m_iVertialScale; + pCurPieces->Add(tp); + tpo.index = 0; + tpo.pos = 0; + tpos.Add(tpo); + } +} +void CFX_TxtBreak::EndBreak_Alignment(CFX_TPOArray& tpos, + FX_BOOL bAllChars, + FX_DWORD dwStatus) { + int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; + CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; + int32_t i, j, iCount = pCurPieces->GetSize(); + FX_BOOL bFind = FALSE; + FX_TPO tpo; + CFX_TxtChar* pTC; + FX_DWORD dwCharType; + for (i = iCount - 1; i > -1; i--) { + tpo = tpos.GetAt(i); + CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); + if (!bFind) { + iNetWidth = ttp.GetEndPos(); + } + FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); + j = bArabic ? 0 : ttp.m_iChars - 1; + while (j > -1 && j < ttp.m_iChars) { + pTC = ttp.GetCharPtr(j); + if (pTC->m_nBreakType == FX_LBT_DIRECT_BRK) { + iGapChars++; + } + if (!bFind || !bAllChars) { + dwCharType = pTC->GetCharType(); + if (dwCharType == FX_CHARTYPE_Space || + dwCharType == FX_CHARTYPE_Control) { + if (!bFind) { + iCharWidth = pTC->m_iCharWidth; + if (bAllChars && iCharWidth > 0) { + iNetWidth -= iCharWidth; + } + } + } else { + bFind = TRUE; + if (!bAllChars) { + break; + } + } + } + j += bArabic ? 1 : -1; + } + if (!bAllChars && bFind) { + break; + } + } + int32_t iOffset = m_iLineWidth - iNetWidth; + int32_t iLowerAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_LowerMask); + int32_t iHigherAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_HigherMask); + if (iGapChars > 0 && (iHigherAlignment == FX_TXTLINEALIGNMENT_Distributed || + (iHigherAlignment == FX_TXTLINEALIGNMENT_Justified && + dwStatus != FX_TXTBREAK_ParagraphBreak))) { + int32_t iStart = -1; + for (i = 0; i < iCount; i++) { + tpo = tpos.GetAt(i); + CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); + if (iStart < -1) { + iStart = ttp.m_iStartPos; + } else { + ttp.m_iStartPos = iStart; + } + int32_t k; + for (j = 0; j < ttp.m_iChars; j++) { + pTC = ttp.GetCharPtr(j); + if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0) { + continue; + } + k = iOffset / iGapChars; + pTC->m_iCharWidth += k; + ttp.m_iWidth += k; + iOffset -= k; + iGapChars--; + if (iGapChars < 1) { + break; + } + } + iStart += ttp.m_iWidth; + } + } else if (iLowerAlignment > FX_TXTLINEALIGNMENT_Left) { + if (iLowerAlignment == FX_TXTLINEALIGNMENT_Center) { + iOffset /= 2; + } + if (iOffset > 0) { + for (i = 0; i < iCount; i++) { + CFX_TxtPiece& ttp = pCurPieces->GetAt(i); + ttp.m_iStartPos += iOffset; + } + } + } +} +FX_DWORD CFX_TxtBreak::EndBreak(FX_DWORD dwStatus) { + FXSYS_assert(dwStatus >= FX_TXTBREAK_PieceBreak && + dwStatus <= FX_TXTBREAK_PageBreak); + CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; + int32_t iCount = pCurPieces->GetSize(); + if (iCount > 0) { + CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); + if (dwStatus > FX_TXTBREAK_PieceBreak) { + pLastPiece->m_dwStatus = dwStatus; + } else { + dwStatus = pLastPiece->m_dwStatus; + } + return dwStatus; + } else { + CFX_TxtLine* pLastLine = GetTxtLine(TRUE); + if (pLastLine != NULL) { + pCurPieces = pLastLine->m_pLinePieces; + iCount = pCurPieces->GetSize(); + if (iCount-- > 0) { + CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); + if (dwStatus > FX_TXTBREAK_PieceBreak) { + pLastPiece->m_dwStatus = dwStatus; + } else { + dwStatus = pLastPiece->m_dwStatus; + } + return dwStatus; + } + return FX_TXTBREAK_None; + } + iCount = m_pCurLine->CountChars(); + if (iCount < 1) { + return FX_TXTBREAK_None; + } + if (!m_bPagination) { + CFX_TxtChar* pTC = m_pCurLine->GetCharPtr(iCount - 1); + pTC->m_dwStatus = dwStatus; + } + if (dwStatus <= FX_TXTBREAK_PieceBreak) { + return dwStatus; + } + } + m_iReady = (m_pCurLine == m_pTxtLine1) ? 1 : 2; + CFX_TxtLine* pNextLine = + (m_pCurLine == m_pTxtLine1) ? m_pTxtLine2 : m_pTxtLine1; + FX_BOOL bAllChars = (m_iCurAlignment > FX_TXTLINEALIGNMENT_Right); + CFX_TPOArray tpos; + CFX_Char* pTC; + if (m_bArabicShapes) { + EndBreak_UpdateArabicShapes(); + } + if (EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) { + goto EndBreak_Ret; + } + EndBreak_BidiLine(tpos, dwStatus); + if (!m_bPagination && m_iCurAlignment > FX_TXTLINEALIGNMENT_Left) { + EndBreak_Alignment(tpos, bAllChars, dwStatus); + } +EndBreak_Ret: + m_pCurLine = pNextLine; + pTC = GetLastChar(0, FALSE); + m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); + if (dwStatus == FX_TXTBREAK_ParagraphBreak) { + m_iArabicContext = m_iCurArabicContext = 1; + ResetArabicContext(); + } + return dwStatus; +} +int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, + int32_t& iEndPos, + FX_BOOL bAllChars, + FX_BOOL bOnlyBrk) { + int32_t iLength = ca.GetSize() - 1; + if (iLength < 1) { + return iLength; + } + int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, + iLast = -1, iLastPos = -1; + if (m_bSingleLine || iEndPos <= m_iLineWidth) { + if (!bAllChars) { + return iLength; + } + iBreak = iLength; + iBreakPos = iEndPos; + } + FX_BOOL bSpaceBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0; + FX_BOOL bNumberBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_NumberBreak) != 0; + FX_LINEBREAKTYPE eType; + FX_DWORD nCodeProp, nCur, nNext; + CFX_Char* pCur = ca.GetDataPtr(iLength--); + if (bAllChars) { + pCur->m_nBreakType = FX_LBT_UNKNOWN; + } + nCodeProp = pCur->m_dwCharProps; + nNext = nCodeProp & 0x003F; + int32_t iCharWidth = pCur->m_iCharWidth; + if (iCharWidth > 0) { + iEndPos -= iCharWidth; + } + while (iLength >= 0) { + pCur = ca.GetDataPtr(iLength); + nCodeProp = pCur->m_dwCharProps; + nCur = nCodeProp & 0x003F; + if (nCur == FX_CBP_SP) { + if (nNext == FX_CBP_SP) { + eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (nCur << 5) + nNext); + } + } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { + eType = FX_LBT_DIRECT_BRK; + } else { + if (nNext == FX_CBP_SP) { + eType = FX_LBT_PROHIBITED_BRK; + } else { + eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + + (nCur << 5) + nNext); + } + } + if (bAllChars) { + pCur->m_nBreakType = (uint8_t)eType; + } + if (!bOnlyBrk) { + if (m_bSingleLine || iEndPos <= m_iLineWidth || + (nCur == FX_CBP_SP && !bSpaceBreak)) { + if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) { + iBreak = iLength; + iBreakPos = iEndPos; + if (!bAllChars) { + return iLength; + } + } else if (eType == FX_LBT_INDIRECT_BRK && iIndirect < 0) { + iIndirect = iLength; + iIndirectPos = iEndPos; + } + if (iLast < 0) { + iLast = iLength; + iLastPos = iEndPos; + } + } + iCharWidth = pCur->m_iCharWidth; + if (iCharWidth > 0) { + iEndPos -= iCharWidth; + } + } + nNext = nCodeProp & 0x003F; + iLength--; + } + if (bOnlyBrk) { + return 0; + } + if (iBreak > -1) { + iEndPos = iBreakPos; + return iBreak; + } + if (iIndirect > -1) { + iEndPos = iIndirectPos; + return iIndirect; + } + if (iLast > -1) { + iEndPos = iLastPos; + return iLast; + } + return 0; +} +void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, + CFX_TxtLine* pNextLine, + FX_BOOL bAllChars) { + FXSYS_assert(pCurLine != NULL && pNextLine != NULL); + int32_t iCount = pCurLine->CountChars(); + if (iCount < 2) { + return; + } + int32_t iEndPos = pCurLine->m_iWidth; + CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; + int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); + if (iCharPos < 0) { + iCharPos = 0; + } + iCharPos++; + if (iCharPos >= iCount) { + pNextLine->RemoveAll(TRUE); + CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); + pTC->m_nBreakType = FX_LBT_UNKNOWN; + return; + } + CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars; + int cur_size = curChars.GetSize(); + nextChars.SetSize(cur_size - iCharPos); + FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), + (cur_size - iCharPos) * sizeof(CFX_TxtChar)); + iCount -= iCharPos; + cur_size = curChars.GetSize(); + curChars.RemoveAt(cur_size - iCount, iCount); + pCurLine->m_iWidth = iEndPos; + CFX_TxtChar* pTC = curChars.GetDataPtr(iCharPos - 1); + pTC->m_nBreakType = FX_LBT_UNKNOWN; + iCount = nextChars.GetSize(); + int32_t iCharWidth, iWidth = 0; + for (int32_t i = 0; i < iCount; i++) { + pTC = nextChars.GetDataPtr(i); + if (pTC->GetCharType() >= FX_CHARTYPE_ArabicAlef) { + pCurLine->m_iArabicChars--; + pNextLine->m_iArabicChars++; + } + iCharWidth = pTC->m_iCharWidth; + if (iCharWidth > 0) { + iWidth += iCharWidth; + } + if (m_bPagination) { + continue; + } + pTC->m_dwStatus = 0; + } + pNextLine->m_iWidth = iWidth; +} +int32_t CFX_TxtBreak::CountBreakChars() const { + CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); + return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); +} +int32_t CFX_TxtBreak::CountBreakPieces() const { + CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); + if (pTxtPieces == NULL) { + return 0; + } + return pTxtPieces->GetSize(); +} +const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { + CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); + if (pTxtPieces == NULL) { + return NULL; + } + if (index < 0 || index >= pTxtPieces->GetSize()) { + return NULL; + } + return pTxtPieces->GetPtrAt(index); +} +void CFX_TxtBreak::ClearBreakPieces() { + CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); + if (pTxtLine != NULL) { + pTxtLine->RemoveAll(TRUE); + } + m_iReady = 0; +} +void CFX_TxtBreak::Reset() { + m_dwCharType = 0; + m_iArabicContext = m_iCurArabicContext = 1; + ResetArabicContext(); + m_pTxtLine1->RemoveAll(TRUE); + m_pTxtLine2->RemoveAll(TRUE); +} + +struct FX_FORMCHAR { + FX_WORD wch; + FX_WORD wForm; + int32_t iWidth; +}; + +int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode, + CFX_WideString* pWSForms, + FX_AdjustCharDisplayPos pAdjustPos) const { + if (pTxtRun == NULL || pTxtRun->iLength < 1) { + return 0; + } + IFX_TxtAccess* pAccess = pTxtRun->pAccess; + void* pIdentity = pTxtRun->pIdentity; + const FX_WCHAR* pStr = pTxtRun->pStr; + int32_t* pWidths = pTxtRun->pWidths; + int32_t iLength = pTxtRun->iLength - 1; + IFX_Font* pFont = pTxtRun->pFont; + FX_DWORD dwStyles = pTxtRun->dwStyles; + CFX_RectF rtText(*pTxtRun->pRect); + FX_BOOL bRTLPiece = + (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; + FX_BOOL bArabicNumber = + (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; + FX_BOOL bArabicComma = + (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; + FX_FLOAT fFontSize = pTxtRun->fFontSize; + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + int32_t iAscent = pFont->GetAscent(); + int32_t iDescent = pFont->GetDescent(); + int32_t iMaxHeight = iAscent - iDescent; + FX_FLOAT fFontHeight = fFontSize; + FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; + FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; + FX_BOOL bVerticalDoc = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; + FX_BOOL bVerticalChar = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0; + int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation; + int32_t iCharRotation; + FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm, wLast = 0xFEFF; + int32_t iWidth, iCharWidth, iCharHeight; + FX_FLOAT fX, fY, fCharWidth, fCharHeight; + int32_t iHorScale = pTxtRun->iHorizontalScale; + int32_t iVerScale = pTxtRun->iVerticalScale; + FX_BOOL bSkipSpace = pTxtRun->bSkipSpace; + FX_BOOL bEmptyChar, bShadda = FALSE, bLam = FALSE; + FX_DWORD dwProps, dwCharType; + FX_FORMCHAR formChars[3]; + FX_FLOAT fYBase; + fX = rtText.left; + if (bVerticalDoc) { + fX += (rtText.width - fFontSize) / 2.0f; + fYBase = bRTLPiece ? rtText.bottom() : rtText.top; + fY = fYBase; + } else { + if (bRTLPiece) { + fX = rtText.right(); + } + fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f; + fY = fYBase + fAscent; + } + int32_t iCount = 0, iNext, iForms; + for (int32_t i = 0; i <= iLength; i++) { + if (pAccess != NULL) { + wch = pAccess->GetChar(pIdentity, i); + iWidth = pAccess->GetWidth(pIdentity, i); + } else { + wch = *pStr++; + iWidth = *pWidths++; + } + dwProps = FX_GetUnicodeProperties(wch); + dwCharType = (dwProps & FX_CHARTYPEBITSMASK); + if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) { + wPrev = 0xFEFF; + wLast = wch; + continue; + } + if (dwCharType >= FX_CHARTYPE_ArabicAlef) { + if (i < iLength) { + if (pAccess != NULL) { + iNext = i + 1; + while (iNext <= iLength) { + wNext = pAccess->GetChar(pIdentity, iNext); + dwProps = FX_GetUnicodeProperties(wNext); + if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { + break; + } + iNext++; + } + if (iNext > iLength) { + wNext = 0xFEFF; + } + } else { + int32_t j = -1; + do { + j++; + if (i + j >= iLength) { + break; + } + wNext = pStr[j]; + dwProps = FX_GetUnicodeProperties(wNext); + } while ((dwProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination); + if (i + j >= iLength) { + wNext = 0xFEFF; + } + } + } else { + wNext = 0xFEFF; + } + wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext); + bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); + } else if (dwCharType == FX_CHARTYPE_Combination) { + wForm = wch; + if (wch >= 0x064C && wch <= 0x0651) { + if (bShadda) { + wForm = 0xFEFF; + bShadda = FALSE; + } else { + wNext = 0xFEFF; + if (pAccess != NULL) { + iNext = i + 1; + if (iNext <= iLength) { + wNext = pAccess->GetChar(pIdentity, iNext); + } + } else { + if (i < iLength) { + wNext = *pStr; + } + } + if (wch == 0x0651) { + if (wNext >= 0x064C && wNext <= 0x0650) { + wForm = FX_GetArabicFromShaddaTable(wNext); + bShadda = TRUE; + } + } else { + if (wNext == 0x0651) { + wForm = FX_GetArabicFromShaddaTable(wch); + bShadda = TRUE; + } + } + } + } else { + bShadda = FALSE; + } + } else if (dwCharType == FX_CHARTYPE_Numeric) { + wForm = wch; + if (bArabicNumber) { + wForm += 0x0630; + } + } else if (wch == L'.') { + wForm = wch; + if (bArabicNumber) { + wNext = 0xFEFF; + if (pAccess != NULL) { + iNext = i + 1; + if (iNext <= iLength) { + wNext = pAccess->GetChar(pIdentity, iNext); + } + } else { + if (i < iLength) { + wNext = *pStr; + } + } + if (wNext >= L'0' && wNext <= L'9') { + wForm = 0x066B; + } + } + } else if (wch == L',') { + wForm = wch; + if (bArabicComma) { + wForm = 0x060C; + } + } else if (bRTLPiece || bVerticalChar) { + wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar); + } else { + wForm = wch; + } + if (dwCharType != FX_CHARTYPE_Combination) { + bShadda = FALSE; + } + if (dwCharType < FX_CHARTYPE_ArabicAlef) { + bLam = FALSE; + } + dwProps = FX_GetUnicodeProperties(wForm); + iCharRotation = iRotation; + if (bVerticalChar && (dwProps & 0x8000) != 0) { + iCharRotation++; + } + iCharRotation %= 4; + bEmptyChar = + (dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control); + if (wForm == 0xFEFF) { + bEmptyChar = TRUE; + } + iForms = bLam ? 3 : 1; + iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; + if (pCharPos == NULL) { + if (iWidth > 0) { + wPrev = wch; + } + wLast = wch; + continue; + } + iCharWidth = iWidth; + if (iCharWidth < 0) { + iCharWidth = -iCharWidth; + } + iCharWidth /= iFontSize; + formChars[0].wch = wch; + formChars[0].wForm = wForm; + formChars[0].iWidth = iCharWidth; + if (bLam) { + formChars[1].wForm = 0x0651; + iCharWidth = 0; + pFont->GetCharWidth(0x0651, iCharWidth, FALSE); + formChars[1].iWidth = iCharWidth; + formChars[2].wForm = 0x0670; + iCharWidth = 0; + pFont->GetCharWidth(0x0670, iCharWidth, FALSE); + formChars[2].iWidth = iCharWidth; + } + for (int32_t j = 0; j < iForms; j++) { + wForm = (FX_WCHAR)formChars[j].wForm; + iCharWidth = formChars[j].iWidth; + if (j > 0) { + dwCharType = FX_CHARTYPE_Combination; + wch = wForm; + wLast = (FX_WCHAR)formChars[j - 1].wForm; + } + if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { + pCharPos->m_GlyphIndex = + bCharCode ? wch : pFont->GetGlyphIndex(wForm, FALSE); + pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; + pCharPos->m_FontCharWidth = iCharWidth; + if (pWSForms) { + *pWSForms += wForm; + } + } + if (bVerticalDoc) { + iCharHeight = iCharWidth; + iCharWidth = 1000; + } else { + iCharHeight = 1000; + } + fCharWidth = fFontSize * iCharWidth / 1000.0f; + fCharHeight = fFontSize * iCharHeight / 1000.0f; + if (bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { + if (bVerticalDoc) { + fY -= fCharHeight; + } else { + fX -= fCharWidth; + } + } + if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { + pCharPos->m_OriginX = fX; + pCharPos->m_OriginY = fY; + if ((dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0) { + int32_t iFormWidth = iCharWidth; + pFont->GetCharWidth(wForm, iFormWidth, FALSE); + FX_FLOAT fOffset = fFontSize * (iCharWidth - iFormWidth) / 2000.0f; + if (bVerticalDoc) { + pCharPos->m_OriginY += fOffset; + } else { + pCharPos->m_OriginX += fOffset; + } + } + if (dwCharType == FX_CHARTYPE_Combination) { + CFX_Rect rtBBox; + rtBBox.Reset(); + if (pFont->GetCharBBox(wForm, rtBBox, FALSE)) { + pCharPos->m_OriginY = + fYBase + fFontSize - + fFontSize * (FX_FLOAT)rtBBox.height / (FX_FLOAT)iMaxHeight; + } + if (wForm == wch && wLast != 0xFEFF) { + FX_DWORD dwLastProps = FX_GetUnicodeProperties(wLast); + if ((dwLastProps & FX_CHARTYPEBITSMASK) == + FX_CHARTYPE_Combination) { + CFX_Rect rtBBox; + rtBBox.Reset(); + if (pFont->GetCharBBox(wLast, rtBBox, FALSE)) { + pCharPos->m_OriginY -= fFontSize * rtBBox.height / iMaxHeight; + } + } + } + } + CFX_PointF ptOffset; + FX_BOOL bAdjusted = FALSE; + if (pAdjustPos) { + bAdjusted = pAdjustPos(wForm, bCharCode, pFont, fFontSize, + bVerticalChar, ptOffset); + } + if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) { + CFX_Rect rtBBox; + rtBBox.Reset(); + if (pFont->GetCharBBox(wForm, rtBBox, FALSE)) { + ptOffset.x = fFontSize * (850 - rtBBox.right()) / iMaxHeight; + ptOffset.y = fFontSize * (iAscent - rtBBox.top - 150) / iMaxHeight; + } + } + pCharPos->m_OriginX += ptOffset.x; + pCharPos->m_OriginY -= ptOffset.y; + } + if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { + if (bVerticalDoc) { + fY += fCharHeight; + } else { + fX += fCharWidth; + } + } + if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { + pCharPos->m_bGlyphAdjust = TRUE; + if (bVerticalDoc) { + if (iCharRotation == 0) { + pCharPos->m_AdjustMatrix[0] = -1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = 1; + pCharPos->m_OriginY += fAscent; + } else if (iCharRotation == 1) { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = -1; + pCharPos->m_AdjustMatrix[2] = -1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX -= fDescent; + } else if (iCharRotation == 2) { + pCharPos->m_AdjustMatrix[0] = 1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = -1; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY += fAscent; + } else { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = 1; + pCharPos->m_AdjustMatrix[2] = 1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX += fAscent; + } + } else { + if (iCharRotation == 0) { + pCharPos->m_AdjustMatrix[0] = -1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = 1; + } else if (iCharRotation == 1) { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = -1; + pCharPos->m_AdjustMatrix[2] = -1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX -= fDescent; + pCharPos->m_OriginY -= fAscent + fDescent; + } else if (iCharRotation == 2) { + pCharPos->m_AdjustMatrix[0] = 1; + pCharPos->m_AdjustMatrix[1] = 0; + pCharPos->m_AdjustMatrix[2] = 0; + pCharPos->m_AdjustMatrix[3] = -1; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY -= fAscent; + } else { + pCharPos->m_AdjustMatrix[0] = 0; + pCharPos->m_AdjustMatrix[1] = 1; + pCharPos->m_AdjustMatrix[2] = 1; + pCharPos->m_AdjustMatrix[3] = 0; + pCharPos->m_OriginX += fAscent; + } + } + if (iHorScale != 100 || iVerScale != 100) { + pCharPos->m_AdjustMatrix[0] = + pCharPos->m_AdjustMatrix[0] * iHorScale / 100.0f; + pCharPos->m_AdjustMatrix[1] = + pCharPos->m_AdjustMatrix[1] * iHorScale / 100.0f; + pCharPos->m_AdjustMatrix[2] = + pCharPos->m_AdjustMatrix[2] * iVerScale / 100.0f; + pCharPos->m_AdjustMatrix[3] = + pCharPos->m_AdjustMatrix[3] * iVerScale / 100.0f; + } + pCharPos++; + } + } + if (iWidth > 0) { + wPrev = (FX_WCHAR)formChars[0].wch; + } + wLast = wch; + } + return iCount; +} +int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, + CFX_RectFArray& rtArray, + FX_BOOL bCharBBox) const { + if (pTxtRun == NULL || pTxtRun->iLength < 1) { + return 0; + } + IFX_TxtAccess* pAccess = pTxtRun->pAccess; + void* pIdentity = pTxtRun->pIdentity; + const FX_WCHAR* pStr = pTxtRun->pStr; + int32_t* pWidths = pTxtRun->pWidths; + int32_t iLength = pTxtRun->iLength; + CFX_RectF rect(*pTxtRun->pRect); + FX_BOOL bRTLPiece = + (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; + FX_FLOAT fFontSize = pTxtRun->fFontSize; + int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); + FX_FLOAT fScale = fFontSize / 1000.0f; + IFX_Font* pFont = pTxtRun->pFont; + if (pFont == NULL) { + bCharBBox = FALSE; + } + CFX_Rect bbox; + bbox.Set(0, 0, 0, 0); + if (bCharBBox) { + bCharBBox = pFont->GetBBox(bbox); + } + FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); + FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); + rtArray.RemoveAll(); + rtArray.SetSize(iLength); + FX_BOOL bVertical = + (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; + FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; + FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; + FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; + int32_t iCharSize; + FX_FLOAT fCharSize, fStart; + if (bVertical) { + fStart = bRTLPiece ? rect.bottom() : rect.top; + } else { + fStart = bRTLPiece ? rect.right() : rect.left; + } + for (int32_t i = 0; i < iLength; i++) { + if (pAccess != NULL) { + wch = pAccess->GetChar(pIdentity, i); + iCharSize = pAccess->GetWidth(pIdentity, i); + } else { + wch = *pStr++; + iCharSize = *pWidths++; + } + fCharSize = (FX_FLOAT)iCharSize / 20000.0f; + FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); + if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || + (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { + bRet = FALSE; + } + if (bRet) { + iCharSize = iFontSize * 500; + fCharSize = fFontSize / 2.0f; + } + if (bVertical) { + rect.top = fStart; + if (bRTLPiece) { + rect.top -= fCharSize; + fStart -= fCharSize; + } else { + fStart += fCharSize; + } + rect.height = fCharSize; + } else { + rect.left = fStart; + if (bRTLPiece) { + rect.left -= fCharSize; + fStart -= fCharSize; + } else { + fStart += fCharSize; + } + rect.width = fCharSize; + } + if (bCharBBox && !bRet) { + int32_t iCharWidth = 1000; + pFont->GetCharWidth(wch, iCharWidth); + FX_FLOAT fRTLeft = 0, fCharWidth = 0; + if (iCharWidth > 0) { + fCharWidth = iCharWidth * fScale; + fRTLeft = fLeft; + if (bCombText) { + fRTLeft = (rect.width - fCharWidth) / 2.0f; + } + } + CFX_RectF rtBBoxF; + if (bVertical) { + rtBBoxF.top = rect.left + fRTLeft; + rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; + rtBBoxF.height = fCharWidth; + rtBBoxF.width = fHeight; + rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); + } else { + rtBBoxF.left = rect.left + fRTLeft; + rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; + rtBBoxF.width = fCharWidth; + rtBBoxF.height = fHeight; + rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); + } + rtArray.SetAt(i, rtBBoxF); + continue; + } + rtArray.SetAt(i, rect); + } + return iLength; +} diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h new file mode 100644 index 0000000000..28731d436c --- /dev/null +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -0,0 +1,222 @@ +// 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_LAYOUT_FGAS_TEXTBREAK_H_ +#define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ + +#include "core/include/fxcrt/fx_ucd.h" +#include "core/include/fxge/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; + +#define FX_TXTBREAKPOLICY_None 0x00 +#define FX_TXTBREAKPOLICY_Pagination 0x01 +#define FX_TXTBREAKPOLICY_SpaceBreak 0x02 +#define FX_TXTBREAKPOLICY_NumberBreak 0x04 +#define FX_TXTBREAK_None 0x00 +#define FX_TXTBREAK_PieceBreak 0x01 +#define FX_TXTBREAK_LineBreak 0x02 +#define FX_TXTBREAK_ParagraphBreak 0x03 +#define FX_TXTBREAK_PageBreak 0x04 +#define FX_TXTBREAK_ControlChar 0x10 +#define FX_TXTBREAK_BreakChar 0x20 +#define FX_TXTBREAK_UnknownChar 0x40 +#define FX_TXTBREAK_RemoveChar 0x80 +#define FX_TXTLAYOUTSTYLE_MutipleFormat 0x0001 +#define FX_TXTLAYOUTSTYLE_VerticalLayout 0x0002 +#define FX_TXTLAYOUTSTYLE_VerticalChars 0x0004 +#define FX_TXTLAYOUTSTYLE_ReverseLine 0x0008 +#define FX_TXTLAYOUTSTYLE_ArabicContext 0x0010 +#define FX_TXTLAYOUTSTYLE_ArabicShapes 0x0020 +#define FX_TXTLAYOUTSTYLE_RTLReadingOrder 0x0040 +#define FX_TXTLAYOUTSTYLE_ExpandTab 0x0100 +#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200 +#define FX_TXTLAYOUTSTYLE_CombText 0x0400 +#define FX_TXTCHARSTYLE_Alignment 0x000F +#define FX_TXTCHARSTYLE_ArabicNumber 0x0010 +#define FX_TXTCHARSTYLE_ArabicShadda 0x0020 +#define FX_TXTCHARSTYLE_OddBidiLevel 0x0040 +#define FX_TXTCHARSTYLE_RTLReadingOrder 0x0080 +#define FX_TXTCHARSTYLE_ArabicContext 0x0300 +#define FX_TXTCHARSTYLE_ArabicIndic 0x0400 +#define FX_TXTCHARSTYLE_ArabicComma 0x0800 +#define FX_TXTLINEALIGNMENT_Left 0 +#define FX_TXTLINEALIGNMENT_Center 1 +#define FX_TXTLINEALIGNMENT_Right 2 +#define FX_TXTLINEALIGNMENT_Justified (1 << 2) +#define FX_TXTLINEALIGNMENT_Distributed (2 << 2) +#define FX_TXTLINEALIGNMENT_JustifiedLeft \ + (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Justified) +#define FX_TXTLINEALIGNMENT_JustifiedCenter \ + (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Justified) +#define FX_TXTLINEALIGNMENT_JustifiedRight \ + (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Justified) +#define FX_TXTLINEALIGNMENT_DistributedLeft \ + (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Distributed) +#define FX_TXTLINEALIGNMENT_DistributedCenter \ + (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Distributed) +#define FX_TXTLINEALIGNMENT_DistributedRight \ + (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Distributed) +#define FX_TXTLINEALIGNMENT_LowerMask 0x03 +#define FX_TXTLINEALIGNMENT_HigherMask 0x0C +#define FX_TXTBREAK_MinimumTabWidth 160000 + +class IFX_TxtAccess { + public: + virtual ~IFX_TxtAccess() {} + virtual FX_WCHAR GetChar(void* pIdentity, int32_t index) const = 0; + virtual int32_t GetWidth(void* pIdentity, int32_t index) const = 0; +}; + +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; + } + + IFX_TxtAccess* pAccess; + void* pIdentity; + const FX_WCHAR* pStr; + int32_t* pWidths; + int32_t iLength; + IFX_Font* pFont; + FX_FLOAT fFontSize; + FX_DWORD dwStyles; + int32_t iHorizontalScale; + int32_t iVerticalScale; + int32_t iCharRotation; + FX_DWORD dwCharStyles; + const CFX_RectF* pRect; + FX_WCHAR wLineBreakChar; + FX_BOOL bSkipSpace; +}; + +class CFX_TxtPiece : public CFX_Target { + public: + CFX_TxtPiece() + : m_dwStatus(FX_TXTBREAK_PieceBreak), + m_iStartPos(0), + m_iWidth(-1), + m_iStartChar(0), + m_iChars(0), + m_iBidiLevel(0), + m_iBidiPos(0), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_dwCharStyles(0), + m_pChars(NULL), + m_pUserData(NULL) {} + int32_t GetEndPos() const { + return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; + } + 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); + return m_pChars->GetDataPtr(m_iStartChar + index); + } + void GetString(FX_WCHAR* pText) const { + FXSYS_assert(pText != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_Char* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pText++ = (FX_WCHAR)pChar->m_wCharCode; + } + } + + void GetString(CFX_WideString& wsText) const { + FX_WCHAR* pText = wsText.GetBuffer(m_iChars); + GetString(pText); + wsText.ReleaseBuffer(m_iChars); + } + void GetWidths(int32_t* pWidths) const { + FXSYS_assert(pWidths != NULL); + int32_t iEndChar = m_iStartChar + m_iChars; + CFX_Char* pChar; + for (int32_t i = m_iStartChar; i < iEndChar; i++) { + pChar = m_pChars->GetDataPtr(i); + *pWidths++ = pChar->m_iCharWidth; + } + } + FX_DWORD m_dwStatus; + int32_t m_iStartPos; + int32_t m_iWidth; + int32_t m_iStartChar; + int32_t m_iChars; + int32_t m_iBidiLevel; + int32_t m_iBidiPos; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + FX_DWORD m_dwCharStyles; + CFX_TxtCharArray* m_pChars; + void* m_pUserData; +}; +typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; + +class IFX_TxtBreak { + public: + static IFX_TxtBreak* Create(FX_DWORD dwPolicies); + virtual ~IFX_TxtBreak() {} + virtual void Release() = 0; + virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0; + virtual void SetLinePos(FX_FLOAT fLinePos) = 0; + virtual FX_DWORD GetLayoutStyles() const = 0; + virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD GetContextCharStyles() const = 0; + virtual void SetContextCharStyles(FX_DWORD dwCharStyles) = 0; + virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0; + virtual void SetUserData(void* pUserData) = 0; + virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0; + virtual FX_DWORD EndBreak(FX_DWORD 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; +}; + +#endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ diff --git a/xfa/fgas/layout/fgas_unicode.cpp b/xfa/fgas/layout/fgas_unicode.cpp new file mode 100644 index 0000000000..a4cbee03b7 --- /dev/null +++ b/xfa/fgas/layout/fgas_unicode.cpp @@ -0,0 +1,117 @@ +// 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/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()); + if (iStart >= iEnd) { + return; + } + int32_t i = iStart, j = iEnd; + FX_TPO *pCur = tpos.GetPtrAt(iStart), *pSort; + int32_t v = pCur->pos; + while (i < j) { + while (j > i) { + pSort = tpos.GetPtrAt(j); + if (pSort->pos < v) { + FX_TPO t = *pSort; + *pSort = *pCur; + *pCur = t; + pCur = pSort; + break; + } + j--; + } + while (i < j) { + pSort = tpos.GetPtrAt(i); + if (pSort->pos > v) { + FX_TPO t = *pSort; + *pSort = *pCur; + *pCur = t; + pCur = pSort; + break; + } + i++; + } + } + i--, j++; + if (iStart < i) { + FX_TEXTLAYOUT_PieceSort(tpos, iStart, i); + } + if (j < iEnd) { + FX_TEXTLAYOUT_PieceSort(tpos, j, iEnd); + } +} +static const FX_JAPCHARPROPERTYEX gs_FX_JapCharPropertysEx[] = { + {0x3001, 0x13}, {0x3002, 0x13}, {0x3041, 0x23}, {0x3043, 0x23}, + {0x3045, 0x23}, {0x3047, 0x23}, {0x3049, 0x23}, {0x3063, 0x23}, + {0x3083, 0x23}, {0x3085, 0x23}, {0x3087, 0x23}, {0x308E, 0x23}, + {0x3095, 0x23}, {0x3096, 0x23}, {0x30A1, 0x23}, {0x30A3, 0x23}, + {0x30A5, 0x23}, {0x30A7, 0x23}, {0x30A9, 0x23}, {0x30C3, 0x23}, + {0x30E3, 0x23}, {0x30E5, 0x23}, {0x30E7, 0x23}, {0x30EE, 0x23}, + {0x30F5, 0x23}, {0x30F6, 0x23}, {0x30FB, 0x22}, {0x31F0, 0x23}, + {0x31F1, 0x23}, {0x31F2, 0x23}, {0x31F3, 0x23}, {0x31F4, 0x23}, + {0x31F5, 0x23}, {0x31F6, 0x23}, {0x31F7, 0x23}, {0x31F8, 0x23}, + {0x31F9, 0x23}, {0x31FA, 0x23}, {0x31FB, 0x23}, {0x31FC, 0x23}, + {0x31FD, 0x23}, {0x31FE, 0x23}, {0x31FF, 0x23}, +}; +const FX_JAPCHARPROPERTYEX* FX_GetJapCharPropertyEx(FX_WCHAR wch) { + int32_t iStart = 0; + int32_t iEnd = + sizeof(gs_FX_JapCharPropertysEx) / sizeof(FX_JAPCHARPROPERTYEX); + while (iStart <= iEnd) { + int32_t iMid = (iStart + iEnd) / 2; + FX_WCHAR wJapChar = gs_FX_JapCharPropertysEx[iMid].wChar; + if (wch == wJapChar) { + return gs_FX_JapCharPropertysEx + iMid; + } else if (wch < wJapChar) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } + return NULL; +} +FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, + FX_BOOL bMBCSCode, + IFX_Font* pFont, + FX_FLOAT fFontSize, + FX_BOOL bVertical, + CFX_PointF& ptOffset) { + if (pFont == NULL || !bVertical) { + return FALSE; + } + if (wch < 0x3001 || wch > 0x31FF) { + return FALSE; + } + const FX_JAPCHARPROPERTYEX* pJapChar = FX_GetJapCharPropertyEx(wch); + if (pJapChar == NULL) { + return FALSE; + } + CFX_Rect rtBBox; + rtBBox.Reset(); + if (pFont->GetCharBBox(wch, rtBBox, bMBCSCode)) { + switch (pJapChar->uAlign & 0xF0) { + case FX_JAPCHARPROPERTYEX_Top: + ptOffset.y = fFontSize * (1000 - rtBBox.height) / 1200.0f; + break; + case FX_JAPCHARPROPERTYEX_Middle: + ptOffset.y = fFontSize * (1000 - rtBBox.height) / 6000.0f; + break; + } + switch (pJapChar->uAlign & 0x0F) { + case FX_JAPCHARPROPERTYEX_Center: + ptOffset.x = fFontSize * (600 - rtBBox.right()) / 1000.0f; + break; + case FX_JAPCHARPROPERTYEX_Right: + ptOffset.x = fFontSize * (950 - rtBBox.right()) / 1000.0f; + break; + } + } + return TRUE; +} diff --git a/xfa/fgas/layout/fgas_unicode.h b/xfa/fgas/layout/fgas_unicode.h new file mode 100644 index 0000000000..536895d870 --- /dev/null +++ b/xfa/fgas/layout/fgas_unicode.h @@ -0,0 +1,47 @@ +// 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_LAYOUT_FGAS_UNICODE_H_ +#define XFA_FGAS_LAYOUT_FGAS_UNICODE_H_ + +#include "xfa/fgas/crt/fgas_utils.h" +#include "xfa/fgas/font/fgas_font.h" + +#define FX_JAPCHARPROPERTYEX_Left 0x01 +#define FX_JAPCHARPROPERTYEX_Center 0x02 +#define FX_JAPCHARPROPERTYEX_Right 0x03 +#define FX_JAPCHARPROPERTYEX_Top 0x10 +#define FX_JAPCHARPROPERTYEX_Middle 0x20 +#define FX_JAPCHARPROPERTYEX_Bottom 0x30 + +struct FX_TPO { + int32_t index; + int32_t pos; +}; +typedef CFX_MassArrayTemplate<FX_TPO> CFX_TPOArray; + +void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd); + +struct FX_JAPCHARPROPERTYEX { + FX_WCHAR wChar; + uint8_t uAlign; +}; + +const FX_JAPCHARPROPERTYEX* FX_GetJapCharPropertyEx(FX_WCHAR wch); +typedef FX_BOOL (*FX_AdjustCharDisplayPos)(FX_WCHAR wch, + FX_BOOL bMBCSCode, + IFX_Font* pFont, + FX_FLOAT fFontSize, + FX_BOOL bVertical, + CFX_PointF& ptOffset); +FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, + FX_BOOL bMBCSCode, + IFX_Font* pFont, + FX_FLOAT fFontSize, + FX_BOOL bVertical, + CFX_PointF& ptOffset); + +#endif // XFA_FGAS_LAYOUT_FGAS_UNICODE_H_ diff --git a/xfa/fgas/localization/fgas_datetime.cpp b/xfa/fgas/localization/fgas_datetime.cpp new file mode 100644 index 0000000000..34b8210fc3 --- /dev/null +++ b/xfa/fgas/localization/fgas_datetime.cpp @@ -0,0 +1,550 @@ +// 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/include/fxcrt/fx_system.h" +#include "xfa/fgas/localization/fgas_datetime.h" + +#if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ + _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ +#include <sys/time.h> +#include <time.h> +#endif + +const uint8_t g_FXDaysPerMonth[12] = {31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; +const uint8_t g_FXDaysPerLeapMonth[12] = {31, 29, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; +const int32_t g_FXDaysBeforeMonth[12] = {0, 31, 59, 90, 120, 151, + 181, 212, 243, 273, 304, 334}; +const int32_t g_FXDaysBeforeLeapMonth[12] = {0, 31, 60, 91, 121, 152, + 182, 213, 244, 274, 305, 335}; +const int32_t g_FXDaysPerYear = 365; +const int32_t g_FXDaysPerLeapYear = 366; +const int32_t g_FXDaysPer4Years = 1461; +const int32_t g_FXDaysPer100Years = 36524; +const int32_t g_FXDaysPer400Years = 146097; +const int64_t g_FXMillisecondsPerSecond = 1000; +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); + return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; +} +int32_t FX_DaysInYear(int32_t iYear) { + FXSYS_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); + 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); + const int32_t* p = + FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; + return p[iMonth - 1]; +} +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)); + int64_t iDays = FX_DaysBeforeMonthInYear(iYear, iMonth); + iDays += iDay; + if (!bIncludeThisDay) { + iDays--; + } + if (iYear > 0) { + iYear--; + } else { + iDays -= FX_DaysInYear(iYear); + iYear++; + } + return iDays + (int64_t)iYear * 365 + iYear / 4 - iYear / 100 + iYear / 400; +} +static void FX_DaysToDate(int64_t iDays, + int32_t& iYear, + uint8_t& iMonth, + uint8_t& iDay) { + FX_BOOL bBC = iDays < 0; + if (bBC) { + iDays = -iDays; + } + iYear = 1; + iMonth = 1; + iDay = 1; + if (iDays >= g_FXDaysPer400Years) { + iYear += (int32_t)(iDays / g_FXDaysPer400Years * 400); + iDays %= g_FXDaysPer400Years; + } + if (iDays >= g_FXDaysPer100Years) { + if (iDays == g_FXDaysPer100Years * 4) { + iYear += 300; + iDays -= g_FXDaysPer100Years * 3; + } else { + iYear += (int32_t)(iDays / g_FXDaysPer100Years * 100); + iDays %= g_FXDaysPer100Years; + } + } + if (iDays >= g_FXDaysPer4Years) { + iYear += (int32_t)(iDays / g_FXDaysPer4Years * 4); + iDays %= g_FXDaysPer4Years; + } + while (TRUE) { + int32_t iYearDays = FX_DaysInYear(iYear); + if (iDays < iYearDays) { + if (bBC) { + iYear = -iYear; + iDays = iYearDays - iDays; + } + break; + } + iYear++; + iDays -= iYearDays; + } + while (TRUE) { + int32_t iMonthDays = FX_DaysInMonth(iYear, iMonth); + if (iDays < iMonthDays) { + break; + } + iMonth++; + iDays -= iMonthDays; + } + iDay += (uint8_t)iDays; +} + +struct FXUT_SYSTEMTIME { + FX_WORD wYear; + FX_WORD wMonth; + FX_WORD wDayOfWeek; + FX_WORD wDay; + FX_WORD wHour; + FX_WORD wMinute; + FX_WORD wSecond; + FX_WORD wMilliseconds; +}; + +void CFX_Unitime::Now() { + FXUT_SYSTEMTIME utLocal; +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ + _FX_OS_ == _FX_WIN64_ + ::GetLocalTime((LPSYSTEMTIME)&utLocal); +#elif _FX_OS_ != _FX_EMBEDDED_ +#if 1 + timeval curTime; + gettimeofday(&curTime, NULL); +#else + struct timespec curTime; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); +#endif + struct tm st; + localtime_r(&curTime.tv_sec, &st); + utLocal.wYear = st.tm_year + 1900; + utLocal.wMonth = st.tm_mon + 1; + utLocal.wDayOfWeek = st.tm_wday; + utLocal.wDay = st.tm_mday; + utLocal.wHour = st.tm_hour; + utLocal.wMinute = st.tm_min; + utLocal.wSecond = st.tm_sec; + utLocal.wMilliseconds = curTime.tv_usec / 1000; +#endif + Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, + (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, + (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); +} +void CFX_Unitime::SetGMTime() { + FXUT_SYSTEMTIME utLocal; +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ + _FX_OS_ == _FX_WIN64_ + ::GetSystemTime((LPSYSTEMTIME)&utLocal); +#elif _FX_OS_ != _FX_EMBEDDED_ +#if 1 + timeval curTime; + gettimeofday(&curTime, NULL); +#else + struct timespec curTime; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); +#endif + struct tm st; + gmtime_r(&curTime.tv_sec, &st); + utLocal.wYear = st.tm_year + 1900; + utLocal.wMonth = st.tm_mon + 1; + utLocal.wDayOfWeek = st.tm_wday; + utLocal.wDay = st.tm_mday; + utLocal.wHour = st.tm_hour; + utLocal.wMinute = st.tm_min; + utLocal.wSecond = st.tm_sec; + utLocal.wMilliseconds = curTime.tv_usec / 1000; +#endif + Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, + (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, + (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); +} +void CFX_Unitime::Set(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour, + uint8_t minute, + uint8_t second, + FX_WORD millisecond) { + FXSYS_assert(hour <= 23); + FXSYS_assert(minute <= 59); + FXSYS_assert(second <= 59); + FXSYS_assert(millisecond <= 999); + m_iUnitime = (int64_t)hour * g_FXMillisecondsPerHour + + (int64_t)minute * g_FXMillisecondsPerMinute + + (int64_t)second * g_FXMillisecondsPerSecond + millisecond; + if (year > 0) { + m_iUnitime = + m_iUnitime + + FX_DateToDays(year, month, day, FALSE) * g_FXMillisecondsPerDay; + } +} +void CFX_Unitime::Set(FX_UNITIME t) { + m_iUnitime = t; +} +int32_t CFX_Unitime::GetYear() const { + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + return iYear; +} +uint8_t CFX_Unitime::GetMonth() const { + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + return iMonth; +} +uint8_t CFX_Unitime::GetDay() const { + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + return iDay; +} +FX_WEEKDAY CFX_Unitime::GetDayOfWeek() const { + int32_t v = (int32_t)((m_iUnitime / g_FXMillisecondsPerDay + 1) % 7); + if (v < 0) { + v += 7; + } + return (FX_WEEKDAY)v; +} +FX_WORD CFX_Unitime::GetDayOfYear() const { + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + return FX_DaysBeforeMonthInYear(iYear, iMonth) + iDay; +} +int64_t CFX_Unitime::GetDayOfAD() const { + FX_BOOL bBC = m_iUnitime < 0; + int64_t iDays = m_iUnitime / g_FXMillisecondsPerDay; + iDays += bBC ? -1 : 0; + if (bBC && (m_iUnitime % g_FXMillisecondsPerDay) == 0) { + iDays++; + } + return iDays; +} +uint8_t CFX_Unitime::GetHour() const { + int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerDay); + if (v < 0) { + v += g_FXMillisecondsPerDay; + } + return (uint8_t)(v / g_FXMillisecondsPerHour); +} +uint8_t CFX_Unitime::GetMinute() const { + int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerHour); + if (v < 0) { + v += g_FXMillisecondsPerHour; + } + return (uint8_t)(v / g_FXMillisecondsPerMinute); +} +uint8_t CFX_Unitime::GetSecond() const { + int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerMinute); + if (v < 0) { + v += g_FXMillisecondsPerMinute; + } + return (uint8_t)(v / g_FXMillisecondsPerSecond); +} +FX_WORD CFX_Unitime::GetMillisecond() const { + int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerSecond); + if (v < 0) { + v += g_FXMillisecondsPerSecond; + } + return (FX_WORD)v; +} +FX_BOOL CFX_Unitime::AddYears(int32_t iYears) { + FX_UNITIME ut = m_iUnitime; + if (ut < 0) { + ut = -ut; + } + FX_UNITIME r = ut % g_FXMillisecondsPerDay; + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + iYear += iYears; + if (iYear == 0) { + iYear = iYears > 0 ? 1 : -1; + } + m_iUnitime = + FX_DateToDays(iYear, iMonth, iDay, FALSE) * g_FXMillisecondsPerDay; + m_iUnitime += (iYear < 0) ? -r : r; + return TRUE; +} +FX_BOOL CFX_Unitime::AddMonths(int32_t iMonths) { + FX_BOOL b = iMonths > 0; + FX_UNITIME ut = m_iUnitime; + if (ut < 0) { + ut = -ut; + } + FX_UNITIME r = ut % g_FXMillisecondsPerDay; + int32_t iYear; + uint8_t iMonth, iDay; + FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); + iMonths += iMonth; + while (iMonths < 1) { + iYear--, iMonths += 12; + } + while (iMonths > 12) { + iYear++, iMonths -= 12; + } + if (iYear == 0) { + iYear = b ? 1 : -1; + } + m_iUnitime = FX_DateToDays(iYear, (uint8_t)iMonths, iDay, FALSE) * + g_FXMillisecondsPerDay; + m_iUnitime += (iYear < 0) ? -r : r; + return TRUE; +} +FX_BOOL CFX_Unitime::AddDays(int32_t iDays) { + m_iUnitime += (int64_t)iDays * g_FXMillisecondsPerDay; + return TRUE; +} +FX_BOOL CFX_Unitime::AddHours(int32_t iHours) { + m_iUnitime += (int64_t)iHours * g_FXMillisecondsPerHour; + return TRUE; +} +FX_BOOL CFX_Unitime::AddMinutes(int32_t iMinutes) { + m_iUnitime += (int64_t)iMinutes * g_FXMillisecondsPerMinute; + return TRUE; +} +FX_BOOL CFX_Unitime::AddSeconds(int32_t iSeconds) { + m_iUnitime += ((int64_t)iSeconds) * g_FXMillisecondsPerSecond; + return TRUE; +} +FX_BOOL CFX_Unitime::AddMilliseconds(int32_t iMilliseconds) { + m_iUnitime += iMilliseconds; + return TRUE; +} +FX_BOOL CFX_DateTime::Set(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour, + uint8_t minute, + uint8_t second, + FX_WORD millisecond) { + ASSERT(year != 0); + ASSERT(month >= 1 && month <= 12); + ASSERT(day >= 1 && day <= FX_DaysInMonth(year, month)); + ASSERT(hour <= 23); + ASSERT(minute <= 59); + ASSERT(second <= 59); + ASSERT(millisecond <= 999); + m_DateTime.Date.sDate.year = year; + m_DateTime.Date.sDate.month = month; + m_DateTime.Date.sDate.day = day; + m_DateTime.Time.sTime.hour = hour; + m_DateTime.Time.sTime.minute = minute; + m_DateTime.Time.sTime.second = second; + m_DateTime.Time.sTime.millisecond = millisecond; + return TRUE; +} +FX_BOOL CFX_DateTime::FromUnitime(FX_UNITIME t) { + CFX_Unitime ut(t); + FX_DaysToDate(ut.GetDayOfAD(), m_DateTime.Date.sDate.year, + m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day); + m_DateTime.Date.sDate.day = ut.GetHour(); + m_DateTime.Time.sTime.minute = ut.GetMinute(); + m_DateTime.Time.sTime.second = ut.GetSecond(); + m_DateTime.Time.sTime.millisecond = ut.GetMillisecond(); + return TRUE; +} +FX_UNITIME CFX_DateTime::ToUnitime() const { + FX_UNITIME v = + (int64_t)m_DateTime.Date.sDate.day * g_FXMillisecondsPerHour + + (int64_t)m_DateTime.Time.sTime.minute * g_FXMillisecondsPerMinute + + (int64_t)m_DateTime.Time.sTime.second * g_FXMillisecondsPerSecond + + m_DateTime.Time.sTime.millisecond; + v += FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, + m_DateTime.Date.sDate.day, FALSE) * + g_FXMillisecondsPerDay; + return v; +} +int32_t CFX_DateTime::GetYear() const { + return m_DateTime.Date.sDate.year; +} +uint8_t CFX_DateTime::GetMonth() const { + return m_DateTime.Date.sDate.month; +} +uint8_t CFX_DateTime::GetDay() const { + return m_DateTime.Date.sDate.day; +} +FX_WEEKDAY CFX_DateTime::GetDayOfWeek() const { + int32_t v = (int32_t)(FX_DateToDays(m_DateTime.Date.sDate.year, + m_DateTime.Date.sDate.month, + m_DateTime.Date.sDate.day, TRUE) % + 7); + if (v < 0) { + v += 7; + } + return (FX_WEEKDAY)v; +} +FX_WORD CFX_DateTime::GetDayOfYear() const { + return FX_DaysBeforeMonthInYear(m_DateTime.Date.sDate.year, + m_DateTime.Date.sDate.month) + + m_DateTime.Date.sDate.day; +} +int64_t CFX_DateTime::GetDayOfAD() const { + return FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, + m_DateTime.Date.sDate.day, TRUE); +} +uint8_t CFX_DateTime::GetHour() const { + return m_DateTime.Date.sDate.day; +} +uint8_t CFX_DateTime::GetMinute() const { + return m_DateTime.Time.sTime.minute; +} +uint8_t CFX_DateTime::GetSecond() const { + return m_DateTime.Time.sTime.second; +} +FX_WORD CFX_DateTime::GetMillisecond() const { + return m_DateTime.Time.sTime.millisecond; +} +FX_BOOL CFX_DateTime::AddYears(int32_t iYears) { + if (iYears == 0) { + return FALSE; + } + int32_t v = m_DateTime.Date.sDate.year + iYears; + if (v >= 0 && m_DateTime.Date.sDate.year < 0) { + v++; + } else if (v <= 0 && m_DateTime.Date.sDate.year > 0) { + v--; + } + m_DateTime.Date.sDate.year = v; + return TRUE; +} +FX_BOOL CFX_DateTime::AddMonths(int32_t iMonths) { + if (iMonths == 0) { + return FALSE; + } + FX_BOOL b = iMonths > 0; + iMonths += m_DateTime.Date.sDate.month; + while (iMonths < 1) { + m_DateTime.Date.sDate.year--; + if (m_DateTime.Date.sDate.year == 0) { + m_DateTime.Date.sDate.year = -1; + } + iMonths += 12; + } + while (iMonths > 12) { + m_DateTime.Date.sDate.year++; + if (m_DateTime.Date.sDate.year == 0) { + m_DateTime.Date.sDate.year = 1; + } + iMonths -= 12; + } + if (m_DateTime.Date.sDate.year == 0) { + m_DateTime.Date.sDate.year = b ? 1 : -1; + } + m_DateTime.Date.sDate.month = (uint8_t)iMonths; + return TRUE; +} +FX_BOOL CFX_DateTime::AddDays(int32_t iDays) { + if (iDays == 0) { + return FALSE; + } + int64_t v1 = + FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, + m_DateTime.Date.sDate.day, TRUE); + int64_t v2 = v1 + iDays; + if (v2 <= 0 && v1 > 0) { + v2--; + } else if (v2 >= 0 && v1 < 0) { + v2++; + } + FX_DaysToDate(v2, m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, + m_DateTime.Date.sDate.day); + return TRUE; +} +FX_BOOL CFX_DateTime::AddHours(int32_t iHours) { + if (iHours == 0) { + return FALSE; + } + iHours += m_DateTime.Date.sDate.day; + int32_t iDays = iHours / 24; + iHours %= 24; + if (iHours < 0) { + iDays--, iHours += 24; + } + m_DateTime.Date.sDate.day = (uint8_t)iHours; + if (iDays != 0) { + AddDays(iDays); + } + return TRUE; +} +FX_BOOL CFX_DateTime::AddMinutes(int32_t iMinutes) { + if (iMinutes == 0) { + return FALSE; + } + iMinutes += m_DateTime.Time.sTime.minute; + int32_t iHours = iMinutes / 60; + iMinutes %= 60; + if (iMinutes < 0) { + iHours--, iMinutes += 60; + } + m_DateTime.Time.sTime.minute = (uint8_t)iMinutes; + if (iHours != 0) { + AddHours(iHours); + } + return TRUE; +} +FX_BOOL CFX_DateTime::AddSeconds(int32_t iSeconds) { + if (iSeconds == 0) { + return FALSE; + } + iSeconds += m_DateTime.Time.sTime.second; + int32_t iMinutes = iSeconds / 60; + iSeconds %= 60; + if (iSeconds < 0) { + iMinutes--, iSeconds += 60; + } + m_DateTime.Time.sTime.second = (uint8_t)iSeconds; + if (iMinutes != 0) { + AddMinutes(iMinutes); + } + return TRUE; +} +FX_BOOL CFX_DateTime::AddMilliseconds(int32_t iMilliseconds) { + if (iMilliseconds == 0) { + return FALSE; + } + iMilliseconds += m_DateTime.Time.sTime.millisecond; + int32_t iSeconds = (int32_t)(iMilliseconds / g_FXMillisecondsPerSecond); + iMilliseconds %= g_FXMillisecondsPerSecond; + if (iMilliseconds < 0) { + iSeconds--, iMilliseconds += g_FXMillisecondsPerSecond; + } + m_DateTime.Time.sTime.millisecond = (FX_WORD)iMilliseconds; + if (iSeconds != 0) { + AddSeconds(iSeconds); + } + return TRUE; +} diff --git a/xfa/fgas/localization/fgas_datetime.h b/xfa/fgas/localization/fgas_datetime.h new file mode 100644 index 0000000000..4aa5093006 --- /dev/null +++ b/xfa/fgas/localization/fgas_datetime.h @@ -0,0 +1,406 @@ +// 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_LOCALIZATION_FGAS_DATETIME_H_ +#define XFA_FGAS_LOCALIZATION_FGAS_DATETIME_H_ + +#include "core/include/fxcrt/fx_system.h" + +class CFX_Unitime; +class CFX_DateTime; + +typedef int64_t FX_UNITIME; +enum FX_WEEKDAY { + FX_Sunday = 0, + FX_Monday, + FX_Tuesday, + FX_Wednesday, + FX_Thursday, + FX_Friday, + FX_Saturday, +}; + +FX_BOOL FX_IsLeapYear(int32_t iYear); +int32_t FX_DaysInYear(int32_t iYear); +uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); + +class CFX_Unitime { + public: + CFX_Unitime() { m_iUnitime = 0; } + CFX_Unitime(FX_UNITIME iUnitime) { m_iUnitime = iUnitime; } + CFX_Unitime(const CFX_Unitime& unitime) { m_iUnitime = unitime.m_iUnitime; } + operator FX_UNITIME*() { return &m_iUnitime; } + operator FX_UNITIME const*() const { return &m_iUnitime; } + operator FX_UNITIME&() { return m_iUnitime; } + operator const FX_UNITIME&() const { return m_iUnitime; } + CFX_Unitime& operator=(const CFX_Unitime& t) { + m_iUnitime = t.m_iUnitime; + return *this; + } + CFX_Unitime& operator=(FX_UNITIME t) { + m_iUnitime = t; + return *this; + } + CFX_Unitime& operator+=(const CFX_Unitime& t) { + m_iUnitime += t.m_iUnitime; + return *this; + } + CFX_Unitime& operator+=(FX_UNITIME t) { + m_iUnitime += t; + return *this; + } + CFX_Unitime& operator-=(const CFX_Unitime& t) { + m_iUnitime -= t.m_iUnitime; + return *this; + } + CFX_Unitime& operator-=(FX_UNITIME t) { + m_iUnitime -= t; + return *this; + } + void Now(); + void SetGMTime(); + void Set(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour = 0, + uint8_t minute = 0, + uint8_t second = 0, + FX_WORD millisecond = 0); + void Set(FX_UNITIME t); + int32_t GetYear() const; + uint8_t GetMonth() const; + uint8_t GetDay() const; + FX_WEEKDAY GetDayOfWeek() const; + FX_WORD GetDayOfYear() const; + int64_t GetDayOfAD() const; + uint8_t GetHour() const; + uint8_t GetMinute() const; + uint8_t GetSecond() const; + FX_WORD GetMillisecond() const; + FX_BOOL AddYears(int32_t iYears); + FX_BOOL AddMonths(int32_t iMonths); + FX_BOOL AddDays(int32_t iDays); + FX_BOOL AddHours(int32_t iHours); + FX_BOOL AddMinutes(int32_t iMinutes); + FX_BOOL AddSeconds(int32_t iSeconds); + FX_BOOL AddMilliseconds(int32_t iMilliseconds); + friend CFX_Unitime operator+(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime); + } + friend CFX_Unitime operator+(const CFX_Unitime& t1, FX_UNITIME t2) { + return CFX_Unitime(t1.m_iUnitime + t2); + } + friend CFX_Unitime operator+(FX_UNITIME t1, const CFX_Unitime& t2) { + return CFX_Unitime(t1 + t2.m_iUnitime); + } + friend CFX_Unitime operator-(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime); + } + friend CFX_Unitime operator-(const CFX_Unitime& t1, FX_UNITIME t2) { + return CFX_Unitime(t1.m_iUnitime + t2); + } + friend CFX_Unitime operator-(FX_UNITIME t1, const CFX_Unitime& t2) { + return CFX_Unitime(t1 + t2.m_iUnitime); + } + friend bool operator==(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime == t2.m_iUnitime; + } + friend bool operator==(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime == t2; + } + friend bool operator==(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 == t2.m_iUnitime; + } + friend bool operator!=(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime != t2.m_iUnitime; + } + friend bool operator!=(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime != t2; + } + friend bool operator!=(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 != t2.m_iUnitime; + } + friend bool operator>(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime > t2.m_iUnitime; + } + friend bool operator>(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime > t2; + } + friend bool operator>(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 > t2.m_iUnitime; + } + friend bool operator>=(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime >= t2.m_iUnitime; + } + friend bool operator>=(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime >= t2; + } + friend bool operator>=(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 >= t2.m_iUnitime; + } + friend bool operator<(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime < t2.m_iUnitime; + } + friend bool operator<(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime < t2; + } + friend bool operator<(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 < t2.m_iUnitime; + } + friend bool operator<=(const CFX_Unitime& t1, const CFX_Unitime& t2) { + return t1.m_iUnitime <= t2.m_iUnitime; + } + friend bool operator<=(const CFX_Unitime& t1, FX_UNITIME t2) { + return t1.m_iUnitime <= t2; + } + friend bool operator<=(FX_UNITIME t1, const CFX_Unitime& t2) { + return t1 <= t2.m_iUnitime; + } + + private: + FX_UNITIME m_iUnitime; +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +struct FX_DATE { + int32_t year; + uint8_t month; + uint8_t day; +}; + +struct FX_TIME { + uint8_t hour; + uint8_t minute; + uint8_t second; + FX_WORD millisecond; +}; + +struct FX_TIMEZONE { + int8_t tzHour; + uint8_t tzMinute; +}; + +struct FX_DATETIME { + union { + struct { + int32_t year; + uint8_t month; + uint8_t day; + } sDate; + FX_DATE aDate; + } Date; + union { + struct { + uint8_t hour; + uint8_t minute; + uint8_t second; + FX_WORD millisecond; + } sTime; + FX_TIME aTime; + } 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; + FX_WORD 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 + +class CFX_DateTime { + public: + CFX_DateTime() {} + CFX_DateTime(const FX_DATETIME& dt) { m_DateTime = dt; } + CFX_DateTime(const CFX_DateTime& dt) { m_DateTime = dt.m_DateTime; } + virtual ~CFX_DateTime() {} + operator FX_DATETIME*() { return &m_DateTime; } + operator const FX_DATETIME*() const { return &m_DateTime; } + operator FX_DATETIME&() { return m_DateTime; } + operator const FX_DATETIME&() const { return m_DateTime; } + CFX_DateTime& operator=(const CFX_DateTime& dt) { + m_DateTime = dt.m_DateTime; + return *this; + } + CFX_DateTime& operator=(const FX_DATETIME& dt) { + m_DateTime = dt; + return *this; + } + CFX_DateTime& operator+=(const CFX_DateTime& dt) { + FromUnitime(ToUnitime() + dt.ToUnitime()); + return *this; + } + CFX_DateTime& operator+=(const FX_DATETIME& dt) { + FromUnitime(ToUnitime() + ((const CFX_DateTime&)dt).ToUnitime()); + return *this; + } + CFX_DateTime& operator-=(const CFX_DateTime& dt) { + FromUnitime(ToUnitime() - dt.ToUnitime()); + return *this; + } + CFX_DateTime& operator-=(const FX_DATETIME& dt) { + FromUnitime(ToUnitime() - ((const CFX_DateTime&)dt).ToUnitime()); + return *this; + } + virtual FX_BOOL Set(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour = 0, + uint8_t minute = 0, + uint8_t second = 0, + FX_WORD millisecond = 0); + virtual FX_BOOL FromUnitime(FX_UNITIME t); + virtual FX_UNITIME ToUnitime() const; + virtual int32_t GetYear() const; + virtual uint8_t GetMonth() const; + virtual uint8_t GetDay() const; + virtual FX_WEEKDAY GetDayOfWeek() const; + virtual FX_WORD GetDayOfYear() const; + virtual int64_t GetDayOfAD() const; + virtual uint8_t GetHour() const; + virtual uint8_t GetMinute() const; + virtual uint8_t GetSecond() const; + virtual FX_WORD GetMillisecond() const; + virtual FX_BOOL AddYears(int32_t iYears); + virtual FX_BOOL AddMonths(int32_t iMonths); + virtual FX_BOOL AddDays(int32_t iDays); + virtual FX_BOOL AddHours(int32_t iHours); + virtual FX_BOOL AddMinutes(int32_t iMinutes); + virtual FX_BOOL AddSeconds(int32_t iSeconds); + virtual FX_BOOL AddMilliseconds(int32_t iMilliseconds); + friend CFX_DateTime operator+(const CFX_DateTime& dt1, + const CFX_DateTime& dt2) { + CFX_DateTime dt; + dt.FromUnitime(dt1.ToUnitime() + dt2.ToUnitime()); + return dt; + } + friend CFX_DateTime operator+(const CFX_DateTime& dt1, + const FX_DATETIME& dt2) { + CFX_DateTime dt; + dt.FromUnitime(dt1.ToUnitime() + ((const CFX_DateTime&)dt2).ToUnitime()); + return dt; + } + friend CFX_DateTime operator+(const FX_DATETIME& dt1, + const CFX_DateTime& dt2) { + CFX_DateTime dt; + dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() + dt2.ToUnitime()); + return dt; + } + friend CFX_DateTime operator-(const CFX_DateTime& dt1, + const CFX_DateTime& dt2) { + CFX_DateTime dt; + dt.FromUnitime(dt1.ToUnitime() - dt2.ToUnitime()); + return dt; + } + friend CFX_DateTime operator-(const CFX_DateTime& dt1, + const FX_DATETIME& dt2) { + CFX_DateTime dt; + dt.FromUnitime(dt1.ToUnitime() - ((const CFX_DateTime&)dt2).ToUnitime()); + return dt; + } + friend CFX_DateTime operator-(const FX_DATETIME& dt1, + const CFX_DateTime& dt2) { + CFX_DateTime dt; + dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() - dt2.ToUnitime()); + return dt; + } + friend FX_BOOL operator==(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), + static_cast<const FX_DATETIME*>(dt2), + sizeof(FX_DATETIME)) == 0; + } + friend FX_BOOL operator==(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), &dt2, + sizeof(FX_DATETIME)) == 0; + } + friend FX_BOOL operator==(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return FXSYS_memcmp(&dt1, static_cast<const FX_DATETIME*>(dt2), + sizeof(FX_DATETIME)) == 0; + } + friend FX_BOOL operator!=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), + static_cast<const FX_DATETIME*>(dt2), + sizeof(FX_DATETIME)) != 0; + } + friend FX_BOOL operator!=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), &dt2, + sizeof(FX_DATETIME)) != 0; + } + friend FX_BOOL operator!=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return FXSYS_memcmp(&dt1, static_cast<const FX_DATETIME*>(dt2), + sizeof(FX_DATETIME)) != 0; + } + friend FX_BOOL operator>(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return dt1.ToUnitime() > dt2.ToUnitime(); + } + friend FX_BOOL operator>(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return dt1.ToUnitime() > ((const CFX_DateTime&)dt2).ToUnitime(); + } + friend FX_BOOL operator>(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return ((const CFX_DateTime&)dt1).ToUnitime() > dt2.ToUnitime(); + } + friend FX_BOOL operator>=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return dt1.ToUnitime() >= dt2.ToUnitime(); + } + friend FX_BOOL operator>=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return dt1.ToUnitime() >= ((const CFX_DateTime&)dt2).ToUnitime(); + } + friend FX_BOOL operator>=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return ((const CFX_DateTime&)dt1).ToUnitime() >= dt2.ToUnitime(); + } + friend FX_BOOL operator<(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return dt1.ToUnitime() < dt2.ToUnitime(); + } + friend FX_BOOL operator<(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return dt1.ToUnitime() < ((const CFX_DateTime&)dt2).ToUnitime(); + } + friend FX_BOOL operator<(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return ((const CFX_DateTime&)dt1).ToUnitime() < dt2.ToUnitime(); + } + friend FX_BOOL operator<=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { + return dt1.ToUnitime() <= dt2.ToUnitime(); + } + friend FX_BOOL operator<=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { + return dt1.ToUnitime() <= ((const CFX_DateTime&)dt2).ToUnitime(); + } + friend FX_BOOL operator<=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { + return ((const CFX_DateTime&)dt1).ToUnitime() <= dt2.ToUnitime(); + } + + private: + FX_DATETIME m_DateTime; +}; + +#endif // XFA_FGAS_LOCALIZATION_FGAS_DATETIME_H_ diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp new file mode 100644 index 0000000000..6af9205d30 --- /dev/null +++ b/xfa/fgas/localization/fgas_locale.cpp @@ -0,0 +1,5030 @@ +// 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 <algorithm> + +#include "core/include/fxcrt/fx_ext.h" +#include "core/include/fxcrt/fx_xml.h" +#include "xfa/fgas/localization/fgas_localeimp.h" + +#define FX_LOCALECATEGORY_DateHash 0xbde9abde +#define FX_LOCALECATEGORY_TimeHash 0x2d71b00f +#define FX_LOCALECATEGORY_DateTimeHash 0x158c72ed +#define FX_LOCALECATEGORY_NumHash 0x0b4ff870 +#define FX_LOCALECATEGORY_TextHash 0x2d08af85 +#define FX_LOCALECATEGORY_ZeroHash 0x568cb500 +#define FX_LOCALECATEGORY_NullHash 0x052931bb + +struct FX_LOCALESUBCATEGORYINFO { + uint32_t uHash; + const FX_WCHAR* pName; + int32_t eSubCategory; +}; + +static const FX_LOCALESUBCATEGORYINFO g_FXLocaleDateTimeSubCatData[] = { + {0x14da2125, L"default", FX_LOCALEDATETIMESUBCATEGORY_Default}, + {0x9041d4b0, L"short", FX_LOCALEDATETIMESUBCATEGORY_Short}, + {0xa084a381, L"medium", FX_LOCALEDATETIMESUBCATEGORY_Medium}, + {0xcdce56b3, L"full", FX_LOCALEDATETIMESUBCATEGORY_Full}, + {0xf6b4afb0, L"long", FX_LOCALEDATETIMESUBCATEGORY_Long}, +}; +static const int32_t g_iFXLocaleDateTimeSubCatCount = + sizeof(g_FXLocaleDateTimeSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); + +static const FX_LOCALESUBCATEGORYINFO g_FXLocaleNumSubCatData[] = { + {0x46f95531, L"percent", FX_LOCALENUMPATTERN_Percent}, + {0x4c4e8acb, L"currency", FX_LOCALENUMPATTERN_Currency}, + {0x54034c2f, L"decimal", FX_LOCALENUMPATTERN_Decimal}, + {0x7568e6ae, L"integer", FX_LOCALENUMPATTERN_Integer}, +}; +static const int32_t g_iFXLocaleNumSubCatCount = + sizeof(g_FXLocaleNumSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); + +struct FX_LOCALETIMEZONEINFO { + FX_DWORD uHash; + int16_t iHour; + int16_t iMinute; +}; + +static const FX_LOCALETIMEZONEINFO g_FXLocaleTimeZoneData[] = { + {FXBSTR_ID(0, 'C', 'D', 'T'), -5, 0}, {FXBSTR_ID(0, 'C', 'S', 'T'), -6, 0}, + {FXBSTR_ID(0, 'E', 'D', 'T'), -4, 0}, {FXBSTR_ID(0, 'E', 'S', 'T'), -5, 0}, + {FXBSTR_ID(0, 'M', 'D', 'T'), -6, 0}, {FXBSTR_ID(0, 'M', 'S', 'T'), -7, 0}, + {FXBSTR_ID(0, 'P', 'D', 'T'), -7, 0}, {FXBSTR_ID(0, 'P', 'S', 'T'), -8, 0}, +}; + +static const CFX_WideStringC gs_wsTextSymbols = FX_WSTRC(L"AXO09"); +static const CFX_WideStringC gs_wsTimeSymbols = FX_WSTRC(L"hHkKMSFAzZ"); +static const CFX_WideStringC gs_wsDateSymbols = FX_WSTRC(L"DJMEeGgYwW"); +static const CFX_WideStringC gs_wsConstChars = FX_WSTRC(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.GetPtr() + nStart, ch); + return (lpsz == NULL) ? -1 : (FX_STRSIZE)(lpsz - wsSymbols.GetPtr()); +} +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); +} +CFX_Locale::CFX_Locale(CXML_Element* pLocaleData) { + m_pElement = pLocaleData; +} +CFX_Locale::~CFX_Locale() {} +CFX_WideString CFX_Locale::GetName() { + return CFX_WideString(); +} +static CFX_WideString FX_GetXMLContent(const CFX_ByteStringC& bsSpace, + CXML_Element* pxmlElement, + const CFX_ByteStringC& bsTag, + const CFX_WideStringC& wsName) { + CXML_Element* pDatePattern = NULL; + int32_t nCount = pxmlElement->CountElements(bsSpace, bsTag); + int32_t i = 0; + for (; i < nCount; i++) { + pDatePattern = pxmlElement->GetElement(bsSpace, bsTag, i); + if (pDatePattern->GetAttrValue("name") == wsName) { + break; + } + } + if (i < nCount && pDatePattern) { + return pDatePattern->GetContent(0); + } + return L""; +} +void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const { + if (!m_pElement) { + return; + } + CFX_ByteString bsSpace; + CFX_WideString wsName = gs_LocalNumberSymbols[eType]; + CXML_Element* pNumberSymbols = + m_pElement->GetElement(bsSpace, "numberSymbols"); + if (!pNumberSymbols) { + return; + } + wsNumSymbol = + FX_GetXMLContent(bsSpace, pNumberSymbols, "numberSymbol", wsName); +} +void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { + if (!m_pElement) { + return; + } + CFX_ByteString bsSpace; + CXML_Element* pNumberSymbols = + m_pElement->GetElement(bsSpace, "dateTimeSymbols"); + if (!pNumberSymbols) { + return; + } + wsDtSymbol = pNumberSymbols->GetContent(0); +} +static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, + const CFX_ByteString& symbol_type, + int32_t index, + FX_BOOL bAbbr, + CFX_WideString& wsName) { + CFX_ByteString bsSpace; + CFX_ByteString pstrSymbolNames = symbol_type + "Names"; + CXML_Element* pChild = pXmlElement->GetElement(bsSpace, "calendarSymbols"); + if (!pChild) { + return; + } + CXML_Element* pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames); + if (!pSymbolNames) { + return; + } + if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { + pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames, 1); + } + if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { + CXML_Element* pSymbolName = + pSymbolNames->GetElement(bsSpace, symbol_type, index); + if (pSymbolName) { + wsName = pSymbolName->GetContent(0); + } + } +} +void CFX_Locale::GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr) const { + if (!m_pElement) { + return; + } + FX_GetCalendarSymbol(m_pElement, "month", nMonth, bAbbr, wsMonthName); +} +void CFX_Locale::GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr) const { + if (!m_pElement) { + return; + } + FX_GetCalendarSymbol(m_pElement, "day", nWeek, bAbbr, wsDayName); +} +void CFX_Locale::GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM) const { + if (!m_pElement) { + return; + } + FX_GetCalendarSymbol(m_pElement, "meridiem", bAM ? 0 : 1, FALSE, + wsMeridiemName); +} +static int32_t FX_ParseTimeZone(const FX_WCHAR* pStr, + int32_t iLen, + FX_TIMEZONE& tz) { + tz.tzHour = 0; + tz.tzMinute = 0; + if (iLen < 0) { + return 0; + } + int32_t iStart = 1; + int32_t iEnd = iStart + 2; + while (iStart < iLen && iStart < iEnd) { + tz.tzHour = tz.tzHour * 10 + pStr[iStart++] - '0'; + } + if (iStart < iLen && pStr[iStart] == ':') { + iStart++; + } + iEnd = iStart + 2; + while (iStart < iLen && iStart < iEnd) { + tz.tzMinute = tz.tzMinute * 10 + pStr[iStart++] - '0'; + } + if (pStr[0] == '-') { + tz.tzHour = -tz.tzHour; + } + return iStart; +} +void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { + tz.tzHour = 0; + tz.tzMinute = 0; + if (!m_pElement) { + return; + } + CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone"); + if (pxmlTimeZone) { + CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); + FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz); + } +} +void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { + if (!m_pElement) { + return; + } + FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); +} +static void FX_GetPattern(CXML_Element* pXmlElement, + const CFX_ByteString& bsCategory, + const CFX_WideString& wsSubCategory, + CFX_WideString& wsPattern) { + CFX_ByteString bsSpace; + CXML_Element* pDatePatterns = + pXmlElement->GetElement(bsSpace, bsCategory + "s"); + if (!pDatePatterns) { + return; + } + wsPattern = + FX_GetXMLContent(bsSpace, pDatePatterns, bsCategory, wsSubCategory); +} +static void FX_GetDateTimePattern(CXML_Element* pXmlElement, + const CFX_ByteString& bsCategory, + FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) { + CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; + FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); +} +void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + if (!m_pElement) { + return; + } + FX_GetDateTimePattern(m_pElement, "datePattern", eType, wsPattern); +} +void CFX_Locale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + if (!m_pElement) { + return; + } + FX_GetDateTimePattern(m_pElement, "timePattern", eType, wsPattern); +} +void CFX_Locale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const { + CFX_WideString wsType = g_FXLocaleNumSubCatData[eType].pName; + FX_GetPattern(m_pElement, "numberPattern", wsType, wsPattern); +} +static FX_BOOL FX_IsDigit(FX_WCHAR c) { + return c >= '0' && c <= '9'; +} +static FX_BOOL FX_IsAlpha(FX_WCHAR c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} +static FX_BOOL FX_IsSpace(FX_WCHAR c) { + return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09); +} +static const FX_FLOAT gs_fraction_scales[] = { + 0.1f, 0.01f, 0.001f, 0.0001f, + 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, + 0.000000001f, 0.0000000001f, 0.00000000001f}; +static const int32_t gs_fraction_count = + sizeof(gs_fraction_scales) / sizeof(FX_FLOAT); + +class CFX_LCNumeric { + public: + CFX_LCNumeric(); + CFX_LCNumeric(int64_t integral, + uint32_t fractional = 0, + int32_t exponent = 0); + CFX_LCNumeric(FX_FLOAT dbRetValue); + CFX_LCNumeric(double dbvalue); + CFX_LCNumeric(CFX_WideString& wsNumeric); + + FX_FLOAT GetFloat() const; + double GetDouble() const; + CFX_WideString ToString() const; + CFX_WideString ToString(int32_t nTreading, FX_BOOL bTrimTailZeros) const; + + int64_t m_Integral; + uint32_t m_Fractional; + int32_t m_Exponent; +}; + +static FX_BOOL FX_WStringToNumeric(const CFX_WideString& wsValue, + CFX_LCNumeric& lcnum) { + lcnum.m_Integral = 0; + lcnum.m_Fractional = 0; + lcnum.m_Exponent = 0; + + if (wsValue.IsEmpty()) + return FALSE; + + const int32_t nIntegralMaxLen = 17; + int32_t cc = 0; + bool bNegative = false; + bool bExpSign = false; + const FX_WCHAR* str = (const FX_WCHAR*)wsValue; + int32_t len = wsValue.GetLength(); + while (cc < len && FX_IsSpace(str[cc])) + cc++; + + if (cc >= len) + return FALSE; + + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bNegative = true; + cc++; + } + int32_t nIntegralLen = 0; + while (cc < len) { + if (str[cc] == '.') + break; + + if (!FX_IsDigit(str[cc])) { + if ((str[cc] == 'E' || str[cc] == 'e')) + break; + else + return FALSE; + } + if (nIntegralLen < nIntegralMaxLen) { + lcnum.m_Integral = lcnum.m_Integral * 10 + str[cc] - '0'; + nIntegralLen++; + } + cc++; + } + + lcnum.m_Integral = bNegative ? -lcnum.m_Integral : lcnum.m_Integral; + if (cc < len && str[cc] == '.') { + int scale = 0; + double fraction = 0.0; + cc++; + while (cc < len) { + if (scale >= gs_fraction_count) { + while (cc < len) { + if (!FX_IsDigit(str[cc])) + break; + cc++; + } + } + if (!FX_IsDigit(str[cc])) { + if ((str[cc] == 'E' || str[cc] == 'e')) + break; + else + return FALSE; + } + fraction += gs_fraction_scales[scale] * (str[cc] - '0'); + scale++; + cc++; + } + lcnum.m_Fractional = (FX_DWORD)(fraction * 4294967296.0); + } + if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = true; + cc++; + } + } + while (cc < len) { + if (FX_IsDigit(str[cc])) + return FALSE; + lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; + cc++; + } + lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; + } + return TRUE; +} + +CFX_LCNumeric::CFX_LCNumeric() { + m_Integral = 0; + m_Fractional = 0; + m_Exponent = 0; +} +CFX_LCNumeric::CFX_LCNumeric(int64_t integral, + FX_DWORD fractional, + int32_t exponent) { + m_Integral = integral; + m_Fractional = fractional; + m_Exponent = exponent; +} +CFX_LCNumeric::CFX_LCNumeric(FX_FLOAT dbRetValue) { + m_Integral = (int64_t)dbRetValue; + m_Fractional = (FX_DWORD)(((dbRetValue > 0) ? (dbRetValue - m_Integral) + : (m_Integral - dbRetValue)) * + 4294967296); + m_Exponent = 0; +} +CFX_LCNumeric::CFX_LCNumeric(double dbvalue) { + m_Integral = (int64_t)dbvalue; + m_Fractional = (FX_DWORD)( + ((dbvalue > 0) ? (dbvalue - m_Integral) : (m_Integral - dbvalue)) * + 4294967296); + m_Exponent = 0; +} +CFX_LCNumeric::CFX_LCNumeric(CFX_WideString& wsNumeric) { + FX_WStringToNumeric(wsNumeric, *this); +} +FX_FLOAT CFX_LCNumeric::GetFloat() const { + FX_FLOAT dbRetValue = m_Fractional / 4294967296.0f; + dbRetValue = m_Integral + (m_Integral >= 0 ? dbRetValue : -dbRetValue); + if (m_Exponent != 0) { + dbRetValue *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); + } + return dbRetValue; +} +double CFX_LCNumeric::GetDouble() const { + double value = m_Fractional / 4294967296.0; + value = m_Integral + (m_Integral >= 0 ? value : -value); + if (m_Exponent != 0) { + value *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); + } + return value; +} + +CFX_WideString CFX_LCNumeric::ToString() const { + return ToString(8, TRUE); +} + +CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading, + FX_BOOL bTrimTailZeros) const { + CFX_WideString wsFormat; + wsFormat.Format(L"%%.%df", nTreading); + CFX_WideString wsResult; + wsResult.Format(wsFormat.c_str(), GetDouble()); + if (bTrimTailZeros && nTreading > 0) { + wsResult.TrimRight(L"0"); + wsResult.TrimRight(L"."); + } + 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* pToken = pStr; + const FX_WCHAR* pEnd = pStr + iStrLen; + FX_BOOL iQuote = FALSE; + while (TRUE) { + if (pStr >= pEnd) { + CFX_WideString sub(pToken, pStr - pToken); + wsPatterns.Add(sub); + return; + } else if (*pStr == '\'') { + iQuote = !iQuote; + } else if (*pStr == L'|' && !iQuote) { + CFX_WideString sub(pToken, pStr - pToken); + wsPatterns.Add(sub); + pToken = pStr + 1; + } + pStr++; + } +} +static CFX_WideString FX_GetLiteralText(const FX_WCHAR* pStrPattern, + int32_t& iPattern, + int32_t iLenPattern) { + CFX_WideString wsOutput; + if (pStrPattern[iPattern] != '\'') { + return wsOutput; + } + iPattern++; + int32_t iQuote = 1; + while (iPattern < iLenPattern) { + if (pStrPattern[iPattern] == '\'') { + iQuote++; + if ((iPattern + 1 >= iLenPattern) || + ((pStrPattern[iPattern + 1] != '\'') && (iQuote % 2 == 0))) { + break; + } else { + iQuote++; + } + iPattern++; + } else if (pStrPattern[iPattern] == '\\' && (iPattern + 1 < iLenPattern) && + pStrPattern[iPattern + 1] == 'u') { + int32_t iKeyValue = 0; + iPattern += 2; + int32_t i = 0; + while (iPattern < iLenPattern && i++ < 4) { + FX_WCHAR ch = pStrPattern[iPattern++]; + if ((ch >= '0' && ch <= '9')) { + iKeyValue = iKeyValue * 16 + ch - '0'; + } else if ((ch >= 'a' && ch <= 'f')) { + iKeyValue = iKeyValue * 16 + ch - 'a' + 10; + } else if ((ch >= 'A' && ch <= 'F')) { + iKeyValue = iKeyValue * 16 + ch - 'A' + 10; + } + } + if (iKeyValue != 0) { + wsOutput += (FX_WCHAR)(iKeyValue & 0x0000FFFF); + } + continue; + } + wsOutput += pStrPattern[iPattern++]; + } + return wsOutput; +} +static CFX_WideString FX_GetLiteralTextReverse(const FX_WCHAR* pStrPattern, + int32_t& iPattern) { + CFX_WideString wsOutput; + if (pStrPattern[iPattern] != '\'') { + return wsOutput; + } + iPattern--; + int32_t iQuote = 1; + while (iPattern >= 0) { + if (pStrPattern[iPattern] == '\'') { + iQuote++; + if (iPattern - 1 >= 0 || + ((pStrPattern[iPattern - 1] != '\'') && (iQuote % 2 == 0))) { + break; + } else { + iQuote++; + } + iPattern--; + } else if (pStrPattern[iPattern] == '\\' && + pStrPattern[iPattern + 1] == 'u') { + iPattern--; + int32_t iKeyValue = 0; + int32_t iLen = wsOutput.GetLength(); + int32_t i = 1; + for (; i < iLen && i < 5; i++) { + FX_WCHAR ch = wsOutput[i]; + if ((ch >= '0' && ch <= '9')) { + iKeyValue = iKeyValue * 16 + ch - '0'; + } else if ((ch >= 'a' && ch <= 'f')) { + iKeyValue = iKeyValue * 16 + ch - 'a' + 10; + } else if ((ch >= 'A' && ch <= 'F')) { + iKeyValue = iKeyValue * 16 + ch - 'A' + 10; + } + } + if (iKeyValue != 0) { + wsOutput.Delete(0, i); + wsOutput = (FX_WCHAR)(iKeyValue & 0x0000FFFF) + wsOutput; + } + continue; + } + wsOutput = pStrPattern[iPattern--] + wsOutput; + } + return wsOutput; +} +FX_LOCALECATEGORY CFX_FormatString::GetCategory( + const CFX_WideString& wsPattern) { + FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; + int32_t ccf = 0; + int32_t iLenf = wsPattern.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; + FX_BOOL bBraceOpen = FALSE; + while (ccf < iLenf) { + if (pStr[ccf] == '\'') { + FX_GetLiteralText(pStr, ccf, iLenf); + } else if (!bBraceOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { + CFX_WideString wsCategory(pStr[ccf]); + ccf++; + while (TRUE) { + if (ccf == iLenf) { + return eCategory; + } + if (pStr[ccf] == '.' || pStr[ccf] == '(') { + break; + } + if (pStr[ccf] == '{') { + bBraceOpen = TRUE; + break; + } + wsCategory += pStr[ccf]; + ccf++; + } + FX_DWORD dwHash = + FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength()); + if (dwHash == FX_LOCALECATEGORY_DateHash) { + if (eCategory == FX_LOCALECATEGORY_Time) { + return FX_LOCALECATEGORY_DateTime; + } + eCategory = FX_LOCALECATEGORY_Date; + } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { + if (eCategory == FX_LOCALECATEGORY_Date) { + return FX_LOCALECATEGORY_DateTime; + } + eCategory = FX_LOCALECATEGORY_Time; + } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { + return FX_LOCALECATEGORY_DateTime; + } else if (dwHash == FX_LOCALECATEGORY_TextHash) { + return FX_LOCALECATEGORY_Text; + } else if (dwHash == FX_LOCALECATEGORY_NumHash) { + return FX_LOCALECATEGORY_Num; + } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { + return FX_LOCALECATEGORY_Zero; + } else if (dwHash == FX_LOCALECATEGORY_NullHash) { + return FX_LOCALECATEGORY_Null; + } + } else if (pStr[ccf] == '}') { + bBraceOpen = FALSE; + } + ccf++; + } + return eCategory; +} +static FX_WORD FX_WStringToLCID(const FX_WCHAR* pstrLCID) { + if (!pstrLCID) { + return 0; + } + wchar_t* pEnd; + return (FX_WORD)wcstol((wchar_t*)pstrLCID, &pEnd, 16); +} +FX_WORD CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { + return FX_WStringToLCID(GetLocaleName(wsPattern)); +} +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; + while (ccf < iLenf) { + if (pStr[ccf] == '\'') { + FX_GetLiteralText(pStr, ccf, iLenf); + } else if (pStr[ccf] == '(') { + ccf++; + CFX_WideString wsLCID; + while (ccf < iLenf && pStr[ccf] != ')') { + wsLCID += pStr[ccf++]; + } + return wsLCID; + } + ccf++; + } + return CFX_WideString(); +} +IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, + const CFX_WideStringC& wsCategory, + CFX_WideString& wsPurgePattern) { + IFX_Locale* pLocale = NULL; + int32_t ccf = 0; + int32_t iLenf = wsPattern.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; + FX_BOOL bBrackOpen = FALSE; + 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) { + CFX_WideString wsSearchCategory(pStr[ccf]); + ccf++; + while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && + pStr[ccf] != '(') { + wsSearchCategory += pStr[ccf]; + ccf++; + } + if (wsSearchCategory != wsCategory) { + continue; + } + while (ccf < iLenf) { + if (pStr[ccf] == '(') { + ccf++; + CFX_WideString wsLCID; + while (ccf < iLenf && pStr[ccf] != ')') { + wsLCID += pStr[ccf++]; + } + pLocale = GetPatternLocale(wsLCID); + } else if (pStr[ccf] == '{') { + bBrackOpen = TRUE; + break; + } + ccf++; + } + } else if (pStr[ccf] != '}') { + wsPurgePattern += pStr[ccf]; + } + ccf++; + } + if (!bBrackOpen) { + wsPurgePattern = wsPattern; + } + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + return pLocale; +} +#define FX_NUMSTYLE_Percent 0x01 +#define FX_NUMSTYLE_Exponent 0x02 +#define FX_NUMSTYLE_DotVorv 0x04 +IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, + int32_t& iDotIndex, + FX_DWORD& dwStyle, + CFX_WideString& wsPurgePattern) { + dwStyle = 0; + IFX_Locale* pLocale = NULL; + int32_t ccf = 0; + int32_t iLenf = wsPattern.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; + FX_BOOL bFindDot = FALSE; + FX_BOOL bBrackOpen = FALSE; + 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) { + CFX_WideString wsCategory(pStr[ccf]); + ccf++; + while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && + pStr[ccf] != '(') { + wsCategory += pStr[ccf]; + ccf++; + } + if (wsCategory != FX_WSTRC(L"num")) { + bBrackOpen = TRUE; + ccf = 0; + continue; + } + while (ccf < iLenf) { + if (pStr[ccf] == '(') { + ccf++; + CFX_WideString wsLCID; + while (ccf < iLenf && pStr[ccf] != ')') { + wsLCID += pStr[ccf++]; + } + pLocale = GetPatternLocale(wsLCID); + } else if (pStr[ccf] == '{') { + bBrackOpen = TRUE; + break; + } else if (pStr[ccf] == '.') { + CFX_WideString wsSubCategory; + ccf++; + while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { + wsSubCategory += pStr[ccf++]; + } + FX_DWORD dwSubHash = + FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); + FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; + for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { + if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { + eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] + .eSubCategory; + break; + } + } + wsSubCategory.Empty(); + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + FXSYS_assert(pLocale != NULL); + pLocale->GetNumPattern(eSubCategory, wsSubCategory); + iDotIndex = wsSubCategory.Find('.'); + if (iDotIndex > 0) { + iDotIndex += wsPurgePattern.GetLength(); + bFindDot = TRUE; + dwStyle |= FX_NUMSTYLE_DotVorv; + } + wsPurgePattern += wsSubCategory; + if (eSubCategory == FX_LOCALENUMPATTERN_Percent) { + dwStyle |= FX_NUMSTYLE_Percent; + } + continue; + } + ccf++; + } + } else if (pStr[ccf] == 'E') { + dwStyle |= FX_NUMSTYLE_Exponent; + wsPurgePattern += pStr[ccf]; + } else if (pStr[ccf] == '%') { + dwStyle |= FX_NUMSTYLE_Percent; + wsPurgePattern += pStr[ccf]; + } else if (pStr[ccf] != '}') { + wsPurgePattern += pStr[ccf]; + } + if (!bFindDot) { + if (pStr[ccf] == '.' || pStr[ccf] == 'V' || pStr[ccf] == 'v') { + bFindDot = TRUE; + iDotIndex = wsPurgePattern.GetLength() - 1; + dwStyle |= FX_NUMSTYLE_DotVorv; + } + } + ccf++; + } + if (!bFindDot) { + iDotIndex = wsPurgePattern.GetLength(); + } + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + return pLocale; +} +static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum, + const CFX_WideString& wsDotSymbol, + int32_t& iDotIndex) { + int32_t ccf = 0; + int32_t iLenf = wsNum.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; + 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)) { + iDotIndex = ccf; + return TRUE; + } + ccf++; + } + iDotIndex = wsNum.Find('.'); + if (iDotIndex < 0) { + iDotIndex = iLenf; + return FALSE; + } + return TRUE; +} +FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, + const CFX_WideString& wsPattern, + CFX_WideString& wsValue) { + wsValue.Empty(); + if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsTextFormat; + GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); + if (wsTextFormat.IsEmpty()) { + return FALSE; + } + int32_t iText = 0, iPattern = 0; + const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; + int32_t iLenText = wsSrcText.GetLength(); + const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern && iText < iLenText) { + switch (pStrPattern[iPattern]) { + case '\'': { + CFX_WideString wsLiteral = + FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + int32_t iLiteralLen = wsLiteral.GetLength(); + if (iText + iLiteralLen > iLenText || + FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, + iLiteralLen)) { + wsValue = wsSrcText; + return FALSE; + } + iText += iLiteralLen; + iPattern++; + break; + } + case 'A': + if (FX_IsAlpha(pStrText[iText])) { + wsValue += pStrText[iText]; + iText++; + } + iPattern++; + break; + case 'X': + wsValue += pStrText[iText]; + iText++; + iPattern++; + break; + case 'O': + case '0': + if (FX_IsDigit(pStrText[iText]) || FX_IsAlpha(pStrText[iText])) { + wsValue += pStrText[iText]; + iText++; + } + iPattern++; + break; + case '9': + if (FX_IsDigit(pStrText[iText])) { + wsValue += pStrText[iText]; + iText++; + } + iPattern++; + break; + default: + if (pStrPattern[iPattern] != pStrText[iText]) { + wsValue = wsSrcText; + return FALSE; + } + iPattern++; + iText++; + break; + } + } + return iPattern == iLenPattern && iText == iLenText; +} +FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, + const CFX_WideString& wsPattern, + FX_FLOAT& fValue) { + fValue = 0.0f; + if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + int32_t dot_index_f = -1; + FX_DWORD dwFormatStyle = 0; + CFX_WideString wsNumFormat; + IFX_Locale* pLocale = + GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); + if (!pLocale || wsNumFormat.IsEmpty()) { + return FALSE; + } + int32_t iExponent = 0; + CFX_WideString wsDotSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); + CFX_WideString wsGroupSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); + int32_t iGroupLen = wsGroupSymbol.GetLength(); + CFX_WideString wsMinus; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); + int32_t iMinusLen = wsMinus.GetLength(); + int cc = 0, ccf = 0; + const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; + int len = wsSrcNum.GetLength(); + const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; + int lenf = wsNumFormat.GetLength(); + double dbRetValue = 0; + double coeff = 1; + FX_BOOL bHavePercentSymbol = FALSE; + FX_BOOL bNeg = FALSE; + FX_BOOL bReverseParse = FALSE; + int32_t dot_index = 0; + if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && + (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { + bReverseParse = TRUE; + } + bReverseParse = FALSE; + if (bReverseParse) { + ccf = lenf - 1; + cc = len - 1; + while (ccf > dot_index_f && cc >= 0) { + switch (strf[ccf]) { + case '\'': { + 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)) { + return FALSE; + } + cc--; + ccf--; + break; + } + case '9': + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; + coeff *= 0.1; + cc--; + ccf--; + break; + case 'z': + if (cc >= 0) { + dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; + coeff *= 0.1; + cc--; + } + ccf--; + break; + case 'Z': + if (str[cc] != ' ') { + dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; + coeff *= 0.1; + } + cc--; + ccf--; + break; + case 'S': + if (str[cc] == '+' || str[cc] == ' ') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 's': + if (str[cc] == '+') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 'E': { + if (cc >= dot_index) { + return FALSE; + } + FX_BOOL bExpSign = FALSE; + while (cc >= 0) { + if (str[cc] == 'E' || str[cc] == 'e') { + break; + } + if (FX_IsDigit(str[cc])) { + iExponent = iExponent + (str[cc] - '0') * 10; + cc--; + continue; + } else if (str[cc] == '+') { + cc--; + continue; + } else if (cc - iMinusLen + 1 > 0 && + !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), + (const FX_WCHAR*)wsMinus, iMinusLen)) { + bExpSign = TRUE; + cc -= iMinusLen; + } else { + return FALSE; + } + } + cc--; + iExponent = bExpSign ? -iExponent : iExponent; + ccf--; + } break; + case '$': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + } break; + case 'r': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { + if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'R': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'b': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { + if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'B': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case '.': + case 'V': + case 'v': + return FALSE; + case '%': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + bHavePercentSymbol = TRUE; + } break; + case '8': + while (ccf < lenf && strf[ccf] == '8') { + ccf++; + } + while (cc < len && FX_IsDigit(str[cc])) { + dbRetValue = (str[cc] - '0') * coeff + dbRetValue; + coeff *= 0.1; + cc++; + } + break; + case ',': { + if (cc >= 0) { + cc -= iGroupLen - 1; + if (cc >= 0 && + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, + iGroupLen) == 0) { + cc--; + } else { + cc += iGroupLen - 1; + } + } + ccf--; + } break; + case '(': + if (str[cc] == L'(') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + case ')': + if (str[cc] == L')') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + default: + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc--; + ccf--; + } + } + dot_index = cc + 1; + } + ccf = dot_index_f - 1; + cc = dot_index - 1; + coeff = 1; + while (ccf >= 0 && cc >= 0) { + switch (strf[ccf]) { + case '\'': { + 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)) { + return FALSE; + } + cc--; + ccf--; + break; + } + case '9': + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 10; + cc--; + ccf--; + break; + case 'z': + if (FX_IsDigit(str[cc])) { + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 10; + cc--; + } + ccf--; + break; + case 'Z': + if (str[cc] != ' ') { + if (FX_IsDigit(str[cc])) { + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 10; + cc--; + } + } else { + cc--; + } + ccf--; + break; + case 'S': + if (str[cc] == '+' || str[cc] == ' ') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 's': + if (str[cc] == '+') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 'E': { + if (cc >= dot_index) { + return FALSE; + } + FX_BOOL bExpSign = FALSE; + while (cc >= 0) { + if (str[cc] == 'E' || str[cc] == 'e') { + break; + } + if (FX_IsDigit(str[cc])) { + iExponent = iExponent + (str[cc] - '0') * 10; + cc--; + continue; + } else if (str[cc] == '+') { + cc--; + continue; + } else if (cc - iMinusLen + 1 > 0 && + !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), + (const FX_WCHAR*)wsMinus, iMinusLen)) { + bExpSign = TRUE; + cc -= iMinusLen; + } else { + return FALSE; + } + } + cc--; + iExponent = bExpSign ? -iExponent : iExponent; + ccf--; + } break; + case '$': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + } break; + case 'r': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { + if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'R': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'b': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { + if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'B': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case '.': + case 'V': + case 'v': + return FALSE; + case '%': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + bHavePercentSymbol = TRUE; + } break; + case '8': + return FALSE; + case ',': { + if (cc >= 0) { + cc -= iGroupLen - 1; + if (cc >= 0 && + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, + iGroupLen) == 0) { + cc--; + } else { + cc += iGroupLen - 1; + } + } + ccf--; + } break; + case '(': + if (str[cc] == L'(') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + case ')': + if (str[cc] == L')') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + default: + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc--; + ccf--; + } + } + if (cc >= 0) { + return FALSE; + } + if (!bReverseParse) { + ccf = dot_index_f + 1; + cc = (dot_index == len) ? len : dot_index + 1; + coeff = 0.1; + while (cc < len && ccf < lenf) { + switch (strf[ccf]) { + case '\'': { + 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)) { + return FALSE; + } + cc += iLiteralLen; + ccf++; + break; + } + case '9': + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + { + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 0.1; + } + cc++; + ccf++; + break; + case 'z': + if (FX_IsDigit(str[cc])) { + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 0.1; + cc++; + } + ccf++; + break; + case 'Z': + if (str[cc] != ' ') { + if (FX_IsDigit(str[cc])) { + dbRetValue = dbRetValue + (str[cc] - '0') * coeff; + coeff *= 0.1; + cc++; + } + } else { + cc++; + } + ccf++; + break; + case 'S': + if (str[cc] == '+' || str[cc] == ' ') { + cc++; + } else { + if (cc + iMinusLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + bNeg = TRUE; + cc += iMinusLen; + } + ccf++; + break; + case 's': + if (str[cc] == '+') { + cc++; + } else { + if (cc + iMinusLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + bNeg = TRUE; + cc += iMinusLen; + } + ccf++; + break; + case 'E': { + if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { + return FALSE; + } + FX_BOOL bExpSign = FALSE; + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = TRUE; + cc++; + } + } + while (cc < len) { + if (!FX_IsDigit(str[cc])) { + break; + } + iExponent = iExponent * 10 + str[cc] - '0'; + cc++; + } + iExponent = bExpSign ? -iExponent : iExponent; + ccf++; + } break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, + wsSymbol); + int32_t iSymbolLen = wsSymbol.GetLength(); + if (cc + iSymbolLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { + return FALSE; + } + cc += iSymbolLen; + ccf++; + } break; + case 'c': + if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { + if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'C': + if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'd': + if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { + if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'D': + if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case '.': + case 'V': + case 'v': + return FALSE; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + int32_t iSysmbolLen = wsSymbol.GetLength(); + if (cc + iSysmbolLen <= len && + !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, + iSysmbolLen)) { + cc += iSysmbolLen; + } + ccf++; + bHavePercentSymbol = TRUE; + } break; + case '8': { + while (ccf < lenf && strf[ccf] == '8') { + ccf++; + } + while (cc < len && FX_IsDigit(str[cc])) { + dbRetValue = (str[cc] - '0') * coeff + dbRetValue; + coeff *= 0.1; + cc++; + } + } break; + case ',': { + if (cc + iGroupLen <= len && + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, + iGroupLen) == 0) { + cc += iGroupLen; + } + ccf++; + } break; + case '(': + if (str[cc] == L'(') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc++; + ccf++; + break; + case ')': + if (str[cc] == L')') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc++; + ccf++; + break; + default: + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc++; + ccf++; + } + } + if (cc != len) { + return FALSE; + } + } + if (iExponent) { + dbRetValue *= FXSYS_pow(10, (FX_FLOAT)iExponent); + } + if (bHavePercentSymbol) { + dbRetValue /= 100.0; + } + if (bNeg) { + dbRetValue = -dbRetValue; + } + fValue = (FX_FLOAT)dbRetValue; + return TRUE; +} +void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) { + int32_t iCount = wsNum.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; + FX_WCHAR* pDst = wsResult.GetBuffer(iCount); + int32_t nIndex = 0; + FX_BOOL bMinus = FALSE; + int32_t i = 0; + for (i = 0; i < iCount; i++) { + FX_WCHAR wc = pStr[i]; + if (wc == '.') { + break; + } + if ((wc == L'0' || wc == L' ' || wc == '+') && nIndex == 0) { + continue; + } + if (wc == '-') { + pDst[nIndex++] = wc; + bMinus = TRUE; + continue; + } + if (wc == L'0' && nIndex == 1 && bMinus) { + continue; + } + pDst[nIndex++] = wc; + } + if (bMinus && nIndex == 1) { + pDst[nIndex++] = '0'; + } + if (nIndex == 0) { + wsResult.ReleaseBuffer(0); + pDst = wsResult.GetBuffer(iCount + 1); + pDst[nIndex++] = '0'; + } + int32_t j = 0; + for (j = iCount - 1; j > i; j--) { + FX_WCHAR wc = pStr[j]; + if (wc != L'0' && wc != L' ') { + break; + } + } + if (j > i) { + pDst[nIndex++] = '.'; + FXSYS_wcsncpy(pDst + nIndex, pStr + i + 1, j - i); + nIndex += j - i; + } + wsResult.ReleaseBuffer(nIndex); +} +FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsValue) { + wsValue.Empty(); + if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + int32_t dot_index_f = -1; + FX_DWORD dwFormatStyle = 0; + CFX_WideString wsNumFormat; + IFX_Locale* pLocale = + GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); + if (!pLocale || wsNumFormat.IsEmpty()) { + return FALSE; + } + int32_t iExponent = 0; + CFX_WideString wsDotSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); + CFX_WideString wsGroupSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); + int32_t iGroupLen = wsGroupSymbol.GetLength(); + CFX_WideString wsMinus; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); + int32_t iMinusLen = wsMinus.GetLength(); + int cc = 0, ccf = 0; + const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; + int len = wsSrcNum.GetLength(); + const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; + int lenf = wsNumFormat.GetLength(); + FX_BOOL bHavePercentSymbol = FALSE; + FX_BOOL bNeg = FALSE; + FX_BOOL bReverseParse = FALSE; + int32_t dot_index = 0; + if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && + (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { + bReverseParse = TRUE; + } + bReverseParse = FALSE; + ccf = dot_index_f - 1; + cc = dot_index - 1; + while (ccf >= 0 && cc >= 0) { + switch (strf[ccf]) { + case '\'': { + 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)) { + return FALSE; + } + cc--; + ccf--; + break; + } + case '9': + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wsValue = CFX_WideStringC(str[cc]) + wsValue; + cc--; + ccf--; + break; + case 'z': + if (FX_IsDigit(str[cc])) { + wsValue = CFX_WideStringC(str[cc]) + wsValue; + cc--; + } + ccf--; + break; + case 'Z': + if (str[cc] != ' ') { + if (FX_IsDigit(str[cc])) { + wsValue = CFX_WideStringC(str[cc]) + wsValue; + cc--; + } + } else { + cc--; + } + ccf--; + break; + case 'S': + if (str[cc] == '+' || str[cc] == ' ') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 's': + if (str[cc] == '+') { + cc--; + } else { + cc -= iMinusLen - 1; + if (cc < 0 || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + cc--; + bNeg = TRUE; + } + ccf--; + break; + case 'E': { + if (cc >= dot_index) { + return FALSE; + } + FX_BOOL bExpSign = FALSE; + while (cc >= 0) { + if (str[cc] == 'E' || str[cc] == 'e') { + break; + } + if (FX_IsDigit(str[cc])) { + iExponent = iExponent + (str[cc] - '0') * 10; + cc--; + continue; + } else if (str[cc] == '+') { + cc--; + continue; + } else if (cc - iMinusLen + 1 > 0 && + !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), + (const FX_WCHAR*)wsMinus, iMinusLen)) { + bExpSign = TRUE; + cc -= iMinusLen; + } else { + return FALSE; + } + } + cc--; + iExponent = bExpSign ? -iExponent : iExponent; + ccf--; + } break; + case '$': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + } break; + case 'r': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { + if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'R': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'b': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { + if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case 'B': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { + bNeg = TRUE; + cc -= 2; + } + ccf -= 2; + } else { + ccf--; + } + break; + case '.': + case 'V': + case 'v': + return FALSE; + case '%': { + CFX_WideString wsSymbol; + 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)) { + return FALSE; + } + cc--; + ccf--; + bHavePercentSymbol = TRUE; + } break; + case '8': + return FALSE; + case ',': { + if (cc >= 0) { + cc -= iGroupLen - 1; + if (cc >= 0 && + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, + iGroupLen) == 0) { + cc--; + } else { + cc += iGroupLen - 1; + } + } + ccf--; + } break; + case '(': + if (str[cc] == L'(') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + case ')': + if (str[cc] == L')') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc--; + ccf--; + break; + default: + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc--; + ccf--; + } + } + if (cc >= 0) { + if (str[cc] == '-') { + bNeg = TRUE; + cc--; + } + if (cc >= 0) { + return FALSE; + } + } + if (dot_index < len && (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { + wsValue += '.'; + } + if (!bReverseParse) { + ccf = dot_index_f + 1; + cc = (dot_index == len) ? len : dot_index + 1; + while (cc < len && ccf < lenf) { + switch (strf[ccf]) { + case '\'': { + 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)) { + return FALSE; + } + cc += iLiteralLen; + ccf++; + break; + } + case '9': + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + { wsValue += str[cc]; } + cc++; + ccf++; + break; + case 'z': + if (FX_IsDigit(str[cc])) { + wsValue += str[cc]; + cc++; + } + ccf++; + break; + case 'Z': + if (str[cc] != ' ') { + if (FX_IsDigit(str[cc])) { + wsValue += str[cc]; + cc++; + } + } else { + cc++; + } + ccf++; + break; + case 'S': + if (str[cc] == '+' || str[cc] == ' ') { + cc++; + } else { + if (cc + iMinusLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + bNeg = TRUE; + cc += iMinusLen; + } + ccf++; + break; + case 's': + if (str[cc] == '+') { + cc++; + } else { + if (cc + iMinusLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { + return FALSE; + } + bNeg = TRUE; + cc += iMinusLen; + } + ccf++; + break; + case 'E': { + if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { + return FALSE; + } + FX_BOOL bExpSign = FALSE; + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = TRUE; + cc++; + } + } + while (cc < len) { + if (!FX_IsDigit(str[cc])) { + break; + } + iExponent = iExponent * 10 + str[cc] - '0'; + cc++; + } + iExponent = bExpSign ? -iExponent : iExponent; + ccf++; + } break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, + wsSymbol); + int32_t iSymbolLen = wsSymbol.GetLength(); + if (cc + iSymbolLen > len || + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { + return FALSE; + } + cc += iSymbolLen; + ccf++; + } break; + case 'c': + if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { + if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'C': + if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'd': + if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { + if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case 'D': + if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { + if (str[cc] == ' ') { + cc++; + } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { + bNeg = TRUE; + cc += 2; + } + ccf += 2; + } + break; + case '.': + case 'V': + case 'v': + return FALSE; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + int32_t iSysmbolLen = wsSymbol.GetLength(); + if (cc + iSysmbolLen <= len && + !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, + iSysmbolLen)) { + cc += iSysmbolLen; + } + ccf++; + bHavePercentSymbol = TRUE; + } break; + case '8': { + while (ccf < lenf && strf[ccf] == '8') { + ccf++; + } + while (cc < len && FX_IsDigit(str[cc])) { + wsValue += str[cc]; + cc++; + } + } break; + case ',': { + if (cc + iGroupLen <= len && + FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, + iGroupLen) == 0) { + cc += iGroupLen; + } + ccf++; + } break; + case '(': + if (str[cc] == L'(') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc++; + ccf++; + break; + case ')': + if (str[cc] == L')') { + bNeg = TRUE; + } else if (str[cc] != L' ') { + return FALSE; + } + cc++; + ccf++; + break; + default: + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc++; + ccf++; + } + } + if (cc != len) { + return FALSE; + } + } + if (iExponent || bHavePercentSymbol) { + CFX_Decimal decimal = CFX_Decimal(wsValue); + if (iExponent) { + decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); + } + if (bHavePercentSymbol) { + decimal = decimal / CFX_Decimal(100); + } + wsValue = decimal; + } + if (bNeg) { + wsValue = CFX_WideStringC('-') + wsValue; + } + return TRUE; +} +FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( + const CFX_WideString& wsPattern, + IFX_Locale*& pLocale, + CFX_WideString& wsDatePattern, + CFX_WideString& wsTimePattern) { + pLocale = NULL; + CFX_WideString wsTempPattern; + FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; + int32_t ccf = 0; + int32_t iLenf = wsPattern.GetLength(); + const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; + int32_t iFindCategory = 0; + FX_BOOL bBraceOpen = FALSE; + 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) { + CFX_WideString wsCategory(pStr[ccf]); + ccf++; + while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && + pStr[ccf] != '(') { + if (pStr[ccf] == 'T') { + wsDatePattern = wsPattern.Left(ccf); + wsTimePattern = wsPattern.Right(wsPattern.GetLength() - ccf); + wsTimePattern.SetAt(0, ' '); + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + return FX_DATETIMETYPE_DateTime; + } + wsCategory += pStr[ccf]; + ccf++; + } + if (!(iFindCategory & 1) && wsCategory == FX_WSTRC(L"date")) { + iFindCategory |= 1; + eCategory = FX_LOCALECATEGORY_Date; + if (iFindCategory & 2) { + iFindCategory = 4; + } + } else if (!(iFindCategory & 2) && wsCategory == FX_WSTRC(L"time")) { + iFindCategory |= 2; + eCategory = FX_LOCALECATEGORY_Time; + } else if (wsCategory == FX_WSTRC(L"datetime")) { + iFindCategory = 3; + eCategory = FX_LOCALECATEGORY_DateTime; + } else { + continue; + } + while (ccf < iLenf) { + if (pStr[ccf] == '(') { + ccf++; + CFX_WideString wsLCID; + while (ccf < iLenf && pStr[ccf] != ')') { + wsLCID += pStr[ccf++]; + } + pLocale = GetPatternLocale(wsLCID); + } else if (pStr[ccf] == '{') { + bBraceOpen = TRUE; + break; + } else if (pStr[ccf] == '.') { + CFX_WideString wsSubCategory; + ccf++; + while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { + wsSubCategory += pStr[ccf++]; + } + FX_DWORD dwSubHash = + FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); + FX_LOCALEDATETIMESUBCATEGORY eSubCategory = + FX_LOCALEDATETIMESUBCATEGORY_Medium; + for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { + if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { + eSubCategory = + (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] + .eSubCategory; + break; + } + } + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + FXSYS_assert(pLocale != NULL); + switch (eCategory) { + case FX_LOCALECATEGORY_Date: + pLocale->GetDatePattern(eSubCategory, wsDatePattern); + wsDatePattern = wsTempPattern + wsDatePattern; + break; + case FX_LOCALECATEGORY_Time: + pLocale->GetTimePattern(eSubCategory, wsTimePattern); + wsTimePattern = wsTempPattern + wsTimePattern; + break; + case FX_LOCALECATEGORY_DateTime: + pLocale->GetDatePattern(eSubCategory, wsDatePattern); + wsDatePattern = wsTempPattern + wsDatePattern; + pLocale->GetTimePattern(eSubCategory, wsTimePattern); + break; + default: + break; + } + wsTempPattern.Empty(); + continue; + } + ccf++; + } + } else if (pStr[ccf] == '}') { + bBraceOpen = FALSE; + if (!wsTempPattern.IsEmpty()) { + if (eCategory == FX_LOCALECATEGORY_Time) { + wsTimePattern = wsTempPattern; + } else if (eCategory == FX_LOCALECATEGORY_Date) { + wsDatePattern = wsTempPattern; + } + wsTempPattern.Empty(); + } + } else { + wsTempPattern += pStr[ccf]; + } + ccf++; + } + if (!wsTempPattern.IsEmpty()) { + if (eCategory == FX_LOCALECATEGORY_Date) { + wsDatePattern += wsTempPattern; + } else { + wsTimePattern += wsTempPattern; + } + } + if (!pLocale) { + pLocale = m_pLocaleMgr->GetDefLocale(); + } + if (!iFindCategory) { + wsTimePattern.Empty(); + wsDatePattern = wsPattern; + } + return (FX_DATETIMETYPE)iFindCategory; +} +static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, + const CFX_WideString& wsDatePattern, + IFX_Locale* pLocale, + CFX_Unitime& datetime, + int32_t& cc) { + int32_t year = 1900; + int32_t month = 1; + int32_t day = 1; + int32_t ccf = 0; + const FX_WCHAR* str = (const FX_WCHAR*)wsDate; + int32_t len = wsDate.GetLength(); + const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; + int32_t lenf = wsDatePattern.GetLength(); + 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)) { + return FALSE; + } + cc += iLiteralLen; + ccf++; + continue; + } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc++; + ccf++; + continue; + } + FX_DWORD dwSymbolNum = 1; + FX_DWORD dwSymbol = strf[ccf++]; + while (ccf < lenf && strf[ccf] == dwSymbol) { + ccf++; + dwSymbolNum++; + } + dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); + if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + day = str[cc++] - '0'; + if (cc < len && FX_IsDigit(str[cc])) { + day = day * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + day = str[cc++] - '0'; + if (cc < len) { + day = day * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { + int i = 0; + while (cc < len && i < 3 && FX_IsDigit(str[cc])) { + cc++; + i++; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { + cc += 3; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + month = str[cc++] - '0'; + if (cc < len && FX_IsDigit(str[cc])) { + month = month * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + month = str[cc++] - '0'; + if (cc < len) { + month = month * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { + CFX_WideString wsMonthNameAbbr; + FX_WORD i = 0; + for (; i < 12; i++) { + pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); + if (wsMonthNameAbbr.IsEmpty()) { + continue; + } + if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc, + wsMonthNameAbbr.GetLength())) { + break; + } + } + if (i < 12) { + cc += wsMonthNameAbbr.GetLength(); + month = i + 1; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { + CFX_WideString wsMonthName; + FX_WORD i = 0; + for (; i < 12; i++) { + pLocale->GetMonthName(i, wsMonthName, FALSE); + if (wsMonthName.IsEmpty()) { + continue; + } + if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc, + wsMonthName.GetLength())) { + break; + } + } + if (i < 12) { + cc += wsMonthName.GetLength(); + month = i + 1; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { + cc += 1; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { + CFX_WideString wsDayNameAbbr; + FX_WORD i = 0; + for (; i < 7; i++) { + pLocale->GetDayName(i, wsDayNameAbbr, TRUE); + if (wsDayNameAbbr.IsEmpty()) { + continue; + } + if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc, + wsDayNameAbbr.GetLength())) { + break; + } + } + if (i < 12) { + cc += wsDayNameAbbr.GetLength(); + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { + CFX_WideString wsDayName; + int32_t i = 0; + for (; i < 7; i++) { + pLocale->GetDayName(i, wsDayName, FALSE); + if (wsDayName == L"") { + continue; + } + if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayName, str + cc, + wsDayName.GetLength())) { + break; + } + } + if (i < 12) { + cc += wsDayName.GetLength(); + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { + cc += 1; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { + cc += 2; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { + if (cc + 2 > len) { + return FALSE; + } + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + year = str[cc++] - '0'; + if (cc >= len || !FX_IsDigit(str[cc])) { + return FALSE; + } + year = year * 10 + str[cc++] - '0'; + if (year <= 29) { + year += 2000; + } else { + year += 1900; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { + int i = 0; + year = 0; + if (cc + 4 > len) { + return FALSE; + } + while (i < 4) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + year = year * 10 + str[cc] - '0'; + cc++; + i++; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { + cc += 1; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { + cc += 2; + } + } + if (cc < len) { + return FALSE; + } + CFX_Unitime ut; + ut.Set(year, month, day); + datetime = datetime + ut; + return cc; +} +static void FX_ResolveZone(uint8_t& wHour, + uint8_t& wMinute, + FX_TIMEZONE tzDiff, + IFX_Locale* pLocale) { + int32_t iMinuteDiff = wHour * 60 + wMinute; + FX_TIMEZONE tzLocale; + pLocale->GetTimeZone(tzLocale); + iMinuteDiff += tzLocale.tzHour * 60 + + (tzLocale.tzHour < 0 ? -tzLocale.tzMinute : tzLocale.tzMinute); + iMinuteDiff -= tzDiff.tzHour * 60 + + (tzDiff.tzHour < 0 ? -tzDiff.tzMinute : tzDiff.tzMinute); + while (iMinuteDiff > 1440) { + iMinuteDiff -= 1440; + } + while (iMinuteDiff < 0) { + iMinuteDiff += 1440; + } + wHour = iMinuteDiff / 60; + wMinute = iMinuteDiff % 60; +} +static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, + const CFX_WideString& wsTimePattern, + IFX_Locale* pLocale, + CFX_Unitime& datetime, + int32_t& cc) { + uint8_t hour = 0; + uint8_t minute = 0; + uint8_t second = 0; + FX_WORD millisecond = 0; + int32_t ccf = 0; + const FX_WCHAR* str = (const FX_WCHAR*)wsTime; + int len = wsTime.GetLength(); + const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; + int lenf = wsTimePattern.GetLength(); + FX_BOOL bHasA = FALSE; + FX_BOOL bPM = FALSE; + 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)) { + return FALSE; + } + cc += iLiteralLen; + ccf++; + continue; + } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { + if (strf[ccf] != str[cc]) { + return FALSE; + } + cc++; + ccf++; + continue; + } + FX_DWORD dwSymbolNum = 1; + FX_DWORD dwSymbol = strf[ccf++]; + while (ccf < lenf && strf[ccf] == dwSymbol) { + ccf++; + dwSymbolNum++; + } + dwSymbol = (dwSymbol << 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') || + dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + hour = str[cc++] - '0'; + if (cc < len && FX_IsDigit(str[cc])) { + hour = hour * 10 + str[cc++] - '0'; + } + if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1') && hour == 24) { + hour = 0; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2') || + dwSymbol == FXBSTR_ID(0, 0, 'H', '2') || + dwSymbol == FXBSTR_ID(0, 0, 'h', '2') || + dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + hour = str[cc++] - '0'; + if (cc >= len) { + return FALSE; + } + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + hour = hour * 10 + str[cc++] - '0'; + if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2') && hour == 24) { + hour = 0; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + minute = str[cc++] - '0'; + if (cc < len && FX_IsDigit(str[cc])) { + minute = minute * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + minute = str[cc++] - '0'; + if (cc >= len) { + return FALSE; + } + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + minute = minute * 10 + str[cc++] - '0'; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + second = str[cc++] - '0'; + if (cc < len && FX_IsDigit(str[cc])) { + second = second * 10 + str[cc++] - '0'; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + second = str[cc++] - '0'; + if (cc >= len) { + return FALSE; + } + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + second = second * 10 + str[cc++] - '0'; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { + if (cc + 3 >= len) { + return FALSE; + } + int i = 0; + while (i < 3) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + millisecond = millisecond * 10 + str[cc++] - '0'; + i++; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { + CFX_WideString wsAM; + pLocale->GetMeridiemName(wsAM, TRUE); + CFX_WideString wsPM; + pLocale->GetMeridiemName(wsPM, FALSE); + if ((cc + wsAM.GetLength() <= len) && + (CFX_WideStringC(str + cc, wsAM.GetLength()) == wsAM)) { + cc += wsAM.GetLength(); + bHasA = TRUE; + } else if ((cc + wsPM.GetLength() <= len) && + (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { + cc += wsPM.GetLength(); + bHasA = TRUE; + bPM = TRUE; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { + if (cc + 3 > len) { + continue; + } + FX_DWORD dwHash = str[cc++]; + dwHash = (dwHash << 8) | str[cc++]; + dwHash = (dwHash << 8) | str[cc++]; + if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { + FX_TIMEZONE tzDiff; + tzDiff.tzHour = 0; + tzDiff.tzMinute = 0; + if (cc < len && (str[cc] == '-' || str[cc] == '+')) { + cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); + } + FX_ResolveZone(hour, minute, tzDiff, pLocale); + } else { + const FX_LOCALETIMEZONEINFO* pEnd = + g_FXLocaleTimeZoneData + FX_ArraySize(g_FXLocaleTimeZoneData); + const FX_LOCALETIMEZONEINFO* pTimeZoneInfo = + std::lower_bound(g_FXLocaleTimeZoneData, pEnd, dwHash, + [](const FX_LOCALETIMEZONEINFO& info, + FX_DWORD hash) { return info.uHash < hash; }); + if (pTimeZoneInfo < pEnd && dwHash == pTimeZoneInfo->uHash) { + hour += pTimeZoneInfo->iHour; + minute += pTimeZoneInfo->iHour > 0 ? pTimeZoneInfo->iMinute + : -pTimeZoneInfo->iMinute; + } + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { + if (str[cc] != 'Z') { + FX_TIMEZONE tzDiff; + cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); + FX_ResolveZone(hour, minute, tzDiff, pLocale); + } else { + cc++; + } + } + } + if (bHasA) { + if (bPM) { + hour += 12; + if (hour == 24) { + hour = 12; + } + } else { + if (hour == 12) { + hour = 0; + } + } + } + CFX_Unitime ut; + ut.Set(0, 0, 0, hour, minute, second, millisecond); + datetime = datetime + ut; + return cc; +} +FX_BOOL CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, + const CFX_WideString& wsPattern, + FX_DATETIMETYPE eDateTimeType, + CFX_Unitime& dtValue) { + dtValue.Set(0); + if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsDatePattern, wsTimePattern; + IFX_Locale* pLocale = NULL; + FX_DATETIMETYPE eCategory = + GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); + if (!pLocale) { + return FALSE; + } + if (eCategory == FX_DATETIMETYPE_Unknown) { + eCategory = eDateTimeType; + } + if (eCategory == FX_DATETIMETYPE_Unknown) { + return FALSE; + } + if (eCategory == FX_DATETIMETYPE_TimeDate) { + int32_t iStart = 0; + if (!FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, + iStart)) { + return FALSE; + } + if (!FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, + iStart)) { + return FALSE; + } + } else { + int32_t iStart = 0; + if ((eCategory & FX_DATETIMETYPE_Date) && + !FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, + iStart)) { + return FALSE; + } + if ((eCategory & FX_DATETIMETYPE_Time) && + !FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, + iStart)) { + return FALSE; + } + } + return TRUE; +} +FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, + const CFX_WideString& wsPattern) { + CFX_WideString wsTextFormat; + GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); + int32_t iText = 0, iPattern = 0; + const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; + int32_t iLenText = wsSrcText.GetLength(); + const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern && iText < iLenText) { + if (pStrPattern[iPattern] == '\'') { + CFX_WideString wsLiteral = + FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + int32_t iLiteralLen = wsLiteral.GetLength(); + if (iText + iLiteralLen > iLenText || + FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, + iLiteralLen)) { + return FALSE; + } + iText += iLiteralLen; + iPattern++; + continue; + } else if (pStrPattern[iPattern] != pStrText[iText]) { + return FALSE; + } else { + iText++; + iPattern++; + } + } + return iPattern == iLenPattern && iText == iLenText; +} +FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, + const CFX_WideString& wsPattern) { + CFX_WideString wsTextFormat; + GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); + int32_t iText = 0, iPattern = 0; + const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; + int32_t iLenText = wsSrcText.GetLength(); + const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern && iText < iLenText) { + if (pStrPattern[iPattern] == '\'') { + CFX_WideString wsLiteral = + FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + int32_t iLiteralLen = wsLiteral.GetLength(); + if (iText + iLiteralLen > iLenText || + FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, + iLiteralLen)) { + return FALSE; + } + iText += iLiteralLen; + iPattern++; + continue; + } else if (pStrPattern[iPattern] != pStrText[iText]) { + return FALSE; + } else { + iText++; + iPattern++; + } + } + return iPattern == iLenPattern && iText == iLenText; +} +FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsPattern.IsEmpty()) { + return FALSE; + } + int32_t iLenText = wsSrcText.GetLength(); + if (iLenText == 0) { + return FALSE; + } + 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; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern) { + switch (pStrPattern[iPattern]) { + case '\'': { + wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + iPattern++; + break; + } + case 'A': + if (iText >= iLenText || !FX_IsAlpha(pStrText[iText])) { + return FALSE; + } + wsOutput += pStrText[iText++]; + iPattern++; + break; + case 'X': + if (iText >= iLenText) { + return FALSE; + } + wsOutput += pStrText[iText++]; + iPattern++; + break; + case 'O': + case '0': + if (iText >= iLenText || + (!FX_IsDigit(pStrText[iText]) && !FX_IsAlpha(pStrText[iText]))) { + return FALSE; + } + wsOutput += pStrText[iText++]; + iPattern++; + break; + case '9': + if (iText >= iLenText || !FX_IsDigit(pStrText[iText])) { + return FALSE; + } + wsOutput += pStrText[iText++]; + iPattern++; + break; + default: + wsOutput += pStrPattern[iPattern++]; + break; + } + } + return iText == iLenText; +} +static int32_t FX_GetNumTrailingLimit(const CFX_WideString& wsFormat, + int iDotPos, + FX_BOOL& bTrimTailZeros) { + if (iDotPos < 0) { + return 0; + } + int32_t iCount = wsFormat.GetLength(); + int32_t iTreading = 0; + for (iDotPos++; iDotPos < iCount; iDotPos++) { + FX_WCHAR wc = wsFormat[iDotPos]; + if (wc == L'z' || wc == L'9' || wc == 'Z') { + iTreading++; + bTrimTailZeros = (wc == L'9' ? FALSE : TRUE); + } + } + return iTreading; +} +FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + int32_t dot_index_f = -1; + FX_DWORD dwNumStyle = 0; + CFX_WideString wsNumFormat; + IFX_Locale* pLocale = + GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); + if (!pLocale || wsNumFormat.IsEmpty()) { + return FALSE; + } + int32_t cc = 0, ccf = 0; + const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; + int lenf = wsNumFormat.GetLength(); + CFX_WideString wsSrcNum = wsInputNum; + wsSrcNum.TrimLeft('0'); + if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { + wsSrcNum.Insert(0, '0'); + } + CFX_Decimal decimal = CFX_Decimal(wsSrcNum); + if (dwNumStyle & FX_NUMSTYLE_Percent) { + decimal = decimal * CFX_Decimal(100); + wsSrcNum = decimal; + } + int32_t exponent = 0; + if (dwNumStyle & FX_NUMSTYLE_Exponent) { + int fixed_count = 0; + while (ccf < dot_index_f) { + switch (strf[ccf]) { + case '\'': + FX_GetLiteralText(strf, ccf, dot_index_f); + break; + case '9': + case 'z': + case 'Z': + fixed_count++; + break; + } + ccf++; + } + int threshold = 1; + while (fixed_count > 1) { + threshold *= 10; + fixed_count--; + } + if (decimal != CFX_Decimal(0)) { + if (decimal < CFX_Decimal(threshold)) { + decimal = decimal * CFX_Decimal(10); + exponent = -1; + while (decimal < CFX_Decimal(threshold)) { + decimal = decimal * CFX_Decimal(10); + exponent -= 1; + } + } else if (decimal > CFX_Decimal(threshold)) { + threshold *= 10; + while (decimal > CFX_Decimal(threshold)) { + decimal = decimal / CFX_Decimal(10); + exponent += 1; + } + } + } + } + FX_BOOL bTrimTailZeros = FALSE; + int32_t iTreading = + FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); + int32_t scale = decimal.GetScale(); + if (iTreading < scale) { + decimal.SetScale(iTreading); + wsSrcNum = decimal; + } + if (bTrimTailZeros && scale > 0 && iTreading > 0) { + wsSrcNum.TrimRight(L"0"); + wsSrcNum.TrimRight(L"."); + } + CFX_WideString wsGroupSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); + FX_BOOL bNeg = FALSE; + if (wsSrcNum[0] == '-') { + bNeg = TRUE; + wsSrcNum.Delete(0, 1); + } + FX_BOOL bAddNeg = FALSE; + const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; + int len = wsSrcNum.GetLength(); + int dot_index = wsSrcNum.Find('.'); + if (dot_index == -1) { + dot_index = len; + } + ccf = dot_index_f - 1; + cc = dot_index - 1; + while (ccf >= 0) { + switch (strf[ccf]) { + case '9': + if (cc >= 0) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + cc--; + } else { + wsOutput = CFX_WideStringC(L'0') + wsOutput; + } + ccf--; + break; + case 'z': + if (cc >= 0) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + if (str[0] != '0') { + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + } + cc--; + } + ccf--; + break; + case 'Z': + if (cc >= 0) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + if (str[0] == '0') { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } else { + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + } + cc--; + } else { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } + ccf--; + break; + case 'S': + if (bNeg) { + CFX_WideString wsMinusSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); + wsOutput = wsMinusSymbol + wsOutput; + bAddNeg = TRUE; + } else { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } + ccf--; + break; + case 's': + if (bNeg) { + CFX_WideString wsMinusSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); + wsOutput = wsMinusSymbol + wsOutput; + bAddNeg = TRUE; + } + ccf--; + break; + case 'E': { + CFX_WideString wsExp; + wsExp.Format(L"E%+d", exponent); + wsOutput = wsExp + wsOutput; + } + ccf--; + break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); + wsOutput = wsSymbol + wsOutput; + } + ccf--; + break; + case 'r': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { + if (bNeg) { + wsOutput = L"CR" + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'R': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { + if (bNeg) { + wsOutput = L"CR" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'b': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { + if (bNeg) { + wsOutput = L"db" + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'B': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { + if (bNeg) { + wsOutput = L"DB" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + wsOutput = wsSymbol + wsOutput; + } + ccf--; + break; + case ',': + if (cc >= 0) { + wsOutput = wsGroupSymbol + wsOutput; + } + ccf--; + break; + case '(': + if (bNeg) { + wsOutput = L"(" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + bAddNeg = TRUE; + ccf--; + break; + case ')': + if (bNeg) { + wsOutput = L")" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf--; + break; + case '\'': + wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; + ccf--; + break; + default: + wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; + ccf--; + } + } + if (cc >= 0) { + int nPos = dot_index % 3; + wsOutput.Empty(); + for (int32_t i = 0; i < dot_index; i++) { + if (i % 3 == nPos && i != 0) { + wsOutput += wsGroupSymbol; + } + wsOutput += wsSrcNum[i]; + } + if (dot_index < len) { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); + wsOutput += wsSymbol; + wsOutput += wsSrcNum.Right(len - dot_index - 1); + } + if (bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = wsMinusymbol + wsOutput; + } + return FALSE; + } + if (dot_index_f == wsNumFormat.GetLength()) { + if (!bAddNeg && bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = wsMinusymbol + wsOutput; + } + return TRUE; + } + CFX_WideString wsDotSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); + if (strf[dot_index_f] == 'V') { + wsOutput += wsDotSymbol; + } else if (strf[dot_index_f] == '.') { + if (dot_index < len) { + wsOutput += wsDotSymbol; + } else { + if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { + wsOutput += wsDotSymbol; + } + } + } + ccf = dot_index_f + 1; + cc = dot_index + 1; + while (ccf < lenf) { + switch (strf[ccf]) { + case '\'': + wsOutput += FX_GetLiteralText(strf, ccf, lenf); + ccf++; + break; + case '9': + if (cc < len) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wsOutput += str[cc]; + cc++; + } else { + wsOutput += L'0'; + } + ccf++; + break; + case 'z': + if (cc < len) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wsOutput += str[cc]; + cc++; + } + ccf++; + break; + case 'Z': + if (cc < len) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wsOutput += str[cc]; + cc++; + } else { + wsOutput += L'0'; + } + ccf++; + break; + case 'E': { + CFX_WideString wsExp; + wsExp.Format(L"E%+d", exponent); + wsOutput += wsExp; + } + ccf++; + break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); + wsOutput += wsSymbol; + } + ccf++; + break; + case 'c': + if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { + if (bNeg) { + wsOutput += L"CR"; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'C': + if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { + if (bNeg) { + wsOutput += L"CR"; + } else { + wsOutput += L" "; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'd': + if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { + if (bNeg) { + wsOutput += L"db"; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'D': + if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { + if (bNeg) { + wsOutput += L"DB"; + } else { + wsOutput += L" "; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + wsOutput += wsSymbol; + } + ccf++; + break; + case '8': { + while (ccf < lenf && strf[ccf] == '8') { + ccf++; + } + while (cc < len && FX_IsDigit(str[cc])) { + wsOutput += str[cc]; + cc++; + } + } break; + case ',': + wsOutput += wsGroupSymbol; + ccf++; + break; + case '(': + if (bNeg) { + wsOutput += '('; + } else { + wsOutput += ' '; + } + bAddNeg = TRUE; + ccf++; + break; + case ')': + if (bNeg) { + wsOutput += ')'; + } else { + wsOutput += ' '; + } + ccf++; + break; + default: + ccf++; + } + } + if (!bAddNeg && bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = + wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); + } + return TRUE; +} +FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + int32_t dot_index_f = -1; + FX_DWORD dwNumStyle = 0; + CFX_WideString wsNumFormat; + IFX_Locale* pLocale = + GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); + if (!pLocale || wsNumFormat.IsEmpty()) { + return FALSE; + } + int32_t cc = 0, ccf = 0; + const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; + int lenf = wsNumFormat.GetLength(); + double dbOrgRaw = lcNum.GetDouble(); + double dbRetValue = dbOrgRaw; + if (dwNumStyle & FX_NUMSTYLE_Percent) { + dbRetValue *= 100; + } + int32_t exponent = 0; + if (dwNumStyle & FX_NUMSTYLE_Exponent) { + int fixed_count = 0; + while (ccf < dot_index_f) { + switch (strf[ccf]) { + case '\'': + FX_GetLiteralText(strf, ccf, dot_index_f); + break; + case '9': + case 'z': + case 'Z': + fixed_count++; + break; + } + ccf++; + } + int threshold = 1; + while (fixed_count > 1) { + threshold *= 10; + fixed_count--; + } + if (dbRetValue != 0) { + if (dbRetValue < threshold) { + dbRetValue *= 10; + exponent = -1; + while (dbRetValue < threshold) { + dbRetValue *= 10; + exponent -= 1; + } + } else if (dbRetValue > threshold) { + threshold *= 10; + while (dbRetValue > threshold) { + dbRetValue /= 10; + exponent += 1; + } + } + } + } + if (dwNumStyle & (FX_NUMSTYLE_Percent | FX_NUMSTYLE_Exponent)) { + lcNum = CFX_LCNumeric(dbRetValue); + } + FX_BOOL bTrimTailZeros = FALSE; + int32_t iTreading = + FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); + CFX_WideString wsNumeric = lcNum.ToString(iTreading, bTrimTailZeros); + if (wsNumeric.IsEmpty()) { + return FALSE; + } + CFX_WideString wsGroupSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); + FX_BOOL bNeg = FALSE; + if (wsNumeric[0] == '-') { + bNeg = TRUE; + wsNumeric.Delete(0, 1); + } + FX_BOOL bAddNeg = FALSE; + const FX_WCHAR* str = (const FX_WCHAR*)wsNumeric; + int len = wsNumeric.GetLength(); + int dot_index = wsNumeric.Find('.'); + if (dot_index == -1) { + dot_index = len; + } + ccf = dot_index_f - 1; + cc = dot_index - 1; + while (ccf >= 0) { + switch (strf[ccf]) { + case '9': + if (cc >= 0) { + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + cc--; + } else { + wsOutput = CFX_WideStringC(L'0') + wsOutput; + } + ccf--; + break; + case 'z': + if (cc >= 0) { + if (lcNum.m_Integral != 0) { + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + } + cc--; + } + ccf--; + break; + case 'Z': + if (cc >= 0) { + if (lcNum.m_Integral == 0) { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } else { + wsOutput = CFX_WideStringC(str[cc]) + wsOutput; + } + cc--; + } else { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } + ccf--; + break; + case 'S': + if (bNeg) { + CFX_WideString wsMinusSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); + wsOutput = wsMinusSymbol + wsOutput; + bAddNeg = TRUE; + } else { + wsOutput = CFX_WideStringC(L' ') + wsOutput; + } + ccf--; + break; + case 's': + if (bNeg) { + CFX_WideString wsMinusSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); + wsOutput = wsMinusSymbol + wsOutput; + bAddNeg = TRUE; + } + ccf--; + break; + case 'E': { + CFX_WideString wsExp; + wsExp.Format(L"E%+d", exponent); + wsOutput = wsExp + wsOutput; + } + ccf--; + break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); + wsOutput = wsSymbol + wsOutput; + } + ccf--; + break; + case 'r': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { + if (bNeg) { + wsOutput = L"CR" + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'R': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { + if (bNeg) { + wsOutput = L"CR" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'b': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { + if (bNeg) { + wsOutput = L"db" + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case 'B': + if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { + if (bNeg) { + wsOutput = L"DB" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf -= 2; + bAddNeg = TRUE; + } + break; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + wsOutput = wsSymbol + wsOutput; + } + ccf--; + break; + case ',': + if (cc >= 0) { + wsOutput = wsGroupSymbol + wsOutput; + } + ccf--; + break; + case '(': + if (bNeg) { + wsOutput = L"(" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + bAddNeg = TRUE; + ccf--; + break; + case ')': + if (bNeg) { + wsOutput = L")" + wsOutput; + } else { + wsOutput = L" " + wsOutput; + } + ccf--; + break; + case '\'': + wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; + ccf--; + break; + default: + wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; + ccf--; + } + } + if (cc >= 0) { + int nPos = dot_index % 3; + wsOutput.Empty(); + for (int32_t i = 0; i < dot_index; i++) { + if (i % 3 == nPos && i != 0) { + wsOutput += wsGroupSymbol; + } + wsOutput += wsNumeric[i]; + } + if (dot_index < len) { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); + wsOutput += wsSymbol; + wsOutput += wsNumeric.Right(len - dot_index - 1); + } + if (bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = wsMinusymbol + wsOutput; + } + return FALSE; + } + if (dot_index_f == wsNumFormat.GetLength()) { + if (!bAddNeg && bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = wsMinusymbol + wsOutput; + } + return TRUE; + } + CFX_WideString wsDotSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); + if (strf[dot_index_f] == 'V') { + wsOutput += wsDotSymbol; + } else if (strf[dot_index_f] == '.') { + if (dot_index < len) { + wsOutput += wsDotSymbol; + } else { + if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { + wsOutput += wsDotSymbol; + } + } + } + ccf = dot_index_f + 1; + cc = dot_index + 1; + while (ccf < lenf) { + switch (strf[ccf]) { + case '\'': + wsOutput += FX_GetLiteralText(strf, ccf, lenf); + ccf++; + break; + case '9': + if (cc < len) { + wsOutput += str[cc]; + cc++; + } else { + wsOutput += L'0'; + } + ccf++; + break; + case 'z': + if (cc < len) { + wsOutput += str[cc]; + cc++; + } + ccf++; + break; + case 'Z': + if (cc < len) { + wsOutput += str[cc]; + cc++; + } else { + wsOutput += L'0'; + } + ccf++; + break; + case 'E': { + CFX_WideString wsExp; + wsExp.Format(L"E%+d", exponent); + wsOutput += wsExp; + } + ccf++; + break; + case '$': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); + wsOutput += wsSymbol; + } + ccf++; + break; + case 'c': + if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { + if (bNeg) { + wsOutput += L"CR"; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'C': + if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { + if (bNeg) { + wsOutput += L"CR"; + } else { + wsOutput += L" "; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'd': + if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { + if (bNeg) { + wsOutput += L"db"; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case 'D': + if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { + if (bNeg) { + wsOutput += L"DB"; + } else { + wsOutput += L" "; + } + ccf += 2; + bAddNeg = TRUE; + } + break; + case '%': { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); + wsOutput += wsSymbol; + } + ccf++; + break; + case '8': { + while (ccf < lenf && strf[ccf] == '8') { + ccf++; + } + while (cc < len && FX_IsDigit(str[cc])) { + wsOutput += str[cc]; + cc++; + } + } break; + case ',': + wsOutput += wsGroupSymbol; + ccf++; + break; + case '(': + if (bNeg) { + wsOutput += '('; + } else { + wsOutput += ' '; + } + bAddNeg = TRUE; + ccf++; + break; + case ')': + if (bNeg) { + wsOutput += ')'; + } else { + wsOutput += ' '; + } + ccf++; + break; + default: + ccf++; + } + } + if (!bAddNeg && bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = + wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); + } + return TRUE; +} +FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + return FormatStrNum(wsSrcNum, wsPattern, wsOutput); +} +FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsPattern.IsEmpty()) { + return FALSE; + } + CFX_LCNumeric lcNum(fNum); + return FormatLCNumeric(lcNum, wsPattern, wsOutput); +} +FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, + CFX_Unitime& datetime) { + int32_t year = 1900; + int32_t month = 1; + int32_t day = 1; + FX_WORD wYear = 0; + int cc_start = 0, cc = 0; + const FX_WCHAR* str = (const FX_WCHAR*)wsDate; + int len = wsDate.GetLength(); + if (len > 10) { + return FALSE; + } + while (cc < len && cc < 4) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + wYear = wYear * 10 + str[cc++] - '0'; + } + year = wYear; + if (cc < 4 || wYear < 1900) { + return FALSE; + } + if (cc < len) { + if (str[cc] == '-') { + cc++; + } + cc_start = cc; + uint8_t tmpM = 0; + while (cc < len && cc < cc_start + 2) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + tmpM = tmpM * 10 + str[cc++] - '0'; + } + month = tmpM; + if (cc == cc_start + 1 || tmpM > 12 || tmpM < 1) { + return FALSE; + } + if (cc < len) { + if (str[cc] == '-') { + cc++; + } + uint8_t tmpD = 0; + cc_start = cc; + while (cc < len && cc < cc_start + 2) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + tmpD = tmpD * 10 + str[cc++] - '0'; + } + day = tmpD; + if (tmpD < 1) { + return FALSE; + } + if ((tmpM == 1 || tmpM == 3 || tmpM == 5 || tmpM == 7 || tmpM == 8 || + tmpM == 10 || tmpM == 12) && + tmpD > 31) { + return FALSE; + } + if ((tmpM == 4 || tmpM == 6 || tmpM == 9 || tmpM == 11) && tmpD > 30) { + return FALSE; + } + FX_BOOL iLeapYear; + if ((wYear % 4 == 0 && wYear % 100 != 0) || wYear % 400 == 0) { + iLeapYear = TRUE; + } else { + iLeapYear = FALSE; + } + if ((iLeapYear && tmpM == 2 && tmpD > 29) || + (!iLeapYear && tmpM == 2 && tmpD > 28)) { + return FALSE; + } + } + } + CFX_Unitime ut; + ut.Set(year, month, day); + datetime = datetime + ut; + return TRUE; +} +FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime, + CFX_Unitime& datetime, + IFX_Locale* pLocale) { + if (wsTime.GetLength() == 0) { + return FALSE; + } + uint8_t hour = 0; + uint8_t minute = 0; + uint8_t second = 0; + FX_WORD millisecond = 0; + int cc_start = 0, cc = cc_start; + const FX_WCHAR* str = (const FX_WCHAR*)wsTime.GetPtr(); + int len = wsTime.GetLength(); + while (cc < len && cc < 2) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + hour = hour * 10 + str[cc++] - '0'; + } + if (cc < 2 || hour >= 24) { + return FALSE; + } + if (cc < len) { + if (str[cc] == ':') { + cc++; + } + cc_start = cc; + while (cc < len && cc < cc_start + 2) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + minute = minute * 10 + str[cc++] - '0'; + } + if (cc == cc_start + 1 || minute >= 60) { + return FALSE; + } + if (cc < len) { + if (str[cc] == ':') { + cc++; + } + cc_start = cc; + while (cc < len && cc < cc_start + 2) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + second = second * 10 + str[cc++] - '0'; + } + if (cc == cc_start + 1 || second >= 60) { + return FALSE; + } + if (cc < len) { + if (str[cc] == '.') { + cc++; + cc_start = cc; + while (cc < len && cc < cc_start + 3) { + if (!FX_IsDigit(str[cc])) { + return FALSE; + } + millisecond = millisecond * 10 + str[cc++] - '0'; + } + if (cc < cc_start + 3 || millisecond >= 1000) { + return FALSE; + } + } + if (cc < len) { + FX_TIMEZONE tzDiff; + tzDiff.tzHour = 0; + tzDiff.tzMinute = 0; + if (str[cc] != 'Z') { + cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); + } + FX_ResolveZone(hour, minute, tzDiff, pLocale); + } + } + } + } + CFX_Unitime ut; + ut.Set(0, 0, 0, hour, minute, second, millisecond); + datetime = datetime + ut; + return TRUE; +} +static FX_WORD FX_GetSolarMonthDays(FX_WORD year, FX_WORD month) { + if (month % 2) { + return 31; + } else if (month == 2) { + return FX_IsLeapYear(year) ? 29 : 28; + } + return 30; +} +static FX_WORD FX_GetWeekDay(FX_WORD year, FX_WORD month, FX_WORD day) { + FX_WORD g_month_day[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}; + FX_WORD nDays = + (year - 1) % 7 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; + nDays += g_month_day[month - 1] + day; + if (FX_IsLeapYear(year) && month > 2) { + nDays++; + } + return nDays % 7; +} +static FX_WORD FX_GetWeekOfMonth(FX_WORD year, FX_WORD month, FX_WORD day) { + FX_WORD week_day = FX_GetWeekDay(year, month, 1); + FX_WORD week_index = 0; + week_index += day / 7; + day = day % 7; + if (week_day + day > 7) { + week_index++; + } + return week_index; +} +static FX_WORD FX_GetWeekOfYear(FX_WORD year, FX_WORD month, FX_WORD day) { + FX_WORD nDays = 0; + for (FX_WORD i = 1; i < month; i++) { + nDays += FX_GetSolarMonthDays(year, i); + } + nDays += day; + FX_WORD week_day = FX_GetWeekDay(year, 1, 1); + FX_WORD week_index = 1; + week_index += nDays / 7; + nDays = nDays % 7; + if (week_day + nDays > 7) { + week_index++; + } + return week_index; +} +static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, + IFX_Locale* pLocale, + const CFX_Unitime& datetime, + CFX_WideString& wsResult) { + FX_BOOL bRet = TRUE; + int32_t year = datetime.GetYear(); + uint8_t month = datetime.GetMonth(); + uint8_t day = datetime.GetDay(); + int32_t ccf = 0; + const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; + int32_t lenf = wsDatePattern.GetLength(); + while (ccf < lenf) { + if (strf[ccf] == '\'') { + wsResult += FX_GetLiteralText(strf, ccf, lenf); + ccf++; + continue; + } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { + wsResult += strf[ccf++]; + continue; + } + FX_DWORD dwSymbolNum = 1; + FX_DWORD dwSymbol = strf[ccf++]; + while (ccf < lenf && strf[ccf] == dwSymbol) { + ccf++; + dwSymbolNum++; + } + dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); + if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { + CFX_WideString wsDay; + wsDay.Format(L"%d", day); + wsResult += wsDay; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { + CFX_WideString wsDay; + wsDay.Format(L"%02d", day); + wsResult += wsDay; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { + FX_WORD nDays = 0; + for (int i = 1; i < month; i++) { + nDays += FX_GetSolarMonthDays(year, i); + } + nDays += day; + CFX_WideString wsDays; + wsDays.Format(L"%d", nDays); + wsResult += wsDays; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { + FX_WORD nDays = 0; + for (int i = 1; i < month; i++) { + nDays += FX_GetSolarMonthDays(year, i); + } + nDays += day; + CFX_WideString wsDays; + wsDays.Format(L"%03d", nDays); + wsResult += wsDays; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { + CFX_WideString wsMonth; + wsMonth.Format(L"%d", month); + wsResult += wsMonth; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { + CFX_WideString wsMonth; + wsMonth.Format(L"%02d", month); + wsResult += wsMonth; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { + CFX_WideString wsTemp; + pLocale->GetMonthName(month - 1, wsTemp, TRUE); + wsResult += wsTemp; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { + CFX_WideString wsTemp; + pLocale->GetMonthName(month - 1, wsTemp, FALSE); + wsResult += wsTemp; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { + FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); + CFX_WideString wsWeekDay; + wsWeekDay.Format(L"%d", wWeekDay + 1); + wsResult += wsWeekDay; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { + FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); + CFX_WideString wsTemp; + pLocale->GetDayName(wWeekDay, wsTemp, TRUE); + wsResult += wsTemp; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { + FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); + if (pLocale) { + CFX_WideString wsTemp; + pLocale->GetDayName(wWeekDay, wsTemp, FALSE); + wsResult += wsTemp; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { + FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); + CFX_WideString wsWeekDay; + wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); + wsResult += wsWeekDay; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { + CFX_WideString wsTemp; + pLocale->GetEraName(wsTemp, year < 0); + wsResult += wsTemp; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { + CFX_WideString wsYear; + wsYear.Format(L"%02d", year % 100); + wsResult += wsYear; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { + CFX_WideString wsYear; + wsYear.Format(L"%d", year); + wsResult += wsYear; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { + FX_WORD week_index = FX_GetWeekOfMonth(year, month, day); + CFX_WideString wsWeekInMonth; + wsWeekInMonth.Format(L"%d", week_index); + wsResult += wsWeekInMonth; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { + FX_WORD week_index = FX_GetWeekOfYear(year, month, day); + CFX_WideString wsWeekInYear; + wsWeekInYear.Format(L"%02d", week_index); + wsResult += wsWeekInYear; + } + } + return bRet; +} +static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern, + IFX_Locale* pLocale, + const CFX_Unitime& datetime, + CFX_WideString& wsResult) { + FX_BOOL bGMT = FALSE; + FX_BOOL bRet = TRUE; + uint8_t hour = datetime.GetHour(); + uint8_t minute = datetime.GetMinute(); + uint8_t second = datetime.GetSecond(); + FX_WORD millisecond = datetime.GetMillisecond(); + int32_t ccf = 0; + const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; + int32_t lenf = wsTimePattern.GetLength(); + FX_WORD wHour = hour; + FX_BOOL bPM = FALSE; + if (wsTimePattern.Find('A') != -1) { + if (wHour >= 12) { + bPM = TRUE; + } + } + while (ccf < lenf) { + if (strf[ccf] == '\'') { + wsResult += FX_GetLiteralText(strf, ccf, lenf); + ccf++; + continue; + } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) < 0) { + wsResult += strf[ccf++]; + continue; + } + FX_DWORD dwSymbolNum = 1; + FX_DWORD dwSymbol = strf[ccf++]; + while (ccf < lenf && strf[ccf] == dwSymbol) { + ccf++; + dwSymbolNum++; + } + dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); + if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) { + if (wHour > 12) { + wHour -= 12; + } + CFX_WideString wsHour; + wsHour.Format(L"%d", wHour == 0 ? 12 : wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'h', '2')) { + if (wHour > 12) { + wHour -= 12; + } + CFX_WideString wsHour; + wsHour.Format(L"%02d", wHour == 0 ? 12 : wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { + CFX_WideString wsHour; + wsHour.Format(L"%d", wHour == 0 ? 24 : wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { + CFX_WideString wsHour; + wsHour.Format(L"%02d", wHour == 0 ? 24 : wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1')) { + if (wHour > 12) { + wHour -= 12; + } + CFX_WideString wsHour; + wsHour.Format(L"%d", wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'H', '1')) { + CFX_WideString wsHour; + wsHour.Format(L"%d", wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2')) { + if (wHour > 12) { + wHour -= 12; + } + CFX_WideString wsHour; + wsHour.Format(L"%02d", wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'H', '2')) { + CFX_WideString wsHour; + wsHour.Format(L"%02d", wHour); + wsResult += wsHour; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { + CFX_WideString wsMinute; + wsMinute.Format(L"%d", minute); + wsResult += wsMinute; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { + CFX_WideString wsMinute; + wsMinute.Format(L"%02d", minute); + wsResult += wsMinute; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { + CFX_WideString wsSecond; + wsSecond.Format(L"%d", second); + wsResult += wsSecond; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { + CFX_WideString wsSecond; + wsSecond.Format(L"%02d", second); + wsResult += wsSecond; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { + CFX_WideString wsMilliseconds; + wsMilliseconds.Format(L"%03d", millisecond); + wsResult += wsMilliseconds; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { + CFX_WideString wsMeridiem; + pLocale->GetMeridiemName(wsMeridiem, !bPM); + wsResult += wsMeridiem; + } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { + wsResult += FX_WSTRC(L"GMT"); + FX_TIMEZONE tz; + pLocale->GetTimeZone(tz); + if (!bGMT && (tz.tzHour != 0 || tz.tzMinute != 0)) { + if (tz.tzHour < 0) { + wsResult += FX_WSTRC(L"-"); + } else { + wsResult += FX_WSTRC(L"+"); + } + CFX_WideString wsTimezone; + wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); + wsResult += wsTimezone; + } + } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { + FX_TIMEZONE tz; + pLocale->GetTimeZone(tz); + if (!bGMT && tz.tzHour != 0 && tz.tzMinute != 0) { + if (tz.tzHour < 0) { + wsResult += FX_WSTRC(L"-"); + } else { + wsResult += FX_WSTRC(L"+"); + } + CFX_WideString wsTimezone; + wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); + wsResult += wsTimezone; + } + } + } + return bRet; +} +static FX_BOOL FX_FormatDateTime(const CFX_Unitime& dt, + const CFX_WideString& wsDatePattern, + const CFX_WideString& wsTimePattern, + FX_BOOL bDateFirst, + IFX_Locale* pLocale, + CFX_WideString& wsOutput) { + FX_BOOL bRet = TRUE; + CFX_WideString wsDateOut, wsTimeOut; + if (!wsDatePattern.IsEmpty()) { + bRet &= FX_DateFormat(wsDatePattern, pLocale, dt, wsDateOut); + } + if (!wsTimePattern.IsEmpty()) { + bRet &= FX_TimeFormat(wsTimePattern, pLocale, dt, wsTimeOut); + } + wsOutput = bDateFirst ? wsDateOut + wsTimeOut : wsTimeOut + wsDateOut; + return bRet; +} +FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsDatePattern, wsTimePattern; + IFX_Locale* pLocale = NULL; + FX_DATETIMETYPE eCategory = + GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); + if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { + return FALSE; + } + CFX_Unitime dt(0); + int32_t iT = wsSrcDateTime.Find(L"T"); + if (iT < 0) { + if (eCategory == FX_DATETIMETYPE_Date) { + FX_DateFromCanonical(wsSrcDateTime, dt); + } else if (eCategory == FX_DATETIMETYPE_Time) { + FX_TimeFromCanonical(wsSrcDateTime, dt, pLocale); + } + } else { + FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); + FX_TimeFromCanonical( + wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1), dt, pLocale); + } + return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, + eCategory != FX_DATETIMETYPE_TimeDate, pLocale, + wsOutput); +} +FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput, + FX_DATETIMETYPE eDateTimeType) { + if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsDatePattern, wsTimePattern; + IFX_Locale* pLocale = NULL; + FX_DATETIMETYPE eCategory = + GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); + if (!pLocale) { + return FALSE; + } + if (eCategory == FX_DATETIMETYPE_Unknown) { + if (eDateTimeType == FX_DATETIMETYPE_Time) { + wsTimePattern = wsDatePattern; + wsDatePattern.Empty(); + } + eCategory = eDateTimeType; + } + if (eCategory == FX_DATETIMETYPE_Unknown) { + return FALSE; + } + CFX_Unitime dt(0); + int32_t iT = wsSrcDateTime.Find(L"T"); + if (iT < 0) { + if (eCategory == FX_DATETIMETYPE_Date && + FX_DateFromCanonical(wsSrcDateTime, dt)) { + return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, + wsOutput); + } else if (eCategory == FX_DATETIMETYPE_Time && + FX_TimeFromCanonical(wsSrcDateTime, 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, + wsSrcDateTime.GetLength() - iT - 1); + if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { + return FALSE; + } + if (FX_DateFromCanonical(wsSrcDate, dt) && + FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { + return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, + eCategory != FX_DATETIMETYPE_TimeDate, pLocale, + wsOutput); + } + } + return FALSE; +} +FX_BOOL CFX_FormatString::FormatDateTime(const CFX_Unitime& dt, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsDatePattern, wsTimePattern; + IFX_Locale* pLocale = NULL; + FX_DATETIMETYPE eCategory = + GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); + if (!pLocale) { + return FALSE; + } + return FX_FormatDateTime(dt, wsPattern, wsTimePattern, + eCategory != FX_DATETIMETYPE_TimeDate, pLocale, + wsOutput); +} +FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsTextFormat; + GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); + int32_t iPattern = 0; + const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern) { + if (pStrPattern[iPattern] == '\'') { + wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + iPattern++; + continue; + } else { + wsOutput += pStrPattern[iPattern++]; + continue; + } + } + return TRUE; +} +FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, + CFX_WideString& wsOutput) { + if (wsPattern.IsEmpty()) { + return FALSE; + } + CFX_WideString wsTextFormat; + GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); + int32_t iPattern = 0; + const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; + int32_t iLenPattern = wsTextFormat.GetLength(); + while (iPattern < iLenPattern) { + if (pStrPattern[iPattern] == '\'') { + wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); + iPattern++; + continue; + } else { + wsOutput += pStrPattern[iPattern++]; + continue; + } + } + return TRUE; +} +IFX_Locale* CFX_FormatString::GetPatternLocale( + const CFX_WideStringC& wsLocale) { + if (m_bUseLCID) { + } + return m_pLocaleMgr->GetLocaleByName(wsLocale); +} +#define FXMATH_DECIMAL_SCALELIMIT 0x1c +#define FXMATH_DECIMAL_NEGMASK (0x80000000L) +#define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) +#define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ + (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) +#define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ + FXMATH_DECIMAL_FORCEBOOL((FLAGS)&FXMATH_DECIMAL_NEGMASK) +#define FXMATH_DECIMAL_FLAGS2SCALE(FLAGS) \ + ((uint8_t)(((FLAGS) & ~FXMATH_DECIMAL_NEGMASK) >> 0x10)) +#define FXMATH_DECIMAL_RSHIFT32BIT(x) ((x) >> 0x10 >> 0x10) +#define FXMATH_DECIMAL_LSHIFT32BIT(x) ((x) << 0x10 << 0x10) +static inline uint8_t fxmath_decimal_helper_div10(uint64_t& phi, + uint64_t& pmid, + uint64_t& plo) { + uint8_t retVal; + pmid += FXMATH_DECIMAL_LSHIFT32BIT(phi % 0xA); + phi /= 0xA; + plo += FXMATH_DECIMAL_LSHIFT32BIT(pmid % 0xA); + pmid /= 0xA; + retVal = plo % 0xA; + plo /= 0xA; + return retVal; +} +static inline uint8_t fxmath_decimal_helper_div10_any(uint64_t nums[], + uint8_t numcount) { + uint8_t retVal = 0; + for (int i = numcount - 1; i > 0; i--) { + nums[i - 1] += FXMATH_DECIMAL_LSHIFT32BIT(nums[i] % 0xA); + nums[i] /= 0xA; + } + if (numcount) { + retVal = nums[0] % 0xA; + nums[0] /= 0xA; + } + return retVal; +} +static inline void fxmath_decimal_helper_mul10(uint64_t& phi, + uint64_t& pmid, + uint64_t& plo) { + plo *= 0xA; + pmid = pmid * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(plo); + plo = (uint32_t)plo; + phi = phi * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(pmid); + pmid = (uint32_t)pmid; +} +static inline void fxmath_decimal_helper_mul10_any(uint64_t nums[], + uint8_t numcount) { + nums[0] *= 0xA; + for (int i = 1; i < numcount; i++) { + nums[i] = nums[i] * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(nums[i - 1]); + nums[i - 1] = (uint32_t)nums[i - 1]; + } +} +static inline void fxmath_decimal_helper_normalize(uint64_t& phi, + uint64_t& pmid, + uint64_t& plo) { + phi += FXMATH_DECIMAL_RSHIFT32BIT(pmid); + pmid = (uint32_t)pmid; + pmid += FXMATH_DECIMAL_RSHIFT32BIT(plo); + plo = (uint32_t)plo; + phi += FXMATH_DECIMAL_RSHIFT32BIT(pmid); + pmid = (uint32_t)pmid; +} +static inline void fxmath_decimal_helper_normalize_any(uint64_t nums[], + uint8_t len) { + { + for (int i = len - 2; i > 0; i--) { + nums[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(nums[i]); + nums[i] = (uint32_t)nums[i]; + } + } + { + for (int i = 0; i < len - 1; i++) { + nums[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(nums[i]); + nums[i] = (uint32_t)nums[i]; + } + } +} +static inline int8_t fxmath_decimal_helper_raw_compare(uint32_t hi1, + uint32_t mid1, + uint32_t lo1, + uint32_t hi2, + uint32_t mid2, + uint32_t lo2) { + int8_t retVal = 0; + if (!retVal) { + retVal += (hi1 > hi2 ? 1 : (hi1 < hi2 ? -1 : 0)); + } + if (!retVal) { + retVal += (mid1 > mid2 ? 1 : (mid1 < mid2 ? -1 : 0)); + } + if (!retVal) { + retVal += (lo1 > lo2 ? 1 : (lo1 < lo2 ? -1 : 0)); + } + return retVal; +} +static inline int8_t fxmath_decimal_helper_raw_compare_any(uint64_t a[], + uint8_t al, + uint64_t b[], + uint8_t bl) { + int8_t retVal = 0; + for (int i = std::max(al - 1, bl - 1); i >= 0; i--) { + uint64_t l = (i >= al ? 0 : a[i]), r = (i >= bl ? 0 : b[i]); + retVal += (l > r ? 1 : (l < r ? -1 : 0)); + if (retVal) { + return retVal; + } + } + return retVal; +} +static inline void fxmath_decimal_helper_dec_any(uint64_t a[], uint8_t al) { + for (int i = 0; i < al; i++) { + if (a[i]--) { + return; + } + } +} +static inline void fxmath_decimal_helper_inc_any(uint64_t a[], uint8_t al) { + for (int i = 0; i < al; i++) { + a[i]++; + if ((uint32_t)a[i] == a[i]) { + return; + } + a[i] = 0; + } +} +static inline void fxmath_decimal_helper_raw_mul(uint64_t a[], + uint8_t al, + uint64_t b[], + uint8_t bl, + uint64_t c[], + uint8_t cl) { + assert(al + bl <= cl); + { + for (int i = 0; i < cl; i++) { + c[i] = 0; + } + } + { + for (int i = 0; i < al; i++) { + for (int j = 0; j < bl; j++) { + uint64_t m = (uint64_t)a[i] * b[j]; + c[i + j] += (uint32_t)m; + c[i + j + 1] += FXMATH_DECIMAL_RSHIFT32BIT(m); + } + } + } + { + for (int i = 0; i < cl - 1; i++) { + c[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(c[i]); + c[i] = (uint32_t)c[i]; + } + } + { + for (int i = 0; i < cl; i++) { + c[i] = (uint32_t)c[i]; + } + } +} +static inline void fxmath_decimal_helper_raw_div(uint64_t a[], + uint8_t al, + uint64_t b[], + uint8_t bl, + uint64_t c[], + uint8_t cl) { + int i; + for (i = 0; i < cl; i++) { + c[i] = 0; + } + uint64_t left[16] = {0}, right[16] = {0}; + left[0] = 0; + for (i = 0; i < al; i++) { + right[i] = a[i]; + } + uint64_t tmp[16]; + while (fxmath_decimal_helper_raw_compare_any(left, al, right, al) <= 0) { + uint64_t cur[16]; + for (i = 0; i < al; i++) { + cur[i] = left[i] + right[i]; + } + for (i = al - 1; i >= 0; i--) { + if (i) { + cur[i - 1] += FXMATH_DECIMAL_LSHIFT32BIT(cur[i] % 2); + } + cur[i] /= 2; + } + fxmath_decimal_helper_raw_mul(cur, al, b, bl, tmp, 16); + switch (fxmath_decimal_helper_raw_compare_any(tmp, 16, a, al)) { + case -1: + for (i = 0; i < 16; i++) { + left[i] = cur[i]; + } + left[0]++; + fxmath_decimal_helper_normalize_any(left, al); + break; + case 1: + for (i = 0; i < 16; i++) { + right[i] = cur[i]; + } + fxmath_decimal_helper_dec_any(right, al); + break; + case 0: + for (i = 0; i < std::min(al, cl); i++) { + c[i] = cur[i]; + } + return; + } + } + for (i = 0; i < std::min(al, cl); i++) { + c[i] = left[i]; + } +} +static inline FX_BOOL fxmath_decimal_helper_outofrange(uint64_t a[], + uint8_t al, + uint8_t goal) { + for (int i = goal; i < al; i++) { + if (a[i]) { + return TRUE; + } + } + return FALSE; +} +static inline void fxmath_decimal_helper_shrinkintorange(uint64_t a[], + uint8_t al, + uint8_t goal, + uint8_t& scale) { + FX_BOOL bRoundUp = FALSE; + while (scale != 0 && (scale > FXMATH_DECIMAL_SCALELIMIT || + fxmath_decimal_helper_outofrange(a, al, goal))) { + bRoundUp = fxmath_decimal_helper_div10_any(a, al) >= 5; + scale--; + } + if (bRoundUp) { + fxmath_decimal_helper_normalize_any(a, goal); + fxmath_decimal_helper_inc_any(a, goal); + } +} +static inline void fxmath_decimal_helper_truncate(uint64_t& phi, + uint64_t& pmid, + uint64_t& plo, + uint8_t& scale, + uint8_t minscale = 0) { + while (scale > minscale) { + uint64_t thi = phi, tmid = pmid, tlo = plo; + if (fxmath_decimal_helper_div10(thi, tmid, tlo) != 0) { + break; + } + phi = thi, pmid = tmid, plo = tlo; + scale--; + } +} +CFX_Decimal::CFX_Decimal() { + m_uLo = m_uMid = m_uHi = m_uFlags = 0; +} +CFX_Decimal::CFX_Decimal(uint64_t val) { + m_uLo = (uint32_t)val; + m_uMid = (uint32_t)FXMATH_DECIMAL_RSHIFT32BIT(val); + m_uHi = 0; + m_uFlags = 0; +} +CFX_Decimal::CFX_Decimal(uint32_t val) { + m_uLo = (uint32_t)val; + m_uMid = m_uHi = 0; + m_uFlags = 0; +} +CFX_Decimal::CFX_Decimal(uint32_t lo, + uint32_t mid, + uint32_t hi, + FX_BOOL neg, + uint8_t scale) { + scale = (scale > FXMATH_DECIMAL_SCALELIMIT ? 0 : scale); + m_uLo = lo; + m_uMid = mid; + m_uHi = hi; + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(neg && IsNotZero(), scale); +} +CFX_Decimal::CFX_Decimal(int32_t val) { + if (val >= 0) { + *this = CFX_Decimal((uint32_t)val); + } else { + *this = CFX_Decimal((uint32_t)-val); + SetNegate(); + } +} +CFX_Decimal::CFX_Decimal(int64_t val) { + if (val >= 0) { + *this = CFX_Decimal((uint64_t)val); + } else { + *this = CFX_Decimal((uint64_t)-val); + SetNegate(); + } +} +CFX_Decimal::CFX_Decimal(FX_FLOAT val, uint8_t scale) { + FX_FLOAT newval = fabs(val); + uint64_t phi, pmid, plo; + plo = (uint64_t)newval; + pmid = (uint64_t)(newval / 1e32); + phi = (uint64_t)(newval / 1e64); + newval = FXSYS_fmod(newval, 1.0f); + for (uint8_t iter = 0; iter < scale; iter++) { + fxmath_decimal_helper_mul10(phi, pmid, plo); + newval *= 10; + plo += (uint64_t)newval; + newval = FXSYS_fmod(newval, 1.0f); + } + plo += FXSYS_round(newval); + fxmath_decimal_helper_normalize(phi, pmid, plo); + m_uHi = (uint32_t)phi; + m_uMid = (uint32_t)pmid; + m_uLo = (uint32_t)plo; + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale); +} +CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) { + const FX_WCHAR* str = strObj.GetPtr(); + const FX_WCHAR* strBound = str + strObj.GetLength(); + FX_BOOL pointmet = 0; + FX_BOOL negmet = 0; + uint8_t scale = 0; + m_uHi = m_uMid = m_uLo = 0; + while (str != strBound && *str == ' ') { + str++; + } + if (str != strBound && *str == '-') { + negmet = 1; + str++; + } else if (str != strBound && *str == '+') { + str++; + } + while (str != strBound && ((*str >= '0' && *str <= '9') || *str == '.') && + scale < FXMATH_DECIMAL_SCALELIMIT) { + if (*str == '.') { + if (pointmet) { + goto cont; + } + pointmet = 1; + } else { + m_uHi = m_uHi * 0xA + FXMATH_DECIMAL_RSHIFT32BIT((uint64_t)m_uMid * 0xA); + m_uMid = m_uMid * 0xA + FXMATH_DECIMAL_RSHIFT32BIT((uint64_t)m_uLo * 0xA); + m_uLo = m_uLo * 0xA + (*str - '0'); + if (pointmet) { + scale++; + } + } + cont: + str++; + } + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); +} + +CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { + *this = CFX_Decimal(CFX_WideString::FromLocal(strObj)); +} + +CFX_Decimal::operator CFX_WideString() const { + CFX_WideString retString; + CFX_WideString tmpbuf; + uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; + while (phi || pmid || plo) { + tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; + } + uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); + uint8_t scale = (uint8_t)FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); + while (scale >= outputlen) { + tmpbuf += '0'; + outputlen++; + } + if (FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero()) { + retString += '-'; + } + for (uint8_t idx = 0; idx < outputlen; idx++) { + if (idx == (outputlen - scale) && scale != 0) { + retString += '.'; + } + retString += tmpbuf[outputlen - 1 - idx]; + } + return retString; +} +CFX_Decimal::operator double() const { + double pow = (double)(1 << 16) * (1 << 16); + double base = + ((double)m_uHi) * pow * pow + ((double)m_uMid) * pow + ((double)m_uLo); + int8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); + FX_BOOL bNeg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags); + return (bNeg ? -1 : 1) * base * ::pow(10.0, -scale); +} +void CFX_Decimal::SetScale(uint8_t newscale) { + uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); + if (newscale > oldscale) { + uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; + for (uint8_t iter = 0; iter < newscale - oldscale; iter++) { + fxmath_decimal_helper_mul10(phi, pmid, plo); + } + m_uHi = (uint32_t)phi; + m_uMid = (uint32_t)pmid; + m_uLo = (uint32_t)plo; + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( + FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), newscale); + } else if (newscale < oldscale) { + uint64_t phi, pmid, plo; + phi = 0, pmid = 0, plo = 5; + { + for (uint8_t iter = 0; iter < oldscale - newscale - 1; iter++) { + fxmath_decimal_helper_mul10(phi, pmid, plo); + } + } + phi += m_uHi; + pmid += m_uMid; + plo += m_uLo; + fxmath_decimal_helper_normalize(phi, pmid, plo); + { + for (uint8_t iter = 0; iter < oldscale - newscale; iter++) { + fxmath_decimal_helper_div10(phi, pmid, plo); + } + } + m_uHi = (uint32_t)phi; + m_uMid = (uint32_t)pmid; + m_uLo = (uint32_t)plo; + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( + FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), newscale); + } +} +uint8_t CFX_Decimal::GetScale() { + uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); + return oldscale; +} +void CFX_Decimal::SetAbs() { + m_uFlags &= ~FXMATH_DECIMAL_NEGMASK; +} +void CFX_Decimal::SetNegate() { + if (IsNotZero()) { + m_uFlags ^= FXMATH_DECIMAL_NEGMASK; + } +} +void CFX_Decimal::FloorOrCeil(FX_BOOL bFloor) { + uint64_t nums[3] = {m_uLo, m_uMid, m_uHi}; + FX_BOOL bDataLoss = FALSE; + for (int i = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); i > 0; i--) { + bDataLoss = fxmath_decimal_helper_div10_any(nums, 3) || bDataLoss; + } + if (bDataLoss && (bFloor ? FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) + : !FXMATH_DECIMAL_FLAGS2NEG(m_uFlags))) { + fxmath_decimal_helper_inc_any(nums, 3); + } + m_uHi = (uint32_t)nums[2]; + m_uMid = (uint32_t)nums[1]; + m_uLo = (uint32_t)nums[0]; + m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( + FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), 0); +} +void CFX_Decimal::SetFloor() { + FloorOrCeil(TRUE); +} +void CFX_Decimal::SetCeiling() { + FloorOrCeil(FALSE); +} +void CFX_Decimal::SetTruncate() { + FloorOrCeil(!FXMATH_DECIMAL_FLAGS2NEG(m_uFlags)); +} +void CFX_Decimal::Swap(CFX_Decimal& val) { + uint32_t tmp; + tmp = m_uHi; + m_uHi = val.m_uHi; + val.m_uHi = tmp; + tmp = m_uMid; + m_uMid = val.m_uMid; + val.m_uMid = tmp; + tmp = m_uLo; + m_uLo = val.m_uLo; + val.m_uLo = tmp; + tmp = m_uFlags; + m_uFlags = val.m_uFlags; + val.m_uFlags = tmp; +} +int8_t CFX_Decimal::Compare(const CFX_Decimal& val) const { + CFX_Decimal lhs = *this, rhs = val; + int8_t retVal = 0; + if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { + uint8_t scale = std::min(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); + lhs.SetScale(scale); + rhs.SetScale(scale); + } + retVal = -(FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) - + FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)); + if (retVal) { + return retVal; + } + retVal = fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, + rhs.m_uHi, rhs.m_uMid, rhs.m_uLo); + return (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) ? -retVal : retVal); +} +CFX_Decimal CFX_Decimal::AddOrMinus(const CFX_Decimal& val, + FX_BOOL isAdding) const { + CFX_Decimal lhs = *this, rhs = val; + if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { + uint8_t scale = std::max(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); + lhs.SetScale(scale); + rhs.SetScale(scale); + } + if (!isAdding) { + rhs.SetNegate(); + } + if (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) == + FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)) { + uint64_t phi = lhs.m_uHi, pmid = lhs.m_uMid, plo = lhs.m_uLo; + phi += rhs.m_uHi; + pmid += rhs.m_uMid; + plo += rhs.m_uLo; + fxmath_decimal_helper_normalize(phi, pmid, plo); + if (FXMATH_DECIMAL_RSHIFT32BIT(phi) && + FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != 0) { + fxmath_decimal_helper_div10(phi, pmid, plo); + lhs.m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( + FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags), + FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) - 1); + } + lhs.m_uHi = (uint32_t)phi; + lhs.m_uMid = (uint32_t)pmid; + lhs.m_uLo = (uint32_t)plo; + return lhs; + } else { + if (fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, + rhs.m_uHi, rhs.m_uMid, + rhs.m_uLo) < 0) { + lhs.Swap(rhs); + } + lhs.m_uHi -= rhs.m_uHi; + if (lhs.m_uMid < rhs.m_uMid) { + lhs.m_uHi--; + } + lhs.m_uMid -= rhs.m_uMid; + if (lhs.m_uLo < rhs.m_uLo) { + if (!lhs.m_uMid) { + lhs.m_uHi--; + } + lhs.m_uMid--; + } + lhs.m_uLo -= rhs.m_uLo; + return lhs; + } +} +CFX_Decimal CFX_Decimal::Multiply(const CFX_Decimal& val) const { + uint64_t a[3] = {m_uLo, m_uMid, m_uHi}, + b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}; + uint64_t c[6]; + fxmath_decimal_helper_raw_mul(a, 3, b, 3, c, 6); + FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ + FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); + uint8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) + + FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); + fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); + return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, + scale); +} +CFX_Decimal CFX_Decimal::Divide(const CFX_Decimal& val) const { + if (!val.IsNotZero()) { + return CFX_Decimal(); + } + FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ + FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); + uint64_t a[7] = {m_uLo, m_uMid, m_uHi}, + b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}, c[7] = {0}; + uint8_t scale = 0; + if (FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) < + FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags)) { + for (int i = FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags) - + FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); + i > 0; i--) { + fxmath_decimal_helper_mul10_any(a, 7); + } + } else { + scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) - + FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); + } + uint8_t minscale = scale; + if (!IsNotZero()) { + return CFX_Decimal(0, 0, 0, 0, minscale); + } + while (!a[6]) { + fxmath_decimal_helper_mul10_any(a, 7); + scale++; + } + fxmath_decimal_helper_div10_any(a, 7); + scale--; + fxmath_decimal_helper_raw_div(a, 6, b, 3, c, 7); + fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); + fxmath_decimal_helper_truncate(c[2], c[1], c[0], scale, minscale); + return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, + scale); +} +CFX_Decimal CFX_Decimal::Modulus(const CFX_Decimal& val) const { + CFX_Decimal lhs = *this, rhs_abs = val; + rhs_abs.SetAbs(); + if (!rhs_abs.IsNotZero()) { + return *this; + } + while (TRUE) { + CFX_Decimal lhs_abs = lhs; + lhs_abs.SetAbs(); + if (lhs_abs < rhs_abs) { + break; + } + CFX_Decimal quot = lhs / rhs_abs; + quot.SetTruncate(); + lhs = lhs - quot * rhs_abs; + } + return lhs; +} +bool CFX_Decimal::operator==(const CFX_Decimal& val) const { + return Compare(val) == 0; +} +bool CFX_Decimal::operator<=(const CFX_Decimal& val) const { + return Compare(val) <= 0; +} +bool CFX_Decimal::operator>=(const CFX_Decimal& val) const { + return Compare(val) >= 0; +} +bool CFX_Decimal::operator!=(const CFX_Decimal& val) const { + return Compare(val) != 0; +} +bool CFX_Decimal::operator<(const CFX_Decimal& val) const { + return Compare(val) < 0; +} +bool CFX_Decimal::operator>(const CFX_Decimal& val) const { + return Compare(val) > 0; +} +CFX_Decimal CFX_Decimal::operator+(const CFX_Decimal& val) const { + return AddOrMinus(val, TRUE); +} +CFX_Decimal CFX_Decimal::operator-(const CFX_Decimal& val) const { + return AddOrMinus(val, FALSE); +} +CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { + return Multiply(val); +} +CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { + return Divide(val); +} +CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { + return Modulus(val); +} diff --git a/xfa/fgas/localization/fgas_locale.h b/xfa/fgas/localization/fgas_locale.h new file mode 100644 index 0000000000..a7e14b3c26 --- /dev/null +++ b/xfa/fgas/localization/fgas_locale.h @@ -0,0 +1,206 @@ +// 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_LOCALIZATION_FGAS_LOCALE_H_ +#define XFA_FGAS_LOCALIZATION_FGAS_LOCALE_H_ + +#include "core/include/fxcrt/fx_xml.h" +#include "xfa/fgas/localization/fgas_datetime.h" + +class CFX_Unitime; + +enum FX_LOCALENUMSYMBOL { + FX_LOCALENUMSYMBOL_Decimal, + FX_LOCALENUMSYMBOL_Grouping, + FX_LOCALENUMSYMBOL_Percent, + FX_LOCALENUMSYMBOL_Minus, + FX_LOCALENUMSYMBOL_Zero, + FX_LOCALENUMSYMBOL_CurrencySymbol, + FX_LOCALENUMSYMBOL_CurrencyName, +}; +enum FX_LOCALEDATETIMESUBCATEGORY { + FX_LOCALEDATETIMESUBCATEGORY_Default, + FX_LOCALEDATETIMESUBCATEGORY_Short, + FX_LOCALEDATETIMESUBCATEGORY_Medium, + FX_LOCALEDATETIMESUBCATEGORY_Full, + FX_LOCALEDATETIMESUBCATEGORY_Long, +}; +enum FX_LOCALENUMSUBCATEGORY { + FX_LOCALENUMPATTERN_Percent, + FX_LOCALENUMPATTERN_Currency, + FX_LOCALENUMPATTERN_Decimal, + FX_LOCALENUMPATTERN_Integer, +}; +enum FX_LOCALECATEGORY { + FX_LOCALECATEGORY_Unknown, + FX_LOCALECATEGORY_Date, + FX_LOCALECATEGORY_Time, + FX_LOCALECATEGORY_DateTime, + FX_LOCALECATEGORY_Num, + FX_LOCALECATEGORY_Text, + FX_LOCALECATEGORY_Zero, + FX_LOCALECATEGORY_Null, +}; +enum FX_DATETIMETYPE { + FX_DATETIMETYPE_Unknown, + FX_DATETIMETYPE_Date, + FX_DATETIMETYPE_Time, + FX_DATETIMETYPE_DateTime, + FX_DATETIMETYPE_TimeDate, +}; + +class IFX_Locale { + public: + static IFX_Locale* Create(CXML_Element* pLocaleData); + + virtual ~IFX_Locale() {} + virtual void Release() = 0; + + virtual CFX_WideString GetName() = 0; + + virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const = 0; + virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0; + virtual void GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr = TRUE) const = 0; + virtual void GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr = TRUE) const = 0; + virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM = TRUE) const = 0; + virtual void GetTimeZone(FX_TIMEZONE& tz) const = 0; + virtual void GetEraName(CFX_WideString& wsEraName, + FX_BOOL bAD = TRUE) const = 0; + virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const = 0; + virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const = 0; + virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const = 0; +}; + +class IFX_LocaleMgr { + public: + virtual ~IFX_LocaleMgr() {} + virtual void Release() = 0; + virtual FX_WORD GetDefLocaleID() = 0; + virtual IFX_Locale* GetDefLocale() = 0; + virtual IFX_Locale* GetLocale(FX_WORD lcid) = 0; + virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName) = 0; +}; +IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, + FX_WORD wDefaultLCID); +void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult); +FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, + CFX_Unitime& datetime); +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 FX_WORD 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(); + CFX_Decimal(uint32_t val); + CFX_Decimal(uint64_t val); + CFX_Decimal(int32_t val); + CFX_Decimal(int64_t val); + CFX_Decimal(FX_FLOAT val, uint8_t scale = 3); + CFX_Decimal(const CFX_WideStringC& str); + CFX_Decimal(const CFX_ByteStringC& str); + operator CFX_WideString() const; + operator double() const; + bool operator==(const CFX_Decimal& val) const; + bool operator<=(const CFX_Decimal& val) const; + bool operator>=(const CFX_Decimal& val) const; + bool operator!=(const CFX_Decimal& val) const; + bool operator<(const CFX_Decimal& val) const; + bool operator>(const CFX_Decimal& val) const; + CFX_Decimal operator+(const CFX_Decimal& val) const; + CFX_Decimal operator-(const CFX_Decimal& val) const; + CFX_Decimal operator*(const CFX_Decimal& val) const; + CFX_Decimal operator/(const CFX_Decimal& val) const; + CFX_Decimal operator%(const CFX_Decimal& val) const; + void SetScale(uint8_t newScale); + uint8_t GetScale(); + void SetAbs(); + void SetNegate(); + void SetFloor(); + void SetCeiling(); + void SetTruncate(); + + protected: + CFX_Decimal(uint32_t hi, + uint32_t mid, + uint32_t lo, + FX_BOOL neg, + uint8_t scale); + inline FX_BOOL IsNotZero() const { return m_uHi || m_uMid || m_uLo; } + inline int8_t Compare(const CFX_Decimal& val) const; + inline void Swap(CFX_Decimal& val); + inline void FloorOrCeil(FX_BOOL bFloor); + CFX_Decimal AddOrMinus(const CFX_Decimal& val, FX_BOOL isAdding) const; + CFX_Decimal Multiply(const CFX_Decimal& val) const; + CFX_Decimal Divide(const CFX_Decimal& val) const; + CFX_Decimal Modulus(const CFX_Decimal& val) const; + uint32_t m_uFlags; + uint32_t m_uHi; + uint32_t m_uLo; + uint32_t m_uMid; +}; + +#endif // XFA_FGAS_LOCALIZATION_FGAS_LOCALE_H_ diff --git a/xfa/fgas/localization/fgas_localeimp.h b/xfa/fgas/localization/fgas_localeimp.h new file mode 100644 index 0000000000..f4b2b0ec8a --- /dev/null +++ b/xfa/fgas/localization/fgas_localeimp.h @@ -0,0 +1,122 @@ +// 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_LOCALIZATION_FGAS_LOCALEIMP_H_ +#define XFA_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ + +#include "xfa/fgas/localization/fgas_locale.h" + +class CFX_LCNumeric; + +class CFX_Locale : public IFX_Locale { + public: + CFX_Locale(CXML_Element* pLocaleData); + virtual void Release() { delete this; } + + virtual CFX_WideString GetName(); + virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const; + + virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; + virtual void GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM = TRUE) const; + virtual void GetTimeZone(FX_TIMEZONE& tz) const; + virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; + + virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const; + + protected: + virtual ~CFX_Locale(); + CXML_Element* m_pElement; +}; + +class CFX_FormatString : public IFX_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 FX_WORD 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); + + protected: + virtual ~CFX_FormatString(); + IFX_Locale* GetTextFormat(const CFX_WideString& wsPattern, + const CFX_WideStringC& wsCategory, + CFX_WideString& wsPurgePattern); + IFX_Locale* GetNumericFormat(const CFX_WideString& wsPattern, + int32_t& iDotIndex, + FX_DWORD& dwStyle, + CFX_WideString& wsPurgePattern); + FX_BOOL FormatStrNum(const CFX_WideStringC& wsInputNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput); + FX_BOOL FormatLCNumeric(CFX_LCNumeric& lcNum, + const CFX_WideString& wsPattern, + CFX_WideString& wsOutput); + FX_DATETIMETYPE GetDateTimeFormat(const CFX_WideString& wsPattern, + IFX_Locale*& pLocale, + CFX_WideString& wsDatePattern, + CFX_WideString& wsTimePattern); + IFX_Locale* GetPatternLocale(const CFX_WideStringC& wsLocale); + IFX_LocaleMgr* m_pLocaleMgr; + FX_BOOL m_bUseLCID; +}; + +#endif // XFA_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ diff --git a/xfa/fgas/localization/fgas_localemgr.cpp b/xfa/fgas/localization/fgas_localemgr.cpp new file mode 100644 index 0000000000..4ed8ddb79a --- /dev/null +++ b/xfa/fgas/localization/fgas_localemgr.cpp @@ -0,0 +1,97 @@ +// 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/fgas/localization/fgas_localemgr.h" + +#include "core/include/fxcrt/fx_xml.h" + +IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, + FX_WORD wDefaultLCID) { + void* pPathHandle = FX_OpenFolder(pszLocalPath); + if (!pPathHandle) { + return NULL; + } + CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID); + CFX_WideString wsFileName; + FX_BOOL bFolder = FALSE; + while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) { + if (!bFolder) { + if (wsFileName.GetLength() < 4) { + continue; + } + CFX_WideString wsExt = wsFileName.Right(4); + wsExt.MakeLower(); + if (wsExt != L".xml") { + continue; + } + CFX_WideString wsFullPath(pszLocalPath); + wsFullPath += L"\\" + wsFileName; + IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath); + if (!pRead) { + continue; + } + CXML_Element* pXmlLocale = CXML_Element::Parse(pRead); + pRead->Release(); + CFX_ByteString bssp = pXmlLocale->GetNamespace(); + if (bssp == "http://www.foxitsoftware.com/localization") { + CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid"); + wchar_t* pEnd = NULL; + FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16); + if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) { + delete pXmlLocale; + } else { + pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale); + } + } else { + delete pXmlLocale; + } + } + } + FX_CloseFolder(pPathHandle); + return pLocaleMgr; +} +CFX_LocaleMgr::CFX_LocaleMgr(FX_WORD wDefLCID) : m_wDefLCID(wDefLCID) {} +CFX_LocaleMgr::~CFX_LocaleMgr() { + FX_POSITION ps = m_lcid2locale.GetStartPosition(); + while (ps) { + void* plcid; + IFX_Locale* pLocale = NULL; + m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale); + pLocale->Release(); + } + m_lcid2locale.RemoveAll(); + ps = m_lcid2xml.GetStartPosition(); + while (ps) { + void* plcid; + CXML_Element* pxml = NULL; + m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml); + delete pxml; + } + m_lcid2xml.RemoveAll(); +} +FX_WORD CFX_LocaleMgr::GetDefLocaleID() { + return m_wDefLCID; +} +IFX_Locale* CFX_LocaleMgr::GetDefLocale() { + return GetLocale(m_wDefLCID); +} +IFX_Locale* CFX_LocaleMgr::GetLocale(FX_WORD lcid) { + IFX_Locale* pLocale = + (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid); + if (!pLocale) { + CXML_Element* pxml = + (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid); + if (pxml) { + pLocale = IFX_Locale::Create(pxml); + m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale); + } + } + return pLocale; +} +IFX_Locale* CFX_LocaleMgr::GetLocaleByName( + const CFX_WideStringC& wsLocaleName) { + return NULL; +} diff --git a/xfa/fgas/localization/fgas_localemgr.h b/xfa/fgas/localization/fgas_localemgr.h new file mode 100644 index 0000000000..5ae0d738cb --- /dev/null +++ b/xfa/fgas/localization/fgas_localemgr.h @@ -0,0 +1,28 @@ +// 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_LOCALIZATION_FGAS_LOCALEMGR_H_ +#define XFA_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ + +#include "xfa/fgas/localization/fgas_locale.h" + +class CFX_LocaleMgr : public IFX_LocaleMgr { + public: + CFX_LocaleMgr(FX_WORD wDefLCID); + virtual void Release() { delete this; } + virtual FX_WORD GetDefLocaleID(); + virtual IFX_Locale* GetDefLocale(); + virtual IFX_Locale* GetLocale(FX_WORD lcid); + virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName); + CFX_MapPtrToPtr m_lcid2xml; + + protected: + ~CFX_LocaleMgr(); + CFX_MapPtrToPtr m_lcid2locale; + FX_WORD m_wDefLCID; +}; + +#endif // XFA_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ diff --git a/xfa/fgas/xml/fgas_sax.h b/xfa/fgas/xml/fgas_sax.h new file mode 100644 index 0000000000..222b109080 --- /dev/null +++ b/xfa/fgas/xml/fgas_sax.h @@ -0,0 +1,68 @@ +// 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_H_ +#define XFA_FGAS_XML_FGAS_SAX_H_ + +#include "core/include/fxcrt/fx_basic.h" + +#define FX_SAXPARSEMODE_NotConvert_amp 0x0001 +#define FX_SAXPARSEMODE_NotConvert_lt 0x0002 +#define FX_SAXPARSEMODE_NotConvert_gt 0x0004 +#define FX_SAXPARSEMODE_NotConvert_apos 0x0008 +#define FX_SAXPARSEMODE_NotConvert_quot 0x0010 +#define FX_SAXPARSEMODE_NotConvert_sharp 0x0020 +#define FX_SAXPARSEMODE_NotSkipSpace 0x0100 + +enum FX_SAXNODE { + FX_SAXNODE_Unknown = 0, + FX_SAXNODE_Instruction, + FX_SAXNODE_Declaration, + FX_SAXNODE_Comment, + FX_SAXNODE_Tag, + FX_SAXNODE_Text, + FX_SAXNODE_CharData, +}; + +class IFX_SAXReaderHandler { + public: + virtual ~IFX_SAXReaderHandler() {} + virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName, + FX_SAXNODE eType, + FX_DWORD 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, + FX_DWORD dwStartPos) = 0; + virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos) = 0; + virtual void OnTagEnd(void* pTag, + const CFX_ByteStringC& bsTagName, + FX_DWORD dwEndPos) = 0; + virtual void OnTargetData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos) = 0; +}; + +class IFX_SAXReader { + public: + virtual ~IFX_SAXReader() {} + virtual void Release() = 0; + virtual int32_t StartParse(IFX_FileRead* pFile, + FX_DWORD dwStart = 0, + FX_DWORD dwLen = -1, + FX_DWORD dwParseMode = 0) = 0; + virtual int32_t ContinueParse(IFX_Pause* pPause = NULL) = 0; + virtual void SkipCurrentNode() = 0; + virtual void SetHandler(IFX_SAXReaderHandler* pHandler) = 0; +}; +IFX_SAXReader* FX_SAXReader_Create(); + +#endif // XFA_FGAS_XML_FGAS_SAX_H_ diff --git a/xfa/fgas/xml/fgas_sax_imp.cpp b/xfa/fgas/xml/fgas_sax_imp.cpp new file mode 100644 index 0000000000..f45d7645ac --- /dev/null +++ b/xfa/fgas/xml/fgas_sax_imp.cpp @@ -0,0 +1,688 @@ +// 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/fgas/xml/fgas_sax_imp.h" + +#include <algorithm> + +namespace { + +const FX_DWORD kSaxFileBufSize = 32768; + +} // namespace + +IFX_SAXReader* FX_SAXReader_Create() { + return new CFX_SAXReader; +} +CFX_SAXFile::CFX_SAXFile() + : m_pFile(NULL), + m_dwStart(0), + m_dwEnd(0), + m_dwCur(0), + m_pBuf(NULL), + m_dwBufSize(0), + m_dwBufIndex(0) {} +FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile, + FX_DWORD dwStart, + FX_DWORD dwLen) { + FXSYS_assert(m_pFile == NULL && pFile != NULL); + FX_DWORD dwSize = pFile->GetSize(); + if (dwStart >= dwSize) { + return FALSE; + } + if (dwLen == -1 || dwStart + dwLen > dwSize) { + dwLen = dwSize - dwStart; + } + if (dwLen == 0) { + return FALSE; + } + m_dwBufSize = std::min(dwLen, kSaxFileBufSize); + m_pBuf = FX_Alloc(uint8_t, m_dwBufSize); + if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) { + return FALSE; + } + m_dwStart = dwStart; + m_dwEnd = dwStart + dwLen; + m_dwCur = dwStart; + m_pFile = pFile; + m_dwBufIndex = 0; + return TRUE; +} +FX_BOOL CFX_SAXFile::ReadNextBlock() { + FXSYS_assert(m_pFile != NULL); + FX_DWORD dwSize = m_dwEnd - m_dwCur; + if (dwSize == 0) { + return FALSE; + } + m_dwBufSize = std::min(dwSize, kSaxFileBufSize); + if (!m_pFile->ReadBlock(m_pBuf, m_dwCur, m_dwBufSize)) { + return FALSE; + } + m_dwBufIndex = 0; + return TRUE; +} +void CFX_SAXFile::Reset() { + if (m_pBuf) { + FX_Free(m_pBuf); + m_pBuf = NULL; + } + m_pFile = NULL; +} +CFX_SAXReader::CFX_SAXReader() + : m_File(), + m_pHandler(nullptr), + m_iState(-1), + m_pRoot(nullptr), + m_pCurItem(nullptr), + m_dwItemID(0), + m_iDataSize(256), + m_iNameSize(256), + m_dwParseMode(0), + m_pCommentContext(nullptr) { + m_pszData = FX_Alloc(uint8_t, m_iDataSize); + m_pszName = FX_Alloc(uint8_t, m_iNameSize); +} +CFX_SAXReader::~CFX_SAXReader() { + Reset(); + if (m_pszData) { + FX_Free(m_pszData); + m_pszData = NULL; + } + if (m_pszName) { + FX_Free(m_pszName); + m_pszName = NULL; + } +} +void CFX_SAXReader::Reset() { + m_File.Reset(); + CFX_SAXItem* pItem = m_pRoot; + while (pItem) { + CFX_SAXItem* pNext = pItem->m_pNext; + delete pItem; + pItem = pNext; + } + m_pRoot = NULL; + m_pCurItem = NULL; + m_dwItemID = 0; + m_SkipStack.RemoveAll(); + m_SkipChar = 0; + m_iDataLength = 0; + m_iEntityStart = -1; + m_iNameLength = 0; + m_iDataPos = 0; + if (m_pCommentContext) { + delete m_pCommentContext; + m_pCommentContext = NULL; + } +} +inline void CFX_SAXReader::Push() { + CFX_SAXItem* pNew = new CFX_SAXItem; + pNew->m_dwID = ++m_dwItemID; + pNew->m_bSkip = m_pCurItem->m_bSkip; + pNew->m_pPrev = m_pCurItem; + m_pCurItem->m_pNext = pNew; + m_pCurItem = pNew; +} +inline void CFX_SAXReader::Pop() { + if (!m_pCurItem) { + return; + } + CFX_SAXItem* pPrev = m_pCurItem->m_pPrev; + pPrev->m_pNext = NULL; + delete m_pCurItem; + m_pCurItem = pPrev; +} +inline void CFX_SAXReader::AppendData(uint8_t ch) { + ReallocDataBuffer(); + m_pszData[m_iDataPos++] = ch; +} +inline void CFX_SAXReader::AppendName(uint8_t ch) { + ReallocNameBuffer(); + m_pszName[m_iDataPos++] = ch; +} +void CFX_SAXReader::ReallocDataBuffer() { + if (m_iDataPos < m_iDataSize) { + return; + } + if (m_iDataSize <= 1024 * 1024) { + m_iDataSize *= 2; + } else { + m_iDataSize += 1024 * 1024; + } + m_pszData = (uint8_t*)FX_Realloc(uint8_t, m_pszData, m_iDataSize); +} +void CFX_SAXReader::ReallocNameBuffer() { + if (m_iDataPos < m_iNameSize) { + return; + } + if (m_iNameSize <= 1024 * 1024) { + m_iNameSize *= 2; + } else { + m_iNameSize += 1024 * 1024; + } + m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize); +} +inline FX_BOOL CFX_SAXReader::SkipSpace(uint8_t ch) { + return (m_dwParseMode & FX_SAXPARSEMODE_NotSkipSpace) == 0 && ch < 0x21; +} +int32_t CFX_SAXReader::StartParse(IFX_FileRead* pFile, + FX_DWORD dwStart, + FX_DWORD dwLen, + FX_DWORD dwParseMode) { + m_iState = -1; + Reset(); + if (!m_File.StartFile(pFile, dwStart, dwLen)) { + return -1; + } + m_iState = 0; + m_eMode = FX_SAXMODE_Text; + m_ePrevMode = FX_SAXMODE_Text; + m_bCharData = FALSE; + m_dwDataOffset = 0; + m_pRoot = m_pCurItem = new CFX_SAXItem; + m_pCurItem->m_dwID = ++m_dwItemID; + m_dwParseMode = dwParseMode; + return 0; +} +typedef void (CFX_SAXReader::*FX_SAXReader_LPFParse)(); +static const FX_SAXReader_LPFParse g_FX_SAXReader_LPFParse[FX_SAXMODE_MAX] = { + &CFX_SAXReader::ParseText, + &CFX_SAXReader::ParseNodeStart, + &CFX_SAXReader::ParseDeclOrComment, + &CFX_SAXReader::ParseDeclNode, + &CFX_SAXReader::ParseComment, + &CFX_SAXReader::ParseCommentContent, + &CFX_SAXReader::ParseTagName, + &CFX_SAXReader::ParseTagAttributeName, + &CFX_SAXReader::ParseTagAttributeEqual, + &CFX_SAXReader::ParseTagAttributeValue, + &CFX_SAXReader::ParseMaybeClose, + &CFX_SAXReader::ParseTagClose, + &CFX_SAXReader::ParseTagEnd, + &CFX_SAXReader::ParseTargetData, +}; +int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) { + if (m_iState < 0 || m_iState > 99) { + return m_iState; + } + while (m_File.m_dwCur < m_File.m_dwEnd) { + FX_DWORD& index = m_File.m_dwBufIndex; + FX_DWORD size = m_File.m_dwBufSize; + const uint8_t* pBuf = m_File.m_pBuf; + while (index < size) { + m_CurByte = pBuf[index]; + (this->*g_FX_SAXReader_LPFParse[m_eMode])(); + index++; + } + m_File.m_dwCur += index; + m_iState = (m_File.m_dwCur - m_File.m_dwStart) * 100 / + (m_File.m_dwEnd - m_File.m_dwStart); + if (m_File.m_dwCur >= m_File.m_dwEnd) { + break; + } + if (!m_File.ReadNextBlock()) { + m_iState = -2; + break; + } + m_dwDataOffset = 0; + if (pPause && pPause->NeedToPauseNow()) { + break; + } + } + return m_iState; +} +void CFX_SAXReader::ParseChar(uint8_t ch) { + ReallocDataBuffer(); + m_pszData[m_iDataPos] = ch; + if (m_iEntityStart > -1 && ch == ';') { + int32_t iSaveEntityStart = m_iEntityStart; + CFX_ByteString csEntity(m_pszData + m_iEntityStart + 1, + m_iDataPos - m_iEntityStart - 1); + int32_t iLen = csEntity.GetLength(); + if (iLen > 0) { + if (csEntity[0] == '#') { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_sharp) == 0) { + ch = 0; + uint8_t w; + if (iLen > 1 && csEntity[1] == 'x') { + for (int32_t i = 2; i < iLen; i++) { + w = csEntity[i]; + if (w >= '0' && w <= '9') { + ch = (ch << 4) + w - '0'; + } else if (w >= 'A' && w <= 'F') { + ch = (ch << 4) + w - 55; + } else if (w >= 'a' && w <= 'f') { + ch = (ch << 4) + w - 87; + } else { + break; + } + } + } else { + for (int32_t i = 1; i < iLen; i++) { + w = csEntity[i]; + if (w < '0' || w > '9') { + break; + } + ch = ch * 10 + w - '0'; + } + } + if (ch != 0) { + m_pszData[m_iEntityStart++] = ch; + } + } + } else { + if (csEntity.Compare("amp") == 0) { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_amp) == 0) { + m_pszData[m_iEntityStart++] = '&'; + } + } else if (csEntity.Compare("lt") == 0) { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_lt) == 0) { + m_pszData[m_iEntityStart++] = '<'; + } + } else if (csEntity.Compare("gt") == 0) { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_gt) == 0) { + m_pszData[m_iEntityStart++] = '>'; + } + } else if (csEntity.Compare("apos") == 0) { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_apos) == 0) { + m_pszData[m_iEntityStart++] = '\''; + } + } else if (csEntity.Compare("quot") == 0) { + if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_quot) == 0) { + m_pszData[m_iEntityStart++] = '\"'; + } + } + } + } + if (iSaveEntityStart != m_iEntityStart) { + m_iDataPos = m_iEntityStart; + m_iEntityStart = -1; + } else { + m_iDataPos++; + m_iEntityStart = -1; + } + } else { + if (m_iEntityStart < 0 && ch == '&') { + m_iEntityStart = m_iDataPos; + } + m_iDataPos++; + } +} +void CFX_SAXReader::ParseText() { + if (m_CurByte == '<') { + if (m_iDataPos > 0) { + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyData(); + } + } + Push(); + m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; + m_eMode = FX_SAXMODE_NodeStart; + return; + } + if (m_iDataPos < 1 && SkipSpace(m_CurByte)) { + return; + } + ParseChar(m_CurByte); +} +void CFX_SAXReader::ParseNodeStart() { + if (m_CurByte == '?') { + m_pCurItem->m_eNode = FX_SAXNODE_Instruction; + m_eMode = FX_SAXMODE_TagName; + return; + } + if (m_CurByte == '!') { + m_eMode = FX_SAXMODE_DeclOrComment; + return; + } + if (m_CurByte == '/') { + m_eMode = FX_SAXMODE_TagEnd; + return; + } + if (m_CurByte == '>') { + Pop(); + m_eMode = FX_SAXMODE_Text; + return; + } + if (m_CurByte > 0x20) { + m_dwDataOffset = m_File.m_dwBufIndex; + m_pCurItem->m_eNode = FX_SAXNODE_Tag; + m_eMode = FX_SAXMODE_TagName; + AppendData(m_CurByte); + } +} +void CFX_SAXReader::ParseDeclOrComment() { + if (m_CurByte == '-') { + m_eMode = FX_SAXMODE_Comment; + m_pCurItem->m_eNode = FX_SAXNODE_Comment; + if (m_pCommentContext == NULL) { + m_pCommentContext = new CFX_SAXCommentContext; + } + m_pCommentContext->m_iHeaderCount = 1; + m_pCommentContext->m_iTailCount = 0; + } else { + m_eMode = FX_SAXMODE_DeclNode; + m_dwDataOffset = m_File.m_dwBufIndex; + m_SkipChar = '>'; + m_SkipStack.Add('>'); + SkipNode(); + } +} +void CFX_SAXReader::ParseComment() { + m_pCommentContext->m_iHeaderCount = 2; + m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; + m_eMode = FX_SAXMODE_CommentContent; +} +void CFX_SAXReader::ParseCommentContent() { + if (m_CurByte == '-') { + m_pCommentContext->m_iTailCount++; + } else if (m_CurByte == '>' && m_pCommentContext->m_iTailCount == 2) { + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyTargetData(); + } + Pop(); + m_eMode = FX_SAXMODE_Text; + } else { + while (m_pCommentContext->m_iTailCount > 0) { + AppendData('-'); + m_pCommentContext->m_iTailCount--; + } + AppendData(m_CurByte); + } +} +void CFX_SAXReader::ParseDeclNode() { + SkipNode(); +} +void CFX_SAXReader::ParseTagName() { + if (m_CurByte < 0x21 || m_CurByte == '/' || m_CurByte == '>' || + m_CurByte == '?') { + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyEnter(); + } + if (m_CurByte < 0x21) { + m_eMode = FX_SAXMODE_TagAttributeName; + } else if (m_CurByte == '/' || m_CurByte == '?') { + m_ePrevMode = m_eMode; + m_eMode = FX_SAXMODE_TagMaybeClose; + } else { + if (m_pHandler) { + NotifyBreak(); + } + m_eMode = FX_SAXMODE_Text; + } + } else { + AppendData(m_CurByte); + } +} +void CFX_SAXReader::ParseTagAttributeName() { + if (m_CurByte < 0x21 || m_CurByte == '=') { + if (m_iDataPos < 1 && m_CurByte < 0x21) { + return; + } + m_iNameLength = m_iDataPos; + m_iDataPos = 0; + m_SkipChar = 0; + m_eMode = m_CurByte == '=' ? FX_SAXMODE_TagAttributeValue + : FX_SAXMODE_TagAttributeEqual; + return; + } + if (m_CurByte == '/' || m_CurByte == '>' || m_CurByte == '?') { + if (m_CurByte == '/' || m_CurByte == '?') { + m_ePrevMode = m_eMode; + m_eMode = FX_SAXMODE_TagMaybeClose; + } else { + if (m_pHandler) { + NotifyBreak(); + } + m_eMode = FX_SAXMODE_Text; + } + return; + } + if (m_iDataPos < 1) { + m_dwDataOffset = m_File.m_dwBufIndex; + } + AppendName(m_CurByte); +} +void CFX_SAXReader::ParseTagAttributeEqual() { + if (m_CurByte == '=') { + m_SkipChar = 0; + m_eMode = FX_SAXMODE_TagAttributeValue; + return; + } else if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) { + m_iDataPos = m_iNameLength; + AppendName(0x20); + m_eMode = FX_SAXMODE_TargetData; + ParseTargetData(); + } +} +void CFX_SAXReader::ParseTagAttributeValue() { + if (m_SkipChar) { + if (m_SkipChar == m_CurByte) { + { + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyAttribute(); + } + } + m_SkipChar = 0; + m_eMode = FX_SAXMODE_TagAttributeName; + return; + } + ParseChar(m_CurByte); + return; + } + if (m_CurByte < 0x21) { + return; + } + if (m_iDataPos < 1) { + if (m_CurByte == '\'' || m_CurByte == '\"') { + m_SkipChar = m_CurByte; + } + } +} +void CFX_SAXReader::ParseMaybeClose() { + if (m_CurByte == '>') { + if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) { + m_iNameLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyTargetData(); + } + } + ParseTagClose(); + m_eMode = FX_SAXMODE_Text; + } else if (m_ePrevMode == FX_SAXMODE_TagName) { + AppendData('/'); + m_eMode = FX_SAXMODE_TagName; + m_ePrevMode = FX_SAXMODE_Text; + ParseTagName(); + } else if (m_ePrevMode == FX_SAXMODE_TagAttributeName) { + AppendName('/'); + m_eMode = FX_SAXMODE_TagAttributeName; + m_ePrevMode = FX_SAXMODE_Text; + ParseTagAttributeName(); + } else if (m_ePrevMode == FX_SAXMODE_TargetData) { + AppendName('?'); + m_eMode = FX_SAXMODE_TargetData; + m_ePrevMode = FX_SAXMODE_Text; + ParseTargetData(); + } +} +void CFX_SAXReader::ParseTagClose() { + m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; + if (m_pHandler) { + NotifyClose(); + } + Pop(); +} +void CFX_SAXReader::ParseTagEnd() { + if (m_CurByte < 0x21) { + return; + } + if (m_CurByte == '>') { + Pop(); + m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_pHandler) { + NotifyEnd(); + } + Pop(); + m_eMode = FX_SAXMODE_Text; + } else { + ParseChar(m_CurByte); + } +} +void CFX_SAXReader::ParseTargetData() { + if (m_CurByte == '?') { + m_ePrevMode = m_eMode; + m_eMode = FX_SAXMODE_TagMaybeClose; + } else { + AppendName(m_CurByte); + } +} +void CFX_SAXReader::SkipNode() { + int32_t iLen = m_SkipStack.GetSize(); + if (m_SkipChar == '\'' || m_SkipChar == '\"') { + if (m_CurByte != m_SkipChar) { + return; + } + iLen--; + FXSYS_assert(iLen > -1); + m_SkipStack.RemoveAt(iLen, 1); + m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; + return; + } + switch (m_CurByte) { + case '<': + m_SkipChar = '>'; + m_SkipStack.Add('>'); + break; + case '[': + m_SkipChar = ']'; + m_SkipStack.Add(']'); + break; + case '(': + m_SkipChar = ')'; + m_SkipStack.Add(')'); + break; + case '\'': + m_SkipChar = '\''; + m_SkipStack.Add('\''); + break; + case '\"': + m_SkipChar = '\"'; + m_SkipStack.Add('\"'); + break; + default: + if (m_CurByte == m_SkipChar) { + iLen--; + m_SkipStack.RemoveAt(iLen, 1); + m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; + if (iLen == 0 && m_CurByte == '>') { + m_iDataLength = m_iDataPos; + m_iDataPos = 0; + if (m_iDataLength >= 9 && + FXSYS_memcmp(m_pszData, "[CDATA[", 7 * sizeof(uint8_t)) == 0 && + FXSYS_memcmp(m_pszData + m_iDataLength - 2, "]]", + 2 * sizeof(uint8_t)) == 0) { + Pop(); + m_iDataLength -= 9; + m_dwDataOffset += 7; + FXSYS_memmove(m_pszData, m_pszData + 7, + m_iDataLength * sizeof(uint8_t)); + m_bCharData = TRUE; + if (m_pHandler) { + NotifyData(); + } + m_bCharData = FALSE; + } else { + Pop(); + } + m_eMode = FX_SAXMODE_Text; + } + } + break; + } + if (iLen > 0) { + 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 = + m_pHandler->OnTagEnter(CFX_ByteStringC(m_pszData, m_iDataLength), + 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, + CFX_ByteStringC(m_pszName, m_iNameLength), + CFX_ByteStringC(m_pszData, m_iDataLength)); + } +} +void CFX_SAXReader::NotifyBreak() { + FXSYS_assert(m_pHandler != NULL); + 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); + } +} +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), + m_dwNodePos); + } else if (m_pCurItem->m_eNode == FX_SAXNODE_Comment) { + m_pHandler->OnTargetData(m_pCurItem->m_pNode, m_pCurItem->m_eNode, + CFX_ByteStringC(m_pszData, m_iDataLength), + m_dwNodePos); + } +} +void CFX_SAXReader::SkipCurrentNode() { + if (!m_pCurItem) { + return; + } + m_pCurItem->m_bSkip = TRUE; +} +void CFX_SAXReader::SetHandler(IFX_SAXReaderHandler* pHandler) { + m_pHandler = pHandler; +} diff --git a/xfa/fgas/xml/fgas_sax_imp.h b/xfa/fgas/xml/fgas_sax_imp.h new file mode 100644 index 0000000000..1d2161763f --- /dev/null +++ b/xfa/fgas/xml/fgas_sax_imp.h @@ -0,0 +1,141 @@ +// 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, FX_DWORD dwStart, FX_DWORD dwLen); + FX_BOOL ReadNextBlock(); + void Reset(); + IFX_FileRead* m_pFile; + FX_DWORD m_dwStart; + FX_DWORD m_dwEnd; + FX_DWORD m_dwCur; + uint8_t* m_pBuf; + FX_DWORD m_dwBufSize; + FX_DWORD 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; + FX_DWORD 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, + FX_DWORD dwStart = 0, + FX_DWORD dwLen = -1, + FX_DWORD 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; + FX_DWORD m_dwItemID; + FX_SAXMODE m_eMode; + FX_SAXMODE m_ePrevMode; + FX_BOOL m_bCharData; + uint8_t m_CurByte; + FX_DWORD m_dwDataOffset; + CFX_ByteArray m_SkipStack; + uint8_t m_SkipChar; + FX_DWORD 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; + FX_DWORD 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/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/fwl/basewidget/fwl_barcodeimp.cpp new file mode 100644 index 0000000000..97ac8e4acb --- /dev/null +++ b/xfa/fwl/basewidget/fwl_barcodeimp.cpp @@ -0,0 +1,221 @@ +// 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/basewidget/fwl_barcodeimp.h" + +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +// static +IFWL_Barcode* IFWL_Barcode::Create(const CFWL_WidgetImpProperties& properties) { + IFWL_Barcode* pBarcode = new IFWL_Barcode; + CFWL_BarcodeImp* pBarcodeImpl = new CFWL_BarcodeImp(properties, nullptr); + pBarcode->SetImpl(pBarcodeImpl); + pBarcodeImpl->SetInterface(pBarcode); + return pBarcode; +} +IFWL_Barcode::IFWL_Barcode() {} +void IFWL_Barcode::SetType(BC_TYPE type) { + static_cast<CFWL_BarcodeImp*>(GetImpl())->SetType(type); +} +FX_BOOL IFWL_Barcode::IsProtectedType() { + return static_cast<CFWL_BarcodeImp*>(GetImpl())->IsProtectedType(); +} + +CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_EditImp(properties, pOuter), + m_pBarcodeEngine(NULL), + m_dwStatus(0), + m_type(BC_UNKNOWN) {} +CFWL_BarcodeImp::~CFWL_BarcodeImp() { + ReleaseBarcodeEngine(); +} +FWL_ERR CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_Barcode; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_BarcodeImp::GetClassID() const { + return FWL_CLASSHASH_Barcode; +} +FWL_ERR 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; +} +FWL_ERR CFWL_BarcodeImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + ReleaseBarcodeEngine(); + return CFWL_EditImp::Finalize(); +} +FWL_ERR CFWL_BarcodeImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + FWL_ERR ret = CFWL_EditImp::Update(); + GenerateBarcodeImageCache(); + return ret; +} +FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + GenerateBarcodeImageCache(); + if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) { + return FWL_ERR_Succeeded; + } + CFX_Matrix mt; + mt.e = m_rtClient.left; + mt.f = m_rtClient.top; + if (pMatrix) { + mt.Concat(*pMatrix); + } + int32_t errorCode = 0; + if (!m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix, + errorCode)) { + return FWL_ERR_Indefinite; + } + return FWL_ERR_Succeeded; + } + return CFWL_EditImp::DrawWidget(pGraphics, pMatrix); +} +void CFWL_BarcodeImp::GenerateBarcodeImageCache() { + if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) + return; + m_dwStatus = 0; + CreateBarcodeEngine(); + IFWL_BarcodeDP* pData = + static_cast<IFWL_BarcodeDP*>(m_pProperties->m_pDataProvider); + if (!pData) + return; + if (!m_pBarcodeEngine) + return; + CFX_WideString wsText; + if (GetText(wsText) != FWL_ERR_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)); + 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)); + if (pFontSize) { + m_pBarcodeEngine->SetFontSize(*pFontSize); + } + FX_ARGB* pFontColor = static_cast<FX_ARGB*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_TextColor)); + if (pFontColor) { + m_pBarcodeEngine->SetFontColor(*pFontColor); + } + m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height)); + m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width)); + FX_DWORD dwAttributeMask = pData->GetBarcodeAttributeMask(); + if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) { + m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) { + m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) { + m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) { + m_pBarcodeEngine->SetDataLength(pData->GetDataLength()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) { + m_pBarcodeEngine->SetCalChecksum(pData->GetCalChecksum()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) { + m_pBarcodeEngine->SetPrintChecksum(pData->GetPrintChecksum()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) { + m_pBarcodeEngine->SetTextLocation(pData->GetTextLocation()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) { + m_pBarcodeEngine->SetWideNarrowRatio(pData->GetWideNarrowRatio()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) { + m_pBarcodeEngine->SetStartChar(pData->GetStartChar()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) { + m_pBarcodeEngine->SetEndChar(pData->GetEndChar()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) { + m_pBarcodeEngine->SetVersion(pData->GetVersion()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) { + m_pBarcodeEngine->SetErrorCorrectionLevel(pData->GetErrorCorrectionLevel()); + } + if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) { + m_pBarcodeEngine->SetTruncated(pData->GetTruncated()); + } + int32_t errorCode = 0; + m_dwStatus = m_pBarcodeEngine->Encode(wsText, 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); + } +} +void CFWL_BarcodeImp::ReleaseBarcodeEngine() { + if (m_pBarcodeEngine) { + m_pBarcodeEngine->Release(); + m_pBarcodeEngine = NULL; + } +} +void CFWL_BarcodeImp::SetType(BC_TYPE type) { + if (m_type == type) { + return; + } + ReleaseBarcodeEngine(); + m_type = type; + m_dwStatus = XFA_BCS_NeedUpdate; +} +FWL_ERR CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) { + ReleaseBarcodeEngine(); + m_dwStatus = XFA_BCS_NeedUpdate; + return CFWL_EditImp::SetText(wsText); +} +FX_BOOL CFWL_BarcodeImp::IsProtectedType() { + if (!m_pBarcodeEngine) { + return TRUE; + } + BC_TYPE tEngineType = m_pBarcodeEngine->GetType(); + if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 || + tEngineType == BC_DATAMATRIX) { + return TRUE; + } + return FALSE; +} +CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner) + : CFWL_EditImpDelegate(pOwner) {} +FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { + FX_DWORD dwFlag = pEvent->GetClassID(); + if (dwFlag == FWL_EVTHASH_EDT_TextChanged) { + CFWL_BarcodeImp* pOwner = static_cast<CFWL_BarcodeImp*>(m_pOwner); + pOwner->ReleaseBarcodeEngine(); + pOwner->m_dwStatus = XFA_BCS_NeedUpdate; + } + return CFWL_EditImpDelegate::OnProcessEvent(pEvent); +} diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.h b/xfa/fwl/basewidget/fwl_barcodeimp.h new file mode 100644 index 0000000000..bf7ad91050 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_barcodeimp.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_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ + +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/include/fwl/basewidget/fwl_barcode.h" +#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" +#include "xfa/include/fwl/basewidget/fxmath_barcode.h" + +class CFWL_WidgetImpProperties; +class CFWL_BarcodeImpDelegate; +class IFWL_Widget; + +#define XFA_BCS_NeedUpdate 0x0001 +#define XFA_BCS_EncodeSuccess 0x0002 + +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 FX_DWORD 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); + FX_BOOL IsProtectedType(); + + protected: + void GenerateBarcodeImageCache(); + void CreateBarcodeEngine(); + void ReleaseBarcodeEngine(); + IFX_Barcode* m_pBarcodeEngine; + FX_DWORD 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; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp new file mode 100644 index 0000000000..ea7402e029 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_caretimp.cpp @@ -0,0 +1,157 @@ +// 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/basewidget/fwl_caretimp.h" + +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_caret.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +// static +IFWL_Caret* IFWL_Caret::Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_Caret* pCaret = new IFWL_Caret; + CFWL_CaretImp* pCaretImpl = new CFWL_CaretImp(properties, pOuter); + pCaret->SetImpl(pCaretImpl); + pCaretImpl->SetInterface(pCaret); + return pCaret; +} +IFWL_Caret::IFWL_Caret() {} +FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) { + return static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag); +} +FWL_ERR IFWL_Caret::GetFrequency(FX_DWORD& elapse) { + return static_cast<CFWL_CaretImp*>(GetImpl())->GetFrequency(elapse); +} +FWL_ERR IFWL_Caret::SetFrequency(FX_DWORD elapse) { + return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); +} +FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) { + return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); +} + +CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_hTimer(nullptr), + m_dwElapse(400), + m_bSetColor(FALSE) { + m_pTimer = new CFWL_CaretTimer(this); + SetStates(FWL_STATE_CAT_HightLight); +} +CFWL_CaretImp::~CFWL_CaretImp() { + if (m_pTimer) { + delete m_pTimer; + m_pTimer = NULL; + } +} +FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_Caret; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_CaretImp::GetClassID() const { + return FWL_CLASSHASH_Caret; +} +FWL_ERR CFWL_CaretImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_CaretImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CaretImp::Finalize() { + if (m_hTimer) { + FWL_StopTimer(m_hTimer); + m_hTimer = NULL; + } + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { + if (m_hTimer) { + FWL_StopTimer(m_hTimer); + m_hTimer = NULL; + } + if (bFlag) { + m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); + } + return SetStates(FWL_WGTSTATE_Invisible, !bFlag); +} +FWL_ERR CFWL_CaretImp::GetFrequency(FX_DWORD& elapse) { + elapse = m_dwElapse; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CaretImp::SetFrequency(FX_DWORD elapse) { + m_dwElapse = elapse; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) { + m_bSetColor = TRUE; + m_crFill = crFill; + return FWL_ERR_Succeeded; +} +FX_BOOL 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); + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_pGraphics = pGraphics; + param.m_rtPart = rect; + 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) { + param.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶m); + return FWL_ERR_Succeeded; +} + +CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret) + : m_pCaret(pCaret) {} + +int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) { + if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) { + m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE); + } else { + m_pCaret->SetStates(FWL_STATE_CAT_HightLight); + } + CFX_RectF rt; + m_pCaret->GetWidgetRect(rt); + rt.Set(0, 0, rt.width + 1, rt.height); + 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); +} diff --git a/xfa/fwl/basewidget/fwl_caretimp.h b/xfa/fwl/basewidget/fwl_caretimp.h new file mode 100644 index 0000000000..d123e15b58 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_caretimp.h @@ -0,0 +1,67 @@ +// 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_FWL_CARETIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_CaretImpDelegate; + +class CFWL_CaretImp : public CFWL_WidgetImp { + public: + CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + virtual ~CFWL_CaretImp(); + + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; + virtual FX_DWORD GetClassID() const; + + 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(FX_DWORD& elapse); + virtual FWL_ERR SetFrequency(FX_DWORD elapse); + virtual FWL_ERR SetColor(CFX_Color crFill); + + protected: + FX_BOOL DrawCaretBK(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + class CFWL_CaretTimer : public IFWL_Timer { + public: + explicit CFWL_CaretTimer(CFWL_CaretImp* pCaret); + ~CFWL_CaretTimer() override {} + int32_t Run(FWL_HTIMER hTimer) override; + CFWL_CaretImp* const m_pCaret; + }; + CFWL_CaretTimer* m_pTimer; + FWL_HTIMER m_hTimer; + FX_DWORD 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; + + protected: + CFWL_CaretImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/basewidget/fwl_checkboximp.cpp new file mode 100644 index 0000000000..5912d0e17c --- /dev/null +++ b/xfa/fwl/basewidget/fwl_checkboximp.cpp @@ -0,0 +1,555 @@ +// 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/basewidget/fwl_checkboximp.h" + +#include <algorithm> + +#include "xfa/fde/tto/fde_textout.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/include/fwl/basewidget/fwl_checkbox.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +#define FWL_CKB_CaptionMargin 5 + +// static +IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_CheckBox* pCheckBox = new IFWL_CheckBox; + CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter); + pCheckBox->SetImpl(pCheckBoxImpl); + pCheckBoxImpl->SetInterface(pCheckBox); + return pCheckBox; +} +IFWL_CheckBox::IFWL_CheckBox() {} +int32_t IFWL_CheckBox::GetCheckState() { + return static_cast<CFWL_CheckBoxImp*>(GetImpl())->GetCheckState(); +} +FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck) { + return static_cast<CFWL_CheckBoxImp*>(GetImpl())->SetCheckState(iCheck); +} + +CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), + m_iTTOAlign(FDE_TTOALIGNMENT_Center), + m_bBtnDown(FALSE) { + m_rtClient.Reset(); + m_rtBox.Reset(); + m_rtCaption.Reset(); + m_rtFocus.Reset(); +} +CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {} +FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_CheckBox; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_CheckBoxImp::GetClassID() const { + return FWL_CLASSHASH_CheckBox; +} +FWL_ERR CFWL_CheckBoxImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_CheckBoxImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CheckBoxImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR 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; + if (!m_pProperties->m_pDataProvider) + return FWL_ERR_Indefinite; + CFX_WideString wsCaption; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); + if (wsCaption.GetLength() > 0) { + CFX_SizeF sz = CalcTextSize( + wsCaption, m_pProperties->m_pThemeProvider, + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); + rect.Set(0, 0, sz.x, sz.y); + } + rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin); + IFWL_CheckBoxDP* pData = + static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); + FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); + rect.width += fCheckBox; + if (rect.height < fCheckBox) { + rect.height = fCheckBox; + } + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CheckBoxImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + UpdateTextOutStyles(); + Layout(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider, + pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix); + } + int32_t dwStates = GetPartStates(); + { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_CKB_Background; + param.m_dwStates = dwStates; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtClient; + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + param.m_pData = &m_rtFocus; + } + pTheme->DrawBackground(¶m); + param.m_iPart = FWL_PART_CKB_CheckBox; + param.m_rtPart = m_rtBox; + pTheme->DrawBackground(¶m); + } + if (!m_pProperties->m_pDataProvider) + return FWL_ERR_Indefinite; + { + CFX_WideString wsCaption; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); + int32_t iLen = wsCaption.GetLength(); + if (iLen <= 0) + return FWL_ERR_Indefinite; + CFWL_ThemeText textParam; + textParam.m_pWidget = m_pInterface; + textParam.m_iPart = FWL_PART_CKB_Caption; + textParam.m_dwStates = dwStates; + textParam.m_pGraphics = pGraphics; + if (pMatrix) { + textParam.m_matrix.Concat(*pMatrix); + } + textParam.m_rtPart = m_rtCaption; + textParam.m_wsText = wsCaption; + textParam.m_dwTTOStyles = m_dwTTOStyles; + textParam.m_iTTOAlign = m_iTTOAlign; + pTheme->DrawText(&textParam); + } + return FWL_ERR_Succeeded; +} +int32_t CFWL_CheckBoxImp::GetCheckState() { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) && + ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Neutral)) { + return 2; + } + if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Checked) { + return 1; + } + return 0; +} +FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) { + m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; + switch (iCheck) { + case 0: { + break; + } + case 1: { + m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; + break; + } + case 2: { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { + m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; + } + break; + } + default: {} + } + Repaint(&m_rtClient); + return FWL_ERR_Succeeded; +} +void CFWL_CheckBoxImp::Layout() { + int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); + int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); + m_pProperties->m_rtWidget.width = (FX_FLOAT)width; + m_pProperties->m_rtWidget.height = (FX_FLOAT)height; + GetClientRect(m_rtClient); + FX_FLOAT fBoxTop = m_rtClient.top; + FX_FLOAT fBoxLeft = m_rtClient.left; + FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0; + FX_FLOAT fClientRight = m_rtClient.right(); + FX_FLOAT fClientBottom = m_rtClient.bottom(); + if (!m_pProperties->m_pDataProvider) + return; + IFWL_CheckBoxDP* pData = + static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); + FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { + case FWL_STYLEEXT_CKB_Top: { + fBoxTop = m_rtClient.top; + break; + } + case FWL_STYLEEXT_CKB_Bottom: { + fBoxTop = fClientBottom - fCheckBox; + break; + } + case FWL_STYLEEXT_CKB_VCenter: + default: { + fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2; + fBoxTop = FXSYS_floor(fBoxTop); + } + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_LeftText) { + fBoxLeft = fClientRight - fCheckBox; + fTextLeft = m_rtClient.left; + fTextRight = fBoxLeft; + } else { + fTextLeft = fBoxLeft + fCheckBox; + fTextRight = fClientRight; + } + 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); + CFX_RectF rtFocus; + rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, + m_rtCaption.height); + CFX_WideString wsCaption; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); + if (wsCaption.IsEmpty()) { + m_rtFocus.Set(0, 0, 0, 0); + } else { + CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, + m_iTTOAlign, rtFocus); + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) { + FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); + FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height); + FX_FLOAT fLeft = m_rtCaption.left; + FX_FLOAT fTop = m_rtCaption.top; + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) == + FWL_STYLEEXT_CKB_Center) { + fLeft = m_rtCaption.left + (m_rtCaption.width - fWidth) / 2; + } else if ((m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_CKB_HLayoutMask) == FWL_STYLEEXT_CKB_Right) { + fLeft = m_rtCaption.right() - fWidth; + } + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) == + FWL_STYLEEXT_CKB_VCenter) { + fTop = m_rtCaption.top + (m_rtCaption.height - fHeight) / 2; + } else if ((m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) { + fTop = m_rtCaption.bottom() - fHeight; + } + m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); + } else { + m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height); + } + m_rtFocus.Inflate(1, 1); + } +} +FX_DWORD CFWL_CheckBoxImp::GetPartStates() { + int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked; + if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Neutral) { + dwStates = FWL_PARTSTATE_CKB_Neutral; + } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Checked) { + dwStates = FWL_PARTSTATE_CKB_Checked; + } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + dwStates |= FWL_PARTSTATE_CKB_Disabled; + } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) { + dwStates |= FWL_PARTSTATE_CKB_Hovered; + } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) { + dwStates |= FWL_PARTSTATE_CKB_Pressed; + } else { + dwStates |= FWL_PARTSTATE_CKB_Normal; + } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + dwStates |= FWL_PARTSTATE_CKB_Focused; + } + return dwStates; +} +void CFWL_CheckBoxImp::UpdateTextOutStyles() { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; + switch (m_pProperties->m_dwStyleExes & + (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) { + case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; + break; + } + case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; + break; + } + case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopRight; + break; + } + case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + break; + } + case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; + break; + } + case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; + break; + } + case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft; + break; + } + case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter; + break; + } + case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; + break; + } + default: {} + } + m_dwTTOStyles = 0; + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + m_dwTTOStyles |= FDE_TTOSTYLE_RTL; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) { + m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap; + } else { + m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; + } +} +void CFWL_CheckBoxImp::NextStates() { + FX_DWORD dwFirststate = m_pProperties->m_dwStates; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { + if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Unchecked) { + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr->IsFormDisabled()) { + CFX_PtrArray radioarr; + pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); + IFWL_CheckBox* pCheckBox = NULL; + int32_t iCount = radioarr.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); + if (pCheckBox != m_pInterface && + pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { + pCheckBox->SetCheckState(0); + CFX_RectF rt; + pCheckBox->GetWidgetRect(rt); + rt.left = rt.top = 0; + m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); + break; + } + } + } + m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; + } + } else { + if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Neutral) { + m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { + m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; + } + } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == + FWL_STATE_CKB_Checked) { + m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; + } else { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { + m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; + } else { + m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; + } + } + } + Repaint(&m_rtClient); + FX_DWORD dwLaststate = m_pProperties->m_dwStates; + if (dwFirststate != dwLaststate) { + CFWL_EvtCkbCheckStateChanged wmCheckBoxState; + wmCheckBoxState.m_pSrcTarget = m_pInterface; + DispatchEvent(&wmCheckBoxState); + } +} +CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_Activate: { + OnActivate(pMessage); + break; + } + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD 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; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + OnKeyDown(pKey); + } + break; + } + default: { iRet = 0; } + } + 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::OnActivate(CFWL_Message* pMsg) { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; + m_pOwner->Repaint(&(m_pOwner->m_rtClient)); +} +void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + } + m_pOwner->Repaint(&(m_pOwner->m_rtClient)); +} +void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + return; + } + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->SetFocus(TRUE); + } + m_pOwner->m_bBtnDown = TRUE; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; + m_pOwner->Repaint(&(m_pOwner->m_rtClient)); +} +void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + if (!m_pOwner->m_bBtnDown) { + return; + } + m_pOwner->m_bBtnDown = FALSE; + if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + return; + } + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed; + m_pOwner->NextStates(); +} +void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + return; + } + FX_BOOL bRepaint = FALSE; + if (m_pOwner->m_bBtnDown) { + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) { + bRepaint = TRUE; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; + } + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) { + bRepaint = TRUE; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; + } + } else { + if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) { + bRepaint = TRUE; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed; + } + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { + bRepaint = TRUE; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; + } + } + } else { + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { + bRepaint = TRUE; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; + } + } + } + if (bRepaint) { + m_pOwner->Repaint(&(m_pOwner->m_rtBox)); + } +} +void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_bBtnDown) { + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; + } + m_pOwner->Repaint(&(m_pOwner->m_rtBox)); +} +void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { + if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { + m_pOwner->DispatchKeyEvent(pMsg); + return; + } + if (pMsg->m_dwKeyCode == FWL_VKEY_Return || + pMsg->m_dwKeyCode == FWL_VKEY_Space) { + m_pOwner->NextStates(); + } +} diff --git a/xfa/fwl/basewidget/fwl_checkboximp.h b/xfa/fwl/basewidget/fwl_checkboximp.h new file mode 100644 index 0000000000..1f6f5f3f7c --- /dev/null +++ b/xfa/fwl/basewidget/fwl_checkboximp.h @@ -0,0 +1,64 @@ +// 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_FWL_CHECKBOXIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_CheckBoxImpDelegate; + +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 FX_DWORD 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); + + protected: + void Layout(); + FX_DWORD GetPartStates(); + void UpdateTextOutStyles(); + void NextStates(); + CFX_RectF m_rtClient; + CFX_RectF m_rtBox; + CFX_RectF m_rtCaption; + CFX_RectF m_rtFocus; + FX_DWORD 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; + + protected: + void OnActivate(CFWL_Message* pMsg); + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + CFWL_CheckBoxImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp new file mode 100644 index 0000000000..7aae6d5a97 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp @@ -0,0 +1,1819 @@ +// 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/basewidget/fwl_comboboximp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/fwl/basewidget/fwl_formproxyimp.h" +#include "xfa/fwl/basewidget/fwl_listboximp.h" +#include "xfa/fwl/basewidget/fwl_scrollbarimp.h" +#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/include/fwl/core/fwl_theme.h" + +// static +IFWL_ComboBox* IFWL_ComboBox::Create( + const CFWL_WidgetImpProperties& properties) { + IFWL_ComboBox* pComboBox = new IFWL_ComboBox; + CFWL_ComboBoxImp* pComboBoxImpl = new CFWL_ComboBoxImp(properties, nullptr); + pComboBox->SetImpl(pComboBoxImpl); + pComboBoxImpl->SetInterface(pComboBox); + return pComboBox; +} +IFWL_ComboBox::IFWL_ComboBox() {} +int32_t IFWL_ComboBox::GetCurSel() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetCurSel(); +} +FWL_ERR IFWL_ComboBox::SetCurSel(int32_t iSel) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetCurSel(iSel); +} +FWL_ERR 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 { + return static_cast<CFWL_ComboBoxImp*>(GetImpl()) + ->GetEditText(wsText, nStart, nCount); +} +FWL_ERR IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl()) + ->SetEditSelRange(nStart, nCount); +} +int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl()) + ->GetEditSelRange(nIndex, nStart); +} +int32_t IFWL_ComboBox::GetEditLimit() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditLimit(); +} +FWL_ERR IFWL_ComboBox::SetEditLimit(int32_t nLimit) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditLimit(nLimit); +} +FWL_ERR IFWL_ComboBox::EditDoClipboard(int32_t iCmd) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDoClipboard(iCmd); +} +FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(bsRecord); +} +FX_BOOL IFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(bsRecord); +} +IFWL_ListBox* IFWL_ComboBox::GetListBoxt() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetListBoxt(); +} +FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->AfterFocusShowDropList(); +} +FX_ERR IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->OpenDropDownList(bActivate); +} +FX_BOOL IFWL_ComboBox::EditCanUndo() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanUndo(); +} +FX_BOOL IFWL_ComboBox::EditCanRedo() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanRedo(); +} +FX_BOOL IFWL_ComboBox::EditUndo() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(); +} +FX_BOOL IFWL_ComboBox::EditRedo() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(); +} +FX_BOOL IFWL_ComboBox::EditCanCopy() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCopy(); +} +FX_BOOL IFWL_ComboBox::EditCanCut() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCut(); +} +FX_BOOL IFWL_ComboBox::EditCanSelectAll() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanSelectAll(); +} +FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCopy(wsCopy); +} +FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCut(wsCut); +} +FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditPaste(wsPaste); +} +FX_BOOL IFWL_ComboBox::EditSelectAll() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditSelectAll(); +} +FX_BOOL IFWL_ComboBox::EditDelete() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDelete(); +} +FX_BOOL IFWL_ComboBox::EditDeSelect() { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDeSelect(); +} +FWL_ERR IFWL_ComboBox::GetBBox(CFX_RectF& rect) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetBBox(rect); +} +FWL_ERR IFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + return static_cast<CFWL_ComboBoxImp*>(GetImpl()) + ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} + +CFWL_ComboEditImp::CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_EditImp(properties, pOuter) { + m_pOuter = static_cast<CFWL_ComboBoxImp*>(pOuter->GetImpl()); +} + +CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner) + : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} +int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + 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; + } + backDefault = FALSE; + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) && + ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { + m_pOwner->SetSelected(); + m_pOwner->SetComboBoxFocus(TRUE); + } + break; + } + default: {} + } + if (!backDefault) { + return 1; + } + return CFWL_EditImpDelegate::OnProcessMessage(pMessage); +} +void CFWL_ComboEditImp::ClearSelected() { + ClearSelections(); + Repaint(&m_rtClient); +} +void CFWL_ComboEditImp::SetSelected() { + FlagFocus(TRUE); + EndCaret(); + AddSelRange(0); +} +void CFWL_ComboEditImp::EndCaret() { + m_pEdtEngine->MoveCaretPos(MC_End); +} +void CFWL_ComboEditImp::FlagFocus(FX_BOOL bSet) { + if (bSet) { + m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + } else { + m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + ShowCaret(FALSE); + } +} +void CFWL_ComboEditImp::SetComboBoxFocus(FX_BOOL bSet) { + m_pOuter->SetFocus(bSet); +} +CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) { + FXSYS_assert(pOuter != NULL); +} +FWL_ERR CFWL_ComboListImp::Initialize() { + if (CFWL_ListBoxImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + delete m_pDelegate; + m_pDelegate = new CFWL_ComboListImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboListImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_ListBoxImp::Finalize(); +} +int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) { + if (wsMatch.IsEmpty()) { + return -1; + } + if (!m_pProperties->m_pDataProvider) + return -1; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + CFX_WideString wsText; + pData->GetItemText(m_pInterface, hItem, wsText); + FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); + if (!pos) { + return i; + } + } + return -1; +} +void CFWL_ComboListImp::ChangeSelected(int32_t iSel) { + if (!m_pProperties->m_pDataProvider) + return; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); + CFX_RectF rtInvalidate; + rtInvalidate.Reset(); + FWL_HLISTITEM hOld = GetSelItem(0); + int32_t iOld = pData->GetItemIndex(m_pInterface, hOld); + if (iOld == iSel) { + return; + } else if (iOld > -1) { + GetItemRect(iOld, rtInvalidate); + SetSelItem(hOld, FALSE); + } + if (hItem) { + CFX_RectF rect; + GetItemRect(iSel, rect); + rtInvalidate.Union(rect); + FWL_HLISTITEM hSel = pData->GetItem(m_pInterface, iSel); + SetSelItem(hSel, TRUE); + } + if (!rtInvalidate.IsEmpty()) { + Repaint(&rtInvalidate); + } +} +int32_t CFWL_ComboListImp::CountItems() { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + return pData ? pData->CountItems(m_pInterface) : 0; +} +void CFWL_ComboListImp::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, nIndex); + pData->GetItemRect(m_pInterface, hItem, rtItem); +} +void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { + fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top; + IFWL_Widget* pOwner = GetOwner(); + if (!pOwner) + return; + pOwner->TransformTo(m_pOuter, fx, 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) { + if (!pMessage) + return 0; + FX_DWORD 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) { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { + CFX_RectF rect; + m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); + if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { + pMsg->m_fx -= rect.left; + pMsg->m_fy -= rect.top; + IFWL_WidgetDelegate* pDelegate = + m_pOwner->m_pVertScrollBar->SetDelegate(NULL); + return pDelegate->OnProcessMessage(pMsg); + } + } + FX_DWORD dwCmd = pMsg->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_MouseMove: { + backDefault = FALSE; + OnDropListMouseMove(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonDown: { + backDefault = FALSE; + OnDropListLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + backDefault = FALSE; + OnDropListLButtonUp(pMsg); + break; + } + default: {} + } + } else if (dwHashCode == FWL_MSGHASH_Key) { + backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage)); + } + if (!backDefault) { + return 1; + } + return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage); +} +void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (!bSet) { + CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); + CFWL_ComboBoxImp* pOuter = + static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); + if (pKill->m_pSetFocus == m_pOwner->m_pOuter || + pKill->m_pSetFocus == pOuter->m_pEdit.get()) { + pOuter->ShowDropList(FALSE); + } + } +} +int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_pOwner->m_bNotifyOwner) { + m_pOwner->m_bNotifyOwner = FALSE; + } + if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { + CFX_RectF rect; + m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); + if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { + return 1; + } + } + FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + if (hItem) { + if (!m_pOwner->m_pProperties->m_pDataProvider) + return 0; + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( + m_pOwner->m_pProperties->m_pDataProvider); + int32_t iSel = pData->GetItemIndex(m_pOwner->m_pInterface, hItem); + CFWL_EvtCmbHoverChanged event; + event.m_pSrcTarget = m_pOwner->m_pOuter; + event.m_iCurHover = iSel; + m_pOwner->DispatchEvent(&event); + m_pOwner->ChangeSelected(iSel); + } + } else if (m_pOwner->m_bNotifyOwner) { + m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); + CFWL_ComboBoxImp* pOuter = + static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); + pOuter->m_pDelegate->OnProcessMessage(pMsg); + } + return 1; +} +int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + return 0; + } + CFWL_ComboBoxImp* pOuter = + static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); + pOuter->ShowDropList(FALSE); + return 1; +} +int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { + CFWL_ComboBoxImp* pOuter = + static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); + if (m_pOwner->m_bNotifyOwner) { + m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); + pOuter->m_pDelegate->OnProcessMessage(pMsg); + } else { + if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { + CFX_RectF rect; + m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); + if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { + return 1; + } + } + pOuter->ShowDropList(FALSE); + FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + if (hItem) { + pOuter->ProcessSelChanged(TRUE); + } + } + return 1; +} +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) { + FX_DWORD dwKeyCode = pKey->m_dwKeyCode; + switch (dwKeyCode) { + case FWL_VKEY_Return: + case FWL_VKEY_Escape: { + pOuter->ShowDropList(FALSE); + return 1; + } + case FWL_VKEY_Up: + case FWL_VKEY_Down: { + OnDropListKeyDown(pKey); + pOuter->SetDelegate(nullptr); + pOuter->ProcessSelChanged(FALSE); + return 1; + } + default: { bPropagate = TRUE; } + } + } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) { + bPropagate = TRUE; + } + if (bPropagate) { + pKey->m_pDstTarget = m_pOwner->m_pOuter; + pOuter->m_pDelegate->OnProcessMessage(pKey); + return 1; + } + return 0; +} +void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) { + FX_DWORD dwKeyCode = pKey->m_dwKeyCode; + switch (dwKeyCode) { + case FWL_VKEY_Up: + case FWL_VKEY_Down: + case FWL_VKEY_Home: + case FWL_VKEY_End: { + CFWL_ComboBoxImp* pOuter = + static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( + m_pOwner->m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = + pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel); + hItem = m_pOwner->GetItem(hItem, dwKeyCode); + if (!hItem) { + break; + } + m_pOwner->SetSelection(hItem, hItem, TRUE); + m_pOwner->ScrollToVisible(hItem); + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, + m_pOwner->m_pProperties->m_rtWidget.height); + m_pOwner->Repaint(&rtInvalidate); + break; + } + default: {} + } +} +CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_pForm(NULL), + m_bLButtonDown(FALSE), + m_iCurSel(-1), + m_iBtnState(FWL_PARTSTATE_CMB_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 { + wsClass = FWL_CLASS_ComboBox; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_ComboBoxImp::GetClassID() const { + return FWL_CLASSHASH_ComboBox; +} +FWL_ERR 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. + 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) { + 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(); + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { + CFWL_WidgetImpProperties prop2; + m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop2, m_pInterface)); + m_pEdit->Initialize(); + static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); + } + if (m_pEdit) { + m_pEdit->SetParent(m_pInterface); + } + SetStates(m_pProperties->m_dwStates); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::Finalize() { + if (m_pEdit) { + m_pEdit->Finalize(); + } + m_pListBox->Finalize(); + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + rect.Reset(); + FX_BOOL bIsDropDown = IsDropDownStyle(); + if (bIsDropDown && m_pEdit) { + m_pEdit->GetWidgetRect(rect, TRUE); + } else { + rect.width = 100; + rect.height = 16; + } + if (!m_pProperties->m_pThemeProvider) { + ReSetTheme(); + } + FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + if (!pFWidth) + return FWL_ERR_Indefinite; + rect.Inflate(0, 0, *pFWidth, 0); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD 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; + if (bAddDropDown && !m_pEdit) { + CFWL_WidgetImpProperties prop; + m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, nullptr)); + m_pEdit->Initialize(); + static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); + m_pEdit->SetParent(m_pInterface); + } else if (bRemoveDropDown && m_pEdit) { + m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} +FWL_ERR CFWL_ComboBoxImp::Update() { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_Update(); + } + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + ReSetTheme(); + FX_BOOL bDropDown = IsDropDownStyle(); + if (bDropDown && m_pEdit) { + ReSetEditAlignment(); + } + if (m_pProperties->m_pThemeProvider == NULL) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + Layout(); + CFWL_ThemePart part; + 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; +} +FX_DWORD 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) { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_DrawWidget(pGraphics, pMatrix); + } + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + FX_BOOL bIsDropDown = IsDropDownStyle(); + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_CMB_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_CMB_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_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = rtTextBk; + if (m_iCurSel >= 0) { + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->m_pProperties->m_pDataProvider); + void* p = pData->GetItemData(m_pListBox.get(), + pData->GetItem(m_pListBox.get(), m_iCurSel)); + if (p != NULL) { + param.m_pData = p; + } + } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + param.m_dwStates = FWL_PARTSTATE_CMB_Disabled; + } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && + (m_iCurSel >= 0)) { + param.m_dwStates = FWL_PARTSTATE_CMB_Selected; + } else { + param.m_dwStates = FWL_PARTSTATE_CMB_Normal; + } + pTheme->DrawBackground(¶m); + if (m_iCurSel >= 0) { + if (!m_pListBox) + return FWL_ERR_Indefinite; + CFX_WideString wsText; + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->GetItemText(hItem, wsText); + CFWL_ThemeText param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_CMB_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; + param.m_wsText = wsText; + param.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + param.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + pTheme->DrawText(¶m); + } + } + { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_CMB_DropDownButton; + param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_CMB_Disabled + : m_iBtnState; + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = m_rtBtn; + pTheme->DrawBackground(¶m); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { + if (!pThemeProvider) + return FWL_ERR_Indefinite; + m_pProperties->m_pThemeProvider = pThemeProvider; + if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox.get())) { + m_pListBox->SetThemeProvider(pThemeProvider); + } + if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit.get())) { + m_pEdit->SetThemeProvider(pThemeProvider); + } + return FWL_ERR_Succeeded; +} +int32_t CFWL_ComboBoxImp::GetCurSel() { + return m_iCurSel; +} +FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { + int32_t iCount = + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems(); + FX_BOOL bClearSel = iSel < 0 || iSel >= iCount; + FX_BOOL bDropDown = IsDropDownStyle(); + if (bDropDown && m_pEdit) { + if (bClearSel) { + m_pEdit->SetText(CFX_WideString()); + } else { + CFX_WideString wsText; + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->GetItemText(hItem, wsText); + m_pEdit->SetText(wsText); + } + m_pEdit->Update(); + } + m_iCurSel = bClearSel ? -1 : iSel; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { + FX_BOOL bIsDropDown = IsDropDownStyle(); + if (bIsDropDown && m_pEdit) { + m_pEdit->SetStates(dwStates, bSet); + } + if (m_pListBox) { + m_pListBox->SetStates(dwStates, bSet); + } + return CFWL_WidgetImp::SetStates(dwStates, bSet); +} +FWL_ERR CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) { + if (!m_pEdit) + return FWL_ERR_Indefinite; + m_pEdit->SetText(wsText); + return m_pEdit->Update(); +} +int32_t CFWL_ComboBoxImp::GetEditTextLength() const { + if (!m_pEdit) + return -1; + return m_pEdit->GetTextLength(); +} +FWL_ERR 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) { + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + return m_pListBox->GetItemText(hItem, wsText); + } + return FWL_ERR_Indefinite; +} +FWL_ERR CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) { + if (!m_pEdit) + return FWL_ERR_Indefinite; + static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->ClearSelected(); + m_pEdit->AddSelRange(nStart, nCount); + return FWL_ERR_Succeeded; +} +int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t& nStart) { + if (!m_pEdit) + return -1; + return m_pEdit->GetSelRange(nIndex, nStart); +} +int32_t CFWL_ComboBoxImp::GetEditLimit() { + if (!m_pEdit) + return -1; + return m_pEdit->GetLimit(); +} +FWL_ERR CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) { + if (!m_pEdit) + return FWL_ERR_Indefinite; + return m_pEdit->SetLimit(nLimit); +} +FWL_ERR CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) { + if (!m_pEdit) + return FWL_ERR_Indefinite; + return m_pEdit->DoClipboard(iCmd); +} +FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord) { + if (!m_pEdit) + return FALSE; + return m_pEdit->Redo(bsRecord); +} +FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) { + if (!m_pEdit) + return FALSE; + return m_pEdit->Undo(bsRecord); +} +IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { + return m_pListBox.get(); +} +FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { + if (!m_bNeedShowList) { + return FALSE; + } + if (m_pEdit) { + MatchEditText(); + } + ShowDropList(TRUE); + m_bNeedShowList = FALSE; + return TRUE; +} +FX_ERR CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) { + ShowDropList(bActivate); + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_ComboBoxImp::EditCanUndo() { + return m_pEdit->CanUndo(); +} +FX_BOOL CFWL_ComboBoxImp::EditCanRedo() { + return m_pEdit->CanRedo(); +} +FX_BOOL CFWL_ComboBoxImp::EditUndo() { + return m_pEdit->Undo(); +} +FX_BOOL CFWL_ComboBoxImp::EditRedo() { + return m_pEdit->Redo(); +} +FX_BOOL CFWL_ComboBoxImp::EditCanCopy() { + return m_pEdit->CountSelRanges() > 0; +} +FX_BOOL CFWL_ComboBoxImp::EditCanCut() { + if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { + return FALSE; + } + return m_pEdit->CountSelRanges() > 0; +} +FX_BOOL CFWL_ComboBoxImp::EditCanSelectAll() { + return m_pEdit->GetTextLength() > 0; +} +FX_BOOL CFWL_ComboBoxImp::EditCopy(CFX_WideString& wsCopy) { + return m_pEdit->Copy(wsCopy); +} +FX_BOOL CFWL_ComboBoxImp::EditCut(CFX_WideString& wsCut) { + return m_pEdit->Cut(wsCut); +} +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; +} +FX_BOOL CFWL_ComboBoxImp::EditDelete() { + return m_pEdit->ClearText() == FWL_ERR_Succeeded; +} +FX_BOOL CFWL_ComboBoxImp::EditDeSelect() { + return m_pEdit->ClearSelections() == FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_GetBBox(rect); + } + rect = m_pProperties->m_rtWidget; + if (m_pListBox && IsDropListShowed()) { + CFX_RectF rtList; + m_pListBox->GetWidgetRect(rtList); + rtList.Offset(rect.left, rect.top); + rect.Union(rtList); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::EditModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + if (m_pEdit != NULL) { + return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); + } else { + return FWL_ERR_Parameter_Invalid; + } +} +FX_FLOAT CFWL_ComboBoxImp::GetListHeight() { + return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) + ->GetListHeight(m_pInterface); +} +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_pWidget = m_pInterface; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtHandler; + m_pProperties->m_pThemeProvider->DrawBackground(¶m); +} +void CFWL_ComboBoxImp::ShowDropList(FX_BOOL bActivate) { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_ShowDropList(bActivate); + } + FX_BOOL bDropList = IsDropListShowed(); + if (bDropList == bActivate) { + return; + } + if (!m_pForm) { + InitProxyForm(); + } + m_pListProxyDelegate->Reset(); + if (bActivate) { + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->ChangeSelected(m_iCurSel); + ReSetListItemAlignment(); + FX_DWORD dwStyleAdd = m_pProperties->m_dwStyleExes & + (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); + m_pListBox->ModifyStylesEx(dwStyleAdd, 0); + m_pListBox->GetWidgetRect(m_rtList, TRUE); + FX_FLOAT fHeight = GetListHeight(); + if (fHeight > 0) { + if (m_rtList.height > GetListHeight()) { + m_rtList.height = GetListHeight(); + m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); + } + } + CFX_RectF rtAnchor; + rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); + FX_FLOAT fMinHeight = 0; + if (m_rtList.width < m_rtClient.width) { + m_rtList.width = m_rtClient.width; + } + m_rtProxy = m_rtList; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { + m_rtProxy.height += m_fComboFormHandler; + } + GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { + FX_FLOAT fx = 0; + FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2; + TransformTo(NULL, fx, fy); + m_bUpFormHandler = fy > m_rtProxy.top; + if (m_bUpFormHandler) { + m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler); + m_rtList.top = m_fComboFormHandler; + } else { + m_rtHandler.Set(0, m_rtList.height, m_rtList.width, + m_fComboFormHandler); + } + } + m_pForm->SetWidgetRect(m_rtProxy); + m_pForm->Update(); + m_pListBox->SetWidgetRect(m_rtList); + m_pListBox->Update(); + CFWL_EvtCmbPreDropDown ev; + ev.m_pSrcTarget = m_pInterface; + DispatchEvent(&ev); + m_fItemHeight = + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_fItemHeight; + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(TRUE); + m_pForm->DoModal(); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(FALSE); + } else { + m_pForm->EndDoModal(); + CFWL_EvtCmbCloseUp ev; + ev.m_pSrcTarget = m_pInterface; + DispatchEvent(&ev); + m_bLButtonDown = FALSE; + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_bNotifyOwner = + TRUE; + SetFocus(TRUE); + } +} +FX_BOOL CFWL_ComboBoxImp::IsDropListShowed() { + return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); +} +FX_BOOL CFWL_ComboBoxImp::IsDropDownStyle() const { + return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown; +} +void CFWL_ComboBoxImp::MatchEditText() { + CFX_WideString wsText; + m_pEdit->GetText(wsText); + int32_t iMatch = + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->MatchItem(wsText); + if (iMatch != m_iCurSel) { + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->ChangeSelected(iMatch); + if (iMatch >= 0) { + SynchrEditText(iMatch); + } + } else if (iMatch >= 0) { + static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); + } + m_iCurSel = iMatch; +} +void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem) { + CFX_WideString wsText; + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iListItem); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->GetItemText(hItem, wsText); + m_pEdit->SetText(wsText); + m_pEdit->Update(); + static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); +} +void CFWL_ComboBoxImp::Layout() { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_Layout(); + } + GetClientRect(m_rtClient); + FX_FLOAT* pFWidth = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + if (!pFWidth) + return; + FX_FLOAT fBtn = *pFWidth; + m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, + m_rtClient.height); + FX_BOOL bIsDropDown = IsDropDownStyle(); + if (bIsDropDown && m_pEdit) { + CFX_RectF rtEdit; + rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, + m_rtClient.height); + m_pEdit->SetWidgetRect(rtEdit); + if (m_iCurSel >= 0) { + CFX_WideString wsText; + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->GetItemText(hItem, wsText); + m_pEdit->LockUpdate(); + m_pEdit->SetText(wsText); + m_pEdit->UnlockUpdate(); + } + m_pEdit->Update(); + } +} +void CFWL_ComboBoxImp::ReSetTheme() { + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (!pTheme) { + pTheme = GetAvailableTheme(); + m_pProperties->m_pThemeProvider = pTheme; + } + if (m_pListBox) { + if (!m_pListBox->GetThemeProvider() && + pTheme->IsValidWidget(m_pListBox.get())) { + m_pListBox->SetThemeProvider(pTheme); + } + } + if (m_pEdit) { + if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit.get())) { + m_pEdit->SetThemeProvider(pTheme); + } + } +} +void CFWL_ComboBoxImp::ReSetEditAlignment() { + if (!m_pEdit) + return; + FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; + FX_DWORD dwAdd = 0; + switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { + case FWL_STYLEEXT_CMB_EditHCenter: { + dwAdd |= FWL_STYLEEXT_EDT_HCenter; + break; + } + case FWL_STYLEEXT_CMB_EditHFar: { + dwAdd |= FWL_STYLEEXT_EDT_HFar; + break; + } + default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; } + } + switch (dwStylExes & FWL_STYLEEXT_CMB_EditVAlignMask) { + case FWL_STYLEEXT_CMB_EditVCenter: { + dwAdd |= FWL_STYLEEXT_EDT_VCenter; + break; + } + case FWL_STYLEEXT_CMB_EditVFar: { + dwAdd |= FWL_STYLEEXT_EDT_VFar; + break; + } + default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; } + } + if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) { + dwAdd |= FWL_STYLEEXT_EDT_Justified; + } + if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) { + dwAdd |= FWL_STYLEEXT_EDT_Distributed; + } + m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | + FWL_STYLEEXT_EDT_HAlignModeMask | + FWL_STYLEEXT_EDT_VAlignMask); +} +void CFWL_ComboBoxImp::ReSetListItemAlignment() { + if (!m_pListBox) + return; + FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; + FX_DWORD dwAdd = 0; + switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { + case FWL_STYLEEXT_CMB_ListItemCenterAlign: { + dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; + } + case FWL_STYLEEXT_CMB_ListItemRightAlign: { + dwAdd |= FWL_STYLEEXT_LTB_RightAlign; + } + default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; } + } + m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); +} +void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) { + IFWL_ComboBoxDP* pDatas = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + m_iCurSel = pDatas->GetItemIndex(m_pInterface, m_pListBox->GetSelItem(0)); + FX_BOOL bDropDown = IsDropDownStyle(); + if (bDropDown) { + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + if (hItem) { + CFX_WideString wsText; + pData->GetItemText(m_pInterface, hItem, wsText); + if (m_pEdit) { + m_pEdit->SetText(wsText); + m_pEdit->Update(); + static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); + } + CFWL_EvtCmbSelChanged ev; + ev.bLButtonUp = bLButtonUp; + ev.m_pSrcTarget = m_pInterface; + ev.iArraySels.Add(m_iCurSel); + DispatchEvent(&ev); + } + } else { + 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; + propForm.m_dwStates = FWL_WGTSTATE_Invisible; + CFX_WideString className; + m_pForm = IFWL_Form::CreateFormProxy(propForm, &className, m_pListBox.get()); + m_pForm->Initialize(); + m_pProxy = static_cast<CFWL_FormProxyImp*>(m_pForm->GetImpl()); + m_pListBox->SetParent(m_pForm); + 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. + m_pDelegate = new CFWL_ComboBoxImpDelegate(this); + DisForm_InitComboList(); + DisForm_InitComboEdit(); + return FWL_ERR_Succeeded; +} +void CFWL_ComboBoxImp::DisForm_InitComboList() { + if (m_pListBox) { + return; + } + CFWL_WidgetImpProperties prop; + prop.m_pParent = m_pInterface; + prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; + prop.m_dwStates = FWL_WGTSTATE_Invisible; + prop.m_pDataProvider = m_pProperties->m_pDataProvider; + prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pListBox.reset(IFWL_ListBox::CreateComboList(prop, m_pInterface)); + m_pListBox->Initialize(); +} +void CFWL_ComboBoxImp::DisForm_InitComboEdit() { + if (m_pEdit) { + return; + } + CFWL_WidgetImpProperties prop; + prop.m_pParent = m_pInterface; + prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, m_pInterface)); + m_pEdit->Initialize(); + static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); +} +void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) { + FX_BOOL bDropList = DisForm_IsDropListShowed(); + if (bDropList == bActivate) { + return; + } + if (bActivate) { + CFWL_EvtCmbPreDropDown preEvent; + preEvent.m_pSrcTarget = m_pInterface; + DispatchEvent(&preEvent); + CFWL_ComboListImp* pComboList = + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()); + int32_t iItems = pComboList->CountItems(); + if (iItems < 1) { + return; + } + ReSetListItemAlignment(); + pComboList->ChangeSelected(m_iCurSel); + FX_FLOAT fItemHeight = pComboList->GetItemHeigt(); + FX_FLOAT fBorder = GetBorderSize(); + FX_FLOAT fPopupMin = 0.0f; + if (iItems > 3) { + fPopupMin = fItemHeight * 3 + fBorder * 2; + } + FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; + CFX_RectF rtList; + rtList.left = m_rtClient.left; + rtList.width = m_pProperties->m_rtWidget.width; + rtList.top = 0; + rtList.height = 0; + GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); + m_pListBox->SetWidgetRect(rtList); + m_pListBox->Update(); + } else { + SetFocus(TRUE); + } + m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); + if (bActivate) { + CFWL_EvtCmbPostDropDown postEvent; + postEvent.m_pSrcTarget = m_pInterface; + DispatchEvent(&postEvent); + } + CFX_RectF rect; + m_pListBox->GetWidgetRect(rect); + rect.Inflate(2, 2); + Repaint(&rect); +} +FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed() { + return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); +} +FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + if (!m_pEdit) { + DisForm_InitComboEdit(); + } + FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown; + FX_BOOL bDelDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown; + dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; + m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; + if (bAddDropDown) { + m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); + } else if (bDelDropDown) { + m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); + } + return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} +FWL_ERR CFWL_ComboBoxImp::DisForm_Update() { + if (m_iLock) { + return FWL_ERR_Indefinite; + } + if (m_pEdit) { + ReSetEditAlignment(); + } + ReSetTheme(); + Layout(); + return FWL_ERR_Succeeded; +} +FX_DWORD 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 (DisForm_IsDropListShowed()) { + m_pListBox->GetWidgetRect(rect); + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + } + return FWL_WGTHITTEST_Unknown; +} +FWL_ERR 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); + if (pMatrix) { + mtOrg = *pMatrix; + } + FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed(); + pGraphics->SaveGraphState(); + pGraphics->ConcatMatrix(&mtOrg); + if (!m_rtBtn.IsEmpty(0.1f)) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_CMB_DropDownButton; + param.m_dwStates = m_iBtnState; + param.m_pGraphics = pGraphics; + param.m_rtPart = m_rtBtn; + pTheme->DrawBackground(¶m); + } + pGraphics->RestoreGraphState(); + if (m_pEdit) { + CFX_RectF rtEdit; + m_pEdit->GetWidgetRect(rtEdit); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); + mt.Concat(mtOrg); + m_pEdit->DrawWidget(pGraphics, &mt); + } + if (bListShowed) { + CFX_RectF rtList; + m_pListBox->GetWidgetRect(rtList); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtList.left, rtList.top); + mt.Concat(mtOrg); + m_pListBox->DrawWidget(pGraphics, &mt); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) { + rect = m_pProperties->m_rtWidget; + if (m_pListBox && DisForm_IsDropListShowed()) { + CFX_RectF rtList; + m_pListBox->GetWidgetRect(rtList); + rtList.Offset(rect.left, rect.top); + rect.Union(rtList); + } + return FWL_ERR_Succeeded; +} +void CFWL_ComboBoxImp::DisForm_Layout() { + GetClientRect(m_rtClient); + m_rtContent = m_rtClient; + FX_FLOAT* pFWidth = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + if (!pFWidth) + return; + FX_FLOAT borderWidth = 0; + { borderWidth = FWL_PART_CMB_Border; } + 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)); + if (pUIMargin) { + m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, + pUIMargin->height); + } + FX_BOOL bIsDropDown = IsDropDownStyle(); + if (bIsDropDown && m_pEdit) { + CFX_RectF rtEdit; + rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, + m_rtContent.height); + m_pEdit->SetWidgetRect(rtEdit); + if (m_iCurSel >= 0) { + CFX_WideString wsText; + IFWL_ComboBoxDP* pData = + static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) + ->GetItemText(hItem, wsText); + m_pEdit->LockUpdate(); + m_pEdit->SetText(wsText); + m_pEdit->UnlockUpdate(); + } + m_pEdit->Update(); + } +} +CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + return DisForm_OnProcessMessage(pMessage); + } + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + FX_BOOL iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD 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; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + OnKey(static_cast<CFWL_MsgKey*>(pMessage)); + break; + } + default: { iRet = 0; } + } + CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); + return iRet; +} +FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { + FX_DWORD dwFlag = pEvent->GetClassID(); + if (dwFlag == FWL_EVTHASH_LTB_DrawItem) { + CFWL_EvtLtbDrawItem* pDrawItemEvent = + static_cast<CFWL_EvtLtbDrawItem*>(pEvent); + CFWL_EvtCmbDrawItem pTemp; + pTemp.m_pSrcTarget = m_pOwner->m_pInterface; + pTemp.m_pGraphics = pDrawItemEvent->m_pGraphics; + pTemp.m_index = pDrawItemEvent->m_index; + pTemp.m_rtItem = pDrawItemEvent->m_rect; + m_pOwner->DispatchEvent(&pTemp); + } else if (dwFlag == FWL_EVTHASH_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) { + CFWL_EvtEdtTextChanged* pTextChangedEvent = + static_cast<CFWL_EvtEdtTextChanged*>(pEvent); + CFWL_EvtCmbEditChanged pTemp; + pTemp.m_pSrcTarget = m_pOwner->m_pInterface; + pTemp.wsInsert = pTextChangedEvent->wsInsert; + pTemp.wsDelete = pTextChangedEvent->wsDelete; + 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::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + IFWL_Target* pDstTarget = pMsg->m_pDstTarget; + IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget; + FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) { + if (!m_pOwner->m_pEdit) + return; + static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) + ->SetSelected(); + } else { + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) { + if (!m_pOwner->m_pEdit) + return; + static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) + ->FlagFocus(FALSE); + static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) + ->ClearSelected(); + } else { + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + } +} +void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + return; + } + FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); + CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient; + FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); + if (bClickBtn) { + if (bDropDown && m_pOwner->m_pEdit) { + m_pOwner->MatchEditText(); + } + m_pOwner->m_bLButtonDown = TRUE; + m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Pressed; + m_pOwner->Repaint(&m_pOwner->m_rtClient); + m_pOwner->ShowDropList(TRUE); + m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_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; + } else { + m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_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; + } else { + m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal; + } + if ((iOldState != m_pOwner->m_iBtnState) && + !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == + FWL_WGTSTATE_Disabled)) { + m_pOwner->Repaint(&m_pOwner->m_rtBtn); + } +} +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->Repaint(&m_pOwner->m_rtBtn); + } +} +void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) { + FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; + if (dwKeyCode == FWL_VKEY_Tab) { + m_pOwner->DispatchKeyEvent(pMsg); + return; + } + if (pMsg->m_pDstTarget == m_pOwner->m_pInterface) + DoSubCtrlKey(pMsg); +} +void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) { + FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; + const bool bUp = dwKeyCode == FWL_VKEY_Up; + const bool bDown = dwKeyCode == FWL_VKEY_Down; + if (bUp || bDown) { + int32_t iCount = + static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) + ->CountItems(); + if (iCount < 1) { + return; + } + FX_BOOL bMatchEqual = FALSE; + int32_t iCurSel = m_pOwner->m_iCurSel; + FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); + if (bDropDown && m_pOwner->m_pEdit) { + CFX_WideString wsText; + m_pOwner->m_pEdit->GetText(wsText); + iCurSel = static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) + ->MatchItem(wsText); + if (iCurSel >= 0) { + CFX_WideString wsTemp; + IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>( + m_pOwner->m_pProperties->m_pDataProvider); + FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel); + static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) + ->GetItemText(hItem, wsTemp); + bMatchEqual = wsText.Equal(wsTemp); + } + } + if (iCurSel < 0) { + iCurSel = 0; + } else if (!bDropDown || bMatchEqual) { + if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) { + return; + } + if (bUp) { + iCurSel--; + } else { + iCurSel++; + } + } + m_pOwner->m_iCurSel = iCurSel; + if (bDropDown && m_pOwner->m_pEdit) { + m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); + } else { + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + return; + } + FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); + if (bDropDown) { + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMsg); + } +} +int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( + CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + FX_BOOL backDefault = TRUE; + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + backDefault = FALSE; + DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + backDefault = FALSE; + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMsg->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + DisForm_OnLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + backDefault = FALSE; + CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) { + break; + } + if (m_pOwner->DisForm_IsDropListShowed() && + pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + FX_DWORD dwKeyCode = pKey->m_dwKeyCode; + FX_BOOL bListKey = + dwKeyCode == FWL_VKEY_Up || dwKeyCode == FWL_VKEY_Down || + dwKeyCode == FWL_VKEY_Return || dwKeyCode == FWL_VKEY_Escape; + if (bListKey) { + IFWL_WidgetDelegate* pDelegate = + m_pOwner->m_pListBox->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMessage); + break; + } + } + DisForm_OnKey(pKey); + break; + } + default: {} + } + if (!backDefault) { + return 1; + } + return 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; + FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); + if (bClickBtn) { + if (m_pOwner->DisForm_IsDropListShowed()) { + m_pOwner->DisForm_ShowDropList(FALSE); + return; + } + { + if (m_pOwner->m_pEdit) { + m_pOwner->MatchEditText(); + } + m_pOwner->DisForm_ShowDropList(TRUE); + } + } +} +void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { + CFWL_MsgSetFocus msg; + msg.m_pDstTarget = m_pOwner->m_pEdit.get(); + msg.m_pSrcTarget = NULL; + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(&msg); + } + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_pOwner->DisForm_ShowDropList(FALSE); + CFWL_MsgKillFocus msg; + msg.m_pDstTarget = NULL; + msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(&msg); + } +} +void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { + FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; + const bool bUp = dwKeyCode == FWL_VKEY_Up; + const bool bDown = dwKeyCode == FWL_VKEY_Down; + if (bUp || bDown) { + CFWL_ComboListImp* pComboList = + static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()); + int32_t iCount = pComboList->CountItems(); + if (iCount < 1) { + return; + } + FX_BOOL bMatchEqual = FALSE; + int32_t iCurSel = m_pOwner->m_iCurSel; + if (m_pOwner->m_pEdit) { + CFX_WideString wsText; + m_pOwner->m_pEdit->GetText(wsText); + iCurSel = pComboList->MatchItem(wsText); + if (iCurSel >= 0) { + CFX_WideString wsTemp; + FWL_HLISTITEM item = m_pOwner->m_pListBox->GetSelItem(iCurSel); + m_pOwner->m_pListBox->GetItemText(item, wsTemp); + bMatchEqual = wsText.Equal(wsTemp); + } + } + if (iCurSel < 0) { + iCurSel = 0; + } else if (bMatchEqual) { + if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) { + return; + } + if (bUp) { + iCurSel--; + } else { + iCurSel++; + } + } + m_pOwner->m_iCurSel = iCurSel; + m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); + return; + } + if (m_pOwner->m_pEdit) { + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMsg); + } +} +CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate( + IFWL_Form* pForm, + CFWL_ComboBoxImp* pComboBox) + : m_bLButtonDown(FALSE), + m_bLButtonUpSelf(FALSE), + m_fStartPos(0), + m_pForm(pForm), + m_pComboBox(pComboBox) {} +int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + if (dwMsgCode == FWL_MSGHASH_Mouse) { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD 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; + } + default: {} + } + } + 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); +} +FWL_ERR 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) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + CFX_RectF rtWidget; + m_pForm->GetWidgetRect(rtWidget); + rtWidget.left = rtWidget.top = 0; + if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_bLButtonDown = TRUE; + pDriver->SetGrab(m_pForm, TRUE); + } else { + m_bLButtonDown = FALSE; + pDriver->SetGrab(m_pForm, FALSE); + m_pComboBox->ShowDropList(FALSE); + } +} +void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + m_bLButtonDown = FALSE; + IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); + if (!pThread) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + pDriver->SetGrab(m_pForm, FALSE); + if (m_bLButtonUpSelf) { + CFX_RectF rect; + m_pForm->GetWidgetRect(rect); + rect.left = rect.top = 0; + if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && + m_pComboBox->IsDropListShowed()) { + m_pComboBox->ShowDropList(FALSE); + } + } else { + m_bLButtonUpSelf = TRUE; + } +} +void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {} +void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) { + m_pComboBox->ShowDropList(FALSE); +} +void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, + FX_BOOL bSet) { + if (!bSet) { + if (pMsg->m_pSetFocus == NULL) { + m_pComboBox->ShowDropList(FALSE); + } + } +} diff --git a/xfa/fwl/basewidget/fwl_comboboximp.h b/xfa/fwl/basewidget/fwl_comboboximp.h new file mode 100644 index 0000000000..74f6c6354d --- /dev/null +++ b/xfa/fwl/basewidget/fwl_comboboximp.h @@ -0,0 +1,237 @@ +// 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_FWL_COMBOBOXIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ + +#include <memory> + +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/fwl/basewidget/fwl_listboximp.h" + +class CFWL_WidgetImp; +class CFWL_WidgetImpProperties; +class CFWL_WidgetImpDelegate; +class CFWL_ListBoxImp; +class CFWL_ListBoxImpDelegate; +class CFWL_FormProxyImp; +class IFWL_Widget; +class CFWL_ComboEditImp; +class CFWL_ComboEditImpDelegate; +class CFWL_ComboListImp; +class CFWL_ComboListImpDelegate; +class CFWL_ComboBoxImp; +class CFWL_ComboBoxImpDelegate; +class CFWL_ComboProxyImpDelegate; +class CFWL_ComboEditImp : public CFWL_EditImp { + public: + CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + + void ClearSelected(); + void SetSelected(); + void EndCaret(); + void FlagFocus(FX_BOOL bSet); + + protected: + void SetComboBoxFocus(FX_BOOL bSet); + CFWL_ComboBoxImp* m_pOuter; + friend class CFWL_ComboEditImpDelegate; +}; +class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate { + public: + CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner); + int32_t OnProcessMessage(CFWL_Message* pMessage) override; + + protected: + CFWL_ComboEditImp* m_pOwner; +}; +class CFWL_ComboListImp : public CFWL_ListBoxImp { + public: + CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + 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; + + protected: + void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg); + int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg); + int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg); + int32_t OnDropListKey(CFWL_MsgKey* pKey); + void OnDropListKeyDown(CFWL_MsgKey* pKey); + CFWL_ComboListImp* m_pOwner; +}; +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 FX_DWORD 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(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved); + virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); + virtual FWL_ERR Update(); + virtual FX_DWORD 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(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved); + + protected: + void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); + FX_FLOAT GetListHeight(); + void ShowDropList(FX_BOOL bActivate); + FX_BOOL IsDropListShowed(); + FX_BOOL IsDropDownStyle() const; + void MatchEditText(); + void SynchrEditText(int32_t iListItem); + void Layout(); + void ReSetTheme(); + void ReSetEditAlignment(); + void ReSetListItemAlignment(); + void ProcessSelChanged(FX_BOOL bLButtonUp); + void InitProxyForm(); + FWL_ERR DisForm_Initialize(); + void DisForm_InitComboList(); + void DisForm_InitComboEdit(); + void DisForm_ShowDropList(FX_BOOL bActivate); + FX_BOOL DisForm_IsDropListShowed(); + FWL_ERR DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved); + FWL_ERR DisForm_Update(); + FX_DWORD 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); + void DisForm_Layout(); + + CFX_RectF m_rtClient; + CFX_RectF m_rtContent; + CFX_RectF m_rtBtn; + CFX_RectF m_rtList; + CFX_RectF m_rtProxy; + CFX_RectF m_rtHandler; + std::unique_ptr<IFWL_Edit> m_pEdit; + std::unique_ptr<IFWL_ListBox> m_pListBox; + IFWL_Form* m_pForm; + FX_BOOL m_bLButtonDown; + FX_BOOL m_bUpFormHandler; + int32_t m_iCurSel; + int32_t m_iBtnState; + FX_FLOAT m_fComboFormHandler; + FX_FLOAT m_fItemHeight; + 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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKey(CFWL_MsgKey* pMsg); + void DoSubCtrlKey(CFWL_MsgKey* pMsg); + + protected: + int32_t 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); + + protected: + CFWL_ComboBoxImp* m_pOwner; + friend class CFWL_ComboEditImpDelegate; + friend class CFWL_ComboListImpDelegate; +}; +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 Reset() { m_bLButtonUpSelf = FALSE; } + + protected: + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnDeactive(CFWL_MsgDeactivate* pMsg); + void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet); + FX_BOOL m_bLButtonDown; + FX_BOOL m_bLButtonUpSelf; + FX_FLOAT m_fStartPos; + IFWL_Form* m_pForm; + CFWL_ComboBoxImp* m_pComboBox; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp new file mode 100644 index 0000000000..cd82dde5ac --- /dev/null +++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp @@ -0,0 +1,1161 @@ +// 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/basewidget/fwl_datetimepickerimp.h" + +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/fwl/basewidget/fwl_formproxyimp.h" +#include "xfa/fwl/basewidget/fwl_monthcalendarimp.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/include/fwl/basewidget/fwl_spinbutton.h" + +#define FWL_DTP_WIDTH 100 +#define FWL_DTP_HEIGHT 20 + +// static +IFWL_DateTimePicker* IFWL_DateTimePicker::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_DateTimePicker* pDateTimePicker = new IFWL_DateTimePicker; + CFWL_DateTimePickerImp* pDateTimePickerImpl = + new CFWL_DateTimePickerImp(properties, pOuter); + pDateTimePicker->SetImpl(pDateTimePickerImpl); + pDateTimePickerImpl->SetInterface(pDateTimePicker); + return pDateTimePicker; +} + +// Static +IFWL_DateTimeForm* IFWL_DateTimeForm::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_DateTimeForm* pDateTimeForm = new IFWL_DateTimeForm; + CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter); + pDateTimeForm->SetImpl(pFormProxyImpl); + pFormProxyImpl->SetInterface(pDateTimeForm); + return pDateTimeForm; +} + +// static +IFWL_DateTimeCalender* IFWL_DateTimeCalender::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_DateTimeCalender* pDateTimeCalendar = new IFWL_DateTimeCalender; + CFWL_DateTimeCalendar* pDateTimeCalendarImpl = + new CFWL_DateTimeCalendar(properties, pOuter); + pDateTimeCalendar->SetImpl(pDateTimeCalendarImpl); + pDateTimeCalendarImpl->SetInterface(pDateTimeCalendar); + return pDateTimeCalendar; +} + +// static +IFWL_DateTimeEdit* IFWL_DateTimeEdit::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_DateTimeEdit* pDateTimeEdit = new IFWL_DateTimeEdit; + CFWL_DateTimeEdit* pDateTimeEditImpl = + new CFWL_DateTimeEdit(properties, pOuter); + pDateTimeEdit->SetImpl(pDateTimeEditImpl); + pDateTimeEditImpl->SetInterface(pDateTimeEdit); + return pDateTimeEdit; +} + +IFWL_DateTimePicker::IFWL_DateTimePicker() {} +int32_t IFWL_DateTimePicker::CountSelRanges() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) + ->GetDataTimeEdit() + ->CountSelRanges(); +} +int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) + ->GetDataTimeEdit() + ->GetSelRange(nIndex, nStart); +} +FWL_ERR 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) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) + ->SetCurSel(iYear, iMonth, iDay); +} +FWL_ERR 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 { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) + ->GetEditText(wsText, nStart, nCount); +} +FX_BOOL IFWL_DateTimePicker::CanUndo() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanUndo(); +} +FX_BOOL IFWL_DateTimePicker::CanRedo() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanRedo(); +} +FX_BOOL IFWL_DateTimePicker::Undo() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Undo(); +} +FX_BOOL IFWL_DateTimePicker::Redo() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Redo(); +} +FX_BOOL IFWL_DateTimePicker::CanCopy() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCopy(); +} +FX_BOOL IFWL_DateTimePicker::CanCut() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCut(); +} +FX_BOOL IFWL_DateTimePicker::CanSelectAll() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanSelectAll(); +} +FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Copy(wsCopy); +} +FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Cut(wsCut); +} +FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Paste(wsPaste); +} +FX_BOOL IFWL_DateTimePicker::SelectAll() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SelectAll(); +} +FX_BOOL IFWL_DateTimePicker::Delete() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Delete(); +} +FX_BOOL IFWL_DateTimePicker::DeSelect() { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect(); +} +FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect); +} +FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { + return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit); +} +FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD 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() { + m_pDelegate = new CFWL_DateTimeEditImpDelegate(this); + if (CFWL_EditImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + return FWL_ERR_Succeeded; +} +FWL_ERR 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) { + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + return DisForm_OnProcessMessage(pMessage); + } + FX_DWORD dwHashCode = pMessage->GetClassID(); + if (dwHashCode == FWL_MSGHASH_SetFocus || + dwHashCode == FWL_MSGHASH_KillFocus) { + IFWL_Widget* pOuter = m_pOwner->GetOuter(); + IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMessage); + } + return 1; +} +int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( + CFWL_Message* pMessage) { + FX_DWORD dwHashCode = pMessage->GetClassID(); + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + if (dwHashCode == FWL_MSGHASH_Mouse) { + CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); + if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || + pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + } + CFWL_DateTimePickerImp* pDateTime = + static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); + if (pDateTime->IsMonthCalendarShowed()) { + CFX_RectF rtInvalidate; + pDateTime->GetWidgetRect(rtInvalidate); + pDateTime->ShowMonthCalendar(FALSE); + rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); + pDateTime->Repaint(&rtInvalidate); + } + } + } else if (dwHashCode == FWL_MSGHASH_Key) { + return CFWL_EditImpDelegate::OnProcessMessage(pMessage); + } + } + return 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; + delete m_pDelegate; + m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR 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( + CFWL_Message* pMessage) { + FX_DWORD dwCode = pMessage->GetClassID(); + if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) { + IFWL_Widget* pOuter = m_pOwner->GetOuter(); + IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); + return pDelegate->OnProcessMessage(pMessage); + } else if (dwCode == FWL_MSGHASH_Mouse) { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { + OnLButtonDownEx(pMsg); + return 1; + } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { + OnLButtonUpEx(pMsg); + return 1; + } + } + return 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->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->NextMonth(); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { + if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == + 0) { + m_pOwner->JumpToToday(); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + } else { + IFWL_DateTimePicker* pIPicker = + static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); + CFWL_DateTimePickerImp* pPicker = + static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); + if (pPicker->IsMonthCalendarShowed()) { + m_bFlag = 1; + } + } +} +void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + return DisForm_OnLButtonUpEx(pMsg); + } + if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iLBtnPartStates = 0; + m_pOwner->Repaint(&m_pOwner->m_rtLBtn); + return; + } + if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iRBtnPartStates = 0; + m_pOwner->Repaint(&m_pOwner->m_rtRBtn); + return; + } + if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { + return; + } + int32_t iOldSel = 0; + if (m_pOwner->m_arrSelDays.GetSize() > 0) { + iOldSel = m_pOwner->m_arrSelDays[0]; + } + int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + CFX_RectF rt; + IFWL_DateTimePicker* pIPicker = + static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); + CFWL_DateTimePickerImp* pPicker = + static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); + 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); + CFX_RectF rtInvalidate(lpDatesInfo->rect); + if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { + lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); + rtInvalidate.Union(lpDatesInfo->rect); + } + m_pOwner->AddSelDay(iCurSel); + if (!m_pOwner->m_pOuter) + return; + pPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, + iCurSel); + pPicker->ShowMonthCalendar(FALSE); + } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { + IFWL_DateTimePicker* pIPicker = + static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); + CFWL_DateTimePickerImp* pPicker = + static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); + pPicker->ShowMonthCalendar(FALSE); + } + m_bFlag = 0; +} +void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { + return; + } + FX_BOOL bRepaint = FALSE; + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, 0, 0); + if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { + int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + bRepaint = m_pOwner->m_iHovered != iHover; + if (bRepaint) { + if (m_pOwner->m_iHovered > 0) { + m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); + } + if (iHover > 0) { + CFX_RectF rtDay; + m_pOwner->GetDayRect(iHover, rtDay); + if (rtInvalidate.IsEmpty()) { + rtInvalidate = rtDay; + } else { + rtInvalidate.Union(rtDay); + } + } + } + m_pOwner->m_iHovered = iHover; + CFWL_Event_DtpHoverChanged ev; + ev.hoverday = iHover; + m_pOwner->DispatchEvent(&ev); + } else { + bRepaint = m_pOwner->m_iHovered > 0; + if (bRepaint) { + m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); + } + m_pOwner->m_iHovered = -1; + } + if (bRepaint && !rtInvalidate.IsEmpty()) { + m_pOwner->Repaint(&rtInvalidate); + } +} +int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( + CFWL_Message* pMessage) { + if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { + DisForm_OnLButtonUpEx(pMsg); + return 1; + } + } + return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); +} +void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( + CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iLBtnPartStates = 0; + m_pOwner->Repaint(&(m_pOwner->m_rtLBtn)); + return; + } + if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iRBtnPartStates = 0; + m_pOwner->Repaint(&(m_pOwner->m_rtRBtn)); + return; + } + if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { + return; + } + int32_t iOldSel = 0; + if (m_pOwner->m_arrSelDays.GetSize() > 0) { + iOldSel = m_pOwner->m_arrSelDays[0]; + } + 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); + CFX_RectF rtInvalidate(lpDatesInfo->rect); + if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { + lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); + rtInvalidate.Union(lpDatesInfo->rect); + } + m_pOwner->AddSelDay(iCurSel); + CFWL_DateTimePickerImp* pDateTime = + static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); + pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, + iCurSel); + pDateTime->ShowMonthCalendar(FALSE); + } +} +CFWL_DateTimePickerImp::CFWL_DateTimePickerImp( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_iBtnState(1), + m_iYear(-1), + m_iMonth(-1), + m_iDay(-1), + m_bLBtnDown(FALSE), + m_pEdit(nullptr), + m_pMonthCal(nullptr), + m_pForm(nullptr) { + m_rtBtn.Set(0, 0, 0, 0); +} +CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {} +FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_DateTimePicker; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_DateTimePickerImp::GetClassID() const { + return FWL_CLASSHASH_DateTimePicker; +} +FWL_ERR CFWL_DateTimePickerImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); + m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; + CFWL_WidgetImpProperties propMonth; + propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; + propMonth.m_dwStates = FWL_WGTSTATE_Invisible; + propMonth.m_pDataProvider = &m_MonthCalendarDP; + propMonth.m_pParent = m_pInterface; + propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); + m_pMonthCal->Initialize(); + CFX_RectF rtMonthCal; + m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); + rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); + m_pMonthCal->SetWidgetRect(rtMonthCal); + CFWL_WidgetImpProperties propEdit; + propEdit.m_pParent = m_pInterface; + propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); + m_pEdit->Initialize(); + RegisterEventTarget(m_pMonthCal.get()); + RegisterEventTarget(m_pEdit.get()); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::Finalize() { + if (m_pEdit) { + m_pEdit->Finalize(); + } + if (m_pMonthCal) { + m_pMonthCal->Finalize(); + } + if (m_pForm) { + m_pForm->Finalize(); + } + UnregisterEventTarget(); + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR 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); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::Update() { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_Update(); + } + if (m_iLock) { + return FWL_ERR_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)); + if (!pFWidth) + return FWL_ERR_Indefinite; + FX_FLOAT fBtn = *pFWidth; + m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, + m_rtClient.height - 1); + CFX_RectF rtEdit; + rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, + m_rtClient.height); + m_pEdit->SetWidgetRect(rtEdit); + ReSetEditAlignment(); + m_pEdit->Update(); + 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); + } + CFX_RectF rtMonthCal; + m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); + CFX_RectF rtPopUp; + rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, + rtMonthCal.width, rtMonthCal.height); + m_pMonthCal->SetWidgetRect(rtPopUp); + m_pMonthCal->Update(); + return FWL_ERR_Succeeded; +} +FX_DWORD 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 (IsMonthCalendarShowed()) { + CFX_RectF rect; + m_pMonthCal->GetWidgetRect(rect); + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + } + return FWL_WGTHITTEST_Unknown; +} +FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix); + } + if (!m_rtBtn.IsEmpty()) { + DrawDropDownButton(pGraphics, pTheme, pMatrix); + } + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_DrawWidget(pGraphics, pMatrix); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) { + m_pProperties->m_pThemeProvider = pTP; + m_pMonthCal->SetThemeProvider(pTP); + return FWL_ERR_Succeeded; +} +FWL_ERR 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; +} +FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + if (iYear <= 0 || iYear >= 3000) + return FWL_ERR_Indefinite; + if (iMonth <= 0 || iMonth >= 13) + return FWL_ERR_Indefinite; + if (iDay <= 0 || iDay >= 32) + return FWL_ERR_Indefinite; + m_iYear = iYear; + m_iMonth = iMonth; + m_iDay = iDay; + m_pMonthCal->SetSelect(iYear, iMonth, iDay); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) { + if (!m_pEdit) + return FWL_ERR_Indefinite; + int32_t 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 { + if (m_pEdit) { + return m_pEdit->GetText(wsText, nStart, nCount); + } + return FWL_ERR_Indefinite; +} +FX_BOOL CFWL_DateTimePickerImp::CanUndo() { + return m_pEdit->CanUndo(); +} +FX_BOOL CFWL_DateTimePickerImp::CanRedo() { + return m_pEdit->CanRedo(); +} +FX_BOOL CFWL_DateTimePickerImp::Undo() { + return m_pEdit->Undo(); +} +FX_BOOL CFWL_DateTimePickerImp::Redo() { + return m_pEdit->Redo(); +} +FX_BOOL CFWL_DateTimePickerImp::CanCopy() { + int32_t nCount = m_pEdit->CountSelRanges(); + return nCount > 0; +} +FX_BOOL CFWL_DateTimePickerImp::CanCut() { + if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { + return FALSE; + } + int32_t nCount = m_pEdit->CountSelRanges(); + return nCount > 0; +} +FX_BOOL CFWL_DateTimePickerImp::CanSelectAll() { + return m_pEdit->GetTextLength() > 0; +} +FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) { + return m_pEdit->Copy(wsCopy); +} +FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) { + return m_pEdit->Cut(wsCut); +} +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; +} +FX_BOOL CFWL_DateTimePickerImp::Delete() { + return m_pEdit->ClearText() == FWL_ERR_Succeeded; +} +FX_BOOL CFWL_DateTimePickerImp::DeSelect() { + return m_pEdit->ClearSelections() == FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_GetBBox(rect); + } + rect = m_pProperties->m_rtWidget; + if (IsMonthCalendarShowed()) { + CFX_RectF rtMonth; + m_pMonthCal->GetWidgetRect(rtMonth); + rtMonth.Offset(m_pProperties->m_rtWidget.left, + m_pProperties->m_rtWidget.top); + rect.Union(rtMonth); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) { + return m_pEdit->SetLimit(nLimit); +} +FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} +void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == + FWL_STYLEEXT_DTP_Spin) { + CFWL_WidgetImpProperties prop; + prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; + prop.m_pParent = m_pInterface; + prop.m_rtWidget = m_rtBtn; + IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(prop, m_pInterface); + pSpin->Initialize(); + } else { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_DTP_DropDownButton; + param.m_dwStates = m_iBtnState; + param.m_pGraphics = pGraphics; + param.m_rtPart = m_rtBtn; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶m); + } +} +void CFWL_DateTimePickerImp::FormatDateString(int32_t iYear, + int32_t iMonth, + int32_t iDay, + CFX_WideString& wsText) { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == + FWL_STYLEEXT_DTP_ShortDateFormat) { + wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay); + } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == + FWL_STYLEEXT_DTP_LongDateFormat) { + wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); + } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) == + FWL_STYLEEXT_DTP_TimeFormat) { + } +} +void CFWL_DateTimePickerImp::ShowMonthCalendar(FX_BOOL bActivate) { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_ShowMonthCalendar(bActivate); + } + if (IsMonthCalendarShowed() == bActivate) { + return; + } + if (!m_pForm) { + InitProxyForm(); + } + if (bActivate) { + CFX_RectF rtMonth; + m_pMonthCal->GetWidgetRect(rtMonth); + CFX_RectF rtAnchor; + rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); + GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); + m_pForm->SetWidgetRect(rtMonth); + rtMonth.left = rtMonth.top = 0; + m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); + m_pMonthCal->SetWidgetRect(rtMonth); + m_pMonthCal->Update(); + m_pForm->DoModal(); + } else { + m_pForm->EndDoModal(); + } +} +FX_BOOL CFWL_DateTimePickerImp::IsMonthCalendarShowed() { + if (m_pWidgetMgr->IsFormDisabled()) { + return DisForm_IsMonthCalendarShowed(); + } + if (!m_pForm) + return FALSE; + return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); +} +void CFWL_DateTimePickerImp::ReSetEditAlignment() { + if (!m_pEdit) + return; + FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; + FX_DWORD dwAdd = 0; + switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) { + case FWL_STYLEEXT_DTP_EditHCenter: { + dwAdd |= FWL_STYLEEXT_EDT_HCenter; + break; + } + case FWL_STYLEEXT_DTP_EditHFar: { + dwAdd |= FWL_STYLEEXT_EDT_HFar; + break; + } + default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; } + } + switch (dwStylExes & FWL_STYLEEXT_DTP_EditVAlignMask) { + case FWL_STYLEEXT_DTP_EditVCenter: { + dwAdd |= FWL_STYLEEXT_EDT_VCenter; + break; + } + case FWL_STYLEEXT_DTP_EditVFar: { + dwAdd |= FWL_STYLEEXT_EDT_VFar; + break; + } + default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; } + } + if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) { + dwAdd |= FWL_STYLEEXT_EDT_Justified; + } + if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) { + dwAdd |= FWL_STYLEEXT_EDT_Distributed; + } + m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | + FWL_STYLEEXT_EDT_HAlignModeMask | + FWL_STYLEEXT_EDT_VAlignMask); +} +void CFWL_DateTimePickerImp::ProcessSelChanged(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + m_iYear = iYear; + m_iMonth = iMonth; + m_iDay = iDay; + CFX_WideString wsText; + FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); + m_pEdit->SetText(wsText); + m_pEdit->Update(); + Repaint(&m_rtClient); + CFWL_Event_DtpSelectChanged ev; + ev.m_pSrcTarget = m_pInterface; + ev.iYear = m_iYear; + ev.iMonth = m_iMonth; + ev.iDay = m_iDay; + DispatchEvent(&ev); +} +void CFWL_DateTimePickerImp::InitProxyForm() { + if (m_pForm) + return; + if (!m_pMonthCal) + return; + CFWL_WidgetImpProperties propForm; + propForm.m_dwStyles = FWL_WGTSTYLE_Popup; + propForm.m_dwStates = FWL_WGTSTATE_Invisible; + propForm.m_pOwner = m_pInterface; + m_pForm.reset(IFWL_DateTimeForm::Create(propForm, m_pMonthCal.get())); + m_pForm->Initialize(); + m_pMonthCal->SetParent(m_pForm.get()); +} +IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { + return m_pEdit.get(); +} +FWL_ERR 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; +} +void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { + if (m_pMonthCal) { + return; + } + CFWL_WidgetImpProperties propMonth; + propMonth.m_dwStyles = + FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; + propMonth.m_dwStates = FWL_WGTSTATE_Invisible; + propMonth.m_pParent = m_pInterface; + propMonth.m_pDataProvider = &m_MonthCalendarDP; + propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); + m_pMonthCal->Initialize(); + CFX_RectF rtMonthCal; + m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); + rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); + m_pMonthCal->SetWidgetRect(rtMonthCal); +} +void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit() { + if (m_pEdit) { + return; + } + CFWL_WidgetImpProperties propEdit; + propEdit.m_pParent = m_pInterface; + propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); + m_pEdit->Initialize(); +} +FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed() { + if (!m_pMonthCal) + return FALSE; + return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); +} +void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { + FX_BOOL bShowed = IsMonthCalendarShowed(); + if (bShowed == bActivate) { + return; + } + if (bActivate) { + CFX_RectF rtMonthCal; + m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); + FX_FLOAT fPopupMin = rtMonthCal.height; + FX_FLOAT fPopupMax = rtMonthCal.height; + CFX_RectF rtAnchor(m_pProperties->m_rtWidget); + rtAnchor.width = rtMonthCal.width; + rtMonthCal.left = m_rtClient.left; + rtMonthCal.top = rtAnchor.Height(); + GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); + m_pMonthCal->SetWidgetRect(rtMonthCal); + if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) { + m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); + } + m_pMonthCal->Update(); + } + m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); + if (bActivate) { + CFWL_MsgSetFocus msg; + msg.m_pDstTarget = m_pMonthCal.get(); + msg.m_pSrcTarget = m_pEdit.get(); + IFWL_WidgetDelegate* pDelegate = m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(&msg); + } + CFX_RectF rtInvalidate, rtCal; + rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); + m_pMonthCal->GetWidgetRect(rtCal); + rtInvalidate.Union(rtCal); + rtInvalidate.Inflate(2, 2); + Repaint(&rtInvalidate); +} +FX_DWORD 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()) { + rect.width += m_fBtn; + } + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + if (IsMonthCalendarShowed()) { + m_pMonthCal->GetWidgetRect(rect); + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + } + return FWL_WGTHITTEST_Unknown; +} +FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() { + FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || + m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || + 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) { + 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) { + 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)); + if (!pWidth) + return 0; + m_fBtn = *pWidth; + CFX_RectF rtMonthCal; + m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); + CFX_RectF rtPopUp; + rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, + rtMonthCal.width, rtMonthCal.height); + m_pMonthCal->SetWidgetRect(rtPopUp); + m_pMonthCal->Update(); + return FWL_ERR_Succeeded; +} +FWL_ERR 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; +} +FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) { + rect = m_pProperties->m_rtWidget; + if (DisForm_IsNeedShowButton()) { + rect.width += m_fBtn; + } + if (IsMonthCalendarShowed()) { + CFX_RectF rtMonth; + m_pMonthCal->GetWidgetRect(rtMonth); + rtMonth.Offset(m_pProperties->m_rtWidget.left, + m_pProperties->m_rtWidget.top); + rect.Union(rtMonth); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (m_pEdit) { + CFX_RectF rtEdit; + m_pEdit->GetWidgetRect(rtEdit); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); + if (pMatrix) { + mt.Concat(*pMatrix); + } + m_pEdit->DrawWidget(pGraphics, &mt); + } + if (IsMonthCalendarShowed()) { + CFX_RectF rtMonth; + m_pMonthCal->GetWidgetRect(rtMonth); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); + if (pMatrix) { + mt.Concat(*pMatrix); + } + m_pMonthCal->DrawWidget(pGraphics, &mt); + } + return FWL_ERR_Succeeded; +} +CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( + CFWL_DateTimePickerImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( + CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMouse->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMouse); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMouse); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMouse); + break; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMouse); + break; + } + default: {} + } + 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); +} +FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget( + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOwner->DrawWidget(pGraphics, pMatrix); +} +void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (!pMsg) + return; + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + return DisForm_OnFocusChanged(pMsg, bSet); + } + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } else { + m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() && + m_pOwner->IsMonthCalendarShowed()) { + m_pOwner->ShowMonthCalendar(FALSE); + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + if (!pMsg) + return; + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->SetFocus(TRUE); + } + if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_pOwner->IsMonthCalendarShowed()) { + m_pOwner->ShowMonthCalendar(FALSE); + CFWL_Event_DtpCloseUp ev; + m_pOwner->DispatchEvent(&ev); + } else { + if (!(m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_DTP_TimeFormat)) { + m_pOwner->ShowMonthCalendar(TRUE); + CFWL_Event_DtpDropDown ev; + m_pOwner->DispatchEvent(&ev); + } else { + } + m_pOwner->m_bLBtnDown = TRUE; + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + } +} +void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + if (!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; + } else { + m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_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->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->Repaint(&m_pOwner->m_rtBtn); +} +void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + CFX_RectF rtInvalidate(m_pOwner->m_rtBtn); + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + if (m_pOwner->m_pEdit && + !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { + m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0, + m_pOwner->m_fBtn, + m_pOwner->m_pProperties->m_rtWidget.height - 1); + } + rtInvalidate = m_pOwner->m_rtBtn; + pMsg->m_pDstTarget = m_pOwner->m_pEdit.get(); + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMsg); + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_pOwner->m_rtBtn.Set(0, 0, 0, 0); + if (m_pOwner->DisForm_IsMonthCalendarShowed()) { + m_pOwner->ShowMonthCalendar(FALSE); + } + if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { + pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMsg); + } + } + rtInvalidate.Inflate(2, 2); + m_pOwner->Repaint(&rtInvalidate); +} diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.h b/xfa/fwl/basewidget/fwl_datetimepickerimp.h new file mode 100644 index 0000000000..4c0ebc5cc5 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.h @@ -0,0 +1,235 @@ +// 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_FWL_DATETIMEPICKERIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ + +#include <memory> + +#include "xfa/fwl/basewidget/fwl_editimp.h" +#include "xfa/fwl/basewidget/fwl_monthcalendarimp.h" +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" +#include "xfa/include/fwl/core/fwl_form.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +class CFWL_WidgetImp; +class CFWL_WidgetImpProperties; +class CFWL_WidgetImpDelegate; +class CFWL_DateTimeEdit; +class CFWL_DateTimeEditImpDelegate; +class CFWL_DateTimeCalendar; +class CFWL_DateTimeCalendarImpDelegate; +class CFWL_DateTimePickerImp; +class CFWL_DateTimePickerImpDelegate; + +class IFWL_DateTimeForm : public IFWL_Form { + public: + static IFWL_DateTimeForm* Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + + protected: + IFWL_DateTimeForm() {} +}; + +class IFWL_DateTimeCalender : public IFWL_MonthCalendar { + public: + static IFWL_DateTimeCalender* Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + + protected: + IFWL_DateTimeCalender() {} +}; + +class IFWL_DateTimeEdit : public IFWL_Edit { + public: + static IFWL_DateTimeEdit* Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + + protected: + IFWL_DateTimeEdit() {} +}; + +class CFWL_DateTimeEdit : public CFWL_EditImp { + public: + CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + friend class CFWL_DateTimeEditImpDelegate; +}; +class CFWL_DateTimeEditImpDelegate : public CFWL_EditImpDelegate { + public: + CFWL_DateTimeEditImpDelegate(CFWL_DateTimeEdit* pOwner); + int32_t OnProcessMessage(CFWL_Message* pMessage) override; + + private: + int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage); + + protected: + CFWL_DateTimeEdit* m_pOwner; +}; +class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp { + public: + CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + friend class CFWL_DateTimeCalendarImpDelegate; +}; +class CFWL_DateTimeCalendarImpDelegate : public CFWL_MonthCalendarImpDelegate { + public: + CFWL_DateTimeCalendarImpDelegate(CFWL_DateTimeCalendar* pOwner); + int32_t 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_OnLButtonUpEx(CFWL_MsgMouse* pMsg); + + protected: + CFWL_DateTimeCalendar* m_pOwner; + FX_BOOL m_bFlag; +}; +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 FX_DWORD 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 FX_DWORD 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; + + 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(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved); + + public: + IFWL_DateTimeEdit* GetDataTimeEdit(); + + protected: + void DrawDropDownButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void FormatDateString(int32_t iYear, + int32_t iMonth, + int32_t iDay, + CFX_WideString& wsText); + void ShowMonthCalendar(FX_BOOL bActivate); + FX_BOOL IsMonthCalendarShowed(); + void ReSetEditAlignment(); + void InitProxyForm(); + void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); + + private: + FWL_ERR DisForm_Initialize(); + void DisForm_InitDateTimeCalendar(); + void DisForm_InitDateTimeEdit(); + FX_BOOL DisForm_IsMonthCalendarShowed(); + void DisForm_ShowMonthCalendar(FX_BOOL bActivate); + FX_DWORD 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); + + protected: + CFX_RectF m_rtBtn; + CFX_RectF m_rtClient; + int32_t m_iBtnState; + int32_t m_iYear; + int32_t m_iMonth; + int32_t m_iDay; + FX_BOOL m_bLBtnDown; + std::unique_ptr<IFWL_DateTimeEdit> m_pEdit; + std::unique_ptr<IFWL_DateTimeCalender> m_pMonthCal; + std::unique_ptr<IFWL_DateTimeForm> m_pForm; + FX_FLOAT m_fBtn; + class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP { + public: + CFWL_MonthCalendarImpDP() { + m_iCurYear = 2010; + m_iCurMonth = 3; + m_iCurDay = 29; + } + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + return FWL_ERR_Succeeded; + } + virtual int32_t GetCurDay(IFWL_Widget* pWidget) { return m_iCurDay; } + virtual int32_t GetCurMonth(IFWL_Widget* pWidget) { return m_iCurMonth; } + virtual int32_t GetCurYear(IFWL_Widget* pWidget) { return m_iCurYear; } + int32_t m_iCurDay; + int32_t m_iCurYear; + int32_t m_iCurMonth; + }; + + CFWL_MonthCalendarImpDP m_MonthCalendarDP; + friend class CFWL_DateTimeEditImpDelegate; + friend class CFWL_DateTimeCalendar; + friend class CFWL_DateTimeCalendarImpDelegate; + friend class CFWL_DateTimePickerImpDelegate; +}; +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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + + CFWL_DateTimePickerImp* m_pOwner; + + private: + void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp new file mode 100644 index 0000000000..6975f50787 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -0,0 +1,2152 @@ +// 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/basewidget/fwl_editimp.h" + +#include <algorithm> +#include <vector> + +#include "xfa/fde/fde_render.h" +#include "xfa/fde/fde_renderdevice.h" +#include "xfa/fee/ifde_txtedtpage.h" +#include "xfa/fwl/basewidget/fwl_caretimp.h" +#include "xfa/fwl/basewidget/fwl_comboboximp.h" +#include "xfa/fwl/basewidget/fwl_scrollbarimp.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/include/fwl/basewidget/fwl_caret.h" +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +// static +IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_Edit* pEdit = new IFWL_Edit; + CFWL_EditImp* pEditImpl = new CFWL_EditImp(properties, pOuter); + pEdit->SetImpl(pEditImpl); + pEditImpl->SetInterface(pEdit); + return pEdit; +} +// static +IFWL_Edit* IFWL_Edit::CreateComboEdit( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_Edit* pEdit = new IFWL_Edit; + CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); + pEdit->SetImpl(pComboEditImpl); + pComboEditImpl->SetInterface(pEdit); + return pEdit; +} +IFWL_Edit::IFWL_Edit() {} +FWL_ERR 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 { + return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); +} +FWL_ERR IFWL_Edit::ClearText() { + return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); +} +int32_t IFWL_Edit::GetCaretPos() const { + return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); +} +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) { + return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); +} +int32_t IFWL_Edit::CountSelRanges() { + return static_cast<CFWL_EditImp*>(GetImpl())->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() { + 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) { + return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); +} +FWL_ERR 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) { + return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); +} +FWL_ERR IFWL_Edit::DeleteSelections() { + return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); +} +FWL_ERR 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) { + return static_cast<CFWL_EditImp*>(GetImpl()) + ->Replace(nStart, nLen, wsReplace); +} +FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) { + return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); +} +FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { + return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); +} +FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { + return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); +} +FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { + return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); +} +FX_BOOL IFWL_Edit::Delete() { + return static_cast<CFWL_EditImp*>(GetImpl())->Delete(); +} +FX_BOOL IFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { + return static_cast<CFWL_EditImp*>(GetImpl())->Redo(bsRecord); +} +FX_BOOL IFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { + return static_cast<CFWL_EditImp*>(GetImpl())->Undo(bsRecord); +} +FX_BOOL IFWL_Edit::Undo() { + return static_cast<CFWL_EditImp*>(GetImpl())->Undo(); +} +FX_BOOL IFWL_Edit::Redo() { + return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); +} +FX_BOOL IFWL_Edit::CanUndo() { + return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); +} +FX_BOOL IFWL_Edit::CanRedo() { + return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); +} +FWL_ERR 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) { + return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); +} +FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { + return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); +} +FWL_ERR IFWL_Edit::SetBackColor(FX_DWORD dwColor) { + return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); +} +FWL_ERR 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) { + return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); +} +FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) { + return static_cast<CFWL_EditImp*>(GetImpl()) + ->GetSuggestWords(pointf, sSuggest); +} +FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + 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), + m_fVAlignOffset(0.0f), + m_fScrollOffsetX(0.0f), + m_fScrollOffsetY(0.0f), + m_pEdtEngine(NULL), + m_bLButtonDown(FALSE), + m_nSelStart(0), + m_nLimit(-1), + m_fSpaceAbove(0), + m_fSpaceBelow(0), + m_fFontSize(0), + m_bSetRange(FALSE), + m_iMin(-1), + m_iMax(0xFFFFFFF), + m_backColor(0), + m_updateBackColor(FALSE), + m_iCurRecord(-1), + m_iMaxRecord(128) { + m_rtClient.Reset(); + m_rtEngine.Reset(); + m_rtStatic.Reset(); +} +CFWL_EditImp::~CFWL_EditImp() { + if (m_pEdtEngine) { + m_pEdtEngine->Release(); + m_pEdtEngine = NULL; + } + ClearRecord(); +} +FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_Edit; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_EditImp::GetClassID() const { + return FWL_CLASSHASH_Edit; +} +FWL_ERR CFWL_EditImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + if (!m_pDelegate) { + m_pDelegate = new CFWL_EditImpDelegate(this); + } + InitCaret(); + if (!m_pEdtEngine) { + InitEngine(); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::Finalize() { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + ShowCaret(FALSE); + } + if (m_pHorzScrollBar) { + m_pHorzScrollBar->Finalize(); + } + if (m_pVertScrollBar) { + m_pVertScrollBar->Finalize(); + } + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + rect.Set(0, 0, 0, 0); + if (m_pEdtEngine) { + int32_t iTextLen = m_pEdtEngine->GetTextLength(); + if (iTextLen > 0) { + CFX_WideString wsText; + m_pEdtEngine->GetText(wsText, 0); + CFX_SizeF sz = CalcTextSize( + wsText, m_pProperties->m_pThemeProvider, + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); + rect.Set(0, 0, sz.x, sz.y); + } + } + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (IsShowScrollBar(TRUE)) { + FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + rect.width += *pfWidth; + rect.width += FWL_EDIT_Margin; + } + if (IsShowScrollBar(FALSE)) { + FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + rect.height += *pfWidth; + rect.height += FWL_EDIT_Margin; + } + } + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetStates(FX_DWORD 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); +} +FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { + return CFWL_WidgetImp::SetWidgetRect(rect); +} +FWL_ERR CFWL_EditImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + Layout(); + if (m_rtClient.IsEmpty()) { + return FWL_ERR_Indefinite; + } + UpdateEditEngine(); + UpdateVAlignment(); + UpdateScroll(); + InitCaret(); + return FWL_ERR_Succeeded; +} +FX_DWORD 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 (IsShowScrollBar(FALSE)) { + CFX_RectF rect; + m_pHorzScrollBar->GetWidgetRect(rect); + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_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); + } +} +void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData, + int32_t nStart, + int32_t nCount, + FX_FLOAT fOffSetX, + FX_FLOAT fOffSetY) { + FX_FLOAT fStartX = 0.0f; + FX_FLOAT fEndX = 0.0f; + FX_FLOAT fY = 0.0f; + FX_FLOAT fStep = 0.0f; + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + CFX_RectFArray rectArray; + CFX_RectF rectText; + const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); + FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * + txtEdtParams->fFontSize / 1000; + pPage->CalcRangeRectArray(nStart, nCount, rectArray); + for (int i = 0; i < rectArray.GetSize(); i++) { + rectText = rectArray.GetAt(i); + fY = rectText.top + fAsent + fOffSetY; + fStep = txtEdtParams->fFontSize / 16.0f; + fStartX = rectText.left + fOffSetX; + fEndX = fStartX + rectText.Width(); + AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); + } +} +int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { + return 0; +} +FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) { + int32_t nWordCount = 0; + int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); + if (nWordCount < 1) { + return FALSE; + } + CFX_WideString wsSpell; + GetText(wsSpell, nWordStart, nWordCount); + CFX_ByteString sLatinWord; + for (int i = 0; i < nWordCount; i++) { + if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { + break; + } + sLatinWord += (FX_CHAR)wsSpell[i]; + } + if (sLatinWord.IsEmpty()) { + return FALSE; + } + CFWL_EvtEdtCheckWord checkWordEvent; + checkWordEvent.m_pSrcTarget = m_pInterface; + checkWordEvent.bsWord = sLatinWord; + checkWordEvent.bCheckWord = TRUE; + DispatchEvent(&checkWordEvent); + if (checkWordEvent.bCheckWord) { + return FALSE; + } + CFWL_EvtEdtGetSuggestWords suggestWordsEvent; + suggestWordsEvent.m_pSrcTarget = m_pInterface; + suggestWordsEvent.bsWord = sLatinWord; + suggestWordsEvent.bsArraySuggestWords = sSuggest; + suggestWordsEvent.bSuggestWords = FALSE; + DispatchEvent(&checkWordEvent); + return suggestWordsEvent.bSuggestWords; +} +FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + int32_t nWordCount = 0; + int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); + if (nWordCount < 1) { + return FALSE; + } + CFX_WideString wsSpell; + GetText(wsSpell, nWordStart, nWordCount); + for (int i = 0; i < nWordCount; i++) { + if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { + nWordCount = i; + break; + } + } + int32_t nDestLen = bsReplace.GetLength(); + CFX_WideString wsDest; + FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); + for (int32_t i = 0; i < nDestLen; i++) { + pBuffer[i] = bsReplace[i]; + } + wsDest.ReleaseBuffer(nDestLen); + Replace(nWordStart, nWordCount, wsDest); + return TRUE; +} +void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + pGraphics->SaveGraphState(); + if (pMatrix) { + pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); + } + FX_ARGB cr = 0xFFFF0000; + CFX_Color crLine(cr); + CFWL_EvtEdtCheckWord checkWordEvent; + checkWordEvent.m_pSrcTarget = m_pInterface; + CFX_ByteString sLatinWord; + CFX_Path pathSpell; + pathSpell.Create(); + int32_t nStart = 0; + FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; + FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; + CFX_WideString wsSpell; + GetText(wsSpell); + int32_t nContentLen = wsSpell.GetLength(); + for (int i = 0; i < nContentLen; i++) { + if (FX_EDIT_ISLATINWORD(wsSpell[i])) { + if (sLatinWord.IsEmpty()) { + nStart = i; + } + sLatinWord += (FX_CHAR)wsSpell[i]; + } else { + checkWordEvent.bsWord = sLatinWord; + checkWordEvent.bCheckWord = TRUE; + DispatchEvent(&checkWordEvent); + if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { + AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, + fOffSetY); + } + sLatinWord.Empty(); + } + } + checkWordEvent.bsWord = sLatinWord; + checkWordEvent.bCheckWord = TRUE; + DispatchEvent(&checkWordEvent); + if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { + AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, + fOffSetY); + } + if (!pathSpell.IsEmpty()) { + CFX_RectF rtClip = m_rtEngine; + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + pGraphics->SetClipRect(rtClip); + pGraphics->SetStrokeColor(&crLine); + pGraphics->SetLineWidth(0); + pGraphics->StrokePath(&pathSpell, NULL); + } + pGraphics->RestoreGraphState(); +} +FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + if (m_rtClient.IsEmpty()) { + return FWL_ERR_Indefinite; + } + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (!m_pWidgetMgr->IsFormDisabled()) { + DrawTextBk(pGraphics, pTheme, pMatrix); + } + if (m_pEdtEngine) { + DrawContent(pGraphics, pTheme, pMatrix); + } + if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && + !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { + DrawSpellCheck(pGraphics, pMatrix); + } + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_EDT_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_EDT_Edge, pTheme, pMatrix); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { + if (!pThemeProvider) + return FWL_ERR_Indefinite; + if (m_pHorzScrollBar) { + m_pHorzScrollBar->SetThemeProvider(pThemeProvider); + } + if (m_pVertScrollBar) { + m_pVertScrollBar->SetThemeProvider(pThemeProvider); + } + if (m_pCaret) { + m_pCaret->SetThemeProvider(pThemeProvider); + } + m_pProperties->m_pThemeProvider = pThemeProvider; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) { + m_pEdtEngine->SetText(wsText); + return FWL_ERR_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 { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + m_pEdtEngine->GetText(wsText, nStart, nCount); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::ClearText() { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + m_pEdtEngine->ClearText(); + return FWL_ERR_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) { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + m_pEdtEngine->AddSelRange(nStart, nCount); + return FWL_ERR_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() { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + m_pEdtEngine->ClearSelection(); + return FWL_ERR_Succeeded; +} +int32_t CFWL_EditImp::GetLimit() { + return m_nLimit; +} +FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) { + m_nLimit = nLimit; + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + m_pEdtEngine->SetLimit(nLimit); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { + if (!m_pEdtEngine) + return FWL_ERR_Indefinite; + m_pEdtEngine->SetAliasChar(wAlias); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::Insert(int32_t nStart, + const FX_WCHAR* lpText, + int32_t nLen) { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { + return FWL_ERR_Indefinite; + } + m_pEdtEngine->Insert(nStart, lpText, nLen); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::DeleteSelections() { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + int32_t iCount = m_pEdtEngine->CountSelRanges(); + if (iCount > 0) { + m_pEdtEngine->Delete(-1); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + 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; +} +FWL_ERR 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; +} +FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { + return FWL_ERR_Succeeded; + } + return FWL_ERR_Indefinite; +} +FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { + if (!m_pEdtEngine) + return FALSE; + int32_t nCount = m_pEdtEngine->CountSelRanges(); + if (nCount == 0) { + return FALSE; + } + wsCopy.Empty(); + 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(); + } + return TRUE; +} +FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { + if (!m_pEdtEngine) + return FALSE; + int32_t nCount = m_pEdtEngine->CountSelRanges(); + if (nCount == 0) { + return FALSE; + } + wsCut.Empty(); + 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(); + } + 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()); + if (iError < 0) { + ProcessInsertError(iError); + return FALSE; + } + return TRUE; +} +FX_BOOL CFWL_EditImp::Delete() { + if (!m_pEdtEngine) + return FALSE; + int32_t nCount = m_pEdtEngine->CountSelRanges(); + 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) { + 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) { + return TRUE; + } + return m_pEdtEngine->Undo(bsRecord); +} +FX_BOOL CFWL_EditImp::Undo() { + if (!CanUndo()) { + return FALSE; + } + CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; + return Undo(bsRecord); +} +FX_BOOL CFWL_EditImp::Redo() { + if (!CanRedo()) { + return FALSE; + } + CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; + return Redo(bsRecord); +} +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) { + if (!m_pEdtEngine) + return FWL_ERR_Succeeded; + FDE_LPTXTEDTPARAMS pParams = + (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams(); + pParams->fTabWidth = fTabWidth; + pParams->bTabEquidistant = bEquidistant; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { + m_pOuter = pOuter; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { + m_iMin = iMin; + m_iMax = iMax; + m_bSetRange = TRUE; + return FWL_ERR_Succeeded; +} +void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit, + int32_t nPage, + FX_BOOL bVisible) { + if (m_rtEngine.IsEmpty()) { + return; + } + if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + return; + } + FX_BOOL bRepaintContent = UpdateOffset(); + UpdateCaret(); + CFX_RectF rtInvalid; + rtInvalid.Set(0, 0, 0, 0); + FX_BOOL bRepaintScroll = FALSE; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { + IFWL_ScrollBar* pScroll = UpdateScroll(); + if (pScroll) { + pScroll->GetWidgetRect(rtInvalid); + bRepaintScroll = TRUE; + } + } + if (bRepaintContent || bRepaintScroll) { + if (bRepaintContent) { + rtInvalid.Union(m_rtEngine); + } + Repaint(&rtInvalid); + } +} +void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, + FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { + FX_DWORD dwStyleEx = m_pProperties->m_dwStyleExes; + 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; + CFX_RectF rtTemp; + GetClientRect(rtTemp); + FX_BOOL bHSelfAdaption = + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; + FX_BOOL bVSelfAdaption = + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; + FX_BOOL bNeedUpdate = FALSE; + if (bHSelfAdaption || bVSelfAdaption) { + CFWL_EvtEdtPreSelfAdaption evt; + evt.m_pSrcTarget = m_pInterface; + evt.bHSelfAdaption = TRUE; + evt.bVSelfAdaption = TRUE; + FX_FLOAT fWidth; + FX_FLOAT fHight; + fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width; + fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height; + evt.rtAfterChange.Set(0, 0, fWidth, fHight); + DispatchEvent(&evt); + if (!evt.bHSelfAdaption) { + ModifyStylesEx( + 0, FWL_STYLEEXT_EDT_HSelfAdaption | FWL_STYLEEXT_EDT_AutoHScroll); + } + if (!evt.bVSelfAdaption) { + ModifyStylesEx( + 0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll); + } + bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || + (bVSelfAdaption && !evt.bVSelfAdaption); + } + FX_FLOAT fContentWidth1 = fContentWidth; + FX_FLOAT fContentHeight1 = fContentHeight; + if (bNeedUpdate) { + UpdateEditParams(); + UpdateEditLayout(); + IFDE_TxtEdtPage* page1 = m_pEdtEngine->GetPage(0); + fContentWidth1 = page1->GetContentsBox().width; + fContentHeight1 = page1->GetContentsBox().height; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { + rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); + m_pProperties->m_rtWidget.width = fContentWidth1; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { + rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); + m_pProperties->m_rtWidget.height = fContentHeight1; + } + CFWL_EvtEdtTextChanged event; + event.m_pSrcTarget = m_pInterface; + event.nChangeType = ChangeInfo.nChangeType; + event.wsInsert = ChangeInfo.wsInsert; + event.wsDelete = ChangeInfo.wsDelete; + event.wsPrevText = ChangeInfo.wsPrevText; + DispatchEvent(&event); + LayoutScrollBar(); + Repaint(&rtTemp); +} +void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) { + CFX_RectF rtTemp; + GetClientRect(rtTemp); + Repaint(&rtTemp); +} +FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit, + int32_t nPageIndex, + int32_t nPurpose) { + IFDE_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, + int32_t nPageIndex, + int32_t nPurpose) { + IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; + IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); + if (!pPage) + return FALSE; + pPage->UnloadPage(nullptr); + return TRUE; +} + +void CFWL_EditImp::On_AddDoRecord(IFDE_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, + CFX_WideString& wsText) { + IFWL_Widget* pDst = GetOuter(); + if (!pDst) { + pDst = m_pInterface; + } + CFWL_EvtEdtValidate event; + event.pDstWidget = pDst; + event.m_pSrcTarget = m_pInterface; + event.wsInsert = wsText; + event.bValidate = TRUE; + DispatchEvent(&event); + return event.bValidate; +} +FWL_ERR CFWL_EditImp::SetBackgroundColor(FX_DWORD color) { + m_backColor = color; + m_updateBackColor = TRUE; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { + m_wsFont = wsFont; + m_fFontSize = fSize; + return FWL_ERR_Succeeded; +} +void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { + m_fScrollOffsetY = fScrollOffset; +} +void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + 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_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly + ? FWL_PARTSTATE_EDT_ReadOnly + : FWL_PARTSTATE_EDT_Normal; + FX_DWORD dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); + if (dwStates) { + param.m_dwStates = FWL_PARTSTATE_EDT_Disable; + } + param.m_pGraphics = pGraphics; + param.m_matrix = *pMatrix; + param.m_rtPart = m_rtClient; + pTheme->DrawBackground(¶m); + if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { + return; + } + CFX_RectF rtScorll; + m_pHorzScrollBar->GetWidgetRect(rtScorll); + CFX_RectF rtStatic; + 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_rtPart = rtStatic; + pTheme->DrawBackground(¶m); +} +void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (!m_pEdtEngine) + return; + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + if (!pPage) + return; + pGraphics->SaveGraphState(); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + pGraphics->SaveGraphState(); + } + CFX_RectF rtClip = m_rtEngine; + FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; + FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + FX_BOOL bShowSel = + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); + if (bShowSel) { + IFWL_Widget* pForm = + m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + if (pForm) { + bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != + FWL_WGTSTATE_Deactivated; + } + } + int32_t nSelCount = m_pEdtEngine->CountSelRanges(); + if (bShowSel && nSelCount > 0) { + int32_t nPageCharStart = pPage->GetCharStart(); + int32_t nPageCharCount = pPage->GetCharCount(); + int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; + int32_t nCharCount; + int32_t nCharStart; + CFX_RectFArray rectArr; + int32_t i = 0; + for (i = 0; i < nSelCount; i++) { + nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart); + int32_t nCharEnd = nCharStart + nCharCount - 1; + if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { + continue; + } + int32_t nBgn = std::max(nCharStart, nPageCharStart); + int32_t nEnd = std::min(nCharEnd, nPageCharEnd); + pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, + rectArr); + } + int32_t nCount = rectArr.GetSize(); + CFX_Path path; + path.Create(); + for (i = 0; i < nCount; i++) { + rectArr[i].left += fOffSetX; + rectArr[i].top += fOffSetY; + path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width, + rectArr[i].height); + } + pGraphics->SetClipRect(rtClip); + CFWL_ThemeBackground param; + param.m_pGraphics = pGraphics; + param.m_matrix = *pMatrix; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_EDT_Background; + param.m_pPath = &path; + pTheme->DrawBackground(¶m); + } + 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; + pRenderDevice->SetClipRect(rtClip); + pRenderContext->StartRender(pRenderDevice, pPage, mt); + pRenderContext->DoRender(NULL); + pRenderContext->Release(); + pRenderDevice->Release(); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + pGraphics->RestoreGraphState(); + CFX_Path path; + path.Create(); + int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1; + FX_FLOAT fStep = m_rtEngine.width / iLimit; + FX_FLOAT fLeft = m_rtEngine.left + 1; + for (int32_t i = 1; i < iLimit; i++) { + fLeft += fStep; + path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); + } + CFWL_ThemeBackground param; + param.m_pGraphics = pGraphics; + param.m_matrix = *pMatrix; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_EDT_CombTextLine; + param.m_pPath = &path; + pTheme->DrawBackground(¶m); + } + pGraphics->RestoreGraphState(); +} +void CFWL_EditImp::UpdateEditEngine() { + UpdateEditParams(); + UpdateEditLayout(); + if (m_nLimit > -1) { + m_pEdtEngine->SetLimit(m_nLimit); + } +} +void CFWL_EditImp::UpdateEditParams() { + FDE_TXTEDTPARAMS params; + params.nHorzScale = 100; + params.fPlateWidth = m_rtEngine.width; + params.fPlateHeight = m_rtEngine.height; + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) { + params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) { + params.dwMode |= FDE_TEXTEDITMODE_Validate; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) { + params.dwMode |= FDE_TEXTEDITMODE_Password; + } + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { + case FWL_STYLEEXT_EDT_HNear: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Left; + break; + } + case FWL_STYLEEXT_EDT_HCenter: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Center; + break; + } + case FWL_STYLEEXT_EDT_HFar: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Right; + break; + } + default: {} + } + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { + case FWL_STYLEEXT_EDT_Justified: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Justified; + break; + } + case FWL_STYLEEXT_EDT_Distributed: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed; + break; + } + default: { params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; } + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { + params.dwMode |= FDE_TEXTEDITMODE_MultiLines; + if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 && + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { + params.dwMode |= + FDE_TEXTEDITMODE_AutoLineWrap | FDE_TEXTEDITMODE_LimitArea_Horz; + } + if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 && + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0) { + params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Vert; + } else { + params.fPlateHeight = 0x00FFFFFF; + } + } else { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { + params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz; + } + } + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { + params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; + } + FX_FLOAT* pFontSize = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); + if (!pFontSize) + return; + m_fFontSize = *pFontSize; + FX_DWORD* pFontColor = + static_cast<FX_DWORD*>(GetThemeCapacity(FWL_WGTCAPACITY_TextColor)); + if (!pFontColor) + return; + params.dwFontColor = *pFontColor; + FX_FLOAT* pLineHeight = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_LineHeight)); + if (!pLineHeight) + return; + params.fLineSpace = *pLineHeight; + IFX_Font* pFont = + static_cast<IFX_Font*>(GetThemeCapacity(FWL_WGTCAPACITY_Font)); + if (!pFont) + return; + params.pFont = pFont; + params.fFontSize = m_fFontSize; + params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace); + if (params.nLineCount <= 0) { + params.nLineCount = 1; + } + params.fTabWidth = params.fFontSize * 1; + params.bTabEquidistant = TRUE; + params.wLineBreakChar = L'\n'; + params.nCharRotation = 0; + params.pEventSink = this; + m_pEdtEngine->SetEditParams(params); +} + +void CFWL_EditImp::UpdateEditLayout() { + if (m_pEdtEngine->GetTextLength() <= 0) + m_pEdtEngine->SetTextByStream(nullptr); + + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + if (pPage) + pPage->UnloadPage(nullptr); + + m_pEdtEngine->StartLayout(); + m_pEdtEngine->DoLayout(nullptr); + m_pEdtEngine->EndLayout(); + pPage = m_pEdtEngine->GetPage(0); + if (pPage) + pPage->LoadPage(nullptr, nullptr); +} + +FX_BOOL CFWL_EditImp::UpdateOffset() { + CFX_RectF rtCaret; + m_pEdtEngine->GetCaretRect(rtCaret); + FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; + FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; + rtCaret.Offset(fOffSetX, fOffSetY); + const CFX_RectF& rtEidt = m_rtEngine; + if (rtEidt.Contains(rtCaret)) { + 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; + } + } + if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) { + m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom(); + if (m_fScrollOffsetY < 0) { + m_fScrollOffsetY = 0; + } + } + 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_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar, + FX_FLOAT fPosChanged) { + if (pScrollBar == m_pHorzScrollBar.get()) { + m_fScrollOffsetX += fPosChanged; + } else { + m_fScrollOffsetY += fPosChanged; + } + return TRUE; +} +void CFWL_EditImp::UpdateVAlignment() { + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + if (!pPage) + return; + const CFX_RectF& rtFDE = pPage->GetContentsBox(); + FX_FLOAT fOffsetY = 0.0f; + FX_FLOAT fSpaceAbove = 0.0f; + FX_FLOAT fSpaceBelow = 0.0f; + CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( + GetThemeCapacity(FWL_WGTCAPACITY_SpaceAboveBelow)); + if (pSpace) { + fSpaceAbove = pSpace->x; + fSpaceBelow = pSpace->y; + } + if (fSpaceAbove < 0.1f) { + fSpaceAbove = 0; + } + if (fSpaceBelow < 0.1f) { + fSpaceBelow = 0; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) { + fOffsetY = (m_rtEngine.height - rtFDE.height) / 2; + if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2 && + fSpaceAbove < fSpaceBelow) { + return; + } + fOffsetY += (fSpaceAbove - fSpaceBelow) / 2; + } else if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) { + fOffsetY = (m_rtEngine.height - rtFDE.height); + fOffsetY -= fSpaceBelow; + } else { + fOffsetY += fSpaceAbove; + } + m_fVAlignOffset = fOffsetY; + if (m_fVAlignOffset < 0) { + m_fVAlignOffset = 0; + } +} +void CFWL_EditImp::UpdateCaret() { + CFX_RectF rtFDE; + m_pEdtEngine->GetCaretRect(rtFDE); + rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, + m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); + CFX_RectF rtCaret; + rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); + CFX_RectF temp = rtCaret; + CFX_RectF rtClient; + GetClientRect(rtClient); + rtCaret.Intersect(rtClient); + if (rtCaret.left > rtClient.right()) { + FX_FLOAT right = rtCaret.right(); + rtCaret.left = rtClient.right() - 1; + rtCaret.width = right - rtCaret.left; + } + FX_BOOL bIntersect = !rtCaret.IsEmpty(); + FX_BOOL bShow = TRUE; + FX_BOOL bShowWhole = FALSE; + if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || !bIntersect) { + bShow = FALSE; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption && + temp.right() > m_rtEngine.right()) { + bShowWhole = TRUE; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption && + temp.bottom() > m_rtEngine.bottom()) { + bShowWhole = TRUE; + } else { + bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect); + } + if (bShowWhole) { + rtCaret = temp; + } + ShowCaret(bShow, &rtCaret); +} +IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() { + FX_BOOL bShowHorz = + m_pHorzScrollBar && + ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); + FX_BOOL bShowVert = + m_pVertScrollBar && + ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); + if (!bShowHorz && !bShowVert) { + return NULL; + } + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + if (!pPage) + return NULL; + const CFX_RectF& rtFDE = pPage->GetContentsBox(); + IFWL_ScrollBar* pRepaint = NULL; + if (bShowHorz) { + CFX_RectF rtScroll; + m_pHorzScrollBar->GetWidgetRect(rtScroll); + if (rtScroll.width < rtFDE.width) { + m_pHorzScrollBar->LockUpdate(); + FX_FLOAT fRange = rtFDE.width - rtScroll.width; + m_pHorzScrollBar->SetRange(0.0f, fRange); + FX_FLOAT fPos = m_fScrollOffsetX; + if (fPos < 0.0f) { + fPos = 0.0f; + } + if (fPos > fRange) { + fPos = fRange; + } + m_pHorzScrollBar->SetPos(fPos); + m_pHorzScrollBar->SetTrackPos(fPos); + m_pHorzScrollBar->SetPageSize(rtScroll.width); + m_pHorzScrollBar->SetStepSize(rtScroll.width / 10); + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); + m_pHorzScrollBar->UnlockUpdate(); + m_pHorzScrollBar->Update(); + pRepaint = m_pHorzScrollBar.get(); + } else if ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { + m_pHorzScrollBar->LockUpdate(); + m_pHorzScrollBar->SetRange(0, -1); + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); + m_pHorzScrollBar->UnlockUpdate(); + m_pHorzScrollBar->Update(); + pRepaint = m_pHorzScrollBar.get(); + } + } + if (bShowVert) { + CFX_RectF rtScroll; + m_pVertScrollBar->GetWidgetRect(rtScroll); + if (rtScroll.height < rtFDE.height) { + m_pVertScrollBar->LockUpdate(); + FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace; + FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; + if (fRange < fStep) { + fRange = fStep; + } + m_pVertScrollBar->SetRange(0.0f, fRange); + FX_FLOAT fPos = m_fScrollOffsetY; + if (fPos < 0.0f) { + fPos = 0.0f; + } + if (fPos > fRange) { + fPos = fRange; + } + m_pVertScrollBar->SetPos(fPos); + m_pVertScrollBar->SetTrackPos(fPos); + m_pVertScrollBar->SetPageSize(rtScroll.height); + m_pVertScrollBar->SetStepSize(fStep); + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); + m_pVertScrollBar->UnlockUpdate(); + m_pVertScrollBar->Update(); + pRepaint = m_pVertScrollBar.get(); + } else if ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { + m_pVertScrollBar->LockUpdate(); + m_pVertScrollBar->SetRange(0, -1); + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); + m_pVertScrollBar->UnlockUpdate(); + m_pVertScrollBar->Update(); + pRepaint = m_pVertScrollBar.get(); + } + } + return pRepaint; +} +FX_BOOL CFWL_EditImp::IsShowScrollBar(FX_BOOL bVert) { + FX_BOOL bShow = + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) + ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == + FWL_WGTSTATE_Focused + : TRUE; + if (bVert) { + return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && + IsContentHeightOverflow(); + } + return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); +} +FX_BOOL CFWL_EditImp::IsContentHeightOverflow() { + if (!m_pEdtEngine) + return FALSE; + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + if (!pPage) + return FALSE; + return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; +} +int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) { + int32_t nCount = m_RecordArr.GetSize(); + if (m_iCurRecord == nCount - 1) { + if (nCount == m_iMaxRecord) { + m_RecordArr.RemoveAt(0); + m_iCurRecord--; + } + } else { + for (int32_t i = nCount - 1; i > m_iCurRecord; i--) { + m_RecordArr.RemoveAt(i); + } + } + m_RecordArr.Add(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)); + if (!pfWidth) + return; + FX_FLOAT fWidth = *pfWidth; + if (!m_pOuter) { + CFX_RectF* pUIMargin = + static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin)); + if (pUIMargin) { + m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, + pUIMargin->height); + } + } else if (m_pOuter->GetClassID() == FWL_CLASSHASH_DateTimePicker) { + CFWL_ThemePart part; + part.m_pWidget = m_pOuter; + CFX_RectF* pUIMargin = + static_cast<CFX_RectF*>(m_pOuter->GetThemeProvider()->GetCapacity( + &part, FWL_WGTCAPACITY_UIMargin)); + if (pUIMargin) { + m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, + pUIMargin->height); + } + } + FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); + FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); + if (bShowVertScrollbar) { + 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); + } else { + rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, + m_rtClient.height); + if (bShowHorzScrollbar) { + rtVertScr.height -= fWidth; + } + m_rtEngine.width -= fWidth; + } + m_pVertScrollBar->SetWidgetRect(rtVertScr); + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + m_pVertScrollBar->Update(); + } else if (m_pVertScrollBar) { + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (bShowHorzScrollbar) { + 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, + m_rtClient.width, fWidth); + } else { + rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, + m_rtClient.width, fWidth); + if (bShowVertScrollbar) { + rtHoriScr.width -= fWidth; + } + m_rtEngine.height -= fWidth; + } + m_pHorzScrollBar->SetWidgetRect(rtHoriScr); + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + m_pHorzScrollBar->Update(); + } else if (m_pHorzScrollBar) { + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } +} +void CFWL_EditImp::LayoutScrollBar() { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == + 0) { + return; + } + FX_FLOAT* pfWidth = NULL; + FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); + FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); + if (bShowVertScrollbar) { + if (!m_pVertScrollBar) { + pfWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(FWL_WGTCAPACITY_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); + } else { + rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, + m_rtClient.height); + if (bShowHorzScrollbar) { + rtVertScr.height -= fWidth; + } + } + m_pVertScrollBar->SetWidgetRect(rtVertScr); + m_pVertScrollBar->Update(); + } + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + } else if (m_pVertScrollBar) { + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (bShowHorzScrollbar) { + if (!m_pHorzScrollBar) { + if (!pfWidth) { + pfWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(FWL_WGTCAPACITY_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, + m_rtClient.width, fWidth); + } else { + rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, + m_rtClient.width, fWidth); + if (bShowVertScrollbar) { + rtHoriScr.width -= (fWidth); + } + } + m_pHorzScrollBar->SetWidgetRect(rtHoriScr); + m_pHorzScrollBar->Update(); + } + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + } else if (m_pHorzScrollBar) { + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (bShowVertScrollbar || bShowHorzScrollbar) { + UpdateScroll(); + } +} +void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) { + pt.x += -m_rtEngine.left + m_fScrollOffsetX; + pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY; +} +void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { + if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { + return; + } + CFWL_WidgetImpProperties prop; + prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; + prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; + prop.m_pParent = m_pInterface; + prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; + IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); + pScrollBar->Initialize(); + (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); +} +void CFWL_EditImp::InitEngine() { + if (m_pEdtEngine) { + return; + } + m_pEdtEngine = IFDE_TxtEdtEngine::Create(); +} +extern FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, + FX_BOOL bVisible, + const CFX_RectF* pRtAnchor); +void CFWL_EditImp::ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect) { + if (m_pCaret) { + m_pCaret->ShowCaret(bVisible); + if (bVisible && !pRect->IsEmpty()) { + m_pCaret->SetWidgetRect(*pRect); + } + Repaint(&m_rtEngine); + } else { + IFWL_Widget* pOuter = m_pInterface; + if (bVisible) { + pRect->Offset(m_pProperties->m_rtWidget.left, + m_pProperties->m_rtWidget.top); + } + while (pOuter->GetOuter()) { + pOuter = pOuter->GetOuter(); + if (bVisible) { + CFX_RectF rtOuter; + pOuter->GetWidgetRect(rtOuter); + pRect->Offset(rtOuter.left, rtOuter.top); + } + } + FWL_ShowCaret(pOuter, bVisible, pRect); + } +} +FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum) { + if (!m_pEdtEngine) { + return FALSE; + } + if (!m_bSetRange) { + return TRUE; + } + CFX_WideString wsOld, wsText; + m_pEdtEngine->GetText(wsText, 0); + if (wsText.IsEmpty()) { + if (cNum == L'0') { + return FALSE; + } + return TRUE; + } + int32_t caretPos = m_pEdtEngine->GetCaretPos(); + int32_t iSel = CountSelRanges(); + if (iSel == 0) { + if (cNum == L'0' && caretPos == 0) { + return FALSE; + } + int32_t nLen = wsText.GetLength(); + CFX_WideString l = wsText.Mid(0, caretPos); + CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); + CFX_WideString wsNew = l + cNum + r; + if (wsNew.GetInteger() <= m_iMax) { + return TRUE; + } + } else { + if (wsText.GetInteger() <= m_iMax) { + return TRUE; + } + } + return FALSE; +} +void CFWL_EditImp::InitCaret() { + if (!m_pCaret) { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { + CFWL_WidgetImpProperties prop; + m_pCaret.reset(IFWL_Caret::Create(prop, m_pInterface)); + m_pCaret->Initialize(); + m_pCaret->SetParent(m_pInterface); + m_pCaret->SetStates(m_pProperties->m_dwStates); + } + } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == + 0) { + m_pCaret.reset(); + } +} +void CFWL_EditImp::ClearRecord() { + m_iCurRecord = -1; + m_RecordArr.RemoveAll(); +} +void CFWL_EditImp::ProcessInsertError(int32_t iError) { + switch (iError) { + case -2: { + CFWL_EvtEdtTextFull textFullEvent; + textFullEvent.m_pSrcTarget = m_pInterface; + DispatchEvent(&textFullEvent); + break; + } + default: {} + } +} +CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_Activate: { + DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); + break; + } + case FWL_MSGHASH_Deactivate: { + DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); + break; + } + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMsg->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonDblClk: { + OnButtonDblClk(pMsg); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMsg); + break; + } + case FWL_MSGMOUSECMD_RButtonDown: { + DoButtonDown(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); + FX_DWORD dwCmd = pKey->m_dwCmd; + if (dwCmd == FWL_MSGKEYCMD_KeyDown) { + OnKeyDown(pKey); + } else if (dwCmd == FWL_MSGKEYCMD_Char) { + OnChar(pKey); + } + break; + } + default: { iRet = 0; } + } + CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); + return iRet; +} +FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { + if (!pEvent) + return FWL_ERR_Indefinite; + FX_DWORD dwHashCode = pEvent->GetClassID(); + if (dwHashCode != FWL_EVTHASH_Scroll) { + return FWL_ERR_Succeeded; + } + IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; + if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && + m_pOwner->m_pVertScrollBar) || + (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && + m_pOwner->m_pHorzScrollBar)) { + CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(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::DoActivate(CFWL_MsgActivate* pMsg) { + m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { + m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->SetFocus(TRUE); + } + if (!m_pOwner->m_pEdtEngine) { + m_pOwner->UpdateEditEngine(); + } + IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); + if (!pPage) + return; + CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); + m_pOwner->DeviceToEngine(pt); + FX_BOOL bBefore = TRUE; + int32_t nIndex = pPage->GetCharIndex(pt, bBefore); + if (nIndex < 0) { + nIndex = 0; + } + m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); +} +void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { + FX_DWORD dwStyleEx = m_pOwner->GetStylesEx(); + FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret; + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + if (!m_pOwner->m_pEdtEngine) { + m_pOwner->UpdateEditEngine(); + } + m_pOwner->UpdateVAlignment(); + m_pOwner->UpdateOffset(); + m_pOwner->UpdateCaret(); + } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + m_pOwner->ShowCaret(FALSE); + if (m_pOwner->m_pEdtEngine && + (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { + int32_t nSel = m_pOwner->CountSelRanges(); + if (nSel > 0) { + m_pOwner->ClearSelections(); + bRepaint = TRUE; + } + m_pOwner->SetCaretPos(0); + m_pOwner->UpdateOffset(); + } + m_pOwner->ClearRecord(); + } + m_pOwner->LayoutScrollBar(); + if (bRepaint) { + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, + m_pOwner->m_pProperties->m_rtWidget.height); + m_pOwner->Repaint(&rtInvalidate); + } +} +void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + DoCursor(pMsg); + if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + return; + } + m_pOwner->m_bLButtonDown = TRUE; + m_pOwner->SetGrab(TRUE); + DoButtonDown(pMsg); + int32_t nIndex = m_pOwner->m_pEdtEngine->GetCaretPos(); + FX_BOOL bRepaint = FALSE; + int32_t iCount = m_pOwner->m_pEdtEngine->CountSelRanges(); + if (iCount > 0) { + m_pOwner->m_pEdtEngine->ClearSelection(); + bRepaint = TRUE; + } + FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; + if (bShift && m_pOwner->m_nSelStart != nIndex) { + int32_t iStart = std::min(m_pOwner->m_nSelStart, nIndex); + int32_t iEnd = std::max(m_pOwner->m_nSelStart, nIndex); + m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart); + bRepaint = TRUE; + } else { + m_pOwner->m_nSelStart = nIndex; + } + if (bRepaint) { + m_pOwner->Repaint(&m_pOwner->m_rtEngine); + } +} +void CFWL_EditImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + DoCursor(pMsg); + m_pOwner->m_bLButtonDown = FALSE; + m_pOwner->SetGrab(FALSE); +} +void CFWL_EditImpDelegate::OnButtonDblClk(CFWL_MsgMouse* pMsg) { + if (!m_pOwner->m_pEdtEngine) + return; + DoCursor(pMsg); + IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); + if (!pPage) + return; + CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); + m_pOwner->DeviceToEngine(pt); + int32_t nCount = 0; + int32_t nIndex = pPage->SelectWord(pt, nCount); + if (nIndex < 0) { + return; + } + m_pOwner->m_pEdtEngine->AddSelRange(nIndex, nCount); + m_pOwner->m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE); + m_pOwner->Repaint(&m_pOwner->m_rtEngine); +} +void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + if (!m_pOwner->m_pEdtEngine) + return; + DoCursor(pMsg); + if (m_pOwner->m_nSelStart == -1 || !m_pOwner->m_bLButtonDown) { + return; + } + IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); + if (!pPage) + return; + CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); + m_pOwner->DeviceToEngine(pt); + FX_BOOL bBefore = TRUE; + int32_t nIndex = pPage->GetCharIndex(pt, bBefore); + m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); + nIndex = m_pOwner->m_pEdtEngine->GetCaretPos(); + m_pOwner->m_pEdtEngine->ClearSelection(); + if (nIndex != m_pOwner->m_nSelStart) { + int32_t nLen = m_pOwner->m_pEdtEngine->GetTextLength(); + if (m_pOwner->m_nSelStart >= nLen) { + m_pOwner->m_nSelStart = nLen; + } + m_pOwner->m_pEdtEngine->AddSelRange( + std::min(m_pOwner->m_nSelStart, nIndex), + FXSYS_abs(nIndex - m_pOwner->m_nSelStart)); + } +} +void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { + if (!m_pOwner->m_pEdtEngine) + return; + FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; + FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; + FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; + FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; + switch (dwKeyCode) { + case FWL_VKEY_Left: { + MoveCaret = MC_Left; + break; + } + case FWL_VKEY_Right: { + MoveCaret = MC_Right; + break; + } + case FWL_VKEY_Up: { + MoveCaret = MC_Up; + break; + } + case FWL_VKEY_Down: { + MoveCaret = MC_Down; + break; + } + case FWL_VKEY_Home: { + if (bCtrl) { + MoveCaret = MC_Home; + } else { + MoveCaret = MC_LineStart; + } + break; + } + case FWL_VKEY_End: { + if (bCtrl) { + MoveCaret = MC_End; + } else { + MoveCaret = MC_LineEnd; + } + break; + } + case FWL_VKEY_Insert: { + break; + } + case FWL_VKEY_Delete: { + if ((m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_EDT_ReadOnly) || + (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { + break; + } + int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos(); +#if (_FX_OS_ == _FX_MACOSX_) + m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE); +#else + m_pOwner->m_pEdtEngine->Delete(nCaret); +#endif + break; + } + case FWL_VKEY_F2: { + break; + } + case FWL_VKEY_Tab: { + m_pOwner->DispatchKeyEvent(pMsg); + break; + } + default: { +#if (_FX_OS_ == _FX_MACOSX_) + if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) { +#else + if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { +#endif + if (dwKeyCode == 0x43 || dwKeyCode == 0x63) { + m_pOwner->DoClipboard(1); + return; + } + if (dwKeyCode == 0x58 || dwKeyCode == 0x78) { + m_pOwner->DoClipboard(2); + return; + } + if (dwKeyCode == 0x56 || dwKeyCode == 0x76) { + m_pOwner->DoClipboard(3); + return; + } + } + } + } + if (MoveCaret != MC_MoveNone) { + m_pOwner->m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl); + } +} +void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey* pMsg) { + if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || + (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { + return; + } + if (!m_pOwner->m_pEdtEngine) + return; + int32_t iError = 0; + FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; + int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos(); + switch (c) { + case FWL_VKEY_Back: { + m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE); + break; + } + case 0x0A: { + break; + } + case FWL_VKEY_Escape: { + break; + } + case FWL_VKEY_Tab: { + iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\t", 1); + break; + } + case FWL_VKEY_Return: { + if (m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_EDT_WantReturn) { + iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\n", 1); + } + break; + } + default: { + if (!m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) { + if (((pMsg->m_dwKeyCode < FWL_VKEY_0) && + (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) || + pMsg->m_dwKeyCode > FWL_VKEY_9) { + break; + } + if (!m_pOwner->ValidateNumberChar(c)) { + break; + } + } + } +#if (_FX_OS_ == _FX_MACOSX_) + if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) +#else + if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) +#endif + { + break; + } + iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1); + break; + } + } + if (iError < 0) { + m_pOwner->ProcessInsertError(iError); + } +} +FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, + FX_DWORD dwCode, + FX_FLOAT fPos) { + CFX_SizeF fs; + pScrollBar->GetRange(fs.x, fs.y); + FX_FLOAT iCurPos = pScrollBar->GetPos(); + FX_FLOAT fStep = pScrollBar->GetStepSize(); + switch (dwCode) { + case FWL_SCBCODE_Min: { + fPos = fs.x; + break; + } + case FWL_SCBCODE_Max: { + fPos = fs.y; + break; + } + case FWL_SCBCODE_StepBackward: { + fPos -= fStep; + if (fPos < fs.x + fStep / 2) { + fPos = fs.x; + } + break; + } + case FWL_SCBCODE_StepForward: { + fPos += fStep; + if (fPos > fs.y - fStep / 2) { + fPos = fs.y; + } + break; + } + case FWL_SCBCODE_PageBackward: { + fPos -= pScrollBar->GetPageSize(); + if (fPos < fs.x) { + fPos = fs.x; + } + break; + } + case FWL_SCBCODE_PageForward: { + fPos += pScrollBar->GetPageSize(); + if (fPos > fs.y) { + fPos = fs.y; + } + break; + } + case FWL_SCBCODE_Pos: + case FWL_SCBCODE_TrackPos: { + break; + } + case FWL_SCBCODE_EndScroll: { + return FALSE; + } + default: {} + } + if (iCurPos != fPos) { + pScrollBar->SetPos(fPos); + pScrollBar->SetTrackPos(fPos); + m_pOwner->UpdateOffset(pScrollBar, fPos - iCurPos); + if (m_pOwner->m_pEdtEngine) { + m_pOwner->UpdateCaret(); + } + CFX_RectF rect; + m_pOwner->GetWidgetRect(rect); + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); + m_pOwner->Repaint(&rtInvalidate); + } + return TRUE; +} +void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h new file mode 100644 index 0000000000..6693b8d187 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_editimp.h @@ -0,0 +1,208 @@ +// 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_FWL_EDITIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ + +#include <memory> +#include <vector> + +#include "xfa/fee/ifde_txtedtengine.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" + +class CFWL_WidgetImpProperties; +class CFWL_WidgetImpDelegate; +class IFWL_Caret; +class CFWL_EditImp; +class CFWL_EditImpDelegate; + +class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { + public: + CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); + ~CFWL_EditImp() override; + + // CFWL_WidgetImp: + FWL_ERR GetClassName(CFX_WideString& wsClass) const override; + FX_DWORD 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; + FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_ERR SetStates(FX_DWORD 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; + + virtual FWL_ERR 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 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 int32_t CountSelRanges(); + virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); + virtual FWL_ERR 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 FX_BOOL Copy(CFX_WideString& wsCopy); + virtual FX_BOOL Cut(CFX_WideString& wsCut); + virtual FX_BOOL Paste(const CFX_WideString& wsPaste); + virtual FX_BOOL Delete(); + virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord); + virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord); + virtual FX_BOOL Undo(); + 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, + 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, + int32_t nPageIndex, + int32_t nPurpose) override; + FX_BOOL On_PageUnload(IFDE_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(FX_DWORD color); + virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); + void SetScrollOffset(FX_FLOAT fScrollOffset); + FX_BOOL GetSuggestWords(CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest); + FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace); + + protected: + void DrawTextBk(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawContent(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void UpdateEditEngine(); + void UpdateEditParams(); + void UpdateEditLayout(); + FX_BOOL UpdateOffset(); + FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); + void UpdateVAlignment(); + void UpdateCaret(); + IFWL_ScrollBar* UpdateScroll(); + void Layout(); + void LayoutScrollBar(); + void DeviceToEngine(CFX_PointF& pt); + void InitScrollBar(FX_BOOL bVert = TRUE); + void InitEngine(); + virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL); + FX_BOOL ValidateNumberChar(FX_WCHAR cNum); + void InitCaret(); + void ClearRecord(); + FX_BOOL IsShowScrollBar(FX_BOOL bVert); + FX_BOOL IsContentHeightOverflow(); + int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord); + void ProcessInsertError(int32_t iError); + + void DrawSpellCheck(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = NULL); + void AddSpellCheckObj(CFX_Path& PathData, + int32_t nStart, + int32_t nCount, + FX_FLOAT fOffSetX, + FX_FLOAT fOffSetY); + int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); + CFX_RectF m_rtClient; + CFX_RectF m_rtEngine; + CFX_RectF m_rtStatic; + FX_FLOAT m_fVAlignOffset; + FX_FLOAT m_fScrollOffsetX; + FX_FLOAT m_fScrollOffsetY; + IFDE_TxtEdtEngine* m_pEdtEngine; + FX_BOOL m_bLButtonDown; + int32_t m_nSelStart; + int32_t m_nLimit; + FX_FLOAT m_fSpaceAbove; + FX_FLOAT m_fSpaceBelow; + FX_FLOAT m_fFontSize; + FX_ARGB m_argbSel; + FX_BOOL m_bSetRange; + int32_t m_iMin; + int32_t m_iMax; + std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; + std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; + std::unique_ptr<IFWL_Caret> m_pCaret; + CFX_WideString m_wsCache; + friend class CFWL_TxtEdtEventSink; + friend class CFWL_EditImpDelegate; + FX_DWORD m_backColor; + FX_BOOL m_updateBackColor; + CFX_WideString m_wsFont; + CFX_ByteStringArray m_RecordArr; + int32_t m_iCurRecord; + int32_t m_iMaxRecord; +}; + +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; + + protected: + void DoActivate(CFWL_MsgActivate* pMsg); + void DoDeactivate(CFWL_MsgDeactivate* pMsg); + void DoButtonDown(CFWL_MsgMouse* pMsg); + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnButtonDblClk(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + void OnChar(CFWL_MsgKey* pMsg); + FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos); + void DoCursor(CFWL_MsgMouse* pMsg); + CFWL_EditImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_formproxyimp.cpp b/xfa/fwl/basewidget/fwl_formproxyimp.cpp new file mode 100644 index 0000000000..51f3507707 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_formproxyimp.cpp @@ -0,0 +1,55 @@ +// 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/basewidget/fwl_formproxyimp.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" + +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 { + wsClass = FWL_CLASS_FormProxy; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_FormProxyImp::GetClassID() const { + return FWL_CLASSHASH_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; + m_pDelegate = new CFWL_FormProxyImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_FormProxyImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_FormProxyImp::Update() { + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_FormProxyImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return FWL_ERR_Succeeded; +} +CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pOuter->SetDelegate(NULL); + return pDelegate->OnProcessMessage(pMessage); +} diff --git a/xfa/fwl/basewidget/fwl_formproxyimp.h b/xfa/fwl/basewidget/fwl_formproxyimp.h new file mode 100644 index 0000000000..c26f21a0d1 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_formproxyimp.h @@ -0,0 +1,42 @@ +// 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_FWL_FORMPROXYIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_FORMPROXYIMP_H_ + +#include "xfa/fwl/core/fwl_formimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" + +class CFWL_WidgetImpProperties; +class CFWL_FormProxyImpDelegate; + +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 FX_DWORD 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); + + protected: + friend class CFWL_FormProxyImpDelegate; +}; +class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate { + public: + CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner); + int32_t OnProcessMessage(CFWL_Message* pMessage) override; + + protected: + CFWL_FormProxyImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_FORMPROXYIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/basewidget/fwl_listboximp.cpp new file mode 100644 index 0000000000..a7481165bf --- /dev/null +++ b/xfa/fwl/basewidget/fwl_listboximp.cpp @@ -0,0 +1,1241 @@ +// 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/basewidget/fwl_listboximp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/basewidget/fwl_comboboximp.h" +#include "xfa/fwl/basewidget/fwl_scrollbarimp.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +#define FWL_LISTBOX_ItemTextMargin 2 + +// static +IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_ListBox* pListBox = new IFWL_ListBox; + CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter); + pListBox->SetImpl(pListBoxImpl); + pListBoxImpl->SetInterface(pListBox); + return pListBox; +} +// static +IFWL_ListBox* IFWL_ListBox::CreateComboList( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_ListBox* pListBox = new IFWL_ListBox; + CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter); + pListBox->SetImpl(pComboListImpl); + pComboListImpl->SetInterface(pListBox); + return pListBox; +} +IFWL_ListBox::IFWL_ListBox() {} +int32_t IFWL_ListBox::CountSelItems() { + return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); +} +FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { + return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(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) { + return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); +} +FWL_ERR 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) { + 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) + : CFWL_WidgetImp(properties, pOuter), + m_dwTTOStyles(0), + m_iTTOAligns(0), + m_hAnchor(NULL), + m_fScorllBarWidth(0), + m_bLButtonDown(FALSE), + m_pScrollBarTP(NULL) { + m_rtClient.Reset(); + m_rtConent.Reset(); + m_rtStatic.Reset(); +} +CFWL_ListBoxImp::~CFWL_ListBoxImp() {} +FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_ListBox; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_ListBoxImp::GetClassID() const { + return FWL_CLASSHASH_ListBox; +} +FWL_ERR CFWL_ListBoxImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_ListBoxImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ListBoxImp::Finalize() { + if (m_pVertScrollBar) { + m_pVertScrollBar->Finalize(); + } + if (m_pHorzScrollBar) { + m_pHorzScrollBar->Finalize(); + } + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_ListBoxImp::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(); + } + CFX_SizeF fs = CalcSize(TRUE); + rect.Set(0, 0, fs.x, fs.y); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ListBoxImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + m_iTTOAligns = FDE_TTOALIGNMENT_Center; + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { + case FWL_STYLEEXT_LTB_LeftAlign: { + m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; + break; + } + case FWL_STYLEEXT_LTB_RightAlign: { + m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; + break; + } + case FWL_STYLEEXT_LTB_CenterAlign: + default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } + } + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + m_dwTTOStyles |= FDE_TTOSTYLE_RTL; + } + m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; + m_fScorllBarWidth = GetScrollWidth(); + SortItem(); + CalcSize(); + return FWL_ERR_Succeeded; +} +FX_DWORD 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 (IsShowScrollBar(TRUE)) { + CFX_RectF rect; + m_pVertScrollBar->GetWidgetRect(rect); + if (rect.Contains(fx, fy)) { + return FWL_WGTHITTEST_VScrollBar; + } + } + if (m_rtClient.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + return FWL_WGTHITTEST_Unknown; +} +FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + pGraphics->SaveGraphState(); + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_LTB_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_LTB_Edge, pTheme, pMatrix); + } + CFX_RectF rtClip(m_rtConent); + if (IsShowScrollBar(FALSE)) { + rtClip.height -= m_fScorllBarWidth; + } + if (IsShowScrollBar(TRUE)) { + rtClip.width -= m_fScorllBarWidth; + } + if (pMatrix) { + pMatrix->TransformRect(rtClip); + } + pGraphics->SetClipRect(rtClip); + if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { + DrawBkground(pGraphics, pTheme, pMatrix); + } + DrawItems(pGraphics, pTheme, pMatrix); + pGraphics->RestoreGraphState(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { + if (!pThemeProvider) + return FWL_ERR_Indefinite; + if (!pThemeProvider->IsValidWidget(m_pInterface)) { + m_pScrollBarTP = pThemeProvider; + return FWL_ERR_Succeeded; + } + m_pProperties->m_pThemeProvider = pThemeProvider; + return FWL_ERR_Succeeded; +} +int32_t CFWL_ListBoxImp::CountSelItems() { + if (!m_pProperties->m_pDataProvider) + return 0; + int32_t iRet = 0; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + continue; + } + FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); + if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { + iRet++; + } + } + return iRet; +} +FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { + if (!m_pProperties->m_pDataProvider) + return NULL; + int32_t index = 0; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + return NULL; + } + FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); + if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { + if (index == nIndexSel) { + return hItem; + } else { + index++; + } + } + } + return NULL; +} +int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { + if (!m_pProperties->m_pDataProvider) + return -1; + int32_t index = 0; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + return -1; + } + FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); + if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { + if (index == nIndex) { + return i; + } else { + index++; + } + } + } + return -1; +} +FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { + if (!m_pProperties->m_pDataProvider) + return FWL_ERR_Indefinite; + if (!hItem) { + if (bSelect) { + SelectAll(); + } else { + ClearSelection(); + SetFocusItem(NULL); + } + return FWL_ERR_Indefinite; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { + SetSelectionDirect(hItem, bSelect); + } else { + SetSelection(hItem, hItem, bSelect); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, + CFX_WideString& wsText) { + if (!m_pProperties->m_pDataProvider) + return FWL_ERR_Indefinite; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + if (!hItem) + return FWL_ERR_Indefinite; + pData->GetItemText(m_pInterface, hItem, wsText); + return FWL_ERR_Succeeded; +} +FWL_ERR 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_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; +} +FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, + FX_DWORD dwKeyCode) { + FWL_HLISTITEM hRet = NULL; + switch (dwKeyCode) { + case FWL_VKEY_Up: + case FWL_VKEY_Down: + case FWL_VKEY_Home: + case FWL_VKEY_End: { + const bool bUp = dwKeyCode == FWL_VKEY_Up; + const bool bDown = dwKeyCode == FWL_VKEY_Down; + const bool bHome = dwKeyCode == FWL_VKEY_Home; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iDstItem = -1; + if (bUp || bDown) { + int32_t index = pData->GetItemIndex(m_pInterface, hItem); + iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; + } else if (bHome) { + iDstItem = 0; + } else { + int32_t iCount = pData->CountItems(m_pInterface); + iDstItem = iCount - 1; + } + hRet = pData->GetItem(m_pInterface, iDstItem); + break; + } + default: {} + } + return hRet; +} +void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, + FWL_HLISTITEM hEnd, + FX_BOOL bSelected) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iStart = pData->GetItemIndex(m_pInterface, hStart); + int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd); + if (iStart > iEnd) { + int32_t iTemp = iStart; + iStart = iEnd; + iEnd = iTemp; + } + if (bSelected) { + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + SetSelectionDirect(hItem, FALSE); + } + } + for (; iStart <= iEnd; iStart++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart); + SetSelectionDirect(hItem, bSelected); + } +} +void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FX_DWORD dwOldStyle = pData->GetItemStyles(m_pInterface, hItem); + bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected + : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; + pData->SetItemStyles(m_pInterface, hItem, dwOldStyle); +} +FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem); + return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; +} +void CFWL_ListBoxImp::ClearSelection() { + FX_BOOL bMulti = + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem); + FX_BOOL bFindSel = dwState & FWL_ITEMSTATE_LTB_Selected; + if (!bFindSel) { + continue; + } + SetSelectionDirect(hItem, FALSE); + if (!bMulti) { + return; + } + } +} +void CFWL_ListBoxImp::SelectAll() { + FX_BOOL bMulti = + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; + if (!bMulti) { + return; + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + if (iCount > 0) { + FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0); + FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1); + SetSelection(hItemStart, hItemEnd, FALSE); + } +} +FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem() { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) + return NULL; + if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) { + return hItem; + } + } + return NULL; +} +void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FWL_HLISTITEM hFocus = GetFocusedItem(); + if (hItem != hFocus) { + if (hFocus) { + FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hFocus); + dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; + pData->SetItemStyles(m_pInterface, hFocus, dwStyle); + } + if (hItem) { + FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); + dwStyle |= FWL_ITEMSTATE_LTB_Focused; + pData->SetItemStyles(m_pInterface, hItem, dwStyle); + } + } +} +FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { + fx -= m_rtConent.left, fy -= m_rtConent.top; + FX_FLOAT fPosX = 0.0f; + if (m_pHorzScrollBar) { + fPosX = m_pHorzScrollBar->GetPos(); + } + FX_FLOAT fPosY = 0.0; + if (m_pVertScrollBar) { + fPosY = m_pVertScrollBar->GetPos(); + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t nCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < nCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + continue; + } + CFX_RectF rtItem; + pData->GetItemRect(m_pInterface, hItem, rtItem); + rtItem.Offset(-fPosX, -fPosY); + if (rtItem.Contains(fx, fy)) { + return hItem; + } + } + return NULL; +} +FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, + CFX_RectF& rtCheck) { + if (!m_pProperties->m_pDataProvider) + return FALSE; + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + return FALSE; + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->GetItemCheckRect(m_pInterface, hItem, rtCheck); + return TRUE; +} +FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) { + if (!m_pProperties->m_pDataProvider) + return FALSE; + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + return FALSE; + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + return (pData->GetItemCheckState(m_pInterface, hItem) & + FWL_ITEMSTATE_LTB_Checked); +} +FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) { + if (!m_pProperties->m_pDataProvider) + return FALSE; + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + return FALSE; + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->SetItemCheckState(m_pInterface, hItem, + bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); + return TRUE; +} +FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem) { + if (!m_pVertScrollBar) + return FALSE; + CFX_RectF rtItem; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->GetItemRect(m_pInterface, hItem, rtItem); + FX_BOOL bScroll = FALSE; + FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); + rtItem.Offset(0, -fPosY + m_rtConent.top); + if (rtItem.top < m_rtConent.top) { + fPosY += rtItem.top - m_rtConent.top; + bScroll = TRUE; + } else if (rtItem.bottom() > m_rtConent.bottom()) { + fPosY += rtItem.bottom() - m_rtConent.bottom(); + bScroll = TRUE; + } + if (!bScroll) { + return FALSE; + } + m_pVertScrollBar->SetPos(fPosY); + m_pVertScrollBar->SetTrackPos(fPosY); + Repaint(&m_rtClient); + return TRUE; +} +void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pTheme) + return; + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_LTB_Background; + param.m_dwStates = 0; + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = m_rtClient; + if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) { + param.m_pData = &m_rtStatic; + } + if (!IsEnabled()) { + param.m_dwStates = FWL_PARTSTATE_LTB_Disabled; + } + pTheme->DrawBackground(¶m); +} +void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + FX_FLOAT fPosX = 0.0f; + if (m_pHorzScrollBar) { + fPosX = m_pHorzScrollBar->GetPos(); + } + FX_FLOAT fPosY = 0.0f; + if (m_pVertScrollBar) { + fPosY = m_pVertScrollBar->GetPos(); + } + CFX_RectF rtView(m_rtConent); + if (m_pHorzScrollBar) { + rtView.height -= m_fScorllBarWidth; + } + if (m_pVertScrollBar) { + rtView.width -= m_fScorllBarWidth; + } + FX_BOOL bMultiCol = + m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + continue; + } + CFX_RectF rtItem; + pData->GetItemRect(m_pInterface, hItem, rtItem); + rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); + if (rtItem.bottom() < m_rtConent.top) { + continue; + } + if (rtItem.top >= m_rtConent.bottom()) { + break; + } + if (bMultiCol && rtItem.left > m_rtConent.right()) { + break; + } + if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) { + CFWL_EvtLtbDrawItem ev; + ev.m_pSrcTarget = m_pInterface; + ev.m_pGraphics = pGraphics; + ev.m_matrix = *pMatrix; + ev.m_index = i; + ev.m_rect = rtItem; + DispatchEvent(&ev); + } else { + DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix); + } + } +} +void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FWL_HLISTITEM hItem, + int32_t Index, + const CFX_RectF& rtItem, + const CFX_Matrix* pMatrix) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + FX_DWORD dwItemStyles = pData->GetItemStyles(m_pInterface, hItem); + FX_DWORD dwPartStates = FWL_PARTSTATE_LTB_Normal; + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + dwPartStates = FWL_PARTSTATE_LTB_Disabled; + } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { + dwPartStates = FWL_PARTSTATE_LTB_Selected; + } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && + dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { + dwPartStates |= FWL_PARTSTATE_LTB_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_dwStates = dwPartStates; + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = rtItem; + param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); + CFX_RectF rtFocus(rtItem); + param.m_pData = &rtFocus; + if (m_pVertScrollBar && !m_pHorzScrollBar && + (dwPartStates & FWL_PARTSTATE_LTB_Focused)) { + param.m_rtPart.left += 1; + param.m_rtPart.width -= (m_fScorllBarWidth + 1); + rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); + } + pTheme->DrawBackground(¶m); + } + { + FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; + if (bHasIcon) { + CFX_RectF rtDIB; + CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem); + rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); + if (pDib) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_LTB_Icon; + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = rtDIB; + param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); + param.m_pImage = pDib; + pTheme->DrawBackground(¶m); + } + } + FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check; + if (bHasCheck) { + CFX_RectF rtCheck; + rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); + rtCheck.Deflate(2, 2, 2, 2); + pData->SetItemCheckRect(m_pInterface, hItem, rtCheck); + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_LTB_Check; + param.m_pGraphics = pGraphics; + if (GetItemChecked(hItem)) { + param.m_dwStates = FWL_PARTSTATE_LTB_Checked; + } else { + param.m_dwStates = FWL_PARTSTATE_LTB_UnChecked; + } + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = rtCheck; + param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); + pTheme->DrawBackground(¶m); + } + CFX_WideString wsText; + pData->GetItemText(m_pInterface, hItem, wsText); + if (wsText.GetLength() <= 0) { + return; + } + CFX_RectF rtText(rtItem); + rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); + 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_dwStates = dwPartStates; + textParam.m_pGraphics = pGraphics; + textParam.m_matrix.Concat(*pMatrix); + textParam.m_rtPart = rtText; + textParam.m_wsText = wsText; + textParam.m_dwTTOStyles = m_dwTTOStyles; + textParam.m_iTTOAlign = m_iTTOAligns; + textParam.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); + pTheme->DrawText(&textParam); + } +} +CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { + CFX_SizeF fs; + if (!m_pProperties->m_pThemeProvider) + return fs; + + GetClientRect(m_rtClient); + m_rtConent = m_rtClient; + CFX_RectF rtUIMargin; + rtUIMargin.Set(0, 0, 0, 0); + if (!m_pOuter) { + CFX_RectF* pUIMargin = + static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin)); + if (pUIMargin) { + m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, + pUIMargin->height); + } + } + FX_FLOAT fWidth = 0; + if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + if (!bAutoSize) { + } + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + 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_pData = m_pProperties->m_pDataProvider; + itemPart.m_dwData = i; + CFX_RectF r; + m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); + if (!bAutoSize) { + CFX_RectF rtItem; + rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->SetItemRect(m_pInterface, hItem, rtItem); + } + fs.y += r.height; + if (fs.x < r.width) { + fs.x = r.width; + fWidth = r.width; + } + } + } else { + fWidth = GetMaxTextWidth(); + fWidth += 2 * FWL_LISTBOX_ItemTextMargin; + if (!bAutoSize) { + FX_FLOAT fActualWidth = + m_rtClient.width - rtUIMargin.left - rtUIMargin.width; + if (fWidth < fActualWidth) { + fWidth = fActualWidth; + } + } + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + m_fItemHeight = GetItemHeigt(); + FX_BOOL bHasIcon; + bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; + if (bHasIcon) { + fWidth += m_fItemHeight; + } + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i); + GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); + } + } + if (bAutoSize) { + return fs; + } + FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; + FX_FLOAT iHeight = m_rtClient.height; + FX_BOOL bShowVertScr = + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && + (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll); + FX_BOOL bShowHorzScr = + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && + (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll); + if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll && + (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) { + bShowVertScr = (fs.y > iHeight); + } + if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) { + bShowHorzScr = (fs.x > iWidth); + } + CFX_SizeF szRange; + if (bShowVertScr) { + if (!m_pVertScrollBar) { + InitScrollBar(); + } + CFX_RectF rtScrollBar; + rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, + m_fScorllBarWidth, m_rtClient.height - 1); + if (bShowHorzScr) { + rtScrollBar.height -= m_fScorllBarWidth; + } + m_pVertScrollBar->SetWidgetRect(rtScrollBar); + szRange.x = 0, szRange.y = fs.y - m_rtConent.height; + if (szRange.y < m_fItemHeight) { + szRange.y = m_fItemHeight; + } + m_pVertScrollBar->SetRange(szRange.x, szRange.y); + m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); + m_pVertScrollBar->SetStepSize(m_fItemHeight); + FX_FLOAT fPos = m_pVertScrollBar->GetPos(); + if (fPos < 0) { + fPos = 0; + } + if (fPos > szRange.y) { + fPos = szRange.y; + } + m_pVertScrollBar->SetPos(fPos); + m_pVertScrollBar->SetTrackPos(fPos); + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == + 0 || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + } + m_pVertScrollBar->Update(); + } else if (m_pVertScrollBar) { + m_pVertScrollBar->SetPos(0); + m_pVertScrollBar->SetTrackPos(0); + m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (bShowHorzScr) { + if (!m_pHorzScrollBar) { + InitScrollBar(FALSE); + } + CFX_RectF rtScrollBar; + rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, + m_rtClient.width, m_fScorllBarWidth); + if (bShowVertScr) { + rtScrollBar.width -= m_fScorllBarWidth; + } + m_pHorzScrollBar->SetWidgetRect(rtScrollBar); + szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; + m_pHorzScrollBar->SetRange(szRange.x, szRange.y); + m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); + m_pHorzScrollBar->SetStepSize(fWidth / 10); + FX_FLOAT fPos = m_pHorzScrollBar->GetPos(); + if (fPos < 0) { + fPos = 0; + } + if (fPos > szRange.y) { + fPos = szRange.y; + } + m_pHorzScrollBar->SetPos(fPos); + m_pHorzScrollBar->SetTrackPos(fPos); + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == + 0 || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); + } + m_pHorzScrollBar->Update(); + } else if (m_pHorzScrollBar) { + m_pHorzScrollBar->SetPos(0); + m_pHorzScrollBar->SetTrackPos(0); + m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (bShowVertScr && bShowHorzScr) { + m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, + m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, + m_fScorllBarWidth); + } + return fs; +} +void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, + FWL_HLISTITEM hItem, + FX_FLOAT fWidth, + FX_FLOAT m_fItemHeight, + FX_BOOL bAutoSize) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { + } else { + if (!bAutoSize) { + CFX_RectF rtItem; + rtItem.Set(0, size.y, fWidth, m_fItemHeight); + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->SetItemRect(m_pInterface, hItem, rtItem); + } + size.x = fWidth; + size.y += m_fItemHeight; + } +} +FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() { + FX_FLOAT fRet = 0.0f; + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + int32_t iCount = pData->CountItems(m_pInterface); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + if (!hItem) { + continue; + } + CFX_WideString wsText; + pData->GetItemText(m_pInterface, hItem, wsText); + CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); + if (sz.x > fRet) { + fRet = sz.x; + } + } + return fRet; +} +FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() { + FX_FLOAT* pfWidth = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); + if (!pfWidth) + return 0; + return *pfWidth; +} +FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { + FX_FLOAT* pfFont = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); + if (!pfFont) + return 20; + return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin; +} +void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { + if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { + return; + } + CFWL_WidgetImpProperties prop; + prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; + prop.m_dwStates = FWL_WGTSTATE_Invisible; + prop.m_pParent = m_pInterface; + prop.m_pThemeProvider = m_pScrollBarTP; + IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); + 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(); + if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { + return FALSE; + } + return !(m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_LTB_ShowScrollBarFocus) || + (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); +} +void CFWL_ListBoxImp::ProcessSelChanged() { + CFWL_EvtLtbSelChanged selEvent; + selEvent.m_pSrcTarget = m_pInterface; + CFX_Int32Array arrSels; + int32_t iCount = CountSelItems(); + for (int32_t i = 0; i < iCount; i++) { + FWL_HLISTITEM item = GetSelItem(i); + if (item == NULL) { + continue; + } + selEvent.iarraySels.Add(i); + } + DispatchEvent(&selEvent); +} +CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + if (!m_pOwner->IsEnabled()) { + return 1; + } + FX_DWORD dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMsg->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_MouseWheel: { + OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); + if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) + OnKeyDown(pMsg); + break; + } + default: { iRet = 0; } + } + CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); + return iRet; +} +FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { + if (!pEvent) + return FWL_ERR_Indefinite; + if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) { + return FWL_ERR_Succeeded; + } + IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; + if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && + m_pOwner->m_pVertScrollBar) || + (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && + m_pOwner->m_pHorzScrollBar)) { + CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(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::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { + if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { + if (m_pOwner->m_pVertScrollBar) { + m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); + } + if (m_pOwner->m_pHorzScrollBar) { + m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); + } + } + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); + } else { + m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + m_pOwner->m_bLButtonDown = TRUE; + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->SetFocus(TRUE); + } + FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + if (!hItem) { + return; + } + if (m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_LTB_MultiSelection) { + if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { + FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem); + m_pOwner->SetSelectionDirect(hItem, !bSelected); + m_pOwner->m_hAnchor = hItem; + } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { + if (m_pOwner->m_hAnchor) { + m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); + } else { + m_pOwner->SetSelectionDirect(hItem, TRUE); + } + } else { + m_pOwner->SetSelection(hItem, hItem, TRUE); + m_pOwner->m_hAnchor = hItem; + } + } else { + m_pOwner->SetSelection(hItem, hItem, TRUE); + } + if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { + FWL_HLISTITEM hSelectedItem = + m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFX_RectF rtCheck; + m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck); + FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem); + if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (bChecked) { + m_pOwner->SetItemChecked(hItem, FALSE); + } else { + m_pOwner->SetItemChecked(hItem, TRUE); + } + m_pOwner->Update(); + } + } + m_pOwner->SetFocusItem(hItem); + m_pOwner->ScrollToVisible(hItem); + m_pOwner->SetGrab(TRUE); + m_pOwner->ProcessSelChanged(); + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_bLButtonDown) { + m_pOwner->m_bLButtonDown = FALSE; + m_pOwner->SetGrab(FALSE); + DispatchSelChangedEv(); + } +} +void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) { + if (!m_pOwner->IsShowScrollBar(TRUE)) { + return; + } + IFWL_WidgetDelegate* pDelegate = + m_pOwner->m_pVertScrollBar->SetDelegate(NULL); + pDelegate->OnProcessMessage(pMsg); +} +void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { + FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; + switch (dwKeyCode) { + case FWL_VKEY_Tab: + case FWL_VKEY_Up: + case FWL_VKEY_Down: + case FWL_VKEY_Home: + case FWL_VKEY_End: { + FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem(); + hItem = m_pOwner->GetItem(hItem, dwKeyCode); + FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; + FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; + OnVK(hItem, bShift, bCtrl); + DispatchSelChangedEv(); + m_pOwner->ProcessSelChanged(); + break; + } + default: {} + } +} +void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, + FX_BOOL bShift, + FX_BOOL bCtrl) { + if (!hItem) { + return; + } + if (m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_LTB_MultiSelection) { + if (bCtrl) { + } else if (bShift) { + if (m_pOwner->m_hAnchor) { + m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); + } else { + m_pOwner->SetSelectionDirect(hItem, TRUE); + } + } else { + m_pOwner->SetSelection(hItem, hItem, TRUE); + m_pOwner->m_hAnchor = hItem; + } + } else { + m_pOwner->SetSelection(hItem, hItem, TRUE); + } + m_pOwner->SetFocusItem(hItem); + m_pOwner->ScrollToVisible(hItem); + { + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, + m_pOwner->m_pProperties->m_rtWidget.height); + m_pOwner->Repaint(&rtInvalidate); + } +} +FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, + FX_DWORD dwCode, + FX_FLOAT fPos) { + CFX_SizeF fs; + pScrollBar->GetRange(fs.x, fs.y); + FX_FLOAT iCurPos = pScrollBar->GetPos(); + FX_FLOAT fStep = pScrollBar->GetStepSize(); + switch (dwCode) { + case FWL_SCBCODE_Min: { + fPos = fs.x; + break; + } + case FWL_SCBCODE_Max: { + fPos = fs.y; + break; + } + case FWL_SCBCODE_StepBackward: { + fPos -= fStep; + if (fPos < fs.x + fStep / 2) { + fPos = fs.x; + } + break; + } + case FWL_SCBCODE_StepForward: { + fPos += fStep; + if (fPos > fs.y - fStep / 2) { + fPos = fs.y; + } + break; + } + case FWL_SCBCODE_PageBackward: { + fPos -= pScrollBar->GetPageSize(); + if (fPos < fs.x) { + fPos = fs.x; + } + break; + } + case FWL_SCBCODE_PageForward: { + fPos += pScrollBar->GetPageSize(); + if (fPos > fs.y) { + fPos = fs.y; + } + break; + } + case FWL_SCBCODE_Pos: + case FWL_SCBCODE_TrackPos: + break; + case FWL_SCBCODE_EndScroll: + return FALSE; + } + if (iCurPos != fPos) { + pScrollBar->SetPos(fPos); + pScrollBar->SetTrackPos(fPos); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + return TRUE; +} +void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { + CFWL_EvtLtbSelChanged ev; + ev.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&ev); +} diff --git a/xfa/fwl/basewidget/fwl_listboximp.h b/xfa/fwl/basewidget/fwl_listboximp.h new file mode 100644 index 0000000000..a78faf3d13 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_listboximp.h @@ -0,0 +1,121 @@ +// 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_FWL_LISTBOXIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ + +#include <memory> + +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_combobox.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/basewidget/fwl_listbox.h" +#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" + +class CFWL_ListBoxImpDelegate; + +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 FX_DWORD 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 FX_DWORD 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); + + protected: + FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode); + void SetSelection(FWL_HLISTITEM hStart, + FWL_HLISTITEM hEnd, + FX_BOOL bSelected); + void SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect); + FX_BOOL IsItemSelected(FWL_HLISTITEM hItem); + void ClearSelection(); + void SelectAll(); + FWL_HLISTITEM GetFocusedItem(); + void SetFocusItem(FWL_HLISTITEM hItem); + FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + FX_BOOL GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF& rtCheck); + FX_BOOL SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked); + FX_BOOL GetItemChecked(FWL_HLISTITEM hItem); + FX_BOOL ScrollToVisible(FWL_HLISTITEM hItem); + void DrawBkground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawItems(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawItem(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FWL_HLISTITEM hItem, + int32_t Index, + const CFX_RectF& rtItem, + const CFX_Matrix* pMatrix = NULL); + void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); + CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); + void GetItemSize(CFX_SizeF& size, + FWL_HLISTITEM hItem, + FX_FLOAT fWidth, + FX_FLOAT fHeight, + FX_BOOL bAutoSize = FALSE); + FX_FLOAT GetMaxTextWidth(); + 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; + std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; + std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; + FX_DWORD m_dwTTOStyles; + int32_t m_iTTOAligns; + FWL_HLISTITEM m_hAnchor; + FX_FLOAT m_fItemHeight; + 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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + void OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl); + FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos); + void DispatchSelChangedEv(); + CFWL_ListBoxImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp new file mode 100644 index 0000000000..e6dad35481 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp @@ -0,0 +1,1098 @@ +// 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/basewidget/fwl_monthcalendarimp.h" + +#include <algorithm> + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +#define MONTHCAL_HSEP_HEIGHT 1 +#define MONTHCAL_VSEP_WIDTH 1 +#define MONTHCAL_HMARGIN 3 +#define MONTHCAL_VMARGIN 2 +#define MONTHCAL_ROWS 9 +#define MONTHCAL_COLUMNS 7 +#define MONTHCAL_HEADER_BTN_VMARGIN 7 +#define MONTHCAL_HEADER_BTN_HMARGIN 5 + +// static +IFWL_MonthCalendar* IFWL_MonthCalendar::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_MonthCalendar* pMonthCalendar = new IFWL_MonthCalendar; + CFWL_MonthCalendarImp* pMonthCalendarImpl = + new CFWL_MonthCalendarImp(properties, pOuter); + pMonthCalendar->SetImpl(pMonthCalendarImpl); + pMonthCalendarImpl->SetInterface(pMonthCalendar); + return pMonthCalendar; +} +IFWL_MonthCalendar::IFWL_MonthCalendar() {} +int32_t IFWL_MonthCalendar::CountSelect() { + return static_cast<CFWL_MonthCalendarImp*>(GetImpl())->CountSelect(); +} +FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear, + int32_t& iMonth, + int32_t& iDay, + int32_t nIndex) { + return static_cast<CFWL_MonthCalendarImp*>(GetImpl()) + ->GetSelect(iYear, iMonth, iDay, nIndex); +} +FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + return static_cast<CFWL_MonthCalendarImp*>(GetImpl()) + ->SetSelect(iYear, iMonth, iDay); +} + +CFWL_MonthCalendarImp::CFWL_MonthCalendarImp( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_iCurYear(2011), + m_iCurMonth(1), + m_iYear(2011), + m_iMonth(1), + m_iDay(1), + m_iHovered(-1), + m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal), + m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal) { + m_rtHead.Reset(); + m_rtWeek.Reset(); + m_rtLBtn.Reset(); + m_rtRBtn.Reset(); + m_rtDates.Reset(); + m_rtHSep.Reset(); + m_rtHeadText.Reset(); + m_rtToday.Reset(); + m_rtTodayFlag.Reset(); + m_rtClient.Reset(); + m_rtWeekNum.Reset(); + m_rtWeekNumSep.Reset(); + m_pDateTime = new CFX_DateTime; + 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 { + wsClass = FWL_CLASS_MonthCalendar; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_MonthCalendarImp::GetClassID() const { + return FWL_CLASSHASH_MonthCalendar; +} +FWL_ERR CFWL_MonthCalendarImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_MonthCalendarImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_MonthCalendarImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect, + FX_BOOL bAutoSize) { + if (bAutoSize) { + CFX_SizeF fs = CalcSize(TRUE); + rect.Set(0, 0, fs.x, fs.y); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_MonthCalendarImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + GetCapValue(); + if (!m_bInit) { + m_bInit = InitDate(); + } + ClearDateItem(); + ReSetDateItem(); + LayOut(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_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); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_MCD_Edge, pTheme, pMatrix); + } + DrawBkground(pGraphics, pTheme, pMatrix); + DrawHeadBK(pGraphics, pTheme, pMatrix); + DrawLButton(pGraphics, pTheme, pMatrix); + DrawRButton(pGraphics, pTheme, pMatrix); + DrawSeperator(pGraphics, pTheme, pMatrix); + DrawDatesInBK(pGraphics, pTheme, pMatrix); + DrawDatesInCircle(pGraphics, pTheme, pMatrix); + DrawCaption(pGraphics, pTheme, pMatrix); + DrawWeek(pGraphics, pTheme, pMatrix); + DrawDatesIn(pGraphics, pTheme, pMatrix); + DrawDatesOut(pGraphics, pTheme, pMatrix); + DrawToday(pGraphics, pTheme, pMatrix); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { + DrawWeekNumberSep(pGraphics, pTheme, pMatrix); + DrawWeekNumber(pGraphics, pTheme, pMatrix); + } + return FWL_ERR_Succeeded; +} +int32_t CFWL_MonthCalendarImp::CountSelect() { + return m_arrSelDays.GetSize(); +} +FX_BOOL CFWL_MonthCalendarImp::GetSelect(int32_t& iYear, + int32_t& iMonth, + int32_t& iDay, + int32_t nIndex) { + if (nIndex >= m_arrSelDays.GetSize()) { + return FALSE; + } + iYear = m_iCurYear; + iMonth = m_iCurMonth; + iDay = m_arrSelDays[nIndex]; + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::SetSelect(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + ChangeToMonth(iYear, iMonth); + return AddSelDay(iDay); +} +void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_Background; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_rtPart = m_rtClient; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_Header; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_rtPart = m_rtHead; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_LBtn; + params.m_pGraphics = pGraphics; + params.m_dwStates = m_iLBtnPartStates; + params.m_rtPart = m_rtLBtn; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_RBtn; + params.m_pGraphics = pGraphics; + params.m_dwStates = m_iRBtnPartStates; + params.m_rtPart = m_rtRBtn; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + 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_pGraphics = pGraphics; + int32_t iYear; + int32_t iMonth; + iYear = m_iCurYear; + iMonth = m_iCurMonth; + CFX_WideString wsCation; + GetHeadText(iYear, iMonth, wsCation); + textParam.m_wsText = wsCation; + m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider); + CalcHeadSize(); + textParam.m_rtPart = m_rtHeadText; + textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center; + if (pMatrix) { + textParam.m_matrix.Concat(*pMatrix); + } + pTheme->DrawText(&textParam); +} +void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_HSeparator; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_rtPart = m_rtHSep; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_DateInBK; + params.m_pGraphics = pGraphics; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + int32_t iCount = m_arrDates.GetSize(); + 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; + if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) == + 0) && + pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { + params.m_dwStates |= FWL_PARTSTATE_MCD_Flagged; + } + if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) { + params.m_dwStates |= FWL_PARTSTATE_MCD_Focused; + } + } else if (j == m_iHovered - 1) { + params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered; + } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { + params.m_dwStates = FWL_PARTSTATE_MCD_Flagged; + pTheme->DrawBackground(¶ms); + } + params.m_rtPart = pDataInfo->rect; + pTheme->DrawBackground(¶ms); + params.m_dwStates = 0; + } +} +void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeText params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_Week; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; + CFX_RectF rtDayOfWeek; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + 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(¶ms, i + FWL_MCCAPACITY_Sun)); + params.m_rtPart = rtDayOfWeek; + params.m_wsText = *wsWeekDay; + params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + pTheme->DrawText(¶ms); + } +} +void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeText params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_WeekNum; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + CFX_WideString wsWeekNum; + params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + int32_t iWeekNum = 0; + int32_t iMonthNum = m_pDateTime->GetMonth(); + int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); + int32_t iTemp = 0; + FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei; + FX_FLOAT fHStartPos = m_rtClient.left; + for (int32_t i = 1; i <= iDayNum; i += 7) { + iTemp++; + iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i); + m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, + m_fWeekNumWid, m_fDateCellHei); + wsWeekNum.Format(L"%d", iWeekNum); + params.m_wsText = wsWeekNum; + params.m_rtPart = m_rtWeekNum; + pTheme->DrawText(¶ms); + } +} +void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_WeekNumSep; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_rtPart = m_rtWeekNumSep; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { + return; + } + CFWL_ThemeText params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_Today; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + CFX_WideString* wsDay = static_cast<CFX_WideString*>( + pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today)); + CFX_WideString wsText; + GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); + params.m_wsText = *wsDay + wsText; + m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); + CalcTodaySize(); + params.m_rtPart = m_rtToday; + params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawText(¶ms); +} +void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeText params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_DatesIn; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + int32_t iCount = m_arrDates.GetSize(); + for (int32_t j = 0; j < iCount; j++) { + FWL_DATEINFO* pDataInfo = (FWL_DATEINFO*)m_arrDates.GetAt(j); + params.m_wsText = pDataInfo->wsDay; + params.m_rtPart = pDataInfo->rect; + params.m_dwStates = pDataInfo->dwStates; + if (j + 1 == m_iHovered) { + params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered; + } + params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + pTheme->DrawText(¶ms); + } +} +void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeText params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_DatesOut; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawText(¶ms); +} +void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { + return; + } + if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) { + return; + } + if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) { + return; + } + FWL_DATEINFO* pDate = (FWL_DATEINFO*)m_arrDates[m_iDay - 1]; + if (!pDate) + return; + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_DateInCircle; + params.m_pGraphics = pGraphics; + params.m_rtPart = pDate->rect; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { + return; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { + return; + } + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_MCD_TodayCircle; + params.m_pGraphics = pGraphics; + params.m_dwStates = FWL_PARTSTATE_MCD_Normal; + params.m_rtPart = m_rtTodayFlag; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶ms); +} +CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) { + if (!m_pProperties->m_pThemeProvider) + return CFX_SizeF(); + + if (!bAutoSize) { + GetClientRect(m_rtClient); + return CFX_SizeF(m_rtClient.width, m_rtClient.height); + } + + CFX_SizeF fs; + 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 (FX_DWORD week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) { + wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, week)); + CFX_SizeF sz = CalcTextSize(*wsText, 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++) { + CFX_WideString wsDay; + wsDay.Format(L"%d", day); + CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider); + fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x; + fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y; + } + m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5) + : (int)(fDayMaxW + 0.5)); + m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH; + fs.x = m_szCell.x * MONTHCAL_COLUMNS + + MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 + + MONTHCAL_HEADER_BTN_HMARGIN * 2; + FX_FLOAT fMonthMaxW = 0.0f; + FX_FLOAT fMonthMaxH = 0.0f; + for (FX_DWORD month = FWL_MCCAPACITY_January; + month <= FWL_MCCAPACITY_December; month++) { + wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, month)); + CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); + fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; + fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; + } + CFX_WideString wsYear; + GetHeadText(m_iYear, m_iMonth, wsYear); + CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); + fMonthMaxH = std::max(fMonthMaxH, szYear.y); + m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH); + fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2; + 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(¶ms, FWL_MCCAPACITY_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; + fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + + MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4; + return fs; +} + +void CFWL_MonthCalendarImp::CalcHeadSize() { + FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2; + FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2; + m_rtHeadText.Set(m_rtClient.left + fHeadHMargin, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + + MONTHCAL_VMARGIN + fHeadVMargin, + m_szHead.x, m_szHead.y); +} +void CFWL_MonthCalendarImp::CalcTodaySize() { + m_rtTodayFlag.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, + m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, + m_szCell.x, m_szToday.y); + m_rtToday.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + + MONTHCAL_HMARGIN * 2, + m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, + m_szToday.x, m_szToday.y); +} +void CFWL_MonthCalendarImp::LayOut() { + GetClientRect(m_rtClient); + { + m_rtHead.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); + m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtHead.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y + MONTHCAL_VMARGIN * 2); + m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - + MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtHSep.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, + m_rtWeek.bottom() - MONTHCAL_VMARGIN, + m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, + MONTHCAL_HSEP_HEIGHT); + m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtWeek.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y * (MONTHCAL_ROWS - 3) + + MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); + } + CalDateItem(); +} +void CFWL_MonthCalendarImp::CalDateItem() { + FX_BOOL bNewWeek = FALSE; + int32_t iWeekOfMonth = 0; + FX_FLOAT fLeft = m_rtDates.left; + FX_FLOAT fTop = m_rtDates.top; + int32_t iCount = m_arrDates.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(i); + if (bNewWeek) { + iWeekOfMonth++; + bNewWeek = FALSE; + } + pDateInfo->rect.Set( + fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), + fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), + m_szCell.x + (MONTHCAL_HMARGIN * 2), + m_szCell.y + (MONTHCAL_VMARGIN * 2)); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { + pDateInfo->rect.Offset(m_fWeekNumWid, 0); + } + if (pDateInfo->iDayOfWeek >= 6) { + bNewWeek = TRUE; + } + } +} +void CFWL_MonthCalendarImp::GetCapValue() { + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + CFWL_ThemePart part; + part.m_pWidget = m_pInterface; + m_fHeadWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_WIDTH)); + m_fHeadHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_Height)); + m_fHeadBtnWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH)); + m_fHeadBtnHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT)); + m_fHeadBtnHMargin = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN)); + m_fHeadBtnVMargin = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN)); + m_fHeadTextWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT)); + m_fHeadTextHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT)); + m_fHeadTextHMargin = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN)); + m_fHeadTextVMargin = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN)); + m_fHSepWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_WIDTH)); + m_fHSepHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_HEIGHT)); + m_fWeekNumWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH)); + m_fSepDOffset = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_DOFFSET)); + m_fSepX = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_X)); + m_fSepY = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_Y)); + m_fWeekNumHeigh = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT)); + m_fWeekWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_WIDTH)); + m_fWeekHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_HEIGHT)); + m_fDateCellWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH)); + m_fDateCellHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT)); + m_fTodayWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_WIDHT)); + m_fTodayHei = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_HEIGHT)); + m_fTodayFlagWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT)); + m_fMCWid = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_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)); +} +int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + return 0; +} +FX_BOOL CFWL_MonthCalendarImp::GetMinDate(int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) { + iYear = m_dtMin.iYear; + iMonth = m_dtMin.iMonth; + iDay = m_dtMin.iDay; + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::SetMinDate(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + m_dtMin = DATE(iYear, iMonth, iDay); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::GetMaxDate(int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) { + iYear = m_dtMax.iYear; + iMonth = m_dtMax.iMonth; + iDay = m_dtMax.iDay; + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::SetMaxDate(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + m_dtMax = DATE(iYear, iMonth, iDay); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::InitDate() { + if (m_pProperties->m_pDataProvider) { + IFWL_MonthCalendarDP* pDateProv = + static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); + m_iYear = pDateProv->GetCurYear(m_pInterface); + m_iMonth = pDateProv->GetCurMonth(m_pInterface); + m_iDay = pDateProv->GetCurDay(m_pInterface); + m_iCurYear = m_iYear; + m_iCurMonth = m_iMonth; + } else { + m_iDay = 1; + m_iMonth = 1; + m_iYear = 1; + m_iCurYear = m_iYear; + m_iCurMonth = m_iMonth; + } + GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); + GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); + m_dtMin = DATE(1500, 12, 1); + m_dtMax = DATE(2200, 1, 1); + return TRUE; +} +void CFWL_MonthCalendarImp::ClearDateItem() { + int32_t iCount = m_arrDates.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + FWL_DATEINFO* pData = (FWL_DATEINFO*)m_arrDates.GetAt(i); + delete pData; + } + m_arrDates.RemoveAll(); +} +void CFWL_MonthCalendarImp::ReSetDateItem() { + m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); + int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); + int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); + for (int32_t i = 0; i < iDays; i++) { + if (iDayOfWeek >= 7) { + iDayOfWeek = 0; + } + CFX_WideString wsDay; + wsDay.Format(L"%d", i + 1); + FX_DWORD dwStates = 0; + if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { + dwStates |= FWL_ITEMSTATE_MCD_Flag; + } + if (m_arrSelDays.Find(i + 1) != -1) { + dwStates |= FWL_ITEMSTATE_MCD_Selected; + } + CFX_RectF rtDate; + rtDate.Set(0, 0, 0, 0); + m_arrDates.Add( + new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); + iDayOfWeek++; + } +} +FX_BOOL CFWL_MonthCalendarImp::NextMonth() { + int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; + if (iMonth >= 12) { + iMonth = 1; + iYear++; + } else { + iMonth++; + } + DATE dt(m_iCurYear, m_iCurMonth, 1); + if (!(dt < m_dtMax)) { + return FALSE; + } + m_iCurYear = iYear, m_iCurMonth = iMonth; + ChangeToMonth(m_iCurYear, m_iCurMonth); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::PrevMonth() { + int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; + if (iMonth <= 1) { + iMonth = 12; + iYear--; + } else { + iMonth--; + } + DATE dt(m_iCurYear, m_iCurMonth, 1); + if (!(dt > m_dtMin)) { + return FALSE; + } + m_iCurYear = iYear, m_iCurMonth = iMonth; + ChangeToMonth(m_iCurYear, m_iCurMonth); + return TRUE; +} +void CFWL_MonthCalendarImp::ChangeToMonth(int32_t iYear, int32_t iMonth) { + m_iCurYear = iYear; + m_iCurMonth = iMonth; + m_iHovered = -1; + ClearDateItem(); + ReSetDateItem(); + CalDateItem(); + GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); +} +FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll) { + if (iDay == -1 && !bAll) { + return FALSE; + } + if (bAll) { + int32_t iCount = m_arrSelDays.GetSize(); + int32_t iDatesCount = m_arrDates.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + int32_t iSelDay = m_arrSelDays.GetAt(i); + if (iSelDay <= iDatesCount) { + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iSelDay - 1); + pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; + } + } + m_arrSelDays.RemoveAll(); + } else { + int32_t index = m_arrSelDays.Find(iDay); + if (index == -1) { + return FALSE; + } + int32_t iSelDay = m_arrSelDays.GetAt(iDay); + int32_t iDatesCount = m_arrDates.GetSize(); + if (iSelDay <= iDatesCount) { + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iSelDay - 1); + pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; + } + m_arrSelDays.RemoveAt(index); + } + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay) { + FXSYS_assert(iDay > 0); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { + } else { + if (m_arrSelDays.Find(iDay) == -1) { + RemoveSelDay(-1, TRUE); + if (iDay <= m_arrDates.GetSize()) { + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iDay - 1); + pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; + } + m_arrSelDays.Add(iDay); + } + } + return TRUE; +} +FX_BOOL CFWL_MonthCalendarImp::JumpToToday() { + if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { + m_iCurYear = m_iYear; + m_iCurMonth = m_iMonth; + ChangeToMonth(m_iYear, m_iMonth); + AddSelDay(m_iDay); + } else { + if (m_arrSelDays.Find(m_iDay) == -1) { + AddSelDay(m_iDay); + } + } + return TRUE; +} +void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear, + int32_t iMonth, + CFX_WideString& wsHead) { + FXSYS_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", + L"September", L"October", L"November", L"December"}; + wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear); +} +void CFWL_MonthCalendarImp::GetTodayText(int32_t iYear, + int32_t iMonth, + int32_t iDay, + CFX_WideString& wsToday) { + wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear); +} +int32_t CFWL_MonthCalendarImp::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { + int32_t iCount = m_arrDates.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(i); + if (pDateInfo->rect.Contains(x, y)) { + return ++i; + } + } + return -1; +} +FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { + if (iDay <= 0 || iDay > m_arrDates.GetSize()) { + return FALSE; + } + FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates[iDay - 1]; + if (!pDateInfo) + return FALSE; + rtDay = pDateInfo->rect; + return TRUE; +} +CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( + CFWL_MonthCalendarImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( + CFWL_Message* pMessage) { + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Key: { + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMouse->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMouse); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMouse); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMouse); + break; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMouse); + 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::OnActivate(CFWL_Message* pMsg) {} + +void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +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->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->NextMonth(); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { + if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == + 0) { + m_pOwner->JumpToToday(); + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } + } else { + if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { + } else { + int32_t iOldSel = 0; + if (m_pOwner->m_arrSelDays.GetSize() > 0) { + iOldSel = m_pOwner->m_arrSelDays[0]; + } else { + return; + } + int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel; + if (bSelChanged) { + FWL_DATEINFO* lpDatesInfo = + (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iCurSel - 1); + CFX_RectF rtInvalidate(lpDatesInfo->rect); + if (iOldSel > 0) { + lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); + rtInvalidate.Union(lpDatesInfo->rect); + } + m_pOwner->AddSelDay(iCurSel); + CFWL_EvtClick wmClick; + wmClick.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&wmClick); + CFWL_EventMcdDateChanged wmDateSelected; + wmDateSelected.m_iStartDay = iCurSel; + wmDateSelected.m_iEndDay = iCurSel; + wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth; + wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear; + wmDateSelected.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&wmDateSelected); + m_pOwner->Repaint(&rtInvalidate); + } + } + } +} +void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iLBtnPartStates = 0; + m_pOwner->Repaint(&m_pOwner->m_rtLBtn); + } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_iRBtnPartStates = 0; + m_pOwner->Repaint(&m_pOwner->m_rtRBtn); + } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { + int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + if (iDay != -1) { + m_pOwner->AddSelDay(iDay); + } + } +} +void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { + return; + } + FX_BOOL bRepaint = FALSE; + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, 0, 0); + if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { + int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + bRepaint = m_pOwner->m_iHovered != iHover; + if (bRepaint) { + if (m_pOwner->m_iHovered > 0) { + m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); + } + if (iHover > 0) { + CFX_RectF rtDay; + m_pOwner->GetDayRect(iHover, rtDay); + if (rtInvalidate.IsEmpty()) { + rtInvalidate = rtDay; + } else { + rtInvalidate.Union(rtDay); + } + } + } + m_pOwner->m_iHovered = iHover; + } else { + bRepaint = m_pOwner->m_iHovered > 0; + if (bRepaint) { + m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); + } + m_pOwner->m_iHovered = -1; + } + if (bRepaint && !rtInvalidate.IsEmpty()) { + m_pOwner->Repaint(&rtInvalidate); + } +} +void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_iHovered > 0) { + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, 0, 0); + m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); + m_pOwner->m_iHovered = -1; + if (!rtInvalidate.IsEmpty()) { + m_pOwner->Repaint(&rtInvalidate); + } + } +} diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.h b/xfa/fwl/basewidget/fwl_monthcalendarimp.h new file mode 100644 index 0000000000..c9542cb599 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.h @@ -0,0 +1,243 @@ +// 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_FWL_MONTHCALENDARIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ + +#include "xfa/fgas/localization/fgas_datetime.h" +#include "xfa/fwl/core/fwl_widgetimp.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_MonthCalendarImpDelegate; + +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 FX_DWORD 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); + + protected: + struct DATE { + DATE() : iYear(0), iMonth(0), iDay(0) {} + DATE(int32_t year, int32_t month, int32_t day) + : iYear(year), iMonth(month), iDay(day) {} + FX_BOOL operator<(const DATE& right) { + if (iYear < right.iYear) { + return TRUE; + } else if (iYear == right.iYear) { + if (iMonth < right.iMonth) { + return TRUE; + } else if (iMonth == right.iMonth) { + return iDay < right.iDay; + } + } + return FALSE; + } + FX_BOOL operator>(const DATE& right) { + if (iYear > right.iYear) { + return TRUE; + } else if (iYear == right.iYear) { + if (iMonth > right.iMonth) { + return TRUE; + } else if (iMonth == right.iMonth) { + return iDay > right.iDay; + } + } + return FALSE; + } + int32_t iYear; + int32_t iMonth; + int32_t iDay; + }; + + void DrawBkground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawHeadBK(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawLButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawRButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawCaption(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawSeperator(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawDatesInBK(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawWeek(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawWeekNumber(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawWeekNumberSep(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawToday(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawDatesIn(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawDatesOut(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawDatesInCircle(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + void DrawTodayCircle(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); + CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); + void LayOut(); + void CalcHeadSize(); + void CalcTodaySize(); + void CalDateItem(); + void GetCapValue(); + int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay); + FX_BOOL GetMinDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); + FX_BOOL SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay); + FX_BOOL GetMaxDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); + FX_BOOL SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay); + FX_BOOL InitDate(); + void ClearDateItem(); + void ReSetDateItem(); + FX_BOOL NextMonth(); + FX_BOOL PrevMonth(); + void ChangeToMonth(int32_t iYear, int32_t iMonth); + FX_BOOL RemoveSelDay(int32_t iDay, FX_BOOL bAll = FALSE); + FX_BOOL AddSelDay(int32_t iDay); + FX_BOOL JumpToToday(); + void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); + void GetTodayText(int32_t iYear, + int32_t iMonth, + int32_t iDay, + CFX_WideString& wsToday); + int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); + FX_BOOL GetDayRect(int32_t iDay, CFX_RectF& rtDay); + + FX_BOOL m_bInit; + CFX_RectF m_rtHead; + CFX_RectF m_rtWeek; + CFX_RectF m_rtLBtn; + CFX_RectF m_rtRBtn; + CFX_RectF m_rtDates; + CFX_RectF m_rtHSep; + CFX_RectF m_rtHeadText; + CFX_RectF m_rtToday; + CFX_RectF m_rtTodayFlag; + CFX_RectF m_rtWeekNum; + CFX_RectF m_rtWeekNumSep; + CFX_RectF m_rtTemp; + CFX_WideString m_wsHead; + CFX_WideString m_wsToday; + CFX_DateTime* m_pDateTime; + CFX_PtrArray m_arrDates; + int32_t m_iCurYear; + int32_t m_iCurMonth; + int32_t m_iYear; + int32_t m_iMonth; + int32_t m_iDay; + int32_t m_iHovered; + int32_t m_iLBtnPartStates; + int32_t m_iRBtnPartStates; + DATE m_dtMin; + DATE m_dtMax; + CFX_SizeF m_szHead; + CFX_SizeF m_szCell; + CFX_SizeF m_szToday; + CFX_ArrayTemplate<int32_t> m_arrSelDays; + int32_t m_iMaxSel; + CFX_RectF m_rtClient; + FX_FLOAT m_fHeadWid; + FX_FLOAT m_fHeadHei; + FX_FLOAT m_fHeadBtnWid; + FX_FLOAT m_fHeadBtnHei; + FX_FLOAT m_fHeadBtnHMargin; + FX_FLOAT m_fHeadBtnVMargin; + FX_FLOAT m_fHeadTextWid; + FX_FLOAT m_fHeadTextHei; + FX_FLOAT m_fHeadTextHMargin; + FX_FLOAT m_fHeadTextVMargin; + FX_FLOAT m_fHSepWid; + FX_FLOAT m_fHSepHei; + FX_FLOAT m_fWeekNumWid; + FX_FLOAT m_fSepDOffset; + FX_FLOAT m_fSepX; + FX_FLOAT m_fSepY; + FX_FLOAT m_fWeekNumHeigh; + FX_FLOAT m_fWeekWid; + FX_FLOAT m_fWeekHei; + FX_FLOAT m_fDateCellWid; + FX_FLOAT m_fDateCellHei; + FX_FLOAT m_fTodayWid; + FX_FLOAT m_fTodayHei; + FX_FLOAT m_fTodayFlagWid; + FX_FLOAT m_fMCWid; + FX_FLOAT m_fMCHei; + friend class CFWL_MonthCalendarImpDelegate; +}; + +struct FWL_DATEINFO { + FWL_DATEINFO(int32_t day, + int32_t dayofweek, + FX_DWORD dwSt, + CFX_RectF rc, + CFX_WideString& wsday) + : iDay(day), + iDayOfWeek(dayofweek), + dwStates(dwSt), + rect(rc), + wsDay(wsday) {} + int32_t iDay; + int32_t iDayOfWeek; + FX_DWORD dwStates; + CFX_RectF rect; + CFX_WideString wsDay; +}; + +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; + + protected: + void OnActivate(CFWL_Message* pMsg); + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + CFWL_MonthCalendarImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_pictureboximp.cpp b/xfa/fwl/basewidget/fwl_pictureboximp.cpp new file mode 100644 index 0000000000..a9dd440ccd --- /dev/null +++ b/xfa/fwl/basewidget/fwl_pictureboximp.cpp @@ -0,0 +1,151 @@ +// 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/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/include/fwl/lightwidget/picturebox.h" + +// static +IFWL_PictureBox* IFWL_PictureBox::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_PictureBox* pPictureBox = new IFWL_PictureBox; + CFWL_PictureBoxImp* pPictureBoxImpl = + new CFWL_PictureBoxImp(properties, pOuter); + pPictureBox->SetImpl(pPictureBoxImpl); + pPictureBoxImpl->SetInterface(pPictureBox); + return pPictureBox; +} +IFWL_PictureBox::IFWL_PictureBox() {} + +CFWL_PictureBoxImp::CFWL_PictureBoxImp( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_bTop(FALSE), + m_bVCenter(FALSE), + m_bButton(FALSE) { + m_rtClient.Reset(); + m_rtImage.Reset(); + m_matrix.SetIdentity(); +} +CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {} +FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_PictureBox; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_PictureBoxImp::GetClassID() const { + return FWL_CLASSHASH_PictureBox; +} +FWL_ERR CFWL_PictureBoxImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_PictureBoxImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PictureBoxImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR 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; + CFX_DIBitmap* pBitmap = + static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) + ->GetPicture(m_pInterface); + if (pBitmap) { + rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), + (FX_FLOAT)pBitmap->GetHeight()); + } + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PictureBoxImp::Update() { + if (IsLocked()) { + return FWL_ERR_Succeeded; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + GetClientRect(m_rtClient); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = GetAvailableTheme(); + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_PTB_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_PTB_Edge, pTheme, pMatrix); + } + DrawBkground(pGraphics, pTheme, pMatrix); + return FWL_ERR_Succeeded; +} +void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + IFWL_PictureBoxDP* pPictureDP = + static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); + if (!pPictureDP) + return; + + CFX_DIBitmap* pPicture = pPictureDP->GetPicture(m_pInterface); + CFX_Matrix matrix; + pPictureDP->GetMatrix(m_pInterface, matrix); + if (!pPicture) + return; + + matrix.Concat(*pMatrix); + FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth(); + FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight(); + if (fx > m_rtClient.width) { + fx = m_rtClient.width; + } + if (fy > m_rtClient.height) { + fy = m_rtClient.height; + } + pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, + (m_rtClient.height - fy) / 2), + &matrix); +} +FX_BOOL CFWL_PictureBoxImp::VStyle(FX_BOOL dwStyle) { + switch (dwStyle & FWL_STYLEEXT_PTB_VAlignMask) { + case FWL_STYLEEXT_PTB_Top: { + return m_bTop = TRUE; + break; + } + case FWL_STYLEEXT_PTB_Vcenter: { + return m_bVCenter = TRUE; + break; + } + case FWL_STYLEEXT_PTB_Bottom: { + return m_bButton = TRUE; + break; + } + } + 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); +} diff --git a/xfa/fwl/basewidget/fwl_pictureboximp.h b/xfa/fwl/basewidget/fwl_pictureboximp.h new file mode 100644 index 0000000000..c848e980af --- /dev/null +++ b/xfa/fwl/basewidget/fwl_pictureboximp.h @@ -0,0 +1,53 @@ +// 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_FWL_PICTUREBOXIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_PictureBoxImpDelegate; + +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 FX_DWORD 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); + + protected: + 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; + CFX_Matrix m_matrix; + 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; + + protected: + CFWL_PictureBoxImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp new file mode 100644 index 0000000000..ac0055b215 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp @@ -0,0 +1,550 @@ +// 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/basewidget/fwl_pushbuttonimp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_pushbutton.h" + +// static +IFWL_PushButton* IFWL_PushButton::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_PushButton* pPushButton = new IFWL_PushButton; + CFWL_PushButtonImp* pPushButtonImpl = + new CFWL_PushButtonImp(properties, pOuter); + pPushButton->SetImpl(pPushButtonImpl); + pPushButtonImpl->SetInterface(pPushButton); + return pPushButton; +} +IFWL_PushButton::IFWL_PushButton() {} + +CFWL_PushButtonImp::CFWL_PushButtonImp( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_bBtnDown(FALSE), + m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), + m_iTTOAlign(FDE_TTOALIGNMENT_Center) { + 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 { + wsClass = FWL_CLASS_PushButton; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_PushButtonImp::GetClassID() const { + return FWL_CLASSHASH_PushButton; +} +FWL_ERR CFWL_PushButtonImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_PushButtonImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PushButtonImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + rect.Set(0, 0, 0, 0); + if (m_pProperties->m_pThemeProvider == NULL) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + CFX_WideString wsCaption; + IFWL_PushButtonDP* pData = + static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); + if (pData) { + pData->GetCaption(m_pInterface, wsCaption); + } + int32_t iLen = wsCaption.GetLength(); + if (iLen > 0) { + CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); + rect.Set(0, 0, sz.x, sz.y); + } + FX_FLOAT* fcaption = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); + rect.Inflate(*fcaption, *fcaption); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { + if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { + m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; + return FWL_ERR_Succeeded; + } + return CFWL_WidgetImp::SetStates(dwStates, bSet); +} +FWL_ERR CFWL_PushButtonImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + UpdateTextOutStyles(); + GetClientRect(m_rtClient); + m_rtCaption = m_rtClient; + FX_FLOAT* fcaption = + static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); + m_rtCaption.Inflate(-*fcaption, -*fcaption); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_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, + pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider, + pMatrix); + } + DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); + CFX_Matrix matrix; + matrix.Concat(*pMatrix); + FX_FLOAT iPicwidth = 0; + FX_FLOAT ipicheight = 0; + CFX_WideString wsCaption; + if (pData) { + pData->GetCaption(m_pInterface, wsCaption); + } + CFX_RectF rtText; + rtText.Set(0, 0, 0, 0); + if (!wsCaption.IsEmpty()) { + CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); + } + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { + case FWL_STYLEEXT_PSB_TextOnly: + DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); + break; + case FWL_STYLEEXT_PSB_IconOnly: + if (pData) { + pPicture = pData->GetPicture(m_pInterface); + } + if (pPicture) { + CFX_PointF point; + switch (m_iTTOAlign) { + case 0: { + point.x = m_rtClient.left; + point.y = m_rtClient.top; + break; + } + case 1: { + point.x = m_rtClient.left + + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); + point.y = m_rtClient.top; + break; + } + case 2: + point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); + point.y = m_rtClient.top; + break; + case 4: + point.x = m_rtClient.left; + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + break; + case 5: + point.x = m_rtClient.left + + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + break; + case 6: + point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + break; + case 8: + point.x = m_rtClient.left; + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + break; + case 9: + point.x = m_rtClient.left + + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + break; + case 10: + point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + break; + } + pGraphics->DrawImage(pPicture, point, &matrix); + } + break; + case FWL_STYLEEXT_PSB_TextIcon: + if (pPicture) { + CFX_PointF point; + switch (m_iTTOAlign) { + case 0: { + point.x = m_rtClient.left; + point.y = m_rtClient.top; + iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); + ipicheight = + pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; + break; + } + case 1: { + point.x = + m_rtClient.left + (m_rtClient.width / 2 - + (pPicture->GetWidth() + rtText.width) / 2); + point.y = m_rtClient.top; + iPicwidth = pPicture->GetWidth() - + ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + + rtText.width / 2 - 7; + ipicheight = + pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; + break; + } + case 2: + point.x = m_rtClient.left + m_rtClient.width - + pPicture->GetWidth() - rtText.width; + point.y = m_rtClient.top; + iPicwidth = m_rtClient.left + m_rtClient.width - point.x - + pPicture->GetWidth() - rtText.width + 7; + ipicheight = + pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; + break; + case 4: + point.x = m_rtClient.left; + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7; + break; + case 5: + point.x = + m_rtClient.left + (m_rtClient.width / 2 - + (pPicture->GetWidth() + rtText.width) / 2); + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + iPicwidth = pPicture->GetWidth() - + ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + + rtText.width / 2 - 7; + break; + case 6: + point.x = m_rtClient.left + m_rtClient.width - + pPicture->GetWidth() - rtText.width; + point.y = m_rtClient.top + m_rtClient.height / 2 - + pPicture->GetHeight() / 2; + iPicwidth = m_rtClient.left + m_rtClient.width - point.x - + pPicture->GetWidth() - rtText.width + 7; + break; + case 8: + point.x = m_rtClient.left; + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); + ipicheight -= rtText.height / 2; + break; + case 9: + point.x = + m_rtClient.left + (m_rtClient.width / 2 - + (pPicture->GetWidth() + rtText.width) / 2); + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + iPicwidth = pPicture->GetWidth() - + ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + + rtText.width / 2 - 7; + ipicheight -= rtText.height / 2; + break; + case 10: + point.x = m_rtClient.left + m_rtClient.width - + pPicture->GetWidth() - rtText.width; + point.y = + m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); + iPicwidth = m_rtClient.left + m_rtClient.width - point.x - + pPicture->GetWidth() - rtText.width + 7; + ipicheight -= rtText.height / 2; + break; + } + pGraphics->DrawImage(pPicture, point, &matrix); + } + matrix.e += m_rtClient.left + iPicwidth; + matrix.f += m_rtClient.top + ipicheight; + DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); + break; + } + return FWL_ERR_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_dwStates = GetPartStates(); + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtClient; + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + param.m_pData = &m_rtCaption; + } + pTheme->DrawBackground(¶m); +} +void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (!m_pProperties->m_pDataProvider) + return; + CFX_WideString wsCaption; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); + if (wsCaption.IsEmpty()) { + return; + } + CFWL_ThemeText param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_PSB_Caption; + param.m_dwStates = GetPartStates(); + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtCaption; + param.m_wsText = wsCaption; + param.m_dwTTOStyles = m_dwTTOStyles; + param.m_iTTOAlign = m_iTTOAlign; + pTheme->DrawText(¶m); +} +FX_DWORD CFWL_PushButtonImp::GetPartStates() { + FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal; + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + dwStates |= FWL_PARTSTATE_PSB_Focused; + } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + dwStates = FWL_PARTSTATE_PSB_Disabled; + } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { + dwStates |= FWL_PARTSTATE_PSB_Pressed; + } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { + dwStates |= FWL_PARTSTATE_PSB_Hovered; + } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { + dwStates |= FWL_PARTSTATE_PSB_Default; + } + return dwStates; +} +void CFWL_PushButtonImp::UpdateTextOutStyles() { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; + switch (m_pProperties->m_dwStyleExes & + (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { + case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; + break; + } + case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; + break; + } + case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: { + m_iTTOAlign = FDE_TTOALIGNMENT_TopRight; + break; + } + case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + break; + } + case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; + break; + } + case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: { + m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; + break; + } + case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft; + break; + } + case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter; + break; + } + case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: { + m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; + break; + } + default: {} + } + m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + m_dwTTOStyles |= FDE_TTOSTYLE_RTL; + } +} +CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( + CFWL_PushButtonImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + if (!m_pOwner->IsEnabled()) { + return 1; + } + int32_t iRet = 1; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD 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; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); + if (pKey->m_dwCmd == FWL_MSGKEYCMD_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::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { + m_pOwner->SetFocus(TRUE); + } + m_pOwner->m_bBtnDown = TRUE; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + m_pOwner->m_bBtnDown = FALSE; + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; + } else { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; + } + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + CFWL_EvtClick wmClick; + wmClick.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&wmClick); + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + FX_BOOL bRepaint = FALSE; + if (m_pOwner->m_bBtnDown) { + if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; + bRepaint = TRUE; + } + if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; + bRepaint = TRUE; + } + } else { + if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; + bRepaint = TRUE; + } + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; + bRepaint = TRUE; + } + } + } else { + if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + return; + } + if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { + m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; + bRepaint = TRUE; + } + } + if (bRepaint) { + m_pOwner->Repaint(&m_pOwner->m_rtClient); + } +} +void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { + m_pOwner->m_bBtnDown = FALSE; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; + m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +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; + m_pOwner->DispatchEvent(&wmMouse); + CFWL_EvtClick wmClick; + wmClick.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&wmClick); + return; + } + if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) { + return; + } + m_pOwner->DispatchKeyEvent(pMsg); +} diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.h b/xfa/fwl/basewidget/fwl_pushbuttonimp.h new file mode 100644 index 0000000000..32d8f6c4e2 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_pushbuttonimp.h @@ -0,0 +1,65 @@ +// 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_FWL_PUSHBUTTONIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_PushButtonImpDelegate; + +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 FX_DWORD 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(FX_DWORD dwStates, FX_BOOL bSet = TRUE); + virtual FWL_ERR Update(); + virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = NULL); + + 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); + FX_DWORD GetPartStates(); + void UpdateTextOutStyles(); + CFX_RectF m_rtClient; + CFX_RectF m_rtCaption; + FX_BOOL m_bBtnDown; + FX_DWORD 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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + CFWL_PushButtonImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp new file mode 100644 index 0000000000..86c78890d8 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp @@ -0,0 +1,805 @@ +// 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/basewidget/fwl_scrollbarimp.h" + +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +#define FWL_SCROLLBAR_Elapse 500 +#define FWL_SCROLLBAR_MinThumb 5 + +// static +IFWL_ScrollBar* IFWL_ScrollBar::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar; + CFWL_ScrollBarImp* pScrollBarImpl = new CFWL_ScrollBarImp(properties, pOuter); + pScrollBar->SetImpl(pScrollBarImpl); + pScrollBarImpl->SetInterface(pScrollBar); + return pScrollBar; +} +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) { + return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetRange(fMin, fMax); +} +FWL_ERR 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) { + 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) { + 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) { + 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) { + return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); +} +FX_BOOL IFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { + return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); +} +CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : CFWL_WidgetImp(properties, pOuter), + m_hTimer(nullptr), + m_fRangeMin(0), + m_fRangeMax(-1), + m_fPageSize(0), + 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_fLastTrackPos(0), + m_cpTrackPointX(0), + m_cpTrackPointY(0), + m_iMouseWheel(0), + m_bTrackMouseLeave(FALSE), + m_bMouseHover(FALSE), + m_bMouseDown(FALSE), + m_bRepaintThumb(FALSE), + m_fButtonLen(0), + m_bMinSize(FALSE), + m_bCustomLayout(FALSE), + m_fMinThumb(FWL_SCROLLBAR_MinThumb) { + m_rtClient.Reset(); + m_rtThumb.Reset(); + m_rtMinBtn.Reset(); + m_rtMaxBtn.Reset(); + m_rtMinTrack.Reset(); + m_rtMaxTrack.Reset(); +} +CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {} +FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_ScrollBar; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_ScrollBarImp::GetClassID() const { + return FWL_CLASSHASH_ScrollBar; +} +FWL_ERR CFWL_ScrollBarImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_ScrollBarImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ScrollBarImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR 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)); + if (!pfMinWidth) + return FWL_ERR_Indefinite; + if (IsVertical()) { + rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); + } else { + rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); + } + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ScrollBarImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + Layout(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (HasBorder()) { + DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_SCB_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; +} +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) { + fMin = m_fRangeMin; + fMax = m_fRangeMax; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { + m_fRangeMin = fMin; + m_fRangeMax = fMax; + return FWL_ERR_Succeeded; +} +FX_FLOAT CFWL_ScrollBarImp::GetPageSize() { + return m_fPageSize; +} +FWL_ERR CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) { + m_fPageSize = fPageSize; + return FWL_ERR_Succeeded; +} +FX_FLOAT CFWL_ScrollBarImp::GetStepSize() { + return m_fStepSize; +} +FWL_ERR CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) { + m_fStepSize = fStepSize; + return FWL_ERR_Succeeded; +} +FX_FLOAT CFWL_ScrollBarImp::GetPos() { + return m_fPos; +} +FWL_ERR CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) { + m_fPos = fPos; + return FWL_ERR_Succeeded; +} +FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() { + return m_fTrackPos; +} +FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) { + m_fTrackPos = fTrackPos; + CalcThumbButtonRect(m_rtThumb); + CalcMinTrackRect(m_rtMinTrack); + CalcMaxTrackRect(m_rtMaxTrack); + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_ScrollBarImp::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { + switch (dwCode) { + case FWL_SCBCODE_Min: + case FWL_SCBCODE_Max: + case FWL_SCBCODE_PageBackward: + case FWL_SCBCODE_PageForward: + case FWL_SCBCODE_StepBackward: + break; + case FWL_SCBCODE_StepForward: + break; + case FWL_SCBCODE_Pos: + case FWL_SCBCODE_TrackPos: + case FWL_SCBCODE_EndScroll: + break; + default: { return FALSE; } + } + return OnScroll(dwCode, fPos); +} +int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) { + if (m_hTimer) { + FWL_StopTimer(m_hTimer); + } + if (!SendEvent()) { + m_hTimer = FWL_StartTimer(this, 0); + } + return 1; +} +FWL_ERR CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { + m_pOuter = pOuter; + return FWL_ERR_Succeeded; +} +void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FX_BOOL bLower, + 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_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_SCB_Disabled + : (bLower ? m_iMinTrackState : m_iMaxTrackState); + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack; + pTheme->DrawBackground(¶m); +} +void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FX_BOOL bMinBtn, + 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_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_SCB_Disabled + : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState); + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; + if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { + pTheme->DrawBackground(¶m); + } +} +void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (!IsEnabled()) { + } + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_SCB_Thumb; + param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_SCB_Disabled + : m_iThumbButtonState; + param.m_pGraphics = pGraphics; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = m_rtThumb; + pTheme->DrawBackground(¶m); +} +void CFWL_ScrollBarImp::Layout() { + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + CFWL_ThemePart part; + part.m_pWidget = m_pInterface; + m_fMinThumb = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size)); + m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface); + GetClientRect(m_rtClient); + CalcButtonLen(); + CalcMinButtonRect(m_rtMinBtn); + CalcMaxButtonRect(m_rtMaxBtn); + CalcThumbButtonRect(m_rtThumb); + CalcMinTrackRect(m_rtMinTrack); + CalcMaxTrackRect(m_rtMaxTrack); +} +void CFWL_ScrollBarImp::CalcButtonLen() { + m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height; + FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width; + if (fLength < m_fButtonLen * 2) { + m_fButtonLen = fLength / 2; + m_bMinSize = TRUE; + } else { + m_bMinSize = FALSE; + } +} +void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF& rect) { + if (m_bCustomLayout) { + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + CFWL_ThemePart pPart; + pPart.m_rtPart = m_rtMinBtn; + pPart.m_pWidget = m_pInterface; + pPart.m_iPart = FWL_PART_SCB_ForeArrow; + pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_SCB_Disabled + : m_iMinButtonState; + pTheme->GetPartRect(&pPart, rect); + } else { + rect.left = m_rtClient.left; + rect.top = m_rtClient.top; + rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; + rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; + } +} +void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF& rect) { + if (m_bCustomLayout) { + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + CFWL_ThemePart pPart; + pPart.m_rtPart = m_rtMaxBtn; + pPart.m_pWidget = m_pInterface; + pPart.m_iPart = FWL_PART_SCB_BackArrow; + pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) + ? FWL_PARTSTATE_SCB_Disabled + : m_iMaxButtonState; + pTheme->GetPartRect(&pPart, rect); + } else { + rect.left = + IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen; + rect.top = + IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top; + rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; + rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; + } +} +void CFWL_ScrollBarImp::CalcThumbButtonRect(CFX_RectF& rect) { + if (!IsEnabled()) { + m_rtThumb.Reset(); + return; + } + if (m_bMinSize) { + m_rtThumb.Empty(); + return; + } + FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; + memset(&rect, 0, sizeof(CFX_Rect)); + if (fRange < 0) { + if (IsVertical()) { + rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0); + } else { + rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height); + } + return; + } + CFX_RectF rtClient = m_rtClient; + FX_FLOAT fLength = IsVertical() ? rtClient.height : rtClient.width; + FX_FLOAT fSize = m_fButtonLen; + if (m_bCustomLayout) { + if (IsVertical()) { + fLength = fLength - m_rtMinBtn.height - m_rtMaxBtn.height; + if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) { + fLength = 0.0f; + } + } else { + fLength = fLength - m_rtMinBtn.width - m_rtMaxBtn.width; + if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) { + fLength = 0.0f; + } + } + } else { + fLength -= fSize * 2.0f; + if (fLength < fSize) { + fLength = 0.0f; + } + } + FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength); + if (fThumbSize < m_fMinThumb) { + fThumbSize = m_fMinThumb; + } + FX_FLOAT fDiff = fLength - fThumbSize; + if (fDiff < 0.0f) { + fDiff = 0.0f; + } + FX_FLOAT fTrackPos = m_fTrackPos; + if (fTrackPos > m_fRangeMax) { + fTrackPos = m_fRangeMax; + } + if (fTrackPos < m_fRangeMin) { + fTrackPos = m_fRangeMin; + } + if (!fRange) + return; + if (m_bCustomLayout) { + FX_FLOAT iPos = fDiff * (fTrackPos - m_fRangeMin) / fRange; + rect.left = rtClient.left; + if (!IsVertical()) { + if ((m_rtMinBtn.right() == m_rtMaxBtn.left && m_rtMinBtn.width > 0 && + m_rtMaxBtn.width > 0) || + (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width)) { + rect.left += iPos; + } else { + rect.left += m_rtMinBtn.right() + iPos; + } + } + rect.top = rtClient.top; + if (IsVertical()) { + if ((m_rtMinBtn.bottom() == m_rtMaxBtn.top && m_rtMinBtn.height > 0 && + m_rtMaxBtn.height > 0) || + (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height)) { + rect.top += iPos; + } else { + rect.top += m_rtMinBtn.bottom() + iPos; + } + } + rect.width = IsVertical() ? rtClient.width : fThumbSize; + rect.height = IsVertical() ? fThumbSize : rtClient.height; + } else { + FX_FLOAT iPos = fSize + fDiff * (fTrackPos - m_fRangeMin) / fRange; + rect.left = rtClient.left; + if (!IsVertical()) { + rect.left += iPos; + } + rect.top = rtClient.top; + if (IsVertical()) { + rect.top += iPos; + } + rect.width = IsVertical() ? rtClient.width : fThumbSize; + rect.height = IsVertical() ? fThumbSize : rtClient.height; + } +} +void CFWL_ScrollBarImp::CalcMinTrackRect(CFX_RectF& rect) { + if (m_bMinSize) { + rect.Empty(); + return; + } + FX_FLOAT fBottom = m_rtThumb.bottom(); + FX_FLOAT fRight = m_rtThumb.right(); + FX_FLOAT ix = (m_rtThumb.left + fRight) / 2; + FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2; + rect.left = m_rtClient.left; + rect.top = m_rtClient.top; + FX_BOOL bVertical = IsVertical(); + rect.width = bVertical ? m_rtClient.width : ix; + rect.height = bVertical ? iy : m_rtClient.height; + if (m_bCustomLayout) { + if (bVertical) { + if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { + rect.top = m_rtClient.top; + } else if (m_rtMinBtn.top < m_rtThumb.top) { + rect.top = m_rtMinBtn.bottom(); + rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top); + } + } else { + if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { + rect.left = m_rtClient.left; + } else if (m_rtMinBtn.left < m_rtThumb.left) { + rect.left = m_rtMinBtn.right(); + rect.width -= (m_rtMinBtn.right() - m_rtClient.left); + } + } + } +} +void CFWL_ScrollBarImp::CalcMaxTrackRect(CFX_RectF& rect) { + if (m_bMinSize) { + rect.Empty(); + return; + } + FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; + FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; + FX_BOOL bVertical = IsVertical(); + rect.left = bVertical ? m_rtClient.left : ix; + rect.top = bVertical ? iy : m_rtClient.top; + rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix; + rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height; + if (m_bCustomLayout) { + if (bVertical) { + if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && + m_rtMaxBtn.height > 0) { + rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); + } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { + rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); + } + } else { + if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && + m_rtMaxBtn.width > 0) { + rect.width -= (m_rtClient.right() - m_rtMinBtn.left); + } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { + rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); + } + } + } +} +FX_FLOAT CFWL_ScrollBarImp::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { + FX_FLOAT fDiffX = fx - m_cpTrackPointX; + FX_FLOAT fDiffY = fy - m_cpTrackPointY; + FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; + FX_FLOAT fPos; + if (m_bCustomLayout) { + if (IsVertical()) { + if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { + fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height); + } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) { + fPos = fRange * fDiffY / + (m_rtMinBtn.top - m_rtClient.top - m_rtThumb.height); + } else { + fPos = fRange * fDiffY / + (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); + } + } else { + if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { + fPos = fRange * fDiffX / (m_rtClient.width - m_rtThumb.width); + } else if (m_rtMinBtn.right() == m_rtMaxBtn.left) { + fPos = fRange * fDiffX / + (m_rtMinBtn.left - m_rtClient.left - m_rtThumb.width); + } else { + fPos = fRange * fDiffX / + (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); + } + } + } else { + if (IsVertical()) { + fPos = fRange * fDiffY / + (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); + } else { + fPos = fRange * fDiffX / + (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); + } + } + fPos += m_fLastTrackPos; + if (fPos < m_fRangeMin) { + fPos = m_fRangeMin; + } + if (fPos > m_fRangeMax) { + fPos = m_fRangeMax; + } + return fPos; +} +void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) { + FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled; + if (bDisabled || m_bCustomLayout) { + rect = bLower ? m_rtMinTrack : m_rtMaxTrack; + } else { + FX_FLOAT fW = m_rtThumb.width / 2; + FX_FLOAT fH = m_rtThumb.height / 2; + FX_BOOL bVert = IsVertical(); + if (bLower) { + if (bVert) { + FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; + fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f; + rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height, + m_rtMinTrack.width, fMinTrackHeight); + } else { + FX_FLOAT fMinTrackWidth = + m_rtMinTrack.width - fW - m_rtMinBtn.width + 2; + fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f; + rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top, + fMinTrackWidth, m_rtMinTrack.height); + } + } else { + if (bVert) { + FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height; + fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f; + rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width, + fMaxTrackHeight); + } else { + FX_FLOAT fMaxTrackWidth = + m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; + fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; + rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, + m_rtMaxTrack.height); + } + } + } +} +FX_BOOL CFWL_ScrollBarImp::SendEvent() { + if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) { + DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos); + return FALSE; + } + if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) { + DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos); + return FALSE; + } + if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) { + DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos); + return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); + } + if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) { + DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); + return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); + } + if (m_iMouseWheel) { + FX_WORD dwCode = + m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; + DoScroll(dwCode, m_fTrackPos); + } + return TRUE; +} +FX_BOOL CFWL_ScrollBarImp::OnScroll(FX_DWORD dwCode, FX_FLOAT fPos) { + FX_BOOL bRet = TRUE; + CFWL_EvtScroll ev; + ev.m_iScrollCode = dwCode; + ev.m_pSrcTarget = m_pInterface; + ev.m_fPos = fPos; + ev.m_pRet = &bRet; + DispatchEvent(&ev); + return bRet; +} +CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + int32_t iRet = 1; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + if (dwMsgCode == FWL_MSGHASH_Mouse) { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD dwCmd = pMsg->m_dwCmd; + switch (dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + break; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(); + break; + } + default: { iRet = 0; } + } + } else if (dwMsgCode == FWL_MSGHASH_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::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pOwner->IsEnabled()) { + return; + } + m_pOwner->m_bMouseDown = TRUE; + m_pOwner->SetGrab(TRUE); + m_pOwner->m_cpTrackPointX = fx; + m_pOwner->m_cpTrackPointY = fy; + m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos; + if (m_pOwner->m_rtMinBtn.Contains(fx, fy)) { + DoMouseDown(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); + } else { + if (m_pOwner->m_rtThumb.Contains(fx, fy)) { + DoMouseDown(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, + fy); + } else { + if (m_pOwner->m_rtMaxBtn.Contains(fx, fy)) { + DoMouseDown(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, + fy); + } else { + if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) { + DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, + fy); + } else { + DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, + fy); + } + } + } + } + if (!m_pOwner->SendEvent()) { + m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); + } +} +void CFWL_ScrollBarImpDelegate::OnLButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + FWL_StopTimer(m_pOwner->m_hTimer); + m_pOwner->m_bMouseDown = FALSE; + DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); + DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); + DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); + DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); + DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); + m_pOwner->SetGrab(FALSE); +} +void CFWL_ScrollBarImpDelegate::OnMouseMove(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); + DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); + DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); + DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); + DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); +} +void CFWL_ScrollBarImpDelegate::OnMouseLeave() { + DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); + DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); + DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); + DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); + DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); +} +void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, + FX_FLOAT fy, + FX_DWORD dwFlags, + FX_FLOAT fDeltaX, + FX_FLOAT fDeltaY) { + m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; + m_pOwner->SendEvent(); + m_pOwner->m_iMouseWheel = 0; +} +void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!rtItem.Contains(fx, fy)) { + return; + } + if (iState == FWL_PARTSTATE_SCB_Pressed) { + return; + } + iState = FWL_PARTSTATE_SCB_Pressed; + m_pOwner->Repaint(&rtItem); +} +void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + FX_FLOAT fx, + FX_FLOAT fy) { + int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered + : FWL_PARTSTATE_SCB_Normal; + if (iState == iNewState) { + return; + } + iState = iNewState; + m_pOwner->Repaint(&rtItem); + m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos); +} +void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + 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; + if (iState == iNewState) { + return; + } + iState = iNewState; + m_pOwner->Repaint(&rtItem); + } else if ((2 == iItem) && + (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) { + FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy); + m_pOwner->m_fTrackPos = fPos; + m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos); + } +} +void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState) { + if (iState == FWL_PARTSTATE_SCB_Normal) { + return; + } + iState = FWL_PARTSTATE_SCB_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) { + return; + } + iState = FWL_PARTSTATE_SCB_Hovered; + m_pOwner->Repaint(&rtItem); +} diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.h b/xfa/fwl/basewidget/fwl_scrollbarimp.h new file mode 100644 index 0000000000..2e378a677c --- /dev/null +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.h @@ -0,0 +1,139 @@ +// 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_FWL_SCROLLBARIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_ScrollBarImpDelegate; + +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 FX_DWORD 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(FX_DWORD dwCode, FX_FLOAT fPos = 0.0f); + virtual FWL_ERR SetOuter(IFWL_Widget* pOuter); + virtual int32_t Run(FWL_HTIMER hTimer); + + protected: + void DrawTrack(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FX_BOOL bLower = TRUE, + const CFX_Matrix* pMatrix = NULL); + void DrawArrowBtn(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + FX_BOOL bMinBtn = TRUE, + const CFX_Matrix* pMatrix = NULL); + void DrawThumb(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void Layout(); + void CalcButtonLen(); + void CalcMinButtonRect(CFX_RectF& rect); + void CalcMaxButtonRect(CFX_RectF& rect); + void CalcThumbButtonRect(CFX_RectF& rect); + void CalcMinTrackRect(CFX_RectF& rect); + void CalcMaxTrackRect(CFX_RectF& rect); + FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); + void GetTrackRect(CFX_RectF& rect, FX_BOOL bLower = TRUE); + FX_BOOL SendEvent(); + FX_BOOL OnScroll(FX_DWORD dwCode, FX_FLOAT fPos); + + FWL_HTIMER m_hTimer; + FX_FLOAT m_fRangeMin; + FX_FLOAT m_fRangeMax; + FX_FLOAT m_fPageSize; + FX_FLOAT m_fStepSize; + FX_FLOAT m_fPos; + FX_FLOAT m_fTrackPos; + int32_t m_iMinButtonState; + int32_t m_iMaxButtonState; + int32_t m_iThumbButtonState; + int32_t m_iMinTrackState; + int32_t m_iMaxTrackState; + FX_FLOAT m_fLastTrackPos; + FX_FLOAT m_cpTrackPointX; + FX_FLOAT m_cpTrackPointY; + int32_t m_iMouseWheel; + FX_BOOL m_bTrackMouseLeave; + FX_BOOL m_bMouseHover; + FX_BOOL m_bMouseDown; + FX_BOOL m_bRepaintThumb; + FX_FLOAT m_fButtonLen; + FX_BOOL m_bMinSize; + CFX_RectF m_rtClient; + CFX_RectF m_rtThumb; + CFX_RectF m_rtMinBtn; + CFX_RectF m_rtMaxBtn; + CFX_RectF m_rtMinTrack; + 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; + + protected: + void OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + void OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + void OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + void OnMouseLeave(); + void OnMouseWheel(FX_FLOAT fx, + FX_FLOAT fy, + FX_DWORD dwFlags, + FX_FLOAT fDeltaX, + FX_FLOAT fDeltaY); + void DoMouseDown(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + FX_FLOAT fx, + FX_FLOAT fy); + void DoMouseUp(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + FX_FLOAT fx, + FX_FLOAT fy); + void DoMouseMove(int32_t iItem, + const CFX_RectF& rtItem, + int32_t& iState, + FX_FLOAT fx, + FX_FLOAT fy); + void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); + void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); + + CFWL_ScrollBarImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp new file mode 100644 index 0000000000..9493cbbc7d --- /dev/null +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp @@ -0,0 +1,429 @@ +// 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/basewidget/fwl_spinbuttonimp.h" + +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/basewidget/fwl_spinbutton.h" +#include "xfa/include/fwl/core/fwl_theme.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +#define FWL_SPN_MinWidth 18 +#define FWL_SPN_MinHeight 32 +#define FWL_SPIN_Elapse 200 + +// static +IFWL_SpinButton* IFWL_SpinButton::Create( + const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_SpinButton* pSpinButton = new IFWL_SpinButton; + CFWL_SpinButtonImp* pSpinButtonImpl = + new CFWL_SpinButtonImp(properties, nullptr); + pSpinButton->SetImpl(pSpinButtonImpl); + pSpinButtonImpl->SetInterface(pSpinButton); + return pSpinButton; +} +IFWL_SpinButton::IFWL_SpinButton() {} +FWL_ERR IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { + return static_cast<CFWL_SpinButtonImp*>(GetImpl()) + ->EnableButton(bEnable, bUp); +} +FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) { + return static_cast<CFWL_SpinButtonImp*>(GetImpl())->IsButtonEnable(bUp); +} + +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_iButtonIndex(0), + m_bLButtonDwn(FALSE), + m_hTimer(NULL) { + m_rtClient.Reset(); + m_rtUpButton.Reset(); + m_rtDnButton.Reset(); + m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; +} +CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {} +FWL_ERR CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_SpinButton; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_SpinButtonImp::GetClassID() const { + return FWL_CLASSHASH_SpinButton; +} +FWL_ERR CFWL_SpinButtonImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + m_pDelegate = new CFWL_SpinButtonImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_SpinButtonImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight); + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_SpinButtonImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + GetClientRect(m_rtClient); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { + m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, + m_rtClient.height / 2); + m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, + m_rtClient.width, m_rtClient.height / 2); + } else { + m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, + m_rtClient.height); + m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, + m_rtClient.width / 2, m_rtClient.height); + } + return FWL_ERR_Succeeded; +} +FX_DWORD 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; + } + 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; +} +FWL_ERR CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!pGraphics) + return FWL_ERR_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); + } + if (HasEdge()) { + DrawEdge(pGraphics, FWL_PART_SPB_Edge, pTheme, pMatrix); + } + DrawUpButton(pGraphics, pTheme, pMatrix); + DrawDownButton(pGraphics, pTheme, pMatrix); + return FWL_ERR_Succeeded; +} +int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) { + if (m_hTimer) { + CFWL_EvtSpbClick wmPosChanged; + wmPosChanged.m_pSrcTarget = m_pInterface; + wmPosChanged.m_bUp = m_iButtonIndex == 0; + DispatchEvent(&wmPosChanged); + } + return 1; +} +FWL_ERR CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { + if (bUp) { + if (bEnable) { + m_dwUpState = FWL_PARTSTATE_SPB_Normal; + } else { + m_dwUpState = FWL_PARTSTATE_SPB_Disabled; + } + } else { + if (bEnable) { + m_dwDnState = FWL_PARTSTATE_SPB_Normal; + } else { + m_dwDnState = FWL_PARTSTATE_SPB_Disabled; + } + } + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp) { + if (bUp) { + return (m_dwUpState != FWL_PARTSTATE_SPB_Disabled); + } + return (m_dwDnState != FWL_PARTSTATE_SPB_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_pGraphics = pGraphics; + params.m_dwStates = m_dwUpState + 1; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + params.m_rtPart = m_rtUpButton; + pTheme->DrawBackground(¶ms); +} +void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFWL_ThemeBackground params; + params.m_pWidget = m_pInterface; + params.m_iPart = FWL_PART_SPB_DownButton; + params.m_pGraphics = pGraphics; + params.m_dwStates = m_dwDnState + 1; + if (pMatrix) { + params.m_matrix.Concat(*pMatrix); + } + params.m_rtPart = m_rtDnButton; + pTheme->DrawBackground(¶ms); +} +CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate( + CFWL_SpinButtonImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + int32_t iRet = 1; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + switch (dwMsgCode) { + case FWL_MSGHASH_SetFocus: + case FWL_MSGHASH_KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + FX_DWORD 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; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMsg); + break; + } + default: {} + } + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); + if (pKey->m_dwCmd == FWL_MSGKEYCMD_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::OnFocusChanged(CFWL_Message* pMsg, + FX_BOOL bSet) { + if (bSet) { + m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); + } else { + m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + m_pOwner->m_bLButtonDwn = TRUE; + m_pOwner->SetGrab(TRUE); + m_pOwner->SetFocus(TRUE); + if (!m_pOwner->m_pProperties->m_pDataProvider) + return; + FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && + m_pOwner->IsButtonEnable(TRUE)); + FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && + m_pOwner->IsButtonEnable(FALSE)); + if (!bUpPress && !bDnPress) { + return; + } + if (bUpPress) { + m_pOwner->m_iButtonIndex = 0; + m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Pressed; + } + if (bDnPress) { + m_pOwner->m_iButtonIndex = 1; + m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Pressed; + } + CFWL_EvtSpbClick wmPosChanged; + wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; + wmPosChanged.m_bUp = bUpPress; + 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); +} +void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_pProperties->m_dwStates & FWL_PARTSTATE_SPB_Disabled) { + return; + } + m_pOwner->m_bLButtonDwn = FALSE; + m_pOwner->SetGrab(FALSE); + m_pOwner->SetFocus(FALSE); + if (m_pOwner->m_hTimer) { + FWL_StopTimer(m_pOwner->m_hTimer); + m_pOwner->m_hTimer = NULL; + } + FX_BOOL bRepaint = FALSE; + CFX_RectF rtInvalidate; + if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Pressed && + m_pOwner->IsButtonEnable(TRUE)) { + m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; + bRepaint = TRUE; + rtInvalidate = m_pOwner->m_rtUpButton; + } else if (m_pOwner->m_dwDnState == FWL_PARTSTATE_SPB_Pressed && + m_pOwner->IsButtonEnable(FALSE)) { + m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; + bRepaint = TRUE; + rtInvalidate = m_pOwner->m_rtDnButton; + } + if (bRepaint) { + m_pOwner->Repaint(&rtInvalidate); + } +} +void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + if (!m_pOwner->m_pProperties->m_pDataProvider) + return; + if (m_pOwner->m_bLButtonDwn) { + return; + } + FX_BOOL bRepaint = FALSE; + CFX_RectF rtInvlidate; + 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; + bRepaint = TRUE; + rtInvlidate = m_pOwner->m_rtUpButton; + } + if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && + m_pOwner->IsButtonEnable(FALSE)) { + m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; + if (bRepaint) { + rtInvlidate.Union(m_pOwner->m_rtDnButton); + } else { + rtInvlidate = m_pOwner->m_rtDnButton; + } + bRepaint = TRUE; + } + } + if (!m_pOwner->IsButtonEnable(FALSE)) { + m_pOwner->EnableButton(FALSE, FALSE); + } + } 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; + bRepaint = TRUE; + rtInvlidate = m_pOwner->m_rtDnButton; + } + if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && + m_pOwner->IsButtonEnable(TRUE)) { + m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; + if (bRepaint) { + rtInvlidate.Union(m_pOwner->m_rtUpButton); + } else { + rtInvlidate = m_pOwner->m_rtUpButton; + } + 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; + 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 (bRepaint) { + rtInvlidate.Union(m_pOwner->m_rtDnButton); + } else { + rtInvlidate = m_pOwner->m_rtDnButton; + } + bRepaint = TRUE; + } + } + if (bRepaint) { + m_pOwner->Repaint(&rtInvlidate); + } +} +void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { + if (!pMsg) + return; + if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && + m_pOwner->IsButtonEnable(TRUE)) { + m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; + } + if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && + m_pOwner->IsButtonEnable(FALSE)) { + m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; + } + m_pOwner->Repaint(&m_pOwner->m_rtClient); +} +void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { + if (!m_pOwner->m_pProperties->m_pDataProvider) + return; + FX_BOOL bUp = + pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; + FX_BOOL bDown = + pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; + if (!bUp && !bDown) { + return; + } + FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE); + FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE); + if (!bUpEnable && !bDownEnable) { + return; + } + CFWL_EvtSpbClick wmPosChanged; + wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; + wmPosChanged.m_bUp = bUpEnable; + m_pOwner->DispatchEvent(&wmPosChanged); + m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton + : &m_pOwner->m_rtDnButton); +} diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.h b/xfa/fwl/basewidget/fwl_spinbuttonimp.h new file mode 100644 index 0000000000..d8eb5963dc --- /dev/null +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.h @@ -0,0 +1,69 @@ +// 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_FWL_SPINBUTTONIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_SPINBUTTONIMP_H_ + +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +class CFWL_WidgetImpProperties; +class CFWL_SpinButtonImpDelegate; + +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 FX_DWORD 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 FX_DWORD 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); + FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); + + protected: + 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; + FX_DWORD m_dwUpState; + FX_DWORD m_dwDnState; + 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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + CFWL_SpinButtonImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_SPINBUTTONIMP_H_ diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp new file mode 100644 index 0000000000..3d545e66fe --- /dev/null +++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp @@ -0,0 +1,293 @@ +// 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/basewidget/fwl_tooltipctrlimp.h" + +#include "xfa/fde/tto/fde_textout.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/include/fwl/basewidget/fwl_tooltipctrl.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +// static +IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) { + IFWL_ToolTip* pToolTip = new IFWL_ToolTip; + CFWL_ToolTipImp* pToolTipImpl = new CFWL_ToolTipImp(properties, pOuter); + pToolTip->SetImpl(pToolTipImpl); + pToolTipImpl->SetInterface(pToolTip); + return pToolTip; +} +FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { + return static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor); +} +FWL_ERR IFWL_ToolTip::Show() { + return static_cast<CFWL_ToolTipImp*>(GetImpl())->Show(); +} +FWL_ERR IFWL_ToolTip::Hide() { + return 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), + m_bBtnDown(FALSE), + m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), + m_iTTOAlign(FDE_TTOALIGNMENT_Center), + m_hTimerShow(NULL), + m_hTimerHide(NULL), + m_pTimer(NULL) { + m_rtClient.Set(0, 0, 0, 0); + m_rtCaption.Set(0, 0, 0, 0); + m_rtAnchor.Set(0, 0, 0, 0); + 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 { + wsClass = FWL_CLASS_ToolTip; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_ToolTipImp::GetClassID() const { + return FWL_CLASSHASH_ToolTip; +} +FWL_ERR 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; + m_pDelegate = new CFWL_ToolTipImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ToolTipImp::Finalize() { + delete m_pDelegate; + m_pDelegate = nullptr; + return CFWL_WidgetImp::Finalize(); +} +FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + rect.Set(0, 0, 0, 0); + if (m_pProperties->m_pThemeProvider == NULL) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + CFX_WideString wsCaption; + IFWL_ToolTipDP* pData = + static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); + if (pData) { + pData->GetCaption(m_pInterface, wsCaption); + } + int32_t iLen = wsCaption.GetLength(); + 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; + } + CFWL_WidgetImp::GetWidgetRect(rect, TRUE); + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ToolTipImp::Update() { + if (IsLocked()) { + return FWL_ERR_Indefinite; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } + UpdateTextOutStyles(); + GetClientRect(m_rtClient); + m_rtCaption = m_rtClient; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) { + FX_FLOAT x = 0; + FX_FLOAT y = 0; + FX_FLOAT t = 0; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (pTheme) { + CFWL_ThemePart part; + part.m_pWidget = m_pInterface; + x = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); + y = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); + } + rect = m_pProperties->m_rtWidget; + rect.Offset(-rect.left, -rect.top); + rect.Deflate(x, t, x, y); + return FWL_ERR_Succeeded; +} +FWL_ERR 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; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + DrawBkground(pGraphics, pTheme, pMatrix); + DrawText(pGraphics, pTheme, pMatrix); + return FWL_ERR_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_dwStates = m_pProperties->m_dwStates; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtClient; + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + param.m_pData = &m_rtCaption; + } + pTheme->DrawBackground(¶m); +} +void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + if (!m_pProperties->m_pDataProvider) + return; + CFX_WideString wsCaption; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); + if (wsCaption.IsEmpty()) { + return; + } + CFWL_ThemeText param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_TTP_Caption; + param.m_dwStates = m_pProperties->m_dwStates; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + param.m_rtPart = m_rtCaption; + param.m_wsText = wsCaption; + param.m_dwTTOStyles = m_dwTTOStyles; + param.m_iTTOAlign = m_iTTOAlign; + pTheme->DrawText(¶m); +} +void CFWL_ToolTipImp::UpdateTextOutStyles() { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; + m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + m_dwTTOStyles |= FDE_TTOSTYLE_RTL; + } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { + m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; + } +} +FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { + m_rtAnchor = rtAnchor; + return TRUE; +} +FWL_ERR 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)) { + m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); + } + return TRUE; +} +FWL_ERR CFWL_ToolTipImp::Hide() { + SetStates(FWL_WGTSTATE_Invisible, TRUE); + if (m_hTimerHide) { + FWL_StopTimer(m_hTimerHide); + m_hTimerHide = NULL; + } + if (m_hTimerShow) { + FWL_StopTimer(m_hTimerShow); + m_hTimerShow = NULL; + } + return TRUE; +} +FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD 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); +} +void CFWL_ToolTipImp::RefreshToolTipPos() { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { + CFX_RectF rtPopup; + CFX_RectF rtWidget(m_pProperties->m_rtWidget); + CFX_RectF rtAnchor(m_rtAnchor); + rtPopup.Set(0, 0, 0, 0); + FX_FLOAT fx = rtAnchor.Center().x + 20; + FX_FLOAT fy = rtAnchor.Center().y + 20; + rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); + FX_FLOAT fScreenWidth = 0; + FX_FLOAT fScreenHeight = 0; + GetScreenSize(fScreenWidth, fScreenHeight); + if (rtPopup.bottom() > fScreenHeight) { + rtPopup.Offset(0, fScreenHeight - rtPopup.bottom()); + } + if (rtPopup.right() > fScreenWidth) { + rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); + } + if (rtPopup.left < 0) { + rtPopup.Offset(0 - rtPopup.left, 0); + } + if (rtPopup.top < 0) { + rtPopup.Offset(0, 0 - rtPopup.top); + } + SetWidgetRect(rtPopup); + Update(); + } +} +CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) + : m_pToolTip(pToolTip) {} +int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { + if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { + if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { + m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); + m_pToolTip->RefreshToolTipPos(); + FWL_StopTimer(m_pToolTip->m_hTimerShow); + m_pToolTip->m_hTimerShow = NULL; + return TRUE; + } + } + if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { + m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); + FWL_StopTimer(m_pToolTip->m_hTimerHide); + m_pToolTip->m_hTimerHide = NULL; + return TRUE; + } + 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; +} +FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOwner->DrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h new file mode 100644 index 0000000000..42fe276fb9 --- /dev/null +++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h @@ -0,0 +1,86 @@ +// 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_FWL_TOOLTIPCTRLIMP_H_ +#define XFA_FWL_BASEWIDGET_FWL_TOOLTIPCTRLIMP_H_ + +#include "xfa/fwl/core/fwl_formimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +class CFWL_WidgetImpProperties; +class IFWL_Widget; +class CFWL_ToolTipImpDelegate; + +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 FX_DWORD 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(FX_DWORD dwStates, FX_BOOL bSet); + virtual FWL_ERR GetClientRect(CFX_RectF& rect); + FWL_ERR SetAnchor(const CFX_RectF& rtAnchor); + FWL_ERR Show(); + FWL_ERR 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(); + 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; + }; + CFX_RectF m_rtClient; + CFX_RectF m_rtCaption; + FX_BOOL m_bBtnDown; + FX_DWORD m_dwTTOStyles; + int32_t m_iTTOAlign; + CFX_RectF m_rtAnchor; + FWL_HTIMER m_hTimerShow; + FWL_HTIMER m_hTimerHide; + 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; + + protected: + void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + CFWL_ToolTipImp* m_pOwner; +}; + +#endif // XFA_FWL_BASEWIDGET_FWL_TOOLTIPCTRLIMP_H_ diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp new file mode 100644 index 0000000000..c27805ef83 --- /dev/null +++ b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp @@ -0,0 +1,385 @@ +// 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/basewidget/fxmath_barcodeimp.h" + +static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { + switch (type) { + case BC_CODE39: + return new CBC_Code39(); + case BC_CODABAR: + return new CBC_Codabar(); + case BC_CODE128: + return new CBC_Code128(BC_CODE128_B); + case BC_CODE128_B: + return new CBC_Code128(BC_CODE128_B); + case BC_CODE128_C: + return new CBC_Code128(BC_CODE128_C); + case BC_EAN8: + return new CBC_EAN8(); + case BC_UPCA: + return new CBC_UPCA(); + case BC_EAN13: + return new CBC_EAN13(); + case BC_QR_CODE: + return new CBC_QRCode(); + case BC_PDF417: + return new CBC_PDF417I(); + case BC_DATAMATRIX: + return new CBC_DataMatrix(); + case BC_UNKNOWN: + default: + return NULL; + } +} +CFX_Barcode::CFX_Barcode() {} +CFX_Barcode::~CFX_Barcode() { + if (m_pBCEngine) { + delete m_pBCEngine; + m_pBCEngine = NULL; + } +} +FX_BOOL CFX_Barcode::Crreate(BC_TYPE type) { + m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); + return m_pBCEngine != NULL; +} +void CFX_Barcode::Release() { + delete this; +} +BC_TYPE CFX_Barcode::GetType() { + return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; +} +FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { + return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; +} +FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { + return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; +} +FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth) { + return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE; +} +FX_BOOL CFX_Barcode::SetHeight(int32_t height) { + return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE; +} +FX_BOOL CFX_Barcode::SetWidth(int32_t width) { + return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE; +} +FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine + ? static_cast<CBC_OneCode*>(m_pBCEngine) + ->CheckContentValidity(contents) + : TRUE; + default: + return TRUE; + } +} +FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) + ->SetPrintChecksum(checksum), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetDataLength(int32_t length) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) + ->SetDataLength(length), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) + ->SetCalChecksum(state), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine + ? static_cast<CBC_OneCode*>(m_pBCEngine)->SetFont(pFont) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine + ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontSize(size), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine + ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontStyle(style), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) { + switch (GetType()) { + case BC_CODE39: + case BC_CODABAR: + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + case BC_EAN8: + case BC_EAN13: + case BC_UPCA: + return m_pBCEngine + ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color), + TRUE) + : FALSE; + default: + return FALSE; + } +} +FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_CODE39: + memptr = (memptrtype)&CBC_Code39::SetTextLocation; + break; + case BC_CODABAR: + memptr = (memptrtype)&CBC_Codabar::SetTextLocation; + break; + case BC_CODE128: + case BC_CODE128_B: + case BC_CODE128_C: + memptr = (memptrtype)&CBC_Code128::SetTextLocation; + break; + default: + break; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE; +} +FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_CODE39: + memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; + break; + case BC_CODABAR: + memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; + break; + default: + break; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE; +} +FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_CODABAR: + memptr = (memptrtype)&CBC_Codabar::SetStartChar; + break; + default: + break; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE; +} +FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_CODABAR: + memptr = (memptrtype)&CBC_Codabar::SetEndChar; + break; + default: + break; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE; +} +FX_BOOL CFX_Barcode::SetVersion(int32_t version) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_QR_CODE: + memptr = (memptrtype)&CBC_QRCode::SetVersion; + break; + default: + break; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE; +} +FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { + typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_QR_CODE: + memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; + break; + case BC_PDF417: + memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; + break; + default: + return FALSE; + } + return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE; +} +FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { + typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL); + memptrtype memptr = NULL; + switch (GetType()) { + case BC_PDF417: + memptr = (memptrtype)&CBC_PDF417I::SetTruncated; + break; + default: + break; + } + 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) { + if (!m_pBCEngine) { + return FALSE; + } + return m_pBCEngine->Encode(contents, isDevice, e); +} +FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device, + const CFX_Matrix* matirx, + int32_t& e) { + if (!m_pBCEngine) { + return FALSE; + } + return m_pBCEngine->RenderDevice(device, matirx, e); +} +FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + if (!m_pBCEngine) { + return FALSE; + } + 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; + t = (BC_TYPE)((int32_t)t + 1)) { + CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); + if (!pTmpEngine) { + continue; + } + CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode); + if (errorCode == BCExceptionNO) { + return ret; + } + } + errorCode = BCExceptionUnSupportedBarcode; + 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; + t = (BC_TYPE)((int32_t)t + 1)) { + CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); + if (!pTmpEngine) { + continue; + } + CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); + if (errorCode == BCExceptionNO) { + return ret; + } + } + errorCode = BCExceptionUnSupportedBarcode; + return CFX_WideString(); +} +IFX_Barcode* FX_Barcode_Create(BC_TYPE type) { + CFX_Barcode* pBarcode = new CFX_Barcode; + if (pBarcode->Crreate(type)) { + return pBarcode; + } + pBarcode->Release(); + return NULL; +} diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.h b/xfa/fwl/basewidget/fxmath_barcodeimp.h new file mode 100644 index 0000000000..a26761e0d7 --- /dev/null +++ b/xfa/fwl/basewidget/fxmath_barcodeimp.h @@ -0,0 +1,56 @@ +// 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_FXMATH_BARCODEIMP_H_ +#define XFA_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_ + +#include "xfa/include/fwl/basewidget/fxmath_barcode.h" + +class CFX_Barcode : public IFX_Barcode { + public: + CFX_Barcode(); + ~CFX_Barcode(); + FX_BOOL Crreate(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); + + protected: + CBC_CodeBase* m_pBCEngine; +}; + +#endif // XFA_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_ diff --git a/xfa/fwl/core/fwl_appimp.cpp b/xfa/fwl/core/fwl_appimp.cpp new file mode 100644 index 0000000000..31634860f4 --- /dev/null +++ b/xfa/fwl/core/fwl_appimp.cpp @@ -0,0 +1,114 @@ +// 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_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/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_widget.h" + +IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) { + IFWL_App* pApp = new IFWL_App; + pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter)); + return pApp; +} +FWL_ERR IFWL_App::Initialize() { + return static_cast<CFWL_AppImp*>(GetImpl())->Initialize(); +} +FWL_ERR IFWL_App::Finalize() { + return static_cast<CFWL_AppImp*>(GetImpl())->Finalize(); +} +IFWL_AdapterNative* 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); +} +FWL_ERR IFWL_App::Exit(int32_t iExitCode) { + return 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_AppImp::~CFWL_AppImp() { + CFWL_ToolTipContainer::DeleteInstance(); +} + +FWL_ERR CFWL_AppImp::Initialize() { + if (!m_pWidgetMgr) { + m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative)); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_AppImp::Finalize() { + m_pWidgetMgr.reset(); + return FWL_ERR_Succeeded; +} +IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const { + return m_pAdapterNative; +} +IFWL_AdapterWidgetMgr* 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) { + m_pThemeProvider = pThemeProvider; + return FWL_ERR_Succeeded; +} +FWL_ERR 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() { + IFWL_App* pApp = FWL_GetApp(); + if (!pApp) + return NULL; + return pApp->GetAdapterNative(); +} +IFWL_ThemeProvider* FWL_GetThemeProvider() { + return NULL; +} +static IFWL_App* _theApp = NULL; +IFWL_App* FWL_GetApp() { + return _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); +} diff --git a/xfa/fwl/core/fwl_appimp.h b/xfa/fwl/core/fwl_appimp.h new file mode 100644 index 0000000000..f9ccabf9bc --- /dev/null +++ b/xfa/fwl/core/fwl_appimp.h @@ -0,0 +1,38 @@ +// 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_APPIMP_H_ +#define XFA_FWL_CORE_FWL_APPIMP_H_ + +#include <memory> + +#include "xfa/fwl/core/fwl_threadimp.h" + +class CFWL_WidgetMgr; +class IFWL_AdapterNative; +class IFWL_WidgetMgr; +class IFWL_ThemeProvider; +class IFWL_App; + +class CFWL_AppImp : public CFWL_NoteThreadImp { + 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; + std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr; + IFWL_ThemeProvider* m_pThemeProvider; +}; + +#endif // XFA_FWL_CORE_FWL_APPIMP_H_ diff --git a/xfa/fwl/core/fwl_contentimp.cpp b/xfa/fwl/core/fwl_contentimp.cpp new file mode 100644 index 0000000000..a38998f0cf --- /dev/null +++ b/xfa/fwl/core/fwl_contentimp.cpp @@ -0,0 +1,94 @@ +// 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/include/fwl/core/fwl_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/xfa/fwl/core/fwl_contentimp.h b/xfa/fwl/core/fwl_contentimp.h new file mode 100644 index 0000000000..b7a44d3a53 --- /dev/null +++ b/xfa/fwl/core/fwl_contentimp.h @@ -0,0 +1,35 @@ +// 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/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp new file mode 100644 index 0000000000..a321431f6f --- /dev/null +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -0,0 +1,1175 @@ +// 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_formimp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/basewidget/fwl_formproxyimp.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/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_content.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +#define FWL_SYSBTNSIZE 21 +#define FWL_SYSBTNMARGIN 5 +#define FWL_SYSBTNSPAN 2 +#define FWL_CornerEnlarge 10 + +// static +IFWL_Form* IFWL_Form::CreateFormProxy(CFWL_WidgetImpProperties& properties, + CFX_WideString* classname, + IFWL_Widget* pOuter) { + IFWL_Form* pForm = new IFWL_Form; + CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter); + pForm->SetImpl(pFormProxyImpl); + pFormProxyImpl->SetInterface(pForm); + return pForm; +} +IFWL_Form::IFWL_Form() {} +FWL_FORMSIZE IFWL_Form::GetFormSize() { + return static_cast<CFWL_FormImp*>(GetImpl())->GetFormSize(); +} +FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { + return static_cast<CFWL_FormImp*>(GetImpl())->SetFormSize(eFormSize); +} +IFWL_Widget* IFWL_Form::DoModal() { + return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(); +} +IFWL_Widget* IFWL_Form::DoModal(FX_DWORD& dwCommandID) { + return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(dwCommandID); +} +FWL_ERR IFWL_Form::EndDoModal() { + return static_cast<CFWL_FormImp*>(GetImpl())->EndDoModal(); +} +FWL_ERR 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), + m_fCXBorder(0), + m_fCYBorder(0), + m_iCaptureBtn(-1), + m_iSysBox(0), + m_eResizeType(FORM_RESIZETYPE_None), + m_bLButtonDown(FALSE), + m_bMaximized(FALSE), + m_bSetMaximize(FALSE), + m_bCustomizeLayout(FALSE), + m_eFormSize(FWL_FORMSIZE_Manual), + m_bDoModalFlag(FALSE), + m_pBigIcon(NULL), + m_pSmallIcon(NULL), + m_bMouseIn(FALSE) { + m_rtRelative.Reset(); + m_rtCaption.Reset(); + m_rtRestore.Reset(); + m_rtCaptionText.Reset(); + m_rtIcon.Reset(); +} +CFWL_FormImp::~CFWL_FormImp() { + RemoveSysButtons(); + delete m_pNoteLoop; +} +FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const { + wsClass = FWL_CLASS_Form; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_FormImp::GetClassID() const { + return FWL_CLASSHASH_Form; +} +FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const { + if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) { + return TRUE; + } + return CFWL_PanelImp::IsInstance(wsClass); +} +FWL_ERR CFWL_FormImp::Initialize() { + if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) + return FWL_ERR_Indefinite; + RegisterForm(); + RegisterEventTarget(); + m_pDelegate = new CFWL_FormImpDelegate(this); + return FWL_ERR_Succeeded; +} +FWL_ERR 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) { + 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; +} +FWL_ERR 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; + } +#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; +#else + FX_FLOAT x = 0; + FX_FLOAT y = 0; + FX_FLOAT t = 0; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + if (pTheme) { + CFWL_ThemePart part; + part.m_pWidget = m_pInterface; + x = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); + y = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); + t = *static_cast<FX_FLOAT*>( + pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption)); + } + rect = m_pProperties->m_rtWidget; + rect.Offset(-rect.left, -rect.top); + rect.Deflate(x, t, x, y); + return FWL_ERR_Succeeded; +#endif +} +FWL_ERR CFWL_FormImp::Update() { + if (m_iLock > 0) { + return FWL_ERR_Succeeded; + } + if (!m_pProperties->m_pThemeProvider) { + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + } +#ifdef FWL_UseMacSystemBorder +#else + SetThemeData(); + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { + UpdateIcon(); + } +#endif + UpdateCaption(); + Layout(); + return FWL_ERR_Succeeded; +} +FX_DWORD 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; + } + 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.height - m_fCXBorder); + if (rtCap.Contains(fx, fy)) { + return FWL_WGTHITTEST_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); + 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, + 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, + 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 (!pGraphics) + return FWL_ERR_Indefinite; + if (!m_pProperties->m_pThemeProvider) + return FWL_ERR_Indefinite; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + FX_BOOL bInactive = !IsActive(); + int32_t iState = + bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal; + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { + DrawBackground(pGraphics, pTheme); + } +#ifdef FWL_UseMacSystemBorder + return FWL_ERR_Succeeded; +#endif + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_dwStates = iState; + param.m_pGraphics = pGraphics; + param.m_rtPart = m_rtRelative; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { + param.m_iPart = FWL_PART_FRM_Border; + pTheme->DrawBackground(¶m); + } + 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_rtPart = rtEdge; + param.m_dwStates = iState; + pTheme->DrawBackground(¶m); + } + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { + param.m_iPart = FWL_PART_FRM_Caption; + param.m_dwStates = iState; + param.m_rtPart = m_rtCaption; + pTheme->DrawBackground(¶m); + DrawCaptionText(pGraphics, pTheme, pMatrix); + } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { + param.m_iPart = FWL_PART_FRM_NarrowCaption; + param.m_dwStates = iState; + param.m_rtPart = m_rtCaption; + pTheme->DrawBackground(¶m); + DrawCaptionText(pGraphics, pTheme, pMatrix); + } + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { + param.m_iPart = FWL_PART_FRM_Icon; + if (HasIcon()) { + DrawIconImage(pGraphics, pTheme, pMatrix); + } + } +#if (_FX_OS_ == _FX_MACOSX_) + { + if (m_pCloseBox) { + param.m_iPart = FWL_PART_FRM_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_rtPart = m_pCloseBox->m_rtBtn; + pTheme->DrawBackground(¶m); + } + if (m_pMaxBox) { + param.m_iPart = FWL_PART_FRM_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_rtPart = m_pMaxBox->m_rtBtn; + param.m_dwData = m_bMaximized; + pTheme->DrawBackground(¶m); + } + if (m_pMinBox) { + param.m_iPart = FWL_PART_FRM_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_rtPart = m_pMinBox->m_rtBtn; + pTheme->DrawBackground(¶m); + } + m_bMouseIn = FALSE; + } +#else + { + if (m_pCloseBox) { + param.m_iPart = FWL_PART_FRM_CloseBox; + param.m_dwStates = m_pCloseBox->GetPartState(); + param.m_rtPart = m_pCloseBox->m_rtBtn; + pTheme->DrawBackground(¶m); + } + if (m_pMaxBox) { + param.m_iPart = FWL_PART_FRM_MaximizeBox; + param.m_dwStates = m_pMaxBox->GetPartState(); + param.m_rtPart = m_pMaxBox->m_rtBtn; + param.m_dwData = m_bMaximized; + pTheme->DrawBackground(¶m); + } + if (m_pMinBox) { + param.m_iPart = FWL_PART_FRM_MinimizeBox; + param.m_dwStates = m_pMinBox->GetPartState(); + param.m_rtPart = m_pMinBox->m_rtBtn; + pTheme->DrawBackground(¶m); + } + } +#endif + return FWL_ERR_Succeeded; +} +FWL_FORMSIZE CFWL_FormImp::GetFormSize() { + return m_eFormSize; +} +FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) { + m_eFormSize = eFormSize; + return FWL_ERR_Succeeded; +} +IFWL_Widget* CFWL_FormImp::DoModal() { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return NULL; + IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); + if (!pDriver) + return NULL; + m_pNoteLoop = new CFWL_NoteLoop(this); + pDriver->PushNoteLoop(m_pNoteLoop); + m_bDoModalFlag = TRUE; + SetStates(FWL_WGTSTATE_Invisible, FALSE); + pDriver->Run(); +#if (_FX_OS_ == _FX_MACOSX_) +#else + pDriver->PopNoteLoop(); +#endif + delete m_pNoteLoop; + m_pNoteLoop = NULL; + return NULL; +} +IFWL_Widget* CFWL_FormImp::DoModal(FX_DWORD& dwCommandID) { + return DoModal(); +} +FWL_ERR CFWL_FormImp::EndDoModal() { + if (!m_pNoteLoop) + return FWL_ERR_Indefinite; + m_bDoModalFlag = FALSE; +#if (_FX_OS_ == _FX_MACOSX_) + m_pNoteLoop->EndModalLoop(); + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return FWL_ERR_Indefinite; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + if (!pDriver) + return FWL_ERR_Indefinite; + pDriver->PopNoteLoop(); + SetStates(FWL_WGTSTATE_Invisible, TRUE); + return FWL_ERR_Succeeded; +#else + SetStates(FWL_WGTSTATE_Invisible, TRUE); + return m_pNoteLoop->EndModalLoop(); +#endif +} +FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) { + return FWL_ERR_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_pGraphics = pGraphics; + param.m_rtPart = m_rtRelative; + param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder, + m_fCXBorder); + pTheme->DrawBackground(¶m); +} +CFWL_WidgetImp* CFWL_FormImp::GetSubFocus() { + return m_pSubFocus; +} +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(); + FX_DWORD 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) + return; + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); + if (!pWidgetMgr) + return; + 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; + } +} +void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) { +#ifdef FWL_UseMacSystemBorder + rtContent = m_rtRelative; +#else + GetEdgeRect(rtContent); + if (HasEdge()) { + FX_FLOAT fEdge = GetEdgeWidth(); + rtContent.Deflate(fEdge, fEdge); + } +#endif +} +CFWL_SysBtn* CFWL_FormImp::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { + if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { + return m_pCloseBox; + } + if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { + return m_pMaxBox; + } + if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { + return m_pMinBox; + } + if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) { + return m_pCaptionBox; + } + return NULL; +} +CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(FX_DWORD dwState) { + if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) { + return m_pCloseBox; + } + if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) { + return m_pMaxBox; + } + if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) { + return m_pMinBox; + } + if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) { + return m_pCaptionBox; + } + return NULL; +} +CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex) { + if (nIndex < 0) { + return NULL; + } + CFX_PtrArray arrBtn; + if (m_pMinBox) { + arrBtn.Add(m_pMinBox); + } + if (m_pMaxBox) { + arrBtn.Add(m_pMaxBox); + } + if (m_pCloseBox) { + arrBtn.Add(m_pCloseBox); + } + return static_cast<CFWL_SysBtn*>(arrBtn[nIndex]); +} +int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn* pBtn) { + CFX_PtrArray arrBtn; + if (m_pMinBox) { + arrBtn.Add(m_pMinBox); + } + if (m_pMaxBox) { + arrBtn.Add(m_pMaxBox); + } + if (m_pCloseBox) { + arrBtn.Add(m_pCloseBox); + } + return arrBtn.Find(pBtn); +} +FX_FLOAT CFWL_FormImp::GetCaptionHeight() { + FX_DWORD dwCapacity = 0; + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { + dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption; + } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { + dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption; + } + if (dwCapacity > 0) { + FX_FLOAT* pfCapHeight = + static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); + return pfCapHeight ? *pfCapHeight : 0; + } + return 0; +} +void CFWL_FormImp::DrawCaptionText(CFX_Graphics* pGs, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFX_WideString wsText; + IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; + pData->GetCaption(m_pInterface, wsText); + if (wsText.IsEmpty()) { + return; + } + CFWL_ThemeText textParam; + textParam.m_pWidget = m_pInterface; + textParam.m_iPart = FWL_PART_FRM_Caption; + textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal; + textParam.m_pGraphics = pGs; + if (pMatrix) { + textParam.m_matrix.Concat(*pMatrix); + } + CFX_RectF rtText; + if (m_bCustomizeLayout) { + rtText = m_rtCaptionText; + rtText.top -= 5; + } else { + rtText = m_rtCaption; + FX_FLOAT fpos; + fpos = HasIcon() ? 29.0f : 13.0f; + rtText.left += fpos; + } + textParam.m_rtPart = rtText; + textParam.m_wsText = wsText; + textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis; + textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center + : FDE_TTOALIGNMENT_CenterLeft; + pTheme->DrawText(&textParam); +} +void CFWL_FormImp::DrawIconImage(CFX_Graphics* pGs, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + IFWL_FormDP* pData = + 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_pGraphics = pGs; + param.m_pImage = pData->GetIcon(m_pInterface, FALSE); + param.m_rtPart = m_rtIcon; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix); + } + pTheme->DrawBackground(¶m); +} +void CFWL_FormImp::GetEdgeRect(CFX_RectF& rtEdge) { + rtEdge = m_rtRelative; + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { + FX_FLOAT fCX = GetBorderSize(); + FX_FLOAT fCY = GetBorderSize(FALSE); + rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); + } +} +void CFWL_FormImp::SetWorkAreaRect() { + m_rtRestore = m_pProperties->m_rtWidget; + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return; + m_bSetMaximize = TRUE; + pWidgetMgr->SetMaximize_Native(m_pInterface); + Repaint(&m_rtRelative); +} +void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} +void CFWL_FormImp::Layout() { + GetRelativeRect(m_rtRelative); +#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)); + m_fCYBorder = + *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CYBorder)); + RemoveSysButtons(); + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; + m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface); + FX_FLOAT fCapHeight = GetCaptionHeight(); + if (fCapHeight > 0) { + m_rtCaption = m_rtRelative; + m_rtCaption.height = fCapHeight; + } + m_iSysBox = 0; + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { + m_pCloseBox = new CFWL_SysBtn; + if (m_bCustomizeLayout) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_FRM_CloseBox; + pTheme->GetPartRect(¶m, m_pCloseBox->m_rtBtn); + } else { + m_pCloseBox->m_rtBtn.Set( + m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, + FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + } + m_iSysBox++; + } + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) { + m_pMaxBox = new CFWL_SysBtn; + if (m_bCustomizeLayout) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_FRM_MaximizeBox; + pTheme->GetPartRect(¶m, 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); + } else { + m_pMaxBox->m_rtBtn.Set( + m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, + FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + } + } + m_iSysBox++; + } + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) { + m_pMinBox = new CFWL_SysBtn; + if (m_bCustomizeLayout) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_FRM_MinimizeBox; + pTheme->GetPartRect(¶m, 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); + } 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); + } else { + m_pMinBox->m_rtBtn.Set( + m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, + FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); + } + } + m_iSysBox++; + } + IFWL_FormDP* pData = + static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && + pData->GetIcon(m_pInterface, FALSE)) { + if (m_bCustomizeLayout) { + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = FWL_PART_FRM_Icon; + CFX_WideString wsText; + m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText); + param.m_pData = &wsText; + pTheme->GetPartRect(¶m, m_rtIcon); + } else { + m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, + m_fSmallIconSz); + } + } + if (m_bCustomizeLayout) { + CFWL_ThemeText parma; + parma.m_pWidget = m_pInterface; + parma.m_iPart = FWL_PART_FRM_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) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + if (!pDriver) + return; + pDriver->RegisterForm(this); +} +void CFWL_FormImp::UnRegisterForm() { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + if (!pDriver) + return; + pDriver->UnRegisterForm(this); +} +FX_BOOL CFWL_FormImp::IsDoModal() { + return m_bDoModalFlag; +} +void CFWL_FormImp::SetThemeData() { + m_fSmallIconSz = + *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon)); + m_fBigIconSz = + *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon)); +} +FX_BOOL CFWL_FormImp::HasIcon() { + IFWL_FormDP* pData = + static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); + return !!pData->GetIcon(m_pInterface, FALSE); +} +void CFWL_FormImp::UpdateIcon() { + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return; + IFWL_FormDP* pData = + 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) { + m_pBigIcon = pBigIcon; + pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE); + } + if (pSmallIcon && pSmallIcon != m_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()); + if (!pWidgetMgr) + return; + IFWL_FormDP* pData = + static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); + if (!pData) + return; + CFX_WideString text; + pData->GetCaption(m_pInterface, text); + pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text); +} +void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, + FX_FLOAT& fWidth, + FX_FLOAT fCurX, + FX_FLOAT fSpace, + FX_FLOAT fLimitMin, + FX_FLOAT fLimitMax, + FX_BOOL bLeft) { + FX_FLOAT fx = fCurX; + FX_FLOAT fy = 0; + TransformTo(NULL, fx, fy); + FX_FLOAT fTemp = + bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); + if (fTemp >= fLimitMin && fTemp <= fLimitMax) { + fWidth = fTemp; + fLeft += bLeft ? (fx - fLeft - fSpace) : 0; + } else { + if (fTemp < fLimitMin && fWidth > fLimitMin) { + fLeft += bLeft ? (fWidth - fLimitMin) : 0; + fWidth = fLimitMin; + } else if (fTemp > fLimitMax && fWidth < fLimitMax) { + fLeft -= bLeft ? (fLimitMax - fWidth) : 0; + fWidth = fLimitMax; + } + } +} +void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop, + FX_FLOAT& fHeight, + FX_FLOAT fCurY, + FX_FLOAT fSpace, + FX_FLOAT fLimitMin, + FX_FLOAT fLimitMax, + FX_BOOL bTop) { + FX_FLOAT fx = 0; + FX_FLOAT fy = fCurY; + TransformTo(NULL, fx, fy); + FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); + if (fTemp >= fLimitMin && fTemp <= fLimitMax) { + fHeight = fTemp; + fTop += bTop ? (fy - fTop - fSpace) : 0; + } else { + if (fTemp < fLimitMin && fHeight > fLimitMin) { + fTop += bTop ? (fHeight - fLimitMin) : 0; + fHeight = fLimitMin; + } else if (fTemp > fLimitMax && fHeight < fLimitMax) { + fTop -= bTop ? (fLimitMax - fHeight) : 0; + fHeight = fLimitMax; + } + } +} +CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner) + : m_pOwner(pOwner) {} +int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { +#ifdef FWL_UseMacSystemBorder + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + switch (dwMsgCode) { + case FWL_MSGHASH_Activate: { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; + m_pOwner->Repaint(&m_pOwner->m_rtRelative); + break; + } + case FWL_MSGHASH_Deactivate: { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; + m_pOwner->Repaint(&m_pOwner->m_rtRelative); + break; + } + } + return FWL_ERR_Succeeded; +#else + if (!pMessage) + return 0; + FX_DWORD dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; + switch (dwMsgCode) { + case FWL_MSGHASH_Activate: { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; + IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread(); + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); + IFWL_Widget* pSubFocus = + pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; + if (pSubFocus && pSubFocus != pDriver->GetFocus()) { + pDriver->SetFocus(pSubFocus); + } + m_pOwner->Repaint(&m_pOwner->m_rtRelative); + break; + } + case FWL_MSGHASH_Deactivate: { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; + IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread(); + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); + IFWL_Widget* pSubFocus = + pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; + if (pSubFocus) { + if (pSubFocus == pDriver->GetFocus()) { + pDriver->SetFocus(NULL); + } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { + CFWL_MsgKillFocus ms; + IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL); + if (pDelegate) { + pDelegate->OnProcessMessage(&ms); + } + } + } + m_pOwner->Repaint(&m_pOwner->m_rtRelative); + break; + } + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + switch (pMsg->m_dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMsg); + break; + } + case FWL_MSGMOUSECMD_MouseHover: { + OnMouseHover(pMsg); + break; + } + case FWL_MSGMOUSECMD_MouseLeave: { + OnMouseLeave(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonDblClk: { + OnLButtonDblClk(pMsg); + break; + } + } + break; + } + case FWL_MSGHASH_Size: { + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return 0; + pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); + 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.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: { + OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); + break; + } + case FWL_MSGHASH_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) { + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOwner->DrawWidget(pGraphics, pMatrix); +} +void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { + m_pOwner->SetGrab(TRUE); + m_pOwner->m_bLButtonDown = TRUE; + m_pOwner->m_eResizeType = FORM_RESIZETYPE_None; + CFWL_SysBtn* pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); + m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn); + 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 - + 2 * m_pOwner->m_fCYBorder, + m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder); + if (pPressBtn) { + pPressBtn->SetPressed(); + m_pOwner->Repaint(&pPressBtn->m_rtBtn); + } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap; + } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && + (m_pOwner->m_pProperties->m_dwStyleExes & + FWL_STYLEEXT_FRM_Resize) && + !m_pOwner->m_bMaximized) { + m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); + } + m_pOwner->m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); + m_pOwner->m_InfoStart.m_szStart = + CFX_SizeF(m_pOwner->m_pProperties->m_rtWidget.width, + m_pOwner->m_pProperties->m_rtWidget.height); +} +void CFWL_FormImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { + m_pOwner->SetGrab(FALSE); + m_pOwner->m_bLButtonDown = FALSE; + CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_SysBtn* pPressedBtn = + m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn); + if (!pPressedBtn || pPointBtn != pPressedBtn) { + return; + } + if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) { + pPressedBtn->SetNormal(); + } + if (pPressedBtn == m_pOwner->m_pMaxBox) { + if (m_pOwner->m_bMaximized) { + m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); + m_pOwner->Update(); + m_pOwner->Repaint(); + } else { + m_pOwner->SetWorkAreaRect(); + 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 { + CFWL_EvtClose eClose; + eClose.m_pSrcTarget = m_pOwner->m_pInterface; + m_pOwner->DispatchEvent(&eClose); + } +} +void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { + if (m_pOwner->m_bLButtonDown) { + return; + } + if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && + (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && + !m_pOwner->m_bMaximized) { + m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); + } + CFX_RectF rtInvalidate; + rtInvalidate.Reset(); + CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_SysBtn* pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); +#if (_FX_OS_ == _FX_MACOSX_) + { + if (pOldHover && pPointBtn != pOldHover) { + pOldHover->SetNormal(); + } + if (pPointBtn && pPointBtn != pOldHover) { + pPointBtn->SetHover(); + } + if (m_pOwner->m_pCloseBox) { + rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn; + } + if (m_pOwner->m_pMaxBox) { + if (rtInvalidate.IsEmpty()) { + rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn; + } else { + rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn); + } + } + if (m_pOwner->m_pMinBox) { + if (rtInvalidate.IsEmpty()) { + rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn; + } else { + rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn); + } + } + if (!rtInvalidate.IsEmpty() && + rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { + m_pOwner->m_bMouseIn = TRUE; + } + } +#else + { + if (pOldHover && pPointBtn != pOldHover) { + pOldHover->SetNormal(); + rtInvalidate = pOldHover->m_rtBtn; + } + if (pPointBtn && pPointBtn != pOldHover) { + pPointBtn->SetHover(); + if (rtInvalidate.IsEmpty()) { + rtInvalidate = pPointBtn->m_rtBtn; + } else { + rtInvalidate.Union(pPointBtn->m_rtBtn); + } + } + } +#endif + if (!rtInvalidate.IsEmpty()) { + m_pOwner->Repaint(&rtInvalidate); + } +} +void CFWL_FormImpDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) { + m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); +} +void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { + CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); + if (pHover) { + pHover->SetNormal(); + m_pOwner->Repaint(&pHover->m_rtBtn); + } + if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && + !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) { + if (m_pOwner->m_bMaximized) { + m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); + } else { + m_pOwner->SetWorkAreaRect(); + } + m_pOwner->Update(); + m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; + } +} +void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { + m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; + m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; +} +void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { + CFWL_EvtClose eClose; + 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/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h new file mode 100644 index 0000000000..eddc1d6032 --- /dev/null +++ b/xfa/fwl/core/fwl_formimp.h @@ -0,0 +1,193 @@ +// 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_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/include/fwl/core/fwl_form.h" + +class CFWL_NoteLoop; +class CFWL_WidgetImpProperties; +class CFWL_MsgMouse; +class IFWL_Widget; +class IFWL_ThemeProvider; +class CFWL_SysBtn; +class CFWL_FormImp; +class CFWL_FormImpDelegate; + +#define FWL_SYSBUTTONSTATE_Hover 0x0001 +#define FWL_SYSBUTTONSTATE_Pressed 0x0002 +#define FWL_SYSBUTTONSTATE_Disabled 0x0010 +class CFWL_SysBtn { + public: + CFWL_SysBtn() { + m_rtBtn.Set(0, 0, 0, 0); + 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; } + void SetNormal() { m_dwState &= 0xFFF0; } + void SetPressed() { + SetNormal(); + m_dwState |= FWL_SYSBUTTONSTATE_Pressed; + } + void SetHover() { + SetNormal(); + m_dwState |= FWL_SYSBUTTONSTATE_Hover; + } + void SetDisabled(FX_BOOL bDisabled) { + bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled + : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; + } + int32_t GetPartState() { + return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1)); + } + + CFX_RectF m_rtBtn; + FX_DWORD 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 { + public: + CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); + virtual ~CFWL_FormImp(); + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; + virtual FX_DWORD 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 FX_DWORD 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(FX_DWORD& dwCommandID); + virtual FWL_ERR EndDoModal(); + virtual FWL_ERR SetBorderRegion(CFX_Path* pPath); + virtual 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); + void RemoveSysButtons(); + void CalcContentRect(CFX_RectF& rtContent); + CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); + CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState); + CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); + int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn); + FX_FLOAT GetCaptionHeight(); + void DrawCaptionText(CFX_Graphics* pGs, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawIconImage(CFX_Graphics* pGs, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void GetEdgeRect(CFX_RectF& rtEdge); + void SetWorkAreaRect(); + void SetCursor(FX_FLOAT fx, FX_FLOAT fy); + void Layout(); + void ReSetSysBtn(); + void RegisterForm(); + void UnRegisterForm(); + FX_BOOL IsDoModal(); + void SetThemeData(); + FX_BOOL HasIcon(); + void UpdateIcon(); + void UpdateCaption(); + void DoWidthLimit(FX_FLOAT& fLeft, + FX_FLOAT& fWidth, + FX_FLOAT fCurX, + FX_FLOAT fSpace, + FX_FLOAT fLimitMin, + FX_FLOAT fLimitMax, + FX_BOOL bLeft); + void DoHeightLimit(FX_FLOAT& fTop, + FX_FLOAT& fHeight, + FX_FLOAT fCurY, + FX_FLOAT fSpace, + 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; + CFX_RectF m_rtCaption; + CFX_RectF m_rtIcon; + CFWL_SysBtn* m_pCloseBox; + CFWL_SysBtn* m_pMinBox; + CFWL_SysBtn* m_pMaxBox; + CFWL_SysBtn* m_pCaptionBox; + CFWL_NoteLoop* m_pNoteLoop; + CFWL_WidgetImp* m_pSubFocus; + RestoreInfo m_InfoStart; + FX_FLOAT m_fCXBorder; + FX_FLOAT m_fCYBorder; + int32_t m_iCaptureBtn; + int32_t m_iSysBox; + int32_t m_eResizeType; + FX_BOOL m_bLButtonDown; + FX_BOOL m_bMaximized; + FX_BOOL m_bSetMaximize; + FX_BOOL m_bCustomizeLayout; + FWL_FORMSIZE m_eFormSize; + FX_BOOL m_bDoModalFlag; + FX_FLOAT m_fSmallIconSz; + FX_FLOAT m_fBigIconSz; + CFX_DIBitmap* m_pBigIcon; + CFX_DIBitmap* m_pSmallIcon; + 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; + + protected: + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseHover(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnLButtonDblClk(CFWL_MsgMouse* pMsg); + void OnWindowMove(CFWL_MsgWindowMove* pMsg); + void OnClose(CFWL_MsgClose* pMsg); + CFWL_FormImp* m_pOwner; +}; + +#endif // XFA_FWL_CORE_FWL_FORMIMP_H_ diff --git a/xfa/fwl/core/fwl_gridimp.cpp b/xfa/fwl/core/fwl_gridimp.cpp new file mode 100644 index 0000000000..b3b8d5aa8d --- /dev/null +++ b/xfa/fwl/core/fwl_gridimp.cpp @@ -0,0 +1,1378 @@ +// 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/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" + +// 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; +} +FX_DWORD 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/xfa/fwl/core/fwl_gridimp.h b/xfa/fwl/core/fwl_gridimp.h new file mode 100644 index 0000000000..fda283f70c --- /dev/null +++ b/xfa/fwl/core/fwl_gridimp.h @@ -0,0 +1,197 @@ +// 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/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_content.h" +#include "xfa/include/fwl/core/fwl_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]; + FX_DWORD 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 FX_DWORD 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/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp new file mode 100644 index 0000000000..cadace4fca --- /dev/null +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -0,0 +1,1097 @@ +// 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_noteimp.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fwl/basewidget/fwl_tooltipctrlimp.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/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/basewidget/fwl_tooltipctrl.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_grid.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) { +#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(); + if (!pDriver) + return FWL_ERR_Indefinite; + pDriver->SendNote(&ev); +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) + } +#endif + return FWL_ERR_Indefinite; +} +CFWL_WidgetImp* CFWL_NoteLoop::GetForm() { + return m_pForm; +} +FX_BOOL CFWL_NoteLoop::ContinueModal() { + return m_bContinueModal; +} +FWL_ERR 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; +} +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; + } + FX_DWORD vrKey, rValue; + while (pos) { + accel.GetNextAssoc(pos, vrKey, rValue); + FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8; + FX_DWORD 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) { + m_pForm = pForm; + return FWL_ERR_Succeeded; +} +void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand) { + CFWL_EvtMenuCommand ev; + ev.m_iCommand = dwCommand; + IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); + if (!pDriver) + return; + pDriver->SendNote(&ev); +} +CFWL_NoteDriver::CFWL_NoteDriver() + : m_sendEventCalled(0), + m_maxSize(500), + m_bFullScreen(FALSE), + m_pHover(nullptr), + m_pFocus(nullptr), + m_pGrab(nullptr), + m_hook(nullptr) { + 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)); + } + } + 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)); + } + } + return TRUE; +} +extern void FWL_PostMessageToMainRoop(CFWL_Message* pMessage); +FX_BOOL CFWL_NoteDriver::PostMessage(CFWL_Message* pMessage) { + FWL_PostMessageToMainRoop(pMessage); + return TRUE; +} +#define FWL_NoteDriver_EventKey 1100 +FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, + IFWL_Widget* pEventSource, + FX_DWORD dwFilter) { + FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData( + (void*)(uintptr_t)FWL_NoteDriver_EventKey); + if (dwkey == 0) { + void* random = FX_Random_MT_Start(0); + dwkey = rand(); + FX_Random_MT_Close(random); + pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, + (void*)(uintptr_t)dwkey, 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; +} +FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { + FX_DWORD dwkey = (FX_DWORD)(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; +} +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 { + return FWL_GetApp(); +} +FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) { + m_noteLoopQueue.Add(pNoteLoop); + return FWL_ERR_Succeeded; +} +IFWL_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)); + m_noteLoopQueue.RemoveAt(pos - 1); + return p; +} +FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) { + if (m_pFocus == pFocus) { + return TRUE; + } + IFWL_Widget* pPrev = m_pFocus; + m_pFocus = pFocus; + if (pPrev) { + CFWL_MsgKillFocus ms; + ms.m_pDstTarget = pPrev; + ms.m_pSrcTarget = pPrev; + if (bNotify) { + ms.m_dwExtend = 1; + } + IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(NULL); + if (pDelegate) { + pDelegate->OnProcessMessage(&ms); + } + } + if (pFocus) { + IFWL_Widget* pWidget = + FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm); + CFWL_FormImp* pForm = + pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; + if (pForm) { + CFWL_WidgetImp* pNewFocus = + static_cast<CFWL_WidgetImp*>(pFocus->GetImpl()); + pForm->SetSubFocus(pNewFocus); + } + CFWL_MsgSetFocus ms; + ms.m_pDstTarget = pFocus; + if (bNotify) { + ms.m_dwExtend = 1; + } + IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL); + if (pDelegate) { + pDelegate->OnProcessMessage(&ms); + } + } + return TRUE; +} +FWL_ERR 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); + } + } +#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; +} +IFWL_Widget* CFWL_NoteDriver::GetFocus() { + return m_pFocus; +} +IFWL_Widget* CFWL_NoteDriver::GetHover() { + return m_pHover; +} +void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) { + m_pHover = pHover; +} +void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) { + m_pGrab = bSet ? pGrab : NULL; +} +void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { + if (m_pFocus == pNoteTarget) { + m_pFocus = NULL; + } + if (m_pHover == pNoteTarget) { + m_pHover = NULL; + } + if (m_pGrab == pNoteTarget) { + m_pGrab = NULL; + } +} +void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { + if (m_pFocus == pNoteTarget) { + m_pFocus = NULL; + } + if (m_pHover == pNoteTarget) { + m_pHover = NULL; + } + if (m_pGrab == pNoteTarget) { + m_pGrab = NULL; + } + UnregisterEventTarget(pNoteTarget); + int32_t count = m_forms.GetSize(); + for (int32_t nIndex = 0; nIndex < count; nIndex++) { + CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]); + if (!pForm) { + continue; + } + CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); + if (!pSubFocus) + return; + if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) { + pForm->SetSubFocus(NULL); + } + } +} +void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget* pNoteTarget, + FX_BOOL bFullScreen) { + m_bFullScreen = bFullScreen; +} +FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) { + if (!pForm) + return FWL_ERR_Indefinite; + if (m_forms.Find(pForm) >= 0) { + return FWL_ERR_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; + pLoop->SetMainForm(pForm); + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) { + if (!pForm) + return FWL_ERR_Indefinite; + int32_t nIndex = m_forms.Find(pForm); + if (nIndex < 0) { + return FWL_ERR_Indefinite; + } + m_forms.RemoveAt(nIndex); + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) { + pMessage->Retain(); + m_noteQueue.Add(pMessage); + return TRUE; +} +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]); + 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); + } + pMessage->Release(); + return TRUE; +} +CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() { + int32_t size = m_noteLoopQueue.GetSize(); + if (size <= 0) + return NULL; + 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() + ? pMessage->m_pDstTarget + : GetMessageForm(pMessage->m_pDstTarget); + if (!pMessageForm) + return FALSE; + if (DispatchMessage(pMessage, pMessageForm)) { + if (pMessage->GetClassID() == FWL_MSGHASH_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: { + bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_Deactivate: { + bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage), + pMessageForm); + break; + } + case FWL_MSGHASH_SetFocus: { + bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_KillFocus: { + bRet = + DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_Key: { + bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_Mouse: { + bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_MouseWheel: { + bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm); + break; + } + case FWL_MSGHASH_Size: { + bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage)); + break; + } + case FWL_MSGHASH_Cursor: { + bRet = TRUE; + break; + } + case FWL_MSGHASH_WindowMove: { + bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage), + pMessageForm); + break; + } + case FWL_MSGHASH_DropFiles: { + bRet = + DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm); + break; + } + default: { + bRet = TRUE; + break; + } + } + if (bRet) { + IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL); + 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; + if (iTrackLoop == 1) { + if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) { + return FALSE; + } + if (pMsg->m_pSrcTarget && + pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) { + return FALSE; + } + if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) { + return FALSE; + } + return TRUE; + } + IFWL_Widget* pDst = pMsg->m_pDstTarget; + if (!pDst) + return FALSE; +#if (_FX_OS_ == _FX_MACOSX_) + if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) { + return TRUE; + } +#endif + return pDst != pMessageForm && + !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) && + !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")); +} +FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (pWidgetMgr->IsFormDisabled()) { + m_pFocus = pMsg->m_pDstTarget; + return TRUE; + } else { + IFWL_Widget* pWidget = pMsg->m_pDstTarget; + CFWL_FormImp* pForm = + pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; + if (pForm) { + CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); + if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { + pMsg->m_pDstTarget = pSubFocus->GetInterface(); + if (m_pFocus != pMsg->m_pDstTarget) { + m_pFocus = pMsg->m_pDstTarget; + return TRUE; + } + } + } + } + return FALSE; +} +FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (pWidgetMgr->IsFormDisabled()) { + if (m_pFocus == pMsg->m_pDstTarget) { + m_pFocus = NULL; + } + return TRUE; + } + IFWL_Widget* pWidget = pMsg->m_pDstTarget; + CFWL_FormImp* pForm = + pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; + if (pForm) { + CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); + if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { + pMsg->m_pDstTarget = pSubFocus->GetInterface(); + if (m_pFocus == pMsg->m_pDstTarget) { + m_pFocus = NULL; + return TRUE; + } + } + } + return FALSE; +} +FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { +#if (_FX_OS_ != _FX_MACOSX_) + if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && + pMsg->m_dwKeyCode == FWL_VKEY_Tab) { + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); + IFWL_Widget* pFocus = m_pFocus; + if (m_pFocus) { + if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) != + pForm) { + pFocus = NULL; + } + } + FX_BOOL bFind = FALSE; + IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind); + if (!pNextTabStop) { + bFind = FALSE; + pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind); + } + if (pNextTabStop == pFocus) { + return TRUE; + } + if (pNextTabStop) { + SetFocus(pNextTabStop); + } + return TRUE; + } +#endif + if (!m_pFocus) { + if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && + pMsg->m_dwKeyCode == FWL_VKEY_Return) { + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); + if (defButton) { + pMsg->m_pDstTarget = defButton; + return TRUE; + } + } + return FALSE; + } + pMsg->m_pDstTarget = m_pFocus; + return TRUE; +} +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) { + return pMsg->m_pDstTarget != NULL; + } + if (pMsg->m_pDstTarget != pMessageForm) { + pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); + } + if (!DoMouseEx(pMsg, pMessageForm)) { + pMsg->m_pDstTarget = pMessageForm; + } + return TRUE; +} +FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg, + IFWL_Widget* pMessageForm) { + 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; +} +FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) { + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return FALSE; + pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth, + (FX_FLOAT)pMsg->m_iHeight); + return TRUE; +} +FX_BOOL CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove* pMsg, + IFWL_Widget* pMessageForm) { + return pMsg->m_pDstTarget == pMessageForm; +} +FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg, + IFWL_Widget* pMessageForm) { + return pMsg->m_pDstTarget == pMessageForm; +} +FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return FALSE; + IFWL_Widget* pTarget = NULL; + if (m_pGrab) + pTarget = m_pGrab; + 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) { + pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); + } + } + if (!pTarget) + return FALSE; + pMsg->m_pDstTarget = pTarget; + return TRUE; +} +void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { + IFWL_Widget* pTarget = pMsg->m_pDstTarget; + if (pTarget == m_pHover) { + return; + } + if (m_pHover) { + CFWL_MsgMouse msLeave; + msLeave.m_pDstTarget = m_pHover; + msLeave.m_fx = pMsg->m_fx; + 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); + } + if (pTarget->GetClassID() == FWL_CLASSHASH_Form) { + m_pHover = NULL; + return; + } + m_pHover = pTarget; + CFWL_MsgMouse msHover; + msHover.m_pDstTarget = pTarget; + 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); +} +FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { + if (pMessage->GetClassID() == FWL_MSGHASH_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)) { + 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) { + 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; + 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; + } + if (!pMessageForm && pDstTarget) { + CFWL_WidgetMgr* pWidgetMgr = + static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + if (!pWidgetMgr) + return NULL; + 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; + } + } +} +class CFWL_CoreToopTipDP : public IFWL_ToolTipDP { + public: + FWL_ERR 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); + CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget); + CFX_RectF GetAnchor(); + CFWL_CoreToopTipDP(); + + CFX_WideString m_wsCaption; + int32_t m_nInitDelayTime; + int32_t m_nAutoPopDelayTime; + CFX_RectF m_fAnchor; +}; +CFWL_CoreToopTipDP::CFWL_CoreToopTipDP() { + m_nInitDelayTime = 500; + m_nAutoPopDelayTime = 50000; + m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); +} +FWL_ERR CFWL_CoreToopTipDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsCaption; + return FWL_ERR_Succeeded; +} +int32_t CFWL_CoreToopTipDP::GetInitialDelay(IFWL_Widget* pWidget) { + return m_nInitDelayTime; +} +int32_t CFWL_CoreToopTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { + return m_nAutoPopDelayTime; +} +CFX_DIBitmap* CFWL_CoreToopTipDP::GetToolTipIcon(IFWL_Widget* pWidget) { + return NULL; +} +CFX_SizeF CFWL_CoreToopTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) { + return CFX_SizeF(); +} +CFX_RectF CFWL_CoreToopTipDP::GetAnchor() { + return m_fAnchor; +} +CFWL_EventTarget::~CFWL_EventTarget() { + m_eventSources.RemoveAll(); +} +int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, + FX_DWORD dwFilter) { + if (pSource) { + m_eventSources.SetAt(pSource, dwFilter); + return m_eventSources.GetCount(); + } + return 1; +} +FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { + IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); + if (!pDelegate) + return FALSE; + if (m_eventSources.GetCount() == 0) { + pDelegate->OnProcessEvent(pEvent); + return TRUE; + } + FX_POSITION pos = m_eventSources.GetStartPosition(); + while (pos) { + IFWL_Widget* pSource = NULL; + FX_DWORD dwFilter = 0; + m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); + if (pSource == pEvent->m_pSrcTarget || + pEvent->GetClassID() == FWL_EVTHASH_Idle) { + if (IsFilterEvent(pEvent, dwFilter)) { + pDelegate->OnProcessEvent(pEvent); + return TRUE; + } + } + } + return FALSE; +} +FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter) { + 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; + } + } + return bRet; +} + +CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL; + +CFWL_ToolTipContainer::CFWL_ToolTipContainer() + : pCurTarget(NULL), m_pToolTipImp(NULL) { + m_ToolTipDp = new CFWL_CoreToopTipDP; + m_ToolTipDp->m_nInitDelayTime = 0; + m_ToolTipDp->m_nAutoPopDelayTime = 2000; +} +CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { + if (m_pToolTipImp) { + IFWL_ToolTip* pToolTip = + static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface()); + pToolTip->Finalize(); + delete pToolTip; + } + delete m_ToolTipDp; +} +// static +CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { + 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; + } +} +FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) { + if (m_arrWidget.Find((void*)pTarget) < 0) { + m_arrWidget.Add((void*)pTarget); + return FWL_ERR_Succeeded; + } + return FWL_ERR_Indefinite; +} +FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) { + int index = m_arrWidget.Find((void*)pTarget); + if (index >= 0) { + m_arrWidget.RemoveAt(index); + return FWL_ERR_Succeeded; + } + return FWL_ERR_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]); + if (p->GetWidget() == pWedget) { + pCurTarget = p; + return TRUE; + } + } + return FALSE; +} +FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt, + IFWL_Widget* pOwner) { + if (HasToolTip(pEvt->m_pDstTarget)) { + if (NULL == m_pToolTipImp) { + CFWL_WidgetImpProperties prop; + prop.m_pDataProvider = m_ToolTipDp; + prop.m_pOwner = pOwner; + CFX_RectF rtTooltip; + rtTooltip.Set(150, 150, 100, 50); + prop.m_rtWidget = rtTooltip; + IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr); + pToolTip->Initialize(); + m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl()); + m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0); + m_pToolTipImp->SetStates(FWL_WGTSTATE_Invisible, TRUE); + } + if (pCurTarget->IsShowed()) { + CFX_WideString wsCaption; + pCurTarget->GetCaption(wsCaption); + if (!wsCaption.IsEmpty()) { + m_ToolTipDp->m_wsCaption = wsCaption; + } + CFX_RectF rt; + CFX_SizeF sz; + pCurTarget->GetToolTipSize(sz); + if (sz.x > 0 && sz.y > 0) { + rt.width = sz.x; + rt.height = sz.y; + } else { + CFX_RectF r; + m_pToolTipImp->GetWidgetRect(r, TRUE); + rt.width = r.width; + rt.height = r.height; + } + CFX_PointF pt(pEvt->m_fx, pEvt->m_fy); + if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) { + rt.left = pt.x; + rt.top = pt.y; + m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0); + } else { + CFX_RectF rtAnchor; + pCurTarget->GetWidget()->GetClientRect(rtAnchor); + pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top); + m_pToolTipImp->SetAnchor(rtAnchor); + m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor); + } + m_pToolTipImp->SetWidgetRect(rt); + m_pToolTipImp->Update(); + m_pToolTipImp->Show(); + } + return TRUE; + } + return FALSE; +} +FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) { + if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { + m_pToolTipImp->Hide(); + pCurTarget = NULL; + return TRUE; + } + return FALSE; +} +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/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h new file mode 100644 index 0000000000..e0f17bb278 --- /dev/null +++ b/xfa/fwl/core/fwl_noteimp.h @@ -0,0 +1,157 @@ +// 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_NOTEIMP_H_ +#define XFA_FWL_CORE_FWL_NOTEIMP_H_ + +#include "xfa/include/fwl/core/fwl_note.h" + +class CFWL_WidgetImp; +class CFWL_ToolTipImp; +class CFWL_CoreToopTipDP; +class CFWL_NoteDriver; +class CFWL_EventTarget; +class CFWL_ToolTipContainer; + +class CFWL_NoteLoop : public IFWL_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_WidgetImp* GetForm(); + FX_BOOL ContinueModal(); + FWL_ERR EndModalLoop(); + FX_BOOL TranslateAccelerator(CFWL_Message* pMessage); + FWL_ERR SetMainForm(CFWL_WidgetImp* pForm); + + protected: + void GenerateCommondEvent(FX_DWORD dwCommand); + + CFWL_WidgetImp* m_pForm; + FX_BOOL m_bContinueModal; +}; +class CFWL_NoteDriver : public IFWL_NoteDriver { + public: + CFWL_NoteDriver(); + ~CFWL_NoteDriver() override; + + // IFWL_NoteDriver: + FX_BOOL SendNote(CFWL_Note* pNote) override; + FX_BOOL PostMessage(CFWL_Message* pMessage) override; + FWL_ERR RegisterEventTarget(IFWL_Widget* pListener, + IFWL_Widget* pEventSource = NULL, + FX_DWORD 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; + + 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); + 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: + FX_BOOL DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); + FX_BOOL DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoSize(CFWL_MsgSize* pMsg); + FX_BOOL DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); + FX_BOOL DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); + void MouseSecondary(CFWL_MsgMouse* pMsg); + 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; + 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*, FX_DWORD> CFWL_EventSource; +class CFWL_EventTarget { + public: + CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener) + : m_pListener(pListener), m_pNoteDriver(pNoteDriver), m_bInvalid(FALSE) {} + ~CFWL_EventTarget(); + int32_t SetEventSource(IFWL_Widget* pSource, + FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); + FX_BOOL ProcessEvent(CFWL_Event* pEvent); + FX_BOOL IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter); + FX_BOOL IsInvalid() { return m_bInvalid; } + void FlagInvalid() { m_bInvalid = TRUE; } + + protected: + CFWL_EventSource m_eventSources; + IFWL_Widget* m_pListener; + CFWL_NoteDriver* m_pNoteDriver; + FX_BOOL m_bInvalid; +}; +class CFWL_ToolTipContainer { + public: + static CFWL_ToolTipContainer* getInstance(); + static void DeleteInstance(); + + FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget); + FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget); + IFWL_ToolTipTarget* GetCurrentToolTipTarget(); + + FX_BOOL HasToolTip(IFWL_Widget* pWidget); + + 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(); + + IFWL_ToolTipTarget* pCurTarget; + CFWL_ToolTipImp* m_pToolTipImp; + CFWL_CoreToopTipDP* m_ToolTipDp; + CFX_PtrArray m_arrWidget; + + private: + static CFWL_ToolTipContainer* s_pInstance; +}; + +#endif // XFA_FWL_CORE_FWL_NOTEIMP_H_ diff --git a/xfa/fwl/core/fwl_panelimp.cpp b/xfa/fwl/core/fwl_panelimp.cpp new file mode 100644 index 0000000000..e24413368c --- /dev/null +++ b/xfa/fwl/core/fwl_panelimp.cpp @@ -0,0 +1,152 @@ +// 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/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/include/fwl/core/fwl_content.h" +#include "xfa/include/fwl/core/fwl_grid.h" +#include "xfa/include/fwl/core/fwl_panel.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; +} +FX_DWORD 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/xfa/fwl/core/fwl_panelimp.h b/xfa/fwl/core/fwl_panelimp.h new file mode 100644 index 0000000000..9462a38490 --- /dev/null +++ b/xfa/fwl/core/fwl_panelimp.h @@ -0,0 +1,32 @@ +// 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 FX_DWORD 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/xfa/fwl/core/fwl_sdadapterimp.cpp b/xfa/fwl/core/fwl_sdadapterimp.cpp new file mode 100644 index 0000000000..88df9bce43 --- /dev/null +++ b/xfa/fwl/core/fwl_sdadapterimp.cpp @@ -0,0 +1,175 @@ +// 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/include/fwl/adapter/fwl_sdadapterimp.h" + +#include "core/include/fxcrt/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/include/fwl/adapter/fwl_adapterthreadmgr.h" +#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/core/fwl_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, + FX_DWORD 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; +} +FX_DWORD CFWL_SDAdapterWidgetMgr::GetKeyState(FX_DWORD 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/xfa/fwl/core/fwl_targetimp.cpp b/xfa/fwl/core/fwl_targetimp.cpp new file mode 100644 index 0000000000..d1f92d0307 --- /dev/null +++ b/xfa/fwl/core/fwl_targetimp.cpp @@ -0,0 +1,44 @@ +// 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); +} +FX_DWORD 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; +} +FX_DWORD 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/xfa/fwl/core/fwl_targetimp.h b/xfa/fwl/core/fwl_targetimp.h new file mode 100644 index 0000000000..8aeca79708 --- /dev/null +++ b/xfa/fwl/core/fwl_targetimp.h @@ -0,0 +1,27 @@ +// 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/include/fxcrt/fx_basic.h" +#include "xfa/include/fwl/core/fwl_target.h" + +class CFWL_TargetImp { + public: + virtual ~CFWL_TargetImp(); + + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; + virtual FX_DWORD 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/xfa/fwl/core/fwl_threadimp.cpp b/xfa/fwl/core/fwl_threadimp.cpp new file mode 100644 index 0000000000..e0ec0b01e7 --- /dev/null +++ b/xfa/fwl/core/fwl_threadimp.cpp @@ -0,0 +1,38 @@ +// 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" + +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/xfa/fwl/core/fwl_threadimp.h b/xfa/fwl/core/fwl_threadimp.h new file mode 100644 index 0000000000..591849bc08 --- /dev/null +++ b/xfa/fwl/core/fwl_threadimp.h @@ -0,0 +1,40 @@ +// 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/include/fwl/core/fwl_thread.h" // For FWL_HTHREAD. + +class CFWL_NoteDriver; +class IFWL_NoteDriver; + +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/xfa/fwl/core/fwl_timerimp.cpp b/xfa/fwl/core/fwl_timerimp.cpp new file mode 100644 index 0000000000..d9741f6fd4 --- /dev/null +++ b/xfa/fwl/core/fwl_timerimp.cpp @@ -0,0 +1,36 @@ +// 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_appimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_threadimp.h" +#include "xfa/include/fwl/adapter/fwl_adapternative.h" +#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_timer.h" + +FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer, + FX_DWORD dwElapse, + FX_BOOL bImmediately) { + IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative(); + if (!pAdapterNative) + return NULL; + IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); + if (!pAdapterTimerMgr) + return NULL; + FWL_HTIMER hTimer = NULL; + pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately); + return hTimer; +} +int32_t FWL_StopTimer(FWL_HTIMER hTimer) { + IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative(); + if (!pAdapterNative) + return FWL_ERR_Indefinite; + IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); + if (!pAdapterTimerMgr) + return FWL_ERR_Indefinite; + return pAdapterTimerMgr->Stop(hTimer); +} diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp new file mode 100644 index 0000000000..18429681c5 --- /dev/null +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -0,0 +1,1101 @@ +// 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_widgetimp.h" + +#include <algorithm> + +#include "xfa/fde/tto/fde_textout.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/include/fwl/adapter/fwl_adapternative.h" +#include "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h" +#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/basewidget/fwl_combobox.h" +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/basewidget/fwl_menu.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_content.h" +#include "xfa/include/fwl/core/fwl_form.h" +#include "xfa/include/fwl/core/fwl_theme.h" + +FWL_ERR 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) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetGlobalRect(rect); +} +FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->SetWidgetRect(rect); +} +FWL_ERR 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) { + 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) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->SetOwner(pOwner); +} +IFWL_Widget* IFWL_Widget::GetOuter() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOuter(); +} +FX_DWORD IFWL_Widget::GetStyles() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStyles(); +} +FWL_ERR IFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, + FX_DWORD dwStylesRemoved) { + return static_cast<CFWL_WidgetImp*>(GetImpl()) + ->ModifyStyles(dwStylesAdded, dwStylesRemoved); +} +FX_DWORD IFWL_Widget::GetStylesEx() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx(); +} +FWL_ERR IFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + return static_cast<CFWL_WidgetImp*>(GetImpl()) + ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} +FX_DWORD IFWL_Widget::GetStates() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates(); +} +FWL_ERR IFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet); +} +FWL_ERR 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() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->Update(); +} +FWL_ERR IFWL_Widget::LockUpdate() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->LockUpdate(); +} +FWL_ERR IFWL_Widget::UnlockUpdate() { + return static_cast<CFWL_WidgetImp*>(GetImpl())->UnlockUpdate(); +} +FX_DWORD 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) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, fx, fy); +} +FWL_ERR 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) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetMatrix(matrix, bGlobal); +} +FWL_ERR 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) { + 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) { + return static_cast<CFWL_WidgetImp*>(GetImpl()) + ->SetThemeProvider(pThemeProvider); +} +FWL_ERR 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(); +} +CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { + return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); +} +FWL_ERR CFWL_WidgetImp::Initialize() { + IFWL_App* pApp = FWL_GetApp(); + if (!pApp) + return FWL_ERR_Indefinite; + IFWL_AdapterNative* 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())); + 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); + } + return FWL_ERR_Succeeded; +} +FWL_ERR 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; +} +FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (bAutoSize) { + if (HasEdge()) { + FX_FLOAT fEdge = GetEdgeWidth(); + rect.Inflate(fEdge, fEdge); + } + if (HasBorder()) { + FX_FLOAT fBorder = GetBorderSize(); + rect.Inflate(fBorder, fBorder); + } + } else { + rect = m_pProperties->m_rtWidget; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) { + IFWL_Widget* pForm = + m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + if (!pForm) + return FWL_ERR_Indefinite; + rect.Set(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); + if (pForm == m_pInterface) { + return FWL_ERR_Succeeded; + } + return TransformTo(pForm, rect); +} +FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { + CFX_RectF rtOld = m_pProperties->m_rtWidget; + m_pProperties->m_rtWidget = rect; + if (IsChild()) { + if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || + FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { + CFWL_EvtSizeChanged ev; + ev.m_pSrcTarget = m_pInterface; + ev.m_rtOld = rtOld; + ev.m_rtNew = rect; + IFWL_WidgetDelegate* pDelegate = SetDelegate(NULL); + if (pDelegate) { + pDelegate->OnProcessEvent(&ev); + } + } + return FWL_ERR_Succeeded; + } + m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { + GetEdgeRect(rect); + if (HasEdge()) { + FX_FLOAT fEdge = GetEdgeWidth(); + rect.Deflate(fEdge, fEdge); + } + return FWL_ERR_Succeeded; +} +IFWL_Widget* CFWL_WidgetImp::GetParent() { + return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent); +} +FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) { + m_pProperties->m_pParent = pParent; + m_pWidgetMgr->SetParent(pParent, m_pInterface); + return FWL_ERR_Succeeded; +} +IFWL_Widget* CFWL_WidgetImp::GetOwner() { + return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner); +} +FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) { + m_pProperties->m_pOwner = pOwner; + m_pWidgetMgr->SetOwner(pOwner, m_pInterface); + return FWL_ERR_Succeeded; +} +IFWL_Widget* CFWL_WidgetImp::GetOuter() { + return m_pOuter; +} +FX_DWORD CFWL_WidgetImp::GetStyles() { + return m_pProperties->m_dwStyles; +} +FWL_ERR CFWL_WidgetImp::ModifyStyles(FX_DWORD dwStylesAdded, + FX_DWORD dwStylesRemoved) { + m_pProperties->m_dwStyles = + (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_WidgetImp::GetStylesEx() { + return m_pProperties->m_dwStyleExes; +} +FWL_ERR CFWL_WidgetImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + m_pProperties->m_dwStyleExes = + (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_WidgetImp::GetStates() { + return m_pProperties->m_dwStates; +} +static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, + IFWL_Widget* widget, + CFWL_NoteDriver* noteDriver) { + IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); + while (child) { + noteDriver->NotifyTargetHide(child); + NotifyHideChildWidget(widgetMgr, child, noteDriver); + child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); + } +} +FWL_ERR CFWL_WidgetImp::SetStates(FX_DWORD 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); + } + } + return ret; +} +FWL_ERR 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; +} +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_ERR CFWL_WidgetImp::LockUpdate() { + m_iLock++; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::UnlockUpdate() { + if (IsLocked()) { + m_iLock--; + } + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { + CFX_RectF rtClient; + GetClientRect(rtClient); + if (rtClient.Contains(fx, fy)) { + return FWL_WGTHITTEST_Client; + } + if (HasEdge()) { + CFX_RectF rtEdge; + GetEdgeRect(rtEdge); + if (rtEdge.Contains(fx, fy)) { + return FWL_WGTHITTEST_Edge; + } + } + if (HasBorder()) { + CFX_RectF rtRelative; + GetRelativeRect(rtRelative); + if (rtRelative.Contains(fx, fy)) { + return FWL_WGTHITTEST_Border; + } + } + return FWL_WGTHITTEST_Unknown; +} +FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, + FX_FLOAT& fx, + FX_FLOAT& fy) { + if (m_pWidgetMgr->IsFormDisabled()) { + CFX_SizeF szOffset; + if (IsParent(pWidget)) { + szOffset = GetOffsetFromParent(pWidget); + } else { + szOffset = pWidget->GetOffsetFromParent(m_pInterface); + szOffset.x = -szOffset.x; + szOffset.y = -szOffset.y; + } + fx += szOffset.x; + fy += szOffset.y; + return FWL_ERR_Succeeded; + } + CFX_RectF r; + CFX_Matrix m; + IFWL_Widget* parent = GetParent(); + if (parent) { + GetWidgetRect(r); + fx += r.left; + fy += r.top; + GetMatrix(m, TRUE); + m.TransformPoint(fx, fy); + } + IFWL_Widget* form1 = + m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + if (!form1) + return FWL_ERR_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; + } + IFWL_Widget* form2 = + m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm); + if (!form2) + return FWL_ERR_Indefinite; + if (form1 != form2) { + form1->GetWidgetRect(r); + fx += r.left; + fy += r.top; + 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) { + pWidget->GetMatrix(m, TRUE); + CFX_Matrix m1; + m1.SetIdentity(); + m1.SetReverse(m); + m1.TransformPoint(fx, fy); + pWidget->GetWidgetRect(r); + fx -= r.left; + fy -= r.top; + } + return FWL_ERR_Succeeded; +} +FWL_ERR 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) { + if (!m_pProperties) + return FWL_ERR_Indefinite; + if (bGlobal) { + IFWL_Widget* parent = GetParent(); + CFX_PtrArray parents; + while (parent) { + parents.Add(parent); + parent = parent->GetParent(); + } + matrix.SetIdentity(); + CFX_Matrix ctmOnParent; + 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->GetMatrix(ctmOnParent, FALSE); + parent->GetWidgetRect(rect); + matrix.Concat(ctmOnParent, TRUE); + matrix.Translate(rect.left, rect.top, TRUE); + } + matrix.Concat(m_pProperties->m_ctmOnParent, TRUE); + parents.RemoveAll(); + } else { + matrix = m_pProperties->m_ctmOnParent; + } + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) { + if (!m_pProperties) + return FWL_ERR_Indefinite; + IFWL_Widget* parent = GetParent(); + if (!parent) { + return FWL_ERR_Indefinite; + } + m_pProperties->m_ctmOnParent = matrix; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return FWL_ERR_Indefinite; +} +IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() { + return m_pProperties->m_pThemeProvider; +} +FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { + m_pProperties->m_pThemeProvider = pThemeProvider; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) { + m_pProperties->m_pDataProvider = pDataProvider; + return FWL_ERR_Succeeded; +} +IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate( + IFWL_WidgetDelegate* pDelegate) { + if (!m_pCurDelegate) { + m_pCurDelegate = m_pDelegate; + } + if (!pDelegate) { + return m_pCurDelegate; + } + IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; + m_pCurDelegate = pDelegate; + return pOldDelegate; +} +IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const { + return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface()); +} +FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) { + m_pOwnerThread = pOwnerThread; + return FWL_ERR_Succeeded; +} +IFWL_Widget* CFWL_WidgetImp::GetInterface() const { + return m_pInterface; +} +void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { + m_pInterface = pInterface; +} +CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter) + : m_pProperties(new CFWL_WidgetImpProperties), + m_pPrivateData(NULL), + m_pDelegate(NULL), + m_pCurDelegate(NULL), + m_pOuter(pOuter), + m_pInterface(NULL), + m_iLock(0) { + *m_pProperties = properties; + m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + FXSYS_assert(m_pWidgetMgr != NULL); +} +CFWL_WidgetImp::~CFWL_WidgetImp() { + if (m_pPrivateData) { + delete m_pPrivateData; + m_pPrivateData = NULL; + } + if (m_pProperties) { + delete m_pProperties; + m_pProperties = NULL; + } +} +FX_BOOL CFWL_WidgetImp::IsEnabled() const { + return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; +} +FX_BOOL CFWL_WidgetImp::IsVisible() const { + return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; +} +FX_BOOL CFWL_WidgetImp::IsActive() const { + return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; +} +FX_BOOL CFWL_WidgetImp::IsOverLapper() const { + return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == + FWL_WGTSTYLE_OverLapper; +} +FX_BOOL CFWL_WidgetImp::IsPopup() const { + return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup); +} +FX_BOOL CFWL_WidgetImp::IsChild() const { + return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child); +} +FX_BOOL CFWL_WidgetImp::IsLocked() const { + return m_iLock > 0; +} +FX_BOOL CFWL_WidgetImp::IsOffscreen() const { + return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); +} +FX_BOOL CFWL_WidgetImp::HasBorder() const { + return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); +} +FX_BOOL CFWL_WidgetImp::HasEdge() const { + return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask); +} +void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) { + rtEdge = m_pProperties->m_rtWidget; + rtEdge.left = rtEdge.top = 0; + if (HasBorder()) { + FX_FLOAT fCX = GetBorderSize(); + FX_FLOAT fCY = GetBorderSize(FALSE); + rtEdge.Deflate(fCX, fCY); + } +} +FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) { + FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( + bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder)); + if (!pfBorder) + return 0; + return *pfBorder; +} +FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() { + FX_DWORD dwCapacity = 0; + switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) { + case FWL_WGTSTYLE_EdgeFlat: { + dwCapacity = FWL_WGTCAPACITY_EdgeFlat; + break; + } + case FWL_WGTSTYLE_EdgeRaised: { + dwCapacity = FWL_WGTCAPACITY_EdgeRaised; + break; + } + case FWL_WGTSTYLE_EdgeSunken: { + dwCapacity = FWL_WGTCAPACITY_EdgeSunken; + break; + } + } + if (dwCapacity > 0) { + FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); + return fRet ? *fRet : 0; + } + return 0; +} +void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) { + rect = m_pProperties->m_rtWidget; + rect.left = rect.top = 0; +} +void* CFWL_WidgetImp::GetThemeCapacity(FX_DWORD dwCapacity) { + IFWL_ThemeProvider* pTheme = GetAvailableTheme(); + if (!pTheme) + return NULL; + CFWL_ThemePart part; + part.m_pWidget = m_pInterface; + return pTheme->GetCapacity(&part, dwCapacity); +} +IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { + if (m_pProperties->m_pThemeProvider) { + return m_pProperties->m_pThemeProvider; + } + IFWL_Widget* pUp = m_pInterface; + do { + FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) + ? FWL_WGTRELATION_Owner + : FWL_WGTRELATION_Parent; + pUp = m_pWidgetMgr->GetWidget(pUp, relation); + if (pUp) { + IFWL_ThemeProvider* pRet = pUp->GetThemeProvider(); + if (pRet && pRet->IsValidWidget(m_pInterface)) { + return pRet; + } + } + } while (pUp); + return FWL_GetApp()->GetThemeProvider(); +} +CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() { + IFWL_Widget* pRet = m_pOuter; + if (!pRet) + return nullptr; + while (IFWL_Widget* pOuter = pRet->GetOuter()) { + pRet = pOuter; + } + return static_cast<CFWL_WidgetImp*>(pRet->GetImpl()); +} +#define FWL_WGT_CalcHeight 2048 +#define FWL_WGT_CalcWidth 2048 +#define FWL_WGT_CalcMultiLineDefWidth 120.0f +CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString& wsText, + IFWL_ThemeProvider* pTheme, + FX_BOOL bMultiLine, + int32_t iLineWidth) { + if (!pTheme) + return CFX_SizeF(); + + CFWL_ThemeText calPart; + calPart.m_pWidget = m_pInterface; + calPart.m_wsText = wsText; + calPart.m_dwTTOStyles = + bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; + calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; + CFX_RectF rect; + FX_FLOAT fWidth = bMultiLine + ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth + : FWL_WGT_CalcMultiLineDefWidth) + : FWL_WGT_CalcWidth; + rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); + pTheme->CalcTextRect(&calPart, rect); + return CFX_SizeF(rect.width, rect.height); +} +void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText, + IFWL_ThemeProvider* pTheme, + FX_DWORD dwTTOStyles, + int32_t iTTOAlign, + CFX_RectF& rect) { + CFWL_ThemeText calPart; + calPart.m_pWidget = m_pInterface; + calPart.m_wsText = wsText; + calPart.m_dwTTOStyles = dwTTOStyles; + calPart.m_iTTOAlign = iTTOAlign; + pTheme->CalcTextRect(&calPart, rect); +} +void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { + if (m_pWidgetMgr->IsFormDisabled()) + return; + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + if (!pDriver) + return; + IFWL_Widget* curFocus = pDriver->GetFocus(); + if (bFocus && curFocus != m_pInterface) { + pDriver->SetFocus(m_pInterface); + } else if (!bFocus && curFocus == m_pInterface) { + pDriver->SetFocus(NULL); + } +} +void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->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()) { + return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, + fMaxHeight, rtAnchor, rtPopup); + } else { + return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + } + } + return FALSE; +} +FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + FX_FLOAT fx = 0; + FX_FLOAT fy = 0; + FX_FLOAT fScreenWidth = 0; + FX_FLOAT fScreenHeight = 0; + GetScreenSize(fScreenWidth, fScreenHeight); + if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { + FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; + FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; + TransformTo(NULL, fx, fy); + if (fRight + fx > fScreenWidth || bLeft) { + rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, + rtPopup.height); + } else { + rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, + rtPopup.height); + } + } else { + FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; + TransformTo(NULL, fx, fy); + if (fBottom + fy > fScreenHeight) { + rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, + rtPopup.height); + } else { + rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, + rtPopup.height); + } + } + rtPopup.Offset(fx, fy); + return TRUE; +} +FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + FX_FLOAT fx = 0; + FX_FLOAT fy = 0; + FX_FLOAT fScreenWidth = 0; + FX_FLOAT fScreenHeight = 0; + GetScreenSize(fScreenWidth, fScreenHeight); + FX_FLOAT fPopHeight = rtPopup.height; + if (rtPopup.height > fMaxHeight) { + fPopHeight = fMaxHeight; + } else if (rtPopup.height < fMinHeight) { + fPopHeight = fMinHeight; + } + FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); + FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; + TransformTo(NULL, fx, fy); + if (fBottom + fy > fScreenHeight) { + rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); + } else { + rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); + } + rtPopup.Offset(fx, fy); + return TRUE; +} +FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + FX_FLOAT fx = 0; + FX_FLOAT fy = 0; + FX_FLOAT fScreenWidth = 0; + FX_FLOAT fScreenHeight = 0; + GetScreenSize(fScreenWidth, fScreenHeight); + TransformTo(NULL, fx, fy); + if (rtAnchor.bottom() + fy > fScreenHeight) { + rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, + rtPopup.height); + } else { + rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, + rtPopup.height); + } + rtPopup.Offset(fx, fy); + return TRUE; +} +FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { + return FALSE; +} +void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, + FX_DWORD dwFilter) { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); +} +void CFWL_WidgetImp::UnregisterEventTarget() { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + pNoteDriver->UnregisterEventTarget(m_pInterface); +} +void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { + if (!pNote) + return; + CFWL_EvtKey* pEvent = new CFWL_EvtKey; + pEvent->m_pSrcTarget = m_pInterface; + pEvent->m_dwCmd = pNote->m_dwCmd; + pEvent->m_dwKeyCode = pNote->m_dwKeyCode; + pEvent->m_dwFlags = pNote->m_dwFlags; + DispatchEvent(pEvent); + pEvent->Release(); +} +void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { + if (m_pOuter) { + IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); + pDelegate->OnProcessEvent(pEvent); + return; + } + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + pNoteDriver->SendNote(pEvent); +} +void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { + if (pRect) { + m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); + return; + } + CFX_RectF rect; + rect = m_pProperties->m_rtWidget; + rect.left = rect.top = 0; + m_pWidgetMgr->RepaintWidget(m_pInterface, &rect); +} +void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics, + int32_t iPartBk, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFX_RectF rtRelative; + GetRelativeRect(rtRelative); + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = iPartBk; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix, TRUE); + } + param.m_rtPart = rtRelative; + pTheme->DrawBackground(¶m); +} +void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics, + int32_t iPartBorder, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFX_RectF rtRelative; + GetRelativeRect(rtRelative); + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = iPartBorder; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix, TRUE); + } + param.m_rtPart = rtRelative; + pTheme->DrawBackground(¶m); +} +void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics, + int32_t iPartEdge, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { + CFX_RectF rtEdge; + GetEdgeRect(rtEdge); + CFWL_ThemeBackground param; + param.m_pWidget = m_pInterface; + param.m_iPart = iPartEdge; + param.m_pGraphics = pGraphics; + if (pMatrix) { + param.m_matrix.Concat(*pMatrix, TRUE); + } + param.m_rtPart = rtEdge; + pTheme->DrawBackground(¶m); +} +void CFWL_WidgetImp::NotifyDriver() { + IFWL_NoteThread* pThread = GetOwnerThread(); + if (!pThread) + return; + CFWL_NoteDriver* pDriver = + static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); + if (!pDriver) + return; + pDriver->NotifyTargetDestroy(m_pInterface); +} +CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { + if (pParent == GetInterface()) + return CFX_SizeF(); + + IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); + if (!pWidgetMgr) + return CFX_SizeF(); + + CFX_SizeF szRet(m_pProperties->m_rtWidget.left, + m_pProperties->m_rtWidget.top); + + IFWL_Widget* pDstWidget = GetParent(); + while (pDstWidget && pDstWidget != pParent) { + CFX_RectF rtDst; + pDstWidget->GetWidgetRect(rtDst); + szRet += CFX_SizeF(rtDst.left, rtDst.top); + pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent); + } + return szRet; +} +FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) { + IFWL_Widget* pUpWidget = GetParent(); + while (pUpWidget) { + if (pUpWidget == pParent) + return TRUE; + pUpWidget = pUpWidget->GetParent(); + } + return FALSE; +} +CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} +int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { + if (!pMessage->m_pDstTarget) + return 0; + CFWL_WidgetImp* pWidget = + static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl()); + FX_DWORD dwMsgCode = pMessage->GetClassID(); + switch (dwMsgCode) { + case FWL_MSGHASH_Mouse: { + CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); + CFWL_EvtMouse evt; + evt.m_pSrcTarget = pWidget->m_pInterface; + evt.m_pDstTarget = pWidget->m_pInterface; + evt.m_dwCmd = pMsgMouse->m_dwCmd; + evt.m_dwFlags = pMsgMouse->m_dwFlags; + evt.m_fx = pMsgMouse->m_fx; + evt.m_fy = pMsgMouse->m_fy; + pWidget->DispatchEvent(&evt); + break; + } + case FWL_MSGHASH_MouseWheel: { + CFWL_MsgMouseWheel* pMsgMouseWheel = + static_cast<CFWL_MsgMouseWheel*>(pMessage); + CFWL_EvtMouseWheel evt; + evt.m_pSrcTarget = pWidget->m_pInterface; + evt.m_pDstTarget = pWidget->m_pInterface; + evt.m_dwFlags = pMsgMouseWheel->m_dwFlags; + evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX; + evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY; + evt.m_fx = pMsgMouseWheel->m_fx; + evt.m_fy = pMsgMouseWheel->m_fy; + pWidget->DispatchEvent(&evt); + break; + } + case FWL_MSGHASH_Key: { + CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); + CFWL_EvtKey evt; + evt.m_pSrcTarget = pWidget->m_pInterface; + evt.m_pDstTarget = pWidget->m_pInterface; + evt.m_dwKeyCode = pMsgKey->m_dwKeyCode; + evt.m_dwFlags = pMsgKey->m_dwFlags; + evt.m_dwCmd = pMsgKey->m_dwCmd; + pWidget->DispatchEvent(&evt); + break; + } + case FWL_MSGHASH_SetFocus: { + CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage); + CFWL_EvtSetFocus evt; + evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; + evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget; + evt.m_pSetFocus = pWidget->m_pInterface; + pWidget->DispatchEvent(&evt); + break; + } + case FWL_MSGHASH_KillFocus: { + CFWL_MsgKillFocus* pMsgKillFocus = + static_cast<CFWL_MsgKillFocus*>(pMessage); + CFWL_EvtKillFocus evt; + evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget; + evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; + evt.m_pKillFocus = pWidget->m_pInterface; + pWidget->DispatchEvent(&evt); + break; + } + default: {} + } + 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; +} + +// 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, FX_DWORD dwStates) { + static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStates = + dwStates; +} +void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD 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; +} diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h new file mode 100644 index 0000000000..0aa7beb2fb --- /dev/null +++ b/xfa/fwl/core/fwl_widgetimp.h @@ -0,0 +1,162 @@ +// 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_WIDGETIMP_H_ +#define XFA_FWL_CORE_FWL_WIDGETIMP_H_ + +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/include/fwl/core/fwl_widget.h" + +class CFWL_NoteThreadImp; +class CFWL_WidgetImpProperties; +class CFWL_WidgetMgr; +class IFWL_DataProvider; +class IFWL_ThemeProvider; +class IFWL_Widget; +class IFWL_WidgetDelegate; + +class CFWL_WidgetImp : public CFWL_TargetImp { + public: + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + 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 IFWL_Widget* GetParent(); + virtual FWL_ERR SetParent(IFWL_Widget* pParent); + virtual IFWL_Widget* GetOwner(); + virtual FWL_ERR SetOwner(IFWL_Widget* pOwner); + virtual IFWL_Widget* GetOuter(); + virtual FX_DWORD GetStyles(); + virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, + FX_DWORD dwStylesRemoved); + virtual FX_DWORD GetStylesEx(); + virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved); + virtual FX_DWORD GetStates(); + virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); + virtual FWL_ERR 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 FX_DWORD 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 IFWL_ThemeProvider* GetThemeProvider(); + virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); + virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider); + virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); + virtual IFWL_NoteThread* GetOwnerThread() const; + FWL_ERR SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread); + IFWL_Widget* GetInterface() const; + void SetInterface(IFWL_Widget* pInterface); + CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); + + protected: + CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, + IFWL_Widget* pOuter); + virtual ~CFWL_WidgetImp(); + FX_BOOL IsEnabled() const; + FX_BOOL IsVisible() const; + FX_BOOL IsActive() const; + FX_BOOL IsOverLapper() const; + FX_BOOL IsPopup() const; + FX_BOOL IsChild() const; + FX_BOOL IsLocked() const; + FX_BOOL IsOffscreen() const; + FX_BOOL HasBorder() const; + FX_BOOL HasEdge() const; + void GetEdgeRect(CFX_RectF& rtEdge); + FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE); + FX_FLOAT GetEdgeWidth(); + void GetRelativeRect(CFX_RectF& rect); + void* GetThemeCapacity(FX_DWORD dwCapacity); + IFWL_ThemeProvider* GetAvailableTheme(); + CFWL_WidgetImp* GetRootOuter(); + CFX_SizeF CalcTextSize(const CFX_WideString& wsText, + IFWL_ThemeProvider* pTheme, + FX_BOOL bMultiLine = FALSE, + int32_t iLineWidth = -1); + void CalcTextRect(const CFX_WideString& wsText, + IFWL_ThemeProvider* pTheme, + FX_DWORD dwTTOStyles, + int32_t iTTOAlign, + CFX_RectF& rect); + void SetFocus(FX_BOOL bFocus); + void SetGrab(FX_BOOL bSet); + FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); + void RegisterEventTarget(IFWL_Widget* pEventSource = NULL, + FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); + void UnregisterEventTarget(); + void DispatchKeyEvent(CFWL_MsgKey* pNote); + void DispatchEvent(CFWL_Event* pEvent); + void Repaint(const CFX_RectF* pRect = NULL); + void DrawBackground(CFX_Graphics* pGraphics, + int32_t iPartBk, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawBorder(CFX_Graphics* pGraphics, + int32_t iPartBorder, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix = NULL); + void DrawEdge(CFX_Graphics* pGraphics, + int32_t 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_WidgetImpProperties* m_pProperties; + CFX_PrivateData* m_pPrivateData; + IFWL_WidgetDelegate* m_pDelegate; + IFWL_WidgetDelegate* m_pCurDelegate; + 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, FX_DWORD dwStates); + friend void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD 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; +}; + +#endif // XFA_FWL_CORE_FWL_WIDGETIMP_H_ diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp new file mode 100644 index 0000000000..ab507c221a --- /dev/null +++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp @@ -0,0 +1,1075 @@ +// 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_widgetmgrimp.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/include/fwl/adapter/fwl_adapternative.h" +#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/core/fwl_form.h" + +FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { +#if (_FX_OS_ == _FX_MACOSX_) + return FALSE; +#else + 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) { + m_pDelegate = new CFWL_WidgetMgrDelegate(this); + m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); + FXSYS_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) { + void* pWidget; + CFWL_WidgetMgrItem* pItem; + m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem); + delete pItem; + } + m_mapWidgetItem.RemoveAll(); + if (m_pDelegate) { + delete m_pDelegate; + m_pDelegate = NULL; + } +} +int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); + return TravelWidgetMgr(pParentItem, NULL, NULL); +} +IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget* pParent) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); + IFWL_Widget* pWidget = NULL; + TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget); + return pWidget; +} +IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget* pWidget, + FWL_WGTRELATION eRelation) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + if (!pItem) { + return NULL; + } + IFWL_Widget* pRet = NULL; + switch (eRelation) { + case FWL_WGTRELATION_Parent: { + pRet = pItem->pParent ? pItem->pParent->pWidget : NULL; + break; + } + case FWL_WGTRELATION_Owner: { + pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL; + break; + } + case FWL_WGTRELATION_FirstSibling: { + pItem = pItem->pPrevious; + while (pItem && pItem->pPrevious) { + pItem = pItem->pPrevious; + } + pRet = pItem ? pItem->pWidget : NULL; + break; + } + case FWL_WGTRELATION_PriorSibling: { + pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL; + break; + } + case FWL_WGTRELATION_NextSibling: { + pRet = pItem->pNext ? pItem->pNext->pWidget : NULL; + break; + } + case FWL_WGTRELATION_LastSibling: { + pItem = pItem->pNext; + while (pItem && pItem->pNext) { + pItem = pItem->pNext; + } + pRet = pItem ? pItem->pWidget : NULL; + break; + } + case FWL_WGTRELATION_FirstChild: { + pRet = pItem->pChild ? pItem->pChild->pWidget : NULL; + break; + } + case FWL_WGTRELATION_LastChild: { + pItem = pItem->pChild; + while (pItem && pItem->pNext) { + pItem = pItem->pNext; + } + pRet = pItem ? pItem->pWidget : NULL; + break; + } + case FWL_WGTRELATION_SystemForm: { + while (pItem) { + if (IsAbleNative(pItem->pWidget)) { + pRet = pItem->pWidget; + break; + } + pItem = pItem->pParent; + } + break; + } + default: {} + } + return pRet; +} +int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget* pWidget) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + if (!pItem) + return -1; + return TravelWidgetMgr(pItem->pParent, NULL, pItem); +} +FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + if (!pItem) + return FALSE; + if (!pItem->pParent) + return FALSE; + CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; + int32_t i = 0; + while (pChild) { + if (pChild == pItem) { + if (i == nIndex) { + return TRUE; + } + if (pChild->pPrevious) { + pChild->pPrevious->pNext = pChild->pNext; + } + if (pChild->pNext) { + pChild->pNext->pPrevious = pChild->pPrevious; + } + if (pItem->pParent->pChild == pItem) { + pItem->pParent->pChild = pItem->pNext; + } + pItem->pNext = NULL; + pItem->pPrevious = NULL; + break; + } + if (!pChild->pNext) { + break; + } + pChild = pChild->pNext; + ++i; + } + pChild = pItem->pParent->pChild; + if (pChild) { + if (nIndex < 0) { + while (pChild->pNext) { + pChild = pChild->pNext; + } + pChild->pNext = pItem; + pItem->pPrevious = pChild; + pItem->pNext = NULL; + return TRUE; + } + i = 0; + while (i < nIndex && pChild->pNext) { + pChild = pChild->pNext; + ++i; + } + if (!pChild->pNext) { + pChild->pNext = pItem; + pItem->pPrevious = pChild; + pItem->pNext = NULL; + return TRUE; + } + if (pChild->pPrevious) { + pItem->pPrevious = pChild->pPrevious; + pChild->pPrevious->pNext = pItem; + } + pChild->pPrevious = pItem; + pItem->pNext = pChild; + if (pItem->pParent->pChild == pChild) { + pItem->pParent->pChild = pItem; + } + } else { + pItem->pParent->pChild = pItem; + pItem->pPrevious = NULL; + pItem->pNext = NULL; + } + return TRUE; +} +FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, + const CFX_RectF* pRect) { + if (!m_pAdapter) + return FWL_ERR_Indefinite; + IFWL_Widget* pNative = pWidget; + CFX_RectF rect(*pRect); + if (IsFormDisabled()) { + IFWL_Widget* pOuter = pWidget->GetOuter(); + while (pOuter) { + CFX_RectF rtTemp; + pNative->GetWidgetRect(rtTemp); + rect.left += rtTemp.left; + rect.top += rtTemp.top; + pNative = pOuter; + pOuter = pOuter->GetOuter(); + } + } else if (!IsAbleNative(pWidget)) { + pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm); + if (!pNative) + return FWL_ERR_Indefinite; + pWidget->TransformTo(pNative, rect.left, rect.top); + } + AddRedrawCounts(pNative); + return m_pAdapter->RepaintWidget(pNative, &rect); +} +void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + if (!pItem) { + pItem = new CFWL_WidgetMgrItem; + pItem->pWidget = pWidget; + m_mapWidgetItem.SetAt(pWidget, pItem); + } + if (pItem->pParent && pItem->pParent != pParentItem) { + if (pItem->pPrevious) { + pItem->pPrevious->pNext = pItem->pNext; + } + if (pItem->pNext) { + pItem->pNext->pPrevious = pItem->pPrevious; + } + if (pItem->pParent->pChild == pItem) { + pItem->pParent->pChild = pItem->pNext; + } + } + pItem->pParent = pParentItem; + SetWidgetIndex(pWidget, -1); +} +void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, + IFWL_Widget* pChild, + int32_t nIndex) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); + if (!pParentItem) { + pParentItem = new CFWL_WidgetMgrItem; + pParentItem->pWidget = pParent; + m_mapWidgetItem.SetAt(pParent, pParentItem); + CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL); + pParentItem->pParent = pRoot; + SetWidgetIndex(pParent, -1); + } + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); + if (!pItem) { + pItem = new CFWL_WidgetMgrItem; + pItem->pWidget = pChild; + m_mapWidgetItem.SetAt(pChild, pItem); + } + if (pItem->pParent && pItem->pParent != pParentItem) { + if (pItem->pPrevious) { + pItem->pPrevious->pNext = pItem->pNext; + } + if (pItem->pNext) { + pItem->pNext->pPrevious = pItem->pPrevious; + } + if (pItem->pParent->pChild == pItem) { + pItem->pParent->pChild = pItem->pNext; + } + } + pItem->pParent = pParentItem; + SetWidgetIndex(pChild, nIndex); +} +void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + if (!pItem) { + return; + } + if (pItem->pPrevious) { + pItem->pPrevious->pNext = pItem->pNext; + } + if (pItem->pNext) { + pItem->pNext->pPrevious = pItem->pPrevious; + } + if (pItem->pParent && pItem->pParent->pChild == pItem) { + pItem->pParent->pChild = pItem->pNext; + } + CFWL_WidgetMgrItem* pChild = pItem->pChild; + while (pChild) { + CFWL_WidgetMgrItem* pNext = pChild->pNext; + RemoveWidget(pChild->pWidget); + pChild = pNext; + } + m_mapWidgetItem.RemoveKey(pWidget); + delete pItem; +} +void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner); + if (!pParentItem) { + pParentItem = new CFWL_WidgetMgrItem; + pParentItem->pWidget = pOwner; + m_mapWidgetItem.SetAt(pOwner, pParentItem); + CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL); + pParentItem->pParent = pRoot; + SetWidgetIndex(pOwner, -1); + } + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned); + if (!pItem) { + pItem = new CFWL_WidgetMgrItem; + pItem->pWidget = pOwned; + m_mapWidgetItem.SetAt(pOwned, pItem); + } + pItem->pOwner = pParentItem; +} +void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { + CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); + if (!pItem) + return; + if (pItem->pParent && pItem->pParent != pParentItem) { + if (pItem->pPrevious) { + pItem->pPrevious->pNext = pItem->pNext; + } + if (pItem->pNext) { + pItem->pNext->pPrevious = pItem->pPrevious; + } + if (pItem->pParent->pChild == pItem) { + pItem->pParent->pChild = pItem->pNext; + } + pItem->pNext = NULL; + pItem->pPrevious = NULL; + } + 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 { + if (pTemp == pParent) { + return TRUE; + } + pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); + } 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) { + if (FWL_UseOffscreen(pWidget)) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + pItem->iRedrawCounter++; + if (pItem->pOffscreen) { + CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); + if (pDevice && pDevice->GetBitmap()) { + CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); + if (pBitmap->GetWidth() - rect.width > 1 || + pBitmap->GetHeight() - rect.height > 1) { + delete pItem->pOffscreen; + pItem->pOffscreen = NULL; + } + } + } +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + 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); +} +IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, + FX_FLOAT x, + FX_FLOAT y) { + if (!parent) + return NULL; + FX_FLOAT x1; + FX_FLOAT y1; + IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); + while (child) { + if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { + x1 = x; + y1 = y; + CFX_Matrix matrixOnParent; + child->GetMatrix(matrixOnParent); + CFX_Matrix m; + m.SetIdentity(); + m.SetReverse(matrixOnParent); + m.TransformPoint(x1, y1); + CFX_RectF bounds; + child->GetWidgetRect(bounds); + if (bounds.Contains(x1, y1)) { + x1 -= bounds.left; + y1 -= bounds.top; + return GetWidgetAtPoint(child, x1, y1); + } + } + child = GetWidget(child, FWL_WGTRELATION_PriorSibling); + } + return parent; +} +void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!FWL_UseOffscreen(pForm)) { + return; + } + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm); + if (pItem->pOffscreen) { + delete pItem->pOffscreen; + pItem->pOffscreen = NULL; + } +} +IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, + IFWL_Widget* focus, + FX_BOOL& bFind) { + IFWL_Widget* child = + FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild); + while (child) { + if (focus == child) { + bFind = TRUE; + } + if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && + (!focus || (focus != child && bFind))) { + return child; + } + IFWL_Widget* bRet = nextTab(child, focus, bFind); + if (bRet) { + return bRet; + } + child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); + } + return NULL; +} +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++; + } + 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; +} +IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( + IFWL_Widget* pRadioButton) { + if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) { + return pRadioButton; + } + IFWL_Widget* pNext = pRadioButton; + while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) { + if (pNext->GetStyles() & FWL_WGTSTYLE_Group) { + return pNext; + } + } + 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) { + return pNext; + } + } + 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) { + 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); + } + return; + } + IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); + do { + group.Add(pNext); + pNext = GetSiblingRadioButton(pNext, TRUE); + if (!pNext) { + if (pFirst->GetClassID() == 3811304691) { + pNext = pFirst; + } else { + pNext = GetSiblingRadioButton(pFirst, TRUE); + } + } + } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); +} +IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { + if ((pParent->GetClassID() == 3521614244) && + (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) && + (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { + return child; + } + IFWL_Widget* find = GetDefaultButton(child); + if (find) { + return find; + } + child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); + } + return NULL; +} +void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + (pItem->iRedrawCounter)++; +} +void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + pItem->iRedrawCounter = 0; +} +CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(IFWL_Widget* pWidget) { + return static_cast<CFWL_WidgetMgrItem*>(m_mapWidgetItem.GetValueAt(pWidget)); +} +int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, + int32_t* pIndex, + CFWL_WidgetMgrItem* pItem, + IFWL_Widget** pWidget) { + if (!pParent) { + return 0; + } + int32_t iCount = 0; + CFWL_WidgetMgrItem* pChild = pParent->pChild; + while (pChild) { + iCount++; + if (pIndex) { + if (*pIndex == 0) { + *pWidget = pChild->pWidget; + return iCount; + } + pIndex--; + } + if (pItem && pItem == pChild) { + return iCount - 1; + } + pChild = pChild->pNext; + } + if (pIndex) { + return 0; + } else if (pItem) { + return -1; + } + return iCount - 1; +} +FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { + return FALSE; + } + FX_DWORD dwStyles = pWidget->GetStyles(); + return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == + FWL_WGTSTYLE_OverLapper) || + (dwStyles & FWL_WGTSTYLE_Popup); +} +FX_BOOL CFWL_WidgetMgr::IsThreadEnabled() { + return !(m_dwCapability & FWL_WGTMGR_DisableThread); +} +FX_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(); + return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); +} +CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) + : m_pWidgetMgr(pWidgetMgr) {} +FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(FX_DWORD dwCapability) { + m_pWidgetMgr->m_dwCapability = dwCapability; + return FWL_ERR_Succeeded; +} +int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { + if (!pMessage) + return 0; + if (!pMessage->m_pDstTarget) + return 0; + IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; + IFWL_NoteThread* pNoteThread = pDstWidget->GetOwnerThread(); + if (!pNoteThread) + return 0; + CFWL_NoteDriver* pNoteDriver = + static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver()); + if (!pNoteDriver) + return 0; + if (m_pWidgetMgr->IsThreadEnabled()) { + pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); + } + if (m_pWidgetMgr->IsFormDisabled()) { + pNoteDriver->ProcessMessage(pMessage); + } else { + pNoteDriver->QueueMessage(pMessage); + } +#if (_FX_OS_ == _FX_MACOSX_) + CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); + if (pTopLoop) { + pNoteDriver->UnqueueMessage(pTopLoop); + } +#endif + if (m_pWidgetMgr->IsThreadEnabled()) { + pMessage->Release(); + } + return FWL_ERR_Succeeded; +} +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; + 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; + } + 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); + pDelegate->OnDrawWidget(pTemp, pMatrix); + pGraphics->GetClipRect(clipBounds); + clipCopy = clipBounds; +#elif(_FX_OS_ == _FX_MACOSX_) + if (m_pWidgetMgr->IsFormDisabled()) { + IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); + pDelegate->OnDrawWidget(pTemp, pMatrix); + pGraphics->GetClipRect(clipBounds); + clipCopy = clipBounds; + } 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); + } + } +#endif + if (!m_pWidgetMgr->IsFormDisabled()) { + CFX_RectF rtClient; + pWidget->GetClientRect(rtClient); + clipBounds.Intersect(rtClient); + } + 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) { + continue; + } + CFX_RectF rtWidget; + child->GetWidgetRect(rtWidget); + if (rtWidget.IsEmpty()) { + continue; + } + CFX_Matrix widgetMatrix; + CFX_RectF clipBounds(rtWidget); + if (!bFormDisable) { + child->GetMatrix(widgetMatrix, TRUE); + } + if (pMatrix) { + widgetMatrix.Concat(*pMatrix); + } + if (!bFormDisable) { + widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); + clipBounds.Intersect(rtClip); + if (clipBounds.IsEmpty()) { + continue; + } + pGraphics->SaveGraphState(); + pGraphics->SetClipRect(clipBounds); + } + widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); + IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL); + if (pDelegate) { + if (m_pWidgetMgr->IsFormDisabled() || + IsNeedRepaint(child, &widgetMatrix, rtClip)) { + pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); + } + } + 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)) { + return pGraphics; + } + CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + if (!pItem->pOffscreen) { + pItem->pOffscreen = new CFX_Graphics; + CFX_RectF rect; + pWidget->GetWidgetRect(rect); + pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, + FXDIB_Argb); + } + CFX_RectF rect; + pGraphics->GetClipRect(rect); + pItem->pOffscreen->SetClipRect(rect); + return pItem->pOffscreen; +} +void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + CFX_RectF& rtClip, + const CFX_Matrix* pMatrix) { + if (FWL_UseOffscreen(pWidget)) { + CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, + pMatrix); +#ifdef _WIN32 + pItem->pOffscreen->ClearClip(); +#endif + } + CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(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) { + CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + if (pItem && pItem->iRedrawCounter > 0) { + pItem->iRedrawCounter = 0; + return TRUE; + } + CFX_RectF rtWidget; + pWidget->GetWidgetRect(rtWidget); + rtWidget.left = rtWidget.top = 0; + pMatrix->TransformRect(rtWidget); + if (!rtWidget.IntersectWith(rtDirty)) { + return FALSE; + } + IFWL_Widget* pChild = + FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); + 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]; + 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; + 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; + hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = + hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; + hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = + rtWidget.width + rtWidget.left; + hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; + hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = + hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; + hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = + hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; + hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = + rtWidget.height + rtWidget.top; + do { + CFX_RectF rect; + pChild->GetWidgetRect(rect); + CFX_RectF r = rect; + r.left += rtWidget.left; + r.top += rtWidget.top; + if (r.IsEmpty()) { + continue; + } + if (r.Contains(rtDirty)) { + return FALSE; + } + if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) { + bChildIntersectWithDirty = TRUE; + } + if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { + bOrginPtIntersectWidthChild = rect.Contains(0, 0); + } + if (rtChilds.IsEmpty()) { + rtChilds = rect; + } 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) { + continue; + } + if (!rtDirty.Contains(hitPoint[i].hitPoint)) { + hitPoint[i].bNotContainByDirty = TRUE; + continue; + } + if (r.Contains(hitPoint[i].hitPoint)) { + hitPoint[i].bNotNeedRepaint = TRUE; + } + } + } while ((pChild = FWL_GetWidgetMgr()->GetWidget( + pChild, FWL_WGTRELATION_NextSibling)) != NULL); + if (!bChildIntersectWithDirty) { + return TRUE; + } + if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { + return TRUE; + } + 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) { + repaintPoint--; + } + } + if (repaintPoint > 0) { + return TRUE; + } + pMatrix->TransformRect(rtChilds); + 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)) { + 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)) { + 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/xfa/fwl/core/fwl_widgetmgrimp.h b/xfa/fwl/core/fwl_widgetmgrimp.h new file mode 100644 index 0000000000..c29045d055 --- /dev/null +++ b/xfa/fwl/core/fwl_widgetmgrimp.h @@ -0,0 +1,170 @@ +// 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_WIDGETMGRIMP_H_ +#define XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_ + +#include "xfa/include/fwl/core/fwl_widgetmgr.h" + +class IFWL_Widget; +class IFWL_AdapterWidgetMgr; +class CFWL_WidgetMgrDelegate; +class IFWL_AdapterNative; + +class CFWL_WidgetMgrItem { + public: + CFWL_WidgetMgrItem() + : pParent(NULL), + pOwner(NULL), + pChild(NULL), + pPrevious(NULL), + pNext(NULL), + pWidget(NULL), + pOffscreen(NULL), + iRedrawCounter(0) +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + , + bOutsideChanged(FALSE) +#endif + { + } + ~CFWL_WidgetMgrItem() { + if (pOffscreen) { + delete pOffscreen; + pOffscreen = NULL; + } + } + CFWL_WidgetMgrItem* pParent; + CFWL_WidgetMgrItem* pOwner; + CFWL_WidgetMgrItem* pChild; + CFWL_WidgetMgrItem* pPrevious; + CFWL_WidgetMgrItem* pNext; + IFWL_Widget* pWidget; + CFX_Graphics* pOffscreen; + int32_t iRedrawCounter; +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + FX_BOOL bOutsideChanged; +#endif +}; + +class CFWL_WidgetMgr : public IFWL_WidgetMgr { + public: + CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative); + ~CFWL_WidgetMgr() override; + + // IFWL_WidgetMgr: + int32_t CountWidgets(IFWL_Widget* pParent = NULL) override; + IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override; + IFWL_Widget* GetWidget(IFWL_Widget* pWidget, + 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; + FX_DWORD GetCapability() override { return m_dwCapability; } + + void AddWidget(IFWL_Widget* pWidget); + void InsertWidget(IFWL_Widget* pParent, + IFWL_Widget* pChild, + int32_t nIndex = -1); + void RemoveWidget(IFWL_Widget* pWidget); + 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); + 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); + 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; } + CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget); + FX_BOOL IsThreadEnabled(); + FX_BOOL IsFormDisabled(); + FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget, + FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + + protected: + int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, + int32_t* pIndex, + CFWL_WidgetMgrItem* pItem, + IFWL_Widget** pWidget = NULL); + FX_BOOL IsAbleNative(IFWL_Widget* pWidget); + CFX_MapPtrToPtr m_mapWidgetItem; + IFWL_AdapterWidgetMgr* m_pAdapter; + CFWL_WidgetMgrDelegate* m_pDelegate; + friend class CFWL_WidgetMgrDelegate; + FX_DWORD m_dwCapability; +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + CFX_RectF m_rtScreen; +#endif +}; + +class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate { + public: + CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); + ~CFWL_WidgetMgrDelegate() override {} + + // IFWL_WidgetMgrDelegate: + FWL_ERR OnSetCapability( + FX_DWORD 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; + + protected: + void DrawChild(IFWL_Widget* pParent, + const CFX_RectF& rtClip, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix); + CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix); + void DrawWidgetAfter(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + CFX_RectF& rtClip, + const CFX_Matrix* pMatrix); + FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget, + CFX_Matrix* pMatrix, + const CFX_RectF& rtDirty); + FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget); + + CFWL_WidgetMgr* m_pWidgetMgr; +}; + +#endif // XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_ diff --git a/xfa/src/fwl/lightwidget/app.cpp b/xfa/fwl/lightwidget/app.cpp index 31a39c17f0..31a39c17f0 100644 --- a/xfa/src/fwl/lightwidget/app.cpp +++ b/xfa/fwl/lightwidget/app.cpp diff --git a/xfa/src/fwl/lightwidget/barcode.cpp b/xfa/fwl/lightwidget/barcode.cpp index 4f05837352..4f05837352 100644 --- a/xfa/src/fwl/lightwidget/barcode.cpp +++ b/xfa/fwl/lightwidget/barcode.cpp diff --git a/xfa/fwl/lightwidget/caret.cpp b/xfa/fwl/lightwidget/caret.cpp new file mode 100644 index 0000000000..279ea2d6f9 --- /dev/null +++ b/xfa/fwl/lightwidget/caret.cpp @@ -0,0 +1,47 @@ +// 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/include/fwl/lightwidget/caret.h" + +#include <memory> + +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/include/fwl/basewidget/fwl_caret.h" +#include "xfa/include/fwl/lightwidget/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(FX_DWORD& elapse) { + return static_cast<IFWL_Caret*>(m_pIface)->GetFrequency(elapse); +} +FWL_ERR CFWL_Caret::SetFrequency(FX_DWORD 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/xfa/src/fwl/lightwidget/checkbox.cpp b/xfa/fwl/lightwidget/checkbox.cpp index 6b7a370973..6b7a370973 100644 --- a/xfa/src/fwl/lightwidget/checkbox.cpp +++ b/xfa/fwl/lightwidget/checkbox.cpp diff --git a/xfa/src/fwl/lightwidget/combobox.cpp b/xfa/fwl/lightwidget/combobox.cpp index aadb0d5ab6..aadb0d5ab6 100644 --- a/xfa/src/fwl/lightwidget/combobox.cpp +++ b/xfa/fwl/lightwidget/combobox.cpp diff --git a/xfa/fwl/lightwidget/datetimepicker.cpp b/xfa/fwl/lightwidget/datetimepicker.cpp new file mode 100644 index 0000000000..bf1d976d90 --- /dev/null +++ b/xfa/fwl/lightwidget/datetimepicker.cpp @@ -0,0 +1,144 @@ +// 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/include/fwl/lightwidget/datetimepicker.h" + +#include <memory> + +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/core/fwl_error.h" +#include "xfa/include/fwl/core/fwl_note.h" +#include "xfa/include/fwl/core/fwl_widget.h" + +CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { + return new CFWL_DateTimePicker; +} +FWL_ERR CFWL_DateTimePicker::Initialize( + const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker( + IFWL_DateTimePicker::Create( + m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), + nullptr)); + FWL_ERR ret = pDateTimePicker->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pDateTimePicker.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR 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; +} +int32_t CFWL_DateTimePicker::CountSelRanges() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CountSelRanges(); +} +int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { + return static_cast<IFWL_DateTimePicker*>(m_pIface) + ->GetSelRange(nIndex, nStart); +} +FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetEditText(wsText); +} +FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditText(wsText); +} +FWL_ERR 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) { + return static_cast<IFWL_DateTimePicker*>(m_pIface) + ->SetCurSel(iYear, iMonth, iDay); +} +CFWL_DateTimePicker::CFWL_DateTimePicker() {} +CFWL_DateTimePicker::~CFWL_DateTimePicker() {} +CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() { + m_iYear = 2011; + m_iMonth = 1; + m_iDay = 1; +} +FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( + IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsData; + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday( + IFWL_Widget* pWidget, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) { + iYear = m_iYear; + iMonth = m_iMonth; + iDay = m_iDay; + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_DateTimePicker::CanUndo() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanUndo(); +} +FX_BOOL CFWL_DateTimePicker::CanRedo() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanRedo(); +} +FX_BOOL CFWL_DateTimePicker::Undo() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Undo(); +} +FX_BOOL CFWL_DateTimePicker::Redo() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Redo(); +} +FX_BOOL CFWL_DateTimePicker::CanCopy() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCopy(); +} +FX_BOOL CFWL_DateTimePicker::CanCut() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCut(); +} +FX_BOOL CFWL_DateTimePicker::CanSelectAll() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanSelectAll(); +} +FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCopy); +} +FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCut); +} +FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Paste(wsPaste); +} +FX_BOOL CFWL_DateTimePicker::SelectAll() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->SelectAll(); +} +FX_BOOL CFWL_DateTimePicker::Delete() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->Delete(); +} +FX_BOOL CFWL_DateTimePicker::DeSelect() { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->DeSelect(); +} +FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetBBox(rect); +} +FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { + return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditLimit(nLimit); +} +FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + return static_cast<IFWL_DateTimePicker*>(m_pIface) + ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); +} diff --git a/xfa/src/fwl/lightwidget/edit.cpp b/xfa/fwl/lightwidget/edit.cpp index 303943a8f6..303943a8f6 100644 --- a/xfa/src/fwl/lightwidget/edit.cpp +++ b/xfa/fwl/lightwidget/edit.cpp diff --git a/xfa/src/fwl/lightwidget/listbox.cpp b/xfa/fwl/lightwidget/listbox.cpp index 6a7a26cd1b..6a7a26cd1b 100644 --- a/xfa/src/fwl/lightwidget/listbox.cpp +++ b/xfa/fwl/lightwidget/listbox.cpp diff --git a/xfa/src/fwl/lightwidget/picturebox.cpp b/xfa/fwl/lightwidget/picturebox.cpp index e35741c3ac..e35741c3ac 100644 --- a/xfa/src/fwl/lightwidget/picturebox.cpp +++ b/xfa/fwl/lightwidget/picturebox.cpp diff --git a/xfa/src/fwl/lightwidget/pushbutton.cpp b/xfa/fwl/lightwidget/pushbutton.cpp index c9fb74e5f5..c9fb74e5f5 100644 --- a/xfa/src/fwl/lightwidget/pushbutton.cpp +++ b/xfa/fwl/lightwidget/pushbutton.cpp diff --git a/xfa/src/fwl/lightwidget/scrollbar.cpp b/xfa/fwl/lightwidget/scrollbar.cpp index cc927e724e..cc927e724e 100644 --- a/xfa/src/fwl/lightwidget/scrollbar.cpp +++ b/xfa/fwl/lightwidget/scrollbar.cpp diff --git a/xfa/src/fwl/lightwidget/theme.cpp b/xfa/fwl/lightwidget/theme.cpp index fe9f55928b..fe9f55928b 100644 --- a/xfa/src/fwl/lightwidget/theme.cpp +++ b/xfa/fwl/lightwidget/theme.cpp diff --git a/xfa/fwl/lightwidget/tooltipctrl.cpp b/xfa/fwl/lightwidget/tooltipctrl.cpp new file mode 100644 index 0000000000..323eed0282 --- /dev/null +++ b/xfa/fwl/lightwidget/tooltipctrl.cpp @@ -0,0 +1,111 @@ +// 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/include/fwl/lightwidget/tooltipctrl.h" + +#include <memory> + +#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) { + if (m_pIface) + return FWL_ERR_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) { + return ret; + } + m_pIface = pToolTip.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { + wsCaption = m_tooltipData.m_wsCaption; + return FWL_ERR_Succeeded; +} +FWL_ERR 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) { + 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) { + 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) { + 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) { + 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); +} +FWL_ERR CFWL_ToolTip::Show() { + return static_cast<IFWL_ToolTip*>(m_pIface)->Show(); +} +FWL_ERR CFWL_ToolTip::Hide() { + return static_cast<IFWL_ToolTip*>(m_pIface)->Hide(); +} +CFWL_ToolTip::CFWL_ToolTip() {} +CFWL_ToolTip::~CFWL_ToolTip() {} +CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { + m_wsCaption = L""; + m_nInitDelayTime = 500; + m_nAutoPopDelayTime = 50000; + m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); +} +FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsCaption; + return FWL_ERR_Succeeded; +} +int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { + return m_nInitDelayTime; +} +int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { + return m_nAutoPopDelayTime; +} +CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( + IFWL_Widget* pWidget) { + return m_pBitmap; +} +CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( + IFWL_Widget* pWidget) { + return m_fIconSize; +} +CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { + return m_fAnchor; +} diff --git a/xfa/fwl/lightwidget/widget.cpp b/xfa/fwl/lightwidget/widget.cpp new file mode 100644 index 0000000000..daaab3c300 --- /dev/null +++ b/xfa/fwl/lightwidget/widget.cpp @@ -0,0 +1,318 @@ +// 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/include/fwl/lightwidget/widget.h" + +#include "xfa/fde/tto/fde_textout.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/include/fwl/core/fwl_theme.h" +#include "xfa/include/fwl/core/fwl_thread.h" + +CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties( + IFWL_DataProvider* pDataProvider) const { + CFWL_WidgetImpProperties result; + result.m_ctmOnParent = m_ctmOnParent; + result.m_rtWidget = m_rtWidget; + result.m_dwStyles = m_dwStyles; + result.m_dwStyleExes = m_dwStyleExes; + result.m_dwStates = m_dwStates; + if (m_pParent) + result.m_pParent = m_pParent->GetWidget(); + if (m_pOwner) + result.m_pOwner = m_pOwner->GetWidget(); + result.m_pDataProvider = pDataProvider; + return result; +} +IFWL_Widget* CFWL_Widget::GetWidget() { + return m_pIface; +} +FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetClassName(wsClass); +} +FX_DWORD CFWL_Widget::GetClassID() const { + if (!m_pIface) + return 0; + return m_pIface->GetClassID(); +} +FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { + if (!m_pIface) + return FALSE; + return m_pIface->IsInstance(wsClass); +} +static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); +FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); +} +FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetWidgetRect(rect, bAutoSize); +} +FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetGlobalRect(rect); +} +FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetWidgetRect(rect); +} +FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetClientRect(rect); +} +CFWL_Widget* CFWL_Widget::GetParent() { + if (!m_pIface) + return NULL; + IFWL_Widget* parent = m_pIface->GetParent(); + if (parent) { + return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); + } + return NULL; +} +FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); +} +CFWL_Widget* CFWL_Widget::GetOwner() { + if (!m_pIface) + return NULL; + return NULL; +} +FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return FWL_ERR_Succeeded; +} +FX_DWORD CFWL_Widget::GetStyles() { + if (!m_pIface) + return 0; + return m_pIface->GetStyles(); +} +FWL_ERR CFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, + FX_DWORD dwStylesRemoved) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); +} +FX_DWORD CFWL_Widget::GetStylesEx() { + if (!m_pIface) + return 0; + return m_pIface->GetStylesEx(); +} +FWL_ERR CFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, + FX_DWORD dwStylesExRemoved) { + return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} +FX_DWORD CFWL_Widget::GetStates() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetStates(); +} +FWL_ERR CFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetStates(dwStates, bSet); +} +FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, + void* pData, + PD_CALLBACK_FREEDATA callback) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetPrivateData(module_id, pData, callback); +} +void* CFWL_Widget::GetPrivateData(void* module_id) { + if (!m_pIface) + return NULL; + return m_pIface->GetPrivateData(module_id); +} +FWL_ERR CFWL_Widget::Update() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->Update(); +} +FWL_ERR CFWL_Widget::LockUpdate() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->LockUpdate(); +} +FWL_ERR CFWL_Widget::UnlockUpdate() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->UnlockUpdate(); +} +FX_DWORD CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pIface) + return 0; + return m_pIface->HitTest(fx, fy); +} +FWL_ERR 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); +} +FWL_ERR 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); +} +FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetMatrix(matrix, bGlobal); +} +FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetMatrix(matrix); +} +FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->DrawWidget(pGraphics, pMatrix); +} +IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { + if (!m_pIface) + return NULL; + m_pDelegate = m_pIface->SetDelegate(pDelegate); + return m_pDelegate; +} +CFWL_Widget::CFWL_Widget() + : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { + m_pProperties = new CFWL_WidgetProperties; + m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + FXSYS_assert(m_pWidgetMgr != NULL); +} +CFWL_Widget::~CFWL_Widget() { + delete m_pProperties; + if (m_pIface) { + m_pIface->Finalize(); + delete m_pIface; + } +} +FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + CFX_RectF rect; + if (pRect) { + rect = *pRect; + } else { + m_pIface->GetWidgetRect(rect); + rect.left = rect.top = 0; + } + return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); +} +FWL_ERR 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(); + if (!pDriver) + return FWL_ERR_Indefinite; + if (bFocus) { + pDriver->SetFocus(m_pIface); + } else { + if (pDriver->GetFocus() == m_pIface) { + pDriver->SetFocus(NULL); + } + } + return FWL_ERR_Succeeded; +} +FWL_ERR 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(); + if (!pDriver) + return FWL_ERR_Indefinite; + pDriver->SetGrab(m_pIface, bSet); + return FWL_ERR_Succeeded; +} +void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, + FX_DWORD dwFilter) { + if (!m_pIface) + return; + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + IFWL_Widget* pEventSourceImp = + !pEventSource ? NULL : pEventSource->GetWidget(); + pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); +} +void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { + if (!m_pIface) + return; + if (m_pIface->GetOuter()) { + return; + } + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + pNoteDriver->SendNote(pEvent); +} +#define FWL_WGT_CalcHeight 2048 +#define FWL_WGT_CalcWidth 2048 +#define FWL_WGT_CalcMultiLineDefWidth 120.0f +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(); + + CFWL_ThemeText calPart; + calPart.m_pWidget = m_pIface; + calPart.m_wsText = wsText; + calPart.m_dwTTOStyles = + bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; + calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; + CFX_RectF rect; + FX_FLOAT fWidth = bMultiLine + ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth + : FWL_WGT_CalcMultiLineDefWidth) + : FWL_WGT_CalcWidth; + rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); + pTheme->CalcTextRect(&calPart, rect); + return CFX_SizeF(rect.width, rect.height); +} +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; +} diff --git a/xfa/src/fwl/theme/barcodetp.cpp b/xfa/fwl/theme/barcodetp.cpp index 477ce99d9b..477ce99d9b 100644 --- a/xfa/src/fwl/theme/barcodetp.cpp +++ b/xfa/fwl/theme/barcodetp.cpp diff --git a/xfa/src/fwl/theme/carettp.cpp b/xfa/fwl/theme/carettp.cpp index 88b01d9f3d..88b01d9f3d 100644 --- a/xfa/src/fwl/theme/carettp.cpp +++ b/xfa/fwl/theme/carettp.cpp diff --git a/xfa/fwl/theme/checkboxtp.cpp b/xfa/fwl/theme/checkboxtp.cpp new file mode 100644 index 0000000000..b65a550936 --- /dev/null +++ b/xfa/fwl/theme/checkboxtp.cpp @@ -0,0 +1,532 @@ +// 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/include/fwl/theme/checkboxtp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/include/fwl/basewidget/fwl_checkbox.h" +#include "xfa/include/fwl/core/fwl_widget.h" + +#define CHECKBOX_SIZE_SIGNMARGIN 3 +#define CHECKBOX_SIZE_SIGNBORDER 2 +#define CHECKBOX_SIZE_SIGNPATH 100 +#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; + SetThemeData(0); +} +CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { + if (m_pThemeData) { + delete m_pThemeData; + m_pThemeData = NULL; + } + 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; +} +FX_DWORD CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget, + FX_DWORD dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +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 + ? FWLTHEME_CAPACITY_TextDisColor + : FWLTHEME_CAPACITY_TextColor); + return CFWL_WidgetTP::DrawText(pParams); +} +FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_CKB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CKB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CKB_Background: { + FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + &pParams->m_matrix); + if (pParams->m_dwStates & FWL_PARTSTATE_CKB_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: { + 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)) { + 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); + break; + } + default: { return FALSE; } + } + return TRUE; +} +FWL_ERR CFWL_CheckBoxTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_CheckBoxTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_DWORD dwStates, + CFX_Matrix* pMatrix) { + dwStates &= 0x03; + int32_t fillMode = FXFILL_WINDING; + FX_DWORD dwStyleEx = pWidget->GetStylesEx(); + dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; + CFX_Path path; + path.Create(); + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_BOOL bClipSign = + (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_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); + } + } 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); + path.AddEllipse(rtClip); + } + } + int32_t iTheme = 1; + if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) { + iTheme = 2; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Pressed) { + iTheme = 3; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Disabled) { + iTheme = 4; + } + if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) { + iTheme += 4; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == + FWL_PARTSTATE_CKB_Neutral) { + iTheme += 8; + } + DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, + m_pThemeData->clrBoxBk[iTheme][0], + m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); +} +void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + FX_DWORD dwStates, + CFX_Matrix* pMatrix) { + CFX_RectF rtSign(*pRtBox); + rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN); + FX_DWORD 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)) { + 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; + } + } + } + if (bCheck) { + FX_DWORD dwStyle = pWidget->GetStylesEx(); + switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { + case FWL_STYLEEXT_CKB_SignShapeCheck: { + DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeCircle: { + rtSign.Deflate(1, 1); + DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeCross: { + DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeDiamond: { + DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeSquare: { + DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeStar: { + DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + } + } else { + FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix); + } +} +void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + CFX_Matrix* pMatrix) { + ((CFX_RectF*)pRtSign)->Inflate(-3, -3); + FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix); +} +void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + if (!m_pCheckPath) { + initCheckPath(pRtSign->width); + } + CFX_Matrix mt; + mt.SetIdentity(); + mt.Translate(pRtSign->left, pRtSign->top); + mt.Concat(*pMatrix); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + path.AddEllipse(*pRtSign); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fRight = pRtSign->right(); + FX_FLOAT fBottom = pRtSign->bottom(); + path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom); + path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetStrokeColor(&crFill); + pGraphics->SetLineWidth(1.0f); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fWidth = pRtSign->width; + FX_FLOAT fHeight = pRtSign->height; + FX_FLOAT fBottom = pRtSign->bottom(); + path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); + path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); + path.LineTo(pRtSign->left + fWidth / 2, fBottom); + path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); + path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, + pRtSign->height); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fBottom = pRtSign->bottom(); + FX_FLOAT fRadius = + (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); + CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, + (pRtSign->top + fBottom) / 2.0f); + FX_FLOAT px[5], py[5]; + FX_FLOAT fAngel = FX_PI / 10.0f; + for (int32_t i = 0; i < 5; i++) { + px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); + py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); + fAngel += FX_PI * 2 / 5.0f; + } + path.MoveTo(px[0], py[0]); + int32_t nNext = 0; + for (int32_t j = 0; j < 5; j++) { + nNext += 2; + if (nNext >= 5) { + nNext -= 5; + } + path.LineTo(px[nNext], py[nNext]); + } + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + FX_BOOL bDisable, + CFX_Matrix* pMatrix) { + switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) { + case FWL_STYLEEXT_CKB_ShapeSolidSquare: { + DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable + : m_pThemeData->clrSignBorderNormal, + pRtBox, 1, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSunkenSquare: { + Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, + pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, + CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSolidCircle: { + DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable + : m_pThemeData->clrSignBorderNormal, + pRtBox, 1, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSunkenCircle: { + Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, + pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, + CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); + break; + } + } +} +void CFWL_CheckBoxTP::SetThemeData(FX_DWORD dwID) { + FX_DWORD* pData = (FX_DWORD*)&m_pThemeData->clrBoxBk; + if (dwID) { + *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114); + m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); + m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138); + m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26); + m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); + m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); + m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); + } else { + *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128); + m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); + m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128); + m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26); + m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); + m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); + m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); + } +} +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; + 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); + CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f); + CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f); + CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f); + CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f); + CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f); + CFX_PointF pt32(fWidth / 4.0f, fBottom); + CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f), + fBottom + fHeight * 4 / 5.0f); + CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f), + fBottom + fHeight * 4 / 5.0f); + CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f); + CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f); + CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f); + CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f); + m_pCheckPath->MoveTo(pt1.x, pt1.y); + FX_FLOAT px1 = pt12.x - pt1.x; + 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); + 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); + 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); + 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); + 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; + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, 0, 0); + mt.Scale(fScale, fScale); + CFX_PathData* pData = m_pCheckPath->GetPathData(); + pData->Transform(&mt); + } +} diff --git a/xfa/src/fwl/theme/comboboxtp.cpp b/xfa/fwl/theme/comboboxtp.cpp index 33be07d44c..33be07d44c 100644 --- a/xfa/src/fwl/theme/comboboxtp.cpp +++ b/xfa/fwl/theme/comboboxtp.cpp diff --git a/xfa/src/fwl/theme/datetimepickertp.cpp b/xfa/fwl/theme/datetimepickertp.cpp index 5efe0b850e..5efe0b850e 100644 --- a/xfa/src/fwl/theme/datetimepickertp.cpp +++ b/xfa/fwl/theme/datetimepickertp.cpp diff --git a/xfa/src/fwl/theme/edittp.cpp b/xfa/fwl/theme/edittp.cpp index a206faffe8..a206faffe8 100644 --- a/xfa/src/fwl/theme/edittp.cpp +++ b/xfa/fwl/theme/edittp.cpp diff --git a/xfa/fwl/theme/formtp.cpp b/xfa/fwl/theme/formtp.cpp new file mode 100644 index 0000000000..5f75535f3b --- /dev/null +++ b/xfa/fwl/theme/formtp.cpp @@ -0,0 +1,893 @@ +// 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/include/fwl/theme/formtp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/include/fwl/core/fwl_form.h" +#include "xfa/include/fwl/core/fwl_widget.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 + +CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) { + m_pThemeData = new SBThemeData; + SetThemeData(0); + m_rtDisLBorder.Reset(); + m_rtDisRBorder.Reset(); + m_rtDisBBorder.Reset(); + m_rtDisCaption.Reset(); +} +CFWL_FormTP::~CFWL_FormTP() { + if (m_pThemeData) { + delete m_pThemeData; + m_pThemeData = NULL; + } +} +FWL_ERR CFWL_FormTP::Initialize() { + InitTTO(); + InitCaption(TRUE); + InitCaption(FALSE); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_FormTP::Finalize() { + FinalizeTTO(); + if (m_pActiveBitmap) { + delete m_pActiveBitmap; + m_pActiveBitmap = NULL; + } + if (m_pDeactivebitmap) { + delete m_pDeactivebitmap; + m_pDeactivebitmap = NULL; + } + return CFWL_WidgetTP::Finalize(); +} +FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + FX_DWORD dwHash = pWidget->GetClassID(); + return dwHash == FWL_CLASSHASH_Form; +} +FX_DWORD CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget, + FX_DWORD dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + InitCaption(TRUE); + InitCaption(FALSE); + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + int32_t iActive = 0; + if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) { + iActive = 1; + } + FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; + switch (pParams->m_dwStates & 0x03) { + case FWL_PARTSTATE_FRM_Hover: { + eState = FWLTHEME_STATE_Hover; + break; + } + case FWL_PARTSTATE_FRM_Pressed: { + eState = FWLTHEME_STATE_Pressed; + break; + } + case FWL_PARTSTATE_FRM_Disabled: { + eState = FWLTHEME_STATE_Disabale; + break; + } + default: {} + } + switch (pParams->m_iPart) { + case FWL_PART_FRM_Border: { + DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_FRM_Background: { + FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + &pParams->m_matrix); + break; + } + case FWL_PART_FRM_Caption: { + DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_NarrowCaption: { + DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_CloseBox: { + DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_MinimizeBox: { + DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_MaximizeBox: { + DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + pParams->m_dwData, &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_Icon: { + DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart, + eState, &pParams->m_matrix, iActive); + break; + } + default: {} + } + return TRUE; +} +FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) + return FALSE; + if (pParams->m_iPart == FWL_PART_FRM_Caption) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } else { + m_pTextOut->SetTextColor(0xFF000000); + } + return CFWL_WidgetTP::DrawText(pParams); +} +void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart, + FX_DWORD dwCapacity) { + FX_BOOL bDefPro = FALSE; + FX_BOOL bDwordVal = FALSE; + switch (dwCapacity) { + case FWL_WGTCAPACITY_CXBorder: { + m_fValue = FWLTHEME_CAPACITY_CXFormBorder; + break; + } + case FWL_WGTCAPACITY_CYBorder: { + m_fValue = FWLTHEME_CAPACITY_CYFormBorder; + break; + } + case FWL_WGTCAPACITY_FRM_CYCaption: { + m_fValue = FWLTHEME_CAPACITY_CYCaption; + break; + } + case FWL_WGTCAPACITY_FRM_CYNarrowCaption: { + m_fValue = FWLTHEME_CAPACITY_CYCaption; + break; + } + case FWL_WGTCAPACITY_TextColor: { + bDwordVal = TRUE; + m_dwValue = FWLTHEME_CAPACITY_FormTextColor; + break; + } + case FWL_WGTCAPACITY_FRM_BigIcon: { + m_fValue = FWLTHEME_CAPACITY_BigIconSize; + break; + } + case FWL_WGTCAPACITY_FRM_SmallIcon: { + m_fValue = FWLTHEME_CAPACITY_SmallIconSize; + break; + } + default: { bDefPro = TRUE; } + } + if (!bDefPro) { + if (bDwordVal) { + return &m_dwValue; + } + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart, + CFX_RectF& rtPart) { + switch (pThemePart->m_iPart) { + case FWL_PART_FRM_CloseBox: { + CalCloseBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_MaximizeBox: { + CalMaxBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_MinimizeBox: { + CalMinBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_HeadText: { + CalCaption(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_Icon: { + CalIcon(pThemePart->m_pWidget, rtPart); + break; + } + default: {} + } + return FWL_ERR_Succeeded; +} +void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + FX_DWORD dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + 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); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); + } +} +void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + FX_DWORD dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + 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); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + + FWLTHEME_FORMBTN_Span * 2, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); + } +} +void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + FX_DWORD dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + 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); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + + FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 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); +} +void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {} +void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + CFX_RectF rt; + rt.Set(pRect->left, pRect->top, 1, pRect->height); + FX_FLOAT fBottom, fRight; + fBottom = pRect->bottom(); + fRight = pRect->right(); + CFX_Path path; + path.Create(); + CFX_Color clrLine; + path.Clear(); + path.MoveTo(pRect->left, pRect->top); + path.LineTo(pRect->left, fBottom - 1); + path.LineTo(fRight - 1, fBottom - 1); + path.LineTo(fRight - 1, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][2]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 1, pRect->top); + path.LineTo(pRect->left + 1, fBottom - 2); + path.LineTo(fRight - 2, fBottom - 2); + path.LineTo(fRight - 2, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][1]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 2, pRect->top); + path.LineTo(pRect->left + 2, fBottom - 3); + path.LineTo(fRight - 3, fBottom - 3); + path.LineTo(fRight - 3, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][0]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 3, pRect->top); + path.LineTo(pRect->left + 3, fBottom - 4); + path.LineTo(fRight - 4, fBottom - 4); + path.LineTo(fRight - 4, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][4]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29); + m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, + pRect->height - 29); + m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4); + m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29); +} +void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + CFX_RectF rt; + FX_FLOAT fBottom, fRight; + fBottom = pRect->bottom(); + fRight = pRect->right(); + rt.Set(pRect->left, pRect->top, pRect->width, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt, + pMatrix); + rt.Offset(0, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt, + pMatrix); + rt.Offset(0, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt, + pMatrix); + rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt, + pMatrix); + rt.Offset(0, -1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt, + pMatrix); + rt.Set(pRect->left, pRect->top, 1, pRect->height); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt, + pMatrix); + rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt, + pMatrix); + rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt, + pMatrix); + rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt, + pMatrix); + rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt, + pMatrix); + rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt, + pMatrix); + CFX_RectF rect(*pRect); + rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5); + if (iActive == 0) { + pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix); + } else { + pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix); + } +} +void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) {} +void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + pGraphics->SaveGraphState(); + CFX_RectF rt(*pRect); + pGraphics->SetLineWidth(1.0f); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); + path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); + CFX_Color crFill; + crFill = m_pThemeData->clrBtnEdgeOut[iActive]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); + path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); + path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); + path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); + crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); + path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); + crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); + path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); + crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); + DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, + fBottom - 2, + m_pThemeData->clrCloseBtBKStart[iActive][eState - 1], + m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path, + FXFILL_WINDING, pMatrix); + CFX_RectF rtX(*pRect); + rtX.Inflate(-5, -5); + path.Clear(); + FX_FLOAT frtXRight = rtX.right(); + FX_FLOAT frtXBottom = rtX.bottom(); + path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom); + path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom); + path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1); + path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top); + path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top); + path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1); + CFX_Color clrLine(0xffffffff); + pGraphics->SetLineWidth(1.0f); + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + pGraphics->SaveGraphState(); + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + CFX_RectF rt(*pRect); + pGraphics->SetLineWidth(1.0f); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); + path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); + CFX_Color crFill; + crFill = m_pThemeData->clrBtnEdgeOut[iActive]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); + path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); + path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); + path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); + crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); + path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); + crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); + path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); + crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); + path.Clear(); + path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); + DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, + fBottom - 2, + m_pThemeData->clrNormalBtBKStart[iActive][eState - 1], + m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path, + FXFILL_WINDING, pMatrix); +} +void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); + CFX_RectF rtMin; + rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14, + pRect->height - 18); + FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix); +} +void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + FX_BOOL bMax, + CFX_Matrix* pMatrix, + int32_t iActive) { + DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + if (bMax) { + CFX_Path path; + path.Create(); + path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14, + pRect->top + 6); + path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11, + pRect->top + 9); + pGraphics->SaveGraphState(); + pGraphics->SetLineWidth(2); + CFX_Color crStroke(0xFFFFFFFF); + pGraphics->SetStrokeColor(&crStroke); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->SetLineWidth(1); + path.Clear(); + path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4, + pRect->top + 14); + path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10, + pRect->top + 14); + path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13, + pRect->top + 11); + path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10, + pRect->top + 14); + path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12, + pRect->top + 11); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); + } else { + CFX_RectF rtMax(*pRect); + rtMax.Inflate(-5, -5); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10, + fHeight - 10); + path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12, + fHeight - 14); + pGraphics->SaveGraphState(); + CFX_Color crFill(0xFFFFFFFF); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); + } +} +void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics, + CFX_DIBitmap* pDIBitmap, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix); +} +void CFWL_FormTP::SetThemeData(FX_DWORD dwID) { + m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255); + m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148); + m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5); + m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176); + m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71); + m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20); + m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33); + m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107); + m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54); + m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74); + m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51); + m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28); + m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13); + if (dwID) { + m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131); + m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128); + m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94); + m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133); + m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125); + m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103); + m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79); + m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201); + m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133); + m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121); + m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103); + m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162); + m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84); + m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208); + m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112); + m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190); + m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88); + m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137); + m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83); + m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123); + m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); + m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); + m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94); + m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133); + m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127); + m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133); + } else { + m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226); + m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226); + m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200); + m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220); + m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210); + m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234); + m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193); + m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139); + m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238); + m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255); + m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252); + m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255); + m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207); + m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112); + m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188); + m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250); + m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248); + m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255); + m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255); + m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245); + m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187); + m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245); + m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195); + m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244); + m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185); + m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); + m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); + m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241); + m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220); + m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160); + m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140); + m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239); + } + m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0]; + m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0]; + m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1]; + m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1]; + m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2]; + m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2]; + m_pThemeData->clrCloseBtEdgeLight[1][0] = + m_pThemeData->clrCloseBtEdgeLight[0][0]; + m_pThemeData->clrCloseBtEdgeDark[1][0] = + m_pThemeData->clrCloseBtEdgeDark[0][0]; + m_pThemeData->clrCloseBtEdgeLight[1][1] = + m_pThemeData->clrCloseBtEdgeLight[0][1]; + m_pThemeData->clrCloseBtEdgeDark[1][1] = + m_pThemeData->clrCloseBtEdgeDark[0][1]; + m_pThemeData->clrCloseBtEdgeLight[1][2] = + m_pThemeData->clrCloseBtEdgeLight[0][2]; + m_pThemeData->clrCloseBtEdgeDark[1][2] = + m_pThemeData->clrCloseBtEdgeDark[0][2]; + m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0]; + m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1]; + m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2]; + m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3]; + m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2]; + m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1]; + m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0]; + m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0]; + m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1]; + m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2]; + m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0]; + m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1]; + m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2]; + m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0]; + m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1]; + m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2]; + m_pThemeData->clrNormalBtBKStart[1][2] = + m_pThemeData->clrNormalBtBKStart[0][2]; + m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2]; + m_pThemeData->clrNormalBtBKStart[1][0] = + m_pThemeData->clrNormalBtBKStart[0][0]; + m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0]; + m_pThemeData->clrNormalBtBKStart[1][1] = + m_pThemeData->clrNormalBtBKStart[0][1]; + m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1]; + m_pThemeData->clrNormalBtEdgeLight[1][0] = + m_pThemeData->clrNormalBtEdgeLight[0][0]; + m_pThemeData->clrNormalBtEdgeDark[1][0] = + m_pThemeData->clrNormalBtEdgeDark[0][0]; + m_pThemeData->clrNormalBtEdgeLight[1][1] = + m_pThemeData->clrNormalBtEdgeLight[0][1]; + m_pThemeData->clrNormalBtEdgeDark[1][1] = + m_pThemeData->clrNormalBtEdgeDark[0][1]; + m_pThemeData->clrNormalBtEdgeLight[1][2] = + m_pThemeData->clrNormalBtEdgeLight[0][2]; + m_pThemeData->clrNormalBtEdgeDark[1][2] = + m_pThemeData->clrNormalBtEdgeDark[0][2]; + m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0]; + m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1]; + m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2]; + m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0]; + m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0]; + m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1]; + m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2]; + m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3]; + m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4]; + m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0]; + DeactiveForm(); +} +void CFWL_FormTP::DeactiveForm() { + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][3]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][4]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorderLight[1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][2]); +} +void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) { + int32_t iAlfaF, iRF, iGF, iBF; + int32_t iAlfaB, iRB, iGB, iBB; + ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF); + ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB); + clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255, + iGB + (iGF - iGB) * iAlfaF / 255, + iBB + (iBF - iBB) * iAlfaF / 255); +} +void CFWL_FormTP::InitCaption(FX_BOOL bActive) { + if (bActive) { + CFX_FxgeDevice dev; + CFX_Graphics gs; + CFX_Path path; + path.Create(); + if (m_pActiveBitmap) { + delete m_pActiveBitmap; + m_pActiveBitmap = NULL; + } + m_pActiveBitmap = new CFX_DIBitmap; + m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); + dev.Attach(m_pActiveBitmap); + gs.Create(&dev); + path.AddRectangle(0, 0, 1, 5); + DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], + m_pThemeData->clrHeadBK[0][1], &path); + path.Clear(); + path.AddRectangle(0, 5, 1, 15); + 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], + 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; + } + m_pDeactivebitmap = new CFX_DIBitmap; + m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); + dev.Attach(m_pDeactivebitmap); + gs.Create(&dev); + path.AddRectangle(0, 0, 1, 5); + DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], + m_pThemeData->clrHeadBK[1][1], &path); + path.Clear(); + path.AddRectangle(0, 5, 1, 15); + 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], + m_pThemeData->clrHeadBK[1][3], &path); + } +} diff --git a/xfa/src/fwl/theme/listboxtp.cpp b/xfa/fwl/theme/listboxtp.cpp index 8ffe669835..8ffe669835 100644 --- a/xfa/src/fwl/theme/listboxtp.cpp +++ b/xfa/fwl/theme/listboxtp.cpp diff --git a/xfa/fwl/theme/monthcalendartp.cpp b/xfa/fwl/theme/monthcalendartp.cpp new file mode 100644 index 0000000000..6ab99ae439 --- /dev/null +++ b/xfa/fwl/theme/monthcalendartp.cpp @@ -0,0 +1,582 @@ +// 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/include/fwl/theme/monthcalendartp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" +#include "xfa/include/fwl/core/fwl_widget.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 + +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; +} +FX_DWORD CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget, + FX_DWORD dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_MCD_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Background: { + DrawTotalBK(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Header: { + DrawHeadBk(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_LBtn: { +#ifdef THEME_XPSimilar + 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 + 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: { + DrawHSeperator(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_DatesIn: { + DrawDatesInBK(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_TodayCircle: { + DrawTodayCircle(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_DateInCircle: { + DrawDatesInCircle(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_WeekNumSep: { + DrawWeekNumSep(pParams, &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) + return FALSE; + if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && + !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && + (pParams->m_dwStates & + (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } else if (pParams->m_iPart == FWL_PART_MCD_Caption) { + m_pTextOut->SetTextColor(m_pThemeData->clrCaption); + } else { + m_pTextOut->SetTextColor(0xFF000000); + } + return CFWL_WidgetTP::DrawText(pParams); +} +void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart, + FX_DWORD dwCapacity) { + FX_BOOL bDefPro = FALSE; + FX_BOOL bDwordVal = FALSE; + switch (dwCapacity) { + case FWL_WGTCAPACITY_MC_HEADER_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_Height: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: { + bDwordVal = TRUE; + m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HSEP_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_VSEP_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_WEEK_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_SEP_DOFFSET: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET; + break; + } + case FWL_WGTCAPACITY_MC_SEP_X: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_X; + break; + } + case FWL_WGTCAPACITY_MC_SEP_Y: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_Y; + break; + } + case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_WIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT; + break; + } + case FWL_WGTCAPACITY_MC_WIDTH: { + m_fValue = FWL_MC_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEIGHT: { + m_fValue = FWL_MC_HEIGHT; + break; + } + case FWL_MCCAPACITY_Sun: { + wsResource = L"Sun"; + return &wsResource; + } + case FWL_MCCAPACITY_Mon: { + wsResource = L"Mon"; + return &wsResource; + } + case FWL_MCCAPACITY_Tue: { + wsResource = L"Tue"; + return &wsResource; + } + case FWL_MCCAPACITY_Wed: { + wsResource = L"Wed"; + return &wsResource; + } + case FWL_MCCAPACITY_Thu: { + wsResource = L"Thu"; + return &wsResource; + } + case FWL_MCCAPACITY_Fri: { + wsResource = L"Fri"; + return &wsResource; + } + case FWL_MCCAPACITY_Sat: { + wsResource = L"Sat"; + return &wsResource; + } + case FWL_MCCAPACITY_January: { + wsResource = L"January"; + return &wsResource; + } + case FWL_MCCAPACITY_February: { + wsResource = L"February"; + return &wsResource; + } + case FWL_MCCAPACITY_March: { + wsResource = L"March"; + return &wsResource; + } + case FWL_MCCAPACITY_April: { + wsResource = L"April"; + return &wsResource; + } + case FWL_MCCAPACITY_May: { + wsResource = L"May"; + return &wsResource; + } + case FWL_MCCAPACITY_June: { + wsResource = L"June"; + return &wsResource; + } + case FWL_MCCAPACITY_July: { + wsResource = L"July"; + return &wsResource; + } + case FWL_MCCAPACITY_August: { + wsResource = L"August"; + return &wsResource; + } + case FWL_MCCAPACITY_September: { + wsResource = L"September"; + return &wsResource; + } + case FWL_MCCAPACITY_October: { + wsResource = L"October"; + return &wsResource; + } + case FWL_MCCAPACITY_November: { + wsResource = L"November"; + return &wsResource; + } + case FWL_MCCAPACITY_December: { + wsResource = L"December"; + return &wsResource; + } + case FWL_MCCAPACITY_Today: { + wsResource = L"Today"; + return &wsResource; + } + default: { bDefPro = TRUE; } + } + if (!bDefPro) { + if (bDwordVal) { + return &m_dwValue; + } + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +FWL_ERR CFWL_MonthCalendarTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_MonthCalendarTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtTotal(pParams->m_rtPart); + path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrBK(m_pThemeData->clrBK); + pParams->m_pGraphics->SetFillColor(&clrBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtHead = pParams->m_rtPart; + path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHeadBK(m_pThemeData->clrBK); + pParams->m_pGraphics->SetFillColor(&clrHeadBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtLBtn; + rtLBtn = pParams->m_rtPart; + path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); + pParams->m_pGraphics->SaveGraphState(); + 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) { + CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242)); + pParams->m_pGraphics->SetFillColor(&clrLBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249)); + pParams->m_pGraphics->SetFillColor(&clrLBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + path.Clear(); + path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.top + rtLBtn.height / 4); + path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2); + path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.bottom() - rtLBtn.height / 4); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); + pParams->m_pGraphics->SetStrokeColor(&clrFlag); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtRBtn; + rtRBtn = pParams->m_rtPart; + path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); + pParams->m_pGraphics->SaveGraphState(); + 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) { + CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242)); + pParams->m_pGraphics->SetFillColor(&clrRBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249)); + pParams->m_pGraphics->SetFillColor(&clrRBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + path.Clear(); + path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4); + path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, + rtRBtn.top + rtRBtn.height / 2); + path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, + rtRBtn.bottom() - rtRBtn.height / 4); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); + pParams->m_pGraphics->SetStrokeColor(&clrFlag); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtHSep; + rtHSep = pParams->m_rtPart; + path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); + path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); + pParams->m_pGraphics->SetStrokeColor(&clrHSep); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtWeekSep; + rtWeekSep = pParams->m_rtPart; + path.MoveTo(rtWeekSep.left, rtWeekSep.top); + path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); + pParams->m_pGraphics->SetStrokeColor(&clrHSep); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + pParams->m_pGraphics->SaveGraphState(); + if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + CFX_Color clrSelDayBK; + 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) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + CFX_Color clrSelDayBK; + clrSelDayBK = m_pThemeData->clrDatesHoverBK; + pParams->m_pGraphics->SetFillColor(&clrSelDayBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + pParams->m_pGraphics->RestoreGraphState(); + return FALSE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrSelDayBK; + clrSelDayBK = m_pThemeData->clrDatesCircle; + pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtTodayCircle; + rtTodayCircle = pParams->m_rtPart; + path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, + rtTodayCircle.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrTodayCircle; + clrTodayCircle = m_pThemeData->clrDatesCircle; + pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(FX_DWORD dwFWLStates) { + if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) { + return FWLTHEME_STATE_Hover; + } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) { + return FWLTHEME_STATE_Pressed; + } + return FWLTHEME_STATE_Normal; +} +void CFWL_MonthCalendarTP::SetThemeData(FX_DWORD dwThemeID) { + if (dwThemeID == 0) { + m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255); + m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239); + m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251); + m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239); + m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209); + m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); + m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); + } else { + m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0); + m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64); + m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191); + m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183); + m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0); + m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); + m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); + } +} diff --git a/xfa/src/fwl/theme/pictureboxtp.cpp b/xfa/fwl/theme/pictureboxtp.cpp index 5d7c079e86..5d7c079e86 100644 --- a/xfa/src/fwl/theme/pictureboxtp.cpp +++ b/xfa/fwl/theme/pictureboxtp.cpp diff --git a/xfa/src/fwl/theme/pushbuttontp.cpp b/xfa/fwl/theme/pushbuttontp.cpp index 76e0eab7dc..76e0eab7dc 100644 --- a/xfa/src/fwl/theme/pushbuttontp.cpp +++ b/xfa/fwl/theme/pushbuttontp.cpp diff --git a/xfa/src/fwl/theme/scrollbartp.cpp b/xfa/fwl/theme/scrollbartp.cpp index 424ff549e5..424ff549e5 100644 --- a/xfa/src/fwl/theme/scrollbartp.cpp +++ b/xfa/fwl/theme/scrollbartp.cpp diff --git a/xfa/fwl/theme/widgettp.cpp b/xfa/fwl/theme/widgettp.cpp new file mode 100644 index 0000000000..04b67b3310 --- /dev/null +++ b/xfa/fwl/theme/widgettp.cpp @@ -0,0 +1,840 @@ +// 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/include/fwl/theme/widgettp.h" + +#include <algorithm> + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/include/fwl/core/fwl_widgetmgr.h" + +static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { + IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); + IFWL_Widget* pChild = + pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); + while (pChild) { + IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); + if (pTheme) { + pTheme->SetThemeID(pChild, dwThemeID, FALSE); + } + FWL_SetChildThemeID(pChild, dwThemeID); + pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); + } +} +FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { + return FALSE; +} +FX_DWORD CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { + return m_dwThemeID; +} +FX_DWORD CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, + FX_DWORD dwThemeID, + FX_BOOL bChildren) { + FX_DWORD dwOld = m_dwThemeID; + m_dwThemeID = dwThemeID; + if (CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); + } + if (bChildren) { + FWL_SetChildThemeID(pWidget, dwThemeID); + } + return dwOld; +} +FWL_ERR 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; +} +FWL_ERR 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; +} +FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { + return TRUE; +} +FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) { + InitTTO(); + } + int32_t iLen = pParams->m_wsText.GetLength(); + if (iLen <= 0) + return FALSE; + CFX_Graphics* pGraphics = pParams->m_pGraphics; + m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + CFX_Matrix* pMatrix = &pParams->m_matrix; + pMatrix->Concat(*pGraphics->GetMatrix()); + m_pTextOut->SetMatrix(*pMatrix); + m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); + return TRUE; +} +void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, + FX_DWORD dwCapacity) { + switch (dwCapacity) { + case FWL_WGTCAPACITY_CXBorder: { + m_fValue = FWLTHEME_CAPACITY_CXBorder; + break; + } + case FWL_WGTCAPACITY_CYBorder: { + m_fValue = FWLTHEME_CAPACITY_CYBorder; + break; + } + case FWL_WGTCAPACITY_EdgeFlat: { + m_fValue = FWLTHEME_CAPACITY_EdgeFlat; + break; + } + case FWL_WGTCAPACITY_EdgeRaised: { + m_fValue = FWLTHEME_CAPACITY_EdgeRaised; + break; + } + case FWL_WGTCAPACITY_EdgeSunken: { + m_fValue = FWLTHEME_CAPACITY_EdgeSunken; + break; + } + case FWL_WGTCAPACITY_FontSize: { + m_fValue = FWLTHEME_CAPACITY_FontSize; + break; + } + case FWL_WGTCAPACITY_TextColor: { + m_dwValue = FWLTHEME_CAPACITY_TextColor; + return &m_dwValue; + } + case FWL_WGTCAPACITY_ScrollBarWidth: { + m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth; + break; + } + case FWL_WGTCAPACITY_Font: { + return m_pFDEFont; + } + case FWL_WGTCAPACITY_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; + break; + } + case FWL_WGTCAPACITY_UIMargin: { + m_rtMargin.Set(0, 0, 0, 0); + return &m_rtMargin; + } + default: { return NULL; } + } + return &m_fValue; +} +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; +} +FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy) { + return TRUE; +} +FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { + if (!pParams) + return FALSE; + if (!m_pTextOut) + 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); + return TRUE; +} +FWL_ERR CFWL_WidgetTP::Initialize() { + m_dwThemeID = 0; + _ctm.SetIdentity(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetTP::Finalize() { + if (!m_pTextOut) { + FinalizeTTO(); + } + return FWL_ERR_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; + } + 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; + } + m_pTextOut->SetFont(pFont); + m_pTextOut->SetFontSize(fFontSize); + m_pTextOut->SetTextColor(rgbFont); + return FWL_ERR_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_pFDEFont = + CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); + m_pTextOut = IFDE_TextOut::Create(); + 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; +} +FX_ERR CFWL_WidgetTP::FinalizeTTO() { + if (m_pTextOut) { + m_pTextOut->Release(); + m_pTextOut = NULL; + } + return FWL_ERR_Succeeded; +} +#ifdef THEME_XPSimilar +void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, + FX_DWORD dwStyles, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 + ? ArgbEncode(255, 127, 157, 185) + : FWLTHEME_COLOR_Green_BKSelected); + pGraphics->SetStrokeColor(&crStroke); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, + pRect->height - 1); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + crStroke = ArgbEncode(255, 255, 255, 255); + pGraphics->SetStrokeColor(&crStroke); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, + pRect->height - 3); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +#else +void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, + FX_DWORD 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, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + if (eType == FWLTHEME_EDGE_Flat) { + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + CFX_Color cr(ArgbEncode(255, 100, 100, 100)); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4, + pRect->height - 4); + cr.Set(0xFFFFFFFF); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + FX_FLOAT fLeft = pRect->left; + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fTop = pRect->top; + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fHalfWidth = fWidth / 2.0f; + CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); + pGraphics->SetFillColor(&crLT); + CFX_Path pathLT; + pathLT.Create(); + pathLT.MoveTo(fLeft, fBottom - fHalfWidth); + pathLT.LineTo(fLeft, fTop); + pathLT.LineTo(fRight - fHalfWidth, fTop); + pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); + pathLT.LineTo(fLeft, fBottom - fHalfWidth); + pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); + pGraphics->SetFillColor(&crLT); + pathLT.Clear(); + pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth); + pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth); + pathLT.LineTo(fRight - fWidth, fTop + fWidth); + pathLT.LineTo(fLeft + fWidth, fTop + fWidth); + pathLT.LineTo(fLeft + fWidth, fBottom - fWidth); + pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth); + pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); + pGraphics->SetFillColor(&crRB); + CFX_Path pathRB; + pathRB.Create(); + pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth); + pathRB.LineTo(fRight - fWidth, fBottom - fWidth); + pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); + pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); + crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); + pGraphics->SetFillColor(&crRB); + pathRB.Clear(); + pathRB.MoveTo(fRight, fTop); + pathRB.LineTo(fRight, fBottom); + pathRB.LineTo(fLeft, fBottom); + pathRB.LineTo(fLeft, fBottom - fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fTop); + pathRB.LineTo(fRight, fTop); + pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); + } + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics, + FWLTHEME_EDGE eType, + FX_FLOAT fWidth, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Path path; + path.Create(); + path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, + FWLTHEME_PI * 3 / 4, FWLTHEME_PI); + CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); + pGraphics->SetStrokeColor(&crFill1); + pGraphics->StrokePath(&path, pMatrix); + CFX_RectF rtInner(*pRect); + 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); + 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); + 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); + CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); + pGraphics->SetStrokeColor(&crFill4); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + pGraphics->SaveGraphState(); + CFX_Color crFill(ArgbEncode(255, 0, 0, 0)); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::FillBackground(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix); +} +void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color crFill(fillColor); + pGraphics->SetFillColor(&crFill); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, + FX_FLOAT fx1, + FX_FLOAT fy1, + FX_FLOAT fx2, + FX_FLOAT fy2, + FX_ARGB beginColor, + FX_ARGB endColor, + CFX_Path* path, + int32_t fillMode, + CFX_Matrix* pMatrix) { + if (!pGraphics || !path) + return; + + CFX_PointF begPoint(fx1, fy1); + CFX_PointF endPoint(fx2, fy2); + CFX_Shading shading; + shading.CreateAxial(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); + pGraphics->SaveGraphState(); + CFX_Color color1(&shading); + pGraphics->SetFillColor(&color1); + pGraphics->FillPath(path, fillMode, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fRingWidth, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color cr(fillColor); + pGraphics->SetFillColor(&cr); + CFX_Path path; + path.Create(); + CFX_RectF rtInner(*pRect); + rtInner.Deflate(fRingWidth, fRingWidth); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fWidth, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + if (fWidth > pRect->width / 2) { + return; + } + pGraphics->SaveGraphState(); + CFX_Color cr(fillColor); + pGraphics->SetFillColor(&cr); + CFX_Path path; + path.Create(); + path.AddEllipse(*pRect); + CFX_RectF rtIn(*pRect); + rtIn.Inflate(-fWidth, -fWidth); + path.AddEllipse(rtIn); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color cr(0xFF000000); + pGraphics->SetStrokeColor(&cr); + FX_FLOAT DashPattern[2] = {1, 1}; + pGraphics->SetLineDash(0.0f, DashPattern, 2); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +#define FWLTHEME_ARROW_Denominator 3 +void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argbFill, + FX_BOOL bPressed, + CFX_Matrix* pMatrix) { + CFX_RectF rtArrow(*pRect); + CFX_Path path; + path.Create(); + FX_FLOAT fBtn = + std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; + rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; + rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; + rtArrow.width = fBtn; + rtArrow.height = fBtn; + if (bPressed) { + rtArrow.Offset(1, 1); + } + switch (eDict) { + case FWLTHEME_DIRECTION_Up: { + path.MoveTo(rtArrow.left, rtArrow.bottom()); + path.LineTo(rtArrow.right(), rtArrow.bottom()); + path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top); + path.LineTo(rtArrow.left, rtArrow.bottom()); + break; + } + case FWLTHEME_DIRECTION_Left: { + path.MoveTo(rtArrow.right(), rtArrow.top); + path.LineTo(rtArrow.right(), rtArrow.bottom()); + path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2); + path.LineTo(rtArrow.right(), rtArrow.top); + break; + } + case FWLTHEME_DIRECTION_Right: { + path.MoveTo(rtArrow.left, rtArrow.top); + path.LineTo(rtArrow.left, rtArrow.bottom()); + path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2); + path.LineTo(rtArrow.left, rtArrow.top); + break; + } + case FWLTHEME_DIRECTION_Down: + default: { + path.MoveTo(rtArrow.left, rtArrow.top); + path.LineTo(rtArrow.right(), rtArrow.top); + path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom()); + path.LineTo(rtArrow.left, rtArrow.top); + } + } + pGraphics->SaveGraphState(); + CFX_Color cr(argbFill); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argSign, + CFX_Matrix* pMatrix) { + FX_BOOL bVert = + (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); + FX_FLOAT fLeft = + (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); + FX_FLOAT fTop = + (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); + CFX_Path path; + path.Create(); + switch (eDict) { + case FWLTHEME_DIRECTION_Down: { + path.MoveTo(fLeft, fTop + 1); + path.LineTo(fLeft + 4, fTop + 5); + path.LineTo(fLeft + 8, fTop + 1); + path.LineTo(fLeft + 7, fTop); + path.LineTo(fLeft + 4, fTop + 3); + path.LineTo(fLeft + 1, fTop); + break; + } + case FWLTHEME_DIRECTION_Up: { + path.MoveTo(fLeft, fTop + 4); + path.LineTo(fLeft + 4, fTop); + path.LineTo(fLeft + 8, fTop + 4); + path.LineTo(fLeft + 7, fTop + 5); + path.LineTo(fLeft + 4, fTop + 2); + path.LineTo(fLeft + 1, fTop + 5); + break; + } + case FWLTHEME_DIRECTION_Right: { + path.MoveTo(fLeft + 1, fTop); + path.LineTo(fLeft + 5, fTop + 4); + path.LineTo(fLeft + 1, fTop + 8); + path.LineTo(fLeft, fTop + 7); + path.LineTo(fLeft + 3, fTop + 4); + path.LineTo(fLeft, fTop + 1); + break; + } + case FWLTHEME_DIRECTION_Left: { + path.MoveTo(fLeft, fTop + 4); + path.LineTo(fLeft + 4, fTop); + path.LineTo(fLeft + 5, fTop + 1); + path.LineTo(fLeft + 2, fTop + 4); + path.LineTo(fLeft + 5, fTop + 7); + path.LineTo(fLeft + 4, fTop + 8); + break; + } + } + CFX_Color cr(argSign); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); +} +void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + if (!CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); + } + CFWL_ArrowData::CColorData* pColorData = + CFWL_ArrowData::GetInstance()->m_pColorData; + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, + pColorData->clrStart[eState - 1], + pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, + pMatrix); + CFX_Color rcStroke; + rcStroke.Set(pColorData->clrBorder[eState - 1]); + pGraphics->SetStrokeColor(&rcStroke); + pGraphics->StrokePath(&path, pMatrix); +} +void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + DrawBtn(pGraphics, pRect, eState, pMatrix); + if (!CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); + } + CFWL_ArrowData::CColorData* pColorData = + 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)( + ((FX_WORD)srcColor.a * n + (FX_WORD)renderColor.a * scale) >> 8); + dstColor.r = (uint8_t)( + ((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8); + dstColor.g = (uint8_t)( + ((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8); + dstColor.b = (uint8_t)( + ((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8); + return dstColor; +} +CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) { + SetColorData(0); +} +CFWL_FontData::CFWL_FontData() + : m_dwStyles(0), + m_dwCodePage(0), + m_pFont(0), + m_pFontMgr(NULL) +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + , + m_pFontSource(NULL) +#endif +{ +} +CFWL_FontData::~CFWL_FontData() { + if (m_pFont) { + m_pFont->Release(); + } + if (m_pFontMgr) { + m_pFontMgr->Release(); + } +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (m_pFontSource != NULL) { + m_pFontSource->Release(); + } +#endif +} +FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && + m_dwCodePage == wCodePage; +} +FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD dwCodePage) { + m_wsFamily = wsFontFamily; + m_dwStyles = dwFontStyles; + m_dwCodePage = dwCodePage; + if (!m_pFontMgr) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); +#else + m_pFontSource = FX_CreateDefaultFontSourceEnum(); + m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); +#endif + } + m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, + m_pFontMgr); + return m_pFont != NULL; +} + +CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr; +CFWL_FontManager* CFWL_FontManager::GetInstance() { + if (!s_FontManager) + s_FontManager = new CFWL_FontManager; + return s_FontManager; +} +void CFWL_FontManager::DestroyInstance() { + delete s_FontManager; + s_FontManager = nullptr; +} +CFWL_FontManager::CFWL_FontManager() {} +CFWL_FontManager::~CFWL_FontManager() {} +IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + for (const auto& pData : m_FontsArray) { + if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) + return pData->GetFont(); + } + std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData); + if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) + return nullptr; + m_FontsArray.push_back(std::move(pFontData)); + return m_FontsArray.back()->GetFont(); +} +FX_BOOL FWLTHEME_Init() { + return TRUE; +} +void FWLTHEME_Release() { + CFWL_ArrowData::DestroyInstance(); + CFWL_FontManager::DestroyInstance(); +} +FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) { + return 0xffff0000 & dwThemeID; +} +FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) { + return 0x0000ffff & dwThemeID; +} +FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) { + return (dwLayout << 16) | (0x0000FFFF & dwColor); +} +CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; +CFWL_ArrowData* CFWL_ArrowData::GetInstance() { + if (!m_pInstance) { + m_pInstance = new CFWL_ArrowData; + } + return m_pInstance; +} +FX_BOOL CFWL_ArrowData::IsInstance() { + return (m_pInstance != NULL); +} +void CFWL_ArrowData::DestroyInstance() { + if (m_pInstance) { + delete m_pInstance; + m_pInstance = NULL; + } +} +CFWL_ArrowData::~CFWL_ArrowData() { + if (m_pColorData) { + delete m_pColorData; + m_pColorData = NULL; + } +} +void CFWL_ArrowData::SetColorData(FX_DWORD dwID) { + if (!m_pColorData) { + m_pColorData = new CColorData; + } + if (dwID) { + m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); + m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); + m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); + m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); + m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); + m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); + m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186); + m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); + m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117); + m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155); + m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117); + m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); + m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); + } else { + m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249); + m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233); + m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219); + m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); + m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254); + m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255); + m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241); + m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); + m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); + m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); + m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); + m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); + m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); + } +} diff --git a/xfa/fxbarcode/BC_BarCode.cpp b/xfa/fxbarcode/BC_BarCode.cpp new file mode 100644 index 0000000000..11f47b5578 --- /dev/null +++ b/xfa/fxbarcode/BC_BarCode.cpp @@ -0,0 +1,877 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h" +#include "xfa/fxbarcode/BC_DecoderResult.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAReader.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Detector.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Reader.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Writer.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h" + +CBC_CodeBase::CBC_CodeBase() {} +CBC_CodeBase::~CBC_CodeBase() {} +FX_BOOL CBC_CodeBase::SetCharEncoding(int32_t encoding) { + if (m_pBCWriter) { + return m_pBCWriter->SetCharEncoding(encoding); + } + return FALSE; +} +FX_BOOL CBC_CodeBase::SetModuleHeight(int32_t moduleHeight) { + if (m_pBCWriter) { + return m_pBCWriter->SetModuleHeight(moduleHeight); + } + return FALSE; +} +FX_BOOL CBC_CodeBase::SetModuleWidth(int32_t moduleWidth) { + if (m_pBCWriter) { + return m_pBCWriter->SetModuleWidth(moduleWidth); + } + return FALSE; +} +FX_BOOL CBC_CodeBase::SetHeight(int32_t height) { + if (m_pBCWriter) { + return m_pBCWriter->SetHeight(height); + } + return FALSE; +} +FX_BOOL CBC_CodeBase::SetWidth(int32_t width) { + if (m_pBCWriter) { + return m_pBCWriter->SetWidth(width); + } + return FALSE; +} +void CBC_CodeBase::SetBackgroundColor(FX_ARGB backgroundColor) { + if (m_pBCWriter) { + m_pBCWriter->SetBackgroundColor(backgroundColor); + } +} +void CBC_CodeBase::SetBarcodeColor(FX_ARGB foregroundColor) { + if (m_pBCWriter) { + m_pBCWriter->SetBarcodeColor(foregroundColor); + } +} +CBC_OneCode::CBC_OneCode() {} +CBC_OneCode::~CBC_OneCode() {} +FX_BOOL CBC_OneCode::CheckContentValidity(const CFX_WideStringC& contents) { + if (m_pBCWriter) { + return ((CBC_OneDimWriter*)m_pBCWriter)->CheckContentValidity(contents); + } + return FALSE; +} +CFX_WideString CBC_OneCode::FilterContents(const CFX_WideStringC& contents) { + CFX_WideString tmp; + if (m_pBCWriter == NULL) { + return tmp; + } + return ((CBC_OneDimWriter*)m_pBCWriter)->FilterContents(contents); +} +void CBC_OneCode::SetPrintChecksum(FX_BOOL checksum) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetPrintChecksum(checksum); + } +} +void CBC_OneCode::SetDataLength(int32_t length) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetDataLength(length); + } +} +void CBC_OneCode::SetCalChecksum(FX_BOOL calc) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetCalcChecksum(calc); + } +} +FX_BOOL CBC_OneCode::SetFont(CFX_Font* cFont) { + if (m_pBCWriter) { + return ((CBC_OneDimWriter*)m_pBCWriter)->SetFont(cFont); + } + return FALSE; +} +void CBC_OneCode::SetFontSize(FX_FLOAT size) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetFontSize(size); + } +} +void CBC_OneCode::SetFontStyle(int32_t style) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetFontStyle(style); + } +} +void CBC_OneCode::SetFontColor(FX_ARGB color) { + if (m_pBCWriter) { + ((CBC_OneDimWriter*)m_pBCWriter)->SetFontColor(color); + } +} +CBC_Code39::CBC_Code39() { + m_pBCReader = (CBC_Reader*)new (CBC_OnedCode39Reader); + m_pBCWriter = (CBC_Writer*)new (CBC_OnedCode39Writer); +} +CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit) { + m_pBCReader = (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit); + m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer; +} +CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode) { + m_pBCReader = + (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit, extendedMode); + m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer(extendedMode); +} +CBC_Code39::~CBC_Code39() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_Code39::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_CODE_39; + int32_t outWidth = 0; + int32_t outHeight = 0; + CFX_WideString filtercontents = + ((CBC_OnedCode39Writer*)m_pBCWriter)->FilterContents(contents); + CFX_WideString renderContents = + ((CBC_OnedCode39Writer*)m_pBCWriter)->RenderTextContents(contents); + m_renderContents = renderContents; + CFX_ByteString byteString = filtercontents.UTF8Encode(); + uint8_t* data = static_cast<CBC_OnedCode39Writer*>(m_pBCWriter) + ->Encode(byteString, format, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderResult(renderContents, 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, + int32_t& e) { + CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter) + ->encodedContents(m_renderContents, e); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, renderCon, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +FX_BOOL CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter) + ->encodedContents(m_renderContents, e); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderBitmapResult(pOutBitmap, renderCon, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_Code39::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +FX_BOOL CBC_Code39::SetTextLocation(BC_TEXT_LOC location) { + if (m_pBCWriter) { + return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetTextLocation(location); + } + return FALSE; +} +FX_BOOL CBC_Code39::SetWideNarrowRatio(int32_t ratio) { + if (m_pBCWriter) { + return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetWideNarrowRatio(ratio); + } + return FALSE; +} +CBC_Codabar::CBC_Codabar() { + m_pBCReader = (CBC_Reader*)new (CBC_OnedCodaBarReader); + m_pBCWriter = (CBC_Writer*)new (CBC_OnedCodaBarWriter); +} +CBC_Codabar::~CBC_Codabar() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_Codabar::SetStartChar(FX_CHAR start) { + if (m_pBCWriter) { + return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetStartChar(start); + } + return FALSE; +} +FX_BOOL CBC_Codabar::SetEndChar(FX_CHAR end) { + if (m_pBCWriter) { + return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetEndChar(end); + } + return FALSE; +} +FX_BOOL CBC_Codabar::SetTextLocation(BC_TEXT_LOC location) { + return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetTextLocation(location); +} +FX_BOOL CBC_Codabar::SetWideNarrowRatio(int32_t ratio) { + if (m_pBCWriter) { + return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetWideNarrowRatio(ratio); + } + return FALSE; +} +FX_BOOL CBC_Codabar::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_CODABAR; + int32_t outWidth = 0; + int32_t outHeight = 0; + CFX_WideString filtercontents = + ((CBC_OneDimWriter*)m_pBCWriter)->FilterContents(contents); + CFX_ByteString byteString = filtercontents.UTF8Encode(); + m_renderContents = filtercontents; + uint8_t* data = static_cast<CBC_OnedCodaBarWriter*>(m_pBCWriter) + ->Encode(byteString, format, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderResult(filtercontents, 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, + int32_t& e) { + CFX_WideString renderCon = + ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedContents(m_renderContents); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, renderCon, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +FX_BOOL CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + CFX_WideString renderCon = + ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedContents(m_renderContents); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderBitmapResult(pOutBitmap, renderCon, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_Codabar::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_Code128::CBC_Code128(BC_TYPE type) { + m_pBCReader = (CBC_Reader*)new (CBC_OnedCode128Reader); + m_pBCWriter = (CBC_Writer*)new CBC_OnedCode128Writer(type); +} +CBC_Code128::~CBC_Code128() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_Code128::SetTextLocation(BC_TEXT_LOC location) { + if (m_pBCWriter) { + return ((CBC_OnedCode128Writer*)m_pBCWriter)->SetTextLocation(location); + } + return FALSE; +} +FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_CODE_128; + int32_t outWidth = 0; + int32_t outHeight = 0; + 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); + 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, 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, + int32_t& e) { + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_Code128::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_EAN8::CBC_EAN8() { + m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN8Reader); + m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN8Writer); +} +CBC_EAN8::~CBC_EAN8() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) { + CFX_WideString encodeContents = + ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); + int32_t length = encodeContents.GetLength(); + if (length <= 7) { + for (int32_t i = 0; i < 7 - length; i++) { + encodeContents = FX_WCHAR('0') + encodeContents; + } + CFX_ByteString byteString = encodeContents.UTF8Encode(); + int32_t checksum = + ((CBC_OnedEAN8Writer*)m_pBCWriter)->CalcChecksum(byteString); + encodeContents += FX_WCHAR(checksum - 0 + '0'); + } + if (length > 8) { + encodeContents = encodeContents.Mid(0, 8); + } + return encodeContents; +} +FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_EAN_8; + int32_t outWidth = 0; + int32_t outHeight = 0; + CFX_WideString encodeContents = Preprocess(contents); + CFX_ByteString byteString = encodeContents.UTF8Encode(); + m_renderContents = encodeContents; + uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter) + ->Encode(byteString, format, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderResult(encodeContents, 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, + int32_t& e) { + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_EAN8::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_EAN13::CBC_EAN13() { + m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN13Reader); + m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN13Writer); +} +CBC_EAN13::~CBC_EAN13() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +CFX_WideString CBC_EAN13::Preprocess(const CFX_WideStringC& contents) { + CFX_WideString encodeContents = + ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); + int32_t length = encodeContents.GetLength(); + if (length <= 12) { + for (int32_t i = 0; i < 12 - length; i++) { + encodeContents = FX_WCHAR('0') + encodeContents; + } + CFX_ByteString byteString = encodeContents.UTF8Encode(); + int32_t checksum = + ((CBC_OnedEAN13Writer*)m_pBCWriter)->CalcChecksum(byteString); + byteString += checksum - 0 + '0'; + encodeContents = byteString.UTF8Decode(); + } + if (length > 13) { + encodeContents = encodeContents.Mid(0, 13); + } + return encodeContents; +} +FX_BOOL CBC_EAN13::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_EAN_13; + int32_t outWidth = 0; + int32_t outHeight = 0; + CFX_WideString encodeContents = Preprocess(contents); + CFX_ByteString byteString = encodeContents.UTF8Encode(); + m_renderContents = encodeContents; + uint8_t* data = static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter) + ->Encode(byteString, format, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderResult(encodeContents, 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, + int32_t& e) { + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_EAN13::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_UPCA::CBC_UPCA() { + m_pBCReader = (CBC_Reader*)new (CBC_OnedUPCAReader); + ((CBC_OnedUPCAReader*)m_pBCReader)->Init(); + m_pBCWriter = (CBC_Writer*)new (CBC_OnedUPCAWriter); +} +CBC_UPCA::~CBC_UPCA() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +CFX_WideString CBC_UPCA::Preprocess(const CFX_WideStringC& contents) { + CFX_WideString encodeContents = + ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); + int32_t length = encodeContents.GetLength(); + if (length <= 11) { + for (int32_t i = 0; i < 11 - length; i++) { + encodeContents = FX_WCHAR('0') + encodeContents; + } + CFX_ByteString byteString = encodeContents.UTF8Encode(); + int32_t checksum = + ((CBC_OnedUPCAWriter*)m_pBCWriter)->CalcChecksum(byteString); + byteString += checksum - 0 + '0'; + encodeContents = byteString.UTF8Decode(); + } + if (length > 12) { + encodeContents = encodeContents.Mid(0, 12); + } + return encodeContents; +} +FX_BOOL CBC_UPCA::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + if (contents.IsEmpty()) { + e = BCExceptionNoContents; + return FALSE; + } + BCFORMAT format = BCFORMAT_UPC_A; + int32_t outWidth = 0; + int32_t outHeight = 0; + CFX_WideString encodeContents = Preprocess(contents); + CFX_ByteString byteString = encodeContents.UTF8Encode(); + m_renderContents = encodeContents; + ((CBC_OnedUPCAWriter*)m_pBCWriter)->Init(); + uint8_t* data = static_cast<CBC_OnedUPCAWriter*>(m_pBCWriter) + ->Encode(byteString, format, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderResult(encodeContents, 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, + int32_t& e) { + ((CBC_OneDimWriter*)m_pBCWriter) + ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_UPCA::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_QRCode::CBC_QRCode() { + m_pBCReader = (CBC_Reader*)new (CBC_QRCodeReader); + ((CBC_QRCodeReader*)m_pBCReader)->Init(); + m_pBCWriter = (CBC_Writer*)new (CBC_QRCodeWriter); +} +CBC_QRCode::~CBC_QRCode() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_QRCode::SetVersion(int32_t version) { + if (version < 0 || version > 40) { + return FALSE; + } + if (m_pBCWriter == NULL) { + return FALSE; + } + return ((CBC_QRCodeWriter*)m_pBCWriter)->SetVersion(version); +} +FX_BOOL CBC_QRCode::SetErrorCorrectionLevel(int32_t level) { + if (level < 0 || level > 3) { + return FALSE; + } + if (m_pBCWriter == NULL) { + return FALSE; + } + return ((CBC_TwoDimWriter*)m_pBCWriter)->SetErrorCorrectionLevel(level); +} +FX_BOOL CBC_QRCode::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + 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); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); + FX_Free(data); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +FX_BOOL CBC_QRCode::RenderDevice(CFX_RenderDevice* device, + const CFX_Matrix* matirx, + int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); + return TRUE; +} +FX_BOOL CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +CFX_WideString CBC_QRCode::Decode(uint8_t* buf, + int32_t width, + int32_t hight, + int32_t& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_QRCode::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_PDF417I::CBC_PDF417I() { + m_pBCReader = (CBC_Reader*)new (CBC_PDF417Reader); + m_pBCWriter = (CBC_Writer*)new (CBC_PDF417Writer); +} +CBC_PDF417I::~CBC_PDF417I() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_PDF417I::SetErrorCorrectionLevel(int32_t level) { + ((CBC_PDF417Writer*)m_pBCWriter)->SetErrorCorrectionLevel(level); + return TRUE; +} +void CBC_PDF417I::SetTruncated(FX_BOOL truncated) { + ((CBC_PDF417Writer*)m_pBCWriter)->SetTruncated(truncated); +} +FX_BOOL CBC_PDF417I::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + int32_t outWidth = 0; + int32_t outHeight = 0; + uint8_t* data = ((CBC_PDF417Writer*)m_pBCWriter) + ->Encode(contents, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); + FX_Free(data); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +FX_BOOL CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, + const CFX_Matrix* matirx, + int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); + return TRUE; +} +FX_BOOL CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +CFX_WideString CBC_PDF417I::Decode(uint8_t* buf, + int32_t width, + int32_t hight, + int32_t& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_PDF417I::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} +CBC_DataMatrix::CBC_DataMatrix() { + m_pBCReader = (CBC_Reader*)new (CBC_DataMatrixReader); + ((CBC_DataMatrixReader*)m_pBCReader)->Init(); + m_pBCWriter = (CBC_Writer*)new (CBC_DataMatrixWriter); +} +CBC_DataMatrix::~CBC_DataMatrix() { + if (m_pBCReader) { + delete (m_pBCReader); + m_pBCReader = NULL; + } + if (m_pBCWriter) { + delete (m_pBCWriter); + m_pBCWriter = NULL; + } +} +FX_BOOL CBC_DataMatrix::Encode(const CFX_WideStringC& contents, + FX_BOOL isDevice, + int32_t& e) { + int32_t outWidth = 0; + int32_t outHeight = 0; + uint8_t* data = ((CBC_DataMatrixWriter*)m_pBCWriter) + ->Encode(contents, outWidth, outHeight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); + FX_Free(data); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, + const CFX_Matrix* matirx, + int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); + return TRUE; +} +FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { + ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return TRUE; +} +CFX_WideString CBC_DataMatrix::Decode(uint8_t* buf, + int32_t width, + int32_t hight, + int32_t& e) { + CFX_WideString str; + return str; +} +CFX_WideString CBC_DataMatrix::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + 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()); +} diff --git a/xfa/fxbarcode/BC_Binarizer.cpp b/xfa/fxbarcode/BC_Binarizer.cpp new file mode 100644 index 0000000000..d36d8fc59c --- /dev/null +++ b/xfa/fxbarcode/BC_Binarizer.cpp @@ -0,0 +1,34 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" + +CBC_Binarizer::CBC_Binarizer(CBC_LuminanceSource* source) { + m_source = source; +} +CBC_Binarizer::~CBC_Binarizer() {} +CBC_LuminanceSource* CBC_Binarizer::GetLuminanceSource() { + return m_source; +} diff --git a/xfa/fxbarcode/BC_Binarizer.h b/xfa/fxbarcode/BC_Binarizer.h new file mode 100644 index 0000000000..20be039211 --- /dev/null +++ b/xfa/fxbarcode/BC_Binarizer.h @@ -0,0 +1,30 @@ +// 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_FXBARCODE_BC_BINARIZER_H_ +#define XFA_FXBARCODE_BC_BINARIZER_H_ + +#include <cstdint> + +class CBC_LuminanceSource; +class CBC_CommonBitMatrix; +class CBC_CommonBitArray; + +class CBC_Binarizer { + public: + CBC_Binarizer(CBC_LuminanceSource* source); + virtual ~CBC_Binarizer(); + CBC_LuminanceSource* GetLuminanceSource(); + virtual CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e) = 0; + virtual CBC_CommonBitArray* GetBlackRow(int32_t y, + CBC_CommonBitArray* row, + int32_t& e) = 0; + + private: + CBC_LuminanceSource* m_source; +}; + +#endif // XFA_FXBARCODE_BC_BINARIZER_H_ diff --git a/xfa/fxbarcode/BC_BinaryBitmap.cpp b/xfa/fxbarcode/BC_BinaryBitmap.cpp new file mode 100644 index 0000000000..ba08824efe --- /dev/null +++ b/xfa/fxbarcode/BC_BinaryBitmap.cpp @@ -0,0 +1,61 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/utils.h" + +CBC_BinaryBitmap::CBC_BinaryBitmap(CBC_Binarizer* binarizer) + : m_binarizer(binarizer), m_matrix(NULL) {} +CBC_BinaryBitmap::~CBC_BinaryBitmap() { + delete m_matrix; +} +int32_t CBC_BinaryBitmap::GetHeight() { + return m_binarizer->GetLuminanceSource()->GetHeight(); +} +int32_t CBC_BinaryBitmap::GetWidth() { + return m_binarizer->GetLuminanceSource()->GetWidth(); +} +CBC_CommonBitMatrix* CBC_BinaryBitmap::GetMatrix(int32_t& e) { + if (m_matrix == NULL) { + m_matrix = m_binarizer->GetBlackMatrix(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return m_matrix; +} +CBC_CommonBitArray* CBC_BinaryBitmap::GetBlackRow(int32_t y, + CBC_CommonBitArray* row, + int32_t& e) { + CBC_CommonBitArray* temp = m_binarizer->GetBlackRow(y, row, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CBC_CommonBitMatrix* CBC_BinaryBitmap::GetBlackMatrix(int32_t& e) { + if (m_matrix == NULL) { + m_matrix = m_binarizer->GetBlackMatrix(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return m_matrix; +} diff --git a/xfa/fxbarcode/BC_BinaryBitmap.h b/xfa/fxbarcode/BC_BinaryBitmap.h new file mode 100644 index 0000000000..5f4dd874a9 --- /dev/null +++ b/xfa/fxbarcode/BC_BinaryBitmap.h @@ -0,0 +1,33 @@ +// 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_FXBARCODE_BC_BINARYBITMAP_H_ +#define XFA_FXBARCODE_BC_BINARYBITMAP_H_ + +#include <cstdint> + +class CBC_Binarizer; +class CBC_CommonBitMatrix; +class CBC_CommonBitArray; + +class CBC_BinaryBitmap { + public: + CBC_BinaryBitmap(CBC_Binarizer* binarizer); + virtual ~CBC_BinaryBitmap(); + int32_t GetWidth(); + int32_t GetHeight(); + CBC_CommonBitMatrix* GetMatrix(int32_t& e); + CBC_CommonBitArray* GetBlackRow(int32_t y, + CBC_CommonBitArray* row, + int32_t& e); + CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e); + + private: + CBC_Binarizer* m_binarizer; + CBC_CommonBitMatrix* m_matrix; +}; + +#endif // XFA_FXBARCODE_BC_BINARYBITMAP_H_ diff --git a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp new file mode 100644 index 0000000000..86b19c15af --- /dev/null +++ b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp @@ -0,0 +1,171 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcodec/fx_codec.h" +#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/utils.h" + +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(); + 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; + 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) { + status = pImageCodec->GetFrames(frames, &pause); + } + if (status != FXCODEC_STATUS_DECODE_READY) { + goto except; + } + status = pImageCodec->StartDecode(bitmap, 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) { + 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; +} +CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource( + const CFX_WideString& filename) + : CBC_LuminanceSource(0, 0), m_filename(filename) { + m_height = 0; + m_width = 0; + m_bytesPerLine = 0; + m_top = 0; + m_left = 0; +} +void CBC_BufferedImageLuminanceSource::Init(int32_t& e) { + IFX_FileRead* fileread = FX_CreateFileRead(m_filename); + m_pBitmap = CreateDIBSource(fileread); + if (m_pBitmap == NULL) { + e = BCExceptionLoadFile; + return; + } + m_pBitmap->ConvertFormat(FXDIB_Argb); + m_height = m_pBitmap->GetHeight(); + m_width = m_pBitmap->GetWidth(); + m_rgbData.SetSize(m_height * m_width); + m_bytesPerLine = m_width * 4; + m_top = 0; + m_left = 0; +} +CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource( + CFX_DIBitmap* pBitmap) + : CBC_LuminanceSource(0, 0) { + m_pBitmap = pBitmap->Clone(); + m_pBitmap->ConvertFormat(FXDIB_Argb); + m_height = m_pBitmap->GetHeight(); + m_width = m_pBitmap->GetWidth(); + m_rgbData.SetSize(m_height * m_width); + m_bytesPerLine = m_width * 4; + 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; + } + int32_t width = m_width; + if (row.GetSize() == 0 || row.GetSize() < width) { + row.SetSize(width); + } + if (m_rgbData.GetSize() == 0 || m_rgbData.GetSize() < width) { + m_rgbData.SetSize(width); + } + int32_t* rowLine = (int32_t*)m_pBitmap->GetScanline(y); + int32_t x; + for (x = 0; x < width; x++) { + int32_t pixel = rowLine[x]; + int32_t luminance = (306 * ((pixel >> 16) & 0xFF) + + 601 * ((pixel >> 8) & 0xFF) + 117 * (pixel & 0xFF)) >> + 10; + row[x] = (uint8_t)luminance; + } + return &row; +} +CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetMatrix() { + CFX_ByteArray* matirx = new CFX_ByteArray(); + matirx->SetSize(m_bytesPerLine * m_height); + int32_t* rgb = (int32_t*)m_pBitmap->GetBuffer(); + int32_t y; + for (y = 0; y < m_height; y++) { + int32_t offset = y * m_width; + int32_t x; + for (x = 0; x < m_width; x++) { + int32_t pixel = rgb[offset + x]; + int32_t luminance = + (306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) + + 117 * (pixel & 0xFF)) >> + 10; + (*matirx)[offset + x] = (uint8_t)luminance; + } + } + return matirx; +} diff --git a/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h new file mode 100644 index 0000000000..e39f4d638c --- /dev/null +++ b/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ +#define XFA_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxge/fx_dib.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" + +class CBC_BufferedImageLuminanceSource : public CBC_LuminanceSource { + public: + explicit CBC_BufferedImageLuminanceSource(const CFX_WideString& filename); + explicit CBC_BufferedImageLuminanceSource(CFX_DIBitmap* pBitmap); + virtual ~CBC_BufferedImageLuminanceSource(); + + CFX_ByteArray* GetRow(int32_t y, CFX_ByteArray& row, int32_t& e); + CFX_ByteArray* GetMatrix(); + virtual void Init(int32_t& e); + + private: + int32_t m_bytesPerLine; + int32_t m_left; + int32_t m_top; + CFX_Int32Array m_rgbData; + CFX_DIBitmap* m_pBitmap; + const CFX_WideString m_filename; +}; + +#endif // XFA_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ diff --git a/xfa/fxbarcode/BC_DecoderResult.h b/xfa/fxbarcode/BC_DecoderResult.h new file mode 100644 index 0000000000..c3008c52bf --- /dev/null +++ b/xfa/fxbarcode/BC_DecoderResult.h @@ -0,0 +1,37 @@ +// 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_FXBARCODE_BC_DECODERRESULT_H_ +#define XFA_FXBARCODE_BC_DECODERRESULT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_DecoderResult { + public: + CBC_DecoderResult(CFX_ByteArray* rawBytes, + CFX_ByteString text, + CFX_ByteString ecLevel); + virtual ~CBC_DecoderResult(); + CFX_ByteArray* getRawBytes(); + CFX_ByteString getText(); + CFX_ByteString getECLevel(); + int32_t getErrorsCorrected(); + void setErrorsCorrected(int32_t errorsCorrected); + int32_t getErasures(); + void setErasures(int32_t erasures); + void* getOther(); + void setOther(void* other); + + private: + CFX_ByteArray* m_rawBytes; + CFX_ByteString m_text; + CFX_ByteString m_ecLevel; + int32_t m_errorsCorrected; + int32_t m_erasures; + void* m_other; +}; + +#endif // XFA_FXBARCODE_BC_DECODERRESULT_H_ diff --git a/xfa/fxbarcode/BC_Dimension.cpp b/xfa/fxbarcode/BC_Dimension.cpp new file mode 100644 index 0000000000..0cb076ce22 --- /dev/null +++ b/xfa/fxbarcode/BC_Dimension.cpp @@ -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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +CBC_Dimension::CBC_Dimension() {} +CBC_Dimension::CBC_Dimension(int32_t width, int32_t height, int32_t& e) { + if (width < 0 || height < 0) { + e = BCExceptionHeightAndWidthMustBeAtLeast1; + } + m_width = width; + m_height = height; +} +CBC_Dimension::~CBC_Dimension() {} +int32_t CBC_Dimension::getWidth() { + return m_width; +} +int32_t CBC_Dimension::getHeight() { + return m_height; +} +int32_t CBC_Dimension::hashCode() { + return m_width * 32713 + m_height; +} +CFX_WideString CBC_Dimension::toString() { + return (FX_WCHAR)(m_width + (FX_WCHAR)'x' + m_height); +} diff --git a/xfa/fxbarcode/BC_Dimension.h b/xfa/fxbarcode/BC_Dimension.h new file mode 100644 index 0000000000..e3253b38ad --- /dev/null +++ b/xfa/fxbarcode/BC_Dimension.h @@ -0,0 +1,29 @@ +// 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_FXBARCODE_BC_DIMENSION_H_ +#define XFA_FXBARCODE_BC_DIMENSION_H_ + +#include <cstdint> + +#include "core/include/fxcrt/fx_string.h" + +class CBC_Dimension { + public: + CBC_Dimension(); + CBC_Dimension(int32_t width, int32_t height, int32_t& e); + virtual ~CBC_Dimension(); + int32_t getWidth(); + int32_t getHeight(); + int32_t hashCode(); + CFX_WideString toString(); + + private: + int32_t m_width; + int32_t m_height; +}; + +#endif // XFA_FXBARCODE_BC_DIMENSION_H_ diff --git a/xfa/fxbarcode/BC_Library.cpp b/xfa/fxbarcode/BC_Library.cpp new file mode 100644 index 0000000000..d6da15cd29 --- /dev/null +++ b/xfa/fxbarcode/BC_Library.cpp @@ -0,0 +1,121 @@ +// 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/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h" +#include "xfa/fxbarcode/BC_DecoderResult.h" +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h" +#include "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h" +#include "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" +#include "xfa/fxbarcode/datamatrix/BC_TextEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_X12Encoder.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAReader.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Detector.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Reader.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h" +#include "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" + +void BC_Library_Init() { + CBC_QRCoderErrorCorrectionLevel::Initialize(); + CBC_QRCoderMode::Initialize(); + CBC_QRCoderVersion::Initialize(); + CBC_QRDataMask::Initialize(); + CBC_ReedSolomonGF256::Initialize(); + CBC_DataMatrixVersion::Initialize(); + CBC_SymbolInfo::Initialize(); + CBC_ErrorCorrection::Initialize(); + CBC_PDF417HighLevelEncoder::Initialize(); + int32_t e = 0; + CBC_PDF417ECModulusGF::Initialize(e); + CBC_DecodedBitStreamPaser::Initialize(); + CBC_PDF417CodewordDecoder::Initialize(); + CBC_PDF417ECErrorCorrection::Initialize(e); + CBC_PDF417ScanningDecoder::Initialize(); +} +void BC_Library_Destory() { + CBC_QRCoderErrorCorrectionLevel::Finalize(); + CBC_QRCoderMode::Finalize(); + CBC_QRCoderVersion::Finalize(); + CBC_QRDataMask::Finalize(); + CBC_ReedSolomonGF256::Finalize(); + CBC_DataMatrixVersion::Finalize(); + CBC_SymbolInfo::Finalize(); + CBC_ErrorCorrection::Finalize(); + CBC_PDF417HighLevelEncoder::Finalize(); + CBC_DecodedBitStreamPaser::Finalize(); + CBC_PDF417CodewordDecoder::Finalize(); + CBC_PDF417ECErrorCorrection::Finalize(); + CBC_PDF417ECModulusGF::Finalize(); + CBC_PDF417ScanningDecoder::Finalize(); +} diff --git a/xfa/fxbarcode/BC_LuminanceSource.cpp b/xfa/fxbarcode/BC_LuminanceSource.cpp new file mode 100644 index 0000000000..0aaa096197 --- /dev/null +++ b/xfa/fxbarcode/BC_LuminanceSource.cpp @@ -0,0 +1,33 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_LuminanceSource.h" + +CBC_LuminanceSource::CBC_LuminanceSource(int32_t width, int32_t height) + : m_width(width), m_height(height) {} +CBC_LuminanceSource::~CBC_LuminanceSource() {} +int32_t CBC_LuminanceSource::GetWidth() { + return m_width; +} +int32_t CBC_LuminanceSource::GetHeight() { + return m_height; +} diff --git a/xfa/fxbarcode/BC_LuminanceSource.h b/xfa/fxbarcode/BC_LuminanceSource.h new file mode 100644 index 0000000000..b4b3ebc03c --- /dev/null +++ b/xfa/fxbarcode/BC_LuminanceSource.h @@ -0,0 +1,27 @@ +// 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_FXBARCODE_BC_LUMINANCESOURCE_H_ +#define XFA_FXBARCODE_BC_LUMINANCESOURCE_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_LuminanceSource { + public: + CBC_LuminanceSource(int32_t width, int32_t height); + virtual ~CBC_LuminanceSource(); + int32_t GetWidth(); + int32_t GetHeight(); + + virtual CFX_ByteArray* GetRow(int32_t y, CFX_ByteArray& row, int32_t& e) = 0; + virtual CFX_ByteArray* GetMatrix() = 0; + + protected: + int32_t m_width; + int32_t m_height; +}; + +#endif // XFA_FXBARCODE_BC_LUMINANCESOURCE_H_ diff --git a/xfa/fxbarcode/BC_Reader.cpp b/xfa/fxbarcode/BC_Reader.cpp new file mode 100644 index 0000000000..9391da1856 --- /dev/null +++ b/xfa/fxbarcode/BC_Reader.cpp @@ -0,0 +1,10 @@ +// 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/fxbarcode/BC_Reader.h" + +CBC_Reader::CBC_Reader() {} +CBC_Reader::~CBC_Reader() {} diff --git a/xfa/fxbarcode/BC_Reader.h b/xfa/fxbarcode/BC_Reader.h new file mode 100644 index 0000000000..12cfd243e5 --- /dev/null +++ b/xfa/fxbarcode/BC_Reader.h @@ -0,0 +1,24 @@ +// 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_FXBARCODE_BC_READER_H_ +#define XFA_FXBARCODE_BC_READER_H_ + +#include "core/include/fxcrt/fx_string.h" + +class CBC_BinaryBitmap; + +class CBC_Reader { + public: + CBC_Reader(); + virtual ~CBC_Reader(); + virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e) = 0; + virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) = 0; +}; + +#endif // XFA_FXBARCODE_BC_READER_H_ diff --git a/xfa/fxbarcode/BC_ResultPoint.cpp b/xfa/fxbarcode/BC_ResultPoint.cpp new file mode 100644 index 0000000000..9726ea4240 --- /dev/null +++ b/xfa/fxbarcode/BC_ResultPoint.cpp @@ -0,0 +1,31 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" + +CBC_ResultPoint::CBC_ResultPoint(FX_FLOAT x, FX_FLOAT y) : m_x(x), m_y(y) {} +FX_FLOAT CBC_ResultPoint::GetX() { + return m_x; +} +FX_FLOAT CBC_ResultPoint::GetY() { + return m_y; +} diff --git a/xfa/fxbarcode/BC_ResultPoint.h b/xfa/fxbarcode/BC_ResultPoint.h new file mode 100644 index 0000000000..721adb1eaa --- /dev/null +++ b/xfa/fxbarcode/BC_ResultPoint.h @@ -0,0 +1,25 @@ +// 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_FXBARCODE_BC_RESULTPOINT_H_ +#define XFA_FXBARCODE_BC_RESULTPOINT_H_ + +#include "core/include/fxcrt/fx_system.h" + +class CBC_ResultPoint { + public: + CBC_ResultPoint(); + CBC_ResultPoint(FX_FLOAT x, FX_FLOAT y); + virtual ~CBC_ResultPoint() {} + virtual FX_FLOAT GetX(); + virtual FX_FLOAT GetY(); + + protected: + FX_FLOAT m_x; + FX_FLOAT m_y; +}; + +#endif // XFA_FXBARCODE_BC_RESULTPOINT_H_ diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp new file mode 100644 index 0000000000..f0065a02b9 --- /dev/null +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -0,0 +1,148 @@ +// 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 <algorithm> + +#include "third_party/base/numerics/safe_math.h" +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" + +CBC_TwoDimWriter::CBC_TwoDimWriter() { + m_iCorrectLevel = 1; + m_bFixedSize = TRUE; + m_output = NULL; +} +CBC_TwoDimWriter::~CBC_TwoDimWriter() { + delete m_output; +} +void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device, + const CFX_Matrix* matrix) { + CFX_GraphStateData stateData; + CFX_PathData path; + path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height); + device->DrawPath(&path, matrix, &stateData, m_backgroundColor, + m_backgroundColor, FXFILL_ALTERNATE); + int32_t leftPos = 0; + int32_t topPos = 0; + if (m_bFixedSize) { + leftPos = (m_Width - m_output->GetWidth()) / 2; + topPos = (m_Height - m_output->GetHeight()) / 2; + } + CFX_Matrix matri = *matrix; + if (m_Width < m_output->GetWidth() && m_Height < m_output->GetHeight()) { + CFX_Matrix matriScale( + (FX_FLOAT)m_Width / (FX_FLOAT)m_output->GetWidth(), 0.0, 0.0, + (FX_FLOAT)m_Height / (FX_FLOAT)m_output->GetHeight(), 0.0, 0.0); + matriScale.Concat(*matrix); + matri = matriScale; + } + for (int32_t x = 0; x < m_output->GetWidth(); x++) { + for (int32_t y = 0; y < m_output->GetHeight(); y++) { + CFX_PathData rect; + rect.AppendRect((FX_FLOAT)leftPos + x, (FX_FLOAT)topPos + y, + (FX_FLOAT)(leftPos + x + 1), (FX_FLOAT)(topPos + y + 1)); + CFX_GraphStateData stateData; + if (m_output->Get(x, y)) { + device->DrawPath(&rect, &matri, &stateData, m_barColor, 0, + FXFILL_WINDING); + } + } + } +} +void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + int32_t& e) { + if (m_bFixedSize) { + pOutBitmap = CreateDIBitmap(m_Width, m_Height); + } else { + pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); + } + if (!pOutBitmap) { + e = BCExceptionFailToCreateBitmap; + return; + } + pOutBitmap->Clear(m_backgroundColor); + int32_t leftPos = 0; + int32_t topPos = 0; + if (m_bFixedSize) { + leftPos = (m_Width - m_output->GetWidth()) / 2; + topPos = (m_Height - m_output->GetHeight()) / 2; + } + for (int32_t x = 0; x < m_output->GetWidth(); x++) { + for (int32_t y = 0; y < m_output->GetHeight(); y++) { + if (m_output->Get(x, y)) { + pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor); + } + } + } + if (!m_bFixedSize) { + CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); + if (pOutBitmap) { + delete pOutBitmap; + } + pOutBitmap = pStretchBitmap; + } +} +void CBC_TwoDimWriter::RenderResult(uint8_t* code, + int32_t codeWidth, + int32_t codeHeight, + int32_t& e) { + int32_t inputWidth = codeWidth; + int32_t inputHeight = codeHeight; + int32_t tempWidth = inputWidth + 2; + int32_t tempHeight = inputHeight + 2; + FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight); + moduleHSize = std::min(moduleHSize, 8.0f); + moduleHSize = std::max(moduleHSize, 1.0f); + pdfium::base::CheckedNumeric<int32_t> scaledWidth = tempWidth; + pdfium::base::CheckedNumeric<int32_t> scaledHeight = tempHeight; + scaledWidth *= moduleHSize; + scaledHeight *= moduleHSize; + + int32_t outputWidth = scaledWidth.ValueOrDie(); + int32_t outputHeight = scaledHeight.ValueOrDie(); + if (m_bFixedSize) { + if (m_Width < outputWidth || m_Height < outputHeight) { + e = BCExceptionBitmapSizeError; + return; + } + } else { + if (m_Width > outputWidth || m_Height > outputHeight) { + outputWidth = (int32_t)(outputWidth * + ceil((FX_FLOAT)m_Width / (FX_FLOAT)outputWidth)); + outputHeight = (int32_t)( + outputHeight * ceil((FX_FLOAT)m_Height / (FX_FLOAT)outputHeight)); + } + } + int32_t multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth); + int32_t multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight); + if (m_bFixedSize) { + multiX = std::min(multiX, multiY); + multiY = multiX; + } + int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2; + int32_t topPadding = (outputHeight - (inputHeight * multiY)) / 2; + if (leftPadding < 0) { + leftPadding = 0; + } + if (topPadding < 0) { + topPadding = 0; + } + m_output = new CBC_CommonBitMatrix; + m_output->Init(outputWidth, outputHeight); + for (int32_t inputY = 0, outputY = topPadding; + (inputY < inputHeight) && (outputY < outputHeight - multiY); + inputY++, outputY += multiY) { + for (int32_t inputX = 0, outputX = leftPadding; + (inputX < inputWidth) && (outputX < outputWidth - multiX); + inputX++, outputX += multiX) { + if (code[inputX + inputY * inputWidth] == 1) { + m_output->SetRegion(outputX, outputY, multiX, multiY, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } + } +} diff --git a/xfa/fxbarcode/BC_TwoDimWriter.h b/xfa/fxbarcode/BC_TwoDimWriter.h new file mode 100644 index 0000000000..f5dcd61ff8 --- /dev/null +++ b/xfa/fxbarcode/BC_TwoDimWriter.h @@ -0,0 +1,35 @@ +// 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_FXBARCODE_BC_TWODIMWRITER_H_ +#define XFA_FXBARCODE_BC_TWODIMWRITER_H_ + +#include "core/include/fxge/fx_ge.h" +#include "xfa/fxbarcode/BC_Writer.h" + +class CBC_CommonBitMatrix; + +class CBC_TwoDimWriter : public CBC_Writer { + public: + CBC_TwoDimWriter(); + virtual ~CBC_TwoDimWriter(); + virtual void RenderResult(uint8_t* code, + int32_t codeWidth, + int32_t codeHeight, + int32_t& e); + virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, int32_t& e); + virtual void RenderDeviceResult(CFX_RenderDevice* device, + const CFX_Matrix* matrix); + virtual FX_BOOL SetErrorCorrectionLevel(int32_t level) = 0; + virtual int32_t GetErrorCorrectionLevel() { return m_iCorrectLevel; } + + protected: + int32_t m_iCorrectLevel; + FX_BOOL m_bFixedSize; + CBC_CommonBitMatrix* m_output; +}; + +#endif // XFA_FXBARCODE_BC_TWODIMWRITER_H_ diff --git a/xfa/fxbarcode/BC_UtilCodingConvert.cpp b/xfa/fxbarcode/BC_UtilCodingConvert.cpp new file mode 100644 index 0000000000..8421e280f3 --- /dev/null +++ b/xfa/fxbarcode/BC_UtilCodingConvert.cpp @@ -0,0 +1,53 @@ +// 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/fxbarcode/BC_UtilCodingConvert.h" + +CBC_UtilCodingConvert::CBC_UtilCodingConvert() {} + +CBC_UtilCodingConvert::~CBC_UtilCodingConvert() {} + +void CBC_UtilCodingConvert::UnicodeToLocale(const CFX_WideString& src, + CFX_ByteString& dst) { + dst = CFX_ByteString::FromUnicode(src); +} + +void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src, + CFX_ByteString& dst) { + CFX_WideString unicode = CFX_WideString::FromLocal(src); + dst = unicode.UTF8Encode(); +} + +void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src, + CFX_ByteArray& dst) { + CFX_WideString unicode = CFX_WideString::FromLocal(src); + CFX_ByteString utf8 = unicode.UTF8Encode(); + for (int32_t i = 0; i < utf8.GetLength(); i++) { + dst.Add(utf8[i]); + } +} + +void CBC_UtilCodingConvert::Utf8ToLocale(const CFX_ByteArray& src, + CFX_ByteString& dst) { + CFX_ByteString utf8; + for (int32_t i = 0; i < src.GetSize(); i++) { + utf8 += src[i]; + } + CFX_WideString unicode = CFX_WideString::FromUTF8(utf8, utf8.GetLength()); + 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); + dst = CFX_ByteString::FromUnicode(unicode); +} + +void CBC_UtilCodingConvert::UnicodeToUTF8(const CFX_WideString& src, + CFX_ByteString& dst) { + dst = src.UTF8Encode(); +} diff --git a/xfa/fxbarcode/BC_UtilCodingConvert.h b/xfa/fxbarcode/BC_UtilCodingConvert.h new file mode 100644 index 0000000000..2d5c9f3892 --- /dev/null +++ b/xfa/fxbarcode/BC_UtilCodingConvert.h @@ -0,0 +1,29 @@ +// 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_FXBARCODE_BC_UTILCODINGCONVERT_H_ +#define XFA_FXBARCODE_BC_UTILCODINGCONVERT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_UtilCodingConvert { + public: + CBC_UtilCodingConvert(); + virtual ~CBC_UtilCodingConvert(); + static void UnicodeToLocale(const CFX_WideString& source, + CFX_ByteString& result); + static void LocaleToUtf8(const CFX_ByteString& source, + CFX_ByteString& result); + static void LocaleToUtf8(const CFX_ByteString& source, CFX_ByteArray& result); + static void Utf8ToLocale(const CFX_ByteArray& source, CFX_ByteString& result); + static void Utf8ToLocale(const uint8_t* source, + int32_t count, + CFX_ByteString& result); + static void UnicodeToUTF8(const CFX_WideString& source, + CFX_ByteString& result); +}; + +#endif // XFA_FXBARCODE_BC_UTILCODINGCONVERT_H_ diff --git a/xfa/fxbarcode/BC_UtilRSS.cpp b/xfa/fxbarcode/BC_UtilRSS.cpp new file mode 100644 index 0000000000..0d6133cf40 --- /dev/null +++ b/xfa/fxbarcode/BC_UtilRSS.cpp @@ -0,0 +1,164 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_UtilRSS.h" + +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +CBC_UtilRSS::CBC_UtilRSS() {} +CBC_UtilRSS::~CBC_UtilRSS() {} +CFX_Int32Array* CBC_UtilRSS::GetRssWidths(int32_t val, + int32_t n, + int32_t elements, + int32_t maxWidth, + FX_BOOL noNarrow) { + std::unique_ptr<CFX_Int32Array> widths(new CFX_Int32Array); + widths->SetSize(elements); + int32_t bar; + int32_t narrowMask = 0; + for (bar = 0; bar < elements - 1; bar++) { + narrowMask |= (1 << bar); + int32_t elmWidth = 1; + int32_t subVal; + while (TRUE) { + subVal = Combins(n - elmWidth - 1, elements - bar - 2); + if (noNarrow && (narrowMask == 0) && + (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { + subVal -= Combins(n - elmWidth - (elements - bar), elements - bar - 2); + } + if (elements - bar - 1 > 1) { + int32_t lessVal = 0; + for (int32_t mxwElement = n - elmWidth - (elements - bar - 2); + mxwElement > maxWidth; mxwElement--) { + lessVal += Combins(n - elmWidth - mxwElement - 1, elements - bar - 3); + } + subVal -= lessVal * (elements - 1 - bar); + } else if (n - elmWidth > maxWidth) { + subVal--; + } + val -= subVal; + if (val < 0) { + break; + } + elmWidth++; + narrowMask &= ~(1 << bar); + } + val += subVal; + n -= elmWidth; + (*widths)[bar] = elmWidth; + } + (*widths)[bar] = n; + return widths.release(); +} +int32_t CBC_UtilRSS::GetRSSvalue(CFX_Int32Array& widths, + int32_t maxWidth, + FX_BOOL noNarrow) { + int32_t elements = widths.GetSize(); + int32_t n = 0; + for (int32_t i = 0; i < elements; i++) { + n += widths[i]; + } + int32_t val = 0; + int32_t narrowMask = 0; + for (int32_t bar = 0; bar < elements - 1; bar++) { + int32_t elmWidth; + for (elmWidth = 1, narrowMask |= (1 << bar); elmWidth < widths[bar]; + elmWidth++, narrowMask &= ~(1 << bar)) { + int32_t subVal = Combins(n - elmWidth - 1, elements - bar - 2); + if (noNarrow && (narrowMask == 0) && + (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { + subVal -= Combins(n - elmWidth - (elements - bar), elements - bar - 2); + } + if (elements - bar - 1 > 1) { + int32_t lessVal = 0; + for (int32_t mxwElement = n - elmWidth - (elements - bar - 2); + mxwElement > maxWidth; mxwElement--) { + lessVal += Combins(n - elmWidth - mxwElement - 1, elements - bar - 3); + } + subVal -= lessVal * (elements - 1 - bar); + } else if (n - elmWidth > maxWidth) { + subVal--; + } + val += subVal; + } + n -= elmWidth; + } + return val; +} +int32_t CBC_UtilRSS::Combins(int32_t n, int32_t r) { + int32_t maxDenom; + int32_t minDenom; + if (n - r > r) { + minDenom = r; + maxDenom = n - r; + } else { + minDenom = n - r; + maxDenom = r; + } + int32_t val = 1; + int32_t j = 1; + for (int32_t i = n; i > maxDenom; i--) { + val *= i; + if (j <= minDenom) { + val /= j; + j++; + } + } + while (j <= minDenom) { + val /= j; + j++; + } + return val; +} +CFX_Int32Array* CBC_UtilRSS::Elements(CFX_Int32Array& eDist, + int32_t N, + int32_t K) { + CFX_Int32Array* widths = new CFX_Int32Array; + widths->SetSize(eDist.GetSize() + 2); + int32_t twoK = K << 1; + (*widths)[0] = 1; + int32_t i; + int32_t minEven = 10; + int32_t barSum = 1; + for (i = 1; i < twoK - 2; i += 2) { + (*widths)[i] = eDist[i - 1] - (*widths)[i - 1]; + (*widths)[i + 1] = eDist[i] - (*widths)[i]; + barSum += (*widths)[i] + (*widths)[i + 1]; + if ((*widths)[i] < minEven) { + minEven = (*widths)[i]; + } + } + (*widths)[twoK - 1] = N - barSum; + if ((*widths)[twoK - 1] < minEven) { + minEven = (*widths)[twoK - 1]; + } + if (minEven > 1) { + for (i = 0; i < twoK; i += 2) { + (*widths)[i] += minEven - 1; + (*widths)[i + 1] -= minEven - 1; + } + } + return widths; +} diff --git a/xfa/fxbarcode/BC_UtilRSS.h b/xfa/fxbarcode/BC_UtilRSS.h new file mode 100644 index 0000000000..b81804e0c8 --- /dev/null +++ b/xfa/fxbarcode/BC_UtilRSS.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_BC_UTILRSS_H_ +#define XFA_FXBARCODE_BC_UTILRSS_H_ + +#include <cstdint> + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_UtilRSS { + public: + virtual ~CBC_UtilRSS(); + static int32_t GetRSSvalue(CFX_Int32Array& widths, + int32_t maxWidth, + FX_BOOL noNarrow); + + protected: + static CFX_Int32Array* GetRssWidths(int32_t val, + int32_t n, + int32_t elements, + int32_t maxWidth, + FX_BOOL noNarrow); + static int32_t Combins(int32_t n, int32_t r); + static CFX_Int32Array* Elements(CFX_Int32Array& eDist, int32_t N, int32_t K); + + private: + CBC_UtilRSS(); +}; + +#endif // XFA_FXBARCODE_BC_UTILRSS_H_ diff --git a/xfa/fxbarcode/BC_Utils.cpp b/xfa/fxbarcode/BC_Utils.cpp new file mode 100644 index 0000000000..02719689e6 --- /dev/null +++ b/xfa/fxbarcode/BC_Utils.cpp @@ -0,0 +1,48 @@ +// 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/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString& dst, + FX_DWORD first, + FX_DWORD last, + int32_t count, + FX_CHAR c) { + if (first > last || count <= 0) { + return FALSE; + } + dst.Delete(first, last - first); + for (int32_t i = 0; i < count; i++) { + dst.Insert(0, c); + } + return TRUE; +} +void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c) { + for (int32_t i = 0; i < count; i++) { + dst += c; + } +} +void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba) { + for (int32_t i = 0; i < ba.GetSize(); i++) { + 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/xfa/fxbarcode/BC_Writer.cpp b/xfa/fxbarcode/BC_Writer.cpp new file mode 100644 index 0000000000..835a2f0309 --- /dev/null +++ b/xfa/fxbarcode/BC_Writer.cpp @@ -0,0 +1,56 @@ +// 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/fxbarcode/BC_Writer.h" + +CBC_Writer::CBC_Writer() { + m_CharEncoding = 0; + m_ModuleHeight = 1; + m_ModuleWidth = 1; + m_Height = 320; + m_Width = 640; + m_colorSpace = FXDIB_Argb; + m_barColor = 0xff000000; + m_backgroundColor = 0xffffffff; +} +CBC_Writer::~CBC_Writer() {} +FX_BOOL CBC_Writer::SetCharEncoding(int32_t encoding) { + m_CharEncoding = encoding; + return TRUE; +} +FX_BOOL CBC_Writer::SetModuleHeight(int32_t moduleHeight) { + if (moduleHeight > 10 || moduleHeight < 1) { + return FALSE; + } + m_ModuleHeight = moduleHeight; + return TRUE; +} +FX_BOOL CBC_Writer::SetModuleWidth(int32_t moduleWidth) { + if (moduleWidth > 10 || moduleWidth < 1) { + return FALSE; + } + m_ModuleWidth = moduleWidth; + return TRUE; +} +FX_BOOL CBC_Writer::SetHeight(int32_t height) { + m_Height = height; + return TRUE; +} +FX_BOOL CBC_Writer::SetWidth(int32_t width) { + m_Width = width; + return TRUE; +} +void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) { + m_backgroundColor = backgroundColor; +} +void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { + m_barColor = foregroundColor; +} +CFX_DIBitmap* CBC_Writer::CreateDIBitmap(int32_t width, int32_t height) { + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; + pDIBitmap->Create(width, height, m_colorSpace); + return pDIBitmap; +} diff --git a/xfa/fxbarcode/BC_Writer.h b/xfa/fxbarcode/BC_Writer.h new file mode 100644 index 0000000000..bff3642b94 --- /dev/null +++ b/xfa/fxbarcode/BC_Writer.h @@ -0,0 +1,38 @@ +// 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_FXBARCODE_BC_WRITER_H_ +#define XFA_FXBARCODE_BC_WRITER_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxge/fx_dib.h" +#include "xfa/fxbarcode/utils.h" + +class CBC_Writer { + public: + CBC_Writer(); + virtual ~CBC_Writer(); + virtual FX_BOOL SetCharEncoding(int32_t 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 void SetBackgroundColor(FX_ARGB backgroundColor); + virtual void SetBarcodeColor(FX_ARGB foregroundColor); + + protected: + CFX_DIBitmap* CreateDIBitmap(int32_t width, int32_t height); + int32_t m_CharEncoding; + int32_t m_ModuleHeight; + int32_t m_ModuleWidth; + int32_t m_Height; + int32_t m_Width; + FXDIB_Format m_colorSpace; + FX_ARGB m_barColor; + FX_ARGB m_backgroundColor; +}; + +#endif // XFA_FXBARCODE_BC_WRITER_H_ diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/fxbarcode/common/BC_CommonBitArray.cpp new file mode 100644 index 0000000000..b39e4acd88 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitArray.cpp @@ -0,0 +1,113 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/utils.h" + +CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array) { + m_size = array->GetSize(); + m_bits.Copy(array->GetBits()); +} +CBC_CommonBitArray::CBC_CommonBitArray() { + m_bits.SetSize(1); + m_size = 0; +} +CBC_CommonBitArray::CBC_CommonBitArray(int32_t size) { + m_bits.SetSize((size + 31) >> 5); + m_size = size; +} +CBC_CommonBitArray::~CBC_CommonBitArray() { + m_size = 0; +} +int32_t CBC_CommonBitArray::GetSize() { + return m_size; +} +CFX_Int32Array& CBC_CommonBitArray::GetBits() { + return m_bits; +} +int32_t CBC_CommonBitArray::GetSizeInBytes() { + return (m_size + 7) >> 3; +} +FX_BOOL CBC_CommonBitArray::Get(int32_t i) { + return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0; +} +void CBC_CommonBitArray::Set(int32_t i) { + m_bits[i >> 5] |= 1 << (i & 0x1F); +} +void CBC_CommonBitArray::Flip(int32_t i) { + m_bits[i >> 5] ^= 1 << (i & 0x1F); +} +void CBC_CommonBitArray::SetBulk(int32_t i, int32_t newBits) { + m_bits[i >> 5] = newBits; +} +void CBC_CommonBitArray::Clear() { + FXSYS_memset(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(int32_t)); +} +FX_BOOL CBC_CommonBitArray::IsRange(int32_t start, + int32_t end, + FX_BOOL value, + int32_t& e) { + if (end < start) { + e = BCExceptionEndLessThanStart; + return FALSE; + } + if (end == start) { + return TRUE; + } + end--; + int32_t firstInt = start >> 5; + int32_t lastInt = end >> 5; + int32_t i; + for (i = firstInt; i <= lastInt; i++) { + int32_t firstBit = i > firstInt ? 0 : start & 0x1F; + int32_t lastBit = i < lastInt ? 31 : end & 0x1F; + int32_t mask; + if (firstBit == 0 && lastBit == 31) { + mask = -1; + } else { + mask = 0; + for (int32_t j = firstBit; j <= lastBit; j++) { + mask |= 1 << j; + } + } + if ((m_bits[i] & mask) != (value ? mask : 0)) { + return FALSE; + } + } + return TRUE; +} +int32_t* CBC_CommonBitArray::GetBitArray() { + return &m_bits[0]; +} +void CBC_CommonBitArray::Reverse() { + int32_t* newBits = FX_Alloc(int32_t, m_bits.GetSize()); + FXSYS_memset(newBits, 0x00, m_bits.GetSize() * sizeof(int32_t)); + int32_t size = m_size; + int32_t i; + for (i = 0; i < size; i++) { + if (Get(size - i - 1)) { + newBits[i >> 5] |= 1 << (i & 0x1F); + } + } + FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t)); + FX_Free(newBits); +} diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.h b/xfa/fxbarcode/common/BC_CommonBitArray.h new file mode 100644 index 0000000000..6ddd789480 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitArray.h @@ -0,0 +1,35 @@ +// 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_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitArray { + public: + CBC_CommonBitArray(CBC_CommonBitArray* array); + CBC_CommonBitArray(int32_t size); + CBC_CommonBitArray(); + virtual ~CBC_CommonBitArray(); + int32_t GetSize(); + CFX_Int32Array& GetBits(); + int32_t GetSizeInBytes(); + FX_BOOL Get(int32_t i); + void Set(int32_t i); + void Flip(int32_t i); + void SetBulk(int32_t i, int32_t newBits); + FX_BOOL IsRange(int32_t start, int32_t end, FX_BOOL value, int32_t& e); + int32_t* GetBitArray(); + void Reverse(); + void Clear(); + + private: + int32_t m_size; + CFX_Int32Array m_bits; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ diff --git a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp new file mode 100644 index 0000000000..a8f87e7ec4 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp @@ -0,0 +1,146 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/utils.h" + +CBC_CommonBitMatrix::CBC_CommonBitMatrix() { + m_width = 0; + m_height = 0; + m_rowSize = 0; + m_bits = NULL; +} +void CBC_CommonBitMatrix::Init(int32_t dimension) { + m_width = dimension; + m_height = dimension; + int32_t rowSize = (m_height + 31) >> 5; + m_rowSize = rowSize; + m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); + FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); +} +void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { + m_width = width; + m_height = height; + int32_t rowSize = (width + 31) >> 5; + m_rowSize = rowSize; + m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); + FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); +} +CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { + FX_Free(m_bits); +} +FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { + int32_t offset = y * m_rowSize + (x >> 5); + if (offset >= m_rowSize * m_height || offset < 0) { + return false; + } + return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; +} +int32_t* CBC_CommonBitMatrix::GetBits() { + return m_bits; +} +void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) { + int32_t offset = y * m_rowSize + (x >> 5); + if (offset >= m_rowSize * m_height || offset < 0) { + return; + } + m_bits[offset] |= 1 << (x & 0x1f); +} +void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y) { + int32_t offset = y * m_rowSize + (x >> 5); + m_bits[offset] ^= 1 << (x & 0x1f); +} +void CBC_CommonBitMatrix::Clear() { + FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); +} +void CBC_CommonBitMatrix::SetRegion(int32_t left, + int32_t top, + int32_t width, + int32_t height, + int32_t& e) { + if (top < 0 || left < 0) { + e = BCExceptionLeftAndTopMustBeNonnegative; + return; + } + if (height < 1 || width < 1) { + e = BCExceptionHeightAndWidthMustBeAtLeast1; + return; + } + int32_t right = left + width; + int32_t bottom = top + height; + if (m_height < bottom || m_width < right) { + e = BCExceptionRegionMustFitInsideMatrix; + return; + } + int32_t y; + for (y = top; y < bottom; y++) { + int32_t offset = y * m_rowSize; + int32_t x; + for (x = left; x < right; x++) { + m_bits[offset + (x >> 5)] |= 1 << (x & 0x1f); + } + } +} +CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y, + CBC_CommonBitArray* row) { + CBC_CommonBitArray* rowArray = NULL; + if (row == NULL || row->GetSize() < m_width) { + rowArray = new CBC_CommonBitArray(m_width); + } else { + rowArray = new CBC_CommonBitArray(row); + } + int32_t offset = y * m_rowSize; + int32_t x; + for (x = 0; x < m_rowSize; x++) { + rowArray->SetBulk(x << 5, m_bits[offset + x]); + } + return rowArray; +} +void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) { + int32_t l = y * m_rowSize; + for (int32_t i = 0; i < m_rowSize; i++) { + m_bits[l] = row->GetBitArray()[i]; + l++; + } +} +void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) { + for (int32_t i = 0; i < col->GetBits().GetSize(); i++) { + m_bits[i * m_rowSize + y] = col->GetBitArray()[i]; + } +} +int32_t CBC_CommonBitMatrix::GetWidth() { + return m_width; +} +int32_t CBC_CommonBitMatrix::GetHeight() { + return m_height; +} +int32_t CBC_CommonBitMatrix::GetRowSize() { + return m_rowSize; +} +int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { + if (m_width != m_height) { + e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; + return 0; + } + return m_width; +} diff --git a/xfa/fxbarcode/common/BC_CommonBitMatrix.h b/xfa/fxbarcode/common/BC_CommonBitMatrix.h new file mode 100644 index 0000000000..78b42641dd --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitMatrix.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 XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ + +#include "core/include/fxcrt/fx_system.h" + +class CBC_CommonBitArray; + +class CBC_CommonBitMatrix { + public: + CBC_CommonBitMatrix(); + virtual ~CBC_CommonBitMatrix(); + FX_BOOL Get(int32_t x, int32_t y); + void Set(int32_t x, int32_t y); + void Flip(int32_t x, int32_t y); + void Clear(); + void SetRegion(int32_t left, + int32_t top, + int32_t width, + int32_t height, + int32_t& e); + CBC_CommonBitArray* GetRow(int32_t y, CBC_CommonBitArray* row); + void SetRow(int32_t y, CBC_CommonBitArray* row); + CBC_CommonBitArray* GetCol(int32_t y, CBC_CommonBitArray* row); + void SetCol(int32_t y, CBC_CommonBitArray* col); + int32_t GetWidth(); + int32_t GetHeight(); + int32_t GetRowSize(); + int32_t GetDimension(int32_t& e); + virtual void Init(int32_t dimension); + virtual void Init(int32_t width, int32_t height); + int32_t* GetBits(); + + private: + int32_t m_width; + int32_t m_height; + int32_t m_rowSize; + int32_t* m_bits; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ diff --git a/xfa/fxbarcode/common/BC_CommonBitSource.cpp b/xfa/fxbarcode/common/BC_CommonBitSource.cpp new file mode 100644 index 0000000000..af91d5e0bd --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitSource.cpp @@ -0,0 +1,71 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitSource.h" + +CBC_CommonBitSource::CBC_CommonBitSource(CFX_ByteArray* bytes) { + m_bytes.Copy((*bytes)); + m_bitOffset = 0; + m_byteOffset = 0; +} +CBC_CommonBitSource::~CBC_CommonBitSource() {} +int32_t CBC_CommonBitSource::ReadBits(int32_t numBits, int32_t& e) { + if (numBits < 1 || numBits > 32) { + e = BCExceptionIllegalArgument; + return 0; + } + int32_t result = 0; + if (m_bitOffset > 0) { + int32_t bitsLeft = 8 - m_bitOffset; + int32_t toRead = numBits < bitsLeft ? numBits : bitsLeft; + int32_t bitsToNotRead = bitsLeft - toRead; + int32_t mask = (0xff >> (8 - toRead)) << bitsToNotRead; + result = (m_bytes[m_byteOffset] & mask) >> bitsToNotRead; + numBits -= toRead; + m_bitOffset += toRead; + if (m_bitOffset == 8) { + m_bitOffset = 0; + m_byteOffset++; + } + } + if (numBits > 0) { + while (numBits >= 8) { + result = (result << 8) | (m_bytes[m_byteOffset] & 0xff); + m_byteOffset++; + numBits -= 8; + } + if (numBits > 0) { + int32_t bitsToNotRead = 8 - numBits; + int32_t mask = (0xff >> bitsToNotRead) << bitsToNotRead; + result = (result << numBits) | + ((m_bytes[m_byteOffset] & mask) >> bitsToNotRead); + m_bitOffset += numBits; + } + } + return result; +} +int32_t CBC_CommonBitSource::Available() { + return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset; +} +int32_t CBC_CommonBitSource::getByteOffset() { + return m_byteOffset; +} diff --git a/xfa/fxbarcode/common/BC_CommonBitSource.h b/xfa/fxbarcode/common/BC_CommonBitSource.h new file mode 100644 index 0000000000..7617a6f19d --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonBitSource.h @@ -0,0 +1,27 @@ +// 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_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +class CBC_CommonBitSource { + public: + CBC_CommonBitSource(CFX_ByteArray* bytes); + virtual ~CBC_CommonBitSource(); + int32_t ReadBits(int32_t numBits, int32_t& e); + int32_t Available(); + int32_t getByteOffset(); + + private: + CFX_ByteArray m_bytes; + int32_t m_byteOffset; + int32_t m_bitOffset; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/fxbarcode/common/BC_CommonByteArray.cpp new file mode 100644 index 0000000000..1fd6e46420 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonByteArray.cpp @@ -0,0 +1,99 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <algorithm> + +#include "xfa/fxbarcode/common/BC_CommonByteArray.h" + +CBC_CommonByteArray::CBC_CommonByteArray() { + m_bytes = NULL; + m_size = 0; + m_index = 0; +} +CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) { + m_size = size; + m_bytes = FX_Alloc(uint8_t, size); + FXSYS_memset(m_bytes, 0, size); + m_index = 0; +} +CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) { + m_size = size; + m_bytes = FX_Alloc(uint8_t, size); + FXSYS_memcpy(m_bytes, byteArray, size); + m_index = size; +} +CBC_CommonByteArray::~CBC_CommonByteArray() { + FX_Free(m_bytes); +} +int32_t CBC_CommonByteArray::At(int32_t index) { + return m_bytes[index] & 0xff; +} +void CBC_CommonByteArray::Set(int32_t index, int32_t value) { + m_bytes[index] = (uint8_t)value; +} +int32_t CBC_CommonByteArray::Size() { + return m_size; +} +FX_BOOL CBC_CommonByteArray::IsEmpty() { + return m_size == 0; +} +void CBC_CommonByteArray::AppendByte(int32_t value) { + if (m_size == 0 || m_index >= m_size) { + int32_t newSize = std::max(32, m_size << 1); + Reserve(newSize); + } + m_bytes[m_index] = (uint8_t)value; + m_index++; +} +void CBC_CommonByteArray::Reserve(int32_t capacity) { + if (m_bytes == NULL || m_size < capacity) { + uint8_t* newArray = FX_Alloc(uint8_t, capacity); + if (m_bytes) { + FXSYS_memcpy(newArray, m_bytes, m_size); + FXSYS_memset(newArray + m_size, 0, capacity - m_size); + } else { + FXSYS_memset(newArray, 0, capacity); + } + FX_Free(m_bytes); + m_bytes = newArray; + m_size = capacity; + } +} +void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) { + FX_Free(m_bytes); + m_bytes = FX_Alloc(uint8_t, count); + m_size = count; + FXSYS_memcpy(m_bytes, source + offset, count); + m_index = count; +} +void CBC_CommonByteArray::Set(CFX_ByteArray* source, + int32_t offset, + int32_t count) { + FX_Free(m_bytes); + m_bytes = FX_Alloc(uint8_t, count); + m_size = count; + int32_t i; + for (i = 0; i < count; i++) { + m_bytes[i] = source->operator[](i + offset); + } + m_index = m_size; +} diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.h b/xfa/fxbarcode/common/BC_CommonByteArray.h new file mode 100644 index 0000000000..69d470b0e5 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonByteArray.h @@ -0,0 +1,33 @@ +// 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_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonByteArray { + private: + int32_t m_size; + int32_t m_index; + uint8_t* m_bytes; + + public: + CBC_CommonByteArray(); + CBC_CommonByteArray(int32_t size); + CBC_CommonByteArray(uint8_t* byteArray, int32_t size); + virtual ~CBC_CommonByteArray(); + int32_t At(int32_t index); + void Set(int32_t index, int32_t value); + int32_t Size(); + FX_BOOL IsEmpty(); + void AppendByte(int32_t value); + void Reserve(int32_t capacity); + void Set(uint8_t* source, int32_t offset, int32_t count); + void Set(CFX_ByteArray* source, int32_t offset, int32_t count); +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ diff --git a/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp new file mode 100644 index 0000000000..c9ed7495c0 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp @@ -0,0 +1,64 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcrt/fx_memory.h" +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" + +CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) { + m_height = height; + m_width = width; + m_bytes = NULL; +} +void CBC_CommonByteMatrix::Init() { + m_bytes = FX_Alloc2D(uint8_t, m_height, m_width); + FXSYS_memset(m_bytes, 0xff, m_height * m_width); +} +CBC_CommonByteMatrix::~CBC_CommonByteMatrix() { + FX_Free(m_bytes); +} +int32_t CBC_CommonByteMatrix::GetHeight() { + return m_height; +} +int32_t CBC_CommonByteMatrix::GetWidth() { + return m_width; +} +uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) { + return m_bytes[y * m_width + x]; +} +void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) { + m_bytes[y * m_width + x] = (uint8_t)value; +} +void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) { + m_bytes[y * m_width + x] = value; +} +void CBC_CommonByteMatrix::clear(uint8_t value) { + int32_t y; + for (y = 0; y < m_height; y++) { + int32_t x; + for (x = 0; x < m_width; x++) { + m_bytes[y * m_width + x] = value; + } + } +} +uint8_t* CBC_CommonByteMatrix::GetArray() { + return m_bytes; +} diff --git a/xfa/fxbarcode/common/BC_CommonByteMatrix.h b/xfa/fxbarcode/common/BC_CommonByteMatrix.h new file mode 100644 index 0000000000..271feef34f --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonByteMatrix.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ + +#include <stdint.h> + +#include "core/include/fxcrt/fx_system.h" + +class CBC_CommonByteMatrix { + public: + CBC_CommonByteMatrix(int32_t width, int32_t height); + virtual ~CBC_CommonByteMatrix(); + int32_t GetHeight(); + int32_t GetWidth(); + uint8_t Get(int32_t x, int32_t y); + uint8_t* GetArray(); + + void Set(int32_t x, int32_t y, int32_t value); + void Set(int32_t x, int32_t y, uint8_t value); + void clear(uint8_t value); + virtual void Init(); + + private: + uint8_t* m_bytes; + int32_t m_width; + int32_t m_height; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ diff --git a/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp new file mode 100644 index 0000000000..d6fa9e472e --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.cpp @@ -0,0 +1,44 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h" +#include "xfa/fxbarcode/common/BC_CommonECI.h" + +void CBC_CommonCharacterSetECI::initialize() {} +CBC_CommonCharacterSetECI::CBC_CommonCharacterSetECI( + int32_t value, + CFX_ByteString encodingName) + : CBC_CommonECI(value), m_encodingName(encodingName) {} +CBC_CommonCharacterSetECI::~CBC_CommonCharacterSetECI() {} +CFX_ByteString CBC_CommonCharacterSetECI::GetEncodingName() { + return m_encodingName; +} +void CBC_CommonCharacterSetECI::AddCharacterSet(int32_t value, + CFX_ByteString encodingName) {} +CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByValue( + int32_t value) { + return NULL; +} +CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByName( + const CFX_ByteString& name) { + return NULL; +} diff --git a/xfa/fxbarcode/common/BC_CommonCharacterSetECI.h b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.h new file mode 100644 index 0000000000..18a676a449 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonCharacterSetECI.h @@ -0,0 +1,29 @@ +// 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_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fxbarcode/common/BC_CommonECI.h" + +class CBC_CommonCharacterSetECI : public CBC_CommonECI { + public: + CBC_CommonCharacterSetECI(int32_t value, CFX_ByteString encodingName); + virtual ~CBC_CommonCharacterSetECI(); + CFX_ByteString GetEncodingName(); + static void AddCharacterSet(int32_t value, CFX_ByteString encodingName); + int32_t GetValue(); + static CBC_CommonCharacterSetECI* GetCharacterSetECIByValue(int32_t value); + static CBC_CommonCharacterSetECI* GetCharacterSetECIByName( + const CFX_ByteString& name); + + private: + CFX_ByteString m_encodingName; + static void initialize(); +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ diff --git a/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp new file mode 100644 index 0000000000..0c545c4eba --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp @@ -0,0 +1,77 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/utils.h" + +CBC_CommonDecoderResult::CBC_CommonDecoderResult() {} +void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes, + const CFX_ByteString& text, + const CFX_Int32Array& byteSegments, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t& e) { + if (text.IsEmpty()) { + e = BCExceptionIllegalArgument; + return; + } + m_rawBytes.Copy(rawBytes); + m_text = text; + m_byteSegments.Copy(byteSegments); + m_ecLevel = ecLevel; + m_other = NULL; +} +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()) { + e = BCExceptionIllegalArgument; + return; + } + m_rawBytes.Copy(rawBytes); + m_text = text; + m_pdf417byteSegments.Copy(byteSegments); + m_pdf417ecLevel = ecLevel; + m_other = NULL; +} +void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other) { + m_other = other; +} +CBC_CommonDecoderResult::~CBC_CommonDecoderResult() { + delete m_other; +} +const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() { + return m_rawBytes; +} +const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments() { + return m_byteSegments; +} +const CFX_ByteString& CBC_CommonDecoderResult::GetText() { + return m_text; +} +CBC_QRCoderErrorCorrectionLevel* CBC_CommonDecoderResult::GetECLevel() { + return m_ecLevel; +} diff --git a/xfa/fxbarcode/common/BC_CommonDecoderResult.h b/xfa/fxbarcode/common/BC_CommonDecoderResult.h new file mode 100644 index 0000000000..dbdb9d34d4 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonDecoderResult.h @@ -0,0 +1,45 @@ +// 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_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_QRCoderErrorCorrectionLevel; +class CBC_PDF417ResultMetadata; + +class CBC_CommonDecoderResult { + public: + CBC_CommonDecoderResult(); + virtual ~CBC_CommonDecoderResult(); + const CFX_ByteArray& GetRawBytes(); + const CFX_ByteString& GetText(); + const CFX_Int32Array& GetByteSegments(); + CBC_QRCoderErrorCorrectionLevel* GetECLevel(); + virtual void Init(const CFX_ByteArray& rawBytes, + const CFX_ByteString& text, + const CFX_Int32Array& byteSegments, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + 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); + + private: + 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; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ diff --git a/xfa/fxbarcode/common/BC_CommonECI.cpp b/xfa/fxbarcode/common/BC_CommonECI.cpp new file mode 100644 index 0000000000..4e37aec566 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonECI.cpp @@ -0,0 +1,42 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h" +#include "xfa/fxbarcode/common/BC_CommonECI.h" +#include "xfa/fxbarcode/utils.h" + +CBC_CommonECI::CBC_CommonECI(int32_t value) { + m_value = value; +} +CBC_CommonECI::~CBC_CommonECI() {} +int32_t CBC_CommonECI::GetValue() { + return m_value; +} +CBC_CommonECI* CBC_CommonECI::GetEICByValue(int32_t value, int32_t& e) { + if (value < 0 || value > 999999) { + e = BCExceptionBadECI; + return NULL; + } + if (value < 900) { + } + return NULL; +} diff --git a/xfa/fxbarcode/common/BC_CommonECI.h b/xfa/fxbarcode/common/BC_CommonECI.h new file mode 100644 index 0000000000..20b3e76bb3 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonECI.h @@ -0,0 +1,24 @@ +// 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_FXBARCODE_COMMON_BC_COMMONECI_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONECI_H_ + +#include <stdint.h> + +class CBC_CommonECI { + public: + CBC_CommonECI(int32_t value); + virtual ~CBC_CommonECI(); + + int32_t GetValue(); + static CBC_CommonECI* GetEICByValue(int32_t value, int32_t& e); + + private: + int32_t m_value; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONECI_H_ diff --git a/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.cpp new file mode 100644 index 0000000000..daa6189e56 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.cpp @@ -0,0 +1,152 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h" + +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11, + FX_FLOAT a21, + FX_FLOAT a31, + FX_FLOAT a12, + FX_FLOAT a22, + FX_FLOAT a32, + FX_FLOAT a13, + FX_FLOAT a23, + FX_FLOAT a33) + : m_a11(a11), + m_a12(a12), + m_a13(a13), + m_a21(a21), + m_a22(a22), + m_a23(a23), + m_a31(a31), + m_a32(a32), + m_a33(a33) {} +CBC_CommonPerspectiveTransform::~CBC_CommonPerspectiveTransform() {} +CBC_CommonPerspectiveTransform* +CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3, + FX_FLOAT x0p, + FX_FLOAT y0p, + FX_FLOAT x1p, + FX_FLOAT y1p, + FX_FLOAT x2p, + FX_FLOAT y2p, + FX_FLOAT x3p, + FX_FLOAT y3p) { + std::unique_ptr<CBC_CommonPerspectiveTransform> qToS( + QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3)); + std::unique_ptr<CBC_CommonPerspectiveTransform> sToQ( + SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)); + return sToQ->Times(*(qToS.get())); +} +void CBC_CommonPerspectiveTransform::TransformPoints(CFX_FloatArray* points) { + int32_t max = points->GetSize(); + FX_FLOAT a11 = m_a11; + FX_FLOAT a12 = m_a12; + FX_FLOAT a13 = m_a13; + FX_FLOAT a21 = m_a21; + FX_FLOAT a22 = m_a22; + FX_FLOAT a23 = m_a23; + FX_FLOAT a31 = m_a31; + FX_FLOAT a32 = m_a32; + FX_FLOAT a33 = m_a33; + int32_t i; + for (i = 0; i < max; i += 2) { + FX_FLOAT x = (*points)[i]; + FX_FLOAT y = (*points)[i + 1]; + FX_FLOAT denominator = a13 * x + a23 * y + a33; + (*points)[i] = (a11 * x + a21 * y + a31) / denominator; + (*points)[i + 1] = (a12 * x + a22 * y + a32) / denominator; + } +} +CBC_CommonPerspectiveTransform* +CBC_CommonPerspectiveTransform::SquareToQuadrilateral(FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3) { + FX_FLOAT dy2 = y3 - y2; + FX_FLOAT dy3 = y0 - y1 + y2 - y3; + if ((dy2 == 0.0f) && (dy3 == 0.0f)) { + return new CBC_CommonPerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, + y2 - y1, y0, 0.0f, 0.0f, 1.0f); + } else { + FX_FLOAT dx1 = x1 - x2; + FX_FLOAT dx2 = x3 - x2; + FX_FLOAT dx3 = x0 - x1 + x2 - x3; + FX_FLOAT dy1 = y1 - y2; + FX_FLOAT denominator = dx1 * dy2 - dx2 * dy1; + FX_FLOAT a13 = (dx3 * dy2 - dx2 * dy3) / denominator; + FX_FLOAT a23 = (dx1 * dy3 - dx3 * dy1) / denominator; + return new CBC_CommonPerspectiveTransform( + x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, + y3 - y0 + a23 * y3, y0, a13, a23, 1.0f); + } +} +CBC_CommonPerspectiveTransform* +CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3) { + std::unique_ptr<CBC_CommonPerspectiveTransform> temp1( + SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); + return temp1->BuildAdjoint(); +} +CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::BuildAdjoint() { + return new CBC_CommonPerspectiveTransform( + m_a22 * m_a33 - m_a23 * m_a32, m_a23 * m_a31 - m_a21 * m_a33, + m_a21 * m_a32 - m_a22 * m_a31, m_a13 * m_a32 - m_a12 * m_a33, + m_a11 * m_a33 - m_a13 * m_a31, m_a12 * m_a31 - m_a11 * m_a32, + m_a12 * m_a23 - m_a13 * m_a22, m_a13 * m_a21 - m_a11 * m_a23, + m_a11 * m_a22 - m_a12 * m_a21); +} +CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::Times( + CBC_CommonPerspectiveTransform& other) { + return new CBC_CommonPerspectiveTransform( + m_a11 * other.m_a11 + m_a21 * other.m_a12 + m_a31 * other.m_a13, + m_a11 * other.m_a21 + m_a21 * other.m_a22 + m_a31 * other.m_a23, + m_a11 * other.m_a31 + m_a21 * other.m_a32 + m_a31 * other.m_a33, + m_a12 * other.m_a11 + m_a22 * other.m_a12 + m_a32 * other.m_a13, + m_a12 * other.m_a21 + m_a22 * other.m_a22 + m_a32 * other.m_a23, + m_a12 * other.m_a31 + m_a22 * other.m_a32 + m_a32 * other.m_a33, + m_a13 * other.m_a11 + m_a23 * other.m_a12 + m_a33 * other.m_a13, + m_a13 * other.m_a21 + m_a23 * other.m_a22 + m_a33 * other.m_a23, + m_a13 * other.m_a31 + m_a23 * other.m_a32 + m_a33 * other.m_a33); +} diff --git a/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h b/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h new file mode 100644 index 0000000000..36defd8146 --- /dev/null +++ b/xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h @@ -0,0 +1,65 @@ +// 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_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ +#define XFA_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonPerspectiveTransform { + public: + CBC_CommonPerspectiveTransform(FX_FLOAT a11, + FX_FLOAT a21, + FX_FLOAT a31, + FX_FLOAT a12, + FX_FLOAT a22, + FX_FLOAT a32, + FX_FLOAT a13, + FX_FLOAT a23, + FX_FLOAT a33); + virtual ~CBC_CommonPerspectiveTransform(); + static CBC_CommonPerspectiveTransform* QuadrilateralToQuadrilateral( + FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3, + FX_FLOAT x0p, + FX_FLOAT y0p, + FX_FLOAT x1p, + FX_FLOAT y1p, + FX_FLOAT x2p, + FX_FLOAT y2p, + FX_FLOAT x3p, + FX_FLOAT y3p); + static CBC_CommonPerspectiveTransform* SquareToQuadrilateral(FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3); + static CBC_CommonPerspectiveTransform* QuadrilateralToSquare(FX_FLOAT x0, + FX_FLOAT y0, + FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_FLOAT x3, + FX_FLOAT y3); + CBC_CommonPerspectiveTransform* BuildAdjoint(); + CBC_CommonPerspectiveTransform* Times(CBC_CommonPerspectiveTransform& other); + void TransformPoints(CFX_FloatArray* points); + + private: + FX_FLOAT m_a11, m_a12, m_a13, m_a21, m_a22, m_a23, m_a31, m_a32, m_a33; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ diff --git a/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp new file mode 100644 index 0000000000..d4a33229cf --- /dev/null +++ b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp @@ -0,0 +1,173 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h" + +#include <memory> + +#include "xfa/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t LUMINANCE_BITS = 5; +const int32_t LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; +const int32_t LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; + +CBC_GlobalHistogramBinarizer::CBC_GlobalHistogramBinarizer( + CBC_LuminanceSource* source) + : CBC_Binarizer(source) {} +CBC_GlobalHistogramBinarizer::~CBC_GlobalHistogramBinarizer() {} +CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow( + int32_t y, + CBC_CommonBitArray* row, + int32_t& e) { + CBC_LuminanceSource* source = GetLuminanceSource(); + int32_t width = source->GetWidth(); + std::unique_ptr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width)); + InitArrays(width); + CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e); + if (e != BCExceptionNO) { + return result.release(); + } + CFX_Int32Array localBuckets; + localBuckets.Copy(m_buckets); + int32_t x; + for (x = 0; x < width; x++) { + int32_t pixel = (*localLuminances)[x] & 0xff; + localBuckets[pixel >> LUMINANCE_SHIFT]++; + } + int32_t blackPoint = EstimateBlackPoint(localBuckets, e); + if (e != BCExceptionNO) { + return result.release(); + } + int32_t left = (*localLuminances)[0] & 0xff; + int32_t center = (*localLuminances)[1] & 0xff; + for (x = 1; x < width - 1; x++) { + int32_t right = (*localLuminances)[x + 1] & 0xff; + int32_t luminance = ((center << 2) - left - right) >> 1; + if (luminance < blackPoint) { + result->Set(x); + } + left = center; + center = right; + } + return result.release(); +} +CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { + CBC_LuminanceSource* source = GetLuminanceSource(); + int32_t width = source->GetWidth(); + int32_t height = source->GetHeight(); + std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix()); + matrix->Init(width, height); + InitArrays(width); + CFX_Int32Array localBuckets; + localBuckets.Copy(m_buckets); + int32_t y; + for (y = 1; y < 5; y++) { + int32_t row = height * y / 5; + CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t right = (width << 2) / 5; + int32_t x; + for (x = width / 5; x < right; x++) { + int32_t pixel = (*localLuminances)[x] & 0xff; + localBuckets[pixel >> LUMINANCE_SHIFT]++; + } + } + int32_t blackPoint = EstimateBlackPoint(localBuckets, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix()); + for (y = 0; y < height; y++) { + int32_t offset = y * width; + for (int32_t x = 0; x < width; x++) { + int32_t pixel = (*localLuminances)[offset + x] & 0xff; + if (pixel < blackPoint) { + matrix->Set(x, y); + } + } + } + return matrix.release(); +} +void CBC_GlobalHistogramBinarizer::InitArrays(int32_t luminanceSize) { + if (m_luminance.GetSize() < luminanceSize) { + m_luminance.SetSize(luminanceSize); + } + if (m_buckets.GetSize() <= 0) { + m_buckets.SetSize(LUMINANCE_BUCKETS); + } else { + int32_t x; + for (x = 0; x < LUMINANCE_BUCKETS; x++) { + m_buckets[x] = 0; + } + } +} +int32_t CBC_GlobalHistogramBinarizer::EstimateBlackPoint( + CFX_Int32Array& buckets, + int32_t& e) { + int32_t numBuckets = buckets.GetSize(); + int32_t maxBucketCount = 0; + int32_t firstPeak = 0; + int32_t firstPeakSize = 0; + int32_t x; + for (x = 0; x < numBuckets; x++) { + if (buckets[x] > firstPeakSize) { + firstPeak = x; + firstPeakSize = buckets[x]; + } + if (buckets[x] > maxBucketCount) { + maxBucketCount = buckets[x]; + } + } + int32_t secondPeak = 0; + int32_t secondPeakScore = 0; + for (x = 0; x < numBuckets; x++) { + int32_t distanceToBiggest = x - firstPeak; + int32_t score = buckets[x] * distanceToBiggest * distanceToBiggest; + if (score > secondPeakScore) { + secondPeak = x; + secondPeakScore = score; + } + } + if (firstPeak > secondPeak) { + int32_t temp = firstPeak; + firstPeak = secondPeak; + secondPeak = temp; + } + if (secondPeak - firstPeak <= numBuckets >> 4) { + e = BCExceptionRead; + return 0; + } + int32_t bestValley = secondPeak - 1; + int32_t bestValleyScore = -1; + for (x = secondPeak - 1; x > firstPeak; x--) { + int32_t fromFirst = x - firstPeak; + int32_t score = fromFirst * fromFirst * (secondPeak - x) * + (maxBucketCount - buckets[x]); + if (score > bestValleyScore) { + bestValley = x; + bestValleyScore = score; + } + } + return bestValley << LUMINANCE_SHIFT; +} diff --git a/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h new file mode 100644 index 0000000000..da13cac402 --- /dev/null +++ b/xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ +#define XFA_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/BC_Binarizer.h" + +class CBC_CommonBitArray; +class CBC_CommonBitMatrix; +class CBC_LuminanceSource; + +class CBC_GlobalHistogramBinarizer : public CBC_Binarizer { + public: + CBC_GlobalHistogramBinarizer(CBC_LuminanceSource* source); + virtual ~CBC_GlobalHistogramBinarizer(); + + void InitArrays(int32_t luminanceSize); + CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e); + CBC_CommonBitArray* GetBlackRow(int32_t y, + CBC_CommonBitArray* row, + int32_t& e); + static int32_t EstimateBlackPoint(CFX_Int32Array& buckets, int32_t& e); + + private: + CFX_ByteArray m_luminance; + CFX_Int32Array m_buckets; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ diff --git a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp new file mode 100644 index 0000000000..2aeacd1399 --- /dev/null +++ b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp @@ -0,0 +1,254 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_WhiteRectangleDetector.h" + +#include <memory> + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/utils.h" + +CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector( + CBC_CommonBitMatrix* image) { + m_image = image; + m_height = image->GetHeight(); + m_width = image->GetWidth(); + m_leftInit = (m_width - INIT_SIZE) >> 1; + m_rightInit = (m_width + INIT_SIZE) >> 1; + m_upInit = (m_height - INIT_SIZE) >> 1; + m_downInit = (m_height + INIT_SIZE) >> 1; +} +void CBC_WhiteRectangleDetector::Init(int32_t& e) { + if (m_upInit < 0 || m_leftInit < 0 || m_downInit >= m_height || + m_rightInit >= m_width) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector( + CBC_CommonBitMatrix* image, + int32_t initSize, + int32_t x, + int32_t y) { + m_image = image; + m_height = image->GetHeight(); + m_width = image->GetWidth(); + int32_t halfsize = initSize >> 1; + m_leftInit = x - halfsize; + m_rightInit = x + halfsize; + m_upInit = y - halfsize; + m_downInit = y + halfsize; +} +CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector() {} +CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) { + int32_t left = m_leftInit; + int32_t right = m_rightInit; + int32_t up = m_upInit; + int32_t down = m_downInit; + FX_BOOL sizeExceeded = FALSE; + FX_BOOL aBlackPointFoundOnBorder = TRUE; + FX_BOOL atLeastOneBlackPointFoundOnBorder = FALSE; + while (aBlackPointFoundOnBorder) { + aBlackPointFoundOnBorder = FALSE; + FX_BOOL rightBorderNotWhite = TRUE; + while (rightBorderNotWhite && right < m_width) { + rightBorderNotWhite = ContainsBlackPoint(up, down, right, FALSE); + if (rightBorderNotWhite) { + right++; + aBlackPointFoundOnBorder = TRUE; + } + } + if (right >= m_width) { + sizeExceeded = TRUE; + break; + } + FX_BOOL bottomBorderNotWhite = TRUE; + while (bottomBorderNotWhite && down < m_height) { + bottomBorderNotWhite = ContainsBlackPoint(left, right, down, TRUE); + if (bottomBorderNotWhite) { + down++; + aBlackPointFoundOnBorder = TRUE; + } + } + if (down >= m_height) { + sizeExceeded = TRUE; + break; + } + FX_BOOL leftBorderNotWhite = TRUE; + while (leftBorderNotWhite && left >= 0) { + leftBorderNotWhite = ContainsBlackPoint(up, down, left, FALSE); + if (leftBorderNotWhite) { + left--; + aBlackPointFoundOnBorder = TRUE; + } + } + if (left < 0) { + sizeExceeded = TRUE; + break; + } + FX_BOOL topBorderNotWhite = TRUE; + while (topBorderNotWhite && up >= 0) { + topBorderNotWhite = ContainsBlackPoint(left, right, up, TRUE); + if (topBorderNotWhite) { + up--; + aBlackPointFoundOnBorder = TRUE; + } + } + if (up < 0) { + sizeExceeded = TRUE; + break; + } + if (aBlackPointFoundOnBorder) { + atLeastOneBlackPointFoundOnBorder = TRUE; + } + } + if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) { + int32_t maxSize = right - left; + std::unique_ptr<CBC_ResultPoint> z; + for (int32_t i = 1; i < maxSize; i++) { + z.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), + (FX_FLOAT)(left + i), (FX_FLOAT)(down))); + if (z) + break; + } + if (z.get() == NULL) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + std::unique_ptr<CBC_ResultPoint> t; + for (int32_t j = 1; j < maxSize; j++) { + t.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), + (FX_FLOAT)(left + j), (FX_FLOAT)up)); + if (t) + break; + } + if (t.get() == NULL) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + std::unique_ptr<CBC_ResultPoint> x; + for (int32_t k = 1; k < maxSize; k++) { + x.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), + (FX_FLOAT)(right - k), (FX_FLOAT)up)); + if (x) + break; + } + if (x.get() == NULL) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + std::unique_ptr<CBC_ResultPoint> y; + for (int32_t m = 1; m < maxSize; m++) { + y.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), + (FX_FLOAT)(right - m), (FX_FLOAT)down)); + if (y) + break; + } + if (y.get() == NULL) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return CenterEdges(y.get(), z.get(), x.get(), t.get()); + } else { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return NULL; +} +int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d) { + return (int32_t)(d + 0.5f); +} +CBC_ResultPoint* CBC_WhiteRectangleDetector::GetBlackPointOnSegment( + FX_FLOAT aX, + FX_FLOAT aY, + FX_FLOAT bX, + FX_FLOAT bY) { + int32_t dist = DistanceL2(aX, aY, bX, bY); + float xStep = (bX - aX) / dist; + float yStep = (bY - aY) / dist; + for (int32_t i = 0; i < dist; i++) { + int32_t x = Round(aX + i * xStep); + int32_t y = Round(aY + i * yStep); + if (m_image->Get(x, y)) { + return new CBC_ResultPoint((FX_FLOAT)x, (FX_FLOAT)y); + } + } + return NULL; +} +int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX, + FX_FLOAT aY, + FX_FLOAT bX, + FX_FLOAT bY) { + float xDiff = aX - bX; + 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) { + float yi = y->GetX(); + float yj = y->GetY(); + float zi = z->GetX(); + float zj = z->GetY(); + float xi = x->GetX(); + 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; + } +} +FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a, + int32_t b, + int32_t fixed, + FX_BOOL horizontal) { + if (horizontal) { + for (int32_t x = a; x <= b; x++) { + if (m_image->Get(x, fixed)) { + return TRUE; + } + } + } else { + for (int32_t y = a; y <= b; y++) { + if (m_image->Get(fixed, y)) { + return TRUE; + } + } + } + return FALSE; +} diff --git a/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h new file mode 100644 index 0000000000..3d6c01ceff --- /dev/null +++ b/xfa/fxbarcode/common/BC_WhiteRectangleDetector.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_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ +#define XFA_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_ResultPoint; + +class CBC_WhiteRectangleDetector { + public: + CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image); + CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image, + int32_t initSize, + int32_t x, + int32_t y); + virtual ~CBC_WhiteRectangleDetector(); + CFX_PtrArray* Detect(int32_t& e); + virtual void Init(int32_t& e); + + private: + int32_t Round(float d); + CBC_ResultPoint* GetBlackPointOnSegment(FX_FLOAT aX, + FX_FLOAT aY, + 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); + FX_BOOL ContainsBlackPoint(int32_t a, + int32_t b, + int32_t fixed, + FX_BOOL horizontal); + + static const int32_t INIT_SIZE = 30; + static const int32_t CORR = 1; + + CBC_CommonBitMatrix* m_image; + int32_t m_height; + int32_t m_width; + int32_t m_leftInit; + int32_t m_rightInit; + int32_t m_downInit; + int32_t m_upInit; +}; + +#endif // XFA_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp new file mode 100644 index 0000000000..4d986cca26 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -0,0 +1,104 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" + +#include <memory> + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" + +CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) { + m_field = field; +} +void CBC_ReedSolomonEncoder::Init() { + m_cachedGenerators.Add(new CBC_ReedSolomonGF256Poly(m_field, 1)); +} +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]); + for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) { + CFX_Int32Array temp; + temp.Add(1); + temp.Add(m_field->Exp(d - 1)); + CBC_ReedSolomonGF256Poly temp_poly; + temp_poly.Init(m_field, &temp, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_ReedSolomonGF256Poly* nextGenerator = + lastGenerator->Multiply(&temp_poly, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + m_cachedGenerators.Add(nextGenerator); + lastGenerator = nextGenerator; + } + } + return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]); +} +void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode, + int32_t ecBytes, + int32_t& e) { + if (ecBytes == 0) { + e = BCExceptionNoCorrectionBytes; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t dataBytes = toEncode->GetSize() - ecBytes; + if (dataBytes <= 0) { + e = BCExceptionNoDataBytesProvided; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CFX_Int32Array infoCoefficients; + infoCoefficients.SetSize(dataBytes); + for (int32_t x = 0; x < dataBytes; x++) { + infoCoefficients[x] = toEncode->operator[](x); + } + CBC_ReedSolomonGF256Poly info; + info.Init(m_field, &infoCoefficients, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + 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)); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CBC_ReedSolomonGF256Poly* remainder = + (CBC_ReedSolomonGF256Poly*)(temp->operator[](1)); + CFX_Int32Array* coefficients = remainder->GetCoefficients(); + int32_t numZeroCoefficients = ecBytes - coefficients->GetSize(); + for (int32_t i = 0; i < numZeroCoefficients; i++) { + (*toEncode)[dataBytes + i] = 0; + } + for (int32_t y = 0; y < coefficients->GetSize(); y++) { + (*toEncode)[dataBytes + numZeroCoefficients + y] = + coefficients->operator[](y); + } + for (int32_t k = 0; k < temp->GetSize(); k++) { + delete (CBC_ReedSolomonGF256Poly*)(*temp)[k]; + } +} +CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() { + for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) { + delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i]; + } +} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h new file mode 100644 index 0000000000..6f6aef7e7d --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h @@ -0,0 +1,29 @@ +// 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_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ +#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ + +#include "core/include/fxcrt/fx_basic.h" + +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(); +}; + +#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp new file mode 100644 index 0000000000..ff91c9ddc3 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp @@ -0,0 +1,221 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" + +#include <memory> +#include <utility> + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" + +CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) { + m_field = field; +} +CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder() {} +void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, + int32_t twoS, + int32_t& e) { + CBC_ReedSolomonGF256Poly poly; + poly.Init(m_field, received, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CFX_Int32Array syndromeCoefficients; + syndromeCoefficients.SetSize(twoS); + FX_BOOL dataMatrix = FALSE; + FX_BOOL noError = TRUE; + for (int32_t i = 0; i < twoS; i++) { + int32_t eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i)); + syndromeCoefficients[twoS - 1 - i] = eval; + if (eval != 0) { + noError = FALSE; + } + } + if (noError) { + return; + } + CBC_ReedSolomonGF256Poly syndrome; + syndrome.Init(m_field, &syndromeCoefficients, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp( + m_field->BuildMonomial(twoS, 1, e)); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CFX_PtrArray> 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<CFX_Int32Array> errorLocations( + FindErrorLocations(sigma.get(), e)); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CFX_Int32Array> errorMagnitudes( + FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e)); + BC_EXCEPTION_CHECK_ReturnVoid(e); + for (int32_t k = 0; k < errorLocations->GetSize(); k++) { + int32_t position = + received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (position < 0) { + e = BCExceptionBadErrorLocation; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract( + (*received)[position], (*errorMagnitudes)[k]); + } +} +CFX_PtrArray* 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); + std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + while (r->GetDegree() >= R / 2) { + std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast); + std::unique_ptr<CBC_ReedSolomonGF256Poly> tLastlast = std::move(tLast); + rLast = std::move(r); + sLast = std::move(s); + tLast = std::move(t); + if (rLast->IsZero()) { + e = BCExceptionR_I_1IsZero; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + r.reset(rLastLast->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree()); + int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + 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); + q.reset(q->AddOrSubtract(build.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply( + rLast->MultiplyByMonomial(degreeDiff, scale, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + r.reset(r->AddOrSubtract(multiply.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1( + q->Multiply(sLast.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + s.reset(temp1->AddOrSubtract(sLastLast.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5( + q->Multiply(tLast.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + t.reset(temp5->AddOrSubtract(tLastlast.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t sigmaTildeAtZero = t->GetCoefficients(0); + if (sigmaTildeAtZero == 0) { + e = BCExceptionIsZero; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_PtrArray* temp = new CFX_PtrArray; + temp->Add(sigma.release()); + temp->Add(omega.release()); + return temp; +} +CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations( + CBC_ReedSolomonGF256Poly* errorLocator, + int32_t& e) { + int32_t numErrors = errorLocator->GetDegree(); + if (numErrors == 1) { + std::unique_ptr<CFX_Int32Array> temp(new CFX_Int32Array); + temp->Add(errorLocator->GetCoefficients(1)); + return temp.release(); + } + CFX_Int32Array* tempT = new CFX_Int32Array; + tempT->SetSize(numErrors); + std::unique_ptr<CFX_Int32Array> result(tempT); + int32_t ie = 0; + for (int32_t i = 1; i < 256 && ie < numErrors; i++) { + if (errorLocator->EvaluateAt(i) == 0) { + (*result)[ie] = m_field->Inverse(i, ie); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + ie++; + } + } + if (ie != numErrors) { + e = BCExceptionDegreeNotMatchRoots; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return result.release(); +} +CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( + CBC_ReedSolomonGF256Poly* errorEvaluator, + CFX_Int32Array* errorLocations, + FX_BOOL dataMatrix, + int32_t& e) { + int32_t s = errorLocations->GetSize(); + CFX_Int32Array* temp = new CFX_Int32Array; + temp->SetSize(s); + std::unique_ptr<CFX_Int32Array> result(temp); + for (int32_t i = 0; i < s; i++) { + int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t denominator = 1; + for (int32_t j = 0; j < s; j++) { + if (i != j) { + denominator = m_field->Multiply( + denominator, CBC_ReedSolomonGF256::AddOrSubtract( + 1, m_field->Multiply(errorLocations->operator[](j), + xiInverse))); + } + } + int32_t temp = m_field->Inverse(denominator, temp); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + (*result)[i] = + m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp); + } + return result.release(); +} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h new file mode 100644 index 0000000000..ec14344fe0 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h @@ -0,0 +1,35 @@ +// 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_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ +#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +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_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, + int32_t& e); + CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, + CFX_Int32Array* errorLocations, + FX_BOOL dataMatrix, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp new file mode 100644 index 0000000000..5e9fd33ac4 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp @@ -0,0 +1,124 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" + +CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = NULL; +CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = NULL; +void CBC_ReedSolomonGF256::Initialize() { + QRCodeFild = new CBC_ReedSolomonGF256(0x011D); + QRCodeFild->Init(); + DataMatrixField = new CBC_ReedSolomonGF256(0x012D); + DataMatrixField->Init(); +} +void CBC_ReedSolomonGF256::Finalize() { + if (QRCodeFild) { + delete QRCodeFild; + } + QRCodeFild = NULL; + if (DataMatrixField) { + delete DataMatrixField; + } + DataMatrixField = NULL; +} +CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) { + int32_t x = 1; + for (int32_t j = 0; j < 256; j++) { + m_expTable[j] = x; + x <<= 1; + if (x >= 0x100) { + x ^= primitive; + } + } + for (int32_t i = 0; i < 255; i++) { + m_logTable[m_expTable[i]] = i; + } + m_logTable[0] = 0; +} +void CBC_ReedSolomonGF256::Init() { + m_zero = new CBC_ReedSolomonGF256Poly(this, 0); + m_one = new CBC_ReedSolomonGF256Poly(this, 1); +} +CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() { + delete m_zero; + delete m_one; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() { + return m_zero; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() { + return m_one; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( + int32_t degree, + int32_t coefficient, + int32_t& e) { + if (degree < 0) { + e = BCExceptionDegreeIsNegative; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + if (coefficient == 0) { + CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; + } + CFX_Int32Array coefficients; + coefficients.SetSize(degree + 1); + coefficients[0] = coefficient; + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(this, &coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { + return a ^ b; +} +int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { + return m_expTable[a]; +} +int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { + if (a == 0) { + e = BCExceptionAIsZero; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + return m_logTable[a]; +} +int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) { + if (a == 0) { + e = BCExceptionAIsZero; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + return m_expTable[255 - m_logTable[a]]; +} +int32_t CBC_ReedSolomonGF256::Multiply(int32_t a, int32_t b) { + if (a == 0 || b == 0) { + return 0; + } + if (a == 1) { + return b; + } + if (b == 1) { + return a; + } + return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; +} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h new file mode 100644 index 0000000000..099cab57d5 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h @@ -0,0 +1,41 @@ +// 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_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ +#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +class CBC_ReedSolomonGF256Poly; +class CBC_ReedSolomonGF256 { + public: + static void Initialize(); + static void Finalize(); + static CBC_ReedSolomonGF256* QRCodeFild; + static CBC_ReedSolomonGF256* DataMatrixField; + CBC_ReedSolomonGF256(int32_t primitive); + virtual ~CBC_ReedSolomonGF256(); + CBC_ReedSolomonGF256Poly* GetZero(); + CBC_ReedSolomonGF256Poly* GetOne(); + CBC_ReedSolomonGF256Poly* BuildMonomial(int32_t degree, + int32_t coefficient, + int32_t& e); + static int32_t AddOrSubtract(int32_t a, int32_t b); + int32_t Exp(int32_t a); + int32_t Log(int32_t a, int32_t& e); + int32_t Inverse(int32_t a, int32_t& e); + int32_t Multiply(int32_t a, int32_t b); + virtual void Init(); + + private: + int32_t m_expTable[256]; + int32_t m_logTable[256]; + CBC_ReedSolomonGF256Poly* m_zero; + CBC_ReedSolomonGF256Poly* m_one; +}; + +#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp new file mode 100644 index 0000000000..ee22390df6 --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp @@ -0,0 +1,254 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" + +#include <memory> + +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" + +CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, + int32_t coefficients) { + if (field == NULL) { + return; + } + m_field = field; + m_coefficients.Add(coefficients); +} +CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() { + m_field = NULL; +} +void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, + CFX_Int32Array* coefficients, + int32_t& e) { + if (coefficients == NULL || coefficients->GetSize() == 0) { + e = BCExceptionCoefficientsSizeIsNull; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + m_field = field; + int32_t coefficientsLength = coefficients->GetSize(); + if ((coefficientsLength > 1 && (*coefficients)[0] == 0)) { + int32_t firstNonZero = 1; + while ((firstNonZero < coefficientsLength) && + ((*coefficients)[firstNonZero] == 0)) { + firstNonZero++; + } + if (firstNonZero == coefficientsLength) { + m_coefficients.Copy(*(m_field->GetZero()->GetCoefficients())); + } else { + m_coefficients.SetSize(coefficientsLength - firstNonZero); + for (int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) { + m_coefficients[j] = coefficients->operator[](i); + } + } + } else { + m_coefficients.Copy(*coefficients); + } +} +CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() { + return &m_coefficients; +} +int32_t CBC_ReedSolomonGF256Poly::GetDegree() { + return m_coefficients.GetSize() - 1; +} +FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() { + return m_coefficients[0] == 0; +} +int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) { + return m_coefficients[m_coefficients.GetSize() - 1 - degree]; +} +int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) { + if (a == 0) { + return GetCoefficients(0); + } + int32_t size = m_coefficients.GetSize(); + if (a == 1) { + int32_t result = 0; + for (int32_t i = 0; i < size; i++) { + result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[i]); + } + return result; + } + int32_t result = m_coefficients[0]; + for (int32_t j = 1; j < size; j++) { + result = CBC_ReedSolomonGF256::AddOrSubtract(m_field->Multiply(a, result), + m_coefficients[j]); + } + return result; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) { + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(m_field, &m_coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract( + CBC_ReedSolomonGF256Poly* other, + int32_t& e) { + if (IsZero()) { + return other->Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + if (other->IsZero()) { + return Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CFX_Int32Array smallerCoefficients; + smallerCoefficients.Copy(m_coefficients); + CFX_Int32Array largerCoefficients; + largerCoefficients.Copy(*(other->GetCoefficients())); + if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { + CFX_Int32Array temp; + temp.Copy(smallerCoefficients); + smallerCoefficients.Copy(largerCoefficients); + largerCoefficients.Copy(temp); + } + CFX_Int32Array sumDiff; + sumDiff.SetSize(largerCoefficients.GetSize()); + int32_t lengthDiff = + largerCoefficients.GetSize() - smallerCoefficients.GetSize(); + for (int32_t i = 0; i < lengthDiff; i++) { + sumDiff[i] = largerCoefficients[i]; + } + for (int32_t j = lengthDiff; j < largerCoefficients.GetSize(); j++) { + sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract( + smallerCoefficients[j - lengthDiff], largerCoefficients[j])); + } + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(m_field, &sumDiff, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply( + CBC_ReedSolomonGF256Poly* other, + int32_t& e) { + if (IsZero() || other->IsZero()) { + CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; + } + CFX_Int32Array aCoefficients; + aCoefficients.Copy(m_coefficients); + int32_t aLength = m_coefficients.GetSize(); + CFX_Int32Array bCoefficients; + bCoefficients.Copy(*(other->GetCoefficients())); + int32_t bLength = other->GetCoefficients()->GetSize(); + CFX_Int32Array product; + product.SetSize(aLength + bLength - 1); + for (int32_t i = 0; i < aLength; i++) { + int32_t aCoeff = m_coefficients[i]; + for (int32_t j = 0; j < bLength; j++) { + product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract( + product[i + j], + m_field->Multiply(aCoeff, other->GetCoefficients()->operator[](j))); + } + } + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(m_field, &product, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, + int32_t& e) { + if (scalar == 0) { + CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; + } + if (scalar == 1) { + return Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t size = m_coefficients.GetSize(); + CFX_Int32Array product; + product.SetSize(size); + for (int32_t i = 0; i < size; i++) { + product[i] = m_field->Multiply(m_coefficients[i], scalar); + } + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(m_field, &product, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial( + int32_t degree, + int32_t coefficient, + int32_t& e) { + if (degree < 0) { + e = BCExceptionDegreeIsNegative; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + if (coefficient == 0) { + CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; + } + int32_t size = m_coefficients.GetSize(); + CFX_Int32Array product; + product.SetSize(size + degree); + for (int32_t i = 0; i < size; i++) { + product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); + } + CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); + temp->Init(m_field, &product, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, + int32_t& e) { + if (other->IsZero()) { + e = BCExceptionDivideByZero; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( + m_field->GetZero()->Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); + int32_t inverseDenominatorLeadingTeam = + m_field->Inverse(denominatorLeadingTerm, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { + int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); + int32_t scale = + m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), + inverseDenominatorLeadingTeam); + std::unique_ptr<CBC_ReedSolomonGF256Poly> term( + other->MultiplyByMonomial(degreeDifference, scale, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( + m_field->BuildMonomial(degreeDifference, scale, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + remainder.reset(remainder->AddOrSubtract(term.get(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CFX_PtrArray* tempPtrA = new CFX_PtrArray; + tempPtrA->Add(quotient.release()); + tempPtrA->Add(remainder.release()); + return tempPtrA; +} +CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() { + m_coefficients.RemoveAll(); +} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h new file mode 100644 index 0000000000..16a1f9066e --- /dev/null +++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h @@ -0,0 +1,43 @@ +// 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_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ +#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_ReedSolomonGF256; + +class CBC_ReedSolomonGF256Poly { + public: + CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); + CBC_ReedSolomonGF256Poly(); + virtual ~CBC_ReedSolomonGF256Poly(); + int32_t GetCoefficients(int32_t degree); + CFX_Int32Array* GetCoefficients(); + int32_t GetDegree(); + FX_BOOL IsZero(); + int32_t EvaluateAt(int32_t a); + CBC_ReedSolomonGF256Poly* AddOrSubtract(CBC_ReedSolomonGF256Poly* other, + int32_t& e); + CBC_ReedSolomonGF256Poly* Multiply(CBC_ReedSolomonGF256Poly* other, + int32_t& e); + CBC_ReedSolomonGF256Poly* Multiply(int32_t scalar, int32_t& e); + CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree, + int32_t coefficient, + int32_t& e); + CFX_PtrArray* 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; + CFX_Int32Array m_coefficients; +}; + +#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp new file mode 100644 index 0000000000..00d8fc1615 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp @@ -0,0 +1,98 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_ASCIIEncoder::CBC_ASCIIEncoder() {} +CBC_ASCIIEncoder::~CBC_ASCIIEncoder() {} +int32_t CBC_ASCIIEncoder::getEncodingMode() { + return ASCII_ENCODATION; +} +void CBC_ASCIIEncoder::Encode(CBC_EncoderContext& context, int32_t& e) { + int32_t n = CBC_HighLevelEncoder::determineConsecutiveDigitCount( + context.m_msg, context.m_pos); + if (n >= 2) { + FX_WCHAR code = + encodeASCIIDigits(context.m_msg.GetAt(context.m_pos), + context.m_msg.GetAt(context.m_pos + 1), e); + if (e != BCExceptionNO) { + return; + } + context.writeCodeword(code); + context.m_pos += 2; + } else { + FX_WCHAR c = context.getCurrentChar(); + int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( + context.m_msg, context.m_pos, getEncodingMode()); + if (newMode != getEncodingMode()) { + switch (newMode) { + case BASE256_ENCODATION: + context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_BASE256); + context.signalEncoderChange(BASE256_ENCODATION); + return; + case C40_ENCODATION: + context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_C40); + context.signalEncoderChange(C40_ENCODATION); + return; + case X12_ENCODATION: + context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_ANSIX12); + context.signalEncoderChange(X12_ENCODATION); + break; + case TEXT_ENCODATION: + context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_TEXT); + context.signalEncoderChange(TEXT_ENCODATION); + break; + case EDIFACT_ENCODATION: + context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_EDIFACT); + context.signalEncoderChange(EDIFACT_ENCODATION); + break; + default: + e = BCExceptionIllegalStateIllegalMode; + return; + } + } else if (CBC_HighLevelEncoder::isExtendedASCII(c)) { + context.writeCodeword(CBC_HighLevelEncoder::UPPER_SHIFT); + context.writeCodeword((FX_WCHAR)(c - 128 + 1)); + context.m_pos++; + } else { + context.writeCodeword((FX_WCHAR)(c + 1)); + context.m_pos++; + } + } +} +FX_WCHAR CBC_ASCIIEncoder::encodeASCIIDigits(FX_WCHAR digit1, + FX_WCHAR digit2, + int32_t& e) { + if (CBC_HighLevelEncoder::isDigit(digit1) && + CBC_HighLevelEncoder::isDigit(digit2)) { + int32_t num = (digit1 - 48) * 10 + (digit2 - 48); + return (FX_WCHAR)(num + 130); + } + e = BCExceptionIllegalArgumentNotGigits; + return 0; +} diff --git a/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h b/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h new file mode 100644 index 0000000000..11be5e046a --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h @@ -0,0 +1,27 @@ +// 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_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ + +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +class CBC_EncoderContext; + +class CBC_ASCIIEncoder : public CBC_Encoder { + public: + CBC_ASCIIEncoder(); + virtual ~CBC_ASCIIEncoder(); + int32_t getEncodingMode(); + void Encode(CBC_EncoderContext& context, int32_t& e); + + private: + static FX_WCHAR encodeASCIIDigits(FX_WCHAR digit1, + FX_WCHAR digit2, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_Base256Encoder.cpp new file mode 100644 index 0000000000..98e7848ce8 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_Base256Encoder.cpp @@ -0,0 +1,87 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_Base256Encoder::CBC_Base256Encoder() {} +CBC_Base256Encoder::~CBC_Base256Encoder() {} +int32_t CBC_Base256Encoder::getEncodingMode() { + return BASE256_ENCODATION; +} +void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { + CFX_WideString buffer; + buffer += (FX_WCHAR)'\0'; + while (context.hasMoreCharacters()) { + FX_WCHAR c = context.getCurrentChar(); + buffer += c; + context.m_pos++; + int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( + context.m_msg, context.m_pos, getEncodingMode()); + if (newMode != getEncodingMode()) { + context.signalEncoderChange(newMode); + break; + } + } + int32_t dataCount = buffer.GetLength() - 1; + FX_CHAR buf[128]; + FXSYS_itoa(dataCount, buf, 10); + buffer.SetAt(0, FX_WCHAR(*buf) - '0'); + int32_t lengthFieldSize = 1; + int32_t currentSize = + context.getCodewordCount() + dataCount + lengthFieldSize; + context.updateSymbolInfo(currentSize, e); + if (e != BCExceptionNO) { + return; + } + FX_BOOL mustPad = (context.m_symbolInfo->m_dataCapacity - currentSize) > 0; + if (context.hasMoreCharacters() || mustPad) { + if (dataCount <= 249) { + buffer.SetAt(0, (FX_WCHAR)dataCount); + } else if (dataCount > 249 && dataCount <= 1555) { + buffer.SetAt(0, (FX_WCHAR)((dataCount / 250) + 249)); + buffer.Insert(1, (FX_WCHAR)(dataCount % 250)); + } else { + e = BCExceptionIllegalStateMessageLengthInvalid; + return; + } + } + for (int32_t i = 0, c = buffer.GetLength(); i < c; i++) { + context.writeCodeword( + randomize255State(buffer.GetAt(i), context.getCodewordCount() + 1)); + } +} +FX_WCHAR CBC_Base256Encoder::randomize255State(FX_WCHAR ch, + int32_t codewordPosition) { + int32_t pseudoRandom = ((149 * codewordPosition) % 255) + 1; + int32_t tempVariable = ch + pseudoRandom; + if (tempVariable <= 255) { + return (FX_WCHAR)tempVariable; + } else { + return (FX_WCHAR)(tempVariable - 256); + } +} diff --git a/xfa/fxbarcode/datamatrix/BC_Base256Encoder.h b/xfa/fxbarcode/datamatrix/BC_Base256Encoder.h new file mode 100644 index 0000000000..64dbdc7ba4 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_Base256Encoder.h @@ -0,0 +1,23 @@ +// 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_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ + +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +class CBC_Base256Encoder : public CBC_Encoder { + public: + CBC_Base256Encoder(); + virtual ~CBC_Base256Encoder(); + int32_t getEncodingMode(); + void Encode(CBC_EncoderContext& context, int32_t& e); + + private: + static FX_WCHAR randomize255State(FX_WCHAR ch, int32_t codewordPosition); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp new file mode 100644 index 0000000000..8858f60012 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_C40Encoder.cpp @@ -0,0 +1,198 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_C40Encoder::CBC_C40Encoder() {} +CBC_C40Encoder::~CBC_C40Encoder() {} +int32_t CBC_C40Encoder::getEncodingMode() { + return C40_ENCODATION; +} +void CBC_C40Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { + CFX_WideString buffer; + while (context.hasMoreCharacters()) { + FX_WCHAR c = context.getCurrentChar(); + context.m_pos++; + int32_t lastCharSize = encodeChar(c, buffer, e); + if (e != BCExceptionNO) { + return; + } + int32_t unwritten = (buffer.GetLength() / 3) * 2; + int32_t curCodewordCount = context.getCodewordCount() + unwritten; + context.updateSymbolInfo(curCodewordCount, e); + if (e != BCExceptionNO) { + return; + } + int32_t available = context.m_symbolInfo->m_dataCapacity - curCodewordCount; + if (!context.hasMoreCharacters()) { + CFX_WideString removed; + if ((buffer.GetLength() % 3) == 2) { + if (available < 2 || available > 2) { + lastCharSize = + backtrackOneCharacter(context, buffer, removed, lastCharSize, e); + if (e != BCExceptionNO) { + return; + } + } + } + while ((buffer.GetLength() % 3) == 1 && + ((lastCharSize <= 3 && available != 1) || lastCharSize > 3)) { + lastCharSize = + backtrackOneCharacter(context, buffer, removed, lastCharSize, e); + if (e != BCExceptionNO) { + return; + } + } + break; + } + int32_t count = buffer.GetLength(); + if ((count % 3) == 0) { + int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( + context.m_msg, context.m_pos, getEncodingMode()); + if (newMode != getEncodingMode()) { + context.signalEncoderChange(newMode); + break; + } + } + } + handleEOD(context, buffer, e); +} +void CBC_C40Encoder::writeNextTriplet(CBC_EncoderContext& context, + CFX_WideString& buffer) { + context.writeCodewords(encodeToCodewords(buffer, 0)); + buffer.Delete(0, 3); +} +void CBC_C40Encoder::handleEOD(CBC_EncoderContext& context, + CFX_WideString& buffer, + int32_t& e) { + int32_t unwritten = (buffer.GetLength() / 3) * 2; + int32_t rest = buffer.GetLength() % 3; + int32_t curCodewordCount = context.getCodewordCount() + unwritten; + context.updateSymbolInfo(curCodewordCount, e); + if (e != BCExceptionNO) { + return; + } + int32_t available = context.m_symbolInfo->m_dataCapacity - curCodewordCount; + if (rest == 2) { + buffer += (FX_WCHAR)'\0'; + while (buffer.GetLength() >= 3) { + writeNextTriplet(context, buffer); + } + if (context.hasMoreCharacters()) { + context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); + } + } else if (available == 1 && rest == 1) { + while (buffer.GetLength() >= 3) { + writeNextTriplet(context, buffer); + } + if (context.hasMoreCharacters()) { + context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); + } + context.m_pos--; + } else if (rest == 0) { + while (buffer.GetLength() >= 3) { + writeNextTriplet(context, buffer); + } + if (available > 0 || context.hasMoreCharacters()) { + context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); + } + } else { + e = BCExceptionIllegalStateUnexpectedCase; + return; + } + context.signalEncoderChange(ASCII_ENCODATION); +} +int32_t CBC_C40Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { + if (c == ' ') { + sb += (FX_WCHAR)'\3'; + return 1; + } else if ((c >= '0') && (c <= '9')) { + sb += (FX_WCHAR)(c - 48 + 4); + return 1; + } else if ((c >= 'A') && (c <= 'Z')) { + sb += (FX_WCHAR)(c - 65 + 14); + return 1; + } else if (c <= 0x1f) { + sb += (FX_WCHAR)'\0'; + sb += c; + return 2; + } else if ((c >= '!') && (c <= '/')) { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 33); + return 2; + } else if ((c >= ':') && (c <= '@')) { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 58 + 15); + return 2; + } else if ((c >= '[') && (c <= '_')) { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 91 + 22); + return 2; + } else if ((c >= 60) && (c <= 0x7f)) { + sb += (FX_WCHAR)'\2'; + sb += (FX_WCHAR)(c - 96); + return 2; + } else if (c >= 80) { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)0x001e; + int32_t len = 2; + len += encodeChar((c - 128), sb, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + return len; + } else { + e = BCExceptionIllegalArgument; + return 0; + } +} +int32_t CBC_C40Encoder::backtrackOneCharacter(CBC_EncoderContext& context, + CFX_WideString& buffer, + CFX_WideString& removed, + int32_t lastCharSize, + int32_t& e) { + int32_t count = buffer.GetLength(); + buffer.Delete(count - lastCharSize, count); + context.m_pos--; + FX_WCHAR c = context.getCurrentChar(); + lastCharSize = encodeChar(c, removed, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + context.resetSymbolInfo(); + return lastCharSize; +} +CFX_WideString CBC_C40Encoder::encodeToCodewords(CFX_WideString sb, + int32_t startPos) { + FX_WCHAR c1 = sb.GetAt(startPos); + FX_WCHAR c2 = sb.GetAt(startPos + 1); + FX_WCHAR c3 = sb.GetAt(startPos + 2); + int32_t v = (1600 * c1) + (40 * c2) + c3 + 1; + FX_WCHAR cw1 = (FX_WCHAR)(v / 256); + FX_WCHAR cw2 = (FX_WCHAR)(v % 256); + CFX_WideString b1(cw1); + CFX_WideString b2(cw2); + return b1 + b2; +} diff --git a/xfa/fxbarcode/datamatrix/BC_C40Encoder.h b/xfa/fxbarcode/datamatrix/BC_C40Encoder.h new file mode 100644 index 0000000000..9dcb1e5c5f --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_C40Encoder.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ + +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +class CBC_C40Encoder : public CBC_Encoder { + public: + CBC_C40Encoder(); + virtual ~CBC_C40Encoder(); + virtual int32_t getEncodingMode(); + virtual void Encode(CBC_EncoderContext& context, int32_t& e); + static void writeNextTriplet(CBC_EncoderContext& context, + CFX_WideString& buffer); + virtual void handleEOD(CBC_EncoderContext& context, + CFX_WideString& buffer, + int32_t& e); + virtual int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); + + private: + int32_t backtrackOneCharacter(CBC_EncoderContext& context, + CFX_WideString& buffer, + CFX_WideString& removed, + int32_t lastCharSize, + int32_t& e); + static CFX_WideString encodeToCodewords(CFX_WideString sb, int32_t startPos); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp new file mode 100644 index 0000000000..a0c00e9506 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp @@ -0,0 +1,378 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" + +#include <memory> + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" +#include "xfa/fxbarcode/utils.h" + +CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser() { + m_mappingBitMatrix = NULL; + m_version = NULL; + m_readMappingMatrix = NULL; +} +void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, + int32_t& e) { + int32_t dimension = bitMatrix->GetHeight(); + if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { + e = BCExceptionFormatException; + return; + } + m_version = ReadVersion(bitMatrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + m_mappingBitMatrix = ExtractDataRegion(bitMatrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + m_readMappingMatrix = new CBC_CommonBitMatrix(); + m_readMappingMatrix->Init(m_mappingBitMatrix->GetWidth(), + m_mappingBitMatrix->GetHeight()); +} +CBC_DataMatrixBitMatrixParser::~CBC_DataMatrixBitMatrixParser() { + delete m_mappingBitMatrix; + delete m_readMappingMatrix; +} +CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::GetVersion() { + return m_version; +} +CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion( + CBC_CommonBitMatrix* bitMatrix, + int32_t& e) { + int32_t rows = bitMatrix->GetHeight(); + int32_t columns = bitMatrix->GetWidth(); + CBC_DataMatrixVersion* temp = + CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return temp; +} +CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) { + std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray()); + result->SetSize(m_version->GetTotalCodewords()); + int32_t resultOffset = 0; + int32_t row = 4; + int32_t column = 0; + int32_t numRows = m_mappingBitMatrix->GetHeight(); + int32_t numColumns = m_mappingBitMatrix->GetWidth(); + FX_BOOL corner1Read = FALSE; + FX_BOOL corner2Read = FALSE; + FX_BOOL corner3Read = FALSE; + FX_BOOL corner4Read = FALSE; + do { + if ((row == numRows) && (column == 0) && !corner1Read) { + (*result)[resultOffset++] = (uint8_t)ReadCorner1(numRows, numColumns); + row -= 2; + column += 2; + corner1Read = TRUE; + } else if ((row == numRows - 2) && (column == 0) && + ((numColumns & 0x03) != 0) && !corner2Read) { + (*result)[resultOffset++] = (uint8_t)ReadCorner2(numRows, numColumns); + row -= 2; + column += 2; + corner2Read = TRUE; + } else if ((row == numRows + 4) && (column == 2) && + ((numColumns & 0x07) == 0) && !corner3Read) { + (*result)[resultOffset++] = (uint8_t)ReadCorner3(numRows, numColumns); + row -= 2; + column += 2; + corner3Read = TRUE; + } else if ((row == numRows - 2) && (column == 0) && + ((numColumns & 0x07) == 4) && !corner4Read) { + (*result)[resultOffset++] = (uint8_t)ReadCorner4(numRows, numColumns); + row -= 2; + column += 2; + corner4Read = TRUE; + } else { + do { + if ((row < numRows) && (column >= 0) && + !m_readMappingMatrix->Get(column, row)) { + if (resultOffset < (*result).GetSize()) { + (*result)[resultOffset++] = + (uint8_t)ReadUtah(row, column, numRows, numColumns); + } + } + row -= 2; + column += 2; + } while ((row >= 0) && (column < numColumns)); + row += 1; + column += 3; + do { + if ((row >= 0) && (column < numColumns) && + !m_readMappingMatrix->Get(column, row)) { + if (resultOffset < (*result).GetSize()) { + (*result)[resultOffset++] = + (uint8_t)ReadUtah(row, column, numRows, numColumns); + } + } + row += 2; + column -= 2; + } while ((row < numRows) && (column >= 0)); + row += 3; + column += 1; + } + } while ((row < numRows) || (column < numColumns)); + if (resultOffset != m_version->GetTotalCodewords()) { + e = BCExceptionFormatException; + return NULL; + } + return result.release(); +} +FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row, + int32_t column, + int32_t numRows, + int32_t numColumns) { + if (row < 0) { + row += numRows; + column += 4 - ((numRows + 4) & 0x07); + } + if (column < 0) { + column += numColumns; + row += 4 - ((numColumns + 4) & 0x07); + } + m_readMappingMatrix->Set(column, row); + return m_mappingBitMatrix->Get(column, row); +} +int32_t CBC_DataMatrixBitMatrixParser::ReadUtah(int32_t row, + int32_t column, + int32_t numRows, + int32_t numColumns) { + int32_t currentByte = 0; + if (ReadModule(row - 2, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row - 2, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row - 1, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row - 1, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row - 1, column, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(row, column, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; +} +int32_t CBC_DataMatrixBitMatrixParser::ReadCorner1(int32_t numRows, + int32_t numColumns) { + int32_t currentByte = 0; + if (ReadModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 1, 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 1, 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; +} +int32_t CBC_DataMatrixBitMatrixParser::ReadCorner2(int32_t numRows, + int32_t numColumns) { + int32_t currentByte = 0; + if (ReadModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 4, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; +} +int32_t CBC_DataMatrixBitMatrixParser::ReadCorner3(int32_t numRows, + int32_t numColumns) { + int32_t currentByte = 0; + if (ReadModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; +} +int32_t CBC_DataMatrixBitMatrixParser::ReadCorner4(int32_t numRows, + int32_t numColumns) { + int32_t currentByte = 0; + if (ReadModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (ReadModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; +} +CBC_CommonBitMatrix* CBC_DataMatrixBitMatrixParser::ExtractDataRegion( + CBC_CommonBitMatrix* bitMatrix, + int32_t& e) { + int32_t symbolSizeRows = m_version->GetSymbolSizeRows(); + int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns(); + if (bitMatrix->GetHeight() != symbolSizeRows) { + e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; + return NULL; + } + int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows(); + int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns(); + int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; + int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; + int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; + int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; + CBC_CommonBitMatrix* bitMatrixWithoutAlignment = new CBC_CommonBitMatrix(); + bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow); + int32_t dataRegionRow; + for (dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { + int32_t dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; + int32_t dataRegionColumn; + for (dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; + ++dataRegionColumn) { + int32_t dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; + int32_t i; + for (i = 0; i < dataRegionSizeRows; ++i) { + int32_t readRowOffset = + dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; + int32_t writeRowOffset = dataRegionRowOffset + i; + int32_t j; + for (j = 0; j < dataRegionSizeColumns; ++j) { + int32_t readColumnOffset = + dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; + if (bitMatrix->Get(readColumnOffset, readRowOffset)) { + int32_t writeColumnOffset = dataRegionColumnOffset + j; + bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset); + } + } + } + } + } + return bitMatrixWithoutAlignment; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h new file mode 100644 index 0000000000..4c54d61eef --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h @@ -0,0 +1,45 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_DataMatrixVersion; + +class CBC_DataMatrixBitMatrixParser { + public: + CBC_DataMatrixBitMatrixParser(); + virtual ~CBC_DataMatrixBitMatrixParser(); + CBC_DataMatrixVersion* GetVersion(); + CFX_ByteArray* ReadCodewords(int32_t& e); + FX_BOOL ReadModule(int32_t row, + int32_t column, + int32_t numRows, + int32_t numColumns); + int32_t ReadUtah(int32_t row, + int32_t column, + int32_t numRows, + int32_t numColumns); + int32_t ReadCorner1(int32_t numRows, int32_t numColumns); + int32_t ReadCorner2(int32_t numRows, int32_t numColumns); + int32_t ReadCorner3(int32_t numRows, int32_t numColumns); + int32_t ReadCorner4(int32_t numRows, int32_t numColumns); + CBC_CommonBitMatrix* ExtractDataRegion(CBC_CommonBitMatrix* bitMatrix, + int32_t& e); + virtual void Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e); + + private: + static CBC_DataMatrixVersion* ReadVersion(CBC_CommonBitMatrix* bitMatrix, + int32_t& e); + CBC_CommonBitMatrix* m_mappingBitMatrix; + CBC_CommonBitMatrix* m_readMappingMatrix; + CBC_DataMatrixVersion* m_version; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp new file mode 100644 index 0000000000..89c09c22a8 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -0,0 +1,115 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" + +#include <memory> + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" +#include "xfa/fxbarcode/utils.h" + +CBC_DataMatrixDataBlock::~CBC_DataMatrixDataBlock() {} +CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(int32_t numDataCodewords, + CFX_ByteArray* codewords) { + m_codewords.Copy(*codewords); + m_numDataCodewords = numDataCodewords; +} +CFX_PtrArray* 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(); + int32_t i; + for (i = 0; i < ecBlockArray.GetSize(); i++) { + totalBlocks += ((ECB*)ecBlockArray[i])->GetCount(); + } + std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); + result->SetSize(totalBlocks); + int32_t numResultBlocks = 0; + int32_t j; + for (j = 0; j < ecBlockArray.GetSize(); j++) { + for (i = 0; i < ((ECB*)ecBlockArray[j])->GetCount(); i++) { + int32_t numDataCodewords = ((ECB*)ecBlockArray[j])->GetDataCodewords(); + int32_t numBlockCodewords = ecBlocks->GetECCodewords() + numDataCodewords; + CFX_ByteArray codewords; + codewords.SetSize(numBlockCodewords); + (*result)[numResultBlocks++] = + new CBC_DataMatrixDataBlock(numDataCodewords, &codewords); + codewords.SetSize(0); + } + } + int32_t longerBlocksTotalCodewords = + ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize(); + int32_t longerBlocksNumDataCodewords = + longerBlocksTotalCodewords - ecBlocks->GetECCodewords(); + int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; + int32_t rawCodewordsOffset = 0; + for (i = 0; i < shorterBlocksNumDataCodewords; i++) { + int32_t j; + for (j = 0; j < numResultBlocks; j++) { + if (rawCodewordsOffset < rawCodewords->GetSize()) { + ((CBC_DataMatrixDataBlock*)(*result)[j]) + ->GetCodewords() + -> + operator[](i) = (*rawCodewords)[rawCodewordsOffset++]; + } + } + } + const bool specialVersion = version->GetVersionNumber() == 24; + int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks; + for (j = 0; j < numLongerBlocks; j++) { + if (rawCodewordsOffset < rawCodewords->GetSize()) { + ((CBC_DataMatrixDataBlock*)(*result)[j]) + ->GetCodewords() + -> + operator[](longerBlocksNumDataCodewords - 1) = + (*rawCodewords)[rawCodewordsOffset++]; + } + } + int32_t max = + ((CBC_DataMatrixDataBlock*)(*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++]; + } + } + } + if (rawCodewordsOffset != rawCodewords->GetSize()) { + e = BCExceptionIllegalArgument; + return NULL; + } + return result.release(); +} +int32_t CBC_DataMatrixDataBlock::GetNumDataCodewords() { + return m_numDataCodewords; +} +CFX_ByteArray* CBC_DataMatrixDataBlock::GetCodewords() { + return &m_codewords; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h new file mode 100644 index 0000000000..218bb0bb49 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h @@ -0,0 +1,32 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_DataMatrixVersion; + +class CBC_DataMatrixDataBlock { + public: + virtual ~CBC_DataMatrixDataBlock(); + + int32_t GetNumDataCodewords(); + CFX_ByteArray* GetCodewords(); + + static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords, + CBC_DataMatrixVersion* version, + int32_t& e); + + private: + 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/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp new file mode 100644 index 0000000000..693b6b9209 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp @@ -0,0 +1,473 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitSource.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" + +const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::C40_BASIC_SET_CHARS[] = { + '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '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::C40_SHIFT2_SET_CHARS[] = { + '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', + '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_'}; +const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { + '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '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}; +const int32_t CBC_DataMatrixDecodedBitStreamParser::PAD_ENCODE = 0; +const int32_t CBC_DataMatrixDecodedBitStreamParser::ASCII_ENCODE = 1; +const int32_t CBC_DataMatrixDecodedBitStreamParser::C40_ENCODE = 2; +const int32_t CBC_DataMatrixDecodedBitStreamParser::TEXT_ENCODE = 3; +const int32_t CBC_DataMatrixDecodedBitStreamParser::ANSIX12_ENCODE = 4; +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) { + CBC_CommonBitSource bits(&bytes); + CFX_ByteString result; + CFX_ByteString resultTrailer; + CFX_Int32Array byteSegments; + int32_t mode = ASCII_ENCODE; + do { + if (mode == 1) { + mode = DecodeAsciiSegment(&bits, result, resultTrailer, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else { + switch (mode) { + case 2: + DecodeC40Segment(&bits, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + case 3: + DecodeTextSegment(&bits, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + case 4: + DecodeAnsiX12Segment(&bits, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + case 5: + DecodeEdifactSegment(&bits, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + case 6: + DecodeBase256Segment(&bits, result, byteSegments, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + default: + e = BCExceptionFormatException; + return NULL; + } + mode = ASCII_ENCODE; + } + } while (mode != PAD_ENCODE && bits.Available() > 0); + if (resultTrailer.GetLength() > 0) { + 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); + return tempCp; +} +int32_t CBC_DataMatrixDecodedBitStreamParser::DecodeAsciiSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + CFX_ByteString& resultTrailer, + int32_t& e) { + FX_CHAR buffer[128]; + FX_BOOL upperShift = FALSE; + do { + int32_t oneByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + if (oneByte == 0) { + e = BCExceptionFormatException; + return 0; + } else if (oneByte <= 128) { + oneByte = upperShift ? oneByte + 128 : oneByte; + upperShift = FALSE; + result += ((FX_CHAR)(oneByte - 1)); + return ASCII_ENCODE; + } else if (oneByte == 129) { + return PAD_ENCODE; + } else if (oneByte <= 229) { + int32_t value = oneByte - 130; + FXSYS_itoa(value, buffer, 10); + if (value < 10) { + result += '0'; + buffer[1] = '\0'; + } else { + buffer[2] = '\0'; + } + result += buffer; + } else if (oneByte == 230) { + return C40_ENCODE; + } else if (oneByte == 231) { + return BASE256_ENCODE; + } else if (oneByte == 232 || oneByte == 233 || oneByte == 234) { + } else if (oneByte == 235) { + upperShift = TRUE; + } else if (oneByte == 236) { + result += "[)>"; + result += 0x1E; + result += "05"; + result += 0x1D; + resultTrailer.Insert(0, 0x1E); + resultTrailer.Insert(0 + 1, 0x04); + } else if (oneByte == 237) { + result += "[)>"; + result += 0x1E; + result += "06"; + result += 0x1D; + resultTrailer.Insert(0, 0x1E); + resultTrailer.Insert(0 + 1, 0x04); + } else if (oneByte == 238) { + return ANSIX12_ENCODE; + } else if (oneByte == 239) { + return TEXT_ENCODE; + } else if (oneByte == 240) { + return EDIFACT_ENCODE; + } else if (oneByte == 241) { + } else if (oneByte >= 242) { + if (oneByte == 254 && bits->Available() == 0) { + } else { + e = BCExceptionFormatException; + return 0; + } + } + } while (bits->Available() > 0); + return ASCII_ENCODE; +} +void CBC_DataMatrixDecodedBitStreamParser::DecodeC40Segment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e) { + FX_BOOL upperShift = FALSE; + CFX_Int32Array cValues; + cValues.SetSize(3); + do { + if (bits->Available() == 8) { + return; + } + int32_t firstByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (firstByte == 254) { + return; + } + int32_t tempp = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + ParseTwoBytes(firstByte, tempp, cValues); + int32_t shift = 0; + int32_t i; + for (i = 0; i < 3; i++) { + int32_t cValue = cValues[i]; + switch (shift) { + case 0: + if (cValue < 3) { + shift = cValue + 1; + } else if (cValue < 27) { + FX_CHAR c40char = C40_BASIC_SET_CHARS[cValue]; + if (upperShift) { + result += (FX_CHAR)(c40char + 128); + upperShift = FALSE; + } else { + result += c40char; + } + } else { + e = BCExceptionFormatException; + return; + } + break; + case 1: + if (upperShift) { + result += (FX_CHAR)(cValue + 128); + upperShift = FALSE; + } else { + result += cValue; + } + shift = 0; + break; + case 2: + if (cValue < 27) { + FX_CHAR c40char = C40_SHIFT2_SET_CHARS[cValue]; + if (upperShift) { + result += (FX_CHAR)(c40char + 128); + upperShift = FALSE; + } else { + result += c40char; + } + } else if (cValue == 27) { + e = BCExceptionFormatException; + return; + } else if (cValue == 30) { + upperShift = TRUE; + } else { + e = BCExceptionFormatException; + return; + } + shift = 0; + break; + case 3: + if (upperShift) { + result += (FX_CHAR)(cValue + 224); + upperShift = FALSE; + } else { + result += (FX_CHAR)(cValue + 96); + } + shift = 0; + break; + default: + break; + e = BCExceptionFormatException; + return; + } + } + } while (bits->Available() > 0); +} +void CBC_DataMatrixDecodedBitStreamParser::DecodeTextSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e) { + FX_BOOL upperShift = FALSE; + CFX_Int32Array cValues; + cValues.SetSize(3); + int32_t shift = 0; + do { + if (bits->Available() == 8) { + return; + } + int32_t firstByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (firstByte == 254) { + return; + } + int32_t inTp = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + ParseTwoBytes(firstByte, inTp, cValues); + for (int32_t i = 0; i < 3; i++) { + int32_t cValue = cValues[i]; + switch (shift) { + case 0: + if (cValue < 3) { + shift = cValue + 1; + } else if (cValue < 40) { + FX_CHAR textChar = TEXT_BASIC_SET_CHARS[cValue]; + if (upperShift) { + result += (FX_CHAR)(textChar + 128); + upperShift = FALSE; + } else { + result += textChar; + } + } else { + e = BCExceptionFormatException; + return; + } + break; + case 1: + if (upperShift) { + result += (FX_CHAR)(cValue + 128); + upperShift = FALSE; + } else { + result += cValue; + } + shift = 0; + break; + case 2: + if (cValue < 27) { + FX_CHAR c40char = C40_SHIFT2_SET_CHARS[cValue]; + if (upperShift) { + result += (FX_CHAR)(c40char + 128); + upperShift = FALSE; + } else { + result += c40char; + } + } else if (cValue == 27) { + e = BCExceptionFormatException; + return; + } else if (cValue == 30) { + upperShift = TRUE; + } else { + e = BCExceptionFormatException; + return; + } + shift = 0; + break; + case 3: + if (cValue < 19) { + FX_CHAR textChar = TEXT_SHIFT3_SET_CHARS[cValue]; + if (upperShift) { + result += (FX_CHAR)(textChar + 128); + upperShift = FALSE; + } else { + result += textChar; + } + shift = 0; + } else { + e = BCExceptionFormatException; + return; + } + break; + default: + break; + e = BCExceptionFormatException; + return; + } + } + } while (bits->Available() > 0); +} +void CBC_DataMatrixDecodedBitStreamParser::DecodeAnsiX12Segment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e) { + CFX_Int32Array cValues; + cValues.SetSize(3); + do { + if (bits->Available() == 8) { + return; + } + int32_t firstByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (firstByte == 254) { + return; + } + int32_t iTemp1 = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + ParseTwoBytes(firstByte, iTemp1, cValues); + int32_t i; + for (i = 0; i < 3; i++) { + int32_t cValue = cValues[i]; + if (cValue == 0) { + BC_FX_ByteString_Append(result, 1, '\r'); + } else if (cValue == 1) { + BC_FX_ByteString_Append(result, 1, '*'); + } else if (cValue == 2) { + BC_FX_ByteString_Append(result, 1, '>'); + } else if (cValue == 3) { + BC_FX_ByteString_Append(result, 1, ' '); + } else if (cValue < 14) { + BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 44)); + } else if (cValue < 40) { + BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 51)); + } else { + e = BCExceptionFormatException; + return; + } + } + } while (bits->Available() > 0); +} +void CBC_DataMatrixDecodedBitStreamParser::ParseTwoBytes( + int32_t firstByte, + int32_t secondByte, + CFX_Int32Array& result) { + int32_t fullBitValue = (firstByte << 8) + secondByte - 1; + int32_t temp = fullBitValue / 1600; + result[0] = temp; + fullBitValue -= temp * 1600; + temp = fullBitValue / 40; + result[1] = temp; + result[2] = fullBitValue - temp * 40; +} + +void CBC_DataMatrixDecodedBitStreamParser::DecodeEdifactSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e) { + FX_CHAR buffer[128]; + FX_BOOL unlatch = FALSE; + do { + if (bits->Available() <= 16) + return; + + for (int32_t i = 0; i < 4; i++) { + int32_t edifactValue = bits->ReadBits(6, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (edifactValue == 0x1F) + unlatch = TRUE; + + if (!unlatch) { + if ((edifactValue & 32) == 0) + edifactValue |= 64; + result += FXSYS_itoa(edifactValue, buffer, 10); + } + } + } while (!unlatch && bits->Available() > 0); +} + +void CBC_DataMatrixDecodedBitStreamParser::DecodeBase256Segment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + CFX_Int32Array& byteSegments, + int32_t& e) { + int32_t codewordPosition = 1 + bits->getByteOffset(); + int32_t iTmp = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t d1 = Unrandomize255State(iTmp, codewordPosition++); + int32_t count; + if (d1 == 0) { + count = bits->Available() / 8; + } else if (d1 < 250) { + count = d1; + } else { + int32_t iTmp3 = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + count = 250 * (d1 - 249) + Unrandomize255State(iTmp3, codewordPosition++); + } + if (count < 0) { + e = BCExceptionFormatException; + return; + } + CFX_ByteArray* bytes = new CFX_ByteArray(); + bytes->SetSize(count); + int32_t i; + for (i = 0; i < count; i++) { + if (bits->Available() < 8) { + e = BCExceptionFormatException; + delete bytes; + return; + } + int32_t iTemp5 = bits->ReadBits(8, e); + if (e != BCExceptionNO) { + delete bytes; + return; + } + bytes->SetAt(i, Unrandomize255State(iTemp5, codewordPosition++)); + } + BC_FX_ByteString_Append(result, *bytes); + delete bytes; +} +uint8_t CBC_DataMatrixDecodedBitStreamParser::Unrandomize255State( + int32_t randomizedBase256Codeword, + int32_t base256CodewordPosition) { + int32_t pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; + int32_t tempVariable = randomizedBase256Codeword - pseudoRandomNumber; + return (uint8_t)(tempVariable >= 0 ? tempVariable : tempVariable + 256); +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h new file mode 100644 index 0000000000..415e27b166 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h @@ -0,0 +1,58 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ +class CBC_CommonDecoderResult; +class CBC_CommonBitSource; +class CBC_DataMatrixDecodedBitStreamParser { + public: + CBC_DataMatrixDecodedBitStreamParser(); + virtual ~CBC_DataMatrixDecodedBitStreamParser(); + static CBC_CommonDecoderResult* Decode(CFX_ByteArray& bytes, int32_t& e); + + private: + static int32_t DecodeAsciiSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + CFX_ByteString& resultTrailer, + int32_t& e); + static void DecodeC40Segment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e); + static void DecodeTextSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e); + static void DecodeAnsiX12Segment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e); + static void ParseTwoBytes(int32_t firstByte, + int32_t secondByte, + CFX_Int32Array& result); + static void DecodeEdifactSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t& e); + static void DecodeBase256Segment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + CFX_Int32Array& byteSegments, + int32_t& e); + static uint8_t Unrandomize255State(int32_t randomizedBase256Codeword, + int32_t base256CodewordPosition); + + static const FX_CHAR C40_BASIC_SET_CHARS[]; + static const FX_CHAR C40_SHIFT2_SET_CHARS[]; + + static const FX_CHAR TEXT_BASIC_SET_CHARS[]; + static const FX_CHAR TEXT_SHIFT3_SET_CHARS[]; + static const int32_t PAD_ENCODE; + static const int32_t ASCII_ENCODE; + static const int32_t C40_ENCODE; + static const int32_t TEXT_ENCODE; + static const int32_t ANSIX12_ENCODE; + static const int32_t EDIFACT_ENCODE; + static const int32_t BASE256_ENCODE; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp new file mode 100644 index 0000000000..3f765aa8f9 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -0,0 +1,114 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" + +#include <memory> + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" + +CBC_DataMatrixDecoder::CBC_DataMatrixDecoder() { + m_rsDecoder = NULL; +} +void CBC_DataMatrixDecoder::Init() { + m_rsDecoder = + new CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::DataMatrixField); +} +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); + CBC_DataMatrixVersion* version = parser.GetVersion(); + std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_PtrArray* dataBlocks = + CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + 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(); + } + 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(); + CorrectErrors(*codewordBytes, numDataCodewords, e); + if (e != BCExceptionNO) { + for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { + delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + } + delete dataBlocks; + dataBlocks = NULL; + return NULL; + } + int32_t i; + for (i = 0; i < numDataCodewords; i++) { + resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i]; + } + } + for (i = 0; i < (dataBlocks->GetSize()); i++) { + delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; + } + delete dataBlocks; + dataBlocks = NULL; + CBC_CommonDecoderResult* resultR = + CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return resultR; +} +void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes, + int32_t numDataCodewords, + int32_t& e) { + int32_t numCodewords = codewordBytes.GetSize(); + CFX_Int32Array codewordsInts; + codewordsInts.SetSize(numCodewords); + int32_t i; + for (i = 0; i < numCodewords; i++) { + codewordsInts[i] = codewordBytes[i] & 0xFF; + } + int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords; + m_rsDecoder->Decode(&codewordsInts, numECCodewords, e); + if (e != BCExceptionNO) { + e = BCExceptionChecksumException; + return; + } + for (i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = (uint8_t)codewordsInts[i]; + } +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h new file mode 100644 index 0000000000..2f70282d01 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h @@ -0,0 +1,30 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_ReedSolomonDecoder; +class CBC_CommonDecoderResult; +class CBC_CommonBitMatrix; + +class CBC_DataMatrixDecoder { + public: + CBC_DataMatrixDecoder(); + virtual ~CBC_DataMatrixDecoder(); + CBC_CommonDecoderResult* Decode(CBC_CommonBitMatrix* bits, int32_t& e); + virtual void Init(); + + private: + void CorrectErrors(CFX_ByteArray& codewordBytes, + int32_t numDataCodewords, + int32_t& e); + CBC_ReedSolomonDecoder* m_rsDecoder; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp new file mode 100644 index 0000000000..fd410097cc --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp @@ -0,0 +1,406 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h" + +#include <algorithm> +#include <memory> + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_WhiteRectangleDetector.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h" +#include "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" +#include "xfa/fxbarcode/qrcode/BC_QRGridSampler.h" +#include "xfa/fxbarcode/utils.h" + +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) {} +void CBC_DataMatrixDetector::Init(int32_t& e) { + m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); + m_rectangleDetector->Init(e); + BC_EXCEPTION_CHECK_ReturnVoid(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]; + delete cornerPoints; + cornerPoints = NULL; + CFX_PtrArray 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]; + 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]); + transitions.RemoveAll(); + CBC_ResultPoint* maybeTopLeft = NULL; + CBC_ResultPoint* bottomLeft = NULL; + CBC_ResultPoint* maybeBottomRight = NULL; + FX_POSITION itBegin = pointCount.GetStartPosition(); + while (itBegin) { + CBC_ResultPoint* key = 0; + int32_t value = 0; + pointCount.GetNextAssoc(itBegin, key, value); + if (value == 2) { + bottomLeft = key; + } else { + if (maybeBottomRight == NULL) { + maybeBottomRight = key; + } else { + maybeTopLeft = key; + } + } + } + if (maybeTopLeft == NULL || bottomLeft == NULL || maybeBottomRight == NULL) { + delete pointA; + delete pointB; + delete pointC; + delete pointD; + e = BCExceptionNotFound; + return NULL; + } + CFX_PtrArray 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; + int32_t value; + if (!pointCount.Lookup(pointA, value)) { + topRight = pointA; + } else if (!pointCount.Lookup(pointB, value)) { + topRight = pointB; + } else if (!pointCount.Lookup(pointC, value)) { + topRight = pointC; + } else { + topRight = pointD; + } + int32_t dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, topRight)) + ->GetTransitions(); + int32_t dimensionRight = std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, topRight)) + ->GetTransitions(); + if ((dimensionTop & 0x01) == 1) { + dimensionTop++; + } + dimensionTop += 2; + if ((dimensionRight & 0x01) == 1) { + dimensionRight++; + } + dimensionRight += 2; + std::unique_ptr<CBC_CommonBitMatrix> bits; + std::unique_ptr<CBC_ResultPoint> correctedTopRight; + if (4 * dimensionTop >= 7 * dimensionRight || + 4 * dimensionRight >= 7 * dimensionTop) { + correctedTopRight.reset( + CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, + dimensionTop, dimensionRight)); + if (correctedTopRight.get() == NULL) { + correctedTopRight.reset(topRight); + } else { + delete topRight; + topRight = NULL; + } + dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, correctedTopRight.get())) + ->GetTransitions(); + dimensionRight = + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, correctedTopRight.get())) + ->GetTransitions(); + if ((dimensionTop & 0x01) == 1) { + dimensionTop++; + } + if ((dimensionRight & 0x01) == 1) { + dimensionRight++; + } + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionTop, dimensionRight, + e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else { + int32_t dimension = std::min(dimensionRight, dimensionTop); + correctedTopRight.reset( + CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); + if (correctedTopRight.get() == NULL) { + correctedTopRight.reset(topRight); + } else { + delete topRight; + topRight = NULL; + } + int32_t dimensionCorrected = + std::max(std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, correctedTopRight.get())) + ->GetTransitions(), + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, correctedTopRight.get())) + ->GetTransitions()); + dimensionCorrected++; + if ((dimensionCorrected & 0x01) == 1) { + dimensionCorrected++; + } + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionCorrected, + dimensionCorrected, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CFX_PtrArray* result = new CFX_PtrArray; + result->SetSize(4); + result->Add(topLeft); + result->Add(bottomLeft); + result->Add(bottomRight); + result->Add(correctedTopRight.release()); + return new CBC_QRDetectorResult(bits.release(), result); +} +CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + int32_t dimensionTop, + int32_t dimensionRight) { + FX_FLOAT corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimensionTop; + int32_t norm = Distance(topLeft, topRight); + FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; + FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; + std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( + topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); + corr = Distance(bottomLeft, topLeft) / (FX_FLOAT)dimensionRight; + norm = Distance(bottomRight, topRight); + cos = (topRight->GetX() - bottomRight->GetX()) / norm; + sin = (topRight->GetY() - bottomRight->GetY()) / norm; + std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( + topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); + if (!IsValid(c1.get())) { + if (IsValid(c2.get())) { + return c2.release(); + } + return NULL; + } else if (!IsValid(c2.get())) { + return c1.release(); + } + int32_t l1 = FXSYS_abs(dimensionTop - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, c1.get())) + ->GetTransitions()) + + FXSYS_abs(dimensionRight - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, c1.get())) + ->GetTransitions()); + int32_t l2 = FXSYS_abs(dimensionTop - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, c2.get())) + ->GetTransitions()) + + FXSYS_abs(dimensionRight - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, c2.get())) + ->GetTransitions()); + if (l1 <= l2) { + return c1.release(); + } + return c2.release(); +} +CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + int32_t dimension) { + FX_FLOAT corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; + int32_t norm = Distance(topLeft, topRight); + FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; + FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; + std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( + topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); + corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; + norm = Distance(bottomRight, topRight); + cos = (topRight->GetX() - bottomRight->GetX()) / norm; + sin = (topRight->GetY() - bottomRight->GetY()) / norm; + std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( + topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); + if (!IsValid(c1.get())) { + if (IsValid(c2.get())) { + return c2.release(); + } + return NULL; + } else if (!IsValid(c2.get())) { + return c1.release(); + } + int32_t l1 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, c1.get())) + ->GetTransitions() - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, c1.get())) + ->GetTransitions()); + int32_t l2 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(topLeft, c2.get())) + ->GetTransitions() - + std::unique_ptr<CBC_ResultPointsAndTransitions>( + TransitionsBetween(bottomRight, c2.get())) + ->GetTransitions()); + return l1 <= l2 ? c1.release() : c2.release(); +} +FX_BOOL CBC_DataMatrixDetector::IsValid(CBC_ResultPoint* p) { + return p->GetX() >= 0 && p->GetX() < m_image->GetWidth() && p->GetY() > 0 && + p->GetY() < m_image->GetHeight(); +} +int32_t CBC_DataMatrixDetector::Round(FX_FLOAT d) { + return (int32_t)(d + 0.5f); +} +int32_t CBC_DataMatrixDetector::Distance(CBC_ResultPoint* a, + CBC_ResultPoint* b) { + return Round( + (FX_FLOAT)sqrt((a->GetX() - b->GetX()) * (a->GetX() - b->GetX()) + + (a->GetY() - b->GetY()) * (a->GetY() - b->GetY()))); +} +void CBC_DataMatrixDetector::Increment( + CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table, + CBC_ResultPoint* key) { + int32_t value; + if (table.Lookup(key, value)) { + table.SetAt(key, INTEGERS[value + 1]); + } else { + table.SetAt(key, INTEGERS[1]); + } +} +CBC_CommonBitMatrix* CBC_DataMatrixDetector::SampleGrid( + CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topRight, + int32_t dimensionX, + int32_t dimensionY, + int32_t& e) { + CBC_QRGridSampler& sampler = CBC_QRGridSampler::GetInstance(); + CBC_CommonBitMatrix* cbm = sampler.SampleGrid( + image, dimensionX, dimensionY, 0.5f, 0.5f, dimensionX - 0.5f, 0.5f, + dimensionX - 0.5f, dimensionY - 0.5f, 0.5f, dimensionY - 0.5f, + topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(), + bottomRight->GetX(), bottomRight->GetY(), bottomLeft->GetX(), + bottomLeft->GetY(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return cbm; +} +CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween( + CBC_ResultPoint* from, + CBC_ResultPoint* to) { + int32_t fromX = (int32_t)from->GetX(); + int32_t fromY = (int32_t)from->GetY(); + int32_t toX = (int32_t)to->GetX(); + int32_t toY = (int32_t)to->GetY(); + FX_BOOL steep = FXSYS_abs(toY - fromY) > FXSYS_abs(toX - fromX); + if (steep) { + int32_t temp = fromX; + fromX = fromY; + fromY = temp; + temp = toX; + toX = toY; + toY = temp; + } + int32_t dx = FXSYS_abs(toX - fromX); + int32_t dy = FXSYS_abs(toY - fromY); + int32_t error = -dx >> 1; + int32_t ystep = fromY < toY ? 1 : -1; + int32_t xstep = fromX < toX ? 1 : -1; + int32_t transitions = 0; + FX_BOOL inBlack = m_image->Get(steep ? fromY : fromX, steep ? fromX : fromY); + for (int32_t x = fromX, y = fromY; x != toX; x += xstep) { + FX_BOOL isBlack = m_image->Get(steep ? y : x, steep ? x : y); + if (isBlack != inBlack) { + transitions++; + inBlack = isBlack; + } + error += dy; + if (error > 0) { + if (y == toY) { + break; + } + y += ystep; + error -= dx; + } + } + 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]); + 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]; + } else if (acDistance >= bcDistance && acDistance >= abDistance) { + topLeft = (CBC_ResultPoint*)(*patterns)[1]; + topRight = (CBC_ResultPoint*)(*patterns)[0]; + bottomLeft = (CBC_ResultPoint*)(*patterns)[2]; + } else { + topLeft = (CBC_ResultPoint*)(*patterns)[2]; + topRight = (CBC_ResultPoint*)(*patterns)[0]; + bottomLeft = (CBC_ResultPoint*)(*patterns)[1]; + } + if ((bottomLeft->GetY() - topLeft->GetY()) * + (topRight->GetX() - topLeft->GetX()) < + (bottomLeft->GetX() - topLeft->GetX()) * + (topRight->GetY() - topLeft->GetY())) { + CBC_ResultPoint* temp = topRight; + topRight = bottomLeft; + bottomLeft = temp; + } + (*patterns)[0] = bottomLeft; + (*patterns)[1] = topLeft; + (*patterns)[2] = topRight; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h new file mode 100644 index 0000000000..62d1699c0a --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_WhiteRectangleDetector; +class CBC_ResultPoint; +class CBC_QRDetectorResult; +class CBC_DataMatrixDetector; +class ResultPointsAndTransitions; +class CBC_ResultPointsAndTransitions { + public: + CBC_ResultPointsAndTransitions(CBC_ResultPoint* from, + CBC_ResultPoint* to, + int32_t transitions) { + m_from = from; + m_to = to; + m_transitions = transitions; + } + ~CBC_ResultPointsAndTransitions() {} + CBC_ResultPoint* GetFrom() { return m_from; } + CBC_ResultPoint* GetTo() { return m_to; } + int32_t GetTransitions() { 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); + virtual ~CBC_DataMatrixDetector(); + CBC_QRDetectorResult* Detect(int32_t& e); + CBC_ResultPoint* CorrectTopRightRectangular(CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + int32_t dimensionTop, + int32_t dimensionRight); + CBC_ResultPoint* CorrectTopRight(CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + int32_t dimension); + CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* bottomRight, + CBC_ResultPoint* topRight, + int32_t dimensionX, + int32_t dimensionY, + int32_t& e); + CBC_ResultPointsAndTransitions* TransitionsBetween(CBC_ResultPoint* from, + CBC_ResultPoint* to); + FX_BOOL IsValid(CBC_ResultPoint* p); + int32_t Distance(CBC_ResultPoint* a, CBC_ResultPoint* b); + void Increment(CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table, + CBC_ResultPoint* key); + int32_t Round(FX_FLOAT d); + void OrderBestPatterns(CFX_PtrArray* patterns); + virtual void Init(int32_t& e); + + private: + static const int32_t INTEGERS[5]; + + CBC_CommonBitMatrix* m_image; + CBC_WhiteRectangleDetector* m_rectangleDetector; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.cpp new file mode 100644 index 0000000000..9a22d4db3a --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.cpp @@ -0,0 +1,65 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h" + +#include <memory> + +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h" +#include "xfa/fxbarcode/utils.h" + +CBC_DataMatrixReader::CBC_DataMatrixReader() { + m_decoder = NULL; +} +void CBC_DataMatrixReader::Init() { + m_decoder = new CBC_DataMatrixDecoder; + m_decoder->Init(); +} +CBC_DataMatrixReader::~CBC_DataMatrixReader() { + delete m_decoder; +} +CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + CBC_CommonBitMatrix* cdr = image->GetBlackMatrix(e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CBC_DataMatrixDetector detector(cdr); + detector.Init(e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + std::unique_ptr<CBC_QRDetectorResult> detectorResult(detector.Detect(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + std::unique_ptr<CBC_CommonDecoderResult> decodeResult( + m_decoder->Decode(detectorResult->GetBits(), e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return decodeResult->GetText(); +} +CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, + int32_t& e) { + CFX_ByteString bs = Decode(image, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return bs; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h new file mode 100644 index 0000000000..21fc54eeb5 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixReader.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ + +#include "xfa/fxbarcode/BC_Reader.h" + +class CBC_BinaryBitmap; +class CBC_DataMatrixDecoder; + +class CBC_DataMatrixReader : public CBC_Reader { + public: + CBC_DataMatrixReader(); + virtual ~CBC_DataMatrixReader(); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int hints, int32_t& e); + + virtual void Init(); + + private: + CBC_DataMatrixDecoder* m_decoder; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp new file mode 100644 index 0000000000..16c253f062 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp @@ -0,0 +1,40 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_DataMatrixSymbolInfo144::CBC_DataMatrixSymbolInfo144() + : CBC_SymbolInfo(FALSE, 1558, 620, 22, 22, 36) { + m_rsBlockData = -1; + m_rsBlockError = 62; +} +CBC_DataMatrixSymbolInfo144::~CBC_DataMatrixSymbolInfo144() {} +int32_t CBC_DataMatrixSymbolInfo144::getInterleavedBlockCount() { + return 10; +} +int32_t CBC_DataMatrixSymbolInfo144getDataLengthForInterleavedBlock( + int32_t index) { + return (index <= 8) ? 156 : 155; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h new file mode 100644 index 0000000000..4d6cdc1291 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h @@ -0,0 +1,20 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ + +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" + +class CBC_DataMatrixSymbolInfo144 : public CBC_SymbolInfo { + public: + CBC_DataMatrixSymbolInfo144(); + virtual ~CBC_DataMatrixSymbolInfo144(); + int32_t getInterleavedBlockCount(); + int32_t getDataLengthForInterleavedBlock(int32_t index); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp new file mode 100644 index 0000000000..50131f3dc2 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp @@ -0,0 +1,173 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdint.h> + +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h" +#include "xfa/fxbarcode/utils.h" + +CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL; + +void CBC_DataMatrixVersion::Initialize() { + VERSIONS = new CFX_PtrArray(); +} +void CBC_DataMatrixVersion::Finalize() { + for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { + delete ((CBC_DataMatrixVersion*)(VERSIONS->GetAt(i))); + } + VERSIONS->RemoveAll(); + delete VERSIONS; +} +CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber, + int32_t symbolSizeRows, + int32_t symbolSizeColumns, + int32_t dataRegionSizeRows, + int32_t dataRegionSizeColumns, + ECBlocks* ecBlocks) { + m_versionNumber = versionNumber; + m_symbolSizeRows = symbolSizeRows; + m_symbolSizeColumns = symbolSizeColumns; + m_dataRegionSizeRows = dataRegionSizeRows; + m_dataRegionSizeColumns = dataRegionSizeColumns; + m_ecBlocks = ecBlocks; + int32_t total = 0; + int32_t ecCodewords = ecBlocks->GetECCodewords(); + const CFX_PtrArray& ecbArray = ecBlocks->GetECBlocks(); + for (int32_t i = 0; i < ecbArray.GetSize(); i++) { + total += ((ECB*)ecbArray[i])->GetCount() * + (((ECB*)ecbArray[i])->GetDataCodewords() + ecCodewords); + } + m_totalCodewords = total; +} +CBC_DataMatrixVersion::~CBC_DataMatrixVersion() { + delete m_ecBlocks; +} +int32_t CBC_DataMatrixVersion::GetVersionNumber() { + return m_versionNumber; +} +int32_t CBC_DataMatrixVersion::GetSymbolSizeRows() { + return m_symbolSizeRows; +} +int32_t CBC_DataMatrixVersion::GetSymbolSizeColumns() { + return m_symbolSizeColumns; +} +int32_t CBC_DataMatrixVersion::GetDataRegionSizeRows() { + return m_dataRegionSizeRows; +} +int32_t CBC_DataMatrixVersion::GetDataRegionSizeColumns() { + return m_dataRegionSizeColumns; +} +int32_t CBC_DataMatrixVersion::GetTotalCodewords() { + return m_totalCodewords; +} +ECBlocks* CBC_DataMatrixVersion::GetECBlocks() { + return m_ecBlocks; +} +void CBC_DataMatrixVersion::ReleaseAll() { + for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { + delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i); + } + VERSIONS->RemoveAll(); +} +CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( + int32_t numRows, + int32_t numColumns, + int32_t& e) { + if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { + e = BCExceptionNotFound; + return NULL; + } + if (VERSIONS->GetSize() == 0) { + VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8, + new ECBlocks(5, new ECB(1, 3)))); + VERSIONS->Add(new CBC_DataMatrixVersion(2, 12, 12, 10, 10, + new ECBlocks(7, new ECB(1, 5)))); + VERSIONS->Add(new CBC_DataMatrixVersion(3, 14, 14, 12, 12, + new ECBlocks(10, new ECB(1, 8)))); + VERSIONS->Add(new CBC_DataMatrixVersion(4, 16, 16, 14, 14, + new ECBlocks(12, new ECB(1, 12)))); + VERSIONS->Add(new CBC_DataMatrixVersion(5, 18, 18, 16, 16, + new ECBlocks(14, new ECB(1, 18)))); + VERSIONS->Add(new CBC_DataMatrixVersion(6, 20, 20, 18, 18, + new ECBlocks(18, new ECB(1, 22)))); + VERSIONS->Add(new CBC_DataMatrixVersion(7, 22, 22, 20, 20, + new ECBlocks(20, new ECB(1, 30)))); + VERSIONS->Add(new CBC_DataMatrixVersion(8, 24, 24, 22, 22, + new ECBlocks(24, new ECB(1, 36)))); + VERSIONS->Add(new CBC_DataMatrixVersion(9, 26, 26, 24, 24, + new ECBlocks(28, new ECB(1, 44)))); + VERSIONS->Add(new CBC_DataMatrixVersion(10, 32, 32, 14, 14, + new ECBlocks(36, new ECB(1, 62)))); + VERSIONS->Add(new CBC_DataMatrixVersion(11, 36, 36, 16, 16, + new ECBlocks(42, new ECB(1, 86)))); + VERSIONS->Add(new CBC_DataMatrixVersion(12, 40, 40, 18, 18, + new ECBlocks(48, new ECB(1, 114)))); + VERSIONS->Add(new CBC_DataMatrixVersion(13, 44, 44, 20, 20, + new ECBlocks(56, new ECB(1, 144)))); + VERSIONS->Add(new CBC_DataMatrixVersion(14, 48, 48, 22, 22, + new ECBlocks(68, new ECB(1, 174)))); + VERSIONS->Add(new CBC_DataMatrixVersion(15, 52, 52, 24, 24, + new ECBlocks(42, new ECB(2, 102)))); + VERSIONS->Add(new CBC_DataMatrixVersion(16, 64, 64, 14, 14, + new ECBlocks(56, new ECB(2, 140)))); + VERSIONS->Add(new CBC_DataMatrixVersion(17, 72, 72, 16, 16, + new ECBlocks(36, new ECB(4, 92)))); + VERSIONS->Add(new CBC_DataMatrixVersion(18, 80, 80, 18, 18, + new ECBlocks(48, new ECB(4, 114)))); + VERSIONS->Add(new CBC_DataMatrixVersion(19, 88, 88, 20, 20, + new ECBlocks(56, new ECB(4, 144)))); + VERSIONS->Add(new CBC_DataMatrixVersion(20, 96, 96, 22, 22, + new ECBlocks(68, new ECB(4, 174)))); + VERSIONS->Add(new CBC_DataMatrixVersion(21, 104, 104, 24, 24, + new ECBlocks(56, new ECB(6, 136)))); + VERSIONS->Add(new CBC_DataMatrixVersion(22, 120, 120, 18, 18, + new ECBlocks(68, new ECB(6, 175)))); + VERSIONS->Add(new CBC_DataMatrixVersion(23, 132, 132, 20, 20, + new ECBlocks(62, new ECB(8, 163)))); + VERSIONS->Add(new CBC_DataMatrixVersion( + 24, 144, 144, 22, 22, + new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))); + VERSIONS->Add(new CBC_DataMatrixVersion(25, 8, 18, 6, 16, + new ECBlocks(7, new ECB(1, 5)))); + VERSIONS->Add(new CBC_DataMatrixVersion(26, 8, 32, 6, 14, + new ECBlocks(11, new ECB(1, 10)))); + VERSIONS->Add(new CBC_DataMatrixVersion(27, 12, 26, 10, 24, + new ECBlocks(14, new ECB(1, 16)))); + VERSIONS->Add(new CBC_DataMatrixVersion(28, 12, 36, 10, 16, + new ECBlocks(18, new ECB(1, 22)))); + VERSIONS->Add(new CBC_DataMatrixVersion(29, 16, 36, 14, 16, + new ECBlocks(24, new ECB(1, 32)))); + VERSIONS->Add(new CBC_DataMatrixVersion(30, 16, 48, 14, 22, + new ECBlocks(28, new ECB(1, 49)))); + } + 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]; + } + } + e = BCExceptionNotFound; + return NULL; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h new file mode 100644 index 0000000000..8a79355153 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h @@ -0,0 +1,92 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ + +#include "core/include/fxcrt/fx_basic.h" + +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; } + + int32_t GetDataCodewords() { return m_dataCodewords; } + + private: + int32_t m_count; + int32_t m_dataCodewords; +}; + +class ECBlocks { + public: + ECBlocks(int32_t ecCodewords, ECB* ecBlocks) { + m_ecCodewords = ecCodewords; + m_ecBlocks.Add(ecBlocks); + } + + ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) { + m_ecCodewords = ecCodewords; + m_ecBlocks.Add(ecBlocks1); + m_ecBlocks.Add(ecBlocks2); + } + ~ECBlocks() { + for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { + delete (ECB*)m_ecBlocks[i]; + } + m_ecBlocks.RemoveAll(); + } + + int32_t GetECCodewords() { return m_ecCodewords; } + + const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; } + + private: + int32_t m_ecCodewords; + CFX_PtrArray m_ecBlocks; +}; + +class CBC_DataMatrixVersion { + public: + CBC_DataMatrixVersion(int32_t versionNumber, + int32_t symbolSizeRows, + int32_t symbolSizeColumns, + int32_t dataRegionSizeRows, + int32_t dataRegionSizeColumns, + ECBlocks* ecBlocks); + virtual ~CBC_DataMatrixVersion(); + static void Initialize(); + static void Finalize(); + int32_t GetVersionNumber(); + int32_t GetSymbolSizeRows(); + int32_t GetSymbolSizeColumns(); + int32_t GetDataRegionSizeRows(); + int32_t GetDataRegionSizeColumns(); + int32_t GetTotalCodewords(); + ECBlocks* GetECBlocks(); + static CBC_DataMatrixVersion* GetVersionForDimensions(int32_t numRows, + int32_t numColumns, + int32_t& e); + static void ReleaseAll(); + + private: + int32_t m_versionNumber; + int32_t m_symbolSizeRows; + int32_t m_symbolSizeColumns; + int32_t m_dataRegionSizeRows; + int32_t m_dataRegionSizeColumns; + ECBlocks* m_ecBlocks; + int32_t m_totalCodewords; + static CFX_PtrArray* VERSIONS; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp new file mode 100644 index 0000000000..03cd5fba50 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp @@ -0,0 +1,136 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h" +#include "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h" +#include "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" +#include "xfa/fxbarcode/datamatrix/BC_TextEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_X12Encoder.h" + +CBC_DataMatrixWriter::CBC_DataMatrixWriter() {} +CBC_DataMatrixWriter::~CBC_DataMatrixWriter() {} +FX_BOOL CBC_DataMatrixWriter::SetErrorCorrectionLevel(int32_t level) { + m_iCorrectLevel = level; + return TRUE; +} +uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + if (outWidth < 0 || outHeight < 0) { + e = BCExceptionHeightAndWidthMustBeAtLeast1; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CBC_SymbolShapeHint::SymbolShapeHint shape = + CBC_SymbolShapeHint::FORCE_SQUARE; + CBC_Dimension* minSize = NULL; + CBC_Dimension* maxSize = NULL; + CFX_WideString ecLevel; + CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel( + contents, ecLevel, shape, minSize, maxSize, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup( + encoded.GetLength(), shape, minSize, maxSize, TRUE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_WideString codewords = + CBC_ErrorCorrection::encodeECC200(encoded, symbolInfo, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_DefaultPlacement* placement = + new CBC_DefaultPlacement(codewords, symbolInfo->getSymbolDataWidth(e), + symbolInfo->getSymbolDataHeight(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + placement->place(); + CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + outWidth = bytematrix->GetWidth(); + outHeight = bytematrix->GetHeight(); + uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); + FXSYS_memcpy(result, bytematrix->GetArray(), outWidth * outHeight); + delete bytematrix; + delete placement; + return result; +} +CBC_CommonByteMatrix* CBC_DataMatrixWriter::encodeLowLevel( + CBC_DefaultPlacement* placement, + CBC_SymbolInfo* symbolInfo, + int32_t& e) { + int32_t symbolWidth = symbolInfo->getSymbolDataWidth(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t symbolHeight = symbolInfo->getSymbolDataHeight(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_CommonByteMatrix* matrix = new CBC_CommonByteMatrix( + symbolInfo->getSymbolWidth(e), symbolInfo->getSymbolHeight(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + matrix->Init(); + int32_t matrixY = 0; + for (int32_t y = 0; y < symbolHeight; y++) { + int32_t matrixX; + if ((y % symbolInfo->m_matrixHeight) == 0) { + matrixX = 0; + for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { + matrix->Set(matrixX, matrixY, (x % 2) == 0); + matrixX++; + } + matrixY++; + } + matrixX = 0; + for (int32_t x = 0; x < symbolWidth; x++) { + if ((x % symbolInfo->m_matrixWidth) == 0) { + matrix->Set(matrixX, matrixY, TRUE); + matrixX++; + } + matrix->Set(matrixX, matrixY, placement->getBit(x, y)); + matrixX++; + if ((x % symbolInfo->m_matrixWidth) == symbolInfo->m_matrixWidth - 1) { + matrix->Set(matrixX, matrixY, (y % 2) == 0); + matrixX++; + } + } + matrixY++; + if ((y % symbolInfo->m_matrixHeight) == symbolInfo->m_matrixHeight - 1) { + matrixX = 0; + for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { + matrix->Set(matrixX, matrixY, TRUE); + matrixX++; + } + matrixY++; + } + } + return matrix; +} diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h new file mode 100644 index 0000000000..7c19a07c19 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixWriter.h @@ -0,0 +1,33 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ + +#include "xfa/fxbarcode/BC_TwoDimWriter.h" + +class CBC_CommonByteMatrix; +class CBC_DefaultPlacement; +class CBC_SymbolInfo; + +class CBC_DataMatrixWriter : public CBC_TwoDimWriter { + public: + CBC_DataMatrixWriter(); + virtual ~CBC_DataMatrixWriter(); + uint8_t* Encode(const CFX_WideString& contents, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + FX_BOOL SetErrorCorrectionLevel(int32_t level); + + private: + static CBC_CommonByteMatrix* encodeLowLevel(CBC_DefaultPlacement* placement, + CBC_SymbolInfo* symbolInfo, + int32_t& e); + int32_t m_iCorrectLevel; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.cpp new file mode 100644 index 0000000000..830df224ca --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.cpp @@ -0,0 +1,164 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +CBC_DefaultPlacement::CBC_DefaultPlacement(CFX_WideString codewords, + int32_t numcols, + int32_t numrows) { + m_codewords = codewords; + m_numcols = numcols; + m_numrows = numrows; + m_bits.SetSize(numcols * numrows); + for (int32_t i = 0; i < numcols * numrows; i++) { + m_bits[i] = (uint8_t)2; + } +} +CBC_DefaultPlacement::~CBC_DefaultPlacement() { + m_bits.RemoveAll(); +} +int32_t CBC_DefaultPlacement::getNumrows() { + return m_numrows; +} +int32_t CBC_DefaultPlacement::getNumcols() { + return m_numcols; +} +CFX_ByteArray& CBC_DefaultPlacement::getBits() { + return m_bits; +} +FX_BOOL CBC_DefaultPlacement::getBit(int32_t col, int32_t row) { + return m_bits[row * m_numcols + col] == 1; +} +void CBC_DefaultPlacement::setBit(int32_t col, int32_t row, FX_BOOL bit) { + m_bits[row * m_numcols + col] = bit ? (uint8_t)1 : (uint8_t)0; +} +FX_BOOL CBC_DefaultPlacement::hasBit(int32_t col, int32_t row) { + return m_bits[row * m_numcols + col] != 2; +} +void CBC_DefaultPlacement::place() { + int32_t pos = 0; + int32_t row = 4; + int32_t col = 0; + do { + if ((row == m_numrows) && (col == 0)) { + corner1(pos++); + } + if ((row == m_numrows - 2) && (col == 0) && ((m_numcols % 4) != 0)) { + corner2(pos++); + } + if ((row == m_numrows - 2) && (col == 0) && (m_numcols % 8 == 4)) { + corner3(pos++); + } + if ((row == m_numrows + 4) && (col == 2) && ((m_numcols % 8) == 0)) { + corner4(pos++); + } + do { + if ((row < m_numrows) && (col >= 0) && !hasBit(col, row)) { + utah(row, col, pos++); + } + row -= 2; + col += 2; + } while (row >= 0 && (col < m_numcols)); + row++; + col += 3; + do { + if ((row >= 0) && (col < m_numcols) && !hasBit(col, row)) { + utah(row, col, pos++); + } + row += 2; + col -= 2; + } while ((row < m_numrows) && (col >= 0)); + row += 3; + col++; + } while ((row < m_numrows) || (col < m_numcols)); + if (!hasBit(m_numcols - 1, m_numrows - 1)) { + setBit(m_numcols - 1, m_numrows - 1, TRUE); + setBit(m_numcols - 2, m_numrows - 2, TRUE); + } +} +void CBC_DefaultPlacement::module(int32_t row, + int32_t col, + int32_t pos, + int32_t bit) { + if (row < 0) { + row += m_numrows; + col += 4 - ((m_numrows + 4) % 8); + } + if (col < 0) { + col += m_numcols; + row += 4 - ((m_numcols + 4) % 8); + } + int32_t v = m_codewords.GetAt(pos); + v &= 1 << (8 - bit); + setBit(col, row, v != 0); +} +void CBC_DefaultPlacement::utah(int32_t row, int32_t col, int32_t pos) { + module(row - 2, col - 2, pos, 1); + module(row - 2, col - 1, pos, 2); + module(row - 1, col - 2, pos, 3); + module(row - 1, col - 1, pos, 4); + module(row - 1, col, pos, 5); + module(row, col - 2, pos, 6); + module(row, col - 1, pos, 7); + module(row, col, pos, 8); +} +void CBC_DefaultPlacement::corner1(int32_t pos) { + module(m_numrows - 1, 0, pos, 1); + module(m_numrows - 1, 1, pos, 2); + module(m_numrows - 1, 2, pos, 3); + module(0, m_numcols - 2, pos, 4); + module(0, m_numcols - 1, pos, 5); + module(1, m_numcols - 1, pos, 6); + module(2, m_numcols - 1, pos, 7); + module(3, m_numcols - 1, pos, 8); +} +void CBC_DefaultPlacement::corner2(int32_t pos) { + module(m_numrows - 3, 0, pos, 1); + module(m_numrows - 2, 0, pos, 2); + module(m_numrows - 1, 0, pos, 3); + module(0, m_numcols - 4, pos, 4); + module(0, m_numcols - 3, pos, 5); + module(0, m_numcols - 2, pos, 6); + module(0, m_numcols - 1, pos, 7); + module(1, m_numcols - 1, pos, 8); +} +void CBC_DefaultPlacement::corner3(int32_t pos) { + module(m_numrows - 3, 0, pos, 1); + module(m_numrows - 2, 0, pos, 2); + module(m_numrows - 1, 0, pos, 3); + module(0, m_numcols - 2, pos, 4); + module(0, m_numcols - 1, pos, 5); + module(1, m_numcols - 1, pos, 6); + module(2, m_numcols - 1, pos, 7); + module(3, m_numcols - 1, pos, 8); +} +void CBC_DefaultPlacement::corner4(int32_t pos) { + module(m_numrows - 1, 0, pos, 1); + module(m_numrows - 1, m_numcols - 1, pos, 2); + module(0, m_numcols - 3, pos, 3); + module(0, m_numcols - 2, pos, 4); + module(0, m_numcols - 1, pos, 5); + module(1, m_numcols - 3, pos, 6); + module(1, m_numcols - 2, pos, 7); + module(1, m_numcols - 1, pos, 8); +} diff --git a/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h b/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h new file mode 100644 index 0000000000..49008f3356 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_DefaultPlacement.h @@ -0,0 +1,40 @@ +// 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_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_DefaultPlacement { + public: + CBC_DefaultPlacement(CFX_WideString codewords, + int32_t numcols, + int32_t numrows); + virtual ~CBC_DefaultPlacement(); + + int32_t getNumrows(); + int32_t getNumcols(); + CFX_ByteArray& getBits(); + FX_BOOL getBit(int32_t col, int32_t row); + void setBit(int32_t col, int32_t row, FX_BOOL bit); + FX_BOOL hasBit(int32_t col, int32_t row); + void place(); + + private: + CFX_WideString m_codewords; + int32_t m_numrows; + int32_t m_numcols; + CFX_ByteArray m_bits; + void module(int32_t row, int32_t col, int32_t pos, int32_t bit); + void utah(int32_t row, int32_t col, int32_t pos); + void corner1(int32_t pos); + void corner2(int32_t pos); + void corner3(int32_t pos); + void corner4(int32_t pos); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.cpp new file mode 100644 index 0000000000..d1f5b9796d --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.cpp @@ -0,0 +1,154 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_EdifactEncoder::CBC_EdifactEncoder() {} +CBC_EdifactEncoder::~CBC_EdifactEncoder() {} +int32_t CBC_EdifactEncoder::getEncodingMode() { + return EDIFACT_ENCODATION; +} +void CBC_EdifactEncoder::Encode(CBC_EncoderContext& context, int32_t& e) { + CFX_WideString buffer; + while (context.hasMoreCharacters()) { + FX_WCHAR c = context.getCurrentChar(); + encodeChar(c, buffer, e); + if (e != BCExceptionNO) { + return; + } + context.m_pos++; + int32_t count = buffer.GetLength(); + if (count >= 4) { + context.writeCodewords(encodeToCodewords(buffer, 0, e)); + if (e != BCExceptionNO) { + return; + } + buffer.Delete(0, 4); + int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( + context.m_msg, context.m_pos, getEncodingMode()); + if (newMode != getEncodingMode()) { + context.signalEncoderChange(ASCII_ENCODATION); + break; + } + } + } + buffer += (FX_WCHAR)31; + handleEOD(context, buffer, e); +} +void CBC_EdifactEncoder::handleEOD(CBC_EncoderContext& context, + CFX_WideString buffer, + int32_t& e) { + int32_t count = buffer.GetLength(); + if (count == 0) { + return; + } + if (count == 1) { + context.updateSymbolInfo(e); + if (e != BCExceptionNO) { + return; + } + int32_t available = + context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); + int32_t remaining = context.getRemainingCharacters(); + if (remaining == 0 && available <= 2) { + return; + } + } + if (count > 4) { + e = BCExceptionIllegalStateCountMustNotExceed4; + return; + } + int32_t restChars = count - 1; + CFX_WideString encoded = encodeToCodewords(buffer, 0, e); + if (e != BCExceptionNO) { + return; + } + FX_BOOL endOfSymbolReached = !context.hasMoreCharacters(); + FX_BOOL restInAscii = endOfSymbolReached && restChars <= 2; + if (restChars <= 2) { + context.updateSymbolInfo(context.getCodewordCount() + restChars, e); + if (e != BCExceptionNO) { + return; + } + int32_t available = + context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); + if (available >= 3) { + restInAscii = FALSE; + context.updateSymbolInfo(context.getCodewordCount() + encoded.GetLength(), + e); + if (e != BCExceptionNO) { + return; + } + } + } + if (restInAscii) { + context.resetSymbolInfo(); + context.m_pos -= restChars; + } else { + context.writeCodewords(encoded); + } + context.signalEncoderChange(ASCII_ENCODATION); +} +void CBC_EdifactEncoder::encodeChar(FX_WCHAR c, + CFX_WideString& sb, + int32_t& e) { + if (c >= ' ' && c <= '?') { + sb += c; + } else if (c >= '@' && c <= '^') { + sb += (FX_WCHAR)(c - 64); + } else { + CBC_HighLevelEncoder::illegalCharacter(c, e); + } +} +CFX_WideString CBC_EdifactEncoder::encodeToCodewords(CFX_WideString sb, + int32_t startPos, + int32_t& e) { + int32_t len = sb.GetLength() - startPos; + if (len == 0) { + e = BCExceptionNoContents; + return (FX_WCHAR*)""; + } + FX_WCHAR c1 = sb.GetAt(startPos); + FX_WCHAR c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0; + FX_WCHAR c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0; + FX_WCHAR c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0; + int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; + FX_WCHAR cw1 = (FX_WCHAR)((v >> 16) & 255); + FX_WCHAR cw2 = (FX_WCHAR)((v >> 8) & 255); + FX_WCHAR cw3 = (FX_WCHAR)(v & 255); + CFX_WideString res; + res += cw1; + if (len >= 2) { + res += cw2; + } + if (len >= 3) { + res += cw3; + } + return res; +} diff --git a/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h b/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h new file mode 100644 index 0000000000..fd37ffb5b4 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h @@ -0,0 +1,29 @@ +// 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_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ + +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" + +class CBC_EdifactEncoder : public CBC_Encoder { + public: + CBC_EdifactEncoder(); + virtual ~CBC_EdifactEncoder(); + int32_t getEncodingMode(); + void Encode(CBC_EncoderContext& context, int32_t& e); + + private: + static void handleEOD(CBC_EncoderContext& context, + CFX_WideString buffer, + int32_t& e); + static void encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); + static CFX_WideString encodeToCodewords(CFX_WideString sb, + int32_t startPos, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_Encoder.cpp new file mode 100644 index 0000000000..bf815bdfa7 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_Encoder.cpp @@ -0,0 +1,10 @@ +// 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/fxbarcode/datamatrix/BC_Encoder.h" + +CBC_Encoder::CBC_Encoder() {} +CBC_Encoder::~CBC_Encoder() {} diff --git a/xfa/fxbarcode/datamatrix/BC_Encoder.h b/xfa/fxbarcode/datamatrix/BC_Encoder.h new file mode 100644 index 0000000000..78dc6ac447 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_Encoder.h @@ -0,0 +1,21 @@ +// 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_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ + +#include "xfa/fxbarcode/utils.h" + +class CBC_EncoderContext; +class CBC_Encoder { + public: + CBC_Encoder(); + virtual ~CBC_Encoder(); + virtual int32_t getEncodingMode() = 0; + virtual void Encode(CBC_EncoderContext& context, int32_t& e) = 0; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp b/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp new file mode 100644 index 0000000000..c99dcb7d7a --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_EncoderContext.cpp @@ -0,0 +1,111 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, + CFX_WideString ecLevel, + int32_t& e) { + CFX_ByteString dststr; + CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr); + CFX_WideString sb; + int32_t c = dststr.GetLength(); + for (int32_t i = 0; i < c; i++) { + FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff); + if (ch == '?' && dststr.GetAt(i) != '?') { + e = BCExceptionCharactersOutsideISO88591Encoding; + } + sb += ch; + } + m_msg = sb; + m_shape = FORCE_NONE; + m_newEncoding = -1; + m_pos = 0; + m_symbolInfo = NULL; + m_skipAtEnd = 0; + m_maxSize = NULL; + m_minSize = NULL; +} +CBC_EncoderContext::~CBC_EncoderContext() {} +void CBC_EncoderContext::setSymbolShape(SymbolShapeHint shape) { + m_shape = shape; +} +void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize, + CBC_Dimension* maxSize) { + m_maxSize = maxSize; + m_minSize = minSize; +} +CFX_WideString CBC_EncoderContext::getMessage() { + return m_msg; +} +void CBC_EncoderContext::setSkipAtEnd(int32_t count) { + m_skipAtEnd = count; +} +FX_WCHAR CBC_EncoderContext::getCurrentChar() { + return m_msg.GetAt(m_pos); +} +FX_WCHAR CBC_EncoderContext::getCurrent() { + return m_msg.GetAt(m_pos); +} +void CBC_EncoderContext::writeCodewords(CFX_WideString codewords) { + m_codewords += codewords; +} +void CBC_EncoderContext::writeCodeword(FX_WCHAR codeword) { + m_codewords += codeword; +} +int32_t CBC_EncoderContext::getCodewordCount() { + return m_codewords.GetLength(); +} +void CBC_EncoderContext::signalEncoderChange(int32_t encoding) { + m_newEncoding = encoding; +} +void CBC_EncoderContext::resetEncoderSignal() { + m_newEncoding = -1; +} +FX_BOOL CBC_EncoderContext::hasMoreCharacters() { + return m_pos < getTotalMessageCharCount(); +} +int32_t CBC_EncoderContext::getRemainingCharacters() { + return getTotalMessageCharCount() - m_pos; +} +void CBC_EncoderContext::updateSymbolInfo(int32_t& e) { + updateSymbolInfo(getCodewordCount(), e); +} +void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t& e) { + if (m_symbolInfo == NULL || len > m_symbolInfo->m_dataCapacity) { + m_symbolInfo = + CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize, true, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_EncoderContext::resetSymbolInfo() { + m_shape = FORCE_NONE; +} +int32_t CBC_EncoderContext::getTotalMessageCharCount() { + return m_msg.GetLength() - m_skipAtEnd; +} diff --git a/xfa/fxbarcode/datamatrix/BC_EncoderContext.h b/xfa/fxbarcode/datamatrix/BC_EncoderContext.h new file mode 100644 index 0000000000..ddc6988dc3 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_EncoderContext.h @@ -0,0 +1,55 @@ +// 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_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ + +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +class CBC_SymbolInfo; +class CBC_Dimension; + +class CBC_EncoderContext : public CBC_SymbolShapeHint { + public: + CBC_EncoderContext(const CFX_WideString msg, + CFX_WideString ecLevel, + int32_t& e); + virtual ~CBC_EncoderContext(); + void setSymbolShape(SymbolShapeHint shape); + void setSizeConstraints(CBC_Dimension* minSize, CBC_Dimension* maxSize); + CFX_WideString getMessage(); + void setSkipAtEnd(int32_t count); + FX_WCHAR getCurrentChar(); + FX_WCHAR getCurrent(); + void writeCodewords(CFX_WideString codewords); + void writeCodeword(FX_WCHAR codeword); + int32_t getCodewordCount(); + void signalEncoderChange(int32_t encoding); + void resetEncoderSignal(); + FX_BOOL hasMoreCharacters(); + int32_t getRemainingCharacters(); + void updateSymbolInfo(int32_t& e); + void updateSymbolInfo(int32_t len, int32_t& e); + void resetSymbolInfo(); + + public: + CFX_WideString m_msg; + CFX_WideString m_codewords; + int32_t m_pos; + int32_t m_newEncoding; + CBC_SymbolInfo* m_symbolInfo; + + private: + int32_t getTotalMessageCharCount(); + + private: + SymbolShapeHint m_shape; + CBC_Dimension* m_minSize; + CBC_Dimension* m_maxSize; + int32_t m_skipAtEnd; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp new file mode 100644 index 0000000000..98c0599e50 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp @@ -0,0 +1,175 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +int32_t CBC_ErrorCorrection::FACTOR_SETS[] = {5, 7, 10, 11, 12, 14, 18, 20, + 24, 28, 36, 42, 48, 56, 62, 68}; +int32_t CBC_ErrorCorrection::FACTORS[][100] = { + {228, 48, 15, 111, 62}, + {23, 68, 144, 134, 240, 92, 254}, + {28, 24, 185, 166, 223, 248, 116, 255, 110, 61}, + {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120}, + {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242}, + {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185}, + {83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, + 90, 188}, + {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, + 174, 186, 172}, + {52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, + 254, 124, 12, 181, 184, 96, 50, 193}, + {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, + 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255}, + {245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, + 182, 229, 18, 2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, + 225, 98, 81, 112}, + {77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, + 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, + 69, 50, 150, 177, 226, 5, 9, 5}, + {245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, + 191, 106, 16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, + 186, 240, 82, 44, 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19}, + {175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, + 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, + 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, + 155, 43, 203, 107, 233, 53, 143, 46}, + {242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, + 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, + 71, 161, 44, 147, 6, 27, 218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31, + 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, 11, 204}, + {220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, + 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, + 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, 96, 210, 231, 136, + 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211, 189, 64, 54, 108, 153, + 132, 63, 96, 103, 82, 186}}; +int32_t CBC_ErrorCorrection::MODULO_VALUE = 0x12D; +int32_t CBC_ErrorCorrection::LOG[256] = {0}; +int32_t CBC_ErrorCorrection::ALOG[256] = {0}; +void CBC_ErrorCorrection::Initialize() { + int32_t p = 1; + for (int32_t i = 0; i < 255; i++) { + ALOG[i] = p; + LOG[p] = i; + p <<= 1; + if (p >= 256) { + p ^= MODULO_VALUE; + } + } +} +void CBC_ErrorCorrection::Finalize() {} +CBC_ErrorCorrection::CBC_ErrorCorrection() {} +CBC_ErrorCorrection::~CBC_ErrorCorrection() {} +CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, + CBC_SymbolInfo* symbolInfo, + int32_t& e) { + if (codewords.GetLength() != symbolInfo->m_dataCapacity) { + e = BCExceptionIllegalArgument; + return (FX_WCHAR*)""; + } + CFX_WideString sb; + sb += codewords; + int32_t blockCount = symbolInfo->getInterleavedBlockCount(); + if (blockCount == 1) { + CFX_WideString ecc = + createECCBlock(codewords, symbolInfo->m_errorCodewords, e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + sb += ecc; + } else { + CFX_Int32Array dataSizes; + dataSizes.SetSize(blockCount); + CFX_Int32Array errorSizes; + errorSizes.SetSize(blockCount); + CFX_Int32Array startPos; + startPos.SetSize(blockCount); + for (int32_t i = 0; i < blockCount; i++) { + dataSizes[i] = symbolInfo->getDataLengthForInterleavedBlock(i + 1); + errorSizes[i] = symbolInfo->getErrorLengthForInterleavedBlock(i + 1); + startPos[i] = 0; + if (i > 0) { + startPos[i] = startPos[i - 1] + dataSizes[i]; + } + } + for (int32_t block = 0; block < blockCount; block++) { + CFX_WideString temp; + for (int32_t d = block; d < symbolInfo->m_dataCapacity; d += blockCount) { + temp += (FX_WCHAR)codewords.GetAt(d); + } + CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + int32_t pos = 0; + for (int32_t l = block; l < errorSizes[block] * blockCount; + l += blockCount) { + sb.SetAt(symbolInfo->m_dataCapacity + l, ecc.GetAt(pos++)); + } + } + } + return sb; +} +CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords, + int32_t numECWords, + int32_t& e) { + return createECCBlock(codewords, 0, codewords.GetLength(), numECWords, e); +} +CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords, + int32_t start, + 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) { + e = BCExceptionIllegalArgument; + return (FX_WCHAR*)""; + } + FX_WORD* ecc = FX_Alloc(FX_WORD, numECWords); + FXSYS_memset(ecc, 0, numECWords * sizeof(FX_WORD)); + for (int32_t l = start; l < start + len; l++) { + FX_WORD m = ecc[numECWords - 1] ^ codewords.GetAt(l); + for (int32_t k = numECWords - 1; k > 0; k--) { + if (m != 0 && FACTORS[table][k] != 0) { + ecc[k] = (FX_WORD)(ecc[k - 1] ^ + ALOG[(LOG[m] + LOG[FACTORS[table][k]]) % 255]); + } else { + ecc[k] = ecc[k - 1]; + } + } + if (m != 0 && FACTORS[table][0] != 0) { + ecc[0] = (FX_WORD)ALOG[(LOG[m] + LOG[FACTORS[table][0]]) % 255]; + } else { + ecc[0] = 0; + } + } + CFX_WideString strecc; + for (int32_t j = 0; j < numECWords; j++) { + strecc += (FX_WCHAR)ecc[numECWords - j - 1]; + } + FX_Free(ecc); + return strecc; +} diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h new file mode 100644 index 0000000000..a4264b6306 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h @@ -0,0 +1,39 @@ +// 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_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ + +class CBC_SymbolInfo; +class CBC_ErrorCorrection { + public: + CBC_ErrorCorrection(); + virtual ~CBC_ErrorCorrection(); + static void Initialize(); + static void Finalize(); + static CFX_WideString encodeECC200(CFX_WideString codewords, + CBC_SymbolInfo* symbolInfo, + int32_t& e); + + private: + static int32_t FACTOR_SETS[]; + static int32_t FACTORS[][100]; + static int32_t MODULO_VALUE; + static int32_t LOG[256]; + static int32_t ALOG[256]; + + private: + static CFX_WideString createECCBlock(CFX_WideString codewords, + int32_t numECWords, + int32_t& e); + static CFX_WideString createECCBlock(CFX_WideString codewords, + int32_t start, + int32_t len, + int32_t numECWords, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp new file mode 100644 index 0000000000..d8e7bb1dc5 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp @@ -0,0 +1,375 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <limits> + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_ASCIIEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Base256Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EdifactEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" +#include "xfa/fxbarcode/datamatrix/BC_TextEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_X12Encoder.h" +#include "xfa/fxbarcode/utils.h" + +FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_C40 = 230; +FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_BASE256 = 231; +FX_WCHAR CBC_HighLevelEncoder::UPPER_SHIFT = 235; +FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_ANSIX12 = 238; +FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_TEXT = 239; +FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_EDIFACT = 240; +FX_WCHAR CBC_HighLevelEncoder::C40_UNLATCH = 254; +FX_WCHAR CBC_HighLevelEncoder::X12_UNLATCH = 254; +FX_WCHAR CBC_HighLevelEncoder::PAD = 129; +FX_WCHAR CBC_HighLevelEncoder::MACRO_05 = 236; +FX_WCHAR CBC_HighLevelEncoder::MACRO_06 = 237; +const wchar_t* CBC_HighLevelEncoder::MACRO_05_HEADER = L"[)>05"; +const wchar_t* CBC_HighLevelEncoder::MACRO_06_HEADER = L"[)>06"; +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); + for (int32_t i = 0; i < bytestr.GetLength(); i++) { + m_bytearray.Add(bytestr.GetAt(i)); + } + return m_bytearray; +} +CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, + CFX_WideString ecLevel, + int32_t& e) { + return encodeHighLevel(msg, ecLevel, FORCE_NONE, NULL, NULL, e); +} +CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, + CFX_WideString ecLevel, + SymbolShapeHint shape, + CBC_Dimension* minSize, + CBC_Dimension* maxSize, + int32_t& e) { + CBC_EncoderContext context(msg, ecLevel, e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + context.setSymbolShape(shape); + context.setSizeConstraints(minSize, maxSize); + if ((msg.Mid(0, 6) == MACRO_05_HEADER) && + (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { + context.writeCodeword(MACRO_05); + context.setSkipAtEnd(2); + context.m_pos += 6; + } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) && + (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { + context.writeCodeword(MACRO_06); + 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()); + 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*)""; + } + if (context.m_newEncoding >= 0) { + encodingMode = context.m_newEncoding; + context.resetEncoderSignal(); + } + } + 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*)""; + } + int32_t capacity = context.m_symbolInfo->m_dataCapacity; + if (len < capacity) { + if (encodingMode != ASCII_ENCODATION && + encodingMode != BASE256_ENCODATION) { + context.writeCodeword(0x00fe); + } + } + CFX_WideString codewords = context.m_codewords; + if (codewords.GetLength() < capacity) { + codewords += PAD; + } + 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, + int32_t startpos, + int32_t currentMode) { + if (startpos >= msg.GetLength()) { + return currentMode; + } + CFX_FloatArray charCounts; + if (currentMode == ASCII_ENCODATION) { + charCounts.Add(0); + charCounts.Add(1); + charCounts.Add(1); + charCounts.Add(1); + charCounts.Add(1); + charCounts.Add(1.25f); + } else { + charCounts.Add(1); + charCounts.Add(2); + charCounts.Add(2); + charCounts.Add(2); + charCounts.Add(2); + charCounts.Add(2.25f); + charCounts[currentMode] = 0; + } + int32_t charsProcessed = 0; + while (TRUE) { + if ((startpos + charsProcessed) == msg.GetLength()) { + FX_DWORD min = std::numeric_limits<int32_t>::max(); + CFX_ByteArray mins; + mins.SetSize(6); + CFX_Int32Array intCharCounts; + intCharCounts.SetSize(6); + min = findMinimums(charCounts, intCharCounts, min, mins); + int32_t minCount = getMinimumCount(mins); + if (intCharCounts[ASCII_ENCODATION] == min) { + return ASCII_ENCODATION; + } + if (minCount == 1 && mins[BASE256_ENCODATION] > 0) { + return BASE256_ENCODATION; + } + if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { + return EDIFACT_ENCODATION; + } + if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { + return TEXT_ENCODATION; + } + if (minCount == 1 && mins[X12_ENCODATION] > 0) { + return X12_ENCODATION; + } + return C40_ENCODATION; + } + FX_WCHAR c = msg.GetAt(startpos + charsProcessed); + charsProcessed++; + if (isDigit(c)) { + charCounts[ASCII_ENCODATION] += 0.5; + } else if (isExtendedASCII(c)) { + charCounts[ASCII_ENCODATION] = + (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); + charCounts[ASCII_ENCODATION] += 2; + } else { + charCounts[ASCII_ENCODATION] = + (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); + charCounts[ASCII_ENCODATION]++; + } + if (isNativeC40(c)) { + charCounts[C40_ENCODATION] += 2.0f / 3.0f; + } else if (isExtendedASCII(c)) { + charCounts[C40_ENCODATION] += 8.0f / 3.0f; + } else { + charCounts[C40_ENCODATION] += 4.0f / 3.0f; + } + if (isNativeText(c)) { + charCounts[TEXT_ENCODATION] += 2.0f / 3.0f; + } else if (isExtendedASCII(c)) { + charCounts[TEXT_ENCODATION] += 8.0f / 3.0f; + } else { + charCounts[TEXT_ENCODATION] += 4.0f / 3.0f; + } + if (isNativeX12(c)) { + charCounts[X12_ENCODATION] += 2.0f / 3.0f; + } else if (isExtendedASCII(c)) { + charCounts[X12_ENCODATION] += 13.0f / 3.0f; + } else { + charCounts[X12_ENCODATION] += 10.0f / 3.0f; + } + if (isNativeEDIFACT(c)) { + charCounts[EDIFACT_ENCODATION] += 3.0f / 4.0f; + } else if (isExtendedASCII(c)) { + charCounts[EDIFACT_ENCODATION] += 17.0f / 4.0f; + } else { + charCounts[EDIFACT_ENCODATION] += 13.0f / 4.0f; + } + if (isSpecialB256(c)) { + charCounts[BASE256_ENCODATION] += 4; + } else { + charCounts[BASE256_ENCODATION]++; + } + if (charsProcessed >= 4) { + CFX_Int32Array intCharCounts; + intCharCounts.SetSize(6); + CFX_ByteArray mins; + mins.SetSize(6); + findMinimums(charCounts, intCharCounts, + std::numeric_limits<int32_t>::max(), mins); + int32_t minCount = getMinimumCount(mins); + if (intCharCounts[ASCII_ENCODATION] < intCharCounts[BASE256_ENCODATION] && + intCharCounts[ASCII_ENCODATION] < intCharCounts[C40_ENCODATION] && + intCharCounts[ASCII_ENCODATION] < intCharCounts[TEXT_ENCODATION] && + intCharCounts[ASCII_ENCODATION] < intCharCounts[X12_ENCODATION] && + intCharCounts[ASCII_ENCODATION] < intCharCounts[EDIFACT_ENCODATION]) { + return ASCII_ENCODATION; + } + if (intCharCounts[BASE256_ENCODATION] < intCharCounts[ASCII_ENCODATION] || + (mins[C40_ENCODATION] + mins[TEXT_ENCODATION] + mins[X12_ENCODATION] + + mins[EDIFACT_ENCODATION]) == 0) { + return BASE256_ENCODATION; + } + if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { + return EDIFACT_ENCODATION; + } + if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { + return TEXT_ENCODATION; + } + if (minCount == 1 && mins[X12_ENCODATION] > 0) { + return X12_ENCODATION; + } + if (intCharCounts[C40_ENCODATION] + 1 < intCharCounts[ASCII_ENCODATION] && + intCharCounts[C40_ENCODATION] + 1 < + intCharCounts[BASE256_ENCODATION] && + intCharCounts[C40_ENCODATION] + 1 < + intCharCounts[EDIFACT_ENCODATION] && + intCharCounts[C40_ENCODATION] + 1 < intCharCounts[TEXT_ENCODATION]) { + if (intCharCounts[C40_ENCODATION] < intCharCounts[X12_ENCODATION]) { + return C40_ENCODATION; + } + if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) { + int32_t p = startpos + charsProcessed + 1; + while (p < msg.GetLength()) { + FX_WCHAR tc = msg.GetAt(p); + if (isX12TermSep(tc)) { + return X12_ENCODATION; + } + if (!isNativeX12(tc)) { + break; + } + p++; + } + return C40_ENCODATION; + } + } + } + } +} +FX_BOOL CBC_HighLevelEncoder::isDigit(FX_WCHAR ch) { + return ch >= '0' && ch <= '9'; +} +FX_BOOL CBC_HighLevelEncoder::isExtendedASCII(FX_WCHAR ch) { + return ch >= 128 && ch <= 255; +} +int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg, + int32_t startpos) { + int32_t count = 0; + int32_t len = msg.GetLength(); + int32_t idx = startpos; + if (idx < len) { + FX_WCHAR ch = msg.GetAt(idx); + while (isDigit(ch) && idx < len) { + count++; + idx++; + if (idx < len) { + ch = msg.GetAt(idx); + } + } + } + return count; +} +void CBC_HighLevelEncoder::illegalCharacter(FX_WCHAR c, int32_t& e) { + e = BCExceptionIllegalArgument; +} +FX_WCHAR CBC_HighLevelEncoder::randomize253State(FX_WCHAR ch, + int32_t codewordPosition) { + int32_t pseudoRandom = ((149 * codewordPosition) % 253) + 1; + int32_t tempVariable = ch + pseudoRandom; + return tempVariable <= 254 ? (FX_WCHAR)tempVariable + : (FX_WCHAR)(tempVariable - 254); +} +int32_t CBC_HighLevelEncoder::findMinimums(CFX_FloatArray& charCounts, + CFX_Int32Array& intCharCounts, + int32_t min, + CFX_ByteArray& mins) { + for (int32_t l = 0; l < mins.GetSize(); l++) { + mins[l] = (uint8_t)0; + } + for (int32_t i = 0; i < 6; i++) { + intCharCounts[i] = (int32_t)ceil(charCounts[i]); + int32_t current = intCharCounts[i]; + if (min > current) { + min = current; + for (int32_t j = 0; j < mins.GetSize(); j++) { + mins[j] = (uint8_t)0; + } + } + if (min == current) { + mins[i]++; + } + } + return min; +} +int32_t CBC_HighLevelEncoder::getMinimumCount(CFX_ByteArray& mins) { + int32_t minCount = 0; + for (int32_t i = 0; i < 6; i++) { + minCount += mins[i]; + } + return minCount; +} +FX_BOOL CBC_HighLevelEncoder::isNativeC40(FX_WCHAR ch) { + return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z'); +} +FX_BOOL CBC_HighLevelEncoder::isNativeText(FX_WCHAR ch) { + return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z'); +} +FX_BOOL CBC_HighLevelEncoder::isNativeX12(FX_WCHAR ch) { + return isX12TermSep(ch) || (ch == ' ') || (ch >= '0' && ch <= '9') || + (ch >= 'A' && ch <= 'Z'); +} +FX_BOOL CBC_HighLevelEncoder::isX12TermSep(FX_WCHAR ch) { + return (ch == '\r') || (ch == '*') || (ch == '>'); +} +FX_BOOL CBC_HighLevelEncoder::isNativeEDIFACT(FX_WCHAR ch) { + return ch >= ' ' && ch <= '^'; +} +FX_BOOL CBC_HighLevelEncoder::isSpecialB256(FX_WCHAR ch) { + return FALSE; +} diff --git a/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h new file mode 100644 index 0000000000..0aad4d4da5 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h @@ -0,0 +1,76 @@ +// 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_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ + +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +#define ASCII_ENCODATION 0 +#define C40_ENCODATION 1 +#define TEXT_ENCODATION 2 +#define X12_ENCODATION 3 +#define EDIFACT_ENCODATION 4 +#define BASE256_ENCODATION 5 + +class CBC_HighLevelEncoder : public CBC_SymbolShapeHint { + public: + CBC_HighLevelEncoder(); + virtual ~CBC_HighLevelEncoder(); + CFX_ByteArray& getBytesForMessage(CFX_WideString msg); + static CFX_WideString encodeHighLevel(CFX_WideString msg, + CFX_WideString ecLevel, + int32_t& e); + static CFX_WideString encodeHighLevel(CFX_WideString msg, + CFX_WideString ecLevel, + SymbolShapeHint shape, + CBC_Dimension* minSize, + CBC_Dimension* maxSize, + int32_t& e); + static int32_t lookAheadTest(CFX_WideString msg, + int32_t startpos, + int32_t currentMode); + static FX_BOOL isDigit(FX_WCHAR ch); + static FX_BOOL isExtendedASCII(FX_WCHAR ch); + static int32_t determineConsecutiveDigitCount(CFX_WideString msg, + int32_t startpos); + static void illegalCharacter(FX_WCHAR c, int32_t& e); + + public: + static FX_WCHAR LATCH_TO_C40; + static FX_WCHAR LATCH_TO_BASE256; + static FX_WCHAR UPPER_SHIFT; + static FX_WCHAR LATCH_TO_ANSIX12; + static FX_WCHAR LATCH_TO_TEXT; + static FX_WCHAR LATCH_TO_EDIFACT; + static FX_WCHAR C40_UNLATCH; + static FX_WCHAR X12_UNLATCH; + + private: + static FX_WCHAR PAD; + static FX_WCHAR MACRO_05; + static FX_WCHAR MACRO_06; + static const wchar_t* MACRO_05_HEADER; + static const wchar_t* MACRO_06_HEADER; + static const wchar_t MACRO_TRAILER; + CFX_ByteArray m_bytearray; + + private: + static FX_WCHAR randomize253State(FX_WCHAR ch, int32_t codewordPosition); + static int32_t findMinimums(CFX_FloatArray& charCounts, + CFX_Int32Array& intCharCounts, + int32_t min, + CFX_ByteArray& mins); + static int32_t getMinimumCount(CFX_ByteArray& mins); + static FX_BOOL isNativeC40(FX_WCHAR ch); + static FX_BOOL isNativeText(FX_WCHAR ch); + static FX_BOOL isNativeX12(FX_WCHAR ch); + static FX_BOOL isX12TermSep(FX_WCHAR ch); + static FX_BOOL isNativeEDIFACT(FX_WCHAR ch); + static FX_BOOL isSpecialB256(FX_WCHAR ch); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp new file mode 100644 index 0000000000..593f4cb162 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp @@ -0,0 +1,255 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +#define SYMBOLS_COUNT 30 + +CBC_SymbolInfo* CBC_SymbolInfo::m_PROD_SYMBOLS[30] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +CBC_SymbolInfo* CBC_SymbolInfo::m_symbols[30] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +void CBC_SymbolInfo::Initialize() { + m_PROD_SYMBOLS[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1); + m_PROD_SYMBOLS[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1); + m_PROD_SYMBOLS[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1); + m_PROD_SYMBOLS[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1); + m_PROD_SYMBOLS[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2); + m_PROD_SYMBOLS[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1); + m_PROD_SYMBOLS[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1); + m_PROD_SYMBOLS[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1); + m_PROD_SYMBOLS[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1); + m_PROD_SYMBOLS[9] = new CBC_SymbolInfo(TRUE, 22, 18, 16, 10, 2); + m_PROD_SYMBOLS[10] = new CBC_SymbolInfo(FALSE, 30, 20, 20, 20, 1); + m_PROD_SYMBOLS[11] = new CBC_SymbolInfo(TRUE, 32, 24, 16, 14, 2); + m_PROD_SYMBOLS[12] = new CBC_SymbolInfo(FALSE, 36, 24, 22, 22, 1); + m_PROD_SYMBOLS[13] = new CBC_SymbolInfo(FALSE, 44, 28, 24, 24, 1); + m_PROD_SYMBOLS[14] = new CBC_SymbolInfo(TRUE, 49, 28, 22, 14, 2); + m_PROD_SYMBOLS[15] = new CBC_SymbolInfo(FALSE, 62, 36, 14, 14, 4); + m_PROD_SYMBOLS[16] = new CBC_SymbolInfo(FALSE, 86, 42, 16, 16, 4); + m_PROD_SYMBOLS[17] = new CBC_SymbolInfo(FALSE, 114, 48, 18, 18, 4); + m_PROD_SYMBOLS[18] = new CBC_SymbolInfo(FALSE, 144, 56, 20, 20, 4); + m_PROD_SYMBOLS[19] = new CBC_SymbolInfo(FALSE, 174, 68, 22, 22, 4); + m_PROD_SYMBOLS[20] = new CBC_SymbolInfo(FALSE, 204, 84, 24, 24, 4, 102, 42); + m_PROD_SYMBOLS[21] = new CBC_SymbolInfo(FALSE, 280, 112, 14, 14, 16, 140, 56); + m_PROD_SYMBOLS[22] = new CBC_SymbolInfo(FALSE, 368, 144, 16, 16, 16, 92, 36); + m_PROD_SYMBOLS[23] = new CBC_SymbolInfo(FALSE, 456, 192, 18, 18, 16, 114, 48); + m_PROD_SYMBOLS[24] = new CBC_SymbolInfo(FALSE, 576, 224, 20, 20, 16, 144, 56); + m_PROD_SYMBOLS[25] = new CBC_SymbolInfo(FALSE, 696, 272, 22, 22, 16, 174, 68); + m_PROD_SYMBOLS[26] = new CBC_SymbolInfo(FALSE, 816, 336, 24, 24, 16, 136, 56); + m_PROD_SYMBOLS[27] = + new CBC_SymbolInfo(FALSE, 1050, 408, 18, 18, 36, 175, 68); + m_PROD_SYMBOLS[28] = + new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62); + m_PROD_SYMBOLS[29] = new CBC_DataMatrixSymbolInfo144(); + for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { + m_symbols[i] = m_PROD_SYMBOLS[i]; + } +} +void CBC_SymbolInfo::Finalize() { + for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { + delete m_PROD_SYMBOLS[i]; + m_PROD_SYMBOLS[i] = NULL; + m_symbols[i] = NULL; + } +} +CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, + int32_t dataCapacity, + int32_t errorCodewords, + int32_t matrixWidth, + int32_t matrixHeight, + int32_t dataRegions) { + m_rectangular = rectangular; + m_dataCapacity = dataCapacity; + m_errorCodewords = errorCodewords; + m_matrixWidth = matrixWidth; + m_matrixHeight = matrixHeight; + m_dataRegions = dataRegions; + m_rsBlockData = dataCapacity; + m_rsBlockError = errorCodewords; +} +CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, + int32_t dataCapacity, + int32_t errorCodewords, + int32_t matrixWidth, + int32_t matrixHeight, + int32_t dataRegions, + int32_t rsBlockData, + int32_t rsBlockError) { + m_rectangular = rectangular; + m_dataCapacity = dataCapacity; + m_errorCodewords = errorCodewords; + m_matrixWidth = matrixWidth; + m_matrixHeight = matrixHeight; + m_dataRegions = dataRegions; + m_rsBlockData = rsBlockData; + m_rsBlockError = rsBlockError; +} +CBC_SymbolInfo::~CBC_SymbolInfo() {} + +CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, int32_t& e) { + return lookup(dataCodewords, FORCE_NONE, TRUE, e); +} +CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, + SymbolShapeHint shape, + int32_t& e) { + return lookup(dataCodewords, shape, TRUE, e); +} +CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, + FX_BOOL allowRectangular, + FX_BOOL fail, + int32_t& e) { + SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; + return lookup(dataCodewords, shape, fail, e); +} +CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, + SymbolShapeHint shape, + FX_BOOL fail, + int32_t& e) { + return lookup(dataCodewords, shape, NULL, NULL, fail, e); +} +CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, + SymbolShapeHint shape, + CBC_Dimension* minSize, + CBC_Dimension* maxSize, + FX_BOOL fail, + int32_t& e) { + for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { + CBC_SymbolInfo* symbol = m_symbols[i]; + if (shape == FORCE_SQUARE && symbol->m_rectangular) { + continue; + } + if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { + continue; + } + if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || + symbol->getSymbolHeight(e) < minSize->getHeight())) { + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + continue; + } + if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() || + symbol->getSymbolHeight(e) > maxSize->getHeight())) { + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + continue; + } + if (dataCodewords <= symbol->m_dataCapacity) { + return symbol; + } + } + if (fail) { + e = BCExceptionIllegalDataCodewords; + return NULL; + } + return NULL; +} +int32_t CBC_SymbolInfo::getHorizontalDataRegions(int32_t& e) { + switch (m_dataRegions) { + case 1: + return 1; + case 2: + return 2; + case 4: + return 2; + case 16: + return 4; + case 36: + return 6; + default: + e = BCExceptionCannotHandleThisNumberOfDataRegions; + return 0; + } +} +int32_t CBC_SymbolInfo::getVerticalDataRegions(int32_t& e) { + switch (m_dataRegions) { + case 1: + return 1; + case 2: + return 1; + case 4: + return 2; + case 16: + return 4; + case 36: + return 6; + default: + e = BCExceptionCannotHandleThisNumberOfDataRegions; + return 0; + } +} +int32_t CBC_SymbolInfo::getSymbolDataWidth(int32_t& e) { + return getHorizontalDataRegions(e) * m_matrixWidth; +} +int32_t CBC_SymbolInfo::getSymbolDataHeight(int32_t& e) { + return getVerticalDataRegions(e) * m_matrixHeight; +} +int32_t CBC_SymbolInfo::getSymbolWidth(int32_t& e) { + return getSymbolDataWidth(e) + (getHorizontalDataRegions(e) * 2); +} +int32_t CBC_SymbolInfo::getSymbolHeight(int32_t& e) { + return getSymbolDataHeight(e) + (getVerticalDataRegions(e) * 2); +} +int32_t CBC_SymbolInfo::getCodewordCount() { + return m_dataCapacity + m_errorCodewords; +} +int32_t CBC_SymbolInfo::getInterleavedBlockCount() { + return m_dataCapacity / m_rsBlockData; +} +int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { + return m_rsBlockData; +} +int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { + return m_rsBlockError; +} +CFX_WideString CBC_SymbolInfo::toString(int32_t& e) { + CFX_WideString sb; + sb += (FX_WCHAR*)(m_rectangular ? "Rectangular Symbol:" : "Square Symbol:"); + sb += (FX_WCHAR*)" data region "; + sb += m_matrixWidth; + sb += (FX_WCHAR)'x'; + sb += m_matrixHeight; + sb += (FX_WCHAR*)", symbol size "; + sb += getSymbolWidth(e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + sb += (FX_WCHAR)'x'; + sb += getSymbolHeight(e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + sb += (FX_WCHAR*)", symbol data size "; + sb += getSymbolDataWidth(e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + sb += (FX_WCHAR)'x'; + sb += getSymbolDataHeight(e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); + sb += (FX_WCHAR*)", codewords "; + sb += m_dataCapacity; + sb += (FX_WCHAR)'+'; + sb += m_errorCodewords; + return sb; +} diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.h b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.h new file mode 100644 index 0000000000..8f7ed28da9 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.h @@ -0,0 +1,83 @@ +// 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_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +class CBC_Dimension; + +class CBC_SymbolInfo : public CBC_SymbolShapeHint { + public: + CBC_SymbolInfo(FX_BOOL rectangular, + int32_t dataCapacity, + int32_t errorCodewords, + int32_t matrixWidth, + int32_t matrixHeight, + int32_t dataRegions); + virtual ~CBC_SymbolInfo(); + static void Initialize(); + static void Finalize(); + static void overrideSymbolSet(CBC_SymbolInfo* override); + static CBC_SymbolInfo* lookup(int32_t dataCodewords, int32_t& e); + static CBC_SymbolInfo* lookup(int32_t dataCodewords, + SymbolShapeHint shape, + int32_t& e); + static CBC_SymbolInfo* lookup(int32_t dataCodewords, + FX_BOOL allowRectangular, + FX_BOOL fail, + int32_t& e); + static CBC_SymbolInfo* lookup(int32_t dataCodewords, + SymbolShapeHint shape, + FX_BOOL fail, + int32_t& e); + static CBC_SymbolInfo* lookup(int32_t dataCodewords, + SymbolShapeHint shape, + CBC_Dimension* minSize, + CBC_Dimension* maxSize, + FX_BOOL fail, + int32_t& e); + int32_t getHorizontalDataRegions(int32_t& e); + int32_t getVerticalDataRegions(int32_t& e); + int32_t getSymbolDataWidth(int32_t& e); + int32_t getSymbolDataHeight(int32_t& e); + int32_t getSymbolWidth(int32_t& e); + int32_t getSymbolHeight(int32_t& e); + int32_t getCodewordCount(); + int32_t getInterleavedBlockCount(); + int32_t getDataLengthForInterleavedBlock(int32_t index); + int32_t getErrorLengthForInterleavedBlock(int32_t index); + CFX_WideString toString(int32_t& e); + + public: + int32_t m_dataCapacity; + int32_t m_errorCodewords; + int32_t m_matrixWidth; + int32_t m_matrixHeight; + int32_t m_rsBlockData; + int32_t m_rsBlockError; + static CBC_SymbolInfo* m_PROD_SYMBOLS[30]; + + private: + static CBC_SymbolInfo* m_symbols[30]; + FX_BOOL m_rectangular; + int32_t m_dataRegions; + + private: + CBC_SymbolInfo(FX_BOOL rectangular, + int32_t dataCapacity, + int32_t errorCodewords, + int32_t matrixWidth, + int32_t matrixHeight, + int32_t dataRegions, + int32_t rsBlockData, + int32_t rsBlockError); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp b/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp new file mode 100644 index 0000000000..8f91dd837a --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp @@ -0,0 +1,26 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" + +CBC_SymbolShapeHint::CBC_SymbolShapeHint() {} +CBC_SymbolShapeHint::~CBC_SymbolShapeHint() {} diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h b/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h new file mode 100644 index 0000000000..5dfac0516f --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h @@ -0,0 +1,21 @@ +// 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_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ + +class CBC_SymbolShapeHint { + public: + CBC_SymbolShapeHint(); + virtual ~CBC_SymbolShapeHint(); + enum SymbolShapeHint { + FORCE_NONE, + FORCE_SQUARE, + FORCE_RECTANGLE, + }; +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp b/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp new file mode 100644 index 0000000000..c8b37e9c85 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_TextEncoder.cpp @@ -0,0 +1,98 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" +#include "xfa/fxbarcode/datamatrix/BC_TextEncoder.h" + +CBC_TextEncoder::CBC_TextEncoder() {} +CBC_TextEncoder::~CBC_TextEncoder() {} +int32_t CBC_TextEncoder::getEncodingMode() { + return TEXT_ENCODATION; +} +int32_t CBC_TextEncoder::encodeChar(FX_WCHAR c, + CFX_WideString& sb, + int32_t& e) { + if (c == ' ') { + sb += (FX_WCHAR)'\3'; + return 1; + } + if (c >= '0' && c <= '9') { + sb += (FX_WCHAR)(c - 48 + 4); + return 1; + } + if (c >= 'a' && c <= 'z') { + sb += (FX_WCHAR)(c - 97 + 14); + return 1; + } + if (c <= 0x1f) { + sb += (FX_WCHAR)'\0'; + sb += c; + return 2; + } + if (c >= '!' && c <= '/') { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 33); + return 2; + } + if (c >= ':' && c <= '@') { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 58 + 15); + return 2; + } + if (c >= '[' && c <= '_') { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)(c - 91 + 22); + return 2; + } + if (c == 0x0060) { + sb += (FX_WCHAR)'\2'; + sb += (FX_WCHAR)(c - 96); + return 2; + } + if (c >= 'A' && c <= 'Z') { + sb += (FX_WCHAR)'\2'; + sb += (FX_WCHAR)(c - 65 + 1); + return 2; + } + if (c >= '{' && c <= 0x007f) { + sb += (FX_WCHAR)'\2'; + sb += (FX_WCHAR)(c - 123 + 27); + return 2; + } + if (c >= 0x0080) { + sb += (FX_WCHAR)'\1'; + sb += (FX_WCHAR)0x001e; + int32_t len = 2; + len += encodeChar((FX_WCHAR)(c - 128), sb, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + return len; + } + CBC_HighLevelEncoder::illegalCharacter(c, e); + return -1; +} diff --git a/xfa/fxbarcode/datamatrix/BC_TextEncoder.h b/xfa/fxbarcode/datamatrix/BC_TextEncoder.h new file mode 100644 index 0000000000..1f97f3f8c6 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_TextEncoder.h @@ -0,0 +1,19 @@ +// 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_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ + +class CBC_TextEncoder; +class CBC_TextEncoder : public CBC_C40Encoder { + public: + CBC_TextEncoder(); + virtual ~CBC_TextEncoder(); + int32_t getEncodingMode(); + int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ diff --git a/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp b/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp new file mode 100644 index 0000000000..9ebfc46700 --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_X12Encoder.cpp @@ -0,0 +1,100 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006-2007 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Dimension.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/datamatrix/BC_C40Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_Encoder.h" +#include "xfa/fxbarcode/datamatrix/BC_EncoderContext.h" +#include "xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h" +#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h" +#include "xfa/fxbarcode/datamatrix/BC_X12Encoder.h" + +CBC_X12Encoder::CBC_X12Encoder() {} +CBC_X12Encoder::~CBC_X12Encoder() {} +int32_t CBC_X12Encoder::getEncodingMode() { + return X12_ENCODATION; +} +void CBC_X12Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { + CFX_WideString buffer; + while (context.hasMoreCharacters()) { + FX_WCHAR c = context.getCurrentChar(); + context.m_pos++; + encodeChar(c, buffer, e); + if (e != BCExceptionNO) { + return; + } + int32_t count = buffer.GetLength(); + if ((count % 3) == 0) { + writeNextTriplet(context, buffer); + int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( + context.m_msg, context.m_pos, getEncodingMode()); + if (newMode != getEncodingMode()) { + context.signalEncoderChange(newMode); + break; + } + } + } + handleEOD(context, buffer, e); +} +void CBC_X12Encoder::handleEOD(CBC_EncoderContext& context, + CFX_WideString& buffer, + int32_t& e) { + context.updateSymbolInfo(e); + if (e != BCExceptionNO) { + return; + } + int32_t available = + context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); + int32_t count = buffer.GetLength(); + if (count == 2) { + context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); + context.m_pos -= 2; + context.signalEncoderChange(ASCII_ENCODATION); + } else if (count == 1) { + context.m_pos--; + if (available > 1) { + context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); + } + context.signalEncoderChange(ASCII_ENCODATION); + } +} +int32_t CBC_X12Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { + if (c == '\r') { + sb += (FX_WCHAR)'\0'; + } else if (c == '*') { + sb += (FX_WCHAR)'\1'; + } else if (c == '>') { + sb += (FX_WCHAR)'\2'; + } else if (c == ' ') { + sb += (FX_WCHAR)'\3'; + } else if (c >= '0' && c <= '9') { + sb += (FX_WCHAR)(c - 48 + 4); + } else if (c >= 'A' && c <= 'Z') { + sb += (FX_WCHAR)(c - 65 + 14); + } else { + CBC_HighLevelEncoder::illegalCharacter(c, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + } + return 1; +} diff --git a/xfa/fxbarcode/datamatrix/BC_X12Encoder.h b/xfa/fxbarcode/datamatrix/BC_X12Encoder.h new file mode 100644 index 0000000000..5dccbb1d6f --- /dev/null +++ b/xfa/fxbarcode/datamatrix/BC_X12Encoder.h @@ -0,0 +1,24 @@ +// 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_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ +#define XFA_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ + +class CBC_C40Encoder; +class CBC_X12Encoder; +class CBC_X12Encoder : public CBC_C40Encoder { + public: + CBC_X12Encoder(); + virtual ~CBC_X12Encoder(); + int32_t getEncodingMode(); + void Encode(CBC_EncoderContext& context, int32_t& e); + void handleEOD(CBC_EncoderContext& context, + CFX_WideString& buffer, + int32_t& e); + int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); +}; + +#endif // XFA_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ diff --git a/xfa/fxbarcode/oned/BC_OneDReader.cpp b/xfa/fxbarcode/oned/BC_OneDReader.cpp new file mode 100644 index 0000000000..c66ec0bebd --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDReader.cpp @@ -0,0 +1,175 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <algorithm> +#include <memory> + +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/utils.h" + +CBC_OneDReader::CBC_OneDReader() {} +CBC_OneDReader::~CBC_OneDReader() {} +CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { + CFX_ByteString strtemp = Decode(image, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return strtemp; +} +CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + CFX_ByteString strtemp = DeDecode(image, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return strtemp; +} +CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + int32_t height = image->GetHeight(); + int32_t middle = height >> 1; + FX_BOOL tryHarder = FALSE; + int32_t rowStep = std::max(1, height >> (tryHarder ? 8 : 5)); + int32_t maxLines; + if (tryHarder) { + maxLines = height; + } else { + maxLines = 15; + } + for (int32_t x = 0; x < maxLines; x++) { + int32_t rowStepsAboveOrBelow = (x + 1) >> 1; + const bool isAbove = (x & 0x01) == 0; + int32_t rowNumber = + middle + + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow); + if (rowNumber < 0 || rowNumber >= height) { + break; + } + std::unique_ptr<CBC_CommonBitArray> row( + image->GetBlackRow(rowNumber, nullptr, e)); + if (e != BCExceptionNO) { + e = BCExceptionNO; + continue; + } + for (int32_t attempt = 0; attempt < 2; attempt++) { + if (attempt == 1) { + row->Reverse(); + } + CFX_ByteString result = DecodeRow(rowNumber, row.get(), hints, e); + if (e != BCExceptionNO) { + e = BCExceptionNO; + continue; + } + return result; + } + } + e = BCExceptionNotFound; + return ""; +} +void CBC_OneDReader::RecordPattern(CBC_CommonBitArray* row, + int32_t start, + CFX_Int32Array* counters, + int32_t& e) { + int32_t numCounters = counters->GetSize(); + for (int32_t i = 0; i < numCounters; i++) { + (*counters)[i] = 0; + } + int32_t end = row->GetSize(); + if (start >= end) { + e = BCExceptionNotFound; + return; + } + FX_BOOL isWhite = !row->Get(start); + int32_t counterPosition = 0; + int32_t j = start; + while (j < end) { + FX_BOOL pixel = row->Get(j); + if (pixel ^ isWhite) { + (*counters)[counterPosition]++; + } else { + counterPosition++; + if (counterPosition == numCounters) { + break; + } else { + (*counters)[counterPosition] = 1; + isWhite = !isWhite; + } + } + j++; + } + if (!(counterPosition == numCounters || + (counterPosition == numCounters - 1 && j == end))) { + e = BCExceptionNotFound; + return; + } +} +void CBC_OneDReader::RecordPatternInReverse(CBC_CommonBitArray* row, + int32_t start, + CFX_Int32Array* counters, + int32_t& e) { + int32_t numTransitionsLeft = counters->GetSize(); + FX_BOOL last = row->Get(start); + while (start > 0 && numTransitionsLeft >= 0) { + if (row->Get(--start) != last) { + numTransitionsLeft--; + last = !last; + } + } + if (numTransitionsLeft >= 0) { + e = BCExceptionNotFound; + return; + } + RecordPattern(row, start + 1, counters, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +int32_t CBC_OneDReader::PatternMatchVariance(CFX_Int32Array* counters, + const int32_t* pattern, + int32_t maxIndividualVariance) { + int32_t numCounters = counters->GetSize(); + int32_t total = 0; + int32_t patternLength = 0; + for (int32_t i = 0; i < numCounters; i++) { + total += (*counters)[i]; + patternLength += pattern[i]; + } + if (total < patternLength) { +#undef max + return FXSYS_IntMax; + } + int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength; + maxIndividualVariance = + (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT; + int32_t totalVariance = 0; + for (int32_t x = 0; x < numCounters; x++) { + int32_t counter = (*counters)[x] << INTEGER_MATH_SHIFT; + int32_t scaledPattern = pattern[x] * unitBarWidth; + int32_t variance = counter > scaledPattern ? counter - scaledPattern + : scaledPattern - counter; + if (variance > maxIndividualVariance) { +#undef max + return FXSYS_IntMax; + } + totalVariance += variance; + } + return totalVariance / total; +} diff --git a/xfa/fxbarcode/oned/BC_OneDReader.h b/xfa/fxbarcode/oned/BC_OneDReader.h new file mode 100644 index 0000000000..2bab06e9b8 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDReader.h @@ -0,0 +1,50 @@ +// 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_FXBARCODE_ONED_BC_ONEDREADER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDREADER_H_ + +#include "xfa/fxbarcode/BC_Reader.h" + +class CBC_BinaryBitmap; +class CBC_CommonBitArray; + +class CBC_OneDReader : public CBC_Reader { + public: + CBC_OneDReader(); + virtual ~CBC_OneDReader(); + virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); + virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e); + virtual CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + return ""; + } + + private: + CFX_ByteString DeDecode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); + + protected: + static const int32_t INTEGER_MATH_SHIFT = 8; + static const int32_t PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << 8; + + void RecordPattern(CBC_CommonBitArray* row, + int32_t start, + CFX_Int32Array* counters, + int32_t& e); + void RecordPatternInReverse(CBC_CommonBitArray* row, + int32_t start, + CFX_Int32Array* counters, + int32_t& e); + int32_t PatternMatchVariance(CFX_Int32Array* counters, + const int32_t* pattern, + int32_t maxIndividualVariance); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDREADER_H_ diff --git a/xfa/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/fxbarcode/oned/BC_OneDimReader.cpp new file mode 100644 index 0000000000..5187c34af9 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDimReader.cpp @@ -0,0 +1,219 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" + +#include <memory> + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_OneDimReader::START_END_PATTERN[3] = {1, 1, 1}; +const int32_t CBC_OneDimReader::MIDDLE_PATTERN[5] = {1, 1, 1, 1, 1}; +const int32_t CBC_OneDimReader::L_PATTERNS[10][4] = { + {3, 2, 1, 1}, {2, 2, 2, 1}, {2, 1, 2, 2}, {1, 4, 1, 1}, {1, 1, 3, 2}, + {1, 2, 3, 1}, {1, 1, 1, 4}, {1, 3, 1, 2}, {1, 2, 1, 3}, {3, 1, 1, 2}}; +const int32_t CBC_OneDimReader::L_AND_G_PATTERNS[20][4] = { + {3, 2, 1, 1}, {2, 2, 2, 1}, {2, 1, 2, 2}, {1, 4, 1, 1}, {1, 1, 3, 2}, + {1, 2, 3, 1}, {1, 1, 1, 4}, {1, 3, 1, 2}, {1, 2, 1, 3}, {3, 1, 1, 2}, + {1, 1, 2, 3}, {1, 2, 2, 2}, {2, 2, 1, 2}, {1, 1, 4, 1}, {2, 3, 1, 1}, + {1, 3, 2, 1}, {4, 1, 1, 1}, {2, 1, 3, 1}, {3, 1, 2, 1}, {2, 1, 1, 3}}; + +CBC_OneDimReader::CBC_OneDimReader() {} +CBC_OneDimReader::~CBC_OneDimReader() {} +CFX_Int32Array* CBC_OneDimReader::FindStartGuardPattern(CBC_CommonBitArray* row, + int32_t& e) { + FX_BOOL foundStart = FALSE; + CFX_Int32Array* startRange = NULL; + CFX_Int32Array startEndPattern; + startEndPattern.SetSize(3); + startEndPattern[0] = START_END_PATTERN[0]; + startEndPattern[1] = START_END_PATTERN[1]; + startEndPattern[2] = START_END_PATTERN[2]; + int32_t nextStart = 0; + while (!foundStart) { + delete startRange; + startRange = FindGuardPattern(row, nextStart, FALSE, &startEndPattern, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t start = (*startRange)[0]; + nextStart = (*startRange)[1]; + if (start <= 1) { + break; + } + int32_t quietStart = start - (nextStart - start); + if (quietStart >= 0) { + FX_BOOL booT = row->IsRange(quietStart, start, FALSE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + foundStart = booT; + } + } + return startRange; +} +CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + std::unique_ptr<CFX_Int32Array> result(FindStartGuardPattern(row, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CFX_ByteString temp = DecodeRow(rowNumber, row, result.get(), hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return temp; +} +CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + CFX_Int32Array* startGuardRange, + int32_t hints, + int32_t& e) { + CFX_ByteString result; + DecodeMiddle(row, startGuardRange, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + FX_BOOL b = CheckChecksum(result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + if (!b) { + e = BCExceptionChecksumException; + return ""; + } + return result; +} +FX_BOOL CBC_OneDimReader::CheckChecksum(CFX_ByteString& s, int32_t& e) { + FX_BOOL temp = CheckStandardUPCEANChecksum(s, e); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + return temp; +} +FX_BOOL CBC_OneDimReader::CheckStandardUPCEANChecksum(CFX_ByteString& s, + int32_t& e) { + int32_t length = s.GetLength(); + if (length == 0) { + return FALSE; + } + int32_t sum = 0; + for (int32_t i = length - 2; i >= 0; i -= 2) { + int32_t digit = (int32_t)s[i] - (int32_t)'0'; + if (digit < 0 || digit > 9) { + e = BCExceptionFormatException; + return FALSE; + } + sum += digit; + } + sum *= 3; + for (int32_t j = length - 1; j >= 0; j -= 2) { + int32_t digit = (int32_t)s[j] - (int32_t)'0'; + if (digit < 0 || digit > 9) { + e = BCExceptionFormatException; + return FALSE; + } + sum += digit; + } + return sum % 10 == 0; +} +CFX_Int32Array* CBC_OneDimReader::DecodeEnd(CBC_CommonBitArray* row, + int32_t endStart, + int32_t& e) { + CFX_Int32Array startEndPattern; + startEndPattern.Add(START_END_PATTERN[0]); + startEndPattern.Add(START_END_PATTERN[1]); + startEndPattern.Add(START_END_PATTERN[2]); + CFX_Int32Array* FindGuard = + FindGuardPattern(row, endStart, FALSE, &startEndPattern, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return FindGuard; +} +CFX_Int32Array* CBC_OneDimReader::FindGuardPattern(CBC_CommonBitArray* row, + int32_t rowOffset, + FX_BOOL whiteFirst, + CFX_Int32Array* pattern, + int32_t& e) { + int32_t patternLength = pattern->GetSize(); + CFX_Int32Array counters; + counters.SetSize(patternLength); + int32_t width = row->GetSize(); + FX_BOOL isWhite = FALSE; + while (rowOffset < width) { + isWhite = !row->Get(rowOffset); + if (whiteFirst == isWhite) { + break; + } + rowOffset++; + } + int32_t counterPosition = 0; + int32_t patternStart = rowOffset; + for (int32_t x = rowOffset; x < width; x++) { + FX_BOOL pixel = row->Get(x); + if (pixel ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + if (PatternMatchVariance(&counters, &(*pattern)[0], + MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { + CFX_Int32Array* result = new CFX_Int32Array(); + result->SetSize(2); + (*result)[0] = patternStart; + (*result)[1] = x; + return result; + } + patternStart += counters[0] + counters[1]; + for (int32_t y = 2; y < patternLength; y++) { + counters[y - 2] = counters[y]; + } + counters[patternLength - 2] = 0; + counters[patternLength - 1] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return NULL; +} +int32_t CBC_OneDimReader::DecodeDigit(CBC_CommonBitArray* row, + CFX_Int32Array* counters, + int32_t rowOffset, + const int32_t* patterns, + int32_t patternLength, + int32_t& e) { + RecordPattern(row, rowOffset, counters, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + int32_t bestVariance = MAX_AVG_VARIANCE; + int32_t bestMatch = -1; + int32_t max = patternLength; + for (int32_t i = 0; i < max; i++) { + int32_t variance = PatternMatchVariance(counters, &patterns[i * 4], + MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = i; + } + } + if (bestMatch >= 0) { + return bestMatch; + } else { + e = BCExceptionNotFound; + return 0; + } + return 0; +} diff --git a/xfa/fxbarcode/oned/BC_OneDimReader.h b/xfa/fxbarcode/oned/BC_OneDimReader.h new file mode 100644 index 0000000000..cc84ffd39a --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDimReader.h @@ -0,0 +1,66 @@ +// 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_FXBARCODE_ONED_BC_ONEDIMREADER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDIMREADER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" + +class CBC_CommonBitArray; + +class CBC_OneDimReader : public CBC_OneDReader { + private: + static const int32_t MAX_AVG_VARIANCE = (int32_t)(256 * 0.48f); + static const int32_t MAX_INDIVIDUAL_VARIANCE = (int32_t)(256 * 0.7f); + + FX_BOOL CheckStandardUPCEANChecksum(CFX_ByteString& s, int32_t& e); + + public: + static const int32_t START_END_PATTERN[3]; + static const int32_t MIDDLE_PATTERN[5]; + static const int32_t L_PATTERNS[10][4]; + static const int32_t L_AND_G_PATTERNS[20][4]; + + CBC_OneDimReader(); + virtual ~CBC_OneDimReader(); + + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e); + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + CFX_Int32Array* startGuardRange, + int32_t hints, + int32_t& e); + + protected: + CFX_Int32Array* FindStartGuardPattern(CBC_CommonBitArray* row, int32_t& e); + virtual FX_BOOL CheckChecksum(CFX_ByteString& s, int32_t& e); + CFX_Int32Array* FindGuardPattern(CBC_CommonBitArray* row, + int32_t rowOffset, + FX_BOOL whiteFirst, + CFX_Int32Array* pattern, + int32_t& e); + int32_t DecodeDigit(CBC_CommonBitArray* row, + CFX_Int32Array* counters, + int32_t rowOffset, + const int32_t* patterns, + int32_t patternLength, + int32_t& e); + virtual int32_t DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultResult, + int32_t& e) { + return 0; + } + virtual CFX_Int32Array* DecodeEnd(CBC_CommonBitArray* row, + int32_t endStart, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDIMREADER_H_ diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp new file mode 100644 index 0000000000..62ca97f488 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -0,0 +1,437 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" + +#include <algorithm> +#include <memory> + +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" + +CBC_OneDimWriter::CBC_OneDimWriter() { + m_locTextLoc = BC_TEXT_LOC_BELOWEMBED; + m_bPrintChecksum = TRUE; + m_iDataLenth = 0; + m_bCalcChecksum = FALSE; + m_pFont = NULL; + m_fFontSize = 10; + m_iFontStyle = 0; + m_fontColor = 0xff000000; + m_iContentLen = 0; + m_bLeftPadding = FALSE; + m_bRightPadding = FALSE; + m_output = NULL; +} +CBC_OneDimWriter::~CBC_OneDimWriter() { + delete m_output; +} +void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) { + m_bPrintChecksum = checksum; +} +void CBC_OneDimWriter::SetDataLength(int32_t length) { + m_iDataLenth = length; +} +void CBC_OneDimWriter::SetCalcChecksum(int32_t state) { + m_bCalcChecksum = state; +} +FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) { + if (cFont == NULL) { + return FALSE; + } + m_pFont = cFont; + return TRUE; +} +void CBC_OneDimWriter::SetFontSize(FX_FLOAT size) { + m_fFontSize = size; +} +void CBC_OneDimWriter::SetFontStyle(int32_t style) { + m_iFontStyle = style; +} +void CBC_OneDimWriter::SetFontColor(FX_ARGB color) { + m_fontColor = color; +} +FX_WCHAR CBC_OneDimWriter::Upper(FX_WCHAR ch) { + if (ch >= 'a' && ch <= 'z') { + ch = ch - ('a' - 'A'); + } + return ch; +} +uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + uint8_t* ret = NULL; + outHeight = 1; + if (m_Width >= 20) { + ret = Encode(contents, outWidth, e); + } else { + ret = Encode(contents, outWidth, e); + } + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +int32_t CBC_OneDimWriter::AppendPattern(uint8_t* target, + int32_t pos, + const int32_t* pattern, + int32_t patternLength, + int32_t startColor, + int32_t& e) { + if (startColor != 0 && startColor != 1) { + e = BCExceptionValueMustBeEither0or1; + return 0; + } + uint8_t color = (uint8_t)startColor; + int32_t numAdded = 0; + for (int32_t i = 0; i < patternLength; i++) { + for (int32_t j = 0; j < pattern[i]; j++) { + target[pos] = color; + pos += 1; + numAdded += 1; + } + color ^= 1; + } + return numAdded; +} +void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, + FXTEXT_CHARPOS* charPos, + CFX_Font* cFont, + FX_FLOAT geWidth, + int32_t fontSize, + FX_FLOAT& charsLen) { + std::unique_ptr<CFX_UnicodeEncodingEx> encoding( + FX_CreateFontEncodingEx(cFont)); + + int32_t length = text.GetLength(); + FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength()); + FX_FLOAT charWidth = 0; + for (int32_t j = 0; j < text.GetLength(); j++) { + pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); + int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); + int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); + FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0); + charWidth += temp; + } + charsLen = charWidth; + FX_FLOAT leftPositon = (FX_FLOAT)(geWidth - charsLen) / 2.0f; + if (leftPositon < 0 && geWidth == 0) { + leftPositon = 0; + } + FX_FLOAT penX = 0.0; + FX_FLOAT penY = + (FX_FLOAT)FXSYS_abs(cFont->GetDescent()) * (FX_FLOAT)fontSize / 1000.0f; + FX_FLOAT left = leftPositon; + FX_FLOAT top = 0.0; + charPos[0].m_OriginX = penX + left; + charPos[0].m_OriginY = penY + top; + charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[0]); + charPos[0].m_FontCharWidth = cFont->GetGlyphWidth(charPos[0].m_GlyphIndex); +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + charPos[0].m_ExtGID = charPos[0].m_GlyphIndex; +#endif + penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; + for (int32_t i = 1; i < length; i++) { + charPos[i].m_OriginX = penX + left; + charPos[i].m_OriginY = penY + top; + charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); + charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + charPos[i].m_ExtGID = charPos[i].m_GlyphIndex; +#endif + penX += + (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; + } + FX_Free(pCharCode); +} +void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, + const CFX_Matrix* matrix, + const CFX_ByteString str, + FX_FLOAT geWidth, + FXTEXT_CHARPOS* pCharPos, + FX_FLOAT locX, + FX_FLOAT locY, + int32_t barWidth) { + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + CFX_FloatRect rect((FX_FLOAT)locX, (FX_FLOAT)locY, (FX_FLOAT)(locX + geWidth), + (FX_FLOAT)(locY + iTextHeight)); + if (geWidth != m_Width) { + rect.right -= 1; + } + matrix->TransformRect(rect); + FX_RECT re = rect.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)locX, + (FX_FLOAT)(locY + iFontSize)); + if (matrix) { + affine_matrix.Concat(*matrix); + } + device->DrawNormalText(str.GetLength(), pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, + m_fontColor, FXTEXT_CLEARTYPE); +} +void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, + const CFX_ByteString str, + FX_FLOAT geWidth, + FXTEXT_CHARPOS* pCharPos, + FX_FLOAT locX, + FX_FLOAT locY, + int32_t barWidth) { + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + CFX_FxgeDevice ge; + ge.Create((int)geWidth, iTextHeight, m_colorSpace); + FX_RECT geRect(0, 0, (int)geWidth, iTextHeight); + ge.FillRect(&geRect, m_backgroundColor); + CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); + ge.DrawNormalText(str.GetLength(), pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); + CFX_FxgeDevice geBitmap; + geBitmap.Attach(pOutBitmap); + geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY); +} +void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { + if (device == NULL && pOutBitmap == NULL) { + e = BCExceptionIllegalArgument; + return; + } + if (m_pFont == NULL) { + e = BCExceptionNullPointer; + return; + } + CFX_ByteString str = FX_UTF8Encode(contents); + int32_t iLen = str.GetLength(); + FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); + FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); + FX_FLOAT charsLen = 0; + FX_FLOAT geWidth = 0; + if (m_locTextLoc == BC_TEXT_LOC_ABOVEEMBED || + m_locTextLoc == BC_TEXT_LOC_BELOWEMBED) { + geWidth = 0; + } else if (m_locTextLoc == BC_TEXT_LOC_ABOVE || + m_locTextLoc == BC_TEXT_LOC_BELOW) { + geWidth = (FX_FLOAT)barWidth; + } + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + CalcTextInfo(str, pCharPos, m_pFont, geWidth, iFontSize, charsLen); + if (charsLen < 1) { + return; + } + int32_t locX = 0; + int32_t locY = 0; + switch (m_locTextLoc) { + case BC_TEXT_LOC_ABOVEEMBED: + locX = (int32_t)(barWidth - charsLen) / 2; + locY = 0; + geWidth = charsLen; + break; + case BC_TEXT_LOC_ABOVE: + locX = 0; + locY = 0; + geWidth = (FX_FLOAT)barWidth; + break; + case BC_TEXT_LOC_BELOWEMBED: + locX = (int32_t)(barWidth - charsLen) / 2; + locY = m_Height - iTextHeight; + geWidth = charsLen; + break; + case BC_TEXT_LOC_BELOW: + default: + locX = 0; + locY = m_Height - iTextHeight; + geWidth = (FX_FLOAT)barWidth; + break; + } + if (device) { + ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (FX_FLOAT)locX, + (FX_FLOAT)locY, barWidth); + } else { + ShowBitmapChars(pOutBitmap, str, geWidth, pCharPos, (FX_FLOAT)locX, + (FX_FLOAT)locY, barWidth); + } + FX_Free(pCharPos); +} +void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + const CFX_WideStringC& contents, + int32_t& e) { + if (m_output == NULL) { + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); + pOutBitmap->Clear(m_backgroundColor); + if (!pOutBitmap) { + e = BCExceptionFailToCreateBitmap; + return; + } + for (int32_t x = 0; x < m_output->GetWidth(); x++) { + for (int32_t y = 0; y < m_output->GetHeight(); y++) { + if (m_output->Get(x, y)) { + pOutBitmap->SetPixel(x, y, m_barColor); + } + } + } + int32_t i = 0; + for (; i < contents.GetLength(); i++) + if (contents.GetAt(i) != ' ') { + break; + } + if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { + ShowChars(contents, pOutBitmap, NULL, NULL, m_barWidth, m_multiple, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); + if (pOutBitmap) { + delete pOutBitmap; + } + pOutBitmap = pStretchBitmap; +} +void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, + const CFX_Matrix* matrix, + const CFX_WideStringC& contents, + int32_t& e) { + if (m_output == NULL) { + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + CFX_GraphStateData stateData; + CFX_PathData path; + path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height); + device->DrawPath(&path, matrix, &stateData, m_backgroundColor, + m_backgroundColor, FXFILL_ALTERNATE); + CFX_Matrix matri(m_outputHScale, 0.0, 0.0, (FX_FLOAT)m_Height, 0.0, 0.0); + matri.Concat(*matrix); + for (int32_t x = 0; x < m_output->GetWidth(); x++) { + for (int32_t y = 0; y < m_output->GetHeight(); y++) { + CFX_PathData rect; + rect.AppendRect((FX_FLOAT)x, (FX_FLOAT)y, (FX_FLOAT)(x + 1), + (FX_FLOAT)(y + 1)); + CFX_GraphStateData stateData; + if (m_output->Get(x, y)) { + device->DrawPath(&rect, &matri, &stateData, m_barColor, 0, + FXFILL_WINDING); + } + } + } + int32_t i = 0; + for (; i < contents.GetLength(); i++) + if (contents.GetAt(i) != ' ') { + break; + } + if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { + ShowChars(contents, NULL, device, matrix, m_barWidth, m_multiple, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + if (codeLength < 1) { + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (m_ModuleHeight < 20.0) { + m_ModuleHeight = 20; + } + int32_t codeOldLength = codeLength; + int32_t leftPadding = 0; + int32_t rightPadding = 0; + if (m_bLeftPadding) { + leftPadding = 7; + } + if (m_bRightPadding) { + rightPadding = 7; + } + codeLength += leftPadding; + codeLength += rightPadding; + m_outputHScale = 1.0; + if (m_Width > 0) { + m_outputHScale = (FX_FLOAT)m_Width / (FX_FLOAT)codeLength; + } + if (!isDevice) { + m_outputHScale = + std::max(m_outputHScale, static_cast<FX_FLOAT>(m_ModuleWidth)); + } + FX_FLOAT dataLengthScale = 1.0; + if (m_iDataLenth > 0 && contents.GetLength() != 0) { + dataLengthScale = FX_FLOAT(contents.GetLength()) / FX_FLOAT(m_iDataLenth); + } + if (m_iDataLenth > 0 && contents.GetLength() == 0) { + dataLengthScale = FX_FLOAT(1) / FX_FLOAT(m_iDataLenth); + } + m_multiple = 1; + if (!isDevice) { + m_multiple = (int32_t)ceil(m_outputHScale * dataLengthScale); + } + int32_t outputHeight = 1; + if (!isDevice) { + if (m_Height == 0) { + outputHeight = std::max(20, m_ModuleHeight); + } else { + outputHeight = m_Height; + } + } + int32_t outputWidth = codeLength; + if (!isDevice) { + outputWidth = (int32_t)(codeLength * m_multiple / dataLengthScale); + } + m_barWidth = m_Width; + if (!isDevice) { + m_barWidth = codeLength * m_multiple; + } + m_output = new CBC_CommonBitMatrix; + m_output->Init(outputWidth, outputHeight); + int32_t outputX = leftPadding * m_multiple; + for (int32_t inputX = 0; inputX < codeOldLength; inputX++) { + if (code[inputX] == 1) { + if (outputX >= outputWidth) { + break; + } + if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { + m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); + break; + } + m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + outputX += m_multiple; + } +} diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h new file mode 100644 index 0000000000..e91a9297e1 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h @@ -0,0 +1,120 @@ +// 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_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ + +#include "core/include/fxge/fx_ge.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/include/fxbarcode/BC_BarCode.h" + +class CBC_CommonBitMatrix; +class CFX_Font; +class CFX_RenderDevice; + +class CBC_OneDimWriter : public CBC_Writer { + public: + CBC_OneDimWriter(); + virtual ~CBC_OneDimWriter(); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + virtual uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e) { + return NULL; + } + virtual void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + const CFX_WideStringC& contents, + int32_t& e); + virtual void RenderDeviceResult(CFX_RenderDevice* device, + const CFX_Matrix* matrix, + const CFX_WideStringC& contents, + int32_t& e); + virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents) { + return TRUE; + } + virtual CFX_WideString FilterContents(const CFX_WideStringC& contents) { + return CFX_WideString(); + } + virtual CFX_WideString RenderTextContents(const CFX_WideStringC& contents) { + return CFX_WideString(); + } + virtual void SetPrintChecksum(FX_BOOL checksum); + virtual void SetDataLength(int32_t length); + virtual void SetCalcChecksum(int32_t state); + virtual void SetFontSize(FX_FLOAT size); + virtual void SetFontStyle(int32_t style); + virtual void SetFontColor(FX_ARGB color); + virtual FX_BOOL SetFont(CFX_Font* cFont); + + protected: + FX_BOOL m_bPrintChecksum; + int32_t m_iDataLenth; + FX_BOOL m_bCalcChecksum; + CFX_Font* m_pFont; + FX_FLOAT m_fFontSize; + int32_t m_iFontStyle; + FX_DWORD m_fontColor; + BC_TEXT_LOC m_locTextLoc; + int32_t m_iContentLen; + FX_BOOL m_bLeftPadding; + FX_BOOL m_bRightPadding; + CBC_CommonBitMatrix* m_output; + int32_t m_barWidth; + int32_t m_multiple; + FX_FLOAT m_outputHScale; + void CalcTextInfo(const CFX_ByteString& text, + FXTEXT_CHARPOS* charPos, + CFX_Font* cFont, + FX_FLOAT geWidth, + int32_t fontSize, + FX_FLOAT& charsLen); + virtual void ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e); + virtual void ShowBitmapChars(CFX_DIBitmap* pOutBitmap, + const CFX_ByteString str, + FX_FLOAT geWidth, + FXTEXT_CHARPOS* pCharPos, + FX_FLOAT locX, + FX_FLOAT locY, + int32_t barWidth); + virtual void ShowDeviceChars(CFX_RenderDevice* device, + const CFX_Matrix* matrix, + const CFX_ByteString str, + FX_FLOAT geWidth, + FXTEXT_CHARPOS* pCharPos, + FX_FLOAT locX, + FX_FLOAT locY, + int32_t barWidth); + int32_t AppendPattern(uint8_t* target, + int32_t pos, + const int32_t* pattern, + int32_t patternLength, + int32_t startColor, + int32_t& e); + FX_WCHAR Upper(FX_WCHAR ch); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp new file mode 100644 index 0000000000..27f2191eac --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp @@ -0,0 +1,212 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h" + +#include <algorithm> +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h" +#include "xfa/fxbarcode/utils.h" + +const FX_CHAR* CBC_OnedCodaBarReader::ALPHABET_STRING = + "0123456789-$:/.+ABCDTN"; +const int32_t CBC_OnedCodaBarReader::CHARACTER_ENCODINGS[22] = { + 0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, + 0x030, 0x048, 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, + 0x01A, 0x029, 0x00B, 0x00E, 0x01A, 0x029}; +const FX_CHAR CBC_OnedCodaBarReader::STARTEND_ENCODING[8] = { + 'E', '*', 'A', 'B', 'C', 'D', 'T', 'N'}; + +CBC_OnedCodaBarReader::CBC_OnedCodaBarReader() {} +CBC_OnedCodaBarReader::~CBC_OnedCodaBarReader() {} +CFX_ByteString CBC_OnedCodaBarReader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + std::unique_ptr<CFX_Int32Array> start(FindAsteriskPattern(row, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + (*start)[1] = 0; + int32_t nextStart = (*start)[1]; + int32_t end = row->GetSize(); + while (nextStart < end && !row->Get(nextStart)) { + nextStart++; + } + CFX_ByteString result; + CFX_Int32Array counters; + counters.SetSize(7); + FX_CHAR decodedChar; + int32_t lastStart; + do { + RecordPattern(row, nextStart, &counters, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + decodedChar = ToNarrowWidePattern(&counters); + if (decodedChar == '!') { + e = BCExceptionNotFound; + return ""; + } + result += decodedChar; + lastStart = nextStart; + for (int32_t i = 0; i < counters.GetSize(); i++) { + nextStart += counters[i]; + } + while (nextStart < end && !row->Get(nextStart)) { + nextStart++; + } + } while (nextStart < end); + int32_t lastPatternSize = 0; + for (int32_t j = 0; j < counters.GetSize(); j++) { + lastPatternSize += counters[j]; + } + int32_t whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; + if (nextStart != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) { + e = BCExceptionNotFound; + return ""; + } + if (result.GetLength() < 2) { + e = BCExceptionNotFound; + return ""; + } + FX_CHAR startchar = result[0]; + if (!ArrayContains(STARTEND_ENCODING, startchar)) { + e = BCExceptionNotFound; + return ""; + } + int32_t len = result.GetLength(); + CFX_ByteString temp = result; + for (int32_t k = 1; k < result.GetLength(); k++) { + if (ArrayContains(STARTEND_ENCODING, result[k])) { + if ((k + 1) != result.GetLength()) { + result.Delete(1, k); + k = 1; + } + } + } + if (result.GetLength() < 5) { + int32_t index = temp.Find(result.Mid(1, result.GetLength() - 1)); + if (index == len - (result.GetLength() - 1)) { + e = BCExceptionNotFound; + return ""; + } + } + if (result.GetLength() > minCharacterLength) { + result = result.Mid(1, result.GetLength() - 2); + } else { + e = BCExceptionNotFound; + return ""; + } + return result; +} +CFX_Int32Array* CBC_OnedCodaBarReader::FindAsteriskPattern( + CBC_CommonBitArray* row, + int32_t& e) { + int32_t width = row->GetSize(); + int32_t rowOffset = 0; + while (rowOffset < width) { + if (row->Get(rowOffset)) { + break; + } + rowOffset++; + } + int32_t counterPosition = 0; + CFX_Int32Array counters; + counters.SetSize(7); + int32_t patternStart = rowOffset; + FX_BOOL isWhite = FALSE; + int32_t patternLength = counters.GetSize(); + for (int32_t i = rowOffset; i < width; i++) { + FX_BOOL pixel = row->Get(i); + if (pixel ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + if (ArrayContains(STARTEND_ENCODING, ToNarrowWidePattern(&counters))) { + FX_BOOL btemp3 = + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), + patternStart, FALSE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (btemp3) { + CFX_Int32Array* result = new CFX_Int32Array(); + result->SetSize(2); + (*result)[0] = patternStart; + (*result)[1] = i; + return result; + } + } + patternStart += counters[0] + counters[1]; + for (int32_t y = 2; y < patternLength; y++) { + counters[y - 2] = counters[y]; + } + counters[patternLength - 2] = 0; + counters[patternLength - 1] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + e = BCExceptionNotFound; + return NULL; +} +FX_BOOL CBC_OnedCodaBarReader::ArrayContains(const FX_CHAR array[], + FX_CHAR key) { + for (int32_t i = 0; i < 8; i++) { + if (array[i] == key) { + return TRUE; + } + } + return FALSE; +} +FX_CHAR CBC_OnedCodaBarReader::ToNarrowWidePattern(CFX_Int32Array* counter) { + int32_t numCounters = counter->GetSize(); + if (numCounters < 1) { + return '!'; + } + int32_t averageCounter = 0; + int32_t totalCounters = 0; + for (int32_t i = 0; i < numCounters; i++) { + totalCounters += (*counter)[i]; + } + averageCounter = totalCounters / numCounters; + int32_t pattern = 0; + int32_t wideCounters = 0; + for (int32_t j = 0; j < numCounters; j++) { + if ((*counter)[j] > averageCounter) { + pattern |= 1 << (numCounters - 1 - j); + wideCounters++; + } + } + if ((wideCounters == 2) || (wideCounters == 3)) { + for (int32_t k = 0; k < 22; k++) { + if (CHARACTER_ENCODINGS[k] == pattern) { + return (ALPHABET_STRING)[k]; + } + } + } + return '!'; +} diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarReader.h b/xfa/fxbarcode/oned/BC_OnedCodaBarReader.h new file mode 100644 index 0000000000..678795dcf3 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarReader.h @@ -0,0 +1,36 @@ +// 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_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" + +class CBC_CommonBitArray; +class CBC_OneDReader; + +class CBC_OnedCodaBarReader : public CBC_OneDReader { + public: + CBC_OnedCodaBarReader(); + virtual ~CBC_OnedCodaBarReader(); + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e); + CFX_Int32Array* FindAsteriskPattern(CBC_CommonBitArray* row, int32_t& e); + FX_BOOL ArrayContains(const FX_CHAR array[], FX_CHAR key); + FX_CHAR ToNarrowWidePattern(CFX_Int32Array* counter); + + static const FX_CHAR* ALPHABET_STRING; + static const int32_t CHARACTER_ENCODINGS[22]; + + private: + static const int32_t minCharacterLength = 3; + static const FX_CHAR STARTEND_ENCODING[8]; +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp new file mode 100644 index 0000000000..81f0339aa8 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -0,0 +1,231 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCodaBarReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h" + +const FX_CHAR CBC_OnedCodaBarWriter::START_END_CHARS[] = { + 'A', 'B', 'C', 'D', 'T', 'N', '*', 'E', 'a', 'b', 'c', 'd', 't', 'n', 'e'}; +const FX_CHAR CBC_OnedCodaBarWriter::CONTENT_CHARS[] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '-', '$', '/', ':', '+', '.'}; + +CBC_OnedCodaBarWriter::CBC_OnedCodaBarWriter() { + m_chStart = 'A'; + m_chEnd = 'B'; + m_iWideNarrRatio = 2; +} +CBC_OnedCodaBarWriter::~CBC_OnedCodaBarWriter() {} +FX_BOOL CBC_OnedCodaBarWriter::SetStartChar(FX_CHAR start) { + for (size_t i = 0; i < FX_ArraySize(START_END_CHARS); ++i) { + if (START_END_CHARS[i] == start) { + m_chStart = start; + return TRUE; + } + } + return FALSE; +} + +FX_BOOL CBC_OnedCodaBarWriter::SetEndChar(FX_CHAR end) { + for (size_t i = 0; i < FX_ArraySize(START_END_CHARS); ++i) { + if (START_END_CHARS[i] == end) { + m_chEnd = end; + return TRUE; + } + } + return FALSE; +} +void CBC_OnedCodaBarWriter::SetDataLength(int32_t length) { + m_iDataLenth = length + 2; +} +FX_BOOL CBC_OnedCodaBarWriter::SetTextLocation(BC_TEXT_LOC location) { + if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { + return FALSE; + } + m_locTextLoc = location; + return TRUE; +} +FX_BOOL CBC_OnedCodaBarWriter::SetWideNarrowRatio(int32_t ratio) { + if (ratio < 2 || ratio > 3) { + return FALSE; + } + m_iWideNarrRatio = ratio; + return TRUE; +} +FX_BOOL CBC_OnedCodaBarWriter::FindChar(FX_WCHAR ch, FX_BOOL isContent) { + if (isContent) { + for (size_t i = 0; i < FX_ArraySize(CONTENT_CHARS); ++i) { + if (ch == (FX_WCHAR)CONTENT_CHARS[i]) { + return TRUE; + } + } + for (size_t j = 0; j < FX_ArraySize(START_END_CHARS); ++j) { + if (ch == (FX_WCHAR)START_END_CHARS[j]) { + return TRUE; + } + } + return FALSE; + } else { + for (size_t i = 0; i < FX_ArraySize(CONTENT_CHARS); ++i) { + if (ch == (FX_WCHAR)CONTENT_CHARS[i]) { + return TRUE; + } + } + return FALSE; + } +} +FX_BOOL CBC_OnedCodaBarWriter::CheckContentValidity( + const CFX_WideStringC& contents) { + FX_WCHAR ch; + int32_t index = 0; + for (index = 0; index < contents.GetLength(); index++) { + ch = contents.GetAt(index); + if (FindChar(ch, FALSE)) { + continue; + } else { + return FALSE; + } + } + return TRUE; +} +CFX_WideString CBC_OnedCodaBarWriter::FilterContents( + const CFX_WideStringC& contents) { + CFX_WideString filtercontents; + FX_WCHAR ch; + for (int32_t index = 0; index < contents.GetLength(); index++) { + ch = contents.GetAt(index); + if (ch > 175) { + index++; + continue; + } + if (FindChar(ch, TRUE)) { + filtercontents += ch; + } else { + continue; + } + } + return filtercontents; +} +uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_CODABAR) { + e = BCExceptionOnlyEncodeCODEBAR; + return NULL; + } + uint8_t* ret = + CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e) { + CBC_OnedCodaBarReader CodaBarR; + CFX_ByteString data = m_chStart + contents + m_chEnd; + m_iContentLen = data.GetLength(); + uint8_t* result = FX_Alloc2D(uint8_t, m_iWideNarrRatio * 7, data.GetLength()); + FX_CHAR ch; + int32_t position = 0; + for (int32_t index = 0; index < data.GetLength(); index++) { + ch = data.GetAt(index); + if (((ch >= 'a') && (ch <= 'z'))) { + ch = ch - 32; + } + switch (ch) { + case 'T': + ch = 'A'; + break; + case 'N': + ch = 'B'; + break; + case '*': + ch = 'C'; + break; + case 'E': + ch = 'D'; + break; + default: + break; + } + int32_t code = 0; + int32_t len = (int32_t)strlen(CodaBarR.ALPHABET_STRING); + for (int32_t i = 0; i < len; i++) { + if (ch == CodaBarR.ALPHABET_STRING[i]) { + code = CodaBarR.CHARACTER_ENCODINGS[i]; + break; + } + } + uint8_t color = 1; + int32_t counter = 0; + int32_t bit = 0; + while (bit < 7) { + result[position] = color; + position++; + if (((code >> (6 - bit)) & 1) == 0 || counter == m_iWideNarrRatio - 1) { + color = !color; + bit++; + counter = 0; + } else { + counter++; + } + } + if (index < data.GetLength() - 1) { + result[position] = 0; + position++; + } + } + outLength = position; + return result; +} +CFX_WideString CBC_OnedCodaBarWriter::encodedContents( + const CFX_WideStringC& contents) { + CFX_WideString strStart(m_chStart); + CFX_WideString strEnd(m_chEnd); + return strStart + contents + strEnd; +} +void CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + CBC_OneDimWriter::RenderResult(encodedContents(contents), code, codeLength, + isDevice, e); +} diff --git a/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.h new file mode 100644 index 0000000000..92a31bd989 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.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_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ + +enum BC_TEXT_LOC; +class CBC_OneDimWriter; +class CBC_OnedCodaBarWriter; +class CBC_OnedCodaBarWriter : public CBC_OneDimWriter { + public: + CBC_OnedCodaBarWriter(); + virtual ~CBC_OnedCodaBarWriter(); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + CFX_WideString encodedContents(const CFX_WideStringC& contents); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + FX_BOOL SetStartChar(FX_CHAR start); + FX_BOOL SetEndChar(FX_CHAR end); + void SetDataLength(int32_t length); + FX_BOOL SetTextLocation(BC_TEXT_LOC location); + FX_BOOL SetWideNarrowRatio(int32_t ratio); + FX_BOOL FindChar(FX_WCHAR ch, FX_BOOL isContent); + + private: + void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + static const FX_CHAR START_END_CHARS[]; + static const FX_CHAR CONTENT_CHARS[]; + FX_CHAR m_chStart; + FX_CHAR m_chEnd; + int32_t m_iWideNarrRatio; +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp new file mode 100644 index 0000000000..b5f5aa5fe4 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp @@ -0,0 +1,351 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <algorithm> + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Reader.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_OnedCode128Reader::CODE_PATTERNS[107][7] = { + {2, 1, 2, 2, 2, 2, 0}, {2, 2, 2, 1, 2, 2, 0}, {2, 2, 2, 2, 2, 1, 0}, + {1, 2, 1, 2, 2, 3, 0}, {1, 2, 1, 3, 2, 2, 0}, {1, 3, 1, 2, 2, 2, 0}, + {1, 2, 2, 2, 1, 3, 0}, {1, 2, 2, 3, 1, 2, 0}, {1, 3, 2, 2, 1, 2, 0}, + {2, 2, 1, 2, 1, 3, 0}, {2, 2, 1, 3, 1, 2, 0}, {2, 3, 1, 2, 1, 2, 0}, + {1, 1, 2, 2, 3, 2, 0}, {1, 2, 2, 1, 3, 2, 0}, {1, 2, 2, 2, 3, 1, 0}, + {1, 1, 3, 2, 2, 2, 0}, {1, 2, 3, 1, 2, 2, 0}, {1, 2, 3, 2, 2, 1, 0}, + {2, 2, 3, 2, 1, 1, 0}, {2, 2, 1, 1, 3, 2, 0}, {2, 2, 1, 2, 3, 1, 0}, + {2, 1, 3, 2, 1, 2, 0}, {2, 2, 3, 1, 1, 2, 0}, {3, 1, 2, 1, 3, 1, 0}, + {3, 1, 1, 2, 2, 2, 0}, {3, 2, 1, 1, 2, 2, 0}, {3, 2, 1, 2, 2, 1, 0}, + {3, 1, 2, 2, 1, 2, 0}, {3, 2, 2, 1, 1, 2, 0}, {3, 2, 2, 2, 1, 1, 0}, + {2, 1, 2, 1, 2, 3, 0}, {2, 1, 2, 3, 2, 1, 0}, {2, 3, 2, 1, 2, 1, 0}, + {1, 1, 1, 3, 2, 3, 0}, {1, 3, 1, 1, 2, 3, 0}, {1, 3, 1, 3, 2, 1, 0}, + {1, 1, 2, 3, 1, 3, 0}, {1, 3, 2, 1, 1, 3, 0}, {1, 3, 2, 3, 1, 1, 0}, + {2, 1, 1, 3, 1, 3, 0}, {2, 3, 1, 1, 1, 3, 0}, {2, 3, 1, 3, 1, 1, 0}, + {1, 1, 2, 1, 3, 3, 0}, {1, 1, 2, 3, 3, 1, 0}, {1, 3, 2, 1, 3, 1, 0}, + {1, 1, 3, 1, 2, 3, 0}, {1, 1, 3, 3, 2, 1, 0}, {1, 3, 3, 1, 2, 1, 0}, + {3, 1, 3, 1, 2, 1, 0}, {2, 1, 1, 3, 3, 1, 0}, {2, 3, 1, 1, 3, 1, 0}, + {2, 1, 3, 1, 1, 3, 0}, {2, 1, 3, 3, 1, 1, 0}, {2, 1, 3, 1, 3, 1, 0}, + {3, 1, 1, 1, 2, 3, 0}, {3, 1, 1, 3, 2, 1, 0}, {3, 3, 1, 1, 2, 1, 0}, + {3, 1, 2, 1, 1, 3, 0}, {3, 1, 2, 3, 1, 1, 0}, {3, 3, 2, 1, 1, 1, 0}, + {3, 1, 4, 1, 1, 1, 0}, {2, 2, 1, 4, 1, 1, 0}, {4, 3, 1, 1, 1, 1, 0}, + {1, 1, 1, 2, 2, 4, 0}, {1, 1, 1, 4, 2, 2, 0}, {1, 2, 1, 1, 2, 4, 0}, + {1, 2, 1, 4, 2, 1, 0}, {1, 4, 1, 1, 2, 2, 0}, {1, 4, 1, 2, 2, 1, 0}, + {1, 1, 2, 2, 1, 4, 0}, {1, 1, 2, 4, 1, 2, 0}, {1, 2, 2, 1, 1, 4, 0}, + {1, 2, 2, 4, 1, 1, 0}, {1, 4, 2, 1, 1, 2, 0}, {1, 4, 2, 2, 1, 1, 0}, + {2, 4, 1, 2, 1, 1, 0}, {2, 2, 1, 1, 1, 4, 0}, {4, 1, 3, 1, 1, 1, 0}, + {2, 4, 1, 1, 1, 2, 0}, {1, 3, 4, 1, 1, 1, 0}, {1, 1, 1, 2, 4, 2, 0}, + {1, 2, 1, 1, 4, 2, 0}, {1, 2, 1, 2, 4, 1, 0}, {1, 1, 4, 2, 1, 2, 0}, + {1, 2, 4, 1, 1, 2, 0}, {1, 2, 4, 2, 1, 1, 0}, {4, 1, 1, 2, 1, 2, 0}, + {4, 2, 1, 1, 1, 2, 0}, {4, 2, 1, 2, 1, 1, 0}, {2, 1, 2, 1, 4, 1, 0}, + {2, 1, 4, 1, 2, 1, 0}, {4, 1, 2, 1, 2, 1, 0}, {1, 1, 1, 1, 4, 3, 0}, + {1, 1, 1, 3, 4, 1, 0}, {1, 3, 1, 1, 4, 1, 0}, {1, 1, 4, 1, 1, 3, 0}, + {1, 1, 4, 3, 1, 1, 0}, {4, 1, 1, 1, 1, 3, 0}, {4, 1, 1, 3, 1, 1, 0}, + {1, 1, 3, 1, 4, 1, 0}, {1, 1, 4, 1, 3, 1, 0}, {3, 1, 1, 1, 4, 1, 0}, + {4, 1, 1, 1, 3, 1, 0}, {2, 1, 1, 4, 1, 2, 0}, {2, 1, 1, 2, 1, 4, 0}, + {2, 1, 1, 2, 3, 2, 0}, {2, 3, 3, 1, 1, 1, 2}}; + +CBC_OnedCode128Reader::CBC_OnedCode128Reader() {} +CBC_OnedCode128Reader::~CBC_OnedCode128Reader() {} +CFX_Int32Array* CBC_OnedCode128Reader::FindStartPattern(CBC_CommonBitArray* row, + int32_t& e) { + int32_t width = row->GetSize(); + int32_t rowOffset = 0; + while (rowOffset < width) { + if (row->Get(rowOffset)) { + break; + } + rowOffset++; + } + int32_t counterPosition = 0; + CFX_Int32Array counters; + counters.SetSize(6); + int32_t patternStart = rowOffset; + FX_BOOL isWhite = FALSE; + int32_t patternLength = counters.GetSize(); + for (int32_t i = rowOffset; i < width; i++) { + FX_BOOL pixel = row->Get(i); + if (pixel ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + int32_t bestVariance = MAX_AVG_VARIANCE; + int32_t bestMatch = -1; + for (int32_t startCode = CODE_START_A; startCode <= CODE_START_C; + startCode++) { + int32_t variance = PatternMatchVariance( + &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = startCode; + } + } + if (bestMatch >= 0) { + FX_BOOL btemp2 = + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), + patternStart, FALSE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (btemp2) { + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(3); + (*result)[0] = patternStart; + (*result)[1] = i; + (*result)[2] = bestMatch; + return result; + } + } + patternStart += counters[0] + counters[1]; + for (int32_t y = 2; y < patternLength; y++) { + counters[y - 2] = counters[y]; + } + counters[patternLength - 2] = 0; + counters[patternLength - 1] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + e = BCExceptionNotFound; + return NULL; +} +int32_t CBC_OnedCode128Reader::DecodeCode(CBC_CommonBitArray* row, + CFX_Int32Array* counters, + int32_t rowOffset, + int32_t& e) { + RecordPattern(row, rowOffset, counters, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + int32_t bestVariance = MAX_AVG_VARIANCE; + int32_t bestMatch = -1; + for (int32_t d = 0; d < 107; d++) { + int32_t variance = PatternMatchVariance(counters, &CODE_PATTERNS[d][0], + MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = d; + } + } + if (bestMatch >= 0) { + return bestMatch; + } else { + e = BCExceptionNotFound; + return 0; + } + return 0; +} +CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + CFX_Int32Array* startPatternInfo = FindStartPattern(row, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + int32_t startCode = (*startPatternInfo)[2]; + int32_t codeSet; + switch (startCode) { + case 103: + codeSet = CODE_CODE_A; + break; + case 104: + codeSet = CODE_CODE_B; + break; + case 105: + codeSet = CODE_CODE_C; + break; + default: + if (startPatternInfo) { + startPatternInfo->RemoveAll(); + delete startPatternInfo; + startPatternInfo = NULL; + } + e = BCExceptionFormatException; + return ""; + } + FX_BOOL done = FALSE; + FX_BOOL isNextShifted = FALSE; + CFX_ByteString result; + int32_t lastStart = (*startPatternInfo)[0]; + int32_t nextStart = (*startPatternInfo)[1]; + if (startPatternInfo) { + startPatternInfo->RemoveAll(); + delete startPatternInfo; + startPatternInfo = NULL; + } + CFX_Int32Array counters; + counters.SetSize(6); + int32_t lastCode = 0; + int32_t code = 0; + int32_t checksumTotal = startCode; + int32_t multiplier = 0; + FX_BOOL lastCharacterWasPrintable = TRUE; + while (!done) { + FX_BOOL unshift = isNextShifted; + isNextShifted = FALSE; + lastCode = code; + code = DecodeCode(row, &counters, nextStart, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + if (code != CODE_STOP) { + lastCharacterWasPrintable = TRUE; + } + if (code != CODE_STOP) { + multiplier++; + checksumTotal += multiplier * code; + } + lastStart = nextStart; + for (int32_t i = 0; i < counters.GetSize(); i++) { + nextStart += counters[i]; + } + switch (code) { + case 103: + case 104: + case 105: + e = BCExceptionFormatException; + return ""; + } + switch (codeSet) { + case 101: + if (code < 64) { + result += (FX_CHAR)(' ' + code); + } else if (code < 96) { + result += (FX_CHAR)(code - 64); + } else { + if (code != CODE_STOP) { + lastCharacterWasPrintable = FALSE; + } + switch (code) { + case 102: + case 97: + case 96: + case 101: + break; + case 98: + isNextShifted = TRUE; + codeSet = CODE_CODE_B; + break; + case 100: + codeSet = CODE_CODE_B; + break; + case 99: + codeSet = CODE_CODE_C; + break; + case 106: + done = TRUE; + break; + } + } + break; + case 100: + if (code < 96) { + result += (FX_CHAR)(' ' + code); + } else { + if (code != CODE_STOP) { + lastCharacterWasPrintable = FALSE; + } + switch (code) { + case 102: + case 97: + case 96: + case 100: + break; + case 98: + isNextShifted = TRUE; + codeSet = CODE_CODE_A; + break; + case 101: + codeSet = CODE_CODE_A; + break; + case 99: + codeSet = CODE_CODE_C; + break; + case 106: + done = TRUE; + break; + } + } + break; + case 99: + if (code < 100) { + if (code < 10) { + result += '0'; + } + FX_CHAR temp[128]; + // TODO(dsinclair): Should this be snprintf? + sprintf(temp, "%d", code); + result += temp; + } else { + if (code != CODE_STOP) { + lastCharacterWasPrintable = FALSE; + } + switch (code) { + case 102: + break; + case 101: + codeSet = CODE_CODE_A; + break; + case 100: + codeSet = CODE_CODE_B; + break; + case 106: + done = TRUE; + break; + } + } + break; + } + if (unshift) { + codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A; + } + } + int32_t width = row->GetSize(); + while (nextStart < width && row->Get(nextStart)) { + nextStart++; + } + FX_BOOL boolT1 = row->IsRange( + nextStart, std::min(width, nextStart + (nextStart - lastStart) / 2), + FALSE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + if (!boolT1) { + e = BCExceptionNotFound; + return ""; + } + checksumTotal -= multiplier * lastCode; + if (checksumTotal % 103 != lastCode) { + e = BCExceptionChecksumException; + return ""; + } + int32_t resultLength = result.GetLength(); + if (resultLength > 0 && lastCharacterWasPrintable) { + if (codeSet == CODE_CODE_C) { + result = result.Mid(0, result.GetLength() - 2); + } else { + result = result.Mid(0, result.GetLength() - 1); + } + } + if (result.GetLength() == 0) { + e = BCExceptionFormatException; + return ""; + } + return result; +} diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Reader.h b/xfa/fxbarcode/oned/BC_OnedCode128Reader.h new file mode 100644 index 0000000000..d9ac4853bf --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode128Reader.h @@ -0,0 +1,49 @@ +// 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_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ + +class CBC_OneDReader; +class CBC_CommonBitArray; +class CBC_OnedCode128Reader : public CBC_OneDReader { + public: + CBC_OnedCode128Reader(); + virtual ~CBC_OnedCode128Reader(); + virtual CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e); + + static const int32_t CODE_PATTERNS[107][7]; + + private: + static const int32_t MAX_AVG_VARIANCE = (int32_t)(256 * 0.25f); + static const int32_t MAX_INDIVIDUAL_VARIANCE = (int32_t)(256 * 0.7f); + + static const int32_t CODE_SHIFT = 98; + static const int32_t CODE_CODE_C = 99; + static const int32_t CODE_CODE_B = 100; + static const int32_t CODE_CODE_A = 101; + static const int32_t CODE_FNC_1 = 102; + static const int32_t CODE_FNC_2 = 97; + static const int32_t CODE_FNC_3 = 96; + static const int32_t CODE_FNC_4_A = 101; + static const int32_t CODE_FNC_4_B = 100; + + static const int32_t CODE_START_A = 103; + static const int32_t CODE_START_B = 104; + static const int32_t CODE_START_C = 105; + static const int32_t CODE_STOP = 106; + + CFX_Int32Array* FindStartPattern(CBC_CommonBitArray* row, int32_t& e); + int32_t DecodeCode(CBC_CommonBitArray* row, + CFX_Int32Array* counters, + int32_t rowOffset, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp new file mode 100644 index 0000000000..4d759b48a3 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp @@ -0,0 +1,235 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode128Writer.h" + +const int32_t CBC_OnedCode128Writer::CODE_CODE_B = 100; +const int32_t CBC_OnedCode128Writer::CODE_CODE_C = 99; +const int32_t CBC_OnedCode128Writer::CODE_START_B = 104; +const int32_t CBC_OnedCode128Writer::CODE_START_C = 105; +const int32_t CBC_OnedCode128Writer::CODE_STOP = 106; + +CBC_OnedCode128Writer::CBC_OnedCode128Writer() { + m_codeFormat = BC_CODE128_B; +} +CBC_OnedCode128Writer::CBC_OnedCode128Writer(BC_TYPE type) { + m_codeFormat = type; +} +CBC_OnedCode128Writer::~CBC_OnedCode128Writer() {} +BC_TYPE CBC_OnedCode128Writer::GetType() { + return m_codeFormat; +} +FX_BOOL CBC_OnedCode128Writer::CheckContentValidity( + const CFX_WideStringC& contents) { + FX_BOOL ret = TRUE; + int32_t position = 0; + int32_t patternIndex = -1; + if (m_codeFormat == BC_CODE128_B || m_codeFormat == BC_CODE128_C) { + while (position < contents.GetLength()) { + patternIndex = (int32_t)contents.GetAt(position); + if (patternIndex >= 32 && patternIndex <= 126 && patternIndex != 34) { + position++; + continue; + } else { + ret = FALSE; + break; + } + position++; + } + } else { + ret = FALSE; + } + return ret; +} +CFX_WideString CBC_OnedCode128Writer::FilterContents( + const CFX_WideStringC& contents) { + CFX_WideString filterChineseChar; + FX_WCHAR ch; + for (int32_t i = 0; i < contents.GetLength(); i++) { + ch = contents.GetAt(i); + if (ch > 175) { + i++; + continue; + } + filterChineseChar += ch; + } + CFX_WideString filtercontents; + if (m_codeFormat == BC_CODE128_B) { + for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { + ch = filterChineseChar.GetAt(i); + if (ch >= 32 && ch <= 126) { + filtercontents += ch; + } else { + continue; + } + } + } else if (m_codeFormat == BC_CODE128_C) { + for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { + ch = filterChineseChar.GetAt(i); + if (ch >= 32 && ch <= 106) { + filtercontents += ch; + } else { + continue; + } + } + } else { + filtercontents = contents; + } + return filtercontents; +} +FX_BOOL CBC_OnedCode128Writer::SetTextLocation(BC_TEXT_LOC location) { + if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { + return FALSE; + } + m_locTextLoc = location; + return TRUE; +} +uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_CODE_128) { + e = BCExceptionOnlyEncodeCODE_128; + return NULL; + } + uint8_t* ret = + CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +FX_BOOL CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents, + int32_t start, + int32_t length) { + int32_t end = start + length; + for (int32_t i = start; i < end; i++) { + if (contents[i] < '0' || contents[i] > '9') { + return FALSE; + } + } + 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; + } + CFX_PtrArray patterns; + int32_t checkSum = 0; + if (m_codeFormat == BC_CODE128_B) { + checkSum = Encode128B(contents, patterns); + } else if (m_codeFormat == BC_CODE128_C) { + checkSum = Encode128C(contents, patterns); + } else { + e = BCExceptionFormatException; + return NULL; + } + checkSum %= 103; + patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]); + patterns.Add((int32_t*)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]; + for (int32_t j = 0; j < 7; j++) { + codeWidth += pattern[j]; + } + } + outLength = codeWidth; + 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]; + pos += AppendPattern(result, pos, pattern, 7, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + return result; +} +int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents, + CFX_PtrArray& patterns) { + int32_t checkSum = 0; + int32_t checkWeight = 1; + int32_t position = 0; + patterns.Add((int32_t*)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]); + checkSum += patternIndex * checkWeight; + if (position != 0) { + checkWeight++; + } + } + return checkSum; +} +int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents, + CFX_PtrArray& patterns) { + int32_t checkSum = 0; + int32_t checkWeight = 1; + int32_t position = 0; + patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]); + checkSum += CODE_START_C * checkWeight; + while (position < contents.GetLength()) { + int32_t patternIndex = 0; + FX_CHAR ch = contents.GetAt(position); + if (ch < '0' || ch > '9') { + patternIndex = (int32_t)ch; + position++; + } else { + patternIndex = FXSYS_atoi(contents.Mid(position, 2)); + if (contents.GetAt(position + 1) < '0' || + contents.GetAt(position + 1) > '9') { + position += 1; + } else { + position += 2; + } + } + patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]); + checkSum += patternIndex * checkWeight; + if (position != 0) { + checkWeight++; + } + } + return checkSum; +} diff --git a/xfa/fxbarcode/oned/BC_OnedCode128Writer.h b/xfa/fxbarcode/oned/BC_OnedCode128Writer.h new file mode 100644 index 0000000000..9be05a19b0 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode128Writer.h @@ -0,0 +1,49 @@ +// 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_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ + +class CBC_OneDimWriter; +class CBC_OnedCode128Writer : public CBC_OneDimWriter { + public: + CBC_OnedCode128Writer(); + CBC_OnedCode128Writer(BC_TYPE type); + virtual ~CBC_OnedCode128Writer(); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + FX_BOOL SetTextLocation(BC_TEXT_LOC location); + BC_TYPE GetType(); + + private: + 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); + BC_TYPE m_codeFormat; + static const int32_t CODE_START_B; + static const int32_t CODE_START_C; + static const int32_t CODE_CODE_B; + static const int32_t CODE_CODE_C; + static const int32_t CODE_STOP; +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Reader.cpp b/xfa/fxbarcode/oned/BC_OnedCode39Reader.cpp new file mode 100644 index 0000000000..e2f88e7a79 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode39Reader.cpp @@ -0,0 +1,287 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <algorithm> + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h" +#include "xfa/fxbarcode/utils.h" + +const FX_CHAR* CBC_OnedCode39Reader::ALPHABET_STRING = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; +const FX_CHAR* CBC_OnedCode39Reader::CHECKSUM_STRING = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; +const int32_t CBC_OnedCode39Reader::CHARACTER_ENCODINGS[44] = { + 0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, + 0x064, 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, + 0x04C, 0x01C, 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, + 0x106, 0x046, 0x016, 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, + 0x085, 0x184, 0x0C4, 0x094, 0x0A8, 0x0A2, 0x08A, 0x02A}; +const int32_t CBC_OnedCode39Reader::ASTERISK_ENCODING = 0x094; + +CBC_OnedCode39Reader::CBC_OnedCode39Reader() + : m_usingCheckDigit(FALSE), m_extendedMode(FALSE) {} +CBC_OnedCode39Reader::CBC_OnedCode39Reader(FX_BOOL usingCheckDigit) + : m_usingCheckDigit(usingCheckDigit), m_extendedMode(FALSE) {} +CBC_OnedCode39Reader::CBC_OnedCode39Reader(FX_BOOL usingCheckDigit, + FX_BOOL extendedMode) + : m_usingCheckDigit(usingCheckDigit), m_extendedMode(extendedMode) {} +CBC_OnedCode39Reader::~CBC_OnedCode39Reader() {} +CFX_ByteString CBC_OnedCode39Reader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + CFX_Int32Array* start = FindAsteriskPattern(row, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + int32_t nextStart = (*start)[1]; + delete start; + int32_t end = row->GetSize(); + while (nextStart < end && !row->Get(nextStart)) { + nextStart++; + } + CFX_ByteString result; + CFX_Int32Array counters; + counters.SetSize(9); + FX_CHAR decodedChar; + do { + RecordPattern(row, nextStart, &counters, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + int32_t pattern = ToNarrowWidePattern(&counters); + if (pattern < 0) { + e = BCExceptionNotFound; + return ""; + } + decodedChar = PatternToChar(pattern, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + result += decodedChar; + for (int32_t i = 0; i < counters.GetSize(); i++) { + nextStart += counters[i]; + } + while (nextStart < end && !row->Get(nextStart)) { + nextStart++; + } + } while (decodedChar != '*'); + result = result.Mid(0, result.GetLength() - 1); + int32_t lastPatternSize = 0; + for (int32_t j = 0; j < counters.GetSize(); j++) { + lastPatternSize += counters[j]; + } + if (m_usingCheckDigit) { + int32_t max = result.GetLength() - 1; + int32_t total = 0; + int32_t len = (int32_t)strlen(ALPHABET_STRING); + for (int32_t k = 0; k < max; k++) { + for (int32_t j = 0; j < len; j++) + if (ALPHABET_STRING[j] == result[k]) { + total += j; + } + } + if (result[max] != (ALPHABET_STRING)[total % 43]) { + e = BCExceptionChecksumException; + return ""; + } + result = result.Mid(0, result.GetLength() - 1); + } + if (result.GetLength() == 0) { + e = BCExceptionNotFound; + return ""; + } + if (m_extendedMode) { + CFX_ByteString bytestr = DecodeExtended(result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return bytestr; + } else { + return result; + } +} +CFX_Int32Array* CBC_OnedCode39Reader::FindAsteriskPattern( + CBC_CommonBitArray* row, + int32_t& e) { + int32_t width = row->GetSize(); + int32_t rowOffset = 0; + while (rowOffset < width) { + if (row->Get(rowOffset)) { + break; + } + rowOffset++; + } + int32_t counterPosition = 0; + CFX_Int32Array counters; + counters.SetSize(9); + int32_t patternStart = rowOffset; + FX_BOOL isWhite = FALSE; + int32_t patternLength = counters.GetSize(); + for (int32_t i = rowOffset; i < width; i++) { + FX_BOOL pixel = row->Get(i); + if (pixel ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { + FX_BOOL bT1 = + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), + patternStart, FALSE, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (bT1) { + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(2); + (*result)[0] = patternStart; + (*result)[1] = i; + return result; + } + } + patternStart += counters[0] + counters[1]; + for (int32_t y = 2; y < patternLength; y++) { + counters[y - 2] = counters[y]; + } + counters[patternLength - 2] = 0; + counters[patternLength - 1] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + e = BCExceptionNotFound; + return NULL; +} +int32_t CBC_OnedCode39Reader::ToNarrowWidePattern(CFX_Int32Array* counters) { + int32_t numCounters = counters->GetSize(); + int32_t maxNarrowCounter = 0; + int32_t wideCounters; + do { +#undef max + int32_t minCounter = FXSYS_IntMax; + for (int32_t i = 0; i < numCounters; i++) { + int32_t counter = (*counters)[i]; + if (counter < minCounter && counter > maxNarrowCounter) { + minCounter = counter; + } + } + maxNarrowCounter = minCounter; + wideCounters = 0; + int32_t totalWideCountersWidth = 0; + int32_t pattern = 0; + for (int32_t j = 0; j < numCounters; j++) { + int32_t counter = (*counters)[j]; + if ((*counters)[j] > maxNarrowCounter) { + pattern |= 1 << (numCounters - 1 - j); + wideCounters++; + totalWideCountersWidth += counter; + } + } + if (wideCounters == 3) { + for (int32_t k = 0; k < numCounters && wideCounters > 0; k++) { + int32_t counter = (*counters)[k]; + if ((*counters)[k] > maxNarrowCounter) { + wideCounters--; + if ((counter << 1) >= totalWideCountersWidth) { + return -1; + } + } + } + return pattern; + } + } while (wideCounters > 3); + return -1; +} +FX_CHAR CBC_OnedCode39Reader::PatternToChar(int32_t pattern, int32_t& e) { + for (int32_t i = 0; i < 44; i++) { + if (CHARACTER_ENCODINGS[i] == pattern) { + return (ALPHABET_STRING)[i]; + } + } + e = BCExceptionNotFound; + return 0; +} +CFX_ByteString CBC_OnedCode39Reader::DecodeExtended(CFX_ByteString& encoded, + int32_t& e) { + int32_t length = encoded.GetLength(); + CFX_ByteString decoded; + FX_CHAR c, next; + for (int32_t i = 0; i < length; i++) { + c = encoded[i]; + if (c == '+' || c == '$' || c == '%' || c == '/') { + next = encoded[i + 1]; + FX_CHAR decodedChar = '\0'; + switch (c) { + case '+': + if (next >= 'A' && next <= 'Z') { + decodedChar = (FX_CHAR)(next + 32); + } else { + e = BCExceptionFormatException; + return ""; + } + break; + case '$': + if (next >= 'A' && next <= 'Z') { + decodedChar = (FX_CHAR)(next - 64); + } else { + e = BCExceptionFormatException; + return ""; + } + break; + case '%': + if (next >= 'A' && next <= 'E') { + decodedChar = (FX_CHAR)(next - 38); + } else if (next >= 'F' && next <= 'J') { + decodedChar = (FX_CHAR)(next - 11); + } else if (next >= 'K' && next <= 'O' && next != 'M' && next != 'N') { + decodedChar = (FX_CHAR)(next + 16); + } else if (next >= 'P' && next <= 'S') { + decodedChar = (FX_CHAR)(next + 43); + } else if (next == 'U') { + decodedChar = (FX_CHAR)0; + } else if (next == 'V') { + decodedChar = (FX_CHAR)64; + } else if (next == 'W') { + decodedChar = (FX_CHAR)96; + } else if (next == 'T' || next == 'X' || next == 'Y' || next == 'Z') { + decodedChar = (FX_CHAR)127; + } else { + e = BCExceptionFormatException; + return ""; + } + break; + case '/': + if (next >= 'A' && next <= 'O') { + decodedChar = (FX_CHAR)(next - 32); + } else if (next == 'Z') { + decodedChar = ':'; + } else { + e = BCExceptionFormatException; + return ""; + } + break; + } + decoded += decodedChar; + i++; + } else { + decoded += c; + } + } + return decoded; +} diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Reader.h b/xfa/fxbarcode/oned/BC_OnedCode39Reader.h new file mode 100644 index 0000000000..f1551e4761 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode39Reader.h @@ -0,0 +1,36 @@ +// 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_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ + +class CBC_OneDReader; +class CBC_CommonBitArray; +class CBC_OnedCode39Reader : public CBC_OneDReader { + public: + static const FX_CHAR* ALPHABET_STRING; + static const FX_CHAR* CHECKSUM_STRING; + static const int32_t CHARACTER_ENCODINGS[44]; + static const int32_t ASTERISK_ENCODING; + CBC_OnedCode39Reader(); + CBC_OnedCode39Reader(FX_BOOL usingCheckDigit); + CBC_OnedCode39Reader(FX_BOOL usingCheckDigit, FX_BOOL extendedMode); + virtual ~CBC_OnedCode39Reader(); + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e); + + private: + FX_BOOL m_usingCheckDigit; + FX_BOOL m_extendedMode; + CFX_Int32Array* FindAsteriskPattern(CBC_CommonBitArray* row, int32_t& e); + int32_t ToNarrowWidePattern(CFX_Int32Array* counters); + FX_CHAR PatternToChar(int32_t pattern, int32_t& e); + CFX_ByteString DecodeExtended(CFX_ByteString& encoded, int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp new file mode 100644 index 0000000000..31e75ca7df --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -0,0 +1,364 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedCode39Writer.h" + +CBC_OnedCode39Writer::CBC_OnedCode39Writer() { + m_extendedMode = FALSE; + m_iWideNarrRatio = 3; +} +CBC_OnedCode39Writer::CBC_OnedCode39Writer(FX_BOOL extendedMode) { + m_iWideNarrRatio = 3; + m_extendedMode = extendedMode; +} +CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {} +FX_BOOL CBC_OnedCode39Writer::CheckContentValidity( + const CFX_WideStringC& contents) { + if (m_extendedMode) { + return CheckExtendedContentValidity(contents); + } + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || + (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || ch == (FX_WCHAR)'-' || + ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || + ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || + ch == (FX_WCHAR)'%') { + continue; + } + return FALSE; + } + return TRUE; +} +FX_BOOL CBC_OnedCode39Writer::CheckExtendedContentValidity( + const CFX_WideStringC& contents) { + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if (ch > 127) { + return FALSE; + } + } + return TRUE; +} +CFX_WideString CBC_OnedCode39Writer::FilterContents( + const CFX_WideStringC& contents) { + if (m_extendedMode) { + return FilterExtendedContents(contents); + } + CFX_WideString filtercontents; + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { + continue; + } + if (ch > 175) { + i++; + continue; + } else { + ch = Upper(ch); + } + if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || + (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || ch == (FX_WCHAR)'-' || + ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || + ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || + ch == (FX_WCHAR)'%') { + filtercontents += ch; + } + } + return filtercontents; +} +CFX_WideString CBC_OnedCode39Writer::FilterExtendedContents( + const CFX_WideStringC& contents) { + CFX_WideString filtercontents; + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { + continue; + } + if (ch > 175) { + i++; + continue; + } + if (ch > 127 && ch < 176) { + continue; + } + if (ch == 0) { + filtercontents += '%'; + filtercontents += 'U'; + } else if (ch >= 1 && ch <= 26) { + filtercontents += '$'; + filtercontents += (ch + 64); + } else if (ch >= 27 && ch <= 31) { + filtercontents += '%'; + filtercontents += (ch + 38); + } else if (ch >= 33 && ch <= 47 && ch != 45 && ch != 46) { + filtercontents += '/'; + filtercontents += (ch + 32); + } else if (ch == 58) { + filtercontents += '/'; + filtercontents += 'Z'; + } else if (ch >= 59 && ch <= 63) { + filtercontents += '%'; + filtercontents += ch + 11; + } else if (ch == 64) { + filtercontents += '%'; + filtercontents += 'V'; + } else if (ch >= 91 && ch <= 95) { + filtercontents += '%'; + filtercontents += ch - 16; + } else if (ch == 96) { + filtercontents += '%'; + filtercontents += 'W'; + } else if (ch >= 97 && ch <= 122) { + filtercontents += '+'; + filtercontents += ch - 32; + } else if (ch >= 123 && ch <= 126) { + filtercontents += '%'; + filtercontents += ch - 43; + } else if (ch == 127) { + filtercontents += '%'; + filtercontents += 'T'; + } else { + filtercontents += ch; + } + } + return filtercontents; +} +CFX_WideString CBC_OnedCode39Writer::RenderTextContents( + const CFX_WideStringC& contents) { + if (m_extendedMode) { + return RenderExtendedTextContents(contents); + } + CFX_WideString renderContents; + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { + continue; + } + if (ch > 175) { + i++; + continue; + } + if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || + (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || + (ch >= (FX_WCHAR)'a' && ch <= (FX_WCHAR)'z') || ch == (FX_WCHAR)'-' || + ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || + ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || + ch == (FX_WCHAR)'%') { + renderContents += ch; + } + } + return renderContents; +} +CFX_WideString CBC_OnedCode39Writer::RenderExtendedTextContents( + const CFX_WideStringC& contents) { + CFX_WideString renderContents; + for (int32_t i = 0; i < contents.GetLength(); i++) { + FX_WCHAR ch = contents.GetAt(i); + if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { + continue; + } + if (ch > 175) { + i++; + continue; + } + if (ch > 127 && ch < 176) { + continue; + } + renderContents += ch; + } + return renderContents; +} +FX_BOOL CBC_OnedCode39Writer::SetTextLocation(BC_TEXT_LOC location) { + if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { + return FALSE; + } + m_locTextLoc = location; + return TRUE; +} +FX_BOOL CBC_OnedCode39Writer::SetWideNarrowRatio(int32_t ratio) { + if (ratio < 2 || ratio > 3) { + return FALSE; + } + m_iWideNarrRatio = ratio; + return TRUE; +} +uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_CODE_39) { + e = BCExceptionOnlyEncodeCODE_39; + return NULL; + } + uint8_t* ret = + CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +void CBC_OnedCode39Writer::ToIntArray(int32_t a, int32_t* toReturn) { + for (int32_t i = 0; i < 9; i++) { + toReturn[i] = (a & (1 << i)) == 0 ? 1 : m_iWideNarrRatio; + } +} +FX_CHAR CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString& contents, + int32_t& e) { + int32_t length = contents.GetLength(); + if (length > 80) { + e = BCExceptionContentsLengthShouldBetween1and80; + return '*'; + } + int32_t checksum = 0; + int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); + for (int32_t i = 0; i < contents.GetLength(); i++) { + int32_t j = 0; + for (; j < len; j++) { + if (CBC_OnedCode39Reader::ALPHABET_STRING[j] == contents[i]) { + if (contents[i] != '*') { + checksum += j; + break; + } else { + break; + } + } + } + if (j >= len) { + e = BCExceptionUnSupportedString; + return '*'; + } + } + checksum = checksum % 43; + return CBC_OnedCode39Reader::CHECKSUM_STRING[checksum]; +} +uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, + int32_t& outlength, + int32_t& e) { + FX_CHAR checksum = CalcCheckSum(contents, e); + if (checksum == '*') { + return NULL; + } + int32_t widths[9] = {0}; + int32_t wideStrideNum = 3; + int32_t narrStrideNum = 9 - wideStrideNum; + CFX_ByteString encodedContents = contents; + if (m_bCalcChecksum) { + encodedContents += checksum; + } + m_iContentLen = encodedContents.GetLength(); + int32_t codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2 + + 1 + m_iContentLen; + int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); + for (int32_t j = 0; j < m_iContentLen; j++) { + for (int32_t i = 0; i < len; i++) { + if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[j]) { + ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths); + for (int32_t k = 0; k < 9; k++) { + codeWidth += widths[k]; + } + } + } + } + outlength = codeWidth; + uint8_t* result = FX_Alloc(uint8_t, codeWidth); + ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); + int32_t pos = AppendPattern(result, 0, widths, 9, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + int32_t narrowWhite[] = {1}; + pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + for (int32_t l = m_iContentLen - 1; l >= 0; l--) { + for (int32_t i = 0; i < len; i++) { + if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[l]) { + ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths); + pos += AppendPattern(result, pos, widths, 9, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + } + pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); + pos += AppendPattern(result, pos, widths, 9, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + for (int32_t i = 0; i < codeWidth / 2; i++) { + result[i] ^= result[codeWidth - 1 - i]; + result[codeWidth - 1 - i] ^= result[i]; + result[i] ^= result[codeWidth - 1 - i]; + } + return result; +} +CFX_WideString CBC_OnedCode39Writer::encodedContents( + const CFX_WideStringC& contents, + int32_t& e) { + 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"")); + str += checksum; + encodedContents += checksum; + } + return encodedContents; +} +void CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + CFX_WideString encodedCon = encodedContents(contents, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CBC_OneDimWriter::RenderResult(encodedCon, code, codeLength, isDevice, e); +} diff --git a/xfa/fxbarcode/oned/BC_OnedCode39Writer.h b/xfa/fxbarcode/oned/BC_OnedCode39Writer.h new file mode 100644 index 0000000000..b438727130 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedCode39Writer.h @@ -0,0 +1,53 @@ +// 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_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ + +enum BC_TEXT_LOC; +class CBC_OneDimWriter; +class CBC_OnedCode39Writer : public CBC_OneDimWriter { + public: + CBC_OnedCode39Writer(); + CBC_OnedCode39Writer(FX_BOOL extendedMode); + virtual ~CBC_OnedCode39Writer(); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e); + void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + CFX_WideString encodedContents(const CFX_WideStringC& contents, int32_t& e); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + FX_BOOL CheckExtendedContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + CFX_WideString FilterExtendedContents(const CFX_WideStringC& contents); + CFX_WideString RenderTextContents(const CFX_WideStringC& contents); + CFX_WideString RenderExtendedTextContents(const CFX_WideStringC& contents); + FX_BOOL SetTextLocation(BC_TEXT_LOC loction); + FX_BOOL SetWideNarrowRatio(int32_t ratio); + + private: + void ToIntArray(int32_t a, int32_t* toReturn); + FX_CHAR CalcCheckSum(const CFX_ByteString& contents, int32_t& e); + int32_t m_iWideNarrRatio; + FX_BOOL m_extendedMode; +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Reader.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Reader.cpp new file mode 100644 index 0000000000..83fea7d5f2 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Reader.cpp @@ -0,0 +1,96 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[10] = { + 0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A}; + +CBC_OnedEAN13Reader::CBC_OnedEAN13Reader() {} +CBC_OnedEAN13Reader::~CBC_OnedEAN13Reader() {} +void CBC_OnedEAN13Reader::DetermineFirstDigit(CFX_ByteString& result, + int32_t lgPatternFound, + int32_t& e) { + for (int32_t d = 0; d < 10; d++) { + if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) { + result.Insert(0, (FX_CHAR)('0' + d)); + return; + } + } + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +int32_t CBC_OnedEAN13Reader::DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultString, + int32_t& e) { + CFX_Int32Array counters; + counters.Add(0); + counters.Add(0); + counters.Add(0); + counters.Add(0); + int32_t end = row->GetSize(); + int32_t rowOffset = (*startRange)[1]; + int32_t lgPatternFound = 0; + for (int32_t x = 0; x < 6 && rowOffset < end; x++) { + int32_t bestMatch = + DecodeDigit(row, &counters, rowOffset, + &(CBC_OneDimReader::L_AND_G_PATTERNS[0][0]), 20, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + resultString += (FX_CHAR)('0' + bestMatch % 10); + for (int32_t i = 0; i < counters.GetSize(); i++) { + rowOffset += counters[i]; + } + if (bestMatch >= 10) { + lgPatternFound |= 1 << (5 - x); + } + } + DetermineFirstDigit(resultString, lgPatternFound, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + CFX_Int32Array result; + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]); + CFX_Int32Array* middleRange = + FindGuardPattern(row, rowOffset, TRUE, &result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + rowOffset = (*middleRange)[1]; + delete middleRange; + for (int32_t Y = 0; Y < 6 && rowOffset < end; Y++) { + int32_t bestMatch = + DecodeDigit(row, &counters, rowOffset, + &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + resultString += (FX_CHAR)('0' + bestMatch); + for (int32_t k = 0; k < counters.GetSize(); k++) { + rowOffset += counters[k]; + } + } + return rowOffset; +} diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Reader.h b/xfa/fxbarcode/oned/BC_OnedEAN13Reader.h new file mode 100644 index 0000000000..0d9d614901 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Reader.h @@ -0,0 +1,31 @@ +// 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_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ +class CBC_OneDimReader; +class CBC_CommonBitArray; +class CBC_OnedEAN13Reader; +class CBC_OnedEAN13Reader : public CBC_OneDimReader { + public: + static const int32_t FIRST_DIGIT_ENCODINGS[10]; + CBC_OnedEAN13Reader(); + virtual ~CBC_OnedEAN13Reader(); + + private: + void DetermineFirstDigit(CFX_ByteString& result, + int32_t lgPatternFound, + int32_t& e); + + protected: + int32_t DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultString, + int32_t& e); + friend class CBC_OnedUPCAReader; +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp new file mode 100644 index 0000000000..b534602fb3 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -0,0 +1,301 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h" + +CBC_OnedEAN13Writer::CBC_OnedEAN13Writer() { + m_bLeftPadding = TRUE; + m_codeWidth = 3 + (7 * 6) + 5 + (7 * 6) + 3; +} +CBC_OnedEAN13Writer::~CBC_OnedEAN13Writer() {} +FX_BOOL CBC_OnedEAN13Writer::CheckContentValidity( + const CFX_WideStringC& contents) { + for (int32_t i = 0; i < contents.GetLength(); i++) { + if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { + continue; + } else { + return FALSE; + } + } + return TRUE; +} +CFX_WideString CBC_OnedEAN13Writer::FilterContents( + const CFX_WideStringC& contents) { + CFX_WideString filtercontents; + FX_WCHAR ch; + for (int32_t i = 0; i < contents.GetLength(); i++) { + ch = contents.GetAt(i); + if (ch > 175) { + i++; + continue; + } + if (ch >= '0' && ch <= '9') { + filtercontents += ch; + } + } + return filtercontents; +} +int32_t CBC_OnedEAN13Writer::CalcChecksum(const CFX_ByteString& contents) { + int32_t odd = 0; + int32_t even = 0; + int32_t j = 1; + for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { + if (j % 2) { + odd += FXSYS_atoi(contents.Mid(i, 1)); + } else { + even += FXSYS_atoi(contents.Mid(i, 1)); + } + j++; + } + int32_t checksum = (odd * 3 + even) % 10; + checksum = (10 - checksum) % 10; + return (checksum); +} +uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_EAN_13) { + e = BCExceptionOnlyEncodeEAN_13; + } + uint8_t* ret = + CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e) { + if (contents.GetLength() != 13) { + e = BCExceptionDigitLengthShould13; + return NULL; + } + m_iDataLenth = 13; + int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1)); + int32_t parities = CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit]; + outLength = m_codeWidth; + uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); + int32_t pos = 0; + pos += + AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + int32_t i = 0; + for (i = 1; i <= 6; i++) { + int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); + if ((parities >> (6 - i) & 1) == 1) { + digit += 10; + } + pos += AppendPattern(result, pos, CBC_OneDimReader::L_AND_G_PATTERNS[digit], + 4, 0, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + for (i = 7; i <= 12; i++) { + int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); + pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, + e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + pos += + AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + return result; +} +void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { + if (device == NULL && pOutBitmap == NULL) { + e = BCExceptionIllegalArgument; + return; + } + int32_t leftPadding = 7 * multiple; + int32_t leftPosition = 3 * multiple + leftPadding; + CFX_ByteString str = FX_UTF8Encode(contents); + int32_t iLen = str.GetLength(); + FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); + FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); + CFX_FxgeDevice geBitmap; + if (pOutBitmap) { + geBitmap.Attach(pOutBitmap); + } + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + CFX_ByteString tempStr = str.Mid(1, 6); + int32_t strWidth = multiple * 42; + if (pOutBitmap == NULL) { + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect( + (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_FloatRect rect1( + (FX_FLOAT)(leftPosition + 47 * multiple), + (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)(leftPosition + 47 * multiple + strWidth - 0.5), + (FX_FLOAT)m_Height); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + int32_t strWidth1 = multiple * 7; + CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); + CFX_FloatRect rect2(0.0f, (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)strWidth1 - 0.5f, (FX_FLOAT)m_Height); + matr2.Concat(*matrix); + matr2.TransformRect(rect2); + re = rect2.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + } + FX_FLOAT blank = 0.0; + iLen = tempStr.GetLength(); + if (pOutBitmap == NULL) { + strWidth = (int32_t)(strWidth * m_outputHScale); + } + CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, + blank); + CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); + CFX_FxgeDevice ge; + if (pOutBitmap) { + ge.Create(strWidth, iTextHeight, FXDIB_Argb); + FX_RECT rect(0, 0, strWidth, iTextHeight); + ge.FillRect(&rect, m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)leftPosition * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight) + iFontSize); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 1, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(7, 6); + iLen = tempStr.GetLength(); + CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (FX_FLOAT)strWidth, iFontSize, + blank); + if (pOutBitmap) { + FX_RECT rect1(0, 0, strWidth, iTextHeight); + ge.FillRect(&rect1, m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple, + m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1( + 1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)(leftPosition + 47 * multiple) * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 7, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(0, 1); + iLen = tempStr.GetLength(); + strWidth = multiple * 7; + if (pOutBitmap == NULL) { + strWidth = (int32_t)(strWidth * m_outputHScale); + } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, + blank); + if (pOutBitmap) { + delete ge.GetBitmap(); + ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + FX_Free(pCharPos); +} +void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); +} diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h new file mode 100644 index 0000000000..fd23129975 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h @@ -0,0 +1,53 @@ +// 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_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ + +class CBC_OneDimWriter; +class CBC_OnedEAN13Writer; +class CBC_OnedEAN13Writer : public CBC_OneDimWriter { + private: + int32_t m_codeWidth; + + public: + CBC_OnedEAN13Writer(); + virtual ~CBC_OnedEAN13Writer(); + + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e); + void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + int32_t CalcChecksum(const CFX_ByteString& contents); + + protected: + void ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Reader.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Reader.cpp new file mode 100644 index 0000000000..f3b21fde99 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Reader.cpp @@ -0,0 +1,82 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Reader.h" +#include "xfa/fxbarcode/utils.h" + +CBC_OnedEAN8Reader::CBC_OnedEAN8Reader() {} +CBC_OnedEAN8Reader::~CBC_OnedEAN8Reader() {} +int32_t CBC_OnedEAN8Reader::DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultResult, + int32_t& e) { + CFX_Int32Array counters; + counters.Add(0); + counters.Add(0); + counters.Add(0); + counters.Add(0); + int32_t end = row->GetSize(); + int32_t rowOffset = (*startRange)[1]; + int32_t rowOffsetLeft = rowOffset; + for (int32_t x = 0; x < 4 && rowOffset < end; x++) { + int32_t bestMatch = + DecodeDigit(row, &counters, rowOffset, + &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + resultResult += (FX_CHAR)('0' + bestMatch); + for (int32_t i = 0; i < counters.GetSize(); i++) { + rowOffset += counters[i]; + } + } + int32_t RowOffsetLen = (rowOffset - rowOffsetLeft) / 4; + CFX_Int32Array result; + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]); + result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]); + CFX_Int32Array* middleRange = + FindGuardPattern(row, rowOffset, TRUE, &result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + int32_t rowOffsetMid = rowOffset; + rowOffset = (*middleRange)[1]; + if ((rowOffset - rowOffsetMid) > RowOffsetLen) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + delete middleRange; + for (int32_t y = 0; y < 4 && rowOffset < end; y++) { + int32_t bestMatch = + DecodeDigit(row, &counters, rowOffset, + &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + resultResult += (FX_CHAR)('0' + bestMatch); + for (int32_t i = 0; i < counters.GetSize(); i++) { + rowOffset += counters[i]; + } + } + return rowOffset; +} diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Reader.h b/xfa/fxbarcode/oned/BC_OnedEAN8Reader.h new file mode 100644 index 0000000000..fe2d33d66f --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Reader.h @@ -0,0 +1,25 @@ +// 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_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ + +class CBC_OneDimReader; +class CBC_CommonBitArray; +class CBC_OnedEAN8Reader; +class CBC_OnedEAN8Reader : public CBC_OneDimReader { + public: + CBC_OnedEAN8Reader(); + virtual ~CBC_OnedEAN8Reader(); + + protected: + int32_t DecodeMiddle(CBC_CommonBitArray*, + CFX_Int32Array* startRange, + CFX_ByteString& result, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp new file mode 100644 index 0000000000..5336867538 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -0,0 +1,268 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN8Writer.h" + +CBC_OnedEAN8Writer::CBC_OnedEAN8Writer() { + m_iDataLenth = 8; + m_codeWidth = 3 + (7 * 4) + 5 + (7 * 4) + 3; +} +CBC_OnedEAN8Writer::~CBC_OnedEAN8Writer() {} +void CBC_OnedEAN8Writer::SetDataLength(int32_t length) { + m_iDataLenth = 8; +} +FX_BOOL CBC_OnedEAN8Writer::SetTextLocation(BC_TEXT_LOC location) { + if (location == BC_TEXT_LOC_BELOWEMBED) { + m_locTextLoc = location; + return TRUE; + } + return FALSE; +} +FX_BOOL CBC_OnedEAN8Writer::CheckContentValidity( + const CFX_WideStringC& contents) { + for (int32_t i = 0; i < contents.GetLength(); i++) { + if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { + continue; + } else { + return FALSE; + } + } + return TRUE; +} +CFX_WideString CBC_OnedEAN8Writer::FilterContents( + const CFX_WideStringC& contents) { + CFX_WideString filtercontents; + FX_WCHAR ch; + for (int32_t i = 0; i < contents.GetLength(); i++) { + ch = contents.GetAt(i); + if (ch > 175) { + i++; + continue; + } + if (ch >= '0' && ch <= '9') { + filtercontents += ch; + } + } + return filtercontents; +} +int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) { + int32_t odd = 0; + int32_t even = 0; + int32_t j = 1; + for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { + if (j % 2) { + odd += FXSYS_atoi(contents.Mid(i, 1)); + } else { + even += FXSYS_atoi(contents.Mid(i, 1)); + } + j++; + } + int32_t checksum = (odd * 3 + even) % 10; + checksum = (10 - checksum) % 10; + return (checksum); +} +uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_EAN_8) { + e = BCExceptionOnlyEncodeEAN_8; + return NULL; + } + uint8_t* ret = + CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e) { + if (contents.GetLength() != 8) { + e = BCExceptionDigitLengthMustBe8; + return NULL; + } + outLength = m_codeWidth; + uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); + int32_t pos = 0; + pos += + AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + int32_t i = 0; + for (i = 0; i <= 3; i++) { + int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); + pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0, + e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + for (i = 4; i <= 7; i++) { + int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); + pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, + e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + } + pos += + AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); + if (e != BCExceptionNO) { + FX_Free(result); + return NULL; + } + return result; +} +void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { + if (device == NULL && pOutBitmap == NULL) { + e = BCExceptionIllegalArgument; + return; + } + int32_t leftPosition = 3 * multiple; + CFX_ByteString str = FX_UTF8Encode(contents); + int32_t iLength = str.GetLength(); + FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); + FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); + CFX_ByteString tempStr = str.Mid(0, 4); + int32_t iLen = tempStr.GetLength(); + int32_t strWidth = 7 * multiple * 4; + FX_FLOAT blank = 0.0; + CFX_FxgeDevice geBitmap; + if (pOutBitmap) { + geBitmap.Attach(pOutBitmap); + } + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + if (pOutBitmap == NULL) { + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect( + (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect1( + (FX_FLOAT)(leftPosition + 33 * multiple), + (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)(leftPosition + 33 * multiple + strWidth - 0.5), + (FX_FLOAT)m_Height); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + } + if (pOutBitmap == NULL) { + strWidth = (int32_t)(strWidth * m_outputHScale); + } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, + blank); + CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); + CFX_FxgeDevice ge; + if (pOutBitmap) { + delete ge.GetBitmap(); + ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)leftPosition * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + affine_matrix1.Concat(*matrix); + device->DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(4, 4); + iLen = tempStr.GetLength(); + CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, + blank); + if (pOutBitmap) { + delete ge.GetBitmap(); + ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, + m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1( + 1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 4, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + FX_Free(pCharPos); +} +void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); +} diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h new file mode 100644 index 0000000000..fc033ffcbf --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h @@ -0,0 +1,55 @@ +// 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_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ + +enum BC_TEXT_LOC; +class CBC_OneDimWriter; +class CBC_OnedEAN8Writer; +class CBC_OnedEAN8Writer : public CBC_OneDimWriter { + private: + int32_t m_codeWidth; + + public: + CBC_OnedEAN8Writer(); + virtual ~CBC_OnedEAN8Writer(); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e); + void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + void SetDataLength(int32_t length); + FX_BOOL SetTextLocation(BC_TEXT_LOC location); + int32_t CalcChecksum(const CFX_ByteString& contents); + + protected: + void ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp new file mode 100644 index 0000000000..95b0f24775 --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedUPCAReader.cpp @@ -0,0 +1,97 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/oned/BC_OneDReader.h" +#include "xfa/fxbarcode/oned/BC_OneDimReader.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Reader.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAReader.h" +#include "xfa/fxbarcode/utils.h" + +CBC_OnedUPCAReader::CBC_OnedUPCAReader() { + m_ean13Reader = NULL; +} +void CBC_OnedUPCAReader::Init() { + m_ean13Reader = new CBC_OnedEAN13Reader; +} +CBC_OnedUPCAReader::~CBC_OnedUPCAReader() { + delete m_ean13Reader; +} +CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e) { + CFX_ByteString bytestring = + m_ean13Reader->DecodeRow(rowNumber, row, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CFX_ByteString temp = MaybeReturnResult(bytestring, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return temp; +} +CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + CFX_Int32Array* startGuardRange, + int32_t hints, + int32_t& e) { + CFX_ByteString bytestring = + m_ean13Reader->DecodeRow(rowNumber, row, startGuardRange, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CFX_ByteString temp = MaybeReturnResult(bytestring, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return temp; +} +CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { + CFX_ByteString bytestring = m_ean13Reader->Decode(image, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CFX_ByteString temp = MaybeReturnResult(bytestring, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return temp; +} +CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + CFX_ByteString bytestring = m_ean13Reader->Decode(image, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CFX_ByteString temp = MaybeReturnResult(bytestring, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return temp; +} +int32_t CBC_OnedUPCAReader::DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultString, + int32_t& e) { + int32_t temp = m_ean13Reader->DecodeMiddle(row, startRange, resultString, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + return temp; +} +CFX_ByteString CBC_OnedUPCAReader::MaybeReturnResult(CFX_ByteString& result, + int32_t& e) { + if (result[0] == '0') { + result.Delete(0); + return result; + } else { + e = BCExceptionFormatException; + return ""; + } + return ""; +} diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAReader.h b/xfa/fxbarcode/oned/BC_OnedUPCAReader.h new file mode 100644 index 0000000000..306683e1cc --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedUPCAReader.h @@ -0,0 +1,43 @@ +// 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_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ + +class CBC_BinaryBitmap; +class CBC_CommonBitArray; +class CBC_OneDimReader; +class CBC_OnedEAN13Reader; +class CBC_OnedUPCAReader; +class CBC_OnedUPCAReader : public CBC_OneDimReader { + private: + CBC_OnedEAN13Reader* m_ean13Reader; + + public: + CBC_OnedUPCAReader(); + virtual ~CBC_OnedUPCAReader(); + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + int32_t hints, + int32_t& e); + CFX_ByteString DecodeRow(int32_t rowNumber, + CBC_CommonBitArray* row, + CFX_Int32Array* startGuardRange, + int32_t hints, + int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); + virtual void Init(); + + protected: + int32_t DecodeMiddle(CBC_CommonBitArray* row, + CFX_Int32Array* startRange, + CFX_ByteString& resultString, + int32_t& e); + CFX_ByteString MaybeReturnResult(CFX_ByteString& result, int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp new file mode 100644 index 0000000000..21ccafc20c --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -0,0 +1,286 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Writer.h" +#include "xfa/fxbarcode/oned/BC_OneDimWriter.h" +#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h" +#include "xfa/fxbarcode/oned/BC_OnedUPCAWriter.h" + +CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() { + m_subWriter = NULL; + m_bLeftPadding = TRUE; + m_bRightPadding = TRUE; +} +void CBC_OnedUPCAWriter::Init() { + m_subWriter = new CBC_OnedEAN13Writer; +} +CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { + delete m_subWriter; +} +FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( + const CFX_WideStringC& contents) { + int32_t i = 0; + for (i = 0; i < contents.GetLength(); i++) { + if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { + continue; + } else { + return FALSE; + } + } + return TRUE; +} +CFX_WideString CBC_OnedUPCAWriter::FilterContents( + const CFX_WideStringC& contents) { + CFX_WideString filtercontents; + FX_WCHAR ch; + for (int32_t i = 0; i < contents.GetLength(); i++) { + ch = contents.GetAt(i); + if (ch > 175) { + i++; + continue; + } + if (ch >= '0' && ch <= '9') { + filtercontents += ch; + } + } + return filtercontents; +} +int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) { + int32_t odd = 0; + int32_t even = 0; + int32_t j = 1; + for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { + if (j % 2) { + odd += FXSYS_atoi(contents.Mid(i, 1)); + } else { + even += FXSYS_atoi(contents.Mid(i, 1)); + } + j++; + } + int32_t checksum = (odd * 3 + even) % 10; + checksum = (10 - checksum) % 10; + return (checksum); +} +uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + if (format != BCFORMAT_UPC_A) { + e = BCExceptionOnlyEncodeUPC_A; + return NULL; + } + CFX_ByteString toEAN13String = '0' + contents; + m_iDataLenth = 13; + uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, + outHeight, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return ret; +} +void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { + if (device == NULL && pOutBitmap == NULL) { + e = BCExceptionIllegalArgument; + return; + } + int32_t leftPadding = 7 * multiple; + int32_t leftPosition = 10 * multiple + leftPadding; + CFX_ByteString str = FX_UTF8Encode(contents); + int32_t iLen = str.GetLength(); + FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); + FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); + CFX_ByteString tempStr = str.Mid(1, 5); + FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; + FX_FLOAT blank = 0.0; + CFX_FxgeDevice geBitmap; + if (pOutBitmap) { + geBitmap.Attach(pOutBitmap); + } + iLen = tempStr.GetLength(); + int32_t iFontSize = (int32_t)fabs(m_fFontSize); + int32_t iTextHeight = iFontSize + 1; + if (pOutBitmap == NULL) { + CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect( + (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); + matr.Concat(*matrix); + matr.TransformRect(rect); + FX_RECT re = rect.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect1( + (FX_FLOAT)(leftPosition + 40 * multiple), + (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), + (FX_FLOAT)m_Height); + matr1.Concat(*matrix); + matr1.TransformRect(rect1); + re = rect1.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7; + CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height); + matr2.Concat(*matrix); + matr2.TransformRect(rect2); + re = rect2.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); + CFX_FloatRect rect3( + (FX_FLOAT)(leftPosition + 85 * multiple), + (FX_FLOAT)(m_Height - iTextHeight), + (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5), + (FX_FLOAT)m_Height); + matr3.Concat(*matrix); + matr3.TransformRect(rect3); + re = rect3.GetOutterRect(); + device->FillRect(&re, m_backgroundColor); + } + if (pOutBitmap == NULL) { + strWidth = strWidth * m_outputHScale; + } + CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); + CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); + CFX_FxgeDevice ge; + if (pOutBitmap) { + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)leftPosition * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 1, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(6, 5); + iLen = tempStr.GetLength(); + CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); + if (pOutBitmap) { + FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); + ge.FillRect(&rect2, m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, + m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1( + 1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 6, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(0, 1); + iLen = tempStr.GetLength(); + strWidth = (FX_FLOAT)multiple * 7; + if (pOutBitmap == NULL) { + strWidth = strWidth * m_outputHScale; + } + CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); + if (pOutBitmap) { + delete ge.GetBitmap(); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + tempStr = str.Mid(11, 1); + iLen = tempStr.GetLength(); + CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); + if (pOutBitmap) { + delete ge.GetBitmap(); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.GetBitmap()->Clear(m_backgroundColor); + ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, + CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, + (CFX_Matrix*)&affine_matrix, m_fontColor, + FXTEXT_CLEARTYPE); + geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, + m_Height - iTextHeight); + } else { + CFX_Matrix affine_matrix1( + 1.0, 0.0, 0.0, -1.0, + (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, + (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); + if (matrix) { + affine_matrix1.Concat(*matrix); + } + device->DrawNormalText(iLen, pCharPos + 11, m_pFont, + CFX_GEModule::Get()->GetFontCache(), + (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, + m_fontColor, FXTEXT_CLEARTYPE); + } + FX_Free(pCharPos); +} +void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e) { + CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); +} diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h new file mode 100644 index 0000000000..f376929b1b --- /dev/null +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h @@ -0,0 +1,55 @@ +// 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_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ +#define XFA_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ + +class CBC_OnedEAN13Writer; +class CBC_OnedUPCAWriter; +class CBC_OnedUPCAWriter : public CBC_OneDimWriter { + private: + CBC_OnedEAN13Writer* m_subWriter; + + public: + CBC_OnedUPCAWriter(); + virtual ~CBC_OnedUPCAWriter(); + virtual void Init(); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + int32_t& outLength, + int32_t& e) { + return nullptr; + } + void RenderResult(const CFX_WideStringC& contents, + uint8_t* code, + int32_t codeLength, + FX_BOOL isDevice, + int32_t& e); + FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); + CFX_WideString FilterContents(const CFX_WideStringC& contents); + int32_t CalcChecksum(const CFX_ByteString& contents); + + protected: + void ShowChars(const CFX_WideStringC& contents, + CFX_DIBitmap* pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp new file mode 100644 index 0000000000..e57a79e17e --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp @@ -0,0 +1,586 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" +#include "xfa/fxbarcode/utils.h" + +int32_t CBC_PDF417::START_PATTERN = 0x1fea8; +int32_t CBC_PDF417::STOP_PATTERN = 0x3fa29; +int32_t CBC_PDF417::CODEWORD_TABLE[][1000] = { + {0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470, + 0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, + 0x1d678, 0x1eb3e, 0x158c0, 0x1ac70, 0x15860, 0x15dc0, 0x1aef0, 0x1d77c, + 0x15ce0, 0x1ae78, 0x1d73e, 0x15c70, 0x1ae3c, 0x15ef0, 0x1af7c, 0x15e78, + 0x1af3e, 0x15f7c, 0x1f5fa, 0x1d2e0, 0x1e978, 0x1f4be, 0x1a4c0, 0x1d270, + 0x1e93c, 0x1a460, 0x1d238, 0x14840, 0x1a430, 0x1d21c, 0x14820, 0x1a418, + 0x14810, 0x1a6e0, 0x1d378, 0x1e9be, 0x14cc0, 0x1a670, 0x1d33c, 0x14c60, + 0x1a638, 0x1d31e, 0x14c30, 0x1a61c, 0x14ee0, 0x1a778, 0x1d3be, 0x14e70, + 0x1a73c, 0x14e38, 0x1a71e, 0x14f78, 0x1a7be, 0x14f3c, 0x14f1e, 0x1a2c0, + 0x1d170, 0x1e8bc, 0x1a260, 0x1d138, 0x1e89e, 0x14440, 0x1a230, 0x1d11c, + 0x14420, 0x1a218, 0x14410, 0x14408, 0x146c0, 0x1a370, 0x1d1bc, 0x14660, + 0x1a338, 0x1d19e, 0x14630, 0x1a31c, 0x14618, 0x1460c, 0x14770, 0x1a3bc, + 0x14738, 0x1a39e, 0x1471c, 0x147bc, 0x1a160, 0x1d0b8, 0x1e85e, 0x14240, + 0x1a130, 0x1d09c, 0x14220, 0x1a118, 0x1d08e, 0x14210, 0x1a10c, 0x14208, + 0x1a106, 0x14360, 0x1a1b8, 0x1d0de, 0x14330, 0x1a19c, 0x14318, 0x1a18e, + 0x1430c, 0x14306, 0x1a1de, 0x1438e, 0x14140, 0x1a0b0, 0x1d05c, 0x14120, + 0x1a098, 0x1d04e, 0x14110, 0x1a08c, 0x14108, 0x1a086, 0x14104, 0x141b0, + 0x14198, 0x1418c, 0x140a0, 0x1d02e, 0x1a04c, 0x1a046, 0x14082, 0x1cae0, + 0x1e578, 0x1f2be, 0x194c0, 0x1ca70, 0x1e53c, 0x19460, 0x1ca38, 0x1e51e, + 0x12840, 0x19430, 0x12820, 0x196e0, 0x1cb78, 0x1e5be, 0x12cc0, 0x19670, + 0x1cb3c, 0x12c60, 0x19638, 0x12c30, 0x12c18, 0x12ee0, 0x19778, 0x1cbbe, + 0x12e70, 0x1973c, 0x12e38, 0x12e1c, 0x12f78, 0x197be, 0x12f3c, 0x12fbe, + 0x1dac0, 0x1ed70, 0x1f6bc, 0x1da60, 0x1ed38, 0x1f69e, 0x1b440, 0x1da30, + 0x1ed1c, 0x1b420, 0x1da18, 0x1ed0e, 0x1b410, 0x1da0c, 0x192c0, 0x1c970, + 0x1e4bc, 0x1b6c0, 0x19260, 0x1c938, 0x1e49e, 0x1b660, 0x1db38, 0x1ed9e, + 0x16c40, 0x12420, 0x19218, 0x1c90e, 0x16c20, 0x1b618, 0x16c10, 0x126c0, + 0x19370, 0x1c9bc, 0x16ec0, 0x12660, 0x19338, 0x1c99e, 0x16e60, 0x1b738, + 0x1db9e, 0x16e30, 0x12618, 0x16e18, 0x12770, 0x193bc, 0x16f70, 0x12738, + 0x1939e, 0x16f38, 0x1b79e, 0x16f1c, 0x127bc, 0x16fbc, 0x1279e, 0x16f9e, + 0x1d960, 0x1ecb8, 0x1f65e, 0x1b240, 0x1d930, 0x1ec9c, 0x1b220, 0x1d918, + 0x1ec8e, 0x1b210, 0x1d90c, 0x1b208, 0x1b204, 0x19160, 0x1c8b8, 0x1e45e, + 0x1b360, 0x19130, 0x1c89c, 0x16640, 0x12220, 0x1d99c, 0x1c88e, 0x16620, + 0x12210, 0x1910c, 0x16610, 0x1b30c, 0x19106, 0x12204, 0x12360, 0x191b8, + 0x1c8de, 0x16760, 0x12330, 0x1919c, 0x16730, 0x1b39c, 0x1918e, 0x16718, + 0x1230c, 0x12306, 0x123b8, 0x191de, 0x167b8, 0x1239c, 0x1679c, 0x1238e, + 0x1678e, 0x167de, 0x1b140, 0x1d8b0, 0x1ec5c, 0x1b120, 0x1d898, 0x1ec4e, + 0x1b110, 0x1d88c, 0x1b108, 0x1d886, 0x1b104, 0x1b102, 0x12140, 0x190b0, + 0x1c85c, 0x16340, 0x12120, 0x19098, 0x1c84e, 0x16320, 0x1b198, 0x1d8ce, + 0x16310, 0x12108, 0x19086, 0x16308, 0x1b186, 0x16304, 0x121b0, 0x190dc, + 0x163b0, 0x12198, 0x190ce, 0x16398, 0x1b1ce, 0x1638c, 0x12186, 0x16386, + 0x163dc, 0x163ce, 0x1b0a0, 0x1d858, 0x1ec2e, 0x1b090, 0x1d84c, 0x1b088, + 0x1d846, 0x1b084, 0x1b082, 0x120a0, 0x19058, 0x1c82e, 0x161a0, 0x12090, + 0x1904c, 0x16190, 0x1b0cc, 0x19046, 0x16188, 0x12084, 0x16184, 0x12082, + 0x120d8, 0x161d8, 0x161cc, 0x161c6, 0x1d82c, 0x1d826, 0x1b042, 0x1902c, + 0x12048, 0x160c8, 0x160c4, 0x160c2, 0x18ac0, 0x1c570, 0x1e2bc, 0x18a60, + 0x1c538, 0x11440, 0x18a30, 0x1c51c, 0x11420, 0x18a18, 0x11410, 0x11408, + 0x116c0, 0x18b70, 0x1c5bc, 0x11660, 0x18b38, 0x1c59e, 0x11630, 0x18b1c, + 0x11618, 0x1160c, 0x11770, 0x18bbc, 0x11738, 0x18b9e, 0x1171c, 0x117bc, + 0x1179e, 0x1cd60, 0x1e6b8, 0x1f35e, 0x19a40, 0x1cd30, 0x1e69c, 0x19a20, + 0x1cd18, 0x1e68e, 0x19a10, 0x1cd0c, 0x19a08, 0x1cd06, 0x18960, 0x1c4b8, + 0x1e25e, 0x19b60, 0x18930, 0x1c49c, 0x13640, 0x11220, 0x1cd9c, 0x1c48e, + 0x13620, 0x19b18, 0x1890c, 0x13610, 0x11208, 0x13608, 0x11360, 0x189b8, + 0x1c4de, 0x13760, 0x11330, 0x1cdde, 0x13730, 0x19b9c, 0x1898e, 0x13718, + 0x1130c, 0x1370c, 0x113b8, 0x189de, 0x137b8, 0x1139c, 0x1379c, 0x1138e, + 0x113de, 0x137de, 0x1dd40, 0x1eeb0, 0x1f75c, 0x1dd20, 0x1ee98, 0x1f74e, + 0x1dd10, 0x1ee8c, 0x1dd08, 0x1ee86, 0x1dd04, 0x19940, 0x1ccb0, 0x1e65c, + 0x1bb40, 0x19920, 0x1eedc, 0x1e64e, 0x1bb20, 0x1dd98, 0x1eece, 0x1bb10, + 0x19908, 0x1cc86, 0x1bb08, 0x1dd86, 0x19902, 0x11140, 0x188b0, 0x1c45c, + 0x13340, 0x11120, 0x18898, 0x1c44e, 0x17740, 0x13320, 0x19998, 0x1ccce, + 0x17720, 0x1bb98, 0x1ddce, 0x18886, 0x17710, 0x13308, 0x19986, 0x17708, + 0x11102, 0x111b0, 0x188dc, 0x133b0, 0x11198, 0x188ce, 0x177b0, 0x13398, + 0x199ce, 0x17798, 0x1bbce, 0x11186, 0x13386, 0x111dc, 0x133dc, 0x111ce, + 0x177dc, 0x133ce, 0x1dca0, 0x1ee58, 0x1f72e, 0x1dc90, 0x1ee4c, 0x1dc88, + 0x1ee46, 0x1dc84, 0x1dc82, 0x198a0, 0x1cc58, 0x1e62e, 0x1b9a0, 0x19890, + 0x1ee6e, 0x1b990, 0x1dccc, 0x1cc46, 0x1b988, 0x19884, 0x1b984, 0x19882, + 0x1b982, 0x110a0, 0x18858, 0x1c42e, 0x131a0, 0x11090, 0x1884c, 0x173a0, + 0x13190, 0x198cc, 0x18846, 0x17390, 0x1b9cc, 0x11084, 0x17388, 0x13184, + 0x11082, 0x13182, 0x110d8, 0x1886e, 0x131d8, 0x110cc, 0x173d8, 0x131cc, + 0x110c6, 0x173cc, 0x131c6, 0x110ee, 0x173ee, 0x1dc50, 0x1ee2c, 0x1dc48, + 0x1ee26, 0x1dc44, 0x1dc42, 0x19850, 0x1cc2c, 0x1b8d0, 0x19848, 0x1cc26, + 0x1b8c8, 0x1dc66, 0x1b8c4, 0x19842, 0x1b8c2, 0x11050, 0x1882c, 0x130d0, + 0x11048, 0x18826, 0x171d0, 0x130c8, 0x19866, 0x171c8, 0x1b8e6, 0x11042, + 0x171c4, 0x130c2, 0x171c2, 0x130ec, 0x171ec, 0x171e6, 0x1ee16, 0x1dc22, + 0x1cc16, 0x19824, 0x19822, 0x11028, 0x13068, 0x170e8, 0x11022, 0x13062, + 0x18560, 0x10a40, 0x18530, 0x10a20, 0x18518, 0x1c28e, 0x10a10, 0x1850c, + 0x10a08, 0x18506, 0x10b60, 0x185b8, 0x1c2de, 0x10b30, 0x1859c, 0x10b18, + 0x1858e, 0x10b0c, 0x10b06, 0x10bb8, 0x185de, 0x10b9c, 0x10b8e, 0x10bde, + 0x18d40, 0x1c6b0, 0x1e35c, 0x18d20, 0x1c698, 0x18d10, 0x1c68c, 0x18d08, + 0x1c686, 0x18d04, 0x10940, 0x184b0, 0x1c25c, 0x11b40, 0x10920, 0x1c6dc, + 0x1c24e, 0x11b20, 0x18d98, 0x1c6ce, 0x11b10, 0x10908, 0x18486, 0x11b08, + 0x18d86, 0x10902, 0x109b0, 0x184dc, 0x11bb0, 0x10998, 0x184ce, 0x11b98, + 0x18dce, 0x11b8c, 0x10986, 0x109dc, 0x11bdc, 0x109ce, 0x11bce, 0x1cea0, + 0x1e758, 0x1f3ae, 0x1ce90, 0x1e74c, 0x1ce88, 0x1e746, 0x1ce84, 0x1ce82, + 0x18ca0, 0x1c658, 0x19da0, 0x18c90, 0x1c64c, 0x19d90, 0x1cecc, 0x1c646, + 0x19d88, 0x18c84, 0x19d84, 0x18c82, 0x19d82, 0x108a0, 0x18458, 0x119a0, + 0x10890, 0x1c66e, 0x13ba0, 0x11990, 0x18ccc, 0x18446, 0x13b90, 0x19dcc, + 0x10884, 0x13b88, 0x11984, 0x10882, 0x11982, 0x108d8, 0x1846e, 0x119d8, + 0x108cc, 0x13bd8, 0x119cc, 0x108c6, 0x13bcc, 0x119c6, 0x108ee, 0x119ee, + 0x13bee, 0x1ef50, 0x1f7ac, 0x1ef48, 0x1f7a6, 0x1ef44, 0x1ef42, 0x1ce50, + 0x1e72c, 0x1ded0, 0x1ef6c, 0x1e726, 0x1dec8, 0x1ef66, 0x1dec4, 0x1ce42, + 0x1dec2, 0x18c50, 0x1c62c, 0x19cd0, 0x18c48, 0x1c626, 0x1bdd0, 0x19cc8, + 0x1ce66, 0x1bdc8, 0x1dee6, 0x18c42, 0x1bdc4, 0x19cc2, 0x1bdc2, 0x10850, + 0x1842c, 0x118d0, 0x10848, 0x18426, 0x139d0, 0x118c8, 0x18c66, 0x17bd0, + 0x139c8, 0x19ce6, 0x10842, 0x17bc8, 0x1bde6, 0x118c2, 0x17bc4, 0x1086c, + 0x118ec, 0x10866, 0x139ec, 0x118e6, 0x17bec, 0x139e6, 0x17be6, 0x1ef28, + 0x1f796, 0x1ef24, 0x1ef22, 0x1ce28, 0x1e716, 0x1de68, 0x1ef36, 0x1de64, + 0x1ce22, 0x1de62, 0x18c28, 0x1c616, 0x19c68, 0x18c24, 0x1bce8, 0x19c64, + 0x18c22, 0x1bce4, 0x19c62, 0x1bce2, 0x10828, 0x18416, 0x11868, 0x18c36, + 0x138e8, 0x11864, 0x10822, 0x179e8, 0x138e4, 0x11862, 0x179e4, 0x138e2, + 0x179e2, 0x11876, 0x179f6, 0x1ef12, 0x1de34, 0x1de32, 0x19c34, 0x1bc74, + 0x1bc72, 0x11834, 0x13874, 0x178f4, 0x178f2, 0x10540, 0x10520, 0x18298, + 0x10510, 0x10508, 0x10504, 0x105b0, 0x10598, 0x1058c, 0x10586, 0x105dc, + 0x105ce, 0x186a0, 0x18690, 0x1c34c, 0x18688, 0x1c346, 0x18684, 0x18682, + 0x104a0, 0x18258, 0x10da0, 0x186d8, 0x1824c, 0x10d90, 0x186cc, 0x10d88, + 0x186c6, 0x10d84, 0x10482, 0x10d82, 0x104d8, 0x1826e, 0x10dd8, 0x186ee, + 0x10dcc, 0x104c6, 0x10dc6, 0x104ee, 0x10dee, 0x1c750, 0x1c748, 0x1c744, + 0x1c742, 0x18650, 0x18ed0, 0x1c76c, 0x1c326, 0x18ec8, 0x1c766, 0x18ec4, + 0x18642, 0x18ec2, 0x10450, 0x10cd0, 0x10448, 0x18226, 0x11dd0, 0x10cc8, + 0x10444, 0x11dc8, 0x10cc4, 0x10442, 0x11dc4, 0x10cc2, 0x1046c, 0x10cec, + 0x10466, 0x11dec, 0x10ce6, 0x11de6, 0x1e7a8, 0x1e7a4, 0x1e7a2, 0x1c728, + 0x1cf68, 0x1e7b6, 0x1cf64, 0x1c722, 0x1cf62, 0x18628, 0x1c316, 0x18e68, + 0x1c736, 0x19ee8, 0x18e64, 0x18622, 0x19ee4, 0x18e62, 0x19ee2, 0x10428, + 0x18216, 0x10c68, 0x18636, 0x11ce8, 0x10c64, 0x10422, 0x13de8, 0x11ce4, + 0x10c62, 0x13de4, 0x11ce2, 0x10436, 0x10c76, 0x11cf6, 0x13df6, 0x1f7d4, + 0x1f7d2, 0x1e794, 0x1efb4, 0x1e792, 0x1efb2, 0x1c714, 0x1cf34, 0x1c712, + 0x1df74, 0x1cf32, 0x1df72, 0x18614, 0x18e34, 0x18612, 0x19e74, 0x18e32, + 0x1bef4}, + {0x1f560, 0x1fab8, 0x1ea40, 0x1f530, 0x1fa9c, 0x1ea20, 0x1f518, 0x1fa8e, + 0x1ea10, 0x1f50c, 0x1ea08, 0x1f506, 0x1ea04, 0x1eb60, 0x1f5b8, 0x1fade, + 0x1d640, 0x1eb30, 0x1f59c, 0x1d620, 0x1eb18, 0x1f58e, 0x1d610, 0x1eb0c, + 0x1d608, 0x1eb06, 0x1d604, 0x1d760, 0x1ebb8, 0x1f5de, 0x1ae40, 0x1d730, + 0x1eb9c, 0x1ae20, 0x1d718, 0x1eb8e, 0x1ae10, 0x1d70c, 0x1ae08, 0x1d706, + 0x1ae04, 0x1af60, 0x1d7b8, 0x1ebde, 0x15e40, 0x1af30, 0x1d79c, 0x15e20, + 0x1af18, 0x1d78e, 0x15e10, 0x1af0c, 0x15e08, 0x1af06, 0x15f60, 0x1afb8, + 0x1d7de, 0x15f30, 0x1af9c, 0x15f18, 0x1af8e, 0x15f0c, 0x15fb8, 0x1afde, + 0x15f9c, 0x15f8e, 0x1e940, 0x1f4b0, 0x1fa5c, 0x1e920, 0x1f498, 0x1fa4e, + 0x1e910, 0x1f48c, 0x1e908, 0x1f486, 0x1e904, 0x1e902, 0x1d340, 0x1e9b0, + 0x1f4dc, 0x1d320, 0x1e998, 0x1f4ce, 0x1d310, 0x1e98c, 0x1d308, 0x1e986, + 0x1d304, 0x1d302, 0x1a740, 0x1d3b0, 0x1e9dc, 0x1a720, 0x1d398, 0x1e9ce, + 0x1a710, 0x1d38c, 0x1a708, 0x1d386, 0x1a704, 0x1a702, 0x14f40, 0x1a7b0, + 0x1d3dc, 0x14f20, 0x1a798, 0x1d3ce, 0x14f10, 0x1a78c, 0x14f08, 0x1a786, + 0x14f04, 0x14fb0, 0x1a7dc, 0x14f98, 0x1a7ce, 0x14f8c, 0x14f86, 0x14fdc, + 0x14fce, 0x1e8a0, 0x1f458, 0x1fa2e, 0x1e890, 0x1f44c, 0x1e888, 0x1f446, + 0x1e884, 0x1e882, 0x1d1a0, 0x1e8d8, 0x1f46e, 0x1d190, 0x1e8cc, 0x1d188, + 0x1e8c6, 0x1d184, 0x1d182, 0x1a3a0, 0x1d1d8, 0x1e8ee, 0x1a390, 0x1d1cc, + 0x1a388, 0x1d1c6, 0x1a384, 0x1a382, 0x147a0, 0x1a3d8, 0x1d1ee, 0x14790, + 0x1a3cc, 0x14788, 0x1a3c6, 0x14784, 0x14782, 0x147d8, 0x1a3ee, 0x147cc, + 0x147c6, 0x147ee, 0x1e850, 0x1f42c, 0x1e848, 0x1f426, 0x1e844, 0x1e842, + 0x1d0d0, 0x1e86c, 0x1d0c8, 0x1e866, 0x1d0c4, 0x1d0c2, 0x1a1d0, 0x1d0ec, + 0x1a1c8, 0x1d0e6, 0x1a1c4, 0x1a1c2, 0x143d0, 0x1a1ec, 0x143c8, 0x1a1e6, + 0x143c4, 0x143c2, 0x143ec, 0x143e6, 0x1e828, 0x1f416, 0x1e824, 0x1e822, + 0x1d068, 0x1e836, 0x1d064, 0x1d062, 0x1a0e8, 0x1d076, 0x1a0e4, 0x1a0e2, + 0x141e8, 0x1a0f6, 0x141e4, 0x141e2, 0x1e814, 0x1e812, 0x1d034, 0x1d032, + 0x1a074, 0x1a072, 0x1e540, 0x1f2b0, 0x1f95c, 0x1e520, 0x1f298, 0x1f94e, + 0x1e510, 0x1f28c, 0x1e508, 0x1f286, 0x1e504, 0x1e502, 0x1cb40, 0x1e5b0, + 0x1f2dc, 0x1cb20, 0x1e598, 0x1f2ce, 0x1cb10, 0x1e58c, 0x1cb08, 0x1e586, + 0x1cb04, 0x1cb02, 0x19740, 0x1cbb0, 0x1e5dc, 0x19720, 0x1cb98, 0x1e5ce, + 0x19710, 0x1cb8c, 0x19708, 0x1cb86, 0x19704, 0x19702, 0x12f40, 0x197b0, + 0x1cbdc, 0x12f20, 0x19798, 0x1cbce, 0x12f10, 0x1978c, 0x12f08, 0x19786, + 0x12f04, 0x12fb0, 0x197dc, 0x12f98, 0x197ce, 0x12f8c, 0x12f86, 0x12fdc, + 0x12fce, 0x1f6a0, 0x1fb58, 0x16bf0, 0x1f690, 0x1fb4c, 0x169f8, 0x1f688, + 0x1fb46, 0x168fc, 0x1f684, 0x1f682, 0x1e4a0, 0x1f258, 0x1f92e, 0x1eda0, + 0x1e490, 0x1fb6e, 0x1ed90, 0x1f6cc, 0x1f246, 0x1ed88, 0x1e484, 0x1ed84, + 0x1e482, 0x1ed82, 0x1c9a0, 0x1e4d8, 0x1f26e, 0x1dba0, 0x1c990, 0x1e4cc, + 0x1db90, 0x1edcc, 0x1e4c6, 0x1db88, 0x1c984, 0x1db84, 0x1c982, 0x1db82, + 0x193a0, 0x1c9d8, 0x1e4ee, 0x1b7a0, 0x19390, 0x1c9cc, 0x1b790, 0x1dbcc, + 0x1c9c6, 0x1b788, 0x19384, 0x1b784, 0x19382, 0x1b782, 0x127a0, 0x193d8, + 0x1c9ee, 0x16fa0, 0x12790, 0x193cc, 0x16f90, 0x1b7cc, 0x193c6, 0x16f88, + 0x12784, 0x16f84, 0x12782, 0x127d8, 0x193ee, 0x16fd8, 0x127cc, 0x16fcc, + 0x127c6, 0x16fc6, 0x127ee, 0x1f650, 0x1fb2c, 0x165f8, 0x1f648, 0x1fb26, + 0x164fc, 0x1f644, 0x1647e, 0x1f642, 0x1e450, 0x1f22c, 0x1ecd0, 0x1e448, + 0x1f226, 0x1ecc8, 0x1f666, 0x1ecc4, 0x1e442, 0x1ecc2, 0x1c8d0, 0x1e46c, + 0x1d9d0, 0x1c8c8, 0x1e466, 0x1d9c8, 0x1ece6, 0x1d9c4, 0x1c8c2, 0x1d9c2, + 0x191d0, 0x1c8ec, 0x1b3d0, 0x191c8, 0x1c8e6, 0x1b3c8, 0x1d9e6, 0x1b3c4, + 0x191c2, 0x1b3c2, 0x123d0, 0x191ec, 0x167d0, 0x123c8, 0x191e6, 0x167c8, + 0x1b3e6, 0x167c4, 0x123c2, 0x167c2, 0x123ec, 0x167ec, 0x123e6, 0x167e6, + 0x1f628, 0x1fb16, 0x162fc, 0x1f624, 0x1627e, 0x1f622, 0x1e428, 0x1f216, + 0x1ec68, 0x1f636, 0x1ec64, 0x1e422, 0x1ec62, 0x1c868, 0x1e436, 0x1d8e8, + 0x1c864, 0x1d8e4, 0x1c862, 0x1d8e2, 0x190e8, 0x1c876, 0x1b1e8, 0x1d8f6, + 0x1b1e4, 0x190e2, 0x1b1e2, 0x121e8, 0x190f6, 0x163e8, 0x121e4, 0x163e4, + 0x121e2, 0x163e2, 0x121f6, 0x163f6, 0x1f614, 0x1617e, 0x1f612, 0x1e414, + 0x1ec34, 0x1e412, 0x1ec32, 0x1c834, 0x1d874, 0x1c832, 0x1d872, 0x19074, + 0x1b0f4, 0x19072, 0x1b0f2, 0x120f4, 0x161f4, 0x120f2, 0x161f2, 0x1f60a, + 0x1e40a, 0x1ec1a, 0x1c81a, 0x1d83a, 0x1903a, 0x1b07a, 0x1e2a0, 0x1f158, + 0x1f8ae, 0x1e290, 0x1f14c, 0x1e288, 0x1f146, 0x1e284, 0x1e282, 0x1c5a0, + 0x1e2d8, 0x1f16e, 0x1c590, 0x1e2cc, 0x1c588, 0x1e2c6, 0x1c584, 0x1c582, + 0x18ba0, 0x1c5d8, 0x1e2ee, 0x18b90, 0x1c5cc, 0x18b88, 0x1c5c6, 0x18b84, + 0x18b82, 0x117a0, 0x18bd8, 0x1c5ee, 0x11790, 0x18bcc, 0x11788, 0x18bc6, + 0x11784, 0x11782, 0x117d8, 0x18bee, 0x117cc, 0x117c6, 0x117ee, 0x1f350, + 0x1f9ac, 0x135f8, 0x1f348, 0x1f9a6, 0x134fc, 0x1f344, 0x1347e, 0x1f342, + 0x1e250, 0x1f12c, 0x1e6d0, 0x1e248, 0x1f126, 0x1e6c8, 0x1f366, 0x1e6c4, + 0x1e242, 0x1e6c2, 0x1c4d0, 0x1e26c, 0x1cdd0, 0x1c4c8, 0x1e266, 0x1cdc8, + 0x1e6e6, 0x1cdc4, 0x1c4c2, 0x1cdc2, 0x189d0, 0x1c4ec, 0x19bd0, 0x189c8, + 0x1c4e6, 0x19bc8, 0x1cde6, 0x19bc4, 0x189c2, 0x19bc2, 0x113d0, 0x189ec, + 0x137d0, 0x113c8, 0x189e6, 0x137c8, 0x19be6, 0x137c4, 0x113c2, 0x137c2, + 0x113ec, 0x137ec, 0x113e6, 0x137e6, 0x1fba8, 0x175f0, 0x1bafc, 0x1fba4, + 0x174f8, 0x1ba7e, 0x1fba2, 0x1747c, 0x1743e, 0x1f328, 0x1f996, 0x132fc, + 0x1f768, 0x1fbb6, 0x176fc, 0x1327e, 0x1f764, 0x1f322, 0x1767e, 0x1f762, + 0x1e228, 0x1f116, 0x1e668, 0x1e224, 0x1eee8, 0x1f776, 0x1e222, 0x1eee4, + 0x1e662, 0x1eee2, 0x1c468, 0x1e236, 0x1cce8, 0x1c464, 0x1dde8, 0x1cce4, + 0x1c462, 0x1dde4, 0x1cce2, 0x1dde2, 0x188e8, 0x1c476, 0x199e8, 0x188e4, + 0x1bbe8, 0x199e4, 0x188e2, 0x1bbe4, 0x199e2, 0x1bbe2, 0x111e8, 0x188f6, + 0x133e8, 0x111e4, 0x177e8, 0x133e4, 0x111e2, 0x177e4, 0x133e2, 0x177e2, + 0x111f6, 0x133f6, 0x1fb94, 0x172f8, 0x1b97e, 0x1fb92, 0x1727c, 0x1723e, + 0x1f314, 0x1317e, 0x1f734, 0x1f312, 0x1737e, 0x1f732, 0x1e214, 0x1e634, + 0x1e212, 0x1ee74, 0x1e632, 0x1ee72, 0x1c434, 0x1cc74, 0x1c432, 0x1dcf4, + 0x1cc72, 0x1dcf2, 0x18874, 0x198f4, 0x18872, 0x1b9f4, 0x198f2, 0x1b9f2, + 0x110f4, 0x131f4, 0x110f2, 0x173f4, 0x131f2, 0x173f2, 0x1fb8a, 0x1717c, + 0x1713e, 0x1f30a, 0x1f71a, 0x1e20a, 0x1e61a, 0x1ee3a, 0x1c41a, 0x1cc3a, + 0x1dc7a, 0x1883a, 0x1987a, 0x1b8fa, 0x1107a, 0x130fa, 0x171fa, 0x170be, + 0x1e150, 0x1f0ac, 0x1e148, 0x1f0a6, 0x1e144, 0x1e142, 0x1c2d0, 0x1e16c, + 0x1c2c8, 0x1e166, 0x1c2c4, 0x1c2c2, 0x185d0, 0x1c2ec, 0x185c8, 0x1c2e6, + 0x185c4, 0x185c2, 0x10bd0, 0x185ec, 0x10bc8, 0x185e6, 0x10bc4, 0x10bc2, + 0x10bec, 0x10be6, 0x1f1a8, 0x1f8d6, 0x11afc, 0x1f1a4, 0x11a7e, 0x1f1a2, + 0x1e128, 0x1f096, 0x1e368, 0x1e124, 0x1e364, 0x1e122, 0x1e362, 0x1c268, + 0x1e136, 0x1c6e8, 0x1c264, 0x1c6e4, 0x1c262, 0x1c6e2, 0x184e8, 0x1c276, + 0x18de8, 0x184e4, 0x18de4, 0x184e2, 0x18de2, 0x109e8, 0x184f6, 0x11be8, + 0x109e4, 0x11be4, 0x109e2, 0x11be2, 0x109f6, 0x11bf6, 0x1f9d4, 0x13af8, + 0x19d7e, 0x1f9d2, 0x13a7c, 0x13a3e, 0x1f194, 0x1197e, 0x1f3b4, 0x1f192, + 0x13b7e, 0x1f3b2, 0x1e114, 0x1e334, 0x1e112, 0x1e774, 0x1e332, 0x1e772, + 0x1c234, 0x1c674, 0x1c232, 0x1cef4, 0x1c672, 0x1cef2, 0x18474, 0x18cf4, + 0x18472, 0x19df4, 0x18cf2, 0x19df2, 0x108f4, 0x119f4, 0x108f2, 0x13bf4, + 0x119f2, 0x13bf2, 0x17af0, 0x1bd7c, 0x17a78, 0x1bd3e, 0x17a3c, 0x17a1e, + 0x1f9ca, 0x1397c, 0x1fbda, 0x17b7c, 0x1393e, 0x17b3e, 0x1f18a, 0x1f39a, + 0x1f7ba, 0x1e10a, 0x1e31a, 0x1e73a, 0x1ef7a, 0x1c21a, 0x1c63a, 0x1ce7a, + 0x1defa, 0x1843a, 0x18c7a, 0x19cfa, 0x1bdfa, 0x1087a, 0x118fa, 0x139fa, + 0x17978, 0x1bcbe, 0x1793c, 0x1791e, 0x138be, 0x179be, 0x178bc, 0x1789e, + 0x1785e, 0x1e0a8, 0x1e0a4, 0x1e0a2, 0x1c168, 0x1e0b6, 0x1c164, 0x1c162, + 0x182e8, 0x1c176, 0x182e4, 0x182e2, 0x105e8, 0x182f6, 0x105e4, 0x105e2, + 0x105f6, 0x1f0d4, 0x10d7e, 0x1f0d2, 0x1e094, 0x1e1b4, 0x1e092, 0x1e1b2, + 0x1c134, 0x1c374, 0x1c132, 0x1c372, 0x18274, 0x186f4, 0x18272, 0x186f2, + 0x104f4, 0x10df4, 0x104f2, 0x10df2, 0x1f8ea, 0x11d7c, 0x11d3e, 0x1f0ca, + 0x1f1da, 0x1e08a, 0x1e19a, 0x1e3ba, 0x1c11a, 0x1c33a, 0x1c77a, 0x1823a, + 0x1867a, 0x18efa, 0x1047a, 0x10cfa, 0x11dfa, 0x13d78, 0x19ebe, 0x13d3c, + 0x13d1e, 0x11cbe, 0x13dbe, 0x17d70, 0x1bebc, 0x17d38, 0x1be9e, 0x17d1c, + 0x17d0e, 0x13cbc, 0x17dbc, 0x13c9e, 0x17d9e, 0x17cb8, 0x1be5e, 0x17c9c, + 0x17c8e, 0x13c5e, 0x17cde, 0x17c5c, 0x17c4e, 0x17c2e, 0x1c0b4, 0x1c0b2, + 0x18174, 0x18172, 0x102f4, 0x102f2, 0x1e0da, 0x1c09a, 0x1c1ba, 0x1813a, + 0x1837a, 0x1027a, 0x106fa, 0x10ebe, 0x11ebc, 0x11e9e, 0x13eb8, 0x19f5e, + 0x13e9c, 0x13e8e, 0x11e5e, 0x13ede, 0x17eb0, 0x1bf5c, 0x17e98, 0x1bf4e, + 0x17e8c, 0x17e86, 0x13e5c, 0x17edc, 0x13e4e, 0x17ece, 0x17e58, 0x1bf2e, + 0x17e4c, 0x17e46, 0x13e2e, 0x17e6e, 0x17e2c, 0x17e26, 0x10f5e, 0x11f5c, + 0x11f4e, 0x13f58, 0x19fae, 0x13f4c, 0x13f46, 0x11f2e, 0x13f6e, 0x13f2c, + 0x13f26}, + {0x1abe0, 0x1d5f8, 0x153c0, 0x1a9f0, 0x1d4fc, 0x151e0, 0x1a8f8, 0x1d47e, + 0x150f0, 0x1a87c, 0x15078, 0x1fad0, 0x15be0, 0x1adf8, 0x1fac8, 0x159f0, + 0x1acfc, 0x1fac4, 0x158f8, 0x1ac7e, 0x1fac2, 0x1587c, 0x1f5d0, 0x1faec, + 0x15df8, 0x1f5c8, 0x1fae6, 0x15cfc, 0x1f5c4, 0x15c7e, 0x1f5c2, 0x1ebd0, + 0x1f5ec, 0x1ebc8, 0x1f5e6, 0x1ebc4, 0x1ebc2, 0x1d7d0, 0x1ebec, 0x1d7c8, + 0x1ebe6, 0x1d7c4, 0x1d7c2, 0x1afd0, 0x1d7ec, 0x1afc8, 0x1d7e6, 0x1afc4, + 0x14bc0, 0x1a5f0, 0x1d2fc, 0x149e0, 0x1a4f8, 0x1d27e, 0x148f0, 0x1a47c, + 0x14878, 0x1a43e, 0x1483c, 0x1fa68, 0x14df0, 0x1a6fc, 0x1fa64, 0x14cf8, + 0x1a67e, 0x1fa62, 0x14c7c, 0x14c3e, 0x1f4e8, 0x1fa76, 0x14efc, 0x1f4e4, + 0x14e7e, 0x1f4e2, 0x1e9e8, 0x1f4f6, 0x1e9e4, 0x1e9e2, 0x1d3e8, 0x1e9f6, + 0x1d3e4, 0x1d3e2, 0x1a7e8, 0x1d3f6, 0x1a7e4, 0x1a7e2, 0x145e0, 0x1a2f8, + 0x1d17e, 0x144f0, 0x1a27c, 0x14478, 0x1a23e, 0x1443c, 0x1441e, 0x1fa34, + 0x146f8, 0x1a37e, 0x1fa32, 0x1467c, 0x1463e, 0x1f474, 0x1477e, 0x1f472, + 0x1e8f4, 0x1e8f2, 0x1d1f4, 0x1d1f2, 0x1a3f4, 0x1a3f2, 0x142f0, 0x1a17c, + 0x14278, 0x1a13e, 0x1423c, 0x1421e, 0x1fa1a, 0x1437c, 0x1433e, 0x1f43a, + 0x1e87a, 0x1d0fa, 0x14178, 0x1a0be, 0x1413c, 0x1411e, 0x141be, 0x140bc, + 0x1409e, 0x12bc0, 0x195f0, 0x1cafc, 0x129e0, 0x194f8, 0x1ca7e, 0x128f0, + 0x1947c, 0x12878, 0x1943e, 0x1283c, 0x1f968, 0x12df0, 0x196fc, 0x1f964, + 0x12cf8, 0x1967e, 0x1f962, 0x12c7c, 0x12c3e, 0x1f2e8, 0x1f976, 0x12efc, + 0x1f2e4, 0x12e7e, 0x1f2e2, 0x1e5e8, 0x1f2f6, 0x1e5e4, 0x1e5e2, 0x1cbe8, + 0x1e5f6, 0x1cbe4, 0x1cbe2, 0x197e8, 0x1cbf6, 0x197e4, 0x197e2, 0x1b5e0, + 0x1daf8, 0x1ed7e, 0x169c0, 0x1b4f0, 0x1da7c, 0x168e0, 0x1b478, 0x1da3e, + 0x16870, 0x1b43c, 0x16838, 0x1b41e, 0x1681c, 0x125e0, 0x192f8, 0x1c97e, + 0x16de0, 0x124f0, 0x1927c, 0x16cf0, 0x1b67c, 0x1923e, 0x16c78, 0x1243c, + 0x16c3c, 0x1241e, 0x16c1e, 0x1f934, 0x126f8, 0x1937e, 0x1fb74, 0x1f932, + 0x16ef8, 0x1267c, 0x1fb72, 0x16e7c, 0x1263e, 0x16e3e, 0x1f274, 0x1277e, + 0x1f6f4, 0x1f272, 0x16f7e, 0x1f6f2, 0x1e4f4, 0x1edf4, 0x1e4f2, 0x1edf2, + 0x1c9f4, 0x1dbf4, 0x1c9f2, 0x1dbf2, 0x193f4, 0x193f2, 0x165c0, 0x1b2f0, + 0x1d97c, 0x164e0, 0x1b278, 0x1d93e, 0x16470, 0x1b23c, 0x16438, 0x1b21e, + 0x1641c, 0x1640e, 0x122f0, 0x1917c, 0x166f0, 0x12278, 0x1913e, 0x16678, + 0x1b33e, 0x1663c, 0x1221e, 0x1661e, 0x1f91a, 0x1237c, 0x1fb3a, 0x1677c, + 0x1233e, 0x1673e, 0x1f23a, 0x1f67a, 0x1e47a, 0x1ecfa, 0x1c8fa, 0x1d9fa, + 0x191fa, 0x162e0, 0x1b178, 0x1d8be, 0x16270, 0x1b13c, 0x16238, 0x1b11e, + 0x1621c, 0x1620e, 0x12178, 0x190be, 0x16378, 0x1213c, 0x1633c, 0x1211e, + 0x1631e, 0x121be, 0x163be, 0x16170, 0x1b0bc, 0x16138, 0x1b09e, 0x1611c, + 0x1610e, 0x120bc, 0x161bc, 0x1209e, 0x1619e, 0x160b8, 0x1b05e, 0x1609c, + 0x1608e, 0x1205e, 0x160de, 0x1605c, 0x1604e, 0x115e0, 0x18af8, 0x1c57e, + 0x114f0, 0x18a7c, 0x11478, 0x18a3e, 0x1143c, 0x1141e, 0x1f8b4, 0x116f8, + 0x18b7e, 0x1f8b2, 0x1167c, 0x1163e, 0x1f174, 0x1177e, 0x1f172, 0x1e2f4, + 0x1e2f2, 0x1c5f4, 0x1c5f2, 0x18bf4, 0x18bf2, 0x135c0, 0x19af0, 0x1cd7c, + 0x134e0, 0x19a78, 0x1cd3e, 0x13470, 0x19a3c, 0x13438, 0x19a1e, 0x1341c, + 0x1340e, 0x112f0, 0x1897c, 0x136f0, 0x11278, 0x1893e, 0x13678, 0x19b3e, + 0x1363c, 0x1121e, 0x1361e, 0x1f89a, 0x1137c, 0x1f9ba, 0x1377c, 0x1133e, + 0x1373e, 0x1f13a, 0x1f37a, 0x1e27a, 0x1e6fa, 0x1c4fa, 0x1cdfa, 0x189fa, + 0x1bae0, 0x1dd78, 0x1eebe, 0x174c0, 0x1ba70, 0x1dd3c, 0x17460, 0x1ba38, + 0x1dd1e, 0x17430, 0x1ba1c, 0x17418, 0x1ba0e, 0x1740c, 0x132e0, 0x19978, + 0x1ccbe, 0x176e0, 0x13270, 0x1993c, 0x17670, 0x1bb3c, 0x1991e, 0x17638, + 0x1321c, 0x1761c, 0x1320e, 0x1760e, 0x11178, 0x188be, 0x13378, 0x1113c, + 0x17778, 0x1333c, 0x1111e, 0x1773c, 0x1331e, 0x1771e, 0x111be, 0x133be, + 0x177be, 0x172c0, 0x1b970, 0x1dcbc, 0x17260, 0x1b938, 0x1dc9e, 0x17230, + 0x1b91c, 0x17218, 0x1b90e, 0x1720c, 0x17206, 0x13170, 0x198bc, 0x17370, + 0x13138, 0x1989e, 0x17338, 0x1b99e, 0x1731c, 0x1310e, 0x1730e, 0x110bc, + 0x131bc, 0x1109e, 0x173bc, 0x1319e, 0x1739e, 0x17160, 0x1b8b8, 0x1dc5e, + 0x17130, 0x1b89c, 0x17118, 0x1b88e, 0x1710c, 0x17106, 0x130b8, 0x1985e, + 0x171b8, 0x1309c, 0x1719c, 0x1308e, 0x1718e, 0x1105e, 0x130de, 0x171de, + 0x170b0, 0x1b85c, 0x17098, 0x1b84e, 0x1708c, 0x17086, 0x1305c, 0x170dc, + 0x1304e, 0x170ce, 0x17058, 0x1b82e, 0x1704c, 0x17046, 0x1302e, 0x1706e, + 0x1702c, 0x17026, 0x10af0, 0x1857c, 0x10a78, 0x1853e, 0x10a3c, 0x10a1e, + 0x10b7c, 0x10b3e, 0x1f0ba, 0x1e17a, 0x1c2fa, 0x185fa, 0x11ae0, 0x18d78, + 0x1c6be, 0x11a70, 0x18d3c, 0x11a38, 0x18d1e, 0x11a1c, 0x11a0e, 0x10978, + 0x184be, 0x11b78, 0x1093c, 0x11b3c, 0x1091e, 0x11b1e, 0x109be, 0x11bbe, + 0x13ac0, 0x19d70, 0x1cebc, 0x13a60, 0x19d38, 0x1ce9e, 0x13a30, 0x19d1c, + 0x13a18, 0x19d0e, 0x13a0c, 0x13a06, 0x11970, 0x18cbc, 0x13b70, 0x11938, + 0x18c9e, 0x13b38, 0x1191c, 0x13b1c, 0x1190e, 0x13b0e, 0x108bc, 0x119bc, + 0x1089e, 0x13bbc, 0x1199e, 0x13b9e, 0x1bd60, 0x1deb8, 0x1ef5e, 0x17a40, + 0x1bd30, 0x1de9c, 0x17a20, 0x1bd18, 0x1de8e, 0x17a10, 0x1bd0c, 0x17a08, + 0x1bd06, 0x17a04, 0x13960, 0x19cb8, 0x1ce5e, 0x17b60, 0x13930, 0x19c9c, + 0x17b30, 0x1bd9c, 0x19c8e, 0x17b18, 0x1390c, 0x17b0c, 0x13906, 0x17b06, + 0x118b8, 0x18c5e, 0x139b8, 0x1189c, 0x17bb8, 0x1399c, 0x1188e, 0x17b9c, + 0x1398e, 0x17b8e, 0x1085e, 0x118de, 0x139de, 0x17bde, 0x17940, 0x1bcb0, + 0x1de5c, 0x17920, 0x1bc98, 0x1de4e, 0x17910, 0x1bc8c, 0x17908, 0x1bc86, + 0x17904, 0x17902, 0x138b0, 0x19c5c, 0x179b0, 0x13898, 0x19c4e, 0x17998, + 0x1bcce, 0x1798c, 0x13886, 0x17986, 0x1185c, 0x138dc, 0x1184e, 0x179dc, + 0x138ce, 0x179ce, 0x178a0, 0x1bc58, 0x1de2e, 0x17890, 0x1bc4c, 0x17888, + 0x1bc46, 0x17884, 0x17882, 0x13858, 0x19c2e, 0x178d8, 0x1384c, 0x178cc, + 0x13846, 0x178c6, 0x1182e, 0x1386e, 0x178ee, 0x17850, 0x1bc2c, 0x17848, + 0x1bc26, 0x17844, 0x17842, 0x1382c, 0x1786c, 0x13826, 0x17866, 0x17828, + 0x1bc16, 0x17824, 0x17822, 0x13816, 0x17836, 0x10578, 0x182be, 0x1053c, + 0x1051e, 0x105be, 0x10d70, 0x186bc, 0x10d38, 0x1869e, 0x10d1c, 0x10d0e, + 0x104bc, 0x10dbc, 0x1049e, 0x10d9e, 0x11d60, 0x18eb8, 0x1c75e, 0x11d30, + 0x18e9c, 0x11d18, 0x18e8e, 0x11d0c, 0x11d06, 0x10cb8, 0x1865e, 0x11db8, + 0x10c9c, 0x11d9c, 0x10c8e, 0x11d8e, 0x1045e, 0x10cde, 0x11dde, 0x13d40, + 0x19eb0, 0x1cf5c, 0x13d20, 0x19e98, 0x1cf4e, 0x13d10, 0x19e8c, 0x13d08, + 0x19e86, 0x13d04, 0x13d02, 0x11cb0, 0x18e5c, 0x13db0, 0x11c98, 0x18e4e, + 0x13d98, 0x19ece, 0x13d8c, 0x11c86, 0x13d86, 0x10c5c, 0x11cdc, 0x10c4e, + 0x13ddc, 0x11cce, 0x13dce, 0x1bea0, 0x1df58, 0x1efae, 0x1be90, 0x1df4c, + 0x1be88, 0x1df46, 0x1be84, 0x1be82, 0x13ca0, 0x19e58, 0x1cf2e, 0x17da0, + 0x13c90, 0x19e4c, 0x17d90, 0x1becc, 0x19e46, 0x17d88, 0x13c84, 0x17d84, + 0x13c82, 0x17d82, 0x11c58, 0x18e2e, 0x13cd8, 0x11c4c, 0x17dd8, 0x13ccc, + 0x11c46, 0x17dcc, 0x13cc6, 0x17dc6, 0x10c2e, 0x11c6e, 0x13cee, 0x17dee, + 0x1be50, 0x1df2c, 0x1be48, 0x1df26, 0x1be44, 0x1be42, 0x13c50, 0x19e2c, + 0x17cd0, 0x13c48, 0x19e26, 0x17cc8, 0x1be66, 0x17cc4, 0x13c42, 0x17cc2, + 0x11c2c, 0x13c6c, 0x11c26, 0x17cec, 0x13c66, 0x17ce6, 0x1be28, 0x1df16, + 0x1be24, 0x1be22, 0x13c28, 0x19e16, 0x17c68, 0x13c24, 0x17c64, 0x13c22, + 0x17c62, 0x11c16, 0x13c36, 0x17c76, 0x1be14, 0x1be12, 0x13c14, 0x17c34, + 0x13c12, 0x17c32, 0x102bc, 0x1029e, 0x106b8, 0x1835e, 0x1069c, 0x1068e, + 0x1025e, 0x106de, 0x10eb0, 0x1875c, 0x10e98, 0x1874e, 0x10e8c, 0x10e86, + 0x1065c, 0x10edc, 0x1064e, 0x10ece, 0x11ea0, 0x18f58, 0x1c7ae, 0x11e90, + 0x18f4c, 0x11e88, 0x18f46, 0x11e84, 0x11e82, 0x10e58, 0x1872e, 0x11ed8, + 0x18f6e, 0x11ecc, 0x10e46, 0x11ec6, 0x1062e, 0x10e6e, 0x11eee, 0x19f50, + 0x1cfac, 0x19f48, 0x1cfa6, 0x19f44, 0x19f42, 0x11e50, 0x18f2c, 0x13ed0, + 0x19f6c, 0x18f26, 0x13ec8, 0x11e44, 0x13ec4, 0x11e42, 0x13ec2, 0x10e2c, + 0x11e6c, 0x10e26, 0x13eec, 0x11e66, 0x13ee6, 0x1dfa8, 0x1efd6, 0x1dfa4, + 0x1dfa2, 0x19f28, 0x1cf96, 0x1bf68, 0x19f24, 0x1bf64, 0x19f22, 0x1bf62, + 0x11e28, 0x18f16, 0x13e68, 0x11e24, 0x17ee8, 0x13e64, 0x11e22, 0x17ee4, + 0x13e62, 0x17ee2, 0x10e16, 0x11e36, 0x13e76, 0x17ef6, 0x1df94, 0x1df92, + 0x19f14, 0x1bf34, 0x19f12, 0x1bf32, 0x11e14, 0x13e34, 0x11e12, 0x17e74, + 0x13e32, 0x17e72, 0x1df8a, 0x19f0a, 0x1bf1a, 0x11e0a, 0x13e1a, 0x17e3a, + 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, 0x1032e, 0x1076e, + 0x10f50, 0x187ac, 0x10f48, 0x187a6, 0x10f44, 0x10f42, 0x1072c, 0x10f6c, + 0x10726, 0x10f66, 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, + 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, 0x10f36, 0x11f76, + 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, 0x18f92, 0x19fb2, 0x10f14, 0x11f34, + 0x10f12, 0x13f74, 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, + 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, 0x107a4, 0x107a2, + 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2, + 0x1c7ea}}; +FX_FLOAT CBC_PDF417::PREFERRED_RATIO = 3.0f; +FX_FLOAT CBC_PDF417::DEFAULT_MODULE_WIDTH = 0.357f; +FX_FLOAT CBC_PDF417::HEIGHT = 2.0f; +CBC_PDF417::CBC_PDF417() { + m_compact = FALSE; + m_compaction = AUTO; + m_minCols = 1; + m_maxCols = 30; + m_maxRows = 90; + m_minRows = 3; + m_barcodeMatrix = NULL; +} +CBC_PDF417::CBC_PDF417(FX_BOOL compact) { + m_compact = compact; + m_compaction = AUTO; + m_minCols = 1; + m_maxCols = 30; + m_maxRows = 90; + m_minRows = 3; + m_barcodeMatrix = NULL; +} +CBC_PDF417::~CBC_PDF417() { + if (m_barcodeMatrix) { + delete m_barcodeMatrix; + } +} +CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { + return m_barcodeMatrix; +} +void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, + int32_t errorCorrectionLevel, + int32_t& e) { + int32_t errorCorrectionCodeWords = + CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( + errorCorrectionLevel, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CFX_WideString highLevel = + CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t sourceCodeWords = highLevel.GetLength(); + CFX_Int32Array* dimension = + determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t cols = dimension->GetAt(0); + int32_t rows = dimension->GetAt(1); + delete dimension; + int32_t pad = getNumberOfPadCodewords(sourceCodeWords, + errorCorrectionCodeWords, cols, rows); + if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { + e = BCExceptionEncodedMessageContainsTooManyCodeWords; + return; + } + int32_t n = sourceCodeWords + pad + 1; + CFX_WideString sb; + sb += (FX_WCHAR)n; + sb += highLevel; + for (int32_t i = 0; i < pad; i++) { + sb += (FX_WCHAR)900; + } + CFX_WideString dataCodewords(sb); + CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( + dataCodewords, errorCorrectionLevel, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CFX_WideString fullCodewords = dataCodewords + ec; + m_barcodeMatrix = new CBC_BarcodeMatrix(rows, cols); + encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, + m_barcodeMatrix); +} +void CBC_PDF417::setDimensions(int32_t maxCols, + int32_t minCols, + int32_t maxRows, + int32_t minRows) { + m_maxCols = maxCols; + m_minCols = minCols; + m_maxRows = maxRows; + m_minRows = minRows; +} +void CBC_PDF417::setCompaction(Compaction compaction) { + m_compaction = compaction; +} +void CBC_PDF417::setCompact(FX_BOOL compact) { + m_compact = compact; +} +int32_t CBC_PDF417::calculateNumberOfRows(int32_t m, int32_t k, int32_t c) { + int32_t r = ((m + 1 + k) / c) + 1; + if (c * r >= (m + 1 + k + c)) { + r--; + } + return r; +} +int32_t CBC_PDF417::getNumberOfPadCodewords(int32_t m, + int32_t k, + int32_t c, + int32_t r) { + int32_t n = c * r - k; + return n > m + 1 ? n - m - 1 : 0; +} +void CBC_PDF417::encodeChar(int32_t pattern, + int32_t len, + CBC_BarcodeRow* logic) { + int32_t map = 1 << (len - 1); + FX_BOOL last = ((pattern & map) != 0); + int32_t width = 0; + for (int32_t i = 0; i < len; i++) { + FX_BOOL black = ((pattern & map) != 0); + if (last == black) { + width++; + } else { + logic->addBar(last, width); + last = black; + width = 1; + } + map >>= 1; + } + logic->addBar(last, width); +} +void CBC_PDF417::encodeLowLevel(CFX_WideString fullCodewords, + int32_t c, + int32_t r, + int32_t errorCorrectionLevel, + CBC_BarcodeMatrix* logic) { + int32_t idx = 0; + for (int32_t y = 0; y < r; y++) { + int32_t cluster = y % 3; + logic->startRow(); + encodeChar(START_PATTERN, 17, logic->getCurrentRow()); + int32_t left; + int32_t right; + if (cluster == 0) { + left = (30 * (y / 3)) + ((r - 1) / 3); + right = (30 * (y / 3)) + (c - 1); + } else if (cluster == 1) { + left = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); + right = (30 * (y / 3)) + ((r - 1) / 3); + } else { + left = (30 * (y / 3)) + (c - 1); + right = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); + } + int32_t pattern = CODEWORD_TABLE[cluster][left]; + encodeChar(pattern, 17, logic->getCurrentRow()); + for (int32_t x = 0; x < c; x++) { + pattern = CODEWORD_TABLE[cluster][fullCodewords.GetAt(idx)]; + encodeChar(pattern, 17, logic->getCurrentRow()); + idx++; + } + if (m_compact) { + encodeChar(STOP_PATTERN, 1, logic->getCurrentRow()); + } else { + pattern = CODEWORD_TABLE[cluster][right]; + encodeChar(pattern, 17, logic->getCurrentRow()); + encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); + } + } +} +CFX_Int32Array* CBC_PDF417::determineDimensions( + int32_t sourceCodeWords, + int32_t errorCorrectionCodeWords, + int32_t& e) { + FX_FLOAT ratio = 0.0f; + CFX_Int32Array* dimension = NULL; + for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { + int32_t rows = + calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); + if (rows < m_minRows) { + break; + } + if (rows > m_maxRows) { + continue; + } + FX_FLOAT newRatio = + ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); + if (dimension && + fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { + continue; + } + ratio = newRatio; + if (dimension) { + delete dimension; + } + dimension = new CFX_Int32Array; + dimension->Add(cols); + dimension->Add(rows); + } + if (dimension == NULL) { + int32_t rows = calculateNumberOfRows(sourceCodeWords, + errorCorrectionCodeWords, m_minCols); + if (rows < m_minRows) { + dimension = new CFX_Int32Array; + dimension->Add(m_minCols); + dimension->Add(m_minRows); + } else if (rows >= 3 && rows <= 90) { + dimension = new CFX_Int32Array; + dimension->Add(m_minCols); + dimension->Add(rows); + } + } + if (dimension == NULL) { + e = BCExceptionUnableToFitMessageInColumns; + return NULL; + } + return dimension; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.h b/xfa/fxbarcode/pdf417/BC_PDF417.h new file mode 100644 index 0000000000..fe279db21b --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417.h @@ -0,0 +1,64 @@ +// 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_FXBARCODE_PDF417_BC_PDF417_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" + +class CBC_BarcodeRow; +class CBC_BarcodeMatrix; + +class CBC_PDF417 { + public: + CBC_PDF417(); + CBC_PDF417(FX_BOOL compact); + virtual ~CBC_PDF417(); + CBC_BarcodeMatrix* getBarcodeMatrix(); + void generateBarcodeLogic(CFX_WideString msg, + int32_t errorCorrectionLevel, + int32_t& e); + void setDimensions(int32_t maxCols, + int32_t minCols, + int32_t maxRows, + int32_t minRows); + void setCompaction(Compaction compaction); + void setCompact(FX_BOOL compact); + + private: + static int32_t START_PATTERN; + static int32_t STOP_PATTERN; + static int32_t CODEWORD_TABLE[][1000]; + static FX_FLOAT PREFERRED_RATIO; + static FX_FLOAT DEFAULT_MODULE_WIDTH; + static FX_FLOAT HEIGHT; + CBC_BarcodeMatrix* m_barcodeMatrix; + FX_BOOL m_compact; + Compaction m_compaction; + int32_t m_minCols; + int32_t m_maxCols; + int32_t m_maxRows; + int32_t m_minRows; + + private: + static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); + static int32_t getNumberOfPadCodewords(int32_t m, + int32_t k, + int32_t c, + int32_t r); + static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); + void encodeLowLevel(CFX_WideString fullCodewords, + int32_t c, + int32_t r, + int32_t errorCorrectionLevel, + CBC_BarcodeMatrix* logic); + CFX_Int32Array* determineDimensions(int32_t sourceCodeWords, + int32_t errorCorrectionCodeWords, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp new file mode 100644 index 0000000000..47255fac71 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp @@ -0,0 +1,90 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" + +CBC_BarcodeMatrix::CBC_BarcodeMatrix(int32_t height, int32_t width) { + m_matrix.SetSize(height + 2); + for (int32_t i = 0, matrixLength = m_matrix.GetSize(); i < matrixLength; + i++) { + m_matrix[i] = new CBC_BarcodeRow((width + 4) * 17 + 1); + } + m_width = width * 17; + m_height = height + 2; + m_currentRow = 0; + m_outHeight = 0; + 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(); + m_matrixOut.RemoveAll(); +} +void CBC_BarcodeMatrix::set(int32_t x, int32_t y, uint8_t value) { + ((CBC_BarcodeRow*)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)); +} +void CBC_BarcodeMatrix::startRow() { + ++m_currentRow; +} +CBC_BarcodeRow* CBC_BarcodeMatrix::getCurrentRow() { + return (CBC_BarcodeRow*)m_matrix[m_currentRow]; +} +int32_t CBC_BarcodeMatrix::getWidth() { + return m_outWidth; +} +int32_t CBC_BarcodeMatrix::getHeight() { + return m_outHeight; +} +CFX_ByteArray& CBC_BarcodeMatrix::getMatrix() { + return getScaledMatrix(1, 1); +} +CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t scale) { + return getScaledMatrix(scale, scale); +} +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)); + int32_t xMax = bytearray.GetSize(); + m_matrixOut.SetSize(xMax * yMax); + m_outWidth = xMax; + m_outHeight = yMax; + 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)); + } + k = i * xMax; + for (int32_t l = 0; l < xMax; l++) { + m_matrixOut[k + l] = bytearray.GetAt(l); + } + } + return m_matrixOut; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h new file mode 100644 index 0000000000..21ee44b65f --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h @@ -0,0 +1,38 @@ +// 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_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_BarcodeRow; +class CBC_BarcodeMatrix { + public: + CBC_BarcodeMatrix(); + CBC_BarcodeMatrix(int32_t height, int32_t width); + virtual ~CBC_BarcodeMatrix(); + void set(int32_t x, int32_t y, uint8_t value); + void setMatrix(int32_t x, int32_t y, FX_BOOL black); + void startRow(); + CBC_BarcodeRow* getCurrentRow(); + CFX_ByteArray& getMatrix(); + CFX_ByteArray& getScaledMatrix(int32_t scale); + CFX_ByteArray& getScaledMatrix(int32_t xScale, int32_t yScale); + int32_t getWidth(); + int32_t getHeight(); + + private: + CFX_PtrArray m_matrix; + CFX_ByteArray m_matrixOut; + int32_t m_currentRow; + int32_t m_height; + int32_t m_width; + int32_t m_outWidth; + int32_t m_outHeight; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp new file mode 100644 index 0000000000..ac59c6ef94 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp @@ -0,0 +1,50 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" + +CBC_BarcodeMetadata::CBC_BarcodeMetadata(int32_t columnCount, + int32_t rowCountUpperPart, + int32_t rowCountLowerPart, + int32_t errorCorrectionLevel) { + m_columnCount = columnCount; + m_rowCountUpperPart = rowCountUpperPart; + m_rowCountLowerPart = rowCountLowerPart; + m_errorCorrectionLevel = errorCorrectionLevel; + m_rowCount = m_rowCountUpperPart + m_rowCountLowerPart; +} +CBC_BarcodeMetadata::~CBC_BarcodeMetadata() {} +int32_t CBC_BarcodeMetadata::getColumnCount() { + return m_columnCount; +} +int32_t CBC_BarcodeMetadata::getErrorCorrectionLevel() { + return m_errorCorrectionLevel; +} +int32_t CBC_BarcodeMetadata::getRowCount() { + return m_rowCount; +} +int32_t CBC_BarcodeMetadata::getRowCountUpperPart() { + return m_rowCountUpperPart; +} +int32_t CBC_BarcodeMetadata::getRowCountLowerPart() { + return m_rowCountLowerPart; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h new file mode 100644 index 0000000000..2b398f13f6 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h @@ -0,0 +1,33 @@ +// 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_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ + +#include <stdint.h> + +class CBC_BarcodeMetadata { + public: + CBC_BarcodeMetadata(int32_t columnCount, + int32_t rowCountUpperPart, + int32_t rowCountLowerPart, + int32_t errorCorrectionLevel); + virtual ~CBC_BarcodeMetadata(); + int32_t getColumnCount(); + int32_t getErrorCorrectionLevel(); + int32_t getRowCount(); + int32_t getRowCountUpperPart(); + int32_t getRowCountLowerPart(); + + private: + int32_t m_columnCount; + int32_t m_errorCorrectionLevel; + int32_t m_rowCountUpperPart; + int32_t m_rowCountLowerPart; + int32_t m_rowCount; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp new file mode 100644 index 0000000000..6f88b33877 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp @@ -0,0 +1,53 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" + +CBC_BarcodeRow::CBC_BarcodeRow(int32_t width) { + m_row.SetSize(width); + m_currentLocation = 0; +} +CBC_BarcodeRow::~CBC_BarcodeRow() { + m_output.RemoveAll(); + m_row.RemoveAll(); +} +void CBC_BarcodeRow::set(int32_t x, uint8_t value) { + m_row.SetAt(x, value); +} +void CBC_BarcodeRow::set(int32_t x, FX_BOOL black) { + m_row.SetAt(x, (uint8_t)(black ? 1 : 0)); +} +void CBC_BarcodeRow::addBar(FX_BOOL black, int32_t width) { + for (int32_t ii = 0; ii < width; ii++) { + set(m_currentLocation++, black); + } +} +CFX_ByteArray& CBC_BarcodeRow::getRow() { + return m_row; +} +CFX_ByteArray& CBC_BarcodeRow::getScaledRow(int32_t scale) { + m_output.SetSize(m_row.GetSize() * scale); + for (int32_t i = 0; i < m_output.GetSize(); i++) { + m_output[i] = (m_row[i / scale]); + } + return m_output; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h new file mode 100644 index 0000000000..007876a93c --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_BarcodeRow { + public: + CBC_BarcodeRow(int32_t width); + virtual ~CBC_BarcodeRow(); + void set(int32_t x, uint8_t value); + void set(int32_t x, FX_BOOL black); + void addBar(FX_BOOL black, int32_t width); + CFX_ByteArray& getRow(); + CFX_ByteArray& getScaledRow(int32_t scale); + + private: + CFX_ByteArray m_row; + CFX_ByteArray m_output; + int32_t m_currentLocation; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp new file mode 100644 index 0000000000..eb89546b5c --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp @@ -0,0 +1,61 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" + +CBC_BarcodeValue::CBC_BarcodeValue() {} +CBC_BarcodeValue::~CBC_BarcodeValue() {} +void CBC_BarcodeValue::setValue(int32_t value) { + int32_t confidence = 0; + for (int32_t i = 0; i < m_keys.GetSize(); i++) { + if (m_keys.GetAt(i) == value) { + confidence = m_values.GetAt(i); + m_values.SetAt(i, confidence + 1); + return; + } + } + confidence = 1; + m_keys.Add(value); + m_values.Add(confidence); +} +CFX_Int32Array* CBC_BarcodeValue::getValue() { + int32_t maxConfidence = -1; + CFX_Int32Array* result = new CFX_Int32Array; + for (int32_t i = 0; i < m_keys.GetSize(); i++) { + if (m_values.GetAt(i) > maxConfidence) { + maxConfidence = m_values.GetAt(i); + result->RemoveAll(); + result->Add(m_keys.GetAt(i)); + } else if (m_values.GetAt(i) == maxConfidence) { + result->Add(m_keys.GetAt(i)); + } + } + return result; +} +int32_t CBC_BarcodeValue::getConfidence(int32_t value) { + for (int32_t i = 0; i < m_keys.GetSize(); i++) + if (m_keys.GetAt(i) == value) { + return m_values.GetAt(i); + } + return -1; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h new file mode 100644 index 0000000000..e99fb84cba --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h @@ -0,0 +1,25 @@ +// 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_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_BarcodeValue { + public: + CBC_BarcodeValue(); + virtual ~CBC_BarcodeValue(); + void setValue(int32_t value); + CFX_Int32Array* getValue(); + int32_t getConfidence(int32_t value); + + private: + CFX_Int32Array m_keys; + CFX_Int32Array m_values; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp new file mode 100644 index 0000000000..c8328ab1c6 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp @@ -0,0 +1,207 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/utils.h" + +CBC_BoundingBox::CBC_BoundingBox(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomRight, + int32_t& e) { + if ((topLeft == NULL && topRight == NULL) || + (bottomLeft == NULL && bottomRight == NULL) || + (topLeft && bottomLeft == NULL) || (topRight && bottomRight == NULL)) { + e = BCExceptionNotFoundInstance; + } + init(image, topLeft, bottomLeft, topRight, bottomRight); +} +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; + } +} +CBC_BoundingBox* CBC_BoundingBox::merge(CBC_BoundingBox* leftBox, + CBC_BoundingBox* rightBox, + int32_t& e) { + CBC_BoundingBox* boundingBox = NULL; + if (leftBox == NULL) { + boundingBox = new CBC_BoundingBox(rightBox); + return boundingBox; + } + if (rightBox == NULL) { + boundingBox = new CBC_BoundingBox(leftBox); + return boundingBox; + } + boundingBox = new CBC_BoundingBox(leftBox->m_image, leftBox->m_topLeft, + leftBox->m_bottomLeft, rightBox->m_topRight, + rightBox->m_bottomRight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return boundingBox; +} +CBC_BoundingBox* CBC_BoundingBox::addMissingRows(int32_t missingStartRows, + int32_t missingEndRows, + FX_BOOL isLeft, + int32_t& e) { + CBC_ResultPoint* newTopLeft = m_topLeft; + CBC_ResultPoint* newBottomLeft = m_bottomLeft; + CBC_ResultPoint* newTopRight = m_topRight; + CBC_ResultPoint* newBottomRight = m_bottomRight; + CBC_ResultPoint* newTop = NULL; + CBC_ResultPoint* newBottom = NULL; + if (missingStartRows > 0) { + CBC_ResultPoint* top = isLeft ? m_topLeft : m_topRight; + int32_t newMinY = (int32_t)top->GetY() - missingStartRows; + if (newMinY < 0) { + newMinY = 0; + } + newTop = new CBC_ResultPoint((FX_FLOAT)top->GetX(), (FX_FLOAT)newMinY); + if (isLeft) { + newTopLeft = newTop; + } else { + newTopRight = newTop; + } + } + if (missingEndRows > 0) { + CBC_ResultPoint* bottom = isLeft ? m_bottomLeft : m_bottomRight; + int32_t newMaxY = (int32_t)bottom->GetY() + missingEndRows; + if (newMaxY >= m_image->GetHeight()) { + newMaxY = m_image->GetHeight() - 1; + } + newBottom = + new CBC_ResultPoint((FX_FLOAT)bottom->GetX(), (FX_FLOAT)newMaxY); + if (isLeft) { + newBottomLeft = newBottom; + } else { + newBottomRight = newBottom; + } + } + calculateMinMaxValues(); + CBC_BoundingBox* boundingBox = new CBC_BoundingBox( + m_image, newTopLeft, newBottomLeft, newTopRight, newBottomRight, e); + delete newTop; + delete newBottom; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return boundingBox; +} +void CBC_BoundingBox::setTopRight(CBC_ResultPoint topRight) { + if (m_topRight) { + delete m_topRight; + } + m_topRight = new CBC_ResultPoint(topRight.GetX(), topRight.GetY()); + calculateMinMaxValues(); +} +void CBC_BoundingBox::setBottomRight(CBC_ResultPoint bottomRight) { + if (m_bottomRight) { + delete m_bottomRight; + } + m_bottomRight = new CBC_ResultPoint(bottomRight.GetX(), bottomRight.GetY()); + calculateMinMaxValues(); +} +int32_t CBC_BoundingBox::getMinX() { + return m_minX; +} +int32_t CBC_BoundingBox::getMaxX() { + return m_maxX; +} +int32_t CBC_BoundingBox::getMinY() { + return m_minY; +} +int32_t CBC_BoundingBox::getMaxY() { + return m_maxY; +} +CBC_ResultPoint* CBC_BoundingBox::getTopLeft() { + return m_topLeft; +} +CBC_ResultPoint* CBC_BoundingBox::getTopRight() { + return m_topRight; +} +CBC_ResultPoint* CBC_BoundingBox::getBottomLeft() { + return m_bottomLeft; +} +CBC_ResultPoint* CBC_BoundingBox::getBottomRight() { + return m_bottomRight; +} +void CBC_BoundingBox::init(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomRight) { + m_topLeft = NULL; + m_bottomLeft = NULL; + m_topRight = NULL; + m_bottomRight = NULL; + m_image = image; + if (topLeft) { + m_topLeft = new CBC_ResultPoint(topLeft->GetX(), topLeft->GetY()); + } + if (bottomLeft) { + m_bottomLeft = new CBC_ResultPoint(bottomLeft->GetX(), bottomLeft->GetY()); + } + if (topRight) { + m_topRight = new CBC_ResultPoint(topRight->GetX(), topRight->GetY()); + } + if (bottomRight) { + m_bottomRight = + new CBC_ResultPoint(bottomRight->GetX(), bottomRight->GetY()); + } + calculateMinMaxValues(); +} +void CBC_BoundingBox::calculateMinMaxValues() { + if (m_topLeft == NULL) { + m_topLeft = new CBC_ResultPoint(0, m_topRight->GetY()); + m_bottomLeft = new CBC_ResultPoint(0, m_bottomRight->GetY()); + } else if (m_topRight == NULL) { + m_topRight = new CBC_ResultPoint((FX_FLOAT)m_image->GetWidth() - 1, + (FX_FLOAT)m_topLeft->GetY()); + m_bottomRight = new CBC_ResultPoint((FX_FLOAT)m_image->GetWidth() - 1, + (FX_FLOAT)m_bottomLeft->GetY()); + } + m_minX = (int32_t)(m_topLeft->GetX() < m_bottomLeft->GetX() + ? m_topLeft->GetX() + : m_bottomLeft->GetX()); + m_maxX = (int32_t)(m_topRight->GetX() > m_bottomRight->GetX() + ? m_topRight->GetX() + : m_bottomRight->GetX()); + m_minY = + (int32_t)(m_topLeft->GetY() < m_topRight->GetY() ? m_topLeft->GetY() + : m_topRight->GetY()); + m_maxY = (int32_t)(m_bottomLeft->GetY() > m_bottomRight->GetY() + ? m_bottomLeft->GetY() + : m_bottomRight->GetY()); +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h new file mode 100644 index 0000000000..8b9563587d --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h @@ -0,0 +1,61 @@ +// 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_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ + +#include "core/include/fxcrt/fx_system.h" + +class CBC_CommonBitMatrix; +class CBC_ResultPoint; + +class CBC_BoundingBox { + public: + CBC_BoundingBox(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomRight, + int32_t& e); + CBC_BoundingBox(CBC_BoundingBox* boundingBox); + virtual ~CBC_BoundingBox(); + static CBC_BoundingBox* merge(CBC_BoundingBox* leftBox, + CBC_BoundingBox* rightBox, + int32_t& e); + CBC_BoundingBox* addMissingRows(int32_t missingStartRows, + int32_t missingEndRows, + FX_BOOL isLeft, + int32_t& e); + void setTopRight(CBC_ResultPoint topRight); + void setBottomRight(CBC_ResultPoint bottomRight); + int32_t getMinX(); + int32_t getMaxX(); + int32_t getMinY(); + int32_t getMaxY(); + CBC_ResultPoint* getTopLeft(); + CBC_ResultPoint* getTopRight(); + CBC_ResultPoint* getBottomLeft(); + CBC_ResultPoint* getBottomRight(); + + private: + CBC_CommonBitMatrix* m_image; + CBC_ResultPoint* m_topLeft; + CBC_ResultPoint* m_bottomLeft; + CBC_ResultPoint* m_topRight; + CBC_ResultPoint* m_bottomRight; + int32_t m_minX; + int32_t m_maxX; + int32_t m_minY; + int32_t m_maxY; + void init(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomRight); + void calculateMinMaxValues(); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Codeword.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Codeword.cpp new file mode 100644 index 0000000000..0280ea0953 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Codeword.cpp @@ -0,0 +1,70 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" + +int32_t CBC_Codeword::BARCODE_ROW_UNKNOWN = -1; +CBC_Codeword::CBC_Codeword(int32_t startX, + int32_t endX, + int32_t bucket, + int32_t cvalue) { + m_startX = startX; + m_endX = endX; + m_bucket = bucket; + m_value = cvalue; + m_rowNumber = BARCODE_ROW_UNKNOWN; +} +CBC_Codeword::~CBC_Codeword() {} +FX_BOOL CBC_Codeword::hasValidRowNumber() { + return isValidRowNumber(m_rowNumber); +} +FX_BOOL CBC_Codeword::isValidRowNumber(int32_t rowNumber) { + return m_rowNumber != BARCODE_ROW_UNKNOWN && + m_bucket == (m_rowNumber % 3) * 3; +} +void CBC_Codeword::setRowNumberAsRowIndicatorColumn() { + m_rowNumber = (m_value / 30) * 3 + m_bucket / 3; +} +int32_t CBC_Codeword::getWidth() { + return m_endX - m_startX; +} +int32_t CBC_Codeword::getStartX() { + return m_startX; +} +int32_t CBC_Codeword::getEndX() { + return m_endX; +} +int32_t CBC_Codeword::getBucket() { + return m_bucket; +} +int32_t CBC_Codeword::getValue() { + return m_value; +} +int32_t CBC_Codeword::getRowNumber() { + return m_rowNumber; +} +void CBC_Codeword::setRowNumber(int32_t rowNumber) { + m_rowNumber = rowNumber; +} +CFX_ByteString CBC_Codeword::toString() { + return m_rowNumber + (FX_CHAR)'|' + m_value; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Codeword.h b/xfa/fxbarcode/pdf417/BC_PDF417Codeword.h new file mode 100644 index 0000000000..e1ca60f229 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Codeword.h @@ -0,0 +1,37 @@ +// 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_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_Codeword { + public: + CBC_Codeword(int32_t startX, int32_t endX, int32_t bucket, int32_t value); + virtual ~CBC_Codeword(); + FX_BOOL hasValidRowNumber(); + FX_BOOL isValidRowNumber(int32_t rowNumber); + void setRowNumberAsRowIndicatorColumn(); + int32_t getWidth(); + int32_t getStartX(); + int32_t getEndX(); + int32_t getBucket(); + int32_t getValue(); + int32_t getRowNumber(); + void setRowNumber(int32_t rowNumber); + CFX_ByteString toString(); + + private: + static int32_t BARCODE_ROW_UNKNOWN; + int32_t m_startX; + int32_t m_endX; + int32_t m_bucket; + int32_t m_value; + int32_t m_rowNumber; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp new file mode 100644 index 0000000000..dfbbc70264 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp @@ -0,0 +1,117 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <limits> + +#include "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" + +#define SYMBOL_TABLE_Length 2787 + +FX_FLOAT CBC_PDF417CodewordDecoder::RATIOS_TABLE[2787][8] = {{0}}; + +CBC_PDF417CodewordDecoder::CBC_PDF417CodewordDecoder() {} +CBC_PDF417CodewordDecoder::~CBC_PDF417CodewordDecoder() {} +void CBC_PDF417CodewordDecoder::Initialize() { + for (int32_t i = 0; i < SYMBOL_TABLE_Length; i++) { + int32_t currentSymbol = CBC_PDF417Common::SYMBOL_TABLE[i]; + int32_t currentBit = currentSymbol & 0x1; + for (int32_t j = 0; j < CBC_PDF417Common::BARS_IN_MODULE; j++) { + FX_FLOAT size = 0.0f; + while ((currentSymbol & 0x1) == currentBit) { + size += 1.0f; + currentSymbol >>= 1; + } + currentBit = currentSymbol & 0x1; + RATIOS_TABLE[i][CBC_PDF417Common::BARS_IN_MODULE - j - 1] = + size / CBC_PDF417Common::MODULES_IN_CODEWORD; + } + } +} +void CBC_PDF417CodewordDecoder::Finalize() {} +int32_t CBC_PDF417CodewordDecoder::getDecodedValue( + CFX_Int32Array& moduleBitCount) { + CFX_Int32Array* array = sampleBitCounts(moduleBitCount); + int32_t decodedValue = getDecodedCodewordValue(*array); + delete array; + if (decodedValue != -1) { + return decodedValue; + } + return getClosestDecodedValue(moduleBitCount); +} +CFX_Int32Array* CBC_PDF417CodewordDecoder::sampleBitCounts( + CFX_Int32Array& moduleBitCount) { + FX_FLOAT bitCountSum = + (FX_FLOAT)CBC_PDF417Common::getBitCountSum(moduleBitCount); + CFX_Int32Array* bitCount = new CFX_Int32Array(); + bitCount->SetSize(CBC_PDF417Common::BARS_IN_MODULE); + int32_t bitCountIndex = 0; + int32_t sumPreviousBits = 0; + for (int32_t i = 0; i < CBC_PDF417Common::MODULES_IN_CODEWORD; i++) { + FX_FLOAT sampleIndex = + bitCountSum / (2 * CBC_PDF417Common::MODULES_IN_CODEWORD) + + (i * bitCountSum) / CBC_PDF417Common::MODULES_IN_CODEWORD; + if (sumPreviousBits + moduleBitCount.GetAt(bitCountIndex) <= sampleIndex) { + sumPreviousBits += moduleBitCount.GetAt(bitCountIndex); + bitCountIndex++; + } + bitCount->SetAt(bitCountIndex, bitCount->GetAt(bitCountIndex) + 1); + } + return bitCount; +} +int32_t CBC_PDF417CodewordDecoder::getDecodedCodewordValue( + CFX_Int32Array& moduleBitCount) { + int32_t decodedValue = getBitValue(moduleBitCount); + return CBC_PDF417Common::getCodeword(decodedValue) == -1 ? -1 : decodedValue; +} +int32_t CBC_PDF417CodewordDecoder::getBitValue(CFX_Int32Array& moduleBitCount) { + int64_t result = 0; + for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) { + for (int32_t bit = 0; bit < moduleBitCount.GetAt(i); bit++) { + result = (result << 1) | (i % 2 == 0 ? 1 : 0); + } + } + return (int32_t)result; +} +int32_t CBC_PDF417CodewordDecoder::getClosestDecodedValue( + CFX_Int32Array& moduleBitCount) { + int32_t bitCountSum = CBC_PDF417Common::getBitCountSum(moduleBitCount); + CFX_FloatArray bitCountRatios; + bitCountRatios.SetSize(CBC_PDF417Common::BARS_IN_MODULE); + for (int32_t i = 0; i < bitCountRatios.GetSize(); i++) { + bitCountRatios[i] = moduleBitCount.GetAt(i) / (FX_FLOAT)bitCountSum; + } + FX_FLOAT bestMatchError = std::numeric_limits<int32_t>::max(); + int32_t bestMatch = -1; + for (int32_t j = 0; j < SYMBOL_TABLE_Length; j++) { + FX_FLOAT error = 0.0f; + for (int32_t k = 0; k < CBC_PDF417Common::BARS_IN_MODULE; k++) { + FX_FLOAT diff = RATIOS_TABLE[j][k] - bitCountRatios[k]; + error += diff * diff; + } + if (error < bestMatchError) { + bestMatchError = error; + bestMatch = CBC_PDF417Common::SYMBOL_TABLE[j]; + } + } + return bestMatch; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h new file mode 100644 index 0000000000..920409df84 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_PDF417CodewordDecoder { + public: + CBC_PDF417CodewordDecoder(); + virtual ~CBC_PDF417CodewordDecoder(); + static void Initialize(); + static void Finalize(); + static int32_t getDecodedValue(CFX_Int32Array& moduleBitCount); + + private: + static FX_FLOAT RATIOS_TABLE[][8]; + static CFX_Int32Array* sampleBitCounts(CFX_Int32Array& moduleBitCount); + static int32_t getDecodedCodewordValue(CFX_Int32Array& moduleBitCount); + static int32_t getBitValue(CFX_Int32Array& moduleBitCount); + static int32_t getClosestDecodedValue(CFX_Int32Array& moduleBitCount); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp new file mode 100644 index 0000000000..fa4647db84 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp @@ -0,0 +1,651 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" + +int32_t CBC_PDF417Common::NUMBER_OF_CODEWORDS = 929; +int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE = NUMBER_OF_CODEWORDS - 1; +int32_t CBC_PDF417Common::MIN_ROWS_IN_BARCODE = 3; +int32_t CBC_PDF417Common::MAX_ROWS_IN_BARCODE = 90; +int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_ROW = 32; +int32_t CBC_PDF417Common::MODULES_IN_CODEWORD = 17; +int32_t CBC_PDF417Common::MODULES_IN_STOP_PATTERN = 18; +int32_t CBC_PDF417Common::BARS_IN_MODULE = 8; +CFX_Int32Array* CBC_PDF417Common::EMPTY_INT_ARRAY = NULL; +int32_t CBC_PDF417Common::SYMBOL_TABLE[] = { + 0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, + 0x1035c, 0x10396, 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, + 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, + 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, + 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c, 0x10540, 0x10578, + 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2, + 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, + 0x106b8, 0x106de, 0x106fa, 0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, + 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, + 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, + 0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc, 0x108c6, + 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e, + 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, + 0x109ce, 0x109dc, 0x109e2, 0x109e4, 0x109e8, 0x109f6, 0x10a08, 0x10a10, + 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, + 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, + 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e, + 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c, + 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, + 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70, 0x10d7e, 0x10d82, 0x10d84, + 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, + 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, + 0x10e6e, 0x10e86, 0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, + 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, + 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, + 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a, 0x11082, 0x11084, + 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee, + 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, + 0x11186, 0x11198, 0x111b0, 0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, + 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, + 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, + 0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410, 0x1141e, + 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618, + 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, + 0x11770, 0x1177e, 0x11782, 0x11784, 0x11788, 0x11790, 0x1179e, 0x117a0, + 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, + 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, + 0x118c2, 0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e, + 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e, + 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, + 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, + 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98, + 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, + 0x11c16, 0x11c26, 0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, + 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, + 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, + 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, + 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28, + 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, + 0x11e84, 0x11e88, 0x11e90, 0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, + 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, + 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, + 0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4, 0x12108, + 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0, + 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, + 0x12220, 0x12278, 0x122f0, 0x12306, 0x1230c, 0x12330, 0x1233e, 0x12360, + 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, + 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, + 0x12660, 0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782, + 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8, + 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, + 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, + 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08, + 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, + 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, + 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, + 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, + 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc, 0x131d8, 0x131f2, + 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308, + 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, + 0x133be, 0x133ce, 0x133dc, 0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, + 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, + 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, + 0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c, 0x137b8, + 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816, + 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, + 0x13898, 0x138b0, 0x138be, 0x138ce, 0x138dc, 0x138e2, 0x138e4, 0x138e8, + 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, + 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, + 0x13a0c, 0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, + 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e, + 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, + 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36, 0x13c42, 0x13c48, 0x13c50, + 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, + 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, + 0x13d10, 0x13d1e, 0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, + 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, + 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, + 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, + 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46, + 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, + 0x140bc, 0x14104, 0x14108, 0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, + 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, + 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, + 0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c, 0x1438e, + 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410, + 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, + 0x14618, 0x14630, 0x1463e, 0x14660, 0x1467c, 0x146c0, 0x146f8, 0x1471c, + 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, + 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, + 0x14840, 0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, + 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0, + 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, + 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0, 0x14fce, 0x14fdc, 0x15020, + 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0, + 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, + 0x15df8, 0x15e08, 0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, + 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, + 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, + 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184, 0x16188, 0x16190, + 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4, + 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, + 0x16308, 0x16310, 0x1631e, 0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, + 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, + 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, + 0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c, 0x16640, + 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e, + 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, + 0x167ec, 0x1681c, 0x16838, 0x16870, 0x168e0, 0x168fc, 0x169c0, 0x169f8, + 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, + 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, + 0x16f1c, 0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e, + 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046, + 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, + 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c, 0x17118, 0x17130, 0x1713e, + 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8, + 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, + 0x17230, 0x1723e, 0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, + 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, + 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, + 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0, 0x1760e, 0x1761c, + 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e, + 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, + 0x177e2, 0x177e4, 0x177e8, 0x17822, 0x17824, 0x17828, 0x17836, 0x17842, + 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, + 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, + 0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910, 0x1791e, + 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0, + 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, + 0x17a08, 0x17a10, 0x17a1e, 0x17a20, 0x17a3c, 0x17a40, 0x17a78, 0x17af0, + 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, + 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, + 0x17c2e, 0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68, + 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0, + 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, + 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, + 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, + 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, + 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, + 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, + 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, + 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a, 0x18446, 0x18458, + 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc, + 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, + 0x1853e, 0x18560, 0x1857c, 0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, + 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, + 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, + 0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6, 0x186cc, + 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796, + 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, + 0x1884c, 0x18858, 0x1886e, 0x18872, 0x18874, 0x18886, 0x18898, 0x188b0, + 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, + 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, + 0x189d0, 0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e, + 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e, + 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, + 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4, 0x18c22, 0x18c24, 0x18c28, + 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, + 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, + 0x18d04, 0x18d08, 0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, + 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, + 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, + 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa, 0x18f16, 0x18f26, + 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94, + 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, + 0x19058, 0x19072, 0x19074, 0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, + 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, + 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, + 0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260, 0x1927c, + 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390, + 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, + 0x193f4, 0x19430, 0x1943e, 0x19460, 0x1947c, 0x194c0, 0x194f8, 0x195f0, + 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, + 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, + 0x197b0, 0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822, + 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882, + 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, + 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c, 0x19940, 0x19978, 0x19986, + 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e, + 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, + 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, + 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, + 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, + 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90, 0x19da0, 0x19dcc, + 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58, + 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, + 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, + 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, + 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, + 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, + 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c, + 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, + 0x1a218, 0x1a230, 0x1a23e, 0x1a260, 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, + 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, + 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, + 0x1a418, 0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, + 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704, + 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, + 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, + 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, + 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, + 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, + 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, + 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, + 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, + 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c, + 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, + 0x1b204, 0x1b208, 0x1b210, 0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, + 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, + 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, + 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, + 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e, + 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, + 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, 0x1b938, 0x1b970, 0x1b97e, 0x1b982, + 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, + 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, + 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, + 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72, + 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, + 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, + 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, + 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, + 0x1be50, 0x1be5e, 0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, + 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, + 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, + 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, + 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268, + 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, + 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, + 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, + 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, + 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, + 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc, + 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, + 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, 0x1c658, 0x1c66e, 0x1c672, 0x1c674, + 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, + 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, + 0x1c744, 0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, + 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c, + 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, + 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, + 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, + 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, + 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, + 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, + 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, + 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, + 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18, + 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, + 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, + 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, + 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, + 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, + 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c, + 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, + 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, + 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, + 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, + 0x1d21c, 0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, + 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386, + 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, + 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, + 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, + 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, + 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, + 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, + 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, + 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, + 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c, + 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, + 0x1db82, 0x1db84, 0x1db88, 0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, + 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, + 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, + 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, + 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4, + 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, + 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, + 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, + 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, + 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, + 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142, + 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, + 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222, 0x1e224, 0x1e228, 0x1e236, + 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, + 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, + 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, + 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, + 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, + 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, + 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510, + 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, + 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, + 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, + 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, + 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, + 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6, + 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, + 0x1e848, 0x1e850, 0x1e85e, 0x1e866, 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, + 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, + 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, + 0x1e93c, 0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, + 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08, + 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, + 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, + 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, + 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, + 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, + 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, + 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, + 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, + 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2, + 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, + 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, + 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, + 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, + 0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, + 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246, + 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, + 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, + 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, + 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, + 0x1f426, 0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, + 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc, + 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, + 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, + 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, + 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, + 0x1f650, 0x1f65e, 0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, + 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, + 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, + 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, + 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934, + 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, + 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, + 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, + 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, + 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, + 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4, + 0x1fba8, 0x1fbb6, 0x1fbda}; +int32_t CBC_PDF417Common::CODEWORD_TABLE[] = { + 2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, + 902, 896, 908, 868, 865, 861, 859, 2511, 873, 871, 1780, 835, + 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, + 807, 2482, 806, 2480, 815, 814, 813, 812, 2484, 817, 816, 1745, + 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752, + 2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, + 787, 781, 747, 739, 736, 2413, 754, 752, 1719, 692, 689, 681, + 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, + 631, 2341, 627, 2338, 651, 646, 643, 2345, 654, 652, 1652, 1650, + 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, + 608, 606, 2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, + 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909, 2509, 2507, + 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, + 2485, 1748, 836, 834, 832, 830, 2494, 827, 2492, 843, 841, 839, + 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, + 2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, + 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, 569, 566, + 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, + 1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492, 485, 482, 2249, + 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, + 419, 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, + 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 377, + 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, + 1416, 1414, 385, 1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441, + 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, + 756, 753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, + 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332, + 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, + 645, 2346, 655, 653, 1653, 1651, 1649, 1655, 2612, 2597, 2595, 2571, + 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, + 910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, + 866, 863, 2513, 876, 874, 1782, 2720, 2713, 2711, 2697, 2694, 2691, + 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, + 2639, 1822, 2654, 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, + 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, + 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, + 2132, 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 2096, 2093, 274, + 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, + 1318, 2052, 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, + 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, + 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, + 2006, 159, 2003, 2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184, + 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, + 2313, 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, + 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, + 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, + 2247, 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 1536, + 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, + 414, 412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, + 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, + 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, + 2440, 792, 789, 785, 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, + 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, + 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, + 683, 2372, 701, 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, + 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, + 1795, 2573, 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, + 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, + 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, + 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, + 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, 131, + 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, + 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, + 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, + 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, + 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, + 100, 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, + 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64, 1931, 61, + 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, + 1043, 1050, 1049, 12, 10, 1869, 1867, 1864, 1861, 21, 1880, 19, + 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, + 974, 32, 30, 991, 989, 987, 984, 34, 995, 994, 992, 2151, + 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, + 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, + 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, 2131, 302, + 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, + 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, 1271, 259, + 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, + 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, + 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, 2049, 2046, + 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, + 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, + 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, 2288, + 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, + 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, 1544, + 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, + 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, + 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, 2248, + 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, + 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, 2453, 2452, + 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, + 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, + 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, 1697, 2381, + 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, + 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, + 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592, 2590, 2587, + 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, + 2554, 1796, 2574, 2572, 2569, 2578, 1847, 1846, 2722, 1843, 1842, 1840, + 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695, + 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, + 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818, 2726, 2776, 782, 740, + 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, + 1645, 1643, 1640, 1648, 602, 600, 597, 595, 2320, 593, 2318, 609, + 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, + 892, 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, + 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632, 2630, 2746, + 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, + 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, 1518, 1529, 411, + 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, + 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, + 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, 1421, 2175, + 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, + 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, + 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, + 925, 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, + 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, 2757, + 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, + 300, 296, 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, + 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, + 203, 2048, 195, 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, + 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, 150, + 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, + 1170, 1167, 170, 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, + 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, + 518, 512, 2268, 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, + 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395, 2185, + 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, + 1456, 1470, 2455, 799, 2433, 2430, 779, 776, 773, 2397, 2394, 2390, + 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, + 673, 670, 667, 688, 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, + 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718, 2709, + 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, + 2760, 2758, 142, 141, 1139, 1138, 134, 132, 129, 126, 1982, 1129, + 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, + 115, 1109, 1108, 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, + 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98, + 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, + 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, 1031, 1030, + 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, + 1046, 1044, 1944, 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, + 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, + 26, 23, 983, 981, 978, 975, 33, 971, 31, 990, 988, 985, + 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, + 323, 2135, 339, 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, + 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090, + 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, + 1300, 1314, 189, 2038, 186, 2036, 183, 2033, 2030, 2026, 206, 198, + 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, + 2300, 2286, 2284, 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, + 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569, 1567, + 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, + 474, 491, 1527, 1525, 1522, 2475, 2467, 2465, 2451, 2449, 2446, 801, + 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, + 2382, 2379, 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, + 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579, 1800, 2591, 2550, + 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, + 1833, 1831, 2690, 2688, 2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, + 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636, 1633, + 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, + 1775, 822, 820, 1757, 1755, 1584, 524, 1560, 1558, 468, 464, 1514, + 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, + 2208, 364, 361, 358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, + 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672, 669, + 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, + 1637, 1635, 920, 918, 884, 880, 889, 849, 848, 847, 846, 2497, + 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, + 1340, 1338, 1335, 1343, 255, 251, 247, 1296, 1291, 1288, 265, 1302, + 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210, + 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, + 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, 1171, 1168, 1165, 168, + 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, + 1562, 1559, 458, 447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, + 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460, 2209, + 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, + 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, 2516, 885, 883, + 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, + 1125, 1124, 1122, 1127, 109, 106, 102, 1103, 1102, 1100, 1098, 116, + 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, + 1060, 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, + 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, + 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, + 4, 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 14, 969, + 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, + 1896, 986, 1905, 1903, 350, 349, 1381, 329, 327, 324, 1368, 1366, + 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, + 237, 2086, 233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, + 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231, 1229, 1226, + 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, + 1586, 507, 506, 504, 502, 2257, 499, 2254, 515, 1563, 1561, 445, + 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, + 1512, 2447, 798, 797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, + 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546, 2543, + 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, + 1732, 1731, 1735, 1814, 1707, 1670, 1668, 1631, 1629, 1626, 1634, 1599, + 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, + 1504, 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, + 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394, 1404, 2171, 2170, 1708, + 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, + 1336, 1286, 1281, 1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, + 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150, 1148, 1146, + 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, + 2017, 2016, 2014, 2019, 1582, 510, 1556, 1553, 452, 448, 1506, 1500, + 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, + 1709, 662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, + 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094, 1092, 103, 1101, + 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, + 1071, 1964, 1963, 1007, 1006, 1004, 1002, 999, 41, 996, 37, 1017, + 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940, + 938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, + 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897, 1379, 325, + 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, + 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, 1219, 1217, 1215, + 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, + 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, + 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, 2377, + 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, + 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, 2169, 2167, + 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, + 1207, 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, + 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, 1433, 1431, 1428, 1425, + 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, + 1055, 1052, 1062, 1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, + 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951, + 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, + 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, 1284, 2110, + 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, + 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, + 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, 2058, 2054, + 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, + 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, 1918, 1928, 937, + 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270, + 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, + 1478, 1491, 1700}; + +CBC_PDF417Common::CBC_PDF417Common() {} +CBC_PDF417Common::~CBC_PDF417Common() {} +int32_t CBC_PDF417Common::getBitCountSum(CFX_Int32Array& moduleBitCount) { + int32_t bitCountSum = 0; + for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) { + int32_t count = moduleBitCount.GetAt(i); + bitCountSum += count; + } + return bitCountSum; +} +int32_t CBC_PDF417Common::getCodeword(FX_DWORD symbol) { + FX_DWORD sym = symbol & 0x3FFFF; + int32_t i = findCodewordIndex(sym); + if (i == -1) { + return -1; + } + return (CODEWORD_TABLE[i] - 1) % NUMBER_OF_CODEWORDS; +} +int32_t CBC_PDF417Common::findCodewordIndex(FX_DWORD symbol) { + int32_t first = 0; + int32_t upto = sizeof(SYMBOL_TABLE) / sizeof(SYMBOL_TABLE[0]); + while (first < upto) { + int32_t mid = ((FX_DWORD)(first + upto)) >> 1; + if (symbol < (FX_DWORD)SYMBOL_TABLE[mid]) { + upto = mid; + } else if (symbol > (FX_DWORD)SYMBOL_TABLE[mid]) { + first = mid + 1; + } else { + return mid; + } + } + return -1; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Common.h b/xfa/fxbarcode/pdf417/BC_PDF417Common.h new file mode 100644 index 0000000000..61e93ab759 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Common.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_PDF417_BC_PDF417COMMON_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417COMMON_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_PDF417Common { + public: + CBC_PDF417Common(); + virtual ~CBC_PDF417Common(); + static int32_t getBitCountSum(CFX_Int32Array& moduleBitCount); + static int32_t getCodeword(FX_DWORD symbol); + static int32_t NUMBER_OF_CODEWORDS; + static int32_t MAX_CODEWORDS_IN_BARCODE; + static int32_t MIN_ROWS_IN_BARCODE; + static int32_t MAX_ROWS_IN_BARCODE; + static int32_t MAX_CODEWORDS_IN_ROW; + static int32_t MODULES_IN_CODEWORD; + static int32_t MODULES_IN_STOP_PATTERN; + static int32_t BARS_IN_MODULE; + static int32_t SYMBOL_TABLE[]; + static int32_t CODEWORD_TABLE[]; + + private: + static CFX_Int32Array* EMPTY_INT_ARRAY; + static int32_t findCodewordIndex(FX_DWORD symbol); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417COMMON_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Compaction.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Compaction.cpp new file mode 100644 index 0000000000..d3a1663eb6 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Compaction.cpp @@ -0,0 +1,26 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2011 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" + +CBC_Compaction::CBC_Compaction() {} +CBC_Compaction::~CBC_Compaction() {} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Compaction.h b/xfa/fxbarcode/pdf417/BC_PDF417Compaction.h new file mode 100644 index 0000000000..2df0fce303 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Compaction.h @@ -0,0 +1,18 @@ +// 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_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ + +class CBC_Compaction; +enum Compaction { AUTO, TEXT, BYTES, NUMERIC }; +class CBC_Compaction { + public: + CBC_Compaction(); + virtual ~CBC_Compaction(); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp new file mode 100644 index 0000000000..d52648c683 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp @@ -0,0 +1,493 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" + +#include <stdlib.h> + +#include "third_party/bigint/BigIntegerLibrary.hh" +#include "xfa/fxbarcode/BC_DecoderResult.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" +#include "xfa/fxbarcode/utils.h" + +#define TEXT_COMPACTION_MODE_LATCH 900 +#define BYTE_COMPACTION_MODE_LATCH 901 +#define NUMERIC_COMPACTION_MODE_LATCH 902 +#define BYTE_COMPACTION_MODE_LATCH_6 924 +#define BEGIN_MACRO_PDF417_CONTROL_BLOCK 928 +#define BEGIN_MACRO_PDF417_OPTIONAL_FIELD 923 +#define MACRO_PDF417_TERMINATOR 922 +#define MODE_SHIFT_TO_BYTE_COMPACTION_MODE 913 + +int32_t CBC_DecodedBitStreamPaser::MAX_NUMERIC_CODEWORDS = 15; +int32_t CBC_DecodedBitStreamPaser::NUMBER_OF_SEQUENCE_CODEWORDS = 2; +int32_t CBC_DecodedBitStreamPaser::PL = 25; +int32_t CBC_DecodedBitStreamPaser::LL = 27; +int32_t CBC_DecodedBitStreamPaser::AS = 27; +int32_t CBC_DecodedBitStreamPaser::ML = 28; +int32_t CBC_DecodedBitStreamPaser::AL = 28; +int32_t CBC_DecodedBitStreamPaser::PS = 29; +int32_t CBC_DecodedBitStreamPaser::PAL = 29; +FX_CHAR CBC_DecodedBitStreamPaser::PUNCT_CHARS[29] = { + ';', '<', '>', '@', '[', '\\', '}', '_', '`', '~', + '!', '\r', '\t', ',', ':', '\n', '-', '.', '$', '/', + '"', '|', '*', '(', ')', '?', '{', '}', '\''}; +FX_CHAR CBC_DecodedBitStreamPaser::MIXED_CHARS[30] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '&', '\r', '\t', + ',', ':', '#', '-', '.', '$', '/', '+', '%', '*', '=', '^'}; + +void CBC_DecodedBitStreamPaser::Initialize() {} +void CBC_DecodedBitStreamPaser::Finalize() {} +CBC_DecodedBitStreamPaser::CBC_DecodedBitStreamPaser() {} +CBC_DecodedBitStreamPaser::~CBC_DecodedBitStreamPaser() {} +CBC_CommonDecoderResult* CBC_DecodedBitStreamPaser::decode( + CFX_Int32Array& codewords, + CFX_ByteString ecLevel, + int32_t& e) { + CFX_ByteString result; + int32_t codeIndex = 1; + int32_t code = codewords.GetAt(codeIndex); + codeIndex++; + CBC_PDF417ResultMetadata* resultMetadata = new CBC_PDF417ResultMetadata; + while (codeIndex < codewords[0]) { + switch (code) { + case TEXT_COMPACTION_MODE_LATCH: + codeIndex = textCompaction(codewords, codeIndex, result); + break; + case BYTE_COMPACTION_MODE_LATCH: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + case NUMERIC_COMPACTION_MODE_LATCH: + codeIndex = numericCompaction(codewords, codeIndex, result, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + break; + case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + case BYTE_COMPACTION_MODE_LATCH_6: + codeIndex = byteCompaction(code, codewords, codeIndex, result); + break; + case BEGIN_MACRO_PDF417_CONTROL_BLOCK: + codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata, e); + if (e != BCExceptionNO) { + delete resultMetadata; + return NULL; + } + break; + default: + codeIndex--; + codeIndex = textCompaction(codewords, codeIndex, result); + break; + } + if (codeIndex < codewords.GetSize()) { + code = codewords[codeIndex++]; + } else { + e = BCExceptionFormatInstance; + delete resultMetadata; + return NULL; + } + } + if (result.GetLength() == 0) { + e = BCExceptionFormatInstance; + delete resultMetadata; + return NULL; + } + CFX_ByteArray rawBytes; + CFX_PtrArray byteSegments; + CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); + tempCd->Init(rawBytes, result, byteSegments, ecLevel, e); + if (e != BCExceptionNO) { + delete resultMetadata; + return NULL; + } + tempCd->setOther(resultMetadata); + return tempCd; +} +int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock( + CFX_Int32Array& codewords, + int32_t codeIndex, + CBC_PDF417ResultMetadata* resultMetadata, + int32_t& e) { + if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { + e = BCExceptionFormatInstance; + return -1; + } + CFX_Int32Array segmentIndexArray; + segmentIndexArray.SetSize(NUMBER_OF_SEQUENCE_CODEWORDS); + for (int32_t i = 0; i < NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) { + segmentIndexArray.SetAt(i, codewords[codeIndex]); + } + CFX_ByteString str = + decodeBase900toBase10(segmentIndexArray, NUMBER_OF_SEQUENCE_CODEWORDS, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + resultMetadata->setSegmentIndex(atoi(str.GetBuffer(str.GetLength()))); + CFX_ByteString fileId; + codeIndex = textCompaction(codewords, codeIndex, fileId); + resultMetadata->setFileId(fileId); + if (codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { + codeIndex++; + CFX_Int32Array additionalOptionCodeWords; + additionalOptionCodeWords.SetSize(codewords[0] - codeIndex); + int32_t additionalOptionCodeWordsIndex = 0; + FX_BOOL end = FALSE; + while ((codeIndex < codewords[0]) && !end) { + int32_t code = codewords[codeIndex++]; + if (code < TEXT_COMPACTION_MODE_LATCH) { + additionalOptionCodeWords[additionalOptionCodeWordsIndex++] = code; + } else { + switch (code) { + case MACRO_PDF417_TERMINATOR: + resultMetadata->setLastSegment(TRUE); + codeIndex++; + end = TRUE; + break; + default: + e = BCExceptionFormatInstance; + return -1; + } + } + } + CFX_Int32Array array; + array.SetSize(additionalOptionCodeWordsIndex); + array.Copy(additionalOptionCodeWords); + resultMetadata->setOptionalData(array); + } else if (codewords[codeIndex] == MACRO_PDF417_TERMINATOR) { + resultMetadata->setLastSegment(TRUE); + codeIndex++; + } + return codeIndex; +} +int32_t CBC_DecodedBitStreamPaser::textCompaction(CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result) { + CFX_Int32Array textCompactionData; + textCompactionData.SetSize((codewords[0] - codeIndex) << 1); + CFX_Int32Array byteCompactionData; + byteCompactionData.SetSize((codewords[0] - codeIndex) << 1); + int32_t index = 0; + FX_BOOL end = FALSE; + while ((codeIndex < codewords[0]) && !end) { + int32_t code = codewords[codeIndex++]; + if (code < TEXT_COMPACTION_MODE_LATCH) { + textCompactionData[index] = code / 30; + textCompactionData[index + 1] = code % 30; + index += 2; + } else { + switch (code) { + case TEXT_COMPACTION_MODE_LATCH: + textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; + break; + case BYTE_COMPACTION_MODE_LATCH: + codeIndex--; + end = TRUE; + break; + case NUMERIC_COMPACTION_MODE_LATCH: + codeIndex--; + end = TRUE; + break; + case BEGIN_MACRO_PDF417_CONTROL_BLOCK: + codeIndex--; + end = TRUE; + break; + case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + codeIndex--; + end = TRUE; + break; + case MACRO_PDF417_TERMINATOR: + codeIndex--; + end = TRUE; + break; + case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; + code = codewords[codeIndex++]; + byteCompactionData[index] = code; + index++; + break; + case BYTE_COMPACTION_MODE_LATCH_6: + codeIndex--; + end = TRUE; + break; + } + } + } + decodeTextCompaction(textCompactionData, byteCompactionData, index, result); + return codeIndex; +} +void CBC_DecodedBitStreamPaser::decodeTextCompaction( + CFX_Int32Array& textCompactionData, + CFX_Int32Array& byteCompactionData, + int32_t length, + CFX_ByteString& result) { + Mode subMode = ALPHA; + Mode priorToShiftMode = ALPHA; + int32_t i = 0; + while (i < length) { + int32_t subModeCh = textCompactionData[i]; + FX_CHAR ch = 0; + switch (subMode) { + case ALPHA: + if (subModeCh < 26) { + ch = (FX_CHAR)('A' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == LL) { + subMode = LOWER; + } else if (subModeCh == ML) { + subMode = MIXED; + } else if (subModeCh == PS) { + priorToShiftMode = subMode; + subMode = PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result += (FX_CHAR)byteCompactionData[i]; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + case LOWER: + if (subModeCh < 26) { + ch = (FX_CHAR)('a' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == AS) { + priorToShiftMode = subMode; + subMode = ALPHA_SHIFT; + } else if (subModeCh == ML) { + subMode = MIXED; + } else if (subModeCh == PS) { + priorToShiftMode = subMode; + subMode = PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result += (FX_CHAR)byteCompactionData[i]; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + case MIXED: + if (subModeCh < PL) { + ch = MIXED_CHARS[subModeCh]; + } else { + if (subModeCh == PL) { + subMode = PUNCT; + } else if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == LL) { + subMode = LOWER; + } else if (subModeCh == AL) { + subMode = ALPHA; + } else if (subModeCh == PS) { + priorToShiftMode = subMode; + subMode = PUNCT_SHIFT; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result += (FX_CHAR)byteCompactionData[i]; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + case PUNCT: + if (subModeCh < PAL) { + ch = PUNCT_CHARS[subModeCh]; + } else { + if (subModeCh == PAL) { + subMode = ALPHA; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result += (FX_CHAR)byteCompactionData[i]; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + case ALPHA_SHIFT: + subMode = priorToShiftMode; + if (subModeCh < 26) { + ch = (FX_CHAR)('A' + subModeCh); + } else { + if (subModeCh == 26) { + ch = ' '; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + case PUNCT_SHIFT: + subMode = priorToShiftMode; + if (subModeCh < PAL) { + ch = PUNCT_CHARS[subModeCh]; + } else { + if (subModeCh == PAL) { + subMode = ALPHA; + } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { + result += (FX_CHAR)byteCompactionData[i]; + } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { + subMode = ALPHA; + } + } + break; + } + if (ch != 0) { + result += ch; + } + i++; + } +} +int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode, + CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result) { + if (mode == BYTE_COMPACTION_MODE_LATCH) { + int32_t count = 0; + int64_t value = 0; + FX_WORD* decodedData = FX_Alloc(FX_WORD, 6); + CFX_Int32Array byteCompactedCodewords; + byteCompactedCodewords.SetSize(6); + FX_BOOL end = FALSE; + int32_t nextCode = codewords[codeIndex++]; + while ((codeIndex < codewords[0]) && !end) { + byteCompactedCodewords[count++] = nextCode; + value = 900 * value + nextCode; + nextCode = codewords[codeIndex++]; + if (nextCode == TEXT_COMPACTION_MODE_LATCH || + nextCode == BYTE_COMPACTION_MODE_LATCH || + nextCode == NUMERIC_COMPACTION_MODE_LATCH || + nextCode == BYTE_COMPACTION_MODE_LATCH_6 || + nextCode == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + nextCode == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + nextCode == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = TRUE; + } else { + if ((count % 5 == 0) && (count > 0)) { + int32_t j = 0; + for (; j < 6; ++j) { + decodedData[5 - j] = (FX_WORD)(value % 256); + value >>= 8; + } + for (j = 0; j < 6; ++j) { + result += (FX_CHAR)decodedData[j]; + } + count = 0; + } + } + } + FX_Free(decodedData); + if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) { + byteCompactedCodewords[count++] = nextCode; + } + for (int32_t i = 0; i < count; i++) { + result += (FX_CHAR)(FX_WORD)byteCompactedCodewords[i]; + } + } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { + int32_t count = 0; + int64_t value = 0; + FX_BOOL end = FALSE; + while (codeIndex < codewords[0] && !end) { + int32_t code = codewords[codeIndex++]; + if (code < TEXT_COMPACTION_MODE_LATCH) { + count++; + value = 900 * value + code; + } else { + if (code == TEXT_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH || + code == NUMERIC_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH_6 || + code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + code == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = TRUE; + } + } + if ((count % 5 == 0) && (count > 0)) { + FX_WORD* decodedData = FX_Alloc(FX_WORD, 6); + int32_t j = 0; + for (; j < 6; ++j) { + decodedData[5 - j] = (FX_WORD)(value & 0xFF); + value >>= 8; + } + for (j = 0; j < 6; ++j) { + result += (FX_CHAR)decodedData[j]; + } + count = 0; + FX_Free(decodedData); + } + } + } + return codeIndex; +} +int32_t CBC_DecodedBitStreamPaser::numericCompaction(CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result, + int32_t& e) { + int32_t count = 0; + FX_BOOL end = FALSE; + CFX_Int32Array numericCodewords; + numericCodewords.SetSize(MAX_NUMERIC_CODEWORDS); + while (codeIndex < codewords[0] && !end) { + int32_t code = codewords[codeIndex++]; + if (codeIndex == codewords[0]) { + end = TRUE; + } + if (code < TEXT_COMPACTION_MODE_LATCH) { + numericCodewords[count] = code; + count++; + } else { + if (code == TEXT_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH || + code == BYTE_COMPACTION_MODE_LATCH_6 || + code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || + code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || + code == MACRO_PDF417_TERMINATOR) { + codeIndex--; + end = TRUE; + } + } + if (count % MAX_NUMERIC_CODEWORDS == 0 || + code == NUMERIC_COMPACTION_MODE_LATCH || end) { + CFX_ByteString s = decodeBase900toBase10(numericCodewords, count, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + result += s; + count = 0; + } + } + return codeIndex; +} +CFX_ByteString CBC_DecodedBitStreamPaser::decodeBase900toBase10( + CFX_Int32Array& codewords, + int32_t count, + int32_t& e) { + BigInteger result = 0; + BigInteger nineHundred(900); + for (int32_t i = 0; i < count; i++) { + result = result * nineHundred + BigInteger(codewords[i]); + } + CFX_ByteString resultString(bigIntegerToString(result).c_str()); + if (resultString.GetAt(0) != '1') { + e = BCExceptionFormatInstance; + return ' '; + } + return resultString.Mid(1, resultString.GetLength() - 1); +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h new file mode 100644 index 0000000000..747a4ceb5d --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h @@ -0,0 +1,63 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" + +class CBC_CommonDecoderResult; +class CBC_PDF417ResultMetadata; + +class CBC_DecodedBitStreamPaser { + public: + CBC_DecodedBitStreamPaser(); + virtual ~CBC_DecodedBitStreamPaser(); + static void Initialize(); + static void Finalize(); + static CBC_CommonDecoderResult* decode(CFX_Int32Array& codewords, + CFX_ByteString ecLevel, + int32_t& e); + + private: + enum Mode { ALPHA, LOWER, MIXED, PUNCT, ALPHA_SHIFT, PUNCT_SHIFT }; + static int32_t MAX_NUMERIC_CODEWORDS; + static int32_t PL; + static int32_t LL; + static int32_t AS; + static int32_t ML; + static int32_t AL; + static int32_t PS; + static int32_t PAL; + static FX_CHAR PUNCT_CHARS[29]; + static FX_CHAR MIXED_CHARS[30]; + static int32_t NUMBER_OF_SEQUENCE_CODEWORDS; + static int32_t decodeMacroBlock(CFX_Int32Array& codewords, + int32_t codeIndex, + CBC_PDF417ResultMetadata* resultMetadata, + int32_t& e); + static int32_t textCompaction(CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result); + static void decodeTextCompaction(CFX_Int32Array& textCompactionData, + CFX_Int32Array& byteCompactionData, + int32_t length, + CFX_ByteString& result); + static int32_t byteCompaction(int32_t mode, + CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result); + static int32_t numericCompaction(CFX_Int32Array& codewords, + int32_t codeIndex, + CFX_ByteString& result, + int32_t& e); + static CFX_ByteString decodeBase900toBase10(CFX_Int32Array& codewords, + int32_t count, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp new file mode 100644 index 0000000000..fa278bdea9 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp @@ -0,0 +1,339 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" + +int32_t CBC_DetectionResult::ADJUST_ROW_NUMBER_SKIP = 2; + +CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, + CBC_BoundingBox* boundingBox) { + m_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; + } +} +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)); + adjustIndicatorColumnRowNumbers( + (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt( + m_barcodeColumnCount + 1)); + int32_t unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE; + int32_t previousUnadjustedCount; + do { + previousUnadjustedCount = unadjustedCodewordCount; + unadjustedCodewordCount = adjustRowNumbers(); + } while (unadjustedCodewordCount > 0 && + unadjustedCodewordCount < previousUnadjustedCount); + return m_detectionResultColumns; +} +void CBC_DetectionResult::setBoundingBox(CBC_BoundingBox* boundingBox) { + m_boundingBox = boundingBox; +} +CBC_BoundingBox* CBC_DetectionResult::getBoundingBox() { + return m_boundingBox; +} +void CBC_DetectionResult::setDetectionResultColumn( + int32_t barcodeColumn, + CBC_DetectionResultColumn* detectionResultColumn) { + m_detectionResultColumns[barcodeColumn] = detectionResultColumn; +} +CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn( + int32_t barcodeColumn) { + return (CBC_DetectionResultColumn*)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]; + } + CFX_ByteString result; + for (int32_t codewordsRow = 0; + codewordsRow < rowIndicatorColumn->getCodewords()->GetSize(); + codewordsRow++) { + result += (FX_CHAR)codewordsRow; + for (int32_t barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount + 2; + barcodeColumn++) { + if (m_detectionResultColumns[barcodeColumn] == NULL) { + result += " | "; + continue; + } + CBC_Codeword* codeword = + (CBC_Codeword*)((CBC_DetectionResultColumn*) + m_detectionResultColumns[barcodeColumn]) + ->getCodewords() + ->GetAt(codewordsRow); + if (codeword == NULL) { + result += " | "; + continue; + } + result += codeword->getRowNumber(); + result += codeword->getValue(); + } + } + return result; +} +void CBC_DetectionResult::adjustIndicatorColumnRowNumbers( + CBC_DetectionResultColumn* detectionResultColumn) { + if (detectionResultColumn) { + ((CBC_DetectionResultRowIndicatorColumn*)detectionResultColumn) + ->adjustCompleteIndicatorColumnRowNumbers(*m_barcodeMetadata); + } +} +int32_t CBC_DetectionResult::adjustRowNumbers() { + int32_t unadjustedCount = adjustRowNumbersByRow(); + if (unadjustedCount == 0) { + return 0; + } + for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; + barcodeColumn++) { + CFX_PtrArray* codewords = + ((CBC_DetectionResultColumn*)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()) { + adjustRowNumbers(barcodeColumn, codewordsRow, codewords); + } + } + } + return unadjustedCount; +} +int32_t CBC_DetectionResult::adjustRowNumbersByRow() { + adjustRowNumbersFromBothRI(); + int32_t unadjustedCount = adjustRowNumbersFromLRI(); + return unadjustedCount + adjustRowNumbersFromRRI(); +} +int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() { + if (m_detectionResultColumns[0] == NULL || + m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { + return 0; + } + CFX_PtrArray* LRIcodewords = + ((CBC_DetectionResultColumn*)m_detectionResultColumns[0])->getCodewords(); + CFX_PtrArray* RRIcodewords = + ((CBC_DetectionResultColumn*) + 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()) { + 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) { + continue; + } + codeword->setRowNumber( + ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber()); + if (!codeword->hasValidRowNumber()) { + ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]) + ->getCodewords() + ->SetAt(codewordsRow, NULL); + } + } + } + } + return 0; +} +int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { + if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { + return 0; + } + int32_t unadjustedCount = 0; + CFX_PtrArray* codewords = + ((CBC_DetectionResultColumn*)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(); + 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); + if (codeword) { + invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, + invalidRowCounts, codeword); + if (!codeword->hasValidRowNumber()) { + unadjustedCount++; + } + } + } + } + return unadjustedCount; +} +int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { + if (m_detectionResultColumns[0] == NULL) { + return 0; + } + int32_t unadjustedCount = 0; + CFX_PtrArray* codewords = + ((CBC_DetectionResultColumn*)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(); + 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); + if (codeword) { + invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, + invalidRowCounts, codeword); + if (!codeword->hasValidRowNumber()) { + unadjustedCount++; + } + } + } + } + return unadjustedCount; +} +int32_t CBC_DetectionResult::adjustRowNumberIfValid( + int32_t rowIndicatorRowNumber, + int32_t invalidRowCounts, + CBC_Codeword* codeword) { + if (codeword == NULL) { + return invalidRowCounts; + } + if (!codeword->hasValidRowNumber()) { + if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { + codeword->setRowNumber(rowIndicatorRowNumber); + invalidRowCounts = 0; + } else { + ++invalidRowCounts; + } + } + 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; + if (m_detectionResultColumns[barcodeColumn + 1]) { + nextColumnCodewords = ((CBC_DetectionResultColumn*) + m_detectionResultColumns[barcodeColumn + 1]) + ->getCodewords(); + } + CFX_PtrArray otherCodewords; + otherCodewords.SetSize(14); + otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow); + otherCodewords[3] = nextColumnCodewords->GetAt(codewordsRow); + if (codewordsRow > 0) { + otherCodewords[0] = codewords->GetAt(codewordsRow - 1); + otherCodewords[4] = previousColumnCodewords->GetAt(codewordsRow - 1); + otherCodewords[5] = nextColumnCodewords->GetAt(codewordsRow - 1); + } + if (codewordsRow > 1) { + otherCodewords[8] = codewords->GetAt(codewordsRow - 2); + otherCodewords[10] = previousColumnCodewords->GetAt(codewordsRow - 2); + otherCodewords[11] = nextColumnCodewords->GetAt(codewordsRow - 2); + } + if (codewordsRow < codewords->GetSize() - 1) { + otherCodewords[1] = codewords->GetAt(codewordsRow + 1); + otherCodewords[6] = previousColumnCodewords->GetAt(codewordsRow + 1); + otherCodewords[7] = nextColumnCodewords->GetAt(codewordsRow + 1); + } + if (codewordsRow < codewords->GetSize() - 2) { + otherCodewords[9] = codewords->GetAt(codewordsRow + 2); + otherCodewords[12] = previousColumnCodewords->GetAt(codewordsRow + 2); + otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2); + } + for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { + CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i); + if (adjustRowNumber(codeword, otherCodeword)) { + return; + } + } +} +FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, + CBC_Codeword* otherCodeword) { + if (otherCodeword == NULL) { + return FALSE; + } + if (otherCodeword->hasValidRowNumber() && + otherCodeword->getBucket() == codeword->getBucket()) { + codeword->setRowNumber(otherCodeword->getRowNumber()); + return TRUE; + } + return FALSE; +} +int32_t CBC_DetectionResult::getBarcodeColumnCount() { + return m_barcodeColumnCount; +} +int32_t CBC_DetectionResult::getBarcodeRowCount() { + return m_barcodeMetadata->getRowCount(); +} +int32_t CBC_DetectionResult::getBarcodeECLevel() { + return m_barcodeMetadata->getErrorCorrectionLevel(); +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h new file mode 100644 index 0000000000..8b7f91bfcd --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h @@ -0,0 +1,57 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ + +class CBC_BarcodeMetadata; +class CBC_BoundingBox; +class CBC_Codeword; +class CBC_DetectionResultColumn; +class CBC_DetectionResult { + public: + CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, + CBC_BoundingBox* boundingBox); + virtual ~CBC_DetectionResult(); + CFX_PtrArray& getDetectionResultColumns(); + void setBoundingBox(CBC_BoundingBox* boundingBox); + CBC_BoundingBox* getBoundingBox(); + void setDetectionResultColumn( + int32_t barcodeColumn, + CBC_DetectionResultColumn* detectionResultColumn); + CBC_DetectionResultColumn* getDetectionResultColumn(int32_t barcodeColumn); + CFX_ByteString toString(); + + int32_t getBarcodeColumnCount(); + int32_t getBarcodeRowCount(); + int32_t getBarcodeECLevel(); + + private: + static int32_t ADJUST_ROW_NUMBER_SKIP; + CBC_BarcodeMetadata* m_barcodeMetadata; + CFX_PtrArray m_detectionResultColumns; + CBC_BoundingBox* m_boundingBox; + int32_t m_barcodeColumnCount; + + private: + void adjustIndicatorColumnRowNumbers( + CBC_DetectionResultColumn* detectionResultColumn); + int32_t adjustRowNumbers(); + int32_t adjustRowNumbersByRow(); + int32_t adjustRowNumbersFromBothRI(); + int32_t adjustRowNumbersFromRRI(); + int32_t adjustRowNumbersFromLRI(); + static int32_t adjustRowNumberIfValid(int32_t rowIndicatorRowNumber, + int32_t invalidRowCounts, + CBC_Codeword* codeword); + void adjustRowNumbers(int32_t barcodeColumn, + int32_t codewordsRow, + CFX_PtrArray* codewords); + static FX_BOOL adjustRowNumber(CBC_Codeword* codeword, + CBC_Codeword* otherCodeword); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp new file mode 100644 index 0000000000..24d81070f3 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp @@ -0,0 +1,101 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" + +int32_t CBC_DetectionResultColumn::MAX_NEARBY_DISTANCE = 5; + +CBC_DetectionResultColumn::CBC_DetectionResultColumn( + CBC_BoundingBox* boundingBox) { + m_boundingBox = boundingBox; + m_codewords = new CFX_PtrArray; + 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); + } + m_codewords->RemoveAll(); + delete m_codewords; +} +CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(int32_t imageRow) { + CBC_Codeword* codeword = getCodeword(imageRow); + if (codeword) { + return codeword; + } + for (int32_t i = 1; i < MAX_NEARBY_DISTANCE; i++) { + int32_t nearImageRow = imageRowToCodewordIndex(imageRow) - i; + if (nearImageRow >= 0) { + codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); + if (codeword) { + return codeword; + } + } + nearImageRow = imageRowToCodewordIndex(imageRow) + i; + if (nearImageRow < m_codewords->GetSize()) { + codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); + if (codeword) { + return codeword; + } + } + } + return NULL; +} +int32_t CBC_DetectionResultColumn::imageRowToCodewordIndex(int32_t imageRow) { + return imageRow - m_boundingBox->getMinY(); +} +int32_t CBC_DetectionResultColumn::codewordIndexToImageRow( + int32_t codewordIndex) { + return m_boundingBox->getMinY() + codewordIndex; +} +void CBC_DetectionResultColumn::setCodeword(int32_t imageRow, + CBC_Codeword* codeword) { + m_codewords->SetAt(imageRowToCodewordIndex(imageRow), codeword); +} +CBC_Codeword* CBC_DetectionResultColumn::getCodeword(int32_t imageRow) { + return (CBC_Codeword*)m_codewords->GetAt(imageRowToCodewordIndex(imageRow)); +} +CBC_BoundingBox* CBC_DetectionResultColumn::getBoundingBox() { + return m_boundingBox; +} +CFX_PtrArray* CBC_DetectionResultColumn::getCodewords() { + return m_codewords; +} +CFX_ByteString CBC_DetectionResultColumn::toString() { + CFX_ByteString result; + int32_t row = 0; + for (int32_t i = 0; i < m_codewords->GetSize(); i++) { + CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i); + if (codeword == NULL) { + result += (FX_CHAR)row; + row++; + continue; + } + result += (FX_CHAR)row; + result += codeword->getRowNumber(); + result += codeword->getValue(); + row++; + } + return result; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h new file mode 100644 index 0000000000..ebe01a2a0c --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h @@ -0,0 +1,33 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ + +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_ByteString toString(); + + public: + CBC_BoundingBox* m_boundingBox; + CFX_PtrArray* m_codewords; + + private: + static int32_t MAX_NEARBY_DISTANCE; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp new file mode 100644 index 0000000000..22fd25df8b --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp @@ -0,0 +1,267 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" +#include "xfa/fxbarcode/utils.h" + +CBC_DetectionResultRowIndicatorColumn::CBC_DetectionResultRowIndicatorColumn( + CBC_BoundingBox* boundingBox, + FX_BOOL isLeft) + : CBC_DetectionResultColumn(boundingBox) { + m_isLeft = isLeft; +} +CBC_DetectionResultRowIndicatorColumn:: + ~CBC_DetectionResultRowIndicatorColumn() {} +void CBC_DetectionResultRowIndicatorColumn::setRowNumbers() { + for (int32_t i = 0; i < m_codewords->GetSize(); i++) { + CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i); + if (codeword) { + codeword->setRowNumberAsRowIndicatorColumn(); + } + } +} +int32_t +CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers( + CBC_BarcodeMetadata barcodeMetadata) { + CFX_PtrArray* codewords = getCodewords(); + setRowNumbers(); + removeIncorrectCodewords(codewords, barcodeMetadata); + CBC_BoundingBox* boundingBox = getBoundingBox(); + CBC_ResultPoint* top = + m_isLeft ? boundingBox->getTopLeft() : boundingBox->getTopRight(); + CBC_ResultPoint* bottom = + m_isLeft ? boundingBox->getBottomLeft() : boundingBox->getBottomRight(); + int32_t firstRow = imageRowToCodewordIndex((int32_t)top->GetY()); + int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY()); + FX_FLOAT averageRowHeight = + (lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount(); + int32_t barcodeRow = -1; + int32_t maxRowHeight = 1; + int32_t currentRowHeight = 0; + for (int32_t codewordsRow = firstRow; codewordsRow < lastRow; + codewordsRow++) { + if (codewords->GetAt(codewordsRow) == NULL) { + continue; + } + CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); + int32_t rowDifference = codeword->getRowNumber() - barcodeRow; + if (rowDifference == 0) { + currentRowHeight++; + } else if (rowDifference == 1) { + maxRowHeight = + maxRowHeight > currentRowHeight ? maxRowHeight : currentRowHeight; + currentRowHeight = 1; + barcodeRow = codeword->getRowNumber(); + } else if (rowDifference < 0) { + codewords->SetAt(codewordsRow, NULL); + } else if (codeword->getRowNumber() >= barcodeMetadata.getRowCount()) { + codewords->SetAt(codewordsRow, NULL); + } else if (rowDifference > codewordsRow) { + codewords->SetAt(codewordsRow, NULL); + } else { + int32_t checkedRows; + if (maxRowHeight > 2) { + checkedRows = (maxRowHeight - 2) * rowDifference; + } else { + checkedRows = rowDifference; + } + FX_BOOL closePreviousCodewordFound = checkedRows >= codewordsRow; + for (int32_t i = 1; i <= checkedRows && !closePreviousCodewordFound; + i++) { + closePreviousCodewordFound = codewords->GetAt(codewordsRow - i) != NULL; + } + if (closePreviousCodewordFound) { + codewords->SetAt(codewordsRow, NULL); + } else { + barcodeRow = codeword->getRowNumber(); + currentRowHeight = 1; + } + } + } + return (int32_t)(averageRowHeight + 0.5); +} +CFX_Int32Array* CBC_DetectionResultRowIndicatorColumn::getRowHeights( + int32_t& e) { + CBC_BarcodeMetadata* barcodeMetadata = getBarcodeMetadata(); + if (barcodeMetadata == NULL) { + e = BCExceptionCannotMetadata; + return NULL; + } + adjustIncompleteIndicatorColumnRowNumbers(*barcodeMetadata); + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(barcodeMetadata->getRowCount()); + for (int32_t i = 0; i < getCodewords()->GetSize(); i++) { + CBC_Codeword* codeword = (CBC_Codeword*)getCodewords()->GetAt(i); + if (codeword) { + result->SetAt(codeword->getRowNumber(), + result->GetAt(codeword->getRowNumber()) + 1); + } + } + return result; +} +int32_t CBC_DetectionResultRowIndicatorColumn:: + adjustIncompleteIndicatorColumnRowNumbers( + CBC_BarcodeMetadata barcodeMetadata) { + CBC_BoundingBox* boundingBox = getBoundingBox(); + CBC_ResultPoint* top = + m_isLeft ? boundingBox->getTopLeft() : boundingBox->getTopRight(); + CBC_ResultPoint* bottom = + m_isLeft ? boundingBox->getBottomLeft() : boundingBox->getBottomRight(); + int32_t firstRow = imageRowToCodewordIndex((int32_t)top->GetY()); + int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY()); + FX_FLOAT averageRowHeight = + (lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount(); + CFX_PtrArray* codewords = getCodewords(); + int32_t barcodeRow = -1; + int32_t maxRowHeight = 1; + int32_t currentRowHeight = 0; + for (int32_t codewordsRow = firstRow; codewordsRow < lastRow; + codewordsRow++) { + if (codewords->GetAt(codewordsRow) == NULL) { + continue; + } + CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); + codeword->setRowNumberAsRowIndicatorColumn(); + int32_t rowDifference = codeword->getRowNumber() - barcodeRow; + if (rowDifference == 0) { + currentRowHeight++; + } else if (rowDifference == 1) { + maxRowHeight = + maxRowHeight > currentRowHeight ? maxRowHeight : currentRowHeight; + currentRowHeight = 1; + barcodeRow = codeword->getRowNumber(); + } else if (codeword->getRowNumber() >= barcodeMetadata.getRowCount()) { + codewords->SetAt(codewordsRow, NULL); + } else { + barcodeRow = codeword->getRowNumber(); + currentRowHeight = 1; + } + } + return (int32_t)(averageRowHeight + 0.5); +} +CBC_BarcodeMetadata* +CBC_DetectionResultRowIndicatorColumn::getBarcodeMetadata() { + CFX_PtrArray* 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); + if (codeword == NULL) { + continue; + } + codeword->setRowNumberAsRowIndicatorColumn(); + int32_t rowIndicatorValue = codeword->getValue() % 30; + int32_t codewordRowNumber = codeword->getRowNumber(); + if (!m_isLeft) { + codewordRowNumber += 2; + } + switch (codewordRowNumber % 3) { + case 0: + barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1); + break; + case 1: + barcodeECLevel.setValue(rowIndicatorValue / 3); + barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3); + break; + case 2: + barcodeColumnCount.setValue(rowIndicatorValue + 1); + break; + } + } + if ((barcodeColumnCount.getValue()->GetSize() == 0) || + (barcodeRowCountUpperPart.getValue()->GetSize() == 0) || + (barcodeRowCountLowerPart.getValue()->GetSize() == 0) || + (barcodeECLevel.getValue()->GetSize() == 0) || + barcodeColumnCount.getValue()->GetAt(0) < 1 || + barcodeRowCountUpperPart.getValue()->GetAt(0) + + barcodeRowCountLowerPart.getValue()->GetAt(0) < + CBC_PDF417Common::MIN_ROWS_IN_BARCODE || + barcodeRowCountUpperPart.getValue()->GetAt(0) + + barcodeRowCountLowerPart.getValue()->GetAt(0) > + CBC_PDF417Common::MAX_ROWS_IN_BARCODE) { + return NULL; + } + CBC_BarcodeMetadata* barcodeMetadata = + new CBC_BarcodeMetadata(barcodeColumnCount.getValue()->GetAt(0), + barcodeRowCountUpperPart.getValue()->GetAt(0), + barcodeRowCountLowerPart.getValue()->GetAt(0), + barcodeECLevel.getValue()->GetAt(0)); + removeIncorrectCodewords(codewords, *barcodeMetadata); + return barcodeMetadata; +} +FX_BOOL CBC_DetectionResultRowIndicatorColumn::isLeft() { + return m_isLeft; +} +CFX_ByteString CBC_DetectionResultRowIndicatorColumn::toString() { + return (CFX_ByteString) "IsLeft: " + (CFX_ByteString)m_isLeft + '\n' + + CBC_DetectionResultColumn::toString(); +} +void CBC_DetectionResultRowIndicatorColumn::removeIncorrectCodewords( + CFX_PtrArray* codewords, + CBC_BarcodeMetadata barcodeMetadata) { + for (int32_t codewordRow = 0; codewordRow < codewords->GetSize(); + codewordRow++) { + CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordRow); + if (codeword == NULL) { + continue; + } + int32_t rowIndicatorValue = codeword->getValue() % 30; + int32_t codewordRowNumber = codeword->getRowNumber(); + if (codewordRowNumber > barcodeMetadata.getRowCount()) { + codewords->SetAt(codewordRow, NULL); + continue; + } + if (!m_isLeft) { + codewordRowNumber += 2; + } + switch (codewordRowNumber % 3) { + case 0: + if (rowIndicatorValue * 3 + 1 != + barcodeMetadata.getRowCountUpperPart()) { + codewords->SetAt(codewordRow, NULL); + } + break; + case 1: + if (rowIndicatorValue / 3 != + barcodeMetadata.getErrorCorrectionLevel() || + rowIndicatorValue % 3 != barcodeMetadata.getRowCountLowerPart()) { + codewords->SetAt(codewordRow, NULL); + } + break; + case 2: + if (rowIndicatorValue + 1 != barcodeMetadata.getColumnCount()) { + codewords->SetAt(codewordRow, NULL); + } + break; + } + } +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h new file mode 100644 index 0000000000..dfe6a069d6 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ + +class CBC_BarcodeMetadata; +class CBC_BoundingBox; +class CBC_DetectionResultRowIndicatorColumn; +class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn { + public: + CBC_DetectionResultRowIndicatorColumn(CBC_BoundingBox* boundingBox, + FX_BOOL isLeft); + virtual ~CBC_DetectionResultRowIndicatorColumn(); + void setRowNumbers(); + int32_t adjustCompleteIndicatorColumnRowNumbers( + CBC_BarcodeMetadata barcodeMetadata); + CFX_Int32Array* getRowHeights(int32_t& e); + int32_t adjustIncompleteIndicatorColumnRowNumbers( + CBC_BarcodeMetadata barcodeMetadata); + CBC_BarcodeMetadata* getBarcodeMetadata(); + FX_BOOL isLeft(); + CFX_ByteString toString(); + + private: + FX_BOOL m_isLeft; + void removeIncorrectCodewords(CFX_PtrArray* codewords, + CBC_BarcodeMetadata barcodeMetadata); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp new file mode 100644 index 0000000000..cfd52e56dc --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp @@ -0,0 +1,352 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Detector.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/utils.h" + +#define INTEGER_MAX 2147483647 + +int32_t CBC_Detector::INDEXES_START_PATTERN[] = {0, 4, 1, 5}; +int32_t CBC_Detector::INDEXES_STOP_PATTERN[] = {6, 2, 7, 3}; +int32_t CBC_Detector::INTEGER_MATH_SHIFT = 8; +int32_t CBC_Detector::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 + << INTEGER_MATH_SHIFT; +int32_t CBC_Detector::MAX_AVG_VARIANCE = + (int32_t)(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); +int32_t CBC_Detector::MAX_INDIVIDUAL_VARIANCE = + (int32_t)(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f); +int32_t CBC_Detector::START_PATTERN[] = {8, 1, 1, 1, 1, 1, 1, 3}; +int32_t CBC_Detector::STOP_PATTERN[] = {7, 1, 1, 3, 1, 1, 1, 2, 1}; +int32_t CBC_Detector::MAX_PIXEL_DRIFT = 3; +int32_t CBC_Detector::MAX_PATTERN_DRIFT = 5; +int32_t CBC_Detector::SKIPPED_ROW_COUNT_MAX = 25; +int32_t CBC_Detector::ROW_STEP = 5; +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); + if (barcodeCoordinates->GetSize() == 0) { + rotate180(bitMatrix); + barcodeCoordinates = detect(multiple, bitMatrix); + } + if (barcodeCoordinates->GetSize() == 0) { + e = BCExceptionUnSupportedBarcode; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CBC_PDF417DetectorResult* detectorResult = + new CBC_PDF417DetectorResult(bitMatrix, barcodeCoordinates); + return detectorResult; +} +void CBC_Detector::rotate180(CBC_CommonBitMatrix* bitMatrix) { + int32_t width = bitMatrix->GetWidth(); + int32_t height = bitMatrix->GetHeight(); + CBC_CommonBitArray* firstRowBitArray = new CBC_CommonBitArray(width); + CBC_CommonBitArray* secondRowBitArray = new CBC_CommonBitArray(width); + CBC_CommonBitArray* tmpBitArray = new CBC_CommonBitArray(width); + for (int32_t y = 0; y<(height + 1)>> 1; y++) { + CBC_CommonBitArray* temp = + bitMatrix->GetRow(height - 1 - y, secondRowBitArray); + CBC_CommonBitArray* tempfirstRow = firstRowBitArray; + firstRowBitArray = bitMatrix->GetRow(y, tempfirstRow); + delete tempfirstRow; + CBC_CommonBitArray* row = mirror(temp, tmpBitArray); + delete temp; + bitMatrix->SetRow(y, row); + delete row; + CBC_CommonBitArray* rowfirstRow = mirror(firstRowBitArray, tmpBitArray); + bitMatrix->SetRow(height - 1 - y, rowfirstRow); + delete rowfirstRow; + } + delete tmpBitArray; + delete firstRowBitArray; + delete secondRowBitArray; +} +CBC_CommonBitArray* CBC_Detector::mirror(CBC_CommonBitArray* input, + CBC_CommonBitArray* result) { + CBC_CommonBitArray* array = new CBC_CommonBitArray(result->GetSize()); + array->Clear(); + int32_t size = input->GetSize(); + for (int32_t i = 0; i < size; i++) { + if (input->Get(i)) { + array->Set(size - 1 - i); + } + } + return array; +} +CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, + CBC_CommonBitMatrix* bitMatrix) { + CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray; + int32_t row = 0; + int32_t column = 0; + FX_BOOL foundBarcodeInRow = FALSE; + while (row < bitMatrix->GetHeight()) { + CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); + if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { + if (!foundBarcodeInRow) { + if (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); + if (barcodeCoordinate->GetAt(1)) { + row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); + } + if (barcodeCoordinate->GetAt(3)) { + row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); + } + } + row += ROW_STEP; + if (vertices) { + delete (vertices); + } + continue; + } + foundBarcodeInRow = TRUE; + barcodeCoordinates->Add(vertices); + if (!multiple) { + break; + } + if (vertices->GetAt(2)) { + column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); + row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); + } else { + column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetX(); + row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetY(); + } + } + return barcodeCoordinates; +} +CFX_PtrArray* 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; + 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; + if (result->GetAt(4)) { + startColumn = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetX(); + startRow = (int32_t)((CBC_ResultPoint*)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; + return result; +} +void CBC_Detector::copyToResult(CFX_PtrArray* result, + CFX_PtrArray* 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; + result->SetSize(4); + FX_BOOL found = FALSE; + CFX_Int32Array counters; + counters.SetSize(patternLength); + for (; startRow < height; startRow += ROW_STEP) { + CFX_Int32Array* loc = + findGuardPattern(matrix, startColumn, startRow, width, FALSE, pattern, + patternLength, counters); + if (loc) { + while (startRow > 0) { + CFX_Int32Array* previousRowLoc = + findGuardPattern(matrix, startColumn, --startRow, width, FALSE, + pattern, patternLength, counters); + if (previousRowLoc) { + delete loc; + loc = previousRowLoc; + } else { + startRow++; + break; + } + } + result->SetAt( + 0, new CBC_ResultPoint((FX_FLOAT)loc->GetAt(0), (FX_FLOAT)startRow)); + result->SetAt( + 1, new CBC_ResultPoint((FX_FLOAT)loc->GetAt(1), (FX_FLOAT)startRow)); + found = TRUE; + delete loc; + break; + } + } + int32_t stopRow = startRow + 1; + 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()); + for (; stopRow < height; stopRow++) { + CFX_Int32Array* loc = + findGuardPattern(matrix, previousRowLoc[0], stopRow, width, FALSE, + pattern, patternLength, counters); + if (loc && abs(previousRowLoc[0] - loc->GetAt(0)) < MAX_PATTERN_DRIFT && + abs(previousRowLoc[1] - loc->GetAt(1)) < MAX_PATTERN_DRIFT) { + previousRowLoc.Copy(*loc); + skippedRowCount = 0; + } else { + if (skippedRowCount > SKIPPED_ROW_COUNT_MAX) { + delete loc; + break; + } else { + skippedRowCount++; + } + } + delete loc; + } + stopRow -= skippedRowCount + 1; + result->SetAt(2, new CBC_ResultPoint((FX_FLOAT)previousRowLoc.GetAt(0), + (FX_FLOAT)stopRow)); + result->SetAt(3, new CBC_ResultPoint((FX_FLOAT)previousRowLoc.GetAt(1), + (FX_FLOAT)stopRow)); + } + if (stopRow - startRow < BARCODE_MIN_HEIGHT) { + for (int32_t i = 0; i < result->GetSize(); i++) { + result->SetAt(i, NULL); + } + } + return result; +} +CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, + int32_t column, + int32_t row, + int32_t width, + FX_BOOL whiteFirst, + int32_t* pattern, + int32_t patternLength, + CFX_Int32Array& counters) { + for (int32_t i = 0; i < counters.GetSize(); i++) { + counters.SetAt(i, 0); + } + FX_BOOL isWhite = whiteFirst; + int32_t patternStart = column; + int32_t pixelDrift = 0; + CFX_Int32Array* intarray = new CFX_Int32Array; + while (matrix->Get(patternStart, row) && patternStart > 0 && + pixelDrift++ < MAX_PIXEL_DRIFT) { + patternStart--; + } + int32_t x = patternStart; + int32_t counterPosition = 0; + for (; x < width; x++) { + FX_BOOL pixel = matrix->Get(x, row); + if (pixel ^ isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == patternLength - 1) { + if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < + MAX_AVG_VARIANCE) { + intarray->Add(patternStart); + intarray->Add(x); + return intarray; + } + patternStart += counters[0] + counters[1]; + for (int32_t l = 2, k = 0; l < patternLength; l++, k++) { + counters.SetAt(k, counters.GetAt(l)); + } + counters.SetAt(patternLength - 2, 0); + counters.SetAt(patternLength - 1, 0); + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + if (counterPosition == patternLength - 1) { + if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < + MAX_AVG_VARIANCE) { + intarray->Add(patternStart); + intarray->Add(x - 1); + return intarray; + } + } + delete intarray; + return NULL; +} +int32_t CBC_Detector::patternMatchVariance(CFX_Int32Array& counters, + int32_t* pattern, + int32_t maxIndividualVariance) { + int32_t numCounters = counters.GetSize(); + int32_t total = 0; + int32_t patternLength = 0; + for (int32_t i = 0; i < numCounters; i++) { + total += counters[i]; + patternLength += pattern[i]; + } + if (total < patternLength) { + return INTEGER_MAX; + } + int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength; + maxIndividualVariance = + (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT; + int32_t totalVariance = 0; + for (int32_t x = 0; x < numCounters; x++) { + int32_t counter = counters[x] << INTEGER_MATH_SHIFT; + int32_t scaledPattern = pattern[x] * unitBarWidth; + int32_t variance = counter > scaledPattern ? counter - scaledPattern + : scaledPattern - counter; + if (variance > maxIndividualVariance) { + return INTEGER_MAX; + } + totalVariance += variance; + } + return totalVariance / total; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Detector.h b/xfa/fxbarcode/pdf417/BC_PDF417Detector.h new file mode 100644 index 0000000000..dda039d6d5 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Detector.h @@ -0,0 +1,69 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ + +class CBC_PDF417DetectorResult; +class CBC_BinaryBitmap; +class CBC_CommonBitMatrix; +class CBC_CommonBitArray; + +class CBC_Detector { + public: + CBC_Detector(); + virtual ~CBC_Detector(); + static CBC_PDF417DetectorResult* detect(CBC_BinaryBitmap* image, + int32_t hints, + FX_BOOL multiple, + int32_t& e); + static void rotate180(CBC_CommonBitMatrix* bitMatrix); + static CBC_CommonBitArray* mirror(CBC_CommonBitArray* input, + CBC_CommonBitArray* result); + + private: + static int32_t INDEXES_START_PATTERN[]; + static int32_t INDEXES_STOP_PATTERN[]; + static int32_t INTEGER_MATH_SHIFT; + static int32_t PATTERN_MATCH_RESULT_SCALE_FACTOR; + static int32_t MAX_AVG_VARIANCE; + static int32_t MAX_INDIVIDUAL_VARIANCE; + static int32_t START_PATTERN[]; + static int32_t STOP_PATTERN[]; + static int32_t MAX_PIXEL_DRIFT; + static int32_t MAX_PATTERN_DRIFT; + 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, + 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 CFX_Int32Array* findGuardPattern(CBC_CommonBitMatrix* matrix, + int32_t column, + int32_t row, + int32_t width, + FX_BOOL whiteFirst, + int32_t* pattern, + int32_t patternLength, + CFX_Int32Array& counters); + static int32_t patternMatchVariance(CFX_Int32Array& counters, + int32_t* pattern, + int32_t maxIndividualVariance); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp b/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp new file mode 100644 index 0000000000..557d50d951 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp @@ -0,0 +1,50 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#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() { + 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(); + delete temp; + } + m_points->RemoveAll(); + delete m_points; +} +CBC_CommonBitMatrix* CBC_PDF417DetectorResult::getBits() { + return m_bits; +} + +CFX_PtrArray* CBC_PDF417DetectorResult::getPoints() { + return m_points; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h b/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h new file mode 100644 index 0000000000..0eea685fbc --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h @@ -0,0 +1,26 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; + +class CBC_PDF417DetectorResult { + public: + CBC_PDF417DetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points); + virtual ~CBC_PDF417DetectorResult(); + CBC_CommonBitMatrix* getBits(); + CFX_PtrArray* getPoints(); + + private: + CBC_CommonBitMatrix* m_bits; + CFX_PtrArray* m_points; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.cpp new file mode 100644 index 0000000000..3f0b3145b0 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.cpp @@ -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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h" + +CBC_Dimensions::CBC_Dimensions(int32_t minCols, + int32_t maxCols, + int32_t minRows, + int32_t maxRows) { + m_minCols = minCols; + m_maxCols = maxCols; + m_minRows = minRows; + m_maxRows = maxRows; +} +CBC_Dimensions::~CBC_Dimensions() {} +int32_t CBC_Dimensions::getMinCols() { + return m_minCols; +} +int32_t CBC_Dimensions::getMaxCols() { + return m_maxCols; +} +int32_t CBC_Dimensions::getMinRows() { + return m_minRows; +} +int32_t CBC_Dimensions::getMaxRows() { + return m_maxRows; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h b/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h new file mode 100644 index 0000000000..622ad236bc --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Dimensions.h @@ -0,0 +1,31 @@ +// 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_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ + +#include <stdint.h> + +class CBC_Dimensions { + public: + CBC_Dimensions(int32_t minCols, + int32_t maxCols, + int32_t minRows, + int32_t maxRows); + virtual ~CBC_Dimensions(); + int32_t getMinCols(); + int32_t getMaxCols(); + int32_t getMinRows(); + int32_t getMaxRows(); + + private: + int32_t m_minCols; + int32_t m_maxCols; + int32_t m_minRows; + int32_t m_maxRows; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp new file mode 100644 index 0000000000..830b65e199 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp @@ -0,0 +1,389 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/utils.h" + +CBC_PDF417ECModulusGF* CBC_PDF417ECErrorCorrection::m_field = NULL; + +void CBC_PDF417ECErrorCorrection::Initialize(int32_t& e) { + m_field = + new CBC_PDF417ECModulusGF(CBC_PDF417Common::NUMBER_OF_CODEWORDS, 3, e); +} +void CBC_PDF417ECErrorCorrection::Finalize() { + delete m_field; +} +CBC_PDF417ECErrorCorrection::CBC_PDF417ECErrorCorrection() {} +CBC_PDF417ECErrorCorrection::~CBC_PDF417ECErrorCorrection() {} +int32_t CBC_PDF417ECErrorCorrection::decode(CFX_Int32Array& received, + int32_t numECCodewords, + CFX_Int32Array& erasures, + int32_t& e) { + CBC_PDF417ECModulusPoly poly(m_field, received, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + CFX_Int32Array S; + S.SetSize(numECCodewords); + FX_BOOL error = FALSE; + for (int32_t l = numECCodewords; l > 0; l--) { + int32_t eval = poly.evaluateAt(m_field->exp(l)); + S[numECCodewords - l] = eval; + if (eval != 0) { + error = TRUE; + } + } + if (!error) { + return 0; + } + CBC_PDF417ECModulusPoly* syndrome = + new CBC_PDF417ECModulusPoly(m_field, S, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + CBC_PDF417ECModulusPoly* buildmonomial = + m_field->buildMonomial(numECCodewords, 1, e); + if (e != BCExceptionNO) { + delete syndrome; + return -1; + } + CFX_PtrArray* sigmaOmega = + runEuclideanAlgorithm(buildmonomial, syndrome, numECCodewords, e); + delete buildmonomial; + delete syndrome; + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + CBC_PDF417ECModulusPoly* sigma = + (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(0); + CBC_PDF417ECModulusPoly* omega = + (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(1); + CFX_Int32Array* errorLocations = findErrorLocations(sigma, e); + if (e != BCExceptionNO) { + for (int32_t i = 0; i < sigmaOmega->GetSize(); i++) { + delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(i); + } + sigmaOmega->RemoveAll(); + delete sigmaOmega; + return -1; + } + CFX_Int32Array* errorMagnitudes = + findErrorMagnitudes(omega, sigma, *errorLocations, e); + if (e != BCExceptionNO) { + delete errorLocations; + for (int32_t i = 0; i < sigmaOmega->GetSize(); i++) { + delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(i); + } + sigmaOmega->RemoveAll(); + delete sigmaOmega; + return -1; + } + for (int32_t i = 0; i < errorLocations->GetSize(); i++) { + int32_t log = m_field->log(errorLocations->GetAt(i), e); + + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + int32_t position = received.GetSize() - 1 - log; + if (position < 0) { + e = BCExceptionChecksumException; + delete errorLocations; + delete errorMagnitudes; + for (int32_t j = 0; j < sigmaOmega->GetSize(); j++) { + delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(j); + } + sigmaOmega->RemoveAll(); + delete sigmaOmega; + return -1; + } + received[position] = + m_field->subtract(received[position], errorMagnitudes->GetAt(i)); + } + int32_t result = errorLocations->GetSize(); + delete errorLocations; + delete errorMagnitudes; + for (int32_t k = 0; k < sigmaOmega->GetSize(); k++) { + delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(k); + } + sigmaOmega->RemoveAll(); + delete sigmaOmega; + return result; +} +CFX_PtrArray* 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; + b = temp; + } + CBC_PDF417ECModulusPoly* rLast = a; + CBC_PDF417ECModulusPoly* r = b; + CBC_PDF417ECModulusPoly* tLast = m_field->getZero(); + CBC_PDF417ECModulusPoly* t = m_field->getOne(); + CBC_PDF417ECModulusPoly* qtemp = NULL; + CBC_PDF417ECModulusPoly* rtemp = NULL; + CBC_PDF417ECModulusPoly* ttemp = NULL; + int32_t i = 0; + int32_t j = 0; + int32_t m = 0; + int32_t n = 0; + while (r->getDegree() >= R / 2) { + CBC_PDF417ECModulusPoly* rLastLast = rLast; + CBC_PDF417ECModulusPoly* tLastLast = tLast; + rLast = r; + tLast = t; + m = i; + n = j; + if (rLast->isZero()) { + e = BCExceptionChecksumException; + if (qtemp) { + delete qtemp; + } + if (rtemp) { + delete rtemp; + } + if (ttemp) { + delete ttemp; + } + return NULL; + } + 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; + } + while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { + int32_t degreeDiff = r->getDegree() - rLast->getDegree(); + int32_t scale = + m_field->multiply(r->getCoefficient(r->getDegree()), dltInverse); + 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; + } + q = q->add(buildmonomial, e); + delete buildmonomial; + if (qtemp) { + delete qtemp; + } + if (e != BCExceptionNO) { + if (rtemp) { + delete rtemp; + } + if (ttemp) { + delete ttemp; + } + return NULL; + } + 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; + } + CBC_PDF417ECModulusPoly* temp = r; + r = temp->subtract(multiply, e); + delete multiply; + if (m > 1 && i > m) { + delete temp; + temp = NULL; + } + if (e != BCExceptionNO) { + if (qtemp) { + delete qtemp; + } + if (rtemp) { + delete rtemp; + } + if (ttemp) { + delete ttemp; + } + return NULL; + } + rtemp = r; + i = m + 1; + } + ttemp = q->multiply(tLast, e); + if (qtemp) { + delete qtemp; + qtemp = NULL; + } + if (e != BCExceptionNO) { + if (rtemp) { + delete rtemp; + } + if (ttemp) { + delete ttemp; + } + return NULL; + } + t = ttemp->subtract(tLastLast, e); + if (n > 1 && j > n) { + delete tLastLast; + } + delete ttemp; + if (e != BCExceptionNO) { + if (rtemp) { + delete rtemp; + } + return NULL; + } + ttemp = t; + t = ttemp->negative(e); + delete ttemp; + if (e != BCExceptionNO) { + if (rtemp) { + delete rtemp; + } + return NULL; + } + ttemp = t; + j++; + } + int32_t sigmaTildeAtZero = t->getCoefficient(0); + if (sigmaTildeAtZero == 0) { + e = BCExceptionChecksumException; + if (rtemp) { + delete rtemp; + } + if (ttemp) { + delete ttemp; + } + return NULL; + } + 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 ttemp; + } + if (e != BCExceptionNO) { + if (rtemp) { + delete rtemp; + } + return NULL; + } + CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); + if (rtemp) { + delete rtemp; + } + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_PtrArray* modulusPoly = new CFX_PtrArray; + modulusPoly->Add(sigma); + modulusPoly->Add(omega); + return modulusPoly; +} +CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( + CBC_PDF417ECModulusPoly* errorLocator, + int32_t& e) { + int32_t numErrors = errorLocator->getDegree(); + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(numErrors); + int32_t ee = 0; + for (int32_t i = 1; i < m_field->getSize() && ee < numErrors; i++) { + if (errorLocator->evaluateAt(i) == 0) { + result->SetAt(ee, m_field->inverse(i, e)); + if (e != BCExceptionNO) { + delete result; + return NULL; + } + ee++; + } + } + if (ee != numErrors) { + e = BCExceptionChecksumException; + delete result; + return NULL; + } + return result; +} +CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorMagnitudes( + CBC_PDF417ECModulusPoly* errorEvaluator, + CBC_PDF417ECModulusPoly* errorLocator, + CFX_Int32Array& errorLocations, + int32_t& e) { + int32_t errorLocatorDegree = errorLocator->getDegree(); + CFX_Int32Array formalDerivativeCoefficients; + formalDerivativeCoefficients.SetSize(errorLocatorDegree); + for (int32_t l = 1; l <= errorLocatorDegree; l++) { + formalDerivativeCoefficients[errorLocatorDegree - l] = + m_field->multiply(l, errorLocator->getCoefficient(l)); + } + CBC_PDF417ECModulusPoly formalDerivative(m_field, + formalDerivativeCoefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t s = errorLocations.GetSize(); + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(s); + for (int32_t i = 0; i < s; i++) { + int32_t xiInverse = m_field->inverse(errorLocations[i], e); + if (e != BCExceptionNO) { + delete result; + return NULL; + } + int32_t numerator = + m_field->subtract(0, errorEvaluator->evaluateAt(xiInverse)); + int32_t denominator = + m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); + if (e != BCExceptionNO) { + delete result; + return NULL; + } + result->SetAt(i, m_field->multiply(numerator, denominator)); + } + return result; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h new file mode 100644 index 0000000000..d7b56defe9 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h @@ -0,0 +1,39 @@ +// 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_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ + +class CBC_PDF417ECModulusGF; +class CBC_PDF417ECModulusPoly; +class CBC_PDF417ECErrorCorrection { + public: + CBC_PDF417ECErrorCorrection(); + virtual ~CBC_PDF417ECErrorCorrection(); + static void Initialize(int32_t& e); + static void Finalize(); + static int32_t decode(CFX_Int32Array& received, + int32_t numECCodewords, + CFX_Int32Array& erasures, + int32_t& e); + + private: + static CBC_PDF417ECModulusGF* m_field; + static CFX_PtrArray* runEuclideanAlgorithm(CBC_PDF417ECModulusPoly* a, + CBC_PDF417ECModulusPoly* b, + int32_t R, + int32_t& e); + static CFX_Int32Array* findErrorLocations( + CBC_PDF417ECModulusPoly* errorLocator, + int32_t& e); + static CFX_Int32Array* findErrorMagnitudes( + CBC_PDF417ECModulusPoly* errorEvaluator, + CBC_PDF417ECModulusPoly* errorLocator, + CFX_Int32Array& errorLocations, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp new file mode 100644 index 0000000000..4779d80157 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp @@ -0,0 +1,120 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/utils.h" + +CBC_PDF417ECModulusGF* CBC_PDF417ECModulusGF::PDF417_GF = NULL; +void CBC_PDF417ECModulusGF::Initialize(int32_t& e) { + PDF417_GF = + new CBC_PDF417ECModulusGF(CBC_PDF417Common::NUMBER_OF_CODEWORDS, 3, e); +} +void CBC_PDF417ECModulusGF::Finalize() { + delete PDF417_GF; +} +CBC_PDF417ECModulusGF::CBC_PDF417ECModulusGF(int32_t modulus, + int32_t generator, + int32_t& e) { + m_modulus = modulus; + m_expTable.SetSize(modulus); + m_logTable.SetSize(modulus); + int32_t x = 1; + for (int32_t i = 0; i < modulus; i++) { + m_expTable[i] = x; + x = (x * generator) % modulus; + } + for (int32_t j = 0; j < modulus - 1; j++) { + m_logTable[m_expTable[j]] = j; + } + CFX_Int32Array zero; + zero.Add(0); + m_zero = new CBC_PDF417ECModulusPoly(this, zero, e); + CFX_Int32Array one; + one.Add(1); + m_one = new CBC_PDF417ECModulusPoly(this, one, e); +} +CBC_PDF417ECModulusGF::~CBC_PDF417ECModulusGF() { + delete m_zero; + delete m_one; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::getZero() { + return m_zero; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::getOne() { + return m_one; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::buildMonomial( + int32_t degree, + int32_t coefficient, + int32_t& e) { + if (degree < 0) { + e = BCExceptionIllegalArgument; + return NULL; + } + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (coefficient == 0) { + modulusPoly = new CBC_PDF417ECModulusPoly(m_zero->getField(), + m_zero->getCoefficients(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + CFX_Int32Array coefficients; + coefficients.SetSize(degree + 1); + coefficients[0] = coefficient; + modulusPoly = new CBC_PDF417ECModulusPoly(this, coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +int32_t CBC_PDF417ECModulusGF::add(int32_t a, int32_t b) { + return (a + b) % m_modulus; +} +int32_t CBC_PDF417ECModulusGF::subtract(int32_t a, int32_t b) { + return (m_modulus + a - b) % m_modulus; +} +int32_t CBC_PDF417ECModulusGF::exp(int32_t a) { + return m_expTable[a]; +} +int32_t CBC_PDF417ECModulusGF::log(int32_t a, int32_t& e) { + if (a == 0) { + e = BCExceptionIllegalArgument; + return -1; + } + return m_logTable[a]; +} +int32_t CBC_PDF417ECModulusGF::inverse(int32_t a, int32_t& e) { + if (a == 0) { + e = BCExceptionIllegalArgument; + return -1; + } + return m_expTable[m_modulus - m_logTable[a] - 1]; +} +int32_t CBC_PDF417ECModulusGF::multiply(int32_t a, int32_t b) { + if (a == 0 || b == 0) { + return 0; + } + return m_expTable[(m_logTable[a] + m_logTable[b]) % (m_modulus - 1)]; +} +int32_t CBC_PDF417ECModulusGF::getSize() { + return m_modulus; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h new file mode 100644 index 0000000000..094e00164d --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h @@ -0,0 +1,39 @@ +// 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_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ + +class CBC_PDF417ECModulusPoly; +class CBC_PDF417ECModulusGF { + public: + CBC_PDF417ECModulusGF(int32_t modulus, int32_t generator, int32_t& e); + virtual ~CBC_PDF417ECModulusGF(); + static void Initialize(int32_t& e); + static void Finalize(); + CBC_PDF417ECModulusPoly* getZero(); + CBC_PDF417ECModulusPoly* getOne(); + CBC_PDF417ECModulusPoly* buildMonomial(int32_t degree, + int32_t coefficient, + int32_t& e); + int32_t add(int32_t a, int32_t b); + int32_t subtract(int32_t a, int32_t b); + int32_t exp(int32_t a); + int32_t log(int32_t a, int32_t& e); + int32_t inverse(int32_t a, int32_t& e); + int32_t multiply(int32_t a, int32_t b); + int32_t getSize(); + static CBC_PDF417ECModulusGF* PDF417_GF; + + private: + CFX_Int32Array m_expTable; + CFX_Int32Array m_logTable; + CBC_PDF417ECModulusPoly* m_zero; + CBC_PDF417ECModulusPoly* m_one; + int32_t m_modulus; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp new file mode 100644 index 0000000000..d0bbe5ab0a --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp @@ -0,0 +1,332 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/utils.h" + +CBC_PDF417ECModulusPoly::CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, + CFX_Int32Array& coefficients, + int32_t& e) { + if (coefficients.GetSize() == 0) { + e = BCExceptionIllegalArgument; + } + m_field = field; + int32_t coefficientsLength = coefficients.GetSize(); + if (coefficientsLength > 1 && coefficients[0] == 0) { + int32_t firstNonZero = 1; + while (firstNonZero < coefficientsLength && + coefficients[firstNonZero] == 0) { + firstNonZero++; + } + if (firstNonZero == coefficientsLength) { + m_coefficients = field->getZero()->m_coefficients; + } else { + m_coefficients.SetSize(coefficientsLength - firstNonZero); + int32_t l = 0; + for (int32_t i = firstNonZero; + i < firstNonZero + m_coefficients.GetSize(); i++) { + m_coefficients.SetAt(l, coefficients.GetAt(i)); + l++; + } + } + } else { + m_coefficients.Copy(coefficients); + } +} +CBC_PDF417ECModulusPoly::~CBC_PDF417ECModulusPoly() {} +CFX_Int32Array& CBC_PDF417ECModulusPoly::getCoefficients() { + return m_coefficients; +} +CBC_PDF417ECModulusGF* CBC_PDF417ECModulusPoly::getField() { + return m_field; +} +int32_t CBC_PDF417ECModulusPoly::getDegree() { + return m_coefficients.GetSize() - 1; +} +FX_BOOL CBC_PDF417ECModulusPoly::isZero() { + return m_coefficients[0] == 0; +} +int32_t CBC_PDF417ECModulusPoly::getCoefficient(int32_t degree) { + return m_coefficients[m_coefficients.GetSize() - 1 - degree]; +} +int32_t CBC_PDF417ECModulusPoly::evaluateAt(int32_t a) { + if (a == 0) { + return getCoefficient(0); + } + int32_t size = m_coefficients.GetSize(); + if (a == 1) { + int32_t result = 0; + for (int32_t l = 0; l < m_coefficients.GetSize(); l++) { + int32_t coefficient = m_coefficients.GetAt(l); + result = m_field->add(result, coefficient); + } + return result; + } + int32_t result = m_coefficients[0]; + for (int32_t i = 1; i < size; i++) { + result = m_field->add(m_field->multiply(a, result), m_coefficients[i]); + } + return result; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::add( + CBC_PDF417ECModulusPoly* other, + int32_t& e) { + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (isZero()) { + modulusPoly = new CBC_PDF417ECModulusPoly(other->getField(), + other->getCoefficients(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + if (other->isZero()) { + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + CFX_Int32Array smallerCoefficients; + smallerCoefficients.Copy(m_coefficients); + CFX_Int32Array largerCoefficients; + largerCoefficients.Copy(other->m_coefficients); + if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { + CFX_Int32Array temp; + temp.Copy(smallerCoefficients); + smallerCoefficients.Copy(largerCoefficients); + largerCoefficients.Copy(temp); + } + CFX_Int32Array sumDiff; + sumDiff.SetSize(largerCoefficients.GetSize()); + int32_t lengthDiff = + largerCoefficients.GetSize() - smallerCoefficients.GetSize(); + for (int32_t l = 0; l < lengthDiff; l++) { + sumDiff.SetAt(l, largerCoefficients.GetAt(l)); + } + for (int32_t i = lengthDiff; i < largerCoefficients.GetSize(); i++) { + sumDiff[i] = m_field->add(smallerCoefficients[i - lengthDiff], + largerCoefficients[i]); + } + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, sumDiff, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::subtract( + CBC_PDF417ECModulusPoly* other, + int32_t& e) { + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (other->isZero()) { + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + CBC_PDF417ECModulusPoly* poly = other->negative(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + modulusPoly = add(poly, e); + delete poly; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply( + CBC_PDF417ECModulusPoly* other, + int32_t& e) { + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (isZero() || other->isZero()) { + modulusPoly = + new CBC_PDF417ECModulusPoly(m_field->getZero()->getField(), + m_field->getZero()->getCoefficients(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + CFX_Int32Array aCoefficients; + aCoefficients.Copy(m_coefficients); + int32_t aLength = aCoefficients.GetSize(); + CFX_Int32Array bCoefficients; + bCoefficients.Copy(other->m_coefficients); + int32_t bLength = bCoefficients.GetSize(); + CFX_Int32Array product; + product.SetSize(aLength + bLength - 1); + for (int32_t i = 0; i < aLength; i++) { + int32_t aCoeff = aCoefficients[i]; + for (int32_t j = 0; j < bLength; j++) { + product[i + j] = m_field->add( + product[i + j], m_field->multiply(aCoeff, bCoefficients[j])); + } + } + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::negative(int32_t& e) { + int32_t size = m_coefficients.GetSize(); + CFX_Int32Array negativeCoefficients; + negativeCoefficients.SetSize(size); + for (int32_t i = 0; i < size; i++) { + negativeCoefficients[i] = m_field->subtract(0, m_coefficients[i]); + } + CBC_PDF417ECModulusPoly* modulusPoly = + new CBC_PDF417ECModulusPoly(m_field, negativeCoefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(int32_t scalar, + int32_t& e) { + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (scalar == 0) { + modulusPoly = + new CBC_PDF417ECModulusPoly(m_field->getZero()->getField(), + m_field->getZero()->getCoefficients(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + if (scalar == 1) { + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + int32_t size = m_coefficients.GetSize(); + CFX_Int32Array product; + product.SetSize(size); + for (int32_t i = 0; i < size; i++) { + product[i] = m_field->multiply(m_coefficients[i], scalar); + } + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); + 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; + } + CBC_PDF417ECModulusPoly* modulusPoly = NULL; + if (coefficient == 0) { + modulusPoly = new CBC_PDF417ECModulusPoly( + m_field->getZero()->m_field, m_field->getZero()->m_coefficients, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; + } + int32_t size = m_coefficients.GetSize(); + CFX_Int32Array product; + product.SetSize(size + degree); + for (int32_t i = 0; i < size; i++) { + product[i] = m_field->multiply(m_coefficients[i], coefficient); + } + modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return modulusPoly; +} +CFX_PtrArray* 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; + } + int32_t denominatorLeadingTerm = other->getCoefficient(other->getDegree()); + int32_t inverseDenominatorLeadingTerm = + m_field->inverse(denominatorLeadingTerm, e); + if (e != BCExceptionNO) { + delete quotient; + delete remainder; + return NULL; + } + 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; + } + } + CFX_PtrArray* modulusPoly = new CFX_PtrArray; + modulusPoly->Add(quotient); + modulusPoly->Add(remainder); + return modulusPoly; +} +CFX_ByteString CBC_PDF417ECModulusPoly::toString() { + CFX_ByteString result; + for (int32_t degree = getDegree(); degree >= 0; degree--) { + int32_t coefficient = getCoefficient(degree); + if (coefficient != 0) { + if (coefficient < 0) { + result += " - "; + coefficient = -coefficient; + } else { + if (result.GetLength() > 0) { + result += " + "; + } + } + if (degree == 0 || coefficient != 1) { + result += coefficient; + } + if (degree != 0) { + if (degree == 1) { + result += 'x'; + } else { + result += "x^"; + result += degree; + } + } + } + } + return result; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h new file mode 100644 index 0000000000..2eff3ef1ce --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h @@ -0,0 +1,39 @@ +// 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_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ + +class CBC_PDF417ECModulusGF; +class CBC_PDF417ECModulusPoly { + public: + CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, + CFX_Int32Array& coefficients, + int32_t& e); + virtual ~CBC_PDF417ECModulusPoly(); + CFX_Int32Array& getCoefficients(); + CBC_PDF417ECModulusGF* getField(); + int32_t getDegree(); + FX_BOOL isZero(); + int32_t getCoefficient(int32_t degree); + int32_t evaluateAt(int32_t a); + CBC_PDF417ECModulusPoly* add(CBC_PDF417ECModulusPoly* other, int32_t& e); + CBC_PDF417ECModulusPoly* subtract(CBC_PDF417ECModulusPoly* other, int32_t& e); + CBC_PDF417ECModulusPoly* multiply(CBC_PDF417ECModulusPoly* other, int32_t& e); + CBC_PDF417ECModulusPoly* negative(int32_t& e); + CBC_PDF417ECModulusPoly* multiply(int32_t scalar, int32_t& e); + CBC_PDF417ECModulusPoly* multiplyByMonomial(int32_t degree, + int32_t coefficient, + int32_t& e); + CFX_PtrArray* divide(CBC_PDF417ECModulusPoly* other, int32_t& e); + CFX_ByteString toString(); + + private: + CBC_PDF417ECModulusGF* m_field; + CFX_Int32Array m_coefficients; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp new file mode 100644 index 0000000000..0d4f2ffdb3 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp @@ -0,0 +1,165 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" +#include "xfa/fxbarcode/utils.h" + +int32_t CBC_PDF417ErrorCorrection::EC_COEFFICIENTS[][2500] = { + {27, 917}, + {522, 568, 723, 809}, + {237, 308, 436, 284, 646, 653, 428, 379}, + {274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, + 65}, + {361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, + 517, 273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, + 63, 410}, + {539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, + 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, + 283, 184, 440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651, + 201, 488, 502, 648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, + 623, 264, 543}, + {521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, + 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, + 490, 704, 516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686, + 606, 860, 569, 193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, + 712, 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507, + 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380, 602, 754, 336, + 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845, + 454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, + 834, 315, 550, 86, 801, 4, 108, 539}, + {524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, + 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, + 828, 757, 710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801, + 700, 799, 137, 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, + 284, 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684, + 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399, 908, 103, 511, + 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730, 433, + 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, 580, + 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263, 318, 374, + 601, 192, 605, 142, 673, 687, 234, 722, 384, 177, 752, 607, 640, 455, 193, + 689, 707, 805, 641, 48, 60, 732, 621, 895, 544, 261, 852, 655, 309, 697, + 755, 756, 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32, 144, + 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914, 342, 126, 32, 681, + 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383, 228, 749, 760, + 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, + 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, 251, 688, 95, + 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10}, + {352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, + 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, + 352, 781, 846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, + 268, 794, 534, 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, + 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761, + 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20, + 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729, 567, + 744, 390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384, + 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151, 429, + 531, 207, 676, 710, 89, 168, 304, 402, 40, 708, 575, 162, 864, 229, 65, + 861, 841, 512, 164, 477, 221, 92, 358, 785, 288, 357, 850, 836, 827, 736, + 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248, 361, + 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902, 452, 167, + 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124, 298, 332, + 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283, 711, 472, + 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, 383, + 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729, 624, + 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772, + 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, + 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247, + 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519, + 644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, + 56, 252, 341, 242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, + 756, 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590, + 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, 782, 210, 815, 905, 303, + 843, 922, 281, 73, 469, 791, 660, 162, 498, 308, 155, 422, 907, 817, 187, + 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667, + 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, 5, 39, 923, + 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534, 105, 667, 488, 640, + 672, 576, 540, 316, 486, 721, 610, 46, 656, 447, 171, 616, 464, 190, 531, + 297, 321, 762, 752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596, + 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407, 164, 332, 899, + 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647, 63, 310, 863, + 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263}}; + +CBC_PDF417ErrorCorrection::CBC_PDF417ErrorCorrection() {} +CBC_PDF417ErrorCorrection::~CBC_PDF417ErrorCorrection() {} +int32_t CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( + int32_t errorCorrectionLevel, + int32_t& e) { + if (errorCorrectionLevel < 0 || errorCorrectionLevel > 8) { + e = BCExceptionErrorCorrectionLevelMustBeBetween0And8; + return -1; + } + return 1 << (errorCorrectionLevel + 1); +} +int32_t CBC_PDF417ErrorCorrection::getRecommendedMinimumErrorCorrectionLevel( + int32_t n, + int32_t& e) { + if (n <= 0) { + e = BCExceptionIllegalArgumentnMustBeAbove0; + return -1; + } + if (n <= 40) { + return 2; + } + if (n <= 160) { + return 3; + } + if (n <= 320) { + return 4; + } + if (n <= 863) { + return 5; + } + e = BCExceptionNoRecommendationPossible; + return -1; +} +CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection( + CFX_WideString dataCodewords, + int32_t errorCorrectionLevel, + int32_t& e) { + int32_t k = getErrorCorrectionCodewordCount(errorCorrectionLevel, e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); + FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k); + FXSYS_memset(ech, 0, k * sizeof(FX_WCHAR)); + int32_t sld = dataCodewords.GetLength(); + for (int32_t i = 0; i < sld; i++) { + int32_t t1 = (dataCodewords.GetAt(i) + ech[k - 1]) % 929; + int32_t t2; + int32_t t3; + for (int32_t j = k - 1; j >= 1; j--) { + t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][j]) % 929; + t3 = 929 - t2; + ech[j] = (FX_WCHAR)((ech[j - 1] + t3) % 929); + } + t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][0]) % 929; + t3 = 929 - t2; + ech[0] = (FX_WCHAR)(t3 % 929); + } + CFX_WideString sb; + for (int32_t j = k - 1; j >= 0; j--) { + if (ech[j] != 0) { + ech[j] = (FX_WCHAR)(929 - ech[j]); + } + sb += (FX_WCHAR)ech[j]; + } + FX_Free(ech); + return sb; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h new file mode 100644 index 0000000000..9a2a0c63ef --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h @@ -0,0 +1,30 @@ +// 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_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ + +#include <stdint.h> + +#include "core/include/fxcrt/fx_string.h" + +class CBC_PDF417ErrorCorrection { + public: + CBC_PDF417ErrorCorrection(); + virtual ~CBC_PDF417ErrorCorrection(); + static int32_t getErrorCorrectionCodewordCount(int32_t errorCorrectionLevel, + int32_t& e); + static int32_t getRecommendedMinimumErrorCorrectionLevel(int32_t n, + int32_t& e); + static CFX_WideString generateErrorCorrection(CFX_WideString dataCodewords, + int32_t errorCorrectionLevel, + int32_t& e); + + private: + static int32_t EC_COEFFICIENTS[][2500]; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp new file mode 100644 index 0000000000..27c6651542 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp @@ -0,0 +1,427 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" + +#include "third_party/bigint/BigIntegerLibrary.hh" +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" +#include "xfa/fxbarcode/utils.h" + +#define SUBMODE_ALPHA 0 +#define SUBMODE_LOWER 1 +#define SUBMODE_MIXED 2 + +int32_t CBC_PDF417HighLevelEncoder::TEXT_COMPACTION = 0; +int32_t CBC_PDF417HighLevelEncoder::BYTE_COMPACTION = 1; +int32_t CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION = 2; +int32_t CBC_PDF417HighLevelEncoder::SUBMODE_PUNCTUATION = 3; +int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_TEXT = 900; +int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE_PADDED = 901; +int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_NUMERIC = 902; +int32_t CBC_PDF417HighLevelEncoder::SHIFT_TO_BYTE = 913; +int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE = 924; +uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = { + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58, + 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0}; +uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = { + 59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58, + 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0}; +int32_t CBC_PDF417HighLevelEncoder::MIXED[128] = {0}; +int32_t CBC_PDF417HighLevelEncoder::PUNCTUATION[128] = {0}; + +void CBC_PDF417HighLevelEncoder::Initialize() { + Inverse(); +} +void CBC_PDF417HighLevelEncoder::Finalize() {} +CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel( + CFX_WideString wideMsg, + Compaction compaction, + int32_t& e) { + CFX_ByteString bytes; + CBC_UtilCodingConvert::UnicodeToUTF8(wideMsg, bytes); + CFX_WideString msg; + int32_t len = bytes.GetLength(); + for (int32_t i = 0; i < len; i++) { + FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff); + if (ch == '?' && bytes.GetAt(i) != '?') { + e = BCExceptionCharactersOutsideISO88591Encoding; + return (FX_WCHAR*)""; + } + msg += ch; + } + CFX_ByteArray byteArr; + for (int32_t k = 0; k < bytes.GetLength(); k++) { + byteArr.Add(bytes.GetAt(k)); + } + CFX_WideString sb; + len = msg.GetLength(); + int32_t p = 0; + int32_t textSubMode = SUBMODE_ALPHA; + if (compaction == TEXT) { + encodeText(msg, p, len, sb, textSubMode); + } else if (compaction == BYTES) { + encodeBinary(&byteArr, p, byteArr.GetSize(), BYTE_COMPACTION, sb); + } else if (compaction == NUMERIC) { + sb += (FX_WCHAR)LATCH_TO_NUMERIC; + encodeNumeric(msg, p, len, sb); + } else { + int32_t encodingMode = LATCH_TO_TEXT; + while (p < len) { + int32_t n = determineConsecutiveDigitCount(msg, p); + if (n >= 13) { + sb += (FX_WCHAR)LATCH_TO_NUMERIC; + encodingMode = NUMERIC_COMPACTION; + textSubMode = SUBMODE_ALPHA; + encodeNumeric(msg, p, n, sb); + p += n; + } else { + int32_t t = determineConsecutiveTextCount(msg, p); + if (t >= 5 || n == len) { + if (encodingMode != TEXT_COMPACTION) { + sb += (FX_WCHAR)LATCH_TO_TEXT; + encodingMode = TEXT_COMPACTION; + textSubMode = SUBMODE_ALPHA; + } + textSubMode = encodeText(msg, p, t, sb, textSubMode); + p += t; + } else { + int32_t b = determineConsecutiveBinaryCount(msg, &byteArr, p, e); + BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); + if (b == 0) { + b = 1; + } + if (b == 1 && encodingMode == TEXT_COMPACTION) { + encodeBinary(&byteArr, p, 1, TEXT_COMPACTION, sb); + } else { + encodeBinary(&byteArr, p, b, encodingMode, sb); + encodingMode = BYTE_COMPACTION; + textSubMode = SUBMODE_ALPHA; + } + p += b; + } + } + } + } + return sb; +} + +void CBC_PDF417HighLevelEncoder::Inverse() { + for (size_t l = 0; l < FX_ArraySize(MIXED); ++l) + MIXED[l] = -1; + + for (uint8_t i = 0; i < FX_ArraySize(TEXT_MIXED_RAW); ++i) { + uint8_t b = TEXT_MIXED_RAW[i]; + if (b != 0) + MIXED[b] = i; + } + + for (size_t l = 0; l < FX_ArraySize(PUNCTUATION); ++l) + PUNCTUATION[l] = -1; + + for (uint8_t i = 0; i < FX_ArraySize(TEXT_PUNCTUATION_RAW); ++i) { + uint8_t b = TEXT_PUNCTUATION_RAW[i]; + if (b != 0) + PUNCTUATION[b] = i; + } +} + +int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, + int32_t startpos, + int32_t count, + CFX_WideString& sb, + int32_t initialSubmode) { + CFX_WideString tmp; + int32_t submode = initialSubmode; + int32_t idx = 0; + while (TRUE) { + FX_WCHAR ch = msg.GetAt(startpos + idx); + switch (submode) { + case SUBMODE_ALPHA: + if (isAlphaUpper(ch)) { + if (ch == ' ') { + tmp += (FX_WCHAR)26; + } else { + tmp += (FX_WCHAR)(ch - 65); + } + } else { + if (isAlphaLower(ch)) { + submode = SUBMODE_LOWER; + tmp += (FX_WCHAR)27; + continue; + } else if (isMixed(ch)) { + submode = SUBMODE_MIXED; + tmp += (FX_WCHAR)28; + continue; + } else { + tmp += (FX_WCHAR)29; + tmp += PUNCTUATION[ch]; + break; + } + } + break; + case SUBMODE_LOWER: + if (isAlphaLower(ch)) { + if (ch == ' ') { + tmp += (FX_WCHAR)26; + } else { + tmp += (FX_WCHAR)(ch - 97); + } + } else { + if (isAlphaUpper(ch)) { + tmp += (FX_WCHAR)27; + tmp += (FX_WCHAR)(ch - 65); + break; + } else if (isMixed(ch)) { + submode = SUBMODE_MIXED; + tmp += (FX_WCHAR)28; + continue; + } else { + tmp += (FX_WCHAR)29; + tmp += PUNCTUATION[ch]; + break; + } + } + break; + case SUBMODE_MIXED: + if (isMixed(ch)) { + tmp += MIXED[ch]; + } else { + if (isAlphaUpper(ch)) { + submode = SUBMODE_ALPHA; + tmp += (FX_WCHAR)28; + continue; + } else if (isAlphaLower(ch)) { + submode = SUBMODE_LOWER; + tmp += (FX_WCHAR)27; + continue; + } else { + if (startpos + idx + 1 < count) { + FX_WCHAR next = msg.GetAt(startpos + idx + 1); + if (isPunctuation(next)) { + submode = SUBMODE_PUNCTUATION; + tmp += (FX_WCHAR)25; + continue; + } + } + tmp += (FX_WCHAR)29; + tmp += PUNCTUATION[ch]; + } + } + break; + default: + if (isPunctuation(ch)) { + tmp += PUNCTUATION[ch]; + } else { + submode = SUBMODE_ALPHA; + tmp += (FX_WCHAR)29; + continue; + } + } + idx++; + if (idx >= count) { + break; + } + } + FX_WCHAR h = 0; + int32_t len = tmp.GetLength(); + for (int32_t i = 0; i < len; i++) { + FX_BOOL odd = (i % 2) != 0; + if (odd) { + h = (FX_WCHAR)((h * 30) + tmp.GetAt(i)); + sb += h; + } else { + h = tmp.GetAt(i); + } + } + if ((len % 2) != 0) { + sb += (FX_WCHAR)((h * 30) + 29); + } + return submode; +} +void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ByteArray* bytes, + int32_t startpos, + int32_t count, + int32_t startmode, + CFX_WideString& sb) { + if (count == 1 && startmode == TEXT_COMPACTION) { + sb += (FX_WCHAR)SHIFT_TO_BYTE; + } + int32_t idx = startpos; + int32_t i = 0; + if (count >= 6) { + sb += (FX_WCHAR)LATCH_TO_BYTE; + FX_WCHAR chars[5]; + while ((startpos + count - idx) >= 6) { + int64_t t = 0; + for (i = 0; i < 6; i++) { + t <<= 8; + t += bytes->GetAt(idx + i) & 0xff; + } + for (i = 0; i < 5; i++) { + chars[i] = (FX_WCHAR)(t % 900); + t /= 900; + } + for (i = 4; i >= 0; i--) { + sb += (chars[i]); + } + idx += 6; + } + } + if (idx < startpos + count) { + sb += (FX_WCHAR)LATCH_TO_BYTE_PADDED; + } + for (i = idx; i < startpos + count; i++) { + int32_t ch = bytes->GetAt(i) & 0xff; + sb += (FX_WCHAR)ch; + } +} +void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg, + int32_t startpos, + int32_t count, + CFX_WideString& sb) { + int32_t idx = 0; + BigInteger num900 = 900; + while (idx < count) { + CFX_WideString tmp; + int32_t len = 44 < count - idx ? 44 : count - idx; + CFX_ByteString part = + ((FX_WCHAR)'1' + msg.Mid(startpos + idx, len)).UTF8Encode(); + BigInteger bigint = stringToBigInteger(part.c_str()); + do { + int32_t c = (bigint % num900).toInt(); + tmp += (FX_WCHAR)(c); + bigint = bigint / num900; + } while (!bigint.isZero()); + for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { + sb += tmp.GetAt(i); + } + idx += len; + } +} +FX_BOOL CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch) { + return ch >= '0' && ch <= '9'; +} +FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch) { + return ch == ' ' || (ch >= 'A' && ch <= 'Z'); +} +FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch) { + return ch == ' ' || (ch >= 'a' && ch <= 'z'); +} +FX_BOOL CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch) { + return MIXED[ch] != -1; +} +FX_BOOL CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch) { + return PUNCTUATION[ch] != -1; +} +FX_BOOL CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch) { + return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); +} +int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount( + CFX_WideString msg, + int32_t startpos) { + int32_t count = 0; + int32_t len = msg.GetLength(); + int32_t idx = startpos; + if (idx < len) { + FX_WCHAR ch = msg.GetAt(idx); + while (isDigit(ch) && idx < len) { + count++; + idx++; + if (idx < len) { + ch = msg.GetAt(idx); + } + } + } + return count; +} +int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount( + CFX_WideString msg, + int32_t startpos) { + int32_t len = msg.GetLength(); + int32_t idx = startpos; + while (idx < len) { + FX_WCHAR ch = msg.GetAt(idx); + int32_t numericCount = 0; + while (numericCount < 13 && isDigit(ch) && idx < len) { + numericCount++; + idx++; + if (idx < len) { + ch = msg.GetAt(idx); + } + } + if (numericCount >= 13) { + return idx - startpos - numericCount; + } + if (numericCount > 0) { + continue; + } + ch = msg.GetAt(idx); + if (!isText(ch)) { + break; + } + idx++; + } + return idx - startpos; +} +int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( + CFX_WideString msg, + CFX_ByteArray* bytes, + int32_t startpos, + int32_t& e) { + int32_t len = msg.GetLength(); + int32_t idx = startpos; + while (idx < len) { + FX_WCHAR ch = msg.GetAt(idx); + int32_t numericCount = 0; + while (numericCount < 13 && isDigit(ch)) { + numericCount++; + int32_t i = idx + numericCount; + if (i >= len) { + break; + } + ch = msg.GetAt(i); + } + if (numericCount >= 13) { + return idx - startpos; + } + int32_t textCount = 0; + while (textCount < 5 && isText(ch)) { + textCount++; + int32_t i = idx + textCount; + if (i >= len) { + break; + } + ch = msg.GetAt(i); + } + if (textCount >= 5) { + return idx - startpos; + } + ch = msg.GetAt(idx); + if (bytes->GetAt(idx) == 63 && ch != '?') { + e = BCExceptionNonEncodableCharacterDetected; + return -1; + } + idx++; + } + return idx - startpos; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h new file mode 100644 index 0000000000..0ba01265f9 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h @@ -0,0 +1,74 @@ +// 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_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" + +class CBC_PDF417HighLevelEncoder { + public: + static CFX_WideString encodeHighLevel(CFX_WideString msg, + Compaction compaction, + int32_t& e); + static void Inverse(); + static void Initialize(); + static void Finalize(); + + private: + static int32_t TEXT_COMPACTION; + static int32_t BYTE_COMPACTION; + static int32_t NUMERIC_COMPACTION; + static int32_t SUBMODE_PUNCTUATION; + static int32_t LATCH_TO_TEXT; + static int32_t LATCH_TO_BYTE_PADDED; + static int32_t LATCH_TO_NUMERIC; + static int32_t SHIFT_TO_BYTE; + static int32_t LATCH_TO_BYTE; + static uint8_t TEXT_MIXED_RAW[]; + static uint8_t TEXT_PUNCTUATION_RAW[]; + static int32_t MIXED[128]; + static int32_t PUNCTUATION[128]; + static int32_t encodeText(CFX_WideString msg, + int32_t startpos, + int32_t count, + CFX_WideString& sb, + int32_t initialSubmode); + static void encodeBinary(CFX_ByteArray* bytes, + int32_t startpos, + int32_t count, + int32_t startmode, + CFX_WideString& sb); + static void encodeNumeric(CFX_WideString msg, + int32_t startpos, + int32_t count, + CFX_WideString& sb); + static FX_BOOL isDigit(FX_WCHAR ch); + static FX_BOOL isAlphaUpper(FX_WCHAR ch); + static FX_BOOL isAlphaLower(FX_WCHAR ch); + static FX_BOOL isMixed(FX_WCHAR ch); + static FX_BOOL isPunctuation(FX_WCHAR ch); + static FX_BOOL isText(FX_WCHAR ch); + static int32_t determineConsecutiveDigitCount(CFX_WideString msg, + int32_t startpos); + static int32_t determineConsecutiveTextCount(CFX_WideString msg, + int32_t startpos); + static int32_t determineConsecutiveBinaryCount(CFX_WideString msg, + CFX_ByteArray* bytes, + int32_t startpos, + int32_t& e); + + friend class PDF417HighLevelEncoder_EncodeNumeric_Test; + friend class PDF417HighLevelEncoder_EncodeBinary_Test; + friend class PDF417HighLevelEncoder_EncodeText_Test; + friend class PDF417HighLevelEncoder_ConsecutiveDigitCount_Test; + friend class PDF417HighLevelEncoder_ConsecutiveTextCount_Test; + friend class PDF417HighLevelEncoder_ConsecutiveBinaryCount_Test; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp new file mode 100644 index 0000000000..8e1837071d --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp @@ -0,0 +1,231 @@ +// 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. + +#include "core/include/fxcrt/fx_basic.h" +#include "testing/fx_string_testhelpers.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" + +TEST(PDF417HighLevelEncoder, EncodeHighLevel) { + // TODO(tsepez): implement test cases. +} + +TEST(PDF417HighLevelEncoder, EncodeText) { + // TODO(tsepez): implement test cases. +} + +TEST(PDF417HighLevelEncoder, EncodeBinary) { + struct EncodeBinaryCase { + const char* input; + int offset; + int count; + int startmode; + const wchar_t* expected; + int expected_length; + } encode_binary_cases[] = { + // Empty string encodes as empty string. + {"", 0, 0, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, L"", 0}, + + // Fewer than 6 characters encodes as prefix without compaction. + {"xxxxx", 0, 5, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, + L"\x0385xxxxx", 6}, + + // 6 charcters triggerst text encoding compaction. + {"xxxxxx", 0, 6, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, + L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6}, + + // Same result if initially in numeric compaction mode. + {"xxxxxx", 0, 6, CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION, + L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6}, + }; + + CBC_PDF417HighLevelEncoder::Initialize(); + for (size_t i = 0; i < FX_ArraySize(encode_binary_cases); ++i) { + EncodeBinaryCase* ptr = &encode_binary_cases[i]; + CFX_ByteArray input_array; + size_t input_length = strlen(ptr->input); + input_array.SetSize(input_length); + for (size_t j = 0; j < input_length; ++j) { + input_array.SetAt(j, ptr->input[j]); + } + CFX_WideString expected(ptr->expected, ptr->expected_length); + CFX_WideString result; + CBC_PDF417HighLevelEncoder::encodeBinary( + &input_array, ptr->offset, ptr->count, ptr->startmode, result); + EXPECT_EQ(expected, result) << " for case number " << i; + } + CBC_PDF417HighLevelEncoder::Finalize(); +} + +TEST(PDF417HighLevelEncoder, EncodeNumeric) { + struct EncodeNumericCase { + const wchar_t* input; + int offset; + int count; + const wchar_t* expected; + int expected_length; + } encode_numeric_cases[] = { + // Empty string encodes as empty string. + {L"", 0, 0, L"", 0}, + + // Single 0 should encode as 10 base-900 == a. + {L"0", 0, 1, L"\x000a", 1}, + + // 800 should encode as 1800 base-900 == 2,0. + {L"800", 0, 3, L"\x0002\x0000", 2}, + + // Test longer strings and sub-strings. + {L"123456", 0, 6, L"\x0001\x015c\x0100", 3}, + {L"123456", 0, 5, L"\x007c\x02e9", 2}, + {L"123456", 1, 5, L"\x0089\x009c", 2}, + {L"123456", 2, 2, L"\x0086", 1}, + + // Up to 44 characters encodes as 15 base-900 words. + {L"00000000000000000000000000000000000000000000", 0, 44, + L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" + L"\x0090\x020b\x019b\x0064", + 15}, + + // 45 characters should encode as same 15 words followed by one additional + // word. + {L"000000000000000000000000000000000000000000000", 0, 45, + L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" + L"\x0090\x020b\x019b\x0064\x000a", + 16}, + + // 44 characters followed by 800 should encode as 15 words followed by + // 1800 base-900 == 2,0. + {L"00000000000000000000000000000000000000000000800", 0, 47, + L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" + L"\x0090\x020b\x019b\x0064\x0002\x0000", + 17}, + + // Even longer input. + {L"10000000000000000000000000000000000000000000000000", 0, 50, + L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108" + L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064", + 18}, + }; + + CBC_PDF417HighLevelEncoder::Initialize(); + for (size_t i = 0; i < FX_ArraySize(encode_numeric_cases); ++i) { + EncodeNumericCase* ptr = &encode_numeric_cases[i]; + CFX_WideString input(ptr->input); + CFX_WideString expected(ptr->expected, ptr->expected_length); + CFX_WideString result; + CBC_PDF417HighLevelEncoder::encodeNumeric(input, ptr->offset, ptr->count, + result); + EXPECT_EQ(expected, result) << " for case number " << i; + } + CBC_PDF417HighLevelEncoder::Finalize(); +} + +TEST(PDF417HighLevelEncoder, ConsecutiveDigitCount) { + struct ConsecutiveDigitCase { + const wchar_t* input; + int offset; + int expected_count; + } consecutive_digit_cases[] = { + // Empty string contains 0 consecuitve digits. + {L"", 0, 0}, + + // Single non-digit character contains 0 consecutive digits. + {L"X", 0, 0}, + + // Leading non-digit followed by digits contains 0 consecutive. + {L"X123", 0, 0}, + + // Single digit contains 1 consecutive digit. + {L"1", 0, 1}, + + // Single digit followe by non-digit contains 1 consecutive digit. + {L"1Z", 0, 1}, + + // Test longer strings. + {L"123FOO45678", 0, 3}, + + // Test subtring starting in digits field. + {L"123FOO45678", 3, 0}, + + // Test subtring starting in non-digits field. + {L"123FOO45678", 3, 0}, + + // Test substring starting in digits field following non-digit field. + {L"123FOO45678", 6, 5}, + }; + + CBC_PDF417HighLevelEncoder::Initialize(); + for (size_t i = 0; i < FX_ArraySize(consecutive_digit_cases); ++i) { + ConsecutiveDigitCase* ptr = &consecutive_digit_cases[i]; + CFX_WideString input(ptr->input); + int actual_count = + CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(input, + ptr->offset); + EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; + } + CBC_PDF417HighLevelEncoder::Finalize(); +} + +TEST(PDF417HighLevelEncoder, ConsecutiveTextCount) { + struct ConsecutiveTextCase { + const wchar_t* input; + int offset; + int expected_count; + } consecutive_text_cases[] = { + // Empty string contains 0 consecutive text characters. + {L"", 0, 0}, + + // Single text character is 1 consecutive text characters. + {L"X", 0, 1}, + + // Trailing numbers count as text characters. + {L"X123", 0, 4}, + + // Leading numbers count as text characters. + {L"123X", 0, 4}, + + // Embedded lo-value binary characters terminate text runs. + {L"ABC\x0001XXXX", 0, 3}, + + // Embedded hi-value binary characters terminate text runs. + {L"ABC\x0100XXXX", 0, 3}, + + // Text run still found after indexing past lo-value character. + {L"ABC\x0001XXXX", 4, 4}, + + // Text run still found after indexing past hi-value character. + {L"ABC\x0100XXXX", 4, 4}, + + // Leading hi-value character results in 0 consecutive characters. + {L"\x0100XXX", 0, 0}, + + // Up to 12 numbers count as text. + {L"123456789012", 0, 12}, + + // 13 or more numbers are compresssed using numeric compression, not text. + {L"1234567890123", 0, 0}, + + // Leading Text character doesn't affect the 12 character case. + {L"X123456789012", 0, 13}, + + // Leading Text character doesn't affect the 13 character case. + {L"X1234567890123", 0, 1}, + + // Jumping between numbers and letters works properly. + {L"XXX121XXX12345678901234", 0, 9}, + }; + + CBC_PDF417HighLevelEncoder::Initialize(); + for (size_t i = 0; i < FX_ArraySize(consecutive_text_cases); ++i) { + ConsecutiveTextCase* ptr = &consecutive_text_cases[i]; + CFX_WideString input(ptr->input); + int actual_count = + CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(input, + ptr->offset); + EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; + } + CBC_PDF417HighLevelEncoder::Finalize(); +} + +TEST(PDF417HighLevelEncoder, ConsecutiveBinaryCount) {} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp new file mode 100644 index 0000000000..4d953e006a --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp @@ -0,0 +1,149 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <limits> + +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_DecoderResult.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Detector.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Reader.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" +#include "xfa/fxbarcode/utils.h" + +CBC_PDF417Reader::CBC_PDF417Reader() {} +CBC_PDF417Reader::~CBC_PDF417Reader() {} + +CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, int32_t& e) { + return Decode(image, 0, e); +} +CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, + FX_BOOL multiple, + int32_t hints, + int32_t& e) { + CFX_ByteString results; + 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; + e = BCExceptiontNotFoundInstance; + return ""; + } + results += ResultTemp->GetText(); + delete ResultTemp; + } + delete detectorResult; + return results; +} +CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + CFX_ByteString bs = Decode(image, FALSE, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return bs; +} +int32_t CBC_PDF417Reader::getMaxWidth(CBC_ResultPoint* p1, + CBC_ResultPoint* p2) { + if (p1 == NULL || p2 == NULL) { + return 0; + } + return (int32_t)FXSYS_fabs(p1->GetX() - p2->GetX()); +} +int32_t CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1, + CBC_ResultPoint* p2) { + if (!p1 || !p2) + 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::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; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Reader.h b/xfa/fxbarcode/pdf417/BC_PDF417Reader.h new file mode 100644 index 0000000000..2a5c39bae2 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Reader.h @@ -0,0 +1,31 @@ +// 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_FXBARCODE_PDF417_BC_PDF417READER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417READER_H_ + +class CBC_BinaryBitmap; +class CBC_ResultPoint; +class CBC_PDF417Reader; +class CBC_PDF417Reader : public CBC_Reader { + public: + CBC_PDF417Reader(); + virtual ~CBC_PDF417Reader(); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, + FX_BOOL multiple, + int32_t hints, + int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); + + 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); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417READER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp new file mode 100644 index 0000000000..083d63e2d2 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp @@ -0,0 +1,50 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" + +CBC_PDF417ResultMetadata::CBC_PDF417ResultMetadata() {} +CBC_PDF417ResultMetadata::~CBC_PDF417ResultMetadata() {} +int32_t CBC_PDF417ResultMetadata::getSegmentIndex() { + return m_segmentIndex; +} +void CBC_PDF417ResultMetadata::setSegmentIndex(int32_t segmentIndex) { + m_segmentIndex = segmentIndex; +} +CFX_ByteString CBC_PDF417ResultMetadata::getFileId() { + return m_fileId; +} +void CBC_PDF417ResultMetadata::setFileId(CFX_ByteString fileId) { + m_fileId = fileId; +} +CFX_Int32Array& CBC_PDF417ResultMetadata::getOptionalData() { + return m_optionalData; +} +void CBC_PDF417ResultMetadata::setOptionalData(CFX_Int32Array& optionalData) { + m_optionalData.Copy(optionalData); +} +FX_BOOL CBC_PDF417ResultMetadata::isLastSegment() { + return m_lastSegment; +} +void CBC_PDF417ResultMetadata::setLastSegment(FX_BOOL lastSegment) { + m_lastSegment = lastSegment; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h b/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h new file mode 100644 index 0000000000..8e25bdbf43 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ResultMetadata.h @@ -0,0 +1,32 @@ +// 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_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_PDF417ResultMetadata { + public: + CBC_PDF417ResultMetadata(); + virtual ~CBC_PDF417ResultMetadata(); + int32_t getSegmentIndex(); + void setSegmentIndex(int32_t segmentIndex); + CFX_ByteString getFileId(); + void setFileId(CFX_ByteString fileId); + CFX_Int32Array& getOptionalData(); + void setOptionalData(CFX_Int32Array& optionalData); + FX_BOOL isLastSegment(); + void setLastSegment(FX_BOOL lastSegment); + + private: + int32_t m_segmentIndex; + CFX_ByteString m_fileId; + CFX_Int32Array m_optionalData; + FX_BOOL m_lastSegment; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp new file mode 100644 index 0000000000..6ae68d72f3 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp @@ -0,0 +1,752 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_DecoderResult.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Codeword.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" +#include "xfa/fxbarcode/utils.h" + +int32_t CBC_PDF417ScanningDecoder::CODEWORD_SKEW_SIZE = 2; +int32_t CBC_PDF417ScanningDecoder::MAX_ERRORS = 3; +int32_t CBC_PDF417ScanningDecoder::MAX_EC_CODEWORDS = 512; +CBC_PDF417ECErrorCorrection* CBC_PDF417ScanningDecoder::errorCorrection = NULL; + +CBC_PDF417ScanningDecoder::CBC_PDF417ScanningDecoder() {} +CBC_PDF417ScanningDecoder::~CBC_PDF417ScanningDecoder() {} +void CBC_PDF417ScanningDecoder::Initialize() { + errorCorrection = new CBC_PDF417ECErrorCorrection; +} +void CBC_PDF417ScanningDecoder::Finalize() { + delete errorCorrection; +} +CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode( + CBC_CommonBitMatrix* image, + CBC_ResultPoint* imageTopLeft, + CBC_ResultPoint* imageBottomLeft, + CBC_ResultPoint* imageTopRight, + CBC_ResultPoint* imageBottomRight, + int32_t minCodewordWidth, + int32_t maxCodewordWidth, + int32_t& e) { + CBC_BoundingBox* boundingBox = new CBC_BoundingBox( + image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn = NULL; + CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn = NULL; + CBC_DetectionResult* detectionResult = NULL; + for (int32_t i = 0; i < 2; i++) { + if (imageTopLeft) { + leftRowIndicatorColumn = + getRowIndicatorColumn(image, boundingBox, *imageTopLeft, TRUE, + minCodewordWidth, maxCodewordWidth); + } + if (imageTopRight) { + rightRowIndicatorColumn = + getRowIndicatorColumn(image, boundingBox, *imageTopRight, FALSE, + minCodewordWidth, maxCodewordWidth); + } + detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn, e); + if (e != BCExceptionNO) { + e = BCExceptiontNotFoundInstance; + delete leftRowIndicatorColumn; + delete rightRowIndicatorColumn; + delete boundingBox; + return NULL; + } + if (i == 0 && (detectionResult->getBoundingBox()->getMinY() < + boundingBox->getMinY() || + detectionResult->getBoundingBox()->getMaxY() > + boundingBox->getMaxY())) { + delete boundingBox; + boundingBox = detectionResult->getBoundingBox(); + } else { + detectionResult->setBoundingBox(boundingBox); + break; + } + } + int32_t maxBarcodeColumn = detectionResult->getBarcodeColumnCount() + 1; + detectionResult->setDetectionResultColumn(0, leftRowIndicatorColumn); + detectionResult->setDetectionResultColumn(maxBarcodeColumn, + rightRowIndicatorColumn); + FX_BOOL leftToRight = leftRowIndicatorColumn != NULL; + for (int32_t barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn; + barcodeColumnCount++) { + int32_t barcodeColumn = leftToRight ? barcodeColumnCount + : maxBarcodeColumn - barcodeColumnCount; + if (detectionResult->getDetectionResultColumn(barcodeColumn)) { + continue; + } + CBC_DetectionResultColumn* detectionResultColumn = NULL; + if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) { + detectionResultColumn = new CBC_DetectionResultRowIndicatorColumn( + boundingBox, barcodeColumn == 0); + } else { + detectionResultColumn = new CBC_DetectionResultColumn(boundingBox); + } + detectionResult->setDetectionResultColumn(barcodeColumn, + detectionResultColumn); + int32_t startColumn = -1; + int32_t previousStartColumn = startColumn; + for (int32_t imageRow = boundingBox->getMinY(); + imageRow <= boundingBox->getMaxY(); imageRow++) { + startColumn = + getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight); + if (startColumn < 0 || startColumn > boundingBox->getMaxX()) { + if (previousStartColumn == -1) { + continue; + } + startColumn = previousStartColumn; + } + CBC_Codeword* codeword = detectCodeword( + image, boundingBox->getMinX(), boundingBox->getMaxX(), leftToRight, + startColumn, imageRow, minCodewordWidth, maxCodewordWidth); + if (codeword) { + detectionResultColumn->setCodeword(imageRow, codeword); + previousStartColumn = startColumn; + minCodewordWidth = minCodewordWidth < codeword->getWidth() + ? minCodewordWidth + : codeword->getWidth(); + maxCodewordWidth = maxCodewordWidth > codeword->getWidth() + ? maxCodewordWidth + : codeword->getWidth(); + } + } + } + CBC_CommonDecoderResult* decoderresult = + createDecoderResult(detectionResult, e); + if (e != BCExceptionNO) { + delete detectionResult; + return NULL; + } + return decoderresult; +} +CFX_ByteString CBC_PDF417ScanningDecoder::toString( + CFX_PtrArray* 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); + if (barcodeValue->getValue()->GetSize() == 0) { + result += ""; + } else { + result += barcodeValue->getValue()->GetAt(0); + result += + barcodeValue->getConfidence(barcodeValue->getValue()->GetAt(0)); + } + } + } + return result; +} +CBC_DetectionResult* CBC_PDF417ScanningDecoder::merge( + CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, + CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn, + int32_t& e) { + if (leftRowIndicatorColumn == NULL && rightRowIndicatorColumn == NULL) { + e = BCExceptionIllegalArgument; + return NULL; + } + CBC_BarcodeMetadata* barcodeMetadata = + getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn); + if (barcodeMetadata == NULL) { + e = BCExceptionCannotMetadata; + return NULL; + } + CBC_BoundingBox* leftboundingBox = + adjustBoundingBox(leftRowIndicatorColumn, e); + if (e != BCExceptionNO) { + delete barcodeMetadata; + return NULL; + } + CBC_BoundingBox* rightboundingBox = + adjustBoundingBox(rightRowIndicatorColumn, e); + if (e != BCExceptionNO) { + delete barcodeMetadata; + return NULL; + } + CBC_BoundingBox* boundingBox = + CBC_BoundingBox::merge(leftboundingBox, rightboundingBox, e); + if (e != BCExceptionNO) { + delete barcodeMetadata; + return NULL; + } + CBC_DetectionResult* detectionresult = + new CBC_DetectionResult(barcodeMetadata, boundingBox); + return detectionresult; +} +CBC_BoundingBox* CBC_PDF417ScanningDecoder::adjustBoundingBox( + CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn, + int32_t& e) { + if (rowIndicatorColumn == NULL) { + return NULL; + } + CFX_Int32Array* rowHeights = rowIndicatorColumn->getRowHeights(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t maxRowHeight = getMax(*rowHeights); + int32_t missingStartRows = 0; + for (int32_t i = 0; i < rowHeights->GetSize(); i++) { + int32_t rowHeight = rowHeights->GetAt(i); + missingStartRows += maxRowHeight - rowHeight; + if (rowHeight > 0) { + break; + } + } + CFX_PtrArray* codewords = rowIndicatorColumn->getCodewords(); + for (int32_t row = 0; missingStartRows > 0 && codewords->GetAt(row) == NULL; + row++) { + missingStartRows--; + } + int32_t missingEndRows = 0; + for (int32_t row1 = rowHeights->GetSize() - 1; row1 >= 0; row1--) { + missingEndRows += maxRowHeight - rowHeights->GetAt(row1); + if (rowHeights->GetAt(row1) > 0) { + break; + } + } + for (int32_t row2 = codewords->GetSize() - 1; + missingEndRows > 0 && codewords->GetAt(row2) == NULL; row2--) { + missingEndRows--; + } + CBC_BoundingBox* boundingBox = + rowIndicatorColumn->getBoundingBox()->addMissingRows( + missingStartRows, missingEndRows, rowIndicatorColumn->isLeft(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return boundingBox; +} +int32_t CBC_PDF417ScanningDecoder::getMax(CFX_Int32Array& values) { + int32_t maxValue = -1; + for (int32_t i = 0; i < values.GetSize(); i++) { + int32_t value = values.GetAt(i); + maxValue = maxValue > value ? maxValue : value; + } + return maxValue; +} +CBC_BarcodeMetadata* CBC_PDF417ScanningDecoder::getBarcodeMetadata( + CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, + CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn) { + CBC_BarcodeMetadata* leftBarcodeMetadata = NULL; + CBC_BarcodeMetadata* rightBarcodeMetadata = NULL; + if (leftRowIndicatorColumn == NULL || + (leftBarcodeMetadata = leftRowIndicatorColumn->getBarcodeMetadata()) == + NULL) { + return rightRowIndicatorColumn == NULL + ? NULL + : rightRowIndicatorColumn->getBarcodeMetadata(); + } + if (rightRowIndicatorColumn == NULL || + (rightBarcodeMetadata = rightRowIndicatorColumn->getBarcodeMetadata()) == + NULL) { + return leftRowIndicatorColumn == NULL + ? NULL + : leftRowIndicatorColumn->getBarcodeMetadata(); + } + if (leftBarcodeMetadata->getColumnCount() != + rightBarcodeMetadata->getColumnCount() && + leftBarcodeMetadata->getErrorCorrectionLevel() != + rightBarcodeMetadata->getErrorCorrectionLevel() && + leftBarcodeMetadata->getRowCount() != + rightBarcodeMetadata->getRowCount()) { + delete leftBarcodeMetadata; + delete rightBarcodeMetadata; + return NULL; + } + delete rightBarcodeMetadata; + return leftBarcodeMetadata; +} +CBC_DetectionResultRowIndicatorColumn* +CBC_PDF417ScanningDecoder::getRowIndicatorColumn(CBC_CommonBitMatrix* image, + CBC_BoundingBox* boundingBox, + CBC_ResultPoint startPoint, + FX_BOOL leftToRight, + int32_t minCodewordWidth, + int32_t maxCodewordWidth) { + CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn = + new CBC_DetectionResultRowIndicatorColumn(boundingBox, leftToRight); + for (int32_t i = 0; i < 2; i++) { + int32_t increment = i == 0 ? 1 : -1; + int32_t startColumn = (int32_t)startPoint.GetX(); + for (int32_t imageRow = (int32_t)startPoint.GetY(); + imageRow <= boundingBox->getMaxY() && + imageRow >= boundingBox->getMinY(); + imageRow += increment) { + CBC_Codeword* codeword = + detectCodeword(image, 0, image->GetWidth(), leftToRight, startColumn, + imageRow, minCodewordWidth, maxCodewordWidth); + if (codeword) { + rowIndicatorColumn->setCodeword(imageRow, codeword); + if (leftToRight) { + startColumn = codeword->getStartX(); + } else { + startColumn = codeword->getEndX(); + } + } + } + } + return rowIndicatorColumn; +} +void CBC_PDF417ScanningDecoder::adjustCodewordCount( + CBC_DetectionResult* detectionResult, + CFX_PtrArray* barcodeMatrix, + int32_t& e) { + CFX_Int32Array* numberOfCodewords = + ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(0))->GetAt(1)) + ->getValue(); + int32_t calculatedNumberOfCodewords = + detectionResult->getBarcodeColumnCount() * + detectionResult->getBarcodeRowCount() - + getNumberOfECCodeWords(detectionResult->getBarcodeECLevel()); + if (numberOfCodewords->GetSize() == 0) { + if (calculatedNumberOfCodewords < 1 || + 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); + } else if (numberOfCodewords->GetAt(0) != calculatedNumberOfCodewords) { + ((CBC_BarcodeValue*)((CFX_PtrArray*)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); + 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(); + delete temp; + } + barcodeMatrix->RemoveAll(); + delete barcodeMatrix; + return NULL; + } + CFX_Int32Array erasures; + CFX_Int32Array codewords; + codewords.SetSize(detectionResult->getBarcodeRowCount() * + detectionResult->getBarcodeColumnCount()); + CFX_PtrArray 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(); + int32_t codewordIndex = + row * detectionResult->getBarcodeColumnCount() + l; + if (values->GetSize() == 0) { + erasures.Add(codewordIndex); + } else if (values->GetSize() == 1) { + codewords[codewordIndex] = values->GetAt(0); + } else { + ambiguousIndexesList.Add(codewordIndex); + ambiguousIndexValuesList.Add(values); + } + } + } + CFX_PtrArray 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); + } + 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); + return decoderResult; +} +CBC_CommonDecoderResult* +CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues( + int32_t ecLevel, + CFX_Int32Array& codewords, + CFX_Int32Array& erasureArray, + CFX_Int32Array& ambiguousIndexes, + CFX_PtrArray& ambiguousIndexValues, + int32_t& e) { + CFX_Int32Array ambiguousIndexCount; + ambiguousIndexCount.SetSize(ambiguousIndexes.GetSize()); + int32_t tries = 100; + while (tries-- > 0) { + for (int32_t l = 0; l < ambiguousIndexCount.GetSize(); l++) { + codewords[ambiguousIndexes[l]] = + ((CFX_Int32Array*)ambiguousIndexValues.GetAt(l)) + ->GetAt(ambiguousIndexCount[l]); + } + CBC_CommonDecoderResult* decoderResult = + decodeCodewords(codewords, ecLevel, erasureArray, e); + if (e != BCExceptionNO) { + e = BCExceptionNO; + continue; + } else { + return decoderResult; + } + if (ambiguousIndexCount.GetSize() == 0) { + e = BCExceptionChecksumInstance; + return NULL; + } + for (int32_t i = 0; i < ambiguousIndexCount.GetSize(); i++) { + if (ambiguousIndexCount[i] < + ((CFX_Int32Array*)(ambiguousIndexValues.GetAt(i)))->GetSize() - 1) { + ambiguousIndexCount[i]++; + break; + } else { + ambiguousIndexCount[i] = 0; + if (i == ambiguousIndexCount.GetSize() - 1) { + e = BCExceptionChecksumInstance; + return NULL; + } + } + } + } + e = BCExceptionChecksumInstance; + return NULL; +} +CFX_PtrArray* CBC_PDF417ScanningDecoder::createBarcodeMatrix( + CBC_DetectionResult* detectionResult) { + CFX_PtrArray* barcodeMatrix = new CFX_PtrArray; + 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; + temp->SetSize(detectionResult->getBarcodeColumnCount() + 2); + for (colume = 0; colume < detectionResult->getBarcodeColumnCount() + 2; + colume++) { + temp->SetAt(colume, 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(); + for (int32_t l = 0; l < temp->GetSize(); l++) { + CBC_Codeword* codeword = (CBC_Codeword*)temp->GetAt(l); + if (codeword == NULL || codeword->getRowNumber() == -1) { + continue; + } + ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt( + codeword->getRowNumber())) + ->GetAt(colume)) + ->setValue(codeword->getValue()); + } + } + return barcodeMatrix; +} +FX_BOOL CBC_PDF417ScanningDecoder::isValidBarcodeColumn( + CBC_DetectionResult* detectionResult, + int32_t barcodeColumn) { + return barcodeColumn >= 0 && + barcodeColumn <= detectionResult->getBarcodeColumnCount() + 1; +} +int32_t CBC_PDF417ScanningDecoder::getStartColumn( + CBC_DetectionResult* detectionResult, + int32_t barcodeColumn, + int32_t imageRow, + FX_BOOL leftToRight) { + int32_t offset = leftToRight ? 1 : -1; + CBC_Codeword* codeword = NULL; + if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) + ->getCodeword(imageRow); + } + if (codeword) { + return leftToRight ? codeword->getEndX() : codeword->getStartX(); + } + codeword = detectionResult->getDetectionResultColumn(barcodeColumn) + ->getCodewordNearby(imageRow); + if (codeword) { + return leftToRight ? codeword->getStartX() : codeword->getEndX(); + } + if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) + ->getCodewordNearby(imageRow); + } + if (codeword) { + return leftToRight ? codeword->getEndX() : codeword->getStartX(); + } + int32_t skippedColumns = 0; + while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + barcodeColumn -= offset; + for (int32_t i = 0; + i < detectionResult->getDetectionResultColumn(barcodeColumn) + ->getCodewords() + ->GetSize(); + i++) { + CBC_Codeword* previousRowCodeword = + (CBC_Codeword*)detectionResult->getDetectionResultColumn( + barcodeColumn) + ->getCodewords() + ->GetAt(i); + if (previousRowCodeword) { + return (leftToRight ? previousRowCodeword->getEndX() + : previousRowCodeword->getStartX()) + + offset * skippedColumns * (previousRowCodeword->getEndX() - + previousRowCodeword->getStartX()); + } + } + skippedColumns++; + } + return leftToRight ? detectionResult->getBoundingBox()->getMinX() + : detectionResult->getBoundingBox()->getMaxX(); +} +CBC_Codeword* CBC_PDF417ScanningDecoder::detectCodeword( + CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t startColumn, + int32_t imageRow, + int32_t minCodewordWidth, + int32_t maxCodewordWidth) { + startColumn = adjustCodewordStartColumn(image, minColumn, maxColumn, + leftToRight, startColumn, imageRow); + CFX_Int32Array* moduleBitCount = getModuleBitCount( + image, minColumn, maxColumn, leftToRight, startColumn, imageRow); + if (moduleBitCount == NULL) { + return NULL; + } + int32_t endColumn; + int32_t codewordBitCount = CBC_PDF417Common::getBitCountSum(*moduleBitCount); + if (leftToRight) { + endColumn = startColumn + codewordBitCount; + } else { + for (int32_t i = 0; i<moduleBitCount->GetSize()>> 1; i++) { + int32_t tmpCount = moduleBitCount->GetAt(i); + moduleBitCount->SetAt( + i, moduleBitCount->GetAt(moduleBitCount->GetSize() - 1 - i)); + moduleBitCount->SetAt(moduleBitCount->GetSize() - 1 - i, tmpCount); + } + endColumn = startColumn; + startColumn = endColumn - codewordBitCount; + } + int32_t decodedValue = + CBC_PDF417CodewordDecoder::getDecodedValue(*moduleBitCount); + int32_t codeword = CBC_PDF417Common::getCodeword(decodedValue); + delete moduleBitCount; + if (codeword == -1) { + return NULL; + } + return new CBC_Codeword(startColumn, endColumn, + getCodewordBucketNumber(decodedValue), codeword); +} +CFX_Int32Array* CBC_PDF417ScanningDecoder::getModuleBitCount( + CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t startColumn, + int32_t imageRow) { + int32_t imageColumn = startColumn; + CFX_Int32Array* moduleBitCount = new CFX_Int32Array; + moduleBitCount->SetSize(8); + int32_t moduleNumber = 0; + int32_t increment = leftToRight ? 1 : -1; + FX_BOOL previousPixelValue = leftToRight; + while (((leftToRight && imageColumn < maxColumn) || + (!leftToRight && imageColumn >= minColumn)) && + moduleNumber < moduleBitCount->GetSize()) { + if (image->Get(imageColumn, imageRow) == previousPixelValue) { + moduleBitCount->SetAt(moduleNumber, + moduleBitCount->GetAt(moduleNumber) + 1); + imageColumn += increment; + } else { + moduleNumber++; + previousPixelValue = !previousPixelValue; + } + } + if (moduleNumber == moduleBitCount->GetSize() || + (((leftToRight && imageColumn == maxColumn) || + (!leftToRight && imageColumn == minColumn)) && + moduleNumber == moduleBitCount->GetSize() - 1)) { + return moduleBitCount; + } + delete moduleBitCount; + return NULL; +} +int32_t CBC_PDF417ScanningDecoder::getNumberOfECCodeWords( + int32_t barcodeECLevel) { + return 2 << barcodeECLevel; +} +int32_t CBC_PDF417ScanningDecoder::adjustCodewordStartColumn( + CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t codewordStartColumn, + int32_t imageRow) { + int32_t correctedStartColumn = codewordStartColumn; + int32_t increment = leftToRight ? -1 : 1; + for (int32_t i = 0; i < 2; i++) { + while (((leftToRight && correctedStartColumn >= minColumn) || + (!leftToRight && correctedStartColumn < maxColumn)) && + leftToRight == image->Get(correctedStartColumn, imageRow)) { + if (abs(codewordStartColumn - correctedStartColumn) > + CODEWORD_SKEW_SIZE) { + return codewordStartColumn; + } + correctedStartColumn += increment; + } + increment = -increment; + leftToRight = !leftToRight; + } + return correctedStartColumn; +} +FX_BOOL CBC_PDF417ScanningDecoder::checkCodewordSkew(int32_t codewordSize, + int32_t minCodewordWidth, + int32_t maxCodewordWidth) { + return minCodewordWidth - CODEWORD_SKEW_SIZE <= codewordSize && + codewordSize <= maxCodewordWidth + CODEWORD_SKEW_SIZE; +} +CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decodeCodewords( + CFX_Int32Array& codewords, + int32_t ecLevel, + CFX_Int32Array& erasures, + int32_t& e) { + if (codewords.GetSize() == 0) { + e = BCExceptionFormatInstance; + return NULL; + } + int32_t numECCodewords = 1 << (ecLevel + 1); + correctErrors(codewords, erasures, numECCodewords, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + verifyCodewordCount(codewords, numECCodewords, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_ByteString bytestring; + CBC_CommonDecoderResult* decoderResult = CBC_DecodedBitStreamPaser::decode( + codewords, bytestring.FormatInteger(ecLevel), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return decoderResult; +} +int32_t CBC_PDF417ScanningDecoder::correctErrors(CFX_Int32Array& codewords, + CFX_Int32Array& erasures, + int32_t numECCodewords, + int32_t& e) { + if ((erasures.GetSize() != 0 && + erasures.GetSize() > (numECCodewords / 2 + MAX_ERRORS)) || + numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) { + e = BCExceptionChecksumInstance; + return -1; + } + int32_t result = CBC_PDF417ECErrorCorrection::decode( + codewords, numECCodewords, erasures, e); + BC_EXCEPTION_CHECK_ReturnValue(e, -1); + return result; +} +void CBC_PDF417ScanningDecoder::verifyCodewordCount(CFX_Int32Array& codewords, + int32_t numECCodewords, + int32_t& e) { + if (codewords.GetSize() < 4) { + e = BCExceptionFormatInstance; + return; + } + int32_t numberOfCodewords = codewords.GetAt(0); + if (numberOfCodewords > codewords.GetSize()) { + e = BCExceptionFormatInstance; + return; + } + if (numberOfCodewords == 0) { + if (numECCodewords < codewords.GetSize()) { + codewords[0] = codewords.GetSize() - numECCodewords; + } else { + e = BCExceptionFormatInstance; + return; + } + } +} +CFX_Int32Array* CBC_PDF417ScanningDecoder::getBitCountForCodeword( + int32_t codeword) { + CFX_Int32Array* result = new CFX_Int32Array; + result->SetSize(8); + int32_t previousValue = 0; + int32_t i = result->GetSize() - 1; + while (TRUE) { + if ((codeword & 0x1) != previousValue) { + previousValue = codeword & 0x1; + i--; + if (i < 0) { + break; + } + } + result->SetAt(i, result->GetAt(i) + 1); + codeword >>= 1; + } + return result; +} +int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber(int32_t codeword) { + CFX_Int32Array* array = getBitCountForCodeword(codeword); + int32_t result = getCodewordBucketNumber(*array); + delete array; + return result; +} +int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber( + CFX_Int32Array& moduleBitCount) { + return (moduleBitCount.GetAt(0) - moduleBitCount.GetAt(2) + + moduleBitCount.GetAt(4) - moduleBitCount.GetAt(6) + 9) % + 9; +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h new file mode 100644 index 0000000000..6dbc125c31 --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h @@ -0,0 +1,119 @@ +// 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_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ + +class CBC_CommonDecoderResult; +class CBC_CommonBitMatrix; +class CBC_Codeword; +class CBC_BoundingBox; +class CBC_ResultPoint; +class CBC_BarcodeMetadata; +class CBC_DetectionResult; +class CBC_DetectionResultRowIndicatorColumn; + +class CBC_PDF417ScanningDecoder { + public: + CBC_PDF417ScanningDecoder(); + virtual ~CBC_PDF417ScanningDecoder(); + static void Initialize(); + static void Finalize(); + static CBC_CommonDecoderResult* decode(CBC_CommonBitMatrix* image, + CBC_ResultPoint* imageTopLeft, + CBC_ResultPoint* imageBottomLeft, + CBC_ResultPoint* imageTopRight, + CBC_ResultPoint* imageBottomRight, + int32_t minCodewordWidth, + int32_t maxCodewordWidth, + int32_t& e); + static CFX_ByteString toString(CFX_PtrArray* barcodeMatrix); + + private: + static int32_t CODEWORD_SKEW_SIZE; + static int32_t MAX_ERRORS; + static int32_t MAX_EC_CODEWORDS; + static CBC_PDF417ECErrorCorrection* errorCorrection; + static CBC_DetectionResult* merge( + CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, + CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn, + int32_t& e); + static CBC_BoundingBox* adjustBoundingBox( + CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn, + int32_t& e); + static int32_t getMax(CFX_Int32Array& values); + static CBC_BarcodeMetadata* getBarcodeMetadata( + CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, + CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn); + static CBC_DetectionResultRowIndicatorColumn* getRowIndicatorColumn( + CBC_CommonBitMatrix* image, + CBC_BoundingBox* boundingBox, + CBC_ResultPoint startPoint, + FX_BOOL leftToRight, + int32_t minCodewordWidth, + int32_t maxCodewordWidth); + static void adjustCodewordCount(CBC_DetectionResult* detectionResult, + CFX_PtrArray* barcodeMatrix, + int32_t& e); + static CBC_CommonDecoderResult* createDecoderResult( + CBC_DetectionResult* detectionResult, + int32_t& e); + static CBC_CommonDecoderResult* createDecoderResultFromAmbiguousValues( + int32_t ecLevel, + CFX_Int32Array& codewords, + CFX_Int32Array& erasureArray, + CFX_Int32Array& ambiguousIndexes, + CFX_PtrArray& ambiguousIndexValues, + int32_t& e); + static CFX_PtrArray* createBarcodeMatrix( + CBC_DetectionResult* detectionResult); + static FX_BOOL isValidBarcodeColumn(CBC_DetectionResult* detectionResult, + int32_t barcodeColumn); + static int32_t getStartColumn(CBC_DetectionResult* detectionResult, + int32_t barcodeColumn, + int32_t imageRow, + FX_BOOL leftToRight); + static CBC_Codeword* detectCodeword(CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t startColumn, + int32_t imageRow, + int32_t minCodewordWidth, + int32_t maxCodewordWidth); + static CFX_Int32Array* getModuleBitCount(CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t startColumn, + int32_t imageRow); + static int32_t getNumberOfECCodeWords(int32_t barcodeECLevel); + static int32_t adjustCodewordStartColumn(CBC_CommonBitMatrix* image, + int32_t minColumn, + int32_t maxColumn, + FX_BOOL leftToRight, + int32_t codewordStartColumn, + int32_t imageRow); + static FX_BOOL checkCodewordSkew(int32_t codewordSize, + int32_t minCodewordWidth, + int32_t maxCodewordWidth); + static CBC_CommonDecoderResult* decodeCodewords(CFX_Int32Array& codewords, + int32_t ecLevel, + CFX_Int32Array& erasures, + int32_t& e); + static int32_t correctErrors(CFX_Int32Array& codewords, + CFX_Int32Array& erasures, + int32_t numECCodewords, + int32_t& e); + static void verifyCodewordCount(CFX_Int32Array& codewords, + int32_t numECCodewords, + int32_t& e); + static CFX_Int32Array* getBitCountForCodeword(int32_t codeword); + static int32_t getCodewordBucketNumber(int32_t codeword); + static int32_t getCodewordBucketNumber(CFX_Int32Array& moduleBitCount); +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp new file mode 100644 index 0000000000..765c1d613c --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Writer.cpp @@ -0,0 +1,115 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/common/BC_CommonBitArray.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" +#include "xfa/fxbarcode/pdf417/BC_PDF417Writer.h" + +CBC_PDF417Writer::CBC_PDF417Writer() { + m_bFixedSize = FALSE; +} +CBC_PDF417Writer::~CBC_PDF417Writer() { + m_bTruncated = TRUE; +} +FX_BOOL CBC_PDF417Writer::SetErrorCorrectionLevel(int32_t level) { + if (level < 0 || level > 8) { + return FALSE; + } + m_iCorrectLevel = level; + return TRUE; +} +void CBC_PDF417Writer::SetTruncated(FX_BOOL truncated) { + m_bTruncated = truncated; +} +uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + CBC_PDF417 encoder; + int32_t col = (m_Width / m_ModuleWidth - 69) / 17; + int32_t row = m_Height / (m_ModuleWidth * 20); + if (row >= 3 && row <= 90 && col >= 1 && col <= 30) { + encoder.setDimensions(col, col, row, row); + } else if (col >= 1 && col <= 30) { + encoder.setDimensions(col, col, 90, 3); + } else if (row >= 3 && row <= 90) { + encoder.setDimensions(30, 1, row, row); + } + encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t lineThickness = 2; + int32_t aspectRatio = 4; + CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); + CFX_ByteArray originalScale; + originalScale.Copy(barcodeMatrix->getScaledMatrix( + lineThickness, aspectRatio * lineThickness)); + int32_t width = outWidth; + int32_t height = outHeight; + outWidth = barcodeMatrix->getWidth(); + outHeight = barcodeMatrix->getHeight(); + FX_BOOL rotated = FALSE; + if ((height > width) ^ (outWidth < outHeight)) { + rotateArray(originalScale, outHeight, outWidth); + rotated = TRUE; + int32_t temp = outHeight; + outHeight = outWidth; + outWidth = temp; + } + int32_t scaleX = width / outWidth; + int32_t scaleY = height / outHeight; + int32_t scale; + if (scaleX < scaleY) { + scale = scaleX; + } else { + scale = scaleY; + } + if (scale > 1) { + originalScale.RemoveAll(); + originalScale.Copy(barcodeMatrix->getScaledMatrix( + scale * lineThickness, scale * aspectRatio * lineThickness)); + if (rotated) { + rotateArray(originalScale, outHeight, outWidth); + int32_t temp = outHeight; + outHeight = outWidth; + outWidth = temp; + } + } + uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth); + FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth); + return result; +} +void CBC_PDF417Writer::rotateArray(CFX_ByteArray& bitarray, + int32_t height, + int32_t width) { + CFX_ByteArray temp; + temp.Copy(bitarray); + for (int32_t ii = 0; ii < height; ii++) { + int32_t inverseii = height - ii - 1; + for (int32_t jj = 0; jj < width; jj++) { + bitarray[jj * height + inverseii] = temp[ii * width + jj]; + } + } +} diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Writer.h b/xfa/fxbarcode/pdf417/BC_PDF417Writer.h new file mode 100644 index 0000000000..f92f57b82c --- /dev/null +++ b/xfa/fxbarcode/pdf417/BC_PDF417Writer.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_PDF417_BC_PDF417WRITER_H_ +#define XFA_FXBARCODE_PDF417_BC_PDF417WRITER_H_ + +class CBC_TwoDimWriter; +class CBC_PDF417Writer; +class CBC_PDF417Writer : public CBC_TwoDimWriter { + public: + CBC_PDF417Writer(); + virtual ~CBC_PDF417Writer(); + uint8_t* Encode(const CFX_WideString& contents, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + FX_BOOL SetErrorCorrectionLevel(int32_t level); + void SetTruncated(FX_BOOL truncated); + + private: + void rotateArray(CFX_ByteArray& bitarray, int32_t width, int32_t height); + FX_BOOL m_bTruncated; +}; + +#endif // XFA_FXBARCODE_PDF417_BC_PDF417WRITER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp new file mode 100644 index 0000000000..25dc28b3f3 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp @@ -0,0 +1,41 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#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() {} +CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetBottomLeft() { + return m_bottomLeft; +} +CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopLeft() { + return m_topLeft; +} +CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopRight() { + return m_topRight; +} diff --git a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h new file mode 100644 index 0000000000..0acb106856 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_ +#define XFA_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_QRFinderPattern; + +class CBC_QRFinderPatternInfo { + 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/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp new file mode 100644 index 0000000000..4d5a36e250 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp @@ -0,0 +1,49 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h" + +CBC_QRAlignmentPattern::CBC_QRAlignmentPattern(FX_FLOAT posX, + FX_FLOAT posY, + FX_FLOAT estimateModuleSize) + : CBC_ResultPoint(posX, posY), m_moduleSize(estimateModuleSize) {} +CBC_QRAlignmentPattern::~CBC_QRAlignmentPattern() {} +FX_FLOAT CBC_QRAlignmentPattern::GetX() { + return m_x; +} +FX_FLOAT CBC_QRAlignmentPattern::GetY() { + return m_y; +} +FX_BOOL CBC_QRAlignmentPattern::AboutEquals(FX_FLOAT moduleSize, + FX_FLOAT i, + FX_FLOAT j) { + if ((FXSYS_fabs(i - GetY()) <= moduleSize) && + (FXSYS_fabs(j - GetX()) <= moduleSize)) { + FX_FLOAT moduleSizeDiff = FXSYS_fabs(moduleSize - m_moduleSize); + return (moduleSizeDiff <= 1.0f) || (moduleSizeDiff / m_moduleSize <= 1.0f); + } + return FALSE; +} +CBC_QRAlignmentPattern* CBC_QRAlignmentPattern::Clone() { + return new CBC_QRAlignmentPattern(m_x, m_y, m_moduleSize); +} diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h new file mode 100644 index 0000000000..9a4e80c2b2 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h @@ -0,0 +1,25 @@ +// 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_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ +class CBC_ResultPoint; +class CBC_QRAlignmentPattern : public CBC_ResultPoint { + private: + FX_FLOAT m_moduleSize; + + public: + CBC_QRAlignmentPattern(FX_FLOAT posX, + FX_FLOAT posY, + FX_FLOAT estimateModuleSize); + virtual ~CBC_QRAlignmentPattern(); + FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j); + FX_FLOAT GetX(); + FX_FLOAT GetY(); + CBC_QRAlignmentPattern* Clone(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp new file mode 100644 index 0000000000..8c462bf328 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp @@ -0,0 +1,200 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h" +#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h" + +CBC_QRAlignmentPatternFinder::CBC_QRAlignmentPatternFinder( + CBC_CommonBitMatrix* image, + int32_t startX, + int32_t startY, + int32_t width, + int32_t height, + FX_FLOAT moduleSize) + : m_image(image), + m_startX(startX), + m_startY(startY), + m_width(width), + m_height(height), + 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(); +} +CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::Find(int32_t& e) { + int32_t startX = m_startX; + int32_t height = m_height; + int32_t maxJ = startX + m_width; + int32_t middleI = m_startY + (height >> 1); + CFX_Int32Array stateCount; + stateCount.SetSize(3); + for (int32_t iGen = 0; iGen < height; iGen++) { + int32_t i = + middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + int32_t j = startX; + while (j < maxJ && !m_image->Get(j, i)) { + j++; + } + int32_t currentState = 0; + while (j < maxJ) { + if (m_image->Get(j, i)) { + if (currentState == 1) { + stateCount[currentState]++; + } else { + if (currentState == 2) { + if (FoundPatternCross(stateCount)) { + CBC_QRAlignmentPattern* confirmed = + HandlePossibleCenter(stateCount, i, j); + if (confirmed) { + return confirmed; + } + } + stateCount[0] = stateCount[2]; + stateCount[1] = 1; + stateCount[2] = 0; + currentState = 1; + } else { + stateCount[++currentState]++; + } + } + } else { + if (currentState == 1) { + currentState++; + } + stateCount[currentState]++; + } + j++; + } + if (FoundPatternCross(stateCount)) { + CBC_QRAlignmentPattern* confirmed = + HandlePossibleCenter(stateCount, i, maxJ); + if (confirmed) { + return confirmed; + } + } + } + if (m_possibleCenters.GetSize() != 0) { + return ((CBC_QRAlignmentPattern*)(m_possibleCenters[0]))->Clone(); + } + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return NULL; +} +FX_FLOAT CBC_QRAlignmentPatternFinder::CenterFromEnd( + const CFX_Int32Array& stateCount, + int32_t end) { + return (FX_FLOAT)(end - stateCount[2]) - stateCount[1] / 2.0f; +} +FX_BOOL CBC_QRAlignmentPatternFinder::FoundPatternCross( + const CFX_Int32Array& stateCount) { + FX_FLOAT moduleSize = m_moduleSize; + FX_FLOAT maxVariance = moduleSize / 2.0f; + for (int32_t i = 0; i < 3; i++) { + if (fabs(moduleSize - stateCount[i]) >= maxVariance) { + return false; + } + } + return TRUE; +} +FX_FLOAT CBC_QRAlignmentPatternFinder::CrossCheckVertical( + int32_t startI, + int32_t centerJ, + int32_t maxCount, + int32_t originalStateCountTotal) { + int32_t maxI = m_image->GetHeight(); + CFX_Int32Array stateCount; + stateCount.Copy(m_crossCheckStateCount); + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + int32_t i = startI; + while (i >= 0 && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + if (i < 0 || stateCount[1] > maxCount) { + return FXSYS_nan(); + } + while (i >= 0 && !m_image->Get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return FXSYS_nan(); + } + i = startI + 1; + while (i < maxI && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + if (i == maxI || stateCount[1] > maxCount) { + return FXSYS_nan(); + } + while (i < maxI && !m_image->Get(centerJ, i) && stateCount[2] <= maxCount) { + stateCount[2]++; + i++; + } + if (stateCount[2] > maxCount) { + return FXSYS_nan(); + } + int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + if (5 * abs(stateCountTotal - originalStateCountTotal) >= + originalStateCountTotal) { + return FXSYS_nan(); + } + return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i) + : FXSYS_nan(); +} +CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::HandlePossibleCenter( + const CFX_Int32Array& stateCount, + int32_t i, + int32_t j) { + int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + FX_FLOAT centerJ = CenterFromEnd(stateCount, j); + FX_FLOAT centerI = CrossCheckVertical(i, (int32_t)centerJ, 2 * stateCount[1], + stateCountTotal); + if (!FXSYS_isnan(centerI)) { + FX_FLOAT estimatedModuleSize = + (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]); + if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) { + return new CBC_QRAlignmentPattern(centerJ, centerI, + estimatedModuleSize); + } + } + m_possibleCenters.Add( + new CBC_QRAlignmentPattern(centerJ, centerI, estimatedModuleSize)); + } + return NULL; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h new file mode 100644 index 0000000000..0b1a2a7ca7 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h @@ -0,0 +1,47 @@ +// 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_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxbarcode/utils.h" + +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, + int32_t startY, + int32_t width, + int32_t height, + FX_FLOAT moduleSize); + virtual ~CBC_QRAlignmentPatternFinder(); + FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount); + FX_FLOAT CrossCheckVertical(int32_t startI, + int32_t startJ, + int32_t maxCount, + int32_t originalStateCountTotal); + CBC_QRAlignmentPattern* Find(int32_t& e); + CBC_QRAlignmentPattern* HandlePossibleCenter(const CFX_Int32Array& stateCount, + int32_t i, + int32_t j); + static FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp new file mode 100644 index 0000000000..53803588b5 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp @@ -0,0 +1,183 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h" + +#include <memory> + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRBitMatrixParser::CBC_QRBitMatrixParser() {} +void CBC_QRBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e) { + m_dimension = bitMatrix->GetDimension(e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + m_tempBitMatrix = bitMatrix; + if (m_dimension < 21 || (m_dimension & 0x03) != 1) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + m_bitMatrix = m_tempBitMatrix; + m_parsedFormatInfo = NULL; + m_version = NULL; +} +CBC_QRBitMatrixParser::~CBC_QRBitMatrixParser() { + delete m_parsedFormatInfo; +} +CBC_QRCoderFormatInformation* CBC_QRBitMatrixParser::ReadFormatInformation( + int32_t& e) { + if (m_parsedFormatInfo) { + return m_parsedFormatInfo; + } + int32_t formatInfoBits = 0; + int32_t j; + for (j = 0; j < 6; j++) { + formatInfoBits = CopyBit(8, j, formatInfoBits); + } + formatInfoBits = CopyBit(8, 7, formatInfoBits); + formatInfoBits = CopyBit(8, 8, formatInfoBits); + formatInfoBits = CopyBit(7, 8, formatInfoBits); + for (int32_t i = 5; i >= 0; i--) { + formatInfoBits = CopyBit(i, 8, formatInfoBits); + } + m_parsedFormatInfo = + CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits); + if (m_parsedFormatInfo) { + return m_parsedFormatInfo; + } + int32_t dimension = m_bitMatrix->GetDimension(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + formatInfoBits = 0; + int32_t iMin = dimension - 8; + for (j = dimension - 1; j >= iMin; j--) { + formatInfoBits = CopyBit(j, 8, formatInfoBits); + } + for (int32_t k = dimension - 7; k < dimension; k++) { + formatInfoBits = CopyBit(8, k, formatInfoBits); + } + m_parsedFormatInfo = + CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits); + if (m_parsedFormatInfo) { + return m_parsedFormatInfo; + } + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return NULL; +} +CBC_QRCoderVersion* CBC_QRBitMatrixParser::ReadVersion(int32_t& e) { + if (m_version) { + return m_version; + } + int32_t dimension = m_bitMatrix->GetDimension(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t provisionVersion = (dimension - 17) >> 2; + if (provisionVersion <= 6) { + CBC_QRCoderVersion* qrv = + CBC_QRCoderVersion::GetVersionForNumber(provisionVersion, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qrv; + } + int32_t versionBits = 0; + for (int32_t i = 5; i >= 0; i--) { + int32_t jMin = dimension - 11; + for (int32_t j = dimension - 9; j >= jMin; j--) { + versionBits = CopyBit(i, j, versionBits); + } + } + m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (m_version && m_version->GetDimensionForVersion() == dimension) { + return m_version; + } + versionBits = 0; + for (int32_t j = 5; j >= 0; j--) { + int32_t iMin = dimension - 11; + for (int32_t i = dimension - 9; i >= iMin; i--) { + versionBits = CopyBit(i, j, versionBits); + } + } + m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (m_version && m_version->GetDimensionForVersion() == dimension) { + return m_version; + } + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return NULL; +} +int32_t CBC_QRBitMatrixParser::CopyBit(int32_t i, + int32_t j, + int32_t versionBits) { + return m_bitMatrix->Get(j, i) ? (versionBits << 1) | 0x1 : versionBits << 1; +} +CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) { + CBC_QRCoderFormatInformation* formatInfo = ReadFormatInformation(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL) CBC_QRCoderVersion* version = + ReadVersion(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRDataMask* dataMask = + CBC_QRDataMask::ForReference((int32_t)(formatInfo->GetDataMask()), 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); + std::unique_ptr<CBC_CommonBitMatrix> functionPattern( + version->BuildFunctionPattern(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + FX_BOOL readingUp = TRUE; + std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray); + result->SetSize(version->GetTotalCodeWords()); + int32_t resultOffset = 0; + int32_t currentByte = 0; + int32_t bitsRead = 0; + for (int32_t j = dimension - 1; j > 0; j -= 2) { + if (j == 6) { + j--; + } + for (int32_t count = 0; count < dimension; count++) { + int32_t i = readingUp ? dimension - 1 - count : count; + for (int32_t col = 0; col < 2; col++) { + if (!functionPattern->Get(j - col, i)) { + bitsRead++; + currentByte <<= 1; + if (m_bitMatrix->Get(j - col, i)) { + currentByte |= 1; + } + if (bitsRead == 8) { + (*result)[resultOffset++] = (uint8_t)currentByte; + bitsRead = 0; + currentByte = 0; + } + } + } + } + readingUp ^= TRUE; + } + if (resultOffset != version->GetTotalCodeWords()) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return result.release(); +} diff --git a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h new file mode 100644 index 0000000000..6bb1064cd2 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h @@ -0,0 +1,34 @@ +// 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_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_QRCoderVersion; +class CBC_QRCoderFormatInformation; + +class CBC_QRBitMatrixParser { + private: + CBC_CommonBitMatrix* m_bitMatrix; + CBC_CommonBitMatrix* m_tempBitMatrix; + CBC_QRCoderVersion* m_version; + CBC_QRCoderFormatInformation* m_parsedFormatInfo; + int32_t m_dimension; + + public: + CBC_QRBitMatrixParser(); + virtual ~CBC_QRBitMatrixParser(); + CBC_QRCoderFormatInformation* ReadFormatInformation(int32_t& e); + CBC_QRCoderVersion* ReadVersion(int32_t& e); + int32_t CopyBit(int32_t i, int32_t j, int32_t versionBits); + CFX_ByteArray* ReadCodewords(int32_t& e); + virtual void Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp new file mode 100644 index 0000000000..716b6c17de --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp @@ -0,0 +1,108 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h" + +#include <memory> + +#include "xfa/fxbarcode/BC_Binarizer.h" +#include "xfa/fxbarcode/BC_BinaryBitmap.h" +#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h" +#include "xfa/fxbarcode/BC_LuminanceSource.h" +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetector.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h" + +CBC_QRCodeReader::CBC_QRCodeReader() : m_decoder(NULL) {} +void CBC_QRCodeReader::Init() { + m_decoder = new CBC_QRCoderDecoder; + m_decoder->Init(); +} +CBC_QRCodeReader::~CBC_QRCodeReader() { + delete m_decoder; +} +CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, + int32_t hints, + int32_t& e) { + CBC_CommonBitMatrix* matrix = image->GetMatrix(e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CBC_QRDetector detector(matrix); + std::unique_ptr<CBC_QRDetectorResult> detectorResult( + detector.Detect(hints, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + std::unique_ptr<CBC_CommonDecoderResult> decodeResult( + m_decoder->Decode(detectorResult->GetBits(), 0, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return (decodeResult->GetText()); +} +CFX_ByteString CBC_QRCodeReader::Decode(const CFX_WideString& filename, + int32_t hints, + int32_t byteModeDecode, + int32_t& e) { + CBC_BufferedImageLuminanceSource source(filename); + source.Init(e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + CBC_GlobalHistogramBinarizer binarizer(&source); + CBC_BinaryBitmap bitmap(&binarizer); + CFX_ByteString bs = Decode(&bitmap, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return bs; +} +CFX_ByteString CBC_QRCodeReader::Decode(CFX_DIBitmap* pBitmap, + int32_t hints, + int32_t byteModeDecode, + int32_t& e) { + CBC_BufferedImageLuminanceSource source(pBitmap); + CBC_GlobalHistogramBinarizer binarizer(&source); + CBC_BinaryBitmap bitmap(&binarizer); + CFX_ByteString bs = Decode(&bitmap, hints, e); + BC_EXCEPTION_CHECK_ReturnValue(e, ""); + return bs; +} +CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { + CFX_ByteString bs = Decode(image, 0, e); + BC_EXCEPTION_CHECK_ReturnValue(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; + } + CBC_QRCoderMode::Destroy(); + CBC_QRCoderErrorCorrectionLevel::Destroy(); + CBC_QRDataMask::Destroy(); + CBC_QRCoderVersion::Destroy(); +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.h b/xfa/fxbarcode/qrcode/BC_QRCodeReader.h new file mode 100644 index 0000000000..72dd453953 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCodeReader.h @@ -0,0 +1,40 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ + +#include <stdint.h> + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fxbarcode/BC_Reader.h" + +class CBC_BinaryBitmap; +class CBC_QRCoderDecoder; +class CFX_DIBitmap; + +class CBC_QRCodeReader : public CBC_Reader { + private: + CBC_QRCoderDecoder* m_decoder; + + public: + CBC_QRCodeReader(); + virtual ~CBC_QRCodeReader(); + CFX_ByteString Decode(CFX_DIBitmap* pBitmap, + int32_t hints, + int32_t byteModeDecode, + int32_t& e); + CFX_ByteString Decode(const CFX_WideString& filename, + int32_t hints, + int32_t byteModeDecode, + int32_t& e); + static void ReleaseAll(); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); + CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); + virtual void Init(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp new file mode 100644 index 0000000000..cd4340e38c --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp @@ -0,0 +1,107 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_Reader.h" +#include "xfa/fxbarcode/BC_TwoDimWriter.h" +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h" +#include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" + +CBC_QRCodeWriter::CBC_QRCodeWriter() { + m_bFixedSize = TRUE; + m_iCorrectLevel = 1; + m_iVersion = 0; +} +CBC_QRCodeWriter::~CBC_QRCodeWriter() {} +void CBC_QRCodeWriter::ReleaseAll() { + CBC_QRCodeReader::ReleaseAll(); +} +FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) { + if (version < 0 || version > 40) { + return FALSE; + } + m_iVersion = version; + return TRUE; +} +FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(int32_t level) { + if (level < 0 || level > 3) { + return FALSE; + } + m_iCorrectLevel = level; + return TRUE; +} +uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, + int32_t ecLevel, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + CBC_QRCoderErrorCorrectionLevel* ec = NULL; + switch (ecLevel) { + case 0: + ec = CBC_QRCoderErrorCorrectionLevel::L; + break; + case 1: + ec = CBC_QRCoderErrorCorrectionLevel::M; + break; + case 2: + ec = CBC_QRCoderErrorCorrectionLevel::Q; + break; + case 3: + ec = CBC_QRCoderErrorCorrectionLevel::H; + break; + default: { + e = BCExceptionUnSupportEclevel; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + } + CBC_QRCoder qr; + if (m_iVersion > 0 && m_iVersion < 41) { + CFX_ByteString byteStr = contents.UTF8Encode(); + CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion); + } else { + CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); + } + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + outWidth = qr.GetMatrixWidth(); + outHeight = qr.GetMatrixWidth(); + uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); + FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); + return result; +} +uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e) { + return NULL; +} +uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e) { + return NULL; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.h b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.h new file mode 100644 index 0000000000..c68c6c0a3f --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.h @@ -0,0 +1,41 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ + +#include "xfa/fxbarcode/BC_TwoDimWriter.h" + +class CBC_TwoDimWriter; +class CBC_QRCodeWriter : public CBC_TwoDimWriter { + public: + CBC_QRCodeWriter(); + virtual ~CBC_QRCodeWriter(); + uint8_t* Encode(const CFX_WideString& contents, + int32_t ecLevel, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t hints, + int32_t& e); + uint8_t* Encode(const CFX_ByteString& contents, + BCFORMAT format, + int32_t& outWidth, + int32_t& outHeight, + int32_t& e); + FX_BOOL SetVersion(int32_t version); + FX_BOOL SetErrorCorrectionLevel(int32_t level); + static void ReleaseAll(); + + private: + int32_t m_iVersion; +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp new file mode 100644 index 0000000000..9e9ad06817 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp @@ -0,0 +1,124 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRCoder::CBC_QRCoder() { + m_mode = NULL; + m_ecLevel = NULL; + m_version = -1; + m_matrixWidth = -1; + m_maskPattern = -1; + m_numTotalBytes = -1; + m_numDataBytes = -1; + m_numECBytes = -1; + m_numRSBlocks = -1; + m_matrix = NULL; +} +CBC_QRCoder::~CBC_QRCoder() { + delete m_matrix; +} +CBC_QRCoderMode* CBC_QRCoder::GetMode() { + return m_mode; +} +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() { + return m_ecLevel; +} +int32_t CBC_QRCoder::GetVersion() { + return m_version; +} +int32_t CBC_QRCoder::GetMatrixWidth() { + return m_matrixWidth; +} +int32_t CBC_QRCoder::GetMaskPattern() { + return m_maskPattern; +} +int32_t CBC_QRCoder::GetNumTotalBytes() { + return m_numTotalBytes; +} +int32_t CBC_QRCoder::GetNumDataBytes() { + return m_numDataBytes; +} +int32_t CBC_QRCoder::GetNumECBytes() { + return m_numECBytes; +} +int32_t CBC_QRCoder::GetNumRSBlocks() { + return m_numRSBlocks; +} +CBC_CommonByteMatrix* CBC_QRCoder::GetMatrix() { + return m_matrix; +} +int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { + int32_t value = m_matrix->Get(x, y); + if (!(value == 0 || value == 1)) { + e = BCExceptionValueMustBeEither0or1; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + return value; +} +FX_BOOL CBC_QRCoder::IsValid() { + return m_mode && m_ecLevel && m_version != -1 && m_matrixWidth != -1 && + m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 && + m_numECBytes != -1 && m_numRSBlocks != -1 && + IsValidMaskPattern(m_maskPattern) && + m_numTotalBytes == m_numDataBytes + m_numECBytes && m_matrix && + m_matrixWidth == m_matrix->GetWidth() && + m_matrix->GetWidth() == m_matrix->GetHeight(); +} +void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) { + m_mode = value; +} +void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) { + m_ecLevel = ecLevel; +} +void CBC_QRCoder::SetVersion(int32_t version) { + m_version = version; +} +void CBC_QRCoder::SetMatrixWidth(int32_t width) { + m_matrixWidth = width; +} +void CBC_QRCoder::SetMaskPattern(int32_t pattern) { + m_maskPattern = pattern; +} +void CBC_QRCoder::SetNumDataBytes(int32_t bytes) { + m_numDataBytes = bytes; +} +void CBC_QRCoder::SetNumTotalBytes(int32_t value) { + m_numTotalBytes = value; +} +void CBC_QRCoder::SetNumRSBlocks(int32_t block) { + m_numRSBlocks = block; +} +void CBC_QRCoder::SetNumECBytes(int32_t value) { + m_numECBytes = value; +} +FX_BOOL CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { + return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; +} +void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) { + m_matrix = value; +} +const int32_t CBC_QRCoder::NUM_MASK_PATTERNS = 8; diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.h b/xfa/fxbarcode/qrcode/BC_QRCoder.h new file mode 100644 index 0000000000..bbf7bd4429 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoder.h @@ -0,0 +1,57 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODER_H_ + +class CBC_QRCoderErrorCorrectionLevel; +class CBC_QRCoderMode; +class CBC_CommonByteMatrix; + +class CBC_QRCoder { + private: + CBC_QRCoderMode* m_mode; + CBC_QRCoderErrorCorrectionLevel* m_ecLevel; + int32_t m_version; + int32_t m_matrixWidth; + int32_t m_maskPattern; + int32_t m_numTotalBytes; + int32_t m_numDataBytes; + int32_t m_numECBytes; + int32_t m_numRSBlocks; + CBC_CommonByteMatrix* m_matrix; + + public: + static const int32_t NUM_MASK_PATTERNS; + CBC_QRCoder(); + virtual ~CBC_QRCoder(); + CBC_QRCoderMode* GetMode(); + CBC_QRCoderErrorCorrectionLevel* GetECLevel(); + int32_t GetVersion(); + int32_t GetMatrixWidth(); + int32_t GetMaskPattern(); + int32_t GetNumTotalBytes(); + int32_t GetNumDataBytes(); + int32_t GetNumECBytes(); + int32_t GetNumRSBlocks(); + CBC_CommonByteMatrix* GetMatrix(); + int32_t At(int32_t x, int32_t y, int32_t& e); + FX_BOOL IsValid(); + + void SetMode(CBC_QRCoderMode* value); + void SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel); + void SetVersion(int32_t version); + void SetMatrixWidth(int32_t width); + void SetMaskPattern(int32_t pattern); + void SetNumDataBytes(int32_t bytes); + void SetNumTotalBytes(int32_t value); + void SetNumECBytes(int32_t value); + void SetNumRSBlocks(int32_t block); + void SetMatrix(CBC_CommonByteMatrix* value); + static FX_BOOL IsValidMaskPattern(int32_t maskPattern); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp new file mode 100644 index 0000000000..a225f61fbb --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.cpp @@ -0,0 +1,124 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/include/fxcrt/fx_memory.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRCoderBitVector::CBC_QRCoderBitVector() { + m_sizeInBits = 0; + m_size = 32; +} +void CBC_QRCoderBitVector::Init() { + m_array = FX_Alloc(uint8_t, m_size); +} +CBC_QRCoderBitVector::~CBC_QRCoderBitVector() { + FX_Free(m_array); +} +void CBC_QRCoderBitVector::Clear() { + FX_Free(m_array); + m_sizeInBits = 0; + m_size = 32; + m_array = FX_Alloc(uint8_t, m_size); +} +int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) { + if (index < 0 || index >= m_sizeInBits) { + e = BCExceptionBadIndexException; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + int32_t value = m_array[index >> 3] & 0xff; + return (value >> (7 - (index & 0x7))) & 1; +} +int32_t CBC_QRCoderBitVector::sizeInBytes() { + return (m_sizeInBits + 7) >> 3; +} +int32_t CBC_QRCoderBitVector::Size() { + return m_sizeInBits; +} +void CBC_QRCoderBitVector::AppendBit(int32_t bit, int32_t& e) { + if (!(bit == 0 || bit == 1)) { + e = BCExceptionBadValueException; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t numBitsInLastByte = m_sizeInBits & 0x7; + if (numBitsInLastByte == 0) { + AppendByte(0); + m_sizeInBits -= 8; + } + m_array[m_sizeInBits >> 3] |= (bit << (7 - numBitsInLastByte)); + ++m_sizeInBits; +} +void CBC_QRCoderBitVector::AppendBits(int32_t value, + int32_t numBits, + int32_t& e) { + if (numBits < 0 || numBits > 32) { + e = BCExceptionBadNumBitsException; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t numBitsLeft = numBits; + while (numBitsLeft > 0) { + if ((m_sizeInBits & 0x7) == 0 && numBitsLeft >= 8) { + int32_t newByte = (value >> (numBitsLeft - 8)) & 0xff; + AppendByte(newByte); + numBitsLeft -= 8; + } else { + int32_t bit = (value >> (numBitsLeft - 1)) & 1; + AppendBit(bit, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + --numBitsLeft; + } + } +} +void CBC_QRCoderBitVector::AppendBitVector(CBC_QRCoderBitVector* bits, + int32_t& e) { + int32_t size = bits->Size(); + for (int32_t i = 0; i < size; i++) { + int32_t num = bits->At(i, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendBit(num, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) + } +} +void CBC_QRCoderBitVector::XOR(CBC_QRCoderBitVector* other, int32_t& e) { + if (m_sizeInBits != other->Size()) { + e = BCExceptioncanNotOperatexorOperator; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t sizeInBytes = (m_sizeInBits + 7) >> 3; + for (int32_t i = 0; i < sizeInBytes; ++i) { + m_array[i] ^= (other->GetArray())[i]; + } +} +uint8_t* CBC_QRCoderBitVector::GetArray() { + return m_array; +} +void CBC_QRCoderBitVector::AppendByte(int32_t value) { + if ((m_sizeInBits >> 3) == m_size) { + uint8_t* newArray = FX_Alloc(uint8_t, m_size << 1); + FXSYS_memcpy(newArray, m_array, m_size); + FX_Free(m_array); + m_array = newArray; + m_size = m_size << 1; + } + m_array[m_sizeInBits >> 3] = (uint8_t)value; + m_sizeInBits += 8; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h new file mode 100644 index 0000000000..7742541a06 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h @@ -0,0 +1,35 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ + +#include <stdint.h> + +class CBC_QRCoderBitVector { + private: + int32_t m_sizeInBits; + uint8_t* m_array; + int32_t m_size; + + void AppendByte(int32_t value); + + public: + CBC_QRCoderBitVector(); + virtual ~CBC_QRCoderBitVector(); + int32_t At(int32_t index, int32_t& e); + int32_t Size(); + int32_t sizeInBytes(); + void AppendBit(int32_t bit, int32_t& e); + void AppendBits(int32_t value, int32_t numBits, int32_t& e); + void AppendBitVector(CBC_QRCoderBitVector* bits, int32_t& e); + void XOR(CBC_QRCoderBitVector* other, int32_t& e); + uint8_t* GetArray(); + void Clear(); + virtual void Init(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp new file mode 100644 index 0000000000..b8a032ae68 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp @@ -0,0 +1,41 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonByteArray.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h" + +CBC_QRCoderBlockPair::CBC_QRCoderBlockPair( + CBC_CommonByteArray* data, + CBC_CommonByteArray* errorCorrection) { + m_dataBytes = data; + m_errorCorrectionBytes = errorCorrection; +} +CBC_QRCoderBlockPair::~CBC_QRCoderBlockPair() { + delete m_dataBytes; + delete m_errorCorrectionBytes; +} +CBC_CommonByteArray* CBC_QRCoderBlockPair::GetDataBytes() { + return m_dataBytes; +} +CBC_CommonByteArray* CBC_QRCoderBlockPair::GetErrorCorrectionBytes() { + return m_errorCorrectionBytes; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h new file mode 100644 index 0000000000..5427436761 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h @@ -0,0 +1,25 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ + +class CBC_CommonByteArray; +class CBC_QRCoderBlockPair { + private: + CBC_CommonByteArray* m_dataBytes; + CBC_CommonByteArray* m_errorCorrectionBytes; + + public: + CBC_QRCoderBlockPair(CBC_CommonByteArray* data, + CBC_CommonByteArray* errorCorrection); + virtual ~CBC_QRCoderBlockPair(); + + CBC_CommonByteArray* GetDataBytes(); + CBC_CommonByteArray* GetErrorCorrectionBytes(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp new file mode 100644 index 0000000000..1966146805 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp @@ -0,0 +1,129 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h" + +#include <memory> + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/qrcode/BC_QRDataBlock.h" +#include "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" + +CBC_QRCoderDecoder::CBC_QRCoderDecoder() { + m_rsDecoder = NULL; +} + +void CBC_QRCoderDecoder::Init() { + m_rsDecoder = new CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::QRCodeFild); +} +CBC_QRCoderDecoder::~CBC_QRCoderDecoder() { + delete m_rsDecoder; +} +CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(FX_BOOL* image, + int32_t width, + int32_t height, + int32_t& e) { + CBC_CommonBitMatrix bits; + bits.Init(width); + for (int32_t i = 0; i < width; i++) { + for (int32_t j = 0; j < height; j++) { + if (image[i * width + j]) { + bits.Set(j, i); + } + } + } + CBC_CommonDecoderResult* cdr = Decode(&bits, height, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return cdr; +} +CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits, + int32_t byteModeDecode, + int32_t& e) { + CBC_QRBitMatrixParser parser; + parser.Init(bits, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRCoderVersion* version = parser.ReadVersion(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRCoderFormatInformation* temp = parser.ReadFormatInformation(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel(); + std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CFX_PtrArray* 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(); + } + CFX_ByteArray resultBytes; + for (int32_t j = 0; j < dataBlocks->GetSize(); j++) { + CBC_QRDataBlock* dataBlock = (CBC_QRDataBlock*)((*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]; + } + dataBlocks->RemoveAll(); + delete dataBlocks; + dataBlocks = NULL; + return NULL; + } + for (int32_t i = 0; i < numDataCodewords; i++) { + resultBytes.Add((*codewordBytes)[i]); + } + } + for (int32_t k = 0; k < dataBlocks->GetSize(); k++) { + delete (CBC_QRDataBlock*)(*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); + return cdr; +} +void CBC_QRCoderDecoder::CorrectErrors(CFX_ByteArray* codewordBytes, + int32_t numDataCodewords, + int32_t& e) { + int32_t numCodewords = codewordBytes->GetSize(); + CFX_Int32Array codewordsInts; + codewordsInts.SetSize(numCodewords); + for (int32_t i = 0; i < numCodewords; i++) { + codewordsInts[i] = (int32_t)((*codewordBytes)[i] & 0xff); + } + int32_t numECCodewords = codewordBytes->GetSize() - numDataCodewords; + m_rsDecoder->Decode(&codewordsInts, numECCodewords, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + for (int32_t k = 0; k < numDataCodewords; k++) { + (*codewordBytes)[k] = (uint8_t)codewordsInts[k]; + } +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h new file mode 100644 index 0000000000..b6c381cc9d --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h @@ -0,0 +1,37 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_ReedSolomonDecoder; +class CBC_CommonDecoderResult; + +class CBC_QRCoderDecoder { + private: + CBC_ReedSolomonDecoder* m_rsDecoder; + + public: + CBC_QRCoderDecoder(); + virtual ~CBC_QRCoderDecoder(); + + CBC_CommonDecoderResult* Decode(FX_BOOL* image, + int32_t width, + int32_t height, + int32_t& e); + CBC_CommonDecoderResult* Decode(CBC_CommonBitMatrix* bits, + int32_t byteModeDecode, + int32_t& e); + void CorrectErrors(CFX_ByteArray* codewordBytes, + int32_t numDataCodewords, + int32_t& e); + virtual void Init(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECB.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderECB.cpp new file mode 100644 index 0000000000..2b5a2a6fef --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderECB.cpp @@ -0,0 +1,35 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h" + +CBC_QRCoderECB::CBC_QRCoderECB(int32_t count, int32_t dataCodeWords) { + m_dataCodeWords = dataCodeWords; + m_count = count; +} +CBC_QRCoderECB::~CBC_QRCoderECB() {} +int32_t CBC_QRCoderECB::GetCount() { + return m_count; +} +int32_t CBC_QRCoderECB::GetDataCodeWords() { + return m_dataCodeWords; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECB.h b/xfa/fxbarcode/qrcode/BC_QRCoderECB.h new file mode 100644 index 0000000000..25b0b20fe3 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderECB.h @@ -0,0 +1,24 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERECB_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERECB_H_ + +#include <stdint.h> + +class CBC_QRCoderECB { + private: + int32_t m_count; + int32_t m_dataCodeWords; + + public: + CBC_QRCoderECB(int32_t count, int32_t dataCodeWords); + virtual ~CBC_QRCoderECB(); + int32_t GetCount(); + int32_t GetDataCodeWords(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERECB_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp new file mode 100644 index 0000000000..eb6d194b55 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp @@ -0,0 +1,59 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h" +#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_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock, + CBC_QRCoderECB* ecBlocks1, + CBC_QRCoderECB* ecBlocks2) { + m_ecCodeWordsPerBlock = ecCodeWordsPerBlock; + m_ecBlocks.Add(ecBlocks1); + m_ecBlocks.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(); +} +int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() { + return m_ecCodeWordsPerBlock; +} +int32_t CBC_QRCoderECBlocks::GetNumBlocks() { + int32_t total = 0; + for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { + total += ((CBC_QRCoderECB*)(m_ecBlocks[i]))->GetCount(); + } + return total; +} +int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() { + return m_ecCodeWordsPerBlock * GetNumBlocks(); +} +CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks() { + return &m_ecBlocks; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h new file mode 100644 index 0000000000..c1a5b34194 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h @@ -0,0 +1,31 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ + +#include "core/include/fxcrt/fx_basic.h" + +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(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp new file mode 100644 index 0000000000..0360ef0b13 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -0,0 +1,961 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h" + +#include <algorithm> +#include <memory> + +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/common/BC_CommonByteArray.h" +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" +#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBlockPair.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" + +const int32_t CBC_QRCoderEncoder::m_alphaNumbericTable[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1}; + +CBC_QRCoderEncoder::CBC_QRCoderEncoder() {} +CBC_QRCoderEncoder::~CBC_QRCoderEncoder() {} +class Make_Pair { + public: + CBC_QRCoderMode* m_mode; + CFX_ByteString m_string; + + private: + Make_Pair(const Make_Pair& mode_string) {} + Make_Pair& operator=(Make_Pair& mode_string) { + if (this == &mode_string) { + return *this; + } + m_mode = mode_string.m_mode; + m_string = mode_string.m_string; + return *this; + } + + public: + Make_Pair(CBC_QRCoderMode* mode, const CFX_ByteString& str) + : m_mode(mode), m_string(str) {} + ~Make_Pair() {} +}; +void CBC_QRCoderEncoder::Encode(const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e, + int32_t versionSpecify) { + if (versionSpecify == 0) { + EncodeWithAutoVersion(content, ecLevel, qrCode, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) + } else if (versionSpecify > 0 && versionSpecify <= 40) { + EncodeWithSpecifyVersion(content, ecLevel, qrCode, versionSpecify, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else { + e = BCExceptionVersionMust1_40; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::AppendECI(CBC_QRCoderBitVector* bits) {} +void CBC_QRCoderEncoder::AppendDataModeLenghInfo( + CFX_PtrArray& splitResult, + CBC_QRCoderBitVector& headerAndDataBits, + CBC_QRCoderMode* tempMode, + CBC_QRCoder* qrCode, + CFX_ByteString& encoding, + int32_t& e) { + for (int32_t i = 0; i < splitResult.GetSize(); i++) { + tempMode = ((Make_Pair*)splitResult[i])->m_mode; + if (tempMode == CBC_QRCoderMode::sGBK) { + AppendModeInfo(tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), + qrCode->GetVersion(), tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, + &headerAndDataBits, encoding, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (tempMode == CBC_QRCoderMode::sBYTE) { + CFX_ByteArray bytes; + CBC_UtilCodingConvert::LocaleToUtf8( + ((Make_Pair*)splitResult[i])->m_string, bytes); + AppendModeInfo(tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendLengthInfo(bytes.GetSize(), qrCode->GetVersion(), tempMode, + &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + Append8BitBytes(bytes, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (tempMode == CBC_QRCoderMode::sALPHANUMERIC) { + AppendModeInfo(tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), + qrCode->GetVersion(), tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, + &headerAndDataBits, encoding, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (tempMode == CBC_QRCoderMode::sNUMERIC) { + AppendModeInfo(tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), + qrCode->GetVersion(), tempMode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, + &headerAndDataBits, encoding, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else { + e = BCExceptionUnknown; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } +} +void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content, + CFX_PtrArray& result) { + int32_t index = 0, flag = 0; + while ( + (((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || + ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && + (index < content.GetLength())) { + index += 2; + } + if (index != flag) { + result.Add( + new Make_Pair(CBC_QRCoderMode::sGBK, content.Mid(flag, index - flag))); + } + flag = index; + if (index >= content.GetLength()) { + return; + } + while ( + GetAlphaNumericCode((uint8_t)content[index]) == -1 && + !(((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || + ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && + (index < content.GetLength())) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + if (IsDBCSLeadByte((uint8_t)content[index])) +#else + if ((uint8_t)content[index] > 127) +#endif + { + index += 2; + } else { + index++; + } + } + if (index != flag) { + result.Add( + new Make_Pair(CBC_QRCoderMode::sBYTE, content.Mid(flag, index - flag))); + } + flag = index; + if (index >= content.GetLength()) { + return; + } + while (FXSYS_Isdigit((uint8_t)content[index]) && + (index < content.GetLength())) { + index++; + } + if (index != flag) { + result.Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC, + content.Mid(flag, index - flag))); + } + flag = index; + if (index >= content.GetLength()) { + return; + } + while (GetAlphaNumericCode((uint8_t)content[index]) != -1 && + (index < content.GetLength())) { + index++; + } + if (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); +} +int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst, + CBC_QRCoderMode* modeSecond, + int32_t versionNum, + int32_t& e) { + if (versionNum == 0) { + return 0; + } + if ((modeFirst == CBC_QRCoderMode::sALPHANUMERIC) && + (modeSecond == CBC_QRCoderMode::sBYTE)) { + if (versionNum >= 1 && versionNum <= 9) { + return 11; + } else if (versionNum >= 10 && versionNum <= 26) { + return 15; + } else if (versionNum >= 27 && versionNum <= 40) { + return 16; + } else { + e = BCExceptionNoSuchVersion; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + } else if ((modeSecond == CBC_QRCoderMode::sALPHANUMERIC) && + (modeFirst == CBC_QRCoderMode::sNUMERIC)) { + if (versionNum >= 1 && versionNum <= 9) { + return 13; + } else if (versionNum >= 10 && versionNum <= 26) { + return 15; + } else if (versionNum >= 27 && versionNum <= 40) { + return 17; + } else { + e = BCExceptionNoSuchVersion; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + } else if ((modeSecond == CBC_QRCoderMode::sBYTE) && + (modeFirst == CBC_QRCoderMode::sNUMERIC)) { + if (versionNum >= 1 && versionNum <= 9) { + return 6; + } else if (versionNum >= 10 && versionNum <= 26) { + return 8; + } else if (versionNum >= 27 && versionNum <= 40) { + return 9; + } else { + e = BCExceptionNoSuchVersion; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + } + return -1; +} +void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& 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]; + if (first->m_mode == CBC_QRCoderMode::sALPHANUMERIC) { + int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC, + CBC_QRCoderMode::sBYTE, versionNum, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if ((second->m_mode == CBC_QRCoderMode::sBYTE) && + (first->m_string.GetLength() < tmp)) { + CFX_ByteString str = first->m_string + second->m_string; + second->m_string = str; + delete first; + result.RemoveAt(i); + i--; + mergeNum++; + } + } else if (first->m_mode == CBC_QRCoderMode::sBYTE) { + if (second->m_mode == CBC_QRCoderMode::sBYTE) { + first->m_string += second->m_string; + delete second; + result.RemoveAt(i + 1); + i--; + mergeNum++; + } + } else if (first->m_mode == CBC_QRCoderMode::sNUMERIC) { + int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC, + CBC_QRCoderMode::sBYTE, versionNum, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if ((second->m_mode == CBC_QRCoderMode::sBYTE) && + (first->m_string.GetLength() < tmp)) { + CFX_ByteString str = first->m_string + second->m_string; + second->m_string = str; + delete first; + result.RemoveAt(i); + i--; + mergeNum++; + } + tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC, + CBC_QRCoderMode::sALPHANUMERIC, versionNum, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if ((second->m_mode == CBC_QRCoderMode::sALPHANUMERIC) && + (first->m_string.GetLength() < tmp)) { + CFX_ByteString str = first->m_string + second->m_string; + second->m_string = str; + delete first; + result.RemoveAt(i); + i--; + mergeNum++; + } + } + } + if (mergeNum == 0) { + return; + } + MergeString(result, versionNum, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, + int32_t versionNumber, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoderMode* mode, + CBC_QRCoder* qrCode, + int32_t& e) { + qrCode->SetECLevel(ecLevel); + qrCode->SetMode(mode); + CBC_QRCoderVersion* version = + CBC_QRCoderVersion::GetVersionForNumber(versionNumber, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t numBytes = version->GetTotalCodeWords(); + CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); + int32_t numEcBytes = ecBlocks->GetTotalECCodeWords(); + int32_t numRSBlocks = ecBlocks->GetNumBlocks(); + int32_t numDataBytes = numBytes - numEcBytes; + if (numDataBytes >= numInputBytes + 3) { + qrCode->SetVersion(versionNumber); + qrCode->SetNumTotalBytes(numBytes); + qrCode->SetNumDataBytes(numDataBytes); + qrCode->SetNumRSBlocks(numRSBlocks); + qrCode->SetNumECBytes(numEcBytes); + qrCode->SetMatrixWidth(version->GetDimensionForVersion()); + return; + } + e = BCExceptionCannotFindBlockInfo; + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderEncoder::EncodeWithSpecifyVersion( + const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t versionSpecify, + int32_t& e) { + CFX_ByteString encoding = "utf8"; + CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; + CFX_PtrArray splitResult; + CBC_QRCoderBitVector dataBits; + dataBits.Init(); + 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); + if (e != BCExceptionNO) { + for (int32_t y = 0; y < splitResult.GetSize(); y++) { + delete (Make_Pair*)splitResult[y]; + } + splitResult.RemoveAll(); + return; + } + } + int32_t numInputBytes = dataBits.sizeInBytes(); + CBC_QRCoderBitVector headerAndDataBits; + 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(); + 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(); + 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]; + } + splitResult.RemoveAll(); + CBC_QRCoderBitVector finalBits; + finalBits.Init(); + InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), + qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), + &finalBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); + int32_t maskPattern = ChooseMaskPattern( + &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + qrCode->SetMaskPattern(maskPattern); + CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), + qrCode->GetVersion(), + qrCode->GetMaskPattern(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + qrCode->SetMatrix(matrix.release()); + if (!qrCode->IsValid()) { + e = BCExceptionInvalidQRCode; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::EncodeWithAutoVersion( + const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e) { + CFX_ByteString encoding = "utf8"; + CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; + CFX_PtrArray splitResult; + CBC_QRCoderBitVector dataBits; + dataBits.Init(); + 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); + if (e != BCExceptionNO) { + for (int32_t l = 0; l < splitResult.GetSize(); l++) { + delete (Make_Pair*)splitResult[l]; + } + splitResult.RemoveAll(); + return; + } + } + int32_t numInputBytes = dataBits.sizeInBytes(); + InitQRCode(numInputBytes, ecLevel, mode, qrCode, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderBitVector headerAndDataBits; + headerAndDataBits.Init(); + tempMode = NULL; + int32_t versionNum = qrCode->GetVersion(); +sign: + AppendDataModeLenghInfo(splitResult, headerAndDataBits, tempMode, qrCode, + encoding, e); + if (e != BCExceptionNO) { + goto catchException; + } + numInputBytes = headerAndDataBits.sizeInBytes(); + TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); + if (e != BCExceptionNO) { + goto catchException; + } +catchException: + if (e != BCExceptionNO) { + int32_t e1 = BCExceptionNO; + InitQRCode(numInputBytes, ecLevel, mode, qrCode, e1); + if (e1 != BCExceptionNO) { + e = e1; + return; + } + versionNum++; + if (versionNum <= 40) { + headerAndDataBits.Clear(); + e = BCExceptionNO; + goto sign; + } else { + for (int32_t j = 0; j < splitResult.GetSize(); j++) { + delete (Make_Pair*)splitResult[j]; + } + splitResult.RemoveAll(); + return; + } + } + for (int32_t k = 0; k < splitResult.GetSize(); k++) { + delete (Make_Pair*)splitResult[k]; + } + splitResult.RemoveAll(); + CBC_QRCoderBitVector finalBits; + finalBits.Init(); + InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), + qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), + &finalBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); + int32_t maskPattern = ChooseMaskPattern( + &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + qrCode->SetMaskPattern(maskPattern); + CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), + qrCode->GetVersion(), + qrCode->GetMaskPattern(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(matrix.release()); + if (!qrCode->IsValid()) { + e = BCExceptionInvalidQRCode; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e) { + CFX_ByteString encoding = "utf8"; + CFX_ByteString utf8Data; + CBC_UtilCodingConvert::UnicodeToUTF8(content, utf8Data); + CBC_QRCoderMode* mode = ChooseMode(utf8Data, encoding); + CBC_QRCoderBitVector dataBits; + dataBits.Init(); + AppendBytes(utf8Data, mode, &dataBits, encoding, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t numInputBytes = dataBits.sizeInBytes(); + InitQRCode(numInputBytes, ecLevel, mode, qrCode, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CBC_QRCoderBitVector headerAndDataBits; + headerAndDataBits.Init(); + AppendModeInfo(mode, &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t numLetters = mode == CBC_QRCoderMode::sBYTE ? dataBits.sizeInBytes() + : content.GetLength(); + AppendLengthInfo(numLetters, qrCode->GetVersion(), mode, &headerAndDataBits, + e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + headerAndDataBits.AppendBitVector(&dataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) + TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + CBC_QRCoderBitVector finalBits; + finalBits.Init(); + InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), + qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), + &finalBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); + int32_t maskPattern = ChooseMaskPattern( + &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + qrCode->SetMaskPattern(maskPattern); + CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), + qrCode->GetVersion(), + qrCode->GetMaskPattern(), matrix.get(), e); + BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(matrix.release()); + if (!qrCode->IsValid()) { + e = BCExceptionInvalidQRCode; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes, + CBC_QRCoderBitVector* bits, + int32_t& e) { + int32_t capacity = numDataBytes << 3; + if (bits->Size() > capacity) { + e = BCExceptionDataTooMany; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t i = 0; i < 4 && bits->Size() < capacity; ++i) { + bits->AppendBit(0, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t numBitsInLastByte = bits->Size() % 8; + if (numBitsInLastByte > 0) { + int32_t numPaddingBits = 8 - numBitsInLastByte; + for (int32_t j = 0; j < numPaddingBits; ++j) { + bits->AppendBit(0, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) + } + } + if (bits->Size() % 8 != 0) { + e = BCExceptionDigitLengthMustBe8; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t numPaddingBytes = numDataBytes - bits->sizeInBytes(); + for (int32_t k = 0; k < numPaddingBytes; ++k) { + if (k % 2 == 0) { + bits->AppendBits(0xec, 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else { + bits->AppendBits(0x11, 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } + if (bits->Size() != capacity) { + e = BCExceptionBitsNotEqualCacity; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +int32_t CBC_QRCoderEncoder::ChooseMaskPattern( + CBC_QRCoderBitVector* bits, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + int32_t minPenalty = 65535; + int32_t bestMaskPattern = -1; + for (int32_t maskPattern = 0; maskPattern < CBC_QRCoder::NUM_MASK_PATTERNS; + maskPattern++) { + CBC_QRCoderMatrixUtil::BuildMatrix(bits, ecLevel, version, maskPattern, + matrix, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + int32_t penalty = CalculateMaskPenalty(matrix); + if (penalty < minPenalty) { + minPenalty = penalty; + bestMaskPattern = maskPattern; + } + } + return bestMaskPattern; +} +int32_t CBC_QRCoderEncoder::CalculateMaskPenalty(CBC_CommonByteMatrix* matrix) { + int32_t penalty = 0; + penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1(matrix); + penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2(matrix); + penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(matrix); + penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(matrix); + return penalty; +} +CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, + CFX_ByteString encoding) { + if (encoding.Compare("SHIFT_JIS") == 0) { + return CBC_QRCoderMode::sKANJI; + } + FX_BOOL hasNumeric = FALSE; + FX_BOOL hasAlphaNumeric = FALSE; + for (int32_t i = 0; i < content.GetLength(); i++) { + if (isdigit((uint8_t)content[i])) { + hasNumeric = TRUE; + } else if (GetAlphaNumericCode((uint8_t)content[i]) != -1) { + hasAlphaNumeric = TRUE; + } else { + return CBC_QRCoderMode::sBYTE; + } + } + if (hasAlphaNumeric) { + return CBC_QRCoderMode::sALPHANUMERIC; + } else if (hasNumeric) { + return CBC_QRCoderMode::sNUMERIC; + } + return CBC_QRCoderMode::sBYTE; +} +int32_t CBC_QRCoderEncoder::GetAlphaNumericCode(int32_t code) { + if (code < 96 && code >= 0) { + return m_alphaNumbericTable[code]; + } + return -1; +} +void CBC_QRCoderEncoder::AppendBytes(const CFX_ByteString& content, + CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + CFX_ByteString encoding, + int32_t& e) { + if (mode == CBC_QRCoderMode::sNUMERIC) { + AppendNumericBytes(content, bits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) { + AppendAlphaNumericBytes(content, bits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (mode == CBC_QRCoderMode::sBYTE) { + Append8BitBytes(content, bits, encoding, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (mode == CBC_QRCoderMode::sKANJI) { + AppendKanjiBytes(content, bits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else if (mode == CBC_QRCoderMode::sGBK) { + AppendGBKBytes(content, bits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } else { + e = BCExceptionUnsupportedMode; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::AppendNumericBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e) { + int32_t length = content.GetLength(); + int32_t i = 0; + while (i < length) { + int32_t num1 = content[i] - '0'; + if (i + 2 < length) { + int32_t num2 = content[i + 1] - '0'; + int32_t num3 = content[i + 2] - '0'; + bits->AppendBits(num1 * 100 + num2 * 10 + num3, 10, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) i += 3; + } else if (i + 1 < length) { + int32_t num2 = content[i + 1] - '0'; + bits->AppendBits(num1 * 10 + num2, 7, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) i += 2; + } else { + bits->AppendBits(num1, 4, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + i++; + } + } +} +void CBC_QRCoderEncoder::AppendAlphaNumericBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e) { + int32_t length = content.GetLength(); + int32_t i = 0; + while (i < length) { + int32_t code1 = GetAlphaNumericCode(content[i]); + if (code1 == -1) { + e = BCExceptionInvalidateCharacter; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (i + 1 < length) { + int32_t code2 = GetAlphaNumericCode(content[i + 1]); + if (code2 == -1) { + e = BCExceptionInvalidateCharacter; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + bits->AppendBits(code1 * 45 + code2, 11, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + i += 2; + } else { + bits->AppendBits(code1, 6, e); + BC_EXCEPTION_CHECK_ReturnVoid(e) i++; + } + } +} +void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e) { + int32_t length = content.GetLength(); + FX_DWORD value = 0; + for (int32_t i = 0; i < length; i += 2) { + value = (FX_DWORD)((uint8_t)content[i] << 8 | (uint8_t)content[i + 1]); + if (value <= 0xAAFE && value >= 0xA1A1) { + value -= 0xA1A1; + } else if (value <= 0xFAFE && value >= 0xB0A1) { + value -= 0xA6A1; + } else { + e = BCExceptionInvalidateCharacter; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + value = (FX_DWORD)((value >> 8) * 0x60) + (FX_DWORD)(value & 0xff); + bits->AppendBits(value, 13, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + CFX_ByteString encoding, + int32_t& e) { + for (int32_t i = 0; i < content.GetLength(); i++) { + bits->AppendBits(content[i], 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::Append8BitBytes(CFX_ByteArray& bytes, + CBC_QRCoderBitVector* bits, + int32_t& e) { + for (int32_t i = 0; i < bytes.GetSize(); i++) { + bits->AppendBits(bytes[i], 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e) { + CFX_ByteArray bytes; + FX_DWORD value = 0; + for (int32_t i = 0; i < bytes.GetSize(); i += 2) { + value = (FX_DWORD)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]); + if (value <= 0x9ffc && value >= 0x8140) { + value -= 0x8140; + } else if (value <= 0xebbf && value >= 0xe040) { + value -= 0xc140; + } else { + e = BCExceptionInvalidateCharacter; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + value = (FX_DWORD)((value >> 8) * 0xc0) + (FX_DWORD)(value & 0xff); + bits->AppendBits(value, 13, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoderMode* mode, + CBC_QRCoder* qrCode, + int32_t& e) { + qrCode->SetECLevel(ecLevel); + qrCode->SetMode(mode); + for (int32_t versionNum = 1; versionNum <= 40; versionNum++) { + CBC_QRCoderVersion* version = + CBC_QRCoderVersion::GetVersionForNumber(versionNum, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t numBytes = version->GetTotalCodeWords(); + CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); + int32_t numEcBytes = ecBlocks->GetTotalECCodeWords(); + int32_t numRSBlocks = ecBlocks->GetNumBlocks(); + int32_t numDataBytes = numBytes - numEcBytes; + if (numDataBytes >= numInputBytes + 3) { + qrCode->SetVersion(versionNum); + qrCode->SetNumTotalBytes(numBytes); + qrCode->SetNumDataBytes(numDataBytes); + qrCode->SetNumRSBlocks(numRSBlocks); + qrCode->SetNumECBytes(numEcBytes); + qrCode->SetMatrixWidth(version->GetDimensionForVersion()); + return; + } + } + e = BCExceptionCannotFindBlockInfo; + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderEncoder::AppendModeInfo(CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + int32_t& e) { + bits->AppendBits(mode->GetBits(), 4, e); + if (mode == CBC_QRCoderMode::sGBK) { + bits->AppendBits(1, 4, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::AppendLengthInfo(int32_t numLetters, + int32_t version, + CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + int32_t& e) { + CBC_QRCoderVersion* qcv = CBC_QRCoderVersion::GetVersionForNumber(version, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t numBits = mode->GetCharacterCountBits(qcv, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (numBits > ((1 << numBits) - 1)) { + return; + } + if (mode == CBC_QRCoderMode::sGBK) { + bits->AppendBits(numLetters / 2, numBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + bits->AppendBits(numLetters, numBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits, + int32_t numTotalBytes, + int32_t numDataBytes, + int32_t numRSBlocks, + CBC_QRCoderBitVector* result, + int32_t& e) { + if (bits->sizeInBytes() != numDataBytes) { + e = BCExceptionBitsBytesNotMatch; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t dataBytesOffset = 0; + int32_t maxNumDataBytes = 0; + int32_t maxNumEcBytes = 0; + CFX_PtrArray blocks; + int32_t i; + for (i = 0; i < numRSBlocks; i++) { + int32_t numDataBytesInBlock; + int32_t numEcBytesInBlosk; + GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, + numRSBlocks, i, numDataBytesInBlock, + numEcBytesInBlosk); + CBC_CommonByteArray* dataBytes = new CBC_CommonByteArray; + dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); + CBC_CommonByteArray* ecBytes = + GenerateECBytes(dataBytes, numEcBytesInBlosk, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + blocks.Add(new CBC_QRCoderBlockPair(dataBytes, ecBytes)); + maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); + maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); + dataBytesOffset += numDataBytesInBlock; + } + if (numDataBytes != dataBytesOffset) { + e = BCExceptionBytesNotMatchOffset; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + 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(); + if (x < dataBytes->Size()) { + result->AppendBits(dataBytes->At(x), 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } + } + 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(); + if (y < ecBytes->Size()) { + result->AppendBits(ecBytes->At(y), 8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } + } + for (int32_t k = 0; k < blocks.GetSize(); k++) { + delete (CBC_QRCoderBlockPair*)blocks[k]; + } + if (numTotalBytes != result->sizeInBytes()) { + e = BCExceptionSizeInBytesDiffer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderEncoder::GetNumDataBytesAndNumECBytesForBlockID( + int32_t numTotalBytes, + int32_t numDataBytes, + int32_t numRSBlocks, + int32_t blockID, + int32_t& numDataBytesInBlock, + int32_t& numECBytesInBlock) { + if (blockID >= numRSBlocks) { + return; + } + int32_t numRsBlocksInGroup2 = numTotalBytes % numRSBlocks; + int32_t numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2; + int32_t numTotalBytesInGroup1 = numTotalBytes / numRSBlocks; + int32_t numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1; + int32_t numDataBytesInGroup1 = numDataBytes / numRSBlocks; + int32_t numDataBytesInGroup2 = numDataBytesInGroup1 + 1; + int32_t numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1; + int32_t numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2; + if (blockID < numRsBlocksInGroup1) { + numDataBytesInBlock = numDataBytesInGroup1; + numECBytesInBlock = numEcBytesInGroup1; + } else { + numDataBytesInBlock = numDataBytesInGroup2; + numECBytesInBlock = numEcBytesInGroup2; + } +} +CBC_CommonByteArray* CBC_QRCoderEncoder::GenerateECBytes( + CBC_CommonByteArray* dataBytes, + int32_t numEcBytesInBlock, + int32_t& e) { + int32_t numDataBytes = dataBytes->Size(); + CFX_Int32Array toEncode; + toEncode.SetSize(numDataBytes + numEcBytesInBlock); + for (int32_t i = 0; i < numDataBytes; i++) { + toEncode[i] = (dataBytes->At(i)); + } + CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); + encode.Init(); + encode.Encode(&toEncode, numEcBytesInBlock, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); + for (int32_t j = 0; j < numEcBytesInBlock; j++) { + ecBytes->Set(j, toEncode[numDataBytes + j]); + } + return ecBytes; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h new file mode 100644 index 0000000000..8330dc2d1a --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h @@ -0,0 +1,133 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" + +class CBC_QRCoder; +class CBC_QRCoderErrorCorrectionLevel; +class CBC_QRCoderMode; +class CBC_QRCoderBitVector; +class CBC_CommonByteArray; +class CBC_CommonByteMatrix; + +class CBC_QRCoderEncoder { + private: + static const int32_t m_alphaNumbericTable[96]; + + public: + CBC_QRCoderEncoder(); + virtual ~CBC_QRCoderEncoder(); + + static void Encode(const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e, + int32_t versionSpecify = 0); + static void Encode(const CFX_WideString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e); + static void EncodeWithSpecifyVersion(const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t versionSpecify, + int32_t& e); + static void EncodeWithAutoVersion(const CFX_ByteString& content, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoder* qrCode, + int32_t& e); + static CBC_QRCoderMode* ChooseMode(const CFX_ByteString& content, + CFX_ByteString encoding); + static int32_t GetAlphaNumericCode(int32_t code); + static void AppendECI(CBC_QRCoderBitVector* bits); + static void AppendBytes(const CFX_ByteString& content, + CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + CFX_ByteString encoding, + int32_t& e); + static void AppendNumericBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void AppendAlphaNumericBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void Append8BitBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + CFX_ByteString encoding, + int32_t& e); + static void Append8BitBytes(CFX_ByteArray& bytes, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void AppendKanjiBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void AppendGBKBytes(const CFX_ByteString& content, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void InitQRCode(int32_t numInputBytes, + int32_t versionNumber, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoderMode* mode, + CBC_QRCoder* qrCode, + int32_t& e); + static void InitQRCode(int32_t numInputBytes, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + CBC_QRCoderMode* mode, + CBC_QRCoder* qrCode, + int32_t& e); + static void AppendModeInfo(CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void AppendLengthInfo(int32_t numLetters, + int32_t version, + CBC_QRCoderMode* mode, + CBC_QRCoderBitVector* bits, + int32_t& e); + + static void InterleaveWithECBytes(CBC_QRCoderBitVector* bits, + int32_t numTotalBytes, + int32_t numDataBytes, + int32_t numRSBlocks, + CBC_QRCoderBitVector* result, + int32_t& e); + static void GetNumDataBytesAndNumECBytesForBlockID( + int32_t numTotalBytes, + int32_t numDataBytes, + int32_t numRSBlocks, + int32_t blockID, + int32_t& numDataBytesInBlock, + int32_t& numECBytesInBlocks); + static CBC_CommonByteArray* GenerateECBytes(CBC_CommonByteArray* dataBytes, + int32_t numEcBytesInBlock, + int32_t& e); + static int32_t ChooseMaskPattern(CBC_QRCoderBitVector* bits, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static int32_t CalculateMaskPenalty(CBC_CommonByteMatrix* matrix); + static void TerminateBits(int32_t numDataBytes, + CBC_QRCoderBitVector* bits, + int32_t& e); + static int32_t GetSpanByVersion(CBC_QRCoderMode* modeFirst, + 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); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp new file mode 100644 index 0000000000..a1ce747b40 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp @@ -0,0 +1,92 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" + +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::L = NULL; +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::M = NULL; +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::Q = NULL; +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::H = NULL; + +CBC_QRCoderErrorCorrectionLevel::CBC_QRCoderErrorCorrectionLevel( + int32_t ordinal, + int32_t bits, + FX_CHAR* name) { + m_name += name; + m_ordinal = ordinal; + m_bits = bits; +} +CBC_QRCoderErrorCorrectionLevel::~CBC_QRCoderErrorCorrectionLevel() {} +void CBC_QRCoderErrorCorrectionLevel::Initialize() { + L = new CBC_QRCoderErrorCorrectionLevel(0, 0x01, (FX_CHAR*)"L"); + M = new CBC_QRCoderErrorCorrectionLevel(1, 0x00, (FX_CHAR*)"M"); + Q = new CBC_QRCoderErrorCorrectionLevel(2, 0x03, (FX_CHAR*)"Q"); + H = new CBC_QRCoderErrorCorrectionLevel(3, 0x02, (FX_CHAR*)"H"); +} +void CBC_QRCoderErrorCorrectionLevel::Finalize() { + delete L; + delete M; + delete Q; + delete H; +} +int32_t CBC_QRCoderErrorCorrectionLevel::Ordinal() { + return m_ordinal; +} +int32_t CBC_QRCoderErrorCorrectionLevel::GetBits() { + return m_bits; +} +CFX_ByteString CBC_QRCoderErrorCorrectionLevel::GetName() { + return m_name; +} +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::ForBits( + int32_t bits) { + switch (bits) { + case 0x00: + return M; + case 0x01: + return L; + case 0x02: + return H; + case 0x03: + return Q; + default: + return NULL; + } +} +void CBC_QRCoderErrorCorrectionLevel::Destroy() { + if (L) { + delete CBC_QRCoderErrorCorrectionLevel::L; + L = NULL; + } + if (M) { + delete CBC_QRCoderErrorCorrectionLevel::M; + M = NULL; + } + if (H) { + delete CBC_QRCoderErrorCorrectionLevel::H; + H = NULL; + } + if (Q) { + delete CBC_QRCoderErrorCorrectionLevel::Q; + Q = NULL; + } +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h b/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h new file mode 100644 index 0000000000..377137ae91 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h @@ -0,0 +1,35 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ + +#include "core/include/fxcrt/fx_string.h" + +class CBC_QRCoderErrorCorrectionLevel { + private: + int32_t m_ordinal; + int32_t m_bits; + CFX_ByteString m_name; + CBC_QRCoderErrorCorrectionLevel(int32_t ordinal, int32_t bits, FX_CHAR* name); + CBC_QRCoderErrorCorrectionLevel(); + + public: + static CBC_QRCoderErrorCorrectionLevel* L; + static CBC_QRCoderErrorCorrectionLevel* M; + static CBC_QRCoderErrorCorrectionLevel* Q; + static CBC_QRCoderErrorCorrectionLevel* H; + virtual ~CBC_QRCoderErrorCorrectionLevel(); + static void Initialize(); + static void Finalize(); + int32_t Ordinal(); + int32_t GetBits(); + CFX_ByteString GetName(); + static void Destroy(); + static CBC_QRCoderErrorCorrectionLevel* ForBits(int32_t bits); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp new file mode 100644 index 0000000000..da647a9c53 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp @@ -0,0 +1,95 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_QRCoderFormatInformation::FORMAT_INFO_MASK_QR = 0X5412; +const int32_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}, +}; +const int32_t CBC_QRCoderFormatInformation::BITS_SET_IN_HALF_BYTE[] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; + +CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo) { + m_errorCorrectLevl = + 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; + return BITS_SET_IN_HALF_BYTE[a & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 4) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 8) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 12) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 16) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 20) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] + + BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F]; +} +uint8_t CBC_QRCoderFormatInformation::GetDataMask() { + return m_dataMask; +} +CBC_QRCoderErrorCorrectionLevel* +CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() { + return m_errorCorrectLevl; +} +CBC_QRCoderFormatInformation* +CBC_QRCoderFormatInformation::DecodeFormatInformation( + int32_t maskedFormatInfo) { + CBC_QRCoderFormatInformation* formatInfo = + DoDecodeFormatInformation(maskedFormatInfo); + if (formatInfo) + 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++) { + int32_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; + int32_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/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h new file mode 100644 index 0000000000..8f1590172e --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h @@ -0,0 +1,32 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ + +class CBC_QRCoderErrorCorrectionLevel; +class CBC_QRCoderFormatInformation { + private: + static const int32_t FORMAT_INFO_MASK_QR; + static const int32_t FORMAT_INFO_DECODE_LOOKUP[32][2]; + static const int32_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(); + 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); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp new file mode 100644 index 0000000000..4d845c4b07 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp @@ -0,0 +1,198 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRCoderMaskUtil::CBC_QRCoderMaskUtil() {} +CBC_QRCoderMaskUtil::~CBC_QRCoderMaskUtil() {} +int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( + CBC_CommonByteMatrix* matrix) { + return ApplyMaskPenaltyRule1Internal(matrix, TRUE) + + ApplyMaskPenaltyRule1Internal(matrix, FALSE); +} + +int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( + CBC_CommonByteMatrix* matrix) { + int32_t penalty = 0; + uint8_t* array = matrix->GetArray(); + int32_t width = matrix->GetWidth(); + int32_t height = matrix->GetHeight(); + for (int32_t y = 0; y < height - 1; y++) { + for (int32_t x = 0; x < width - 1; x++) { + int32_t value = array[y * width + x]; + if (value == array[y * width + x + 1] && + value == array[(y + 1) * width + x] && + value == array[(y + 1) * width + x + 1]) { + penalty++; + } + } + } + return 3 * penalty; +} + +int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( + CBC_CommonByteMatrix* matrix) { + int32_t penalty = 0; + uint8_t* array = matrix->GetArray(); + int32_t width = matrix->GetWidth(); + int32_t height = matrix->GetHeight(); + for (int32_t y = 0; y < height; ++y) { + for (int32_t x = 0; x < width; ++x) { + if (x == 0 && + ((y >= 0 && y <= 6) || (y >= height - 7 && y <= height - 1))) { + continue; + } + if (x == width - 7 && (y >= 0 && y <= 6)) { + continue; + } + if (y == 0 && + ((x >= 0 && x <= 6) || (x >= width - 7 && x <= width - 1))) { + continue; + } + if (y == height - 7 && (x >= 0 && x <= 6)) { + continue; + } + if (x + 6 < width && array[y * width + x] == 1 && + array[y * width + x + 1] == 0 && array[y * width + x + 2] == 1 && + array[y * width + x + 3] == 1 && array[y * width + x + 4] == 1 && + array[y * width + x + 5] == 0 && array[y * width + x + 6] == 1 && + ((x + 10 < width && array[y * width + x + 7] == 0 && + array[y * width + x + 8] == 0 && array[y * width + x + 9] == 0 && + array[y * width + x + 10] == 0) || + (x - 4 >= 0 && array[y * width + x - 1] == 0 && + array[y * width + x - 2] == 0 && array[y * width + x - 3] == 0 && + array[y * width + x - 4] == 0))) { + penalty += 40; + } + if (y + 6 < height && array[y * width + x] == 1 && + array[(y + 1) * width + x] == 0 && array[(y + 2) * width + x] == 1 && + array[(y + 3) * width + x] == 1 && array[(y + 4) * width + x] == 1 && + array[(y + 5) * width + x] == 0 && array[(y + 6) * width + x] == 1 && + ((y + 10 < height && array[(y + 7) * width + x] == 0 && + array[(y + 8) * width + x] == 0 && + array[(y + 9) * width + x] == 0 && + array[(y + 10) * width + x] == 0) || + (y - 4 >= 0 && array[(y - 1) * width + x] == 0 && + array[(y - 2) * width + x] == 0 && + array[(y - 3) * width + x] == 0 && + array[(y - 4) * width + x] == 0))) { + penalty += 40; + } + } + } + return penalty; +} +int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4( + CBC_CommonByteMatrix* matrix) { + int32_t numDarkCells = 0; + uint8_t* array = matrix->GetArray(); + int32_t width = matrix->GetWidth(); + int32_t height = matrix->GetHeight(); + for (int32_t y = 0; y < height; ++y) { + for (int32_t x = 0; x < width; ++x) { + if (array[y * width + x] == 1) { + numDarkCells += 1; + } + } + } + int32_t numTotalCells = matrix->GetHeight() * matrix->GetWidth(); + double darkRatio = (double)numDarkCells / numTotalCells; + return abs((int32_t)(darkRatio * 100 - 50) / 5) * 5 * 10; +} +FX_BOOL CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern, + int32_t x, + int32_t y, + int32_t& e) { + if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) { + e = (BCExceptionInvalidateMaskPattern); + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + } + int32_t intermediate = 0, temp = 0; + switch (maskPattern) { + case 0: + intermediate = (y + x) & 0x1; + break; + case 1: + intermediate = y & 0x1; + break; + case 2: + intermediate = x % 3; + break; + case 3: + intermediate = (y + x) % 3; + break; + case 4: + intermediate = ((y >> 1) + (x / 3)) & 0x1; + break; + case 5: + temp = y * x; + intermediate = (temp & 0x1) + (temp % 3); + break; + case 6: + temp = y * x; + intermediate = (((temp & 0x1) + (temp % 3)) & 0x1); + break; + case 7: + temp = y * x; + intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1); + break; + default: { + e = BCExceptionInvalidateMaskPattern; + BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); + } + } + return intermediate == 0; +} +int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal( + CBC_CommonByteMatrix* matrix, + FX_BOOL isHorizontal) { + int32_t penalty = 0; + int32_t numSameBitCells = 0; + int32_t prevBit = -1; + int32_t width = matrix->GetWidth(); + int32_t height = matrix->GetHeight(); + int32_t iLimit = isHorizontal ? height : width; + int32_t jLimit = isHorizontal ? width : height; + uint8_t* array = matrix->GetArray(); + for (int32_t i = 0; i < iLimit; ++i) { + for (int32_t j = 0; j < jLimit; ++j) { + int32_t bit = isHorizontal ? array[i * width + j] : array[j * width + i]; + if (bit == prevBit) { + numSameBitCells += 1; + if (numSameBitCells == 5) { + penalty += 3; + } else if (numSameBitCells > 5) { + penalty += 1; + } + } else { + numSameBitCells = 1; + prevBit = bit; + } + } + numSameBitCells = 0; + } + return penalty; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h new file mode 100644 index 0000000000..35032a3aaf --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h @@ -0,0 +1,27 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ +class CBC_CommonByteMatrix; +class CBC_QRCoderMaskUtil { + public: + CBC_QRCoderMaskUtil(); + virtual ~CBC_QRCoderMaskUtil(); + static FX_BOOL GetDataMaskBit(int32_t maskPattern, + int32_t x, + int32_t y, + int32_t& e); + + static int32_t ApplyMaskPenaltyRule1(CBC_CommonByteMatrix* matrix); + static int32_t ApplyMaskPenaltyRule2(CBC_CommonByteMatrix* matrix); + static int32_t ApplyMaskPenaltyRule3(CBC_CommonByteMatrix* matrix); + static int32_t ApplyMaskPenaltyRule4(CBC_CommonByteMatrix* matrix); + static int32_t ApplyMaskPenaltyRule1Internal(CBC_CommonByteMatrix* matrix, + FX_BOOL isHorizontal); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp new file mode 100644 index 0000000000..65cf0365cb --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp @@ -0,0 +1,474 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_QRCoderMatrixUtil::POSITION_DETECTION_PATTERN[7][7] = { + {1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 1}, {1, 0, 1, 1, 1, 0, 1}, + {1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0, 1}, {1, 0, 0, 0, 0, 0, 1}, + {1, 1, 1, 1, 1, 1, 1}}; +const int32_t CBC_QRCoderMatrixUtil::HORIZONTAL_SEPARATION_PATTERN[1][8] = { + {0, 0, 0, 0, 0, 0, 0, 0}}; +const int32_t CBC_QRCoderMatrixUtil::VERTICAL_SEPARATION_PATTERN[7][1] = { + {0}, {0}, {0}, {0}, {0}, {0}, {0}}; +const int32_t CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN[5][5] = { + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}}; +const int32_t + CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7] = + // NOLINTNEXTLINE + { + {-1, -1, -1, -1, -1, -1, -1}, {6, 18, -1, -1, -1, -1, -1}, + {6, 22, -1, -1, -1, -1, -1}, {6, 26, -1, -1, -1, -1, -1}, + {6, 30, -1, -1, -1, -1, -1}, {6, 34, -1, -1, -1, -1, -1}, + {6, 22, 38, -1, -1, -1, -1}, {6, 24, 42, -1, -1, -1, -1}, + {6, 26, 46, -1, -1, -1, -1}, {6, 28, 50, -1, -1, -1, -1}, + {6, 30, 54, -1, -1, -1, -1}, {6, 32, 58, -1, -1, -1, -1}, + {6, 34, 62, -1, -1, -1, -1}, {6, 26, 46, 66, -1, -1, -1}, + {6, 26, 48, 70, -1, -1, -1}, {6, 26, 50, 74, -1, -1, -1}, + {6, 30, 54, 78, -1, -1, -1}, {6, 30, 56, 82, -1, -1, -1}, + {6, 30, 58, 86, -1, -1, -1}, {6, 34, 62, 90, -1, -1, -1}, + {6, 28, 50, 72, 94, -1, -1}, {6, 26, 50, 74, 98, -1, -1}, + {6, 30, 54, 78, 102, -1, -1}, {6, 28, 54, 80, 106, -1, -1}, + {6, 32, 58, 84, 110, -1, -1}, {6, 30, 58, 86, 114, -1, -1}, + {6, 34, 62, 90, 118, -1, -1}, {6, 26, 50, 74, 98, 122, -1}, + {6, 30, 54, 78, 102, 126, -1}, {6, 26, 52, 78, 104, 130, -1}, + {6, 30, 56, 82, 108, 134, -1}, {6, 34, 60, 86, 112, 138, -1}, + {6, 30, 58, 86, 114, 142, -1}, {6, 34, 62, 90, 118, 146, -1}, + {6, 30, 54, 78, 102, 126, 150}, {6, 24, 50, 76, 102, 128, 154}, + {6, 28, 54, 80, 106, 132, 158}, {6, 32, 58, 84, 110, 136, 162}, + {6, 26, 54, 82, 110, 138, 166}, {6, 30, 58, 86, 114, 142, 170}, +}; +const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_COORDINATES[15][2] = { + {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 7}, {8, 8}, + {7, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8}, +}; +const int32_t CBC_QRCoderMatrixUtil::VERSION_INFO_POLY = 0x1f25; +const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_POLY = 0x0537; +const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_MASK_PATTERN = 0x5412; + +void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + matrix->clear((uint8_t)-1); +} +void CBC_QRCoderMatrixUtil::BuildMatrix( + CBC_QRCoderBitVector* dataBits, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t version, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + ClearMatrix(matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedBasicPatterns(version, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedTypeInfo(ecLevel, maskPattern, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + MaybeEmbedVersionInfo(version, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedDataBits(dataBits, maskPattern, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + EmbedPositionDetectionPatternsAndSeparators(matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedDarkDotAtLeftBottomCorner(matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + MaybeEmbedPositionAdjustmentPatterns(version, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedTimingPatterns(matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderMatrixUtil::EmbedTypeInfo( + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + CBC_QRCoderBitVector typeInfoBits; + typeInfoBits.Init(); + MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + for (int32_t i = 0; i < typeInfoBits.Size(); i++) { + int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t x1 = TYPE_INFO_COORDINATES[i][0]; + int32_t y1 = TYPE_INFO_COORDINATES[i][1]; + matrix->Set(x1, y1, bit); + if (i < 8) { + int32_t x2 = matrix->GetWidth() - i - 1; + int32_t y2 = 8; + matrix->Set(x2, y2, bit); + } else { + int32_t x2 = 8; + int32_t y2 = matrix->GetHeight() - 7 + (i - 8); + matrix->Set(x2, y2, bit); + } + } +} +void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (version < 7) { + return; + } + CBC_QRCoderBitVector versionInfoBits; + versionInfoBits.Init(); + MakeVersionInfoBits(version, &versionInfoBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t bitIndex = 6 * 3 - 1; + for (int32_t i = 0; i < 6; i++) { + for (int32_t j = 0; j < 3; j++) { + int32_t bit = versionInfoBits.At(bitIndex, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + bitIndex--; + matrix->Set(i, matrix->GetHeight() - 11 + j, bit); + matrix->Set(matrix->GetHeight() - 11 + j, i, bit); + } + } +} +void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL || dataBits == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t bitIndex = 0; + int32_t direction = -1; + int32_t x = matrix->GetWidth() - 1; + int32_t y = matrix->GetHeight() - 1; + while (x > 0) { + if (x == 6) { + x -= 1; + } + while (y >= 0 && y < matrix->GetHeight()) { + if (y == 6) { + y += direction; + continue; + } + for (int32_t i = 0; i < 2; i++) { + int32_t xx = x - i; + if (!IsEmpty(matrix->Get(xx, y))) { + continue; + } + int32_t bit; + if (bitIndex < dataBits->Size()) { + bit = dataBits->At(bitIndex, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + bitIndex++; + } else { + bit = 0; + } + if (maskPattern != -1) { + FX_BOOL bol = + CBC_QRCoderMaskUtil::GetDataMaskBit(maskPattern, xx, y, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (bol) { + bit ^= 0x01; + } + } + matrix->Set(xx, y, bit); + } + y += direction; + } + direction = -direction; + y += direction; + x -= 2; + } + if (bitIndex != dataBits->Size()) { + return; + } +} +int32_t CBC_QRCoderMatrixUtil::CalculateBCHCode(int32_t value, int32_t poly) { + int32_t msbSetInPoly = FindMSBSet(poly); + value <<= msbSetInPoly - 1; + while (FindMSBSet(value) >= msbSetInPoly) { + value ^= poly << (FindMSBSet(value) - msbSetInPoly); + } + return value; +} +void CBC_QRCoderMatrixUtil::MakeTypeInfoBits( + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t maskPattern, + CBC_QRCoderBitVector* bits, + int32_t& e) { + if (bits == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) { + e = BCExceptionBadMask; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern; + BC_EXCEPTION_CHECK_ReturnVoid(e); + bits->AppendBits(typeInfo, 5, e); + int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY); + BC_EXCEPTION_CHECK_ReturnVoid(e); + bits->AppendBits(bchCode, 10, e); + CBC_QRCoderBitVector maskBits; + maskBits.Init(); + maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + bits->XOR(&maskBits, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (bits->Size() != 15) { + e = BCExceptionBitSizeNot15; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version, + CBC_QRCoderBitVector* bits, + int32_t& e) { + if (bits == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + bits->AppendBits(version, 6, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY); + bits->AppendBits(bchCode, 12, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (bits->Size() != 18) { + e = BCExceptionBitSizeNot18; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } +} +FX_BOOL CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) { + return (uint8_t)value == 0xff; +} +FX_BOOL CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) { + return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 || + (uint8_t)value == 0x01); +} +void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) { + int32_t bit = (i + 1) % 2; + if (!IsValidValue(matrix->Get(i, 6))) { + e = BCExceptionInvalidateImageData; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (IsEmpty(matrix->Get(i, 6))) { + matrix->Set(i, 6, bit); + } + if (!IsValidValue(matrix->Get(6, i))) { + e = BCExceptionInvalidateImageData; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (IsEmpty(matrix->Get(6, i))) { + matrix->Set(6, i, bit); + } + } +} +void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner( + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (matrix->Get(8, matrix->GetHeight() - 8) == 0) { + e = BCExceptionHeight_8BeZero; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + matrix->Set(8, matrix->GetHeight() - 8, 1); +} +void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern( + int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t x = 0; x < 8; x++) { + if (!IsEmpty(matrix->Get(xStart + x, yStart))) { + e = BCExceptionInvalidateData; + BC_EXCEPTION_CHECK_ReturnVoid(e) + } + matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]); + } +} +void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern( + int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t y = 0; y < 7; y++) { + if (!IsEmpty(matrix->Get(xStart, yStart + y))) { + e = BCExceptionInvalidateData; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]); + } +} +void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern( + int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t y = 0; y < 5; y++) { + for (int32_t x = 0; x < 5; x++) { + if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) { + e = BCExceptionInvalidateData; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]); + } + } +} +void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern( + int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + for (int32_t y = 0; y < 7; y++) { + for (int32_t x = 0; x < 7; x++) { + if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) { + e = BCExceptionInvalidateData; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]); + } + } +} +void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators( + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + int32_t pdpWidth = 7; + EmbedPositionDetectionPattern(0, 0, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedPositionDetectionPattern(matrix->GetWidth() - pdpWidth, 0, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedPositionDetectionPattern(0, matrix->GetWidth() - pdpWidth, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t hspWidth = 8; + EmbedHorizontalSeparationPattern(0, hspWidth - 1, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedHorizontalSeparationPattern(matrix->GetWidth() - hspWidth, hspWidth - 1, + matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedHorizontalSeparationPattern(0, matrix->GetWidth() - hspWidth, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t vspSize = 7; + EmbedVerticalSeparationPattern(vspSize, 0, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedVerticalSeparationPattern(matrix->GetHeight() - vspSize - 1, 0, matrix, + e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + EmbedVerticalSeparationPattern(vspSize, matrix->GetHeight() - vspSize, matrix, + e); + BC_EXCEPTION_CHECK_ReturnVoid(e); +} +void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns( + int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e) { + if (matrix == NULL) { + e = BCExceptionNullPointer; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if (version < 2) { + return; + } + int32_t index = version - 1; + int32_t const* coordinates = + &(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]); + int32_t numCoordinate = 7; + for (int32_t i = 0; i < numCoordinate; i++) { + for (int32_t j = 0; j < numCoordinate; j++) { + int32_t y = coordinates[i]; + int32_t x = coordinates[j]; + if (x == -1 || y == -1) { + continue; + } + if (IsEmpty(matrix->Get(x, y))) { + EmbedPositionAdjustmentPattern(x - 2, y - 2, matrix, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + } + } +} +int32_t CBC_QRCoderMatrixUtil::FindMSBSet(int32_t value) { + int32_t numDigits = 0; + while (value != 0) { + value >>= 1; + ++numDigits; + } + return numDigits; +} +CBC_QRCoderMatrixUtil::CBC_QRCoderMatrixUtil() {} +CBC_QRCoderMatrixUtil::~CBC_QRCoderMatrixUtil() {} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h new file mode 100644 index 0000000000..feb0bb491c --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h @@ -0,0 +1,87 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ + +class CBC_CommonByteMatrix; +class CBC_QRCoderErrorCorrectionLevel; +class CBC_QRCoderBitVector; +class CBC_QRCoderMatrixUtil { + private: + static const int32_t POSITION_DETECTION_PATTERN[7][7]; + static const int32_t VERTICAL_SEPARATION_PATTERN[7][1]; + static const int32_t HORIZONTAL_SEPARATION_PATTERN[1][8]; + static const int32_t POSITION_ADJUSTMENT_PATTERN[5][5]; + static const int32_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7]; + static const int32_t TYPE_INFO_COORDINATES[15][2]; + static const int32_t VERSION_INFO_POLY; + static const int32_t TYPE_INFO_POLY; + static const int32_t TYPE_INFO_MASK_PATTERN; + + public: + CBC_QRCoderMatrixUtil(); + virtual ~CBC_QRCoderMatrixUtil(); + static void ClearMatrix(CBC_CommonByteMatrix* matrix, int32_t& e); + static void BuildMatrix(CBC_QRCoderBitVector* dataBits, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t version, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedBasicPatterns(int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedTypeInfo(CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedDataBits(CBC_QRCoderBitVector* dataBits, + int32_t maskPattern, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void MaybeEmbedVersionInfo(int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static int32_t FindMSBSet(int32_t value); + static int32_t CalculateBCHCode(int32_t code, int32_t poly); + static void MakeTypeInfoBits(CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t maskPattern, + CBC_QRCoderBitVector* bits, + int32_t& e); + static void MakeVersionInfoBits(int32_t version, + CBC_QRCoderBitVector* bits, + int32_t& e); + static FX_BOOL IsEmpty(int32_t value); + static FX_BOOL IsValidValue(int32_t value); + static void EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, int32_t& e); + static void EmbedDarkDotAtLeftBottomCorner(CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedHorizontalSeparationPattern(int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedVerticalSeparationPattern(int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedPositionAdjustmentPattern(int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedPositionDetectionPattern(int32_t xStart, + int32_t yStart, + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void EmbedPositionDetectionPatternsAndSeparators( + CBC_CommonByteMatrix* matrix, + int32_t& e); + static void MaybeEmbedPositionAdjustmentPatterns(int32_t version, + CBC_CommonByteMatrix* matrix, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp new file mode 100644 index 0000000000..2abdab55a5 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMode.cpp @@ -0,0 +1,179 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sALPHANUMERIC = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sKANJI = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sECI = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sGBK = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sTERMINATOR = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_FIRST_POSITION = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_SECOND_POSITION = NULL; +CBC_QRCoderMode* CBC_QRCoderMode::sSTRUCTURED_APPEND = NULL; + +CBC_QRCoderMode::CBC_QRCoderMode(int32_t* characterCountBitsForVersions, + int32_t x1, + int32_t x2, + int32_t x3, + int32_t bits, + CFX_ByteString name) { + m_characterCountBitsForVersions = characterCountBitsForVersions; + if (m_characterCountBitsForVersions) { + m_characterCountBitsForVersions[0] = x1; + m_characterCountBitsForVersions[1] = x2; + m_characterCountBitsForVersions[2] = x3; + } + m_name += name; + m_bits = bits; +} +CBC_QRCoderMode::~CBC_QRCoderMode() { + FX_Free(m_characterCountBitsForVersions); +} +void CBC_QRCoderMode::Initialize() { + sBYTE = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 16, 16, 0x4, "BYTE"); + sALPHANUMERIC = + new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 9, 11, 13, 0x2, "ALPHANUMERIC"); + sECI = new CBC_QRCoderMode(NULL, 0, 0, 0, 0x7, "ECI"); + sKANJI = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 10, 12, 0x8, "KANJI"); + sNUMERIC = + new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 10, 12, 14, 0x1, "NUMERIC"); + sGBK = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 10, 12, 0x0D, "GBK"); + sTERMINATOR = + new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 0, 0, 0, 0x00, "TERMINATOR"); + sFNC1_FIRST_POSITION = + new CBC_QRCoderMode(NULL, 0, 0, 0, 0x05, "FNC1_FIRST_POSITION"); + sFNC1_SECOND_POSITION = + new CBC_QRCoderMode(NULL, 0, 0, 0, 0x09, "FNC1_SECOND_POSITION"); + sSTRUCTURED_APPEND = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 0, 0, 0, 0x03, + "STRUCTURED_APPEND"); +} +void CBC_QRCoderMode::Finalize() { + delete sBYTE; + delete sALPHANUMERIC; + delete sECI; + delete sKANJI; + delete sNUMERIC; + delete sGBK; + delete sTERMINATOR; + delete sFNC1_FIRST_POSITION; + delete sFNC1_SECOND_POSITION; + delete sSTRUCTURED_APPEND; +} +CBC_QRCoderMode* CBC_QRCoderMode::ForBits(int32_t bits, int32_t& e) { + switch (bits) { + case 0x0: + return sTERMINATOR; + case 0x1: + return sNUMERIC; + case 0x2: + return sALPHANUMERIC; + case 0x3: + return sSTRUCTURED_APPEND; + case 0x4: + return sBYTE; + case 0x5: + return sFNC1_FIRST_POSITION; + case 0x7: + return sECI; + case 0x8: + return sKANJI; + case 0x9: + return sFNC1_SECOND_POSITION; + case 0x0D: + return sGBK; + default: { + e = BCExceptionUnsupportedMode; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + } + return NULL; +} +int32_t CBC_QRCoderMode::GetBits() { + return m_bits; +} +CFX_ByteString CBC_QRCoderMode::GetName() { + return m_name; +} +int32_t CBC_QRCoderMode::GetCharacterCountBits(CBC_QRCoderVersion* version, + int32_t& e) { + if (m_characterCountBitsForVersions == NULL) { + e = BCExceptionCharacterNotThisMode; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + int32_t number = version->GetVersionNumber(); + int32_t offset; + if (number <= 9) { + offset = 0; + } else if (number <= 26) { + offset = 1; + } else { + offset = 2; + } + return m_characterCountBitsForVersions[offset]; +} +void CBC_QRCoderMode::Destroy() { + if (sBYTE) { + delete CBC_QRCoderMode::sBYTE; + sBYTE = NULL; + } + if (sNUMERIC) { + delete CBC_QRCoderMode::sNUMERIC; + sNUMERIC = NULL; + } + if (sALPHANUMERIC) { + delete CBC_QRCoderMode::sALPHANUMERIC; + sALPHANUMERIC = NULL; + } + if (sKANJI) { + delete CBC_QRCoderMode::sKANJI; + sKANJI = NULL; + } + if (sECI) { + delete CBC_QRCoderMode::sECI; + sECI = NULL; + } + if (sGBK) { + delete CBC_QRCoderMode::sGBK; + sGBK = NULL; + } + if (sTERMINATOR) { + delete CBC_QRCoderMode::sTERMINATOR; + sTERMINATOR = NULL; + } + if (sFNC1_FIRST_POSITION) { + delete CBC_QRCoderMode::sFNC1_FIRST_POSITION; + sFNC1_FIRST_POSITION = NULL; + } + if (sFNC1_SECOND_POSITION) { + delete CBC_QRCoderMode::sFNC1_SECOND_POSITION; + sFNC1_SECOND_POSITION = NULL; + } + if (sSTRUCTURED_APPEND) { + delete CBC_QRCoderMode::sSTRUCTURED_APPEND; + sSTRUCTURED_APPEND = NULL; + } +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMode.h b/xfa/fxbarcode/qrcode/BC_QRCoderMode.h new file mode 100644 index 0000000000..e36f7a13b5 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderMode.h @@ -0,0 +1,51 @@ +// 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_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ + +#include <stdint.h> + +#include "core/include/fxcrt/fx_string.h" + +class CBC_QRCoderVersion; + +class CBC_QRCoderMode { + private: + int32_t* m_characterCountBitsForVersions; + int32_t m_bits; + CFX_ByteString m_name; + CBC_QRCoderMode(int32_t* characterCountBitsForVersions, + int32_t x1, + int32_t x2, + int32_t x3, + int32_t bits, + CFX_ByteString name); + CBC_QRCoderMode(); + + public: + static CBC_QRCoderMode* sBYTE; + static CBC_QRCoderMode* sNUMERIC; + static CBC_QRCoderMode* sALPHANUMERIC; + static CBC_QRCoderMode* sKANJI; + static CBC_QRCoderMode* sECI; + static CBC_QRCoderMode* sGBK; + static CBC_QRCoderMode* sTERMINATOR; + static CBC_QRCoderMode* sFNC1_FIRST_POSITION; + static CBC_QRCoderMode* sFNC1_SECOND_POSITION; + static CBC_QRCoderMode* sSTRUCTURED_APPEND; + virtual ~CBC_QRCoderMode(); + + static void Initialize(); + static void Finalize(); + static CBC_QRCoderMode* ForBits(int32_t bits, int32_t& e); + int32_t GetCharacterCountBits(CBC_QRCoderVersion* version, int32_t& e); + int32_t GetBits(); + CFX_ByteString GetName(); + static void Destroy(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp new file mode 100644 index 0000000000..1ff557ede2 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp @@ -0,0 +1,769 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_QRCoderVersion::VERSION_DECODE_INFO[] = { + 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, + 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, + 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; + +void CBC_QRCoderVersion::Initialize() { + VERSION = new CFX_PtrArray(); +} +void CBC_QRCoderVersion::Finalize() { + for (int32_t i = 0; i < VERSION->GetSize(); i++) { + CBC_QRCoderVersion* v = (CBC_QRCoderVersion*)(VERSION->GetAt(i)); + delete v; + } + delete VERSION; +} +CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber, + CBC_QRCoderECBlocks* ecBlocks1, + CBC_QRCoderECBlocks* ecBlocks2, + 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); + int32_t total = 0; + int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock(); + CFX_PtrArray* ecbArray = ecBlocks1->GetECBlocks(); + for (int32_t i = 0; i < ecbArray->GetSize(); i++) { + CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)((*ecbArray)[i]); + total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords); + } + m_totalCodeWords = total; + switch (versionNumber) { + case 1: + break; + case 2: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(18); + break; + case 3: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(22); + break; + case 4: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + break; + case 5: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + break; + case 6: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + break; + case 7: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(22); + m_alignmentPatternCenters.Add(38); + break; + case 8: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(24); + m_alignmentPatternCenters.Add(42); + break; + case 9: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(46); + break; + case 10: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(28); + m_alignmentPatternCenters.Add(50); + break; + case 11: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(54); + break; + case 12: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(32); + m_alignmentPatternCenters.Add(58); + break; + case 13: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + m_alignmentPatternCenters.Add(62); + break; + case 14: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(46); + m_alignmentPatternCenters.Add(66); + break; + case 15: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(48); + m_alignmentPatternCenters.Add(70); + break; + case 16: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(50); + m_alignmentPatternCenters.Add(74); + break; + case 17: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(78); + break; + case 18: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(56); + m_alignmentPatternCenters.Add(82); + break; + case 19: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(86); + break; + case 20: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + m_alignmentPatternCenters.Add(62); + m_alignmentPatternCenters.Add(90); + break; + case 21: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(28); + m_alignmentPatternCenters.Add(50); + m_alignmentPatternCenters.Add(72); + m_alignmentPatternCenters.Add(94); + break; + case 22: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(50); + m_alignmentPatternCenters.Add(74); + m_alignmentPatternCenters.Add(98); + break; + case 23: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(74); + m_alignmentPatternCenters.Add(102); + break; + case 24: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(28); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(80); + m_alignmentPatternCenters.Add(106); + break; + case 25: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(32); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(84); + m_alignmentPatternCenters.Add(110); + break; + case 26: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(86); + m_alignmentPatternCenters.Add(114); + break; + case 27: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + m_alignmentPatternCenters.Add(62); + m_alignmentPatternCenters.Add(90); + m_alignmentPatternCenters.Add(118); + break; + case 28: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(50); + m_alignmentPatternCenters.Add(74); + m_alignmentPatternCenters.Add(98); + m_alignmentPatternCenters.Add(122); + break; + case 29: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(78); + m_alignmentPatternCenters.Add(102); + m_alignmentPatternCenters.Add(126); + break; + case 30: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(52); + m_alignmentPatternCenters.Add(78); + m_alignmentPatternCenters.Add(104); + m_alignmentPatternCenters.Add(130); + break; + case 31: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(56); + m_alignmentPatternCenters.Add(82); + m_alignmentPatternCenters.Add(108); + m_alignmentPatternCenters.Add(134); + break; + case 32: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + m_alignmentPatternCenters.Add(60); + m_alignmentPatternCenters.Add(86); + m_alignmentPatternCenters.Add(112); + m_alignmentPatternCenters.Add(138); + break; + case 33: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(86); + m_alignmentPatternCenters.Add(114); + m_alignmentPatternCenters.Add(142); + break; + case 34: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(34); + m_alignmentPatternCenters.Add(62); + m_alignmentPatternCenters.Add(90); + m_alignmentPatternCenters.Add(118); + m_alignmentPatternCenters.Add(146); + break; + case 35: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(78); + m_alignmentPatternCenters.Add(102); + m_alignmentPatternCenters.Add(126); + m_alignmentPatternCenters.Add(150); + break; + case 36: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(24); + m_alignmentPatternCenters.Add(50); + m_alignmentPatternCenters.Add(76); + m_alignmentPatternCenters.Add(102); + m_alignmentPatternCenters.Add(128); + m_alignmentPatternCenters.Add(154); + break; + case 37: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(28); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(80); + m_alignmentPatternCenters.Add(106); + m_alignmentPatternCenters.Add(132); + m_alignmentPatternCenters.Add(158); + break; + case 38: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(32); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(84); + m_alignmentPatternCenters.Add(110); + m_alignmentPatternCenters.Add(136); + m_alignmentPatternCenters.Add(162); + break; + case 39: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(26); + m_alignmentPatternCenters.Add(54); + m_alignmentPatternCenters.Add(82); + m_alignmentPatternCenters.Add(110); + m_alignmentPatternCenters.Add(138); + m_alignmentPatternCenters.Add(166); + break; + case 40: + m_alignmentPatternCenters.Add(6); + m_alignmentPatternCenters.Add(30); + m_alignmentPatternCenters.Add(58); + m_alignmentPatternCenters.Add(86); + m_alignmentPatternCenters.Add(114); + m_alignmentPatternCenters.Add(142); + m_alignmentPatternCenters.Add(170); + 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++; + } + } +} +int32_t CBC_QRCoderVersion::GetVersionNumber() { + return m_versionNumber; +} +CFX_Int32Array* CBC_QRCoderVersion::GetAlignmentPatternCenters() { + return &m_alignmentPatternCenters; +} +int32_t CBC_QRCoderVersion::GetTotalCodeWords() { + return m_totalCodeWords; +} +int32_t CBC_QRCoderVersion::GetDimensionForVersion() { + return 17 + 4 * m_versionNumber; +} +CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel( + CBC_QRCoderErrorCorrectionLevel* ecLevel) { + return (CBC_QRCoderECBlocks*)m_ecBlocks[ecLevel->Ordinal()]; +} +CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension( + int32_t dimension, + int32_t& e) { + if ((dimension % 4) != 1) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CBC_QRCoderVersion* qcv = GetVersionForNumber((dimension - 17) >> 2, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qcv; +} +CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation( + int32_t versionBits, + int32_t& e) { + int32_t bestDifference = FXSYS_IntMax; + int32_t bestVersion = 0; + for (int32_t i = 0; i < 34; i++) { + int32_t targetVersion = VERSION_DECODE_INFO[i]; + if (targetVersion == versionBits) { + CBC_QRCoderVersion* qcv = GetVersionForNumber(i + 7, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qcv; + } + int32_t bitsDifference = CBC_QRCoderFormatInformation::NumBitsDiffering( + versionBits, targetVersion); + if (bitsDifference < bestDifference) { + bestVersion = i + 7; + bestDifference = bitsDifference; + } + } + if (bestDifference <= 3) { + CBC_QRCoderVersion* qcv = GetVersionForNumber(bestVersion, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qcv; + } + return NULL; +} +CBC_CommonBitMatrix* CBC_QRCoderVersion::BuildFunctionPattern(int32_t& e) { + int32_t dimension = GetDimensionForVersion(); + CBC_CommonBitMatrix* bitMatrix = new CBC_CommonBitMatrix(); + bitMatrix->Init(dimension); + bitMatrix->SetRegion(0, 0, 9, 9, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + bitMatrix->SetRegion(dimension - 8, 0, 8, 9, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + bitMatrix->SetRegion(0, dimension - 8, 9, 8, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t max = m_alignmentPatternCenters.GetSize(); + for (int32_t x = 0; x < max; x++) { + int32_t i = m_alignmentPatternCenters[x] - 2; + for (int32_t y = 0; y < max; y++) { + if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { + continue; + } + bitMatrix->SetRegion(m_alignmentPatternCenters[y] - 2, i, 5, 5, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + } + bitMatrix->SetRegion(6, 9, 1, dimension - 17, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + bitMatrix->SetRegion(9, 6, dimension - 17, 1, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (m_versionNumber > 6) { + bitMatrix->SetRegion(dimension - 11, 0, 3, 6, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + bitMatrix->SetRegion(0, dimension - 11, 6, 3, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return bitMatrix; +} +CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber( + int32_t versionNumber, + int32_t& e) { + if (VERSION->GetSize() == 0) { + VERSION->Add(new CBC_QRCoderVersion( + 1, new CBC_QRCoderECBlocks(7, new CBC_QRCoderECB(1, 19)), + new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 16)), + new CBC_QRCoderECBlocks(13, new CBC_QRCoderECB(1, 13)), + new CBC_QRCoderECBlocks(17, new CBC_QRCoderECB(1, 9)))); + VERSION->Add(new CBC_QRCoderVersion( + 2, new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 34)), + new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(1, 28)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(1, 22)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 3, new CBC_QRCoderECBlocks(15, new CBC_QRCoderECB(1, 55)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 44)), + new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 17)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 4, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(1, 80)), + new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 32)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(2, 24)), + new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 9)))); + VERSION->Add(new CBC_QRCoderVersion( + 5, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 108)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 43)), + new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 15), + new CBC_QRCoderECB(2, 16)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 11), + new CBC_QRCoderECB(2, 12)))); + VERSION->Add(new CBC_QRCoderVersion( + 6, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68)), + new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 27)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 19)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 15)))); + VERSION->Add(new CBC_QRCoderVersion( + 7, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(2, 78)), + new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(4, 31)), + new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 14), + new CBC_QRCoderECB(4, 15)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 13), + new CBC_QRCoderECB(1, 14)))); + VERSION->Add(new CBC_QRCoderVersion( + 8, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 97)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 38), + new CBC_QRCoderECB(2, 39)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(4, 18), + new CBC_QRCoderECB(2, 19)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 14), + new CBC_QRCoderECB(2, 15)))); + VERSION->Add(new CBC_QRCoderVersion( + 9, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 116)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(3, 36), + new CBC_QRCoderECB(2, 37)), + new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 16), + new CBC_QRCoderECB(4, 17)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 12), + new CBC_QRCoderECB(4, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 10, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68), + new CBC_QRCoderECB(2, 69)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 43), + new CBC_QRCoderECB(1, 44)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(6, 19), + new CBC_QRCoderECB(2, 20)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 15), + new CBC_QRCoderECB(2, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 11, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 81)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 50), + new CBC_QRCoderECB(4, 51)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 22), + new CBC_QRCoderECB(4, 23)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(3, 12), + new CBC_QRCoderECB(8, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 12, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 92), + new CBC_QRCoderECB(2, 93)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(6, 36), + new CBC_QRCoderECB(2, 37)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 20), + new CBC_QRCoderECB(6, 21)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 14), + new CBC_QRCoderECB(4, 15)))); + VERSION->Add(new CBC_QRCoderVersion( + 13, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 107)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(8, 37), + new CBC_QRCoderECB(1, 38)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(8, 20), + new CBC_QRCoderECB(4, 21)), + new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(12, 11), + new CBC_QRCoderECB(4, 12)))); + VERSION->Add(new CBC_QRCoderVersion( + 14, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 115), + new CBC_QRCoderECB(1, 116)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 40), + new CBC_QRCoderECB(5, 41)), + new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(11, 16), + new CBC_QRCoderECB(5, 17)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12), + new CBC_QRCoderECB(5, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 15, new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(5, 87), + new CBC_QRCoderECB(1, 88)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 41), + new CBC_QRCoderECB(5, 42)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 24), + new CBC_QRCoderECB(7, 25)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12), + new CBC_QRCoderECB(7, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 16, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 98), + new CBC_QRCoderECB(1, 99)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 45), + new CBC_QRCoderECB(3, 46)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(15, 19), + new CBC_QRCoderECB(2, 20)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 15), + new CBC_QRCoderECB(13, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 17, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 107), + new CBC_QRCoderECB(5, 108)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46), + new CBC_QRCoderECB(1, 47)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 22), + new CBC_QRCoderECB(15, 23)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14), + new CBC_QRCoderECB(17, 15)))); + VERSION->Add(new CBC_QRCoderVersion( + 18, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 120), + new CBC_QRCoderECB(1, 121)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 43), + new CBC_QRCoderECB(4, 44)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22), + new CBC_QRCoderECB(1, 23)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14), + new CBC_QRCoderECB(19, 15)))); + VERSION->Add(new CBC_QRCoderVersion( + 19, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 113), + new CBC_QRCoderECB(4, 114)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 44), + new CBC_QRCoderECB(11, 45)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 21), + new CBC_QRCoderECB(4, 22)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 13), + new CBC_QRCoderECB(16, 14)))); + VERSION->Add(new CBC_QRCoderVersion( + 20, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 107), + new CBC_QRCoderECB(5, 108)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 41), + new CBC_QRCoderECB(13, 42)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24), + new CBC_QRCoderECB(5, 25)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(15, 15), + new CBC_QRCoderECB(10, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 21, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 116), + new CBC_QRCoderECB(4, 117)), + new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 42)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22), + new CBC_QRCoderECB(6, 23)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 16), + new CBC_QRCoderECB(6, 17)))); + VERSION->Add(new CBC_QRCoderVersion( + 22, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 111), + new CBC_QRCoderECB(7, 112)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 46)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24), + new CBC_QRCoderECB(16, 25)), + new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(34, 13)))); + VERSION->Add(new CBC_QRCoderVersion( + 23, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 121), + new CBC_QRCoderECB(5, 122)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 47), + new CBC_QRCoderECB(14, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24), + new CBC_QRCoderECB(14, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(16, 15), + new CBC_QRCoderECB(14, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 24, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 117), + new CBC_QRCoderECB(4, 118)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 45), + new CBC_QRCoderECB(14, 46)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24), + new CBC_QRCoderECB(16, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(30, 16), + new CBC_QRCoderECB(2, 17)))); + VERSION->Add(new CBC_QRCoderVersion( + 25, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(8, 106), + new CBC_QRCoderECB(4, 107)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(8, 47), + new CBC_QRCoderECB(13, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24), + new CBC_QRCoderECB(22, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15), + new CBC_QRCoderECB(13, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 26, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 114), + new CBC_QRCoderECB(2, 115)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 46), + new CBC_QRCoderECB(4, 47)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(28, 22), + new CBC_QRCoderECB(6, 23)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(33, 16), + new CBC_QRCoderECB(4, 17)))); + VERSION->Add(new CBC_QRCoderVersion( + 27, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 122), + new CBC_QRCoderECB(4, 123)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(22, 45), + new CBC_QRCoderECB(3, 46)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 23), + new CBC_QRCoderECB(26, 24)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 15), + new CBC_QRCoderECB(28, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 28, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 117), + new CBC_QRCoderECB(10, 118)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 45), + new CBC_QRCoderECB(23, 46)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 24), + new CBC_QRCoderECB(31, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15), + new CBC_QRCoderECB(31, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 29, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 116), + new CBC_QRCoderECB(7, 117)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(21, 45), + new CBC_QRCoderECB(7, 46)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 23), + new CBC_QRCoderECB(37, 24)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15), + new CBC_QRCoderECB(26, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 30, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 115), + new CBC_QRCoderECB(10, 116)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 47), + new CBC_QRCoderECB(10, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24), + new CBC_QRCoderECB(25, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15), + new CBC_QRCoderECB(25, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 31, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115), + new CBC_QRCoderECB(3, 116)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 46), + new CBC_QRCoderECB(29, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 24), + new CBC_QRCoderECB(1, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15), + new CBC_QRCoderECB(28, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 32, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46), + new CBC_QRCoderECB(23, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 24), + new CBC_QRCoderECB(35, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15), + new CBC_QRCoderECB(35, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 33, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115), + new CBC_QRCoderECB(1, 116)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46), + new CBC_QRCoderECB(21, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(29, 24), + new CBC_QRCoderECB(19, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15), + new CBC_QRCoderECB(46, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 34, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115), + new CBC_QRCoderECB(6, 116)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46), + new CBC_QRCoderECB(23, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(44, 24), + new CBC_QRCoderECB(7, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(59, 16), + new CBC_QRCoderECB(1, 17)))); + VERSION->Add(new CBC_QRCoderVersion( + 35, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 121), + new CBC_QRCoderECB(7, 122)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(12, 47), + new CBC_QRCoderECB(26, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(39, 24), + new CBC_QRCoderECB(14, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15), + new CBC_QRCoderECB(41, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 36, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 121), + new CBC_QRCoderECB(14, 122)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 47), + new CBC_QRCoderECB(34, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(46, 24), + new CBC_QRCoderECB(10, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 15), + new CBC_QRCoderECB(64, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 37, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 122), + new CBC_QRCoderECB(4, 123)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(29, 46), + new CBC_QRCoderECB(14, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(49, 24), + new CBC_QRCoderECB(10, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(24, 15), + new CBC_QRCoderECB(46, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 38, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 122), + new CBC_QRCoderECB(18, 123)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(13, 46), + new CBC_QRCoderECB(32, 47)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(48, 24), + new CBC_QRCoderECB(14, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 15), + new CBC_QRCoderECB(32, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 39, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 117), + new CBC_QRCoderECB(4, 118)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(40, 47), + new CBC_QRCoderECB(7, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(43, 24), + new CBC_QRCoderECB(22, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 15), + new CBC_QRCoderECB(67, 16)))); + VERSION->Add(new CBC_QRCoderVersion( + 40, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 118), + new CBC_QRCoderECB(6, 119)), + new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(18, 47), + new CBC_QRCoderECB(31, 48)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(34, 24), + new CBC_QRCoderECB(34, 25)), + new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 15), + new CBC_QRCoderECB(61, 16)))); + } + if (versionNumber < 1 || versionNumber > 40) { + e = BCExceptionIllegalArgument; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + return (CBC_QRCoderVersion*)(*VERSION)[versionNumber - 1]; +} +void CBC_QRCoderVersion::Destroy() { + int32_t i; + for (i = 0; i < VERSION->GetSize(); i++) { + delete ((CBC_QRCoderVersion*)(*VERSION)[i]); + } +} diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h new file mode 100644 index 0000000000..dd2b0c6be8 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.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_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_QRCoderECBlocks; +class CBC_CommonBitMatrix; +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(); + static void Finalize(); + + int32_t GetVersionNumber(); + int32_t GetTotalCodeWords(); + int32_t GetDimensionForVersion(); + CBC_CommonBitMatrix* BuildFunctionPattern(int32_t& e); + CFX_Int32Array* GetAlignmentPatternCenters(); + CBC_QRCoderECBlocks* GetECBlocksForLevel( + CBC_QRCoderErrorCorrectionLevel* ecLevel); + static CBC_QRCoderVersion* GetVersionForNumber(int32_t versionNumber, + int32_t& e); + static CBC_QRCoderVersion* GetProvisionalVersionForDimension( + int32_t dimension, + int32_t& e); + static CBC_QRCoderVersion* DecodeVersionInformation(int32_t versionBits, + int32_t& e); + static void Destroy(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp new file mode 100644 index 0000000000..9805ac9af8 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp @@ -0,0 +1,111 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRDataBlock.h" + +#include <memory> + +#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRDataBlock::CBC_QRDataBlock(int32_t numDataCodewords, + CFX_ByteArray* codewords) + : m_numDataCodewords(numDataCodewords), m_codewords(codewords) {} +CBC_QRDataBlock::~CBC_QRDataBlock() { + delete m_codewords; +} +int32_t CBC_QRDataBlock::GetNumDataCodewords() { + return m_numDataCodewords; +} +CFX_ByteArray* CBC_QRDataBlock::GetCodewords() { + return m_codewords; +} +CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks( + CFX_ByteArray* rawCodewords, + CBC_QRCoderVersion* version, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t& e) { + if (rawCodewords->GetSize() != version->GetTotalCodeWords()) { + e = BCExceptionIllegalArgument; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); + int32_t totalBlocks = 0; + CFX_PtrArray* ecBlockArray = ecBlocks->GetECBlocks(); + int32_t i = 0; + for (i = 0; i < ecBlockArray->GetSize(); i++) { + totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount(); + } + std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); + result->SetSize(totalBlocks); + int32_t numResultBlocks = 0; + for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) { + CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)(*ecBlockArray)[j]; + for (int32_t k = 0; k < ecBlock->GetCount(); k++) { + int32_t numDataCodewords = ecBlock->GetDataCodeWords(); + int32_t numBlockCodewords = + ecBlocks->GetECCodeWordsPerBlock() + numDataCodewords; + CFX_ByteArray* bytearray = new CFX_ByteArray(); + bytearray->SetSize(numBlockCodewords); + (*result)[numResultBlocks++] = + new CBC_QRDataBlock(numDataCodewords, bytearray); + } + } + int32_t shorterBlocksTotalCodewords = + ((CBC_QRDataBlock*)(*result)[0])->m_codewords->GetSize(); + int32_t longerBlocksStartAt = result->GetSize() - 1; + while (longerBlocksStartAt >= 0) { + int32_t numCodewords = ((CBC_QRDataBlock*)(*result)[longerBlocksStartAt]) + ->m_codewords->GetSize(); + if (numCodewords == shorterBlocksTotalCodewords) { + break; + } + longerBlocksStartAt--; + } + longerBlocksStartAt++; + int32_t shorterBlocksNumDataCodewords = + shorterBlocksTotalCodewords - ecBlocks->GetECCodeWordsPerBlock(); + int32_t rawCodewordsOffset = 0; + 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++]; + } + } + for (x = longerBlocksStartAt; x < numResultBlocks; x++) { + (*(((CBC_QRDataBlock*)(*result)[x]) + ->m_codewords))[shorterBlocksNumDataCodewords] = + (*rawCodewords)[rawCodewordsOffset++]; + } + int32_t max = ((CBC_QRDataBlock*)(*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] = + (*rawCodewords)[rawCodewordsOffset++]; + } + } + return result.release(); +} diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.h b/xfa/fxbarcode/qrcode/BC_QRDataBlock.h new file mode 100644 index 0000000000..8e11ab845c --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDataBlock.h @@ -0,0 +1,30 @@ +// 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_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ + +#include "core/include/fxcrt/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); + + public: + virtual ~CBC_QRDataBlock(); + int32_t GetNumDataCodewords(); + CFX_ByteArray* GetCodewords(); + static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords, + CBC_QRCoderVersion* version, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp b/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp new file mode 100644 index 0000000000..20f94069f4 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp @@ -0,0 +1,118 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#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; + +void CBC_QRDataMask::Initialize() { + DATA_MASKS = new CFX_PtrArray(); + N_DATA_MASKS = BuildDataMasks(); +} +void CBC_QRDataMask::Finalize() { + Destroy(); + delete DATA_MASKS; +} +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; + } + } +} +void CBC_QRDataMask::UnmaskBitMatirx(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)) { + 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); + } + return (CBC_QRDataMask*)(*DATA_MASKS)[reference]; +} +class DataMask000 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { return ((x + y) % 2) == 0; } +}; +class DataMask001 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { return (x % 2) == 0; } +}; +class DataMask010 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { return y % 3 == 0; } +}; +class DataMask011 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { return (x + y) % 3 == 0; } +}; +class DataMask100 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { + return (((x >> 1) + (y / 3)) % 2) == 0; + } +}; +class DataMask101 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { + size_t temp = x * y; + return (temp % 2) + (temp % 3) == 0; + } +}; +class DataMask110 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { + size_t temp = x * y; + return (((temp % 2) + (temp % 3)) % 2) == 0; + } +}; +class DataMask111 : public CBC_QRDataMask { + public: + FX_BOOL IsMasked(int32_t x, int32_t y) { + return ((((x + y) % 2) + ((x * y) % 3)) % 2) == 0; + } +}; +int32_t CBC_QRDataMask::BuildDataMasks() { + DATA_MASKS->Add(new DataMask000); + DATA_MASKS->Add(new DataMask001); + DATA_MASKS->Add(new DataMask010); + DATA_MASKS->Add(new DataMask011); + DATA_MASKS->Add(new DataMask100); + DATA_MASKS->Add(new DataMask101); + DATA_MASKS->Add(new DataMask110); + DATA_MASKS->Add(new DataMask111); + return DATA_MASKS->GetSize(); +} +CBC_QRDataMask::CBC_QRDataMask() {} +CBC_QRDataMask::~CBC_QRDataMask() {} diff --git a/xfa/fxbarcode/qrcode/BC_QRDataMask.h b/xfa/fxbarcode/qrcode/BC_QRDataMask.h new file mode 100644 index 0000000000..5893149d3b --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDataMask.h @@ -0,0 +1,28 @@ +// 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_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ + +#include "core/include/fxcrt/fx_basic.h" + +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(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp new file mode 100644 index 0000000000..8919c3a9a1 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp @@ -0,0 +1,273 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_UtilCodingConvert.h" +#include "xfa/fxbarcode/common/BC_CommonBitSource.h" +#include "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h" +#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h" +#include "xfa/fxbarcode/common/BC_CommonECI.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" +#include "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" + +const FX_CHAR* CBC_QRDecodedBitStreamParser::UTF_8 = "utf8"; +const FX_CHAR CBC_QRDecodedBitStreamParser::ALPHANUMERIC_CHARS[45] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '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', ' ', '$', '%', '*', '+', '-', '.', '/', ':'}; + +CBC_QRDecodedBitStreamParser::CBC_QRDecodedBitStreamParser() {} +CBC_QRDecodedBitStreamParser::~CBC_QRDecodedBitStreamParser() {} +CBC_CommonDecoderResult* CBC_QRDecodedBitStreamParser::Decode( + CFX_ByteArray* bytes, + CBC_QRCoderVersion* version, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t byteModeDecode, + int32_t& e) { + CBC_CommonBitSource bits(bytes); + CFX_ByteString result; + CBC_CommonCharacterSetECI* currentCharacterSetECI = NULL; + FX_BOOL fc1Infact = FALSE; + CFX_Int32Array byteSegments; + CBC_QRCoderMode* mode = NULL; + do { + if (bits.Available() < 4) { + mode = CBC_QRCoderMode::sTERMINATOR; + } else { + int32_t iTemp1 = bits.ReadBits(4, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + mode = CBC_QRCoderMode::ForBits(iTemp1, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (mode == NULL) { + e = BCExceptionUnSupportMode; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + } + if (!(mode == CBC_QRCoderMode::sTERMINATOR)) { + if (mode == CBC_QRCoderMode::sFNC1_FIRST_POSITION || + mode == CBC_QRCoderMode::sFNC1_SECOND_POSITION) { + fc1Infact = TRUE; + } else if (mode == CBC_QRCoderMode::sSTRUCTURED_APPEND) { + bits.ReadBits(16, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else if (mode == CBC_QRCoderMode::sECI) { + int32_t value = ParseECIValue(&bits, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + currentCharacterSetECI = + CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(value); + } else { + if (mode == CBC_QRCoderMode::sGBK) { + bits.ReadBits(4, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t numBits = mode->GetCharacterCountBits(version, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t count = bits.ReadBits(numBits, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + if (mode == CBC_QRCoderMode::sNUMERIC) { + DecodeNumericSegment(&bits, result, count, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) { + DecodeAlphanumericSegment(&bits, result, count, fc1Infact, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else if (mode == CBC_QRCoderMode::sBYTE) { + DecodeByteSegment(&bits, result, count, currentCharacterSetECI, + &byteSegments, byteModeDecode, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else if (mode == CBC_QRCoderMode::sGBK) { + DecodeGBKSegment(&bits, result, count, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else if (mode == CBC_QRCoderMode::sKANJI) { + DecodeKanjiSegment(&bits, result, count, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } else { + e = BCExceptionUnSupportMode; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + } + } + } while (!(mode == CBC_QRCoderMode::sTERMINATOR)); + CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); + tempCd->Init(*bytes, result, byteSegments, ecLevel, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return tempCd; +} +void CBC_QRDecodedBitStreamParser::DecodeGBKSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e) { + CFX_ByteString buffer; + while (count > 0) { + int32_t twoBytes = bits->ReadBits(13, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060); + if (assembledTwoBytes <= 0x0095d) { + assembledTwoBytes += 0x0a1a1; + } else { + assembledTwoBytes += 0x0a6a1; + } + buffer += (uint8_t)(assembledTwoBytes >> 8); + buffer += (uint8_t)assembledTwoBytes; + count--; + } + CBC_UtilCodingConvert::LocaleToUtf8(buffer, result); +} +void CBC_QRDecodedBitStreamParser::DecodeKanjiSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e) { + CFX_ByteString buffer; + while (count > 0) { + int32_t twoBytes = bits->ReadBits(13, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + int32_t assembledTwoBytes = ((twoBytes / 0x0c0) << 8) | (twoBytes % 0x0c0); + if (assembledTwoBytes <= 0x01f00) { + assembledTwoBytes += 0x08140; + } else { + assembledTwoBytes += 0x0c140; + } + buffer += (uint8_t)(assembledTwoBytes >> 8); + buffer += (uint8_t)assembledTwoBytes; + count--; + } + CBC_UtilCodingConvert::LocaleToUtf8(buffer, result); +} +void CBC_QRDecodedBitStreamParser::DecodeByteSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + CBC_CommonCharacterSetECI* currentCharacterSetECI, + CFX_Int32Array* byteSegments, + int32_t byteModeDecode, + int32_t& e) { + if (count < 0) { + e = BCExceptionNotFound; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + if ((count << 3) > bits->Available()) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + uint8_t* readBytes = FX_Alloc(uint8_t, count); + FXSYS_memset(readBytes, 0x00, count); + for (int32_t i = 0; i < count; i++) { + readBytes[i] = (uint8_t)bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + CFX_ByteString bs(readBytes, count); + result += bs; + FX_Free(readBytes); +} +void CBC_QRDecodedBitStreamParser::DecodeAlphanumericSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + FX_BOOL fac1InEffect, + int32_t& e) { + int32_t start = result.GetLength(); + while (count > 1) { + int32_t nextTwoCharsBits = bits->ReadBits(11, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + BC_FX_ByteString_Append(result, 1, + ALPHANUMERIC_CHARS[nextTwoCharsBits / 45]); + BC_FX_ByteString_Append(result, 1, + ALPHANUMERIC_CHARS[nextTwoCharsBits % 45]); + count -= 2; + } + if (count == 1) { + int32_t itemp = bits->ReadBits(6, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[itemp]); + } + if (fac1InEffect) { + for (int32_t i = start; i < result.GetLength(); i++) { + if (result[i] == '%') { + if ((i < result.GetLength() - 1) && result[i + 1] == '%') { + result.Delete(i + 1, 1); + } else { + result.SetAt(i, (FX_CHAR)0x1d); + } + } + } + } +} +void CBC_QRDecodedBitStreamParser::DecodeNumericSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e) { + while (count >= 3) { + int32_t threeDigitsBits = bits->ReadBits(10, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (threeDigitsBits >= 1000) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + BC_FX_ByteString_Append(result, 1, + ALPHANUMERIC_CHARS[threeDigitsBits / 100]); + BC_FX_ByteString_Append(result, 1, + ALPHANUMERIC_CHARS[(threeDigitsBits / 10) % 10]); + BC_FX_ByteString_Append(result, 1, + ALPHANUMERIC_CHARS[threeDigitsBits % 10]); + count -= 3; + } + if (count == 2) { + int32_t twoDigitBits = bits->ReadBits(7, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (twoDigitBits >= 100) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits / 10]); + BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits % 10]); + } else if (count == 1) { + int32_t digitBits = bits->ReadBits(4, e); + BC_EXCEPTION_CHECK_ReturnVoid(e); + if (digitBits >= 10) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[digitBits]); + } +} +const CFX_ByteString CBC_QRDecodedBitStreamParser::GuessEncoding( + CFX_ByteArray* bytes) { + return *UTF_8; +} +int32_t CBC_QRDecodedBitStreamParser::ParseECIValue(CBC_CommonBitSource* bits, + int32_t& e) { + int32_t firstByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + if ((firstByte & 0x80) == 0) { + return firstByte & 0x7f; + } else if ((firstByte & 0xc0) == 0x80) { + int32_t secondByte = bits->ReadBits(8, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + return ((firstByte & 0x3f) << 8) | secondByte; + } else if ((firstByte & 0xe0) == 0xc0) { + int32_t secondThirdByte = bits->ReadBits(16, e); + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + return ((firstByte & 0x1f) << 16) | secondThirdByte; + } + e = BCExceptionBadECI; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + return 0; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h new file mode 100644 index 0000000000..0943bc0a4e --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h @@ -0,0 +1,59 @@ +// 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_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ + +class CBC_CommonDecoderResult; +class CBC_QRCoderErrorCorrectionLevel; +class CBC_CommonBitSource; +class CBC_QRCoderVersion; +class CBC_CommonCharacterSetECI; +class CBC_QRDecodedBitStreamParser { + private: + static const FX_CHAR ALPHANUMERIC_CHARS[45]; + static const FX_CHAR* UTF_8; + CBC_QRDecodedBitStreamParser(); + + public: + virtual ~CBC_QRDecodedBitStreamParser(); + static CBC_CommonDecoderResult* Decode( + CFX_ByteArray* bytes, + CBC_QRCoderVersion* version, + CBC_QRCoderErrorCorrectionLevel* ecLevel, + int32_t byteModeDecode, + int32_t& e); + + static const CFX_ByteString GuessEncoding(CFX_ByteArray* bytes); + static int32_t ParseECIValue(CBC_CommonBitSource* bits, int32_t& e); + static void DecodeGBKSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e); + static void DecodeKanjiSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e); + static void DecodeNumericSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + int32_t& e); + static void DecodeAlphanumericSegment(CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + FX_BOOL fac1InEffect, + int32_t& e); + static void DecodeByteSegment( + CBC_CommonBitSource* bits, + CFX_ByteString& result, + int32_t count, + CBC_CommonCharacterSetECI* currentCharacterSetECI, + CFX_Int32Array* byteSegments, + int32_t byteModeDecode, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp new file mode 100644 index 0000000000..030ee43c20 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp @@ -0,0 +1,278 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRDetector.h" + +#include <algorithm> +#include <memory> + +#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_QRAlignmentPatternFinder.h" +#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h" +#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h" +#include "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" +#include "xfa/fxbarcode/qrcode/BC_QRGridSampler.h" + +CBC_QRDetector::CBC_QRDetector(CBC_CommonBitMatrix* image) : m_image(image) {} +CBC_QRDetector::~CBC_QRDetector() {} +CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { + CBC_QRFinderPatternFinder finder(m_image); + std::unique_ptr<CBC_QRFinderPatternInfo> info(finder.Find(hints, e)); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRDetectorResult* qdr = ProcessFinderPatternInfo(info.get(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qdr; +} +CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( + CBC_QRFinderPatternInfo* info, + int32_t& e) { + std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); + std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight()); + std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); + FX_FLOAT moduleSize = + CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); + if (moduleSize < 1.0f) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t dimension = ComputeDimension(topLeft.get(), topRight.get(), + bottomLeft.get(), moduleSize, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + CBC_QRCoderVersion* provisionalVersion = + CBC_QRCoderVersion::GetProvisionalVersionForDimension(dimension, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + int32_t modulesBetweenFPCenters = + provisionalVersion->GetDimensionForVersion() - 7; + CBC_QRAlignmentPattern* alignmentPattern = NULL; + if (provisionalVersion->GetAlignmentPatternCenters()->GetSize() > 0) { + FX_FLOAT bottomRightX = + topRight->GetX() - topLeft->GetX() + bottomLeft->GetX(); + FX_FLOAT bottomRightY = + topRight->GetY() - topLeft->GetY() + bottomLeft->GetY(); + FX_FLOAT correctionToTopLeft = + 1.0f - 3.0f / (FX_FLOAT)modulesBetweenFPCenters; + FX_FLOAT xtemp = (topLeft->GetX() + + correctionToTopLeft * (bottomRightX - topLeft->GetX())); + int32_t estAlignmentX = (int32_t)xtemp; + FX_FLOAT ytemp = (topLeft->GetY() + + correctionToTopLeft * (bottomRightY - topLeft->GetY())); + int32_t estAlignmentY = (int32_t)ytemp; + for (int32_t i = 4; i <= 16; i <<= 1) { + CBC_QRAlignmentPattern* temp = FindAlignmentInRegion( + moduleSize, estAlignmentX, estAlignmentY, (FX_FLOAT)i, e); + alignmentPattern = temp; + break; + } + } + CBC_CommonBitMatrix* bits = + 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()); + points->Add(alignmentPattern); + } + return new CBC_QRDetectorResult(bits, points); +} +CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid( + CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* alignmentPattern, + int32_t dimension, + int32_t& e) { + FX_FLOAT dimMinusThree = (FX_FLOAT)dimension - 3.5f; + FX_FLOAT bottomRightX; + FX_FLOAT bottomRightY; + FX_FLOAT sourceBottomRightX; + FX_FLOAT sourceBottomRightY; + if (alignmentPattern) { + bottomRightX = alignmentPattern->GetX(); + bottomRightY = alignmentPattern->GetY(); + sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f; + } else { + bottomRightX = (topRight->GetX() - topLeft->GetX()) + bottomLeft->GetX(); + bottomRightY = (topRight->GetY() - topLeft->GetY()) + bottomLeft->GetY(); + sourceBottomRightX = sourceBottomRightY = dimMinusThree; + } + CBC_QRGridSampler& sampler = CBC_QRGridSampler::GetInstance(); + CBC_CommonBitMatrix* cbm = sampler.SampleGrid( + image, dimension, dimension, 3.5f, 3.5f, dimMinusThree, 3.5f, + sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree, + topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(), + bottomRightX, bottomRightY, bottomLeft->GetX(), bottomLeft->GetY(), e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return cbm; +} +int32_t CBC_QRDetector::ComputeDimension(CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft, + FX_FLOAT moduleSize, + int32_t& e) { + int32_t tltrCentersDimension = Round( + CBC_QRFinderPatternFinder::Distance(topLeft, topRight) / moduleSize); + int32_t tlblCentersDimension = Round( + CBC_QRFinderPatternFinder::Distance(topLeft, bottomLeft) / moduleSize); + int32_t dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; + switch (dimension & 0x03) { + case 0: + dimension++; + break; + case 2: + dimension--; + break; + case 3: { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, 0); + } + } + return dimension; +} +FX_FLOAT CBC_QRDetector::CalculateModuleSize(CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft) { + return (CalculateModuleSizeOneWay(topLeft, topRight) + + CalculateModuleSizeOneWay(topLeft, bottomLeft)) / + 2.0f; +} +FX_FLOAT CBC_QRDetector::CalculateModuleSizeOneWay( + CBC_ResultPoint* pattern, + CBC_ResultPoint* otherPattern) { + FX_FLOAT moduleSizeEst1 = SizeOfBlackWhiteBlackRunBothWays( + (int32_t)pattern->GetX(), (int32_t)pattern->GetY(), + (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY()); + FX_FLOAT moduleSizeEst2 = SizeOfBlackWhiteBlackRunBothWays( + (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY(), + (int32_t)pattern->GetX(), (int32_t)pattern->GetY()); + if (FXSYS_isnan(moduleSizeEst1)) { + return moduleSizeEst2; + } + if (FXSYS_isnan(moduleSizeEst2)) { + return moduleSizeEst1; + } + return (moduleSizeEst1 + moduleSizeEst2) / 14.0f; +} +int32_t CBC_QRDetector::Round(FX_FLOAT d) { + return (int32_t)(d + 0.5f); +} +FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRunBothWays(int32_t fromX, + int32_t fromY, + int32_t toX, + int32_t toY) { + FX_FLOAT result = SizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY); + int32_t otherToX = fromX - (toX - fromX); + if (otherToX < 0) { + otherToX = -1; + } else if (otherToX >= m_image->GetWidth()) { + otherToX = m_image->GetWidth(); + } + int32_t otherToY = fromY - (toY - fromY); + if (otherToY < 0) { + otherToY = -1; + } else if (otherToY >= m_image->GetHeight()) { + otherToY = m_image->GetHeight(); + } + result += SizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); + return result - 1.0f; +} +FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRun(int32_t fromX, + int32_t fromY, + int32_t toX, + int32_t toY) { + FX_BOOL steep = FXSYS_abs(toY - fromY) > FXSYS_abs(toX - fromX); + if (steep) { + int32_t temp = fromX; + fromX = fromY; + fromY = temp; + temp = toX; + toX = toY; + toY = temp; + } + int32_t dx = FXSYS_abs(toX - fromX); + int32_t dy = FXSYS_abs(toY - fromY); + int32_t error = -dx >> 1; + int32_t ystep = fromY < toY ? 1 : -1; + int32_t xstep = fromX < toX ? 1 : -1; + int32_t state = 0; + for (int32_t x = fromX, y = fromY; x != toX; x += xstep) { + int32_t realX = steep ? y : x; + int32_t realY = steep ? x : y; + if (state == 1) { + if (m_image->Get(realX, realY)) { + state++; + } + } else { + if (!m_image->Get(realX, realY)) { + state++; + } + } + if (state == 3) { + int32_t diffX = x - fromX; + int32_t diffY = y - fromY; + return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY)); + } + error += dy; + if (error > 0) { + y += ystep; + error -= dx; + } + } + int32_t diffX = toX - fromX; + int32_t diffY = toY - fromY; + return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY)); +} +CBC_QRAlignmentPattern* CBC_QRDetector::FindAlignmentInRegion( + FX_FLOAT overallEstModuleSize, + int32_t estAlignmentX, + int32_t estAlignmentY, + FX_FLOAT allowanceFactor, + int32_t& e) { + int32_t allowance = (int32_t)(allowanceFactor * overallEstModuleSize); + int32_t alignmentAreaLeftX = std::max(0, estAlignmentX - allowance); + int32_t alignmentAreaRightX = + std::min(m_image->GetWidth() - 1, estAlignmentX + allowance); + if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + int32_t alignmentAreaTopY = std::max(0, estAlignmentY - allowance); + int32_t alignmentAreaBottomY = + std::min(m_image->GetHeight() - 1, estAlignmentY + allowance); + CBC_QRAlignmentPatternFinder alignmentFinder( + m_image, alignmentAreaLeftX, alignmentAreaTopY, + alignmentAreaRightX - alignmentAreaLeftX, + alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize); + CBC_QRAlignmentPattern* qap = alignmentFinder.Find(e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + return qap; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.h b/xfa/fxbarcode/qrcode/BC_QRDetector.h new file mode 100644 index 0000000000..4c171847cb --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDetector.h @@ -0,0 +1,63 @@ +// 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_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_ResultPoint; +class CBC_CommonBitMatrix; +class CBC_QRDetectorResult; +class CBC_QRFinderPatternInfo; +class CBC_QRAlignmentPattern; + +class CBC_QRDetector { + private: + CBC_CommonBitMatrix* m_image; + + public: + CBC_QRDetector(CBC_CommonBitMatrix* image); + virtual ~CBC_QRDetector(); + + CBC_CommonBitMatrix* GetImage(); + CBC_QRDetectorResult* Detect(int32_t hints, int32_t& e); + CBC_QRDetectorResult* ProcessFinderPatternInfo(CBC_QRFinderPatternInfo* info, + int32_t& e); + FX_FLOAT CalculateModuleSize(CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft); + FX_FLOAT CalculateModuleSizeOneWay(CBC_ResultPoint* pattern, + CBC_ResultPoint* otherPattern); + FX_FLOAT SizeOfBlackWhiteBlackRunBothWays(int32_t fromX, + int32_t fromY, + int32_t toX, + int32_t toY); + FX_FLOAT SizeOfBlackWhiteBlackRun(int32_t fromX, + int32_t fromY, + int32_t toX, + int32_t toY); + CBC_QRAlignmentPattern* FindAlignmentInRegion(FX_FLOAT overallEstModuleSize, + int32_t estAlignmentX, + int32_t estAlignmentY, + FX_FLOAT allowanceFactor, + int32_t& e); + static int32_t Round(FX_FLOAT d); + static int32_t ComputeDimension(CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft, + FX_FLOAT moduleSize, + int32_t& e); + static CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, + CBC_ResultPoint* topLeft, + CBC_ResultPoint* topRight, + CBC_ResultPoint* bottomLeft, + CBC_ResultPoint* alignmentPattern, + int32_t dimension, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp new file mode 100644 index 0000000000..18e5d9ad4c --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp @@ -0,0 +1,43 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h" + +CBC_QRDetectorResult::CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, + CFX_PtrArray* 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; +} +CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() { + return m_bits; +} +CFX_PtrArray* CBC_QRDetectorResult::GetPoints() { + return m_points; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h new file mode 100644 index 0000000000..c6145ecbbe --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h @@ -0,0 +1,26 @@ +// 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_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; + +class CBC_QRDetectorResult { + private: + CBC_CommonBitMatrix* m_bits; + CFX_PtrArray* m_points; + + public: + CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points); + virtual ~CBC_QRDetectorResult(); + CBC_CommonBitMatrix* GetBits(); + CFX_PtrArray* GetPoints(); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp new file mode 100644 index 0000000000..5039920e32 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp @@ -0,0 +1,68 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/BC_ResultPoint.h" +#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h" + +CBC_QRFinderPattern::CBC_QRFinderPattern(FX_FLOAT x, + FX_FLOAT posY, + FX_FLOAT estimatedModuleSize) + : CBC_ResultPoint(x, posY), + m_estimatedModuleSize(estimatedModuleSize), + m_count(1) {} +CBC_QRFinderPattern::~CBC_QRFinderPattern() { + m_count = 0; + m_x = 0.0f; + m_y = 0.0f; + m_estimatedModuleSize = 0.0f; +} +CBC_QRFinderPattern* CBC_QRFinderPattern::Clone() { + CBC_QRFinderPattern* temp = + new CBC_QRFinderPattern(m_x, m_y, m_estimatedModuleSize); + temp->m_count = m_count; + return temp; +} +FX_FLOAT CBC_QRFinderPattern::GetEstimatedModuleSize() { + return m_estimatedModuleSize; +} +int32_t CBC_QRFinderPattern::GetCount() { + return m_count; +} +void CBC_QRFinderPattern::IncrementCount() { + m_count++; +} +FX_BOOL CBC_QRFinderPattern::AboutEquals(FX_FLOAT moduleSize, + FX_FLOAT i, + FX_FLOAT j) { + if ((fabs(i - GetY()) <= moduleSize) && (fabs(j - GetX()) <= moduleSize)) { + FX_FLOAT moduleSizeDiff = fabs(moduleSize - m_estimatedModuleSize); + return (moduleSizeDiff <= 1.0f) || + (moduleSizeDiff / m_estimatedModuleSize <= 1.0f); + } + return false; +} +FX_FLOAT CBC_QRFinderPattern::GetX() { + return m_x; +} +FX_FLOAT CBC_QRFinderPattern::GetY() { + return m_y; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h new file mode 100644 index 0000000000..bf3adffea4 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h @@ -0,0 +1,31 @@ +// 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_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ + +class CBC_ResultPoint; +class CBC_QRFinderPattern; +class CBC_QRFinderPattern : public CBC_ResultPoint { + private: + FX_FLOAT m_estimatedModuleSize; + int32_t m_count; + + public: + CBC_QRFinderPattern(FX_FLOAT x, FX_FLOAT posY, FX_FLOAT estimatedModuleSize); + virtual ~CBC_QRFinderPattern(); + + int32_t GetCount(); + FX_FLOAT GetX(); + FX_FLOAT GetY(); + FX_FLOAT GetEstimatedModuleSize(); + void IncrementCount(); + FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j); + CBC_QRFinderPattern* Clone(); +}; +typedef CBC_QRFinderPattern FinderPattern; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp new file mode 100644 index 0000000000..5ccbd9804b --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp @@ -0,0 +1,477 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" + +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" +#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_QRFinderPattern.h" +#include "xfa/fxbarcode/utils.h" + +const int32_t CBC_QRFinderPatternFinder::CENTER_QUORUM = 2; +const int32_t CBC_QRFinderPatternFinder::MIN_SKIP = 3; +const int32_t CBC_QRFinderPatternFinder::MAX_MODULES = 57; +const int32_t CBC_QRFinderPatternFinder::INTEGER_MATH_SHIFT = 8; + +CBC_QRFinderPatternFinder::CBC_QRFinderPatternFinder( + CBC_CommonBitMatrix* image) { + m_image = image; + 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(); +} +class ClosestToAverageComparator { + private: + FX_FLOAT m_averageModuleSize; + + public: + ClosestToAverageComparator(FX_FLOAT averageModuleSize) + : m_averageModuleSize(averageModuleSize) {} + int32_t operator()(FinderPattern* a, FinderPattern* b) { + FX_FLOAT dA = + (FX_FLOAT)fabs(a->GetEstimatedModuleSize() - m_averageModuleSize); + FX_FLOAT dB = + (FX_FLOAT)fabs(b->GetEstimatedModuleSize() - m_averageModuleSize); + return dA < dB ? -1 : dA > dB ? 1 : 0; + } +}; +class CenterComparator { + public: + int32_t operator()(FinderPattern* a, FinderPattern* b) { + return b->GetCount() - a->GetCount(); + } +}; +CBC_CommonBitMatrix* CBC_QRFinderPatternFinder::GetImage() { + return m_image; +} +CFX_Int32Array& CBC_QRFinderPatternFinder::GetCrossCheckStateCount() { + m_crossCheckStateCount[0] = 0; + m_crossCheckStateCount[1] = 0; + m_crossCheckStateCount[2] = 0; + m_crossCheckStateCount[3] = 0; + m_crossCheckStateCount[4] = 0; + return m_crossCheckStateCount; +} +CFX_PtrArray* CBC_QRFinderPatternFinder::GetPossibleCenters() { + return &m_possibleCenters; +} +CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint, + int32_t& e) { + int32_t maxI = m_image->GetHeight(); + int32_t maxJ = m_image->GetWidth(); + int32_t iSkip = (3 * maxI) / (4 * MAX_MODULES); + if (iSkip < MIN_SKIP || 0) { + iSkip = MIN_SKIP; + } + FX_BOOL done = FALSE; + CFX_Int32Array stateCount; + stateCount.SetSize(5); + for (int32_t i = iSkip - 1; i < maxI && !done; i += iSkip) { + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + int32_t currentState = 0; + for (int32_t j = 0; j < maxJ; j++) { + if (m_image->Get(j, i)) { + if ((currentState & 1) == 1) { + currentState++; + } + stateCount[currentState]++; + } else { + if ((currentState & 1) == 0) { + if (currentState == 4) { + if (FoundPatternCross(stateCount)) { + FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, j); + if (confirmed) { + iSkip = 2; + if (m_hasSkipped) { + done = HaveMultiplyConfirmedCenters(); + } else { + int32_t rowSkip = FindRowSkip(); + if (rowSkip > stateCount[2]) { + i += rowSkip - stateCount[2] - iSkip; + j = maxJ - 1; + } + } + } else { + do { + j++; + } while (j < maxJ && !m_image->Get(j, i)); + j--; + } + currentState = 0; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + } else { + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + } + } else { + stateCount[++currentState]++; + } + } else { + stateCount[currentState]++; + } + } + } + if (FoundPatternCross(stateCount)) { + FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, maxJ); + if (confirmed) { + iSkip = stateCount[0]; + if (m_hasSkipped) { + done = HaveMultiplyConfirmedCenters(); + } + } + } + } + std::unique_ptr<CFX_PtrArray> 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; + if (bcDistance >= abDistance && bcDistance >= acDistance) { + topLeft = (CBC_QRFinderPattern*)(*patterns)[0]; + topRight = (CBC_QRFinderPattern*)(*patterns)[1]; + bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2]; + } else if (acDistance >= bcDistance && acDistance >= abDistance) { + topLeft = (CBC_QRFinderPattern*)(*patterns)[1]; + topRight = (CBC_QRFinderPattern*)(*patterns)[0]; + bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2]; + } else { + topLeft = (CBC_QRFinderPattern*)(*patterns)[2]; + topRight = (CBC_QRFinderPattern*)(*patterns)[0]; + bottomLeft = (CBC_QRFinderPattern*)(*patterns)[1]; + } + if ((bottomLeft->GetY() - topLeft->GetY()) * + (topRight->GetX() - topLeft->GetX()) < + (bottomLeft->GetX() - topLeft->GetX()) * + (topRight->GetY() - topLeft->GetY())) { + CBC_QRFinderPattern* temp = topRight; + topRight = bottomLeft; + bottomLeft = temp; + } + (*patterns)[0] = bottomLeft; + (*patterns)[1] = topLeft; + (*patterns)[2] = topRight; +} +FX_FLOAT CBC_QRFinderPatternFinder::Distance(CBC_ResultPoint* point1, + CBC_ResultPoint* point2) { + FX_FLOAT dx = point1->GetX() - point2->GetX(); + FX_FLOAT dy = point1->GetY() - point2->GetY(); + return (FX_FLOAT)FXSYS_sqrt(dx * dx + dy * dy); +} +FX_FLOAT CBC_QRFinderPatternFinder::CenterFromEnd( + const CFX_Int32Array& stateCount, + int32_t end) { + return (FX_FLOAT)(end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; +} +FX_BOOL CBC_QRFinderPatternFinder::FoundPatternCross( + const CFX_Int32Array& stateCount) { + int32_t totalModuleSize = 0; + for (int32_t i = 0; i < 5; i++) { + int32_t count = stateCount[i]; + if (count == 0) { + return FALSE; + } + totalModuleSize += count; + } + if (totalModuleSize < 7) { + return FALSE; + } + int32_t moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; + int32_t maxVariance = moduleSize / 2; + return FXSYS_abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < + maxVariance && + FXSYS_abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < + maxVariance && + FXSYS_abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < + 3 * maxVariance && + FXSYS_abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < + maxVariance && + FXSYS_abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < + maxVariance; +} +FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckVertical( + int32_t startI, + int32_t centerJ, + int32_t maxCount, + int32_t originalStateCountTotal) { + CBC_CommonBitMatrix* image = m_image; + int32_t maxI = image->GetHeight(); + CFX_Int32Array& stateCount = GetCrossCheckStateCount(); + int32_t i = startI; + while (i >= 0 && image->Get(centerJ, i)) { + stateCount[2]++; + i--; + } + if (i < 0) { + return FXSYS_nan(); + } + while (i >= 0 && !image->Get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + if (i < 0 || stateCount[1] > maxCount) { + return FXSYS_nan(); + } + while (i >= 0 && image->Get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return FXSYS_nan(); + } + i = startI + 1; + while (i < maxI && image->Get(centerJ, i)) { + stateCount[2]++; + i++; + } + if (i == maxI) { + return FXSYS_nan(); + } + while (i < maxI && !image->Get(centerJ, i) && stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if (i == maxI || stateCount[3] >= maxCount) { + return FXSYS_nan(); + } + while (i < maxI && image->Get(centerJ, i) && stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return FXSYS_nan(); + } + int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + + stateCount[3] + stateCount[4]; + if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >= + originalStateCountTotal) { + return FXSYS_nan(); + } + return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i) + : FXSYS_nan(); +} +FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckHorizontal( + int32_t startJ, + int32_t centerI, + int32_t maxCount, + int32_t originalStateCountTotal) { + CBC_CommonBitMatrix* image = m_image; + int32_t maxJ = image->GetWidth(); + CFX_Int32Array& stateCount = GetCrossCheckStateCount(); + int32_t j = startJ; + while (j >= 0 && image->Get(j, centerI)) { + stateCount[2]++; + j--; + } + if (j < 0) { + return FXSYS_nan(); + } + while (j >= 0 && !image->Get(j, centerI) && stateCount[1] <= maxCount) { + stateCount[1]++; + j--; + } + if (j < 0 || stateCount[1] > maxCount) { + return FXSYS_nan(); + } + while (j >= 0 && image->Get(j, centerI) && stateCount[0] <= maxCount) { + stateCount[0]++; + j--; + } + if (stateCount[0] > maxCount) { + return FXSYS_nan(); + } + j = startJ + 1; + while (j < maxJ && image->Get(j, centerI)) { + stateCount[2]++; + j++; + } + if (j == maxJ) { + return FXSYS_nan(); + } + while (j < maxJ && !image->Get(j, centerI) && stateCount[3] < maxCount) { + stateCount[3]++; + j++; + } + if (j == maxJ || stateCount[3] >= maxCount) { + return FXSYS_nan(); + } + while (j < maxJ && image->Get(j, centerI) && stateCount[4] < maxCount) { + stateCount[4]++; + j++; + } + if (stateCount[4] >= maxCount) { + return FXSYS_nan(); + } + int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + + stateCount[3] + stateCount[4]; + if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >= + originalStateCountTotal) { + return FXSYS_nan(); + } + return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, j) + : FXSYS_nan(); +} +FX_BOOL CBC_QRFinderPatternFinder::HandlePossibleCenter( + const CFX_Int32Array& stateCount, + int32_t i, + int32_t j) { + int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + + stateCount[3] + stateCount[4]; + FX_FLOAT centerJ = CenterFromEnd(stateCount, j); + FX_FLOAT centerI = + CrossCheckVertical(i, (int32_t)centerJ, stateCount[2], stateCountTotal); + if (!FXSYS_isnan(centerI)) { + centerJ = CrossCheckHorizontal((int32_t)centerJ, (int32_t)centerI, + stateCount[2], stateCountTotal); + if (!FXSYS_isnan(centerJ)) { + FX_FLOAT estimatedModuleSize = (FX_FLOAT)stateCountTotal / 7.0f; + 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]); + if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) { + center->IncrementCount(); + found = TRUE; + break; + } + } + if (!found) { + m_possibleCenters.Add( + new CBC_QRFinderPattern(centerJ, centerI, estimatedModuleSize)); + } + return TRUE; + } + } + return FALSE; +} +int32_t CBC_QRFinderPatternFinder::FindRowSkip() { + int32_t max = m_possibleCenters.GetSize(); + if (max <= 1) { + return 0; + } + FinderPattern* firstConfirmedCenter = NULL; + for (int32_t i = 0; i < max; i++) { + CBC_QRFinderPattern* center = (CBC_QRFinderPattern*)m_possibleCenters[i]; + if (center->GetCount() >= CENTER_QUORUM) { + if (firstConfirmedCenter == NULL) { + firstConfirmedCenter = center; + } else { + m_hasSkipped = TRUE; + return (int32_t)((fabs(firstConfirmedCenter->GetX() - center->GetX()) - + fabs(firstConfirmedCenter->GetY() - center->GetY())) / + 2); + } + } + } + return 0; +} +FX_BOOL CBC_QRFinderPatternFinder::HaveMultiplyConfirmedCenters() { + int32_t confirmedCount = 0; + FX_FLOAT totalModuleSize = 0.0f; + int32_t max = m_possibleCenters.GetSize(); + int32_t i; + for (i = 0; i < max; i++) { + CBC_QRFinderPattern* pattern = (CBC_QRFinderPattern*)m_possibleCenters[i]; + if (pattern->GetCount() >= CENTER_QUORUM) { + confirmedCount++; + totalModuleSize += pattern->GetEstimatedModuleSize(); + } + } + if (confirmedCount < 3) { + return FALSE; + } + 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]; + 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) { + int32_t startSize = m_possibleCenters.GetSize(); + if (m_possibleCenters.GetSize() < 3) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + } + 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(); + } + 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]; + if (fabs(pattern->GetEstimatedModuleSize() - average) > 0.2f * average) { + delete pattern; + m_possibleCenters.RemoveAt(j); + j--; + } + } + } + if (m_possibleCenters.GetSize() > 3) { + BC_FX_PtrArray_Sort(m_possibleCenters, centerComparator); + } + CFX_PtrArray* vec = new CFX_PtrArray(); + 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(); + return vec; +} diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h new file mode 100644 index 0000000000..058f65df31 --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h @@ -0,0 +1,57 @@ +// 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_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; +class CBC_QRFinderPattern; +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(); + int32_t FindRowSkip(); + CBC_CommonBitMatrix* GetImage(); + CBC_QRFinderPatternInfo* Find(int32_t hint, int32_t& e); + + CFX_Int32Array& GetCrossCheckStateCount(); + CFX_PtrArray* GetPossibleCenters(); + CFX_PtrArray* SelectBestpatterns(int32_t& e); + + FX_BOOL HandlePossibleCenter(const CFX_Int32Array& stateCount, + int32_t i, + int32_t j); + FX_BOOL HaveMultiplyConfirmedCenters(); + FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end); + FX_FLOAT CrossCheckVertical(int32_t startI, + int32_t centerJ, + int32_t maxCount, + int32_t originalStateCountTotal); + FX_FLOAT CrossCheckHorizontal(int32_t startJ, + int32_t CenterI, + int32_t maxCOunt, + int32_t originalStateCountTotal); + static void OrderBestPatterns(CFX_PtrArray* patterns); + static FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount); + static FX_FLOAT Distance(CBC_ResultPoint* point1, CBC_ResultPoint* point2); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ diff --git a/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp new file mode 100644 index 0000000000..881e74a98c --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp @@ -0,0 +1,139 @@ +// 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 +// Original code is licensed as follows: +/* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "xfa/fxbarcode/qrcode/BC_QRGridSampler.h" + +#include <memory> + +#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" +#include "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h" +#include "xfa/fxbarcode/utils.h" + +CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler; + +CBC_QRGridSampler::CBC_QRGridSampler() {} +CBC_QRGridSampler::~CBC_QRGridSampler() {} +CBC_QRGridSampler& CBC_QRGridSampler::GetInstance() { + return m_gridSampler; +} +void CBC_QRGridSampler::CheckAndNudgePoints(CBC_CommonBitMatrix* image, + CFX_FloatArray* points, + int32_t& e) { + int32_t width = image->GetWidth(); + int32_t height = image->GetHeight(); + FX_BOOL nudged = TRUE; + int32_t offset; + for (offset = 0; offset < points->GetSize() && nudged; offset += 2) { + int32_t x = (int32_t)(*points)[offset]; + int32_t y = (int32_t)(*points)[offset + 1]; + if (x < -1 || x > width || y < -1 || y > height) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + nudged = FALSE; + if (x == -1) { + (*points)[offset] = 0.0f; + nudged = TRUE; + } else if (x == width) { + (*points)[offset] = (FX_FLOAT)(width - 1); + nudged = TRUE; + } + if (y == -1) { + (*points)[offset + 1] = 0.0f; + nudged = TRUE; + } else if (y == height) { + (*points)[offset + 1] = (FX_FLOAT)(height - 1); + nudged = TRUE; + } + } + nudged = TRUE; + for (offset = (*points).GetSize() - 2; offset >= 0 && nudged; offset -= 2) { + int32_t x = (int32_t)(*points)[offset]; + int32_t y = (int32_t)(*points)[offset + 1]; + if (x < -1 || x > width || y < -1 || y > height) { + e = BCExceptionRead; + BC_EXCEPTION_CHECK_ReturnVoid(e); + } + nudged = FALSE; + if (x == -1) { + (*points)[offset] = 0.0f; + nudged = TRUE; + } else if (x == width) { + (*points)[offset] = (FX_FLOAT)(width - 1); + nudged = TRUE; + } + if (y == -1) { + (*points)[offset + 1] = 0.0f; + nudged = TRUE; + } else if (y == height) { + (*points)[offset + 1] = (FX_FLOAT)(height - 1); + nudged = TRUE; + } + } +} +CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image, + int32_t dimensionX, + int32_t dimensionY, + FX_FLOAT p1ToX, + FX_FLOAT p1ToY, + FX_FLOAT p2ToX, + FX_FLOAT p2ToY, + FX_FLOAT p3ToX, + FX_FLOAT p3ToY, + FX_FLOAT p4ToX, + FX_FLOAT p4ToY, + FX_FLOAT p1FromX, + FX_FLOAT p1FromY, + FX_FLOAT p2FromX, + FX_FLOAT p2FromY, + FX_FLOAT p3FromX, + FX_FLOAT p3FromY, + FX_FLOAT p4FromX, + FX_FLOAT p4FromY, + int32_t& e) { + std::unique_ptr<CBC_CommonPerspectiveTransform> transform( + CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral( + p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, + p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)); + std::unique_ptr<CBC_CommonBitMatrix> bits(new CBC_CommonBitMatrix()); + bits->Init(dimensionX, dimensionY); + CFX_FloatArray points; + points.SetSize(dimensionX << 1); + for (int32_t y = 0; y < dimensionY; y++) { + int32_t max = points.GetSize(); + FX_FLOAT iValue = (FX_FLOAT)(y + 0.5f); + int32_t x; + for (x = 0; x < max; x += 2) { + points[x] = (FX_FLOAT)((x >> 1) + 0.5f); + points[x + 1] = iValue; + } + transform->TransformPoints(&points); + CheckAndNudgePoints(image, &points, e); + BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + for (x = 0; x < max; x += 2) { + if (image->Get((int32_t)points[x], (int32_t)points[x + 1])) { + bits->Set(x >> 1, y); + } + } + } + return bits.release(); +} diff --git a/xfa/fxbarcode/qrcode/BC_QRGridSampler.h b/xfa/fxbarcode/qrcode/BC_QRGridSampler.h new file mode 100644 index 0000000000..4e10c5627a --- /dev/null +++ b/xfa/fxbarcode/qrcode/BC_QRGridSampler.h @@ -0,0 +1,48 @@ +// 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_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ +#define XFA_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ + +#include "core/include/fxcrt/fx_basic.h" + +class CBC_CommonBitMatrix; + +class CBC_QRGridSampler { + private: + static CBC_QRGridSampler m_gridSampler; + + public: + CBC_QRGridSampler(); + virtual ~CBC_QRGridSampler(); + virtual CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, + int32_t dimensionX, + int32_t dimensionY, + FX_FLOAT p1ToX, + FX_FLOAT p1ToY, + FX_FLOAT p2ToX, + FX_FLOAT p2ToY, + FX_FLOAT p3ToX, + FX_FLOAT p3ToY, + FX_FLOAT p4ToX, + FX_FLOAT p4ToY, + FX_FLOAT p1FromX, + FX_FLOAT p1FromY, + FX_FLOAT p2FromX, + FX_FLOAT p2FromY, + FX_FLOAT p3FromX, + FX_FLOAT p3FromY, + FX_FLOAT p4FromX, + FX_FLOAT p4FromY, + int32_t& e); + + static CBC_QRGridSampler& GetInstance(); + static void CheckAndNudgePoints(CBC_CommonBitMatrix* image, + CFX_FloatArray* points, + int32_t& e); +}; + +#endif // XFA_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ diff --git a/xfa/fxbarcode/utils.h b/xfa/fxbarcode/utils.h new file mode 100644 index 0000000000..f6186e664f --- /dev/null +++ b/xfa/fxbarcode/utils.h @@ -0,0 +1,183 @@ +// 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_FXBARCODE_UTILS_H_ +#define XFA_FXBARCODE_UTILS_H_ + +#include "core/include/fxcrt/fx_basic.h" + +typedef CFX_MapPtrTemplate<void*, int32_t> CFX_PtrToInt32; +FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString& dst, + FX_DWORD first, + FX_DWORD last, + int32_t count, + 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> +#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ + _FX_OS_ == _FX_IOS_) +#include <limits.h> +#endif +#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) +#define FXSYS_isnan(x) _isnan(x) +#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_) +#include <cmath> +#define FXSYS_isnan(x) std::isnan(x) +#elif(_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_) +#include <math.h> +#define FXSYS_isnan(x) isnan(x) +#endif +#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) +#define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN()) +#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ + _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_) +#define FXSYS_nan() NAN +#endif +enum BCFORMAT { + BCFORMAT_UNSPECIFY = -1, + BCFORMAT_CODABAR, + BCFORMAT_CODE_39, + BCFORMAT_CODE_128, + BCFORMAT_CODE_128B, + BCFORMAT_CODE_128C, + BCFORMAT_EAN_8, + BCFORMAT_UPC_A, + BCFORMAT_EAN_13, + BCFORMAT_PDF_417, + BCFORMAT_DATAMATRIX, + BCFORMAT_QR_CODE +}; +#define BCFORMAT_ECLEVEL_L 0 +#define BCFORMAT_ECLEVEL_M 1 +#define BCFORMAT_ECLEVEL_Q 2 +#define BCFORMAT_ECLEVEL_H 3 +#include <ctype.h> +#define FXSYS_IntMax INT_MAX +#define FXSYS_Isdigit isdigit +#define BCExceptionNO 0 +#define BCExceptionNotFound 1 +#define BCExceptionEndLessThanStart 2 +#define BCExceptionUnknownDecoder 3 +#define BCExceptionRotateNotSupported 4 +#define BCExceptionHeightAndWidthMustBeAtLeast1 5 +#define BCExceptionRegionMustFitInsideMatrix 6 +#define BCExceptionCanNotCallGetDimensionOnNonSquareMatrix 7 +#define BCExceptionFormatException 8 +#define BCExceptionIllegalArgumentMustMatchVersionSize 9 +#define BCExceptionChecksumException 10 +#define BCExceptionIllegalArgumentInvalidFirstDigit 11 +#define BCExceptionIllegalArgumentInvalidSecondDigit 12 +#define BCExceptionRuntimeDecodingInvalidISO_IEC 13 +#define BCExceptionRuntimeDecodingInvalidAlphanumeric 14 +#define BCExceptionLeftAndTopMustBeNonnegative 15 +#define BCExceptionIllegalArgument 16 +#define BCExceptionBadECI 17 +#define BCExceptionUnSupportedBarcode 18 +#define BCExceptionUnSupportedString 19 +#define BCExceptionDigitLengthMustBe8 20 +#define BCExceptionDataCheckException 21 +#define BCExceptionExtractNumberValueFromBitArray 22 +#define BCExceptionRead 23 +#define BCExceptionRequestedRowIsOutSizeTheImage 24 +#define BCExceptionNoContents 26 +#define BCExceptionUnSupportEclevel 27 +#define BCExceptionUnSupportMode 28 +#define BCExceptionReferenceMustBeBetween0And7 29 +#define BCExceptionBadErrorLocation 30 +#define BCExceptionDegreeIsNegative 31 +#define BCExceptionDivideByZero 32 +#define BCExceptionCoefficientsSizeIsNull 33 +#define BCExceptionNoCorrectionBytes 34 +#define BCExceptionNoDataBytesProvided 35 +#define BCExceptionR_I_1IsZero 36 +#define BCExceptionAIsZero 37 +#define BCExceptionIsZero 38 +#define BCExceptionDegreeNotMatchRoots 39 +#define BCExceptionContentsLengthShouldBetween1and80 40 +#define BCExceptionOnlyEncodeCODE_128 41 +#define BCExceptionOnlyEncodeCODE_39 42 +#define BCExceptionOnlyEncodeEAN_13 43 +#define BCExceptionOnlyEncodeEAN_8 44 +#define BCExceptionOnlyEncodeITF 45 +#define BCExceptionDigitLengthShould13 46 +#define BCExceptionDigitLengthMustBe6or8or10or12or14or16or20or24or44 47 +#define BCExceptionOnlyEncodeUPC_A 48 +#define BCExceptionDigitLengthShouldBe12 49 +#define BCExceptionValueMustBeEither0or1 50 +#define BCExceptionReedsolomnDecodeException 51 +#define BCExceptionBadIndexException 52 +#define BCExceptionBadValueException 53 +#define BCExceptionBadNumBitsException 54 +#define BCExceptioncanNotOperatexorOperator 55 +#define BCExceptionVersionMust1_40 56 +#define BCExceptionUnknown 57 +#define BCExceptionNoSuchVersion 58 +#define BCExceptionCannotFindBlockInfo 59 +#define BCExceptionDataTooBig 60 +#define BCExceptionInvalidQRCode 61 +#define BCExceptionDataTooMany 62 +#define BCExceptionBitsNotEqualCacity 63 +#define BCExceptionUnsupportedMode 64 +#define BCExceptionInvalidateCharacter 65 +#define BCExceptionBytesNotMatchOffset 66 +#define BCExceptionSizeInBytesDiffer 67 +#define BCExceptionInvalidateMaskPattern 68 +#define BCExceptionNullPointer 69 +#define BCExceptionBadMask 70 +#define BCExceptionBitSizeNot15 71 +#define BCExceptionBitSizeNot18 72 +#define BCExceptionInvalidateImageData 73 +#define BCExceptionHeight_8BeZero 74 +#define BCExceptionCharacterNotThisMode 75 +#define BCExceptionBitsBytesNotMatch 76 +#define BCExceptionInvalidateData 77 +#define BCExceptionLoadFile 78 +#define BCExceptionPDF417EncodeFail 79 +#define BCExceptionFailToCreateBitmap 80 +#define BCExceptionLoadFontFail 81 +#define BCExceptionOnlyEncodeCODEBAR 82 +#define BCExceptionCodabarShouldStartWithOneOfABCD 83 +#define BCExceptionCodabarShouldEndWithOneOfTNE 84 +#define BCExceptionCodabarEncodeCharsInvalid 85 +#define BCExceptionOnlyEncodeDATAMATRIX 86 +#define BCExceptionCharactersOutsideISO88591Encoding 87 +#define BCExceptionIllegalDataCodewords 88 +#define BCExceptionCannotHandleThisNumberOfDataRegions 89 +#define BCExceptionIllegalStateUnexpectedCase 90 +#define BCExceptionIllegalStateCountMustNotExceed4 91 +#define BCExceptionIllegalStateMessageLengthInvalid 92 +#define BCExceptionIllegalArgumentNotGigits 93 +#define BCExceptionIllegalStateIllegalMode 94 +#define BCExceptionOnlyEncodePDF417 95 +#define BCExceptionNonEncodableCharacterDetected 96 +#define BCExceptionErrorCorrectionLevelMustBeBetween0And8 97 +#define BCExceptionNoRecommendationPossible 98 +#define BCExceptionIllegalArgumentnMustBeAbove0 99 +#define BCExceptionUnableToFitMessageInColumns 100 +#define BCExceptionEncodedMessageContainsTooManyCodeWords 101 +#define BCExceptionBitmapSizeError 102 +#define BCExceptionFormatInstance 102 +#define BCExceptionChecksumInstance 103 +#define BCExceptiontNotFoundInstance 104 +#define BCExceptionNotFoundInstance 105 +#define BCExceptionCannotMetadata 106 +#define TWO_DIGIT_DATA_LENGTH_SIZE 24 +#define THREE_DIGIT_DATA_LENGTH_SIZE 23 +#define THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH_SIZE 57 +#define FOUR_DIGIT_DATA_LENGTH_SIZE 17 +#define BC_EXCEPTION_CHECK_ReturnVoid(e) \ + if (e != BCExceptionNO) \ + return; +#define BC_EXCEPTION_CHECK_ReturnValue(e, v) \ + if (e != BCExceptionNO) \ + return v; + +#endif // XFA_FXBARCODE_UTILS_H_ diff --git a/xfa/fxfa/app/xfa_checksum.cpp b/xfa/fxfa/app/xfa_checksum.cpp new file mode 100644 index 0000000000..1639c0d2f6 --- /dev/null +++ b/xfa/fxfa/app/xfa_checksum.cpp @@ -0,0 +1,190 @@ +// 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/fxfa/app/xfa_checksum.h" + +#include "core/include/fdrm/fx_crypt.h" +#include "xfa/fgas/crt/fgas_algorithm.h" + +CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) + : m_pContext(pContext) { + FXSYS_assert(m_pContext); +} +CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} +void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName, + FX_SAXNODE eType, + FX_DWORD dwStartPos) { + UpdateChecksum(TRUE); + if (eType != FX_SAXNODE_Tag && eType != FX_SAXNODE_Instruction) { + return NULL; + } + m_SAXContext.m_eNode = eType; + CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; + textBuf << "<"; + if (eType == FX_SAXNODE_Instruction) { + textBuf << "?"; + } + textBuf << bsTagName; + m_SAXContext.m_bsTagName = bsTagName; + return &m_SAXContext; +} +void CXFA_SAXReaderHandler::OnTagAttribute(void* pTag, + const CFX_ByteStringC& bsAttri, + const CFX_ByteStringC& bsValue) { + if (pTag == NULL) { + return; + } + CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; + textBuf << " " << bsAttri << "=\"" << bsValue << "\""; +} +void CXFA_SAXReaderHandler::OnTagBreak(void* pTag) { + if (pTag == NULL) { + return; + } + CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; + textBuf << ">"; + UpdateChecksum(FALSE); +} +void CXFA_SAXReaderHandler::OnTagData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos) { + if (pTag == NULL) { + return; + } + CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; + if (eType == FX_SAXNODE_CharData) { + textBuf << "<![CDATA["; + } + textBuf << bsData; + if (eType == FX_SAXNODE_CharData) { + textBuf << "]]>"; + } +} +void CXFA_SAXReaderHandler::OnTagClose(void* pTag, FX_DWORD dwEndPos) { + if (pTag == NULL) { + return; + } + CXFA_SAXContext* pSAXContext = (CXFA_SAXContext*)pTag; + CFX_ByteTextBuf& textBuf = pSAXContext->m_TextBuf; + if (pSAXContext->m_eNode == FX_SAXNODE_Instruction) { + textBuf << "?>"; + } else if (pSAXContext->m_eNode == FX_SAXNODE_Tag) { + textBuf << "></" << pSAXContext->m_bsTagName << ">"; + } + UpdateChecksum(FALSE); +} +void CXFA_SAXReaderHandler::OnTagEnd(void* pTag, + const CFX_ByteStringC& bsTagName, + FX_DWORD dwEndPos) { + if (pTag == NULL) { + return; + } + CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; + textBuf << "</" << bsTagName << ">"; + UpdateChecksum(FALSE); +} +void CXFA_SAXReaderHandler::OnTargetData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos) { + if (pTag == NULL && eType != FX_SAXNODE_Comment) { + return; + } + if (eType == FX_SAXNODE_Comment) { + CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; + textBuf << "<!--" << bsData << "-->"; + UpdateChecksum(FALSE); + } else { + CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; + textBuf << " " << bsData; + } +} +void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) { + int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); + if (iLength < 1) { + return; + } + uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); + FX_BOOL bUpdata = TRUE; + if (bCheckSpace) { + bUpdata = FALSE; + for (int32_t i = 0; i < iLength; i++) { + bUpdata = (pBuffer[i] > 0x20); + if (bUpdata) { + break; + } + } + } + if (bUpdata) { + m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); + } + m_SAXContext.m_TextBuf.Clear(); +} +IXFA_ChecksumContext* XFA_Checksum_Create() { + return new CXFA_ChecksumContext; +} +CXFA_ChecksumContext::CXFA_ChecksumContext() + : m_pSAXReader(NULL), m_pByteContext(NULL) {} +CXFA_ChecksumContext::~CXFA_ChecksumContext() { + FinishChecksum(); +} +FX_BOOL 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; +} +FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile, + FX_FILESIZE offset, + size_t size) { + if (m_pSAXReader == NULL) { + return FALSE; + } + if (pSrcFile == NULL) { + return FALSE; + } + if (size < 1) { + size = pSrcFile->GetSize(); + } + CXFA_SAXReaderHandler handler(this); + m_pSAXReader->SetHandler(&handler); + if (m_pSAXReader->StartParse( + pSrcFile, (FX_DWORD)offset, (FX_DWORD)size, + FX_SAXPARSEMODE_NotSkipSpace | FX_SAXPARSEMODE_NotConvert_amp | + FX_SAXPARSEMODE_NotConvert_lt | FX_SAXPARSEMODE_NotConvert_gt | + FX_SAXPARSEMODE_NotConvert_sharp) < 0) { + return FALSE; + } + return m_pSAXReader->ContinueParse(NULL) > 99; +} +void CXFA_ChecksumContext::FinishChecksum() { + if (m_pSAXReader) { + m_pSAXReader->Release(); + m_pSAXReader = NULL; + } + if (m_pByteContext) { + uint8_t digest[20]; + FXSYS_memset(digest, 0, 20); + CRYPT_SHA1Finish(m_pByteContext, digest); + int32_t nLen = FX_Base64EncodeA(digest, 20, NULL); + FX_CHAR* pBuffer = m_bsChecksum.GetBuffer(nLen); + FX_Base64EncodeA(digest, 20, pBuffer); + m_bsChecksum.ReleaseBuffer(nLen); + FX_Free(m_pByteContext); + m_pByteContext = NULL; + } +} +void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { + bsChecksum = m_bsChecksum; +} +void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { + if (m_pByteContext) { + CRYPT_SHA1Update(m_pByteContext, bsText.GetPtr(), bsText.GetLength()); + } +} diff --git a/xfa/fxfa/app/xfa_checksum.h b/xfa/fxfa/app/xfa_checksum.h new file mode 100644 index 0000000000..5331800b82 --- /dev/null +++ b/xfa/fxfa/app/xfa_checksum.h @@ -0,0 +1,73 @@ +// 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_APP_XFA_CHECKSUM_H_ +#define XFA_FXFA_APP_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, + FX_DWORD 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, + FX_DWORD dwStartPos); + virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos); + virtual void OnTagEnd(void* pTag, + const CFX_ByteStringC& bsTagName, + FX_DWORD dwEndPos); + + virtual void OnTargetData(void* pTag, + FX_SAXNODE eType, + const CFX_ByteStringC& bsData, + FX_DWORD dwStartPos); + + protected: + void UpdateChecksum(FX_BOOL bCheckSpace); + CXFA_ChecksumContext* m_pContext; + CXFA_SAXContext m_SAXContext; +}; + +class CXFA_ChecksumContext : public IXFA_ChecksumContext { + public: + CXFA_ChecksumContext(); + virtual ~CXFA_ChecksumContext(); + virtual void Release() { delete this; } + virtual FX_BOOL StartChecksum(); + virtual FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile, + FX_FILESIZE offset = 0, + size_t size = 0); + virtual void FinishChecksum(); + virtual 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_FXFA_APP_XFA_CHECKSUM_H_ diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp new file mode 100644 index 0000000000..8327d1b27c --- /dev/null +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -0,0 +1,190 @@ +// 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/fxfa/app/xfa_ffapp.h" + +#include <algorithm> + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdochandler.h" +#include "xfa/fxfa/app/xfa_ffwidgethandler.h" +#include "xfa/fxfa/app/xfa_fontmgr.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/include/fwl/core/fwl_widgetmgr.h" + +CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { + int32_t iCount = streams.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CPDF_StreamAcc& acc = m_Data.Add(); + acc.LoadAllData(streams[i]); + } +} +FX_FILESIZE CXFA_FileRead::GetSize() { + FX_DWORD dwSize = 0; + int32_t iCount = m_Data.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CPDF_StreamAcc& acc = m_Data[i]; + dwSize += acc.GetSize(); + } + return dwSize; +} +FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) { + int32_t iCount = m_Data.GetSize(); + int32_t index = 0; + while (index < iCount) { + CPDF_StreamAcc& acc = m_Data[index]; + FX_FILESIZE dwSize = acc.GetSize(); + if (offset < dwSize) { + break; + } + offset -= dwSize; + index++; + } + while (index < iCount) { + CPDF_StreamAcc& acc = m_Data[index]; + FX_DWORD dwSize = acc.GetSize(); + size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset)); + FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); + size -= dwRead; + if (size == 0) { + return TRUE; + } + buffer = (uint8_t*)buffer + dwRead; + offset = 0; + index++; + } + return FALSE; +} +// static +IXFA_App* IXFA_App::Create(IXFA_AppProvider* pProvider) { + return new CXFA_FFApp(pProvider); +} +// virtual +IXFA_App::~IXFA_App() {} +CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) + : m_pDocHandler(nullptr), + m_pFWLTheme(nullptr), + m_pProvider(pProvider), + m_pFontMgr(nullptr), +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + m_pFontSource(nullptr), +#endif + m_pAdapterWidgetMgr(nullptr), + m_pWidgetMgrDelegate(nullptr), + m_pFDEFontMgr(nullptr), + m_pMenuHandler(nullptr), + m_pAdapterThreadMgr(nullptr) { + m_pFWLApp = IFWL_App::Create(this); + FWL_SetApp(m_pFWLApp); + m_pFWLApp->Initialize(); + IXFA_TimeZoneProvider::Create(); +} +CXFA_FFApp::~CXFA_FFApp() { + delete m_pDocHandler; + if (m_pFWLApp) { + m_pFWLApp->Finalize(); + m_pFWLApp->Release(); + delete m_pFWLApp; + } + if (m_pFWLTheme) + m_pFWLTheme->Release(); + delete m_pAdapterWidgetMgr; + delete m_pAdapterThreadMgr; + delete m_pMenuHandler; + IXFA_TimeZoneProvider::Destroy(); + delete m_pFontMgr; +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (m_pFontSource) + m_pFontSource->Release(); +#endif + if (m_pFDEFontMgr) + m_pFDEFontMgr->Release(); +} +IXFA_MenuHandler* CXFA_FFApp::GetMenuHandler() { + if (!m_pMenuHandler) { + m_pMenuHandler = new CXFA_FFMenuHandler; + } + return m_pMenuHandler; +} +IXFA_DocHandler* CXFA_FFApp::GetDocHandler() { + if (!m_pDocHandler) { + m_pDocHandler = new CXFA_FFDocHandler; + } + return m_pDocHandler; +} +IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, + IFX_FileRead* pStream, + FX_BOOL bTakeOverFile) { + CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); + FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); + if (!bSuccess) { + delete pDoc; + pDoc = NULL; + } + return pDoc; +} +IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, + CPDF_Document* pPDFDoc) { + if (pPDFDoc == NULL) { + return NULL; + } + CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); + FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); + if (!bSuccess) { + delete pDoc; + pDoc = NULL; + } + return pDoc; +} + +void CXFA_FFApp::SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) { + if (!m_pFontMgr) { + m_pFontMgr = new CXFA_FontMgr(); + } + m_pFontMgr->SetDefFontMgr(pFontMgr); +} +CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { + return m_pFontMgr; +} +IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() { + if (!m_pFDEFontMgr) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + m_pFDEFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); +#else + m_pFontSource = FX_CreateDefaultFontSourceEnum(); + m_pFDEFontMgr = IFX_FontMgr::Create(m_pFontSource); +#endif + } + return m_pFDEFontMgr; +} +CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { + if (!m_pFWLTheme) { + m_pFWLTheme = new CXFA_FWLTheme(this); + } + return m_pFWLTheme; +} +IFWL_AdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( + IFWL_WidgetMgrDelegate* pDelegate) { + if (!m_pAdapterWidgetMgr) { + m_pAdapterWidgetMgr = new CXFA_FWLAdapterWidgetMgr; + pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread | + FWL_WGTMGR_DisableForm); + m_pWidgetMgrDelegate = pDelegate; + } + 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/xfa/fxfa/app/xfa_ffapp.h b/xfa/fxfa/app/xfa_ffapp.h new file mode 100644 index 0000000000..0374d4ac5b --- /dev/null +++ b/xfa/fxfa/app/xfa_ffapp.h @@ -0,0 +1,81 @@ +// 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_APP_XFA_FFAPP_H_ +#define XFA_FXFA_APP_XFA_FFAPP_H_ + +#include "core/include/fpdfapi/cpdf_stream.h" +#include "xfa/fgas/font/fgas_font.h" +#include "xfa/include/fwl/adapter/fwl_adapternative.h" +#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_FWLAdapterWidgetMgr; +class CXFA_FWLTheme; +class CXFA_FFDocHandler; +class CXFA_FFMenuHandler; +class CXFA_FontMgr; + +class CXFA_FileRead : public IFX_FileRead { + public: + explicit CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams); + + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + + virtual void Release() { delete this; } + + protected: + CFX_ObjectArray<CPDF_StreamAcc> m_Data; +}; + +class CXFA_FFApp : public IXFA_App, public IFWL_AdapterNative { + public: + CXFA_FFApp(IXFA_AppProvider* pProvider); + ~CXFA_FFApp() override; + + // IFXFA_App: + IXFA_DocHandler* GetDocHandler() override; + IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider, + IFX_FileRead* pStream, + FX_BOOL bTakeOverFile) override; + IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider, + CPDF_Document* pPDFDoc) override; + IXFA_AppProvider* GetAppProvider() override { return m_pProvider; } + void SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) override; + IXFA_MenuHandler* GetMenuHandler() override; + + // IFWL_AdapterNative: + IFWL_AdapterWidgetMgr* GetWidgetMgr( + IFWL_WidgetMgrDelegate* pDelegate) override; + IFWL_AdapterThreadMgr* GetThreadMgr() override; + IFWL_AdapterTimerMgr* GetTimerMgr() override; + + CXFA_FontMgr* GetXFAFontMgr(); + IFX_FontMgr* GetFDEFontMgr(); + CXFA_FWLTheme* GetFWLTheme(); + IFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() { + return m_pWidgetMgrDelegate; + } + + protected: + CXFA_FFDocHandler* m_pDocHandler; + IFWL_App* m_pFWLApp; + CXFA_FWLTheme* m_pFWLTheme; + IXFA_AppProvider* m_pProvider; + CXFA_FontMgr* m_pFontMgr; +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + IFX_FontSourceEnum* m_pFontSource; +#endif + CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr; + IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; + IFX_FontMgr* m_pFDEFontMgr; + CXFA_FFMenuHandler* m_pMenuHandler; + CFWL_SDAdapterThreadMgr* m_pAdapterThreadMgr; +}; + +#endif // XFA_FXFA_APP_XFA_FFAPP_H_ diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp new file mode 100644 index 0000000000..2062ca1e35 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -0,0 +1,235 @@ +// 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/fxfa/app/xfa_ffbarcode.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/lightwidget/barcode.h" + +static XFA_LPCBARCODETYPEENUMINFO XFA_GetBarcodeTypeByName( + const CFX_WideStringC& wsName); +CXFA_FFBarcode::CXFA_FFBarcode(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pPageView, pDataAcc) {} +CXFA_FFBarcode::~CXFA_FFBarcode() {} +FX_BOOL CXFA_FFBarcode::LoadWidget() { + CFWL_Barcode* pFWLBarcode = CFWL_Barcode::Create(); + if (pFWLBarcode) { + pFWLBarcode->Initialize(); + } + m_pNormalWidget = pFWLBarcode; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pFWLBarcode->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + CFX_RectF rtWidget; + m_pNormalWidget->GetWidgetRect(rtWidget); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + m_pNormalWidget->DrawWidget(pGS, &mt); +} +void CXFA_FFBarcode::UpdateWidgetProperty() { + CXFA_FFTextEdit::UpdateWidgetProperty(); + CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + CFX_WideString wsType = GetDataAcc()->GetBarcodeType(); + XFA_LPCBARCODETYPEENUMINFO pBarcodeTypeInfo = + XFA_GetBarcodeTypeByName(wsType); + pBarCodeWidget->SetType(pBarcodeTypeInfo->eBCType); + CXFA_WidgetAcc* pAcc = GetDataAcc(); + int32_t intVal; + FX_CHAR charVal; + FX_BOOL boolVal; + FX_FLOAT floatVal; + if (pAcc->GetBarcodeAttribute_CharEncoding(intVal)) { + pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); + } + if (pAcc->GetBarcodeAttribute_Checksum(intVal)) { + pBarCodeWidget->SetCalChecksum(intVal); + } + if (pAcc->GetBarcodeAttribute_DataLength(intVal)) { + pBarCodeWidget->SetDataLength(intVal); + } + if (pAcc->GetBarcodeAttribute_StartChar(charVal)) { + pBarCodeWidget->SetStartChar(charVal); + } + if (pAcc->GetBarcodeAttribute_EndChar(charVal)) { + pBarCodeWidget->SetEndChar(charVal); + } + if (pAcc->GetBarcodeAttribute_ECLevel(intVal)) { + pBarCodeWidget->SetErrorCorrectionLevel(intVal); + } + if (pAcc->GetBarcodeAttribute_ModuleWidth(intVal)) { + pBarCodeWidget->SetModuleWidth(intVal); + } + if (pAcc->GetBarcodeAttribute_ModuleHeight(intVal)) { + pBarCodeWidget->SetModuleHeight(intVal); + } + if (pAcc->GetBarcodeAttribute_PrintChecksum(boolVal)) { + pBarCodeWidget->SetPrintChecksum(boolVal); + } + if (pAcc->GetBarcodeAttribute_TextLocation(intVal)) { + pBarCodeWidget->SetTextLocation((BC_TEXT_LOC)intVal); + } + if (pAcc->GetBarcodeAttribute_Truncate(boolVal)) { + pBarCodeWidget->SetTruncated(boolVal); + } + if (pAcc->GetBarcodeAttribute_WideNarrowRatio(floatVal)) { + pBarCodeWidget->SetWideNarrowRatio((int32_t)floatVal); + } + if (pBarcodeTypeInfo->eName == XFA_BARCODETYPE_code3Of9 || + pBarcodeTypeInfo->eName == XFA_BARCODETYPE_ean8 || + pBarcodeTypeInfo->eName == XFA_BARCODETYPE_ean13 || + pBarcodeTypeInfo->eName == XFA_BARCODETYPE_upcA) { + pBarCodeWidget->SetPrintChecksum(TRUE); + } +} +FX_BOOL CXFA_FFBarcode::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { + return FALSE; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + return CXFA_FFTextEdit::OnLButtonDown(dwFlags, fx, fy); +} +FX_BOOL CXFA_FFBarcode::OnRButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { + return FALSE; + } + return CXFA_FFTextEdit::OnRButtonDown(dwFlags, fx, fy); +} +extern const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[] = { + {0x7fb4a18, L"ean13", XFA_BARCODETYPE_ean13, BC_EAN13}, + {0x8d13a3d, L"code11", XFA_BARCODETYPE_code11, BC_UNKNOWN}, + {0x8d149a8, L"code49", XFA_BARCODETYPE_code49, BC_UNKNOWN}, + {0x8d16347, L"code93", XFA_BARCODETYPE_code93, BC_UNKNOWN}, + {0x91a92e2, L"upsMaxicode", XFA_BARCODETYPE_upsMaxicode, BC_UNKNOWN}, + {0xa7d48dc, L"fim", XFA_BARCODETYPE_fim, BC_UNKNOWN}, + {0xb359fe9, L"msi", XFA_BARCODETYPE_msi, BC_UNKNOWN}, + {0x121f738c, L"code2Of5Matrix", XFA_BARCODETYPE_code2Of5Matrix, BC_UNKNOWN}, + {0x15358616, L"ucc128", XFA_BARCODETYPE_ucc128, BC_UNKNOWN}, + {0x1f4bfa05, L"rfid", XFA_BARCODETYPE_rfid, BC_UNKNOWN}, + {0x1fda71bc, L"rss14Stacked", XFA_BARCODETYPE_rss14Stacked, BC_UNKNOWN}, + {0x22065087, L"ean8add2", XFA_BARCODETYPE_ean8add2, BC_UNKNOWN}, + {0x2206508a, L"ean8add5", XFA_BARCODETYPE_ean8add5, BC_UNKNOWN}, + {0x2278366c, L"codabar", XFA_BARCODETYPE_codabar, BC_CODABAR}, + {0x2a039a8d, L"telepen", XFA_BARCODETYPE_telepen, BC_UNKNOWN}, + {0x323ed337, L"upcApwcd", XFA_BARCODETYPE_upcApwcd, BC_UNKNOWN}, + {0x347a1846, L"postUSIMB", XFA_BARCODETYPE_postUSIMB, BC_UNKNOWN}, + {0x391bb836, L"code128", XFA_BARCODETYPE_code128, BC_CODE128}, + {0x398eddaf, L"dataMatrix", XFA_BARCODETYPE_dataMatrix, BC_DATAMATRIX}, + {0x3cff60a8, L"upcEadd2", XFA_BARCODETYPE_upcEadd2, BC_UNKNOWN}, + {0x3cff60ab, L"upcEadd5", XFA_BARCODETYPE_upcEadd5, BC_UNKNOWN}, + {0x402cb188, L"code2Of5Standard", XFA_BARCODETYPE_code2Of5Standard, + BC_UNKNOWN}, + {0x411764f7, L"aztec", XFA_BARCODETYPE_aztec, BC_UNKNOWN}, + {0x44d4e84c, L"ean8", XFA_BARCODETYPE_ean8, BC_EAN8}, + {0x48468902, L"ucc128sscc", XFA_BARCODETYPE_ucc128sscc, BC_UNKNOWN}, + {0x4880aea4, L"upcAadd2", XFA_BARCODETYPE_upcAadd2, BC_UNKNOWN}, + {0x4880aea7, L"upcAadd5", XFA_BARCODETYPE_upcAadd5, BC_UNKNOWN}, + {0x54f18256, L"code2Of5Industrial", XFA_BARCODETYPE_code2Of5Industrial, + BC_UNKNOWN}, + {0x58e15f25, L"rss14Limited", XFA_BARCODETYPE_rss14Limited, BC_UNKNOWN}, + {0x5c08d1b9, L"postAUSReplyPaid", XFA_BARCODETYPE_postAUSReplyPaid, + BC_UNKNOWN}, + {0x5fa700bd, L"rss14", XFA_BARCODETYPE_rss14, BC_UNKNOWN}, + {0x631a7e35, L"logmars", XFA_BARCODETYPE_logmars, BC_UNKNOWN}, + {0x6a236236, L"pdf417", XFA_BARCODETYPE_pdf417, BC_PDF417}, + {0x6d098ece, L"upcean2", XFA_BARCODETYPE_upcean2, BC_UNKNOWN}, + {0x6d098ed1, L"upcean5", XFA_BARCODETYPE_upcean5, BC_UNKNOWN}, + {0x76b04eed, L"code3Of9extended", XFA_BARCODETYPE_code3Of9extended, + BC_UNKNOWN}, + {0x7c7db84a, L"maxicode", XFA_BARCODETYPE_maxicode, BC_UNKNOWN}, + {0x8266f7f7, L"ucc128random", XFA_BARCODETYPE_ucc128random, BC_UNKNOWN}, + {0x83eca147, L"postUSDPBC", XFA_BARCODETYPE_postUSDPBC, BC_UNKNOWN}, + {0x8dd71de0, L"postAUSStandard", XFA_BARCODETYPE_postAUSStandard, + BC_UNKNOWN}, + {0x98adad85, L"plessey", XFA_BARCODETYPE_plessey, BC_UNKNOWN}, + {0x9f84cce6, L"ean13pwcd", XFA_BARCODETYPE_ean13pwcd, BC_UNKNOWN}, + {0xb514fbe9, L"upcA", XFA_BARCODETYPE_upcA, BC_UPCA}, + {0xb514fbed, L"upcE", XFA_BARCODETYPE_upcE, BC_UNKNOWN}, + {0xb5c6a853, L"ean13add2", XFA_BARCODETYPE_ean13add2, BC_UNKNOWN}, + {0xb5c6a856, L"ean13add5", XFA_BARCODETYPE_ean13add5, BC_UNKNOWN}, + {0xb81fc512, L"postUKRM4SCC", XFA_BARCODETYPE_postUKRM4SCC, BC_UNKNOWN}, + {0xbad34b22, L"code128SSCC", XFA_BARCODETYPE_code128SSCC, BC_UNKNOWN}, + {0xbfbe0cf6, L"postUS5Zip", XFA_BARCODETYPE_postUS5Zip, BC_UNKNOWN}, + {0xc56618e8, L"pdf417macro", XFA_BARCODETYPE_pdf417macro, BC_UNKNOWN}, + {0xca730f8a, L"code2Of5Interleaved", XFA_BARCODETYPE_code2Of5Interleaved, + BC_UNKNOWN}, + {0xd0097ac6, L"rss14Expanded", XFA_BARCODETYPE_rss14Expanded, BC_UNKNOWN}, + {0xd25a0240, L"postAUSCust2", XFA_BARCODETYPE_postAUSCust2, BC_UNKNOWN}, + {0xd25a0241, L"postAUSCust3", XFA_BARCODETYPE_postAUSCust3, BC_UNKNOWN}, + {0xd53ed3e7, L"rss14Truncated", XFA_BARCODETYPE_rss14Truncated, BC_UNKNOWN}, + {0xe72bcd57, L"code128A", XFA_BARCODETYPE_code128A, BC_UNKNOWN}, + {0xe72bcd58, L"code128B", XFA_BARCODETYPE_code128B, BC_CODE128_B}, + {0xe72bcd59, L"code128C", XFA_BARCODETYPE_code128C, BC_CODE128_C}, + {0xee83c50f, L"rss14StackedOmni", XFA_BARCODETYPE_rss14StackedOmni, + BC_UNKNOWN}, + {0xf2a18f7e, L"QRCode", XFA_BARCODETYPE_QRCode, BC_QR_CODE}, + {0xfaeaf37f, L"postUSStandard", XFA_BARCODETYPE_postUSStandard, BC_UNKNOWN}, + {0xfb48155c, L"code3Of9", XFA_BARCODETYPE_code3Of9, BC_CODE39}, +}; +extern const int32_t g_iXFABarcodeTypeCount = + sizeof(g_XFABarCodeTypeEnumData) / sizeof(XFA_BARCODETYPEENUMINFO); +static 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.GetPtr(), iLength, TRUE); + int32_t iStart = 0, iEnd = g_iXFABarcodeTypeCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + XFA_LPCBARCODETYPEENUMINFO pInfo = g_XFABarCodeTypeEnumData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/xfa_ffbarcode.h new file mode 100644 index 0000000000..114a492e4d --- /dev/null +++ b/xfa/fxfa/app/xfa_ffbarcode.h @@ -0,0 +1,101 @@ +// 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_APP_XFA_FFBARCODE_H_ +#define XFA_FXFA_APP_XFA_FFBARCODE_H_ + +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/include/fxbarcode/BC_BarCode.h" + +class CXFA_FFBarcode : public CXFA_FFTextEdit { + public: + CXFA_FFBarcode(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFBarcode(); + virtual FX_BOOL LoadWidget(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual void UpdateWidgetProperty(); + virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); +}; + +enum XFA_BARCODETYPEENUM { + XFA_BARCODETYPE_aztec, + XFA_BARCODETYPE_codabar, + XFA_BARCODETYPE_code11, + XFA_BARCODETYPE_code128, + XFA_BARCODETYPE_code128A, + XFA_BARCODETYPE_code128B, + XFA_BARCODETYPE_code128C, + XFA_BARCODETYPE_code128SSCC, + XFA_BARCODETYPE_code2Of5Industrial, + XFA_BARCODETYPE_code2Of5Interleaved, + XFA_BARCODETYPE_code2Of5Matrix, + XFA_BARCODETYPE_code2Of5Standard, + XFA_BARCODETYPE_code3Of9, + XFA_BARCODETYPE_code3Of9extended, + XFA_BARCODETYPE_code49, + XFA_BARCODETYPE_code93, + XFA_BARCODETYPE_dataMatrix, + XFA_BARCODETYPE_ean13, + XFA_BARCODETYPE_ean13add2, + XFA_BARCODETYPE_ean13add5, + XFA_BARCODETYPE_ean13pwcd, + XFA_BARCODETYPE_ean8, + XFA_BARCODETYPE_ean8add2, + XFA_BARCODETYPE_ean8add5, + XFA_BARCODETYPE_fim, + XFA_BARCODETYPE_logmars, + XFA_BARCODETYPE_maxicode, + XFA_BARCODETYPE_msi, + XFA_BARCODETYPE_pdf417, + XFA_BARCODETYPE_pdf417macro, + XFA_BARCODETYPE_plessey, + XFA_BARCODETYPE_postAUSCust2, + XFA_BARCODETYPE_postAUSCust3, + XFA_BARCODETYPE_postAUSReplyPaid, + XFA_BARCODETYPE_postAUSStandard, + XFA_BARCODETYPE_postUKRM4SCC, + XFA_BARCODETYPE_postUS5Zip, + XFA_BARCODETYPE_postUSDPBC, + XFA_BARCODETYPE_postUSIMB, + XFA_BARCODETYPE_postUSStandard, + XFA_BARCODETYPE_QRCode, + XFA_BARCODETYPE_rfid, + XFA_BARCODETYPE_rss14, + XFA_BARCODETYPE_rss14Expanded, + XFA_BARCODETYPE_rss14Limited, + XFA_BARCODETYPE_rss14Stacked, + XFA_BARCODETYPE_rss14StackedOmni, + XFA_BARCODETYPE_rss14Truncated, + XFA_BARCODETYPE_telepen, + XFA_BARCODETYPE_ucc128, + XFA_BARCODETYPE_ucc128random, + XFA_BARCODETYPE_ucc128sscc, + XFA_BARCODETYPE_upcA, + XFA_BARCODETYPE_upcAadd2, + XFA_BARCODETYPE_upcAadd5, + XFA_BARCODETYPE_upcApwcd, + XFA_BARCODETYPE_upcE, + XFA_BARCODETYPE_upcEadd2, + XFA_BARCODETYPE_upcEadd5, + XFA_BARCODETYPE_upcean2, + XFA_BARCODETYPE_upcean5, + XFA_BARCODETYPE_upsMaxicode +}; +struct XFA_BARCODETYPEENUMINFO { + uint32_t uHash; + const FX_WCHAR* pName; + XFA_BARCODETYPEENUM eName; + BC_TYPE eBCType; +}; +typedef XFA_BARCODETYPEENUMINFO const* XFA_LPCBARCODETYPEENUMINFO; +extern const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[]; + +#endif // XFA_FXFA_APP_XFA_FFBARCODE_H_ diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp new file mode 100644 index 0000000000..862a2cd013 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -0,0 +1,335 @@ +// 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/fxfa/app/xfa_ffcheckbutton.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_ffexclgroup.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fwl/core/fwl_widgetmgr.h" +#include "xfa/include/fwl/lightwidget/checkbox.h" + +CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) { + m_rtCheckBox.Set(0, 0, 0, 0); +} +CXFA_FFCheckButton::~CXFA_FFCheckButton() {} +FX_BOOL CXFA_FFCheckButton::LoadWidget() { + CFWL_CheckBox* pCheckBox = CFWL_CheckBox::Create(); + pCheckBox->Initialize(); + m_pNormalWidget = pCheckBox; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = m_pNormalWidget->SetDelegate(this); + if (m_pDataAcc->IsRadioButton()) { + pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); + } + m_pNormalWidget = (CFWL_Widget*)pCheckBox; + m_pNormalWidget->SetPrivateData(m_pNormalWidget->GetWidget(), this, NULL); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); + SetFWLCheckState(eState); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFCheckButton::UpdateWidgetProperty() { + CFWL_CheckBox* pCheckBox = (CFWL_CheckBox*)m_pNormalWidget; + if (!m_pNormalWidget) { + return; + } + FX_FLOAT fSize = m_pDataAcc->GetCheckButtonSize(); + pCheckBox->SetBoxSize(fSize); + FX_DWORD dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross; + int32_t iCheckMark = m_pDataAcc->GetCheckButtonMark(); + switch (iCheckMark) { + case XFA_ATTRIBUTEENUM_Check: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCheck; + break; + case XFA_ATTRIBUTEENUM_Circle: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; + break; + case XFA_ATTRIBUTEENUM_Cross: + break; + case XFA_ATTRIBUTEENUM_Diamond: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeDiamond; + break; + case XFA_ATTRIBUTEENUM_Square: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeSquare; + break; + case XFA_ATTRIBUTEENUM_Star: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeStar; + break; + default: { + int32_t iShape = m_pDataAcc->GetCheckButtonShape(); + if (iShape == XFA_ATTRIBUTEENUM_Round) { + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; + } + } break; + } + if (m_pDataAcc->IsAllowNeutral()) { + dwStyleEx |= FWL_STYLEEXT_CKB_3State; + } + pCheckBox->ModifyStylesEx( + dwStyleEx, FWL_STYLEEXT_CKB_SignShapeMask | FWL_STYLEEXT_CKB_3State); +} +FX_BOOL CXFA_FFCheckButton::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + FX_FLOAT fCheckSize = m_pDataAcc->GetCheckButtonSize(); + CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + if (mgWidget) { + XFA_RectWidthoutMargin(rtWidget, mgWidget); + } + int32_t iCapPlacement = -1; + FX_FLOAT fCapReserve = 0; + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence()) { + m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, + rtWidget.height); + iCapPlacement = caption.GetPlacementType(); + fCapReserve = caption.GetReserve(); + if (fCapReserve <= 0) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { + fCapReserve = rtWidget.height - fCheckSize; + } else { + fCapReserve = rtWidget.width - fCheckSize; + } + } + } + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + m_rtUI = rtWidget; + CXFA_Margin mgCap = caption.GetMargin(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: { + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(mgCap); + m_rtUI.width -= fCapReserve; + m_rtUI.left += fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Top: { + m_rtCaption.height = fCapReserve; + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + m_rtUI.height -= fCapReserve; + m_rtUI.top += fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Right: { + m_rtCaption.left = m_rtCaption.right() - fCapReserve; + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(mgCap); + m_rtUI.width -= fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Bottom: { + m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; + m_rtCaption.height = fCapReserve; + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + m_rtUI.height -= fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Inline: + break; + default: + iHorzAlign = XFA_ATTRIBUTEENUM_Right; + break; + } + if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { + m_rtUI.left += (m_rtUI.width - fCheckSize) / 2; + } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { + m_rtUI.left = m_rtUI.right() - fCheckSize; + } + if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { + m_rtUI.top += (m_rtUI.height - fCheckSize) / 2; + } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { + m_rtUI.top = m_rtUI.bottom() - fCheckSize; + } + m_rtUI.width = fCheckSize; + m_rtUI.height = fCheckSize; + AddUIMargin(iCapPlacement); + m_rtCheckBox = m_rtUI; + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + if (borderUI) { + CXFA_Margin margin = borderUI.GetMargin(); + if (margin) { + XFA_RectWidthoutMargin(m_rtUI, margin); + } + } + m_rtUI.Normalize(); + LayoutCaption(); + SetFWLRect(); + if (m_pNormalWidget) { + m_pNormalWidget->Update(); + } + return TRUE; +} +void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) { + m_rtCaption.top += m_rtCaption.height; + } + if (m_rtCaption.width < 0) { + m_rtCaption.left += m_rtCaption.width; + m_rtCaption.width = -m_rtCaption.width; + } +} +void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) { + CFX_RectF rtUIMargin; + m_pDataAcc->GetUIMargin(rtUIMargin); + m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2; + FX_FLOAT fLeftAddRight = rtUIMargin.left + rtUIMargin.width; + FX_FLOAT fTopAddBottom = rtUIMargin.top + rtUIMargin.height; + if (m_rtUI.width < fLeftAddRight) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right || + iCapPlacement == XFA_ATTRIBUTEENUM_Left) { + m_rtUI.left -= fLeftAddRight - m_rtUI.width; + } else { + m_rtUI.left -= 2 * (fLeftAddRight - m_rtUI.width); + } + m_rtUI.width += 2 * (fLeftAddRight - m_rtUI.width); + } + if (m_rtUI.height < fTopAddBottom) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) { + m_rtUI.left -= fTopAddBottom - m_rtUI.height; + } + m_rtUI.top -= fTopAddBottom - m_rtUI.height; + m_rtUI.height += 2 * (fTopAddBottom - m_rtUI.height); + } +} +void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate, + m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round + ? XFA_DRAWBOX_ForceRound + : 0); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, + m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), + pGS, &mt); +} +FX_BOOL CXFA_FFCheckButton::OnLButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + if (!IsButtonDown()) { + return FALSE; + } + SetButtonDown(FALSE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { + XFA_CHECKSTATE eCheckState = XFA_CHECKSTATE_Off; + FX_DWORD dwState = m_pNormalWidget->GetStates(); + if (dwState & FWL_STATE_CKB_Checked) { + eCheckState = XFA_CHECKSTATE_On; + } else if (dwState & FWL_STATE_CKB_Neutral) { + eCheckState = XFA_CHECKSTATE_Neutral; + } + return eCheckState; +} +FX_BOOL CXFA_FFCheckButton::CommitData() { + XFA_CHECKSTATE eCheckState = FWLState2XFAState(); + m_pDataAcc->SetCheckState(eCheckState, TRUE); + return TRUE; +} +FX_BOOL CXFA_FFCheckButton::IsDataChanged() { + XFA_CHECKSTATE eCheckState = FWLState2XFAState(); + return m_pDataAcc->GetCheckState() != eCheckState; +} +void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { + if (eCheckState == XFA_CHECKSTATE_Neutral) { + m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral, TRUE); + } else { + m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked, + eCheckState == XFA_CHECKSTATE_On); + } +} +FX_BOOL CXFA_FFCheckButton::UpdateFWLData() { + if (!m_pNormalWidget) { + return FALSE; + } + XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); + SetFWLCheckState(eState); + m_pNormalWidget->Update(); + return TRUE; +} +int32_t CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + FX_DWORD dwEventID = pEvent->GetClassID(); + switch (dwEventID) { + case FWL_EVTHASH_CKB_CheckStateChanged: { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); + CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup(); + if (ProcessCommittedData()) { + eParam.m_pTarget = pFFExclGroup; + if (pFFExclGroup) { + m_pDocView->AddValidateWidget(pFFExclGroup); + m_pDocView->AddCalculateWidgetAcc(pFFExclGroup); + pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); + } + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); + } else { + SetFWLCheckState(m_pDataAcc->GetCheckState()); + } + if (pFFExclGroup) { + eParam.m_pTarget = pFFExclGroup; + pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + } + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + break; + } + default: {} + } + return m_pOldDelegate->OnProcessEvent(pEvent); +} +FWL_ERR CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/xfa_ffcheckbutton.h new file mode 100644 index 0000000000..852736577d --- /dev/null +++ b/xfa/fxfa/app/xfa_ffcheckbutton.h @@ -0,0 +1,43 @@ +// 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_APP_XFA_FFCHECKBUTTON_H_ +#define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ + +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" + +class CXFA_FFCheckButton : public CXFA_FFField { + public: + CXFA_FFCheckButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFCheckButton(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + + virtual FX_BOOL LoadWidget(); + virtual FX_BOOL PerformLayout(); + virtual FX_BOOL UpdateFWLData(); + virtual void UpdateWidgetProperty(); + virtual FX_BOOL OnLButtonUp(FX_DWORD 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); + + protected: + virtual FX_BOOL CommitData(); + virtual FX_BOOL IsDataChanged(); + void CapLeftRightPlacement(CXFA_Margin mgCap); + void AddUIMargin(int32_t iCapPlacement); + XFA_CHECKSTATE FWLState2XFAState(); + IFWL_WidgetDelegate* m_pOldDelegate; + CFX_RectF m_rtCheckBox; +}; + +#endif // XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp new file mode 100644 index 0000000000..2789e073f4 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -0,0 +1,530 @@ +// 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/fxfa/app/xfa_ffchoicelist.h" + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/lightwidget/combobox.h" +#include "xfa/include/fwl/lightwidget/listbox.h" + +CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} +CXFA_FFListBox::~CXFA_FFListBox() { + if (m_pNormalWidget) { + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(pWidget); + } +} +FX_BOOL CXFA_FFListBox::LoadWidget() { + CFWL_ListBox* pListBox = CFWL_ListBox::Create(); + pListBox->Initialize(); + pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, + 0xFFFFFFFF); + m_pNormalWidget = (CFWL_Widget*)pListBox; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + CFX_WideStringArray wsLabelArray; + m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); + int32_t iItems = wsLabelArray.GetSize(); + for (int32_t i = 0; i < iItems; i++) { + pListBox->AddString(wsLabelArray[i]); + } + FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; + if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + CFX_Int32Array iSelArray; + m_pDataAcc->GetSelectedItems(iSelArray); + int32_t iSelCount = iSelArray.GetSize(); + for (int32_t j = 0; j < iSelCount; j++) { + FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]); + pListBox->SetSelItem(item, TRUE); + } + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +FX_BOOL CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { + FX_BOOL flag = ProcessCommittedData(); + if (!flag) { + UpdateFWLData(); + } + CXFA_FFField::OnKillFocus(pNewFocus); + return TRUE; +} +FX_BOOL CXFA_FFListBox::CommitData() { + CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); + int32_t iSels = pListBox->CountSelItems(); + CFX_Int32Array iSelArray; + for (int32_t i = 0; i < iSels; i++) { + iSelArray.Add(pListBox->GetSelIndex(i)); + } + m_pDataAcc->SetSelectdItems(iSelArray, TRUE); + return TRUE; +} +FX_BOOL CXFA_FFListBox::IsDataChanged() { + CFX_Int32Array iSelArray; + m_pDataAcc->GetSelectedItems(iSelArray); + int32_t iOldSels = iSelArray.GetSize(); + CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; + int32_t iSels = pListBox->CountSelItems(); + if (iOldSels == iSels) { + int32_t iIndex = 0; + for (; iIndex < iSels; iIndex++) { + FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[iIndex]); + if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) { + break; + } + } + if (iIndex == iSels) { + return FALSE; + } + } + return TRUE; +} +FX_DWORD CXFA_FFListBox::GetAlignment() { + FX_DWORD dwExtendedStyle = 0; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + int32_t iHorz = para.GetHorizontalAlign(); + switch (iHorz) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; + break; + case XFA_ATTRIBUTEENUM_Justify: + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; + break; + } + } + return dwExtendedStyle; +} +FX_BOOL CXFA_FFListBox::UpdateFWLData() { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); + CFX_ArrayTemplate<FWL_HLISTITEM> selItemArray; + CFX_Int32Array iSelArray; + m_pDataAcc->GetSelectedItems(iSelArray); + int32_t iSelCount = iSelArray.GetSize(); + for (int32_t j = 0; j < iSelCount; j++) { + FWL_HLISTITEM lpItemSel = pListBox->GetSelItem(iSelArray[j]); + selItemArray.Add(lpItemSel); + } + pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE); + for (int32_t i = 0; i < iSelCount; i++) { + ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], TRUE); + } + m_pNormalWidget->Update(); + return TRUE; +} +void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, + const CFX_Int32Array& arrSels) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; + int32_t iSels = pListBox->CountSelItems(); + if (iSels > 0) { + pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText); + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} +void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { + FWL_HLISTITEM item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); + ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, + int32_t nIndex) { + CFX_WideString wsTemp(wsLabel); + ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +void CXFA_FFListBox::DeleteItem(int32_t nIndex) { + if (nIndex < 0) { + ((CFWL_ListBox*)m_pNormalWidget)->DeleteAll(); + } else { + ((CFWL_ListBox*)m_pNormalWidget) + ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex)); + } + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + FX_DWORD dwEventID = pEvent->GetClassID(); + switch (dwEventID) { + case FWL_EVTHASH_LTB_SelChanged: { + CFX_Int32Array arrSels; + OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); + break; + } + default: {} + } + return m_pOldDelegate->OnProcessEvent(pEvent); +} +FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} + +CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} + +CXFA_FFComboBox::~CXFA_FFComboBox() {} + +FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus) { + if (bDrawFocus) + return FALSE; + return CXFA_FFWidget::GetBBox(rtBox, dwStatus); +} + +FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFX_RectF rtWidget; + ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); + if (rtWidget.Contains(fx, fy)) { + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_FFComboBox::LoadWidget() { + CFWL_ComboBox* pComboBox = CFWL_ComboBox::Create(); + pComboBox->Initialize(); + m_pNormalWidget = (CFWL_Widget*)pComboBox; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + CFX_WideStringArray wsLabelArray; + m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); + int32_t iItems = wsLabelArray.GetSize(); + for (int32_t i = 0; i < iItems; i++) { + pComboBox->AddString(wsLabelArray[i]); + } + CFX_Int32Array iSelArray; + m_pDataAcc->GetSelectedItems(iSelArray); + int32_t iSelCount = iSelArray.GetSize(); + if (iSelCount > 0) { + pComboBox->SetCurSel(iSelArray[0]); + } else { + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); + pComboBox->SetEditText(wsText); + } + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFComboBox::UpdateWidgetProperty() { + CFWL_ComboBox* pComboBox = (CFWL_ComboBox*)m_pNormalWidget; + if (!pComboBox) { + return; + } + FX_DWORD dwExtendedStyle = 0; + FX_DWORD dwEditStyles = + FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->IsChoiceListAllowTextEntry()) { + dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; + } + pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); +} +FX_BOOL CXFA_FFComboBox::OnRButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) + return FALSE; + + GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); + return TRUE; +} +FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { + FX_BOOL flag = ProcessCommittedData(); + if (!flag) { + UpdateFWLData(); + } + CXFA_FFField::OnKillFocus(pNewWidget); + return TRUE; +} +void CXFA_FFComboBox::OpenDropDownList() { + ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(TRUE); +} +FX_BOOL CXFA_FFComboBox::CommitData() { + return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); +} +FX_BOOL CXFA_FFComboBox::IsDataChanged() { + CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); + CFX_WideString wsText; + pFWLcombobox->GetEditText(wsText); + int32_t iCursel = pFWLcombobox->GetCurSel(); + if (iCursel >= 0) { + CFX_WideString wsSel; + pFWLcombobox->GetTextByIndex(iCursel, wsSel); + if (wsSel == wsText) { + m_pDataAcc->GetChoiceListItem(wsText, iCursel, TRUE); + } + } + CFX_WideString wsOldValue; + m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); + if (wsOldValue != wsText) { + m_wsNewValue = wsText; + return TRUE; + } + return FALSE; +} +void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { + pParam->m_eType = XFA_EVENT_Change; + pParam->m_pTarget = m_pDataAcc; + CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); + pFWLcombobox->GetEditText(pParam->m_wsNewText); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); +} +FX_DWORD CXFA_FFComboBox::GetAlignment() { + FX_DWORD dwExtendedStyle = 0; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + int32_t iHorz = para.GetHorizontalAlign(); + switch (iHorz) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= + FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + break; + default: + dwExtendedStyle |= + FWL_STYLEEXT_CMB_EditHNear | FWL_STYLEEXT_CMB_ListItemLeftAlign; + break; + } + int32_t iVert = para.GetVerticalAlign(); + switch (iVert) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; + break; + } + } + return dwExtendedStyle; +} +FX_BOOL CXFA_FFComboBox::UpdateFWLData() { + if (!m_pNormalWidget) { + return FALSE; + } + CFX_Int32Array iSelArray; + m_pDataAcc->GetSelectedItems(iSelArray); + int32_t iSelCount = iSelArray.GetSize(); + if (iSelCount > 0) { + ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); + } else { + CFX_WideString wsText; + ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); + ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); + } + m_pNormalWidget->Update(); + return TRUE; +} +FX_BOOL CXFA_FFComboBox::CanUndo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditCanUndo(); +} +FX_BOOL CXFA_FFComboBox::CanRedo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditCanRedo(); +} +FX_BOOL CXFA_FFComboBox::Undo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditUndo(); +} +FX_BOOL CXFA_FFComboBox::Redo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditRedo(); +} +FX_BOOL CXFA_FFComboBox::CanCopy() { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCopy(); +} +FX_BOOL CXFA_FFComboBox::CanCut() { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCut(); +} +FX_BOOL CXFA_FFComboBox::CanPaste() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + (m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open); +} +FX_BOOL CXFA_FFComboBox::CanSelectAll() { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanSelectAll(); +} +FX_BOOL CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditCopy(wsCopy); +} +FX_BOOL CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditCut(wsCut); +} +FX_BOOL CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste); +} +FX_BOOL CXFA_FFComboBox::SelectAll() { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll(); +} +FX_BOOL CXFA_FFComboBox::Delete() { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete(); +} +FX_BOOL CXFA_FFComboBox::DeSelect() { + return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect(); +} +void CXFA_FFComboBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { + if (bSelected) { + ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(nIndex); + } else { + ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); + } + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, + int32_t nIndex) { + ((CFWL_ComboBox*)m_pNormalWidget)->AddString(wsLabel); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { + if (nIndex < 0) { + ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAll(); + } else { + ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAt(nIndex); + } + m_pNormalWidget->Update(); + AddInvalidateRect(); +} +void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget, + const CFX_WideString& wsChanged) { + CXFA_EventParam eParam; + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + eParam.m_wsChange = wsChanged; + FWLEventSelChange(&eParam); +} +void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget, + const CFX_Int32Array& arrSels, + FX_BOOL bLButtonUp) { + CXFA_EventParam eParam; + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + FWLEventSelChange(&eParam); + if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && + bLButtonUp) { + m_pDocView->SetFocusWidgetAcc(NULL); + } +} +void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_PreOpen; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam); +} +void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_PostOpen; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); +} + +int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + FX_DWORD dwEventID = pEvent->GetClassID(); + switch (dwEventID) { + case FWL_EVTHASH_CMB_SelChanged: { + CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent; + OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels, + postEvent->bLButtonUp); + break; + } + case FWL_EVTHASH_CMB_EditChanged: { + CFX_WideString wsChanged; + OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); + break; + } + case FWL_EVTHASH_CMB_PreDropDown: { + OnPreOpen(m_pNormalWidget->GetWidget()); + break; + } + case FWL_EVTHASH_CMB_PostDropDown: { + OnPostOpen(m_pNormalWidget->GetWidget()); + break; + } + default: {} + } + return m_pOldDelegate->OnProcessEvent(pEvent); +} +FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h new file mode 100644 index 0000000000..1699b18039 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffchoicelist.h @@ -0,0 +1,96 @@ +// 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_APP_XFA_FFCHOICELIST_H_ +#define XFA_FXFA_APP_XFA_FFCHOICELIST_H_ + +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" + +class CXFA_FFListBox : public CXFA_FFField { + public: + CXFA_FFListBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFListBox(); + virtual FX_BOOL LoadWidget(); + virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); + + protected: + virtual FX_BOOL CommitData(); + virtual FX_BOOL UpdateFWLData(); + virtual FX_BOOL IsDataChanged(); + FX_DWORD GetAlignment(); + + public: + void OnSelectChanged(IFWL_Widget* pWidget, const CFX_Int32Array& arrSels); + 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); + + protected: + IFWL_WidgetDelegate* m_pOldDelegate; +}; +class CXFA_FFComboBox : public CXFA_FFField { + public: + CXFA_FFComboBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFComboBox(); + virtual FX_BOOL GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus = FALSE); + virtual FX_BOOL LoadWidget(); + virtual void UpdateWidgetProperty(); + virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); + 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 CanPaste(); + 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(); + void OpenDropDownList(); + + protected: + virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL CommitData(); + virtual FX_BOOL UpdateFWLData(); + virtual FX_BOOL IsDataChanged(); + FX_DWORD GetAlignment(); + void FWLEventSelChange(CXFA_EventParam* pParam); + + CFX_WideString m_wsNewValue; + + public: + void OnTextChanged(IFWL_Widget* pWidget, const CFX_WideString& wsChanged); + void OnSelectChanged(IFWL_Widget* pWidget, + const CFX_Int32Array& arrSels, + FX_BOOL bLButtonUp); + void OnPreOpen(IFWL_Widget* pWidget); + void OnPostOpen(IFWL_Widget* pWidget); + 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); + + protected: + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_XFA_FFCHOICELIST_H_ diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp new file mode 100644 index 0000000000..e33dd4fa47 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -0,0 +1,431 @@ +// 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/fxfa/app/xfa_ffdoc.h" + +#include "core/include/fpdfapi/cpdf_array.h" +#include "core/include/fpdfapi/cpdf_document.h" +#include "core/include/fpdfdoc/fpdf_doc.h" +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_algorithm.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fontmgr.h" +#include "xfa/fxfa/parser/xfa_docdata.h" +#include "xfa/fxfa/parser/xfa_parser.h" +#include "xfa/include/fwl/core/fwl_note.h" + +CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) + : m_pDocProvider(pDocProvider), + m_pDocument(nullptr), + m_pStream(nullptr), + m_pApp(pApp), + m_pNotify(nullptr), + m_pPDFDoc(nullptr), + m_dwDocType(XFA_DOCTYPE_Static), + m_bOwnStream(TRUE) {} +CXFA_FFDoc::~CXFA_FFDoc() { + CloseDoc(); +} +FX_DWORD CXFA_FFDoc::GetDocType() { + return m_dwDocType; +} +int32_t CXFA_FFDoc::StartLoad() { + m_pNotify = new CXFA_FFNotify(this); + IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify); + int32_t iStatus = pDocParser->StartParse(m_pStream); + m_pDocument = pDocParser->GetDocument(); + return iStatus; +} +FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, + uint8_t*& pByteBuffer, + int32_t& iBufferSize) { + IFDE_XMLElement* pDocumentElement = NULL; + for (IFDE_XMLNode* pXMLNode = + pPDFElement->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + CFX_WideString wsTagName; + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + pXMLElement->GetTagName(wsTagName); + if (wsTagName.Equal(FX_WSTRC(L"document"))) { + pDocumentElement = pXMLElement; + break; + } + } + } + if (!pDocumentElement) { + return FALSE; + } + IFDE_XMLElement* pChunkElement = NULL; + for (IFDE_XMLNode* pXMLNode = + pDocumentElement->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + CFX_WideString wsTagName; + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + pXMLElement->GetTagName(wsTagName); + if (wsTagName.Equal(FX_WSTRC(L"chunk"))) { + pChunkElement = pXMLElement; + break; + } + } + } + if (!pChunkElement) { + return FALSE; + } + CFX_WideString wsPDFContent; + pChunkElement->GetTextData(wsPDFContent); + iBufferSize = FX_Base64DecodeW(wsPDFContent, 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); + return TRUE; +} +void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) { + CXFA_Node* pChildNode = pNewRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChildNode) { + CXFA_Node* pOriginChild = + pOriginRoot->GetFirstChildByName(pChildNode->GetNameHash()); + if (pOriginChild) { + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } else { + CXFA_Node* pNextSibling = + pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pNewRoot->RemoveChild(pChildNode); + pOriginRoot->InsertChild(pChildNode); + pChildNode = pNextSibling; + pNextSibling = NULL; + } + } +} +int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { + int32_t iStatus = m_pDocument->GetParser()->DoParse(pPause); + if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) { + CXFA_Node* pPDFNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Pdf)); + if (!pPDFNode) { + return XFA_PARSESTATUS_SyntaxErr; + } + IFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); + if (pPDFXML->GetType() != FDE_XMLNODE_Element) { + return XFA_PARSESTATUS_SyntaxErr; + } + int32_t iBufferSize = 0; + uint8_t* pByteBuffer = NULL; + IFX_FileRead* pXFAReader = NULL; + if (XFA_GetPDFContentsFromPDFXML(pPDFXML, pByteBuffer, iBufferSize)) { + pXFAReader = FX_CreateMemoryStream(pByteBuffer, iBufferSize, TRUE); + } else { + CFX_WideString wsHref; + ((IFDE_XMLElement*)pPDFXML)->GetString(L"href", wsHref); + if (!wsHref.IsEmpty()) { + pXFAReader = GetDocProvider()->OpenLinkedFile(this, wsHref); + } + } + if (!pXFAReader) { + return XFA_PARSESTATUS_SyntaxErr; + } + CPDF_Document* pPDFDocument = + GetDocProvider()->OpenPDF(this, pXFAReader, TRUE); + FXSYS_assert(!m_pPDFDoc); + if (!OpenDoc(pPDFDocument)) { + return XFA_PARSESTATUS_SyntaxErr; + } + IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument, TRUE); + if (!pParser) { + return XFA_PARSESTATUS_SyntaxErr; + } + CXFA_Node* pRootNode = NULL; + if (pParser->StartParse(m_pStream) == XFA_PARSESTATUS_Ready && + pParser->DoParse(NULL) == XFA_PARSESTATUS_Done) { + pRootNode = pParser->GetRootNode(); + } + if (pRootNode && m_pDocument->GetRoot()) { + XFA_XPDPacket_MergeRootNode(m_pDocument->GetRoot(), pRootNode); + iStatus = XFA_PARSESTATUS_Done; + } else { + iStatus = XFA_PARSESTATUS_StatusErr; + } + pParser->Release(); + pParser = NULL; + } + return iStatus; +} +void CXFA_FFDoc::StopLoad() { + m_pApp->GetXFAFontMgr()->LoadDocFonts(this); + m_dwDocType = XFA_DOCTYPE_Static; + CXFA_Node* pConfig = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); + if (!pConfig) { + return; + } + CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); + if (!pAcrobat) { + return; + } + CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_ELEMENT_Acrobat7); + if (!pAcrobat7) { + return; + } + CXFA_Node* pDynamicRender = + pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); + if (!pDynamicRender) { + return; + } + CFX_WideString wsType; + if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { + m_dwDocType = XFA_DOCTYPE_Dynamic; + } +} +IXFA_DocView* CXFA_FFDoc::CreateDocView(FX_DWORD 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; +} +CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* 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; + } + } + return NULL; +} +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; +} +FX_BOOL CXFA_FFDoc::OpenDoc(IFX_FileRead* pStream, FX_BOOL bTakeOverFile) { + m_bOwnStream = bTakeOverFile; + m_pStream = pStream; + return TRUE; +} +FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { + if (pPDFDoc == NULL) { + return FALSE; + } + CPDF_Dictionary* pRoot = pPDFDoc->GetRoot(); + if (pRoot == NULL) { + return FALSE; + } + CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); + if (pAcroForm == NULL) { + return FALSE; + } + CPDF_Object* pElementXFA = pAcroForm->GetElementValue("XFA"); + if (pElementXFA == NULL) { + return FALSE; + } + CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; + if (pElementXFA->IsArray()) { + CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; + FX_DWORD count = pXFAArray->GetCount() / 2; + for (FX_DWORD i = 0; i < count; i++) { + if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) + xfaStreams.Add(pStream); + } + } else if (pElementXFA->IsStream()) { + xfaStreams.Add((CPDF_Stream*)pElementXFA); + } + if (xfaStreams.GetSize() < 1) { + return FALSE; + } + IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); + m_pPDFDoc = pPDFDoc; + if (m_pStream) { + m_pStream->Release(); + m_pStream = NULL; + } + m_pStream = pFileRead; + m_bOwnStream = TRUE; + 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) { + 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(); + if (m_pDocument) { + IXFA_Parser* pParser = m_pDocument->GetParser(); + pParser->Release(); + m_pDocument = NULL; + } + if (m_pNotify) { + delete m_pNotify; + m_pNotify = NULL; + } + 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_mapNamedImages.RemoveAll(); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->ClearEventTargets(FALSE); + return TRUE; +} +void CXFA_FFDoc::SetDocType(FX_DWORD dwType) { + m_dwDocType = dwType; +} +CPDF_Document* CXFA_FFDoc::GetPDFDoc() { + return m_pPDFDoc; +} + +CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + if (!m_pPDFDoc) + return nullptr; + + FX_DWORD dwHash = + FX_HashCode_String_GetW(wsName.GetPtr(), 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); + } + + CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); + if (!pRoot) + return nullptr; + + CPDF_Dictionary* pNames = pRoot->GetDictBy("Names"); + if (!pNames) + return nullptr; + + CPDF_Dictionary* pXFAImages = pNames->GetDictBy("XFAImages"); + if (!pXFAImages) + return nullptr; + + CPDF_NameTree nametree(pXFAImages); + CFX_ByteString bsName = PDF_EncodeText(wsName.GetPtr(), wsName.GetLength()); + CPDF_Object* pObject = nametree.LookupValue(bsName); + if (!pObject) { + int32_t iCount = nametree.GetCount(); + for (int32_t i = 0; i < iCount; i++) { + CFX_ByteString bsTemp; + CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); + if (bsTemp == bsName) { + pObject = pTempObject; + break; + } + } + } + + if (!pObject || !pObject->IsStream()) + 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; +} + +IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { + FX_DWORD packetHash = + FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); + CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); + if (!pNode) { + return NULL; + } + IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); + return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) + ? (IFDE_XMLElement*)pXMLNode + : NULL; +} +FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, + IFX_FileWrite* pFile, + IXFA_ChecksumContext* pCSContext) { + IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); + if (!pExport) { + return FALSE; + } + FX_DWORD packetHash = + FX_HashCode_String_GetW(wsPackage.GetPtr(), 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; +} +FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { + FX_BOOL bRet = FALSE; + IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); + if (pImport) { + bRet = pImport->ImportData(pStream); + pImport->Release(); + } + return bRet; +} diff --git a/xfa/fxfa/app/xfa_ffdoc.h b/xfa/fxfa/app/xfa_ffdoc.h new file mode 100644 index 0000000000..d656d30de7 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdoc.h @@ -0,0 +1,64 @@ +// 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_APP_XFA_FFDOC_H_ +#define XFA_FXFA_APP_XFA_FFDOC_H_ + +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_FFApp; +class CXFA_FFNotify; +class CXFA_FFDocView; + +struct FX_IMAGEDIB_AND_DPI { + CFX_DIBSource* pDibSource; + int32_t iImageXDpi; + int32_t iImageYDpi; +}; + +class CXFA_FFDoc : public IXFA_Doc { + public: + CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider); + ~CXFA_FFDoc(); + IXFA_DocProvider* GetDocProvider() { return m_pDocProvider; } + FX_DWORD GetDocType(); + int32_t StartLoad(); + int32_t DoLoad(IFX_Pause* pPause = NULL); + void StopLoad(); + IXFA_DocView* CreateDocView(FX_DWORD dwView = 0); + FX_BOOL OpenDoc(IFX_FileRead* pStream, FX_BOOL bTakeOverFile); + FX_BOOL OpenDoc(CPDF_Document* pPDFDoc); + FX_BOOL CloseDoc(); + void SetDocType(FX_DWORD dwType); + CXFA_Document* GetXFADoc() { return m_pDocument; } + CXFA_FFApp* GetApp() { return m_pApp; } + CXFA_FFDocView* GetDocView(IXFA_DocLayout* pLayout); + CXFA_FFDocView* GetDocView(); + CPDF_Document* GetPDFDoc(); + CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi); + IFDE_XMLElement* GetPackageData(const CFX_WideStringC& wsPackage); + FX_BOOL SavePackage(const CFX_WideStringC& wsPackage, + IFX_FileWrite* pFile, + IXFA_ChecksumContext* pCSContext = NULL); + FX_BOOL ImportData(IFX_FileRead* pStream, FX_BOOL bXDP = TRUE); + + protected: + IXFA_DocProvider* m_pDocProvider; + CXFA_Document* m_pDocument; + IFX_FileRead* m_pStream; + CXFA_FFApp* m_pApp; + CXFA_FFNotify* m_pNotify; + CPDF_Document* m_pPDFDoc; + CFX_MapPtrToPtr m_mapNamedImages; + CFX_MapPtrToPtr m_mapTypeToDocView; + FX_DWORD m_dwDocType; + FX_BOOL m_bOwnStream; +}; + +#endif // XFA_FXFA_APP_XFA_FFDOC_H_ diff --git a/xfa/fxfa/app/xfa_ffdochandler.cpp b/xfa/fxfa/app/xfa_ffdochandler.cpp new file mode 100644 index 0000000000..5ea7884134 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdochandler.cpp @@ -0,0 +1,110 @@ +// 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/fxfa/app/xfa_ffdochandler.h" + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/parser/xfa_script.h" + +CXFA_FFDocHandler::CXFA_FFDocHandler() {} +CXFA_FFDocHandler::~CXFA_FFDocHandler() {} +void CXFA_FFDocHandler::ReleaseDoc(IXFA_Doc* hDoc) { + delete hDoc; // virtual dtor. +} +IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(IXFA_Doc* hDoc) { + return static_cast<CXFA_FFDoc*>(hDoc)->GetDocProvider(); +} +FX_DWORD CXFA_FFDocHandler::GetDocType(IXFA_Doc* hDoc) { + return static_cast<CXFA_FFDoc*>(hDoc)->GetDocType(); +} +int32_t CXFA_FFDocHandler::StartLoad(IXFA_Doc* hDoc) { + return static_cast<CXFA_FFDoc*>(hDoc)->StartLoad(); +} +int32_t CXFA_FFDocHandler::DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause) { + return static_cast<CXFA_FFDoc*>(hDoc)->DoLoad(pPause); +} +void CXFA_FFDocHandler::StopLoad(IXFA_Doc* hDoc) { + static_cast<CXFA_FFDoc*>(hDoc)->StopLoad(); +} + +IXFA_DocView* CXFA_FFDocHandler::CreateDocView(IXFA_Doc* hDoc, + FX_DWORD dwView) { + return static_cast<CXFA_FFDoc*>(hDoc)->CreateDocView(dwView); +} +int32_t CXFA_FFDocHandler::CountPackages(IXFA_Doc* hDoc) { + return 0; +} +void CXFA_FFDocHandler::GetPackageName(IXFA_Doc* hDoc, + int32_t iPackage, + CFX_WideStringC& wsPackage) {} +IFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( + IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage) { + return static_cast<CXFA_FFDoc*>(hDoc)->GetPackageData(wsPackage); +} +FX_BOOL CXFA_FFDocHandler::SavePackage(IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage, + IFX_FileWrite* pFile, + IXFA_ChecksumContext* pCSContext) { + return static_cast<CXFA_FFDoc*>(hDoc) + ->SavePackage(wsPackage, pFile, pCSContext); +} +FX_BOOL CXFA_FFDocHandler::CloseDoc(IXFA_Doc* hDoc) { + return static_cast<CXFA_FFDoc*>(hDoc)->CloseDoc(); +} + +FX_BOOL CXFA_FFDocHandler::ImportData(IXFA_Doc* hDoc, + IFX_FileRead* pStream, + FX_BOOL bXDP) { + return static_cast<CXFA_FFDoc*>(hDoc)->ImportData(pStream, bXDP); +} +void CXFA_FFDocHandler::SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime) { + static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc()->InitScriptContext(hRuntime); +} +FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(IXFA_Doc* hDoc) { + CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); + if (!pXFADoc) { + return NULL; + } + IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); + if (!pScriptContext) { + return NULL; + } + return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); +} +XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(IXFA_Doc* hDoc) { + CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); + if (!pXFADoc) { + return XFA_ATTRIBUTEENUM_Unknown; + } + CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); + if (!pForm) { + return XFA_ATTRIBUTEENUM_Unknown; + } + CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); + if (!pSubForm) { + return XFA_ATTRIBUTEENUM_Unknown; + } + return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); +} +FX_BOOL CXFA_FFDocHandler::RunDocScript(IXFA_Doc* hDoc, + XFA_SCRIPTTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + FXJSE_HVALUE hThisObject) { + CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); + if (!pXFADoc) { + return FALSE; + } + IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); + if (!pScriptContext) { + return FALSE; + } + return pScriptContext->RunScript( + (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, + hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) + : NULL); +} diff --git a/xfa/fxfa/app/xfa_ffdochandler.h b/xfa/fxfa/app/xfa_ffdochandler.h new file mode 100644 index 0000000000..47dd85fa81 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdochandler.h @@ -0,0 +1,50 @@ +// 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_APP_XFA_FFDOCHANDLER_H_ +#define XFA_FXFA_APP_XFA_FFDOCHANDLER_H_ + +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_FFDocHandler : public IXFA_DocHandler { + public: + CXFA_FFDocHandler(); + ~CXFA_FFDocHandler(); + virtual void ReleaseDoc(IXFA_Doc* hDoc); + virtual IXFA_DocProvider* GetDocProvider(IXFA_Doc* hDoc); + virtual FX_DWORD GetDocType(IXFA_Doc* hDoc); + virtual int32_t StartLoad(IXFA_Doc* hDoc); + virtual int32_t DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause = NULL); + virtual void StopLoad(IXFA_Doc* hDoc); + + virtual IXFA_DocView* CreateDocView(IXFA_Doc* hDoc, FX_DWORD dwView = 0); + virtual int32_t CountPackages(IXFA_Doc* hDoc); + virtual void GetPackageName(IXFA_Doc* hDoc, + int32_t iPackage, + CFX_WideStringC& wsPackage); + virtual IFDE_XMLElement* GetPackageData(IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage); + virtual FX_BOOL SavePackage(IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage, + IFX_FileWrite* pFile, + IXFA_ChecksumContext* pCSContext = NULL); + virtual FX_BOOL CloseDoc(IXFA_Doc* hDoc); + virtual FX_BOOL ImportData(IXFA_Doc* hDoc, + IFX_FileRead* pStream, + FX_BOOL bXDP = TRUE); + virtual void SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime); + virtual FXJSE_HVALUE GetXFAScriptObject(IXFA_Doc* hDoc); + virtual XFA_ATTRIBUTEENUM GetRestoreState(IXFA_Doc* hDoc); + virtual FX_BOOL RunDocScript(IXFA_Doc* hDoc, + XFA_SCRIPTTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + FXJSE_HVALUE hThisObject); + + protected: +}; + +#endif // XFA_FXFA_APP_XFA_FFDOCHANDLER_H_ diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp new file mode 100644 index 0000000000..082ca2bbaa --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -0,0 +1,932 @@ +// 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/fxfa/app/xfa_ffdocview.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffbarcode.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffexclgroup.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffimage.h" +#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffpath.h" +#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/xfa_ffsignature.h" +#include "xfa/fxfa/app/xfa_ffsubform.h" +#include "xfa/fxfa/app/xfa_fftext.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/xfa_ffwidgethandler.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/parser/xfa_script.h" + +extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = { + XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, + XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, + XFA_ATTRIBUTEENUM_Enter, XFA_ATTRIBUTEENUM_Exit, + XFA_ATTRIBUTEENUM_Full, XFA_ATTRIBUTEENUM_IndexChange, + XFA_ATTRIBUTEENUM_Initialize, XFA_ATTRIBUTEENUM_MouseDown, + XFA_ATTRIBUTEENUM_MouseEnter, XFA_ATTRIBUTEENUM_MouseExit, + XFA_ATTRIBUTEENUM_MouseUp, XFA_ATTRIBUTEENUM_PostExecute, + XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, + XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, + XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, + XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, + XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, + XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, + XFA_ATTRIBUTEENUM_Unknown, +}; +CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) + : m_bLayoutEvent(FALSE), + m_pListFocusWidget(nullptr), + m_bInLayoutStatus(FALSE), + m_pDoc(pDoc), + m_pWidgetHandler(nullptr), + m_pXFADocLayout(nullptr), + m_pFocusAcc(nullptr), + m_pFocusWidget(nullptr), + 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; +} +void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { + RunBindItems(); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange); +} +int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; + m_pDoc->GetXFADoc()->DoProtoMerge(); + m_pDoc->GetXFADoc()->DoDataMerge(); + m_pXFADocLayout = GetXFALayout(); + int32_t iStatus = m_pXFADocLayout->StartLayout(); + if (iStatus < 0) { + return iStatus; + } + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return iStatus; + } + InitLayout(pRootItem); + InitCalculate(pRootItem); + InitValidate(pRootItem); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE); + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; + return iStatus; +} +int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { + int32_t iStatus = 100; + iStatus = m_pXFADocLayout->DoLayout(pPause); + if (iStatus != 100) { + return iStatus; + } + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; + return iStatus; +} +void CXFA_FFDocView::StopLayout() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return; + } + CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform); + if (!pSubformNode) { + return; + } + CXFA_Node* pPageSetNode = + pSubformNode->GetFirstChildByClass(XFA_ELEMENT_PageSet); + if (!pPageSetNode) { + return; + } + RunCalculateWidgets(); + RunValidate(); + InitLayout(pPageSetNode); + InitCalculate(pPageSetNode); + InitValidate(pPageSetNode); + ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady); + RunCalculateWidgets(); + RunValidate(); + if (RunLayout()) { + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); + } + m_CalculateAccs.RemoveAll(); + if (m_pFocusAcc && !m_pFocusWidget) { + SetFocusWidgetAcc(m_pFocusAcc); + } + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; +} +int32_t CXFA_FFDocView::GetLayoutStatus() { + return m_iStatus; +} +void CXFA_FFDocView::ShowNullTestMsg() { + int32_t iCount = m_arrNullTestMsg.GetSize(); + CXFA_FFApp* pApp = m_pDoc->GetApp(); + IXFA_AppProvider* pAppProvider = pApp->GetAppProvider(); + if (pAppProvider && iCount) { + int32_t iRemain = iCount > 7 ? iCount - 7 : 0; + iCount -= iRemain; + CFX_WideString wsMsg; + for (int32_t i = 0; i < iCount; i++) { + wsMsg += m_arrNullTestMsg[i] + FX_WSTRC(L"\n"); + } + if (iRemain > 0) { + CFX_WideString wsLimit; + pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit); + if (!wsLimit.IsEmpty()) { + CFX_WideString wsTemp; + wsTemp.Format((const FX_WCHAR*)wsLimit, iRemain); + wsMsg += FX_WSTRC(L"\n") + wsTemp; + } + } + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); + pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); + } + m_arrNullTestMsg.RemoveAll(); +} +void CXFA_FFDocView::UpdateDocView() { + if (IsUpdateLocked()) { + return; + } + 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]); + InitCalculate(pNode); + InitValidate(pNode); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE); + } + m_NewAddedNodes.RemoveAll(); + RunSubformIndexChange(); + RunCalculateWidgets(); + RunValidate(); + ShowNullTestMsg(); + if (RunLayout() && m_bLayoutEvent) { + RunEventLayoutReady(); + } + m_bLayoutEvent = FALSE; + m_CalculateAccs.RemoveAll(); + RunInvalidate(); + UnlockUpdate(); +} +int32_t CXFA_FFDocView::CountPageViews() { + if (!m_pXFADocLayout) { + return 0; + } + return m_pXFADocLayout->CountPages(); +} +IXFA_PageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { + if (!m_pXFADocLayout) { + return NULL; + } + return static_cast<CXFA_FFPageView*>(m_pXFADocLayout->GetPage(nIndex)); +} +IXFA_Widget* CXFA_FFDocView::GetWidgetByName(const CFX_WideStringC& wsName) { + return GetWidgetByName(wsName, NULL); +} +CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( + const CFX_WideStringC& wsName) { + return GetWidgetAccByName(wsName, NULL); +} +IXFA_DocLayout* CXFA_FFDocView::GetXFALayout() const { + return m_pDoc->GetXFADoc()->GetDocLayout(); +} +FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { + CXFA_Node* pNode = pWidgetAcc->GetNode(); + XFA_ELEMENT eType = pNode->GetClassID(); + 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); + } + return TRUE; +} +void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { + m_bLayoutEvent = TRUE; + FX_BOOL bChanged = FALSE; + CXFA_Node* pFormNode = NULL; + if (pWidgetAcc) { + bChanged = ResetSingleWidgetAccData(pWidgetAcc); + pFormNode = pWidgetAcc->GetNode(); + } else { + pFormNode = GetRootSubform(); + } + if (!pFormNode) { + return; + } + if (pFormNode->GetClassID() != XFA_ELEMENT_Field && + pFormNode->GetClassID() != XFA_ELEMENT_ExclGroup) { + CXFA_WidgetAccIterator Iterator(this, pFormNode); + while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { + bChanged |= ResetSingleWidgetAccData(pAcc); + if (pAcc->GetNode()->GetClassID() == XFA_ELEMENT_ExclGroup) { + Iterator.SkipTree(); + } + } + } + if (bChanged) { + m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); + } +} +int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, + CXFA_WidgetAcc* pWidgetAcc) { + if (pParam == NULL) { + return XFA_EVENTERROR_Error; + } + if (pParam->m_eType == XFA_EVENT_Validate) { + CFX_WideString wsValidateStr = FX_WSTRC(L"preSubmit"); + CXFA_Node* pConfigItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); + if (pConfigItem) { + CXFA_Node* pValidateNode = NULL; + CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_ELEMENT_Acrobat); + pValidateNode = + pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_ELEMENT_Validate) : NULL; + if (!pValidateNode) { + CXFA_Node* pPresentNode = pConfigItem->GetChild(0, XFA_ELEMENT_Present); + pValidateNode = pPresentNode + ? pPresentNode->GetChild(0, XFA_ELEMENT_Validate) + : NULL; + } + if (pValidateNode) { + wsValidateStr = pValidateNode->GetContent(); + } + } + FX_BOOL bValidate = FALSE; + switch (pParam->m_iValidateActivities) { + case XFA_VALIDATE_preSubmit: + bValidate = wsValidateStr.Find(L"preSubmit") != -1; + break; + case XFA_VALIDATE_prePrint: + bValidate = wsValidateStr.Find(L"prePrint") != -1; + break; + case XFA_VALIDATE_preExecute: + bValidate = wsValidateStr.Find(L"preExecute") != -1; + break; + case XFA_VALIDATE_preSave: + bValidate = wsValidateStr.Find(L"preSave") != -1; + break; + } + if (!bValidate) { + return XFA_EVENTERROR_Sucess; + } + } + CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : NULL; + if (!pNode) { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return XFA_EVENTERROR_Error; + } + pNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform); + } + ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady); + return XFA_EVENTERROR_Sucess; +} +IXFA_WidgetHandler* CXFA_FFDocView::GetWidgetHandler() { + if (!m_pWidgetHandler) { + m_pWidgetHandler = new CXFA_FFWidgetHandler(this); + } + return m_pWidgetHandler; +} +IXFA_WidgetIterator* CXFA_FFDocView::CreateWidgetIterator() { + CXFA_Node* pFormRoot = GetRootSubform(); + if (!pFormRoot) { + return NULL; + } + return new CXFA_FFDocWidgetIterator(this, pFormRoot); +} +IXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( + XFA_WIDGETORDER eOrder) { + CXFA_Node* pFormRoot = GetRootSubform(); + if (!pFormRoot) { + return NULL; + } + return new CXFA_WidgetAccIterator(this, pFormRoot); +} +IXFA_Widget* CXFA_FFDocView::GetFocusWidget() { + return m_pFocusWidget; +} +void CXFA_FFDocView::KillFocus() { + if (m_pFocusWidget && + (m_pFocusWidget->GetStatus() & XFA_WIDGETSTATUS_Focused)) { + (m_pFocusWidget)->OnKillFocus(NULL); + } + m_pFocusAcc = NULL; + m_pFocusWidget = NULL; + m_pOldFocusWidget = NULL; +} +FX_BOOL CXFA_FFDocView::SetFocus(IXFA_Widget* hWidget) { + CXFA_FFWidget* pNewFocus = (CXFA_FFWidget*)hWidget; + if (m_pOldFocusWidget == pNewFocus) { + return FALSE; + } + CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; + m_pOldFocusWidget = pNewFocus; + if (pOldFocus) { + if (m_pFocusWidget != m_pOldFocusWidget && + (pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Focused)) { + m_pFocusWidget = pOldFocus; + pOldFocus->OnKillFocus(pNewFocus); + } else if ((pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + if (!pOldFocus->IsLoaded()) { + pOldFocus->LoadWidget(); + } + pOldFocus->OnSetFocus(m_pFocusWidget); + m_pFocusWidget = pOldFocus; + pOldFocus->OnKillFocus(pNewFocus); + } + } + if (m_pFocusWidget == m_pOldFocusWidget) { + return FALSE; + } + pNewFocus = m_pOldFocusWidget; + if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { + m_pFocusAcc = NULL; + m_pFocusWidget = NULL; + m_pListFocusWidget = NULL; + m_pOldFocusWidget = NULL; + return FALSE; + } + if (pNewFocus && (pNewFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + if (!pNewFocus->IsLoaded()) { + pNewFocus->LoadWidget(); + } + pNewFocus->OnSetFocus(m_pFocusWidget); + } + m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : NULL; + m_pFocusWidget = pNewFocus; + m_pOldFocusWidget = m_pFocusWidget; + return TRUE; +} +CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { + return m_pFocusAcc; +} +void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { + CXFA_FFWidget* pNewFocus = + pWidgetAcc ? pWidgetAcc->GetNextWidget(NULL) : NULL; + if (SetFocus(pNewFocus)) { + m_pFocusAcc = pWidgetAcc; + if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { + m_pDoc->GetDocProvider()->SetFocusWidget(m_pDoc, m_pFocusWidget); + } + } +} +void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { + if (m_pFocusAcc == pWidget->GetDataAcc()) { + m_pFocusAcc = NULL; + m_pFocusWidget = NULL; + m_pOldFocusWidget = NULL; + } +} +static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, + CXFA_WidgetAcc* pWidgetAcc, + CXFA_EventParam* pParam) { + if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { + return XFA_EVENTERROR_NotExist; + } + if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { + return XFA_EVENTERROR_NotExist; + } + switch (pParam->m_eType) { + case XFA_EVENT_Calculate: + return pWidgetAcc->ProcessCalculate(); + case XFA_EVENT_Validate: + if (((CXFA_FFDoc*)pDocView->GetDoc()) + ->GetDocProvider() + ->IsValidationsEnabled(pDocView->GetDoc())) { + return pWidgetAcc->ProcessValidate(0x01); + } + return XFA_EVENTERROR_Disabled; + case XFA_EVENT_InitCalculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + if (!calc) { + return XFA_EVENTERROR_NotExist; + } + if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return XFA_EVENTERROR_Disabled; + } + CXFA_Script script = calc.GetScript(); + return pWidgetAcc->ExecuteScript(script, pParam); + } + default: + break; + } + int32_t iRet = + pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + return iRet; +} +int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + FX_BOOL bIsFormReady, + FX_BOOL bRecursive, + CXFA_Node* pExclude) { + int32_t iRet = XFA_EVENTERROR_NotExist; + if (pFormNode == pExclude) { + return iRet; + } + XFA_ELEMENT elementType = pFormNode->GetClassID(); + if (elementType == XFA_ELEMENT_Field) { + if (eEventType == XFA_EVENT_IndexChange) { + return iRet; + } + CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); + if (pWidgetAcc == NULL) { + return iRet; + } + CXFA_EventParam eParam; + eParam.m_eType = eEventType; + eParam.m_pTarget = pWidgetAcc; + eParam.m_bIsFormReady = bIsFormReady; + return XFA_ProcessEvent(this, pWidgetAcc, &eParam); + } + if (bRecursive) { + for (CXFA_Node* pNode = pFormNode->GetNodeItem( + XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_OBJECTTYPE_ContainerNode)) { + elementType = pNode->GetClassID(); + if (elementType != XFA_ELEMENT_Variables && + elementType != XFA_ELEMENT_Draw) { + iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, + bRecursive, pExclude); + } + } + } + CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); + if (pWidgetAcc == NULL) { + return iRet; + } + CXFA_EventParam eParam; + eParam.m_eType = eEventType; + eParam.m_pTarget = pWidgetAcc; + eParam.m_bIsFormReady = bIsFormReady; + iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam); + return iRet; +} +CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideStringC& 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* CXFA_FFDocView::GetWidgetAccByName( + const CFX_WideStringC& wsName, + CXFA_WidgetAcc* pRefWidgetAcc) { + CFX_WideString wsExpression; + FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; + IXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext(); + if (!pScriptContext) { + return NULL; + } + CXFA_Node* refNode = NULL; + if (pRefWidgetAcc) { + refNode = pRefWidgetAcc->GetNode(); + wsExpression = wsName; + } else { + wsExpression = L"$form." + wsName; + } + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = pScriptContext->ResolveObjects(refNode, wsExpression, + resoveNodeRS, dwStyle); + if (iRet < 1) { + return NULL; + } + if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + CXFA_Node* pNode = resoveNodeRS.nodes[0]->AsNode(); + if (pNode) { + return (CXFA_WidgetAcc*)pNode->GetWidgetData(); + } + } + return NULL; +} +void CXFA_FFDocView::OnPageEvent(IXFA_LayoutPage* pSender, + XFA_PAGEEVENT eEvent, + int32_t iPageIndex) { + 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(); +} +void CXFA_FFDocView::LockUpdate() { + m_iLock++; +} +void CXFA_FFDocView::UnlockUpdate() { + m_iLock--; +} +FX_BOOL CXFA_FFDocView::IsUpdateLocked() { + return m_iLock; +} +void CXFA_FFDocView::ClearInvalidateList() { + FX_POSITION ps = m_mapPageInvalidate.GetStartPosition(); + while (ps) { + void* pPageView = NULL; + CFX_RectF* pRect = NULL; + m_mapPageInvalidate.GetNextAssoc(ps, pPageView, (void*&)pRect); + delete pRect; + } + m_mapPageInvalidate.RemoveAll(); +} +void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, + const CFX_RectF& rtInvalidate) { + AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); +} +void CXFA_FFDocView::AddInvalidateRect(IXFA_PageView* pPageView, + const CFX_RectF& rtInvalidate) { + CFX_RectF* pRect = (CFX_RectF*)m_mapPageInvalidate.GetValueAt(pPageView); + if (!pRect) { + pRect = new CFX_RectF; + pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, + rtInvalidate.height); + m_mapPageInvalidate.SetAt(pPageView, pRect); + } else { + pRect->Union(rtInvalidate); + } +} +void CXFA_FFDocView::RunInvalidate() { + FX_POSITION ps = m_mapPageInvalidate.GetStartPosition(); + while (ps) { + IXFA_PageView* pPageView = NULL; + CFX_RectF* pRect = NULL; + m_mapPageInvalidate.GetNextAssoc(ps, (void*&)pPageView, (void*&)pRect); + m_pDoc->GetDocProvider()->InvalidateRect(pPageView, *pRect); + delete pRect; + } + m_mapPageInvalidate.RemoveAll(); +} +FX_BOOL CXFA_FFDocView::RunLayout() { + LockUpdate(); + m_bInLayoutStatus = TRUE; + if (!m_pXFADocLayout->IncrementLayout() && + m_pXFADocLayout->StartLayout() < 100) { + m_pXFADocLayout->DoLayout(); + UnlockUpdate(); + m_bInLayoutStatus = FALSE; + return TRUE; + } + m_bInLayoutStatus = FALSE; + UnlockUpdate(); + return FALSE; +} +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_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData(); + if (!pWidgetAcc) { + continue; + } + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_IndexChange; + eParam.m_pTarget = pWidgetAcc; + pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); + } + m_IndexChangedSubforms.RemoveAll(); +} +void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode) { + m_NewAddedNodes.Add(pNode); + InitLayout(pNode); +} +void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { + FXSYS_assert(pNode->GetClassID() == XFA_ELEMENT_Subform); + m_IndexChangedSubforms.Add(pNode); +} +void CXFA_FFDocView::RunDocClose() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return; + } + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose); +} +void CXFA_FFDocView::DestroyDocView() { + ClearInvalidateList(); + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; + m_iLock = 0; + m_ValidateAccs.RemoveAll(); + m_bindItems.RemoveAll(); + m_CalculateAccs.RemoveAll(); +} +FX_BOOL CXFA_FFDocView::IsStaticNotify() { + return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; +} +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]; + if (pCurrentAcc != pWidgetAcc) { + m_CalculateAccs.Add(pWidgetAcc); + } +} +void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { + CXFA_CalcData* pGlobalData = + (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]; + 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]; + if (pCurrentAcc != pResultAcc) { + m_CalculateAccs.Add(pResultAcc); + } + } +} +void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { + while (iIndex < m_CalculateAccs.GetSize()) { + CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex]; + AddCalculateNodeNotify(pCurAcc->GetNode()); + int32_t iRefCount = + (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); + iRefCount++; + pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, + (void*)(uintptr_t)iRefCount); + if (iRefCount > 11) { + break; + } + if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Sucess) { + AddValidateWidget(pCurAcc); + } + iIndex++; + RunCalculateRecursive(iIndex); + } +} +int32_t CXFA_FFDocView::RunCalculateWidgets() { + if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { + return XFA_EVENTERROR_Disabled; + } + int32_t iCounts = m_CalculateAccs.GetSize(); + int32_t iIndex = 0; + if (iCounts > 0) { + RunCalculateRecursive(iIndex); + } + for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) { + CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i]; + pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); + } + m_CalculateAccs.RemoveAll(); + return XFA_EVENTERROR_Sucess; +} +void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { + if (m_ValidateAccs.Find(pWidget) < 0) { + m_ValidateAccs.Add(pWidget); + } +} +FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate); + return TRUE; +} +FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { + if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { + return FALSE; + } + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate); + m_ValidateAccs.RemoveAll(); + return TRUE; +} +FX_BOOL CXFA_FFDocView::RunValidate() { + if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { + return FALSE; + } + int32_t iCounts = m_ValidateAccs.GetSize(); + for (int32_t i = 0; i < iCounts; i++) { + CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i]; + if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { + continue; + } + pAcc->ProcessValidate(); + } + m_ValidateAccs.RemoveAll(); + return TRUE; +} +FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return FALSE; + } + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); + RunLayout(); + return TRUE; +} +void CXFA_FFDocView::RunBindItems() { + 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)) { + continue; + } + CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i]) + ->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData(); + if (!pAcc) { + continue; + } + CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i])); + IXFA_ScriptContext* pScriptContext = + pWidgetNode->GetDocument()->GetScriptContext(); + CFX_WideStringC wsRef; + binditems.GetRef(wsRef); + FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_ALL; + XFA_RESOLVENODE_RS rs; + pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); + int32_t iCount = rs.nodes.GetSize(); + pAcc->DeleteItem(-1); + if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) { + continue; + } + CFX_WideStringC wsValueRef, wsLabelRef; + binditems.GetValueRef(wsValueRef); + binditems.GetLabelRef(wsLabelRef); + const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; + const bool bLabelUseContent = + wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$"); + const bool bValueUseContent = + wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$"); + CFX_WideString wsValue, wsLabel; + FX_DWORD uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef), + wsValueRef.GetLength()); + for (int32_t i = 0; i < iCount; i++) { + CXFA_Object* refObj = rs.nodes[i]; + if (!refObj->IsNode()) { + continue; + } + CXFA_Node* refNode = refObj->AsNode(); + if (bValueUseContent) { + wsValue = refNode->GetContent(); + } else { + CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash); + if (nodeValue == NULL) { + wsValue = refNode->GetContent(); + } else { + wsValue = nodeValue->GetContent(); + } + } + if (!bUseValue) { + if (bLabelUseContent) { + wsLabel = refNode->GetContent(); + } else { + CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); + if (nodeLabel) + wsLabel = nodeLabel->GetContent(); + } + } else { + wsLabel = wsValue; + } + pAcc->InsertItem(wsLabel, wsValue); + } + } + m_bindItems.RemoveAll(); +} +void CXFA_FFDocView::SetChangeMark() { + if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { + return; + } + m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); +} +CXFA_Node* CXFA_FFDocView::GetRootSubform() { + CXFA_Node* pFormPacketNode = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pFormPacketNode) { + return NULL; + } + return pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform); +} +CXFA_FFDocWidgetIterator::CXFA_FFDocWidgetIterator(CXFA_FFDocView* pDocView, + CXFA_Node* pTravelRoot) + : m_ContentIterator(pTravelRoot) { + m_pDocView = pDocView; + m_pCurWidget = NULL; +} +CXFA_FFDocWidgetIterator::~CXFA_FFDocWidgetIterator() {} +void CXFA_FFDocWidgetIterator::Reset() { + m_ContentIterator.Reset(); + m_pCurWidget = NULL; +} +IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToFirst() { + return NULL; +} +IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToLast() { + return NULL; +} +IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToNext() { + CXFA_Node* pItem = m_pCurWidget ? m_ContentIterator.MoveToNext() + : m_ContentIterator.GetCurrent(); + while (pItem) { + 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->LoadWidget(); + } + return m_pCurWidget; + } + } + pItem = m_ContentIterator.MoveToNext(); + } + return NULL; +} +IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToPrevious() { + return NULL; +} +IXFA_Widget* CXFA_FFDocWidgetIterator::GetCurrentWidget() { + return NULL; +} +FX_BOOL CXFA_FFDocWidgetIterator::SetCurrentWidget(IXFA_Widget* hWidget) { + return FALSE; +} +IXFA_WidgetAccIterator* XFA_WidgetAccIterator_Create( + CXFA_WidgetAcc* pTravelRoot, + XFA_WIDGETORDER eOrder) { + if (!pTravelRoot) { + return NULL; + } + return new CXFA_WidgetAccIterator(pTravelRoot->GetDocView(), + pTravelRoot->GetNode()); +} +CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, + CXFA_Node* pTravelRoot) + : m_ContentIterator(pTravelRoot) { + m_pDocView = pDocView; + m_pCurWidgetAcc = NULL; +} +CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} +void CXFA_WidgetAccIterator::Reset() { + m_pCurWidgetAcc = NULL; + m_ContentIterator.Reset(); +} +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() { + return NULL; +} +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() { + return NULL; +} +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { + CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() + : m_ContentIterator.GetCurrent(); + while (pItem) { + if ((m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData())) { + return m_pCurWidgetAcc; + } + pItem = m_ContentIterator.MoveToNext(); + } + return NULL; +} +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { + return NULL; +} +CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { + return NULL; +} +FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { + return FALSE; +} +void CXFA_WidgetAccIterator::SkipTree() { + m_ContentIterator.SkipChildrenAndMoveToNext(); + m_pCurWidgetAcc = NULL; +} diff --git a/xfa/fxfa/app/xfa_ffdocview.h b/xfa/fxfa/app/xfa_ffdocview.h new file mode 100644 index 0000000000..284a32fdc3 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdocview.h @@ -0,0 +1,170 @@ +// 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_APP_XFA_FFDOCVIEW_H_ +#define XFA_FXFA_APP_XFA_FFDOCVIEW_H_ + +#include "xfa/fxfa/app/xfa_ffdoc.h" + +class CXFA_FFWidgetHandler; +class CXFA_FFDoc; +class CXFA_FFWidget; +extern const XFA_ATTRIBUTEENUM gs_EventActivity[]; +enum XFA_DOCVIEW_LAYOUTSTATUS { + XFA_DOCVIEW_LAYOUTSTATUS_None, + XFA_DOCVIEW_LAYOUTSTATUS_Start, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitialize, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitCalculate, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitValidate, + XFA_DOCVIEW_LAYOUTSTATUS_FormFormReady, + XFA_DOCVIEW_LAYOUTSTATUS_Doing, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitialize, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitCalculate, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitValidate, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetFormReady, + XFA_DOCVIEW_LAYOUTSTATUS_LayoutReady, + XFA_DOCVIEW_LAYOUTSTATUS_DocReady, + XFA_DOCVIEW_LAYOUTSTATUS_End +}; +class CXFA_FFDocView : public IXFA_DocView { + public: + CXFA_FFDocView(CXFA_FFDoc* pDoc); + ~CXFA_FFDocView(); + + virtual IXFA_Doc* GetDoc() { return m_pDoc; } + virtual int32_t StartLayout(int32_t iStartPage = 0); + virtual int32_t DoLayout(IFX_Pause* pPause = NULL); + virtual void StopLayout(); + virtual int32_t GetLayoutStatus(); + virtual void UpdateDocView(); + virtual int32_t CountPageViews(); + virtual IXFA_PageView* GetPageView(int32_t nIndex); + virtual IXFA_Widget* GetWidgetByName(const CFX_WideStringC& wsName); + virtual CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName); + virtual void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = NULL); + virtual int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, + CXFA_WidgetAcc* pWidgetAcc = NULL); + virtual IXFA_WidgetHandler* GetWidgetHandler(); + virtual IXFA_WidgetIterator* CreateWidgetIterator(); + virtual IXFA_WidgetAccIterator* CreateWidgetAccIterator( + XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder); + virtual IXFA_Widget* GetFocusWidget(); + virtual void KillFocus(); + virtual FX_BOOL SetFocus(IXFA_Widget* hWidget); + CXFA_FFWidget* GetWidgetByName(const CFX_WideStringC& wsName, + CXFA_FFWidget* pRefWidget = NULL); + CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName, + CXFA_WidgetAcc* pRefWidgetAcc = NULL); + IXFA_DocLayout* GetXFALayout() const; + void OnPageEvent(IXFA_LayoutPage* pSender, + XFA_PAGEEVENT eEvent, + int32_t iPageIndex); + void LockUpdate(); + void UnlockUpdate(); + FX_BOOL IsUpdateLocked(); + void ClearInvalidateList(); + void AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF& rtInvalidate); + void AddInvalidateRect(IXFA_PageView* pPageView, + const CFX_RectF& rtInvalidate); + void RunInvalidate(); + void RunDocClose(); + void DestroyDocView(); + + FX_BOOL InitValidate(CXFA_Node* pNode); + FX_BOOL RunValidate(); + + void SetChangeMark(); + + void AddValidateWidget(CXFA_WidgetAcc* pWidget); + void AddCalculateNodeNotify(CXFA_Node* pNodeChange); + void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + int32_t RunCalculateWidgets(); + FX_BOOL IsStaticNotify(); + FX_BOOL RunLayout(); + void RunSubformIndexChange(); + void AddNewFormNode(CXFA_Node* pNode); + void AddIndexChangedSubform(CXFA_Node* pNode); + CXFA_WidgetAcc* GetFocusWidgetAcc(); + void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + void DeleteLayoutItem(CXFA_FFWidget* pWidget); + int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + FX_BOOL bIsFormReady = FALSE, + FX_BOOL bRecursive = TRUE, + CXFA_Node* pExclude = NULL); + FX_BOOL m_bLayoutEvent; + CFX_WideStringArray m_arrNullTestMsg; + CXFA_FFWidget* m_pListFocusWidget; + FX_BOOL m_bInLayoutStatus; + + protected: + FX_BOOL RunEventLayoutReady(); + void RunBindItems(); + FX_BOOL InitCalculate(CXFA_Node* pNode); + void InitLayout(CXFA_Node* pNode); + void RunCalculateRecursive(int32_t& iIndex); + void ShowNullTestMsg(); + FX_BOOL ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); + CXFA_Node* GetRootSubform(); + + CXFA_FFDoc* m_pDoc; + CXFA_FFWidgetHandler* m_pWidgetHandler; + IXFA_DocLayout* m_pXFADocLayout; + CXFA_WidgetAcc* m_pFocusAcc; + 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; + 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; } + + virtual void Reset(); + virtual IXFA_Widget* MoveToFirst(); + virtual IXFA_Widget* MoveToLast(); + virtual IXFA_Widget* MoveToNext(); + virtual IXFA_Widget* MoveToPrevious(); + virtual IXFA_Widget* GetCurrentWidget(); + virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); + + protected: + CXFA_ContainerIterator m_ContentIterator; + CXFA_FFDocView* m_pDocView; + CXFA_FFWidget* m_pCurWidget; +}; +class CXFA_WidgetAccIterator : public IXFA_WidgetAccIterator { + public: + CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot); + virtual ~CXFA_WidgetAccIterator(); + virtual void Release() { delete this; } + virtual void Reset(); + virtual CXFA_WidgetAcc* MoveToFirst(); + virtual CXFA_WidgetAcc* MoveToLast(); + virtual CXFA_WidgetAcc* MoveToNext(); + virtual CXFA_WidgetAcc* MoveToPrevious(); + virtual CXFA_WidgetAcc* GetCurrentWidgetAcc(); + virtual FX_BOOL SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget); + virtual void SkipTree(); + + protected: + CXFA_ContainerIterator m_ContentIterator; + CXFA_FFDocView* m_pDocView; + CXFA_WidgetAcc* m_pCurWidgetAcc; +}; + +#endif // XFA_FXFA_APP_XFA_FFDOCVIEW_H_ diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/xfa_ffdraw.cpp new file mode 100644 index 0000000000..06cfdfec52 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdraw.cpp @@ -0,0 +1,16 @@ +// 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/fxfa/app/xfa_ffdraw.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +CXFA_FFDraw::CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFWidget(pPageView, pDataAcc) {} +CXFA_FFDraw::~CXFA_FFDraw() {} diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/xfa_ffdraw.h new file mode 100644 index 0000000000..a5db5982a5 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffdraw.h @@ -0,0 +1,19 @@ +// 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_APP_XFA_FFDRAW_H_ +#define XFA_FXFA_APP_XFA_FFDRAW_H_ + +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +class CXFA_FFDraw : public CXFA_FFWidget { + public: + CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFDraw(); +}; + +#endif // XFA_FXFA_APP_XFA_FFDRAW_H_ diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp new file mode 100644 index 0000000000..4e24218470 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffexclgroup.cpp @@ -0,0 +1,31 @@ +// 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/fxfa/app/xfa_ffexclgroup.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFWidget(pPageView, pDataAcc) {} +CXFA_FFExclGroup::~CXFA_FFExclGroup() {} +void CXFA_FFExclGroup::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); +} diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/xfa_ffexclgroup.h new file mode 100644 index 0000000000..fd3f4d80db --- /dev/null +++ b/xfa/fxfa/app/xfa_ffexclgroup.h @@ -0,0 +1,24 @@ +// 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_APP_XFA_FFEXCLGROUP_H_ +#define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ + +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +class CXFA_FFExclGroup : public CXFA_FFWidget { + public: + CXFA_FFExclGroup(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFExclGroup(); + + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); +}; + +#endif // XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp new file mode 100644 index 0000000000..39e7ee5d8f --- /dev/null +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -0,0 +1,835 @@ +// 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/fxfa/app/xfa_fffield.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/core/fwl_widgetmgr.h" +#include "xfa/include/fwl/lightwidget/edit.h" +#include "xfa/include/fwl/lightwidget/picturebox.h" + +CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) { + m_rtUI.Set(0, 0, 0, 0); + m_rtCaption.Set(0, 0, 0, 0); +} +CXFA_FFField::~CXFA_FFField() { + CXFA_FFField::UnloadWidget(); +} + +FX_BOOL CXFA_FFField::GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus) { + if (!bDrawFocus) + return CXFA_FFWidget::GetBBox(rtBox, dwStatus); + + XFA_ELEMENT type = (XFA_ELEMENT)m_pDataAcc->GetUIType(); + if (type == XFA_ELEMENT_Button || type == XFA_ELEMENT_CheckButton || + type == XFA_ELEMENT_ImageEdit || type == XFA_ELEMENT_Signature || + type == XFA_ELEMENT_ChoiceList) { + rtBox = m_rtUI; + CFX_Matrix mt; + GetRotateMatrix(mt); + mt.TransformRect(rtBox); + return TRUE; + } + return FALSE; +} + +void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, FALSE); + CFX_RectF rtWidget; + m_pNormalWidget->GetWidgetRect(rtWidget); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), + pGS, &mt); +} +void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + FX_BOOL bEllipse) { + if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return; + } + if ((dwStatus & XFA_WIDGETSTATUS_Highlight) && + m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) { + CXFA_FFDoc* pDoc = GetDoc(); + CFX_Color crHighlight(pDoc->GetDocProvider()->GetHighlightColor(pDoc)); + pGS->SetFillColor(&crHighlight); + CFX_Path path; + path.Create(); + if (bEllipse) { + path.AddEllipse(m_rtUI); + } else { + path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); + } + pGS->FillPath(&path, FXFILL_WINDING, pMatrix); + } +} +void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { + if (m_dwStatus & XFA_WIDGETSTATUS_Focused) { + CFX_Color cr(0xFF000000); + pGS->SetStrokeColor(&cr); + FX_FLOAT DashPattern[2] = {1, 1}; + pGS->SetLineDash(0.0f, DashPattern, 2); + pGS->SetLineWidth(0, FALSE); + CFX_Path path; + path.Create(); + path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); + pGS->StrokePath(&path, pMatrix); + } +} +void CXFA_FFField::SetFWLThemeProvider() { + if (m_pNormalWidget) { + m_pNormalWidget->m_pIface->SetThemeProvider(GetApp()->GetFWLTheme()); + } +} +FX_BOOL CXFA_FFField::IsLoaded() { + return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); +} +FX_BOOL CXFA_FFField::LoadWidget() { + SetFWLThemeProvider(); + m_pDataAcc->LoadCaption(); + PerformLayout(); + return TRUE; +} +void CXFA_FFField::UnloadWidget() { + delete m_pNormalWidget; + m_pNormalWidget = nullptr; +} +void CXFA_FFField::SetEditScrollOffset() { + XFA_ELEMENT eType = m_pDataAcc->GetUIType(); + if (eType == XFA_ELEMENT_TextEdit || eType == XFA_ELEMENT_NumericEdit || + eType == XFA_ELEMENT_PasswordEdit) { + FX_FLOAT fScrollOffset = 0; + CXFA_FFField* pPrev = static_cast<CXFA_FFField*>(GetPrev()); + if (pPrev) { + CFX_RectF rtMargin; + m_pDataAcc->GetUIMargin(rtMargin); + fScrollOffset = -rtMargin.top; + } + while (pPrev) { + fScrollOffset += pPrev->m_rtUI.height; + pPrev = static_cast<CXFA_FFField*>(pPrev->GetPrev()); + } + ((CFWL_Edit*)m_pNormalWidget)->SetScrollOffset(fScrollOffset); + } +} +FX_BOOL CXFA_FFField::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + CapPlacement(); + LayoutCaption(); + SetFWLRect(); + SetEditScrollOffset(); + if (m_pNormalWidget) { + m_pNormalWidget->Update(); + } + return TRUE; +} +void CXFA_FFField::CapPlacement() { + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); + if (mgWidget) { + CXFA_LayoutItem* pItem = this; + FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { + rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); + } else { + if (pItem->GetPrev() == NULL) { + rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); + } else if (pItem->GetNext() == NULL) { + rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); + } else { + rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); + } + } + } + XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + FX_FLOAT fCapReserve = 0; + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { + m_rtCaption.Set(0, 0, 0, 0); + } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { + m_rtCaption.Set(0, 0, 0, 0); + } else { + fCapReserve = caption.GetReserve(); + CXFA_LayoutItem* pItem = this; + if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { + m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, + rtWidget.height); + } else { + pItem = pItem->GetFirst(); + pItem->GetRect(m_rtCaption); + pItem = pItem->GetNext(); + while (pItem) { + CFX_RectF rtRect; + pItem->GetRect(rtRect); + m_rtCaption.height += rtRect.Height(); + pItem = pItem->GetNext(); + } + XFA_RectWidthoutMargin(m_rtCaption, mgWidget); + } + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (fCapReserve <= 0 && pCapTextLayout) { + CFX_SizeF size; + CFX_SizeF minSize; + CFX_SizeF maxSize; + pCapTextLayout->CalcSize(minSize, maxSize, size); + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { + fCapReserve = size.y; + } else { + fCapReserve = size.x; + } + } + } + } + m_rtUI = rtWidget; + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: { + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.width -= fCapReserve; + m_rtUI.left += fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Top: { + m_rtCaption.height = fCapReserve; + CapTopBottomPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.top += fCapReserve; + m_rtUI.height -= fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Right: { + m_rtCaption.left = m_rtCaption.right() - fCapReserve; + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.width -= fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Bottom: { + m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; + m_rtCaption.height = fCapReserve; + CapTopBottomPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.height -= fCapReserve; + } break; + case XFA_ATTRIBUTEENUM_Inline: + break; + default: + break; + } + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + if (borderUI) { + CXFA_Margin margin = borderUI.GetMargin(); + if (margin) { + XFA_RectWidthoutMargin(m_rtUI, margin); + } + } + m_rtUI.Normalize(); +} +void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement) { + CFX_RectF rtUIMargin; + m_pDataAcc->GetUIMargin(rtUIMargin); + m_rtCaption.left += rtUIMargin.left; + if (CXFA_Margin mgCap = caption.GetMargin()) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) { + m_rtCaption.top += m_rtCaption.height; + } + } + FX_FLOAT fWidth = rtUIMargin.left + rtUIMargin.width; + FX_FLOAT fHeight = m_rtCaption.height + rtUIMargin.top + rtUIMargin.height; + if (fWidth > rtWidget.width) { + m_rtUI.width += fWidth - rtWidget.width; + } + if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { + m_rtUI.height = XFA_MINUI_HEIGHT; + m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; + } else if (fHeight > rtWidget.height) { + m_rtUI.height += fHeight - rtWidget.height; + if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { + m_rtCaption.top += fHeight - rtWidget.height; + } + } +} +void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement) { + CFX_RectF rtUIMargin; + m_pDataAcc->GetUIMargin(rtUIMargin); + m_rtCaption.top += rtUIMargin.top; + m_rtCaption.height -= rtUIMargin.top; + if (CXFA_Margin mgCap = caption.GetMargin()) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) { + m_rtCaption.top += m_rtCaption.height; + } + } + FX_FLOAT fWidth = m_rtCaption.width + rtUIMargin.left + rtUIMargin.width; + FX_FLOAT fHeight = rtUIMargin.top + rtUIMargin.height; + if (fWidth > rtWidget.width) { + m_rtUI.width += fWidth - rtWidget.width; + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) { + m_rtCaption.left += fWidth - rtWidget.width; + } + } + if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { + m_rtUI.height = XFA_MINUI_HEIGHT; + m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; + } else if (fHeight > rtWidget.height) { + m_rtUI.height += fHeight - rtWidget.height; + } +} +void CXFA_FFField::UpdateFWL() { + if (m_pNormalWidget) { + m_pNormalWidget->Update(); + } +} +FX_DWORD CXFA_FFField::UpdateUIProperty() { + CXFA_Node* pUiNode = m_pDataAcc->GetUIChild(); + FX_DWORD dwStyle = 0; + if (pUiNode && pUiNode->GetClassID() == XFA_ELEMENT_DefaultUi) { + dwStyle = FWL_STYLEEXT_EDT_ReadOnly; + } + return dwStyle; +} +void CXFA_FFField::SetFWLRect() { + if (!m_pNormalWidget) { + return; + } + CFX_RectF rtUi = m_rtUI; + if (rtUi.width < 1.0) { + FXSYS_assert(rtUi.width < 1.0); + rtUi.width = 1.0; + } + if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + FX_FLOAT fFontSize = m_pDataAcc->GetFontSize(); + if (rtUi.height < fFontSize) { + rtUi.height = fFontSize; + } + } + m_pNormalWidget->SetWidgetRect(rtUi); +} +FX_BOOL CXFA_FFField::OnMouseEnter() { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_MouseEnter; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnMouseExit() { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { + if (!m_pNormalWidget) { + return; + } + CFX_RectF rtWidget; + m_pNormalWidget->GetWidgetRect(rtWidget); + fx -= rtWidget.left; + fy -= rtWidget.top; +} +FX_BOOL CXFA_FFField::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return FALSE; + } + if (!PtInActiveRect(fx, fy)) { + return FALSE; + } + SetButtonDown(TRUE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + if (!IsButtonDown()) { + return FALSE; + } + SetButtonDown(FALSE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnLButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDblClk; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_MouseMove; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouseWheel ms; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_fDeltaX = zDelta; + ms.m_fDeltaY = 0; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnRButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return FALSE; + } + if (!PtInActiveRect(fx, fy)) { + return FALSE; + } + SetButtonDown(TRUE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + if (!IsButtonDown()) { + return FALSE; + } + SetButtonDown(FALSE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnRButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDblClk; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + TranslateFWLMessage(&ms); + return TRUE; +} + +FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { + CXFA_FFWidget::OnSetFocus(pOldWidget); + if (!m_pNormalWidget) { + return FALSE; + } + CFWL_MsgSetFocus ms; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + m_dwStatus |= XFA_WIDGETSTATUS_Focused; + AddInvalidateRect(); + return TRUE; +} +FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { + if (!m_pNormalWidget) { + return CXFA_FFWidget::OnKillFocus(pNewWidget); + } + CFWL_MsgKillFocus ms; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + AddInvalidateRect(); + CXFA_FFWidget::OnKillFocus(pNewWidget); + return TRUE; +} +FX_BOOL CXFA_FFField::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return FALSE; + } + CFWL_MsgKey ms; + ms.m_dwCmd = FWL_MSGKEYCMD_KeyDown; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwKeyCode; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return FALSE; + } + CFWL_MsgKey ms; + ms.m_dwCmd = FWL_MSGKEYCMD_KeyUp; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwKeyCode; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFField::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { + if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return FALSE; + } + if (dwChar == FWL_VKEY_Tab) { + return TRUE; + } + if (!m_pNormalWidget) { + return FALSE; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + CFWL_MsgKey ms; + ms.m_dwCmd = FWL_MSGKEYCMD_Char; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwChar; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_DWORD CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { + if (m_pNormalWidget) { + FX_FLOAT ffx = fx, ffy = fy; + FWLToClient(ffx, ffy); + FX_DWORD dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy); + if (dwWidgetHit != FWL_WGTHITTEST_Unknown) { + return FWL_WGTHITTEST_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; +} +FX_BOOL CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { + return TRUE; +} +FX_BOOL CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFX_RectF rtWidget; + m_pNormalWidget->GetWidgetRect(rtWidget); + if (rtWidget.Contains(fx, fy)) { + return TRUE; + } + return FALSE; +} +void CXFA_FFField::LayoutCaption() { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextLayout) + return; + + FX_FLOAT fHeight = 0; + pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height), + &fHeight); + if (m_rtCaption.height < fHeight) + m_rtCaption.height = fHeight; +} +void CXFA_FFField::RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextLayout) { + return; + } + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { + if (!pCapTextLayout->IsLoaded()) { + pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height)); + } + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + CFX_RectF rtClip = m_rtCaption; + rtClip.Intersect(rtWidget); + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); + } +} +FX_BOOL CXFA_FFField::ProcessCommittedData() { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + if (!IsDataChanged()) { + return FALSE; + } + if (CalculateOverride() != 1) { + return FALSE; + } + if (!CommitData()) { + return FALSE; + } + m_pDocView->SetChangeMark(); + m_pDocView->AddValidateWidget(m_pDataAcc); + return TRUE; +} +int32_t CXFA_FFField::CalculateOverride() { + CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup(); + if (!pAcc) { + return CalculateWidgetAcc(m_pDataAcc); + } + if (CalculateWidgetAcc(pAcc) == 0) { + return 0; + } + CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); + if (!pNode) { + return 1; + } + CXFA_WidgetAcc* pWidgetAcc = NULL; + while (pNode) { + pWidgetAcc = (CXFA_WidgetAcc*)pNode->GetWidgetData(); + if (!pWidgetAcc) { + return 1; + } + if (CalculateWidgetAcc(pWidgetAcc) == 0) { + return 0; + } + pNode = pWidgetAcc->GetExclGroupNextMember(pNode); + } + return 1; +} +int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { + CXFA_Calculate calc = pAcc->GetCalculate(); + if (!calc) { + return 1; + } + XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); + if (calc) { + int32_t iOverride = calc.GetOverride(); + switch (iOverride) { + case XFA_ATTRIBUTEENUM_Error: { + if (version <= XFA_VERSION_204) { + return 1; + } + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (pAppProvider) { + CFX_WideString wsMessage; + CFX_WideString wsWarning; + pAppProvider->LoadString(XFA_IDS_NotModifyField, wsWarning); + wsMessage += wsWarning; + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle); + pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning, + XFA_MB_OK); + } + } + return 0; + case XFA_ATTRIBUTEENUM_Warning: { + if (version <= XFA_VERSION_204) { + CXFA_Script script = calc.GetScript(); + if (!script) { + return 1; + } + CFX_WideString wsExpression; + script.GetExpression(wsExpression); + if (wsExpression.IsEmpty()) { + return 1; + } + } + if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return 1; + } + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (pAppProvider) { + CFX_WideString wsMessage; + calc.GetMessageText(wsMessage); + if (!wsMessage.IsEmpty()) { + wsMessage += L"\r\n"; + } + CFX_WideString wsWarning; + pAppProvider->LoadString(XFA_IDS_ModifyField, wsWarning); + wsMessage += wsWarning; + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle); + if (pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); + return 1; + } + } + return 0; + } + case XFA_ATTRIBUTEENUM_Ignore: + return 0; + case XFA_ATTRIBUTEENUM_Disabled: + pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); + default: + return 1; + } + } + return 1; +} +FX_BOOL CXFA_FFField::CommitData() { + return FALSE; +} +FX_BOOL CXFA_FFField::IsDataChanged() { + return FALSE; +} +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) { + FX_DWORD dwEventID = pEvent->GetClassID(); + switch (dwEventID) { + case FWL_EVTHASH_Mouse: { + CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent; + if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) { + 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) { + 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) { + 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) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_MouseUp; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseUp, &eParam); + } + break; + } + case FWL_EVTHASH_Click: { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Click; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + break; + } + default: {} + } + return FWL_ERR_Succeeded; +} +FWL_ERR CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return FWL_ERR_Succeeded; +} diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h new file mode 100644 index 0000000000..4f816cebab --- /dev/null +++ b/xfa/fxfa/app/xfa_fffield.h @@ -0,0 +1,100 @@ +// 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_APP_XFA_FFFIELD_H_ +#define XFA_FXFA_APP_XFA_FFFIELD_H_ + +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" +#include "xfa/include/fwl/core/fwl_widget.h" +#include "xfa/include/fwl/lightwidget/widget.h" + +#define XFA_MINUI_HEIGHT 4.32f +#define XFA_DEFAULTUI_HEIGHT 2.0f + +class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { + public: + CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFField(); + + virtual FX_BOOL GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus = FALSE); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL IsLoaded(); + virtual FX_BOOL LoadWidget(); + virtual void UnloadWidget(); + virtual FX_BOOL PerformLayout(); + virtual void UpdateFWL(); + FX_DWORD UpdateUIProperty(); + virtual FX_BOOL OnMouseEnter(); + virtual FX_BOOL OnMouseExit(); + virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + + virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); + virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); + virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); + virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); + + protected: + virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + virtual void SetFWLRect(); + void SetFWLThemeProvider(); + CFWL_Widget* GetNormalWidget() { return m_pNormalWidget; } + void FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy); + void LayoutCaption(); + void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = NULL); + + int32_t CalculateOverride(); + int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc); + FX_BOOL ProcessCommittedData(); + virtual FX_BOOL CommitData(); + virtual FX_BOOL IsDataChanged(); + void DrawHighlight(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + FX_BOOL bEllipse = FALSE); + void DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix); + void TranslateFWLMessage(CFWL_Message* pMessage); + void CapPlacement(); + void CapTopBottomPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement); + void CapLeftRightPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement); + 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); + + protected: + CFWL_Widget* m_pNormalWidget; + CFX_RectF m_rtUI; + CFX_RectF m_rtCaption; +}; + +#endif // XFA_FXFA_APP_XFA_FFFIELD_H_ diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp new file mode 100644 index 0000000000..c17273d5cf --- /dev/null +++ b/xfa/fxfa/app/xfa_ffimage.cpp @@ -0,0 +1,67 @@ +// 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/fxfa/app/xfa_ffimage.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +CXFA_FFImage::CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pPageView, pDataAcc) {} +CXFA_FFImage::~CXFA_FFImage() { + CXFA_FFImage::UnloadWidget(); +} +FX_BOOL CXFA_FFImage::IsLoaded() { + return GetDataAcc()->GetImageImage() != NULL; +} +FX_BOOL CXFA_FFImage::LoadWidget() { + if (GetDataAcc()->GetImageImage()) { + return TRUE; + } + GetDataAcc()->LoadImageImage(); + return CXFA_FFDraw::LoadWidget(); +} +void CXFA_FFImage::UnloadWidget() { + GetDataAcc()->SetImageImage(NULL); +} +void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + if (CFX_DIBitmap* pDIBitmap = GetDataAcc()->GetImageImage()) { + CFX_RectF rtImage; + GetRectWithoutRotate(rtImage); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + XFA_RectWidthoutMargin(rtImage, mgWidget); + } + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + CXFA_Value value = m_pDataAcc->GetFormValue(); + CXFA_Image imageObj = value.GetImage(); + int32_t iAspect = imageObj.GetAspect(); + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); + XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, + iImageYDpi, iHorzAlign, iVertAlign); + } +} diff --git a/xfa/fxfa/app/xfa_ffimage.h b/xfa/fxfa/app/xfa_ffimage.h new file mode 100644 index 0000000000..71bb495be1 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffimage.h @@ -0,0 +1,25 @@ +// 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_APP_XFA_FFIMAGE_H_ +#define XFA_FXFA_APP_XFA_FFIMAGE_H_ + +#include "xfa/fxfa/app/xfa_ffdraw.h" + +class CXFA_FFImage : public CXFA_FFDraw { + public: + CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFImage(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL IsLoaded(); + virtual FX_BOOL LoadWidget(); + virtual void UnloadWidget(); +}; + +#endif // XFA_FXFA_APP_XFA_FFIMAGE_H_ diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp new file mode 100644 index 0000000000..4f9f6c670c --- /dev/null +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -0,0 +1,183 @@ +// 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/fxfa/app/xfa_ffimageedit.h" + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fwl/core/fwl_app.h" +#include "xfa/include/fwl/lightwidget/picturebox.h" + +CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} +CXFA_FFImageEdit::~CXFA_FFImageEdit() { + CXFA_FFImageEdit::UnloadWidget(); +} +FX_BOOL CXFA_FFImageEdit::LoadWidget() { + CFWL_PictureBox* pPictureBox = new CFWL_PictureBox; + if (pPictureBox) { + pPictureBox->Initialize(); + } + m_pNormalWidget = (CFWL_Widget*)pPictureBox; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = pPictureBox->SetDelegate(this); + CXFA_FFField::LoadWidget(); + if (m_pDataAcc->GetImageEditImage()) { + return TRUE; + } + UpdateFWLData(); + return TRUE; +} +void CXFA_FFImageEdit::UnloadWidget() { + m_pDataAcc->SetImageEditImage(NULL); + CXFA_FFField::UnloadWidget(); +} +void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + if (CFX_DIBitmap* pDIBitmap = m_pDataAcc->GetImageEditImage()) { + CFX_RectF rtImage; + m_pNormalWidget->GetWidgetRect(rtImage); + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; + if (CXFA_Value value = m_pDataAcc->GetFormValue()) { + if (CXFA_Image imageObj = value.GetImage()) { + iAspect = imageObj.GetAspect(); + } + } + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); + XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, + iImageYDpi, iHorzAlign, iVertAlign); + } +} +FX_BOOL CXFA_FFImageEdit::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + if (!PtInActiveRect(fx, fy)) { + return FALSE; + } + SetButtonDown(TRUE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + 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, wsFilter, 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, CFX_WideStringC(), wsImage); + m_pDataAcc->LoadImageEditImage(); + AddInvalidateRect(); + m_pDocView->SetChangeMark(); + return TRUE; +} +void CXFA_FFImageEdit::SetFWLRect() { + if (!m_pNormalWidget) { + return; + } + CFX_RectF rtUIMargin; + m_pDataAcc->GetUIMargin(rtUIMargin); + CFX_RectF rtImage(m_rtUI); + rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, + rtUIMargin.height); + m_pNormalWidget->SetWidgetRect(rtImage); +} +FX_BOOL CXFA_FFImageEdit::CommitData() { + return TRUE; +} +FX_BOOL CXFA_FFImageEdit::UpdateFWLData() { + m_pDataAcc->SetImageEditImage(NULL); + m_pDataAcc->LoadImageEditImage(); + return TRUE; +} +int32_t CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + return m_pOldDelegate->OnProcessEvent(pEvent); +} +FWL_ERR CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/xfa_ffimageedit.h b/xfa/fxfa/app/xfa_ffimageedit.h new file mode 100644 index 0000000000..7ecd18a0c1 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffimageedit.h @@ -0,0 +1,36 @@ +// 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_APP_XFA_FFIMAGEEDIT_H_ +#define XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ + +#include "xfa/fxfa/app/xfa_fffield.h" + +class CXFA_FFImageEdit : public CXFA_FFField { + public: + CXFA_FFImageEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFImageEdit(); + + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL LoadWidget(); + virtual void UnloadWidget(); + virtual FX_BOOL OnLButtonDown(FX_DWORD 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); + + protected: + virtual void SetFWLRect(); + virtual FX_BOOL UpdateFWLData(); + virtual FX_BOOL CommitData(); + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp new file mode 100644 index 0000000000..845f7b82b7 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -0,0 +1,648 @@ +// 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/fxfa/app/xfa_ffnotify.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffbarcode.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffexclgroup.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffimage.h" +#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffpath.h" +#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/xfa_ffsignature.h" +#include "xfa/fxfa/app/xfa_ffsubform.h" +#include "xfa/fxfa/app/xfa_fftext.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/xfa_ffwidgethandler.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_textlayout.h" + +static void XFA_FFDeleteWidgetAcc(void* pData) { + delete static_cast<CXFA_WidgetAcc*>(pData); +} +static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { + XFA_FFDeleteWidgetAcc, NULL}; +CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} +CXFA_FFNotify::~CXFA_FFNotify() {} +void CXFA_FFNotify::OnPageEvent(IXFA_LayoutPage* pSender, + XFA_PAGEEVENT eEvent, + void* pParam) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); + if (!pDocView) { + return; + } + pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam); +} +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::OnWidgetDataEvent(CXFA_WidgetData* pSender, + FX_DWORD dwEvent, + void* pParam, + void* pAdditional, + void* pAdditional2) { + 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); + } + } break; + } +} +CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { + IXFA_DocLayout* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); + XFA_ELEMENT eType = pNode->GetClassID(); + if (eType == XFA_ELEMENT_PageArea) { + return new CXFA_FFPageView(pDocView, pNode); + } + if (eType == XFA_ELEMENT_ContentArea) { + return new CXFA_ContainerLayoutItem(pNode); + } + CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); + if (!pAcc) { + return new CXFA_ContentLayoutItem(pNode); + } + CXFA_FFPageView* pPageView = NULL; + CXFA_FFWidget* pWidget = NULL; + switch (pAcc->GetUIType()) { + case XFA_ELEMENT_Barcode: + pWidget = new CXFA_FFBarcode(pPageView, pAcc); + break; + case XFA_ELEMENT_Button: + pWidget = new CXFA_FFPushButton(pPageView, pAcc); + break; + case XFA_ELEMENT_CheckButton: + pWidget = new CXFA_FFCheckButton(pPageView, pAcc); + break; + case XFA_ELEMENT_ChoiceList: { + if (pAcc->IsListBox()) { + pWidget = new CXFA_FFListBox(pPageView, pAcc); + } else { + pWidget = new CXFA_FFComboBox(pPageView, pAcc); + } + } break; + case XFA_ELEMENT_DateTimeEdit: + pWidget = new CXFA_FFDateTimeEdit(pPageView, pAcc); + break; + case XFA_ELEMENT_ImageEdit: + pWidget = new CXFA_FFImageEdit(pPageView, pAcc); + break; + case XFA_ELEMENT_NumericEdit: + pWidget = new CXFA_FFNumericEdit(pPageView, pAcc); + break; + case XFA_ELEMENT_PasswordEdit: + pWidget = new CXFA_FFPasswordEdit(pPageView, pAcc); + break; + case XFA_ELEMENT_Signature: + pWidget = new CXFA_FFSignature(pPageView, pAcc); + break; + case XFA_ELEMENT_TextEdit: + pWidget = new CXFA_FFTextEdit(pPageView, pAcc); + break; + case XFA_ELEMENT_Arc: + pWidget = new CXFA_FFArc(pPageView, pAcc); + break; + case XFA_ELEMENT_Line: + pWidget = new CXFA_FFLine(pPageView, pAcc); + break; + case XFA_ELEMENT_Rectangle: + pWidget = new CXFA_FFRectangle(pPageView, pAcc); + break; + case XFA_ELEMENT_Text: + pWidget = new CXFA_FFText(pPageView, pAcc); + break; + case XFA_ELEMENT_Image: + pWidget = new CXFA_FFImage(pPageView, pAcc); + break; + case XFA_ELEMENT_Draw: + pWidget = new CXFA_FFDraw(pPageView, pAcc); + break; + case XFA_ELEMENT_Subform: + pWidget = new CXFA_FFSubForm(pPageView, pAcc); + break; + case XFA_ELEMENT_ExclGroup: + pWidget = new CXFA_FFExclGroup(pPageView, pAcc); + break; + case XFA_ELEMENT_DefaultUi: + default: + pWidget = NULL; + break; + } + if (!pWidget) { + return NULL; + } + pWidget->SetDocView(pDocView); + return pWidget; +} +void CXFA_FFNotify::OnLayoutEvent(IXFA_DocLayout* 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) { + CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); + if (!pAcc) { + return; + } + pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); +} +FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, + int32_t iBlockIndex, + FX_FLOAT& fCalcHeightPos) { + CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); + if (!pAcc) { + return FALSE; + } + return (XFA_LAYOUTRESULT)pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); +} +FX_BOOL CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { + FX_BOOL bRet = FALSE; + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return bRet; + } + CXFA_WidgetAcc* pWidgetAcc = + static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData()); + if (!pWidgetAcc) { + return bRet; + } + CXFA_EventParam EventParam; + EventParam.m_eType = XFA_EVENT_Unknown; + FXJSE_HVALUE pRetValue = NULL; + int32_t iRet = + pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); + if (iRet == XFA_EVENTERROR_Sucess && pRetValue) { + bRet = FXJSE_Value_ToBoolean(pRetValue); + FXJSE_Value_Release(pRetValue); + } + return bRet; +} +int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + FX_BOOL bIsFormReady, + FX_BOOL bRecursive, + CXFA_WidgetAcc* pExclude) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return XFA_EVENTERROR_NotExist; + } + return pDocView->ExecEventActivityByDeepFirst( + pFormNode, eEventType, bIsFormReady, bRecursive, + pExclude ? pExclude->GetNode() : NULL); +} +void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + CXFA_WidgetAcc* pWidgetAcc = + static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); + if (!pWidgetAcc) { + return; + } + pDocView->AddCalculateWidgetAcc(pWidgetAcc); + pDocView->AddValidateWidget(pWidgetAcc); +} +IXFA_Doc* CXFA_FFNotify::GetHDOC() { + return m_pDoc; +} +IXFA_DocProvider* CXFA_FFNotify::GetDocProvider() { + return m_pDoc->GetDocProvider(); +} +IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { + return m_pDoc->GetApp()->GetAppProvider(); +} +IXFA_WidgetHandler* CXFA_FFNotify::GetWidgetHandler() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + return pDocView ? pDocView->GetWidgetHandler() : NULL; +} +IXFA_Widget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { + return XFA_GetWidgetFromLayoutItem(pLayoutItem); +} +void CXFA_FFNotify::OpenDropDownList(IXFA_Widget* hWidget) { + CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget); + if (pWidget->GetDataAcc()->GetUIType() != XFA_ELEMENT_ChoiceList) { + return; + } + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + pDocView->LockUpdate(); + static_cast<CXFA_FFComboBox*>(pWidget)->OpenDropDownList(); + pDocView->UnlockUpdate(); + pDocView->UpdateDocView(); +} +CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { + CFX_Unitime dataTime; + dataTime.Now(); + CFX_WideString wsDateTime; + wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), + dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), + dataTime.GetMinute(), dataTime.GetSecond()); + return wsDateTime; +} +void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + pDocView->ResetWidgetData(static_cast<CXFA_WidgetAcc*>(pWidgetData)); +} +int32_t CXFA_FFNotify::GetLayoutStatus() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + return pDocView ? pDocView->GetLayoutStatus() : 0; +} +void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + pDocView->AddNewFormNode(pNode); +} +void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + pDocView->AddIndexChangedSubform(pSubformNode); +} +CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return NULL; + } + CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); + return pAcc ? pAcc->GetNode() : NULL; +} +void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + CXFA_WidgetAcc* pAcc = + 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) { + return; + } + XFA_ELEMENT iType = pNode->GetClassID(); + if (XFA_IsCreateWidget(iType)) { + CXFA_WidgetAcc* pAcc = + new CXFA_WidgetAcc(pDocView, static_cast<CXFA_Node*>(pNode)); + pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); + return; + } + switch (iType) { + case XFA_ELEMENT_BindItems: + pDocView->m_bindItems.Add(pNode); + break; + case XFA_ELEMENT_Validate: { + pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE); + } break; + default: + break; + } +} +void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, + void* pParam, + void* pParam2) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) { + return; + } + FX_DWORD 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(); + } + } + } + } +} +void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, + void* pParam, + void* pParam2, + void* pParam3, + void* pParam4) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + FX_DWORD 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) { + 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; + } + } + 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); + } + } +} +void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, + void* pParam, + void* pParam2) { + if (!pSender->IsFormContainer()) { + return; + } + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) { + return; + } + 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_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::OnLayoutItemAdd(CXFA_FFDocView* pDocView, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2) { + CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); + int32_t iPageIdx = (int32_t)(uintptr_t)pParam; + IXFA_PageView* pNewPageView = pDocView->GetPageView(iPageIdx); + FX_DWORD dwStatus = (FX_DWORD)(uintptr_t)pParam2; + FX_DWORD dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | + XFA_WIDGETSTATUS_Printable; + pWidget->ModifyStatus(dwStatus, dwFilter); + IXFA_PageView* pPrePageView = pWidget->GetPageView(); + if (pPrePageView != pNewPageView || + (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); + } + if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || + !(dwStatus & XFA_WIDGETSTATUS_Visible)) { + return; + } + if (pWidget->IsLoaded()) { + CFX_RectF rtOld; + pWidget->GetWidgetRect(rtOld); + if (rtOld != pWidget->ReCacheWidgetRect()) + pWidget->PerformLayout(); + } else { + pWidget->LoadWidget(); + } + pWidget->AddInvalidateRect(nullptr); +} +void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, + IXFA_DocLayout* 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, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2) {} +void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2) { + CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); + if (!pWidget) { + return; + } + FX_DWORD dwStatus = (FX_DWORD)(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(); + } + } + } + FX_DWORD dwOldStatus = pWidget->GetStatus(); + FX_DWORD dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | + XFA_WIDGETSTATUS_Printable; + if ((dwOldStatus & dwFilter) == dwStatus) { + return; + } + pWidget->ModifyStatus(dwStatus, dwFilter); +} diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h new file mode 100644 index 0000000000..e61c07924e --- /dev/null +++ b/xfa/fxfa/app/xfa_ffnotify.h @@ -0,0 +1,99 @@ +// 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_APP_XFA_FFNOTIFY_H_ +#define XFA_FXFA_APP_XFA_FFNOTIFY_H_ + +#include "xfa/fxfa/parser/xfa_document.h" + +class CXFA_FFNotify : public IXFA_Notify { + public: + CXFA_FFNotify(CXFA_FFDoc* pDoc); + ~CXFA_FFNotify(); + + virtual void OnPageEvent(IXFA_LayoutPage* pSender, + XFA_PAGEEVENT eEvent, + void* pParam = NULL); + + virtual void OnNodeEvent(CXFA_Node* pSender, + XFA_NODEEVENT eEvent, + void* pParam = NULL, + void* pParam2 = NULL, + void* pParam3 = NULL, + void* pParam4 = NULL); + virtual void OnWidgetDataEvent(CXFA_WidgetData* pSender, + FX_DWORD dwEvent, + void* pParam = NULL, + void* pAdditional = NULL, + void* pAdditional2 = NULL); + virtual CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode); + virtual void OnLayoutEvent(IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + XFA_LAYOUTEVENT eEvent, + void* pParam = NULL, + void* pParam2 = NULL); + + virtual void StartFieldDrawLayout(CXFA_Node* pItem, + FX_FLOAT& fCalcWidth, + FX_FLOAT& fCalcHeight); + virtual FX_BOOL FindSplitPos(CXFA_Node* pItem, + int32_t iBlockIndex, + FX_FLOAT& fCalcHeightPos); + virtual FX_BOOL RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem); + virtual int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + FX_BOOL bIsFormReady = FALSE, + FX_BOOL bRecursive = TRUE, + CXFA_WidgetAcc* pExclude = NULL); + virtual void AddCalcValidate(CXFA_Node* pNode); + virtual IXFA_Doc* GetHDOC(); + virtual IXFA_DocProvider* GetDocProvider(); + virtual IXFA_AppProvider* GetAppProvider(); + virtual IXFA_WidgetHandler* GetWidgetHandler(); + virtual IXFA_Widget* GetHWidget(CXFA_LayoutItem* pLayoutItem); + virtual void OpenDropDownList(IXFA_Widget* hWidget); + virtual CFX_WideString GetCurrentDateTime(); + virtual void ResetData(CXFA_WidgetData* pWidgetData = NULL); + virtual int32_t GetLayoutStatus(); + virtual void RunNodeInitialize(CXFA_Node* pNode); + virtual void RunSubformIndexChange(CXFA_Node* pSubformNode); + virtual CXFA_Node* GetFocusWidgetNode(); + virtual 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, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2); + void OnLayoutItemRemoving(CXFA_FFDocView* pDocView, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2); + void OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2); + void OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, + IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + void* pParam, + void* pParam2); + CXFA_FFDoc* m_pDoc; +}; + +#endif // XFA_FXFA_APP_XFA_FFNOTIFY_H_ diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp new file mode 100644 index 0000000000..1bc168187c --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -0,0 +1,424 @@ +// 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/fxfa/app/xfa_ffpageview.h" + +#include "xfa/fde/fde_render.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" + +CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) + : CXFA_ContainerLayoutItem(pPageArea), + m_pDocView(pDocView), + m_bLoaded(FALSE) {} +CXFA_FFPageView::~CXFA_FFPageView() {} +IXFA_DocView* CXFA_FFPageView::GetDocView() { + return m_pDocView; +} +int32_t CXFA_FFPageView::GetPageViewIndex() { + return GetPageIndex(); +} +void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) { + CFX_SizeF sz; + GetPageSize(sz); + rtPage.Set(0, 0, sz); +} +void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt, + const CFX_Rect& rtDisp, + int32_t iRotate) { + 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; +} +IXFA_Widget* 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); + FX_DWORD dwFlag = pWidget->OnHitTest(fWidgetx, fWidgety); + if ((FWL_WGTHITTEST_Client == dwFlag || + FWL_WGTHITTEST_HyperLink == dwFlag)) { + break; + } + } + pIterator->Release(); + return pWidget; +} +IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( + FX_DWORD dwTraverseWay, + FX_DWORD dwWidgetFilter) { + switch (dwTraverseWay) { + case XFA_TRAVERSEWAY_Tranvalse: + return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter); + case XFA_TRAVERSEWAY_Form: + return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); + } + return NULL; +} +static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget, + FX_DWORD dwFilter, + FX_BOOL bTraversal, + FX_BOOL bIgnorerelevant) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + FX_DWORD dwType = dwFilter & XFA_WIDGETFILTER_AllType; + if ((dwType == XFA_WIDGETFILTER_Field) && + (pWidgetAcc->GetClassID() != XFA_ELEMENT_Field)) { + return FALSE; + } + FX_DWORD 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; +} +CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, + FX_DWORD dwFilter) { + m_pPageView = pPageView; + m_dwFilter = dwFilter; + m_sIterator.Init(pPageView); + m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) + ->GetXFADoc() + ->GetCurVersionMode() < XFA_VERSION_205; +} +CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} +void CXFA_FFPageWidgetIterator::Reset() { + m_sIterator.Reset(); +} +IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToFirst() { + m_sIterator.Reset(); + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToNext()) { + if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return NULL; +} +IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToLast() { + m_sIterator.SetCurrent(NULL); + return MoveToPrevious(); +} +IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToNext() { + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToNext()) { + if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return NULL; +} +IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToPrevious() { + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToPrev()) { + if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return NULL; +} +IXFA_Widget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { + CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); + return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; +} +FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(IXFA_Widget* hWidget) { + CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget); + return pWidget && m_sIterator.SetCurrent(pWidget); +} +IXFA_Widget* CXFA_FFPageWidgetIterator::GetWidget( + CXFA_LayoutItem* pLayoutItem) { + if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { + if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { + return NULL; + } + if (!pWidget->IsLoaded() && + (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { + pWidget->LoadWidget(); + } + return pWidget; + } + return NULL; +} +CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( + CXFA_FFPageView* pPageView, + FX_DWORD dwFilter) + : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { + m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) + ->GetXFADoc() + ->GetCurVersionMode() < XFA_VERSION_205; + Reset(); +} +CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} +void CXFA_FFTabOrderPageWidgetIterator::Release() { + delete this; +} +void CXFA_FFTabOrderPageWidgetIterator::Reset() { + CreateTabOrderWidgetArray(); + m_iCurWidget = -1; +} +IXFA_Widget* 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)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + } + return NULL; +} +IXFA_Widget* 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)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + } + return NULL; +} +IXFA_Widget* 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)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + m_iCurWidget = -1; + return NULL; +} +IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { + for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { + if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + m_iCurWidget = -1; + return NULL; +} +IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { + if (m_iCurWidget >= 0) { + return m_TabOrderWidgetArray[m_iCurWidget]; + } + return NULL; +} +FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( + IXFA_Widget* hWidget) { + int32_t iWidgetIndex = + m_TabOrderWidgetArray.Find(static_cast<CXFA_FFWidget*>(hWidget)); + if (iWidgetIndex >= 0) { + m_iCurWidget = iWidgetIndex; + return TRUE; + } + return FALSE; +} +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( + CXFA_FFWidget* pWidget) { + CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); + CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_ELEMENT_Traversal); + if (pTraversal) { + CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_ELEMENT_Traverse); + if (pTraverse) { + CFX_WideString wsTraverseWidgetName; + if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { + return FindWidgetByName(wsTraverseWidgetName, pWidget); + } + } + } + return NULL; +} +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( + const CFX_WideStringC& wsWidgetName, + CXFA_FFWidget* pRefWidget) { + return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); +} +void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { + m_TabOrderWidgetArray.RemoveAll(); + CXFA_WidgetArray SpaceOrderWidgetArray; + CreateSpaceOrderWidgetArray(SpaceOrderWidgetArray); + int32_t nWidgetCount = SpaceOrderWidgetArray.GetSize(); + if (nWidgetCount < 1) { + return; + } + CXFA_FFWidget* hWidget = SpaceOrderWidgetArray[0]; + for (; m_TabOrderWidgetArray.GetSize() < nWidgetCount;) { + if (m_TabOrderWidgetArray.Find(hWidget) < 0) { + m_TabOrderWidgetArray.Add(hWidget); + CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); + if (pWidgetAcc->GetUIType() == XFA_ELEMENT_ExclGroup) { + int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget) + 1; + while (TRUE) { + CXFA_FFWidget* pRadio = + SpaceOrderWidgetArray[(iWidgetIndex) % nWidgetCount]; + if (pRadio->GetDataAcc()->GetExclGroup() != pWidgetAcc) { + break; + } + if (m_TabOrderWidgetArray.Find(hWidget) < 0) { + m_TabOrderWidgetArray.Add(pRadio); + } + iWidgetIndex++; + } + } + if (CXFA_FFWidget* hTraverseWidget = GetTraverseWidget(hWidget)) { + hWidget = hTraverseWidget; + continue; + } + } + int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget); + hWidget = SpaceOrderWidgetArray[(iWidgetIndex + 1) % nWidgetCount]; + } +} +static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, + const void* phWidget2) { + CXFA_FFWidget* pWidget1 = (*(CXFA_TabParam**)phWidget1)->m_pWidget; + CXFA_FFWidget* pWidget2 = (*(CXFA_TabParam**)phWidget2)->m_pWidget; + CFX_RectF rt1, rt2; + pWidget1->GetWidgetRect(rt1); + pWidget2->GetWidgetRect(rt2); + FX_FLOAT x1 = rt1.left, y1 = rt1.top, x2 = rt2.left, y2 = rt2.top; + if (y1 < y2 || (y1 - y2 < XFA_FLOAT_PERCISION && x1 < x2)) { + return -1; + } + return 1; +} +void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( + CXFA_LayoutItemIterator* sIterator, + CXFA_LayoutItem* pContainerItem, + CXFA_TabParam* pContainer, + FX_BOOL& bCurrentItem, + FX_BOOL& bContentArea, + FX_BOOL bMarsterPage) { + CFX_PtrArray tabParams; + CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext(); + while (pSearchItem) { + if (!pSearchItem->IsContentLayoutItem()) { + bContentArea = TRUE; + pSearchItem = sIterator->MoveToNext(); + continue; + } + if (bMarsterPage && bContentArea) { + break; + } + if (bMarsterPage || bContentArea) { + CXFA_FFWidget* hWidget = GetWidget(pSearchItem); + if (!hWidget) { + pSearchItem = sIterator->MoveToNext(); + continue; + } + if (pContainerItem && (pSearchItem->GetParent() != pContainerItem)) { + bCurrentItem = TRUE; + break; + } + CXFA_TabParam* pParam = new CXFA_TabParam; + pParam->m_pWidget = hWidget; + tabParams.Add(pParam); + if (XFA_IsLayoutElement(pSearchItem->GetFormNode()->GetClassID(), TRUE)) { + OrderContainer(sIterator, pSearchItem, pParam, bCurrentItem, + bContentArea, bMarsterPage); + } + } + if (bCurrentItem) { + pSearchItem = sIterator->GetCurrent(); + bCurrentItem = FALSE; + } else { + pSearchItem = sIterator->MoveToNext(); + } + } + int32_t iChildren = tabParams.GetSize(); + if (iChildren > 1) { + FXSYS_qsort(tabParams.GetData(), iChildren, sizeof(void*), + XFA_TabOrderWidgetComparator); + } + for (int32_t iStart = 0; iStart < iChildren; iStart++) { + CXFA_TabParam* pParam = (CXFA_TabParam*)tabParams[iStart]; + pContainer->m_Children.Add(pParam->m_pWidget); + if (pParam->m_Children.GetSize() > 0) { + pContainer->m_Children.Append(pParam->m_Children); + } + delete pParam; + } + tabParams.RemoveAll(); +} +void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( + CXFA_WidgetArray& WidgetArray) { + CXFA_LayoutItemIterator sIterator; + sIterator.Init(m_pPageView); + CXFA_TabParam* pParam = new CXFA_TabParam; + FX_BOOL bCurrentItem = FALSE; + FX_BOOL bContentArea = FALSE; + OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea); + if (pParam->m_Children.GetSize() > 0) { + WidgetArray.Append(pParam->m_Children); + } + sIterator.Reset(); + bCurrentItem = FALSE; + bContentArea = FALSE; + pParam->m_Children.RemoveAll(); + OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea, TRUE); + if (pParam->m_Children.GetSize() > 0) { + WidgetArray.Append(pParam->m_Children); + } + delete pParam; +} +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( + CXFA_LayoutItem* pLayoutItem) { + if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { + if (!pWidget->IsLoaded() && + (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + pWidget->LoadWidget(); + } + return pWidget; + } + return NULL; +} diff --git a/xfa/fxfa/app/xfa_ffpageview.h b/xfa/fxfa/app/xfa_ffpageview.h new file mode 100644 index 0000000000..b68e828123 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpageview.h @@ -0,0 +1,111 @@ +// 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_APP_XFA_FFPAGEVIEW_H_ +#define XFA_FXFA_APP_XFA_FFPAGEVIEW_H_ + +#include "xfa/fxfa/parser/xfa_doclayout.h" + +class CXFA_FFWidget; +class CXFA_FFDocView; +class CXFA_FFPageView : public CXFA_ContainerLayoutItem, public IXFA_PageView { + public: + CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); + ~CXFA_FFPageView() override; + + // IFXA_PageView: + IXFA_DocView* GetDocView() override; + int32_t GetPageViewIndex() override; + void GetPageViewRect(CFX_RectF& rtPage) override; + void GetDisplayMatrix(CFX_Matrix& mt, + const CFX_Rect& rtDisp, + int32_t iRotate) override; + int32_t LoadPageView(IFX_Pause* pPause = NULL) override; + void UnloadPageView() override; + IXFA_Widget* GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) override; + IXFA_WidgetIterator* CreateWidgetIterator( + FX_DWORD dwTraverseWay = XFA_TRAVERSEWAY_Form, + FX_DWORD dwWidgetFilter = XFA_WIDGETFILTER_Visible | + XFA_WIDGETFILTER_Viewable | + XFA_WIDGETFILTER_AllType) override; + + FX_BOOL IsPageViewLoaded(); + + protected: + CXFA_FFDocView* m_pDocView; + FX_BOOL m_bLoaded; +}; +typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem, + CXFA_TraverseStrategy_LayoutItem> + CXFA_LayoutItemIterator; +class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { + public: + CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, FX_DWORD dwFilter); + virtual ~CXFA_FFPageWidgetIterator(); + virtual void Release() { delete this; } + + virtual void Reset(); + virtual IXFA_Widget* MoveToFirst(); + virtual IXFA_Widget* MoveToLast(); + virtual IXFA_Widget* MoveToNext(); + virtual IXFA_Widget* MoveToPrevious(); + virtual IXFA_Widget* GetCurrentWidget(); + virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); + + protected: + IXFA_Widget* GetWidget(CXFA_LayoutItem* pLayoutItem); + CXFA_FFPageView* m_pPageView; + IXFA_Widget* m_hCurWidget; + FX_DWORD m_dwFilter; + FX_BOOL m_bIgnorerelevant; + CXFA_LayoutItemIterator m_sIterator; +}; +typedef CFX_ArrayTemplate<CXFA_FFWidget*> CXFA_WidgetArray; +class CXFA_TabParam { + public: + CXFA_TabParam() : m_pWidget(NULL) {} + ~CXFA_TabParam() {} + + CXFA_FFWidget* m_pWidget; + CXFA_WidgetArray m_Children; +}; +class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { + public: + CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, + FX_DWORD dwFilter); + virtual ~CXFA_FFTabOrderPageWidgetIterator(); + + virtual void Release(); + + virtual void Reset(); + virtual IXFA_Widget* MoveToFirst(); + virtual IXFA_Widget* MoveToLast(); + virtual IXFA_Widget* MoveToNext(); + virtual IXFA_Widget* MoveToPrevious(); + virtual IXFA_Widget* GetCurrentWidget(); + virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); + + protected: + CXFA_WidgetArray m_TabOrderWidgetArray; + CXFA_FFPageView* m_pPageView; + FX_DWORD m_dwFilter; + int32_t m_iCurWidget; + FX_BOOL m_bIgnorerelevant; + CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget); + CXFA_FFWidget* FindWidgetByName(const CFX_WideStringC& wsWidgetName, + CXFA_FFWidget* pRefWidget); + void CreateTabOrderWidgetArray(); + void CreateSpaceOrderWidgetArray(CXFA_WidgetArray& WidgetArray); + CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); + void OrderContainer(CXFA_LayoutItemIterator* sIterator, + CXFA_LayoutItem* pContainerItem, + CXFA_TabParam* pContainer, + FX_BOOL& bCurrentItem, + FX_BOOL& bContentArea, + FX_BOOL bMarsterPage = FALSE); +}; + +#endif // XFA_FXFA_APP_XFA_FFPAGEVIEW_H_ diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp new file mode 100644 index 0000000000..f082232905 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpath.cpp @@ -0,0 +1,159 @@ +// 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/fxfa/app/xfa_ffpath.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fxgraphics/fx_graphics.h" + +CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pPageView, pDataAcc) {} +CXFA_FFLine::~CXFA_FFLine() {} +void CXFA_FFLine::GetRectFromHand(CFX_RectF& rect, + int32_t iHand, + FX_FLOAT fLineWidth) { + FX_FLOAT fHalfWidth = fLineWidth / 2.0f; + if (rect.height < 1.0f) { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.top -= fHalfWidth; + break; + case XFA_ATTRIBUTEENUM_Right: + rect.top += fHalfWidth; + } + } else if (rect.width < 1.0f) { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.left += fHalfWidth; + break; + case XFA_ATTRIBUTEENUM_Right: + rect.left += fHalfWidth; + break; + } + } else { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.Inflate(fHalfWidth, fHalfWidth); + break; + case XFA_ATTRIBUTEENUM_Right: + rect.Deflate(fHalfWidth, fHalfWidth); + break; + } + } +} +void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) { + return; + } + CXFA_Line lineObj = value.GetLine(); + FX_ARGB lineColor = 0xFF000000; + int32_t iStrokeType = 0; + FX_FLOAT fLineWidth = 1.0f; + FX_BOOL bSlope = lineObj.GetSlop(); + int32_t iCap = 0; + CXFA_Edge edge = lineObj.GetEdge(); + if (edge) { + if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { + return; + } + lineColor = edge.GetColor(); + iStrokeType = edge.GetStrokeType(); + fLineWidth = edge.GetThickness(); + iCap = edge.GetCapType(); + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CFX_RectF rtLine; + GetRectWithoutRotate(rtLine); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + XFA_RectWidthoutMargin(rtLine, mgWidget); + } + GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth); + CFX_Path linePath; + linePath.Create(); + if (bSlope && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) { + linePath.AddLine(rtLine.right(), rtLine.top, rtLine.left, rtLine.bottom()); + } else { + linePath.AddLine(rtLine.left, rtLine.top, rtLine.right(), rtLine.bottom()); + } + CFX_Color color(lineColor); + pGS->SaveGraphState(); + pGS->SetLineWidth(fLineWidth, TRUE); + XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap); + pGS->SetStrokeColor(&color); + pGS->SetLineCap(XFA_LineCapToFXGE(iCap)); + pGS->StrokePath(&linePath, &mtRotate); + pGS->RestoreGraphState(); +} +CXFA_FFArc::CXFA_FFArc(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pPageView, pDataAcc) {} +CXFA_FFArc::~CXFA_FFArc() {} +void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) { + return; + } + CXFA_Arc arcObj = value.GetArc(); + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CFX_RectF rtArc; + GetRectWithoutRotate(rtArc); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + XFA_RectWidthoutMargin(rtArc, mgWidget); + } + DrawBorder(pGS, arcObj, rtArc, &mtRotate); +} +CXFA_FFRectangle::CXFA_FFRectangle(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pPageView, pDataAcc) {} +CXFA_FFRectangle::~CXFA_FFRectangle() {} +void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) { + return; + } + CXFA_Rectangle rtObj = value.GetRectangle(); + CFX_RectF rect; + GetRectWithoutRotate(rect); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + XFA_RectWidthoutMargin(rect, mgWidget); + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + DrawBorder(pGS, rtObj, rect, &mtRotate); +} diff --git a/xfa/fxfa/app/xfa_ffpath.h b/xfa/fxfa/app/xfa_ffpath.h new file mode 100644 index 0000000000..2b2c40d01b --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpath.h @@ -0,0 +1,43 @@ +// 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_APP_XFA_FFPATH_H_ +#define XFA_FXFA_APP_XFA_FFPATH_H_ + +#include "xfa/fxfa/app/xfa_ffdraw.h" + +class CXFA_FFLine : public CXFA_FFDraw { + public: + CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFLine(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + + private: + void GetRectFromHand(CFX_RectF& rect, int32_t iHand, FX_FLOAT fLineWidth); +}; +class CXFA_FFArc : public CXFA_FFDraw { + public: + CXFA_FFArc(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFArc(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); +}; +class CXFA_FFRectangle : public CXFA_FFDraw { + public: + CXFA_FFRectangle(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFRectangle(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); +}; + +#endif // XFA_FXFA_APP_XFA_FFPATH_H_ diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp new file mode 100644 index 0000000000..718853e5e2 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -0,0 +1,249 @@ +// 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/fxfa/app/xfa_ffpushbutton.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/include/fwl/core/fwl_widgetmgr.h" +#include "xfa/include/fwl/lightwidget/pushbutton.h" + +CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), + m_pRolloverTextLayout(NULL), + m_pDownTextLayout(NULL), + m_pDownProvider(NULL), + m_pRollProvider(NULL), + m_pOldDelegate(NULL) {} +CXFA_FFPushButton::~CXFA_FFPushButton() { + CXFA_FFPushButton::UnloadWidget(); +} +void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + RenderHighlightCaption(pGS, &mtRotate); + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), + pGS, &mt); +} +FX_BOOL CXFA_FFPushButton::LoadWidget() { + FXSYS_assert(m_pNormalWidget == NULL); + CFWL_PushButton* pPushButton = CFWL_PushButton::Create(); + if (pPushButton) { + pPushButton->Initialize(); + } + m_pOldDelegate = pPushButton->SetDelegate(this); + m_pNormalWidget = (CFWL_Widget*)pPushButton; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + LoadHighlightCaption(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFPushButton::UpdateWidgetProperty() { + FX_DWORD dwStyleEx = 0; + switch (m_pDataAcc->GetButtonHighlight()) { + case XFA_ATTRIBUTEENUM_Inverted: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteInverted; + break; + case XFA_ATTRIBUTEENUM_Outline: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteOutLine; + break; + case XFA_ATTRIBUTEENUM_Push: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HilitePush; + break; + default: + break; + } + 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; + } + CXFA_FFField::UnloadWidget(); +} +FX_BOOL CXFA_FFPushButton::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + m_rtUI = rtWidget; + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + XFA_RectWidthoutMargin(rtWidget, mgWidget); + } + CXFA_Caption caption = m_pDataAcc->GetCaption(); + m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height); + if (CXFA_Margin mgCap = caption.GetMargin()) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + } + LayoutHighlightCaption(); + SetFWLRect(); + if (m_pNormalWidget) { + m_pNormalWidget->Update(); + } + return TRUE; +} +FX_FLOAT CXFA_FFPushButton::GetLineWidth() { + CXFA_Border border = m_pDataAcc->GetBorder(); + if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { + CXFA_Edge edge = border.GetEdge(0); + return edge.GetThickness(); + } + return 0; +} +FX_ARGB CXFA_FFPushButton::GetLineColor() { + return 0xFF000000; +} +FX_ARGB CXFA_FFPushButton::GetFillColor() { + return 0xFFFFFFFF; +} +void CXFA_FFPushButton::LoadHighlightCaption() { + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + { + CFX_WideString wsRollover; + FX_BOOL bRichText; + if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { + if (m_pRollProvider == NULL) { + m_pRollProvider = + new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover); + } + m_pRolloverTextLayout = new CXFA_TextLayout(m_pRollProvider); + } + CFX_WideString wsDown; + if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { + if (m_pDownProvider == NULL) { + m_pDownProvider = + new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down); + } + m_pDownTextLayout = new CXFA_TextLayout(m_pDownProvider); + } + } + } +} +void CXFA_FFPushButton::LayoutHighlightCaption() { + CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height); + LayoutCaption(); + if (m_pRolloverTextLayout) { + m_pRolloverTextLayout->Layout(sz); + } + if (m_pDownTextLayout) { + m_pDownTextLayout->Layout(sz); + } +} +void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, + CFX_Matrix* pMatrix) { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + CFX_RectF rtClip = m_rtCaption; + rtClip.Intersect(rtWidget); + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + { + FX_DWORD dwState = m_pNormalWidget->GetStates(); + if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && + (dwState & FWL_STATE_PSB_Hovered)) { + if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip)) { + return; + } + } else if (m_pRolloverTextLayout && (dwState & FWL_STATE_PSB_Hovered)) { + if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) { + return; + } + } + } + if (pCapTextLayout) { + pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); + } + } +} +int32_t CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) { + m_pOldDelegate->OnProcessEvent(pEvent); + return CXFA_FFField::OnProcessEvent(pEvent); +} +FWL_ERR 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)) { + CFX_RectF rtFill; + m_pNormalWidget->GetWidgetRect(rtFill); + rtFill.left = rtFill.top = 0; + FX_FLOAT fLineWith = GetLineWidth(); + rtFill.Deflate(fLineWith, fLineWith); + CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); + pGraphics->SetFillColor(&cr); + CFX_Path path; + path.Create(); + path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); + pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); + } + } else if (m_pNormalWidget->GetStylesEx() & + XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { + if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && + (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { + FX_FLOAT fLineWidth = GetLineWidth(); + CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255)); + pGraphics->SetStrokeColor(&cr); + pGraphics->SetLineWidth(fLineWidth); + CFX_Path path; + path.Create(); + CFX_RectF rect; + m_pNormalWidget->GetWidgetRect(rect); + 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/xfa/fxfa/app/xfa_ffpushbutton.h b/xfa/fxfa/app/xfa_ffpushbutton.h new file mode 100644 index 0000000000..39f6bd4b7b --- /dev/null +++ b/xfa/fxfa/app/xfa_ffpushbutton.h @@ -0,0 +1,50 @@ +// 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_APP_XFA_FFPUSHBUTTON_H_ +#define XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ + +#include "xfa/fxfa/app/xfa_fffield.h" + +#define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) +#define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0) +#define XFA_FWL_PSBSTYLEEXT_HilitePush (2L << 0) +#define XFA_FWL_PSBSTYLEEXT_HiliteOutLine (4L << 0) + +class CXFA_TextProvider; + +class CXFA_FFPushButton : public CXFA_FFField { + public: + CXFA_FFPushButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFPushButton(); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL LoadWidget(); + 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); + + protected: + void LoadHighlightCaption(); + void LayoutHighlightCaption(); + void RenderHighlightCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = NULL); + FX_FLOAT GetLineWidth(); + FX_ARGB GetLineColor(); + FX_ARGB GetFillColor(); + CXFA_TextLayout* m_pRolloverTextLayout; + CXFA_TextLayout* m_pDownTextLayout; + CXFA_TextProvider* m_pDownProvider; + CXFA_TextProvider* m_pRollProvider; + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp new file mode 100644 index 0000000000..96907c50a0 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffsignature.cpp @@ -0,0 +1,120 @@ +// 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/fxfa/app/xfa_ffsignature.h" + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +CXFA_FFSignature::CXFA_FFSignature(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc) {} +CXFA_FFSignature::~CXFA_FFSignature() {} +FX_BOOL CXFA_FFSignature::LoadWidget() { + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, FALSE); + CFX_RectF rtWidget = m_rtUI; + IXFA_DocProvider* pDocProvider = m_pDataAcc->GetDoc()->GetDocProvider(); + FXSYS_assert(pDocProvider); + pDocProvider->RenderCustomWidget(this, pGS, &mtRotate, rtWidget); +} +FX_BOOL CXFA_FFSignature::OnMouseEnter() { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnMouseExit() { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnLButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnLButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnMouseMove(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnRButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnRButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnRButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + return FALSE; +} +FX_BOOL CXFA_FFSignature::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { + return FALSE; +} +FX_DWORD CXFA_FFSignature::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { + if (m_pNormalWidget) { + FX_FLOAT ffx = fx, ffy = fy; + FWLToClient(ffx, ffy); + FX_DWORD dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy); + if (dwWidgetHit != FWL_WGTHITTEST_Unknown) { + return FWL_WGTHITTEST_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; +} +FX_BOOL CXFA_FFSignature::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} diff --git a/xfa/fxfa/app/xfa_ffsignature.h b/xfa/fxfa/app/xfa_ffsignature.h new file mode 100644 index 0000000000..f976fed102 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffsignature.h @@ -0,0 +1,43 @@ +// 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_APP_XFA_FFSIGNATURE_H_ +#define XFA_FXFA_APP_XFA_FFSIGNATURE_H_ + +#include "xfa/fxfa/app/xfa_fffield.h" + +class CXFA_FFSignature final : public CXFA_FFField { + public: + CXFA_FFSignature(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFSignature(); + + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL LoadWidget(); + virtual FX_BOOL OnMouseEnter(); + virtual FX_BOOL OnMouseExit(); + virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + + virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); + virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); +}; + +#endif // XFA_FXFA_APP_XFA_FFSIGNATURE_H_ diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/xfa_ffsubform.cpp new file mode 100644 index 0000000000..aebbb08684 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffsubform.cpp @@ -0,0 +1,17 @@ +// 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/fxfa/app/xfa_ffsubform.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +CXFA_FFSubForm::CXFA_FFSubForm(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFWidget(pPageView, pDataAcc) {} +CXFA_FFSubForm::~CXFA_FFSubForm() {} diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/xfa_ffsubform.h new file mode 100644 index 0000000000..e4369113de --- /dev/null +++ b/xfa/fxfa/app/xfa_ffsubform.h @@ -0,0 +1,19 @@ +// 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_APP_XFA_FFSUBFORM_H_ +#define XFA_FXFA_APP_XFA_FFSUBFORM_H_ + +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +class CXFA_FFSubForm : public CXFA_FFWidget { + public: + CXFA_FFSubForm(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFSubForm(); +}; + +#endif // XFA_FXFA_APP_XFA_FFSUBFORM_H_ diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp new file mode 100644 index 0000000000..aba8d162b0 --- /dev/null +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -0,0 +1,179 @@ +// 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/fxfa/app/xfa_fftext.h" + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/include/fwl/core/fwl_widgetdef.h" +#include "xfa/include/fxgraphics/fx_graphics.h" + +CXFA_FFText::CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pPageView, pDataAcc) {} +CXFA_FFText::~CXFA_FFText() {} +void CXFA_FFText::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + { + CFX_Matrix mtRotate; + GetRotateMatrix(mtRotate); + if (pMatrix) { + mtRotate.Concat(*pMatrix); + } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (pTextLayout) { + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_RectF rtText; + GetRectWithoutRotate(rtText); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + CXFA_LayoutItem* pItem = this; + if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { + XFA_RectWidthoutMargin(rtText, mgWidget); + } else { + FX_FLOAT fLeftInset, fRightInset, fTopInset = 0, fBottomInset = 0; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + if (pItem->GetPrev() == NULL) { + mgWidget.GetTopInset(fTopInset); + } else if (pItem->GetNext() == NULL) { + mgWidget.GetBottomInset(fBottomInset); + } + rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); + } + } + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, rtText.left, rtText.top); + CFX_RectF rtClip = rtText; + mtRotate.TransformRect(rtClip); + mt.Concat(mtRotate); + pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); + } + } +} +FX_BOOL CXFA_FFText::IsLoaded() { + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + return pTextLayout && !pTextLayout->m_bHasBlock; +} +FX_BOOL CXFA_FFText::PerformLayout() { + CXFA_FFDraw::PerformLayout(); + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (!pTextLayout) { + return FALSE; + } + if (!pTextLayout->m_bHasBlock) { + return TRUE; + } + pTextLayout->m_Blocks.RemoveAll(); + CXFA_LayoutItem* pItem = this; + if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { + return TRUE; + } + pItem = pItem->GetFirst(); + while (pItem) { + CFX_RectF rtText; + pItem->GetRect(rtText); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + if (pItem->GetPrev() == NULL) { + FX_FLOAT fTopInset; + mgWidget.GetTopInset(fTopInset); + rtText.height -= fTopInset; + } else if (pItem->GetNext() == NULL) { + FX_FLOAT fBottomInset; + mgWidget.GetBottomInset(fBottomInset); + rtText.height -= fBottomInset; + } + } + pTextLayout->ItemBlocks(rtText, pItem->GetIndex()); + pItem = pItem->GetNext(); + } + pTextLayout->m_bHasBlock = FALSE; + return TRUE; +} +FX_BOOL CXFA_FFText::OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + CFX_RectF rtBox; + GetRectWithoutRotate(rtBox); + if (!rtBox.Contains(fx, fy)) { + return FALSE; + } + const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); + if (NULL == wsURLContent) { + return FALSE; + } + SetButtonDown(TRUE); + return TRUE; +} +FX_BOOL CXFA_FFText::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + CFX_RectF rtBox; + GetRectWithoutRotate(rtBox); + if (!rtBox.Contains(fx, fy)) { + return FALSE; + } + const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); + if (NULL == wsURLContent) { + return FALSE; + } + return TRUE; +} +FX_BOOL CXFA_FFText::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + if (!IsButtonDown()) { + return FALSE; + } + SetButtonDown(FALSE); + const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); + if (NULL == wsURLContent) { + return FALSE; + } + CXFA_FFDoc* pDoc = GetDoc(); + pDoc->GetDocProvider()->GotoURL(pDoc, CFX_WideStringC(wsURLContent), FALSE); + return TRUE; +} +FX_DWORD 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; +} +const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (NULL == pTextLayout) { + return NULL; + } + FX_FLOAT x(fx), y(fy); + FWLToClient(x, y); + const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines(); + int32_t iCount = pPieceLines->GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); + int32_t iPieces = pPieceLine->m_textPieces.GetSize(); + for (int32_t j = 0; j < iPieces; j++) { + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); + if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { + return pPiece->pLinkData->GetLinkURL(); + } + } + } + return NULL; +} +void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { + CFX_RectF rtWidget; + GetRectWithoutRotate(rtWidget); + fx -= rtWidget.left; + fy -= rtWidget.top; +} diff --git a/xfa/fxfa/app/xfa_fftext.h b/xfa/fxfa/app/xfa_fftext.h new file mode 100644 index 0000000000..edf12f5bee --- /dev/null +++ b/xfa/fxfa/app/xfa_fftext.h @@ -0,0 +1,32 @@ +// 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_APP_XFA_FFTEXT_H_ +#define XFA_FXFA_APP_XFA_FFTEXT_H_ + +#include "xfa/fxfa/app/xfa_ffdraw.h" + +class CXFA_FFText : public CXFA_FFDraw { + public: + CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFText(); + virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + virtual FX_BOOL IsLoaded(); + virtual FX_BOOL PerformLayout(); + + private: + virtual const FX_WCHAR* GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy); + void FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy); +}; + +#endif // XFA_FXFA_APP_XFA_FFTEXT_H_ diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp new file mode 100644 index 0000000000..c35fe58387 --- /dev/null +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -0,0 +1,796 @@ +// 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/fxfa/app/xfa_fftextedit.h" + +#include <vector> + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/parser/xfa_localevalue.h" +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/lightwidget/datetimepicker.h" +#include "xfa/include/fwl/lightwidget/edit.h" + +CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} +CXFA_FFTextEdit::~CXFA_FFTextEdit() { + if (m_pNormalWidget) { + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(pWidget); + } +} +FX_BOOL CXFA_FFTextEdit::LoadWidget() { + CFWL_Edit* pFWLEdit = CFWL_Edit::Create(); + pFWLEdit->Initialize(); + m_pNormalWidget = pFWLEdit; + IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pWidget, this, NULL); + IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(pWidget, pWidget); + m_pOldDelegate = m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pFWLEdit->SetText(wsText); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFTextEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; + if (!pWidget) { + return; + } + FX_DWORD dwStyle = 0; + FX_DWORD dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | + FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->IsMultiLine()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; + if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwStyle |= FWL_WGTSTYLE_VScroll; + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; + } + } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; + } + XFA_ELEMENT eType = XFA_ELEMENT_UNKNOWN; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); + if (eType == XFA_ELEMENT_ExData) { + iMaxChars = 0; + } + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells == 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); + } else if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } else { + pWidget->SetLimit(iMaxChars); + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} +FX_BOOL CXFA_FFTextEdit::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!PtInActiveRect(fx, fy)) { + return FALSE; + } + if (!IsFocused()) { + m_dwStatus |= XFA_WIDGETSTATUS_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + SetButtonDown(TRUE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; + 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); + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::OnRButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + if (!PtInActiveRect(fx, fy)) { + return FALSE; + } + if (!IsFocused()) { + m_dwStatus |= XFA_WIDGETSTATUS_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + SetButtonDown(TRUE); + CFWL_MsgMouse ms; + ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_fx = fx; + ms.m_fy = fy; + FWLToClient(ms.m_fx, ms.m_fy); + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::OnRButtonUp(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) + return FALSE; + + GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { + m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; + if (!IsFocused()) { + m_dwStatus |= XFA_WIDGETSTATUS_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + CXFA_FFWidget::OnSetFocus(pOldWidget); + CFWL_MsgSetFocus ms; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { + CFWL_MsgKillFocus ms; + ms.m_pDstTarget = m_pNormalWidget->m_pIface; + ms.m_pSrcTarget = NULL; + TranslateFWLMessage(&ms); + m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + SetEditScrollOffset(); + ProcessCommittedData(); + UpdateFWLData(); + AddInvalidateRect(); + CXFA_FFWidget::OnKillFocus(pNewWidget); + m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::CommitData() { + CFX_WideString wsText; + ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); + if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { + m_pDataAcc->UpdateUIDisplay(this); + return TRUE; + } + ValidateNumberField(wsText); + return FALSE; +} +void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { + CXFA_WidgetAcc* pAcc = GetDataAcc(); + if (pAcc && pAcc->GetUIType() == XFA_ELEMENT_NumericEdit) { + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + 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, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + } + } +} +FX_BOOL CXFA_FFTextEdit::IsDataChanged() { + return (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) != 0; +} +FX_DWORD CXFA_FFTextEdit::GetAlignment() { + FX_DWORD dwExtendedStyle = 0; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + int32_t iHorz = para.GetHorizontalAlign(); + switch (iHorz) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; + break; + } + int32_t iVert = para.GetVerticalAlign(); + switch (iVert) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; + break; + } + } + return dwExtendedStyle; +} +FX_BOOL CXFA_FFTextEdit::UpdateFWLData() { + if (!m_pNormalWidget) { + return FALSE; + } + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) { + eType = XFA_VALUEPICTURE_Edit; + } + FX_BOOL bUpdate = FALSE; + if (m_pDataAcc->GetUIType() == XFA_ELEMENT_TextEdit && + m_pDataAcc->GetNumberOfCells() < 0) { + XFA_ELEMENT elementType = XFA_ELEMENT_UNKNOWN; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); + if (elementType == XFA_ELEMENT_ExData) { + iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; + } + if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) { + ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars); + bUpdate = TRUE; + } + } + if (m_pDataAcc->GetUIType() == XFA_ELEMENT_Barcode) { + int32_t nDataLen = 0; + if (eType == XFA_VALUEPICTURE_Edit) + m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen); + static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen); + bUpdate = TRUE; + } + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + CFX_WideString wsOldText; + ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); + if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { + ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); + bUpdate = TRUE; + } + if (bUpdate) { + m_pNormalWidget->Update(); + } + return TRUE; +} +FX_BOOL CXFA_FFTextEdit::CanUndo() { + return ((CFWL_Edit*)m_pNormalWidget)->CanUndo(); +} +FX_BOOL CXFA_FFTextEdit::CanRedo() { + return ((CFWL_Edit*)m_pNormalWidget)->CanRedo(); +} +FX_BOOL CXFA_FFTextEdit::Undo() { + return ((CFWL_Edit*)m_pNormalWidget)->Undo(); +} +FX_BOOL CXFA_FFTextEdit::Redo() { + return ((CFWL_Edit*)m_pNormalWidget)->Redo(); +} +FX_BOOL CXFA_FFTextEdit::CanCopy() { + int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); + return nCount > 0; +} +FX_BOOL CXFA_FFTextEdit::CanCut() { + if (m_pNormalWidget->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { + return FALSE; + } + int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); + return nCount > 0; +} +FX_BOOL CXFA_FFTextEdit::CanPaste() { + return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; +} +FX_BOOL CXFA_FFTextEdit::CanSelectAll() { + return ((CFWL_Edit*)m_pNormalWidget)->GetTextLength() > 0; +} +FX_BOOL CXFA_FFTextEdit::Copy(CFX_WideString& wsCopy) { + return ((CFWL_Edit*)m_pNormalWidget)->Copy(wsCopy); +} +FX_BOOL CXFA_FFTextEdit::Cut(CFX_WideString& wsCut) { + return ((CFWL_Edit*)m_pNormalWidget)->Cut(wsCut); +} +FX_BOOL CXFA_FFTextEdit::Paste(const CFX_WideString& wsPaste) { + return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); +} +FX_BOOL CXFA_FFTextEdit::SelectAll() { + int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); + return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount); +} +FX_BOOL CXFA_FFTextEdit::Delete() { + return ((CFWL_Edit*)m_pNormalWidget)->Delete(); +} +FX_BOOL CXFA_FFTextEdit::DeSelect() { + return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections(); +} +FX_BOOL CXFA_FFTextEdit::GetSuggestWords( + CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) { + if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { + return FALSE; + } + FWLToClient(pointf.x, pointf.y); + return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); +} +FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord( + CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { + return FALSE; + } + FWLToClient(pointf.x, pointf.y); + return ((CFWL_Edit*)m_pNormalWidget) + ->ReplaceSpellCheckWord(pointf, bsReplace); +} +void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText) { + m_dwStatus |= XFA_WIDGETSTATUS_TextEditValueChanged; + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_wsChange = wsChanged; + eParam.m_pTarget = m_pDataAcc; + eParam.m_wsPrevText = wsPrevText; + CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); + if (m_pDataAcc->GetUIType() == XFA_ELEMENT_DateTimeEdit) { + CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; + pDateTime->GetEditText(eParam.m_wsNewText); + int32_t iSels = pDateTime->CountSelRanges(); + if (iSels) { + eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); + } + } else { + pEdit->GetText(eParam.m_wsNewText); + int32_t iSels = pEdit->CountSelRanges(); + if (iSels) { + eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); + } + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} +void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Full; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); +} + +FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { + if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { + return TRUE; + } + return GetDoc()->GetDocProvider()->CheckWord(GetDoc(), sWord); +} +FX_BOOL CXFA_FFTextEdit::GetSuggestWords( + const CFX_ByteStringC& sWord, + std::vector<CFX_ByteString>& sSuggest) { + if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { + return FALSE; + } + return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); +} +int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { + return m_pOldDelegate->OnProcessMessage(pMessage); +} +FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + FX_DWORD dwEventID = pEvent->GetClassID(); + switch (dwEventID) { + case FWL_EVTHASH_EDT_TextChanged: { + CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; + CFX_WideString wsChange; + OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); + break; + } + case FWL_EVTHASH_EDT_TextFull: { + OnTextFull(m_pNormalWidget->GetWidget()); + break; + } + case FWL_EVTHASH_EDT_CheckWord: { + CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); + CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; + event->bCheckWord = CheckWord(event->bsWord); + break; + } + case FWL_EVTHASH_EDT_GetSuggestWords: { + CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; + event->bSuggestWords = + GetSuggestWords(event->bsWord, event->bsArraySuggestWords); + break; + } + default: {} + } + return m_pOldDelegate->OnProcessEvent(pEvent); +} +FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} +CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pPageView, pDataAcc) {} +CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} +FX_BOOL CXFA_FFNumericEdit::LoadWidget() { + CFWL_Edit* pWidget = CFWL_Edit::Create(); + pWidget->Initialize(); + m_pNormalWidget = (CFWL_Widget*)pWidget; + IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); + IFWL_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->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFNumericEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; + if (!pWidget) { + return; + } + FX_DWORD dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + } + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } + dwExtendedStyle |= GetAlignment(); + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} +FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { + FX_DWORD dwEventID = pEvent->GetClassID(); + if (dwEventID == FWL_EVTHASH_EDT_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); + } +} +FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, + CFX_WideString& wsText) { + CFX_WideString wsPattern; + m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); + if (!wsPattern.IsEmpty()) { + return TRUE; + } + int32_t iLeads = 0; + m_pDataAcc->GetLeadDigits(iLeads); + int32_t iFracs = 0; + m_pDataAcc->GetFracDigits(iFracs); + CFX_WideString wsFormat; + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); + widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); + return widgetValue.ValidateNumericTemp(wsText, wsFormat, + m_pDataAcc->GetLocal()); +} +CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pPageView, pDataAcc) {} +CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} +FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { + CFWL_Edit* pWidget = CFWL_Edit::Create(); + pWidget->Initialize(); + m_pNormalWidget = (CFWL_Widget*)pWidget; + IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); + IFWL_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->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFPasswordEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; + if (!pWidget) { + return; + } + FX_DWORD dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + CFX_WideString wsPassWord; + m_pDataAcc->GetPasswordChar(wsPassWord); + if (!wsPassWord.IsEmpty()) { + pWidget->SetAliasChar(wsPassWord.GetAt(0)); + } + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} +CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pPageView, pDataAcc) {} + +CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} + +FX_BOOL CXFA_FFDateTimeEdit::GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus) { + if (bDrawFocus) + return FALSE; + return CXFA_FFWidget::GetBBox(rtBox, dwStatus); +} + +FX_BOOL CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pNormalWidget) { + return FALSE; + } + CFX_RectF rtWidget; + ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); + if (rtWidget.Contains(fx, fy)) { + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { + CFWL_DateTimePicker* pWidget = CFWL_DateTimePicker::Create(); + pWidget->Initialize(); + m_pNormalWidget = (CFWL_Widget*)pWidget; + IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); + m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); + IFWL_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); + if (CXFA_Value value = m_pDataAcc->GetFormValue()) { + switch (value.GetChildValueClassID()) { + case XFA_ELEMENT_Date: { + if (!wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); + CFX_Unitime date = lcValue.GetDate(); + if ((FX_UNITIME)date != 0) { + pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } + } break; + default: + break; + } + } + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} +void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { + CFWL_DateTimePicker* pWidget = (CFWL_DateTimePicker*)m_pNormalWidget; + if (!pWidget) { + return; + } + FX_DWORD dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; + dwExtendedStyle |= UpdateUIProperty(); + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + FX_DWORD dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwEditStyles |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetEditLimit(iNumCells); + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; + } + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; + } + pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); +} +FX_DWORD CXFA_FFDateTimeEdit::GetAlignment() { + FX_DWORD dwExtendedStyle = 0; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + int32_t iHorz = para.GetHorizontalAlign(); + switch (iHorz) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; + break; + } + int32_t iVert = para.GetVerticalAlign(); + switch (iVert) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; + break; + } + } + return dwExtendedStyle; +} +FX_BOOL CXFA_FFDateTimeEdit::CommitData() { + CFX_WideString wsText; + ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); + if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { + m_pDataAcc->UpdateUIDisplay(this); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { + if (!m_pNormalWidget) { + return FALSE; + } + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) { + eType = XFA_VALUEPICTURE_Edit; + } + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); + if (IsFocused() && !wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); + CFX_Unitime date = lcValue.GetDate(); + if (lcValue.IsValid()) { + if ((FX_UNITIME)date != 0) { + ((CFWL_DateTimePicker*)m_pNormalWidget) + ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } + } + m_pNormalWidget->Update(); + return TRUE; +} +FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() { + if (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) { + return TRUE; + } + CFX_WideString wsText; + ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); + CFX_WideString wsOldValue; + m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); + return wsOldValue != wsText; +} +FX_BOOL CXFA_FFDateTimeEdit::CanUndo() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo(); +} +FX_BOOL CXFA_FFDateTimeEdit::CanRedo() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanRedo(); +} +FX_BOOL CXFA_FFDateTimeEdit::Undo() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Undo(); +} +FX_BOOL CXFA_FFDateTimeEdit::Redo() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Redo(); +} +FX_BOOL CXFA_FFDateTimeEdit::CanCopy() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCopy(); +} +FX_BOOL CXFA_FFDateTimeEdit::CanCut() { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return FALSE; + } + return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCut(); +} +FX_BOOL CXFA_FFDateTimeEdit::CanPaste() { + return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; +} +FX_BOOL CXFA_FFDateTimeEdit::CanSelectAll() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanSelectAll(); +} +FX_BOOL CXFA_FFDateTimeEdit::Copy(CFX_WideString& wsCopy) { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Copy(wsCopy); +} +FX_BOOL CXFA_FFDateTimeEdit::Cut(CFX_WideString& wsCut) { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Cut(wsCut); +} +FX_BOOL CXFA_FFDateTimeEdit::Paste(const CFX_WideString& wsPaste) { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Paste(wsPaste); +} +FX_BOOL CXFA_FFDateTimeEdit::SelectAll() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->SelectAll(); +} +FX_BOOL CXFA_FFDateTimeEdit::Delete() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->Delete(); +} +FX_BOOL CXFA_FFDateTimeEdit::DeSelect() { + return ((CFWL_DateTimePicker*)m_pNormalWidget)->DeSelect(); +} +void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay) { + CFX_WideString wsPicture; + m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); + CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); + CFX_Unitime dt; + dt.Set(iYear, iMonth, iDay); + date.SetDate(dt); + CFX_WideString wsDate; + date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), + XFA_VALUEPICTURE_Edit); + CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; + pDateTime->SetEditText(wsDate); + pDateTime->Update(); + GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} +FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { + FX_DWORD dwEventID = pEvent->GetClassID(); + if (dwEventID == FWL_EVTHASH_DTP_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); + } +} diff --git a/xfa/fxfa/app/xfa_fftextedit.h b/xfa/fxfa/app/xfa_fftextedit.h new file mode 100644 index 0000000000..d379ab1991 --- /dev/null +++ b/xfa/fxfa/app/xfa_fftextedit.h @@ -0,0 +1,138 @@ +// 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_APP_XFA_FFTEXTEDIT_H_ +#define XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ + +#include <vector> + +#include "xfa/fxfa/app/xfa_fffield.h" + +class CXFA_FFTextEdit : public CXFA_FFField { + public: + CXFA_FFTextEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFTextEdit() override; + + // CXFA_FFField: + FX_BOOL LoadWidget() override; + void UpdateWidgetProperty() override; + FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget) override; + FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget) override; + FX_BOOL CanUndo() override; + FX_BOOL CanRedo() override; + FX_BOOL Undo() override; + FX_BOOL Redo() override; + FX_BOOL CanCopy() override; + FX_BOOL CanCut() override; + FX_BOOL CanPaste() override; + FX_BOOL CanSelectAll() override; + FX_BOOL Copy(CFX_WideString& wsCopy) override; + FX_BOOL Cut(CFX_WideString& wsCut) override; + FX_BOOL Paste(const CFX_WideString& wsPaste) override; + FX_BOOL SelectAll() override; + FX_BOOL Delete() override; + FX_BOOL DeSelect() override; + FX_BOOL GetSuggestWords(CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) override; + FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, + 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 OnTextChanged(IFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText); + void OnTextFull(IFWL_Widget* pWidget); + FX_BOOL CheckWord(const CFX_ByteStringC& sWord); + FX_BOOL GetSuggestWords(const CFX_ByteStringC& sWord, + std::vector<CFX_ByteString>& sSuggest); + + protected: + FX_DWORD GetAlignment(); + FX_BOOL CommitData() override; + FX_BOOL UpdateFWLData() override; + FX_BOOL IsDataChanged() override; + void ValidateNumberField(const CFX_WideString& wsText); + + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +class CXFA_FFNumericEdit : public CXFA_FFTextEdit { + public: + CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFNumericEdit(); + virtual FX_BOOL LoadWidget(); + virtual void UpdateWidgetProperty(); + virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); + + public: + FX_BOOL OnValidate(IFWL_Widget* pWidget, CFX_WideString& wsText); +}; +class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { + public: + CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFPasswordEdit(); + virtual FX_BOOL LoadWidget(); + virtual void UpdateWidgetProperty(); + + protected: +}; +enum XFA_DATETIMETYPE { + XFA_DATETIMETYPE_Date = 0, + XFA_DATETIMETYPE_Time, + XFA_DATETIMETYPE_DateAndTime +}; +class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { + public: + CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFDateTimeEdit(); + + virtual FX_BOOL GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus = FALSE); + virtual FX_BOOL LoadWidget(); + virtual void UpdateWidgetProperty(); + + 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 CanPaste(); + 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(); + + protected: + FX_DWORD GetAlignment(); + + virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL CommitData(); + virtual FX_BOOL UpdateFWLData(); + virtual FX_BOOL IsDataChanged(); + + public: + void OnSelectChanged(IFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay); + virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); +}; + +#endif // XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp new file mode 100644 index 0000000000..315394629d --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -0,0 +1,1961 @@ +// 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/fxfa/app/xfa_ffwidget.h" + +#include <algorithm> + +#include "core/include/fpdfapi/fpdf_page.h" +#include "core/include/fxcodec/fx_codec.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/include/fxgraphics/fx_graphics.h" + +CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, + CXFA_WidgetAcc* pDataAcc) + : CXFA_ContentLayoutItem(pDataAcc->GetNode()), + m_pPageView(pPageView), + m_pDataAcc(pDataAcc) { + m_rtWidget.Set(0, 0, 0, 0); +} +CXFA_FFWidget::~CXFA_FFWidget() {} +IXFA_PageView* CXFA_FFWidget::GetPageView() { + return m_pPageView; +} +void CXFA_FFWidget::SetPageView(IXFA_PageView* pPageView) { + m_pPageView = static_cast<CXFA_FFPageView*>(pPageView); +} +void CXFA_FFWidget::GetWidgetRect(CFX_RectF& rtWidget) { + 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; + GetRect(m_rtWidget); + return m_rtWidget; +} +void CXFA_FFWidget::GetRectWithoutRotate(CFX_RectF& rtWidget) { + GetWidgetRect(rtWidget); + FX_FLOAT fValue = 0; + switch (m_pDataAcc->GetRotate()) { + case 90: + rtWidget.top = rtWidget.bottom(); + fValue = rtWidget.width; + rtWidget.width = rtWidget.height; + rtWidget.height = fValue; + break; + case 180: + rtWidget.left = rtWidget.right(); + rtWidget.top = rtWidget.bottom(); + break; + case 270: + rtWidget.left = rtWidget.right(); + fValue = rtWidget.width; + rtWidget.width = rtWidget.height; + rtWidget.height = fValue; + break; + } +} +FX_DWORD CXFA_FFWidget::GetStatus() { + return m_dwStatus; +} + +void CXFA_FFWidget::ModifyStatus(FX_DWORD dwAdded, FX_DWORD dwRemoved) { + m_dwStatus = (m_dwStatus & ~dwRemoved) | dwAdded; +} + +FX_BOOL CXFA_FFWidget::GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus) { + if (bDrawFocus) + return FALSE; + if (m_pPageView) + m_pPageView->GetPageViewRect(rtBox); + return TRUE; +} + +CXFA_WidgetAcc* CXFA_FFWidget::GetDataAcc() { + return m_pDataAcc; +} +FX_BOOL CXFA_FFWidget::GetToolTip(CFX_WideString& wsToolTip) { + if (CXFA_Assist assist = m_pDataAcc->GetAssist()) { + if (CXFA_ToolTip toolTip = assist.GetToolTip()) { + return toolTip.GetTip(wsToolTip); + } + } + return GetCaptionText(wsToolTip); +} +void CXFA_FFWidget::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_DWORD dwStatus, + int32_t iRotate) { + if (!IsMatchVisibleStatus(dwStatus)) { + return; + } + CXFA_Border border = m_pDataAcc->GetBorder(); + if (border) { + CFX_RectF rtBorder; + GetRectWithoutRotate(rtBorder); + CXFA_Margin margin = border.GetMargin(); + if (margin) { + XFA_RectWidthoutMargin(rtBorder, margin); + } + rtBorder.Normalize(); + DrawBorder(pGS, border, rtBorder, pMatrix); + } +} +FX_BOOL CXFA_FFWidget::IsLoaded() { + return m_pPageView != NULL; +} +FX_BOOL CXFA_FFWidget::LoadWidget() { + PerformLayout(); + return TRUE; +} +void CXFA_FFWidget::UnloadWidget() {} +FX_BOOL CXFA_FFWidget::PerformLayout() { + ReCacheWidgetRect(); + return TRUE; +} +FX_BOOL CXFA_FFWidget::UpdateFWLData() { + return FALSE; +} +void CXFA_FFWidget::UpdateWidgetProperty() {} +void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS, + CXFA_Box box, + const CFX_RectF& rtBorder, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags) { + XFA_DrawBox(box, pGS, rtBorder, pMatrix, dwFlags); +} +void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { + if (!pRect) { + CFX_RectF rtWidget; + GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); + rtWidget.Inflate(2, 2); + GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, rtWidget, + XFA_INVALIDATE_CurrentPage); + } else { + GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, *pRect, + XFA_INVALIDATE_CurrentPage); + } +} +void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { + CFX_RectF rtWidget; + if (pRect) { + rtWidget = *pRect; + } else { + GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); + rtWidget.Inflate(2, 2); + } + m_pDocView->AddInvalidateRect(m_pPageView, rtWidget); +} +FX_BOOL CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) { + CXFA_TextLayout* pCapTextlayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextlayout) { + return FALSE; + } + pCapTextlayout->GetText(wsCap); + return TRUE; +} +FX_BOOL CXFA_FFWidget::IsFocused() { + return m_dwStatus & XFA_WIDGETSTATUS_Focused; +} +FX_BOOL CXFA_FFWidget::OnMouseEnter() { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnMouseExit() { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnLButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnLButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnRButtonDown(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnRButtonDblClk(FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + return FALSE; +} + +FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { + CXFA_FFWidget* pParent = GetParent(); + if (pParent && !pParent->IsAncestorOf(pOldWidget)) { + pParent->OnSetFocus(pOldWidget); + } + m_dwStatus |= XFA_WIDGETSTATUS_Focused; + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Enter; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Enter, &eParam); + return TRUE; +} +FX_BOOL CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { + m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + EventKillFocus(); + if (pNewWidget) { + CXFA_FFWidget* pParent = GetParent(); + if (pParent && !pParent->IsAncestorOf(pNewWidget)) { + pParent->OnKillFocus(pNewWidget); + } + } + return TRUE; +} +FX_BOOL CXFA_FFWidget::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { + return FALSE; +} +FX_DWORD CXFA_FFWidget::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} +FX_BOOL CXFA_FFWidget::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { + return FALSE; +} +void CXFA_FFWidget::Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy) { + CFX_Matrix mt; + GetRotateMatrix(mt); + if (mt.IsIdentity()) { + return; + } + CFX_Matrix mtReverse; + mtReverse.SetReverse(mt); + mtReverse.TransformPoint(fx, fy); +} +static void XFA_GetMatrix(CFX_Matrix& m, + int32_t iRotate, + int32_t at, + const CFX_RectF& rt) { + if (!iRotate) { + return; + } + FX_FLOAT fAnchorX, fAnchorY; + switch (at) { + case XFA_ATTRIBUTEENUM_TopLeft: + fAnchorX = rt.left, fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_TopCenter: + fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_TopRight: + fAnchorX = rt.right(), fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_MiddleLeft: + fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_MiddleCenter: + fAnchorX = (rt.left + rt.right()) / 2, + fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_MiddleRight: + fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_BottomLeft: + fAnchorX = rt.left, fAnchorY = rt.bottom(); + break; + case XFA_ATTRIBUTEENUM_BottomCenter: + fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom(); + break; + case XFA_ATTRIBUTEENUM_BottomRight: + fAnchorX = rt.right(), fAnchorY = rt.bottom(); + break; + } + switch (iRotate) { + case 90: + m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY, + m.f = fAnchorX + fAnchorY; + break; + case 180: + m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2, + m.f = fAnchorY * 2; + break; + case 270: + m.a = 0, m.b = 1, m.c = -1, m.d = 0, m.e = fAnchorX + fAnchorY, + m.f = fAnchorY - fAnchorX; + break; + } +} +void CXFA_FFWidget::GetRotateMatrix(CFX_Matrix& mt) { + mt.Set(1, 0, 0, 1, 0, 0); + int32_t iRotate = m_pDataAcc->GetRotate(); + if (!iRotate) { + return; + } + CFX_RectF rcWidget; + GetRectWithoutRotate(rcWidget); + XFA_ATTRIBUTEENUM at = XFA_ATTRIBUTEENUM_TopLeft; + XFA_GetMatrix(mt, iRotate, at, rcWidget); +} +FX_BOOL CXFA_FFWidget::IsLayoutRectEmpty() { + CFX_RectF rtLayout; + GetRectWithoutRotate(rtLayout); + return rtLayout.width < 0.1f && rtLayout.height < 0.1f; +} +CXFA_FFWidget* CXFA_FFWidget::GetParent() { + CXFA_Node* pParentNode = + m_pDataAcc->GetNode()->GetNodeItem(XFA_NODEITEM_Parent); + if (pParentNode) { + CXFA_WidgetAcc* pParentWidgetAcc = + (CXFA_WidgetAcc*)pParentNode->GetWidgetData(); + if (pParentWidgetAcc) { + return pParentWidgetAcc->GetNextWidget(NULL); + } + } + return NULL; +} +FX_BOOL CXFA_FFWidget::IsAncestorOf(CXFA_FFWidget* pWidget) { + if (!pWidget) { + return FALSE; + } + CXFA_Node* pNode = m_pDataAcc->GetNode(); + CXFA_Node* pChildNode = pWidget->GetDataAcc()->GetNode(); + while (pChildNode) { + if (pChildNode == pNode) { + return TRUE; + } + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_Parent); + } + return FALSE; +} +FX_BOOL CXFA_FFWidget::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { + CFX_RectF rtWidget; + GetWidgetRect(rtWidget); + if (rtWidget.Contains(fx, fy)) { + return TRUE; + } + return FALSE; +} +CXFA_FFDocView* CXFA_FFWidget::GetDocView() { + return m_pDocView; +} +CXFA_FFDoc* CXFA_FFWidget::GetDoc() { + return (CXFA_FFDoc*)m_pDocView->GetDoc(); +} +CXFA_FFApp* CXFA_FFWidget::GetApp() { + return GetDoc()->GetApp(); +} +IXFA_AppProvider* CXFA_FFWidget::GetAppProvider() { + return GetApp()->GetAppProvider(); +} +void CXFA_FFWidget::GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth) { + fMinWidth = fMaxWidth = 0; + FX_FLOAT fWidth = 0; + if (m_pDataAcc->GetWidth(fWidth)) { + fMinWidth = fMaxWidth = fWidth; + } else { + m_pDataAcc->GetMinWidth(fMinWidth); + m_pDataAcc->GetMaxWidth(fMaxWidth); + } +} +void CXFA_FFWidget::GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight) { + fMinHeight = fMaxHeight = 0; + FX_FLOAT fHeight = 0; + if (m_pDataAcc->GetHeight(fHeight)) { + fMinHeight = fMaxHeight = fHeight; + } else { + m_pDataAcc->GetMinHeight(fMinHeight); + m_pDataAcc->GetMaxHeight(fMaxHeight); + } +} +FX_BOOL CXFA_FFWidget::IsMatchVisibleStatus(FX_DWORD dwStatus) { + return m_dwStatus & XFA_WIDGETSTATUS_Visible; +} +void CXFA_FFWidget::EventKillFocus() { + if (m_dwStatus & XFA_WIDGETSTATUS_Access) { + m_dwStatus &= ~XFA_WIDGETSTATUS_Access; + return; + } + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Exit; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam); +} +FX_BOOL CXFA_FFWidget::IsButtonDown() { + 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; +} +int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, + int32_t iStrokeType, + int32_t iCapType) { + switch (iStrokeType) { + case XFA_ATTRIBUTEENUM_DashDot: { + FX_FLOAT dashArray[] = {4, 1, 2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + } + pGraphics->SetLineDash(0, dashArray, 4); + return FX_DASHSTYLE_DashDot; + } + case XFA_ATTRIBUTEENUM_DashDotDot: { + FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + dashArray[5] = 2; + } + pGraphics->SetLineDash(0, dashArray, 6); + return FX_DASHSTYLE_DashDotDot; + } + case XFA_ATTRIBUTEENUM_Dashed: { + FX_FLOAT dashArray[] = {5, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + } + pGraphics->SetLineDash(0, dashArray, 2); + return FX_DASHSTYLE_Dash; + } + case XFA_ATTRIBUTEENUM_Dotted: { + FX_FLOAT dashArray[] = {2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + } + pGraphics->SetLineDash(0, dashArray, 2); + return FX_DASHSTYLE_Dot; + } + default: + break; + } + pGraphics->SetLineDash(FX_DASHSTYLE_Solid); + return FX_DASHSTYLE_Solid; +} +CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) { + switch (iLineCap) { + case XFA_ATTRIBUTEENUM_Round: + return CFX_GraphStateData::LineCapRound; + case XFA_ATTRIBUTEENUM_Butt: + return CFX_GraphStateData::LineCapButt; + default: + break; + } + 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, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + FX_DWORD flags, + int blendType = FXDIB_BLEND_NORMAL); + FX_BOOL Continue(IFX_Pause* pPause); + + protected: + CFX_RenderDevice* m_pDevice; + int m_Status; + CFX_Matrix m_ImageMatrix; + CFX_DIBSource* m_pDIBSource; + CFX_DIBitmap* m_pCloneConvert; + int m_BitmapAlpha; + FX_ARGB m_FillArgb; + FX_DWORD m_Flags; + CFX_ImageTransformer* m_pTransformer; + void* m_DeviceHandle; + int32_t m_BlendType; + FX_BOOL m_Result; + FX_BOOL m_bPrint; + FX_BOOL StartDIBSource(); + void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency); +}; +CXFA_ImageRenderer::CXFA_ImageRenderer() { + m_pDevice = NULL; + m_Status = 0; + m_pDIBSource = NULL; + m_pCloneConvert = NULL; + 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) { + m_pDevice->CancelDIBits(m_DeviceHandle); + } +} +FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, + CFX_DIBSource* pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + FX_DWORD flags, + int blendType) { + m_pDevice = pDevice; + m_pDIBSource = pDIBSource; + m_FillArgb = bitmap_argb; + m_BitmapAlpha = bitmap_alpha; + m_ImageMatrix = *pImage2Device; + m_Flags = flags; + m_BlendType = blendType; + return StartDIBSource(); +} +FX_BOOL CXFA_ImageRenderer::StartDIBSource() { + if (m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_FillArgb, + &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, + m_BlendType)) { + if (m_DeviceHandle) { + m_Status = 3; + return TRUE; + } + return FALSE; + } + CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); + FX_RECT image_rect = image_rect_f.GetOutterRect(); + int dest_width = image_rect.Width(); + int dest_height = image_rect.Height(); + if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || + (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { + if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { + m_Result = FALSE; + return FALSE; + } + CFX_DIBSource* pDib = m_pDIBSource; + if (m_pDIBSource->HasAlpha() && + !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && + !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { + m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); + if (!m_pCloneConvert) { + m_Result = FALSE; + return FALSE; + } + pDib = m_pCloneConvert; + } + 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); + return TRUE; + } + if (m_ImageMatrix.a < 0) { + dest_width = -dest_width; + } + 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; + if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { + if (m_pDevice->StretchDIBits(m_pDIBSource, dest_left, dest_top, dest_width, + dest_height, m_Flags, NULL, m_BlendType)) { + return FALSE; + } + } + if (m_pDIBSource->IsAlphaMask()) { + if (m_BitmapAlpha != 255) { + m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); + } + if (m_pDevice->StretchBitMask(m_pDIBSource, dest_left, dest_top, dest_width, + dest_height, m_FillArgb, m_Flags)) { + return FALSE; + } + } + if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { + m_Result = FALSE; + return TRUE; + } + FX_RECT clip_box = m_pDevice->GetClipBox(); + FX_RECT dest_rect = clip_box; + dest_rect.Intersect(image_rect); + 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); + if (pStretched) { + CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb, + m_BitmapAlpha, m_BlendType, FALSE); + delete pStretched; + pStretched = NULL; + } + return FALSE; +} +FX_BOOL CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { + if (m_Status == 2) { + if (m_pTransformer->Continue(pPause)) { + return TRUE; + } + CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); + if (pBitmap == NULL) { + return FALSE; + } + if (pBitmap->IsAlphaMask()) { + 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); + } else { + if (m_BitmapAlpha != 255) { + pBitmap->MultiplyAlpha(m_BitmapAlpha); + } + m_Result = m_pDevice->SetDIBits(pBitmap, m_pTransformer->m_ResultLeft, + m_pTransformer->m_ResultTop, m_BlendType); + } + delete pBitmap; + return FALSE; + } else if (m_Status == 3) { + return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); + } + return FALSE; +} +void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency) { + if (pDIBitmap == NULL) { + 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) { + pDIBitmap->MultiplyAlpha(bitmap_alpha); + } + if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { + return; + } + } else { + FX_DWORD fill_argb = (mask_argb); + if (bitmap_alpha < 255) { + ((uint8_t*)&fill_argb)[3] = + ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; + } + if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { + return; + } + } + } + FX_BOOL bBackAlphaRequired = blend_mode && bIsolated; + FX_BOOL bGetBackGround = + ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || + (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && + (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); + if (bGetBackGround) { + if (bIsolated || !bGroup) { + if (pDIBitmap->IsAlphaMask()) { + return; + } + m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode); + } else { + FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), + top + pDIBitmap->GetHeight()); + rect.Intersect(m_pDevice->GetClipBox()); + CFX_DIBitmap* pClone = NULL; + FX_BOOL bClone = FALSE; + if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { + bClone = TRUE; + pClone = m_pDevice->GetBackDrop()->Clone(&rect); + CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); + pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pForeBitmap, rect.left, rect.top); + left = left >= 0 ? 0 : left; + top = top >= 0 ? 0 : top; + if (!pDIBitmap->IsAlphaMask()) + pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pDIBitmap, left, top, blend_mode); + else + pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pDIBitmap, mask_argb, left, top, blend_mode); + } else { + pClone = pDIBitmap; + } + if (m_pDevice->GetBackDrop()) { + m_pDevice->SetDIBits(pClone, rect.left, rect.top); + } else { + if (pDIBitmap->IsAlphaMask()) { + return; + } + m_pDevice->SetDIBits(pDIBitmap, rect.left, rect.top, blend_mode); + } + if (bClone) { + delete pClone; + } + } + return; + } + if (pDIBitmap->HasAlpha() && + !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { + CFX_DIBitmap* pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb); + if (!pCloneConvert) { + return; + } + CXFA_ImageRenderer imageRender; + FX_BOOL bRet = imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb, + m_BitmapAlpha, &m_ImageMatrix, m_Flags); + while (bRet) { + bRet = imageRender.Continue(NULL); + } + delete pCloneConvert; + return; + } +} +void XFA_DrawImage(CFX_Graphics* pGS, + const CFX_RectF& rtImage, + CFX_Matrix* pMatrix, + CFX_DIBitmap* pDIBitmap, + int32_t iAspect, + int32_t iImageXDpi, + int32_t iImageYDpi, + int32_t iHorzAlign, + int32_t iVertAlign) { + if (rtImage.IsEmpty()) { + return; + } + if (!pDIBitmap || !pDIBitmap->GetBuffer()) { + return; + } + FX_FLOAT fWidth = + XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); + FX_FLOAT fHeight = + XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); + CFX_RectF rtFit; + rtFit.Set(rtImage.left, rtImage.top, fWidth, fHeight); + switch (iAspect) { + case XFA_ATTRIBUTEENUM_Fit: { + FX_FLOAT f1 = rtImage.height / rtFit.height; + FX_FLOAT f2 = rtImage.width / rtFit.width; + f1 = std::min(f1, f2); + rtFit.height = rtFit.height * f1; + rtFit.width = rtFit.width * f1; + } break; + case XFA_ATTRIBUTEENUM_Actual: + break; + case XFA_ATTRIBUTEENUM_Height: { + FX_FLOAT f1 = rtImage.height / rtFit.height; + rtFit.height = rtImage.height; + rtFit.width = f1 * rtFit.width; + } break; + case XFA_ATTRIBUTEENUM_None: + rtFit.height = rtImage.height; + rtFit.width = rtImage.width; + break; + case XFA_ATTRIBUTEENUM_Width: { + FX_FLOAT f1 = rtImage.width / rtFit.width; + rtFit.width = rtImage.width; + rtFit.height = rtFit.height * f1; + } break; + } + if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { + rtFit.left += (rtImage.width - rtFit.width) / 2; + } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { + rtFit.left = rtImage.right() - rtFit.width; + } + if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { + rtFit.top += (rtImage.height - rtFit.height) / 2; + } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { + rtFit.top = rtImage.bottom() - rtImage.height; + } + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + pRenderDevice->SaveState(); + CFX_PathData path; + path.AppendRect(rtImage.left, rtImage.bottom(), rtImage.right(), rtImage.top); + pRenderDevice->SetClip_PathFill(&path, pMatrix, FXFILL_WINDING); + CFX_Matrix mtImage(1, 0, 0, -1, 0, 1); + mtImage.Concat(rtFit.width, 0, 0, rtFit.height, rtFit.left, rtFit.top); + mtImage.Concat(*pMatrix); + CXFA_ImageRenderer imageRender; + FX_BOOL bRet = imageRender.Start(pRenderDevice, pDIBitmap, 0, 255, &mtImage, + FXDIB_INTERPOL); + while (bRet) { + bRet = imageRender.Continue(NULL); + } + pRenderDevice->RestoreState(); +} + +static const uint8_t g_inv_base64[128] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, + 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, + 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 255, 255, 255, 255, 255, +}; + +static uint8_t* XFA_RemoveBase64Whitespace(const uint8_t* pStr, int32_t iLen) { + uint8_t* pCP; + int32_t i = 0, j = 0; + if (iLen == 0) { + iLen = FXSYS_strlen((FX_CHAR*)pStr); + } + pCP = FX_Alloc(uint8_t, iLen + 1); + for (; i < iLen; i++) { + if ((pStr[i] & 128) == 0) { + if (g_inv_base64[pStr[i]] != 0xFF || pStr[i] == '=') { + pCP[j++] = pStr[i]; + } + } + } + pCP[j] = '\0'; + return pCP; +} +static int32_t XFA_Base64Decode(const FX_CHAR* pStr, uint8_t* pOutBuffer) { + if (pStr == NULL) { + return 0; + } + uint8_t* pBuffer = + XFA_RemoveBase64Whitespace((uint8_t*)pStr, FXSYS_strlen((FX_CHAR*)pStr)); + if (pBuffer == NULL) { + return 0; + } + int32_t iLen = FXSYS_strlen((FX_CHAR*)pBuffer); + int32_t i = 0, j = 0; + FX_DWORD dwLimb = 0; + for (; i + 3 < iLen; i += 4) { + if (pBuffer[i] == '=' || pBuffer[i + 1] == '=' || pBuffer[i + 2] == '=' || + pBuffer[i + 3] == '=') { + if (pBuffer[i] == '=' || pBuffer[i + 1] == '=') { + break; + } + if (pBuffer[i + 2] == '=') { + dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 6) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 1]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 4) & 0xFF; + j++; + } else { + dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 12) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 1]] << 6) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 2]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 10) & 0xFF; + pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 2) & 0xFF; + j += 2; + } + } else { + dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 18) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 1]] << 12) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 2]] << 6) | + ((FX_DWORD)g_inv_base64[pBuffer[i + 3]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 16) & 0xff; + pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 8) & 0xff; + pOutBuffer[j + 2] = (uint8_t)(dwLimb)&0xff; + j += 3; + } + } + FX_Free(pBuffer); + return j; +} +static FX_CHAR g_base64_chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len) { + FX_CHAR* out = NULL; + int i, j; + FX_DWORD limb; + out = FX_Alloc(FX_CHAR, ((buf_len * 8 + 5) / 6) + 5); + for (i = 0, j = 0, limb = 0; i + 2 < buf_len; i += 3, j += 4) { + limb = ((FX_DWORD)buf[i] << 16) | ((FX_DWORD)buf[i + 1] << 8) | + ((FX_DWORD)buf[i + 2]); + out[j] = g_base64_chars[(limb >> 18) & 63]; + out[j + 1] = g_base64_chars[(limb >> 12) & 63]; + out[j + 2] = g_base64_chars[(limb >> 6) & 63]; + out[j + 3] = g_base64_chars[(limb)&63]; + } + switch (buf_len - i) { + case 0: + break; + case 1: + limb = ((FX_DWORD)buf[i]); + out[j++] = g_base64_chars[(limb >> 2) & 63]; + out[j++] = g_base64_chars[(limb << 4) & 63]; + out[j++] = '='; + out[j++] = '='; + break; + case 2: + limb = ((FX_DWORD)buf[i] << 8) | ((FX_DWORD)buf[i + 1]); + out[j++] = g_base64_chars[(limb >> 10) & 63]; + out[j++] = g_base64_chars[(limb >> 4) & 63]; + out[j++] = g_base64_chars[(limb << 2) & 63]; + out[j++] = '='; + break; + default: + break; + } + out[j] = '\0'; + return out; +} +FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType) { + CFX_WideString wsContentType(wsType); + wsContentType.MakeLower(); + if (wsContentType == FX_WSTRC(L"image/jpg")) { + return FXCODEC_IMAGE_JPG; + } + if (wsContentType == FX_WSTRC(L"image/png")) { + return FXCODEC_IMAGE_PNG; + } + if (wsContentType == FX_WSTRC(L"image/gif")) { + return FXCODEC_IMAGE_GIF; + } + if (wsContentType == FX_WSTRC(L"image/bmp")) { + return FXCODEC_IMAGE_BMP; + } + if (wsContentType == FX_WSTRC(L"image/tif")) { + return FXCODEC_IMAGE_TIF; + } + return FXCODEC_IMAGE_UNKNOWN; +} +CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + FX_BOOL& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + CFX_WideString wsHref; + pImage->GetHref(wsHref); + CFX_WideString wsImage; + pImage->GetContent(wsImage); + if (wsHref.IsEmpty() && wsImage.IsEmpty()) { + return NULL; + } + CFX_WideString wsContentType; + pImage->GetContentType(wsContentType); + FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); + CFX_ByteString bsContent; + uint8_t* pImageBuffer = NULL; + IFX_FileRead* pImageFileRead = NULL; + if (wsImage.GetLength() > 0) { + XFA_ATTRIBUTEENUM iEncoding = + (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); + if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { + 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); + 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()); + } + } 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, iImageXDpi, iImageYDpi); + if (pBitmap) { + bNameImage = TRUE; + return pBitmap; + } + } + pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); + } + if (!pImageFileRead) { + FX_Free(pImageBuffer); + return NULL; + } + bNameImage = FALSE; + CFX_DIBitmap* pBitmap = + XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); + FX_Free(pImageBuffer); + pImageFileRead->Release(); + return pBitmap; +} +static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, + int32_t iComponents, + int32_t iBitsPerComponent) { + FXDIB_Format dibFormat = FXDIB_Argb; + switch (type) { + case FXCODEC_IMAGE_BMP: + case FXCODEC_IMAGE_JPG: + case FXCODEC_IMAGE_TIF: { + dibFormat = FXDIB_Rgb32; + int32_t bpp = iComponents * iBitsPerComponent; + if (bpp <= 24) { + dibFormat = FXDIB_Rgb; + } + } break; + case FXCODEC_IMAGE_PNG: + default: + break; + } + return dibFormat; +} +CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + CFX_GEModule* pGeModule = CFX_GEModule::Get(); + if (!pGeModule) { + return NULL; + } + CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); + if (!pCodecMgr) { + return NULL; + } + CFX_DIBAttribute dibAttr; + CFX_DIBitmap* pBitmap = NULL; + ICodec_ProgressiveDecoder* pProgressiveDecoder = + pCodecMgr->CreateProgressiveDecoder(); + pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr); + switch (dibAttr.m_wDPIUnit) { + case FXCODEC_RESUNIT_CENTIMETER: + dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI * 2.54f); + dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI * 2.54f); + break; + case FXCODEC_RESUNIT_METER: + dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI / (FX_FLOAT)100 * 2.54f); + dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI / (FX_FLOAT)100 * 2.54f); + break; + default: + break; + } + iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96); + iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96); + if (pProgressiveDecoder->GetWidth() > 0 && + pProgressiveDecoder->GetHeight() > 0) { + type = pProgressiveDecoder->GetType(); + int32_t iComponents = pProgressiveDecoder->GetNumComponents(); + int32_t iBpc = pProgressiveDecoder->GetBPC(); + FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); + pBitmap = new CFX_DIBitmap(); + pBitmap->Create(pProgressiveDecoder->GetWidth(), + pProgressiveDecoder->GetHeight(), dibFormat); + pBitmap->Clear(0xffffffff); + int32_t nFrames; + if ((pProgressiveDecoder->GetFrames(nFrames) == + FXCODEC_STATUS_DECODE_READY) && + (nFrames > 0)) { + pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), + pBitmap->GetHeight()); + pProgressiveDecoder->ContinueDecode(); + } + } + delete pProgressiveDecoder; + return pBitmap; +} +void XFA_RectWidthoutMargin(CFX_RectF& rt, const CXFA_Margin& mg, FX_BOOL bUI) { + if (!mg) { + return; + } + FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; + mg.GetLeftInset(fLeftInset); + mg.GetTopInset(fTopInset); + mg.GetRightInset(fRightInset); + mg.GetBottomInset(fBottomInset); + rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); +} +CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) { + XFA_ELEMENT iType = pLayoutItem->GetFormNode()->GetClassID(); + if (XFA_IsCreateWidget(iType)) { + return static_cast<CXFA_FFWidget*>(pLayoutItem); + } + return nullptr; +} +FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType) { + return iType == XFA_ELEMENT_Field || iType == XFA_ELEMENT_Draw || + iType == XFA_ELEMENT_Subform || iType == XFA_ELEMENT_ExclGroup; +} +static void XFA_BOX_GetPath_Arc(CXFA_Box box, + CFX_RectF rtDraw, + CFX_Path& fillPath, + FX_DWORD dwFlags) { + FX_FLOAT a, b; + a = rtDraw.width / 2.0f; + b = rtDraw.height / 2.0f; + if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + a = b = std::min(a, b); + } + CFX_PointF center = rtDraw.Center(); + rtDraw.left = center.x - a; + rtDraw.top = center.y - b; + rtDraw.width = a + a; + rtDraw.height = b + b; + FX_FLOAT startAngle = 0, sweepAngle = 360; + FX_BOOL bStart = box.GetStartAngle(startAngle); + FX_BOOL bEnd = box.GetSweepAngle(sweepAngle); + if (!bStart && !bEnd) { + fillPath.AddEllipse(rtDraw); + return; + } + startAngle = -startAngle * FX_PI / 180.0f; + sweepAngle = -sweepAngle * FX_PI / 180.0f; + fillPath.AddArc(rtDraw.left, rtDraw.top, rtDraw.width, rtDraw.height, + startAngle, sweepAngle); +} +static void XFA_BOX_GetPath(CXFA_Box box, + const CXFA_StrokeArray& strokes, + CFX_RectF rtWidget, + CFX_Path& path, + int32_t nIndex, + FX_BOOL bStart, + FX_BOOL bCorner) { + FXSYS_assert(nIndex >= 0 && nIndex < 8); + FX_BOOL bInverted, bRound; + FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX, + offsetEX, offsetEY; + CFX_PointF cpStart, cp, cp1, cp2; + CFX_RectF rtRadius; + int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; + CXFA_Corner corner1(strokes[n].GetNode()); + CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); + fRadius1 = bCorner ? corner1.GetRadius() : 0; + fRadius2 = bCorner ? corner2.GetRadius() : 0; + bInverted = corner1.IsInverted(); + offsetY = 0.0f; + offsetX = 0.0f; + bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; + FX_FLOAT halfAfter = 0.0f; + FX_FLOAT halfBefore = 0.0f; + CXFA_Stroke stroke = strokes[nIndex]; + if (stroke.IsCorner()) { + CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; + CXFA_Stroke edgeAfter = strokes[nIndex + 1]; + if (stroke.IsInverted()) { + if (!stroke.SameStyles(edgeBefore)) { + halfBefore = edgeBefore.GetThickness() / 2; + } + if (!stroke.SameStyles(edgeAfter)) { + halfAfter = edgeAfter.GetThickness() / 2; + } + } + } else { + CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8]; + CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8]; + if (!bRound && !bInverted) { + { halfBefore = edgeBefore.GetThickness() / 2; } + { halfAfter = edgeAfter.GetThickness() / 2; } + } + } + offsetEX = 0.0f; + offsetEY = 0.0f; + if (bRound) { + sy = FX_PI / 2; + } + switch (nIndex) { + case 0: + case 1: + cp1 = rtWidget.TopLeft(); + cp2 = rtWidget.TopRight(); + if (nIndex == 0) { + cpStart.x = cp1.x - halfBefore; + cpStart.y = cp1.y + fRadius1, offsetY = -halfAfter; + } else { + cpStart.x = cp1.x + fRadius1 - halfBefore, cpStart.y = cp1.y, + offsetEX = halfAfter; + } + vx = 1, vy = 1; + nx = -1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI / 2 : FX_PI; + } else { + sx = 1, sy = 0; + } + break; + case 2: + case 3: + cp1 = rtWidget.TopRight(); + cp2 = rtWidget.BottomRight(); + if (nIndex == 2) { + cpStart.x = cp1.x - fRadius1, cpStart.y = cp1.y - halfBefore, + offsetX = halfAfter; + } else { + cpStart.x = cp1.x, cpStart.y = cp1.y + fRadius1 - halfBefore, + offsetEY = halfAfter; + } + vx = -1, vy = 1; + nx = 0, ny = -1; + if (bRound) { + sx = bInverted ? FX_PI : FX_PI * 3 / 2; + } else { + sx = 0, sy = 1; + } + break; + case 4: + case 5: + cp1 = rtWidget.BottomRight(); + cp2 = rtWidget.BottomLeft(); + if (nIndex == 4) { + cpStart.x = cp1.x + halfBefore, cpStart.y = cp1.y - fRadius1, + offsetY = halfAfter; + } else { + cpStart.x = cp1.x - fRadius1 + halfBefore, cpStart.y = cp1.y, + offsetEX = -halfAfter; + } + vx = -1, vy = -1; + nx = 1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI * 3 / 2 : 0; + } else { + sx = -1, sy = 0; + } + break; + case 6: + case 7: + cp1 = rtWidget.BottomLeft(); + cp2 = rtWidget.TopLeft(); + if (nIndex == 6) { + cpStart.x = cp1.x + fRadius1, cpStart.y = cp1.y + halfBefore, + offsetX = -halfAfter; + } else { + cpStart.x = cp1.x, cpStart.y = cp1.y - fRadius1 + halfBefore, + offsetEY = -halfAfter; + } + vx = 1, vy = -1; + nx = 0, ny = 1; + if (bRound) { + sx = bInverted ? 0 : FX_PI / 2; + } else { + sx = 0, sy = -1; + } + break; + } + if (bStart) { + path.MoveTo(cpStart.x, cpStart.y); + } + if (nIndex & 1) { + path.LineTo(cp2.x + fRadius2 * nx + offsetEX, + cp2.y + fRadius2 * ny + offsetEY); + return; + } + if (bRound) { + if (fRadius1 < 0) { + sx -= FX_PI; + } + if (bInverted) { + sy *= -1; + } + rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2, + fRadius1 * 2 * vx - offsetX * 2, + fRadius1 * 2 * vy - offsetY * 2); + rtRadius.Normalize(); + if (bInverted) { + rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); + } + path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx, + sy); + } else { + if (bInverted) { + cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; + } else { + cp = cp1; + } + path.LineTo(cp.x, cp.y); + path.LineTo(cp1.x + fRadius1 * sx + offsetX, + cp1.y + fRadius1 * sy + offsetY); + } +} +static void XFA_BOX_GetFillPath(CXFA_Box box, + const CXFA_StrokeArray& strokes, + CFX_RectF rtWidget, + CFX_Path& fillPath, + FX_WORD dwFlags) { + if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + CXFA_Edge edge = box.GetEdge(0); + FX_FLOAT fThickness = edge.GetThickness(); + if (fThickness < 0) { + fThickness = 0; + } + FX_FLOAT fHalf = fThickness / 2; + int32_t iHand = box.GetHand(); + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.Inflate(fHalf, fHalf); + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.Deflate(fHalf, fHalf); + } + XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags); + return; + } + FX_BOOL bSameStyles = TRUE; + int32_t i; + CXFA_Stroke stroke1 = strokes[0]; + for (i = 1; i < 8; i++) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2)) { + bSameStyles = FALSE; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + for (i = 2; i < 8; i += 2) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | + XFA_STROKE_SAMESTYLE_Corner)) { + bSameStyles = FALSE; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + if (stroke1.IsInverted()) { + bSameStyles = FALSE; + } + if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { + bSameStyles = FALSE; + } + } + } + if (bSameStyles) { + fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width, + rtWidget.height); + return; + } + FX_BOOL bInverted, bRound; + FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny; + CFX_PointF cp, cp1, cp2; + CFX_RectF rtRadius; + for (int32_t i = 0; i < 8; i += 2) { + CXFA_Corner corner1(strokes[i].GetNode()); + CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); + fRadius1 = corner1.GetRadius(); + fRadius2 = corner2.GetRadius(); + bInverted = corner1.IsInverted(); + bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; + if (bRound) { + sy = FX_PI / 2; + } + switch (i) { + case 0: + cp1 = rtWidget.TopLeft(); + cp2 = rtWidget.TopRight(); + vx = 1, vy = 1; + nx = -1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI / 2 : FX_PI; + } else { + sx = 1, sy = 0; + } + break; + case 2: + cp1 = rtWidget.TopRight(); + cp2 = rtWidget.BottomRight(); + vx = -1, vy = 1; + nx = 0, ny = -1; + if (bRound) { + sx = bInverted ? FX_PI : FX_PI * 3 / 2; + } else { + sx = 0, sy = 1; + } + break; + case 4: + cp1 = rtWidget.BottomRight(); + cp2 = rtWidget.BottomLeft(); + vx = -1, vy = -1; + nx = 1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI * 3 / 2 : 0; + } else { + sx = -1, sy = 0; + } + break; + case 6: + cp1 = rtWidget.BottomLeft(); + cp2 = rtWidget.TopLeft(); + vx = 1, vy = -1; + nx = 0, ny = 1; + if (bRound) { + sx = bInverted ? 0 : FX_PI / 2; + } else { + sx = 0, sy = -1; + } + break; + } + if (i == 0) { + fillPath.MoveTo(cp1.x, cp1.y + fRadius1); + } + if (bRound) { + if (fRadius1 < 0) { + sx -= FX_PI; + } + if (bInverted) { + sy *= -1; + } + rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); + rtRadius.Normalize(); + if (bInverted) { + rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); + } + fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, + rtRadius.height, sx, sy); + } else { + if (bInverted) { + cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; + } else { + cp = cp1; + } + fillPath.LineTo(cp.x, cp.y); + fillPath.LineTo(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy); + } + fillPath.LineTo(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny); + } +} +static void XFA_BOX_Fill_Radial(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart, crEnd; + crStart = fill.GetColor(); + int32_t iType = fill.GetRadial(crEnd); + CFX_Shading shading; + if (iType != XFA_ATTRIBUTEENUM_ToEdge) { + FX_ARGB temp = crEnd; + crEnd = crStart; + crStart = temp; + } + shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, + FXSYS_sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / + 2, + TRUE, TRUE, crStart, crEnd); + CFX_Color cr(&shading); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill_Pattern(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart, crEnd; + crStart = fill.GetColor(); + int32_t iType = fill.GetPattern(crEnd); + int32_t iHatch = FX_HATCHSTYLE_Cross; + switch (iType) { + case XFA_ATTRIBUTEENUM_CrossDiagonal: + iHatch = FX_HATCHSTYLE_DiagonalCross; + break; + case XFA_ATTRIBUTEENUM_DiagonalLeft: + iHatch = FX_HATCHSTYLE_ForwardDiagonal; + break; + case XFA_ATTRIBUTEENUM_DiagonalRight: + iHatch = FX_HATCHSTYLE_BackwardDiagonal; + break; + case XFA_ATTRIBUTEENUM_Horizontal: + iHatch = FX_HATCHSTYLE_Horizontal; + break; + case XFA_ATTRIBUTEENUM_Vertical: + iHatch = FX_HATCHSTYLE_Vertical; + break; + default: + break; + } + CFX_Pattern pattern; + pattern.Create(iHatch, crEnd, crStart); + CFX_Color cr(&pattern); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill_Linear(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart = fill.GetColor(); + FX_ARGB crEnd; + int32_t iType = fill.GetLinear(crEnd); + CFX_PointF ptStart; + CFX_PointF ptEnd; + switch (iType) { + case XFA_ATTRIBUTEENUM_ToRight: + ptStart = CFX_PointF(rtFill.left, rtFill.top); + ptEnd = CFX_PointF(rtFill.right(), rtFill.top); + break; + case XFA_ATTRIBUTEENUM_ToBottom: + ptStart = CFX_PointF(rtFill.left, rtFill.top); + ptEnd = CFX_PointF(rtFill.left, rtFill.bottom()); + break; + case XFA_ATTRIBUTEENUM_ToLeft: + ptStart = CFX_PointF(rtFill.right(), rtFill.top); + ptEnd = CFX_PointF(rtFill.left, rtFill.top); + break; + case XFA_ATTRIBUTEENUM_ToTop: + ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); + ptEnd = CFX_PointF(rtFill.left, rtFill.top); + break; + default: + break; + } + CFX_Shading shading; + shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); + CFX_Color cr(&shading); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill(CXFA_Box box, + const CXFA_StrokeArray& strokes, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags) { + CXFA_Fill fill = box.GetFill(); + if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { + return; + } + pGS->SaveGraphState(); + CFX_Path fillPath; + fillPath.Create(); + XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, + (dwFlags & XFA_DRAWBOX_ForceRound) != 0); + fillPath.Close(); + int32_t eType = fill.GetFillType(); + switch (eType) { + case XFA_ELEMENT_Radial: + XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix); + break; + case XFA_ELEMENT_Pattern: + XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix); + break; + case XFA_ELEMENT_Linear: + XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix); + break; + default: { + FX_ARGB cr; + if (eType == XFA_ELEMENT_Stipple) { + int32_t iRate = fill.GetStipple(cr); + if (iRate == 0) { + iRate = 100; + } + int32_t a = 0; + FX_COLORREF rgb; + ArgbDecode(cr, a, rgb); + cr = ArgbEncode(iRate * a / 100, rgb); + } else { + cr = fill.GetColor(); + } + CFX_Color fillColor(cr); + pGS->SetFillColor(&fillColor); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); + } break; + } + pGS->RestoreGraphState(); +} +static void XFA_BOX_StrokePath(CXFA_Stroke stroke, + CFX_Path* pPath, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix) { + if (!stroke || !stroke.IsVisible()) { + return; + } + FX_FLOAT fThickness = stroke.GetThickness(); + if (fThickness < 0.001f) { + return; + } + pGS->SaveGraphState(); + if (stroke.IsCorner() && fThickness > 2 * stroke.GetRadius()) { + fThickness = 2 * stroke.GetRadius(); + } + pGS->SetLineWidth(fThickness, TRUE); + pGS->SetLineCap(CFX_GraphStateData::LineCapButt); + XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(), + XFA_ATTRIBUTEENUM_Butt); + CFX_Color fxColor(stroke.GetColor()); + pGS->SetStrokeColor(&fxColor); + pGS->StrokePath(pPath, pMatrix); + pGS->RestoreGraphState(); +} +static void XFA_BOX_StrokeArc(CXFA_Box box, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags) { + CXFA_Edge edge = box.GetEdge(0); + if (!edge || !edge.IsVisible()) { + return; + } + FX_BOOL bVisible = FALSE; + FX_FLOAT fThickness = 0; + int32_t i3DType = box.Get3DStyle(bVisible, fThickness); + if (i3DType) { + if (bVisible && fThickness >= 0.001f) { + dwFlags |= XFA_DRAWBOX_Lowered3D; + } + } + FX_FLOAT fHalf = edge.GetThickness() / 2; + if (fHalf < 0) { + fHalf = 0; + } + int32_t iHand = box.GetHand(); + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.Inflate(fHalf, fHalf); + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.Deflate(fHalf, fHalf); + } + if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 || + (dwFlags & XFA_DRAWBOX_Lowered3D) == 0) { + if (fHalf < 0.001f) { + return; + } + CFX_Path arcPath; + arcPath.Create(); + XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); + XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); + return; + } + pGS->SaveGraphState(); + pGS->SetLineWidth(fHalf); + FX_FLOAT a, b; + a = rtWidget.width / 2.0f; + b = rtWidget.height / 2.0f; + if (dwFlags & XFA_DRAWBOX_ForceRound) { + a = b = std::min(a, b); + } + CFX_PointF center = rtWidget.Center(); + rtWidget.left = center.x - a; + rtWidget.top = center.y - b; + rtWidget.width = a + a; + rtWidget.height = b + b; + FX_FLOAT startAngle = 0, sweepAngle = 360; + startAngle = startAngle * FX_PI / 180.0f; + sweepAngle = -sweepAngle * FX_PI / 180.0f; + CFX_Path arcPath; + arcPath.Create(); + arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, + 3.0f * FX_PI / 4.0f, FX_PI); + CFX_Color cr(0xFF808080); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + arcPath.Clear(); + arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, + -1.0f * FX_PI / 4.0f, FX_PI); + cr.Set(0xFFFFFFFF); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + rtWidget.Deflate(fHalf, fHalf); + arcPath.Clear(); + arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, + 3.0f * FX_PI / 4.0f, FX_PI); + cr.Set(0xFF404040); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + arcPath.Clear(); + arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, + -1.0f * FX_PI / 4.0f, FX_PI); + cr.Set(0xFFC0C0C0); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + pGS->RestoreGraphState(); +} +static void XFA_Draw3DRect(CFX_Graphics* pGraphic, + const CFX_RectF& rt, + FX_FLOAT fLineWidth, + CFX_Matrix* pMatrix, + FX_ARGB argbTopLeft, + FX_ARGB argbBottomRight) { + CFX_Color crLT(argbTopLeft); + pGraphic->SetFillColor(&crLT); + FX_FLOAT fBottom = rt.bottom(); + FX_FLOAT fRight = rt.right(); + CFX_Path pathLT; + pathLT.Create(); + pathLT.MoveTo(rt.left, fBottom); + pathLT.LineTo(rt.left, rt.top); + pathLT.LineTo(fRight, rt.top); + pathLT.LineTo(fRight - fLineWidth, rt.top + fLineWidth); + pathLT.LineTo(rt.left + fLineWidth, rt.top + fLineWidth); + pathLT.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); + pathLT.LineTo(rt.left, fBottom); + pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + CFX_Color crRB(argbBottomRight); + pGraphic->SetFillColor(&crRB); + CFX_Path pathRB; + pathRB.Create(); + pathRB.MoveTo(fRight, rt.top); + pathRB.LineTo(fRight, fBottom); + pathRB.LineTo(rt.left, fBottom); + pathRB.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); + pathRB.LineTo(fRight - fLineWidth, fBottom - fLineWidth); + pathRB.LineTo(fRight - fLineWidth, rt.top + fLineWidth); + pathRB.LineTo(fRight, rt.top); + pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS, + CFX_RectF rt, + FX_FLOAT fThickness, + CFX_Matrix* pMatrix) { + FX_FLOAT fHalfWidth = fThickness / 2.0f; + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + CFX_Color cr(0xFF000000); + pGS->SetFillColor(&cr); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left, rt.top, rt.width, rt.height); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF808080, 0xFFC0C0C0); +} +static void XFA_BOX_Stroke_3DRect_Raised(CFX_Graphics* pGS, + CFX_RectF rt, + FX_FLOAT fThickness, + CFX_Matrix* pMatrix) { + FX_FLOAT fHalfWidth = fThickness / 2.0f; + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + CFX_Color cr(0xFF000000); + pGS->SetFillColor(&cr); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left, rt.top, rt.width, rt.height); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); +} +static void XFA_BOX_Stroke_3DRect_Etched(CFX_Graphics* pGS, + CFX_RectF rt, + FX_FLOAT fThickness, + CFX_Matrix* pMatrix) { + FX_FLOAT fHalfWidth = fThickness / 2.0f; + XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFFFFFFFF); + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); +} +static void XFA_BOX_Stroke_3DRect_Embossed(CFX_Graphics* pGS, + CFX_RectF rt, + FX_FLOAT fThickness, + CFX_Matrix* pMatrix) { + FX_FLOAT fHalfWidth = fThickness / 2.0f; + XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); +} +static void XFA_BOX_Stroke_Rect(CXFA_Box box, + const CXFA_StrokeArray& strokes, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix) { + FX_BOOL bVisible = FALSE; + FX_FLOAT fThickness = 0; + int32_t i3DType = box.Get3DStyle(bVisible, fThickness); + if (i3DType) { + if (!bVisible || fThickness < 0.001f) { + return; + } + switch (i3DType) { + case XFA_ATTRIBUTEENUM_Lowered: + XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Raised: + XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Etched: + XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Embossed: + XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, pMatrix); + break; + } + return; + } + FX_BOOL bClose = FALSE; + FX_BOOL bSameStyles = TRUE; + int32_t i; + CXFA_Stroke stroke1 = strokes[0]; + for (i = 1; i < 8; i++) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2)) { + bSameStyles = FALSE; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + bClose = TRUE; + for (i = 2; i < 8; i += 2) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | + XFA_STROKE_SAMESTYLE_Corner)) { + bSameStyles = FALSE; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + if (stroke1.IsInverted()) { + bSameStyles = FALSE; + } + if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { + bSameStyles = FALSE; + } + } + } + FX_BOOL bStart = TRUE; + CFX_Path path; + path.Create(); + for (i = 0; i < 8; i++) { + CXFA_Stroke stroke1 = strokes[i]; + if ((i % 1) == 0 && stroke1.GetRadius() < 0) { + FX_BOOL bEmpty = path.IsEmpty(); + if (!bEmpty) { + XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); + path.Clear(); + } + bStart = TRUE; + continue; + } + XFA_BOX_GetPath(box, strokes, rtWidget, path, i, bStart, !bSameStyles); + CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; + bStart = !stroke1.SameStyles(stroke2); + if (bStart) { + XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); + path.Clear(); + } + } + FX_BOOL bEmpty = path.IsEmpty(); + if (!bEmpty) { + if (bClose) { + path.Close(); + } + XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); + } +} +static void XFA_BOX_Stroke(CXFA_Box box, + const CXFA_StrokeArray& strokes, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags) { + if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); + return; + } + bool bVisible = false; + for (int32_t j = 0; j < 4; j++) { + if (strokes[j * 2 + 1].IsVisible()) { + bVisible = true; + break; + } + } + if (!bVisible) { + return; + } + for (int32_t i = 1; i < 8; i += 2) { + CXFA_Edge edge(strokes[i].GetNode()); + FX_FLOAT fThickness = edge.GetThickness(); + if (fThickness < 0) { + fThickness = 0; + } + FX_FLOAT fHalf = fThickness / 2; + int32_t iHand = box.GetHand(); + switch (i) { + case 1: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.top -= fHalf; + rtWidget.height += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.top += fHalf; + rtWidget.height -= fHalf; + } + break; + case 3: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.width += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.width -= fHalf; + } + break; + case 5: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.height += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.height -= fHalf; + } + break; + case 7: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.left -= fHalf; + rtWidget.width += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.left += fHalf; + rtWidget.width -= fHalf; + } + break; + } + } + XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix); +} +void XFA_DrawBox(CXFA_Box box, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags) { + if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { + return; + } + int32_t iType = box.GetClassID(); + if (iType != XFA_ELEMENT_Arc && iType != XFA_ELEMENT_Border && + iType != XFA_ELEMENT_Rectangle) { + return; + } + CXFA_StrokeArray strokes; + if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { + box.GetStrokes(strokes); + } + XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); + XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); +} diff --git a/xfa/fxfa/app/xfa_ffwidget.h b/xfa/fxfa/app/xfa_ffwidget.h new file mode 100644 index 0000000000..3782e3b8a6 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidget.h @@ -0,0 +1,187 @@ +// 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_APP_XFA_FFWIDGET_H_ +#define XFA_FXFA_APP_XFA_FFWIDGET_H_ + +#include <vector> + +#include "core/include/fxcodec/fx_codec_def.h" +#include "core/include/fxge/fx_ge.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; + +inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) { + return fPx * 72.0f / fDpi; +} +#define XFA_FLOAT_PERCISION 0.001f +enum XFA_WIDGETITEM { + XFA_WIDGETITEM_Parent, + XFA_WIDGETITEM_FirstChild, + XFA_WIDGETITEM_NextSibling, + XFA_WIDGETITEM_PrevSibling, +}; +class CXFA_CalcData { + public: + CXFA_CalcData() : m_iRefCount(0) {} + ~CXFA_CalcData() { m_Globals.RemoveAll(); } + CFX_PtrArray m_Globals; + int32_t m_iRefCount; +}; +class CXFA_FFWidget : public IXFA_Widget, + public CFX_PrivateData, + public CXFA_ContentLayoutItem { + public: + CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); + virtual ~CXFA_FFWidget(); + IXFA_PageView* GetPageView(); + void SetPageView(IXFA_PageView* pPageView); + void GetWidgetRect(CFX_RectF& rtWidget); + CFX_RectF ReCacheWidgetRect(); + FX_DWORD GetStatus(); + void ModifyStatus(FX_DWORD dwAdded, FX_DWORD dwRemoved); + virtual FX_BOOL GetBBox(CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus = FALSE); + CXFA_WidgetAcc* GetDataAcc(); + FX_BOOL GetToolTip(CFX_WideString& wsToolTip); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_DWORD dwStatus = 0, + int32_t iRotate = 0); + + virtual FX_BOOL IsLoaded(); + virtual FX_BOOL LoadWidget(); + virtual void UnloadWidget(); + virtual FX_BOOL PerformLayout(); + virtual FX_BOOL UpdateFWLData(); + virtual void UpdateWidgetProperty(); + virtual FX_BOOL OnMouseEnter(); + virtual FX_BOOL OnMouseExit(); + virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); + + virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); + virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); + virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); + virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); + virtual FX_DWORD 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; } + virtual FX_BOOL Undo() { return FALSE; } + virtual FX_BOOL Redo() { return FALSE; } + virtual FX_BOOL CanCopy() { return FALSE; } + virtual FX_BOOL CanCut() { return FALSE; } + virtual FX_BOOL CanPaste() { return FALSE; } + virtual FX_BOOL CanSelectAll() { return FALSE; } + virtual FX_BOOL CanDelete() { return CanCut(); } + virtual FX_BOOL CanDeSelect() { return CanCopy(); } + virtual FX_BOOL Copy(CFX_WideString& wsCopy) { return FALSE; } + virtual FX_BOOL Cut(CFX_WideString& wsCut) { return FALSE; } + virtual FX_BOOL Paste(const CFX_WideString& wsPaste) { return FALSE; } + virtual FX_BOOL SelectAll() { return FALSE; } + virtual FX_BOOL Delete() { return FALSE; } + virtual FX_BOOL DeSelect() { return FALSE; } + virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) { + return FALSE; + } + virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + return FALSE; + } + CXFA_FFDocView* GetDocView(); + void SetDocView(CXFA_FFDocView* pDocView) { m_pDocView = pDocView; } + CXFA_FFDoc* GetDoc(); + CXFA_FFApp* GetApp(); + IXFA_AppProvider* GetAppProvider(); + void InvalidateWidget(const CFX_RectF* pRect = NULL); + void AddInvalidateRect(const CFX_RectF* pRect = NULL); + FX_BOOL GetCaptionText(CFX_WideString& wsCap); + FX_BOOL IsFocused(); + void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy); + void GetRotateMatrix(CFX_Matrix& mt); + FX_BOOL IsLayoutRectEmpty(); + CXFA_FFWidget* GetParent(); + FX_BOOL IsAncestorOf(CXFA_FFWidget* pWidget); + + protected: + virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + void DrawBorder(CFX_Graphics* pGS, + CXFA_Box box, + const CFX_RectF& rtBorder, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags = 0); + void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); + void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); + void GetRectWithoutRotate(CFX_RectF& rtWidget); + FX_BOOL IsMatchVisibleStatus(FX_DWORD dwStatus); + + void EventKillFocus(); + FX_BOOL IsButtonDown(); + void SetButtonDown(FX_BOOL bSet); + CXFA_FFDocView* m_pDocView; + CXFA_FFPageView* m_pPageView; + CXFA_WidgetAcc* m_pDataAcc; + CFX_RectF m_rtWidget; +}; +int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, + int32_t iStrokeType, + int32_t iCapType); +CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); +void XFA_DrawImage(CFX_Graphics* pGS, + const CFX_RectF& rtImage, + CFX_Matrix* pMatrix, + CFX_DIBitmap* pDIBitmap, + int32_t iAspect, + int32_t iImageXDpi, + int32_t iImageYDpi, + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); +CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + FX_BOOL& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi); +CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi); +FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType); +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 +#define XFA_DRAWBOX_Lowered3D 2 +void XFA_DrawBox(CXFA_Box box, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + FX_DWORD dwFlags = 0); + +#endif // XFA_FXFA_APP_XFA_FFWIDGET_H_ diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp new file mode 100644 index 0000000000..500235d4a5 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -0,0 +1,1714 @@ +// 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/fxfa/app/xfa_ffwidgetacc.h" + +#include <algorithm> + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffpageview.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fontmgr.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxfa/parser/xfa_localevalue.h" +#include "xfa/fxfa/parser/xfa_script.h" + +static void XFA_FFDeleteCalcData(void* pData) { + if (pData) { + delete ((CXFA_CalcData*)pData); + } +} +static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = { + XFA_FFDeleteCalcData, NULL}; +class CXFA_WidgetLayoutData { + public: + CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {} + virtual ~CXFA_WidgetLayoutData() {} + virtual void Release() { delete this; } + FX_FLOAT m_fWidgetHeight; +}; +class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { + public: + CXFA_TextLayoutData() : m_pTextLayout(NULL), m_pTextProvider(NULL) {} + ~CXFA_TextLayoutData() { + if (m_pTextLayout) { + delete m_pTextLayout; + } + m_pTextLayout = NULL; + if (m_pTextProvider) { + delete m_pTextProvider; + } + m_pTextProvider = NULL; + } + void LoadText(CXFA_WidgetAcc* pAcc) { + if (m_pTextLayout) + return; + + m_pTextProvider = new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Text); + m_pTextLayout = new CXFA_TextLayout(m_pTextProvider); + } + CXFA_TextLayout* m_pTextLayout; + CXFA_TextProvider* m_pTextProvider; +}; +class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { + public: + CXFA_ImageLayoutData() + : m_pDIBitmap(NULL), + m_bNamedImage(FALSE), + m_iImageXDpi(0), + m_iImageYDpi(0) {} + + ~CXFA_ImageLayoutData() { + if (m_pDIBitmap && !m_bNamedImage) { + delete m_pDIBitmap; + } + m_pDIBitmap = NULL; + } + + FX_BOOL LoadImageData(CXFA_WidgetAcc* pAcc) { + if (m_pDIBitmap) { + return TRUE; + } + CXFA_Value value = pAcc->GetFormValue(); + if (!value) { + return FALSE; + } + CXFA_Image imageObj = value.GetImage(); + if (!imageObj) { + return FALSE; + } + CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); + pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + m_iImageXDpi, m_iImageYDpi)); + return m_pDIBitmap != NULL; + } + + CFX_DIBitmap* m_pDIBitmap; + FX_BOOL m_bNamedImage; + 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; + } + } + FX_BOOL LoadCaption(CXFA_WidgetAcc* pAcc) { + 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; + } + CXFA_TextLayout* m_pCapTextLayout; + CXFA_TextProvider* m_pCapTextProvider; + IFDE_TextOut* m_pTextOut; + CFX_FloatArray* m_pFieldSplitArray; +}; +class CXFA_TextEditData : public CXFA_FieldLayoutData { + public: +}; +class CXFA_ImageEditData : public CXFA_FieldLayoutData { + public: + CXFA_ImageEditData() + : m_pDIBitmap(NULL), + m_bNamedImage(FALSE), + m_iImageXDpi(0), + m_iImageYDpi(0) {} + + ~CXFA_ImageEditData() { + if (m_pDIBitmap && !m_bNamedImage) { + delete m_pDIBitmap; + } + m_pDIBitmap = NULL; + } + FX_BOOL LoadImageData(CXFA_WidgetAcc* pAcc) { + if (m_pDIBitmap) { + return TRUE; + } + CXFA_Value value = pAcc->GetFormValue(); + if (!value) { + return FALSE; + } + CXFA_Image imageObj = value.GetImage(); + CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); + pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + m_iImageXDpi, m_iImageYDpi)); + return m_pDIBitmap != NULL; + } + CFX_DIBitmap* m_pDIBitmap; + FX_BOOL m_bNamedImage; + int32_t m_iImageXDpi; + int32_t m_iImageYDpi; +}; +CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode) + : CXFA_WidgetData(pNode), + m_pDocView(pDocView), + m_pLayoutData(NULL), + m_nRecursionDepth(0) {} +CXFA_WidgetAcc::~CXFA_WidgetAcc() { + if (m_pLayoutData) { + m_pLayoutData->Release(); + m_pLayoutData = NULL; + } +} +FX_BOOL CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) { + if (iNameType == 0) { + m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); + return !wsName.IsEmpty(); + } + 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())) { + wsName.Delete(0, wsPre.GetLength()); + } + } + return TRUE; +} +CXFA_Node* CXFA_WidgetAcc::GetDatasets() { + return m_pNode->GetBindData(); +} +FX_BOOL CXFA_WidgetAcc::ProcessValueChanged() { + m_pDocView->AddValidateWidget(this); + m_pDocView->AddCalculateWidgetAcc(this); + m_pDocView->RunCalculateWidgets(); + m_pDocView->RunValidate(); + return TRUE; +} +void CXFA_WidgetAcc::ResetData() { + CFX_WideString wsValue; + XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); + switch (eUIType) { + case XFA_ELEMENT_ImageEdit: { + CXFA_Value imageValue = GetDefaultValue(); + CXFA_Image image = imageValue.GetImage(); + CFX_WideString wsContentType, wsHref; + if (image) { + image.GetContent(wsValue); + image.GetContentType(wsContentType); + image.GetHref(wsHref); + } + SetImageEdit(wsContentType, wsHref, wsValue); + } break; + case XFA_ELEMENT_ExclGroup: { + CXFA_Node* pNextChild = m_pNode->GetNodeItem( + XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); + while (pNextChild) { + CXFA_Node* pChild = pNextChild; + CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); + if (!pAcc) { + continue; + } + CXFA_Value defValue(NULL); + if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) { + defValue.GetChildValueContent(wsValue); + SetValue(wsValue, XFA_VALUEPICTURE_Raw); + pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); + } else { + CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); + if (!pItems) { + continue; + } + CFX_WideString itemText; + if (pItems->CountChildren(XFA_ELEMENT_UNKNOWN) > 1) { + itemText = pItems->GetChild(1, XFA_ELEMENT_UNKNOWN)->GetContent(); + } + pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw); + } + pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_OBJECTTYPE_ContainerNode); + } + } break; + case XFA_ELEMENT_ChoiceList: + ClearAllSelections(); + default: + if (CXFA_Value defValue = GetDefaultValue()) { + defValue.GetChildValueContent(wsValue); + } + SetValue(wsValue, XFA_VALUEPICTURE_Raw); + break; + } +} +void CXFA_WidgetAcc::SetImageEdit(const CFX_WideStringC& wsContentType, + const CFX_WideStringC& wsHref, + const CFX_WideStringC& wsData) { + CXFA_Image image = GetFormValue().GetImage(); + if (image) { + image.SetContentType(wsContentType); + image.SetHref(wsHref); + } + CFX_WideString wsFormatValue(wsData); + GetFormatDataValue(wsData, wsFormatValue); + m_pNode->SetContent(wsData, wsFormatValue, TRUE); + CXFA_Node* pBind = GetDatasets(); + if (!pBind) { + image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); + return; + } + pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); + CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pHrefNode) { + pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); + } else { + IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + FXSYS_assert(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); + ((IFDE_XMLElement*)pXMLNode)->SetString(FX_WSTRC(L"href"), wsHref); + } +} + +CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { + CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) { + return NULL; + } + return (CXFA_WidgetAcc*)pExcl->GetWidgetData(); +} +CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { + return m_pDocView; +} +CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { + return (CXFA_FFDoc*)m_pDocView->GetDoc(); +} +CXFA_FFApp* CXFA_WidgetAcc::GetApp() { + return GetDoc()->GetApp(); +} +IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { + return GetApp()->GetAppProvider(); +} +int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, + CXFA_EventParam* pEventParam) { + if (GetClassID() == XFA_ELEMENT_Draw) { + return XFA_EVENTERROR_NotExist; + } + int32_t iRet = XFA_EVENTERROR_NotExist; + CXFA_NodeArray eventArray; + int32_t iCounts = + GetEventByActivity(iActivity, eventArray, pEventParam->m_bIsFormReady); + for (int32_t i = 0; i < iCounts; i++) { + CXFA_Event event(eventArray[i]); + int32_t result = ProcessEvent(event, pEventParam); + if (i == 0) { + iRet = result; + } else if (result == XFA_EVENTERROR_Sucess) { + iRet = result; + } + } + return iRet; +} +int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event, + CXFA_EventParam* pEventParam) { + if (!event) { + return XFA_EVENTERROR_NotExist; + } + switch (event.GetEventType()) { + case XFA_ELEMENT_Execute: + break; + case XFA_ELEMENT_Script: { + CXFA_Script script = event.GetScript(); + return ExecuteScript(script, pEventParam); + } break; + case XFA_ELEMENT_SignData: + break; + case XFA_ELEMENT_Submit: { + CXFA_Submit submit = event.GetSubmit(); + return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); + } + default: + break; + } + return XFA_EVENTERROR_NotExist; +} +int32_t CXFA_WidgetAcc::ProcessCalculate() { + if (GetClassID() == XFA_ELEMENT_Draw) { + return XFA_EVENTERROR_NotExist; + } + CXFA_Calculate calc = GetCalculate(); + if (!calc) { + return XFA_EVENTERROR_NotExist; + } + if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return XFA_EVENTERROR_Disabled; + } + CXFA_EventParam EventParam; + EventParam.m_eType = XFA_EVENT_Calculate; + CXFA_Script script = calc.GetScript(); + int32_t iRet = ExecuteScript(script, &EventParam); + if (iRet == XFA_EVENTERROR_Sucess) { + 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_Sucess; + } + } + return iRet; +} +void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, + int32_t iRet, + FXJSE_HVALUE pRetValue, + FX_BOOL bVersionFlag) { + if (iRet == XFA_EVENTERROR_Sucess && pRetValue) { + if (FXJSE_Value_IsBoolean(pRetValue) && !FXJSE_Value_ToBoolean(pRetValue)) { + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) { + return; + } + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); + CFX_WideString wsScriptMsg; + validate.GetScriptMessageText(wsScriptMsg); + int32_t eScriptTest = validate.GetScriptTest(); + if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { + if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return; + } + if (wsScriptMsg.IsEmpty()) { + GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); + } + if (bVersionFlag) { + pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_OK); + return; + } + if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); + } + } else { + if (wsScriptMsg.IsEmpty()) { + GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); + } + pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + } + } + } +} +int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, + FX_BOOL bVersionFlag) { + CFX_WideString wsRawValue = GetRawValue(); + if (!wsRawValue.IsEmpty()) { + CFX_WideString wsPicture; + validate.GetPicture(wsPicture); + if (wsPicture.IsEmpty()) { + return XFA_EVENTERROR_NotExist; + } + IFX_Locale* pLocale = GetLocal(); + if (!pLocale) { + return XFA_EVENTERROR_NotExist; + } + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this); + if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) { + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) { + return XFA_EVENTERROR_NotExist; + } + CFX_WideString wsFormatMsg; + validate.GetFormatMessageText(wsFormatMsg); + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); + int32_t eFormatTest = validate.GetFormatTest(); + if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { + if (wsFormatMsg.IsEmpty()) { + GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); + } + pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + return XFA_EVENTERROR_Sucess; + } + if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return XFA_EVENTERROR_NotExist; + } + if (wsFormatMsg.IsEmpty()) { + GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); + } + if (bVersionFlag) { + pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_OK); + return XFA_EVENTERROR_Sucess; + } + if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); + } + return XFA_EVENTERROR_Sucess; + } + } + return XFA_EVENTERROR_NotExist; +} +int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, + int32_t iFlags, + FX_BOOL bVersionFlag) { + CFX_WideString wsValue; + GetValue(wsValue, XFA_VALUEPICTURE_Raw); + if (!wsValue.IsEmpty()) { + return XFA_EVENTERROR_Sucess; + } + if (m_bIsNull && (m_bPreNull == m_bIsNull)) { + return XFA_EVENTERROR_Sucess; + } + int32_t eNullTest = validate.GetNullTest(); + CFX_WideString wsNullMsg; + validate.GetNullMessageText(wsNullMsg); + if (iFlags & 0x01) { + int32_t iRet = XFA_EVENTERROR_Sucess; + if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { + iRet = XFA_EVENTERROR_Error; + } + if (!wsNullMsg.IsEmpty()) { + if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { + m_pDocView->m_arrNullTestMsg.Add(wsNullMsg); + return XFA_EVENTERROR_Error; + } + return XFA_EVENTERROR_Sucess; + } + return iRet; + } + if (wsNullMsg.IsEmpty() && bVersionFlag && + eNullTest != XFA_ATTRIBUTEENUM_Disabled) { + return XFA_EVENTERROR_Error; + } + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) { + return XFA_EVENTERROR_NotExist; + } + CFX_WideString wsCaptionName; + CFX_WideString wsTitle; + pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); + switch (eNullTest) { + case XFA_ATTRIBUTEENUM_Error: { + if (wsNullMsg.IsEmpty()) { + GetValidateCaptionName(wsCaptionName, bVersionFlag); + CFX_WideString wsError; + pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); + wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); + } + pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); + return XFA_EVENTERROR_Error; + } + case XFA_ATTRIBUTEENUM_Warning: { + if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return TRUE; + } + if (wsNullMsg.IsEmpty()) { + GetValidateCaptionName(wsCaptionName, bVersionFlag); + CFX_WideString wsWarning; + pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); + wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, + (const FX_WCHAR*)wsCaptionName); + } + if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); + } + return XFA_EVENTERROR_Error; + } + case XFA_ATTRIBUTEENUM_Disabled: + default: + break; + } + return XFA_EVENTERROR_Sucess; +} +void CXFA_WidgetAcc::GetValidateCaptionName(CFX_WideString& wsCaptionName, + FX_BOOL bVersionFlag) { + if (!bVersionFlag) { + CXFA_Caption caption = GetCaption(); + if (caption) { + CXFA_Value capValue = caption.GetValue(); + if (capValue) { + CXFA_Text capText = capValue.GetText(); + if (capText) { + capText.GetContent(wsCaptionName); + } + } + } + } + if (wsCaptionName.IsEmpty()) { + GetName(wsCaptionName); + } +} +void CXFA_WidgetAcc::GetValidateMessage(IXFA_AppProvider* pAppProvider, + CFX_WideString& wsMessage, + FX_BOOL bError, + FX_BOOL bVersionFlag) { + CFX_WideString wsCaptionName; + GetValidateCaptionName(wsCaptionName, bVersionFlag); + CFX_WideString wsError; + if (bVersionFlag) { + pAppProvider->LoadString(XFA_IDS_ValidateFailed, wsError); + wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName); + return; + } + if (bError) { + pAppProvider->LoadString(XFA_IDS_ValidateError, wsError); + wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName); + return; + } + CFX_WideString wsWarning; + pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning); + wsMessage.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, + (const FX_WCHAR*)wsCaptionName); +} +int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { + if (GetClassID() == XFA_ELEMENT_Draw) { + return XFA_EVENTERROR_NotExist; + } + CXFA_Validate validate = GetValidate(); + if (!validate) { + return XFA_EVENTERROR_NotExist; + } + FX_BOOL bInitDoc = validate.GetNode()->HasFlag(XFA_NODEFLAG_NeedsInitApp); + FX_BOOL bStatus = + m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; + int32_t iFormat = 0; + FXJSE_HVALUE pRetValue = NULL; + int32_t iRet = XFA_EVENTERROR_NotExist; + CXFA_Script script = validate.GetScript(); + if (script) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Validate; + eParam.m_pTarget = this; + iRet = ExecuteScript(script, &eParam, + ((bInitDoc || bStatus) && GetRawValue().IsEmpty()) + ? nullptr + : &pRetValue); + } + XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + FX_BOOL bVersionFlag = FALSE; + if (version < XFA_VERSION_208) { + bVersionFlag = TRUE; + } + if (bInitDoc) { + validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, FALSE, FALSE); + } else { + iFormat = ProcessFormatTestValidate(validate, bVersionFlag); + if (!bVersionFlag) { + bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); + } + iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); + } + if (iFormat != XFA_EVENTERROR_Sucess) { + ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag); + } + if (pRetValue) { + FXJSE_Value_Release(pRetValue); + } + return iRet | iFormat; +} +int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script, + CXFA_EventParam* pEventParam, + FXJSE_HVALUE* pRetValue) { + static const uint32_t MAX_RECURSION_DEPTH = 2; + if (m_nRecursionDepth > MAX_RECURSION_DEPTH) + return XFA_EVENTERROR_Sucess; + FXSYS_assert(pEventParam); + if (!script) { + return XFA_EVENTERROR_NotExist; + } + if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server) { + return XFA_EVENTERROR_Disabled; + } + CFX_WideString wsExpression; + script.GetExpression(wsExpression); + if (wsExpression.IsEmpty()) { + return XFA_EVENTERROR_NotExist; + } + XFA_SCRIPTTYPE eScriptType = script.GetContentType(); + if (eScriptType == XFA_SCRIPTTYPE_Unkown) { + return XFA_EVENTERROR_Sucess; + } + CXFA_FFDoc* pDoc = GetDoc(); + IXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); + pContext->SetEventParam(*pEventParam); + pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); + CXFA_NodeArray refNodes; + if (pEventParam->m_eType == XFA_EVENT_InitCalculate || + pEventParam->m_eType == XFA_EVENT_Calculate) { + pContext->SetNodesOfRunScript(&refNodes); + } + FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); + ++m_nRecursionDepth; + FX_BOOL bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, + wsExpression, hRetValue, m_pNode); + --m_nRecursionDepth; + int32_t iRet = XFA_EVENTERROR_Error; + if (bRet) { + iRet = XFA_EVENTERROR_Sucess; + if (pEventParam->m_eType == XFA_EVENT_Calculate || + pEventParam->m_eType == XFA_EVENT_InitCalculate) { + if (!FXJSE_Value_IsUndefined(hRetValue)) { + if (!FXJSE_Value_IsNull(hRetValue)) { + CFX_ByteString bsString; + FXJSE_Value_ToUTF8String(hRetValue, bsString); + pEventParam->m_wsResult = + CFX_WideString::FromUTF8(bsString, bsString.GetLength()); + } + iRet = XFA_EVENTERROR_Sucess; + } else { + iRet = XFA_EVENTERROR_Error; + } + if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { + if ((iRet == XFA_EVENTERROR_Sucess) && + (GetRawValue() != pEventParam->m_wsResult)) { + SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); + m_pDocView->AddValidateWidget(this); + } + } + int32_t iRefs = refNodes.GetSize(); + for (int32_t r = 0; r < iRefs; r++) { + CXFA_WidgetAcc* pRefAcc = (CXFA_WidgetAcc*)refNodes[r]->GetWidgetData(); + if (pRefAcc && pRefAcc == this) { + continue; + } + CXFA_Node* pRefNode = refNodes[r]; + CXFA_CalcData* pGlobalData = + (CXFA_CalcData*)pRefNode->GetUserData(XFA_CalcData); + if (!pGlobalData) { + pGlobalData = new CXFA_CalcData; + pRefNode->SetUserData(XFA_CalcData, pGlobalData, + &gs_XFADeleteCalcData); + } + if (pGlobalData->m_Globals.Find(this) < 0) { + pGlobalData->m_Globals.Add(this); + } + } + } + } + if (pRetValue) { + *pRetValue = hRetValue; + } else { + FXJSE_Value_Release(hRetValue); + } + pContext->SetNodesOfRunScript(NULL); + return iRet; +} +CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) { + CXFA_LayoutItem* pLayout = nullptr; + if (pWidget) { + pLayout = pWidget->GetNext(); + } else { + pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode); + } + return static_cast<CXFA_FFWidget*>(pLayout); +} +void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) { + CXFA_FFWidget* pWidget = NULL; + while ((pWidget = GetNextWidget(pWidget))) { + if (pWidget == pExcept || !pWidget->IsLoaded() || + (GetUIType() != XFA_ELEMENT_CheckButton && pWidget->IsFocused())) { + continue; + } + pWidget->UpdateFWLData(); + pWidget->AddInvalidateRect(); + } +} +void CXFA_WidgetAcc::NotifyEvent(FX_DWORD 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) { + return; + } + LoadCaption(); + XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); + int32_t iCapPlacement = caption.GetPlacementType(); + FX_FLOAT fCapReserve = caption.GetReserve(); + const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; + const bool bReserveExit = fCapReserve > 0.01; + CXFA_TextLayout* pCapTextLayout = + ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout; + if (pCapTextLayout) { + if (!bVert && eUIType != XFA_ELEMENT_Button) { + szCap.x = fCapReserve; + } + CFX_SizeF minSize; + pCapTextLayout->CalcSize(minSize, szCap, szCap); + if (bReserveExit) { + bVert ? szCap.y = fCapReserve : szCap.x = fCapReserve; + } + } else { + FX_FLOAT fFontSize = 10.0f; + if (CXFA_Font font = caption.GetFont()) { + fFontSize = font.GetFontSize(); + } else if (CXFA_Font widgetfont = GetFont()) { + fFontSize = widgetfont.GetFontSize(); + } + if (bVert) { + szCap.y = fCapReserve > 0 ? fCapReserve : fFontSize; + } else { + szCap.x = fCapReserve > 0 ? fCapReserve : 0; + szCap.y = fFontSize; + } + } + if (CXFA_Margin mgCap = caption.GetMargin()) { + FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; + mgCap.GetLeftInset(fLeftInset); + mgCap.GetTopInset(fTopInset); + mgCap.GetRightInset(fRightInset); + mgCap.GetBottomInset(fBottomInset); + if (bReserveExit) { + bVert ? (szCap.x += fLeftInset + fRightInset) + : (szCap.y += fTopInset + fBottomInset); + } else { + szCap.x += fLeftInset + fRightInset; + szCap.y += fTopInset + fBottomInset; + } + } +} +FX_BOOL CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { + CFX_SizeF szCap; + CalcCaptionSize(szCap); + CFX_RectF rtUIMargin; + GetUIMargin(rtUIMargin); + size.x += rtUIMargin.left + rtUIMargin.width; + size.y += rtUIMargin.top + rtUIMargin.height; + if (szCap.x > 0 && szCap.y > 0) { + int32_t iCapPlacement = GetCaption().GetPlacementType(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.x += szCap.x; + size.y = std::max(size.y, szCap.y); + } break; + case XFA_ATTRIBUTEENUM_Top: + case XFA_ATTRIBUTEENUM_Bottom: { + size.y += szCap.y; + size.x = std::max(size.x, szCap.x); + } + default: + break; + } + } + return CalculateWidgetAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetTopInset(fTopInset); + mgWidget.GetRightInset(fRightInset); + mgWidget.GetBottomInset(fBottomInset); + size.x += fLeftInset + fRightInset; + size.y += fTopInset + fBottomInset; + } + CXFA_Para para = GetPara(); + if (para) { + size.x += para.GetMarginLeft(); + size.x += para.GetTextIndent(); + } + FX_FLOAT fVal = 0, fMin = 0, fMax = 0; + if (GetWidth(fVal)) { + size.x = fVal; + } else { + if (GetMinWidth(fMin)) { + size.x = std::max(size.x, fMin); + } + if (GetMaxWidth(fMax) && fMax > 0) { + size.x = std::min(size.x, fMax); + } + } + fVal = 0, fMin = 0, fMax = 0; + if (GetHeight(fVal)) { + size.y = fVal; + } else { + if (GetMinHeight(fMin)) { + size.y = std::max(size.y, fMin); + } + if (GetMaxHeight(fMax) && fMax > 0) { + size.y = std::min(size.y, fMax); + } + } + return TRUE; +} +void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { + FX_FLOAT fFontSize = GetFontSize(); + CFX_WideString wsText; + GetValue(wsText, XFA_VALUEPICTURE_Display); + if (wsText.IsEmpty()) { + size.y += fFontSize; + return; + } + FX_WCHAR wcEnter = '\n'; + FX_WCHAR wsLast = wsText.GetAt(wsText.GetLength() - 1); + 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; + pTextOut->SetFont(GetFDEFont()); + pTextOut->SetFontSize(fFontSize); + pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); + pTextOut->SetLineSpace(GetLineHeight()); + FX_DWORD dwStyles = FDE_TTOSTYLE_LastLineHeight; + if (GetUIType() == XFA_ELEMENT_TextEdit && IsMultiLine()) { + dwStyles |= FDE_TTOSTYLE_LineWrap; + } + pTextOut->SetStyles(dwStyles); + } + ((CXFA_FieldLayoutData*)m_pLayoutData) + ->m_pTextOut->CalcLogicSize(wsText, wsText.GetLength(), size); +} +FX_BOOL CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { + if (size.x > 0) { + CFX_SizeF szOrz = size; + CFX_SizeF szCap; + CalcCaptionSize(szCap); + FX_BOOL bCapExit = szCap.x > 0.01 && szCap.y > 0.01; + int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + if (bCapExit) { + iCapPlacement = GetCaption().GetPlacementType(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.x -= szCap.x; + } + default: + break; + } + } + CFX_RectF rtUIMargin; + GetUIMargin(rtUIMargin); + size.x -= rtUIMargin.left + rtUIMargin.width; + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + size.x -= fLeftInset + fRightInset; + } + CalculateTextContentSize(size); + size.y += rtUIMargin.top + rtUIMargin.height; + if (bCapExit) { + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.y = std::max(size.y, szCap.y); + } break; + case XFA_ATTRIBUTEENUM_Top: + case XFA_ATTRIBUTEENUM_Bottom: { + size.y += szCap.y; + } + default: + break; + } + } + size.x = szOrz.x; + return CalculateWidgetAutoSize(size); + } + CalculateTextContentSize(size); + return CalculateFieldAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) { + FX_FLOAT fCheckSize = GetCheckButtonSize(); + size.x = size.y = fCheckSize; + return CalculateFieldAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) { + CalcCaptionSize(size); + return CalculateWidgetAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { + if (!GetImageImage()) { + LoadImageImage(); + } + size.clear(); + if (CFX_DIBitmap* pBitmap = GetImageImage()) { + CFX_RectF rtImage, rtFit; + rtImage.Set(0, 0, 0, 0); + rtFit.Set(0, 0, 0, 0); + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + GetImageDpi(iImageXDpi, iImageYDpi); + rtImage.width = + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); + rtImage.height = + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); + if (GetWidth(rtFit.width)) { + GetWidthWithoutMargin(rtFit.width); + } else { + rtFit.width = rtImage.width; + } + if (GetHeight(rtFit.height)) { + GetHeightWithoutMargin(rtFit.height); + } else { + rtFit.height = rtImage.height; + } + size.x = rtFit.width; + size.y = rtFit.height; + } + return CalculateWidgetAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { + if (!GetImageEditImage()) { + LoadImageEditImage(); + } + size.clear(); + if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { + CFX_RectF rtImage, rtFit; + rtImage.Set(0, 0, 0, 0); + rtFit.Set(0, 0, 0, 0); + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + GetImageEditDpi(iImageXDpi, iImageYDpi); + rtImage.width = + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); + rtImage.height = + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); + if (GetWidth(rtFit.width)) { + GetWidthWithoutMargin(rtFit.width); + } else { + rtFit.width = rtImage.width; + } + if (GetHeight(rtFit.height)) { + GetHeightWithoutMargin(rtFit.height); + } else { + rtFit.height = rtImage.height; + } + size.x = rtFit.width; + size.y = rtFit.height; + } + return CalculateFieldAutoSize(size); +} +FX_BOOL CXFA_WidgetAcc::LoadImageImage() { + InitLayoutData(); + return ((CXFA_ImageLayoutData*)m_pLayoutData)->LoadImageData(this); +} +FX_BOOL CXFA_WidgetAcc::LoadImageEditImage() { + InitLayoutData(); + return ((CXFA_ImageEditData*)m_pLayoutData)->LoadImageData(this); +} +void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { + iImageXDpi = ((CXFA_ImageLayoutData*)m_pLayoutData)->m_iImageXDpi; + iImageYDpi = ((CXFA_ImageLayoutData*)m_pLayoutData)->m_iImageYDpi; +} +void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { + iImageXDpi = ((CXFA_ImageEditData*)m_pLayoutData)->m_iImageXDpi; + iImageYDpi = ((CXFA_ImageEditData*)m_pLayoutData)->m_iImageYDpi; +} +FX_BOOL CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { + LoadText(); + CXFA_TextLayout* pTextLayout = + ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; + if (pTextLayout) { + size.x = pTextLayout->StartLayout(size.x); + size.y = pTextLayout->GetLayoutHeight(); + } + return CalculateWidgetAutoSize(size); +} +void CXFA_WidgetAcc::LoadText() { + InitLayoutData(); + ((CXFA_TextLayoutData*)m_pLayoutData)->LoadText(this); +} +FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoWidth(FX_FLOAT fWidthCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + fWidthCalc += fLeftInset + fRightInset; + } + FX_FLOAT fMin = 0, fMax = 0; + if (GetMinWidth(fMin)) { + fWidthCalc = std::max(fWidthCalc, fMin); + } + if (GetMaxWidth(fMax) && fMax > 0) { + fWidthCalc = std::min(fWidthCalc, fMax); + } + return fWidthCalc; +} +FX_FLOAT CXFA_WidgetAcc::GetWidthWithoutMargin(FX_FLOAT fWidthCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + fWidthCalc -= fLeftInset + fRightInset; + } + return fWidthCalc; +} +FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoHeight(FX_FLOAT fHeightCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fTopInset, fBottomInset; + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + fHeightCalc += fTopInset + fBottomInset; + } + FX_FLOAT fMin = 0, fMax = 0; + if (GetMinHeight(fMin)) { + fHeightCalc = std::max(fHeightCalc, fMin); + } + if (GetMaxHeight(fMax) && fMax > 0) { + fHeightCalc = std::min(fHeightCalc, fMax); + } + return fHeightCalc; +} +FX_FLOAT CXFA_WidgetAcc::GetHeightWithoutMargin(FX_FLOAT fHeightCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + FX_FLOAT fTopInset, fBottomInset; + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + fHeightCalc -= fTopInset + fBottomInset; + } + return fHeightCalc; +} +void CXFA_WidgetAcc::StartWidgetLayout(FX_FLOAT& fCalcWidth, + FX_FLOAT& fCalcHeight) { + InitLayoutData(); + XFA_ELEMENT eUIType = GetUIType(); + if (eUIType == XFA_ELEMENT_Text) { + m_pLayoutData->m_fWidgetHeight = -1; + GetHeight(m_pLayoutData->m_fWidgetHeight); + StartTextLayout(fCalcWidth, fCalcHeight); + return; + } + if (fCalcWidth > 0 && fCalcHeight > 0) { + return; + } + m_pLayoutData->m_fWidgetHeight = -1; + FX_FLOAT fWidth = 0; + if (fCalcWidth > 0 && fCalcHeight < 0) { + if (!GetHeight(fCalcHeight)) { + CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); + } + m_pLayoutData->m_fWidgetHeight = fCalcHeight; + return; + } + if (fCalcWidth < 0 && fCalcHeight < 0) { + if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) { + CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); + } + fCalcWidth = fWidth; + } + m_pLayoutData->m_fWidgetHeight = fCalcHeight; +} +void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_ELEMENT eUIType, + FX_FLOAT& fWidth, + FX_FLOAT& fCalcHeight) { + CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); + switch (eUIType) { + case XFA_ELEMENT_Barcode: + case XFA_ELEMENT_ChoiceList: + case XFA_ELEMENT_Signature: + CalculateFieldAutoSize(sz); + break; + case XFA_ELEMENT_ImageEdit: + CalculateImageEditAutoSize(sz); + break; + case XFA_ELEMENT_Button: + CalculatePushButtonAutoSize(sz); + break; + case XFA_ELEMENT_CheckButton: + CalculateCheckButtonAutoSize(sz); + break; + case XFA_ELEMENT_DateTimeEdit: + case XFA_ELEMENT_NumericEdit: + case XFA_ELEMENT_PasswordEdit: + case XFA_ELEMENT_TextEdit: + CalculateTextEditAutoSize(sz); + break; + case XFA_ELEMENT_Image: + CalculateImageAutoSize(sz); + break; + case XFA_ELEMENT_Arc: + case XFA_ELEMENT_Line: + case XFA_ELEMENT_Rectangle: + case XFA_ELEMENT_Subform: + case XFA_ELEMENT_ExclGroup: + CalculateWidgetAutoSize(sz); + break; + default: + break; + } + fWidth = sz.x; + m_pLayoutData->m_fWidgetHeight = sz.y; + fCalcHeight = sz.y; +} +FX_BOOL CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, + FX_FLOAT& fCalcHeight) { + XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); + if (eUIType == XFA_ELEMENT_Subform) { + return FALSE; + } + if (eUIType != XFA_ELEMENT_Text && eUIType != XFA_ELEMENT_TextEdit && + eUIType != XFA_ELEMENT_NumericEdit && + eUIType != XFA_ELEMENT_PasswordEdit) { + fCalcHeight = 0; + return TRUE; + } + FX_FLOAT fTopInset = 0; + FX_FLOAT fBottomInset = 0; + if (iBlockIndex == 0) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + } + CFX_RectF rtUIMargin; + GetUIMargin(rtUIMargin); + fTopInset += rtUIMargin.top; + fBottomInset += rtUIMargin.width; + } + if (eUIType == XFA_ELEMENT_Text) { + FX_FLOAT fHeight = fCalcHeight; + if (iBlockIndex == 0) { + fCalcHeight = fCalcHeight - fTopInset; + if (fCalcHeight < 0) { + fCalcHeight = 0; + } + } + CXFA_TextLayout* pTextLayout = + ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; + pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight, + m_pLayoutData->m_fWidgetHeight - fTopInset); + if (fCalcHeight != 0) { + if (iBlockIndex == 0) { + fCalcHeight = fCalcHeight + fTopInset; + } + if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { + return FALSE; + } + } + return TRUE; + } + XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + FX_FLOAT fCapReserve = 0; + if (iBlockIndex == 0) { + CXFA_Caption caption = GetCaption(); + if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); + fCapReserve = caption.GetReserve(); + } + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && + fCalcHeight < fCapReserve + fTopInset) { + fCalcHeight = 0; + return TRUE; + } + if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && + m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) { + fCalcHeight = 0; + return TRUE; + } + if (iCapPlacement != XFA_ATTRIBUTEENUM_Top) { + fCapReserve = 0; + } + } + int32_t iLinesCount = 0; + FX_FLOAT fHeight = m_pLayoutData->m_fWidgetHeight; + CFX_WideString wsText; + GetValue(wsText, XFA_VALUEPICTURE_Display); + if (wsText.IsEmpty()) { + iLinesCount = 1; + } else { + if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut) { + FX_FLOAT fWidth = 0; + GetWidth(fWidth); + CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); + } + iLinesCount = + ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut->GetTotalLines(); + } + if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray) { + ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray = + new CFX_FloatArray; + } + CFX_FloatArray* pFieldArray = + ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray; + int32_t iFieldSplitCount = pFieldArray->GetSize(); + for (int32_t i = 0; i < iBlockIndex * 3; i += 3) { + iLinesCount -= (int32_t)pFieldArray->GetAt(i + 1); + fHeight -= pFieldArray->GetAt(i + 2); + } + if (iLinesCount == 0) { + return FALSE; + } + FX_FLOAT fLineHeight = GetLineHeight(); + FX_FLOAT fFontSize = GetFontSize(); + FX_FLOAT fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize; + FX_FLOAT fSpaceAbove = 0; + FX_FLOAT fStartOffset = 0; + if (fHeight > 0.1f && iBlockIndex == 0) { + fStartOffset = fTopInset; + fHeight -= (fTopInset + fBottomInset); + if (CXFA_Para para = GetPara()) { + fSpaceAbove = para.GetSpaceAbove(); + FX_FLOAT fSpaceBelow = para.GetSpaceBelow(); + fHeight -= (fSpaceAbove + fSpaceBelow); + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Top: + fStartOffset += fSpaceAbove; + break; + case XFA_ATTRIBUTEENUM_Middle: + fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove); + break; + case XFA_ATTRIBUTEENUM_Bottom: + fStartOffset += (fHeight - fTextHeight + fSpaceAbove); + break; + } + } + if (fStartOffset < 0.1f) { + fStartOffset = 0; + } + } + for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) { + fStartOffset = pFieldArray->GetAt(i * 3) - pFieldArray->GetAt(i * 3 + 2); + if (fStartOffset < 0.1f) { + fStartOffset = 0; + } + } + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + pFieldArray->SetAt(0, fStartOffset); + } else { + pFieldArray->Add(fStartOffset); + } + XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + FX_BOOL bCanSplitNoContent = FALSE; + XFA_ATTRIBUTEENUM eLayoutMode; + GetNode() + ->GetNodeItem(XFA_NODEITEM_Parent) + ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, TRUE); + if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position || + eLayoutMode == XFA_ATTRIBUTEENUM_Tb || + eLayoutMode == XFA_ATTRIBUTEENUM_Row || + eLayoutMode == XFA_ATTRIBUTEENUM_Table) && + version > XFA_VERSION_208) { + bCanSplitNoContent = TRUE; + } + if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb || + eLayoutMode == XFA_ATTRIBUTEENUM_Row || + eLayoutMode == XFA_ATTRIBUTEENUM_Table) && + version <= XFA_VERSION_208) { + if (fStartOffset < fCalcHeight) { + bCanSplitNoContent = TRUE; + } else { + fCalcHeight = 0; + return TRUE; + } + } + if (bCanSplitNoContent) { + if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) { + fCalcHeight = 0; + return TRUE; + } + if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) { + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + pFieldArray->SetAt(iBlockIndex * 3 + 1, 0); + pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); + } else { + pFieldArray->Add(0); + pFieldArray->Add(fCalcHeight); + } + return FALSE; + } + if (fCalcHeight - fStartOffset < fLineHeight) { + fCalcHeight = fStartOffset; + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + pFieldArray->SetAt(iBlockIndex * 3 + 1, 0); + pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); + } else { + pFieldArray->Add(0); + pFieldArray->Add(fCalcHeight); + } + return TRUE; + } + FX_FLOAT fTextNum = + fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset; + int32_t iLineNum = + (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight); + if (iLineNum >= iLinesCount) { + if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) { + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLinesCount); + pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); + } else { + pFieldArray->Add((FX_FLOAT)iLinesCount); + pFieldArray->Add(fCalcHeight); + } + return FALSE; + } + if (fHeight - fStartOffset - fTextHeight < fFontSize) { + iLineNum -= 1; + if (iLineNum == 0) { + fCalcHeight = 0; + return TRUE; + } + } else { + iLineNum = (int32_t)(fTextNum / fLineHeight); + } + } + if (iLineNum > 0) { + FX_FLOAT fSplitHeight = + iLineNum * fLineHeight + fCapReserve + fStartOffset; + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLineNum); + pFieldArray->SetAt(iBlockIndex * 3 + 2, fSplitHeight); + } else { + pFieldArray->Add((FX_FLOAT)iLineNum); + pFieldArray->Add(fSplitHeight); + } + if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { + return FALSE; + } + fCalcHeight = fSplitHeight; + return TRUE; + } + } + fCalcHeight = 0; + return TRUE; +} +void CXFA_WidgetAcc::InitLayoutData() { + if (m_pLayoutData) { + return; + } + switch (GetUIType()) { + case XFA_ELEMENT_Text: + m_pLayoutData = new CXFA_TextLayoutData; + return; + case XFA_ELEMENT_TextEdit: + m_pLayoutData = new CXFA_TextEditData; + return; + case XFA_ELEMENT_Image: + m_pLayoutData = new CXFA_ImageLayoutData; + return; + case XFA_ELEMENT_ImageEdit: + m_pLayoutData = new CXFA_ImageEditData; + return; + default: + break; + } + if (GetClassID() == XFA_ELEMENT_Field) { + m_pLayoutData = new CXFA_FieldLayoutData; + } else { + m_pLayoutData = new CXFA_WidgetLayoutData; + } +} +void CXFA_WidgetAcc::StartTextLayout(FX_FLOAT& fCalcWidth, + FX_FLOAT& fCalcHeight) { + LoadText(); + CXFA_TextLayout* pTextLayout = + ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; + FX_FLOAT fTextHeight = 0; + if (fCalcWidth > 0 && fCalcHeight > 0) { + FX_FLOAT fWidth = GetWidthWithoutMargin(fCalcWidth); + pTextLayout->StartLayout(fWidth); + fTextHeight = fCalcHeight; + fTextHeight = GetHeightWithoutMargin(fTextHeight); + pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); + return; + } + if (fCalcWidth > 0 && fCalcHeight < 0) { + FX_FLOAT fWidth = GetWidthWithoutMargin(fCalcWidth); + pTextLayout->StartLayout(fWidth); + } + if (fCalcWidth < 0 && fCalcHeight < 0) { + FX_FLOAT fMaxWidth = -1; + FX_BOOL bRet = GetWidth(fMaxWidth); + if (bRet) { + FX_FLOAT fWidth = GetWidthWithoutMargin(fMaxWidth); + pTextLayout->StartLayout(fWidth); + } else { + FX_FLOAT fWidth = pTextLayout->StartLayout(fMaxWidth); + fMaxWidth = CalculateWidgetAutoWidth(fWidth); + fWidth = GetWidthWithoutMargin(fMaxWidth); + pTextLayout->StartLayout(fWidth); + } + fCalcWidth = fMaxWidth; + } + if (m_pLayoutData->m_fWidgetHeight < 0) { + m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight(); + m_pLayoutData->m_fWidgetHeight = + CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight); + } + fTextHeight = m_pLayoutData->m_fWidgetHeight; + fTextHeight = GetHeightWithoutMargin(fTextHeight); + pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); + fCalcHeight = m_pLayoutData->m_fWidgetHeight; +} +FX_BOOL CXFA_WidgetAcc::LoadCaption() { + InitLayoutData(); + return ((CXFA_FieldLayoutData*)m_pLayoutData)->LoadCaption(this); +} +CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() { + return m_pLayoutData + ? ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout + : NULL; +} +CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { + return m_pLayoutData ? ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout + : NULL; +} +CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() { + return m_pLayoutData ? ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap + : NULL; +} +CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() { + return m_pLayoutData ? ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap + : NULL; +} +void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) { + if (((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap == newImage) { + return; + } + if (((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap && + !((CXFA_ImageLayoutData*)m_pLayoutData)->m_bNamedImage) { + delete ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap; + ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap = NULL; + } + ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap = newImage; +} +void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) { + if (((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap == newImage) { + return; + } + if (((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap && + !((CXFA_ImageEditData*)m_pLayoutData)->m_bNamedImage) { + delete ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap; + ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap = NULL; + } + ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap = newImage; +} +CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { + return m_pLayoutData; +} +IFX_Font* CXFA_WidgetAcc::GetFDEFont() { + CFX_WideStringC wsFontName = FX_WSTRC(L"Courier"); + FX_DWORD dwFontStyle = 0; + if (CXFA_Font font = GetFont()) { + if (font.IsBold()) { + dwFontStyle |= FX_FONTSTYLE_Bold; + } + if (font.IsItalic()) { + dwFontStyle |= FX_FONTSTYLE_Italic; + } + font.GetTypeface(wsFontName); + } + CXFA_FFDoc* pDoc = GetDoc(); + return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName, + dwFontStyle); +} +FX_FLOAT CXFA_WidgetAcc::GetFontSize() { + FX_FLOAT fFontSize = 10.0f; + if (CXFA_Font font = GetFont()) { + fFontSize = font.GetFontSize(); + } + return fFontSize < 0.1f ? 10.0f : fFontSize; +} +FX_FLOAT CXFA_WidgetAcc::GetLineHeight() { + FX_FLOAT fLineHeight = 0; + if (CXFA_Para para = GetPara()) { + fLineHeight = para.GetLineHeight(); + } + if (fLineHeight < 1) { + fLineHeight = GetFontSize() * 1.2f; + } + return fLineHeight; +} +FX_ARGB CXFA_WidgetAcc::GetTextColor() { + if (CXFA_Font font = GetFont()) { + return font.GetColor(); + } + return 0xFF000000; +} +CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { + bRichText = FALSE; + if (m_pTextNode) { + if (m_pTextNode->GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideString wsContentType; + m_pTextNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, + FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + bRichText = TRUE; + } + } + return m_pTextNode; + } + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { + CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); + CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_ELEMENT_Value); + if (!pValueNode) { + return NULL; + } + CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideString wsContentType; + pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + bRichText = TRUE; + } + } + return pChildNode; + } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { + CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); + IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + FXSYS_assert(pXMLNode); + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pXMLChild->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLChild; + if (XFA_RecognizeRichText(pElement)) { + bRichText = TRUE; + } + } + } + return pBind; + } else if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) { + CXFA_Node* pCaptionNode = + m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); + if (pCaptionNode == NULL) { + return NULL; + } + CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_ELEMENT_Value); + if (pValueNode == NULL) { + return NULL; + } + CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideString wsContentType; + pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + bRichText = TRUE; + } + } + return pChildNode; + } + CXFA_Node* pItemNode = + m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Items); + if (pItemNode == NULL) { + return NULL; + } + CXFA_Node* pNode = pItemNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pNode) { + CFX_WideStringC wsName; + pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); + if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && + wsName == FX_WSTRC(L"rollover")) { + return pNode; + } + if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == FX_WSTRC(L"down")) { + return pNode; + } + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + return NULL; +} +CXFA_Para CXFA_TextProvider::GetParaNode() { + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { + return m_pWidgetAcc->GetPara(); + } + CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); + return CXFA_Para(pNode->GetChild(0, XFA_ELEMENT_Para)); +} +CXFA_Font CXFA_TextProvider::GetFontNode() { + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { + return m_pWidgetAcc->GetFont(); + } + CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); + pNode = pNode->GetChild(0, XFA_ELEMENT_Font); + if (pNode) { + return CXFA_Font(pNode); + } + return m_pWidgetAcc->GetFont(); +} +FX_BOOL CXFA_TextProvider::IsCheckButtonAndAutoWidth() { + XFA_ELEMENT eType = m_pWidgetAcc->GetUIType(); + if (eType == XFA_ELEMENT_CheckButton) { + FX_FLOAT fWidth = 0; + return !m_pWidgetAcc->GetWidth(fWidth); + } + return FALSE; +} +FX_BOOL CXFA_TextProvider::GetEmbbedObj(FX_BOOL bURI, + FX_BOOL bRaw, + const CFX_WideString& wsAttr, + CFX_WideString& wsValue) { + if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { + return FALSE; + } + if (bURI) { + CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); + CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Document* pDocument = pWidgetNode->GetDocument(); + CXFA_Node* pIDNode = NULL; + CXFA_WidgetAcc* pEmbAcc = NULL; + if (pParent) { + pIDNode = pDocument->GetNodeByID(pParent, wsAttr); + } + if (!pIDNode) { + pIDNode = pDocument->GetNodeByID( + ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), wsAttr); + } + if (pIDNode) { + pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); + } + if (pEmbAcc) { + pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); + return TRUE; + } + } + return FALSE; +} diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.h b/xfa/fxfa/app/xfa_ffwidgetacc.h new file mode 100644 index 0000000000..722256a6f7 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidgetacc.h @@ -0,0 +1,44 @@ +// 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_APP_XFA_FFWIDGETACC_H_ +#define XFA_FXFA_APP_XFA_FFWIDGETACC_H_ + +#include "xfa/fxfa/app/xfa_textlayout.h" + +enum XFA_TEXTPROVIDERTYPE { + XFA_TEXTPROVIDERTYPE_Text, + XFA_TEXTPROVIDERTYPE_Datasets, + XFA_TEXTPROVIDERTYPE_Caption, + XFA_TEXTPROVIDERTYPE_Rollover, + XFA_TEXTPROVIDERTYPE_Down, +}; +class CXFA_TextProvider : public IXFA_TextProvider { + public: + CXFA_TextProvider(CXFA_WidgetAcc* pWidgetAcc, + XFA_TEXTPROVIDERTYPE eType, + CXFA_Node* pTextNode = NULL) + : m_pWidgetAcc(pWidgetAcc), m_eType(eType), m_pTextNode(pTextNode) { + FXSYS_assert(m_pWidgetAcc); + } + virtual ~CXFA_TextProvider() {} + virtual CXFA_Node* GetTextNode(FX_BOOL& bRichText); + virtual CXFA_Para GetParaNode(); + virtual CXFA_Font GetFontNode(); + virtual FX_BOOL IsCheckButtonAndAutoWidth(); + virtual CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); } + virtual FX_BOOL GetEmbbedObj(FX_BOOL bURI, + FX_BOOL bRaw, + const CFX_WideString& wsAttr, + CFX_WideString& wsValue); + + protected: + CXFA_WidgetAcc* m_pWidgetAcc; + XFA_TEXTPROVIDERTYPE m_eType; + CXFA_Node* m_pTextNode; +}; + +#endif // XFA_FXFA_APP_XFA_FFWIDGETACC_H_ diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp new file mode 100644 index 0000000000..b775643189 --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -0,0 +1,634 @@ +// 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/fxfa/app/xfa_ffwidgethandler.h" + +#include <vector> + +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_ffdocview.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/parser/xfa_parser.h" + +CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) + : m_pDocView(pDocView) {} +CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} +IXFA_PageView* CXFA_FFWidgetHandler::GetPageView(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->GetPageView(); +} +void CXFA_FFWidgetHandler::GetRect(IXFA_Widget* hWidget, CFX_RectF& rt) { + static_cast<CXFA_FFWidget*>(hWidget)->GetWidgetRect(rt); +} +FX_DWORD CXFA_FFWidgetHandler::GetStatus(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->GetStatus(); +} +FX_BOOL CXFA_FFWidgetHandler::GetBBox(IXFA_Widget* hWidget, + CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus) { + return static_cast<CXFA_FFWidget*>(hWidget) + ->GetBBox(rtBox, dwStatus, bDrawFocus); +} +CXFA_WidgetAcc* CXFA_FFWidgetHandler::GetDataAcc(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->GetDataAcc(); +} +void CXFA_FFWidgetHandler::GetName(IXFA_Widget* hWidget, + CFX_WideString& wsName, + int32_t iNameType) { + static_cast<CXFA_FFWidget*>(hWidget)->GetDataAcc()->GetName(wsName, + iNameType); +} +FX_BOOL CXFA_FFWidgetHandler::GetToolTip(IXFA_Widget* hWidget, + CFX_WideString& wsToolTip) { + return static_cast<CXFA_FFWidget*>(hWidget)->GetToolTip(wsToolTip); +} +void CXFA_FFWidgetHandler::SetPrivateData(IXFA_Widget* hWidget, + void* module_id, + void* pData, + PD_CALLBACK_FREEDATA callback) { + static_cast<CXFA_FFWidget*>(hWidget) + ->SetPrivateData(module_id, pData, callback); +} +void* CXFA_FFWidgetHandler::GetPrivateData(IXFA_Widget* hWidget, + void* module_id) { + return static_cast<CXFA_FFWidget*>(hWidget)->GetPrivateData(module_id); +} +FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(IXFA_Widget* hWidget) { + m_pDocView->LockUpdate(); + FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnMouseEnter(); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(IXFA_Widget* hWidget) { + m_pDocView->LockUpdate(); + FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnMouseExit(); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + m_pDocView->LockUpdate(); + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonDown(dwFlags, fx, fy); + if (bRet && m_pDocView->SetFocus(hWidget)) { + ((CXFA_FFDoc*)m_pDocView->GetDoc()) + ->GetDocProvider() + ->SetFocusWidget(m_pDocView->GetDoc(), (IXFA_Widget*)hWidget); + } + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + m_pDocView->LockUpdate(); + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + m_pDocView->m_bLayoutEvent = TRUE; + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonUp(dwFlags, fx, fy); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonDblClk(dwFlags, fx, fy); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnMouseMove(dwFlags, fx, fy); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget) + ->OnMouseWheel(dwFlags, zDelta, fx, fy); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonDown(dwFlags, fx, fy); + if (bRet && m_pDocView->SetFocus(hWidget)) { + ((CXFA_FFDoc*)m_pDocView->GetDoc()) + ->GetDocProvider() + ->SetFocusWidget(m_pDocView->GetDoc(), (IXFA_Widget*)hWidget); + } + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonUp(dwFlags, fx, fy); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonDblClk(dwFlags, fx, fy); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(IXFA_Widget* hWidget, + FX_DWORD dwKeyCode, + FX_DWORD dwFlags) { + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnKeyDown(dwKeyCode, dwFlags); + m_pDocView->RunInvalidate(); + m_pDocView->UpdateDocView(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(IXFA_Widget* hWidget, + FX_DWORD dwKeyCode, + FX_DWORD dwFlags) { + FX_BOOL bRet = + static_cast<CXFA_FFWidget*>(hWidget)->OnKeyUp(dwKeyCode, dwFlags); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_BOOL CXFA_FFWidgetHandler::OnChar(IXFA_Widget* hWidget, + FX_DWORD dwChar, + FX_DWORD dwFlags) { + FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnChar(dwChar, dwFlags); + m_pDocView->RunInvalidate(); + return bRet; +} +FX_DWORD CXFA_FFWidgetHandler::OnHitTest(IXFA_Widget* hWidget, + FX_FLOAT fx, + FX_FLOAT fy) { + if (!(static_cast<CXFA_FFWidget*>(hWidget)->GetStatus() & + XFA_WIDGETSTATUS_Visible)) { + return FWL_WGTHITTEST_Unknown; + } + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + return static_cast<CXFA_FFWidget*>(hWidget)->OnHitTest(fx, fy); +} +FX_BOOL CXFA_FFWidgetHandler::OnSetCursor(IXFA_Widget* hWidget, + FX_FLOAT fx, + FX_FLOAT fy) { + static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); + return static_cast<CXFA_FFWidget*>(hWidget)->OnSetCursor(fx, fy); +} +void CXFA_FFWidgetHandler::RenderWidget(IXFA_Widget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + FX_BOOL bHighlight) { + static_cast<CXFA_FFWidget*>(hWidget)->RenderWidget( + pGS, pMatrix, bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); +} +FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, + XFA_EVENTTYPE eEventType) { + if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) { + return FALSE; + } + if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { + return FALSE; + } + switch (eEventType) { + case XFA_EVENT_Calculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + if (!calc) { + return FALSE; + } + if (calc.GetScript()) { + return TRUE; + } + return FALSE; + } + case XFA_EVENT_Validate: { + CXFA_Validate val = pWidgetAcc->GetValidate(); + if (!val) { + return FALSE; + } + if (val.GetScript()) { + return TRUE; + } + return FALSE; + } + default: + break; + } + CXFA_NodeArray eventArray; + return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], + eventArray); +} +int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, + CXFA_EventParam* pParam) { + if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { + return XFA_EVENTERROR_NotExist; + } + if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { + return XFA_EVENTERROR_NotExist; + } + switch (pParam->m_eType) { + case XFA_EVENT_Calculate: + return pWidgetAcc->ProcessCalculate(); + case XFA_EVENT_Validate: + if (((CXFA_FFDoc*)m_pDocView->GetDoc()) + ->GetDocProvider() + ->IsValidationsEnabled(m_pDocView->GetDoc())) { + return pWidgetAcc->ProcessValidate(); + } + return XFA_EVENTERROR_Disabled; + case XFA_EVENT_InitCalculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + if (!calc) { + return XFA_EVENTERROR_NotExist; + } + if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { + return XFA_EVENTERROR_Disabled; + } + CXFA_Script script = calc.GetScript(); + return pWidgetAcc->ExecuteScript(script, pParam); + } + default: + break; + } + int32_t iRet = + pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + return iRet; +} +IXFA_Widget* CXFA_FFWidgetHandler::CreateWidget(IXFA_Widget* hParent, + XFA_WIDGETTYPE eType, + IXFA_Widget* hBefore) { + CXFA_Node* pParentFormItem = + hParent ? static_cast<CXFA_FFWidget*>(hParent)->GetDataAcc()->GetNode() + : NULL; + CXFA_Node* pBeforeFormItem = + hBefore ? static_cast<CXFA_FFWidget*>(hBefore)->GetDataAcc()->GetNode() + : NULL; + CXFA_Node* pNewFormItem = + CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); + if (pNewFormItem == NULL) { + return NULL; + } + pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); + pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); + m_pDocView->RunLayout(); + CXFA_LayoutItem* pLayout = + m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); + return (IXFA_Widget*)pLayout; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( + XFA_WIDGETTYPE eType, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + switch (eType) { + case XFA_WIDGETTYPE_Barcode: + return NULL; + case XFA_WIDGETTYPE_PushButton: + return CreatePushButton(pParent, pBefore); + case XFA_WIDGETTYPE_CheckButton: + return CreateCheckButton(pParent, pBefore); + case XFA_WIDGETTYPE_ExcludeGroup: + return CreateExclGroup(pParent, pBefore); + case XFA_WIDGETTYPE_RadioButton: + return CreateRadioButton(pParent, pBefore); + case XFA_WIDGETTYPE_Arc: + return CreateArc(pParent, pBefore); + case XFA_WIDGETTYPE_Rectangle: + return CreateRectangle(pParent, pBefore); + case XFA_WIDGETTYPE_Image: + return CreateImage(pParent, pBefore); + case XFA_WIDGETTYPE_Line: + return CreateLine(pParent, pBefore); + case XFA_WIDGETTYPE_Text: + return CreateText(pParent, pBefore); + case XFA_WIDGETTYPE_DatetimeEdit: + return CreateDatetimeEdit(pParent, pBefore); + case XFA_WIDGETTYPE_DecimalField: + return CreateDecimalField(pParent, pBefore); + case XFA_WIDGETTYPE_NumericField: + return CreateNumericField(pParent, pBefore); + case XFA_WIDGETTYPE_Signature: + return CreateSignature(pParent, pBefore); + case XFA_WIDGETTYPE_TextEdit: + return CreateTextEdit(pParent, pBefore); + case XFA_WIDGETTYPE_DropdownList: + return CreateDropdownList(pParent, pBefore); + case XFA_WIDGETTYPE_ListBox: + return CreateListBox(pParent, pBefore); + case XFA_WIDGETTYPE_ImageField: + return CreateImageField(pParent, pBefore); + case XFA_WIDGETTYPE_PasswordEdit: + return CreatePasswordEdit(pParent, pBefore); + case XFA_WIDGETTYPE_Subform: + return CreateSubform(pParent, pBefore); + default: + break; + } + return NULL; +} +CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); + 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); + CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); + pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); + pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); + CreateFontNode(pCaption); + CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); + pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); + CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); + pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); + 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); + CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); + pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); +} +CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); + CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_ELEMENT_Ui); + CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_ELEMENT_CheckButton); + pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); + CreateValueNode(XFA_ELEMENT_Date, pField); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateNumericField(pParent, pBefore); + CreateValueNode(XFA_ELEMENT_Decimal, pField); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_Signature, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDropdownList(pParent, pBefore); + CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); + pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); + pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); + CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); + pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateFormItem(XFA_ELEMENT_Field, pParent, pBefore); + CreateCopyNode(eElement, CreateCopyNode(XFA_ELEMENT_Ui, pField)); + CreateFontNode(pField); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); +} +CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); +} +CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); + CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); + CreateCopyNode(XFA_ELEMENT_TextEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); + CreateFontNode(pField); + return pField; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pDraw = CreateFormItem(XFA_ELEMENT_Draw, pParent, pBefore); + CreateValueNode(eElement, pDraw); + return pDraw; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pSubform = CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); + return pSubform; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; + CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE); + if (pParent) + pParent->InsertChild(pNewFormItem, pBefore); + return pNewFormItem; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; + CXFA_Node* pNewNode = + CreateTemplateNode(eElement, pTemplateParent, + pBefore ? pBefore->GetTemplateNode() : NULL) + ->Clone(FALSE); + if (pParent) + pParent->InsertChild(pNewNode, pBefore); + return pNewNode; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Document* pXFADoc = GetXFADoc(); + CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode( + XFA_XDPPACKET_Template, eElement); + if (pParent) + pParent->InsertChild(pNewTemplateNode, pBefore); + return pNewTemplateNode; +} +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); + return pFont; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, + FX_DWORD dwFlags, + FX_FLOAT fInsets[4]) const { + CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); + if (dwFlags & 0x01) { + pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, + CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); + } + if (dwFlags & 0x02) { + pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, + CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); + } + if (dwFlags & 0x04) { + pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, + CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); + } + if (dwFlags & 0x08) { + pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, + CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); + } + return pMargin; +} +CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, + CXFA_Node* pParent) const { + CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); + CreateCopyNode(eValue, pValue); + return pValue; +} +IXFA_ObjFactory* CXFA_FFWidgetHandler::GetObjFactory() const { + return GetXFADoc()->GetParser()->GetFactory(); +} +CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { + return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); +} +CXFA_FFMenuHandler::CXFA_FFMenuHandler() {} +CXFA_FFMenuHandler::~CXFA_FFMenuHandler() {} +FX_BOOL CXFA_FFMenuHandler::CanCopy(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanCopy(); +} +FX_BOOL CXFA_FFMenuHandler::CanCut(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanCut(); +} +FX_BOOL CXFA_FFMenuHandler::CanPaste(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanPaste(); +} +FX_BOOL CXFA_FFMenuHandler::CanSelectAll(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanSelectAll(); +} +FX_BOOL CXFA_FFMenuHandler::CanDelete(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanDelete(); +} +FX_BOOL CXFA_FFMenuHandler::CanDeSelect(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanDeSelect(); +} +FX_BOOL CXFA_FFMenuHandler::Copy(IXFA_Widget* hWidget, CFX_WideString& wsText) { + return static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsText); +} +FX_BOOL CXFA_FFMenuHandler::Cut(IXFA_Widget* hWidget, CFX_WideString& wsText) { + return static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsText); +} +FX_BOOL CXFA_FFMenuHandler::Paste(IXFA_Widget* hWidget, + const CFX_WideString& wsText) { + return static_cast<CXFA_FFWidget*>(hWidget)->Paste(wsText); +} +FX_BOOL CXFA_FFMenuHandler::SelectAll(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->SelectAll(); +} +FX_BOOL CXFA_FFMenuHandler::Delete(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->Delete(); +} +FX_BOOL CXFA_FFMenuHandler::DeSelect(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->DeSelect(); +} +FX_BOOL CXFA_FFMenuHandler::CanUndo(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanUndo(); +} +FX_BOOL CXFA_FFMenuHandler::CanRedo(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->CanRedo(); +} +FX_BOOL CXFA_FFMenuHandler::Undo(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->Undo(); +} +FX_BOOL CXFA_FFMenuHandler::Redo(IXFA_Widget* hWidget) { + return static_cast<CXFA_FFWidget*>(hWidget)->Redo(); +} +FX_BOOL CXFA_FFMenuHandler::GetSuggestWords( + IXFA_Widget* hWidget, + CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest) { + return static_cast<CXFA_FFWidget*>(hWidget) + ->GetSuggestWords(pointf, sSuggest); +} +FX_BOOL CXFA_FFMenuHandler::ReplaceSpellCheckWord( + IXFA_Widget* hWidget, + CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + return static_cast<CXFA_FFWidget*>(hWidget) + ->ReplaceSpellCheckWord(pointf, bsReplace); +} diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.h b/xfa/fxfa/app/xfa_ffwidgethandler.h new file mode 100644 index 0000000000..a9998b395c --- /dev/null +++ b/xfa/fxfa/app/xfa_ffwidgethandler.h @@ -0,0 +1,176 @@ +// 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_APP_XFA_FFWIDGETHANDLER_H_ +#define XFA_FXFA_APP_XFA_FFWIDGETHANDLER_H_ + +#include <vector> + +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_FFDocView; + +class CXFA_FFWidgetHandler : public IXFA_WidgetHandler { + public: + CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView); + ~CXFA_FFWidgetHandler(); + virtual IXFA_Widget* CreateWidget(IXFA_Widget* hParent, + XFA_WIDGETTYPE eType, + IXFA_Widget* hBefore = NULL); + virtual IXFA_PageView* GetPageView(IXFA_Widget* hWidget); + virtual void GetRect(IXFA_Widget* hWidget, CFX_RectF& rt); + virtual FX_DWORD GetStatus(IXFA_Widget* hWidget); + virtual FX_BOOL GetBBox(IXFA_Widget* hWidget, + CFX_RectF& rtBox, + FX_DWORD dwStatus, + FX_BOOL bDrawFocus = FALSE); + virtual CXFA_WidgetAcc* GetDataAcc(IXFA_Widget* hWidget); + virtual void GetName(IXFA_Widget* hWidget, + CFX_WideString& wsName, + int32_t iNameType = 0); + virtual FX_BOOL GetToolTip(IXFA_Widget* hWidget, CFX_WideString& wsToolTip); + virtual void SetPrivateData(IXFA_Widget* hWidget, + void* module_id, + void* pData, + PD_CALLBACK_FREEDATA callback); + virtual void* GetPrivateData(IXFA_Widget* hWidget, void* module_id); + virtual FX_BOOL OnMouseEnter(IXFA_Widget* hWidget); + virtual FX_BOOL OnMouseExit(IXFA_Widget* hWidget); + virtual FX_BOOL OnLButtonDown(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnLButtonUp(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnLButtonDblClk(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnMouseMove(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnMouseWheel(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + int16_t zDelta, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDown(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonUp(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL OnRButtonDblClk(IXFA_Widget* hWidget, + FX_DWORD dwFlags, + FX_FLOAT fx, + FX_FLOAT fy); + + virtual FX_BOOL OnKeyDown(IXFA_Widget* hWidget, + FX_DWORD dwKeyCode, + FX_DWORD dwFlags); + virtual FX_BOOL OnKeyUp(IXFA_Widget* hWidget, + FX_DWORD dwKeyCode, + FX_DWORD dwFlags); + virtual FX_BOOL OnChar(IXFA_Widget* hWidget, + FX_DWORD dwChar, + FX_DWORD dwFlags); + virtual FX_DWORD OnHitTest(IXFA_Widget* hWidget, FX_FLOAT fx, FX_FLOAT fy); + virtual FX_BOOL OnSetCursor(IXFA_Widget* hWidget, FX_FLOAT fx, FX_FLOAT fy); + virtual void RenderWidget(IXFA_Widget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix = NULL, + FX_BOOL bHighlight = FALSE); + virtual FX_BOOL HasEvent(CXFA_WidgetAcc* pWidgetAcc, + XFA_EVENTTYPE eEventType); + virtual int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, + CXFA_EventParam* pParam); + + protected: + CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + + CXFA_Node* CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateField(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDraw(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + + CXFA_Node* CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateFormItem(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateCopyNode(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore = NULL) const; + CXFA_Node* CreateTemplateNode(XFA_ELEMENT eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateFontNode(CXFA_Node* pParent) const; + CXFA_Node* CreateMarginNode(CXFA_Node* pParent, + FX_DWORD dwFlags, + FX_FLOAT fInsets[4]) const; + CXFA_Node* CreateValueNode(XFA_ELEMENT eValue, CXFA_Node* pParent) const; + IXFA_ObjFactory* GetObjFactory() const; + CXFA_Document* GetXFADoc() const; + + CXFA_FFDocView* m_pDocView; +}; + +class CXFA_FFMenuHandler : public IXFA_MenuHandler { + public: + CXFA_FFMenuHandler(); + ~CXFA_FFMenuHandler(); + virtual FX_BOOL CanCopy(IXFA_Widget* hWidget); + virtual FX_BOOL CanCut(IXFA_Widget* hWidget); + virtual FX_BOOL CanPaste(IXFA_Widget* hWidget); + virtual FX_BOOL CanSelectAll(IXFA_Widget* hWidget); + virtual FX_BOOL CanDelete(IXFA_Widget* hWidget); + virtual FX_BOOL CanDeSelect(IXFA_Widget* hWidget); + virtual FX_BOOL Copy(IXFA_Widget* hWidget, CFX_WideString& wsText); + virtual FX_BOOL Cut(IXFA_Widget* hWidget, CFX_WideString& wsText); + virtual FX_BOOL Paste(IXFA_Widget* hWidget, const CFX_WideString& wsText); + virtual FX_BOOL SelectAll(IXFA_Widget* hWidget); + virtual FX_BOOL Delete(IXFA_Widget* hWidget); + virtual FX_BOOL DeSelect(IXFA_Widget* hWidget); + virtual FX_BOOL CanUndo(IXFA_Widget* hWidget); + virtual FX_BOOL CanRedo(IXFA_Widget* hWidget); + virtual FX_BOOL Undo(IXFA_Widget* hWidget); + virtual FX_BOOL Redo(IXFA_Widget* hWidget); + virtual FX_BOOL GetSuggestWords(IXFA_Widget* hWidget, + CFX_PointF pointf, + std::vector<CFX_ByteString>& sSuggest); + virtual FX_BOOL ReplaceSpellCheckWord(IXFA_Widget* hWidget, + CFX_PointF pointf, + const CFX_ByteStringC& bsReplace); +}; + +#endif // XFA_FXFA_APP_XFA_FFWIDGETHANDLER_H_ diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp new file mode 100644 index 0000000000..dda8f5b5c3 --- /dev/null +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -0,0 +1,2089 @@ +// 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/fxfa/app/xfa_fontmgr.h" + +#include <algorithm> + +#include "core/include/fpdfapi/cpdf_dictionary.h" +#include "core/include/fpdfapi/cpdf_document.h" +#include "core/include/fpdfapi/fpdf_resource.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +static const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"Arial", 0, 936}, + {0x01e4f102, L"YouYuan", L"Arial", 1, 936}, + {0x030549dc, L"LiSu", L"Arial", 1, 936}, + {0x032edd44, L"Simhei", L"Arial", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", L"Arial", 2, 1252}, + {0x03ed90e6, L"Nina", L"Arial", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", L"Arial", 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Arial", 0, 1252}, + {0x089b18a9, L"Arial", L"Arial", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Arial", 8, 1252}, + {0x0bb003e7, L"Kartika", L"Arial", 2, 1252}, + {0x0bb469df, L"VinerHandITC", L"Arial", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Arial", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"Arial", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Kokila,Arial Narrow", 0, 847}, + {0x0e7de0f9, L"Playbill", L"Arial", 0, 1252}, + {0x0eff47c3, L"STHupo", L"Arial", 0, 936}, + {0x107ad374, L"Constantia", L"Arial", 2, 1252}, + {0x12194c2d, L"KunstlerScript", L"Arial", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0x158c4049, L"Garamond", L"Arial", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"Arial", 0, 936}, + {0x161ed07e, L"MSGothic", L"Arial", 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", L"Arial", 0, 1252}, + {0x18d1188f, L"Cambria", L"Arial", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Arial", 0, 936}, + {0x1a92d115, L"MingLiU", L"Arial", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", L"Arial", 0, 1252}, + {0x1d649596, L"BasemicTimes", L"Arial", 0, 1252}, + {0x1e34ee60, L"BellMT", L"Arial", 2, 1252}, + {0x1eb36945, L"CooperBlack", L"Arial", 2, 1252}, + {0x1ef7787d, L"BatangChe", L"Arial", 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", L"Arial", 8, 1252}, + {0x220877aa, L"Candara", L"Arial", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", L"Arial", 8, 1252}, + {0x251059c3, L"Chiller", L"Arial", 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", L"Arial", 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Arial", 8, 1252}, + {0x29711eb9, L"STLiti", L"Arial", 0, 936}, + {0x2b1993b4, L"Basemic", L"Arial", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Arial", 0, 1252}, + {0x2c147529, L"FootlightMTLight", L"Arial", 0, 1252}, + {0x2c198928, L"HarlowSolid", L"Arial", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", L"Arial", 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Arial", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Arial", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", L"Arial", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"Arial", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", L"Arial", 0, 1252}, + {0x31327817, L"MyriadPro", + L"Calibri,Corbel,Candara,Cambria Math,Franklin Gothic Medium,Arial " + L"Narrow,Times New Roman", + 0, 1252}, + {0x32244975, L"Helvetica", L"Arial", 0, 1252}, + {0x32ac995c, L"Terminal", L"Arial", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Arial", 0, 1252}, + {0x33bb65f2, L"Sylfaen", L"Arial", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Arial", 2, 1252}, + {0x3412bf31, L"SimSun-PUA", L"Arial", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", L"Arial", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"Arial", 2, 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Arial", 0, 1252}, + {0x3cdae668, L"FreestyleScript", L"Arial", 8, 1252}, + {0x3d55aed7, L"Jokerman", L"Arial", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Arial", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"Arial", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Arial", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"Arial", 1, 936}, + {0x3f6c36a8, L"Gautami", L"Arial", 0, 1252}, + {0x3ff32662, L"Chiller-Regular", L"Arial", 0, 1252}, + {0x409de312, L"ModernNo.20", L"Arial", 2, 1252}, + {0x41443c5e, L"Georgia", L"Arial", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", + L"Arial,Arial Unicode MS,Book Antiqua,Dotum,Georgia", 0, 1252}, + {0x421976c4, L"Modern-Regular", L"Arial", 2, 1252}, + {0x422a7252, L"Stencil", L"Arial", 0, 1252}, + {0x42c8554f, L"Fixedsys", L"Arial", 0, 1252}, + {0x435cb41d, L"Roman", L"Arial", 0, 1252}, + {0x47882383, L"CourierNew", L"Arial", 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", L"Arial", 0, 1252}, + {0x480bf7a4, L"CourierStd", L"Courier New,Verdana", 0, 1252}, + {0x481ad6ed, L"VladimirScript", L"Arial", 8, 1252}, + {0x4911577a, L"YouYuan", L"Arial", 1, 936}, + {0x4a788d72, L"STXingkai", L"Arial", 0, 936}, + {0x4bf88566, L"SegoeCondensed", L"Arial", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", L"Arial", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Arial", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", L"Courier New,Verdana", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"Arial", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", L"Arial", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", L"Arial", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"Arial", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", L"Arial", 0, 1252}, + {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, + {0x5792e759, L"STKaiti", L"Arial", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Arial", 0, 1252}, + {0x594e2da4, L"Vrinda", L"Arial", 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Arial", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", L"Arial", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"Batang,Bookman Old Style,Consolas,STZhongsong", 0, 936}, + {0x5fefbfad, L"Batang", L"Arial", 2, 1252}, + {0x605342b9, L"DotumChe", L"Arial", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Arial", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", L"Arial", 0, 1252}, + {0x626608a9, L"MVBoli", L"Arial", 0, 1252}, + {0x630501a3, L"SmallFonts", L"Arial", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"Arial", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"Arial", 0, 936}, + {0x673a9e5f, L"Tunga", L"Arial", 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Arial", 0, 1252}, + {0x696259b7, L"Corbel", L"Arial", 0, 1252}, + {0x696ee9be, L"STXihei", L"Arial", 0, 936}, + {0x6c59cf69, L"Dotum", L"Arial", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Arial", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", L"Arial", 0, 1252}, + {0x71b41801, L"Verdana", L"Arial", 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Arial", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Arial", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Arial", 0, 1252}, + {0x74cb44ee, L"NSimSun", L"Arial", 1, 936}, + {0x76b4d7ff, L"Shruti", L"Arial", 0, 1252}, + {0x788b3533, L"Webdings", L"Arial", 6, 42}, + {0x797dde99, L"MSSerif", L"Arial", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", L"Arial", 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", L"Arial", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", L"Arial", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", + L"Centaur,Calibri,STSong,Bell MT,Garamond,Times New Roman", 0, 936}, + {0x83581825, L"Modern", L"Arial", 0, 1252}, + {0x835a2823, L"Algerian", L"Arial", 0, 1252}, + {0x83dab9f5, L"Script", L"Arial", 0, 1252}, + {0x847b56da, L"Tahoma", L"Arial", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"Arial", 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Arial", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Arial", 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Arial", 0, 1252}, + {0x8e8d43b2, L"Centaur", L"Arial", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Arial", 0, 1252}, + {0x90794800, L"BellGothicStdLight", L"Bell MT,Calibri,Times New Roman", 0, + 1252}, + {0x909b516a, L"Century", L"Arial", 2, 1252}, + {0x92ae370d, L"MSOutlook", L"Arial", 4, 42}, + {0x93c9fbf1, L"LucidaFax", L"Arial", 2, 1252}, + {0x9565085e, L"BookAntiqua", L"Arial", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"Arial,Arial Unicode MS,Cambria,BatangChe", + 0, 949}, + {0x9bbadd6b, L"ColonnaMT", L"Arial", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", L"Arial", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"Arial", 0, 1252}, + {0xa0607db1, L"GungsuhChe", L"Arial", 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"Arial", 2, 1252}, + {0xa1429b36, L"Symbol", L"Arial", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"Arial", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"Arial", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", L"Arial", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"Arial", 0, 936}, + {0xa8d83ece, L"CalifornianFB", L"Arial", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", L"Arial", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", L"Arial", 0, 1252}, + {0xade5337c, L"MSUIGothic", L"Arial", 0, 1252}, + {0xb08dd941, L"WideLatin", L"Arial", 2, 1252}, + {0xb207f05d, L"PoorRichard", L"Arial", 2, 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Arial", 0, 1252}, + {0xb5545399, L"Marlett", L"Arial", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", L"Arial", 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", L"Arial", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Arial", 2, 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Batang,Century,Dotum", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Arial", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"Arial", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", L"Bell MT,Berlin Sans FB,Calibri", 0, 1252}, + {0xc318b0af, L"MyriadProLight", L"Calibri,STFangsong,Times New Roman", 0, + 1252}, + {0xc65e5659, L"CambriaMath", L"Arial", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", L"Arial", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Arial", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Arial", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", L"Arial", 0, 1252}, + {0xcca00cc5, L"System", L"Arial", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Arial", 0, 1252}, + {0xccc5818c, L"EuroSign", L"Arial", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", L"Arial", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0xcfe5755f, L"Simhei", L"Arial", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Arial", 0, 1252}, + {0xd060e7ef, L"Vivaldi", L"Arial", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Arial", 0, 1252}, + {0xd107243f, L"SimSun", L"Arial", 0, 936}, + {0xd1881562, L"ArialNarrow", L"Arial Narrow", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", L"Arial", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", L"Arial", 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", L"Arial", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Arial", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", L"Arial", 0, 1252}, + {0xd8e8a027, L"LucidaSans", L"Arial", 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", L"Arial", 2, 1252}, + {0xda7e551e, L"STSong", L"Arial", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"Arial", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Arial", 0, 936}, + {0xdaeb0713, L"STSong", L"Arial", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Arial", 0, 936}, + {0xdb00a3d9, L"Broadway", L"Arial", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Arial", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Arial", 0, 936}, + {0xdb69595a, L"STHupo", L"Arial", 0, 936}, + {0xdba0082c, L"STXihei", L"Arial", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Arial", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Arial", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", L"Arial", 8, 1252}, + {0xdcc7009c, L"Harrington", L"Arial", 0, 1252}, + {0xdd712466, L"ArialBlack", L"Arial", 0, 1252}, + {0xdde87b3e, L"Impact", L"Arial", 0, 1252}, + {0xdf69fb32, L"SnapITC", L"Arial", 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", L"Arial", 0, 1252}, + {0xe0f705c0, L"KristenITC", L"Arial", 8, 1252}, + {0xe1427573, L"Raavi", L"Arial", 0, 1252}, + {0xe2cea0cb, L"Magneto", L"Arial", 0, 1252}, + {0xe36a9e17, L"Ravie", L"Arial", 0, 1252}, + {0xe433f8e2, L"Parchment", L"Arial", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"Arial", 4, 42}, + {0xe4e2c405, L"MTExtra", L"Arial", 6, 42}, + {0xe618cc35, L"InformalRoman", L"Arial", 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Arial", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"Arial", 0, 1252}, + {0xe90fb013, L"TempusSansITC", L"Arial", 0, 1252}, + {0xec637b42, L"Consolas", L"Verdana", 1, 1252}, + {0xed3a683b, L"STXinwei", L"Arial", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", L"Arial", 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", L"Arial", 0, 1252}, + {0xf1028030, L"Mangal", L"Arial", 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", L"Arial", 0, 1252}, + {0xf210f06a, L"ArialMT", L"Arial", 0, 1252}, + {0xf477f16a, L"Latha", L"Arial", 0, 1252}, + {0xf616f3dd, L"LiSu", L"Arial", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Arial", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", L"Arial", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", L"Arial", 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Batang,Century,Dotum", 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ +static const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 0, 936}, + {0x01e4f102, L"YouYuan", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 1, 936}, + {0x030549dc, L"LiSu", + L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " + L"Mono,WenQuanYi Micro Hei", + 1, 936}, + {0x032edd44, L"Simhei", + L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " + L"Mono,WenQuanYi Micro Hei", + 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", L"Droid Sans Japanese,FreeSerif", 2, + 1252}, + {0x03ed90e6, L"Nina", L"FreeSerif", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans Thai,Droid Sans " + L"Armenian,Untitled1,utkal,Lohit Oriya", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", + L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei", 0, 1252}, + {0x089b18a9, L"Arial", + L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif,WenQuanYi Micro Hei", + 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Droid Sans Japanese,FreeSerif", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"FreeSans,Liberation Sans,Liberation Sans Narrow,Nimbus Sans " + L"L,Garuda,FreeSerif,WenQuanYi Micro Hei", + 2, 1252}, + {0x0bb469df, L"VinerHandITC", + L"Droid Sans Japanese,Ubuntu,Liberation Sans,Liberation Serif", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"FreeSerif", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Droid Sans Japanese,Waree", 0, 847}, + {0x0e7de0f9, L"Playbill", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Ethiopic,Droid Sans Japanese,FreeSerif", + 0, 1252}, + {0x0eff47c3, L"STHupo", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0x107ad374, L"Constantia", + L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei,Ubuntu", 2, 1252}, + {0x12194c2d, L"KunstlerScript", L"Droid Sans Japanese,Liberation Serif", 8, + 1252}, + {0x135ef6a1, L"MinionProSmBd", L"Liberation Serif", 0, 1252}, + {0x158c4049, L"Garamond", + L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 2, 1252}, + {0x160ecb24, L"STZhongsong", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x161ed07e, L"MSGothic", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,AR PL " + L"UMing CN,AR PL UMing HK,AR PL UMing TW", + 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Sans", 0, + 1252}, + {0x18d1188f, L"Cambria", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, + 1252}, + {0x18eaf350, L"ArialUnicodeMS", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x1a92d115, L"MingLiU", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", + L"Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, 1252}, + {0x1d649596, L"BasemicTimes", + L"Liberation Serif,Times New Roman,Droid Sans Japanese,FreeSerif,Ubuntu", + 0, 1252}, + {0x1e34ee60, L"BellMT", + L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"KacstQurn,Droid Sans Japanese,FreeMono,Liberation Mono, WenQuanYi Micro " + L"Hei Mono", + 2, 1252}, + {0x1ef7787d, L"BatangChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " + L"TW,WenQuanYi Zen Hei,WenQuanYi Micro Hei", + 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Japanese,URW Chancery L,Liberation Sans", + 8, 1252}, + {0x220877aa, L"Candara", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 8, 1252}, + {0x251059c3, L"Chiller", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Japanese,Liberation Sans", + 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", + L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,AR PL UKai " + L"HK", + 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Droid Sans Japanese,Liberation Sans", + 8, 1252}, + {0x29711eb9, L"STLiti", L"AR PL UKai HK", 0, 936}, + {0x2b1993b4, L"Basemic", + L"Liberation Serif,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Droid Sans Japanese,Liberation Sans", 0, + 1252}, + {0x2c147529, L"FootlightMTLight", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,Liberation Sans", + 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"DejaVu Sans", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"AR PL UKai HK", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"KacstQurn,Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"DejaVu Serif", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x31327817, L"MyriadPro", + L"Ubuntu Condensed,Droid Sans Japanese, FreeSerif", 0, 1252}, + {0x32244975, L"Helvetica", + L"Ubuntu,DejaVu Sans Condensed,Liberation Sans,Liberation Sans " + L"Narrow,Nimbus Sans L", + 0, 1252}, + {0x32ac995c, L"Terminal", L"DejaVu Serif", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Droid Sans Japanese,DejaVu Serif", 0, + 1252}, + {0x33bb65f2, L"Sylfaen", L"Droid Sans Japanese,DejaVu Sans", 2, 1252}, + {0x3402c30e, L"MSPMincho", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 2, + 1252}, + {0x3412bf31, L"SimSun-PUA", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing CN,AR PL UMing HK", 0, + 936}, + {0x36eb39b9, L"BerlinSansFB", + L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"Droid Sans Japanese,DejaVu Serif", 2, + 1252}, + {0x3a257d03, L"FangSong_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei", 0, 1252}, + {0x3c7d1d07, L"Garamond3LTStd", + L"Droid Sans Japanese,Ubuntu Condensed,DejaVu Sans Condensed,Liberation " + L"Serif,Ubuntu,FreeSerif", + 2, 1252}, + {0x3cdae668, L"FreestyleScript", + L"KacstQurn,Droid Sans Japanese,DejaVu Sans", 8, 1252}, + {0x3d55aed7, L"Jokerman", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x3d5b4385, L"PMingLiU", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Droid Sans Japanese,Ubuntu", 0, + 1252}, + {0x3e6aa32d, L"NSimSun", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Droid Arabic Naskh,Droid Sans Ethiopic, mry_KacstQurn,Droid Sans " + L"Japanese,FreeSans", + 0, 1252}, + {0x3ff32662, L"Chiller-Regular", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,FreeSans", 0, 1252}, + {0x409de312, L"ModernNo.20", + L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,Nimbus Sans L,FreeSans", 2, + 1252}, + {0x41443c5e, L"Georgia", L"Droid Sans Japanese,FreeSans", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", L"FreeSans", 0, 1252}, + {0x421976c4, L"Modern-Regular", L"FreeSans", 2, 1252}, + {0x422a7252, L"Stencil", L"Droid Sans Japanese,FreeSans,Liberation Sans", 0, + 1252}, + {0x42c8554f, L"Fixedsys", L"FreeSerif", 0, 1252}, + {0x435cb41d, L"Roman", L"FreeSerif", 0, 1252}, + {0x47882383, L"CourierNew", + L"FreeMono,WenQuanYi Micro Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL " + L"UKai TW,AR PL UKai TW MBE,DejaVu Sans", + 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0x480bf7a4, L"CourierStd", L"DejaVu Sans", 0, 1252}, + {0x481ad6ed, L"VladimirScript", L"Droid Sans Japanese,DejaVu Serif", 8, + 1252}, + {0x4911577a, L"YouYuan", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, + 936}, + {0x4a788d72, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0x4bf88566, L"SegoeCondensed", L"FreeSerif", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0x4ea967ce, L"GulimChe", + L"WenQuanYi Zen Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL " + L"UKai TW MBE", + 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"FreeMono,Liberation Mono,Andale Mono,WenQuanYi Micro Hei Mono", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"FreeSerif", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", L"FreeSerif", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"Droid Sans Japanese,URW Chancery L,FreeSerif", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", + L"Ubuntu Mono,DejaVu Sans Mono,Nimbus Mono L,Liberation Mono,Courier 10 " + L"Pitch,FreeMono", + 0, 1252}, + {0x574d4d3d, L"AdobeArabic", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x5792e759, L"STKaiti", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0x594e2da4, L"Vrinda", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Arabic " + L"Naskh,mry_KacstQurn,Droid Sans Japanese,FreeSans,FreeSerif", + 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 0, 1252}, + {0x5e16ac91, L"TrajanPro", + L"Nimbus Sans L,AR PL UMing HK,AR PL UKai HK,AR PL UMing TW,AR PL UMing " + L"TW MBE,DejaVu Sans,DejaVu Serif", + 0, 1252}, + {0x5f388196, L"ITCLegacySansStdMedium", + L"Liberation Serif,FreeSerif,FreeSans,Ubuntu", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x5fefbfad, L"Batang", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 2, 1252}, + {0x605342b9, L"DotumChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, + 1252}, + {0x608c5f9a, L"KaiTi_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif,DejaVu Sans", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Ethiopic,Droid Sans Japanese,DejaVu Sans", + 0, 1252}, + {0x630501a3, L"SmallFonts", L"DejaVu Serif", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", + L"AR PL UMing CN,AR PL UKai CN, AR PL UMing HK", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,DejaVu Serif", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0x696259b7, L"Corbel", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x696ee9be, L"STXihei", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0x6c59cf69, L"Dotum", L"WenQuanYi Zen Hei Mono", 0, 1252}, + {0x707fa561, L"Gungsuh", L"WenQuanYi Zen Hei Mono", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"KacstArt,KacstBookm,KacstDecorative,KacstDigital,KacstFarsi,KacstLetter," + L"KacstOffice,Dingbats,FreeSerif", + 0, 1252}, + {0x71b41801, L"Verdana", + L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,DejaVu Sans", + 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Japanese,FreeSerif", 0, + 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Droid Sans Japanese,FreeSerif", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Droid Sans Japanese,AR PL UKai HK", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Droid Sans Japanese,DejaVu Serif", 0, + 1252}, + {0x74cb44ee, L"NSimSun", L"WenQuanYi Zen Hei Mono", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,FreeSans", + 0, 1252}, + {0x788b3533, L"Webdings", L"FreeSans", 6, 42}, + {0x797dde99, L"MSSerif", L"FreeSans", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", + L"WenQuanYi Micro Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", + 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Ubuntu Mono,Liberation Mono,DejaVu Sans Mono", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x83581825, L"Modern", L"FreeSans", 0, 1252}, + {0x835a2823, L"Algerian", + L"KacstQurn,Droid Sans Japanese,FreeSans,Liberation Sans,Ubuntu", 0, 1252}, + {0x83dab9f5, L"Script", L"FreeSans", 0, 1252}, + {0x847b56da, L"Tahoma", + L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x8c6a499e, L"Gulim", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x8e8d43b2, L"Centaur", + L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Liberation Sans", 0, 1252}, + {0x90794800, L"BellGothicStdLight", L"Liberation Sans", 0, 1252}, + {0x909b516a, L"Century", + L"Droid Sans Japanese,Liberation Sans,Liberation Mono,Liberation Serif", 2, + 1252}, + {0x92ae370d, L"MSOutlook", L"Liberation Sans", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"KacstQurn,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,Liberation Sans", + 2, 1252}, + {0x9565085e, L"BookAntiqua", + L"Droid Sans Japanese,Liberation Sans,Liberation Serif", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"AR PL UMing HK", 0, 949}, + {0x9bbadd6b, L"ColonnaMT", + L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"FreeSerif", 0, 1252}, + {0xa0607db1, L"GungsuhChe", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"FreeSerif", 2, 1252}, + {0xa1429b36, L"Symbol", L"FreeSerif", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"FreeSerif", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"FreeSerif", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,FreeSerif", + 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"AR PL UMing CN", 0, 936}, + {0xa8d83ece, L"CalifornianFB", L"Droid Sans Japanese,FreeSerif", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans " + L"Thai,utkal,Kedage,Mallige,AR PL UKai CN", + 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"KacstQurn,Droid Sans Japanese,Liberation Serif", 0, 1252}, + {0xade5337c, L"MSUIGothic", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0xb08dd941, L"WideLatin", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,Liberation Serif", + 2, 1252}, + {0xb12765e0, L"ITCLegacySansStdBook", + L"AR PL UMing HK,AR PL UKai HK,FreeSerif,Ubuntu,FreeSans", 0, 1252}, + {0xb207f05d, L"PoorRichard", L"Droid Sans Japanese,Liberation Serif", 2, + 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0xb5545399, L"Marlett", L"Liberation Serif", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", + L"KacstQurn,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,Liberation Serif", + 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif", + 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Droid Sans Japanese,Liberation Sans", 2, + 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Droid Sans Japanese,DejaVu Serif", + 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"DejaVu Sans", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", L"Droid Sans Japanese,Ubuntu,Liberation Serif", + 0, 1252}, + {0xc318b0af, L"MyriadProLight", + L"Droid Sans Japanese,AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 1252}, + {0xc65e5659, L"CambriaMath", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, + 1252}, + {0xc75c8f05, L"LucidaConsole", + L"Liberation Mono,DejaVu Sans Mono,FreeMono,WenQuanYi Micro Hei Mono", 1, + 1252}, + {0xca7c35d6, L"Calibri", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xcb7190f9, L"Magneto-Bold", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,DejaVu Serif", + 0, 1252}, + {0xcca00cc5, L"System", L"DejaVu Sans", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0xccc5818c, L"EuroSign", L"DejaVu Serif", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Serif", 0, + 1252}, + {0xcf7b8fdb, L"MinionPro", L"DejaVu Sans", 0, 1252}, + {0xcfe5755f, L"Simhei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 936}, + {0xd011f4ee, L"MSPGothic", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 0, + 1252}, + {0xd060e7ef, L"Vivaldi", + L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Droid Sans Japanese,Ubuntu", 0, + 1252}, + {0xd107243f, L"SimSun", L"WenQuanYi Zen Hei Mono", 0, 936}, + {0xd1881562, L"ArialNarrow", + L"Liberation Sans Narrow,Droid Sans Japanese,FreeSerif", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", + L"Droid Sans Japanese,FreeMono,Liberation Mono", 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,URW Chancery " + L"L,KacstOne,Liberation Sans", + 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Liberation Sans Narrow,Nimbus Sans L,KacstQurn,Droid Arabic Naskh,Droid " + L"Sans Ethiopic,DejaVu Serif Condensed,Liberation Mono,Ubuntu", + 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, + {0xda7e551e, L"STSong", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0xdaa6842d, L"STZhongsong", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xdaaab93f, L"STFangsong", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdaeb0713, L"STSong", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdafedbef, L"STCaiyun", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdb00a3d9, L"Broadway", + L"KacstQurn,Droid Sans Japanese,DejaVu Sans,FreeMono,Liberation Mono", 0, + 1252}, + {0xdb1f5ad4, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdb326e7f, L"STKaiti", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdb69595a, L"STHupo", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdba0082c, L"STXihei", + L" WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdbd0ab18, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdc1a7db1, L"STLiti", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdc33075f, L"KristenITC-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " + L"Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xdcc7009c, L"Harrington", + L"KacstQurn,Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, + 1252}, + {0xdd712466, L"ArialBlack", + L"Droid Sans Japanese,DejaVu Sans,DejaVu Serif,FreeMono", 0, 1252}, + {0xdde87b3e, L"Impact", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Liberation Sans Narrow,Ubuntu Condensed,DejaVu Sans,DejaVu " + L"Serif,FreeMono", + 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, + 1252}, + {0xe0f705c0, L"KristenITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " + L"Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xe1427573, L"Raavi", + L"Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,FreeSerif,Liberation Serif,Khmer OS", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " + L"Serif,DejaVu Serif Condensed,DejaVu Sans", + 0, 1252}, + {0xe36a9e17, L"Ravie", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " + L"Serif,DejaVu Sans,FreeMono", + 0, 1252}, + {0xe433f8e2, L"Parchment", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"DejaVu Serif", 4, 42}, + {0xe4e2c405, L"MTExtra", L"DejaVu Serif", 6, 42}, + {0xe618cc35, L"InformalRoman", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,Nimbus Sans L,DejaVu Sans Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"DejaVu Sans,DejaVu Sans Condensed,FreeSerif", 0, + 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"DejaVu Serif", 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"Droid Sans Japanese,Ubuntu,Liberation Serif,FreeSerif", 0, 1252}, + {0xec637b42, L"Consolas", + L"DejaVu Sans Condensed,AR PL UKai CN,AR PL UKai HK,AR PL UKai " + L"TW,FreeSerif,FreeSans", + 1, 1252}, + {0xed3a683b, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans " + L"L,KacstQurn,Liberation Mono", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"KacstQurn,Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, + 1252}, + {0xf1028030, L"Mangal", + L"FreeSans,TSCu_Paranar,Garuda,Liberation Sans,Liberation Sans " + L"Narrow,Nimbus Sans L", + 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Droid Sans Japanese,DejaVu Serif Condensed,DejaVu Sans " + L"Condensed,Liberation Sans,Ubuntu", + 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Liberation Sans,Liberation Sans Narrow,FreeSans,Nimbus Sans L,Khmer OS " + L"System,Khmer OS", + 0, 1252}, + {0xf477f16a, L"Latha", + L"Liberation Sans Narrow,Nimbus Sans L,Droid Arabic " + L"Naskh,mry_KacstQurn,FreeSerif,Nimbus Sans L", + 0, 1252}, + {0xf616f3dd, L"LiSu", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, + 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif,DejaVu Sans,FreeMono", + 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ +static const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0x01e4f102, L"YouYuan", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x030549dc, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x032edd44, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", + L"Noteworthy,Avenir Next Condensed,Impact", 2, 1252}, + {0x03ed90e6, L"Nina", L"Microsoft Sans Serif", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"LastResort,Apple " + L"Chancery,STIXVariants,STIXSizeOneSym,STIXSizeOneSym,Apple Braille", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, + {0x089b18a9, L"Arial", + L"Arial Unicode MS,Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Arial Narrow,Impact", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Damascus", 2, 1252}, + {0x0bb469df, L"VinerHandITC", L"Comic Sans MS,Songti SC,STSong", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Apple Symbols", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Avenir Next Condensed Ultra Light", 0, 847}, + {0x0e7de0f9, L"Playbill", L"STIXNonUnicode", 0, 1252}, + {0x0eff47c3, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0x107ad374, L"Constantia", L"Arial Unicode MS,Palatino,Baskerville", 2, + 1252}, + {0x12194c2d, L"KunstlerScript", + L"Avenir Next Condensed Demi Bold,Arial Narrow", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x158c4049, L"Garamond", L"Impact,Arial Narrow", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"STFangsong,Songti SC", 0, 936}, + {0x161ed07e, L"MSGothic", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " + L"TW,Microsoft Sans Serif,Apple Symbols", + 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", L"STHeiti,Arial Black", 0, 1252}, + {0x18d1188f, L"Cambria", L"Arial Unicode MS", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Microsoft Sans Serif,Apple Symbols", 0, + 936}, + {0x1a92d115, L"MingLiU", L"Heiti SC,STHeiti", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", L"Damascus,Impact,Arial Narrow", 0, 1252}, + {0x1d649596, L"BasemicTimes", L"Liberation Serif,Impact,Arial Narrow", 0, + 1252}, + {0x1e34ee60, L"BellMT", + L"Papyrus,STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"Marion,STIXNonUnicode,Arial Rounded MT Bold,Lucida Grande", 2, 1252}, + {0x1ef7787d, L"BatangChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Heiti TC", + 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", + L"STIXNonUnicode,Damascus,Arial Narrow,Avenir Next Condensed,Cochin", 8, + 1252}, + {0x220877aa, L"Candara", L"Cochin,Baskerville,Marion", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"STIXNonUnicode,Nadeem,Zapf Dingbats", 8, 1252}, + {0x251059c3, L"Chiller", + L"Zapf Dingbats,Damascus,STIXNonUnicode,Papyrus,KufiStandardGK,Baghdad", 0, + 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", + L"Tahoma,Apple Symbols,Apple LiGothic,Arial Unicode MS,Lucida " + L"Grande,Microsoft Sans Serif", + 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Microsoft Sans Serif,Apple Symbols", 8, + 1252}, + {0x29711eb9, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, + {0x2b1993b4, L"Basemic", L"Impact,Arial Narrow", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x2c147529, L"FootlightMTLight", + L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans,Noteworthy", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"PT Sans Narrow,Papyrus,Damascus,STIXNonUnicode,Arial Rounded MT " + L"Bold,Comic Sans MS,Avenir Next", + 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Kaiti SC,Songti SC", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"Impact,Avenir Next Condensed Demi Bold,American Typewriter", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x3115525a, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x31327817, L"MyriadPro", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x32244975, L"Helvetica", + L"Arial Narrow,Arial Unicode MS,Damascus,STIXNonUnicode", 0, 1252}, + {0x32ac995c, L"Terminal", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x33bb65f2, L"Sylfaen", L"Arial Unicode MS,Marion", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Arial Unicode MS,Apple SD Gothic Neo", 2, + 1252}, + {0x3412bf31, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", L"American Typewriter,Impact", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"STIXGeneral,.Helvetica Neue Desk UI", 2, + 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x3cdae668, L"FreestyleScript", L"Nadeem,Zapf Dingbats,STIXNonUnicode", 8, + 1252}, + {0x3d55aed7, L"Jokerman", + L"Papyrus,Lucida Grande,Heiti TC,American Typewriter", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Heiti SC,STHeiti", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"American Typewriter,Marion", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Impact,Arial Narrow", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"STHeiti,STFangsong", 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Damascus,STIXNonUnicode,STIXGeneral,American Typewriter", 0, 1252}, + {0x3ff32662, L"Chiller-Regular", L"Papyrus,KufiStandardGK,Baghdad", 0, + 1252}, + {0x409de312, L"ModernNo.20", L"Avenir Next Condensed,Impact", 2, 1252}, + {0x41443c5e, L"Georgia", L".Helvetica Neue Desk UI,Arial Unicode MS", 2, + 1252}, + {0x4160ade5, L"BellGothicStdBlack", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x421976c4, L"Modern-Regular", L"Impact", 2, 1252}, + {0x422a7252, L"Stencil", L"STIXNonUnicode,Songti SC,Georgia,Baskerville", 0, + 1252}, + {0x42c8554f, L"Fixedsys", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x435cb41d, L"Roman", L"Arial Narrow", 0, 1252}, + {0x47882383, L"CourierNew", L"PCMyungjo,Osaka,Arial Unicode MS,Songti SC", + 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", + L"STIXNonUnicode,American Typewriter,Avenir Next Condensed Heavy", 0, + 1252}, + {0x480bf7a4, L"CourierStd", L"Courier New", 0, 1252}, + {0x481ad6ed, L"VladimirScript", + L"STIXNonUnicode,Avenir Next Condensed,Impact", 8, 1252}, + {0x4911577a, L"YouYuan", L"STHeiti,Heiti TC", 1, 936}, + {0x4a788d72, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, + {0x4bf88566, L"SegoeCondensed", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", + L"STIXNonUnicode,American Typewriter,Impact", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Arial Unicode MS,Heiti TC,STFangsong", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"Courier New,Andale Mono,Ayuthaya,PCMyungjo,Osaka", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x531b3dea, L"BasemicSymbol", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", L"Menlo,Courier New,Andale Mono", 0, + 1252}, + {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, + {0x5792e759, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Lucida Grande,Arial Unicode MS,Menlo", + 0, 1252}, + {0x594e2da4, L"Vrinda", L"Geeza Pro,Damascus,STIXGeneral,Gill Sans", 0, + 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"Avenir Next Condensed Heavy,PT Sans,Avenir Next Condensed", 0, 1252}, + {0x5e16ac91, L"TrajanPro", L"Arial Narrow,PT Sans Narrow,Damascus", 0, + 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"AppleMyungjo,AppleGothic,Arial Unicode MS", 0, 936}, + {0x5fefbfad, L"Batang", L"Arial Unicode MS,Songti SC", 2, 1252}, + {0x605342b9, L"DotumChe", L"Arial Unicode MS,Heiti TC", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti,Heiti TC", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black,Avenir Next Heavy", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Apple Braille,Geeza Pro,Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x630501a3, L"SmallFonts", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Damascus,STIXNonUnicode,Avenir Next Condensed,Avenir Next Condensed " + L"Ultra Light,Futura", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x696259b7, L"Corbel", L"Cochin,Baskerville,Marion", 0, 1252}, + {0x696ee9be, L"STXihei", L"STHeiti,Heiti TC,Songti SC,Arial Unicode MS", 0, + 936}, + {0x6c59cf69, L"Dotum", L"Arial Unicode MS,Songti SC", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Arial Unicode MS,Heiti TC", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"STIXSizeFourSym,STIXSizeThreeSym,STIXSizeTwoSym,STIXSizeOneSym", 0, + 1252}, + {0x71b41801, L"Verdana", + L"Tahoma,Marion,Apple Symbols,.Helvetica Neue Desk UI,Lucida " + L"Grande,Courier New", + 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Palatino,Arial Unicode MS", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x74001694, L"MyriadProBlack", L"Palatino,Baskerville,Marion,Cochin", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x74cb44ee, L"NSimSun", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Damascus,STIXNonUnicode,Arial Unicode MS,American Typewriter", 0, 1252}, + {0x788b3533, L"Webdings", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0x797dde99, L"MSSerif", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Apple SD Gothic Neo", + 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"STIXNonUnicode,Arial Unicode MS,Baskerville,Avenir Next Medium", 0, + 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Comic Sans MS,Avenir Next,Arial Rounded MT Bold", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", L"Heiti TC,STHeiti", 0, 936}, + {0x83581825, L"Modern", L"Avenir Next Condensed,Impact", 0, 1252}, + {0x835a2823, L"Algerian", + L"STIXNonUnicode,Baskerville,Avenir Next Medium,American Typewriter", 0, + 1252}, + {0x83dab9f5, L"Script", L"Arial Narrow", 0, 1252}, + {0x847b56da, L"Tahoma", L"Songti SC,Apple Symbols", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Arial Unicode MS,Songti SC", 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Nadeem,Al Bayan", 0, 1252}, + {0x8e8d43b2, L"Centaur", L"Avenir Next Condensed,Noteworthy,Impact", 2, + 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x90794800, L"BellGothicStdLight", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x909b516a, L"Century", L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", + 2, 1252}, + {0x92ae370d, L"MSOutlook", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"PT Sans Narrow,Papyrus,Kokonor,Geeza Pro,Arial Rounded MT Bold,Lucida " + L"Grande,Futura", + 2, 1252}, + {0x9565085e, L"BookAntiqua", L"Palatino,Microsoft Sans Serif,Apple Symbols", + 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"AHiragino Sans GB,Heiti TC,STHeiti", 0, + 949}, + {0x9bbadd6b, L"ColonnaMT", L"Noteworthy,Avenir Next Condensed,Impact", 0, + 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, + {0xa0607db1, L"GungsuhChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Heiti TC,STFangsong", + 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"Zapfino,Arial Black,STHeiti", 2, 1252}, + {0xa1429b36, L"Symbol", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"STIXNonUnicode,Arial Narrow,Avenir Next Condensed Demi Bold", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0xa8d83ece, L"CalifornianFB", + L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"STIXVariants,STIXSizeOneSym,Apple Braille", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"STIXNonUnicode,Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, + 1252}, + {0xade5337c, L"MSUIGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, + 1252}, + {0xb08dd941, L"WideLatin", + L"Marion,Papyrus,Nanum Pen Script,Zapf Dingbats,Damascus,Zapfino,Arial " + L"Black,STHeiti", + 2, 1252}, + {0xb12765e0, L"ITCLegacySansStdBook", + L"LastResort,.Helvetica Neue Desk UI,Arial Unicode MS,Palatino", 0, 1252}, + {0xb207f05d, L"PoorRichard", L"Noteworthy,Avenir Next Condensed,Impact", 2, + 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Nadeem,Al Bayan,STIXNonUnicode", 0, + 1252}, + {0xb5545399, L"Marlett", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", + L"Damascus,STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", L"STHeiti,Arial Black", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Microsoft Sans Serif,Apple Symbols", 2, + 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Heiti TC,STHeiti", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", + L"American Typewriter,Avenir Next Condensed Heavy", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0xc16c0118, L"AdobeHebrew", + L".Helvetica Neue Desk UI,Palatino,American Typewriter", 0, 1252}, + {0xc318b0af, L"MyriadProLight", L"Palatino,Baskerville,Marion", 0, 1252}, + {0xc65e5659, L"CambriaMath", L"Arial Unicode MS", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", L"Courier New,Menlo,Andale Mono", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Apple Symbols,HeadLineA", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", L"Lucida Grande", 0, 1252}, + {0xcca00cc5, L"System", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Lucida Grande", 0, 1252}, + {0xccc5818c, L"EuroSign", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0xcfe5755f, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, + 1252}, + {0xd060e7ef, L"Vivaldi", + L"STIXNonUnicode,Arial Unicode MS,Avenir Medium,Avenir Next Medium", 8, + 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Impact,Arial Narrow", 0, 1252}, + {0xd107243f, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0xd1881562, L"ArialNarrow", L"PT Sans Narrow,Apple Symbols", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", + L"Damascus,Georgia,.Helvetica Neue Desk UI,Lucida Grande,Arial Unicode MS", + 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"STIXNonUnicode,Arial Unicode MS,Avenir Next,Avenir", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"Impact,Avenir Next Condensed Demi Bold", 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Arial Narrow,Khmer MN,Kokonor,Damascus,Microsoft Sans Serif,Apple " + L"Symbols", + 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"STIXGeneral,.Helvetica Neue Desk UI,Trebuchet MS", 2, 1252}, + {0xda7e551e, L"STSong", L"Arial Unicode MS", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"STFangsong,Songti SC,STSong", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdaeb0713, L"STSong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdb00a3d9, L"Broadway", + L"Papyrus,STIXNonUnicode,Arial Black,Avenir Next Heavy,Heiti TC", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdb69595a, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdba0082c, L"STXihei", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", + L"STIXNonUnicode,Damascus,Songti SC,STSong", 8, 1252}, + {0xdcc7009c, L"Harrington", + L"STIXNonUnicode,Avenir Next Condensed Heavy,Noteworthy", 0, 1252}, + {0xdd712466, L"ArialBlack", L"Geeza Pro,Damascus,Songti SC,STSong", 0, + 1252}, + {0xdde87b3e, L"Impact", L"Arial Narrow,Marion", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Arial Narrow,PT Sans Narrow,Marion,STHeiti,Arial Black", 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, + {0xe0f705c0, L"KristenITC", L"Songti SC,STSong", 8, 1252}, + {0xe1427573, L"Raavi", + L"Damascus,STIXNonUnicode,Marion,Papyrus,Avenir Next Condensed " + L"Heavy,American Typewriter", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"STIXNonUnicode,Damascus,Geeza Pro,Lucida Grande,Georgia,Heiti TC", 0, + 1252}, + {0xe36a9e17, L"Ravie", L"STHeiti,Arial Black", 0, 1252}, + {0xe433f8e2, L"Parchment", L"Microsoft Sans Serif,Apple Symbols", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0xe4e2c405, L"MTExtra", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xe618cc35, L"InformalRoman", L"Arial Narrow", 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Apple Symbols", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 0, 1252}, + {0xec637b42, L"Consolas", + L"AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL UKai TW MBE,AR PL UMing " + L"CN,AR PL UMing HK,Microsoft Sans Serif,Tahoma", + 1, 1252}, + {0xed3a683b, L"STXinwei", L"Kaiti SC,Songti SC,", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Arial Narrow,Avenir Next Condensed Demi Bold,Avenir Next " + L"Condensed,Avenir Next Condensed Medium,STHeiti,Arial Black", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, + {0xf1028030, L"Mangal", + L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Tahoma", 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Papyrus,Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Arial Unicode MS,Arial Narrow,STIXNonUnicode,Damascus,Avenir Next " + L"Condensed Demi Bold,Avenir Next Condensed Medium,Avenir Next Condensed", + 0, 1252}, + {0xf477f16a, L"Latha", + L"Arial Narrow,Damascus,STIXNonUnicode,American Typewriter", 0, 1252}, + {0xf616f3dd, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Geeza Pro,Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black", 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Heiti TC,STHeiti", 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ +static const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"Droid Sans Fallback", 0, 936}, + {0x01e4f102, L"YouYuan", L"Droid Sans Fallback", 1, 936}, + {0x030549dc, L"LiSu", L"Droid Sans Fallback", 1, 936}, + {0x032edd44, L"Simhei", L"Droid Sans Fallback", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " + L"Naskh,Droid Sans Ethiopic", + 2, 1252}, + {0x03ed90e6, L"Nina", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"Droid Sans Thai,Droid Sans Armenian,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,Droid Sans Fallback", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Droid Sans Fallback", 0, 1252}, + {0x089b18a9, L"Arial", L"Droid Sans Fallback", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 2, 1252}, + {0x0bb469df, L"VinerHandITC", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Droid Sans Fallback", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 847}, + {0x0e7de0f9, L"Playbill", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x0eff47c3, L"STHupo", L"Droid Sans Fallback", 0, 936}, + {0x107ad374, L"Constantia", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x12194c2d, L"KunstlerScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x158c4049, L"Garamond", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, + {0x161ed07e, L"MSGothic", L"Droid Sans Fallback", 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x18d1188f, L"Cambria", L"Droid Sans Fallback", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Droid Sans Fallback", 0, 936}, + {0x1a92d115, L"MingLiU", L"Droid Sans Fallback", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x1d649596, L"BasemicTimes", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x1e34ee60, L"BellMT", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x1ef7787d, L"BatangChe", L"Droid Sans Fallback", 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, + 1252}, + {0x220877aa, L"Candara", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x251059c3, L"Chiller", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", L"Droid Sans Fallback", 0, 1252}, + {0x28154c81, L"Parchment-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x29711eb9, L"STLiti", L"Droid Sans Fallback", 0, 936}, + {0x2b1993b4, L"Basemic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c147529, L"FootlightMTLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x31327817, L"MyriadPro", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x32244975, L"Helvetica", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, + {0x32ac995c, L"Terminal", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x33bb65f2, L"Sylfaen", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Droid Sans Fallback", 2, 1252}, + {0x3412bf31, L"SimSun-PUA", L"Droid Sans Fallback", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x3cdae668, L"FreestyleScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x3d55aed7, L"Jokerman", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Droid Sans Fallback", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"Droid Sans Fallback", 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono,Droid Sans Fallback", + 0, 1252}, + {0x3ff32662, L"Chiller-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x409de312, L"ModernNo.20", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x41443c5e, L"Georgia", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x421976c4, L"Modern-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x422a7252, L"Stencil", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x42c8554f, L"Fixedsys", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x435cb41d, L"Roman", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x47882383, L"CourierNew", L"Droid Sans Fallback", 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x480bf7a4, L"CourierStd", L"Droid Sans Fallback", 0, 1252}, + {0x481ad6ed, L"VladimirScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x4911577a, L"YouYuan", L"Droid Sans Fallback", 1, 936}, + {0x4a788d72, L"STXingkai", L"Droid Sans Fallback", 0, 936}, + {0x4bf88566, L"SegoeCondensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Droid Sans Fallback", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Mono,Droid Serif,Droid Sans Fallback", + 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", + L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic", 0, 1252}, + {0x574d4d3d, L"AdobeArabic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5792e759, L"STKaiti", L"Droid Sans Fallback", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Fallback", 0, 1252}, + {0x594e2da4, L"Vrinda", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", L"Droid Sans Fallback", 0, 936}, + {0x5fefbfad, L"Batang", L"Droid Sans Fallback", 2, 1252}, + {0x605342b9, L"DotumChe", L"Droid Sans Fallback", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0x630501a3, L"SmallFonts", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono,Droid Sans Fallback", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x696259b7, L"Corbel", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x696ee9be, L"STXihei", L"Droid Sans Fallback", 0, 936}, + {0x6c59cf69, L"Dotum", L"Droid Sans Fallback", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Droid Sans Fallback", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"Droid Arabic Naskh,Droid Sans Armenian,Droid Sans Ethiopic,Droid Sans " + L"Georgian,Droid Sans Hebrew,Droid Sans Thai", + 0, 1252}, + {0x71b41801, L"Verdana", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Fallback", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x74cb44ee, L"NSimSun", L"Droid Sans Fallback", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x788b3533, L"Webdings", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0x797dde99, L"MSSerif", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", L"Droid Sans Fallback", 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", L"Droid Sans Fallback", 0, 936}, + {0x83581825, L"Modern", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x835a2823, L"Algerian", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x83dab9f5, L"Script", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x847b56da, L"Tahoma", L"Droid Sans Fallback", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"Droid Sans Fallback", 0, 1252}, + {0x8b5cac0e, L"Onyx", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Droid Sans Fallback", 0, 1252}, + {0x8e0af790, L"JuiceITC", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8e8d43b2, L"Centaur", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x90794800, L"BellGothicStdLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x909b516a, L"Century", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x92ae370d, L"MSOutlook", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0x9565085e, L"BookAntiqua", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"Droid Sans Fallback", 0, 949}, + {0x9bbadd6b, L"ColonnaMT", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, + {0x9d73008e, L"MSSansSerif", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xa0607db1, L"GungsuhChe", L"Droid Sans Fallback", 1, 1252}, + {0xa0bcf6a1, L"LatinWide", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xa1429b36, L"Symbol", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa1fa5abc, L"Wingdings2", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa1fa5abd, L"Wingdings3", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0xa8d83ece, L"CalifornianFB", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xade5337c, L"MSUIGothic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb08dd941, L"WideLatin", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0xb207f05d, L"PoorRichard", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xb3bc492f, L"JuiceITC-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb5545399, L"Marlett", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", L"Droid Arabic Naskh,Droid Sans Ethiopic", 0, + 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Droid Sans Fallback", 2, 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Droid Sans Fallback", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " + L"Naskh,Droid Sans Ethiopic", + 0, 1252}, + {0xc318b0af, L"MyriadProLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xc65e5659, L"CambriaMath", L"Droid Sans Fallback", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", + L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Droid Sans Fallback", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcca00cc5, L"System", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xccc5818c, L"EuroSign", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcfe5755f, L"Simhei", L"Droid Sans Fallback", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Droid Sans Fallback", 0, 1252}, + {0xd060e7ef, L"Vivaldi", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd107243f, L"SimSun", L"Droid Sans Fallback", 0, 936}, + {0xd1881562, L"ArialNarrow", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", L"Droid Serif,Roboto,Droid Sans Fallback", 8, + 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Droid Sans Fallback", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xda7e551e, L"STSong", L"Droid Sans Fallback", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Droid Sans Fallback", 0, 936}, + {0xdaeb0713, L"STSong", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, + {0xdb00a3d9, L"Broadway", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Droid Sans Fallback", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Droid Sans Fallback", 0, 936}, + {0xdb69595a, L"STHupo", L"Droid Sans Fallback", 0, 936}, + {0xdba0082c, L"STXihei", L"Droid Sans Fallback", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Droid Sans Fallback", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Droid Sans Fallback", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, + {0xdcc7009c, L"Harrington", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdd712466, L"ArialBlack", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdde87b3e, L"Impact", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Droid Serif,Roboto,Droid Serif,Droid Sans Mono", 0, 1252}, + {0xe0f705c0, L"KristenITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, + {0xe1427573, L"Raavi", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xe36a9e17, L"Ravie", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xe433f8e2, L"Parchment", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xe43dff4a, L"Wingdings", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0xe4e2c405, L"MTExtra", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xe618cc35, L"InformalRoman", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 8, 1252}, + {0xe6c27ffc, L"Mistral", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Droid Sans Fallback", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xec637b42, L"Consolas", L"Droid Sans Fallback", 1, 1252}, + {0xed3a683b, L"STXinwei", L"Droid Sans Fallback", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xf1028030, L"Mangal", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, + {0xf477f16a, L"Latha", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xf616f3dd, L"LiSu", L"Droid Sans Fallback", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Droid Sans Fallback", 0, 936}, +}; +#endif +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_ + FX_DWORD dwLocalNameHash = FX_HashCode_String_GetW( + wsLocalName.GetPtr(), wsLocalName.GetLength(), TRUE); + int32_t iStart = 0; + int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1; + int32_t iMid = 0; + do { + iMid = (iStart + iEnd) / 2; + FX_DWORD dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash; + if (dwFontNameHash == dwLocalNameHash) { + wsEnglishName = g_XFAFontsMap[iMid].pPsName; + break; + } else if (dwFontNameHash < dwLocalNameHash) { + iStart = iMid + 1; + } else { + 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; + wsFontNameTemp.Remove(L' '); + FX_DWORD dwCurFontNameHash = + FX_HashCode_String_GetW(wsFontNameTemp, wsFontNameTemp.GetLength(), TRUE); + int32_t iStart = 0; + int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1; + int32_t iMid = 0; + const XFA_FONTINFO* pFontInfo = NULL; + do { + iMid = (iStart + iEnd) / 2; + FX_DWORD dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash; + if (dwFontNameHash == dwCurFontNameHash) { + pFontInfo = &g_XFAFontsMap[iMid]; + break; + } else if (dwFontNameHash < dwCurFontNameHash) { + iStart = iMid + 1; + } else { + iEnd = iMid - 1; + } + } while (iEnd >= iStart); + return pFontInfo; +#else + return NULL; +#endif +} +// static +IXFA_FontMgr* IXFA_FontMgr::CreateDefault() { + return new CXFA_DefFontMgr; +} +// virtual +IXFA_FontMgr::~IXFA_FontMgr() {} +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(); +} + +IFX_Font* CXFA_DefFontMgr::GetFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + CFX_WideString wsFontName = wsFontFamily; + IFX_FontMgr* pFDEFontMgr = + static_cast<CXFA_FFDoc*>(hDoc)->GetApp()->GetFDEFontMgr(); + IFX_Font* pFont = pFDEFontMgr->LoadFont(wsFontName, dwFontStyles, wCodePage); + if (!pFont) { + const XFA_FONTINFO* pCurFont = XFA_GetFontINFOByFontName(wsFontName); + if (pCurFont && pCurFont->pReplaceFont) { + FX_DWORD dwStyle = 0; + if (dwFontStyles & FX_FONTSTYLE_Bold) { + dwStyle |= FX_FONTSTYLE_Bold; + } + if (dwFontStyles & FX_FONTSTYLE_Italic) { + dwStyle |= FX_FONTSTYLE_Italic; + } + const FX_WCHAR* pReplace = pCurFont->pReplaceFont; + int32_t iLength = FXSYS_wcslen(pReplace); + while (iLength > 0) { + const FX_WCHAR* pNameText = pReplace; + while (*pNameText != L',' && iLength > 0) { + pNameText++; + iLength--; + } + CFX_WideString wsReplace = + CFX_WideString(pReplace, pNameText - pReplace); + pFont = pFDEFontMgr->LoadFont(wsReplace, dwStyle, wCodePage); + if (pFont) { + break; + } + iLength--; + pNameText++; + pReplace = pNameText; + } + } + } + if (pFont) { + m_CacheFonts.Add(pFont); + } + return pFont; +} + +IFX_Font* CXFA_DefFontMgr::GetDefaultFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + IFX_FontMgr* pFDEFontMgr = ((CXFA_FFDoc*)hDoc)->GetApp()->GetFDEFontMgr(); + IFX_Font* pFont = + pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); + if (!pFont) + pFont = + pFDEFontMgr->LoadFont((const FX_WCHAR*)NULL, dwFontStyles, wCodePage); + FXSYS_assert(pFont); + if (pFont) { + m_CacheFonts.Add(pFont); + } + return pFont; +} +struct XFA_PDFFONTNAME { + const FX_CHAR* lpPsName; + const FX_CHAR* lpNormal; + const FX_CHAR* lpBold; + const FX_CHAR* lpItalic; + const FX_CHAR* lpBoldItalic; +}; +const XFA_PDFFONTNAME g_XFAPDFFontName[] = { + {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"}, + {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold", + "MyriadPro-LightIt", "MyriadPro-SemiboldIt"}, +}; +CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) { + m_pDoc = pDoc; +} +CXFA_PDFFontMgr::~CXFA_PDFFontMgr() { + m_FDE2PDFFont.RemoveAll(); + for (const auto& pair : m_FontMap) { + if (pair.second) + pair.second->Release(); + } +} +IFX_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, + FX_BOOL bBold, + FX_BOOL bItalic, + CPDF_Font** pDstPDFFont, + FX_BOOL bStrictMatch) { + CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); + if (pDoc == NULL) { + return NULL; + } + CPDF_Dictionary* pFontSetDict = + pDoc->GetRoot()->GetDictBy("AcroForm")->GetDictBy("DR"); + if (!pFontSetDict) { + return NULL; + } + pFontSetDict = (CPDF_Dictionary*)pFontSetDict->GetDictBy("Font"); + if (!pFontSetDict) { + return NULL; + } + strPsName.Remove(' '); + IFX_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); + for (const auto& it : *pFontSetDict) { + const CFX_ByteString& key = it.first; + CPDF_Object* pObj = it.second; + if (!PsNameMatchDRFontName(strPsName, bBold, bItalic, key, bStrictMatch)) { + continue; + } + CPDF_Object* pDirect = pObj->GetDirect(); + if (!pDirect || !pDirect->IsDictionary()) { + return NULL; + } + CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)pDirect; + if (pFontDict->GetStringBy("Type") != "Font") { + return NULL; + } + CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); + if (!pPDFFont) { + return NULL; + } + if (!pPDFFont->IsEmbedded()) { + *pDstPDFFont = pPDFFont; + return NULL; + } + return IFX_Font::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); + } + return NULL; +} +IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch) { + FX_DWORD dwHashCode = + FX_HashCode_String_GetW(wsFontFamily.GetPtr(), wsFontFamily.GetLength()); + 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); + 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); + IFX_Font* pFont = + FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); + if (pFont) + m_FontMap[strKey] = pFont; + return pFont; +} +CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName( + const CFX_ByteString& strPsName, + FX_BOOL bBold, + FX_BOOL bItalic) { + int32_t nCount = sizeof(g_XFAPDFFontName) / sizeof(XFA_PDFFONTNAME); + for (int32_t i = 0; i < nCount; i++) { + if (strPsName == g_XFAPDFFontName[i].lpPsName) { + int32_t index = 1 + ((bItalic << 1) | bBold); + return *(&g_XFAPDFFontName[i].lpPsName + index); + } + } + return strPsName; +} +FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( + const CFX_ByteStringC& bsPsName, + FX_BOOL bBold, + FX_BOOL bItalic, + const CFX_ByteString& bsDRFontName, + FX_BOOL bStrictMatch) { + CFX_ByteString bsDRName = bsDRFontName; + bsDRName.Remove('-'); + int32_t iPsLen = bsPsName.GetLength(); + int32_t nIndex = bsDRName.Find(bsPsName); + if (nIndex != -1 && !bStrictMatch) { + return TRUE; + } + if (nIndex != 0) { + return FALSE; + } + int32_t iDifferLength = bsDRName.GetLength() - iPsLen; + if (iDifferLength > 1 || (bBold || bItalic)) { + int32_t iBoldIndex = bsDRName.Find("Bold"); + FX_BOOL bBoldFont = iBoldIndex > 0; + if (bBold ^ bBoldFont) { + return FALSE; + } + if (bBoldFont) { + iDifferLength = + std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); + } + FX_BOOL bItalicFont = TRUE; + if (bsDRName.Find("Italic") > 0) { + iDifferLength -= 6; + } else if (bsDRName.Find("It") > 0) { + iDifferLength -= 2; + } else if (bsDRName.Find("Oblique") > 0) { + iDifferLength -= 7; + } else { + bItalicFont = FALSE; + } + if (bItalic ^ bItalicFont) { + return FALSE; + } + if (iDifferLength > 1) { + CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength); + if (bsDRTailer.Equal("MT") || bsDRTailer.Equal("PSMT") || + bsDRTailer.Equal("Regular") || bsDRTailer.Equal("Reg")) { + return TRUE; + } + if (bBoldFont || bItalicFont) { + return FALSE; + } + FX_BOOL bMatch = FALSE; + switch (bsPsName.GetAt(iPsLen - 1)) { + case 'L': { + if (bsDRName.Right(5).Equal("Light")) { + bMatch = TRUE; + } + } break; + case 'R': { + if (bsDRName.Right(7).Equal("Regular") || + bsDRName.Right(3).Equal("Reg")) { + bMatch = TRUE; + } + } break; + case 'M': { + if (bsDRName.Right(5).Equal("Medium")) { + bMatch = TRUE; + } + } break; + default: + break; + } + return bMatch; + } + } + return TRUE; +} +FX_BOOL CXFA_PDFFontMgr::GetCharWidth(IFX_Font* pFont, + FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode) { + if (wUnicode != 0x20 || bCharCode) { + return FALSE; + } + CPDF_Font* pPDFFont = (CPDF_Font*)m_FDE2PDFFont.GetValueAt(pFont); + if (!pPDFFont) { + return FALSE; + } + wUnicode = (FX_WCHAR)pPDFFont->CharCodeFromUnicode(wUnicode); + iWidth = pPDFFont->GetCharWidthF(wUnicode); + return TRUE; +} +CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(NULL) {} +CXFA_FontMgr::~CXFA_FontMgr() { + DelAllMgrMap(); +} +IFX_Font* CXFA_FontMgr::GetFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage) { + FX_DWORD dwHash = FX_HashCode_String_GetW(wsFontFamily.GetPtr(), + wsFontFamily.GetLength(), FALSE); + CFX_ByteString bsKey; + bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); + auto it = m_FontMap.find(bsKey); + if (it != m_FontMap.end()) + return it->second; + CFX_WideString wsEnglishName; + XFA_LocalFontNameToEnglishName(wsFontFamily, wsEnglishName); + CXFA_PDFFontMgr* pMgr = (CXFA_PDFFontMgr*)m_PDFFontMgrArray.GetValueAt(hDoc); + CPDF_Font* pPDFFont = NULL; + IFX_Font* pFont = NULL; + if (pMgr) { + pFont = pMgr->GetFont(wsEnglishName, dwFontStyles, &pPDFFont); + if (pFont) + return pFont; + } + if (!pFont && m_pDefFontMgr) { + pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); + } + if (!pFont && pMgr) { + pPDFFont = NULL; + pFont = pMgr->GetFont(wsEnglishName, dwFontStyles, &pPDFFont, FALSE); + if (pFont) + return pFont; + } + if (!pFont && m_pDefFontMgr) { + pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, + wCodePage); + } + if (pFont) { + if (pPDFFont) { + pMgr->m_FDE2PDFFont.SetAt(pFont, pPDFFont); + pFont->SetFontProvider(pMgr); + } + m_FontMap[bsKey] = pFont; + } + return pFont; +} +void CXFA_FontMgr::LoadDocFonts(IXFA_Doc* hDoc) { + if (!m_PDFFontMgrArray.GetValueAt(hDoc)) { + m_PDFFontMgrArray.SetAt(hDoc, new CXFA_PDFFontMgr((CXFA_FFDoc*)hDoc)); + } +} +void CXFA_FontMgr::ReleaseDocFonts(IXFA_Doc* hDoc) { + CXFA_PDFFontMgr* pMgr = NULL; + if (m_PDFFontMgrArray.Lookup(hDoc, (void*&)pMgr)) { + delete pMgr; + m_PDFFontMgrArray.RemoveKey(hDoc); + } +} +void CXFA_FontMgr::DelAllMgrMap() { + FX_POSITION ps = m_PDFFontMgrArray.GetStartPosition(); + while (ps) { + IXFA_Doc* hDoc = NULL; + CXFA_PDFFontMgr* pMgr = NULL; + m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); + delete pMgr; + } + m_PDFFontMgrArray.RemoveAll(); + m_FontMap.clear(); +} +void CXFA_FontMgr::SetDefFontMgr(IXFA_FontMgr* pFontMgr) { + m_pDefFontMgr = pFontMgr; +} diff --git a/xfa/fxfa/app/xfa_fontmgr.h b/xfa/fxfa/app/xfa_fontmgr.h new file mode 100644 index 0000000000..44360796e9 --- /dev/null +++ b/xfa/fxfa/app/xfa_fontmgr.h @@ -0,0 +1,100 @@ +// 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_APP_XFA_FONTMGR_H_ +#define XFA_FXFA_APP_XFA_FONTMGR_H_ + +#include <map> + +#include "core/include/fxcrt/fx_ext.h" +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fgas/font/fgas_font.h" +#include "xfa/include/fxfa/fxfa.h" + +class CPDF_Font; + +struct XFA_FONTINFO { + FX_DWORD dwFontNameHash; + const FX_WCHAR* pPsName; + const FX_WCHAR* pReplaceFont; + FX_WORD dwStyles; + FX_WORD wCodePage; +}; + +class CXFA_DefFontMgr : public IXFA_FontMgr { + public: + CXFA_DefFontMgr() {} + ~CXFA_DefFontMgr() override; + + // IXFA_FontMgr: + IFX_Font* GetFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF) override; + IFX_Font* GetDefaultFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF) override; + + protected: + CFX_PtrArray m_CacheFonts; +}; + +class CXFA_PDFFontMgr : public IFX_FontProvider { + public: + CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); + ~CXFA_PDFFontMgr(); + IFX_Font* GetFont(const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch = TRUE); + FX_BOOL GetCharWidth(IFX_Font* pFont, + FX_WCHAR wUnicode, + int32_t& iWidth, + FX_BOOL bCharCode); + CFX_MapPtrToPtr m_FDE2PDFFont; + + protected: + IFX_Font* FindFont(CFX_ByteString strFamilyName, + FX_BOOL bBold, + FX_BOOL bItalic, + CPDF_Font** pPDFFont, + FX_BOOL bStrictMatch = TRUE); + CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, + FX_BOOL bBold, + FX_BOOL bItalic); + FX_BOOL PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, + FX_BOOL bBold, + FX_BOOL bItalic, + const CFX_ByteString& bsDRFontName, + FX_BOOL bStrictMatch = TRUE); + + CXFA_FFDoc* m_pDoc; + std::map<CFX_ByteString, IFX_Font*> m_FontMap; +}; + +class CXFA_FontMgr { + public: + CXFA_FontMgr(); + ~CXFA_FontMgr(); + IFX_Font* GetFont(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFontFamily, + FX_DWORD dwFontStyles, + FX_WORD wCodePage = 0xFFFF); + void LoadDocFonts(IXFA_Doc* hDoc); + void ReleaseDocFonts(IXFA_Doc* hDoc); + + void SetDefFontMgr(IXFA_FontMgr* pFontMgr); + + protected: + void DelAllMgrMap(); + + CFX_MapPtrToPtr m_PDFFontMgrArray; + IXFA_FontMgr* m_pDefFontMgr; + std::map<CFX_ByteString, IFX_Font*> m_FontMap; +}; + +#endif // XFA_FXFA_APP_XFA_FONTMGR_H_ diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp new file mode 100644 index 0000000000..1e6010e0c9 --- /dev/null +++ b/xfa/fxfa/app/xfa_fwladapter.cpp @@ -0,0 +1,61 @@ +// 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/fxfa/app/xfa_fwladapter.h" + +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" + +void FWL_PostMessageToMainRoop(CFWL_Message* pMessage) {} +FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, + FX_BOOL bVisible, + const CFX_RectF* pRtAnchor) { + CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget); + if (!pXFAWidget) { + return FALSE; + } + IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider(); + if (!pDocProvider) { + return FALSE; + } + if (bVisible) { + CFX_Matrix mt; + pXFAWidget->GetRotateMatrix(mt); + CFX_RectF rt(*pRtAnchor); + mt.TransformRect(rt); + pDocProvider->DisplayCaret(pXFAWidget, bVisible, &rt); + return TRUE; + } + pDocProvider->DisplayCaret(pXFAWidget, bVisible, pRtAnchor); + return TRUE; +} + +FWL_ERR CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget, + const CFX_RectF* pRect) { + if (!pWidget) + return FWL_ERR_Indefinite; + CXFA_FFField* pField = (CXFA_FFField*)pWidget->GetPrivateData(pWidget); + if (!pField) + return FWL_ERR_Indefinite; + pField->AddInvalidateRect(nullptr); + return FWL_ERR_Succeeded; +} + +FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, + FX_FLOAT fMinHeight, + FX_FLOAT fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + CXFA_FFWidget* pFFWidget = (CXFA_FFWidget*)(pWidget->GetPrivateData(pWidget)); + CFX_Matrix mt; + pFFWidget->GetRotateMatrix(mt); + CFX_RectF rtRotateAnchor(rtAnchor); + mt.TransformRect(rtRotateAnchor); + pFFWidget->GetDoc()->GetDocProvider()->GetPopupPos( + pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); + return TRUE; +} diff --git a/xfa/fxfa/app/xfa_fwladapter.h b/xfa/fxfa/app/xfa_fwladapter.h new file mode 100644 index 0000000000..bf9a3d6c8e --- /dev/null +++ b/xfa/fxfa/app/xfa_fwladapter.h @@ -0,0 +1,22 @@ +// 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_APP_XFA_FWLADAPTER_H_ +#define XFA_FXFA_APP_XFA_FWLADAPTER_H_ + +#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" + +class CXFA_FWLAdapterWidgetMgr : public CFWL_SDAdapterWidgetMgr { + 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); +}; + +#endif // XFA_FXFA_APP_XFA_FWLADAPTER_H_ diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp new file mode 100644 index 0000000000..b0657ee8e4 --- /dev/null +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -0,0 +1,424 @@ +// 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/fxfa/app/xfa_fwltheme.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fwl/basewidget/fwl_barcode.h" +#include "xfa/include/fwl/basewidget/fwl_caret.h" +#include "xfa/include/fwl/basewidget/fwl_checkbox.h" +#include "xfa/include/fwl/basewidget/fwl_combobox.h" +#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" +#include "xfa/include/fwl/basewidget/fwl_edit.h" +#include "xfa/include/fwl/basewidget/fwl_listbox.h" +#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" +#include "xfa/include/fwl/basewidget/fwl_picturebox.h" +#include "xfa/include/fwl/basewidget/fwl_pushbutton.h" +#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" + +CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { + IFWL_Widget* pOuter = pWidget; + while (pOuter->GetOuter()) { + pOuter = pOuter->GetOuter(); + } + if (pOuter) { + return (CXFA_FFWidget*)pOuter->GetPrivateData(pOuter); + } + return NULL; +} +CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { + m_pTextOut = NULL; + m_dwCapacity = 0; + m_fCapacity = 0; + m_pCalendarFont = NULL; + m_Rect.Set(0, 0, 0, 0); + m_pCheckBoxTP = new CXFA_FWLCheckBoxTP; + m_pListBoxTP = new CFWL_ListBoxTP; + m_pPictureBoxTP = new CFWL_PictureBoxTP; + m_pSrollBarTP = new CFWL_ScrollBarTP; + m_pEditTP = new CXFA_FWLEditTP; + m_pComboBoxTP = new CFWL_ComboBoxTP; + m_pMonthCalendarTP = new CFWL_MonthCalendarTP; + m_pDateTimePickerTP = new CFWL_DateTimePickerTP; + m_pPushButtonTP = new CFWL_PushButtonTP; + m_pCaretTP = new CFWL_CaretTP; + m_pBarcodeTP = new CFWL_BarcodeTP; + Initialize(); +} +CXFA_FWLTheme::~CXFA_FWLTheme() { + Finalize(); + delete m_pCheckBoxTP; + delete m_pListBoxTP; + delete m_pPictureBoxTP; + delete m_pSrollBarTP; + delete m_pEditTP; + delete m_pComboBoxTP; + delete m_pMonthCalendarTP; + delete m_pDateTimePickerTP; + delete m_pPushButtonTP; + delete m_pCaretTP; + delete m_pBarcodeTP; +} +static const FX_WCHAR* g_FWLTheme_CalFonts[] = { + L"Arial", L"Courier New", L"DejaVu Sans", +}; +FWL_ERR CXFA_FWLTheme::Initialize() { + m_pTextOut = IFDE_TextOut::Create(); + 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, + m_pApp->GetFDEFontMgr()); + } + if (!m_pCalendarFont) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( + FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); +#else + m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( + FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); +#endif + } + + FXSYS_assert(NULL != m_pCalendarFont); + FWLTHEME_Init(); + return FWL_ERR_Succeeded; +} +FWL_ERR CXFA_FWLTheme::Finalize() { + if (m_pTextOut) { + m_pTextOut->Release(); + m_pTextOut = NULL; + } + if (m_pCalendarFont) { + m_pCalendarFont->Release(); + m_pCalendarFont = NULL; + } + FWLTHEME_Release(); + return FWL_ERR_Succeeded; +} +FX_BOOL CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) { + return TRUE; +} +FX_DWORD CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) { + return 0; +} +FX_DWORD CXFA_FWLTheme::SetThemeID(IFWL_Widget* pWidget, + FX_DWORD 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) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) { + return FWL_ERR_Indefinite; + } + 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) && + !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && + (pParams->m_dwStates & + (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } + if (pParams->m_iPart == FWL_PART_MCD_Caption) { + if (m_pMonthCalendarTP->GetThemeID(pParams->m_pWidget) == 0) { + m_pTextOut->SetTextColor(ArgbEncode(0xff, 0, 153, 255)); + } else { + m_pTextOut->SetTextColor(ArgbEncode(0xff, 128, 128, 0)); + } + } + CFX_Graphics* pGraphics = pParams->m_pGraphics; + CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); + if (!pRenderDevice) + return FALSE; + m_pTextOut->SetRenderDevice(pRenderDevice); + CFX_Matrix mtPart = pParams->m_matrix; + CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + if (pMatrix) { + mtPart.Concat(*pMatrix); + } + m_pTextOut->SetMatrix(mtPart); + m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(), + pParams->m_rtPart); + return TRUE; + } + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) { + return FWL_ERR_Indefinite; + } + CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); + CFX_Graphics* pGraphics = pParams->m_pGraphics; + CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); + if (!pRenderDevice) + return FALSE; + m_pTextOut->SetRenderDevice(pRenderDevice); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetFont(pAcc->GetFDEFont()); + m_pTextOut->SetFontSize(pAcc->GetFontSize()); + m_pTextOut->SetTextColor(pAcc->GetTextColor()); + CFX_Matrix mtPart = pParams->m_matrix; + CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + if (pMatrix) { + mtPart.Concat(*pMatrix); + } + m_pTextOut->SetMatrix(mtPart); + m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(), + pParams->m_rtPart); + return TRUE; +} +void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart, + FX_DWORD dwCapacity) { + switch (dwCapacity) { + case FWL_WGTCAPACITY_Font: { + if (CXFA_FFWidget* pWidget = + XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + return pWidget->GetDataAcc()->GetFDEFont(); + } + } break; + case FWL_WGTCAPACITY_FontSize: { + if (CXFA_FFWidget* pWidget = + XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + m_fCapacity = pWidget->GetDataAcc()->GetFontSize(); + return &m_fCapacity; + } + } break; + case FWL_WGTCAPACITY_TextColor: { + if (CXFA_FFWidget* pWidget = + XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + m_dwCapacity = pWidget->GetDataAcc()->GetTextColor(); + return &m_dwCapacity; + } + } break; + case FWL_WGTCAPACITY_LineHeight: { + if (CXFA_FFWidget* pWidget = + XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + m_fCapacity = pWidget->GetDataAcc()->GetLineHeight(); + return &m_fCapacity; + } + } break; + case FWL_WGTCAPACITY_ScrollBarWidth: { + m_fCapacity = 9; + return &m_fCapacity; + } break; + case FWL_WGTCAPACITY_UIMargin: { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); + if (pWidget) { + CXFA_LayoutItem* pItem = pWidget; + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + pWidgetAcc->GetUIMargin(m_Rect); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + m_Rect.left += para.GetMarginLeft(); + if (pWidgetAcc->IsMultiLine()) { + m_Rect.width += para.GetMarginRight(); + } + } + if (pItem->GetPrev() == NULL) { + if (pItem->GetNext()) { + m_Rect.height = 0; + } + } else if (pItem->GetNext() == NULL) { + m_Rect.top = 0; + } else { + m_Rect.top = 0; + m_Rect.height = 0; + } + } + return &m_Rect; + } break; + case FWL_WGTCAPACITY_SpaceAboveBelow: { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); + if (pWidget) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + m_SizeAboveBelow.x = para.GetSpaceAbove(); + m_SizeAboveBelow.y = para.GetSpaceBelow(); + } + } + return &m_SizeAboveBelow; + } break; + default: + break; + } + if (pThemePart->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar && + dwCapacity >= FWL_MCCAPACITY_Sun && dwCapacity <= FWL_MCCAPACITY_Today) { + 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; + } + } + } + return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); +} +FX_BOOL CXFA_FWLTheme::IsCustomizedLayout(IFWL_Widget* pWidget) { + return GetTheme(pWidget)->IsCustomizedLayout(pWidget); +} +FWL_ERR CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) { + CFX_RectF rect; + return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rect); +} +FX_BOOL CXFA_FWLTheme::IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy) { + 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) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) { + return FWL_ERR_Indefinite; + } + if (!pParams) + return FALSE; + if (!m_pTextOut) + return FALSE; + m_pTextOut->SetFont(m_pCalendarFont); + m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); + 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); + return TRUE; + } + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) { + return FWL_ERR_Indefinite; + } + 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); + return TRUE; +} +CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) { + switch (pWidget->GetClassID()) { + case FWL_CLASSHASH_CheckBox: + return m_pCheckBoxTP; + case FWL_CLASSHASH_ListBox: + return m_pListBoxTP; + case FWL_CLASSHASH_PictureBox: + return m_pPictureBoxTP; + case FWL_CLASSHASH_ScrollBar: + return m_pSrollBarTP; + case FWL_CLASSHASH_Edit: + return m_pEditTP; + case FWL_CLASSHASH_ComboBox: + return m_pComboBoxTP; + case FWL_CLASSHASH_MonthCalendar: + return m_pMonthCalendarTP; + case FWL_CLASSHASH_DateTimePicker: + return m_pDateTimePickerTP; + case FWL_CLASSHASH_PushButton: + return m_pPushButtonTP; + case FWL_CLASSHASH_Caret: + return m_pCaretTP; + case FWL_CLASSHASH_Barcode: + return m_pBarcodeTP; + default: + break; + } + return NULL; +} +CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {} +FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (pParams->m_iPart != FWL_PART_CKB_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)) { + DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, + pParams->m_dwStates, &pParams->m_matrix); + } + return TRUE; +} +void CXFA_FWLCheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + int32_t iState, + CFX_Matrix* pMatrix) { + CFX_RectF rtSign(*pRtBox); + FX_DWORD dwColor = 0xFF000000; + if ((iState & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) { + dwColor = 0xFFA9A9A9; + } + { + FX_DWORD dwStyle = pWidget->GetStylesEx(); + rtSign.Deflate(rtSign.width / 4, rtSign.height / 4); + switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { + case FWL_STYLEEXT_CKB_SignShapeCheck: + DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeCircle: + DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeCross: + DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeDiamond: + DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeSquare: + DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeStar: + DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); + break; + default: + break; + } + } +} +CXFA_FWLEditTP::CXFA_FWLEditTP() {} +CXFA_FWLEditTP::~CXFA_FWLEditTP() {} +FX_BOOL CXFA_FWLEditTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (FWL_PART_EDT_CombTextLine == pParams->m_iPart) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + FX_ARGB cr = 0xFF000000; + FX_FLOAT fWidth = 1.0f; + if (CXFA_Border borderUI = pWidget->GetDataAcc()->GetUIBorder()) { + CXFA_Edge edge = borderUI.GetEdge(0); + if (edge) { + cr = edge.GetColor(); + fWidth = edge.GetThickness(); + } + } + CFX_Color crLine(cr); + pParams->m_pGraphics->SetStrokeColor(&crLine); + pParams->m_pGraphics->SetLineWidth(fWidth); + pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); + return TRUE; + } + return CFWL_EditTP::DrawBackground(pParams); +} diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h new file mode 100644 index 0000000000..aab8099a88 --- /dev/null +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -0,0 +1,110 @@ +// 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_APP_XFA_FWLTHEME_H_ +#define XFA_FXFA_APP_XFA_FWLTHEME_H_ + +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/include/fwl/core/fwl_target.h" +#include "xfa/include/fwl/core/fwl_theme.h" +#include "xfa/include/fwl/theme/barcodetp.h" +#include "xfa/include/fwl/theme/carettp.h" +#include "xfa/include/fwl/theme/checkboxtp.h" +#include "xfa/include/fwl/theme/comboboxtp.h" +#include "xfa/include/fwl/theme/datetimepickertp.h" +#include "xfa/include/fwl/theme/edittp.h" +#include "xfa/include/fwl/theme/listboxtp.h" +#include "xfa/include/fwl/theme/monthcalendartp.h" +#include "xfa/include/fwl/theme/pictureboxtp.h" +#include "xfa/include/fwl/theme/pushbuttontp.h" +#include "xfa/include/fwl/theme/scrollbartp.h" +#include "xfa/include/fwl/theme/widgettp.h" + +class CXFA_FWLTheme : public IFWL_ThemeProvider { + public: + CXFA_FWLTheme(CXFA_FFApp* pApp); + virtual ~CXFA_FWLTheme(); + virtual FWL_ERR Release() { + delete this; + return FWL_ERR_Succeeded; + } + virtual IFWL_Target* Retain() { return NULL; } + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { + return FWL_ERR_Succeeded; + } + virtual FX_DWORD GetHashCode() const { return 0; } + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_DWORD GetThemeID(IFWL_Widget* pWidget); + virtual FX_DWORD SetThemeID(IFWL_Widget* pWidget, + FX_DWORD 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, FX_DWORD dwCapacity); + virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget); + virtual FWL_ERR 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_ERR SetThemeMatrix(IFWL_Widget* pWidget, + const CFX_Matrix& matrix) { + return FWL_ERR_Succeeded; + } + virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { + return FWL_ERR_Succeeded; + } + + protected: + CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget); + CFWL_CheckBoxTP* m_pCheckBoxTP; + CFWL_ListBoxTP* m_pListBoxTP; + CFWL_PictureBoxTP* m_pPictureBoxTP; + CFWL_ScrollBarTP* m_pSrollBarTP; + CFWL_EditTP* m_pEditTP; + CFWL_ComboBoxTP* m_pComboBoxTP; + CFWL_MonthCalendarTP* m_pMonthCalendarTP; + CFWL_DateTimePickerTP* m_pDateTimePickerTP; + CFWL_PushButtonTP* m_pPushButtonTP; + CFWL_CaretTP* m_pCaretTP; + CFWL_BarcodeTP* m_pBarcodeTP; + IFDE_TextOut* m_pTextOut; + FX_FLOAT m_fCapacity; + FX_DWORD m_dwCapacity; + IFX_Font* m_pCalendarFont; + CFX_WideString m_wsResource; + CXFA_FFApp* m_pApp; + CFX_RectF m_Rect; + CFX_SizeF m_SizeAboveBelow; +}; +class CXFA_FWLCheckBoxTP : public CFWL_CheckBoxTP { + public: + CXFA_FWLCheckBoxTP(); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + + protected: + void DrawCheckSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + int32_t iState, + CFX_Matrix* pMatrix); +}; +class CXFA_FWLEditTP : public CFWL_EditTP { + public: + CXFA_FWLEditTP(); + virtual ~CXFA_FWLEditTP(); + + public: + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); +}; + +#endif // XFA_FXFA_APP_XFA_FWLTHEME_H_ diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp new file mode 100644 index 0000000000..5b5cf48a87 --- /dev/null +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -0,0 +1,77 @@ +// 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/fxfa/app/xfa_rendercontext.h" + +#include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/include/fxgraphics/fx_graphics.h" + +#define XFA_RENDERCONTEXT_MaxCount 30 + +IXFA_RenderContext* XFA_RenderContext_Create() { + return new CXFA_RenderContext; +} +CXFA_RenderContext::CXFA_RenderContext() { + m_pWidgetIterator = NULL; + m_pWidget = NULL; + m_pPageView = NULL; + m_pGS = NULL; + m_dwStatus = 0; + m_matrix.SetIdentity(); + m_rtClipRect.Reset(); +} +CXFA_RenderContext::~CXFA_RenderContext() { + StopRender(); +} +int32_t CXFA_RenderContext::StartRender(IXFA_PageView* pPageView, + CFX_Graphics* pGS, + const CFX_Matrix& matrix, + const CXFA_RenderOptions& options) { + m_pPageView = pPageView; + m_pGS = pGS; + m_matrix = matrix; + m_options = options; + CFX_RectF rtPage; + pGS->GetClipRect(rtPage); + CFX_Matrix mtRes; + 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; + FX_DWORD dwFilterType = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_AllType | + (m_options.m_bPrint ? XFA_WIDGETSTATUS_Printable + : XFA_WIDGETSTATUS_Viewable); + m_pWidgetIterator = + m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType); + m_pWidget = m_pWidgetIterator->MoveToNext(); + return XFA_RENDERSTATUS_Ready; +} +int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { + int32_t iCount = 0; + while (m_pWidget) { + CXFA_FFWidget* pWidget = (CXFA_FFWidget*)m_pWidget; + CFX_RectF rtWidgetBox; + pWidget->GetBBox(rtWidgetBox, XFA_WIDGETSTATUS_Visible); + rtWidgetBox.width += 1; + rtWidgetBox.height += 1; + if (rtWidgetBox.IntersectWith(m_rtClipRect)) { + pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus); + } + m_pWidget = m_pWidgetIterator->MoveToNext(); + iCount++; + if (iCount > XFA_RENDERCONTEXT_MaxCount && pPause && + pPause->NeedToPauseNow()) { + return XFA_RENDERSTATUS_ToBeContinued; + } + } + return XFA_RENDERSTATUS_Done; +} +void CXFA_RenderContext::StopRender() { + if (m_pWidgetIterator) { + m_pWidgetIterator->Release(); + m_pWidgetIterator = NULL; + } +} diff --git a/xfa/fxfa/app/xfa_rendercontext.h b/xfa/fxfa/app/xfa_rendercontext.h new file mode 100644 index 0000000000..ef4b3069a6 --- /dev/null +++ b/xfa/fxfa/app/xfa_rendercontext.h @@ -0,0 +1,35 @@ +// 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_APP_XFA_RENDERCONTEXT_H_ +#define XFA_FXFA_APP_XFA_RENDERCONTEXT_H_ + +#include "xfa/include/fxfa/fxfa.h" + +class CXFA_RenderContext : public IXFA_RenderContext { + public: + CXFA_RenderContext(); + virtual ~CXFA_RenderContext(); + virtual void Release() { delete this; } + virtual int32_t StartRender(IXFA_PageView* pPageView, + CFX_Graphics* pGS, + const CFX_Matrix& matrix, + const CXFA_RenderOptions& options); + virtual int32_t DoRender(IFX_Pause* pPause = NULL); + virtual void StopRender(); + + protected: + IXFA_WidgetIterator* m_pWidgetIterator; + IXFA_Widget* m_pWidget; + IXFA_PageView* m_pPageView; + CFX_Graphics* m_pGS; + CFX_Matrix m_matrix; + CXFA_RenderOptions m_options; + FX_DWORD m_dwStatus; + CFX_RectF m_rtClipRect; +}; + +#endif // XFA_FXFA_APP_XFA_RENDERCONTEXT_H_ diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp new file mode 100644 index 0000000000..05316f8784 --- /dev/null +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -0,0 +1,2001 @@ +// 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/fxfa/app/xfa_textlayout.h" + +#include <algorithm> + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fde/fde_pen.h" +#include "xfa/fgas/crt/fgas_algorithm.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fxfa/app/xfa_ffapp.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/app/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, + int32_t iDeclCount) { + if (iDeclCount <= 0 || ppDeclArray == NULL) { + return; + } + m_dwMatchedDecls = iDeclCount; + m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount); + FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, + iDeclCount * sizeof(IFDE_CSSDeclaration*)); +} +CXFA_TextParser::~CXFA_TextParser() { + if (m_pUASheet) + m_pUASheet->Release(); + if (m_pSelector) + m_pSelector->Release(); + if (m_pAllocator) + m_pAllocator->Release(); + FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); + while (ps) { + IFDE_XMLNode* pXMLNode; + CXFA_TextParseContext* pParseContext; + m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); + if (pParseContext) + FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); + } + m_mapXMLNodeToParseContext.RemoveAll(); +} +void CXFA_TextParser::Reset() { + FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); + while (ps) { + IFDE_XMLNode* pXMLNode; + CXFA_TextParseContext* pParseContext; + m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); + if (pParseContext) + FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); + } + m_mapXMLNodeToParseContext.RemoveAll(); + if (m_pAllocator) { + m_pAllocator->Release(); + m_pAllocator = NULL; + } +} +void CXFA_TextParser::InitCSSData(IXFA_TextProvider* pTextProvider) { + if (pTextProvider == NULL) { + return; + } + if (m_pSelector == NULL) { + CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); + IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); + FXSYS_assert(pFontMgr); + m_pSelector = IFDE_CSSStyleSelector::Create(); + m_pSelector->SetFontMgr(pFontMgr); + FX_FLOAT fFontSize = 10; + CXFA_Font font = pTextProvider->GetFontNode(); + if (font) { + fFontSize = font.GetFontSize(); + } + m_pSelector->SetDefFontSize(fFontSize); + } + if (m_pUASheet == NULL) { + m_pUASheet = LoadDefaultSheetStyle(); + m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); + m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); + } +} +IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { + static const FX_WCHAR s_pStyle[] = + L"html,body,ol,p,ul{display:block}" + L"li{display:list-item}" + L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" + L"margin-bottom:0}ul,ol{margin:1.12em 0}" + L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-" + L"style:italic}" + L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" + L"size:.66em}"; + return IFDE_CSSStyleSheet::LoadFromBuffer( + CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); +} +IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( + IXFA_TextProvider* pTextProvider) { + CXFA_Font font = pTextProvider->GetFontNode(); + CXFA_Para para = pTextProvider->GetParaNode(); + IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL); + IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); + IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); + FX_FLOAT fLineHeight = 0, fFontSize = 10; + if (para) { + fLineHeight = para.GetLineHeight(); + FDE_CSSLENGTH indent; + indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); + pParaStyle->SetTextIndent(indent); + FDE_CSSTEXTALIGN hAlgin = FDE_CSSTEXTALIGN_Left; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + hAlgin = FDE_CSSTEXTALIGN_Center; + break; + case XFA_ATTRIBUTEENUM_Right: + hAlgin = FDE_CSSTEXTALIGN_Right; + break; + case XFA_ATTRIBUTEENUM_Justify: + hAlgin = FDE_CSSTEXTALIGN_Justify; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + hAlgin = FDE_CSSTEXTALIGN_JustifyAll; + break; + } + pParaStyle->SetTextAlign(hAlgin); + FDE_CSSRECT rtMarginWidth; + rtMarginWidth.left.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginLeft()); + rtMarginWidth.top.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceAbove()); + rtMarginWidth.right.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginRight()); + rtMarginWidth.bottom.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceBelow()); + pStyle->GetBoundaryStyles()->SetMarginWidth(rtMarginWidth); + } + if (font) { + pFontStyle->SetColor(font.GetColor()); + pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFONTSTYLE_Italic + : FDE_CSSFONTSTYLE_Normal); + pFontStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD + : FXFONT_FW_NORMAL); + pParaStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); + fFontSize = font.GetFontSize(); + FDE_CSSLENGTH letterSpacing; + letterSpacing.Set(FDE_CSSLENGTHUNIT_Point, font.GetLetterSpacing()); + pParaStyle->SetLetterSpacing(letterSpacing); + FX_DWORD dwDecoration = 0; + if (font.GetLineThrough() > 0) { + dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; + } + if (font.GetUnderline() > 1) { + dwDecoration |= FDE_CSSTEXTDECORATION_Double; + } else if (font.GetUnderline() > 0) { + dwDecoration |= FDE_CSSTEXTDECORATION_Underline; + } + pParaStyle->SetTextDecoration(dwDecoration); + } + pParaStyle->SetLineHeight(fLineHeight); + pFontStyle->SetFontSize(fFontSize); + return pStyle; +} +IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( + IFDE_CSSComputedStyle* pParentStyle) { + IFDE_CSSComputedStyle* pNewStyle = + m_pSelector->CreateComputedStyle(pParentStyle); + FXSYS_assert(pNewStyle); + if (pParentStyle) { + IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles(); + FX_DWORD dwDecoration = pParaStyle->GetTextDecoration(); + FX_FLOAT fBaseLine = 0; + if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { + fBaseLine = pParaStyle->GetNumberVerticalAlign(); + } + pParaStyle = pNewStyle->GetParagraphStyles(); + pParaStyle->SetTextDecoration(dwDecoration); + pParaStyle->SetNumberVerticalAlign(fBaseLine); + IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles(); + const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth(); + if (pRect) { + pBoundarytyle = pNewStyle->GetBoundaryStyles(); + pBoundarytyle->SetMarginWidth(*pRect); + } + } + return pNewStyle; +} +IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( + IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle) { + CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( + m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); + if (!pContext) + return nullptr; + pContext->m_pParentStyle = pParentStyle; + pParentStyle->AddRef(); + CXFA_CSSTagProvider tagProvider; + ParseTagInfo(pXMLNode, tagProvider); + if (tagProvider.m_bContent) + return nullptr; + IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); + IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); + pCSSAccel->OnEnterTag(&tagProvider); + m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), + pContext->CountDecls(), pStyle); + pCSSAccel->OnLeaveTag(&tagProvider); + return pStyle; +} +void CXFA_TextParser::DoParse(IFDE_XMLNode* pXMLContainer, + IXFA_TextProvider* pTextProvider) { + if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { + return; + } + m_pAllocator = + FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider)); + InitCSSData(pTextProvider); + IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); + ParseRichText(pXMLContainer, pRootStyle); + pRootStyle->Release(); +} +void CXFA_TextParser::ParseRichText(IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle) { + if (pXMLNode == NULL) { + return; + } + CXFA_CSSTagProvider tagProvider; + ParseTagInfo(pXMLNode, tagProvider); + if (!tagProvider.m_bTagAviliable) { + return; + } + IFDE_CSSComputedStyle* pNewStyle = NULL; + if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || + (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { + CXFA_TextParseContext* pTextContext = + FXTARGET_NewWith(m_pAllocator) CXFA_TextParseContext; + FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; + if (!tagProvider.m_bContent) { + pNewStyle = CreateStyle(pParentStyle); + IFDE_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(); + m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls, + pNewStyle); + pCSSAccel->OnLeaveTag(&tagProvider); + if (iMatchedDecls > 0) { + pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); + } + eDisplay = pNewStyle->GetPositionStyles()->GetDisplay(); + } + pTextContext->SetDisplay(eDisplay); + m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); + } + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + ParseRichText(pXMLChild, pNewStyle); + } + if (pNewStyle) + pNewStyle->Release(); +} +void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, + CXFA_CSSTagProvider& tagProvider) { + static const FX_DWORD s_XFATagName[] = { + 0x61, 0x62, 0x69, 0x70, 0x0001f714, + 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, + 0xa73e3af2, 0xb182eaae, 0xdb8ac455, + }; + CFX_WideString wsName; + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + pXMLElement->GetLocalTagName(wsName); + tagProvider.SetTagNameObj(wsName); + FX_DWORD dwHashCode = + FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); + static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(FX_DWORD); + CFX_DSPATemplate<FX_DWORD> lookup; + tagProvider.m_bTagAviliable = + lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; + CFX_WideString wsValue; + pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); + if (!wsValue.IsEmpty()) { + tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); + } + } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { + tagProvider.m_bTagAviliable = TRUE; + tagProvider.m_bContent = TRUE; + } +} +int32_t CXFA_TextParser::GetVAlgin(IXFA_TextProvider* pTextProvider) const { + int32_t iAlign = XFA_ATTRIBUTEENUM_Top; + CXFA_Para para = pTextProvider->GetParaNode(); + if (para) { + iAlign = para.GetVerticalAlign(); + } + return iAlign; +} +FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const { + CFX_WideString wsValue; + if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) { + CXFA_Measurement ms(wsValue); + return ms.ToUnit(XFA_UNIT_Pt); + } + return 36; +} +int32_t CXFA_TextParser::CountTabs(IFDE_CSSComputedStyle* pStyle) const { + CFX_WideString wsValue; + if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-count"), wsValue)) { + return wsValue.GetInteger(); + } + return 0; +} +FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { + CFX_WideString wsValue; + if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { + wsValue.MakeLower(); + return wsValue == FX_WSTRC(L"yes"); + } + return FALSE; +} +IFX_Font* CXFA_TextParser::GetFont(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { + CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); + FX_DWORD dwStyle = 0; + CXFA_Font font = pTextProvider->GetFontNode(); + if (font) { + font.GetTypeface(wsFamily); + if (font.IsBold()) { + dwStyle |= FX_FONTSTYLE_Bold; + } + if (font.IsItalic()) { + dwStyle |= FX_FONTSTYLE_Italic; + } + } + if (pStyle) { + IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); + int32_t iCount = pFontStyle->CountFontFamilies(); + if (iCount > 0) { + wsFamily = pFontStyle->GetFontFamily(iCount - 1); + } + dwStyle = 0; + if (pFontStyle->GetFontWeight() > FXFONT_FW_NORMAL) { + dwStyle |= FX_FONTSTYLE_Bold; + } + if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) { + dwStyle |= FX_FONTSTYLE_Italic; + } + } + CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); + CXFA_FontMgr* pFontMgr = pDoc->GetApp()->GetXFAFontMgr(); + return pFontMgr->GetFont(pDoc, wsFamily, dwStyle); +} +FX_FLOAT CXFA_TextParser::GetFontSize(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { + if (pStyle) + return pStyle->GetFontStyles()->GetFontSize(); + + CXFA_Font font = pTextProvider->GetFontNode(); + if (font) { + return font.GetFontSize(); + } + return 10; +} +int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + IFDE_XMLNode* pXMLNode) const { + if (pStyle) { + CFX_WideString wsValue; + if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"), + wsValue)) { + return wsValue.GetInteger(); + } + while (pXMLNode) { + CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( + m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); + if (pContext && pContext->m_pParentStyle && + pContext->m_pParentStyle->GetCustomStyle( + FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) { + return wsValue.GetInteger(); + } + pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + } + } + if (CXFA_Font font = pTextProvider->GetFontNode()) { + return static_cast<int32_t>(font.GetHorizontalScale()); + } + return 100; +} +int32_t CXFA_TextParser::GetVerScale(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { + if (pStyle) { + CFX_WideString wsValue; + if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-vertical-scale"), wsValue)) { + return wsValue.GetInteger(); + } + } + if (CXFA_Font font = pTextProvider->GetFontNode()) { + return (int32_t)font.GetVerticalScale(); + } + return 100; +} +void CXFA_TextParser::GetUnderline(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + int32_t& iUnderline, + int32_t& iPeriod) const { + iUnderline = 0; + iPeriod = XFA_ATTRIBUTEENUM_All; + if (pStyle) { + FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); + if (dwDecoration & FDE_CSSTEXTDECORATION_Double) { + iUnderline = 2; + } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) { + iUnderline = 1; + } + CFX_WideString wsValue; + if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) { + if (wsValue == FX_WSTRC(L"word")) { + iPeriod = XFA_ATTRIBUTEENUM_Word; + } + } else if (CXFA_Font font = pTextProvider->GetFontNode()) { + iPeriod = font.GetUnderlinePeriod(); + } + } else { + CXFA_Font font = pTextProvider->GetFontNode(); + if (font) { + iUnderline = font.GetUnderline(); + iPeriod = font.GetUnderlinePeriod(); + } + } +} +void CXFA_TextParser::GetLinethrough(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + int32_t& iLinethrough) const { + if (pStyle) { + FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); + iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; + } else { + CXFA_Font font = pTextProvider->GetFontNode(); + if (font) { + iLinethrough = font.GetLineThrough(); + } + } +} +FX_ARGB CXFA_TextParser::GetColor(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { + if (pStyle) + return pStyle->GetFontStyles()->GetColor(); + + if (CXFA_Font font = pTextProvider->GetFontNode()) + return font.GetColor(); + + return 0xFF000000; +} +FX_FLOAT CXFA_TextParser::GetBaseline(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const { + if (pStyle) { + IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); + if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { + return pParaStyle->GetNumberVerticalAlign(); + } + } else if (CXFA_Font font = pTextProvider->GetFontNode()) { + return font.GetBaselineShift(); + } + return 0; +} +FX_FLOAT CXFA_TextParser::GetLineHeight(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + FX_BOOL bFirst, + FX_FLOAT fVerScale) const { + FX_FLOAT fLineHeight = 0; + if (pStyle) { + fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight(); + } else if (CXFA_Para para = pTextProvider->GetParaNode()) { + fLineHeight = para.GetLineHeight(); + } + if (bFirst) { + FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle); + if (fLineHeight < 0.1f) { + fLineHeight = fFontSize; + } else { + fLineHeight = std::min(fLineHeight, fFontSize); + } + } else if (fLineHeight < 0.1f) { + fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; + } + fLineHeight *= fVerScale; + return fLineHeight; +} +FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, + IFDE_XMLNode* pXMLNode, + CFX_WideString& wsValue) { + wsValue.Empty(); + if (pXMLNode == NULL) { + return FALSE; + } + FX_BOOL bRet = FALSE; + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLNode; + CFX_WideString wsAttr; + pElement->GetString(FX_WSTRC(L"xfa:embed").GetPtr(), wsAttr); + if (wsAttr.IsEmpty()) { + return FALSE; + } + if (wsAttr.GetAt(0) == L'#') { + wsAttr.Delete(0); + } + CFX_WideString ws; + pElement->GetString(FX_WSTRC(L"xfa:embedType").GetPtr(), ws); + if (ws.IsEmpty()) { + ws = L"som"; + } else { + ws.MakeLower(); + } + FX_BOOL bURI = (ws == FX_WSTRC(L"uri")); + if (!bURI && ws != FX_WSTRC(L"som")) { + return FALSE; + } + ws.Empty(); + pElement->GetString(FX_WSTRC(L"xfa:embedMode").GetPtr(), ws); + if (ws.IsEmpty()) { + ws = L"formatted"; + } else { + ws.MakeLower(); + } + FX_BOOL bRaw = (ws == FX_WSTRC(L"raw")); + if (!bRaw && ws != FX_WSTRC(L"formatted")) { + return FALSE; + } + bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue); + } + return bRet; +} +CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( + IFDE_XMLNode* pXMLNode) { + return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( + pXMLNode); +} +enum XFA_TABSTOPSSTATUS { + XFA_TABSTOPSSTATUS_Error, + XFA_TABSTOPSSTATUS_EOS, + XFA_TABSTOPSSTATUS_None, + XFA_TABSTOPSSTATUS_Alignment, + XFA_TABSTOPSSTATUS_StartLeader, + XFA_TABSTOPSSTATUS_Leader, + XFA_TABSTOPSSTATUS_Location, +}; +FX_BOOL CXFA_TextParser::GetTabstops( + IFDE_CSSComputedStyle* pStyle, + CXFA_TextTabstopsContext* pTabstopContext) { + if (pStyle == NULL || pTabstopContext == NULL) { + return FALSE; + } + CFX_WideString wsValue; + if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && + !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { + return FALSE; + } + int32_t iLength = wsValue.GetLength(); + const FX_WCHAR* pTabStops = wsValue; + int32_t iCur = 0; + int32_t iLast = 0; + CFX_WideString wsAlign; + XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None; + FX_WCHAR ch; + while (iCur < iLength) { + ch = pTabStops[iCur]; + switch (eStatus) { + case XFA_TABSTOPSSTATUS_None: + if (ch <= ' ') { + iCur++; + } else { + eStatus = XFA_TABSTOPSSTATUS_Alignment; + iLast = iCur; + } + break; + case XFA_TABSTOPSSTATUS_Alignment: + if (ch == ' ') { + wsAlign = CFX_WideStringC(pTabStops + iLast, iCur - iLast); + eStatus = XFA_TABSTOPSSTATUS_StartLeader; + iCur++; + while (iCur < iLength && pTabStops[iCur] <= ' ') { + iCur++; + } + iLast = iCur; + } else { + iCur++; + } + break; + case XFA_TABSTOPSSTATUS_StartLeader: + if (ch != 'l') { + eStatus = XFA_TABSTOPSSTATUS_Location; + } else { + int32_t iCount = 0; + while (iCur < iLength) { + ch = pTabStops[iCur]; + iCur++; + if (ch == '(') { + iCount++; + } else if (ch == ')') { + iCount--; + if (iCount == 0) { + break; + } + } + } + while (iCur < iLength && pTabStops[iCur] <= ' ') { + iCur++; + } + iLast = iCur; + eStatus = XFA_TABSTOPSSTATUS_Location; + } + break; + case XFA_TABSTOPSSTATUS_Location: + if (ch == ' ') { + FX_DWORD dwHashCode = + FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); + CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); + FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); + pTabstopContext->Append(dwHashCode, fPos); + wsAlign.Empty(); + eStatus = XFA_TABSTOPSSTATUS_None; + } + iCur++; + break; + default: + break; + } + } + if (!wsAlign.IsEmpty()) { + FX_DWORD dwHashCode = + FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); + CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); + FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); + pTabstopContext->Append(dwHashCode, fPos); + } + return TRUE; +} +CXFA_TextLayout::CXFA_TextLayout(IXFA_TextProvider* pTextProvider) + : m_bHasBlock(FALSE), + m_pTextProvider(pTextProvider), + m_pTextDataNode(nullptr), + m_bRichText(FALSE), + m_pAllocator(nullptr), + m_pBreak(nullptr), + m_pLoader(nullptr), + m_iLines(0), + m_fMaxWidth(0), + m_pTabstopContext(nullptr), + m_bBlockContinue(TRUE) { + FXSYS_assert(m_pTextProvider); +} +CXFA_TextLayout::~CXFA_TextLayout() { + m_textParser.Reset(); + delete m_pLoader; + delete m_pTabstopContext; + Unload(); +} +void CXFA_TextLayout::Unload() { + int32_t iCount = m_pieceLines.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CXFA_PieceLine* pLine = m_pieceLines.GetAt(i); + FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator, pLine); + } + m_pieceLines.RemoveAll(); + if (m_pBreak) { + m_pBreak->Release(); + m_pBreak = NULL; + } + if (m_pAllocator) { + m_pAllocator->Release(); + m_pAllocator = NULL; + } +} +const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { + return &m_pieceLines; +} +void CXFA_TextLayout::GetTextDataNode() { + if (m_pTextProvider == NULL) { + return; + } + CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); + if (pNode && m_bRichText) { + m_textParser.Reset(); + } + m_pTextDataNode = pNode; +} +IFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { + IFDE_XMLNode* pXMLContainer = NULL; + if (m_bRichText) { + IFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); + if (!pXMLRoot) { + return pXMLContainer; + } + for (IFDE_XMLNode* pXMLChild = + pXMLRoot->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pXMLChild->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + CFX_WideString wsTag; + pXMLElement->GetLocalTagName(wsTag); + if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { + pXMLContainer = pXMLChild; + break; + } + } + } + } + return pXMLContainer; +} +IFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { + FX_DWORD dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; + if (!bDefault) { + dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; + } + IFX_RTFBreak* pBreak = IFX_RTFBreak::Create(0); + pBreak->SetLayoutStyles(dwStyle); + pBreak->SetLineBreakChar(L'\n'); + pBreak->SetLineBreakTolerance(1); + pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); + pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); + return pBreak; +} +void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { + CXFA_Font font = m_pTextProvider->GetFontNode(); + CXFA_Para para = m_pTextProvider->GetParaNode(); + FX_FLOAT fStart = 0; + FX_FLOAT fStartPos = 0; + if (para) { + int32_t iAlign = FX_RTFLINEALIGNMENT_Left; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + iAlign = FX_RTFLINEALIGNMENT_Center; + break; + case XFA_ATTRIBUTEENUM_Right: + iAlign = FX_RTFLINEALIGNMENT_Right; + break; + case XFA_ATTRIBUTEENUM_Justify: + iAlign = FX_RTFLINEALIGNMENT_Justified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + iAlign = FX_RTFLINEALIGNMENT_Distributed; + break; + } + m_pBreak->SetAlignment(iAlign); + fStart = para.GetMarginLeft(); + if (m_pTextProvider->IsCheckButtonAndAutoWidth()) { + if (iAlign != FX_RTFLINEALIGNMENT_Left) { + fLineWidth -= para.GetMarginRight(); + } + } else { + fLineWidth -= para.GetMarginRight(); + } + if (fLineWidth < 0) { + fLineWidth = fStart; + } + fStartPos = fStart; + FX_FLOAT fIndent = para.GetTextIndent(); + if (fIndent > 0) { + fStartPos += fIndent; + } + } + m_pBreak->SetLineBoundary(fStart, fLineWidth); + m_pBreak->SetLineStartPos(fStartPos); + if (font) { + m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); + m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); + m_pBreak->SetCharSpace(font.GetLetterSpacing()); + } + FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL); + m_pBreak->SetFontSize(fFontSize); + m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); + m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); +} +void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, + FDE_CSSDISPLAY eDisplay, + FX_FLOAT fLineWidth, + IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle) { + if (pStyle == NULL) { + InitBreak(fLineWidth); + return; + } + IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); + if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { + int32_t iAlign = FX_RTFLINEALIGNMENT_Left; + switch (pParaStyle->GetTextAlign()) { + case FDE_CSSTEXTALIGN_Right: + iAlign = FX_RTFLINEALIGNMENT_Right; + break; + case FDE_CSSTEXTALIGN_Center: + iAlign = FX_RTFLINEALIGNMENT_Center; + break; + case FDE_CSSTEXTALIGN_Justify: + iAlign = FX_RTFLINEALIGNMENT_Justified; + break; + case FDE_CSSTEXTALIGN_JustifyAll: + iAlign = FX_RTFLINEALIGNMENT_Distributed; + break; + default: + break; + } + m_pBreak->SetAlignment(iAlign); + FX_FLOAT fStart = 0; + const FDE_CSSRECT* pRect = pStyle->GetBoundaryStyles()->GetMarginWidth(); + const FDE_CSSRECT* pPaddingRect = + pStyle->GetBoundaryStyles()->GetPaddingWidth(); + if (pRect) { + fStart = pRect->left.GetValue(); + fLineWidth -= pRect->right.GetValue(); + if (pPaddingRect) { + fStart += pPaddingRect->left.GetValue(); + fLineWidth -= pPaddingRect->right.GetValue(); + } + if (eDisplay == FDE_CSSDISPLAY_ListItem) { + const FDE_CSSRECT* pParRect = + pParentStyle->GetBoundaryStyles()->GetMarginWidth(); + const FDE_CSSRECT* pParPaddingRect = + pParentStyle->GetBoundaryStyles()->GetPaddingWidth(); + if (pParRect) { + fStart += pParRect->left.GetValue(); + fLineWidth -= pParRect->right.GetValue(); + if (pParPaddingRect) { + fStart += pParPaddingRect->left.GetValue(); + fLineWidth -= pParPaddingRect->right.GetValue(); + } + } + FDE_CSSRECT pNewRect; + pNewRect.left.Set(FDE_CSSLENGTHUNIT_Point, fStart); + pNewRect.right.Set(FDE_CSSLENGTHUNIT_Point, pRect->right.GetValue()); + pNewRect.top.Set(FDE_CSSLENGTHUNIT_Point, pRect->top.GetValue()); + pNewRect.bottom.Set(FDE_CSSLENGTHUNIT_Point, pRect->bottom.GetValue()); + pStyle->GetBoundaryStyles()->SetMarginWidth(pNewRect); + } + } + m_pBreak->SetLineBoundary(fStart, fLineWidth); + FX_FLOAT fIndent = pParaStyle->GetTextIndent().GetValue(); + if (fIndent > 0) { + fStart += fIndent; + } + m_pBreak->SetLineStartPos(fStart); + m_pBreak->SetTabWidth(m_textParser.GetTabInterval(pStyle)); + if (m_pTabstopContext == NULL) { + m_pTabstopContext = new CXFA_TextTabstopsContext; + } + m_textParser.GetTabstops(pStyle, m_pTabstopContext); + for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) { + XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i); + m_pBreak->AddPositionedTab(pTab->fTabstops); + } + } + FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); + m_pBreak->SetFontSize(fFontSize); + m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); + m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, pStyle)); + m_pBreak->SetHorizontalScale( + m_textParser.GetHorScale(m_pTextProvider, pStyle, pXMLNode)); + m_pBreak->SetVerticalScale(m_textParser.GetVerScale(m_pTextProvider, pStyle)); + m_pBreak->SetCharSpace(pParaStyle->GetLetterSpacing().GetValue()); +} +int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { + GetTextDataNode(); + wsText.Empty(); + if (m_bRichText) { + } else { + wsText = m_pTextDataNode->GetContent(); + } + return wsText.GetLength(); +} +FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { + if (m_pLoader == NULL) { + return 0; + } + int32_t iCount = m_pLoader->m_lineHeights.GetSize(); + if (iCount == 0 && m_pLoader->m_fWidth > 0) { + CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); + CFX_SizeF szDef; + m_pLoader->m_bSaveLineHeight = TRUE; + m_pLoader->m_fLastPos = 0; + CalcSize(szMax, szMax, szDef); + m_pLoader->m_bSaveLineHeight = FALSE; + return szDef.y; + } + FX_FLOAT fHeight = m_pLoader->m_fHeight; + if (fHeight < 0.1f) { + fHeight = 0; + for (int32_t i = 0; i < iCount; i++) { + fHeight += m_pLoader->m_lineHeights.ElementAt(i); + } + } + return fHeight; +} +FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) { + if (m_pLoader == NULL) { + m_pLoader = new CXFA_LoaderContext; + } + if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && + FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { + m_pLoader->m_lineHeights.RemoveAll(); + m_Blocks.RemoveAll(); + Unload(); + m_pLoader->m_fStartLineOffset = 0; + } + m_pLoader->m_fWidth = fWidth; + if (fWidth < 0) { + CFX_SizeF szMax; + CFX_SizeF szDef; + m_pLoader->m_bSaveLineHeight = TRUE; + m_pLoader->m_fLastPos = 0; + CalcSize(szMax, szMax, szDef); + m_pLoader->m_bSaveLineHeight = FALSE; + fWidth = szDef.x; + } + return fWidth; +} +FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, + FX_FLOAT& fCalcHeight, + FX_FLOAT fContentAreaHeight, + FX_FLOAT fTextHeight) { + if (m_pLoader == NULL) { + return FALSE; + } + int32_t iBlockCount = m_Blocks.GetSize(); + FX_FLOAT fHeight = fTextHeight; + if (fHeight < 0) { + fHeight = GetLayoutHeight(); + } + m_pLoader->m_fHeight = fHeight; + if (fContentAreaHeight < 0) { + return FALSE; + } + m_bHasBlock = TRUE; + if (iBlockCount == 0 && fHeight > 0) { + fHeight = fTextHeight - GetLayoutHeight(); + if (fHeight > 0) { + int32_t iAlign = m_textParser.GetVAlgin(m_pTextProvider); + if (iAlign == XFA_ATTRIBUTEENUM_Middle) { + fHeight /= 2.0f; + } else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) { + fHeight = 0; + } + m_pLoader->m_fStartLineOffset = fHeight; + } + } + FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; + int32_t iLineIndex = 0; + if (iBlockCount > 1) { + if (iBlockCount >= (iBlockIndex + 1) * 2) { + iLineIndex = m_Blocks.ElementAt(iBlockIndex * 2); + } else { + iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + + m_Blocks.ElementAt(iBlockCount - 2); + } + if (m_pLoader->m_BlocksHeight.GetSize() > 0) { + for (int32_t i = 0; i < iBlockIndex; i++) { + fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); + } + } + } + int32_t iCount = m_pLoader->m_lineHeights.GetSize(); + int32_t i = 0; + for (i = iLineIndex; i < iCount; i++) { + FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); + if ((i == iLineIndex) && (fLineHeight - fContentAreaHeight > 0.001)) { + fCalcHeight = 0; + return TRUE; + } + if (fLinePos + fLineHeight - fContentAreaHeight > 0.001) { + if (iBlockCount >= (iBlockIndex + 1) * 2) { + m_Blocks.SetAt(iBlockIndex * 2, iLineIndex); + m_Blocks.SetAt(iBlockIndex * 2 + 1, i - iLineIndex); + } else { + m_Blocks.Add(iLineIndex); + m_Blocks.Add(i - iLineIndex); + } + if (i == iLineIndex) { + if (fCalcHeight <= fLinePos) { + if (m_pLoader->m_BlocksHeight.GetSize() > iBlockIndex * 2 && + (m_pLoader->m_BlocksHeight.GetAt(iBlockIndex * 2) == + iBlockIndex)) { + m_pLoader->m_BlocksHeight.SetAt(iBlockIndex * 2 + 1, fCalcHeight); + } else { + m_pLoader->m_BlocksHeight.Add((FX_FLOAT)iBlockIndex); + m_pLoader->m_BlocksHeight.Add(fCalcHeight); + } + } + return TRUE; + } + fCalcHeight = fLinePos; + return TRUE; + } + fLinePos += fLineHeight; + } + return FALSE; +} +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) { + defaultSize.x = maxSize.x; + if (defaultSize.x < 1) { + defaultSize.x = 0xFFFF; + } + if (m_pBreak) + m_pBreak->Release(); + + m_pBreak = CreateBreak(FALSE); + FX_FLOAT fLinePos = 0; + m_iLines = 0; + m_fMaxWidth = 0; + Loader(defaultSize, fLinePos, FALSE); + if (fLinePos < 0.1f) { + fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); + } + if (m_pTabstopContext) { + delete m_pTabstopContext; + m_pTabstopContext = NULL; + } + 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; + } + Unload(); + m_pBreak = CreateBreak(TRUE); + if (m_pLoader) { + m_pLoader->m_iTotalLines = -1; + m_pLoader->m_iChar = 0; + } + m_iLines = 0; + FX_FLOAT fLinePos = 0; + Loader(size, fLinePos, TRUE); + UpdateAlign(size.y, fLinePos); + if (m_pTabstopContext) { + delete m_pTabstopContext; + m_pTabstopContext = NULL; + } + if (fHeight) { + *fHeight = fLinePos; + } + return TRUE; +} +FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { + if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { + return FALSE; + } + if (m_pLoader->m_fWidth < 1) { + return FALSE; + } + m_pLoader->m_iTotalLines = -1; + m_iLines = 0; + FX_FLOAT fLinePos = 0; + CXFA_Node* pNode = NULL; + CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); + int32_t iCount = m_Blocks.GetSize(); + int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); + iBlocksHeightCount /= 2; + if (iBlock < iBlocksHeightCount) { + return TRUE; + } + if (iBlock == iBlocksHeightCount) { + Unload(); + m_pBreak = CreateBreak(TRUE); + fLinePos = m_pLoader->m_fStartLineOffset; + for (int32_t i = 0; i < iBlocksHeightCount; i++) { + fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); + } + m_pLoader->m_iChar = 0; + if (iCount > 1) { + m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); + } + Loader(szText, fLinePos, TRUE); + if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) { + UpdateAlign(szText.y, fLinePos); + } + } else if (m_pTextDataNode) { + iBlock *= 2; + if (iBlock < iCount - 2) { + m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); + } + m_pBreak->Reset(); + if (m_bRichText) { + IFDE_XMLNode* pContainerNode = GetXMLContainerNode(); + if (!pContainerNode) { + return TRUE; + } + IFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; + if (pXMLNode == NULL) { + return TRUE; + } + IFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; + for (; pXMLNode; + pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, + m_pLoader->m_pParentStyle, TRUE); + if (!bFlag) { + break; + } + } + while (pXMLNode == NULL) { + pXMLNode = pSaveXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + if (pXMLNode == pContainerNode) { + break; + } + FX_BOOL bFlag = + LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, + TRUE, NULL, FALSE); + if (!bFlag) { + break; + } + pSaveXMLNode = pXMLNode; + pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + if (!pXMLNode) { + continue; + } + for (; pXMLNode; + pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, + m_pLoader->m_pParentStyle, TRUE); + if (!bFlag) { + break; + } + } + } + } else { + pNode = m_pLoader->m_pNode; + if (pNode == NULL) { + return TRUE; + } + LoadText(pNode, szText, fLinePos, TRUE); + } + } + if (iBlock == iCount) { + delete m_pTabstopContext; + m_pTabstopContext = nullptr; + delete m_pLoader; + m_pLoader = nullptr; + } + return TRUE; +} +void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) { + if (!m_pLoader) { + return; + } + int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize(); + if (iCountHeight == 0) { + return; + } + FX_BOOL bEndItem = TRUE; + int32_t iBlockCount = m_Blocks.GetSize(); + FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; + int32_t iLineIndex = 0; + if (iBlockIndex > 0) { + int32_t iBlockHeightCount = m_pLoader->m_BlocksHeight.GetSize(); + iBlockHeightCount /= 2; + if (iBlockHeightCount >= iBlockIndex) { + for (int32_t i = 0; i < iBlockIndex; i++) { + fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); + } + } else { + fLinePos = 0; + } + iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + + m_Blocks.ElementAt(iBlockCount - 2); + } + int32_t i = 0; + for (i = iLineIndex; i < iCountHeight; i++) { + FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); + if (fLinePos + fLineHeight - rtText.height > 0.001) { + m_Blocks.Add(iLineIndex); + m_Blocks.Add(i - iLineIndex); + bEndItem = FALSE; + break; + } + fLinePos += fLineHeight; + } + if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { + m_Blocks.Add(iLineIndex); + m_Blocks.Add(i - iLineIndex); + } +} +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) { + return 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); + if (m_pieceLines.GetSize() == 0) { + int32_t iBlockCount = CountBlocks(); + for (int32_t i = 0; i < iBlockCount; i++) { + Layout(i); + } + } + FXTEXT_CHARPOS* pCharPos = NULL; + int32_t iCharCount = 0; + int32_t iLineStart = 0; + int32_t iPieceLines = m_pieceLines.GetSize(); + int32_t iCount = m_Blocks.GetSize(); + if (iCount > 0) { + iBlock *= 2; + if (iBlock < iCount) { + iLineStart = m_Blocks.ElementAt(iBlock); + iPieceLines = m_Blocks.ElementAt(iBlock + 1); + } else { + iPieceLines = 0; + } + } + for (int32_t i = 0; i < iPieceLines; i++) { + if (i + iLineStart >= m_pieceLines.GetSize()) { + break; + } + CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i + iLineStart); + int32_t iPieces = pPieceLine->m_textPieces.GetSize(); + int32_t j = 0; + for (j = 0; j < iPieces; j++) { + const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); + int32_t iChars = pPiece->iChars; + if (iCharCount < iChars) { + FX_Free(pCharPos); + pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars); + iCharCount = iChars; + } + FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); + RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device); + } + for (j = 0; j < iPieces; j++) { + RenderPath(pDevice, pPen, 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) { + fHeight -= fBottom; + if (fHeight < 0.1f) { + return; + } + switch (m_textParser.GetVAlgin(m_pTextProvider)) { + case XFA_ATTRIBUTEENUM_Middle: + fHeight /= 2.0f; + break; + case XFA_ATTRIBUTEENUM_Bottom: + break; + default: + return; + } + int32_t iCount = m_pieceLines.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i); + int32_t iPieces = pPieceLine->m_textPieces.GetSize(); + for (int32_t j = 0; j < iPieces; j++) { + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); + CFX_RectF& rect = pPiece->rtPiece; + rect.top += fHeight; + } + } +} +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); + } + GetTextDataNode(); + if (m_pTextDataNode == NULL) { + return TRUE; + } + if (m_bRichText) { + IFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); + if (pXMLContainer) { + if (!m_textParser.IsParsed()) { + m_textParser.DoParse(pXMLContainer, m_pTextProvider); + } + IFDE_CSSComputedStyle* pRootStyle = + m_textParser.CreateRootStyle(m_pTextProvider); + LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); + pRootStyle->Release(); + } + } else { + LoadText(m_pTextDataNode, szText, fLinePos, bSavePieces); + } + return TRUE; +} +void CXFA_TextLayout::LoadText(CXFA_Node* pNode, + const CFX_SizeF& szText, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces) { + InitBreak(szText.x); + CXFA_Para para = m_pTextProvider->GetParaNode(); + FX_FLOAT fSpaceAbove = 0; + if (para) { + fSpaceAbove = para.GetSpaceAbove(); + if (fSpaceAbove < 0.1f) { + fSpaceAbove = 0; + } + int32_t verAlign = para.GetVerticalAlign(); + switch (verAlign) { + case XFA_ATTRIBUTEENUM_Top: + case XFA_ATTRIBUTEENUM_Middle: + case XFA_ATTRIBUTEENUM_Bottom: { + fLinePos += fSpaceAbove; + break; + } + } + } + CFX_WideString wsText = pNode->GetContent(); + wsText.TrimRight(L" "); + FX_BOOL bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces); + if (bRet && m_pLoader) { + m_pLoader->m_pNode = pNode; + } else { + EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); + } +} +FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, + const CFX_SizeF& szText, + FX_FLOAT& fLinePos, + IFDE_CSSComputedStyle* pParentStyle, + FX_BOOL bSavePieces, + CXFA_LinkUserData* pLinkData, + FX_BOOL bEndBreak, + FX_BOOL bIsOl, + int32_t iLiCount) { + if (pXMLNode == NULL) { + return FALSE; + } + CXFA_TextParseContext* pContext = + m_textParser.GetParseContextFromMap(pXMLNode); + FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; + FX_BOOL bContentNode = FALSE; + FX_FLOAT fSpaceBelow = 0; + IFDE_CSSComputedStyle* pStyle = NULL; + CFX_WideString wsName; + if (bEndBreak) { + FX_BOOL bCurOl = FALSE; + FX_BOOL bCurLi = FALSE; + IFDE_XMLElement* pElement = NULL; + if (pContext) { + if (m_bBlockContinue || + (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { + m_bBlockContinue = TRUE; + } + if (pXMLNode->GetType() == FDE_XMLNODE_Text) { + bContentNode = TRUE; + } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + pElement = (IFDE_XMLElement*)pXMLNode; + pElement->GetLocalTagName(wsName); + } + if (wsName == FX_WSTRC(L"ol")) { + bIsOl = TRUE; + bCurOl = TRUE; + } + if (m_bBlockContinue || bContentNode == FALSE) { + eDisplay = pContext->GetDisplay(); + if (eDisplay != FDE_CSSDISPLAY_Block && + eDisplay != FDE_CSSDISPLAY_Inline && + eDisplay != FDE_CSSDISPLAY_ListItem) { + return TRUE; + } + pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle); + InitBreak(bContentNode ? pParentStyle : pStyle, eDisplay, szText.x, + pXMLNode, pParentStyle); + if ((eDisplay == FDE_CSSDISPLAY_Block || + eDisplay == FDE_CSSDISPLAY_ListItem) && + pStyle && + (wsName.IsEmpty() || + (wsName != FX_WSTRC(L"body") && wsName != FX_WSTRC(L"html") && + wsName != FX_WSTRC(L"ol") && wsName != FX_WSTRC(L"ul")))) { + const FDE_CSSRECT* pRect = + pStyle->GetBoundaryStyles()->GetMarginWidth(); + if (pRect) { + fLinePos += pRect->top.GetValue(); + fSpaceBelow = pRect->bottom.GetValue(); + } + } + if (wsName == FX_WSTRC(L"a")) { + CFX_WideString wsLinkContent; + FXSYS_assert(pElement); + pElement->GetString(FX_WSTRC(L"href").GetPtr(), wsLinkContent); + if (!wsLinkContent.IsEmpty()) { + pLinkData = FXTARGET_NewWith(m_pAllocator) CXFA_LinkUserData( + m_pAllocator, + wsLinkContent.GetBuffer(wsLinkContent.GetLength())); + wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); + } + } + int32_t iTabCount = + m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); + FX_BOOL bSpaceRun = + m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); + CFX_WideString wsText; + if (bContentNode && iTabCount == 0) { + ((IFDE_XMLText*)pXMLNode)->GetText(wsText); + } else if (wsName == FX_WSTRC(L"br")) { + wsText = L'\n'; + } else if (wsName == FX_WSTRC(L"li")) { + bCurLi = TRUE; + if (bIsOl) { + wsText.Format(L"%d. ", iLiCount); + } else { + wsText = 0x00B7 + FX_WSTRC(L" "); + } + } else if (!bContentNode) { + if (iTabCount > 0) { + while (iTabCount-- > 0) + wsText += L'\t'; + } else { + m_textParser.GetEmbbedObj(m_pTextProvider, pXMLNode, wsText); + } + } + int32_t iLength = wsText.GetLength(); + if (iLength > 0 && bContentNode && !bSpaceRun) { + ProcessText(wsText); + } + if (m_pLoader) { + if (wsText.GetLength() > 0 && + (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { + wsText.TrimLeft(0x20); + } + if (FDE_CSSDISPLAY_Block == eDisplay) { + m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; + } else if (FDE_CSSDISPLAY_Inline == eDisplay && + (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { + m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; + } else if (wsText.GetLength() > 0 && + (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { + m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; + } else if (wsText.GetLength() != 0) { + m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; + } + } + if (wsText.GetLength() > 0) { + if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { + if (pLinkData) { + pLinkData->AddRef(); + } + CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator) + CXFA_TextUserData(m_pAllocator, + bContentNode ? pParentStyle : pStyle, + pLinkData); + m_pBreak->SetUserData(pUserData); + } + if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { + if (m_pLoader) { + m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; + } + if (IsEnd(bSavePieces)) { + if (m_pLoader && m_pLoader->m_iTotalLines > -1) { + m_pLoader->m_pXMLNode = pXMLNode; + m_pLoader->m_pParentStyle = pParentStyle; + } + if (pStyle) + pStyle->Release(); + return FALSE; + } + return TRUE; + } + } + } + } + FX_BOOL ret = TRUE; + for (IFDE_XMLNode* pChildNode = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (bCurOl) { + iLiCount++; + } + ret = LoadRichText(pChildNode, szText, fLinePos, + pContext ? pStyle : pParentStyle, bSavePieces, + pLinkData, TRUE, bIsOl, iLiCount); + if (ret == FALSE) { + return FALSE; + } + } + if (m_pLoader) { + if (FDE_CSSDISPLAY_Block == eDisplay) { + m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; + } + } + if (bCurLi) { + EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); + } + } else { + if (pContext) { + eDisplay = pContext->GetDisplay(); + } + } + if (m_bBlockContinue) { + if (pContext && !bContentNode) { + FX_DWORD dwStatus = (eDisplay == FDE_CSSDISPLAY_Block) + ? FX_RTFBREAK_ParagraphBreak + : FX_RTFBREAK_PieceBreak; + EndBreak(dwStatus, fLinePos, bSavePieces); + if (eDisplay == FDE_CSSDISPLAY_Block) { + fLinePos += fSpaceBelow; + if (m_pTabstopContext) { + m_pTabstopContext->RemoveAll(); + } + } + if (wsName == FX_WSTRC(L"a")) { + if (pLinkData) { + pLinkData->Release(); + pLinkData = nullptr; + } + } + if (IsEnd(bSavePieces)) { + if (pStyle) { + pStyle->Release(); + } + if (m_pLoader && m_pLoader->m_iTotalLines > -1) { + m_pLoader->m_pXMLNode = + pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + m_pLoader->m_pParentStyle = pParentStyle; + } + return FALSE; + } + } + } + if (pStyle) + pStyle->Release(); + return TRUE; +} +FX_BOOL CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, + FX_FLOAT& fLinePos, + FX_FLOAT fSpaceAbove, + FX_BOOL bSavePieces) { + FX_DWORD dwStatus = 0; + int32_t iChar = 0; + if (m_pLoader) { + iChar = m_pLoader->m_iChar; + } + int32_t iLength = wsText.GetLength(); + for (int32_t i = iChar; i < iLength; i++) { + FX_WCHAR wch = wsText.GetAt(i); + if (wch == 0xA0) { + wch = 0x20; + } + if ((dwStatus = m_pBreak->AppendChar(wch)) > FX_RTFBREAK_PieceBreak) { + AppendTextLine(dwStatus, fLinePos, bSavePieces); + if (IsEnd(bSavePieces)) { + if (m_pLoader) + m_pLoader->m_iChar = i; + return TRUE; + } + if (dwStatus == FX_RTFBREAK_ParagraphBreak && m_bRichText) { + fLinePos += fSpaceAbove; + } + } + } + if (m_pLoader) { + m_pLoader->m_iChar = 0; + } + return FALSE; +} +FX_BOOL CXFA_TextLayout::IsEnd(FX_BOOL bSavePieces) { + if (!bSavePieces) { + return FALSE; + } + if (m_pLoader && m_pLoader->m_iTotalLines > 0) { + return m_iLines >= m_pLoader->m_iTotalLines; + } + return FALSE; +} +void CXFA_TextLayout::ProcessText(CFX_WideString& wsText) { + int32_t iLen = wsText.GetLength(); + if (iLen == 0) { + return; + } + FX_WCHAR* psz = wsText.GetBuffer(iLen); + int32_t iTrimLeft = 0; + FX_WCHAR wch = 0, wPrev = 0; + for (int32_t i = 0; i < iLen; i++) { + wch = psz[i]; + if (wch < 0x20) { + wch = 0x20; + } + if (wch == 0x20 && wPrev == 0x20) { + continue; + } + wPrev = wch; + psz[iTrimLeft++] = wch; + } + wsText.ReleaseBuffer(iLen); + wsText = wsText.Left(iTrimLeft); +} +void CXFA_TextLayout::EndBreak(FX_DWORD dwStatus, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces) { + dwStatus = m_pBreak->EndBreak(dwStatus); + if (dwStatus > FX_RTFBREAK_PieceBreak) { + AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); + } +} +void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, + CXFA_PieceLine* pPieceLine) { + if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { + return; + } + if (pStyle == NULL || pPieceLine == NULL) { + return; + } + int32_t iPieces = pPieceLine->m_textPieces.GetSize(); + if (iPieces == 0) { + return; + } + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); + int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; + int32_t iCount = m_textParser.CountTabs(pStyle); + if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { + return; + } + if (iCount > 0) { + iTabstopsIndex++; + m_pTabstopContext->m_bTabstops = TRUE; + FX_FLOAT fRight = 0; + if (iPieces > 1) { + XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); + fRight = p->rtPiece.right(); + } + m_pTabstopContext->m_fTabWidth = + pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; + } else if (iTabstopsIndex > -1) { + FX_FLOAT fLeft = 0; + if (m_pTabstopContext->m_bTabstops) { + XFA_TABSTOPS* pTabstops = + m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); + FX_DWORD dwAlgin = pTabstops->dwAlign; + if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) { + fLeft = pPiece->rtPiece.width / 2.0f; + } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) || + dwAlgin == FX_HashCode_String_GetW(L"before", 6)) { + fLeft = pPiece->rtPiece.width; + } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) { + int32_t iChars = pPiece->iChars; + for (int32_t i = 0; i < iChars; i++) { + if (pPiece->pszText[i] == L'.') { + break; + } + fLeft += pPiece->pWidths[i] / 20000.0f; + } + } + m_pTabstopContext->m_fLeft = + std::min(fLeft, m_pTabstopContext->m_fTabWidth); + m_pTabstopContext->m_bTabstops = FALSE; + m_pTabstopContext->m_fTabWidth = 0; + } + pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; + } +} +void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces, + FX_BOOL bEndBreak) { + int32_t iPieces = m_pBreak->CountBreakPieces(); + if (iPieces < 1) { + return; + } + IFDE_CSSComputedStyle* pStyle = NULL; + if (bSavePieces) { + CXFA_PieceLine* pPieceLine = FXTARGET_NewWith(m_pAllocator) CXFA_PieceLine; + m_pieceLines.Add(pPieceLine); + if (m_pTabstopContext) { + m_pTabstopContext->Reset(); + } + FX_FLOAT fLineStep = 0, fBaseLine = 0; + int32_t i = 0; + for (i = 0; i < iPieces; i++) { + const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i); + CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData; + if (pUserData) + pStyle = pUserData->m_pStyle; + FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; + XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator) XFA_TextPiece(); + pTP->pszText = + (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR)); + pTP->pWidths = + (int32_t*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(int32_t)); + pTP->iChars = pPiece->m_iChars; + pPiece->GetString(pTP->pszText); + pPiece->GetWidths(pTP->pWidths); + pTP->iBidiLevel = pPiece->m_iBidiLevel; + pTP->iHorScale = pPiece->m_iHorizontalScale; + pTP->iVerScale = pPiece->m_iVerticalScale; + m_textParser.GetUnderline(m_pTextProvider, pStyle, pTP->iUnderline, + pTP->iPeriod); + m_textParser.GetLinethrough(m_pTextProvider, pStyle, pTP->iLineThrough); + pTP->dwColor = m_textParser.GetColor(m_pTextProvider, pStyle); + pTP->pFont = m_textParser.GetFont(m_pTextProvider, pStyle); + pTP->fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); + pTP->rtPiece.left = pPiece->m_iStartPos / 20000.0f; + pTP->rtPiece.width = pPiece->m_iWidth / 20000.0f; + pTP->rtPiece.height = (FX_FLOAT)pPiece->m_iFontSize * fVerScale / 20.0f; + FX_FLOAT fBaseLineTemp = + m_textParser.GetBaseline(m_pTextProvider, pStyle); + pTP->rtPiece.top = fBaseLineTemp; + pPieceLine->m_textPieces.Add(pTP); + FX_FLOAT fLineHeight = m_textParser.GetLineHeight( + m_pTextProvider, pStyle, m_iLines == 0, fVerScale); + if (fBaseLineTemp > 0) { + FX_FLOAT fLineHeightTmp = fBaseLineTemp + pTP->rtPiece.height; + if (fLineHeight < fLineHeightTmp) { + fLineHeight = fLineHeightTmp; + } else { + fBaseLineTemp = 0; + } + } else if (fBaseLine < -fBaseLineTemp) { + fBaseLine = -fBaseLineTemp; + } + fLineStep = std::max(fLineStep, fLineHeight); + if (pUserData && pUserData->m_pLinkData) { + pUserData->m_pLinkData->AddRef(); + pTP->pLinkData = pUserData->m_pLinkData; + } else { + pTP->pLinkData = NULL; + } + DoTabstops(pStyle, pPieceLine); + } + for (i = 0; i < iPieces; i++) { + XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); + FX_FLOAT& fTop = pTP->rtPiece.top; + FX_FLOAT fBaseLineTemp = fTop; + fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; + fTop = std::max(0.0f, fTop); + } + fLinePos += fLineStep + fBaseLine; + } else { + FX_FLOAT fLineStep = 0; + FX_FLOAT fLineWidth = 0; + for (int32_t i = 0; i < iPieces; i++) { + const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i); + CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData; + if (pUserData) + pStyle = pUserData->m_pStyle; + FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; + FX_FLOAT fBaseLine = m_textParser.GetBaseline(m_pTextProvider, pStyle); + FX_FLOAT fLineHeight = m_textParser.GetLineHeight( + m_pTextProvider, pStyle, m_iLines == 0, fVerScale); + if (fBaseLine > 0) { + FX_FLOAT fLineHeightTmp = + fBaseLine + (FX_FLOAT)pPiece->m_iFontSize * fVerScale / 20.0f; + if (fLineHeight < fLineHeightTmp) { + fLineHeight = fLineHeightTmp; + } + } + fLineStep = std::max(fLineStep, fLineHeight); + fLineWidth += pPiece->m_iWidth / 20000.0f; + } + fLinePos += fLineStep; + m_fMaxWidth = std::max(m_fMaxWidth, fLineWidth); + if (m_pLoader && m_pLoader->m_bSaveLineHeight) { + FX_FLOAT fHeight = fLinePos - m_pLoader->m_fLastPos; + m_pLoader->m_fLastPos = fLinePos; + m_pLoader->m_lineHeights.Add(fHeight); + } + } + if (pStyle) { + pStyle->AddRef(); + } + m_pBreak->ClearBreakPieces(); + if (dwStatus == FX_RTFBREAK_ParagraphBreak) { + m_pBreak->Reset(); + if (!pStyle && bEndBreak) { + CXFA_Para para = m_pTextProvider->GetParaNode(); + if (para) { + FX_FLOAT fStartPos = para.GetMarginLeft(); + FX_FLOAT fIndent = para.GetTextIndent(); + if (fIndent > 0) { + fStartPos += fIndent; + } + FX_FLOAT fSpaceBelow = para.GetSpaceBelow(); + if (fSpaceBelow < 0.1f) { + fSpaceBelow = 0; + } + m_pBreak->SetLineStartPos(fStartPos); + fLinePos += fSpaceBelow; + } + } + } + if (pStyle) { + FX_FLOAT fStart = 0; + const FDE_CSSRECT* pRect = pStyle->GetBoundaryStyles()->GetMarginWidth(); + if (pRect) { + fStart = pRect->left.GetValue(); + } + FX_FLOAT fTextIndent = + pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); + if (fTextIndent < 0) { + fStart -= fTextIndent; + } + m_pBreak->SetLineStartPos(fStart); + pStyle->Release(); + } + m_iLines++; +} +void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, + IFDE_SolidBrush* pBrush, + CXFA_PieceLine* pPieceLine, + int32_t iPiece, + FXTEXT_CHARPOS* pCharPos, + const CFX_Matrix& tmDoc2Device) { + const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); + int32_t iCount = GetDisplayPos(pPiece, pCharPos); + if (iCount > 0) { + pBrush->SetColor(pPiece->dwColor); + pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, + pPiece->fFontSize, &tmDoc2Device); + } + pPieceLine->m_charCounts.Add(iCount); +} +void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, + IFDE_Pen* pPen, + CXFA_PieceLine* pPieceLine, + int32_t iPiece, + FXTEXT_CHARPOS* pCharPos, + const CFX_Matrix& tmDoc2Device) { + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); + FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; + FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; + if (bNoUnderline && bNoLineThrough) { + return; + } + pPen->SetColor(pPiece->dwColor); + IFDE_Path* pPath = IFDE_Path::Create(); + int32_t iChars = GetDisplayPos(pPiece, pCharPos); + if (iChars > 0) { + CFX_PointF pt1, pt2; + FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; + int32_t i = 0; + if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { + for (int32_t i = 0; i < pPiece->iUnderline; i++) { + for (int32_t j = 0; j < iChars; j++) { + pt1.x = pCharPos[j].m_OriginX; + pt2.x = + pt1.x + pCharPos[j].m_FontCharWidth * pPiece->fFontSize / 1000.0f; + pt1.y = pt2.y = fEndY; + pPath->AddLine(pt1, pt2); + } + fEndY += 2.0f; + } + } else { + pt1.x = pCharPos[0].m_OriginX; + pt2.x = + pCharPos[iChars - 1].m_OriginX + + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; + for (int32_t i = 0; i < pPiece->iUnderline; i++) { + pt1.y = pt2.y = fEndY; + pPath->AddLine(pt1, pt2); + fEndY += 2.0f; + } + } + fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; + pt1.x = pCharPos[0].m_OriginX; + pt2.x = pCharPos[iChars - 1].m_OriginX + + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; + for (i = 0; i < pPiece->iLineThrough; i++) { + pt1.y = pt2.y = fEndY; + pPath->AddLine(pt1, pt2); + fEndY += 2.0f; + } + } else { + if (bNoLineThrough && + (bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) { + goto XFA_RenderPathRet; + } + int32_t iCharsTmp = 0; + int32_t iPiecePrev = iPiece, iPieceNext = iPiece; + while (iPiecePrev > 0) { + iPiecePrev--; + iCharsTmp = pPieceLine->m_charCounts.GetAt(iPiecePrev); + if (iCharsTmp > 0) { + break; + } + } + if (iCharsTmp == 0) { + goto XFA_RenderPathRet; + } + iCharsTmp = 0; + int32_t iPieces = pPieceLine->m_textPieces.GetSize(); + while (iPieceNext < iPieces - 1) { + iPieceNext++; + iCharsTmp = pPieceLine->m_charCounts.GetAt(iPieceNext); + if (iCharsTmp > 0) { + break; + } + } + if (iCharsTmp == 0) { + goto XFA_RenderPathRet; + } + FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f; + pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev); + iChars = GetDisplayPos(pPiece, pCharPos); + if (iChars < 1) { + goto XFA_RenderPathRet; + } + 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; + } + fEndX = pCharPos[0].m_OriginX; + CFX_PointF pt1, pt2; + pt1.x = fOrgX, pt2.x = fEndX; + FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; + int32_t i = 0; + for (i = 0; i < pPiece->iUnderline; i++) { + pt1.y = pt2.y = fEndY; + pPath->AddLine(pt1, pt2); + fEndY += 2.0f; + } + fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; + for (i = 0; i < pPiece->iLineThrough; i++) { + pt1.y = pt2.y = fEndY; + pPath->AddLine(pt1, pt2); + fEndY += 2.0f; + } + } + pDevice->DrawPath(pPen, 1, pPath, &tmDoc2Device); +XFA_RenderPathRet: + pPath->Release(); +} +int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode) { + if (pPiece == NULL) { + return 0; + } + FX_RTFTEXTOBJ tr; + if (!ToRun(pPiece, tr)) { + return 0; + } + return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); +} +FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { + int32_t iLength = pPiece->iChars; + if (iLength < 1) { + return FALSE; + } + tr.pStr = pPiece->pszText; + tr.pFont = pPiece->pFont; + tr.pRect = &pPiece->rtPiece; + tr.pWidths = pPiece->pWidths; + tr.iLength = iLength; + tr.fFontSize = pPiece->fFontSize; + tr.iBidiLevel = pPiece->iBidiLevel; + tr.iCharRotation = 0; + tr.wLineBreakChar = L'\n'; + tr.iVerticalScale = pPiece->iVerScale; + tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; + tr.iHorizontalScale = pPiece->iHorScale; + return TRUE; +} diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h new file mode 100644 index 0000000000..9cc1e29f3b --- /dev/null +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -0,0 +1,425 @@ +// 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_APP_XFA_TEXTLAYOUT_H_ +#define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ + +#include "xfa/fde/css/fde_css.h" +#include "xfa/fde/fde_brush.h" +#include "xfa/fde/fde_renderdevice.h" +#include "xfa/fgas/layout/fgas_rtfbreak.h" +#include "xfa/fxfa/app/xfa_ffdoc.h" +#include "xfa/fxfa/parser/xfa_object.h" + +#define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001 + +class CXFA_Para; +class CXFA_Font; +class CXFA_TextTabstopsContext; + +class IXFA_TextProvider { + public: + virtual ~IXFA_TextProvider() {} + virtual CXFA_Node* GetTextNode(FX_BOOL& bRichText) = 0; + virtual CXFA_Para GetParaNode() = 0; + virtual CXFA_Font GetFontNode() = 0; + virtual FX_BOOL IsCheckButtonAndAutoWidth() = 0; + virtual CXFA_FFDoc* GetDocNode() = 0; + virtual FX_BOOL GetEmbbedObj(FX_BOOL bURI, + FX_BOOL bRaw, + const CFX_WideString& wsAttr, + CFX_WideString& wsValue) = 0; +}; + +class CXFA_CSSTagProvider : public IFDE_CSSTagProvider { + public: + CXFA_CSSTagProvider() : m_bTagAviliable(FALSE), m_bContent(FALSE) {} + virtual ~CXFA_CSSTagProvider(); + virtual CFX_WideStringC GetTagName() { return m_wsTagName; } + 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); + FX_BOOL m_bTagAviliable; + FX_BOOL m_bContent; + + protected: + CFX_WideString m_wsTagName; + CFX_MapPtrToPtr m_Attributes; +}; + +class CXFA_TextParseContext : public CFX_Target { + public: + CXFA_TextParseContext() + : m_pParentStyle(nullptr), + m_ppMatchedDecls(nullptr), + m_dwMatchedDecls(0), + m_eDisplay(FDE_CSSDISPLAY_None) {} + ~CXFA_TextParseContext() { + if (m_pParentStyle) + m_pParentStyle->Release(); + FX_Free(m_ppMatchedDecls); + } + 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; + } + FX_DWORD CountDecls() const { return m_dwMatchedDecls; } + IFDE_CSSComputedStyle* m_pParentStyle; + + protected: + IFDE_CSSDeclaration** m_ppMatchedDecls; + FX_DWORD m_dwMatchedDecls; + FDE_CSSDISPLAY m_eDisplay; +}; + +class CXFA_TextParser { + public: + CXFA_TextParser() : m_pAllocator(NULL), m_pSelector(NULL), m_pUASheet(NULL) {} + virtual ~CXFA_TextParser(); + void Reset(); + void DoParse(IFDE_XMLNode* pXMLContainer, IXFA_TextProvider* pTextProvider); + IFDE_CSSComputedStyle* CreateRootStyle(IXFA_TextProvider* pTextProvider); + IFDE_CSSComputedStyle* ComputeStyle(IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle); + FX_BOOL IsParsed() const { return m_pAllocator != NULL; } + + int32_t GetVAlgin(IXFA_TextProvider* pTextProvider) const; + FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const; + int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const; + FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const; + FX_BOOL GetTabstops(IFDE_CSSComputedStyle* pStyle, + CXFA_TextTabstopsContext* pTabstopContext); + IFX_Font* GetFont(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; + FX_FLOAT GetFontSize(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; + int32_t GetHorScale(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + IFDE_XMLNode* pXMLNode) const; + int32_t GetVerScale(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; + void GetUnderline(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + int32_t& iUnderline, + int32_t& iPeriod) const; + void GetLinethrough(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + int32_t& iLinethrough) const; + FX_ARGB GetColor(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; + FX_FLOAT GetBaseline(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle) const; + FX_FLOAT GetLineHeight(IXFA_TextProvider* pTextProvider, + IFDE_CSSComputedStyle* pStyle, + FX_BOOL bFirst, + FX_FLOAT fVerScale) const; + FX_BOOL GetEmbbedObj(IXFA_TextProvider* pTextProvider, + IFDE_XMLNode* pXMLNode, + CFX_WideString& wsValue); + CXFA_TextParseContext* GetParseContextFromMap(IFDE_XMLNode* pXMLNode); + + private: + void InitCSSData(IXFA_TextProvider* pTextProvider); + void ParseRichText(IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle); + void ParseTagInfo(IFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); + IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); + IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); + IFX_MEMAllocator* m_pAllocator; + IFDE_CSSStyleSelector* m_pSelector; + IFDE_CSSStyleSheet* m_pUASheet; + CFX_MapPtrTemplate<IFDE_XMLNode*, CXFA_TextParseContext*> + m_mapXMLNodeToParseContext; +}; + +class CXFA_LoaderContext { + public: + CXFA_LoaderContext() + : m_bSaveLineHeight(FALSE), + m_fWidth(0), + m_fHeight(0), + m_fLastPos(0), + m_fStartLineOffset(0), + m_iChar(0), + m_iTotalLines(-1), + m_pXMLNode(NULL), + m_pNode(NULL), + m_pParentStyle(NULL), + m_dwFlags(0) {} + FX_BOOL m_bSaveLineHeight; + FX_FLOAT m_fWidth; + FX_FLOAT m_fHeight; + FX_FLOAT m_fLastPos; + FX_FLOAT m_fStartLineOffset; + int32_t m_iChar; + int32_t m_iLines; + int32_t m_iTotalLines; + IFDE_XMLNode* m_pXMLNode; + CXFA_Node* m_pNode; + IFDE_CSSComputedStyle* m_pParentStyle; + CFX_ArrayTemplate<FX_FLOAT> m_lineHeights; + FX_DWORD m_dwFlags; + CFX_FloatArray m_BlocksHeight; +}; + +class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target { + public: + CXFA_LinkUserData(IFX_MEMAllocator* pAllocator, FX_WCHAR* pszText) + : m_pAllocator(pAllocator), m_dwRefCount(1) { + m_pszURLContent = pszText; + } + ~CXFA_LinkUserData() {} + virtual FX_DWORD Release() { + FX_DWORD dwRefCount = --m_dwRefCount; + if (dwRefCount <= 0) { + FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); + } + return dwRefCount; + } + virtual FX_DWORD AddRef() { return ++m_dwRefCount; } + + public: + const FX_WCHAR* GetLinkURL() { return m_pszURLContent; } + + protected: + IFX_MEMAllocator* m_pAllocator; + FX_DWORD m_dwRefCount; + CFX_WideString m_pszURLContent; +}; + +class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { + public: + CXFA_TextUserData(IFX_MEMAllocator* pAllocator, IFDE_CSSComputedStyle* pStyle) + : m_pStyle(pStyle), + m_pLinkData(nullptr), + m_pAllocator(pAllocator), + m_dwRefCount(0) { + FXSYS_assert(m_pAllocator); + if (m_pStyle) + m_pStyle->AddRef(); + } + CXFA_TextUserData(IFX_MEMAllocator* pAllocator, + IFDE_CSSComputedStyle* pStyle, + CXFA_LinkUserData* pLinkData) + : m_pStyle(pStyle), + m_pLinkData(pLinkData), + m_pAllocator(pAllocator), + m_dwRefCount(0) { + FXSYS_assert(m_pAllocator); + if (m_pStyle) + m_pStyle->AddRef(); + } + ~CXFA_TextUserData() { + if (m_pStyle) + m_pStyle->Release(); + if (m_pLinkData) + m_pLinkData->Release(); + } + virtual FX_DWORD Release() { + FX_DWORD dwRefCount = --m_dwRefCount; + if (dwRefCount == 0) { + FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); + } + return dwRefCount; + } + virtual FX_DWORD AddRef() { return ++m_dwRefCount; } + + IFDE_CSSComputedStyle* m_pStyle; + CXFA_LinkUserData* m_pLinkData; + + protected: + IFX_MEMAllocator* m_pAllocator; + FX_DWORD m_dwRefCount; +}; + +class XFA_TextPiece : public CFX_Target { + public: + XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} + ~XFA_TextPiece() { + if (pLinkData) + pLinkData->Release(); + } + + FX_WCHAR* pszText; + int32_t iChars; + int32_t* pWidths; + int32_t iHorScale; + int32_t iVerScale; + int32_t iBidiLevel; + int32_t iUnderline; + int32_t iPeriod; + int32_t iLineThrough; + IFX_Font* pFont; + FX_ARGB dwColor; + FX_FLOAT fFontSize; + CFX_RectF rtPiece; + CXFA_LinkUserData* pLinkData; +}; +typedef CFX_ArrayTemplate<XFA_TextPiece*> CXFA_PieceArray; + +class CXFA_PieceLine : public CFX_Target { + public: + CXFA_PieceLine() {} + CXFA_PieceArray m_textPieces; + CFX_Int32Array m_charCounts; +}; +typedef CFX_ArrayTemplate<CXFA_PieceLine*> CXFA_PieceLineArray; + +struct XFA_TABSTOPS { + FX_DWORD dwAlign; + FX_FLOAT fTabstops; +}; + +class CXFA_TextTabstopsContext { + public: + CXFA_TextTabstopsContext() + : m_iTabCount(0), + m_iTabIndex(-1), + m_bTabstops(FALSE), + m_fTabWidth(0), + m_fLeft(0) {} + void Append(FX_DWORD dwAlign, FX_FLOAT fTabstops) { + int32_t i = 0; + for (i = 0; i < m_iTabCount; i++) { + XFA_TABSTOPS* pTabstop = m_tabstops.GetDataPtr(i); + if (fTabstops < pTabstop->fTabstops) { + break; + } + } + m_tabstops.InsertSpaceAt(i, 1); + XFA_TABSTOPS tabstop; + tabstop.dwAlign = dwAlign; + tabstop.fTabstops = fTabstops; + m_tabstops.SetAt(i, tabstop); + m_iTabCount++; + } + void RemoveAll() { + m_tabstops.RemoveAll(); + m_iTabCount = 0; + } + void Reset() { + m_iTabIndex = -1; + m_bTabstops = FALSE; + m_fTabWidth = 0; + m_fLeft = 0; + } + CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops; + int32_t m_iTabCount; + int32_t m_iTabIndex; + FX_BOOL m_bTabstops; + FX_FLOAT m_fTabWidth; + FX_FLOAT m_fLeft; +}; + +class CXFA_TextLayout { + public: + CXFA_TextLayout(IXFA_TextProvider* pTextProvider); + virtual ~CXFA_TextLayout(); + int32_t GetText(CFX_WideString& wsText); + FX_FLOAT GetLayoutHeight(); + FX_FLOAT StartLayout(FX_FLOAT fWidth = -1); + FX_BOOL DoLayout(int32_t iBlockIndex, + FX_FLOAT& fCalcHeight, + FX_FLOAT fContentAreaHeight = -1, + FX_FLOAT fTextHeight = -1); + + FX_BOOL CalcSize(const CFX_SizeF& minSize, + const CFX_SizeF& maxSize, + CFX_SizeF& defaultSize); + FX_BOOL Layout(const CFX_SizeF& size, FX_FLOAT* fHeight = NULL); + void ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex); + FX_BOOL DrawString(CFX_RenderDevice* pFxDevice, + const CFX_Matrix& tmDoc2Device, + const CFX_RectF& rtClip, + int32_t iBlock = 0); + FX_BOOL IsLoaded() const { return m_pieceLines.GetSize() > 0; } + void Unload(); + const CXFA_PieceLineArray* GetPieceLines(); + + FX_BOOL m_bHasBlock; + CFX_Int32Array m_Blocks; + + private: + void GetTextDataNode(); + IFDE_XMLNode* GetXMLContainerNode(); + IFX_RTFBreak* CreateBreak(FX_BOOL bDefault); + void InitBreak(FX_FLOAT fLineWidth); + void InitBreak(IFDE_CSSComputedStyle* pStyle, + FDE_CSSDISPLAY eDisplay, + FX_FLOAT fLineWidth, + IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* pParentStyle = NULL); + FX_BOOL Loader(const CFX_SizeF& szText, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces = TRUE); + void LoadText(CXFA_Node* pNode, + const CFX_SizeF& szText, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces); + FX_BOOL LoadRichText(IFDE_XMLNode* pXMLNode, + const CFX_SizeF& szText, + FX_FLOAT& fLinePos, + IFDE_CSSComputedStyle* pParentStyle, + FX_BOOL bSavePieces, + CXFA_LinkUserData* pLinkData = NULL, + FX_BOOL bEndBreak = TRUE, + FX_BOOL bIsOl = FALSE, + int32_t iLiCount = 0); + FX_BOOL AppendChar(const CFX_WideString& wsText, + FX_FLOAT& fLinePos, + FX_FLOAT fSpaceAbove, + FX_BOOL bSavePieces); + void AppendTextLine(FX_DWORD dwStatus, + FX_FLOAT& fLinePos, + FX_BOOL bSavePieces, + FX_BOOL bEndBreak = FALSE); + void EndBreak(FX_DWORD dwStatus, FX_FLOAT& fLinePos, FX_BOOL bDefault); + 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, + CXFA_PieceLine* pPieceLine, + int32_t iPiece, + FXTEXT_CHARPOS* pCharPos, + const CFX_Matrix& tmDoc2Device); + void RenderPath(IFDE_RenderDevice* pDevice, + IFDE_Pen* pPen, + CXFA_PieceLine* pPieceLine, + int32_t iPiece, + FXTEXT_CHARPOS* pCharPos, + const CFX_Matrix& tmDoc2Device); + int32_t GetDisplayPos(const XFA_TextPiece* pPiece, + FXTEXT_CHARPOS* pCharPos, + FX_BOOL bCharCode = FALSE); + FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); + void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); + FX_BOOL Layout(int32_t iBlock); + int32_t CountBlocks() const; + + IXFA_TextProvider* m_pTextProvider; + CXFA_Node* m_pTextDataNode; + FX_BOOL m_bRichText; + IFX_MEMAllocator* m_pAllocator; + IFX_RTFBreak* m_pBreak; + CXFA_LoaderContext* m_pLoader; + int32_t m_iLines; + FX_FLOAT m_fMaxWidth; + CXFA_TextParser m_textParser; + CXFA_PieceLineArray m_pieceLines; + CXFA_TextTabstopsContext* m_pTabstopContext; + FX_BOOL m_bBlockContinue; +}; + +#endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ diff --git a/xfa/fxfa/fm2js/xfa_error.cpp b/xfa/fxfa/fm2js/xfa_error.cpp new file mode 100644 index 0000000000..69ce608318 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_error.cpp @@ -0,0 +1,21 @@ +// 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/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""; +} diff --git a/xfa/fxfa/fm2js/xfa_error.h b/xfa/fxfa/fm2js/xfa_error.h new file mode 100644 index 0000000000..1da1e245c0 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_error.h @@ -0,0 +1,35 @@ +// 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_FM2JS_XFA_ERROR_H_ +#define XFA_FXFA_FM2JS_XFA_ERROR_H_ + +#include "core/include/fxcrt/fx_string.h" +#include "core/include/fxcrt/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 +}; + +class CXFA_FMErrorInfo { + public: + CXFA_FMErrorInfo() : linenum(0) {} + ~CXFA_FMErrorInfo() {} + FX_DWORD linenum; + CFX_WideString message; +}; +const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg); + +#endif // XFA_FXFA_FM2JS_XFA_ERROR_H_ diff --git a/xfa/fxfa/fm2js/xfa_expression.cpp b/xfa/fxfa/fm2js/xfa_expression.cpp new file mode 100644 index 0000000000..b4b1a1ae55 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_expression.cpp @@ -0,0 +1,627 @@ +// 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/fxfa/fm2js/xfa_expression.h" + +#include "core/include/fxcrt/fx_basic.h" + +namespace { + +const CFX_WideStringC RUNTIMEBLOCKTEMPARRAY = + FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array"); + +const CFX_WideStringC RUNTIMEBLOCKTEMPARRAYINDEX = + FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array_index"); + +} // namespace + +CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line) + : m_type(XFA_FM_EXPTYPE_UNKNOWN), m_line(line) {} + +CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type) + : m_type(type), m_line(line) {} + +void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + +void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} + +CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( + FX_DWORD line, + FX_BOOL isGlobal, + const CFX_WideStringC& wsName, + CFX_WideStringCArray* pArguments, + CFX_PtrArray* pExpressions) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC), + m_wsName(wsName), + m_pArguments(pArguments), + m_pExpressions(pExpressions), + m_isGlobal(isGlobal) {} + +CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() { + if (m_pArguments) { + m_pArguments->RemoveAll(); + 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(); + delete m_pExpressions; + } +} + +void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { + if (m_isGlobal && (!m_pExpressions || m_pExpressions->GetSize() == 0)) { + javascript << FX_WSTRC(L"// comments only"); + return; + } + if (m_isGlobal) { + javascript << FX_WSTRC(L"(\n"); + } + javascript << FX_WSTRC(L"function "); + if (m_wsName.GetAt(0) == L'!') { + CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); + javascript << tempName; + } else { + javascript << m_wsName; + } + javascript << FX_WSTRC(L"("); + if (m_pArguments != 0) { + CFX_WideStringC identifier = 0; + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + identifier = m_pArguments->GetAt(i); + if (identifier.GetAt(0) == L'!') { + CFX_WideString tempIdentifier = + EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1); + javascript << tempIdentifier; + } else { + javascript << identifier; + } + if (i + 1 < m_pArguments->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + } + javascript << FX_WSTRC(L")\n{\n"); + javascript << FX_WSTRC(L"var "); + javascript << RUNTIMEFUNCTIONRETURNVALUE; + 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)); + if (i + 1 < m_pExpressions->GetSize()) { + e->ToJavaScript(javascript); + } else { + e->ToImpliedReturnJS(javascript); + } + } + } + javascript << FX_WSTRC(L"return "); + if (m_isGlobal) { + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L")"); + } else { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + } + javascript << FX_WSTRC(L";\n}\n"); + if (m_isGlobal) { + javascript << FX_WSTRC(L").call(this);\n"); + } +} + +void CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {} + +CXFA_FMVarExpression::CXFA_FMVarExpression(FX_DWORD line, + const CFX_WideStringC& wsName, + CXFA_FMExpression* pInit) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_VAR), + m_wsName(wsName), + m_pInit(pInit) {} + +void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"var "); + CFX_WideString tempName = m_wsName; + if (m_wsName.GetAt(0) == L'!') { + tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); + } + javascript << tempName; + javascript << FX_WSTRC(L" = "); + if (m_pInit) { + m_pInit->ToJavaScript(javascript); + javascript << tempName; + javascript << FX_WSTRC(L" = "); + javascript << XFA_FM_EXPTypeToString(VARFILTER); + javascript << FX_WSTRC(L"("); + javascript << tempName; + javascript << FX_WSTRC(L");\n"); + } else { + javascript << FX_WSTRC(L"\"\";\n"); + } +} + +void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"var "); + CFX_WideString tempName = m_wsName; + if (m_wsName.GetAt(0) == L'!') { + tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); + } + javascript << tempName; + javascript << FX_WSTRC(L" = "); + if (m_pInit) { + m_pInit->ToJavaScript(javascript); + javascript << tempName; + javascript << FX_WSTRC(L" = "); + javascript << XFA_FM_EXPTypeToString(VARFILTER); + javascript << FX_WSTRC(L"("); + javascript << tempName; + javascript << FX_WSTRC(L");\n"); + } else { + javascript << FX_WSTRC(L"\"\";\n"); + } + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = "); + javascript << tempName; + javascript << FX_WSTRC(L";\n"); +} + +CXFA_FMExpExpression::CXFA_FMExpExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExpression) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_EXP), m_pExpression(pExpression) {} + +void CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + if (m_pExpression->GetOperatorToken() == TOKassign) { + m_pExpression->ToJavaScript(javascript); + } else { + m_pExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n"); + } +} + +void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + if (m_pExpression->GetOperatorToken() == TOKassign) { + m_pExpression->ToImpliedReturnJS(javascript); + } else { + if (m_pExpression->GetOperatorToken() == TOKstar || + m_pExpression->GetOperatorToken() == TOKdotstar || + m_pExpression->GetOperatorToken() == TOKdotscream || + m_pExpression->GetOperatorToken() == TOKdotdot || + m_pExpression->GetOperatorToken() == TOKdot) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L");\n"); + } else { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = "); + m_pExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n"); + } + } +} + +CXFA_FMBlockExpression::CXFA_FMBlockExpression(FX_DWORD line, + CFX_PtrArray* 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(); + delete m_pExpressionList; + } +} + +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); + } + } + javascript << FX_WSTRC(L"}\n"); +} + +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)); + if (i + 1 == m_pExpressionList->GetSize()) { + e->ToImpliedReturnJS(javascript); + } else { + e->ToJavaScript(javascript); + } + } + } + javascript << FX_WSTRC(L"}\n"); +} + +CXFA_FMDoExpression::CXFA_FMDoExpression(FX_DWORD line, + CXFA_FMExpression* pList) + : CXFA_FMExpression(line), m_pList(pList) {} + +void CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + m_pList->ToJavaScript(javascript); +} + +void CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + m_pList->ToImpliedReturnJS(javascript); +} + +CXFA_FMIfExpression::CXFA_FMIfExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExpression, + CXFA_FMExpression* pIfExpression, + CXFA_FMExpression* pElseExpression) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_IF), + m_pExpression(pExpression), + m_pIfExpression(pIfExpression), + m_pElseExpression(pElseExpression) {} + +void CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"if ("); + if (m_pExpression) { + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + } + javascript << FX_WSTRC(L")\n"); + if (m_pIfExpression) { + m_pIfExpression->ToJavaScript(javascript); + } + if (m_pElseExpression) { + if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { + javascript << FX_WSTRC(L"else\n"); + javascript << FX_WSTRC(L"{\n"); + m_pElseExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L"}\n"); + } else { + javascript << FX_WSTRC(L"else\n"); + m_pElseExpression->ToJavaScript(javascript); + } + } +} + +void CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"if ("); + if (m_pExpression) { + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pExpression->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + } + javascript << FX_WSTRC(L")\n"); + if (m_pIfExpression) { + m_pIfExpression->ToImpliedReturnJS(javascript); + } + if (m_pElseExpression) { + if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { + javascript << FX_WSTRC(L"else\n"); + javascript << FX_WSTRC(L"{\n"); + m_pElseExpression->ToImpliedReturnJS(javascript); + javascript << FX_WSTRC(L"}\n"); + } else { + javascript << FX_WSTRC(L"else\n"); + m_pElseExpression->ToImpliedReturnJS(javascript); + } + } +} + +CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {} + +void CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + +void CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {} + +CXFA_FMWhileExpression::CXFA_FMWhileExpression( + FX_DWORD line, + CXFA_FMSimpleExpression* pCondition, + CXFA_FMExpression* pExpression) + : CXFA_FMLoopExpression(line), + m_pCondition(pCondition), + m_pExpression(pExpression) {} + +void CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"while ("); + m_pCondition->ToJavaScript(javascript); + javascript << FX_WSTRC(L")\n"); + m_pExpression->ToJavaScript(javascript); +} + +void CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"while ("); + m_pCondition->ToJavaScript(javascript); + javascript << FX_WSTRC(L")\n"); + m_pExpression->ToImpliedReturnJS(javascript); +} + +CXFA_FMBreakExpression::CXFA_FMBreakExpression(FX_DWORD line) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_BREAK) {} + +CXFA_FMBreakExpression::~CXFA_FMBreakExpression() {} + +void CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"break;\n"); +} + +void CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"break;\n"); +} + +CXFA_FMContinueExpression::CXFA_FMContinueExpression(FX_DWORD line) + : CXFA_FMExpression(line, XFA_FM_EXPTYPE_CONTINUE) {} + +CXFA_FMContinueExpression::~CXFA_FMContinueExpression() {} + +void CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"continue;\n"); +} + +void CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"continue;\n"); +} + +CXFA_FMForExpression::CXFA_FMForExpression(FX_DWORD line, + const CFX_WideStringC& wsVariant, + CXFA_FMSimpleExpression* pAssignment, + CXFA_FMSimpleExpression* pAccessor, + int32_t iDirection, + CXFA_FMSimpleExpression* pStep, + CXFA_FMExpression* pList) + : CXFA_FMLoopExpression(line), + m_wsVariant(wsVariant), + m_pAssignment(pAssignment), + m_pAccessor(pAccessor), + m_iDirection(iDirection), + m_pStep(pStep), + m_pList(pList) {} + +void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"{\nvar "); + CFX_WideString tempVariant; + if (m_wsVariant.GetAt(0) == L'!') { + tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1); + javascript << tempVariant; + } else { + tempVariant = m_wsVariant; + javascript << m_wsVariant; + } + javascript << FX_WSTRC(L" = null;\n"); + javascript << FX_WSTRC(L"for ("); + javascript << tempVariant; + javascript << FX_WSTRC(L" = "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAssignment->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + if (m_iDirection == 1) { + javascript << FX_WSTRC(L" <= "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAccessor->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + javascript << FX_WSTRC(L" += "); + } else { + javascript << FX_WSTRC(L" >= "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAccessor->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + javascript << FX_WSTRC(L" -= "); + } + if (m_pStep) { + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pStep->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + } else { + javascript << FX_WSTRC(L"1"); + } + javascript << FX_WSTRC(L")\n"); + m_pList->ToJavaScript(javascript); + javascript << FX_WSTRC(L"}\n"); +} + +void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"{\nvar "); + CFX_WideString tempVariant; + if (m_wsVariant.GetAt(0) == L'!') { + tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1); + javascript << tempVariant; + } else { + tempVariant = m_wsVariant; + javascript << m_wsVariant; + } + javascript << FX_WSTRC(L" = null;\n"); + javascript << FX_WSTRC(L"for ("); + javascript << tempVariant; + javascript << FX_WSTRC(L" = "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAssignment->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + if (m_iDirection == 1) { + javascript << FX_WSTRC(L" <= "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAccessor->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + javascript << FX_WSTRC(L" += "); + } else { + javascript << FX_WSTRC(L" >= "); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pAccessor->ToJavaScript(javascript); + javascript << FX_WSTRC(L"); "); + javascript << tempVariant; + javascript << FX_WSTRC(L" -= "); + } + if (m_pStep) { + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << FX_WSTRC(L"("); + m_pStep->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + } else { + javascript << FX_WSTRC(L"1"); + } + javascript << FX_WSTRC(L")\n"); + m_pList->ToImpliedReturnJS(javascript); + javascript << FX_WSTRC(L"}\n"); +} + +CXFA_FMForeachExpression::CXFA_FMForeachExpression( + FX_DWORD line, + const CFX_WideStringC& wsIdentifier, + CFX_PtrArray* pAccessors, + CXFA_FMExpression* pList) + : CXFA_FMLoopExpression(line), + m_wsIdentifier(wsIdentifier), + m_pAccessors(pAccessors), + m_pList(pList) {} + +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(); + delete m_pAccessors; + } +} + +void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"{\n"); + javascript << FX_WSTRC(L"var "); + if (m_wsIdentifier.GetAt(0) == L'!') { + CFX_WideString tempIdentifier = + EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); + javascript << tempIdentifier; + } else { + javascript << m_wsIdentifier; + } + javascript << FX_WSTRC(L" = null;\n"); + javascript << FX_WSTRC(L"var "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L" = "); + 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)); + s->ToJavaScript(javascript); + if (i + 1 < m_pAccessors->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + javascript << FX_WSTRC(L");\n"); + javascript << FX_WSTRC(L"var "); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"while("); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L" < "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L".length)\n{\n"); + if (m_wsIdentifier.GetAt(0) == L'!') { + CFX_WideString tempIdentifier = + EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); + javascript << tempIdentifier; + } else { + javascript << m_wsIdentifier; + } + javascript << FX_WSTRC(L" = "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L"["); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L"++];\n"); + m_pList->ToJavaScript(javascript); + javascript << FX_WSTRC(L"}\n"); + javascript << FX_WSTRC(L"}\n"); +} + +void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"{\n"); + javascript << FX_WSTRC(L"var "); + if (m_wsIdentifier.GetAt(0) == L'!') { + CFX_WideString tempIdentifier = + EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); + javascript << tempIdentifier; + } else { + javascript << m_wsIdentifier; + } + javascript << FX_WSTRC(L" = null;\n"); + javascript << FX_WSTRC(L"var "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L" = "); + 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)); + s->ToJavaScript(javascript); + if (i + 1 < m_pAccessors->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + javascript << FX_WSTRC(L");\n"); + javascript << FX_WSTRC(L"var "); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L" = 0;\n"); + javascript << FX_WSTRC(L"while("); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L" < "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L".length)\n{\n"); + if (m_wsIdentifier.GetAt(0) == L'!') { + CFX_WideString tempIdentifier = + EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); + javascript << tempIdentifier; + } else { + javascript << m_wsIdentifier; + } + javascript << FX_WSTRC(L" = "); + javascript << RUNTIMEBLOCKTEMPARRAY; + javascript << FX_WSTRC(L"["); + javascript << RUNTIMEBLOCKTEMPARRAYINDEX; + javascript << FX_WSTRC(L"++];\n"); + m_pList->ToImpliedReturnJS(javascript); + javascript << FX_WSTRC(L"}\n"); + javascript << FX_WSTRC(L"}\n"); +} diff --git a/xfa/fxfa/fm2js/xfa_expression.h b/xfa/fxfa/fm2js/xfa_expression.h new file mode 100644 index 0000000000..0b99e8da13 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_expression.h @@ -0,0 +1,191 @@ +// 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_FM2JS_XFA_EXPRESSION_H_ +#define XFA_FXFA_FM2JS_XFA_EXPRESSION_H_ + +#include <memory> + +#include "xfa/fxfa/fm2js/xfa_simpleexpression.h" + +enum XFA_FM_EXPTYPE { + XFA_FM_EXPTYPE_UNKNOWN, + XFA_FM_EXPTYPE_FUNC, + XFA_FM_EXPTYPE_VAR, + XFA_FM_EXPTYPE_EXP, + XFA_FM_EXPTYPE_BLOCK, + XFA_FM_EXPTYPE_IF, + XFA_FM_EXPTYPE_BREAK, + XFA_FM_EXPTYPE_CONTINUE, +}; + +class CXFA_FMExpression { + public: + explicit CXFA_FMExpression(FX_DWORD line); + CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type); + virtual ~CXFA_FMExpression() {} + virtual void ToJavaScript(CFX_WideTextBuf& javascript); + virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + FX_DWORD GetLine() { return m_line; } + XFA_FM_EXPTYPE GetExpType() const { return m_type; } + + protected: + XFA_FM_EXPTYPE m_type; + FX_DWORD m_line; +}; + +class CXFA_FMFunctionDefinition : public CXFA_FMExpression { + public: + CXFA_FMFunctionDefinition(FX_DWORD line, + FX_BOOL isGlobal, + const CFX_WideStringC& wsName, + CFX_WideStringCArray* pArguments, + CFX_PtrArray* 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; + FX_BOOL m_isGlobal; +}; + +class CXFA_FMVarExpression : public CXFA_FMExpression { + public: + CXFA_FMVarExpression(FX_DWORD line, + const CFX_WideStringC& wsName, + CXFA_FMExpression* pInit); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + CFX_WideStringC m_wsName; + std::unique_ptr<CXFA_FMExpression> m_pInit; +}; + +class CXFA_FMExpExpression : public CXFA_FMExpression { + public: + CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; +}; + +class CXFA_FMBlockExpression : public CXFA_FMExpression { + public: + CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList); + ~CXFA_FMBlockExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + CFX_PtrArray* m_pExpressionList; +}; + +class CXFA_FMDoExpression : public CXFA_FMExpression { + public: + CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + std::unique_ptr<CXFA_FMExpression> m_pList; +}; + +class CXFA_FMIfExpression : public CXFA_FMExpression { + public: + CXFA_FMIfExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExpression, + CXFA_FMExpression* pIfExpression, + CXFA_FMExpression* pElseExpression); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; + std::unique_ptr<CXFA_FMExpression> m_pIfExpression; + std::unique_ptr<CXFA_FMExpression> m_pElseExpression; +}; + +class CXFA_FMLoopExpression : public CXFA_FMExpression { + public: + explicit CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} + ~CXFA_FMLoopExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; +}; + +class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { + public: + CXFA_FMWhileExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pCodition, + CXFA_FMExpression* pExpression); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + std::unique_ptr<CXFA_FMSimpleExpression> m_pCondition; + std::unique_ptr<CXFA_FMExpression> m_pExpression; +}; + +class CXFA_FMBreakExpression : public CXFA_FMExpression { + public: + explicit CXFA_FMBreakExpression(FX_DWORD line); + ~CXFA_FMBreakExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; +}; + +class CXFA_FMContinueExpression : public CXFA_FMExpression { + public: + explicit CXFA_FMContinueExpression(FX_DWORD line); + ~CXFA_FMContinueExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; +}; + +class CXFA_FMForExpression : public CXFA_FMLoopExpression { + public: + CXFA_FMForExpression(FX_DWORD line, + const CFX_WideStringC& wsVariant, + CXFA_FMSimpleExpression* pAssignment, + CXFA_FMSimpleExpression* pAccessor, + int32_t iDirection, + CXFA_FMSimpleExpression* pStep, + CXFA_FMExpression* pList); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; + + private: + CFX_WideStringC m_wsVariant; + std::unique_ptr<CXFA_FMSimpleExpression> m_pAssignment; + std::unique_ptr<CXFA_FMSimpleExpression> m_pAccessor; + int32_t m_iDirection; + std::unique_ptr<CXFA_FMSimpleExpression> m_pStep; + std::unique_ptr<CXFA_FMExpression> m_pList; +}; + +class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { + public: + CXFA_FMForeachExpression(FX_DWORD line, + const CFX_WideStringC& wsIdentifier, + CFX_PtrArray* 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; + std::unique_ptr<CXFA_FMExpression> m_pList; +}; + +#endif // XFA_FXFA_FM2JS_XFA_EXPRESSION_H_ diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp b/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp new file mode 100644 index 0000000000..3a6bc17a25 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp @@ -0,0 +1,65 @@ +// 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/fxfa/fm2js/xfa_fm2jsapi.h" + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" +#include "xfa/fxfa/fm2js/xfa_program.h" +#include "xfa/fxfa/parser/xfa_document.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, + CFX_WideTextBuf& wsJavascript, + CFX_WideString& wsError) { + if (wsFormcalc.IsEmpty()) { + wsJavascript.Clear(); + wsError.Empty(); + return 0; + } + int32_t status = 0; + CXFA_FMProgram program; + status = program.Init(wsFormcalc); + if (status) { + wsError = program.GetError().message; + return status; + } + status = program.ParseProgram(); + if (status) { + wsError = program.GetError().message; + return status; + } + program.TranslateProgram(wsJavascript); + return 0; +} +XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate() { + return (XFA_HFM2JSCONTEXT)CXFA_FM2JSContext::Create(); +} +void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, + FXJSE_HRUNTIME hScriptRuntime, + FXJSE_HCONTEXT hScriptContext, + CXFA_Document* pDocument) { + CXFA_FM2JSContext* pContext = + reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); + pContext->Initialize(hScriptRuntime, hScriptContext, pDocument); +} +void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, + FXJSE_HVALUE hValue) { + CXFA_FM2JSContext* pContext = + reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); + pContext->GlobalPropertyGetter(hValue); +} +void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext) { + CXFA_FM2JSContext* pContext = + reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); + pContext->Release(); +} +#ifdef __cplusplus +} +#endif diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.h b/xfa/fxfa/fm2js/xfa_fm2jsapi.h new file mode 100644 index 0000000000..246bc8f255 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fm2jsapi.h @@ -0,0 +1,37 @@ +// 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_FM2JS_XFA_FM2JSAPI_H_ +#define XFA_FXFA_FM2JS_XFA_FM2JSAPI_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/include/fxjse/fxjse.h" + +#define FOXIT_XFA_FM2JS_FORMCALC_RUNTIME "foxit_xfa_formcalc_runtime" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct XFA_HFM2JSCONTEXT_ { void** pData; } * XFA_HFM2JSCONTEXT; +int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, + CFX_WideTextBuf& wsJavascript, + CFX_WideString& wsError); +XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate(); +void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, + FXJSE_HRUNTIME hScriptRuntime, + FXJSE_HCONTEXT hScriptContext, + CXFA_Document* pDocument); +void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, + FXJSE_HVALUE hValue); +void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext); + +#ifdef __cplusplus +} +#endif + +#endif // XFA_FXFA_FM2JS_XFA_FM2JSAPI_H_ diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp new file mode 100644 index 0000000000..9de6e1c9f4 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -0,0 +1,7223 @@ +// 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/fxfa/fm2js/xfa_fm2jscontext.h" + +#include <time.h> + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/localization/fgas_locale.h" +#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/xfa_localevalue.h" +#include "xfa/fxfa/parser/xfa_parser.h" + +#define FINANCIAL_PRECISION 0.00000001 + +namespace { + +struct XFA_FMHtmlReserveCode { + uint32_t m_uCode; + const FX_WCHAR* m_htmlReserve; +}; +struct XFA_FMHtmlHashedReserveCode { + uint32_t m_uHash; + const FX_WCHAR* m_htmlReserve; + uint32_t m_uCode; +}; + +const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { + {0x00018b62, L"Mu", 924}, {0x00019083, L"Nu", 925}, + {0x00019ab9, L"Pi", 928}, {0x0001c3c1, L"Xi", 926}, + {0x000210ac, L"ge", 8805}, {0x000210bb, L"gt", 62}, + {0x00022a51, L"le", 8804}, {0x00022a60, L"lt", 60}, + {0x00022f82, L"mu", 956}, {0x00023493, L"ne", 8800}, + {0x00023497, L"ni", 8715}, {0x000234a3, L"nu", 957}, + {0x000239c1, L"or", 8744}, {0x00023ed9, L"pi", 960}, + {0x000267e1, L"xi", 958}, {0x00c41789, L"lceil", 8968}, + {0x00eef34f, L"thetasym", 977}, {0x012d7ead, L"lcirc", 206}, + {0x01637b56, L"agrave", 224}, {0x020856da, L"crarr", 8629}, + {0x022188c3, L"gamma", 947}, {0x033586d3, L"nbsp", 160}, + {0x04f4c358, L"nsub", 8836}, {0x0581466a, L"dagger", 8224}, + {0x06b1f790, L"oelig", 339}, {0x06e490d4, L"Chi", 935}, + {0x0718c6a1, L"ETH", 208}, {0x07196ada, L"Eta", 919}, + {0x07f667ca, L"Ugrave", 217}, {0x083a8a21, L"Phi", 934}, + {0x083ac28c, L"Psi", 936}, {0x086f26a9, L"Rho", 929}, + {0x089b5b51, L"aring", 229}, {0x08a39f4a, L"Tau", 932}, + {0x08b6188b, L"THORN", 222}, {0x09ce792a, L"icirc", 238}, + {0x09f9d61e, L"amp", 38}, {0x09f9db33, L"and", 8743}, + {0x09f9db36, L"ang", 8736}, {0x0a2e3514, L"cap", 8745}, + {0x0a2e58f4, L"chi", 967}, {0x0a2e9ba8, L"cup", 8746}, + {0x0a4897d0, L"deg", 176}, {0x0a6332fa, L"eta", 951}, + {0x0a633301, L"eth", 240}, {0x0acc4d4b, L"int", 8747}, + {0x0b1b3d35, L"loz", 9674}, {0x0b1b4c8b, L"lrm", 8206}, + {0x0b4fd9b1, L"not", 172}, {0x0b845241, L"phi", 966}, + {0x0b84576f, L"piv", 982}, {0x0b848aac, L"psi", 968}, + {0x0bb8df5e, L"reg", 174}, {0x0bb8eec9, L"rho", 961}, + {0x0bb9034b, L"rlm", 8207}, {0x0bd33d14, L"shy", 173}, + {0x0bd34229, L"sim", 8764}, {0x0bd37faa, L"sub", 8834}, + {0x0bd37fb5, L"sum", 8721}, {0x0bd37fb8, L"sup", 8835}, + {0x0bed676a, L"tau", 964}, {0x0c07f32e, L"uml", 168}, + {0x0c71032c, L"yen", 165}, {0x0c7f2889, L"szlig", 223}, + {0x0c8badbb, L"zwj", 8205}, {0x10ba4dba, L"Egrave", 200}, + {0x10f1ea24, L"para", 182}, {0x10f1ea37, L"part", 8706}, + {0x115b2337, L"perp", 8869}, {0x12b10d15, L"prod", 8719}, + {0x12b10d21, L"prop", 8733}, {0x12dfa9f4, L"rfloor", 8971}, + {0x12eb4736, L"Agrave", 192}, {0x12fff2b7, L"pund", 163}, + {0x13fda9f2, L"tilde", 732}, {0x1417fd62, L"times", 215}, + {0x154fc726, L"ecirc", 234}, {0x165aa451, L"sigma", 963}, + {0x1709124a, L"Dagger", 8225}, {0x192f78d5, L"iexcl", 161}, + {0x1b7ed8d7, L"rArr", 8658}, {0x1ec88c68, L"rang", 9002}, + {0x1ec8a0f7, L"rarr", 8594}, {0x1eda07f3, L"atilde", 227}, + {0x1f3182c4, L"real", 8476}, {0x1fc34f8b, L"yacute", 253}, + {0x20d11522, L"acirc", 226}, {0x21933a9b, L"rsaquo", 8250}, + {0x21f44907, L"uacute", 250}, {0x220cca72, L"acute", 180}, + {0x242cded1, L"alefsym", 8501}, {0x2655c66a, L"delta", 948}, + {0x269e4b4d, L"exist", 8707}, {0x273379fa, L"micro", 181}, + {0x27a37440, L"forall", 8704}, {0x2854e62c, L"minus", 8722}, + {0x28636f81, L"cedil", 184}, {0x2887357b, L"iacute", 237}, + {0x2994d5ff, L"frac12", 189}, {0x2994d601, L"frac14", 188}, + {0x2994e043, L"frac34", 190}, {0x2a1feb41, L"lambda", 955}, + {0x2ab215f3, L"apos", 39}, {0x2ab82ef7, L"eacute", 233}, + {0x2b3592ef, L"auml", 228}, {0x2ce92873, L"aacute", 225}, + {0x2daff48a, L"oslash", 248}, {0x2ef68882, L"aelig", 230}, + {0x3061d3d3, L"Atilde", 195}, {0x314b1b6b, L"Yacute", 221}, + {0x337c14e7, L"Uacute", 218}, {0x37676aca, L"cent", 162}, + {0x37d0b841, L"circ", 710}, {0x386e7947, L"cong", 8773}, + {0x386e839b, L"copy", 169}, {0x3a0e225a, L"Epsilon", 917}, + {0x3ba7b721, L"Lambda", 923}, {0x3bd9abe6, L"Alpha", 913}, + {0x3c3ffad7, L"Eacute", 201}, {0x3cfaf69f, L"brvbar", 166}, + {0x3d54a489, L"omega", 969}, {0x3e70f453, L"Aacute", 193}, + {0x3f37c06a, L"Oslash", 216}, {0x40e1b34e, L"diams", 9830}, + {0x416596df, L"plusmn", 177}, {0x4354ff16, L"Ucirc", 219}, + {0x454fce6a, L"Upsilon", 933}, {0x4610ad35, L"emsp", 8195}, + {0x462afb76, L"ensp", 8194}, {0x46e30073, L"euml", 235}, + {0x46e31a1b, L"euro", 8364}, {0x46f2eada, L"lowast", 8727}, + {0x4dca26cf, L"Auml", 196}, {0x4e2d6083, L"image", 8465}, + {0x4f964ee8, L"notin", 8713}, {0x50917a7a, L"epsilon", 949}, + {0x52f9a4cd, L"Kappa", 922}, {0x5496f410, L"Ocirc", 212}, + {0x568cbf34, L"zeta", 950}, {0x57badd20, L"ntilde", 241}, + {0x58662109, L"zwnj", 8204}, {0x5b39870f, L"empty", 8709}, + {0x5bd3268a, L"upsilon", 965}, {0x5e2bf8a3, L"Gamma", 915}, + {0x5f73c13a, L"rsquo", 8217}, {0x61f2bc4d, L"iota", 953}, + {0x625bbcf3, L"isin", 8712}, {0x62906df7, L"iuml", 239}, + {0x64a5cb31, L"Aring", 197}, {0x66f25c4a, L"sbquo", 8218}, + {0x6851ab60, L"spades", 9824}, {0x6942a900, L"Ntilde", 209}, + {0x69779453, L"Euml", 203}, {0x6cda6e23, L"current", 164}, + {0x70b5b634, L"lsquo", 8216}, {0x715a3706, L"Ecirc", 202}, + {0x71e8bf8d, L"tdquo", 8221}, {0x72651431, L"Sigma", 931}, + {0x7569813b, L"iquest", 191}, {0x776a436a, L"equiv", 8801}, + {0x79215314, L"Zeta", 918}, {0x79b81224, L"ograve", 242}, + {0x7c2f8b23, L"macr", 175}, {0x7cdb8502, L"Acirc", 194}, + {0x8185c62e, L"ndash", 8211}, {0x8260364a, L"Delta", 916}, + {0x846619ad, L"mdash", 8212}, {0x8550fb50, L"OElig", 338}, + {0x88eb5b85, L"ldquo", 8220}, {0x8b3fde04, L"Ograve", 210}, + {0x8bc5794b, L"ordf", 170}, {0x8bc57952, L"ordm", 186}, + {0x8c14923d, L"ouml", 246}, {0x8c5a7cd6, L"theta", 952}, + {0x8d61812b, L"thorn", 254}, {0x912b95aa, L"asymp", 8776}, + {0x947faf81, L"middot", 183}, {0x9629202e, L"lfloor", 8970}, + {0x972e9ec1, L"otilde", 245}, {0x9748f231, L"otimes", 8855}, + {0x995f1469, L"Omega", 937}, {0x99eb5349, L"quot", 34}, + {0x9aeb639e, L"hellip", 8230}, {0xa0ae2f86, L"Scaron", 352}, + {0xa4dcb0d5, L"lsaquo", 8249}, {0xa53dbf41, L"oacute", 243}, + {0xa5ae9e7b, L"bdquo", 8222}, {0xa602d7ba, L"sdot", 8901}, + {0xa61ce86f, L"sect", 167}, {0xa6e4c3d7, L"sigmaf", 962}, + {0xa7c1c74f, L"sube", 8838}, {0xa7c20ee9, L"sup1", 185}, + {0xa7c20eea, L"sup2", 178}, {0xa7c20eeb, L"sup3", 179}, + {0xa7c20f1d, L"supe", 8839}, {0xa8b66aa1, L"Otilde", 213}, + {0xad958c42, L"AElig", 198}, {0xaea9261d, L"Ouml", 214}, + {0xb040eafa, L"uArr", 8657}, {0xb07c2e1c, L"beta", 946}, + {0xb220e92f, L"bull", 8226}, {0xb22750c4, L"ccedil", 231}, + {0xb38ab31a, L"uarr", 8593}, {0xb598b683, L"uuml", 252}, + {0xb6c58b21, L"Oacute", 211}, {0xb6d2a617, L"oline", 8254}, + {0xba9fd989, L"dArr", 8659}, {0xbb5ccd41, L"lgrave", 204}, + {0xbd39b44c, L"weierp", 8472}, {0xbde9a1a9, L"darr", 8595}, + {0xc027e329, L"permil", 8240}, {0xc2451389, L"upsih", 978}, + {0xc3af1ca4, L"Ccedil", 199}, {0xcd164249, L"fnof", 402}, + {0xcf6c8467, L"hearts", 9829}, {0xd1228390, L"trade", 8482}, + {0xd1462407, L"yuml", 255}, {0xd2cf2253, L"oplus", 8853}, + {0xd310c1fc, L"Beta", 914}, {0xd59c4d74, L"infin", 8734}, + {0xd64d470d, L"hArr", 8660}, {0xd67d9c75, L"divide", 247}, + {0xd698dd37, L"Omicron", 927}, {0xd82d4a63, L"Uuml", 220}, + {0xd9970f2d, L"harr", 8596}, {0xda91fd99, L"clubs", 9827}, + {0xdbe5bdcc, L"there4", 8756}, {0xdd7671bd, L"prime", 8242}, + {0xdfcf3c06, L"alpha", 945}, {0xe0213063, L"saron", 353}, + {0xe1911d83, L"radic", 8730}, {0xe2e75468, L"raquo", 187}, + {0xe6e27a5e, L"lacute", 205}, {0xe74a8f36, L"ucirc", 251}, + {0xe864ecb6, L"Theta", 920}, {0xecddde5e, L"nabla", 8711}, + {0xed1c3557, L"omicron", 959}, {0xef82228f, L"rceil", 8969}, + {0xf1fab491, L"lArr", 8656}, {0xf3dab7e7, L"Yuml", 376}, + {0xf4294962, L"laquo", 171}, {0xf5446822, L"lang", 9001}, + {0xf5447cb1, L"larr", 8592}, {0xf66e9bea, L"ugrave", 249}, + {0xf6b4ce70, L"lota", 921}, {0xf6ef34ed, L"kappa", 954}, + {0xf72a3a56, L"thinsp", 8201}, {0xf752801a, L"luml", 207}, + {0xf88c8430, L"ocirc", 244}, {0xf9676178, L"frasl", 8260}, + {0xfd01885e, L"igrave", 236}, {0xff3281da, L"egrave", 232}, +}; + +const XFA_FMHtmlReserveCode reservesForEncode[] = { + {34, L"quot"}, {38, L"amp"}, {39, L"apos"}, + {60, L"lt"}, {62, L"gt"}, {160, L"nbsp"}, + {161, L"iexcl"}, {162, L"cent"}, {163, L"pund"}, + {164, L"current"}, {165, L"yen"}, {166, L"brvbar"}, + {167, L"sect"}, {168, L"uml"}, {169, L"copy"}, + {170, L"ordf"}, {171, L"laquo"}, {172, L"not"}, + {173, L"shy"}, {174, L"reg"}, {175, L"macr"}, + {176, L"deg"}, {177, L"plusmn"}, {178, L"sup2"}, + {179, L"sup3"}, {180, L"acute"}, {181, L"micro"}, + {182, L"para"}, {183, L"middot"}, {184, L"cedil"}, + {185, L"sup1"}, {186, L"ordm"}, {187, L"raquo"}, + {188, L"frac14"}, {189, L"frac12"}, {190, L"frac34"}, + {191, L"iquest"}, {192, L"Agrave"}, {193, L"Aacute"}, + {194, L"Acirc"}, {195, L"Atilde"}, {196, L"Auml"}, + {197, L"Aring"}, {198, L"AElig"}, {199, L"Ccedil"}, + {200, L"Egrave"}, {201, L"Eacute"}, {202, L"Ecirc"}, + {203, L"Euml"}, {204, L"lgrave"}, {205, L"lacute"}, + {206, L"lcirc"}, {207, L"luml"}, {208, L"ETH"}, + {209, L"Ntilde"}, {210, L"Ograve"}, {211, L"Oacute"}, + {212, L"Ocirc"}, {213, L"Otilde"}, {214, L"Ouml"}, + {215, L"times"}, {216, L"Oslash"}, {217, L"Ugrave"}, + {218, L"Uacute"}, {219, L"Ucirc"}, {220, L"Uuml"}, + {221, L"Yacute"}, {222, L"THORN"}, {223, L"szlig"}, + {224, L"agrave"}, {225, L"aacute"}, {226, L"acirc"}, + {227, L"atilde"}, {228, L"auml"}, {229, L"aring"}, + {230, L"aelig"}, {231, L"ccedil"}, {232, L"egrave"}, + {233, L"eacute"}, {234, L"ecirc"}, {235, L"euml"}, + {236, L"igrave"}, {237, L"iacute"}, {238, L"icirc"}, + {239, L"iuml"}, {240, L"eth"}, {241, L"ntilde"}, + {242, L"ograve"}, {243, L"oacute"}, {244, L"ocirc"}, + {245, L"otilde"}, {246, L"ouml"}, {247, L"divide"}, + {248, L"oslash"}, {249, L"ugrave"}, {250, L"uacute"}, + {251, L"ucirc"}, {252, L"uuml"}, {253, L"yacute"}, + {254, L"thorn"}, {255, L"yuml"}, {338, L"OElig"}, + {339, L"oelig"}, {352, L"Scaron"}, {353, L"saron"}, + {376, L"Yuml"}, {402, L"fnof"}, {710, L"circ"}, + {732, L"tilde"}, {913, L"Alpha"}, {914, L"Beta"}, + {915, L"Gamma"}, {916, L"Delta"}, {917, L"Epsilon"}, + {918, L"Zeta"}, {919, L"Eta"}, {920, L"Theta"}, + {921, L"lota"}, {922, L"Kappa"}, {923, L"Lambda"}, + {924, L"Mu"}, {925, L"Nu"}, {926, L"Xi"}, + {927, L"Omicron"}, {928, L"Pi"}, {929, L"Rho"}, + {931, L"Sigma"}, {932, L"Tau"}, {933, L"Upsilon"}, + {934, L"Phi"}, {935, L"Chi"}, {936, L"Psi"}, + {937, L"Omega"}, {945, L"alpha"}, {946, L"beta"}, + {947, L"gamma"}, {948, L"delta"}, {949, L"epsilon"}, + {950, L"zeta"}, {951, L"eta"}, {952, L"theta"}, + {953, L"iota"}, {954, L"kappa"}, {955, L"lambda"}, + {956, L"mu"}, {957, L"nu"}, {958, L"xi"}, + {959, L"omicron"}, {960, L"pi"}, {961, L"rho"}, + {962, L"sigmaf"}, {963, L"sigma"}, {964, L"tau"}, + {965, L"upsilon"}, {966, L"phi"}, {967, L"chi"}, + {968, L"psi"}, {969, L"omega"}, {977, L"thetasym"}, + {978, L"upsih"}, {982, L"piv"}, {8194, L"ensp"}, + {8195, L"emsp"}, {8201, L"thinsp"}, {8204, L"zwnj"}, + {8205, L"zwj"}, {8206, L"lrm"}, {8207, L"rlm"}, + {8211, L"ndash"}, {8212, L"mdash"}, {8216, L"lsquo"}, + {8217, L"rsquo"}, {8218, L"sbquo"}, {8220, L"ldquo"}, + {8221, L"tdquo"}, {8222, L"bdquo"}, {8224, L"dagger"}, + {8225, L"Dagger"}, {8226, L"bull"}, {8230, L"hellip"}, + {8240, L"permil"}, {8242, L"prime"}, {8249, L"lsaquo"}, + {8250, L"rsaquo"}, {8254, L"oline"}, {8260, L"frasl"}, + {8364, L"euro"}, {8465, L"image"}, {8472, L"weierp"}, + {8476, L"real"}, {8482, L"trade"}, {8501, L"alefsym"}, + {8592, L"larr"}, {8593, L"uarr"}, {8594, L"rarr"}, + {8595, L"darr"}, {8596, L"harr"}, {8629, L"crarr"}, + {8656, L"lArr"}, {8657, L"uArr"}, {8658, L"rArr"}, + {8659, L"dArr"}, {8660, L"hArr"}, {8704, L"forall"}, + {8706, L"part"}, {8707, L"exist"}, {8709, L"empty"}, + {8711, L"nabla"}, {8712, L"isin"}, {8713, L"notin"}, + {8715, L"ni"}, {8719, L"prod"}, {8721, L"sum"}, + {8722, L"minus"}, {8727, L"lowast"}, {8730, L"radic"}, + {8733, L"prop"}, {8734, L"infin"}, {8736, L"ang"}, + {8743, L"and"}, {8744, L"or"}, {8745, L"cap"}, + {8746, L"cup"}, {8747, L"int"}, {8756, L"there4"}, + {8764, L"sim"}, {8773, L"cong"}, {8776, L"asymp"}, + {8800, L"ne"}, {8801, L"equiv"}, {8804, L"le"}, + {8805, L"ge"}, {8834, L"sub"}, {8835, L"sup"}, + {8836, L"nsub"}, {8838, L"sube"}, {8839, L"supe"}, + {8853, L"oplus"}, {8855, L"otimes"}, {8869, L"perp"}, + {8901, L"sdot"}, {8968, L"lceil"}, {8969, L"rceil"}, + {8970, L"lfloor"}, {8971, L"rfloor"}, {9001, L"lang"}, + {9002, L"rang"}, {9674, L"loz"}, {9824, L"spades"}, + {9827, L"clubs"}, {9829, L"hearts"}, {9830, L"diams"}, +}; + +} // namespace + +void CXFA_FM2JSContext::Abs(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, argOne); + if (dValue < 0) { + dValue = -dValue; + } + FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Abs"); + } +} +void CXFA_FM2JSContext::Avg(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint32_t uCount = 0; + FX_DOUBLE dSum = 0.0; + if (argc >= 1) { + FXJSE_HVALUE argValue = 0; + for (int32_t i = 0; i < argc; i++) { + argValue = args.GetValue(i); + if (FXJSE_Value_IsNull(argValue)) { + FXJSE_Value_Release(argValue); + continue; + } else if (FXJSE_Value_IsArray(argValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); + FXJSE_HVALUE defaultPropValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(jsObjectValue, defaultPropValue); + if (!FXJSE_Value_IsNull(defaultPropValue)) { + dSum += HValueToDouble(hThis, defaultPropValue); + uCount++; + } + FXJSE_Value_Release(defaultPropValue); + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + 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, + newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + dSum += HValueToDouble(hThis, newPropertyValue); + uCount++; + } + } + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(propertyValue); + } + } else { + dSum += HValueToDouble(hThis, argValue); + uCount++; + } + FXJSE_Value_Release(argValue); + } + argValue = 0; + } + if (0 == uCount) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); + } +} +void CXFA_FM2JSContext::Ceil(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argValue)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetFloat(args.GetReturnValue(), + FXSYS_ceil(HValueToFloat(hThis, argValue))); + } + FXJSE_Value_Release(argValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Ceil"); + } +} +void CXFA_FM2JSContext::Count(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint32_t uCount = 0; + FXJSE_HVALUE argValue = 0; + for (int32_t i = 0; i < argc; i++) { + argValue = args.GetValue(i); + if (FXJSE_Value_IsNull(argValue)) { + FXJSE_Value_Release(argValue); + continue; + } else if (FXJSE_Value_IsArray(argValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + GetObjectDefaultValue(jsObjectValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + } + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); + } + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(newPropertyValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else if (FXJSE_Value_IsObject(argValue)) { + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(argValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + } + FXJSE_Value_Release(newPropertyValue); + } else { + uCount++; + } + FXJSE_Value_Release(argValue); + } + argValue = 0; + FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); +} +void CXFA_FM2JSContext::Floor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argValue)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetFloat(args.GetReturnValue(), + FXSYS_floor(HValueToFloat(hThis, argValue))); + } + FXJSE_Value_Release(argValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Floor"); + } +} +void CXFA_FM2JSContext::Max(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint32_t uCount = 0; + FX_DOUBLE dMaxValue = 0.0; + FXJSE_HVALUE argValue = 0; + for (int32_t i = 0; i < argc; i++) { + argValue = args.GetValue(i); + if (FXJSE_Value_IsNull(argValue)) { + FXJSE_Value_Release(argValue); + continue; + } else if (FXJSE_Value_IsArray(argValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + GetObjectDefaultValue(jsObjectValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMaxValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMaxValue < dValue) { + dMaxValue = dValue; + } + } + } + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMaxValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMaxValue < dValue) { + dMaxValue = dValue; + } + } + } + } + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(newPropertyValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else if (FXJSE_Value_IsObject(argValue)) { + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(argValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMaxValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMaxValue < dValue) { + dMaxValue = dValue; + } + } + } + FXJSE_Value_Release(newPropertyValue); + } else { + uCount++; + if (uCount == 1) { + dMaxValue = HValueToDouble(hThis, argValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, argValue); + if (dMaxValue < dValue) { + dMaxValue = dValue; + } + } + } + FXJSE_Value_Release(argValue); + } + argValue = 0; + if (uCount) { + FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } +} +void CXFA_FM2JSContext::Min(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint32_t uCount = 0; + FX_DOUBLE dMinValue = 0.0; + FXJSE_HVALUE argValue = 0; + for (int32_t i = 0; i < argc; i++) { + argValue = args.GetValue(i); + if (FXJSE_Value_IsNull(argValue)) { + FXJSE_Value_Release(argValue); + continue; + } else if (FXJSE_Value_IsArray(argValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + GetObjectDefaultValue(jsObjectValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMinValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMinValue > dValue) { + dMinValue = dValue; + } + } + } + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + for (int32_t i = 2; i < iLength; i++) { + FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMinValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMinValue > dValue) { + dMinValue = dValue; + } + } + } + } + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(newPropertyValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else if (FXJSE_Value_IsObject(argValue)) { + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(argValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + uCount++; + if (uCount == 1) { + dMinValue = HValueToDouble(hThis, newPropertyValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); + if (dMinValue > dValue) { + dMinValue = dValue; + } + } + } + FXJSE_Value_Release(newPropertyValue); + } else { + uCount++; + if (uCount == 1) { + dMinValue = HValueToDouble(hThis, argValue); + } else { + FX_DOUBLE dValue = HValueToDouble(hThis, argValue); + if (dMinValue > dValue) { + dMinValue = dValue; + } + } + } + FXJSE_Value_Release(argValue); + } + argValue = 0; + if (uCount) { + FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } +} +void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + if (args.GetLength() == 2) { + FXJSE_HVALUE argOne = args.GetValue(0); + FXJSE_HVALUE argTwo = args.GetValue(1); + if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE dDividend = 0.0; + FX_DOUBLE dDividor = 0.0; + if (FXJSE_Value_IsArray(argOne)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + dDividend = HValueToDouble(hThis, jsObjectValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + dDividend = HValueToDouble(hThis, newPropertyValue); + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + dDividend = HValueToDouble(hThis, argOne); + } + if (FXJSE_Value_IsArray(argTwo)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + dDividor = HValueToDouble(hThis, jsObjectValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + dDividor = HValueToDouble(hThis, newPropertyValue); + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + dDividor = HValueToDouble(hThis, argTwo); + } + if (dDividor) { + FXJSE_Value_SetDouble( + args.GetReturnValue(), + dDividend - dDividor * (int32_t)(dDividend / dDividor)); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Mod"); + } +} +void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint8_t uPrecision = 0; + if (argc == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE dValue = 0.0; + if (FXJSE_Value_IsArray(argOne)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + dValue = HValueToDouble(hThis, jsObjectValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + dValue = HValueToDouble(hThis, newPropertyValue); + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + dValue = HValueToDouble(hThis, argOne); + } + CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); + CFX_WideString wsValue = decimalValue; + FXJSE_Value_SetUTF8String(args.GetReturnValue(), wsValue.UTF8Encode()); + } + FXJSE_Value_Release(argOne); + } else if (argc == 2) { + FXJSE_HVALUE argOne = args.GetValue(0); + FXJSE_HVALUE argTwo = args.GetValue(1); + if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE dValue = 0.0; + if (FXJSE_Value_IsArray(argOne)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + dValue = HValueToDouble(hThis, jsObjectValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + dValue = HValueToDouble(hThis, newPropertyValue); + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + dValue = HValueToDouble(hThis, argOne); + } + FX_DOUBLE dPrecision = 0.0; + if (FXJSE_Value_IsArray(argTwo)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + dPrecision = HValueToDouble(hThis, jsObjectValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + dPrecision = HValueToDouble(hThis, newPropertyValue); + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + dPrecision = HValueToDouble(hThis, argTwo); + } + if (dPrecision < 0) { + uPrecision = 0; + } else if (dPrecision > 12.0) { + uPrecision = 12; + } else { + uPrecision = (uint8_t)dPrecision; + } + CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); + CFX_WideString wsValue = decimalValue; + FXJSE_Value_SetUTF8String(args.GetReturnValue(), wsValue.UTF8Encode()); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Round"); + } +} +void CXFA_FM2JSContext::Sum(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + uint32_t uCount = 0; + FX_DOUBLE dSum = 0.0; + if (argc) { + FXJSE_HVALUE argValue = 0; + for (int32_t i = 0; i < argc; i++) { + argValue = args.GetValue(i); + if (FXJSE_Value_IsNull(argValue)) { + FXJSE_Value_Release(argValue); + continue; + } else if (FXJSE_Value_IsArray(argValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); + GetObjectDefaultValue(jsObjectValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + dSum += HValueToDouble(hThis, jsObjectValue); + uCount++; + } + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, + newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + dSum += HValueToDouble(hThis, newPropertyValue); + uCount++; + } + } + } + FXJSE_Value_Release(newPropertyValue); + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(propertyValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else if (FXJSE_Value_IsObject(argValue)) { + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(argValue, newPropertyValue); + if (!FXJSE_Value_IsNull(newPropertyValue)) { + dSum += HValueToDouble(hThis, argValue); + uCount++; + } + FXJSE_Value_Release(newPropertyValue); + } else { + dSum += HValueToDouble(hThis, argValue); + uCount++; + } + FXJSE_Value_Release(argValue); + } + argValue = 0; + } + if (uCount < 1) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); + } +} +void CXFA_FM2JSContext::Date(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 0) { + struct tm* pTmStruct = 0; + time_t currentTime; + time(¤tTime); + pTmStruct = gmtime(¤tTime); + CFX_ByteString bufferYear; + CFX_ByteString bufferMon; + CFX_ByteString bufferDay; + bufferYear.Format("%d", pTmStruct->tm_year + 1900); + bufferMon.Format("%02d", pTmStruct->tm_mon + 1); + bufferDay.Format("%02d", pTmStruct->tm_mday); + CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; + int32_t dDays = DateString2Num(bufferCurrent); + FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Date"); + } +} +void CXFA_FM2JSContext::Date2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + CFX_ByteString dateString; + CFX_ByteString formatString; + CFX_ByteString localString; + FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE formatValue = 0; + FXJSE_HVALUE localValue = 0; + if (HValueIsNull(hThis, dateValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(dateValue, dateString); + } + if (argc > 1) { + formatValue = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, formatValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(formatValue, formatString); + } + } + if (argc == 3) { + localValue = GetSimpleHValue(hThis, args, 2); + if (HValueIsNull(hThis, localValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localValue, localString); + } + } + if (!bFlags) { + CFX_ByteString szIsoDateString; + FX_BOOL bRet = Local2IsoDate(hThis, dateString, formatString, localString, + szIsoDateString); + if (bRet) { + FXJSE_Value_SetInteger(args.GetReturnValue(), + DateString2Num(szIsoDateString)); + } else { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(dateValue); + if (argc > 1) { + FXJSE_Value_Release(formatValue); + if (argc == 3) { + FXJSE_Value_Release(localValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Date2Num"); + } +} +void CXFA_FM2JSContext::DateFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc < 3) { + FX_BOOL bFlags = FALSE; + int32_t iStyle = 0; + CFX_ByteString szLocal; + FXJSE_HVALUE argStyle = 0; + FXJSE_HVALUE argLocal = 0; + if (argc > 0) { + argStyle = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argStyle)) { + bFlags = TRUE; + } + iStyle = (int32_t)HValueToFloat(hThis, argStyle); + if (iStyle > 4 || iStyle < 0) { + iStyle = 0; + } + } + if (argc == 2) { + argLocal = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argLocal)) { + bFlags = TRUE; + } else { + HValueToUTF8String(argLocal, szLocal); + } + } + if (!bFlags) { + CFX_ByteString formatStr; + GetStandardDateFormat(hThis, iStyle, szLocal, formatStr); + if (formatStr.IsEmpty()) { + formatStr = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + if (argc > 0) { + FXJSE_Value_Release(argStyle); + if (argc == 2) { + FXJSE_Value_Release(argLocal); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Date2Num"); + } +} +void CXFA_FM2JSContext::IsoDate2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString szArgString; + HValueToUTF8String(argOne, szArgString); + int32_t dDays = DateString2Num(szArgString); + FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"IsoDate2Num"); + } +} +void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CXFA_Document* pDoc = pContext->GetDocument(); + FXSYS_assert(pDoc); + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + CFX_ByteString szArgString; + HValueToUTF8String(argOne, szArgString); + szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); + if (szArgString.IsEmpty()) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + FXJSE_Value_Release(argOne); + return; + } + CXFA_LocaleValue timeValue( + XFA_VT_TIME, + CFX_WideString::FromUTF8(szArgString, szArgString.GetLength()), + (CXFA_LocaleMgr*)pMgr); + if (timeValue.IsValid()) { + CFX_Unitime uniTime = timeValue.GetTime(); + int32_t hour = uniTime.GetHour(); + int32_t min = uniTime.GetMinute(); + int32_t second = uniTime.GetSecond(); + int32_t milSecond = uniTime.GetMillisecond(); + IFX_Locale* pDefLocale = pMgr->GetDefLocale(); + FXSYS_assert(pDefLocale); + FX_TIMEZONE tzLocale; + pDefLocale->GetTimeZone(tzLocale); + int32_t mins = hour * 60 + min; + mins -= (tzLocale.tzHour * 60); + while (mins > 1440) { + mins -= 1440; + } + while (mins < 0) { + mins += 1440; + } + hour = mins / 60; + min = mins % 60; + int32_t iResult = + hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; + FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); + } else { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"IsoTime2Num"); + } +} +void CXFA_FM2JSContext::LocalDateFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc < 3) { + FX_BOOL bFlags = FALSE; + int32_t iStyle = 0; + CFX_ByteString szLocal; + FXJSE_HVALUE argStyle = 0; + FXJSE_HVALUE argLocal = 0; + if (argc > 0) { + argStyle = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argStyle)) { + bFlags = TRUE; + } + iStyle = (int32_t)HValueToFloat(hThis, argStyle); + if (iStyle > 4 || iStyle < 0) { + iStyle = 0; + } + } + if (argc == 2) { + argLocal = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argLocal)) { + bFlags = TRUE; + } else { + HValueToUTF8String(argLocal, szLocal); + } + } + if (!bFlags) { + CFX_ByteString formatStr; + GetLocalDateFormat(hThis, iStyle, szLocal, formatStr, FALSE); + if (formatStr.IsEmpty()) { + formatStr = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + if (argc > 0) { + FXJSE_Value_Release(argStyle); + if (argc == 2) { + FXJSE_Value_Release(argLocal); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"LocalDateFmt"); + } +} +void CXFA_FM2JSContext::LocalTimeFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc < 3) { + FX_BOOL bFlags = FALSE; + int32_t iStyle = 0; + CFX_ByteString szLocal; + FXJSE_HVALUE argStyle = 0; + FXJSE_HVALUE argLocal = 0; + if (argc > 0) { + argStyle = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argStyle)) { + bFlags = TRUE; + } + iStyle = (int32_t)HValueToFloat(hThis, argStyle); + if (iStyle > 4 || iStyle < 0) { + iStyle = 0; + } + } + if (argc == 2) { + argLocal = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argLocal)) { + bFlags = TRUE; + } else { + HValueToUTF8String(argLocal, szLocal); + } + } + if (!bFlags) { + CFX_ByteString formatStr; + GetLocalTimeFormat(hThis, iStyle, szLocal, formatStr, FALSE); + if (formatStr.IsEmpty()) { + formatStr = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + if (argc > 0) { + FXJSE_Value_Release(argStyle); + if (argc == 2) { + FXJSE_Value_Release(argLocal); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"LocalTimeFmt"); + } +} +void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + int32_t dDate; + CFX_ByteString formatString; + CFX_ByteString localString; + FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE formatValue = 0; + FXJSE_HVALUE localValue = 0; + if (HValueIsNull(hThis, dateValue)) { + bFlags = TRUE; + } else { + dDate = (int32_t)HValueToFloat(hThis, dateValue); + bFlags = dDate < 1; + } + if (argc > 1) { + formatValue = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, formatValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(formatValue, formatString); + } + } + if (argc == 3) { + localValue = GetSimpleHValue(hThis, args, 2); + if (HValueIsNull(hThis, localValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localValue, localString); + } + } + if (!bFlags) { + int32_t iYear = 1900; + int32_t iMonth = 1; + int32_t iDay = 1; + int32_t i = 0; + while (dDate > 0) { + if (iMonth == 2) { + if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || + !((iYear + i) % 400)) { + if (dDate > 29) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 29; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } else { + if (dDate > 28) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 28; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } + } else if (iMonth < 8) { + if ((iMonth % 2 == 0)) { + if (dDate > 30) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 30; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } else { + if (dDate > 31) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 31; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } + } else { + if (iMonth % 2 != 0) { + if (dDate > 30) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 30; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } else { + if (dDate > 31) { + ++iMonth; + if (iMonth > 12) { + iMonth = 1; + ++i; + } + iDay = 1; + dDate -= 31; + } else { + iDay += static_cast<int32_t>(dDate) - 1; + dDate = 0; + } + } + } + } + CFX_ByteString szIsoDateString; + szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); + CFX_ByteString szLocalDateString; + IsoDate2Local(hThis, szIsoDateString, formatString, localString, + szLocalDateString); + if (szLocalDateString.IsEmpty()) { + szLocalDateString = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szLocalDateString); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(dateValue); + if (argc > 1) { + FXJSE_Value_Release(formatValue); + if (argc == 3) { + FXJSE_Value_Release(localValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Num2Date"); + } +} +void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + int32_t iTime; + CFX_ByteString formatString; + CFX_ByteString localString; + FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE formatValue = 0; + FXJSE_HVALUE localValue = 0; + if (FXJSE_Value_IsNull(timeValue)) { + bFlags = TRUE; + } else { + iTime = (int32_t)HValueToFloat(hThis, timeValue); + if (FXSYS_abs(iTime) < 1.0) { + bFlags = TRUE; + } + } + if (argc > 1) { + formatValue = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(formatValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(formatValue, formatString); + } + } + if (argc == 3) { + localValue = GetSimpleHValue(hThis, args, 2); + if (FXJSE_Value_IsNull(localValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localValue, localString); + } + } + if (!bFlags) { + CFX_ByteString szGMTTimeString; + Num2AllTime(hThis, iTime, formatString, localString, TRUE, + szGMTTimeString); + if (szGMTTimeString.IsEmpty()) { + szGMTTimeString = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szGMTTimeString); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(timeValue); + if (argc > 1) { + FXJSE_Value_Release(formatValue); + if (argc == 3) { + FXJSE_Value_Release(localValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Num2GMTime"); + } +} +void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + FX_FLOAT fTime; + CFX_ByteString formatString; + CFX_ByteString localString; + FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE formatValue = 0; + FXJSE_HVALUE localValue = 0; + if (FXJSE_Value_IsNull(timeValue)) { + bFlags = TRUE; + } else { + fTime = HValueToFloat(hThis, timeValue); + if (FXSYS_fabs(fTime) < 1.0) { + bFlags = TRUE; + } + } + if (argc > 1) { + formatValue = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(formatValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(formatValue, formatString); + } + } + if (argc == 3) { + localValue = GetSimpleHValue(hThis, args, 2); + if (FXJSE_Value_IsNull(localValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localValue, localString); + } + } + if (!bFlags) { + CFX_ByteString szLocalTimeString; + Num2AllTime(hThis, (int32_t)fTime, formatString, localString, FALSE, + szLocalTimeString); + if (szLocalTimeString.IsEmpty()) { + szLocalTimeString = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szLocalTimeString); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(timeValue); + if (argc > 1) { + FXJSE_Value_Release(formatValue); + if (argc == 3) { + FXJSE_Value_Release(localValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Num2Time"); + } +} +void CXFA_FM2JSContext::Time(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 0) { + time_t now; + time(&now); + struct tm* pGmt = gmtime(&now); + int32_t iGMHour = pGmt->tm_hour; + int32_t iGMMin = pGmt->tm_min; + int32_t iGMSec = pGmt->tm_sec; + FXJSE_Value_SetInteger(args.GetReturnValue(), + ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Time"); + } +} +void CXFA_FM2JSContext::Time2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + CFX_ByteString timeString; + CFX_ByteString formatString; + CFX_ByteString localString; + FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE formatValue = 0; + FXJSE_HVALUE localValue = 0; + if (HValueIsNull(hThis, timeValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(timeValue, timeString); + } + if (argc > 1) { + formatValue = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, formatValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(formatValue, formatString); + } + } + if (argc == 3) { + localValue = GetSimpleHValue(hThis, args, 2); + if (HValueIsNull(hThis, localValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localValue, localString); + } + } + if (!bFlags) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (localString.IsEmpty()) { + CXFA_Node* pThisNode = + ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(localString, localString.GetLength())); + } + CFX_WideString wsFormat; + if (formatString.IsEmpty()) { + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(formatString, formatString.GetLength()); + } + wsFormat = FX_WSTRC(L"time{") + wsFormat; + wsFormat += FX_WSTRC(L"}"); + CXFA_LocaleValue timeValue( + XFA_VT_TIME, + CFX_WideString::FromUTF8(timeString, timeString.GetLength()), + wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); + if (timeValue.IsValid()) { + CFX_Unitime uniTime = timeValue.GetTime(); + int32_t hour = uniTime.GetHour(); + int32_t min = uniTime.GetMinute(); + int32_t second = uniTime.GetSecond(); + int32_t milSecond = uniTime.GetMillisecond(); + int32_t mins = hour * 60 + min; + IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); + if (pProvider) { + FX_TIMEZONE tz; + pProvider->GetTimeZone(tz); + mins -= (tz.tzHour * 60); + while (mins > 1440) { + mins -= 1440; + } + while (mins < 0) { + mins += 1440; + } + hour = mins / 60; + min = mins % 60; + } + int32_t iResult = + hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; + FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); + } else { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(timeValue); + if (argc > 1) { + FXJSE_Value_Release(formatValue); + if (argc == 3) { + FXJSE_Value_Release(localValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Time2Num"); + } +} +void CXFA_FM2JSContext::TimeFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc < 3) { + FX_BOOL bFlags = FALSE; + int32_t iStyle = 0; + CFX_ByteString szLocal; + FXJSE_HVALUE argStyle = 0; + FXJSE_HVALUE argLocal = 0; + if (argc > 0) { + argStyle = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argStyle)) { + bFlags = TRUE; + } + iStyle = (int32_t)HValueToFloat(hThis, argStyle); + if (iStyle > 4 || iStyle < 0) { + iStyle = 0; + } + } + if (argc == 2) { + argLocal = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argLocal)) { + bFlags = TRUE; + } else { + HValueToUTF8String(argLocal, szLocal); + } + } + if (!bFlags) { + CFX_ByteString formatStr; + GetStandardTimeFormat(hThis, iStyle, szLocal, formatStr); + if (formatStr.IsEmpty()) { + formatStr = ""; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + if (argc > 0) { + FXJSE_Value_Release(argStyle); + if (argc == 2) { + FXJSE_Value_Release(argLocal); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"TimeFmt"); + } +} +FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iStyle, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) { + iYear = 0; + iMonth = 1; + iDay = 1; + FX_BOOL iRet = FALSE; + if (iLength < 4) { + return iRet; + } + FX_CHAR strYear[5]; + strYear[4] = '\0'; + for (int32_t i = 0; i < 4; ++i) { + if (*(pData + i) <= '9' && *(pData + i) >= '0') { + strYear[i] = *(pData + i); + } else { + return iRet; + } + } + iYear = FXSYS_atoi(strYear); + iStyle = 0; + if (iLength > 4) { + if (*(pData + 4) == '-') { + iStyle = 1; + } else { + iStyle = 0; + } + } else { + iRet = TRUE; + return iRet; + } + FX_CHAR strTemp[3]; + strTemp[2] = '\0'; + int32_t iPosOff = 0; + if (iStyle == 0) { + iPosOff = 4; + if (iLength == 4) { + iRet = TRUE; + return iRet; + } + } else { + iPosOff = 5; + if (iLength == 4) { + iRet = TRUE; + return iRet; + } + } + if ((*(pData + iPosOff) > '9' || *(pData + iPosOff) < '0') || + (*(pData + iPosOff + 1) > '9' || *(pData + iPosOff + 1) < '0')) { + return iRet; + } + strTemp[0] = *(pData + iPosOff); + strTemp[1] = *(pData + iPosOff + 1); + iMonth = FXSYS_atoi(strTemp); + if (iMonth > 12 || iMonth < 1) { + return iRet; + } + if (iStyle == 0) { + iPosOff += 2; + if (iLength == 6) { + iRet = 1; + return iRet; + } + } else { + iPosOff += 3; + if (iLength == 7) { + iRet = 1; + return iRet; + } + } + if ((*(pData + iPosOff) > '9' || *(pData + iPosOff) < '0') || + (*(pData + iPosOff + 1) > '9' || *(pData + iPosOff + 1) < '0')) { + return iRet; + } + strTemp[0] = *(pData + iPosOff); + strTemp[1] = *(pData + iPosOff + 1); + iDay = FXSYS_atoi(strTemp); + if (iPosOff + 2 < iLength) { + return iRet; + } + if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) { + if (iMonth == 2) { + if (iDay > 29) { + return iRet; + } + } else { + if (iMonth < 8) { + if (iDay > (iMonth % 2 == 0 ? 30 : 31)) { + return iRet; + } + } else { + if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { + return iRet; + } + } + } + } else { + if (iMonth == 2) { + if (iDay > 28) { + return iRet; + } + } else { + if (iMonth < 8) { + if (iDay > (iMonth % 2 == 0 ? 30 : 31)) { + return iRet; + } + } else { + if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { + return iRet; + } + } + } + } + iRet = TRUE; + return iRet; +} +FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iHour, + int32_t& iMinute, + int32_t& iSecond, + int32_t& iMilliSecond, + int32_t& iZoneHour, + int32_t& iZoneMinute) { + iHour = 0; + iMinute = 0; + iSecond = 0; + iMilliSecond = 0; + iZoneHour = 0; + iZoneMinute = 0; + if (!pData) { + return FALSE; + } + int32_t iRet = FALSE; + FX_CHAR strTemp[3]; + strTemp[2] = '\0'; + int32_t iIndex = 0; + int32_t iZone = 0; + int32_t i = iIndex; + while (i < iLength) { + if ((*(pData + i) > '9' || *(pData + i) < '0') && *(pData + i) != ':') { + iZone = i; + break; + } + ++i; + } + if (i == iLength) { + iZone = iLength; + } + int32_t iPos = 0; + while (iIndex < iZone) { + if (iIndex >= iZone) { + break; + } + if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { + return iRet; + } + strTemp[0] = *(pData + iIndex); + if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { + return iRet; + } + strTemp[1] = *(pData + iIndex + 1); + if (FXSYS_atoi(strTemp) > 60) { + return iRet; + } + if (*(pData + 2) == ':') { + if (iPos == 0) { + iHour = FXSYS_atoi(strTemp); + ++iPos; + } else if (iPos == 1) { + iMinute = FXSYS_atoi(strTemp); + ++iPos; + } else { + iSecond = FXSYS_atoi(strTemp); + } + iIndex += 3; + } else { + if (iPos == 0) { + iHour = FXSYS_atoi(strTemp); + ++iPos; + } else if (iPos == 1) { + iMinute = FXSYS_atoi(strTemp); + ++iPos; + } else if (iPos == 2) { + iSecond = FXSYS_atoi(strTemp); + ++iPos; + } + iIndex += 2; + } + } + if (*(pData + iIndex) == '.') { + ++iIndex; + FX_CHAR strTemp[4]; + strTemp[3] = '\0'; + if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { + return iRet; + } + strTemp[0] = *(pData + iIndex); + if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { + return iRet; + } + strTemp[1] = *(pData + iIndex + 1); + if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { + return iRet; + } + strTemp[2] = *(pData + iIndex + 2); + iMilliSecond = FXSYS_atoi(strTemp); + if (iMilliSecond > 100) { + iMilliSecond = 0; + return iRet; + } + iIndex += 3; + } + int32_t iSign = 1; + if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') { + iRet = 1; + return iRet; + } else if (*(pData + iIndex) == '+') { + ++iIndex; + } else if (*(pData + iIndex) == '-') { + iSign = -1; + ++iIndex; + } + iPos = 0; + while (iIndex < iLength) { + if (iIndex >= iLength) { + return iRet; + } + if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { + return iRet; + } + strTemp[0] = *(pData + iIndex); + if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { + return iRet; + } + strTemp[1] = *(pData + iIndex + 1); + if (FXSYS_atoi(strTemp) > 60) { + return iRet; + } + if (*(pData + 2) == ':') { + if (iPos == 0) { + iZoneHour = FXSYS_atoi(strTemp); + } else if (iPos == 1) { + iZoneMinute = FXSYS_atoi(strTemp); + } + iIndex += 3; + } else { + if (!iPos) { + iZoneHour = FXSYS_atoi(strTemp); + ++iPos; + } else if (iPos == 1) { + iZoneMinute = FXSYS_atoi(strTemp); + ++iPos; + } + iIndex += 2; + } + } + if (iIndex < iLength) { + return iRet; + } + iZoneHour *= iSign; + iRet = TRUE; + return iRet; +} +FX_BOOL CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay, + int32_t& iHour, + int32_t& iMinute, + int32_t& iSecond, + int32_t& iMillionSecond, + int32_t& iZoneHour, + int32_t& iZoneMinute) { + iYear = 0; + iMonth = 0; + iDay = 0; + iHour = 0; + iMinute = 0; + iSecond = 0; + if (!pData) { + return FALSE; + } + int32_t iRet = FALSE; + int32_t iIndex = 0; + while (*(pData + iIndex) != 'T' && *(pData + iIndex) != 't') { + if (iIndex >= iLength) { + return iRet; + } + ++iIndex; + } + if (iIndex != 8 && iIndex != 10) { + return iRet; + } + int32_t iStyle = -1; + iRet = IsIsoDateFormat(pData, iIndex, iStyle, iYear, iMonth, iDay); + if (!iRet) { + return iRet; + } + if (*(pData + iIndex) != 'T' && *(pData + iIndex) != 't') { + return iRet; + } + ++iIndex; + if (((iLength - iIndex > 13) && (iLength - iIndex < 6)) && + (iLength - iIndex != 15)) { + return iRet; + } + iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, + iSecond, iMillionSecond, iZoneHour, iZoneMinute); + if (!iRet) { + return iRet; + } + iRet = TRUE; + return iRet; +} +FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szDate, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strIsoDate) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return FALSE; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocale.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); + } + if (!pLocale) { + return FALSE; + } + CFX_WideString wsFormat; + if (szFormat.IsEmpty()) { + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); + } + CXFA_LocaleValue widgetValue( + XFA_VT_DATE, + CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), wsFormat, + pLocale, (CXFA_LocaleMgr*)pMgr); + CFX_Unitime dt = widgetValue.GetDate(); + strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); + return TRUE; +} +FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strIsoTime) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return FALSE; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocale.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); + } + if (!pLocale) { + return FALSE; + } + CFX_WideString wsFormat; + if (szFormat.IsEmpty()) { + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); + } + wsFormat = FX_WSTRC(L"time{") + wsFormat; + wsFormat += FX_WSTRC(L"}"); + CXFA_LocaleValue widgetValue( + XFA_VT_TIME, + CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), wsFormat, + pLocale, (CXFA_LocaleMgr*)pMgr); + CFX_Unitime utime = widgetValue.GetTime(); + strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), + utime.GetSecond(), utime.GetMillisecond()); + return TRUE; +} +FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szDate, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strLocalDate) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return FALSE; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocale.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); + } + if (!pLocale) { + return FALSE; + } + CFX_WideString wsFormat; + if (szFormat.IsEmpty()) { + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); + } + CXFA_LocaleValue widgetValue( + XFA_VT_DATE, + CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), + (CXFA_LocaleMgr*)pMgr); + CFX_WideString wsRet; + widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, + XFA_VALUEPICTURE_Display); + strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); + return TRUE; +} +FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strLocalTime) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return FALSE; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocale.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); + } + if (!pLocale) { + return FALSE; + } + CFX_WideString wsFormat; + if (szFormat.IsEmpty()) { + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); + } + wsFormat = FX_WSTRC(L"time{") + wsFormat; + wsFormat += FX_WSTRC(L"}"); + CXFA_LocaleValue widgetValue( + XFA_VT_TIME, + CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), + (CXFA_LocaleMgr*)pMgr); + CFX_WideString wsRet; + widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, + XFA_VALUEPICTURE_Display); + strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); + return TRUE; +} +FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strGMTTime) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return FALSE; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocale.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); + } + if (!pLocale) { + return FALSE; + } + CFX_WideString wsFormat; + if (szFormat.IsEmpty()) { + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); + } else { + wsFormat = + CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); + } + wsFormat = FX_WSTRC(L"time{") + wsFormat; + wsFormat += FX_WSTRC(L"}"); + CXFA_LocaleValue widgetValue( + XFA_VT_TIME, + CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), + (CXFA_LocaleMgr*)pMgr); + CFX_WideString wsRet; + widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, + XFA_VALUEPICTURE_Display); + strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); + return TRUE; +} +int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { + FX_BOOL bFlags = FALSE; + int32_t iLength = szDateString.GetLength(); + FX_BOOL iRet = FALSE; + int32_t iStyle = -1; + int32_t iYear = 0; + int32_t iMonth = 0; + int32_t iDay = 0; + int32_t iHour = 0; + int32_t iMinute = 0; + int32_t iSecond = 0; + int32_t iMillionSecond = 0; + int32_t iZoneHour = 0; + int32_t iZoneMinute = 0; + if (iLength <= 10) { + iRet = IsIsoDateFormat(szDateString.GetCStr(), iLength, iStyle, iYear, + iMonth, iDay); + } else { + iRet = IsIsoDateTimeFormat(szDateString.GetCStr(), iLength, iYear, iMonth, + iDay, iHour, iMinute, iSecond, iMillionSecond, + iZoneHour, iZoneMinute); + } + if (!iRet) { + bFlags = TRUE; + } + FX_FLOAT dDays = 0; + int32_t i = 1; + if (iYear < 1900) { + bFlags = TRUE; + } + if (!bFlags) { + while (iYear - i >= 1900) { + if ((!((iYear - i) % 4) && ((iYear - i) % 100)) || !((iYear - i) % 400)) { + dDays += 366; + } else { + dDays += 365; + } + ++i; + } + i = 1; + while (i < iMonth) { + if (i == 2) { + if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) { + dDays += 29; + } else { + dDays += 28; + } + } else if (i <= 7) { + if (i % 2 == 0) { + dDays += 30; + } else { + dDays += 31; + } + } else { + if (i % 2 == 0) { + dDays += 31; + } else { + dDays += 30; + } + } + ++i; + } + i = 0; + while (iDay - i > 0) { + dDays += 1; + ++i; + } + } else { + dDays = 0; + } + return (int32_t)dDays; +} +#define XFA_N 19 +static uint8_t g_sAltTable_Date[] = { + XFA_N, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, 2, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, 1, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, +}; +static uint8_t g_sAltTable_Time[] = { + 14, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, + XFA_N, 6, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 7, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, 1, 17, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, + XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, +}; +static void XFA_FM_AlternateDateTimeSymbols(CFX_WideString& wsPattern, + const CFX_WideString& wsAltSymbols, + uint8_t* pAltTable) { + int32_t nLength = wsPattern.GetLength(); + FX_BOOL bInConstRange = FALSE; + FX_BOOL bEscape = FALSE; + int32_t i = 0, n = 0; + while (i < nLength) { + FX_WCHAR wc = wsPattern[i]; + if (wc == L'\'') { + bInConstRange = !bInConstRange; + if (bEscape) { + i++; + } else { + wsPattern.Delete(i); + nLength--; + } + bEscape = !bEscape; + continue; + } + if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { + int32_t nAlt = (int32_t)pAltTable[n]; + if (nAlt != XFA_N) { + wsPattern.SetAt(i, wsAltSymbols[nAlt]); + } + } + i++; + bEscape = FALSE; + } +} +#undef XFA_N +void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat, + FX_BOOL bStandard) { + FX_LOCALEDATETIMESUBCATEGORY strStyle; + switch (iStyle) { + case 0: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + case 1: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; + break; + case 2: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + case 3: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; + break; + case 4: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; + break; + default: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + } + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocalStr.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); + } + if (!pLocale) { + return; + } + CFX_WideString strRet; + pLocale->GetDatePattern(strStyle, strRet); + if (!bStandard) { + CFX_WideString wsSymbols; + pLocale->GetDateTimeSymbols(wsSymbols); + XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); + } + strFormat = FX_UTF8Encode(strRet, strRet.GetLength()); +} +void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat, + FX_BOOL bStandard) { + FX_LOCALEDATETIMESUBCATEGORY strStyle; + switch (iStyle) { + case 0: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + case 1: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; + break; + case 2: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + case 3: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; + break; + case 4: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; + break; + default: + strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; + break; + } + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return; + } + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + IFX_Locale* pLocale = NULL; + if (szLocalStr.IsEmpty()) { + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + pLocale = widgetData.GetLocal(); + } else { + pLocale = pMgr->GetLocaleByName( + CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); + } + if (!pLocale) { + return; + } + CFX_WideString strRet; + pLocale->GetTimePattern(strStyle, strRet); + if (!bStandard) { + CFX_WideString wsSymbols; + pLocale->GetDateTimeSymbols(wsSymbols); + XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); + } + strFormat = FX_UTF8Encode(strRet, strRet.GetLength()); +} +void CXFA_FM2JSContext::GetStandardDateFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat) { + GetLocalDateFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); +} +void CXFA_FM2JSContext::GetStandardTimeFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat) { + GetLocalTimeFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); +} +void CXFA_FM2JSContext::Num2AllTime(FXJSE_HOBJECT hThis, + int32_t iTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + FX_BOOL bGM, + CFX_ByteString& strTime) { + int32_t iHour = 0; + int32_t iMin = 0; + int32_t iSec = 0; + int32_t iZoneHour = 0; + int32_t iZoneMin = 0; + int32_t iZoneSec = 0; + iHour = static_cast<int>(iTime) / 3600000; + iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; + iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; + if (!bGM) { + GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); + iHour += iZoneHour; + iMin += iZoneMin; + iSec += iZoneSec; + } + int32_t iRet = 0; + CFX_ByteString strIsoTime; + strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); + if (bGM) { + iRet = GetGMTTime(hThis, strIsoTime, szFormat, szLocale, strTime); + } else { + iRet = IsoTime2Local(hThis, strIsoTime, szFormat, szLocale, strTime); + } + if (!iRet) { + strTime = ""; + } +} + +void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, + int32_t& iMin, + int32_t& iSec) { + time_t now; + time(&now); + struct tm* pGmt = gmtime(&now); + int32_t iGMHour = pGmt->tm_hour; + int32_t iGMMin = pGmt->tm_min; + int32_t iGMSec = pGmt->tm_sec; + struct tm* pLocal = localtime(&now); + int32_t iLocalHour = pLocal->tm_hour; + int32_t iLocalMin = pLocal->tm_min; + int32_t iLocalSec = pLocal->tm_sec; + iHour = iLocalHour - iGMHour; + iMin = iLocalMin - iGMMin; + iSec = iLocalSec - iGMSec; +} +void CXFA_FM2JSContext::Apr(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_DOUBLE nPrincipal = 0; + FX_DOUBLE nPayment = 0; + FX_DOUBLE nPeriods = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nPrincipal = HValueToDouble(hThis, argOne); + nPayment = HValueToDouble(hThis, argTwo); + nPeriods = HValueToDouble(hThis, argThree); + bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_DOUBLE r = + 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); + FX_DOUBLE nTemp = 1; + for (int32_t i = 0; i < nPeriods; ++i) { + nTemp *= (1 + r); + } + FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; + while ((nRet > FINANCIAL_PRECISION || nRet < -FINANCIAL_PRECISION) && + (!bFlags)) { + FX_DOUBLE nDerivative = 0; + nDerivative = + ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - + (r * nTemp * nPeriods * (nTemp / (1 + r)))) / + ((nTemp - 1) * (nTemp - 1)); + if (nDerivative == 0) { + bFlags = TRUE; + continue; + } + r = r - nRet / nDerivative; + nTemp = 1; + for (int32_t i = 0; i < nPeriods; ++i) { + nTemp *= (1 + r); + } + nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; + } + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + r = r * 12; + FXJSE_Value_SetDouble(args.GetReturnValue(), r); + } + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Apr"); + } +} +void CXFA_FM2JSContext::CTerm(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nRate = 0; + FX_FLOAT nFutureValue = 0; + FX_FLOAT nInitAmount = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nRate = HValueToFloat(hThis, argOne); + nFutureValue = HValueToFloat(hThis, argTwo); + nInitAmount = HValueToFloat(hThis, argThree); + bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FXJSE_Value_SetFloat(args.GetReturnValue(), + FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / + FXSYS_log((FX_FLOAT)(1 + nRate))); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"CTerm"); + } +} +void CXFA_FM2JSContext::FV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_DOUBLE nAmount = 0; + FX_DOUBLE nRate = 0; + FX_DOUBLE nPeriod = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nAmount = HValueToDouble(hThis, argOne); + nRate = HValueToDouble(hThis, argTwo); + nPeriod = HValueToDouble(hThis, argThree); + bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_DOUBLE dResult = 0; + if (!nRate) { + dResult = nAmount * nPeriod; + } else { + FX_DOUBLE nTemp = 1; + for (int i = 0; i < nPeriod; ++i) { + nTemp *= 1 + nRate; + } + dResult = nAmount * (nTemp - 1) / nRate; + } + FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"FV"); + } +} +void CXFA_FM2JSContext::IPmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 5) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nPrincpalAmount = 0; + FX_FLOAT nRate = 0; + FX_FLOAT nPayment = 0; + FX_FLOAT nFirstMonth = 0; + FX_FLOAT nNumberOfMonths = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); + FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || + HValueIsNull(hThis, argFive)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nPrincpalAmount = HValueToFloat(hThis, argOne); + nRate = HValueToFloat(hThis, argTwo); + nPayment = HValueToFloat(hThis, argThree); + nFirstMonth = HValueToFloat(hThis, argFour); + nNumberOfMonths = HValueToFloat(hThis, argFive); + bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || + (nFirstMonth < 0) || (nNumberOfMonths < 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_FLOAT fResult = 0; + FX_FLOAT nRateOfMonth = nRate / 12; + int32_t iNums = + (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - + FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - + nRateOfMonth))) / + FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); + int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); + if (iEnd > iNums) { + iEnd = iNums; + } + FX_FLOAT nSum = 0; + if (nPayment < nPrincpalAmount * nRateOfMonth) { + bFlags = TRUE; + fResult = 0; + } + if (!bFlags) { + int32_t i = 0; + for (i = 0; i < nFirstMonth - 1; ++i) { + nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; + } + for (; i < iEnd; ++i) { + nSum += nPrincpalAmount * nRateOfMonth; + nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; + } + fResult = nSum; + } + FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + FXJSE_Value_Release(argFour); + FXJSE_Value_Release(argFive); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"IPmt"); + } +} +void CXFA_FM2JSContext::NPV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc > 2) { + FX_BOOL bFlags = FALSE; + FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); + for (int32_t i = 0; i < argc; i++) { + argValues[i] = GetSimpleHValue(hThis, args, i); + if (HValueIsNull(hThis, argValues[i])) { + bFlags = TRUE; + } + } + if (!bFlags) { + FX_DOUBLE nRate = 0; + nRate = HValueToDouble(hThis, argValues[0]); + if (nRate <= 0) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); + for (int32_t i = 1; i < argc; i++) { + pData[i - 1] = HValueToDouble(hThis, argValues[i]); + } + FX_DOUBLE nSum = 0; + int32_t iIndex = 0; + for (int32_t i = 0; i < argc - 1; i++) { + FX_DOUBLE nTemp = 1; + for (int32_t j = 0; j <= i; j++) { + nTemp *= 1 + nRate; + } + FX_DOUBLE nNum = *(pData + iIndex++); + nSum += nNum / nTemp; + } + FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); + FX_Free(pData); + pData = 0; + } + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + for (int32_t i = 0; i < argc; i++) { + FXJSE_Value_Release(argValues[i]); + } + FX_Free(argValues); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"NPV"); + } +} +void CXFA_FM2JSContext::Pmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nPrincipal = 0; + FX_FLOAT nRate = 0; + FX_FLOAT nPeriods = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nPrincipal = HValueToFloat(hThis, argOne); + nRate = HValueToFloat(hThis, argTwo); + nPeriods = HValueToFloat(hThis, argThree); + bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_FLOAT nSum = 0; + FX_FLOAT nTmp = 1 + nRate; + nSum = nTmp; + for (int32_t i = 0; i < nPeriods - 1; ++i) { + nSum *= nTmp; + } + FXJSE_Value_SetFloat(args.GetReturnValue(), + (nPrincipal * nRate * nSum) / (nSum - 1)); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Pmt"); + } +} +void CXFA_FM2JSContext::PPmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 5) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nPrincpalAmount = 0; + FX_FLOAT nRate = 0; + FX_FLOAT nPayment = 0; + FX_FLOAT nFirstMonth = 0; + FX_FLOAT nNumberOfMonths = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); + FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || + HValueIsNull(hThis, argFive)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nPrincpalAmount = HValueToFloat(hThis, argOne); + nRate = HValueToFloat(hThis, argTwo); + nPayment = HValueToFloat(hThis, argThree); + nFirstMonth = HValueToFloat(hThis, argFour); + nNumberOfMonths = HValueToFloat(hThis, argFive); + bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || + (nFirstMonth < 0) || (nNumberOfMonths < 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); + FX_FLOAT nSum = 0; + FX_FLOAT nRateOfMonth = nRate / 12; + int32_t iNums = + (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - + FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - + nRateOfMonth))) / + FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); + if (iEnd > iNums) { + iEnd = iNums; + } + if (nPayment < nPrincpalAmount * nRateOfMonth) { + bFlags = TRUE; + } + if (!bFlags) { + int32_t i = 0; + for (i = 0; i < nFirstMonth - 1; ++i) { + nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; + } + FX_FLOAT nTemp = 0; + for (; i < iEnd; ++i) { + nTemp = nPayment - nPrincpalAmount * nRateOfMonth; + nSum += nTemp; + nPrincpalAmount -= nTemp; + } + FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + FXJSE_Value_Release(argFour); + FXJSE_Value_Release(argFive); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"PPmt"); + } +} +void CXFA_FM2JSContext::PV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_DOUBLE nAmount = 0; + FX_DOUBLE nRate = 0; + FX_DOUBLE nPeriod = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nAmount = HValueToDouble(hThis, argOne); + nRate = HValueToDouble(hThis, argTwo); + nPeriod = HValueToDouble(hThis, argThree); + bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FX_DOUBLE nTemp = 1; + for (int32_t i = 0; i < nPeriod; ++i) { + nTemp *= 1 + nRate; + } + nTemp = 1 / nTemp; + FXJSE_Value_SetDouble(args.GetReturnValue(), + nAmount * ((1 - nTemp) / nRate)); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"PV"); + } +} +void CXFA_FM2JSContext::Rate(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nFuture = 0; + FX_FLOAT nPresent = 0; + FX_FLOAT nTotalNumber = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || + HValueIsNull(hThis, argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nFuture = HValueToFloat(hThis, argOne); + nPresent = HValueToFloat(hThis, argTwo); + nTotalNumber = HValueToFloat(hThis, argThree); + bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FXJSE_Value_SetFloat(args.GetReturnValue(), + (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), + (FX_FLOAT)(1 / nTotalNumber)) - + 1)); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Rate"); + } +} +void CXFA_FM2JSContext::Term(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 3) { + FX_BOOL bFlags = FALSE; + FX_FLOAT nMount = 0; + FX_FLOAT nRate = 0; + FX_FLOAT nFuture = 0; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); + bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || + FXJSE_Value_IsNull(argThree)); + if (bFlags) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + nMount = HValueToFloat(hThis, argOne); + nRate = HValueToFloat(hThis, argTwo); + nFuture = HValueToFloat(hThis, argThree); + bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); + if (bFlags) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + FXJSE_Value_SetFloat( + args.GetReturnValue(), + (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / + FXSYS_log((FX_FLOAT)(1 + nRate)))); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + FXJSE_Value_Release(argThree); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Term"); + } +} +void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + if (argc > 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + FX_BOOL argOneIsNull = FALSE; + int32_t iIndex = 0; + argOneIsNull = HValueIsNull(hThis, argOne); + if (!argOneIsNull) { + iIndex = (int32_t)HValueToFloat(hThis, argOne); + } + FXJSE_Value_Release(argOne); + if (argOneIsNull) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else if (iIndex < 1) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } else { + FX_BOOL bFound = FALSE; + FX_BOOL bStopCounterFlags = FALSE; + int32_t iArgIndex = 1; + int32_t iValueIndex = 0; + while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { + FXJSE_HVALUE argIndexValue = args.GetValue(iArgIndex); + if (FXJSE_Value_IsArray(argIndexValue)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 3) { + bStopCounterFlags = TRUE; + } + iValueIndex += (iLength - 2); + if (iValueIndex >= iIndex) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx( + argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), + jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, newProperty); + } else { + CFX_ByteString propStr; + FXJSE_Value_ToUTF8String(propertyValue, propStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propStr, newProperty); + } + CFX_ByteString bsChoosed; + HValueToUTF8String(newProperty, bsChoosed); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed); + FXJSE_Value_Release(newProperty); + FXJSE_Value_Release(jsobjectValue); + FXJSE_Value_Release(propertyValue); + bFound = TRUE; + } + } else { + iValueIndex++; + if (iValueIndex == iIndex) { + CFX_ByteString bsChoosed; + HValueToUTF8String(argIndexValue, bsChoosed); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed); + bFound = TRUE; + } + } + FXJSE_Value_Release(argIndexValue); + iArgIndex++; + } + if (!bFound) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Choose"); + } +} +void CXFA_FM2JSContext::Exists(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Exists"); + } +} +void CXFA_FM2JSContext::HasValue(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsUTF8String(argOne)) { + CFX_ByteString valueStr; + FXJSE_Value_ToUTF8String(argOne, valueStr); + valueStr.TrimLeft(); + FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); + } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { + FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); + } else { + FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"HasValue"); + } +} +void CXFA_FM2JSContext::Oneof(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc > 1) { + FX_BOOL bFlags = FALSE; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE* parametersValue = 0; + int32_t iCount = 0; + unfoldArgs(hThis, args, parametersValue, iCount, 1); + for (int32_t i = 0; i < iCount; i++) { + if (simpleValueCompare(hThis, argOne, parametersValue[i])) { + bFlags = TRUE; + break; + } + } + FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); + FXJSE_Value_Release(argOne); + for (int32_t i = 0; i < iCount; i++) { + FXJSE_Value_Release(parametersValue[i]); + } + FX_Free(parametersValue); + parametersValue = 0; + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Oneof"); + } +} +void CXFA_FM2JSContext::Within(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc == 3) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetUndefined(args.GetReturnValue()); + } else { + FXJSE_HVALUE argLow = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argHeight = GetSimpleHValue(hThis, args, 2); + if (FXJSE_Value_IsNumber(argOne)) { + FX_FLOAT oneNumber = HValueToFloat(hThis, argOne); + FX_FLOAT lowNumber = HValueToFloat(hThis, argLow); + FX_FLOAT heightNumber = HValueToFloat(hThis, argHeight); + FXJSE_Value_SetInteger( + args.GetReturnValue(), + ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); + } else { + CFX_ByteString oneString; + CFX_ByteString lowString; + CFX_ByteString heightString; + HValueToUTF8String(argOne, oneString); + HValueToUTF8String(argLow, lowString); + HValueToUTF8String(argHeight, heightString); + FXJSE_Value_SetInteger(args.GetReturnValue(), + ((oneString.Compare(lowString) >= 0) && + (oneString.Compare(heightString) <= 0))); + } + FXJSE_Value_Release(argLow); + FXJSE_Value_Release(argHeight); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Within"); + } +} +void CXFA_FM2JSContext::If(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 3) { + FXJSE_HVALUE argCondition = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argFirstValue = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argSecondValue = GetSimpleHValue(hThis, args, 2); + FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); + FXJSE_Value_Set(args.GetReturnValue(), + bCondition ? argFirstValue : argSecondValue); + FXJSE_Value_Release(argSecondValue); + FXJSE_Value_Release(argFirstValue); + FXJSE_Value_Release(argCondition); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"If"); + } +} +void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + if (args.GetLength() == 1) { + FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); + CFX_ByteString utf8ScriptString; + HValueToUTF8String(scriptValue, utf8ScriptString); + if (utf8ScriptString.IsEmpty()) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_WideTextBuf wsJavaScriptBuf; + CFX_WideString javaScript; + CFX_WideString wsError; + XFA_FM2JS_Translate(CFX_WideString::FromUTF8( + utf8ScriptString, utf8ScriptString.GetLength()), + 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); + FXJSE_Value_Set(args.GetReturnValue(), returnValue); + FXJSE_Value_Release(returnValue); + FXJSE_Context_Release(hContext); + } + FXJSE_Value_Release(scriptValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Eval"); + } +} +void CXFA_FM2JSContext::Ref(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_HVALUE rgValues[3]; + for (int32_t i = 0; i < 3; i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 4); + FXJSE_Value_SetNull(rgValues[1]); + FXJSE_Value_SetNull(rgValues[2]); + FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); + for (int32_t i = 0; i < 3; i++) { + FXJSE_Value_Release(rgValues[i]); + } + } else if (FXJSE_Value_IsArray(argOne)) { +#ifndef NDEBUG + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); + FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); + FXJSE_Value_Release(lengthValue); +#endif + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); + if (FXJSE_Value_IsNull(jsObjectValue)) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else if (FXJSE_Value_IsNull(propertyValue) && + (!FXJSE_Value_IsNull(jsObjectValue))) { + FXJSE_HVALUE rgValues[3]; + for (int32_t i = 0; i < 3; i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 3); + FXJSE_Value_SetNull(rgValues[1]); + FXJSE_Value_Set(rgValues[2], jsObjectValue); + FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); + for (int32_t i = 0; i < 3; i++) { + FXJSE_Value_Release(rgValues[i]); + } + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(propertyValue); + } else if (FXJSE_Value_IsObject(argOne)) { + FXJSE_HVALUE rgValues[3]; + for (int32_t i = 0; i < 3; i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 3); + FXJSE_Value_SetNull(rgValues[1]); + FXJSE_Value_Set(rgValues[2], argOne); + FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); + for (int32_t i = 0; i < 3; i++) { + FXJSE_Value_Release(rgValues[i]); + } + } else if (FXJSE_Value_IsBoolean(argOne) || + FXJSE_Value_IsUTF8String(argOne) || + FXJSE_Value_IsNumber(argOne)) { + FXJSE_Value_Set(args.GetReturnValue(), argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Ref"); + } +} +void CXFA_FM2JSContext::UnitType(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 1) { + FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(unitspanValue)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + FXJSE_Value_Release(unitspanValue); + return; + } + CFX_ByteString unitspanString; + HValueToUTF8String(unitspanValue, unitspanString); + if (unitspanString.IsEmpty()) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); + } else { + enum XFA_FM2JS_VALUETYPE_ParserStatus { + VALUETYPE_START, + VALUETYPE_HAVEINVALIDCHAR, + VALUETYPE_HAVEDIGIT, + VALUETYPE_HAVEDIGITWHITE, + VALUETYPE_ISCM, + VALUETYPE_ISMM, + VALUETYPE_ISPT, + VALUETYPE_ISMP, + VALUETYPE_ISIN, + }; + unitspanString.MakeLower(); + CFX_WideString wsTypeString = + CFX_WideString::FromUTF8(unitspanString, unitspanString.GetLength()); + const FX_WCHAR* pData = wsTypeString; + int32_t u = 0; + int32_t uLen = wsTypeString.GetLength(); + while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || + *(pData + u) == 0x0B || *(pData + u) == 0x0C || + *(pData + u) == 0x0A || *(pData + u) == 0x0D) { + u++; + } + XFA_FM2JS_VALUETYPE_ParserStatus eParserStatus = VALUETYPE_START; + FX_WCHAR typeChar; + while (u < uLen) { + typeChar = *(pData + u); + if (typeChar == 0x20 || typeChar == 0x09 || typeChar == 0x0B || + typeChar == 0x0C || typeChar == 0x0A || typeChar == 0x0D) { + if (eParserStatus == VALUETYPE_HAVEDIGIT || + eParserStatus == VALUETYPE_HAVEDIGITWHITE) { + eParserStatus = VALUETYPE_HAVEDIGITWHITE; + } else { + eParserStatus = VALUETYPE_ISIN; + break; + } + } else if ((typeChar >= '0' && typeChar <= '9') || typeChar == '-' || + typeChar == '.') { + if (eParserStatus == VALUETYPE_HAVEDIGITWHITE) { + eParserStatus = VALUETYPE_ISIN; + break; + } else { + eParserStatus = VALUETYPE_HAVEDIGIT; + } + } else if ((typeChar == 'c' || typeChar == 'p') && (u + 1 < uLen)) { + FX_WCHAR nextChar = *(pData + u + 1); + if ((eParserStatus == VALUETYPE_START || + eParserStatus == VALUETYPE_HAVEDIGIT || + eParserStatus == VALUETYPE_HAVEDIGITWHITE) && + (nextChar > '9' || nextChar < '0') && nextChar != '.' && + nextChar != '-') { + eParserStatus = (typeChar == 'c') ? VALUETYPE_ISCM : VALUETYPE_ISPT; + break; + } else { + eParserStatus = VALUETYPE_HAVEINVALIDCHAR; + } + } else if (typeChar == 'm' && (u + 1 < uLen)) { + FX_WCHAR nextChar = *(pData + u + 1); + if ((eParserStatus == VALUETYPE_START || + eParserStatus == VALUETYPE_HAVEDIGIT || + eParserStatus == VALUETYPE_HAVEDIGITWHITE) && + (nextChar > '9' || nextChar < '0') && nextChar != '.' && + nextChar != '-') { + eParserStatus = VALUETYPE_ISMM; + if (nextChar == 'p' || + ((u + 5 < uLen) && *(pData + u + 1) == 'i' && + *(pData + u + 2) == 'l' && *(pData + u + 3) == 'l' && + *(pData + u + 4) == 'i' && *(pData + u + 5) == 'p')) { + eParserStatus = VALUETYPE_ISMP; + } + break; + } + } else { + eParserStatus = VALUETYPE_HAVEINVALIDCHAR; + } + u++; + } + switch (eParserStatus) { + case VALUETYPE_ISCM: + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "cm"); + break; + case VALUETYPE_ISMM: + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mm"); + break; + case VALUETYPE_ISPT: + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "pt"); + break; + case VALUETYPE_ISMP: + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); + break; + default: + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); + break; + } + } + FXJSE_Value_Release(unitspanValue); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"UnitType"); + } +} +void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc == 1) || (argc == 2)) { + FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE unitValue = 0; + CFX_ByteString unitspanString; + FX_DOUBLE dFirstNumber = 0; + CFX_ByteString strFirstUnit; + CFX_ByteString strUnit; + if (FXJSE_Value_IsNull(unitspanValue)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + HValueToUTF8String(unitspanValue, unitspanString); + const FX_CHAR* pData = unitspanString; + if (pData) { + int32_t u = 0; + while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || + *(pData + u) == 0x0B || *(pData + u) == 0x0C || + *(pData + u) == 0x0A || *(pData + u) == 0x0D) { + ++u; + } + while (u < unitspanString.GetLength()) { + if ((*(pData + u) > '9' || *(pData + u) < '0') && + *(pData + u) != '.' && *(pData + u) != '-') { + break; + } + ++u; + } + FX_CHAR* pTemp = NULL; + dFirstNumber = strtod(pData, &pTemp); + while (*(pData + u) == ' ' || *(pData + u) == 0x09 || + *(pData + u) == 0x0B || *(pData + u) == 0x0C || + *(pData + u) == 0x0A || *(pData + u) == 0x0D) { + ++u; + } + int32_t uLen = unitspanString.GetLength(); + while (u < uLen) { + if (*(pData + u) == ' ') { + break; + } + strFirstUnit += (*(pData + u)); + ++u; + } + strFirstUnit.MakeLower(); + if (argc == 2) { + unitValue = GetSimpleHValue(hThis, args, 1); + CFX_ByteString unitTempString; + HValueToUTF8String(unitValue, unitTempString); + const FX_CHAR* pData = unitTempString; + int32_t u = 0; + while (*(pData + u) == ' ' || *(pData + u) == 0x09 || + *(pData + u) == 0x0B || *(pData + u) == 0x0C || + *(pData + u) == 0x0A || *(pData + u) == 0x0D) { + ++u; + } + while (u < unitTempString.GetLength()) { + if ((*(pData + u) > '9' || *(pData + u) < '0') && + *(pData + u) != '.') { + break; + } + ++u; + } + while (*(pData + u) == ' ' || *(pData + u) == 0x09 || + *(pData + u) == 0x0B || *(pData + u) == 0x0C || + *(pData + u) == 0x0A || *(pData + u) == 0x0D) { + ++u; + } + int32_t uLen = unitTempString.GetLength(); + while (u < uLen) { + if (*(pData + u) == ' ') { + break; + } + strUnit += (*(pData + u)); + ++u; + } + strUnit.MakeLower(); + } else { + strUnit = strFirstUnit; + } + FX_DOUBLE dResult = 0; + if (strFirstUnit.Equal("in") || strFirstUnit.Equal("inches")) { + if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + dResult = dFirstNumber * 25.4; + } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + dResult = dFirstNumber * 2.54; + } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + dResult = dFirstNumber / 72; + } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + dResult = dFirstNumber / 72000; + } else { + dResult = dFirstNumber; + } + } else if (strFirstUnit.Equal("mm") || + strFirstUnit.Equal("millimeters")) { + if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + dResult = dFirstNumber; + } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + dResult = dFirstNumber / 10; + } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + dResult = dFirstNumber / 25.4 / 72; + } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + dResult = dFirstNumber / 25.4 / 72000; + } else { + dResult = dFirstNumber / 25.4; + } + } else if (strFirstUnit.Equal("cm") || + strFirstUnit.Equal("centimeters")) { + if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + dResult = dFirstNumber * 10; + } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + dResult = dFirstNumber; + } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + dResult = dFirstNumber / 2.54 / 72; + } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + dResult = dFirstNumber / 2.54 / 72000; + } else { + dResult = dFirstNumber / 2.54; + } + } else if (strFirstUnit.Equal("pt") || strFirstUnit.Equal("points")) { + if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + dResult = dFirstNumber / 72 * 25.4; + } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + dResult = dFirstNumber / 72 * 2.54; + } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + dResult = dFirstNumber; + } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + dResult = dFirstNumber * 1000; + } else { + dResult = dFirstNumber / 72; + } + } else if (strFirstUnit.Equal("mp") || + strFirstUnit.Equal("millipoints")) { + if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + dResult = dFirstNumber / 72000 * 25.4; + } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + dResult = dFirstNumber / 72000 * 2.54; + } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + dResult = dFirstNumber / 1000; + } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + dResult = dFirstNumber; + } else { + dResult = dFirstNumber / 72000; + } + } + FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); + } else { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } + } + FXJSE_Value_Release(unitspanValue); + if (argc == 2) { + FXJSE_Value_Release(unitValue); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"UnitValue"); + } +} +void CXFA_FM2JSContext::At(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString stringTwo; + HValueToUTF8String(argTwo, stringTwo); + if (stringTwo.IsEmpty()) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 1); + } else { + CFX_ByteString stringOne; + HValueToUTF8String(argOne, stringOne); + FX_STRSIZE iPosition = stringOne.Find(stringTwo); + FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"At"); + } +} +void CXFA_FM2JSContext::Concat(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc >= 1) { + CFX_ByteString resultString; + FX_BOOL bAllNull = TRUE; + FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); + for (int32_t i = 0; i < argc; i++) { + argValues[i] = GetSimpleHValue(hThis, args, i); + if (!HValueIsNull(hThis, argValues[i])) { + CFX_ByteString valueStr; + HValueToUTF8String(argValues[i], valueStr); + resultString += valueStr; + bAllNull = FALSE; + } + } + for (int32_t i = 0; i < argc; i++) { + FXJSE_Value_Release(argValues[i]); + } + FX_Free(argValues); + if (bAllNull) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString); + } + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Concat"); + } +} +void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString toDecodeString; + HValueToUTF8String(argOne, toDecodeString); + CFX_ByteTextBuf resultBuf; + DecodeURL(toDecodeString, resultBuf); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } + FXJSE_Value_Release(argOne); + } else if (argc == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString toDecodeString; + HValueToUTF8String(argOne, toDecodeString); + CFX_ByteString identifyString; + HValueToUTF8String(argTwo, identifyString); + CFX_ByteTextBuf resultBuf; + if (identifyString.EqualNoCase("html")) { + DecodeHTML(toDecodeString, resultBuf); + } else if (identifyString.EqualNoCase("xml")) { + DecodeXML(toDecodeString, resultBuf); + } else { + DecodeURL(toDecodeString, resultBuf); + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Decode"); + } +} +void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, + CFX_ByteTextBuf& szResultString) { + CFX_WideString wsURLString = + CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); + const FX_WCHAR* pData = wsURLString; + int32_t iLen = wsURLString.GetLength(); + int32_t i = 0; + FX_WCHAR ch = 0; + FX_WCHAR chTemp = 0; + CFX_WideTextBuf wsResultBuf; + while (i < iLen) { + ch = *(pData + i); + if ('%' == ch) { + chTemp = 0; + int32_t iCount = 0; + while (iCount < 2) { + ++i; + ch = *(pData + i); + if (ch <= '9' && ch >= '0') { + if (!iCount) { + chTemp += (ch - '0') * 16; + } else { + chTemp += (ch - '0'); + } + } else { + if (ch <= 'F' && ch >= 'A') { + if (!iCount) { + chTemp += (ch - 'A' + 10) * 16; + } else { + chTemp += (ch - 'A' + 10); + } + } else if (ch <= 'f' && ch >= 'a') { + if (!iCount) { + chTemp += (ch - 'a' + 10) * 16; + } else { + chTemp += (ch - 'a' + 10); + } + } else { + wsResultBuf.Clear(); + return; + } + } + ++iCount; + } + wsResultBuf.AppendChar(chTemp); + } else { + wsResultBuf.AppendChar(ch); + } + ++i; + } + wsResultBuf.AppendChar(0); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); +} +void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, + CFX_ByteTextBuf& szResultString) { + CFX_WideString wsHTMLString = CFX_WideString::FromUTF8( + szHTMLString.GetCStr(), szHTMLString.GetLength()); + 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; + CFX_WideTextBuf wsResultBuf; + while (i < iLen) { + ch = *(pData + i); + if (ch == '&') { + ++i; + ch = *(pData + i); + if (ch == '#') { + ++i; + ch = *(pData + i); + if (ch == 'x' || ch == 'X') { + ++i; + ch = *(pData + i); + if ((ch >= '0' && ch <= '9') || (ch <= 'f' && ch >= 'a') || + (ch <= 'F' && ch >= 'A')) { + while (ch != ';' && i < iLen) { + if (ch >= '0' && ch <= '9') { + iCode += ch - '0'; + } else if (ch <= 'f' && ch >= 'a') { + iCode += ch - 'a' + 10; + } else if (ch <= 'F' && ch >= 'A') { + iCode += ch - 'A' + 10; + } else { + wsResultBuf.Clear(); + return; + } + ++i; + iCode *= 16; + ch = *(pData + i); + } + iCode /= 16; + } + } else { + wsResultBuf.Clear(); + return; + } + } else { + while (ch != ';' && i < iLen) { + strString[iStrIndex++] = ch; + ++i; + ch = *(pData + i); + } + strString[iStrIndex] = 0; + } + } else { + wsResultBuf.AppendChar(ch); + ++i; + continue; + } + uint32_t iData = 0; + if (HTMLSTR2Code(strString, iData)) { + wsResultBuf.AppendChar((FX_WCHAR)iData); + } else { + wsResultBuf.AppendChar(iCode); + } + iStrIndex = 0; + strString[iStrIndex] = 0; + ++i; + } + wsResultBuf.AppendChar(0); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); +} +void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, + CFX_ByteTextBuf& szResultString) { + CFX_WideString wsXMLString = + CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); + 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; + CFX_WideTextBuf wsXMLBuf; + while (i < iLen) { + ch = *(pData + i); + if (ch == '&') { + ++i; + ch = *(pData + i); + if (ch == '#') { + ++i; + ch = *(pData + i); + if (ch == 'x' || ch == 'X') { + ++i; + ch = *(pData + i); + if ((ch >= '0' && ch <= '9') || (ch <= 'f' && ch >= 'a') || + (ch <= 'F' && ch >= 'A')) { + while (ch != ';') { + if (ch >= '0' && ch <= '9') { + iCode += ch - '0'; + } else if (ch <= 'f' && ch >= 'a') { + iCode += ch - 'a' + 10; + } else if (ch <= 'F' && ch >= 'A') { + iCode += ch - 'A' + 10; + } else { + wsXMLBuf.Clear(); + return; + } + ++i; + iCode *= 16; + ch = *(pData + i); + } + iCode /= 16; + } + } else { + wsXMLBuf.Clear(); + return; + } + } else { + while (ch != ';' && i < iLen) { + strString[iStrIndex++] = ch; + ++i; + ch = *(pData + i); + } + strString[iStrIndex] = 0; + } + } else { + wsXMLBuf.AppendChar(ch); + ++i; + continue; + } + const FX_WCHAR* const strName[] = {L"quot", L"amp", L"apos", L"lt", L"gt"}; + int32_t iIndex = 0; + while (iIndex < 5) { + if (FXSYS_memcmp(strString, strName[iIndex], + FXSYS_wcslen(strName[iIndex])) == 0) { + break; + } + ++iIndex; + } + switch (iIndex) { + case 0: + wsXMLBuf.AppendChar('"'); + break; + case 1: + wsXMLBuf.AppendChar('&'); + break; + case 2: + wsXMLBuf.AppendChar('\''); + break; + case 3: + wsXMLBuf.AppendChar('<'); + break; + case 4: + wsXMLBuf.AppendChar('>'); + break; + default: + wsXMLBuf.AppendChar(iCode); + break; + } + iStrIndex = 0; + strString[iStrIndex] = 0; + ++i; + iCode = 0; + } + wsXMLBuf.AppendChar(0); + szResultString.Clear(); + szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()); +} +void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString toEncodeString; + HValueToUTF8String(argOne, toEncodeString); + CFX_ByteTextBuf resultBuf; + EncodeURL(toEncodeString, resultBuf); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } + FXJSE_Value_Release(argOne); + } else if (argc == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString toEncodeString; + HValueToUTF8String(argOne, toEncodeString); + CFX_ByteString identifyString; + HValueToUTF8String(argTwo, identifyString); + CFX_ByteTextBuf resultBuf; + if (identifyString.EqualNoCase("html")) { + EncodeHTML(toEncodeString, resultBuf); + } else if (identifyString.EqualNoCase("xml")) { + EncodeXML(toEncodeString, resultBuf); + } else { + EncodeURL(toEncodeString, resultBuf); + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Encode"); + } +} +void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, + CFX_ByteTextBuf& szResultBuf) { + CFX_WideString wsURLString = + CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); + CFX_WideTextBuf wsResultBuf; + FX_WCHAR ch = 0; + int32_t iLength = wsURLString.GetLength(); + FX_WCHAR strEncode[4]; + strEncode[0] = '%'; + strEncode[3] = 0; + FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', + '|', '\\', '^', '~', '[', ']', '`'}; + FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; + FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; + const FX_WCHAR* strCode = L"0123456789abcdef"; + for (int32_t u = 0; u < iLength; ++u) { + ch = wsURLString.GetAt(u); + int32_t i = 0; + int32_t iCount = sizeof(strUnsafe) / sizeof(strUnsafe[0]); + while (i < iCount) { + if (ch == strUnsafe[i]) { + int32_t iIndex = ch / 16; + strEncode[1] = strCode[iIndex]; + strEncode[2] = strCode[ch - iIndex * 16]; + wsResultBuf << FX_WSTRC(strEncode); + break; + } + ++i; + } + if (i < iCount) { + continue; + } + i = 0; + iCount = sizeof(strReserved) / sizeof(strReserved[0]); + while (i < iCount) { + if (ch == strReserved[i]) { + int32_t iIndex = ch / 16; + strEncode[1] = strCode[iIndex]; + strEncode[2] = strCode[ch - iIndex * 16]; + wsResultBuf << FX_WSTRC(strEncode); + break; + } + ++i; + } + if (i < iCount) { + continue; + } + i = 0; + iCount = sizeof(strSpecial) / sizeof(strSpecial[0]); + while (i < iCount) { + if (ch == strSpecial[i]) { + wsResultBuf.AppendChar(ch); + break; + } + ++i; + } + if (i < iCount) { + continue; + } + if (ch >= 0x80 && ch <= 0xff) { + int32_t iIndex = ch / 16; + strEncode[1] = strCode[iIndex]; + strEncode[2] = strCode[ch - iIndex * 16]; + wsResultBuf << FX_WSTRC(strEncode); + } else if (ch <= 0x1f || ch == 0x7f) { + int32_t iIndex = ch / 16; + strEncode[1] = strCode[iIndex]; + strEncode[2] = strCode[ch - iIndex * 16]; + wsResultBuf << FX_WSTRC(strEncode); + } else if (ch >= 0x20 && ch <= 0x7e) { + wsResultBuf.AppendChar(ch); + } else { + int32_t iRadix = 16; + CFX_WideString strTmp; + while (ch >= iRadix) { + FX_WCHAR tmp = strCode[ch % iRadix]; + ch /= iRadix; + strTmp += tmp; + } + strTmp += strCode[ch]; + int32_t iLen = strTmp.GetLength(); + if (iLen < 2) { + break; + } + int32_t iIndex = 0; + if (iLen % 2 != 0) { + strEncode[1] = '0'; + strEncode[2] = strTmp.GetAt(iLen - 1); + iIndex = iLen - 2; + } else { + strEncode[1] = strTmp.GetAt(iLen - 1); + strEncode[2] = strTmp.GetAt(iLen - 2); + iIndex = iLen - 3; + } + wsResultBuf << FX_WSTRC(strEncode); + while (iIndex > 0) { + strEncode[1] = strTmp.GetAt(iIndex); + strEncode[2] = strTmp.GetAt(iIndex - 1); + iIndex -= 2; + wsResultBuf << FX_WSTRC(strEncode); + } + } + } + wsResultBuf.AppendChar(0); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); +} +void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, + CFX_ByteTextBuf& szResultBuf) { + CFX_ByteString str = szHTMLString.GetCStr(); + CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); + const FX_WCHAR* strCode = L"0123456789abcdef"; + FX_WCHAR strEncode[9]; + strEncode[0] = '&'; + strEncode[1] = '#'; + strEncode[2] = 'x'; + strEncode[5] = ';'; + strEncode[6] = 0; + strEncode[7] = ';'; + strEncode[8] = 0; + CFX_WideTextBuf wsResultBuf; + uint32_t ch = 0; + int32_t iLen = wsHTMLString.GetLength(); + int32_t i = 0; + const FX_WCHAR* pData = wsHTMLString; + int32_t iIndex = 0; + CFX_WideString htmlReserve; + while (i < iLen) { + ch = *(pData + i); + htmlReserve.Empty(); + if (HTMLCode2STR(ch, htmlReserve)) { + wsResultBuf.AppendChar(L'&'); + wsResultBuf << htmlReserve; + wsResultBuf.AppendChar(L';'); + } else { + if (ch >= 32 && ch <= 126) { + wsResultBuf.AppendChar((FX_WCHAR)ch); + } else if (ch < 256) { + iIndex = ch / 16; + strEncode[3] = strCode[iIndex]; + strEncode[4] = strCode[ch - iIndex * 16]; + strEncode[5] = ';'; + strEncode[6] = 0; + wsResultBuf << FX_WSTRC(strEncode); + } else { + int32_t iBigByte = ch / 256; + int32_t iLittleByte = ch % 256; + strEncode[3] = strCode[iBigByte / 16]; + strEncode[4] = strCode[iBigByte % 16]; + strEncode[5] = strCode[iLittleByte / 16]; + strEncode[6] = strCode[iLittleByte % 16]; + wsResultBuf << FX_WSTRC(strEncode); + } + } + ++i; + } + wsResultBuf.AppendChar(0); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); +} +void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, + CFX_ByteTextBuf& szResultBuf) { + CFX_WideString wsXMLString = + CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); + CFX_WideTextBuf wsResultBuf; + enum { + QUOT, + AMP, + APOS, + LT, + GT, + }; + FX_WCHAR strEncode[9]; + strEncode[0] = '&'; + strEncode[1] = '#'; + strEncode[2] = 'x'; + strEncode[5] = ';'; + strEncode[6] = 0; + strEncode[7] = ';'; + strEncode[8] = 0; + const FX_WCHAR* const strName[] = {L"quot", L"amp", L"apos", L"lt", L"gt"}; + const FX_WCHAR* strCode = L"0123456789abcdef"; + FX_WCHAR ch = 0; + int32_t iLength = wsXMLString.GetLength(); + int32_t iIndex = 0; + int32_t u = 0; + const FX_WCHAR* pData = wsXMLString; + for (u = 0; u < iLength; ++u) { + ch = *(pData + u); + switch (ch) { + case '"': + wsResultBuf.AppendChar('&'); + wsResultBuf << CFX_WideStringC(strName[QUOT]); + wsResultBuf.AppendChar(';'); + break; + case '&': + wsResultBuf.AppendChar('&'); + wsResultBuf << CFX_WideStringC(strName[AMP]); + wsResultBuf.AppendChar(';'); + break; + case '\'': + wsResultBuf.AppendChar('&'); + wsResultBuf << CFX_WideStringC(strName[APOS]); + wsResultBuf.AppendChar(';'); + break; + case '<': + wsResultBuf.AppendChar('&'); + wsResultBuf << CFX_WideStringC(strName[LT]); + wsResultBuf.AppendChar(';'); + break; + case '>': + wsResultBuf.AppendChar('&'); + wsResultBuf << CFX_WideStringC(strName[GT]); + wsResultBuf.AppendChar(';'); + break; + default: { + if (ch >= 32 && ch <= 126) { + wsResultBuf.AppendChar(ch); + } else if (ch < 256) { + iIndex = ch / 16; + strEncode[3] = strCode[iIndex]; + strEncode[4] = strCode[ch - iIndex * 16]; + strEncode[5] = ';'; + strEncode[6] = 0; + wsResultBuf << FX_WSTRC(strEncode); + } else { + int32_t iBigByte = ch / 256; + int32_t iLittleByte = ch % 256; + strEncode[3] = strCode[iBigByte / 16]; + strEncode[4] = strCode[iBigByte % 16]; + strEncode[5] = strCode[iLittleByte / 16]; + strEncode[6] = strCode[iLittleByte % 16]; + wsResultBuf << FX_WSTRC(strEncode); + } + } break; + } + } + wsResultBuf.AppendChar(0); + szResultBuf.Clear(); + szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), + wsResultBuf.GetLength()); +} +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.GetPtr(), iLength); + XFA_FMHtmlHashedReserveCode htmlhashedreservecode; + int32_t iStart = 0, + iEnd = (sizeof(reservesForDecode) / sizeof(reservesForDecode[0])) - 1; + int32_t iMid = (iStart + iEnd) / 2; + do { + iMid = (iStart + iEnd) / 2; + htmlhashedreservecode = reservesForDecode[iMid]; + if (uHash == htmlhashedreservecode.m_uHash) { + iCode = htmlhashedreservecode.m_uCode; + return TRUE; + } else if (uHash < htmlhashedreservecode.m_uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return FALSE; +} +FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, + CFX_WideString& wsHTMLReserve) { + XFA_FMHtmlReserveCode htmlreservecode; + int32_t iStart = 0, + iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; + int32_t iMid = (iStart + iEnd) / 2; + do { + iMid = (iStart + iEnd) / 2; + htmlreservecode = reservesForEncode[iMid]; + if (iCode == htmlreservecode.m_uCode) { + wsHTMLReserve = htmlreservecode.m_htmlReserve; + return TRUE; + } else if (iCode < htmlreservecode.m_uCode) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return FALSE; +} +static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, + FX_DWORD& patternType) { + CFX_WideString wsPattern = + CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); + if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { + patternType = XFA_VT_DATETIME; + return TRUE; + } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { + patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; + return TRUE; + } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { + patternType = XFA_VT_TIME; + return TRUE; + } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { + patternType = XFA_VT_TEXT; + return TRUE; + } else if (FX_WSTRC(L"num") == wsPattern.Left(3)) { + if (FX_WSTRC(L"integer") == wsPattern.Mid(4, 7)) { + patternType = XFA_VT_INTEGER; + } else if (FX_WSTRC(L"decimal") == wsPattern.Mid(4, 7)) { + patternType = XFA_VT_DECIMAL; + } else if (FX_WSTRC(L"currency") == wsPattern.Mid(4, 8)) { + patternType = XFA_VT_FLOAT; + } else if (FX_WSTRC(L"percent") == wsPattern.Mid(4, 7)) { + patternType = XFA_VT_FLOAT; + } else { + patternType = XFA_VT_FLOAT; + } + return TRUE; + } + patternType = XFA_VT_NULL; + wsPattern.MakeLower(); + const FX_WCHAR* pData = wsPattern; + int32_t iLength = wsPattern.GetLength(); + int32_t iIndex = 0; + FX_BOOL bSingleQuotation = FALSE; + FX_WCHAR patternChar; + while (iIndex < iLength) { + patternChar = *(pData + iIndex); + if (patternChar == 0x27) { + bSingleQuotation = !bSingleQuotation; + } else if (!bSingleQuotation && + (patternChar == 'y' || patternChar == 'j')) { + patternType = XFA_VT_DATE; + iIndex++; + FX_WCHAR timePatternChar; + while (iIndex < iLength) { + timePatternChar = *(pData + iIndex); + if (timePatternChar == 0x27) { + bSingleQuotation = !bSingleQuotation; + } else if (!bSingleQuotation && timePatternChar == 't') { + patternType = XFA_VT_DATETIME; + break; + } + iIndex++; + } + break; + } else if (!bSingleQuotation && + (patternChar == 'h' || patternChar == 'k')) { + patternType = XFA_VT_TIME; + break; + } else if (!bSingleQuotation && + (patternChar == 'a' || patternChar == 'x' || + patternChar == 'o' || patternChar == '0')) { + patternType = XFA_VT_TEXT; + if (patternChar == 'x' || patternChar == 'o' || patternChar == '0') { + break; + } + } else if (!bSingleQuotation && + (patternChar == 'z' || patternChar == 's' || + patternChar == 'e' || patternChar == 'v' || + patternChar == '8' || patternChar == ',' || + patternChar == '.' || patternChar == '$')) { + patternType = XFA_VT_FLOAT; + if (patternChar == 'v' || patternChar == '8' || patternChar == '$') { + break; + } + } + iIndex++; + } + if (patternType == XFA_VT_NULL) { + patternType = XFA_VT_TEXT | XFA_VT_FLOAT; + } + return FALSE; +} +void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc >= 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + CFX_ByteString szPattern; + HValueToUTF8String(argOne, szPattern); + CFX_ByteString szValue; + HValueToUTF8String(argTwo, szValue); + CXFA_Document* pDoc = pContext->GetDocument(); + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + IFX_Locale* pLocale = widgetData.GetLocal(); + FX_DWORD patternType; + FX_BOOL bCompelte = XFA_PATTERN_STRING_Type(szPattern, patternType); + CFX_WideString wsPattern = + CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); + CFX_WideString wsValue = + CFX_WideString::FromUTF8(szValue, szValue.GetLength()); + if (!bCompelte) { + switch (patternType) { + case XFA_VT_DATETIME: { + FX_STRSIZE iTChar = wsPattern.Find(L'T'); + CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); + wsDatePattern += wsPattern.Left(iTChar); + wsDatePattern += FX_WSTRC(L"} "); + CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); + wsTimePattern += wsPattern.Mid(iTChar + 1); + wsTimePattern += FX_WSTRC(L"}"); + wsPattern = wsDatePattern + wsTimePattern; + } break; + case XFA_VT_DATE: { + wsPattern = FX_WSTRC(L"date{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + } break; + case XFA_VT_TIME: { + wsPattern = FX_WSTRC(L"time{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + } break; + case XFA_VT_TEXT: { + wsPattern = FX_WSTRC(L"text{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + } break; + case XFA_VT_FLOAT: { + wsPattern = FX_WSTRC(L"num{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + } break; + default: { + CFX_WideString wsTestPattern; + wsTestPattern = FX_WSTRC(L"num{") + wsPattern; + wsTestPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue tempLocaleValue(XFA_VT_FLOAT, wsValue, wsTestPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (tempLocaleValue.IsValid()) { + wsPattern = wsTestPattern; + patternType = XFA_VT_FLOAT; + } else { + wsTestPattern = FX_WSTRC(L"text{") + wsPattern; + wsTestPattern += FX_WSTRC(L"}"); + wsPattern = wsTestPattern; + patternType = XFA_VT_TEXT; + } + } break; + } + } + CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, + (CXFA_LocaleMgr*)pMgr); + CFX_WideString wsRet; + if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, + XFA_VALUEPICTURE_Display)) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + FX_UTF8Encode(wsRet, wsRet.GetLength())); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Format"); + } +} +void CXFA_FM2JSContext::Left(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FX_BOOL argIsNull = FALSE; + if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { + argIsNull = TRUE; + } + if (argIsNull) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString sourceString; + HValueToUTF8String(argOne, sourceString); + int32_t count = HValueToInteger(hThis, argTwo); + if (count < 0) { + count = 0; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + sourceString.Left(count)); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Left"); + } +} +void CXFA_FM2JSContext::Len(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString sourceString; + HValueToUTF8String(argOne, sourceString); + FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Len"); + } +} +void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 3)) { + CFX_ByteString argString; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE localeValue = 0; + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + if (argc == 2) { + localeValue = GetSimpleHValue(hThis, args, 1); + } + HValueToUTF8String(argOne, argString); + CFX_WideTextBuf lowStringBuf; + CFX_WideString wsArgString = + CFX_WideString::FromUTF8(argString, argString.GetLength()); + const FX_WCHAR* pData = wsArgString; + int32_t iLen = argString.GetLength(); + int32_t i = 0; + int32_t ch = 0; + while (i < iLen) { + ch = *(pData + i); + if (ch >= 0x41 && ch <= 0x5A) { + ch += 32; + } else if (ch >= 0xC0 && ch <= 0xDE) { + ch += 32; + } else if (ch == 0x100 || ch == 0x102 || ch == 0x104) { + ch += 1; + } + lowStringBuf.AppendChar(ch); + ++i; + } + lowStringBuf.AppendChar(0); + FXJSE_Value_SetUTF8String( + args.GetReturnValue(), + FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())); + if (argc == 2) { + FXJSE_Value_Release(localeValue); + } + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Lower"); + } +} +void CXFA_FM2JSContext::Ltrim(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString sourceString; + HValueToUTF8String(argOne, sourceString); + sourceString.TrimLeft(); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), sourceString); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Ltrim"); + } +} +void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + if (HValueIsNull(hThis, argTwo)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString szPattern; + HValueToUTF8String(argOne, szPattern); + CFX_ByteString szValue; + HValueToUTF8String(argTwo, szValue); + CXFA_Document* pDoc = pContext->GetDocument(); + IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); + CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); + FXSYS_assert(pThisNode); + CXFA_WidgetData widgetData(pThisNode); + IFX_Locale* pLocale = widgetData.GetLocal(); + FX_DWORD patternType; + FX_BOOL bCompletePattern = + XFA_PATTERN_STRING_Type(szPattern, patternType); + CFX_WideString wsPattern = + CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); + CFX_WideString wsValue = + CFX_WideString::FromUTF8(szValue, szValue.GetLength()); + CFX_ByteString szParsedValue; + if (bCompletePattern) { + CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, + (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } else { + switch (patternType) { + case XFA_VT_DATETIME: { + FX_STRSIZE iTChar = wsPattern.Find(L'T'); + CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); + wsDatePattern += wsPattern.Left(iTChar); + wsDatePattern += FX_WSTRC(L"} "); + CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); + wsTimePattern += wsPattern.Mid(iTChar + 1); + wsTimePattern += FX_WSTRC(L"}"); + wsPattern = wsDatePattern + wsTimePattern; + CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } break; + case XFA_VT_DATE: { + wsPattern = FX_WSTRC(L"date{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } break; + case XFA_VT_TIME: { + wsPattern = FX_WSTRC(L"time{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } break; + case XFA_VT_TEXT: { + wsPattern = FX_WSTRC(L"text{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } break; + case XFA_VT_FLOAT: { + wsPattern = FX_WSTRC(L"num{") + wsPattern; + wsPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + FXJSE_Value_SetDouble(args.GetReturnValue(), + localeValue.GetDoubleNum()); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } break; + default: { + CFX_WideString wsTestPattern; + wsTestPattern = FX_WSTRC(L"num{") + wsPattern; + wsTestPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + FXJSE_Value_SetDouble(args.GetReturnValue(), + localeValue.GetDoubleNum()); + } else { + wsTestPattern = FX_WSTRC(L"text{") + wsPattern; + wsTestPattern += FX_WSTRC(L"}"); + CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern, + pLocale, (CXFA_LocaleMgr*)pMgr); + if (localeValue.IsValid()) { + szParsedValue = FX_UTF8Encode(localeValue.GetValue()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); + } else { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } + } + } break; + } + } + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Parse"); + } +} +void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc == 2) || (argc == 3)) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE argThree = 0; + CFX_ByteString oneString; + CFX_ByteString twoString; + CFX_ByteString threeString; + if (!HValueIsNull(hThis, argOne) && !HValueIsNull(hThis, argTwo)) { + HValueToUTF8String(argOne, oneString); + HValueToUTF8String(argTwo, twoString); + } + if (argc == 3) { + argThree = GetSimpleHValue(hThis, args, 2); + HValueToUTF8String(argThree, threeString); + } + int32_t iSrcLen = oneString.GetLength(); + int32_t iFindLen = twoString.GetLength(); + CFX_ByteTextBuf resultString; + int32_t iFindIndex = 0; + uint8_t ch = 0; + for (int32_t u = 0; u < iSrcLen; ++u) { + ch = oneString.GetAt(u); + if (ch == twoString.GetAt(iFindIndex)) { + int32_t iTemp = u + 1; + ++iFindIndex; + uint8_t chTemp = 0; + while (iFindIndex < iFindLen) { + chTemp = oneString.GetAt(iTemp); + if (chTemp == twoString.GetAt(iFindIndex)) { + ++iTemp; + ++iFindIndex; + } else { + iFindIndex = 0; + break; + } + } + if (iFindIndex == iFindLen) { + resultString << threeString; + u += iFindLen - 1; + iFindIndex = 0; + } else { + resultString.AppendChar(ch); + } + } else { + resultString.AppendChar(ch); + } + } + resultString.AppendChar(0); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultString.GetByteString()); + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + if (argc == 3) { + FXJSE_Value_Release(argThree); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Replace"); + } +} +void CXFA_FM2JSContext::Right(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 2) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); + FX_BOOL argIsNull = FALSE; + if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { + argIsNull = TRUE; + } + if (argIsNull) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString sourceString; + HValueToUTF8String(argOne, sourceString); + int32_t count = HValueToInteger(hThis, argTwo); + if (count < 0) { + count = 0; + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + sourceString.Right(count)); + } + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Right"); + } +} +void CXFA_FM2JSContext::Rtrim(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString sourceString; + HValueToUTF8String(argOne, sourceString); + sourceString.TrimRight(); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), sourceString); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Rtrim"); + } +} +void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + int32_t count = 0; + count = HValueToInteger(hThis, argOne); + count = (count < 0) ? 0 : count; + CFX_ByteTextBuf spaceString; + int32_t index = 0; + while (index < count) { + spaceString.AppendByte(' '); + index++; + } + spaceString.AppendByte(0); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + spaceString.GetByteString()); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Space"); + } +} +void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + FX_FLOAT fNumber; + int32_t iWidth = 10; + int32_t iPrecision = 0; + FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE widthValue = 0; + FXJSE_HVALUE precisionValue = 0; + if (FXJSE_Value_IsNull(numberValue)) { + bFlags = TRUE; + } else { + fNumber = HValueToFloat(hThis, numberValue); + } + if (argc > 1) { + widthValue = GetSimpleHValue(hThis, args, 1); + iWidth = (int32_t)HValueToFloat(hThis, widthValue); + } + if (argc == 3) { + precisionValue = GetSimpleHValue(hThis, args, 2); + iPrecision = (int32_t)HValueToFloat(hThis, precisionValue); + if (iPrecision < 0) { + iPrecision = 0; + } + } + if (!bFlags) { + CFX_ByteString numberString; + CFX_ByteString formatStr = "%"; + if (iPrecision) { + formatStr += "."; + formatStr += CFX_ByteString::FormatInteger(iPrecision); + } + formatStr += "f"; + numberString.Format(formatStr, fNumber); + const FX_CHAR* pData = numberString; + int32_t iLength = numberString.GetLength(); + int32_t u = 0; + while (u < iLength) { + if (*(pData + u) == '.') { + break; + } + ++u; + } + CFX_ByteTextBuf resultBuf; + if (u > iWidth || (iPrecision + u) >= iWidth) { + int32_t i = 0; + while (i < iWidth) { + resultBuf.AppendChar('*'); + ++i; + } + resultBuf.AppendChar(0); + } else { + if (u == iLength) { + if (iLength > iWidth) { + int32_t i = 0; + while (i < iWidth) { + resultBuf.AppendChar('*'); + ++i; + } + } else { + int32_t i = 0; + int32_t iSpace = iWidth - iLength; + while (i < iSpace) { + resultBuf.AppendChar(' '); + ++i; + } + resultBuf << pData; + } + } else { + int32_t iLeavingSpace = 0; + if (iPrecision == 0) { + iLeavingSpace = iWidth - (u + iPrecision); + } else { + iLeavingSpace = iWidth - (u + iPrecision + 1); + } + int32_t i = 0; + while (i < iLeavingSpace) { + resultBuf.AppendChar(' '); + ++i; + } + i = 0; + while (i < u) { + resultBuf.AppendChar(*(pData + i)); + ++i; + } + if (iPrecision != 0) { + resultBuf.AppendChar('.'); + } + u++; + i = 0; + while (u < iLength) { + if (i >= iPrecision) { + break; + } + resultBuf.AppendChar(*(pData + u)); + ++i; + ++u; + } + while (i < iPrecision) { + resultBuf.AppendChar('0'); + ++i; + } + resultBuf.AppendChar(0); + } + } + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(numberValue); + if (argc > 1) { + FXJSE_Value_Release(widthValue); + if (argc == 3) { + FXJSE_Value_Release(precisionValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Str"); + } +} +void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc == 3) || (argc == 4)) { + CFX_ByteString sourceString; + CFX_ByteString insertString; + int32_t iLength = 0; + int32_t iStart = 0; + int32_t iDelete = 0; + FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); + FXJSE_HVALUE insertValue = 0; + if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && + !FXJSE_Value_IsNull(deleteValue)) { + HValueToUTF8String(sourceValue, sourceString); + iLength = sourceString.GetLength(); + iStart = (int32_t)HValueToFloat(hThis, startValue); + if (iStart < 1) { + iStart = 1; + } + if (iStart > iLength) { + iStart = iLength; + } + iDelete = (int32_t)HValueToFloat(hThis, deleteValue); + if (iDelete <= 0) { + iDelete = 0; + } + } + if (argc == 4) { + insertValue = GetSimpleHValue(hThis, args, 3); + HValueToUTF8String(insertValue, insertString); + } + iStart -= 1; + CFX_ByteTextBuf resultString; + int32_t i = 0; + while (i < iStart) { + resultString.AppendChar(sourceString.GetAt(i)); + ++i; + } + resultString << insertString; + i = iStart + iDelete; + while (i < iLength) { + resultString.AppendChar(sourceString.GetAt(i)); + ++i; + } + resultString.AppendChar(0); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultString.GetByteString()); + FXJSE_Value_Release(sourceValue); + FXJSE_Value_Release(startValue); + FXJSE_Value_Release(deleteValue); + if (argc == 4) { + FXJSE_Value_Release(insertValue); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Stuff"); + } +} +void CXFA_FM2JSContext::Substr(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if (argc == 3) { + FXJSE_HVALUE stringValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); + FXJSE_HVALUE endValue = GetSimpleHValue(hThis, args, 2); + if (HValueIsNull(hThis, stringValue) || (HValueIsNull(hThis, startValue)) || + (HValueIsNull(hThis, endValue))) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + CFX_ByteString szSourceStr; + int32_t iStart = 0; + int32_t iCount = 0; + HValueToUTF8String(stringValue, szSourceStr); + int32_t iLength = szSourceStr.GetLength(); + if (iLength == 0) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } else { + iStart = (int32_t)HValueToFloat(hThis, startValue); + iCount = (int32_t)HValueToFloat(hThis, endValue); + if (iStart < 1) { + iStart = 1; + } + if (iStart > iLength) { + iStart = iLength; + } + if (iCount <= 0) { + iCount = 0; + } + iStart -= 1; + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + szSourceStr.Mid(iStart, iCount)); + } + } + FXJSE_Value_Release(stringValue); + FXJSE_Value_Release(startValue); + FXJSE_Value_Release(endValue); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Substr"); + } +} +void CXFA_FM2JSContext::Uuid(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc == 0) || (argc == 1)) { + int32_t iNum = 0; + FXJSE_HVALUE argOne = 0; + if (argc == 1) { + argOne = GetSimpleHValue(hThis, args, 0); + iNum = (int32_t)HValueToFloat(hThis, argOne); + } + FX_GUID guid; + FX_GUID_CreateV4(&guid); + CFX_ByteString bsUId; + FX_GUID_ToString(&guid, bsUId, iNum); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId); + if (argc == 1) { + FXJSE_Value_Release(argOne); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Uuid"); + } +} +void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 3)) { + CFX_ByteString argString; + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE localeValue = 0; + if (HValueIsNull(hThis, argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + if (argc == 2) { + localeValue = GetSimpleHValue(hThis, args, 1); + } + HValueToUTF8String(argOne, argString); + CFX_WideTextBuf upperStringBuf; + CFX_WideString wsArgString = + CFX_WideString::FromUTF8(argString, argString.GetLength()); + const FX_WCHAR* pData = wsArgString; + int32_t iLen = wsArgString.GetLength(); + int32_t i = 0; + int32_t ch = 0; + while (i < iLen) { + ch = *(pData + i); + if (ch >= 0x61 && ch <= 0x7A) { + ch -= 32; + } else if (ch >= 0xE0 && ch <= 0xFE) { + ch -= 32; + } else if (ch == 0x101 || ch == 0x103 || ch == 0x105) { + ch -= 1; + } + upperStringBuf.AppendChar(ch); + ++i; + } + upperStringBuf.AppendChar(0); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + FX_UTF8Encode(upperStringBuf.GetBuffer(), + upperStringBuf.GetLength())); + if (argc == 2) { + FXJSE_Value_Release(localeValue); + } + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Upper"); + } +} +void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t argc = args.GetLength(); + if ((argc > 0) && (argc < 4)) { + FX_BOOL bFlags = FALSE; + FX_FLOAT fNumber; + int32_t iIdentifier = 0; + CFX_ByteString localeString; + FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE identifierValue = 0; + FXJSE_HVALUE localeValue = 0; + if (FXJSE_Value_IsNull(numberValue)) { + bFlags = TRUE; + } else { + fNumber = HValueToFloat(hThis, numberValue); + } + if (argc > 1) { + identifierValue = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(identifierValue)) { + bFlags = TRUE; + } else { + iIdentifier = (int32_t)HValueToFloat(hThis, identifierValue); + } + } + if (argc == 3) { + localeValue = GetSimpleHValue(hThis, args, 2); + if (FXJSE_Value_IsNull(localeValue)) { + bFlags = TRUE; + } else { + HValueToUTF8String(localeValue, localeString); + } + } + if (!bFlags) { + if ((fNumber < 0) || (fNumber > 922337203685477550)) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); + } else { + CFX_ByteTextBuf resultBuf; + CFX_ByteString numberString; + numberString.Format("%.2f", fNumber); + WordUS(numberString, iIdentifier, resultBuf); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + resultBuf.GetByteString()); + } + } else { + FXJSE_Value_SetNull(args.GetReturnValue()); + } + FXJSE_Value_Release(numberValue); + if (argc > 1) { + FXJSE_Value_Release(identifierValue); + if (argc == 3) { + FXJSE_Value_Release(localeValue); + } + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"WordNum"); + } +} +void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, + CFX_ByteTextBuf& strBuf) { + CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", + "five", "six", "seven", "eight", "nine"}; + CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", + "Five", "Six", "Seven", "Eight", "Nine"}; + CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", + "Fourteen", "Fifteen", "Sixteen", "Seventeen", + "Eighteen", "Nineteen"}; + CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", + "Sixty", "Seventy", "Eighty", "Ninety"}; + CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", + " Billion ", "Trillion"}; + int32_t iComm = 0; + const FX_CHAR* pData = szData.GetCStr(); + int32_t iLength = szData.GetLength(); + if (iLength > 12) { + iComm = 4; + } else if (iLength > 9) { + iComm = 3; + } else if (iLength > 6) { + iComm = 2; + } else if (iLength > 3) { + iComm = 1; + } + int32_t iIndex = 0; + int32_t iFirstCount = iLength % 3; + if (iFirstCount == 0) { + iFirstCount = 3; + } + if (iFirstCount == 3) { + if (*(pData + iIndex) != '0') { + strBuf << pCapUnits[*(pData + iIndex) - '0']; + strBuf << pComm[0]; + } + if (*(pData + iIndex + 1) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; + } else { + if (*(pData + iIndex + 1) > '1') { + strBuf << pLastTens[*(pData + iIndex + 1) - '2']; + strBuf << "-"; + strBuf << pUnits[*(pData + iIndex + 2) - '0']; + } else if (*(pData + iIndex + 1) == '1') { + strBuf << pTens[*(pData + iIndex + 2) - '0']; + } else if (*(pData + iIndex + 1) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; + } + } + iIndex += 3; + } else if (iFirstCount == 2) { + if (*(pData + iIndex) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 1) - '0']; + } else { + if (*(pData + iIndex) > '1') { + strBuf << pLastTens[*(pData + iIndex) - '2']; + strBuf << "-"; + strBuf << pUnits[*(pData + iIndex + 1) - '0']; + } else if (*(pData + iIndex) == '1') { + strBuf << pTens[*(pData + iIndex + 1) - '0']; + } else if (*(pData + iIndex) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 1) - '0']; + } + } + iIndex += 2; + } else if (iFirstCount == 1) { + strBuf << pCapUnits[*(pData + iIndex) - '0']; + iIndex += 1; + } + if (iLength > 3 && iFirstCount > 0) { + strBuf << pComm[iComm]; + --iComm; + } + while (iIndex < iLength) { + if (*(pData + iIndex) != '0') { + strBuf << pCapUnits[*(pData + iIndex) - '0']; + strBuf << pComm[0]; + } + if (*(pData + iIndex + 1) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; + } else { + if (*(pData + iIndex + 1) > '1') { + strBuf << pLastTens[*(pData + iIndex + 1) - '2']; + strBuf << "-"; + strBuf << pUnits[*(pData + iIndex + 2) - '0']; + } else if (*(pData + iIndex + 1) == '1') { + strBuf << pTens[*(pData + iIndex + 2) - '0']; + } else if (*(pData + iIndex + 1) == '0') { + strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; + } + } + if (iIndex < iLength - 3) { + strBuf << pComm[iComm]; + --iComm; + } + iIndex += 3; + } +} +void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, + int32_t iStyle, + CFX_ByteTextBuf& strBuf) { + const FX_CHAR* pData = szData.GetCStr(); + int32_t iLength = szData.GetLength(); + switch (iStyle) { + case 0: { + int32_t iIndex = 0; + while (iIndex < iLength) { + if (*(pData + iIndex) == '.') { + break; + } + ++iIndex; + } + iLength = iIndex; + iIndex = 0; + int32_t iCount = 0; + while (iIndex < iLength) { + iCount = (iLength - iIndex) % 12; + if (!iCount && iLength - iIndex > 0) { + iCount = 12; + } + TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); + iIndex += iCount; + if (iIndex < iLength) { + strBuf << " Trillion "; + } + } + } break; + case 1: { + int32_t iIndex = 0; + while (iIndex < iLength) { + if (*(pData + iIndex) == '.') { + break; + } + ++iIndex; + } + iLength = iIndex; + iIndex = 0; + int32_t iCount = 0; + while (iIndex < iLength) { + iCount = (iLength - iIndex) % 12; + if (!iCount && iLength - iIndex > 0) { + iCount = 12; + } + TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); + iIndex += iCount; + if (iIndex < iLength) { + strBuf << " Trillion "; + } + } + strBuf << " Dollars"; + } break; + case 2: { + int32_t iIndex = 0; + while (iIndex < iLength) { + if (*(pData + iIndex) == '.') { + break; + } + ++iIndex; + } + int32_t iInteger = iIndex; + iIndex = 0; + int32_t iCount = 0; + while (iIndex < iInteger) { + iCount = (iInteger - iIndex) % 12; + if (!iCount && iLength - iIndex > 0) { + iCount = 12; + } + TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); + iIndex += iCount; + if (iIndex < iInteger) { + strBuf << " Trillion "; + } + } + strBuf << " Dollars"; + if (iInteger < iLength) { + strBuf << " And "; + iIndex = iInteger + 1; + int32_t iCount = 0; + while (iIndex < iLength) { + iCount = (iLength - iIndex) % 12; + if (!iCount && iLength - iIndex > 0) { + iCount = 12; + } + TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); + iIndex += iCount; + if (iIndex < iLength) { + strBuf << " Trillion "; + } + } + strBuf << " Cents"; + } + } break; + default: + break; + } +} +void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc == 1) { + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return; + } + IXFA_AppProvider* pAppProvider = + pDoc->GetParser()->GetNotify()->GetAppProvider(); + if (!pAppProvider) { + return; + } + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + CFX_ByteString urlString; + HValueToUTF8String(argOne, urlString); + IFX_FileRead* pFile = pAppProvider->DownloadURL( + CFX_WideString::FromUTF8(urlString, urlString.GetLength())); + if (pFile) { + int32_t size = pFile->GetSize(); + uint8_t* pData = FX_Alloc(uint8_t, size); + pFile->ReadBlock(pData, size); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + CFX_ByteStringC(pData, size)); + FX_Free(pData); + pFile->Release(); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Get"); + } +} +void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if ((argc >= 2) && (argc <= 5)) { + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return; + } + IXFA_AppProvider* pAppProvider = + pDoc->GetParser()->GetNotify()->GetAppProvider(); + if (!pAppProvider) { + return; + } + CFX_ByteString bsURL; + CFX_ByteString bsData; + CFX_ByteString bsContentType; + CFX_ByteString bsEncode; + CFX_ByteString bsHeader; + FXJSE_HVALUE argOne; + FXJSE_HVALUE argTwo; + FXJSE_HVALUE argThree; + FXJSE_HVALUE argFour; + FXJSE_HVALUE argFive; + argOne = GetSimpleHValue(hThis, args, 0); + HValueToUTF8String(argOne, bsURL); + argTwo = GetSimpleHValue(hThis, args, 1); + HValueToUTF8String(argTwo, bsData); + if (argc > 2) { + argThree = GetSimpleHValue(hThis, args, 2); + HValueToUTF8String(argThree, bsContentType); + } + if (argc > 3) { + argFour = GetSimpleHValue(hThis, args, 3); + HValueToUTF8String(argFour, bsEncode); + } + if (argc > 4) { + argFive = GetSimpleHValue(hThis, args, 4); + HValueToUTF8String(argFive, bsHeader); + } + CFX_WideString decodedResponse; + FX_BOOL bFlags = pAppProvider->PostRequestURL( + CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), + CFX_WideString::FromUTF8(bsData, bsData.GetLength()), + CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()), + CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()), + CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()), + decodedResponse); + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + if (argc > 2) { + FXJSE_Value_Release(argThree); + } + if (argc > 3) { + FXJSE_Value_Release(argFour); + } + if (argc > 4) { + FXJSE_Value_Release(argFive); + } + if (bFlags) { + FXJSE_Value_SetUTF8String( + args.GetReturnValue(), + FX_UTF8Encode(decodedResponse, decodedResponse.GetLength())); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); + } + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Post"); + } +} +void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if ((argc == 2) || (argc == 3)) { + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return; + } + IXFA_AppProvider* pAppProvider = + pDoc->GetParser()->GetNotify()->GetAppProvider(); + if (!pAppProvider) { + return; + } + CFX_ByteString bsURL; + CFX_ByteString bsData; + CFX_ByteString bsEncode; + FXJSE_HVALUE argOne; + FXJSE_HVALUE argTwo; + FXJSE_HVALUE argThree; + argOne = GetSimpleHValue(hThis, args, 0); + HValueToUTF8String(argOne, bsURL); + argTwo = GetSimpleHValue(hThis, args, 1); + HValueToUTF8String(argTwo, bsData); + if (argc > 2) { + argThree = GetSimpleHValue(hThis, args, 2); + HValueToUTF8String(argThree, bsEncode); + } + FX_BOOL bFlags = pAppProvider->PutRequestURL( + CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), + CFX_WideString::FromUTF8(bsData, bsData.GetLength()), + CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())); + FXJSE_Value_Release(argOne); + FXJSE_Value_Release(argTwo); + if (argc > 2) { + FXJSE_Value_Release(argThree); + } + if (bFlags) { + FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); + } + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Put"); + } +} +void CXFA_FM2JSContext::assign_value_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + if (args.GetLength() == 2) { + FXJSE_HVALUE lValue = args.GetValue(0); + FXJSE_HVALUE rValue = GetSimpleHValue(hThis, args, 1); + FX_BOOL bSetStatus = TRUE; + if (FXJSE_Value_IsArray(lValue)) { + FXJSE_HVALUE leftLengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); + int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); + FXJSE_Value_Release(leftLengthValue); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t i = 2; i < iLeftLength; i++) { + FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); + bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); + if (!bSetStatus) { + pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); + break; + } + } + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + for (int32_t i = 2; i < iLeftLength; i++) { + FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); + FXJSE_Value_SetObjectProp(jsObjectValue, propertyStr, rValue); + } + } + FXJSE_Value_Release(jsObjectValue); + FXJSE_Value_Release(propertyValue); + } else if (FXJSE_Value_IsObject(lValue)) { + bSetStatus = SetObjectDefaultValue(lValue, rValue); + if (!bSetStatus) { + pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); + } + } + FXJSE_Value_Set(args.GetReturnValue(), rValue); + FXJSE_Value_Release(lValue); + FXJSE_Value_Release(rValue); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::logical_or_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_FLOAT first = HValueToFloat(hThis, argFirst); + FX_FLOAT second = HValueToFloat(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::logical_and_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_FLOAT first = HValueToFloat(hThis, argFirst); + FX_FLOAT second = HValueToFloat(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::equality_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + if (fm_ref_equal(hThis, args)) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 1); + } else { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger( + args.GetReturnValue(), + (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) + ? 1 + : 0); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + firstOutput.Equal(secondOutput) ? 1 : 0); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (first == second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::notequality_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + if (fm_ref_equal(hThis, args)) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } else { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger( + args.GetReturnValue(), + (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) + ? 0 + : 1); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + firstOutput.Equal(secondOutput) ? 0 : 1); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (first == second) ? 0 : 1); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +FX_BOOL CXFA_FM2JSContext::fm_ref_equal(FXJSE_HOBJECT hThis, + CFXJSE_Arguments& args) { + FX_BOOL bRet = FALSE; + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + FXJSE_HVALUE argFirst = args.GetValue(0); + FXJSE_HVALUE argSecond = args.GetValue(0); + if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { + FXJSE_HVALUE firstFlagValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE secondFlagValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); + FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); + if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && + (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { + FXJSE_HVALUE firstJSObject = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE secondJSObject = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); + FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); + if (!FXJSE_Value_IsNull(firstJSObject) && + !FXJSE_Value_IsNull(secondJSObject)) { + bRet = (FXJSE_Value_ToObject(firstJSObject, NULL) == + FXJSE_Value_ToObject(secondJSObject, NULL)); + } + FXJSE_Value_Release(firstJSObject); + FXJSE_Value_Release(secondJSObject); + } + FXJSE_Value_Release(firstFlagValue); + FXJSE_Value_Release(secondFlagValue); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + return bRet; +} +void CXFA_FM2JSContext::less_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (firstOutput.Compare(secondOutput) == -1) ? 1 : 0); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::lessequal_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger( + args.GetReturnValue(), + (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 + : 0); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (firstOutput.Compare(secondOutput) != 1) ? 1 : 0); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::greater_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger(args.GetReturnValue(), 0); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (firstOutput.Compare(secondOutput) == 1) ? 1 : 0); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::greaterequal_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetInteger( + args.GetReturnValue(), + (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 + : 0); + } else if (FXJSE_Value_IsUTF8String(argFirst) && + FXJSE_Value_IsUTF8String(argSecond)) { + CFX_ByteString firstOutput; + CFX_ByteString secondOutput; + FXJSE_Value_ToUTF8String(argFirst, firstOutput); + FXJSE_Value_ToUTF8String(argSecond, secondOutput); + FXJSE_Value_SetInteger(args.GetReturnValue(), + (firstOutput.Compare(secondOutput) != -1) ? 1 : 0); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::plus_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = args.GetValue(0); + FXJSE_HVALUE argSecond = args.GetValue(1); + if (HValueIsNull(hThis, argFirst) && HValueIsNull(hThis, argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::minus_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::multiple_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::divide_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + if (args.GetLength() == 2) { + FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); + FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); + if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argFirst); + FX_DOUBLE second = HValueToDouble(hThis, argSecond); + if (second == 0.0) { + pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); + } else { + FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); + } + } + FXJSE_Value_Release(argFirst); + FXJSE_Value_Release(argSecond); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::positive_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetDouble(args.GetReturnValue(), + 0.0 + HValueToDouble(hThis, argOne)); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::negative_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FXJSE_Value_SetDouble(args.GetReturnValue(), + 0.0 - HValueToDouble(hThis, argOne)); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::logical_not_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + if (FXJSE_Value_IsNull(argOne)) { + FXJSE_Value_SetNull(args.GetReturnValue()); + } else { + FX_DOUBLE first = HValueToDouble(hThis, argOne); + FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); + } + FXJSE_Value_Release(argOne); + } else { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + if ((argc == 4) || (argc == 5)) { + FX_BOOL bIsStar = TRUE; + FXJSE_HVALUE argAccessor = args.GetValue(0); + CFX_ByteString bsAccessorName = args.GetUTF8String(1); + CFX_ByteString szName = args.GetUTF8String(2); + int32_t iIndexFlags = args.GetInt32(3); + int32_t iIndexValue = 0; + FXJSE_HVALUE argIndex = NULL; + if (argc == 5) { + bIsStar = FALSE; + argIndex = args.GetValue(4); + iIndexValue = HValueToInteger(hThis, argIndex); + } + CFX_ByteString szSomExp; + GenerateSomExpression(szName, iIndexFlags, iIndexValue, bIsStar, szSomExp); + if (FXJSE_Value_IsArray(argAccessor)) { + FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); + int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); + FXJSE_Value_Release(hLengthValue); + int32_t iCounter = 0; + FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); + int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); + for (int32_t i = 0; i < (iLength - 2); i++) { + iSizes[i] = 0; + } + FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(hruntime); + FX_BOOL bAttribute = FALSE; + 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, + resoveNodeRS, TRUE, szName.IsEmpty()); + if (iRet > 0) { + ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, + hResolveValues[i - 2], iSizes[i - 2], bAttribute); + iCounter += iSizes[i - 2]; + } + } + FXJSE_Value_Release(hJSObjValue); + if (iCounter > 0) { + FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); + for (int32_t i = 0; i < (iCounter + 2); i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 1); + if (bAttribute) { + FXJSE_Value_SetUTF8String(rgValues[1], szName); + } else { + FXJSE_Value_SetNull(rgValues[1]); + } + int32_t iIndex = 2; + for (int32_t i = 0; i < iLength - 2; i++) { + for (int32_t j = 0; j < iSizes[i]; j++) { + FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); + iIndex++; + } + } + FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); + for (int32_t i = 0; i < (iCounter + 2); i++) { + FXJSE_Value_Release(rgValues[i]); + } + FX_Free(rgValues); + } else { + CFX_WideString wsPropertyName = + CFX_WideString::FromUTF8(szName, szName.GetLength()); + CFX_WideString wsSomExpression = + CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); + pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, + (const FX_WCHAR*)wsPropertyName, + (const FX_WCHAR*)wsSomExpression); + } + for (int32_t i = 0; i < iLength - 2; i++) { + for (int32_t j = 0; j < iSizes[i]; j++) { + FXJSE_Value_Release(hResolveValues[i][j]); + } + if (iSizes[i] > 0) { + FX_Free(hResolveValues[i]); + } + } + FX_Free(hResolveValues); + FX_Free(iSizes); + } else { + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = 0; + if (FXJSE_Value_IsObject(argAccessor) || + (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { + iRet = ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, TRUE, + szName.IsEmpty()); + } else if (!FXJSE_Value_IsObject(argAccessor) && + !bsAccessorName.IsEmpty()) { + FX_BOOL bGetObject = + GetObjectByName(hThis, argAccessor, bsAccessorName); + if (bGetObject) { + iRet = ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, + TRUE, szName.IsEmpty()); + } + } + if (iRet > 0) { + FXJSE_HVALUE* hResolveValues; + int32_t iSize = 0; + FX_BOOL bAttribute = FALSE; + ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, + iSize, bAttribute); + FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); + for (int32_t i = 0; i < (iSize + 2); i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 1); + if (bAttribute) { + FXJSE_Value_SetUTF8String(rgValues[1], szName); + } else { + FXJSE_Value_SetNull(rgValues[1]); + } + for (int32_t i = 0; i < iSize; i++) { + FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); + } + FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); + for (int32_t i = 0; i < (iSize + 2); i++) { + FXJSE_Value_Release(rgValues[i]); + } + FX_Free(rgValues); + for (int32_t i = 0; i < iSize; i++) { + FXJSE_Value_Release(hResolveValues[i]); + } + FX_Free(hResolveValues); + } else { + CFX_WideString wsPropertyName = + CFX_WideString::FromUTF8(szName, szName.GetLength()); + CFX_WideString wsSomExpression = + CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); + pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, + (const FX_WCHAR*)wsPropertyName, + (const FX_WCHAR*)wsSomExpression); + } + } + if (argc == 5) { + FXJSE_Value_Release(argIndex); + } + FXJSE_Value_Release(argAccessor); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + if ((argc == 4) || (argc == 5)) { + FX_BOOL bIsStar = TRUE; + FXJSE_HVALUE argAccessor = args.GetValue(0); + CFX_ByteString bsAccessorName = args.GetUTF8String(1); + CFX_ByteString szName = args.GetUTF8String(2); + int32_t iIndexFlags = args.GetInt32(3); + int32_t iIndexValue = 0; + FXJSE_HVALUE argIndex = NULL; + if (argc == 5) { + bIsStar = FALSE; + argIndex = args.GetValue(4); + iIndexValue = HValueToInteger(hThis, argIndex); + } + CFX_ByteString szSomExp; + GenerateSomExpression(szName, iIndexFlags, iIndexValue, bIsStar, szSomExp); + if (FXJSE_Value_IsArray(argAccessor)) { + FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); + int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); + int32_t iCounter = 0; + FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); + int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); + FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(hruntime); + FX_BOOL bAttribute = FALSE; + 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, resoveNodeRS, FALSE); + if (iRet > 0) { + ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, + hResolveValues[i - 2], iSizes[i - 2], bAttribute); + iCounter += iSizes[i - 2]; + } + } + FXJSE_Value_Release(hJSObjValue); + if (iCounter > 0) { + FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); + for (int32_t i = 0; i < (iCounter + 2); i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 1); + if (bAttribute) { + FXJSE_Value_SetUTF8String(rgValues[1], szName); + } else { + FXJSE_Value_SetNull(rgValues[1]); + } + int32_t iIndex = 2; + for (int32_t i = 0; i < iLength - 2; i++) { + for (int32_t j = 0; j < iSizes[i]; j++) { + FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); + iIndex++; + } + } + FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); + for (int32_t i = 0; i < (iCounter + 2); i++) { + FXJSE_Value_Release(rgValues[i]); + } + FX_Free(rgValues); + } else { + CFX_WideString wsPropertyName = + CFX_WideString::FromUTF8(szName, szName.GetLength()); + CFX_WideString wsSomExpression = + CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); + pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, + (const FX_WCHAR*)wsPropertyName, + (const FX_WCHAR*)wsSomExpression); + } + for (int32_t i = 0; i < iLength - 2; i++) { + for (int32_t j = 0; j < iSizes[i]; j++) { + FXJSE_Value_Release(hResolveValues[i][j]); + } + FX_Free(hResolveValues[i]); + } + FX_Free(hResolveValues); + FX_Free(iSizes); + FXJSE_Value_Release(hLengthValue); + } else { + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = 0; + if (FXJSE_Value_IsObject(argAccessor) || + (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { + iRet = + ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, FALSE); + } else if (!FXJSE_Value_IsObject(argAccessor) && + !bsAccessorName.IsEmpty()) { + FX_BOOL bGetObject = + GetObjectByName(hThis, argAccessor, bsAccessorName); + if (bGetObject) { + iRet = + ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, FALSE); + } + } + if (iRet > 0) { + FXJSE_HVALUE* hResolveValues; + int32_t iSize = 0; + FX_BOOL bAttribute = FALSE; + ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, + iSize, bAttribute); + FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); + for (int32_t i = 0; i < (iSize + 2); i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 1); + if (bAttribute) { + FXJSE_Value_SetUTF8String(rgValues[1], szName); + } else { + FXJSE_Value_SetNull(rgValues[1]); + } + for (int32_t i = 0; i < iSize; i++) { + FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); + } + FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); + for (int32_t i = 0; i < (iSize + 2); i++) { + FXJSE_Value_Release(rgValues[i]); + } + FX_Free(rgValues); + for (int32_t i = 0; i < iSize; i++) { + FXJSE_Value_Release(hResolveValues[i]); + } + FX_Free(hResolveValues); + } else { + CFX_WideString wsPropertyName = + CFX_WideString::FromUTF8(szName, szName.GetLength()); + CFX_WideString wsSomExpression = + CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); + pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, + (const FX_WCHAR*)wsPropertyName, + (const FX_WCHAR*)wsSomExpression); + } + } + if (argc == 5) { + FXJSE_Value_Release(argIndex); + } + FXJSE_Value_Release(argAccessor); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + int32_t argc = args.GetLength(); + if (argc == 1) { + FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); + CFX_ByteString argString; + HValueToUTF8String(argOne, argString); + if (argString.IsEmpty()) { + pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } else { + CFX_WideString scriptString = + CFX_WideString::FromUTF8(argString, argString.GetLength()); + CFX_WideTextBuf wsJavaScriptBuf; + CFX_WideString wsError; + XFA_FM2JS_Translate(scriptString, wsJavaScriptBuf, wsError); + if (wsError.IsEmpty()) { + CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); + FXJSE_Value_SetUTF8String( + args.GetReturnValue(), + FX_UTF8Encode(javaScript, javaScript.GetLength())); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"Eval"); + } +} +void CXFA_FM2JSContext::is_fm_object(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); + FXJSE_Value_Release(argOne); + } else { + FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); + } +} +void CXFA_FM2JSContext::is_fm_array(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); + FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); + FXJSE_Value_Release(argOne); + } else { + FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); + } +} +void CXFA_FM2JSContext::get_fm_value(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t iLength = args.GetLength(); + if (iLength == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (FXJSE_Value_IsArray(argOne)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, + args.GetReturnValue()); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsobjectValue); + } else if (FXJSE_Value_IsObject(argOne)) { + GetObjectDefaultValue(argOne, args.GetReturnValue()); + } else { + FXJSE_Value_Set(args.GetReturnValue(), argOne); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis, nullptr)); + int32_t argc = args.GetLength(); + if (argc == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (FXJSE_Value_IsArray(argOne)) { +#ifndef NDEBUG + 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); + FXJSE_Value_Release(lengthValue); +#endif + FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); + } else { + FXJSE_Value_Set(args.GetReturnValue(), argOne); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t argc = args.GetLength(); + if (argc == 1) { + FXJSE_HVALUE argOne = args.GetValue(0); + if (FXJSE_Value_IsArray(argOne)) { +#ifndef NDEBUG + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); + FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); + FXJSE_Value_Release(lengthValue); +#endif + FXJSE_HVALUE flagsValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); + int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); + FXJSE_Value_Release(flagsValue); + if (iFlags == 4) { + FXJSE_HVALUE rgValues[3]; + for (int32_t i = 0; i < 3; i++) { + rgValues[i] = FXJSE_Value_Create(hruntime); + } + FXJSE_Value_SetInteger(rgValues[0], 3); + FXJSE_Value_SetNull(rgValues[1]); + FXJSE_Value_SetNull(rgValues[2]); + FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); + for (int32_t i = 0; i < 3; i++) { + FXJSE_Value_Release(rgValues[i]); + } + } else if (iFlags == 3) { + FXJSE_HVALUE objectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); + if (!FXJSE_Value_IsNull(objectValue)) { + FXJSE_Value_Set(args.GetReturnValue(), argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } + FXJSE_Value_Release(objectValue); + } else { + FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); + FXJSE_Value_Set(args.GetReturnValue(), simpleValue); + FXJSE_Value_Release(simpleValue); + } + } else { + FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); + FXJSE_Value_Set(args.GetReturnValue(), simpleValue); + FXJSE_Value_Release(simpleValue); + } + FXJSE_Value_Release(argOne); + } else { + pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); + } +} +void CXFA_FM2JSContext::concat_fm_object(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + uint32_t iLength = 0; + int32_t argCount = args.GetLength(); + FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argCount); + for (int32_t i = 0; i < argCount; i++) { + argValues[i] = args.GetValue(i); + if (FXJSE_Value_IsArray(argValues[i])) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); + int32_t length = FXJSE_Value_ToInteger(lengthValue); + iLength = iLength + ((length > 2) ? (length - 2) : 0); + FXJSE_Value_Release(lengthValue); + } + iLength += 1; + } + FXJSE_HVALUE* returnValues = FX_Alloc(FXJSE_HVALUE, iLength); + for (int32_t i = 0; i < (int32_t)iLength; i++) { + returnValues[i] = FXJSE_Value_Create(hruntime); + } + int32_t index = 0; + for (int32_t i = 0; i < argCount; i++) { + if (FXJSE_Value_IsArray(argValues[i])) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); + int32_t length = FXJSE_Value_ToInteger(lengthValue); + for (int32_t j = 2; j < length; j++) { + FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); + index++; + } + FXJSE_Value_Release(lengthValue); + } + FXJSE_Value_Set(returnValues[index], argValues[i]); + index++; + } + FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); + for (int32_t i = 0; i < argCount; i++) { + FXJSE_Value_Release(argValues[i]); + } + FX_Free(argValues); + for (int32_t i = 0; i < (int32_t)iLength; i++) { + FXJSE_Value_Release(returnValues[i]); + } + FX_Free(returnValues); +} +FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis, + CFXJSE_Arguments& args, + uint32_t index) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + FXSYS_assert(index < (uint32_t)args.GetLength()); + FXJSE_HVALUE argIndex = args.GetValue(index); + if (FXJSE_Value_IsArray(argIndex)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + FXJSE_HVALUE simpleValue = FXJSE_Value_Create(hruntime); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, simpleValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, simpleValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsobjectValue); + } else { + FXJSE_Value_SetUndefined(simpleValue); + } + FXJSE_Value_Release(argIndex); + return simpleValue; + } else if (FXJSE_Value_IsObject(argIndex)) { + FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(argIndex, defaultValue); + FXJSE_Value_Release(argIndex); + return defaultValue; + } else { + return argIndex; + } +} +FX_BOOL CXFA_FM2JSContext::HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + FX_BOOL isNull = FALSE; + if (FXJSE_Value_IsNull(arg)) { + isNull = TRUE; + } else if (FXJSE_Value_IsArray(arg)) { + int32_t iLength = hvalue_get_array_length(hThis, arg); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(jsObjectValue, defaultValue); + if (FXJSE_Value_IsNull(defaultValue)) { + isNull = TRUE; + } + FXJSE_Value_Release(defaultValue); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, newPropertyValue); + if (FXJSE_Value_IsNull(newPropertyValue)) { + isNull = TRUE; + } + FXJSE_Value_Release(newPropertyValue); + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } else { + isNull = TRUE; + } + } else if (FXJSE_Value_IsObject(arg)) { + FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(arg, defaultValue); + if (FXJSE_Value_IsNull(defaultValue)) { + isNull = TRUE; + } + FXJSE_Value_Release(defaultValue); + } + return isNull; +} +int32_t CXFA_FM2JSContext::hvalue_get_array_length(FXJSE_HOBJECT hThis, + FXJSE_HVALUE arg) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t iLength = 0; + if (FXJSE_Value_IsArray(arg)) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(arg, "length", lengthValue); + iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + } + return iLength; +} +FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, + FXJSE_HVALUE firstValue, + FXJSE_HVALUE secondValue) { + FX_BOOL bReturn = FALSE; + if (FXJSE_Value_IsUTF8String(firstValue)) { + CFX_ByteString firstString, secondString; + HValueToUTF8String(firstValue, firstString); + HValueToUTF8String(secondValue, secondString); + bReturn = firstString.Equal(secondString); + } else if (FXJSE_Value_IsNumber(firstValue)) { + FX_FLOAT first = HValueToFloat(hThis, firstValue); + FX_FLOAT second = HValueToFloat(hThis, secondValue); + bReturn = (first == second); + } else if (FXJSE_Value_IsBoolean(firstValue)) { + bReturn = (FXJSE_Value_ToBoolean(firstValue) == + FXJSE_Value_ToBoolean(secondValue)); + } else if (FXJSE_Value_IsNull(firstValue) && + FXJSE_Value_IsNull(secondValue)) { + bReturn = TRUE; + } + return bReturn; +} +void CXFA_FM2JSContext::unfoldArgs(FXJSE_HOBJECT hThis, + CFXJSE_Arguments& args, + FXJSE_HVALUE*& resultValues, + int32_t& iCount, + int32_t iStart) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + iCount = 0; + int32_t argc = args.GetLength(); + FXJSE_HVALUE* argsValue = FX_Alloc(FXJSE_HVALUE, argc); + for (int32_t i = iStart; i < argc; i++) { + argsValue[i] = args.GetValue(i); + if (FXJSE_Value_IsArray(argsValue[i])) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + iCount += ((iLength > 2) ? (iLength - 2) : 0); + } else { + iCount += 1; + } + } + resultValues = FX_Alloc(FXJSE_HVALUE, iCount); + for (int32_t i = 0; i < iCount; i++) { + resultValues[i] = FXJSE_Value_Create(hruntime); + } + int32_t index = 0; + for (int32_t i = iStart; i < argc; i++) { + if (FXJSE_Value_IsArray(argsValue[i])) { + FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); + int32_t iLength = FXJSE_Value_ToInteger(lengthValue); + FXJSE_Value_Release(lengthValue); + if (iLength > 2) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); + if (FXJSE_Value_IsNull(propertyValue)) { + for (int32_t j = 2; j < iLength; j++) { + FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); + GetObjectDefaultValue(jsObjectValue, resultValues[index]); + index++; + } + } else { + CFX_ByteString propertyString; + 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, + resultValues[index]); + index++; + } + } + FXJSE_Value_Release(propertyValue); + FXJSE_Value_Release(jsObjectValue); + } + } else if (FXJSE_Value_IsObject(argsValue[i])) { + GetObjectDefaultValue(argsValue[i], resultValues[index]); + index++; + } else { + FXJSE_Value_Set(resultValues[index], argsValue[i]); + index++; + } + } + for (int32_t i = iStart; i < argc; i++) { + FXJSE_Value_Release(argsValue[i]); + } + FX_Free(argsValue); +} +void CXFA_FM2JSContext::GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, + FXJSE_HVALUE hDefaultValue) { + CXFA_Node* pNode = + ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); + if (pNode) { + pNode->Script_Som_DefaultValue(hDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); + } else { + FXJSE_Value_SetNull(hDefaultValue); + } +} +FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, + FXJSE_HVALUE hNewValue) { + CXFA_Node* pNode = + ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); + if (pNode) { + pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); + return TRUE; + } + return FALSE; +} +void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, + int32_t iIndexFlags, + int32_t iIndexValue, + FX_BOOL bIsStar, + CFX_ByteString& szSomExp) { + if (bIsStar) { + szSomExp = szName + "[*]"; + return; + } + if (iIndexFlags == 0) { + szSomExp = szName; + return; + } + if (iIndexFlags == 1 || iIndexValue == 0) { + szSomExp = szName + "[" + + CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + + "]"; + } else if (iIndexFlags == 2) { + szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); + iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; + szSomExp += CFX_ByteString::FormatInteger(iIndexValue); + szSomExp += "]"; + } else { + szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); + iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; + szSomExp += CFX_ByteString::FormatInteger(iIndexValue); + szSomExp += "]"; + } +} +FX_BOOL CXFA_FM2JSContext::GetObjectByName( + FXJSE_HOBJECT hThis, + FXJSE_HVALUE accessorValue, + const CFX_ByteStringC& szAccessorName) { + FX_BOOL bFlags = FALSE; + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return bFlags; + } + IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); + XFA_RESOLVENODE_RS resoveNodeRS; + FX_DWORD dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; + int32_t iRet = pScriptContext->ResolveObjects( + pScriptContext->GetThisObject(), + CFX_WideString::FromUTF8(szAccessorName.GetCStr(), + szAccessorName.GetLength()), + resoveNodeRS, dwFlags); + if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( + resoveNodeRS.nodes.GetAt(0))); + bFlags = TRUE; + } + return bFlags; +} +int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, + FXJSE_HVALUE hRefValue, + const CFX_ByteStringC& bsSomExp, + XFA_RESOLVENODE_RS& resoveNodeRS, + FX_BOOL bdotAccessor, + FX_BOOL bHasNoResolveName) { + CFX_WideString wsSomExpression = + CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); + int32_t iRet = -1; + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + CXFA_Document* pDoc = pContext->GetDocument(); + if (!pDoc) { + return iRet; + } + IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); + CXFA_Object* pNode = NULL; + FX_DWORD dFlags = 0UL; + if (bdotAccessor) { + if (FXJSE_Value_IsNull(hRefValue)) { + pNode = pScriptContext->GetThisObject(); + dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; + } else { + pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); + FXSYS_assert(pNode); + if (bHasNoResolveName) { + CFX_WideString wsName; + if (CXFA_Node* pXFANode = pNode->AsNode()) { + pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); + } + if (wsName.IsEmpty()) { + CFX_WideStringC className; + pNode->GetClassName(className); + wsName = FX_WSTRC(L"#") + className; + } + wsSomExpression = wsName + wsSomExpression; + dFlags = XFA_RESOLVENODE_Siblings; + } else { + dFlags = (bsSomExp == "*") + ? (XFA_RESOLVENODE_Children) + : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | + XFA_RESOLVENODE_Properties); + } + } + } else { + pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); + dFlags = XFA_RESOLVENODE_AnyChild; + } + iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression, resoveNodeRS, + dFlags); + return iRet; +} +void CXFA_FM2JSContext::ParseResolveResult( + FXJSE_HOBJECT hThis, + const XFA_RESOLVENODE_RS& resoveNodeRS, + FXJSE_HVALUE hParentValue, + FXJSE_HVALUE*& resultValues, + int32_t& iSize, + FX_BOOL& bAttribute) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hRuntime = pContext->GetScriptRuntime(); + iSize = 0; + resultValues = NULL; + if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + bAttribute = FALSE; + iSize = resoveNodeRS.nodes.GetSize(); + resultValues = FX_Alloc(FXJSE_HVALUE, iSize); + for (int32_t i = 0; i < iSize; i++) { + resultValues[i] = FXJSE_Value_Create(hRuntime); + FXJSE_Value_Set( + resultValues[i], + pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( + resoveNodeRS.nodes.GetAt(i))); + } + } else { + CXFA_HVALUEArray objectProperties(hRuntime); + int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); + bAttribute = (iRet == 0); + if (bAttribute) { + if (FXJSE_Value_IsObject(hParentValue)) { + iSize = 1; + resultValues = FX_Alloc(FXJSE_HVALUE, 1); + resultValues[0] = FXJSE_Value_Create(hRuntime); + FXJSE_Value_Set(resultValues[0], hParentValue); + } + } else { + iSize = iRet; + resultValues = FX_Alloc(FXJSE_HVALUE, iSize); + for (int32_t i = 0; i < iSize; i++) { + resultValues[i] = FXJSE_Value_Create(hRuntime); + FXJSE_Value_Set(resultValues[i], objectProperties[i]); + } + } + } +} +int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis, + FXJSE_HVALUE hValue) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + int32_t iValue = 0; + if (FXJSE_Value_IsArray(hValue)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(hValue, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(hValue, 2, jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, newProperty); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); + } + iValue = HValueToInteger(hThis, newProperty); + FXJSE_Value_Release(newProperty); + FXJSE_Value_Release(jsobjectValue); + FXJSE_Value_Release(propertyValue); + return iValue; + } else if (FXJSE_Value_IsObject(hValue)) { + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(hValue, newProperty); + iValue = HValueToInteger(hThis, newProperty); + FXJSE_Value_Release(newProperty); + return iValue; + } else if (FXJSE_Value_IsUTF8String(hValue)) { + CFX_ByteString szValue; + FXJSE_Value_ToUTF8String(hValue, szValue); + iValue = FXSYS_atoi(szValue); + } else { + iValue = FXJSE_Value_ToInteger(hValue); + } + return iValue; +} +FX_DOUBLE CXFA_FM2JSContext::StringToDouble( + const CFX_ByteStringC& szStringVal) { + return XFA_ByteStringToDouble(szStringVal); +} +FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis, + FXJSE_HVALUE arg) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + FX_FLOAT fRet = 0.0f; + if (FXJSE_Value_IsArray(arg)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, newProperty); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); + } + fRet = HValueToFloat(hThis, newProperty); + FXJSE_Value_Release(newProperty); + FXJSE_Value_Release(jsobjectValue); + FXJSE_Value_Release(propertyValue); + } else if (FXJSE_Value_IsObject(arg)) { + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(arg, newProperty); + fRet = HValueToFloat(hThis, newProperty); + FXJSE_Value_Release(newProperty); + } else if (FXJSE_Value_IsUTF8String(arg)) { + CFX_ByteString bsOutput; + FXJSE_Value_ToUTF8String(arg, bsOutput); + fRet = (FX_FLOAT)StringToDouble(bsOutput); + } else if (FXJSE_Value_IsUndefined(arg)) { + fRet = 0; + } else { + fRet = FXJSE_Value_ToFloat(arg); + } + return fRet; +} +FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis, + FXJSE_HVALUE arg) { + CXFA_FM2JSContext* pContext = + (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); + FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); + FX_DOUBLE dRet = 0; + if (FXJSE_Value_IsArray(arg)) { + FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); + FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); + if (FXJSE_Value_IsNull(propertyValue)) { + GetObjectDefaultValue(jsobjectValue, newProperty); + } else { + CFX_ByteString propertyStr; + FXJSE_Value_ToUTF8String(propertyValue, propertyStr); + FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); + } + dRet = HValueToDouble(hThis, newProperty); + FXJSE_Value_Release(newProperty); + FXJSE_Value_Release(jsobjectValue); + FXJSE_Value_Release(propertyValue); + } else if (FXJSE_Value_IsObject(arg)) { + FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); + GetObjectDefaultValue(arg, newProperty); + dRet = HValueToDouble(hThis, newProperty); + FXJSE_Value_Release(newProperty); + } else if (FXJSE_Value_IsUTF8String(arg)) { + CFX_ByteString bsOutput; + FXJSE_Value_ToUTF8String(arg, bsOutput); + dRet = StringToDouble(bsOutput); + } else if (FXJSE_Value_IsUndefined(arg)) { + dRet = 0; + } else { + dRet = FXJSE_Value_ToDouble(arg); + } + return dRet; +} +void CXFA_FM2JSContext::HValueToUTF8String(FXJSE_HVALUE arg, + CFX_ByteString& szOutputString) { + if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { + szOutputString = ""; + } else if (FXJSE_Value_IsBoolean(arg)) { + szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; + } else { + szOutputString = ""; + FXJSE_Value_ToUTF8String(arg, szOutputString); + } +} +static FXJSE_FUNCTION formcalc_fm2js_functions[] = { + {"Abs", CXFA_FM2JSContext::Abs}, + {"Avg", CXFA_FM2JSContext::Avg}, + {"Ceil", CXFA_FM2JSContext::Ceil}, + {"Count", CXFA_FM2JSContext::Count}, + {"Floor", CXFA_FM2JSContext::Floor}, + {"Max", CXFA_FM2JSContext::Max}, + {"Min", CXFA_FM2JSContext::Min}, + {"Mod", CXFA_FM2JSContext::Mod}, + {"Round", CXFA_FM2JSContext::Round}, + {"Sum", CXFA_FM2JSContext::Sum}, + {"Date", CXFA_FM2JSContext::Date}, + {"Date2Num", CXFA_FM2JSContext::Date2Num}, + {"DateFmt", CXFA_FM2JSContext::DateFmt}, + {"IsoDate2Num", CXFA_FM2JSContext::IsoDate2Num}, + {"IsoTime2Num", CXFA_FM2JSContext::IsoTime2Num}, + {"LocalDateFmt", CXFA_FM2JSContext::LocalDateFmt}, + {"LocalTimeFmt", CXFA_FM2JSContext::LocalTimeFmt}, + {"Num2Date", CXFA_FM2JSContext::Num2Date}, + {"Num2GMTime", CXFA_FM2JSContext::Num2GMTime}, + {"Num2Time", CXFA_FM2JSContext::Num2Time}, + {"Time", CXFA_FM2JSContext::Time}, + {"Time2Num", CXFA_FM2JSContext::Time2Num}, + {"TimeFmt", CXFA_FM2JSContext::TimeFmt}, + {"Apr", CXFA_FM2JSContext::Apr}, + {"Cterm", CXFA_FM2JSContext::CTerm}, + {"FV", CXFA_FM2JSContext::FV}, + {"Ipmt", CXFA_FM2JSContext::IPmt}, + {"NPV", CXFA_FM2JSContext::NPV}, + {"Pmt", CXFA_FM2JSContext::Pmt}, + {"PPmt", CXFA_FM2JSContext::PPmt}, + {"PV", CXFA_FM2JSContext::PV}, + {"Rate", CXFA_FM2JSContext::Rate}, + {"Term", CXFA_FM2JSContext::Term}, + {"Choose", CXFA_FM2JSContext::Choose}, + {"Exists", CXFA_FM2JSContext::Exists}, + {"HasValue", CXFA_FM2JSContext::HasValue}, + {"Oneof", CXFA_FM2JSContext::Oneof}, + {"Within", CXFA_FM2JSContext::Within}, + {"If", CXFA_FM2JSContext::If}, + {"Eval", CXFA_FM2JSContext::Eval}, + {"Translate", CXFA_FM2JSContext::eval_translation}, + {"Ref", CXFA_FM2JSContext::Ref}, + {"UnitType", CXFA_FM2JSContext::UnitType}, + {"UnitValue", CXFA_FM2JSContext::UnitValue}, + {"At", CXFA_FM2JSContext::At}, + {"Concat", CXFA_FM2JSContext::Concat}, + {"Decode", CXFA_FM2JSContext::Decode}, + {"Encode", CXFA_FM2JSContext::Encode}, + {"Format", CXFA_FM2JSContext::Format}, + {"Left", CXFA_FM2JSContext::Left}, + {"Len", CXFA_FM2JSContext::Len}, + {"Lower", CXFA_FM2JSContext::Lower}, + {"Ltrim", CXFA_FM2JSContext::Ltrim}, + {"Parse", CXFA_FM2JSContext::Parse}, + {"Replace", CXFA_FM2JSContext::Replace}, + {"Right", CXFA_FM2JSContext::Right}, + {"Rtrim", CXFA_FM2JSContext::Rtrim}, + {"Space", CXFA_FM2JSContext::Space}, + {"Str", CXFA_FM2JSContext::Str}, + {"Stuff", CXFA_FM2JSContext::Stuff}, + {"Substr", CXFA_FM2JSContext::Substr}, + {"Uuid", CXFA_FM2JSContext::Uuid}, + {"Upper", CXFA_FM2JSContext::Upper}, + {"WordNum", CXFA_FM2JSContext::WordNum}, + {"Get", CXFA_FM2JSContext::Get}, + {"Post", CXFA_FM2JSContext::Post}, + {"Put", CXFA_FM2JSContext::Put}, + {"positive_operator", CXFA_FM2JSContext::positive_operator}, + {"negative_operator", CXFA_FM2JSContext::negative_operator}, + {"logical_or_operator", CXFA_FM2JSContext::logical_or_operator}, + {"logical_and_operator", CXFA_FM2JSContext::logical_and_operator}, + {"logical_not_operator", CXFA_FM2JSContext::logical_not_operator}, + {"equality_operator", CXFA_FM2JSContext::equality_operator}, + {"notequality_operator", CXFA_FM2JSContext::notequality_operator}, + {"less_operator", CXFA_FM2JSContext::less_operator}, + {"lessequal_operator", CXFA_FM2JSContext::lessequal_operator}, + {"greater_operator", CXFA_FM2JSContext::greater_operator}, + {"greaterequal_operator", CXFA_FM2JSContext::greaterequal_operator}, + {"plus_operator", CXFA_FM2JSContext::plus_operator}, + {"minus_operator", CXFA_FM2JSContext::minus_operator}, + {"multiple_operator", CXFA_FM2JSContext::multiple_operator}, + {"divide_operator", CXFA_FM2JSContext::divide_operator}, + {"assign_value_operator", CXFA_FM2JSContext::assign_value_operator}, + {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, + {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, + {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, + {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, + {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, + {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, + {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, + {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, +}; +CXFA_FM2JSContext::CXFA_FM2JSContext() + : m_hFMClass(nullptr), m_pDocument(nullptr) { + FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); +} +CXFA_FM2JSContext::~CXFA_FM2JSContext() { + m_pDocument = NULL; + if (m_hValue) { + FXJSE_Value_Release(m_hValue); + m_hValue = NULL; + } + m_hScriptRuntime = NULL; +} +CXFA_FM2JSContext* CXFA_FM2JSContext::Create() { + return new CXFA_FM2JSContext; +} +void CXFA_FM2JSContext::Initialize(FXJSE_HRUNTIME hScriptRuntime, + FXJSE_HCONTEXT hScriptContext, + CXFA_Document* pDoc) { + m_pDocument = pDoc; + m_hScriptRuntime = hScriptRuntime; + m_fmClass.name = "XFA_FM2JS_FormCalcClass"; + m_fmClass.constructor = NULL; + m_fmClass.properties = NULL; + m_fmClass.methods = formcalc_fm2js_functions; + m_fmClass.propNum = 0; + m_fmClass.methNum = + sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); + m_hFMClass = FXJSE_DefineClass(hScriptContext, &m_fmClass); + m_hValue = FXJSE_Value_Create(hScriptRuntime); + FXJSE_Value_SetNull(m_hValue); + FXJSE_Value_SetObject(m_hValue, this, m_hFMClass); +} +void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { + FXJSE_Value_Set(hValue, m_hValue); +} +void CXFA_FM2JSContext::Release() { + delete this; +} +void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { + IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); + FXSYS_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); + va_end(arg_ptr); + FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); +} diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h new file mode 100644 index 0000000000..c80d9881a0 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h @@ -0,0 +1,453 @@ +// 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_FM2JS_XFA_FM2JSCONTEXT_H_ +#define XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ + +#include "xfa/fxfa/parser/xfa_script.h" + +class CXFA_FM2JSContext { + public: + static void Abs(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Avg(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Ceil(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Count(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Floor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Max(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Min(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Mod(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Round(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Sum(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Date(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Date2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void DateFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void IsoDate2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void IsoTime2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void LocalDateFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void LocalTimeFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Num2Date(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Num2GMTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Num2Time(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Time(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Time2Num(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void TimeFmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + + static FX_BOOL IsIsoDateFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iStyle, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay); + static FX_BOOL IsIsoTimeFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iHour, + int32_t& iMinute, + int32_t& iSecond, + int32_t& iMilliSecond, + int32_t& iZoneHour, + int32_t& iZoneMinute); + static FX_BOOL IsIsoDateTimeFormat(const FX_CHAR* pData, + int32_t iLength, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay, + int32_t& iHour, + int32_t& iMinute, + int32_t& iSecond, + int32_t& iMillionSecond, + int32_t& iZoneHour, + int32_t& iZoneMinute); + static FX_BOOL Local2IsoDate(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szDate, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strIsoDate); + static FX_BOOL Local2IsoTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strIsoTime); + static FX_BOOL IsoDate2Local(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szDate, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strLocalDate); + static FX_BOOL IsoTime2Local(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strLocalTime); + static FX_BOOL GetGMTTime(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + CFX_ByteString& strGMTTime); + static int32_t DateString2Num(const CFX_ByteStringC& szDateString); + static void GetLocalDateFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat, + FX_BOOL bStandard); + static void GetLocalTimeFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat, + FX_BOOL bStandard); + static void GetStandardDateFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat); + static void GetStandardTimeFormat(FXJSE_HOBJECT hThis, + int32_t iStyle, + const CFX_ByteStringC& szLocalStr, + CFX_ByteString& strFormat); + + static void Num2AllTime(FXJSE_HOBJECT hThis, + int32_t iTime, + const CFX_ByteStringC& szFormat, + const CFX_ByteStringC& szLocale, + FX_BOOL bGM, + CFX_ByteString& strTime); + static void GetLocalTimeZone(int32_t& iHour, int32_t& iMin, int32_t& iSec); + + static void Apr(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void CTerm(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void FV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void IPmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void NPV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Pmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void PPmt(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void PV(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Rate(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Term(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Choose(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Exists(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void HasValue(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Oneof(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Within(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void If(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Eval(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Ref(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void UnitType(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void UnitValue(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + + static void At(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Concat(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Decode(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void DecodeURL(const CFX_ByteStringC& szURLString, + CFX_ByteTextBuf& szResultBuf); + static void DecodeHTML(const CFX_ByteStringC& szHTMLString, + CFX_ByteTextBuf& szResultBuf); + static void DecodeXML(const CFX_ByteStringC& szXMLString, + CFX_ByteTextBuf& szResultBuf); + static void Encode(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void EncodeURL(const CFX_ByteStringC& szURLString, + CFX_ByteTextBuf& szResultBuf); + static void EncodeHTML(const CFX_ByteStringC& szHTMLString, + CFX_ByteTextBuf& szResultBuf); + static void EncodeXML(const CFX_ByteStringC& szXMLString, + CFX_ByteTextBuf& szResultBuf); + static FX_BOOL HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode); + static FX_BOOL HTMLCode2STR(uint32_t iCode, CFX_WideString& wsHTMLReserve); + static void Format(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Left(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Len(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Lower(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Ltrim(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Parse(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Replace(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Right(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Rtrim(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Space(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Str(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Stuff(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Substr(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Uuid(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Upper(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void WordNum(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void TrillionUS(const CFX_ByteStringC& szData, + CFX_ByteTextBuf& strBuf); + static void WordUS(const CFX_ByteStringC& szData, + int32_t iStyle, + CFX_ByteTextBuf& strBuf); + + static void Get(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Post(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void Put(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void assign_value_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void logical_or_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void logical_and_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void equality_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void notequality_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static FX_BOOL fm_ref_equal(FXJSE_HOBJECT hThis, CFXJSE_Arguments& args); + static void less_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void lessequal_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void greater_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void greaterequal_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void plus_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void minus_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void multiple_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void divide_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void positive_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void negative_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void logical_not_operator(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void dot_accessor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void dotdot_accessor(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void eval_translation(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void is_fm_object(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void is_fm_array(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void get_fm_value(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void get_fm_jsobj(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void fm_var_filter(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static void concat_fm_object(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + + static int32_t hvalue_get_array_length(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg); + static FX_BOOL simpleValueCompare(FXJSE_HOBJECT hThis, + FXJSE_HVALUE firstValue, + FXJSE_HVALUE secondValue); + static void unfoldArgs(FXJSE_HOBJECT hThis, + CFXJSE_Arguments& args, + FXJSE_HVALUE*& resultValues, + int32_t& iCount, + int32_t iStart = 0); + static void GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, + FXJSE_HVALUE hDefaultValue); + static FX_BOOL SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, + FXJSE_HVALUE hNewValue); + static void GenerateSomExpression(const CFX_ByteStringC& szName, + int32_t iIndexFlags, + int32_t iIndexValue, + FX_BOOL bIsStar, + CFX_ByteString& szSomExp); + static FX_BOOL GetObjectByName(FXJSE_HOBJECT hThis, + FXJSE_HVALUE accessorValue, + const CFX_ByteStringC& szAccessorName); + static int32_t ResolveObjects(FXJSE_HOBJECT hThis, + FXJSE_HVALUE hParentValue, + const CFX_ByteStringC& bsSomExp, + XFA_RESOLVENODE_RS& resoveNodeRS, + FX_BOOL bdotAccessor = TRUE, + FX_BOOL bHasNoResolveName = FALSE); + static void ParseResolveResult(FXJSE_HOBJECT hThis, + const XFA_RESOLVENODE_RS& resoveNodeRS, + FXJSE_HVALUE hParentValue, + FXJSE_HVALUE*& resultValues, + int32_t& iSize, + FX_BOOL& bAttribute); + + static FXJSE_HVALUE GetSimpleHValue(FXJSE_HOBJECT hThis, + CFXJSE_Arguments& args, + uint32_t index); + static FX_BOOL HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); + static int32_t HValueToInteger(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); + static FX_DOUBLE StringToDouble(const CFX_ByteStringC& szStringVal); + static FX_FLOAT HValueToFloat(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); + static FX_DOUBLE HValueToDouble(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); + static void HValueToUTF8String(FXJSE_HVALUE hValue, + CFX_ByteString& outputValue); + CXFA_FM2JSContext(); + ~CXFA_FM2JSContext(); + static CXFA_FM2JSContext* Create(); + void Initialize(FXJSE_HRUNTIME hScriptRuntime, + FXJSE_HCONTEXT hScriptContext, + CXFA_Document* pDoc); + void GlobalPropertyGetter(FXJSE_HVALUE hValue); + void Release(); + FXJSE_HRUNTIME GetScriptRuntime() const { return m_hScriptRuntime; } + CXFA_Document* GetDocument() const { return m_pDocument; } + void ThrowScriptErrorMessage(int32_t iStringID, ...); + + private: + FXJSE_HRUNTIME m_hScriptRuntime; + FXJSE_CLASS m_fmClass; + FXJSE_HCLASS m_hFMClass; + FXJSE_HVALUE m_hValue; + CXFA_Document* m_pDocument; +}; + +#endif // XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp new file mode 100644 index 0000000000..6e30d95f1a --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp @@ -0,0 +1,1051 @@ +// 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/fxfa/fm2js/xfa_fmparse.h" + +#include <memory> + +CXFA_FMParse::CXFA_FMParse() : m_pToken(nullptr), m_pErrorInfo(0) {} + +int32_t CXFA_FMParse::Init(const CFX_WideStringC& wsFormcalc, + CXFA_FMErrorInfo* pErrorInfo) { + m_pErrorInfo = pErrorInfo; + m_lexer.reset(new CXFA_FMLexer(wsFormcalc, m_pErrorInfo)); + return 0; +} + +void CXFA_FMParse::NextToken() { + m_pToken = m_lexer->NextToken(); + while (m_pToken->m_type == TOKreserver) { + if (m_lexer->HasError()) { + break; + } + m_pToken = m_lexer->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()); + } + NextToken(); +} + +void CXFA_FMParse::Error(FX_DWORD lineNum, XFA_FM_ERRMSG 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); + va_end(ap); +} + +CFX_PtrArray* CXFA_FMParse::ParseTopExpression() { + std::unique_ptr<CXFA_FMExpression> e; + CFX_PtrArray* expression = new CFX_PtrArray(); + while (1) { + if (m_pToken->m_type == TOKeof || m_pToken->m_type == TOKendfunc || + m_pToken->m_type == TOKendif || m_pToken->m_type == TOKelseif || + m_pToken->m_type == TOKelse || m_pToken->m_type == TOKreserver) { + return expression; + } + + if (m_pToken->m_type == TOKfunc) { + e.reset(ParseFunction()); + if (e) { + expression->Add(e.release()); + } else { + break; + } + } else { + e.reset(ParseExpression()); + if (e) { + expression->Add(e.release()); + } else { + break; + } + } + } + return expression; +} + +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; + FX_DWORD 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, + ws_TempString.c_str()); + } else { + ident = m_pToken->m_wstring; + NextToken(); + } + Check(TOKlparen); + if (m_pToken->m_type == TOKrparen) { + NextToken(); + } else { + pArguments.reset(new CFX_WideStringCArray()); + CFX_WideStringC p; + while (1) { + if (m_pToken->m_type == TOKidentifier) { + p = m_pToken->m_wstring; + pArguments->Add(p); + NextToken(); + if (m_pToken->m_type == TOKcomma) { + NextToken(); + continue; + } else if (m_pToken->m_type == TOKrparen) { + NextToken(); + break; + } else { + Check(TOKrparen); + break; + } + } else { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, + ws_TempString.c_str()); + NextToken(); + break; + } + } + } + Check(TOKdo); + if (m_pToken->m_type == TOKendfunc) { + NextToken(); + } else { + pExpressions.reset(ParseTopExpression()); + Check(TOKendfunc); + } + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMFunctionDefinition(line, 0, ident, pArguments.release(), + pExpressions.release())); + } else { + if (pArguments) + pArguments->RemoveAll(); + if (pExpressions) { + for (int i = 0; i < pExpressions->GetSize(); ++i) + delete static_cast<CXFA_FMExpression*>(pExpressions->GetAt(i)); + } + } + return e.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseExpression() { + std::unique_ptr<CXFA_FMExpression> e; + FX_DWORD line = m_pToken->m_uLinenum; + switch (m_pToken->m_type) { + case TOKvar: + e.reset(ParseVarExpression()); + break; + case TOKnull: + case TOKnumber: + case TOKstring: + case TOKplus: + case TOKminus: + case TOKksnot: + case TOKidentifier: + case TOKlparen: + e.reset(ParseExpExpression()); + break; + case TOKif: + e.reset(ParseIfExpression()); + break; + case TOKwhile: + e.reset(ParseWhileExpression()); + break; + case TOKfor: + e.reset(ParseForExpression()); + break; + case TOKforeach: + e.reset(ParseForeachExpression()); + break; + case TOKdo: + e.reset(ParseDoExpression()); + break; + case TOKbreak: + e.reset(new CXFA_FMBreakExpression(line)); + NextToken(); + break; + case TOKcontinue: + e.reset(new CXFA_FMContinueExpression(line)); + NextToken(); + break; + default: + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, + ws_TempString.c_str()); + NextToken(); + break; + } + return e.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() { + std::unique_ptr<CXFA_FMExpression> e; + CFX_WideStringC ident; + FX_DWORD 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, + ws_TempString.c_str()); + } else { + ident = m_pToken->m_wstring; + NextToken(); + } + if (m_pToken->m_type == TOKassign) { + NextToken(); + e.reset(ParseExpExpression()); + } + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMVarExpression(line, ident, e.release())); + } else { + e.reset(); + } + return e.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseSimpleExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); + while (m_pToken->m_type == TOKassign) { + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + pExp1.reset(new CXFA_FMAssignExpression(line, TOKassign, pExp1.release(), + pExp2.release())); + } else { + pExp1.reset(); + } + } + return pExp1.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseExpExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseSimpleExpression()); + std::unique_ptr<CXFA_FMExpression> e; + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMExpExpression(line, pExp1.release())); + } else { + e.reset(); + } + return e.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseLogicalOrExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseLogicalAndExpression()); + for (;;) { + switch (m_pToken->m_type) { + case TOKor: + case TOKksor: { + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> e2( + ParseLogicalAndExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMLogicalOrExpression(line, TOKor, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + } + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseLogicalAndExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseEqualityExpression()); + for (;;) { + switch (m_pToken->m_type) { + case TOKand: + case TOKksand: { + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> e2(ParseEqualityExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMLogicalAndExpression(line, TOKand, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + } + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseEqualityExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseRelationalExpression()); + for (;;) { + std::unique_ptr<CXFA_FMSimpleExpression> e2; + switch (m_pToken->m_type) { + case TOKeq: + case TOKkseq: + NextToken(); + e2.reset(ParseRelationalExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMEqualityExpression(line, TOKeq, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + case TOKne: + case TOKksne: + NextToken(); + e2.reset(ParseRelationalExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMEqualityExpression(line, TOKne, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseRelationalExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseAddtiveExpression()); + for (;;) { + std::unique_ptr<CXFA_FMSimpleExpression> e2; + switch (m_pToken->m_type) { + case TOKlt: + case TOKkslt: + NextToken(); + e2.reset(ParseAddtiveExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMRelationalExpression(line, TOKlt, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + case TOKgt: + case TOKksgt: + NextToken(); + e2.reset(ParseAddtiveExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMRelationalExpression(line, TOKgt, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + case TOKle: + case TOKksle: + NextToken(); + e2.reset(ParseAddtiveExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMRelationalExpression(line, TOKle, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + case TOKge: + case TOKksge: + NextToken(); + e2.reset(ParseAddtiveExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMRelationalExpression(line, TOKge, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseAddtiveExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseMultiplicativeExpression()); + for (;;) { + std::unique_ptr<CXFA_FMSimpleExpression> e2; + switch (m_pToken->m_type) { + case TOKplus: + NextToken(); + e2.reset(ParseMultiplicativeExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMAdditiveExpression(line, TOKplus, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + case TOKminus: + NextToken(); + e2.reset(ParseMultiplicativeExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMAdditiveExpression(line, TOKminus, e1.release(), + e2.release())); + } else { + e1.reset(); + } + continue; + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseMultiplicativeExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseUnaryExpression()); + for (;;) { + std::unique_ptr<CXFA_FMSimpleExpression> e2; + switch (m_pToken->m_type) { + case TOKmul: + NextToken(); + e2.reset(ParseUnaryExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMMultiplicativeExpression( + line, TOKmul, e1.release(), e2.release())); + } else { + e1.reset(); + } + continue; + case TOKdiv: + NextToken(); + e2.reset(ParseUnaryExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e1.reset(new CXFA_FMMultiplicativeExpression( + line, TOKdiv, e1.release(), e2.release())); + } else { + e1.reset(); + } + continue; + default: + break; + } + break; + } + return e1.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseUnaryExpression() { + std::unique_ptr<CXFA_FMSimpleExpression> e; + FX_DWORD line = m_pToken->m_uLinenum; + switch (m_pToken->m_type) { + case TOKplus: + NextToken(); + e.reset(ParseUnaryExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMPosExpression(line, e.release())); + } else { + e.reset(); + } + break; + case TOKminus: + NextToken(); + e.reset(ParseUnaryExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMNegExpression(line, e.release())); + } else { + e.reset(); + } + break; + case TOKksnot: + NextToken(); + e.reset(ParseUnaryExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMNotExpression(line, e.release())); + } else { + e.reset(); + } + break; + default: + e.reset(ParsePrimaryExpression()); + break; + } + return e.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParsePrimaryExpression() { + std::unique_ptr<CXFA_FMSimpleExpression> e; + FX_DWORD line = m_pToken->m_uLinenum; + switch (m_pToken->m_type) { + case TOKnumber: + e.reset(new CXFA_FMNumberExpression(line, m_pToken->m_wstring)); + NextToken(); + break; + case TOKstring: + e.reset(new CXFA_FMStringExpression(line, m_pToken->m_wstring)); + NextToken(); + break; + case TOKidentifier: { + CFX_WideStringC wsIdentifier(m_pToken->m_wstring); + NextToken(); + if (m_pToken->m_type == TOKlbracket) { + CXFA_FMSimpleExpression* s = ParseIndexExpression(); + if (s) { + e.reset(new CXFA_FMDotAccessorExpression(line, NULL, TOKdot, + wsIdentifier, s)); + } + NextToken(); + } else { + e.reset(new CXFA_FMIdentifierExpressionn(line, wsIdentifier)); + } + } break; + case TOKif: + e.reset(new CXFA_FMIdentifierExpressionn(line, m_pToken->m_wstring)); + NextToken(); + break; + case TOKnull: + e.reset(new CXFA_FMNullExpression(line)); + NextToken(); + break; + case TOKlparen: + e.reset(ParseParenExpression()); + break; + default: + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, + ws_TempString.c_str()); + NextToken(); + break; + } + e.reset(ParsePostExpression(e.release())); + if (!(m_pErrorInfo->message.IsEmpty())) + e.reset(); + return e.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression( + CXFA_FMSimpleExpression* e) { + FX_DWORD line = m_pToken->m_uLinenum; + while (1) { + switch (m_pToken->m_type) { + case TOKlparen: { + NextToken(); + std::unique_ptr<CFX_PtrArray> pArray; + if (m_pToken->m_type != TOKrparen) { + pArray.reset(new CFX_PtrArray()); + while (m_pToken->m_type != TOKrparen) { + CXFA_FMSimpleExpression* e = ParseSimpleExpression(); + if (e) { + pArray->Add(e); + } + if (m_pToken->m_type == TOKcomma) { + NextToken(); + } else if (m_pToken->m_type == TOKeof || + m_pToken->m_type == TOKreserver) { + break; + } + } + if (m_pToken->m_type != TOKrparen) { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, + XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); + } + } + if (m_pErrorInfo->message.IsEmpty()) { + e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE); + NextToken(); + if (m_pToken->m_type != TOKlbracket) { + continue; + } + CXFA_FMSimpleExpression* s = ParseIndexExpression(); + if (s) { + e = new CXFA_FMDotAccessorExpression(line, e, TOKcall, + FX_WSTRC(L""), s); + } else { + delete e; + e = nullptr; + } + } else { + if (pArray) { + for (int32_t i = 0; i < pArray->GetSize(); ++i) + delete static_cast<CXFA_FMSimpleExpression*>(pArray->GetAt(i)); + } + delete e; + e = nullptr; + } + } break; + case TOKdot: + NextToken(); + if (m_pToken->m_type == TOKidentifier) { + CFX_WideStringC tempStr = m_pToken->m_wstring; + FX_DWORD tempLine = m_pToken->m_uLinenum; + NextToken(); + if (m_pToken->m_type == TOKlparen) { + CXFA_FMSimpleExpression* pExpAccessor; + CXFA_FMSimpleExpression* pExpCall; + pExpAccessor = e; + NextToken(); + std::unique_ptr<CFX_PtrArray> pArray; + if (m_pToken->m_type != TOKrparen) { + pArray.reset(new CFX_PtrArray()); + while (m_pToken->m_type != TOKrparen) { + CXFA_FMSimpleExpression* exp = ParseSimpleExpression(); + pArray->Add(exp); + if (m_pToken->m_type == TOKcomma) { + NextToken(); + } else if (m_pToken->m_type == TOKeof || + m_pToken->m_type == TOKreserver) { + break; + } + } + if (m_pToken->m_type != TOKrparen) { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, + XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); + } + } + if (m_pErrorInfo->message.IsEmpty()) { + CXFA_FMSimpleExpression* pIdentifier = + new CXFA_FMIdentifierExpressionn(tempLine, tempStr); + pExpCall = new CXFA_FMCallExpression(line, pIdentifier, + pArray.release(), TRUE); + e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall); + NextToken(); + if (m_pToken->m_type != TOKlbracket) { + continue; + } + CXFA_FMSimpleExpression* s = ParseIndexExpression(); + if (s) { + e = new CXFA_FMDotAccessorExpression(line, e, TOKcall, + FX_WSTRC(L""), s); + } else { + delete e; + e = nullptr; + } + } else { + if (pArray) { + for (int32_t i = 0; i < pArray->GetSize(); ++i) { + delete static_cast<CXFA_FMSimpleExpression*>( + pArray->GetAt(i)); + } + } + delete e; + e = nullptr; + } + } else if (m_pToken->m_type == TOKlbracket) { + std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); + if (!(m_pErrorInfo->message.IsEmpty())) { + delete e; + return nullptr; + } + e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr, + s.release()); + } else { + CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( + tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); + e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s); + continue; + } + } else { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, + ws_TempString.c_str()); + return e; + } + break; + case TOKdotdot: + NextToken(); + if (m_pToken->m_type == TOKidentifier) { + CFX_WideStringC tempStr = m_pToken->m_wstring; + FX_DWORD tempLine = m_pToken->m_uLinenum; + NextToken(); + if (m_pToken->m_type == TOKlbracket) { + std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); + if (!(m_pErrorInfo->message.IsEmpty())) { + delete e; + return nullptr; + } + e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot, + tempStr, s.release()); + } else { + CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( + tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); + e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr, + s); + continue; + } + } else { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, + ws_TempString.c_str()); + return e; + } + break; + case TOKdotscream: + NextToken(); + if (m_pToken->m_type == TOKidentifier) { + CFX_WideStringC tempStr = m_pToken->m_wstring; + FX_DWORD tempLine = m_pToken->m_uLinenum; + NextToken(); + if (m_pToken->m_type == TOKlbracket) { + std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); + if (!(m_pErrorInfo->message.IsEmpty())) { + delete e; + return nullptr; + } + e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream, + tempStr, s.release()); + } else { + CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( + tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); + e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr, + s); + continue; + } + } else { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, + ws_TempString.c_str()); + return e; + } + break; + case TOKdotstar: { + CXFA_FMSimpleExpression* s = + new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE); + e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar, + FX_WSTRC(L"*"), s); + } break; + default: + return e; + } + NextToken(); + } + return e; +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseIndexExpression() { + std::unique_ptr<CXFA_FMSimpleExpression> pExp; + FX_DWORD line = m_pToken->m_uLinenum; + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> s; + XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX; + if (m_pToken->m_type == TOKmul) { + pExp.reset( + 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, + XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); + pExp.reset(); + } + return pExp.release(); + } + if (m_pToken->m_type == TOKplus) { + accessorIndex = ACCESSOR_POSITIVE_INDEX; + NextToken(); + } else if (m_pToken->m_type == TOKminus) { + accessorIndex = ACCESSOR_NEGATIVE_INDEX; + NextToken(); + } + 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, + XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); + } else { + pExp.reset( + new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE)); + } + return pExp.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() { + Check(TOKlparen); + + if (m_pToken->m_type == TOKrparen) { + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_NON_EMPTY_EXPRESSION); + NextToken(); + return nullptr; + } + + FX_DWORD line = m_pToken->m_uLinenum; + std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); + + while (m_pToken->m_type == TOKassign) { + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); + if (m_pErrorInfo->message.IsEmpty()) { + pExp1.reset(new CXFA_FMAssignExpression(line, TOKassign, pExp1.release(), + pExp2.release())); + } else { + pExp1.reset(); + } + } + Check(TOKrparen); + return pExp1.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseBlockExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + CXFA_FMExpression* e = nullptr; + std::unique_ptr<CFX_PtrArray> expression(new CFX_PtrArray()); + while (1) { + switch (m_pToken->m_type) { + case TOKeof: + case TOKendif: + case TOKelseif: + case TOKelse: + case TOKendwhile: + case TOKendfor: + case TOKend: + case TOKendfunc: + case TOKreserver: + break; + case TOKfunc: + e = ParseFunction(); + if (e) { + expression->Add(e); + } + continue; + default: + e = ParseExpression(); + if (e) { + expression->Add(e); + } + continue; + } + break; + } + std::unique_ptr<CXFA_FMBlockExpression> pExp; + if (m_pErrorInfo->message.IsEmpty()) { + pExp.reset(new CXFA_FMBlockExpression(line, expression.release())); + } else { + for (int i = 0; i < expression->GetSize(); ++i) + delete static_cast<CXFA_FMExpression*>(expression->GetAt(i)); + } + return pExp.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseIfExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + const FX_WCHAR* pStartPos = m_lexer->SavePos(); + NextToken(); + Check(TOKlparen); + std::unique_ptr<CXFA_FMSimpleExpression> pExpression; + while (m_pToken->m_type != TOKrparen) { + pExpression.reset(ParseSimpleExpression()); + if (m_pToken->m_type != TOKcomma) + break; + NextToken(); + } + Check(TOKrparen); + if (m_pToken->m_type != TOKthen) { + m_lexer->SetCurrentLine(line); + m_pToken = new CXFA_FMToken(line); + m_pToken->m_type = TOKidentifier; + m_pToken->m_wstring = FX_WSTRC(L"if"); + m_lexer->SetToken(m_pToken); + m_lexer->RestorePos(pStartPos); + return ParseExpExpression(); + } + Check(TOKthen); + std::unique_ptr<CXFA_FMExpression> pIfExpression(ParseBlockExpression()); + std::unique_ptr<CXFA_FMExpression> pElseExpression; + switch (m_pToken->m_type) { + case TOKeof: + case TOKendif: + Check(TOKendif); + break; + case TOKif: + pElseExpression.reset(ParseIfExpression()); + Check(TOKendif); + break; + case TOKelseif: + pElseExpression.reset(ParseIfExpression()); + break; + case TOKelse: + NextToken(); + pElseExpression.reset(ParseBlockExpression()); + Check(TOKendif); + break; + default: + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IFEND, ws_TempString.c_str()); + NextToken(); + break; + } + std::unique_ptr<CXFA_FMIfExpression> pExp; + if (m_pErrorInfo->message.IsEmpty()) { + pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(), + pIfExpression.release(), + pElseExpression.release())); + } + return pExp.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseWhileExpression() { + FX_DWORD line = m_pToken->m_uLinenum; + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> pCondition(ParseParenExpression()); + Check(TOKdo); + std::unique_ptr<CXFA_FMExpression> pExpression(ParseBlockExpression()); + Check(TOKendwhile); + std::unique_ptr<CXFA_FMExpression> e; + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMWhileExpression(line, pCondition.release(), + pExpression.release())); + } + return e.release(); +} + +CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() { + std::unique_ptr<CXFA_FMSimpleExpression> e; + switch (m_pToken->m_type) { + case TOKidentifier: + e.reset(ParseSimpleExpression()); + break; + default: + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, + ws_TempString.c_str()); + NextToken(); + break; + } + return e.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseForExpression() { + CFX_WideStringC wsVariant; + FX_DWORD 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, + XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); + } + wsVariant = m_pToken->m_wstring; + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> pAssignment; + if (m_pToken->m_type == TOKassign) { + NextToken(); + pAssignment.reset(ParseSimpleExpression()); + } else { + CFX_WideString ws_TempString = m_pToken->m_wstring; + Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, + XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); + } + int32_t iDirection = 0; + if (m_pToken->m_type == TOKupto) { + iDirection = 1; + } 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); + } + NextToken(); + std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression()); + std::unique_ptr<CXFA_FMSimpleExpression> pStep; + if (m_pToken->m_type == TOKstep) { + NextToken(); + pStep.reset(ParseSimpleExpression()); + } + Check(TOKdo); + std::unique_ptr<CXFA_FMExpression> pList(ParseBlockExpression()); + Check(TOKendfor); + std::unique_ptr<CXFA_FMExpression> e; + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMForExpression(line, wsVariant, pAssignment.release(), + pAccessor.release(), iDirection, + pStep.release(), pList.release())); + } + return e.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() { + std::unique_ptr<CXFA_FMExpression> e; + CFX_WideStringC wsIdentifier; + std::unique_ptr<CFX_PtrArray> pAccessors; + std::unique_ptr<CXFA_FMExpression> pList; + FX_DWORD 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, + XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); + } + wsIdentifier = m_pToken->m_wstring; + NextToken(); + 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, + ws_TempString.c_str()); + NextToken(); + } else { + pAccessors.reset(new CFX_PtrArray()); + while (m_pToken->m_type != TOKrparen) { + CXFA_FMSimpleExpression* s = ParseSimpleExpression(); + if (s) { + pAccessors->Add(s); + } + if (m_pToken->m_type == TOKcomma) { + NextToken(); + } else { + break; + } + } + Check(TOKrparen); + } + Check(TOKdo); + pList.reset(ParseBlockExpression()); + Check(TOKendfor); + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMForeachExpression( + line, wsIdentifier, pAccessors.release(), pList.release())); + } else { + if (pAccessors) { + for (int i = 0; i < pAccessors->GetSize(); ++i) + delete static_cast<CXFA_FMSimpleExpression*>(pAccessors->GetAt(i)); + } + } + return e.release(); +} + +CXFA_FMExpression* CXFA_FMParse::ParseDoExpression() { + std::unique_ptr<CXFA_FMExpression> e; + FX_DWORD line = m_pToken->m_uLinenum; + NextToken(); + e.reset(ParseBlockExpression()); + Check(TOKend); + if (m_pErrorInfo->message.IsEmpty()) { + e.reset(new CXFA_FMDoExpression(line, e.release())); + } else { + e.reset(); + } + return e.release(); +} diff --git a/xfa/fxfa/fm2js/xfa_fmparse.h b/xfa/fxfa/fm2js/xfa_fmparse.h new file mode 100644 index 0000000000..a8991b466f --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_fmparse.h @@ -0,0 +1,53 @@ +// 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_FM2JS_XFA_FMPARSE_H_ +#define XFA_FXFA_FM2JS_XFA_FMPARSE_H_ + +#include <memory> + +#include "xfa/fxfa/fm2js/xfa_expression.h" +#include "xfa/fxfa/fm2js/xfa_lexer.h" + +class CXFA_FMParse { + public: + CXFA_FMParse(); + int32_t Init(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); + void NextToken(); + void Check(XFA_FM_TOKEN op); + void Error(FX_DWORD lineNum, XFA_FM_ERRMSG msg, ...); + CFX_PtrArray* ParseTopExpression(); + CXFA_FMExpression* ParseFunction(); + CXFA_FMExpression* ParseExpression(); + CXFA_FMExpression* ParseVarExpression(); + CXFA_FMExpression* ParseExpExpression(); + CXFA_FMExpression* ParseBlockExpression(); + CXFA_FMExpression* ParseIfExpression(); + CXFA_FMExpression* ParseWhileExpression(); + CXFA_FMExpression* ParseForExpression(); + CXFA_FMExpression* ParseForeachExpression(); + CXFA_FMExpression* ParseDoExpression(); + CXFA_FMSimpleExpression* ParseParenExpression(); + CXFA_FMSimpleExpression* ParseSimpleExpression(); + CXFA_FMSimpleExpression* ParseSubassignmentInForExpression(); + CXFA_FMSimpleExpression* ParseLogicalOrExpression(); + CXFA_FMSimpleExpression* ParseLogicalAndExpression(); + CXFA_FMSimpleExpression* ParseEqualityExpression(); + CXFA_FMSimpleExpression* ParseRelationalExpression(); + CXFA_FMSimpleExpression* ParseAddtiveExpression(); + CXFA_FMSimpleExpression* ParseMultiplicativeExpression(); + CXFA_FMSimpleExpression* ParseUnaryExpression(); + CXFA_FMSimpleExpression* ParsePrimaryExpression(); + CXFA_FMSimpleExpression* ParsePostExpression(CXFA_FMSimpleExpression* e); + CXFA_FMSimpleExpression* ParseIndexExpression(); + + private: + std::unique_ptr<CXFA_FMLexer> m_lexer; + CXFA_FMToken* m_pToken; + CXFA_FMErrorInfo* m_pErrorInfo; +}; + +#endif // XFA_FXFA_FM2JS_XFA_FMPARSE_H_ diff --git a/xfa/fxfa/fm2js/xfa_lexer.cpp b/xfa/fxfa/fm2js/xfa_lexer.cpp new file mode 100644 index 0000000000..d470390609 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_lexer.cpp @@ -0,0 +1,552 @@ +// 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/fxfa/fm2js/xfa_lexer.h" + +#include "core/include/fxcrt/fx_ext.h" + +namespace { + +struct XFA_FMDChar { + static const FX_WCHAR* inc(const FX_WCHAR*& p) { + ++p; + return p; + } + static const FX_WCHAR* dec(const FX_WCHAR*& p) { + --p; + return p; + } + static uint16_t get(const FX_WCHAR* p) { return *p; } + static FX_BOOL isWhiteSpace(const FX_WCHAR* p) { + return (*p) == 0x09 || (*p) == 0x0b || (*p) == 0x0c || (*p) == 0x20; + } + static FX_BOOL isLineTerminator(const FX_WCHAR* p) { + return *p == 0x0A || *p == 0x0D; + } + static FX_BOOL isBinary(const FX_WCHAR* p) { + return (*p) >= '0' && (*p) <= '1'; + } + static FX_BOOL isOctal(const FX_WCHAR* p) { + return (*p) >= '0' && (*p) <= '7'; + } + static FX_BOOL isDigital(const FX_WCHAR* p) { + return (*p) >= '0' && (*p) <= '9'; + } + static FX_BOOL isHex(const FX_WCHAR* p) { + return isDigital(p) || ((*p) >= 'a' && (*p) <= 'f') || + ((*p) >= 'A' && (*p) <= 'F'); + } + static FX_BOOL isAlpha(const FX_WCHAR* p) { + return ((*p) <= 'z' && (*p) >= 'a') || ((*p) <= 'Z' && (*p) >= 'A'); + } + static FX_BOOL isAvalid(const FX_WCHAR* p, FX_BOOL flag = 0); + static FX_BOOL string2number(const FX_WCHAR* s, + FX_DOUBLE* pValue, + const FX_WCHAR*& pEnd); + static FX_BOOL isUnicodeAlpha(uint16_t ch); +}; + +inline FX_BOOL XFA_FMDChar::isAvalid(const FX_WCHAR* p, FX_BOOL flag) { + if (*p == 0) { + return 1; + } + if ((*p <= 0x0A && *p >= 0x09) || *p == 0x0D || + (*p <= 0xd7ff && *p >= 0x20) || (*p <= 0xfffd && *p >= 0xe000)) { + return 1; + } + if (!flag) { + if (*p == 0x0B || *p == 0x0C) { + return 1; + } + } + return 0; +} + +inline FX_BOOL XFA_FMDChar::string2number(const FX_WCHAR* s, + FX_DOUBLE* pValue, + const FX_WCHAR*& pEnd) { + if (s) { + *pValue = wcstod((wchar_t*)s, (wchar_t**)&pEnd); + } + return 0; +} + +inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(uint16_t ch) { + if (ch == 0 || ch == 0x0A || ch == 0x0D || ch == 0x09 || ch == 0x0B || + ch == 0x0C || ch == 0x20 || ch == '.' || ch == ';' || ch == '"' || + ch == '=' || ch == '<' || ch == '>' || ch == ',' || ch == '(' || + ch == ')' || ch == ']' || ch == '[' || ch == '&' || ch == '|' || + ch == '+' || ch == '-' || ch == '*' || ch == '/') { + return FALSE; + } + return TRUE; +} + +const XFA_FMKeyword keyWords[] = { + {TOKand, 0x00000026, L"&"}, + {TOKlparen, 0x00000028, L"("}, + {TOKrparen, 0x00000029, L")"}, + {TOKmul, 0x0000002a, L"*"}, + {TOKplus, 0x0000002b, L"+"}, + {TOKcomma, 0x0000002c, L","}, + {TOKminus, 0x0000002d, L"-"}, + {TOKdot, 0x0000002e, L"."}, + {TOKdiv, 0x0000002f, L"/"}, + {TOKlt, 0x0000003c, L"<"}, + {TOKassign, 0x0000003d, L"="}, + {TOKgt, 0x0000003e, L">"}, + {TOKlbracket, 0x0000005b, L"["}, + {TOKrbracket, 0x0000005d, L"]"}, + {TOKor, 0x0000007c, L"|"}, + {TOKdotscream, 0x0000ec11, L".#"}, + {TOKdotstar, 0x0000ec18, L".*"}, + {TOKdotdot, 0x0000ec1c, L".."}, + {TOKle, 0x000133f9, L"<="}, + {TOKne, 0x000133fa, L"<>"}, + {TOKeq, 0x0001391a, L"=="}, + {TOKge, 0x00013e3b, L">="}, + {TOKdo, 0x00020153, L"do"}, + {TOKkseq, 0x00020676, L"eq"}, + {TOKksge, 0x000210ac, L"ge"}, + {TOKksgt, 0x000210bb, L"gt"}, + {TOKif, 0x00021aef, L"if"}, + {TOKin, 0x00021af7, L"in"}, + {TOKksle, 0x00022a51, L"le"}, + {TOKkslt, 0x00022a60, L"lt"}, + {TOKksne, 0x00023493, L"ne"}, + {TOKksor, 0x000239c1, L"or"}, + {TOKnull, 0x052931bb, L"null"}, + {TOKbreak, 0x05518c25, L"break"}, + {TOKksand, 0x09f9db33, L"and"}, + {TOKend, 0x0a631437, L"end"}, + {TOKeof, 0x0a63195a, L"eof"}, + {TOKfor, 0x0a7d67a7, L"for"}, + {TOKnan, 0x0b4f91dd, L"nan"}, + {TOKksnot, 0x0b4fd9b1, L"not"}, + {TOKvar, 0x0c2203e9, L"var"}, + {TOKthen, 0x2d5738cf, L"then"}, + {TOKelse, 0x45f65ee9, L"else"}, + {TOKexit, 0x4731d6ba, L"exit"}, + {TOKdownto, 0x4caadc3b, L"downto"}, + {TOKreturn, 0x4db8bd60, L"return"}, + {TOKinfinity, 0x5c0a010a, L"infinity"}, + {TOKendwhile, 0x5c64bff0, L"endwhile"}, + {TOKforeach, 0x67e31f38, L"foreach"}, + {TOKendfunc, 0x68f984a3, L"endfunc"}, + {TOKelseif, 0x78253218, L"elseif"}, + {TOKwhile, 0x84229259, L"while"}, + {TOKendfor, 0x8ab49d7e, L"endfor"}, + {TOKthrow, 0x8db05c94, L"throw"}, + {TOKstep, 0xa7a7887c, L"step"}, + {TOKupto, 0xb5155328, L"upto"}, + {TOKcontinue, 0xc0340685, L"continue"}, + {TOKfunc, 0xcdce60ec, L"func"}, + {TOKendif, 0xe0e8fee6, L"endif"}, +}; + +const XFA_FM_TOKEN KEYWORD_START = TOKdo; +const XFA_FM_TOKEN KEYWORD_END = TOKendif; + +} // namespace + +const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op) { + if (op < KEYWORD_START || op > KEYWORD_END) + return L""; + return keyWords[op].m_keyword; +} + +CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {} + +CXFA_FMToken::CXFA_FMToken(FX_DWORD uLineNum) + : m_type(TOKreserver), m_uLinenum(uLineNum) {} + +CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc, + CXFA_FMErrorInfo* pErrorInfo) + : m_ptr(wsFormCalc.GetPtr()), m_uCurrentLine(1), m_pErrorInfo(pErrorInfo) {} + +CXFA_FMToken* CXFA_FMLexer::NextToken() { + m_pToken.reset(Scan()); + return m_pToken.get(); +} + +CXFA_FMToken* CXFA_FMLexer::Scan() { + uint16_t ch = 0; + 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); + return p; + } + int iRet = 0; + while (1) { + if (!XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + ch = XFA_FMDChar::get(m_ptr); + switch (ch) { + case 0: + p->m_type = TOKeof; + return p; + case 0x0A: + ++m_uCurrentLine; + p->m_uLinenum = m_uCurrentLine; + XFA_FMDChar::inc(m_ptr); + break; + case 0x0D: + XFA_FMDChar::inc(m_ptr); + break; + case ';': { + const FX_WCHAR* pTemp = 0; + Comment(m_ptr, pTemp); + m_ptr = pTemp; + } break; + case '"': { + const FX_WCHAR* pTemp = 0; + p->m_type = TOKstring; + iRet = String(p, m_ptr, pTemp); + m_ptr = pTemp; + } + return p; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { + p->m_type = TOKnumber; + const FX_WCHAR* pTemp = 0; + iRet = Number(p, m_ptr, pTemp); + m_ptr = pTemp; + if (iRet) { + Error(FMERR_BAD_SUFFIX_NUMBER); + return p; + } + } + return p; + case '=': + XFA_FMDChar::inc(m_ptr); + if (XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + if (ch == '=') { + p->m_type = TOKeq; + XFA_FMDChar::inc(m_ptr); + return p; + } else { + p->m_type = TOKassign; + return p; + } + } else { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + break; + case '<': + XFA_FMDChar::inc(m_ptr); + if (XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + if (ch == '=') { + p->m_type = TOKle; + XFA_FMDChar::inc(m_ptr); + return p; + } else if (ch == '>') { + p->m_type = TOKne; + XFA_FMDChar::inc(m_ptr); + return p; + } else { + p->m_type = TOKlt; + return p; + } + } else { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + break; + case '>': + XFA_FMDChar::inc(m_ptr); + if (XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + if (ch == '=') { + p->m_type = TOKge; + XFA_FMDChar::inc(m_ptr); + return p; + } else { + p->m_type = TOKgt; + return p; + } + } else { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + break; + case ',': + p->m_type = TOKcomma; + XFA_FMDChar::inc(m_ptr); + return p; + case '(': + p->m_type = TOKlparen; + XFA_FMDChar::inc(m_ptr); + return p; + case ')': + p->m_type = TOKrparen; + XFA_FMDChar::inc(m_ptr); + return p; + case '[': + p->m_type = TOKlbracket; + XFA_FMDChar::inc(m_ptr); + return p; + case ']': + p->m_type = TOKrbracket; + XFA_FMDChar::inc(m_ptr); + return p; + case '&': + XFA_FMDChar::inc(m_ptr); + p->m_type = TOKand; + return p; + case '|': + XFA_FMDChar::inc(m_ptr); + p->m_type = TOKor; + return p; + case '+': + XFA_FMDChar::inc(m_ptr); + p->m_type = TOKplus; + return p; + case '-': + XFA_FMDChar::inc(m_ptr); + p->m_type = TOKminus; + return p; + case '*': + XFA_FMDChar::inc(m_ptr); + p->m_type = TOKmul; + return p; + case '/': + XFA_FMDChar::inc(m_ptr); + if (XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + if (ch == '/') { + const FX_WCHAR* pTemp = 0; + Comment(m_ptr, pTemp); + m_ptr = pTemp; + break; + } else { + p->m_type = TOKdiv; + return p; + } + } else { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + break; + case '.': + XFA_FMDChar::inc(m_ptr); + if (XFA_FMDChar::isAvalid(m_ptr)) { + ch = XFA_FMDChar::get(m_ptr); + if (ch == '.') { + p->m_type = TOKdotdot; + XFA_FMDChar::inc(m_ptr); + return p; + } else if (ch == '*') { + p->m_type = TOKdotstar; + XFA_FMDChar::inc(m_ptr); + return p; + } else if (ch == '#') { + p->m_type = TOKdotscream; + XFA_FMDChar::inc(m_ptr); + return p; + } else if (ch <= '9' && ch >= '0') { + p->m_type = TOKnumber; + const FX_WCHAR* pTemp = 0; + XFA_FMDChar::dec(m_ptr); + iRet = Number(p, m_ptr, pTemp); + m_ptr = pTemp; + if (iRet) { + Error(FMERR_BAD_SUFFIX_NUMBER); + } + return p; + } else { + p->m_type = TOKdot; + return p; + } + } else { + ch = XFA_FMDChar::get(m_ptr); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return p; + } + case 0x09: + case 0x0B: + case 0x0C: + case 0x20: + XFA_FMDChar::inc(m_ptr); + break; + default: { + const FX_WCHAR* pTemp = 0; + iRet = Identifiers(p, m_ptr, pTemp); + m_ptr = pTemp; + if (iRet) { + return p; + } + p->m_type = IsKeyword(p->m_wstring); + } + return p; + } + } +} + +FX_DWORD CXFA_FMLexer::Number(CXFA_FMToken* t, + const FX_WCHAR* p, + const FX_WCHAR*& pEnd) { + FX_DOUBLE number = 0; + if (XFA_FMDChar::string2number(p, &number, pEnd)) { + return 1; + } + if (pEnd && XFA_FMDChar::isAlpha(pEnd)) { + return 1; + } + t->m_wstring = CFX_WideStringC(p, (pEnd - p)); + return 0; +} + +FX_DWORD CXFA_FMLexer::String(CXFA_FMToken* t, + const FX_WCHAR* p, + const FX_WCHAR*& pEnd) { + const FX_WCHAR* pStart = p; + uint16_t ch = 0; + XFA_FMDChar::inc(p); + ch = XFA_FMDChar::get(p); + while (ch) { + if (!XFA_FMDChar::isAvalid(p)) { + ch = XFA_FMDChar::get(p); + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return 1; + } + if (ch == '"') { + XFA_FMDChar::inc(p); + if (!XFA_FMDChar::isAvalid(p)) { + ch = XFA_FMDChar::get(p); + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return 1; + } + ch = XFA_FMDChar::get(p); + if (ch == '"') { + goto NEXT; + } else { + break; + } + } + NEXT: + XFA_FMDChar::inc(p); + ch = XFA_FMDChar::get(p); + } + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + return 0; +} + +FX_DWORD CXFA_FMLexer::Identifiers(CXFA_FMToken* t, + const FX_WCHAR* p, + const FX_WCHAR*& pEnd) { + const FX_WCHAR* pStart = p; + uint16_t ch = 0; + ch = XFA_FMDChar::get(p); + XFA_FMDChar::inc(p); + if (!XFA_FMDChar::isAvalid(p)) { + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return 1; + } + ch = XFA_FMDChar::get(p); + while (ch) { + if (!XFA_FMDChar::isAvalid(p)) { + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + Error(FMERR_UNSUPPORTED_CHAR, ch); + return 1; + } + ch = XFA_FMDChar::get(p); + if (XFA_FMDChar::isUnicodeAlpha(ch)) { + XFA_FMDChar::inc(p); + } else { + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + return 0; + } + } + pEnd = p; + t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); + return 0; +} + +void CXFA_FMLexer::Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd) { + unsigned ch = 0; + XFA_FMDChar::inc(p); + ch = XFA_FMDChar::get(p); + while (ch) { + if (ch == 0x0D) { + XFA_FMDChar::inc(p); + pEnd = p; + return; + } + if (ch == 0x0A) { + ++m_uCurrentLine; + XFA_FMDChar::inc(p); + pEnd = p; + return; + } + XFA_FMDChar::inc(p); + ch = XFA_FMDChar::get(p); + } + pEnd = p; +} + +XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) { + int32_t iLength = str.GetLength(); + uint32_t uHash = FX_HashCode_String_GetW(str.GetPtr(), iLength, TRUE); + int32_t iStart = KEYWORD_START, iEnd = KEYWORD_END; + int32_t iMid = (iStart + iEnd) / 2; + XFA_FMKeyword keyword; + do { + iMid = (iStart + iEnd) / 2; + keyword = keyWords[iMid]; + if (uHash == keyword.m_uHash) { + return keyword.m_type; + } else if (uHash < keyword.m_uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return TOKidentifier; +} + +void CXFA_FMLexer::Error(XFA_FM_ERRMSG 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); + va_end(ap); +} + +FX_BOOL CXFA_FMLexer::HasError() const { + if (m_pErrorInfo->message.IsEmpty()) { + return FALSE; + } + return TRUE; +} diff --git a/xfa/fxfa/fm2js/xfa_lexer.h b/xfa/fxfa/fm2js/xfa_lexer.h new file mode 100644 index 0000000000..b0d6069683 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_lexer.h @@ -0,0 +1,134 @@ +// 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_FM2JS_XFA_LEXER_H_ +#define XFA_FXFA_FM2JS_XFA_LEXER_H_ + +#include <memory> + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/fxfa/fm2js/xfa_error.h" + +enum XFA_FM_TOKEN { + TOKand, + TOKlparen, + TOKrparen, + TOKmul, + TOKplus, + TOKcomma, + TOKminus, + TOKdot, + TOKdiv, + TOKlt, + TOKassign, + TOKgt, + TOKlbracket, + TOKrbracket, + TOKor, + TOKdotscream, + TOKdotstar, + TOKdotdot, + TOKle, + TOKne, + TOKeq, + TOKge, + TOKdo, + TOKkseq, + TOKksge, + TOKksgt, + TOKif, + TOKin, + TOKksle, + TOKkslt, + TOKksne, + TOKksor, + TOKnull, + TOKbreak, + TOKksand, + TOKend, + TOKeof, + TOKfor, + TOKnan, + TOKksnot, + TOKvar, + TOKthen, + TOKelse, + TOKexit, + TOKdownto, + TOKreturn, + TOKinfinity, + TOKendwhile, + TOKforeach, + TOKendfunc, + TOKelseif, + TOKwhile, + TOKendfor, + TOKthrow, + TOKstep, + TOKupto, + TOKcontinue, + TOKfunc, + TOKendif, + TOKstar, + TOKidentifier, + TOKunderscore, + TOKdollar, + TOKexclamation, + TOKcall, + TOKstring, + TOKnumber, + TOKreserver +}; + +struct XFA_FMKeyword { + XFA_FM_TOKEN m_type; + uint32_t m_uHash; + const FX_WCHAR* m_keyword; +}; + +const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op); + +class CXFA_FMToken { + public: + CXFA_FMToken(); + explicit CXFA_FMToken(FX_DWORD uLineNum); + + CFX_WideStringC m_wstring; + XFA_FM_TOKEN m_type; + FX_DWORD m_uLinenum; +}; + +class CXFA_FMLexer { + public: + CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); + CXFA_FMToken* NextToken(); + FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); + FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); + FX_DWORD Identifiers(CXFA_FMToken* t, + const FX_WCHAR* p, + const FX_WCHAR*& pEnd); + void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd); + XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p); + void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; } + void SetToken(CXFA_FMToken* pToken) { + if (m_pToken.get() != pToken) + m_pToken.reset(pToken); + } + const FX_WCHAR* SavePos() { return m_ptr; } + void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; } + void Error(XFA_FM_ERRMSG msg, ...); + FX_BOOL HasError() const; + + protected: + CXFA_FMToken* Scan(); + + const FX_WCHAR* m_ptr; + FX_DWORD m_uCurrentLine; + std::unique_ptr<CXFA_FMToken> m_pToken; + CXFA_FMErrorInfo* m_pErrorInfo; +}; + +#endif // XFA_FXFA_FM2JS_XFA_LEXER_H_ diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp new file mode 100644 index 0000000000..ef5efb214c --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_program.cpp @@ -0,0 +1,45 @@ +// 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/fxfa/fm2js/xfa_program.h" + +CXFA_FMProgram::CXFA_FMProgram() : m_globalFunction(0) {} +CXFA_FMProgram::~CXFA_FMProgram() { + if (m_globalFunction != 0) { + delete m_globalFunction; + m_globalFunction = 0; + } +} +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; + 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; + } + } + delete expressions; + return -1; + } + m_globalFunction = + new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); + return 0; +} +int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { + m_globalFunction->ToJavaScript(wsJavaScript); + wsJavaScript.AppendChar(0); + return 0; +} diff --git a/xfa/fxfa/fm2js/xfa_program.h b/xfa/fxfa/fm2js/xfa_program.h new file mode 100644 index 0000000000..2f6de5e3a8 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_program.h @@ -0,0 +1,28 @@ +// 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_FM2JS_XFA_PROGRAM_H_ +#define XFA_FXFA_FM2JS_XFA_PROGRAM_H_ + +#include "xfa/fxfa/fm2js/xfa_error.h" +#include "xfa/fxfa/fm2js/xfa_fmparse.h" + +class CXFA_FMProgram { + public: + CXFA_FMProgram(); + ~CXFA_FMProgram(); + int32_t Init(const CFX_WideStringC& wsFormcalc); + int32_t ParseProgram(); + int32_t TranslateProgram(CFX_WideTextBuf& wsJavaScript); + CXFA_FMErrorInfo& GetError() { return m_pErrorInfo; } + + private: + CXFA_FMErrorInfo m_pErrorInfo; + CXFA_FMParse m_parse; + CXFA_FMFunctionDefinition* m_globalFunction; +}; + +#endif // XFA_FXFA_FM2JS_XFA_PROGRAM_H_ diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp new file mode 100644 index 0000000000..3e6657335c --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp @@ -0,0 +1,745 @@ +// 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/fxfa/fm2js/xfa_simpleexpression.h" + +#include "core/include/fxcrt/fx_ext.h" + +namespace { + +const CFX_WideStringC gs_lpStrExpFuncName[] = { + FX_WSTRC(L"foxit_xfa_formcalc_runtime.assign_value_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_or_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_and_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.equality_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.notequality_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.less_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.lessequal_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.greater_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.greaterequal_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.plus_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.minus_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.multiple_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.divide_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.positive_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.negative_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_not_operator"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime."), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.dot_accessor"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.dotdot_accessor"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.concat_fm_object"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.is_fm_object"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.is_fm_array"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.get_fm_value"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.get_fm_jsobj"), + FX_WSTRC(L"foxit_xfa_formcalc_runtime.fm_var_filter"), +}; + +struct XFA_FMBuildInFunc { + uint32_t m_uHash; + const FX_WCHAR* m_buildinfunc; +}; +const XFA_FMBuildInFunc g_BuildInFuncs[] = { + {0x0001f1f5, L"At"}, {0x00020b9c, L"FV"}, + {0x00021aef, L"If"}, {0x00023ee6, L"PV"}, + {0x04b5c9ee, L"Encode"}, {0x08e96685, L"DateFmt"}, + {0x09f99db6, L"Abs"}, {0x09f9e583, L"Apr"}, + {0x09fa043e, L"Avg"}, {0x0a9782a0, L"Get"}, + {0x0b1b09df, L"Len"}, {0x0b3543a6, L"Max"}, + {0x0b356ca4, L"Min"}, {0x0b358b60, L"Mod"}, + {0x0b4fded4, L"NPV"}, {0x0b846bf1, L"Pmt"}, + {0x0b8494f9, L"Put"}, {0x0bb8df5d, L"Ref"}, + {0x0bd37a99, L"Str"}, {0x0bd37fb5, L"Sum"}, + {0x1048469b, L"Cterm"}, {0x11e03660, L"Exists"}, + {0x126236e6, L"Post"}, {0x127c6661, L"PPmt"}, + {0x193ade3e, L"Right"}, {0x1ec8ab2c, L"Rate"}, + {0x20e476dc, L"IsoTime2Num"}, {0x23eb6816, L"TimeFmt"}, + {0x24fb17b0, L"LocalDateFmt"}, {0x28dee6e9, L"Format"}, + {0x2d0890b8, L"Term"}, {0x2d71b00f, L"Time"}, + {0x2f890fb1, L"Num2Time"}, {0x3767511d, L"Ceil"}, + {0x3ffd1941, L"LocalTimeFmt"}, {0x442f68c8, L"Round"}, + {0x46fd1128, L"Eval"}, {0x4d629440, L"Date2Num"}, + {0x4dcf25f8, L"Concat"}, {0x4e00255d, L"UnitValue"}, + {0x55a5cc29, L"Lower"}, {0x5e43e04c, L"WordNum"}, + {0x620ce6ba, L"Ipmt"}, {0x6f544d49, L"Count"}, + {0x7e241013, L"Within"}, {0x9b9a6e2b, L"IsoDate2Num"}, + {0xb2c941c2, L"UnitType"}, {0xb598a1f7, L"Uuid"}, + {0xbde9abde, L"Date"}, {0xc0010b80, L"Num2Date"}, + {0xc1f6144c, L"Upper"}, {0xc44028f7, L"Oneof"}, + {0xc62c1b2c, L"Space"}, {0xd0ff50f9, L"HasValue"}, + {0xd1537042, L"Floor"}, {0xd2ac9cf1, L"Time2Num"}, + {0xd907aee5, L"Num2GMTime"}, {0xdf24f7c4, L"Decode"}, + {0xe2664803, L"Substr"}, {0xe3e7b528, L"Stuff"}, + {0xe6792d4e, L"Rtrim"}, {0xe8c23f5b, L"Parse"}, + {0xea18d121, L"Choose"}, {0xebfef69c, L"Replace"}, + {0xf5ad782b, L"Left"}, {0xf7bb2248, L"Ltrim"}, +}; + +struct XFA_FMSOMMethod { + uint32_t m_uHash; + const FX_WCHAR* m_wsSomMethodName; + FX_DWORD m_dParameters; +}; +const XFA_FMSOMMethod gs_FMSomMethods[] = { + {0x00000068, L"h", 0x01}, + {0x00000077, L"w", 0x01}, + {0x00000078, L"x", 0x01}, + {0x00000079, L"y", 0x01}, + {0x05eb5b0f, L"pageSpan", 0x01}, + {0x10f1b1bd, L"page", 0x01}, + {0x3bf1c2a5, L"absPageSpan", 0x01}, + {0x3c752495, L"verify", 0x0d}, + {0x44c352ad, L"formNodes", 0x01}, + {0x5775c2cc, L"absPageInBatch", 0x01}, + {0x5ee00996, L"setElement", 0x01}, + {0x7033bfd5, L"insert", 0x03}, + {0x8c5feb32, L"sheetInBatch", 0x01}, + {0x8f3a8379, L"sheet", 0x01}, + {0x92dada4f, L"saveFilteredXML", 0x01}, + {0x9cab7cae, L"remove", 0x01}, + {0xa68635f1, L"sign", 0x61}, + {0xaac241c8, L"isRecordGroup", 0x01}, + {0xd8ed1467, L"clear", 0x01}, + {0xda12e518, L"append", 0x01}, + {0xe74f0653, L"absPage", 0x01}, +}; + +} // namespace + +CFX_WideStringC XFA_FM_EXPTypeToString( + XFA_FM_SimpleExpressionType simpleExpType) { + return gs_lpStrExpFuncName[simpleExpType]; +} + +CXFA_FMSimpleExpression::CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op) + : m_line(line), m_op(op) {} + +void CXFA_FMSimpleExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + +void CXFA_FMSimpleExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} + +XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const { + return m_op; +} + +CXFA_FMNullExpression::CXFA_FMNullExpression(FX_DWORD line) + : CXFA_FMSimpleExpression(line, TOKnull) {} + +void CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"null"); +} + +CXFA_FMNumberExpression::CXFA_FMNumberExpression(FX_DWORD line, + CFX_WideStringC wsNumber) + : CXFA_FMSimpleExpression(line, TOKnumber), m_wsNumber(wsNumber) {} + +void CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << m_wsNumber; +} + +CXFA_FMStringExpression::CXFA_FMStringExpression(FX_DWORD line, + CFX_WideStringC wsString) + : CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {} + +void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + CFX_WideString tempStr = m_wsString; + if (tempStr.GetLength() > 2) { + javascript.AppendChar(L'\"'); + FX_WCHAR oneChar; + for (int16_t i = 1; i < tempStr.GetLength() - 1; i++) { + oneChar = tempStr[i]; + switch (oneChar) { + case L'\"': { + i++; + javascript << FX_WSTRC(L"\\\""); + } break; + case 0x0d: + break; + case 0x0a: { + javascript << FX_WSTRC(L"\\n"); + } break; + default: { javascript.AppendChar(oneChar); } break; + } + } + javascript.AppendChar(L'\"'); + } else { + javascript << tempStr; + } +} + +CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( + FX_DWORD line, + CFX_WideStringC wsIdentifier) + : CXFA_FMSimpleExpression(line, TOKidentifier), + m_wsIdentifier(wsIdentifier) {} + +void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { + CFX_WideString tempStr = m_wsIdentifier; + if (tempStr.Equal(FX_WSTRC(L"$"))) { + tempStr = FX_WSTRC(L"this"); + } else if (tempStr.Equal(FX_WSTRC(L"!"))) { + tempStr = FX_WSTRC(L"xfa.datasets"); + } else if (tempStr.Equal(FX_WSTRC(L"$data"))) { + tempStr = FX_WSTRC(L"xfa.datasets.data"); + } else if (tempStr.Equal(FX_WSTRC(L"$event"))) { + tempStr = FX_WSTRC(L"xfa.event"); + } else if (tempStr.Equal(FX_WSTRC(L"$form"))) { + tempStr = FX_WSTRC(L"xfa.form"); + } else if (tempStr.Equal(FX_WSTRC(L"$host"))) { + tempStr = FX_WSTRC(L"xfa.host"); + } else if (tempStr.Equal(FX_WSTRC(L"$layout"))) { + tempStr = FX_WSTRC(L"xfa.layout"); + } else if (tempStr.Equal(FX_WSTRC(L"$template"))) { + tempStr = FX_WSTRC(L"xfa.template"); + } else if (tempStr[0] == L'!') { + tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1); + } + javascript << tempStr; +} + +CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp) + : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {} + +void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + +CXFA_FMBinExpression::CXFA_FMBinExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMSimpleExpression(line, op), m_pExp1(pExp1), m_pExp2(pExp2) {} + +void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + +CXFA_FMAssignExpression::CXFA_FMAssignExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"if ("); + javascript << gs_lpStrExpFuncName[ISFMOBJECT]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L"))\n{\n"); + javascript << gs_lpStrExpFuncName[ASSIGN]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L");\n}\n"); + CFX_WideTextBuf tempExp1; + m_pExp1->ToJavaScript(tempExp1); + if (m_pExp1->GetOperatorToken() == TOKidentifier && + tempExp1.GetWideString() != FX_WSTRC(L"this")) { + javascript << FX_WSTRC(L"else\n{\n"); + javascript << tempExp1; + javascript << FX_WSTRC(L" = "); + javascript << gs_lpStrExpFuncName[ASSIGN]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L");\n}\n"); + } +} + +void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"if ("); + javascript << gs_lpStrExpFuncName[ISFMOBJECT]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L"))\n{\n"); + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = "); + javascript << gs_lpStrExpFuncName[ASSIGN]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L");\n}\n"); + CFX_WideTextBuf tempExp1; + m_pExp1->ToJavaScript(tempExp1); + if (m_pExp1->GetOperatorToken() == TOKidentifier && + tempExp1.GetWideString() != FX_WSTRC(L"this")) { + javascript << FX_WSTRC(L"else\n{\n"); + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << FX_WSTRC(L" = "); + javascript << tempExp1; + javascript << FX_WSTRC(L" = "); + javascript << gs_lpStrExpFuncName[ASSIGN]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L");\n}\n"); + } +} + +CXFA_FMLogicalOrExpression::CXFA_FMLogicalOrExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[LOGICALOR]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMLogicalAndExpression::CXFA_FMLogicalAndExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[LOGICALAND]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMEqualityExpression::CXFA_FMEqualityExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + switch (m_op) { + case TOKeq: + case TOKkseq: + javascript << gs_lpStrExpFuncName[EQUALITY]; + break; + case TOKne: + case TOKksne: + javascript << gs_lpStrExpFuncName[NOTEQUALITY]; + break; + default: + FXSYS_assert(FALSE); + break; + } + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMRelationalExpression::CXFA_FMRelationalExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + switch (m_op) { + case TOKlt: + case TOKkslt: + javascript << gs_lpStrExpFuncName[LESS]; + break; + case TOKgt: + case TOKksgt: + javascript << gs_lpStrExpFuncName[GREATER]; + break; + case TOKle: + case TOKksle: + javascript << gs_lpStrExpFuncName[LESSEQUAL]; + break; + case TOKge: + case TOKksge: + javascript << gs_lpStrExpFuncName[GREATEREQUAL]; + break; + default: + FXSYS_assert(FALSE); + break; + } + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMAdditiveExpression::CXFA_FMAdditiveExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + switch (m_op) { + case TOKplus: + javascript << gs_lpStrExpFuncName[PLUS]; + break; + case TOKminus: + javascript << gs_lpStrExpFuncName[MINUS]; + break; + default: + FXSYS_assert(FALSE); + break; + } + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMMultiplicativeExpression::CXFA_FMMultiplicativeExpression( + FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2) + : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + +void CXFA_FMMultiplicativeExpression::ToJavaScript( + CFX_WideTextBuf& javascript) { + switch (m_op) { + case TOKmul: + javascript << gs_lpStrExpFuncName[MULTIPLE]; + break; + case TOKdiv: + javascript << gs_lpStrExpFuncName[DIVIDE]; + break; + default: + FXSYS_assert(FALSE); + break; + } + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMPosExpression::CXFA_FMPosExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExp) + : CXFA_FMUnaryExpression(line, TOKplus, pExp) {} + +void CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[POSITIVE]; + javascript << FX_WSTRC(L"("); + m_pExp->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMNegExpression::CXFA_FMNegExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExp) + : CXFA_FMUnaryExpression(line, TOKminus, pExp) {} + +void CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[NEGATIVE]; + javascript << FX_WSTRC(L"("); + m_pExp->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMNotExpression::CXFA_FMNotExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExp) + : CXFA_FMUnaryExpression(line, TOKksnot, pExp) {} + +void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[NOT]; + javascript << FX_WSTRC(L"("); + m_pExp->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMCallExpression::CXFA_FMCallExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExp, + CFX_PtrArray* 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(); + delete m_pArguments; + } +} + +bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) { + uint32_t uHash = FX_HashCode_String_GetW(funcName->GetBuffer(), + funcName->GetLength(), TRUE); + const XFA_FMBuildInFunc* pEnd = g_BuildInFuncs + FX_ArraySize(g_BuildInFuncs); + const XFA_FMBuildInFunc* pFunc = + std::lower_bound(g_BuildInFuncs, pEnd, uHash, + [](const XFA_FMBuildInFunc& func, uint32_t hash) { + return func.m_uHash < hash; + }); + if (pFunc < pEnd && uHash == pFunc->m_uHash) { + funcName->Clear(); + *funcName << pFunc->m_buildinfunc; + return true; + } + return false; +} + +FX_DWORD CXFA_FMCallExpression::IsMethodWithObjParam( + const CFX_WideStringC& methodName) { + int32_t iLength = methodName.GetLength(); + uint32_t uHash = FX_HashCode_String_GetW(methodName.GetPtr(), iLength); + XFA_FMSOMMethod somMethodWithObjPara; + FX_DWORD parameters = 0x00; + int32_t iStart = 0, + iEnd = (sizeof(gs_FMSomMethods) / sizeof(gs_FMSomMethods[0])) - 1; + int32_t iMid = (iStart + iEnd) / 2; + do { + iMid = (iStart + iEnd) / 2; + somMethodWithObjPara = gs_FMSomMethods[iMid]; + if (uHash == somMethodWithObjPara.m_uHash) { + parameters = somMethodWithObjPara.m_dParameters; + break; + } else if (uHash < somMethodWithObjPara.m_uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return parameters; +} + +void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + CFX_WideTextBuf funcName; + m_pExp->ToJavaScript(funcName); + if (m_bIsSomMethod) { + javascript << funcName; + javascript << FX_WSTRC(L"("); + if (m_pArguments) { + FX_DWORD methodPara = IsMethodWithObjParam(funcName.GetWideString()); + if (methodPara > 0) { + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + if ((methodPara & (0x01 << i)) > 0) { + javascript << gs_lpStrExpFuncName[GETFMJSOBJ]; + } else { + javascript << gs_lpStrExpFuncName[GETFMVALUE]; + } + javascript << FX_WSTRC(L"("); + CXFA_FMSimpleExpression* e = + reinterpret_cast<CXFA_FMSimpleExpression*>( + m_pArguments->GetAt(i)); + e->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + if (i + 1 < m_pArguments->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + } else { + 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)); + e->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); + if (i + 1 < m_pArguments->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + } + } + javascript << FX_WSTRC(L")"); + } else { + bool isEvalFunc = false; + bool isExistsFunc = false; + if (IsBuildInFunc(&funcName)) { + if (funcName.GetWideString() == 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")) { + isExistsFunc = true; + javascript << gs_lpStrExpFuncName[CALL]; + javascript << funcName; + } else { + javascript << gs_lpStrExpFuncName[CALL]; + javascript << funcName; + } + } else { + javascript << funcName; + } + javascript << FX_WSTRC(L"("); + 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)); + javascript << FX_WSTRC(L"return "); + e->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n}\n"); + } else { + javascript << FX_WSTRC(L"return 0;\n}\n"); + } + javascript << FX_WSTRC( + 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)); + e->ToJavaScript(javascript); + if (i + 1 < m_pArguments->GetSize()) { + javascript << FX_WSTRC(L", "); + } + } + } + javascript << FX_WSTRC(L")"); + if (isEvalFunc) { + javascript << FX_WSTRC(L")"); + } + } +} + +CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( + FX_DWORD line, + CXFA_FMSimpleExpression* pAccessor, + XFA_FM_TOKEN op, + CFX_WideStringC wsIdentifier, + CXFA_FMSimpleExpression* pIndexExp) + : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), + m_wsIdentifier(wsIdentifier) {} + +void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[DOT]; + javascript << FX_WSTRC(L"("); + if (m_pExp1) { + m_pExp1->ToJavaScript(javascript); + } else { + javascript << FX_WSTRC(L"null"); + } + javascript << FX_WSTRC(L", "); + javascript << FX_WSTRC(L"\""); + if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { + m_pExp1->ToJavaScript(javascript); + } + javascript << FX_WSTRC(L"\", "); + if (m_op == TOKdotscream) { + javascript << FX_WSTRC(L"\"#"); + javascript << m_wsIdentifier; + javascript << FX_WSTRC(L"\", "); + } else if (m_op == TOKdotstar) { + javascript << FX_WSTRC(L"\"*\", "); + } else if (m_op == TOKcall) { + javascript << FX_WSTRC(L"\"\", "); + } else { + javascript << FX_WSTRC(L"\""); + javascript << m_wsIdentifier; + javascript << FX_WSTRC(L"\", "); + } + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMIndexExpression::CXFA_FMIndexExpression( + FX_DWORD line, + XFA_FM_AccessorIndex accessorIndex, + CXFA_FMSimpleExpression* pIndexExp, + FX_BOOL bIsStarIndex) + : CXFA_FMUnaryExpression(line, TOKlbracket, pIndexExp), + m_accessorIndex(accessorIndex), + m_bIsStarIndex(bIsStarIndex) {} + +void CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + switch (m_accessorIndex) { + case ACCESSOR_NO_INDEX: + javascript << FX_WSTRC(L"0"); + break; + case ACCESSOR_NO_RELATIVEINDEX: + javascript << FX_WSTRC(L"1"); + break; + case ACCESSOR_POSITIVE_INDEX: + javascript << FX_WSTRC(L"2"); + break; + case ACCESSOR_NEGATIVE_INDEX: + javascript << FX_WSTRC(L"3"); + break; + default: + javascript << FX_WSTRC(L"0"); + } + if (!m_bIsStarIndex) { + javascript << FX_WSTRC(L", "); + if (m_pExp) { + m_pExp->ToJavaScript(javascript); + } else { + javascript << FX_WSTRC(L"0"); + } + } +} + +CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( + FX_DWORD line, + CXFA_FMSimpleExpression* pAccessor, + XFA_FM_TOKEN op, + CFX_WideStringC wsIdentifier, + CXFA_FMSimpleExpression* pIndexExp) + : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), + m_wsIdentifier(wsIdentifier) {} + +void CXFA_FMDotDotAccessorExpression::ToJavaScript( + CFX_WideTextBuf& javascript) { + javascript << gs_lpStrExpFuncName[DOTDOT]; + javascript << FX_WSTRC(L"("); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L", "); + javascript << FX_WSTRC(L"\""); + if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { + m_pExp1->ToJavaScript(javascript); + } + javascript << FX_WSTRC(L"\", "); + javascript << FX_WSTRC(L"\""); + javascript << m_wsIdentifier; + javascript << FX_WSTRC(L"\", "); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L")"); +} + +CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression( + FX_DWORD line, + CXFA_FMSimpleExpression* pAccessorExp1, + CXFA_FMSimpleExpression* pCallExp) + : CXFA_FMBinExpression(line, TOKdot, pAccessorExp1, pCallExp) {} + +void CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + javascript << FX_WSTRC(L"(\nfunction ()\n{\n"); + javascript << FX_WSTRC(L"var method_return_value = null;\n"); + javascript << FX_WSTRC(L"var accessor_object = "); + m_pExp1->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n"); + javascript << FX_WSTRC(L"if ("); + javascript << gs_lpStrExpFuncName[ISFMARRAY]; + javascript << FX_WSTRC(L"(accessor_object))\n{\n"); + javascript << FX_WSTRC( + L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); + javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n}\n}\n"); + javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); + m_pExp2->ToJavaScript(javascript); + javascript << FX_WSTRC(L";\n}\n"); + javascript << FX_WSTRC(L"return method_return_value;\n"); + javascript << FX_WSTRC(L"}\n).call(this)"); +} diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.h b/xfa/fxfa/fm2js/xfa_simpleexpression.h new file mode 100644 index 0000000000..9098b39824 --- /dev/null +++ b/xfa/fxfa/fm2js/xfa_simpleexpression.h @@ -0,0 +1,292 @@ +// 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_FM2JS_XFA_SIMPLEEXPRESSION_H_ +#define XFA_FXFA_FM2JS_XFA_SIMPLEEXPRESSION_H_ + +#include <memory> + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxfa/fm2js/xfa_lexer.h" + +#define RUNTIMEFUNCTIONRETURNVALUE \ + (FX_WSTRC(L"foxit_xfa_formcalc_runtime_func_return_value")) +#define EXCLAMATION_IN_IDENTIFIER \ + (FX_WSTRC(L"foxit_xfa_formcalc__exclamation__")) + +enum XFA_FM_SimpleExpressionType { + ASSIGN, + LOGICALOR, + LOGICALAND, + EQUALITY, + NOTEQUALITY, + LESS, + LESSEQUAL, + GREATER, + GREATEREQUAL, + PLUS, + MINUS, + MULTIPLE, + DIVIDE, + POSITIVE, + NEGATIVE, + NOT, + CALL, + DOT, + DOTDOT, + CONCATFMOBJECT, + ISFMOBJECT, + ISFMARRAY, + GETFMVALUE, + GETFMJSOBJ, + VARFILTER +}; + +CFX_WideStringC XFA_FM_EXPTypeToString( + XFA_FM_SimpleExpressionType simpleExpType); + +enum XFA_FM_AccessorIndex { + ACCESSOR_NO_INDEX, + ACCESSOR_NO_RELATIVEINDEX, + ACCESSOR_POSITIVE_INDEX, + ACCESSOR_NEGATIVE_INDEX +}; + +class CXFA_FMSimpleExpression { + public: + CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op); + virtual ~CXFA_FMSimpleExpression() {} + virtual void ToJavaScript(CFX_WideTextBuf& javascript); + virtual void ToImpliedReturnJS(CFX_WideTextBuf& javascript); + + XFA_FM_TOKEN GetOperatorToken() const; + + protected: + FX_DWORD m_line; + XFA_FM_TOKEN m_op; +}; + +class CXFA_FMNullExpression : public CXFA_FMSimpleExpression { + public: + explicit CXFA_FMNullExpression(FX_DWORD line); + ~CXFA_FMNullExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMNumberExpression : public CXFA_FMSimpleExpression { + public: + CXFA_FMNumberExpression(FX_DWORD line, CFX_WideStringC wsNumber); + ~CXFA_FMNumberExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + CFX_WideStringC m_wsNumber; +}; + +class CXFA_FMStringExpression : public CXFA_FMSimpleExpression { + public: + CXFA_FMStringExpression(FX_DWORD line, CFX_WideStringC wsString); + ~CXFA_FMStringExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + CFX_WideStringC m_wsString; +}; + +class CXFA_FMIdentifierExpressionn : public CXFA_FMSimpleExpression { + public: + CXFA_FMIdentifierExpressionn(FX_DWORD line, CFX_WideStringC wsIdentifier); + ~CXFA_FMIdentifierExpressionn() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + CFX_WideStringC m_wsIdentifier; +}; + +class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression { + public: + CXFA_FMUnaryExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + protected: + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp; +}; + +class CXFA_FMBinExpression : public CXFA_FMSimpleExpression { + public: + CXFA_FMBinExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + protected: + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp2; +}; + +class CXFA_FMAssignExpression : public CXFA_FMBinExpression { + public: + CXFA_FMAssignExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMAssignExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMLogicalOrExpression : public CXFA_FMBinExpression { + public: + CXFA_FMLogicalOrExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMLogicalOrExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMLogicalAndExpression : public CXFA_FMBinExpression { + public: + CXFA_FMLogicalAndExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMLogicalAndExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMEqualityExpression : public CXFA_FMBinExpression { + public: + CXFA_FMEqualityExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMEqualityExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMRelationalExpression : public CXFA_FMBinExpression { + public: + CXFA_FMRelationalExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMRelationalExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMAdditiveExpression : public CXFA_FMBinExpression { + public: + CXFA_FMAdditiveExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMAdditiveExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMMultiplicativeExpression : public CXFA_FMBinExpression { + public: + CXFA_FMMultiplicativeExpression(FX_DWORD line, + XFA_FM_TOKEN op, + CXFA_FMSimpleExpression* pExp1, + CXFA_FMSimpleExpression* pExp2); + ~CXFA_FMMultiplicativeExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMPosExpression : public CXFA_FMUnaryExpression { + public: + CXFA_FMPosExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); + ~CXFA_FMPosExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMNegExpression : public CXFA_FMUnaryExpression { + public: + CXFA_FMNegExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); + ~CXFA_FMNegExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMNotExpression : public CXFA_FMUnaryExpression { + public: + CXFA_FMNotExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); + ~CXFA_FMNotExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +class CXFA_FMCallExpression : public CXFA_FMUnaryExpression { + public: + CXFA_FMCallExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pExp, + CFX_PtrArray* pArguments, + FX_BOOL bIsSomMethod); + ~CXFA_FMCallExpression() override; + bool IsBuildInFunc(CFX_WideTextBuf* funcName); + FX_DWORD IsMethodWithObjParam(const CFX_WideStringC& methodName); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + FX_BOOL m_bIsSomMethod; + CFX_PtrArray* m_pArguments; +}; + +class CXFA_FMDotAccessorExpression : public CXFA_FMBinExpression { + public: + CXFA_FMDotAccessorExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pAccessor, + XFA_FM_TOKEN op, + CFX_WideStringC wsIdentifier, + CXFA_FMSimpleExpression* pIndexExp); + ~CXFA_FMDotAccessorExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + CFX_WideStringC m_wsIdentifier; +}; + +class CXFA_FMIndexExpression : public CXFA_FMUnaryExpression { + public: + CXFA_FMIndexExpression(FX_DWORD line, + XFA_FM_AccessorIndex accessorIndex, + CXFA_FMSimpleExpression* pIndexExp, + FX_BOOL bIsStarIndex); + ~CXFA_FMIndexExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + XFA_FM_AccessorIndex m_accessorIndex; + FX_BOOL m_bIsStarIndex; +}; + +class CXFA_FMDotDotAccessorExpression : public CXFA_FMBinExpression { + public: + CXFA_FMDotDotAccessorExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pAccessor, + XFA_FM_TOKEN op, + CFX_WideStringC wsIdentifier, + CXFA_FMSimpleExpression* pIndexExp); + ~CXFA_FMDotDotAccessorExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; + + private: + CFX_WideStringC m_wsIdentifier; +}; + +class CXFA_FMMethodCallExpression : public CXFA_FMBinExpression { + public: + CXFA_FMMethodCallExpression(FX_DWORD line, + CXFA_FMSimpleExpression* pAccessorExp1, + CXFA_FMSimpleExpression* pCallExp); + ~CXFA_FMMethodCallExpression() override {} + void ToJavaScript(CFX_WideTextBuf& javascript) override; +}; + +#endif // XFA_FXFA_FM2JS_XFA_SIMPLEEXPRESSION_H_ diff --git a/xfa/fxfa/parser/xfa_basic_data.cpp b/xfa/fxfa/parser/xfa_basic_data.cpp new file mode 100644 index 0000000000..58e71debd3 --- /dev/null +++ b/xfa/fxfa/parser/xfa_basic_data.cpp @@ -0,0 +1,7333 @@ +// 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/fxfa/parser/xfa_basic_data.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_localemgr.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_script_datawindow.h" +#include "xfa/fxfa/parser/xfa_script_eventpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_logpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +const XFA_ATTRIBUTEENUMINFO g_XFAEnumData[] = { + {0x2a, L"*", XFA_ATTRIBUTEENUM_Asterisk}, + {0x2f, L"/", XFA_ATTRIBUTEENUM_Slash}, + {0x5c, L"\\", XFA_ATTRIBUTEENUM_Backslash}, + {0x239bd, L"on", XFA_ATTRIBUTEENUM_On}, + {0x25356, L"tb", XFA_ATTRIBUTEENUM_Tb}, + {0x25885, L"up", XFA_ATTRIBUTEENUM_Up}, + {0x91b281, L"metaData", XFA_ATTRIBUTEENUM_MetaData}, + {0x1f8dedb, L"delegate", XFA_ATTRIBUTEENUM_Delegate}, + {0x2a6c55a, L"postSubmit", XFA_ATTRIBUTEENUM_PostSubmit}, + {0x31b19c1, L"name", XFA_ATTRIBUTEENUM_Name}, + {0x378a38a, L"cross", XFA_ATTRIBUTEENUM_Cross}, + {0x3848b3f, L"next", XFA_ATTRIBUTEENUM_Next}, + {0x48b6670, L"none", XFA_ATTRIBUTEENUM_None}, + {0x51aafe5, L"shortEdge", XFA_ATTRIBUTEENUM_ShortEdge}, + {0x55264c4, L"1mod10_1mod11", XFA_ATTRIBUTEENUM_1mod10_1mod11}, + {0x5a5c519, L"height", XFA_ATTRIBUTEENUM_Height}, + {0x89ce549, L"crossDiagonal", XFA_ATTRIBUTEENUM_CrossDiagonal}, + {0x9f9d0f9, L"all", XFA_ATTRIBUTEENUM_All}, + {0x9f9db48, L"any", XFA_ATTRIBUTEENUM_Any}, + {0xa126261, L"toRight", XFA_ATTRIBUTEENUM_ToRight}, + {0xa36de29, L"matchTemplate", XFA_ATTRIBUTEENUM_MatchTemplate}, + {0xa48d040, L"dpl", XFA_ATTRIBUTEENUM_Dpl}, + {0xa559c05, L"invisible", XFA_ATTRIBUTEENUM_Invisible}, + {0xa7d48e3, L"fit", XFA_ATTRIBUTEENUM_Fit}, + {0xa8a8f80, L"width", XFA_ATTRIBUTEENUM_Width}, + {0xab466bb, L"preSubmit", XFA_ATTRIBUTEENUM_PreSubmit}, + {0xacc5785, L"ipl", XFA_ATTRIBUTEENUM_Ipl}, + {0xafab0f8, L"flateCompress", XFA_ATTRIBUTEENUM_FlateCompress}, + {0xb355816, L"med", XFA_ATTRIBUTEENUM_Med}, + {0xb69ef77, L"odd", XFA_ATTRIBUTEENUM_Odd}, + {0xb69f9bb, L"off", XFA_ATTRIBUTEENUM_Off}, + {0xb843dba, L"pdf", XFA_ATTRIBUTEENUM_Pdf}, + {0xbb912b8, L"row", XFA_ATTRIBUTEENUM_Row}, + {0xbedaf33, L"top", XFA_ATTRIBUTEENUM_Top}, + {0xc56afcc, L"xdp", XFA_ATTRIBUTEENUM_Xdp}, + {0xc56ba02, L"xfd", XFA_ATTRIBUTEENUM_Xfd}, + {0xc56ddf1, L"xml", XFA_ATTRIBUTEENUM_Xml}, + {0xc8b65f3, L"zip", XFA_ATTRIBUTEENUM_Zip}, + {0xc8b89d6, L"zpl", XFA_ATTRIBUTEENUM_Zpl}, + {0xf55d7ee, L"visible", XFA_ATTRIBUTEENUM_Visible}, + {0xfe3596a, L"exclude", XFA_ATTRIBUTEENUM_Exclude}, + {0x109d7ce7, L"mouseEnter", XFA_ATTRIBUTEENUM_MouseEnter}, + {0x10f1bc0c, L"pair", XFA_ATTRIBUTEENUM_Pair}, + {0x1154efe6, L"filter", XFA_ATTRIBUTEENUM_Filter}, + {0x125bc94b, L"moveLast", XFA_ATTRIBUTEENUM_MoveLast}, + {0x12e1f1f0, L"exportAndImport", XFA_ATTRIBUTEENUM_ExportAndImport}, + {0x13000c60, L"push", XFA_ATTRIBUTEENUM_Push}, + {0x138ee315, L"portrait", XFA_ATTRIBUTEENUM_Portrait}, + {0x14da2125, L"default", XFA_ATTRIBUTEENUM_Default}, + {0x157749a5, L"storedProc", XFA_ATTRIBUTEENUM_StoredProc}, + {0x16641198, L"stayBOF", XFA_ATTRIBUTEENUM_StayBOF}, + {0x16b2fc5b, L"stayEOF", XFA_ATTRIBUTEENUM_StayEOF}, + {0x17fad373, L"postPrint", XFA_ATTRIBUTEENUM_PostPrint}, + {0x193207d0, L"usCarrier", XFA_ATTRIBUTEENUM_UsCarrier}, + {0x193ade3e, L"right", XFA_ATTRIBUTEENUM_Right}, + {0x1bfc72d9, L"preOpen", XFA_ATTRIBUTEENUM_PreOpen}, + {0x1cc9317a, L"actual", XFA_ATTRIBUTEENUM_Actual}, + {0x1f31df1e, L"rest", XFA_ATTRIBUTEENUM_Rest}, + {0x1fb1bf14, L"topCenter", XFA_ATTRIBUTEENUM_TopCenter}, + {0x207de667, L"standardSymbol", XFA_ATTRIBUTEENUM_StandardSymbol}, + {0x2196a452, L"initialize", XFA_ATTRIBUTEENUM_Initialize}, + {0x23bd40c7, L"justifyAll", XFA_ATTRIBUTEENUM_JustifyAll}, + {0x247cf3e9, L"normal", XFA_ATTRIBUTEENUM_Normal}, + {0x25aa946b, L"landscape", XFA_ATTRIBUTEENUM_Landscape}, + {0x2739b5c9, L"nonInteractive", XFA_ATTRIBUTEENUM_NonInteractive}, + {0x27410f03, L"mouseExit", XFA_ATTRIBUTEENUM_MouseExit}, + {0x2854e62c, L"minus", XFA_ATTRIBUTEENUM_Minus}, + {0x287e936a, L"diagonalLeft", XFA_ATTRIBUTEENUM_DiagonalLeft}, + {0x2972a98f, L"simplexPaginated", XFA_ATTRIBUTEENUM_SimplexPaginated}, + {0x29d8225f, L"document", XFA_ATTRIBUTEENUM_Document}, + {0x2a9d3016, L"warning", XFA_ATTRIBUTEENUM_Warning}, + {0x2b35b6d9, L"auto", XFA_ATTRIBUTEENUM_Auto}, + {0x2c1653d9, L"below", XFA_ATTRIBUTEENUM_Below}, + {0x2c1f0540, L"bottomLeft", XFA_ATTRIBUTEENUM_BottomLeft}, + {0x2c44e816, L"bottomCenter", XFA_ATTRIBUTEENUM_BottomCenter}, + {0x2cd3e9f3, L"tcpl", XFA_ATTRIBUTEENUM_Tcpl}, + {0x2d08af85, L"text", XFA_ATTRIBUTEENUM_Text}, + {0x2dc478eb, L"grouping", XFA_ATTRIBUTEENUM_Grouping}, + {0x2ef3afdd, L"secureSymbol", XFA_ATTRIBUTEENUM_SecureSymbol}, + {0x2f2dd29a, L"preExecute", XFA_ATTRIBUTEENUM_PreExecute}, + {0x33c43dec, L"docClose", XFA_ATTRIBUTEENUM_DocClose}, + {0x33f25bb5, L"keyset", XFA_ATTRIBUTEENUM_Keyset}, + {0x34e363da, L"vertical", XFA_ATTRIBUTEENUM_Vertical}, + {0x361fa1b6, L"preSave", XFA_ATTRIBUTEENUM_PreSave}, + {0x36f1c6d8, L"preSign", XFA_ATTRIBUTEENUM_PreSign}, + {0x399f02b5, L"bottom", XFA_ATTRIBUTEENUM_Bottom}, + {0x3b0ab096, L"toTop", XFA_ATTRIBUTEENUM_ToTop}, + {0x3c752495, L"verify", XFA_ATTRIBUTEENUM_Verify}, + {0x3ce05d68, L"first", XFA_ATTRIBUTEENUM_First}, + {0x3ecead94, L"contentArea", XFA_ATTRIBUTEENUM_ContentArea}, + {0x40623b5b, L"solid", XFA_ATTRIBUTEENUM_Solid}, + {0x42c6cd8d, L"pessimistic", XFA_ATTRIBUTEENUM_Pessimistic}, + {0x43ddc6bf, L"duplexPaginated", XFA_ATTRIBUTEENUM_DuplexPaginated}, + {0x442f68c8, L"round", XFA_ATTRIBUTEENUM_Round}, + {0x45efb847, L"remerge", XFA_ATTRIBUTEENUM_Remerge}, + {0x46972265, L"ordered", XFA_ATTRIBUTEENUM_Ordered}, + {0x46f95531, L"percent", XFA_ATTRIBUTEENUM_Percent}, + {0x46fd25ae, L"even", XFA_ATTRIBUTEENUM_Even}, + {0x4731d6ba, L"exit", XFA_ATTRIBUTEENUM_Exit}, + {0x4977356b, L"toolTip", XFA_ATTRIBUTEENUM_ToolTip}, + {0x49b980ee, L"orderedOccurrence", XFA_ATTRIBUTEENUM_OrderedOccurrence}, + {0x4a7e2dfe, L"readOnly", XFA_ATTRIBUTEENUM_ReadOnly}, + {0x4c4e8acb, L"currency", XFA_ATTRIBUTEENUM_Currency}, + {0x4dcf25f8, L"concat", XFA_ATTRIBUTEENUM_Concat}, + {0x4febb826, L"Thai", XFA_ATTRIBUTEENUM_Thai}, + {0x50ef95b2, L"embossed", XFA_ATTRIBUTEENUM_Embossed}, + {0x516e35ce, L"formdata", XFA_ATTRIBUTEENUM_Formdata}, + {0x52fa6f0e, L"Greek", XFA_ATTRIBUTEENUM_Greek}, + {0x54034c2f, L"decimal", XFA_ATTRIBUTEENUM_Decimal}, + {0x542c7300, L"select", XFA_ATTRIBUTEENUM_Select}, + {0x551f0ae5, L"longEdge", XFA_ATTRIBUTEENUM_LongEdge}, + {0x55520a8a, L"protected", XFA_ATTRIBUTEENUM_Protected}, + {0x559f76f3, L"bottomRight", XFA_ATTRIBUTEENUM_BottomRight}, + {0x568cb500, L"zero", XFA_ATTRIBUTEENUM_Zero}, + {0x56bcecb7, L"forwardOnly", XFA_ATTRIBUTEENUM_ForwardOnly}, + {0x56bf456b, L"docReady", XFA_ATTRIBUTEENUM_DocReady}, + {0x573cb40c, L"hidden", XFA_ATTRIBUTEENUM_Hidden}, + {0x582e3424, L"include", XFA_ATTRIBUTEENUM_Include}, + {0x58a3dd29, L"dashed", XFA_ATTRIBUTEENUM_Dashed}, + {0x5955b22b, L"multiSelect", XFA_ATTRIBUTEENUM_MultiSelect}, + {0x598d5c53, L"inactive", XFA_ATTRIBUTEENUM_Inactive}, + {0x59c8f27d, L"embed", XFA_ATTRIBUTEENUM_Embed}, + {0x5e7555e8, L"static", XFA_ATTRIBUTEENUM_Static}, + {0x606d4def, L"onEntry", XFA_ATTRIBUTEENUM_OnEntry}, + {0x6195eafb, L"Cyrillic", XFA_ATTRIBUTEENUM_Cyrillic}, + {0x6491b0f3, L"nonBlank", XFA_ATTRIBUTEENUM_NonBlank}, + {0x67bef031, L"topRight", XFA_ATTRIBUTEENUM_TopRight}, + {0x67df5ebd, L"Hebrew", XFA_ATTRIBUTEENUM_Hebrew}, + {0x6aea98be, L"topLeft", XFA_ATTRIBUTEENUM_TopLeft}, + {0x6c51afc1, L"center", XFA_ATTRIBUTEENUM_Center}, + {0x7145e6bf, L"moveFirst", XFA_ATTRIBUTEENUM_MoveFirst}, + {0x7375465c, L"diamond", XFA_ATTRIBUTEENUM_Diamond}, + {0x7461aef4, L"pageOdd", XFA_ATTRIBUTEENUM_PageOdd}, + {0x75f8aeb2, L"1mod10", XFA_ATTRIBUTEENUM_1mod10}, + {0x76d708e0, L"Korean", XFA_ATTRIBUTEENUM_Korean}, + {0x789f14d7, L"aboveEmbedded", XFA_ATTRIBUTEENUM_AboveEmbedded}, + {0x792ea39f, L"zipCompress", XFA_ATTRIBUTEENUM_ZipCompress}, + {0x7a5b7193, L"numeric", XFA_ATTRIBUTEENUM_Numeric}, + {0x7abec0d2, L"circle", XFA_ATTRIBUTEENUM_Circle}, + {0x7afbba38, L"toBottom", XFA_ATTRIBUTEENUM_ToBottom}, + {0x7b95e661, L"inverted", XFA_ATTRIBUTEENUM_Inverted}, + {0x7baca2e3, L"update", XFA_ATTRIBUTEENUM_Update}, + {0x7eb5da2c, L"isoname", XFA_ATTRIBUTEENUM_Isoname}, + {0x7f6fd3d7, L"server", XFA_ATTRIBUTEENUM_Server}, + {0x814f82b5, L"position", XFA_ATTRIBUTEENUM_Position}, + {0x82deacf0, L"middleCenter", XFA_ATTRIBUTEENUM_MiddleCenter}, + {0x83a49dc6, L"optional", XFA_ATTRIBUTEENUM_Optional}, + {0x861a116f, L"usePrinterSetting", XFA_ATTRIBUTEENUM_UsePrinterSetting}, + {0x86701ce0, L"outline", XFA_ATTRIBUTEENUM_Outline}, + {0x8808385e, L"indexChange", XFA_ATTRIBUTEENUM_IndexChange}, + {0x891f4606, L"change", XFA_ATTRIBUTEENUM_Change}, + {0x89939f36, L"pageArea", XFA_ATTRIBUTEENUM_PageArea}, + {0x8b5c3b25, L"once", XFA_ATTRIBUTEENUM_Once}, + {0x8b5c6962, L"only", XFA_ATTRIBUTEENUM_Only}, + {0x8b90e1f2, L"open", XFA_ATTRIBUTEENUM_Open}, + {0x8bcfe96e, L"caption", XFA_ATTRIBUTEENUM_Caption}, + {0x8ce83ef8, L"raised", XFA_ATTRIBUTEENUM_Raised}, + {0x8d269cae, L"justify", XFA_ATTRIBUTEENUM_Justify}, + {0x8fd520dc, L"refAndDescendants", XFA_ATTRIBUTEENUM_RefAndDescendants}, + {0x9041d4b0, L"short", XFA_ATTRIBUTEENUM_Short}, + {0x90c94426, L"pageFront", XFA_ATTRIBUTEENUM_PageFront}, + {0x936beee5, L"monospace", XFA_ATTRIBUTEENUM_Monospace}, + {0x947fa00f, L"middle", XFA_ATTRIBUTEENUM_Middle}, + {0x9528a7b4, L"prePrint", XFA_ATTRIBUTEENUM_PrePrint}, + {0x959ab231, L"always", XFA_ATTRIBUTEENUM_Always}, + {0x96d61bf0, L"unknown", XFA_ATTRIBUTEENUM_Unknown}, + {0x997194ee, L"toLeft", XFA_ATTRIBUTEENUM_ToLeft}, + {0x9a83a3cd, L"above", XFA_ATTRIBUTEENUM_Above}, + {0x9d0d71c7, L"dashDot", XFA_ATTRIBUTEENUM_DashDot}, + {0x9df56f3e, L"gregorian", XFA_ATTRIBUTEENUM_Gregorian}, + {0x9f6723fd, L"Roman", XFA_ATTRIBUTEENUM_Roman}, + {0x9f693b21, L"mouseDown", XFA_ATTRIBUTEENUM_MouseDown}, + {0xa1429b36, L"symbol", XFA_ATTRIBUTEENUM_Symbol}, + {0xa5aa45cb, L"pageEven", XFA_ATTRIBUTEENUM_PageEven}, + {0xa68635f1, L"sign", XFA_ATTRIBUTEENUM_Sign}, + {0xa7315093, L"addNew", XFA_ATTRIBUTEENUM_AddNew}, + {0xa7a773fa, L"star", XFA_ATTRIBUTEENUM_Star}, + {0xa7d57b45, L"optimistic", XFA_ATTRIBUTEENUM_Optimistic}, + {0xa8077321, L"rl-tb", XFA_ATTRIBUTEENUM_Rl_tb}, + {0xa8f1468d, L"middleRight", XFA_ATTRIBUTEENUM_MiddleRight}, + {0xaa84a1f1, L"maintain", XFA_ATTRIBUTEENUM_Maintain}, + {0xab40b12c, L"package", XFA_ATTRIBUTEENUM_Package}, + {0xac8b4d85, L"SimplifiedChinese", XFA_ATTRIBUTEENUM_SimplifiedChinese}, + {0xadae6744, L"toCenter", XFA_ATTRIBUTEENUM_ToCenter}, + {0xb0129df1, L"back", XFA_ATTRIBUTEENUM_Back}, + {0xb0f088cf, L"unspecified", XFA_ATTRIBUTEENUM_Unspecified}, + {0xb1271067, L"batchOptimistic", XFA_ATTRIBUTEENUM_BatchOptimistic}, + {0xb18313a1, L"bold", XFA_ATTRIBUTEENUM_Bold}, + {0xb1833cad, L"both", XFA_ATTRIBUTEENUM_Both}, + {0xb221123f, L"butt", XFA_ATTRIBUTEENUM_Butt}, + {0xb40c36bf, L"client", XFA_ATTRIBUTEENUM_Client}, + {0xb56c7053, L"2mod10", XFA_ATTRIBUTEENUM_2mod10}, + {0xb683a345, L"imageOnly", XFA_ATTRIBUTEENUM_ImageOnly}, + {0xb7732dea, L"horizontal", XFA_ATTRIBUTEENUM_Horizontal}, + {0xb88652a4, L"dotted", XFA_ATTRIBUTEENUM_Dotted}, + {0xbb2f2880, L"userControl", XFA_ATTRIBUTEENUM_UserControl}, + {0xbbb79c5d, L"diagonalRight", XFA_ATTRIBUTEENUM_DiagonalRight}, + {0xbd077154, L"consumeData", XFA_ATTRIBUTEENUM_ConsumeData}, + {0xbd3fb11e, L"check", XFA_ATTRIBUTEENUM_Check}, + {0xbde9abda, L"data", XFA_ATTRIBUTEENUM_Data}, + {0xbf5a02d8, L"down", XFA_ATTRIBUTEENUM_Down}, + {0xbf7450ee, L"sansSerif", XFA_ATTRIBUTEENUM_SansSerif}, + {0xc02d649f, L"inline", XFA_ATTRIBUTEENUM_Inline}, + {0xc11a9e3a, L"TraditionalChinese", XFA_ATTRIBUTEENUM_TraditionalChinese}, + {0xc16169d8, L"warn", XFA_ATTRIBUTEENUM_Warn}, + {0xc16f071f, L"refOnly", XFA_ATTRIBUTEENUM_RefOnly}, + {0xc27c8ba5, L"interactiveForms", XFA_ATTRIBUTEENUM_InteractiveForms}, + {0xc2d1b15c, L"word", XFA_ATTRIBUTEENUM_Word}, + {0xc3621288, L"unordered", XFA_ATTRIBUTEENUM_Unordered}, + {0xc5251981, L"required", XFA_ATTRIBUTEENUM_Required}, + {0xc7088e7d, L"importOnly", XFA_ATTRIBUTEENUM_ImportOnly}, + {0xc72cf0e3, L"belowEmbedded", XFA_ATTRIBUTEENUM_BelowEmbedded}, + {0xc819cf07, L"Japanese", XFA_ATTRIBUTEENUM_Japanese}, + {0xcdce56b3, L"full", XFA_ATTRIBUTEENUM_Full}, + {0xce0122e3, L"rl-row", XFA_ATTRIBUTEENUM_Rl_row}, + {0xcf7d71f1, L"Vietnamese", XFA_ATTRIBUTEENUM_Vietnamese}, + {0xcfde3e09, L"EastEuropeanRoman", XFA_ATTRIBUTEENUM_EastEuropeanRoman}, + {0xd576d08e, L"mouseUp", XFA_ATTRIBUTEENUM_MouseUp}, + {0xd7a92904, L"exportOnly", XFA_ATTRIBUTEENUM_ExportOnly}, + {0xd8ed1467, L"clear", XFA_ATTRIBUTEENUM_Clear}, + {0xd95657a6, L"click", XFA_ATTRIBUTEENUM_Click}, + {0xd96c7de5, L"base64", XFA_ATTRIBUTEENUM_Base64}, + {0xd9f47f36, L"close", XFA_ATTRIBUTEENUM_Close}, + {0xdb075bde, L"host", XFA_ATTRIBUTEENUM_Host}, + {0xdb103411, L"global", XFA_ATTRIBUTEENUM_Global}, + {0xdb647188, L"blank", XFA_ATTRIBUTEENUM_Blank}, + {0xdb9be968, L"table", XFA_ATTRIBUTEENUM_Table}, + {0xdf590fbb, L"import", XFA_ATTRIBUTEENUM_Import}, + {0xe0e573fb, L"custom", XFA_ATTRIBUTEENUM_Custom}, + {0xe0ecc79a, L"middleLeft", XFA_ATTRIBUTEENUM_MiddleLeft}, + {0xe1452019, L"postExecute", XFA_ATTRIBUTEENUM_PostExecute}, + {0xe1911d98, L"radix", XFA_ATTRIBUTEENUM_Radix}, + {0xe25fa7b8, L"postOpen", XFA_ATTRIBUTEENUM_PostOpen}, + {0xe28dce7e, L"enter", XFA_ATTRIBUTEENUM_Enter}, + {0xe2c44de4, L"ignore", XFA_ATTRIBUTEENUM_Ignore}, + {0xe2cd8c61, L"lr-tb", XFA_ATTRIBUTEENUM_Lr_tb}, + {0xe2da8336, L"fantasy", XFA_ATTRIBUTEENUM_Fantasy}, + {0xe31d5396, L"italic", XFA_ATTRIBUTEENUM_Italic}, + {0xe7ada113, L"author", XFA_ATTRIBUTEENUM_Author}, + {0xe8e7cc18, L"toEdge", XFA_ATTRIBUTEENUM_ToEdge}, + {0xe97aa98b, L"choice", XFA_ATTRIBUTEENUM_Choice}, + {0xeafd2a38, L"disabled", XFA_ATTRIBUTEENUM_Disabled}, + {0xeb2b7972, L"crossHatch", XFA_ATTRIBUTEENUM_CrossHatch}, + {0xeb2db2d7, L"dataRef", XFA_ATTRIBUTEENUM_DataRef}, + {0xec35dc6e, L"dashDotDot", XFA_ATTRIBUTEENUM_DashDotDot}, + {0xef85d351, L"square", XFA_ATTRIBUTEENUM_Square}, + {0xf2102445, L"dynamic", XFA_ATTRIBUTEENUM_Dynamic}, + {0xf272c7be, L"manual", XFA_ATTRIBUTEENUM_Manual}, + {0xf2bbb64d, L"etched", XFA_ATTRIBUTEENUM_Etched}, + {0xf3b8fc6c, L"validationState", XFA_ATTRIBUTEENUM_ValidationState}, + {0xf42f2b81, L"cursive", XFA_ATTRIBUTEENUM_Cursive}, + {0xf54481d4, L"last", XFA_ATTRIBUTEENUM_Last}, + {0xf5ad782b, L"left", XFA_ATTRIBUTEENUM_Left}, + {0xf616da2e, L"link", XFA_ATTRIBUTEENUM_Link}, + {0xf6b4afb0, L"long", XFA_ATTRIBUTEENUM_Long}, + {0xf8636460, L"internationalCarrier", + XFA_ATTRIBUTEENUM_InternationalCarrier}, + {0xf9fb37ac, L"PDF1.3", XFA_ATTRIBUTEENUM_PDF1_3}, + {0xf9fb37af, L"PDF1.6", XFA_ATTRIBUTEENUM_PDF1_6}, + {0xfbce7f19, L"serif", XFA_ATTRIBUTEENUM_Serif}, + {0xfc82d695, L"postSave", XFA_ATTRIBUTEENUM_PostSave}, + {0xfcef86b5, L"ready", XFA_ATTRIBUTEENUM_Ready}, + {0xfd54fbb7, L"postSign", XFA_ATTRIBUTEENUM_PostSign}, + {0xfdc0aae2, L"Arabic", XFA_ATTRIBUTEENUM_Arabic}, + {0xfe06d2ca, L"error", XFA_ATTRIBUTEENUM_Error}, + {0xfefc4885, L"urlencoded", XFA_ATTRIBUTEENUM_Urlencoded}, + {0xff795ad2, L"lowered", XFA_ATTRIBUTEENUM_Lowered}, +}; +const int32_t g_iXFAEnumCount = + sizeof(g_XFAEnumData) / sizeof(XFA_ATTRIBUTEENUMINFO); +static const CXFA_Measurement g_XFAMeasurementData[] = { + CXFA_Measurement(0, XFA_UNIT_In), + CXFA_Measurement(0, XFA_UNIT_Pt), + CXFA_Measurement(5, XFA_UNIT_Mm), + CXFA_Measurement(0.25, XFA_UNIT_Mm), + CXFA_Measurement(-1, XFA_UNIT_Unknown), + CXFA_Measurement(0, XFA_UNIT_Angle), + CXFA_Measurement(10, XFA_UNIT_Pt), + CXFA_Measurement(360, XFA_UNIT_Angle), + CXFA_Measurement(0.5, XFA_UNIT_Pt), +}; +const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = { + {0x68, L"h", XFA_ATTRIBUTE_H, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x77, L"w", XFA_ATTRIBUTE_W, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x78, L"x", XFA_ATTRIBUTE_X, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x79, L"y", XFA_ATTRIBUTE_Y, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x21aed, L"id", XFA_ATTRIBUTE_Id, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x25363, L"to", XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Config, (void*)NULL}, + {0xcb0ac9, L"lineThrough", XFA_ATTRIBUTE_LineThrough, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x2282c73, L"hAlign", XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Left}, + {0x2c1c7f1, L"typeface", XFA_ATTRIBUTE_Typeface, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"Courier"}, + {0x3106c3a, L"beforeTarget", XFA_ATTRIBUTE_BeforeTarget, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x31b19c1, L"name", XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | + XFA_XDPPACKET_Template | XFA_XDPPACKET_Datasets | XFA_XDPPACKET_Form | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x3848b3f, L"next", XFA_ATTRIBUTE_Next, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_None}, + {0x43e349b, L"dataRowCount", XFA_ATTRIBUTE_DataRowCount, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x5518c25, L"break", XFA_ATTRIBUTE_Break, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Close}, + {0x5ce6195, L"vScrollPolicy", XFA_ATTRIBUTE_VScrollPolicy, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0x8c74ae9, L"fontHorizontalScale", XFA_ATTRIBUTE_FontHorizontalScale, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"100%"}, + {0x8d4f1c7, L"textIndent", XFA_ATTRIBUTE_TextIndent, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x97c1c65, L"context", XFA_ATTRIBUTE_Context, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_UNKNOWN, (void*)0}, + {0x9876578, L"trayOut", XFA_ATTRIBUTE_TrayOut, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xa2e3514, L"cap", XFA_ATTRIBUTE_Cap, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Square}, + {0xb3543a6, L"max", XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xb356ca4, L"min", XFA_ATTRIBUTE_Min, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, + {0xbb8df5d, L"ref", XFA_ATTRIBUTE_Ref, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | + XFA_XDPPACKET_Form, + (void*)NULL}, + {0xbb8f3df, L"rid", XFA_ATTRIBUTE_Rid, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xc080cd3, L"url", XFA_ATTRIBUTE_Url, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xc0811ed, L"use", XFA_ATTRIBUTE_Use, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xcfea02e, L"leftInset", XFA_ATTRIBUTE_LeftInset, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x1026c59d, L"widows", XFA_ATTRIBUTE_Widows, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x1059ec18, L"level", XFA_ATTRIBUTE_Level, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Config, (void*)0}, + {0x1356caf8, L"bottomInset", XFA_ATTRIBUTE_BottomInset, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x13a08bdb, L"overflowTarget", XFA_ATTRIBUTE_OverflowTarget, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x1414d431, L"allowMacro", XFA_ATTRIBUTE_AllowMacro, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x14a32d52, L"pagePosition", XFA_ATTRIBUTE_PagePosition, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Any}, + {0x1517dfa1, L"columnWidths", XFA_ATTRIBUTE_ColumnWidths, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x169134a1, L"overflowLeader", XFA_ATTRIBUTE_OverflowLeader, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x1b8dce3e, L"action", XFA_ATTRIBUTE_Action, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Include}, + {0x1e459b8f, L"nonRepudiation", XFA_ATTRIBUTE_NonRepudiation, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x1ec8ab2c, L"rate", XFA_ATTRIBUTE_Rate, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)50}, + {0x1ef3a64a, L"allowRichText", XFA_ATTRIBUTE_AllowRichText, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x2038c9b2, L"role", XFA_ATTRIBUTE_Role, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x20914367, L"overflowTrailer", XFA_ATTRIBUTE_OverflowTrailer, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x226ca8f1, L"operation", XFA_ATTRIBUTE_Operation, + XFA_ATTRIBUTETYPE_NOTSURE, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x24d85167, L"timeout", XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_SourceSet, (void*)NULL}, + {0x25764436, L"topInset", XFA_ATTRIBUTE_TopInset, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x25839852, L"access", XFA_ATTRIBUTE_Access, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Open}, + {0x268b7ec1, L"commandType", XFA_ATTRIBUTE_CommandType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, + (void*)XFA_ATTRIBUTEENUM_Unknown}, + {0x28dee6e9, L"format", XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x28e17e91, L"dataPrep", XFA_ATTRIBUTE_DataPrep, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_None}, + {0x292b88fe, L"widgetData", XFA_ATTRIBUTE_WidgetData, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, + {0x29418bb7, L"abbr", XFA_ATTRIBUTE_Abbr, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_LocaleSet, (void*)0}, + {0x2a82d99c, L"marginRight", XFA_ATTRIBUTE_MarginRight, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x2b5df51e, L"dataDescription", XFA_ATTRIBUTE_DataDescription, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_ConnectionSet, (void*)NULL}, + {0x2bb3f470, L"encipherOnly", XFA_ATTRIBUTE_EncipherOnly, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x2cd79033, L"kerningMode", XFA_ATTRIBUTE_KerningMode, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_None}, + {0x2ee7678f, L"rotate", XFA_ATTRIBUTE_Rotate, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 5)}, + {0x2f105f72, L"wordCharacterCount", XFA_ATTRIBUTE_WordCharacterCount, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)7}, + {0x2f16a382, L"type", XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x34ae103c, L"reserve", XFA_ATTRIBUTE_Reserve, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 4)}, + {0x3650557e, L"textLocation", XFA_ATTRIBUTE_TextLocation, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Below}, + {0x39cdb0a2, L"priority", XFA_ATTRIBUTE_Priority, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Custom}, + {0x3a0273a6, L"underline", XFA_ATTRIBUTE_Underline, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x3b582286, L"moduleWidth", XFA_ATTRIBUTE_ModuleWidth, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 3)}, + {0x3d123c26, L"hyphenate", XFA_ATTRIBUTE_Hyphenate, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x3e7af94f, L"listen", XFA_ATTRIBUTE_Listen, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_RefOnly}, + {0x4156ee3f, L"delimiter", XFA_ATTRIBUTE_Delimiter, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x42fed1fd, L"contentType", XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | + XFA_XDPPACKET_Datasets | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x453eaf38, L"startNew", XFA_ATTRIBUTE_StartNew, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x45a6daf8, L"eofAction", XFA_ATTRIBUTE_EofAction, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_MoveLast}, + {0x47cfa43a, L"allowNeutral", XFA_ATTRIBUTE_AllowNeutral, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x47d03490, L"connection", XFA_ATTRIBUTE_Connection, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x4873c601, L"baselineShift", XFA_ATTRIBUTE_BaselineShift, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x4b319767, L"overlinePeriod", XFA_ATTRIBUTE_OverlinePeriod, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_All}, + {0x4b8bc840, L"fracDigits", XFA_ATTRIBUTE_FracDigits, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)2}, + {0x4ef3d02c, L"orientation", XFA_ATTRIBUTE_Orientation, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Portrait}, + {0x4fdc3454, L"timeStamp", XFA_ATTRIBUTE_TimeStamp, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_XDP, (void*)NULL}, + {0x52666f1c, L"printCheckDigit", XFA_ATTRIBUTE_PrintCheckDigit, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x534729c9, L"marginLeft", XFA_ATTRIBUTE_MarginLeft, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x5392ea58, L"stroke", XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Solid}, + {0x5404d6df, L"moduleHeight", XFA_ATTRIBUTE_ModuleHeight, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 2)}, + {0x54fa722c, L"transferEncoding", XFA_ATTRIBUTE_TransferEncoding, + XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x552d9ad5, L"usage", XFA_ATTRIBUTE_Usage, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_ExportAndImport}, + {0x570ce835, L"presence", XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Visible}, + {0x5739d1ff, L"radixOffset", XFA_ATTRIBUTE_RadixOffset, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x577682ac, L"preserve", XFA_ATTRIBUTE_Preserve, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x58be2870, L"aliasNode", XFA_ATTRIBUTE_AliasNode, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, + {0x5a32e493, L"multiLine", XFA_ATTRIBUTE_MultiLine, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x5a50e9e6, L"version", XFA_ATTRIBUTE_Version, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x5ab23b6c, L"startChar", XFA_ATTRIBUTE_StartChar, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x5b707a35, L"scriptTest", XFA_ATTRIBUTE_ScriptTest, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Error}, + {0x5c054755, L"startAngle", XFA_ATTRIBUTE_StartAngle, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 5)}, + {0x5ec958c0, L"cursorType", XFA_ATTRIBUTE_CursorType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, + (void*)XFA_ATTRIBUTEENUM_ForwardOnly}, + {0x5f760b50, L"digitalSignature", XFA_ATTRIBUTE_DigitalSignature, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x60a61edd, L"codeType", XFA_ATTRIBUTE_CodeType, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x60d4c8b1, L"output", XFA_ATTRIBUTE_Output, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_ConnectionSet, (void*)NULL}, + {0x64110ab5, L"bookendTrailer", XFA_ATTRIBUTE_BookendTrailer, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x65e30c67, L"imagingBBox", XFA_ATTRIBUTE_ImagingBBox, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"none"}, + {0x66539c48, L"excludeInitialCap", XFA_ATTRIBUTE_ExcludeInitialCap, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x66642f8f, L"force", XFA_ATTRIBUTE_Force, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Config, (void*)NULL}, + {0x69aa2292, L"crlSign", XFA_ATTRIBUTE_CrlSign, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x6a3405dd, L"previous", XFA_ATTRIBUTE_Previous, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_None}, + {0x6a95c976, L"pushCharacterCount", XFA_ATTRIBUTE_PushCharacterCount, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)3}, + {0x6b6ddcfb, L"nullTest", XFA_ATTRIBUTE_NullTest, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Disabled}, + {0x6cfa828a, L"runAt", XFA_ATTRIBUTE_RunAt, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Client}, + {0x731e0665, L"spaceBelow", XFA_ATTRIBUTE_SpaceBelow, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x74788f8b, L"sweepAngle", XFA_ATTRIBUTE_SweepAngle, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 7)}, + {0x78bff531, L"numberOfCells", XFA_ATTRIBUTE_NumberOfCells, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0x79543055, L"letterSpacing", XFA_ATTRIBUTE_LetterSpacing, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x79975f2b, L"lockType", XFA_ATTRIBUTE_LockType, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_ReadOnly}, + {0x7a0cc471, L"passwordChar", XFA_ATTRIBUTE_PasswordChar, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"*"}, + {0x7a7cc341, L"vAlign", XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Top}, + {0x7b29630a, L"sourceBelow", XFA_ATTRIBUTE_SourceBelow, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, + (void*)XFA_ATTRIBUTEENUM_Update}, + {0x7b95e661, L"inverted", XFA_ATTRIBUTE_Inverted, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x7c2fd80b, L"mark", XFA_ATTRIBUTE_Mark, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Default}, + {0x7c2ff6ae, L"maxH", XFA_ATTRIBUTE_MaxH, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x7c2ff6bd, L"maxW", XFA_ATTRIBUTE_MaxW, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x7c732a66, L"truncate", XFA_ATTRIBUTE_Truncate, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x7d02356c, L"minH", XFA_ATTRIBUTE_MinH, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x7d02357b, L"minW", XFA_ATTRIBUTE_MinW, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x7d0b5fca, L"initial", XFA_ATTRIBUTE_Initial, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, + {0x7d9fd7c5, L"mode", XFA_ATTRIBUTE_Mode, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Config, (void*)XFA_ATTRIBUTEENUM_UsePrinterSetting}, + {0x7e7e845e, L"layout", XFA_ATTRIBUTE_Layout, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Position}, + {0x7f6fd3d7, L"server", XFA_ATTRIBUTE_Server, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x824f21b7, L"embedPDF", XFA_ATTRIBUTE_EmbedPDF, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x8340ea66, L"oddOrEven", XFA_ATTRIBUTE_OddOrEven, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Any}, + {0x836d4d7c, L"tabDefault", XFA_ATTRIBUTE_TabDefault, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x8855805f, L"contains", XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Datasets, (void*)XFA_ATTRIBUTEENUM_Data}, + {0x8a692521, L"rightInset", XFA_ATTRIBUTE_RightInset, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x8af2e657, L"maxChars", XFA_ATTRIBUTE_MaxChars, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x8b90e1f2, L"open", XFA_ATTRIBUTE_Open, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_UserControl}, + {0x8c99377e, L"relation", XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x8d181d61, L"wideNarrowRatio", XFA_ATTRIBUTE_WideNarrowRatio, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"3:1"}, + {0x8e1c2921, L"relevant", XFA_ATTRIBUTE_Relevant, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x8e29d794, L"signatureType", XFA_ATTRIBUTE_SignatureType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Filter}, + {0x8ec6204c, L"lineThroughPeriod", XFA_ATTRIBUTE_LineThroughPeriod, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_All}, + {0x8ed182d1, L"shape", XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Square}, + {0x8fa01790, L"tabStops", XFA_ATTRIBUTE_TabStops, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0x8fc36c0a, L"outputBelow", XFA_ATTRIBUTE_OutputBelow, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, + (void*)XFA_ATTRIBUTEENUM_Warn}, + {0x9041d4b0, L"short", XFA_ATTRIBUTE_Short, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0x907c7719, L"fontVerticalScale", XFA_ATTRIBUTE_FontVerticalScale, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"100%"}, + {0x94446dcc, L"thickness", XFA_ATTRIBUTE_Thickness, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 8)}, + {0x957fa006, L"commitOn", XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Select}, + {0x982bd892, L"remainCharacterCount", XFA_ATTRIBUTE_RemainCharacterCount, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)3}, + {0x98fd4d81, L"keyAgreement", XFA_ATTRIBUTE_KeyAgreement, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x99800d7a, L"errorCorrectionLevel", XFA_ATTRIBUTE_ErrorCorrectionLevel, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0x9a63da3d, L"upsMode", XFA_ATTRIBUTE_UpsMode, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_UsCarrier}, + {0x9cc17d75, L"mergeMode", XFA_ATTRIBUTE_MergeMode, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_ConsumeData}, + {0x9d833d75, L"circular", XFA_ATTRIBUTE_Circular, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0x9d8ee204, L"psName", XFA_ATTRIBUTE_PsName, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Config, (void*)NULL}, + {0x9dcc3ab3, L"trailer", XFA_ATTRIBUTE_Trailer, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xa0933954, L"unicodeRange", XFA_ATTRIBUTE_UnicodeRange, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Config, (void*)NULL}, + {0xa1b0d2f5, L"executeType", XFA_ATTRIBUTE_ExecuteType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Import}, + {0xa25a883d, L"duplexImposition", XFA_ATTRIBUTE_DuplexImposition, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_LongEdge}, + {0xa42ca1b7, L"trayIn", XFA_ATTRIBUTE_TrayIn, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xa433f001, L"bindingNode", XFA_ATTRIBUTE_BindingNode, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, + {0xa5340ff5, L"bofAction", XFA_ATTRIBUTE_BofAction, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_MoveFirst}, + {0xa5b410cf, L"save", XFA_ATTRIBUTE_Save, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0xa6118c89, L"targetType", XFA_ATTRIBUTE_TargetType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xa66404cb, L"keyEncipherment", XFA_ATTRIBUTE_KeyEncipherment, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xa6710262, L"credentialServerPolicy", + XFA_ATTRIBUTE_CredentialServerPolicy, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {0xa686975b, L"size", XFA_ATTRIBUTE_Size, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 6)}, + {0xa85e74f3, L"initialNumber", XFA_ATTRIBUTE_InitialNumber, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)1}, + {0xabef37e3, L"slope", XFA_ATTRIBUTE_Slope, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Backslash}, + {0xabfa6c4f, L"cSpace", XFA_ATTRIBUTE_CSpace, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"SRGB"}, + {0xac06e2b0, L"colSpan", XFA_ATTRIBUTE_ColSpan, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, + {0xadc4c77b, L"binding", XFA_ATTRIBUTE_Binding, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xaf754613, L"checksum", XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xb045fbc5, L"charEncoding", XFA_ATTRIBUTE_CharEncoding, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)L"UTF-8"}, + {0xb0e5485d, L"bind", XFA_ATTRIBUTE_Bind, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet, (void*)NULL}, + {0xb12128b7, L"textEntry", XFA_ATTRIBUTE_TextEntry, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0xb373a862, L"archive", XFA_ATTRIBUTE_Archive, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xb598a1f7, L"uuid", XFA_ATTRIBUTE_Uuid, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_XDP, (void*)NULL}, + {0xb5e49bf2, L"posture", XFA_ATTRIBUTE_Posture, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Normal}, + {0xb6b44172, L"after", XFA_ATTRIBUTE_After, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xb716467b, L"orphans", XFA_ATTRIBUTE_Orphans, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0xbc0c4695, L"qualifiedName", XFA_ATTRIBUTE_QualifiedName, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_UNKNOWN, (void*)NULL}, + {0xbc254332, L"usehref", XFA_ATTRIBUTE_Usehref, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xbc8fa350, L"locale", XFA_ATTRIBUTE_Locale, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xbd6e1d88, L"weight", XFA_ATTRIBUTE_Weight, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Normal}, + {0xbd96a0e9, L"underlinePeriod", XFA_ATTRIBUTE_UnderlinePeriod, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_All}, + {0xbde9abda, L"data", XFA_ATTRIBUTE_Data, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Link}, + {0xbe52dfbf, L"desc", XFA_ATTRIBUTE_Desc, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, (void*)NULL}, + {0xbe9ba472, L"numbered", XFA_ATTRIBUTE_Numbered, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, + {0xc035c6b1, L"dataColumnCount", XFA_ATTRIBUTE_DataColumnCount, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xc0ec9fa4, L"overline", XFA_ATTRIBUTE_Overline, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0xc2ba0923, L"urlPolicy", XFA_ATTRIBUTE_UrlPolicy, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xc2bd40fd, L"anchorType", XFA_ATTRIBUTE_AnchorType, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_TopLeft}, + {0xc39a88bd, L"labelRef", XFA_ATTRIBUTE_LabelRef, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xc3c1442f, L"bookendLeader", XFA_ATTRIBUTE_BookendLeader, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xc4547a08, L"maxLength", XFA_ATTRIBUTE_MaxLength, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*) - 1}, + {0xc4fed09b, L"accessKey", XFA_ATTRIBUTE_AccessKey, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xc5762157, L"cursorLocation", XFA_ATTRIBUTE_CursorLocation, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, + (void*)XFA_ATTRIBUTEENUM_Client}, + {0xc860f30a, L"delayedOpen", XFA_ATTRIBUTE_DelayedOpen, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_SourceSet, (void*)NULL}, + {0xc8da4da7, L"target", XFA_ATTRIBUTE_Target, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xca5dc27c, L"dataEncipherment", XFA_ATTRIBUTE_DataEncipherment, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xcb150479, L"afterTarget", XFA_ATTRIBUTE_AfterTarget, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xcbcaf66d, L"leader", XFA_ATTRIBUTE_Leader, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xcca7897e, L"picker", XFA_ATTRIBUTE_Picker, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Host}, + {0xcd7f7b54, L"from", XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config, (void*)NULL}, + {0xcea5e62c, L"baseProfile", XFA_ATTRIBUTE_BaseProfile, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Full}, + {0xd171b240, L"aspect", XFA_ATTRIBUTE_Aspect, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Fit}, + {0xd3c84d25, L"rowColumnRatio", XFA_ATTRIBUTE_RowColumnRatio, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xd4b01921, L"lineHeight", XFA_ATTRIBUTE_LineHeight, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 1)}, + {0xd4cc53f8, L"highlight", XFA_ATTRIBUTE_Highlight, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Inverted}, + {0xd50f903a, L"valueRef", XFA_ATTRIBUTE_ValueRef, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xd52482e0, L"maxEntries", XFA_ATTRIBUTE_MaxEntries, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Config, (void*)5}, + {0xd57c513c, L"dataLength", XFA_ATTRIBUTE_DataLength, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xd6128d8d, L"activity", XFA_ATTRIBUTE_Activity, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Click}, + {0xd6a39990, L"input", XFA_ATTRIBUTE_Input, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_ConnectionSet, (void*)NULL}, + {0xd6e27f1d, L"value", XFA_ATTRIBUTE_Value, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | + XFA_XDPPACKET_Template | XFA_XDPPACKET_Datasets | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xd70798c2, L"blankOrNotBlank", XFA_ATTRIBUTE_BlankOrNotBlank, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Any}, + {0xd861f8af, L"addRevocationInfo", XFA_ATTRIBUTE_AddRevocationInfo, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xd8f982bf, L"genericFamily", XFA_ATTRIBUTE_GenericFamily, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, + (void*)XFA_ATTRIBUTEENUM_Serif}, + {0xd996fa9b, L"hand", XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Even}, + {0xdb55fec5, L"href", XFA_ATTRIBUTE_Href, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xdc75676c, L"textEncoding", XFA_ATTRIBUTE_TextEncoding, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xde7f92ba, L"leadDigits", XFA_ATTRIBUTE_LeadDigits, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*) - 1}, + {0xe11a2cbc, L"permissions", XFA_ATTRIBUTE_Permissions, + XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)2}, + {0xe18b5659, L"spaceAbove", XFA_ATTRIBUTE_SpaceAbove, + XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0xe1a26b56, L"codeBase", XFA_ATTRIBUTE_CodeBase, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xe349d044, L"stock", XFA_ATTRIBUTE_Stock, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xe372ae97, L"isNull", XFA_ATTRIBUTE_IsNull, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Datasets, (void*)0}, + {0xe4c3a5e5, L"restoreState", XFA_ATTRIBUTE_RestoreState, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Manual}, + {0xe5c96d6a, L"excludeAllCaps", XFA_ATTRIBUTE_ExcludeAllCaps, + XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)0}, + {0xe64b1129, L"formatTest", XFA_ATTRIBUTE_FormatTest, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Warning}, + {0xe6f99487, L"hScrollPolicy", XFA_ATTRIBUTE_HScrollPolicy, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xe8dddf50, L"join", XFA_ATTRIBUTE_Join, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Square}, + {0xe8f118a8, L"keyCertSign", XFA_ATTRIBUTE_KeyCertSign, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xe948b9a8, L"radius", XFA_ATTRIBUTE_Radius, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0xe996b2fe, L"sourceAbove", XFA_ATTRIBUTE_SourceAbove, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, + (void*)XFA_ATTRIBUTEENUM_Warn}, + {0xea7090a0, L"override", XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xeb091003, L"classId", XFA_ATTRIBUTE_ClassId, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xeb511b54, L"disable", XFA_ATTRIBUTE_Disable, XFA_ATTRIBUTETYPE_Boolean, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, + {0xeda9017a, L"scope", XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_NOTSURE, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xf197844d, L"match", XFA_ATTRIBUTE_Match, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Once}, + {0xf2009339, L"placement", XFA_ATTRIBUTE_Placement, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Left}, + {0xf4ffce73, L"before", XFA_ATTRIBUTE_Before, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_Auto}, + {0xf531b059, L"writingScript", XFA_ATTRIBUTE_WritingScript, + XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, + (void*)XFA_ATTRIBUTEENUM_Asterisk}, + {0xf575ca75, L"endChar", XFA_ATTRIBUTE_EndChar, XFA_ATTRIBUTETYPE_Cdata, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, + {0xf6b47749, L"lock", XFA_ATTRIBUTE_Lock, XFA_ATTRIBUTETYPE_Integer, + XFA_XDPPACKET_Config, (void*)0}, + {0xf6b4afb0, L"long", XFA_ATTRIBUTE_Long, XFA_ATTRIBUTETYPE_Measure, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)(g_XFAMeasurementData + 0)}, + {0xf6b59543, L"intact", XFA_ATTRIBUTE_Intact, XFA_ATTRIBUTETYPE_Enum, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)XFA_ATTRIBUTEENUM_None}, + {0xf889e747, L"xdpContent", XFA_ATTRIBUTE_XdpContent, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, + {0xfea53ec6, L"decipherOnly", XFA_ATTRIBUTE_DecipherOnly, + XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + (void*)NULL}, +}; +const int32_t g_iXFAAttributeCount = + sizeof(g_XFAAttributeData) / sizeof(XFA_ATTRIBUTEINFO); +const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[] = { + {XFA_ELEMENT_SubformSet, XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Ordered}, + {XFA_ELEMENT_NumberPattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Numeric}, + {XFA_ELEMENT_KeyUsage, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_LabelPrinter, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Zpl}, + {XFA_ELEMENT_CalendarSymbols, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Gregorian}, + {XFA_ELEMENT_Barcode, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_Barcode, XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_None}, + {XFA_ELEMENT_TimePattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Med}, + {XFA_ELEMENT_BatchOutput, XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_None}, + {XFA_ELEMENT_SubjectDNs, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Issuers, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_EncryptionMethods, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Pattern, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_CrossHatch}, + {XFA_ELEMENT_Compress, XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_ImageOnly}, + {XFA_ELEMENT_Image, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Base64}, + {XFA_ELEMENT_TimeStamp, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Subform, XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Name}, + {XFA_ELEMENT_Handler, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Record, XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_Integer, + (void*)0}, + {XFA_ELEMENT_Command, XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_Integer, + (void*)30}, + {XFA_ELEMENT_DigestMethods, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_PageSet, XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_OrderedOccurrence}, + {XFA_ELEMENT_Equate, XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_Equate, XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_Traverse, XFA_ATTRIBUTE_Operation, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Next}, + {XFA_ELEMENT_Encodings, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Signing, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Oids, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Signature, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_PDF1_3}, + {XFA_ELEMENT_ExData, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_None}, + {XFA_ELEMENT_Linear, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_ToRight}, + {XFA_ELEMENT_CurrencySymbol, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Symbol}, + {XFA_ELEMENT_EquateRange, XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_EquateRange, XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_SignData, XFA_ATTRIBUTE_Operation, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Sign}, + {XFA_ELEMENT_DatePattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Med}, + {XFA_ELEMENT_Bind, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_None}, + {XFA_ELEMENT_Reasons, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_AppearanceFilter, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Form, XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_Cdata, + (void*)NULL}, + {XFA_ELEMENT_Value, XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_Boolean, + (void*)0}, + {XFA_ELEMENT_Calculate, XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Error}, + {XFA_ELEMENT_Connect, XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_Integer, + (void*)15}, + {XFA_ELEMENT_Submit, XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Xdp}, + {XFA_ELEMENT_Radial, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_ToEdge}, + {XFA_ELEMENT_LockDocument, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Optional}, + {XFA_ELEMENT_Occur, XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_Integer, (void*)1}, + {XFA_ELEMENT_NumberSymbol, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, + (void*)XFA_ATTRIBUTEENUM_Decimal}, +}; +const int32_t g_iXFANotsureCount = + sizeof(g_XFANotsureAttributes) / sizeof(XFA_NOTSUREATTRIBUTE); +const XFA_ELEMENTINFO g_XFAElementData[] = { + {0x23ee3, L"ps", XFA_ELEMENT_Ps, XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, + {0x25363, L"to", XFA_ELEMENT_To, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x2587e, L"ui", XFA_ELEMENT_Ui, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x1c648b, L"recordSet", XFA_ELEMENT_RecordSet, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_Node}, + {0x171428f, L"subsetBelow", XFA_ELEMENT_SubsetBelow, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x1a0776a, L"subformSet", XFA_ELEMENT_SubformSet, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x2340d70, L"adobeExtensionLevel", XFA_ELEMENT_AdobeExtensionLevel, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x2c1c7f1, L"typeface", XFA_ELEMENT_Typeface, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_Node}, + {0x5518c25, L"break", XFA_ELEMENT_Break, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x5fff523, L"fontInfo", XFA_ELEMENT_FontInfo, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x653a227, L"numberPattern", XFA_ELEMENT_NumberPattern, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0x65b4a05, L"dynamicRender", XFA_ELEMENT_DynamicRender, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x7e4362e, L"printScaling", XFA_ELEMENT_PrintScaling, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x7fe6d3a, L"checkButton", XFA_ELEMENT_CheckButton, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x80cf58f, L"datePatterns", XFA_ELEMENT_DatePatterns, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0x811929d, L"sourceSet", XFA_ELEMENT_SourceSet, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_ModelNode}, + {0x9f9d612, L"amd", XFA_ELEMENT_Amd, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x9f9efb6, L"arc", XFA_ELEMENT_Arc, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xa48835e, L"day", XFA_ELEMENT_Day, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_ContentNode}, + {0xa6328b8, L"era", XFA_ELEMENT_Era, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_ContentNode}, + {0xae6a0a0, L"jog", XFA_ELEMENT_Jog, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xb1b3d22, L"log", XFA_ELEMENT_Log, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xb35439e, L"map", XFA_ELEMENT_Map, + XFA_XDPPACKET_Config | XFA_XDPPACKET_SourceSet, XFA_OBJECTTYPE_Node}, + {0xb355301, L"mdp", XFA_ELEMENT_Mdp, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xb420438, L"breakBefore", XFA_ELEMENT_BreakBefore, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xb6a091c, L"oid", XFA_ELEMENT_Oid, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0xb84389f, L"pcl", XFA_ELEMENT_Pcl, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xb843dba, L"pdf", XFA_ELEMENT_Pdf, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xbb8df5d, L"ref", XFA_ELEMENT_Ref, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0xc080cd0, L"uri", XFA_ELEMENT_Uri, + XFA_XDPPACKET_Config | XFA_XDPPACKET_ConnectionSet, + XFA_OBJECTTYPE_TextNode}, + {0xc56afbf, L"xdc", XFA_ELEMENT_Xdc, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Xdc, XFA_OBJECTTYPE_ModelNode}, + {0xc56afcc, L"xdp", XFA_ELEMENT_Xdp, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc56b9ff, L"xfa", XFA_ELEMENT_Xfa, XFA_XDPPACKET_XDP, + XFA_OBJECTTYPE_ModelNode}, + {0xc56fcb7, L"xsl", XFA_ELEMENT_Xsl, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc8b89d6, L"zpl", XFA_ELEMENT_Zpl, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc9bae94, L"cache", XFA_ELEMENT_Cache, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xcb016be, L"margin", XFA_ELEMENT_Margin, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xe1378fe, L"keyUsage", XFA_ELEMENT_KeyUsage, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xfe3596a, L"exclude", XFA_ELEMENT_Exclude, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x10395ac7, L"choiceList", XFA_ELEMENT_ChoiceList, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x1059ec18, L"level", XFA_ELEMENT_Level, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x10874804, L"labelPrinter", XFA_ELEMENT_LabelPrinter, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, + {0x10c40e03, L"calendarSymbols", XFA_ELEMENT_CalendarSymbols, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0x10f1ea24, L"para", XFA_ELEMENT_Para, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x10f1ea37, L"part", XFA_ELEMENT_Part, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x1140975b, L"pdfa", XFA_ELEMENT_Pdfa, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x1154efe6, L"filter", XFA_ELEMENT_Filter, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x13f41de1, L"present", XFA_ELEMENT_Present, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x1827e6ea, L"pagination", XFA_ELEMENT_Pagination, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x18463707, L"encoding", XFA_ELEMENT_Encoding, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, + {0x185e41e2, L"event", XFA_ELEMENT_Event, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x1adb142d, L"whitespace", XFA_ELEMENT_Whitespace, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x1f3f64c3, L"defaultUi", XFA_ELEMENT_DefaultUi, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x204e87cb, L"dataModel", XFA_ELEMENT_DataModel, XFA_XDPPACKET_Datasets, + XFA_OBJECTTYPE_ModelNode}, + {0x2057b350, L"barcode", XFA_ELEMENT_Barcode, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x20596bad, L"timePattern", XFA_ELEMENT_TimePattern, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0x210b74d3, L"batchOutput", XFA_ELEMENT_BatchOutput, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x212ff0e2, L"enforce", XFA_ELEMENT_Enforce, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x21d351b4, L"currencySymbols", XFA_ELEMENT_CurrencySymbols, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0x21db83c5, L"addSilentPrint", XFA_ELEMENT_AddSilentPrint, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x22266258, L"rename", XFA_ELEMENT_Rename, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x226ca8f1, L"operation", XFA_ELEMENT_Operation, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, + {0x23e27b84, L"typefaces", XFA_ELEMENT_Typefaces, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_Node}, + {0x23f4aa75, L"subjectDNs", XFA_ELEMENT_SubjectDNs, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x240d5e8e, L"issuers", XFA_ELEMENT_Issuers, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x2457a033, L"signaturePseudoModel", XFA_ELEMENT_SignaturePseudoModel, + XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, + {0x24a52f8a, L"wsdlConnection", XFA_ELEMENT_WsdlConnection, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, + {0x254ebd07, L"debug", XFA_ELEMENT_Debug, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x2655c66a, L"delta", XFA_ELEMENT_Delta, XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_OrdinaryObject}, + {0x26c0daec, L"eraNames", XFA_ELEMENT_EraNames, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_Node}, + {0x273ab03b, L"modifyAnnots", XFA_ELEMENT_ModifyAnnots, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x27875bb4, L"startNode", XFA_ELEMENT_StartNode, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x285d0dbc, L"button", XFA_ELEMENT_Button, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x28dee6e9, L"format", XFA_ELEMENT_Format, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x2a23349e, L"border", XFA_ELEMENT_Border, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x2ae67f19, L"area", XFA_ELEMENT_Area, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContainerNode}, + {0x2c3c4c67, L"hyphenation", XFA_ELEMENT_Hyphenation, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x2d08af85, L"text", XFA_ELEMENT_Text, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x2d71b00f, L"time", XFA_ELEMENT_Time, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0x2f16a382, L"type", XFA_ELEMENT_Type, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x2fe057e9, L"overprint", XFA_ELEMENT_Overprint, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x302aee16, L"certificates", XFA_ELEMENT_Certificates, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x30b227df, L"encryptionMethods", XFA_ELEMENT_EncryptionMethods, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x32b900d1, L"setProperty", XFA_ELEMENT_SetProperty, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x337d9e45, L"printerName", XFA_ELEMENT_PrinterName, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x33edda4b, L"startPage", XFA_ELEMENT_StartPage, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x381943e4, L"pageOffset", XFA_ELEMENT_PageOffset, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x382106cd, L"dateTime", XFA_ELEMENT_DateTime, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0x386e7421, L"comb", XFA_ELEMENT_Comb, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x390acd9e, L"pattern", XFA_ELEMENT_Pattern, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x3942163e, L"ifEmpty", XFA_ELEMENT_IfEmpty, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x39944a7b, L"suppressBanner", XFA_ELEMENT_SuppressBanner, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x3b3c3dca, L"outputBin", XFA_ELEMENT_OutputBin, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x3b8a4024, L"field", XFA_ELEMENT_Field, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x3c15352f, L"agent", XFA_ELEMENT_Agent, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x3d7e8668, L"outputXSL", XFA_ELEMENT_OutputXSL, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x3e1c91c5, L"adjustData", XFA_ELEMENT_AdjustData, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x3e7a9408, L"autoSave", XFA_ELEMENT_AutoSave, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x3ecead94, L"contentArea", XFA_ELEMENT_ContentArea, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x3ef334e3, L"eventPseudoModel", XFA_ELEMENT_EventPseudoModel, + XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, + {0x3fadaec0, L"wsdlAddress", XFA_ELEMENT_WsdlAddress, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, + {0x40623b5b, L"solid", XFA_ELEMENT_Solid, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x41f0bd76, L"dateTimeSymbols", XFA_ELEMENT_DateTimeSymbols, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0x444e7523, L"encryptionLevel", XFA_ELEMENT_EncryptionLevel, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x4523af55, L"edge", XFA_ELEMENT_Edge, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x45d5e3c1, L"stipple", XFA_ELEMENT_Stipple, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x475e4e87, L"attributes", XFA_ELEMENT_Attributes, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x487a8c87, L"versionControl", XFA_ELEMENT_VersionControl, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, + {0x48e5248c, L"meridiem", XFA_ELEMENT_Meridiem, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_ContentNode}, + {0x48f36719, L"exclGroup", XFA_ELEMENT_ExclGroup, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x4977356b, L"toolTip", XFA_ELEMENT_ToolTip, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0x499afecc, L"compress", XFA_ELEMENT_Compress, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x4a0c4948, L"reason", XFA_ELEMENT_Reason, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0x4bdcce13, L"execute", XFA_ELEMENT_Execute, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x4c56b216, L"contentCopy", XFA_ELEMENT_ContentCopy, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x4cc176d3, L"dateTimeEdit", XFA_ELEMENT_DateTimeEdit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x4e1e39b6, L"config", XFA_ELEMENT_Config, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ModelNode}, + {0x4e2d6083, L"image", XFA_ELEMENT_Image, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0x4e814150, L"#xHTML", XFA_ELEMENT_SharpxHTML, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_SourceSet | + XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_NodeV}, + {0x4f2388c1, L"numberOfCopies", XFA_ELEMENT_NumberOfCopies, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x4f512e30, L"behaviorOverride", XFA_ELEMENT_BehaviorOverride, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x4fdc3454, L"timeStamp", XFA_ELEMENT_TimeStamp, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x51d90546, L"month", XFA_ELEMENT_Month, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_ContentNode}, + {0x523437e4, L"viewerPreferences", XFA_ELEMENT_ViewerPreferences, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, + {0x53abc1c6, L"scriptModel", XFA_ELEMENT_ScriptModel, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x54034c2f, L"decimal", XFA_ELEMENT_Decimal, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0x54202c9e, L"subform", XFA_ELEMENT_Subform, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x542c7300, L"select", XFA_ELEMENT_Select, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0x5436d198, L"window", XFA_ELEMENT_Window, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x5473b6dc, L"localeSet", XFA_ELEMENT_LocaleSet, + XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ModelNode}, + {0x56ae179e, L"handler", XFA_ELEMENT_Handler, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0x5700bd5f, L"hostPseudoModel", XFA_ELEMENT_HostPseudoModel, + XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, + {0x570ce835, L"presence", XFA_ELEMENT_Presence, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x5779d65f, L"record", XFA_ELEMENT_Record, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x59c8f27d, L"embed", XFA_ELEMENT_Embed, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x5a50e9e6, L"version", XFA_ELEMENT_Version, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x5b8383df, L"command", XFA_ELEMENT_Command, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_Node}, + {0x5c43c6c3, L"copies", XFA_ELEMENT_Copies, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x5e0c2c49, L"staple", XFA_ELEMENT_Staple, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x5e5083dd, L"submitFormat", XFA_ELEMENT_SubmitFormat, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x5e8c5d20, L"boolean", XFA_ELEMENT_Boolean, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x60490a85, L"message", XFA_ELEMENT_Message, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_Node}, + {0x60d4c8b1, L"output", XFA_ELEMENT_Output, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x61810081, L"psMap", XFA_ELEMENT_PsMap, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x62bd904b, L"excludeNS", XFA_ELEMENT_ExcludeNS, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x669d4f77, L"assist", XFA_ELEMENT_Assist, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x67334a1c, L"picture", XFA_ELEMENT_Picture, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x67fe7334, L"traversal", XFA_ELEMENT_Traversal, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x6894589c, L"silentPrint", XFA_ELEMENT_SilentPrint, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x68a16bbd, L"webClient", XFA_ELEMENT_WebClient, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x69f115df, L"layoutPseudoModel", XFA_ELEMENT_LayoutPseudoModel, + XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, + {0x6a4bc084, L"producer", XFA_ELEMENT_Producer, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x6a9e04c9, L"corner", XFA_ELEMENT_Corner, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x6ccd7274, L"msgId", XFA_ELEMENT_MsgId, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x6e67921f, L"color", XFA_ELEMENT_Color, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x6ec217a5, L"keep", XFA_ELEMENT_Keep, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x6eef1116, L"query", XFA_ELEMENT_Query, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_Node}, + {0x7033bfd5, L"insert", XFA_ELEMENT_Insert, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0x704af389, L"imageEdit", XFA_ELEMENT_ImageEdit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x7233018a, L"validate", XFA_ELEMENT_Validate, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x72ba47b4, L"digestMethods", XFA_ELEMENT_DigestMethods, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x72f2aa7a, L"numberPatterns", XFA_ELEMENT_NumberPatterns, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0x74caed29, L"pageSet", XFA_ELEMENT_PageSet, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x7568e6ae, L"integer", XFA_ELEMENT_Integer, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x76182db9, L"soapAddress", XFA_ELEMENT_SoapAddress, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, + {0x773146c5, L"equate", XFA_ELEMENT_Equate, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x77d449dd, L"formFieldFilling", XFA_ELEMENT_FormFieldFilling, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x7889d68a, L"pageRange", XFA_ELEMENT_PageRange, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x7baca2e3, L"update", XFA_ELEMENT_Update, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0x7ce89001, L"connectString", XFA_ELEMENT_ConnectString, + XFA_XDPPACKET_SourceSet, XFA_OBJECTTYPE_TextNode}, + {0x7d9fd7c5, L"mode", XFA_ELEMENT_Mode, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x7e7e845e, L"layout", XFA_ELEMENT_Layout, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x7e845c34, L"#xml", XFA_ELEMENT_Sharpxml, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeV}, + {0x7fb341df, L"xsdConnection", XFA_ELEMENT_XsdConnection, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, + {0x7ffb51cc, L"traverse", XFA_ELEMENT_Traverse, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x80203b5a, L"encodings", XFA_ELEMENT_Encodings, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x803550fc, L"template", XFA_ELEMENT_Template, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ModelNode}, + {0x803d5bbc, L"acrobat", XFA_ELEMENT_Acrobat, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0x821d6569, L"validationMessaging", XFA_ELEMENT_ValidationMessaging, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, + {0x830e688f, L"signing", XFA_ELEMENT_Signing, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x83a550d2, L"dataWindow", XFA_ELEMENT_DataWindow, XFA_XDPPACKET_Datasets, + XFA_OBJECTTYPE_OrdinaryObject}, + {0x83dab9f5, L"script", XFA_ELEMENT_Script, + XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0x8411ebcd, L"addViewerPreferences", XFA_ELEMENT_AddViewerPreferences, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x8777642e, L"alwaysEmbed", XFA_ELEMENT_AlwaysEmbed, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x877a6b39, L"passwordEdit", XFA_ELEMENT_PasswordEdit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x87e84c99, L"numericEdit", XFA_ELEMENT_NumericEdit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x8852cdec, L"encryptionMethod", XFA_ELEMENT_EncryptionMethod, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, + {0x891f4606, L"change", XFA_ELEMENT_Change, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x89939f36, L"pageArea", XFA_ELEMENT_PageArea, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0x8a9d6247, L"submitUrl", XFA_ELEMENT_SubmitUrl, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0x8ad8b90f, L"oids", XFA_ELEMENT_Oids, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x8b036f32, L"signature", XFA_ELEMENT_Signature, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x8b128efb, L"ADBE_JSConsole", XFA_ELEMENT_ADBE_JSConsole, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0x8bcfe96e, L"caption", XFA_ELEMENT_Caption, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x8e1c2921, L"relevant", XFA_ELEMENT_Relevant, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x8e3f0a4b, L"flipLabel", XFA_ELEMENT_FlipLabel, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0x900280b7, L"exData", XFA_ELEMENT_ExData, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0x91e80352, L"dayNames", XFA_ELEMENT_DayNames, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_Node}, + {0x93113b11, L"soapAction", XFA_ELEMENT_SoapAction, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, + {0x938b09f6, L"defaultTypeface", XFA_ELEMENT_DefaultTypeface, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, + {0x95b37897, L"manifest", XFA_ELEMENT_Manifest, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x97b76b54, L"overflow", XFA_ELEMENT_Overflow, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x9a57861b, L"linear", XFA_ELEMENT_Linear, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0x9ad5a821, L"currencySymbol", XFA_ELEMENT_CurrencySymbol, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0x9c6471b3, L"delete", XFA_ELEMENT_Delete, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0x9deea61d, L"deltas", XFA_ELEMENT_Deltas, XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_OrdinaryObject}, + {0x9e67de21, L"digestMethod", XFA_ELEMENT_DigestMethod, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, + {0x9f3e9510, L"instanceManager", XFA_ELEMENT_InstanceManager, + XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xa0799892, L"equateRange", XFA_ELEMENT_EquateRange, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xa084a381, L"medium", XFA_ELEMENT_Medium, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xa1211b8b, L"textEdit", XFA_ELEMENT_TextEdit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xa17008f0, L"templateCache", XFA_ELEMENT_TemplateCache, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, + {0xa4f7b88f, L"compressObjectStream", XFA_ELEMENT_CompressObjectStream, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xa65f5d17, L"dataValue", XFA_ELEMENT_DataValue, XFA_XDPPACKET_Datasets, + XFA_OBJECTTYPE_Node}, + {0xa6caaa89, L"accessibleContent", XFA_ELEMENT_AccessibleContent, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xa8c7d5e2, L"nodeList", XFA_ELEMENT_NodeList, XFA_XDPPACKET_XDP, + XFA_OBJECTTYPE_NodeList}, + {0xa94cc00b, L"includeXDPContent", XFA_ELEMENT_IncludeXDPContent, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xa9b081a1, L"xmlConnection", XFA_ELEMENT_XmlConnection, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, + {0xab2a3b74, L"validateApprovalSignatures", + XFA_ELEMENT_ValidateApprovalSignatures, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xab8c5a2b, L"signData", XFA_ELEMENT_SignData, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xabaa2ceb, L"packets", XFA_ELEMENT_Packets, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xadba359c, L"datePattern", XFA_ELEMENT_DatePattern, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0xae222b2b, L"duplexOption", XFA_ELEMENT_DuplexOption, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xb012effb, L"base", XFA_ELEMENT_Base, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xb0e5485d, L"bind", XFA_ELEMENT_Bind, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_Node}, + {0xb45d61b2, L"compression", XFA_ELEMENT_Compression, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xb563f0ff, L"user", XFA_ELEMENT_User, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0xb5848ad5, L"rectangle", XFA_ELEMENT_Rectangle, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xb6dacb72, L"effectiveOutputPolicy", XFA_ELEMENT_EffectiveOutputPolicy, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, + {0xb7d7654d, L"ADBE_JSDebugger", XFA_ELEMENT_ADBE_JSDebugger, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xbab37f73, L"acrobat7", XFA_ELEMENT_Acrobat7, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xbc70081e, L"interactive", XFA_ELEMENT_Interactive, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xbc8fa350, L"locale", XFA_ELEMENT_Locale, + XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0xbcd44940, L"currentPage", XFA_ELEMENT_CurrentPage, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xbde9abda, L"data", XFA_ELEMENT_Data, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xbde9abde, L"date", XFA_ELEMENT_Date, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0xbe52dfbf, L"desc", XFA_ELEMENT_Desc, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xbf4b6405, L"encrypt", XFA_ELEMENT_Encrypt, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ContentNode}, + {0xbfa87cce, L"draw", XFA_ELEMENT_Draw, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0xc181ff4b, L"encryption", XFA_ELEMENT_Encryption, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc1970f40, L"meridiemNames", XFA_ELEMENT_MeridiemNames, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0xc5ad9f5e, L"messaging", XFA_ELEMENT_Messaging, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc69549f4, L"speak", XFA_ELEMENT_Speak, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0xc7743dc7, L"dataGroup", XFA_ELEMENT_DataGroup, XFA_XDPPACKET_Datasets, + XFA_OBJECTTYPE_Node}, + {0xc7eb20e9, L"common", XFA_ELEMENT_Common, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xc85d4528, L"#text", XFA_ELEMENT_Sharptext, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | + XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_SourceSet | + XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_NodeV}, + {0xc861556a, L"paginationOverride", XFA_ELEMENT_PaginationOverride, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xc903dabb, L"reasons", XFA_ELEMENT_Reasons, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xc9a8127f, L"signatureProperties", XFA_ELEMENT_SignatureProperties, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xca010c2d, L"threshold", XFA_ELEMENT_Threshold, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xcb4c5e96, L"appearanceFilter", XFA_ELEMENT_AppearanceFilter, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, + {0xcc92aba7, L"fill", XFA_ELEMENT_Fill, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xcd308b77, L"font", XFA_ELEMENT_Font, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_Node}, + {0xcd309ff4, L"form", XFA_ELEMENT_Form, XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_ModelNode}, + {0xcebcca2d, L"mediumInfo", XFA_ELEMENT_MediumInfo, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xcfe0d643, L"certificate", XFA_ELEMENT_Certificate, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, + {0xd012c033, L"password", XFA_ELEMENT_Password, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_TextNode}, + {0xd01604bd, L"runScripts", XFA_ELEMENT_RunScripts, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xd1227e6f, L"trace", XFA_ELEMENT_Trace, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xd1532876, L"float", XFA_ELEMENT_Float, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0xd17a6c30, L"renderPolicy", XFA_ELEMENT_RenderPolicy, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xd4bf6823, L"logPseudoModel", XFA_ELEMENT_LogPseudoModel, + XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, + {0xd58aa962, L"destination", XFA_ELEMENT_Destination, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xd6e27f1d, L"value", XFA_ELEMENT_Value, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xd7a14462, L"bookend", XFA_ELEMENT_Bookend, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xd8c31254, L"exObject", XFA_ELEMENT_ExObject, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xda6a8590, L"openAction", XFA_ELEMENT_OpenAction, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xdab4fb7d, L"neverEmbed", XFA_ELEMENT_NeverEmbed, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xdb98475f, L"bindItems", XFA_ELEMENT_BindItems, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xdbfbe02e, L"calculate", XFA_ELEMENT_Calculate, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xdd7676ed, L"print", XFA_ELEMENT_Print, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xdde273d7, L"extras", XFA_ELEMENT_Extras, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_Node}, + {0xde146b34, L"proto", XFA_ELEMENT_Proto, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xdf059321, L"dSigData", XFA_ELEMENT_DSigData, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xdfccf030, L"creator", XFA_ELEMENT_Creator, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xdff78c6a, L"connect", XFA_ELEMENT_Connect, + XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, + XFA_OBJECTTYPE_Node}, + {0xe11a2cbc, L"permissions", XFA_ELEMENT_Permissions, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xe14c801c, L"connectionSet", XFA_ELEMENT_ConnectionSet, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_ModelNode}, + {0xe1c83a14, L"submit", XFA_ELEMENT_Submit, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xe29821cd, L"range", XFA_ELEMENT_Range, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xe38d83c7, L"linearized", XFA_ELEMENT_Linearized, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xe3aa2578, L"packet", XFA_ELEMENT_Packet, XFA_XDPPACKET_XDP, + XFA_OBJECTTYPE_NodeC}, + {0xe3aa860e, L"rootElement", XFA_ELEMENT_RootElement, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, + {0xe3e553fa, L"plaintextMetadata", XFA_ELEMENT_PlaintextMetadata, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xe3e6e4f2, L"numberSymbols", XFA_ELEMENT_NumberSymbols, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0xe3f067f6, L"printHighQuality", XFA_ELEMENT_PrintHighQuality, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xe3fd078c, L"driver", XFA_ELEMENT_Driver, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xe48b34f2, L"incrementalLoad", XFA_ELEMENT_IncrementalLoad, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, + {0xe550e7c2, L"subjectDN", XFA_ELEMENT_SubjectDN, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, + {0xe6669a78, L"compressLogicalStructure", + XFA_ELEMENT_CompressLogicalStructure, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xe7a7ea02, L"incrementalMerge", XFA_ELEMENT_IncrementalMerge, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xe948530d, L"radial", XFA_ELEMENT_Radial, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xea8d6999, L"variables", XFA_ELEMENT_Variables, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, + {0xeaa142c0, L"timePatterns", XFA_ELEMENT_TimePatterns, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, + {0xeb943a71, L"effectiveInputPolicy", XFA_ELEMENT_EffectiveInputPolicy, + XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, + {0xef04a2bc, L"nameAttr", XFA_ELEMENT_NameAttr, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xf07222ab, L"conformance", XFA_ELEMENT_Conformance, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xf0aaaadc, L"transform", XFA_ELEMENT_Transform, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_Node}, + {0xf1433e88, L"lockDocument", XFA_ELEMENT_LockDocument, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, + {0xf54eb997, L"breakAfter", XFA_ELEMENT_BreakAfter, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xf616da28, L"line", XFA_ELEMENT_Line, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xf616f3dc, L"list", XFA_ELEMENT_List, XFA_XDPPACKET_XDP, + XFA_OBJECTTYPE_OrdinaryList}, + {0xf7055fb1, L"source", XFA_ELEMENT_Source, XFA_XDPPACKET_SourceSet, + XFA_OBJECTTYPE_Node}, + {0xf7eebe1c, L"occur", XFA_ELEMENT_Occur, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, + {0xf8d10d97, L"pickTrayByPDFSize", XFA_ELEMENT_PickTrayByPDFSize, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xf8f19e3a, L"monthNames", XFA_ELEMENT_MonthNames, XFA_XDPPACKET_LocaleSet, + XFA_OBJECTTYPE_Node}, + {0xf984149b, L"severity", XFA_ELEMENT_Severity, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xf9bcb037, L"groupParent", XFA_ELEMENT_GroupParent, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_NodeV}, + {0xfbc42fff, L"documentAssembly", XFA_ELEMENT_DocumentAssembly, + XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, + {0xfc78159f, L"numberSymbol", XFA_ELEMENT_NumberSymbol, + XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, + {0xfcbd606c, L"tagged", XFA_ELEMENT_Tagged, XFA_XDPPACKET_Config, + XFA_OBJECTTYPE_ContentNode}, + {0xff063802, L"items", XFA_ELEMENT_Items, + XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, +}; +const int32_t g_iXFAElementCount = + sizeof(g_XFAElementData) / sizeof(XFA_ELEMENTINFO); +const XFA_ELEMENTHIERARCHY g_XFAElementPropertyIndex[] = { + {0, 8}, {8, 0}, {8, 14}, {22, 0}, {22, 0}, {22, 6}, {28, 0}, + {28, 0}, {28, 1}, {29, 3}, {32, 0}, {32, 0}, {32, 0}, {32, 3}, + {35, 1}, {36, 0}, {36, 0}, {36, 2}, {38, 0}, {38, 0}, {38, 0}, + {38, 4}, {42, 0}, {42, 0}, {42, 1}, {43, 0}, {43, 8}, {51, 19}, + {70, 0}, {70, 0}, {70, 2}, {72, 1}, {73, 0}, {73, 2}, {75, 4}, + {79, 1}, {80, 1}, {81, 0}, {81, 0}, {81, 3}, {84, 0}, {84, 4}, + {88, 4}, {92, 1}, {93, 0}, {93, 4}, {97, 9}, {106, 14}, {120, 0}, + {120, 0}, {120, 5}, {125, 0}, {125, 1}, {126, 0}, {126, 0}, {126, 0}, + {126, 0}, {126, 0}, {126, 1}, {127, 0}, {127, 0}, {127, 0}, {127, 0}, + {127, 0}, {127, 0}, {127, 0}, {127, 6}, {133, 1}, {134, 0}, {134, 1}, + {135, 0}, {135, 0}, {135, 1}, {136, 2}, {138, 5}, {143, 2}, {145, 0}, + {145, 0}, {145, 0}, {145, 0}, {145, 0}, {145, 5}, {150, 0}, {150, 0}, + {150, 0}, {150, 0}, {150, 0}, {150, 0}, {150, 0}, {150, 2}, {152, 0}, + {152, 0}, {152, 0}, {152, 17}, {169, 0}, {169, 1}, {170, 0}, {170, 0}, + {170, 2}, {172, 0}, {172, 0}, {172, 1}, {173, 0}, {173, 0}, {173, 2}, + {175, 2}, {177, 0}, {177, 0}, {177, 0}, {177, 11}, {188, 0}, {188, 0}, + {188, 0}, {188, 0}, {188, 0}, {188, 4}, {192, 3}, {195, 0}, {195, 0}, + {195, 0}, {195, 0}, {195, 0}, {195, 0}, {195, 9}, {204, 0}, {204, 0}, + {204, 17}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, + {221, 0}, {221, 0}, {221, 0}, {221, 4}, {225, 0}, {225, 0}, {225, 0}, + {225, 0}, {225, 2}, {227, 3}, {230, 0}, {230, 0}, {230, 2}, {232, 0}, + {232, 1}, {233, 2}, {235, 2}, {237, 0}, {237, 0}, {237, 2}, {239, 0}, + {239, 1}, {240, 1}, {241, 2}, {243, 0}, {243, 3}, {246, 4}, {250, 0}, + {250, 1}, {251, 2}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, + {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 2}, {255, 2}, + {257, 0}, {257, 6}, {263, 5}, {268, 0}, {268, 0}, {268, 0}, {268, 3}, + {271, 0}, {271, 0}, {271, 3}, {274, 4}, {278, 0}, {278, 0}, {278, 4}, + {282, 0}, {282, 0}, {282, 5}, {287, 0}, {287, 5}, {292, 0}, {292, 0}, + {292, 0}, {292, 1}, {293, 0}, {293, 0}, {293, 1}, {294, 0}, {294, 2}, + {296, 0}, {296, 0}, {296, 0}, {296, 0}, {296, 1}, {297, 0}, {297, 0}, + {297, 4}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, + {301, 1}, {302, 0}, {302, 2}, {304, 0}, {304, 0}, {304, 0}, {304, 0}, + {304, 1}, {305, 4}, {309, 0}, {309, 3}, {312, 0}, {312, 0}, {312, 1}, + {313, 0}, {313, 8}, {321, 0}, {321, 10}, {331, 0}, {331, 10}, {341, 1}, + {342, 12}, {354, 3}, {357, 1}, {358, 0}, {358, 0}, {358, 0}, {358, 8}, + {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 7}, + {373, 2}, {375, 0}, {375, 1}, {376, 0}, {376, 0}, {376, 0}, {376, 0}, + {376, 0}, {376, 0}, {376, 0}, {376, 0}, {376, 13}, {389, 0}, {389, 1}, + {390, 1}, {391, 0}, {391, 0}, {391, 3}, {394, 0}, {394, 0}, {394, 0}, + {394, 0}, {394, 0}, {394, 4}, {398, 9}, {407, 0}, {407, 1}, {408, 0}, + {408, 0}, {408, 0}, {408, 0}, {408, 0}, {408, 1}, {409, 0}, {409, 2}, + {411, 0}, {411, 0}, {411, 0}, {411, 0}, {411, 2}, {413, 0}, {413, 1}, + {414, 0}, {414, 0}, {414, 0}, {414, 7}, {421, 0}, {421, 1}, {422, 1}, + {423, 0}, {423, 1}, {424, 1}, {425, 0}, {425, 1}, {426, 0}, {426, 0}, + {426, 0}, {426, 0}, {426, 0}, {426, 0}, +}; +const XFA_PROPERTY g_XFAElementPropertyData[] = { + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Jog, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_BatchOutput, 1, 0}, + {XFA_ELEMENT_OutputBin, 1, 0}, + {XFA_ELEMENT_Compress, 1, 0}, + {XFA_ELEMENT_Staple, 1, 0}, + {XFA_ELEMENT_MediumInfo, 1, 0}, + {XFA_ELEMENT_CheckButton, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_ChoiceList, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_DefaultUi, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Barcode, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Button, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_DateTimeEdit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_ImageEdit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_PasswordEdit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_NumericEdit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Signature, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_TextEdit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_ExObject, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Break, 1, 0}, + {XFA_ELEMENT_Overflow, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Bookend, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Occur, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_SubsetBelow, 1, 0}, + {XFA_ELEMENT_Map, 1, 0}, + {XFA_ELEMENT_Embed, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_DatePattern, 4, 0}, + {XFA_ELEMENT_Edge, 1, 0}, + {XFA_ELEMENT_Fill, 1, 0}, + {XFA_ELEMENT_To, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Mode, 1, 0}, + {XFA_ELEMENT_Threshold, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Jog, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_BatchOutput, 1, 0}, + {XFA_ELEMENT_PageOffset, 1, 0}, + {XFA_ELEMENT_OutputBin, 1, 0}, + {XFA_ELEMENT_Staple, 1, 0}, + {XFA_ELEMENT_MediumInfo, 1, 0}, + {XFA_ELEMENT_AdobeExtensionLevel, 1, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_Pdfa, 1, 0}, + {XFA_ELEMENT_BatchOutput, 1, 0}, + {XFA_ELEMENT_ViewerPreferences, 1, 0}, + {XFA_ELEMENT_ScriptModel, 1, 0}, + {XFA_ELEMENT_Version, 1, 0}, + {XFA_ELEMENT_SubmitFormat, 1, 0}, + {XFA_ELEMENT_SilentPrint, 1, 0}, + {XFA_ELEMENT_Producer, 1, 0}, + {XFA_ELEMENT_Compression, 1, 0}, + {XFA_ELEMENT_Interactive, 1, 0}, + {XFA_ELEMENT_Encryption, 1, 0}, + {XFA_ELEMENT_RenderPolicy, 1, 0}, + {XFA_ELEMENT_OpenAction, 1, 0}, + {XFA_ELEMENT_Creator, 1, 0}, + {XFA_ELEMENT_Linearized, 1, 0}, + {XFA_ELEMENT_Tagged, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Xsl, 1, 0}, + {XFA_ELEMENT_Packets, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Debug, 1, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_BatchOutput, 1, 0}, + {XFA_ELEMENT_FlipLabel, 1, 0}, + {XFA_ELEMENT_TemplateCache, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_BatchOutput, 1, 0}, + {XFA_ELEMENT_FlipLabel, 1, 0}, + {XFA_ELEMENT_EraNames, 1, 0}, + {XFA_ELEMENT_DayNames, 2, 0}, + {XFA_ELEMENT_MeridiemNames, 1, 0}, + {XFA_ELEMENT_MonthNames, 2, 0}, + {XFA_ELEMENT_Hyphenation, 1, 0}, + {XFA_ELEMENT_Amd, 1, 0}, + {XFA_ELEMENT_Part, 1, 0}, + {XFA_ELEMENT_IncludeXDPContent, 1, 0}, + {XFA_ELEMENT_Conformance, 1, 0}, + {XFA_ELEMENT_Mdp, 1, 0}, + {XFA_ELEMENT_Certificates, 1, 0}, + {XFA_ELEMENT_TimeStamp, 1, 0}, + {XFA_ELEMENT_Handler, 1, 0}, + {XFA_ELEMENT_DigestMethods, 1, 0}, + {XFA_ELEMENT_Encodings, 1, 0}, + {XFA_ELEMENT_Reasons, 1, 0}, + {XFA_ELEMENT_AppearanceFilter, 1, 0}, + {XFA_ELEMENT_LockDocument, 1, 0}, + {XFA_ELEMENT_Xdp, 1, 0}, + {XFA_ELEMENT_Cache, 1, 0}, + {XFA_ELEMENT_Pagination, 1, 0}, + {XFA_ELEMENT_Overprint, 1, 0}, + {XFA_ELEMENT_BehaviorOverride, 1, 0}, + {XFA_ELEMENT_Copies, 1, 0}, + {XFA_ELEMENT_Output, 1, 0}, + {XFA_ELEMENT_Validate, 1, 0}, + {XFA_ELEMENT_Layout, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_Common, 1, 0}, + {XFA_ELEMENT_PaginationOverride, 1, 0}, + {XFA_ELEMENT_Destination, 1, 0}, + {XFA_ELEMENT_IncrementalMerge, 1, 0}, + {XFA_ELEMENT_Execute, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Script, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_SignData, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Submit, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_CurrencySymbol, 3, 0}, + {XFA_ELEMENT_Operation, 1, 0}, + {XFA_ELEMENT_WsdlAddress, 1, 0}, + {XFA_ELEMENT_SoapAddress, 1, 0}, + {XFA_ELEMENT_SoapAction, 1, 0}, + {XFA_ELEMENT_EffectiveOutputPolicy, 1, 0}, + {XFA_ELEMENT_EffectiveInputPolicy, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Era, 2, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Edge, 4, 0}, + {XFA_ELEMENT_Corner, 4, 0}, + {XFA_ELEMENT_Fill, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_KeyUsage, 1, 0}, + {XFA_ELEMENT_SubjectDNs, 1, 0}, + {XFA_ELEMENT_Issuers, 1, 0}, + {XFA_ELEMENT_Signing, 1, 0}, + {XFA_ELEMENT_Oids, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Ui, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Para, 1, 0}, + {XFA_ELEMENT_Format, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Assist, 1, 0}, + {XFA_ELEMENT_Traversal, 1, 0}, + {XFA_ELEMENT_Keep, 1, 0}, + {XFA_ELEMENT_Validate, 1, 0}, + {XFA_ELEMENT_Caption, 1, 0}, + {XFA_ELEMENT_Bind, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Font, 1, 0}, + {XFA_ELEMENT_Value, 1, 0}, + {XFA_ELEMENT_Calculate, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Items, 2, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Para, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Assist, 1, 0}, + {XFA_ELEMENT_Traversal, 1, 0}, + {XFA_ELEMENT_Validate, 1, 0}, + {XFA_ELEMENT_Caption, 1, 0}, + {XFA_ELEMENT_Bind, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Calculate, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Comb, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Present, 1, 0}, + {XFA_ELEMENT_Acrobat, 1, 0}, + {XFA_ELEMENT_Trace, 1, 0}, + {XFA_ELEMENT_PrintScaling, 1, 0}, + {XFA_ELEMENT_Enforce, 1, 0}, + {XFA_ELEMENT_NumberOfCopies, 1, 0}, + {XFA_ELEMENT_PageRange, 1, 0}, + {XFA_ELEMENT_AddViewerPreferences, 1, 0}, + {XFA_ELEMENT_ADBE_JSConsole, 1, 0}, + {XFA_ELEMENT_DuplexOption, 1, 0}, + {XFA_ELEMENT_ADBE_JSDebugger, 1, 0}, + {XFA_ELEMENT_PickTrayByPDFSize, 1, 0}, + {XFA_ELEMENT_Break, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Para, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Assist, 1, 0}, + {XFA_ELEMENT_Traversal, 1, 0}, + {XFA_ELEMENT_Keep, 1, 0}, + {XFA_ELEMENT_Validate, 1, 0}, + {XFA_ELEMENT_PageSet, 1, 0}, + {XFA_ELEMENT_Overflow, 1, 0}, + {XFA_ELEMENT_Bind, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Bookend, 1, 0}, + {XFA_ELEMENT_Calculate, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Variables, 1, 0}, + {XFA_ELEMENT_Occur, 1, 0}, + {XFA_ELEMENT_Query, 1, 0}, + {XFA_ELEMENT_Insert, 1, 0}, + {XFA_ELEMENT_Update, 1, 0}, + {XFA_ELEMENT_Delete, 1, 0}, + {XFA_ELEMENT_MsgId, 1, 0}, + {XFA_ELEMENT_Severity, 1, 0}, + {XFA_ELEMENT_To, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Type, 1, 0}, + {XFA_ELEMENT_ToolTip, 1, 0}, + {XFA_ELEMENT_Speak, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_AddSilentPrint, 1, 0}, + {XFA_ELEMENT_PrinterName, 1, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_RecordSet, 1, 0}, + {XFA_ELEMENT_Select, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Message, 1, 0}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_NumberPattern, 4, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Occur, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_RootElement, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Xsl, 1, 0}, + {XFA_ELEMENT_StartPage, 1, 0}, + {XFA_ELEMENT_Relevant, 1, 0}, + {XFA_ELEMENT_Base, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_AutoSave, 1, 0}, + {XFA_ELEMENT_Validate, 1, 0}, + {XFA_ELEMENT_ValidateApprovalSignatures, 1, 0}, + {XFA_ELEMENT_Acrobat7, 1, 0}, + {XFA_ELEMENT_Common, 1, 0}, + {XFA_ELEMENT_Exclude, 1, 0}, + {XFA_ELEMENT_CurrentPage, 1, 0}, + {XFA_ELEMENT_RunScripts, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Comb, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Medium, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Occur, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Filter, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Manifest, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Para, 1, 0}, + {XFA_ELEMENT_Font, 1, 0}, + {XFA_ELEMENT_Value, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Day, 7, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Occur, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Comb, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Filter, 1, 0}, + {XFA_ELEMENT_Manifest, 1, 0}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_Level, 1, 0}, + {XFA_ELEMENT_Type, 1, 0}, + {XFA_ELEMENT_CompressObjectStream, 1, 0}, + {XFA_ELEMENT_CompressLogicalStructure, 1, 0}, + {XFA_ELEMENT_Edge, 4, 0}, + {XFA_ELEMENT_Corner, 4, 0}, + {XFA_ELEMENT_Fill, 1, 0}, + {XFA_ELEMENT_DynamicRender, 1, 0}, + {XFA_ELEMENT_DatePatterns, 1, 0}, + {XFA_ELEMENT_CalendarSymbols, 1, 0}, + {XFA_ELEMENT_CurrencySymbols, 1, 0}, + {XFA_ELEMENT_Typefaces, 1, 0}, + {XFA_ELEMENT_DateTimeSymbols, 1, 0}, + {XFA_ELEMENT_NumberPatterns, 1, 0}, + {XFA_ELEMENT_NumberSymbols, 1, 0}, + {XFA_ELEMENT_TimePatterns, 1, 0}, + {XFA_ELEMENT_Uri, 1, 0}, + {XFA_ELEMENT_Xsl, 1, 0}, + {XFA_ELEMENT_StartNode, 1, 0}, + {XFA_ELEMENT_OutputXSL, 1, 0}, + {XFA_ELEMENT_AdjustData, 1, 0}, + {XFA_ELEMENT_Attributes, 1, 0}, + {XFA_ELEMENT_Window, 1, 0}, + {XFA_ELEMENT_Record, 1, 0}, + {XFA_ELEMENT_Range, 1, 0}, + {XFA_ELEMENT_IncrementalLoad, 1, 0}, + {XFA_ELEMENT_Text, 1, 0}, + {XFA_ELEMENT_Time, 1, 0}, + {XFA_ELEMENT_DateTime, 1, 0}, + {XFA_ELEMENT_Image, 1, 0}, + {XFA_ELEMENT_Decimal, 1, 0}, + {XFA_ELEMENT_Boolean, 1, 0}, + {XFA_ELEMENT_Integer, 1, 0}, + {XFA_ELEMENT_ExData, 1, 0}, + {XFA_ELEMENT_Date, 1, 0}, + {XFA_ELEMENT_Float, 1, 0}, + {XFA_ELEMENT_Certificate, 1, 0}, + {XFA_ELEMENT_Ui, 1, 0}, + {XFA_ELEMENT_Margin, 1, 0}, + {XFA_ELEMENT_Para, 1, 0}, + {XFA_ELEMENT_Border, 1, 0}, + {XFA_ELEMENT_Assist, 1, 0}, + {XFA_ELEMENT_Traversal, 1, 0}, + {XFA_ELEMENT_Keep, 1, 0}, + {XFA_ELEMENT_Caption, 1, 0}, + {XFA_ELEMENT_Desc, 1, 0}, + {XFA_ELEMENT_Font, 1, 0}, + {XFA_ELEMENT_Value, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_EncryptionLevel, 1, 0}, + {XFA_ELEMENT_Encrypt, 1, 0}, + {XFA_ELEMENT_Permissions, 1, 0}, + {XFA_ELEMENT_Meridiem, 2, 0}, + {XFA_ELEMENT_SuppressBanner, 1, 0}, + {XFA_ELEMENT_VersionControl, 1, 0}, + {XFA_ELEMENT_LocaleSet, 1, 0}, + {XFA_ELEMENT_Template, 1, 0}, + {XFA_ELEMENT_ValidationMessaging, 1, 0}, + {XFA_ELEMENT_Locale, 1, 0}, + {XFA_ELEMENT_Data, 1, 0}, + {XFA_ELEMENT_Messaging, 1, 0}, + {XFA_ELEMENT_Pattern, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Solid, 1, + XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf}, + {XFA_ELEMENT_Stipple, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Linear, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Radial, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Fill, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Map, 1, 0}, + {XFA_ELEMENT_Arc, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Text, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Time, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_DateTime, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Image, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Decimal, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Boolean, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Integer, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_ExData, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Rectangle, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Date, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Float, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Line, 1, XFA_PROPERTYFLAG_OneOf}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Destination, 1, 0}, + {XFA_ELEMENT_Message, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_ConnectString, 1, 0}, + {XFA_ELEMENT_User, 1, 0}, + {XFA_ELEMENT_Password, 1, 0}, + {XFA_ELEMENT_ModifyAnnots, 1, 0}, + {XFA_ELEMENT_ContentCopy, 1, 0}, + {XFA_ELEMENT_FormFieldFilling, 1, 0}, + {XFA_ELEMENT_Change, 1, 0}, + {XFA_ELEMENT_AccessibleContent, 1, 0}, + {XFA_ELEMENT_Print, 1, 0}, + {XFA_ELEMENT_PlaintextMetadata, 1, 0}, + {XFA_ELEMENT_PrintHighQuality, 1, 0}, + {XFA_ELEMENT_DocumentAssembly, 1, 0}, + {XFA_ELEMENT_Encrypt, 1, 0}, + {XFA_ELEMENT_NumberSymbol, 5, 0}, + {XFA_ELEMENT_FontInfo, 1, 0}, + {XFA_ELEMENT_Xdc, 1, 0}, + {XFA_ELEMENT_Color, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_TimePattern, 4, 0}, + {XFA_ELEMENT_Whitespace, 1, 0}, + {XFA_ELEMENT_Rename, 1, 0}, + {XFA_ELEMENT_IfEmpty, 1, 0}, + {XFA_ELEMENT_Presence, 1, 0}, + {XFA_ELEMENT_Picture, 1, 0}, + {XFA_ELEMENT_NameAttr, 1, 0}, + {XFA_ELEMENT_GroupParent, 1, 0}, + {XFA_ELEMENT_Script, 1, 0}, + {XFA_ELEMENT_Edge, 1, 0}, + {XFA_ELEMENT_Connect, 1, 0}, + {XFA_ELEMENT_Extras, 1, 0}, + {XFA_ELEMENT_Month, 12, 0}, +}; +const XFA_ELEMENTHIERARCHY g_XFAElementChildrenIndex[] = { + {0, 0}, {0, 0}, {0, 0}, {0, 1}, {1, 0}, {1, 4}, {5, 0}, + {5, 0}, {5, 0}, {5, 3}, {8, 0}, {8, 0}, {8, 0}, {8, 0}, + {8, 0}, {8, 1}, {9, 0}, {9, 0}, {9, 0}, {9, 0}, {9, 0}, + {9, 0}, {9, 2}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, + {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, + {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, + {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 8}, {19, 0}, + {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, + {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 1}, + {20, 1}, {21, 1}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, + {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 7}, {29, 0}, + {29, 0}, {29, 0}, {29, 0}, {29, 0}, {29, 0}, {29, 1}, {30, 1}, + {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, + {31, 0}, {31, 0}, {31, 4}, {35, 2}, {37, 0}, {37, 0}, {37, 0}, + {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, + {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 4}, {41, 0}, {41, 0}, + {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 2}, {43, 0}, {43, 0}, + {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, + {43, 13}, {56, 0}, {56, 0}, {56, 1}, {57, 0}, {57, 0}, {57, 0}, + {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, + {57, 0}, {57, 1}, {58, 0}, {58, 1}, {59, 0}, {59, 0}, {59, 0}, + {59, 1}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, + {60, 0}, {60, 0}, {60, 1}, {61, 0}, {61, 0}, {61, 0}, {61, 1}, + {62, 0}, {62, 2}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, + {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, + {64, 1}, {65, 1}, {66, 1}, {67, 0}, {67, 1}, {68, 0}, {68, 0}, + {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 6}, + {74, 0}, {74, 1}, {75, 0}, {75, 0}, {75, 0}, {75, 0}, {75, 0}, + {75, 0}, {75, 0}, {75, 0}, {75, 0}, {75, 1}, {76, 0}, {76, 0}, + {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, + {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, + {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, + {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, + {76, 0}, {76, 0}, {76, 0}, {76, 2}, {78, 0}, {78, 0}, {78, 0}, + {78, 1}, {79, 0}, {79, 0}, {79, 1}, {80, 0}, {80, 0}, {80, 1}, + {81, 0}, {81, 0}, {81, 1}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, + {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 1}, + {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 11}, + {94, 0}, {94, 0}, {94, 0}, {94, 0}, {94, 0}, {94, 11}, {105, 106}, + {211, 0}, {211, 0}, {211, 1}, {212, 0}, {212, 3}, {215, 1}, {216, 0}, + {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, + {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 12}, {228, 0}, + {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, + {228, 0}, {228, 2}, {230, 0}, {230, 0}, {230, 0}, {230, 0}, {230, 0}, + {230, 0}, {230, 0}, {230, 0}, {230, 10}, +}; +const FX_WORD g_XFAElementChildrenData[] = { + XFA_ELEMENT_Extras, + XFA_ELEMENT_SubformSet, + XFA_ELEMENT_BreakBefore, + XFA_ELEMENT_Subform, + XFA_ELEMENT_BreakAfter, + XFA_ELEMENT_AlwaysEmbed, + XFA_ELEMENT_DefaultTypeface, + XFA_ELEMENT_NeverEmbed, + XFA_ELEMENT_Source, + XFA_ELEMENT_Equate, + XFA_ELEMENT_EquateRange, + XFA_ELEMENT_Ps, + XFA_ELEMENT_Pcl, + XFA_ELEMENT_Pdf, + XFA_ELEMENT_Zpl, + XFA_ELEMENT_LabelPrinter, + XFA_ELEMENT_WebClient, + XFA_ELEMENT_SubmitUrl, + XFA_ELEMENT_Driver, + XFA_ELEMENT_Typeface, + XFA_ELEMENT_SubjectDN, + XFA_ELEMENT_Certificate, + XFA_ELEMENT_SubformSet, + XFA_ELEMENT_Area, + XFA_ELEMENT_Field, + XFA_ELEMENT_ExclGroup, + XFA_ELEMENT_Subform, + XFA_ELEMENT_Draw, + XFA_ELEMENT_ExObject, + XFA_ELEMENT_EncryptionMethod, + XFA_ELEMENT_Ref, + XFA_ELEMENT_Event, + XFA_ELEMENT_SetProperty, + XFA_ELEMENT_BindItems, + XFA_ELEMENT_Connect, + XFA_ELEMENT_Pdf, + XFA_ELEMENT_Destination, + XFA_ELEMENT_Event, + XFA_ELEMENT_SetProperty, + XFA_ELEMENT_Field, + XFA_ELEMENT_Connect, + XFA_ELEMENT_Agent, + XFA_ELEMENT_PsMap, + XFA_ELEMENT_SubformSet, + XFA_ELEMENT_BreakBefore, + XFA_ELEMENT_Event, + XFA_ELEMENT_Area, + XFA_ELEMENT_SetProperty, + XFA_ELEMENT_Field, + XFA_ELEMENT_ExclGroup, + XFA_ELEMENT_Subform, + XFA_ELEMENT_Draw, + XFA_ELEMENT_ExObject, + XFA_ELEMENT_Proto, + XFA_ELEMENT_Connect, + XFA_ELEMENT_BreakAfter, + XFA_ELEMENT_Locale, + XFA_ELEMENT_Text, + XFA_ELEMENT_Font, + XFA_ELEMENT_Traverse, + XFA_ELEMENT_Map, + XFA_ELEMENT_DigestMethod, + XFA_ELEMENT_PageSet, + XFA_ELEMENT_PageArea, + XFA_ELEMENT_Encoding, + XFA_ELEMENT_Subform, + XFA_ELEMENT_SubmitUrl, + XFA_ELEMENT_Certificate, + XFA_ELEMENT_Area, + XFA_ELEMENT_Field, + XFA_ELEMENT_ContentArea, + XFA_ELEMENT_ExclGroup, + XFA_ELEMENT_Subform, + XFA_ELEMENT_Draw, + XFA_ELEMENT_Oid, + XFA_ELEMENT_Ref, + XFA_ELEMENT_ExcludeNS, + XFA_ELEMENT_Transform, + XFA_ELEMENT_SetProperty, + XFA_ELEMENT_Message, + XFA_ELEMENT_Log, + XFA_ELEMENT_Reason, + XFA_ELEMENT_Area, + XFA_ELEMENT_Text, + XFA_ELEMENT_Time, + XFA_ELEMENT_DateTime, + XFA_ELEMENT_Image, + XFA_ELEMENT_Decimal, + XFA_ELEMENT_Boolean, + XFA_ELEMENT_Integer, + XFA_ELEMENT_ExData, + XFA_ELEMENT_Date, + XFA_ELEMENT_Float, + XFA_ELEMENT_ExObject, + XFA_ELEMENT_Text, + XFA_ELEMENT_Time, + XFA_ELEMENT_DateTime, + XFA_ELEMENT_Image, + XFA_ELEMENT_Decimal, + XFA_ELEMENT_Boolean, + XFA_ELEMENT_Integer, + XFA_ELEMENT_ExData, + XFA_ELEMENT_Date, + XFA_ELEMENT_Float, + XFA_ELEMENT_Extras, + XFA_ELEMENT_Ui, + XFA_ELEMENT_SubformSet, + XFA_ELEMENT_Break, + XFA_ELEMENT_CheckButton, + XFA_ELEMENT_Arc, + XFA_ELEMENT_Mdp, + XFA_ELEMENT_BreakBefore, + XFA_ELEMENT_Oid, + XFA_ELEMENT_Ref, + XFA_ELEMENT_Margin, + XFA_ELEMENT_KeyUsage, + XFA_ELEMENT_ChoiceList, + XFA_ELEMENT_Para, + XFA_ELEMENT_Filter, + XFA_ELEMENT_Encoding, + XFA_ELEMENT_Event, + XFA_ELEMENT_DefaultUi, + XFA_ELEMENT_Barcode, + XFA_ELEMENT_SubjectDNs, + XFA_ELEMENT_Issuers, + XFA_ELEMENT_Button, + XFA_ELEMENT_Format, + XFA_ELEMENT_Border, + XFA_ELEMENT_Area, + XFA_ELEMENT_Hyphenation, + XFA_ELEMENT_Text, + XFA_ELEMENT_Time, + XFA_ELEMENT_Certificates, + XFA_ELEMENT_SetProperty, + XFA_ELEMENT_DateTime, + XFA_ELEMENT_Comb, + XFA_ELEMENT_Pattern, + XFA_ELEMENT_Field, + XFA_ELEMENT_ContentArea, + XFA_ELEMENT_Solid, + XFA_ELEMENT_Edge, + XFA_ELEMENT_Stipple, + XFA_ELEMENT_ExclGroup, + XFA_ELEMENT_ToolTip, + XFA_ELEMENT_Reason, + XFA_ELEMENT_Execute, + XFA_ELEMENT_DateTimeEdit, + XFA_ELEMENT_Image, + XFA_ELEMENT_TimeStamp, + XFA_ELEMENT_Decimal, + XFA_ELEMENT_Subform, + XFA_ELEMENT_Handler, + XFA_ELEMENT_Boolean, + XFA_ELEMENT_Message, + XFA_ELEMENT_Assist, + XFA_ELEMENT_Picture, + XFA_ELEMENT_Traversal, + XFA_ELEMENT_Corner, + XFA_ELEMENT_Color, + XFA_ELEMENT_Keep, + XFA_ELEMENT_ImageEdit, + XFA_ELEMENT_Validate, + XFA_ELEMENT_DigestMethods, + XFA_ELEMENT_PageSet, + XFA_ELEMENT_Integer, + XFA_ELEMENT_Traverse, + XFA_ELEMENT_Encodings, + XFA_ELEMENT_Signing, + XFA_ELEMENT_Script, + XFA_ELEMENT_PasswordEdit, + XFA_ELEMENT_NumericEdit, + XFA_ELEMENT_PageArea, + XFA_ELEMENT_Oids, + XFA_ELEMENT_Signature, + XFA_ELEMENT_Caption, + XFA_ELEMENT_ExData, + XFA_ELEMENT_Manifest, + XFA_ELEMENT_Overflow, + XFA_ELEMENT_Linear, + XFA_ELEMENT_DigestMethod, + XFA_ELEMENT_Medium, + XFA_ELEMENT_TextEdit, + XFA_ELEMENT_SignData, + XFA_ELEMENT_Rectangle, + XFA_ELEMENT_Date, + XFA_ELEMENT_Desc, + XFA_ELEMENT_Encrypt, + XFA_ELEMENT_Draw, + XFA_ELEMENT_Speak, + XFA_ELEMENT_Reasons, + XFA_ELEMENT_AppearanceFilter, + XFA_ELEMENT_Fill, + XFA_ELEMENT_Font, + XFA_ELEMENT_Certificate, + XFA_ELEMENT_Float, + XFA_ELEMENT_Value, + XFA_ELEMENT_Bookend, + XFA_ELEMENT_ExObject, + XFA_ELEMENT_BindItems, + XFA_ELEMENT_Calculate, + XFA_ELEMENT_Extras, + XFA_ELEMENT_Connect, + XFA_ELEMENT_Submit, + XFA_ELEMENT_SubjectDN, + XFA_ELEMENT_Radial, + XFA_ELEMENT_Variables, + XFA_ELEMENT_LockDocument, + XFA_ELEMENT_BreakAfter, + XFA_ELEMENT_Line, + XFA_ELEMENT_Occur, + XFA_ELEMENT_Items, + XFA_ELEMENT_Extras, + XFA_ELEMENT_WsdlConnection, + XFA_ELEMENT_XsdConnection, + XFA_ELEMENT_XmlConnection, + XFA_ELEMENT_SignData, + XFA_ELEMENT_Text, + XFA_ELEMENT_Time, + XFA_ELEMENT_DateTime, + XFA_ELEMENT_Image, + XFA_ELEMENT_Decimal, + XFA_ELEMENT_Boolean, + XFA_ELEMENT_Integer, + XFA_ELEMENT_Script, + XFA_ELEMENT_ExData, + XFA_ELEMENT_Manifest, + XFA_ELEMENT_Date, + XFA_ELEMENT_Float, + XFA_ELEMENT_Command, + XFA_ELEMENT_Bind, + XFA_ELEMENT_Text, + XFA_ELEMENT_Time, + XFA_ELEMENT_DateTime, + XFA_ELEMENT_Image, + XFA_ELEMENT_Decimal, + XFA_ELEMENT_Boolean, + XFA_ELEMENT_Integer, + XFA_ELEMENT_ExData, + XFA_ELEMENT_Date, + XFA_ELEMENT_Float, +}; +const XFA_ELEMENTHIERARCHY g_XFAElementAttributeIndex[] = { + {0, 3}, {3, 2}, {5, 3}, {8, 10}, {18, 2}, {20, 6}, {26, 2}, + {28, 1}, {29, 13}, {42, 2}, {44, 1}, {45, 2}, {47, 2}, {49, 7}, + {56, 0}, {56, 4}, {60, 2}, {62, 7}, {69, 0}, {69, 0}, {69, 2}, + {71, 2}, {73, 8}, {81, 5}, {86, 8}, {94, 4}, {98, 3}, {101, 3}, + {104, 3}, {107, 6}, {113, 2}, {115, 2}, {117, 2}, {119, 2}, {121, 3}, + {124, 2}, {126, 7}, {133, 13}, {146, 2}, {148, 6}, {154, 2}, {156, 3}, + {159, 1}, {160, 17}, {177, 2}, {179, 2}, {181, 6}, {187, 2}, {189, 2}, + {191, 3}, {194, 7}, {201, 2}, {203, 3}, {206, 0}, {206, 21}, {227, 1}, + {228, 3}, {231, 2}, {233, 0}, {233, 2}, {235, 2}, {237, 6}, {243, 0}, + {243, 4}, {247, 4}, {251, 0}, {251, 2}, {253, 2}, {255, 0}, {255, 0}, + {255, 2}, {257, 2}, {259, 4}, {263, 3}, {266, 7}, {273, 10}, {283, 9}, + {292, 6}, {298, 4}, {302, 2}, {304, 2}, {306, 6}, {312, 4}, {316, 3}, + {319, 2}, {321, 2}, {323, 4}, {327, 4}, {331, 4}, {335, 4}, {339, 2}, + {341, 2}, {343, 2}, {345, 22}, {367, 3}, {370, 2}, {372, 2}, {374, 2}, + {376, 9}, {385, 0}, {385, 4}, {389, 3}, {392, 0}, {392, 2}, {394, 7}, + {401, 4}, {405, 2}, {407, 4}, {411, 0}, {411, 21}, {432, 4}, {436, 3}, + {439, 4}, {443, 6}, {449, 2}, {451, 5}, {456, 2}, {458, 8}, {466, 1}, + {467, 2}, {469, 2}, {471, 5}, {476, 0}, {476, 2}, {478, 2}, {480, 6}, + {486, 26}, {512, 4}, {516, 2}, {518, 2}, {520, 4}, {524, 0}, {524, 2}, + {526, 2}, {528, 2}, {530, 2}, {532, 5}, {537, 2}, {539, 3}, {542, 2}, + {544, 4}, {548, 5}, {553, 2}, {555, 0}, {555, 2}, {557, 4}, {561, 5}, + {566, 3}, {569, 2}, {571, 3}, {574, 0}, {574, 2}, {576, 9}, {585, 2}, + {587, 5}, {592, 6}, {598, 5}, {603, 4}, {607, 4}, {611, 8}, {619, 4}, + {623, 0}, {623, 7}, {630, 4}, {634, 4}, {638, 5}, {643, 2}, {645, 2}, + {647, 4}, {651, 4}, {655, 2}, {657, 2}, {659, 1}, {660, 2}, {662, 5}, + {667, 4}, {671, 3}, {674, 2}, {676, 2}, {678, 4}, {682, 0}, {682, 9}, + {691, 2}, {693, 2}, {695, 5}, {700, 4}, {704, 3}, {707, 2}, {709, 10}, + {719, 2}, {721, 4}, {725, 4}, {729, 2}, {731, 6}, {737, 2}, {739, 2}, + {741, 9}, {750, 1}, {751, 4}, {755, 3}, {758, 5}, {763, 6}, {769, 4}, + {773, 1}, {774, 4}, {778, 0}, {778, 3}, {781, 1}, {782, 5}, {787, 10}, + {797, 7}, {804, 3}, {807, 2}, {809, 5}, {814, 2}, {816, 0}, {816, 2}, + {818, 2}, {820, 2}, {822, 6}, {828, 2}, {830, 1}, {831, 2}, {833, 2}, + {835, 8}, {843, 2}, {845, 4}, {849, 4}, {853, 4}, {857, 2}, {859, 2}, + {861, 2}, {863, 3}, {866, 2}, {868, 2}, {870, 4}, {874, 3}, {877, 5}, + {882, 20}, {902, 2}, {904, 0}, {904, 2}, {906, 6}, {912, 1}, {913, 2}, + {915, 1}, {916, 2}, {918, 4}, {922, 2}, {924, 2}, {926, 4}, {930, 4}, + {934, 20}, {954, 1}, {955, 2}, {957, 4}, {961, 4}, {965, 2}, {967, 2}, + {969, 4}, {973, 2}, {975, 0}, {975, 2}, {977, 5}, {982, 5}, {987, 8}, + {995, 2}, {997, 2}, {999, 4}, {1003, 4}, {1007, 2}, {1009, 4}, {1013, 0}, + {1013, 1}, {1014, 2}, {1016, 9}, {1025, 2}, {1027, 0}, {1027, 8}, {1035, 2}, + {1037, 2}, {1039, 0}, {1039, 4}, {1043, 2}, {1045, 0}, {1045, 2}, {1047, 3}, + {1050, 2}, {1052, 5}, {1057, 2}, {1059, 2}, {1061, 4}, {1065, 3}, {1068, 0}, + {1068, 4}, {1072, 2}, {1074, 2}, {1076, 3}, {1079, 4}, {1083, 8}, {1091, 5}, + {1096, 0}, {1096, 4}, {1100, 6}, {1106, 2}, {1108, 1}, {1109, 2}, {1111, 2}, + {1113, 2}, {1115, 1}, {1116, 2}, {1118, 7}, +}; +const uint8_t g_XFAElementAttributeData[] = { + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Max, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_EofAction, + XFA_ATTRIBUTE_CursorType, + XFA_ATTRIBUTE_LockType, + XFA_ATTRIBUTE_BofAction, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_CursorLocation, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Relation, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_BeforeTarget, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_OverflowTarget, + XFA_ATTRIBUTE_OverflowLeader, + XFA_ATTRIBUTE_OverflowTrailer, + XFA_ATTRIBUTE_StartNew, + XFA_ATTRIBUTE_BookendTrailer, + XFA_ATTRIBUTE_After, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_BookendLeader, + XFA_ATTRIBUTE_AfterTarget, + XFA_ATTRIBUTE_Before, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_AllowNeutral, + XFA_ATTRIBUTE_Mark, + XFA_ATTRIBUTE_Shape, + XFA_ATTRIBUTE_Size, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_StartAngle, + XFA_ATTRIBUTE_SweepAngle, + XFA_ATTRIBUTE_Circular, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Hand, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Bind, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_From, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_SignatureType, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Permissions, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_StartNew, + XFA_ATTRIBUTE_Trailer, + XFA_ATTRIBUTE_TargetType, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_Leader, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_TimeStamp, + XFA_ATTRIBUTE_Uuid, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_LeftInset, + XFA_ATTRIBUTE_BottomInset, + XFA_ATTRIBUTE_TopInset, + XFA_ATTRIBUTE_RightInset, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_NonRepudiation, + XFA_ATTRIBUTE_EncipherOnly, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_DigitalSignature, + XFA_ATTRIBUTE_CrlSign, + XFA_ATTRIBUTE_KeyAgreement, + XFA_ATTRIBUTE_KeyEncipherment, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_DataEncipherment, + XFA_ATTRIBUTE_KeyCertSign, + XFA_ATTRIBUTE_DecipherOnly, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Open, + XFA_ATTRIBUTE_CommitOn, + XFA_ATTRIBUTE_TextEntry, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_HAlign, + XFA_ATTRIBUTE_TextIndent, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Widows, + XFA_ATTRIBUTE_MarginRight, + XFA_ATTRIBUTE_MarginLeft, + XFA_ATTRIBUTE_RadixOffset, + XFA_ATTRIBUTE_Preserve, + XFA_ATTRIBUTE_SpaceBelow, + XFA_ATTRIBUTE_VAlign, + XFA_ATTRIBUTE_TabDefault, + XFA_ATTRIBUTE_TabStops, + XFA_ATTRIBUTE_Orphans, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_LineHeight, + XFA_ATTRIBUTE_SpaceAbove, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Version, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_AddRevocationInfo, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Listen, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Activity, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_DataRowCount, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_DataPrep, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_TextLocation, + XFA_ATTRIBUTE_ModuleWidth, + XFA_ATTRIBUTE_PrintCheckDigit, + XFA_ATTRIBUTE_ModuleHeight, + XFA_ATTRIBUTE_StartChar, + XFA_ATTRIBUTE_Truncate, + XFA_ATTRIBUTE_WideNarrowRatio, + XFA_ATTRIBUTE_ErrorCorrectionLevel, + XFA_ATTRIBUTE_UpsMode, + XFA_ATTRIBUTE_Checksum, + XFA_ATTRIBUTE_CharEncoding, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_DataColumnCount, + XFA_ATTRIBUTE_RowColumnRatio, + XFA_ATTRIBUTE_DataLength, + XFA_ATTRIBUTE_EndChar, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Format, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Output, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Input, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_DataDescription, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Highlight, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Break, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Hand, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Level, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_ColSpan, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_WordCharacterCount, + XFA_ATTRIBUTE_Hyphenate, + XFA_ATTRIBUTE_ExcludeInitialCap, + XFA_ATTRIBUTE_PushCharacterCount, + XFA_ATTRIBUTE_RemainCharacterCount, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_ExcludeAllCaps, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Rid, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_MaxChars, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Url, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_CredentialServerPolicy, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_UrlPolicy, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Connection, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_NumberOfCells, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_H, + XFA_ATTRIBUTE_W, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_HAlign, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Access, + XFA_ATTRIBUTE_Rotate, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_VAlign, + XFA_ATTRIBUTE_MaxH, + XFA_ATTRIBUTE_MaxW, + XFA_ATTRIBUTE_MinH, + XFA_ATTRIBUTE_MinW, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_ColSpan, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Locale, + XFA_ATTRIBUTE_AnchorType, + XFA_ATTRIBUTE_AccessKey, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_H, + XFA_ATTRIBUTE_W, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Cap, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Stroke, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Thickness, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Rate, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_SourceBelow, + XFA_ATTRIBUTE_OutputBelow, + XFA_ATTRIBUTE_SourceAbove, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_H, + XFA_ATTRIBUTE_W, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_HAlign, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Access, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_VAlign, + XFA_ATTRIBUTE_MaxH, + XFA_ATTRIBUTE_MaxW, + XFA_ATTRIBUTE_MinH, + XFA_ATTRIBUTE_MinW, + XFA_ATTRIBUTE_Layout, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_ColSpan, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_AnchorType, + XFA_ATTRIBUTE_AccessKey, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Rid, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Scope, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Connection, + XFA_ATTRIBUTE_RunAt, + XFA_ATTRIBUTE_ExecuteType, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Picker, + XFA_ATTRIBUTE_HScrollPolicy, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTE_TransferEncoding, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Aspect, + XFA_ATTRIBUTE_Href, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Server, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_FracDigits, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_LeadDigits, + XFA_ATTRIBUTE_H, + XFA_ATTRIBUTE_W, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_HAlign, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_AllowMacro, + XFA_ATTRIBUTE_ColumnWidths, + XFA_ATTRIBUTE_Access, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_VAlign, + XFA_ATTRIBUTE_MaxH, + XFA_ATTRIBUTE_MaxW, + XFA_ATTRIBUTE_MinH, + XFA_ATTRIBUTE_MinW, + XFA_ATTRIBUTE_Layout, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_MergeMode, + XFA_ATTRIBUTE_ColSpan, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Locale, + XFA_ATTRIBUTE_AnchorType, + XFA_ATTRIBUTE_RestoreState, + XFA_ATTRIBUTE_Scope, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Timeout, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Mode, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Role, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Stroke, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Inverted, + XFA_ATTRIBUTE_Thickness, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Join, + XFA_ATTRIBUTE_Radius, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_CSpace, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Next, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Previous, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Intact, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_CommandType, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Data, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_ScriptTest, + XFA_ATTRIBUTE_NullTest, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_FormatTest, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Relation, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_DuplexImposition, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_To, + XFA_ATTRIBUTE_Force, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_From, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_DataDescription, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Operation, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_BaseProfile, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTE_RunAt, + XFA_ATTRIBUTE_Binding, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_PasswordChar, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_HScrollPolicy, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_HScrollPolicy, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_PagePosition, + XFA_ATTRIBUTE_OddOrEven, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_InitialNumber, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Numbered, + XFA_ATTRIBUTE_BlankOrNotBlank, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Reserve, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Placement, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Rid, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTE_TransferEncoding, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_MaxLength, + XFA_ATTRIBUTE_Href, + XFA_ATTRIBUTE_Abbr, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_WritingScript, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Action, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Trailer, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_Leader, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_To, + XFA_ATTRIBUTE_UnicodeRange, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_From, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_TrayOut, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Orientation, + XFA_ATTRIBUTE_ImagingBBox, + XFA_ATTRIBUTE_Short, + XFA_ATTRIBUTE_TrayIn, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Stock, + XFA_ATTRIBUTE_Long, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_VScrollPolicy, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_AllowRichText, + XFA_ATTRIBUTE_MultiLine, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_HScrollPolicy, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_MaxEntries, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTE_Contains, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_IsNull, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_DataDescription, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Operation, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_ContentType, + XFA_ATTRIBUTE_TransferEncoding, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Match, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Hand, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_H, + XFA_ATTRIBUTE_W, + XFA_ATTRIBUTE_X, + XFA_ATTRIBUTE_Y, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_HAlign, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Rotate, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_VAlign, + XFA_ATTRIBUTE_MaxH, + XFA_ATTRIBUTE_MaxW, + XFA_ATTRIBUTE_MinH, + XFA_ATTRIBUTE_MinW, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_ColSpan, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Locale, + XFA_ATTRIBUTE_AnchorType, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Rid, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Priority, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Disable, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_LineThrough, + XFA_ATTRIBUTE_Typeface, + XFA_ATTRIBUTE_FontHorizontalScale, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_KerningMode, + XFA_ATTRIBUTE_Underline, + XFA_ATTRIBUTE_BaselineShift, + XFA_ATTRIBUTE_OverlinePeriod, + XFA_ATTRIBUTE_LetterSpacing, + XFA_ATTRIBUTE_LineThroughPeriod, + XFA_ATTRIBUTE_FontVerticalScale, + XFA_ATTRIBUTE_PsName, + XFA_ATTRIBUTE_Size, + XFA_ATTRIBUTE_Posture, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Weight, + XFA_ATTRIBUTE_UnderlinePeriod, + XFA_ATTRIBUTE_Overline, + XFA_ATTRIBUTE_GenericFamily, + XFA_ATTRIBUTE_Checksum, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Relevant, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Override, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Trailer, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Leader, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_CodeType, + XFA_ATTRIBUTE_Archive, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_CodeBase, + XFA_ATTRIBUTE_ClassId, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Connection, + XFA_ATTRIBUTE_LabelRef, + XFA_ATTRIBUTE_ValueRef, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Override, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Value, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Timeout, + XFA_ATTRIBUTE_Connection, + XFA_ATTRIBUTE_Usage, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_DelayedOpen, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Format, + XFA_ATTRIBUTE_EmbedPDF, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_TextEncoding, + XFA_ATTRIBUTE_XdpContent, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Delimiter, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Type, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_StartNew, + XFA_ATTRIBUTE_Trailer, + XFA_ATTRIBUTE_TargetType, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Target, + XFA_ATTRIBUTE_Leader, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Slope, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Hand, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Max, + XFA_ATTRIBUTE_Min, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Initial, + XFA_ATTRIBUTE_Usehref, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Abbr, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Desc, + XFA_ATTRIBUTE_Lock, + XFA_ATTRIBUTE_Id, + XFA_ATTRIBUTE_Name, + XFA_ATTRIBUTE_Ref, + XFA_ATTRIBUTE_Use, + XFA_ATTRIBUTE_Presence, + XFA_ATTRIBUTE_Save, + XFA_ATTRIBUTE_Usehref, +}; +const XFA_PACKETINFO g_XFAPacketData[] = { + {0x0, NULL, XFA_XDPPACKET_USER, NULL, + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, + {0x811929d, L"sourceSet", XFA_XDPPACKET_SourceSet, + L"http://www.xfa.org/schema/xfa-source-set/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0xb843dba, L"pdf", XFA_XDPPACKET_Pdf, L"http://ns.adobe.com/xdp/pdf/", + XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0xc56afbf, L"xdc", XFA_XDPPACKET_Xdc, L"http://www.xfa.org/schema/xdc/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0xc56afcc, L"xdp", XFA_XDPPACKET_XDP, L"http://ns.adobe.com/xdp/", + XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x132a8fbc, L"xmpmeta", XFA_XDPPACKET_Xmpmeta, + L"http://ns.adobe.com/xmpmeta/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, + {0x48d004a8, L"xfdf", XFA_XDPPACKET_Xfdf, L"http://ns.adobe.com/xfdf/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x4e1e39b6, L"config", XFA_XDPPACKET_Config, + L"http://www.xfa.org/schema/xci/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x5473b6dc, L"localeSet", XFA_XDPPACKET_LocaleSet, + L"http://www.xfa.org/schema/xfa-locale-set/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x6038580a, L"stylesheet", XFA_XDPPACKET_Stylesheet, + L"http://www.w3.org/1999/XSL/Transform", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, + {0x803550fc, L"template", XFA_XDPPACKET_Template, + L"http://www.xfa.org/schema/xfa-template/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x8b036f32, L"signature", XFA_XDPPACKET_Signature, + L"http://www.w3.org/2000/09/xmldsig#", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0x99b95079, L"datasets", XFA_XDPPACKET_Datasets, + L"http://www.xfa.org/schema/xfa-data/", + XFA_XDPPACKET_FLAGS_PREFIXMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0xcd309ff4, L"form", XFA_XDPPACKET_Form, + L"http://www.xfa.org/schema/xfa-form/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, + {0xe14c801c, L"connectionSet", XFA_XDPPACKET_ConnectionSet, + L"http://www.xfa.org/schema/xfa-connection-set/", + XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, +}; +const int32_t g_iXFAPacketCount = + sizeof(g_XFAPacketData) / sizeof(XFA_PACKETINFO); +const XFA_SCRIPTHIERARCHY g_XFAScriptIndex[] = { + {0, 0, 0, 2, 316}, {0, 0, 2, 2, 316}, {0, 0, 4, 2, 316}, + {0, 0, 6, 8, 316}, {0, 0, 14, 4, 316}, {0, 0, 18, 5, 317}, + {0, 0, 23, 2, 316}, {0, 0, 25, 1, 316}, {0, 0, 26, 12, 316}, + {0, 0, 38, 2, 316}, {0, 0, 40, 1, 316}, {0, 0, 41, 3, 316}, + {0, 0, 44, 2, 316}, {0, 0, 46, 6, 316}, {0, 0, 52, 0, 316}, + {0, 0, 52, 2, 319}, {0, 0, 54, 2, 316}, {0, 0, 56, 6, 316}, + {0, 0, 62, 0, 316}, {0, 0, 62, 0, 316}, {0, 0, 62, 2, 316}, + {0, 0, 64, 2, 316}, {0, 0, 66, 6, 316}, {0, 0, 72, 4, 316}, + {0, 0, 76, 7, 316}, {0, 0, 83, 2, 320}, {0, 0, 85, 3, 316}, + {0, 0, 88, 3, 316}, {0, 0, 91, 2, 320}, {0, 0, 93, 6, 320}, + {0, 0, 99, 4, 316}, {0, 0, 103, 2, 316}, {0, 0, 105, 3, 319}, + {0, 0, 108, 4, 316}, {0, 0, 112, 3, 316}, {0, 0, 115, 2, 316}, + {0, 0, 117, 6, 316}, {0, 0, 123, 12, 316}, {0, 0, 135, 2, 316}, + {0, 0, 137, 5, 316}, {0, 0, 142, 2, 316}, {0, 0, 144, 3, 316}, + {0, 0, 147, 1, 316}, {0, 0, 148, 14, 316}, {0, 0, 162, 2, 316}, + {0, 0, 164, 2, 316}, {0, 0, 166, 3, 316}, {0, 0, 169, 2, 316}, + {0, 0, 171, 2, 316}, {0, 0, 173, 2, 316}, {0, 0, 175, 4, 316}, + {0, 0, 179, 2, 316}, {0, 0, 181, 2, 316}, {0, 0, 183, 0, 319}, + {0, 0, 183, 20, 316}, {0, 0, 203, 1, 316}, {0, 0, 204, 3, 316}, + {0, 0, 207, 2, 316}, {0, 0, 209, 0, 316}, {0, 0, 209, 2, 316}, + {0, 0, 211, 2, 316}, {0, 0, 213, 4, 320}, {0, 0, 217, 0, 316}, + {0, 0, 217, 1, 316}, {0, 0, 218, 3, 316}, {0, 4, 221, 0, 312}, + {4, 1, 221, 1, 316}, {5, 0, 222, 2, 316}, {5, 1, 224, 3, -1}, + {6, 0, 227, 0, 316}, {6, 0, 227, 2, 316}, {6, 0, 229, 2, 316}, + {6, 0, 231, 3, 316}, {6, 0, 234, 2, 316}, {6, 0, 236, 6, 316}, + {6, 0, 242, 10, 317}, {6, 0, 252, 9, 316}, {6, 0, 261, 5, 318}, + {6, 0, 266, 4, 318}, {6, 0, 270, 2, 316}, {6, 0, 272, 2, 316}, + {6, 0, 274, 5, 316}, {6, 0, 279, 3, 316}, {6, 0, 282, 2, 316}, + {6, 0, 284, 2, 316}, {6, 0, 286, 2, 316}, {6, 0, 288, 2, 316}, + {6, 0, 290, 4, 316}, {6, 0, 294, 3, 316}, {6, 0, 297, 3, 316}, + {6, 0, 300, 2, 316}, {6, 0, 302, 2, 316}, {6, 0, 304, 2, 316}, + {6, 13, 306, 36, 317}, {19, 0, 342, 3, 316}, {19, 0, 345, 2, 316}, + {19, 0, 347, 2, 316}, {19, 0, 349, 2, 316}, {19, 0, 351, 7, 317}, + {19, 2, 358, 16, 312}, {21, 0, 374, 2, 320}, {21, 0, 376, 2, 316}, + {21, 0, 378, 0, 316}, {21, 0, 378, 2, 316}, {21, 0, 380, 6, 316}, + {21, 0, 386, 3, 316}, {21, 0, 389, 2, 316}, {21, 0, 391, 4, 316}, + {21, 0, 395, 0, 316}, {21, 5, 395, 30, 316}, {26, 0, 425, 2, 320}, + {26, 0, 427, 3, 316}, {26, 0, 430, 2, 320}, {26, 0, 432, 5, 316}, + {26, 0, 437, 2, 316}, {26, 0, 439, 3, 316}, {26, 0, 442, 2, 316}, + {26, 0, 444, 8, 316}, {26, 0, 452, 1, 316}, {26, 0, 453, 2, 316}, + {26, 0, 455, 2, 316}, {26, 0, 457, 4, 316}, {26, 0, 461, 0, 316}, + {26, 0, 461, 2, 316}, {26, 0, 463, 2, 316}, {26, 0, 465, 6, 318}, + {26, 5, 471, 31, 317}, {31, 0, 502, 2, 320}, {31, 0, 504, 2, 316}, + {31, 0, 506, 2, 316}, {31, 0, 508, 4, 320}, {31, 16, 512, 14, 312}, + {47, 0, 526, 2, 316}, {47, 0, 528, 2, 316}, {47, 0, 530, 2, 316}, + {47, 0, 532, 2, 316}, {47, 0, 534, 3, 316}, {47, 0, 537, 2, 316}, + {47, 0, 539, 3, 316}, {47, 0, 542, 3, 316}, {47, 0, 545, 4, 318}, + {47, 0, 549, 4, 316}, {47, 0, 553, 2, 316}, {47, 0, 555, 0, 316}, + {47, 0, 555, 2, 316}, {47, 0, 557, 3, 316}, {47, 0, 560, 6, 316}, + {47, 0, 566, 2, 316}, {47, 0, 568, 2, 316}, {47, 0, 570, 3, 316}, + {47, 19, 573, 1, 312}, {66, 0, 574, 2, 316}, {66, 0, 576, 8, 316}, + {66, 0, 584, 2, 316}, {66, 0, 586, 4, 316}, {66, 0, 590, 5, 316}, + {66, 0, 595, 3, 316}, {66, 0, 598, 2, 320}, {66, 0, 600, 3, 316}, + {66, 0, 603, 7, 316}, {66, 0, 610, 3, 316}, {66, 0, 613, 0, 316}, + {66, 0, 613, 4, 317}, {66, 0, 617, 4, 318}, {66, 0, 621, 2, 320}, + {66, 0, 623, 5, 316}, {66, 0, 628, 2, 316}, {66, 0, 630, 2, 316}, + {66, 0, 632, 2, 320}, {66, 0, 634, 2, 320}, {66, 0, 636, 4, 316}, + {66, 0, 640, 2, 316}, {66, 0, 642, 1, 316}, {66, 0, 643, 1, 316}, + {66, 0, 644, 4, 316}, {66, 0, 648, 3, 316}, {66, 7, 651, 2, 319}, + {73, 0, 653, 2, 316}, {73, 0, 655, 2, 316}, {73, 0, 657, 3, 316}, + {73, 4, 660, 4, 312}, {77, 0, 664, 10, 316}, {77, 0, 674, 2, 316}, + {77, 0, 676, 4, 316}, {77, 0, 680, 4, 316}, {77, 0, 684, 3, 316}, + {77, 0, 687, 2, 316}, {77, 0, 689, 2, 316}, {77, 0, 691, 8, 317}, + {77, 0, 699, 3, 316}, {77, 0, 702, 3, 316}, {77, 0, 705, 2, 316}, + {77, 0, 707, 2, 316}, {77, 0, 709, 5, 316}, {77, 0, 714, 4, 316}, + {77, 0, 718, 2, 316}, {77, 0, 720, 8, 318}, {77, 0, 728, 1, 316}, + {77, 0, 729, 2, 320}, {77, 0, 731, 3, 316}, {77, 1, 734, 4, 316}, + {78, 0, 738, 5, 316}, {78, 0, 743, 3, 316}, {78, 0, 746, 1, 316}, + {78, 0, 747, 2, 320}, {78, 0, 749, 0, 313}, {78, 0, 749, 2, 316}, + {78, 5, 751, 3, 316}, {83, 0, 754, 5, 316}, {83, 0, 759, 7, 316}, + {83, 0, 766, 6, 316}, {83, 0, 772, 3, 316}, {83, 0, 775, 2, 316}, + {83, 0, 777, 5, 316}, {83, 0, 782, 2, 316}, {83, 0, 784, 0, 314}, + {83, 0, 784, 2, 316}, {83, 0, 786, 1, 316}, {83, 0, 787, 2, 316}, + {83, 0, 789, 5, 316}, {83, 0, 794, 2, 316}, {83, 0, 796, 1, 316}, + {83, 0, 797, 2, 316}, {83, 0, 799, 2, 316}, {83, 0, 801, 6, 316}, + {83, 0, 807, 2, 316}, {83, 0, 809, 2, 320}, {83, 0, 811, 3, 316}, + {83, 0, 814, 4, 316}, {83, 0, 818, 2, 316}, {83, 0, 820, 2, 316}, + {83, 0, 822, 2, 316}, {83, 0, 824, 2, 316}, {83, 0, 826, 2, 316}, + {83, 0, 828, 2, 316}, {83, 0, 830, 4, 318}, {83, 1, 834, 2, 316}, + {84, 0, 836, 5, 316}, {84, 0, 841, 20, 317}, {84, 0, 861, 2, 316}, + {84, 0, 863, 0, 316}, {84, 0, 863, 2, 316}, {84, 0, 865, 4, 320}, + {84, 0, 869, 0, 316}, {84, 0, 869, 2, 316}, {84, 0, 871, 1, 316}, + {84, 0, 872, 2, 316}, {84, 0, 874, 3, 316}, {84, 0, 877, 2, 316}, + {84, 0, 879, 2, 316}, {84, 0, 881, 4, 316}, {84, 0, 885, 3, 316}, + {84, 0, 888, 17, 316}, {84, 6, 905, 1, 319}, {90, 0, 906, 2, 316}, + {90, 0, 908, 2, 320}, {90, 0, 910, 2, 320}, {90, 0, 912, 2, 316}, + {90, 0, 914, 2, 316}, {90, 0, 916, 4, 318}, {90, 0, 920, 2, 316}, + {90, 5, 922, 0, 312}, {95, 0, 922, 2, 316}, {95, 0, 924, 4, 316}, + {95, 0, 928, 4, 316}, {95, 0, 932, 6, 316}, {95, 0, 938, 2, 316}, + {95, 0, 940, 4, 316}, {95, 0, 944, 3, 316}, {95, 0, 947, 3, 316}, + {95, 0, 950, 2, 316}, {95, 0, 952, 3, 316}, {95, 0, 955, 0, 316}, + {95, 0, 955, 0, 316}, {95, 0, 955, 2, 316}, {95, 0, 957, 7, 316}, + {95, 0, 964, 2, 316}, {95, 0, 966, 0, 319}, {95, 0, 966, 7, 316}, + {95, 0, 973, 2, 316}, {95, 0, 975, 2, 316}, {95, 3, 977, 1, 316}, + {98, 0, 978, 2, 320}, {98, 0, 980, 4, 316}, {98, 0, 984, 0, 316}, + {98, 0, 984, 2, 316}, {98, 0, 986, 2, 316}, {98, 0, 988, 4, 316}, + {98, 0, 992, 1, 316}, {98, 0, 993, 2, 316}, {98, 0, 995, 2, 316}, + {98, 0, 997, 3, 316}, {98, 0, 1000, 2, 317}, {98, 0, 1002, 0, 316}, + {98, 0, 1002, 4, 316}, {98, 0, 1006, 4, 316}, {98, 0, 1010, 2, 316}, + {98, 0, 1012, 3, 316}, {98, 0, 1015, 4, 316}, {98, 0, 1019, 7, 316}, + {98, 0, 1026, 4, 316}, {98, 0, 1030, 1, 313}, {98, 17, 1031, 3, 316}, + {115, 0, 1034, 5, 316}, {115, 0, 1039, 2, 316}, {115, 0, 1041, 1, 316}, + {115, 0, 1042, 4, 316}, {115, 0, 1046, 2, 316}, {115, 0, 1048, 2, 316}, + {115, 0, 1050, 1, 316}, {115, 0, 1051, 2, 316}, {115, 0, 1053, 5, 316}, + {115, 0, 1058, 1, -1}, {115, 4, 1059, 1, 312}, {119, 1, 1060, 0, 313}, + {120, 2, 1060, 8, 312}, {122, 11, 1068, 6, 315}, {133, 2, 1074, 0, 316}, + {135, 0, 1074, 0, 316}, {135, 3, 1074, 2, 316}, {138, 0, 1076, 2, 316}, +}; +const XFA_METHODINFO g_SomMethodData[] = { + {0x3c752495, L"verify", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: + Script_SignaturePseudoModel_Verify}, + {0xa68635f1, L"sign", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: + Script_SignaturePseudoModel_Sign}, + {0xa7f2c5e6, L"enumerate", + (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: + Script_SignaturePseudoModel_Enumerate}, + {0xd8ed1467, L"clear", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: + Script_SignaturePseudoModel_Clear}, + {0x4bdcce13, L"execute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_WsdlConnection_Execute}, + {0x1c296ba4, L"restore", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Delta_Restore}, + {0x7d123a9, L"clearItems", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ClearItems}, + {0xfb0b007, L"execEvent", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecEvent}, + {0x6716ce97, L"execInitialize", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecInitialize}, + {0x7bb919c2, L"deleteItem", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_DeleteItem}, + {0x9f053d5e, L"getSaveItem", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetSaveItem}, + {0xbbd32747, L"boundItem", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_BoundItem}, + {0xc492d950, L"getItemState", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetItemState}, + {0xc6013cd3, L"execCalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecCalculate}, + {0xd8930d0e, L"setItems", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_SetItems}, + {0xe0f15045, L"getDisplayItem", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetDisplayItem}, + {0xe23acddc, L"setItemState", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_SetItemState}, + {0xe2dfb2f8, L"addItem", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_AddItem}, + {0xef8ce48f, L"execValidate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecValidate}, + {0x461079ef, L"emit", (XFA_METHOD_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Emit}, + {0xfec90c63, L"reset", (XFA_METHOD_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Reset}, + {0xfb0b007, L"execEvent", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecEvent}, + {0x3d832221, L"selectedMember", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_SelectedMember}, + {0x6716ce97, L"execInitialize", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecInitialize}, + {0xc6013cd3, L"execCalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecCalculate}, + {0xef8ce48f, L"execValidate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecValidate}, + {0xfb0b007, L"execEvent", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecEvent}, + {0x6716ce97, L"execInitialize", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecInitialize}, + {0xc6013cd3, L"execCalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecCalculate}, + {0xd9b9b1f1, L"getInvalidObjects", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_GetInvalidObjects}, + {0xef8ce48f, L"execValidate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecValidate}, + {0xa366b7c, L"exportData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_ExportData}, + {0x16cc226c, L"gotoURL", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_GotoURL}, + {0x1e0722f5, L"pageDown", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_PageDown}, + {0x3e66cb2c, L"setFocus", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_SetFocus}, + {0x4ac9faae, L"openList", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_OpenList}, + {0x7b89714f, L"response", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Response}, + {0x7fd9fd58, L"documentInBatch", + (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_DocumentInBatch}, + {0xaf1d019d, L"resetData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_ResetData}, + {0xb07be13c, L"beep", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Beep}, + {0xb1882ca0, L"getFocus", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_GetFocus}, + {0xbf4ba9ee, L"messageBox", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_MessageBox}, + {0xd6d4dbc1, L"documentCountInBatch", + (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_DocumentCountInBatch}, + {0xdd7676ed, L"print", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Print}, + {0xe2f863d0, L"currentDateTime", + (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_CurrentDateTime}, + {0xf995d0f5, L"importData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_ImportData}, + {0xfeb96b62, L"pageUp", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_PageUp}, + {0x68, L"h", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_H}, + {0x77, L"w", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_W}, + {0x78, L"x", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_X}, + {0x79, L"y", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_Y}, + {0x5460206, L"pageCount", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_PageCount}, + {0x5eb5b0f, L"pageSpan", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_PageSpan}, + {0x10f1b1bd, L"page", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_Page}, + {0x1c1e6318, L"pageContent", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_PageContent}, + {0x1c1f4a5c, L"absPageCount", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_AbsPageCount}, + {0x1ec47db5, L"absPageCountInBatch", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_AbsPageCountInBatch}, + {0x2e4ecbdb, L"sheetCountInBatch", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_SheetCountInBatch}, + {0x2fcff4b5, L"relayout", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_Relayout}, + {0x3bf1c2a5, L"absPageSpan", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_AbsPageSpan}, + {0x5775c2cc, L"absPageInBatch", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_AbsPageInBatch}, + {0x8c5feb32, L"sheetInBatch", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_SheetInBatch}, + {0x8f3a8379, L"sheet", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_Sheet}, + {0x96f3c4cb, L"relayoutPageArea", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_RelayoutPageArea}, + {0xd2a4a542, L"sheetCount", + (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_SheetCount}, + {0xe74f0653, L"absPage", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_AbsPage}, + {0x44c352ad, L"formNodes", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_FormNodes}, + {0x45efb847, L"remerge", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_Remerge}, + {0x6716ce97, L"execInitialize", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecInitialize}, + {0x712c6afa, L"createNode", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_CreateNode}, + {0xa8a35e25, L"recalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_Recalculate}, + {0xc6013cd3, L"execCalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecCalculate}, + {0xef8ce48f, L"execValidate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecValidate}, + {0x4cc1c0f9, L"moveCurrentRecord", + (XFA_METHOD_CALLBACK)&CScript_DataWindow:: + Script_DataWindow_MoveCurrentRecord}, + {0x5779d65f, L"record", + (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_Record}, + {0x8a476498, L"gotoRecord", + (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_GotoRecord}, + {0xaac241c8, L"isRecordGroup", + (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_IsRecordGroup}, + {0x1c6f4277, L"evaluate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Manifest_Evaluate}, + {0x2afec2cc, L"moveInstance", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_MoveInstance}, + {0x2bf94a63, L"removeInstance", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_RemoveInstance}, + {0x303adaf4, L"setInstances", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_SetInstances}, + {0x4d76b89e, L"addInstance", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_AddInstance}, + {0xc660dc8a, L"insertInstance", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_InsertInstance}, + {0xddfd1ea1, L"metadata", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Desc_Metadata}, + {0x44c352ad, L"formNodes", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_FormNodes}, + {0x45efb847, L"remerge", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_Remerge}, + {0x6716ce97, L"execInitialize", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecInitialize}, + {0xa8a35e25, L"recalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_Recalculate}, + {0xc6013cd3, L"execCalculate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecCalculate}, + {0xef8ce48f, L"execValidate", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecValidate}, + {0x60490a85, L"message", (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: + Script_LogPseudoModel_Message}, + {0x60ecfcc9, L"traceDeactivate", + (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: + Script_LogPseudoModel_TraceDeactivate}, + {0x86a0f4c0, L"traceActivate", + (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: + Script_LogPseudoModel_TraceActivate}, + {0x93eac39a, L"traceEnabled", (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: + Script_LogPseudoModel_TraceEnabled}, + {0xd1227e6f, L"trace", + (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel::Script_LogPseudoModel_Trace}, + {0x36c0ee14, L"getAttribute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_GetAttribute}, + {0x5468e2a0, L"setAttribute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_SetAttribute}, + {0xadc48de2, L"removeAttribute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_RemoveAttribute}, + {0x3848b3f, L"next", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Next}, + {0x14e25bc8, L"cancelBatch", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_CancelBatch}, + {0x3ce05d68, L"first", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_First}, + {0x649e1e65, L"updateBatch", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_UpdateBatch}, + {0x6a3405dd, L"previous", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Previous}, + {0x74818fb3, L"isBOF", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_IsBOF}, + {0x74d07a76, L"isEOF", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_IsEOF}, + {0x7613cb66, L"cancel", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Cancel}, + {0x7baca2e3, L"update", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Update}, + {0x8b90e1f2, L"open", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Open}, + {0x9c6471b3, L"delete", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Delete}, + {0xa7315093, L"addNew", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_AddNew}, + {0xa7ce5f8d, L"requery", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Requery}, + {0xc7368674, L"resync", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Resync}, + {0xd9f47f36, L"close", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Close}, + {0xf54481d4, L"last", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Last}, + {0xf7965460, L"hasDataChanged", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_HasDataChanged}, + {0x6275f6af, L"item", + (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Item}, + {0x7033bfd5, L"insert", + (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Insert}, + {0x9cab7cae, L"remove", + (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Remove}, + {0xda12e518, L"append", + (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Append}, + {0xd892a054, L"namedItem", + (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_TreelistClass_NamedItem}, + {0xba2dd386, L"resolveNode", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_TreeClass_ResolveNode}, + {0xe509e2b9, L"resolveNodes", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_TreeClass_ResolveNodes}, + {0x1bca1ebd, L"applyXSL", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_ApplyXSL}, + {0x36c0ee14, L"getAttribute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_GetAttribute}, + {0x5468e2a0, L"setAttribute", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SetAttribute}, + {0x5ee00996, L"setElement", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SetElement}, + {0x92dada4f, L"saveFilteredXML", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SaveFilteredXML}, + {0x9c456500, L"saveXML", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SaveXML}, + {0xabd3200a, L"getElement", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_GetElement}, + {0xb269c60d, L"isPropertySpecified", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_IsPropertySpecified}, + {0xb528be91, L"loadXML", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_LoadXML}, + {0xd9f46591, L"clone", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_Clone}, + {0xe006a76b, L"assignNode", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_AssignNode}, + {0x7303fcea, L"getDelta", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ContainerClass_GetDelta}, + {0xe7742c9d, L"getDeltas", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ContainerClass_GetDeltas}, + {0x30ff6aad, L"clearErrorList", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_ClearErrorList}, + {0x712c6afa, L"createNode", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_CreateNode}, + {0x83a6411d, L"isCompatibleNS", + (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_IsCompatibleNS}, +}; +const int32_t g_iSomMethodCount = + sizeof(g_SomMethodData) / sizeof(XFA_METHODINFO); +const XFA_SCRIPTATTRIBUTEINFO g_SomAttributeData[] = { + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xb3543a6, L"max", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Max, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x45a6daf8, L"eofAction", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_EofAction, XFA_SCRIPT_Basic}, + {0x5ec958c0, L"cursorType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CursorType, XFA_SCRIPT_Basic}, + {0x79975f2b, L"lockType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LockType, XFA_SCRIPT_Basic}, + {0xa5340ff5, L"bofAction", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BofAction, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc5762157, L"cursorLocation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CursorLocation, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1ee2d24d, L"instanceIndex", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_InstanceIndex, -1, + XFA_SCRIPT_Basic}, + {0x8c99377e, L"relation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relation, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0x3106c3a, L"beforeTarget", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BeforeTarget, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x13a08bdb, L"overflowTarget", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OverflowTarget, XFA_SCRIPT_Basic}, + {0x169134a1, L"overflowLeader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OverflowLeader, XFA_SCRIPT_Basic}, + {0x20914367, L"overflowTrailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OverflowTrailer, XFA_SCRIPT_Basic}, + {0x453eaf38, L"startNew", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, + {0x64110ab5, L"bookendTrailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BookendTrailer, XFA_SCRIPT_Basic}, + {0xb6b44172, L"after", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_After, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc3c1442f, L"bookendLeader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BookendLeader, XFA_SCRIPT_Basic}, + {0xcb150479, L"afterTarget", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AfterTarget, XFA_SCRIPT_Basic}, + {0xf4ffce73, L"before", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Before, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, + XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x47cfa43a, L"allowNeutral", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AllowNeutral, XFA_SCRIPT_Basic}, + {0x7c2fd80b, L"mark", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Mark, XFA_SCRIPT_Basic}, + {0x8ed182d1, L"shape", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Shape, XFA_SCRIPT_Basic}, + {0xa686975b, L"size", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Size, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x5c054755, L"startAngle", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_StartAngle, XFA_SCRIPT_Basic}, + {0x74788f8b, L"sweepAngle", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SweepAngle, XFA_SCRIPT_Basic}, + {0x9d833d75, L"circular", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Circular, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd996fa9b, L"hand", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xb0e5485d, L"bind", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Bind, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xcd7f7b54, L"from", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8e29d794, L"signatureType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SignatureType, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe11a2cbc, L"permissions", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Permissions, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x453eaf38, L"startNew", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, + {0x9dcc3ab3, L"trailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, + {0xa6118c89, L"targetType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TargetType, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xcbcaf66d, L"leader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x2d574d58, L"this", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Xfa_This, + -1, XFA_SCRIPT_Object}, + {0x4fdc3454, L"timeStamp", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TimeStamp, XFA_SCRIPT_Basic}, + {0xb598a1f7, L"uuid", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Uuid, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xcfea02e, L"leftInset", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LeftInset, XFA_SCRIPT_Basic}, + {0x1356caf8, L"bottomInset", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BottomInset, XFA_SCRIPT_Basic}, + {0x25764436, L"topInset", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TopInset, XFA_SCRIPT_Basic}, + {0x8a692521, L"rightInset", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RightInset, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1e459b8f, L"nonRepudiation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_NonRepudiation, XFA_SCRIPT_Basic}, + {0x2bb3f470, L"encipherOnly", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_EncipherOnly, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0x5f760b50, L"digitalSignature", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DigitalSignature, XFA_SCRIPT_Basic}, + {0x69aa2292, L"crlSign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CrlSign, XFA_SCRIPT_Basic}, + {0x98fd4d81, L"keyAgreement", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_KeyAgreement, XFA_SCRIPT_Basic}, + {0xa66404cb, L"keyEncipherment", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_KeyEncipherment, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xca5dc27c, L"dataEncipherment", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataEncipherment, XFA_SCRIPT_Basic}, + {0xe8f118a8, L"keyCertSign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_KeyCertSign, XFA_SCRIPT_Basic}, + {0xfea53ec6, L"decipherOnly", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DecipherOnly, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8b90e1f2, L"open", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Open, XFA_SCRIPT_Basic}, + {0x957fa006, L"commitOn", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CommitOn, XFA_SCRIPT_Basic}, + {0xb12128b7, L"textEntry", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TextEntry, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0x2282c73, L"hAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, + {0x8d4f1c7, L"textIndent", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TextIndent, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2a82d99c, L"marginRight", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MarginRight, XFA_SCRIPT_Basic}, + {0x534729c9, L"marginLeft", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MarginLeft, XFA_SCRIPT_Basic}, + {0x5739d1ff, L"radixOffset", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RadixOffset, XFA_SCRIPT_Basic}, + {0x577682ac, L"preserve", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Preserve, XFA_SCRIPT_Basic}, + {0x731e0665, L"spaceBelow", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SpaceBelow, XFA_SCRIPT_Basic}, + {0x7a7cc341, L"vAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, + {0x836d4d7c, L"tabDefault", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TabDefault, XFA_SCRIPT_Basic}, + {0x8fa01790, L"tabStops", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TabStops, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd4b01921, L"lineHeight", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LineHeight, XFA_SCRIPT_Basic}, + {0xe18b5659, L"spaceAbove", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SpaceAbove, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd861f8af, L"addRevocationInfo", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AddRevocationInfo, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6128d8d, L"activity", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Activity, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x43e349b, L"dataRowCount", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataRowCount, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x28e17e91, L"dataPrep", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataPrep, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0x3650557e, L"textLocation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TextLocation, XFA_SCRIPT_Basic}, + {0x3b582286, L"moduleWidth", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ModuleWidth, XFA_SCRIPT_Basic}, + {0x52666f1c, L"printCheckDigit", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_PrintCheckDigit, XFA_SCRIPT_Basic}, + {0x5404d6df, L"moduleHeight", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ModuleHeight, XFA_SCRIPT_Basic}, + {0x5ab23b6c, L"startChar", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_StartChar, XFA_SCRIPT_Basic}, + {0x7c732a66, L"truncate", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Truncate, XFA_SCRIPT_Basic}, + {0x8d181d61, L"wideNarrowRatio", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_WideNarrowRatio, XFA_SCRIPT_Basic}, + {0x99800d7a, L"errorCorrectionLevel", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ErrorCorrectionLevel, XFA_SCRIPT_Basic}, + {0x9a63da3d, L"upsMode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_UpsMode, XFA_SCRIPT_Basic}, + {0xaf754613, L"checksum", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Checksum, XFA_SCRIPT_Basic}, + {0xb045fbc5, L"charEncoding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CharEncoding, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc035c6b1, L"dataColumnCount", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataColumnCount, XFA_SCRIPT_Basic}, + {0xd3c84d25, L"rowColumnRatio", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RowColumnRatio, XFA_SCRIPT_Basic}, + {0xd57c513c, L"dataLength", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataLength, XFA_SCRIPT_Basic}, + {0xf575ca75, L"endChar", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_EndChar, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0x28dee6e9, L"format", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Format, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x60d4c8b1, L"output", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Output, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6a39990, L"input", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Input, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x2b5df51e, L"dataDescription", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x6c0d9600, L"currentValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_CurrentValue, -1, + XFA_SCRIPT_Basic}, + {0x942643f0, L"savedValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_SavedValue, -1, + XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_Target, -1, + XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd4cc53f8, L"highlight", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Highlight, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x5518c25, L"break", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Break, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd996fa9b, L"hand", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1059ec18, L"level", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_Integer, + XFA_ATTRIBUTE_Level, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xac06e2b0, L"colSpan", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f105f72, L"wordCharacterCount", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_WordCharacterCount, XFA_SCRIPT_Basic}, + {0x3d123c26, L"hyphenate", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Hyphenate, XFA_SCRIPT_Basic}, + {0x66539c48, L"excludeInitialCap", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ExcludeInitialCap, XFA_SCRIPT_Basic}, + {0x6a95c976, L"pushCharacterCount", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_PushCharacterCount, XFA_SCRIPT_Basic}, + {0x982bd892, L"remainCharacterCount", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RemainCharacterCount, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe5c96d6a, L"excludeAllCaps", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ExcludeAllCaps, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8af2e657, L"maxChars", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxChars, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc080cd3, L"url", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Url, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa6710262, L"credentialServerPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CredentialServerPolicy, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc2ba0923, L"urlPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_UrlPolicy, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x47d03490, L"connection", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x78bff531, L"numberOfCells", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_Integer, + XFA_ATTRIBUTE_NumberOfCells, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, + {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0x2282c73, L"hAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1abbd7e0, L"dataNode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, + XFA_SCRIPT_Object}, + {0x25839852, L"access", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, + {0x2ee7678f, L"rotate", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Rotate, XFA_SCRIPT_Basic}, + {0x3b1ddd06, L"fillColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, + XFA_SCRIPT_Basic}, + {0x54c399e3, L"formattedValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_FormattedValue, -1, + XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x5a3b375d, L"borderColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, + XFA_SCRIPT_Basic}, + {0x5e936ed6, L"fontColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FontColor, -1, + XFA_SCRIPT_Basic}, + {0x6826c408, L"parentSubform", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_ParentSubform, -1, + XFA_SCRIPT_Basic}, + {0x79b67434, L"mandatoryMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_MandatoryMessage, -1, + XFA_SCRIPT_Basic}, + {0x7a7cc341, L"vAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, + {0x7c2ff6ae, L"maxH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, + {0x7c2ff6bd, L"maxW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, + {0x7d02356c, L"minH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, + {0x7d02357b, L"minW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, + {0x85fd6faf, L"mandatory", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_Mandatory, -1, + XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0x964fb42e, L"formatMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_FormatMessage, -1, + XFA_SCRIPT_Basic}, + {0xa03cf627, L"rawValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xa60dd202, L"length", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_Length, -1, + XFA_SCRIPT_Basic}, + {0xac06e2b0, L"colSpan", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbc8fa350, L"locale", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Locale, XFA_SCRIPT_Basic}, + {0xc2bd40fd, L"anchorType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, + {0xc4fed09b, L"accessKey", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AccessKey, XFA_SCRIPT_Basic}, + {0xcabfa3d0, L"validationMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, + XFA_SCRIPT_Basic}, + {0xdcecd663, L"editValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_EditValue, -1, + XFA_SCRIPT_Basic}, + {0xe07e5061, L"selectedIndex", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_SelectedIndex, -1, + XFA_SCRIPT_Basic}, + {0xf65e34be, L"borderWidth", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, + XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, + {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd843798, L"fullText", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_FullText, + -1, XFA_SCRIPT_Basic}, + {0x1b6d1cf5, L"reenter", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Reenter, + -1, XFA_SCRIPT_Basic}, + {0x1e6ffa9a, L"prevContentType", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_PrevContentType, + -1, XFA_SCRIPT_Basic}, + {0x25a3c206, L"soapFaultString", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_SoapFaultString, + -1, XFA_SCRIPT_Basic}, + {0x2e00c007, L"newContentType", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_NewContentType, + -1, XFA_SCRIPT_Basic}, + {0x4570500f, L"modifier", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Modifier, + -1, XFA_SCRIPT_Basic}, + {0x50e2e33b, L"selEnd", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_SelEnd, + -1, XFA_SCRIPT_Basic}, + {0x57de87c2, L"prevText", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_PrevText, + -1, XFA_SCRIPT_Basic}, + {0x6ea04e0a, L"soapFaultCode", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_SoapFaultCode, + -1, XFA_SCRIPT_Basic}, + {0x6f6556cf, L"newText", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_NewText, + -1, XFA_SCRIPT_Basic}, + {0x891f4606, L"change", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Change, + -1, XFA_SCRIPT_Basic}, + {0x8fa3c19e, L"shift", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Shift, + -1, XFA_SCRIPT_Basic}, + {0xa9d9b2e1, L"keyDown", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_KeyDown, + -1, XFA_SCRIPT_Basic}, + {0xbfc89db2, L"selStart", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_SelStart, + -1, XFA_SCRIPT_Basic}, + {0xc32a5812, L"commitKey", + (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_CommitKey, + -1, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: + Script_EventPseudoModel_Target, + -1, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xa2e3514, L"cap", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Cap, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x5392ea58, L"stroke", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Stroke, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x94446dcc, L"thickness", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Thickness, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1ec8ab2c, L"rate", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Rate, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x7b29630a, L"sourceBelow", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SourceBelow, XFA_SCRIPT_Basic}, + {0x8fc36c0a, L"outputBelow", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OutputBelow, XFA_SCRIPT_Basic}, + {0xe996b2fe, L"sourceAbove", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_SourceAbove, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, + {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0x2282c73, L"hAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xf23332f, L"errorText", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_ErrorText, -1, + XFA_SCRIPT_Basic}, + {0x1abbd7e0, L"dataNode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, + XFA_SCRIPT_Object}, + {0x25839852, L"access", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, + {0x3b1ddd06, L"fillColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, + XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x5a3b375d, L"borderColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, + XFA_SCRIPT_Basic}, + {0x79b67434, L"mandatoryMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_MandatoryMessage, -1, + XFA_SCRIPT_Basic}, + {0x7a7cc341, L"vAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, + {0x7c2ff6ae, L"maxH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, + {0x7c2ff6bd, L"maxW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, + {0x7d02356c, L"minH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, + {0x7d02357b, L"minW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, + {0x7e7e845e, L"layout", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Layout, XFA_SCRIPT_Basic}, + {0x846599f8, L"transient", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_Transient, -1, + XFA_SCRIPT_Basic}, + {0x85fd6faf, L"mandatory", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_Mandatory, -1, + XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xa03cf627, L"rawValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_DefaultAndRawValue, + -1, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_DefaultAndRawValue, + -1, XFA_SCRIPT_Basic}, + {0xac06e2b0, L"colSpan", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc2bd40fd, L"anchorType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, + {0xc4fed09b, L"accessKey", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AccessKey, XFA_SCRIPT_Basic}, + {0xcabfa3d0, L"validationMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, + XFA_SCRIPT_Basic}, + {0xf65e34be, L"borderWidth", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xeda9017a, L"scope", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Scope, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x47d03490, L"connection", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, + {0x6cfa828a, L"runAt", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RunAt, XFA_SCRIPT_Basic}, + {0xa1b0d2f5, L"executeType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ExecuteType, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe6f99487, L"hScrollPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x42fed1fd, L"contentType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, + {0x54fa722c, L"transferEncoding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd171b240, L"aspect", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Aspect, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, + XFA_SCRIPT_Basic}, + {0xdb55fec5, L"href", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Href, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0x7f6fd3d7, L"server", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Server, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x4b8bc840, L"fracDigits", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_FracDigits, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xde7f92ba, L"leadDigits", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LeadDigits, XFA_SCRIPT_Basic}, + {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, + {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0x2282c73, L"hAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1414d431, L"allowMacro", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AllowMacro, XFA_SCRIPT_Basic}, + {0x1517dfa1, L"columnWidths", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColumnWidths, XFA_SCRIPT_Basic}, + {0x1abbd7e0, L"dataNode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, + XFA_SCRIPT_Object}, + {0x1ee2d24d, L"instanceIndex", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_InstanceIndex, -1, + XFA_SCRIPT_Basic}, + {0x25839852, L"access", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, + {0x3b1ddd06, L"fillColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, + XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x5a3b375d, L"borderColor", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, + XFA_SCRIPT_Basic}, + {0x7a7cc341, L"vAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, + {0x7c2ff6ae, L"maxH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, + {0x7c2ff6bd, L"maxW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, + {0x7d02356c, L"minH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, + {0x7d02357b, L"minW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, + {0x7e7e845e, L"layout", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Layout, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0x9cc17d75, L"mergeMode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MergeMode, XFA_SCRIPT_Basic}, + {0x9f3e9510, L"instanceManager", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Subform_InstanceManager, -1, + XFA_SCRIPT_Object}, + {0xac06e2b0, L"colSpan", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbc8fa350, L"locale", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Subform_Locale, -1, + XFA_SCRIPT_Basic}, + {0xc2bd40fd, L"anchorType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, + {0xcabfa3d0, L"validationMessage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, + XFA_SCRIPT_Basic}, + {0xe4c3a5e5, L"restoreState", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RestoreState, XFA_SCRIPT_Basic}, + {0xeda9017a, L"scope", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Scope, XFA_SCRIPT_Basic}, + {0xf65e34be, L"borderWidth", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0x5a50e9e6, L"version", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Handler_Version, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x4107ed, L"foxitAppType", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_FoxitAppType, + -1, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Name, + -1, XFA_SCRIPT_Basic}, + {0x66c1ae9, L"validationsEnabled", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_ValidationsEnabled, + -1, XFA_SCRIPT_Basic}, + {0x14d04502, L"title", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Title, + -1, XFA_SCRIPT_Basic}, + {0x193afe8b, L"foxitName", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_FoxitName, + -1, XFA_SCRIPT_Basic}, + {0x392ae445, L"platform", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Platform, + -1, XFA_SCRIPT_Basic}, + {0x5a50e9e6, L"version", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Version, + -1, XFA_SCRIPT_Basic}, + {0x66cb1eed, L"variation", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Variation, + -1, XFA_SCRIPT_Basic}, + {0x7717cbc4, L"language", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_Language, + -1, XFA_SCRIPT_Basic}, + {0x86698963, L"appType", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_AppType, + -1, XFA_SCRIPT_Basic}, + {0x94ff9e8d, L"calculationsEnabled", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_CalculationsEnabled, + -1, XFA_SCRIPT_Basic}, + {0xbcd44940, L"currentPage", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_CurrentPage, + -1, XFA_SCRIPT_Basic}, + {0xd4286870, L"foxitVersion", + (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_FoxitVersion, + -1, XFA_SCRIPT_Basic}, + {0xd592b920, L"numPages", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: + Script_HostPseudoModel_NumPages, + -1, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x24d85167, L"timeout", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Timeout, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x7d9fd7c5, L"mode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Mode, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x7d9fd7c5, L"mode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_SubmitFormat_Mode, -1, + XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2038c9b2, L"role", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Role, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xfcef86b5, L"ready", (XFA_ATTRIBUTE_CALLBACK)&CScript_LayoutPseudoModel:: + Script_LayoutPseudoModel_Ready, + -1, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x5392ea58, L"stroke", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Stroke, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x7b95e661, L"inverted", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Inverted, XFA_SCRIPT_Basic}, + {0x94446dcc, L"thickness", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Thickness, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe8dddf50, L"join", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Join, XFA_SCRIPT_Basic}, + {0xe948b9a8, L"radius", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Radius, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xabfa6c4f, L"cSpace", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CSpace, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, + {0x3848b3f, L"next", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Next, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x6a3405dd, L"previous", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Previous, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xf6b59543, L"intact", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Intact, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x268b7ec1, L"commandType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CommandType, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbde9abda, L"data", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Data, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x5b707a35, L"scriptTest", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ScriptTest, XFA_SCRIPT_Basic}, + {0x6b6ddcfb, L"nullTest", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_NullTest, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xe64b1129, L"formatTest", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_FormatTest, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8c99377e, L"relation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relation, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x25363, L"to", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_To, XFA_SCRIPT_Basic}, + {0x66642f8f, L"force", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Force, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xcd7f7b54, L"from", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, + {0x2b5df51e, L"dataDescription", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x226ca8f1, L"operation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Operation, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xfb67185, L"recordsBefore", (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: + Script_DataWindow_RecordsBefore, + -1, XFA_SCRIPT_Basic}, + {0x21d5dfcb, L"currentRecordNumber", + (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: + Script_DataWindow_CurrentRecordNumber, + -1, XFA_SCRIPT_Basic}, + {0x312af044, L"recordsAfter", (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: + Script_DataWindow_RecordsAfter, + -1, XFA_SCRIPT_Basic}, + {0x6aab37cb, L"isDefined", + (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow::Script_DataWindow_IsDefined, + -1, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x42fed1fd, L"contentType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, + {0x6cfa828a, L"runAt", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_RunAt, XFA_SCRIPT_Basic}, + {0xa021b738, L"stateless", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Script_Stateless, -1, + XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xadc4c77b, L"binding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Binding, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x7a0cc471, L"passwordChar", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_PasswordChar, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe6f99487, L"hScrollPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe6f99487, L"hScrollPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x14a32d52, L"pagePosition", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_PagePosition, XFA_SCRIPT_Basic}, + {0x8340ea66, L"oddOrEven", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OddOrEven, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xa85e74f3, L"initialNumber", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_InitialNumber, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe9ba472, L"numbered", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Numbered, XFA_SCRIPT_Basic}, + {0xd70798c2, L"blankOrNotBlank", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BlankOrNotBlank, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x34ae103c, L"reserve", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Reserve, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xf2009339, L"placement", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Placement, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x42fed1fd, L"contentType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, + {0x54fa722c, L"transferEncoding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc4547a08, L"maxLength", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxLength, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xdb55fec5, L"href", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Href, XFA_SCRIPT_Basic}, + {0x29418bb7, L"abbr", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Abbr, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf531b059, L"writingScript", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_WritingScript, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1b8dce3e, L"action", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Action, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x9dcc3ab3, L"trailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xcbcaf66d, L"leader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xb3543a6, L"max", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Max, -1, + XFA_SCRIPT_Basic}, + {0xb356ca4, L"min", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Min, -1, + XFA_SCRIPT_Basic}, + {0x6f544d49, L"count", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Count, -1, + XFA_SCRIPT_Basic}, + {0x25363, L"to", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_To, XFA_SCRIPT_Basic}, + {0xa0933954, L"unicodeRange", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_UnicodeRange, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xcd7f7b54, L"from", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x4ef3d02c, L"orientation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Orientation, XFA_SCRIPT_Basic}, + {0x65e30c67, L"imagingBBox", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ImagingBBox, XFA_SCRIPT_Basic}, + {0x9041d4b0, L"short", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Short, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe349d044, L"stock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Stock, XFA_SCRIPT_Basic}, + {0xf6b4afb0, L"long", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Long, XFA_SCRIPT_Basic}, + {0x5ce6195, L"vScrollPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VScrollPolicy, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x1ef3a64a, L"allowRichText", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AllowRichText, XFA_SCRIPT_Basic}, + {0x5a32e493, L"multiLine", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MultiLine, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe6f99487, L"hScrollPolicy", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xd52482e0, L"maxEntries", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxEntries, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x42fed1fd, L"contentType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, + {0x8855805f, L"contains", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Contains, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xe372ae97, L"isNull", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_IsNull, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x2b5df51e, L"dataDescription", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x226ca8f1, L"operation", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Operation, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x42fed1fd, L"contentType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, + {0x54fa722c, L"transferEncoding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xf197844d, L"match", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Match, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd996fa9b, L"hand", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x28dee6e9, L"format", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Encrypt_Format, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, + {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, + {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, + {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, + {0x2282c73, L"hAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2ee7678f, L"rotate", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Rotate, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0x7a7cc341, L"vAlign", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, + {0x7c2ff6ae, L"maxH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, + {0x7c2ff6bd, L"maxW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, + {0x7d02356c, L"minH", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, + {0x7d02357b, L"minW", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xa03cf627, L"rawValue", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xac06e2b0, L"colSpan", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbc8fa350, L"locale", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Locale, XFA_SCRIPT_Basic}, + {0xc2bd40fd, L"anchorType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x39cdb0a2, L"priority", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Priority, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xeb511b54, L"disable", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Disable, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xcb0ac9, L"lineThrough", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LineThrough, XFA_SCRIPT_Basic}, + {0x2c1c7f1, L"typeface", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Typeface, XFA_SCRIPT_Basic}, + {0x8c74ae9, L"fontHorizontalScale", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_FontHorizontalScale, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2cd79033, L"kerningMode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_KerningMode, XFA_SCRIPT_Basic}, + {0x3a0273a6, L"underline", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Underline, XFA_SCRIPT_Basic}, + {0x4873c601, L"baselineShift", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_BaselineShift, XFA_SCRIPT_Basic}, + {0x4b319767, L"overlinePeriod", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_OverlinePeriod, XFA_SCRIPT_Basic}, + {0x79543055, L"letterSpacing", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LetterSpacing, XFA_SCRIPT_Basic}, + {0x8ec6204c, L"lineThroughPeriod", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LineThroughPeriod, XFA_SCRIPT_Basic}, + {0x907c7719, L"fontVerticalScale", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_FontVerticalScale, XFA_SCRIPT_Basic}, + {0xa686975b, L"size", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Size, XFA_SCRIPT_Basic}, + {0xb5e49bf2, L"posture", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Posture, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbd6e1d88, L"weight", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Weight, XFA_SCRIPT_Basic}, + {0xbd96a0e9, L"underlinePeriod", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_UnderlinePeriod, XFA_SCRIPT_Basic}, + {0xc0ec9fa4, L"overline", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Overline, XFA_SCRIPT_Basic}, + {0xaf754613, L"checksum", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Form_Checksum, -1, + XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x8e1c2921, L"relevant", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xea7090a0, L"override", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Override, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x9dcc3ab3, L"trailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xcbcaf66d, L"leader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x60a61edd, L"codeType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CodeType, XFA_SCRIPT_Basic}, + {0xb373a862, L"archive", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Archive, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xe1a26b56, L"codeBase", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_CodeBase, XFA_SCRIPT_Basic}, + {0xeb091003, L"classId", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ClassId, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x47d03490, L"connection", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, + {0xc39a88bd, L"labelRef", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_LabelRef, XFA_SCRIPT_Basic}, + {0xd50f903a, L"valueRef", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_ValueRef, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xea7090a0, L"override", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Override, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Extras_Type, -1, + XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x24d85167, L"timeout", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Timeout, XFA_SCRIPT_Basic}, + {0x47d03490, L"connection", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, + {0x552d9ad5, L"usage", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usage, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc860f30a, L"delayedOpen", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_DelayedOpen, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x28dee6e9, L"format", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Format, XFA_SCRIPT_Basic}, + {0x824f21b7, L"embedPDF", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_EmbedPDF, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xdc75676c, L"textEncoding", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TextEncoding, XFA_SCRIPT_Basic}, + {0xf889e747, L"xdpContent", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_XdpContent, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x97be91b, L"content", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Packet_Content, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x4156ee3f, L"delimiter", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Delimiter, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x2f16a382, L"type", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x453eaf38, L"startNew", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, + {0x9dcc3ab3, L"trailer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, + {0xa6118c89, L"targetType", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_TargetType, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xc8da4da7, L"target", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, + {0xcbcaf66d, L"leader", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xabef37e3, L"slope", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Slope, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xd996fa9b, L"hand", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, + {0xa60dd202, L"length", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_NodeList::Script_ListClass_Length, -1, + XFA_SCRIPT_Basic}, + {0x20146, L"db", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Source_Db, -1, + XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xb3543a6, L"max", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Occur_Max, + -1, XFA_SCRIPT_Basic}, + {0xb356ca4, L"min", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Occur_Min, + -1, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x7d0b5fca, L"initial", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Initial, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x29418bb7, L"abbr", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Abbr, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0xbe52dfbf, L"desc", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, + {0xf6b47749, L"lock", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, + XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, + {0xbb8df5d, L"ref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, + {0xc0811ed, L"use", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, + {0x570ce835, L"presence", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, + {0xa5b410cf, L"save", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Save, XFA_SCRIPT_Basic}, + {0xbc254332, L"usehref", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, + {0xb2c80857, L"className", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Object::Script_ObjectClass_ClassName, -1, + XFA_SCRIPT_Basic}, + {0xa60dd202, L"length", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_NodeList::Script_ListClass_Length, -1, + XFA_SCRIPT_Basic}, + {0x31b19c1, L"name", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, + {0x9f9d0f9, L"all", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_All, -1, + XFA_SCRIPT_Object}, + {0x4df15659, L"nodes", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Nodes, -1, + XFA_SCRIPT_Object}, + {0x78a8d6cf, L"classAll", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_ClassAll, -1, + XFA_SCRIPT_Object}, + {0xcad6d8ca, L"parent", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Parent, -1, + XFA_SCRIPT_Object}, + {0xd5679c78, L"index", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Index, -1, + XFA_SCRIPT_Basic}, + {0xdb5b4bce, L"classIndex", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_ClassIndex, -1, + XFA_SCRIPT_Basic}, + {0xe4989adf, L"somExpression", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_SomExpression, -1, + XFA_SCRIPT_Basic}, + {0x21aed, L"id", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, + XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, + {0x234a1, L"ns", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_Ns, + -1, XFA_SCRIPT_Basic}, + {0x50d1a9d1, L"model", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_Model, -1, + XFA_SCRIPT_Object}, + {0xacb4823f, L"isContainer", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_IsContainer, -1, + XFA_SCRIPT_Basic}, + {0xe372ae97, L"isNull", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_IsNull, -1, + XFA_SCRIPT_Basic}, + {0xfe612a5b, L"oneOfChild", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_OneOfChild, -1, + XFA_SCRIPT_Object}, + {0x97c1c65, L"context", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ModelClass_Context, -1, + XFA_SCRIPT_Object}, + {0x58be2870, L"aliasNode", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ModelClass_AliasNode, -1, + XFA_SCRIPT_Object}, + {0xa52682bd, L"{default}", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, + {0xd6e27f1d, L"value", + (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, + XFA_SCRIPT_Basic}, +}; +const int32_t g_iSomAttributeCount = + sizeof(g_SomAttributeData) / sizeof(XFA_ATTRIBUTEINFO); diff --git a/xfa/fxfa/parser/xfa_basic_data.h b/xfa/fxfa/parser/xfa_basic_data.h new file mode 100644 index 0000000000..8d36650a87 --- /dev/null +++ b/xfa/fxfa/parser/xfa_basic_data.h @@ -0,0 +1,48 @@ +// 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_XFA_BASIC_DATA_H_ +#define XFA_FXFA_PARSER_XFA_BASIC_DATA_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; + +extern const XFA_ATTRIBUTEENUMINFO g_XFAEnumData[]; +extern const int32_t g_iXFAEnumCount; + +extern const XFA_ATTRIBUTEINFO g_XFAAttributeData[]; +extern const int32_t g_iXFAAttributeCount; + +extern const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[]; +extern const int32_t g_iXFANotsureCount; + +extern const XFA_ELEMENTINFO g_XFAElementData[]; +extern const int32_t g_iXFAElementCount; + +extern const XFA_ELEMENTHIERARCHY g_XFAElementChildrenIndex[]; +extern const FX_WORD g_XFAElementChildrenData[]; + +extern const XFA_ELEMENTHIERARCHY g_XFAElementAttributeIndex[]; +extern const uint8_t g_XFAElementAttributeData[]; + +extern const XFA_ELEMENTHIERARCHY g_XFAElementPropertyIndex[]; +extern const XFA_PROPERTY g_XFAElementPropertyData[]; + +extern const XFA_SCRIPTHIERARCHY g_XFAScriptIndex[]; + +extern const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[]; +extern const int32_t g_iXFANotsureCount; + +extern const XFA_METHODINFO g_SomMethodData[]; +extern const int32_t g_iSomMethodCount; + +extern const XFA_SCRIPTATTRIBUTEINFO g_SomAttributeData[]; +extern const int32_t g_iSomAttributeCount; + +#endif // XFA_FXFA_PARSER_XFA_BASIC_DATA_H_ diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp new file mode 100644 index 0000000000..a6d4fc069a --- /dev/null +++ b/xfa/fxfa/parser/xfa_basic_imp.cpp @@ -0,0 +1,612 @@ +// 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/fxfa/parser/xfa_basic_imp.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_algorithm.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#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" +#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" + +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.GetPtr(), iLength); + int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} + +const XFA_PACKETINFO* XFA_GetPacketByID(FX_DWORD dwPacket) { + int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + FX_DWORD dwFind = (g_XFAPacketData + iMid)->eName; + if (dwPacket == dwFind) { + return g_XFAPacketData + iMid; + } else if (dwPacket < dwFind) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} + +const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { + return g_XFAPacketData + 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.GetPtr(), iLength); + int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} +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.GetPtr(), iLength); + int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} +const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) { + return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL; +} +FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue, + XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + XFA_ATTRIBUTETYPE eType, + FX_DWORD dwPacket) { + const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); + if (pInfo == NULL) { + return FALSE; + } + if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) { + return FALSE; + } + if (pInfo->eType == eType) { + pValue = pInfo->pDefValue; + return TRUE; + } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) { + const XFA_NOTSUREATTRIBUTE* pAttr = + XFA_GetNotsureAttribute(eElement, eAttribute, eType); + if (pAttr) { + pValue = pAttr->pValue; + return TRUE; + } + } + return FALSE; +} +XFA_ATTRIBUTEENUM XFA_GetAttributeDefaultValue_Enum(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + FX_DWORD dwPacket) { + void* pValue; + if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, + XFA_ATTRIBUTETYPE_Enum, dwPacket)) { + return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; + } + return XFA_ATTRIBUTEENUM_Unknown; +} +CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + FX_DWORD dwPacket) { + void* pValue; + if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, + XFA_ATTRIBUTETYPE_Cdata, dwPacket)) { + return (const FX_WCHAR*)pValue; + } + return NULL; +} +FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + FX_DWORD dwPacket) { + void* pValue; + if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, + XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { + return (FX_BOOL)(uintptr_t)pValue; + } + return FALSE; +} +int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + FX_DWORD 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, + FX_DWORD dwPacket) { + void* pValue; + if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, + XFA_ATTRIBUTETYPE_Measure, dwPacket)) { + return *(CXFA_Measurement*)pValue; + } + 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.GetPtr(), iLength); + int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} +const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName) { + return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : NULL; +} +const FX_WORD* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount) { + if (eElement >= g_iXFAElementCount) { + return NULL; + } + const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement; + iCount = pElement->wCount; + return g_XFAElementChildrenData + pElement->wStart; +} +const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { + if (eElement >= g_iXFAElementCount) { + return NULL; + } + const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; + iCount = pElement->wCount; + return g_XFAElementAttributeData + pElement->wStart; +} +const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + FX_DWORD dwPacket) { + int32_t iCount = 0; + const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); + if (pAttr == NULL || iCount < 1) { + return NULL; + } + CFX_DSPATemplate<uint8_t> search; + int32_t index = search.Lookup(eAttribute, pAttr, iCount); + if (index < 0) { + return NULL; + } + const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); + ASSERT(pInfo); + if (dwPacket == XFA_XDPPACKET_UNKNOWN) + return pInfo; + return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; +} +const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, + XFA_ELEMENT eChild, + FX_DWORD dwPacket) { + int32_t iCount = 0; + const FX_WORD* pChild = XFA_GetElementChildren(eElement, iCount); + if (pChild == NULL || iCount < 1) { + return NULL; + } + CFX_DSPATemplate<FX_WORD> 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) { + return NULL; + } + const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; + iCount = pElement->wCount; + return g_XFAElementPropertyData + pElement->wStart; +} +const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, + XFA_ELEMENT eProperty, + FX_DWORD dwPacket) { + int32_t iCount = 0; + const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount); + if (pProperty == NULL || iCount < 1) { + return NULL; + } + int32_t iStart = 0, iEnd = iCount - 1, iMid; + do { + iMid = (iStart + iEnd) / 2; + XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; + if (eProperty == eName) { + break; + } else if (eProperty < eName) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + if (iStart > iEnd) { + return NULL; + } + const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eProperty); + ASSERT(pInfo); + if (dwPacket == XFA_XDPPACKET_UNKNOWN) + return pProperty + iMid; + return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : NULL; +} +const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + XFA_ATTRIBUTETYPE eType) { + int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_NOTSUREATTRIBUTE* pAttr = g_XFANotsureAttributes + iMid; + if (eElement == pAttr->eElement) { + if (pAttr->eAttribute == eAttribute) { + if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { + return pAttr; + } + return NULL; + } else { + int32_t iBefore = iMid - 1; + if (iBefore >= 0) { + pAttr = g_XFANotsureAttributes + iBefore; + while (eElement == pAttr->eElement) { + if (pAttr->eAttribute == eAttribute) { + if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { + return pAttr; + } + return NULL; + } + iBefore--; + if (iBefore < 0) { + break; + } + pAttr = g_XFANotsureAttributes + iBefore; + } + } + int32_t iAfter = iMid + 1; + if (iAfter <= g_iXFANotsureCount - 1) { + pAttr = g_XFANotsureAttributes + iAfter; + while (eElement == pAttr->eElement) { + if (pAttr->eAttribute == eAttribute) { + if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { + return pAttr; + } + return NULL; + } + iAfter++; + if (iAfter > g_iXFANotsureCount - 1) { + break; + } + pAttr = g_XFANotsureAttributes + iAfter; + } + } + return NULL; + } + } else if (eElement < pAttr->eElement) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } 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; + } + int32_t iElementIndex = eElement; + while (iElementIndex != -1) { + XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; + int32_t icount = scriptIndex->wMethodCount; + if (icount == 0) { + iElementIndex = scriptIndex->wParentIndex; + continue; + } + uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.GetPtr(), iLength); + int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + iElementIndex = scriptIndex->wParentIndex; + } + return NULL; +} +const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( + XFA_ELEMENT eElement, + const CFX_WideStringC& wsAttributeName) { + int32_t iLength = wsAttributeName.GetLength(); + if (iLength == 0) { + return NULL; + } + int32_t iElementIndex = eElement; + while (iElementIndex != -1) { + XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; + int32_t icount = scriptIndex->wAttributeCount; + if (icount == 0) { + iElementIndex = scriptIndex->wParentIndex; + continue; + } + uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.GetPtr(), iLength); + int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid; + if (uHash == pInfo->uHash) { + return pInfo; + } else if (uHash < pInfo->uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + iElementIndex = scriptIndex->wParentIndex; + } + return NULL; +} +void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) { + if (wsMeasure.IsEmpty()) { + m_fValue = 0; + m_eUnit = XFA_UNIT_Unknown; + return; + } + int32_t iUsedLen = 0; + int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; + FX_FLOAT fValue = FX_wcstof(wsMeasure.GetPtr() + iOffset, + wsMeasure.GetLength() - iOffset, &iUsedLen); + XFA_UNIT eUnit = GetUnit(wsMeasure.Mid(iOffset + iUsedLen)); + Set(fValue, eUnit); +} +FX_BOOL CXFA_Measurement::ToString(CFX_WideString& wsMeasure) const { + switch (GetUnit()) { + case XFA_UNIT_Mm: + wsMeasure.Format(L"%.8gmm", GetValue()); + return TRUE; + case XFA_UNIT_Pt: + wsMeasure.Format(L"%.8gpt", GetValue()); + return TRUE; + case XFA_UNIT_In: + wsMeasure.Format(L"%.8gin", GetValue()); + return TRUE; + case XFA_UNIT_Cm: + wsMeasure.Format(L"%.8gcm", GetValue()); + return TRUE; + case XFA_UNIT_Mp: + wsMeasure.Format(L"%.8gmp", GetValue()); + return TRUE; + case XFA_UNIT_Pc: + wsMeasure.Format(L"%.8gpc", GetValue()); + return TRUE; + case XFA_UNIT_Em: + wsMeasure.Format(L"%.8gem", GetValue()); + return TRUE; + case XFA_UNIT_Percent: + wsMeasure.Format(L"%.8g%%", GetValue()); + return TRUE; + default: + wsMeasure.Format(L"%.8g", GetValue()); + return FALSE; + } +} +FX_BOOL CXFA_Measurement::ToUnit(XFA_UNIT eUnit, FX_FLOAT& fValue) const { + fValue = GetValue(); + XFA_UNIT eFrom = GetUnit(); + if (eFrom == eUnit) { + return TRUE; + } + switch (eFrom) { + case XFA_UNIT_Pt: + break; + case XFA_UNIT_Mm: + fValue *= 72 / 2.54f / 10; + break; + case XFA_UNIT_In: + fValue *= 72; + break; + case XFA_UNIT_Cm: + fValue *= 72 / 2.54f; + break; + case XFA_UNIT_Mp: + fValue *= 0.001f; + break; + case XFA_UNIT_Pc: + fValue *= 12.0f; + break; + default: + fValue = 0; + return FALSE; + } + switch (eUnit) { + case XFA_UNIT_Pt: + return TRUE; + case XFA_UNIT_Mm: + fValue /= 72 / 2.54f / 10; + return TRUE; + case XFA_UNIT_In: + fValue /= 72; + return TRUE; + case XFA_UNIT_Cm: + fValue /= 72 / 2.54f; + return TRUE; + case XFA_UNIT_Mp: + fValue /= 0.001f; + return TRUE; + case XFA_UNIT_Pc: + fValue /= 12.0f; + return TRUE; + default: + fValue = 0; + return FALSE; + } + return FALSE; +} +XFA_UNIT CXFA_Measurement::GetUnit(const CFX_WideStringC& wsUnit) { + if (wsUnit == FX_WSTRC(L"mm")) { + return XFA_UNIT_Mm; + } else if (wsUnit == FX_WSTRC(L"pt")) { + return XFA_UNIT_Pt; + } else if (wsUnit == FX_WSTRC(L"in")) { + return XFA_UNIT_In; + } else if (wsUnit == FX_WSTRC(L"cm")) { + return XFA_UNIT_Cm; + } else if (wsUnit == FX_WSTRC(L"pc")) { + return XFA_UNIT_Pc; + } else if (wsUnit == FX_WSTRC(L"mp")) { + return XFA_UNIT_Mp; + } else if (wsUnit == FX_WSTRC(L"em")) { + return XFA_UNIT_Em; + } else if (wsUnit == FX_WSTRC(L"%")) { + return XFA_UNIT_Percent; + } else { + return XFA_UNIT_Unknown; + } +} +IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer) { + return new CXFA_WideTextRead(wsBuffer); +} +CXFA_WideTextRead::CXFA_WideTextRead(const CFX_WideString& wsBuffer) + : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {} +void CXFA_WideTextRead::Release() { + if (--m_iRefCount < 1) { + delete this; + } +} +IFX_Stream* CXFA_WideTextRead::Retain() { + m_iRefCount++; + return this; +} +FX_DWORD CXFA_WideTextRead::GetAccessModes() const { + return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text; +} +int32_t CXFA_WideTextRead::GetLength() const { + return m_wsBuffer.GetLength() * sizeof(FX_WCHAR); +} +int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { + switch (eSeek) { + case FX_STREAMSEEK_Begin: + m_iPosition = iOffset; + break; + case FX_STREAMSEEK_Current: + m_iPosition += iOffset; + break; + case FX_STREAMSEEK_End: + m_iPosition = m_wsBuffer.GetLength() + iOffset; + break; + } + if (m_iPosition < 0) { + m_iPosition = 0; + } + if (m_iPosition > m_wsBuffer.GetLength()) { + m_iPosition = m_wsBuffer.GetLength(); + } + return GetPosition(); +} +int32_t CXFA_WideTextRead::GetPosition() { + return m_iPosition * sizeof(FX_WCHAR); +} +FX_BOOL CXFA_WideTextRead::IsEOF() const { + return m_iPosition >= m_wsBuffer.GetLength(); +} +int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize) { + if (iMaxLength > m_wsBuffer.GetLength() - m_iPosition) { + iMaxLength = m_wsBuffer.GetLength() - m_iPosition; + } + FXSYS_wcsncpy(pStr, (const FX_WCHAR*)m_wsBuffer + m_iPosition, iMaxLength); + m_iPosition += iMaxLength; + bEOS = IsEOF(); + return iMaxLength; +} +FX_WORD CXFA_WideTextRead::GetCodePage() const { + return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; +} +FX_WORD CXFA_WideTextRead::SetCodePage(FX_WORD wCodePage) { + return GetCodePage(); +} diff --git a/xfa/fxfa/parser/xfa_basic_imp.h b/xfa/fxfa/parser/xfa_basic_imp.h new file mode 100644 index 0000000000..7e67d2b96e --- /dev/null +++ b/xfa/fxfa/parser/xfa_basic_imp.h @@ -0,0 +1,71 @@ +// 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_BASIC_IMP_H_ +#define XFA_FXFA_PARSER_XFA_BASIC_IMP_H_ + +#include "xfa/fgas/crt/fgas_stream.h" +#include "xfa/include/fxfa/fxfa_basic.h" + +struct XFA_NOTSUREATTRIBUTE { + XFA_ELEMENT eElement; + XFA_ATTRIBUTE eAttribute; + XFA_ATTRIBUTETYPE eType; + void* pValue; +}; +const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute( + XFA_ELEMENT eElement, + XFA_ATTRIBUTE eAttribute, + XFA_ATTRIBUTETYPE eType = XFA_ATTRIBUTETYPE_NOTSURE); + +class CXFA_WideTextRead : public IFX_Stream { + public: + CXFA_WideTextRead(const CFX_WideString& wsBuffer); + virtual void Release(); + virtual IFX_Stream* Retain(); + + virtual FX_DWORD GetAccessModes() const; + virtual int32_t GetLength() const; + virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); + virtual int32_t GetPosition(); + virtual FX_BOOL IsEOF() const; + + virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } + virtual int32_t ReadString(FX_WCHAR* pStr, + int32_t iMaxLength, + FX_BOOL& bEOS, + int32_t const* pByteSize = NULL); + virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { + return 0; + } + virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { + return 0; + } + virtual void Flush() {} + virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } + + virtual int32_t GetBOM(uint8_t bom[4]) const { return 0; } + virtual FX_WORD GetCodePage() const; + virtual FX_WORD SetCodePage(FX_WORD wCodePage); + + virtual void Lock() {} + virtual void Unlock() {} + + virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, + int32_t iOffset, + int32_t iLength) { + return NULL; + } + + CFX_WideString GetSrcText() const { return m_wsBuffer; } + + protected: + CFX_WideString m_wsBuffer; + int32_t m_iPosition; + int32_t m_iRefCount; +}; + +#endif // XFA_FXFA_PARSER_XFA_BASIC_IMP_H_ diff --git a/xfa/fxfa/parser/xfa_docdata.h b/xfa/fxfa/parser/xfa_docdata.h new file mode 100644 index 0000000000..b3c3edd0cc --- /dev/null +++ b/xfa/fxfa/parser/xfa_docdata.h @@ -0,0 +1,36 @@ +// 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, +}; + +class IXFA_PacketExport { + public: + static IXFA_PacketExport* Create(CXFA_Document* pDocument, + XFA_DATAFORMAT eFormat = XFA_DATAFORMAT_XDP); + virtual ~IXFA_PacketExport() {} + virtual void Release() = 0; + virtual FX_BOOL Export(IFX_FileWrite* pWrite) = 0; + virtual FX_BOOL Export(IFX_FileWrite* pWrite, + CXFA_Node* pNode, + FX_DWORD dwFlag = 0, + const FX_CHAR* pChecksum = NULL) = 0; +}; +class IXFA_PacketImport { + public: + static IXFA_PacketImport* Create(CXFA_Document* pDstDoc); + virtual ~IXFA_PacketImport() {} + virtual void Release() = 0; + virtual FX_BOOL ImportData(IFX_FileRead* pDataDocument) = 0; +}; + +#endif // XFA_FXFA_PARSER_XFA_DOCDATA_H_ diff --git a/xfa/fxfa/parser/xfa_doclayout.h b/xfa/fxfa/parser/xfa_doclayout.h new file mode 100644 index 0000000000..bb44868a98 --- /dev/null +++ b/xfa/fxfa/parser/xfa_doclayout.h @@ -0,0 +1,136 @@ +// 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_DOCLAYOUT_H_ +#define XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_ + +#include "xfa/fxfa/parser/xfa_document.h" + +class CXFA_ContainerLayoutItem; +class CXFA_ContentLayoutItem; +class IXFA_DocLayout; + +class IXFA_LayoutPage { + public: + virtual ~IXFA_LayoutPage() {} + virtual IXFA_DocLayout* GetLayout() const = 0; + virtual int32_t GetPageIndex() const = 0; + virtual void GetPageSize(CFX_SizeF& size) = 0; + virtual CXFA_Node* GetMasterPage() const = 0; +}; + +class CXFA_LayoutItem { + public: + virtual ~CXFA_LayoutItem(); + + FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; } + FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; } + inline CXFA_ContainerLayoutItem* AsContainerLayoutItem(); + inline CXFA_ContentLayoutItem* AsContentLayoutItem(); + + IXFA_LayoutPage* GetPage() const; + CXFA_Node* GetFormNode() const; + void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const; + int32_t GetIndex() const; + int32_t GetCount() const; + CXFA_LayoutItem* GetParent() const; + const CXFA_LayoutItem* GetFirst() const; + CXFA_LayoutItem* GetFirst(); + const CXFA_LayoutItem* GetLast() const; + CXFA_LayoutItem* GetLast(); + CXFA_LayoutItem* GetPrev() const; + CXFA_LayoutItem* GetNext() const; + + void AddChild(CXFA_LayoutItem* pChildItem); + void AddHeadChild(CXFA_LayoutItem* pChildItem); + void RemoveChild(CXFA_LayoutItem* pChildItem); + void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem); + + CXFA_Node* m_pFormNode; + CXFA_LayoutItem* m_pParent; + CXFA_LayoutItem* m_pNextSibling; + CXFA_LayoutItem* m_pFirstChild; + + protected: + CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem); + + FX_BOOL m_bIsContentLayoutItem; +}; + +class CXFA_ContainerLayoutItem : public CXFA_LayoutItem, + public IXFA_LayoutPage { + public: + CXFA_ContainerLayoutItem(CXFA_Node* pNode); + + // IXFA_LayoutPage: + IXFA_DocLayout* GetLayout() const override; + int32_t GetPageIndex() const override; + void GetPageSize(CFX_SizeF& size) override; + CXFA_Node* GetMasterPage() const override; + + 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); + virtual ~CXFA_ContentLayoutItem(); + + CXFA_ContentLayoutItem* m_pPrev; + CXFA_ContentLayoutItem* m_pNext; + CFX_PointF m_sPos; + CFX_SizeF m_sSize; + FX_DWORD m_dwStatus; +}; + +CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() { + return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this) + : nullptr; +} +CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() { + return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this) + : nullptr; +} +inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) { + return pItem ? pItem->AsContainerLayoutItem() : nullptr; +} +inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) { + return pItem ? pItem->AsContentLayoutItem() : nullptr; +} + +class CXFA_TraverseStrategy_LayoutItem { + public: + static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) { + return pLayoutItem->m_pFirstChild; + } + static inline CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) { + return pLayoutItem->m_pNextSibling; + } + static inline CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) { + return pLayoutItem->m_pParent; + } +}; + +class IXFA_DocLayout { + public: + virtual ~IXFA_DocLayout() {} + virtual CXFA_Document* GetDocument() const = 0; + virtual int32_t StartLayout(FX_BOOL bForceRestart = FALSE) = 0; + virtual int32_t DoLayout(IFX_Pause* pPause = NULL) = 0; + virtual FX_BOOL IncrementLayout() = 0; + virtual int32_t CountPages() const = 0; + virtual IXFA_LayoutPage* GetPage(int32_t index) const = 0; + virtual CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem) = 0; +}; + +#endif // XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_ diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/xfa_document.h new file mode 100644 index 0000000000..affe4001ba --- /dev/null +++ b/xfa/fxfa/parser/xfa_document.h @@ -0,0 +1,201 @@ +// 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_DOCUMENT_H_ +#define XFA_FXFA_PARSER_XFA_DOCUMENT_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; +class CXFA_LayoutProcessor; +class CXFA_Node; +class IXFA_DocLayout; +class IXFA_DocParser; +class IXFA_LayoutPage; +class IXFA_Notify; +class IXFA_ObjFactory; +class IXFA_ScriptContext; + +enum XFA_VERSION { + XFA_VERSION_UNKNOWN = 0, + XFA_VERSION_200 = 200, + XFA_VERSION_202 = 202, + XFA_VERSION_204 = 204, + XFA_VERSION_205 = 205, + XFA_VERSION_206 = 206, + XFA_VERSION_207 = 207, + XFA_VERSION_208 = 208, + XFA_VERSION_300 = 300, + XFA_VERSION_301 = 301, + XFA_VERSION_303 = 303, + XFA_VERSION_306 = 306, + XFA_VERSION_DEFAULT = XFA_VERSION_303, + XFA_VERSION_MIN = 200, + 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, + XFA_LAYOUTRESULT_NextContent, +}; +#define XFA_LAYOUTNOTIFY_StrictHeight 0x0001 +#define XFA_LAYOUTNOTIFY_NoParentBreak 0x0002 + +class IXFA_Notify { + public: + virtual ~IXFA_Notify() {} + virtual void OnPageEvent(IXFA_LayoutPage* pSender, + XFA_PAGEEVENT eEvent, + void* pParam = NULL) = 0; + + virtual void OnNodeEvent(CXFA_Node* pSender, + XFA_NODEEVENT eEvent, + void* pParam = NULL, + void* pParam2 = NULL, + void* pParam3 = NULL, + void* pParam4 = NULL) = 0; + virtual void OnWidgetDataEvent(CXFA_WidgetData* pSender, + FX_DWORD dwEvent, + void* pParam = NULL, + void* pAdditional = NULL, + void* pAdditional2 = NULL) = 0; + + virtual CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode) = 0; + virtual void OnLayoutEvent(IXFA_DocLayout* pLayout, + CXFA_LayoutItem* pSender, + XFA_LAYOUTEVENT eEvent, + void* pParam = NULL, + void* pParam2 = NULL) = 0; + virtual void StartFieldDrawLayout(CXFA_Node* pItem, + FX_FLOAT& fCalcWidth, + FX_FLOAT& fCalcHeight) = 0; + virtual FX_BOOL FindSplitPos(CXFA_Node* pItem, + int32_t iBlockIndex, + FX_FLOAT& fCalcHeightPos) = 0; + virtual FX_BOOL RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) = 0; + virtual int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + FX_BOOL bIsFormReady = FALSE, + FX_BOOL bRecursive = TRUE, + CXFA_WidgetAcc* pExclude = NULL) = 0; + virtual void AddCalcValidate(CXFA_Node* pNode) = 0; + virtual IXFA_Doc* GetHDOC() = 0; + virtual IXFA_DocProvider* GetDocProvider() = 0; + virtual IXFA_AppProvider* GetAppProvider() = 0; + virtual IXFA_WidgetHandler* GetWidgetHandler() = 0; + virtual IXFA_Widget* GetHWidget(CXFA_LayoutItem* pLayoutItem) = 0; + virtual void OpenDropDownList(IXFA_Widget* hWidget) = 0; + virtual CFX_WideString GetCurrentDateTime() = 0; + virtual void ResetData(CXFA_WidgetData* pWidgetData = NULL) = 0; + virtual int32_t GetLayoutStatus() = 0; + virtual void RunNodeInitialize(CXFA_Node* pNode) = 0; + virtual void RunSubformIndexChange(CXFA_Node* pSubformNode) = 0; + virtual CXFA_Node* GetFocusWidgetNode() = 0; + virtual void SetFocusWidgetNode(CXFA_Node* pNode) = 0; +}; +class IXFA_ObjFactory { + public: + virtual ~IXFA_ObjFactory() {} + virtual CXFA_Node* CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement) = 0; + virtual CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, + XFA_ELEMENT eElement) = 0; +}; +#define XFA_DOCFLAG_StrictScoping 0x0001 +#define XFA_DOCFLAG_HasInteractive 0x0002 +#define XFA_DOCFLAG_Interactive 0x0004 +#define XFA_DOCFLAG_Scripting 0x0008 +class CScript_DataWindow; +class CScript_EventPseudoModel; +class CScript_HostPseudoModel; +class CScript_LogPseudoModel; +class CScript_LayoutPseudoModel; +class CScript_SignaturePseudoModel; +class CXFA_Document : public IXFA_ObjFactory { + public: + CXFA_Document(IXFA_DocParser* pParser); + ~CXFA_Document(); + CXFA_Node* GetRoot() const { return m_pRootNode; } + IXFA_DocParser* GetParser() const { return m_pParser; } + IXFA_Notify* GetNotify() const; + void SetRoot(CXFA_Node* pNewRoot); + CXFA_Object* GetXFAObject(const CFX_WideStringC& wsNodeName); + CXFA_Object* GetXFAObject(FX_DWORD wsNodeNameHash); + void AddPurgeNode(CXFA_Node* pNode); + FX_BOOL RemovePurgeNode(CXFA_Node* pNode); + void PurgeNodes(); + bool HasFlag(FX_DWORD dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } + void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE); + FX_BOOL IsInteractive(); + XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; } + XFA_VERSION RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS); + CXFA_LocaleMgr* GetLocalMgr(); + virtual CXFA_Node* CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement); + virtual CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, + XFA_ELEMENT eElement); + void DoProtoMerge(); + CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID); + void DoDataMerge(); + void DoDataRemerge(FX_BOOL bDoDataMerge); + CXFA_Node* DataMerge_CopyContainer(CXFA_Node* pTemplateNode, + CXFA_Node* pFormNode, + CXFA_Node* pDataScope, + FX_BOOL bOneInstance = FALSE, + FX_BOOL bDataMerge = TRUE, + FX_BOOL bUpLevel = TRUE); + void DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot); + CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes); + CXFA_LayoutProcessor* GetLayoutProcessor(); + IXFA_DocLayout* GetDocLayout(); + IXFA_ScriptContext* InitScriptContext(FXJSE_HRUNTIME hRuntime); + IXFA_ScriptContext* GetScriptContext(); + void ClearLayoutData(); + + CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> m_rgGlobalBinding; + CXFA_NodeArray m_pPendingPageSet; + + protected: + IXFA_DocParser* m_pParser; + IXFA_ScriptContext* m_pScriptContext; + CXFA_LayoutProcessor* m_pLayoutProcessor; + CXFA_Node* m_pRootNode; + CXFA_LocaleMgr* m_pLocalMgr; + CScript_DataWindow* m_pScriptDataWindow; + CScript_EventPseudoModel* m_pScriptEvent; + CScript_HostPseudoModel* m_pScriptHost; + CScript_LogPseudoModel* m_pScriptLog; + CScript_LayoutPseudoModel* m_pScriptLayout; + CScript_SignaturePseudoModel* m_pScriptSignature; + CXFA_NodeSet m_rgPurgeNodes; + XFA_VERSION m_eCurVersionMode; + FX_DWORD m_dwDocFlags; + friend class CXFA_SimpleParser; +}; + +#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_H_ diff --git a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp new file mode 100644 index 0000000000..8cc8d01644 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp @@ -0,0 +1,126 @@ +// 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/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" +#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" + +#define XFA_HASHCODE_Group 0xf7f75fcd + +class CXFA_TraverseStrategy_DDGroup { + public: + static inline CXFA_Node* GetFirstChild(CXFA_Node* pDDGroupNode) { + return pDDGroupNode->GetFirstChildByName(XFA_HASHCODE_Group); + } + static inline CXFA_Node* GetNextSibling(CXFA_Node* pDDGroupNode) { + return pDDGroupNode->GetNextSameNameSibling(XFA_HASHCODE_Group); + } + static inline CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) { + return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent); + } +}; +void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, + CXFA_Node* pDataDescriptionNode) { + FXSYS_assert(pDataDescriptionNode); + for (CXFA_Node* pDataChild = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pDataChild; + pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + FX_DWORD dwNameHash = pDataChild->GetNameHash(); + XFA_ELEMENT eType = pDataChild->GetClassID(); + if (!dwNameHash) { + continue; + } + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> + sIterator(pDataDescriptionNode); + for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; + pDDGroupNode = sIterator.MoveToNext()) { + if (pDDGroupNode != pDataDescriptionNode) { + if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { + continue; + } + CFX_WideString wsNamespace; + if (!pDDGroupNode->TryNamespace(wsNamespace) || + wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { + continue; + } + } + CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash); + if (!pDDNode) { + continue; + } + if (pDDNode->GetClassID() != eType) { + break; + } + pDataChild->SetDataDescriptionNode(pDDNode); + XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode); + break; + } + } +} +CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( + CXFA_Document* pDocument, + CXFA_Node* pDataParent, + XFA_ELEMENT eNodeType, + const CFX_WideStringC& wsName) { + if (!pDataParent) { + return NULL; + } + CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode(); + if (!pParentDDNode) { + CXFA_Node* pDataNode = + pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); + FXSYS_assert(pDataNode); + pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); + pDataNode->CreateXMLMappingNode(); + pDataParent->InsertChild(pDataNode); + pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + return pDataNode; + } else { + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> + sIterator(pParentDDNode); + for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; + pDDGroupNode = sIterator.MoveToNext()) { + if (pDDGroupNode != pParentDDNode) { + if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { + continue; + } + CFX_WideString wsNamespace; + if (!pDDGroupNode->TryNamespace(wsNamespace) || + wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { + continue; + } + } + CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName); + if (!pDDNode) { + continue; + } + if (pDDNode->GetClassID() != eNodeType) { + break; + } + CXFA_Node* pDataNode = + pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); + FXSYS_assert(pDataNode); + pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); + pDataNode->CreateXMLMappingNode(); + if (eNodeType == XFA_ELEMENT_DataValue && + pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) == + XFA_ATTRIBUTEENUM_MetaData) { + pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData); + } + pDataParent->InsertChild(pDataNode); + pDataNode->SetDataDescriptionNode(pDDNode); + pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + return pDataNode; + } + return NULL; + } +} diff --git a/xfa/fxfa/parser/xfa_document_datadescription_imp.h b/xfa/fxfa/parser/xfa_document_datadescription_imp.h new file mode 100644 index 0000000000..f7c626dfb7 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_datadescription_imp.h @@ -0,0 +1,18 @@ +// 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_DOCUMENT_DATADESCRIPTION_IMP_H_ +#define XFA_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_ + +void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, + CXFA_Node* pDataDescriptionNode); +CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( + CXFA_Document* pDocument, + CXFA_Node* pDataParent, + XFA_ELEMENT eNodeType, + const CFX_WideStringC& wsName); + +#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_ diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp new file mode 100644 index 0000000000..0dc087a48f --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -0,0 +1,1429 @@ +// 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/fxfa/parser/xfa_document_datamerger_imp.h" + +#include "core/include/fxcrt/fx_ext.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_datadescription_imp.h" +#include "xfa/fxfa/parser/xfa_document_layout_imp.h" +#include "xfa/fxfa/parser/xfa_localemgr.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_BOOL XFA_GetOccurInfo(CXFA_Node* pOccurNode, + int32_t& iMin, + int32_t& iMax, + int32_t& iInit) { + if (!pOccurNode) { + return FALSE; + } + CXFA_Occur occur(pOccurNode); + return occur.GetOccurInfo(iMin, iMax, iInit); +} +struct XFA_DataMerge_RecurseRecord { + CXFA_Node* pTemplateChild; + CXFA_Node* pDataChild; +}; +static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild( + CXFA_Node* pValueNode, + XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { + CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pChildNode) { + if (iType == XFA_ELEMENT_UNKNOWN) { + return FALSE; + } + pChildNode = pValueNode->GetProperty(0, iType); + } + return pChildNode; +} +static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild( + CXFA_Node* pFormNode) { + CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); + FXSYS_assert(pWidgetData); + pWidgetData->GetUIType(); +} +static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent( + CXFA_Node* pValueNode, + const CFX_WideString& wsContent, + XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { + if (!pValueNode) { + return FALSE; + } + FXSYS_assert(pValueNode->GetPacketID() == XFA_XDPPACKET_Form); + CXFA_Node* pChildNode = + XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType); + if (!pChildNode) { + return FALSE; + } + XFA_OBJECTTYPE objectType = pChildNode->GetObjectType(); + switch (objectType) { + case XFA_OBJECTTYPE_ContentNode: { + CXFA_Node* pContentRawDataNode = + pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pContentRawDataNode) { + XFA_ELEMENT element = XFA_ELEMENT_Sharptext; + if (pChildNode->GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideString wsContentType; + pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, + FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + element = XFA_ELEMENT_SharpxHTML; + } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + element = XFA_ELEMENT_Sharpxml; + } + } + pContentRawDataNode = pChildNode->CreateSamePacketNode(element); + pChildNode->InsertChild(pContentRawDataNode); + } + pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); + } break; + case XFA_OBJECTTYPE_NodeC: + case XFA_OBJECTTYPE_TextNode: + case XFA_OBJECTTYPE_NodeV: { + pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); + } break; + default: + FXSYS_assert(FALSE); + break; + } + return TRUE; +} +static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, + CXFA_Node* pDataNode, + FX_BOOL bDataToForm = TRUE) { + pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); + pDataNode->AddBindItem(pFormNode); + XFA_ELEMENT eClass = pFormNode->GetClassID(); + if (eClass != XFA_ELEMENT_Field && eClass != XFA_ELEMENT_ExclGroup) { + return; + } + CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); + FXSYS_assert(pWidgetData); + FX_BOOL bNotify = FALSE; + XFA_ELEMENT eUIType = pWidgetData->GetUIType(); + CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value)); + if (!bDataToForm) { + CFX_WideString wsValue; + CFX_WideString wsFormatedValue; + switch (eUIType) { + case XFA_ELEMENT_ImageEdit: { + CXFA_Image image = defValue.GetImage(); + CFX_WideString wsContentType; + CFX_WideString wsHref; + if (image) { + image.GetContent(wsValue); + image.GetContentType(wsContentType); + image.GetHref(wsHref); + } + IFDE_XMLElement* pXMLDataElement = + (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); + FXSYS_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); + } + } break; + case XFA_ELEMENT_ChoiceList: + defValue.GetChildValueContent(wsValue); + if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + CFX_WideStringArray wsSelTextArray; + pWidgetData->GetSelectedItemsValue(wsSelTextArray); + int32_t iSize = wsSelTextArray.GetSize(); + if (iSize >= 1) { + 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->CreateXMLMappingNode(); + pDataNode->InsertChild(pValue); + pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); + } + } else { + IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); + ((IFDE_XMLElement*)pXMLNode) + ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); + } + } else if (!wsValue.IsEmpty()) { + pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); + pDataNode->SetAttributeValue(wsValue, wsFormatedValue); + } + break; + case XFA_ELEMENT_CheckButton: + defValue.GetChildValueContent(wsValue); + if (wsValue.IsEmpty()) { + break; + } + pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); + pDataNode->SetAttributeValue(wsValue, wsFormatedValue); + break; + case XFA_ELEMENT_ExclGroup: { + CXFA_Node* pChecked = NULL; + CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pChild->GetClassID() != XFA_ELEMENT_Field) { + continue; + } + CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value); + if (!pValue) { + continue; + } + CXFA_Value valueChild(pValue); + valueChild.GetChildValueContent(wsValue); + if (wsValue.IsEmpty()) { + continue; + } + CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); + if (!pItems) { + continue; + } + CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pText) { + continue; + } + CFX_WideString wsContent; + if (pText->TryContent(wsContent) && (wsContent == wsValue)) { + pChecked = pChild; + wsFormatedValue = wsValue; + pDataNode->SetAttributeValue(wsValue, wsFormatedValue); + pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); + break; + } + } + if (!pChecked) { + break; + } + pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pChild == pChecked) { + continue; + } + if (pChild->GetClassID() != XFA_ELEMENT_Field) { + continue; + } + CXFA_Node* pValue = pChild->GetProperty(0, XFA_ELEMENT_Value); + CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); + CXFA_Node* pText = + pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; + if (pText) { + pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); + } + CFX_WideString wsContent; + if (pText) { + pText->TryContent(wsContent); + } + XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, + XFA_ELEMENT_Text); + } + } break; + case XFA_ELEMENT_NumericEdit: { + defValue.GetChildValueContent(wsValue); + if (wsValue.IsEmpty()) { + break; + } + CFX_WideString wsOutput; + pWidgetData->NormalizeNumStr(wsValue, wsOutput); + wsValue = wsOutput; + pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); + pDataNode->SetAttributeValue(wsValue, wsFormatedValue); + CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value); + XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, + XFA_ELEMENT_Float); + } break; + default: + defValue.GetChildValueContent(wsValue); + if (wsValue.IsEmpty()) { + break; + } + pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); + pDataNode->SetAttributeValue(wsValue, wsFormatedValue); + break; + } + } else { + CFX_WideString wsXMLValue; + pDataNode->TryContent(wsXMLValue); + CFX_WideString wsNormailizeValue; + pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue); + pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); + switch (eUIType) { + case XFA_ELEMENT_ImageEdit: { + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); + CXFA_Image image = defValue.GetImage(); + if (image) { + IFDE_XMLElement* pXMLDataElement = + (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); + FXSYS_assert(pXMLDataElement); + CFX_WideString wsContentType; + CFX_WideString wsHref; + pXMLDataElement->GetString(L"xfa:contentType", wsContentType); + if (!wsContentType.IsEmpty()) { + pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); + image.SetContentType(wsContentType); + } + pXMLDataElement->GetString(L"href", wsHref); + if (!wsHref.IsEmpty()) { + image.SetHref(wsHref); + } + } + } break; + case XFA_ELEMENT_ChoiceList: + if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + CXFA_NodeArray items; + pDataNode->GetNodeList(items); + int32_t iCounts = items.GetSize(); + if (iCounts > 0) { + wsNormailizeValue.Empty(); + CFX_WideString wsItem; + for (int32_t i = 0; i < iCounts; i++) { + items[i]->TryContent(wsItem); + wsItem = (iCounts == 1) ? wsItem : wsItem + FX_WSTRC(L"\n"); + wsNormailizeValue += wsItem; + } + CXFA_ExData exData = defValue.GetExData(); + FXSYS_assert(exData); + exData.SetContentType((iCounts == 1) ? FX_WSTRC(L"text/plain") + : FX_WSTRC(L"text/xml")); + } + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_ExData); + } else { + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); + } + break; + case XFA_ELEMENT_CheckButton: + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); + break; + case XFA_ELEMENT_ExclGroup: { + pWidgetData->SetSelectedMemberByValue(wsNormailizeValue, bNotify, FALSE, + FALSE); + } break; + case XFA_ELEMENT_DateTimeEdit: + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime); + break; + case XFA_ELEMENT_NumericEdit: { + CFX_WideString wsPicture; + pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); + if (wsPicture.IsEmpty()) { + CFX_WideString wsOutput; + pWidgetData->NormalizeNumStr(wsNormailizeValue, wsOutput); + wsNormailizeValue = wsOutput; + } + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Float); + } break; + case XFA_ELEMENT_Barcode: + case XFA_ELEMENT_Button: + case XFA_ELEMENT_PasswordEdit: + case XFA_ELEMENT_Signature: + case XFA_ELEMENT_TextEdit: + default: + XFA_DataMerge_FormValueNode_SetChildContent( + defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); + break; + } + } +} +static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, + FX_DWORD dwNameHash) { + CXFA_Node* pNode = NULL; + pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); + return pNode; +} +static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, + FX_DWORD dwNameHash, + CXFA_Node* pDataNode) { + pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); +} +static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { + pDocument->m_rgGlobalBinding.RemoveAll(); +} +static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( + CXFA_Node* pDataScope, + FX_DWORD dwNameHash, + XFA_ELEMENT eMatchDataNodeType, + FX_BOOL bUpLevel = TRUE) { + 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 || + (eMatchDataNodeType != XFA_ELEMENT_DataModel && + pDataChild->GetClassID() != eMatchDataNodeType) || + pDataChild->HasBindItem()) { + continue; + } + return pDataChild; + } + for (CXFA_Node* pDataChild = + pCurDataScope->GetFirstChildByClass(XFA_ELEMENT_DataGroup); + pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( + XFA_ELEMENT_DataGroup)) { + CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( + pDataChild, dwNameHash, eMatchDataNodeType, FALSE); + if (pDataNode) { + return pDataNode; + } + } + if (!bUpLevel) { + break; + } + } + return NULL; +} +static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, + CFX_WideStringC wsName, + CXFA_Node* pDataScope, + XFA_ELEMENT eMatchNodeType) { + FX_DWORD dwNameHash = + wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), + 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); + } + } + return pBounded; + } + return NULL; +} +static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, + CFX_WideStringC wsName, + CXFA_Node* pDataScope, + XFA_ELEMENT eMatchNodeType) { + FX_DWORD dwNameHash = + wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), + 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; + } + } + } + return NULL; +} +static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, + CFX_WideStringC wsRef, + CXFA_Node* pDataScope, + XFA_ELEMENT eMatchNodeType, + CXFA_Node* pTemplateNode, + FX_BOOL bForceBind, + FX_BOOL bUpLevel = TRUE) { + FX_DWORD dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; + if (bUpLevel || wsRef != FX_WSTRC(L"name")) { + dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); + } + XFA_RESOLVENODE_RS rs; + pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, + pTemplateNode); + if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || + rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || + rs.nodes.GetSize() > 1) { + return pDocument->GetNotBindNode(rs.nodes); + } + if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { + CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; + CXFA_Node* pNode = ToNode(pObject); + if (!bForceBind && pNode && pNode->HasBindItem()) { + pNode = NULL; + } + return pNode; + } + return NULL; +} +CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, + XFA_ELEMENT eClassID, + FX_DWORD dwNameHash, + CXFA_Node* pFormParent) { + CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pFormChild; + pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pFormChild->GetClassID() == eClassID && + pFormChild->GetNameHash() == dwNameHash && + pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { + return pFormChild; + } + } + return NULL; +} +static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, + FX_BOOL bUseInstanceManager = TRUE) { + XFA_ELEMENT eType = pTemplateChild->GetClassID(); + if (eType == XFA_ELEMENT_Variables) { + return TRUE; + } + if (pTemplateChild->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { + return FALSE; + } + if (eType == XFA_ELEMENT_Proto || + (bUseInstanceManager && eType == XFA_ELEMENT_Occur)) { + return FALSE; + } + return TRUE; +} +CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, + CXFA_Node* pFormParent, + CXFA_Node* pTemplateNode, + FX_BOOL bRecursive, + CXFA_NodeArray* pSubformArray) { + CXFA_Node* pExistingNode = NULL; + if (pSubformArray == NULL) { + pExistingNode = XFA_DataMerge_FindFormDOMInstance( + pDocument, pTemplateNode->GetClassID(), pTemplateNode->GetNameHash(), + pFormParent); + } else if (pSubformArray->GetSize() > 0) { + pExistingNode = pSubformArray->GetAt(0); + pSubformArray->RemoveAt(0); + } + if (pExistingNode) { + if (pSubformArray) { + pFormParent->InsertChild(pExistingNode); + } else if (pExistingNode->IsContainerNode()) { + pFormParent->RemoveChild(pExistingNode); + pFormParent->InsertChild(pExistingNode); + } + pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + pExistingNode->SetTemplateNode(pTemplateNode); + if (bRecursive && pExistingNode->GetClassID() != XFA_ELEMENT_Items) { + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, + pTemplateChild, bRecursive); + } + } + } + pExistingNode->SetFlag(XFA_NODEFLAG_Initialized); + return pExistingNode; + } + CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE); + pFormParent->InsertChild(pNewNode, NULL); + if (bRecursive) { + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild)) { + CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE); + pNewNode->InsertChild(pNewChild, NULL); + } + } + } + return pNewNode; +} +static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( + CXFA_Document* pDocument, + CXFA_Node* pFormParent, + CXFA_Node* pTemplateNode, + CXFA_NodeArray& subforms) { + CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); + CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; + FX_DWORD dwInstNameHash = + FX_HashCode_String_GetW(wsInstMgrNodeName, wsInstMgrNodeName.GetLength()); + CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( + pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); + if (pExistingNode) { + FX_DWORD dwNameHash = pTemplateNode->GetNameHash(); + for (CXFA_Node* pNode = + pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pNode;) { + XFA_ELEMENT eCurType = pNode->GetClassID(); + if (eCurType == XFA_ELEMENT_InstanceManager) { + break; + } + if ((eCurType != XFA_ELEMENT_Subform) && + (eCurType != XFA_ELEMENT_SubformSet)) { + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + continue; + } + if (dwNameHash != pNode->GetNameHash()) { + break; + } + CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pFormParent->RemoveChild(pNode); + subforms.Add(pNode); + pNode = pNextNode; + } + pFormParent->RemoveChild(pExistingNode); + pFormParent->InsertChild(pExistingNode); + pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + pExistingNode->SetTemplateNode(pTemplateNode); + return pExistingNode; + } + CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( + XFA_XDPPACKET_Form, XFA_ELEMENT_InstanceManager); + FXSYS_assert(pNewNode); + wsInstMgrNodeName = + FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); + pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); + pFormParent->InsertChild(pNewNode, NULL); + pNewNode->SetTemplateNode(pTemplateNode); + return pNewNode; +} +static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( + CXFA_Document* pDocument, + CXFA_Node* pTemplateNode, + CXFA_Node* pDataScope, + FX_BOOL& bAccessedDataDOM, + FX_BOOL bForceBind, + CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode>* + pIterator, + FX_BOOL& bSelfMatch, + XFA_ATTRIBUTEENUM& eBindMatch, + FX_BOOL bUpLevel = TRUE) { + FX_BOOL bOwnIterator = FALSE; + if (!pIterator) { + bOwnIterator = TRUE; + pIterator = new CXFA_NodeIteratorTemplate< + CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); + } + CXFA_Node* pResult = NULL; + for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); + pCurTemplateNode;) { + XFA_ELEMENT eMatchNodeType; + switch (pCurTemplateNode->GetClassID()) { + case XFA_ELEMENT_Subform: + eMatchNodeType = XFA_ELEMENT_DataGroup; + break; + case XFA_ELEMENT_Field: { + eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) + ? XFA_ELEMENT_DataGroup + : XFA_ELEMENT_DataValue; + } break; + case XFA_ELEMENT_ExclGroup: + eMatchNodeType = XFA_ELEMENT_DataValue; + break; + default: + pCurTemplateNode = pIterator->MoveToNext(); + continue; + } + CXFA_Node* pTemplateNodeOccur = + pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur); + int32_t iMin, iMax, iInit; + if (pTemplateNodeOccur && + XFA_GetOccurInfo(pTemplateNodeOccur, iMin, iMax, iInit) && iMax == 0) { + pCurTemplateNode = pIterator->MoveToNext(); + continue; + } + CXFA_Node* pTemplateNodeBind = + pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind); + XFA_ATTRIBUTEENUM eMatch = + pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) + : XFA_ATTRIBUTEENUM_Once; + eBindMatch = eMatch; + switch (eMatch) { + case XFA_ATTRIBUTEENUM_None: + pCurTemplateNode = pIterator->MoveToNext(); + continue; + case XFA_ATTRIBUTEENUM_Global: + bAccessedDataDOM = TRUE; + if (!bForceBind) { + pCurTemplateNode = pIterator->MoveToNext(); + continue; + } + if (eMatchNodeType == XFA_ELEMENT_DataValue || + (eMatchNodeType == XFA_ELEMENT_DataGroup && + XFA_FieldIsMultiListBox(pTemplateNodeBind))) { + CXFA_Node* pGlobalBindNode = XFA_DataMerge_FindGlobalDataNode( + pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), + pDataScope, eMatchNodeType); + if (!pGlobalBindNode) { + pCurTemplateNode = pIterator->MoveToNext(); + continue; + } + pResult = pGlobalBindNode; + break; + } + case XFA_ATTRIBUTEENUM_Once: { + bAccessedDataDOM = TRUE; + CXFA_Node* pOnceBindNode = XFA_DataMerge_FindOnceDataNode( + pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), + pDataScope, eMatchNodeType); + if (!pOnceBindNode) { + pCurTemplateNode = pIterator->MoveToNext(); + continue; + } + pResult = pOnceBindNode; + } break; + case XFA_ATTRIBUTEENUM_DataRef: { + bAccessedDataDOM = TRUE; + CXFA_Node* pDataRefBindNode = XFA_DataMerge_FindDataRefDataNode( + pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref), + pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel); + if (pDataRefBindNode && + pDataRefBindNode->GetClassID() == eMatchNodeType) { + pResult = pDataRefBindNode; + } + if (!pResult) { + pCurTemplateNode = pIterator->SkipChildrenAndMoveToNext(); + continue; + } + } break; + default: + break; + } + if (pCurTemplateNode == pTemplateNode && pResult) { + bSelfMatch = TRUE; + } + break; + } + if (bOwnIterator) { + delete pIterator; + } + return pResult; +} +static void XFA_DataMerge_SortRecurseRecord( + CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord>& rgRecords, + CXFA_Node* pDataScope, + FX_BOOL bChoiceMode = FALSE) { + int32_t iCount = rgRecords.GetSize(); + CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgResultRecord; + for (CXFA_Node* pChildNode = pDataScope->GetNodeItem(XFA_NODEITEM_FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + for (int32_t i = 0; i < iCount; i++) { + CXFA_Node* pNode = rgRecords[i].pDataChild; + if (pChildNode == pNode) { + XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, + pNode}; + rgResultRecord.Add(sNewRecord); + rgRecords.RemoveAt(i); + iCount--; + break; + } + } + if (bChoiceMode && rgResultRecord.GetSize() > 0) { + break; + } + } + if (rgResultRecord.GetSize() > 0) { + if (!bChoiceMode) { + for (int32_t i = 0; i < iCount; i++) { + XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, + rgRecords[i].pDataChild}; + rgResultRecord.Add(sNewRecord); + } + } + rgRecords.RemoveAll(); + rgRecords.Copy(rgResultRecord); + } +} +static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( + CXFA_Document* pDocument, + CXFA_Node* pTemplateNode, + CXFA_Node* pFormParentNode, + CXFA_Node* pDataScope, + FX_BOOL bOneInstance, + FX_BOOL bDataMerge) { + XFA_ELEMENT eElement = pTemplateNode->GetClassID(); + CXFA_Node* pOccurNode = NULL; + CXFA_Node* pFirstInstance = NULL; + FX_BOOL bUseInstanceManager = + pFormParentNode->GetClassID() != XFA_ELEMENT_Area; + CXFA_Node* pInstMgrNode = NULL; + CXFA_NodeArray subformArray; + CXFA_NodeArray* pSearchArray = NULL; + if (!bOneInstance && + (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Subform)) { + pInstMgrNode = + bUseInstanceManager + ? XFA_NodeMerge_CloneOrMergeInstanceManager( + pDocument, pFormParentNode, pTemplateNode, subformArray) + : NULL; + if (CXFA_Node* pOccurTemplateNode = + pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur)) { + pOccurNode = pInstMgrNode + ? XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) + : pOccurTemplateNode; + } else if (pInstMgrNode) { + pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_ELEMENT_Occur); + if (pOccurNode) { + pOccurNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + } + } + if (pInstMgrNode) { + pInstMgrNode->SetFlag(XFA_NODEFLAG_Initialized); + pSearchArray = &subformArray; + if (pFormParentNode->GetClassID() == XFA_ELEMENT_PageArea) { + bOneInstance = TRUE; + if (subformArray.GetSize() < 1) { + pSearchArray = NULL; + } + } else if ((pTemplateNode->GetNameHash() == 0) && + (subformArray.GetSize() < 1)) { + pSearchArray = NULL; + } + } + } + int32_t iMax = 1, iInit = 1, iMin = 1; + if (!bOneInstance) { + XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); + } + XFA_ATTRIBUTEENUM eRelation = + eElement == XFA_ELEMENT_SubformSet + ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) + : XFA_ATTRIBUTEENUM_Ordered; + int32_t iCurRepeatIndex = 0; + XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None; + if (bDataMerge) { + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> + sNodeIterator(pTemplateNode); + FX_BOOL bAccessedDataDOM = FALSE; + if (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Area) { + sNodeIterator.MoveToNext(); + } else { + CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; + CXFA_NodeArray subformArray; + for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { + FX_BOOL bSelfMatch = FALSE; + XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; + CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( + pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, + &sNodeIterator, bSelfMatch, eBindMatch); + if (!pDataNode || sNodeIterator.GetCurrent() != pTemplateNode) { + break; + } + eParentBindMatch = eBindMatch; + CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); + if (!pFirstInstance) { + pFirstInstance = pSubformNode; + } + XFA_DataMerge_CreateDataBinding(pSubformNode, pDataNode); + FXSYS_assert(pSubformNode); + subformMapArray.SetAt(pSubformNode, pDataNode); + subformArray.Add(pSubformNode); + } + subformMapArray.GetStartPosition(); + for (int32_t iIndex = 0; iIndex < subformArray.GetSize(); iIndex++) { + CXFA_Node* pSubform = subformArray[iIndex]; + CXFA_Node* pDataNode = + reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform)); + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubform, + pTemplateChild, TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + pDocument->DataMerge_CopyContainer(pTemplateChild, pSubform, + pDataNode, FALSE, TRUE, FALSE); + } + } + } + subformMapArray.RemoveAll(); + } + for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { + FX_BOOL bSelfMatch = FALSE; + XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; + if (!XFA_DataMerge_FindMatchingDataNode( + pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, + &sNodeIterator, bSelfMatch, eBindMatch)) { + break; + } + if (eBindMatch == XFA_ATTRIBUTEENUM_DataRef && + eParentBindMatch == XFA_ATTRIBUTEENUM_DataRef) { + break; + } + if (eRelation == XFA_ATTRIBUTEENUM_Choice || + eRelation == XFA_ATTRIBUTEENUM_Unordered) { + CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); + FXSYS_assert(pSubformSetNode); + if (!pFirstInstance) { + pFirstInstance = pSubformSetNode; + } + CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgItemMatchList; + CFX_ArrayTemplate<CXFA_Node*> rgItemUnmatchList; + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, + pTemplateChild, TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + CXFA_Node* pDataMatch; + bSelfMatch = FALSE; + eBindMatch = XFA_ATTRIBUTEENUM_None; + if (eRelation != XFA_ATTRIBUTEENUM_Ordered && + (pDataMatch = XFA_DataMerge_FindMatchingDataNode( + pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, + FALSE, NULL, bSelfMatch, eBindMatch))) { + XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild, + pDataMatch}; + if (bSelfMatch) { + rgItemMatchList.InsertAt(0, sNewRecord); + } else { + rgItemMatchList.Add(sNewRecord); + } + } else { + rgItemUnmatchList.Add(pTemplateChild); + } + } + } + switch (eRelation) { + case XFA_ATTRIBUTEENUM_Choice: { + FXSYS_assert(rgItemMatchList.GetSize()); + XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope, TRUE); + pDocument->DataMerge_CopyContainer( + rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope); + } break; + case XFA_ATTRIBUTEENUM_Unordered: { + if (rgItemMatchList.GetSize()) { + XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope); + for (int32_t i = 0, count = rgItemMatchList.GetSize(); i < count; + i++) { + pDocument->DataMerge_CopyContainer( + rgItemMatchList[i].pTemplateChild, pSubformSetNode, + pDataScope); + } + } + for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count; + i++) { + pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i], + pSubformSetNode, pDataScope); + } + } break; + default: + break; + } + } else { + CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); + FXSYS_assert(pSubformSetNode); + if (!pFirstInstance) { + pFirstInstance = pSubformSetNode; + } + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, + pTemplateChild, TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, + pDataScope); + } + } + } + } + if (iCurRepeatIndex == 0 && bAccessedDataDOM == FALSE) { + int32_t iLimit = iMax; + if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) { + iLimit = subformArray.GetSize(); + if (iLimit < iMin) { + iLimit = iInit; + } + } + for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) { + if (pInstMgrNode) { + if (pSearchArray && pSearchArray->GetSize() < 1) { + if (pTemplateNode->GetNameHash() != 0) { + break; + } + pSearchArray = NULL; + } + } else if (!XFA_DataMerge_FindFormDOMInstance( + pDocument, pTemplateNode->GetClassID(), + pTemplateNode->GetNameHash(), pFormParentNode)) { + break; + } + CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); + FXSYS_assert(pSubformNode); + if (!pFirstInstance) { + pFirstInstance = pSubformNode; + } + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformNode, + pTemplateChild, TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode, + pDataScope); + } + } + } + } + } + int32_t iMinimalLimit = iCurRepeatIndex == 0 ? iInit : iMin; + for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) { + CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); + FXSYS_assert(pSubformSetNode); + if (!pFirstInstance) { + pFirstInstance = pSubformSetNode; + } + FX_BOOL bFound = FALSE; + for (CXFA_Node* pTemplateChild = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, + pTemplateChild, TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + if (bFound && eRelation == XFA_ATTRIBUTEENUM_Choice) { + continue; + } + pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, + pDataScope, FALSE, bDataMerge); + bFound = TRUE; + } + } + } + return pFirstInstance; +} +static CXFA_Node* XFA_DataMerge_CopyContainer_Field(CXFA_Document* pDocument, + CXFA_Node* pTemplateNode, + CXFA_Node* pFormNode, + CXFA_Node* pDataScope, + FX_BOOL bDataMerge, + FX_BOOL bUpLevel = TRUE) { + CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pFormNode, pTemplateNode, FALSE); + FXSYS_assert(pFieldNode); + for (CXFA_Node* pTemplateChildNode = + pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChildNode)) { + XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, + pTemplateChildNode, TRUE); + } else if (pTemplateNode->GetClassID() == XFA_ELEMENT_ExclGroup && + pTemplateChildNode->IsContainerNode()) { + if (pTemplateChildNode->GetClassID() == XFA_ELEMENT_Field) { + XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, + pFieldNode, NULL, FALSE); + } + } + } + if (bDataMerge) { + FX_BOOL bAccessedDataDOM = FALSE; + FX_BOOL bSelfMatch = FALSE; + XFA_ATTRIBUTEENUM eBindMatch; + CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( + pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL, + bSelfMatch, eBindMatch, bUpLevel); + if (pDataNode) { + XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); + } + } else { + XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); + } + return pFieldNode; +} +CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, + CXFA_Node* pFormNode, + CXFA_Node* pDataScope, + FX_BOOL bOneInstance, + FX_BOOL bDataMerge, + FX_BOOL bUpLevel) { + switch (pTemplateNode->GetClassID()) { + case XFA_ELEMENT_SubformSet: + case XFA_ELEMENT_Subform: + case XFA_ELEMENT_Area: + case XFA_ELEMENT_PageArea: + return XFA_DataMerge_CopyContainer_SubformSet( + this, pTemplateNode, pFormNode, pDataScope, bOneInstance, bDataMerge); + case XFA_ELEMENT_ExclGroup: + case XFA_ELEMENT_Field: + case XFA_ELEMENT_Draw: + case XFA_ELEMENT_ContentArea: + return XFA_DataMerge_CopyContainer_Field( + this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); + case XFA_ELEMENT_PageSet: + break; + case XFA_ELEMENT_Variables: + break; + default: + FXSYS_assert(FALSE); + break; + } + return NULL; +} + +static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, + CXFA_Node* pFormNode, + CXFA_Node* pDataScope, + FX_BOOL bDataRef, + FX_BOOL bParentDataRef) { + FX_BOOL bMatchRef = TRUE; + XFA_ELEMENT eClassID = pFormNode->GetClassID(); + CXFA_Node* pDataNode = pFormNode->GetBindData(); + if (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup || + eClassID == XFA_ELEMENT_Field) { + CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); + CXFA_Node* pTemplateNodeBind = + pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind) + : NULL; + XFA_ATTRIBUTEENUM eMatch = + pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) + : XFA_ATTRIBUTEENUM_Once; + switch (eMatch) { + case XFA_ATTRIBUTEENUM_None: + if (!bDataRef || bParentDataRef) { + XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); + } + break; + case XFA_ATTRIBUTEENUM_Once: + if (!bDataRef || bParentDataRef) { + if (!pDataNode) { + if (pFormNode->GetNameHash() != 0 && + pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != + XFA_ATTRIBUTEENUM_None) { + XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || + XFA_FieldIsMultiListBox(pFormNode)) + ? XFA_ELEMENT_DataGroup + : XFA_ELEMENT_DataValue; + pDataNode = XFA_DataDescription_MaybeCreateDataNode( + pDocument, pDataScope, eDataNodeType, + pFormNode->GetCData(XFA_ATTRIBUTE_Name)); + if (pDataNode) { + XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); + } + } + if (!pDataNode) { + XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); + } + } else { + CXFA_Node* pDataParent = + pDataNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pDataParent != pDataScope) { + FXSYS_assert(pDataParent); + pDataParent->RemoveChild(pDataNode); + pDataScope->InsertChild(pDataNode); + } + } + } + break; + case XFA_ATTRIBUTEENUM_Global: + if (!bDataRef || bParentDataRef) { + FX_DWORD dwNameHash = pFormNode->GetNameHash(); + if (dwNameHash != 0 && !pDataNode) { + pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); + if (!pDataNode) { + XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || + XFA_FieldIsMultiListBox(pFormNode)) + ? XFA_ELEMENT_DataGroup + : XFA_ELEMENT_DataValue; + CXFA_Node* pRecordNode = + ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); + pDataNode = XFA_DataDescription_MaybeCreateDataNode( + pDocument, pRecordNode, eDataNodeType, + pFormNode->GetCData(XFA_ATTRIBUTE_Name)); + if (pDataNode) { + XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); + XFA_DataMerge_RegisterGlobalBinding( + pDocument, pFormNode->GetNameHash(), pDataNode); + } + } else { + XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode); + } + } + if (!pDataNode) { + XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); + } + } + break; + case XFA_ATTRIBUTEENUM_DataRef: { + bMatchRef = bDataRef; + bParentDataRef = TRUE; + if (!pDataNode && bDataRef) { + CFX_WideStringC wsRef = + pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref); + FX_DWORD dFlags = + XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode; + XFA_RESOLVENODE_RS rs; + pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, + dFlags, pTemplateNode); + CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; + pDataNode = ToNode(pObject); + if (pDataNode) { + XFA_DataMerge_CreateDataBinding( + pFormNode, pDataNode, + rs.dwFlags == XFA_RESOVENODE_RSTYPE_ExistNodes); + } else { + XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); + } + } + } break; + default: + break; + } + } + if (bMatchRef && + (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_SubformSet || + eClassID == XFA_ELEMENT_Area || eClassID == XFA_ELEMENT_PageArea || + eClassID == XFA_ELEMENT_PageSet)) { + for (CXFA_Node* pFormChild = + pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pFormChild; + pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pFormChild->GetObjectType() != XFA_OBJECTTYPE_ContainerNode) { + continue; + } + if (pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { + continue; + } + XFA_DataMerge_UpdateBindingRelations(pDocument, pFormChild, + pDataNode ? pDataNode : pDataScope, + bDataRef, bParentDataRef); + } + } +} +CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode) { + for (CXFA_Node* pRootBoundNode = pParentFormNode; + pRootBoundNode && + pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; + pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { + CXFA_Node* pDataScope = pRootBoundNode->GetBindData(); + if (pDataScope) { + return pDataScope; + } + } + return ToNode( + pParentFormNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Data)); +} +void CXFA_Document::DataMerge_UpdateBindingRelations( + CXFA_Node* pFormUpdateRoot) { + CXFA_Node* pDataScope = XFA_DataMerge_FindDataScope( + pFormUpdateRoot->GetNodeItem(XFA_NODEITEM_Parent)); + if (!pDataScope) { + return; + } + XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, FALSE, + FALSE); + XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, TRUE, + FALSE); +} +CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) { + for (int32_t i = 0; i < arrayNodes.GetSize(); i++) { + CXFA_Node* pNode = arrayNodes[i]->AsNode(); + if (pNode && !pNode->HasBindItem()) + return pNode; + } + return nullptr; +} +void CXFA_Document::DoDataMerge() { + CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); + if (!pDatasetsRoot) { + IFDE_XMLElement* pDatasetsXMLNode = + IFDE_XMLElement::Create(FX_WSTRC(L"xfa:datasets")); + FXSYS_assert(pDatasetsXMLNode); + pDatasetsXMLNode->SetString( + FX_WSTRC(L"xmlns:xfa"), + FX_WSTRC(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")); + m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); + m_pRootNode->InsertChild(pDatasetsRoot); + pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); + } + CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL; + CFX_WideString wsDatasetsURI; + pDatasetsRoot->TryNamespace(wsDatasetsURI); + for (CXFA_Node* pChildNode = + pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pChildNode->GetClassID() != XFA_ELEMENT_DataGroup) { + continue; + } + CFX_WideString wsNamespaceURI; + if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { + if (!pChildNode->TryNamespace(wsNamespaceURI)) { + continue; + } + if (wsNamespaceURI == + FX_WSTRC(L"http://ns.adobe.com/data-description/")) { + pDDRoot = pChildNode; + } + } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { + if (!pChildNode->TryNamespace(wsNamespaceURI)) { + continue; + } + if (wsNamespaceURI == wsDatasetsURI) { + pDataRoot = pChildNode; + } + } + if (pDataRoot && pDDRoot) { + break; + } + } + if (!pDataRoot) { + IFDE_XMLElement* pDataRootXMLNode = + IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); + FXSYS_assert(pDataRootXMLNode); + pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); + pDataRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"data")); + pDataRoot->SetXMLMappingNode(pDataRootXMLNode); + pDatasetsRoot->InsertChild(pDataRoot); + } + CXFA_Node* pDataTopLevel = + pDataRoot->GetFirstChildByClass(XFA_ELEMENT_DataGroup); + FX_DWORD dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; + CXFA_Node* pTemplateRoot = + m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); + if (!pTemplateRoot) { + return; + } + CXFA_Node* pTemplateChosen = + dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL; + if (!pTemplateChosen || + pTemplateChosen->GetClassID() != XFA_ELEMENT_Subform) { + pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform); + } + if (!pTemplateChosen) { + return; + } + CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Form); + FX_BOOL bEmptyForm = FALSE; + if (!pFormRoot) { + bEmptyForm = TRUE; + pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); + FXSYS_assert(pFormRoot); + pFormRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(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); + } + } + CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( + this, pFormRoot, pTemplateChosen, FALSE); + FXSYS_assert(pSubformSetNode); + if (!pDataTopLevel) { + CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); + CFX_WideString wsDataTopLevelName = + wsFormName.IsEmpty() ? FX_WSTRC(L"form") : wsFormName; + IFDE_XMLElement* pDataTopLevelXMLNode = + IFDE_XMLElement::Create(wsDataTopLevelName); + FXSYS_assert(pDataTopLevelXMLNode); + pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); + pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); + pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); + CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + pDataRoot->InsertChild(pDataTopLevel, pBeforeNode); + } + FXSYS_assert(pDataTopLevel); + XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel); + for (CXFA_Node* pTemplateChild = + pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; + pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (XFA_NeedGenerateForm(pTemplateChild)) { + XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild, + TRUE); + } else if (pTemplateChild->GetObjectType() == + XFA_OBJECTTYPE_ContainerNode) { + DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel); + } + } + if (pDDRoot) { + XFA_DataDescription_UpdateDataRelation(pDataRoot, pDDRoot); + } + DataMerge_UpdateBindingRelations(pSubformSetNode); + CXFA_Node* pPageSetNode = + pSubformSetNode->GetFirstChildByClass(XFA_ELEMENT_PageSet); + while (pPageSetNode) { + m_pPendingPageSet.Add(pPageSetNode); + CXFA_Node* pNextPageSetNode = + pPageSetNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet); + pSubformSetNode->RemoveChild(pPageSetNode); + pPageSetNode = pNextPageSetNode; + } + if (!bEmptyForm) { + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> + sIterator(pFormRoot); + CXFA_Node* pNode = sIterator.MoveToNext(); + while (pNode) { + if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { + if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode || + pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { + CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); + pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); + pNode = pNext; + } else { + pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + pNode->SetFlag(XFA_NODEFLAG_Initialized); + pNode = sIterator.MoveToNext(); + } + } else { + pNode->SetFlag(XFA_NODEFLAG_Initialized); + pNode = sIterator.MoveToNext(); + } + } + } +} +void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) { + CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form)); + if (pFormRoot) { + while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { + pFormRoot->RemoveChild(pNode); + } + pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + } + XFA_DataMerge_ClearGlobalBinding(this); + if (bDoDataMerge) { + DoDataMerge(); + } + CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); + pLayoutProcessor->SetForceReLayout(TRUE); +} diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.h b/xfa/fxfa/parser/xfa_document_datamerger_imp.h new file mode 100644 index 0000000000..a5583cb9b7 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.h @@ -0,0 +1,24 @@ +// 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_DOCUMENT_DATAMERGER_IMP_H_ +#define XFA_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_ + +#include "xfa/fxfa/parser/xfa_object.h" + +CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer( + CXFA_Document* pDocument, + CXFA_Node* pFormParent, + CXFA_Node* pTemplateNode, + FX_BOOL bRecursive, + CXFA_NodeArray* pSubformArray = NULL); +CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode); +CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, + XFA_ELEMENT eClassID, + FX_DWORD dwNameHash, + CXFA_Node* pFormParent); + +#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_ diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp new file mode 100644 index 0000000000..ce07c4704e --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_imp.cpp @@ -0,0 +1,441 @@ +// 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/include/fxcrt/fx_ext.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" +#include "xfa/fxfa/parser/xfa_localemgr.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_script_datawindow.h" +#include "xfa/fxfa/parser/xfa_script_eventpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_logpseudomodel.h" +#include "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +CXFA_Document::CXFA_Document(IXFA_DocParser* pParser) + : m_pParser(pParser), + m_pScriptContext(nullptr), + m_pLayoutProcessor(nullptr), + m_pRootNode(nullptr), + m_pLocalMgr(nullptr), + m_pScriptDataWindow(nullptr), + m_pScriptEvent(nullptr), + m_pScriptHost(nullptr), + m_pScriptLog(nullptr), + m_pScriptLayout(nullptr), + m_pScriptSignature(nullptr), + m_eCurVersionMode(XFA_VERSION_DEFAULT), + m_dwDocFlags(0) { + ASSERT(m_pParser); +} +CXFA_Document::~CXFA_Document() { + delete m_pRootNode; + PurgeNodes(); +} +void CXFA_Document::ClearLayoutData() { + if (m_pLayoutProcessor) { + delete m_pLayoutProcessor; + m_pLayoutProcessor = NULL; + } + 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; + } +} +void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { + if (m_pRootNode) { + AddPurgeNode(m_pRootNode); + } + m_pRootNode = pNewRoot; + RemovePurgeNode(pNewRoot); +} +IXFA_Notify* CXFA_Document::GetNotify() const { + return m_pParser->GetNotify(); +} +CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { + return GetXFAObject( + FX_HashCode_String_GetW(wsNodeName.GetPtr(), wsNodeName.GetLength())); +} +CXFA_Object* CXFA_Document::GetXFAObject(FX_DWORD dwNodeNameHash) { + switch (dwNodeNameHash) { + case XFA_HASHCODE_Data: { + CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); + if (!pDatasetsNode) { + return NULL; + } + for (CXFA_Node* pDatasetsChild = + pDatasetsNode->GetFirstChildByClass(XFA_ELEMENT_DataGroup); + pDatasetsChild; + pDatasetsChild = + pDatasetsChild->GetNextSameClassSibling(XFA_ELEMENT_DataGroup)) { + if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) { + continue; + } + CFX_WideString wsNamespaceURI; + if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) { + continue; + } + CFX_WideString wsDatasetsURI; + if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) { + continue; + } + if (wsNamespaceURI == wsDatasetsURI) { + return pDatasetsChild; + } + } + } + return NULL; + case XFA_HASHCODE_Record: { + CXFA_Node* pData = ToNode(GetXFAObject(XFA_HASHCODE_Data)); + return pData ? pData->GetFirstChildByClass(XFA_ELEMENT_DataGroup) : NULL; + } + case XFA_HASHCODE_DataWindow: { + if (m_pScriptDataWindow == NULL) { + m_pScriptDataWindow = new CScript_DataWindow(this); + } + return m_pScriptDataWindow; + } + case XFA_HASHCODE_Event: { + if (m_pScriptEvent == NULL) { + m_pScriptEvent = new CScript_EventPseudoModel(this); + } + return m_pScriptEvent; + } + case XFA_HASHCODE_Host: { + if (m_pScriptHost == NULL) { + m_pScriptHost = new CScript_HostPseudoModel(this); + } + return m_pScriptHost; + } + case XFA_HASHCODE_Log: { + if (m_pScriptLog == NULL) { + m_pScriptLog = new CScript_LogPseudoModel(this); + } + return m_pScriptLog; + } + case XFA_HASHCODE_Signature: { + if (m_pScriptSignature == NULL) { + m_pScriptSignature = new CScript_SignaturePseudoModel(this); + } + return m_pScriptSignature; + } + case XFA_HASHCODE_Layout: { + if (m_pScriptLayout == NULL) { + m_pScriptLayout = new CScript_LayoutPseudoModel(this); + } + return m_pScriptLayout; + } + default: + return m_pRootNode->GetFirstChildByName(dwNodeNameHash); + } +} +CXFA_Node* CXFA_Document::CreateNode(FX_DWORD 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; + } + 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); + } + return pNode; + } + return NULL; +} +void CXFA_Document::AddPurgeNode(CXFA_Node* pNode) { + m_rgPurgeNodes.Add(pNode); +} +FX_BOOL CXFA_Document::RemovePurgeNode(CXFA_Node* pNode) { + return m_rgPurgeNodes.RemoveKey(pNode); +} +void CXFA_Document::PurgeNodes() { + FX_POSITION psNode = m_rgPurgeNodes.GetStartPosition(); + while (psNode) { + CXFA_Node* pNode; + m_rgPurgeNodes.GetNextAssoc(psNode, pNode); + delete pNode; + } + m_rgPurgeNodes.RemoveAll(); +} +void CXFA_Document::SetFlag(FX_DWORD dwFlag, FX_BOOL bOn) { + if (bOn) { + m_dwDocFlags |= dwFlag; + } else { + m_dwDocFlags &= ~dwFlag; + } +} +FX_BOOL CXFA_Document::IsInteractive() { + if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) { + return m_dwDocFlags & XFA_DOCFLAG_Interactive; + } + CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config)); + if (!pConfig) { + return FALSE; + } + CFX_WideString wsInteractive; + CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_ELEMENT_Present); + if (!pPresent) { + return FALSE; + } + CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_ELEMENT_Pdf); + if (!pPDF) { + return FALSE; + } + CXFA_Node* pInteractive = pPDF->GetChild(0, XFA_ELEMENT_Interactive); + if (pInteractive) { + m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; + if (pInteractive->TryContent(wsInteractive) && + wsInteractive == FX_WSTRC(L"1")) { + m_dwDocFlags |= XFA_DOCFLAG_Interactive; + return TRUE; + } + } + return FALSE; +} +CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { + if (!m_pLocalMgr) { + CFX_WideString wsLanguage; + GetParser()->GetNotify()->GetAppProvider()->GetLanguage(wsLanguage); + m_pLocalMgr = new CXFA_LocaleMgr( + ToNode(GetXFAObject(XFA_HASHCODE_LocaleSet)), wsLanguage); + } + return m_pLocalMgr; +} +IXFA_ScriptContext* CXFA_Document::InitScriptContext(FXJSE_HRUNTIME hRuntime) { + if (!m_pScriptContext) { + m_pScriptContext = XFA_ScriptContext_Create(this); + } + m_pScriptContext->Initialize(hRuntime); + return m_pScriptContext; +} +IXFA_ScriptContext* CXFA_Document::GetScriptContext() { + if (!m_pScriptContext) { + m_pScriptContext = XFA_ScriptContext_Create(this); + } + return m_pScriptContext; +} +XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( + CFX_WideString& wsTemplateNS) { + CFX_WideStringC wsTemplateURIPrefix = + XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; + FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); + if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) != + wsTemplateURIPrefix) { + return XFA_VERSION_UNKNOWN; + } + FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength); + if (nDotPos == (FX_STRSIZE)-1) { + return XFA_VERSION_UNKNOWN; + } + int8_t iMajor = + FXSYS_wtoi(wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength)); + int8_t iMinor = FXSYS_wtoi( + wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2)); + XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor); + if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) { + return XFA_VERSION_UNKNOWN; + } + m_eCurVersionMode = eVersion; + return eVersion; +} +CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, + const CFX_WideStringC& wsID) { + if (!pRoot || wsID.IsEmpty()) { + return NULL; + } + CXFA_NodeIterator sIterator(pRoot); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + CFX_WideStringC wsIDVal; + if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { + if (wsIDVal == wsID) { + return pNode; + } + } + } + return NULL; +} +static void XFA_ProtoMerge_MergeNodeRecurse(CXFA_Document* pDocument, + CXFA_Node* pDestNodeParent, + CXFA_Node* pProtoNode) { + CXFA_Node* pExistingNode = NULL; + for (CXFA_Node* pFormChild = + pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild); + pFormChild; + pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pFormChild->GetClassID() == pProtoNode->GetClassID() && + pFormChild->GetNameHash() == pProtoNode->GetNameHash() && + pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { + pFormChild->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + pExistingNode = pFormChild; + break; + } + } + if (pExistingNode) { + pExistingNode->SetTemplateNode(pProtoNode); + for (CXFA_Node* pTemplateChild = + pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + XFA_ProtoMerge_MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild); + } + return; + } + CXFA_Node* pNewNode = pProtoNode->Clone(TRUE); + pNewNode->SetTemplateNode(pProtoNode); + pDestNodeParent->InsertChild(pNewNode, NULL); +} +static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument, + CXFA_Node* pDestNode, + CXFA_Node* pProtoNode) { + { + CXFA_NodeIterator sIterator(pDestNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + pNode->SetFlag(XFA_NODEFLAG_UnusedNode); + } + } + pDestNode->SetTemplateNode(pProtoNode); + for (CXFA_Node* pTemplateChild = + pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; + pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ProtoMerge_MergeNodeRecurse(pDocument, pDestNode, pTemplateChild); + } + { + CXFA_NodeIterator sIterator(pDestNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + } + } +} +void CXFA_Document::DoProtoMerge() { + CXFA_Node* pTemplateRoot = ToNode(GetXFAObject(XFA_HASHCODE_Template)); + if (!pTemplateRoot) { + return; + } + CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> mIDMap; + CXFA_NodeSet sUseNodes; + CXFA_NodeIterator sIterator(pTemplateRoot); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + CFX_WideStringC wsIDVal; + if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { + mIDMap[FX_HashCode_String_GetW(wsIDVal.GetPtr(), wsIDVal.GetLength())] = + pNode; + } + CFX_WideStringC wsUseVal; + if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) { + sUseNodes.Add(pNode); + } else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) && + !wsUseVal.IsEmpty()) { + sUseNodes.Add(pNode); + } + } + FX_POSITION pos = sUseNodes.GetStartPosition(); + while (pos) { + CXFA_Node* pUseHrefNode = NULL; + sUseNodes.GetNextAssoc(pos, pUseHrefNode); + 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; + } else { + wsURI = CFX_WideStringC((const FX_WCHAR*)wsUseVal, uSharpPos); + FX_STRSIZE uLen = wsUseVal.GetLength(); + if (uLen >= uSharpPos + 5 && + CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos, 5) == + FX_WSTRC(L"#som(") && + wsUseVal[uLen - 1] == ')') { + wsSOM = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 5, + uLen - 1 - uSharpPos - 5); + } else { + wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + 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); + } else { + wsSOM = + CFX_WideStringC((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength()); + } + } + if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) { + continue; + } + CXFA_Node* pProtoNode = NULL; + if (!wsSOM.IsEmpty()) { + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | + XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM, + resoveNodeRS, dwFlag); + if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { + pProtoNode = resoveNodeRS.nodes[0]->AsNode(); + } + } else if (!wsID.IsEmpty()) { + if (!mIDMap.Lookup( + FX_HashCode_String_GetW(wsID.GetPtr(), wsID.GetLength()), + pProtoNode)) { + continue; + } + } + if (!pProtoNode) { + continue; + } + XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); + } +} diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/fxfa/parser/xfa_document_layout_imp.cpp new file mode 100644 index 0000000000..dbaa6e4df7 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_layout_imp.cpp @@ -0,0 +1,208 @@ +// 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/fxfa/parser/xfa_document_layout_imp.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_datamerger_imp.h" +#include "xfa/fxfa/parser/xfa_layout_appadapter.h" +#include "xfa/fxfa/parser/xfa_layout_itemlayout.h" +#include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" +#include "xfa/fxfa/parser/xfa_localemgr.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" + +CXFA_LayoutProcessor* CXFA_Document::GetLayoutProcessor() { + if (!m_pLayoutProcessor) { + m_pLayoutProcessor = new CXFA_LayoutProcessor(this); + ASSERT(m_pLayoutProcessor); + } + return m_pLayoutProcessor; +} +IXFA_DocLayout* CXFA_Document::GetDocLayout() { + return GetLayoutProcessor(); +} +CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument) + : m_pDocument(pDocument), + m_pRootItemLayoutProcessor(NULL), + m_pLayoutPageMgr(NULL), + m_nProgressCounter(0), + m_bNeeLayout(TRUE) {} +CXFA_LayoutProcessor::~CXFA_LayoutProcessor() { + ClearLayoutData(); +} +CXFA_Document* CXFA_LayoutProcessor::GetDocument() const { + return m_pDocument; +} +int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) { + if (!bForceRestart && !IsNeedLayout()) { + return 100; + } + if (m_pRootItemLayoutProcessor) { + delete m_pRootItemLayoutProcessor; + m_pRootItemLayoutProcessor = NULL; + } + m_nProgressCounter = 0; + CXFA_Node* pFormPacketNode = + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); + if (!pFormPacketNode) { + return -1; + } + CXFA_Node* pFormRoot = + pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform); + if (!pFormRoot) { + return -1; + } + if (!m_pLayoutPageMgr) { + m_pLayoutPageMgr = new CXFA_LayoutPageMgr(this); + } + if (!m_pLayoutPageMgr->InitLayoutPage(pFormRoot)) { + return -1; + } + if (!m_pLayoutPageMgr->PrepareFirstPage(pFormRoot)) { + return -1; + } + m_pRootItemLayoutProcessor = + new CXFA_ItemLayoutProcessor(pFormRoot, m_pLayoutPageMgr); + m_nProgressCounter = 1; + return 0; +} +int32_t CXFA_LayoutProcessor::DoLayout(IFX_Pause* pPause) { + if (m_nProgressCounter < 1) { + return -1; + } + XFA_ItemLayoutProcessorResult eStatus; + CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode(); + FX_FLOAT fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); + FX_FLOAT fPosY = pFormNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); + do { + FX_FLOAT fAvailHeight = m_pLayoutPageMgr->GetAvailHeight(); + eStatus = + m_pRootItemLayoutProcessor->DoLayout(TRUE, fAvailHeight, fAvailHeight); + if (eStatus != XFA_ItemLayoutProcessorResult_Done) { + m_nProgressCounter++; + } + CXFA_ContentLayoutItem* pLayoutItem = + m_pRootItemLayoutProcessor->ExtractLayoutItem(); + if (pLayoutItem) { + pLayoutItem->m_sPos = CFX_PointF(fPosX, fPosY); + } + m_pLayoutPageMgr->SubmitContentItem(pLayoutItem, eStatus); + } while (eStatus != XFA_ItemLayoutProcessorResult_Done && + (!pPause || !pPause->NeedToPauseNow())); + if (eStatus == XFA_ItemLayoutProcessorResult_Done) { + m_pLayoutPageMgr->FinishPaginatedPageSets(); + m_pLayoutPageMgr->SyncLayoutData(); + m_bNeeLayout = FALSE; + m_rgChangedContainers.RemoveAll(); + } + return 100 * (eStatus == XFA_ItemLayoutProcessorResult_Done + ? m_nProgressCounter + : m_nProgressCounter - 1) / + m_nProgressCounter; +} +FX_BOOL CXFA_LayoutProcessor::IncrementLayout() { + if (m_bNeeLayout) { + StartLayout(TRUE); + return DoLayout(NULL) == 100; + } + for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) { + CXFA_Node* pNode = m_rgChangedContainers[i]; + CXFA_Node* pParentNode = + pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); + if (!pParentNode) { + return FALSE; + } + if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode, + pParentNode)) { + return FALSE; + } + } + m_rgChangedContainers.RemoveAll(); + return TRUE; +} +int32_t CXFA_LayoutProcessor::CountPages() const { + return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPageCount() : 0; +} +IXFA_LayoutPage* CXFA_LayoutProcessor::GetPage(int32_t index) const { + return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPage(index) : NULL; +} +CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) { + return static_cast<CXFA_LayoutItem*>( + pFormItem->GetUserData(XFA_LAYOUTITEMKEY)); +} +void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) { + if (m_rgChangedContainers.Find(pContainer) < 0) { + m_rgChangedContainers.Add(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; + } + m_nProgressCounter = 0; +} +FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() { + return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0; +} +CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem) + : m_pFormNode(pNode), + m_pParent(NULL), + m_pNextSibling(NULL), + m_pFirstChild(NULL), + m_bIsContentLayoutItem(bIsContentLayoutItem) {} +CXFA_LayoutItem::~CXFA_LayoutItem() {} +CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode) + : CXFA_LayoutItem(pNode, FALSE), m_pOldSubform(NULL) {} +IXFA_DocLayout* CXFA_ContainerLayoutItem::GetLayout() const { + return m_pFormNode->GetDocument()->GetLayoutProcessor(); +} +int32_t CXFA_ContainerLayoutItem::GetPageIndex() const { + return m_pFormNode->GetDocument() + ->GetLayoutProcessor() + ->GetLayoutPageMgr() + ->GetPageIndex(this); +} +void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) { + size.clear(); + CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium); + if (!pMedium) + return; + + size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt), + pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt)); + if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) == + XFA_ATTRIBUTEENUM_Landscape) { + size = CFX_SizeF(size.y, size.x); + } +} +CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const { + return m_pFormNode; +} +CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode) + : CXFA_LayoutItem(pNode, TRUE), + m_pPrev(NULL), + m_pNext(NULL), + m_dwStatus(0) {} +CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() { + if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this) { + m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, NULL); + } +} diff --git a/xfa/fxfa/parser/xfa_document_layout_imp.h b/xfa/fxfa/parser/xfa_document_layout_imp.h new file mode 100644 index 0000000000..7f6c14e73f --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_layout_imp.h @@ -0,0 +1,49 @@ +// 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_DOCUMENT_LAYOUT_IMP_H_ +#define XFA_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_ + +#include "xfa/fxfa/parser/xfa_doclayout.h" + +class CXFA_ItemLayoutProcessor; +class CXFA_LayoutPageMgr; +class CXFA_ContainerLayoutItem; + +class CXFA_LayoutProcessor : public IXFA_DocLayout { + public: + CXFA_LayoutProcessor(CXFA_Document* pDocument); + ~CXFA_LayoutProcessor(); + virtual CXFA_Document* GetDocument() const; + virtual int32_t StartLayout(FX_BOOL bForceRestart = FALSE); + virtual int32_t DoLayout(IFX_Pause* pPause = NULL); + virtual FX_BOOL IncrementLayout(); + virtual int32_t CountPages() const; + virtual IXFA_LayoutPage* GetPage(int32_t index) const; + virtual CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem); + + void AddChangedContainer(CXFA_Node* pContainer); + void SetForceReLayout(FX_BOOL bForceRestart) { m_bNeeLayout = bForceRestart; } + CXFA_ContainerLayoutItem* GetRootLayoutItem() const; + CXFA_ItemLayoutProcessor* GetRootRootItemLayoutProcessor() { + return m_pRootItemLayoutProcessor; + } + CXFA_LayoutPageMgr* GetLayoutPageMgr() { return m_pLayoutPageMgr; } + + protected: + void ClearLayoutData(); + + FX_BOOL IsNeedLayout(); + + CXFA_Document* m_pDocument; + CXFA_ItemLayoutProcessor* m_pRootItemLayoutProcessor; + CXFA_LayoutPageMgr* m_pLayoutPageMgr; + CXFA_NodeArray m_rgChangedContainers; + uint32_t m_nProgressCounter; + FX_BOOL m_bNeeLayout; +}; + +#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_ diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp new file mode 100644 index 0000000000..858effff60 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -0,0 +1,590 @@ +// 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/fxfa/parser/xfa_document_serialize.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" +#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" + +IXFA_PacketImport* IXFA_PacketImport::Create(CXFA_Document* pDocument) { + return new CXFA_DataImporter(pDocument); +} +CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) + : m_pDocument(pDocument) { + ASSERT(m_pDocument); +} +FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) { + IXFA_Parser* pDataDocumentParser = IXFA_Parser::Create(m_pDocument); + if (!pDataDocumentParser) { + return FALSE; + } + if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) != + XFA_PARSESTATUS_Ready) { + pDataDocumentParser->Release(); + return FALSE; + } + if (pDataDocumentParser->DoParse(NULL) < XFA_PARSESTATUS_Done) { + pDataDocumentParser->Release(); + return FALSE; + } + CXFA_Node* pImportDataRoot = pDataDocumentParser->GetRootNode(); + if (!pImportDataRoot) { + pDataDocumentParser->Release(); + return FALSE; + } + CXFA_Node* pDataModel = + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); + if (!pDataModel) { + pDataDocumentParser->Release(); + return FALSE; + } + CXFA_Node* pDataNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Data)); + if (pDataNode) { + pDataModel->RemoveChild(pDataNode); + } + if (pImportDataRoot->GetClassID() == XFA_ELEMENT_DataModel) { + while (CXFA_Node* pChildNode = + pImportDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { + pImportDataRoot->RemoveChild(pChildNode); + pDataModel->InsertChild(pChildNode); + } + } else { + IFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); + IFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + if (pParentXMLNode) { + pParentXMLNode->RemoveChildNode(pXMLNode); + } + pDataModel->InsertChild(pImportDataRoot); + } + m_pDocument->DoDataRemerge(FALSE); + pDataDocumentParser->Release(); + return TRUE; +} +CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) { + CFX_WideTextBuf textBuf; + int32_t iLen = str.GetLength(); + for (int32_t i = 0; i < iLen; i++) { + switch (str[i]) { + case '&': + textBuf << FX_WSTRC(L"&"); + break; + case '<': + textBuf << FX_WSTRC(L"<"); + break; + case '>': + textBuf << FX_WSTRC(L">"); + break; + case '\'': + textBuf << FX_WSTRC(L"'"); + break; + case '\"': + textBuf << FX_WSTRC(L"""); + break; + default: + textBuf.AppendChar(str[i]); + } + } + return textBuf.GetWideString(); +} +CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) { + CFX_WideTextBuf textBuf; + int32_t iLen = str.GetLength(); + for (int32_t i = 0; i < iLen; i++) { + FX_WCHAR ch = str.GetAt(i); + if (!FDE_IsXMLValidChar(ch)) { + continue; + } + if (ch == '&') { + textBuf << FX_WSTRC(L"&"); + } else if (ch == '<') { + textBuf << FX_WSTRC(L"<"); + } else if (ch == '>') { + textBuf << FX_WSTRC(L">"); + } else if (ch == '\'') { + textBuf << FX_WSTRC(L"'"); + } else if (ch == '\"') { + textBuf << FX_WSTRC(L"""); + } else if (ch == ' ') { + if (i && str.GetAt(i - 1) != ' ') { + textBuf.AppendChar(' '); + } else { + textBuf << FX_WSTRC(L" "); + } + } else { + textBuf.AppendChar(str.GetAt(i)); + } + } + return textBuf.GetWideString(); +} +static void XFA_SaveAttribute(CXFA_Node* pNode, + XFA_ATTRIBUTE eName, + const CFX_WideStringC& wsName, + FX_BOOL bProto, + CFX_WideString& wsOutput) { + CFX_WideString wsValue; + if ((!bProto && !pNode->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) || + !pNode->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, FALSE)) { + return; + } + wsValue = XFA_ExportEncodeAttribute(wsValue); + wsOutput += FX_WSTRC(L" "); + wsOutput += wsName; + wsOutput += FX_WSTRC(L"=\""); + wsOutput += wsValue; + wsOutput += FX_WSTRC(L"\""); +} +static FX_BOOL XFA_DataExporter_AttributeSaveInDataModel( + CXFA_Node* pNode, + XFA_ATTRIBUTE eAttribute) { + FX_BOOL bSaveInDataModel = FALSE; + if (pNode->GetClassID() != XFA_ELEMENT_Image) { + return bSaveInDataModel; + } + CXFA_Node* pValueNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pValueNode || pValueNode->GetClassID() != XFA_ELEMENT_Value) { + return bSaveInDataModel; + } + CXFA_Node* pFieldNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pFieldNode && pFieldNode->GetBindData() && + eAttribute == XFA_ATTRIBUTE_Href) { + bSaveInDataModel = TRUE; + } + return bSaveInDataModel; +} +FX_BOOL XFA_DataExporter_ContentNodeNeedtoExport(CXFA_Node* pContentNode) { + CFX_WideString wsContent; + if (!pContentNode->TryContent(wsContent, FALSE, FALSE)) { + return FALSE; + } + FXSYS_assert(pContentNode->GetObjectType() == XFA_OBJECTTYPE_ContentNode); + CXFA_Node* pParentNode = pContentNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Value) { + return TRUE; + } + CXFA_Node* pGrandParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pGrandParentNode || + pGrandParentNode->GetObjectType() != XFA_OBJECTTYPE_ContainerNode) { + return TRUE; + } + if (pGrandParentNode->GetBindData()) { + return FALSE; + } + CXFA_WidgetData* pWidgetData = pGrandParentNode->GetWidgetData(); + XFA_ELEMENT eUIType = pWidgetData->GetUIType(); + if (eUIType == XFA_ELEMENT_PasswordEdit) { + return FALSE; + } + return TRUE; +} +static void XFA_DataExporter_RecognizeXFAVersionNumber( + CXFA_Node* pTemplateRoot, + CFX_WideString& wsVersionNumber) { + wsVersionNumber.Empty(); + if (!pTemplateRoot) { + return; + } + CFX_WideString wsTemplateNS; + if (!pTemplateRoot->TryNamespace(wsTemplateNS)) { + return; + } + XFA_VERSION eVersion = + pTemplateRoot->GetDocument()->RecognizeXFAVersionNumber(wsTemplateNS); + if (eVersion == XFA_VERSION_UNKNOWN) { + eVersion = XFA_VERSION_DEFAULT; + } + wsVersionNumber.Format(L"%i.%i", eVersion / 100, eVersion % 100); +} +static void XFA_DataExporter_RegenerateFormFile_Changed( + CXFA_Node* pNode, + CFX_WideTextBuf& buf, + FX_BOOL bSaveXML = FALSE) { + CFX_WideString wsAttrs; + int32_t iAttrs = 0; + const uint8_t* pAttrs = XFA_GetElementAttributes(pNode->GetClassID(), iAttrs); + while (iAttrs--) { + const XFA_ATTRIBUTEINFO* pAttr = + XFA_GetAttributeByID((XFA_ATTRIBUTE)pAttrs[iAttrs]); + if (pAttr->eName == XFA_ATTRIBUTE_Name || + (XFA_DataExporter_AttributeSaveInDataModel(pNode, pAttr->eName) && + !bSaveXML)) { + continue; + } + CFX_WideString wsAttr; + XFA_SaveAttribute(pNode, pAttr->eName, pAttr->pName, bSaveXML, wsAttr); + wsAttrs += wsAttr; + } + CFX_WideString wsChildren; + switch (pNode->GetObjectType()) { + case XFA_OBJECTTYPE_ContentNode: { + if (!bSaveXML && !XFA_DataExporter_ContentNodeNeedtoExport(pNode)) { + break; + } + CXFA_Node* pRawValueNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pRawValueNode && + pRawValueNode->GetClassID() != XFA_ELEMENT_SharpxHTML && + pRawValueNode->GetClassID() != XFA_ELEMENT_Sharptext && + pRawValueNode->GetClassID() != XFA_ELEMENT_Sharpxml) { + pRawValueNode = pRawValueNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + if (!pRawValueNode) { + break; + } + CFX_WideString wsContentType; + pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); + if (pRawValueNode->GetClassID() == XFA_ELEMENT_SharpxHTML && + wsContentType.Equal(FX_WSTRC(L"text/html"))) { + IFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); + if (!pExDataXML) { + break; + } + IFDE_XMLNode* pRichTextXML = + pExDataXML->GetNodeItem(IFDE_XMLNode::FirstChild); + if (!pRichTextXML) { + break; + } + IFX_MemoryStream* pMemStream = FX_CreateMemoryStream(TRUE); + IFX_Stream* pTempStream = IFX_Stream::CreateStream( + (IFX_FileWrite*)pMemStream, FX_STREAMACCESS_Text | + FX_STREAMACCESS_Write | + FX_STREAMACCESS_Append); + pTempStream->SetCodePage(FX_CODEPAGE_UTF8); + pRichTextXML->SaveXMLNode(pTempStream); + wsChildren += CFX_WideString::FromUTF8( + (const FX_CHAR*)pMemStream->GetBuffer(), pMemStream->GetSize()); + pTempStream->Release(); + pMemStream->Release(); + } else if (pRawValueNode->GetClassID() == XFA_ELEMENT_Sharpxml && + wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + CFX_WideString wsRawValue; + pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, FALSE); + if (wsRawValue.IsEmpty()) { + break; + } + CFX_WideStringArray wsSelTextArray; + int32_t iStart = 0; + int32_t iEnd = wsRawValue.Find(L'\n', iStart); + iEnd = (iEnd == -1) ? wsRawValue.GetLength() : iEnd; + while (iEnd >= iStart) { + wsSelTextArray.Add(wsRawValue.Mid(iStart, iEnd - iStart)); + iStart = iEnd + 1; + if (iStart >= wsRawValue.GetLength()) { + break; + } + iEnd = wsRawValue.Find(L'\n', iStart); + } + CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); + FXSYS_assert(pParentNode); + CXFA_Node* pGrandparentNode = + pParentNode->GetNodeItem(XFA_NODEITEM_Parent); + FXSYS_assert(pGrandparentNode); + CFX_WideString bodyTagName; + bodyTagName = pGrandparentNode->GetCData(XFA_ATTRIBUTE_Name); + if (bodyTagName.IsEmpty()) { + bodyTagName = FX_WSTRC(L"ListBox1"); + } + buf << FX_WSTRC(L"<"); + buf << bodyTagName; + 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]); + buf << FX_WSTRC(L"</value\n>"); + } + buf << FX_WSTRC(L"</"); + buf << bodyTagName; + buf << FX_WSTRC(L"\n>"); + wsChildren += buf.GetWideString(); + buf.Clear(); + } else { + CFX_WideStringC wsValue = pRawValueNode->GetCData(XFA_ATTRIBUTE_Value); + wsChildren += XFA_ExportEncodeContent(wsValue); + } + } break; + case XFA_OBJECTTYPE_TextNode: + case XFA_OBJECTTYPE_NodeC: + case XFA_OBJECTTYPE_NodeV: { + CFX_WideStringC wsValue = pNode->GetCData(XFA_ATTRIBUTE_Value); + wsChildren += XFA_ExportEncodeContent(wsValue); + } break; + default: + if (pNode->GetClassID() == XFA_ELEMENT_Items) { + CXFA_Node* pTemplateNode = pNode->GetTemplateNode(); + if (!pTemplateNode || + pTemplateNode->CountChildren(XFA_ELEMENT_UNKNOWN) != + pNode->CountChildren(XFA_ELEMENT_UNKNOWN)) { + bSaveXML = TRUE; + } + } + CFX_WideTextBuf newBuf; + CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChildNode) { + XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, + bSaveXML); + wsChildren += newBuf.GetWideString(); + newBuf.Clear(); + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + if (!bSaveXML && !wsChildren.IsEmpty() && + pNode->GetClassID() == XFA_ELEMENT_Items) { + wsChildren.Empty(); + bSaveXML = TRUE; + CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChildNode) { + XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, + bSaveXML); + wsChildren += newBuf.GetWideString(); + newBuf.Clear(); + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } + break; + } + if (!wsChildren.IsEmpty() || !wsAttrs.IsEmpty() || + pNode->HasAttribute(XFA_ATTRIBUTE_Name)) { + CFX_WideStringC wsElement; + pNode->GetClassName(wsElement); + CFX_WideString wsName; + XFA_SaveAttribute(pNode, XFA_ATTRIBUTE_Name, FX_WSTRC(L"name"), TRUE, + wsName); + buf << FX_WSTRC(L"<"); + buf << wsElement; + buf << wsName; + buf << wsAttrs; + if (wsChildren.IsEmpty()) { + buf << FX_WSTRC(L"\n/>"); + } else { + buf << FX_WSTRC(L"\n>"); + buf << wsChildren; + buf << FX_WSTRC(L"</"); + buf << wsElement; + buf << FX_WSTRC(L"\n>"); + } + } +} +static void XFA_DataExporter_RegenerateFormFile_Container( + CXFA_Node* pNode, + IFX_Stream* pStream, + FX_BOOL bSaveXML = FALSE) { + XFA_ELEMENT eElement = pNode->GetClassID(); + if (eElement == XFA_ELEMENT_Field || eElement == XFA_ELEMENT_Draw || + !pNode->IsContainerNode()) { + CFX_WideTextBuf buf; + XFA_DataExporter_RegenerateFormFile_Changed(pNode, buf, bSaveXML); + FX_STRSIZE nLen = buf.GetLength(); + if (nLen > 0) { + pStream->WriteString((const FX_WCHAR*)buf.GetBuffer(), nLen); + } + return; + } + CFX_WideStringC wsElement; + pNode->GetClassName(wsElement); + pStream->WriteString(L"<", 1); + pStream->WriteString(wsElement.GetPtr(), wsElement.GetLength()); + CFX_WideString wsOutput; + XFA_SaveAttribute(pNode, XFA_ATTRIBUTE_Name, FX_WSTRC(L"name"), TRUE, + wsOutput); + CFX_WideString wsAttrs; + int32_t iAttrs = 0; + const uint8_t* pAttrs = XFA_GetElementAttributes(pNode->GetClassID(), iAttrs); + while (iAttrs--) { + const XFA_ATTRIBUTEINFO* pAttr = + XFA_GetAttributeByID((XFA_ATTRIBUTE)pAttrs[iAttrs]); + if (pAttr->eName == XFA_ATTRIBUTE_Name) { + continue; + } + CFX_WideString wsAttr; + XFA_SaveAttribute(pNode, pAttr->eName, pAttr->pName, FALSE, wsAttr); + wsOutput += wsAttr; + } + if (!wsOutput.IsEmpty()) { + pStream->WriteString((const FX_WCHAR*)wsOutput, wsOutput.GetLength()); + } + CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildNode) { + pStream->WriteString(L"\n>", 2); + while (pChildNode) { + XFA_DataExporter_RegenerateFormFile_Container(pChildNode, pStream, + bSaveXML); + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + pStream->WriteString(L"</", 2); + pStream->WriteString(wsElement.GetPtr(), wsElement.GetLength()); + pStream->WriteString(L"\n>", 2); + } else { + pStream->WriteString(L"\n/>", 3); + } +} +void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, + IFX_Stream* pStream, + 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>"; + 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)); + pStream->WriteString(s_pwChecksum, FXSYS_wcslen(s_pwChecksum)); + pStream->WriteString((const FX_WCHAR*)wsChecksum, wsChecksum.GetLength()); + pStream->WriteString(L"\"", 1); + } + pStream->WriteString(L" xmlns=\"", FXSYS_wcslen(L" xmlns=\"")); + const FX_WCHAR* pURI = XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI; + pStream->WriteString(pURI, FXSYS_wcslen(pURI)); + CFX_WideString wsVersionNumber; + XFA_DataExporter_RecognizeXFAVersionNumber( + ToNode(pNode->GetDocument()->GetXFAObject(XFA_XDPPACKET_Template)), + wsVersionNumber); + if (wsVersionNumber.IsEmpty()) { + wsVersionNumber = FX_WSTRC(L"2.8"); + } + wsVersionNumber += FX_WSTRC(L"/\"\n>"); + pStream->WriteString((const FX_WCHAR*)wsVersionNumber, + wsVersionNumber.GetLength()); + CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChildNode) { + XFA_DataExporter_RegenerateFormFile_Container(pChildNode, pStream); + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + pStream->WriteString(s_pwsClose, FXSYS_wcslen(s_pwsClose)); + } else { + XFA_DataExporter_RegenerateFormFile_Container(pNode, pStream, bSaveXML); + } +} +IXFA_PacketExport* IXFA_PacketExport::Create(CXFA_Document* pDocument, + XFA_DATAFORMAT eFormat) { + return new CXFA_DataExporter(pDocument); +} +CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) + : m_pDocument(pDocument) { + ASSERT(m_pDocument); +} +FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite) { + return Export(pWrite, m_pDocument->GetRoot()); +} +FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite, + CXFA_Node* pNode, + FX_DWORD dwFlag, + const FX_CHAR* pChecksum) { + if (!pWrite) { + ASSERT(false); + return FALSE; + } + IFX_Stream* pStream = IFX_Stream::CreateStream( + pWrite, + FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); + if (pStream == NULL) { + return FALSE; + } + pStream->SetCodePage(FX_CODEPAGE_UTF8); + FX_BOOL bRet = Export(pStream, pNode, dwFlag, pChecksum); + pStream->Release(); + return bRet; +} +FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, + CXFA_Node* pNode, + FX_DWORD dwFlag, + const FX_CHAR* pChecksum) { + IFDE_XMLDoc* pXMLDoc = m_pDocument->GetParser()->GetXMLDoc(); + if (pNode->GetObjectType() == XFA_OBJECTTYPE_ModelNode) { + switch (pNode->GetPacketID()) { + case XFA_XDPPACKET_XDP: { + 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>"; + pStream->WriteString(s_pwsPostamble, FXSYS_wcslen(s_pwsPostamble)); + } break; + case XFA_XDPPACKET_Datasets: { + IFDE_XMLElement* pElement = + (IFDE_XMLElement*)pNode->GetXMLMappingNode(); + if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { + return FALSE; + } + CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + FXSYS_assert(pDataNode); + XFA_DataExporter_DealWithDataGroupNode(pDataNode); + pXMLDoc->SaveXMLNode(pStream, pElement); + } break; + case XFA_XDPPACKET_Form: { + XFA_DataExporter_RegenerateFormFile(pNode, pStream, pChecksum); + } break; + case XFA_XDPPACKET_Template: + default: { + IFDE_XMLElement* pElement = + (IFDE_XMLElement*)pNode->GetXMLMappingNode(); + if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { + return FALSE; + } + pXMLDoc->SaveXMLNode(pStream, pElement); + } break; + } + } else { + CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pExportNode = pNode; + for (CXFA_Node* pChildNode = + pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pChildNode != pNode) { + pExportNode = pDataNode; + break; + } + } + IFDE_XMLElement* pElement = + (IFDE_XMLElement*)pExportNode->GetXMLMappingNode(); + if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { + 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/")); + pXMLDoc->SaveXMLNode(pStream, pElement); + pElement->RemoveAttribute(L"xmlns:xfa"); + } + return TRUE; +} +void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { + if (!pDataNode || pDataNode->GetClassID() == XFA_ELEMENT_DataValue) { + return; + } + int32_t iChildNum = 0; + for (CXFA_Node* pChildNode = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + iChildNum++; + XFA_DataExporter_DealWithDataGroupNode(pChildNode); + } + if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) { + if (iChildNum > 0) { + IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + if (pXMLElement->HasAttribute(L"xfa:dataNode")) { + pXMLElement->RemoveAttribute(L"xfa:dataNode"); + } + } else { + IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); + ((IFDE_XMLElement*)pXMLNode) + ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); + } + } +} diff --git a/xfa/fxfa/parser/xfa_document_serialize.h b/xfa/fxfa/parser/xfa_document_serialize.h new file mode 100644 index 0000000000..f9253fb980 --- /dev/null +++ b/xfa/fxfa/parser/xfa_document_serialize.h @@ -0,0 +1,40 @@ +// 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_DOCUMENT_SERIALIZE_H_ +#define XFA_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_ + +#include "xfa/fxfa/parser/xfa_docdata.h" + +class CXFA_DataImporter : public IXFA_PacketImport { + public: + CXFA_DataImporter(CXFA_Document* pDocument); + virtual void Release() { delete this; } + virtual FX_BOOL ImportData(IFX_FileRead* pDataDocument); + + protected: + CXFA_Document* m_pDocument; +}; + +class CXFA_DataExporter : public IXFA_PacketExport { + public: + CXFA_DataExporter(CXFA_Document* pDocument); + virtual void Release() { delete this; } + virtual FX_BOOL Export(IFX_FileWrite* pWrite); + virtual FX_BOOL Export(IFX_FileWrite* pWrite, + CXFA_Node* pNode, + FX_DWORD dwFlag = 0, + const FX_CHAR* pChecksum = NULL); + + protected: + FX_BOOL Export(IFX_Stream* pStream, + CXFA_Node* pNode, + FX_DWORD dwFlag, + const FX_CHAR* pChecksum); + CXFA_Document* m_pDocument; +}; + +#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_ diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/fxfa/parser/xfa_layout_appadapter.cpp new file mode 100644 index 0000000000..3515dee1ee --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_appadapter.cpp @@ -0,0 +1,62 @@ +// 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/fxfa/parser/xfa_layout_appadapter.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" +#include "xfa/fxfa/parser/xfa_layout_itemlayout.h" +#include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" +#include "xfa/fxfa/parser/xfa_localemgr.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" + +FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) { + FX_DWORD 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; + IXFA_Notify* pNotify = + pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); + IXFA_DocLayout* pDocLayout = + pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); + while (pNode) { + CXFA_LayoutItem* pNext = pNode->m_pNextSibling; + pNode->m_pParent = nullptr; + pNotify->OnLayoutEvent(pDocLayout, static_cast<CXFA_LayoutItem*>(pNode), + XFA_LAYOUTEVENT_ItemRemoving); + XFA_ReleaseLayoutItem(pNode); + pNode = pNext; + } + pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, XFA_LAYOUTEVENT_ItemRemoving); + if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) { + pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), + XFA_PAGEEVENT_PageRemoved); + } + delete pLayoutItem; +} diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.h b/xfa/fxfa/parser/xfa_layout_appadapter.h new file mode 100644 index 0000000000..f20ee9b3fe --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_appadapter.h @@ -0,0 +1,77 @@ +// 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_LAYOUT_APPADAPTER_H_ +#define XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ + +#include "xfa/fxfa/parser/xfa_doclayout.h" + +class CXFA_TraverseStrategy_PageAreaContainerLayoutItem { + public: + static inline CXFA_ContainerLayoutItem* GetFirstChild( + CXFA_ContainerLayoutItem* pLayoutItem) { + if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) { + return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild; + } + return NULL; + } + static inline CXFA_ContainerLayoutItem* GetNextSibling( + CXFA_ContainerLayoutItem* pLayoutItem) { + return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling; + } + static inline CXFA_ContainerLayoutItem* GetParent( + CXFA_ContainerLayoutItem* pLayoutItem) { + return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + } +}; +class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { + public: + static inline CXFA_ContainerLayoutItem* GetFirstChild( + CXFA_ContainerLayoutItem* pLayoutItem) { + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + if (CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem()) { + return pContainer; + } + } + return nullptr; + } + static inline CXFA_ContainerLayoutItem* GetNextSibling( + CXFA_ContainerLayoutItem* pLayoutItem) { + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + if (CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem()) { + return pContainer; + } + } + return nullptr; + } + static inline CXFA_ContainerLayoutItem* GetParent( + CXFA_ContainerLayoutItem* pLayoutItem) { + return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + } +}; +class CXFA_TraverseStrategy_ContentLayoutItem { + public: + static inline CXFA_ContentLayoutItem* GetFirstChild( + CXFA_ContentLayoutItem* pLayoutItem) { + return (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; + } + static inline CXFA_ContentLayoutItem* GetNextSibling( + CXFA_ContentLayoutItem* pLayoutItem) { + return (CXFA_ContentLayoutItem*)pLayoutItem->m_pNextSibling; + } + static inline CXFA_ContentLayoutItem* GetParent( + CXFA_ContentLayoutItem* pLayoutItem) { + return (CXFA_ContentLayoutItem*)pLayoutItem->m_pParent; + } +}; +FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant); +void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); + +#endif // XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp new file mode 100644 index 0000000000..2924fad922 --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp @@ -0,0 +1,2968 @@ +// 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/fxfa/parser/xfa_layout_itemlayout.h" + +#include <algorithm> +#include <memory> + +#include "xfa/fgas/crt/fgas_algorithm.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" +#include "xfa/fxfa/parser/xfa_layout_appadapter.h" +#include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" +#include "xfa/fxfa/parser/xfa_localemgr.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" + +CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode, + CXFA_LayoutPageMgr* pPageMgr) + : m_bKeepBreakFinish(FALSE), + m_bIsProcessKeep(FALSE), + m_pKeepHeadNode(nullptr), + m_pKeepTailNode(nullptr), + m_pFormNode(pNode), + m_pLayoutItem(nullptr), + m_pOldLayoutItem(nullptr), + m_pCurChildNode(XFA_LAYOUT_INVALIDNODE), + m_pCurChildPreprocessor(nullptr), + m_nCurChildNodeStage(XFA_ItemLayoutProcessorStages_None), + m_fUsedSize(0), + m_pPageMgr(pPageMgr), + m_bBreakPending(TRUE), + m_fLastRowWidth(0), + m_fLastRowY(0), + m_fWidthLimite(0), + m_bUseInheriated(FALSE), + m_ePreProcessRs(XFA_ItemLayoutProcessorResult_Done), + m_bHasAvailHeight(TRUE) { + FXSYS_assert(m_pFormNode && (m_pFormNode->IsContainerNode() || + m_pFormNode->GetClassID() == XFA_ELEMENT_Form)); + m_pOldLayoutItem = + (CXFA_ContentLayoutItem*)m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY); +} +CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem( + CXFA_Node* pFormNode) { + if (!pFormNode) { + return NULL; + } + CXFA_ContentLayoutItem* pLayoutItem = NULL; + if (m_pOldLayoutItem) { + pLayoutItem = m_pOldLayoutItem; + m_pOldLayoutItem = m_pOldLayoutItem->m_pNext; + return pLayoutItem; + } + pLayoutItem = (CXFA_ContentLayoutItem*)pFormNode->GetDocument() + ->GetParser() + ->GetNotify() + ->OnCreateLayoutItem(pFormNode); + CXFA_ContentLayoutItem* pPrevLayoutItem = + (CXFA_ContentLayoutItem*)pFormNode->GetUserData(XFA_LAYOUTITEMKEY); + if (pPrevLayoutItem) { + while (pPrevLayoutItem->m_pNext) { + pPrevLayoutItem = pPrevLayoutItem->m_pNext; + } + pPrevLayoutItem->m_pNext = pLayoutItem; + pLayoutItem->m_pPrev = pPrevLayoutItem; + } else { + pFormNode->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem); + } + return pLayoutItem; +} +FX_BOOL CXFA_ItemLayoutProcessor::FindLayoutItemSplitPos( + CXFA_ContentLayoutItem* pLayoutItem, + FX_FLOAT fCurVerticalOffset, + FX_FLOAT& fProposedSplitPos, + FX_BOOL& bAppChange, + FX_BOOL bCalculateMargin) { + CXFA_Node* pFormNode = pLayoutItem->m_pFormNode; + if (fProposedSplitPos > fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION && + fProposedSplitPos <= fCurVerticalOffset + pLayoutItem->m_sSize.y - + XFA_LAYOUT_FLOAT_PERCISION) { + switch (pFormNode->GetIntact()) { + case XFA_ATTRIBUTEENUM_None: { + FX_BOOL bAnyChanged = FALSE; + CXFA_Document* pDocument = pFormNode->GetDocument(); + IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); + FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; + CXFA_Node* pMarginNode = + pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + if (pMarginNode && bCalculateMargin) { + fCurTopMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) + .ToUnit(XFA_UNIT_Pt); + fCurBottomMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset) + .ToUnit(XFA_UNIT_Pt); + } + FX_BOOL bChanged = TRUE; + while (bChanged) { + bChanged = FALSE; + { + FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurVerticalOffset; + if (pNotify->FindSplitPos(pFormNode, pLayoutItem->GetIndex(), + fRelSplitPos)) { + bAnyChanged = TRUE; + bChanged = TRUE; + fProposedSplitPos = fCurVerticalOffset + fRelSplitPos; + bAppChange = TRUE; + if (fProposedSplitPos <= + fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { + return TRUE; + } + } + } + FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurBottomMargin; + for (CXFA_ContentLayoutItem* pChildItem = + (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; + pChildItem; + pChildItem = + (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { + FX_FLOAT fChildOffset = + fCurVerticalOffset + fCurTopMargin + pChildItem->m_sPos.y; + FX_BOOL bAppChange = FALSE; + if (FindLayoutItemSplitPos(pChildItem, fChildOffset, fRelSplitPos, + bAppChange, bCalculateMargin)) { + if (fRelSplitPos - fChildOffset < XFA_LAYOUT_FLOAT_PERCISION && + bAppChange) { + fProposedSplitPos = fRelSplitPos - fCurTopMargin; + } else { + fProposedSplitPos = fRelSplitPos + fCurBottomMargin; + } + bAnyChanged = TRUE; + bChanged = TRUE; + if (fProposedSplitPos <= + fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { + return TRUE; + } + if (bAnyChanged) { + break; + } + } + } + } + return bAnyChanged; + } break; + case XFA_ATTRIBUTEENUM_ContentArea: + case XFA_ATTRIBUTEENUM_PageArea: { + fProposedSplitPos = fCurVerticalOffset; + return TRUE; + } + default: + return FALSE; + } + } + return FALSE; +} +static XFA_ATTRIBUTEENUM XFA_ItemLayoutProcessor_GetLayout( + CXFA_Node* pFormNode, + FX_BOOL& bRootForceTb) { + bRootForceTb = FALSE; + XFA_ATTRIBUTEENUM eLayoutMode; + if (pFormNode->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, FALSE)) { + return eLayoutMode; + } + CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Form) { + bRootForceTb = TRUE; + return XFA_ATTRIBUTEENUM_Tb; + } + return XFA_ATTRIBUTEENUM_Position; +} +static FX_BOOL XFA_ExistContainerKeep(CXFA_Node* pCurNode, FX_BOOL bPreFind) { + if (pCurNode == NULL || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode)) { + return FALSE; + } + XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling; + if (!bPreFind) { + eItemType = XFA_NODEITEM_NextSibling; + } + CXFA_Node* pPreContainer = + pCurNode->GetNodeItem(eItemType, XFA_OBJECTTYPE_ContainerNode); + if (pPreContainer == NULL) { + return FALSE; + } + CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Keep); + if (pKeep) { + XFA_ATTRIBUTEENUM ePrevious; + XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Previous; + if (!bPreFind) { + eKeepType = XFA_ATTRIBUTE_Next; + } + if (pKeep->TryEnum(eKeepType, ePrevious, FALSE)) { + if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea || + ePrevious == XFA_ATTRIBUTEENUM_PageArea) { + return TRUE; + } + } + } + pKeep = pPreContainer->GetFirstChildByClass(XFA_ELEMENT_Keep); + if (!pKeep) { + return FALSE; + } + XFA_ATTRIBUTEENUM eNext; + XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Next; + if (!bPreFind) { + eKeepType = XFA_ATTRIBUTE_Previous; + } + if (!pKeep->TryEnum(eKeepType, eNext, FALSE)) { + return FALSE; + } + if (eNext == XFA_ATTRIBUTEENUM_ContentArea || + eNext == XFA_ATTRIBUTEENUM_PageArea) { + return TRUE; + } + return FALSE; +} +FX_FLOAT CXFA_ItemLayoutProcessor::FindSplitPos(FX_FLOAT fProposedSplitPos) { + ASSERT(m_pLayoutItem); + XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + FX_BOOL bCalculateMargin = TRUE; + if (eLayout == XFA_ATTRIBUTEENUM_Position) { + bCalculateMargin = FALSE; + } + while (fProposedSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { + FX_BOOL bAppChange = FALSE; + if (!FindLayoutItemSplitPos(m_pLayoutItem, 0, fProposedSplitPos, bAppChange, + bCalculateMargin)) { + break; + } + } + return fProposedSplitPos; +} +void CXFA_ItemLayoutProcessor::SplitLayoutItem( + CXFA_ContentLayoutItem* pLayoutItem, + CXFA_ContentLayoutItem* pSecondParent, + FX_FLOAT fSplitPos) { + FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; + XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + FX_BOOL bCalculateMargin = TRUE; + if (eLayout == XFA_ATTRIBUTEENUM_Position) { + bCalculateMargin = FALSE; + } + CXFA_Node* pMarginNode = + pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + if (pMarginNode && bCalculateMargin) { + fCurTopMargin = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); + fCurBottomMargin = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); + } + CXFA_ContentLayoutItem* pSecondLayoutItem = NULL; + if (m_pCurChildPreprocessor && + m_pCurChildPreprocessor->m_pFormNode == pLayoutItem->m_pFormNode) { + pSecondLayoutItem = m_pCurChildPreprocessor->CreateContentLayoutItem( + pLayoutItem->m_pFormNode); + } else { + pSecondLayoutItem = CreateContentLayoutItem(pLayoutItem->m_pFormNode); + } + pSecondLayoutItem->m_sPos.x = pLayoutItem->m_sPos.x; + pSecondLayoutItem->m_sSize.x = pLayoutItem->m_sSize.x; + pSecondLayoutItem->m_sPos.y = 0; + pSecondLayoutItem->m_sSize.y = pLayoutItem->m_sSize.y - fSplitPos; + pLayoutItem->m_sSize.y -= pSecondLayoutItem->m_sSize.y; + if (pLayoutItem->m_pFirstChild) { + pSecondLayoutItem->m_sSize.y += fCurTopMargin; + } + if (pSecondParent) { + pSecondParent->AddChild(pSecondLayoutItem); + if (fCurTopMargin > 0 && pLayoutItem->m_pFirstChild) { + pSecondParent->m_sSize.y += fCurTopMargin; + CXFA_ContentLayoutItem* pParentItem = + (CXFA_ContentLayoutItem*)pSecondParent->m_pParent; + while (pParentItem) { + pParentItem->m_sSize.y += fCurTopMargin; + pParentItem = (CXFA_ContentLayoutItem*)pParentItem->m_pParent; + } + } + } else { + pSecondLayoutItem->m_pParent = pLayoutItem->m_pParent; + pSecondLayoutItem->m_pNextSibling = pLayoutItem->m_pNextSibling; + pLayoutItem->m_pNextSibling = pSecondLayoutItem; + } + CXFA_ContentLayoutItem* pChildren = + (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; + pLayoutItem->m_pFirstChild = NULL; + FX_FLOAT lHeightForKeep = 0; + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; + FX_FLOAT fAddMarginHeight = 0; + for (CXFA_ContentLayoutItem *pChildItem = pChildren, *pChildNext = NULL; + pChildItem; pChildItem = pChildNext) { + pChildNext = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling; + pChildItem->m_pNextSibling = NULL; + if (fSplitPos <= fCurTopMargin + pChildItem->m_sPos.y + fCurBottomMargin + + XFA_LAYOUT_FLOAT_PERCISION) { + if (!XFA_ExistContainerKeep(pChildItem->m_pFormNode, TRUE)) { + pChildItem->m_sPos.y -= fSplitPos - fCurBottomMargin; + pChildItem->m_sPos.y += lHeightForKeep; + pChildItem->m_sPos.y += fAddMarginHeight; + pSecondLayoutItem->AddChild(pChildItem); + } else { + if (lHeightForKeep < XFA_LAYOUT_FLOAT_PERCISION) { + for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); + iIndex++) { + CXFA_ContentLayoutItem* pPreItem = keepLayoutItems[iIndex]; + pLayoutItem->RemoveChild(pPreItem); + pPreItem->m_sPos.y -= fSplitPos; + if (pPreItem->m_sPos.y < 0) { + pPreItem->m_sPos.y = 0; + } + if (pPreItem->m_sPos.y + pPreItem->m_sSize.y > lHeightForKeep) { + pPreItem->m_sPos.y = lHeightForKeep; + lHeightForKeep += pPreItem->m_sSize.y; + pSecondLayoutItem->m_sSize.y += pPreItem->m_sSize.y; + if (pSecondParent) { + pSecondParent->m_sSize.y += pPreItem->m_sSize.y; + } + } + pSecondLayoutItem->AddChild(pPreItem); + } + } + pChildItem->m_sPos.y -= fSplitPos; + pChildItem->m_sPos.y += lHeightForKeep; + pChildItem->m_sPos.y += fAddMarginHeight; + pSecondLayoutItem->AddChild(pChildItem); + } + } else if (fSplitPos + XFA_LAYOUT_FLOAT_PERCISION >= + fCurTopMargin + fCurBottomMargin + pChildItem->m_sPos.y + + pChildItem->m_sSize.y) { + pLayoutItem->AddChild(pChildItem); + if (XFA_ExistContainerKeep(pChildItem->m_pFormNode, FALSE)) { + keepLayoutItems.Add(pChildItem); + } else { + keepLayoutItems.RemoveAll(); + } + } else { + FX_FLOAT fOldHeight = pSecondLayoutItem->m_sSize.y; + SplitLayoutItem( + pChildItem, pSecondLayoutItem, + fSplitPos - fCurTopMargin - fCurBottomMargin - pChildItem->m_sPos.y); + fAddMarginHeight = pSecondLayoutItem->m_sSize.y - fOldHeight; + pLayoutItem->AddChild(pChildItem); + } + } +} +void CXFA_ItemLayoutProcessor::SplitLayoutItem(FX_FLOAT fSplitPos) { + ASSERT(m_pLayoutItem); + SplitLayoutItem(m_pLayoutItem, NULL, fSplitPos); +} + +IXFA_LayoutPage* CXFA_LayoutItem::GetPage() const { + for (CXFA_LayoutItem* pCurNode = const_cast<CXFA_LayoutItem*>(this); pCurNode; + pCurNode = pCurNode->m_pParent) { + if (pCurNode->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) + return static_cast<CXFA_ContainerLayoutItem*>(pCurNode); + } + return nullptr; +} + +CXFA_Node* CXFA_LayoutItem::GetFormNode() const { + return m_pFormNode; +} + +void CXFA_LayoutItem::GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative) const { + ASSERT(m_bIsContentLayoutItem); + const CXFA_ContentLayoutItem* pThis = + static_cast<const CXFA_ContentLayoutItem*>(this); + CFX_PointF sPos = pThis->m_sPos; + CFX_SizeF sSize = pThis->m_sSize; + if (!bRelative) { + for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem; + pLayoutItem = pLayoutItem->m_pParent) { + if (CXFA_ContentLayoutItem* pContent = + pLayoutItem->AsContentLayoutItem()) { + sPos += pContent->m_sPos; + if (CXFA_Node* pMarginNode = + pLayoutItem->m_pFormNode->GetFirstChildByClass( + XFA_ELEMENT_Margin)) { + sPos += CFX_PointF(pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset) + .ToUnit(XFA_UNIT_Pt), + pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) + .ToUnit(XFA_UNIT_Pt)); + } + } else { + if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { + sPos += + CFX_PointF(pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_X) + .ToUnit(XFA_UNIT_Pt), + pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Y) + .ToUnit(XFA_UNIT_Pt)); + break; + } else if (pLayoutItem->m_pFormNode->GetClassID() == + XFA_ELEMENT_PageArea) { + break; + } + } + } + } + rtLayout.Set(sPos.x, sPos.y, sSize.x, sSize.y); +} + +CXFA_LayoutItem* CXFA_LayoutItem::GetParent() const { + return m_pParent; +} + +const CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() const { + ASSERT(m_bIsContentLayoutItem); + const CXFA_ContentLayoutItem* pCurNode = + static_cast<const CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pPrev) { + pCurNode = pCurNode->m_pPrev; + } + return pCurNode; +} + +CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() { + ASSERT(m_bIsContentLayoutItem); + CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pPrev) { + pCurNode = pCurNode->m_pPrev; + } + return pCurNode; +} + +CXFA_LayoutItem* CXFA_LayoutItem::GetLast() { + ASSERT(m_bIsContentLayoutItem); + CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pNext) { + pCurNode = pCurNode->m_pNext; + } + return pCurNode; +} + +const CXFA_LayoutItem* CXFA_LayoutItem::GetLast() const { + ASSERT(m_bIsContentLayoutItem); + const CXFA_ContentLayoutItem* pCurNode = + static_cast<const CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pNext) { + pCurNode = pCurNode->m_pNext; + } + return pCurNode; +} + +CXFA_LayoutItem* CXFA_LayoutItem::GetPrev() const { + ASSERT(m_bIsContentLayoutItem); + return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pPrev; +} + +CXFA_LayoutItem* CXFA_LayoutItem::GetNext() const { + ASSERT(m_bIsContentLayoutItem); + return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pNext; +} + +int32_t CXFA_LayoutItem::GetIndex() const { + ASSERT(m_bIsContentLayoutItem); + int32_t iIndex = 0; + const CXFA_ContentLayoutItem* pCurNode = + static_cast<const CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pPrev) { + pCurNode = pCurNode->m_pPrev; + ++iIndex; + } + return iIndex; +} + +int32_t CXFA_LayoutItem::GetCount() const { + ASSERT(m_bIsContentLayoutItem); + int32_t iCount = GetIndex() + 1; + const CXFA_ContentLayoutItem* pCurNode = + static_cast<const CXFA_ContentLayoutItem*>(this); + while (pCurNode->m_pNext) { + pCurNode = pCurNode->m_pNext; + iCount++; + } + return iCount; +} + +void CXFA_LayoutItem::AddChild(CXFA_LayoutItem* pChildItem) { + if (pChildItem->m_pParent) { + pChildItem->m_pParent->RemoveChild(pChildItem); + } + pChildItem->m_pParent = this; + if (m_pFirstChild == NULL) { + m_pFirstChild = pChildItem; + } else { + CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; + while (pExistingChildItem->m_pNextSibling) { + pExistingChildItem = pExistingChildItem->m_pNextSibling; + } + pExistingChildItem->m_pNextSibling = pChildItem; + } +} +void CXFA_LayoutItem::AddHeadChild(CXFA_LayoutItem* pChildItem) { + if (pChildItem->m_pParent) { + pChildItem->m_pParent->RemoveChild(pChildItem); + } + pChildItem->m_pParent = this; + if (m_pFirstChild == NULL) { + m_pFirstChild = pChildItem; + } else { + CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; + m_pFirstChild = pChildItem; + m_pFirstChild->m_pNextSibling = pExistingChildItem; + } +} +void CXFA_LayoutItem::InsertChild(CXFA_LayoutItem* pBeforeItem, + CXFA_LayoutItem* pChildItem) { + if (pBeforeItem->m_pParent != this) { + return; + } + if (pChildItem->m_pParent) { + pChildItem->m_pParent = NULL; + } + pChildItem->m_pParent = this; + CXFA_LayoutItem* pExistingChildItem = pBeforeItem->m_pNextSibling; + pBeforeItem->m_pNextSibling = pChildItem; + pChildItem->m_pNextSibling = pExistingChildItem; +} +void CXFA_LayoutItem::RemoveChild(CXFA_LayoutItem* pChildItem) { + if (pChildItem->m_pParent != this) { + return; + } + if (m_pFirstChild == pChildItem) { + m_pFirstChild = pChildItem->m_pNextSibling; + } else { + CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; + while (pExistingChildItem && + pExistingChildItem->m_pNextSibling != pChildItem) { + pExistingChildItem = pExistingChildItem->m_pNextSibling; + } + if (pExistingChildItem) { + pExistingChildItem->m_pNextSibling = pChildItem->m_pNextSibling; + } + } + pChildItem->m_pNextSibling = NULL; + pChildItem->m_pParent = NULL; +} +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; + } + IXFA_Notify* pNotify = + m_pOldLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); + IXFA_DocLayout* 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; + } + return pLayoutItem; +} +static FX_BOOL XFA_ItemLayoutProcessor_FindBreakNode( + CXFA_Node* pContainerNode, + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + FX_BOOL bBreakBefore) { + FX_BOOL bFindRs = FALSE; + for (CXFA_Node* pBreakNode = pContainerNode; pBreakNode; + pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ATTRIBUTE eAttributeType = XFA_ATTRIBUTE_Before; + if (!bBreakBefore) { + eAttributeType = XFA_ATTRIBUTE_After; + } + switch (pBreakNode->GetClassID()) { + case XFA_ELEMENT_BreakBefore: { + if (bBreakBefore) { + pCurActionNode = pBreakNode; + nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; + bFindRs = TRUE; + } + } break; + case XFA_ELEMENT_BreakAfter: { + if (!bBreakBefore) { + pCurActionNode = pBreakNode; + nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; + bFindRs = TRUE; + } + } break; + case XFA_ELEMENT_Break: + if (pBreakNode->GetEnum(eAttributeType) != XFA_ATTRIBUTEENUM_Auto) { + pCurActionNode = pBreakNode; + nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; + if (!bBreakBefore) { + nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; + } + bFindRs = TRUE; + break; + } + default: + break; + } + if (bFindRs) { + break; + } + } + return bFindRs; +} +static void XFA_DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { + IXFA_Notify* pNotify = pGenerateNode->GetDocument()->GetParser()->GetNotify(); + IXFA_DocLayout* pDocLayout = pGenerateNode->GetDocument()->GetDocLayout(); + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( + pGenerateNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + CXFA_ContentLayoutItem* pCurLayoutItem = + (CXFA_ContentLayoutItem*)pNode->GetUserData(XFA_LAYOUTITEMKEY); + CXFA_ContentLayoutItem* pNextLayoutItem = NULL; + while (pCurLayoutItem) { + pNextLayoutItem = pCurLayoutItem->m_pNext; + pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, + XFA_LAYOUTEVENT_ItemRemoving); + delete pCurLayoutItem; + pCurLayoutItem = pNextLayoutItem; + } + } + pGenerateNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pGenerateNode); +} +void CXFA_ItemLayoutProcessor::XFA_ItemLayoutProcessor_GotoNextContainerNode( + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node* pParentContainer, + FX_BOOL bUsePageBreak) { + CXFA_Node* pEntireContainer = pParentContainer; + CXFA_Node* pChildContainer = XFA_LAYOUT_INVALIDNODE; + switch (nCurStage) { + case XFA_ItemLayoutProcessorStages_BreakBefore: + case XFA_ItemLayoutProcessorStages_BreakAfter: { + pChildContainer = pCurActionNode->GetNodeItem(XFA_NODEITEM_Parent); + } break; + case XFA_ItemLayoutProcessorStages_Keep: + case XFA_ItemLayoutProcessorStages_Container: + pChildContainer = pCurActionNode; + break; + default: + pChildContainer = XFA_LAYOUT_INVALIDNODE; + break; + } + switch (nCurStage) { + case XFA_ItemLayoutProcessorStages_Keep: { + CXFA_Node* pBreakAfterNode = + pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!m_bKeepBreakFinish && + XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, + nCurStage, FALSE)) { + return; + } + goto CheckNextChildContainer; + } + case XFA_ItemLayoutProcessorStages_None: { + pCurActionNode = XFA_LAYOUT_INVALIDNODE; + case XFA_ItemLayoutProcessorStages_BookendLeader: + for (CXFA_Node* pBookendNode = + pCurActionNode == XFA_LAYOUT_INVALIDNODE + ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) + : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pBookendNode; pBookendNode = pBookendNode->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + switch (pBookendNode->GetClassID()) { + case XFA_ELEMENT_Bookend: + case XFA_ELEMENT_Break: + pCurActionNode = pBookendNode; + nCurStage = XFA_ItemLayoutProcessorStages_BookendLeader; + return; + default: + break; + } + } + } + { + pCurActionNode = XFA_LAYOUT_INVALIDNODE; + case XFA_ItemLayoutProcessorStages_BreakBefore: + if (pCurActionNode != XFA_LAYOUT_INVALIDNODE) { + CXFA_Node* pBreakBeforeNode = + pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); + if (!m_bKeepBreakFinish && + XFA_ItemLayoutProcessor_FindBreakNode( + pBreakBeforeNode, pCurActionNode, nCurStage, TRUE)) { + return; + } + if (m_bIsProcessKeep) { + if (ProcessKeepNodesForBreakBefore(pCurActionNode, nCurStage, + pChildContainer)) { + return; + } + goto CheckNextChildContainer; + } + pCurActionNode = pChildContainer; + nCurStage = XFA_ItemLayoutProcessorStages_Container; + return; + } + goto CheckNextChildContainer; + } + case XFA_ItemLayoutProcessorStages_Container: { + pCurActionNode = XFA_LAYOUT_INVALIDNODE; + case XFA_ItemLayoutProcessorStages_BreakAfter: { + if (pCurActionNode == XFA_LAYOUT_INVALIDNODE) { + CXFA_Node* pBreakAfterNode = + pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!m_bKeepBreakFinish && + XFA_ItemLayoutProcessor_FindBreakNode( + pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { + return; + } + } else { + CXFA_Node* pBreakAfterNode = + pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); + if (XFA_ItemLayoutProcessor_FindBreakNode( + pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { + return; + } + } + goto CheckNextChildContainer; + } + } + CheckNextChildContainer : { + CXFA_Node* pNextChildContainer = + pChildContainer == XFA_LAYOUT_INVALIDNODE + ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild, + XFA_OBJECTTYPE_ContainerNode) + : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_OBJECTTYPE_ContainerNode); + while (pNextChildContainer && + pNextChildContainer->HasFlag(XFA_NODEFLAG_LayoutGeneratedNode)) { + CXFA_Node* pSaveNode = pNextChildContainer; + pNextChildContainer = pNextChildContainer->GetNodeItem( + XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode); + if (pSaveNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { + XFA_DeleteLayoutGeneratedNode(pSaveNode); + } + } + if (!pNextChildContainer) { + goto NoMoreChildContainer; + } + FX_BOOL bLastKeep = FALSE; + if (ProcessKeepNodesForCheckNext(pCurActionNode, nCurStage, + pNextChildContainer, bLastKeep)) { + return; + } + if (!m_bKeepBreakFinish && !bLastKeep && + XFA_ItemLayoutProcessor_FindBreakNode( + pNextChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild), + pCurActionNode, nCurStage, TRUE)) { + return; + } + pCurActionNode = pNextChildContainer; + if (m_bIsProcessKeep) { + nCurStage = XFA_ItemLayoutProcessorStages_Keep; + } else { + nCurStage = XFA_ItemLayoutProcessorStages_Container; + } + return; + } + NoMoreChildContainer : { + pCurActionNode = XFA_LAYOUT_INVALIDNODE; + case XFA_ItemLayoutProcessorStages_BookendTrailer: + for (CXFA_Node* pBookendNode = + pCurActionNode == XFA_LAYOUT_INVALIDNODE + ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) + : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pBookendNode; pBookendNode = pBookendNode->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + switch (pBookendNode->GetClassID()) { + case XFA_ELEMENT_Bookend: + case XFA_ELEMENT_Break: + pCurActionNode = pBookendNode; + nCurStage = XFA_ItemLayoutProcessorStages_BookendTrailer; + return; + default: + break; + } + } + } + default: + pCurActionNode = NULL; + nCurStage = XFA_ItemLayoutProcessorStages_Done; + } +} +FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext( + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node*& pNextContainer, + FX_BOOL& bLastKeepNode) { + const bool bCanSplit = pNextContainer->GetIntact() == XFA_ATTRIBUTEENUM_None; + FX_BOOL bNextKeep = FALSE; + if (XFA_ExistContainerKeep(pNextContainer, FALSE)) { + bNextKeep = TRUE; + } + if (bNextKeep && !bCanSplit) { + if (!m_bIsProcessKeep && !m_bKeepBreakFinish) { + m_pKeepHeadNode = pNextContainer; + m_bIsProcessKeep = TRUE; + } + } else { + if (m_bIsProcessKeep && m_pKeepHeadNode) { + m_pKeepTailNode = pNextContainer; + if (!m_bKeepBreakFinish && + XFA_ItemLayoutProcessor_FindBreakNode( + pNextContainer->GetNodeItem(XFA_NODEITEM_FirstChild), + pCurActionNode, nCurStage, TRUE)) { + return TRUE; + } else { + pNextContainer = m_pKeepHeadNode; + m_bKeepBreakFinish = TRUE; + m_pKeepHeadNode = NULL; + m_pKeepTailNode = NULL; + m_bIsProcessKeep = FALSE; + } + } else { + if (m_bKeepBreakFinish) { + bLastKeepNode = TRUE; + } + m_bKeepBreakFinish = FALSE; + } + } + return FALSE; +} +FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore( + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node* pContainerNode) { + if (m_pKeepTailNode == pContainerNode) { + pCurActionNode = m_pKeepHeadNode; + m_bKeepBreakFinish = TRUE; + m_pKeepHeadNode = NULL; + m_pKeepTailNode = NULL; + m_bIsProcessKeep = FALSE; + nCurStage = XFA_ItemLayoutProcessorStages_Container; + return TRUE; + } + CXFA_Node* pBreakAfterNode = + pContainerNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, + nCurStage, FALSE)) { + return TRUE; + } + return FALSE; +} +FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode) { + XFA_ATTRIBUTEENUM ePresence = pNode->GetEnum(XFA_ATTRIBUTE_Presence); + return ePresence == XFA_ATTRIBUTEENUM_Visible || + ePresence == XFA_ATTRIBUTEENUM_Invisible; +} +static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( + CXFA_Node* pFormNode, + FX_FLOAT& fContainerWidth, + FX_FLOAT& fContainerHeight, + FX_BOOL& bContainerWidthAutoSize, + FX_BOOL& bContainerHeightAutoSize) { + fContainerWidth = 0; + fContainerHeight = 0; + bContainerWidthAutoSize = TRUE; + bContainerHeightAutoSize = TRUE; + XFA_ELEMENT eClassID = pFormNode->GetClassID(); + CXFA_Measurement mTmpValue; + if (bContainerWidthAutoSize && + (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && + pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && + mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { + fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); + bContainerWidthAutoSize = FALSE; + } + if (bContainerHeightAutoSize && + (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && + pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && + mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { + fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); + bContainerHeightAutoSize = FALSE; + } + if (bContainerWidthAutoSize && eClassID == XFA_ELEMENT_Subform && + pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && + mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { + fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); + bContainerWidthAutoSize = FALSE; + } + if (bContainerHeightAutoSize && eClassID == XFA_ELEMENT_Subform && + pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && + mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { + fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); + bContainerHeightAutoSize = FALSE; + } +} +static inline void +XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( + CXFA_Node* pFormNode, + FX_BOOL bContainerWidthAutoSize, + FX_FLOAT fContentCalculatedWidth, + FX_FLOAT& fContainerWidth, + FX_BOOL bContainerHeightAutoSize, + FX_FLOAT fContentCalculatedHeight, + FX_FLOAT& fContainerHeight) { + CXFA_Node* pMarginNode = pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + CXFA_Measurement mTmpValue; + if (bContainerWidthAutoSize) { + fContainerWidth = fContentCalculatedWidth; + if (pMarginNode) { + if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_LeftInset, mTmpValue, FALSE)) { + fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); + } + if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_RightInset, mTmpValue, FALSE)) { + fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); + } + } + } + if (bContainerHeightAutoSize) { + fContainerHeight = fContentCalculatedHeight; + if (pMarginNode) { + if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_TopInset, mTmpValue, FALSE)) { + fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); + } + if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_BottomInset, mTmpValue, + FALSE)) { + fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); + } + } + } +} +void CXFA_ItemLayoutProcessor::CalculatePositionedContainerPos( + CXFA_Node* pNode, + FX_FLOAT fWidth, + FX_FLOAT fHeight, + FX_FLOAT& fAbsoluteX, + FX_FLOAT& fAbsoluteY) { + XFA_ATTRIBUTEENUM eAnchorType = pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); + int32_t nAnchorType = 0; + switch (eAnchorType) { + case XFA_ATTRIBUTEENUM_TopLeft: + nAnchorType = 0; + break; + case XFA_ATTRIBUTEENUM_TopCenter: + nAnchorType = 1; + break; + case XFA_ATTRIBUTEENUM_TopRight: + nAnchorType = 2; + break; + case XFA_ATTRIBUTEENUM_MiddleLeft: + nAnchorType = 3; + break; + case XFA_ATTRIBUTEENUM_MiddleCenter: + nAnchorType = 4; + break; + case XFA_ATTRIBUTEENUM_MiddleRight: + nAnchorType = 5; + break; + case XFA_ATTRIBUTEENUM_BottomLeft: + nAnchorType = 6; + break; + case XFA_ATTRIBUTEENUM_BottomCenter: + nAnchorType = 7; + break; + case XFA_ATTRIBUTEENUM_BottomRight: + nAnchorType = 8; + break; + default: + break; + } + static const uint8_t nNextPos[4][9] = {{0, 1, 2, 3, 4, 5, 6, 7, 8}, + {6, 3, 0, 7, 4, 1, 8, 5, 2}, + {8, 7, 6, 5, 4, 3, 2, 1, 0}, + {2, 5, 8, 1, 4, 7, 0, 3, 6}}; + + FX_FLOAT fAnchorX = pNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); + FX_FLOAT fAnchorY = pNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); + int32_t nRotate = + FXSYS_round(pNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); + nRotate = XFA_MapRotation(nRotate) / 90; + int32_t nAbsoluteAnchorType = nNextPos[nRotate][nAnchorType]; + fAbsoluteX = fAnchorX; + fAbsoluteY = fAnchorY; + switch (nAbsoluteAnchorType / 3) { + case 1: + fAbsoluteY -= fHeight / 2; + break; + case 2: + fAbsoluteY -= fHeight; + break; + default: + break; + } + switch (nAbsoluteAnchorType % 3) { + case 1: + fAbsoluteX -= fWidth / 2; + break; + case 2: + fAbsoluteX -= fWidth; + break; + default: + break; + } +} +FX_BOOL CXFA_ItemLayoutProcessor::IncrementRelayoutNode( + CXFA_LayoutProcessor* pLayoutProcessor, + CXFA_Node* pNode, + CXFA_Node* pParentNode) { + return FALSE; +} +void CXFA_ItemLayoutProcessor::DoLayoutPageArea( + CXFA_ContainerLayoutItem* pPageAreaLayoutItem) { + CXFA_Node* pFormNode = pPageAreaLayoutItem->m_pFormNode; + CXFA_Node* pCurChildNode = XFA_LAYOUT_INVALIDNODE; + XFA_ItemLayoutProcessorStages nCurChildNodeStage = + XFA_ItemLayoutProcessorStages_None; + CXFA_LayoutItem* pBeforeItem = NULL; + for (XFA_ItemLayoutProcessor_GotoNextContainerNode( + pCurChildNode, nCurChildNodeStage, pFormNode, FALSE); + pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( + pCurChildNode, nCurChildNodeStage, pFormNode, FALSE)) { + if (nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { + continue; + } + if (pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { + continue; + } + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(pCurChildNode, NULL); + pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); + if (!pProcessor->HasLayoutItem()) { + delete pProcessor; + continue; + } + FX_FLOAT fWidth, fHeight; + pProcessor->GetCurrentComponentSize(fWidth, fHeight); + FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; + CalculatePositionedContainerPos(pCurChildNode, fWidth, fHeight, fAbsoluteX, + fAbsoluteY); + pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); + CXFA_LayoutItem* pProcessItem = pProcessor->ExtractLayoutItem(); + if (pBeforeItem == NULL) { + pPageAreaLayoutItem->AddHeadChild(pProcessItem); + } else { + pPageAreaLayoutItem->InsertChild(pBeforeItem, pProcessItem); + } + pBeforeItem = pProcessItem; + delete pProcessor; + } + pBeforeItem = NULL; + CXFA_LayoutItem* pLayoutItem = pPageAreaLayoutItem->m_pFirstChild; + while (pLayoutItem) { + if (!pLayoutItem->IsContentLayoutItem() || + pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_Draw) { + pLayoutItem = pLayoutItem->m_pNextSibling; + continue; + } + if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_Draw) { + CXFA_LayoutItem* pNextLayoutItem = pLayoutItem->m_pNextSibling; + pPageAreaLayoutItem->RemoveChild(pLayoutItem); + if (pBeforeItem == NULL) { + pPageAreaLayoutItem->AddHeadChild(pLayoutItem); + } else { + pPageAreaLayoutItem->InsertChild(pBeforeItem, pLayoutItem); + } + pBeforeItem = pLayoutItem; + pLayoutItem = pNextLayoutItem; + } + } +} +void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer( + CXFA_LayoutContext* pContext) { + if (m_pLayoutItem) + return; + + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + FX_BOOL bIgnoreXY = (m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) != + XFA_ATTRIBUTEENUM_Position); + FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; + FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; + XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( + m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, + bContainerHeightAutoSize); + FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; + FX_FLOAT fHiddenContentCalculatedWidth = 0, + fHiddenContentCalculatedHeight = 0; + if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); + } + int32_t iColIndex = 0; + for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { + if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { + continue; + } + if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { + continue; + } + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); + if (pContext && pContext->m_prgSpecifiedColumnWidths) { + int32_t iColSpan = m_pCurChildNode->GetInteger(XFA_ATTRIBUTE_ColSpan); + if (iColSpan <= + pContext->m_prgSpecifiedColumnWidths->GetSize() - iColIndex) { + pContext->m_fCurColumnWidth = 0; + pContext->m_bCurColumnWidthAvaiable = TRUE; + if (iColSpan == -1) + iColSpan = pContext->m_prgSpecifiedColumnWidths->GetSize(); + for (int32_t i = 0; iColIndex + i < iColSpan; ++i) { + pContext->m_fCurColumnWidth += + pContext->m_prgSpecifiedColumnWidths->GetAt(iColIndex + i); + } + if (pContext->m_fCurColumnWidth == 0) + pContext->m_bCurColumnWidthAvaiable = FALSE; + iColIndex += iColSpan >= 0 ? iColSpan : 0; + } + } + pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, + pContext); + if (!pProcessor->HasLayoutItem()) { + delete pProcessor; + continue; + } + FX_FLOAT fWidth, fHeight; + pProcessor->GetCurrentComponentSize(fWidth, fHeight); + FX_BOOL bChangeParentSize = FALSE; + if (XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { + bChangeParentSize = TRUE; + } + FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; + if (!bIgnoreXY) { + CalculatePositionedContainerPos(m_pCurChildNode, fWidth, fHeight, + fAbsoluteX, fAbsoluteY); + } + pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); + if (bContainerWidthAutoSize) { + FX_FLOAT fChildSuppliedWidth = fAbsoluteX + fWidth; + if (bChangeParentSize) { + if (fContentCalculatedWidth < fChildSuppliedWidth) { + fContentCalculatedWidth = fChildSuppliedWidth; + } + } else { + if (fHiddenContentCalculatedWidth < fChildSuppliedWidth && + m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { + fHiddenContentCalculatedWidth = fChildSuppliedWidth; + } + } + } + if (bContainerHeightAutoSize) { + FX_FLOAT fChildSuppliedHeight = fAbsoluteY + fHeight; + if (bChangeParentSize) { + if (fContentCalculatedHeight < fChildSuppliedHeight) { + fContentCalculatedHeight = fChildSuppliedHeight; + } + } else { + if (fHiddenContentCalculatedHeight < fChildSuppliedHeight && + m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { + fHiddenContentCalculatedHeight = fChildSuppliedHeight; + } + } + } + m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); + delete pProcessor; + } + XFA_VERSION eVersion = m_pFormNode->GetDocument()->GetCurVersionMode(); + if (fContentCalculatedWidth == 0 && eVersion < XFA_VERSION_207) { + fContentCalculatedWidth = fHiddenContentCalculatedWidth; + } + if (fContentCalculatedHeight == 0 && eVersion < XFA_VERSION_207) { + fContentCalculatedHeight = fHiddenContentCalculatedHeight; + } + XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( + m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, + fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, + fContainerHeight); + SetCurrentComponentSize(fContainerWidth, fContainerHeight); +} +static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( + CXFA_ContentLayoutItem* pLayoutItem, + FX_FLOAT& fWidth, + FX_FLOAT& fHeight) { + CXFA_Node* pNode = pLayoutItem->m_pFormNode; + ASSERT(pNode); + XFA_ELEMENT eClassID = pNode->GetClassID(); + switch (eClassID) { + case XFA_ELEMENT_Subform: + case XFA_ELEMENT_Area: + case XFA_ELEMENT_ExclGroup: + case XFA_ELEMENT_SubformSet: { + if (fWidth < -XFA_LAYOUT_FLOAT_PERCISION) { + fWidth = pLayoutItem->m_sSize.x; + } + if (fHeight < -XFA_LAYOUT_FLOAT_PERCISION) { + fHeight = pLayoutItem->m_sSize.y; + } + break; + } + case XFA_ELEMENT_Draw: + case XFA_ELEMENT_Field: { + pNode->GetDocument()->GetParser()->GetNotify()->StartFieldDrawLayout( + pNode, fWidth, fHeight); + break; + } + default: + ASSERT(FALSE); + } +} +static inline void XFA_ItemLayoutProcessor_RelocateTableRowCells( + CXFA_ContentLayoutItem* pLayoutRow, + const CFX_ArrayTemplate<FX_FLOAT>& rgSpecifiedColumnWidths, + XFA_ATTRIBUTEENUM eLayout) { + FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; + FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; + XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( + pLayoutRow->m_pFormNode, fContainerWidth, fContainerHeight, + bContainerWidthAutoSize, bContainerHeightAutoSize); + CXFA_Node* pMarginNode = + pLayoutRow->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; + if (pMarginNode) { + fLeftInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); + fTopInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); + fRightInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); + fBottomInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); + } + FX_FLOAT fContentWidthLimit = + bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX + : fContainerWidth - fLeftInset - fRightInset; + FX_FLOAT fContentCurrentHeight = + pLayoutRow->m_sSize.y - fTopInset - fBottomInset; + FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; + FX_FLOAT fCurrentColX = 0; + int32_t nCurrentColIdx = 0; + FX_BOOL bMetWholeRowCell = FALSE; + for (CXFA_ContentLayoutItem* pLayoutChild = + (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; + pLayoutChild; + pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { + int32_t nOriginalColSpan = + pLayoutChild->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); + int32_t nColSpan = nOriginalColSpan; + FX_FLOAT fColSpanWidth = 0; + if (nColSpan == -1 || + nCurrentColIdx + nColSpan > rgSpecifiedColumnWidths.GetSize()) { + nColSpan = rgSpecifiedColumnWidths.GetSize() - nCurrentColIdx; + } + for (int32_t i = 0; i < nColSpan; i++) { + fColSpanWidth += rgSpecifiedColumnWidths[nCurrentColIdx + i]; + } + if (nColSpan != nOriginalColSpan) { + fColSpanWidth = bMetWholeRowCell ? 0 : std::max(fColSpanWidth, + pLayoutChild->m_sSize.y); + } + if (nOriginalColSpan == -1) { + bMetWholeRowCell = TRUE; + } + pLayoutChild->m_sPos = CFX_PointF(fCurrentColX, 0); + pLayoutChild->m_sSize.x = fColSpanWidth; + if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { + fCurrentColX += fColSpanWidth; + nCurrentColIdx += nColSpan; + FX_FLOAT fNewHeight = + bContainerHeightAutoSize ? -1 : fContentCurrentHeight; + XFA_ItemLayoutProcessor_UpdateWidgetSize(pLayoutChild, fColSpanWidth, + fNewHeight); + pLayoutChild->m_sSize.y = fNewHeight; + if (bContainerHeightAutoSize) { + FX_FLOAT fChildSuppliedHeight = pLayoutChild->m_sSize.y; + if (fContentCalculatedHeight < fChildSuppliedHeight) { + fContentCalculatedHeight = fChildSuppliedHeight; + } + } + } + } + if (bContainerHeightAutoSize) { + for (CXFA_ContentLayoutItem* pLayoutChild = + (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; + pLayoutChild; + pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { + XFA_ItemLayoutProcessor_UpdateWidgetSize( + pLayoutChild, pLayoutChild->m_sSize.x, fContentCalculatedHeight); + FX_FLOAT fOldChildHeight = pLayoutChild->m_sSize.y; + pLayoutChild->m_sSize.y = fContentCalculatedHeight; + CXFA_Node* pParaNode = + pLayoutChild->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Para); + if (pParaNode && pLayoutChild->m_pFirstChild) { + FX_FLOAT fOffHeight = fContentCalculatedHeight - fOldChildHeight; + XFA_ATTRIBUTEENUM eVType = pParaNode->GetEnum(XFA_ATTRIBUTE_VAlign); + switch (eVType) { + case XFA_ATTRIBUTEENUM_Middle: + fOffHeight = fOffHeight / 2; + break; + case XFA_ATTRIBUTEENUM_Bottom: + break; + case XFA_ATTRIBUTEENUM_Top: + default: + fOffHeight = 0; + break; + } + if (fOffHeight > 0) { + for (CXFA_ContentLayoutItem* pInnerLayoutChild = + (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild; + pInnerLayoutChild; + pInnerLayoutChild = + (CXFA_ContentLayoutItem*)pInnerLayoutChild->m_pNextSibling) { + pInnerLayoutChild->m_sPos.y += fOffHeight; + } + } + } + } + } + if (bContainerWidthAutoSize) { + FX_FLOAT fChildSuppliedWidth = fCurrentColX; + if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && + fContentWidthLimit > fChildSuppliedWidth) { + fChildSuppliedWidth = fContentWidthLimit; + } + if (fContentCalculatedWidth < fChildSuppliedWidth) { + fContentCalculatedWidth = fChildSuppliedWidth; + } + } else { + fContentCalculatedWidth = fContainerWidth - fLeftInset - fRightInset; + } + if (pLayoutRow->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) == + XFA_ATTRIBUTEENUM_Rl_row) { + for (CXFA_ContentLayoutItem* pLayoutChild = + (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; + pLayoutChild; + pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { + pLayoutChild->m_sPos.x = fContentCalculatedWidth - + pLayoutChild->m_sPos.x - pLayoutChild->m_sSize.x; + } + } + XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( + pLayoutRow->m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, + fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, + fContainerHeight); + pLayoutRow->m_sSize = CFX_SizeF(fContainerWidth, fContainerHeight); +} +void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) { + if (m_pLayoutItem) + return; + + if (pLayoutNode == NULL) { + pLayoutNode = m_pFormNode; + } + ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; + FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; + XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( + m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, + bContainerHeightAutoSize); + FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; + CXFA_Node* pMarginNode = + m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + FX_FLOAT fLeftInset = 0; + FX_FLOAT fRightInset = 0; + if (pMarginNode) { + fLeftInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); + fRightInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); + } + FX_FLOAT fContentWidthLimit = + bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX + : fContainerWidth - fLeftInset - fRightInset; + CFX_WideStringC wsColumnWidths; + if (pLayoutNode->TryCData(XFA_ATTRIBUTE_ColumnWidths, wsColumnWidths)) { + CFX_WideStringArray widths; + if (FX_SeparateStringW(wsColumnWidths.GetPtr(), wsColumnWidths.GetLength(), + L' ', widths) > 0) { + int32_t iCols = widths.GetSize(); + CFX_WideString wsWidth; + for (int32_t i = 0; i < iCols; i++) { + wsWidth = widths[i]; + wsWidth.TrimLeft(L' '); + if (!wsWidth.IsEmpty()) { + CXFA_Measurement measure(wsWidth); + m_rgSpecifiedColumnWidths.Add(measure.ToUnit(XFA_UNIT_Pt)); + } + } + } + } + int32_t iSpecifiedColumnCount = m_rgSpecifiedColumnWidths.GetSize(); + CXFA_LayoutContext layoutContext; + layoutContext.m_prgSpecifiedColumnWidths = &m_rgSpecifiedColumnWidths; + CXFA_LayoutContext* pLayoutContext = + iSpecifiedColumnCount > 0 ? &layoutContext : NULL; + if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); + } + for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { + layoutContext.m_bCurColumnWidthAvaiable = FALSE; + layoutContext.m_fCurColumnWidth = 0; + if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { + continue; + } + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); + pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, + pLayoutContext); + if (!pProcessor->HasLayoutItem()) { + delete pProcessor; + continue; + } + m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); + delete pProcessor; + } + int32_t iRowCount = 0, iColCount = 0; + { + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgRowItems; + CFX_ArrayTemplate<int32_t> rgRowItemsSpan; + CFX_ArrayTemplate<FX_FLOAT> rgRowItemsWidth; + for (CXFA_ContentLayoutItem* pLayoutChild = + (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; + pLayoutChild; + pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { + if (pLayoutChild->m_pFormNode->GetClassID() != XFA_ELEMENT_Subform) { + continue; + } + if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { + continue; + } + XFA_ATTRIBUTEENUM eLayout = + pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (eLayout != XFA_ATTRIBUTEENUM_Row && + eLayout != XFA_ATTRIBUTEENUM_Rl_row) { + continue; + } + if (CXFA_ContentLayoutItem* pRowLayoutCell = + (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild) { + rgRowItems.Add(pRowLayoutCell); + int32_t iColSpan = + pRowLayoutCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); + rgRowItemsSpan.Add(iColSpan); + rgRowItemsWidth.Add(pRowLayoutCell->m_sSize.x); + } + } + iRowCount = rgRowItems.GetSize(); + iColCount = 0; + FX_BOOL bMoreColumns = TRUE; + while (bMoreColumns) { + bMoreColumns = FALSE; + FX_BOOL bAutoCol = FALSE; + for (int32_t i = 0; i < iRowCount; i++) { + while (rgRowItems[i] && (rgRowItemsSpan[i] <= 0 || + !XFA_ItemLayoutProcessor_IsTakingSpace( + rgRowItems[i]->m_pFormNode))) { + CXFA_ContentLayoutItem* pNewCell = + (CXFA_ContentLayoutItem*)rgRowItems[i]->m_pNextSibling; + if (rgRowItemsSpan[i] < 0 && XFA_ItemLayoutProcessor_IsTakingSpace( + rgRowItems[i]->m_pFormNode)) { + pNewCell = NULL; + } + rgRowItems[i] = pNewCell; + rgRowItemsSpan[i] = + pNewCell + ? pNewCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan) + : 0; + rgRowItemsWidth[i] = pNewCell ? pNewCell->m_sSize.x : 0; + } + CXFA_ContentLayoutItem* pCell = rgRowItems[i]; + if (!pCell) { + continue; + } + bMoreColumns = TRUE; + if (rgRowItemsSpan[i] == 1) { + if (iColCount >= iSpecifiedColumnCount) { + for (int32_t j = 0, c = iColCount + 1 - + m_rgSpecifiedColumnWidths.GetSize(); + j < c; j++) { + m_rgSpecifiedColumnWidths.Add(0); + } + } + if (m_rgSpecifiedColumnWidths[iColCount] < + XFA_LAYOUT_FLOAT_PERCISION) { + bAutoCol = TRUE; + } + if (bAutoCol && + m_rgSpecifiedColumnWidths[iColCount] < rgRowItemsWidth[i]) { + m_rgSpecifiedColumnWidths[iColCount] = rgRowItemsWidth[i]; + } + } + } + if (bMoreColumns) { + FX_FLOAT fFinalColumnWidth = 0.0f; + if (iColCount < m_rgSpecifiedColumnWidths.GetSize()) + fFinalColumnWidth = m_rgSpecifiedColumnWidths[iColCount]; + for (int32_t i = 0; i < iRowCount; ++i) { + if (!rgRowItems[i]) + continue; + --rgRowItemsSpan[i]; + rgRowItemsWidth[i] -= fFinalColumnWidth; + } + ++iColCount; + } + } + } + FX_FLOAT fCurrentRowY = 0; + for (CXFA_ContentLayoutItem* pLayoutChild = + (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; + pLayoutChild; + pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { + if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { + continue; + } + if (pLayoutChild->m_pFormNode->GetClassID() == XFA_ELEMENT_Subform) { + XFA_ATTRIBUTEENUM eSubformLayout = + pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (eSubformLayout == XFA_ATTRIBUTEENUM_Row || + eSubformLayout == XFA_ATTRIBUTEENUM_Rl_row) { + XFA_ItemLayoutProcessor_RelocateTableRowCells( + pLayoutChild, m_rgSpecifiedColumnWidths, eSubformLayout); + } + } + pLayoutChild->m_sPos.y = fCurrentRowY; + if (bContainerWidthAutoSize) { + pLayoutChild->m_sPos.x = 0; + } else { + switch (pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { + case XFA_ATTRIBUTEENUM_Left: + default: + pLayoutChild->m_sPos.x = 0; + break; + case XFA_ATTRIBUTEENUM_Center: + pLayoutChild->m_sPos.x = + (fContentWidthLimit - pLayoutChild->m_sSize.x) / 2; + break; + case XFA_ATTRIBUTEENUM_Right: + pLayoutChild->m_sPos.x = fContentWidthLimit - pLayoutChild->m_sSize.x; + break; + } + } + if (bContainerWidthAutoSize) { + FX_FLOAT fChildSuppliedWidth = + pLayoutChild->m_sPos.x + pLayoutChild->m_sSize.x; + if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && + fContentWidthLimit > fChildSuppliedWidth) { + fChildSuppliedWidth = fContentWidthLimit; + } + if (fContentCalculatedWidth < fChildSuppliedWidth) { + fContentCalculatedWidth = fChildSuppliedWidth; + } + } + fCurrentRowY += pLayoutChild->m_sSize.y; + } + if (bContainerHeightAutoSize) { + FX_FLOAT fChildSuppliedHeight = fCurrentRowY; + if (fContentCalculatedHeight < fChildSuppliedHeight) { + fContentCalculatedHeight = fChildSuppliedHeight; + } + } + XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( + m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, + fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, + fContainerHeight); + SetCurrentComponentSize(fContainerWidth, fContainerHeight); +} +static uint8_t XFA_ItemLayoutProcessor_HAlignEnumToInt( + XFA_ATTRIBUTEENUM eHAlign) { + switch (eHAlign) { + case XFA_ATTRIBUTEENUM_Center: + return 1; + case XFA_ATTRIBUTEENUM_Right: + return 2; + case XFA_ATTRIBUTEENUM_Left: + default: + return 0; + } +} +static void XFA_ItemLayoutProcessor_UpdatePendedItemLayout( + CXFA_ItemLayoutProcessor* pProcessor, + CXFA_ContentLayoutItem* pLayoutItem) { + XFA_ATTRIBUTEENUM eLayout = + pLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + switch (eLayout) { + case XFA_ATTRIBUTEENUM_Row: + case XFA_ATTRIBUTEENUM_Rl_row: + XFA_ItemLayoutProcessor_RelocateTableRowCells( + pLayoutItem, pProcessor->m_rgSpecifiedColumnWidths, eLayout); + break; + default: + break; + } +} +FX_BOOL CXFA_ItemLayoutProcessor::IsAddNewRowForTrailer( + CXFA_ContentLayoutItem* pTrailerItem) { + if (!pTrailerItem) { + return FALSE; + } + FX_FLOAT fWidth = pTrailerItem->m_sSize.x; + XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (eLayout != XFA_ATTRIBUTEENUM_Tb && m_fWidthLimite > fWidth) { + return FALSE; + } + return TRUE; +} +static void XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( + CXFA_ItemLayoutProcessor* pProcessor, + FX_FLOAT fSplitPos, + CXFA_ContentLayoutItem* pTrailerLayoutItem, + FX_BOOL bUseInherited = FALSE) { + if (!pTrailerLayoutItem) { + return; + } + FX_FLOAT fHeight = pTrailerLayoutItem->m_sSize.y; + if (bUseInherited) { + FX_FLOAT fNewSplitPos = 0; + if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { + fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); + } + if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { + pProcessor->SplitLayoutItem(fNewSplitPos); + } + return; + } + XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, + pTrailerLayoutItem); + CXFA_Node* pMarginNode = + pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; + if (pMarginNode) { + fLeftInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); + fTopInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); + fRightInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); + fBottomInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); + } + if (!pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem)) { + pTrailerLayoutItem->m_sPos.y = pProcessor->m_fLastRowY; + pTrailerLayoutItem->m_sPos.x = pProcessor->m_fLastRowWidth; + pProcessor->m_pLayoutItem->m_sSize.x += pTrailerLayoutItem->m_sSize.x; + pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); + return; + } + FX_FLOAT fNewSplitPos = 0; + if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { + fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); + } + if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { + pProcessor->SplitLayoutItem(fNewSplitPos); + pTrailerLayoutItem->m_sPos.y = fNewSplitPos - fTopInset - fBottomInset; + } else { + pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset; + } + switch (pTrailerLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { + case XFA_ATTRIBUTEENUM_Left: + default: + pTrailerLayoutItem->m_sPos.x = fLeftInset; + break; + case XFA_ATTRIBUTEENUM_Right: + pTrailerLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - + fRightInset - + pTrailerLayoutItem->m_sSize.x; + break; + case XFA_ATTRIBUTEENUM_Center: + pTrailerLayoutItem->m_sPos.x = + (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - + pTrailerLayoutItem->m_sSize.x) / + 2; + break; + } + pProcessor->m_pLayoutItem->m_sSize.y += fHeight; + pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); +} +static void XFA_ItemLayoutProcessor_AddLeaderAfterSplit( + CXFA_ItemLayoutProcessor* pProcessor, + CXFA_ContentLayoutItem* pLeaderLayoutItem) { + XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, pLeaderLayoutItem); + CXFA_Node* pMarginNode = + pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + FX_FLOAT fLeftInset = 0; + FX_FLOAT fRightInset = 0; + if (pMarginNode) { + fLeftInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); + fRightInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); + } + FX_FLOAT fHeight = pLeaderLayoutItem->m_sSize.y; + for (CXFA_ContentLayoutItem* pChildItem = + (CXFA_ContentLayoutItem*)pProcessor->m_pLayoutItem->m_pFirstChild; + pChildItem; + pChildItem = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { + pChildItem->m_sPos.y += fHeight; + } + pLeaderLayoutItem->m_sPos.y = 0; + switch (pLeaderLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { + case XFA_ATTRIBUTEENUM_Left: + default: + pLeaderLayoutItem->m_sPos.x = fLeftInset; + break; + case XFA_ATTRIBUTEENUM_Right: + pLeaderLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - + fRightInset - pLeaderLayoutItem->m_sSize.x; + break; + case XFA_ATTRIBUTEENUM_Center: + pLeaderLayoutItem->m_sPos.x = + (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - + pLeaderLayoutItem->m_sSize.x) / + 2; + break; + } + pProcessor->m_pLayoutItem->m_sSize.y += fHeight; + pProcessor->m_pLayoutItem->AddChild(pLeaderLayoutItem); +} +static void XFA_ItemLayoutProcessor_AddPendingNode( + CXFA_ItemLayoutProcessor* pProcessor, + CXFA_Node* pPendingNode, + FX_BOOL bBreakPending) { + pProcessor->m_PendingNodes.push_back(pPendingNode); + pProcessor->m_bBreakPending = bBreakPending; +} +static FX_FLOAT XFA_ItemLayoutProcessor_InsertPendingItems( + CXFA_ItemLayoutProcessor* pProcessor, + CXFA_Node* pCurChildNode) { + FX_FLOAT fTotalHeight = 0; + if (pProcessor->m_PendingNodes.empty()) { + return fTotalHeight; + } + if (!pProcessor->m_pLayoutItem) { + pProcessor->m_pLayoutItem = + pProcessor->CreateContentLayoutItem(pCurChildNode); + pProcessor->m_pLayoutItem->m_sSize.clear(); + } + while (!pProcessor->m_PendingNodes.empty()) { + std::unique_ptr<CXFA_ItemLayoutProcessor> pPendingProcessor( + new CXFA_ItemLayoutProcessor(pProcessor->m_PendingNodes.front(), + nullptr)); + pProcessor->m_PendingNodes.pop_front(); + pPendingProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); + CXFA_ContentLayoutItem* pPendingLayoutItem = + pPendingProcessor->HasLayoutItem() + ? pPendingProcessor->ExtractLayoutItem() + : nullptr; + if (pPendingLayoutItem) { + XFA_ItemLayoutProcessor_AddLeaderAfterSplit(pProcessor, + pPendingLayoutItem); + if (pProcessor->m_bBreakPending) { + fTotalHeight += pPendingLayoutItem->m_sSize.y; + } + } + } + return fTotalHeight; +} +FX_FLOAT CXFA_ItemLayoutProcessor::InsertKeepLayoutItems() { + FX_FLOAT fTotalHeight = 0; + if (m_arrayKeepItems.GetSize()) { + if (!m_pLayoutItem) { + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + m_pLayoutItem->m_sSize.clear(); + } + for (int32_t iIndex = m_arrayKeepItems.GetSize() - 1; iIndex >= 0; + iIndex--) { + XFA_ItemLayoutProcessor_AddLeaderAfterSplit(this, + m_arrayKeepItems[iIndex]); + fTotalHeight += m_arrayKeepItems[iIndex]->m_sSize.y; + } + m_arrayKeepItems.RemoveAll(); + } + return fTotalHeight; +} +FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepForSplite( + CXFA_ItemLayoutProcessor* pParentProcessor, + CXFA_ItemLayoutProcessor* pChildProcessor, + XFA_ItemLayoutProcessorResult eRetValue, + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, + FX_FLOAT& fContentCurRowAvailWidth, + FX_FLOAT& fContentCurRowHeight, + FX_FLOAT& fContentCurRowY, + FX_BOOL& bAddedItemInRow, + FX_BOOL& bForceEndPage, + XFA_ItemLayoutProcessorResult& result) { + if (pParentProcessor == NULL || pChildProcessor == NULL) { + return FALSE; + } + if (pParentProcessor->m_pCurChildNode->GetIntact() != + XFA_ATTRIBUTEENUM_None || + !pChildProcessor->m_bHasAvailHeight) { + if (XFA_ExistContainerKeep(pParentProcessor->m_pCurChildNode, TRUE)) { + FX_FLOAT fChildWidth, fChildHeight; + pChildProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; + if (pParentProcessor->JudgePutNextPage(pParentProcessor->m_pLayoutItem, + fChildHeight, keepLayoutItems)) { + m_arrayKeepItems.RemoveAll(); + for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); iIndex++) { + CXFA_ContentLayoutItem* pItem = keepLayoutItems.GetAt(iIndex); + pParentProcessor->m_pLayoutItem->RemoveChild(pItem); + fContentCurRowY -= pItem->m_sSize.y; + m_arrayKeepItems.Add(pItem); + } + bAddedItemInRow = TRUE; + bForceEndPage = TRUE; + result = XFA_ItemLayoutProcessorResult_PageFullBreak; + return TRUE; + } + rgCurLineLayoutItem.Add(pChildProcessor->ExtractLayoutItem()); + bAddedItemInRow = TRUE; + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + result = eRetValue; + return TRUE; + } + } + return FALSE; +} +FX_BOOL CXFA_ItemLayoutProcessor::JudgePutNextPage( + CXFA_ContentLayoutItem* pParentLayoutItem, + FX_FLOAT fChildHeight, + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems) { + if (pParentLayoutItem == NULL) { + return FALSE; + } + FX_FLOAT fItemsHeight = 0; + for (CXFA_ContentLayoutItem* pChildLayoutItem = + (CXFA_ContentLayoutItem*)pParentLayoutItem->m_pFirstChild; + pChildLayoutItem; + pChildLayoutItem = + (CXFA_ContentLayoutItem*)pChildLayoutItem->m_pNextSibling) { + if (XFA_ExistContainerKeep(pChildLayoutItem->m_pFormNode, FALSE)) { + pKeepItems.Add(pChildLayoutItem); + fItemsHeight += pChildLayoutItem->m_sSize.y; + } else { + pKeepItems.RemoveAll(); + fItemsHeight = 0; + } + } + fItemsHeight += fChildHeight; + if (m_pPageMgr->GetNextAvailContentHeight(fItemsHeight)) { + return TRUE; + } + return FALSE; +} +void CXFA_ItemLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) { + if (!pFormNode) { + return; + } + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( + pFormNode); + for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; + pNode = sIterator.MoveToNext()) { + if (pNode->IsContainerNode()) { + CXFA_Node* pBindNode = pNode->GetBindData(); + if (pBindNode) { + pBindNode->RemoveBindItem(pNode); + pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + } + } + pNode->SetFlag(XFA_NODEFLAG_UnusedNode); + } +} +void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( + CXFA_Node* pLeaderNode, + CXFA_Node* pTrailerNode, + CXFA_ContentLayoutItem* pTrailerItem, + CXFA_Node* pFormNode) { + ProcessUnUseBinds(pLeaderNode); + ProcessUnUseBinds(pTrailerNode); + if (pFormNode == NULL) { + return; + } + if (pFormNode->GetClassID() == XFA_ELEMENT_Overflow || + pFormNode->GetClassID() == XFA_ELEMENT_Break) { + pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); + } + if (pLeaderNode && pFormNode) { + pFormNode->RemoveChild(pLeaderNode); + } + if (pTrailerNode && pFormNode) { + pFormNode->RemoveChild(pTrailerNode); + } + if (pTrailerItem) { + XFA_ReleaseLayoutItem(pTrailerItem); + } +} +static XFA_ItemLayoutProcessorResult XFA_ItemLayoutProcessor_InsertFlowedItem( + CXFA_ItemLayoutProcessor* pThis, + CXFA_ItemLayoutProcessor*& pProcessor, + FX_BOOL bContainerWidthAutoSize, + FX_BOOL bContainerHeightAutoSize, + FX_FLOAT fContainerHeight, + XFA_ATTRIBUTEENUM eFlowStrategy, + uint8_t& uCurHAlignState, + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], + FX_BOOL bUseBreakControl, + FX_FLOAT fAvailHeight, + FX_FLOAT fRealHeight, + FX_FLOAT& fContentCurRowY, + FX_FLOAT& fContentWidthLimit, + FX_FLOAT& fContentCurRowAvailWidth, + FX_FLOAT& fContentCurRowHeight, + FX_BOOL& bAddedItemInRow, + FX_BOOL& bForceEndPage, + CXFA_LayoutContext* pLayoutContext = NULL, + FX_BOOL bNewRow = FALSE) { + FX_BOOL bTakeSpace = + XFA_ItemLayoutProcessor_IsTakingSpace(pProcessor->m_pFormNode); + uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( + pThis->m_pCurChildNode->GetEnum(XFA_ATTRIBUTE_HAlign)); + if (bContainerWidthAutoSize) { + uHAlign = 0; + } + if ((eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb && uHAlign < uCurHAlignState) || + (eFlowStrategy == XFA_ATTRIBUTEENUM_Rl_tb && uHAlign > uCurHAlignState)) { + return XFA_ItemLayoutProcessorResult_RowFullBreak; + } + uCurHAlignState = uHAlign; + FX_BOOL bIsOwnSplite = + pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None; + FX_BOOL bUseRealHeight = + bTakeSpace && bContainerHeightAutoSize && bIsOwnSplite && + pProcessor->m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetIntact() == + XFA_ATTRIBUTEENUM_None; + FX_BOOL bIsTransHeight = bTakeSpace; + if (bIsTransHeight && !bIsOwnSplite) { + FX_BOOL bRootForceTb = FALSE; + XFA_ATTRIBUTEENUM eLayoutStrategy = XFA_ItemLayoutProcessor_GetLayout( + pProcessor->m_pFormNode, bRootForceTb); + if (eLayoutStrategy == XFA_ATTRIBUTEENUM_Lr_tb || + eLayoutStrategy == XFA_ATTRIBUTEENUM_Rl_tb) { + bIsTransHeight = FALSE; + } + } + FX_BOOL bUseInherited = FALSE; + CXFA_LayoutContext layoutContext; + if (pThis->m_pPageMgr) { + CXFA_Node* pOverflowNode = + pThis->m_pPageMgr->QueryOverflow(pThis->m_pFormNode); + if (pOverflowNode) { + layoutContext.m_pOverflowNode = pOverflowNode; + layoutContext.m_pOverflowProcessor = pThis; + pLayoutContext = &layoutContext; + } + } + XFA_ItemLayoutProcessorResult eRetValue = XFA_ItemLayoutProcessorResult_Done; + if (!bNewRow || + pProcessor->m_ePreProcessRs == XFA_ItemLayoutProcessorResult_Done) { + eRetValue = pProcessor->DoLayout( + bTakeSpace ? bUseBreakControl : FALSE, + bUseRealHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, + bIsTransHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, + pLayoutContext); + pProcessor->m_ePreProcessRs = eRetValue; + } else { + eRetValue = pProcessor->m_ePreProcessRs; + pProcessor->m_ePreProcessRs = XFA_ItemLayoutProcessorResult_Done; + } + if (pProcessor->HasLayoutItem() == FALSE) { + return eRetValue; + } + FX_FLOAT fChildWidth, fChildHeight; + pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); + if (bUseRealHeight && fRealHeight < XFA_LAYOUT_FLOAT_PERCISION) { + fRealHeight = XFA_LAYOUT_FLOAT_MAX; + fAvailHeight = XFA_LAYOUT_FLOAT_MAX; + } + if (!bTakeSpace || + (fChildWidth <= fContentCurRowAvailWidth + XFA_LAYOUT_FLOAT_PERCISION) || + (fContentWidthLimit - fContentCurRowAvailWidth <= + XFA_LAYOUT_FLOAT_PERCISION)) { + CXFA_Node *pOverflowLeaderNode = NULL, *pOverflowTrailerNode = NULL, + *pFormNode = NULL; + CXFA_ContentLayoutItem* pTrailerLayoutItem = NULL; + FX_BOOL bIsAddTrailerHeight = FALSE; + if (pThis->m_pPageMgr && + pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { + pFormNode = pThis->m_pPageMgr->QueryOverflow(pProcessor->m_pFormNode); + if (pFormNode == NULL && pLayoutContext && + pLayoutContext->m_pOverflowProcessor) { + pFormNode = pLayoutContext->m_pOverflowNode; + bUseInherited = TRUE; + } + if (pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, + pOverflowTrailerNode, FALSE, + FALSE)) { + if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowTrailerNode)) { + if (pOverflowTrailerNode) { + CXFA_ItemLayoutProcessor* pOverflowLeaderProcessor = + new CXFA_ItemLayoutProcessor(pOverflowTrailerNode, NULL); + pOverflowLeaderProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); + pTrailerLayoutItem = + pOverflowLeaderProcessor->HasLayoutItem() + ? pOverflowLeaderProcessor->ExtractLayoutItem() + : NULL; + delete pOverflowLeaderProcessor; + } + if (bUseInherited) { + bIsAddTrailerHeight = + pThis->IsAddNewRowForTrailer(pTrailerLayoutItem); + } else { + bIsAddTrailerHeight = + pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem); + } + if (bIsAddTrailerHeight) { + FX_FLOAT fTrailerHeight = pTrailerLayoutItem->m_sSize.y; + fChildHeight += fTrailerHeight; + bIsAddTrailerHeight = TRUE; + } + } + } + } + if (!bTakeSpace || + fContentCurRowY + fChildHeight <= + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION || + (!bContainerHeightAutoSize && + pThis->m_fUsedSize + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION >= + fContainerHeight)) { + if (!bTakeSpace || eRetValue == XFA_ItemLayoutProcessorResult_Done) { + if (pProcessor->m_bUseInheriated) { + if (pTrailerLayoutItem) { + XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( + pProcessor, fChildHeight, pTrailerLayoutItem); + } + if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, + pOverflowLeaderNode, FALSE); + } + pProcessor->m_bUseInheriated = FALSE; + } else { + if (bIsAddTrailerHeight) { + fChildHeight -= pTrailerLayoutItem->m_sSize.y; + } + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + } + CXFA_ContentLayoutItem* pChildLayoutItem = + pProcessor->ExtractLayoutItem(); + if (XFA_ExistContainerKeep(pProcessor->m_pFormNode, FALSE) && + pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { + pThis->m_arrayKeepItems.Add(pChildLayoutItem); + } else { + pThis->m_arrayKeepItems.RemoveAll(); + } + rgCurLineLayoutItems[uHAlign].Add(pChildLayoutItem); + bAddedItemInRow = TRUE; + if (bTakeSpace) { + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + } + return XFA_ItemLayoutProcessorResult_Done; + } else { + if (eRetValue == XFA_ItemLayoutProcessorResult_PageFullBreak) { + if (pProcessor->m_bUseInheriated) { + if (pTrailerLayoutItem) { + XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( + pProcessor, fChildHeight, pTrailerLayoutItem); + } + if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode( + pProcessor, pOverflowLeaderNode, FALSE); + } + pProcessor->m_bUseInheriated = FALSE; + } else { + if (bIsAddTrailerHeight) { + fChildHeight -= pTrailerLayoutItem->m_sSize.y; + } + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + } + } + rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); + bAddedItemInRow = TRUE; + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + return eRetValue; + } + } else { + XFA_ItemLayoutProcessorResult eResult; + if (pThis->ProcessKeepForSplite( + pThis, pProcessor, eRetValue, rgCurLineLayoutItems[uHAlign], + fContentCurRowAvailWidth, fContentCurRowHeight, fContentCurRowY, + bAddedItemInRow, bForceEndPage, eResult)) { + return eResult; + } + bForceEndPage = TRUE; + FX_FLOAT fSplitPos = + pProcessor->FindSplitPos(fAvailHeight - fContentCurRowY); + if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { + XFA_ATTRIBUTEENUM eLayout = + pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (eLayout == XFA_ATTRIBUTEENUM_Tb && + eRetValue == XFA_ItemLayoutProcessorResult_Done) { + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); + bAddedItemInRow = TRUE; + if (bTakeSpace) { + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + } + return XFA_ItemLayoutProcessorResult_PageFullBreak; + } + CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; + if (pThis->m_pPageMgr && !pProcessor->m_bUseInheriated && + eRetValue != XFA_ItemLayoutProcessorResult_PageFullBreak) { + pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, + pTempTrailerNode, FALSE, TRUE); + } + if (pTrailerLayoutItem && bIsAddTrailerHeight) { + XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( + pProcessor, fSplitPos, pTrailerLayoutItem, bUseInherited); + } else { + pProcessor->SplitLayoutItem(fSplitPos); + } + if (bUseInherited) { + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + pThis->m_bUseInheriated = TRUE; + } else { + if (pProcessor->m_pLayoutItem->m_pFirstChild && + pProcessor->m_pLayoutItem->m_pFirstChild->m_pNextSibling == + NULL && + pProcessor->m_pLayoutItem->m_pFirstChild->m_pFormNode->HasFlag( + XFA_NODEFLAG_LayoutGeneratedNode)) { + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + } else { + if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode( + pProcessor, pOverflowLeaderNode, FALSE); + } + } + } + if (pProcessor->m_pLayoutItem->m_pNextSibling) { + pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); + rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); + bAddedItemInRow = TRUE; + if (bTakeSpace) { + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + } + } + return XFA_ItemLayoutProcessorResult_PageFullBreak; + } else if (fContentCurRowY <= XFA_LAYOUT_FLOAT_PERCISION) { + pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); + if (pProcessor->m_pPageMgr->GetNextAvailContentHeight(fChildHeight)) { + CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; + if (pThis->m_pPageMgr) { + if (pFormNode == NULL && pLayoutContext) { + pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; + } + pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, + pTempTrailerNode, FALSE, TRUE); + } + if (bUseInherited) { + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + pThis->m_bUseInheriated = TRUE; + } + return XFA_ItemLayoutProcessorResult_PageFullBreak; + } + rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); + bAddedItemInRow = TRUE; + if (bTakeSpace) { + fContentCurRowAvailWidth -= fChildWidth; + if (fContentCurRowHeight < fChildHeight) { + fContentCurRowHeight = fChildHeight; + } + } + if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { + bForceEndPage = FALSE; + } + return eRetValue; + } else { + XFA_ATTRIBUTEENUM eLayout = + pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None && + eLayout == XFA_ATTRIBUTEENUM_Tb) { + if (pThis->m_pPageMgr) { + pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, + pOverflowTrailerNode, FALSE, + TRUE); + } + if (pTrailerLayoutItem) { + XFA_ItemLayoutProcessor_AddTrailerBeforeSplit(pProcessor, fSplitPos, + pTrailerLayoutItem); + } + if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, + pOverflowLeaderNode, FALSE); + } + } else { + if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { + if (pFormNode == NULL && pLayoutContext) { + pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; + } + if (pThis->m_pPageMgr) { + pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, + pOverflowTrailerNode, FALSE, + TRUE); + } + if (bUseInherited) { + pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, + pOverflowTrailerNode, + pTrailerLayoutItem, pFormNode); + pThis->m_bUseInheriated = TRUE; + } + } + } + return XFA_ItemLayoutProcessorResult_PageFullBreak; + } + } + } else { + return XFA_ItemLayoutProcessorResult_RowFullBreak; + } + return XFA_ItemLayoutProcessorResult_Done; +} +XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( + FX_BOOL bUseBreakControl, + XFA_ATTRIBUTEENUM eFlowStrategy, + FX_FLOAT fHeightLimit, + FX_FLOAT fRealHeight, + CXFA_LayoutContext* pContext, + FX_BOOL bRootForceTb) { + m_bHasAvailHeight = TRUE; + FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; + FX_BOOL bBreakDone = FALSE; + FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; + FX_BOOL bForceEndPage = FALSE; + FX_BOOL bIsManualBreak = FALSE; + if (m_pCurChildPreprocessor) { + m_pCurChildPreprocessor->m_ePreProcessRs = + XFA_ItemLayoutProcessorResult_Done; + } + XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( + m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, + bContainerHeightAutoSize); + if (pContext && pContext->m_bCurColumnWidthAvaiable) { + bContainerWidthAutoSize = FALSE; + fContainerWidth = pContext->m_fCurColumnWidth; + } + if (!bContainerHeightAutoSize) { + fContainerHeight -= m_fUsedSize; + } + if (!bContainerHeightAutoSize) { + CXFA_Node* pParentNode = m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent); + FX_BOOL bFocrTb = FALSE; + if (pParentNode && + XFA_ItemLayoutProcessor_GetLayout(pParentNode, bFocrTb) == + XFA_ATTRIBUTEENUM_Row) { + CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem( + XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); + if (pChildContainer && + pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_OBJECTTYPE_ContainerNode)) { + fContainerHeight = 0; + bContainerHeightAutoSize = TRUE; + } + } + } + CXFA_Node* pMarginNode = + m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); + FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; + if (pMarginNode) { + fLeftInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); + fTopInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); + fRightInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); + fBottomInset = + pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); + } + FX_FLOAT fContentWidthLimit = + bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX + : fContainerWidth - fLeftInset - fRightInset; + FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; + FX_FLOAT fAvailHeight = fHeightLimit - fTopInset - fBottomInset; + if (fAvailHeight < 0) { + m_bHasAvailHeight = FALSE; + } + fRealHeight = fRealHeight - fTopInset - fBottomInset; + FX_FLOAT fContentCurRowY = 0; + CXFA_ContentLayoutItem* pLayoutChild = NULL; + if (m_pLayoutItem) { + if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done && + eFlowStrategy != XFA_ATTRIBUTEENUM_Tb) { + pLayoutChild = (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; + for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; + pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { + if (pLayoutNext->m_sPos.y != pLayoutChild->m_sPos.y) { + pLayoutChild = pLayoutNext; + } + } + } + for (CXFA_ContentLayoutItem* pLayoutTempChild = + (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; + pLayoutTempChild != pLayoutChild; + pLayoutTempChild = + (CXFA_ContentLayoutItem*)pLayoutTempChild->m_pNextSibling) { + if (XFA_ItemLayoutProcessor_IsTakingSpace( + pLayoutTempChild->m_pFormNode)) { + FX_FLOAT fChildContentWidth = + pLayoutTempChild->m_sPos.x + pLayoutTempChild->m_sSize.x; + FX_FLOAT fChildContentHeight = + pLayoutTempChild->m_sPos.y + pLayoutTempChild->m_sSize.y; + if (fContentCalculatedWidth < fChildContentWidth) { + fContentCalculatedWidth = fChildContentWidth; + } + if (fContentCalculatedHeight < fChildContentHeight) { + fContentCalculatedHeight = fChildContentHeight; + } + } + } + if (pLayoutChild) { + fContentCurRowY = pLayoutChild->m_sPos.y; + } else { + fContentCurRowY = fContentCalculatedHeight; + } + } + fContentCurRowY += InsertKeepLayoutItems(); + if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_None) { + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); + } + fContentCurRowY += + XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); + if (m_pCurChildPreprocessor && + m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Container) { + if (XFA_ExistContainerKeep(m_pCurChildPreprocessor->GetFormNode(), FALSE)) { + m_pKeepHeadNode = m_pCurChildNode; + m_bIsProcessKeep = TRUE; + m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Keep; + } + } + while (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done) { + FX_FLOAT fContentCurRowHeight = 0; + FX_FLOAT fContentCurRowAvailWidth = fContentWidthLimit; + m_fWidthLimite = fContentCurRowAvailWidth; + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgCurLineLayoutItems[3]; + uint8_t uCurHAlignState = + (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb ? 0 : 2); + if (pLayoutChild) { + for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; + pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { + if (pLayoutNext->m_pNextSibling == NULL && m_pCurChildPreprocessor && + m_pCurChildPreprocessor->m_pFormNode == pLayoutNext->m_pFormNode) { + pLayoutNext->m_pNext = m_pCurChildPreprocessor->m_pLayoutItem; + m_pCurChildPreprocessor->m_pLayoutItem = pLayoutNext; + break; + } + uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( + pLayoutNext->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)); + rgCurLineLayoutItems[uHAlign].Add(pLayoutNext); + if (eFlowStrategy == XFA_ATTRIBUTEENUM_Lr_tb) { + if (uHAlign > uCurHAlignState) { + uCurHAlignState = uHAlign; + } + } else if (uHAlign < uCurHAlignState) { + uCurHAlignState = uHAlign; + } + if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutNext->m_pFormNode)) { + if (pLayoutNext->m_sSize.y > fContentCurRowHeight) { + fContentCurRowHeight = pLayoutNext->m_sSize.y; + } + fContentCurRowAvailWidth -= pLayoutNext->m_sSize.x; + } + } + if ((CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild == + pLayoutChild) { + m_pLayoutItem->m_pFirstChild = NULL; + } else { + CXFA_ContentLayoutItem* pLayoutNext = + (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; + for (; pLayoutNext; + pLayoutNext = + (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { + if ((CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling == + pLayoutChild) { + pLayoutNext->m_pNextSibling = NULL; + break; + } + } + } + CXFA_ContentLayoutItem* pLayoutNextTemp = + (CXFA_ContentLayoutItem*)pLayoutChild; + while (pLayoutNextTemp) { + pLayoutNextTemp->m_pParent = NULL; + CXFA_ContentLayoutItem* pSaveLayoutNext = + (CXFA_ContentLayoutItem*)pLayoutNextTemp->m_pNextSibling; + pLayoutNextTemp->m_pNextSibling = NULL; + pLayoutNextTemp = pSaveLayoutNext; + } + pLayoutChild = NULL; + } + while (m_pCurChildNode) { + CXFA_ItemLayoutProcessor* pProcessor = NULL; + FX_BOOL bAddedItemInRow = FALSE; + fContentCurRowY += + XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); + switch (m_nCurChildNodeStage) { + case XFA_ItemLayoutProcessorStages_Keep: + case XFA_ItemLayoutProcessorStages_None: + break; + case XFA_ItemLayoutProcessorStages_BreakBefore: { + for (int32_t iIndex = 0; iIndex < m_arrayKeepItems.GetSize(); + iIndex++) { + CXFA_ContentLayoutItem* pItem = m_arrayKeepItems.GetAt(iIndex); + m_pLayoutItem->RemoveChild(pItem); + fContentCalculatedHeight -= pItem->m_sSize.y; + } + CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; + FX_BOOL bCreatePage = FALSE; + if (bUseBreakControl && m_pPageMgr && + m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, TRUE, + pLeaderNode, pTrailerNode, + bCreatePage) && + m_pFormNode->GetClassID() != XFA_ELEMENT_Form && bCreatePage) { + if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); + } + if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { + if (m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() == + XFA_ELEMENT_Form && + m_pLayoutItem == NULL) { + XFA_ItemLayoutProcessor_AddPendingNode(this, pTrailerNode, + TRUE); + } else { + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); + XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, FALSE, + XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext); + delete pProcessor; + pProcessor = NULL; + } + } + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); + bForceEndPage = TRUE; + bIsManualBreak = TRUE; + goto SuspendAndCreateNewRow; + } + } break; + case XFA_ItemLayoutProcessorStages_BreakAfter: { + CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; + FX_BOOL bCreatePage = FALSE; + if (bUseBreakControl && m_pPageMgr && + m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, FALSE, + pLeaderNode, pTrailerNode, + bCreatePage) && + m_pFormNode->GetClassID() != XFA_ELEMENT_Form) { + if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); + XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, FALSE, + XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext); + delete pProcessor; + pProcessor = NULL; + } + if (!bCreatePage) { + if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { + CalculateRowChildPosition( + rgCurLineLayoutItems, eFlowStrategy, + bContainerHeightAutoSize, bContainerWidthAutoSize, + fContentCalculatedWidth, fContentCalculatedHeight, + fContentCurRowY, fContentCurRowHeight, fContentWidthLimit); + rgCurLineLayoutItems->RemoveAll(); + CXFA_ItemLayoutProcessor* pProcessor = + new CXFA_ItemLayoutProcessor(pLeaderNode, NULL); + XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, FALSE, + XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext); + delete pProcessor; + pProcessor = NULL; + } + } else { + if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { + XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); + } + } + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); + if (bCreatePage) { + bForceEndPage = TRUE; + bIsManualBreak = TRUE; + if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done) { + bBreakDone = TRUE; + } + } + goto SuspendAndCreateNewRow; + } + } break; + case XFA_ItemLayoutProcessorStages_BookendLeader: { + CXFA_Node* pLeaderNode = NULL; + if (m_pCurChildPreprocessor) { + pProcessor = m_pCurChildPreprocessor; + m_pCurChildPreprocessor = NULL; + } else if (m_pPageMgr && + m_pPageMgr->ProcessBookendLeaderOrTrailer( + m_pCurChildNode, TRUE, pLeaderNode)) { + pProcessor = new CXFA_ItemLayoutProcessor(pLeaderNode, m_pPageMgr); + } + if (pProcessor) { + if (XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, + fAvailHeight, fRealHeight, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext) != XFA_ItemLayoutProcessorResult_Done) { + goto SuspendAndCreateNewRow; + } else { + delete pProcessor; + pProcessor = NULL; + } + } + } break; + case XFA_ItemLayoutProcessorStages_BookendTrailer: { + CXFA_Node* pTrailerNode = NULL; + if (m_pCurChildPreprocessor) { + pProcessor = m_pCurChildPreprocessor; + m_pCurChildPreprocessor = NULL; + } else if (m_pPageMgr && + m_pPageMgr->ProcessBookendLeaderOrTrailer( + m_pCurChildNode, FALSE, pTrailerNode)) { + pProcessor = new CXFA_ItemLayoutProcessor(pTrailerNode, m_pPageMgr); + } + if (pProcessor) { + if (XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, + fAvailHeight, fRealHeight, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext) != XFA_ItemLayoutProcessorResult_Done) { + goto SuspendAndCreateNewRow; + } else { + delete pProcessor; + pProcessor = NULL; + } + } + } break; + case XFA_ItemLayoutProcessorStages_Container: + ASSERT(m_pCurChildNode->IsContainerNode()); + if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { + break; + } + if (fContentCurRowY >= fHeightLimit + XFA_LAYOUT_FLOAT_PERCISION && + XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { + bForceEndPage = TRUE; + goto SuspendAndCreateNewRow; + } + if (m_pCurChildNode->IsContainerNode()) { + FX_BOOL bNewRow = FALSE; + if (m_pCurChildPreprocessor) { + pProcessor = m_pCurChildPreprocessor; + m_pCurChildPreprocessor = NULL; + bNewRow = TRUE; + } else { + pProcessor = + new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); + } + XFA_ItemLayoutProcessor_InsertPendingItems(pProcessor, + m_pCurChildNode); + XFA_ItemLayoutProcessorResult rs = + XFA_ItemLayoutProcessor_InsertFlowedItem( + this, pProcessor, bContainerWidthAutoSize, + bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, + uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, + fAvailHeight, fRealHeight, fContentCurRowY, + fContentWidthLimit, fContentCurRowAvailWidth, + fContentCurRowHeight, bAddedItemInRow, bForceEndPage, + pContext, bNewRow); + switch (rs) { + case XFA_ItemLayoutProcessorResult_ManualBreak: + bIsManualBreak = TRUE; + case XFA_ItemLayoutProcessorResult_PageFullBreak: + bForceEndPage = TRUE; + case XFA_ItemLayoutProcessorResult_RowFullBreak: + goto SuspendAndCreateNewRow; + case XFA_ItemLayoutProcessorResult_Done: + default: + fContentCurRowY += XFA_ItemLayoutProcessor_InsertPendingItems( + pProcessor, m_pCurChildNode); + delete pProcessor; + pProcessor = NULL; + } + } + break; + case XFA_ItemLayoutProcessorStages_Done: + break; + default: + break; + } + XFA_ItemLayoutProcessor_GotoNextContainerNode( + m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); + if (bAddedItemInRow && eFlowStrategy == XFA_ATTRIBUTEENUM_Tb) { + break; + } else { + continue; + } + SuspendAndCreateNewRow: + if (pProcessor) { + m_pCurChildPreprocessor = pProcessor; + } + break; + } + CalculateRowChildPosition(rgCurLineLayoutItems, eFlowStrategy, + bContainerHeightAutoSize, bContainerWidthAutoSize, + fContentCalculatedWidth, fContentCalculatedHeight, + fContentCurRowY, fContentCurRowHeight, + fContentWidthLimit, bRootForceTb); + m_fWidthLimite = fContentCurRowAvailWidth; + if (bForceEndPage) { + break; + } + } + FX_BOOL bRetValue = + m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done && + m_PendingNodes.empty(); + if (bBreakDone) { + bRetValue = FALSE; + } + XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( + m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, + fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, + fContainerHeight); + if (fContainerHeight >= XFA_LAYOUT_FLOAT_PERCISION || m_pLayoutItem || + bRetValue) { + if (m_pLayoutItem == NULL) { + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + } + if (fContainerHeight < 0) { + fContainerHeight = 0; + } + SetCurrentComponentSize(fContainerWidth, fContainerHeight); + if (bForceEndPage) { + m_fUsedSize = 0; + } else { + m_fUsedSize += m_pLayoutItem->m_sSize.y; + } + } + return bRetValue + ? XFA_ItemLayoutProcessorResult_Done + : (bIsManualBreak ? XFA_ItemLayoutProcessorResult_ManualBreak + : XFA_ItemLayoutProcessorResult_PageFullBreak); +} +FX_BOOL CXFA_ItemLayoutProcessor::CalculateRowChildPosition( + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], + XFA_ATTRIBUTEENUM eFlowStrategy, + FX_BOOL bContainerHeightAutoSize, + FX_BOOL bContainerWidthAutoSize, + FX_FLOAT& fContentCalculatedWidth, + FX_FLOAT& fContentCalculatedHeight, + FX_FLOAT& fContentCurRowY, + FX_FLOAT fContentCurRowHeight, + FX_FLOAT fContentWidthLimit, + FX_BOOL bRootForceTb) { + int32_t nGroupLengths[3] = {0, 0, 0}; + FX_FLOAT fGroupWidths[3] = {0, 0, 0}; + int32_t nTotalLength = 0; + for (int32_t i = 0; i < 3; i++) { + nGroupLengths[i] = rgCurLineLayoutItems[i].GetSize(); + for (int32_t c = nGroupLengths[i], j = 0; j < c; j++) { + nTotalLength++; + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[i][j]->m_pFormNode)) { + fGroupWidths[i] += rgCurLineLayoutItems[i][j]->m_sSize.x; + } + } + } + if (!nTotalLength) { + if (bContainerHeightAutoSize) { + FX_FLOAT fNewHeight = fContentCurRowY; + if (fContentCalculatedHeight > fNewHeight) { + fContentCalculatedHeight = fNewHeight; + } + } + return FALSE; + } + if (m_pLayoutItem == NULL) { + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + } + if (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb) { + FX_FLOAT fCurPos; + fCurPos = 0; + for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { + if (bRootForceTb) { + FX_FLOAT fAbsoluteX, fAbsoluteY; + CalculatePositionedContainerPos(rgCurLineLayoutItems[0][j]->m_pFormNode, + rgCurLineLayoutItems[0][j]->m_sSize.x, + rgCurLineLayoutItems[0][j]->m_sSize.y, + fAbsoluteX, fAbsoluteY); + rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); + } else { + rgCurLineLayoutItems[0][j]->m_sPos = + CFX_PointF(fCurPos, fContentCurRowY); + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[0][j]->m_pFormNode)) { + fCurPos += rgCurLineLayoutItems[0][j]->m_sSize.x; + } + } + m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); + m_fLastRowWidth = fCurPos; + } + fCurPos = (fContentWidthLimit + fGroupWidths[0] - fGroupWidths[1] - + fGroupWidths[2]) / + 2; + for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { + if (bRootForceTb) { + FX_FLOAT fAbsoluteX, fAbsoluteY; + CalculatePositionedContainerPos(rgCurLineLayoutItems[1][j]->m_pFormNode, + rgCurLineLayoutItems[1][j]->m_sSize.x, + rgCurLineLayoutItems[1][j]->m_sSize.y, + fAbsoluteX, fAbsoluteY); + rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); + } else { + rgCurLineLayoutItems[1][j]->m_sPos = + CFX_PointF(fCurPos, fContentCurRowY); + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[1][j]->m_pFormNode)) { + fCurPos += rgCurLineLayoutItems[1][j]->m_sSize.x; + } + } + m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); + m_fLastRowWidth = fCurPos; + } + fCurPos = fContentWidthLimit - fGroupWidths[2]; + for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { + if (bRootForceTb) { + FX_FLOAT fAbsoluteX, fAbsoluteY; + CalculatePositionedContainerPos(rgCurLineLayoutItems[2][j]->m_pFormNode, + rgCurLineLayoutItems[2][j]->m_sSize.x, + rgCurLineLayoutItems[2][j]->m_sSize.y, + fAbsoluteX, fAbsoluteY); + rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); + } else { + rgCurLineLayoutItems[2][j]->m_sPos = + CFX_PointF(fCurPos, fContentCurRowY); + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[2][j]->m_pFormNode)) { + fCurPos += rgCurLineLayoutItems[2][j]->m_sSize.x; + } + } + m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); + m_fLastRowWidth = fCurPos; + } + } else { + FX_FLOAT fCurPos; + fCurPos = fGroupWidths[0]; + for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[0][j]->m_pFormNode)) { + fCurPos -= rgCurLineLayoutItems[0][j]->m_sSize.x; + } + rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); + m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); + m_fLastRowWidth = fCurPos; + } + fCurPos = (fContentWidthLimit + fGroupWidths[0] + fGroupWidths[1] - + fGroupWidths[2]) / + 2; + for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[1][j]->m_pFormNode)) { + fCurPos -= rgCurLineLayoutItems[1][j]->m_sSize.x; + } + rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); + m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); + m_fLastRowWidth = fCurPos; + } + fCurPos = fContentWidthLimit; + for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { + if (XFA_ItemLayoutProcessor_IsTakingSpace( + rgCurLineLayoutItems[2][j]->m_pFormNode)) { + fCurPos -= rgCurLineLayoutItems[2][j]->m_sSize.x; + } + rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); + m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); + m_fLastRowWidth = fCurPos; + } + } + m_fLastRowY = fContentCurRowY; + fContentCurRowY += fContentCurRowHeight; + if (bContainerWidthAutoSize) { + FX_FLOAT fChildSuppliedWidth = fGroupWidths[0]; + if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && + fContentWidthLimit > fChildSuppliedWidth) { + fChildSuppliedWidth = fContentWidthLimit; + } + if (fContentCalculatedWidth < fChildSuppliedWidth) { + fContentCalculatedWidth = fChildSuppliedWidth; + } + } + if (bContainerHeightAutoSize) { + FX_FLOAT fChildSuppliedHeight = fContentCurRowY; + if (fContentCalculatedHeight < fChildSuppliedHeight) { + fContentCalculatedHeight = fChildSuppliedHeight; + } + } + return TRUE; +} +CXFA_Node* CXFA_ItemLayoutProcessor::GetSubformSetParent( + CXFA_Node* pSubformSet) { + if (pSubformSet && pSubformSet->GetClassID() == XFA_ELEMENT_SubformSet) { + CXFA_Node* pParent = pSubformSet->GetNodeItem(XFA_NODEITEM_Parent); + while (pParent) { + if (pParent->GetClassID() != XFA_ELEMENT_SubformSet) { + return pParent; + } + pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); + } + } + return pSubformSet; +} +void CXFA_ItemLayoutProcessor::DoLayoutField() { + if (m_pLayoutItem) + return; + + ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); + m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); + if (!m_pLayoutItem) { + return; + } + CXFA_Document* pDocument = m_pFormNode->GetDocument(); + IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); + FX_FLOAT fHeight = -1; + FX_FLOAT fWidth = -1; + pNotify->StartFieldDrawLayout(m_pFormNode, fWidth, fHeight); + int32_t nRotate = + FXSYS_round(m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); + nRotate = XFA_MapRotation(nRotate); + if (nRotate == 90 || nRotate == 270) { + FX_FLOAT fTmp = fWidth; + fWidth = fHeight; + fHeight = fTmp; + } + SetCurrentComponentSize(fWidth, fHeight); +} +XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( + FX_BOOL bUseBreakControl, + FX_FLOAT fHeightLimit, + FX_FLOAT fRealHeight, + CXFA_LayoutContext* pContext) { + XFA_ELEMENT eClassID = m_pFormNode->GetClassID(); + switch (eClassID) { + case XFA_ELEMENT_Subform: + case XFA_ELEMENT_Area: + case XFA_ELEMENT_ExclGroup: + case XFA_ELEMENT_SubformSet: { + FX_BOOL bRootForceTb = FALSE; + CXFA_Node* pLayoutNode = GetSubformSetParent(m_pFormNode); + XFA_ATTRIBUTEENUM eLayoutStrategy = + XFA_ItemLayoutProcessor_GetLayout(pLayoutNode, bRootForceTb); + switch (eLayoutStrategy) { + case XFA_ATTRIBUTEENUM_Tb: + case XFA_ATTRIBUTEENUM_Lr_tb: + case XFA_ATTRIBUTEENUM_Rl_tb: + return DoLayoutFlowedContainer(bUseBreakControl, eLayoutStrategy, + fHeightLimit, fRealHeight, pContext, + bRootForceTb); + case XFA_ATTRIBUTEENUM_Position: + case XFA_ATTRIBUTEENUM_Row: + case XFA_ATTRIBUTEENUM_Rl_row: + default: + DoLayoutPositionedContainer(pContext); + m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; + return XFA_ItemLayoutProcessorResult_Done; + case XFA_ATTRIBUTEENUM_Table: + DoLayoutTableContainer(pLayoutNode); + m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; + return XFA_ItemLayoutProcessorResult_Done; + } + } + case XFA_ELEMENT_Draw: + case XFA_ELEMENT_Field: + DoLayoutField(); + m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; + return XFA_ItemLayoutProcessorResult_Done; + case XFA_ELEMENT_ContentArea: + return XFA_ItemLayoutProcessorResult_Done; + default: + return XFA_ItemLayoutProcessorResult_Done; + } +} +void CXFA_ItemLayoutProcessor::GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, + FX_FLOAT& fAbsoluteY) { + ASSERT(m_pLayoutItem); + fAbsoluteX = m_pLayoutItem->m_sPos.x; + fAbsoluteY = m_pLayoutItem->m_sPos.y; +} +void CXFA_ItemLayoutProcessor::GetCurrentComponentSize(FX_FLOAT& fWidth, + FX_FLOAT& fHeight) { + ASSERT(m_pLayoutItem); + fWidth = m_pLayoutItem->m_sSize.x; + fHeight = m_pLayoutItem->m_sSize.y; +} +void CXFA_ItemLayoutProcessor::SetCurrentComponentPos(FX_FLOAT fAbsoluteX, + FX_FLOAT fAbsoluteY) { + m_pLayoutItem->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); +} +void CXFA_ItemLayoutProcessor::SetCurrentComponentSize(FX_FLOAT fWidth, + FX_FLOAT fHeight) { + m_pLayoutItem->m_sSize = CFX_SizeF(fWidth, fHeight); +} +FX_BOOL CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur( + CXFA_Node* pFormNode) { + if (pFormNode == NULL) { + return FALSE; + } + CXFA_Node* pTemplate = pFormNode->GetTemplateNode(); + if (!pTemplate) { + pTemplate = pFormNode; + } + CXFA_Occur NodeOccur(pTemplate->GetFirstChildByClass(XFA_ELEMENT_Occur)); + int32_t iMax = NodeOccur.GetMax(); + if (iMax > -1) { + int32_t iCount = + (int32_t)(uintptr_t)m_PendingNodesCount.GetValueAt(pTemplate); + if (iCount >= iMax) { + return FALSE; + } + iCount++; + m_PendingNodesCount.SetAt(pTemplate, (void*)(uintptr_t)(iCount)); + return TRUE; + } + return TRUE; +} diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.h b/xfa/fxfa/parser/xfa_layout_itemlayout.h new file mode 100644 index 0000000000..362e1c19fc --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.h @@ -0,0 +1,195 @@ +// 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_LAYOUT_ITEMLAYOUT_H_ +#define XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ + +#include <float.h> + +#include <list> + +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/fxfa/parser/xfa_doclayout.h" +#include "xfa/fxfa/parser/xfa_document_layout_imp.h" + +#define XFA_LAYOUT_INVALIDNODE ((CXFA_Node*)(intptr_t)-1) +#define XFA_LAYOUT_FLOAT_PERCISION (0.0005f) +#define XFA_LAYOUT_FLOAT_MAX FLT_MAX + +class CXFA_ContainerLayoutItem; +class CXFA_ContentLayoutItem; +class CXFA_ItemLayoutProcessor; +class CXFA_LayoutPageMgr; +class CXFA_Node; + +enum XFA_ItemLayoutProcessorResult { + XFA_ItemLayoutProcessorResult_Done, + XFA_ItemLayoutProcessorResult_PageFullBreak, + XFA_ItemLayoutProcessorResult_RowFullBreak, + XFA_ItemLayoutProcessorResult_ManualBreak, +}; + +enum XFA_ItemLayoutProcessorStages { + XFA_ItemLayoutProcessorStages_None, + XFA_ItemLayoutProcessorStages_BookendLeader, + XFA_ItemLayoutProcessorStages_BreakBefore, + XFA_ItemLayoutProcessorStages_Keep, + XFA_ItemLayoutProcessorStages_Container, + XFA_ItemLayoutProcessorStages_BreakAfter, + XFA_ItemLayoutProcessorStages_BookendTrailer, + XFA_ItemLayoutProcessorStages_Done, +}; + +class CXFA_LayoutContext { + public: + CXFA_LayoutContext() + : m_prgSpecifiedColumnWidths(NULL), + m_fCurColumnWidth(0), + m_bCurColumnWidthAvaiable(FALSE), + m_pOverflowProcessor(NULL), + m_pOverflowNode(NULL) {} + ~CXFA_LayoutContext() { m_pOverflowProcessor = NULL; } + CFX_ArrayTemplate<FX_FLOAT>* m_prgSpecifiedColumnWidths; + FX_FLOAT m_fCurColumnWidth; + FX_BOOL m_bCurColumnWidthAvaiable; + CXFA_ItemLayoutProcessor* m_pOverflowProcessor; + CXFA_Node* m_pOverflowNode; +}; + +class CXFA_ItemLayoutProcessor { + public: + CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr); + + XFA_ItemLayoutProcessorResult DoLayout( + FX_BOOL bUseBreakControl, + FX_FLOAT fHeightLimit, + FX_FLOAT fRealHeight = XFA_LAYOUT_FLOAT_MAX, + CXFA_LayoutContext* pContext = NULL); + + void GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, FX_FLOAT& fAbsoluteY); + + void GetCurrentComponentSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); + + void SetCurrentComponentPos(FX_FLOAT fAbsoluteX, FX_FLOAT fAbsoluteY); + + void SetCurrentComponentSize(FX_FLOAT fWidth, FX_FLOAT fHeight); + inline CXFA_Node* GetFormNode() { return m_pFormNode; } + inline FX_BOOL HasLayoutItem() { return m_pLayoutItem != NULL; } + CXFA_ContentLayoutItem* ExtractLayoutItem(); + + static FX_BOOL IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor, + CXFA_Node* pNode, + CXFA_Node* pParentNode); + static void CalculatePositionedContainerPos(CXFA_Node* pNode, + FX_FLOAT fWidth, + FX_FLOAT fHeight, + FX_FLOAT& fAbsoluteX, + FX_FLOAT& fAbsoluteY); + static FX_BOOL FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem, + FX_FLOAT fCurVerticalOffset, + FX_FLOAT& fProposedSplitPos, + FX_BOOL& bAppChange, + FX_BOOL bCalculateMargin = TRUE); + FX_FLOAT FindSplitPos(FX_FLOAT fProposedSplitPos); + void SplitLayoutItem(CXFA_ContentLayoutItem* pLayoutItem, + CXFA_ContentLayoutItem* pSecondParent, + FX_FLOAT fSplitPos); + void SplitLayoutItem(FX_FLOAT fSplitPos); + FX_BOOL JudgePutNextPage( + CXFA_ContentLayoutItem* pParentLayoutItem, + FX_FLOAT fChildHeight, + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems); + FX_BOOL ProcessKeepForSplite( + CXFA_ItemLayoutProcessor* pParentProcessor, + CXFA_ItemLayoutProcessor* pChildProcessor, + XFA_ItemLayoutProcessorResult eRetValue, + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, + FX_FLOAT& fContentCurRowAvailWidth, + FX_FLOAT& fContentCurRowHeight, + FX_FLOAT& fContentCurRowY, + FX_BOOL& bAddedItemInRow, + FX_BOOL& bForceEndPage, + XFA_ItemLayoutProcessorResult& result); + FX_FLOAT InsertKeepLayoutItems(); + void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem); + FX_BOOL CalculateRowChildPosition( + CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], + XFA_ATTRIBUTEENUM eFlowStrategy, + FX_BOOL bContainerHeightAutoSize, + FX_BOOL bContainerWidthAutoSize, + FX_FLOAT& fContentCalculatedWidth, + FX_FLOAT& fContentCalculatedHeight, + FX_FLOAT& fContentCurRowY, + FX_FLOAT fContentCurRowHeight, + FX_FLOAT fContentWidthLimit, + FX_BOOL bRootForceTb = FALSE); + + void ProcessUnUseOverFlow(CXFA_Node* pLeaderNode, + CXFA_Node* pTrailerNode, + CXFA_ContentLayoutItem* pTrailerItem, + CXFA_Node* pFormNode); + void ProcessUnUseBinds(CXFA_Node* pFormNode); + FX_BOOL IsAddNewRowForTrailer(CXFA_ContentLayoutItem* pTrailerItem); + FX_BOOL JudgeLeaderOrTrailerForOccur(CXFA_Node* pFormNode); + CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode); + + protected: + void DoLayoutPositionedContainer(CXFA_LayoutContext* pContext = NULL); + void DoLayoutTableContainer(CXFA_Node* pLayoutNode); + XFA_ItemLayoutProcessorResult DoLayoutFlowedContainer( + FX_BOOL bUseBreakControl, + XFA_ATTRIBUTEENUM eFlowStrategy, + FX_FLOAT fHeightLimit, + FX_FLOAT fRealHeight, + CXFA_LayoutContext* pContext = NULL, + FX_BOOL bRootForceTb = FALSE); + void DoLayoutField(); + void XFA_ItemLayoutProcessor_GotoNextContainerNode( + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node* pParentContainer, + FX_BOOL bUsePageBreak); + + FX_BOOL ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node*& pNextContainer, + FX_BOOL& bLastKeepNode); + + FX_BOOL ProcessKeepNodesForBreakBefore( + CXFA_Node*& pCurActionNode, + XFA_ItemLayoutProcessorStages& nCurStage, + CXFA_Node* pContainerNode); + + CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet); + + public: + FX_BOOL m_bKeepBreakFinish; + FX_BOOL m_bIsProcessKeep; + CXFA_Node* m_pKeepHeadNode; + CXFA_Node* m_pKeepTailNode; + CXFA_Node* m_pFormNode; + CXFA_ContentLayoutItem* m_pLayoutItem; + CXFA_ContentLayoutItem* m_pOldLayoutItem; + CXFA_Node* m_pCurChildNode; + CXFA_ItemLayoutProcessor* m_pCurChildPreprocessor; + XFA_ItemLayoutProcessorStages m_nCurChildNodeStage; + FX_FLOAT m_fUsedSize; + CXFA_LayoutPageMgr* m_pPageMgr; + std::list<CXFA_Node*> m_PendingNodes; + FX_BOOL m_bBreakPending; + CFX_ArrayTemplate<FX_FLOAT> m_rgSpecifiedColumnWidths; + CFX_ArrayTemplate<CXFA_ContentLayoutItem*> m_arrayKeepItems; + CFX_MapPtrToPtr m_PendingNodesCount; + FX_FLOAT m_fLastRowWidth; + FX_FLOAT m_fLastRowY; + FX_FLOAT m_fWidthLimite; + FX_BOOL m_bUseInheriated; + XFA_ItemLayoutProcessorResult m_ePreProcessRs; + FX_BOOL m_bHasAvailHeight; +}; +FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode); + +#endif // XFA_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp new file mode 100644 index 0000000000..b46d882b54 --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -0,0 +1,1931 @@ +// 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/fxfa/parser/xfa_layout_pagemgr_new.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" +#include "xfa/fxfa/parser/xfa_document_layout_imp.h" +#include "xfa/fxfa/parser/xfa_layout_appadapter.h" +#include "xfa/fxfa/parser/xfa_layout_itemlayout.h" +#include "xfa/fxfa/parser/xfa_localemgr.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" + +CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) + : m_pLayoutProcessor(pLayoutProcessor), + m_pTemplatePageSetRoot(nullptr), + m_pPageSetLayoutItemRoot(nullptr), + m_pPageSetCurRoot(nullptr), + m_pCurrentContainerRecord(nullptr), + m_pCurPageArea(nullptr), + m_nAvailPages(0), + m_nCurPageCount(0), + m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), + m_bCreateOverFlowPage(FALSE) {} +CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { + ClearData(); + CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); + CXFA_LayoutItem* pNextLayout = NULL; + for (; pLayoutItem; pLayoutItem = pNextLayout) { + pNextLayout = pLayoutItem->m_pNextSibling; + XFA_ReleaseLayoutItem(pLayoutItem); + } +} +FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { + PrepareLayout(); + CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); + if (!pTemplateNode) { + return FALSE; + } + m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_ELEMENT_PageSet); + ASSERT(m_pTemplatePageSetRoot); + if (m_pPageSetLayoutItemRoot) { + m_pPageSetLayoutItemRoot->m_pParent = NULL; + m_pPageSetLayoutItemRoot->m_pFirstChild = NULL; + m_pPageSetLayoutItemRoot->m_pNextSibling = NULL; + m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; + } else { + m_pPageSetLayoutItemRoot = + new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); + } + m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; + m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, + (void*)m_pPageSetLayoutItemRoot); + XFA_ATTRIBUTEENUM eRelation = + m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); + if (eRelation != XFA_ATTRIBUTEENUM_Unknown) { + m_ePageSetMode = eRelation; + } + InitPageSetMap(); + CXFA_Node* pPageArea = NULL; + int32_t iCount = 0; + for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + pPageArea; + pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pPageArea->GetClassID() == XFA_ELEMENT_PageArea) { + iCount++; + if (pPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea)) { + return TRUE; + } + } + } + if (iCount > 0) { + return FALSE; + } + CXFA_Document* pDocument = pTemplateNode->GetDocument(); + IXFA_ObjFactory* pObjFactory = pDocument->GetParser()->GetFactory(); + pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_ELEMENT_PageArea); + if (!pPageArea) { + pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), + XFA_ELEMENT_PageArea); + if (!pPageArea) { + return FALSE; + } + m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL); + pPageArea->SetFlag(XFA_NODEFLAG_Initialized); + } + CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_ELEMENT_ContentArea); + if (!pContentArea) { + pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), + XFA_ELEMENT_ContentArea); + if (!pContentArea) { + return FALSE; + } + pPageArea->InsertChild(pContentArea, NULL); + pContentArea->SetFlag(XFA_NODEFLAG_Initialized); + pContentArea->SetMeasure(XFA_ATTRIBUTE_X, + CXFA_Measurement(0.25f, XFA_UNIT_In)); + pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, + CXFA_Measurement(0.25f, XFA_UNIT_In)); + pContentArea->SetMeasure(XFA_ATTRIBUTE_W, + CXFA_Measurement(8.0f, XFA_UNIT_In)); + pContentArea->SetMeasure(XFA_ATTRIBUTE_H, + CXFA_Measurement(10.5f, XFA_UNIT_In)); + } + CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_ELEMENT_Medium); + if (!pMedium) { + pMedium = + pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_ELEMENT_Medium); + if (!pContentArea) { + return FALSE; + } + pPageArea->InsertChild(pMedium, NULL); + pMedium->SetFlag(XFA_NODEFLAG_Initialized); + pMedium->SetMeasure(XFA_ATTRIBUTE_Short, + CXFA_Measurement(8.5f, XFA_UNIT_In)); + pMedium->SetMeasure(XFA_ATTRIBUTE_Long, + CXFA_Measurement(11.0f, XFA_UNIT_In)); + } + return TRUE; +} +FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { + FX_BOOL bProBreakBefore = FALSE; + CXFA_Node* pBreakBeforeNode = NULL; + while (pRootSubform) { + for (CXFA_Node* pBreakNode = + pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); + pBreakNode; + pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ELEMENT eType = pBreakNode->GetClassID(); + if (eType == XFA_ELEMENT_BreakBefore || + (eType == XFA_ELEMENT_Break && + pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != + XFA_ATTRIBUTEENUM_Auto)) { + bProBreakBefore = TRUE; + pBreakBeforeNode = pBreakNode; + break; + } + } + if (bProBreakBefore) { + break; + } + bProBreakBefore = TRUE; + pRootSubform = pRootSubform->GetFirstChildByClass(XFA_ELEMENT_Subform); + while (pRootSubform && + !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) { + pRootSubform = pRootSubform->GetNextSameClassSibling(XFA_ELEMENT_Subform); + } + } + CXFA_Node *pLeader, *pTrailer; + if (pBreakBeforeNode && + ExecuteBreakBeforeOrAfter(pBreakBeforeNode, TRUE, pLeader, pTrailer)) { + m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); + return TRUE; + } + return AppendNewPage(TRUE); +} +FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { + if (m_pCurrentContainerRecord != + m_rgProposedContainerRecord.GetTailPosition()) { + return TRUE; + } + CXFA_Node* pPageNode = GetNextAvailPageArea(NULL); + if (!pPageNode) { + return FALSE; + } + if (bFirstTemPage && m_pCurrentContainerRecord == NULL) { + m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); + } + 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); + return; + } + if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { + XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageArea); + return; + } + if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { + XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurContentArea); + return; + } +} +void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( + CXFA_ContainerRecord* pNewRecord, + CXFA_ContainerRecord* pPrevRecord) { + if (!pNewRecord || !pPrevRecord) { + return; + } + if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { + XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageSet); + return; + } + if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { + XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageArea); + return; + } + if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { + XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurContentArea); + return; + } +} +void CXFA_LayoutPageMgr::SubmitContentItem( + CXFA_ContentLayoutItem* pContentLayoutItem, + XFA_ItemLayoutProcessorResult eStatus) { + if (pContentLayoutItem) { + GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); + m_bCreateOverFlowPage = FALSE; + } + if (eStatus != XFA_ItemLayoutProcessorResult_Done) { + if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak && + m_pCurrentContainerRecord == + m_rgProposedContainerRecord.GetTailPosition()) { + AppendNewPage(); + } + m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition(); + m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; + } +} +FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { + CXFA_ContainerLayoutItem* pLayoutItem = + GetCurrentContainerRecord()->pCurContentArea; + if (!pLayoutItem || !pLayoutItem->m_pFormNode) + return 0.0f; + FX_FLOAT fAvailHeight = + pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); + if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) + return fAvailHeight; + if (m_pCurrentContainerRecord == + m_rgProposedContainerRecord.GetHeadPosition()) { + return 0.0f; + } + 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)); + 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, 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; + pTestScript->TryContent(wsExpression); + if (wsExpression.IsEmpty()) { + return TRUE; + } + return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( + pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode)); +} +CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( + CXFA_Node* pPageNode, + FX_BOOL bCreateNew) { + CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); + if (m_pCurrentContainerRecord) { + if (!IsPageSetRootOrderedOccurrence() || pPageNode == NULL) { + *pNewRecord = *GetCurrentContainerRecord(); + m_rgProposedContainerRecord.AddTail(pNewRecord); + return pNewRecord; + } + CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!bCreateNew) { + if (pPageSet == m_pTemplatePageSetRoot) { + pNewRecord->pCurPageSet = m_pPageSetCurRoot; + } else { + CXFA_ContainerLayoutItem* pParentLayoutItem = + (CXFA_ContainerLayoutItem*)pPageSet->GetUserData(XFA_LAYOUTITEMKEY); + if (pParentLayoutItem == NULL) { + pParentLayoutItem = m_pPageSetCurRoot; + } + pNewRecord->pCurPageSet = pParentLayoutItem; + } + } else { + CXFA_ContainerLayoutItem* pParentPageSetLayout = NULL; + if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { + pParentPageSetLayout = + (CXFA_ContainerLayoutItem*)GetCurrentContainerRecord() + ->pCurPageSet->m_pParent; + } else { + pParentPageSetLayout = + (CXFA_ContainerLayoutItem*)pPageSet->GetNodeItem( + XFA_NODEITEM_Parent) + ->GetUserData(XFA_LAYOUTITEMKEY); + } + CXFA_ContainerLayoutItem* pPageSetLayoutItem = + new CXFA_ContainerLayoutItem(pPageSet); + pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); + if (pParentPageSetLayout == NULL) { + CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; + while (pPrePageSet->m_pNextSibling) { + pPrePageSet = (CXFA_ContainerLayoutItem*)pPrePageSet->m_pNextSibling; + } + pPrePageSet->m_pNextSibling = pPageSetLayoutItem; + m_pPageSetCurRoot = pPageSetLayoutItem; + } else { + pParentPageSetLayout->AddChild(pPageSetLayoutItem); + } + pNewRecord->pCurPageSet = pPageSetLayoutItem; + } + } else { + if (pPageNode) { + CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pPageSet == m_pTemplatePageSetRoot) { + pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; + } else { + CXFA_ContainerLayoutItem* pPageSetLayoutItem = + new CXFA_ContainerLayoutItem(pPageSet); + pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); + m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem); + pNewRecord->pCurPageSet = pPageSetLayoutItem; + } + } else { + pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; + } + } + m_rgProposedContainerRecord.AddTail(pNewRecord); + return pNewRecord; +} +void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, + CXFA_Node* pNewPageArea) { + CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = NULL; + if (m_PageArray.GetSize() > m_nAvailPages) { + CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; + pContainerItem->m_pFormNode = pNewPageArea; + m_nAvailPages++; + pNewPageAreaLayoutItem = pContainerItem; + } else { + IXFA_Notify* pNotify = + pNewPageArea->GetDocument()->GetParser()->GetNotify(); + CXFA_ContainerLayoutItem* pContainerItem = + (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); + m_PageArray.Add(pContainerItem); + m_nAvailPages++; + pNotify->OnPageEvent(pContainerItem, XFA_PAGEEVENT_PageAdded, + (void*)(uintptr_t)m_nAvailPages); + pNewPageAreaLayoutItem = pContainerItem; + } + pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); + pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; + pNewRecord->pCurContentArea = NULL; +} +void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( + CXFA_ContainerRecord* pNewRecord, + CXFA_Node* pContentArea) { + if (pContentArea == NULL) { + pNewRecord->pCurContentArea = NULL; + return; + } + CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = + new CXFA_ContainerLayoutItem(pContentArea); + ASSERT(pNewRecord->pCurPageArea); + 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> + sIterator(pRootPageSetLayoutItem); + for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); + pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { + XFA_ATTRIBUTEENUM ePageRelation = + pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); + switch (ePageRelation) { + case XFA_ATTRIBUTEENUM_OrderedOccurrence: + default: { ProcessLastPageSet(); } break; + case XFA_ATTRIBUTEENUM_SimplexPaginated: + case XFA_ATTRIBUTEENUM_DuplexPaginated: { + CXFA_LayoutItem* pLastPageAreaLayoutItem = NULL; + int32_t nPageAreaCount = 0; + for (CXFA_LayoutItem* pPageAreaLayoutItem = + pPageSetLayoutItem->m_pFirstChild; + pPageAreaLayoutItem; + pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { + if (pPageAreaLayoutItem->m_pFormNode->GetClassID() != + XFA_ELEMENT_PageArea) { + continue; + } + nPageAreaCount++; + pLastPageAreaLayoutItem = pPageAreaLayoutItem; + } + if (!pLastPageAreaLayoutItem) { + break; + } + if (!FindPageAreaFromPageSet_SimplexDuplex( + pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, TRUE, + nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only + : XFA_ATTRIBUTEENUM_Last) && + (nPageAreaCount == 1 && + !FindPageAreaFromPageSet_SimplexDuplex( + pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, + TRUE, XFA_ATTRIBUTEENUM_Last))) { + break; + } + CXFA_Node* pNode = m_pCurPageArea; + XFA_ATTRIBUTEENUM eCurChoice = + pNode->GetEnum(XFA_ATTRIBUTE_PagePosition); + if (eCurChoice == XFA_ATTRIBUTEENUM_Last) { + XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; + pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); + XFA_ATTRIBUTEENUM eLastChoice = + pLastPageAreaLayoutItem->m_pFormNode->GetEnum( + XFA_ATTRIBUTE_PagePosition); + if (eLastChoice == XFA_ATTRIBUTEENUM_First && + (ePageRelation == XFA_ATTRIBUTEENUM_SimplexPaginated || + eOddOrEven != XFA_ATTRIBUTEENUM_Odd)) { + CXFA_ContainerRecord* pRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pRecord, pNode); + break; + } + } + FX_BOOL bUsable = TRUE; + CFX_ArrayTemplate<FX_FLOAT> rgUsedHeights; + for (CXFA_LayoutItem* pChildLayoutItem = + pLastPageAreaLayoutItem->m_pFirstChild; + pChildLayoutItem; + pChildLayoutItem = pChildLayoutItem->m_pNextSibling) { + if (pChildLayoutItem->m_pFormNode->GetClassID() != + XFA_ELEMENT_ContentArea) { + continue; + } + FX_FLOAT fUsedHeight = 0; + for (CXFA_LayoutItem* pContentChildLayoutItem = + pChildLayoutItem->m_pFirstChild; + pContentChildLayoutItem; + pContentChildLayoutItem = + pContentChildLayoutItem->m_pNextSibling) { + if (CXFA_ContentLayoutItem* pContent = + pContentChildLayoutItem->AsContentLayoutItem()) { + fUsedHeight += pContent->m_sSize.y; + } + } + rgUsedHeights.Add(fUsedHeight); + } + int32_t iCurContentAreaIndex = -1; + for (CXFA_Node* pContentAreaNode = + pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pContentAreaNode; + pContentAreaNode = + pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pContentAreaNode->GetClassID() != XFA_ELEMENT_ContentArea) { + continue; + } + iCurContentAreaIndex++; + if (rgUsedHeights[iCurContentAreaIndex] > + pContentAreaNode->GetMeasure(XFA_ATTRIBUTE_H) + .ToUnit(XFA_UNIT_Pt) + + XFA_LAYOUT_FLOAT_PERCISION) { + bUsable = FALSE; + break; + } + } + if (bUsable) { + CXFA_LayoutItem* pChildLayoutItem = + pLastPageAreaLayoutItem->m_pFirstChild; + CXFA_Node* pContentAreaNode = + pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pLastPageAreaLayoutItem->m_pFormNode = pNode; + while (pChildLayoutItem && pContentAreaNode) { + if (pChildLayoutItem->m_pFormNode->GetClassID() != + XFA_ELEMENT_ContentArea) { + pChildLayoutItem = pChildLayoutItem->m_pNextSibling; + continue; + } + if (pContentAreaNode->GetClassID() != XFA_ELEMENT_ContentArea) { + pContentAreaNode = + pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling); + continue; + } + pChildLayoutItem->m_pFormNode = pContentAreaNode; + pChildLayoutItem = pChildLayoutItem->m_pNextSibling; + pContentAreaNode = + pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } else if (pNode->GetEnum(XFA_ATTRIBUTE_PagePosition) == + XFA_ATTRIBUTEENUM_Last) { + CXFA_ContainerRecord* pRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pRecord, pNode); + } + } break; + } + } + } +} +int32_t CXFA_LayoutPageMgr::GetPageCount() const { + return m_PageArray.GetSize(); +} +IXFA_LayoutPage* CXFA_LayoutPageMgr::GetPage(int32_t index) const { + if (index < 0 || index >= m_PageArray.GetSize()) + return nullptr; + return m_PageArray[index]; +} +int32_t CXFA_LayoutPageMgr::GetPageIndex(const IXFA_LayoutPage* pPage) const { + // FIXME: Find() method should take const. + return m_PageArray.Find(static_cast<CXFA_ContainerLayoutItem*>( + const_cast<IXFA_LayoutPage*>(pPage))); +} +FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_ELEMENT eBreakType, + XFA_ATTRIBUTEENUM eTargetType, + CXFA_Node* pTarget, + FX_BOOL bStartNew) { + FX_BOOL bRet = FALSE; + switch (eTargetType) { + case XFA_ATTRIBUTEENUM_ContentArea: + if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_ContentArea) { + pTarget = NULL; + } + if (!pTarget || !m_pCurrentContainerRecord || + pTarget != + GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || + bStartNew) { + CXFA_Node* pPageArea = NULL; + if (pTarget) { + pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); + } + pPageArea = GetNextAvailPageArea(pPageArea, pTarget); + bRet = pPageArea != NULL; + } + break; + case XFA_ATTRIBUTEENUM_PageArea: + if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { + pTarget = NULL; + } + if (!pTarget || !m_pCurrentContainerRecord || + pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || + bStartNew) { + CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, NULL, TRUE); + bRet = pPageArea != NULL; + } + break; + case XFA_ATTRIBUTEENUM_PageOdd: + 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: + break; + } + return bRet; +} +FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( + CXFA_Node* pCurNode, + FX_BOOL bBefore, + CXFA_Node*& pBreakLeaderTemplate, + CXFA_Node*& pBreakTrailerTemplate) { + XFA_ELEMENT eType = pCurNode->GetClassID(); + switch (eType) { + case XFA_ELEMENT_BreakBefore: + case XFA_ELEMENT_BreakAfter: { + CFX_WideStringC wsBreakLeader, wsBreakTrailer; + CXFA_Node* pFormNode = pCurNode->GetNodeItem( + XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); + CXFA_Node* pContainer = pFormNode->GetTemplateNode(); + FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; + CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Script); + if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) { + return FALSE; + } + CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); + CXFA_Node* pTarget = + XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); + wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); + wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); + pBreakLeaderTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); + pBreakTrailerTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); + if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, + bStartNew)) { + return TRUE; + } else { + if (m_rgProposedContainerRecord.GetCount() > 0 && + m_pCurrentContainerRecord == + m_rgProposedContainerRecord.GetHeadPosition() && + eType == XFA_ELEMENT_BreakBefore) { + CXFA_Node* pParentNode = pFormNode->GetNodeItem( + XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); + if (!pParentNode || + pFormNode != + pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, + XFA_OBJECTTYPE_ContainerNode)) { + break; + } + pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Form) { + break; + } + return TRUE; + } + } + } break; + case XFA_ELEMENT_Break: { + FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; + CFX_WideStringC wsTarget = pCurNode->GetCData( + bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); + CXFA_Node* pTarget = + XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); + if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter, + pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before + : XFA_ATTRIBUTE_After), + pTarget, bStartNew)) { + return TRUE; + } + } break; + default: + break; + } + 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, + CXFA_Node*& pBreakLeaderNode, + CXFA_Node*& pBreakTrailerNode, + FX_BOOL& bCreatePage) { + CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; + CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode); + if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { + bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, + pLeaderTemplate, pTrailerTemplate); + CXFA_Document* pDocument = pBreakNode->GetDocument(); + CXFA_Node* pDataScope = NULL; + pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode); + if (pLeaderTemplate) { + if (!pDataScope) { + pDataScope = XFA_DataMerge_FindDataScope(pFormNode); + } + pBreakLeaderNode = pDocument->DataMerge_CopyContainer( + pLeaderTemplate, pFormNode, pDataScope, TRUE); + pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); + XFA_SetLayoutGeneratedNodeFlag(pBreakLeaderNode); + } + if (pTrailerTemplate) { + if (!pDataScope) { + pDataScope = XFA_DataMerge_FindDataScope(pFormNode); + } + pBreakTrailerNode = pDocument->DataMerge_CopyContainer( + pTrailerTemplate, pFormNode, pDataScope, TRUE); + pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); + XFA_SetLayoutGeneratedNodeFlag(pBreakTrailerNode); + } + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( + CXFA_Node* pBookendNode, + FX_BOOL bLeader, + CXFA_Node*& pBookendAppendNode) { + CXFA_Node* pLeaderTemplate = NULL; + CXFA_Node* pFormNode = pBookendNode->GetNodeItem( + XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); + if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { + CXFA_Document* pDocument = pBookendNode->GetDocument(); + CXFA_Node* pDataScope = NULL; + if (pLeaderTemplate) { + if (!pDataScope) { + pDataScope = XFA_DataMerge_FindDataScope(pFormNode); + } + pBookendAppendNode = pDocument->DataMerge_CopyContainer( + pLeaderTemplate, pFormNode, pDataScope, TRUE); + pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); + XFA_SetLayoutGeneratedNodeFlag(pBookendAppendNode); + return TRUE; + } + } + return FALSE; +} +CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, + CXFA_Node*& pLeaderTemplate, + CXFA_Node*& pTrailerTemplate, + FX_BOOL bCreatePage) { + CFX_WideStringC wsOverflowLeader, wsOverflowTrailer; + CXFA_Node* pContainer = + pOverflowNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode) + ->GetTemplateNode(); + if (pOverflowNode->GetClassID() == XFA_ELEMENT_Break) { + CFX_WideStringC wsOverflowLeader; + CFX_WideStringC wsOverflowTarget; + CFX_WideStringC wsOverflowTrailer; + pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); + pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); + pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); + if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || + !wsOverflowTarget.IsEmpty()) { + if (!wsOverflowTarget.IsEmpty() && bCreatePage && + !m_bCreateOverFlowPage) { + CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, + TRUE, wsOverflowTarget); + if (pTarget) { + m_bCreateOverFlowPage = TRUE; + switch (pTarget->GetClassID()) { + case XFA_ELEMENT_PageArea: + RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, + pTarget, TRUE); + break; + case XFA_ELEMENT_ContentArea: + RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, + pTarget, TRUE); + break; + default: + break; + } + } + } + if (!bCreatePage) { + pLeaderTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); + pTrailerTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); + } + return pOverflowNode; + } + return NULL; + } else if (pOverflowNode->GetClassID() == XFA_ELEMENT_Overflow) { + CFX_WideStringC wsOverflowTarget; + pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); + 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); + if (pTarget) { + m_bCreateOverFlowPage = TRUE; + switch (pTarget->GetClassID()) { + case XFA_ELEMENT_PageArea: + RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, + TRUE); + break; + case XFA_ELEMENT_ContentArea: + RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, + pTarget, TRUE); + break; + default: + break; + } + } + } + if (!bCreatePage) { + pLeaderTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); + pTrailerTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); + } + return pOverflowNode; + } + return NULL; +} +FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, + CXFA_Node*& pLeaderNode, + CXFA_Node*& pTrailerNode, + FX_BOOL bDataMerge, + FX_BOOL bCreatePage) { + if (pFormNode == NULL) { + return FALSE; + } + CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; + FX_BOOL bIsOverflowNode = FALSE; + if (pFormNode->GetClassID() == XFA_ELEMENT_Overflow || + pFormNode->GetClassID() == XFA_ELEMENT_Break) { + bIsOverflowNode = TRUE; + } + for (CXFA_Node* pCurNode = + bIsOverflowNode ? pFormNode + : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { + if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, + bCreatePage)) { + if (bIsOverflowNode) { + pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); + } + CXFA_Document* pDocument = pCurNode->GetDocument(); + CXFA_Node* pDataScope = NULL; + if (pLeaderTemplate) { + if (!pDataScope) { + pDataScope = XFA_DataMerge_FindDataScope(pFormNode); + } + pLeaderNode = pDocument->DataMerge_CopyContainer( + pLeaderTemplate, pFormNode, pDataScope, TRUE); + pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); + XFA_SetLayoutGeneratedNodeFlag(pLeaderNode); + } + if (pTrailerTemplate) { + if (!pDataScope) { + pDataScope = XFA_DataMerge_FindDataScope(pFormNode); + } + pTrailerNode = pDocument->DataMerge_CopyContainer( + pTrailerTemplate, pFormNode, pDataScope, TRUE); + pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); + XFA_SetLayoutGeneratedNodeFlag(pTrailerNode); + } + return TRUE; + } + if (bIsOverflowNode) { + break; + } + } + return FALSE; +} +FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( + CXFA_Node* pBookendNode, + FX_BOOL bLeader, + CXFA_Node*& pBookendAppendTemplate) { + CFX_WideStringC wsBookendLeader; + CXFA_Node* pContainer = + pBookendNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode) + ->GetTemplateNode(); + if (pBookendNode->GetClassID() == XFA_ELEMENT_Break) { + pBookendNode->TryCData( + bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, + wsBookendLeader); + if (!wsBookendLeader.IsEmpty()) { + pBookendAppendTemplate = + XFA_ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); + return TRUE; + } + return FALSE; + } else if (pBookendNode->GetClassID() == XFA_ELEMENT_Bookend) { + pBookendNode->TryCData( + bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, + wsBookendLeader); + pBookendAppendTemplate = + XFA_ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( + CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea, + CXFA_Node* pTargetContentArea, + FX_BOOL bNewPage, + FX_BOOL bQuery) { + if (pPageSet == NULL && pStartChild == NULL) { + return FALSE; + } + if (IsPageSetRootOrderedOccurrence()) { + return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, + pTargetPageArea, pTargetContentArea, + bNewPage, bQuery); + } + XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord + ? XFA_ATTRIBUTEENUM_Rest + : XFA_ATTRIBUTEENUM_First; + return FindPageAreaFromPageSet_SimplexDuplex( + pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage, + bQuery, ePreferredPosition); +} +FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( + CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea, + CXFA_Node* pTargetContentArea, + FX_BOOL bNewPage, + FX_BOOL bQuery) { + int32_t iPageSetCount = 0; + if (!pStartChild && !bQuery) { + m_pPageSetMap.Lookup(pPageSet, iPageSetCount); + int32_t iMax = -1; + CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_ELEMENT_Occur); + if (pOccurNode) { + pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); + } + if (iMax >= 0 && iMax <= iPageSetCount) { + return FALSE; + } + } + FX_BOOL bRes = FALSE; + CXFA_Node* pCurrentNode = + pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) + : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pCurrentNode; + pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { + if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { + if (pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea) == + NULL) { + if (pTargetPageArea == pCurrentNode) { + CreateMinPageRecord(pCurrentNode, TRUE); + pTargetPageArea = NULL; + } + continue; + } + if (!bQuery) { + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(pCurrentNode, pStartChild == NULL); + AddPageAreaLayoutItem(pNewRecord, pCurrentNode); + if (pTargetContentArea == NULL) { + pTargetContentArea = + pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + } + AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); + } + m_pCurPageArea = pCurrentNode; + m_nCurPageCount = 1; + bRes = TRUE; + break; + } + if (!bQuery) { + CreateMinPageRecord(pCurrentNode, FALSE); + } + } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { + if (FindPageAreaFromPageSet_Ordered(pCurrentNode, NULL, pTargetPageArea, + pTargetContentArea, bNewPage, + bQuery)) { + bRes = TRUE; + break; + } + if (!bQuery) { + CreateMinPageSetRecord(pCurrentNode, TRUE); + } + } + } + if (!pStartChild && bRes && !bQuery) { + m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); + } + return bRes; +} +FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( + CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea, + CXFA_Node* pTargetContentArea, + FX_BOOL bNewPage, + FX_BOOL bQuery, + XFA_ATTRIBUTEENUM ePreferredPosition) { + const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; + CXFA_Node *pPreferredPageArea = NULL, *pFallbackPageArea = NULL; + CXFA_Node* pCurrentNode = NULL; + if (!pStartChild || pStartChild->GetClassID() == XFA_ELEMENT_PageArea) { + pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); + } else { + pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); + } + for (; pCurrentNode; + pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { + if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) { + continue; + } + XFA_ATTRIBUTEENUM eCurPagePosition = + pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition); + if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) { + if (eCurPagePosition != ePreferredPosition) { + continue; + } + if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated || + pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == + XFA_ATTRIBUTEENUM_Any) { + pPreferredPageArea = pCurrentNode; + break; + } + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pNewRecord, pCurrentNode); + AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( + XFA_ELEMENT_ContentArea)); + pPreferredPageArea = pCurrentNode; + return FALSE; + } else if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) { + if (eCurPagePosition != ePreferredPosition) { + continue; + } + if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || + pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == + XFA_ATTRIBUTEENUM_Any) { + pPreferredPageArea = pCurrentNode; + break; + } + return FALSE; + } + if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { + if (pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea) == + NULL) { + if (pTargetPageArea == pCurrentNode) { + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pNewRecord, pCurrentNode); + pTargetPageArea = NULL; + } + continue; + } + if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest && + eCurPagePosition == XFA_ATTRIBUTEENUM_Any) || + eCurPagePosition == ePreferredPosition) { + pPreferredPageArea = pCurrentNode; + break; + } else if (eCurPagePosition == eFallbackPosition && + !pFallbackPageArea) { + pFallbackPageArea = pCurrentNode; + } + } else if (pTargetPageArea && + !MatchPageAreaOddOrEven(pTargetPageArea, FALSE)) { + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pNewRecord, pCurrentNode); + AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( + XFA_ELEMENT_ContentArea)); + } + } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { + if (FindPageAreaFromPageSet_SimplexDuplex( + pCurrentNode, NULL, pTargetPageArea, pTargetContentArea, bNewPage, + bQuery, ePreferredPosition)) { + break; + } + } + } + CXFA_Node* pCurPageArea = NULL; + if (pPreferredPageArea) { + pCurPageArea = pPreferredPageArea; + } else if (pFallbackPageArea) { + pCurPageArea = pFallbackPageArea; + } + if (!pCurPageArea) { + return FALSE; + } + if (!bQuery) { + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pNewRecord, pCurPageArea); + if (pTargetContentArea == NULL) { + pTargetContentArea = + pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + } + AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); + } + m_pCurPageArea = pCurPageArea; + return TRUE; +} +FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, + FX_BOOL bLastMatch) { + if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated) { + return TRUE; + } + XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; + pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); + if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) { + int32_t iPageCount = GetPageCount(); + if (bLastMatch) { + return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1 + : iPageCount % 2 == 0; + } + return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 + : iPageCount % 2 == 1; + } + return TRUE; +} +CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( + CXFA_Node* pTargetPageArea, + CXFA_Node* pTargetContentArea, + FX_BOOL bNewPage, + FX_BOOL bQuery) { + if (m_pCurPageArea == NULL) { + FindPageAreaFromPageSet(m_pTemplatePageSetRoot, NULL, pTargetPageArea, + pTargetContentArea, bNewPage, bQuery); + ASSERT(m_pCurPageArea); + return m_pCurPageArea; + } + if (pTargetPageArea == NULL || pTargetPageArea == m_pCurPageArea) { + if (!bNewPage && GetNextContentArea(pTargetContentArea)) { + return m_pCurPageArea; + } + if (IsPageSetRootOrderedOccurrence()) { + int32_t iMax = -1; + CXFA_Node* pOccurNode = + m_pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_Occur); + if (pOccurNode) { + pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); + } + if ((iMax < 0 || m_nCurPageCount < iMax)) { + if (!bQuery) { + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(m_pCurPageArea); + AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); + if (pTargetContentArea == NULL) { + pTargetContentArea = + m_pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + } + AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); + } + m_nCurPageCount++; + return m_pCurPageArea; + } + } + } + if (!bQuery && IsPageSetRootOrderedOccurrence()) { + CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); + } + if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), + m_pCurPageArea, pTargetPageArea, + pTargetContentArea, bNewPage, bQuery)) { + return m_pCurPageArea; + } + CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); + while (TRUE) { + if (FindPageAreaFromPageSet(pPageSet, NULL, pTargetPageArea, + pTargetContentArea, bNewPage, bQuery)) { + return m_pCurPageArea; + } + if (!bQuery && IsPageSetRootOrderedOccurrence()) { + CreateMinPageSetRecord(pPageSet); + } + if (FindPageAreaFromPageSet(NULL, pPageSet, pTargetPageArea, + pTargetContentArea, bNewPage, bQuery)) { + return m_pCurPageArea; + } + if (pPageSet == m_pTemplatePageSetRoot) { + break; + } + pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); + } + 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; + if (pContentArea == NULL) { + pContentArea = + pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); + if (pContentArea == NULL) { + return FALSE; + } + } else { + if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { + return FALSE; + } + CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; + if (!XFA_LayoutPageMgr_CheckContentAreaNotUsed( + GetCurrentContainerRecord()->pCurPageArea, pContentArea, + pContentAreaLayout)) { + return FALSE; + } + if (pContentAreaLayout) { + if (pContentAreaLayout->m_pFormNode != pCurContentNode) { + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + pNewRecord->pCurContentArea = pContentAreaLayout; + return TRUE; + } else { + return FALSE; + } + } + } + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddContentAreaLayoutItem(pNewRecord, pContentArea); + return TRUE; +} +void CXFA_LayoutPageMgr::InitPageSetMap() { + if (!IsPageSetRootOrderedOccurrence()) { + return; + } + CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); + for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; + pPageSetNode = sIterator.MoveToNext()) { + if (pPageSetNode->GetClassID() == XFA_ELEMENT_PageSet) { + XFA_ATTRIBUTEENUM eRelation = + pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); + if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) { + m_pPageSetMap.SetAt(pPageSetNode, 0); + } + } + } +} +int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, + FX_BOOL bTargetPageArea, + FX_BOOL bCreateLast) { + if (pPageArea == NULL) { + return 0; + } + CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_ELEMENT_Occur); + int32_t iMin = 0; + if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || + bTargetPageArea) { + CXFA_Node* pContentArea = + pPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + if (iMin < 1 && bTargetPageArea && !pContentArea) { + iMin = 1; + } + int32_t i = 0; + if (bCreateLast) { + i = m_nCurPageCount; + } + for (; i < iMin; i++) { + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + AddPageAreaLayoutItem(pNewRecord, pPageArea); + AddContentAreaLayoutItem(pNewRecord, pContentArea); + } + } + return iMin; +} +void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, + FX_BOOL bCreateAll) { + if (pPageSet == NULL) { + return; + } + int32_t iCurSetCount = 0; + if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) { + return; + } + if (bCreateAll) { + iCurSetCount = 0; + } + CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_ELEMENT_Occur); + int32_t iMin = 0; + if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) { + if (iCurSetCount < iMin) { + for (int32_t i = 0; i < iMin - iCurSetCount; i++) { + for (CXFA_Node* pCurrentPageNode = + pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); + pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + if (pCurrentPageNode->GetClassID() == XFA_ELEMENT_PageArea) { + CreateMinPageRecord(pCurrentPageNode, FALSE); + } else if (pCurrentPageNode->GetClassID() == XFA_ELEMENT_PageSet) { + CreateMinPageSetRecord(pCurrentPageNode, TRUE); + } + } + } + m_pPageSetMap.SetAt(pPageSet, iMin); + } + } +} +void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { + if (pRecordNode == NULL) { + return; + } + for (CXFA_Node* pCurrentNode = + pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pCurrentNode; + pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { + CreateMinPageRecord(pCurrentNode, FALSE); + } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { + CreateMinPageSetRecord(pCurrentNode, TRUE); + } + } +} +void CXFA_LayoutPageMgr::ProcessLastPageSet() { + CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); + CreateNextMinRecord(m_pCurPageArea); + CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); + while (TRUE) { + CreateMinPageSetRecord(pPageSet); + if (pPageSet == m_pTemplatePageSetRoot) { + break; + } + CreateNextMinRecord(pPageSet); + pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); + } +} +FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { + CXFA_Node* pCurContentNode = + GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; + if (pCurContentNode == NULL) { + return FALSE; + } + pCurContentNode = + pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); + if (pCurContentNode) { + FX_FLOAT fNextContentHeight = + pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); + return fNextContentHeight > fChildHeight; + } + CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; + CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_ELEMENT_Occur); + int32_t iMax = 0; + if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { + if (m_nCurPageCount == iMax) { + CXFA_Node* pSrcPage = m_pCurPageArea; + int32_t nSrcPageCount = m_nCurPageCount; + FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); + CXFA_Node* pNextPage = GetNextAvailPageArea(NULL, NULL, FALSE, TRUE); + m_pCurPageArea = pSrcPage; + m_nCurPageCount = nSrcPageCount; + CXFA_ContainerRecord* pPrevRecord = + (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( + psSrcRecord); + while (psSrcRecord) { + FX_POSITION psSaveRecord = psSrcRecord; + CXFA_ContainerRecord* pInsertRecord = + (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( + psSrcRecord); + RemoveLayoutRecord(pInsertRecord, pPrevRecord); + delete pInsertRecord; + m_rgProposedContainerRecord.RemoveAt(psSaveRecord); + } + if (pNextPage) { + CXFA_Node* pContentArea = + pNextPage->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + if (pContentArea) { + FX_FLOAT fNextContentHeight = + pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); + if (fNextContentHeight > fChildHeight) { + return TRUE; + } + } + } + return FALSE; + } + } + CXFA_Node* pContentArea = + pPageNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea); + FX_FLOAT fNextContentHeight = + pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); + if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION) { + return TRUE; + } + if (fNextContentHeight > fChildHeight) { + return TRUE; + } + return FALSE; +} +void CXFA_LayoutPageMgr::ClearData() { + ClearRecordList(); +} +void CXFA_LayoutPageMgr::ClearRecordList() { + if (!m_pTemplatePageSetRoot) { + return; + } + if (m_rgProposedContainerRecord.GetCount() > 0) { + FX_POSITION sPos; + sPos = m_rgProposedContainerRecord.GetHeadPosition(); + while (sPos) { + CXFA_ContainerRecord* pRecord = + (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext(sPos); + delete pRecord; + } + m_rgProposedContainerRecord.RemoveAll(); + } + m_pCurrentContainerRecord = NULL; + m_pCurPageArea = NULL; + m_nCurPageCount = 0; + m_bCreateOverFlowPage = FALSE; + m_pPageSetMap.RemoveAll(); +} +CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( + CXFA_Node* pFormNode) { + return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( + pFormNode); +} +static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, + IXFA_Notify* pNotify, + IXFA_DocLayout* 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; + while (pCurLayoutItem) { + pNextLayoutItem = pCurLayoutItem->m_pNextSibling; + if (pCurLayoutItem->IsContentLayoutItem()) { + FX_DWORD dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); + if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { + IXFA_Notify* pNotify = + m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); + IXFA_DocLayout* pDocLayout = + m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); + if (pCurLayoutItem->m_pFirstChild) { + XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); + } + pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, + XFA_LAYOUTEVENT_ItemRemoving); + delete pCurLayoutItem; + pCurLayoutItem = pNextLayoutItem; + continue; + } + if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> + sIterator(pCurLayoutItem->m_pFormNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE); + } + } + } + if (pCurLayoutItem->m_pFirstChild) { + SaveLayoutItem(pCurLayoutItem); + } + pCurLayoutItem->m_pParent = NULL; + pCurLayoutItem->m_pNextSibling = NULL; + pCurLayoutItem->m_pFirstChild = NULL; + if (!pCurLayoutItem->IsContentLayoutItem() && + pCurLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageArea) { + delete pCurLayoutItem; + } + pCurLayoutItem = pNextLayoutItem; + } +} +CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( + CXFA_Node* pFormNode, + CXFA_LayoutContext* pLayoutContext) { + for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { + if (pCurNode->GetClassID() == XFA_ELEMENT_Break) { + CFX_WideStringC wsOverflowLeader; + CFX_WideStringC wsOverflowTarget; + CFX_WideStringC wsOverflowTrailer; + pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); + pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); + pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); + if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || + !wsOverflowTarget.IsEmpty()) { + return pCurNode; + } + return NULL; + } else if (pCurNode->GetClassID() == XFA_ELEMENT_Overflow) { + return pCurNode; + } + } + return NULL; +} +void CXFA_LayoutPageMgr::MergePageSetContents() { + CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); + IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); + IXFA_DocLayout* pDocLayout = pDocument->GetDocLayout(); + CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); + { + for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); + iIndex++) { + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> + sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + if (pNode->IsContainerNode()) { + CXFA_Node* pBindNode = pNode->GetBindData(); + if (pBindNode) { + pBindNode->RemoveBindItem(pNode); + pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + } + } + pNode->SetFlag(XFA_NODEFLAG_UnusedNode); + } + } + } + int32_t iIndex = 0; + CXFA_Node* pPendingPageSet = NULL; + for (; pRootLayout; + pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { + pPendingPageSet = NULL; + CXFA_NodeIteratorTemplate< + CXFA_ContainerLayoutItem, + CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> + iterator(pRootLayout); + CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); + ASSERT(pRootPageSetContainerItem->m_pFormNode->GetClassID() == + XFA_ELEMENT_PageSet); + if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { + pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); + iIndex++; + } + if (!pPendingPageSet) { + if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() == + XFA_XDPPACKET_Template) { + pPendingPageSet = + pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); + } else { + pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; + } + } + if (pRootPageSetContainerItem->m_pFormNode->GetUserData( + XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { + pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, + NULL); + } + pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; + pPendingPageSet->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); + pContainerItem; pContainerItem = iterator.MoveToNext()) { + CXFA_Node* pNode = pContainerItem->m_pFormNode; + if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { + continue; + } + switch (pNode->GetClassID()) { + case XFA_ELEMENT_PageSet: { + CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; + pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( + pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE); + } break; + case XFA_ELEMENT_PageArea: { + CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; + CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; + FX_BOOL bIsExistForm = TRUE; + for (int32_t iLevel = 0; iLevel < 3; iLevel++) { + pFormLayout = (CXFA_ContainerLayoutItem*)pFormLayout->m_pFirstChild; + if (iLevel == 2) { + while (pFormLayout && + !XFA_ItemLayoutProcessor_IsTakingSpace( + pFormLayout->m_pFormNode)) { + pFormLayout = + (CXFA_ContainerLayoutItem*)pFormLayout->m_pNextSibling; + } + } + if (pFormLayout == NULL) { + bIsExistForm = FALSE; + break; + } + } + if (bIsExistForm) { + CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; + if (pContainerItem->m_pOldSubform && + pContainerItem->m_pOldSubform != pNewSubform) { + CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( + pDocument, pContainerItem->m_pFormNode->GetClassID(), + pContainerItem->m_pFormNode->GetNameHash(), pParentNode); + CXFA_ContainerIterator sIterator(pExistingNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { + CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( + pNode->GetUserData(XFA_LAYOUTITEMKEY)); + if (pLayoutItem) { + pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, + XFA_LAYOUTEVENT_ItemRemoving); + delete pLayoutItem; + } + } + } + if (pExistingNode) { + pParentNode->RemoveChild(pExistingNode); + } + } + pContainerItem->m_pOldSubform = pNewSubform; + } + pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( + pContainerItem->m_pFormNode, pParentNode, + ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE); + } break; + case XFA_ELEMENT_ContentArea: { + CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; + for (CXFA_Node* pChildNode = + pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pChildNode; + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { + continue; + } + pContainerItem->m_pFormNode = pChildNode; + break; + } + } break; + default: + break; + } + } + if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { + CXFA_Node* pFormToplevelSubform = + pDocument->GetXFAObject(XFA_HASHCODE_Form) + ->AsNode() + ->GetFirstChildByClass(XFA_ELEMENT_Subform); + pFormToplevelSubform->InsertChild(pPendingPageSet); + } + pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); + pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized); + } + pPendingPageSet = GetRootLayoutItem()->m_pFormNode; + while (pPendingPageSet) { + CXFA_Node* pNextPendingPageSet = + pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet); + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> + sIterator(pPendingPageSet); + CXFA_Node* pNode = sIterator.GetCurrent(); + while (pNode) { + if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { + if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { + XFA_ELEMENT eCurId = pNode->GetClassID(); + if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) { + CXFA_ContainerIterator iteChild(pNode); + CXFA_Node* pChildNode = iteChild.MoveToNext(); + for (; pChildNode; pChildNode = iteChild.MoveToNext()) { + CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( + pChildNode->GetUserData(XFA_LAYOUTITEMKEY)); + if (pLayoutItem) { + pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, + XFA_LAYOUTEVENT_ItemRemoving); + delete pLayoutItem; + } + } + } else if (eCurId != XFA_ELEMENT_ContentArea) { + CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( + pNode->GetUserData(XFA_LAYOUTITEMKEY)); + if (pLayoutItem) { + pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, + XFA_LAYOUTEVENT_ItemRemoving); + delete pLayoutItem; + } + } + CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); + pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); + pNode = pNext; + } else { + pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); + pNode->SetFlag(XFA_NODEFLAG_Initialized); + pNode = sIterator.MoveToNext(); + } + } else { + pNode->SetFlag(XFA_NODEFLAG_Initialized); + pNode = sIterator.MoveToNext(); + } + } + pPendingPageSet = pNextPendingPageSet; + } +} +void CXFA_LayoutPageMgr::LayoutPageSetContents() { + CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); + for (; pRootLayoutItem; + pRootLayoutItem = + (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { + CXFA_NodeIteratorTemplate< + CXFA_ContainerLayoutItem, + CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> + iterator(pRootLayoutItem); + for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); + pContainerItem; pContainerItem = iterator.MoveToNext()) { + CXFA_Node* pNode = pContainerItem->m_pFormNode; + switch (pNode->GetClassID()) { + case XFA_ELEMENT_PageArea: + m_pLayoutProcessor->GetRootRootItemLayoutProcessor() + ->DoLayoutPageArea(pContainerItem); + break; + default: + break; + } + } + } +} +void XFA_SyncContainer(IXFA_Notify* pNotify, + IXFA_DocLayout* pDocLayout, + CXFA_LayoutItem* pContainerItem, + FX_DWORD dwRelevant, + FX_BOOL bVisible, + int32_t nPageIndex) { + FX_BOOL bVisibleItem = FALSE; + FX_DWORD dwStatus = 0; + FX_DWORD 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(); + IXFA_Notify* pNotify = + m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); + int32_t nPageIdx = -1; + CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); + for (; pRootLayoutItem; + pRootLayoutItem = + (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { + CXFA_NodeIteratorTemplate< + CXFA_ContainerLayoutItem, + CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> + iteratorParent(pRootLayoutItem); + for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); + pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { + switch (pContainerItem->m_pFormNode->GetClassID()) { + case XFA_ELEMENT_PageArea: { + nPageIdx++; + FX_DWORD dwRelevant = + XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; + CXFA_NodeIteratorTemplate<CXFA_LayoutItem, + CXFA_TraverseStrategy_LayoutItem> + iterator(pContainerItem); + CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent(); + while (pChildLayoutItem) { + CXFA_ContentLayoutItem* pContentItem = + pChildLayoutItem->AsContentLayoutItem(); + if (!pContentItem) { + pChildLayoutItem = iterator.MoveToNext(); + continue; + } + FX_BOOL bVisible = + (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == + XFA_ATTRIBUTEENUM_Visible); + FX_DWORD dwRelevantChild = + XFA_GetRelevant(pContentItem->m_pFormNode, dwRelevant); + XFA_SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, + dwRelevantChild, bVisible, nPageIdx); + pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); + } + } break; + default: + break; + } + } + } + int32_t nPage = m_PageArray.GetSize(); + 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); + delete pPage; + } + ClearRecordList(); +} +void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { + CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; + while (pNode) { + pNext = pNode->m_pNextSibling; + pNode->m_pParent = NULL; + XFA_ReleaseLayoutItem_NoPageArea(pNode); + pNode = pNext; + } + if (pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageArea) { + delete pLayoutItem; + } +} +void CXFA_LayoutPageMgr::PrepareLayout() { + m_pPageSetCurRoot = NULL; + m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; + m_nAvailPages = 0; + ClearRecordList(); + if (!m_pPageSetLayoutItemRoot) { + return; + } + CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; + if (pRootLayoutItem && + pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { + CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; + pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); + if (pPageSetFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { + XFA_ReleaseLayoutItem(pRootLayoutItem); + m_pPageSetLayoutItemRoot = NULL; + pRootLayoutItem = NULL; + pPageSetFormNode = NULL; + m_PageArray.RemoveAll(); + } + while (pPageSetFormNode) { + CXFA_Node* pNextPageSet = + pPageSetFormNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet); + pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) + ->RemoveChild(pPageSetFormNode, FALSE); + pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( + pPageSetFormNode); + pPageSetFormNode = pNextPageSet; + } + } + pRootLayoutItem = m_pPageSetLayoutItemRoot; + CXFA_ContainerLayoutItem* pNextLayout = NULL; + for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { + pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; + SaveLayoutItem(pRootLayoutItem); + delete pRootLayoutItem; + } + m_pPageSetLayoutItemRoot = NULL; +} diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.h b/xfa/fxfa/parser/xfa_layout_pagemgr_new.h new file mode 100644 index 0000000000..354daa5e31 --- /dev/null +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.h @@ -0,0 +1,152 @@ +// 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_LAYOUT_PAGEMGR_NEW_H_ +#define XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ + +#include "xfa/fxfa/parser/xfa_doclayout.h" +#include "xfa/fxfa/parser/xfa_layout_itemlayout.h" + +class CXFA_ContainerRecord { + public: + CXFA_ContainerRecord(CXFA_ContainerLayoutItem* pPageSet = NULL, + CXFA_ContainerLayoutItem* pPageArea = NULL, + CXFA_ContainerLayoutItem* pContentArea = NULL) + : pCurPageSet(pPageSet), + pCurPageArea(pPageArea), + pCurContentArea(pContentArea) {} + CXFA_ContainerLayoutItem* pCurPageSet; + CXFA_ContainerLayoutItem* pCurPageArea; + CXFA_ContainerLayoutItem* pCurContentArea; +}; +class CXFA_LayoutPageMgr { + public: + CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor); + ~CXFA_LayoutPageMgr(); + FX_BOOL InitLayoutPage(CXFA_Node* pFormNode); + FX_BOOL PrepareFirstPage(CXFA_Node* pRootSubform); + FX_FLOAT GetAvailHeight(); + FX_BOOL GetNextAvailContentHeight(FX_FLOAT fChildHeight); + void SubmitContentItem(CXFA_ContentLayoutItem* pContentLayoutItem, + XFA_ItemLayoutProcessorResult eStatus); + void FinishPaginatedPageSets(); + void SyncLayoutData(); + int32_t GetPageCount() const; + IXFA_LayoutPage* GetPage(int32_t index) const; + int32_t GetPageIndex(const IXFA_LayoutPage* pPage) const; + inline CXFA_ContainerLayoutItem* GetRootLayoutItem() const { + return m_pPageSetLayoutItemRoot; + } + FX_BOOL ProcessBreakBeforeOrAfter(CXFA_Node* pBreakNode, + FX_BOOL bBefore, + CXFA_Node*& pBreakLeaderNode, + CXFA_Node*& pBreakTrailerNode, + FX_BOOL& bCreatePage); + FX_BOOL ProcessOverflow(CXFA_Node* pFormNode, + CXFA_Node*& pLeaderNode, + CXFA_Node*& pTrailerNode, + FX_BOOL bDataMerge = FALSE, + FX_BOOL bCreatePage = TRUE); + CXFA_Node* QueryOverflow(CXFA_Node* pFormNode, + CXFA_LayoutContext* pLayoutContext = NULL); + FX_BOOL ProcessBookendLeaderOrTrailer(CXFA_Node* pBookendNode, + FX_BOOL bLeader, + CXFA_Node*& pBookendAppendNode); + CXFA_LayoutItem* FindOrCreateLayoutItem(CXFA_Node* pFormNode); + + protected: + FX_BOOL AppendNewPage(FX_BOOL bFirstTemPage = FALSE); + void ReorderPendingLayoutRecordToTail(CXFA_ContainerRecord* pNewRecord, + CXFA_ContainerRecord* pPrevRecord); + void RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, + CXFA_ContainerRecord* pPrevRecord); + inline CXFA_ContainerRecord* GetCurrentContainerRecord() { + CXFA_ContainerRecord* result = + ((CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetAt( + m_pCurrentContainerRecord)); + ASSERT(result); + return result; + } + CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = NULL, + FX_BOOL bCreateNew = FALSE); + void AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, + CXFA_Node* pNewPageArea); + void AddContentAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, + CXFA_Node* pContentArea); + FX_BOOL RunBreak(XFA_ELEMENT eBreakType, + XFA_ATTRIBUTEENUM eTargetType, + CXFA_Node* pTarget, + FX_BOOL bStartNew); + CXFA_Node* BreakOverflow(CXFA_Node* pOverflowNode, + CXFA_Node*& pLeaderTemplate, + CXFA_Node*& pTrailerTemplate, + FX_BOOL bCreatePage = TRUE); + FX_BOOL ResolveBookendLeaderOrTrailer(CXFA_Node* pBookendNode, + FX_BOOL bLeader, + CXFA_Node*& pBookendAppendTemplate); + FX_BOOL ExecuteBreakBeforeOrAfter(CXFA_Node* pCurNode, + FX_BOOL bBefore, + CXFA_Node*& pBreakLeaderTemplate, + CXFA_Node*& pBreakTrailerTemplate); + + int32_t CreateMinPageRecord(CXFA_Node* pPageArea, + FX_BOOL bTargetPageArea, + FX_BOOL bCreateLast = FALSE); + void CreateMinPageSetRecord(CXFA_Node* pPageSet, FX_BOOL bCreateAll = FALSE); + void CreateNextMinRecord(CXFA_Node* pRecordNode); + FX_BOOL FindPageAreaFromPageSet(CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea = NULL, + CXFA_Node* pTargetContentArea = NULL, + FX_BOOL bNewPage = FALSE, + FX_BOOL bQuery = FALSE); + FX_BOOL FindPageAreaFromPageSet_Ordered(CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea = NULL, + CXFA_Node* pTargetContentArea = NULL, + FX_BOOL bNewPage = FALSE, + FX_BOOL bQuery = FALSE); + FX_BOOL FindPageAreaFromPageSet_SimplexDuplex( + CXFA_Node* pPageSet, + CXFA_Node* pStartChild, + CXFA_Node* pTargetPageArea = NULL, + CXFA_Node* pTargetContentArea = NULL, + FX_BOOL bNewPage = FALSE, + FX_BOOL bQuery = FALSE, + XFA_ATTRIBUTEENUM ePreferredPosition = XFA_ATTRIBUTEENUM_First); + FX_BOOL MatchPageAreaOddOrEven(CXFA_Node* pPageArea, FX_BOOL bLastMatch); + CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea, + CXFA_Node* pTargetContentArea = NULL, + FX_BOOL bNewPage = FALSE, + FX_BOOL bQuery = FALSE); + FX_BOOL GetNextContentArea(CXFA_Node* pTargetContentArea); + void InitPageSetMap(); + void ProcessLastPageSet(); + inline FX_BOOL IsPageSetRootOrderedOccurrence() { + return m_ePageSetMode == XFA_ATTRIBUTEENUM_OrderedOccurrence; + } + void ClearData(); + void ClearRecordList(); + void MergePageSetContents(); + void LayoutPageSetContents(); + void PrepareLayout(); + void SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem); + CXFA_LayoutProcessor* m_pLayoutProcessor; + CXFA_Node* m_pTemplatePageSetRoot; + CXFA_ContainerLayoutItem* m_pPageSetLayoutItemRoot; + CXFA_ContainerLayoutItem* m_pPageSetCurRoot; + FX_POSITION m_pCurrentContainerRecord; + CFX_PtrList m_rgProposedContainerRecord; + CXFA_Node* m_pCurPageArea; + int32_t m_nAvailPages; + int32_t m_nCurPageCount; + XFA_ATTRIBUTEENUM m_ePageSetMode; + FX_BOOL m_bCreateOverFlowPage; + CFX_MapPtrTemplate<CXFA_Node*, int32_t> m_pPageSetMap; + CFX_ArrayTemplate<CXFA_ContainerLayoutItem*> m_PageArray; +}; + +#endif // XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp new file mode 100644 index 0000000000..eb8c244c23 --- /dev/null +++ b/xfa/fxfa/parser/xfa_locale.cpp @@ -0,0 +1,377 @@ +// 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/fxfa/parser/xfa_locale.h" + +#include "core/include/fxcrt/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" +#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 const FX_WCHAR g_FX_Percent[] = L"z,zzz,zzz,zzz,zzz,zzz%"; +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() { + if (m_pLocaleData) { + delete m_pLocaleData; + } +} +void CXFA_XMLLocale::Release() { + delete this; +} +CFX_WideString CXFA_XMLLocale::GetName() { + return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString(); +} +void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const { + CFX_ByteString bsSymbols; + CFX_WideString wsName; + switch (eType) { + case FX_LOCALENUMSYMBOL_Decimal: + bsSymbols = "numberSymbols"; + wsName = FX_WSTRC(L"decimal"); + break; + case FX_LOCALENUMSYMBOL_Grouping: + bsSymbols = "numberSymbols"; + wsName = FX_WSTRC(L"grouping"); + break; + case FX_LOCALENUMSYMBOL_Percent: + bsSymbols = "numberSymbols"; + wsName = FX_WSTRC(L"percent"); + break; + case FX_LOCALENUMSYMBOL_Minus: + bsSymbols = "numberSymbols"; + wsName = FX_WSTRC(L"minus"); + break; + case FX_LOCALENUMSYMBOL_Zero: + bsSymbols = "numberSymbols"; + wsName = FX_WSTRC(L"zero"); + break; + case FX_LOCALENUMSYMBOL_CurrencySymbol: + bsSymbols = "currencySymbols"; + wsName = FX_WSTRC(L"symbol"); + break; + case FX_LOCALENUMSYMBOL_CurrencyName: + bsSymbols = "currencySymbols"; + wsName = FX_WSTRC(L"isoname"); + break; + default: + return; + } + CXML_Element* pElement = m_pLocaleData->GetElement("", bsSymbols); + if (!pElement) { + return; + } + GetPattern(pElement, CFX_ByteStringC((const FX_CHAR*)bsSymbols, + bsSymbols.GetLength() - 1), + wsName, wsNumSymbol); +} +void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { + if (!m_pLocaleData) { + return; + } + CFX_ByteString bsSpace; + CXML_Element* pNumberSymbols = + m_pLocaleData->GetElement(bsSpace, "dateTimeSymbols"); + if (!pNumberSymbols) { + return; + } + wsDtSymbol = pNumberSymbols->GetContent(0); +} +void CXFA_XMLLocale::GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr) const { + wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr); +} +void CXFA_XMLLocale::GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr) const { + wsDayName = GetCalendarSymbol("day", nWeek, bAbbr); +} +void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM) const { + wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, FALSE); +} +void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const { + IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); + pProvider->GetTimeZone(tz); +} +void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { + wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, FALSE); +} +CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, + int index, + FX_BOOL bAbbr) const { + CFX_ByteString pstrSymbolNames = symbol + "Names"; + CFX_WideString wsSymbolName = L""; + if (m_pLocaleData) { + CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols"); + if (pChild) { + CXML_Element* pSymbolNames = pChild->GetElement("", pstrSymbolNames); + if (pSymbolNames) { + if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { + pSymbolNames = pChild->GetElement("", pstrSymbolNames, 1); + } + if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { + CXML_Element* pSymbolName = + pSymbolNames->GetElement("", symbol, index); + if (pSymbolName) { + wsSymbolName = pSymbolName->GetContent(0); + } + } + } + } + } + return wsSymbolName; +} +void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns"); + if (pElement == NULL) { + return; + } + CFX_WideString wsName; + switch (eType) { + case FX_LOCALEDATETIMESUBCATEGORY_Short: + wsName = L"short"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Default: + case FX_LOCALEDATETIMESUBCATEGORY_Medium: + wsName = L"med"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Full: + wsName = L"full"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Long: + wsName = L"long"; + break; + } + GetPattern(pElement, "datePattern", wsName, wsPattern); +} +void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns"); + if (pElement == NULL) { + return; + } + CFX_WideString wsName; + switch (eType) { + case FX_LOCALEDATETIMESUBCATEGORY_Short: + wsName = L"short"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Default: + case FX_LOCALEDATETIMESUBCATEGORY_Medium: + wsName = L"med"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Full: + wsName = L"full"; + break; + case FX_LOCALEDATETIMESUBCATEGORY_Long: + wsName = L"long"; + break; + } + GetPattern(pElement, "timePattern", wsName, wsPattern); +} +void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const { + CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns"); + if (pElement == NULL) { + return; + } + switch (eType) { + case FX_LOCALENUMPATTERN_Percent: + wsPattern = g_FX_Percent; + break; + case FX_LOCALENUMPATTERN_Currency: + wsPattern = g_FX_Currency; + break; + case FX_LOCALENUMPATTERN_Decimal: + wsPattern = g_FX_Decimal; + break; + case FX_LOCALENUMPATTERN_Integer: + wsPattern = g_FX_Integer; + break; + } +} +void CXFA_XMLLocale::GetPattern(CXML_Element* pElement, + const CFX_ByteStringC& bsTag, + const CFX_WideStringC& wsName, + CFX_WideString& wsPattern) const { + int32_t iCount = pElement->CountElements("", bsTag); + for (int32_t i = 0; i < iCount; i++) { + CXML_Element* pChild = pElement->GetElement("", bsTag, i); + if (pChild->GetAttrValue("name") == wsName) { + wsPattern = pChild->GetContent(0); + return; + } + } +} +CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) { + m_pLocale = pLocale; +} +CXFA_NodeLocale::~CXFA_NodeLocale() {} +void CXFA_NodeLocale::Release() { + delete this; +} +CFX_WideString CXFA_NodeLocale::GetName() { + return m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) : NULL; +} +void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const { + switch (eType) { + case FX_LOCALENUMSYMBOL_Decimal: + wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"decimal")); + break; + case FX_LOCALENUMSYMBOL_Grouping: + wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"grouping")); + break; + case FX_LOCALENUMSYMBOL_Percent: + wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"percent")); + break; + case FX_LOCALENUMSYMBOL_Minus: + wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"minus")); + break; + case FX_LOCALENUMSYMBOL_Zero: + wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"zero")); + break; + case FX_LOCALENUMSYMBOL_CurrencySymbol: + wsNumSymbol = GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"symbol")); + break; + case FX_LOCALENUMSYMBOL_CurrencyName: + wsNumSymbol = + GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"isoname")); + break; + } +} +void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { + CXFA_Node* pSymbols = + m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_DateTimeSymbols) : NULL; + wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); +} +void CXFA_NodeLocale::GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr) const { + wsMonthName = GetCalendarSymbol(XFA_ELEMENT_MonthNames, nMonth, bAbbr); +} +void CXFA_NodeLocale::GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr) const { + wsDayName = GetCalendarSymbol(XFA_ELEMENT_DayNames, nWeek, bAbbr); +} +void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM) const { + wsMeridiemName = + GetCalendarSymbol(XFA_ELEMENT_MeridiemNames, bAM ? 0 : 1, FALSE); +} +void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { + IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); + pProvider->GetTimeZone(tz); +} +void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { + wsEraName = GetCalendarSymbol(XFA_ELEMENT_EraNames, bAD ? 1 : 0, FALSE); +} +void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + switch (eType) { + case FX_LOCALEDATETIMESUBCATEGORY_Short: + wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"short")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Medium: + case FX_LOCALEDATETIMESUBCATEGORY_Default: + wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"med")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Full: + wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"full")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Long: + wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"long")); + break; + } +} +void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const { + switch (eType) { + case FX_LOCALEDATETIMESUBCATEGORY_Short: + wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"short")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Medium: + case FX_LOCALEDATETIMESUBCATEGORY_Default: + wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"med")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Full: + wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"full")); + break; + case FX_LOCALEDATETIMESUBCATEGORY_Long: + wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"long")); + break; + } +} +void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const { + switch (eType) { + case FX_LOCALENUMPATTERN_Percent: + wsPattern = g_FX_Percent; + break; + case FX_LOCALENUMPATTERN_Currency: + wsPattern = g_FX_Currency; + break; + case FX_LOCALENUMPATTERN_Decimal: + wsPattern = g_FX_Decimal; + break; + case FX_LOCALENUMPATTERN_Integer: + wsPattern = g_FX_Integer; + break; + } +} +CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, + const CFX_WideStringC& wsName) const { + CXFA_Node* pChild = + pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; + while (pChild) { + CFX_WideString wsChild; + if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { + if (wsChild == wsName) { + return pChild; + } + } + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + } + return NULL; +} +CFX_WideString CXFA_NodeLocale::GetSymbol( + XFA_ELEMENT eElement, + const CFX_WideStringC& symbol_type) const { + CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : NULL; + CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); + return pSymbol ? pSymbol->GetContent() : CFX_WideString(); +} +CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_ELEMENT eElement, + int index, + FX_BOOL bAbbr) const { + CXFA_Node* pCalendar = + m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_CalendarSymbols) : NULL; + if (pCalendar) { + CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); + for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { + if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { + CXFA_Node* pSymbol = pNode->GetChild(index, XFA_ELEMENT_UNKNOWN); + return pSymbol ? pSymbol->GetContent() : CFX_WideString(); + } + } + } + return CFX_WideString(); +} diff --git a/xfa/fxfa/parser/xfa_locale.h b/xfa/fxfa/parser/xfa_locale.h new file mode 100644 index 0000000000..522df19a82 --- /dev/null +++ b/xfa/fxfa/parser/xfa_locale.h @@ -0,0 +1,93 @@ +// 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_LOCALE_H_ +#define XFA_FXFA_PARSER_XFA_LOCALE_H_ + +#include "xfa/fgas/localization/fgas_locale.h" +#include "xfa/fxfa/parser/xfa_object.h" + +class CXFA_XMLLocale : public IFX_Locale { + public: + CXFA_XMLLocale(CXML_Element* pLocaleData); + virtual void Release(); + virtual CFX_WideString GetName(); + virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const; + + virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; + virtual void GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM = TRUE) const; + virtual void GetTimeZone(FX_TIMEZONE& tz) const; + virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; + + virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const; + + protected: + ~CXFA_XMLLocale(); + void GetPattern(CXML_Element* pElement, + const CFX_ByteStringC& bsTag, + const CFX_WideStringC& wsName, + CFX_WideString& wsPattern) const; + CFX_WideString GetCalendarSymbol(const CFX_ByteStringC& symbol, + int index, + FX_BOOL bAbbr) const; + + private: + CXML_Element* m_pLocaleData; +}; +class CXFA_NodeLocale : public IFX_Locale { + public: + CXFA_NodeLocale(CXFA_Node* pLocale); + virtual void Release(); + virtual CFX_WideString GetName(); + virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, + CFX_WideString& wsNumSymbol) const; + + virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; + virtual void GetMonthName(int32_t nMonth, + CFX_WideString& wsMonthName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetDayName(int32_t nWeek, + CFX_WideString& wsDayName, + FX_BOOL bAbbr = TRUE) const; + virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, + FX_BOOL bAM = TRUE) const; + virtual void GetTimeZone(FX_TIMEZONE& tz) const; + virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; + + virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, + CFX_WideString& wsPattern) const; + virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, + CFX_WideString& wsPattern) const; + + protected: + ~CXFA_NodeLocale(); + CXFA_Node* GetNodeByName(CXFA_Node* pParent, + const CFX_WideStringC& wsName) const; + CFX_WideString GetSymbol(XFA_ELEMENT eElement, + const CFX_WideStringC& symbol_type) const; + CFX_WideString GetCalendarSymbol(XFA_ELEMENT eElement, + int index, + FX_BOOL bAbbr) const; + + CXFA_Node* m_pLocale; +}; + +#endif // XFA_FXFA_PARSER_XFA_LOCALE_H_ diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp new file mode 100644 index 0000000000..c3ec203fa0 --- /dev/null +++ b/xfa/fxfa/parser/xfa_localemgr.cpp @@ -0,0 +1,1305 @@ +// 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/fxfa/parser/xfa_localemgr.h" + +#include "core/include/fxcodec/fx_codec.h" +#include "core/include/fxcrt/fx_xml.h" +#include "core/include/fxge/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" +#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" + +const uint8_t g_enUS_Locale[] = { + 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0x9B, 0x30, 0x14, 0x7D, 0x9F, 0xB4, + 0x7F, 0x40, 0xD6, 0x2A, 0xB5, 0x52, 0x56, 0x6F, 0x8F, 0xA9, 0x88, 0xA5, + 0x6C, 0x24, 0x9B, 0x3A, 0xD1, 0x55, 0x22, 0x55, 0xB5, 0xBE, 0x4C, 0x0E, + 0xDC, 0x05, 0x34, 0xB0, 0x23, 0x83, 0x37, 0x05, 0xED, 0xE3, 0x67, 0x07, + 0xC3, 0xC0, 0xF6, 0x24, 0xC2, 0x4B, 0x7C, 0xCF, 0x3D, 0xE7, 0xE6, 0xDE, + 0x63, 0x30, 0x84, 0x25, 0x4F, 0x69, 0x09, 0x01, 0xA3, 0x15, 0xAC, 0x10, + 0xB0, 0xEF, 0x4F, 0x09, 0x0A, 0x32, 0xA8, 0xD3, 0x15, 0xDA, 0xB0, 0x43, + 0x59, 0xD4, 0xF9, 0xF5, 0xBA, 0x02, 0x51, 0xA4, 0xF4, 0x06, 0x91, 0x50, + 0x53, 0x59, 0x46, 0x45, 0x72, 0xAA, 0xF6, 0xBC, 0xAC, 0x8D, 0xEA, 0x20, + 0xE0, 0xC0, 0x45, 0x41, 0x99, 0x62, 0x54, 0x9C, 0x35, 0xF9, 0x83, 0x82, + 0x6B, 0xB3, 0x26, 0xF7, 0x94, 0x49, 0x2A, 0x4E, 0x21, 0xEE, 0xC2, 0xD7, + 0xAF, 0x0C, 0xBE, 0x85, 0xBD, 0xF0, 0x26, 0x62, 0x2A, 0xD2, 0xDC, 0x41, + 0xD7, 0x47, 0x51, 0x94, 0x1E, 0xAE, 0xAB, 0xBF, 0x97, 0x0C, 0x3C, 0x60, + 0xE9, 0x32, 0xD7, 0xF2, 0x20, 0xEB, 0xC6, 0x81, 0x13, 0x38, 0x36, 0x50, + 0xED, 0x41, 0x38, 0x99, 0xAF, 0x69, 0xC3, 0x7D, 0xF8, 0x03, 0xFF, 0xE5, + 0x17, 0x44, 0x90, 0xDA, 0x09, 0x3C, 0xB2, 0xA8, 0xE7, 0x9D, 0xA3, 0x80, + 0xEE, 0xF7, 0x62, 0x85, 0xDE, 0xA3, 0x91, 0x73, 0x3E, 0xD7, 0x7C, 0x86, + 0xF9, 0xEC, 0x9A, 0x6B, 0x96, 0xCF, 0x2B, 0x9F, 0x55, 0x3E, 0x9F, 0x7C, + 0x0E, 0xF9, 0xDC, 0xF1, 0x19, 0xF3, 0x7F, 0x4F, 0x32, 0x7A, 0x32, 0xB7, + 0x90, 0x5A, 0x91, 0x44, 0xAA, 0x5B, 0x4E, 0x75, 0xAE, 0xD7, 0x5D, 0x92, + 0xC4, 0xDC, 0x81, 0x76, 0x12, 0x6A, 0x1B, 0x7B, 0x86, 0x8C, 0xB9, 0xE8, + 0x2E, 0x97, 0xC2, 0x01, 0xB7, 0xA2, 0xB0, 0xA1, 0x84, 0x36, 0x52, 0x8C, + 0x41, 0x3C, 0xF4, 0x35, 0xEA, 0x71, 0xB4, 0x6B, 0xA6, 0x59, 0xBB, 0x53, + 0xBB, 0x4D, 0xBB, 0x45, 0xBB, 0x39, 0xBB, 0x2F, 0xBB, 0x29, 0x7F, 0x3F, + 0xFA, 0x21, 0xCD, 0x0A, 0xA8, 0xFA, 0x67, 0xCF, 0x84, 0x64, 0x1D, 0x2B, + 0x77, 0xFB, 0x60, 0xC4, 0x23, 0x8F, 0x56, 0x02, 0x4F, 0x2B, 0x28, 0x04, + 0x04, 0x35, 0xD5, 0xD4, 0x8A, 0x7C, 0xF8, 0x18, 0x62, 0xFD, 0xDB, 0x25, + 0xC8, 0x3A, 0x1A, 0x42, 0x3C, 0x10, 0x75, 0x60, 0x9D, 0x11, 0x5D, 0xE3, + 0x0D, 0x3C, 0xD2, 0xA6, 0x01, 0xC1, 0xCE, 0x7B, 0x3A, 0x44, 0xE6, 0x00, + 0xF9, 0x21, 0xCB, 0x12, 0x91, 0x8D, 0xBA, 0x16, 0x41, 0xAC, 0xAE, 0x20, + 0x5A, 0x04, 0xDF, 0xD4, 0xA5, 0x27, 0x1C, 0xB8, 0x56, 0x21, 0x23, 0x2D, + 0x39, 0x3B, 0x20, 0x72, 0xA1, 0xA8, 0x82, 0xEC, 0xAC, 0xB9, 0x40, 0x52, + 0xE7, 0x5C, 0x34, 0x4A, 0x84, 0x23, 0xEC, 0xE1, 0xE3, 0xC9, 0x84, 0x0A, + 0x68, 0x8A, 0x6A, 0x34, 0xF1, 0x28, 0x9A, 0x4C, 0x9C, 0xDF, 0xC5, 0xF1, + 0x5D, 0x92, 0x04, 0xEB, 0xE0, 0x25, 0xC4, 0x23, 0x92, 0x55, 0x61, 0x32, + 0xEA, 0x65, 0x9A, 0xF3, 0xA4, 0x83, 0x64, 0x86, 0xC0, 0xCC, 0xA9, 0x25, + 0x1E, 0x3E, 0x9E, 0xCC, 0x65, 0x8C, 0xDA, 0x29, 0xAC, 0xDF, 0xEC, 0x4F, + 0xA7, 0x38, 0xFB, 0xF9, 0xB9, 0xAA, 0x93, 0x4D, 0xB4, 0xFD, 0xFD, 0x4C, + 0xF3, 0x2F, 0xED, 0x4B, 0x67, 0xCE, 0x98, 0xA4, 0x74, 0x4C, 0xEA, 0x53, + 0xF1, 0x9F, 0x43, 0x93, 0xD8, 0xB4, 0xA2, 0x30, 0xFD, 0xE2, 0x41, 0xA4, + 0x5D, 0xB4, 0xED, 0xF2, 0xB6, 0x6D, 0xDB, 0x10, 0x4F, 0x78, 0x4E, 0x21, + 0x23, 0x4C, 0xA5, 0x10, 0xC0, 0xD2, 0x13, 0x22, 0x6F, 0x3A, 0xE9, 0x72, + 0xF9, 0xE7, 0x7A, 0x58, 0xDE, 0xCC, 0xAC, 0x72, 0x04, 0x91, 0x02, 0x6B, + 0xCC, 0xDF, 0x5F, 0x79, 0x54, 0xD8, 0x9A, 0x62, 0x28, 0xD4, 0x0F, 0x3A, + 0x09, 0x4D, 0xD9, 0x0C, 0xD2, 0xA2, 0xA2, 0x6A, 0xF3, 0x6F, 0x7B, 0x7D, + 0x97, 0xB6, 0xD5, 0xC3, 0xBB, 0x95, 0xCB, 0x63, 0xA1, 0x37, 0x7E, 0x31, + 0x8B, 0x3F, 0x74, 0x7D, 0x35, 0x8B, 0x5E, 0x15, 0x4C, 0xD6, 0x88, 0xBC, + 0x9D, 0x45, 0x6E, 0x41, 0x70, 0x44, 0xDE, 0xB9, 0x5C, 0x3C, 0x1D, 0x5B, + 0x21, 0xFD, 0x16, 0x0C, 0x4E, 0x4C, 0x81, 0xFE, 0x66, 0x3B, 0x07, 0x6A, + 0x9B, 0xD4, 0xA9, 0x31, 0xC9, 0xBB, 0x25, 0x8C, 0xA2, 0xA8, 0xB9, 0x5E, + 0x20, 0xF2, 0x94, 0x44, 0xB3, 0x45, 0x63, 0xCB, 0x5D, 0x09, 0xB6, 0x7B, + 0xD5, 0x58, 0xF7, 0x55, 0xA4, 0x96, 0x7F, 0x01, 0x75, 0x37, 0x1B, 0x8B, +}; +const uint8_t g_enGB_Locale[] = { + 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0xD3, 0x30, 0x14, 0x7D, 0x47, 0xE2, + 0x1F, 0xA2, 0x88, 0x49, 0x20, 0x6D, 0x33, 0x3C, 0x6E, 0xEA, 0x2C, 0x75, + 0xEB, 0xD6, 0x32, 0xC8, 0xA8, 0x48, 0xC5, 0xC4, 0x5E, 0x90, 0x9B, 0x78, + 0x8D, 0x59, 0x62, 0x57, 0x4E, 0xCC, 0x94, 0xFC, 0x02, 0x9F, 0xC0, 0x23, + 0xCF, 0x08, 0xF1, 0x01, 0xBC, 0xF0, 0x2F, 0x48, 0xFB, 0x0C, 0x6E, 0x1A, + 0x27, 0x4B, 0x1C, 0xAF, 0x64, 0x79, 0x89, 0xEF, 0xB9, 0xE7, 0xDC, 0xDE, + 0x7B, 0x9C, 0xB8, 0x19, 0xC5, 0x22, 0x20, 0x31, 0x75, 0x38, 0x49, 0xE8, + 0x91, 0x4B, 0xF9, 0xA7, 0xE9, 0xB1, 0xEB, 0x84, 0x34, 0x0D, 0x8E, 0xDC, + 0xBB, 0xAF, 0xBF, 0xEE, 0x7E, 0xFE, 0x78, 0x0E, 0xB7, 0xBF, 0xDF, 0x7E, + 0xBF, 0x70, 0xF1, 0xA8, 0x24, 0xF2, 0x90, 0x48, 0x3F, 0x4F, 0x96, 0x22, + 0x4E, 0xB5, 0x66, 0x25, 0xE9, 0x4A, 0x48, 0x46, 0x38, 0x30, 0x12, 0xC1, + 0xB3, 0xE8, 0x02, 0xE0, 0x54, 0xAF, 0xF1, 0x39, 0xE1, 0x8A, 0xC8, 0x7C, + 0x84, 0xAA, 0xF0, 0xE9, 0x13, 0x8D, 0x9F, 0xD1, 0xA5, 0xB4, 0x26, 0x3C, + 0x22, 0x83, 0xA8, 0x87, 0x8E, 0xD7, 0x92, 0xC5, 0x16, 0x6E, 0x5F, 0x7F, + 0xAE, 0x38, 0xB5, 0x80, 0x71, 0x9F, 0x39, 0x56, 0x2B, 0x95, 0x66, 0x3D, + 0xD8, 0xA7, 0xEB, 0x8C, 0x26, 0x4B, 0x2A, 0x7B, 0x99, 0x77, 0x41, 0x26, + 0x6C, 0xF8, 0x85, 0xF8, 0x62, 0x17, 0x4C, 0x68, 0x60, 0x26, 0x50, 0xCB, + 0xA2, 0x9A, 0xB7, 0x89, 0x1C, 0xB2, 0x5C, 0xCA, 0x23, 0xF7, 0x95, 0xDB, + 0x72, 0xCE, 0xE6, 0x9A, 0xCD, 0x30, 0x9B, 0x5D, 0x43, 0xCD, 0xB2, 0x79, + 0x65, 0xB3, 0xCA, 0xE6, 0x93, 0xCD, 0x21, 0x9B, 0x3B, 0x36, 0x63, 0x1E, + 0xF6, 0x24, 0x24, 0xB9, 0x7E, 0x84, 0x60, 0x85, 0x7D, 0x05, 0x8F, 0x1C, + 0x74, 0x5E, 0xAE, 0xAB, 0x24, 0xF6, 0x44, 0x0F, 0x5A, 0x28, 0x9A, 0x9A, + 0xD8, 0x25, 0x0D, 0x79, 0x1F, 0x5D, 0x44, 0x4A, 0xF6, 0xC0, 0x33, 0xC9, + 0x4C, 0xC8, 0x27, 0x99, 0x92, 0x6D, 0x10, 0x35, 0x7D, 0xB5, 0x7A, 0x6C, + 0xED, 0x9A, 0x6E, 0xD6, 0xEC, 0xD4, 0x6C, 0xD3, 0x6C, 0xD1, 0x6C, 0xCE, + 0xEC, 0xCB, 0x6C, 0xCA, 0xDE, 0x4F, 0x42, 0x61, 0x02, 0x46, 0x93, 0xFA, + 0xDD, 0xD3, 0x21, 0x1E, 0x7B, 0xE0, 0x6E, 0x1D, 0xB4, 0x78, 0x78, 0x6E, + 0x24, 0x50, 0xB7, 0x02, 0x20, 0x54, 0x12, 0x5D, 0x0D, 0x56, 0xF8, 0xF8, + 0x64, 0x84, 0xCA, 0x7B, 0x95, 0xC0, 0xE3, 0x49, 0x13, 0xA2, 0x86, 0x58, + 0x06, 0xC6, 0x19, 0x51, 0x35, 0x9E, 0xD1, 0x39, 0xC9, 0x32, 0x2A, 0xF9, + 0x66, 0x4F, 0x9B, 0x48, 0x1F, 0x20, 0xD7, 0x2A, 0x8E, 0x5D, 0x7C, 0x0A, + 0xD7, 0xAE, 0x33, 0x71, 0x3C, 0xB8, 0x9C, 0x8F, 0x70, 0x95, 0x03, 0x36, + 0x54, 0xA3, 0x8E, 0x56, 0xC6, 0x82, 0xAF, 0x5C, 0xFC, 0x38, 0x4D, 0x42, + 0x43, 0x2D, 0x19, 0xAA, 0x48, 0x23, 0x21, 0x33, 0xD0, 0x4C, 0x90, 0xE7, + 0x21, 0xAB, 0x06, 0x75, 0x46, 0x04, 0x20, 0x63, 0x49, 0x6B, 0xE4, 0x56, + 0xD4, 0x19, 0x79, 0x36, 0x3B, 0xF4, 0xBC, 0x43, 0xDF, 0x77, 0xAE, 0x46, + 0xA8, 0xC5, 0x31, 0x0A, 0x74, 0x66, 0x7D, 0x94, 0x64, 0x33, 0x6A, 0xAD, + 0x18, 0xC0, 0xD7, 0x83, 0x6E, 0x14, 0x3D, 0x3A, 0xEA, 0xCC, 0xA4, 0x8D, + 0x5A, 0x00, 0x56, 0xEF, 0xF4, 0x34, 0xF7, 0xC2, 0x9B, 0x59, 0x92, 0xFA, + 0xA7, 0x93, 0xB3, 0xDB, 0x4B, 0x12, 0xBD, 0x29, 0xAE, 0x2A, 0x63, 0xDA, + 0x24, 0xD0, 0x71, 0x55, 0x1E, 0x89, 0xF7, 0xEE, 0x74, 0x62, 0xDD, 0x09, + 0x60, 0xF0, 0x38, 0x06, 0x2E, 0x2E, 0x76, 0x8B, 0xE2, 0x60, 0xBF, 0x28, + 0x8A, 0x11, 0xEA, 0xF0, 0x7A, 0x85, 0xB4, 0x30, 0x50, 0x52, 0x52, 0x1E, + 0xE4, 0x2E, 0x7E, 0x56, 0x49, 0x0F, 0x0E, 0x06, 0x2A, 0xD7, 0x54, 0x06, + 0x94, 0x67, 0xFA, 0x27, 0x77, 0x2C, 0x2A, 0x64, 0x74, 0xDE, 0x14, 0xAA, + 0x87, 0xEB, 0x84, 0xBA, 0x6C, 0x48, 0x03, 0x96, 0x10, 0xD8, 0xEC, 0xFD, + 0x5A, 0x5F, 0xA5, 0x4D, 0x75, 0xF3, 0x67, 0x2A, 0xD4, 0x9A, 0x95, 0x3B, + 0xBD, 0x3B, 0x88, 0xDF, 0x74, 0xBD, 0x33, 0x88, 0x9E, 0x30, 0xAE, 0x52, + 0x17, 0xEF, 0x0D, 0x22, 0x17, 0x54, 0x0A, 0x17, 0xBF, 0xEC, 0x73, 0x51, + 0x77, 0x6C, 0x40, 0x6A, 0xDB, 0x1B, 0x27, 0xBA, 0x40, 0xFD, 0x7C, 0x6D, + 0x02, 0x17, 0xFF, 0xF9, 0x0E, 0xE7, 0x44, 0x87, 0xD0, 0xAF, 0xA1, 0x25, + 0x2C, 0x15, 0xE5, 0xC2, 0xC5, 0xD3, 0xE3, 0xF9, 0x60, 0x51, 0xDB, 0xF3, + 0xBE, 0x04, 0x99, 0xCD, 0x96, 0xEF, 0x42, 0xBE, 0xA6, 0xD7, 0x24, 0x28, + 0x0F, 0xBB, 0x7A, 0xA9, 0x6B, 0x79, 0x39, 0x7C, 0xDA, 0x84, 0xCE, 0x1C, + 0xAC, 0x40, 0x6D, 0x66, 0x9D, 0x66, 0x9C, 0x09, 0xFE, 0x60, 0xFA, 0x44, + 0x28, 0xC9, 0xA8, 0x74, 0xFC, 0x2C, 0xB4, 0xE6, 0xC7, 0x21, 0x7C, 0x50, + 0x38, 0x73, 0xF6, 0x1F, 0xC2, 0x0C, 0x3E, 0x96, 0xE8, 0xED, 0x16, 0xC2, + 0x58, 0x92, 0x25, 0xBC, 0x2E, 0x0F, 0x13, 0x16, 0x11, 0x61, 0xD6, 0xF4, + 0x1B, 0x51, 0xA8, 0x1B, 0xE2, 0x4C, 0x45, 0x16, 0xB1, 0xA0, 0x9C, 0x63, + 0xEF, 0xC3, 0x6B, 0xC7, 0xDB, 0x46, 0x85, 0x91, 0x83, 0x48, 0xD4, 0xD4, + 0xF7, 0x5B, 0x7E, 0x14, 0x98, 0xAB, 0x72, 0x32, 0xE7, 0xED, 0x16, 0x92, + 0x2F, 0x06, 0x90, 0xBC, 0x5C, 0xF1, 0xD5, 0x67, 0xB1, 0xE1, 0xE9, 0xE6, + 0xD0, 0xFD, 0x9E, 0x95, 0x51, 0xF5, 0x19, 0x0B, 0xCB, 0x7F, 0x8E, 0x69, + 0xAC, 0xD0}; +const uint8_t g_zhCN_Locale[] = { + 0x78, 0x9C, 0xED, 0x56, 0x41, 0x4F, 0xD4, 0x40, 0x14, 0xBE, 0x9B, 0xF8, + 0x1F, 0x9A, 0x46, 0x52, 0x4D, 0x58, 0x46, 0x8F, 0x90, 0xD2, 0x64, 0x03, + 0x08, 0x06, 0xBB, 0x21, 0x96, 0x68, 0xE0, 0x62, 0xBA, 0xED, 0xB0, 0x2D, + 0x6C, 0x3B, 0x64, 0xB6, 0x0D, 0x6E, 0x4F, 0x18, 0x82, 0x82, 0xC2, 0x45, + 0x89, 0x9A, 0x80, 0xE1, 0x64, 0x3C, 0x28, 0x9E, 0x8C, 0x01, 0x22, 0xF1, + 0xCF, 0xB0, 0xCB, 0x91, 0xBF, 0xE0, 0x9B, 0xED, 0xB4, 0xB4, 0xDD, 0xD9, + 0xB5, 0x3F, 0xC0, 0x3D, 0xCD, 0xFB, 0xDE, 0xF7, 0x7D, 0xF3, 0xDE, 0xEB, + 0x74, 0xB6, 0x6A, 0x93, 0x58, 0x66, 0x13, 0x4B, 0xBE, 0xE9, 0xE1, 0x49, + 0x39, 0x72, 0x9E, 0x4F, 0xD5, 0x64, 0xC9, 0xC6, 0x2D, 0x6B, 0x52, 0xBE, + 0x3C, 0x3D, 0xE9, 0x7E, 0x78, 0x7D, 0xF7, 0xEA, 0xC7, 0xE6, 0xE5, 0xC5, + 0xFB, 0xEB, 0xDF, 0x7B, 0x10, 0x77, 0x0E, 0x2F, 0xEE, 0xC9, 0x9A, 0xCA, + 0x14, 0xBE, 0x6D, 0x52, 0xA3, 0xED, 0xD5, 0x49, 0xB3, 0xC5, 0xC5, 0x0D, + 0x8A, 0x1B, 0x84, 0xBA, 0xA6, 0x0F, 0x0C, 0x8F, 0xF8, 0x81, 0x53, 0x03, + 0xB8, 0xC5, 0xD7, 0xDA, 0xE5, 0xE9, 0x66, 0xF7, 0x68, 0x47, 0x45, 0x71, + 0x74, 0xFB, 0x56, 0x02, 0x9F, 0xEF, 0x09, 0xE1, 0xD3, 0x5D, 0x11, 0xDC, + 0x39, 0x3C, 0x14, 0x9B, 0x1C, 0x08, 0xD9, 0xDB, 0x27, 0x62, 0xEF, 0x2D, + 0x31, 0xFB, 0x9B, 0x90, 0x7D, 0xF6, 0x59, 0xC8, 0xDE, 0x7F, 0x39, 0x00, + 0x1E, 0xD0, 0x28, 0xCB, 0x14, 0x7B, 0x45, 0x99, 0x31, 0x25, 0xC4, 0x5E, + 0x24, 0x99, 0xF5, 0x3A, 0x9D, 0x94, 0x1F, 0xC8, 0xFF, 0xA7, 0x57, 0x7A, + 0x7A, 0xB6, 0xD9, 0xE6, 0x07, 0x0E, 0x56, 0x5A, 0xF7, 0xD3, 0x71, 0xF7, + 0xE8, 0xB8, 0xFB, 0xF1, 0x8B, 0x8A, 0x58, 0x18, 0xE7, 0x39, 0x0A, 0x7B, + 0x88, 0xD0, 0xF3, 0x3D, 0x21, 0x77, 0x57, 0x80, 0xC2, 0x24, 0x85, 0x0E, + 0x07, 0x22, 0xEE, 0xF6, 0x49, 0x8A, 0xA2, 0xB4, 0xC8, 0x4C, 0xC1, 0x99, + 0x87, 0xDD, 0x53, 0x15, 0x6A, 0x2E, 0x56, 0x5B, 0xAC, 0xB3, 0x58, 0x61, + 0xB1, 0xB6, 0x62, 0x55, 0x03, 0xEB, 0xF1, 0x30, 0x75, 0x6D, 0x17, 0x7B, + 0xC9, 0x6B, 0xCB, 0x43, 0xD8, 0xE0, 0x4D, 0x67, 0x9F, 0x0D, 0x3E, 0x01, + 0x32, 0x5C, 0x48, 0xBE, 0xED, 0x4B, 0xA2, 0xBC, 0x13, 0x20, 0x98, 0x9A, + 0xDC, 0x15, 0x56, 0x50, 0xC1, 0xF7, 0xCE, 0xF6, 0x56, 0x67, 0x77, 0x5F, + 0x45, 0x2C, 0x8C, 0xF3, 0x1C, 0x4D, 0x21, 0x94, 0x6A, 0x58, 0x50, 0xB8, + 0x71, 0xE2, 0x5E, 0x02, 0xBC, 0x60, 0x06, 0x01, 0xA6, 0x7E, 0xEF, 0x99, + 0xA7, 0x11, 0xBF, 0x8E, 0x56, 0xC2, 0x66, 0x53, 0xD6, 0x96, 0xE0, 0xA7, + 0x74, 0xCE, 0x7E, 0x2A, 0xBA, 0x02, 0xA7, 0x47, 0x99, 0x56, 0x60, 0xBC, + 0xCA, 0x0C, 0xFC, 0x58, 0xEF, 0xA9, 0xA4, 0xE0, 0xC7, 0x1D, 0x9A, 0xC4, + 0x6F, 0x0C, 0x70, 0x28, 0xA1, 0xF6, 0xB0, 0x1D, 0x8B, 0x2B, 0x7A, 0x65, + 0xBA, 0x04, 0xBF, 0xE5, 0x10, 0x1A, 0x30, 0x85, 0x90, 0x8F, 0x72, 0xED, + 0x02, 0x10, 0xB8, 0x5E, 0xA6, 0xFD, 0x4C, 0x94, 0x6B, 0xBF, 0xEA, 0x38, + 0x50, 0xEF, 0x2F, 0x45, 0xD7, 0x95, 0xCE, 0xCE, 0x2B, 0xC5, 0x30, 0x94, + 0xAB, 0xAF, 0xEF, 0x14, 0x69, 0x59, 0x45, 0x19, 0x45, 0xC1, 0x2E, 0xD7, + 0xBD, 0xD8, 0xA0, 0x84, 0xBC, 0xD7, 0x3E, 0xA8, 0x27, 0x74, 0x7D, 0xC2, + 0x30, 0x4A, 0x08, 0x78, 0xFF, 0x55, 0xA6, 0xE8, 0xA3, 0xA3, 0x5C, 0xBB, + 0x7C, 0x7E, 0x8B, 0x80, 0x25, 0x07, 0x62, 0xD6, 0xF4, 0x57, 0xD7, 0xE6, + 0xBC, 0x96, 0x31, 0x33, 0xFD, 0x70, 0xE3, 0xD9, 0x0B, 0x67, 0x3E, 0x5A, + 0x8E, 0x67, 0x96, 0x25, 0x81, 0xCE, 0x0F, 0xBD, 0x3A, 0xA6, 0x37, 0x83, + 0xCB, 0xC5, 0xBC, 0x12, 0xC0, 0xE0, 0x00, 0x5B, 0xB2, 0x16, 0x8D, 0x46, + 0xD1, 0xF8, 0x58, 0x14, 0x45, 0x2A, 0xCA, 0xF1, 0xFA, 0x8C, 0xB8, 0xD0, + 0x0A, 0x29, 0xC5, 0xBE, 0xD5, 0x96, 0xB5, 0x3B, 0xB1, 0x74, 0x7C, 0xBC, + 0xA4, 0x72, 0x1D, 0x53, 0x0B, 0xFB, 0x01, 0xDF, 0x72, 0x44, 0xA0, 0x42, + 0x85, 0xCA, 0x53, 0xA3, 0xA4, 0xB9, 0x5C, 0xC8, 0x6D, 0x6D, 0x6C, 0xB9, + 0x9E, 0x09, 0xE7, 0x60, 0x2C, 0xD1, 0xC7, 0xE9, 0xA2, 0x3A, 0xFD, 0x07, + 0x27, 0xE1, 0xBA, 0xCB, 0x1E, 0xFB, 0x68, 0x29, 0x7E, 0x5A, 0xF5, 0x48, + 0x29, 0xBA, 0xE7, 0xFA, 0x61, 0x4B, 0xD6, 0x2A, 0xA5, 0xC8, 0x11, 0xA6, + 0x44, 0xD6, 0xEE, 0xF7, 0x73, 0x51, 0xBE, 0x6D, 0x40, 0x92, 0xB1, 0xA7, + 0x93, 0xC8, 0x03, 0xC9, 0xF9, 0xEA, 0x05, 0xB2, 0x76, 0xFD, 0x07, 0xEE, + 0xD7, 0x3C, 0xA3, 0xDF, 0x84, 0x6B, 0xDC, 0x16, 0x61, 0x0B, 0x59, 0x9B, + 0xAA, 0x2D, 0x95, 0x16, 0x65, 0x87, 0xDE, 0x2F, 0x41, 0xC5, 0x6A, 0xD9, + 0xCB, 0xD0, 0x5E, 0xC7, 0x2B, 0xA6, 0xC5, 0xEE, 0xC7, 0x64, 0xC9, 0xBD, + 0xAA, 0x36, 0xA9, 0x63, 0xC9, 0x80, 0x57, 0x51, 0x32, 0x02, 0x5B, 0x7A, + 0x2C, 0xA3, 0x2C, 0x9F, 0x93, 0xF4, 0x36, 0x7C, 0x75, 0xD9, 0xD2, 0x02, + 0x0C, 0x4C, 0x98, 0x76, 0x7D, 0x97, 0xF8, 0x03, 0xD3, 0x53, 0x24, 0xA4, + 0x2E, 0xA6, 0xCC, 0x5F, 0x98, 0x8F, 0x4B, 0x58, 0x70, 0xFF, 0x41, 0x98, + 0xC3, 0x75, 0x8A, 0x37, 0x86, 0x10, 0xAA, 0xD4, 0xAC, 0xC3, 0x4B, 0x35, + 0x98, 0xB0, 0xE8, 0x98, 0xAE, 0x30, 0x3D, 0x4F, 0xA2, 0x70, 0xCD, 0x94, + 0x66, 0x49, 0xE0, 0xB8, 0x16, 0xEB, 0xA3, 0xF2, 0xF4, 0x91, 0xA4, 0x0F, + 0xA3, 0x42, 0xCB, 0x96, 0x43, 0x12, 0xEA, 0x93, 0x21, 0x9B, 0x02, 0x73, + 0xD8, 0x68, 0x39, 0xA9, 0x1D, 0xFA, 0x8D, 0x55, 0xD2, 0xE3, 0xF1, 0x7D, + 0xD1, 0xCD, 0x33, 0x63, 0x51, 0xFC, 0x15, 0x0D, 0xCB, 0xBF, 0xC0, 0xE4, + 0x3D, 0x40}; +const uint8_t g_zhTW_Locale[] = { + 0x78, 0x9C, 0xED, 0x57, 0xCD, 0x4F, 0xD4, 0x40, 0x14, 0x3F, 0x63, 0xE2, + 0xFF, 0x30, 0x69, 0x20, 0xD5, 0x04, 0xA8, 0x1E, 0x21, 0xA5, 0xC9, 0xC6, + 0x45, 0x30, 0x58, 0x42, 0xEC, 0x46, 0x22, 0x17, 0x33, 0xDB, 0x0E, 0xDB, + 0xC2, 0xB6, 0x43, 0x66, 0xDB, 0xC0, 0xF6, 0x24, 0x12, 0x14, 0x14, 0x62, + 0xA2, 0xC4, 0x8F, 0x80, 0xE1, 0x64, 0x3C, 0x28, 0x89, 0x07, 0x0F, 0x2C, + 0x51, 0xFF, 0x1A, 0x76, 0x39, 0xFA, 0x2F, 0x38, 0xD3, 0x2F, 0xFA, 0xB1, + 0xB3, 0xD4, 0xC4, 0xA3, 0x7B, 0x9A, 0xF7, 0xDE, 0xEF, 0xF7, 0xE6, 0xBD, + 0xDF, 0xBC, 0x7D, 0xD9, 0x95, 0x9B, 0x58, 0x87, 0x4D, 0x04, 0x1C, 0x68, + 0xA3, 0x29, 0xC1, 0x37, 0x1F, 0xD7, 0x16, 0x05, 0x60, 0xA0, 0x96, 0x3E, + 0x25, 0x9C, 0x9F, 0x9E, 0xF4, 0xDE, 0x3E, 0xBF, 0x71, 0xD1, 0xD9, 0x3C, + 0xFF, 0xF9, 0xE6, 0xF7, 0x8F, 0xBD, 0xEE, 0xAB, 0x6F, 0xBD, 0xCE, 0xAF, + 0x9B, 0x82, 0x72, 0xFD, 0x1A, 0x00, 0x32, 0x63, 0x39, 0x06, 0x24, 0x5A, + 0xDB, 0xAE, 0xE3, 0x66, 0x2B, 0x4A, 0xD0, 0x20, 0xA8, 0x81, 0x89, 0x05, + 0x1D, 0x86, 0x1A, 0x02, 0xB2, 0x8D, 0x1D, 0xD7, 0x9C, 0xA7, 0xA1, 0x16, + 0xB3, 0x87, 0x42, 0x5B, 0x39, 0x3F, 0x7D, 0xD2, 0x3B, 0xDA, 0x91, 0xA5, + 0xD0, 0x4A, 0x07, 0xCE, 0xF6, 0x38, 0x81, 0xD3, 0xDD, 0xFE, 0x81, 0xEE, + 0xE1, 0x21, 0x2F, 0xD5, 0x01, 0x87, 0xB1, 0x7D, 0xC2, 0xBB, 0x63, 0x8B, + 0xC7, 0xF8, 0xC2, 0x61, 0x74, 0x3E, 0x72, 0x18, 0xFB, 0x9B, 0xDC, 0x00, + 0xB7, 0x79, 0x16, 0xCB, 0xF7, 0x0F, 0xA2, 0x73, 0x22, 0x61, 0x5A, 0x52, + 0x00, 0xEB, 0x75, 0x32, 0x25, 0xDC, 0x16, 0xFE, 0x6B, 0xFB, 0x8F, 0xB4, + 0x35, 0x60, 0x3B, 0x35, 0xAC, 0xD4, 0x52, 0x7A, 0xEF, 0x8F, 0x7B, 0x47, + 0xC7, 0xBD, 0x77, 0x9F, 0x64, 0x89, 0x99, 0x39, 0x3F, 0xBD, 0xAF, 0xBF, + 0xFF, 0x6C, 0x8F, 0x83, 0xDF, 0xED, 0xEB, 0xA7, 0x4A, 0x73, 0xF2, 0x1C, + 0xF4, 0xC7, 0x6F, 0x9F, 0x24, 0x7E, 0x10, 0x9C, 0xFA, 0x34, 0x91, 0x1B, + 0x8F, 0x80, 0x5D, 0xE8, 0xA3, 0xD8, 0x41, 0xB1, 0xF6, 0x62, 0xD5, 0xC5, + 0x7A, 0x8B, 0x95, 0x0E, 0xAC, 0xD1, 0x46, 0xC4, 0x32, 0x2C, 0x64, 0xA7, + 0x57, 0x43, 0xE4, 0xA2, 0xD7, 0xBD, 0xE8, 0xEE, 0xB3, 0x87, 0x8A, 0x1D, + 0xF9, 0xF0, 0xCB, 0x42, 0x18, 0x5C, 0x9A, 0xA9, 0x4B, 0x10, 0x81, 0xA9, + 0xFC, 0xD4, 0xA2, 0x35, 0x7D, 0xED, 0x6E, 0x6F, 0x75, 0x77, 0xF7, 0x65, + 0x89, 0x99, 0x39, 0x7F, 0xE2, 0x04, 0xC1, 0x29, 0xE6, 0xD2, 0x65, 0x27, + 0xE5, 0xB6, 0x5D, 0xE8, 0x35, 0xA0, 0x8B, 0x16, 0xA0, 0xEB, 0x22, 0xE2, + 0x24, 0xD2, 0x27, 0x9E, 0x68, 0x21, 0x2E, 0x7B, 0xCD, 0xA6, 0xA0, 0x3C, + 0xA2, 0x1F, 0xB1, 0xDB, 0xF9, 0x2E, 0xAA, 0x22, 0x9D, 0x41, 0xB1, 0x2A, + 0xD2, 0x87, 0x10, 0xA7, 0xE9, 0x87, 0xE9, 0x92, 0x50, 0x78, 0x39, 0x9A, + 0xD8, 0x69, 0x70, 0x72, 0x94, 0xE2, 0xDB, 0xC8, 0x08, 0xE9, 0x92, 0x2A, + 0x55, 0x4B, 0x31, 0x5A, 0x26, 0x26, 0x2E, 0x9F, 0x03, 0x40, 0xC6, 0x13, + 0xC9, 0xE1, 0x5A, 0x76, 0x4E, 0x8E, 0x94, 0x27, 0x23, 0x47, 0xC5, 0x34, + 0xC5, 0xDE, 0x87, 0xA7, 0xA2, 0xAA, 0x8A, 0xDD, 0x9D, 0x67, 0xA2, 0xA6, + 0x89, 0x17, 0x9F, 0x5F, 0x8B, 0x60, 0x49, 0x96, 0x52, 0x0C, 0x5E, 0x8A, + 0x50, 0x8D, 0xFE, 0x29, 0x4A, 0x25, 0x08, 0xE4, 0xA8, 0x00, 0x73, 0x52, + 0x55, 0x27, 0x35, 0xAD, 0x14, 0x25, 0xD2, 0x23, 0x24, 0xE5, 0x19, 0x4C, + 0x8D, 0x5C, 0xEF, 0xD1, 0x70, 0xD4, 0xA8, 0x37, 0x9E, 0x98, 0x19, 0xE8, + 0xAC, 0xAC, 0xCE, 0xDA, 0x2D, 0x6D, 0xBA, 0x7A, 0x77, 0x7D, 0x71, 0xC3, + 0x9C, 0xF3, 0x97, 0x42, 0x11, 0xD3, 0xA0, 0x80, 0xE9, 0x78, 0x76, 0x1D, + 0x91, 0xAC, 0x92, 0x19, 0x5F, 0x54, 0x14, 0xF5, 0xD1, 0x99, 0xD7, 0x05, + 0xC5, 0x1F, 0xF5, 0xFD, 0x89, 0x71, 0xDF, 0xF7, 0x65, 0x29, 0x83, 0xE3, + 0x53, 0x75, 0x8F, 0x10, 0xE4, 0xE8, 0x6D, 0x41, 0x19, 0x0E, 0xC9, 0x13, + 0x13, 0xA5, 0xB9, 0x6B, 0x88, 0xE8, 0xC8, 0x71, 0xA3, 0x6B, 0x47, 0x8A, + 0x3C, 0xA6, 0x47, 0xA1, 0x87, 0xA4, 0xAF, 0xCB, 0x56, 0x87, 0xB2, 0xAE, + 0x28, 0xBD, 0x81, 0x74, 0xCB, 0x86, 0x74, 0x48, 0xC6, 0xE3, 0x2C, 0x61, + 0x98, 0x4B, 0x68, 0x10, 0xEC, 0xAD, 0x59, 0x6C, 0x26, 0x46, 0x4B, 0x32, + 0x92, 0x0E, 0x46, 0x4A, 0x12, 0x6C, 0xCB, 0xF1, 0x5A, 0x82, 0x32, 0x56, + 0x12, 0xEE, 0x23, 0x82, 0x05, 0xE5, 0x56, 0x01, 0x7D, 0x29, 0x4C, 0xE6, + 0xBD, 0xE3, 0xC7, 0xC8, 0x28, 0x93, 0x75, 0xC6, 0x63, 0x18, 0x18, 0x82, + 0x32, 0x5F, 0x1B, 0xA6, 0x2B, 0x29, 0x83, 0x18, 0xC0, 0xB2, 0x5A, 0x98, + 0x1D, 0x04, 0xA5, 0xB6, 0x58, 0xFD, 0x0B, 0x5A, 0xFA, 0x21, 0x0A, 0xA4, + 0x60, 0x27, 0x16, 0xEA, 0x66, 0x4B, 0xA0, 0xBD, 0x86, 0x96, 0xA1, 0x1E, + 0xAF, 0xE0, 0xD8, 0x8C, 0x72, 0x56, 0x0C, 0x5C, 0x47, 0x40, 0xA5, 0xAF, + 0x05, 0x34, 0xD7, 0x00, 0xF7, 0x05, 0xA9, 0x2F, 0x4C, 0x6D, 0xD3, 0x9F, + 0x90, 0x06, 0x58, 0xA0, 0x32, 0x72, 0x00, 0x96, 0x63, 0x61, 0x67, 0x00, + 0xE0, 0x0E, 0xF6, 0x88, 0x85, 0x08, 0xBB, 0x85, 0x83, 0x08, 0x4B, 0x59, + 0xB0, 0xAE, 0x84, 0xCC, 0xA2, 0x3A, 0x41, 0xEB, 0x03, 0x21, 0x15, 0x02, + 0xEB, 0xF4, 0x8B, 0x38, 0x08, 0x52, 0x33, 0xA1, 0xC5, 0x01, 0xCC, 0x61, + 0xDF, 0x5B, 0x85, 0x60, 0x06, 0xBB, 0xA6, 0xA5, 0xB3, 0x9E, 0xC6, 0x1E, + 0xDE, 0x03, 0xEA, 0x60, 0x30, 0x15, 0x40, 0x37, 0x71, 0x0C, 0x7E, 0x30, + 0xF0, 0x6A, 0x0D, 0x5F, 0x21, 0x77, 0xF4, 0x2A, 0x6D, 0xCF, 0x69, 0xAC, + 0xE0, 0x00, 0x19, 0xDE, 0x1E, 0x2C, 0xB6, 0xD4, 0x7B, 0xCA, 0x52, 0xF8, + 0x67, 0x41, 0xF9, 0x03, 0x11, 0xC2, 0x4A, 0xC9}; +const uint8_t g_zhHK_Locale[] = { + 0x78, 0x9C, 0xA5, 0x57, 0x4D, 0x4F, 0x13, 0x41, 0x18, 0x3E, 0x63, 0xE2, + 0x7F, 0x98, 0x6C, 0x20, 0x0B, 0x09, 0x50, 0x8A, 0x9F, 0x25, 0xCB, 0x26, + 0x44, 0x90, 0x9A, 0x5A, 0x43, 0x2C, 0xD1, 0xC8, 0xC5, 0x6C, 0x77, 0x87, + 0xEE, 0x42, 0x77, 0x87, 0x4C, 0xB7, 0xC1, 0x6E, 0x3C, 0x88, 0x04, 0xA5, + 0x5A, 0x2E, 0x4A, 0x54, 0x02, 0x86, 0x78, 0x50, 0x0F, 0x48, 0xBC, 0x78, + 0x68, 0x89, 0xC6, 0x3F, 0x43, 0x8B, 0x9E, 0xFC, 0x0B, 0xCE, 0xEC, 0x17, + 0xFB, 0x35, 0x6D, 0x8D, 0x3D, 0xCD, 0xFB, 0xBC, 0xCF, 0xF3, 0xCE, 0xFB, + 0x3E, 0x33, 0x3B, 0x01, 0xA1, 0x8C, 0x64, 0xA9, 0x0C, 0x81, 0x21, 0xE9, + 0x70, 0x9A, 0xB3, 0xD4, 0x87, 0xD9, 0x1C, 0x07, 0x14, 0x58, 0x91, 0xA7, + 0xB9, 0xD3, 0xE6, 0x71, 0xE7, 0xCD, 0xF3, 0xE1, 0xB3, 0xD6, 0xC6, 0xE9, + 0x8F, 0xD7, 0x7F, 0xBE, 0x37, 0x7E, 0x7F, 0xDA, 0xEB, 0x34, 0xBF, 0x9E, + 0xD5, 0x5B, 0xED, 0xED, 0xA3, 0x5F, 0x1F, 0x1A, 0x9D, 0xDD, 0x9F, 0xED, + 0xC6, 0xC9, 0x08, 0x27, 0x5E, 0xBC, 0x00, 0x80, 0x40, 0x8B, 0x18, 0x8A, + 0x84, 0x0B, 0x35, 0xBD, 0x88, 0xCA, 0x15, 0xB7, 0x5E, 0x09, 0xC3, 0x12, + 0xC2, 0x9A, 0x64, 0x50, 0xD6, 0x00, 0x10, 0x74, 0x64, 0x98, 0xEA, 0x1D, + 0x92, 0xAA, 0xD0, 0x78, 0xC0, 0x89, 0xC5, 0xD3, 0xE6, 0x93, 0xCE, 0xC1, + 0xB6, 0x90, 0x72, 0xA2, 0x60, 0xE2, 0xA4, 0xC1, 0x48, 0x34, 0xEB, 0xC9, + 0x89, 0xF6, 0xFE, 0x3E, 0xAB, 0xD4, 0x2E, 0x43, 0xB1, 0x75, 0xCC, 0xDA, + 0x63, 0x93, 0xA5, 0x38, 0x62, 0x28, 0x5A, 0xEF, 0x19, 0x8A, 0x9D, 0x0D, + 0x66, 0x82, 0x39, 0x3C, 0xCD, 0x45, 0xE7, 0x07, 0xEE, 0xDA, 0xB7, 0x30, + 0x68, 0x29, 0x90, 0x8A, 0x45, 0x3C, 0xCD, 0xA5, 0xB9, 0x60, 0x95, 0x74, + 0x72, 0xF1, 0xC9, 0x64, 0xF8, 0x52, 0x32, 0x7C, 0x39, 0x19, 0xBE, 0x92, + 0x0C, 0x5F, 0x4D, 0x86, 0xAF, 0x25, 0xC3, 0xD7, 0x93, 0xE1, 0x4C, 0x32, + 0x9C, 0x9E, 0x60, 0xE0, 0x8C, 0x39, 0xD3, 0x93, 0x3D, 0x0D, 0x54, 0xA4, + 0x5A, 0xE0, 0x46, 0x92, 0x48, 0xEC, 0xBC, 0x3B, 0xEC, 0x1C, 0x1C, 0x76, + 0xDE, 0x7E, 0x14, 0x52, 0x34, 0x8C, 0xE0, 0xE4, 0xC0, 0x92, 0xF1, 0x93, + 0x06, 0x83, 0x5F, 0x4F, 0xC4, 0xC9, 0x55, 0x65, 0xD4, 0xD9, 0x4D, 0xE6, + 0x6F, 0x1D, 0xFB, 0x38, 0xB0, 0x57, 0x09, 0x43, 0x44, 0xEE, 0x80, 0xAD, + 0x8E, 0xCD, 0x11, 0x9F, 0x20, 0xDE, 0x7B, 0xBC, 0xEB, 0x78, 0xBF, 0xF1, + 0x4E, 0xBB, 0xF6, 0xA8, 0x43, 0xAC, 0x29, 0x1A, 0xD4, 0x83, 0xDF, 0xBF, + 0x0B, 0x91, 0xED, 0x5E, 0xB4, 0x77, 0xE8, 0x41, 0x79, 0x40, 0x34, 0xFD, + 0x32, 0x96, 0x06, 0xE7, 0x61, 0x60, 0x13, 0x88, 0xA5, 0x40, 0x7D, 0x12, + 0x91, 0x9E, 0xBE, 0xB4, 0xB7, 0x36, 0xDB, 0xF5, 0x1D, 0x21, 0x45, 0xC3, + 0x08, 0xEE, 0x83, 0xC0, 0x5E, 0x79, 0x5A, 0xF2, 0xA2, 0xA5, 0x22, 0x4F, + 0x9A, 0x83, 0x2A, 0x92, 0x09, 0x17, 0x24, 0xD3, 0x84, 0xD8, 0xF0, 0xAD, + 0xF7, 0x11, 0xF7, 0xD5, 0x5B, 0xAE, 0x96, 0xCB, 0x9C, 0xF8, 0x80, 0xFC, + 0xF8, 0x76, 0xEB, 0x1B, 0x9F, 0xE7, 0xC9, 0x1D, 0xE4, 0x67, 0x79, 0x72, + 0x10, 0x3C, 0x98, 0x23, 0x3F, 0x6A, 0x8C, 0xAF, 0x61, 0x15, 0x29, 0x23, + 0xA3, 0xC4, 0x28, 0xD2, 0x97, 0x5E, 0x87, 0xCA, 0xFF, 0xC8, 0x2B, 0x2A, + 0xC2, 0x26, 0x2D, 0xD0, 0x53, 0x0E, 0x40, 0x08, 0x71, 0x7D, 0x32, 0x35, + 0x3D, 0xE2, 0x53, 0x00, 0x09, 0xF9, 0x34, 0xA3, 0xAA, 0x7C, 0x67, 0xEF, + 0x29, 0x9F, 0xCF, 0xF3, 0xED, 0xED, 0x67, 0x7C, 0xA1, 0xC0, 0x9F, 0x7D, + 0x7E, 0xC5, 0x83, 0x25, 0x21, 0x15, 0x50, 0xB0, 0x4A, 0x38, 0x2E, 0x25, + 0x97, 0xE8, 0xAB, 0x80, 0x6D, 0x13, 0xD1, 0x4F, 0xE5, 0xF3, 0x53, 0x85, + 0x42, 0x5F, 0x12, 0xD7, 0x9A, 0x19, 0xAA, 0x89, 0x0A, 0xA8, 0x19, 0x91, + 0xD1, 0xDD, 0x4B, 0xB3, 0x48, 0x50, 0xEF, 0x26, 0xCD, 0x4B, 0xC6, 0xCA, + 0x6A, 0x56, 0xAF, 0x14, 0xE6, 0x66, 0x6F, 0xAE, 0xDF, 0x7F, 0xA4, 0xE6, + 0xAC, 0x25, 0xC7, 0xC3, 0x20, 0xC9, 0x56, 0x1A, 0x55, 0xBD, 0x08, 0x71, + 0xD8, 0xC8, 0x10, 0xE6, 0xF6, 0x44, 0x30, 0xF2, 0x2D, 0xC8, 0x9C, 0x68, + 0x8D, 0x5A, 0x56, 0x66, 0xDC, 0xB2, 0x2C, 0x21, 0x15, 0xE2, 0xB1, 0xA5, + 0x72, 0x15, 0x63, 0x68, 0xC8, 0x35, 0x4E, 0x1C, 0x74, 0xC4, 0x99, 0xCC, + 0xE3, 0x61, 0x7F, 0x39, 0xD2, 0x77, 0x9D, 0x35, 0x88, 0x65, 0x68, 0x98, + 0x6E, 0x0B, 0x43, 0x71, 0x1D, 0xF5, 0x26, 0x36, 0x8F, 0x3F, 0xE3, 0xF9, + 0xD8, 0x03, 0x61, 0xC8, 0x2D, 0xAF, 0x40, 0x59, 0xD3, 0x25, 0x72, 0x5F, + 0xC6, 0xBD, 0x2A, 0x4E, 0x9A, 0x29, 0x28, 0x61, 0x54, 0x5D, 0xD3, 0xE8, + 0xF5, 0x18, 0xED, 0x53, 0xE1, 0x4F, 0x30, 0xD4, 0xA7, 0x40, 0xD7, 0x8C, + 0x6A, 0x85, 0x13, 0xC7, 0xFA, 0xA4, 0x5B, 0x10, 0x23, 0x4E, 0x9C, 0x88, + 0xB1, 0xCF, 0x8D, 0x09, 0x9D, 0xBD, 0x77, 0x30, 0x21, 0x67, 0xC2, 0xA0, + 0x77, 0x23, 0xED, 0x80, 0x13, 0xB3, 0xB9, 0x41, 0xF2, 0x6C, 0x85, 0x18, + 0x5D, 0x54, 0x5A, 0x05, 0xD1, 0x05, 0x95, 0xCD, 0xFE, 0x83, 0x2C, 0x78, + 0x10, 0x31, 0x91, 0xFD, 0x6E, 0xC6, 0xFA, 0xA6, 0xEF, 0x41, 0x6D, 0x0D, + 0x2E, 0x4B, 0xB2, 0xF7, 0x4C, 0x7B, 0xA1, 0x5B, 0x73, 0x46, 0x41, 0x45, + 0x08, 0xF2, 0xE4, 0xB4, 0x40, 0xC1, 0x54, 0xC0, 0x6D, 0x2E, 0x95, 0x48, + 0xCB, 0xD7, 0xC8, 0xDF, 0x92, 0x0A, 0x58, 0x20, 0x36, 0x32, 0x08, 0x9A, + 0xA1, 0x21, 0xA3, 0x0B, 0xE1, 0x06, 0xAA, 0x62, 0x0D, 0x62, 0xBA, 0x0B, + 0x83, 0xE1, 0xB4, 0xB2, 0xA0, 0xF5, 0xA4, 0x64, 0x61, 0x11, 0xC3, 0xF5, + 0xAE, 0x94, 0x19, 0x2C, 0x15, 0xC9, 0x47, 0xD9, 0x8D, 0xB2, 0xA8, 0x4A, + 0x1A, 0x83, 0x90, 0x43, 0x56, 0x75, 0x55, 0x02, 0xF3, 0xC8, 0x54, 0x35, + 0x99, 0xCE, 0x34, 0x76, 0xEF, 0x16, 0xC8, 0x77, 0x27, 0x13, 0x03, 0x64, + 0x15, 0x79, 0xE4, 0xBB, 0x5D, 0xB7, 0x2E, 0xA0, 0x1E, 0x76, 0xBB, 0xA7, + 0x52, 0xAB, 0x1A, 0xA5, 0x15, 0x64, 0x33, 0x9D, 0xDD, 0xED, 0x47, 0x2E, + 0x70, 0x9E, 0x42, 0xCA, 0xF9, 0x27, 0x42, 0xFC, 0x0B, 0xD9, 0x0E, 0x4B, + 0xED}; +const uint8_t g_jaJP_Locale[] = { + 0x78, 0x9C, 0xED, 0x56, 0xCB, 0x6E, 0xD3, 0x40, 0x14, 0x5D, 0x17, 0x89, + 0x7F, 0x18, 0x59, 0x20, 0x83, 0xD4, 0xD6, 0x0D, 0xEF, 0x56, 0xAE, 0xA5, + 0x8A, 0x96, 0x86, 0x16, 0xA3, 0x08, 0x57, 0xA0, 0x76, 0x83, 0x26, 0xF6, + 0x34, 0x99, 0x36, 0x9E, 0xA9, 0x26, 0xB6, 0x4A, 0xBC, 0xE2, 0x21, 0x20, + 0x48, 0x74, 0x01, 0x1B, 0x04, 0x44, 0x62, 0x55, 0x40, 0x02, 0x04, 0x8B, + 0x6E, 0xD8, 0xD0, 0xAF, 0x49, 0x5A, 0x56, 0xFC, 0x02, 0x33, 0x7E, 0xC5, + 0x8E, 0xED, 0xE0, 0xEE, 0xF1, 0x22, 0x99, 0x7B, 0x7C, 0xCE, 0xF5, 0xBD, + 0xE7, 0x8E, 0x47, 0x56, 0x5B, 0xD4, 0x84, 0x2D, 0x04, 0x08, 0xB4, 0xD1, + 0xBC, 0xB4, 0x05, 0xEF, 0xAF, 0xD4, 0x24, 0x60, 0xA1, 0xB6, 0x39, 0x2F, + 0x0D, 0xDE, 0xEC, 0x1F, 0x7F, 0xFF, 0x76, 0x8E, 0xFF, 0x0D, 0x7A, 0x5F, + 0xCF, 0x4B, 0xDA, 0xE9, 0x53, 0x00, 0xA8, 0x82, 0x4C, 0x2C, 0xC8, 0x8C, + 0x8E, 0x5D, 0xA7, 0xAD, 0x76, 0xA8, 0x6B, 0x30, 0xD4, 0xA0, 0x0C, 0x43, + 0x22, 0x58, 0x13, 0x40, 0xB5, 0x29, 0x71, 0x9A, 0xB7, 0xF9, 0xAD, 0xB6, + 0x88, 0x27, 0x82, 0x58, 0xAB, 0x0C, 0x7A, 0x5D, 0x55, 0x09, 0xD6, 0x09, + 0xF8, 0x42, 0x3E, 0x7C, 0x31, 0x1F, 0xBE, 0x94, 0x0F, 0x5F, 0xCE, 0x87, + 0xAF, 0xE4, 0xC3, 0x57, 0xF3, 0xE1, 0x6B, 0xF9, 0xF0, 0x6C, 0x3E, 0x5C, + 0x99, 0x29, 0xC0, 0x0B, 0xFA, 0xAC, 0x8C, 0x34, 0x0A, 0xC2, 0x75, 0xEC, + 0x53, 0xD2, 0x37, 0x00, 0xEB, 0x75, 0x36, 0x2F, 0x55, 0xA4, 0xFF, 0x06, + 0x9E, 0xC4, 0x40, 0x0B, 0x76, 0x12, 0xDB, 0x8E, 0x47, 0x9A, 0xD8, 0xBE, + 0xEF, 0x7B, 0xFC, 0x57, 0x55, 0x44, 0x38, 0xC4, 0x7B, 0xDD, 0x5C, 0xFC, + 0xE8, 0xD1, 0x97, 0x7C, 0xFE, 0x8F, 0x83, 0x82, 0x3C, 0x9F, 0x73, 0xF1, + 0xDF, 0xCF, 0x5F, 0xE5, 0xE2, 0xFD, 0xDE, 0x87, 0x11, 0x1C, 0xF8, 0xAB, + 0x9C, 0x26, 0x46, 0xF6, 0x40, 0xD8, 0x4D, 0xB6, 0x8F, 0x6C, 0x07, 0xD9, + 0xDA, 0xB3, 0x55, 0x67, 0xEB, 0xCD, 0x56, 0x5A, 0x5C, 0xA3, 0x8D, 0x18, + 0xB6, 0x30, 0xB2, 0x93, 0x2F, 0x79, 0x08, 0x69, 0xFD, 0xBD, 0x6E, 0xFF, + 0xC5, 0x1E, 0x1F, 0x4E, 0x04, 0x64, 0x6F, 0xFF, 0x7A, 0x99, 0xBE, 0x0D, + 0x86, 0x61, 0xE2, 0x21, 0x88, 0xC1, 0x44, 0x7E, 0x1E, 0x69, 0x47, 0x07, + 0x0F, 0xFB, 0x4F, 0x9F, 0xF8, 0xD9, 0x45, 0x18, 0xE3, 0xC7, 0xFB, 0x87, + 0x83, 0x77, 0x1F, 0x63, 0x10, 0xF8, 0xAB, 0x48, 0xCB, 0x8F, 0x2D, 0x65, + 0xE4, 0xDC, 0x0A, 0x50, 0x0B, 0x3A, 0xA8, 0x06, 0x1D, 0x07, 0x31, 0x12, + 0x5B, 0x1F, 0x23, 0xE1, 0xD1, 0xB6, 0xE9, 0xB6, 0x5A, 0x92, 0xB6, 0xCE, + 0x2F, 0xB9, 0xFF, 0xF3, 0x40, 0xD6, 0x65, 0x6E, 0xB8, 0xBC, 0x28, 0xF3, + 0x41, 0xC8, 0x4B, 0xFC, 0x12, 0xBE, 0xC4, 0x92, 0xA2, 0x1C, 0x2D, 0x4A, + 0x1A, 0x05, 0x39, 0x4A, 0xE9, 0x6D, 0x64, 0x05, 0x72, 0x45, 0xD7, 0x95, + 0xC5, 0xC5, 0x52, 0x9A, 0x76, 0x93, 0x32, 0x47, 0xA8, 0xF2, 0x35, 0x00, + 0xA4, 0x90, 0xD0, 0x10, 0x07, 0xDB, 0x23, 0x86, 0x24, 0x90, 0x94, 0x21, + 0x55, 0x79, 0xF0, 0xF6, 0xB1, 0xAC, 0xEB, 0x72, 0xBF, 0xFB, 0x4C, 0x36, + 0x0C, 0xF9, 0xE8, 0xD3, 0x6B, 0x79, 0x43, 0x55, 0x12, 0xF4, 0x22, 0x7D, + 0x60, 0x46, 0x75, 0x4E, 0xD7, 0xE7, 0x0C, 0x63, 0xAE, 0x9C, 0xC6, 0x37, + 0x20, 0x94, 0x94, 0x12, 0x84, 0xDD, 0x0B, 0xC9, 0x28, 0x5F, 0x74, 0x3E, + 0xD2, 0x67, 0xB8, 0x15, 0xD6, 0x38, 0x1A, 0xED, 0x8F, 0x65, 0x48, 0xB6, + 0xB6, 0xAB, 0x76, 0xDB, 0x58, 0x5A, 0xBC, 0xB1, 0x7B, 0xEF, 0x41, 0x73, + 0xD5, 0xDB, 0x08, 0x0C, 0x4B, 0x92, 0x7C, 0x25, 0x71, 0xED, 0x3A, 0x62, + 0x69, 0xD7, 0x52, 0x58, 0x58, 0x12, 0xC7, 0xF8, 0x0E, 0x37, 0x25, 0xCD, + 0x9B, 0xF4, 0xBC, 0xD9, 0x69, 0xCF, 0xF3, 0x54, 0x25, 0xC5, 0x2B, 0x96, + 0x9A, 0x2E, 0x63, 0x88, 0x98, 0x1D, 0x49, 0x3B, 0xE3, 0x8B, 0x4B, 0x0B, + 0x77, 0x10, 0x33, 0x11, 0x71, 0xC2, 0x67, 0x9E, 0xCD, 0xEA, 0x84, 0x19, + 0x99, 0x06, 0xE2, 0xA6, 0x86, 0x7D, 0x4E, 0xA4, 0xA1, 0x30, 0xBD, 0x85, + 0x4C, 0x6C, 0x43, 0xBE, 0x1B, 0xA6, 0xA3, 0x2C, 0xC1, 0xED, 0x42, 0x41, + 0x83, 0x51, 0x77, 0x07, 0x8B, 0xF9, 0x4F, 0x96, 0x54, 0xC4, 0x1D, 0x9C, + 0x2D, 0x29, 0xB0, 0x31, 0x71, 0xDB, 0x92, 0x36, 0x55, 0x92, 0xEE, 0x21, + 0x46, 0x25, 0x6D, 0x26, 0xC3, 0x1E, 0x1A, 0x93, 0x1A, 0x76, 0x34, 0x89, + 0x94, 0x33, 0x69, 0x30, 0xDA, 0x81, 0x7E, 0x20, 0x69, 0x7F, 0x0E, 0xF9, + 0x89, 0x9D, 0x66, 0x8C, 0x51, 0xE1, 0x36, 0x15, 0x0B, 0x49, 0x5B, 0xA9, + 0xAD, 0x9F, 0x40, 0x96, 0x1C, 0x44, 0x46, 0xE4, 0x1F, 0x7F, 0x99, 0xBA, + 0xC5, 0xDB, 0xDE, 0xD9, 0x41, 0x9B, 0xD0, 0x8C, 0x4E, 0xDB, 0x28, 0x0C, + 0x73, 0xAE, 0x52, 0xCF, 0xDD, 0x86, 0x60, 0x99, 0x3A, 0x4D, 0x6C, 0x82, + 0x1A, 0xA3, 0x53, 0x77, 0x6F, 0x02, 0x5D, 0x52, 0xC6, 0x91, 0x75, 0x4C, + 0xCC, 0x26, 0x8D, 0xC8, 0x77, 0x0A, 0xC8, 0x7A, 0x87, 0x7F, 0x2A, 0x5A, + 0x82, 0x55, 0x44, 0xC0, 0x04, 0x53, 0x32, 0x86, 0x70, 0x9D, 0xBA, 0x0C, + 0x23, 0x06, 0x0C, 0xC7, 0x2A, 0x60, 0x2C, 0x58, 0xB4, 0x8E, 0x40, 0x0D, + 0xFF, 0x93, 0x52, 0x45, 0x75, 0x86, 0x76, 0xC7, 0x52, 0x16, 0x18, 0xAC, + 0xF3, 0x17, 0x77, 0x1C, 0x65, 0xAD, 0x09, 0xF1, 0x58, 0x02, 0x6F, 0xA9, + 0x21, 0x6A, 0x01, 0xB7, 0xC6, 0xD2, 0x0C, 0x5A, 0x8A, 0xA6, 0x77, 0x5C, + 0xD2, 0xD8, 0xA2, 0x3E, 0x33, 0x18, 0x89, 0x7F, 0xAA, 0x25, 0xE6, 0xA9, + 0x2A, 0xC1, 0x87, 0xBD, 0xF6, 0x17, 0x6C, 0x42, 0x08, 0x21}; +const uint8_t g_koKR_Locale[] = { + 0x78, 0x9C, 0xED, 0x56, 0x4D, 0x6B, 0xD4, 0x40, 0x18, 0x3E, 0x57, 0xF0, + 0x3F, 0x0C, 0xC1, 0x12, 0x85, 0x76, 0xB7, 0xEB, 0x77, 0x4B, 0x1A, 0x28, + 0x6E, 0x6D, 0x65, 0x8D, 0x94, 0xA6, 0x58, 0xEC, 0x45, 0x66, 0x93, 0xE9, + 0x26, 0xED, 0x26, 0x53, 0x26, 0x09, 0x75, 0x73, 0xAE, 0x52, 0xF0, 0xE2, + 0xA1, 0x87, 0xEA, 0x6E, 0xB1, 0x07, 0x11, 0x2A, 0x88, 0x22, 0x22, 0x1E, + 0x14, 0x7F, 0x8D, 0x62, 0x6D, 0x8A, 0x7F, 0xC1, 0xC9, 0xE7, 0xE6, 0x63, + 0xB2, 0x4D, 0xEF, 0xEE, 0x61, 0x99, 0xF7, 0x99, 0xE7, 0x79, 0xF3, 0xBE, + 0xCF, 0x4C, 0x5E, 0x22, 0x74, 0xB1, 0x02, 0xBB, 0x08, 0x98, 0xD0, 0x40, + 0xB3, 0xDC, 0x26, 0x7E, 0xDC, 0x5A, 0xE6, 0x80, 0x8A, 0x2C, 0x65, 0x96, + 0xFB, 0x35, 0x38, 0x38, 0xFE, 0x34, 0xF8, 0xFD, 0xE1, 0xFD, 0xE5, 0xE3, + 0xD7, 0x47, 0x3F, 0xFB, 0xDF, 0xAF, 0x70, 0xE2, 0xC5, 0x0B, 0x00, 0x08, + 0x3E, 0xDF, 0x54, 0x21, 0x91, 0x7B, 0x46, 0x1B, 0x77, 0xAD, 0x48, 0xDA, + 0x21, 0xA8, 0x83, 0x89, 0x0E, 0x4D, 0x9F, 0x35, 0x06, 0x04, 0x03, 0x9B, + 0xB6, 0xF6, 0x80, 0x6E, 0x59, 0x7E, 0x3C, 0x16, 0xC6, 0x62, 0xC3, 0xEB, + 0xEF, 0x09, 0xF5, 0x70, 0x9D, 0x82, 0xAF, 0xB2, 0xE1, 0x6B, 0x6C, 0xF8, + 0x3A, 0x1B, 0xBE, 0xC1, 0x86, 0x6F, 0xB2, 0xE1, 0x5B, 0x6C, 0xF8, 0x36, + 0x1B, 0x9E, 0x66, 0xC3, 0x8D, 0xA9, 0x12, 0xBC, 0xA4, 0xCF, 0x46, 0xAE, + 0x51, 0x10, 0xAD, 0x13, 0x9F, 0xD2, 0xBE, 0x01, 0xD8, 0x6E, 0x93, 0x59, + 0xAE, 0xC1, 0xFD, 0x37, 0xF0, 0x3C, 0x06, 0xAA, 0xB0, 0x97, 0xBA, 0x76, + 0x34, 0x12, 0xBD, 0x83, 0x6F, 0xDE, 0xAB, 0x3D, 0xFA, 0x2F, 0xD4, 0xFD, + 0x70, 0x88, 0xF7, 0xF7, 0x98, 0xF8, 0xE9, 0x4B, 0x36, 0xEE, 0xED, 0xEE, + 0x33, 0xF1, 0x93, 0x77, 0x47, 0x4C, 0xFC, 0xCF, 0xD7, 0x5D, 0x76, 0xFE, + 0x67, 0x87, 0x39, 0x1C, 0x04, 0x2B, 0x46, 0x13, 0xB9, 0x3B, 0x10, 0x75, + 0x53, 0xEC, 0xA3, 0xD8, 0x41, 0xB1, 0xF6, 0x62, 0xD5, 0xC5, 0x7A, 0x8B, + 0x95, 0x96, 0xD7, 0x68, 0x20, 0xA2, 0xAB, 0x3A, 0x32, 0xD2, 0x2F, 0x79, + 0x04, 0x89, 0xDE, 0xFE, 0x1B, 0xEF, 0x70, 0x87, 0x1E, 0x4E, 0x0C, 0x14, + 0xB6, 0x4F, 0xFB, 0xB9, 0x6D, 0x30, 0x0C, 0x53, 0x0F, 0x41, 0x04, 0xA6, + 0xF2, 0xD3, 0x88, 0x56, 0xF9, 0xD1, 0xEB, 0xBF, 0x08, 0xB2, 0xFB, 0x61, + 0x82, 0x7B, 0x3B, 0x03, 0xBA, 0x95, 0x80, 0x20, 0x58, 0xC5, 0x5A, 0x3A, + 0xB6, 0xEA, 0xB9, 0xB9, 0x15, 0xA2, 0x2A, 0xB4, 0xD1, 0x12, 0xB4, 0x6D, + 0x44, 0xCC, 0xC4, 0xFA, 0x04, 0x89, 0x46, 0xDB, 0xBA, 0xD3, 0xED, 0x72, + 0xE2, 0x23, 0xFA, 0xE3, 0x4F, 0x9E, 0xEE, 0xF0, 0x40, 0xE2, 0xA9, 0xE3, + 0x3C, 0x68, 0xF2, 0xF4, 0x28, 0x78, 0x30, 0x4F, 0x7F, 0xBE, 0x35, 0x89, + 0xAA, 0x2C, 0x4D, 0x17, 0x9B, 0x9D, 0xD2, 0x34, 0x95, 0x32, 0x18, 0x48, + 0x0D, 0x13, 0xD4, 0x80, 0x24, 0xD5, 0x40, 0xB3, 0x59, 0x49, 0x65, 0x69, + 0x98, 0xD8, 0xBE, 0xAE, 0x4C, 0x05, 0x40, 0x06, 0x89, 0x9C, 0xB1, 0x75, + 0x23, 0xE7, 0x4C, 0x0A, 0xC9, 0x38, 0x33, 0x07, 0x34, 0x8D, 0xF7, 0x9E, + 0x0F, 0x68, 0x4B, 0x12, 0x7F, 0xF2, 0x85, 0xB6, 0x26, 0xCB, 0xBC, 0xF7, + 0x79, 0x97, 0x07, 0x6B, 0x42, 0x3D, 0x25, 0x2A, 0xCB, 0x12, 0x1A, 0x53, + 0x9A, 0xA5, 0x52, 0x8E, 0xC0, 0x1A, 0x9A, 0x62, 0x46, 0x92, 0x66, 0x64, + 0xB9, 0x92, 0x24, 0xF2, 0x25, 0x14, 0xE5, 0x15, 0xBE, 0x27, 0x39, 0x07, + 0xA2, 0xDB, 0xB2, 0x42, 0xD1, 0xF8, 0x0A, 0x2D, 0x40, 0x73, 0x63, 0x73, + 0xD1, 0xB0, 0xE4, 0xF9, 0xE6, 0xDD, 0xED, 0xD5, 0x27, 0x5A, 0xCB, 0x5D, + 0x0B, 0xAD, 0x4C, 0x93, 0x02, 0xA5, 0xE9, 0x18, 0x6D, 0x44, 0xB2, 0x7E, + 0x66, 0xB0, 0xA8, 0x28, 0x8A, 0xD1, 0x97, 0x40, 0xE1, 0x44, 0x77, 0xC2, + 0x75, 0xA7, 0x6B, 0xAE, 0xEB, 0x0A, 0xF5, 0x0C, 0xAF, 0x5C, 0xAA, 0x38, + 0x84, 0x20, 0x53, 0xE9, 0x71, 0xE2, 0xA5, 0x40, 0x5C, 0x59, 0xB8, 0x85, + 0x88, 0x82, 0x4C, 0x3B, 0x7A, 0xE6, 0x78, 0x51, 0xE7, 0x9B, 0x51, 0x68, + 0x20, 0x69, 0x6A, 0xD8, 0xE7, 0x58, 0x16, 0x8A, 0xD2, 0xAB, 0x48, 0xD1, + 0x0D, 0x48, 0xEF, 0x49, 0x2D, 0xCE, 0x12, 0x6E, 0x97, 0x0A, 0x3A, 0x04, + 0x3B, 0x5B, 0xBA, 0x7F, 0x27, 0x26, 0x2A, 0x2A, 0x92, 0x0E, 0xC6, 0x2B, + 0x0A, 0x0C, 0xDD, 0x74, 0x2C, 0x4E, 0x9C, 0xAC, 0x48, 0x77, 0x11, 0xC1, + 0x9C, 0x38, 0x55, 0x60, 0x0F, 0x8D, 0xC9, 0x1C, 0x76, 0x7C, 0x12, 0x19, + 0x67, 0xB2, 0x60, 0x7C, 0x07, 0x83, 0x80, 0x13, 0xFF, 0xFE, 0x78, 0x4B, + 0x07, 0x54, 0x86, 0x31, 0x42, 0xA5, 0x5B, 0xD8, 0x5F, 0x70, 0x62, 0x6B, + 0x79, 0xF5, 0x1C, 0xB2, 0xF4, 0x41, 0x14, 0x44, 0xC1, 0x84, 0x2C, 0xD4, + 0xED, 0xCF, 0x81, 0xDE, 0x16, 0x5A, 0x87, 0x4A, 0x3C, 0x90, 0xE3, 0x30, + 0xCA, 0x39, 0xA7, 0xE2, 0x36, 0x02, 0x52, 0xCF, 0x31, 0x3B, 0x1B, 0x18, + 0xC8, 0xB6, 0x0A, 0x24, 0xAE, 0xCE, 0x64, 0x4A, 0x3D, 0xFA, 0x75, 0xA8, + 0x82, 0x25, 0xEA, 0x64, 0x09, 0x41, 0x37, 0x75, 0x6C, 0x8E, 0x20, 0xDC, + 0xC1, 0x0E, 0xD1, 0x11, 0xF1, 0x9F, 0x52, 0xC2, 0x08, 0xAB, 0x59, 0xD2, + 0xCF, 0xA4, 0x2C, 0xA2, 0x36, 0x41, 0xDB, 0x23, 0x29, 0x73, 0x04, 0xB6, + 0xE9, 0x8B, 0x38, 0x8A, 0xB2, 0xA2, 0x41, 0xBD, 0x84, 0xD0, 0xC2, 0xAE, + 0xB3, 0x09, 0xC1, 0x02, 0xB6, 0x35, 0x5D, 0xF1, 0x7B, 0x9A, 0x7C, 0x78, + 0xAF, 0xD4, 0x9A, 0x88, 0x4C, 0x0D, 0x50, 0x34, 0x1C, 0x93, 0x97, 0x47, + 0x3E, 0x9A, 0x72, 0x3B, 0x81, 0xDD, 0xF7, 0x47, 0xD2, 0x64, 0x9C, 0xA1, + 0x05, 0x53, 0x2D, 0x75, 0x9E, 0x42, 0x3D, 0xFC, 0xFC, 0x17, 0xFF, 0x01, + 0xDC, 0xF1, 0x18, 0xD3}; +const uint8_t g_esES_Locale[] = { + 0x78, 0x9C, 0x9D, 0x56, 0xCF, 0x6B, 0xD4, 0x40, 0x14, 0xBE, 0x0B, 0xFE, + 0x0F, 0x21, 0x58, 0x56, 0xA1, 0xDD, 0xD1, 0x63, 0xCB, 0x36, 0x50, 0xDA, + 0xDA, 0x95, 0x1A, 0x59, 0x9A, 0xAA, 0xD8, 0x8B, 0x4C, 0x92, 0xE9, 0xEE, + 0xB4, 0xC9, 0xCC, 0x32, 0x49, 0x2C, 0x9B, 0xA3, 0xE0, 0x41, 0x10, 0x0B, + 0xDE, 0x8A, 0x27, 0x0F, 0x1E, 0x04, 0x8B, 0x77, 0x51, 0x3C, 0xF4, 0x3F, + 0x11, 0x6A, 0xEB, 0xC9, 0x7F, 0xC1, 0x37, 0x9B, 0x49, 0x36, 0x3F, 0x66, + 0xD7, 0x60, 0x4E, 0xF3, 0xBE, 0xF7, 0x7D, 0x2F, 0xEF, 0x7D, 0x93, 0x4C, + 0xD2, 0x0B, 0xB8, 0x87, 0x03, 0x62, 0x30, 0x1C, 0x92, 0x75, 0x93, 0x44, + 0xCF, 0xB7, 0x1D, 0xD3, 0xF0, 0x49, 0xE4, 0xAD, 0x9B, 0xD7, 0x1F, 0x7F, + 0x5C, 0x9D, 0x9E, 0x5F, 0xBD, 0x3E, 0xBB, 0xFE, 0x72, 0x7E, 0xBB, 0x08, + 0xFE, 0x7C, 0x7B, 0x73, 0xF9, 0xFE, 0xFB, 0xEF, 0xB3, 0x57, 0xBF, 0xDE, + 0xBE, 0xBB, 0xFC, 0x7A, 0x7A, 0xC7, 0xB4, 0x7A, 0xB2, 0x00, 0xF3, 0xB1, + 0x70, 0x26, 0xA1, 0xCB, 0x83, 0x48, 0xD5, 0x1A, 0x0A, 0x32, 0xE4, 0x82, + 0x62, 0x06, 0x8C, 0x90, 0xB3, 0x78, 0xF4, 0x08, 0xE0, 0x48, 0xAD, 0x2D, + 0xC2, 0x88, 0xE0, 0x3D, 0x94, 0x05, 0x37, 0x6F, 0x28, 0xF4, 0x90, 0xB8, + 0x42, 0x87, 0x87, 0x58, 0xA4, 0x4D, 0x14, 0xBB, 0x82, 0x06, 0x1A, 0xEE, + 0xA4, 0x49, 0x3D, 0x4A, 0x18, 0xD5, 0xA1, 0x81, 0x06, 0xC5, 0x43, 0x1E, + 0xC5, 0x4D, 0x38, 0x22, 0xE3, 0x98, 0x92, 0x10, 0x1A, 0x6C, 0xA4, 0xB8, + 0x17, 0x27, 0x3A, 0x9C, 0xF1, 0x17, 0x73, 0x14, 0x3E, 0xF5, 0x1A, 0x19, + 0x54, 0x72, 0x29, 0x27, 0x4E, 0x23, 0x03, 0xBB, 0xAE, 0x58, 0x37, 0xEF, + 0x99, 0x25, 0xF3, 0x74, 0xD6, 0xE9, 0x6C, 0xD3, 0x99, 0xA6, 0xB3, 0x4C, + 0xE7, 0x98, 0xCE, 0x2F, 0x9D, 0x5B, 0x3A, 0xAB, 0x74, 0x1E, 0xE9, 0xFC, + 0xD1, 0x39, 0x33, 0xDF, 0x13, 0x1F, 0x4F, 0xD4, 0x53, 0x04, 0x2B, 0xCB, + 0xE7, 0x21, 0x65, 0xF2, 0xF6, 0x32, 0xC8, 0xB2, 0x56, 0x90, 0x30, 0x12, + 0x55, 0x10, 0x30, 0x21, 0xAE, 0x43, 0xF4, 0xE2, 0x93, 0xF0, 0x78, 0x50, + 0x83, 0x8F, 0x12, 0xF2, 0xA2, 0x06, 0xC1, 0xFE, 0x89, 0x7A, 0xC1, 0xE8, + 0xE2, 0x83, 0x8B, 0xFD, 0xD9, 0x6D, 0x51, 0xD1, 0x55, 0xA9, 0xC3, 0xD2, + 0x9E, 0xA9, 0x56, 0xEB, 0x6D, 0xD6, 0x9B, 0x6C, 0x74, 0x58, 0xEF, 0xAD, + 0xDE, 0x58, 0xA3, 0x29, 0x7D, 0x47, 0x21, 0x11, 0xD4, 0x87, 0x87, 0x2D, + 0x7F, 0xFD, 0x54, 0x68, 0x6D, 0xD8, 0xE0, 0x6E, 0x1E, 0x94, 0x78, 0xD6, + 0xA0, 0x96, 0x40, 0xD5, 0x0A, 0x80, 0x10, 0x81, 0x55, 0x35, 0x58, 0x59, + 0xB8, 0xBB, 0xD9, 0xED, 0x21, 0xB9, 0xCA, 0x52, 0x96, 0x5F, 0x06, 0x50, + 0x41, 0x96, 0x41, 0xED, 0xA8, 0xC8, 0xBA, 0x8F, 0xC9, 0x00, 0xC7, 0x31, + 0x18, 0x3D, 0xDD, 0xD7, 0x22, 0x52, 0xE7, 0xC8, 0x61, 0x12, 0x04, 0xA6, + 0xB5, 0x0D, 0x97, 0xB1, 0xD5, 0x81, 0xA3, 0xC9, 0xE8, 0xD8, 0x70, 0x65, + 0xAB, 0x67, 0x70, 0xC9, 0x69, 0x0B, 0x4D, 0xAD, 0xA0, 0x2A, 0x11, 0x70, + 0x36, 0x34, 0xAD, 0xFF, 0x55, 0x87, 0xC4, 0x07, 0xF1, 0x16, 0xB2, 0x6D, + 0xD4, 0x52, 0x11, 0x8D, 0xB8, 0x88, 0x67, 0x9A, 0x86, 0x02, 0x55, 0x66, + 0x06, 0x20, 0xA6, 0x61, 0xC9, 0x83, 0x52, 0x54, 0xF1, 0xA0, 0xDF, 0xEF, + 0xF4, 0xA1, 0xFD, 0x0E, 0x5C, 0x0E, 0x9C, 0xD2, 0x07, 0x3D, 0x54, 0x62, + 0xD6, 0xCA, 0x54, 0x26, 0xEF, 0xF7, 0xD7, 0x6C, 0x7B, 0xCD, 0x71, 0x5A, + 0x49, 0xA6, 0xE3, 0x2A, 0x41, 0x0B, 0xBA, 0x9A, 0x55, 0x0A, 0x1A, 0x6C, + 0x54, 0x99, 0x4B, 0x59, 0xB5, 0x0F, 0x58, 0xBE, 0xFD, 0x3B, 0x89, 0x1D, + 0x1F, 0x8F, 0xC2, 0xC8, 0xD9, 0xDE, 0xBA, 0x7F, 0xF2, 0x14, 0x8F, 0x76, + 0xD3, 0x83, 0xCC, 0x9C, 0x32, 0x09, 0x74, 0x2C, 0x09, 0x5D, 0x22, 0x66, + 0x0E, 0x55, 0x62, 0xD5, 0x08, 0x60, 0xF0, 0x9C, 0x7A, 0xA6, 0x95, 0x2E, + 0xA7, 0xE9, 0x6A, 0x37, 0x4D, 0xD3, 0x1E, 0xAA, 0xF0, 0x1A, 0x85, 0x94, + 0xD0, 0x4B, 0x84, 0x20, 0xCC, 0x9B, 0xE4, 0xCA, 0xD5, 0x55, 0xE3, 0x56, + 0x4B, 0xE9, 0x98, 0x08, 0x8F, 0xB0, 0x58, 0x29, 0x97, 0x34, 0x2A, 0x54, + 0x6B, 0xBD, 0x28, 0x94, 0x4F, 0x57, 0x09, 0x55, 0x59, 0x9F, 0x78, 0x34, + 0xC4, 0xB0, 0xE3, 0xCB, 0xB9, 0x3E, 0x4B, 0xD7, 0xD5, 0xC5, 0x97, 0x96, + 0x27, 0x63, 0x2A, 0x37, 0xBA, 0xDB, 0x8A, 0x5F, 0x74, 0xBD, 0xD4, 0x8A, + 0x0E, 0x87, 0x6C, 0x12, 0x99, 0xD6, 0x4A, 0x2B, 0x72, 0x0A, 0x9F, 0x6F, + 0xD3, 0xBA, 0xDB, 0xE4, 0xA2, 0xEA, 0xD8, 0x80, 0xE4, 0xBE, 0x17, 0x4E, + 0x54, 0x81, 0xFC, 0xF9, 0x9A, 0x06, 0xA6, 0xF5, 0xF3, 0xE5, 0x67, 0x38, + 0x3E, 0x2A, 0x8C, 0x66, 0x11, 0xA5, 0xA1, 0x11, 0x97, 0x0B, 0x38, 0x35, + 0x1E, 0xEF, 0xB5, 0x16, 0x95, 0x4D, 0x6F, 0x4A, 0x50, 0xBD, 0x5B, 0xF9, + 0x32, 0x4C, 0xC6, 0xE4, 0x10, 0x7B, 0xF2, 0x1C, 0xCC, 0x97, 0xAA, 0x96, + 0x3D, 0x81, 0x1F, 0x1F, 0xDF, 0x18, 0x80, 0x17, 0xA8, 0xCC, 0xCC, 0xD3, + 0x14, 0xFE, 0x46, 0xD8, 0xDC, 0xF4, 0x26, 0x4F, 0x04, 0x7C, 0x77, 0x0C, + 0x27, 0xF6, 0xB5, 0xF9, 0x0D, 0x9F, 0xBB, 0xC4, 0x18, 0xD0, 0x7F, 0x10, + 0xFA, 0xF2, 0x67, 0xEA, 0x64, 0x01, 0x61, 0x43, 0x60, 0x17, 0x5E, 0x98, + 0xF9, 0x84, 0xFD, 0x11, 0xA6, 0xDA, 0xF4, 0x2E, 0x4F, 0x93, 0x63, 0x6C, + 0xEC, 0xF0, 0x78, 0x44, 0x3D, 0x39, 0xC7, 0xCA, 0x93, 0x07, 0x86, 0xBD, + 0x88, 0x0A, 0x23, 0x7B, 0x23, 0x9E, 0x53, 0xF7, 0x16, 0xDC, 0x14, 0x98, + 0x43, 0x39, 0x99, 0xF1, 0x70, 0x01, 0xC9, 0xE1, 0x2D, 0x48, 0xF6, 0x24, + 0x61, 0xC3, 0x23, 0x3E, 0xE5, 0xA9, 0xE6, 0xD0, 0x6C, 0xCF, 0x64, 0x94, + 0xFD, 0xFC, 0xC2, 0xF2, 0x2F, 0x7C, 0xDC, 0xCC, 0x2F, +}; +const uint8_t g_esLA_Locale[] = { + 0x78, 0x9C, 0x9D, 0x56, 0xCD, 0x4E, 0xDC, 0x30, 0x10, 0x3E, 0x53, 0xA9, + 0xEF, 0x60, 0x45, 0x45, 0x80, 0x04, 0x9B, 0xF6, 0xB8, 0x28, 0x44, 0x5A, + 0x01, 0xA5, 0x15, 0x0D, 0x5A, 0x75, 0x51, 0x4B, 0xB9, 0x54, 0x4E, 0x62, + 0x36, 0x86, 0xC4, 0x5E, 0x39, 0x09, 0x68, 0xA3, 0xBE, 0x40, 0x4F, 0x3D, + 0xF4, 0xD4, 0x63, 0x2B, 0x21, 0xB5, 0x07, 0xD4, 0x47, 0xE8, 0x81, 0x67, + 0x41, 0xF0, 0x18, 0x9D, 0xFC, 0x6E, 0x12, 0x3B, 0xE9, 0xD2, 0x9C, 0x3C, + 0xDF, 0x7C, 0x9F, 0x77, 0xE6, 0xB3, 0x33, 0x1B, 0xC3, 0xE7, 0x0E, 0xF6, + 0x09, 0x62, 0x38, 0x20, 0x3B, 0x1A, 0x09, 0x3F, 0x5A, 0x27, 0x1A, 0x72, + 0x49, 0xE8, 0xEC, 0x68, 0x0F, 0xD7, 0x7F, 0xEE, 0xBF, 0xDC, 0xDC, 0x7F, + 0xFE, 0xF6, 0xF0, 0xFB, 0x66, 0xFD, 0xEE, 0xC7, 0x4F, 0x88, 0xEF, 0xBE, + 0x5E, 0x6F, 0x68, 0xE6, 0xD3, 0x27, 0x08, 0x19, 0xA9, 0x8A, 0xB9, 0x58, + 0x4C, 0xE6, 0x81, 0xCD, 0xFD, 0xB0, 0xD8, 0x60, 0x2A, 0xC8, 0x94, 0x0B, + 0x8A, 0x59, 0xCA, 0x5A, 0x41, 0x46, 0xC0, 0x59, 0xE4, 0x1D, 0x41, 0x2A, + 0x4C, 0xE3, 0x95, 0x3C, 0x36, 0x09, 0x23, 0x82, 0x1B, 0x7A, 0x1E, 0xD4, + 0xF0, 0x33, 0x62, 0x0B, 0x75, 0x26, 0xC0, 0x22, 0x51, 0xE1, 0xD8, 0x16, + 0xD4, 0x57, 0xF2, 0xE7, 0x2A, 0xFA, 0x79, 0xCC, 0xA8, 0x1A, 0xF7, 0x95, + 0x38, 0x9E, 0xF2, 0x30, 0x52, 0x25, 0x42, 0x32, 0x8B, 0x28, 0x09, 0xA0, + 0x5C, 0x45, 0x92, 0x3B, 0x51, 0xAC, 0xCE, 0x30, 0x7E, 0xD9, 0xA9, 0x72, + 0xA9, 0x23, 0xE5, 0x50, 0xB1, 0xAE, 0x1C, 0xAC, 0x3B, 0x8A, 0xB0, 0x6D, + 0x8B, 0x1D, 0xED, 0x85, 0xD6, 0xB2, 0x56, 0x6D, 0xAC, 0xDA, 0x54, 0xB5, + 0xA5, 0x6A, 0x43, 0xD5, 0x7E, 0xAA, 0xDD, 0x54, 0x7B, 0xA9, 0x36, 0x52, + 0xED, 0xA0, 0xDA, 0x3D, 0xB5, 0x6F, 0xFD, 0x8E, 0xB9, 0x78, 0x5E, 0xBB, + 0x81, 0x10, 0x99, 0x2E, 0x0F, 0x28, 0x4B, 0xCB, 0x49, 0x83, 0x0A, 0xF5, + 0x63, 0x46, 0xC2, 0x16, 0x06, 0x16, 0x45, 0x32, 0x48, 0x6F, 0x7F, 0x09, + 0x87, 0xFB, 0x52, 0xE2, 0x3C, 0x26, 0x97, 0x12, 0x08, 0x27, 0x2E, 0xE4, + 0x8D, 0xC3, 0xDB, 0xEF, 0x36, 0x76, 0x17, 0x25, 0xA0, 0x6C, 0xA5, 0xA8, + 0xBA, 0x75, 0xCA, 0x45, 0xF9, 0x72, 0xE9, 0x72, 0xE1, 0x8A, 0xAA, 0xE5, + 0x7A, 0xE5, 0x62, 0x15, 0x85, 0x76, 0x57, 0x19, 0x10, 0x41, 0x5D, 0xB8, + 0xB6, 0xF5, 0x57, 0xBC, 0x80, 0xCC, 0x91, 0x05, 0x67, 0x51, 0x06, 0xCD, + 0xD4, 0xB8, 0x95, 0x42, 0x8B, 0xB0, 0xB6, 0x39, 0x11, 0xB8, 0xB6, 0x2F, + 0x44, 0x26, 0x1E, 0xEC, 0x0E, 0x0C, 0x3D, 0x5D, 0x55, 0x90, 0x5B, 0x87, + 0x50, 0xB6, 0x2A, 0x45, 0x30, 0xA5, 0xF4, 0xD6, 0x98, 0xCA, 0x51, 0x17, + 0x47, 0x64, 0x8C, 0xA3, 0x08, 0x0E, 0xA6, 0x72, 0xBB, 0x42, 0x8A, 0x49, + 0x76, 0x16, 0xFB, 0xBE, 0x66, 0xEE, 0xC3, 0x83, 0xF6, 0xD6, 0x60, 0x22, + 0xA2, 0x35, 0x0B, 0x9E, 0x7C, 0xF5, 0x01, 0x9E, 0xD4, 0x89, 0x4A, 0xD3, + 0xB5, 0x89, 0xCF, 0xD9, 0x54, 0x33, 0xFF, 0x5F, 0x1F, 0x10, 0x17, 0xE4, + 0x7B, 0xBA, 0x65, 0xE9, 0x4B, 0x6B, 0x42, 0x8F, 0x8B, 0x68, 0xA1, 0x6A, + 0x6B, 0x10, 0x6A, 0x20, 0x85, 0x23, 0x11, 0x0D, 0x5A, 0x8E, 0xD4, 0x90, + 0x86, 0x23, 0x9E, 0xB7, 0x6D, 0x59, 0xDB, 0x93, 0x09, 0x1A, 0xA1, 0x53, + 0x43, 0xAF, 0xB1, 0xBA, 0x64, 0xB9, 0x07, 0x8F, 0x96, 0x65, 0xAD, 0x2F, + 0x54, 0x4B, 0x69, 0x8A, 0xD6, 0x33, 0x95, 0x2C, 0x49, 0x3B, 0x6F, 0xF5, + 0x59, 0xDC, 0x85, 0x63, 0x40, 0xCB, 0x0B, 0x72, 0x10, 0x5B, 0xD1, 0x85, + 0x17, 0x84, 0x93, 0xFD, 0xBD, 0x97, 0x57, 0xEF, 0xB1, 0x77, 0x98, 0x9C, + 0xE6, 0x86, 0xD5, 0x49, 0x99, 0x92, 0xC5, 0x81, 0x4D, 0x44, 0xD3, 0xB5, + 0x06, 0x56, 0x54, 0x05, 0x18, 0xDC, 0x6D, 0x47, 0x33, 0x93, 0xCD, 0x24, + 0x19, 0x0E, 0x92, 0x24, 0x31, 0xF4, 0x06, 0xAF, 0x5B, 0xEA, 0xC4, 0x42, + 0x10, 0xE6, 0xCC, 0x35, 0xF3, 0x59, 0x2E, 0x1E, 0x0E, 0x3F, 0xAD, 0x57, + 0xCB, 0x8D, 0xA5, 0xF7, 0x99, 0x11, 0xE1, 0x10, 0x16, 0x15, 0x25, 0xAC, + 0xCA, 0xBA, 0xD4, 0x1B, 0xA9, 0x9F, 0xAA, 0xC7, 0x45, 0xDB, 0x2B, 0x4D, + 0xA8, 0xD8, 0xDE, 0x25, 0x0E, 0x0D, 0x30, 0x5C, 0x8E, 0x41, 0xB9, 0x4B, + 0x9E, 0xEE, 0x14, 0x4C, 0x05, 0x8F, 0x67, 0x34, 0xBD, 0x17, 0x9B, 0x4B, + 0x2A, 0xAA, 0x0E, 0x56, 0x97, 0x14, 0xC0, 0x84, 0x8F, 0x43, 0xCD, 0xDC, + 0x5A, 0x92, 0x9E, 0xC0, 0x77, 0x87, 0x66, 0x3E, 0x97, 0xD8, 0x0B, 0x63, + 0x1A, 0x67, 0x5F, 0x1E, 0x4C, 0xC3, 0x99, 0x26, 0x58, 0xDE, 0xC9, 0x2C, + 0x80, 0x03, 0x84, 0x59, 0xD4, 0xC8, 0xF7, 0x68, 0x68, 0xC8, 0xD3, 0x85, + 0x66, 0x5A, 0x27, 0x47, 0x8F, 0x90, 0xD5, 0x8F, 0x41, 0x12, 0x65, 0xC3, + 0x50, 0xAA, 0x3A, 0x7D, 0xF5, 0xE7, 0x33, 0x72, 0x86, 0x9D, 0x72, 0xE8, + 0x96, 0x61, 0xB1, 0xA7, 0x35, 0x87, 0xAF, 0x39, 0x17, 0x8D, 0xC1, 0x1D, + 0x5D, 0x4D, 0xA0, 0xF0, 0x49, 0xC5, 0x7A, 0x08, 0xBB, 0x3C, 0x16, 0xF0, + 0x17, 0x88, 0x26, 0x91, 0xDB, 0xC1, 0x18, 0xB9, 0xDC, 0x26, 0x68, 0x4C, + 0xFF, 0x49, 0x79, 0x95, 0x7E, 0x1F, 0x5E, 0xF5, 0x52, 0x46, 0x02, 0xDB, + 0xF0, 0xAE, 0xF5, 0x51, 0x8E, 0x3D, 0x4C, 0x3B, 0x08, 0x87, 0x3C, 0x89, + 0x2F, 0x30, 0x3A, 0xE0, 0x91, 0x47, 0x9D, 0xB4, 0xA7, 0xAD, 0x77, 0xAF, + 0x91, 0xD5, 0x4F, 0x06, 0x03, 0x1C, 0x8F, 0x97, 0xE4, 0xB7, 0xBD, 0x3F, + 0x0D, 0xDC, 0x69, 0xDA, 0x25, 0x7A, 0xD3, 0x4B, 0x9B, 0xF0, 0xA5, 0x68, + 0xD6, 0x3C, 0x66, 0xD3, 0x73, 0x9E, 0x31, 0xF3, 0x22, 0xB3, 0x11, 0x57, + 0x3B, 0x4F, 0x43, 0xCF, 0x3F, 0xEF, 0xCD, 0xBF, 0xC4, 0xB5, 0xD4, 0x04}; +const uint8_t g_deDE_Loacale[] = { + 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x6F, 0xD4, 0x30, 0x10, 0xBD, 0x23, 0xF1, + 0x1F, 0xAC, 0x88, 0xAA, 0x20, 0xB5, 0x1B, 0x38, 0xB6, 0xDA, 0x46, 0x5A, + 0x75, 0xFB, 0x41, 0x4B, 0xCA, 0xAA, 0x69, 0x41, 0xF4, 0x82, 0xBC, 0x89, + 0xBB, 0x71, 0x9B, 0xD8, 0x2B, 0xC7, 0x69, 0xB5, 0x39, 0xF2, 0x37, 0xB8, + 0x72, 0x04, 0x71, 0xE4, 0x04, 0x17, 0xFE, 0x09, 0x52, 0x25, 0x7E, 0x06, + 0x93, 0x8D, 0x93, 0x26, 0xB6, 0xBB, 0x0D, 0xB9, 0xAC, 0xE7, 0xCD, 0x7B, + 0xB3, 0x33, 0xCF, 0x89, 0x93, 0x61, 0xC2, 0x43, 0x9C, 0x10, 0xC4, 0x70, + 0x4A, 0x76, 0x9C, 0x88, 0x7C, 0x1C, 0xEF, 0x39, 0x28, 0x22, 0x59, 0xB8, + 0xE3, 0xDC, 0xFD, 0xFA, 0xF1, 0xF7, 0xFB, 0xB7, 0xE7, 0xF0, 0x73, 0xF7, + 0xF9, 0xE7, 0x0B, 0xC7, 0x1B, 0x96, 0x44, 0x16, 0x61, 0x11, 0x2C, 0xD2, + 0x29, 0x4F, 0x32, 0xA5, 0x99, 0x09, 0x32, 0xE3, 0x82, 0x62, 0x06, 0x8C, + 0x94, 0x33, 0x19, 0x9F, 0x00, 0x9C, 0xA9, 0xB5, 0x77, 0x84, 0x59, 0x8E, + 0xC5, 0xD0, 0xAD, 0xA2, 0xA7, 0x4F, 0x14, 0xBC, 0x4F, 0xA6, 0xC2, 0x86, + 0xFB, 0xBF, 0xBF, 0x88, 0xC2, 0x40, 0x47, 0x73, 0x41, 0x13, 0x93, 0x8B, + 0xA9, 0x81, 0x1D, 0xE5, 0xCC, 0x06, 0x26, 0x26, 0x38, 0xCA, 0x67, 0x79, + 0x26, 0x0D, 0x38, 0x20, 0x73, 0x49, 0xD2, 0x29, 0x31, 0x5B, 0x7B, 0x7B, + 0x2D, 0xB9, 0x0D, 0x3F, 0xE1, 0x37, 0x76, 0xC1, 0x98, 0x14, 0x7A, 0xC2, + 0x6D, 0x19, 0x54, 0xF3, 0x96, 0x11, 0xC2, 0xD3, 0xA9, 0xD8, 0x71, 0x5E, + 0x39, 0x2D, 0xDF, 0x6C, 0xA6, 0x99, 0x26, 0xD8, 0xED, 0xEA, 0x6B, 0x96, + 0xCD, 0x2B, 0x9B, 0x55, 0x36, 0x9F, 0x6C, 0x0E, 0xD9, 0xDC, 0xB1, 0x19, + 0xF3, 0xB0, 0x27, 0x11, 0x5E, 0xA8, 0x1B, 0x08, 0x56, 0x5E, 0xC0, 0x19, + 0x93, 0x18, 0xFE, 0xBE, 0x0C, 0xAA, 0xAC, 0xE7, 0x73, 0x03, 0x1A, 0x53, + 0xC2, 0x32, 0x83, 0x47, 0xA5, 0xBC, 0xE5, 0x61, 0xDC, 0x65, 0x42, 0x41, + 0x22, 0x0C, 0xEE, 0xBE, 0x20, 0x54, 0xC7, 0x02, 0x9C, 0x76, 0x78, 0x6E, + 0xD3, 0x5A, 0xAB, 0xCD, 0xD6, 0xC6, 0x55, 0xFD, 0x6A, 0xAD, 0x6A, 0x6D, + 0x6A, 0x0D, 0x6A, 0xAD, 0x69, 0x2D, 0x69, 0xDD, 0xD8, 0x1B, 0x49, 0x89, + 0xA0, 0x11, 0x25, 0x69, 0xFD, 0xD4, 0xA9, 0xD0, 0x1B, 0xF9, 0xE0, 0x6C, + 0x1D, 0xB4, 0x78, 0xDE, 0x44, 0x4B, 0xB8, 0xDD, 0x0A, 0x80, 0x10, 0x81, + 0x55, 0x35, 0x58, 0x79, 0x37, 0x03, 0xB4, 0x1B, 0x8B, 0xC1, 0xD0, 0x2D, + 0x83, 0x2A, 0xEB, 0x31, 0x0D, 0x73, 0x1B, 0x49, 0x19, 0x68, 0xE7, 0x44, + 0x35, 0x81, 0x24, 0x13, 0x2C, 0x25, 0x11, 0x6C, 0xB9, 0xB3, 0x4D, 0xA4, + 0x0E, 0x91, 0xCB, 0x3C, 0x49, 0x1C, 0x6F, 0x0F, 0xAE, 0x0D, 0x34, 0x1E, + 0x20, 0x1F, 0x2E, 0xF4, 0x01, 0xAE, 0x72, 0xD6, 0x86, 0xAB, 0x15, 0x52, + 0xD2, 0x84, 0xB3, 0x99, 0xE3, 0xFD, 0xA7, 0x28, 0x25, 0x11, 0x68, 0xC6, + 0x03, 0xDF, 0x1F, 0xF4, 0x54, 0x64, 0x31, 0x17, 0xF2, 0x5E, 0x63, 0x28, + 0xDC, 0xCE, 0x88, 0x00, 0x48, 0x9A, 0xB6, 0x46, 0x6E, 0x45, 0x9D, 0x91, + 0x0F, 0xB7, 0x7D, 0x7F, 0x1D, 0x9D, 0xC7, 0x02, 0xAD, 0x5F, 0x0C, 0xDD, + 0x16, 0x4B, 0x2B, 0xD1, 0x19, 0xF6, 0xB0, 0x54, 0x6D, 0x07, 0x01, 0xEA, + 0x23, 0x59, 0x8E, 0x5A, 0x2B, 0x7A, 0xF0, 0xD5, 0xA0, 0x4B, 0x85, 0x41, + 0x77, 0x3B, 0x53, 0x29, 0xA3, 0xCE, 0x00, 0xAB, 0xF7, 0xFA, 0xE0, 0xCA, + 0x97, 0xD7, 0x87, 0x69, 0x16, 0xEC, 0x8D, 0xF7, 0x6F, 0xDF, 0xE3, 0xF8, + 0xB8, 0xB8, 0xA8, 0xAC, 0x69, 0x93, 0x40, 0xC7, 0xF2, 0xF2, 0x68, 0xBC, + 0xF7, 0xA7, 0x13, 0xAB, 0x4E, 0x00, 0x83, 0x5B, 0x33, 0x74, 0xBC, 0x62, + 0xA3, 0x28, 0xB6, 0x06, 0x45, 0x01, 0xC7, 0x46, 0x87, 0x67, 0x14, 0x52, + 0xC2, 0x30, 0x17, 0x82, 0xB0, 0x70, 0x51, 0x2B, 0xB7, 0xB6, 0xD0, 0xB3, + 0x9E, 0xD2, 0x39, 0x11, 0x21, 0x61, 0x52, 0x29, 0xD7, 0x2C, 0x2A, 0x57, + 0x6B, 0xBD, 0x29, 0x54, 0x4F, 0xD7, 0x09, 0x9B, 0x17, 0x6B, 0x48, 0x53, + 0x0C, 0xFB, 0xBD, 0x51, 0xEB, 0xAB, 0xB4, 0xAE, 0x6E, 0xDE, 0xA9, 0x3C, + 0x9F, 0xD3, 0x72, 0xAB, 0x07, 0xBD, 0xF8, 0x4D, 0xD7, 0x6B, 0xBD, 0xE8, + 0x29, 0x65, 0x79, 0xE6, 0x78, 0x9B, 0xBD, 0xC8, 0x05, 0x11, 0xDC, 0xF1, + 0x5E, 0x9A, 0x5C, 0xB7, 0x3B, 0x36, 0x20, 0xB5, 0xEF, 0x8D, 0x13, 0x5D, + 0xA0, 0xBE, 0xC1, 0x96, 0x81, 0xE3, 0xFD, 0xF9, 0xF4, 0x15, 0xCE, 0x8A, + 0x0E, 0xC3, 0x2C, 0xA2, 0x34, 0x34, 0xE3, 0xE5, 0x02, 0x8E, 0x88, 0xF3, + 0xD3, 0xDE, 0xA2, 0xB6, 0xE9, 0xA6, 0xC4, 0xD5, 0xBB, 0x2D, 0x9F, 0x86, + 0xC5, 0x9C, 0x5C, 0xE2, 0xB0, 0x3C, 0xFA, 0xEA, 0xA5, 0xAA, 0xE5, 0x2F, + 0xE0, 0x13, 0x27, 0x42, 0x13, 0xF0, 0xC2, 0x6D, 0x33, 0xEB, 0x34, 0x65, + 0x94, 0xB3, 0x07, 0xD3, 0xBB, 0x3C, 0x17, 0x94, 0x08, 0x14, 0xC8, 0xC8, + 0x9A, 0x1F, 0x45, 0xF0, 0x69, 0x81, 0x26, 0xF4, 0x11, 0xC2, 0x21, 0x7C, + 0x35, 0x91, 0xDB, 0x15, 0x84, 0x91, 0xC0, 0x53, 0x78, 0x60, 0x1E, 0x26, + 0x9C, 0xC5, 0x98, 0x5A, 0xD3, 0xC7, 0xBC, 0xC8, 0xAF, 0x31, 0x3A, 0xE0, + 0x32, 0xA6, 0x61, 0x39, 0xC7, 0xE6, 0xBB, 0xD7, 0xC8, 0x5F, 0x45, 0x85, + 0x91, 0xC3, 0x98, 0xD7, 0xD4, 0xD3, 0x15, 0x7F, 0x0A, 0xCC, 0x59, 0x39, + 0x19, 0x7A, 0xB3, 0x82, 0x04, 0x6F, 0xFA, 0xC7, 0x49, 0xFE, 0x22, 0x67, + 0xB3, 0x2B, 0xBE, 0xE4, 0xA9, 0xE6, 0xDC, 0xFB, 0x3D, 0x2B, 0xA3, 0xEA, + 0x73, 0x16, 0x96, 0xFF, 0x00, 0x29, 0x27, 0xAF, 0x17, +}; +const uint8_t g_frFR_Locale[] = { + 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x6F, 0xD3, 0x40, 0x10, 0xBD, 0x23, 0xF1, + 0x1F, 0x56, 0x16, 0x55, 0x41, 0x6A, 0xBD, 0x70, 0x4C, 0x95, 0x5A, 0xAA, + 0xFA, 0x15, 0x28, 0x46, 0x51, 0x53, 0x40, 0xF4, 0x82, 0x36, 0xF6, 0x36, + 0xDE, 0xD4, 0xDE, 0x8D, 0xD6, 0x76, 0x4A, 0x7C, 0xE4, 0x3F, 0x70, 0xE2, + 0xC2, 0xB5, 0x12, 0x88, 0x03, 0x47, 0xC4, 0x85, 0xFE, 0x13, 0x24, 0x10, + 0x3F, 0x83, 0x71, 0xBC, 0x76, 0xED, 0x5D, 0x27, 0xB8, 0xBE, 0x64, 0xE7, + 0xCD, 0x7B, 0xE3, 0x99, 0xB7, 0xF6, 0xC6, 0xFD, 0x50, 0x78, 0x24, 0xA4, + 0x88, 0x93, 0x88, 0xEE, 0x5A, 0x17, 0xF2, 0xED, 0xD1, 0xA9, 0x85, 0x7C, + 0x1A, 0x7B, 0xBB, 0xD6, 0x9F, 0x6F, 0x1F, 0xFE, 0x7E, 0xFD, 0xF2, 0x10, + 0x7E, 0x7E, 0x7F, 0xFC, 0xF1, 0xC8, 0x72, 0xFA, 0x39, 0x91, 0xFB, 0x44, + 0x8E, 0x16, 0xD1, 0x58, 0x84, 0xB1, 0xD2, 0x4C, 0x24, 0x9D, 0x08, 0xC9, + 0x08, 0x07, 0x46, 0x24, 0x78, 0x12, 0xBC, 0x00, 0x38, 0x56, 0x6B, 0x67, + 0x4A, 0xF8, 0x9C, 0x51, 0xD9, 0xC7, 0x45, 0x78, 0xFF, 0x9E, 0xC2, 0x2F, + 0x6E, 0xAE, 0xE7, 0xB2, 0x2D, 0x11, 0x11, 0x19, 0x1B, 0x20, 0x01, 0x6E, + 0xD8, 0x42, 0x65, 0x06, 0x36, 0x4D, 0x19, 0x6F, 0x03, 0xC3, 0x90, 0x26, + 0x66, 0x59, 0x71, 0xF3, 0xDD, 0x44, 0x63, 0x3A, 0x4B, 0x68, 0x34, 0x96, + 0xD4, 0xC8, 0x08, 0x2F, 0x11, 0x6D, 0x38, 0x17, 0xF3, 0x76, 0x81, 0x7F, + 0x73, 0xED, 0xE9, 0x19, 0x5C, 0x33, 0xA9, 0x24, 0x2E, 0x23, 0x44, 0xC6, + 0x63, 0xB9, 0x6B, 0x3D, 0xB1, 0xEA, 0xDE, 0xD9, 0xED, 0xCE, 0x99, 0xF0, + 0x2A, 0xDF, 0xDA, 0x98, 0x77, 0xB0, 0xCD, 0x94, 0xAF, 0x36, 0xCD, 0xE4, + 0x82, 0x61, 0x26, 0x08, 0x6E, 0x99, 0x60, 0xEE, 0x94, 0xBD, 0xDA, 0x25, + 0x9F, 0x2C, 0xD4, 0x63, 0x05, 0x2B, 0xC7, 0x67, 0x11, 0xE1, 0x5E, 0x00, + 0xAE, 0xE6, 0x51, 0x91, 0x76, 0xC2, 0x94, 0xFB, 0xAC, 0x81, 0x80, 0x25, + 0x3A, 0x42, 0xA5, 0x27, 0xA9, 0x06, 0x4E, 0x69, 0xAA, 0x21, 0x73, 0x78, + 0xCC, 0x0D, 0x5A, 0x0C, 0xF7, 0xAF, 0x41, 0xB8, 0x6A, 0xA9, 0xD6, 0x5E, + 0x6D, 0x0B, 0x55, 0x9F, 0xB6, 0xDE, 0xA3, 0xAD, 0xB7, 0x68, 0xEB, 0x1D, + 0xDA, 0x7A, 0x77, 0xB6, 0xDE, 0x9C, 0xAD, 0x37, 0x66, 0xB7, 0xB7, 0x05, + 0xC5, 0x98, 0xCF, 0x68, 0x54, 0xBE, 0x91, 0x2A, 0x74, 0xF6, 0x5C, 0xF0, + 0xB7, 0x0C, 0x6A, 0x3C, 0x67, 0xA8, 0x25, 0x70, 0xB3, 0x02, 0x20, 0x54, + 0x12, 0x55, 0x0D, 0x56, 0xF0, 0x7C, 0xD9, 0xE8, 0x99, 0xBD, 0xBD, 0x0F, + 0xF7, 0xCF, 0xC3, 0x22, 0xEF, 0x90, 0x99, 0x8E, 0xE2, 0x4A, 0x96, 0x07, + 0xDA, 0x39, 0x52, 0xCC, 0x91, 0xD0, 0x21, 0x49, 0x12, 0x2A, 0xF9, 0x72, + 0x8F, 0xAB, 0xA8, 0x3C, 0x98, 0xD2, 0x30, 0xB4, 0x9C, 0x43, 0xB8, 0xD0, + 0x01, 0x72, 0xE1, 0x42, 0x6F, 0xE0, 0xCA, 0xA7, 0xAD, 0x98, 0x5A, 0x19, + 0x25, 0x0C, 0x05, 0x9F, 0x58, 0xCE, 0xDD, 0x34, 0xB0, 0xCF, 0x4A, 0x82, + 0x3A, 0xF1, 0xE3, 0x40, 0xC8, 0x04, 0x14, 0x07, 0xD8, 0x75, 0x71, 0x8B, + 0x02, 0x37, 0xA6, 0x03, 0x20, 0x61, 0x51, 0x6D, 0xDA, 0x5A, 0xD4, 0x98, + 0x76, 0x30, 0xD8, 0x44, 0x01, 0xDA, 0x84, 0x2E, 0xCE, 0xFB, 0xB8, 0x46, + 0xD2, 0x2A, 0x34, 0x06, 0x1D, 0x0C, 0x76, 0x5C, 0x77, 0x67, 0x34, 0xEA, + 0x24, 0x59, 0xCE, 0x59, 0x2A, 0x3A, 0xF0, 0xD5, 0x9C, 0x4B, 0x85, 0x41, + 0xC7, 0x8D, 0xA1, 0x94, 0x4F, 0x67, 0x80, 0x95, 0xBB, 0x7C, 0x4C, 0xDC, + 0xE9, 0xE5, 0x20, 0x8A, 0x47, 0x87, 0x07, 0x47, 0x57, 0xAF, 0xDF, 0x05, + 0x27, 0xD9, 0x79, 0xE1, 0x4C, 0x9D, 0x04, 0x3A, 0x9E, 0x46, 0x63, 0x2A, + 0x6F, 0xED, 0x69, 0xC4, 0xAA, 0x13, 0xC0, 0xE0, 0xC1, 0xF4, 0x2C, 0x27, + 0xDB, 0xCA, 0xB2, 0x9E, 0x9D, 0x65, 0x59, 0x1F, 0x37, 0x78, 0x46, 0x21, + 0x25, 0xF4, 0x52, 0x29, 0x29, 0xF7, 0x16, 0xA5, 0xB2, 0xD7, 0x43, 0x0F, + 0x3A, 0x4A, 0x67, 0x70, 0x76, 0x50, 0x9E, 0x28, 0xE5, 0x46, 0x8B, 0x0A, + 0x6B, 0xAD, 0x57, 0x85, 0xCA, 0xE9, 0x1A, 0xA1, 0x2A, 0xEB, 0x53, 0x0F, + 0x4E, 0x33, 0xD8, 0xEE, 0xAD, 0x52, 0x5F, 0xA4, 0x75, 0x75, 0xF5, 0x6F, + 0x2B, 0xD2, 0x19, 0xCB, 0xB7, 0xFA, 0xE7, 0xA7, 0x4E, 0x82, 0xAA, 0xED, + 0x8D, 0x4E, 0xF4, 0x88, 0xF1, 0x34, 0xB6, 0x9C, 0xED, 0x4E, 0xE4, 0x8C, + 0x4A, 0x61, 0x39, 0x8F, 0x4D, 0x2E, 0x6E, 0xCE, 0x0D, 0x48, 0x69, 0x7C, + 0x65, 0x45, 0x13, 0x28, 0x9F, 0xB0, 0x65, 0x60, 0x39, 0xBF, 0xDE, 0x7F, + 0x86, 0x63, 0xA2, 0xC1, 0x30, 0x8B, 0x28, 0x0D, 0x8B, 0x45, 0xBE, 0x80, + 0xD3, 0xE1, 0xE5, 0x69, 0x67, 0x51, 0xDD, 0x75, 0x53, 0x82, 0xF5, 0x6E, + 0xF3, 0xD7, 0x61, 0x31, 0xA3, 0x17, 0xC4, 0xCB, 0x4F, 0xBE, 0x72, 0xA9, + 0x6A, 0xB9, 0x0B, 0xF8, 0xFA, 0xF1, 0xD1, 0x10, 0xBC, 0xC0, 0x75, 0x66, + 0x99, 0x66, 0x9C, 0x09, 0xBE, 0x32, 0xBD, 0x2F, 0xD2, 0xFC, 0x3B, 0x08, + 0x8D, 0x12, 0xBF, 0x35, 0xBF, 0xE7, 0x8B, 0x31, 0x45, 0x43, 0xF6, 0x1F, + 0xC2, 0x80, 0xC2, 0x57, 0xC6, 0xD5, 0x1A, 0xC2, 0x9E, 0x24, 0x63, 0x78, + 0x63, 0x56, 0x13, 0xCE, 0x02, 0xC2, 0x5A, 0xD3, 0x27, 0x22, 0x4B, 0x2F, + 0x09, 0x3A, 0x16, 0x49, 0xC0, 0xBC, 0x7C, 0x8E, 0xED, 0x57, 0x4F, 0x91, + 0xBB, 0x8E, 0x0A, 0x23, 0x7B, 0x81, 0x28, 0xA9, 0xA7, 0x6B, 0x6E, 0x0A, + 0xCC, 0x49, 0x3E, 0x19, 0x7A, 0xBE, 0x86, 0x34, 0x12, 0x1D, 0x48, 0xEE, + 0x22, 0xE5, 0x93, 0xA9, 0x58, 0xF2, 0x54, 0x73, 0xF8, 0x76, 0xCF, 0xF2, + 0xA8, 0xF8, 0xD2, 0x85, 0xE5, 0x3F, 0x5D, 0x49, 0xBE, 0x1B}; +const uint8_t g_itIT_Locale[] = { + 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6A, 0xD4, 0x40, 0x14, 0x7D, 0x17, 0xFC, + 0x87, 0x21, 0x58, 0x50, 0x68, 0x3B, 0xFA, 0xD8, 0x92, 0x06, 0x4A, 0x5B, + 0xBB, 0xA5, 0x46, 0x96, 0xEE, 0xAA, 0xD8, 0x17, 0x99, 0x64, 0xA6, 0xD9, + 0xB1, 0xC9, 0xCC, 0x32, 0x49, 0x5A, 0x92, 0x47, 0xF1, 0xC1, 0x37, 0x7F, + 0x42, 0x10, 0x41, 0xF1, 0x23, 0xFC, 0x13, 0xA1, 0xE2, 0x67, 0x78, 0xB3, + 0x99, 0xA4, 0xC9, 0x64, 0xBA, 0xA6, 0x79, 0xD9, 0xB9, 0xE7, 0x9E, 0x73, + 0x73, 0xEF, 0x99, 0x64, 0x36, 0x6E, 0x2C, 0x43, 0x12, 0x33, 0x24, 0x48, + 0xC2, 0xF6, 0x1C, 0x9E, 0xBD, 0x3B, 0x99, 0x3B, 0x88, 0xB2, 0x34, 0xDC, + 0x73, 0xFE, 0x7C, 0xFC, 0x7C, 0xF3, 0xE5, 0xEB, 0xCD, 0xA7, 0x6F, 0x7F, + 0x7F, 0xFE, 0x78, 0xDC, 0x06, 0x4F, 0x1C, 0xCF, 0xAD, 0x14, 0x82, 0x12, + 0x35, 0x2B, 0x92, 0x40, 0xC6, 0xA9, 0x16, 0x47, 0x8A, 0x45, 0x52, 0x71, + 0x22, 0x80, 0x91, 0x48, 0x91, 0x2D, 0x5E, 0x02, 0x9C, 0xEA, 0xB5, 0x17, + 0x31, 0x21, 0x08, 0x97, 0x2E, 0xAE, 0xC3, 0x87, 0x0F, 0x34, 0x7E, 0xC1, + 0x82, 0x40, 0xD9, 0x12, 0x09, 0x51, 0xE5, 0x10, 0x25, 0x4B, 0xC5, 0x63, + 0x66, 0x21, 0x47, 0x91, 0xA5, 0x46, 0xC4, 0xF3, 0x48, 0x0C, 0xE1, 0x38, + 0x8F, 0x62, 0x0B, 0x9B, 0x44, 0x32, 0xCD, 0x86, 0x70, 0xCA, 0xB2, 0x8C, + 0x25, 0x81, 0x1A, 0xDE, 0x55, 0x66, 0x99, 0xB4, 0xE1, 0x42, 0x5E, 0xD9, + 0x05, 0x94, 0x87, 0x66, 0x02, 0x77, 0xAC, 0x6A, 0x78, 0xAB, 0x08, 0x11, + 0x30, 0x66, 0xCF, 0x79, 0xE6, 0x74, 0x1C, 0xB4, 0xB9, 0x67, 0x33, 0xCE, + 0x66, 0x9B, 0xCD, 0x33, 0x9B, 0x61, 0x36, 0xB7, 0x6C, 0x56, 0xD9, 0x7C, + 0xB2, 0x39, 0x64, 0x73, 0xC7, 0x66, 0xCC, 0xDD, 0x9E, 0x50, 0x52, 0xE8, + 0x47, 0x09, 0x56, 0x1E, 0x95, 0x09, 0x13, 0x3C, 0x24, 0x2E, 0xAE, 0xA2, + 0x3A, 0x0D, 0x3D, 0x0A, 0x46, 0x7F, 0x7D, 0xEF, 0x61, 0xE0, 0x43, 0x36, + 0x04, 0x99, 0x0A, 0x65, 0x3C, 0x80, 0xE1, 0xE1, 0xB9, 0x1A, 0x80, 0x57, + 0x4C, 0x30, 0x65, 0x82, 0x29, 0x09, 0x48, 0xF5, 0x90, 0x68, 0x08, 0xB7, + 0xCD, 0x75, 0x1A, 0xED, 0x6C, 0x9D, 0xEE, 0xD8, 0x6C, 0xD6, 0x6C, 0xD4, + 0xEC, 0xD1, 0x6C, 0xCE, 0xEC, 0xCB, 0x6C, 0xC9, 0xDE, 0x0F, 0x14, 0xE2, + 0x94, 0xB3, 0xA4, 0x79, 0x11, 0x75, 0xE8, 0xED, 0xFB, 0x60, 0x71, 0x13, + 0x74, 0x78, 0xDE, 0xD4, 0x48, 0xE0, 0x7E, 0x05, 0x40, 0x98, 0x22, 0xBA, + 0x1A, 0xAC, 0x3C, 0x72, 0xE0, 0xE2, 0xEA, 0xB7, 0x4E, 0x78, 0xF4, 0x36, + 0xC4, 0x2D, 0xB1, 0x0A, 0x8C, 0x03, 0xA3, 0x6E, 0x3C, 0x63, 0x53, 0x02, + 0x6F, 0x96, 0x12, 0xAB, 0x8D, 0x6D, 0x23, 0x7D, 0x9A, 0x5C, 0xE4, 0x71, + 0xEC, 0x78, 0x47, 0x70, 0xA1, 0x43, 0xE4, 0xC3, 0x85, 0xDE, 0xC2, 0x55, + 0xCD, 0xD7, 0x32, 0x8D, 0x32, 0x5A, 0x18, 0x4B, 0x11, 0x39, 0xDE, 0xE1, + 0xFD, 0x44, 0x09, 0xA3, 0x95, 0x06, 0x83, 0x04, 0x8F, 0x12, 0xA4, 0x0B, + 0xA9, 0x32, 0x2D, 0xB1, 0x29, 0x70, 0x6F, 0x3E, 0x00, 0x32, 0x9E, 0x74, + 0xE6, 0xED, 0x44, 0xBD, 0x79, 0x27, 0x93, 0x5D, 0xDF, 0xDF, 0x9D, 0xCD, + 0xD0, 0xB9, 0x8B, 0x3B, 0x1C, 0xA3, 0x40, 0x6F, 0xD2, 0xFB, 0x28, 0x56, + 0x63, 0x36, 0xF7, 0x18, 0xC1, 0xD7, 0x53, 0xAE, 0x14, 0x03, 0x3A, 0xEE, + 0x8D, 0xA4, 0x5D, 0x9A, 0x03, 0xD6, 0xEC, 0xF2, 0x71, 0xE1, 0xD3, 0xCB, + 0x49, 0x92, 0xCE, 0x8E, 0x0E, 0x9F, 0x5F, 0xBF, 0x21, 0x8B, 0xD3, 0xF2, + 0xBC, 0xF6, 0xA5, 0x4B, 0x02, 0x9D, 0xC8, 0x93, 0x80, 0xA9, 0x5B, 0x73, + 0x7A, 0xB1, 0xEE, 0x04, 0x30, 0x78, 0x14, 0x43, 0xC7, 0x2B, 0x37, 0xCB, + 0x72, 0x67, 0xBB, 0x2C, 0x4B, 0x17, 0xF7, 0x78, 0x83, 0x42, 0x5A, 0x18, + 0xE6, 0x4A, 0x31, 0x11, 0x16, 0x8E, 0xF7, 0x08, 0xD5, 0xDA, 0x9D, 0x9D, + 0x91, 0xD2, 0x25, 0x9C, 0x15, 0x4C, 0x64, 0xFA, 0x9E, 0x1B, 0x16, 0x15, + 0x36, 0x5A, 0x6F, 0x0B, 0x35, 0xD3, 0xF5, 0x42, 0x5D, 0x96, 0xB2, 0x90, + 0x27, 0x04, 0x36, 0x7B, 0xB3, 0xD1, 0xD7, 0x69, 0x53, 0xDD, 0xFE, 0xAD, + 0xCA, 0x7C, 0xC9, 0xAB, 0x9D, 0xDE, 0x1E, 0xC5, 0x6F, 0xBB, 0xDE, 0x18, + 0x45, 0x4F, 0xB8, 0xC8, 0x53, 0xC7, 0xDB, 0x1A, 0x45, 0x2E, 0x99, 0x92, + 0x8E, 0xF7, 0x74, 0xC8, 0xC5, 0xFD, 0xB1, 0x01, 0x69, 0x7C, 0x6F, 0x9D, + 0xE8, 0x03, 0xCD, 0x03, 0xB6, 0x0A, 0x1C, 0xEF, 0xF7, 0x07, 0x38, 0x65, + 0xFB, 0x8C, 0x61, 0x91, 0xE6, 0x23, 0x25, 0x95, 0xD5, 0x02, 0x0E, 0x87, + 0x57, 0x67, 0xA3, 0x45, 0x5D, 0xD3, 0x87, 0x12, 0x6C, 0x76, 0x5B, 0xBD, + 0x0D, 0xC5, 0x92, 0x5D, 0x90, 0xB0, 0x3A, 0xEA, 0x9A, 0xA5, 0xAE, 0xE5, + 0x17, 0xF0, 0x95, 0x43, 0xD1, 0x14, 0xBC, 0xC0, 0x5D, 0x66, 0x93, 0xE6, + 0x82, 0x4B, 0x71, 0x67, 0xFA, 0x40, 0xE6, 0x8A, 0x33, 0x85, 0x66, 0x19, + 0xB5, 0xE6, 0xF7, 0xA9, 0x0C, 0x18, 0x9A, 0xF2, 0xFF, 0x10, 0x26, 0x0C, + 0xBE, 0x23, 0xAE, 0xD7, 0x10, 0xF6, 0x15, 0x09, 0xE0, 0x85, 0xB9, 0x9B, + 0x30, 0x5F, 0x10, 0x6E, 0x4D, 0x9F, 0xCA, 0x32, 0xBF, 0x24, 0xE8, 0x58, + 0x66, 0x0B, 0x1E, 0x56, 0x73, 0x6C, 0xBD, 0x3E, 0x41, 0xFE, 0x3A, 0x2A, + 0x8C, 0x1C, 0x2E, 0x64, 0x43, 0x3D, 0x5B, 0x73, 0x53, 0x60, 0x46, 0xD5, + 0x64, 0xE8, 0xC5, 0x1A, 0xD2, 0x4C, 0x8E, 0x20, 0xF9, 0x45, 0x2E, 0xA2, + 0xF7, 0x72, 0xC5, 0xD3, 0xCD, 0xE1, 0xDB, 0x3D, 0xAB, 0xA2, 0xFA, 0xD3, + 0x16, 0x96, 0xFF, 0x00, 0x20, 0x8B, 0xBE, 0xF7}; +const uint8_t g_ptBR_Locale[] = { + 0x78, 0x9C, 0x9D, 0x56, 0x3D, 0x6F, 0xD4, 0x40, 0x10, 0xAD, 0x83, 0xC4, + 0x7F, 0x58, 0x59, 0x89, 0x0E, 0xA4, 0x24, 0x86, 0x92, 0xC8, 0x67, 0xE9, + 0x92, 0x0B, 0x39, 0x94, 0x18, 0x9D, 0xCE, 0x11, 0x88, 0x34, 0x68, 0x6D, + 0xEF, 0xD9, 0x9B, 0xD8, 0xBB, 0xC7, 0xDA, 0x4E, 0xB0, 0x6B, 0x1A, 0x3A, + 0x28, 0x29, 0x53, 0x20, 0x2A, 0x44, 0x83, 0x44, 0x49, 0x91, 0xDF, 0x82, + 0xB8, 0x9F, 0xC1, 0xFA, 0xF3, 0xFC, 0xB1, 0x36, 0x06, 0x37, 0xDE, 0x99, + 0x79, 0x6F, 0x3D, 0xF3, 0x76, 0x76, 0x64, 0xC5, 0xA5, 0x26, 0x74, 0x11, + 0x20, 0xD0, 0x43, 0x63, 0x69, 0x15, 0xBC, 0x3E, 0x5C, 0x48, 0xC0, 0x42, + 0xBE, 0x39, 0x96, 0xD6, 0x1F, 0x6F, 0xD7, 0x1F, 0xDE, 0xFD, 0x7E, 0xFF, + 0x69, 0xFD, 0xED, 0xEB, 0x83, 0x5F, 0x3F, 0xBE, 0xAF, 0x3F, 0xFF, 0x7C, + 0x28, 0xA9, 0xF7, 0xEF, 0x01, 0xA0, 0x24, 0x14, 0x62, 0x41, 0xA6, 0x47, + 0x9E, 0x41, 0x5D, 0x3F, 0x67, 0xDB, 0x0C, 0xD9, 0x94, 0x61, 0x48, 0x12, + 0xD4, 0x16, 0x50, 0x3C, 0x4A, 0x02, 0xE7, 0x39, 0x0F, 0xF9, 0x89, 0xBD, + 0x95, 0xD9, 0xEA, 0x25, 0x24, 0x08, 0x33, 0xAA, 0xC8, 0x99, 0x59, 0x89, + 0x2C, 0xD1, 0x35, 0x62, 0x1D, 0x31, 0x0F, 0xB2, 0xBB, 0x2F, 0xA2, 0x00, + 0x34, 0x18, 0x76, 0x85, 0x04, 0x2C, 0x82, 0x5F, 0x86, 0xC4, 0x11, 0xFB, + 0x5D, 0xA1, 0x1F, 0xDA, 0xD4, 0x0F, 0x44, 0x01, 0x1F, 0x05, 0xC8, 0x33, + 0x84, 0xB9, 0xD2, 0x30, 0x08, 0xC5, 0x11, 0x42, 0xAF, 0xBB, 0x48, 0x16, + 0x8A, 0x9B, 0x21, 0x90, 0xAF, 0x4B, 0x09, 0xAB, 0x92, 0x02, 0x68, 0x18, + 0x6C, 0x2C, 0x3D, 0x96, 0x1A, 0xDA, 0x8A, 0x75, 0x15, 0x2B, 0x2A, 0x96, + 0x53, 0x2C, 0xA6, 0x58, 0x4B, 0xB1, 0x92, 0x62, 0x1D, 0xC5, 0x22, 0x8A, + 0xF5, 0x13, 0x6B, 0x27, 0x96, 0xAD, 0x5F, 0x31, 0x0B, 0x46, 0x95, 0x16, + 0xE4, 0x96, 0x6A, 0x51, 0x0F, 0x93, 0x24, 0x9D, 0xC4, 0x28, 0xBD, 0x3E, + 0xB2, 0x43, 0xDE, 0xD2, 0x7B, 0x4B, 0xDE, 0x80, 0xB0, 0x11, 0x0B, 0x10, + 0x6F, 0x3E, 0x71, 0xE8, 0x4D, 0x08, 0x59, 0xD0, 0x15, 0xC2, 0xA4, 0x23, + 0xE4, 0xA3, 0xB7, 0x5D, 0x91, 0xBB, 0x5B, 0x03, 0x5A, 0x9B, 0xE4, 0x40, + 0xBA, 0x12, 0xD4, 0xD3, 0x38, 0xFF, 0xBC, 0xB0, 0x76, 0x51, 0xED, 0x52, + 0xDA, 0x15, 0xB4, 0x13, 0x6F, 0xE7, 0x2B, 0xC8, 0xB3, 0x3B, 0x49, 0x0F, + 0x31, 0x6C, 0x61, 0xE4, 0x55, 0x2F, 0x7F, 0xEE, 0x52, 0x27, 0x1A, 0x3F, + 0xA4, 0xC2, 0xA8, 0x87, 0xE6, 0x8D, 0x10, 0xD8, 0x98, 0x95, 0xCD, 0x11, + 0x83, 0x95, 0x7D, 0xB9, 0xA5, 0x1E, 0x1E, 0x29, 0x72, 0xF2, 0x2E, 0x1D, + 0x93, 0x69, 0xE9, 0x00, 0xE9, 0xAA, 0x20, 0xF0, 0xD9, 0x25, 0x37, 0x86, + 0x57, 0xE6, 0xB5, 0x60, 0x80, 0xE6, 0x30, 0xE0, 0xF2, 0x90, 0x52, 0xE8, + 0xD2, 0x93, 0xCF, 0xB7, 0x65, 0xE8, 0xBA, 0x92, 0x7A, 0xCC, 0x9F, 0x5D, + 0x30, 0x1D, 0xF1, 0x29, 0x09, 0x46, 0x1A, 0x7F, 0xB2, 0xD5, 0x2B, 0xFE, + 0x24, 0x32, 0x94, 0xA4, 0xAE, 0x5D, 0x5C, 0x4A, 0x6C, 0x49, 0xFD, 0x7F, + 0xBE, 0x87, 0x2C, 0x4E, 0x9F, 0xCA, 0x9A, 0x26, 0x0F, 0xE6, 0xF8, 0x0E, + 0x65, 0xC1, 0x86, 0xD5, 0xE4, 0x00, 0x50, 0xF3, 0xE4, 0x92, 0x04, 0xD8, + 0x6B, 0x48, 0x52, 0xF1, 0xD4, 0x24, 0x99, 0xCD, 0x46, 0x0E, 0x2F, 0x65, + 0xC4, 0xEF, 0xD5, 0x48, 0xD7, 0x47, 0xFE, 0x08, 0x5C, 0x28, 0x72, 0x05, + 0xDC, 0xC5, 0xCE, 0xA4, 0x48, 0xC9, 0x19, 0x77, 0x38, 0x35, 0x55, 0x61, + 0x36, 0x3B, 0xD0, 0xB4, 0x03, 0x5D, 0x1F, 0xC4, 0xC8, 0x35, 0x48, 0x39, + 0x4D, 0x42, 0x22, 0x40, 0xA3, 0xDC, 0xBC, 0x27, 0xCE, 0xB9, 0xB7, 0x68, + 0x94, 0x93, 0x48, 0xB3, 0xAE, 0x66, 0x9E, 0xAF, 0x1F, 0x4F, 0x9F, 0xDE, + 0xBC, 0x84, 0xCE, 0x69, 0x7C, 0x91, 0xE9, 0x56, 0x05, 0xA5, 0x4C, 0x12, + 0x7A, 0x06, 0x62, 0x75, 0xF1, 0x6A, 0xBE, 0x3C, 0x27, 0xEE, 0xE3, 0xFD, + 0x6D, 0x4A, 0x6A, 0xBC, 0x1B, 0xC7, 0x4F, 0xF6, 0xE3, 0x98, 0x0F, 0xB3, + 0x1A, 0xAE, 0x9B, 0x6A, 0x86, 0x8C, 0x21, 0x62, 0x46, 0x92, 0xBA, 0x0D, + 0x0A, 0xF6, 0x60, 0xF2, 0x0A, 0x31, 0x13, 0x91, 0x20, 0xFF, 0xEE, 0x4E, + 0x9B, 0x97, 0x08, 0xD2, 0x2A, 0xA2, 0x2C, 0x6C, 0x53, 0xEB, 0x56, 0xDD, + 0x95, 0x6F, 0x6F, 0x21, 0x13, 0x7B, 0x90, 0x37, 0xC6, 0x6E, 0xB1, 0x4B, + 0x16, 0xEE, 0x24, 0xD8, 0x8C, 0x86, 0x2B, 0x9C, 0x34, 0xC3, 0xFE, 0x40, + 0x46, 0x59, 0xC1, 0xCE, 0x40, 0x02, 0xEF, 0xAF, 0xD0, 0x97, 0xD4, 0xBD, + 0x81, 0xF0, 0x18, 0x31, 0x2A, 0xA9, 0x8F, 0x5A, 0xE8, 0x8D, 0x30, 0xB5, + 0x03, 0x2F, 0x4E, 0xA3, 0xA6, 0x4C, 0xDD, 0x59, 0xB4, 0x61, 0x6A, 0x48, + 0xEA, 0x62, 0x9B, 0x4F, 0xA2, 0x1A, 0xA0, 0x87, 0x84, 0x7D, 0x9A, 0x2C, + 0x24, 0xF5, 0x70, 0x71, 0xF6, 0x0F, 0xB4, 0xEA, 0x39, 0xB4, 0x48, 0xE9, + 0x28, 0x6C, 0xA5, 0x9D, 0xDC, 0xFB, 0x68, 0x85, 0x96, 0xD0, 0x2C, 0xC6, + 0x6D, 0x61, 0xE6, 0x7B, 0x6A, 0x11, 0xFF, 0xC3, 0xB3, 0xC0, 0x9C, 0xCB, + 0x23, 0x8B, 0x01, 0x98, 0x60, 0x4A, 0x7A, 0x00, 0x47, 0x34, 0x64, 0x18, + 0x31, 0xA0, 0x07, 0x56, 0x07, 0x62, 0x62, 0x51, 0x03, 0x81, 0x39, 0xFE, + 0x2B, 0x64, 0x86, 0x0C, 0x86, 0x6E, 0x7A, 0x21, 0x13, 0x06, 0x0D, 0x7E, + 0xC3, 0xFA, 0x20, 0xE7, 0x0E, 0xC4, 0x1D, 0x80, 0x53, 0x1A, 0x87, 0x57, + 0x10, 0x9C, 0xD0, 0xC0, 0xC1, 0x66, 0x52, 0xD3, 0xDE, 0x8B, 0x67, 0x40, + 0xEB, 0x07, 0x73, 0x01, 0x4C, 0x87, 0x16, 0xE0, 0x45, 0xEF, 0xA7, 0x39, + 0xD6, 0x4E, 0xAA, 0x04, 0x67, 0xBD, 0x30, 0x9D, 0x0E, 0x82, 0x69, 0x51, + 0x48, 0xEC, 0x4B, 0x9A, 0x22, 0xB3, 0x24, 0xD3, 0xC1, 0x56, 0x39, 0x4F, + 0x45, 0xCE, 0xFE, 0xF7, 0xD5, 0x3F, 0x30, 0xBB, 0xD9, 0x9B}; +const uint8_t g_nlNL_Locale[] = { + 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x4F, 0xDC, 0x30, 0x10, 0x3D, 0x53, 0xA9, + 0xFF, 0xC1, 0x8A, 0x8A, 0x68, 0x25, 0x96, 0x2D, 0x47, 0x50, 0x88, 0xB4, + 0x05, 0x0A, 0x15, 0x04, 0xAD, 0x58, 0xDA, 0xAA, 0x5C, 0x2A, 0x6F, 0x62, + 0x76, 0xBD, 0x24, 0xF6, 0xCA, 0x89, 0x41, 0xC9, 0xB1, 0x52, 0x8F, 0xFD, + 0x27, 0xAD, 0xDA, 0x5B, 0xFF, 0x4F, 0xA5, 0x4A, 0xFC, 0x8C, 0x8E, 0xF3, + 0x45, 0x12, 0x3B, 0x69, 0xC8, 0x05, 0xCF, 0x9B, 0xF7, 0xBC, 0x33, 0xCF, + 0xCE, 0x10, 0x3B, 0xE0, 0x1E, 0x0E, 0x08, 0x62, 0x38, 0x24, 0x07, 0x16, + 0x0B, 0x3E, 0x5F, 0x9C, 0x5B, 0xC8, 0x27, 0x91, 0x77, 0x60, 0x3D, 0x7C, + 0xFB, 0xFD, 0xF7, 0xEB, 0xAF, 0x87, 0x9F, 0x3F, 0x5E, 0xE6, 0xAB, 0x57, + 0x96, 0xF3, 0xFC, 0x19, 0x42, 0xB6, 0xE2, 0x33, 0x1F, 0x8B, 0x59, 0x12, + 0xCE, 0x79, 0x10, 0x15, 0xD2, 0x85, 0x20, 0x0B, 0x2E, 0x28, 0x66, 0x8A, + 0xB5, 0x81, 0xEC, 0x90, 0xB3, 0x78, 0x79, 0x01, 0xA9, 0x48, 0xC5, 0x1B, + 0x79, 0xEC, 0xAC, 0x30, 0x93, 0x58, 0x50, 0x7B, 0x9C, 0x87, 0xB5, 0xCC, + 0x0D, 0x99, 0x8B, 0x8E, 0x54, 0x88, 0xB1, 0x88, 0x0D, 0x38, 0x5E, 0x0B, + 0x1A, 0x98, 0xF8, 0xC4, 0xB4, 0xCB, 0x4A, 0x32, 0x33, 0x1C, 0x98, 0x60, + 0x2C, 0x17, 0x32, 0x8A, 0x65, 0x64, 0x48, 0x45, 0x64, 0x1D, 0x93, 0x70, + 0x4E, 0x84, 0x21, 0xC7, 0x6F, 0x63, 0x6E, 0xCE, 0x30, 0x7E, 0xD7, 0x25, + 0xF2, 0x89, 0xD7, 0x4E, 0xA1, 0x62, 0x5D, 0x19, 0x58, 0x37, 0x14, 0xE1, + 0xF9, 0x5C, 0x1C, 0x58, 0xBB, 0x56, 0xCB, 0x59, 0xB3, 0xAB, 0x26, 0x83, + 0xBA, 0xEC, 0x7C, 0x8A, 0x99, 0x66, 0x2F, 0xCD, 0x56, 0x9A, 0x5D, 0x34, + 0xFB, 0x67, 0xF6, 0xCE, 0x6C, 0x5B, 0xBF, 0x63, 0x3E, 0x4E, 0x6A, 0x17, + 0x10, 0x22, 0x27, 0xE5, 0x70, 0x71, 0xA1, 0x1A, 0xB5, 0xAE, 0x40, 0xB8, + 0x5E, 0x06, 0xD4, 0xA7, 0x2C, 0xD2, 0xD1, 0x7B, 0x4E, 0x4C, 0xB0, 0x0F, + 0xFB, 0x12, 0xA1, 0xE3, 0x77, 0x82, 0xAE, 0x74, 0x34, 0xC5, 0x71, 0x93, + 0x8C, 0xB2, 0x95, 0xA1, 0xF2, 0xD6, 0x49, 0xE7, 0x2D, 0x68, 0xE5, 0x6B, + 0x95, 0x6B, 0x45, 0x6B, 0xE5, 0x6A, 0x75, 0x6A, 0x25, 0x76, 0x17, 0x17, + 0x12, 0x41, 0x7D, 0x4A, 0xC2, 0xFA, 0xCB, 0x5D, 0x40, 0xCE, 0xC4, 0x85, + 0x63, 0x28, 0x83, 0x66, 0x6A, 0xDA, 0x4A, 0xA1, 0xC7, 0xB0, 0xB6, 0x39, + 0x11, 0xB8, 0xB6, 0x2F, 0x44, 0xCE, 0x9B, 0x43, 0x7B, 0xAC, 0xFE, 0x56, + 0xC0, 0xE4, 0xA8, 0x02, 0x50, 0xB6, 0x2A, 0x05, 0x30, 0x9B, 0xC6, 0xAD, + 0xE1, 0x94, 0xA3, 0x3E, 0x18, 0x3E, 0xC5, 0x31, 0xB8, 0xCE, 0x2A, 0x83, + 0x2B, 0xA4, 0x98, 0x5F, 0x37, 0x32, 0x08, 0x2C, 0xE7, 0x18, 0x1E, 0x74, + 0x84, 0x5C, 0x78, 0xD0, 0x27, 0x78, 0x54, 0xEF, 0x15, 0xB3, 0x4B, 0x1A, + 0x70, 0xB6, 0xB0, 0x9C, 0xA7, 0xAA, 0x42, 0xE2, 0x83, 0x68, 0x04, 0x9A, + 0xD1, 0x60, 0x4D, 0xB4, 0xE4, 0x22, 0xCE, 0x54, 0x23, 0x5D, 0x81, 0x50, + 0x03, 0x29, 0x7A, 0x8F, 0x69, 0xD8, 0xEA, 0xBD, 0x86, 0x34, 0x7A, 0x3F, + 0xDD, 0x77, 0xDD, 0xFD, 0xD9, 0x6C, 0x0B, 0x49, 0x29, 0xB6, 0xD0, 0xB5, + 0x3D, 0xAE, 0x11, 0xBB, 0x94, 0x79, 0xEB, 0x85, 0x72, 0xA0, 0x26, 0x6B, + 0xBC, 0x90, 0x0C, 0x12, 0x14, 0x5D, 0x2B, 0x49, 0x9B, 0xAF, 0x7A, 0x6E, + 0x75, 0x58, 0x9C, 0xF7, 0x15, 0xA0, 0xE5, 0x25, 0x38, 0x49, 0x5C, 0xFF, + 0xF6, 0x34, 0x8C, 0x66, 0xC7, 0x47, 0x6F, 0xEF, 0x3F, 0xE2, 0xE5, 0x59, + 0x7A, 0x9D, 0x5B, 0x55, 0x27, 0x65, 0x4A, 0x26, 0xD5, 0x20, 0x6E, 0xFA, + 0xD5, 0xC0, 0xCA, 0x7F, 0x94, 0x52, 0xDD, 0x5D, 0xCF, 0x72, 0xD2, 0xED, + 0x34, 0xDD, 0xDB, 0x49, 0xD3, 0xD4, 0x1E, 0x37, 0x78, 0xDD, 0x52, 0x4F, + 0x0A, 0x41, 0x98, 0x97, 0x58, 0xCE, 0x0B, 0x94, 0xAB, 0xF7, 0xF6, 0xA2, + 0xC1, 0xEA, 0x35, 0x11, 0x1E, 0x61, 0x71, 0xF1, 0xC3, 0x9B, 0xBA, 0x4E, + 0x39, 0xA2, 0x75, 0x51, 0x75, 0xF6, 0xD8, 0xEC, 0x46, 0x13, 0x2A, 0xB6, + 0x87, 0x99, 0x4A, 0x43, 0x0C, 0x97, 0x61, 0xBB, 0xDC, 0x25, 0x4F, 0x77, + 0x0A, 0x16, 0x82, 0xCB, 0x35, 0x55, 0x97, 0x60, 0x67, 0xA0, 0xA2, 0xEA, + 0x60, 0x73, 0xA0, 0x20, 0xA4, 0x4C, 0x46, 0x96, 0x33, 0x1A, 0x48, 0x4F, + 0x89, 0xE0, 0x96, 0xF3, 0x5A, 0x63, 0x3F, 0x1A, 0xD3, 0x38, 0xF1, 0xF2, + 0x38, 0x1A, 0xCE, 0x34, 0xC1, 0xF2, 0x1A, 0x66, 0x81, 0xE5, 0xFC, 0xF9, + 0xF2, 0x1D, 0xE6, 0x4C, 0x83, 0xD1, 0xA3, 0xA2, 0x11, 0x57, 0x0B, 0x18, + 0x2D, 0xEF, 0x2F, 0x9F, 0x20, 0xAB, 0x1F, 0x84, 0x26, 0xCA, 0x06, 0x9D, + 0x56, 0xB7, 0x7A, 0xD9, 0x93, 0x35, 0xB9, 0xC1, 0x5E, 0x39, 0x4C, 0xCB, + 0xB0, 0xD8, 0xD3, 0x4D, 0xE0, 0xFB, 0xCC, 0x47, 0x53, 0xF0, 0x67, 0x6C, + 0x26, 0x50, 0x46, 0x39, 0xEB, 0x21, 0x1C, 0x72, 0x29, 0x28, 0x11, 0x68, + 0x16, 0xFB, 0x1D, 0x8C, 0x89, 0x0F, 0xDF, 0x3F, 0x68, 0x4A, 0xFF, 0x4B, + 0x39, 0x85, 0xEF, 0x3D, 0x72, 0xDF, 0x4B, 0x99, 0x08, 0x3C, 0x87, 0x77, + 0xAC, 0x8F, 0x72, 0xB5, 0xC4, 0xB4, 0x83, 0x70, 0xC6, 0x53, 0x79, 0x8B, + 0xD1, 0x09, 0x8F, 0x97, 0xD4, 0x53, 0x3D, 0x8D, 0x3E, 0xBC, 0x43, 0x6E, + 0x3F, 0x19, 0x0C, 0xF0, 0x96, 0xBC, 0x24, 0x5F, 0xF6, 0xFE, 0x34, 0x70, + 0x17, 0xAA, 0x4B, 0x74, 0xDE, 0x4B, 0x9B, 0xF1, 0x41, 0x34, 0x37, 0x91, + 0x6C, 0xB1, 0xE2, 0x19, 0x33, 0x2F, 0x32, 0x1B, 0x6D, 0xB5, 0xF3, 0xB4, + 0xC7, 0xF9, 0xA7, 0xBA, 0xF3, 0x0F, 0xD5, 0xFA, 0xC0, 0xFA}; +const uint8_t g_ruRU_Locale[] = { + 0x78, 0x9C, 0xAD, 0x57, 0x4D, 0x4F, 0x13, 0x41, 0x18, 0x3E, 0x63, 0xE2, + 0x7F, 0x98, 0x6C, 0x24, 0x68, 0x02, 0xAD, 0x1E, 0x25, 0x65, 0x13, 0x22, + 0x0A, 0x06, 0xD7, 0x90, 0x16, 0x34, 0x72, 0x31, 0xDB, 0xDD, 0xA1, 0x5D, + 0xE8, 0xEE, 0x90, 0xE9, 0x6E, 0xB0, 0x7B, 0x2A, 0x85, 0xE8, 0x05, 0x25, + 0xE1, 0xA0, 0x47, 0xF4, 0xE4, 0xC9, 0x50, 0xBE, 0x12, 0x82, 0xB6, 0x24, + 0xFE, 0x82, 0xD9, 0xFF, 0x60, 0xD4, 0x9F, 0xE1, 0x3B, 0xFB, 0xD1, 0xEE, + 0xB7, 0xC5, 0xD8, 0x1E, 0x3A, 0xF3, 0x3E, 0xCF, 0xF3, 0xCE, 0xFB, 0xB5, + 0xD3, 0xB6, 0xD4, 0x20, 0x8A, 0xDC, 0xC0, 0xC8, 0x90, 0x75, 0x3C, 0x23, + 0x50, 0xEB, 0x65, 0x79, 0x45, 0x40, 0x2A, 0x6E, 0x2A, 0x33, 0xC2, 0x8F, + 0xAB, 0xDD, 0xDF, 0x47, 0x5F, 0x6E, 0xC3, 0xC7, 0xAF, 0xDE, 0x87, 0x9F, + 0xEF, 0x8F, 0xEE, 0x08, 0xE2, 0xCD, 0x1B, 0x08, 0x95, 0x38, 0xDF, 0x50, + 0x65, 0x5A, 0x69, 0xE9, 0x55, 0xD2, 0x68, 0xFA, 0xD2, 0x1A, 0xC5, 0x35, + 0x42, 0x35, 0xD9, 0xE0, 0xAC, 0x31, 0x54, 0xD2, 0x89, 0x61, 0xD6, 0x9F, + 0x02, 0xD4, 0xE4, 0xFB, 0x31, 0x6F, 0x2F, 0x3A, 0xFB, 0xAC, 0xC7, 0x4E, + 0x58, 0xD7, 0x69, 0x3B, 0xFB, 0xA5, 0xA2, 0x67, 0x0B, 0xC3, 0xBB, 0xEC, + 0x9C, 0x9D, 0x38, 0x6D, 0xD6, 0x65, 0x5F, 0x53, 0x09, 0xEC, 0x9B, 0xAB, + 0xED, 0xB0, 0x6E, 0x1A, 0xD8, 0x65, 0x57, 0xA0, 0x3D, 0xCF, 0xD3, 0xA6, + 0x02, 0x17, 0xCE, 0x3B, 0xD6, 0xCB, 0x86, 0x32, 0xDC, 0x75, 0x21, 0x91, + 0x53, 0x67, 0xC7, 0xD9, 0xCE, 0x08, 0xC7, 0xD9, 0x86, 0x50, 0x7A, 0x4E, + 0x07, 0x72, 0x3E, 0xCE, 0xC8, 0x97, 0xF5, 0xD9, 0x65, 0x3E, 0xA1, 0xC7, + 0xFA, 0x79, 0xF0, 0x19, 0x1C, 0x71, 0x09, 0x91, 0xC4, 0x09, 0xC8, 0x5F, + 0x0F, 0x1A, 0x10, 0x6E, 0x08, 0x92, 0xAB, 0x55, 0x3A, 0x23, 0xDC, 0x13, + 0x92, 0x9D, 0x29, 0xE4, 0x34, 0x25, 0x0D, 0x1B, 0xA1, 0x1F, 0x99, 0xB2, + 0xFF, 0xDD, 0x8A, 0xD4, 0xD8, 0xFD, 0x1E, 0xA4, 0x06, 0xE1, 0x16, 0x3F, + 0x15, 0xF1, 0xAB, 0x9E, 0x8A, 0xB9, 0x25, 0x2F, 0xE4, 0xD7, 0x5A, 0x95, + 0x5B, 0xA1, 0xD1, 0x87, 0x9D, 0x08, 0x01, 0xF6, 0x21, 0x98, 0x4B, 0x3E, + 0x9F, 0x7E, 0x50, 0x7B, 0xEC, 0xBC, 0x54, 0xE4, 0xD8, 0x90, 0x74, 0x05, + 0x31, 0xF5, 0x00, 0x3C, 0x73, 0x87, 0x78, 0x0F, 0xD6, 0x17, 0xEC, 0x32, + 0x4E, 0x3A, 0x81, 0x72, 0xF7, 0xC1, 0x4F, 0x1A, 0x08, 0xC3, 0xD8, 0x76, + 0xF5, 0xDD, 0x38, 0xF0, 0x06, 0xCE, 0xED, 0x40, 0x14, 0xE7, 0x40, 0x38, + 0x4D, 0x9C, 0xEB, 0xEC, 0x03, 0x08, 0x0E, 0x9D, 0xD7, 0x49, 0xE5, 0xB6, + 0xB3, 0xC3, 0x8E, 0xE1, 0xDD, 0xF7, 0xDA, 0xEC, 0x83, 0xC8, 0x5D, 0xA5, + 0xE4, 0x1C, 0x9B, 0x2E, 0xD7, 0xFF, 0x81, 0xB3, 0x1D, 0x3F, 0xF2, 0x90, + 0xF5, 0xE2, 0xA6, 0x03, 0xA7, 0x13, 0x37, 0x7D, 0x72, 0xDA, 0x71, 0xD3, + 0xE7, 0x24, 0xEB, 0x30, 0x45, 0xC8, 0x8E, 0xB3, 0x43, 0xD5, 0x31, 0xD5, + 0x54, 0x0D, 0xEB, 0xE1, 0xEB, 0xC9, 0x37, 0x89, 0xB3, 0x12, 0xB4, 0x33, + 0xD8, 0x44, 0xA1, 0xA5, 0x18, 0x84, 0x86, 0xDB, 0x90, 0x73, 0x4C, 0xE5, + 0x90, 0x5F, 0xD8, 0xF1, 0x91, 0xE9, 0x23, 0xD6, 0x2B, 0x38, 0x6F, 0x61, + 0x6C, 0xB8, 0x61, 0x88, 0x44, 0x8D, 0xC8, 0x5D, 0x05, 0x6A, 0xB8, 0x6A, + 0x8B, 0xB1, 0xBB, 0xD6, 0xB3, 0xAA, 0xB2, 0x89, 0x97, 0x64, 0xD3, 0xC4, + 0xD4, 0x18, 0xD4, 0x7E, 0x60, 0xF1, 0xAF, 0xE3, 0x35, 0xAB, 0xD1, 0x10, + 0xC4, 0x39, 0x24, 0xC1, 0x0B, 0xBD, 0x80, 0x17, 0x9A, 0x80, 0x27, 0x64, + 0x82, 0x57, 0x62, 0x40, 0xCD, 0xD2, 0x36, 0x88, 0x51, 0xFB, 0x57, 0xAD, + 0x8E, 0x55, 0x90, 0xCE, 0x15, 0x24, 0xA9, 0xC0, 0x95, 0x23, 0x69, 0x9A, + 0x75, 0x42, 0xCD, 0xA1, 0x2A, 0xAE, 0x41, 0x28, 0x62, 0xF1, 0x8B, 0x60, + 0x6A, 0x7A, 0xAC, 0x08, 0x21, 0x4B, 0xA4, 0x08, 0x0B, 0xD3, 0x92, 0x34, + 0x5D, 0xA9, 0xA0, 0xD5, 0x52, 0x31, 0x44, 0xC9, 0xD2, 0x78, 0xC9, 0x5F, + 0x4F, 0xE3, 0x26, 0xED, 0x4B, 0x46, 0x12, 0xF8, 0x19, 0x73, 0x49, 0x9C, + 0xCF, 0xB3, 0x8D, 0xE5, 0xE6, 0xB7, 0x7C, 0x19, 0xAC, 0xC1, 0x1C, 0xCC, + 0xCB, 0xC6, 0xFA, 0xC6, 0x82, 0xDE, 0xAC, 0x3C, 0x9C, 0x7B, 0xB4, 0xF5, + 0xFC, 0x55, 0x7D, 0xD1, 0x5E, 0xF5, 0x8A, 0x14, 0x26, 0xB9, 0x4A, 0xC3, + 0xD2, 0xAB, 0x98, 0x46, 0x2B, 0x15, 0xB1, 0xF9, 0x21, 0x81, 0x0D, 0x66, + 0x59, 0x11, 0x44, 0x7B, 0xD2, 0xB6, 0xEF, 0x17, 0x6C, 0xDB, 0x2E, 0x15, + 0x23, 0xBC, 0x6C, 0xA9, 0x62, 0x51, 0x8A, 0x0D, 0xA5, 0x35, 0xD4, 0xDE, + 0x1A, 0x59, 0xBB, 0x89, 0xA9, 0x82, 0x0D, 0xD3, 0x97, 0x8E, 0x27, 0x75, + 0xBC, 0x1E, 0x89, 0x1C, 0x06, 0x79, 0x0D, 0x53, 0x1D, 0x8B, 0x9A, 0x7C, + 0xF7, 0x2A, 0x56, 0x34, 0x5D, 0x86, 0x21, 0x98, 0x0C, 0xBC, 0x78, 0x70, + 0xA6, 0xA0, 0x46, 0x89, 0xB5, 0xA9, 0xF1, 0x11, 0xF8, 0xFE, 0x71, 0x44, + 0xC9, 0x20, 0x85, 0xF1, 0x11, 0x05, 0xBA, 0x66, 0x58, 0x4D, 0x41, 0x9C, + 0x1A, 0x91, 0x6E, 0x63, 0x4A, 0x04, 0xF1, 0x6E, 0x82, 0x3D, 0xAC, 0x4C, + 0xA4, 0xE1, 0x41, 0x37, 0x22, 0xA5, 0x89, 0x1A, 0x83, 0x29, 0x74, 0x37, + 0x82, 0xE8, 0x7E, 0x47, 0x47, 0x19, 0x39, 0x2A, 0xAD, 0x49, 0xF8, 0x42, + 0x10, 0xCB, 0x2B, 0xE5, 0x6B, 0xC8, 0xC2, 0x9D, 0x48, 0x88, 0xDC, 0xAB, + 0x2E, 0x11, 0x37, 0x7F, 0xCA, 0x5B, 0x9B, 0x78, 0x4D, 0x56, 0x82, 0xBB, + 0x35, 0xD8, 0xFA, 0x3E, 0xA5, 0x16, 0xFC, 0xE0, 0x54, 0xD1, 0x12, 0xD4, + 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2, + 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A, + 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54, + 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91, + 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4, + 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5, + 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19, + 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B, + 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB, + 0x8B, 0xC4}; +static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { + if (pBuf == NULL || nBufLen <= 0) { + return NULL; + } + CFX_GEModule* pGeModule = CFX_GEModule::Get(); + if (!pGeModule) { + return NULL; + } + CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); + if (!pCodecMgr) { + return NULL; + } + CXML_Element* pLocale = NULL; + uint8_t* pOut = NULL; + FX_DWORD dwSize; + pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0, + 0, 0, 0, 0, pOut, dwSize); + if (pOut) { + pLocale = CXML_Element::Parse(pOut, dwSize); + FX_Free(pOut); + } + if (pLocale) { + return new CXFA_XMLLocale(pLocale); + } + return NULL; +} +static FX_WORD XFA_GetLanguage(CFX_WideString wsLanguage) { + FX_WORD dwLangueID = XFA_LANGID_en_US; + if (wsLanguage.GetLength() < 2) { + return dwLangueID; + } + wsLanguage.MakeLower(); + FX_DWORD dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); + FX_DWORD dwIDSecond = wsLanguage.GetLength() >= 5 + ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) + : 0; + switch (dwIDFirst) { + case FXBSTR_ID(0, 0, 'z', 'h'): { + if (dwIDSecond == FXBSTR_ID(0, 0, 'c', 'n')) { + dwLangueID = XFA_LANGID_zh_CN; + } else if (dwIDSecond == FXBSTR_ID(0, 0, 't', 'w')) { + dwLangueID = XFA_LANGID_zh_TW; + } else if (dwIDSecond == FXBSTR_ID(0, 0, 'h', 'k')) { + dwLangueID = XFA_LANGID_zh_HK; + } + } break; + case FXBSTR_ID(0, 0, 'j', 'a'): + dwLangueID = XFA_LANGID_ja_JP; + break; + case FXBSTR_ID(0, 0, 'k', 'o'): + dwLangueID = XFA_LANGID_ko_KR; + break; + case FXBSTR_ID(0, 0, 'e', 'n'): { + if (dwIDSecond == FXBSTR_ID(0, 0, 'g', 'b')) { + dwLangueID = XFA_LANGID_en_GB; + } else { + dwLangueID = XFA_LANGID_en_US; + } + } break; + case FXBSTR_ID(0, 0, 'd', 'e'): + dwLangueID = XFA_LANGID_de_DE; + break; + case FXBSTR_ID(0, 0, 'f', 'r'): + dwLangueID = XFA_LANGID_fr_FR; + break; + case FXBSTR_ID(0, 0, 'e', 's'): { + if (dwIDSecond == FXBSTR_ID(0, 0, 'e', 's')) { + dwLangueID = XFA_LANGID_es_ES; + } else { + dwLangueID = XFA_LANGID_es_LA; + } + } break; + case FXBSTR_ID(0, 0, 'i', 't'): + dwLangueID = XFA_LANGID_it_IT; + break; + case FXBSTR_ID(0, 0, 'p', 't'): + dwLangueID = XFA_LANGID_pt_BR; + break; + case FXBSTR_ID(0, 0, 'n', 'l'): + dwLangueID = XFA_LANGID_nl_NL; + break; + case FXBSTR_ID(0, 0, 'r', 'u'): + dwLangueID = XFA_LANGID_ru_RU; + break; + } + return dwLangueID; +} +CXFA_LocaleMgr::CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid) + : m_dwLocaleFlags(0x00) { + m_dwDeflcid = XFA_GetLanguage(wsDeflcid); + CXFA_Node* pNodeLocale = NULL; + if (pLocaleSet && + (pNodeLocale = pLocaleSet->GetNodeItem(XFA_NODEITEM_FirstChild))) { + while (pNodeLocale) { + m_LocaleArray.Add(new CXFA_NodeLocale(pNodeLocale)); + pNodeLocale = pNodeLocale->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } + 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(); + } +} +void CXFA_LocaleMgr::Release() { + delete this; +} +FX_WORD CXFA_LocaleMgr::GetDefLocaleID() { + return m_dwDeflcid; +} +IFX_Locale* CXFA_LocaleMgr::GetDefLocale() { + 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]; + } + m_pDefLocale = GetLocale(m_dwDeflcid); + if (m_pDefLocale) + m_XMLLocaleArray.Add(m_pDefLocale); + return m_pDefLocale; +} +IFX_Locale* CXFA_LocaleMgr::GetLocale(FX_WORD lcid) { + IFX_Locale* pLocal = NULL; + switch (lcid) { + case XFA_LANGID_zh_CN: + pLocal = XFA_GetLocaleFromBuffer(g_zhCN_Locale, sizeof(g_zhCN_Locale)); + break; + case XFA_LANGID_zh_TW: + pLocal = XFA_GetLocaleFromBuffer(g_zhTW_Locale, sizeof(g_zhTW_Locale)); + break; + case XFA_LANGID_zh_HK: + pLocal = XFA_GetLocaleFromBuffer(g_zhHK_Locale, sizeof(g_zhHK_Locale)); + break; + case XFA_LANGID_ja_JP: + pLocal = XFA_GetLocaleFromBuffer(g_jaJP_Locale, sizeof(g_jaJP_Locale)); + break; + case XFA_LANGID_ko_KR: + pLocal = XFA_GetLocaleFromBuffer(g_koKR_Locale, sizeof(g_koKR_Locale)); + break; + case XFA_LANGID_en_GB: + pLocal = XFA_GetLocaleFromBuffer(g_enGB_Locale, sizeof(g_enGB_Locale)); + break; + case XFA_LANGID_es_LA: + pLocal = XFA_GetLocaleFromBuffer(g_esLA_Locale, sizeof(g_esLA_Locale)); + break; + case XFA_LANGID_es_ES: + pLocal = XFA_GetLocaleFromBuffer(g_esES_Locale, sizeof(g_esES_Locale)); + break; + case XFA_LANGID_de_DE: + pLocal = XFA_GetLocaleFromBuffer(g_deDE_Loacale, sizeof(g_deDE_Loacale)); + break; + case XFA_LANGID_fr_FR: + pLocal = XFA_GetLocaleFromBuffer(g_frFR_Locale, sizeof(g_frFR_Locale)); + break; + case XFA_LANGID_it_IT: + pLocal = XFA_GetLocaleFromBuffer(g_itIT_Locale, sizeof(g_itIT_Locale)); + break; + case XFA_LANGID_pt_BR: + pLocal = XFA_GetLocaleFromBuffer(g_ptBR_Locale, sizeof(g_ptBR_Locale)); + break; + case XFA_LANGID_nl_NL: + pLocal = XFA_GetLocaleFromBuffer(g_nlNL_Locale, sizeof(g_nlNL_Locale)); + break; + case XFA_LANGID_ru_RU: + pLocal = XFA_GetLocaleFromBuffer(g_ruRU_Locale, sizeof(g_ruRU_Locale)); + break; + case XFA_LANGID_en_US: + default: + pLocal = XFA_GetLocaleFromBuffer(g_enUS_Locale, sizeof(g_enUS_Locale)); + break; + } + return pLocal; +} +IFX_Locale* CXFA_LocaleMgr::GetLocaleByName( + const CFX_WideStringC& 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]); + if (pLocale->GetName() == wsLocaleName) { + return pLocale; + } + } + int32_t iLen = wsLocaleName.GetLength(); + if (iLen < 2) { + return NULL; + } + iCount = m_XMLLocaleArray.GetSize(); + for (i = 0; i < iCount; i++) { + IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]); + if (pLocale->GetName() == wsLocaleName) { + return pLocale; + } + } + FX_WORD dwLangueID = XFA_GetLanguage(wsLocaleName); + IFX_Locale* pLocale = GetLocale(dwLangueID); + if (pLocale) + m_XMLLocaleArray.Add(pLocale); + return pLocale; +} +void CXFA_LocaleMgr::SetDefLocale(IFX_Locale* pLocale) { + m_pDefLocale = pLocale; +} +CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) { + if (!(m_dwLocaleFlags & 0x01)) { + m_wsConfigLocale.Empty(); + if (pConfig) { + CXFA_Node* pChildfConfig = + pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); + if (!pChildfConfig) { + pChildfConfig = pConfig->GetFirstChildByClass(XFA_ELEMENT_Present); + } + CXFA_Node* pCommon = + pChildfConfig + ? pChildfConfig->GetFirstChildByClass(XFA_ELEMENT_Common) + : NULL; + CXFA_Node* pLocale = + pCommon ? pCommon->GetFirstChildByClass(XFA_ELEMENT_Locale) : NULL; + if (pLocale) { + pLocale->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale, FALSE); + } + } + m_dwLocaleFlags |= 0x01; + } + return m_wsConfigLocale; +} +static CXFA_TimeZoneProvider* g_pProvider = NULL; +IXFA_TimeZoneProvider* IXFA_TimeZoneProvider::Create() { + FXSYS_assert(!g_pProvider); + g_pProvider = new CXFA_TimeZoneProvider(); + return g_pProvider; +} +IXFA_TimeZoneProvider* IXFA_TimeZoneProvider::Get() { + if (!g_pProvider) { + g_pProvider = new CXFA_TimeZoneProvider(); + } + return g_pProvider; +} +void IXFA_TimeZoneProvider::Destroy() { + delete g_pProvider; + g_pProvider = NULL; +} +#include <time.h> +CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + _tzset(); + m_tz.tzHour = (int8_t)(_timezone / 3600 * -1); + m_tz.tzMinute = (int8_t)((FXSYS_abs(_timezone) % 3600) / 60); +#else + tzset(); + m_tz.tzHour = (int8_t)(timezone / 3600 * -1); + m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); +#endif +} +CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} +void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { + m_tz = tz; +} +void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { + tz = m_tz; +} diff --git a/xfa/fxfa/parser/xfa_localemgr.h b/xfa/fxfa/parser/xfa_localemgr.h new file mode 100644 index 0000000000..e296fc4663 --- /dev/null +++ b/xfa/fxfa/parser/xfa_localemgr.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_PARSER_XFA_LOCALEMGR_H_ +#define XFA_FXFA_PARSER_XFA_LOCALEMGR_H_ + +#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; + +#define XFA_LANGID_zh_CN 0x0804 +#define XFA_LANGID_zh_TW 0x0404 +#define XFA_LANGID_zh_HK 0x0c04 +#define XFA_LANGID_ja_JP 0x0411 +#define XFA_LANGID_ko_KR 0x0412 +#define XFA_LANGID_en_US 0x0409 +#define XFA_LANGID_en_GB 0x0809 +#define XFA_LANGID_es_ES 0x0c0a +#define XFA_LANGID_es_LA 0x080a +#define XFA_LANGID_de_DE 0x0407 +#define XFA_LANGID_fr_FR 0x040c +#define XFA_LANGID_it_IT 0x0410 +#define XFA_LANGID_pt_BR 0x0416 +#define XFA_LANGID_nl_NL 0x0413 +#define XFA_LANGID_ru_RU 0x0419 + +class CXFA_LocaleMgr : public IFX_LocaleMgr { + public: + CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid); + virtual void Release(); + virtual FX_WORD GetDefLocaleID(); + virtual IFX_Locale* GetDefLocale(); + virtual IFX_Locale* GetLocale(FX_WORD lcid); + virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName); + ~CXFA_LocaleMgr(); + void SetDefLocale(IFX_Locale* pLocale); + CFX_WideStringC GetConfigLocaleName(CXFA_Node* pConfig); + + protected: + CFX_PtrArray m_LocaleArray; + CFX_PtrArray m_XMLLocaleArray; + IFX_Locale* m_pDefLocale; + CFX_WideString m_wsConfigLocale; + FX_WORD m_dwDeflcid; + FX_WORD m_dwLocaleFlags; +}; + +class IXFA_TimeZoneProvider { + public: + static IXFA_TimeZoneProvider* Create(); + static IXFA_TimeZoneProvider* Get(); + static void Destroy(); + + virtual ~IXFA_TimeZoneProvider() {} + + virtual void SetTimeZone(FX_TIMEZONE& tz) = 0; + + virtual void GetTimeZone(FX_TIMEZONE& tz) = 0; +}; +class CXFA_TimeZoneProvider : public IXFA_TimeZoneProvider { + public: + CXFA_TimeZoneProvider(); + virtual ~CXFA_TimeZoneProvider(); + virtual void SetTimeZone(FX_TIMEZONE& tz); + virtual void GetTimeZone(FX_TIMEZONE& tz); + + private: + FX_TIMEZONE m_tz; +}; + +#endif // XFA_FXFA_PARSER_XFA_LOCALEMGR_H_ diff --git a/xfa/fxfa/parser/xfa_localevalue.cpp b/xfa/fxfa/parser/xfa_localevalue.cpp new file mode 100644 index 0000000000..8b3efa5951 --- /dev/null +++ b/xfa/fxfa/parser/xfa_localevalue.cpp @@ -0,0 +1,981 @@ +// 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/fxfa/parser/xfa_localevalue.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" +#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 const FX_DOUBLE fraction_scales[] = {0.1, + 0.01, + 0.001, + 0.0001, + 0.00001, + 0.000001, + 0.0000001, + 0.00000001, + 0.000000001, + 0.0000000001, + 0.00000000001, + 0.000000000001, + 0.0000000000001, + 0.00000000000001, + 0.000000000000001, + 0.0000000000000001}; +CXFA_LocaleValue::CXFA_LocaleValue() { + m_dwType = XFA_VT_NULL; + m_bValid = TRUE; + m_pLocaleMgr = NULL; +} +CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& value) { + m_dwType = XFA_VT_NULL; + m_bValid = TRUE; + m_pLocaleMgr = NULL; + *this = value; +} +CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, + CXFA_LocaleMgr* pLocaleMgr) { + m_dwType = dwType; + m_bValid = (m_dwType != XFA_VT_NULL); + m_pLocaleMgr = pLocaleMgr; +} +CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, + const CFX_WideString& wsValue, + CXFA_LocaleMgr* pLocaleMgr) { + m_wsValue = wsValue; + m_dwType = dwType; + m_pLocaleMgr = pLocaleMgr; + m_bValid = ValidateCanonicalValue(wsValue, dwType); +} +CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, + const CFX_WideString& wsValue, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + CXFA_LocaleMgr* pLocaleMgr) { + m_pLocaleMgr = pLocaleMgr; + m_bValid = TRUE; + m_dwType = dwType; + m_bValid = ParsePatternValue(wsValue, wsFormat, pLocale); +} +CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& value) { + m_wsValue = value.m_wsValue; + m_dwType = value.m_dwType; + m_bValid = value.m_bValid; + m_pLocaleMgr = value.m_pLocaleMgr; + return *this; +} +CXFA_LocaleValue::~CXFA_LocaleValue() {} +static FX_LOCALECATEGORY XFA_ValugeCategory(FX_LOCALECATEGORY eCategory, + FX_DWORD dwValueType) { + if (eCategory == FX_LOCALECATEGORY_Unknown) { + switch (dwValueType) { + case XFA_VT_BOOLEAN: + case XFA_VT_INTEGER: + case XFA_VT_DECIMAL: + case XFA_VT_FLOAT: + return FX_LOCALECATEGORY_Num; + case XFA_VT_TEXT: + return FX_LOCALECATEGORY_Text; + case XFA_VT_DATE: + return FX_LOCALECATEGORY_Date; + case XFA_VT_TIME: + return FX_LOCALECATEGORY_Time; + case XFA_VT_DATETIME: + return FX_LOCALECATEGORY_DateTime; + } + } + return eCategory; +} +FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, + const CFX_WideString& wsPattern, + IFX_Locale* pLocale, + CFX_WideString* pMatchFormat) { + CFX_WideString wsOutput; + IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); + if (pLocale) { + m_pLocaleMgr->SetDefLocale(pLocale); + } + IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); + CFX_WideStringArray wsPatterns; + pFormat->SplitFormatString(wsPattern, wsPatterns); + FX_BOOL bRet = FALSE; + int32_t iCount = wsPatterns.GetSize(); + int32_t i = 0; + for (; i < iCount && !bRet; i++) { + CFX_WideString wsFormat = wsPatterns[i]; + FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); + eCategory = XFA_ValugeCategory(eCategory, m_dwType); + switch (eCategory) { + case FX_LOCALECATEGORY_Null: + bRet = pFormat->ParseNull(wsValue, wsFormat); + if (!bRet) { + bRet = wsValue.IsEmpty(); + } + break; + case FX_LOCALECATEGORY_Zero: + bRet = pFormat->ParseZero(wsValue, wsFormat); + if (!bRet) { + bRet = wsValue == FX_WSTRC(L"0"); + } + break; + case FX_LOCALECATEGORY_Num: { + CFX_WideString fNum; + bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); + if (!bRet) { + bRet = pFormat->FormatNum(wsValue, wsFormat, wsOutput); + } + break; + } + case FX_LOCALECATEGORY_Text: + bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput); + wsOutput.Empty(); + if (!bRet) { + bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput); + } + break; + case FX_LOCALECATEGORY_Date: { + CFX_Unitime dt; + bRet = ValidateCanonicalDate(wsValue, dt); + if (!bRet) { + bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, + dt); + if (!bRet) { + bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, + FX_DATETIMETYPE_Date); + } + } + break; + } + case FX_LOCALECATEGORY_Time: { + CFX_Unitime dt; + bRet = + pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, dt); + if (!bRet) { + bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, + FX_DATETIMETYPE_Time); + } + break; + } + case FX_LOCALECATEGORY_DateTime: { + CFX_Unitime dt; + bRet = pFormat->ParseDateTime(wsValue, wsFormat, + FX_DATETIMETYPE_DateTime, dt); + if (!bRet) { + bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, + FX_DATETIMETYPE_DateTime); + } + break; + } + default: + bRet = FALSE; + break; + } + } + if (bRet && pMatchFormat) { + *pMatchFormat = wsPatterns[i - 1]; + } + pFormat->Release(); + if (pLocale) { + m_pLocaleMgr->SetDefLocale(locale); + } + return bRet; +} +CFX_WideString CXFA_LocaleValue::GetValue() const { + return m_wsValue; +} +FX_DWORD CXFA_LocaleValue::GetType() const { + return m_dwType; +} +void CXFA_LocaleValue::SetValue(const CFX_WideString& wsValue, + FX_DWORD dwType) { + m_wsValue = wsValue; + m_dwType = dwType; +} +CFX_WideString CXFA_LocaleValue::GetText() const { + if (m_bValid && m_dwType == XFA_VT_TEXT) { + return m_wsValue; + } + return CFX_WideString(); +} +FX_FLOAT CXFA_LocaleValue::GetNum() const { + if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || + m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { + int64_t nIntegral = 0; + FX_DWORD dwFractional = 0; + int32_t nExponent = 0; + int cc = 0; + FX_BOOL bNegative = FALSE, bExpSign = FALSE; + const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; + int len = m_wsValue.GetLength(); + while (XFA_IsSpace(str[cc]) && cc < len) { + cc++; + } + if (cc >= len) { + return 0; + } + if (str[0] == '+') { + cc++; + } else if (str[0] == '-') { + bNegative = TRUE; + cc++; + } + int nIntegralLen = 0; + while (cc < len) { + if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { + break; + } + nIntegral = nIntegral * 10 + str[cc] - '0'; + cc++; + nIntegralLen++; + } + nIntegral = bNegative ? -nIntegral : nIntegral; + int scale = 0; + double fraction = 0.0; + if (cc < len && str[cc] == '.') { + cc++; + while (cc < len) { + fraction += fraction_scales[scale] * (str[cc] - '0'); + scale++; + cc++; + if (scale == sizeof fraction_scales / sizeof(double) || + !XFA_IsDigit(str[cc])) { + break; + } + } + dwFractional = (FX_DWORD)(fraction * 4294967296.0); + } + if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = TRUE; + cc++; + } + } + while (cc < len) { + if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { + break; + } + nExponent = nExponent * 10 + str[cc] - '0'; + cc++; + } + nExponent = bExpSign ? -nExponent : nExponent; + } + FX_FLOAT fValue = (FX_FLOAT)(dwFractional / 4294967296.0); + fValue = nIntegral + (nIntegral >= 0 ? fValue : -fValue); + if (nExponent != 0) { + fValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); + } + return fValue; + } + return 0; +} +FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const { + if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || + m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { + int64_t nIntegral = 0; + FX_DWORD dwFractional = 0; + int32_t nExponent = 0; + int32_t cc = 0; + FX_BOOL bNegative = FALSE, bExpSign = FALSE; + const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; + int len = m_wsValue.GetLength(); + while (XFA_IsSpace(str[cc]) && cc < len) { + cc++; + } + if (cc >= len) { + return 0; + } + if (str[0] == '+') { + cc++; + } else if (str[0] == '-') { + bNegative = TRUE; + cc++; + } + int32_t nIntegralLen = 0; + while (cc < len) { + if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { + break; + } + nIntegral = nIntegral * 10 + str[cc] - '0'; + cc++; + nIntegralLen++; + } + nIntegral = bNegative ? -nIntegral : nIntegral; + int32_t scale = 0; + FX_DOUBLE fraction = 0.0; + if (cc < len && str[cc] == '.') { + cc++; + while (cc < len) { + fraction += fraction_scales[scale] * (str[cc] - '0'); + scale++; + cc++; + if (scale == sizeof fraction_scales / sizeof(FX_DOUBLE) || + !XFA_IsDigit(str[cc])) { + break; + } + } + dwFractional = (FX_DWORD)(fraction * 4294967296.0); + } + if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = TRUE; + cc++; + } + } + while (cc < len) { + if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { + break; + } + nExponent = nExponent * 10 + str[cc] - '0'; + cc++; + } + nExponent = bExpSign ? -nExponent : nExponent; + } + FX_DOUBLE dValue = (dwFractional / 4294967296.0); + dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); + if (nExponent != 0) { + dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); + } + return dValue; + } + return 0; +} +CFX_Unitime CXFA_LocaleValue::GetDate() const { + if (m_bValid && m_dwType == XFA_VT_DATE) { + CFX_Unitime dt; + FX_DateFromCanonical(m_wsValue, dt); + return dt; + } + return CFX_Unitime(); +} +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, dt, m_pLocaleMgr->GetDefLocale()); + return dt; + } + return CFX_Unitime(); +} +CFX_Unitime CXFA_LocaleValue::GetDateTime() const { + if (m_bValid && m_dwType == XFA_VT_DATETIME) { + int32_t index = m_wsValue.Find('T'); + CFX_Unitime dt; + FX_DateFromCanonical(m_wsValue.Left(index), dt); + FXSYS_assert(m_pLocaleMgr); + FX_TimeFromCanonical(m_wsValue.Right(m_wsValue.GetLength() - index - 1), dt, + m_pLocaleMgr->GetDefLocale()); + return dt; + } + return CFX_Unitime(); +} +FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText) { + m_dwType = XFA_VT_TEXT; + m_wsValue = wsText; + return TRUE; +} +FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale) { + m_dwType = XFA_VT_TEXT; + return m_bValid = ParsePatternValue(wsText, wsFormat, pLocale); +} +FX_BOOL CXFA_LocaleValue::SetNum(FX_FLOAT fNum) { + m_dwType = XFA_VT_FLOAT; + m_wsValue.Format(L"%.8g", (FX_DOUBLE)fNum); + return TRUE; +} +FX_BOOL CXFA_LocaleValue::SetNum(const CFX_WideString& wsNum, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale) { + m_dwType = XFA_VT_FLOAT; + return m_bValid = ParsePatternValue(wsNum, wsFormat, pLocale); +} +FX_BOOL CXFA_LocaleValue::SetDate(const CFX_Unitime& d) { + m_dwType = XFA_VT_DATE; + m_wsValue.Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), d.GetDay()); + return TRUE; +} +FX_BOOL CXFA_LocaleValue::SetDate(const CFX_WideString& wsDate, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale) { + m_dwType = XFA_VT_DATE; + return m_bValid = ParsePatternValue(wsDate, wsFormat, pLocale); +} +FX_BOOL CXFA_LocaleValue::SetTime(const CFX_Unitime& t) { + m_dwType = XFA_VT_TIME; + m_wsValue.Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), + t.GetSecond()); + if (t.GetMillisecond() > 0) { + CFX_WideString wsTemp; + wsTemp.Format(L"%:03d", t.GetMillisecond()); + m_wsValue += wsTemp; + } + return TRUE; +} +FX_BOOL CXFA_LocaleValue::SetTime(const CFX_WideString& wsTime, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale) { + m_dwType = XFA_VT_TIME; + return m_bValid = ParsePatternValue(wsTime, wsFormat, pLocale); +} +FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_Unitime& dt) { + m_dwType = XFA_VT_DATETIME; + m_wsValue.Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), + dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), + dt.GetSecond()); + if (dt.GetMillisecond() > 0) { + CFX_WideString wsTemp; + wsTemp.Format(L"%:03d", dt.GetMillisecond()); + m_wsValue += wsTemp; + } + return TRUE; +} +FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_WideString& wsDateTime, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale) { + m_dwType = XFA_VT_DATETIME; + return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); +} +FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + XFA_VALUEPICTURE eValueType) const { + wsResult.Empty(); + FX_BOOL bRet = FALSE; + IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); + CFX_WideStringArray wsPatterns; + pFormat->SplitFormatString(wsFormat, wsPatterns); + int32_t iCount = wsPatterns.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType); + if (bRet) { + break; + } + } + pFormat->Release(); + return bRet; +} +FX_BOOL CXFA_LocaleValue::FormatSinglePattern( + CFX_WideString& wsResult, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + XFA_VALUEPICTURE eValueType) const { + IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); + if (pLocale) { + m_pLocaleMgr->SetDefLocale(pLocale); + } + wsResult.Empty(); + FX_BOOL bRet = FALSE; + IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); + FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); + eCategory = XFA_ValugeCategory(eCategory, m_dwType); + switch (eCategory) { + case FX_LOCALECATEGORY_Null: + if (m_wsValue.IsEmpty()) { + bRet = pFormat->FormatNull(wsFormat, wsResult); + } + break; + case FX_LOCALECATEGORY_Zero: + if (m_wsValue == FX_WSTRC(L"0")) { + bRet = pFormat->FormatZero(wsFormat, wsResult); + } + break; + case FX_LOCALECATEGORY_Num: + bRet = pFormat->FormatNum(m_wsValue, wsFormat, wsResult); + break; + case FX_LOCALECATEGORY_Text: + bRet = pFormat->FormatText(m_wsValue, wsFormat, wsResult); + break; + case FX_LOCALECATEGORY_Date: + bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, + FX_DATETIMETYPE_Date); + break; + case FX_LOCALECATEGORY_Time: + bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, + FX_DATETIMETYPE_Time); + break; + case FX_LOCALECATEGORY_DateTime: + bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, + FX_DATETIMETYPE_DateTime); + break; + default: + wsResult = m_wsValue; + bRet = TRUE; + } + pFormat->Release(); + if (!bRet && (eCategory != FX_LOCALECATEGORY_Num || + eValueType != XFA_VALUEPICTURE_Display)) { + wsResult = m_wsValue; + } + if (pLocale) { + m_pLocaleMgr->SetDefLocale(locale); + } + return bRet; +} +static FX_BOOL XFA_ValueSplitDateTime(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); + wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); + return TRUE; +} +FX_BOOL CXFA_LocaleValue::ValidateCanonicalValue(const CFX_WideString& wsValue, + FX_DWORD dwVType) { + if (wsValue.IsEmpty()) { + return TRUE; + } + CFX_Unitime dt; + switch (dwVType) { + case XFA_VT_DATE: { + if (ValidateCanonicalDate(wsValue, dt)) { + return TRUE; + } + CFX_WideString wsDate, wsTime; + if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && + ValidateCanonicalDate(wsDate, dt)) { + return TRUE; + } + return FALSE; + } + case XFA_VT_TIME: { + if (ValidateCanonicalTime(wsValue)) { + return TRUE; + } + CFX_WideString wsDate, wsTime; + if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && + ValidateCanonicalTime(wsTime)) { + return TRUE; + } + return FALSE; + } + case XFA_VT_DATETIME: { + CFX_WideString wsDate, wsTime; + if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && + ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime)) { + return TRUE; + } + } break; + } + return TRUE; +} +FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, + CFX_Unitime& unDate) { + const FX_WORD LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + const FX_WORD wCountY = 4, wCountM = 2, wCountD = 2; + int nLen = wsDate.GetLength(); + if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) { + return FALSE; + } + const bool bSymbol = wsDate.Find(0x2D) != -1; + FX_WORD wYear = 0; + FX_WORD wMonth = 0; + FX_WORD wDay = 0; + const FX_WCHAR* pDate = (const FX_WCHAR*)wsDate; + int nIndex = 0, nStart = 0; + while (pDate[nIndex] != '\0' && nIndex < wCountY) { + if (!XFA_IsDigit(pDate[nIndex])) { + return FALSE; + } + wYear = (pDate[nIndex] - '0') + wYear * 10; + nIndex++; + } + if (bSymbol) { + if (pDate[nIndex] != 0x2D) { + return FALSE; + } + nIndex++; + } + nStart = nIndex; + while (pDate[nIndex] != '\0' && nIndex - nStart < wCountM && nIndex < nLen) { + if (!XFA_IsDigit(pDate[nIndex])) { + return FALSE; + } + wMonth = (pDate[nIndex] - '0') + wMonth * 10; + nIndex++; + } + if (bSymbol) { + if (pDate[nIndex] != 0x2D) { + return FALSE; + } + nIndex++; + } + nStart = nIndex; + while (pDate[nIndex] != '\0' && nIndex - nStart < wCountD && nIndex < nLen) { + if (!XFA_IsDigit(pDate[nIndex])) { + return FALSE; + } + wDay = (pDate[nIndex] - '0') + wDay * 10; + nIndex++; + } + if (nIndex != nLen) { + return FALSE; + } + if (wYear < 1900 || wYear > 2029) { + return FALSE; + } + if (wMonth < 1 || wMonth > 12) { + if (wMonth == 0 && nLen == wCountY) { + return TRUE; + } + return FALSE; + } + if (wDay < 1) { + if (wDay == 0 && (nLen == wCountY + wCountM)) { + return TRUE; + } + return FALSE; + } + if (wMonth == 2) { + if (wYear % 400 == 0 || (wYear % 100 != 0 && wYear % 4 == 0)) { + if (wDay > 29) { + return FALSE; + } + } else { + if (wDay > 28) { + return FALSE; + } + } + } else if (wDay > LastDay[wMonth - 1]) { + return FALSE; + } + CFX_Unitime ut; + ut.Set(wYear, static_cast<uint8_t>(wMonth), static_cast<uint8_t>(wDay)); + unDate = unDate + ut; + return TRUE; +} +FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) { + int nLen = wsTime.GetLength(); + if (nLen < 2) + return FALSE; + const FX_WORD wCountH = 2; + const FX_WORD wCountM = 2; + const FX_WORD wCountS = 2; + const FX_WORD wCountF = 3; + const bool bSymbol = wsTime.Find(':') != -1; + FX_WORD wHour = 0; + FX_WORD wMinute = 0; + FX_WORD wSecond = 0; + FX_WORD wFraction = 0; + const FX_WCHAR* pTime = (const FX_WCHAR*)wsTime; + int nIndex = 0; + int nStart = 0; + while (nIndex - nStart < wCountH && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + wHour = pTime[nIndex] - '0' + wHour * 10; + nIndex++; + } + if (bSymbol) { + if (nIndex < nLen && pTime[nIndex] != ':') + return FALSE; + nIndex++; + } + nStart = nIndex; + while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + wMinute = pTime[nIndex] - '0' + wMinute * 10; + nIndex++; + } + if (bSymbol) { + if (nIndex < nLen && pTime[nIndex] != ':') + return FALSE; + nIndex++; + } + nStart = nIndex; + while (nIndex - nStart < wCountS && nIndex < nLen && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + wSecond = pTime[nIndex] - '0' + wSecond * 10; + nIndex++; + } + if (wsTime.Find('.') > 0) { + if (pTime[nIndex] != '.') + return FALSE; + nIndex++; + nStart = nIndex; + while (nIndex - nStart < wCountF && nIndex < nLen && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + wFraction = pTime[nIndex] - '0' + wFraction * 10; + nIndex++; + } + } + if (nIndex < nLen) { + if (pTime[nIndex] == 'Z') { + nIndex++; + } else if (pTime[nIndex] == '-' || pTime[nIndex] == '+') { + int16_t nOffsetH = 0; + int16_t nOffsetM = 0; + nIndex++; + nStart = nIndex; + while (nIndex - nStart < wCountH && nIndex < nLen && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + nOffsetH = pTime[nIndex] - '0' + nOffsetH * 10; + nIndex++; + } + if (bSymbol) { + if (nIndex < nLen && pTime[nIndex] != ':') + return FALSE; + nIndex++; + } + nStart = nIndex; + while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { + if (!XFA_IsDigit(pTime[nIndex])) + return FALSE; + nOffsetM = pTime[nIndex] - '0' + nOffsetM * 10; + nIndex++; + } + if (nOffsetH > 12 || nOffsetM >= 60) + return FALSE; + } + } + return nIndex == nLen && wHour < 24 && wMinute < 60 && wSecond < 60 && + wFraction <= 999; +} +FX_BOOL CXFA_LocaleValue::ValidateCanonicalDateTime( + const CFX_WideString& wsDateTime) { + CFX_WideString wsDate, wsTime; + 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); + wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); + CFX_Unitime dt; + return ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime); +} +FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, + const CFX_WideString& wsPattern, + IFX_Locale* pLocale) { + IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); + if (pLocale) { + m_pLocaleMgr->SetDefLocale(pLocale); + } + IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); + CFX_WideStringArray wsPatterns; + pFormat->SplitFormatString(wsPattern, wsPatterns); + FX_BOOL bRet = FALSE; + int32_t iCount = wsPatterns.GetSize(); + for (int32_t i = 0; i < iCount && !bRet; i++) { + CFX_WideString wsFormat = wsPatterns[i]; + FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); + eCategory = XFA_ValugeCategory(eCategory, m_dwType); + switch (eCategory) { + case FX_LOCALECATEGORY_Null: + bRet = pFormat->ParseNull(wsValue, wsFormat); + if (bRet) { + m_wsValue.Empty(); + } + break; + case FX_LOCALECATEGORY_Zero: + bRet = pFormat->ParseZero(wsValue, wsFormat); + if (bRet) { + m_wsValue = FX_WSTRC(L"0"); + } + break; + case FX_LOCALECATEGORY_Num: { + CFX_WideString fNum; + bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); + if (bRet) { + m_wsValue = fNum; + } + break; + } + case FX_LOCALECATEGORY_Text: + bRet = pFormat->ParseText(wsValue, wsFormat, m_wsValue); + break; + case FX_LOCALECATEGORY_Date: { + CFX_Unitime dt; + bRet = ValidateCanonicalDate(wsValue, dt); + if (!bRet) { + bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, + dt); + } + if (bRet) { + SetDate(dt); + } + break; + } + case FX_LOCALECATEGORY_Time: { + CFX_Unitime dt; + bRet = + pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, dt); + if (bRet) { + SetTime(dt); + } + break; + } + case FX_LOCALECATEGORY_DateTime: { + CFX_Unitime dt; + bRet = pFormat->ParseDateTime(wsValue, wsFormat, + FX_DATETIMETYPE_DateTime, dt); + if (bRet) { + SetDateTime(dt); + } + break; + } + default: + m_wsValue = wsValue; + bRet = TRUE; + break; + } + } + if (!bRet) { + m_wsValue = wsValue; + } + pFormat->Release(); + if (pLocale) { + m_pLocaleMgr->SetDefLocale(locale); + } + return bRet; +} +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); + int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + (bSign ? 1 : 0) + + (nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1); + FX_WCHAR* lpBuf = wsFormat.GetBuffer(nTotalLen); + int32_t nPos = 0; + if (bSign) { + lpBuf[nPos++] = L's'; + } + if (nIntLen == -1) { + lpBuf[nPos++] = L'z'; + lpBuf[nPos++] = L'*'; + } else { + while (nIntLen) { + lpBuf[nPos++] = L'z'; + nIntLen--; + } + } + if (nDecLen != 0) { + lpBuf[nPos++] = L'.'; + } + if (nDecLen == -1) { + lpBuf[nPos++] = L'z'; + lpBuf[nPos++] = L'*'; + } else { + while (nDecLen) { + lpBuf[nPos++] = L'z'; + nDecLen--; + } + } + wsFormat.ReleaseBuffer(nTotalLen); +} +FX_BOOL CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric, + CFX_WideString& wsFormat, + IFX_Locale* pLocale, + int32_t* pos) { + if (wsFormat.IsEmpty() || wsNumeric.IsEmpty()) { + return TRUE; + } + const FX_WCHAR* pNum = wsNumeric.c_str(); + const FX_WCHAR* pFmt = wsFormat.c_str(); + int32_t n = 0, nf = 0; + FX_WCHAR c = pNum[n]; + FX_WCHAR cf = pFmt[nf]; + if (cf == L's') { + if (c == L'-' || c == L'+') { + ++n; + } + ++nf; + } + FX_BOOL bLimit = TRUE; + int32_t nCount = wsNumeric.GetLength(); + int32_t nCountFmt = wsFormat.GetLength(); + while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && + XFA_IsDigit(c = pNum[n])) { + if (bLimit == TRUE) { + if ((cf = pFmt[nf]) == L'*') { + bLimit = FALSE; + } else if (cf == L'z') { + nf++; + } else { + return FALSE; + } + } + n++; + } + if (n == nCount) { + return TRUE; + } + if (nf == nCountFmt) { + return FALSE; + } + while (nf < nCountFmt && (cf = pFmt[nf]) != L'.') { + FXSYS_assert(cf == L'z' || cf == L'*'); + ++nf; + } + CFX_WideString wsDecimalSymbol; + if (pLocale) { + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDecimalSymbol); + } else { + wsDecimalSymbol = CFX_WideString(L'.'); + } + if (pFmt[nf] != L'.') { + return FALSE; + } + if (wsDecimalSymbol != CFX_WideStringC(c) && c != L'.') { + return FALSE; + } + ++nf; + ++n; + bLimit = TRUE; + while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && + XFA_IsDigit(c = pNum[n])) { + if (bLimit == TRUE) { + if ((cf = pFmt[nf]) == L'*') { + bLimit = FALSE; + } else if (cf == L'z') { + nf++; + } else { + return FALSE; + } + } + n++; + } + return n == nCount; +} diff --git a/xfa/fxfa/parser/xfa_localevalue.h b/xfa/fxfa/parser/xfa_localevalue.h new file mode 100644 index 0000000000..5906858f33 --- /dev/null +++ b/xfa/fxfa/parser/xfa_localevalue.h @@ -0,0 +1,112 @@ +// 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_LOCALEVALUE_H_ +#define XFA_FXFA_PARSER_XFA_LOCALEVALUE_H_ + +#include "xfa/include/fxfa/fxfa_objectacc.h" + +class IFX_Locale; +class CFX_Unitime; +class CXFA_LocaleMgr; + +#define XFA_VT_NULL 0 +#define XFA_VT_BOOLEAN 1 +#define XFA_VT_INTEGER 2 +#define XFA_VT_DECIMAL 4 +#define XFA_VT_FLOAT 8 +#define XFA_VT_TEXT 16 +#define XFA_VT_DATE 32 +#define XFA_VT_TIME 64 +#define XFA_VT_DATETIME 128 + +class CXFA_LocaleValue { + public: + CXFA_LocaleValue(); + CXFA_LocaleValue(const CXFA_LocaleValue& value); + CXFA_LocaleValue(FX_DWORD dwType, CXFA_LocaleMgr* pLocaleMgr); + CXFA_LocaleValue(FX_DWORD dwType, + const CFX_WideString& wsValue, + CXFA_LocaleMgr* pLocaleMgr); + CXFA_LocaleValue(FX_DWORD dwType, + const CFX_WideString& wsValue, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + CXFA_LocaleMgr* pLocaleMgr); + ~CXFA_LocaleValue(); + CXFA_LocaleValue& operator=(const CXFA_LocaleValue& value); + + FX_BOOL ValidateValue(const CFX_WideString& wsValue, + const CFX_WideString& wsPattern, + IFX_Locale* pLocale, + CFX_WideString* pMatchFormat = NULL); + FX_BOOL FormatPatterns(CFX_WideString& wsResult, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + XFA_VALUEPICTURE eValueType) const; + FX_BOOL FormatSinglePattern(CFX_WideString& wsResult, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale, + XFA_VALUEPICTURE eValueType) const; + FX_BOOL ValidateCanonicalValue(const CFX_WideString& wsValue, + FX_DWORD dwVType); + FX_BOOL ValidateCanonicalDate(const CFX_WideString& wsDate, + CFX_Unitime& unDate); + FX_BOOL ValidateCanonicalTime(const CFX_WideString& wsTime); + FX_BOOL ValidateCanonicalDateTime(const CFX_WideString& wsDateTime); + void GetNumbericFormat(CFX_WideString& wsFormat, + int32_t nIntLen, + int32_t nDecLen, + FX_BOOL bSign = TRUE); + FX_BOOL ValidateNumericTemp(CFX_WideString& wsNumeric, + CFX_WideString& wsFormat, + IFX_Locale* pLocale = NULL, + int32_t* pos = NULL); + + CFX_WideString GetValue() const; + FX_DWORD GetType() const; + void SetValue(const CFX_WideString& wsValue, FX_DWORD dwType); + CFX_WideString GetText() const; + FX_FLOAT GetNum() const; + FX_DOUBLE GetDoubleNum() const; + CFX_Unitime GetDate() const; + CFX_Unitime GetTime() const; + CFX_Unitime GetDateTime() const; + FX_BOOL SetText(const CFX_WideString& wsText); + FX_BOOL SetText(const CFX_WideString& wsText, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale); + FX_BOOL SetNum(FX_FLOAT fNum); + FX_BOOL SetNum(const CFX_WideString& wsNum, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale); + FX_BOOL SetDate(const CFX_Unitime& d); + FX_BOOL SetDate(const CFX_WideString& wsDate, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale); + FX_BOOL SetTime(const CFX_Unitime& t); + FX_BOOL SetTime(const CFX_WideString& wsTime, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale); + FX_BOOL SetDateTime(const CFX_Unitime& dt); + FX_BOOL SetDateTime(const CFX_WideString& wsDateTime, + const CFX_WideString& wsFormat, + IFX_Locale* pLocale); + bool IsNull() const { return m_dwType == XFA_VT_NULL; } + FX_BOOL IsEmpty() const { return m_wsValue.IsEmpty(); } + FX_BOOL IsValid() const { return m_bValid; } + + protected: + FX_BOOL ParsePatternValue(const CFX_WideString& wsValue, + const CFX_WideString& wsPattern, + IFX_Locale* pLocale); + CXFA_LocaleMgr* m_pLocaleMgr; + CFX_WideString m_wsValue; + FX_DWORD m_dwType; + FX_BOOL m_bValid; +}; + +#endif // XFA_FXFA_PARSER_XFA_LOCALEVALUE_H_ diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h new file mode 100644 index 0000000000..1dba00166f --- /dev/null +++ b/xfa/fxfa/parser/xfa_object.h @@ -0,0 +1,803 @@ +// 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_OBJECT_H_ +#define XFA_FXFA_PARSER_XFA_OBJECT_H_ + +#include "xfa/fde/xml/fde_xml.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +class CXFA_Document; +class CXFA_Node; +class CXFA_NodeList; +class CXFA_OrdinaryObject; + +enum XFA_OBJECTTYPE { + XFA_OBJECTTYPE_OrdinaryObject = 0x0, + XFA_OBJECTTYPE_OrdinaryList = 0x1, + XFA_OBJECTTYPE_NodeList = 0x2, + XFA_OBJECTTYPE_Node = 0x4, + XFA_OBJECTTYPE_NodeC = 0x5, + XFA_OBJECTTYPE_NodeV = 0x6, + XFA_OBJECTTYPE_ModelNode = 0x8, + XFA_OBJECTTYPE_TextNode = 0x9, + XFA_OBJECTTYPE_ContainerNode = 0xA, + XFA_OBJECTTYPE_ContentNode = 0xB, + XFA_OBJECTTYPE_VariablesThis = 0xC, + XFA_OBJECTTYPEMASK = 0xF, + XFA_NODEFLAG_Initialized = 0x00020, + XFA_NODEFLAG_HasRemoved = 0x00200, + XFA_NODEFLAG_NeedsInitApp = 0x00400, + XFA_NODEFLAG_BindFormItems = 0x00800, + XFA_NODEFLAG_UserInteractive = 0x01000, + XFA_NODEFLAG_SkipDataBinding = 0x02000, + XFA_NODEFLAG_OwnXMLNode = 0x04000, + XFA_NODEFLAG_UnusedNode = 0x08000, + XFA_NODEFLAG_LayoutGeneratedNode = 0x10000, +}; +class CXFA_Object { + public: + CXFA_Object(CXFA_Document* pDocument, FX_DWORD uFlags); + CXFA_Document* GetDocument() const { return m_pDocument; } + FX_DWORD GetFlag() const { return m_uFlags; } + XFA_OBJECTTYPE GetObjectType() const { + return (XFA_OBJECTTYPE)(m_uFlags & XFA_OBJECTTYPEMASK); + } + + FX_BOOL IsNode() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) >= XFA_OBJECTTYPE_Node; + } + FX_BOOL IsOrdinaryObject() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryObject; + } + FX_BOOL IsNodeList() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_NodeList; + } + FX_BOOL IsOrdinaryList() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryList; + } + FX_BOOL IsContentNode() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContentNode; + } + FX_BOOL IsContainerNode() const { + return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContainerNode; + } + + CXFA_Node* AsNode(); + CXFA_OrdinaryObject* AsOrdinaryObject(); + CXFA_NodeList* AsNodeList(); + + const CXFA_Node* AsNode() const; + const CXFA_OrdinaryObject* AsOrdinaryObject() const; + const CXFA_NodeList* AsNodeList() const; + + XFA_ELEMENT GetClassID() const; + void GetClassName(CFX_WideStringC& wsName) const; + uint32_t GetClassHashCode() const; + void Script_ObjectClass_ClassName(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void ThrowScriptErrorMessage(int32_t iStringID, ...); + + protected: + CXFA_Document* const m_pDocument; + FX_DWORD m_uFlags; +}; + +#define XFA_NODEFILTER_Children 0x01 +#define XFA_NODEFILTER_Properties 0x02 +#define XFA_NODEFILTER_OneOfProperty 0x04 +#define XFA_CLONEFLAG_Content 0x01 +enum XFA_NODEITEM { + XFA_NODEITEM_Parent, + XFA_NODEITEM_FirstChild, + XFA_NODEITEM_NextSibling, + XFA_NODEITEM_PrevSibling, +}; +enum XFA_SOM_MESSAGETYPE { + XFA_SOM_ValidationMessage, + XFA_SOM_FormatMessage, + XFA_SOM_MandatoryMessage +}; + +typedef CFX_ArrayTemplate<CXFA_Node*> CXFA_NodeArray; +typedef CFX_StackTemplate<CXFA_Node*> CXFA_NodeStack; +typedef CXFA_PtrSetTemplate<CXFA_Node*> CXFA_NodeSet; +typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData); + +struct XFA_MAPDATABLOCKCALLBACKINFO { + PD_CALLBACK_FREEDATA pFree; + PD_CALLBACK_DUPLICATEDATA pCopy; +}; + +struct XFA_MAPDATABLOCK { + uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); } + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo; + int32_t iBytes; +}; + +struct XFA_MAPMODULEDATA { + CFX_MapPtrToPtr m_ValueMap; + CFX_MapPtrTemplate<void*, XFA_MAPDATABLOCK*> m_BufferMap; +}; + +#define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R') +#define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C') +#define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M') +class CXFA_Node : public CXFA_Object { + public: + XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; } + FX_DWORD GetPacketID() const { return m_ePacket; } + FX_BOOL HasFlag(FX_DWORD dwFlag) const; + void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE, FX_BOOL bNotify = TRUE); + FX_BOOL IsAttributeInXML(); + FX_BOOL IsFormContainer() { + return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); + } + void SetXMLMappingNode(IFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } + IFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } + IFDE_XMLNode* CreateXMLMappingNode(); + FX_BOOL IsNeedSavingXMLNode(); + FX_DWORD GetNameHash() const { return m_dwNameHash; } + bool IsUnnamed() const { return m_dwNameHash == 0; } + CXFA_Node* GetModelNode(); + void UpdateNameHash(); + FX_BOOL HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit = FALSE); + FX_BOOL SetAttribute(XFA_ATTRIBUTE eAttr, + const CFX_WideStringC& wsValue, + FX_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); + 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, + FX_BOOL bScriptModify = FALSE, + FX_BOOL bSyncData = TRUE); + FX_BOOL TryContent(CFX_WideString& wsContent, + FX_BOOL bScriptModify = FALSE, + FX_BOOL bProto = TRUE); + CFX_WideString GetContent(); + + FX_BOOL TryNamespace(CFX_WideString& wsNamespace); + + FX_BOOL SetBoolean(XFA_ATTRIBUTE eAttr, + FX_BOOL bValue, + FX_BOOL bNotify = FALSE) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue, + bNotify); + } + FX_BOOL TryBoolean(XFA_ATTRIBUTE eAttr, + FX_BOOL& bValue, + FX_BOOL bUseDefault = TRUE); + FX_BOOL GetBoolean(XFA_ATTRIBUTE eAttr) { + FX_BOOL bValue; + return TryBoolean(eAttr, bValue, TRUE) ? bValue : FALSE; + } + FX_BOOL SetInteger(XFA_ATTRIBUTE eAttr, + int32_t iValue, + FX_BOOL bNotify = FALSE) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue, + bNotify); + } + FX_BOOL TryInteger(XFA_ATTRIBUTE eAttr, + int32_t& iValue, + FX_BOOL bUseDefault = TRUE); + int32_t GetInteger(XFA_ATTRIBUTE eAttr) { + int32_t iValue; + return TryInteger(eAttr, iValue, TRUE) ? iValue : 0; + } + FX_BOOL SetEnum(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTEENUM eValue, + FX_BOOL bNotify = FALSE) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue, + bNotify); + } + FX_BOOL TryEnum(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTEENUM& eValue, + FX_BOOL bUseDefault = TRUE); + XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) { + XFA_ATTRIBUTEENUM eValue; + return TryEnum(eAttr, eValue, TRUE) ? eValue : XFA_ATTRIBUTEENUM_Unknown; + } + FX_BOOL SetCData(XFA_ATTRIBUTE eAttr, + const CFX_WideString& wsValue, + FX_BOOL bNotify = FALSE, + FX_BOOL bScriptModify = FALSE); + FX_BOOL SetAttributeValue(const CFX_WideString& wsValue, + const CFX_WideString& wsXMLValue, + FX_BOOL bNotify = FALSE, + FX_BOOL bScriptModify = FALSE); + FX_BOOL TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideString& wsValue, + FX_BOOL bUseDefault = TRUE, + FX_BOOL bProto = TRUE); + FX_BOOL TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideStringC& wsValue, + FX_BOOL bUseDefault = TRUE, + FX_BOOL bProto = TRUE); + CFX_WideStringC GetCData(XFA_ATTRIBUTE eAttr) { + CFX_WideStringC wsValue; + return TryCData(eAttr, wsValue) ? wsValue : CFX_WideStringC(); + } + FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement mValue, + FX_BOOL bNotify = FALSE); + FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement& mValue, + FX_BOOL bUseDefault = TRUE) const; + CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const; + FX_BOOL SetObject(XFA_ATTRIBUTE eAttr, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); + FX_BOOL TryObject(XFA_ATTRIBUTE eAttr, void*& pData); + void* GetObject(XFA_ATTRIBUTE eAttr) { + void* pData; + return TryObject(eAttr, pData) ? pData : NULL; + } + FX_BOOL SetUserData(void* pKey, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); + FX_BOOL TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso = FALSE); + void* GetUserData(void* pKey, FX_BOOL bProtoAlso = FALSE) { + void* pData; + return TryUserData(pKey, pData, bProtoAlso) ? pData : NULL; + } + CXFA_Node* GetProperty(int32_t index, + XFA_ELEMENT eProperty, + FX_BOOL bCreateProperty = TRUE); + int32_t CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild = FALSE); + CXFA_Node* GetChild(int32_t index, + XFA_ELEMENT eElement, + 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); + CXFA_Node* Clone(FX_BOOL bRecursive); + CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const; + CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_OBJECTTYPE eType) const; + int32_t GetNodeList(CXFA_NodeArray& nodes, + FX_DWORD dwTypeFilter = XFA_NODEFILTER_Children | + XFA_NODEFILTER_Properties, + XFA_ELEMENT eElementFilter = XFA_ELEMENT_UNKNOWN, + int32_t iLevel = 1); + CXFA_Node* CreateSamePacketNode(XFA_ELEMENT eElement, + FX_DWORD dwFlags = XFA_NODEFLAG_Initialized); + CXFA_Node* CloneTemplateToForm(FX_BOOL bRecursive); + CXFA_Node* GetTemplateNode() const; + void SetTemplateNode(CXFA_Node* pTemplateNode); + CXFA_Node* GetDataDescriptionNode(); + void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode); + CXFA_Node* GetBindData(); + int32_t GetBindItems(CXFA_NodeArray& formItems); + int32_t AddBindItem(CXFA_Node* pFormNode); + int32_t RemoveBindItem(CXFA_Node* pFormNode); + FX_BOOL HasBindItem(); + CXFA_WidgetData* GetWidgetData(); + CXFA_WidgetData* GetContainerWidgetData(); + FX_BOOL GetLocaleName(CFX_WideString& wsLocaleName); + XFA_ATTRIBUTEENUM GetIntact(); + CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const; + CXFA_Node* GetFirstChildByName(FX_DWORD dwNodeNameHash) const; + CXFA_Node* GetFirstChildByClass(XFA_ELEMENT eNodeClass) const; + CXFA_Node* GetNextSameNameSibling(FX_DWORD dwNodeNameHash) const; + CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const; + CXFA_Node* GetNextSameClassSibling(XFA_ELEMENT eNodeClass) const; + int32_t GetNodeSameNameIndex() const; + int32_t GetNodeSameClassIndex() const; + void GetSOMExpression(CFX_WideString& wsSOMExpression); + CXFA_Node* GetInstanceMgrOfSubform(); + + CXFA_Node* GetOccurNode(); + void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments); + void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments); + void Script_Som_ResolveNodeList(FXJSE_HVALUE hValue, + CFX_WideString wsExpression, + FX_DWORD dwFlag, + CXFA_Node* refNode = NULL); + void Script_TreeClass_All(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Nodes(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_ClassAll(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Parent(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Index(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_ClassIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_SomExpression(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments); + void Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments); + void Script_NodeClass_Clone(CFXJSE_Arguments* pArguments); + void Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments); + void Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments); + void Script_NodeClass_IsPropertySpecified(CFXJSE_Arguments* pArguments); + void Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments); + void Script_NodeClass_Ns(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_Model(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_IsContainer(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_IsNull(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_OneOfChild(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments); + void Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments); + void Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments); + void Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments); + void Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments); + void Script_ModelClass_Context(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments); + void Script_Delta_Restore(CFXJSE_Arguments* pArguments); + void Script_Delta_CurrentValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Delta_SavedValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Delta_Target(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_SendAttributeChangeMessage(void* eAttribute, + void* eValue, + FX_BOOL bScriptModify); + void Script_Attribute_Integer(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_IntegerRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_BOOL(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_String(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_StringRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_ValidationMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_Length(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Boolean_Value(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_Message(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_SOM_MESSAGETYPE iMessageType); + void Script_Som_BorderColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_BorderWidth(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_FillColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DataNode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_FontColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_Mandatory(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_MandatoryMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_InstanceIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Draw_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_EditValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_FormatMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_FormattedValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_ParentSubform(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_SelectedIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_ClearItems(CFXJSE_Arguments* pArguments); + void Script_Field_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Field_DeleteItem(CFXJSE_Arguments* pArguments); + void Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments); + void Script_Field_BoundItem(CFXJSE_Arguments* pArguments); + void Script_Field_GetItemState(CFXJSE_Arguments* pArguments); + void Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Field_SetItems(CFXJSE_Arguments* pArguments); + void Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments); + void Script_Field_SetItemState(CFXJSE_Arguments* pArguments); + void Script_Field_AddItem(CFXJSE_Arguments* pArguments); + void Script_Field_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_ErrorText(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_Transient(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Subform_InstanceManager(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Subform_Locale(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments); + + int32_t Subform_and_SubformSet_InstanceIndex(); + void Script_Template_FormNodes(CFXJSE_Arguments* pArguments); + void Script_Template_Remerge(CFXJSE_Arguments* pArguments); + void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Template_CreateNode(CFXJSE_Arguments* pArguments); + void Script_Template_Recalculate(CFXJSE_Arguments* pArguments); + void Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Template_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_Count(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_Max(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_Min(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_MoveInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_RemoveInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments); + int32_t InstanceManager_SetInstances(int32_t iCount); + int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); + void Script_Occur_Max(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Occur_Min(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Desc_Metadata(CFXJSE_Arguments* pArguments); + void Script_Form_FormNodes(CFXJSE_Arguments* pArguments); + void Script_Form_Remerge(CFXJSE_Arguments* pArguments); + void Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Form_Recalculate(CFXJSE_Arguments* pArguments); + void Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Form_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Form_Checksum(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_Content(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Source_Next(CFXJSE_Arguments* pArguments); + void Script_Source_CancelBatch(CFXJSE_Arguments* pArguments); + void Script_Source_First(CFXJSE_Arguments* pArguments); + void Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments); + void Script_Source_Previous(CFXJSE_Arguments* pArguments); + void Script_Source_IsBOF(CFXJSE_Arguments* pArguments); + void Script_Source_IsEOF(CFXJSE_Arguments* pArguments); + void Script_Source_Cancel(CFXJSE_Arguments* pArguments); + void Script_Source_Update(CFXJSE_Arguments* pArguments); + void Script_Source_Open(CFXJSE_Arguments* pArguments); + void Script_Source_Delete(CFXJSE_Arguments* pArguments); + void Script_Source_AddNew(CFXJSE_Arguments* pArguments); + void Script_Source_Requery(CFXJSE_Arguments* pArguments); + void Script_Source_Resync(CFXJSE_Arguments* pArguments); + void Script_Source_Close(CFXJSE_Arguments* pArguments); + void Script_Source_Last(CFXJSE_Arguments* pArguments); + void Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments); + void Script_Source_Db(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Xfa_This(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Handler_Version(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_SubmitFormat_Mode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Extras_Type(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Encrypt_Format(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Script_Stateless(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + + protected: + CXFA_Node(CXFA_Document* pDoc, FX_WORD ePacket, XFA_ELEMENT eElement); + ~CXFA_Node(); + friend class CXFA_Document; + CXFA_Node* Deprecated_GetPrevSibling(); + FX_BOOL SetValue(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTETYPE eType, + void* pValue, + FX_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); + 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, + FX_BOOL bScriptModify = FALSE, + FX_BOOL bSyncData = TRUE); + CFX_WideString GetScriptContent(FX_BOOL bScriptModify = FALSE); + XFA_MAPMODULEDATA* CreateMapModuleData(); + XFA_MAPMODULEDATA* GetMapModuleData() const; + void SetMapModuleValue(void* pKey, void* pValue); + FX_BOOL GetMapModuleValue(void* pKey, void*& pValue); + void SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue); + FX_BOOL GetMapModuleString(void* pKey, CFX_WideStringC& wsValue); + void SetMapModuleBuffer(void* pKey, + void* pValue, + int32_t iBytes, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); + FX_BOOL GetMapModuleBuffer(void* pKey, + void*& pValue, + int32_t& iBytes, + FX_BOOL bProtoAlso = TRUE) const; + FX_BOOL HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso = FALSE); + void RemoveMapModuleKey(void* pKey = NULL); + void MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr = TRUE); + void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); + void MoveBufferMapData(CXFA_Node* pSrcModule, + CXFA_Node* pDstModule, + void* pKey, + FX_BOOL bRecursive = FALSE); + + CXFA_Node* m_pNext; + CXFA_Node* m_pChild; + CXFA_Node* m_pLastChild; + CXFA_Node* m_pParent; + IFDE_XMLNode* m_pXMLNode; + XFA_ELEMENT m_eNodeClass; + FX_WORD m_ePacket; + FX_DWORD m_dwNameHash; + CXFA_Node* m_pAuxNode; + XFA_MAPMODULEDATA* m_pMapModuleData; +}; +class CXFA_OrdinaryObject : public CXFA_Object { + public: + CXFA_OrdinaryObject(CXFA_Document* pDocument, XFA_ELEMENT eElement) + : CXFA_Object(pDocument, XFA_OBJECTTYPE_OrdinaryObject), + m_uScriptHash(0) { + m_eNodeClass = eElement; + } + XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; } + uint32_t GetScriptObjHash() { return m_uScriptHash; } + + protected: + XFA_ELEMENT m_eNodeClass; + uint32_t m_uScriptHash; +}; +class CXFA_ThisProxy : public CXFA_Object { + public: + CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) + : CXFA_Object(pThisNode->GetDocument(), XFA_OBJECTTYPE_VariablesThis), + m_pThisNode(NULL), + m_pScriptNode(NULL) { + m_pThisNode = pThisNode; + m_pScriptNode = pScriptNode; + } + virtual ~CXFA_ThisProxy() {} + CXFA_Node* GetThisNode() { return m_pThisNode; } + CXFA_Node* GetScriptNode() { return m_pScriptNode; } + + private: + CXFA_Node* m_pThisNode; + CXFA_Node* m_pScriptNode; +}; +class CXFA_NodeList : public CXFA_Object { + public: + explicit CXFA_NodeList(CXFA_Document* pDocument); + virtual ~CXFA_NodeList() {} + XFA_ELEMENT GetClassID() const { return XFA_ELEMENT_NodeList; } + CXFA_Node* NamedItem(const CFX_WideStringC& wsName); + virtual int32_t GetLength() = 0; + virtual FX_BOOL Append(CXFA_Node* pNode) = 0; + virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; + virtual FX_BOOL Remove(CXFA_Node* pNode) = 0; + virtual CXFA_Node* Item(int32_t iIndex) = 0; + + void Script_ListClass_Append(CFXJSE_Arguments* pArguments); + void Script_ListClass_Insert(CFXJSE_Arguments* pArguments); + void Script_ListClass_Remove(CFXJSE_Arguments* pArguments); + void Script_ListClass_Item(CFXJSE_Arguments* pArguments); + + void Script_TreelistClass_NamedItem(CFXJSE_Arguments* pArguments); + void Script_ListClass_Length(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); +}; +class CXFA_ArrayNodeList : public CXFA_NodeList { + public: + explicit CXFA_ArrayNodeList(CXFA_Document* pDocument); + void SetArrayNodeList(const CXFA_NodeArray& srcArray); + virtual int32_t GetLength(); + virtual FX_BOOL Append(CXFA_Node* pNode); + virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode); + virtual FX_BOOL Remove(CXFA_Node* pNode); + virtual CXFA_Node* Item(int32_t iIndex); + + protected: + CXFA_NodeArray m_array; +}; +class CXFA_AttachNodeList : public CXFA_NodeList { + public: + CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode); + + virtual int32_t GetLength(); + virtual FX_BOOL Append(CXFA_Node* pNode); + virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode); + virtual FX_BOOL Remove(CXFA_Node* pNode); + virtual CXFA_Node* Item(int32_t iIndex); + + protected: + CXFA_Node* m_pAttachNode; +}; +class CXFA_TraverseStrategy_XFAContainerNode { + public: + static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode, + void* pUserData = NULL) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild, + XFA_OBJECTTYPE_ContainerNode); + } + static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode, + void* pUserData = NULL) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_OBJECTTYPE_ContainerNode); + } + static CXFA_Node* GetParent(CXFA_Node* pTemplateNode, + void* pUserData = NULL) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_OBJECTTYPE_ContainerNode); + } +}; +typedef CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode> + CXFA_ContainerIterator; +class CXFA_TraverseStrategy_XFANode { + public: + static inline CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + } + static inline CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); + } +}; +typedef CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> + CXFA_NodeIterator; + +inline CXFA_Node* CXFA_Object::AsNode() { + return IsNode() ? static_cast<CXFA_Node*>(this) : nullptr; +} +inline CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() { + return IsOrdinaryObject() ? static_cast<CXFA_OrdinaryObject*>(this) : nullptr; +} +inline CXFA_NodeList* CXFA_Object::AsNodeList() { + return IsNodeList() ? static_cast<CXFA_NodeList*>(this) : nullptr; +} + +inline const CXFA_Node* CXFA_Object::AsNode() const { + return IsNode() ? static_cast<const CXFA_Node*>(this) : nullptr; +} +inline const CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() const { + return IsOrdinaryObject() ? static_cast<const CXFA_OrdinaryObject*>(this) + : nullptr; +} +inline const CXFA_NodeList* CXFA_Object::AsNodeList() const { + return IsNodeList() ? static_cast<const CXFA_NodeList*>(this) : nullptr; +} + +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/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp new file mode 100644 index 0000000000..83bf800c1a --- /dev/null +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -0,0 +1,5408 @@ +// 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/fxfa/parser/xfa_object.h" + +#include "core/include/fxcrt/fx_ext.h" +#include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fgas/crt/fgas_system.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" +#include "xfa/fxfa/parser/xfa_localemgr.h" +#include "xfa/fxfa/parser/xfa_parser.h" +#include "xfa/fxfa/parser/xfa_script.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +CXFA_Object::CXFA_Object(CXFA_Document* pDocument, FX_DWORD uFlags) + : m_pDocument(pDocument), m_uFlags(uFlags) {} +void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { + wsName = XFA_GetElementByID(GetClassID())->pName; +} +uint32_t CXFA_Object::GetClassHashCode() const { + return XFA_GetElementByID(GetClassID())->uHash; +} +XFA_ELEMENT CXFA_Object::GetClassID() const { + if (IsNode()) { + return AsNode()->GetClassID(); + } + if (IsOrdinaryObject()) { + return AsOrdinaryObject()->GetClassID(); + } + if (IsNodeList()) { + return AsNodeList()->GetClassID(); + } + if (IsOrdinaryList()) { + return XFA_ELEMENT_List; + } + ASSERT(FALSE); + return (XFA_ELEMENT)0; +} +void CXFA_Object::Script_ObjectClass_ClassName(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + CFX_WideStringC className; + GetClassName(className); + FXJSE_Value_SetUTF8String( + hValue, FX_UTF8Encode(className.GetPtr(), className.GetLength())); + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Object::ThrowScriptErrorMessage(int32_t iStringID, ...) { + IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); + FXSYS_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); + va_end(arg_ptr); + FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); +} + +static void XFA_DeleteWideString(void* pData) { + delete static_cast<CFX_WideString*>(pData); +} + +static void XFA_CopyWideString(void*& pData) { + if (pData) { + CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); + pData = pNewData; + } +} +static XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = { + XFA_DeleteWideString, XFA_CopyWideString}; +static XFA_OBJECTTYPE XFA_GetElementObjectType(XFA_ELEMENT eElement) { + return (XFA_OBJECTTYPE)XFA_GetElementByID(eElement)->eObjectType; +} +CXFA_Node::CXFA_Node(CXFA_Document* pDoc, FX_WORD ePacket, XFA_ELEMENT eElement) + : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), + m_pNext(nullptr), + m_pChild(nullptr), + m_pLastChild(nullptr), + m_pParent(nullptr), + m_pXMLNode(nullptr), + m_eNodeClass(eElement), + m_ePacket(ePacket), + m_dwNameHash(0), + m_pAuxNode(nullptr), + m_pMapModuleData(nullptr) { + ASSERT(m_pDocument); +} +CXFA_Node::~CXFA_Node() { + FXSYS_assert(m_pParent == NULL); + RemoveMapModuleKey(); + CXFA_Node *pNext, *pNode = m_pChild; + while (pNode) { + pNext = pNode->m_pNext; + pNode->m_pParent = NULL; + delete pNode; + pNode = pNext; + } + if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) { + m_pXMLNode->Release(); + } +} +CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { + IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); + CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); + if (!pClone) { + return NULL; + } + MergeAllData(pClone); + pClone->UpdateNameHash(); + if (IsNeedSavingXMLNode()) { + IFDE_XMLNode* pCloneXML = NULL; + if (IsAttributeInXML()) { + CFX_WideString wsName; + GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); + IFDE_XMLElement* pCloneXMLElement = IFDE_XMLElement::Create(wsName); + CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); + if (!wsValue.IsEmpty()) { + pCloneXMLElement->SetTextData(wsValue); + } + pCloneXML = pCloneXMLElement; + pCloneXMLElement = NULL; + pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); + } else { + pCloneXML = m_pXMLNode->Clone(FALSE); + } + pClone->SetXMLMappingNode(pCloneXML); + pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); + } + if (bRecursive) { + for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + pClone->InsertChild(pChild->Clone(bRecursive)); + } + } + pClone->SetFlag(XFA_NODEFLAG_Initialized); + pClone->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + return pClone; +} +CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem) const { + switch (eItem) { + case XFA_NODEITEM_NextSibling: + return m_pNext; + case XFA_NODEITEM_FirstChild: + return m_pChild; + case XFA_NODEITEM_Parent: + return m_pParent; + case XFA_NODEITEM_PrevSibling: + if (m_pParent) { + CXFA_Node* pSibling = m_pParent->m_pChild; + CXFA_Node* pPrev = NULL; + while (pSibling && pSibling != this) { + pPrev = pSibling; + pSibling = pSibling->m_pNext; + } + return pPrev; + } + return NULL; + default: + break; + } + return NULL; +} +CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem, + XFA_OBJECTTYPE eType) const { + CXFA_Node* pNode = NULL; + switch (eItem) { + case XFA_NODEITEM_NextSibling: + pNode = m_pNext; + if (eType != XFA_OBJECTTYPEMASK) { + while (pNode && pNode->GetObjectType() != eType) { + pNode = pNode->m_pNext; + } + } + break; + case XFA_NODEITEM_FirstChild: + pNode = m_pChild; + if (eType != XFA_OBJECTTYPEMASK) { + while (pNode && pNode->GetObjectType() != eType) { + pNode = pNode->m_pNext; + } + } + break; + case XFA_NODEITEM_Parent: + pNode = m_pParent; + if (eType != XFA_OBJECTTYPEMASK) { + while (pNode && pNode->GetObjectType() != eType) { + pNode = pNode->m_pParent; + } + } + break; + case XFA_NODEITEM_PrevSibling: + if (m_pParent) { + CXFA_Node* pSibling = m_pParent->m_pChild; + while (pSibling && pSibling != this) { + if (eType == XFA_OBJECTTYPEMASK || + eType == pSibling->GetObjectType()) { + pNode = pSibling; + } + pSibling = pSibling->m_pNext; + } + } + break; + default: + break; + } + return pNode; +} +int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, + FX_DWORD dwTypeFilter, + XFA_ELEMENT eElementFilter, + int32_t iLevel) { + if (--iLevel < 0) { + return nodes.GetSize(); + } + if (eElementFilter != XFA_ELEMENT_UNKNOWN) { + CXFA_Node* pChild = m_pChild; + while (pChild) { + if (pChild->GetClassID() == eElementFilter) { + nodes.Add(pChild); + if (iLevel > 0) { + GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); + } + } + pChild = pChild->m_pNext; + } + } else if (dwTypeFilter == + (XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) { + CXFA_Node* pChild = m_pChild; + while (pChild) { + nodes.Add(pChild); + if (iLevel > 0) { + GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); + } + pChild = pChild->m_pNext; + } + } else if (dwTypeFilter != 0) { + FX_BOOL bFilterChildren = (dwTypeFilter & XFA_NODEFILTER_Children) != 0; + FX_BOOL bFilterProperties = (dwTypeFilter & XFA_NODEFILTER_Properties) != 0; + FX_BOOL bFilterOneOfProperties = + (dwTypeFilter & XFA_NODEFILTER_OneOfProperty) != 0; + CXFA_Node* pChild = m_pChild; + while (pChild) { + const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( + GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); + if (pProperty) { + if (bFilterProperties) { + nodes.Add(pChild); + } else if (bFilterOneOfProperties && + (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { + nodes.Add(pChild); + } else if (bFilterChildren && + (pChild->GetClassID() == XFA_ELEMENT_Variables || + pChild->GetClassID() == XFA_ELEMENT_PageSet)) { + nodes.Add(pChild); + } + } else { + if (bFilterChildren) { + nodes.Add(pChild); + } + } + pChild = pChild->m_pNext; + } + if (bFilterOneOfProperties && nodes.GetSize() < 1) { + int32_t iProperties = 0; + const XFA_PROPERTY* pProperty = + XFA_GetElementProperties(GetClassID(), iProperties); + if (pProperty == NULL || iProperties < 1) { + return 0; + } + for (int32_t i = 0; i < iProperties; i++) { + if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { + IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); + const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); + CXFA_Node* pNewNode = + pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); + if (!pNewNode) { + break; + } + InsertChild(pNewNode, NULL); + pNewNode->SetFlag(XFA_NODEFLAG_Initialized); + nodes.Add(pNewNode); + break; + } + } + } + } + return nodes.GetSize(); +} +CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_ELEMENT eElement, + FX_DWORD dwFlags) { + IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); + CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement); + pNode->SetFlag(dwFlags); + return pNode; +} +CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { + FXSYS_assert(m_ePacket == XFA_XDPPACKET_Template); + IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); + CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_eNodeClass); + if (!pClone) { + return NULL; + } + pClone->SetTemplateNode(this); + pClone->UpdateNameHash(); + pClone->SetXMLMappingNode(GetXMLMappingNode()); + if (bRecursive) { + for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive)); + } + } + pClone->SetFlag(XFA_NODEFLAG_Initialized); + return pClone; +} + +CXFA_Node* CXFA_Node::GetTemplateNode() const { + return m_pAuxNode; +} + +void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) { + m_pAuxNode = pTemplateNode; +} +CXFA_Node* CXFA_Node::GetBindData() { + ASSERT(GetPacketID() == XFA_XDPPACKET_Form); + return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); +} +int32_t CXFA_Node::GetBindItems(CXFA_NodeArray& formItems) { + if (m_uFlags & XFA_NODEFLAG_BindFormItems) { + CXFA_NodeArray* pItems = NULL; + TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); + formItems.Copy(*pItems); + return formItems.GetSize(); + } + CXFA_Node* pFormNode = + static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); + if (pFormNode) { + formItems.Add(pFormNode); + } + return formItems.GetSize(); +} + +static void XFA_DataNodeDeleteBindItem(void* pData) { + delete static_cast<CXFA_NodeArray*>(pData); +} + +static XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { + XFA_DataNodeDeleteBindItem, NULL}; +int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { + ASSERT(pFormNode); + if (m_uFlags & XFA_NODEFLAG_BindFormItems) { + CXFA_NodeArray* pItems = NULL; + TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); + ASSERT(pItems); + if (pItems->Find(pFormNode) < 0) { + pItems->Add(pFormNode); + } + return pItems->GetSize(); + } + CXFA_Node* pOldFormItem = + static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); + if (!pOldFormItem) { + SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); + return 1; + } else if (pOldFormItem == pFormNode) { + return 1; + } + CXFA_NodeArray* pItems = new CXFA_NodeArray; + SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack); + pItems->Add(pOldFormItem); + pItems->Add(pFormNode); + m_uFlags |= XFA_NODEFLAG_BindFormItems; + return 2; +} +int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { + if (m_uFlags & XFA_NODEFLAG_BindFormItems) { + CXFA_NodeArray* pItems = NULL; + TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); + ASSERT(pItems); + int32_t iIndex = pItems->Find(pFormNode); + int32_t iCount = pItems->GetSize(); + if (iIndex >= 0) { + if (iIndex != iCount - 1) { + pItems->SetAt(iIndex, pItems->GetAt(iCount - 1)); + } + pItems->RemoveAt(iCount - 1); + if (iCount == 2) { + CXFA_Node* pLastFormNode = pItems->GetAt(0); + SetObject(XFA_ATTRIBUTE_BindingNode, pLastFormNode); + m_uFlags &= ~XFA_NODEFLAG_BindFormItems; + } + iCount--; + } + return iCount; + } + CXFA_Node* pOldFormItem = + static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); + if (pOldFormItem == pFormNode) { + SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + pOldFormItem = NULL; + } + return pOldFormItem == NULL ? 0 : 1; +} +FX_BOOL CXFA_Node::HasBindItem() { + return (GetPacketID() == XFA_XDPPACKET_Datasets) && + GetObject(XFA_ATTRIBUTE_BindingNode) != NULL; +} +CXFA_WidgetData* CXFA_Node::GetWidgetData() { + return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData); +} +CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { + if (GetPacketID() != XFA_XDPPACKET_Form) { + return NULL; + } + XFA_ELEMENT classID = GetClassID(); + if (classID == XFA_ELEMENT_ExclGroup) { + return NULL; + } + CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); + if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) { + return NULL; + } + if (classID == XFA_ELEMENT_Field) { + CXFA_WidgetData* pFieldWidgetData = GetWidgetData(); + if (pFieldWidgetData && + pFieldWidgetData->GetChoiceListOpen() == + XFA_ATTRIBUTEENUM_MultiSelect) { + return NULL; + } else { + CFX_WideString wsPicture; + if (pFieldWidgetData) { + pFieldWidgetData->GetPictureContent(wsPicture, + XFA_VALUEPICTURE_DataBind); + } + if (!wsPicture.IsEmpty()) { + return pFieldWidgetData; + } + CXFA_Node* pDataNode = GetBindData(); + if (!pDataNode) { + return NULL; + } + pFieldWidgetData = NULL; + CXFA_NodeArray formNodes; + pDataNode->GetBindItems(formNodes); + for (int32_t i = 0; i < formNodes.GetSize(); i++) { + CXFA_Node* pFormNode = formNodes.GetAt(i); + if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { + continue; + } + pFieldWidgetData = pFormNode->GetWidgetData(); + if (pFieldWidgetData) { + pFieldWidgetData->GetPictureContent(wsPicture, + XFA_VALUEPICTURE_DataBind); + } + if (!wsPicture.IsEmpty()) { + break; + } + pFieldWidgetData = NULL; + } + return pFieldWidgetData; + } + } + CXFA_Node* pGrandNode = + pParentNode ? pParentNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; + CXFA_Node* pValueNode = + (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Value) + ? pParentNode + : NULL; + if (!pValueNode) { + pValueNode = (pGrandNode && pGrandNode->GetClassID() == XFA_ELEMENT_Value) + ? pGrandNode + : NULL; + } + CXFA_Node* pParentOfValueNode = + pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; + return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData() + : NULL; +} +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); + CXFA_Node* pLocaleNode = this; + FX_BOOL bLocale = FALSE; + do { + bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); + if (!bLocale) { + pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); + } + } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); + if (bLocale) { + return bLocale; + } + CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); + wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); + if (!wsLocaleName.IsEmpty()) { + bLocale = TRUE; + } + if (bLocale) { + return bLocale; + } + if (pTopSubform) { + bLocale = pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); + } + if (bLocale) { + return bLocale; + } + IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); + if (pLocale) { + wsLocaleName = pLocale->GetName(); + bLocale = TRUE; + } + return bLocale; +} +XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { + XFA_ELEMENT eElement = GetClassID(); + CXFA_Node* pKeep = GetFirstChildByClass(XFA_ELEMENT_Keep); + XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); + if (pKeep) { + XFA_ATTRIBUTEENUM eIntact; + if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, FALSE)) { + if (eIntact == XFA_ATTRIBUTEENUM_None && + eLayoutType == XFA_ATTRIBUTEENUM_Row && + m_pDocument->GetCurVersionMode() < XFA_VERSION_208) { + CXFA_Node* pPreviewRow = + GetNodeItem(XFA_NODEITEM_PrevSibling, XFA_OBJECTTYPE_ContainerNode); + if (pPreviewRow && + pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) == + XFA_ATTRIBUTEENUM_Row) { + XFA_ATTRIBUTEENUM eValue; + if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, FALSE)) { + if (eValue == XFA_ATTRIBUTEENUM_ContentArea || + eValue == XFA_ATTRIBUTEENUM_PageArea) { + return XFA_ATTRIBUTEENUM_ContentArea; + } + } + CXFA_Node* pKeep = + pPreviewRow->GetFirstChildByClass(XFA_ELEMENT_Keep); + if (pKeep) { + if (pKeep->TryEnum(XFA_ATTRIBUTE_Next, eValue, FALSE)) { + if (eValue == XFA_ATTRIBUTEENUM_ContentArea || + eValue == XFA_ATTRIBUTEENUM_PageArea) { + return XFA_ATTRIBUTEENUM_ContentArea; + } + } + } + } + } + return eIntact; + } + } + switch (eElement) { + case XFA_ELEMENT_Subform: + switch (eLayoutType) { + case XFA_ATTRIBUTEENUM_Position: + case XFA_ATTRIBUTEENUM_Row: + return XFA_ATTRIBUTEENUM_ContentArea; + case XFA_ATTRIBUTEENUM_Tb: + case XFA_ATTRIBUTEENUM_Table: + case XFA_ATTRIBUTEENUM_Lr_tb: + case XFA_ATTRIBUTEENUM_Rl_tb: + return XFA_ATTRIBUTEENUM_None; + default: + break; + } + break; + case XFA_ELEMENT_Field: { + CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); + if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_PageArea) { + return XFA_ATTRIBUTEENUM_ContentArea; + } + if (pParentNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { + XFA_ATTRIBUTEENUM eParLayout = + pParentNode->GetEnum(XFA_ATTRIBUTE_Layout); + if (eParLayout == XFA_ATTRIBUTEENUM_Position || + eParLayout == XFA_ATTRIBUTEENUM_Row || + eParLayout == XFA_ATTRIBUTEENUM_Table) { + return XFA_ATTRIBUTEENUM_None; + } + XFA_VERSION version = m_pDocument->GetCurVersionMode(); + if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) { + CXFA_Measurement measureH; + if (TryMeasure(XFA_ATTRIBUTE_H, measureH, FALSE)) { + return XFA_ATTRIBUTEENUM_ContentArea; + } + } + return XFA_ATTRIBUTEENUM_None; + } + return XFA_ATTRIBUTEENUM_ContentArea; + } + case XFA_ELEMENT_Draw: + return XFA_ATTRIBUTEENUM_ContentArea; + default: + break; + } + return XFA_ATTRIBUTEENUM_None; +} +CXFA_Node* CXFA_Node::GetDataDescriptionNode() { + if (m_ePacket == XFA_XDPPACKET_Datasets) { + return m_pAuxNode; + } + return NULL; +} +void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) { + FXSYS_assert(m_ePacket == XFA_XDPPACKET_Datasets); + m_pAuxNode = pDataDescriptionNode; +} +void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + 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()); + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + CXFA_Node* refNode = this; + if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { + refNode = ToNode(pScriptContext->GetThisObject()); + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | + XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = pScriptContext->ResolveObjects(refNode, wsExpression, + resoveNodeRS, dwFlag); + if (iRet < 1) { + return FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } + FXJSE_HVALUE hValue = NULL; + if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + CXFA_Object* pNode = resoveNodeRS.nodes[0]; + hValue = pScriptContext->GetJSValueFromMap(pNode); + FXJSE_Value_Set(pArguments->GetReturnValue(), hValue); + } else { + const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = + resoveNodeRS.pScriptAttribute; + if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { + hValue = FXJSE_Value_Create(pScriptContext->GetRuntime()); + (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( + hValue, FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); + FXJSE_Value_Set(pArguments->GetReturnValue(), hValue); + FXJSE_Value_Release(hValue); + } else { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } + } +} +void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"resolveNodes"); + return; + } + CFX_WideString wsExpression; + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (!hValue) { + return; + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | + XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + CXFA_Node* refNode = this; + if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { + refNode = ToNode(m_pDocument->GetScriptContext()->GetThisObject()); + } + Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag, refNode); +} +void CXFA_Node::Script_Som_ResolveNodeList(FXJSE_HVALUE hValue, + CFX_WideString wsExpression, + FX_DWORD dwFlag, + CXFA_Node* refNode) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + XFA_RESOLVENODE_RS resoveNodeRS; + if (refNode == NULL) { + refNode = this; + } + pScriptContext->ResolveObjects(refNode, wsExpression, resoveNodeRS, dwFlag); + CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument); + if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + for (int32_t i = 0; i < resoveNodeRS.nodes.GetSize(); i++) { + if (resoveNodeRS.nodes[i]->IsNode()) + pNodeList->Append(resoveNodeRS.nodes[i]->AsNode()); + } + } else { + CXFA_HVALUEArray hValueArray(pScriptContext->GetRuntime()); + if (resoveNodeRS.GetAttributeResult(hValueArray) > 0) { + CXFA_ObjArray objectArray; + hValueArray.GetAttributeObject(objectArray); + for (int32_t i = 0; i < objectArray.GetSize(); i++) { + if (objectArray[i]->IsNode()) + pNodeList->Append(objectArray[i]->AsNode()); + } + } + } + FXJSE_Value_SetObject(hValue, (CXFA_Object*)pNodeList, + pScriptContext->GetJseNormalClass()); +} +void CXFA_Node::Script_TreeClass_All(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FX_DWORD dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; + CFX_WideString wsName; + GetAttribute(XFA_ATTRIBUTE_Name, wsName); + CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]"); + Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag); + } +} +void CXFA_Node::Script_TreeClass_Nodes(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + if (bSetting) { + IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); + FXSYS_assert(pAppProvider); + CFX_WideString wsMessage; + pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); + FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); + } else { + CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); + FXJSE_Value_SetObject(hValue, (CXFA_Object*)pNodeList, + pScriptContext->GetJseNormalClass()); + } +} +void CXFA_Node::Script_TreeClass_ClassAll(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FX_DWORD dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; + CFX_WideStringC wsName; + GetClassName(wsName); + CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); + Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag); + } +} +void CXFA_Node::Script_TreeClass_Parent(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); + if (pParent) { + FXJSE_Value_Set( + hValue, m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); + } else { + FXJSE_Value_SetNull(hValue); + } + } +} +void CXFA_Node::Script_TreeClass_Index(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FXJSE_Value_SetInteger(hValue, GetNodeSameNameIndex()); + } +} +void CXFA_Node::Script_TreeClass_ClassIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FXJSE_Value_SetInteger(hValue, GetNodeSameClassIndex()); + } +} +void CXFA_Node::Script_TreeClass_SomExpression(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + CFX_WideString wsSOMExpression; + GetSOMExpression(wsSOMExpression); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsSOMExpression)); + } +} +void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + 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()); +} +void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 3) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"assignNode"); + return; + } + CFX_WideString wsExpression; + CFX_WideString wsValue; + int32_t iAction = 0; + if (iLength >= 1) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + } + if (iLength >= 2) { + CFX_ByteString bsValue = pArguments->GetUTF8String(1); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + } + if (iLength >= 3) { + iAction = pArguments->GetInt32(2); + } +} +void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); + return; + } + FX_BOOL bClone = TRUE; + bClone = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; + CXFA_Node* pCloneNode = Clone(bClone); + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); +} +void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"getAttribute"); + return; + } + CFX_WideString wsExpression; + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + CFX_WideString wsValue; + GetAttribute(wsExpression, wsValue); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); + } +} +void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); + return; + } + CFX_WideString wsExpression; + int32_t iValue = 0; + if (iLength >= 1) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + } + if (iLength >= 2) { + iValue = pArguments->GetInt32(1); + } + const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); + CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); + FXJSE_Value_Set(pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); +} +void CXFA_Node::Script_NodeClass_IsPropertySpecified( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 3) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"isPropertySpecified"); + return; + } + CFX_WideString wsExpression; + FX_BOOL bParent = TRUE; + int32_t iIndex = 0; + if (iLength >= 1) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + } + if (iLength >= 2) { + bParent = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; + } + if (iLength >= 3) { + iIndex = pArguments->GetInt32(2); + } + FX_BOOL bHas = FALSE; + const XFA_ATTRIBUTEINFO* pAttributeInfo = + XFA_GetAttributeByName(wsExpression); + CFX_WideString wsValue; + if (pAttributeInfo) { + bHas = HasAttribute(pAttributeInfo->eName); + } + if (!bHas) { + const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); + bHas = (GetProperty(iIndex, pElementInfo->eName) != NULL); + } + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, bHas); + } +} +void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 3) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); + return; + } + CFX_WideString wsExpression; + FX_BOOL bIgnoreRoot = TRUE; + FX_BOOL bOverwrite = 0; + if (iLength >= 1) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + if (wsExpression.IsEmpty()) { + return; + } + } + if (iLength >= 2) { + bIgnoreRoot = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; + } + if (iLength >= 3) { + bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; + } + IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument); + if (!pParser) { + return; + } + IFDE_XMLNode* pXMLNode = NULL; + int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); + if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { + pParser->Release(); + pParser = NULL; + return; + } + if (bIgnoreRoot && (pXMLNode->GetType() != FDE_XMLNODE_Element || + XFA_RecognizeRichText((IFDE_XMLElement*)pXMLNode))) { + bIgnoreRoot = FALSE; + } + CXFA_Node* pFakeRoot = Clone(FALSE); + CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); + if (!wsContentType.IsEmpty()) { + pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); + } + IFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); + if (!pFakeXMLRoot) { + IFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); + pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : NULL; + } + if (!pFakeXMLRoot) { + CFX_WideStringC wsClassName; + GetClassName(wsClassName); + pFakeXMLRoot = IFDE_XMLElement::Create(wsClassName); + } + if (bIgnoreRoot) { + IFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + while (pXMLChild) { + IFDE_XMLNode* pXMLSibling = + pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling); + pXMLNode->RemoveChildNode(pXMLChild); + pFakeXMLRoot->InsertChildNode(pXMLChild); + pXMLChild = pXMLSibling; + } + } else { + IFDE_XMLNode* pXMLParent = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + if (pXMLParent) { + pXMLParent->RemoveChildNode(pXMLNode); + } + pFakeXMLRoot->InsertChildNode(pXMLNode); + } + pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot); + pFakeRoot = pParser->GetRootNode(); + if (pFakeRoot) { + if (bOverwrite) { + CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pNewChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + int32_t index = 0; + while (pNewChild) { + CXFA_Node* pItem = pNewChild->GetNodeItem(XFA_NODEITEM_NextSibling); + pFakeRoot->RemoveChild(pNewChild); + InsertChild(index++, pNewChild); + pNewChild->SetFlag(XFA_NODEFLAG_Initialized); + pNewChild = pItem; + } + while (pChild) { + CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + RemoveChild(pChild); + pFakeRoot->InsertChild(pChild); + pChild = pItem; + } + if (GetPacketID() == XFA_XDPPACKET_Form && + GetClassID() == XFA_ELEMENT_ExData) { + IFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); + SetXMLMappingNode(pFakeXMLRoot); + SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); + if (pTempXMLNode && + pTempXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL) { + pFakeXMLRoot = pTempXMLNode; + } else { + pFakeXMLRoot = NULL; + } + } + MoveBufferMapData(pFakeRoot, this, XFA_CalcData, TRUE); + } else { + CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChild) { + CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + pFakeRoot->RemoveChild(pChild); + InsertChild(pChild); + pChild->SetFlag(XFA_NODEFLAG_Initialized); + pChild = pItem; + } + } + if (pFakeXMLRoot) { + pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); + pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); + } + pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, TRUE, FALSE); + } else { + if (pFakeXMLRoot) { + pFakeXMLRoot->Release(); + pFakeXMLRoot = NULL; + } + } + pParser->Release(); + pParser = NULL; +} +void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { +} + +void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 0 || iLength > 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); + return; + } + FX_BOOL bPrettyMode = FALSE; + if (iLength == 1) { + CFX_ByteString bsPretty = pArguments->GetUTF8String(0); + if (!bsPretty.Equal("pretty")) { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + return; + } + bPrettyMode = TRUE; + } + CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + if (GetPacketID() == XFA_XDPPACKET_Form) { + IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); + IFX_Stream* pStream = IFX_Stream::CreateStream( + (IFX_FileWrite*)pMemoryStream, + FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); + if (!pStream) { + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); + pMemoryStream->Release(); + pMemoryStream = NULL; + return; + } + pStream->SetCodePage(FX_CODEPAGE_UTF8); + pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength()); + XFA_DataExporter_RegenerateFormFile(this, pStream, NULL, TRUE); + FXJSE_Value_SetUTF8String( + pArguments->GetReturnValue(), + CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); + pStream->Release(); + pStream = NULL; + if (pMemoryStream) { + pMemoryStream->Release(); + pMemoryStream = NULL; + } + return; + } + if (GetPacketID() == XFA_XDPPACKET_Datasets) { + IFDE_XMLNode* pElement = GetXMLMappingNode(); + if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); + return; + } + XFA_DataExporter_DealWithDataGroupNode(this); + IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); + IFX_Stream* pStream = IFX_Stream::CreateStream( + (IFX_FileWrite*)pMemoryStream, + FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); + if (pStream) { + pStream->SetCodePage(FX_CODEPAGE_UTF8); + pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength()); + pElement->SaveXMLNode(pStream); + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), + CFX_ByteStringC(pMemoryStream->GetBuffer(), + pMemoryStream->GetSize())); + pStream->Release(); + pStream = NULL; + } + if (pMemoryStream) { + pMemoryStream->Release(); + pMemoryStream = NULL; + } + return; + } + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); +} + +void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + 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, wsAttributeValue, TRUE); +} +void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1 && iLength != 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setElement"); + return; + } + CXFA_Node* pNode = NULL; + CFX_WideString wsName; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (iLength >= 2) { + CFX_ByteString bsName = pArguments->GetUTF8String(1); + wsName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); + } +} +void CXFA_Node::Script_NodeClass_Ns(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + CFX_WideString wsNameSpace; + TryNamespace(wsNameSpace); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsNameSpace)); + } +} +void CXFA_Node::Script_NodeClass_Model(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FXJSE_Value_Set(hValue, m_pDocument->GetScriptContext()->GetJSValueFromMap( + GetModelNode())); + } +} +void CXFA_Node::Script_NodeClass_IsContainer(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FXJSE_Value_SetBoolean(hValue, IsContainerNode()); + } +} +void CXFA_Node::Script_NodeClass_IsNull(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + if (GetClassID() == XFA_ELEMENT_Subform) { + FXJSE_Value_SetBoolean(hValue, FALSE); + return; + } + CFX_WideString strValue; + FXJSE_Value_SetBoolean(hValue, !TryContent(strValue) || strValue.IsEmpty()); + } +} +void CXFA_Node::Script_NodeClass_OneOfChild(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + CXFA_NodeArray properts; + int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); + if (iSize > 0) { + FXJSE_Value_Set( + hValue, + m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); + } + } +} +void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} +void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { + CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); + FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, + m_pDocument->GetScriptContext()->GetJseNormalClass()); +} +void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { +} +void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { + Script_Template_CreateNode(pArguments); +} +void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"isCompatibleNS"); + return; + } + CFX_WideString wsNameSpace; + if (iLength >= 1) { + CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); + wsNameSpace = + CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); + } + CFX_WideString wsNodeNameSpace; + TryNamespace(wsNodeNameSpace); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace.Equal(wsNameSpace)); + } +} +void CXFA_Node::Script_ModelClass_Context(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Attribute_Integer(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + SetInteger(eAttribute, FXJSE_Value_ToInteger(hValue), TRUE); + } else { + FXJSE_Value_SetInteger(hValue, GetInteger(eAttribute)); + } +} +void CXFA_Node::Script_Attribute_IntegerRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + FXJSE_Value_SetInteger(hValue, GetInteger(eAttribute)); + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_Attribute_BOOL(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + SetBoolean(eAttribute, FXJSE_Value_ToBoolean(hValue), TRUE); + } else { + FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); + } +} +void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( + void* eAttribute, + void* eValue, + FX_BOOL bScriptModify) { + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (!pLayoutPro) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + FX_DWORD 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)); + } + } break; + case XFA_ELEMENT_CheckButton: { + bNeedFindContainer = TRUE; + CXFA_Node* pUINode = 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; + } + 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->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); + } + } + } + } break; + default: + break; + } + if (bNeedFindContainer) { + CXFA_Node* pParent = this; + while (pParent) { + if (pParent->IsContainerNode()) { + break; + } + pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); + } + 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, TRUE); + if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { + CFX_WideString wsUseVal = wsValue, wsID, wsSOM; + CXFA_Node* pTemplateNode = + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); + CXFA_Node* pProtoRoot = + pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) + ->GetFirstChildByClass(XFA_ELEMENT_Proto); + if (!wsUseVal.IsEmpty()) { + if (wsUseVal[0] == '#') { + wsID = CFX_WideString((const FX_WCHAR*)wsUseVal + 1, + wsUseVal.GetLength() - 1); + } else { + wsSOM = + CFX_WideString((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength()); + } + } + CXFA_Node* pProtoNode = NULL; + if (!wsSOM.IsEmpty()) { + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | + XFA_RESOLVENODE_Attributes | + XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects( + pProtoRoot, wsSOM, resoveNodeRS, dwFlag); + if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { + pProtoNode = resoveNodeRS.nodes[0]->AsNode(); + } + } else if (!wsID.IsEmpty()) { + pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID); + } + if (pProtoNode) { + CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild); + while (pHeadChild) { + CXFA_Node* pSibling = + pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); + RemoveChild(pHeadChild); + pHeadChild = pSibling; + } + CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(TRUE); + pHeadChild = pProtoForm->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pHeadChild) { + CXFA_Node* pSibling = + pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); + pProtoForm->RemoveChild(pHeadChild); + InsertChild(pHeadChild); + pHeadChild = pSibling; + } + m_pDocument->RemovePurgeNode(pProtoForm); + delete pProtoForm; + } + } + } else { + CFX_WideString wsValue; + GetAttribute(eAttribute, wsValue); + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(wsValue, wsValue.GetLength())); + } +} +void CXFA_Node::Script_Attribute_StringRead(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + CFX_WideString wsValue; + GetAttribute(eAttribute, wsValue); + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(wsValue, wsValue.GetLength())); + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc == 0) || (argc == 1)) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); + } +} +void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); + } +} +void CXFA_Node::Script_Delta_CurrentValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Delta_SavedValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Delta_Target(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Som_Message(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_SOM_MESSAGETYPE iMessageType) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + FX_BOOL bNew = FALSE; + CXFA_Validate validate = pWidgetData->GetValidate(); + if (!validate) { + validate = pWidgetData->GetValidate(TRUE); + bNew = TRUE; + } + if (bSetting) { + CFX_ByteString bsMessage; + FXJSE_Value_ToUTF8String(hValue, bsMessage); + switch (iMessageType) { + case XFA_SOM_ValidationMessage: + validate.SetScriptMessageText( + CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); + break; + case XFA_SOM_FormatMessage: + validate.SetFormatMessageText( + CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); + break; + case XFA_SOM_MandatoryMessage: + validate.SetNullMessageText( + CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); + break; + default: + break; + } + if (!bNew) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->AddCalcValidate(this); + } + } else { + CFX_WideString wsMessage; + switch (iMessageType) { + case XFA_SOM_ValidationMessage: + validate.GetScriptMessageText(wsMessage); + break; + case XFA_SOM_FormatMessage: + validate.GetFormatMessageText(wsMessage); + break; + case XFA_SOM_MandatoryMessage: + validate.GetNullMessageText(wsMessage); + break; + default: + break; + } + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsMessage)); + } +} +void CXFA_Node::Script_Som_ValidationMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_Som_Message(hValue, bSetting, XFA_SOM_ValidationMessage); +} +void CXFA_Node::Script_Field_Length(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetInteger(hValue, 0); + return; + } + FXJSE_Value_SetInteger(hValue, pWidgetData->CountChoiceListItems(TRUE)); + } +} +void CXFA_Node::Script_Som_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + XFA_ELEMENT classID = GetClassID(); + if (classID == XFA_ELEMENT_Field) { + Script_Field_DefaultValue(hValue, bSetting, eAttribute); + return; + } else if (classID == XFA_ELEMENT_Draw) { + Script_Draw_DefaultValue(hValue, bSetting, eAttribute); + return; + } else if (classID == XFA_ELEMENT_Boolean) { + Script_Boolean_Value(hValue, bSetting, eAttribute); + return; + } + if (bSetting) { + CFX_ByteString newValue; + 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 wsFormatValue(wsNewValue); + CXFA_WidgetData* pContainerWidgetData = NULL; + if (GetPacketID() == XFA_XDPPACKET_Datasets) { + CXFA_NodeArray formNodes; + GetBindItems(formNodes); + CFX_WideString wsPicture; + for (int32_t i = 0; i < formNodes.GetSize(); i++) { + CXFA_Node* pFormNode = formNodes.GetAt(i); + if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { + continue; + } + pContainerWidgetData = pFormNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetPictureContent(wsPicture, + XFA_VALUEPICTURE_DataBind); + } + if (!wsPicture.IsEmpty()) { + break; + } + pContainerWidgetData = NULL; + } + } else if (GetPacketID() == XFA_XDPPACKET_Form) { + pContainerWidgetData = GetContainerWidgetData(); + } + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); + } + 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)); + } else if (classID == XFA_ELEMENT_Float || classID == XFA_ELEMENT_Decimal) { + CFX_Decimal decimal(content); + FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); + } else { + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(content, content.GetLength())); + } + } +} +void CXFA_Node::Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CFX_WideString content = GetScriptContent(TRUE); + if (content.IsEmpty()) { + FXJSE_Value_SetNull(hValue); + } else { + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(content, content.GetLength())); + } +} +void CXFA_Node::Script_Boolean_Value(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + CFX_ByteString newValue; + 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"); + CFX_WideString wsFormatValue(wsNewValue); + CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); + } + SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); + } else { + CFX_WideString wsValue = GetScriptContent(TRUE); + FXJSE_Value_SetBoolean(hValue, wsValue.Equal(FX_WSTRC(L"1"))); + } +} +struct XFA_ExecEventParaInfo { + public: + uint32_t m_uHash; + const FX_WCHAR* m_lpcEventName; + XFA_EVENTTYPE m_eventType; + uint32_t m_validFlags; +}; +static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { + {0x02a6c55a, L"postSubmit", XFA_EVENT_PostSubmit, 0}, + {0x0ab466bb, L"preSubmit", XFA_EVENT_PreSubmit, 0}, + {0x109d7ce7, L"mouseEnter", XFA_EVENT_MouseEnter, 5}, + {0x17fad373, L"postPrint", XFA_EVENT_PostPrint, 0}, + {0x1bfc72d9, L"preOpen", XFA_EVENT_PreOpen, 7}, + {0x2196a452, L"initialize", XFA_EVENT_Initialize, 1}, + {0x27410f03, L"mouseExit", XFA_EVENT_MouseExit, 5}, + {0x33c43dec, L"docClose", XFA_EVENT_DocClose, 0}, + {0x361fa1b6, L"preSave", XFA_EVENT_PreSave, 0}, + {0x36f1c6d8, L"preSign", XFA_EVENT_PreSign, 6}, + {0x4731d6ba, L"exit", XFA_EVENT_Exit, 2}, + {0x56bf456b, L"docReady", XFA_EVENT_DocReady, 0}, + {0x7233018a, L"validate", XFA_EVENT_Validate, 1}, + {0x8808385e, L"indexChange", XFA_EVENT_IndexChange, 3}, + {0x891f4606, L"change", XFA_EVENT_Change, 4}, + {0x9528a7b4, L"prePrint", XFA_EVENT_PrePrint, 0}, + {0x9f693b21, L"mouseDown", XFA_EVENT_MouseDown, 5}, + {0xcdce56b3, L"full", XFA_EVENT_Full, 4}, + {0xd576d08e, L"mouseUp", XFA_EVENT_MouseUp, 5}, + {0xd95657a6, L"click", XFA_EVENT_Click, 4}, + {0xdbfbe02e, L"calculate", XFA_EVENT_Calculate, 1}, + {0xe25fa7b8, L"postOpen", XFA_EVENT_PostOpen, 7}, + {0xe28dce7e, L"enter", XFA_EVENT_Enter, 2}, + {0xfc82d695, L"postSave", XFA_EVENT_PostSave, 0}, + {0xfd54fbb7, L"postSign", XFA_EVENT_PostSign, 6}, +}; +const XFA_ExecEventParaInfo* GetEventParaInfoByName( + const CFX_WideStringC& wsEventName) { + int32_t iLength = wsEventName.GetLength(); + uint32_t uHash = FX_HashCode_String_GetW(wsEventName.GetPtr(), 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; + do { + iMid = (iStart + iEnd) / 2; + eventParaInfo = &gs_eventParaInfos[iMid]; + if (uHash == eventParaInfo->m_uHash) { + return eventParaInfo; + } else if (uHash < eventParaInfo->m_uHash) { + iEnd = iMid - 1; + } else { + iStart = iMid + 1; + } + } while (iStart <= iEnd); + return NULL; +} +void XFA_STRING_TO_RGB(CFX_WideString& strRGB, + int32_t& r, + int32_t& g, + int32_t& b) { + r = 0; + g = 0; + b = 0; + FX_WCHAR zero = '0'; + int32_t iIndex = 0; + int32_t iLen = strRGB.GetLength(); + for (int32_t i = 0; i < iLen; ++i) { + FX_WCHAR ch = strRGB.GetAt(i); + if (ch == L',') { + ++iIndex; + } + if (iIndex > 2) { + break; + } + int32_t iValue = ch - zero; + if (iValue >= 0 && iValue <= 9) { + switch (iIndex) { + case 0: + r = r * 10 + iValue; + break; + case 1: + g = g * 10 + iValue; + break; + default: + b = b * 10 + iValue; + break; + } + } + } +} +void CXFA_Node::Script_Som_BorderColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CXFA_Border border = pWidgetData->GetBorder(TRUE); + int32_t iSize = border.CountEdges(); + CFX_WideString strColor; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + strColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + int32_t r = 0, g = 0, b = 0; + XFA_STRING_TO_RGB(strColor, r, g, b); + FX_ARGB rgb = ArgbEncode(100, r, g, b); + for (int32_t i = 0; i < iSize; ++i) { + CXFA_Edge edge = border.GetEdge(i); + edge.SetColor(rgb); + } + } else { + CXFA_Edge edge = border.GetEdge(0); + FX_ARGB color = edge.GetColor(); + 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)); + } +} +void CXFA_Node::Script_Som_BorderWidth(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CXFA_Border border = pWidgetData->GetBorder(TRUE); + int32_t iSize = border.CountEdges(); + CFX_WideString wsThickness; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsThickness = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + for (int32_t i = 0; i < iSize; ++i) { + CXFA_Edge edge = border.GetEdge(i); + CXFA_Measurement thickness(wsThickness); + 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)); + } +} +void CXFA_Node::Script_Som_FillColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CXFA_Border border = pWidgetData->GetBorder(TRUE); + CXFA_Fill borderfill = border.GetFill(TRUE); + CXFA_Node* pNode = borderfill.GetNode(); + if (!pNode) { + return; + } + CFX_WideString wsColor; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + int32_t r, g, b; + XFA_STRING_TO_RGB(wsColor, r, g, b); + FX_ARGB color = ArgbEncode(0xff, r, g, b); + borderfill.SetColor(color); + } else { + FX_ARGB color = borderfill.GetColor(); + 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)); + } +} +void CXFA_Node::Script_Som_DataNode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + CXFA_Node* pDataNode = GetBindData(); + if (pDataNode) { + FXJSE_Value_Set( + hValue, + m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); + } else { + FXJSE_Value_SetNull(hValue); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_Draw_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + if (FXJSE_Value_IsUTF8String(hValue)) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + FXSYS_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 wsFormatValue(wsNewValue); + SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); + } else if (uiType != XFA_ELEMENT_Image) { + } + } + } else { + CFX_WideString content = GetScriptContent(TRUE); + if (content.IsEmpty()) { + FXJSE_Value_SetNull(hValue); + } else { + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(content, content.GetLength())); + } + } +} +void CXFA_Node::Script_Field_DefaultValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + if (bSetting) { + if (FXJSE_Value_IsNull(hValue)) { + pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; + pWidgetData->m_bIsNull = TRUE; + } else { + pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; + pWidgetData->m_bIsNull = FALSE; + } + CFX_ByteString newValue; + if (!(FXJSE_Value_IsNull(hValue) || FXJSE_Value_IsUndefined(hValue))) { + FXJSE_Value_ToUTF8String(hValue, newValue); + } + CFX_WideString wsNewText = + CFX_WideString::FromUTF8(newValue, newValue.GetLength()); + 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); + } + CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); + CFX_WideString wsFormatText(wsNewText); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); + } + SetScriptContent(wsNewText, wsFormatText, TRUE, TRUE); + } else { + CFX_WideString content = GetScriptContent(TRUE); + if (content.IsEmpty()) { + FXJSE_Value_SetNull(hValue); + } else { + CXFA_Node* pUIChild = pWidgetData->GetUIChild(); + XFA_ELEMENT eUI = pUIChild->GetClassID(); + CXFA_Value defVal = pWidgetData->GetFormValue(); + CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pNode && pNode->GetClassID() == XFA_ELEMENT_Decimal) { + if (eUI == XFA_ELEMENT_NumericEdit && + (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { + FXJSE_Value_SetUTF8String( + hValue, FX_UTF8Encode(content, content.GetLength())); + } else { + CFX_Decimal decimal(content); + FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); + } + } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Integer) { + FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content)); + } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Boolean) { + FXJSE_Value_SetBoolean(hValue, FXSYS_wtoi(content) == 0 ? FALSE : TRUE); + } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Float) { + CFX_Decimal decimal(content); + FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); + } else { + FXJSE_Value_SetUTF8String(hValue, + FX_UTF8Encode(content, content.GetLength())); + } + } + } +} +void CXFA_Node::Script_Field_EditValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CFX_WideString wsValue; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit); + } else { + pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); + } +} +void CXFA_Node::Script_Som_FontColor(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CXFA_Font font = pWidgetData->GetFont(TRUE); + CXFA_Node* pNode = font.GetNode(); + if (!pNode) { + return; + } + CFX_WideString wsColor; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + int32_t r, g, b; + XFA_STRING_TO_RGB(wsColor, r, g, b); + FX_ARGB color = ArgbEncode(0xff, r, g, b); + font.SetColor(color); + } else { + FX_ARGB color = font.GetColor(); + 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)); + } +} +void CXFA_Node::Script_Field_FormatMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_Som_Message(hValue, bSetting, XFA_SOM_FormatMessage); +} +void CXFA_Node::Script_Field_FormattedValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CFX_WideString wsValue; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display); + } else { + pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); + } +} +void CXFA_Node::Script_Som_Mandatory(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CXFA_Validate validate = pWidgetData->GetValidate(TRUE); + CFX_WideString wsValue; + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + validate.SetNullTest(wsValue); + } else { + int32_t iValue = validate.GetNullTest(); + const XFA_ATTRIBUTEENUMINFO* pInfo = + XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); + if (pInfo) { + wsValue = pInfo->pName; + } + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); + } +} +void CXFA_Node::Script_Som_MandatoryMessage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_Som_Message(hValue, bSetting, XFA_SOM_MandatoryMessage); +} +void CXFA_Node::Script_Field_ParentSubform(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } else { + FXJSE_Value_SetNull(hValue); + } +} +void CXFA_Node::Script_Field_SelectedIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + if (bSetting) { + int32_t iIndex = FXJSE_Value_ToInteger(hValue); + if (iIndex == -1) { + pWidgetData->ClearAllSelections(); + return; + } + pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE); + } else { + FXJSE_Value_SetInteger(hValue, pWidgetData->GetSelectedItem()); + } +} +void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + pWidgetData->DeleteItem(-1, TRUE); +} +void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CFX_ByteString eventString = pArguments->GetUTF8String(0); + int32_t iRet = execSingleEventByName( + CFX_WideString::FromUTF8(eventString, eventString.GetLength()), + XFA_ELEMENT_Field); + if (eventString == "validate") { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), + ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); + } +} +void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execInitialize"); + } +} +void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + int32_t iIndex = pArguments->GetInt32(0); + FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, bValue); + } +} +void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); + return; + } + int32_t iIndex = pArguments->GetInt32(0); + if (iIndex < 0) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + return; + } + CFX_WideString wsValue; + FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); + if (bHasItem) { + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), + FX_UTF8Encode(wsValue, wsValue.GetLength())); + } else { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } +} +void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CFX_ByteString bsValue = pArguments->GetUTF8String(0); + CFX_WideString wsValue = + CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + CFX_WideString wsBoundValue; + pWidgetData->GetItemValue(wsValue, wsBoundValue); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsBoundValue)); + } +} +void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"getItemState"); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + int32_t iIndex = pArguments->GetInt32(0); + FX_BOOL bValue = pWidgetData->GetItemState(iIndex); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, bValue); + } +} +void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execCalculate"); + } +} +void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} +void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"getDisplayItem"); + return; + } + int32_t iIndex = pArguments->GetInt32(0); + if (iIndex < 0) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + return; + } + CFX_WideString wsValue; + FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); + if (bHasItem) { + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), + FX_UTF8Encode(wsValue, wsValue.GetLength())); + } else { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } +} +void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"setItemState"); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + int32_t iIndex = pArguments->GetInt32(0); + if (pArguments->GetInt32(1) != 0) { + pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE); + } else { + if (pWidgetData->GetItemState(iIndex)) { + pWidgetData->SetItemState(iIndex, FALSE, TRUE, TRUE); + } + } +} +void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem"); + return; + } + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + CFX_WideString wsLabel; + CFX_WideString wsValue; + if (iLength >= 1) { + CFX_ByteString bsLable = pArguments->GetUTF8String(0); + wsLabel = CFX_WideString::FromUTF8(bsLable, bsLable.GetLength()); + } + if (iLength >= 2) { + CFX_ByteString bsValue = pArguments->GetUTF8String(1); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + } + pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); +} +void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + int32_t iRet = + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), + ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execValidate"); + } +} +void CXFA_Node::Script_ExclGroup_ErrorText(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + return; + } + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + pWidgetData->SetSelectedMemberByValue( + CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()), 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)); + } + } +} +void CXFA_Node::Script_ExclGroup_Transient(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CFX_ByteString eventString = pArguments->GetUTF8String(0); + execSingleEventByName( + CFX_WideString::FromUTF8(eventString, eventString.GetLength()), + XFA_ELEMENT_ExclGroup); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); + } +} +void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc == 0) || (argc == 1)) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } else { + CXFA_Node* pReturnNode = NULL; + if (argc == 0) { + pReturnNode = pWidgetData->GetSelectedMember(); + } else { + CFX_ByteString szName; + szName = pArguments->GetUTF8String(0); + pReturnNode = pWidgetData->SetSelectedMember( + CFX_WideString::FromUTF8(szName, szName.GetLength())); + } + if (pReturnNode) { + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode)); + } else { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"selectedMember"); + } +} +void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execInitialize"); + } +} +void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execCalculate"); + } +} +void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), + ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execValidate"); + } +} +static CXFA_Node* XFA_ScriptInstanceManager_GetItem(CXFA_Node* pInstMgrNode, + int32_t iIndex) { + ASSERT(pInstMgrNode); + int32_t iCount = 0; + FX_DWORD dwNameHash = 0; + for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ELEMENT eCurType = pNode->GetClassID(); + if (eCurType == XFA_ELEMENT_InstanceManager) { + break; + } + if ((eCurType != XFA_ELEMENT_Subform) && + (eCurType != XFA_ELEMENT_SubformSet)) { + continue; + } + if (iCount == 0) { + CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); + CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); + if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || + wsInstName.Mid(1) != wsName) { + return NULL; + } + dwNameHash = pNode->GetNameHash(); + } + if (dwNameHash != pNode->GetNameHash()) { + break; + } + iCount++; + if (iCount > iIndex) { + return pNode; + } + } + return NULL; +} +void CXFA_Node::Script_Som_InstanceIndex(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + int32_t iTo = FXJSE_Value_ToInteger(hValue); + int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); + CXFA_Node* pManagerNode = NULL; + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { + pManagerNode = pNode; + break; + } + } + if (pManagerNode) { + pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CXFA_Node* pToInstance = + XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); + if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { + pNotify->RunSubformIndexChange(pToInstance); + } + CXFA_Node* pFromInstance = + XFA_ScriptInstanceManager_GetItem(pManagerNode, iFrom); + if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { + pNotify->RunSubformIndexChange(pFromInstance); + } + } + } else { + FXJSE_Value_SetInteger(hValue, Subform_and_SubformSet_InstanceIndex()); + } +} +void CXFA_Node::Script_Subform_InstanceManager(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); + CXFA_Node* pInstanceMgr = NULL; + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { + CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); + if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && + wsInstMgrName.Mid(1) == wsName) { + pInstanceMgr = pNode; + } + break; + } + } + if (pInstanceMgr) { + FXJSE_Value_Set( + hValue, + m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); + } else { + FXJSE_Value_SetNull(hValue); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +void CXFA_Node::Script_Subform_Locale(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + CFX_ByteString bsLocaleName; + FXJSE_Value_ToUTF8String(hValue, bsLocaleName); + SetCData(XFA_ATTRIBUTE_Locale, + CFX_WideString::FromUTF8(bsLocaleName, bsLocaleName.GetLength()), + TRUE, TRUE); + } else { + CFX_WideString wsLocaleName; + GetLocaleName(wsLocaleName); + FXJSE_Value_SetUTF8String( + hValue, FX_UTF8Encode(wsLocaleName, wsLocaleName.GetLength())); + } +} +void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CFX_ByteString eventString = pArguments->GetUTF8String(0); + execSingleEventByName( + CFX_WideString::FromUTF8(eventString, eventString.GetLength()), + XFA_ELEMENT_Subform); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); + } +} +void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execInitialize"); + } +} +void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execCalculate"); + } +} +void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), + ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execValidate"); + } +} +void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"getInvalidObjects"); + } +} +int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { + int32_t index = 0; + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + if ((pNode->GetClassID() == XFA_ELEMENT_Subform) || + (pNode->GetClassID() == XFA_ELEMENT_SubformSet)) { + index++; + } else { + break; + } + } + return index; +} +void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); + } +} +void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + m_pDocument->DoDataRemerge(TRUE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); + } +} +void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execInitialize"); + } +} +void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc > 0) && (argc < 4)) { + CFX_WideString strTagName; + CFX_WideString strName; + CFX_WideString strNameSpace; + CFX_ByteString bsTagName = pArguments->GetUTF8String(0); + strTagName = CFX_WideString::FromUTF8(bsTagName, bsTagName.GetLength()); + if (argc > 1) { + CFX_ByteString bsName = pArguments->GetUTF8String(1); + strName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); + if (argc == 3) { + CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); + strNameSpace = + CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); + } + } + const XFA_ELEMENTINFO* pElement = XFA_GetElementByName(strTagName); + CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); + if (!pNewNode) { + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } else { + if (!strName.IsEmpty()) { + if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, + XFA_XDPPACKET_UNKNOWN)) { + pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName, TRUE); + if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { + pNewNode->CreateXMLMappingNode(); + } + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); + } else { + ThrowScriptErrorMessage(XFA_IDS_NOT_HAVE_PROPERTY, + (const FX_WCHAR*)strTagName, L"name"); + } + } else { + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); + } + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); + } +} +void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { + if (pArguments->GetLength() == 1) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); + } +} +void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execCalculate"); + } +} +void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execValidate"); + } +} +void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (!pWidgetData) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); + } +} +void CXFA_Node::Script_InstanceManager_Max(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CXFA_Occur nodeOccur(GetOccurNode()); + FXJSE_Value_SetInteger(hValue, nodeOccur.GetMax()); +} +void CXFA_Node::Script_InstanceManager_Min(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CXFA_Occur nodeOccur(GetOccurNode()); + FXJSE_Value_SetInteger(hValue, nodeOccur.GetMin()); +} +static int32_t XFA_ScriptInstanceManager_GetCount(CXFA_Node* pInstMgrNode) { + ASSERT(pInstMgrNode); + int32_t iCount = 0; + FX_DWORD dwNameHash = 0; + for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ELEMENT eCurType = pNode->GetClassID(); + if (eCurType == XFA_ELEMENT_InstanceManager) { + break; + } + if ((eCurType != XFA_ELEMENT_Subform) && + (eCurType != XFA_ELEMENT_SubformSet)) { + continue; + } + if (iCount == 0) { + CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); + CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); + if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || + wsInstName.Mid(1) != wsName) { + return iCount; + } + dwNameHash = pNode->GetNameHash(); + } + if (dwNameHash != pNode->GetNameHash()) { + break; + } + iCount++; + } + return iCount; +} +static void +XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( + const CXFA_NodeSet& rgNodeSet, + CXFA_NodeArray& rgNodeArray, + CFX_ArrayTemplate<int32_t>& rgIdxArray) { + int32_t iCount = rgNodeSet.GetCount(); + rgNodeArray.SetSize(iCount); + rgIdxArray.SetSize(iCount); + 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); + pNode && iIndex < iCount; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + iTotalIndex++; + if (rgNodeSet.Lookup(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<FX_DWORD, 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); + FX_DWORD dwNameHash = pNode->GetNameHash(); + if (!pParentNode || !dwNameHash) { + continue; + } + CFX_MapPtrTemplate<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = + rgNodeListMap[pParentNode]; + if (!pNodeListChildMap) { + rgNodeListMap[pParentNode] = pNodeListChildMap = + new CFX_MapPtrTemplate<FX_DWORD, 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); + FX_DWORD dwNameHash = pNode->GetNameHash(); + if (!pParentNode || !dwNameHash) { + continue; + } + CFX_MapPtrTemplate<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = + rgNodeListMap[pParentNode]; + if (!pNodeListChildMap) { + rgNodeListMap[pParentNode] = pNodeListChildMap = + new CFX_MapPtrTemplate<FX_DWORD, 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<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = NULL; + rgNodeListMap.GetNextAssoc(pos, pParentNode, pNodeListChildMap); + if (!pNodeListChildMap) { + continue; + } + FX_POSITION childpos = pNodeListChildMap->GetStartPosition(); + while (childpos) { + FX_DWORD dwNameHash = 0; + CXFA_DualNodeArray* pDualNodeArray = NULL; + pNodeListChildMap->GetNextAssoc(childpos, dwNameHash, pDualNodeArray); + if (!pDualNodeArray) { + continue; + } + if (pDualNodeArray->firstNodeList.GetCount() != 0 && + pDualNodeArray->secondNodeList.GetCount() != 0) { + CXFA_NodeArray rgNodeArray1, rgNodeArray2; + CFX_ArrayTemplate<int32_t> rgIdxArray1, rgIdxArray2; + XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( + pDualNodeArray->firstNodeList, rgNodeArray1, rgIdxArray1); + XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( + pDualNodeArray->secondNodeList, rgNodeArray2, rgIdxArray2); + CXFA_Node *pParentNode = NULL, *pBeforeNode = NULL; + if (bInsertBefore) { + pBeforeNode = rgNodeArray2[0]; + pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent); + } else { + CXFA_Node* pLastNode = rgNodeArray2[rgIdxArray2.GetSize() - 1]; + pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent); + pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + for (int32_t iIdx = 0, iCount = rgIdxArray1.GetSize(); iIdx < iCount; + iIdx++) { + CXFA_Node* pCurNode = rgNodeArray1[iIdx]; + pParentNode->RemoveChild(pCurNode); + pParentNode->InsertChild(pCurNode, pBeforeNode); + } + } + delete pDualNodeArray; + } + pNodeListChildMap->RemoveAll(); + } + rgNodeListMap.RemoveAll(); +} +static void XFA_ScriptInstanceManager_InsertItem( + CXFA_Node* pInstMgrNode, + CXFA_Node* pNewInstance, + int32_t iPos, + int32_t iCount = -1, + FX_BOOL bMoveDataBindingNodes = TRUE) { + if (iCount < 0) { + iCount = XFA_ScriptInstanceManager_GetCount(pInstMgrNode); + } + if (iPos < 0) { + iPos = iCount; + } + if (iPos == iCount) { + CXFA_Node* pNextSibling = + iCount > 0 + ? XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iCount - 1) + ->GetNodeItem(XFA_NODEITEM_NextSibling) + : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) + ->InsertChild(pNewInstance, pNextSibling); + if (bMoveDataBindingNodes) { + CXFA_NodeSet sNew, sAfter; + CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode> + sIteratorNew(pNewInstance); + for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; + pNode = sIteratorNew.MoveToNext()) { + CXFA_Node* pDataNode = pNode->GetBindData(); + if (!pDataNode) { + continue; + } + sNew.Add(pDataNode); + } + CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode> + sIteratorAfter(pNextSibling); + for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode; + pNode = sIteratorAfter.MoveToNext()) { + CXFA_Node* pDataNode = pNode->GetBindData(); + if (!pDataNode) { + continue; + } + sAfter.Add(pDataNode); + } + XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sAfter, FALSE); + } + } else { + CXFA_Node* pBeforeInstance = + XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iPos); + pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) + ->InsertChild(pNewInstance, pBeforeInstance); + if (bMoveDataBindingNodes) { + CXFA_NodeSet sNew, sBefore; + CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode> + sIteratorNew(pNewInstance); + for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; + pNode = sIteratorNew.MoveToNext()) { + CXFA_Node* pDataNode = pNode->GetBindData(); + if (!pDataNode) { + continue; + } + sNew.Add(pDataNode); + } + CXFA_NodeIteratorTemplate<CXFA_Node, + CXFA_TraverseStrategy_XFAContainerNode> + sIteratorBefore(pBeforeInstance); + for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode; + pNode = sIteratorBefore.MoveToNext()) { + CXFA_Node* pDataNode = pNode->GetBindData(); + if (!pDataNode) { + continue; + } + sBefore.Add(pDataNode); + } + XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sBefore, TRUE); + } + } +} +static void XFA_ScriptInstanceManager_RemoveItem( + CXFA_Node* pInstMgrNode, + CXFA_Node* pRemoveInstance, + FX_BOOL bRemoveDataBinding = TRUE) { + pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance); + if (!bRemoveDataBinding) { + return; + } + CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> + sIterator(pRemoveInstance); + for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode; + pFormNode = sIterator.MoveToNext()) { + CXFA_Node* pDataNode = pFormNode->GetBindData(); + if (!pDataNode) { + continue; + } + if (pDataNode->RemoveBindItem(pFormNode) == 0) { + if (CXFA_Node* pDataParent = + pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { + pDataParent->RemoveChild(pDataNode); + } + } + pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); + } +} +static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance( + CXFA_Node* pInstMgrNode, + FX_BOOL bDataMerge) { + CXFA_Document* pDocument = pInstMgrNode->GetDocument(); + CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); + CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pDataScope = NULL; + for (CXFA_Node* pRootBoundNode = pFormParent; + pRootBoundNode && + pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; + pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { + pDataScope = pRootBoundNode->GetBindData(); + if (pDataScope) { + break; + } + } + if (!pDataScope) { + pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); + ASSERT(pDataScope); + } + CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer( + pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge); + if (pInstance) { + pDocument->DataMerge_UpdateBindingRelations(pInstance); + pFormParent->RemoveChild(pInstance); + } + return pInstance; +} +void CXFA_Node::Script_InstanceManager_Count(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + int32_t iDesired = FXJSE_Value_ToInteger(hValue); + InstanceManager_SetInstances(iDesired); + } else { + FXJSE_Value_SetInteger(hValue, XFA_ScriptInstanceManager_GetCount(this)); + } +} +void CXFA_Node::Script_InstanceManager_MoveInstance( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc != 2) { + FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); + return; + } + int32_t iFrom = pArguments->GetInt32(0); + int32_t iTo = pArguments->GetInt32(1); + InstanceManager_MoveInstance(iTo, iFrom); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); + if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { + pNotify->RunSubformIndexChange(pToInstance); + } + CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); + if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { + pNotify->RunSubformIndexChange(pFromInstance); + } +} +void CXFA_Node::Script_InstanceManager_RemoveInstance( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc != 1) { + FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); + return; + } + int32_t iIndex = pArguments->GetInt32(0); + int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); + if (iIndex < 0 || iIndex >= iCount) { + ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); + return; + } + CXFA_Occur nodeOccur(GetOccurNode()); + int32_t iMin = nodeOccur.GetMin(); + if (iCount - 1 < iMin) { + ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"min"); + return; + } + CXFA_Node* pRemoveInstance = XFA_ScriptInstanceManager_GetItem(this, iIndex); + XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + for (int32_t i = iIndex; i < iCount - 1; i++) { + CXFA_Node* pSubformInstance = XFA_ScriptInstanceManager_GetItem(this, i); + if (pSubformInstance && + pSubformInstance->GetClassID() == XFA_ELEMENT_Subform) { + pNotify->RunSubformIndexChange(pSubformInstance); + } + } + } + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (!pLayoutPro) { + return; + } + pLayoutPro->AddChangedContainer( + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); +} +void CXFA_Node::Script_InstanceManager_SetInstances( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc != 1) { + FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); + return; + } + int32_t iDesired = pArguments->GetInt32(0); + InstanceManager_SetInstances(iDesired); +} +void CXFA_Node::Script_InstanceManager_AddInstance( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc != 0) && (argc != 1)) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); + return; + } + FX_BOOL fFlags = TRUE; + if (argc == 1) { + fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; + } + int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); + CXFA_Occur nodeOccur(GetOccurNode()); + int32_t iMax = nodeOccur.GetMax(); + if (iMax >= 0 && iCount >= iMax) { + ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); + return; + } + CXFA_Node* pNewInstance = + XFA_ScriptInstanceManager_CreateInstance(this, fFlags); + XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, + FALSE); + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->RunNodeInitialize(pNewInstance); + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (!pLayoutPro) { + return; + } + pLayoutPro->AddChangedContainer( + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); +} +void CXFA_Node::Script_InstanceManager_InsertInstance( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc != 1) && (argc != 2)) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"insertInstance"); + return; + } + int32_t iIndex = pArguments->GetInt32(0); + FX_BOOL bBind = FALSE; + if (argc == 2) { + bBind = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; + } + CXFA_Occur nodeOccur(GetOccurNode()); + int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); + if (iIndex < 0 || iIndex > iCount) { + ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); + return; + } + int32_t iMax = nodeOccur.GetMax(); + if (iMax >= 0 && iCount >= iMax) { + ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); + return; + } + CXFA_Node* pNewInstance = + XFA_ScriptInstanceManager_CreateInstance(this, bBind); + XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, + TRUE); + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->RunNodeInitialize(pNewInstance); + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (!pLayoutPro) { + return; + } + pLayoutPro->AddChangedContainer( + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); +} +int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) { + CXFA_Occur nodeOccur(GetOccurNode()); + int32_t iMax = nodeOccur.GetMax(); + int32_t iMin = nodeOccur.GetMin(); + if (iDesired < iMin) { + ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"min"); + return 1; + } + if ((iMax >= 0) && (iDesired > iMax)) { + ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); + return 2; + } + int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); + if (iDesired == iCount) { + return 0; + } + if (iDesired < iCount) { + CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name); + CFX_WideString wsInstanceName = wsInstManagerName.IsEmpty() + ? wsInstManagerName + : wsInstManagerName.Mid(1); + FX_DWORD dInstanceNameHash = + wsInstanceName.IsEmpty() ? 0 : FX_HashCode_String_GetW( + wsInstanceName, + wsInstanceName.GetLength()); + CXFA_Node* pPrevSibling = + (iDesired == 0) ? this + : XFA_ScriptInstanceManager_GetItem(this, iDesired - 1); + while (iCount > iDesired) { + CXFA_Node* pRemoveInstance = + pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); + if (pRemoveInstance->GetClassID() != XFA_ELEMENT_Subform && + pRemoveInstance->GetClassID() != XFA_ELEMENT_SubformSet) { + continue; + } + if (pRemoveInstance->GetClassID() == XFA_ELEMENT_InstanceManager) { + FXSYS_assert(FALSE); + break; + } + if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { + XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); + iCount--; + } + } + } else if (iDesired > iCount) { + while (iCount < iDesired) { + CXFA_Node* pNewInstance = + XFA_ScriptInstanceManager_CreateInstance(this, TRUE); + XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, + FALSE); + iCount++; + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return 0; + } + pNotify->RunNodeInitialize(pNewInstance); + } + } + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} +int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { + int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); + if (iFrom > iCount || iTo > iCount - 1) { + ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); + return 1; + } + if (iFrom < 0 || iTo < 0 || iFrom == iTo) { + return 0; + } + CXFA_Node* pMoveInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); + XFA_ScriptInstanceManager_RemoveItem(this, pMoveInstance, FALSE); + XFA_ScriptInstanceManager_InsertItem(this, pMoveInstance, iTo, iCount - 1, + TRUE); + CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} +void CXFA_Node::Script_Occur_Max(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_Occur occur(this); + if (bSetting) { + int32_t iMax = FXJSE_Value_ToInteger(hValue); + occur.SetMax(iMax); + } else { + FXJSE_Value_SetInteger(hValue, occur.GetMax()); + } +} +void CXFA_Node::Script_Occur_Min(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + CXFA_Occur occur(this); + if (bSetting) { + int32_t iMin = FXJSE_Value_ToInteger(hValue); + occur.SetMin(iMin); + } else { + FXJSE_Value_SetInteger(hValue, occur.GetMin()); + } +} +void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if ((argc == 0) || (argc == 1)) { + FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); + } +} +void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + if (pDataNode) { + CXFA_NodeArray formItems; + CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); + pFormNodes->SetArrayNodeList(formItems); + FXJSE_Value_SetObject( + pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, + m_pDocument->GetScriptContext()->GetJseNormalClass()); + } else { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); + } +} +void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + m_pDocument->DoDataRemerge(TRUE); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); + } +} +void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execInitialize"); + } +} +void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { + CXFA_EventParam* pEventParam = + m_pDocument->GetScriptContext()->GetEventParam(); + if (pEventParam->m_eType == XFA_EVENT_Calculate || + pEventParam->m_eType == XFA_EVENT_InitCalculate) { + return; + } + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + const bool bScriptFlags = pArguments->GetInt32(0) != 0; + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bScriptFlags) { + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); + } else { + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); + } +} +void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execCalculate"); + } +} +void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); + } else { + int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); + FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), + ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"execValidate"); + } +} +void CXFA_Node::Script_Form_Checksum(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + CFX_ByteString bsChecksum; + FXJSE_Value_ToUTF8String(hValue, bsChecksum); + SetAttribute(XFA_ATTRIBUTE_Checksum, + CFX_WideString::FromUTF8(bsChecksum, bsChecksum.GetLength())); + } else { + CFX_WideString wsChecksum; + GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); + FXJSE_Value_SetUTF8String( + hValue, FX_UTF8Encode(wsChecksum, wsChecksum.GetLength())); + } +} +void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); + CFX_WideString wsAttributeValue; + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { + ((IFDE_XMLElement*)pXMLNode) + ->GetString(CFX_WideString::FromUTF8(bsAttributeName, + bsAttributeName.GetLength()), + wsAttributeValue); + } + FXJSE_Value_SetUTF8String( + pArguments->GetReturnValue(), + FX_UTF8Encode(wsAttributeValue, wsAttributeValue.GetLength())); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"getAttribute"); + } +} +void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 2) { + CFX_ByteString bsValue = pArguments->GetUTF8String(0); + CFX_ByteString bsName = pArguments->GetUTF8String(1); + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { + ((IFDE_XMLElement*)pXMLNode) + ->SetString(CFX_WideString::FromUTF8(bsName, bsName.GetLength()), + CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); + } + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"setAttribute"); + } +} +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()); + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + if (pXMLElement->HasAttribute(wsName)) { + pXMLElement->RemoveAttribute(wsName); + } + } + FXJSE_Value_SetNull(pArguments->GetReturnValue()); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"removeAttribute"); + } +} +void CXFA_Node::Script_Packet_Content(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + CFX_ByteString bsNewContent; + FXJSE_Value_ToUTF8String(hValue, bsNewContent); + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + pXMLElement->SetTextData( + CFX_WideString::FromUTF8(bsNewContent, bsNewContent.GetLength())); + } + } else { + CFX_WideString wsTextData; + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + pXMLElement->GetTextData(wsTextData); + } + FXJSE_Value_SetUTF8String( + hValue, FX_UTF8Encode(wsTextData, wsTextData.GetLength())); + } +} +void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); + } +} +void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancelBatch"); + } +} +void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"first"); + } +} +void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"updateBatch"); + } +} +void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"previous"); + } +} +void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isBOF"); + } +} +void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isEOF"); + } +} +void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancel"); + } +} +void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"update"); + } +} +void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"open"); + } +} +void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"delete"); + } +} +void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addNew"); + } +} +void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"requery"); + } +} +void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resync"); + } +} +void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"close"); + } +} +void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"last"); + } +} +void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 0) { + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"hasDataChanged"); + } +} +void CXFA_Node::Script_Source_Db(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Xfa_This(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); + FXSYS_assert(pThis); + FXJSE_Value_Set(hValue, + m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); + } +} +void CXFA_Node::Script_Handler_Version(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_SubmitFormat_Mode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Extras_Type(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CXFA_Node::Script_Script_Stateless(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(FX_WSTRC(L"0"))); +} +void CXFA_Node::Script_Encrypt_Format(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +enum XFA_KEYTYPE { + XFA_KEYTYPE_Custom, + XFA_KEYTYPE_Element, +}; +void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { + FX_DWORD dwKey = FX_HashCode_String_GetW(wsKey.GetPtr(), wsKey.GetLength()); + return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); +} +void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) { + return (void*)(uintptr_t)((eElement << 16) | (eAttribute << 8) | + XFA_KEYTYPE_Element); +} +FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + return HasMapModuleKey(pKey, bCanInherit); +} +FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, + const CFX_WideStringC& wsValue, + FX_BOOL bNotify) { + const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); + if (pAttr == NULL) { + return FALSE; + } + XFA_ATTRIBUTETYPE eType = pAttr->eType; + if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { + const XFA_NOTSUREATTRIBUTE* pNotsure = + XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); + eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; + } + switch (eType) { + case XFA_ATTRIBUTETYPE_Enum: { + const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue); + return SetEnum(pAttr->eName, + pEnum ? pEnum->eName + : (XFA_ATTRIBUTEENUM)(intptr_t)(pAttr->pDefValue), + bNotify); + } break; + case XFA_ATTRIBUTETYPE_Cdata: + return SetCData(pAttr->eName, 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.GetPtr(), wsValue.GetLength())), + bNotify); + case XFA_ATTRIBUTETYPE_Measure: + return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); + default: + break; + } + return FALSE; +} +FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, + CFX_WideString& wsValue, + FX_BOOL bUseDefault) { + const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); + if (pAttr == NULL) { + return FALSE; + } + XFA_ATTRIBUTETYPE eType = pAttr->eType; + if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { + const XFA_NOTSUREATTRIBUTE* pNotsure = + XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); + eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; + } + switch (eType) { + case XFA_ATTRIBUTETYPE_Enum: { + XFA_ATTRIBUTEENUM eValue; + if (!TryEnum(pAttr->eName, eValue, bUseDefault)) { + return FALSE; + } + wsValue = XFA_GetAttributeEnumByID(eValue)->pName; + return TRUE; + } break; + case XFA_ATTRIBUTETYPE_Cdata: { + CFX_WideStringC wsValueC; + if (!TryCData(pAttr->eName, wsValueC, bUseDefault)) { + return FALSE; + } + wsValue = wsValueC; + return TRUE; + } break; + case XFA_ATTRIBUTETYPE_Boolean: { + FX_BOOL bValue; + if (!TryBoolean(pAttr->eName, bValue, bUseDefault)) { + return FALSE; + } + wsValue = bValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0"); + return TRUE; + } break; + case XFA_ATTRIBUTETYPE_Integer: { + int32_t iValue; + if (!TryInteger(pAttr->eName, iValue, bUseDefault)) { + return FALSE; + } + wsValue.Format(L"%d", iValue); + return TRUE; + } break; + case XFA_ATTRIBUTETYPE_Measure: { + CXFA_Measurement mValue; + if (!TryMeasure(pAttr->eName, mValue, bUseDefault)) { + return FALSE; + } + mValue.ToString(wsValue); + return TRUE; + } break; + default: + break; + } + return FALSE; +} +FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, + const CFX_WideStringC& wsValue, + FX_BOOL bNotify) { + const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); + if (pAttributeInfo) { + return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); + } + void* pKey = XFA_GetMapKey_Custom(wsAttr); + SetMapModuleString(pKey, wsValue); + return TRUE; +} +FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, + CFX_WideString& wsValue, + FX_BOOL bUseDefault) { + const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr); + if (pAttributeInfo) { + return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault); + } + void* pKey = XFA_GetMapKey_Custom(wsAttr); + CFX_WideStringC wsValueC; + if (GetMapModuleString(pKey, wsValueC)) { + wsValue = wsValueC; + } + return TRUE; +} +FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { + void* pKey = XFA_GetMapKey_Custom(wsAttr); + RemoveMapModuleKey(pKey); + return TRUE; +} +FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, + FX_BOOL& bValue, + FX_BOOL bUseDefault) { + void* pValue = NULL; + if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) { + return FALSE; + } + bValue = (FX_BOOL)(uintptr_t)pValue; + return TRUE; +} +FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, + int32_t& iValue, + FX_BOOL bUseDefault) { + void* pValue = NULL; + if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) { + return FALSE; + } + iValue = (int32_t)(uintptr_t)pValue; + return TRUE; +} +FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTEENUM& eValue, + FX_BOOL bUseDefault) { + void* pValue = NULL; + if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) { + return FALSE; + } + eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; + return TRUE; +} +FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement mValue, + FX_BOOL bNotify) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + OnChanging(eAttr, &mValue, bNotify); + SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); + OnChanged(eAttr, &mValue, bNotify); + return TRUE; +} +FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement& mValue, + FX_BOOL bUseDefault) const { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + void* pValue; + int32_t iBytes; + if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { + FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); + return TRUE; + } + if (bUseDefault && + XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, + XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { + FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); + return TRUE; + } + return FALSE; +} + +CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { + CXFA_Measurement mValue; + return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); +} + +FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, + const CFX_WideString& wsValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + OnChanging(eAttr, (void*)(const FX_WCHAR*)wsValue, bNotify); + if (eAttr == XFA_ATTRIBUTE_Value) { + CFX_WideString* pClone = new CFX_WideString(wsValue); + SetUserData(pKey, pClone, &deleteWideStringCallBack); + } else { + SetMapModuleString(pKey, wsValue); + 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()) { + ((IFDE_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; + } + } + } + if (bDeleteChildren) { + ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); + } + ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsValue); + } + break; + case FDE_XMLNODE_Text: + ((IFDE_XMLText*)m_pXMLNode)->SetText(wsValue); + break; + default: + FXSYS_assert(0); + } + return TRUE; + } + 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; + } + ((IFDE_XMLElement*)m_pXMLNode)->SetString(wsAttrName, wsValue); + } + } + return TRUE; +} +FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, + const CFX_WideString& wsXMLValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); + OnChanging(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify); + CFX_WideString* pClone = new CFX_WideString(wsValue); + SetUserData(pKey, pClone, &deleteWideStringCallBack); + OnChanged(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify, + bScriptModify); + if (IsNeedSavingXMLNode()) { + FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); + switch (eXMLType) { + case FDE_XMLNODE_Element: + if (IsAttributeInXML()) { + ((IFDE_XMLElement*)m_pXMLNode) + ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); + } 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) { + ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); + } + ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsXMLValue); + } + break; + case FDE_XMLNODE_Text: + ((IFDE_XMLText*)m_pXMLNode)->SetText(wsXMLValue); + break; + default: + FXSYS_assert(0); + } + } + return TRUE; +} +FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideString& wsValue, + FX_BOOL bUseDefault, + FX_BOOL bProto) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + if (eAttr == XFA_ATTRIBUTE_Value) { + CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); + if (pStr) { + wsValue = *pStr; + return TRUE; + } + } else { + CFX_WideStringC wsValueC; + if (GetMapModuleString(pKey, wsValueC)) { + wsValue = wsValueC; + return TRUE; + } + } + if (!bUseDefault) { + return FALSE; + } + void* pValue = NULL; + if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, + XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { + wsValue = (const FX_WCHAR*)pValue; + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideStringC& wsValue, + FX_BOOL bUseDefault, + FX_BOOL bProto) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + if (eAttr == XFA_ATTRIBUTE_Value) { + CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); + if (pStr) { + wsValue = *pStr; + return TRUE; + } + } else { + if (GetMapModuleString(pKey, wsValue)) { + return TRUE; + } + } + if (!bUseDefault) { + return FALSE; + } + void* pValue = NULL; + if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, + XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { + wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + return SetUserData(pKey, pData, pCallbackInfo); +} +FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + pData = GetUserData(pKey); + return pData != NULL; +} +FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTETYPE eType, + void* pValue, + FX_BOOL bNotify) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + OnChanging(eAttr, pValue, bNotify); + SetMapModuleValue(pKey, pValue); + OnChanged(eAttr, pValue, bNotify); + if (IsNeedSavingXMLNode()) { + FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); + const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); + if (pInfo) { + switch (eType) { + case XFA_ATTRIBUTETYPE_Enum: + ((IFDE_XMLElement*)m_pXMLNode) + ->SetString( + pInfo->pName, + XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) + ->pName); + break; + case XFA_ATTRIBUTETYPE_Boolean: + ((IFDE_XMLElement*)m_pXMLNode) + ->SetString(pInfo->pName, + pValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0")); + break; + case XFA_ATTRIBUTETYPE_Integer: + ((IFDE_XMLElement*)m_pXMLNode) + ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); + break; + default: + FXSYS_assert(0); + } + } + } + return TRUE; +} +FX_BOOL CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTETYPE eType, + FX_BOOL bUseDefault, + void*& pValue) { + void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); + if (GetMapModuleValue(pKey, pValue)) { + return TRUE; + } + if (!bUseDefault) { + return FALSE; + } + return XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, eType, + m_ePacket); +} +static void XFA_DefaultFreeData(void* pData) {} +static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { + XFA_DefaultFreeData, NULL}; +FX_BOOL CXFA_Node::SetUserData(void* pKey, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { + SetMapModuleBuffer(pKey, &pData, sizeof(void*), + pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); + return TRUE; +} +FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { + int32_t iBytes = 0; + if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { + return FALSE; + } + return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); +} +FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, + const CFX_WideString& wsXMLValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify, + FX_BOOL bSyncData) { + CXFA_Node* pNode = NULL; + CXFA_Node* pBindNode = NULL; + switch (GetObjectType()) { + case XFA_OBJECTTYPE_ContainerNode: { + 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")); + pChildValue->SetScriptContent(wsContent, wsContent, bNotify, + bScriptModify, FALSE); + CXFA_Node* pBind = GetBindData(); + if (bSyncData && pBind) { + CFX_WideStringArray wsSaveTextArray; + int32_t iSize = 0; + if (!wsContent.IsEmpty()) { + int32_t iStart = 0; + int32_t iLength = wsContent.GetLength(); + int32_t iEnd = wsContent.Find(L'\n', iStart); + iEnd = (iEnd == -1) ? iLength : iEnd; + while (iEnd >= iStart) { + wsSaveTextArray.Add(wsContent.Mid(iStart, iEnd - iStart)); + iStart = iEnd + 1; + if (iStart >= iLength) { + break; + } + iEnd = wsContent.Find(L'\n', iStart); + if (iEnd < 0) { + wsSaveTextArray.Add(wsContent.Mid(iStart, iLength - iStart)); + } + } + iSize = wsSaveTextArray.GetSize(); + } + if (iSize == 0) { + while (CXFA_Node* pChildNode = + pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { + pBind->RemoveChild(pChildNode); + } + } else { + CXFA_NodeArray valueNodes; + int32_t iDatas = pBind->GetNodeList( + valueNodes, XFA_NODEFILTER_Children, XFA_ELEMENT_DataValue); + if (iDatas < iSize) { + int32_t iAddNodes = iSize - iDatas; + CXFA_Node* pValueNodes = NULL; + while (iAddNodes-- > 0) { + pValueNodes = + pBind->CreateSamePacketNode(XFA_ELEMENT_DataValue); + pValueNodes->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value")); + pValueNodes->CreateXMLMappingNode(); + pBind->InsertChild(pValueNodes); + } + pValueNodes = NULL; + } else if (iDatas > iSize) { + int32_t iDelNodes = iDatas - iSize; + while (iDelNodes-- > 0) { + pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild)); + } + } + int32_t i = 0; + for (CXFA_Node* pValueNode = + pBind->GetNodeItem(XFA_NODEITEM_FirstChild); + pValueNode; pValueNode = pValueNode->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + pValueNode->SetAttributeValue(wsSaveTextArray[i], + wsSaveTextArray[i], FALSE); + i++; + } + } + CXFA_NodeArray nodeArray; + pBind->GetBindItems(nodeArray); + for (int32_t i = 0; i < nodeArray.GetSize(); i++) { + CXFA_Node* pNode = nodeArray[i]; + if (pNode == this) { + continue; + } + pNode->SetScriptContent(wsContent, wsContent, bNotify, + bScriptModify, FALSE); + } + } + break; + } else if (GetClassID() == XFA_ELEMENT_ExclGroup) { + pNode = this; + } else { + CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); + CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); + FXSYS_assert(pChildValue); + pChildValue->SetScriptContent(wsContent, wsContent, bNotify, + bScriptModify, FALSE); + } + pBindNode = GetBindData(); + if (pBindNode && bSyncData) { + pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, + bScriptModify, FALSE); + CXFA_NodeArray nodeArray; + pBindNode->GetBindItems(nodeArray); + for (int32_t i = 0; i < nodeArray.GetSize(); i++) { + CXFA_Node* pNode = nodeArray[i]; + if (pNode == this) { + continue; + } + pNode->SetScriptContent(wsContent, wsContent, bNotify, TRUE, FALSE); + } + } + pBindNode = NULL; + break; + } + case XFA_OBJECTTYPE_ContentNode: { + CFX_WideString wsContentType; + if (GetClassID() == XFA_ELEMENT_ExData) { + GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + wsContentType = FX_WSTRC(L""); + SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType); + } + } + CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pContentRawDataNode) { + pContentRawDataNode = + CreateSamePacketNode((wsContentType.Equal(FX_WSTRC(L"text/xml"))) + ? XFA_ELEMENT_Sharpxml + : XFA_ELEMENT_Sharptext); + InsertChild(pContentRawDataNode); + } + return pContentRawDataNode->SetScriptContent( + wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); + } break; + case XFA_OBJECTTYPE_NodeC: + case XFA_OBJECTTYPE_TextNode: + pNode = this; + break; + case XFA_OBJECTTYPE_NodeV: + pNode = this; + if (bSyncData && GetPacketID() == XFA_XDPPACKET_Form) { + CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); + if (pParent) { + pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); + } + if (pParent && pParent->GetClassID() == XFA_ELEMENT_Value) { + pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); + if (pParent && pParent->IsContainerNode()) { + pBindNode = pParent->GetBindData(); + if (pBindNode) { + pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, + bScriptModify, FALSE); + } + } + } + } + break; + default: + if (GetClassID() == XFA_ELEMENT_DataValue) { + pNode = this; + pBindNode = this; + } + break; + } + if (pNode) { + SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); + if (pBindNode && bSyncData) { + CXFA_NodeArray nodeArray; + pBindNode->GetBindItems(nodeArray); + for (int32_t i = 0; i < nodeArray.GetSize(); i++) { + CXFA_Node* pNode = nodeArray[i]; + pNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, + FALSE); + } + } + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, + const CFX_WideString& wsXMLValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify, + FX_BOOL bSyncData) { + return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, + bSyncData); +} +CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { + CFX_WideString wsContent; + return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); +} +CFX_WideString CXFA_Node::GetContent() { + return GetScriptContent(); +} +FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, + FX_BOOL bScriptModify, + FX_BOOL bProto) { + CXFA_Node* pNode = NULL; + switch (GetObjectType()) { + case XFA_OBJECTTYPE_ContainerNode: + if (GetClassID() == XFA_ELEMENT_ExclGroup) { + pNode = this; + } else { + CXFA_Node* pValue = GetChild(0, XFA_ELEMENT_Value); + if (!pValue) { + return FALSE; + } + CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildValue && XFA_FieldIsMultiListBox(this)) { + pChildValue->SetAttribute(XFA_ATTRIBUTE_ContentType, + FX_WSTRC(L"text/xml")); + } + return pChildValue + ? pChildValue->TryContent(wsContent, bScriptModify, bProto) + : FALSE; + } + break; + case XFA_OBJECTTYPE_ContentNode: { + CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pContentRawDataNode) { + XFA_ELEMENT element = XFA_ELEMENT_Sharptext; + if (GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideString wsContentType; + GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); + if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + element = XFA_ELEMENT_SharpxHTML; + } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + element = XFA_ELEMENT_Sharpxml; + } + } + pContentRawDataNode = CreateSamePacketNode(element); + InsertChild(pContentRawDataNode); + } + return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto); + } + case XFA_OBJECTTYPE_NodeC: + case XFA_OBJECTTYPE_NodeV: + case XFA_OBJECTTYPE_TextNode: + pNode = this; + default: + if (GetClassID() == XFA_ELEMENT_DataValue) { + pNode = this; + } + break; + } + if (pNode) { + if (bScriptModify) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (pScriptContext) { + m_pDocument->GetScriptContext()->AddNodesOfRunScript(this); + } + } + return TryCData(XFA_ATTRIBUTE_Value, wsContent, FALSE, bProto); + } + return FALSE; +} +CXFA_Node* CXFA_Node::GetModelNode() { + switch (GetPacketID()) { + case XFA_XDPPACKET_XDP: + return m_pDocument->GetRoot(); + case XFA_XDPPACKET_Config: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); + case XFA_XDPPACKET_Template: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); + case XFA_XDPPACKET_Form: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); + case XFA_XDPPACKET_Datasets: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); + case XFA_XDPPACKET_LocaleSet: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet)); + case XFA_XDPPACKET_ConnectionSet: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet)); + case XFA_XDPPACKET_SourceSet: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet)); + case XFA_XDPPACKET_Xdc: + return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc)); + default: + return this; + } +} +FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { + wsNamespace.Empty(); + if (GetObjectType() == XFA_OBJECTTYPE_ModelNode || + GetClassID() == XFA_ELEMENT_Packet) { + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { + return FALSE; + } + ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); + return TRUE; + } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { + IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + if (!pXMLNode) { + return FALSE; + } + if (pXMLNode->GetType() != FDE_XMLNODE_Element) { + return TRUE; + } + if (GetClassID() == XFA_ELEMENT_DataValue && + GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { + return XFA_FDEExtension_ResolveNamespaceQualifier( + (IFDE_XMLElement*)pXMLNode, GetCData(XFA_ATTRIBUTE_QualifiedName), + wsNamespace); + } + ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); + return TRUE; + } else { + CXFA_Node* pModelNode = GetModelNode(); + return pModelNode->TryNamespace(wsNamespace); + } +} +CXFA_Node* CXFA_Node::GetProperty(int32_t index, + XFA_ELEMENT eProperty, + FX_BOOL bCreateProperty) { + XFA_ELEMENT eElement = GetClassID(); + FX_DWORD dwPacket = GetPacketID(); + const XFA_PROPERTY* pProperty = + XFA_GetPropertyOfElement(eElement, eProperty, dwPacket); + if (pProperty == NULL || index >= pProperty->uOccur) { + return NULL; + } + CXFA_Node* pNode = m_pChild; + int32_t iCount = 0; + for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetClassID() == eProperty) { + iCount++; + if (iCount > index) { + return pNode; + } + } + } + if (!bCreateProperty) { + return NULL; + } + if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { + pNode = m_pChild; + for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + const XFA_PROPERTY* pExistProperty = + XFA_GetPropertyOfElement(eElement, pNode->GetClassID(), dwPacket); + if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { + return NULL; + } + } + } + IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); + const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); + CXFA_Node* pNewNode; + for (; iCount <= index; iCount++) { + pNewNode = pFactory->CreateNode(pPacket, eProperty); + if (!pNewNode) { + return NULL; + } + InsertChild(pNewNode, nullptr); + pNewNode->SetFlag(XFA_NODEFLAG_Initialized); + } + return pNewNode; +} +int32_t CXFA_Node::CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild) { + CXFA_Node* pNode = m_pChild; + int32_t iCount = 0; + for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { + if (bOnlyChild) { + const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( + GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); + if (pProperty) { + continue; + } + } + iCount++; + } + } + return iCount; +} +CXFA_Node* CXFA_Node::GetChild(int32_t index, + XFA_ELEMENT eElement, + FX_BOOL bOnlyChild) { + FXSYS_assert(index > -1); + CXFA_Node* pNode = m_pChild; + int32_t iCount = 0; + for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { + if (bOnlyChild) { + const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( + GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); + if (pProperty) { + continue; + } + } + iCount++; + if (iCount > index) { + return pNode; + } + } + } + return NULL; +} +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); + + if (m_pChild == NULL || index == 0) { + if (index > 0) { + return -1; + } + pNode->m_pNext = m_pChild; + m_pChild = pNode; + index = 0; + } else if (index < 0) { + m_pLastChild->m_pNext = pNode; + } else { + CXFA_Node* pPrev = m_pChild; + int32_t iCount = 0; + while (++iCount != index && pPrev->m_pNext) { + pPrev = pPrev->m_pNext; + } + if (index > 0 && index != iCount) { + return -1; + } + pNode->m_pNext = pPrev->m_pNext; + pPrev->m_pNext = pNode; + index = iCount; + } + if (pNode->m_pNext == NULL) { + m_pLastChild = pNode; + } + ASSERT(m_pLastChild); + ASSERT(m_pLastChild->m_pNext == NULL); + pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); + } + if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { + FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); + m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); + pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); + } + 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); + return FALSE; + } + FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode); + if (!bWasPurgeNode) + FXSYS_assert(false); + + int32_t nIndex = -1; + pNode->m_pParent = this; + if (m_pChild == NULL || pBeforeNode == m_pChild) { + pNode->m_pNext = m_pChild; + m_pChild = pNode; + nIndex = 0; + } else if (!pBeforeNode) { + pNode->m_pNext = m_pLastChild->m_pNext; + m_pLastChild->m_pNext = pNode; + } else { + nIndex = 1; + CXFA_Node* pPrev = m_pChild; + while (pPrev->m_pNext != pBeforeNode) { + pPrev = pPrev->m_pNext; + nIndex++; + } + pNode->m_pNext = pPrev->m_pNext; + pPrev->m_pNext = pNode; + } + if (pNode->m_pNext == NULL) { + m_pLastChild = pNode; + } + ASSERT(m_pLastChild); + ASSERT(m_pLastChild->m_pNext == NULL); + pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); + } + if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { + FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); + m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); + pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); + } + return TRUE; +} +CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { + if (!m_pParent) { + return NULL; + } + for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; + pSibling = pSibling->m_pNext) { + if (pSibling->m_pNext == this) { + return pSibling; + } + } + return NULL; +} +FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) { + if (pNode == NULL || pNode->m_pParent != this) { + FXSYS_assert(FALSE); + return FALSE; + } + if (m_pChild == pNode) { + m_pChild = pNode->m_pNext; + if (m_pLastChild == pNode) { + m_pLastChild = pNode->m_pNext; + } + pNode->m_pNext = NULL; + pNode->m_pParent = NULL; + } else { + CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); + pPrev->m_pNext = pNode->m_pNext; + if (m_pLastChild == pNode) { + m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; + } + pNode->m_pNext = NULL; + pNode->m_pParent = NULL; + } + ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL); + OnRemoved(this, pNode, bNotify); + pNode->SetFlag(XFA_NODEFLAG_HasRemoved); + 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); + if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)(pNode->m_pXMLNode); + CFX_WideStringC wsAttributeName = + pNode->GetCData(XFA_ATTRIBUTE_QualifiedName); + pXMLElement->RemoveAttribute(wsAttributeName.GetPtr()); + } + CFX_WideString wsName; + pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); + IFDE_XMLElement* pNewXMLElement = IFDE_XMLElement::Create(wsName); + CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); + if (!wsValue.IsEmpty()) { + pNewXMLElement->SetTextData(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); + } + return TRUE; +} +CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { + return GetFirstChildByName( + wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), + wsName.GetLength())); +} +CXFA_Node* CXFA_Node::GetFirstChildByName(FX_DWORD dwNameHash) const { + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetNameHash() == dwNameHash) { + return pNode; + } + } + return NULL; +} +CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_ELEMENT eElement) const { + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetClassID() == eElement) { + return pNode; + } + } + return NULL; +} +CXFA_Node* CXFA_Node::GetNextSameNameSibling(FX_DWORD dwNameHash) const { + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetNameHash() == dwNameHash) { + return pNode; + } + } + return NULL; +} +CXFA_Node* CXFA_Node::GetNextSameNameSibling( + const CFX_WideStringC& wsNodeName) const { + return GetNextSameNameSibling( + wsNodeName.IsEmpty() ? 0 + : FX_HashCode_String_GetW(wsNodeName.GetPtr(), + wsNodeName.GetLength())); +} +CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const { + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetClassID() == eElement) { + return pNode; + } + } + return NULL; +} +int32_t CXFA_Node::GetNodeSameNameIndex() const { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return -1; + } + return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); +} +int32_t CXFA_Node::GetNodeSameClassIndex() const { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return -1; + } + return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); +} +void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + pScriptContext->GetSomExpression(this, wsSOMExpression); +} +CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { + CXFA_Node* pInstanceMgr = NULL; + if (m_ePacket == XFA_XDPPACKET_Form) { + CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); + if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_Area) { + return pInstanceMgr; + } + for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; + pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + XFA_ELEMENT eType = pNode->GetClassID(); + if ((eType == XFA_ELEMENT_Subform || eType == XFA_ELEMENT_SubformSet) && + pNode->m_dwNameHash != m_dwNameHash) { + break; + } + if (eType == XFA_ELEMENT_InstanceManager) { + CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); + CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name); + if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' && + wsInstName.Mid(1) == wsName) { + pInstanceMgr = pNode; + } + break; + } + } + } + return pInstanceMgr; +} +CXFA_Node* CXFA_Node::GetOccurNode() { + return GetFirstChildByClass(XFA_ELEMENT_Occur); +} +FX_BOOL CXFA_Node::HasFlag(FX_DWORD dwFlag) const { + if (m_uFlags & dwFlag) { + return TRUE; + } + switch (dwFlag) { + case XFA_NODEFLAG_HasRemoved: + return m_pParent && m_pParent->HasFlag(dwFlag); + default: + break; + } + return FALSE; +} +void CXFA_Node::SetFlag(FX_DWORD dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { + if (bOn) { + switch (dwFlag) { + case XFA_NODEFLAG_Initialized: + if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready); + } + } + break; + default: + break; + } + m_uFlags |= dwFlag; + } else { + 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) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + pNotify->OnNodeEvent(pParent, XFA_NODEEVENT_ChildRemoved, pRemoved); + } + } +} +void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, + void* pNewValue, + FX_BOOL bNotify) { + if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (pNotify) { + pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanging, + (void*)(uintptr_t)eAttr, pNewValue); + } + } +} +void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, + void* pNewValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify) { + if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { + Script_Attribute_SendAttributeChangeMessage((void*)(uintptr_t)eAttr, + pNewValue, bScriptModify); + } +} +int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, + XFA_ELEMENT eElementType) { + int32_t iRet = XFA_EVENTERROR_NotExist; + const XFA_ExecEventParaInfo* eventParaInfo = + GetEventParaInfoByName(wsEventName); + if (eventParaInfo) { + uint32_t validFlags = eventParaInfo->m_validFlags; + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return iRet; + } + if (validFlags == 1) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType); + } else if (validFlags == 2) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } else if (validFlags == 3) { + if (eElementType == XFA_ELEMENT_Subform) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + } else if (validFlags == 4) { + if (eElementType == XFA_ELEMENT_ExclGroup || + eElementType == XFA_ELEMENT_Field) { + CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); + if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + } else if (validFlags == 5) { + if (eElementType == XFA_ELEMENT_Field) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + } else if (validFlags == 6) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (pWidgetData) { + CXFA_Node* pUINode = pWidgetData->GetUIChild(); + if (pUINode->m_eNodeClass == XFA_ELEMENT_Signature) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + } + } else if (validFlags == 7) { + CXFA_WidgetData* pWidgetData = GetWidgetData(); + if (pWidgetData) { + CXFA_Node* pUINode = pWidgetData->GetUIChild(); + if ((pUINode->m_eNodeClass == XFA_ELEMENT_ChoiceList) && + (!pWidgetData->IsListBox())) { + iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, + FALSE, FALSE); + } + } + } + } + return iRet; +} +void CXFA_Node::UpdateNameHash() { + const XFA_NOTSUREATTRIBUTE* pNotsure = + XFA_GetNotsureAttribute(GetClassID(), XFA_ATTRIBUTE_Name); + if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { + CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); + m_dwNameHash = + wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), + wsName.GetLength()); + } 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.GetPtr(), + wsName.GetLength()); + } +} +IFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { + if (!m_pXMLNode) { + CFX_WideStringC wsTag = GetCData(XFA_ATTRIBUTE_Name); + m_pXMLNode = IFDE_XMLElement::Create(wsTag); + SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); + } + return m_pXMLNode; +} +FX_BOOL CXFA_Node::IsNeedSavingXMLNode() { + return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets || + GetClassID() == XFA_ELEMENT_Xfa); +} + +XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() { + if (!m_pMapModuleData) + m_pMapModuleData = new XFA_MAPMODULEDATA; + return m_pMapModuleData; +} + +XFA_MAPMODULEDATA* CXFA_Node::GetMapModuleData() const { + return m_pMapModuleData; +} + +void CXFA_Node::SetMapModuleValue(void* pKey, void* pValue) { + XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); + pModule->m_ValueMap.SetAt(pKey, pValue); +} + +FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) { + CXFA_Node* pNode = this; + while (pNode) { + XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); + if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { + return TRUE; + } + pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets + ? pNode->GetTemplateNode() + : NULL; + } + return FALSE; +} +void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { + SetMapModuleBuffer(pKey, (void*)wsValue.GetPtr(), + wsValue.GetLength() * sizeof(FX_WCHAR)); +} +FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { + void* pValue; + int32_t iBytes; + if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { + return FALSE; + } + wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); + return TRUE; +} +void CXFA_Node::SetMapModuleBuffer( + void* pKey, + void* pValue, + int32_t iBytes, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { + XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); + XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; + if (pBuffer == NULL) { + pBuffer = + (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); + } else if (pBuffer->iBytes != iBytes) { + if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, + sizeof(XFA_MAPDATABLOCK) + iBytes); + } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + if (pBuffer == NULL) { + return; + } + pBuffer->pCallbackInfo = pCallbackInfo; + pBuffer->iBytes = iBytes; + FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); +} +FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, + void*& pValue, + int32_t& iBytes, + FX_BOOL bProtoAlso) const { + XFA_MAPDATABLOCK* pBuffer = NULL; + const CXFA_Node* pNode = this; + while (pNode) { + XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); + if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { + break; + } + pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) + ? pNode->GetTemplateNode() + : NULL; + } + if (pBuffer == NULL) { + return FALSE; + } + pValue = pBuffer->GetData(); + iBytes = pBuffer->iBytes; + return TRUE; +} +FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { + CXFA_Node* pNode = this; + while (pNode) { + void* pVal; + XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); + if (pModule && + (pModule->m_ValueMap.Lookup(pKey, pVal) || + pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { + return TRUE; + } + pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) + ? pNode->GetTemplateNode() + : NULL; + } + return FALSE; +} +void CXFA_Node::RemoveMapModuleKey(void* pKey) { + XFA_MAPMODULEDATA* pModule = GetMapModuleData(); + if (!pModule) + return; + + if (pKey) { + XFA_MAPDATABLOCK* pBuffer = NULL; + pModule->m_BufferMap.Lookup(pKey, pBuffer); + if (pBuffer) { + if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + FX_Free(pBuffer); + } + pModule->m_BufferMap.RemoveKey(pKey); + pModule->m_ValueMap.RemoveKey(pKey); + } else { + XFA_MAPDATABLOCK* pBuffer; + FX_POSITION posBuffer = pModule->m_BufferMap.GetStartPosition(); + while (posBuffer) { + pModule->m_BufferMap.GetNextAssoc(posBuffer, pKey, pBuffer); + if (pBuffer) { + if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + FX_Free(pBuffer); + } + } + pModule->m_BufferMap.RemoveAll(); + pModule->m_ValueMap.RemoveAll(); + delete pModule; + } +} +void CXFA_Node::MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr) { + XFA_MAPMODULEDATA* pDstModuleData = + static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData(); + XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); + if (!pSrcModuleData) { + return; + } + FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition(); + while (psValue) { + void* pKey; + void* pValue; + pSrcModuleData->m_ValueMap.GetNextAssoc(psValue, pKey, pValue); + if (bUseSrcAttr || !pDstModuleData->m_ValueMap.GetValueAt(pKey)) { + pDstModuleData->m_ValueMap.SetAt(pKey, pValue); + } + } + FX_POSITION psBuffer = pSrcModuleData->m_BufferMap.GetStartPosition(); + while (psBuffer) { + void* pKey; + XFA_MAPDATABLOCK* pSrcBuffer; + pSrcModuleData->m_BufferMap.GetNextAssoc(psBuffer, pKey, pSrcBuffer); + XFA_MAPDATABLOCK*& pBuffer = pDstModuleData->m_BufferMap[pKey]; + if (pBuffer && !bUseSrcAttr) { + continue; + } + if (pSrcBuffer->pCallbackInfo && pSrcBuffer->pCallbackInfo->pFree && + !pSrcBuffer->pCallbackInfo->pCopy) { + if (pBuffer) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + pDstModuleData->m_BufferMap.RemoveKey(pKey); + } + continue; + } + if (pBuffer == NULL) { + pBuffer = (XFA_MAPDATABLOCK*)FX_Alloc( + uint8_t, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); + } else if (pBuffer->iBytes != pSrcBuffer->iBytes) { + if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc( + uint8_t, pBuffer, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); + } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { + pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); + } + if (pBuffer == NULL) { + continue; + } + pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; + pBuffer->iBytes = pSrcBuffer->iBytes; + FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); + if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { + pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); + } + } +} +void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { + if (!pDstModule) { + return; + } + FX_BOOL bNeedMove = TRUE; + if (!pKey) { + bNeedMove = FALSE; + } + if (pDstModule->GetClassID() != GetClassID()) { + bNeedMove = FALSE; + } + XFA_MAPMODULEDATA* pSrcModuleData = NULL; + XFA_MAPMODULEDATA* pDstModuleData = NULL; + if (bNeedMove) { + pSrcModuleData = GetMapModuleData(); + if (!pSrcModuleData) { + bNeedMove = FALSE; + } + pDstModuleData = pDstModule->CreateMapModuleData(); + } + if (bNeedMove) { + void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey); + if (pBufferBlockData) { + pSrcModuleData->m_BufferMap.RemoveKey(pKey); + pDstModuleData->m_BufferMap.RemoveKey(pKey); + pDstModuleData->m_BufferMap.SetAt(pKey, + (XFA_MAPDATABLOCK*)pBufferBlockData); + } + } + if (pDstModule->GetObjectType() == XFA_OBJECTTYPE_NodeV) { + CFX_WideString wsValue = pDstModule->GetScriptContent(FALSE); + CFX_WideString wsFormatValue(wsValue); + CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData(); + if (pWidgetData) { + pWidgetData->GetFormatDataValue(wsValue, wsFormatValue); + } + pDstModule->SetScriptContent(wsValue, wsFormatValue, TRUE, TRUE); + } +} +void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule, + CXFA_Node* pDstModule, + void* pKey, + FX_BOOL bRecursive) { + if (!pSrcModule || !pDstModule || !pKey) { + return; + } + if (bRecursive) { + CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pSrcChild && pDstChild; + pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), + pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); + } + } + pSrcModule->MoveBufferMapData(pDstModule, pKey); +} +CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) + : CXFA_Object(pDocument, XFA_OBJECTTYPE_NodeList) { + m_pDocument->GetScriptContext()->CacheList(this); +} +CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { + int32_t iCount = GetLength(); + FX_DWORD dwHashCode = + FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); + for (int32_t i = 0; i < iCount; i++) { + CXFA_Node* ret = Item(i); + if (dwHashCode == ret->GetNameHash()) { + return ret; + } + } + return NULL; +} +void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + if (pNode) { + Append(pNode); + } else { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"append"); + } +} +void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 2) { + CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1)); + if (pNewNode) { + Insert(pNewNode, pBeforeNode); + } else { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insert"); + } +} +void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + if (pNode) { + Remove(pNode); + } else { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove"); + } +} +void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + int32_t iIndex = pArguments->GetInt32(0); + if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) { + FXJSE_Value_Set( + pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex))); + } else { + ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); + } + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item"); + } +} +void CXFA_NodeList::Script_TreelistClass_NamedItem( + CFXJSE_Arguments* pArguments) { + int32_t argc = pArguments->GetLength(); + if (argc == 1) { + CFX_ByteString szName = pArguments->GetUTF8String(0); + CXFA_Node* pNode = + NamedItem(CFX_WideString::FromUTF8(szName, szName.GetLength())); + if (!pNode) { + return; + } + FXJSE_Value_Set(pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); + } else { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem"); + } +} +void CXFA_NodeList::Script_ListClass_Length(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!bSetting) { + FXJSE_Value_SetInteger(hValue, GetLength()); + } else { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + } +} +CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) + : CXFA_NodeList(pDocument) {} +void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { + if (srcArray.GetSize() > 0) { + m_array.Copy(srcArray); + } +} +int32_t CXFA_ArrayNodeList::GetLength() { + return m_array.GetSize(); +} +FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { + m_array.Add(pNode); + return TRUE; +} +FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, + CXFA_Node* pBeforeNode) { + if (pBeforeNode == NULL) { + m_array.Add(pNewNode); + } else { + int32_t iSize = m_array.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + if (m_array[i] == pBeforeNode) { + m_array.InsertAt(i, pNewNode); + break; + } + } + } + return TRUE; +} +FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { + int32_t iSize = m_array.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + if (m_array[i] == pNode) { + m_array.RemoveAt(i); + break; + } + } + return TRUE; +} +CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { + int32_t iSize = m_array.GetSize(); + if (iIndex >= 0 && iIndex < iSize) { + return m_array[iIndex]; + } + return NULL; +} +CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, + CXFA_Node* pAttachNode) + : CXFA_NodeList(pDocument) { + m_pAttachNode = pAttachNode; +} +int32_t CXFA_AttachNodeList::GetLength() { + return m_pAttachNode->CountChildren( + XFA_ELEMENT_UNKNOWN, m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); +} +FX_BOOL CXFA_AttachNodeList::Append(CXFA_Node* pNode) { + CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pParent) { + pParent->RemoveChild(pNode); + } + return m_pAttachNode->InsertChild(pNode); +} +FX_BOOL CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, + CXFA_Node* pBeforeNode) { + CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); + if (pParent) { + pParent->RemoveChild(pNewNode); + } + return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); +} +FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { + return m_pAttachNode->RemoveChild(pNode); +} +CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { + return m_pAttachNode->GetChild( + iIndex, XFA_ELEMENT_UNKNOWN, + m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); +} diff --git a/xfa/fxfa/parser/xfa_objectacc_imp.cpp b/xfa/fxfa/parser/xfa_objectacc_imp.cpp new file mode 100644 index 0000000000..5bf368b517 --- /dev/null +++ b/xfa/fxfa/parser/xfa_objectacc_imp.cpp @@ -0,0 +1,3760 @@ +// 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/include/fxcrt/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" +#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" +#include "xfa/include/fxbarcode/BC_BarCode.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.GetPtr(); + 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; +} +FX_BOOL CXFA_Fill::SetPresence(int32_t iPresence) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); +} +FX_BOOL CXFA_Fill::SetFillType(int32_t iType) { + return FALSE; +} +FX_BOOL CXFA_Fill::SetPattern(int32_t iPattern, FX_ARGB foreColor) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern); + CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); + CFX_WideString wsColor; + int a, r, g, b; + ArgbDecode(foreColor, a, r, g, b); + wsColor.Format(L"%d,%d,%d", r, g, b); + pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); + return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iPattern); +} +FX_BOOL CXFA_Fill::SetStipple(int32_t iStipple, FX_ARGB stippleColor) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple); + CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); + CFX_WideString wsColor; + int a, r, g, b; + ArgbDecode(stippleColor, a, r, g, b); + wsColor.Format(L"%d,%d,%d", r, g, b); + pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); + return pNode->SetEnum(XFA_ATTRIBUTE_Rate, (XFA_ATTRIBUTEENUM)iStipple); +} +FX_BOOL CXFA_Fill::SetLinear(int32_t iLinear, FX_ARGB endColor) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear); + CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); + CFX_WideString wsColor; + int a, r, g, b; + ArgbDecode(endColor, a, r, g, b); + wsColor.Format(L"%d,%d,%d", r, g, b); + pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); + return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iLinear); +} +FX_BOOL CXFA_Fill::SetRadial(int32_t iRadial, FX_ARGB endColor) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial); + CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); + CFX_WideString wsColor; + int a, r, g, b; + ArgbDecode(endColor, a, r, g, b); + wsColor.Format(L"%d,%d,%d", r, g, b); + pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); + return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iRadial); +} +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); +} +FX_BOOL CXFA_Margin::SetLeftInset(FX_FLOAT fInset) { + return SetMeasure(XFA_ATTRIBUTE_LeftInset, fInset); +} +FX_BOOL CXFA_Margin::SetTopInset(FX_FLOAT fInset) { + return SetMeasure(XFA_ATTRIBUTE_TopInset, fInset); +} +FX_BOOL CXFA_Margin::SetRightInset(FX_FLOAT fInset) { + return SetMeasure(XFA_ATTRIBUTE_RightInset, fInset); +} +FX_BOOL CXFA_Margin::SetBottomInset(FX_FLOAT fInset) { + return SetMeasure(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::GetLineThroughPeriod() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; + m_pNode->TryEnum(XFA_ATTRIBUTE_LineThroughPeriod, eAttr); + return eAttr; +} +int32_t CXFA_Font::GetOverline() { + int32_t iValue = 0; + m_pNode->TryInteger(XFA_ATTRIBUTE_Overline, iValue); + return iValue; +} +int32_t CXFA_Font::GetOverlinePeriod() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; + m_pNode->TryEnum(XFA_ATTRIBUTE_OverlinePeriod, eAttr); + return eAttr; +} +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; +} +FX_BOOL CXFA_Font::IsUseKerning() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; + m_pNode->TryEnum(XFA_ATTRIBUTE_KerningMode, eAttr); + return eAttr == XFA_ATTRIBUTEENUM_Pair; +} +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; +} +FX_BOOL CXFA_Font::SetBaselineShift(FX_FLOAT fBaselineShift) { + CXFA_Measurement ms(fBaselineShift, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_BaselineShift, ms); +} +FX_BOOL CXFA_Font::SetHorizontalScale(FX_FLOAT fHorizontalScale) { + CFX_WideString wsValue; + wsValue.Format(L"%d", (int32_t)fHorizontalScale); + return m_pNode->SetCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue); +} +FX_BOOL CXFA_Font::SetVerticalScale(FX_FLOAT fVerticalScale) { + CFX_WideString wsValue; + wsValue.Format(L"%d", (int32_t)fVerticalScale); + return m_pNode->SetCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue); +} +FX_BOOL CXFA_Font::SetLetterSpacing(FX_FLOAT fLetterSpacing, XFA_UNIT eUnit) { + return FALSE; +} +FX_BOOL CXFA_Font::SetLineThrough(int32_t iLineThrough) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_LineThrough, iLineThrough); +} +FX_BOOL CXFA_Font::SetLineThroughPeriod(int32_t iLineThroughPeriod) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_LineThroughPeriod, + (XFA_ATTRIBUTEENUM)iLineThroughPeriod); +} +FX_BOOL CXFA_Font::SetOverline(int32_t iOverline) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_Overline, iOverline); +} +FX_BOOL CXFA_Font::SetOverlinePeriod(int32_t iOverlinePeriod) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_OverlinePeriod, + (XFA_ATTRIBUTEENUM)iOverlinePeriod); +} +FX_BOOL CXFA_Font::SetUnderline(int32_t iUnderline) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_Underline, iUnderline); +} +FX_BOOL CXFA_Font::SetUnderlinePeriod(int32_t iUnderlinePeriod) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_UnderlinePeriod, + (XFA_ATTRIBUTEENUM)iUnderlinePeriod); +} +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_Caption::GetPara() { + return CXFA_Para(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Para) : NULL); +} +FX_BOOL CXFA_Caption::SetPresence(int32_t iPresence) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); +} +FX_BOOL CXFA_Caption::SetPlacementType(int32_t iType) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Placement, (XFA_ATTRIBUTEENUM)iType); +} +FX_BOOL CXFA_Caption::SetReserve(FX_FLOAT fReserve) { + CXFA_Measurement ms(fReserve, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_Reserve, ms); +} +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); +} +int32_t CXFA_Para::GetOrphans() { + int32_t iValue = 0; + m_pNode->TryInteger(XFA_ATTRIBUTE_Orphans, iValue); + return iValue; +} +FX_FLOAT CXFA_Para::GetRadixOffset() { + CXFA_Measurement ms; + m_pNode->TryMeasure(XFA_ATTRIBUTE_RadixOffset, 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); +} +int32_t CXFA_Para::GetWidows() { + int32_t iValue = 0; + m_pNode->TryInteger(XFA_ATTRIBUTE_Widows, iValue); + return iValue; +} +FX_BOOL CXFA_Para::SetHorizontalAlign(int32_t iHorizontalAlign) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_HAlign, + (XFA_ATTRIBUTEENUM)iHorizontalAlign); +} +FX_BOOL CXFA_Para::SetVerticalAlign(int32_t iVerticalAlign) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_VAlign, + (XFA_ATTRIBUTEENUM)iVerticalAlign); +} +FX_BOOL CXFA_Para::SetLineHeight(FX_FLOAT fLineHeight) { + CXFA_Measurement ms; + return m_pNode->SetMeasure(XFA_ATTRIBUTE_LineHeight, ms); +} +FX_BOOL CXFA_Para::SetMarginLeft(FX_FLOAT fMarginLeft) { + CXFA_Measurement ms(fMarginLeft, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginLeft, ms); +} +FX_BOOL CXFA_Para::SetMarginRight(FX_FLOAT fMarginRight) { + CXFA_Measurement ms(fMarginRight, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginRight, ms); +} +FX_BOOL CXFA_Para::SetOrphans(int32_t iOrphans) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_Orphans, iOrphans); +} +FX_BOOL CXFA_Para::SetRadixOffset(FX_FLOAT fRadixOffset) { + CXFA_Measurement ms(fRadixOffset, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_RadixOffset, ms); +} +FX_BOOL CXFA_Para::SetSpaceAbove(FX_FLOAT fSpaceAbove) { + CXFA_Measurement ms(fSpaceAbove, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceAbove, ms); +} +FX_BOOL CXFA_Para::SetSpaceBelow(FX_FLOAT fSpaceBelow) { + CXFA_Measurement ms(fSpaceBelow, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceBelow, ms); +} +FX_BOOL CXFA_Para::SetTextIndent(FX_FLOAT fTextIndent) { + CXFA_Measurement ms(fTextIndent, XFA_UNIT_Pt); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_TextIndent, ms); +} +FX_BOOL CXFA_Para::SetWidows(int32_t iWidows) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_Widows, iWidows); +} +CXFA_Keep::CXFA_Keep(CXFA_Node* pNode, CXFA_Node* pParent) + : CXFA_Data(pNode), m_pParent(pParent) {} +int32_t CXFA_Keep::GetIntact() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; + switch (m_pParent->GetClassID()) { + case XFA_ELEMENT_Subform: { + XFA_ATTRIBUTEENUM eAttrSubForm; + m_pParent->TryEnum(XFA_ATTRIBUTE_Layout, eAttrSubForm); + if (eAttrSubForm == XFA_ATTRIBUTEENUM_Position || + eAttrSubForm == XFA_ATTRIBUTEENUM_Row) { + eAttr = XFA_ATTRIBUTEENUM_ContentArea; + } + } break; + case XFA_ELEMENT_Draw: + eAttr = XFA_ATTRIBUTEENUM_ContentArea; + break; + default: + break; + } + m_pNode->TryEnum(XFA_ATTRIBUTE_Intact, eAttr, FALSE); + return eAttr; +} +int32_t CXFA_Keep::GetNext() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; + m_pNode->TryEnum(XFA_ATTRIBUTE_Next, eAttr); + return eAttr; +} +int32_t CXFA_Keep::GetPrevious() { + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; + m_pNode->TryEnum(XFA_ATTRIBUTE_Previous, eAttr); + return eAttr; +} +FX_BOOL CXFA_Keep::SetIntact(int32_t iIntact) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Intact, (XFA_ATTRIBUTEENUM)iIntact); +} +FX_BOOL CXFA_Keep::SetNext(int32_t iNext) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Next, (XFA_ATTRIBUTEENUM)iNext); +} +FX_BOOL CXFA_Keep::SetPrevious(int32_t iPrevious) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Previous, (XFA_ATTRIBUTEENUM)iPrevious); +} +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); +} +int32_t CXFA_Event::GetExecuteRunAt() { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + return pNode->GetEnum(XFA_ATTRIBUTE_RunAt); +} +int32_t CXFA_Event::GetExecuteType() { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + return pNode->GetEnum(XFA_ATTRIBUTE_ExecuteType); +} +void CXFA_Event::GetExecuteConnection(CFX_WideString& wsConnection) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + CFX_WideStringC cData; + pNode->TryCData(XFA_ATTRIBUTE_Connection, cData); + wsConnection = cData; +} +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)); +} +int32_t CXFA_Event::GetSignDataOperation() { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); + return pNode->GetEnum(XFA_ATTRIBUTE_Operation); +} +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; + } +} +FX_BOOL CXFA_Event::SetActivity(int32_t iActivity) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Activity, (XFA_ATTRIBUTEENUM)iActivity); +} +FX_BOOL CXFA_Event::SetEventType(int32_t iEventType) { + return FALSE; +} +FX_BOOL CXFA_Event::SetExecuteRunAt(int32_t iExecuteRunAt) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + return pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iExecuteRunAt); +} +FX_BOOL CXFA_Event::SetExecuteType(int32_t iExecuteType) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + return pNode->SetEnum(XFA_ATTRIBUTE_ExecuteType, + (XFA_ATTRIBUTEENUM)iExecuteType); +} +FX_BOOL CXFA_Event::SetExecuteConnection(const CFX_WideString& wsConnection) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); + return pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection); +} +FX_BOOL CXFA_Event::SetSignDataOperation(int32_t iOperation) { + CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); + return pNode->SetEnum(XFA_ATTRIBUTE_Operation, (XFA_ATTRIBUTEENUM)iOperation); +} +FX_BOOL CXFA_Event::SetSignDataTarget(const CFX_WideString& wsTarget) { + if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) { + return pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); + } + return FALSE; +} +CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {} +void CXFA_Script::GetBinding(CFX_WideString& wsBinding) { + CFX_WideStringC cData; + m_pNode->TryCData(XFA_ATTRIBUTE_Binding, cData); + wsBinding = cData; +} +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); +} +FX_BOOL CXFA_Script::SetBinding(const CFX_WideString& wsBinding) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Binding, wsBinding); +} +FX_BOOL CXFA_Script::SetContentType(XFA_SCRIPTTYPE eType) { + CFX_WideString wsType; + switch (eType) { + case XFA_SCRIPTTYPE_Javascript: + wsType = L"application/x-javascript"; + break; + case XFA_SCRIPTTYPE_Formcalc: + wsType = L"application/x-formcalc"; + break; + default: + break; + } + return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsType); +} +FX_BOOL CXFA_Script::SetRunAt(int32_t iRunAt) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iRunAt); +} +FX_BOOL CXFA_Script::SetExpression(const CFX_WideString& wsExpression) { + return m_pNode->SetContent(wsExpression, 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); +} +XFA_TEXTENCODING CXFA_Submit::GetSubmitTextEncoding() { + CFX_WideStringC wsCData; + if (!m_pNode->TryCData(XFA_ATTRIBUTE_TextEncoding, wsCData)) { + return XFA_TEXTENCODING_None; + } + CFX_WideString wsValue(wsCData); + if (wsValue == L"Big-Five") { + return XFA_TEXTENCODING_Big5; + } else if (wsValue == L"fontSpecific") { + return XFA_TEXTENCODING_FontSpecific; + } else if (wsValue == L"GBK") { + return XFA_TEXTENCODING_GBK; + } else if (wsValue == L"GB-18030") { + return XFA_TEXTENCODING_GB18030; + } else if (wsValue == L"GB-2312") { + return XFA_TEXTENCODING_GB2312; + } else if (wsValue == L"ISO-8859-NN") { + return XFA_TEXTENCODING_ISO8859NN; + } else if (wsValue == L"KSC-5601") { + return XFA_TEXTENCODING_KSC5601; + } else if (wsValue == L"Shift-JIS") { + return XFA_TEXTENCODING_ShiftJIS; + } else if (wsValue == L"UCS-2") { + return XFA_TEXTENCODING_UCS2; + } else if (wsValue == L"UTF-16") { + return XFA_TEXTENCODING_UTF16; + } else if (wsValue == L"UTF-8") { + return XFA_TEXTENCODING_UTF8; + } + return XFA_TEXTENCODING_None; +} +void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) { + m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent); +} +FX_BOOL CXFA_Submit::SetSubmitFormat(int32_t iSubmitFormat) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Format, + (XFA_ATTRIBUTEENUM)iSubmitFormat); +} +FX_BOOL CXFA_Submit::SetSubmitTarget(const CFX_WideString& wsTarget) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); +} +FX_BOOL CXFA_Submit::SetSubmitTextEncoding(XFA_TEXTENCODING eTextEncoding) { + CFX_WideString wsValue; + switch (eTextEncoding) { + case XFA_TEXTENCODING_Big5: + wsValue = L"Big-Five"; + break; + case XFA_TEXTENCODING_FontSpecific: + wsValue = L"fontSpecific"; + break; + case XFA_TEXTENCODING_GBK: + wsValue = L"GBK"; + break; + case XFA_TEXTENCODING_GB18030: + wsValue = L"GB-18030"; + break; + case XFA_TEXTENCODING_GB2312: + wsValue = L"GB-2312"; + break; + case XFA_TEXTENCODING_ISO8859NN: + wsValue = L"ISO-8859-NN"; + break; + case XFA_TEXTENCODING_KSC5601: + wsValue = L"KSC-5601"; + break; + case XFA_TEXTENCODING_ShiftJIS: + wsValue = L"Shift-JIS"; + break; + case XFA_TEXTENCODING_UCS2: + wsValue = L"UCS-2"; + break; + case XFA_TEXTENCODING_UTF16: + wsValue = L"UTF-16"; + break; + case XFA_TEXTENCODING_UTF8: + wsValue = L"UTF-8"; + break; + default: + break; + } + return m_pNode->SetCData(XFA_ATTRIBUTE_TextEncoding, wsValue); +} +FX_BOOL CXFA_Submit::SetSubmitXDPContent(const CFX_WideString& wsContent) { + return m_pNode->SetCData(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); +} +FX_BOOL CXFA_Value::SetChildValueContent(const CFX_WideString& wsContent, + FX_BOOL bNotify, + XFA_ELEMENT iType) { + if (!m_pNode) { + return FALSE; + } + CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pNode) { + if (iType == XFA_ELEMENT_UNKNOWN) { + return FALSE; + } + pNode = m_pNode->GetProperty(0, iType); + } + CFX_WideString wsFormatContent(wsContent); + CXFA_WidgetData* pContainerWidgetData = pNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsContent, wsFormatContent); + } + return pNode->SetContent(wsContent, wsFormatContent, bNotify); +} +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)); +} +FX_BOOL CXFA_Line::SetHand(int32_t iHand) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Hand, (XFA_ATTRIBUTEENUM)iHand); +} +FX_BOOL CXFA_Line::SetSlop(int32_t iSlop) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Slope, (XFA_ATTRIBUTEENUM)iSlop); +} +CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} +void CXFA_Text::GetName(CFX_WideStringC& wsName) { + m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); +} +int32_t CXFA_Text::GetMaxChars() { + return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxChars); +} +void CXFA_Text::GetRid(CFX_WideStringC& wsRid) { + m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); +} +void CXFA_Text::GetContent(CFX_WideString& wsText) { + m_pNode->TryContent(wsText); +} +void CXFA_Text::SetContent(CFX_WideString wsText, FX_BOOL bNotify) { + CFX_WideString wsFormatValue(wsText); + CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); + } + m_pNode->SetContent(wsText, wsFormatValue, bNotify); +} +FX_BOOL CXFA_Text::SetName(const CFX_WideString& wsName) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); +} +FX_BOOL CXFA_Text::SetMaxChars(int32_t iMaxChars) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxChars, iMaxChars); +} +FX_BOOL CXFA_Text::SetRid(const CFX_WideString& wsRid) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); +} +CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {} +void CXFA_ExData::GetContentType(CFX_WideStringC& wsContentType) { + m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); +} +void CXFA_ExData::GetHref(CFX_WideStringC& wsHref) { + m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref); +} +int32_t CXFA_ExData::GetMaxLength() { + return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxLength); +} +void CXFA_ExData::GetRid(CFX_WideStringC& wsRid) { + m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); +} +int32_t CXFA_ExData::GetTransferEncoding() { + return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding); +} +void CXFA_ExData::GetContent(CFX_WideString& wsText) { + m_pNode->TryContent(wsText); +} +FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) { + return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); +} +FX_BOOL CXFA_ExData::SetHref(const CFX_WideString& wsHref) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref); +} +FX_BOOL CXFA_ExData::SetMaxLength(int32_t iMaxLength) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxLength, iMaxLength); +} +FX_BOOL CXFA_ExData::SetRid(const CFX_WideString& wsRid) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); +} +FX_BOOL CXFA_ExData::SetTransferEncoding(int32_t iTransferEncoding) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, + (XFA_ATTRIBUTEENUM)iTransferEncoding); +} +FX_BOOL CXFA_ExData::SetContent(const CFX_WideString& wsText, + FX_BOOL bNotify, + FX_BOOL bScriptModify, + FX_BOOL bSyncData) { + CFX_WideString wsFormatValue(wsText); + CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); + } + return m_pNode->SetContent(wsText, wsFormatValue, bNotify, bScriptModify, + bSyncData); +} +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::SetAspect(int32_t iAspect) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Aspect, (XFA_ATTRIBUTEENUM)iAspect); +} +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); +} +FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) { + if (m_bDefValue) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, + (XFA_ATTRIBUTEENUM)iTransferEncoding); + } + return TRUE; +} +FX_BOOL CXFA_Image::SetContent(const CFX_WideString& wsText) { + CFX_WideString wsFormatValue(wsText); + CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); + } + return m_pNode->SetContent(wsText, wsFormatValue); +} +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); + } + } +} +FX_BOOL CXFA_Calculate::SetOverride(int32_t iOverride) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Override, (XFA_ATTRIBUTEENUM)iOverride); +} +FX_BOOL CXFA_Calculate::SetMessageText(const CFX_WideString& wsMessage) { + if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) { + CXFA_Node* pChildNode = pNode->GetProperty(0, XFA_ELEMENT_Text); + return pChildNode->SetContent(wsMessage, wsMessage); + } + return FALSE; +} +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); + if (pInfo) { + eName = pInfo->eName; + } + m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE); + return TRUE; +} +FX_BOOL CXFA_Validate::SetFormatTest(CFX_WideString wsValue) { + return SetTestValue(XFA_ATTRIBUTE_FormatTest, wsValue, + XFA_ATTRIBUTEENUM_Warning); +} +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_Variables::CXFA_Variables(CXFA_Node* pNode) : CXFA_Data(pNode) {} +int32_t CXFA_Variables::CountScripts() { + return m_pNode->CountChildren(XFA_ELEMENT_Script); +} +CXFA_Script CXFA_Variables::GetScript(int32_t nIndex) { + return CXFA_Script(m_pNode->GetChild(nIndex, XFA_ELEMENT_Script)); +} +CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} +int32_t CXFA_Bind::GetMatch() { + return m_pNode->GetEnum(XFA_ATTRIBUTE_Match); +} +void CXFA_Bind::GetRef(CFX_WideStringC& wsRef) { + m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); +} +void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) { + if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { + pPicture->TryContent(wsPicture); + } +} +FX_BOOL CXFA_Bind::SetMatch(int32_t iMatch) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Match, (XFA_ATTRIBUTEENUM)iMatch); +} +FX_BOOL CXFA_Bind::SetRef(const CFX_WideString& wsRef) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); +} +FX_BOOL CXFA_Bind::SetPicture(const CFX_WideString& wsPicture) { + if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { + return pPicture->SetContent(wsPicture, wsPicture); + } + return FALSE; +} +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); +} +FX_BOOL CXFA_ToolTip::SetTip(const CFX_WideString& wsTip) { + return m_pNode->SetContent(wsTip, wsTip); +} +CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {} +void CXFA_BindItems::GetConnection(CFX_WideStringC& wsConnection) { + m_pNode->TryCData(XFA_ATTRIBUTE_Connection, wsConnection); +} +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); +} +FX_BOOL CXFA_BindItems::SetLabelRef(const CFX_WideString& wsLabelRef) { + return m_pNode->SetCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); +} +FX_BOOL CXFA_BindItems::SetValueRef(const CFX_WideString& wsValueRef) { + return m_pNode->SetCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); +} +FX_BOOL CXFA_BindItems::SetRef(const CFX_WideString& wsRef) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); +} +int32_t CXFA_Box::GetBreak() const { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Close; + } + return m_pNode->GetEnum(XFA_ATTRIBUTE_Break); +} +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::CountCorners() const { + if (!m_pNode) { + return 0; + } + return m_pNode->CountChildren(XFA_ELEMENT_Corner); +} +CXFA_Corner CXFA_Box::GetCorner(int32_t nIndex) const { + return CXFA_Corner( + m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Corner, nIndex == 0) + : nullptr); +} +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; + } + 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); +} +static FX_BOOL XFA_BOX_SameStyles(const CXFA_StrokeArray& strokes) { + int32_t iCount = strokes.GetSize(); + if (iCount < 1) { + return TRUE; + } + CXFA_Stroke stroke1 = strokes[0]; + for (int32_t i = 1; i < iCount; i++) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke2) { + continue; + } + if (!stroke1) { + stroke1 = stroke2; + } else if (!stroke1.SameStyles(stroke2)) { + return FALSE; + } + } + return TRUE; +} +FX_BOOL CXFA_Box::SameStyles() const { + if (IsArc()) { + return TRUE; + } + CXFA_StrokeArray strokes; + XFA_BOX_GetStrokes(m_pNode, strokes, TRUE); + return XFA_BOX_SameStyles(strokes); +} +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; + } + } + 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::SetThickness(FX_FLOAT fThickness) { + if (!m_pNode) { + return; + } + CXFA_Measurement thickness(fThickness, XFA_UNIT_Pt); + m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, thickness); +} +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, FX_DWORD 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); + } + } + return fThickness; +} +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) { + 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) { + 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) { + return iAcc; + } + pNode = + pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); + } + return XFA_ATTRIBUTEENUM_Open; +} +FX_BOOL CXFA_WidgetData::GetAccessKey(CFX_WideStringC& wsAccessKey) { + return m_pNode->TryCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); +} +int32_t CXFA_WidgetData::GetAnchorType() { + return m_pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); +} +int32_t CXFA_WidgetData::GetColSpan() { + return m_pNode->GetInteger(XFA_ATTRIBUTE_ColSpan); +} +int32_t CXFA_WidgetData::GetPresence() { + return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); + CXFA_Node* pNode = m_pNode; + while (pNode && pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { + int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Presence); + if (iAcc != XFA_ATTRIBUTEENUM_Visible) { + return iAcc; + } + pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); + } + return XFA_ATTRIBUTEENUM_Visible; +} +int32_t CXFA_WidgetData::GetRotate() { + CXFA_Measurement ms; + 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)); +} +CXFA_Keep CXFA_WidgetData::GetKeep(FX_BOOL bModified) { + return CXFA_Keep(m_pNode->GetProperty(0, XFA_ELEMENT_Keep, bModified), + m_pNode); +} +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) { + CXFA_NodeArray allEvents; + GetEventList(allEvents); + int32_t iCount = allEvents.GetSize(); + for (int32_t i = 0; i < iCount; i++) { + CXFA_Event event(allEvents[i]); + if (event.GetActivity() == iActivity) { + if (iActivity == XFA_ATTRIBUTEENUM_Ready) { + CFX_WideStringC wsRef; + event.GetRef(wsRef); + if (bIsFormReady) { + if (wsRef == CFX_WideStringC(L"$form")) { + events.Add(allEvents[i]); + } + } else { + if (wsRef == CFX_WideStringC(L"$layout")) { + events.Add(allEvents[i]); + } + } + } else { + events.Add(allEvents[i]); + } + } + } + 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_Variables CXFA_WidgetData::GetVariables(FX_BOOL bModified) { + return CXFA_Variables( + m_pNode->GetProperty(0, XFA_ELEMENT_Variables, 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)); +} +void CXFA_WidgetData::GetRelevant(CFX_WideStringC& wsRelevant) { + m_pNode->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant); +} +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_BindItems CXFA_WidgetData::GetBindItems() { + return CXFA_BindItems(m_pNode->GetChild(0, XFA_ELEMENT_BindItems)); +} +FX_BOOL CXFA_WidgetData::SetAccess(int32_t iAccess, FX_BOOL bNotify) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Access, (XFA_ATTRIBUTEENUM)iAccess, + bNotify); +} +FX_BOOL CXFA_WidgetData::SetAccessKey(const CFX_WideString& wsAccessKey) { + return m_pNode->SetCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); +} +FX_BOOL CXFA_WidgetData::SetAnchorType(int32_t iType) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_AnchorType, (XFA_ATTRIBUTEENUM)iType); +} +FX_BOOL CXFA_WidgetData::SetColSpan(int32_t iColSpan) { + return m_pNode->SetInteger(XFA_ATTRIBUTE_ColSpan, + (XFA_ATTRIBUTEENUM)iColSpan); +} +FX_BOOL CXFA_WidgetData::SetPresence(int32_t iPresence) { + return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); +} +FX_BOOL CXFA_WidgetData::SetRotate(int32_t iRotate) { + iRotate = XFA_MapRotation(iRotate); + CXFA_Measurement ms((FX_FLOAT)iRotate, XFA_UNIT_Angle); + return m_pNode->SetMeasure(XFA_ATTRIBUTE_Rotate, ms); +} +FX_BOOL CXFA_WidgetData::SetRelevant(const CFX_WideString& wsRelevant) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Relevant, wsRelevant); +} +FX_BOOL CXFA_WidgetData::SetStatus(FX_DWORD dwStatus) { + return FALSE; +} +FX_BOOL CXFA_WidgetData::SetWidth(FX_FLOAT fWidth) { + return SetMeasure(XFA_ATTRIBUTE_W, fWidth); +} +FX_BOOL CXFA_WidgetData::SetHeight(FX_FLOAT fHeight) { + return SetMeasure(XFA_ATTRIBUTE_H, fHeight); +} +FX_BOOL CXFA_WidgetData::SetMinWidth(FX_FLOAT fMinWidth) { + return SetMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); +} +FX_BOOL CXFA_WidgetData::SetMinHeight(FX_FLOAT fMinHeight) { + return SetMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); +} +FX_BOOL CXFA_WidgetData::SetMaxWidth(FX_FLOAT fMaxWidth) { + return SetMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); +} +FX_BOOL CXFA_WidgetData::SetMaxHeight(FX_FLOAT fMaxHeight) { + return SetMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); +} +FX_BOOL CXFA_WidgetData::SetPos(FX_FLOAT x, FX_FLOAT y) { + return SetMeasure(XFA_ATTRIBUTE_X, x) && SetMeasure(XFA_ATTRIBUTE_Y, y); +} +FX_BOOL CXFA_WidgetData::SetName(const CFX_WideString& wsName) { + return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); +} +FX_BOOL CXFA_WidgetData::SetButtonHighlight(int32_t iButtonHighlight) { + CXFA_Node* pUiChildNode = GetUIChild(); + return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Highlight, + (XFA_ATTRIBUTEENUM)iButtonHighlight); +} +FX_BOOL CXFA_WidgetData::SetButtonRollover(const CFX_WideString& wsRollover, + FX_BOOL bRichText) { + return FALSE; +} +FX_BOOL CXFA_WidgetData::SetButtonDown(const CFX_WideString& wsDown, + FX_BOOL bRichText) { + return FALSE; +} +FX_BOOL CXFA_WidgetData::SetCheckButtonShape(int32_t iCheckButtonShape) { + CXFA_Node* pUiChildNode = GetUIChild(); + return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Shape, + (XFA_ATTRIBUTEENUM)iCheckButtonShape); +} +FX_BOOL CXFA_WidgetData::SetCheckButtonMark(int32_t iCheckButtonMark) { + CXFA_Node* pUiChildNode = GetUIChild(); + return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Mark, + (XFA_ATTRIBUTEENUM)iCheckButtonMark); +} +FX_BOOL CXFA_WidgetData::SetCheckButtonSize(FX_FLOAT fCheckButtonMark) { + CXFA_Node* pUiChildNode = GetUIChild(); + if (pUiChildNode) { + CXFA_Measurement ms(fCheckButtonMark, XFA_UNIT_Pt); + return pUiChildNode->SetMeasure(XFA_ATTRIBUTE_Size, ms); + } + return FALSE; +} +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) { + return; + } + CXFA_Border border = GetUIBorder(); + 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); + FX_BOOL bRight = mgUI.GetRightInset(fRightInset); + FX_BOOL bBottom = mgUI.GetBottomInset(fBottomInset); + if (border) { + FX_BOOL bVisible = FALSE; + FX_FLOAT fThickness = 0; + border.Get3DStyle(bVisible, fThickness); + 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); + } + } + } + rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); +} +int32_t CXFA_WidgetData::GetButtonHighlight() { + CXFA_Node* pUIChild = GetUIChild(); + 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)) { + CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pText) { + CFX_WideStringC wsName; + pText->TryCData(XFA_ATTRIBUTE_Name, wsName); + if (wsName == FX_WSTRC(L"rollover")) { + pText->TryContent(wsRollover); + bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; + return !wsRollover.IsEmpty(); + } + pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, + FX_BOOL& bRichText) { + if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { + CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pText) { + CFX_WideStringC wsName; + pText->TryCData(XFA_ATTRIBUTE_Name, wsName); + if (wsName == FX_WSTRC(L"down")) { + pText->TryContent(wsDown); + bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; + return !wsDown.IsEmpty(); + } + pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } + return FALSE; +} +int32_t CXFA_WidgetData::GetCheckButtonShape() { + CXFA_Node* pUIChild = GetUIChild(); + 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) { + 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)) { + return pParent->GetClassID() == XFA_ELEMENT_ExclGroup; + } + return FALSE; +} +FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() { + CXFA_Node* pUIChild = GetUIChild(); + 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) { + 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()) { + 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)) { + 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()); + if (exclGroup) { + CFX_WideString wsValue; + 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) { + 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) { + continue; + } + CXFA_Node* pItem = pChild->GetChild(0, XFA_ELEMENT_Items); + if (!pItem) { + continue; + } + CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pItemchild) { + continue; + } + CFX_WideString text = pItemchild->GetContent(); + CFX_WideString wsChildValue = text; + if (wsValue != text) { + pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); + if (pItemchild) { + wsChildValue = pItemchild->GetContent(); + } else { + wsChildValue.Empty(); + } + } + CXFA_WidgetData ch(pChild); + ch.SyncValue(wsChildValue, bNotify); + } + exclGroup.SyncValue(wsValue, bNotify); + } else { + CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items); + if (!pItems) { + return; + } + int32_t i = -1; + CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); + CFX_WideString wsContent; + while (pText) { + i++; + if (i == eCheckState) { + pText->TryContent(wsContent); + break; + } + pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); + } + 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) { + return NULL; + } + return pExcl; +} +CXFA_Node* CXFA_WidgetData::GetSelectedMember() { + CXFA_Node* pSelectedMember = NULL; + CFX_WideString wsState = GetRawValue(); + 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); + if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { + pSelectedMember = pNode; + break; + } + } + return pSelectedMember; +} +CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName, + FX_BOOL bNotify) { + CXFA_Node* pSelectedMember = NULL; + FX_DWORD nameHash = + FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); + for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pNode->GetNameHash() == nameHash) { + CXFA_WidgetData widgetData(pNode); + widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); + pSelectedMember = pNode; + break; + } + } + return pSelectedMember; +} +void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue, + FX_BOOL bNotify, + FX_BOOL bScriptModify, + FX_BOOL bSyncData) { + 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) { + continue; + } + CXFA_Node* pItem = pNode->GetChild(0, XFA_ELEMENT_Items); + if (!pItem) { + continue; + } + CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pItemchild) { + continue; + } + CFX_WideString wsChildValue = pItemchild->GetContent(); + if (wsValue != wsChildValue) { + pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); + if (pItemchild) { + wsChildValue = pItemchild->GetContent(); + } else { + wsChildValue.Empty(); + } + } else { + wsExclGroup = wsValue; + } + pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify, + FALSE); + } + if (m_pNode) { + m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, + bSyncData); + } +} +CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { + CXFA_Node* pExcl = GetNode(); + if (!pExcl) { + return NULL; + } + CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pNode) { + 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) { + return NULL; + } + CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + while (pNodeField) { + 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) { + 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) { + 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) { + 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) { + continue; + } + iCount++; + pItems.Add(pNode); + if (iCount == 2) { + break; + } + } + 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) { + 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(); + 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) { + continue; + } + iCount++; + pItemsArray.Add(pNode); + if (iCount == 2) { + break; + } + } + 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) { + pItems = pItemsArray[1]; + } + } + if (pItems) { + CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_ELEMENT_UNKNOWN); + if (pItem) { + pItem->TryContent(wsText); + return TRUE; + } + } + return FALSE; +} +void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, + 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) { + continue; + } + iCount++; + pItems.Add(pNode); + if (iCount == 2) { + break; + } + } + 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) { + pItem = pItems[1]; + } + } + pItems.RemoveAll(); + pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); + 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()) { + return wsValueArray.GetSize(); + } + int32_t iSelected = 0; + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + int32_t iValues = wsValueArray.GetSize(); + for (int32_t i = 0; i < iValues; i++) { + int32_t iSaves = wsSaveTextArray.GetSize(); + for (int32_t j = 0; j < iSaves; j++) { + if (wsValueArray[i] == wsSaveTextArray[j]) { + iSelected++; + break; + } + } + } + return iSelected; +} +int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) { + CFX_WideStringArray wsValueArray; + GetSelectedItemsValue(wsValueArray); + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + int32_t iSaves = wsSaveTextArray.GetSize(); + for (int32_t j = 0; j < iSaves; 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) { + return; + } + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + int32_t iSaves = wsSaveTextArray.GetSize(); + for (int32_t i = 0; i < iValues; i++) { + for (int32_t j = 0; j < iSaves; j++) { + if (wsValueArray[i] == wsSaveTextArray[j]) { + iSelArray.Add(j); + break; + } + } + } +} +void CXFA_WidgetData::GetSelectedItemsValue( + CFX_WideStringArray& wsSelTextArray) { + CFX_WideString wsValue = GetRawValue(); + if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + if (!wsValue.IsEmpty()) { + int32_t iStart = 0; + int32_t iLength = wsValue.GetLength(); + int32_t iEnd = wsValue.Find(L'\n', iStart); + iEnd = (iEnd == -1) ? iLength : iEnd; + while (iEnd >= iStart) { + wsSelTextArray.Add(wsValue.Mid(iStart, iEnd - iStart)); + iStart = iEnd + 1; + if (iStart >= iLength) { + break; + } + iEnd = wsValue.Find(L'\n', iStart); + 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) { + return FALSE; + } + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + 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]) { + 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) { + return; + } + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + if (wsSaveTextArray.GetSize() <= nIndex) { + return; + } + int32_t iSel = -1; + CFX_WideStringArray wsValueArray; + GetSelectedItemsValue(wsValueArray); + int32_t iValues = wsValueArray.GetSize(); + for (int32_t j = 0; j < iValues; j++) { + if (wsValueArray[j] == wsSaveTextArray[nIndex]) { + iSel = j; + break; + } + } + if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { + if (bSelected) { + if (iSel < 0) { + CFX_WideString wsValue = GetRawValue(); + if (!wsValue.IsEmpty()) { + wsValue += L"\n"; + } + wsValue += wsSaveTextArray[nIndex]; + m_pNode->SetContent(wsValue, wsValue, bNotify, bScriptModify, + bSyncData); + } + } else if (iSel >= 0) { + CFX_Int32Array iSelArray; + GetSelectedItems(iSelArray); + for (int32_t i = 0; i < iSelArray.GetSize(); i++) { + if (iSelArray[i] == nIndex) { + iSelArray.RemoveAt(i); + break; + } + } + SetSelectdItems(iSelArray, bNotify, bScriptModify, bSyncData); + } + } else { + if (bSelected) { + if (iSel < 0) { + CFX_WideString wsSaveText = wsSaveTextArray[nIndex]; + CFX_WideString wsFormatText(wsSaveText); + GetFormatDataValue(wsSaveText, wsFormatText); + m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify, + bSyncData); + } + } else if (iSel >= 0) { + m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, + bScriptModify, bSyncData); + } + } +} +void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray, + FX_BOOL bNotify, + FX_BOOL bScriptModify, + FX_BOOL bSyncData) { + CFX_WideString wsValue; + int32_t iSize = iSelArray.GetSize(); + if (iSize >= 1) { + CFX_WideStringArray wsSaveTextArray; + GetChoiceListItems(wsSaveTextArray, TRUE); + CFX_WideString wsItemValue; + for (int32_t i = 0; i < iSize; i++) { + wsItemValue = (iSize == 1) + ? wsSaveTextArray[iSelArray[i]] + : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); + wsValue += wsItemValue; + } + } + CFX_WideString wsFormat(wsValue); + 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) { + while (CXFA_Node* pChildNode = + pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { + pBind->RemoveChild(pChildNode); + } + } else { + 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()) { + 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) { + 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, nIndex); + CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); + m_pNode->InsertChild(-1, pSaveItems); + pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); + 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, nIndex); + } else { + InsertListTextItem(pNode, wsLabel, nIndex); + } + } + } else { + CXFA_Node* pNode = listitems[0]; + pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); + pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); + CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); + m_pNode->InsertChild(-1, pSaveItems); + pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); + pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); + listitems.RemoveAll(); + CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + int32_t i = 0; + while (pListNode) { + CFX_WideString wsOldValue; + pListNode->TryContent(wsOldValue); + InsertListTextItem(pSaveItems, wsOldValue, i); + i++; + pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + InsertListTextItem(pNode, wsLabel, nIndex); + InsertListTextItem(pSaveItems, wsNewValue, nIndex); + } + 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); +} +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) { + continue; + } + iCount++; + listitems.Add(pItems); + } + if (iCount <= 1) { + wsLabel = wsValue; + } else { + CXFA_Node* pLabelItems = listitems[0]; + FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); + CXFA_Node* pSaveItems = NULL; + if (bSave) { + pSaveItems = pLabelItems; + pLabelItems = listitems[1]; + } else { + pSaveItems = listitems[1]; + } + iCount = 0; + int32_t iSearch = -1; + CFX_WideString wsContent; + CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pChildItem; + pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { + pChildItem->TryContent(wsContent); + if (wsContent == wsValue) { + iSearch = iCount; + break; + } + iCount++; + } + 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) { + continue; + } + iCount++; + listitems.Add(pItems); + } + if (iCount <= 1) { + wsValue = wsLabel; + } else { + CXFA_Node* pLabelItems = listitems[0]; + FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); + CXFA_Node* pSaveItems = NULL; + if (bSave) { + pSaveItems = pLabelItems; + pLabelItems = listitems[1]; + } else { + pSaveItems = listitems[1]; + } + iCount = 0; + int32_t iSearch = -1; + CFX_WideString wsContent; + CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pChildItem; + pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { + pChildItem->TryContent(wsContent); + if (wsContent == wsLabel) { + iSearch = iCount; + break; + } + iCount++; + } + if (iSearch < 0) { + return; + } + 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, + FX_BOOL bSyncData) { + 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) { + continue; + } + if (nIndex < 0) { + while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) { + pItems->RemoveChild(pNode); + } + } else { + if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { + SetItemState(nIndex, FALSE, TRUE, bScriptModify, bSyncData); + bSetValue = TRUE; + } + int32_t i = 0; + CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pNode) { + if (i == nIndex) { + pItems->RemoveChild(pNode); + break; + } + i++; + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + } + } + if (!bNotify) { + return TRUE; + } + m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( + this, XFA_WIDGETEVENT_ListItemRemoved, (void*)(uintptr_t)nIndex); + return TRUE; +} +int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() { + CXFA_Node* pUIChild = GetUIChild(); + if (pUIChild) { + return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy); + } + return XFA_ATTRIBUTEENUM_Auto; +} +int32_t CXFA_WidgetData::GetNumberOfCells() { + CXFA_Node* pUIChild = GetUIChild(); + if (!pUIChild) { + return -1; + } + if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) { + return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); + } + return -1; +} +FX_BOOL CXFA_WidgetData::IsDateTimeEditUsePicker() { + return TRUE; +} +CFX_WideString CXFA_WidgetData::GetBarcodeType() { + CXFA_Node* pUIChild = GetUIChild(); + return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { + CXFA_Node* pUIChild = GetUIChild(); + CFX_WideString wsCharEncoding; + if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { + if (wsCharEncoding.CompareNoCase(L"UTF-16")) { + val = CHAR_ENCODING_UNICODE; + return TRUE; + } else 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; + if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { + switch (eChecksum) { + case XFA_ATTRIBUTEENUM_None: + val = 0; + return TRUE; + case XFA_ATTRIBUTEENUM_Auto: + val = 1; + return TRUE; + case XFA_ATTRIBUTEENUM_1mod10: + break; + case XFA_ATTRIBUTEENUM_1mod10_1mod11: + break; + case XFA_ATTRIBUTEENUM_2mod10: + break; + default: + break; + } + } + 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); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) { + CXFA_Node* pUIChild = GetUIChild(); + CFX_WideStringC wsStartEndChar; + if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { + if (wsStartEndChar.GetLength()) { + val = (FX_CHAR)wsStartEndChar.GetAt(0); + return TRUE; + } + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) { + CXFA_Node* pUIChild = GetUIChild(); + CFX_WideStringC wsStartEndChar; + if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { + if (wsStartEndChar.GetLength()) { + val = (FX_CHAR)wsStartEndChar.GetAt(0); + return TRUE; + } + } + 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); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) { + CXFA_Node* pUIChild = GetUIChild(); + CXFA_Measurement mModuleWidthHeight; + if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) { + val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) { + CXFA_Node* pUIChild = GetUIChild(); + CXFA_Measurement mModuleWidthHeight; + if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) { + val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) { + CXFA_Node* pUIChild = GetUIChild(); + FX_BOOL bPrintCheckDigit; + if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) { + val = bPrintCheckDigit; + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) { + CXFA_Node* pUIChild = GetUIChild(); + XFA_ATTRIBUTEENUM eTextLocation; + if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) { + switch (eTextLocation) { + case XFA_ATTRIBUTEENUM_None: + val = BC_TEXT_LOC_NONE; + return TRUE; + case XFA_ATTRIBUTEENUM_Above: + val = BC_TEXT_LOC_ABOVE; + return TRUE; + case XFA_ATTRIBUTEENUM_Below: + val = BC_TEXT_LOC_BELOW; + return TRUE; + case XFA_ATTRIBUTEENUM_AboveEmbedded: + val = BC_TEXT_LOC_ABOVEEMBED; + return TRUE; + case XFA_ATTRIBUTEENUM_BelowEmbedded: + val = BC_TEXT_LOC_BELOWEMBED; + return TRUE; + default: + break; + } + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) { + CXFA_Node* pUIChild = GetUIChild(); + FX_BOOL bTruncate; + if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) { + val = bTruncate; + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) { + CXFA_Node* pUIChild = GetUIChild(); + CFX_WideString wsWideNarrowRatio; + if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) { + FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':'); + FX_FLOAT fRatio = 0; + if (ptPos >= 0) { + fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio); + } else { + int32_t fA, fB; + fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos)); + fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1)); + 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) { + pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord); + } else { + wsPassWord = XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT_PasswordEdit, + XFA_ATTRIBUTE_PasswordChar, + XFA_XDPPACKET_Form); + } +} +FX_BOOL CXFA_WidgetData::IsAllowRichText() { + CXFA_Node* pUIChild = GetUIChild(); + FX_BOOL bValue = FALSE; + if (pUIChild && + pUIChild->TryBoolean(XFA_ATTRIBUTE_AllowRichText, bValue, FALSE)) { + return bValue; + } + if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { + if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { + return pChild->GetClassID() == XFA_ELEMENT_ExData; + } + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::IsMultiLine() { + CXFA_Node* pUIChild = GetUIChild(); + 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) { + 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)) { + switch (pChild->GetClassID()) { + case XFA_ELEMENT_Text: + eType = XFA_ELEMENT_Text; + return pChild->GetInteger(XFA_ATTRIBUTE_MaxChars); + case XFA_ELEMENT_ExData: { + eType = XFA_ELEMENT_ExData; + int32_t iMax = pChild->GetInteger(XFA_ATTRIBUTE_MaxLength); + return iMax < 0 ? 0 : iMax; + } + default: + break; + } + } + } + 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)) { + 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)) { + 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); + 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()) { + SyncValue(wsValue, TRUE); + return TRUE; + } + m_bPreNull = m_bIsNull; + m_bIsNull = FALSE; + CFX_WideString wsNewText(wsValue); + CFX_WideString wsPicture; + GetPictureContent(wsPicture, eValueType); + FX_BOOL bValidate = TRUE; + FX_BOOL bSyncData = FALSE; + CXFA_Node* pNode = GetUIChild(); + if (!pNode) { + return TRUE; + } + XFA_ELEMENT uiType = pNode->GetClassID(); + if (!wsPicture.IsEmpty()) { + CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); + IFX_Locale* pLocale = GetLocal(); + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); + bValidate = + widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); + if (bValidate) { + widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, + wsPicture, pLocale, pLocalMgr); + wsNewText = widgetValue.GetValue(); + if (uiType == XFA_ELEMENT_NumericEdit) { + int32_t iLeadDigits = 0; + int32_t iFracDigits = 0; + GetLeadDigits(iLeadDigits); + GetFracDigits(iFracDigits); + wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); + } + bSyncData = TRUE; + } + } else { + if (uiType == XFA_ELEMENT_NumericEdit) { + if (wsNewText != FX_WSTRC(L"0")) { + int32_t iLeadDigits = 0; + int32_t iFracDigits = 0; + GetLeadDigits(iLeadDigits); + GetFracDigits(iFracDigits); + wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); + } + bSyncData = TRUE; + } + } + 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) { + 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)) { + return TRUE; + } + } + } + CFX_WideString wsDataPicture, wsTimePicture; + IFX_Locale* pLocale = GetLocal(); + if (!pLocale) { + return FALSE; + } + FX_DWORD dwType = widgetValue.GetType(); + switch (dwType) { + case XFA_VT_DATE: + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, + wsPicture); + break; + case XFA_VT_TIME: + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, + wsPicture); + break; + case XFA_VT_DATETIME: + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, + wsDataPicture); + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, + wsTimePicture); + wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture; + break; + case XFA_VT_DECIMAL: + case XFA_VT_FLOAT: + break; + 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)) { + return TRUE; + } + } + } + { + CFX_WideString wsDataPicture, wsTimePicture; + IFX_Locale* pLocale = GetLocal(); + if (!pLocale) { + return FALSE; + } + FX_DWORD dwType = widgetValue.GetType(); + switch (dwType) { + case XFA_VT_DATE: + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, + wsPicture); + break; + case XFA_VT_TIME: + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, + wsPicture); + break; + case XFA_VT_DATETIME: + pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, + wsDataPicture); + pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, + wsTimePicture); + wsPicture = wsDataPicture + L"T" + wsTimePicture; + break; + default: + break; + } + } + } + return TRUE; + case XFA_VALUEPICTURE_DataBind: { + if (CXFA_Bind bind = GetBind()) { + bind.GetPicture(wsPicture); + return TRUE; + } + } break; + default: + break; + } + return FALSE; +} +IFX_Locale* CXFA_WidgetData::GetLocal() { + IFX_Locale* pLocale = NULL; + if (!m_pNode) { + return pLocale; + } + FX_BOOL bLocale = FALSE; + CFX_WideString wsLocaleName; + bLocale = m_pNode->GetLocaleName(wsLocaleName); + if (bLocale) { + if (wsLocaleName.Equal(FX_WSTRC(L"ambient"))) { + pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); + } else { + 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, wsValue); + + CFX_WideString wsPicture; + GetPictureContent(wsPicture, eValueType); + CXFA_Node* pNode = GetUIChild(); + if (!pNode) + return TRUE; + + XFA_ELEMENT uiType = GetUIChild()->GetClassID(); + switch (uiType) { + case XFA_ELEMENT_ChoiceList: { + if (eValueType == XFA_VALUEPICTURE_Display) { + int32_t iSelItemIndex = GetSelectedItem(0); + if (iSelItemIndex >= 0) { + GetChoiceListItem(wsValue, iSelItemIndex); + wsPicture.Empty(); + } + } + } break; + case XFA_ELEMENT_NumericEdit: + if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { + IFX_Locale* pLocale = GetLocal(); + if (eValueType == XFA_VALUEPICTURE_Display && pLocale) { + CFX_WideString wsOutput; + NormalizeNumStr(wsValue, wsOutput); + FormatNumStr(wsOutput, pLocale, wsOutput); + wsValue = wsOutput; + } + } + break; + default: + break; + } + if (wsPicture.IsEmpty()) + return TRUE; + + if (IFX_Locale* pLocale = GetLocal()) { + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); + CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); + switch (widgetValue.GetType()) { + case XFA_VT_DATE: { + CFX_WideString wsDate, wsTime; + if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { + CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); + if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) + return TRUE; + } + break; + } + case XFA_VT_TIME: { + CFX_WideString wsDate, wsTime; + if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { + CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); + if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) + return TRUE; + } + break; + } + default: + break; + } + widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType); + } + return TRUE; +} + +FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( + const CFX_WideStringC& wsValue, + CFX_WideString& wsNormalizeValue) { + wsNormalizeValue = wsValue; + if (wsValue.IsEmpty()) { + return TRUE; + } + CFX_WideString wsPicture; + GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); + if (wsPicture.IsEmpty()) { + return TRUE; + } + FXSYS_assert(GetNode()); + CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); + IFX_Locale* pLocale = GetLocal(); + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); + if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) { + widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue, + wsPicture, pLocale, pLocalMgr); + wsNormalizeValue = widgetValue.GetValue(); + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue, + CFX_WideString& wsFormatedValue) { + wsFormatedValue = wsValue; + if (wsValue.IsEmpty()) { + return TRUE; + } + CFX_WideString wsPicture; + GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); + if (wsPicture.IsEmpty()) { + return TRUE; + } + if (IFX_Locale* pLocale = GetLocal()) { + FXSYS_assert(GetNode()); + CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_ELEMENT_Value); + if (!pNodeValue) { + return FALSE; + } + CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pValueChild) { + return FALSE; + } + int32_t iVTType = XFA_VT_NULL; + XFA_ELEMENT eType = pValueChild->GetClassID(); + switch (eType) { + case XFA_ELEMENT_Decimal: + iVTType = XFA_VT_DECIMAL; + break; + case XFA_ELEMENT_Float: + iVTType = XFA_VT_FLOAT; + break; + case XFA_ELEMENT_Date: + iVTType = XFA_VT_DATE; + break; + case XFA_ELEMENT_Time: + iVTType = XFA_VT_TIME; + break; + case XFA_ELEMENT_DateTime: + iVTType = XFA_VT_DATETIME; + break; + case XFA_ELEMENT_Boolean: + iVTType = XFA_VT_BOOLEAN; + break; + case XFA_ELEMENT_Integer: + iVTType = XFA_VT_INTEGER; + break; + case XFA_ELEMENT_Text: + iVTType = XFA_VT_TEXT; + break; + default: + iVTType = XFA_VT_NULL; + break; + } + CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); + CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr); + switch (widgetValue.GetType()) { + case XFA_VT_DATE: { + CFX_WideString wsDate, wsTime; + if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { + CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); + if (date.FormatPatterns(wsFormatedValue, wsPicture, pLocale, + XFA_VALUEPICTURE_DataBind)) { + return TRUE; + } + } + break; + } + case XFA_VT_TIME: { + CFX_WideString wsDate, wsTime; + if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { + CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); + if (time.FormatPatterns(wsFormatedValue, wsPicture, pLocale, + XFA_VALUEPICTURE_DataBind)) { + return TRUE; + } + } + break; + } + default: + break; + } + widgetValue.FormatPatterns(wsFormatedValue, wsPicture, pLocale, + XFA_VALUEPICTURE_DataBind); + } + return FALSE; +} +void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue, + CFX_WideString& wsOutput) { + if (wsValue.IsEmpty()) { + return; + } + wsOutput = wsValue; + wsOutput.TrimLeft('0'); + int32_t dot_index = wsOutput.Find('.'); + int32_t iFracDigits = 0; + if (!wsOutput.IsEmpty() && dot_index >= 0 && + (!GetFracDigits(iFracDigits) || iFracDigits != -1)) { + wsOutput.TrimRight(L"0"); + wsOutput.TrimRight(L"."); + } + 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()) { + return; + } + CFX_WideString wsSrcNum = wsValue; + CFX_WideString wsGroupSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); + FX_BOOL bNeg = FALSE; + if (wsSrcNum[0] == '-') { + bNeg = TRUE; + wsSrcNum.Delete(0, 1); + } + int32_t len = wsSrcNum.GetLength(); + int32_t dot_index = wsSrcNum.Find('.'); + if (dot_index == -1) { + dot_index = len; + } + int32_t cc = dot_index - 1; + if (cc >= 0) { + int nPos = dot_index % 3; + wsOutput.Empty(); + for (int32_t i = 0; i < dot_index; i++) { + if (i % 3 == nPos && i != 0) { + wsOutput += wsGroupSymbol; + } + wsOutput += wsSrcNum[i]; + } + if (dot_index < len) { + CFX_WideString wsSymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); + wsOutput += wsSymbol; + wsOutput += wsSrcNum.Right(len - dot_index - 1); + } + if (bNeg) { + CFX_WideString wsMinusymbol; + pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); + wsOutput = wsMinusymbol + wsOutput; + } + } +} +void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, + FX_BOOL bNotify) { + if (!m_pNode) { + return; + } + CFX_WideString wsFormatValue(wsValue); + CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); + if (pContainerWidgetData) { + pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); + } + m_pNode->SetContent(wsValue, wsFormatValue, bNotify); +} +void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, + const CFX_WideStringC& wsText, + int32_t nIndex) { + CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); + pItems->InsertChild(nIndex, pText); + pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); +} +CXFA_Filter CXFA_WidgetData::GetFilter(FX_BOOL bModified) { + if (!m_pUiChildNode) { + return CXFA_Filter(nullptr); + } + return CXFA_Filter( + m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Filter, bModified)); +} +CXFA_Manifest CXFA_WidgetData::GetManifest(FX_BOOL bModified) { + if (!m_pUiChildNode) { + return CXFA_Manifest(nullptr); + } + return CXFA_Manifest( + m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Manifest, bModified)); +} +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; +} +int32_t CXFA_Occur::GetInitial() { + int32_t iInit = 1; + if (m_pNode) { + int32_t iMin = GetMin(); + if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, TRUE) || + iInit < iMin) { + iInit = iMin; + } + } + return iInit; +} +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); + } +} +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; + } + } + return eType; +} +CFX_WideString CXFA_Filter::GetFilterString(XFA_ATTRIBUTE eAttribute) { + CFX_WideString wsStringValue; + if (m_pNode) { + m_pNode->GetAttribute(eAttribute, wsStringValue, FALSE); + } + return wsStringValue; +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetAppearanceFilterType() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Optional; + } + CXFA_Node* pAppearanceFilterNode = + m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); + return XFA_GetEnumTypeAttribute(pAppearanceFilterNode); +} +CFX_WideString CXFA_Filter::GetAppearanceFilterContent() { + CFX_WideString wsContent; + if (m_pNode) { + CXFA_Node* pAppearanceFilterNode = + m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); + pAppearanceFilterNode->TryContent(wsContent); + } + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetCertificatesCredentialServerPolicy() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Optional; + } + CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); + return XFA_GetEnumTypeAttribute(pCertsNode, + XFA_ATTRIBUTE_CredentialServerPolicy); +} +CFX_WideString CXFA_Filter::GetCertificatesURL() { + CFX_WideString wsURL; + if (m_pNode) { + CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); + pCertsNode->GetAttribute(XFA_ATTRIBUTE_Url, wsURL, FALSE); + } + return wsURL; +} +CFX_WideString CXFA_Filter::GetCertificatesURLPolicy() { + CFX_WideString wsURLPolicy; + if (m_pNode) { + CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); + pCertsNode->GetAttribute(XFA_ATTRIBUTE_UrlPolicy, wsURLPolicy, FALSE); + } + return wsURLPolicy; +} +CXFA_WrapCertificate CXFA_Filter::GetCertificatesEncryption(FX_BOOL bModified) { + if (!m_pNode) { + return CXFA_WrapCertificate(NULL); + } + CXFA_Node* pCertsNode = + m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); + return CXFA_WrapCertificate( + pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Encryption, bModified) + : NULL); +} +CXFA_WrapCertificate CXFA_Filter::GetCertificatesIssuers(FX_BOOL bModified) { + if (!m_pNode) { + return CXFA_WrapCertificate(NULL); + } + CXFA_Node* pCertsNode = + m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); + return CXFA_WrapCertificate( + pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Issuers, bModified) + : NULL); +} +CFX_WideString CXFA_Filter::GetCertificatesKeyUsageString( + XFA_ATTRIBUTE eAttribute) { + if (!m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); + CXFA_Node* pKeyUsageNode = pCertsNode->GetProperty(0, XFA_ELEMENT_KeyUsage); + CFX_WideString wsAttributeValue; + pKeyUsageNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); + return wsAttributeValue; +} +CXFA_Oids CXFA_Filter::GetCertificatesOids() { + if (!m_pNode) { + return CXFA_Oids(NULL); + } + CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); + return CXFA_Oids(pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Oids) + : NULL); +} +CXFA_WrapCertificate CXFA_Filter::GetCertificatesSigning(FX_BOOL bModified) { + if (!m_pNode) { + return CXFA_WrapCertificate(NULL); + } + CXFA_Node* pCertsNode = + m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); + return CXFA_WrapCertificate( + pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Signing, bModified) + : NULL); +} +CXFA_DigestMethods CXFA_Filter::GetDigestMethods(FX_BOOL bModified) { + return CXFA_DigestMethods( + m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_DigestMethods, bModified) + : NULL); +} +CXFA_Encodings CXFA_Filter::GetEncodings(FX_BOOL bModified) { + return CXFA_Encodings( + m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Encodings, bModified) + : NULL); +} +CXFA_EncryptionMethods CXFA_Filter::GetEncryptionMethods(FX_BOOL bModified) { + return CXFA_EncryptionMethods( + m_pNode + ? m_pNode->GetProperty(0, XFA_ELEMENT_EncryptionMethods, bModified) + : NULL); +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetHandlerType() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Optional; + } + CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); + return XFA_GetEnumTypeAttribute(pHandlerNode); +} +CFX_WideString CXFA_Filter::GetHandlerContent() { + CFX_WideString wsContent; + if (m_pNode) { + CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); + pHandlerNode->TryContent(wsContent); + } + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetlockDocumentType() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Optional; + } + CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); + return XFA_GetEnumTypeAttribute(pLockDocNode); +} +CFX_WideString CXFA_Filter::GetlockDocumentContent() { + CFX_WideString wsContent = FX_WSTRC(L"auto"); + if (m_pNode) { + CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); + pLockDocNode->TryContent(wsContent); + } + return wsContent; +} +int32_t CXFA_Filter::GetMDPPermissions() { + int32_t iPermissions = 2; + if (m_pNode) { + CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); + if (!pMDPNode->TryInteger(XFA_ATTRIBUTE_Permissions, iPermissions, TRUE)) { + iPermissions = 2; + } + } + return iPermissions; +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetMDPSignatureType() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Filter; + } + CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); + return XFA_GetEnumTypeAttribute(pMDPNode, XFA_ATTRIBUTE_SignatureType, + XFA_ATTRIBUTEENUM_Filter); +} +CXFA_Reasons CXFA_Filter::GetReasons(FX_BOOL bModified) { + return CXFA_Reasons(m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Reasons) + : NULL); +} +CFX_WideString CXFA_Filter::GetTimeStampServer() { + CFX_WideString wsServerURI; + if (m_pNode) { + CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); + pTimeStampNode->GetAttribute(XFA_ATTRIBUTE_Server, wsServerURI, FALSE); + } + return wsServerURI; +} +XFA_ATTRIBUTEENUM CXFA_Filter::GetTimeStampType() { + if (!m_pNode) { + return XFA_ATTRIBUTEENUM_Optional; + } + CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); + return XFA_GetEnumTypeAttribute(pTimeStampNode); +} +CFX_WideString CXFA_Certificate::GetCertificateName() { + CFX_WideString wsName; + if (m_pNode) { + m_pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); + } + return wsName; +} +CFX_WideString CXFA_Certificate::GetCertificateContent() { + CFX_WideString wsContent; + if (m_pNode) { + m_pNode->TryContent(wsContent); + } + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_WrapCertificate::GetType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_WrapCertificate::CountCertificates() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Certificate) : 0; +} +CXFA_Certificate CXFA_WrapCertificate::GetCertificate(int32_t nIndex) { + return CXFA_Certificate( + (nIndex > -1 && m_pNode) + ? m_pNode->GetChild(nIndex, XFA_ELEMENT_Certificate) + : NULL); +} +XFA_ATTRIBUTEENUM CXFA_Oids::GetOidsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_Oids::CountOids() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Oid) : 0; +} +CFX_WideString CXFA_Oids::GetOidContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pOidNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Oid); + if (!pOidNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pOidNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_SubjectDNs::GetSubjectDNsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_SubjectDNs::CountSubjectDNs() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_SubjectDN) : 0; +} +CFX_WideString CXFA_SubjectDNs::GetSubjectDNString(int32_t nIndex, + XFA_ATTRIBUTE eAttribute) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); + if (!pSubjectDNNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsAttributeValue; + pSubjectDNNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); + return wsAttributeValue; +} +CFX_WideString CXFA_SubjectDNs::GetSubjectDNContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); + if (!pSubjectDNNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pSubjectDNNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_DigestMethods::GetDigestMethodsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_DigestMethods::CountDigestMethods() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_DigestMethod) : 0; +} +CFX_WideString CXFA_DigestMethods::GetDigestMethodContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pDigestMethodNode = + m_pNode->GetChild(nIndex, XFA_ELEMENT_DigestMethod); + if (!pDigestMethodNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pDigestMethodNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_Encodings::GetEncodingsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_Encodings::CountEncodings() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Encoding) : 0; +} +CFX_WideString CXFA_Encodings::GetEncodingContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pEncodingNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Encoding); + if (!pEncodingNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pEncodingNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_EncryptionMethods::GetEncryptionMethodsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_EncryptionMethods::CountEncryptionMethods() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_EncryptionMethod) : 0; +} +CFX_WideString CXFA_EncryptionMethods::GetEncryptionMethodContent( + int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pEncryMethodNode = + m_pNode->GetChild(nIndex, XFA_ELEMENT_EncryptionMethod); + if (!pEncryMethodNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pEncryMethodNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_Reasons::GetReasonsType() { + return XFA_GetEnumTypeAttribute(m_pNode); +} +int32_t CXFA_Reasons::CountReasons() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Reason) : 0; +} +CFX_WideString CXFA_Reasons::GetReasonContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pReasonNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Reason); + if (!pReasonNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pReasonNode->TryContent(wsContent); + return wsContent; +} +XFA_ATTRIBUTEENUM CXFA_Manifest::GetAction() { + return XFA_GetEnumTypeAttribute(m_pNode, XFA_ATTRIBUTE_Action, + XFA_ATTRIBUTEENUM_Include); +} +int32_t CXFA_Manifest::CountReives() { + return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Ref) : 0; +} +CFX_WideString CXFA_Manifest::GetRefContent(int32_t nIndex) { + if (nIndex <= -1 || !m_pNode) { + return FX_WSTRC(L""); + } + CXFA_Node* pRefNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Ref); + if (!pRefNode) { + return FX_WSTRC(L""); + } + CFX_WideString wsContent; + pRefNode->TryContent(wsContent); + return wsContent; +} diff --git a/xfa/fxfa/parser/xfa_parser.h b/xfa/fxfa/parser/xfa_parser.h new file mode 100644 index 0000000000..2d45e5f9c8 --- /dev/null +++ b/xfa/fxfa/parser/xfa_parser.h @@ -0,0 +1,38 @@ +// 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_PARSER_H_ +#define XFA_FXFA_PARSER_XFA_PARSER_H_ + +#include "xfa/fxfa/parser/xfa_document.h" + +class IXFA_Parser { + public: + static IXFA_Parser* Create(IXFA_ObjFactory* pFactory, + FX_BOOL bDocumentParser = FALSE); + virtual ~IXFA_Parser() {} + virtual void Release() = 0; + virtual int32_t StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) = 0; + virtual int32_t DoParse(IFX_Pause* pPause = NULL) = 0; + virtual int32_t ParseXMLData(const CFX_WideString& wsXML, + IFDE_XMLNode*& pXMLNode, + IFX_Pause* pPause = NULL) = 0; + virtual void ConstructXFANode(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode) = 0; + virtual IXFA_ObjFactory* GetFactory() const = 0; + virtual CXFA_Node* GetRootNode() const = 0; + virtual IFDE_XMLDoc* GetXMLDoc() const = 0; + virtual void CloseParser() = 0; +}; +class IXFA_DocParser : public IXFA_Parser { + public: + static IXFA_DocParser* Create(IXFA_Notify* pNotify); + virtual CXFA_Document* GetDocument() const = 0; + virtual IXFA_Notify* GetNotify() const = 0; +}; + +#endif // XFA_FXFA_PARSER_XFA_PARSER_H_ diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp new file mode 100644 index 0000000000..f27e3a6c0f --- /dev/null +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -0,0 +1,1568 @@ +// 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/fxfa/parser/xfa_parser_imp.h" + +#include "xfa/fgas/crt/fgas_codepage.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_localemgr.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" + +IXFA_Parser* IXFA_Parser::Create(IXFA_ObjFactory* pFactory, + FX_BOOL bDocumentParser) { + return new CXFA_SimpleParser(pFactory, bDocumentParser); +} +CXFA_SimpleParser::CXFA_SimpleParser(IXFA_ObjFactory* pFactory, + FX_BOOL bDocumentParser) + : m_pXMLParser(nullptr), + m_pXMLDoc(nullptr), + m_pStream(nullptr), + m_pFileRead(nullptr), + m_pFactory(pFactory), + m_pRootNode(nullptr), + m_ePacketID(XFA_XDPPACKET_UNKNOWN), + m_bDocumentParser(bDocumentParser) {} +CXFA_SimpleParser::~CXFA_SimpleParser() { + CloseParser(); +} +void CXFA_SimpleParser::SetFactory(IXFA_ObjFactory* pFactory) { + m_pFactory = pFactory; +} +static IFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( + IFDE_XMLDoc* pXMLDoc, + FX_BOOL bVerifyWellFormness = FALSE) { + if (!pXMLDoc) { + return NULL; + } + IFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); + for (IFDE_XMLNode* pXMLNode = + pXMLFakeRoot->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + if (bVerifyWellFormness) { + for (IFDE_XMLNode* pNextNode = + pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + pNextNode; + pNextNode = pNextNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (pNextNode->GetType() == FDE_XMLNODE_Element) { + return FALSE; + } + } + } + return pXMLNode; + } + } + return NULL; +} +int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID) { + CloseParser(); + m_pFileRead = pStream; + m_pStream = IFX_Stream::CreateStream( + pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text); + if (m_pStream == NULL) { + return XFA_PARSESTATUS_StreamErr; + } + FX_WORD wCodePage = m_pStream->GetCodePage(); + if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && + wCodePage != FX_CODEPAGE_UTF8) { + m_pStream->SetCodePage(FX_CODEPAGE_UTF8); + } + m_pXMLDoc = IFDE_XMLDoc::Create(); + if (m_pXMLDoc == NULL) { + return XFA_PARSESTATUS_StatusErr; + } + m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); + if (m_pXMLParser == NULL) { + return XFA_PARSESTATUS_StatusErr; + } + if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { + return XFA_PARSESTATUS_StatusErr; + } + m_ePacketID = ePacketID; + return XFA_PARSESTATUS_Ready; +} +int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { + if (m_pXMLDoc == NULL || m_ePacketID == XFA_XDPPACKET_UNKNOWN) { + return XFA_PARSESTATUS_StatusErr; + } + int32_t iRet = m_pXMLDoc->DoLoad(pPause); + if (iRet < 0) { + return XFA_PARSESTATUS_SyntaxErr; + } + if (iRet < 100) { + return iRet / 2; + } + m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc), + m_ePacketID); + m_pXMLDoc->CloseXML(); + if (m_pStream) { + m_pStream->Release(); + m_pStream = NULL; + } + if (!m_pRootNode) { + return XFA_PARSESTATUS_StatusErr; + } + return XFA_PARSESTATUS_Done; +} +int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, + IFDE_XMLNode*& pXMLNode, + IFX_Pause* pPause) { + CloseParser(); + pXMLNode = NULL; + IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML); + if (!pStream) { + return XFA_PARSESTATUS_StreamErr; + } + m_pStream = pStream; + m_pXMLDoc = IFDE_XMLDoc::Create(); + if (m_pXMLDoc == NULL) { + return XFA_PARSESTATUS_StatusErr; + } + CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); + if (pParser == NULL) { + return XFA_PARSESTATUS_StatusErr; + } + + pParser->m_dwCheckStatus = 0x03; + if (!m_pXMLDoc->LoadXML(pParser)) { + return XFA_PARSESTATUS_StatusErr; + } + int32_t iRet = m_pXMLDoc->DoLoad(pPause); + if (iRet < 0 || iRet >= 100) { + m_pXMLDoc->CloseXML(); + } + if (iRet < 0) { + return XFA_PARSESTATUS_SyntaxErr; + } + if (iRet < 100) { + return iRet / 2; + } + if (m_pStream) { + m_pStream->Release(); + m_pStream = NULL; + } + pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); + return XFA_PARSESTATUS_Done; +} + +void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode) { + XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); + if (ePacketID == XFA_XDPPACKET_Datasets) { + if (pXFANode->GetClassID() == XFA_ELEMENT_DataValue) { + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FDE_XMLNODE_Instruction) + continue; + + if (eNodeType == FDE_XMLNODE_Element) { + CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, + XFA_ELEMENT_DataValue); + if (!pXFAChild) + return; + + CFX_WideString wsNodeStr; + ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); + pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); + CFX_WideString wsChildValue; + XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, + wsChildValue); + if (!wsChildValue.IsEmpty()) + pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsChildValue); + + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLChild); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + break; + } + } + m_pRootNode = pXFANode; + } else { + m_pRootNode = DataLoader(pXFANode, pXMLNode, TRUE); + } + } else if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { + ParseContentNode(pXFANode, pXMLNode, ePacketID); + m_pRootNode = pXFANode; + } else { + m_pRootNode = NormalLoader(pXFANode, pXMLNode, ePacketID); + } +} + +FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( + IFDE_XMLElement* pNode, + const CFX_WideStringC& wsQualifier, + CFX_WideString& wsNamespaceURI) { + if (!pNode) { + return FALSE; + } + IFDE_XMLNode* pFakeRoot = pNode->GetNodeItem(IFDE_XMLNode::Root); + CFX_WideString wsNSAttribute; + FX_BOOL bRet = FALSE; + if (wsQualifier.IsEmpty()) { + wsNSAttribute = FX_WSTRC(L"xmlns"); + bRet = TRUE; + } else { + wsNSAttribute = FX_WSTRC(L"xmlns:") + wsQualifier; + } + for (; pNode != pFakeRoot; + pNode = (IFDE_XMLElement*)pNode->GetNodeItem(IFDE_XMLNode::Parent)) { + if (pNode->GetType() != FDE_XMLNODE_Element) { + continue; + } + if (pNode->HasAttribute(wsNSAttribute)) { + pNode->GetString(wsNSAttribute, wsNamespaceURI); + return TRUE; + } + } + wsNamespaceURI.Empty(); + return bRet; +} +static inline void XFA_FDEExtension_GetElementTagNamespaceURI( + IFDE_XMLElement* pElement, + CFX_WideString& wsNamespaceURI) { + CFX_WideString wsNodeStr; + pElement->GetNamespacePrefix(wsNodeStr); + if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNodeStr, + wsNamespaceURI)) { + wsNamespaceURI.Empty(); + } +} +static FX_BOOL XFA_FDEExtension_MatchNodeName( + IFDE_XMLNode* pNode, + const CFX_WideStringC& wsLocalTagName, + const CFX_WideStringC& wsNamespaceURIPrefix, + FX_DWORD eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { + if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) { + return FALSE; + } + IFDE_XMLElement* pElement = reinterpret_cast<IFDE_XMLElement*>(pNode); + CFX_WideString wsNodeStr; + pElement->GetLocalTagName(wsNodeStr); + if (wsNodeStr != wsLocalTagName) { + return FALSE; + } + XFA_FDEExtension_GetElementTagNamespaceURI(pElement, wsNodeStr); + if (eMatchFlags & XFA_XDPPACKET_FLAGS_NOMATCH) { + return TRUE; + } + if (eMatchFlags & XFA_XDPPACKET_FLAGS_PREFIXMATCH) { + return wsNodeStr.Left(wsNamespaceURIPrefix.GetLength()) == + wsNamespaceURIPrefix; + } + return wsNodeStr == wsNamespaceURIPrefix; +} +static FX_BOOL XFA_FDEExtension_GetAttributeLocalName( + const CFX_WideStringC& wsAttributeName, + CFX_WideString& wsLocalAttrName) { + CFX_WideString wsAttrName(wsAttributeName); + FX_STRSIZE iFind = wsAttrName.Find(L':', 0); + if (iFind < 0) { + wsLocalAttrName = wsAttrName; + return FALSE; + } else { + wsLocalAttrName = wsAttrName.Right(wsAttrName.GetLength() - iFind - 1); + return TRUE; + } +} +static FX_BOOL XFA_FDEExtension_ResolveAttribute( + IFDE_XMLElement* pElement, + const CFX_WideStringC& wsAttributeName, + CFX_WideString& wsLocalAttrName, + CFX_WideString& wsNamespaceURI) { + CFX_WideString wsAttrName(wsAttributeName); + CFX_WideString wsNSPrefix; + if (XFA_FDEExtension_GetAttributeLocalName(wsAttributeName, + wsLocalAttrName)) { + wsNSPrefix = wsAttrName.Left(wsAttributeName.GetLength() - + wsLocalAttrName.GetLength() - 1); + } + if (wsLocalAttrName == FX_WSTRC(L"xmlns") || + wsNSPrefix == FX_WSTRC(L"xmlns") || wsNSPrefix == FX_WSTRC(L"xml")) { + return FALSE; + } + if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix, + wsNamespaceURI)) { + wsNamespaceURI.Empty(); + return FALSE; + } + return TRUE; +} +static FX_BOOL XFA_FDEExtension_FindAttributeWithNS( + IFDE_XMLElement* pElement, + const CFX_WideStringC& wsLocalAttributeName, + const CFX_WideStringC& wsNamespaceURIPrefix, + CFX_WideString& wsValue, + FX_BOOL bMatchNSAsPrefix = FALSE) { + if (!pElement) { + return FALSE; + } + CFX_WideString wsAttrName; + CFX_WideString wsAttrValue; + CFX_WideString wsAttrNS; + for (int32_t iAttrCount = pElement->CountAttributes(), i = 0; i < iAttrCount; + i++) { + pElement->GetAttribute(i, wsAttrName, wsAttrValue); + FX_STRSIZE iFind = wsAttrName.Find(L':', 0); + CFX_WideString wsNSPrefix; + if (iFind < 0) { + if (wsLocalAttributeName != wsAttrName) { + continue; + } + } else { + if (wsLocalAttributeName != + wsAttrName.Right(wsAttrName.GetLength() - iFind - 1)) { + continue; + } + wsNSPrefix = wsAttrName.Left(iFind); + } + if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix, + wsAttrNS)) { + continue; + } + if (bMatchNSAsPrefix) { + if (wsAttrNS.Left(wsNamespaceURIPrefix.GetLength()) != + wsNamespaceURIPrefix) { + continue; + } + } else { + if (wsAttrNS != wsNamespaceURIPrefix) { + continue; + } + } + wsValue = wsAttrValue; + return TRUE; + } + return FALSE; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + switch (ePacketID) { + case XFA_XDPPACKET_UNKNOWN: + return NULL; + case XFA_XDPPACKET_XDP: + return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID); + case XFA_XDPPACKET_Config: + return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID); + case XFA_XDPPACKET_Template: + case XFA_XDPPACKET_Form: + return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID); + case XFA_XDPPACKET_Datasets: + return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID); + case XFA_XDPPACKET_Xdc: + return ParseAsXDPPacket_Xdc(pXMLDocumentNode, ePacketID); + case XFA_XDPPACKET_LocaleSet: + case XFA_XDPPACKET_ConnectionSet: + case XFA_XDPPACKET_SourceSet: + return ParseAsXDPPacket_LocaleConnectionSourceSet(pXMLDocumentNode, + ePacketID); + default: + return ParseAsXDPPacket_User(pXMLDocumentNode, ePacketID); + } + return NULL; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + if (!XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, + XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { + return nullptr; + } + CXFA_Node* pXFARootNode = + m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Xfa); + if (!pXFARootNode) { + return nullptr; + } + m_pRootNode = pXFARootNode; + pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"xfa")); + { + IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLDocumentNode; + int32_t iAttributeCount = pElement->CountAttributes(); + for (int32_t i = 0; i < iAttributeCount; i++) { + CFX_WideString wsAttriName, wsAttriValue; + pElement->GetAttribute(i, wsAttriName, wsAttriValue); + if (wsAttriName == FX_WSTRC(L"uuid")) { + pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, wsAttriValue); + } else if (wsAttriName == FX_WSTRC(L"timeStamp")) { + pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, wsAttriValue); + } + } + } + IFDE_XMLNode* pXMLConfigDOMRoot = nullptr; + CXFA_Node* pXFAConfigDOMRoot = nullptr; + { + for (IFDE_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pChildItem; + pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { + const XFA_PACKETINFO* pPacketInfo = + XFA_GetPacketByIndex(XFA_PACKET_Config); + if (!XFA_FDEExtension_MatchNodeName(pChildItem, pPacketInfo->pName, + pPacketInfo->pURI, + pPacketInfo->eFlags)) { + continue; + } + if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { + return nullptr; + } + pXMLConfigDOMRoot = pChildItem; + pXFAConfigDOMRoot = + ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config); + pXFARootNode->InsertChild(pXFAConfigDOMRoot, NULL); + } + } + IFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; + IFDE_XMLNode* pXMLFormDOMRoot = nullptr; + IFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; + { + for (IFDE_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pChildItem; + pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element) { + continue; + } + if (pChildItem == pXMLConfigDOMRoot) { + continue; + } + IFDE_XMLElement* pElement = + reinterpret_cast<IFDE_XMLElement*>(pChildItem); + CFX_WideString wsPacketName; + pElement->GetLocalTagName(wsPacketName); + const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByName(wsPacketName); + if (pPacketInfo && pPacketInfo->pURI) { + if (!XFA_FDEExtension_MatchNodeName(pElement, pPacketInfo->pName, + pPacketInfo->pURI, + pPacketInfo->eFlags)) { + pPacketInfo = nullptr; + } + } + XFA_XDPPACKET ePacket = + pPacketInfo ? pPacketInfo->eName : XFA_XDPPACKET_USER; + if (ePacket == XFA_XDPPACKET_XDP) { + continue; + } + if (ePacket == XFA_XDPPACKET_Datasets) { + if (pXMLDatasetsDOMRoot) { + return nullptr; + } + pXMLDatasetsDOMRoot = pElement; + } else if (ePacket == XFA_XDPPACKET_Form) { + if (pXMLFormDOMRoot) { + return nullptr; + } + pXMLFormDOMRoot = pElement; + } else if (ePacket == XFA_XDPPACKET_Template) { + if (pXMLTemplateDOMRoot) { + // Found a duplicate template packet. + return nullptr; + } + CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket); + if (pPacketNode) { + pXMLTemplateDOMRoot = pElement; + pXFARootNode->InsertChild(pPacketNode); + } + } else { + CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket); + if (pPacketNode) { + if (pPacketInfo && + (pPacketInfo->eFlags & XFA_XDPPACKET_FLAGS_SUPPORTONE) && + pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { + return nullptr; + } + pXFARootNode->InsertChild(pPacketNode); + } + } + } + } + if (!pXMLTemplateDOMRoot) { + // No template is found. + return nullptr; + } + if (pXMLDatasetsDOMRoot) { + CXFA_Node* pPacketNode = + ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_XDPPACKET_Datasets); + if (pPacketNode) { + pXFARootNode->InsertChild(pPacketNode); + } + } + if (pXMLFormDOMRoot) { + CXFA_Node* pPacketNode = + ParseAsXDPPacket(pXMLFormDOMRoot, XFA_XDPPACKET_Form); + if (pPacketNode) { + pXFARootNode->InsertChild(pPacketNode); + } + } + pXFARootNode->SetXMLMappingNode(pXMLDocumentNode); + return pXFARootNode; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + if (!XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) { + return NULL; + } + CXFA_Node* pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_ELEMENT_Config); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_Config)->pName); + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { + return NULL; + } + pNode->SetXMLMappingNode(pXMLDocumentNode); + return pNode; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + CXFA_Node* pNode = NULL; + if (ePacketID == XFA_XDPPACKET_Template) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) { + pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_ELEMENT_Template); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); + if (m_bDocumentParser) { + CFX_WideString wsNamespaceURI; + IFDE_XMLElement* pXMLDocumentElement = + (IFDE_XMLElement*)pXMLDocumentNode; + pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); + if (wsNamespaceURI.IsEmpty()) { + pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); + } + pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); + } + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { + return NULL; + } + } + } else if (ePacketID == XFA_XDPPACKET_Form) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { + IFDE_XMLElement* pXMLDocumentElement = (IFDE_XMLElement*)pXMLDocumentNode; + CFX_WideString wsChecksum; + pXMLDocumentElement->GetString(L"checksum", wsChecksum); + if (wsChecksum.GetLength() != 28 || + m_pXMLParser->m_dwCheckStatus != 0x03) { + return NULL; + } + IXFA_ChecksumContext* pChecksum = XFA_Checksum_Create(); + pChecksum->StartChecksum(); + pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], + m_pXMLParser->m_nSize[0]); + pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], + m_pXMLParser->m_nSize[1]); + pChecksum->FinishChecksum(); + CFX_ByteString bsCheck; + pChecksum->GetChecksum(bsCheck); + pChecksum->Release(); + if (bsCheck != wsChecksum.UTF8Encode()) { + return NULL; + } + + pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_Form)->pName); + pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum); + CXFA_Node* pTemplateRoot = + m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); + CXFA_Node* pTemplateChosen = + pTemplateRoot + ? pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform) + : NULL; + FX_BOOL bUseAttribute = TRUE; + if (pTemplateChosen && + pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) != + XFA_ATTRIBUTEENUM_Auto) { + bUseAttribute = FALSE; + } + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) { + return NULL; + } + } + } + if (pNode) { + pNode->SetXMLMappingNode(pXMLDocumentNode); + } + return pNode; +} +static IFDE_XMLNode* XFA_GetDataSetsFromXDP(IFDE_XMLNode* pXMLDocumentNode) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { + return pXMLDocumentNode; + } + if (!XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, + XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { + return NULL; + } + for (IFDE_XMLNode* pDatasetsNode = + pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pDatasetsNode; + pDatasetsNode = pDatasetsNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + if (!XFA_FDEExtension_MatchNodeName( + pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { + continue; + } + return pDatasetsNode; + } + return NULL; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + IFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); + if (pDatasetsXMLNode) { + CXFA_Node* pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName); + if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) { + return NULL; + } + pNode->SetXMLMappingNode(pDatasetsXMLNode); + return pNode; + } + IFDE_XMLNode* pDataXMLNode = NULL; + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, FX_WSTRC(L"data"), + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { + ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); + pDataXMLNode = pXMLDocumentNode; + } else { + IFDE_XMLElement* pDataElement = + IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); + IFDE_XMLNode* pParentXMLNode = + pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::Parent); + if (pParentXMLNode) { + pParentXMLNode->RemoveChildNode(pXMLDocumentNode); + } + FXSYS_assert(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); + if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { + ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); + } + pDataElement->InsertChildNode(pXMLDocumentNode); + pDataXMLNode = pDataElement; + } + if (pDataXMLNode) { + CXFA_Node* pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); + if (!pNode) { + if (pDataXMLNode != pXMLDocumentNode) { + pDataXMLNode->Release(); + } + return NULL; + } + CFX_WideString wsLocalName; + ((IFDE_XMLElement*)pDataXMLNode)->GetLocalTagName(wsLocalName); + pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); + if (!DataLoader(pNode, pDataXMLNode, TRUE)) { + return NULL; + } + pNode->SetXMLMappingNode(pDataXMLNode); + if (pDataXMLNode != pXMLDocumentNode) { + pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); + } + return pNode; + } + return NULL; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + CXFA_Node* pNode = NULL; + if (ePacketID == XFA_XDPPACKET_LocaleSet) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName, + XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) { + pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet, + XFA_ELEMENT_LocaleSet); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName); + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { + return NULL; + } + } + } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, + XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName, + XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) { + pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet, + XFA_ELEMENT_ConnectionSet); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName); + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { + return NULL; + } + } + } else if (ePacketID == XFA_XDPPACKET_SourceSet) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName, + XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) { + pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet, + XFA_ELEMENT_SourceSet); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName); + if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { + return NULL; + } + } + } + if (pNode) { + pNode->SetXMLMappingNode(pXMLDocumentNode); + } + return pNode; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + if (XFA_FDEExtension_MatchNodeName( + pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, + XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI, + XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) { + CXFA_Node* pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_ELEMENT_Xdc); + if (!pNode) { + return NULL; + } + pNode->SetCData(XFA_ATTRIBUTE_Name, + XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName); + pNode->SetXMLMappingNode(pXMLDocumentNode); + return pNode; + } + return NULL; +} +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID) { + CXFA_Node* pNode = + m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Packet); + if (!pNode) { + return NULL; + } + CFX_WideString wsName; + ((IFDE_XMLElement*)pXMLDocumentNode)->GetLocalTagName(wsName); + pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); + if (!UserPacketLoader(pNode, pXMLDocumentNode)) { + return NULL; + } + pNode->SetXMLMappingNode(pXMLDocumentNode); + return pNode; +} +CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLDoc) { + return pXFANode; +} +static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { + wsText.TrimRight(L"\x20\x9\xD\xA"); + return wsText.IsEmpty(); +} +CXFA_Node* CXFA_SimpleParser::DataLoader(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLDoc, + FX_BOOL bDoTransform) { + ParseDataGroup(pXFANode, pXMLDoc, XFA_XDPPACKET_Datasets); + return pXFANode; +} +CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLDoc, + XFA_XDPPACKET ePacketID, + FX_BOOL bUseAttribute) { + FX_BOOL bOneOfPropertyFound = FALSE; + for (IFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + switch (pXMLChild->GetType()) { + case FDE_XMLNODE_Element: { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + CFX_WideString wsTagName; + pXMLElement->GetLocalTagName(wsTagName); + const XFA_ELEMENTINFO* pElemInfo = XFA_GetElementByName(wsTagName); + if (!pElemInfo) { + continue; + } + const XFA_PROPERTY* pPropertyInfo = XFA_GetPropertyOfElement( + pXFANode->GetClassID(), pElemInfo->eName, ePacketID); + if (pPropertyInfo && + ((pPropertyInfo->uFlags & + (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { + if (bOneOfPropertyFound) { + break; + } + bOneOfPropertyFound = TRUE; + } + CXFA_Node* pXFAChild = + m_pFactory->CreateNode(ePacketID, pElemInfo->eName); + if (pXFAChild == NULL) { + return NULL; + } + if (ePacketID == XFA_XDPPACKET_Config) { + pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName); + } + FX_BOOL IsNeedValue = TRUE; + for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; + i++) { + CFX_WideString wsAttrQualifiedName; + CFX_WideString wsAttrName; + CFX_WideString wsAttrValue; + pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); + XFA_FDEExtension_GetAttributeLocalName(wsAttrQualifiedName, + wsAttrName); + if (wsAttrName == FX_WSTRC(L"nil") && + wsAttrValue == FX_WSTRC(L"true")) { + IsNeedValue = FALSE; + } + const XFA_ATTRIBUTEINFO* lpAttrInfo = + XFA_GetAttributeByName(wsAttrName); + if (!lpAttrInfo) { + continue; + } + if (!bUseAttribute && lpAttrInfo->eName != XFA_ATTRIBUTE_Name && + lpAttrInfo->eName != XFA_ATTRIBUTE_Save) { + continue; + } + pXFAChild->SetAttribute(lpAttrInfo->eName, wsAttrValue); + } + pXFANode->InsertChild(pXFAChild); + if (pElemInfo->eName == XFA_ELEMENT_Validate || + pElemInfo->eName == XFA_ELEMENT_Locale) { + if (ePacketID == XFA_XDPPACKET_Config) { + ParseContentNode(pXFAChild, pXMLElement, ePacketID); + } else { + NormalLoader(pXFAChild, pXMLElement, ePacketID, bUseAttribute); + } + break; + } + switch (pXFAChild->GetObjectType()) { + case XFA_OBJECTTYPE_ContentNode: + case XFA_OBJECTTYPE_TextNode: + case XFA_OBJECTTYPE_NodeC: + case XFA_OBJECTTYPE_NodeV: + if (IsNeedValue) { + ParseContentNode(pXFAChild, pXMLElement, ePacketID); + } + break; + default: + NormalLoader(pXFAChild, pXMLElement, ePacketID, bUseAttribute); + break; + } + } break; + case FDE_XMLNODE_Instruction: + ParseInstruction(pXFANode, (IFDE_XMLInstruction*)pXMLChild, ePacketID); + break; + default: + break; + } + } + return pXFANode; +} +FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { + if (pRichTextXMLNode) { + CFX_WideString wsNamespaceURI; + XFA_FDEExtension_GetElementTagNamespaceURI(pRichTextXMLNode, + wsNamespaceURI); + if (wsNamespaceURI == FX_WSTRC(L"http://www.w3.org/1999/xhtml")) { + return TRUE; + } + } + return FALSE; +} +class RichTextNodeVisitor { + public: + static inline IFDE_XMLNode* GetFirstChild(IFDE_XMLNode* pNode) { + return pNode->GetNodeItem(IFDE_XMLNode::FirstChild); + } + static inline IFDE_XMLNode* GetNextSibling(IFDE_XMLNode* pNode) { + return pNode->GetNodeItem(IFDE_XMLNode::NextSibling); + } + static inline IFDE_XMLNode* GetParent(IFDE_XMLNode* pNode) { + return pNode->GetNodeItem(IFDE_XMLNode::Parent); + } +}; + +void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, + CFX_WideString& wsOutput) { + for (IFDE_XMLNode* pXMLChild = + pRootXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + switch (pXMLChild->GetType()) { + case FDE_XMLNODE_Element: { + CFX_WideString wsTextData; + ((IFDE_XMLElement*)pXMLChild)->GetTextData(wsTextData); + wsTextData += FX_WSTRC(L"\n"); + wsOutput += wsTextData; + } break; + case FDE_XMLNODE_Text: { + CFX_WideString wsText; + ((IFDE_XMLText*)pXMLChild)->GetText(wsText); + if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { + continue; + } else { + wsOutput = wsText; + } + } break; + case FDE_XMLNODE_CharData: { + CFX_WideString wsCharData; + ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsCharData); + if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { + continue; + } else { + wsOutput = wsCharData; + } + } break; + default: + FXSYS_assert(FALSE); + break; + } + } +} + +void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID) { + XFA_ELEMENT element = XFA_ELEMENT_Sharptext; + if (pXFANode->GetClassID() == XFA_ELEMENT_ExData) { + CFX_WideStringC wsContentType = + pXFANode->GetCData(XFA_ATTRIBUTE_ContentType); + if (wsContentType == FX_WSTRC(L"text/html")) + element = XFA_ELEMENT_SharpxHTML; + else if (wsContentType == FX_WSTRC(L"text/xml")) + element = XFA_ELEMENT_Sharpxml; + } + if (element == XFA_ELEMENT_SharpxHTML) + pXFANode->SetXMLMappingNode(pXMLNode); + + CFX_WideString wsValue; + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FDE_XMLNODE_Instruction) + continue; + + if (element == XFA_ELEMENT_SharpxHTML) { + if (eNodeType != FDE_XMLNODE_Element) + break; + + if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) + XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsValue); + } else if (element == XFA_ELEMENT_Sharpxml) { + if (eNodeType != FDE_XMLNODE_Element) + break; + XFA_ConvertXMLToPlainText((IFDE_XMLElement*)pXMLChild, wsValue); + } else { + if (eNodeType == FDE_XMLNODE_Element) + break; + if (eNodeType == FDE_XMLNODE_Text) + ((IFDE_XMLText*)pXMLChild)->GetText(wsValue); + else if (eNodeType == FDE_XMLNODE_CharData) + ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsValue); + } + break; + } + if (!wsValue.IsEmpty()) { + if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { + CXFA_Node* pContentRawDataNode = + m_pFactory->CreateNode(ePacketID, element); + FXSYS_assert(pContentRawDataNode); + pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsValue); + pXFANode->InsertChild(pContentRawDataNode); + } else { + pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsValue); + } + } +} + +void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID) { + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + switch (pXMLChild->GetType()) { + case FDE_XMLNODE_Element: { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + { + CFX_WideString wsNamespaceURI; + XFA_FDEExtension_GetElementTagNamespaceURI(pXMLElement, + wsNamespaceURI); + if (wsNamespaceURI == + FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || + wsNamespaceURI == + FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || + wsNamespaceURI == + FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance")) { + continue; + } + if (0) { + continue; + } + } + XFA_ELEMENT eNodeType = XFA_ELEMENT_DataModel; + if (eNodeType == XFA_ELEMENT_DataModel) { + CFX_WideString wsDataNodeAttr; + if (XFA_FDEExtension_FindAttributeWithNS( + pXMLElement, FX_WSTRC(L"dataNode"), + FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"), + wsDataNodeAttr)) { + if (wsDataNodeAttr == FX_WSTRC(L"dataGroup")) { + eNodeType = XFA_ELEMENT_DataGroup; + } else if (wsDataNodeAttr == FX_WSTRC(L"dataValue")) { + eNodeType = XFA_ELEMENT_DataValue; + } + } + } + CFX_WideString wsContentType; + if (eNodeType == XFA_ELEMENT_DataModel) { + if (XFA_FDEExtension_FindAttributeWithNS( + pXMLElement, FX_WSTRC(L"contentType"), + FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"), + wsContentType)) { + if (!wsContentType.IsEmpty()) { + eNodeType = XFA_ELEMENT_DataValue; + } + } + } + if (eNodeType == XFA_ELEMENT_DataModel) { + for (IFDE_XMLNode* pXMLDataChild = + pXMLElement->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem( + IFDE_XMLNode::NextSibling)) { + if (pXMLDataChild->GetType() == FDE_XMLNODE_Element) { + if (!XFA_RecognizeRichText((IFDE_XMLElement*)pXMLDataChild)) { + eNodeType = XFA_ELEMENT_DataGroup; + break; + } + } + } + } + if (eNodeType == XFA_ELEMENT_DataModel) { + eNodeType = XFA_ELEMENT_DataValue; + } + CXFA_Node* pXFAChild = + m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); + if (pXFAChild == NULL) { + return; + } + CFX_WideString wsNodeName; + pXMLElement->GetLocalTagName(wsNodeName); + pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); + FX_BOOL bNeedValue = TRUE; + if (1) { + for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; + i++) { + CFX_WideString wsAttrQualifiedName; + CFX_WideString wsAttrValue; + CFX_WideString wsAttrName; + CFX_WideString wsAttrNamespaceURI; + pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); + if (!XFA_FDEExtension_ResolveAttribute( + pXMLElement, wsAttrQualifiedName, wsAttrName, + wsAttrNamespaceURI)) { + continue; + } + if (wsAttrName == FX_WSTRC(L"nil") && + wsAttrValue == FX_WSTRC(L"true")) { + bNeedValue = FALSE; + continue; + } + if (wsAttrNamespaceURI == + FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || + wsAttrNamespaceURI == + FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || + wsAttrNamespaceURI == + FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || + wsAttrNamespaceURI == + FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { + continue; + } + if (0) { + continue; + } + CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( + XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataValue); + if (pXFAMetaData == NULL) { + return; + } + pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); + pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, + wsAttrQualifiedName); + pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); + pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, + XFA_ATTRIBUTEENUM_MetaData); + pXFAChild->InsertChild(pXFAMetaData); + pXFAMetaData->SetXMLMappingNode(pXMLElement); + pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + } + if (!bNeedValue) { + CFX_WideString wsNilName = FX_WSTRC(L"xsi:nil"); + pXMLElement->RemoveAttribute(wsNilName); + } + } + pXFANode->InsertChild(pXFAChild); + if (eNodeType == XFA_ELEMENT_DataGroup) { + ParseDataGroup(pXFAChild, pXMLElement, ePacketID); + } else { + if (bNeedValue) { + ParseDataValue(pXFAChild, pXMLChild, XFA_XDPPACKET_Datasets); + } + } + pXFAChild->SetXMLMappingNode(pXMLElement); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + } + continue; + case FDE_XMLNODE_CharData: { + IFDE_XMLCharData* pXMLCharData = (IFDE_XMLCharData*)pXMLChild; + CFX_WideString wsCharData; + pXMLCharData->GetCharData(wsCharData); + if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { + continue; + } + CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, + XFA_ELEMENT_DataValue); + if (pXFAChild == NULL) { + return; + } + pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLCharData); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + } + continue; + case FDE_XMLNODE_Text: { + IFDE_XMLText* pXMLText = (IFDE_XMLText*)pXMLChild; + CFX_WideString wsText; + pXMLText->GetText(wsText); + if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { + continue; + } + CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, + XFA_ELEMENT_DataValue); + if (pXFAChild == NULL) { + return; + } + pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLText); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + } + continue; + case FDE_XMLNODE_Instruction: + continue; + default: + continue; + } + } +} + +void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID) { + CFX_WideTextBuf wsValueTextBuf; + CFX_WideTextBuf wsCurValueTextBuf; + FX_BOOL bMarkAsCompound = FALSE; + IFDE_XMLNode* pXMLCurValueNode = nullptr; + for (IFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FDE_XMLNODE_Instruction) + continue; + + CFX_WideString wsText; + if (eNodeType == FDE_XMLNODE_Text) { + ((IFDE_XMLText*)pXMLChild)->GetText(wsText); + if (!pXMLCurValueNode) + pXMLCurValueNode = pXMLChild; + + wsCurValueTextBuf << wsText; + } else if (eNodeType == FDE_XMLNODE_CharData) { + ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsText); + if (!pXMLCurValueNode) + pXMLCurValueNode = pXMLChild; + + wsCurValueTextBuf << wsText; + } else if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) { + XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsText); + if (!pXMLCurValueNode) + pXMLCurValueNode = pXMLChild; + + wsCurValueTextBuf << wsText; + } else { + bMarkAsCompound = TRUE; + if (pXMLCurValueNode) { + CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); + 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_Value, wsCurValue); + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLCurValueNode); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + wsValueTextBuf << wsCurValue; + wsCurValueTextBuf.Clear(); + } + pXMLCurValueNode = nullptr; + } + CXFA_Node* pXFAChild = + m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); + if (!pXFAChild) + return; + + CFX_WideString wsNodeStr; + ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); + pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); + ParseDataValue(pXFAChild, pXMLChild, ePacketID); + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLChild); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + CFX_WideStringC wsCurValue = pXFAChild->GetCData(XFA_ATTRIBUTE_Value); + wsValueTextBuf << wsCurValue; + } + } + if (pXMLCurValueNode) { + CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); + if (!wsCurValue.IsEmpty()) { + if (bMarkAsCompound) { + 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_Value, wsCurValue); + pXFANode->InsertChild(pXFAChild); + pXFAChild->SetXMLMappingNode(pXMLCurValueNode); + pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); + } + wsValueTextBuf << wsCurValue; + wsCurValueTextBuf.Clear(); + } + pXMLCurValueNode = nullptr; + } + CFX_WideStringC wsNodeValue = wsValueTextBuf.GetWideString(); + pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue); +} + +void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, + IFDE_XMLInstruction* pXMLInstruction, + XFA_XDPPACKET ePacketID) { + if (!m_bDocumentParser) { + return; + } + CFX_WideString wsTargetName; + pXMLInstruction->GetTargetName(wsTargetName); + if (wsTargetName == FX_WSTRC(L"originalXFAVersion")) { + CFX_WideString wsData; + if (pXMLInstruction->GetData(0, wsData) && + (pXFANode->GetDocument()->RecognizeXFAVersionNumber(wsData) != + XFA_VERSION_UNKNOWN)) { + wsData.Empty(); + if (pXMLInstruction->GetData(1, wsData) && + wsData == FX_WSTRC(L"v2.7-scripting:1")) { + pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, TRUE); + } + } + } else if (wsTargetName == FX_WSTRC(L"acrobat")) { + CFX_WideString wsData; + if (pXMLInstruction->GetData(0, wsData) && + wsData == FX_WSTRC(L"JavaScript")) { + if (pXMLInstruction->GetData(1, wsData) && + wsData == FX_WSTRC(L"strictScoping")) { + pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); + } + } + } +} +void CXFA_SimpleParser::CloseParser() { + if (m_pXMLDoc) { + m_pXMLDoc->Release(); + m_pXMLDoc = NULL; + } + if (m_pStream) { + m_pStream->Release(); + m_pStream = NULL; + } +} +IXFA_DocParser* IXFA_DocParser::Create(IXFA_Notify* pNotify) { + return new CXFA_DocumentParser(pNotify); +} +CXFA_DocumentParser::CXFA_DocumentParser(IXFA_Notify* pNotify) + : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} +CXFA_DocumentParser::~CXFA_DocumentParser() { + CloseParser(); +} +int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID) { + CloseParser(); + int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); + if (nRetStatus == XFA_PARSESTATUS_Ready) { + m_pDocument = new CXFA_Document(this); + m_nodeParser.SetFactory(m_pDocument); + } + return nRetStatus; +} +int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { + int32_t nRetStatus = m_nodeParser.DoParse(pPause); + if (nRetStatus >= XFA_PARSESTATUS_Done) { + FXSYS_assert(m_pDocument); + m_pDocument->SetRoot(m_nodeParser.GetRootNode()); + } + return nRetStatus; +} +int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, + IFDE_XMLNode*& pXMLNode, + IFX_Pause* pPause) { + CloseParser(); + int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); + if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { + m_pDocument = new CXFA_Document(this); + m_nodeParser.SetFactory(m_pDocument); + } + return nRetStatus; +} +void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode) { + if (!pXFANode || !pXMLNode) { + return; + } + m_nodeParser.ConstructXFANode(pXFANode, pXMLNode); + CXFA_Node* pRootNode = m_nodeParser.GetRootNode(); + if (m_pDocument && pRootNode) { + m_pDocument->SetRoot(pRootNode); + } +} +void CXFA_DocumentParser::CloseParser() { + if (m_pDocument) { + delete m_pDocument; + m_pDocument = NULL; + } + m_nodeParser.CloseParser(); +} +CXFA_XMLParser::CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream) + : m_nElementStart(0), + m_dwCheckStatus(0), + m_dwCurrentCheckStatus(0), + m_pRoot(pRoot), + m_pStream(pStream), + m_pParser(nullptr), + m_pParent(pRoot), + m_pChild(nullptr), + m_NodeStack(16), + m_dwStatus(FDE_XMLSYNTAXSTATUS_None) { + ASSERT(m_pParent && m_pStream); + m_NodeStack.Push(m_pParent); + m_pParser = IFDE_XMLSyntaxParser::Create(); + m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); +} +CXFA_XMLParser::~CXFA_XMLParser() { + if (m_pParser) { + m_pParser->Release(); + } + m_NodeStack.RemoveAll(); + m_ws1.Empty(); + m_ws2.Empty(); +} +int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) { + return -1; + } + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { + return 100; + } + int32_t iCount = 0; + while (TRUE) { + m_dwStatus = m_pParser->DoSyntaxParse(); + switch (m_dwStatus) { + case FDE_XMLSYNTAXSTATUS_InstructionOpen: + break; + case FDE_XMLSYNTAXSTATUS_InstructionClose: + if (m_pChild) { + if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + break; + } + } + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_ElementOpen: + if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 2) { + m_nElementStart = m_pParser->GetCurrentPos() - 1; + } + break; + case FDE_XMLSYNTAXSTATUS_ElementBreak: + break; + case FDE_XMLSYNTAXSTATUS_ElementClose: + if (m_pChild->GetType() != FDE_XMLNODE_Element) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_pParser->GetTagName(m_ws1); + ((IFDE_XMLElement*)m_pChild)->GetTagName(m_ws2); + if (m_ws1.GetLength() > 0 && !m_ws1.Equal(m_ws2)) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + break; + } + m_NodeStack.Pop(); + if (m_NodeStack.GetSize() < 1) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + break; + } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.GetSize() == 2) { + m_nSize[m_dwCurrentCheckStatus - 1] = + m_pParser->GetCurrentBinaryPos() - + m_nStart[m_dwCurrentCheckStatus - 1]; + m_dwCurrentCheckStatus = 0; + } + + m_pParent = (IFDE_XMLNode*)*m_NodeStack.GetTopElement(); + m_pChild = m_pParent; + iCount++; + break; + case FDE_XMLSYNTAXSTATUS_TargetName: + m_pParser->GetTargetName(m_ws1); + if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || + m_ws1 == FX_WSTRC(L"acrobat")) { + m_pChild = IFDE_XMLInstruction::Create(m_ws1); + m_pParent->InsertChildNode(m_pChild); + } else { + m_pChild = NULL; + } + m_ws1.Empty(); + break; + case FDE_XMLSYNTAXSTATUS_TagName: + m_pParser->GetTagName(m_ws1); + m_pChild = IFDE_XMLElement::Create(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_NodeStack.Push(m_pChild); + m_pParent = m_pChild; + + if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 3) { + CFX_WideString wsTag; + ((IFDE_XMLElement*)m_pChild)->GetLocalTagName(wsTag); + if (wsTag == FX_WSTRC(L"template")) { + m_dwCheckStatus |= 0x01; + m_dwCurrentCheckStatus = 0x01; + m_nStart[0] = m_pParser->GetCurrentBinaryPos() - + (m_pParser->GetCurrentPos() - m_nElementStart); + } else if (wsTag == FX_WSTRC(L"datasets")) { + m_dwCheckStatus |= 0x02; + m_dwCurrentCheckStatus = 0x02; + m_nStart[1] = m_pParser->GetCurrentBinaryPos() - + (m_pParser->GetCurrentPos() - m_nElementStart); + } + } + break; + case FDE_XMLSYNTAXSTATUS_AttriName: + m_pParser->GetAttributeName(m_ws1); + break; + case FDE_XMLSYNTAXSTATUS_AttriValue: + if (m_pChild) { + m_pParser->GetAttributeName(m_ws2); + if (m_pChild->GetType() == FDE_XMLNODE_Element) { + ((IFDE_XMLElement*)m_pChild)->SetString(m_ws1, m_ws2); + } + } + m_ws1.Empty(); + break; + case FDE_XMLSYNTAXSTATUS_Text: + m_pParser->GetTextData(m_ws1); + m_pChild = IFDE_XMLText::Create(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_CData: + m_pParser->GetTextData(m_ws1); + m_pChild = IFDE_XMLCharData::Create(m_ws1); + m_pParent->InsertChildNode(m_pChild); + m_pChild = m_pParent; + break; + case FDE_XMLSYNTAXSTATUS_TargetData: + if (m_pChild) { + if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { + m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; + break; + } + if (!m_ws1.IsEmpty()) { + ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + } + m_pParser->GetTargetData(m_ws1); + ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + } + m_ws1.Empty(); + break; + default: + break; + } + if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || + m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { + break; + } + if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { + break; + } + } + return (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || m_NodeStack.GetSize() != 1) + ? -1 + : m_pParser->GetStatus(); +} diff --git a/xfa/fxfa/parser/xfa_parser_imp.h b/xfa/fxfa/parser/xfa_parser_imp.h new file mode 100644 index 0000000000..136cae6744 --- /dev/null +++ b/xfa/fxfa/parser/xfa_parser_imp.h @@ -0,0 +1,138 @@ +// 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_PARSER_IMP_H_ +#define XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ + +#include "xfa/fxfa/parser/xfa_parser.h" + +class CXFA_XMLParser; + +class CXFA_SimpleParser : public IXFA_Parser { + public: + CXFA_SimpleParser(IXFA_ObjFactory* pFactory, FX_BOOL bDocumentParser = FALSE); + ~CXFA_SimpleParser(); + virtual void Release() { delete this; } + + virtual int32_t StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); + virtual int32_t DoParse(IFX_Pause* pPause = NULL); + virtual int32_t ParseXMLData(const CFX_WideString& wsXML, + IFDE_XMLNode*& pXMLNode, + IFX_Pause* pPause = NULL); + virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); + virtual IXFA_ObjFactory* GetFactory() const { return m_pFactory; } + virtual CXFA_Node* GetRootNode() const { return m_pRootNode; } + virtual IFDE_XMLDoc* GetXMLDoc() const { return m_pXMLDoc; } + virtual void CloseParser(); + + protected: + CXFA_Node* ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_XDP(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_Config(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_TemplateForm(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_Data(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet( + IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_Xdc(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* ParseAsXDPPacket_User(IFDE_XMLNode* pXMLDocumentNode, + XFA_XDPPACKET ePacketID); + CXFA_Node* NormalLoader(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLDoc, + XFA_XDPPACKET ePacketID, + FX_BOOL bUseAttribute = TRUE); + CXFA_Node* DataLoader(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLDoc, + FX_BOOL bDoTransform); + CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc); + void ParseContentNode(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID); + void ParseDataValue(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID); + void ParseDataGroup(CXFA_Node* pXFANode, + IFDE_XMLNode* pXMLNode, + XFA_XDPPACKET ePacketID); + void ParseInstruction(CXFA_Node* pXFANode, + IFDE_XMLInstruction* pXMLInstruction, + XFA_XDPPACKET ePacketID); + void SetFactory(IXFA_ObjFactory* pFactory); + + CXFA_XMLParser* m_pXMLParser; + IFDE_XMLDoc* m_pXMLDoc; + IFX_Stream* m_pStream; + IFX_FileRead* m_pFileRead; + IXFA_ObjFactory* m_pFactory; + CXFA_Node* m_pRootNode; + XFA_XDPPACKET m_ePacketID; + FX_BOOL m_bDocumentParser; + friend class CXFA_DocumentParser; +}; + +class CXFA_DocumentParser : public IXFA_DocParser { + public: + CXFA_DocumentParser(IXFA_Notify* pNotify); + ~CXFA_DocumentParser(); + virtual void Release() { delete this; } + virtual int32_t StartParse(IFX_FileRead* pStream, + XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); + virtual int32_t DoParse(IFX_Pause* pPause = NULL); + virtual int32_t ParseXMLData(const CFX_WideString& wsXML, + IFDE_XMLNode*& pXMLNode, + IFX_Pause* pPause = NULL); + virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); + virtual IXFA_ObjFactory* GetFactory() const { + return m_nodeParser.GetFactory(); + } + virtual CXFA_Node* GetRootNode() const { return m_nodeParser.GetRootNode(); } + virtual IFDE_XMLDoc* GetXMLDoc() const { return m_nodeParser.GetXMLDoc(); } + virtual IXFA_Notify* GetNotify() const { return m_pNotify; } + virtual CXFA_Document* GetDocument() const { return m_pDocument; } + virtual void CloseParser(); + + protected: + CXFA_SimpleParser m_nodeParser; + IXFA_Notify* m_pNotify; + CXFA_Document* m_pDocument; +}; +typedef CFX_StackTemplate<IFDE_XMLNode*> CXFA_XMLNodeStack; + +class CXFA_XMLParser : public IFDE_XMLParser { + public: + CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream); + ~CXFA_XMLParser(); + + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); + + FX_FILESIZE m_nStart[2]; + size_t m_nSize[2]; + FX_FILESIZE m_nElementStart; + FX_WORD m_dwCheckStatus; + FX_WORD m_dwCurrentCheckStatus; + + protected: + IFDE_XMLNode* m_pRoot; + IFX_Stream* m_pStream; + IFDE_XMLSyntaxParser* m_pParser; + + IFDE_XMLNode* m_pParent; + IFDE_XMLNode* m_pChild; + CXFA_XMLNodeStack m_NodeStack; + CFX_WideString m_ws1; + CFX_WideString m_ws2; + FX_DWORD m_dwStatus; +}; + +#endif // XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_parser_imp_embeddertest.cpp b/xfa/fxfa/parser/xfa_parser_imp_embeddertest.cpp index 63fe272872..63fe272872 100644 --- a/xfa/src/fxfa/parser/xfa_parser_imp_embeddertest.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp_embeddertest.cpp diff --git a/xfa/fxfa/parser/xfa_script.h b/xfa/fxfa/parser/xfa_script.h new file mode 100644 index 0000000000..6d8f3a0ed3 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script.h @@ -0,0 +1,121 @@ +// 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_SCRIPT_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_H_ + +#include "xfa/include/fxfa/fxfa.h" +#include "xfa/include/fxfa/fxfa_objectacc.h" + +#define XFA_RESOLVENODE_Children 0x0001 +#define XFA_RESOLVENODE_Attributes 0x0004 +#define XFA_RESOLVENODE_Properties 0x0008 +#define XFA_RESOLVENODE_Siblings 0x0020 +#define XFA_RESOLVENODE_Parent 0x0040 +#define XFA_RESOLVENODE_AnyChild 0x0080 +#define XFA_RESOLVENODE_ALL 0x0100 +#define XFA_RESOLVENODE_CreateNode 0x0400 +#define XFA_RESOLVENODE_Bind 0x0800 +#define XFA_RESOLVENODE_BindNew 0x1000 + +enum XFA_SCRIPTLANGTYPE { + XFA_SCRIPTLANGTYPE_Formcalc = XFA_SCRIPTTYPE_Formcalc, + XFA_SCRIPTLANGTYPE_Javascript = XFA_SCRIPTTYPE_Javascript, + XFA_SCRIPTLANGTYPE_Unkown = XFA_SCRIPTTYPE_Unkown, +}; + +enum XFA_RESOVENODE_RSTYPE { + XFA_RESOVENODE_RSTYPE_Nodes, + XFA_RESOVENODE_RSTYPE_Attribute, + XFA_RESOLVENODE_RSTYPE_CreateNodeOne, + XFA_RESOLVENODE_RSTYPE_CreateNodeAll, + XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll, + XFA_RESOVENODE_RSTYPE_ExistNodes, +}; + +class CXFA_HVALUEArray : public CFX_ArrayTemplate<FXJSE_HVALUE> { + public: + CXFA_HVALUEArray(FXJSE_HRUNTIME hRunTime) : m_hRunTime(hRunTime) {} + ~CXFA_HVALUEArray() { + for (int32_t i = 0; i < GetSize(); i++) { + FXJSE_Value_Release(GetAt(i)); + } + } + void GetAttributeObject(CXFA_ObjArray& objArray) { + for (int32_t i = 0; i < GetSize(); i++) { + CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(GetAt(i), NULL); + objArray.Add(pObject); + } + } + FXJSE_HRUNTIME m_hRunTime; +}; + +struct XFA_RESOLVENODE_RS { + XFA_RESOLVENODE_RS() + : dwFlags(XFA_RESOVENODE_RSTYPE_Nodes), pScriptAttribute(NULL) {} + ~XFA_RESOLVENODE_RS() { nodes.RemoveAll(); } + int32_t GetAttributeResult(CXFA_HVALUEArray& hValueArray) const { + if (pScriptAttribute && pScriptAttribute->eValueType == XFA_SCRIPT_Object) { + FXJSE_HRUNTIME hRunTime = hValueArray.m_hRunTime; + for (int32_t i = 0; i < nodes.GetSize(); i++) { + FXJSE_HVALUE hValue = FXJSE_Value_Create(hRunTime); + (nodes[i]->*(pScriptAttribute->lpfnCallback))( + hValue, FALSE, (XFA_ATTRIBUTE)pScriptAttribute->eAttribute); + hValueArray.Add(hValue); + } + } + return hValueArray.GetSize(); + } + + CXFA_ObjArray nodes; + XFA_RESOVENODE_RSTYPE dwFlags; + const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute; +}; + +struct XFA_JSBUILTININFO { + uint32_t uUnicodeHash; + const FX_CHAR* pName; +}; + +const XFA_JSBUILTININFO* XFA_GetJSBuiltinByHash(uint32_t uHashCode); + +class IXFA_ScriptContext { + public: + virtual ~IXFA_ScriptContext() {} + virtual void Release() = 0; + virtual void Initialize(FXJSE_HRUNTIME hRuntime) = 0; + + virtual void SetEventParam(CXFA_EventParam param) = 0; + virtual CXFA_EventParam* GetEventParam() = 0; + virtual FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + CXFA_Object* pThisObject = NULL) = 0; + virtual int32_t ResolveObjects(CXFA_Object* refNode, + const CFX_WideStringC& wsExpression, + XFA_RESOLVENODE_RS& resolveNodeRS, + FX_DWORD dwStyles = XFA_RESOLVENODE_Children, + CXFA_Node* bindNode = NULL) = 0; + virtual FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject) = 0; + virtual void CacheList(CXFA_NodeList* pList) = 0; + virtual CXFA_Object* GetThisObject() const = 0; + virtual FXJSE_HRUNTIME GetRuntime() const = 0; + virtual int32_t GetIndexByName(CXFA_Node* refNode) = 0; + virtual int32_t GetIndexByClassName(CXFA_Node* refNode) = 0; + virtual void GetSomExpression(CXFA_Node* refNode, + CFX_WideString& wsExpression) = 0; + + virtual void SetNodesOfRunScript(CXFA_NodeArray* pArray) = 0; + virtual void AddNodesOfRunScript(const CXFA_NodeArray& nodes) = 0; + virtual void AddNodesOfRunScript(CXFA_Node* pNode) = 0; + virtual FXJSE_HCLASS GetJseNormalClass() = 0; + virtual XFA_SCRIPTLANGTYPE GetType() = 0; + virtual void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) = 0; + virtual FX_BOOL IsRunAtClient() = 0; +}; +IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument); + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_H_ diff --git a/xfa/fxfa/parser/xfa_script_datawindow.cpp b/xfa/fxfa/parser/xfa_script_datawindow.cpp new file mode 100644 index 0000000000..9c771e6ffa --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_datawindow.cpp @@ -0,0 +1,47 @@ +// 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/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" +#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" + +CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_DataWindow) { + m_uScriptHash = XFA_HASHCODE_DataWindow; +} +CScript_DataWindow::~CScript_DataWindow() {} +void CScript_DataWindow::Script_DataWindow_MoveCurrentRecord( + CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::Script_DataWindow_Record( + CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::Script_DataWindow_GotoRecord( + CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::Script_DataWindow_IsRecordGroup( + CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::Script_DataWindow_RecordsBefore( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CScript_DataWindow::Script_DataWindow_CurrentRecordNumber( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CScript_DataWindow::Script_DataWindow_RecordsAfter( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) {} +void CScript_DataWindow::Script_DataWindow_IsDefined(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { +} diff --git a/xfa/fxfa/parser/xfa_script_datawindow.h b/xfa/fxfa/parser/xfa_script_datawindow.h new file mode 100644 index 0000000000..9974e11eb1 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_datawindow.h @@ -0,0 +1,34 @@ +// 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_SCRIPT_DATAWINDOW_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_ + +#include "xfa/fxfa/parser/xfa_object.h" + +class CScript_DataWindow : public CXFA_OrdinaryObject { + public: + CScript_DataWindow(CXFA_Document* pDocument); + virtual ~CScript_DataWindow(); + void Script_DataWindow_MoveCurrentRecord(CFXJSE_Arguments* pArguments); + void Script_DataWindow_Record(CFXJSE_Arguments* pArguments); + void Script_DataWindow_GotoRecord(CFXJSE_Arguments* pArguments); + void Script_DataWindow_IsRecordGroup(CFXJSE_Arguments* pArguments); + void Script_DataWindow_RecordsBefore(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_DataWindow_CurrentRecordNumber(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_DataWindow_RecordsAfter(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_DataWindow_IsDefined(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_ diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp new file mode 100644 index 0000000000..4e1cb22dd3 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp @@ -0,0 +1,269 @@ +// 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/fxfa/parser/xfa_script_eventpseudomodel.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" +#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" + +CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_EventPseudoModel) { + m_uScriptHash = XFA_HASHCODE_Event; +} +CScript_EventPseudoModel::~CScript_EventPseudoModel() {} +void Script_EventPseudoModel_StringProperty(FXJSE_HVALUE hValue, + CFX_WideString& wsValue, + FX_BOOL bSetting) { + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); + } else { + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); + } +} +void Script_EventPseudoModel_InterProperty(FXJSE_HVALUE hValue, + int32_t& iValue, + FX_BOOL bSetting) { + if (bSetting) { + iValue = FXJSE_Value_ToInteger(hValue); + } else { + FXJSE_Value_SetInteger(hValue, iValue); + } +} +void Script_EventPseudoModel_BooleanProperty(FXJSE_HVALUE hValue, + FX_BOOL& bValue, + FX_BOOL bSetting) { + if (bSetting) { + bValue = FXJSE_Value_ToBoolean(hValue); + } else { + FXJSE_Value_SetBoolean(hValue, bValue); + } +} +void CScript_EventPseudoModel::Script_EventPseudoModel_Property( + FXJSE_HVALUE hValue, + FX_DWORD dwFlag, + FX_BOOL bSetting) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); + if (!pEventParam) { + return; + } + switch (dwFlag) { + case XFA_EVENT_CANCELACTION: + Script_EventPseudoModel_BooleanProperty( + hValue, pEventParam->m_bCancelAction, bSetting); + break; + case XFA_EVENT_CHANGE: + Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsChange, + bSetting); + break; + case XFA_EVENT_COMMITKEY: + Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iCommitKey, + bSetting); + break; + case XFA_EVENT_FULLTEXT: + Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsFullText, + bSetting); + break; + case XFA_EVENT_KEYDOWN: + Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bKeyDown, + bSetting); + break; + case XFA_EVENT_MODIFIER: + Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bModifier, + bSetting); + break; + case XFA_EVENT_NEWCONTENTTYPE: + Script_EventPseudoModel_StringProperty( + hValue, pEventParam->m_wsNewContentType, bSetting); + break; + case XFA_EVENT_NEWTEXT: + Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsNewText, + bSetting); + break; + case XFA_EVENT_PREVCONTENTTYPE: + Script_EventPseudoModel_StringProperty( + hValue, pEventParam->m_wsPrevContentType, bSetting); + break; + case XFA_EVENT_PREVTEXT: + Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsPrevText, + bSetting); + break; + case XFA_EVENT_REENTER: + Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bReenter, + bSetting); + break; + case XFA_EVENT_SELEND: + Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelEnd, + bSetting); + break; + case XFA_EVENT_SELSTART: + Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelStart, + bSetting); + break; + case XFA_EVENT_SHIFT: + Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bShift, + bSetting); + break; + case XFA_EVENT_SOAPFAULTCODE: + Script_EventPseudoModel_StringProperty( + hValue, pEventParam->m_wsSoapFaultCode, bSetting); + break; + case XFA_EVENT_SOAPFAULTSTRING: + Script_EventPseudoModel_StringProperty( + hValue, pEventParam->m_wsSoapFaultString, bSetting); + break; + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_CommitKey( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_KeyDown( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_NewContentType( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_PrevContentType( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVCONTENTTYPE, bSetting); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_PrevText( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVTEXT, bSetting); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_Reenter( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_SelStart( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELSTART, bSetting); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_Shift( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultString( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + 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); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_Emit( + CFXJSE_Arguments* pArguments) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); + if (!pEventParam) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_WidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); + if (!pWidgetHandler) { + return; + } + pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); +} +void CScript_EventPseudoModel::Script_EventPseudoModel_Reset( + CFXJSE_Arguments* pArguments) { + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); + if (!pEventParam) { + return; + } + pEventParam->Reset(); +} diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.h b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h new file mode 100644 index 0000000000..e1db83a182 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h @@ -0,0 +1,96 @@ +// 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_SCRIPT_EVENTPSEUDOMODEL_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_ + +#include "xfa/fxfa/parser/xfa_object.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 + +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); + void Script_EventPseudoModel_CommitKey(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_FullText(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_KeyDown(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_Modifier(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_NewContentType(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_NewText(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_PrevContentType(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_PrevText(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_Reenter(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_SelEnd(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_SelStart(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_Shift(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_SoapFaultCode(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_SoapFaultString(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_EventPseudoModel_Target(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + + void Script_EventPseudoModel_Emit(CFXJSE_Arguments* pArguments); + void Script_EventPseudoModel_Reset(CFXJSE_Arguments* pArguments); + + protected: + void Script_EventPseudoModel_Property(FXJSE_HVALUE hValue, + FX_DWORD dwFlag, + FX_BOOL bSetting); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp new file mode 100644 index 0000000000..1f5886bf4e --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp @@ -0,0 +1,800 @@ +// 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/fxfa/parser/xfa_script_hostpseudomodel.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" +#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" + +CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) { + m_uScriptHash = XFA_HASHCODE_Host; +} +CScript_HostPseudoModel::~CScript_HostPseudoModel() {} +void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( + FXJSE_HVALUE hValue, + IXFA_Notify* pNotify, + FX_DWORD dwFlag) { + CFX_WideString wsValue; + pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CFX_WideString wsAppType; + pNotify->GetAppProvider()->GetAppType(wsAppType); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CFX_WideString wsAppType; + pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + if (bSetting) { + pNotify->GetDocProvider()->SetCalculationsEnabled( + hDoc, FXJSE_Value_ToBoolean(hValue)); + return; + } + FX_BOOL bEnabled = pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc); + FXJSE_Value_SetBoolean(hValue, bEnabled); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentPage( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + if (bSetting) { + pNotify->GetDocProvider()->SetCurrentPage(hDoc, + FXJSE_Value_ToInteger(hValue)); + return; + } + int32_t iCurrentPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); + FXJSE_Value_SetInteger(hValue, iCurrentPage); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Language( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_LANGUAGE); + return; + } + CFX_WideString wsLanguage; + pNotify->GetAppProvider()->GetLanguage(wsLanguage); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsLanguage)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_NUMPAGES); + return; + } + int32_t iNumPages = pNotify->GetDocProvider()->CountPages(hDoc); + FXJSE_Value_SetInteger(hValue, iNumPages); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_PLATFORM); + return; + } + CFX_WideString wsPlatform; + pNotify->GetAppProvider()->GetPlatform(wsPlatform); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsPlatform)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Title( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + if (bSetting) { + CFX_ByteString bsValue; + FXJSE_Value_ToUTF8String(hValue, bsValue); + pNotify->GetDocProvider()->SetTitle( + hDoc, CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); + return; + } + CFX_WideString wsTitle; + pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsTitle)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + if (bSetting) { + pNotify->GetDocProvider()->SetValidationsEnabled( + hDoc, FXJSE_Value_ToBoolean(hValue)); + return; + } + FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); + FXJSE_Value_SetBoolean(hValue, bEnabled); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Variation( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VARIATION); + return; + } + CFX_WideString wsVariation; + pNotify->GetAppProvider()->GetVariation(wsVariation); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVariation)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Version( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); + return; + } + CFX_WideString wsVersion; + pNotify->GetAppProvider()->GetVersion(wsVersion); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); + return; + } + CFX_WideString wsVersion; + pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Name( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CFX_WideString wsAppName; + pNotify->GetAppProvider()->GetAppName(wsAppName); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppName)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); + return; + } + CFX_WideString wsFoxitAppName; + pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsFoxitAppName)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CFX_WideString wsURL; + if (iLength >= 1) { + CFX_ByteString bsURL = pArguments->GetUTF8String(0); + wsURL = CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()); + } + pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + FXJSE_HVALUE hValue = pArguments->GetValue(0); + if (FXJSE_Value_IsObject(hValue)) { + pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, nullptr)); + } else if (FXJSE_Value_IsUTF8String(hValue)) { + CFX_ByteString bsString; + FXJSE_Value_ToUTF8String(hValue, bsString); + CFX_WideString wsExpression = + CFX_WideString::FromUTF8(bsString, bsString.GetLength()); + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + FXJSE_Value_Release(hValue); + return; + } + CXFA_Object* pObject = pScriptContext->GetThisObject(); + if (!pObject) { + FXJSE_Value_Release(hValue); + return; + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, + resoveNodeRS, dwFlag); + if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { + FXJSE_Value_Release(hValue); + return; + } + pNode = resoveNodeRS.nodes[0]->AsNode(); + } + FXJSE_Value_Release(hValue); + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); + if (!hWidget) { + return; + } + pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); + pNotify->OpenDropDownList(hWidget); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Response( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 4) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CFX_WideString wsQuestion; + CFX_WideString wsTitle; + CFX_WideString wsDefaultAnswer; + FX_BOOL bMark = FALSE; + if (iLength >= 1) { + CFX_ByteString bsQuestion = pArguments->GetUTF8String(0); + wsQuestion = CFX_WideString::FromUTF8(bsQuestion, bsQuestion.GetLength()); + } + if (iLength >= 2) { + CFX_ByteString bsTitle = pArguments->GetUTF8String(1); + wsTitle = CFX_WideString::FromUTF8(bsTitle, bsTitle.GetLength()); + } + if (iLength >= 3) { + CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); + wsDefaultAnswer = + CFX_WideString::FromUTF8(bsDefaultAnswer, bsDefaultAnswer.GetLength()); + } + if (iLength >= 4) { + bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; + } + CFX_WideString wsAnswer; + pNotify->GetAppProvider()->Response(wsAnswer, wsQuestion, wsTitle, + wsDefaultAnswer, bMark); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer)); + } +} +void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iCur); + } +} +static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, + int32_t nStart, + CFX_WideString& wsFilter) { + FXSYS_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.GetPtr(); + FX_WCHAR wCur; + while (nStart < iLength) { + wCur = pSrc[nStart++]; + if (wCur == ',') { + break; + } + pBuf[nCount++] = wCur; + } + wsFilter.ReleaseBuffer(nCount); + wsFilter.TrimLeft(); + wsFilter.TrimRight(); + return nStart; +} +void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 0 || iLength > 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CFX_WideString wsExpression; + if (iLength >= 1) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(0); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + } + if (wsExpression.IsEmpty()) { + pNotify->ResetData(); + return; + } + int32_t iStart = 0; + CFX_WideString wsName; + CXFA_Node* pNode = NULL; + int32_t iExpLength = wsExpression.GetLength(); + while (iStart < iExpLength) { + iStart = XFA_FilterName(wsExpression, iStart, wsName); + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + return; + } + CXFA_Object* pObject = pScriptContext->GetThisObject(); + if (!pObject) { + return; + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = + pScriptContext->ResolveObjects(pObject, wsName, resoveNodeRS, dwFlag); + if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { + continue; + } + pNode = resoveNodeRS.nodes[0]->AsNode(); + pNotify->ResetData(pNode->GetWidgetData()); + } + if (!pNode) { + pNotify->ResetData(); + } +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength < 0 || iLength > 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + FX_DWORD dwType = 4; + if (iLength >= 1) { + dwType = pArguments->GetInt32(0); + } + pNotify->GetAppProvider()->Beep(dwType); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + FXJSE_HVALUE hValue = pArguments->GetValue(0); + if (FXJSE_Value_IsObject(hValue)) { + pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, NULL)); + } else if (FXJSE_Value_IsUTF8String(hValue)) { + CFX_ByteString bsString; + FXJSE_Value_ToUTF8String(hValue, bsString); + CFX_WideString wsExpression = + CFX_WideString::FromUTF8(bsString, bsString.GetLength()); + IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); + if (!pScriptContext) { + FXJSE_Value_Release(hValue); + return; + } + CXFA_Object* pObject = pScriptContext->GetThisObject(); + if (!pObject) { + FXJSE_Value_Release(hValue); + return; + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Siblings; + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, + resoveNodeRS, dwFlag); + if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { + FXJSE_Value_Release(hValue); + return; + } + pNode = resoveNodeRS.nodes[0]->AsNode(); + } + FXJSE_Value_Release(hValue); + } + pNotify->SetFocusWidgetNode(pNode); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); + if (!pNode) { + return; + } + FXJSE_Value_Set(pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 4) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CFX_WideString wsMessage; + CFX_WideString bsTitle; + FX_DWORD dwMessageType = XFA_MBICON_Error; + FX_DWORD dwButtonType = XFA_MB_OK; + if (iLength >= 1) { + if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 0, wsMessage)) { + return; + } + } + if (iLength >= 2) { + if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 1, bsTitle)) { + return; + } + } + if (iLength >= 3) { + dwMessageType = pArguments->GetInt32(2); + if (dwMessageType > XFA_MBICON_Status) { + dwMessageType = XFA_MBICON_Error; + } + } + if (iLength >= 4) { + dwButtonType = pArguments->GetInt32(3); + if (dwButtonType > XFA_MB_YesNoCancel) { + dwButtonType = XFA_MB_OK; + } + } + int32_t iValue = pNotify->GetAppProvider()->MsgBox( + wsMessage, bsTitle, dwMessageType, dwButtonType); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iValue); + } +} +FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( + CFXJSE_Arguments* pArguments, + int32_t iArgIndex, + CFX_WideString& wsValue) { + if (pArguments == NULL || iArgIndex < 0) { + return FALSE; + } + FX_BOOL bIsJsType = FALSE; + if (m_pDocument->GetScriptContext()->GetType() == + XFA_SCRIPTLANGTYPE_Javascript) { + bIsJsType = TRUE; + } + FXJSE_HVALUE hValueArg = pArguments->GetValue(iArgIndex); + if (!FXJSE_Value_IsUTF8String(hValueArg) && bIsJsType) { + ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); + FXJSE_Value_Release(hValueArg); + return FALSE; + } + if (FXJSE_Value_IsNull(hValueArg)) { + wsValue = FX_WSTRC(L""); + } else { + CFX_ByteString byMessage; + FXJSE_Value_ToUTF8String(hValueArg, byMessage); + wsValue = CFX_WideString::FromUTF8(byMessage, byMessage.GetLength()); + } + FXJSE_Value_Release(hValueArg); + return TRUE; +} +void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iValue); + } +} +void CScript_HostPseudoModel::Script_HostPseudoModel_Print( + CFXJSE_Arguments* pArguments) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + return; + } + int32_t iLength = pArguments->GetLength(); + if (iLength != 8) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + FX_DWORD dwOptions = 0; + FX_BOOL bShowDialog = TRUE; + if (iLength >= 1) { + bShowDialog = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; + } + if (bShowDialog) { + dwOptions |= XFA_PRINTOPT_ShowDialog; + } + int32_t nStartPage = 0; + if (iLength >= 2) { + nStartPage = pArguments->GetInt32(1); + } + int32_t nEndPage = 0; + if (iLength >= 3) { + nEndPage = pArguments->GetInt32(2); + } + FX_BOOL bCanCancel = TRUE; + if (iLength >= 4) { + bCanCancel = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; + } + if (bCanCancel) { + dwOptions |= XFA_PRINTOPT_CanCancel; + } + FX_BOOL bShrinkPage = TRUE; + if (iLength >= 5) { + bShrinkPage = pArguments->GetInt32(4) == 0 ? FALSE : TRUE; + } + if (bShrinkPage) { + dwOptions |= XFA_PRINTOPT_ShrinkPage; + } + FX_BOOL bAsImage = TRUE; + if (iLength >= 6) { + bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; + } + if (bAsImage) { + dwOptions |= XFA_PRINTOPT_AsImage; + } + FX_BOOL bReverseOrder = TRUE; + if (iLength >= 7) { + bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; + } + bReverseOrder = pArguments->GetInt32(6) == 0 ? FALSE : TRUE; + if (bReverseOrder) { + dwOptions |= XFA_PRINTOPT_ReverseOrder; + } + FX_BOOL bPrintAnnot = TRUE; + if (iLength >= 8) { + bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; + } + if (bPrintAnnot) { + dwOptions |= XFA_PRINTOPT_PrintAnnot; + } + pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 0 || iLength > 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CFX_WideString wsFilePath; + if (iLength > 0) { + CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); + wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength()); + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 0 || iLength > 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CFX_WideString wsFilePath; + FX_BOOL bXDP = TRUE; + if (iLength >= 1) { + CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); + wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength()); + } + if (iLength >= 2) { + bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; + } + pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); + int32_t nNewPage = 0; + if (nCurPage <= 1) { + return; + } + nNewPage = nCurPage - 1; + pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_PageDown( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); + int32_t nPageCount = pNotify->GetDocProvider()->CountPages(hDoc); + if (!nPageCount || nCurPage == nPageCount) { + return; + } + int32_t nNewPage = 0; + if (nCurPage >= nPageCount) { + nNewPage = nPageCount - 1; + } else { + nNewPage = nCurPage + 1; + } + pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); +} +void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime)); + } +} diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.h b/xfa/fxfa/parser/xfa_script_hostpseudomodel.h new file mode 100644 index 0000000000..dcc2a9bf7d --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.h @@ -0,0 +1,89 @@ +// 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_SCRIPT_HOSTPSEUDOMODEL_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_ + +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/xfa_object.h" + +class CScript_HostPseudoModel : public CXFA_OrdinaryObject { + public: + CScript_HostPseudoModel(CXFA_Document* pDocument); + virtual ~CScript_HostPseudoModel(); + + void Script_HostPseudoModel_AppType(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_FoxitAppType(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_CalculationsEnabled(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_CurrentPage(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Language(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_NumPages(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Platform(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Title(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_ValidationsEnabled(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Variation(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Version(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_FoxitVersion(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_Name(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_HostPseudoModel_FoxitName(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + + void Script_HostPseudoModel_GotoURL(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_OpenList(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_Response(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_DocumentInBatch(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_ResetData(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_Beep(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_SetFocus(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_GetFocus(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_MessageBox(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_DocumentCountInBatch( + CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_Print(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_ImportData(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_ExportData(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_PageUp(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_PageDown(CFXJSE_Arguments* pArguments); + void Script_HostPseudoModel_CurrentDateTime(CFXJSE_Arguments* pArguments); + + protected: + void Script_HostPseudoModel_LoadString(FXJSE_HVALUE hValue, + IXFA_Notify* pNotify, + FX_DWORD dwFlag); + FX_BOOL Script_HostPseudoModel_ValidateArgsForMsg( + CFXJSE_Arguments* pArguments, + int32_t iArgIndex, + CFX_WideString& wsValue); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp new file mode 100644 index 0000000000..275f4944fc --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -0,0 +1,781 @@ +// 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/fxfa/parser/xfa_script_imp.h" + +#include "core/include/fxcrt/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" +#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_script_nodehelper.h" +#include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument) + : m_pDocument(pDocument), + m_hJsContext(nullptr), + m_hJsRuntime(nullptr), + m_hJsClass(nullptr), + m_eScriptType(XFA_SCRIPTLANGTYPE_Unkown), + m_pScriptNodeArray(nullptr), + m_pResolveProcessor(nullptr), + m_hFM2JSContext(nullptr), + m_pThisObject(nullptr), + m_dwBuiltInInFlags(0), + m_eRunAtType(XFA_ATTRIBUTEENUM_Client) { + FXSYS_memset(&m_JsGlobalClass, 0, sizeof(FXJSE_CLASS)); + FXSYS_memset(&m_JsNormalClass, 0, sizeof(FXJSE_CLASS)); +} +CXFA_ScriptContext::~CXFA_ScriptContext() { + FX_POSITION ps = m_mapXFAToHValue.GetStartPosition(); + while (ps) { + CXFA_Object* pXFAObj; + FXJSE_HVALUE pValue; + m_mapXFAToHValue.GetNextAssoc(ps, pXFAObj, pValue); + FXJSE_Value_Release(pValue); + } + m_mapXFAToHValue.RemoveAll(); + ReleaseVariablesMap(); + if (m_hFM2JSContext) { + XFA_FM2JS_ContextRelease(m_hFM2JSContext); + m_hFM2JSContext = NULL; + } + if (m_hJsContext) { + FXJSE_Context_Release(m_hJsContext); + m_hJsContext = NULL; + } + if (m_pResolveProcessor) { + delete m_pResolveProcessor; + m_pResolveProcessor = NULL; + } + m_upObjectArray.RemoveAll(); + for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) { + delete ((CXFA_NodeList*)m_CacheListArray[i]); + } + m_CacheListArray.RemoveAll(); +} +void CXFA_ScriptContext::Initialize(FXJSE_HRUNTIME hRuntime) { + m_hJsRuntime = hRuntime; + DefineJsContext(); + DefineJsClass(); + m_pResolveProcessor = new CXFA_ResolveProcessor; +} +void CXFA_ScriptContext::Release() { + delete this; +} +FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + CXFA_Object* pThisObject) { + CFX_ByteString btScript; + XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType; + m_eScriptType = eScriptType; + if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) { + if (!m_hFM2JSContext) { + m_hFM2JSContext = XFA_FM2JS_ContextCreate(); + XFA_FM2JS_ContextInitialize(m_hFM2JSContext, m_hJsRuntime, m_hJsContext, + m_pDocument); + } + CFX_WideTextBuf wsJavaScript; + CFX_WideString wsErrorInfo; + int32_t iFlags = XFA_FM2JS_Translate(wsScript, wsJavaScript, wsErrorInfo); + if (iFlags) { + FXJSE_Value_SetUndefined(hRetValue); + return FALSE; + } + btScript = + FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); + } else { + btScript = FX_UTF8Encode(wsScript.GetPtr(), 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); + m_pThisObject = pOriginalObject; + m_eScriptType = eSaveType; + return bRet; +} +void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + CXFA_Object* lpOrginalNode = + (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + CXFA_Document* pDoc = lpOrginalNode->GetDocument(); + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pDoc->GetScriptContext(); + CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + FX_DWORD dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | + XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Attributes; + CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); + if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { + pRefNode = ToNode(lpCurNode); + } + if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, + TRUE)) { + return; + } + if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { + if (FXJSE_Value_IsUndefined(hValue)) { + FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); + return; + } + } + IXFA_Notify* pNotify = pDoc->GetNotify(); + if (!pNotify) { + return; + } + pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName, + hValue); +} +FX_BOOL CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode, + const CFX_WideStringC& propname, + FXJSE_HVALUE hValue, + FX_DWORD dwFlag, + FX_BOOL bSetting) { + if (!refNode) + return false; + XFA_RESOLVENODE_RS resolveRs; + if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) + return false; + if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]); + FXJSE_Value_Set(hValue, pValue); + return true; + } + if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) { + const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute; + if (lpAttributeInfo) { + (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))( + hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); + } + } + return true; +} +void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + CXFA_Object* pOrginalObject = + (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + CXFA_Document* pDoc = pOrginalObject->GetDocument(); + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pDoc->GetScriptContext(); + CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(pOrginalObject); + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + 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()); + if (uHashCode != XFA_HASHCODE_Layout) { + CXFA_Object* pObject = + lpScriptContext->GetDocument()->GetXFAObject(uHashCode); + if (pObject) { + FXJSE_Value_Set(hValue, lpScriptContext->GetJSValueFromMap(pObject)); + return; + } + } + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Attributes; + CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); + if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { + pRefNode = ToNode(lpCurNode); + } + if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, + FALSE)) { + return; + } + dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; + if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, + FALSE)) { + return; + } + CXFA_Object* pScriptObject = + lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); + if (pScriptObject && + lpScriptContext->QueryVariableHValue(pScriptObject->AsNode(), szPropName, + hValue, TRUE)) { + return; + } + IXFA_Notify* pNotify = pDoc->GetNotify(); + if (!pNotify) { + return; + } + pNotify->GetDocProvider()->GetGlobalProperty(pNotify->GetHDOC(), szPropName, + hValue); +} +void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + CXFA_Object* pOrginalObject = + (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + if (pOrginalObject == NULL) { + FXJSE_Value_SetUndefined(hValue); + return; + } + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); + CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); + if (wsPropName == FX_WSTRC(L"xfa")) { + FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap( + lpScriptContext->GetDocument()->GetRoot()); + FXJSE_Value_Set(hValue, pValue); + return; + } + FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Attributes; + FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName, + hValue, dwFlag, FALSE); + if (bRet) { + return; + } + if (pObject == lpScriptContext->GetThisObject() || + (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript && + !lpScriptContext->IsStrictScopeInJavaScript())) { + dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; + bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName, hValue, + dwFlag, FALSE); + } + if (bRet) { + return; + } + CXFA_Object* pScriptObject = + lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); + if (pScriptObject) { + bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), + szPropName, hValue, TRUE); + } + if (!bRet) { + FXJSE_Value_SetUndefined(hValue); + } +} +void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + CXFA_Object* pOrginalObject = + (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + if (pOrginalObject == NULL) { + return; + } + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); + CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = + XFA_GetScriptAttributeByName(pObject->GetClassID(), wsPropName); + if (lpAttributeInfo) { + (pObject->*(lpAttributeInfo->lpfnCallback))( + hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); + } else { + if (pObject->IsNode()) { + if (wsPropName.GetAt(0) == '#') { + wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); + } + CXFA_Node* pNode = ToNode(pObject); + CXFA_Node* pPropOrChild = NULL; + const XFA_ELEMENTINFO* lpElementInfo = XFA_GetElementByName(wsPropName); + if (lpElementInfo) { + pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName); + } else { + pPropOrChild = pNode->GetFirstChildByName(wsPropName); + } + if (pPropOrChild) { + CFX_WideString wsDefaultName = FX_WSTRC(L"{default}"); + const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = + XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), + wsDefaultName); + if (lpAttributeInfo) { + (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( + hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); + return; + } + } + } + CXFA_Object* pScriptObject = + lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); + if (pScriptObject) { + lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName, + hValue, FALSE); + } + } +} +int32_t CXFA_ScriptContext::NormalPropTypeGetter( + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FX_BOOL bQueryIn) { + CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + if (pObject == NULL) { + return FXJSE_ClassPropType_None; + } + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); + pObject = lpScriptContext->GetVariablesThis(pObject); + XFA_ELEMENT objElement = pObject->GetClassID(); + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + if (XFA_GetMethodByName(objElement, wsPropName)) { + return FXJSE_ClassPropType_Method; + } + if (bQueryIn && !XFA_GetScriptAttributeByName(objElement, wsPropName)) { + return FXJSE_ClassPropType_None; + } + return FXJSE_ClassPropType_Property; +} +int32_t CXFA_ScriptContext::GlobalPropTypeGetter( + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FX_BOOL bQueryIn) { + CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); + if (pObject == NULL) { + return FXJSE_ClassPropType_None; + } + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); + pObject = lpScriptContext->GetVariablesThis(pObject); + XFA_ELEMENT objElement = pObject->GetClassID(); + CFX_WideString wsPropName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); + if (XFA_GetMethodByName(objElement, wsPropName)) { + return FXJSE_ClassPropType_Method; + } + return FXJSE_ClassPropType_Property; +} +void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args) { + CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL); + if (pObject == NULL) { + return; + } + CXFA_ScriptContext* lpScriptContext = + (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); + pObject = lpScriptContext->GetVariablesThis(pObject); + CFX_WideString wsFunName = CFX_WideString::FromUTF8( + (const FX_CHAR*)szFuncName.GetPtr(), szFuncName.GetLength()); + const XFA_METHODINFO* lpMethodInfo = + XFA_GetMethodByName(pObject->GetClassID(), wsFunName); + if (NULL == lpMethodInfo) { + return; + } + (pObject->*(lpMethodInfo->lpfnCallback))(&args); +} +FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { + return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); +} +XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { + return m_eScriptType; +} +void CXFA_ScriptContext::DefineJsContext() { + m_JsGlobalClass.constructor = NULL; + m_JsGlobalClass.name = "Root"; + m_JsGlobalClass.propNum = 0; + m_JsGlobalClass.properties = NULL; + m_JsGlobalClass.methNum = 0; + m_JsGlobalClass.methods = NULL; + m_JsGlobalClass.dynPropGetter = CXFA_ScriptContext::GlobalPropertyGetter; + m_JsGlobalClass.dynPropSetter = CXFA_ScriptContext::GlobalPropertySetter; + m_JsGlobalClass.dynPropTypeGetter = CXFA_ScriptContext::GlobalPropTypeGetter; + m_JsGlobalClass.dynPropDeleter = NULL; + m_JsGlobalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; + m_hJsContext = FXJSE_Context_Create(m_hJsRuntime, &m_JsGlobalClass, + m_pDocument->GetRoot()); + RemoveBuiltInObjs(m_hJsContext); + FXJSE_Context_EnableCompatibleMode( + m_hJsContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); +} +FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext( + CXFA_Node* pScriptNode, + CXFA_Node* pSubform) { + if (pScriptNode == NULL || pSubform == NULL) { + return NULL; + } + if (m_mapVariableToHValue.GetCount() == 0) { + m_JsGlobalVariablesClass.constructor = NULL; + m_JsGlobalVariablesClass.name = "XFAScriptObject"; + m_JsGlobalVariablesClass.propNum = 0; + m_JsGlobalVariablesClass.properties = NULL; + m_JsGlobalVariablesClass.methNum = 0; + m_JsGlobalVariablesClass.methods = NULL; + m_JsGlobalVariablesClass.dynPropGetter = + CXFA_ScriptContext::GlobalPropertyGetter; + m_JsGlobalVariablesClass.dynPropSetter = + CXFA_ScriptContext::GlobalPropertySetter; + m_JsGlobalVariablesClass.dynPropTypeGetter = + CXFA_ScriptContext::NormalPropTypeGetter; + m_JsGlobalVariablesClass.dynPropDeleter = NULL; + 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); + RemoveBuiltInObjs(hVariablesContext); + FXJSE_Context_EnableCompatibleMode( + hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); + m_mapVariableToHValue.SetAt(pScriptNode, hVariablesContext); + return hVariablesContext; +} +CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, + FX_BOOL bScriptNode) { + if (pObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { + return bScriptNode ? ((CXFA_ThisProxy*)pObject)->GetScriptNode() + : ((CXFA_ThisProxy*)pObject)->GetThisNode(); + } + return pObject; +} +FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { + if (pScriptNode == NULL) { + 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.GetPtr(), 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; +} +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) { + return FALSE; + } + CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); + 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); + } + return bRes; +} +void CXFA_ScriptContext::ReleaseVariablesMap() { + FX_POSITION ps = m_mapVariableToHValue.GetStartPosition(); + while (ps) { + CXFA_Object* pScriptNode; + FXJSE_HCONTEXT hVariableContext; + 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; + } + 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"; + m_JsNormalClass.propNum = 0; + m_JsNormalClass.properties = NULL; + m_JsNormalClass.methNum = 0; + m_JsNormalClass.methods = NULL; + m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; + m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; + m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; + m_JsNormalClass.dynPropDeleter = NULL; + m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; + m_hJsClass = FXJSE_DefineClass(m_hJsContext, &m_JsNormalClass); +} +void CXFA_ScriptContext::RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const { + static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; + FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(jsContext); + FXJSE_HVALUE hProp = FXJSE_Value_Create(m_hJsRuntime); + for (int i = 0; i < 2; ++i) { + if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) + FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); + } + FXJSE_Value_Release(hProp); + FXJSE_Value_Release(hObject); +} +FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() { + return m_hJsClass; +} +int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, + const CFX_WideStringC& wsExpression, + XFA_RESOLVENODE_RS& resolveNodeRS, + FX_DWORD dwStyles, + CXFA_Node* bindNode) { + if (wsExpression.IsEmpty()) { + return 0; + } + if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || + (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { + m_upObjectArray.RemoveAll(); + } + if (refNode && refNode->IsNode() && + (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { + m_upObjectArray.Add(refNode->AsNode()); + } + FX_BOOL bNextCreate = FALSE; + if (dwStyles & XFA_RESOLVENODE_CreateNode) { + m_pResolveProcessor->GetNodeHelper()->XFA_SetCreateNodeType(bindNode); + } + m_pResolveProcessor->GetNodeHelper()->m_pCreateParent = NULL; + m_pResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1; + CXFA_ResolveNodesData rndFind; + int32_t nStart = 0; + int32_t nLevel = 0; + int32_t nRet = -1; + rndFind.m_pSC = this; + CXFA_ObjArray findNodes; + findNodes.Add(refNode ? refNode : m_pDocument->GetRoot()); + int32_t nNodes = 0; + while (TRUE) { + nNodes = findNodes.GetSize(); + int32_t i = 0; + rndFind.m_dwStyles = dwStyles; + m_pResolveProcessor->m_iCurStart = nStart; + nStart = m_pResolveProcessor->XFA_ResolveNodes_GetFilter(wsExpression, + nStart, rndFind); + if (nStart < 1) { + if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) { + CXFA_Node* pDataNode = NULL; + nStart = m_pResolveProcessor->GetNodeHelper()->m_iCurAllStart; + if (nStart != -1) { + pDataNode = m_pDocument->GetNotBindNode(findNodes); + if (pDataNode) { + findNodes.RemoveAll(); + findNodes.Add(pDataNode); + break; + } + } else { + pDataNode = findNodes[0]->AsNode(); + findNodes.RemoveAll(); + findNodes.Add(pDataNode); + break; + } + dwStyles |= XFA_RESOLVENODE_Bind; + findNodes.RemoveAll(); + findNodes.Add(m_pResolveProcessor->GetNodeHelper()->m_pAllStartParent); + continue; + } else { + break; + } + } + if (bNextCreate) { + FX_BOOL bCreate = + m_pResolveProcessor->GetNodeHelper()->XFA_ResolveNodes_CreateNode( + rndFind.m_wsName, rndFind.m_wsCondition, + nStart == wsExpression.GetLength(), this); + if (bCreate) { + continue; + } else { + break; + } + } + CXFA_ObjArray retNodes; + while (i < nNodes) { + FX_BOOL bDataBind = FALSE; + if (((dwStyles & XFA_RESOLVENODE_Bind) || + (dwStyles & XFA_RESOLVENODE_CreateNode)) && + nNodes > 1) { + CXFA_ResolveNodesData rndBind; + m_pResolveProcessor->XFA_ResolveNodes_GetFilter(wsExpression, nStart, + rndBind); + m_pResolveProcessor->XFA_ResolveNode_SetIndexDataBind( + rndBind.m_wsCondition, i, nNodes); + bDataBind = TRUE; + } + rndFind.m_CurNode = findNodes[i++]; + rndFind.m_nLevel = nLevel; + rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes; + nRet = m_pResolveProcessor->XFA_ResolveNodes(rndFind); + if (nRet < 1) { + continue; + } + if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute && + rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) { + FXJSE_HVALUE hValue = FXJSE_Value_Create(m_hJsRuntime); + (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))( + hValue, FALSE, + (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute); + rndFind.m_Nodes.SetAt(0, + (CXFA_Object*)FXJSE_Value_ToObject(hValue, NULL)); + FXJSE_Value_Release(hValue); + } + int32_t iSize = m_upObjectArray.GetSize(); + if (iSize) { + m_upObjectArray.RemoveAt(iSize - 1); + } + retNodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + if (bDataBind) { + break; + } + } + findNodes.RemoveAll(); + nNodes = retNodes.GetSize(); + if (nNodes < 1) { + if (dwStyles & XFA_RESOLVENODE_CreateNode) { + bNextCreate = TRUE; + if (m_pResolveProcessor->GetNodeHelper()->m_pCreateParent == NULL) { + m_pResolveProcessor->GetNodeHelper()->m_pCreateParent = + ToNode(rndFind.m_CurNode); + m_pResolveProcessor->GetNodeHelper()->m_iCreateCount = 1; + } + FX_BOOL bCreate = + m_pResolveProcessor->GetNodeHelper()->XFA_ResolveNodes_CreateNode( + rndFind.m_wsName, rndFind.m_wsCondition, + nStart == wsExpression.GetLength(), this); + if (bCreate) { + continue; + } else { + break; + } + } else { + break; + } + } + findNodes.Copy(retNodes); + rndFind.m_Nodes.RemoveAll(); + if (nLevel == 0) { + dwStyles &= ~(XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); + } + nLevel++; + } + if (!bNextCreate) { + resolveNodeRS.dwFlags = rndFind.m_dwFlag; + if (nNodes > 0) { + resolveNodeRS.nodes.Append(findNodes); + } + if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute) { + resolveNodeRS.pScriptAttribute = rndFind.m_pScriptAttribute; + return 1; + } + } + if (dwStyles & (XFA_RESOLVENODE_CreateNode | XFA_RESOLVENODE_Bind | + XFA_RESOLVENODE_BindNew)) { + m_pResolveProcessor->XFA_ResolveNode_SetResultCreateNode( + resolveNodeRS, rndFind.m_wsCondition); + if (!bNextCreate && (dwStyles & XFA_RESOLVENODE_CreateNode)) { + resolveNodeRS.dwFlags = XFA_RESOVENODE_RSTYPE_ExistNodes; + } + return resolveNodeRS.nodes.GetSize(); + } + return nNodes; +} +FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { + if (!pObject) { + return NULL; + } + if (pObject->IsNode()) { + RunVariablesScript(pObject->AsNode()); + } + void* pValue = m_mapXFAToHValue.GetValueAt(pObject); + if (pValue == NULL) { + FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_hJsRuntime); + FXJSE_Value_SetObject(jsHvalue, pObject, m_hJsClass); + m_mapXFAToHValue.SetAt(pObject, jsHvalue); + pValue = jsHvalue; + } + return (FXJSE_HVALUE)pValue; +} +int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { + CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); + return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, + lpNodeHelper->XFA_NodeIsProperty(refNode), + FALSE); +} +int32_t CXFA_ScriptContext::GetIndexByClassName(CXFA_Node* refNode) { + CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); + return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, + lpNodeHelper->XFA_NodeIsProperty(refNode), + TRUE); +} +void CXFA_ScriptContext::GetSomExpression(CXFA_Node* refNode, + CFX_WideString& wsExpression) { + CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); + lpNodeHelper->XFA_GetNameExpression(refNode, wsExpression, TRUE, + XFA_LOGIC_Transparent); +} +void CXFA_ScriptContext::SetNodesOfRunScript(CXFA_NodeArray* pArray) { + m_pScriptNodeArray = pArray; +} +void CXFA_ScriptContext::AddNodesOfRunScript(const CXFA_NodeArray& nodes) { + if (!m_pScriptNodeArray) { + return; + } + if (nodes.GetSize() > 0) { + m_pScriptNodeArray->Copy(nodes); + } +} +void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { + if (!m_pScriptNodeArray) { + return; + } + if (m_pScriptNodeArray->Find(pNode) == -1) { + m_pScriptNodeArray->Add(pNode); + } +} +IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) { + return new CXFA_ScriptContext(pDocument); +} diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h new file mode 100644 index 0000000000..e4b5501770 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_imp.h @@ -0,0 +1,127 @@ +// 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_SCRIPT_IMP_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ + +#include <map> + +#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" +#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/xfa_script.h" + +#define XFA_RESOLVENODE_TagName 0x0002 + +class CXFA_ResolveProcessor; + +class CXFA_ScriptContext : public IXFA_ScriptContext { + public: + explicit CXFA_ScriptContext(CXFA_Document* pDocument); + ~CXFA_ScriptContext(); + + virtual void Release(); + virtual void Initialize(FXJSE_HRUNTIME hRuntime); + virtual void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } + virtual CXFA_EventParam* GetEventParam() { return &m_eventParam; } + virtual FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + CXFA_Object* pThisObject = NULL); + + virtual int32_t ResolveObjects(CXFA_Object* refNode, + const CFX_WideStringC& wsExpression, + XFA_RESOLVENODE_RS& resolveNodeRS, + FX_DWORD dwStyles = XFA_RESOLVENODE_Children, + CXFA_Node* bindNode = NULL); + virtual FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject); + virtual void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } + virtual CXFA_Object* GetThisObject() const { return m_pThisObject; } + virtual FXJSE_HRUNTIME GetRuntime() const { return m_hJsRuntime; } + + virtual int32_t GetIndexByName(CXFA_Node* refNode); + virtual int32_t GetIndexByClassName(CXFA_Node* refNode); + virtual void GetSomExpression(CXFA_Node* refNode, + CFX_WideString& wsExpression); + + virtual void SetNodesOfRunScript(CXFA_NodeArray* pArray); + virtual void AddNodesOfRunScript(const CXFA_NodeArray& nodes); + virtual void AddNodesOfRunScript(CXFA_Node* pNode); + virtual FXJSE_HCLASS GetJseNormalClass(); + + virtual void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } + virtual FX_BOOL IsRunAtClient() { + return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; + } + FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, + const CFX_WideStringC& propname, + FXJSE_HVALUE hValue, + FX_DWORD dwFlag, + FX_BOOL bSetting); + FX_BOOL QueryVariableHValue(CXFA_Node* pScriptNode, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue, + FX_BOOL bGetter); + FX_BOOL QueryBuiltinHValue(const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + static void GlobalPropertyGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + static void GlobalPropertySetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + static void NormalPropertyGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + static void NormalPropertySetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + static void NormalMethodCall(FXJSE_HOBJECT hThis, + const CFX_ByteStringC& szFuncName, + CFXJSE_Arguments& args); + static int32_t NormalPropTypeGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FX_BOOL bQueryIn); + static int32_t GlobalPropTypeGetter(FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FX_BOOL bQueryIn); + FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); + CXFA_Object* GetVariablesThis(CXFA_Object* pObject, + FX_BOOL bScriptNode = FALSE); + void ReleaseVariablesMap(); + FX_BOOL IsStrictScopeInJavaScript(); + XFA_SCRIPTLANGTYPE GetType(); + CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } + CXFA_Document* GetDocument() const { return m_pDocument; } + + protected: + void DefineJsContext(); + FXJSE_HCONTEXT CreateVariablesContext(CXFA_Node* pScriptNode, + CXFA_Node* pSubform); + void DefineJsClass(); + void RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const; + + CXFA_Document* m_pDocument; + FXJSE_HCONTEXT m_hJsContext; + FXJSE_HRUNTIME m_hJsRuntime; + FXJSE_HCLASS m_hJsClass; + XFA_SCRIPTLANGTYPE m_eScriptType; + FXJSE_CLASS m_JsGlobalClass; + FXJSE_CLASS m_JsNormalClass; + CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE> m_mapXFAToHValue; + FXJSE_CLASS m_JsGlobalVariablesClass; + CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue; + CXFA_EventParam m_eventParam; + CXFA_NodeArray m_upObjectArray; + CFX_PtrArray m_CacheListArray; + CXFA_NodeArray* m_pScriptNodeArray; + CXFA_ResolveProcessor* m_pResolveProcessor; + XFA_HFM2JSCONTEXT m_hFM2JSContext; + CXFA_Object* m_pThisObject; + FX_DWORD m_dwBuiltInInFlags; + XFA_ATTRIBUTEENUM m_eRunAtType; +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp new file mode 100644 index 0000000000..d4a4ea8021 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp @@ -0,0 +1,552 @@ +// 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/fxfa/parser/xfa_script_layoutpseudomodel.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" +#include "xfa/fxfa/parser/xfa_layout_appadapter.h" +#include "xfa/fxfa/parser/xfa_localemgr.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" + +CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_LayoutPseudoModel) { + m_uScriptHash = XFA_HASHCODE_Layout; +} +CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready( + FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + if (bSetting) { + ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_READY); + return; + } + int32_t iStatus = pNotify->GetLayoutStatus(); + FXJSE_Value_SetBoolean(hValue, iStatus >= 2); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY( + CFXJSE_Arguments* pArguments, + XFA_LAYOUTMODEL_HWXY layoutModel) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 3) { + const FX_WCHAR* methodName = NULL; + switch (layoutModel) { + case XFA_LAYOUTMODEL_H: + methodName = L"h"; + break; + case XFA_LAYOUTMODEL_W: + methodName = L"w"; + break; + case XFA_LAYOUTMODEL_X: + methodName = L"x"; + break; + case XFA_LAYOUTMODEL_Y: + methodName = L"y"; + break; + } + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); + return; + } + CXFA_Node* pNode = NULL; + CFX_WideString wsUnit = FX_WSTRC(L"pt"); + int32_t iIndex = 0; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (iLength >= 2) { + CFX_ByteString bsUnit = pArguments->GetUTF8String(1); + if (!bsUnit.IsEmpty()) { + wsUnit = CFX_WideString::FromUTF8(bsUnit, bsUnit.GetLength()); + } + } + if (iLength >= 3) { + iIndex = pArguments->GetInt32(2); + } + if (!pNode) { + return; + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + CFX_RectF rtRect; + CXFA_Measurement measure; + CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); + if (!pLayoutItem) { + return; + } + while (iIndex > 0 && pLayoutItem) { + pLayoutItem = pLayoutItem->GetNext(); + iIndex--; + } + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (!pLayoutItem) { + FXJSE_Value_SetFloat(hValue, 0); + return; + } + pLayoutItem->GetRect(rtRect, TRUE); + switch (layoutModel) { + case XFA_LAYOUTMODEL_H: + measure.Set(rtRect.height, XFA_UNIT_Pt); + break; + case XFA_LAYOUTMODEL_W: + measure.Set(rtRect.width, XFA_UNIT_Pt); + break; + case XFA_LAYOUTMODEL_X: + measure.Set(rtRect.left, XFA_UNIT_Pt); + break; + case XFA_LAYOUTMODEL_Y: + measure.Set(rtRect.top, XFA_UNIT_Pt); + break; + } + XFA_UNIT unit = measure.GetUnit(wsUnit); + FX_FLOAT fValue = measure.ToUnit(unit); + fValue = FXSYS_round(fValue * 1000) / 1000.0f; + if (hValue) { + FXJSE_Value_SetFloat(hValue, fValue); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_H( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_H); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_W( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_W); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_X( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_X); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Y( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_Y); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_NumberedPageCount( + CFXJSE_Arguments* pArguments, + FX_BOOL bNumbered) { + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + int32_t iPageCount = 0; + int32_t iPageNum = pDocLayout->CountPages(); + if (bNumbered) { + for (int32_t i = 0; i < iPageNum; i++) { + IXFA_LayoutPage* pLayoutPage = pDocLayout->GetPage(i); + if (!pLayoutPage) { + continue; + } + CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); + if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { + iPageCount++; + } + } + } else { + iPageCount = iPageNum; + } + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageCount); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageCount( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (!pNode) { + return; + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); + if (!pLayoutItem) { + FXJSE_Value_SetInteger(hValue, -1); + return; + } + int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); + int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); + int32_t iPageSpan = iLast - iFirst + 1; + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageSpan); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Page( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_PageImp(pArguments, FALSE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( + IXFA_DocLayout* pDocLayout, + int32_t iPageNo, + const CFX_WideString& wsType, + FX_BOOL bOnPageArea, + CXFA_NodeArray& retArray) { + CXFA_ContainerLayoutItem* pLayoutPage = + (CXFA_ContainerLayoutItem*)pDocLayout->GetPage(iPageNo); + if (!pLayoutPage) { + return; + } + if (wsType == FX_WSTRC(L"pageArea")) { + if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { + retArray.Add(pMasterPage); + } + return; + } + if (wsType == FX_WSTRC(L"contentArea")) { + for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; + pItem = pItem->m_pNextSibling) { + if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { + retArray.Add(pItem->m_pFormNode); + } + } + return; + } + CFX_MapPtrToPtr formItems; + formItems.InitHashTable(256, TRUE); + if (wsType.IsEmpty()) { + if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { + retArray.Add(pMasterPage); + } + for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; + pItem = pItem->m_pNextSibling) { + if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { + retArray.Add(pItem->m_pFormNode); + if (!bOnPageArea) { + CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, + CXFA_TraverseStrategy_ContentLayoutItem> + iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); + for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); + pItemChild; pItemChild = iterator.MoveToNext()) { + if (!pItemChild->IsContentLayoutItem()) { + continue; + } + XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); + if (eElementType != XFA_ELEMENT_Field && + eElementType != XFA_ELEMENT_Draw && + eElementType != XFA_ELEMENT_Subform && + eElementType != XFA_ELEMENT_Area) { + continue; + } + if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + continue; + } + formItems.SetAt(pItemChild->m_pFormNode, this); + retArray.Add(pItemChild->m_pFormNode); + } + } + } else { + if (bOnPageArea) { + CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, + CXFA_TraverseStrategy_ContentLayoutItem> + iterator((CXFA_ContentLayoutItem*)pItem); + for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); + pItemChild; pItemChild = iterator.MoveToNext()) { + if (!pItemChild->IsContentLayoutItem()) { + continue; + } + XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); + if (eElementType != XFA_ELEMENT_Field && + eElementType != XFA_ELEMENT_Draw && + eElementType != XFA_ELEMENT_Subform && + eElementType != XFA_ELEMENT_Area) { + continue; + } + if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + continue; + } + formItems.SetAt(pItemChild->m_pFormNode, this); + retArray.Add(pItemChild->m_pFormNode); + } + } + } + } + return; + } + XFA_ELEMENT eType = XFA_ELEMENT_UNKNOWN; + if (wsType == FX_WSTRC(L"field")) { + eType = XFA_ELEMENT_Field; + } else if (wsType == FX_WSTRC(L"draw")) { + eType = XFA_ELEMENT_Draw; + } else if (wsType == FX_WSTRC(L"subform")) { + eType = XFA_ELEMENT_Subform; + } else if (wsType == FX_WSTRC(L"area")) { + eType = XFA_ELEMENT_Area; + } + if (eType != XFA_ELEMENT_UNKNOWN) { + for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; + pItem = pItem->m_pNextSibling) { + if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { + if (!bOnPageArea) { + CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, + CXFA_TraverseStrategy_ContentLayoutItem> + iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); + for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); + pItemChild; pItemChild = iterator.MoveToNext()) { + if (!pItemChild->IsContentLayoutItem()) { + continue; + } + if (pItemChild->m_pFormNode->GetClassID() != eType) { + continue; + } + if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + continue; + } + formItems.SetAt(pItemChild->m_pFormNode, this); + retArray.Add(pItemChild->m_pFormNode); + } + } + } else { + if (bOnPageArea) { + CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, + CXFA_TraverseStrategy_ContentLayoutItem> + iterator((CXFA_ContentLayoutItem*)pItem); + for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); + pItemChild; pItemChild = iterator.MoveToNext()) { + if (!pItemChild->IsContentLayoutItem()) { + continue; + } + if (pItemChild->m_pFormNode->GetClassID() != eType) { + continue; + } + if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + continue; + } + formItems.SetAt(pItemChild->m_pFormNode, this); + retArray.Add(pItemChild->m_pFormNode); + } + } + } + } + return; + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 3) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); + return; + } + int32_t iIndex = 0; + CFX_WideString wsType; + FX_BOOL bOnPageArea = FALSE; + if (iLength >= 1) { + iIndex = pArguments->GetInt32(0); + } + if (iLength >= 2) { + CFX_ByteString bsType = pArguments->GetUTF8String(1); + wsType = CFX_WideString::FromUTF8(bsType, bsType.GetLength()); + } + if (iLength >= 3) { + bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + CXFA_NodeArray retArray; + Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, + retArray); + CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); + pArrayNodeList->SetArrayNodeList(retArray); + FXJSE_Value_SetObject(pArguments->GetReturnValue(), + (CXFA_Object*)pArrayNodeList, + m_pDocument->GetScriptContext()->GetJseNormalClass()); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageCount); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCountInBatch( + CFXJSE_Arguments* pArguments) { + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageCount); + } +} +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); + CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); + if (pContentRootNode) { + pLayoutProcessor->AddChangedContainer(pContentRootNode); + } + pLayoutProcessor->SetForceReLayout(TRUE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageSpan( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_PageSpan(pArguments); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"absPageInBatch"); + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (!pNode) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); + if (!hWidget) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageCount); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, + L"sheetInBatch"); + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (!pNode) { + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); + if (!hWidget) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + int32_t iPageCount = pNotify->GetDocProvider()->SheetInBatch(hDoc, hWidget); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, iPageCount); + } +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Sheet( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_PageImp(pArguments, TRUE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_RelayoutPageArea( + CFXJSE_Arguments* pArguments) {} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCount( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPage( + CFXJSE_Arguments* pArguments) { + Script_LayoutPseudoModel_PageImp(pArguments, TRUE); +} +void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageImp( + CFXJSE_Arguments* pArguments, + FX_BOOL bAbsPage) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 1) { + const FX_WCHAR* methodName; + if (bAbsPage) { + methodName = L"absPage"; + } else { + methodName = L"page"; + } + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); + return; + } + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + int32_t iPage = 0; + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (!pNode && hValue) { + FXJSE_Value_SetInteger(hValue, iPage); + } + IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); + if (!pDocLayout) { + return; + } + CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); + if (!pLayoutItem) { + FXJSE_Value_SetInteger(hValue, -1); + return; + } + iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, bAbsPage ? iPage : iPage + 1); + } +} diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h new file mode 100644 index 0000000000..349a3cc96d --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h @@ -0,0 +1,64 @@ +// 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_SCRIPT_LAYOUTPSEUDOMODEL_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_ + +#include "xfa/fxfa/parser/xfa_doclayout.h" +#include "xfa/fxfa/parser/xfa_object.h" + +enum XFA_LAYOUTMODEL_HWXY { + XFA_LAYOUTMODEL_H, + XFA_LAYOUTMODEL_W, + XFA_LAYOUTMODEL_X, + XFA_LAYOUTMODEL_Y +}; + +class CScript_LayoutPseudoModel : public CXFA_OrdinaryObject { + public: + explicit CScript_LayoutPseudoModel(CXFA_Document* pDocument); + ~CScript_LayoutPseudoModel(); + + void Script_LayoutPseudoModel_Ready(FXJSE_HVALUE hValue, + FX_BOOL bSetting, + XFA_ATTRIBUTE eAttribute); + + void Script_LayoutPseudoModel_HWXY(CFXJSE_Arguments* pArguments, + XFA_LAYOUTMODEL_HWXY layoutModel); + void Script_LayoutPseudoModel_H(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_W(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_X(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_Y(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_NumberedPageCount(CFXJSE_Arguments* pArguments, + FX_BOOL bNumbered); + void Script_LayoutPseudoModel_PageCount(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_PageSpan(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_Page(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_PageContent(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_AbsPageCount(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_AbsPageCountInBatch( + CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_SheetCountInBatch(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_Relayout(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_AbsPageSpan(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_AbsPageInBatch(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_SheetInBatch(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_Sheet(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_RelayoutPageArea(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_SheetCount(CFXJSE_Arguments* pArguments); + void Script_LayoutPseudoModel_AbsPage(CFXJSE_Arguments* pArguments); + + protected: + void Script_LayoutPseudoModel_GetObjArray(IXFA_DocLayout* pDocLayout, + int32_t iPageNo, + const CFX_WideString& wsType, + FX_BOOL bOnPageArea, + CXFA_NodeArray& retArray); + void Script_LayoutPseudoModel_PageImp(CFXJSE_Arguments* pArguments, + FX_BOOL bAbsPage); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp new file mode 100644 index 0000000000..01f94c5414 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp @@ -0,0 +1,33 @@ +// 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/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" +#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" + +CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_LogPseudoModel) { + m_uScriptHash = XFA_HASHCODE_Log; +} +CScript_LogPseudoModel::~CScript_LogPseudoModel() {} +void CScript_LogPseudoModel::Script_LogPseudoModel_Message( + CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Script_LogPseudoModel_TraceEnabled( + CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Script_LogPseudoModel_TraceActivate( + CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Script_LogPseudoModel_TraceDeactivate( + CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Script_LogPseudoModel_Trace( + CFXJSE_Arguments* pArguments) {} diff --git a/xfa/fxfa/parser/xfa_script_logpseudomodel.h b/xfa/fxfa/parser/xfa_script_logpseudomodel.h new file mode 100644 index 0000000000..8cd7c23a49 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_logpseudomodel.h @@ -0,0 +1,24 @@ +// 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_SCRIPT_LOGPSEUDOMODEL_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_ + +#include "xfa/fxfa/parser/xfa_object.h" + +class CScript_LogPseudoModel : public CXFA_OrdinaryObject { + public: + explicit CScript_LogPseudoModel(CXFA_Document* pDocument); + virtual ~CScript_LogPseudoModel(); + + void Script_LogPseudoModel_Message(CFXJSE_Arguments* pArguments); + void Script_LogPseudoModel_TraceEnabled(CFXJSE_Arguments* pArguments); + void Script_LogPseudoModel_TraceActivate(CFXJSE_Arguments* pArguments); + void Script_LogPseudoModel_TraceDeactivate(CFXJSE_Arguments* pArguments); + void Script_LogPseudoModel_Trace(CFXJSE_Arguments* pArguments); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/xfa_script_nodehelper.cpp b/xfa/fxfa/parser/xfa_script_nodehelper.cpp new file mode 100644 index 0000000000..ba584303cd --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_nodehelper.cpp @@ -0,0 +1,429 @@ +// 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/fxfa/parser/xfa_script_nodehelper.h" + +#include "core/include/fxcrt/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" +#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_script_imp.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +CXFA_NodeHelper::CXFA_NodeHelper(void) + : m_eLastCreateType(XFA_ELEMENT_DataValue), + m_pCreateParent(NULL), + m_iCreateCount(0), + m_iCreateFlag(XFA_RESOLVENODE_RSTYPE_CreateNodeOne), + m_iCurAllStart(-1), + m_pAllStartParent(NULL) {} +CXFA_NodeHelper::~CXFA_NodeHelper(void) {} +CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetOneChild( + CXFA_Node* parent, + const FX_WCHAR* pwsName, + FX_BOOL bIsClassName) { + if (parent == NULL) { + return NULL; + } + CXFA_NodeArray siblings; + uint32_t uNameHash = FX_HashCode_String_GetW(pwsName, FXSYS_wcslen(pwsName)); + XFA_NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName); + if (siblings.GetSize() == 0) { + return NULL; + } + return siblings[0]; +} +int32_t CXFA_NodeHelper::XFA_CountSiblings(CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType, + CXFA_NodeArray* pSiblings, + FX_BOOL bIsClassName) { + if (!pNode) + return 0; + CXFA_Node* parent = + XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); + if (!parent) + return 0; + const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( + parent->GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); + if (!pProperty && eLogicType == XFA_LOGIC_Transparent) { + parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); + if (parent == NULL) { + return 0; + } + } + if (bIsClassName) { + return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(), + pSiblings, eLogicType, bIsClassName); + } else { + return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings, + eLogicType, bIsClassName); + } +} +int32_t CXFA_NodeHelper::XFA_NodeAcc_TraverseAnySiblings( + CXFA_Node* parent, + FX_DWORD dNameHash, + CXFA_NodeArray* pSiblings, + FX_BOOL bIsClassName) { + if (parent == NULL || pSiblings == NULL) { + return 0; + } + int32_t nCount = 0; + int32_t i = 0; + CXFA_NodeArray properties; + parent->GetNodeList(properties, XFA_NODEFILTER_Properties); + int32_t nProperties = properties.GetSize(); + for (i = 0; i < nProperties; ++i) { + CXFA_Node* child = properties[i]; + if (bIsClassName) { + if (child->GetClassHashCode() == dNameHash) { + pSiblings->Add(child); + nCount++; + } + } else { + if (child->GetNameHash() == dNameHash) { + pSiblings->Add(child); + nCount++; + } + } + if (nCount > 0) { + return nCount; + } + nCount += XFA_NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, + bIsClassName); + } + CXFA_NodeArray children; + parent->GetNodeList(children, XFA_NODEFILTER_Children); + int32_t nChildren = children.GetSize(); + for (i = 0; i < nChildren; i++) { + CXFA_Node* child = children[i]; + if (bIsClassName) { + if (child->GetClassHashCode() == dNameHash) { + if (pSiblings) { + pSiblings->Add(child); + } + nCount++; + } + } else { + if (child->GetNameHash() == dNameHash) { + if (pSiblings) { + pSiblings->Add(child); + } + nCount++; + } + } + if (nCount > 0) { + return nCount; + } + nCount += XFA_NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, + bIsClassName); + } + return nCount; +} +int32_t CXFA_NodeHelper::XFA_NodeAcc_TraverseSiblings(CXFA_Node* parent, + FX_DWORD dNameHash, + CXFA_NodeArray* pSiblings, + XFA_LOGIC_TYPE eLogicType, + FX_BOOL bIsClassName, + FX_BOOL bIsFindProperty) { + if (parent == NULL || pSiblings == NULL) { + return 0; + } + int32_t nCount = 0; + int32_t i = 0; + if (bIsFindProperty) { + CXFA_NodeArray properties; + parent->GetNodeList(properties, XFA_NODEFILTER_Properties); + int32_t nProperties = properties.GetSize(); + for (i = 0; i < nProperties; ++i) { + CXFA_Node* child = properties[i]; + if (bIsClassName) { + if (child->GetClassHashCode() == dNameHash) { + pSiblings->Add(child); + nCount++; + } + } else { + if (child->GetNameHash() == dNameHash) { + if (child->GetClassID() != XFA_ELEMENT_PageSet && + child->GetClassID() != XFA_ELEMENT_Extras && + child->GetClassID() != XFA_ELEMENT_Items) { + pSiblings->Add(child); + nCount++; + } + } + } + if (child->IsUnnamed() && child->GetClassID() == XFA_ELEMENT_PageSet) { + nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, + eLogicType, bIsClassName, FALSE); + } + } + if (nCount > 0) { + return nCount; + } + } + CXFA_NodeArray children; + parent->GetNodeList(children, XFA_NODEFILTER_Children); + int32_t nChildren = children.GetSize(); + for (i = 0; i < nChildren; i++) { + CXFA_Node* child = children[i]; + if (child->GetClassID() == XFA_ELEMENT_Variables) { + continue; + } + if (bIsClassName) { + if (child->GetClassHashCode() == dNameHash) { + if (pSiblings) { + pSiblings->Add(child); + } + nCount++; + } + } else { + if (child->GetNameHash() == dNameHash) { + if (pSiblings) { + pSiblings->Add(child); + } + nCount++; + } + } + if (eLogicType == XFA_LOGIC_NoTransparent) { + continue; + } + if (XFA_NodeIsTransparent(child) && + child->GetClassID() != XFA_ELEMENT_PageSet) { + nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, + eLogicType, bIsClassName, FALSE); + } + } + return nCount; +} +CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetParent( + CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType) { + if (!pNode) { + return NULL; + } + if (eLogicType == XFA_LOGIC_NoTransparent) { + return pNode->GetNodeItem(XFA_NODEITEM_Parent); + } + CXFA_Node* parent; + CXFA_Node* node = pNode; + while (TRUE) { + parent = XFA_ResolveNodes_GetParent(node); + if (parent == NULL) { + break; + } + XFA_ELEMENT parentElement = parent->GetClassID(); + if ((!parent->IsUnnamed() && parentElement != XFA_ELEMENT_SubformSet) || + parentElement == XFA_ELEMENT_Variables) { + break; + } + node = parent; + } + return parent; +} +int32_t CXFA_NodeHelper::XFA_GetIndex(CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType, + FX_BOOL bIsProperty, + FX_BOOL bIsClassIndex) { + CXFA_Node* parent = + XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); + if (parent == NULL) { + return 0; + } + if (!bIsProperty && eLogicType == XFA_LOGIC_Transparent) { + parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); + if (parent == NULL) { + return 0; + } + } + FX_DWORD dwHashName = pNode->GetNameHash(); + if (bIsClassIndex) { + dwHashName = pNode->GetClassHashCode(); + } + CXFA_NodeArray siblings; + int32_t iSize = XFA_NodeAcc_TraverseSiblings(parent, dwHashName, &siblings, + eLogicType, bIsClassIndex); + for (int32_t i = 0; i < iSize; ++i) { + CXFA_Node* child = siblings[i]; + if (child == pNode) { + return i; + } + } + return 0; +} +void CXFA_NodeHelper::XFA_GetNameExpression(CXFA_Node* refNode, + CFX_WideString& wsName, + FX_BOOL bIsAllPath, + XFA_LOGIC_TYPE eLogicType) { + wsName.Empty(); + if (bIsAllPath) { + XFA_GetNameExpression(refNode, wsName, FALSE, eLogicType); + CFX_WideString wsParent; + CXFA_Node* parent = + XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); + while (parent) { + XFA_GetNameExpression(parent, wsParent, FALSE, eLogicType); + wsParent += L"."; + wsParent += wsName; + wsName = wsParent; + parent = XFA_ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent); + } + return; + } + + CFX_WideStringC wsTagName; + CFX_WideString ws; + FX_BOOL bIsProperty = XFA_NodeIsProperty(refNode); + if (refNode->IsUnnamed() || + (bIsProperty && refNode->GetClassID() != XFA_ELEMENT_PageSet)) { + refNode->GetClassName(wsTagName); + ws = wsTagName; + wsName.Format(L"#%s[%d]", (const FX_WCHAR*)ws, + 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, + XFA_GetIndex(refNode, eLogicType, bIsProperty, FALSE)); +} + +FX_BOOL CXFA_NodeHelper::XFA_NodeIsTransparent(CXFA_Node* refNode) { + if (refNode == NULL) { + return FALSE; + } + XFA_ELEMENT eRefNode = refNode->GetClassID(); + if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || + eRefNode == XFA_ELEMENT_SubformSet || eRefNode == XFA_ELEMENT_Area || + eRefNode == XFA_ELEMENT_Proto) { + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_NodeHelper::XFA_CreateNode_ForCondition( + CFX_WideString& wsCondition) { + int32_t iLen = wsCondition.GetLength(); + CFX_WideString wsIndex = FX_WSTRC(L"0"); + FX_BOOL bAll = FALSE; + + if (iLen == 0) { + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; + return FALSE; + } + if (wsCondition.GetAt(0) == '[') { + int32_t i = 1; + for (; i < iLen; ++i) { + FX_WCHAR ch = wsCondition[i]; + if (ch == ' ') { + continue; + } + if (ch == '+' || ch == '-') { + break; + } else if (ch == '*') { + bAll = TRUE; + break; + } else { + break; + } + } + if (bAll) { + wsIndex = FX_WSTRC(L"1"); + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; + } else { + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; + wsIndex = wsCondition.Mid(i, iLen - 1 - i); + } + int32_t iIndex = wsIndex.GetInteger(); + m_iCreateCount = iIndex; + return TRUE; + } + return FALSE; +} +FX_BOOL CXFA_NodeHelper::XFA_ResolveNodes_CreateNode( + CFX_WideString wsName, + CFX_WideString wsCondition, + FX_BOOL bLastNode, + CXFA_ScriptContext* pScriptContext) { + if (m_pCreateParent == NULL) { + return FALSE; + } + FX_BOOL bIsClassName = FALSE; + FX_BOOL bResult = FALSE; + if (wsName.GetAt(0) == '!') { + wsName = wsName.Right(wsName.GetLength() - 1); + m_pCreateParent = ToNode( + pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); + } + if (wsName.GetAt(0) == '#') { + bIsClassName = TRUE; + wsName = wsName.Right(wsName.GetLength() - 1); + } + if (m_iCreateCount == 0) { + XFA_CreateNode_ForCondition(wsCondition); + } + if (bIsClassName) { + const XFA_ELEMENTINFO* lpElement = XFA_GetElementByName(wsName); + if (lpElement == NULL) { + return FALSE; + } + for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { + CXFA_Node* pNewNode = + m_pCreateParent->CreateSamePacketNode(lpElement->eName); + if (pNewNode) { + m_pCreateParent->InsertChild(pNewNode); + if (iIndex == m_iCreateCount - 1) { + m_pCreateParent = pNewNode; + } + bResult = TRUE; + } + } + } else { + XFA_ELEMENT eClassType = XFA_ELEMENT_DataGroup; + if (bLastNode) { + eClassType = m_eLastCreateType; + } + for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { + CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType); + if (pNewNode) { + pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName); + pNewNode->CreateXMLMappingNode(); + m_pCreateParent->InsertChild(pNewNode); + if (iIndex == m_iCreateCount - 1) { + m_pCreateParent = pNewNode; + } + bResult = TRUE; + } + } + } + if (!bResult) { + m_pCreateParent = NULL; + } + return bResult; +} +void CXFA_NodeHelper::XFA_SetCreateNodeType(CXFA_Node* refNode) { + if (refNode == NULL) { + return; + } + if (refNode->GetClassID() == XFA_ELEMENT_Subform) { + m_eLastCreateType = XFA_ELEMENT_DataGroup; + } else if (refNode->GetClassID() == XFA_ELEMENT_Field) { + m_eLastCreateType = XFA_FieldIsMultiListBox(refNode) + ? XFA_ELEMENT_DataGroup + : XFA_ELEMENT_DataValue; + } else if (refNode->GetClassID() == XFA_ELEMENT_ExclGroup) { + m_eLastCreateType = XFA_ELEMENT_DataValue; + } +} +FX_BOOL CXFA_NodeHelper::XFA_NodeIsProperty(CXFA_Node* refNode) { + CXFA_Node* parent = + XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); + return parent && refNode && + XFA_GetPropertyOfElement(parent->GetClassID(), refNode->GetClassID(), + XFA_XDPPACKET_UNKNOWN); +} diff --git a/xfa/fxfa/parser/xfa_script_nodehelper.h b/xfa/fxfa/parser/xfa_script_nodehelper.h new file mode 100644 index 0000000000..b52f681447 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_nodehelper.h @@ -0,0 +1,72 @@ +// 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_SCRIPT_NODEHELPER_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_NODEHELPER_H_ + +#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/xfa_script.h" + +class CXFA_ScriptContext; + +enum XFA_LOGIC_TYPE { + XFA_LOGIC_NoTransparent, + XFA_LOGIC_Transparent, +}; + +class CXFA_NodeHelper { + public: + CXFA_NodeHelper(void); + ~CXFA_NodeHelper(void); + CXFA_Node* XFA_ResolveNodes_GetOneChild(CXFA_Node* parent, + const FX_WCHAR* pwsName, + FX_BOOL bIsClassName = FALSE); + CXFA_Node* XFA_ResolveNodes_GetParent( + CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent); + + int32_t XFA_NodeAcc_TraverseSiblings(CXFA_Node* parent, + FX_DWORD dNameHash, + CXFA_NodeArray* pSiblings, + XFA_LOGIC_TYPE eLogicType, + FX_BOOL bIsClassName = FALSE, + FX_BOOL bIsFindProperty = TRUE); + int32_t XFA_NodeAcc_TraverseAnySiblings(CXFA_Node* parent, + FX_DWORD dNameHash, + CXFA_NodeArray* pSiblings, + FX_BOOL bIsClassName = FALSE); + int32_t XFA_CountSiblings(CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType, + CXFA_NodeArray* pSiblings, + FX_BOOL bIsClassName = FALSE); + int32_t XFA_GetIndex(CXFA_Node* pNode, + XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent, + FX_BOOL bIsProperty = FALSE, + FX_BOOL bIsClassIndex = FALSE); + void XFA_GetNameExpression( + CXFA_Node* refNode, + CFX_WideString& wsName, + FX_BOOL bIsAllPath, + XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent); + FX_BOOL XFA_NodeIsTransparent(CXFA_Node* refNode); + FX_BOOL XFA_ResolveNodes_CreateNode(CFX_WideString wsName, + CFX_WideString wsCondition, + FX_BOOL bLastNode, + CXFA_ScriptContext* pScriptContext); + FX_BOOL XFA_CreateNode_ForCondition(CFX_WideString& wsCondition); + void XFA_SetCreateNodeType(CXFA_Node* refNode); + FX_BOOL XFA_NodeIsProperty(CXFA_Node* refNode); + + public: + XFA_ELEMENT m_eLastCreateType; + CXFA_Node* m_pCreateParent; + int32_t m_iCreateCount; + XFA_RESOVENODE_RSTYPE m_iCreateFlag; + int32_t m_iCurAllStart; + CXFA_Node* m_pAllStartParent; +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_NODEHELPER_H_ diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp new file mode 100644 index 0000000000..b40d714ec9 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp @@ -0,0 +1,825 @@ +// 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/fxfa/parser/xfa_script_resolveprocessor.h" + +#include "core/include/fxcrt/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" +#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_script_imp.h" +#include "xfa/fxfa/parser/xfa_script_nodehelper.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +CXFA_ResolveProcessor::CXFA_ResolveProcessor(void) + : m_pNodeHelper(NULL), m_iCurStart(0) { + m_pNodeHelper = new CXFA_NodeHelper; +} +CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) { + if (m_pNodeHelper) { + delete m_pNodeHelper; + m_pNodeHelper = NULL; + } +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { + if (rnd.m_CurNode == NULL) { + return -1; + } + if (!rnd.m_CurNode->IsNode()) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) { + return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, rnd.m_wsName); + } + return 0; + } + if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) { + return XFA_ResolveNodes_AnyChild(rnd); + } + FX_WCHAR wch = rnd.m_wsName.GetAt(0); + switch (wch) { + case '$': + return XFA_ResolveNodes_Dollar(rnd); + case '!': + return XFA_ResolveNodes_Excalmatory(rnd); + case '#': + return XFA_ResolveNodes_NumberSign(rnd); + case '*': + return XFA_ResolveNodes_Asterisk(rnd); + case '.': + return XFA_ResolveNodes_AnyChild(rnd); + default: + break; + } + if (rnd.m_uHashName == XFA_HASHCODE_This && rnd.m_nLevel == 0) { + rnd.m_Nodes.Add(rnd.m_pSC->GetThisObject()); + return 1; + } else if (rnd.m_CurNode->GetClassID() == XFA_ELEMENT_Xfa) { + CXFA_Object* pObjNode = + rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName); + if (pObjNode) { + rnd.m_Nodes.Add(pObjNode); + } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) { + 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)) { + return 1; + } + if (rnd.m_Nodes.GetSize() > 0) { + XFA_ResolveNode_FilterCondition(rnd, rnd.m_wsCondition); + } + return rnd.m_Nodes.GetSize(); + } + int32_t nRet = XFA_ResolveNodes_Normal(rnd); + if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) { + rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); + } + return rnd.m_Nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild( + CXFA_ResolveNodesData& rnd) { + CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); + CFX_WideString wsCondition = rnd.m_wsCondition; + CXFA_Node* findNode = NULL; + CXFA_NodeArray siblings; + FX_BOOL bClassName = FALSE; + if (wsName.GetAt(0) == '#') { + bClassName = TRUE; + wsName = wsName.Right(wsName.GetLength() - 1); + } + findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(ToNode(rnd.m_CurNode), + wsName, bClassName); + if (findNode == NULL) { + return 0; + } + if (wsCondition.IsEmpty()) { + rnd.m_Nodes.Add(findNode); + return rnd.m_Nodes.GetSize(); + } + m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, + (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + return rnd.m_Nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( + CXFA_ResolveNodesData& rnd) { + CXFA_ObjArray& nodes = rnd.m_Nodes; + CFX_WideString wsName = rnd.m_wsName; + CFX_WideString wsCondition = rnd.m_wsCondition; + int32_t iNameLen = wsName.GetLength(); + if (iNameLen == 1) { + nodes.Add(rnd.m_CurNode); + return 1; + } + if (rnd.m_nLevel > 0) { + return -1; + } + FX_DWORD dwNameHash = + FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1); + if (dwNameHash == XFA_HASHCODE_Xfa) { + nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); + } else { + CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); + if (pObjNode) { + rnd.m_Nodes.Add(pObjNode); + } + } + if (rnd.m_Nodes.GetSize() > 0) { + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + } + return rnd.m_Nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( + CXFA_ResolveNodesData& rnd) { + if (rnd.m_nLevel > 0) { + return 0; + } + CXFA_Node* datasets = + ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); + if (!datasets) { + return 0; + } + CXFA_ResolveNodesData rndFind; + 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_nLevel = rnd.m_nLevel + 1; + rndFind.m_dwStyles = XFA_RESOLVENODE_Children; + rndFind.m_wsCondition = rnd.m_wsCondition; + XFA_ResolveNodes(rndFind); + if (rndFind.m_Nodes.GetSize() > 0) { + rnd.m_Nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + return rnd.m_Nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( + CXFA_ResolveNodesData& rnd) { + 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)) { + return 1; + } + CXFA_ResolveNodesData rndFind; + rndFind.m_pSC = rnd.m_pSC; + rndFind.m_nLevel = rnd.m_nLevel + 1; + rndFind.m_dwStyles = rnd.m_dwStyles; + 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_wsCondition = wsCondition; + rndFind.m_CurNode = curNode; + XFA_ResolveNodes_Normal(rndFind); + if (rndFind.m_Nodes.GetSize() > 0) { + if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { + rnd.m_Nodes.Add(curNode); + } else { + rnd.m_Nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + } + return rnd.m_Nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_ForAttributeRs( + CXFA_Object* curNode, + CXFA_ResolveNodesData& rnd, + const CFX_WideStringC& strAttr) { + const XFA_SCRIPTATTRIBUTEINFO* lpScriptAttribute = + XFA_GetScriptAttributeByName(curNode->GetClassID(), strAttr); + if (lpScriptAttribute) { + rnd.m_pScriptAttribute = lpScriptAttribute; + rnd.m_Nodes.Add(curNode); + rnd.m_dwFlag = XFA_RESOVENODE_RSTYPE_Attribute; + return 1; + } + return 0; +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal( + CXFA_ResolveNodesData& rnd) { + if (rnd.m_nLevel > 32) { + return 0; + } + if (!rnd.m_CurNode->IsNode()) { + return 0; + } + CXFA_Node* curNode = ToNode(rnd.m_CurNode); + CXFA_ObjArray& nodes = rnd.m_Nodes; + int32_t nNum = nodes.GetSize(); + FX_DWORD dwStyles = rnd.m_dwStyles; + CFX_WideString& wsName = rnd.m_wsName; + uint32_t uNameHash = rnd.m_uHashName; + CFX_WideString& wsCondition = rnd.m_wsCondition; + CXFA_ResolveNodesData rndFind; + rndFind.m_wsName = rnd.m_wsName; + rndFind.m_wsCondition = rnd.m_wsCondition; + rndFind.m_pSC = rnd.m_pSC; + rndFind.m_nLevel = rnd.m_nLevel + 1; + rndFind.m_uHashName = uNameHash; + CXFA_NodeArray children; + CXFA_NodeArray properties; + CXFA_Node* pVariablesNode = NULL; + CXFA_Node* pPageSetNode = NULL; + CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChild) { + if (pChild->GetClassID() == XFA_ELEMENT_Variables) { + pVariablesNode = pChild; + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + continue; + } else if (pChild->GetClassID() == XFA_ELEMENT_PageSet) { + pPageSetNode = pChild; + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + continue; + } else { + const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( + curNode->GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); + if (pPropert) { + properties.Add(pChild); + } else { + children.Add(pChild); + } + } + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + } + if ((dwStyles & XFA_RESOLVENODE_Properties) && pVariablesNode) { + uint32_t uPropHash = pVariablesNode->GetClassHashCode(); + if (uPropHash == uNameHash) { + nodes.Add(pVariablesNode); + } else { + rndFind.m_CurNode = pVariablesNode; + XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); + CFX_WideString wsSaveCondition = rndFind.m_wsCondition; + rndFind.m_wsCondition.Empty(); + XFA_ResolveNodes_Normal(rndFind); + rndFind.m_wsCondition = wsSaveCondition; + if (rndFind.m_Nodes.GetSize() > 0) { + nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + } + if (nodes.GetSize() > nNum) { + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + if (nodes.GetSize() > 0) { + return 1; + } + return 0; + } + } + if (dwStyles & XFA_RESOLVENODE_Children) { + FX_BOOL bSetFlag = FALSE; + if (pPageSetNode && (dwStyles & XFA_RESOLVENODE_Properties)) { + children.Add(pPageSetNode); + } + for (int32_t i = 0; i < children.GetSize(); i++) { + CXFA_Node* child = children[i]; + if (dwStyles & XFA_RESOLVENODE_TagName) { + if (child->GetClassHashCode() == uNameHash) { + nodes.Add(child); + } + } else if (child->GetNameHash() == uNameHash) { + nodes.Add(child); + } + if (m_pNodeHelper->XFA_NodeIsTransparent(child) && + child->GetClassID() != XFA_ELEMENT_PageSet) { + if (!bSetFlag) { + XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); + bSetFlag = TRUE; + } + rndFind.m_CurNode = child; + CFX_WideString wsSaveCondition = rndFind.m_wsCondition; + rndFind.m_wsCondition.Empty(); + XFA_ResolveNodes_Normal(rndFind); + rndFind.m_wsCondition = wsSaveCondition; + if (rndFind.m_Nodes.GetSize() > 0) { + nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + } + } + if (nodes.GetSize() > nNum) { + if (!(dwStyles & XFA_RESOLVENODE_ALL)) { + CXFA_NodeArray upArrayNodes; + if (m_pNodeHelper->XFA_NodeIsTransparent(ToNode(curNode))) { + m_pNodeHelper->XFA_CountSiblings( + ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, + !!(dwStyles & XFA_RESOLVENODE_TagName)); + } + if (upArrayNodes.GetSize() > nodes.GetSize()) { + upArrayNodes[0] = ToNode(nodes[0]); + nodes.RemoveAll(); + nodes.Append((CXFA_ObjArray&)upArrayNodes); + upArrayNodes.RemoveAll(); + } + } + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + if (nodes.GetSize() > 0) { + return 1; + } + return 0; + } + } + if (dwStyles & XFA_RESOLVENODE_Attributes) { + if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName)) { + return 1; + } + } + if (dwStyles & XFA_RESOLVENODE_Properties) { + for (int32_t i = 0; i < properties.GetSize(); i++) { + CXFA_Node* childProperty = properties[i]; + if (childProperty->IsUnnamed()) { + uint32_t uPropHash = childProperty->GetClassHashCode(); + if (uPropHash == uNameHash) { + nodes.Add(childProperty); + } + } else if (childProperty->GetNameHash() == uNameHash && + childProperty->GetClassID() != XFA_ELEMENT_Extras && + childProperty->GetClassID() != XFA_ELEMENT_Items) { + nodes.Add(childProperty); + } + } + if (nodes.GetSize() > nNum) { + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + if (nodes.GetSize() > 0) { + return 1; + } + return 0; + } + CXFA_Node* pProp = NULL; + if (XFA_ELEMENT_Subform == curNode->GetClassID() && + XFA_HASHCODE_Occur == uNameHash) { + CXFA_Node* pInstanceManager = + curNode->AsNode()->GetInstanceMgrOfSubform(); + if (pInstanceManager) { + pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE); + } + } else { + const XFA_ELEMENTINFO* pElement = XFA_GetElementByName(wsName); + if (pElement) { + pProp = curNode->AsNode()->GetProperty( + 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet); + } + } + if (pProp) { + nodes.Add(pProp); + return nodes.GetSize(); + } + } + CXFA_Node* parentNode = m_pNodeHelper->XFA_ResolveNodes_GetParent( + curNode->AsNode(), XFA_LOGIC_NoTransparent); + uint32_t uCurClassHash = curNode->GetClassHashCode(); + if (!parentNode) { + if (uCurClassHash == uNameHash) { + nodes.Add(curNode->AsNode()); + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + if (nodes.GetSize() > 0) { + return 1; + } + } + return 0; + } + if (dwStyles & XFA_RESOLVENODE_Siblings) { + CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild); + FX_DWORD dwSubStyles = + XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties; + if (dwStyles & XFA_RESOLVENODE_TagName) { + dwSubStyles |= XFA_RESOLVENODE_TagName; + } + if (dwStyles & XFA_RESOLVENODE_ALL) { + dwSubStyles |= XFA_RESOLVENODE_ALL; + } + rndFind.m_dwStyles = dwSubStyles; + while (child) { + if (child == curNode) { + if (dwStyles & XFA_RESOLVENODE_TagName) { + if (uCurClassHash == uNameHash) { + nodes.Add(curNode); + } + } else { + if (child->GetNameHash() == uNameHash) { + nodes.Add(curNode); + if (rnd.m_nLevel == 0 && wsCondition.GetLength() == 0) { + nodes.RemoveAll(); + nodes.Add(curNode); + return 1; + } + } + } + child = child->GetNodeItem(XFA_NODEITEM_NextSibling); + continue; + } + if (dwStyles & XFA_RESOLVENODE_TagName) { + if (child->GetClassHashCode() == uNameHash) { + nodes.Add(child); + } + } else if (child->GetNameHash() == uNameHash) { + nodes.Add(child); + } + const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( + parentNode->GetClassID(), child->GetClassID(), XFA_XDPPACKET_UNKNOWN); + FX_BOOL bInnerSearch = FALSE; + if (pPropert) { + if ((child->GetClassID() == XFA_ELEMENT_Variables || + child->GetClassID() == XFA_ELEMENT_PageSet)) { + bInnerSearch = TRUE; + } + } else { + if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { + bInnerSearch = TRUE; + } + } + if (bInnerSearch) { + rndFind.m_CurNode = child; + CFX_WideString wsOriginCondition = rndFind.m_wsCondition; + rndFind.m_wsCondition.Empty(); + FX_DWORD dwOriginStyle = rndFind.m_dwStyles; + rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; + XFA_ResolveNodes_Normal(rndFind); + rndFind.m_dwStyles = dwOriginStyle; + rndFind.m_wsCondition = wsOriginCondition; + if (rndFind.m_Nodes.GetSize() > 0) { + nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + } + child = child->GetNodeItem(XFA_NODEITEM_NextSibling); + } + if (nodes.GetSize() > nNum) { + if (m_pNodeHelper->XFA_NodeIsTransparent(parentNode)) { + CXFA_NodeArray upArrayNodes; + m_pNodeHelper->XFA_CountSiblings( + ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, + !!(dwStyles & XFA_RESOLVENODE_TagName)); + if (upArrayNodes.GetSize() > nodes.GetSize()) { + upArrayNodes[0] = ToNode(nodes[0]); + nodes.RemoveAll(); + nodes.Append((CXFA_ObjArray&)upArrayNodes); + upArrayNodes.RemoveAll(); + } + } + XFA_ResolveNode_FilterCondition(rnd, wsCondition); + if (nodes.GetSize() > 0) { + return 1; + } + return 0; + } + } + if (dwStyles & XFA_RESOLVENODE_Parent) { + FX_DWORD dwSubStyles = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_Properties; + if (dwStyles & XFA_RESOLVENODE_TagName) { + dwSubStyles |= XFA_RESOLVENODE_TagName; + } + if (dwStyles & XFA_RESOLVENODE_ALL) { + dwSubStyles |= XFA_RESOLVENODE_ALL; + } + rndFind.m_dwStyles = dwSubStyles; + rndFind.m_CurNode = parentNode; + CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); + array.Add(parentNode); + XFA_ResolveNodes_Normal(rndFind); + if (rndFind.m_Nodes.GetSize() > 0) { + nodes.Append(rndFind.m_Nodes); + rndFind.m_Nodes.RemoveAll(); + } + if (nodes.GetSize() > nNum) { + return 1; + } + } + return 0; +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Asterisk( + CXFA_ResolveNodesData& rnd) { + CXFA_Node* curNode = ToNode(rnd.m_CurNode); + CXFA_ObjArray& nodes = rnd.m_Nodes; + CXFA_NodeArray array; + curNode->GetNodeList(array, + XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties); + nodes.Append((CXFA_ObjArray&)array); + return nodes.GetSize(); +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_PopStack( + CFX_Int32Array& stack) { + int32_t nType = -1; + int32_t iSize = stack.GetSize() - 1; + if (iSize > -1) { + nType = stack[iSize]; + stack.RemoveAt(iSize, 1); + } + return nType; +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter( + const CFX_WideStringC& wsExpression, + int32_t nStart, + CXFA_ResolveNodesData& rnd) { + FXSYS_assert(nStart > -1); + int32_t iLength = wsExpression.GetLength(); + if (nStart >= iLength) { + return 0; + } + CFX_WideString& wsName = rnd.m_wsName; + CFX_WideString& wsCondition = rnd.m_wsCondition; + FX_WCHAR* pNameBuf = wsName.GetBuffer(iLength - nStart); + FX_WCHAR* pConditionBuf = wsCondition.GetBuffer(iLength - nStart); + int32_t nNameCount = 0; + int32_t nConditionCount = 0; + CFX_Int32Array stack; + int32_t nType = -1; + const FX_WCHAR* pSrc = wsExpression.GetPtr(); + FX_WCHAR wPrev = 0, wCur; + FX_BOOL bIsCondition = FALSE; + while (nStart < iLength) { + wCur = pSrc[nStart++]; + if (wCur == '.') { + if (wPrev == '\\') { + pNameBuf[nNameCount - 1] = wPrev = '.'; + continue; + } + if (nNameCount == 0) { + pNameBuf[nNameCount++] = wCur; + continue; + } + FX_WCHAR wLookahead = nStart < iLength ? pSrc[nStart] : 0; + if (wLookahead != '[' && wLookahead != '(') { + if (nType < 0) { + break; + } + } + } + if (wCur == '[' || wCur == '(') { + bIsCondition = TRUE; + } else if (wCur == '.' && nStart < iLength && + (pSrc[nStart] == '[' || pSrc[nStart] == '(')) { + bIsCondition = TRUE; + } + if (bIsCondition) { + pConditionBuf[nConditionCount++] = wCur; + } else { + pNameBuf[nNameCount++] = wCur; + } + FX_BOOL bRecursive = TRUE; + switch (nType) { + case 0: + if (wCur == ']') { + nType = XFA_ResolveNodes_PopStack(stack); + bRecursive = FALSE; + } + break; + case 1: + if (wCur == ')') { + nType = XFA_ResolveNodes_PopStack(stack); + bRecursive = FALSE; + } + break; + case 2: + if (wCur == '"') { + nType = XFA_ResolveNodes_PopStack(stack); + bRecursive = FALSE; + } + break; + } + if (bRecursive) { + switch (wCur) { + case '[': + stack.Add(nType); + nType = 0; + break; + case '(': + stack.Add(nType); + nType = 1; + break; + case '"': + stack.Add(nType); + nType = 2; + break; + } + } + wPrev = wCur; + } + if (stack.GetSize() > 0) { + return -1; + } + wsName.ReleaseBuffer(nNameCount); + wsName.TrimLeft(); + wsName.TrimRight(); + wsCondition.ReleaseBuffer(nConditionCount); + wsCondition.TrimLeft(); + wsCondition.TrimRight(); + rnd.m_uHashName = FX_HashCode_String_GetW(wsName, wsName.GetLength()); + return nStart; +} +void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( + int32_t iCurIndex, + CFX_WideString wsCondition, + int32_t iFoundCount, + CXFA_ResolveNodesData& rnd) { + CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; + int32_t iLen = wsCondition.GetLength(); + FX_BOOL bRelative = FALSE; + FX_BOOL bAll = FALSE; + int32_t i = 1; + for (; i < iLen; ++i) { + FX_WCHAR ch = wsCondition[i]; + if (ch == ' ') { + continue; + } + if (ch == '+' || ch == '-') { + bRelative = TRUE; + break; + } else if (ch == '*') { + bAll = TRUE; + break; + } else { + break; + } + } + if (bAll) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) { + m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); + m_pNodeHelper->m_iCreateCount = 1; + findNodes.RemoveAll(); + m_pNodeHelper->m_iCurAllStart = -1; + m_pNodeHelper->m_pAllStartParent = NULL; + } else { + if (m_pNodeHelper->m_iCurAllStart == -1) { + m_pNodeHelper->m_iCurAllStart = m_iCurStart; + m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode); + } + } + } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) { + if (m_pNodeHelper->m_iCurAllStart == -1) { + m_pNodeHelper->m_iCurAllStart = m_iCurStart; + } + } + return; + } + if (iFoundCount == 1 && !iLen) { + return; + } + CFX_WideString wsIndex; + wsIndex = wsCondition.Mid(i, iLen - 1 - i); + int32_t iIndex = wsIndex.GetInteger(); + if (bRelative) { + iIndex += iCurIndex; + } + if (iFoundCount <= iIndex || iIndex < 0) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { + m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); + m_pNodeHelper->m_iCreateCount = iIndex - iFoundCount + 1; + } + findNodes.RemoveAll(); + } else { + CXFA_Node* ret = findNodes[iIndex]; + findNodes.RemoveAll(); + findNodes.Add(ret); + } +} +void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter( + int32_t iCurIndex, + CFX_WideString wsCondition, + int32_t iFoundCount, + CXFA_ResolveNodesData& rnd) { + CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; + FXSYS_assert(iFoundCount == findNodes.GetSize()); + CFX_WideString wsExpression; + IXFA_ScriptContext* pContext = NULL; + XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown; + if (wsCondition.Left(2) == FX_WSTRC(L".[") && + wsCondition.Right(1) == FX_WSTRC(L"]")) { + eLangType = XFA_SCRIPTLANGTYPE_Formcalc; + } else if (wsCondition.Left(2) == FX_WSTRC(L".(") && + wsCondition.Right(1) == FX_WSTRC(L")")) { + eLangType = XFA_SCRIPTLANGTYPE_Javascript; + } else { + return; + } + pContext = rnd.m_pSC; + wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3); + for (int32_t i = iFoundCount - 1; i >= 0; i--) { + CXFA_Object* node = findNodes[i]; + FX_BOOL bRet = FALSE; + FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime()); + bRet = pContext->RunScript(eLangType, wsExpression, pRetValue, node); + if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) { + findNodes.RemoveAt(i); + } + FXJSE_Value_Release(pRetValue); + } +} + +void CXFA_ResolveProcessor::XFA_ResolveNode_FilterCondition( + CXFA_ResolveNodesData& rnd, + CFX_WideString wsCondition) { + CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; + int32_t iCurrIndex = 0; + const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); + int32_t iSize = array.GetSize(); + if (iSize) { + CXFA_Node* curNode = array[iSize - 1]; + FX_BOOL bIsProperty = m_pNodeHelper->XFA_NodeIsProperty(curNode); + if (curNode->IsUnnamed() || + (bIsProperty && curNode->GetClassID() != XFA_ELEMENT_PageSet)) { + iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, + bIsProperty, TRUE); + } else { + iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, + bIsProperty, FALSE); + } + } + int32_t iFoundCount = findNodes.GetSize(); + wsCondition.TrimLeft(); + wsCondition.TrimRight(); + int32_t iLen = wsCondition.GetLength(); + if (!iLen) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_ALL) { + return; + } + if (iFoundCount == 1) { + return; + } + if (iFoundCount <= iCurrIndex) { + if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { + m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); + m_pNodeHelper->m_iCreateCount = iCurrIndex - iFoundCount + 1; + } + findNodes.RemoveAll(); + return; + } else { + CXFA_Node* ret = findNodes[iCurrIndex]; + findNodes.RemoveAll(); + findNodes.Add(ret); + return; + } + } + FX_WCHAR wTypeChar = wsCondition[0]; + switch (wTypeChar) { + case '[': + XFA_ResolveNode_ConditionArray(iCurrIndex, wsCondition, iFoundCount, rnd); + return; + case '(': + return; + case '"': + return; + case '.': + if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) { + XFA_ResolveNode_DoPredicateFilter(iCurrIndex, wsCondition, iFoundCount, + rnd); + } + default: + return; + } +} +void CXFA_ResolveProcessor::XFA_ResolveNodes_SetStylesForChild( + FX_DWORD dwParentStyles, + CXFA_ResolveNodesData& rnd) { + FX_DWORD dwSubStyles = XFA_RESOLVENODE_Children; + if (dwParentStyles & XFA_RESOLVENODE_TagName) { + dwSubStyles |= XFA_RESOLVENODE_TagName; + } + dwSubStyles &= ~XFA_RESOLVENODE_Parent; + dwSubStyles &= ~XFA_RESOLVENODE_Siblings; + dwSubStyles &= ~XFA_RESOLVENODE_Properties; + dwSubStyles |= XFA_RESOLVENODE_ALL; + rnd.m_dwStyles = dwSubStyles; +} +int32_t CXFA_ResolveProcessor::XFA_ResolveNode_SetResultCreateNode( + XFA_RESOLVENODE_RS& resolveNodeRS, + CFX_WideString& wsLastCondition) { + if (m_pNodeHelper->m_pCreateParent) { + resolveNodeRS.nodes.Add(m_pNodeHelper->m_pCreateParent); + } else { + m_pNodeHelper->XFA_CreateNode_ForCondition(wsLastCondition); + } + resolveNodeRS.dwFlags = m_pNodeHelper->m_iCreateFlag; + if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { + if (m_pNodeHelper->m_iCurAllStart != -1) { + resolveNodeRS.dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll; + } + } + return resolveNodeRS.nodes.GetSize(); +} +void CXFA_ResolveProcessor::XFA_ResolveNode_SetIndexDataBind( + CFX_WideString& wsNextCondition, + int32_t& iIndex, + int32_t iCount) { + if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { + if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { + iIndex = 0; + } else { + iIndex = iCount - 1; + } + } else { + iIndex = iCount - 1; + } +} diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.h b/xfa/fxfa/parser/xfa_script_resolveprocessor.h new file mode 100644 index 0000000000..fa34a88038 --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.h @@ -0,0 +1,86 @@ +// 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_SCRIPT_RESOLVEPROCESSOR_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_RESOLVEPROCESSOR_H_ + +#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; + +class CXFA_ResolveNodesData { + public: + CXFA_ResolveNodesData(CXFA_ScriptContext* pSC = NULL) + : m_pSC(pSC), + m_CurNode(NULL), + m_wsName(), + m_uHashName(0), + m_wsCondition(), + m_nLevel(0), + m_Nodes(), + m_dwStyles(XFA_RESOLVENODE_Children), + m_pScriptAttribute(NULL), + m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {} + ~CXFA_ResolveNodesData() { m_Nodes.RemoveAll(); } + CXFA_ScriptContext* m_pSC; + CXFA_Object* m_CurNode; + CFX_WideString m_wsName; + uint32_t m_uHashName; + CFX_WideString m_wsCondition; + int32_t m_nLevel; + CXFA_ObjArray m_Nodes; + FX_DWORD m_dwStyles; + const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute; + XFA_RESOVENODE_RSTYPE m_dwFlag; +}; +class CXFA_ResolveProcessor { + public: + CXFA_ResolveProcessor(void); + ~CXFA_ResolveProcessor(void); + int32_t XFA_ResolveNodes(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_AnyChild(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_Dollar(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_Excalmatory(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_NumberSign(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_Asterisk(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_Normal(CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_ForAttributeRs(CXFA_Object* curNode, + CXFA_ResolveNodesData& rnd, + const CFX_WideStringC& strAttr); + void XFA_ResolveNode_ConditionArray(int32_t iCurIndex, + CFX_WideString wsCondition, + int32_t iFoundCount, + CXFA_ResolveNodesData& rnd); + void XFA_ResolveNode_DoPredicateFilter(int32_t iCurIndex, + CFX_WideString wsCondition, + int32_t iFoundCount, + CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNodes_GetFilter(const CFX_WideStringC& wsExpression, + int32_t nStart, + CXFA_ResolveNodesData& rnd); + void XFA_ResolveNode_FilterCondition(CXFA_ResolveNodesData& rnd, + CFX_WideString wsCondition); + int32_t XFA_ResolveNodes_PopStack(CFX_Int32Array& stack); + void XFA_ResolveNodes_SetStylesForChild(FX_DWORD dwParentStyles, + CXFA_ResolveNodesData& rnd); + int32_t XFA_ResolveNode_SetResultCreateNode(XFA_RESOLVENODE_RS& resolveNodeRS, + CFX_WideString& wsLastCondition); + void XFA_ResolveNode_SetIndexDataBind(CFX_WideString& wsNextCondition, + int32_t& iIndex, + int32_t iCount); + CXFA_NodeHelper* GetNodeHelper() { return m_pNodeHelper; } + + private: + CXFA_NodeHelper* m_pNodeHelper; + + public: + int32_t m_iCurStart; +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_RESOLVEPROCESSOR_H_ diff --git a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp new file mode 100644 index 0000000000..ee33eb21ff --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp @@ -0,0 +1,124 @@ +// 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/fxfa/parser/xfa_script_signaturepseudomodel.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" +#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" + +CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( + CXFA_Document* pDocument) + : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_SignaturePseudoModel) { + m_uScriptHash = XFA_HASHCODE_Signature; +} +CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} +void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Verify( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 4) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CXFA_Node* pNode = NULL; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + int32_t bVerify = pNotify->GetDocProvider()->Verify(hDoc, pNode); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetInteger(hValue, bVerify); + } +} +void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Sign( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 3 || iLength > 7) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CXFA_NodeList* pNodeList = NULL; + CFX_WideString wsExpression; + CFX_WideString wsXMLIdent; + if (iLength >= 1) { + pNodeList = (CXFA_NodeList*)pArguments->GetObject(0); + } + if (iLength >= 2) { + CFX_ByteString bsExpression = pArguments->GetUTF8String(1); + wsExpression = + CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); + } + if (iLength >= 3) { + CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2); + wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent, bsXMLIdent.GetLength()); + } + FX_BOOL bSign = pNotify->GetDocProvider()->Sign(hDoc, pNodeList, wsExpression, + wsXMLIdent); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, bSign); + } +} +void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Enumerate( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength != 0) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CXFA_NodeList* pList = pNotify->GetDocProvider()->Enumerate(hDoc); + if (!pList) + return; + FXJSE_Value_Set(pArguments->GetReturnValue(), + m_pDocument->GetScriptContext()->GetJSValueFromMap(pList)); +} +void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Clear( + CFXJSE_Arguments* pArguments) { + int32_t iLength = pArguments->GetLength(); + if (iLength < 1 || iLength > 2) { + ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); + return; + } + IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); + if (!pNotify) { + return; + } + IXFA_Doc* hDoc = pNotify->GetHDOC(); + CXFA_Node* pNode = NULL; + FX_BOOL bClear = TRUE; + if (iLength >= 1) { + pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); + } + if (iLength >= 2) { + bClear = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; + } + FX_BOOL bFlag = pNotify->GetDocProvider()->Clear(hDoc, pNode, bClear); + FXJSE_HVALUE hValue = pArguments->GetReturnValue(); + if (hValue) { + FXJSE_Value_SetBoolean(hValue, bFlag); + } +} diff --git a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h new file mode 100644 index 0000000000..2591917c0d --- /dev/null +++ b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h @@ -0,0 +1,22 @@ +// 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_SCRIPT_SIGNATUREPSEUDOMODEL_H_ +#define XFA_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_ + +#include "xfa/fxfa/parser/xfa_object.h" + +class CScript_SignaturePseudoModel : public CXFA_OrdinaryObject { + public: + CScript_SignaturePseudoModel(CXFA_Document* pDocument); + ~CScript_SignaturePseudoModel(); + void Script_SignaturePseudoModel_Verify(CFXJSE_Arguments* pArguments); + void Script_SignaturePseudoModel_Sign(CFXJSE_Arguments* pArguments); + void Script_SignaturePseudoModel_Enumerate(CFXJSE_Arguments* pArguments); + void Script_SignaturePseudoModel_Clear(CFXJSE_Arguments* pArguments); +}; + +#endif // XFA_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h new file mode 100644 index 0000000000..6cc17d97c0 --- /dev/null +++ b/xfa/fxfa/parser/xfa_utils.h @@ -0,0 +1,219 @@ +// 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_UTILS_H_ +#define XFA_FXFA_PARSER_XFA_UTILS_H_ + +#include "xfa/fde/xml/fde_xml.h" +#include "xfa/include/fxfa/fxfa_basic.h" + +class CXFA_LocaleValue; + +FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( + IFDE_XMLElement* pNode, + const CFX_WideStringC& wsQualifier, + CFX_WideString& wsNamespaceURI); +template <class NodeType, class TraverseStrategy> +class CXFA_NodeIteratorTemplate { + public: + CXFA_NodeIteratorTemplate(NodeType* pRootNode = NULL) : m_pRoot(pRootNode) { + if (pRootNode) { + m_NodeStack.Push(pRootNode); + } + } + FX_BOOL Init(NodeType* pRootNode) { + if (!pRootNode) { + return FALSE; + } + m_pRoot = pRootNode; + m_NodeStack.RemoveAll(); + m_NodeStack.Push(pRootNode); + return TRUE; + } + void Clear() { m_NodeStack.RemoveAll(); } + void Reset() { + Clear(); + if (m_pRoot) { + m_NodeStack.Push(m_pRoot); + } + } + FX_BOOL SetCurrent(NodeType* pCurNode) { + m_NodeStack.RemoveAll(); + if (pCurNode) { + CFX_StackTemplate<NodeType*> revStack; + NodeType* pNode; + for (pNode = pCurNode; pNode && pNode != m_pRoot; + pNode = TraverseStrategy::GetParent(pNode)) { + revStack.Push(pNode); + } + if (!pNode) { + return FALSE; + } + revStack.Push(m_pRoot); + while (revStack.GetSize()) { + m_NodeStack.Push(*revStack.GetTopElement()); + revStack.Pop(); + } + } + return TRUE; + } + NodeType* GetCurrent() const { + return m_NodeStack.GetSize() ? *m_NodeStack.GetTopElement() : NULL; + } + NodeType* GetRoot() const { return m_pRoot; } + NodeType* MoveToPrev() { + int32_t nStackLength = m_NodeStack.GetSize(); + if (nStackLength == 1) { + return NULL; + } else if (nStackLength > 1) { + NodeType* pCurItem = *m_NodeStack.GetTopElement(); + m_NodeStack.Pop(); + NodeType* pParentItem = *m_NodeStack.GetTopElement(); + NodeType* pParentFirstChildItem = + TraverseStrategy::GetFirstChild(pParentItem); + if (pCurItem == pParentFirstChildItem) { + return pParentItem; + } + NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = NULL; + for (; pPrevItem; pPrevItem = pPrevItemNext) { + pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); + if (!pPrevItemNext || pPrevItemNext == pCurItem) { + break; + } + } + m_NodeStack.Push(pPrevItem); + } else { + m_NodeStack.RemoveAll(); + if (m_pRoot) { + m_NodeStack.Push(m_pRoot); + } + } + if (m_NodeStack.GetSize() > 0) { + NodeType* pChildItem = *m_NodeStack.GetTopElement(); + while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != + NULL) { + while (NodeType* pNextItem = + TraverseStrategy::GetNextSibling(pChildItem)) { + pChildItem = pNextItem; + } + m_NodeStack.Push(pChildItem); + } + return *m_NodeStack.GetTopElement(); + } + return NULL; + } + NodeType* MoveToNext() { + NodeType** ppNode = NULL; + NodeType* pCurrent = GetCurrent(); + while (m_NodeStack.GetSize() > 0) { + while ((ppNode = m_NodeStack.GetTopElement())) { + if (pCurrent != *ppNode) { + return *ppNode; + } + NodeType* pChild = TraverseStrategy::GetFirstChild(*ppNode); + if (pChild == NULL) { + break; + } + m_NodeStack.Push(pChild); + } + while ((ppNode = m_NodeStack.GetTopElement())) { + NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); + m_NodeStack.Pop(); + if (m_NodeStack.GetSize() == 0) { + break; + } + if (pNext) { + m_NodeStack.Push(pNext); + break; + } + } + } + return NULL; + } + NodeType* SkipChildrenAndMoveToNext() { + NodeType** ppNode = NULL; + while ((ppNode = m_NodeStack.GetTopElement())) { + NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); + m_NodeStack.Pop(); + if (m_NodeStack.GetSize() == 0) { + break; + } + if (pNext) { + m_NodeStack.Push(pNext); + break; + } + } + return GetCurrent(); + } + + protected: + 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); + +FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode); +void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, + CFX_WideString& wsPlainText); +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, + const FX_CHAR* pChecksum = NULL, + FX_BOOL bSaveXML = FALSE); + +#endif // XFA_FXFA_PARSER_XFA_UTILS_H_ diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp new file mode 100644 index 0000000000..c043e7cc67 --- /dev/null +++ b/xfa/fxfa/parser/xfa_utils_imp.cpp @@ -0,0 +1,403 @@ +// 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/fxfa/parser/xfa_utils.h" + +#include "core/include/fxcrt/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" +#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" + +CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_ELEMENT& eWidgetType) { + XFA_ELEMENT eType = pNode->GetClassID(); + eWidgetType = eType; + if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_Draw) { + return NULL; + } + eWidgetType = XFA_ELEMENT_UNKNOWN; + XFA_ELEMENT eUIType = XFA_ELEMENT_UNKNOWN; + CXFA_Value defValue(pNode->GetProperty(0, XFA_ELEMENT_Value, TRUE)); + XFA_ELEMENT eValueType = (XFA_ELEMENT)defValue.GetChildValueClassID(); + switch (eValueType) { + case XFA_ELEMENT_Boolean: + eUIType = XFA_ELEMENT_CheckButton; + break; + case XFA_ELEMENT_Integer: + case XFA_ELEMENT_Decimal: + case XFA_ELEMENT_Float: + eUIType = XFA_ELEMENT_NumericEdit; + break; + case XFA_ELEMENT_ExData: + case XFA_ELEMENT_Text: + eUIType = XFA_ELEMENT_TextEdit; + eWidgetType = XFA_ELEMENT_Text; + break; + case XFA_ELEMENT_Date: + case XFA_ELEMENT_Time: + case XFA_ELEMENT_DateTime: + eUIType = XFA_ELEMENT_DateTimeEdit; + break; + case XFA_ELEMENT_Image: + eUIType = XFA_ELEMENT_ImageEdit; + eWidgetType = XFA_ELEMENT_Image; + break; + case XFA_ELEMENT_Arc: + case XFA_ELEMENT_Line: + case XFA_ELEMENT_Rectangle: + eUIType = XFA_ELEMENT_DefaultUi; + eWidgetType = eValueType; + break; + default: + break; + } + CXFA_Node* pUIChild = NULL; + CXFA_Node* pUI = pNode->GetProperty(0, XFA_ELEMENT_Ui, TRUE); + CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); + for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + XFA_ELEMENT eChild = pChild->GetClassID(); + if (eChild == XFA_ELEMENT_Extras || eChild == XFA_ELEMENT_Picture) { + continue; + } + const XFA_PROPERTY* pProperty = + XFA_GetPropertyOfElement(XFA_ELEMENT_Ui, eChild, XFA_XDPPACKET_Form); + if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { + pUIChild = pChild; + break; + } + } + if (eType == XFA_ELEMENT_Draw) { + XFA_ELEMENT eDraw = pUIChild ? pUIChild->GetClassID() : XFA_ELEMENT_UNKNOWN; + switch (eDraw) { + case XFA_ELEMENT_TextEdit: + eWidgetType = XFA_ELEMENT_Text; + break; + case XFA_ELEMENT_ImageEdit: + eWidgetType = XFA_ELEMENT_Image; + break; + default: + eWidgetType = + eWidgetType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_Text : eWidgetType; + break; + } + } else { + if (pUIChild && pUIChild->GetClassID() == XFA_ELEMENT_DefaultUi) { + eWidgetType = XFA_ELEMENT_TextEdit; + } else { + eWidgetType = pUIChild + ? pUIChild->GetClassID() + : (eUIType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_TextEdit + : eUIType); + } + } + if (!pUIChild) { + if (eUIType == XFA_ELEMENT_UNKNOWN) { + eUIType = XFA_ELEMENT_TextEdit; + defValue.GetNode()->GetProperty(0, XFA_ELEMENT_Text, TRUE); + } + pUIChild = pUI->GetProperty(0, eUIType, TRUE); + } else if (eUIType == XFA_ELEMENT_UNKNOWN) { + switch (pUIChild->GetClassID()) { + case XFA_ELEMENT_CheckButton: { + eValueType = XFA_ELEMENT_Text; + if (CXFA_Node* pItems = pNode->GetChild(0, XFA_ELEMENT_Items)) { + if (CXFA_Node* pItem = pItems->GetChild(0, XFA_ELEMENT_UNKNOWN)) { + eValueType = pItem->GetClassID(); + } + } + } break; + case XFA_ELEMENT_DateTimeEdit: + eValueType = XFA_ELEMENT_DateTime; + break; + case XFA_ELEMENT_ImageEdit: + eValueType = XFA_ELEMENT_Image; + break; + case XFA_ELEMENT_NumericEdit: + eValueType = XFA_ELEMENT_Float; + break; + case XFA_ELEMENT_ChoiceList: { + eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) == + XFA_ATTRIBUTEENUM_MultiSelect) + ? XFA_ELEMENT_ExData + : XFA_ELEMENT_Text; + } break; + case XFA_ELEMENT_Barcode: + case XFA_ELEMENT_Button: + case XFA_ELEMENT_PasswordEdit: + case XFA_ELEMENT_Signature: + case XFA_ELEMENT_TextEdit: + default: + eValueType = XFA_ELEMENT_Text; + break; + } + defValue.GetNode()->GetProperty(0, eValueType, TRUE); + } + return pUIChild; +} +CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { + CXFA_Node* pNodeValue = + pWidgetData->GetNode()->GetChild(0, XFA_ELEMENT_Value); + if (!pNodeValue) { + return CXFA_LocaleValue(); + } + CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pValueChild) { + return CXFA_LocaleValue(); + } + int32_t iVTType = XFA_VT_NULL; + XFA_ELEMENT eType = pValueChild->GetClassID(); + switch (eType) { + case XFA_ELEMENT_Decimal: + iVTType = XFA_VT_DECIMAL; + break; + case XFA_ELEMENT_Float: + iVTType = XFA_VT_FLOAT; + break; + case XFA_ELEMENT_Date: + iVTType = XFA_VT_DATE; + break; + case XFA_ELEMENT_Time: + iVTType = XFA_VT_TIME; + break; + case XFA_ELEMENT_DateTime: + iVTType = XFA_VT_DATETIME; + break; + case XFA_ELEMENT_Boolean: + iVTType = XFA_VT_BOOLEAN; + break; + case XFA_ELEMENT_Integer: + iVTType = XFA_VT_INTEGER; + break; + case XFA_ELEMENT_Text: + iVTType = XFA_VT_TEXT; + break; + default: + iVTType = XFA_VT_NULL; + break; + } + return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), + pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); +} +void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, + CFX_WideString& wsPlainText) { + if (pXMLNode == NULL) { + return; + } + switch (pXMLNode->GetType()) { + case FDE_XMLNODE_Element: { + IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFX_WideString wsTag; + pXMLElement->GetLocalTagName(wsTag); + uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); + if (uTag == 0x0001f714) { + wsPlainText += L"\n"; + } else if (uTag == 0x00000070) { + if (!wsPlainText.IsEmpty()) { + wsPlainText += L"\n"; + } + } else if (uTag == 0xa48ac63) { + if (!wsPlainText.IsEmpty() && + wsPlainText[wsPlainText.GetLength() - 1] != '\n') { + wsPlainText += L"\n"; + } + } + } break; + case FDE_XMLNODE_Text: { + CFX_WideString wsContent; + ((IFDE_XMLText*)pXMLNode)->GetText(wsContent); + wsPlainText += wsContent; + } break; + case FDE_XMLNODE_CharData: { + CFX_WideString wsCharData; + ((IFDE_XMLCharData*)pXMLNode)->GetCharData(wsCharData); + wsPlainText += wsCharData; + } break; + default: + break; + } + for (IFDE_XMLNode* pChildXML = + pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + pChildXML; + pChildXML = pChildXML->GetNodeItem(IFDE_XMLNode::NextSibling)) { + XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); + } +} +FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { + FX_BOOL bRet = FALSE; + if (!pFieldNode) { + return bRet; + } + CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui); + if (pUIChild) { + CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pFirstChild && pFirstChild->GetClassID() == XFA_ELEMENT_ChoiceList) { + bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) == + XFA_ATTRIBUTEENUM_MultiSelect; + } + } + return bRet; +} +FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, FX_BOOL bLayoutContainer) { + switch (eElement) { + case XFA_ELEMENT_Draw: + case XFA_ELEMENT_Field: + case XFA_ELEMENT_InstanceManager: + return !bLayoutContainer; + case XFA_ELEMENT_Area: + case XFA_ELEMENT_Subform: + case XFA_ELEMENT_ExclGroup: + case XFA_ELEMENT_SubformSet: + return TRUE; + case XFA_ELEMENT_PageArea: + case XFA_ELEMENT_Form: + return TRUE; + default: + return FALSE; + } + 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, + 0.0001, + 0.00001, + 0.000001, + 0.0000001, + 0.00000001, + 0.000000001, + 0.0000000001, + 0.00000000001, + 0.000000000001, + 0.0000000000001, + 0.00000000000001, + 0.000000000000001, + 0.0000000000000001}; +FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal) { + CFX_WideString wsValue = wsStringVal; + wsValue.TrimLeft(); + wsValue.TrimRight(); + int64_t nIntegral = 0; + FX_DWORD dwFractional = 0; + int32_t nExponent = 0; + int32_t cc = 0; + FX_BOOL bNegative = FALSE, bExpSign = FALSE; + const FX_WCHAR* str = (const FX_WCHAR*)wsValue; + int32_t len = wsValue.GetLength(); + if (str[0] == '+') { + cc++; + } else if (str[0] == '-') { + bNegative = TRUE; + cc++; + } + int32_t nIntegralLen = 0; + while (cc < len) { + if (str[cc] == '.' || str[cc] == 'E' || str[cc] == 'e' || + nIntegralLen > 17) { + break; + } + if (!XFA_IsDigit(str[cc])) { + return 0; + } + nIntegral = nIntegral * 10 + str[cc] - '0'; + cc++; + nIntegralLen++; + } + nIntegral = bNegative ? -nIntegral : nIntegral; + int32_t scale = 0; + FX_DOUBLE fraction = 0.0; + if (cc < len && str[cc] == '.') { + cc++; + while (cc < len) { + fraction += fraction_scales[scale] * (str[cc] - '0'); + scale++; + cc++; + if (cc == len) { + break; + } + if (scale == sizeof(fraction_scales) / sizeof(FX_DOUBLE) || + str[cc] == 'E' || str[cc] == 'e') { + break; + } + if (!XFA_IsDigit(str[cc])) { + return 0; + } + } + dwFractional = (FX_DWORD)(fraction * 4294967296.0); + } + if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { + cc++; + if (cc < len) { + if (str[cc] == '+') { + cc++; + } else if (str[cc] == '-') { + bExpSign = TRUE; + cc++; + } + } + while (cc < len) { + if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { + return 0; + } + nExponent = nExponent * 10 + str[cc] - '0'; + cc++; + } + nExponent = bExpSign ? -nExponent : nExponent; + } + FX_DOUBLE dValue = (dwFractional / 4294967296.0); + dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); + if (nExponent != 0) { + dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); + } + return dValue; +} + +FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { + CFX_WideString wsValue = + CFX_WideString::FromUTF8(szStringVal.GetCStr(), szStringVal.GetLength()); + return XFA_WideStringToDouble(wsValue); +} + +int32_t XFA_MapRotation(int32_t nRotation) { + nRotation = nRotation % 360; + nRotation = nRotation < 0 ? nRotation + 360 : nRotation; + return nRotation; +} diff --git a/xfa/fxfa/parser/xfa_utils_imp_unittest.cpp b/xfa/fxfa/parser/xfa_utils_imp_unittest.cpp new file mode 100644 index 0000000000..93ee3b94aa --- /dev/null +++ b/xfa/fxfa/parser/xfa_utils_imp_unittest.cpp @@ -0,0 +1,22 @@ +// 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. + +#include "testing/gtest/include/gtest/gtest.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +TEST(XfaUtilsImp, XFA_MapRotation) { + struct TestCase { + int input; + int expected_output; + } TestCases[] = {{-1000000, 80}, {-361, 359}, {-360, 0}, {-359, 1}, + {-91, 269}, {-90, 270}, {-89, 271}, {-1, 359}, + {0, 0}, {1, 1}, {89, 89}, {90, 90}, + {91, 91}, {359, 359}, {360, 0}, {361, 1}, + {100000, 280}}; + + for (size_t i = 0; i < FX_ArraySize(TestCases); ++i) { + EXPECT_EQ(TestCases[i].expected_output, + XFA_MapRotation(TestCases[i].input)); + } +} diff --git a/xfa/fxgraphics/fx_graphics.cpp b/xfa/fxgraphics/fx_graphics.cpp new file mode 100644 index 0000000000..a3fb84dbb0 --- /dev/null +++ b/xfa/fxgraphics/fx_graphics.cpp @@ -0,0 +1,1548 @@ +// 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/include/fxgraphics/fx_graphics.h" + +#include <memory> + +#include "xfa/fxgraphics/fx_path_generator.h" +#include "xfa/fxgraphics/pre.h" + +class CAGG_Graphics { + public: + CAGG_Graphics(); + FX_ERR Create(CFX_Graphics* owner, + int32_t width, + int32_t height, + FXDIB_Format format); + virtual ~CAGG_Graphics(); + + private: + CFX_Graphics* _owner; +}; +CFX_Graphics::CFX_Graphics() { + _type = FX_CONTEXT_None; + _info._graphState.SetDashCount(0); + _info._isAntialiasing = TRUE; + _info._strokeAlignment = FX_STROKEALIGNMENT_Center; + _info._CTM.SetIdentity(); + _info._isActOnDash = FALSE; + _info._strokeColor = NULL; + _info._fillColor = NULL; + _info._font = NULL; + _info._fontSize = 40.0; + _info._fontHScale = 1.0; + _info._fontSpacing = 0.0; + _renderDevice = NULL; + _aggGraphics = NULL; +} +FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, + FX_BOOL isAntialiasing) { + if (!renderDevice) + return FX_ERR_Parameter_Invalid; + if (_type != FX_CONTEXT_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_CONTEXT_Device; + _info._isAntialiasing = isAntialiasing; + _renderDevice = renderDevice; + if (_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) { + return FX_ERR_Succeeded; + } + return FX_ERR_Indefinite; +} +FX_ERR CFX_Graphics::Create(int32_t width, + int32_t height, + FXDIB_Format format, + FX_BOOL isNative, + FX_BOOL isAntialiasing) { + if (_type != FX_CONTEXT_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_CONTEXT_Device; + _info._isAntialiasing = isAntialiasing; + { + _aggGraphics = new CAGG_Graphics; + return _aggGraphics->Create(this, width, height, format); + } +} +CFX_Graphics::~CFX_Graphics() { + if (_aggGraphics) { + delete _aggGraphics; + _aggGraphics = NULL; + } + _renderDevice = NULL; + _info._graphState.SetDashCount(0); + _type = FX_CONTEXT_None; +} +FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + capVal = _renderDevice->GetDeviceCaps(capID); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + int32_t deviceClass = _renderDevice->GetDeviceClass(); + if (deviceClass == FXDC_PRINTER) { + isPrinter = TRUE; + } else { + isPrinter = FALSE; + } + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._isAntialiasing = isAntialiasing; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SaveGraphState() { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _renderDevice->SaveState(); + TInfo* info = new TInfo; + info->_graphState.Copy(_info._graphState); + info->_isAntialiasing = _info._isAntialiasing; + info->_strokeAlignment = _info._strokeAlignment; + info->_CTM = _info._CTM; + info->_isActOnDash = _info._isActOnDash; + info->_strokeColor = _info._strokeColor; + info->_fillColor = _info._fillColor; + info->_font = _info._font; + info->_fontSize = _info._fontSize; + info->_fontHScale = _info._fontHScale; + info->_fontSpacing = _info._fontSpacing; + _infoStack.Add(info); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::RestoreGraphState() { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _renderDevice->RestoreState(); + int32_t size = _infoStack.GetSize(); + if (size <= 0) { + return FX_ERR_Intermediate_Value_Invalid; + } + int32_t topIndex = size - 1; + TInfo* info = (TInfo*)_infoStack.GetAt(topIndex); + if (!info) + return FX_ERR_Intermediate_Value_Invalid; + _info._graphState.Copy(info->_graphState); + _info._isAntialiasing = info->_isAntialiasing; + _info._strokeAlignment = info->_strokeAlignment; + _info._CTM = info->_CTM; + _info._isActOnDash = info->_isActOnDash; + _info._strokeColor = info->_strokeColor; + _info._fillColor = info->_fillColor; + _info._font = info->_font; + _info._fontSize = info->_fontSize; + _info._fontHScale = info->_fontHScale; + _info._fontSpacing = info->_fontSpacing; + delete info; + info = NULL; + _infoStack.RemoveAt(topIndex); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + lineCap = _info._graphState.m_LineCap; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._graphState.m_LineCap = lineCap; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + dashCount = _info._graphState.m_DashCount; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) { + if (!dashArray) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + dashPhase = _info._graphState.m_DashPhase; + FXSYS_memcpy(dashArray, _info._graphState.m_DashArray, + _info._graphState.m_DashCount * sizeof(FX_FLOAT)); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, + FX_FLOAT* dashArray, + int32_t dashCount) { + if (dashCount > 0 && !dashArray) { + return FX_ERR_Parameter_Invalid; + } + dashCount = dashCount < 0 ? 0 : dashCount; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + FX_FLOAT scale = 1.0; + if (_info._isActOnDash) { + scale = _info._graphState.m_LineWidth; + } + _info._graphState.m_DashPhase = dashPhase; + _info._graphState.SetDashCount(dashCount); + for (int32_t i = 0; i < dashCount; i++) { + _info._graphState.m_DashArray[i] = dashArray[i] * scale; + } + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceSetLineDash(dashStyle); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + lineJoin = _info._graphState.m_LineJoin; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._graphState.m_LineJoin = lineJoin; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + miterLimit = _info._graphState.m_MiterLimit; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._graphState.m_MiterLimit = miterLimit; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + lineWidth = _info._graphState.m_LineWidth; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._graphState.m_LineWidth = lineWidth; + _info._isActOnDash = isActOnDash; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + strokeAlignment = _info._strokeAlignment; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._strokeAlignment = strokeAlignment; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { + if (!color) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._strokeColor = color; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { + if (!color) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._fillColor = color; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceStrokePath(path, matrix); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::FillPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceFillPath(path, fillMode, matrix); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + FX_BOOL result = _renderDevice->SetClip_PathFill( + path->GetPathData(), (CFX_Matrix*)matrix, fillMode); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix) { + if (!source) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceDrawImage(source, point, matrix); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix) { + if (!source) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceStretchImage(source, rect, matrix); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { + if (!matrix) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._CTM.Concat(*matrix); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +CFX_Matrix* CFX_Graphics::GetMatrix() { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return NULL; + return &_info._CTM; + } + default: { return NULL; } + } +} +FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + FX_RECT r = _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; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + if (!_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 FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::ClearClip() { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { + if (!font) + return FX_ERR_Parameter_Invalid; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._font = font; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { + FX_FLOAT fontSize = size <= 0 ? 1.0f : size; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._fontSize = fontSize; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { + FX_FLOAT fontHScale = scale <= 0 ? 1.0f : scale; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._fontHScale = fontHScale; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { + FX_FLOAT fontSpacing = spacing < 0 ? 0 : spacing; + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + _info._fontSpacing = fontSpacing; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + return RenderDeviceShowText(point, text, matrix); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, + const CFX_WideString& text, + FX_BOOL isMultiline, + CFX_Matrix* matrix) { + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + int32_t length = text.GetLength(); + FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); + CalcTextInfo(text, charCodes, charPos, rect); + FX_Free(charPos); + FX_Free(charCodes); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, + const CFX_Matrix* matrix) { + if (!graphics) + return FX_ERR_Parameter_Invalid; + CFX_Matrix m; + m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + { + if (!graphics->_renderDevice) + return FX_ERR_Parameter_Invalid; + CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); + FX_BOOL result = _renderDevice->SetDIBits(bitmap, 0, 0); + if (!result) + return FX_ERR_Method_Not_Supported; + } + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, + FX_FLOAT srcLeft, + FX_FLOAT srcTop, + const CFX_RectF& dstRect, + const CFX_Matrix* matrix) { + if (!graphics) + return FX_ERR_Parameter_Invalid; + CFX_Matrix m; + m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (_type) { + case FX_CONTEXT_Device: { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + { + if (!graphics->_renderDevice) + return FX_ERR_Parameter_Invalid; + CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); + CFX_DIBitmap bmp; + FX_BOOL result = + bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, + bitmap->GetFormat()); + if (!result) + return FX_ERR_Intermediate_Value_Invalid; + result = graphics->_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, + (int32_t)srcTop); + if (!result) + return FX_ERR_Method_Not_Supported; + result = _renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, + (int32_t)dstRect.top); + if (!result) + return FX_ERR_Method_Not_Supported; + return FX_ERR_Succeeded; + } + } + default: { return FX_ERR_Property_Invalid; } + } +} +CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { + return _renderDevice; +} +FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); + if (!bitmap) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + _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; + } + FX_ARGB* pBuf = + (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pLine = pBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pLine; + *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); + } + pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); + } + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, + const CFX_RectF& rect) { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* dst = _renderDevice->GetBitmap(); + if (!dst) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + _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; + } + FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + + int32_t(r.top) * srcBitmap->GetPitch()); + FX_ARGB* pDstBuf = + (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; + FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pDstLine; + *pDstLine++ = + ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); + pSrcLine++; + } + pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); + pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); + } + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, + const CFX_RectF& rect) { + if (!_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* dst = _renderDevice->GetBitmap(); + if (!dst) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + _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; + } + FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + + int32_t(r.top) * srcBitmap->GetPitch()); + FX_ARGB* pDstBuf = + (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; + FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pDstLine; + *pDstLine++ = + ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); + pSrcLine++; + } + pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); + pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); + } + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { + switch (dashStyle) { + case FX_DASHSTYLE_Solid: { + _info._graphState.SetDashCount(0); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_Dash: { + FX_FLOAT dashArray[] = {3, 1}; + SetLineDash(0, dashArray, 2); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_Dot: { + FX_FLOAT dashArray[] = {1, 1}; + SetLineDash(0, dashArray, 2); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_DashDot: { + FX_FLOAT dashArray[] = {3, 1, 1, 1}; + SetLineDash(0, dashArray, 4); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_DashDotDot: { + FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; + SetLineDash(0, dashArray, 6); + return FX_ERR_Succeeded; + } + default: { return FX_ERR_Parameter_Invalid; } + } +} +FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, + CFX_Matrix* matrix) { + if (!_info._strokeColor) + return FX_ERR_Property_Invalid; + CFX_Matrix m; + m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (_info._strokeColor->_type) { + case FX_COLOR_Solid: { + FX_BOOL result = _renderDevice->DrawPath( + path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 0x0, + _info._strokeColor->_argb, 0); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_Succeeded; + } + case FX_COLOR_Pattern: { + return StrokePathWithPattern(path, &m); + } + case FX_COLOR_Shading: { + return StrokePathWithShading(path, &m); + } + default: { return FX_ERR_Property_Invalid; } + } +} +FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!_info._fillColor) + return FX_ERR_Property_Invalid; + CFX_Matrix m; + m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (_info._fillColor->_type) { + case FX_COLOR_Solid: { + FX_BOOL result = _renderDevice->DrawPath( + path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, + _info._fillColor->_argb, 0x0, fillMode); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_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; } + } +} +FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix) { + CFX_Matrix m1; + m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m1.Concat(*matrix); + } + CFX_Matrix m2; + m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), + point.x, point.y); + m2.Concat(m1); + int32_t left, top; + CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); + CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m2, left, top); + CFX_RectF r; + GetClipRect(r); + FX_ERR result = FX_ERR_Indefinite; + { + CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); + CFX_DIBitmap bmp; + bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb); + _renderDevice->GetDIBits(&bmp, 0, 0); + bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), + FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp2, + FXSYS_round(r.left - left), FXSYS_round(r.top - top)); + _renderDevice->SetDIBits(&bmp, 0, 0); + result = FX_ERR_Succeeded; + } + if (bmp2) { + delete bmp2; + bmp2 = NULL; + } + if (bmp1) { + delete bmp1; + bmp1 = NULL; + } + return result; +} +FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix) { + CFX_Matrix m1; + m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + if (matrix) { + m1.Concat(*matrix); + } + CFX_DIBitmap* bmp1 = + source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); + CFX_Matrix m2; + m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); + m2.Concat(m1); + int32_t left, top; + CFX_DIBitmap* bmp2 = bmp1->FlipImage(FALSE, TRUE); + CFX_DIBitmap* bmp3 = bmp2->TransformTo((CFX_Matrix*)&m2, left, top); + CFX_RectF r; + GetClipRect(r); + FX_ERR result = FX_ERR_Indefinite; + { + CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); + bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), + FXSYS_round(r.Width()), FXSYS_round(r.Height()), + bmp3, FXSYS_round(r.left - left), + FXSYS_round(r.top - top)); + result = FX_ERR_Succeeded; + } + if (bmp3) { + delete bmp3; + bmp3 = NULL; + } + if (bmp2) { + delete bmp2; + bmp2 = NULL; + } + if (bmp1) { + delete bmp1; + bmp1 = NULL; + } + return result; +} +FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix) { + int32_t length = text.GetLength(); + FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); + CFX_RectF rect; + rect.Set(point.x, point.y, 0, 0); + CalcTextInfo(text, charCodes, charPos, rect); + CFX_Matrix m; + m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, + _info._CTM.f); + m.Translate(0, _info._fontSize * _info._fontHScale); + if (matrix) { + m.Concat(*matrix); + } + FX_BOOL result = _renderDevice->DrawNormalText( + length, charPos, _info._font, CFX_GEModule::Get()->GetFontCache(), + -_info._fontSize * _info._fontHScale, (CFX_Matrix*)&m, + _info._fillColor->_argb, FXTEXT_CLEARTYPE); + if (!result) + return FX_ERR_Indefinite; + FX_Free(charPos); + FX_Free(charCodes); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { + return FX_ERR_Method_Not_Supported; +} +FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { + return FX_ERR_Method_Not_Supported; +} +FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + CFX_Pattern* pattern = _info._fillColor->_pattern; + CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); + int32_t width = bitmap->GetWidth(); + int32_t height = bitmap->GetHeight(); + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + _renderDevice->GetDIBits(&bmp, 0, 0); + switch (pattern->_type) { + case FX_PATTERN_Bitmap: { + int32_t xStep = FXSYS_round(pattern->_x1Step); + int32_t yStep = FXSYS_round(pattern->_y1Step); + int32_t xCount = width / xStep + 1; + int32_t yCount = height / yStep + 1; + for (int32_t i = 0; i <= yCount; i++) { + for (int32_t j = 0; j <= xCount; j++) { + bmp.TransferBitmap(j * xStep, i * yStep, xStep, yStep, + pattern->_bitmap, 0, 0); + } + } + break; + } + case FX_PATTERN_Hatch: { + FX_HatchStyle hatchStyle = _info._fillColor->_pattern->_hatchStyle; + if (hatchStyle < FX_HATCHSTYLE_Horizontal || + hatchStyle > FX_HATCHSTYLE_SolidDiamond) { + return FX_ERR_Intermediate_Value_Invalid; + } + const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; + CFX_DIBitmap mask; + mask.Create(data.width, data.height, FXDIB_1bppMask); + FXSYS_memcpy(mask.GetBuffer(), data.maskBits, + mask.GetPitch() * data.height); + CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); + if (matrix) { + rectf.Transform((const CFX_Matrix*)matrix); + } + FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), + FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); + CFX_FxgeDevice device; + device.Attach(&bmp); + device.FillRect(&rect, _info._fillColor->_pattern->_backArgb); + for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { + for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { + device.SetBitMask(&mask, i, j, _info._fillColor->_pattern->_foreArgb); + } + } + break; + } + } + _renderDevice->SaveState(); + _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, + fillMode); + SetDIBitsWithMatrix(&bmp, &pattern->_matrix); + _renderDevice->RestoreState(); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); + int32_t width = bitmap->GetWidth(); + int32_t height = bitmap->GetHeight(); + FX_FLOAT start_x = _info._fillColor->_shading->_beginPoint.x; + FX_FLOAT start_y = _info._fillColor->_shading->_beginPoint.y; + FX_FLOAT end_x = _info._fillColor->_shading->_endPoint.x; + FX_FLOAT end_y = _info._fillColor->_shading->_endPoint.y; + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + _renderDevice->GetDIBits(&bmp, 0, 0); + int32_t pitch = bmp.GetPitch(); + FX_BOOL result = FALSE; + switch (_info._fillColor->_shading->_type) { + case FX_SHADING_Axial: { + FX_FLOAT x_span = end_x - start_x; + FX_FLOAT y_span = end_y - start_y; + FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); + for (int32_t row = 0; row < height; row++) { + FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); + for (int32_t column = 0; column < width; column++) { + FX_FLOAT x = (FX_FLOAT)(column); + FX_FLOAT y = (FX_FLOAT)(row); + FX_FLOAT scale = + (((x - start_x) * x_span) + ((y - start_y) * y_span)) / + axis_len_square; + if (scale < 0) { + if (!_info._fillColor->_shading->_isExtendedBegin) { + continue; + } + scale = 0; + } else if (scale > 1.0f) { + if (!_info._fillColor->_shading->_isExtendedEnd) { + continue; + } + scale = 1.0f; + } + int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); + dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; + } + } + result = TRUE; + break; + } + case FX_SHADING_Radial: { + FX_FLOAT start_r = _info._fillColor->_shading->_beginRadius; + FX_FLOAT end_r = _info._fillColor->_shading->_endRadius; + FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + + ((start_y - end_y) * (start_y - end_y)) - + ((start_r - end_r) * (start_r - end_r)); + for (int32_t row = 0; row < height; row++) { + FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); + for (int32_t column = 0; column < width; column++) { + FX_FLOAT x = (FX_FLOAT)(column); + FX_FLOAT y = (FX_FLOAT)(row); + FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + + ((y - start_y) * (end_y - start_y)) + + (start_r * (end_r - start_r))); + FX_FLOAT c = ((x - start_x) * (x - start_x)) + + ((y - start_y) * (y - start_y)) - (start_r * start_r); + FX_FLOAT s; + if (a == 0) { + s = -c / b; + } else { + FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); + if (b2_4ac < 0) { + continue; + } + FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); + FX_FLOAT s1, s2; + if (a > 0) { + s1 = (-b - root) / (2 * a); + s2 = (-b + root) / (2 * a); + } else { + s2 = (-b - root) / (2 * a); + s1 = (-b + root) / (2 * a); + } + if (s2 <= 1.0f || _info._fillColor->_shading->_isExtendedEnd) { + s = (s2); + } else { + s = (s1); + } + if ((start_r) + s * (end_r - start_r) < 0) { + continue; + } + } + if (s < 0) { + if (!_info._fillColor->_shading->_isExtendedBegin) { + continue; + } + s = 0; + } + if (s > 1.0f) { + if (!_info._fillColor->_shading->_isExtendedEnd) { + continue; + } + s = 1.0f; + } + int index = (int32_t)(s * (FX_SHADING_Steps - 1)); + dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; + } + } + result = TRUE; + break; + } + default: { result = FALSE; } + } + if (result) { + _renderDevice->SaveState(); + _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, + fillMode); + SetDIBitsWithMatrix(&bmp, matrix); + _renderDevice->RestoreState(); + } + return result; +} +FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, + CFX_Matrix* matrix) { + if (matrix->IsIdentity()) { + _renderDevice->SetDIBits(source, 0, 0); + } else { + CFX_Matrix m; + m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, + 0); + m.Concat(*matrix); + int32_t left, top; + CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); + CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m, left, top); + _renderDevice->SetDIBits(bmp2, left, top); + if (bmp2) { + delete bmp2; + bmp2 = NULL; + } + if (bmp1) { + delete bmp1; + bmp1 = NULL; + } + } + return FX_ERR_Succeeded; +} +FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, + FX_DWORD* charCodes, + FXTEXT_CHARPOS* charPos, + CFX_RectF& rect) { + std::unique_ptr<CFX_UnicodeEncoding> encoding( + new CFX_UnicodeEncoding(_info._font)); + int32_t length = text.GetLength(); + FX_FLOAT penX = (FX_FLOAT)rect.left; + FX_FLOAT penY = (FX_FLOAT)rect.top; + FX_FLOAT left = (FX_FLOAT)(0); + FX_FLOAT top = (FX_FLOAT)(0); + charCodes[0] = text.GetAt(0); + charPos[0].m_OriginX = penX + left; + charPos[0].m_OriginY = penY + top; + charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); + charPos[0].m_FontCharWidth = FXSYS_round( + _info._font->GetGlyphWidth(charPos[0].m_GlyphIndex) * _info._fontHScale); + charPos[0].m_bGlyphAdjust = TRUE; + charPos[0].m_AdjustMatrix[0] = -1; + charPos[0].m_AdjustMatrix[1] = 0; + charPos[0].m_AdjustMatrix[2] = 0; + charPos[0].m_AdjustMatrix[3] = 1; + penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * _info._fontSize / 1000 + + _info._fontSpacing; + for (int32_t i = 1; i < length; i++) { + charCodes[i] = text.GetAt(i); + charPos[i].m_OriginX = penX + left; + charPos[i].m_OriginY = penY + top; + charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); + charPos[i].m_FontCharWidth = + FXSYS_round(_info._font->GetGlyphWidth(charPos[i].m_GlyphIndex) * + _info._fontHScale); + charPos[i].m_bGlyphAdjust = TRUE; + charPos[i].m_AdjustMatrix[0] = -1; + charPos[i].m_AdjustMatrix[1] = 0; + charPos[i].m_AdjustMatrix[2] = 0; + charPos[i].m_AdjustMatrix[3] = 1; + penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * _info._fontSize / 1000 + + _info._fontSpacing; + } + rect.width = (FX_FLOAT)penX - rect.left; + rect.height = rect.top + _info._fontSize * _info._fontHScale - rect.top; + return FX_ERR_Succeeded; +} +CAGG_Graphics::CAGG_Graphics() { + _owner = NULL; +} +FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, + int32_t width, + int32_t height, + FXDIB_Format format) { + if (owner->_renderDevice) { + return FX_ERR_Parameter_Invalid; + } + if (_owner) { + return FX_ERR_Property_Invalid; + } + CFX_FxgeDevice* device = new CFX_FxgeDevice; + device->Create(width, height, format); + _owner = owner; + _owner->_renderDevice = device; + _owner->_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); + return FX_ERR_Succeeded; +} +CAGG_Graphics::~CAGG_Graphics() { + if (_owner->_renderDevice) { + delete (CFX_FxgeDevice*)_owner->_renderDevice; + } + _owner = NULL; +} +CFX_Path::CFX_Path() { + _generator = NULL; +} +FX_ERR CFX_Path::Create() { + if (_generator) { + return FX_ERR_Property_Invalid; + } + _generator = new CFX_PathGenerator; + _generator->Create(); + return FX_ERR_Succeeded; +} +CFX_Path::~CFX_Path() { + if (_generator) { + delete _generator; + _generator = NULL; + } +} +FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->MoveTo(x, y); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->LineTo(x, y); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, + FX_FLOAT ctrlY1, + FX_FLOAT ctrlX2, + FX_FLOAT ctrlY2, + FX_FLOAT toX, + FX_FLOAT toY) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::ArcTo(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::Close() { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->Close(); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddLine(x1, y1, x2, y2); + return FX_ERR_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) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, + endY); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddRectangle(left, top, left + width, top + height); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddEllipse(left + width / 2, top + height / 2, width / 2, + height / 2); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddEllipse(rect.left + rect.Width() / 2, + rect.top + rect.Height() / 2, rect.Width() / 2, + rect.Height() / 2); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddArc(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddPie(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->AddPathData(path->GetPathData()); + return FX_ERR_Succeeded; +} +FX_ERR CFX_Path::Clear() { + if (!_generator) + return FX_ERR_Property_Invalid; + _generator->GetPathData()->SetPointCount(0); + return FX_ERR_Succeeded; +} +FX_BOOL CFX_Path::IsEmpty() { + if (!_generator) + return FX_ERR_Property_Invalid; + if (_generator->GetPathData()->GetPointCount() == 0) { + return TRUE; + } + return FALSE; +} +CFX_PathData* CFX_Path::GetPathData() { + if (!_generator) + return NULL; + return _generator->GetPathData(); +} +CFX_Color::CFX_Color() { + _type = FX_COLOR_None; +} +CFX_Color::CFX_Color(const FX_ARGB argb) { + _type = FX_COLOR_None; + Set(argb); +} +CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { + _type = FX_COLOR_None; + Set(pattern, argb); +} +CFX_Color::CFX_Color(CFX_Shading* shading) { + _type = FX_COLOR_None; + Set(shading); +} +CFX_Color::~CFX_Color() { + _type = FX_COLOR_None; +} +FX_ERR CFX_Color::Set(const FX_ARGB argb) { + _type = FX_COLOR_Solid; + _argb = argb; + _pattern = NULL; + return FX_ERR_Succeeded; +} +FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { + if (!pattern) + return FX_ERR_Parameter_Invalid; + _type = FX_COLOR_Pattern; + _argb = argb; + _pattern = pattern; + return FX_ERR_Succeeded; +} +FX_ERR CFX_Color::Set(CFX_Shading* shading) { + if (!shading) + return FX_ERR_Parameter_Invalid; + _type = FX_COLOR_Shading; + _shading = shading; + return FX_ERR_Succeeded; +} +CFX_Pattern::CFX_Pattern() { + _type = FX_PATTERN_None; + _matrix.SetIdentity(); +} +FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, + const FX_FLOAT xStep, + const FX_FLOAT yStep, + CFX_Matrix* matrix) { + if (!bitmap) + return FX_ERR_Parameter_Invalid; + if (_type != FX_PATTERN_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_PATTERN_Bitmap; + _bitmap = bitmap; + _x1Step = xStep; + _y1Step = yStep; + if (matrix) { + _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, + matrix->f); + } + return FX_ERR_Succeeded; +} +FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle, + const FX_ARGB foreArgb, + const FX_ARGB backArgb, + CFX_Matrix* matrix) { + if (hatchStyle < FX_HATCHSTYLE_Horizontal || + hatchStyle > FX_HATCHSTYLE_SolidDiamond) { + return FX_ERR_Parameter_Invalid; + } + if (_type != FX_PATTERN_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_PATTERN_Hatch; + _hatchStyle = hatchStyle; + _foreArgb = foreArgb; + _backArgb = backArgb; + if (matrix) { + _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, + matrix->f); + } + return FX_ERR_Succeeded; +} +CFX_Pattern::~CFX_Pattern() { + _type = FX_PATTERN_None; +} +CFX_Shading::CFX_Shading() { + _type = FX_SHADING_None; +} +FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) { + if (_type != FX_SHADING_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_SHADING_Axial; + _beginPoint = beginPoint; + _endPoint = endPoint; + _isExtendedBegin = isExtendedBegin; + _isExtendedEnd = isExtendedEnd; + _beginArgb = beginArgb; + _endArgb = endArgb; + return InitArgbArray(); +} +FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + const FX_FLOAT beginRadius, + const FX_FLOAT endRadius, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) { + if (_type != FX_SHADING_None) { + return FX_ERR_Property_Invalid; + } + _type = FX_SHADING_Radial; + _beginPoint = beginPoint; + _endPoint = endPoint; + _beginRadius = beginRadius; + _endRadius = endRadius; + _isExtendedBegin = isExtendedBegin; + _isExtendedEnd = isExtendedEnd; + _beginArgb = beginArgb; + _endArgb = endArgb; + return InitArgbArray(); +} +CFX_Shading::~CFX_Shading() { + _type = FX_SHADING_None; +} +FX_ERR CFX_Shading::InitArgbArray() { + int32_t a1, r1, g1, b1; + ArgbDecode(_beginArgb, a1, r1, g1, b1); + int32_t a2, r2, g2, b2; + ArgbDecode(_endArgb, a2, r2, g2, b2); + FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); + FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f); + FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f); + FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f); + FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f); + int32_t a3, r3, g3, b3; + for (int32_t i = 0; i < FX_SHADING_Steps; i++) { + a3 = (int32_t)(i * aScale); + r3 = (int32_t)(i * rScale); + g3 = (int32_t)(i * gScale); + b3 = (int32_t)(i * bScale); + _argbArray[i] = + FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); + } + return FX_ERR_Succeeded; +} +class CFX_Pause : public IFX_Pause { + public: + virtual FX_BOOL NeedToPauseNow() { return TRUE; } +}; diff --git a/xfa/fxgraphics/fx_path_generator.cpp b/xfa/fxgraphics/fx_path_generator.cpp new file mode 100644 index 0000000000..cbe0f29239 --- /dev/null +++ b/xfa/fxgraphics/fx_path_generator.cpp @@ -0,0 +1,201 @@ +// 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/fxgraphics/fx_path_generator.h" + +#include "xfa/fxgraphics/pre.h" + +CFX_PathGenerator::CFX_PathGenerator() { + m_pPathData = NULL; +} +void CFX_PathGenerator::Create() { + m_pPathData = new CFX_PathData; +} +CFX_PathGenerator::~CFX_PathGenerator() { + if (m_pPathData) { + delete m_pPathData; + m_pPathData = NULL; + } +} +void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { + if (pPathData && pPathData->GetPointCount() > 0) { + int nCount = pPathData->GetPointCount(); + FX_PATHPOINT* pPoints = pPathData->GetPoints(); + AddPathData(pPoints, nCount); + } +} +void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { + if (pPoints && nCount > 0) { + int nOldCount = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(nCount); + FX_PATHPOINT* pDstPoints = m_pPathData->GetPoints(); + FXSYS_memcpy(pDstPoints + nOldCount, pPoints, + sizeof(FX_PATHPOINT) * nCount); + } +} +void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); +} +void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); +} +void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT to_x, + FX_FLOAT to_y) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(3); + m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::Close() { + if (m_pPathData->GetPointCount() > 0) { + int index = m_pPathData->GetPointCount() - 1; + FX_PATHPOINT* pPoints = m_pPathData->GetPoints(); + pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; + } +} +void CFX_PathGenerator::AddLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(2); + m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); +} +void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, + FX_FLOAT start_y, + FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT end_x, + FX_FLOAT end_y) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(4); + m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2) { + m_pPathData->AppendRect(x1, y1, x2, y2); +} +void CFX_PathGenerator::AddEllipse(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height) { + AddArc(x, y, width, height, 0, FX_PI * 2); +} +void CFX_PathGenerator::ArcTo(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2); + FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2); + FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f); + FX_FLOAT ty = y0 - ((tx * x0) / y0); + FX_FLOAT px[3], py[3]; + px[0] = x0 + tx; + py[0] = -ty; + px[1] = x0 + tx; + py[1] = ty; + FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); + FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(3); + FX_FLOAT bezier_x, bezier_y; + bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); + bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); + m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); + bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); + bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); + m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); + bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); + bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); + m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::AddArc(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + if (sweep_angle == 0) { + return; + } + + const FX_FLOAT bezier_arc_angle_epsilon = 0.01f; + while (start_angle > FX_PI * 2) { + start_angle -= FX_PI * 2; + } + while (start_angle < 0) { + start_angle += FX_PI * 2; + } + if (sweep_angle >= FX_PI * 2) { + sweep_angle = FX_PI * 2; + } + if (sweep_angle <= -FX_PI * 2) { + sweep_angle = -FX_PI * 2; + } + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, + x + (width * FXSYS_cos(start_angle)), + y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO); + FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; + FX_BOOL done = FALSE; + do { + if (sweep_angle < 0) { + prev_sweep = total_sweep; + local_sweep = -FX_PI / 2; + total_sweep -= FX_PI / 2; + if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = TRUE; + } + } else { + prev_sweep = total_sweep; + local_sweep = FX_PI / 2; + total_sweep += FX_PI / 2; + if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = TRUE; + } + } + ArcTo(x, y, width, height, start_angle, local_sweep); + start_angle += local_sweep; + } while (!done); +} +void CFX_PathGenerator::AddPie(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + if (sweep_angle == 0) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(2); + m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)), + y + (height * FXSYS_sin(start_angle)), FXPT_LINETO); + return; + } + AddArc(x, y, width, height, start_angle, sweep_angle); + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, + FXPT_LINETO | FXPT_CLOSEFIGURE); +} diff --git a/xfa/fxgraphics/fx_path_generator.h b/xfa/fxgraphics/fx_path_generator.h new file mode 100644 index 0000000000..3087a64366 --- /dev/null +++ b/xfa/fxgraphics/fx_path_generator.h @@ -0,0 +1,64 @@ +// 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_FXGRAPHICS_FX_PATH_GENERATOR_H_ +#define XFA_FXGRAPHICS_FX_PATH_GENERATOR_H_ + +#include "core/include/fxge/fx_ge.h" + +class CFX_PathGenerator { + public: + CFX_PathGenerator(); + void Create(); + ~CFX_PathGenerator(); + CFX_PathData* GetPathData() const { return m_pPathData; } + void AddPathData(CFX_PathData* path_data); + void AddPathData(FX_PATHPOINT* points, int count); + void MoveTo(FX_FLOAT x, FX_FLOAT y); + void LineTo(FX_FLOAT x, FX_FLOAT y); + void BezierTo(FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT to_x, + FX_FLOAT to_y); + void Close(); + void ArcTo(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + + void AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + void AddBezier(FX_FLOAT start_x, + FX_FLOAT start_y, + FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT end_x, + FX_FLOAT end_y); + void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + void AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height); + void AddArc(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + void AddPie(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + + protected: + CFX_PathData* m_pPathData; +}; + +#endif // XFA_FXGRAPHICS_FX_PATH_GENERATOR_H_ diff --git a/xfa/fxgraphics/pre.h b/xfa/fxgraphics/pre.h new file mode 100644 index 0000000000..fb0ac55839 --- /dev/null +++ b/xfa/fxgraphics/pre.h @@ -0,0 +1,586 @@ +// 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_FXGRAPHICS_PRE_H_ +#define XFA_FXGRAPHICS_PRE_H_ + +enum { + FX_CONTEXT_None = 0, + FX_CONTEXT_Device, +}; +enum { FX_COLOR_None = 0, FX_COLOR_Solid, FX_COLOR_Pattern, FX_COLOR_Shading }; +enum { FX_PATTERN_None = 0, FX_PATTERN_Bitmap, FX_PATTERN_Hatch }; +enum { FX_SHADING_None = 0, FX_SHADING_Axial, FX_SHADING_Radial }; + +#define FX_HATCHSTYLE_Total 53 + +struct FX_HATCHDATA { + int32_t width; + int32_t height; + uint8_t maskBits[64]; +}; +typedef FX_HATCHDATA const* FX_LPCHATCHDATA; + +static const FX_HATCHDATA hatchBitmapData[FX_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, + }}, +}; +#if defined(__WIN32__) || defined(_WIN32) +#define FX_START_TIMER \ + SYSTEMTIME start, stop; \ + ::GetLocalTime(&start); +#define FX_STOP_TIMER \ + ::GetLocalTime(&stop); \ + WORD wSecond = stop.wSecond - start.wSecond; \ + WORD wMilliseconds = stop.wMilliseconds - start.wMilliseconds; \ + char buf[256]; \ + memset(buf, 0, sizeof(buf)); \ + snprintf(buf, sizeof(buf) - 1, "duration is %d millisecond\n", \ + wSecond * 1000 + wMilliseconds); \ + ::OutputDebugString(buf); +#elif defined(__linux) || defined(linux) +#define FX_START_TIMER +#define FX_STOP_TIMER +#elif defined(__APPLE__) || defined(__MACOSX__) +#define FX_START_TIMER \ + NSTimeInterval start, stop; \ + start = [NSDate timeIntervalSinceReferenceDate]; +#define FX_STOP_TIMER \ + stop = [NSDate timeIntervalSinceReferenceDate]; \ + NSTimeInterval duration = stop - start; \ + printf("duration is %f millisecond\n", duration * 1000); +#else +#endif + +#endif // XFA_FXGRAPHICS_PRE_H_ diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp new file mode 100644 index 0000000000..e87fbbfaf9 --- /dev/null +++ b/xfa/fxjse/class.cpp @@ -0,0 +1,348 @@ +// 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/fxjse/class.h" + +#include "xfa/fxjse/context.h" +#include "xfa/fxjse/scope_inline.h" +#include "xfa/fxjse/util_inline.h" +#include "xfa/fxjse/value.h" + +static void FXJSE_V8ConstructorCallback_Wrapper( + const v8::FunctionCallbackInfo<v8::Value>& info); +static void FXJSE_V8FunctionCallback_Wrapper( + const v8::FunctionCallbackInfo<v8::Value>& info); +static void FXJSE_V8GetterCallback_Wrapper( + v8::Local<v8::String> property, + const v8::PropertyCallbackInfo<v8::Value>& info); +static void FXJSE_V8SetterCallback_Wrapper( + v8::Local<v8::String> property, + 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); + ASSERT(lpContext); + return reinterpret_cast<FXJSE_HCLASS>( + 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 = + static_cast<FXJSE_FUNCTION*>(info.Data().As<v8::External>()->Value()); + if (!lpFunctionInfo) { + return; + } + CFX_ByteStringC szFunctionName(lpFunctionInfo->name); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(info.This()); + CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); + CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; + lpFunctionInfo->callbackProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szFunctionName, + reinterpret_cast<CFXJSE_Arguments&>(impl)); + if (!lpRetValue->DirectGetValue().IsEmpty()) { + info.GetReturnValue().Set(lpRetValue->DirectGetValue()); + } + delete lpRetValue; + lpRetValue = NULL; + delete lpThisValue; + lpThisValue = NULL; +} + +static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper( + const v8::FunctionCallbackInfo<v8::Value>& info) { + const FXJSE_CLASS* lpClassDefinition = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + if (!lpClassDefinition) { + return; + } + CFX_ByteStringC szFunctionName(lpClassDefinition->name); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(info.This()); + CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); + CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; + lpClassDefinition->constructor(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szFunctionName, + reinterpret_cast<CFXJSE_Arguments&>(impl)); + if (!lpRetValue->DirectGetValue().IsEmpty()) { + info.GetReturnValue().Set(lpRetValue->DirectGetValue()); + } + delete lpRetValue; + lpRetValue = NULL; + delete lpThisValue; + lpThisValue = NULL; +} + +static void FXJSE_V8GetterCallback_Wrapper( + v8::Local<v8::String> property, + const v8::PropertyCallbackInfo<v8::Value>& info) { + const FXJSE_PROPERTY* lpPropertyInfo = + static_cast<FXJSE_PROPERTY*>(info.Data().As<v8::External>()->Value()); + if (!lpPropertyInfo) { + return; + } + CFX_ByteStringC szPropertyName(lpPropertyInfo->name); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(info.This()); + lpPropertyInfo->getProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szPropertyName, + reinterpret_cast<FXJSE_HVALUE>(lpPropValue)); + info.GetReturnValue().Set(lpPropValue->DirectGetValue()); + delete lpThisValue; + lpThisValue = NULL; + delete lpPropValue; + lpPropValue = NULL; +} + +static void FXJSE_V8SetterCallback_Wrapper( + v8::Local<v8::String> property, + v8::Local<v8::Value> value, + const v8::PropertyCallbackInfo<void>& info) { + const FXJSE_PROPERTY* lpPropertyInfo = + static_cast<FXJSE_PROPERTY*>(info.Data().As<v8::External>()->Value()); + if (!lpPropertyInfo) { + return; + } + CFX_ByteStringC szPropertyName(lpPropertyInfo->name); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(info.This()); + lpPropValue->ForceSetValue(value); + lpPropertyInfo->setProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szPropertyName, + reinterpret_cast<FXJSE_HVALUE>(lpPropValue)); + delete lpThisValue; + lpThisValue = NULL; + delete lpPropValue; + lpPropValue = NULL; +} + +static void FXJSE_V8ConstructorCallback_Wrapper( + const v8::FunctionCallbackInfo<v8::Value>& info) { + const FXJSE_CLASS* lpClassDefinition = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + if (!lpClassDefinition) { + return; + } + FXSYS_assert(info.This()->InternalFieldCount()); + info.This()->SetAlignedPointerInInternalField(0, NULL); +} + +FXJSE_HRUNTIME CFXJSE_Arguments::GetRuntime() const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return reinterpret_cast<FXJSE_HRUNTIME>( + lpArguments->m_pRetValue->GetIsolate()); +} + +int32_t CFXJSE_Arguments::GetLength() const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return lpArguments->m_pInfo->Length(); +} + +FXJSE_HVALUE CFXJSE_Arguments::GetValue(int32_t index) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + CFXJSE_Value* lpArgValue = CFXJSE_Value::Create(v8::Isolate::GetCurrent()); + ASSERT(lpArgValue); + lpArgValue->ForceSetValue((*lpArguments->m_pInfo)[index]); + return reinterpret_cast<FXJSE_HVALUE>(lpArgValue); +} + +FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return (*lpArguments->m_pInfo)[index]->BooleanValue(); +} + +int32_t CFXJSE_Arguments::GetInt32(int32_t index) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return static_cast<int32_t>((*lpArguments->m_pInfo)[index]->NumberValue()); +} + +FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return static_cast<FX_FLOAT>((*lpArguments->m_pInfo)[index]->NumberValue()); +} + +CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + v8::Local<v8::String> hString = (*lpArguments->m_pInfo)[index]->ToString(); + v8::String::Utf8Value szStringVal(hString); + return CFX_ByteString(*szStringVal); +} + +void* CFXJSE_Arguments::GetObject(int32_t index, FXJSE_HCLASS hClass) const { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + v8::Local<v8::Value> hValue = (*lpArguments->m_pInfo)[index]; + ASSERT(!hValue.IsEmpty()); + if (!hValue->IsObject()) { + return NULL; + } + CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); + return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); +} + +FXJSE_HVALUE CFXJSE_Arguments::GetReturnValue() { + const CFXJSE_ArgumentsImpl* lpArguments = + reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); + return reinterpret_cast<FXJSE_HVALUE>(lpArguments->m_pRetValue); +} +static void FXJSE_Context_GlobalObjToString( + const v8::FunctionCallbackInfo<v8::Value>& info) { + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + if (!lpClass) { + return; + } + if (info.This() == info.Holder() && lpClass->name) { + 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())); + } else { + v8::Local<v8::String> local_str = + info.This() + ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()) + .FromMaybe(v8::Local<v8::String>()); + info.GetReturnValue().Set(local_str); + } +} + +CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, + const FXJSE_CLASS* lpClassDefinition, + FX_BOOL bIsJSGlobal) { + if (!lpContext || !lpClassDefinition) { + return NULL; + } + CFXJSE_Class* pClass = + GetClassFromContext(lpContext, lpClassDefinition->name); + if (pClass) { + return pClass; + } + v8::Isolate* pIsolate = lpContext->m_pIsolate; + pClass = new CFXJSE_Class(lpContext); + pClass->m_szClassName = lpClassDefinition->name; + pClass->m_lpClassDefinition = lpClassDefinition; + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New( + pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper, + v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition))); + hFunctionTemplate->SetClassName( + v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name)); + hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1); + v8::Local<v8::ObjectTemplate> hObjectTemplate = + hFunctionTemplate->InstanceTemplate(); + SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition); + + if (lpClassDefinition->propNum) { + for (int32_t i = 0; i < lpClassDefinition->propNum; i++) { + hObjectTemplate->SetNativeDataProperty( + v8::String::NewFromUtf8(pIsolate, + lpClassDefinition->properties[i].name), + lpClassDefinition->properties[i].getProc + ? FXJSE_V8GetterCallback_Wrapper + : NULL, + lpClassDefinition->properties[i].setProc + ? FXJSE_V8SetterCallback_Wrapper + : NULL, + v8::External::New(pIsolate, const_cast<FXJSE_PROPERTY*>( + lpClassDefinition->properties + i)), + static_cast<v8::PropertyAttribute>(v8::DontDelete)); + } + } + if (lpClassDefinition->methNum) { + for (int32_t i = 0; i < lpClassDefinition->methNum; i++) { + hObjectTemplate->Set( + v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name), + v8::FunctionTemplate::New( + pIsolate, FXJSE_V8FunctionCallback_Wrapper, + v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION*>( + lpClassDefinition->methods + i))), + static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); + } + } + if (lpClassDefinition->constructor) { + if (bIsJSGlobal) { + hObjectTemplate->Set( + v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), + v8::FunctionTemplate::New( + pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, + v8::External::New(pIsolate, + const_cast<FXJSE_CLASS*>(lpClassDefinition))), + static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); + } else { + v8::Local<v8::Context> hLocalContext = + v8::Local<v8::Context>::New(pIsolate, lpContext->m_hContext); + FXJSE_GetGlobalObjectFromContext(hLocalContext) + ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), + v8::Function::New( + pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, + v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>( + lpClassDefinition)))); + } + } + if (bIsJSGlobal) { + hObjectTemplate->Set( + v8::String::NewFromUtf8(pIsolate, "toString"), + v8::FunctionTemplate::New( + pIsolate, FXJSE_Context_GlobalObjToString, + v8::External::New(pIsolate, + const_cast<FXJSE_CLASS*>(lpClassDefinition)))); + } + pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate); + lpContext->m_rgClasses.Add(pClass); + return pClass; +} +CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, + const CFX_ByteStringC& szName) { + for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { + CFXJSE_Class* pClass = pContext->m_rgClasses[i]; + if (pClass->m_szClassName == szName) { + return pClass; + } + } + return NULL; +} diff --git a/xfa/fxjse/class.h b/xfa/fxjse/class.h new file mode 100644 index 0000000000..e67a77a5c3 --- /dev/null +++ b/xfa/fxjse/class.h @@ -0,0 +1,49 @@ +// 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_FXJSE_CLASS_H_ +#define XFA_FXJSE_CLASS_H_ + +#include "v8/include/v8.h" +#include "xfa/include/fxjse/fxjse.h" + +class CFXJSE_Context; +class CFXJSE_Value; + +class CFXJSE_Class { + protected: + CFXJSE_Class(CFXJSE_Context* lpContext) + : m_lpClassDefinition(nullptr), m_pContext(lpContext) {} + + public: + inline CFXJSE_Context* GetContext() { return m_pContext; } + inline v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; } + + public: + static CFXJSE_Class* Create(CFXJSE_Context* pContext, + const FXJSE_CLASS* lpClassDefintion, + FX_BOOL bIsJSGlobal = FALSE); + static CFXJSE_Class* GetClassFromContext(CFXJSE_Context* pContext, + const CFX_ByteStringC& szName); + static void SetUpNamedPropHandler( + v8::Isolate* pIsolate, + v8::Local<v8::ObjectTemplate>& hObjectTemplate, + const FXJSE_CLASS* lpClassDefinition); + + protected: + CFX_ByteString m_szClassName; + const FXJSE_CLASS* m_lpClassDefinition; + CFXJSE_Context* m_pContext; + v8::Global<v8::FunctionTemplate> m_hTemplate; + friend class CFXJSE_Context; + friend class CFXJSE_Value; +}; +struct CFXJSE_ArgumentsImpl { + const v8::FunctionCallbackInfo<v8::Value>* m_pInfo; + CFXJSE_Value* m_pRetValue; +}; + +#endif // XFA_FXJSE_CLASS_H_ diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp new file mode 100644 index 0000000000..1b46a792f2 --- /dev/null +++ b/xfa/fxjse/context.cpp @@ -0,0 +1,275 @@ +// 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/fxjse/context.h" + +#include "xfa/fxjse/class.h" +#include "xfa/fxjse/scope_inline.h" +#include "xfa/fxjse/util_inline.h" +#include "xfa/fxjse/value.h" + +FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime, + const FXJSE_CLASS* lpGlobalClass, + void* lpGlobalObject) { + CFXJSE_Context* pContext = CFXJSE_Context::Create( + reinterpret_cast<v8::Isolate*>(hRuntime), lpGlobalClass, lpGlobalObject); + return reinterpret_cast<FXJSE_HCONTEXT>(pContext); +} + +void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) { + CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext); + if (pContext) { + delete pContext; + } +} + +FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) { + CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext); + if (!pContext) { + return NULL; + } + 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" + " var objname;\n" + " for (objname in list) {\n" + " var globalobj = global[objname];\n" + " if (globalobj) {\n" + " list[objname].forEach(function(name) {\n" + " if (!globalobj[name]) {\n" + " Object.defineProperty(globalobj, name, {\n" + " writable: true,\n" + " enumerable: false,\n" + " value: (function(obj) {\n" + " if (arguments.length === 0) {\n" + " throw new TypeError('missing argument 0 when calling " + " function ' + objname + '.' + name);\n" + " }\n" + " return globalobj.prototype[name].apply(obj, " + " Array.prototype.slice.call(arguments, 1));\n" + " })\n" + " });\n" + " }\n" + " });\n" + " }\n" + " }\n" + "}(this, {String: ['substr', 'toUpperCase']}));"}; +void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext, + FX_DWORD dwCompatibleFlags) { + for (uint32_t i = 0; i < (uint32_t)FXJSE_COMPATIBLEMODEFLAGCOUNT; i++) { + if (dwCompatibleFlags & (1 << i)) { + FXJSE_ExecuteScript(hContext, szCompatibleModeScripts[i], NULL, NULL); + } + } +} + +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); + return pContext->ExecuteScript( + szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue), + reinterpret_cast<CFXJSE_Value*>(hNewThisObject)); +} + +v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, + v8::TryCatch& trycatch) { + v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate); + if (trycatch.HasCaught()) { + v8::Local<v8::Value> hException = trycatch.Exception(); + v8::Local<v8::Message> hMessage = trycatch.Message(); + if (hException->IsObject()) { + v8::Local<v8::Value> hValue; + hValue = hException.As<v8::Object>()->Get( + v8::String::NewFromUtf8(pIsolate, "name")); + if (hValue->IsString() || hValue->IsStringObject()) { + hReturnValue->Set(0, hValue); + } else { + hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); + } + hValue = hException.As<v8::Object>()->Get( + v8::String::NewFromUtf8(pIsolate, "message")); + if (hValue->IsString() || hValue->IsStringObject()) { + hReturnValue->Set(1, hValue); + } else { + hReturnValue->Set(1, hMessage->Get()); + } + } else { + hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); + hReturnValue->Set(1, hMessage->Get()); + } + hReturnValue->Set(2, hException); + hReturnValue->Set(3, v8::Integer::New(pIsolate, hMessage->GetLineNumber())); + hReturnValue->Set(4, hMessage->GetSourceLine()); + v8::Maybe<int32_t> maybe_int = + hMessage->GetStartColumn(pIsolate->GetCurrentContext()); + hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); + maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); + hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); + } + 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) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); + CFXJSE_Class* lpGlobalClassObj = NULL; + v8::Local<v8::ObjectTemplate> hObjectTemplate; + if (lpGlobalClass) { + lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); + ASSERT(lpGlobalClassObj); + v8::Local<v8::FunctionTemplate> hFunctionTemplate = + v8::Local<v8::FunctionTemplate>::New(pIsolate, + lpGlobalClassObj->m_hTemplate); + hObjectTemplate = hFunctionTemplate->InstanceTemplate(); + } else { + hObjectTemplate = v8::ObjectTemplate::New(pIsolate); + hObjectTemplate->SetInternalFieldCount(1); + } + v8::Local<v8::Context> hNewContext = + v8::Context::New(pIsolate, NULL, hObjectTemplate); + v8::Local<v8::Context> hRootContext = v8::Local<v8::Context>::New( + pIsolate, CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext); + hNewContext->SetSecurityToken(hRootContext->GetSecurityToken()); + v8::Local<v8::Object> hGlobalObject = + FXJSE_GetGlobalObjectFromContext(hNewContext); + FXJSE_UpdateObjectBinding(hGlobalObject, lpGlobalObject); + pContext->m_hContext.Reset(pIsolate, hNewContext); + return pContext; +} + +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; + } + } + m_rgClasses.RemoveAll(); +} + +void CFXJSE_Context::GetGlobalObject(CFXJSE_Value* pValue) { + ASSERT(pValue); + CFXJSE_ScopeUtil_IsolateHandleContext scope(this); + v8::Local<v8::Context> hContext = + v8::Local<v8::Context>::New(m_pIsolate, m_hContext); + v8::Local<v8::Object> hGlobalObject = hContext->Global(); + pValue->ForceSetValue(hGlobalObject); +} + +FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript, + CFXJSE_Value* lpRetValue, + CFXJSE_Value* lpNewThisObject) { + CFXJSE_ScopeUtil_IsolateHandleContext scope(this); + v8::TryCatch trycatch(m_pIsolate); + v8::Local<v8::String> hScriptString = + v8::String::NewFromUtf8(m_pIsolate, szScript); + if (lpNewThisObject == NULL) { + v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString); + if (!trycatch.HasCaught()) { + v8::Local<v8::Value> hValue = hScript->Run(); + if (!trycatch.HasCaught()) { + if (lpRetValue) { + lpRetValue->m_hValue.Reset(m_pIsolate, hValue); + } + return TRUE; + } + } + if (lpRetValue) { + lpRetValue->m_hValue.Reset(m_pIsolate, + FXJSE_CreateReturnValue(m_pIsolate, trycatch)); + } + return FALSE; + } else { + v8::Local<v8::Value> hNewThis = + v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue); + ASSERT(!hNewThis.IsEmpty()); + v8::Local<v8::Script> hWrapper = + v8::Script::Compile(v8::String::NewFromUtf8( + m_pIsolate, "(function () { return eval(arguments[0]); })")); + v8::Local<v8::Value> hWrapperValue = hWrapper->Run(); + ASSERT(hWrapperValue->IsFunction()); + v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>(); + if (!trycatch.HasCaught()) { + v8::Local<v8::Value> rgArgs[] = {hScriptString}; + v8::Local<v8::Value> hValue = + hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs); + if (!trycatch.HasCaught()) { + if (lpRetValue) { + lpRetValue->m_hValue.Reset(m_pIsolate, hValue); + } + return TRUE; + } + } + if (lpRetValue) { + lpRetValue->m_hValue.Reset(m_pIsolate, + FXJSE_CreateReturnValue(m_pIsolate, trycatch)); + } + return FALSE; + } +} diff --git a/xfa/fxjse/context.h b/xfa/fxjse/context.h new file mode 100644 index 0000000000..01a1f4b655 --- /dev/null +++ b/xfa/fxjse/context.h @@ -0,0 +1,48 @@ +// 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_FXJSE_CONTEXT_H_ +#define XFA_FXJSE_CONTEXT_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "v8/include/v8.h" +#include "xfa/include/fxjse/fxjse.h" + +class CFXJSE_Class; +class CFXJSE_Value; + +class CFXJSE_Context { + protected: + CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} + + public: + static CFXJSE_Context* Create(v8::Isolate* pIsolate, + const FXJSE_CLASS* lpGlobalClass = NULL, + void* lpGlobalObject = NULL); + ~CFXJSE_Context(); + V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } + void GetGlobalObject(CFXJSE_Value* pValue); + FX_BOOL ExecuteScript(const FX_CHAR* szScript, + CFXJSE_Value* lpRetValue, + CFXJSE_Value* lpNewThisObject = NULL); + + protected: + CFXJSE_Context(); + CFXJSE_Context(const CFXJSE_Context&); + CFXJSE_Context& operator=(const CFXJSE_Context&); + + protected: + v8::Global<v8::Context> m_hContext; + v8::Isolate* m_pIsolate; + CFX_ArrayTemplate<CFXJSE_Class*> m_rgClasses; + friend class CFXJSE_Class; + friend class CFXJSE_ScopeUtil_IsolateHandleContext; + friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext; +}; +v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, + v8::TryCatch& trycatch); + +#endif // XFA_FXJSE_CONTEXT_H_ diff --git a/xfa/fxjse/dynprop.cpp b/xfa/fxjse/dynprop.cpp new file mode 100644 index 0000000000..88cb0197bd --- /dev/null +++ b/xfa/fxjse/dynprop.cpp @@ -0,0 +1,236 @@ +// 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/fxjse/class.h" +#include "xfa/fxjse/value.h" + +static void FXJSE_DynPropGetterAdapter_MethodCallback( + const v8::FunctionCallbackInfo<v8::Value>& info) { + v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>(); + FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>( + hCallBackInfo->GetAlignedPointerFromInternalField(0)); + v8::Local<v8::String> hPropName = + hCallBackInfo->GetInternalField(1).As<v8::String>(); + ASSERT(lpClass && !hPropName.IsEmpty()); + v8::String::Utf8Value szPropName(hPropName); + CFX_ByteStringC szFxPropName = *szPropName; + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(info.This()); + CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); + CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; + lpClass->dynMethodCall(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szFxPropName, + reinterpret_cast<CFXJSE_Arguments&>(impl)); + if (!lpRetValue->DirectGetValue().IsEmpty()) { + info.GetReturnValue().Set(lpRetValue->DirectGetValue()); + } + delete lpRetValue; + lpRetValue = nullptr; + delete lpThisValue; + lpThisValue = nullptr; +} + +static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass, + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + ASSERT(lpClass); + int32_t nPropType = + lpClass->dynPropTypeGetter == nullptr + ? FXJSE_ClassPropType_Property + : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); + if (nPropType == FXJSE_ClassPropType_Property) { + if (lpClass->dynPropGetter) { + lpClass->dynPropGetter(hObject, szPropName, hValue); + } + } else if (nPropType == FXJSE_ClassPropType_Method) { + if (lpClass->dynMethodCall && hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + v8::Isolate* pIsolate = lpValue->GetIsolate(); + v8::HandleScope hscope(pIsolate); + v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate = + v8::ObjectTemplate::New(pIsolate); + hCallBackInfoTemplate->SetInternalFieldCount(2); + v8::Local<v8::Object> hCallBackInfo = + hCallBackInfoTemplate->NewInstance(); + hCallBackInfo->SetAlignedPointerInInternalField( + 0, const_cast<FXJSE_CLASS*>(lpClass)); + hCallBackInfo->SetInternalField( + 1, v8::String::NewFromUtf8( + pIsolate, reinterpret_cast<const char*>(szPropName.GetPtr()), + v8::String::kNormalString, szPropName.GetLength())); + lpValue->ForceSetValue(v8::Function::New( + lpValue->GetIsolate(), FXJSE_DynPropGetterAdapter_MethodCallback, + hCallBackInfo)); + } + } +} + +static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS* lpClass, + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue) { + ASSERT(lpClass); + int32_t nPropType = + lpClass->dynPropTypeGetter == nullptr + ? FXJSE_ClassPropType_Property + : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); + if (nPropType != FXJSE_ClassPropType_Method) { + if (lpClass->dynPropSetter) { + lpClass->dynPropSetter(hObject, szPropName, hValue); + } + } +} + +static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS* lpClass, + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName) { + ASSERT(lpClass); + int32_t nPropType = + lpClass->dynPropTypeGetter == nullptr + ? FXJSE_ClassPropType_Property + : lpClass->dynPropTypeGetter(hObject, szPropName, TRUE); + return nPropType != FXJSE_ClassPropType_None; +} + +static FX_BOOL FXJSE_DynPropDeleterAdapter(const FXJSE_CLASS* lpClass, + FXJSE_HOBJECT hObject, + const CFX_ByteStringC& szPropName) { + ASSERT(lpClass); + int32_t nPropType = + lpClass->dynPropTypeGetter == nullptr + ? FXJSE_ClassPropType_Property + : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); + if (nPropType != FXJSE_ClassPropType_Method) { + if (lpClass->dynPropDeleter) { + return lpClass->dynPropDeleter(hObject, szPropName); + } else { + return nPropType == FXJSE_ClassPropType_Property ? FALSE : TRUE; + } + } + return FALSE; +} + +static void FXJSE_V8_GenericNamedPropertyQueryCallback( + v8::Local<v8::Name> property, + const v8::PropertyCallbackInfo<v8::Integer>& info) { + v8::Local<v8::Object> thisObject = info.This(); + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + v8::Isolate* pIsolate = info.GetIsolate(); + v8::HandleScope scope(pIsolate); + v8::String::Utf8Value szPropName(property); + CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(thisObject); + if (FXJSE_DynPropQueryAdapter(lpClass, + reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), + szFxPropName)) { + info.GetReturnValue().Set(v8::DontDelete); + } else { + const int32_t iV8Absent = 64; + info.GetReturnValue().Set(iV8Absent); + } + delete lpThisValue; + lpThisValue = nullptr; +} + +static void FXJSE_V8_GenericNamedPropertyDeleterCallback( + v8::Local<v8::Name> property, + const v8::PropertyCallbackInfo<v8::Boolean>& info) { + v8::Local<v8::Object> thisObject = info.This(); + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + v8::Isolate* pIsolate = info.GetIsolate(); + v8::HandleScope scope(pIsolate); + v8::String::Utf8Value szPropName(property); + CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(thisObject); + info.GetReturnValue().Set( + FXJSE_DynPropDeleterAdapter( + lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName) + ? true + : false); + delete lpThisValue; + lpThisValue = nullptr; +} + +static void FXJSE_V8_GenericNamedPropertyGetterCallback( + v8::Local<v8::Name> property, + const v8::PropertyCallbackInfo<v8::Value>& info) { + v8::Local<v8::Object> thisObject = info.This(); + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + v8::String::Utf8Value szPropName(property); + CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(thisObject); + CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); + FXJSE_DynPropGetterAdapter( + lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, + reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); + info.GetReturnValue().Set(lpNewValue->DirectGetValue()); + delete lpThisValue; + lpThisValue = nullptr; +} + +static void FXJSE_V8_GenericNamedPropertySetterCallback( + v8::Local<v8::Name> property, + v8::Local<v8::Value> value, + const v8::PropertyCallbackInfo<v8::Value>& info) { + v8::Local<v8::Object> thisObject = info.This(); + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + v8::String::Utf8Value szPropName(property); + CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); + CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); + lpThisValue->ForceSetValue(thisObject); + CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); + lpNewValue->ForceSetValue(value); + FXJSE_DynPropSetterAdapter( + lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, + reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); + info.GetReturnValue().Set(value); + delete lpThisValue; + lpThisValue = nullptr; +} + +static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback( + const v8::PropertyCallbackInfo<v8::Array>& info) { + const FXJSE_CLASS* lpClass = + static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); + v8::Isolate* pIsolate = info.GetIsolate(); + v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum); + for (int i = 0; i < lpClass->propNum; i++) { + newArray->Set( + i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name)); + } + info.GetReturnValue().Set(newArray); +} + +void CFXJSE_Class::SetUpNamedPropHandler( + v8::Isolate* pIsolate, + v8::Local<v8::ObjectTemplate>& hObjectTemplate, + const FXJSE_CLASS* lpClassDefinition) { + v8::NamedPropertyHandlerConfiguration configuration( + lpClassDefinition->dynPropGetter + ? FXJSE_V8_GenericNamedPropertyGetterCallback + : 0, + lpClassDefinition->dynPropSetter + ? FXJSE_V8_GenericNamedPropertySetterCallback + : 0, + lpClassDefinition->dynPropTypeGetter + ? FXJSE_V8_GenericNamedPropertyQueryCallback + : 0, + lpClassDefinition->dynPropDeleter + ? FXJSE_V8_GenericNamedPropertyDeleterCallback + : 0, + FXJSE_V8_GenericNamedPropertyEnumeratorCallback, + v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition)), + v8::PropertyHandlerFlags::kNonMasking); + hObjectTemplate->SetHandler(configuration); +} diff --git a/xfa/fxjse/runtime.cpp b/xfa/fxjse/runtime.cpp new file mode 100644 index 0000000000..a1472c7d8f --- /dev/null +++ b/xfa/fxjse/runtime.cpp @@ -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 + +#include "xfa/fxjse/runtime.h" + +#include "fpdfsdk/include/jsapi/fxjs_v8.h" +#include "xfa/fxjse/scope_inline.h" + +// Duplicates fpdfsdk's JS_Runtime.h, but keeps XFA from depending on it. +// TODO(tsepez): make a single version of this. +class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { + void* Allocate(size_t length) override { return calloc(1, length); } + void* AllocateUninitialized(size_t length) override { return malloc(length); } + void Free(void* data, size_t length) override { free(data); } +}; + +static void FXJSE_KillV8() { + v8::V8::Dispose(); +} + +void FXJSE_Initialize() { + if (!CFXJSE_RuntimeData::g_RuntimeList) { + CFXJSE_RuntimeData::g_RuntimeList = new CFXJSE_RuntimeList; + } + static FX_BOOL bV8Initialized = FALSE; + if (bV8Initialized) { + return; + } + bV8Initialized = TRUE; + atexit(FXJSE_KillV8); +} + +static void FXJSE_Runtime_DisposeCallback(v8::Isolate* pIsolate) { + { + v8::Locker locker(pIsolate); + if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) { + delete pData->m_pFXJSERuntimeData; + pData->m_pFXJSERuntimeData = nullptr; + } + } + pIsolate->Dispose(); +} + +void FXJSE_Finalize() { + if (CFXJSE_RuntimeData::g_RuntimeList) { + CFXJSE_RuntimeData::g_RuntimeList->RemoveAllRuntimes( + FXJSE_Runtime_DisposeCallback); + delete CFXJSE_RuntimeData::g_RuntimeList; + CFXJSE_RuntimeData::g_RuntimeList = NULL; + } +} + +FXJSE_HRUNTIME FXJSE_Runtime_Create() { + v8::Isolate::CreateParams params; + params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator(); + v8::Isolate* pIsolate = v8::Isolate::New(params); + ASSERT(pIsolate && CFXJSE_RuntimeData::g_RuntimeList); + CFXJSE_RuntimeData::g_RuntimeList->AppendRuntime(pIsolate); + return reinterpret_cast<FXJSE_HRUNTIME>(pIsolate); +} + +void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime, bool bOwnedRuntime) { + v8::Isolate* pIsolate = reinterpret_cast<v8::Isolate*>(hRuntime); + if (!pIsolate) + return; + if (bOwnedRuntime) { + ASSERT(CFXJSE_RuntimeData::g_RuntimeList); + CFXJSE_RuntimeData::g_RuntimeList->RemoveRuntime( + pIsolate, FXJSE_Runtime_DisposeCallback); + } else { + if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) { + delete pData->m_pFXJSERuntimeData; + pData->m_pFXJSERuntimeData = nullptr; + } + } +} + +CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) { + CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::FunctionTemplate> hFuncTemplate = + v8::FunctionTemplate::New(pIsolate); + v8::Local<v8::Context> hContext = + v8::Context::New(pIsolate, 0, hFuncTemplate->InstanceTemplate()); + hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate)); + pRuntimeData->m_hRootContextGlobalTemplate.Reset(pIsolate, hFuncTemplate); + pRuntimeData->m_hRootContext.Reset(pIsolate, hContext); + return pRuntimeData; +} + +CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { + FXJS_PerIsolateData::SetUp(pIsolate); + FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); + if (!pData->m_pFXJSERuntimeData) + pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate); + return pData->m_pFXJSERuntimeData; +} + +CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = NULL; +void CFXJSE_RuntimeList::AppendRuntime(v8::Isolate* pIsolate) { + m_RuntimeList.Add(pIsolate); +} + +void CFXJSE_RuntimeList::RemoveRuntime( + v8::Isolate* pIsolate, + CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { + int32_t iIdx = m_RuntimeList.Find(pIsolate, 0); + if (iIdx >= 0) { + m_RuntimeList.RemoveAt(iIdx, 1); + } + if (lpfnDisposeCallback) { + lpfnDisposeCallback(pIsolate); + } +} + +void CFXJSE_RuntimeList::RemoveAllRuntimes( + CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { + int32_t iSize = m_RuntimeList.GetSize(); + if (lpfnDisposeCallback) { + for (int32_t iIdx = 0; iIdx < iSize; iIdx++) { + lpfnDisposeCallback(m_RuntimeList[iIdx]); + } + } + m_RuntimeList.RemoveAll(); +} diff --git a/xfa/fxjse/runtime.h b/xfa/fxjse/runtime.h new file mode 100644 index 0000000000..023aaaac9b --- /dev/null +++ b/xfa/fxjse/runtime.h @@ -0,0 +1,51 @@ +// 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_FXJSE_RUNTIME_H_ +#define XFA_FXJSE_RUNTIME_H_ + +#include "core/include/fxcrt/fx_basic.h" +#include "v8/include/v8.h" + +class CFXJSE_RuntimeList; + +class CFXJSE_RuntimeData { + protected: + CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} + + public: + static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); + static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); + + public: + v8::Isolate* m_pIsolate; + v8::Global<v8::FunctionTemplate> m_hRootContextGlobalTemplate; + v8::Global<v8::Context> m_hRootContext; + + public: + static CFXJSE_RuntimeList* g_RuntimeList; + + protected: + CFXJSE_RuntimeData(); + CFXJSE_RuntimeData(const CFXJSE_RuntimeData&); + CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&); +}; + +class CFXJSE_RuntimeList { + public: + typedef void (*RuntimeDisposeCallback)(v8::Isolate*); + + public: + void AppendRuntime(v8::Isolate* pIsolate); + void RemoveRuntime(v8::Isolate* pIsolate, + RuntimeDisposeCallback lpfnDisposeCallback); + void RemoveAllRuntimes(RuntimeDisposeCallback lpfnDisposeCallback); + + protected: + CFX_ArrayTemplate<v8::Isolate*> m_RuntimeList; +}; + +#endif // XFA_FXJSE_RUNTIME_H_ diff --git a/xfa/fxjse/scope_inline.h b/xfa/fxjse/scope_inline.h new file mode 100644 index 0000000000..8eeda5c949 --- /dev/null +++ b/xfa/fxjse/scope_inline.h @@ -0,0 +1,108 @@ +// 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_FXJSE_SCOPE_INLINE_H_ +#define XFA_FXJSE_SCOPE_INLINE_H_ + +#include "xfa/fxjse/context.h" +#include "xfa/fxjse/runtime.h" + +class CFXJSE_ScopeUtil_IsolateHandle { + protected: + v8::Isolate* m_isolate; + v8::Locker m_locker; + v8::Isolate::Scope m_iscope; + v8::HandleScope m_hscope; + + public: + explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) + : m_isolate(pIsolate), + m_locker(pIsolate), + m_iscope(pIsolate), + m_hscope(pIsolate) {} + v8::Isolate* GetIsolate() { return m_isolate; } + + private: + CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&); + void operator=(const CFXJSE_ScopeUtil_IsolateHandle&); + void* operator new(size_t size); + void operator delete(void*, size_t); +}; +class CFXJSE_ScopeUtil_IsolateHandleRootContext { + CFXJSE_ScopeUtil_IsolateHandle m_parent; + v8::Context::Scope m_cscope; + + public: + explicit CFXJSE_ScopeUtil_IsolateHandleRootContext(v8::Isolate* pIsolate) + : m_parent(pIsolate), + m_cscope(v8::Local<v8::Context>::New( + pIsolate, + CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} + + private: + CFXJSE_ScopeUtil_IsolateHandleRootContext( + const CFXJSE_ScopeUtil_IsolateHandleRootContext&); + void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&); + void* operator new(size_t size); + void operator delete(void*, size_t); +}; +class CFXJSE_ScopeUtil_IsolateHandleContext { + CFXJSE_Context* m_context; + CFXJSE_ScopeUtil_IsolateHandle m_parent; + v8::Context::Scope m_cscope; + + public: + explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) + : m_context(pContext), + m_parent(pContext->m_pIsolate), + m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate, + pContext->m_hContext)) {} + v8::Isolate* GetIsolate() { return m_context->m_pIsolate; } + v8::Local<v8::Context> GetLocalContext() { + return v8::Local<v8::Context>::New(m_context->m_pIsolate, + m_context->m_hContext); + } + + private: + CFXJSE_ScopeUtil_IsolateHandleContext( + const CFXJSE_ScopeUtil_IsolateHandleContext&); + void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&); + void* operator new(size_t size); + void operator delete(void*, size_t); +}; +class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext { + CFXJSE_Context* m_context; + CFXJSE_ScopeUtil_IsolateHandle m_parent; + v8::Context::Scope m_cscope; + + public: + explicit CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext( + v8::Isolate* pIsolate, + CFXJSE_Context* pContext) + : m_context(pContext), + m_parent(pIsolate), + m_cscope(v8::Local<v8::Context>::New( + pIsolate, + pContext ? pContext->m_hContext + : CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} + v8::Isolate* GetIsolate() { return m_parent.GetIsolate(); } + v8::Local<v8::Context> GetLocalContext() { + v8::Isolate* pIsolate = m_parent.GetIsolate(); + return v8::Local<v8::Context>::New( + pIsolate, m_context + ? m_context->m_hContext + : CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext); + } + + private: + CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext( + const CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext&); + void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext&); + void* operator new(size_t size); + void operator delete(void*, size_t); +}; + +#endif // XFA_FXJSE_SCOPE_INLINE_H_ diff --git a/xfa/fxjse/util_inline.h b/xfa/fxjse/util_inline.h new file mode 100644 index 0000000000..e61dc6aa80 --- /dev/null +++ b/xfa/fxjse/util_inline.h @@ -0,0 +1,51 @@ +// 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_FXJSE_UTIL_INLINE_H_ +#define XFA_FXJSE_UTIL_INLINE_H_ + +#include "xfa/fxjse/context.h" + +static V8_INLINE v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( + const v8::Local<v8::Context>& hContext) { + return hContext->Global()->GetPrototype().As<v8::Object>(); +} +static V8_INLINE void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, + void* lpNewBinding) { + ASSERT(!hObject.IsEmpty()); + ASSERT(hObject->InternalFieldCount() > 0); + hObject->SetAlignedPointerInInternalField(0, lpNewBinding); +} +static V8_INLINE void* FXJSE_RetrieveObjectBinding( + const v8::Local<v8::Object>& hJSObject, + CFXJSE_Class* lpClass = NULL) { + ASSERT(!hJSObject.IsEmpty()); + if (!hJSObject->IsObject()) { + return NULL; + } + v8::Local<v8::Object> hObject = hJSObject; + if (hObject->InternalFieldCount() == 0) { + v8::Local<v8::Value> hProtoObject = hObject->GetPrototype(); + if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { + return NULL; + } + hObject = hProtoObject.As<v8::Object>(); + if (hObject->InternalFieldCount() == 0) { + return NULL; + } + } + if (lpClass) { + v8::Local<v8::FunctionTemplate> hClass = + v8::Local<v8::FunctionTemplate>::New( + lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate()); + if (!hClass->HasInstance(hObject)) { + return NULL; + } + } + return hObject->GetAlignedPointerFromInternalField(0); +} + +#endif // XFA_FXJSE_UTIL_INLINE_H_ diff --git a/xfa/fxjse/value.cpp b/xfa/fxjse/value.cpp new file mode 100644 index 0000000000..7732026fe6 --- /dev/null +++ b/xfa/fxjse/value.cpp @@ -0,0 +1,582 @@ +// 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/fxjse/value.h" + +#include <math.h> + +#include "xfa/fxjse/class.h" +#include "xfa/fxjse/util_inline.h" + +FX_BOOL FXJSE_Value_IsUndefined(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + return lpValue && lpValue->IsUndefined(); +} + +FX_BOOL FXJSE_Value_IsNull(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + return lpValue && lpValue->IsNull(); +} + +FX_BOOL FXJSE_Value_IsBoolean(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + return lpValue && lpValue->IsBoolean(); +} + +FX_BOOL FXJSE_Value_IsUTF8String(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + return lpValue && lpValue->IsString(); +} + +FX_BOOL FXJSE_Value_IsNumber(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); +} + +FX_BOOL FXJSE_Value_IsArray(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + return lpValue && lpValue->IsArray(); +} + +FX_BOOL FXJSE_Value_IsFunction(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); +} + +FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue) { + return reinterpret_cast<CFXJSE_Value*>(hValue)->ToFloat(); +} + +FXJSE_DOUBLE FXJSE_Value_ToDouble(FXJSE_HVALUE hValue) { + return reinterpret_cast<CFXJSE_Value*>(hValue)->ToDouble(); +} + +void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, + CFX_ByteString& szStrOutput) { + return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); +} + +int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { + return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); +} + +void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, FXJSE_HCLASS hClass) { + CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); + return reinterpret_cast<CFXJSE_Value*>(hValue)->ToObject(lpClass); +} + +void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetUndefined(); +} + +void FXJSE_Value_SetNull(FXJSE_HVALUE hValue) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetNull(); +} + +void FXJSE_Value_SetBoolean(FXJSE_HVALUE hValue, FX_BOOL bBoolean) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetBoolean(bBoolean); +} + +void FXJSE_Value_SetUTF8String(FXJSE_HVALUE hValue, + const CFX_ByteStringC& szString) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetString(szString); +} + +void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetInteger(nInteger); +} + +void FXJSE_Value_SetFloat(FXJSE_HVALUE hValue, FX_FLOAT fFloat) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetFloat(fFloat); +} + +void FXJSE_Value_SetDouble(FXJSE_HVALUE hValue, FXJSE_DOUBLE dDouble) { + reinterpret_cast<CFXJSE_Value*>(hValue)->SetDouble(dDouble); +} + +void FXJSE_Value_SetObject(FXJSE_HVALUE hValue, + void* lpObject, + FXJSE_HCLASS hClass) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); + if (!lpClass) { + ASSERT(!lpObject); + lpValue->SetJSObject(); + } else { + lpValue->SetHostObject(lpObject, lpClass); + } +} + +void FXJSE_Value_SetArray(FXJSE_HVALUE hValue, + uint32_t uValueCount, + FXJSE_HVALUE* rgValues) { + reinterpret_cast<CFXJSE_Value*>(hValue) + ->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgValues)); +} + +void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, FXJSE_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 = + reinterpret_cast<CFXJSE_Value*>(hOriginalValue); + ASSERT(lpValue && lpOriginalValue); + lpValue->Assign(lpOriginalValue); +} + +FX_BOOL FXJSE_Value_GetObjectProp(FXJSE_HVALUE hValue, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hPropValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); + ASSERT(lpValue && lpPropValue); + return lpValue->GetObjectProperty(szPropName, lpPropValue); +} + +FX_BOOL FXJSE_Value_SetObjectProp(FXJSE_HVALUE hValue, + const CFX_ByteStringC& szPropName, + 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(szPropName, lpPropValue); +} + +FX_BOOL FXJSE_Value_GetObjectPropByIdx(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->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) + ->DeleteObjectProperty(szPropName); +} + +FX_BOOL FXJSE_Value_ObjectHasOwnProp(FXJSE_HVALUE hValue, + const CFX_ByteStringC& szPropName, + FX_BOOL bUseTypeGetter) { + return reinterpret_cast<CFXJSE_Value*>(hValue) + ->HasObjectOwnProperty(szPropName, bUseTypeGetter); +} + +FX_BOOL FXJSE_Value_SetObjectOwnProp(FXJSE_HVALUE hValue, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hPropValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); + ASSERT(lpValue && lpPropValue); + return lpValue->SetObjectOwnProperty(szPropName, lpPropValue); +} + +FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue, + FXJSE_HVALUE hOldFunction, + FXJSE_HVALUE hNewThis) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); + CFXJSE_Value* lpOldFunction = reinterpret_cast<CFXJSE_Value*>(hOldFunction); + CFXJSE_Value* lpNewThis = reinterpret_cast<CFXJSE_Value*>(hNewThis); + ASSERT(lpValue && lpOldFunction && lpNewThis); + 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))); +} + +void FXJSE_Value_Release(FXJSE_HVALUE hValue) { + CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); + ASSERT(pIsolate); + + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::String> hMessage = v8::String::NewFromUtf8( + pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, + utf8Message.GetLength()); + v8::Local<v8::Value> hError; + + if (utf8Name == "RangeError") { + hError = v8::Exception::RangeError(hMessage); + } else if (utf8Name == "ReferenceError") { + hError = v8::Exception::ReferenceError(hMessage); + } else if (utf8Name == "SyntaxError") { + hError = v8::Exception::SyntaxError(hMessage); + } else if (utf8Name == "TypeError") { + hError = v8::Exception::TypeError(hMessage); + } else { + hError = v8::Exception::Error(hMessage); + if (utf8Name != "Error" && !utf8Name.IsEmpty()) { + hError.As<v8::Object>()->Set( + v8::String::NewFromUtf8(pIsolate, "name"), + v8::String::NewFromUtf8(pIsolate, utf8Name.GetCStr(), + v8::String::kNormalString, + utf8Name.GetLength())); + } + } + pIsolate->ThrowException(hError); +} + +CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { + return new CFXJSE_Value(pIsolate); +} + +void* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { + ASSERT(!m_hValue.IsEmpty()); + + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + ASSERT(!hValue.IsEmpty()); + + if (!hValue->IsObject()) + return nullptr; + + return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); +} + +V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { + if (sizeof(FX_FLOAT) != 4) { + ASSERT(FALSE); + return fNumber; + } + + uint32_t nFloatBits = (uint32_t&)fNumber; + uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7); + if (nExponent == 0 || nExponent == 255) + return fNumber; + + int8_t nErrExp = nExponent - 127 - 23; + if (nErrExp >= 0) + return fNumber; + + double dwError = pow(2.0, nErrExp), dwErrorHalf = dwError / 2; + double dNumber = fNumber, dNumberAbs = fabs(fNumber); + double dNumberAbsMin = dNumberAbs - dwErrorHalf, + dNumberAbsMax = dNumberAbs + dwErrorHalf; + int32_t iErrPos = 0; + if (floor(dNumberAbsMin) == floor(dNumberAbsMax)) { + dNumberAbsMin = fmod(dNumberAbsMin, 1.0); + dNumberAbsMax = fmod(dNumberAbsMax, 1.0); + int32_t iErrPosMin = 1, iErrPosMax = 38; + do { + int32_t iMid = (iErrPosMin + iErrPosMax) / 2; + double dPow = pow(10.0, iMid); + if (floor(dNumberAbsMin * dPow) == floor(dNumberAbsMax * dPow)) { + iErrPosMin = iMid + 1; + } else { + iErrPosMax = iMid; + } + } while (iErrPosMin < iErrPosMax); + iErrPos = iErrPosMax; + } + double dPow = pow(10.0, iErrPos); + return fNumber < 0 ? ceil(dNumber * dPow - 0.5) / dPow + : floor(dNumber * dPow + 0.5) / dPow; +} + +void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, FXJSE_ftod(fFloat)); + m_hValue.Reset(m_pIsolate, hValue); +} + +void CFXJSE_Value::SetHostObject(void* lpObject, CFXJSE_Class* lpClass) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + ASSERT(lpClass); + v8::Local<v8::FunctionTemplate> hClass = + v8::Local<v8::FunctionTemplate>::New(m_pIsolate, lpClass->m_hTemplate); + v8::Local<v8::Object> hObject = hClass->InstanceTemplate()->NewInstance(); + FXJSE_UpdateObjectBinding(hObject, lpObject); + m_hValue.Reset(m_pIsolate, hObject); +} + +void CFXJSE_Value::SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, uValueCount); + if (rgValues) { + for (uint32_t i = 0; i < uValueCount; i++) { + if (rgValues[i]) { + hArrayObject->Set(i, v8::Local<v8::Value>::New( + m_pIsolate, rgValues[i]->DirectGetValue())); + } + } + } + m_hValue.Reset(m_pIsolate, hArrayObject); +} + +void CFXJSE_Value::SetDate(FXJSE_DOUBLE dDouble) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hDate = v8::Date::New(m_pIsolate, dDouble); + m_hValue.Reset(m_pIsolate, hDate); +} + +FX_BOOL CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::Value> hPropValue = + v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue()); + return (FX_BOOL)hObject.As<v8::Object>()->Set( + v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), + v8::String::kNormalString, + szPropName.GetLength()), + hPropValue); +} + +FX_BOOL CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::Value> hPropValue = + hObject.As<v8::Object>()->Get(v8::String::NewFromUtf8( + m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, + szPropName.GetLength())); + lpPropValue->ForceSetValue(hPropValue); + return TRUE; +} + +FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, + CFXJSE_Value* lpPropValue) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::Value> hPropValue = + v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue()); + return (FX_BOOL)hObject.As<v8::Object>()->Set(uPropIdx, hPropValue); +} + +FX_BOOL CFXJSE_Value::GetObjectProperty(uint32_t uPropIdx, + CFXJSE_Value* lpPropValue) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(uPropIdx); + lpPropValue->ForceSetValue(hPropValue); + return TRUE; +} + +FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + hObject.As<v8::Object>()->Delete(v8::String::NewFromUtf8( + m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, + szPropName.GetLength())); + return TRUE; +} + +FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, + FX_BOOL bUseTypeGetter) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::String> hKey = v8::String::NewFromUtf8( + m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, + szPropName.GetLength()); + return hObject.As<v8::Object>()->HasRealNamedProperty(hKey) || + (bUseTypeGetter && + hObject.As<v8::Object>() + ->HasOwnProperty(m_pIsolate->GetCurrentContext(), hKey) + .FromMaybe(false)); +} + +FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hObject = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + if (!hObject->IsObject()) + return FALSE; + + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->m_hValue); + return hObject.As<v8::Object>() + ->DefineOwnProperty( + m_pIsolate->GetCurrentContext(), + v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), + v8::String::kNormalString, + szPropName.GetLength()), + hValue) + .FromMaybe(false); +} + +FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, + CFXJSE_Value* lpNewThis) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> rgArgs[2]; + v8::Local<v8::Value> hOldFunction = + v8::Local<v8::Value>::New(m_pIsolate, lpOldFunction->DirectGetValue()); + if (hOldFunction.IsEmpty() || !hOldFunction->IsFunction()) + return FALSE; + + rgArgs[0] = hOldFunction; + v8::Local<v8::Value> hNewThis = + v8::Local<v8::Value>::New(m_pIsolate, lpNewThis->DirectGetValue()); + if (hNewThis.IsEmpty()) + return FALSE; + + rgArgs[1] = hNewThis; + v8::Local<v8::String> hBinderFuncSource = + v8::String::NewFromUtf8(m_pIsolate, + "(function (oldfunction, newthis) { return " + "oldfunction.bind(newthis); })"); + v8::Local<v8::Function> hBinderFunc = + v8::Script::Compile(hBinderFuncSource)->Run().As<v8::Function>(); + v8::Local<v8::Value> hBoundFunction = + hBinderFunc->Call(m_pIsolate->GetCurrentContext()->Global(), 2, rgArgs); + if (hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) + return FALSE; + + m_hValue.Reset(m_pIsolate, hBoundFunction); + return TRUE; +} + +#define FXJSE_INVALID_PTR ((void*)(intptr_t)-1) +FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, + CFXJSE_Value* lpRetValue, + uint32_t nArgCount, + FXJSE_HVALUE* lpArgs) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hFunctionValue = + v8::Local<v8::Value>::New(m_pIsolate, DirectGetValue()); + v8::Local<v8::Object> hFunctionObject = + !hFunctionValue.IsEmpty() && hFunctionValue->IsObject() + ? hFunctionValue.As<v8::Object>() + : v8::Local<v8::Object>(); + + v8::TryCatch trycatch(m_pIsolate); + if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) { + if (lpRetValue) + lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycatch)); + return FALSE; + } + + v8::Local<v8::Value> hReturnValue; + v8::Local<v8::Value>* lpLocalArgs = NULL; + if (nArgCount) { + lpLocalArgs = FX_Alloc(v8::Local<v8::Value>, nArgCount); + for (uint32_t i = 0; i < nArgCount; i++) { + new (lpLocalArgs + i) v8::Local<v8::Value>; + CFXJSE_Value* lpArg = (CFXJSE_Value*)lpArgs[i]; + if (lpArg) { + lpLocalArgs[i] = + v8::Local<v8::Value>::New(m_pIsolate, lpArg->DirectGetValue()); + } + if (lpLocalArgs[i].IsEmpty()) { + lpLocalArgs[i] = v8::Undefined(m_pIsolate); + } + } + } + + FX_BOOL bRetValue = TRUE; + if (lpReceiver == FXJSE_INVALID_PTR) { + v8::MaybeLocal<v8::Value> maybe_retvalue = + hFunctionObject->CallAsConstructor(m_pIsolate->GetCurrentContext(), + nArgCount, lpLocalArgs); + hReturnValue = maybe_retvalue.FromMaybe(v8::Local<v8::Value>()); + } else { + v8::Local<v8::Value> hReceiver; + if (lpReceiver) { + hReceiver = + v8::Local<v8::Value>::New(m_pIsolate, lpReceiver->DirectGetValue()); + } + if (hReceiver.IsEmpty() || !hReceiver->IsObject()) + hReceiver = v8::Object::New(m_pIsolate); + + v8::MaybeLocal<v8::Value> maybe_retvalue = hFunctionObject->CallAsFunction( + m_pIsolate->GetCurrentContext(), hReceiver, nArgCount, lpLocalArgs); + hReturnValue = maybe_retvalue.FromMaybe(v8::Local<v8::Value>()); + } + + if (trycatch.HasCaught()) { + hReturnValue = FXJSE_CreateReturnValue(m_pIsolate, trycatch); + bRetValue = FALSE; + } + + if (lpRetValue) + lpRetValue->ForceSetValue(hReturnValue); + + if (lpLocalArgs) { + for (uint32_t i = 0; i < nArgCount; i++) + lpLocalArgs[i].~Local(); + FX_Free(lpLocalArgs); + } + return bRetValue; +} diff --git a/xfa/fxjse/value.h b/xfa/fxjse/value.h new file mode 100644 index 0000000000..7e140d7975 --- /dev/null +++ b/xfa/fxjse/value.h @@ -0,0 +1,241 @@ +// 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_FXJSE_VALUE_H_ +#define XFA_FXJSE_VALUE_H_ + +#include "xfa/fxjse/scope_inline.h" + +class CFXJSE_Value { + public: + CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} + + protected: + CFXJSE_Value(); + CFXJSE_Value(const CFXJSE_Value&); + CFXJSE_Value& operator=(const CFXJSE_Value&); + + public: + V8_INLINE FX_BOOL IsUndefined() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsUndefined(); + } + V8_INLINE FX_BOOL IsNull() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsNull(); + } + V8_INLINE FX_BOOL IsBoolean() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsBoolean(); + } + V8_INLINE FX_BOOL IsString() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsString(); + } + V8_INLINE FX_BOOL IsNumber() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsNumber(); + } + V8_INLINE FX_BOOL IsInteger() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsInt32(); + } + V8_INLINE FX_BOOL IsObject() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsObject(); + } + V8_INLINE FX_BOOL IsArray() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsArray(); + } + V8_INLINE FX_BOOL IsFunction() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsFunction(); + } + V8_INLINE FX_BOOL IsDate() const { + if (m_hValue.IsEmpty()) { + return FALSE; + } + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return hValue->IsDate(); + } + + public: + V8_INLINE FX_BOOL ToBoolean() const { + ASSERT(!m_hValue.IsEmpty()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return static_cast<FX_BOOL>(hValue->BooleanValue()); + } + V8_INLINE FX_FLOAT ToFloat() const { + ASSERT(!m_hValue.IsEmpty()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return static_cast<FX_FLOAT>(hValue->NumberValue()); + } + V8_INLINE FXJSE_DOUBLE ToDouble() const { + ASSERT(!m_hValue.IsEmpty()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return static_cast<FXJSE_DOUBLE>(hValue->NumberValue()); + } + V8_INLINE int32_t ToInteger() const { + ASSERT(!m_hValue.IsEmpty()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + return static_cast<int32_t>(hValue->NumberValue()); + } + V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { + ASSERT(!m_hValue.IsEmpty()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Local<v8::Value>::New(m_pIsolate, m_hValue); + v8::Local<v8::String> hString = hValue->ToString(); + v8::String::Utf8Value hStringVal(hString); + szStrOutput = *hStringVal; + } + void* ToObject(CFXJSE_Class* lpClass) const; + + public: + V8_INLINE void SetUndefined() { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetNull() { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Null(m_pIsolate); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetBoolean(FX_BOOL bBoolean) { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = + v8::Boolean::New(m_pIsolate, bBoolean != FALSE); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetInteger(int32_t nInteger) { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetDouble(FXJSE_DOUBLE dDouble) { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetString(const CFX_ByteStringC& szString) { + CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::String::NewFromUtf8( + m_pIsolate, reinterpret_cast<const char*>(szString.GetPtr()), + v8::String::kNormalString, szString.GetLength()); + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void SetFloat(FX_FLOAT fFloat); + V8_INLINE void SetJSObject() { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); + v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); + m_hValue.Reset(m_pIsolate, hValue); + } + void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); + void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); + void SetDate(FXJSE_DOUBLE dDouble); + + public: + FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue); + FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue); + FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); + FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); + FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); + FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, + FX_BOOL bUseTypeGetter); + FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue); + FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis); + FX_BOOL Call(CFXJSE_Value* lpReceiver, + CFXJSE_Value* lpRetValue, + uint32_t nArgCount, + FXJSE_HVALUE* lpArgs); + + public: + V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; } + V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const { + return m_hValue; + } + V8_INLINE void ForceSetValue(v8::Local<v8::Value> hValue) { + m_hValue.Reset(m_pIsolate, hValue); + } + V8_INLINE void Assign(const CFXJSE_Value* lpValue) { + if (lpValue) { + m_hValue.Reset(m_pIsolate, lpValue->m_hValue); + } else { + m_hValue.Reset(); + } + } + + public: + static CFXJSE_Value* Create(v8::Isolate* pIsolate); + + protected: + v8::Isolate* m_pIsolate; + v8::Global<v8::Value> m_hValue; + friend class CFXJSE_Context; + friend class CFXJSE_Class; +}; + +#endif // XFA_FXJSE_VALUE_H_ diff --git a/xfa/include/fwl/basewidget/fwl_picturebox.h b/xfa/include/fwl/basewidget/fwl_picturebox.h index be999493b2..123607a804 100644 --- a/xfa/include/fwl/basewidget/fwl_picturebox.h +++ b/xfa/include/fwl/basewidget/fwl_picturebox.h @@ -7,7 +7,7 @@ #ifndef XFA_INCLUDE_FWL_BASEWIDGET_FWL_PICTUREBOX_H_ #define XFA_INCLUDE_FWL_BASEWIDGET_FWL_PICTUREBOX_H_ -#include "xfa/src/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" #define FWL_CLASS_PictureBox L"FWL_PICTUREBOX" #define FWL_CLASSHASH_PictureBox 2974721741 diff --git a/xfa/include/fwl/basewidget/fwl_pushbutton.h b/xfa/include/fwl/basewidget/fwl_pushbutton.h index ffc05c2305..28f9df4fa6 100644 --- a/xfa/include/fwl/basewidget/fwl_pushbutton.h +++ b/xfa/include/fwl/basewidget/fwl_pushbutton.h @@ -7,8 +7,8 @@ #ifndef XFA_INCLUDE_FWL_BASEWIDGET_FWL_PUSHBUTTON_H_ #define XFA_INCLUDE_FWL_BASEWIDGET_FWL_PUSHBUTTON_H_ +#include "xfa/fwl/core/fwl_widgetimp.h" #include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" #define FWL_CLASS_PushButton L"FWL_PUSHBUTTON" #define FWL_CLASSHASH_PushButton 3521614244 diff --git a/xfa/include/fwl/basewidget/fwl_scrollbar.h b/xfa/include/fwl/basewidget/fwl_scrollbar.h index 461e67576c..8cd69bcf1f 100644 --- a/xfa/include/fwl/basewidget/fwl_scrollbar.h +++ b/xfa/include/fwl/basewidget/fwl_scrollbar.h @@ -7,7 +7,7 @@ #ifndef XFA_INCLUDE_FWL_BASEWIDGET_FWL_SCROLLBAR_H_ #define XFA_INCLUDE_FWL_BASEWIDGET_FWL_SCROLLBAR_H_ -#include "xfa/src/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" #define FWL_CLASS_ScrollBar L"FWL_SCROLLBAR" #define FWL_CLASSHASH_ScrollBar 2826584844 diff --git a/xfa/include/fwl/basewidget/fwl_spinbutton.h b/xfa/include/fwl/basewidget/fwl_spinbutton.h index 17f48954b8..fdd27c64a6 100644 --- a/xfa/include/fwl/basewidget/fwl_spinbutton.h +++ b/xfa/include/fwl/basewidget/fwl_spinbutton.h @@ -7,7 +7,7 @@ #ifndef XFA_INCLUDE_FWL_BASEWIDGET_FWL_SPINBUTTON_H_ #define XFA_INCLUDE_FWL_BASEWIDGET_FWL_SPINBUTTON_H_ -#include "xfa/src/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" #define FWL_CLASS_SpinButton L"FWL_SPINBUTTON" #define FWL_CLASSHASH_SpinButton 3793043646 diff --git a/xfa/include/fwl/core/fwl_content.h b/xfa/include/fwl/core/fwl_content.h index 5801bd3374..10d6c1e1ac 100644 --- a/xfa/include/fwl/core/fwl_content.h +++ b/xfa/include/fwl/core/fwl_content.h @@ -7,7 +7,7 @@ #ifndef XFA_INCLUDE_FWL_CORE_FWL_CONTENT_H_ #define XFA_INCLUDE_FWL_CORE_FWL_CONTENT_H_ -#include "xfa/src/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" class IFWL_Content : public IFWL_Widget { public: diff --git a/xfa/include/fwl/core/fwl_panel.h b/xfa/include/fwl/core/fwl_panel.h index 462112c6be..4e0b7a38a0 100644 --- a/xfa/include/fwl/core/fwl_panel.h +++ b/xfa/include/fwl/core/fwl_panel.h @@ -7,7 +7,7 @@ #ifndef XFA_INCLUDE_FWL_CORE_FWL_PANEL_H_ #define XFA_INCLUDE_FWL_CORE_FWL_PANEL_H_ -#include "xfa/src/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" class IFWL_Content; diff --git a/xfa/include/fxfa/fxfa_objectacc.h b/xfa/include/fxfa/fxfa_objectacc.h index 7938b2ef2d..6f111b06f8 100644 --- a/xfa/include/fxfa/fxfa_objectacc.h +++ b/xfa/include/fxfa/fxfa_objectacc.h @@ -8,7 +8,7 @@ #define XFA_INCLUDE_FXFA_FXFA_OBJECTACC_H_ #include "core/include/fxge/fx_dib.h" -#include "xfa/src/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/xfa_object.h" class CXFA_Node; class IFX_Locale; diff --git a/xfa/src/fde/css/fde_css.h b/xfa/src/fde/css/fde_css.h deleted file mode 100644 index 1e62b66c9a..0000000000 --- a/xfa/src/fde/css/fde_css.h +++ /dev/null @@ -1,1082 +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_SRC_FDE_CSS_FDE_CSS_H_ -#define XFA_SRC_FDE_CSS_FDE_CSS_H_ - -#include "core/include/fxge/fx_dib.h" -#include "xfa/src/fgas/font/fgas_font.h" -#include "xfa/src/fgas/crt/fgas_stream.h" -#include "xfa/src/fgas/crt/fgas_utils.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 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; - -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, - FDE_CSSPRIMITIVETYPE_Percent = 2, - FDE_CSSPRIMITIVETYPE_EMS = 3, - FDE_CSSPRIMITIVETYPE_EXS = 4, - FDE_CSSPRIMITIVETYPE_PX = 5, - FDE_CSSPRIMITIVETYPE_CM = 6, - FDE_CSSPRIMITIVETYPE_MM = 7, - FDE_CSSPRIMITIVETYPE_IN = 8, - FDE_CSSPRIMITIVETYPE_PT = 9, - FDE_CSSPRIMITIVETYPE_PC = 10, - FDE_CSSPRIMITIVETYPE_String = 19, - FDE_CSSPRIMITIVETYPE_URI = 20, - FDE_CSSPRIMITIVETYPE_RGB = 25, - FDE_CSSPRIMITIVETYPE_Enum, - FDE_CSSPRIMITIVETYPE_Function, -}; -enum FDE_CSSPROPERTYVALUE { - FDE_CSSPROPERTYVALUE_Bolder, - FDE_CSSPROPERTYVALUE_LowerLatin, - FDE_CSSPROPERTYVALUE_Lowercase, - FDE_CSSPROPERTYVALUE_LowerGreek, - FDE_CSSPROPERTYVALUE_Sesame, - FDE_CSSPROPERTYVALUE_None, - FDE_CSSPROPERTYVALUE_NwResize, - FDE_CSSPROPERTYVALUE_WResize, - FDE_CSSPROPERTYVALUE_Dot, - FDE_CSSPROPERTYVALUE_End, - FDE_CSSPROPERTYVALUE_Ltr, - FDE_CSSPROPERTYVALUE_Pre, - FDE_CSSPROPERTYVALUE_Rtl, - FDE_CSSPROPERTYVALUE_Sub, - FDE_CSSPROPERTYVALUE_Top, - FDE_CSSPROPERTYVALUE_Visible, - FDE_CSSPROPERTYVALUE_Filled, - FDE_CSSPROPERTYVALUE_SwResize, - FDE_CSSPROPERTYVALUE_NoRepeat, - FDE_CSSPROPERTYVALUE_Default, - FDE_CSSPROPERTYVALUE_Transparent, - FDE_CSSPROPERTYVALUE_Ridge, - FDE_CSSPROPERTYVALUE_Right, - FDE_CSSPROPERTYVALUE_HorizontalTb, - FDE_CSSPROPERTYVALUE_DistributeLetter, - FDE_CSSPROPERTYVALUE_DoubleCircle, - FDE_CSSPROPERTYVALUE_Ruby, - FDE_CSSPROPERTYVALUE_Collapse, - FDE_CSSPROPERTYVALUE_Normal, - FDE_CSSPROPERTYVALUE_Avoid, - FDE_CSSPROPERTYVALUE_UpperRoman, - FDE_CSSPROPERTYVALUE_Auto, - FDE_CSSPROPERTYVALUE_Text, - FDE_CSSPROPERTYVALUE_XSmall, - FDE_CSSPROPERTYVALUE_Thin, - FDE_CSSPROPERTYVALUE_Repeat, - FDE_CSSPROPERTYVALUE_Small, - FDE_CSSPROPERTYVALUE_NeResize, - FDE_CSSPROPERTYVALUE_NoContent, - FDE_CSSPROPERTYVALUE_Outside, - FDE_CSSPROPERTYVALUE_EResize, - FDE_CSSPROPERTYVALUE_TableRow, - FDE_CSSPROPERTYVALUE_Bottom, - FDE_CSSPROPERTYVALUE_Underline, - FDE_CSSPROPERTYVALUE_CjkIdeographic, - FDE_CSSPROPERTYVALUE_SeResize, - FDE_CSSPROPERTYVALUE_Fixed, - FDE_CSSPROPERTYVALUE_Double, - FDE_CSSPROPERTYVALUE_Solid, - FDE_CSSPROPERTYVALUE_RubyBaseGroup, - FDE_CSSPROPERTYVALUE_OpenQuote, - FDE_CSSPROPERTYVALUE_Lighter, - FDE_CSSPROPERTYVALUE_LowerRoman, - FDE_CSSPROPERTYVALUE_Strict, - FDE_CSSPROPERTYVALUE_TableCaption, - FDE_CSSPROPERTYVALUE_Oblique, - FDE_CSSPROPERTYVALUE_Decimal, - FDE_CSSPROPERTYVALUE_Loose, - FDE_CSSPROPERTYVALUE_Hebrew, - FDE_CSSPROPERTYVALUE_Hidden, - FDE_CSSPROPERTYVALUE_Dashed, - FDE_CSSPROPERTYVALUE_Embed, - FDE_CSSPROPERTYVALUE_TableRowGroup, - FDE_CSSPROPERTYVALUE_TableColumn, - FDE_CSSPROPERTYVALUE_Static, - FDE_CSSPROPERTYVALUE_Outset, - FDE_CSSPROPERTYVALUE_DecimalLeadingZero, - FDE_CSSPROPERTYVALUE_KeepWords, - FDE_CSSPROPERTYVALUE_KatakanaIroha, - FDE_CSSPROPERTYVALUE_Super, - FDE_CSSPROPERTYVALUE_Center, - FDE_CSSPROPERTYVALUE_TableHeaderGroup, - FDE_CSSPROPERTYVALUE_Inside, - FDE_CSSPROPERTYVALUE_XxLarge, - FDE_CSSPROPERTYVALUE_Triangle, - FDE_CSSPROPERTYVALUE_RubyTextGroup, - FDE_CSSPROPERTYVALUE_Circle, - FDE_CSSPROPERTYVALUE_Hiragana, - FDE_CSSPROPERTYVALUE_RepeatX, - FDE_CSSPROPERTYVALUE_RepeatY, - FDE_CSSPROPERTYVALUE_Move, - FDE_CSSPROPERTYVALUE_HiraganaIroha, - FDE_CSSPROPERTYVALUE_RubyBase, - FDE_CSSPROPERTYVALUE_Scroll, - FDE_CSSPROPERTYVALUE_Smaller, - FDE_CSSPROPERTYVALUE_TableFooterGroup, - FDE_CSSPROPERTYVALUE_Baseline, - FDE_CSSPROPERTYVALUE_Separate, - FDE_CSSPROPERTYVALUE_Armenian, - FDE_CSSPROPERTYVALUE_Open, - FDE_CSSPROPERTYVALUE_Relative, - FDE_CSSPROPERTYVALUE_Thick, - FDE_CSSPROPERTYVALUE_Justify, - FDE_CSSPROPERTYVALUE_Middle, - FDE_CSSPROPERTYVALUE_Always, - FDE_CSSPROPERTYVALUE_DistributeSpace, - FDE_CSSPROPERTYVALUE_LineEdge, - FDE_CSSPROPERTYVALUE_PreWrap, - FDE_CSSPROPERTYVALUE_Medium, - FDE_CSSPROPERTYVALUE_NResize, - FDE_CSSPROPERTYVALUE_ListItem, - FDE_CSSPROPERTYVALUE_Show, - FDE_CSSPROPERTYVALUE_Currentcolor, - FDE_CSSPROPERTYVALUE_NoCloseQuote, - FDE_CSSPROPERTYVALUE_VerticalLr, - FDE_CSSPROPERTYVALUE_VerticalRl, - FDE_CSSPROPERTYVALUE_Pointer, - FDE_CSSPROPERTYVALUE_XxSmall, - FDE_CSSPROPERTYVALUE_Bold, - FDE_CSSPROPERTYVALUE_Both, - FDE_CSSPROPERTYVALUE_SmallCaps, - FDE_CSSPROPERTYVALUE_Katakana, - FDE_CSSPROPERTYVALUE_After, - FDE_CSSPROPERTYVALUE_Horizontal, - FDE_CSSPROPERTYVALUE_Dotted, - FDE_CSSPROPERTYVALUE_Disc, - FDE_CSSPROPERTYVALUE_Georgian, - FDE_CSSPROPERTYVALUE_Inline, - FDE_CSSPROPERTYVALUE_Overline, - FDE_CSSPROPERTYVALUE_Wait, - FDE_CSSPROPERTYVALUE_BreakAll, - FDE_CSSPROPERTYVALUE_UpperAlpha, - FDE_CSSPROPERTYVALUE_Capitalize, - FDE_CSSPROPERTYVALUE_Nowrap, - FDE_CSSPROPERTYVALUE_TextBottom, - FDE_CSSPROPERTYVALUE_NoOpenQuote, - FDE_CSSPROPERTYVALUE_Groove, - FDE_CSSPROPERTYVALUE_Progress, - FDE_CSSPROPERTYVALUE_Larger, - FDE_CSSPROPERTYVALUE_CloseQuote, - FDE_CSSPROPERTYVALUE_TableCell, - FDE_CSSPROPERTYVALUE_PreLine, - FDE_CSSPROPERTYVALUE_Absolute, - FDE_CSSPROPERTYVALUE_InlineTable, - FDE_CSSPROPERTYVALUE_BidiOverride, - FDE_CSSPROPERTYVALUE_InlineBlock, - FDE_CSSPROPERTYVALUE_Inset, - FDE_CSSPROPERTYVALUE_Crosshair, - FDE_CSSPROPERTYVALUE_UpperLatin, - FDE_CSSPROPERTYVALUE_Help, - FDE_CSSPROPERTYVALUE_Hide, - FDE_CSSPROPERTYVALUE_Uppercase, - FDE_CSSPROPERTYVALUE_SResize, - FDE_CSSPROPERTYVALUE_Table, - FDE_CSSPROPERTYVALUE_Blink, - FDE_CSSPROPERTYVALUE_Block, - FDE_CSSPROPERTYVALUE_Start, - FDE_CSSPROPERTYVALUE_TableColumnGroup, - FDE_CSSPROPERTYVALUE_Italic, - FDE_CSSPROPERTYVALUE_LineThrough, - FDE_CSSPROPERTYVALUE_KeepAll, - FDE_CSSPROPERTYVALUE_LowerAlpha, - FDE_CSSPROPERTYVALUE_RunIn, - FDE_CSSPROPERTYVALUE_Square, - FDE_CSSPROPERTYVALUE_XLarge, - FDE_CSSPROPERTYVALUE_Large, - FDE_CSSPROPERTYVALUE_Before, - FDE_CSSPROPERTYVALUE_Left, - FDE_CSSPROPERTYVALUE_TextTop, - FDE_CSSPROPERTYVALUE_RubyText, - 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, - FDE_CSSPROPERTY_BorderLeft, - FDE_CSSPROPERTY_ColumnRule, - FDE_CSSPROPERTY_Height, - FDE_CSSPROPERTY_CounterReset, - FDE_CSSPROPERTY_Content, - FDE_CSSPROPERTY_RubyPosition, - FDE_CSSPROPERTY_BackgroundColor, - FDE_CSSPROPERTY_Width, - FDE_CSSPROPERTY_Src, - FDE_CSSPROPERTY_Top, - FDE_CSSPROPERTY_Margin, - FDE_CSSPROPERTY_BorderColor, - FDE_CSSPROPERTY_Widows, - FDE_CSSPROPERTY_BorderBottomColor, - FDE_CSSPROPERTY_TextIndent, - FDE_CSSPROPERTY_Right, - FDE_CSSPROPERTY_TextEmphasisStyle, - FDE_CSSPROPERTY_PaddingLeft, - FDE_CSSPROPERTY_ColumnWidth, - FDE_CSSPROPERTY_MarginLeft, - FDE_CSSPROPERTY_Border, - FDE_CSSPROPERTY_BorderTop, - FDE_CSSPROPERTY_RubyOverhang, - FDE_CSSPROPERTY_PageBreakBefore, - FDE_CSSPROPERTY_MaxHeight, - FDE_CSSPROPERTY_MinWidth, - FDE_CSSPROPERTY_BorderLeftColor, - FDE_CSSPROPERTY_Bottom, - FDE_CSSPROPERTY_Quotes, - FDE_CSSPROPERTY_MaxWidth, - FDE_CSSPROPERTY_PaddingRight, - FDE_CSSPROPERTY_ListStyleImage, - FDE_CSSPROPERTY_WhiteSpace, - FDE_CSSPROPERTY_BorderBottom, - FDE_CSSPROPERTY_ListStyleType, - FDE_CSSPROPERTY_WordBreak, - FDE_CSSPROPERTY_OverflowX, - FDE_CSSPROPERTY_OverflowY, - FDE_CSSPROPERTY_BorderTopColor, - FDE_CSSPROPERTY_FontFamily, - FDE_CSSPROPERTY_Cursor, - FDE_CSSPROPERTY_RubyAlign, - FDE_CSSPROPERTY_ColumnRuleColor, - FDE_CSSPROPERTY_FontWeight, - FDE_CSSPROPERTY_BorderRightStyle, - FDE_CSSPROPERTY_MinHeight, - FDE_CSSPROPERTY_Color, - FDE_CSSPROPERTY_LetterSpacing, - FDE_CSSPROPERTY_EmptyCells, - FDE_CSSPROPERTY_TextAlign, - FDE_CSSPROPERTY_RubySpan, - FDE_CSSPROPERTY_Position, - FDE_CSSPROPERTY_BorderStyle, - FDE_CSSPROPERTY_BorderBottomStyle, - FDE_CSSPROPERTY_BorderCollapse, - FDE_CSSPROPERTY_ColumnCount, - FDE_CSSPROPERTY_BorderRightWidth, - FDE_CSSPROPERTY_UnicodeBidi, - FDE_CSSPROPERTY_VerticalAlign, - FDE_CSSPROPERTY_PaddingTop, - FDE_CSSPROPERTY_Columns, - FDE_CSSPROPERTY_Overflow, - FDE_CSSPROPERTY_TableLayout, - FDE_CSSPROPERTY_FontVariant, - FDE_CSSPROPERTY_ListStyle, - FDE_CSSPROPERTY_BackgroundPosition, - FDE_CSSPROPERTY_BorderWidth, - FDE_CSSPROPERTY_TextEmphasisColor, - FDE_CSSPROPERTY_BorderLeftStyle, - FDE_CSSPROPERTY_PageBreakInside, - FDE_CSSPROPERTY_TextEmphasis, - FDE_CSSPROPERTY_BorderBottomWidth, - FDE_CSSPROPERTY_ColumnGap, - FDE_CSSPROPERTY_Orphans, - FDE_CSSPROPERTY_BorderRight, - FDE_CSSPROPERTY_FontSize, - FDE_CSSPROPERTY_PageBreakAfter, - FDE_CSSPROPERTY_CaptionSide, - FDE_CSSPROPERTY_BackgroundRepeat, - FDE_CSSPROPERTY_BorderTopStyle, - FDE_CSSPROPERTY_BorderSpacing, - FDE_CSSPROPERTY_TextTransform, - FDE_CSSPROPERTY_FontStyle, - FDE_CSSPROPERTY_Font, - FDE_CSSPROPERTY_LineHeight, - FDE_CSSPROPERTY_MarginRight, - FDE_CSSPROPERTY_Float, - FDE_CSSPROPERTY_BorderLeftWidth, - FDE_CSSPROPERTY_Display, - FDE_CSSPROPERTY_Clear, - FDE_CSSPROPERTY_ColumnRuleStyle, - FDE_CSSPROPERTY_TextCombine, - FDE_CSSPROPERTY_ListStylePosition, - FDE_CSSPROPERTY_Visibility, - FDE_CSSPROPERTY_PaddingBottom, - FDE_CSSPROPERTY_BackgroundAttachment, - FDE_CSSPROPERTY_BackgroundImage, - FDE_CSSPROPERTY_LineBreak, - FDE_CSSPROPERTY_Background, - FDE_CSSPROPERTY_BorderTopWidth, - FDE_CSSPROPERTY_WordSpacing, - FDE_CSSPROPERTY_BorderRightColor, - FDE_CSSPROPERTY_CounterIncrement, - FDE_CSSPROPERTY_Left, - FDE_CSSPROPERTY_TextDecoration, - FDE_CSSPROPERTY_Padding, - FDE_CSSPROPERTY_MarginBottom, - FDE_CSSPROPERTY_MarginTop, - 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, - FDE_CSSPERSUDO_NONE -}; -enum FDE_CSSSELECTORTYPE { - FDE_CSSSELECTORTYPE_Element, - FDE_CSSSELECTORTYPE_Descendant, - FDE_CSSSELECTORTYPE_Class, - FDE_CSSSELECTORTYPE_Persudo, - FDE_CSSSELECTORTYPE_ID, -}; -class IFDE_CSSSelector { - public: - virtual ~IFDE_CSSSelector() {} - virtual FDE_CSSSELECTORTYPE GetType() const = 0; - virtual FX_DWORD 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 FX_DWORD 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, - FX_WORD wCodePage, - FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL); - static IFDE_CSSStyleSheet* LoadFromBuffer( - const CFX_WideString& szUrl, - const FX_WCHAR* pBuffer, - int32_t iBufSize, - FX_WORD wCodePage, - FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL); - virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0; - virtual FX_DWORD GetMediaList() const = 0; - virtual FX_WORD GetCodePage() const = 0; - - virtual int32_t CountRules() const = 0; - virtual IFDE_CSSRule* GetRule(int32_t index) = 0; -}; -typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray; -#define FDE_CSSUSERSTYLESHEET (FX_BSTRC("#USERSHEET")) -#define FDE_CSSUAGENTSTYLESHEET (FX_BSTRC("#AGENTSHEET")) -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, - FDE_CSSSYNTAXSTATUS_None, - FDE_CSSSYNTAXSTATUS_Charset, - FDE_CSSSYNTAXSTATUS_ImportRule, - FDE_CSSSYNTAXSTATUS_ImportClose, - FDE_CSSSYNTAXSTATUS_PageRule, - FDE_CSSSYNTAXSTATUS_StyleRule, - FDE_CSSSYNTAXSTATUS_FontFaceRule, - FDE_CSSSYNTAXSTATUS_MediaRule, - FDE_CSSSYNTAXSTATUS_MediaType, - FDE_CSSSYNTAXSTATUS_URI, - FDE_CSSSYNTAXSTATUS_Selector, - FDE_CSSSYNTAXSTATUS_DeclOpen, - FDE_CSSSYNTAXSTATUS_DeclClose, - 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, - FDE_CSSLENGTHUNIT_Normal, - 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, - FDE_CSSBORDERSTYLE_Dotted, - FDE_CSSBORDERSTYLE_Dashed, - FDE_CSSBORDERSTYLE_Solid, - FDE_CSSBORDERSTYLE_Double, - FDE_CSSBORDERSTYLE_Groove, - FDE_CSSBORDERSTYLE_Ridge, - 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, - FDE_CSSDISPLAY_RunIn, - FDE_CSSDISPLAY_Block, - FDE_CSSDISPLAY_Inline, - FDE_CSSDISPLAY_InlineBlock, - FDE_CSSDISPLAY_InlineTable, - FDE_CSSDISPLAY_Table, - FDE_CSSDISPLAY_TableRow, - FDE_CSSDISPLAY_TableCell, - FDE_CSSDISPLAY_TableCaption, - FDE_CSSDISPLAY_TableColumn, - FDE_CSSDISPLAY_TableRowGroup, - FDE_CSSDISPLAY_TableColumnGroup, - FDE_CSSDISPLAY_TableHeaderGroup, - FDE_CSSDISPLAY_TableFooterGroup, - FDE_CSSDISPLAY_Ruby, - FDE_CSSDISPLAY_RubyBase, - FDE_CSSDISPLAY_RubyText, - 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, - FDE_CSSPAGEBREAK_Avoid, - FDE_CSSPAGEBREAK_Left, - FDE_CSSPAGEBREAK_Right, -}; -enum FDE_CSSOVERFLOW { - FDE_CSSOVERFLOW_Visible, - FDE_CSSOVERFLOW_Hidden, - FDE_CSSOVERFLOW_Scroll, - FDE_CSSOVERFLOW_Auto, - 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, - FDE_CSSTEXTEMPHASISMARK_Dot, - FDE_CSSTEXTEMPHASISMARK_Circle, - FDE_CSSTEXTEMPHASISMARK_DoubleCircle, - FDE_CSSTEXTEMPHASISMARK_Triangle, - FDE_CSSTEXTEMPHASISMARK_Sesame, - FDE_CSSTEXTEMPHASISMARK_Custom, -}; -enum FDE_CSSTEXTCOMBINE { - FDE_CSSTEXTCOMBINE_Horizontal, - FDE_CSSTEXTCOMBINE_None, -}; -enum FDE_CSSCURSOR { - FDE_CSSCURSOR_Auto, - FDE_CSSCURSOR_Crosshair, - FDE_CSSCURSOR_Default, - FDE_CSSCURSOR_Pointer, - FDE_CSSCURSOR_Move, - FDE_CSSCURSOR_EResize, - FDE_CSSCURSOR_NeResize, - FDE_CSSCURSOR_NwResize, - FDE_CSSCURSOR_NResize, - FDE_CSSCURSOR_SeResize, - FDE_CSSCURSOR_SwResize, - FDE_CSSCURSOR_SResize, - FDE_CSSCURSOR_WResize, - FDE_CSSCURSOR_Text, - FDE_CSSCURSOR_Wait, - 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, - FDE_CSSCAPTIONSIDE_Left, - FDE_CSSCAPTIONSIDE_Right, - FDE_CSSCAPTIONSIDE_Before, - FDE_CSSCAPTIONSIDE_After, -}; -enum FDE_CSSRUBYALIGN { - FDE_CSSRUBYALIGN_Auto, - FDE_CSSRUBYALIGN_Start, - FDE_CSSRUBYALIGN_Left, - FDE_CSSRUBYALIGN_Center, - FDE_CSSRUBYALIGN_End, - FDE_CSSRUBYALIGN_Right, - FDE_CSSRUBYALIGN_DistributeLetter, - 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, - FDE_CSSTEXTALIGN_Center, - FDE_CSSTEXTALIGN_Justify, - FDE_CSSTEXTALIGN_JustifyAll, -}; -enum FDE_CSSVERTICALALIGN { - FDE_CSSVERTICALALIGN_Baseline, - FDE_CSSVERTICALALIGN_Sub, - FDE_CSSVERTICALALIGN_Super, - FDE_CSSVERTICALALIGN_Top, - FDE_CSSVERTICALALIGN_TextTop, - FDE_CSSVERTICALALIGN_Middle, - FDE_CSSVERTICALALIGN_Bottom, - FDE_CSSVERTICALALIGN_TextBottom, - FDE_CSSVERTICALALIGN_Number, -}; -enum FDE_CSSLISTSTYLETYPE { - FDE_CSSLISTSTYLETYPE_Disc, - FDE_CSSLISTSTYLETYPE_Circle, - FDE_CSSLISTSTYLETYPE_Square, - FDE_CSSLISTSTYLETYPE_Decimal, - FDE_CSSLISTSTYLETYPE_DecimalLeadingZero, - FDE_CSSLISTSTYLETYPE_LowerRoman, - FDE_CSSLISTSTYLETYPE_UpperRoman, - FDE_CSSLISTSTYLETYPE_LowerGreek, - FDE_CSSLISTSTYLETYPE_LowerLatin, - FDE_CSSLISTSTYLETYPE_UpperLatin, - FDE_CSSLISTSTYLETYPE_Armenian, - FDE_CSSLISTSTYLETYPE_Georgian, - FDE_CSSLISTSTYLETYPE_LowerAlpha, - FDE_CSSLISTSTYLETYPE_UpperAlpha, - FDE_CSSLISTSTYLETYPE_None, - FDE_CSSLISTSTYLETYPE_CjkIdeographic, - FDE_CSSLISTSTYLETYPE_Hebrew, - FDE_CSSLISTSTYLETYPE_Hiragana, - FDE_CSSLISTSTYLETYPE_HiraganaIroha, - FDE_CSSLISTSTYLETYPE_Katakana, - FDE_CSSLISTSTYLETYPE_KatakanaIroha, -}; -enum FDE_CSSLISTSTYLEPOSITION { - FDE_CSSLISTSTYLEPOSITION_Outside, - FDE_CSSLISTSTYLEPOSITION_Inside, -}; -enum FDE_CSSWHITESPACE { - FDE_CSSWHITESPACE_Normal, - FDE_CSSWHITESPACE_Pre, - FDE_CSSWHITESPACE_Nowrap, - 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, - FDE_CSSTEXTDECORATION_Overline = 2, - FDE_CSSTEXTDECORATION_LineThrough = 4, - FDE_CSSTEXTDECORATION_Blink = 8, - FDE_CSSTEXTDECORATION_Double = 16, -}; -class IFDE_CSSRubyStyle { - 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; -}; -class IFDE_CSSMultiColumnStyle { - 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; -}; -class IFDE_CSSGeneratedContentStyle { - 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; -}; -class IFDE_CSSFontStyle { - public: - virtual ~IFDE_CSSFontStyle() {} - virtual int32_t CountFontFamilies() const = 0; - virtual const FX_WCHAR* GetFontFamily(int32_t index) const = 0; - virtual FX_WORD GetFontWeight() const = 0; - virtual FDE_CSSFONTVARIANT GetFontVariant() const = 0; - virtual FDE_CSSFONTSTYLE GetFontStyle() const = 0; - virtual FX_FLOAT GetFontSize() const = 0; - virtual FX_ARGB GetColor() const = 0; - virtual void SetFontWeight(FX_WORD wFontWeight) = 0; - virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) = 0; - virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) = 0; - 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 FX_DWORD 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(FX_DWORD 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 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(FX_DWORD 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_SRC_FDE_CSS_FDE_CSS_H_ diff --git a/xfa/src/fde/css/fde_csscache.cpp b/xfa/src/fde/css/fde_csscache.cpp deleted file mode 100644 index 012585bfd0..0000000000 --- a/xfa/src/fde/css/fde_csscache.cpp +++ /dev/null @@ -1,149 +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/src/fde/css/fde_csscache.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_ext.h" - -FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p) - : pStylesheet(p), dwActivity(0) { - FXSYS_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) - : 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.GetPtr(), wsName.GetLength(), TRUE); - FX_POSITION pos = pTag->GetFirstAttribute(); - while (pos != NULL) { - pTag->GetNextAttribute(pos, wsName, wsValue); - FX_DWORD dwNameHash = - FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); - static const FX_DWORD s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE); - static const FX_DWORD s_dwClassHash = - FX_HashCode_String_GetW(L"class", 5, TRUE); - if (dwNameHash == s_dwClassHash) { - FX_DWORD dwHash = - FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); - dwClassHashs.Add(dwHash); - } else if (dwNameHash == s_dwIDHash) { - dwIDHash = FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); - } - } -} -FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) - : pTag(it.pTag), - pParent(it.pParent), - dwIDHash(it.dwIDHash), - dwTagHash(it.dwTagHash), - iClassIndex(0), - dwClassHashs(1) { - if (it.dwClassHashs.GetSize() > 0) { - dwClassHashs.Copy(it.dwClassHashs); - } -} -void CFDE_CSSAccelerator::OnEnterTag(IFDE_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); - m_Stack.Pop(); -} diff --git a/xfa/src/fde/css/fde_csscache.h b/xfa/src/fde/css/fde_csscache.h deleted file mode 100644 index e10bea77f5..0000000000 --- a/xfa/src/fde/css/fde_csscache.h +++ /dev/null @@ -1,85 +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_SRC_FDE_CSS_FDE_CSSCACHE_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSCACHE_H_ - -#include <map> - -#include "xfa/src/fde/css/fde_css.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -class FDE_CSSCacheItem : public CFX_Target { - public: - explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); - ~FDE_CSSCacheItem(); - - IFDE_CSSStyleSheet* pStylesheet; - FX_DWORD 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(const FDE_CSSTagCache& it); - FDE_CSSTagCache* GetParent() const { return pParent; } - IFDE_CSSTagProvider* GetTag() const { return pTag; } - FX_DWORD HashID() const { return dwIDHash; } - FX_DWORD HashTag() const { return dwTagHash; } - int32_t CountHashClass() const { return dwClassHashs.GetSize(); } - void SetClassIndex(int32_t index) { iClassIndex = index; } - FX_DWORD HashClass() const { - return iClassIndex < dwClassHashs.GetSize() - ? dwClassHashs.GetAt(iClassIndex) - : 0; - } - - protected: - IFDE_CSSTagProvider* pTag; - FDE_CSSTagCache* pParent; - FX_DWORD dwIDHash; - FX_DWORD dwTagHash; - int32_t iClassIndex; - CFDE_DWordArray dwClassHashs; -}; -typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack; - -class CFDE_CSSAccelerator : public IFDE_CSSAccelerator, public CFX_Target { - public: - virtual void OnEnterTag(IFDE_CSSTagProvider* pTag); - virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag); - void Clear() { m_Stack.RemoveAll(); } - FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); } - - protected: - CFDE_CSSTagStack m_Stack; -}; - -#endif // XFA_SRC_FDE_CSS_FDE_CSSCACHE_H_ diff --git a/xfa/src/fde/css/fde_cssdatatable.cpp b/xfa/src/fde/css/fde_cssdatatable.cpp deleted file mode 100644 index 5ad83e7b25..0000000000 --- a/xfa/src/fde/css/fde_cssdatatable.cpp +++ /dev/null @@ -1,889 +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/src/fde/css/fde_cssdatatable.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/crt/fgas_algorithm.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fgas/crt/fgas_system.h" - -FX_BOOL FDE_CSSLengthToFloat(const FDE_CSSLENGTH& len, - FX_FLOAT fPercentBase, - FX_FLOAT& fResult) { - switch (len.GetUnit()) { - case FDE_CSSLENGTHUNIT_Point: - fResult = len.GetValue(); - return TRUE; - case FDE_CSSLENGTHUNIT_Percent: - fResult = len.GetValue() * fPercentBase; - return TRUE; - default: - return FALSE; - } -} -CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle, - FX_FLOAT fContainerWidth, - FX_BOOL bPadding, - FX_BOOL bBorder, - FX_BOOL bMargin) { - FXSYS_assert(pBoundStyle != NULL); - FX_FLOAT fResult; - const FDE_CSSRECT* pRect; - CFX_FloatRect rect(0, 0, 0, 0); - if (bPadding) { - pRect = pBoundStyle->GetPaddingWidth(); - if (pRect != NULL) { - if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { - rect.left += fResult; - } - if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { - rect.top += fResult; - } - if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { - rect.right += fResult; - } - if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { - rect.bottom += fResult; - } - } - } - if (bBorder) { - pRect = pBoundStyle->GetBorderWidth(); - if (pRect != NULL) { - if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { - rect.left += fResult; - } - if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { - rect.top += fResult; - } - if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { - rect.right += fResult; - } - if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { - rect.bottom += fResult; - } - } - } - if (bMargin) { - pRect = pBoundStyle->GetMarginWidth(); - if (pRect != NULL) { - if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) { - rect.left += fResult; - } - if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) { - rect.top += fResult; - } - if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) { - rect.right += fResult; - } - if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) { - rect.bottom += fResult; - } - } - } - return rect; -} -FX_DWORD FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle* pFontStyle) { - FXSYS_assert(pFontStyle != NULL); - FX_DWORD dwFontStyle = FX_FONTSTYLE_Normal; - if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) { - dwFontStyle |= FX_FONTSTYLE_Italic; - } - if (pFontStyle->GetFontWeight() >= 700) { - dwFontStyle |= FX_FONTSTYLE_Bold; - } - return dwFontStyle; -} -static const FDE_CSSPROPERTYTABLE g_FDE_CSSProperties[] = { - {FDE_CSSPROPERTY_WritingMode, L"writing-mode", 0x01878076, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_ColumnRuleWidth, L"column-rule-width", 0x0200FB00, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderLeft, L"border-left", 0x04080036, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_ColumnRule, L"column-rule", 0x04C83DF3, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_Height, L"height", 0x05A5C519, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_CounterReset, L"counter-reset", 0x0894F9B0, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_Content, L"content", 0x097BE91B, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeURI | FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_RubyPosition, L"ruby-position", 0x09ACD024, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BackgroundColor, L"background-color", 0x09E8E8AC, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_Width, L"width", 0x0A8A8F80, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Src, L"src", 0x0BD37048, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeURI}, - {FDE_CSSPROPERTY_Top, L"top", 0x0BEDAF33, FDE_CSSVALUETYPE_Primitive | - FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Margin, L"margin", 0x0CB016BE, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderColor, L"border-color", 0x0CBB528A, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_Widows, L"widows", 0x1026C59D, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderBottomColor, L"border-bottom-color", 0x121E22EC, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_TextIndent, L"text-indent", 0x169ADB74, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Right, L"right", 0x193ADE3E, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_TextEmphasisStyle, L"text-emphasis-style", 0x20DBAF4A, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_PaddingLeft, L"padding-left", 0x228CF02F, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_ColumnWidth, L"column-width", 0x24C9AC9B, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_MarginLeft, L"margin-left", 0x297C5656, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | - FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Border, L"border", 0x2A23349E, FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_BorderTop, L"border-top", 0x2B866ADE, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_RubyOverhang, L"ruby-overhang", 0x2CCA0D89, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_PageBreakBefore, L"page-break-before", 0x3119B36F, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_MaxHeight, L"max-height", 0x343597EC, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_MinWidth, L"min-width", 0x35832871, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderLeftColor, L"border-left-color", 0x35C64022, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_Bottom, L"bottom", 0x399F02B5, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Quotes, L"quotes", 0x3D8C6A01, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_MaxWidth, L"max-width", 0x3EA274F3, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_PaddingRight, L"padding-right", 0x3F616AC2, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_ListStyleImage, L"list-style-image", 0x42A8A86A, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeURI}, - {FDE_CSSPROPERTY_WhiteSpace, L"white-space", 0x42F0429A, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderBottom, L"border-bottom", 0x452CE780, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_ListStyleType, L"list-style-type", 0x48094789, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_WordBreak, L"word-break", 0x4D74A3CE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_OverflowX, L"overflow-x", 0x4ECEBF99, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_OverflowY, L"overflow-y", 0x4ECEBF9A, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderTopColor, L"border-top-color", 0x5109B8CA, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_FontFamily, L"font-family", 0x574686E6, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_Cursor, L"cursor", 0x59DFCA5E, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_RubyAlign, L"ruby-align", 0x6077BDFA, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_ColumnRuleColor, L"column-rule-color", 0x65DDFD9F, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_FontWeight, L"font-weight", 0x6692F60C, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderRightStyle, L"border-right-style", 0x6920DDA7, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_MinHeight, L"min-height", 0x6AAE312A, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Color, L"color", 0x6E67921F, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_LetterSpacing, L"letter-spacing", 0x70536102, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_EmptyCells, L"empty-cells", 0x7531528F, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_TextAlign, L"text-align", 0x7553F1BD, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_RubySpan, L"ruby-span", 0x76FCFCE1, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeFunction}, - {FDE_CSSPROPERTY_Position, L"position", 0x814F82B5, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderStyle, L"border-style", 0x82A4CD5C, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderBottomStyle, L"border-bottom-style", 0x88079DBE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderCollapse, L"border-collapse", 0x8883C7FE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_ColumnCount, L"column-count", 0x89936A64, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderRightWidth, L"border-right-width", 0x8F5A6036, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_UnicodeBidi, L"unicode-bidi", 0x91670F6C, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_VerticalAlign, L"vertical-align", 0x934A87D2, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_PaddingTop, L"padding-top", 0x959D22B7, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Columns, L"columns", 0x96FA5D81, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_Overflow, L"overflow", 0x97B76B54, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_TableLayout, L"table-layout", 0x9B1CB4B3, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_FontVariant, L"font-variant", 0x9C785779, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_ListStyle, L"list-style", 0x9E6C471A, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_BackgroundPosition, L"background-position", 0xA8846D22, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderWidth, L"border-width", 0xA8DE4FEB, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_TextEmphasisColor, L"text-emphasis-color", 0xAAF23478, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_BorderLeftStyle, L"border-left-style", 0xABAFBAF4, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_PageBreakInside, L"page-break-inside", 0xACB695F8, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_TextEmphasis, L"text-emphasis", 0xAD0E580C, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_BorderBottomWidth, L"border-bottom-width", 0xAE41204D, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_ColumnGap, L"column-gap", 0xB5C1BA73, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Orphans, L"orphans", 0xB716467B, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderRight, L"border-right", 0xB78E9EA9, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_FontSize, L"font-size", 0xB93956DF, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_PageBreakAfter, L"page-break-after", 0xBC358AEE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_CaptionSide, L"caption-side", 0xC03F3560, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BackgroundRepeat, L"background-repeat", 0xC2C2FDCE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderTopStyle, L"border-top-style", 0xC6F3339C, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderSpacing, L"border-spacing", 0xC72030F0, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_TextTransform, L"text-transform", 0xC88EEA6E, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_FontStyle, L"font-style", 0xCB1950F5, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Font, L"font", 0xCD308B77, FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_LineHeight, L"line-height", 0xCFCACE2E, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_MarginRight, L"margin-right", 0xD13C58C9, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | - FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Float, L"float", 0xD1532876, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BorderLeftWidth, L"border-left-width", 0xD1E93D83, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_Display, L"display", 0xD4224C36, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Clear, L"clear", 0xD8ED1467, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_ColumnRuleStyle, L"column-rule-style", 0xDBC77871, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_TextCombine, L"text-combine", 0xDC5207CF, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_ListStylePosition, L"list-style-position", 0xE1A1DE3C, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Visibility, L"visibility", 0xE29F5168, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_PaddingBottom, L"padding-bottom", 0xE555B3B9, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BackgroundAttachment, L"background-attachment", 0xE77981F6, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_BackgroundImage, L"background-image", 0xE9AEB710, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeURI}, - {FDE_CSSPROPERTY_LineBreak, L"line-break", 0xEA2D1D9A, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Background, L"background", 0xEB49DD40, - FDE_CSSVALUETYPE_Shorthand}, - {FDE_CSSPROPERTY_BorderTopWidth, L"border-top-width", 0xED2CB62B, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_WordSpacing, L"word-spacing", 0xEDA63BAE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_BorderRightColor, L"border-right-color", 0xF33762D5, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeColor}, - {FDE_CSSPROPERTY_CounterIncrement, L"counter-increment", 0xF4CFB1B2, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString}, - {FDE_CSSPROPERTY_Left, L"left", 0xF5AD782B, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum | - FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_TextDecoration, L"text-decoration", 0xF7C634BA, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Padding, L"padding", 0xF8C373F7, - FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber}, - {FDE_CSSPROPERTY_MarginBottom, L"margin-bottom", 0xF93485A0, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | - FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_MarginTop, L"margin-top", 0xFE51DCFE, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber | - FDE_CSSVALUETYPE_MaybeEnum}, - {FDE_CSSPROPERTY_Direction, L"direction", 0xFE746E61, - FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum}, -}; -static const FDE_CSSPROPERTYVALUETABLE g_FDE_CSSPropertyValues[] = { - {FDE_CSSPROPERTYVALUE_Bolder, L"bolder", 0x009F1058}, - {FDE_CSSPROPERTYVALUE_LowerLatin, L"lower-latin", 0x016014CE}, - {FDE_CSSPROPERTYVALUE_Lowercase, L"lowercase", 0x02ACB805}, - {FDE_CSSPROPERTYVALUE_LowerGreek, L"lower-greek", 0x03D81D64}, - {FDE_CSSPROPERTYVALUE_Sesame, L"sesame", 0x0432ECDE}, - {FDE_CSSPROPERTYVALUE_None, L"none", 0x048B6670}, - {FDE_CSSPROPERTYVALUE_NwResize, L"nw-resize", 0x054B4BE4}, - {FDE_CSSPROPERTYVALUE_WResize, L"w-resize", 0x0A2F8D76}, - {FDE_CSSPROPERTYVALUE_Dot, L"dot", 0x0A48CB27}, - {FDE_CSSPROPERTYVALUE_End, L"end", 0x0A631437}, - {FDE_CSSPROPERTYVALUE_Ltr, L"ltr", 0x0B1B56D2}, - {FDE_CSSPROPERTYVALUE_Pre, L"pre", 0x0B848587}, - {FDE_CSSPROPERTYVALUE_Rtl, L"rtl", 0x0BB92C52}, - {FDE_CSSPROPERTYVALUE_Sub, L"sub", 0x0BD37FAA}, - {FDE_CSSPROPERTYVALUE_Top, L"top", 0x0BEDAF33}, - {FDE_CSSPROPERTYVALUE_Visible, L"visible", 0x0F55D7EE}, - {FDE_CSSPROPERTYVALUE_Filled, L"filled", 0x10827DD0}, - {FDE_CSSPROPERTYVALUE_SwResize, L"sw-resize", 0x10B548E9}, - {FDE_CSSPROPERTYVALUE_NoRepeat, L"no-repeat", 0x1235C18B}, - {FDE_CSSPROPERTYVALUE_Default, L"default", 0x14DA2125}, - {FDE_CSSPROPERTYVALUE_Transparent, L"transparent", 0x17B64DB2}, - {FDE_CSSPROPERTYVALUE_Ridge, L"ridge", 0x18EBEE4B}, - {FDE_CSSPROPERTYVALUE_Right, L"right", 0x193ADE3E}, - {FDE_CSSPROPERTYVALUE_HorizontalTb, L"horizontal-tb", 0x1A66A86D}, - {FDE_CSSPROPERTYVALUE_DistributeLetter, L"distribute-letter", 0x1EDBD75C}, - {FDE_CSSPROPERTYVALUE_DoubleCircle, L"double-circle", 0x1FF082BA}, - {FDE_CSSPROPERTYVALUE_Ruby, L"ruby", 0x20D66C02}, - {FDE_CSSPROPERTYVALUE_Collapse, L"collapse", 0x2128D673}, - {FDE_CSSPROPERTYVALUE_Normal, L"normal", 0x247CF3E9}, - {FDE_CSSPROPERTYVALUE_Avoid, L"avoid", 0x24E684B3}, - {FDE_CSSPROPERTYVALUE_UpperRoman, L"upper-roman", 0x28BAC2B6}, - {FDE_CSSPROPERTYVALUE_Auto, L"auto", 0x2B35B6D9}, - {FDE_CSSPROPERTYVALUE_Text, L"text", 0x2D08AF85}, - {FDE_CSSPROPERTYVALUE_XSmall, L"x-small", 0x2D2FCAFE}, - {FDE_CSSPROPERTYVALUE_Thin, L"thin", 0x2D574D53}, - {FDE_CSSPROPERTYVALUE_Repeat, L"repeat", 0x306614A1}, - {FDE_CSSPROPERTYVALUE_Small, L"small", 0x316A3739}, - {FDE_CSSPROPERTYVALUE_NeResize, L"ne-resize", 0x31FD5E12}, - {FDE_CSSPROPERTYVALUE_NoContent, L"no-content", 0x33A1C545}, - {FDE_CSSPROPERTYVALUE_Outside, L"outside", 0x36DF693D}, - {FDE_CSSPROPERTYVALUE_EResize, L"e-resize", 0x36E19FA4}, - {FDE_CSSPROPERTYVALUE_TableRow, L"table-row", 0x3912A02D}, - {FDE_CSSPROPERTYVALUE_Bottom, L"bottom", 0x399F02B5}, - {FDE_CSSPROPERTYVALUE_Underline, L"underline", 0x3A0273A6}, - {FDE_CSSPROPERTYVALUE_CjkIdeographic, L"cjk-ideographic", 0x3A641CC4}, - {FDE_CSSPROPERTYVALUE_SeResize, L"se-resize", 0x3D675B17}, - {FDE_CSSPROPERTYVALUE_Fixed, L"fixed", 0x3D7DEB10}, - {FDE_CSSPROPERTYVALUE_Double, L"double", 0x3D98515B}, - {FDE_CSSPROPERTYVALUE_Solid, L"solid", 0x40623B5B}, - {FDE_CSSPROPERTYVALUE_RubyBaseGroup, L"ruby-base-group", 0x41014E84}, - {FDE_CSSPROPERTYVALUE_OpenQuote, L"open-quote", 0x44A41E8D}, - {FDE_CSSPROPERTYVALUE_Lighter, L"lighter", 0x45BEB7AF}, - {FDE_CSSPROPERTYVALUE_LowerRoman, L"lower-roman", 0x5044D253}, - {FDE_CSSPROPERTYVALUE_Strict, L"strict", 0x52F4EBD9}, - {FDE_CSSPROPERTYVALUE_TableCaption, L"table-caption", 0x5325CD63}, - {FDE_CSSPROPERTYVALUE_Oblique, L"oblique", 0x53EBDDB1}, - {FDE_CSSPROPERTYVALUE_Decimal, L"decimal", 0x54034C2F}, - {FDE_CSSPROPERTYVALUE_Loose, L"loose", 0x54D3A1E2}, - {FDE_CSSPROPERTYVALUE_Hebrew, L"hebrew", 0x565792DD}, - {FDE_CSSPROPERTYVALUE_Hidden, L"hidden", 0x573CB40C}, - {FDE_CSSPROPERTYVALUE_Dashed, L"dashed", 0x58A3DD29}, - {FDE_CSSPROPERTYVALUE_Embed, L"embed", 0x59C8F27D}, - {FDE_CSSPROPERTYVALUE_TableRowGroup, L"table-row-group", 0x5A43BD07}, - {FDE_CSSPROPERTYVALUE_TableColumn, L"table-column", 0x5E705DA3}, - {FDE_CSSPROPERTYVALUE_Static, L"static", 0x5E7555E8}, - {FDE_CSSPROPERTYVALUE_Outset, L"outset", 0x61236164}, - {FDE_CSSPROPERTYVALUE_DecimalLeadingZero, L"decimal-leading-zero", - 0x61DFC55D}, - {FDE_CSSPROPERTYVALUE_KeepWords, L"keep-words", 0x63964801}, - {FDE_CSSPROPERTYVALUE_KatakanaIroha, L"katakana-iroha", 0x65D7C91C}, - {FDE_CSSPROPERTYVALUE_Super, L"super", 0x6A4F842F}, - {FDE_CSSPROPERTYVALUE_Center, L"center", 0x6C51AFC1}, - {FDE_CSSPROPERTYVALUE_TableHeaderGroup, L"table-header-group", 0x706103D8}, - {FDE_CSSPROPERTYVALUE_Inside, L"inside", 0x709CB0FC}, - {FDE_CSSPROPERTYVALUE_XxLarge, L"xx-large", 0x70BB1508}, - {FDE_CSSPROPERTYVALUE_Triangle, L"triangle", 0x7524EDF6}, - {FDE_CSSPROPERTYVALUE_RubyTextGroup, L"ruby-text-group", 0x78C2B98E}, - {FDE_CSSPROPERTYVALUE_Circle, L"circle", 0x7ABEC0D2}, - {FDE_CSSPROPERTYVALUE_Hiragana, L"hiragana", 0x7BF5E25B}, - {FDE_CSSPROPERTYVALUE_RepeatX, L"repeat-x", 0x7C8F3226}, - {FDE_CSSPROPERTYVALUE_RepeatY, L"repeat-y", 0x7C8F3227}, - {FDE_CSSPROPERTYVALUE_Move, L"move", 0x7DA03417}, - {FDE_CSSPROPERTYVALUE_HiraganaIroha, L"hiragana-iroha", 0x7EE863FB}, - {FDE_CSSPROPERTYVALUE_RubyBase, L"ruby-base", 0x7FD1B1EA}, - {FDE_CSSPROPERTYVALUE_Scroll, L"scroll", 0x84787AEF}, - {FDE_CSSPROPERTYVALUE_Smaller, L"smaller", 0x849769F0}, - {FDE_CSSPROPERTYVALUE_TableFooterGroup, L"table-footer-group", 0x85BDD97E}, - {FDE_CSSPROPERTYVALUE_Baseline, L"baseline", 0x87436BA3}, - {FDE_CSSPROPERTYVALUE_Separate, L"separate", 0x877C66B5}, - {FDE_CSSPROPERTYVALUE_Armenian, L"armenian", 0x889BE4EB}, - {FDE_CSSPROPERTYVALUE_Open, L"open", 0x8B90E1F2}, - {FDE_CSSPROPERTYVALUE_Relative, L"relative", 0x8C995B5C}, - {FDE_CSSPROPERTYVALUE_Thick, L"thick", 0x8CC35EB3}, - {FDE_CSSPROPERTYVALUE_Justify, L"justify", 0x8D269CAE}, - {FDE_CSSPROPERTYVALUE_Middle, L"middle", 0x947FA00F}, - {FDE_CSSPROPERTYVALUE_Always, L"always", 0x959AB231}, - {FDE_CSSPROPERTYVALUE_DistributeSpace, L"distribute-space", 0x97A20E58}, - {FDE_CSSPROPERTYVALUE_LineEdge, L"line-edge", 0x9A845D2A}, - {FDE_CSSPROPERTYVALUE_PreWrap, L"pre-wrap", 0x9D59588E}, - {FDE_CSSPROPERTYVALUE_Medium, L"medium", 0xA084A381}, - {FDE_CSSPROPERTYVALUE_NResize, L"n-resize", 0xA088968D}, - {FDE_CSSPROPERTYVALUE_ListItem, L"list-item", 0xA32382B8}, - {FDE_CSSPROPERTYVALUE_Show, L"show", 0xA66C10C1}, - {FDE_CSSPROPERTYVALUE_Currentcolor, L"currentColor", 0xA7883922}, - {FDE_CSSPROPERTYVALUE_NoCloseQuote, L"no-close-quote", 0xA79CBFFB}, - {FDE_CSSPROPERTYVALUE_VerticalLr, L"vertical-lr", 0xA8673F65}, - {FDE_CSSPROPERTYVALUE_VerticalRl, L"vertical-rl", 0xA8675E25}, - {FDE_CSSPROPERTYVALUE_Pointer, L"pointer", 0xA90929C1}, - {FDE_CSSPROPERTYVALUE_XxSmall, L"xx-small", 0xADE1FC76}, - {FDE_CSSPROPERTYVALUE_Bold, L"bold", 0xB18313A1}, - {FDE_CSSPROPERTYVALUE_Both, L"both", 0xB1833CAD}, - {FDE_CSSPROPERTYVALUE_SmallCaps, L"small-caps", 0xB299428D}, - {FDE_CSSPROPERTYVALUE_Katakana, L"katakana", 0xB421A4BC}, - {FDE_CSSPROPERTYVALUE_After, L"after", 0xB6B44172}, - {FDE_CSSPROPERTYVALUE_Horizontal, L"horizontal", 0xB7732DEA}, - {FDE_CSSPROPERTYVALUE_Dotted, L"dotted", 0xB88652A4}, - {FDE_CSSPROPERTYVALUE_Disc, L"disc", 0xBEBC18C3}, - {FDE_CSSPROPERTYVALUE_Georgian, L"georgian", 0xBEF99E8C}, - {FDE_CSSPROPERTYVALUE_Inline, L"inline", 0xC02D649F}, - {FDE_CSSPROPERTYVALUE_Overline, L"overline", 0xC0EC9FA4}, - {FDE_CSSPROPERTYVALUE_Wait, L"wait", 0xC1613BB5}, - {FDE_CSSPROPERTYVALUE_BreakAll, L"break-all", 0xC3145BAB}, - {FDE_CSSPROPERTYVALUE_UpperAlpha, L"upper-alpha", 0xC52D4A9F}, - {FDE_CSSPROPERTYVALUE_Capitalize, L"capitalize", 0xC5321D46}, - {FDE_CSSPROPERTYVALUE_Nowrap, L"nowrap", 0xC7994417}, - {FDE_CSSPROPERTYVALUE_TextBottom, L"text-bottom", 0xC7D08D87}, - {FDE_CSSPROPERTYVALUE_NoOpenQuote, L"no-open-quote", 0xC8CD7877}, - {FDE_CSSPROPERTYVALUE_Groove, L"groove", 0xCB24A412}, - {FDE_CSSPROPERTYVALUE_Progress, L"progress", 0xCD1D9835}, - {FDE_CSSPROPERTYVALUE_Larger, L"larger", 0xCD3C409D}, - {FDE_CSSPROPERTYVALUE_CloseQuote, L"close-quote", 0xCF8696D1}, - {FDE_CSSPROPERTYVALUE_TableCell, L"table-cell", 0xCFB5E595}, - {FDE_CSSPROPERTYVALUE_PreLine, L"pre-line", 0xD04FEDBC}, - {FDE_CSSPROPERTYVALUE_Absolute, L"absolute", 0xD0B2D55F}, - {FDE_CSSPROPERTYVALUE_InlineTable, L"inline-table", 0xD131F494}, - {FDE_CSSPROPERTYVALUE_BidiOverride, L"bidi-override", 0xD161FDE5}, - {FDE_CSSPROPERTYVALUE_InlineBlock, L"inline-block", 0xD26A8BD7}, - {FDE_CSSPROPERTYVALUE_Inset, L"inset", 0xD6F23243}, - {FDE_CSSPROPERTYVALUE_Crosshair, L"crosshair", 0xD6F8018E}, - {FDE_CSSPROPERTYVALUE_UpperLatin, L"upper-latin", 0xD9D60531}, - {FDE_CSSPROPERTYVALUE_Help, L"help", 0xDA002969}, - {FDE_CSSPROPERTYVALUE_Hide, L"hide", 0xDA69395A}, - {FDE_CSSPROPERTYVALUE_Uppercase, L"uppercase", 0xDAD595A8}, - {FDE_CSSPROPERTYVALUE_SResize, L"s-resize", 0xDB3AADF2}, - {FDE_CSSPROPERTYVALUE_Table, L"table", 0xDB9BE968}, - {FDE_CSSPROPERTYVALUE_Blink, L"blink", 0xDC36E390}, - {FDE_CSSPROPERTYVALUE_Block, L"block", 0xDCD480AB}, - {FDE_CSSPROPERTYVALUE_Start, L"start", 0xE1D9D5AE}, - {FDE_CSSPROPERTYVALUE_TableColumnGroup, L"table-column-group", 0xE2258EFD}, - {FDE_CSSPROPERTYVALUE_Italic, L"italic", 0xE31D5396}, - {FDE_CSSPROPERTYVALUE_LineThrough, L"line-through", 0xE4C5A276}, - {FDE_CSSPROPERTYVALUE_KeepAll, L"keep-all", 0xE704A72B}, - {FDE_CSSPROPERTYVALUE_LowerAlpha, L"lower-alpha", 0xECB75A3C}, - {FDE_CSSPROPERTYVALUE_RunIn, L"run-in", 0xEEC930B9}, - {FDE_CSSPROPERTYVALUE_Square, L"square", 0xEF85D351}, - {FDE_CSSPROPERTYVALUE_XLarge, L"x-large", 0xF008E390}, - {FDE_CSSPROPERTYVALUE_Large, L"large", 0xF4434FCB}, - {FDE_CSSPROPERTYVALUE_Before, L"before", 0xF4FFCE73}, - {FDE_CSSPROPERTYVALUE_Left, L"left", 0xF5AD782B}, - {FDE_CSSPROPERTYVALUE_TextTop, L"text-top", 0xFCB58D45}, - {FDE_CSSPROPERTYVALUE_RubyText, L"ruby-text", 0xFCC77174}, - {FDE_CSSPROPERTYVALUE_NoDisplay, L"no-display", 0xFE482860}, -}; -static const FDE_CSSMEDIATYPETABLE g_FDE_CSSMediaTypes[] = { - {0xF09, 0x02}, {0x4880, 0x20}, {0x536A, 0x80}, - {0x741D, 0x10}, {0x76ED, 0x08}, {0x7CFB, 0x01}, - {0x9578, 0x04}, {0xC8E1, 0x40}, {0xD0F9, 0xFF}, -}; -static const FDE_CSSLENGTHUNITTABLE g_FDE_CSSLengthUnits[] = { - {0x0672, 3}, {0x067D, 4}, {0x1AF7, 8}, {0x2F7A, 7}, - {0x3ED3, 10}, {0x3EE4, 9}, {0x3EE8, 5}, {0xFC30, 6}, -}; -static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = { - {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000}, - {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff}, - {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0}, - {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500}, - {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080}, - {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff}, - {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00}, - {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00}, - {0xF6EFFF31, 0xff008000}, -}; -static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = { - {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC}, - {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D}, -}; -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); - FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); - int32_t iEnd = FDE_CSSPROPERTY_MAX - 1; - int32_t iMid, iStart = 0; - FX_DWORD dwMid; - do { - iMid = (iStart + iEnd) / 2; - dwMid = g_FDE_CSSProperties[iMid].dwHash; - if (dwHash == dwMid) { - return g_FDE_CSSProperties + iMid; - } else if (dwHash > dwMid) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iStart <= iEnd); - return NULL; -} -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); - FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); - int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1; - int32_t iMid, iStart = 0; - FX_DWORD dwMid; - do { - iMid = (iStart + iEnd) / 2; - dwMid = g_FDE_CSSPropertyValues[iMid].dwHash; - if (dwHash == dwMid) { - return g_FDE_CSSPropertyValues + iMid; - } else if (dwHash > dwMid) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iStart <= iEnd); - return NULL; -} -FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( - FDE_CSSPROPERTYVALUE eName) { - 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); - FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE); - int32_t iEnd = - sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1; - int32_t iMid, iStart = 0; - FX_WORD uMid; - do { - iMid = (iStart + iEnd) / 2; - uMid = g_FDE_CSSMediaTypes[iMid].wHash; - if (wHash == uMid) { - return g_FDE_CSSMediaTypes + iMid; - } else if (wHash > uMid) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iStart <= iEnd); - return NULL; -} -FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE); - int32_t iEnd = - sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1; - int32_t iMid, iStart = 0; - FX_WORD wMid; - do { - iMid = (iStart + iEnd) / 2; - wMid = g_FDE_CSSLengthUnits[iMid].wHash; - if (wHash == wMid) { - return g_FDE_CSSLengthUnits + iMid; - } else if (wHash > wMid) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iStart <= iEnd); - return NULL; -} -FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); - int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1; - int32_t iMid, iStart = 0; - FX_DWORD dwMid; - do { - iMid = (iStart + iEnd) / 2; - dwMid = g_FDE_CSSColors[iMid].dwHash; - if (dwHash == dwMid) { - return g_FDE_CSSColors + iMid; - } else if (dwHash > dwMid) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iStart <= iEnd); - return NULL; -} -FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_FLOAT& fValue, - FDE_CSSPRIMITIVETYPE& eUnit) { - FXSYS_assert(pszValue != NULL && iValueLen > 0); - int32_t iUsedLen = 0; - fValue = FX_wcstof(pszValue, iValueLen, &iUsedLen); - if (iUsedLen <= 0) { - return FALSE; - } - iValueLen -= iUsedLen; - pszValue += iUsedLen; - eUnit = FDE_CSSPRIMITIVETYPE_Number; - if (iValueLen >= 1 && *pszValue == '%') { - eUnit = FDE_CSSPRIMITIVETYPE_Percent; - } else if (iValueLen == 2) { - FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2); - if (pUnit != NULL) { - eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue; - } - } - return TRUE; -} - -FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue, - int32_t iValueLen, - int32_t& iOffset, - int32_t& iLength) { - FXSYS_assert(pszValue != NULL && iValueLen > 0); - iOffset = 0; - iLength = iValueLen; - if (iValueLen >= 2) { - FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1]; - if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) { - iOffset = 1, iLength -= 2; - } - } - return iValueLen > 0; -} - -FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue, - int32_t iValueLen, - int32_t& iOffset, - int32_t& iLength) { - FXSYS_assert(pszValue != NULL && iValueLen > 0); - if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' || - FX_wcsnicmp(L"url(", pszValue, 4)) { - return FALSE; - } - if (FDE_ParseCSSString(pszValue + 4, iValueLen - 5, iOffset, iLength)) { - iOffset += 4; - return TRUE; - } - return FALSE; -} - -FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_ARGB& dwColor) { - FXSYS_assert(pszValue != NULL && iValueLen > 0); - if (*pszValue == '#') { - switch (iValueLen) { - case 4: { - uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]); - uint8_t green = FX_Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]); - uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]); - dwColor = ArgbEncode(255, red, green, blue); - } - return TRUE; - case 7: { - uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]); - uint8_t green = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]); - uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]); - dwColor = ArgbEncode(255, red, green, blue); - } - return TRUE; - } - } else if (iValueLen >= 10) { - if (pszValue[iValueLen - 1] != ')' || FX_wcsnicmp(L"rgb(", pszValue, 4)) { - return FALSE; - } - uint8_t rgb[3] = {0}; - FX_FLOAT fValue; - FDE_CSSPRIMITIVETYPE eType; - CFDE_CSSValueListParser list(pszValue + 4, iValueLen - 5, ','); - for (int32_t i = 0; i < 3; ++i) { - if (!list.NextValue(eType, pszValue, iValueLen)) { - return FALSE; - } - if (eType != FDE_CSSPRIMITIVETYPE_Number) { - return FALSE; - } - if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - return FALSE; - } - rgb[i] = eType == FDE_CSSPRIMITIVETYPE_Percent - ? FXSYS_round(fValue * 2.55f) - : FXSYS_round(fValue); - } - dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]); - return TRUE; - } else { - FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen); - if (pColor != NULL) { - dwColor = pColor->dwValue; - return TRUE; - } - } - return FALSE; -} - -CFDE_CSSValueList::CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore, - const CFDE_CSSValueArray& list) { - m_iCount = list.GetSize(); - int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*); - m_ppList = (IFDE_CSSValue**)pStaticStore->Alloc(iByteCount); - FXSYS_memcpy(m_ppList, list.GetData(), iByteCount); -} -FX_BOOL CFDE_CSSValueListParser::NextValue(FDE_CSSPRIMITIVETYPE& eType, - const FX_WCHAR*& pStart, - int32_t& iLength) { - while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator)) { - ++m_pCur; - } - if (m_pCur >= m_pEnd) { - return FALSE; - } - eType = FDE_CSSPRIMITIVETYPE_Unknown; - pStart = m_pCur; - iLength = 0; - FX_WCHAR wch = *m_pCur; - if (wch == '#') { - iLength = SkipTo(' '); - if (iLength == 4 || iLength == 7) { - eType = FDE_CSSPRIMITIVETYPE_RGB; - } - } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' || - wch == '+') { - while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) { - ++m_pCur; - } - iLength = m_pCur - pStart; - if (iLength > 0) { - eType = FDE_CSSPRIMITIVETYPE_Number; - } - } else if (wch == '\"' || wch == '\'') { - pStart++; - iLength = SkipTo(wch) - 1; - m_pCur++; - eType = FDE_CSSPRIMITIVETYPE_String; - } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') { - if (FX_wcsnicmp(L"url", m_pCur, 3) == 0) { - wch = m_pCur[4]; - if (wch == '\"' || wch == '\'') { - pStart += 5; - iLength = SkipTo(wch) - 6; - m_pCur += 2; - } else { - pStart += 4; - iLength = SkipTo(')') - 4; - m_pCur++; - } - eType = FDE_CSSPRIMITIVETYPE_URI; - } else if (FX_wcsnicmp(L"rgb", m_pCur, 3) == 0) { - iLength = SkipTo(')') + 1; - m_pCur++; - eType = FDE_CSSPRIMITIVETYPE_RGB; - } - } else { - iLength = SkipTo(m_Separator, TRUE, TRUE); - eType = FDE_CSSPRIMITIVETYPE_String; - } - return m_pCur <= m_pEnd && iLength > 0; -} -int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch, - FX_BOOL bWSSeparator, - FX_BOOL bBrContinue) { - const FX_WCHAR* pStart = m_pCur; - if (!bBrContinue) { - if (bWSSeparator) { - while ((++m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) { - continue; - } - } else { - while (++m_pCur < m_pEnd && *m_pCur != wch) { - continue; - } - } - - } else { - int32_t iBracketCount = 0; - if (bWSSeparator) { - while ((m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) { - if (*m_pCur == '(') { - iBracketCount++; - } else if (*m_pCur == ')') { - iBracketCount--; - } - m_pCur++; - } - } else { - while (m_pCur < m_pEnd && *m_pCur != wch) { - if (*m_pCur == '(') { - iBracketCount++; - } else if (*m_pCur == ')') { - iBracketCount--; - } - m_pCur++; - } - } - while (iBracketCount > 0 && m_pCur < m_pEnd) { - if (*m_pCur == ')') { - iBracketCount--; - } - m_pCur++; - } - } - return m_pCur - pStart; -} diff --git a/xfa/src/fde/css/fde_cssdatatable.h b/xfa/src/fde/css/fde_cssdatatable.h deleted file mode 100644 index 950b8d358d..0000000000 --- a/xfa/src/fde/css/fde_cssdatatable.h +++ /dev/null @@ -1,200 +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_SRC_FDE_CSS_FDE_CSSDATATABLE_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSDATATABLE_H_ - -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fde/css/fde_css.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -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); - } - int32_t CountArgs() const { return m_pArgList->CountValues(); } - IFDE_CSSValue* GetArgs(int32_t index) const { - return m_pArgList->GetValue(index); - } - const FX_WCHAR* GetFuncName() const { return m_pszFuncName; } - - protected: - IFDE_CSSValueList* m_pArgList; - const FX_WCHAR* m_pszFuncName; -}; -class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue, - public CFX_Target { - public: - CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src) { *this = src; } - CFDE_CSSPrimitiveValue(FX_ARGB color) - : m_eType(FDE_CSSPRIMITIVETYPE_RGB), m_dwColor(color) {} - CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue) - : m_eType(FDE_CSSPRIMITIVETYPE_Enum), m_eEnum(eValue) {} - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, FX_FLOAT fValue) - : 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); - } - CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction) - : m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {} - - virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const { return m_eType; } - - virtual FX_ARGB GetRGBColor() const { - FXSYS_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); - return m_fNumber; - } - virtual const FX_WCHAR* GetString(int32_t& iLength) const { - FXSYS_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); - return m_eEnum; - } - virtual const FX_WCHAR* GetFuncName() const { - FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function); - return m_pFunction->GetFuncName(); - } - virtual int32_t CountArgs() const { - FXSYS_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); - return m_pFunction->GetArgs(index); - } - - FDE_CSSPRIMITIVETYPE m_eType; - union { - FX_ARGB m_dwColor; - FX_FLOAT m_fNumber; - const FX_WCHAR* m_pString; - FDE_CSSPROPERTYVALUE m_eEnum; - CFDE_CSSFunction* m_pFunction; - }; -}; -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, - const CFDE_CSSValueArray& list); - virtual int32_t CountValues() const { return m_iCount; } - virtual IFDE_CSSValue* GetValue(int32_t index) const { - return m_ppList[index]; - } - - protected: - IFDE_CSSValue** m_ppList; - int32_t m_iCount; -}; -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); - } - FX_BOOL NextValue(FDE_CSSPRIMITIVETYPE& eType, - const FX_WCHAR*& pStart, - int32_t& iLength); - FX_WCHAR m_Separator; - - protected: - int32_t SkipTo(FX_WCHAR wch, - FX_BOOL bWSSeparator = FALSE, - FX_BOOL bBrContinue = FALSE); - const FX_WCHAR* m_pCur; - const FX_WCHAR* m_pEnd; -}; - -#define FDE_CSSVALUETYPE_MaybeNumber 0x0100 -#define FDE_CSSVALUETYPE_MaybeEnum 0x0200 -#define FDE_CSSVALUETYPE_MaybeURI 0x0400 -#define FDE_CSSVALUETYPE_MaybeString 0x0800 -#define FDE_CSSVALUETYPE_MaybeColor 0x1000 -#define FDE_CSSVALUETYPE_MaybeFunction 0x2000 -#define FDE_IsOnlyValue(type, enum) \ - (((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive) -struct FDE_CSSPROPERTYTABLE { - FDE_CSSPROPERTY eName; - const FX_WCHAR* pszName; - FX_DWORD dwHash; - FX_DWORD dwType; -}; -typedef FDE_CSSPROPERTYTABLE const* FDE_LPCCSSPROPERTYTABLE; - -FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName, - int32_t iLength); -FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName); -struct FDE_CSSPROPERTYVALUETABLE { - FDE_CSSPROPERTYVALUE eName; - const FX_WCHAR* pszName; - FX_DWORD dwHash; -}; -typedef FDE_CSSPROPERTYVALUETABLE const* FDE_LPCCSSPROPERTYVALUETABLE; - -FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName( - const FX_WCHAR* pszName, - int32_t iLength); -FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( - FDE_CSSPROPERTYVALUE eName); -struct FDE_CSSMEDIATYPETABLE { - FX_WORD wHash; - FX_WORD wValue; -}; -typedef FDE_CSSMEDIATYPETABLE const* FDE_LPCCSSMEDIATYPETABLE; -FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName, - int32_t iLength); -struct FDE_CSSLENGTHUNITTABLE { - FX_WORD wHash; - FX_WORD wValue; -}; -typedef FDE_CSSLENGTHUNITTABLE const* FDE_LPCCSSLENGTHUNITTABLE; -FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, - int32_t iLength); -struct FDE_CSSCOLORTABLE { - FX_DWORD dwHash; - FX_ARGB dwValue; -}; -typedef FDE_CSSCOLORTABLE const* FDE_LPCCSSCOLORTABLE; -FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName, - int32_t iLength); -struct FDE_CSSPERSUDOTABLE { - FDE_CSSPERSUDO eName; - const FX_WCHAR* pszName; - FX_DWORD dwHash; -}; -typedef FDE_CSSPERSUDOTABLE const* FDE_LPCCSSPERSUDOTABLE; - -FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo); -FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_FLOAT& fValue, - FDE_CSSPRIMITIVETYPE& eUnit); -FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue, - int32_t iValueLen, - int32_t& iOffset, - int32_t& iLength); -FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_ARGB& dwColor); -FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue, - int32_t iValueLen, - int32_t& iOffset, - int32_t& iLength); - -#endif // XFA_SRC_FDE_CSS_FDE_CSSDATATABLE_H_ diff --git a/xfa/src/fde/css/fde_cssdeclaration.cpp b/xfa/src/fde/css/fde_cssdeclaration.cpp deleted file mode 100644 index 073c14d414..0000000000 --- a/xfa/src/fde/css/fde_cssdeclaration.cpp +++ /dev/null @@ -1,1377 +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/src/fde/css/fde_cssdeclaration.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/crt/fgas_system.h" - -IFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSPROPERTY eProperty, - FX_BOOL& bImportant) const { - for (const FDE_CSSPropertyHolder* pHolder = m_pFirstProperty; pHolder; - pHolder = pHolder->pNext) { - if (pHolder->eProperty == eProperty) { - bImportant = pHolder->bImportant; - return pHolder->pValue; - } - } - return NULL; -} -FX_POSITION CFDE_CSSDeclaration::GetStartPosition() const { - return (FX_POSITION)m_pFirstProperty; -} -void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos, - FDE_CSSPROPERTY& eProperty, - IFDE_CSSValue*& pValue, - FX_BOOL& bImportant) const { - const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos; - FXSYS_assert(pHolder != NULL); - bImportant = pHolder->bImportant; - eProperty = (FDE_CSSPROPERTY)pHolder->eProperty; - pValue = pHolder->pValue; - pos = (FX_POSITION)pHolder->pNext; -} -FX_POSITION CFDE_CSSDeclaration::GetStartCustom() const { - return (FX_POSITION)m_pFirstCustom; -} -void CFDE_CSSDeclaration::GetNextCustom(FX_POSITION& pos, - CFX_WideString& wsName, - CFX_WideString& wsValue) const { - const FDE_CSSCustomProperty* pProperty = (const FDE_CSSCustomProperty*)pos; - if (pProperty == NULL) { - return; - } - wsName = pProperty->pwsName; - wsValue = pProperty->pwsValue; - pos = (FX_POSITION)pProperty->pNext; -} -const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - FXSYS_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); - if (pCache->Lookup(pKey, pszCached)) { - return (const FX_WCHAR*)pszCached; - } - } - FX_WCHAR* psz = - (FX_WCHAR*)pArgs->pStaticStore->Alloc((iValueLen + 1) * sizeof(FX_WCHAR)); - if (psz == NULL) { - return NULL; - } - FXSYS_wcsncpy(psz, pszValue, iValueLen); - psz[iValueLen] = '\0'; - if (pCache) { - pCache->SetAt(pKey, psz); - } - return psz; -} -IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue( - IFX_MEMAllocator* pStaticStore, - FDE_CSSPRIMITIVETYPE eUnit, - FX_FLOAT fValue) const { - static CFDE_CSSPrimitiveValue s_ZeroValue(FDE_CSSPRIMITIVETYPE_Number, 0.0f); - if (eUnit == FDE_CSSPRIMITIVETYPE_Number && FXSYS_fabs(fValue) < 0.001f) { - return &s_ZeroValue; - } - return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eUnit, fValue); -} -inline IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewEnumValue( - IFX_MEMAllocator* pStaticStore, - FDE_CSSPROPERTYVALUE eValue) const { - return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eValue); -} -void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore, - FDE_CSSPROPERTY eProperty, - IFDE_CSSValue* pValue, - FX_BOOL bImportant) { - FDE_CSSPropertyHolder* pHolder = - FXTARGET_NewWith(pStaticStore) FDE_CSSPropertyHolder; - pHolder->bImportant = bImportant; - pHolder->eProperty = eProperty; - pHolder->pValue = pValue; - pHolder->pNext = NULL; - if (m_pLastProperty == NULL) { - m_pLastProperty = m_pFirstProperty = pHolder; - } else { - m_pLastProperty->pNext = pHolder; - m_pLastProperty = pHolder; - } -} -FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - FXSYS_assert(iValueLen > 0); - FX_BOOL bImportant = FALSE; - if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' && - FX_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) { - if ((iValueLen -= 10) == 0) { - return FALSE; - } - bImportant = TRUE; - } - const FX_DWORD dwType = pArgs->pProperty->dwType; - switch (dwType & 0x0F) { - case FDE_CSSVALUETYPE_Primitive: { - static const FX_DWORD g_ValueGuessOrder[] = { - FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum, - FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeURI, - FDE_CSSVALUETYPE_MaybeFunction, FDE_CSSVALUETYPE_MaybeString, - }; - static const int32_t g_ValueGuessCount = - sizeof(g_ValueGuessOrder) / sizeof(FX_DWORD); - for (int32_t i = 0; i < g_ValueGuessCount; ++i) { - const FX_DWORD dwMatch = dwType & g_ValueGuessOrder[i]; - if (dwMatch == 0) { - continue; - } - IFDE_CSSValue* pCSSValue = NULL; - switch (dwMatch) { - case FDE_CSSVALUETYPE_MaybeFunction: - pCSSValue = ParseFunction(pArgs, pszValue, iValueLen); - break; - case FDE_CSSVALUETYPE_MaybeNumber: - pCSSValue = ParseNumber(pArgs, pszValue, iValueLen); - break; - case FDE_CSSVALUETYPE_MaybeEnum: - pCSSValue = ParseEnum(pArgs, pszValue, iValueLen); - break; - case FDE_CSSVALUETYPE_MaybeColor: - pCSSValue = ParseColor(pArgs, pszValue, iValueLen); - break; - case FDE_CSSVALUETYPE_MaybeURI: - pCSSValue = ParseURI(pArgs, pszValue, iValueLen); - break; - case FDE_CSSVALUETYPE_MaybeString: - pCSSValue = ParseString(pArgs, pszValue, iValueLen); - break; - default: - break; - } - if (pCSSValue != NULL) { - AddPropertyHolder(pArgs->pStaticStore, pArgs->pProperty->eName, - pCSSValue, bImportant); - return TRUE; - } - if (FDE_IsOnlyValue(dwType, g_ValueGuessOrder[i])) { - return FALSE; - } - } - } break; - case FDE_CSSVALUETYPE_Shorthand: { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - IFDE_CSSValue *pColor, *pStyle, *pWidth; - switch (pArgs->pProperty->eName) { - case FDE_CSSPROPERTY_Font: - return ParseFontProperty(pArgs, pszValue, iValueLen, bImportant); - case FDE_CSSPROPERTY_Background: - return ParseBackgroundProperty(pArgs, pszValue, iValueLen, - bImportant); - case FDE_CSSPROPERTY_ListStyle: - return ParseListStyleProperty(pArgs, pszValue, iValueLen, bImportant); - case FDE_CSSPROPERTY_Border: - if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, - pStyle, pWidth)) { - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderLeftColor, - FDE_CSSPROPERTY_BorderLeftStyle, - FDE_CSSPROPERTY_BorderLeftWidth); - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderTopColor, - FDE_CSSPROPERTY_BorderTopStyle, - FDE_CSSPROPERTY_BorderTopWidth); - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderRightColor, - FDE_CSSPROPERTY_BorderRightStyle, - FDE_CSSPROPERTY_BorderRightWidth); - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderBottomColor, - FDE_CSSPROPERTY_BorderBottomStyle, - FDE_CSSPROPERTY_BorderBottomWidth); - return TRUE; - } - break; - case FDE_CSSPROPERTY_BorderLeft: - if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, - pStyle, pWidth)) { - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderLeftColor, - FDE_CSSPROPERTY_BorderLeftStyle, - FDE_CSSPROPERTY_BorderLeftWidth); - return TRUE; - } - break; - case FDE_CSSPROPERTY_BorderTop: - if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, - pStyle, pWidth)) { - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderTopColor, - FDE_CSSPROPERTY_BorderTopStyle, - FDE_CSSPROPERTY_BorderTopWidth); - return TRUE; - } - break; - case FDE_CSSPROPERTY_BorderRight: - if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, - pStyle, pWidth)) { - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderRightColor, - FDE_CSSPROPERTY_BorderRightStyle, - FDE_CSSPROPERTY_BorderRightWidth); - return TRUE; - } - break; - case FDE_CSSPROPERTY_BorderBottom: - if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor, - pStyle, pWidth)) { - AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant, - FDE_CSSPROPERTY_BorderBottomColor, - FDE_CSSPROPERTY_BorderBottomStyle, - FDE_CSSPROPERTY_BorderBottomWidth); - return TRUE; - } - break; - case FDE_CSSPROPERTY_Overflow: - return ParseOverflowProperty(pArgs, pszValue, iValueLen, bImportant); - case FDE_CSSPROPERTY_ColumnRule: - return ParseColumnRuleProperty(pArgs, pszValue, iValueLen, - bImportant); - default: - break; - } - } break; - case FDE_CSSVALUETYPE_List: - switch (pArgs->pProperty->eName) { - case FDE_CSSPROPERTY_CounterIncrement: - case FDE_CSSPROPERTY_CounterReset: - return ParseCounterProperty(pArgs, pszValue, iValueLen, bImportant); - case FDE_CSSPROPERTY_Content: - return ParseContentProperty(pArgs, pszValue, iValueLen, bImportant); - default: - return ParseValueListProperty(pArgs, pszValue, iValueLen, bImportant); - } - default: - FXSYS_assert(FALSE); - break; - } - return FALSE; -} -FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszName, - int32_t iNameLen, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - FDE_CSSCustomProperty* pProperty = - FXTARGET_NewWith(pArgs->pStaticStore) FDE_CSSCustomProperty; - pProperty->pwsName = CopyToLocal(pArgs, pszName, iNameLen); - pProperty->pwsValue = CopyToLocal(pArgs, pszValue, iValueLen); - pProperty->pNext = NULL; - if (m_pLastCustom == NULL) { - m_pLastCustom = m_pFirstCustom = pProperty; - } else { - m_pLastCustom->pNext = pProperty; - m_pLastCustom = pProperty; - } - return TRUE; -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - FX_FLOAT fValue; - FDE_CSSPRIMITIVETYPE eUnit; - if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eUnit)) { - return NULL; - } - return NewNumberValue(pArgs->pStaticStore, eUnit, fValue); -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - return pValue ? NewEnumValue(pArgs->pStaticStore, pValue->eName) : NULL; -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - FX_ARGB dwColor; - if (!FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - return NULL; - } - return FXTARGET_NewWith(pArgs->pStaticStore) CFDE_CSSPrimitiveValue(dwColor); -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - int32_t iOffset; - if (!FDE_ParseCSSURI(pszValue, iValueLen, iOffset, iValueLen)) { - return NULL; - } - if (iValueLen <= 0) { - return NULL; - } - pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen); - return pszValue - ? FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_URI, pszValue) - : NULL; -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseString( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - int32_t iOffset; - if (!FDE_ParseCSSString(pszValue, iValueLen, iOffset, iValueLen)) { - return NULL; - } - if (iValueLen <= 0) { - return NULL; - } - pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen); - return pszValue - ? FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue) - : NULL; -} -IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen) { - if (pszValue[iValueLen - 1] != ')') { - return NULL; - } - int32_t iStartBracket = 0; - while (pszValue[iStartBracket] != '(') { - if (iStartBracket < iValueLen) { - iStartBracket++; - } else { - return NULL; - } - } - if (iStartBracket == 0) { - return NULL; - } - const FX_WCHAR* pszFuncName = CopyToLocal(pArgs, pszValue, iStartBracket); - pszValue += (iStartBracket + 1); - iValueLen -= (iStartBracket + 2); - CFDE_CSSValueArray argumentArr; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ','); - FDE_CSSPRIMITIVETYPE ePrimitiveType; - while (parser.NextValue(ePrimitiveType, pszValue, iValueLen)) { - switch (ePrimitiveType) { - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pPropertyValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pPropertyValue != NULL) { - argumentArr.Add( - NewEnumValue(pArgs->pStaticStore, pPropertyValue->eName)); - continue; - } - IFDE_CSSValue* pFunctionValue = - ParseFunction(pArgs, pszValue, iValueLen); - if (pFunctionValue != NULL) { - argumentArr.Add(pFunctionValue); - continue; - } - argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSPrimitiveValue( - FDE_CSSPRIMITIVETYPE_String, - CopyToLocal(pArgs, pszValue, iValueLen))); - } break; - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, ePrimitiveType)) { - argumentArr.Add( - NewNumberValue(pArgs->pStaticStore, ePrimitiveType, fValue)); - } - } break; - default: - argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSPrimitiveValue( - FDE_CSSPRIMITIVETYPE_String, - CopyToLocal(pArgs, pszValue, iValueLen))); - break; - } - } - IFDE_CSSValueList* pArgumentList = FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSValueList(pArgs->pStaticStore, argumentArr); - CFDE_CSSFunction* pFunction = FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSFunction(pszFuncName, pArgumentList); - return FXTARGET_NewWith(pArgs->pStaticStore) - CFDE_CSSPrimitiveValue(pFunction); -} -FX_BOOL CFDE_CSSDeclaration::ParseContentProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = (IFX_MEMAllocator*)pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - FDE_CSSPRIMITIVETYPE eType; - CFDE_CSSValueArray list; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_URI: - list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - eType, CopyToLocal(pArgs, pszValue, iValueLen))); - break; - case FDE_CSSPRIMITIVETYPE_Number: - return FALSE; - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_Normal: - case FDE_CSSPROPERTYVALUE_None: { - if (list.GetSize() == 0) { - list.Add(NewEnumValue(pStaticStore, pValue->eName)); - } else { - return FALSE; - } - } break; - case FDE_CSSPROPERTYVALUE_OpenQuote: - case FDE_CSSPROPERTYVALUE_CloseQuote: - case FDE_CSSPROPERTYVALUE_NoOpenQuote: - case FDE_CSSPROPERTYVALUE_NoCloseQuote: - list.Add(NewEnumValue(pStaticStore, pValue->eName)); - break; - default: - return FALSE; - } - continue; - } - IFDE_CSSValue* pFunction = ParseFunction(pArgs, pszValue, iValueLen); - if (pFunction != NULL) { - list.Add(pFunction); - continue; - } - list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - eType, CopyToLocal(pArgs, pszValue, iValueLen))); - } break; - case FDE_CSSPRIMITIVETYPE_RGB: - return FALSE; - default: - break; - } - } - if (list.GetSize() == 0) { - return FALSE; - } - AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, - FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, list), - bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseCounterProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - CFDE_CSSValueArray list; - CFDE_CSSValueArray listFull; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - if (list.GetSize() == 1) { - list.Add(NewNumberValue(pStaticStore, eType, fValue)); - listFull.Add(FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, list)); - list.RemoveAll(); - } else { - return FALSE; - } - } - } break; - case FDE_CSSPRIMITIVETYPE_String: { - if (list.GetSize() == 0) { - pszValue = CopyToLocal(pArgs, pszValue, iValueLen); - list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - FDE_CSSPRIMITIVETYPE_String, pszValue)); - } else { - listFull.Add(FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, list)); - list.RemoveAll(); - pszValue = CopyToLocal(pArgs, pszValue, iValueLen); - list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - FDE_CSSPRIMITIVETYPE_String, pszValue)); - } - } break; - default: - break; - } - } - if (list.GetSize() == 1) { - listFull.Add(FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, list)); - } - if (listFull.GetSize() == 0) { - return FALSE; - } - AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, - FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, listFull), - bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - FX_WCHAR separator = - (pArgs->pProperty->eName == FDE_CSSPROPERTY_FontFamily) ? ',' : ' '; - CFDE_CSSValueListParser parser(pszValue, iValueLen, separator); - const FX_DWORD dwType = pArgs->pProperty->dwType; - FDE_CSSPRIMITIVETYPE eType; - CFDE_CSSValueArray list; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_Number: - if (dwType & FDE_CSSVALUETYPE_MaybeNumber) { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - list.Add(NewNumberValue(pStaticStore, eType, fValue)); - } - } - break; - case FDE_CSSPRIMITIVETYPE_String: - if (dwType & FDE_CSSVALUETYPE_MaybeColor) { - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - list.Add(FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue(dwColor)); - continue; - } - } - if (dwType & FDE_CSSVALUETYPE_MaybeEnum) { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - list.Add(NewEnumValue(pStaticStore, pValue->eName)); - continue; - } - } - if (dwType & FDE_CSSVALUETYPE_MaybeString) { - pszValue = CopyToLocal(pArgs, pszValue, iValueLen); - list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - FDE_CSSPRIMITIVETYPE_String, pszValue)); - } - break; - case FDE_CSSPRIMITIVETYPE_RGB: - if (dwType & FDE_CSSVALUETYPE_MaybeColor) { - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - list.Add(FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue(dwColor)); - } - } - break; - default: - break; - } - } - if (list.GetSize() == 0) { - return FALSE; - } - switch (pArgs->pProperty->eName) { - case FDE_CSSPROPERTY_BorderColor: - return Add4ValuesProperty( - pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftColor, - FDE_CSSPROPERTY_BorderTopColor, FDE_CSSPROPERTY_BorderRightColor, - FDE_CSSPROPERTY_BorderBottomColor); - case FDE_CSSPROPERTY_BorderStyle: - return Add4ValuesProperty( - pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftStyle, - FDE_CSSPROPERTY_BorderTopStyle, FDE_CSSPROPERTY_BorderRightStyle, - FDE_CSSPROPERTY_BorderBottomStyle); - case FDE_CSSPROPERTY_BorderWidth: - return Add4ValuesProperty( - pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftWidth, - FDE_CSSPROPERTY_BorderTopWidth, FDE_CSSPROPERTY_BorderRightWidth, - FDE_CSSPROPERTY_BorderBottomWidth); - case FDE_CSSPROPERTY_Margin: - return Add4ValuesProperty( - pStaticStore, list, bImportant, FDE_CSSPROPERTY_MarginLeft, - FDE_CSSPROPERTY_MarginTop, FDE_CSSPROPERTY_MarginRight, - FDE_CSSPROPERTY_MarginBottom); - case FDE_CSSPROPERTY_Padding: - return Add4ValuesProperty( - pStaticStore, list, bImportant, FDE_CSSPROPERTY_PaddingLeft, - FDE_CSSPROPERTY_PaddingTop, FDE_CSSPROPERTY_PaddingRight, - FDE_CSSPROPERTY_PaddingBottom); - default: { - CFDE_CSSValueList* pList = - FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, list); - AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, pList, - bImportant); - return TRUE; - } break; - } - 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) { - switch (list.GetSize()) { - case 1: - AddPropertyHolder(pStaticStore, eLeft, list[0], bImportant); - AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); - AddPropertyHolder(pStaticStore, eRight, list[0], bImportant); - AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant); - return TRUE; - case 2: - AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant); - AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); - AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); - AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant); - return TRUE; - case 3: - AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant); - AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); - AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); - AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant); - return TRUE; - case 4: - AddPropertyHolder(pStaticStore, eLeft, list[3], bImportant); - AddPropertyHolder(pStaticStore, eTop, list[0], bImportant); - AddPropertyHolder(pStaticStore, eRight, list[1], bImportant); - AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant); - return TRUE; - default: - break; - } - return FALSE; -} -FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty( - IFX_MEMAllocator* pStaticStore, - const FX_WCHAR* pszValue, - int32_t iValueLen, - IFDE_CSSValue*& pColor, - IFDE_CSSValue*& pStyle, - IFDE_CSSValue*& pWidth) const { - pColor = pStyle = pWidth = NULL; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_Number: - if (pWidth == NULL) { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - pWidth = NewNumberValue(pStaticStore, eType, fValue); - } - } - break; - case FDE_CSSPRIMITIVETYPE_RGB: - if (pColor == NULL) { - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - pColor = - FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); - } - } - break; - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSCOLORTABLE* pColorItem = - FDE_GetCSSColorByName(pszValue, iValueLen); - if (pColorItem != NULL) { - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue(pColorItem->dwValue); - } - continue; - } - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue == NULL) { - continue; - } - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_Transparent: - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue((FX_ARGB)0); - } - break; - case FDE_CSSPROPERTYVALUE_Thin: - case FDE_CSSPROPERTYVALUE_Thick: - case FDE_CSSPROPERTYVALUE_Medium: - if (pWidth == NULL) { - pWidth = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_None: - case FDE_CSSPROPERTYVALUE_Hidden: - case FDE_CSSPROPERTYVALUE_Dotted: - case FDE_CSSPROPERTYVALUE_Dashed: - case FDE_CSSPROPERTYVALUE_Solid: - case FDE_CSSPROPERTYVALUE_Double: - case FDE_CSSPROPERTYVALUE_Groove: - case FDE_CSSPROPERTYVALUE_Ridge: - case FDE_CSSPROPERTYVALUE_Inset: - case FDE_CSSPROPERTYVALUE_Outset: - if (pStyle == NULL) { - pStyle = NewEnumValue(pStaticStore, pValue->eName); - } - break; - default: - break; - } - }; break; - default: - break; - } - } - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); - } - if (pStyle == NULL) { - pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); - } - if (pWidth == NULL) { - pWidth = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); - } - return TRUE; -} -void CFDE_CSSDeclaration::AddBorderProperty(IFX_MEMAllocator* pStaticStore, - IFDE_CSSValue* pColor, - IFDE_CSSValue* pStyle, - IFDE_CSSValue* pWidth, - FX_BOOL bImportant, - FDE_CSSPROPERTY eColor, - FDE_CSSPROPERTY eStyle, - FDE_CSSPROPERTY eWidth) { - AddPropertyHolder(pStaticStore, eStyle, pStyle, bImportant); - AddPropertyHolder(pStaticStore, eWidth, pWidth, bImportant); - AddPropertyHolder(pStaticStore, eColor, pColor, bImportant); -} -FX_BOOL CFDE_CSSDeclaration::ParseListStyleProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - IFDE_CSSPrimitiveValue *pType = NULL, *pImage = NULL, *pPosition = NULL; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_URI: - if (pImage == NULL) { - pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - eType, CopyToLocal(pArgs, pszValue, iValueLen)); - } - break; - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue == NULL) { - break; - } - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_None: - if (pImage == NULL) { - pImage = NewEnumValue(pStaticStore, pValue->eName); - } else if (pType == NULL) { - pImage = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Inside: - case FDE_CSSPROPERTYVALUE_Outside: - if (pPosition == NULL) { - pPosition = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Disc: - case FDE_CSSPROPERTYVALUE_Circle: - case FDE_CSSPROPERTYVALUE_Square: - case FDE_CSSPROPERTYVALUE_Decimal: - case FDE_CSSPROPERTYVALUE_DecimalLeadingZero: - case FDE_CSSPROPERTYVALUE_LowerRoman: - case FDE_CSSPROPERTYVALUE_UpperRoman: - case FDE_CSSPROPERTYVALUE_LowerGreek: - case FDE_CSSPROPERTYVALUE_LowerLatin: - case FDE_CSSPROPERTYVALUE_UpperLatin: - case FDE_CSSPROPERTYVALUE_Armenian: - case FDE_CSSPROPERTYVALUE_Georgian: - case FDE_CSSPROPERTYVALUE_LowerAlpha: - case FDE_CSSPROPERTYVALUE_UpperAlpha: - if (pType == NULL) { - pType = NewEnumValue(pStaticStore, pValue->eName); - } - break; - default: - break; - } - }; break; - default: - break; - } - } - if (pPosition == NULL) { - pPosition = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Outside); - } - if (pImage == NULL) { - pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); - } - if (pType == NULL) { - pType = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); - } - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStylePosition, pPosition, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleImage, pImage, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleType, pType, - bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - IFDE_CSSPrimitiveValue *pColor = NULL, *pImage = NULL, *pRepeat = NULL; - IFDE_CSSPrimitiveValue *pPosX = NULL, *pPosY = NULL, *pAttachment = NULL; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_URI: - if (pImage == NULL) { - pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - eType, CopyToLocal(pArgs, pszValue, iValueLen)); - } - break; - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - break; - } - if (pPosX == NULL) { - pPosX = NewNumberValue(pStaticStore, eType, fValue); - } else if (pPosY == NULL) { - pPosY = NewNumberValue(pStaticStore, eType, fValue); - } - } break; - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_None: - if (pImage == NULL) { - pImage = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Transparent: - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue((FX_ARGB)0); - } - break; - case FDE_CSSPROPERTYVALUE_Fixed: - case FDE_CSSPROPERTYVALUE_Scroll: - if (pAttachment == NULL) { - pAttachment = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Repeat: - case FDE_CSSPROPERTYVALUE_RepeatX: - case FDE_CSSPROPERTYVALUE_RepeatY: - case FDE_CSSPROPERTYVALUE_NoRepeat: - if (pRepeat == NULL) { - pRepeat = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Left: - case FDE_CSSPROPERTYVALUE_Right: - if (pPosX == NULL) { - pPosX = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Top: - case FDE_CSSPROPERTYVALUE_Bottom: - if (pPosY == NULL) { - pPosX = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Center: - if (pPosX == NULL) { - pPosX = NewEnumValue(pStaticStore, pValue->eName); - } else if (pPosY == NULL) { - pPosX = NewEnumValue(pStaticStore, pValue->eName); - } - break; - default: - break; - } - break; - } - const FDE_CSSCOLORTABLE* pColorItem = - FDE_GetCSSColorByName(pszValue, iValueLen); - if (pColorItem != NULL) { - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue(pColorItem->dwValue); - } - } - } break; - case FDE_CSSPRIMITIVETYPE_RGB: - if (pColor == NULL) { - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - pColor = - FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); - } - } - break; - default: - break; - } - } - if (pColor == NULL) { - pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); - } - if (pImage == NULL) { - pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); - } - if (pRepeat == NULL) { - pRepeat = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Repeat); - } - if (pAttachment == NULL) { - pAttachment = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Scroll); - } - if (pPosX == NULL) { - pPosX = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); - pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); - } else if (pPosY == NULL) { - pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f); - } - CFDE_CSSValueArray position; - position.Add(pPosX); - position.Add(pPosY); - CFDE_CSSValueList* pPosList = - FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, position); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundColor, pColor, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundImage, pImage, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundRepeat, pRepeat, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundPosition, pPosList, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundAttachment, - pAttachment, bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, '/'); - IFDE_CSSPrimitiveValue *pStyle = NULL, *pVariant = NULL, *pWeight = NULL; - IFDE_CSSPrimitiveValue *pFontSize = NULL, *pLineHeight = NULL; - CFDE_CSSValueArray familyList; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_XxSmall: - case FDE_CSSPROPERTYVALUE_XSmall: - case FDE_CSSPROPERTYVALUE_Small: - case FDE_CSSPROPERTYVALUE_Medium: - case FDE_CSSPROPERTYVALUE_Large: - case FDE_CSSPROPERTYVALUE_XLarge: - case FDE_CSSPROPERTYVALUE_XxLarge: - case FDE_CSSPROPERTYVALUE_Smaller: - case FDE_CSSPROPERTYVALUE_Larger: - if (pFontSize == NULL) { - pFontSize = NewEnumValue(pStaticStore, pValue->eName); - } - continue; - case FDE_CSSPROPERTYVALUE_Bold: - case FDE_CSSPROPERTYVALUE_Bolder: - case FDE_CSSPROPERTYVALUE_Lighter: - if (pWeight == NULL) { - pWeight = NewEnumValue(pStaticStore, pValue->eName); - } - continue; - case FDE_CSSPROPERTYVALUE_Italic: - case FDE_CSSPROPERTYVALUE_Oblique: - if (pStyle == NULL) { - pStyle = NewEnumValue(pStaticStore, pValue->eName); - } - continue; - case FDE_CSSPROPERTYVALUE_SmallCaps: - if (pVariant == NULL) { - pVariant = NewEnumValue(pStaticStore, pValue->eName); - } - continue; - case FDE_CSSPROPERTYVALUE_Normal: - if (pStyle == NULL) { - pStyle = NewEnumValue(pStaticStore, pValue->eName); - } else if (pVariant == NULL) { - pVariant = NewEnumValue(pStaticStore, pValue->eName); - } else if (pWeight == NULL) { - pWeight = NewEnumValue(pStaticStore, pValue->eName); - } else if (pFontSize == NULL) { - pFontSize = NewEnumValue(pStaticStore, pValue->eName); - } else if (pLineHeight == NULL) { - pLineHeight = NewEnumValue(pStaticStore, pValue->eName); - } - continue; - default: - break; - } - } - if (pFontSize != NULL) { - familyList.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue( - eType, CopyToLocal(pArgs, pszValue, iValueLen))); - } - parser.m_Separator = ','; - } break; - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - break; - } - if (eType == FDE_CSSPRIMITIVETYPE_Number) { - switch ((int32_t)fValue) { - case 100: - case 200: - case 300: - case 400: - case 500: - case 600: - case 700: - case 800: - case 900: - if (pWeight == NULL) { - pWeight = NewNumberValue(pStaticStore, - FDE_CSSPRIMITIVETYPE_Number, fValue); - } - continue; - } - } - if (pFontSize == NULL) { - pFontSize = NewNumberValue(pStaticStore, eType, fValue); - } else if (pLineHeight == NULL) { - pLineHeight = NewNumberValue(pStaticStore, eType, fValue); - } - } break; - default: - break; - } - } - if (pStyle == NULL) { - pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); - } - if (pVariant == NULL) { - pVariant = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); - } - if (pWeight == NULL) { - pWeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); - } - if (pFontSize == NULL) { - pFontSize = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium); - } - if (pLineHeight == NULL) { - pLineHeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal); - } - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontStyle, pStyle, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontVariant, pVariant, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontWeight, pWeight, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontSize, pFontSize, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_LineHeight, pLineHeight, - bImportant); - if (familyList.GetSize() > 0) { - CFDE_CSSValueList* pList = FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, familyList); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontFamily, pList, - bImportant); - } - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseColumnRuleProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - IFDE_CSSPrimitiveValue* pColumnRuleWidth = NULL; - IFDE_CSSPrimitiveValue* pColumnRuleStyle = NULL; - IFDE_CSSPrimitiveValue* pColumnRuleColor = NULL; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - switch (pValue->eName) { - case FDE_CSSPROPERTYVALUE_None: - case FDE_CSSPROPERTYVALUE_Hidden: - case FDE_CSSPROPERTYVALUE_Dotted: - case FDE_CSSPROPERTYVALUE_Dashed: - case FDE_CSSPROPERTYVALUE_Solid: - case FDE_CSSPROPERTYVALUE_Double: - case FDE_CSSPROPERTYVALUE_Groove: - case FDE_CSSPROPERTYVALUE_Ridge: - case FDE_CSSPROPERTYVALUE_Inset: - case FDE_CSSPROPERTYVALUE_Outset: - if (pColumnRuleStyle == NULL) { - pColumnRuleStyle = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Transparent: - if (pColumnRuleColor == NULL) { - pColumnRuleColor = NewEnumValue(pStaticStore, pValue->eName); - } - break; - case FDE_CSSPROPERTYVALUE_Thin: - case FDE_CSSPROPERTYVALUE_Medium: - case FDE_CSSPROPERTYVALUE_Thick: - if (pColumnRuleWidth == NULL) { - pColumnRuleWidth = NewEnumValue(pStaticStore, pValue->eName); - } - break; - default: - break; - } - continue; - } - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor) && - pColumnRuleColor == NULL) { - pColumnRuleColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue((FX_ARGB)dwColor); - continue; - } - } break; - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType) && - pColumnRuleWidth == NULL) { - pColumnRuleWidth = NewNumberValue(pStaticStore, eType, fValue); - } - } break; - case FDE_CSSPRIMITIVETYPE_RGB: { - FX_ARGB dwColor; - if (pColumnRuleColor == NULL && - FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - pColumnRuleColor = FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue((FX_ARGB)dwColor); - } - } break; - default: - break; - } - } - if (pColumnRuleColor == NULL && pColumnRuleStyle == NULL && - pColumnRuleWidth == NULL) { - return FALSE; - } - if (pColumnRuleStyle == NULL) { - pColumnRuleStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None); - } - if (pColumnRuleWidth == NULL) { - pColumnRuleWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium); - } - if (pColumnRuleColor == NULL) { - pColumnRuleColor = - FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0); - } - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleStyle, - pColumnRuleStyle, bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleWidth, - pColumnRuleWidth, bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleColor, - pColumnRuleColor, bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseTextEmphasisProperty( - FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - CFDE_CSSValueArray arrEmphasisStyle; - FDE_CSSPRIMITIVETYPE eType; - IFDE_CSSPrimitiveValue* pEmphasisColor = NULL; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - arrEmphasisStyle.Add(NewEnumValue(pStaticStore, pValue->eName)); - continue; - } - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - pEmphasisColor = - FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); - continue; - } - pszValue = CopyToLocal(pArgs, pszValue, iValueLen); - arrEmphasisStyle.Add( - FXTARGET_NewWith(pStaticStore) - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue)); - } break; - case FDE_CSSPRIMITIVETYPE_RGB: { - FX_ARGB dwColor; - if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) { - pEmphasisColor = - FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor); - } - } break; - default: - break; - } - } - if (arrEmphasisStyle.GetSize() != 0) { - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisStyle, - FXTARGET_NewWith(pStaticStore) - CFDE_CSSValueList(pStaticStore, arrEmphasisStyle), - bImportant); - } - if (pEmphasisColor != NULL) { - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisColor, - pEmphasisColor, bImportant); - } - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseColumnsProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - IFDE_CSSPrimitiveValue* pColumnWidth = NULL; - IFDE_CSSPrimitiveValue* pColumnCount = NULL; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_String: { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue == NULL && pValue->eName == FDE_CSSPROPERTYVALUE_Auto) { - pColumnWidth = NewEnumValue(pStaticStore, pValue->eName); - } - } break; - case FDE_CSSPRIMITIVETYPE_Number: { - FX_FLOAT fValue; - if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) { - switch (eType) { - case FDE_CSSPRIMITIVETYPE_Number: - if (pColumnCount == NULL) { - pColumnCount = NewNumberValue(pStaticStore, eType, fValue); - } - break; - default: - if (pColumnWidth == NULL) { - pColumnWidth = NewNumberValue(pStaticStore, eType, fValue); - } - break; - } - } - } break; - default: - break; - } - } - if (pColumnWidth == NULL && pColumnCount == NULL) { - return FALSE; - } else if (pColumnWidth == NULL) { - pColumnWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto); - } else if (pColumnCount == NULL) { - pColumnCount = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto); - } - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnWidth, pColumnWidth, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnCount, pColumnCount, - bImportant); - return TRUE; -} -FX_BOOL CFDE_CSSDeclaration::ParseOverflowProperty( - const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant) { - IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore; - CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); - IFDE_CSSPrimitiveValue* pOverflowX = NULL; - IFDE_CSSPrimitiveValue* pOverflowY = NULL; - FDE_CSSPRIMITIVETYPE eType; - while (parser.NextValue(eType, pszValue, iValueLen)) { - if (eType == FDE_CSSPRIMITIVETYPE_String) { - const FDE_CSSPROPERTYVALUETABLE* pValue = - FDE_GetCSSPropertyValueByName(pszValue, iValueLen); - if (pValue != NULL) { - switch (pValue->eName) { - case FDE_CSSOVERFLOW_Visible: - case FDE_CSSOVERFLOW_Hidden: - case FDE_CSSOVERFLOW_Scroll: - case FDE_CSSOVERFLOW_Auto: - case FDE_CSSOVERFLOW_NoDisplay: - case FDE_CSSOVERFLOW_NoContent: - if (pOverflowX != NULL && pOverflowY != NULL) { - return FALSE; - } else if (pOverflowX == NULL) { - pOverflowX = NewEnumValue(pStaticStore, pValue->eName); - } else if (pOverflowY == NULL) { - pOverflowY = NewEnumValue(pStaticStore, pValue->eName); - } - break; - default: - break; - } - } - } - } - if (pOverflowX == NULL && pOverflowY == NULL) { - return FALSE; - } else if (pOverflowY == NULL) { - pOverflowY = NewEnumValue(pStaticStore, pOverflowX->GetEnum()); - } - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowX, pOverflowX, - bImportant); - AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowY, pOverflowY, - bImportant); - return TRUE; -} diff --git a/xfa/src/fde/css/fde_cssdeclaration.h b/xfa/src/fde/css/fde_cssdeclaration.h deleted file mode 100644 index 9866b20f4c..0000000000 --- a/xfa/src/fde/css/fde_cssdeclaration.h +++ /dev/null @@ -1,158 +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_SRC_FDE_CSS_FDE_CSSDECLARATION_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_ - -#include "xfa/src/fde/css/fde_cssdatatable.h" - -class FDE_CSSPropertyHolder : public CFX_Target { - public: - int16_t eProperty; - int16_t bImportant; - IFDE_CSSValue* pValue; - FDE_CSSPropertyHolder* pNext; -}; - -class FDE_CSSCustomProperty : public CFX_Target { - public: - const FX_WCHAR* pwsName; - const FX_WCHAR* pwsValue; - FDE_CSSCustomProperty* pNext; -}; - -struct FDE_CSSPROPERTYARGS { - IFX_MEMAllocator* pStaticStore; - CFX_MapPtrToPtr* pStringCache; - FDE_LPCCSSPROPERTYTABLE pProperty; -}; - -class CFDE_CSSDeclaration : public IFDE_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; - FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszName, - int32_t iNameLen, - const FX_WCHAR* pszValue, - int32_t iValueLen); - - protected: - FX_BOOL ParseTextEmphasisProperty(FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseColumnsProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseColumnRuleProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseOverflowProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseBackgroundProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseListStyleProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseBorderPropoerty(IFX_MEMAllocator* pStaticStore, - const FX_WCHAR* pszValue, - int32_t iValueLen, - IFDE_CSSValue*& pColor, - IFDE_CSSValue*& pStyle, - IFDE_CSSValue*& pWidth) const; - void AddBorderProperty(IFX_MEMAllocator* pStaticStore, - IFDE_CSSValue* pColor, - IFDE_CSSValue* pStyle, - IFDE_CSSValue* pWidth, - FX_BOOL bImportant, - FDE_CSSPROPERTY eColor, - FDE_CSSPROPERTY eStyle, - FDE_CSSPROPERTY eWidth); - FX_BOOL ParseContentProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseCounterProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL ParseValueListProperty(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen, - FX_BOOL bImportant); - FX_BOOL Add4ValuesProperty(IFX_MEMAllocator* pStaticStore, - const CFDE_CSSValueArray& list, - FX_BOOL bImportant, - FDE_CSSPROPERTY eLeft, - FDE_CSSPROPERTY eTop, - FDE_CSSPROPERTY eRight, - FDE_CSSPROPERTY eBottom); - IFDE_CSSValue* ParseNumber(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - IFDE_CSSValue* ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - IFDE_CSSValue* ParseColor(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - IFDE_CSSValue* ParseURI(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - IFDE_CSSValue* ParseString(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - IFDE_CSSValue* ParseFunction(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs, - const FX_WCHAR* pszValue, - int32_t iValueLen); - void AddPropertyHolder(IFX_MEMAllocator* pStaticStore, - FDE_CSSPROPERTY eProperty, - IFDE_CSSValue* pValue, - FX_BOOL bImportant); - IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MEMAllocator* pStaticStore, - FDE_CSSPRIMITIVETYPE eUnit, - FX_FLOAT fValue) const; - IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore, - FDE_CSSPROPERTYVALUE eValue) const; - FDE_CSSPropertyHolder* m_pFirstProperty; - FDE_CSSPropertyHolder* m_pLastProperty; - FDE_CSSCustomProperty* m_pFirstCustom; - FDE_CSSCustomProperty* m_pLastCustom; -}; - -#endif // XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_ diff --git a/xfa/src/fde/css/fde_cssstyleselector.cpp b/xfa/src/fde/css/fde_cssstyleselector.cpp deleted file mode 100644 index ff82f9d956..0000000000 --- a/xfa/src/fde/css/fde_cssstyleselector.cpp +++ /dev/null @@ -1,1794 +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/src/fde/css/fde_cssstyleselector.h" - -#include <algorithm> - -#include "xfa/src/fde/css/fde_csscache.h" -#include "xfa/src/fde/css/fde_cssdeclaration.h" - -int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) { - int32_t iCount = m_arrCounterData.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) == - 0) { - return i; - } - } - return -1; -} -void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { - if (pList == NULL) { - return; - } - int32_t iCount = pList->CountValues(); - FX_FLOAT fDefValue = 1.0; - FX_BOOL bDefIncrement = TRUE; - if (pList == m_pCounterReset) { - fDefValue = 0.0; - bDefIncrement = FALSE; - } - for (int32_t i = 0; i < iCount; i++) { - IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); - int32_t iLen; - const FX_WCHAR* pszIdentifier = - ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(0)))->GetString(iLen); - FX_FLOAT fValue = fDefValue; - if (pCounter->CountValues() > 1) { - fValue = ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(1)))->GetFloat(); - } - int32_t iIndex = FindIndex(pszIdentifier); - if (iIndex == -1) { - FDE_CSSCOUNTERDATA data; - data.m_pszIdent = pszIdentifier; - if (bDefIncrement) { - data.m_bIncrement = TRUE; - data.m_iIncVal = (int32_t)fValue; - } else { - data.m_iResetVal = (int32_t)fValue; - data.m_bReset = TRUE; - } - m_arrCounterData.Add(data); - } else { - FDE_CSSCOUNTERDATA& data = m_arrCounterData.ElementAt(iIndex); - if (bDefIncrement) { - data.m_bIncrement = TRUE; - data.m_iIncVal += (int32_t)fValue; - } else { - data.m_bReset = TRUE; - data.m_iResetVal = (int32_t)fValue; - } - } - } -} -void CFDE_CSSCounterStyle::UpdateIndex() { - if (!m_bIndexDirty) { - return; - } - m_arrCounterData.RemoveAll(); - DoUpdateIndex(m_pCounterInc); - 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, - FX_DWORD dwPos) - : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) { - static const FX_DWORD s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, - 0x00100000, 0x01000000}; - for (; pSel != NULL; pSel = pSel->GetNextSelector()) { - FDE_CSSSELECTORTYPE eType = pSel->GetType(); - if (eType > FDE_CSSSELECTORTYPE_Descendant || - pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { - dwPriority += s_Specific[eType]; - } - } -} -void CFDE_CSSRuleCollection::Clear() { - m_IDRules.RemoveAll(); - m_TagRules.RemoveAll(); - m_ClassRules.RemoveAll(); - m_pUniversalRules = NULL; - m_pStaticStore = NULL; - m_iSelectors = 0; -} -void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, - FX_DWORD dwMediaList, - IFX_FontMgr* pFontMgr) { - int32_t iSheets = sheets.GetSize(); - for (int32_t i = 0; i < iSheets; ++i) { - IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); - if (FX_DWORD dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { - int32_t iRules = pSheet->CountRules(); - for (int32_t j = 0; j < iRules; j++) { - AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr); - } - } - } -} -void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, - IFDE_CSSRule* pRule, - FX_DWORD dwMediaList, - IFX_FontMgr* pFontMgr) { - switch (pRule->GetType()) { - case FDE_CSSRULETYPE_Style: { - IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule; - IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); - int32_t iSelectors = pStyleRule->CountSelectorLists(); - for (int32_t i = 0; i < iSelectors; ++i) { - IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); - if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { - FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); - AddRuleTo(m_pPersudoRules, pData); - continue; - } - if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) { - AddRuleTo(m_TagRules, pSelector->GetNameHash(), pSelector, - pDeclaration); - continue; - } - IFDE_CSSSelector* pNext = pSelector->GetNextSelector(); - if (pNext == NULL) { - FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); - AddRuleTo(m_pUniversalRules, pData); - continue; - } - switch (pNext->GetType()) { - case FDE_CSSSELECTORTYPE_ID: - AddRuleTo(m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration); - break; - case FDE_CSSSELECTORTYPE_Class: - AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector, - pDeclaration); - break; - case FDE_CSSSELECTORTYPE_Descendant: - case FDE_CSSSELECTORTYPE_Element: - AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration)); - break; - default: - FXSYS_assert(FALSE); - break; - } - } - } break; - case FDE_CSSRULETYPE_Media: { - IFDE_CSSMediaRule* pMediaRule = (IFDE_CSSMediaRule*)pRule; - if (pMediaRule->GetMediaList() & dwMediaList) { - int32_t iRules = pMediaRule->CountRules(); - for (int32_t i = 0; i < iRules; ++i) { - AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList, - pFontMgr); - } - } - } break; - default: - break; - } -} -void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, - FX_DWORD dwKey, - IFDE_CSSSelector* pSel, - IFDE_CSSDeclaration* pDecl) { - void* pKey = (void*)(uintptr_t)dwKey; - FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); - FDE_CSSRuleData* pList = NULL; - if (!map.Lookup(pKey, (void*&)pList)) { - map.SetAt(pKey, pData); - } else if (AddRuleTo(pList, pData)) { - map.SetAt(pKey, pList); - } -} - -FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, - FDE_CSSRuleData* pData) { - if (pList) { - pData->pNext = pList->pNext; - pList->pNext = pData; - return FALSE; - } - - pList = pData; - return TRUE; -} - -FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( - IFDE_CSSSelector* pSel, - IFDE_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), - m_pRuleDataStore(NULL), - m_pInlineStyleStore(NULL), - m_pFixedStyleStore(NULL), - m_pAccelerator(NULL) { - m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; - m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; - 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; - } -} -void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { - m_pFontMgr = pFontMgr; -} -void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { - FXSYS_assert(fFontSize > 0); - m_fDefFontSize = fFontSize; -} -IFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { - if (m_pAccelerator == NULL) { - 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); - } - CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) - CFDE_CSSComputedStyle(m_pFixedStyleStore); - if (pParentStyle) { - pStyle->m_InheritedData = - ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; - } else { - pStyle->m_InheritedData.Reset(); - } - pStyle->m_NonInheritedData.Reset(); - return pStyle; -} -FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, - IFDE_CSSStyleSheet* pSheet) { - FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); - CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; - dest.RemoveAt(0, dest.GetSize()); - if (pSheet != NULL) { - dest.Add(pSheet); - } - return TRUE; -} -FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets( - FDE_CSSSTYLESHEETGROUP eType, - const CFDE_CSSStyleSheetArray* pArray) { - FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); - CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; - if (pArray == NULL) { - dest.RemoveAt(0, dest.GetSize()); - } else { - dest.Copy(*pArray); - } - return TRUE; -} -void CFDE_CSSStyleSelector::SetStylePriority( - FDE_CSSSTYLESHEETGROUP eType, - FDE_CSSSTYLESHEETPRIORITY ePriority) { - m_ePriorities[ePriority] = eType; -} -void CFDE_CSSStyleSelector::UpdateStyleIndex(FX_DWORD dwMediaList) { - Reset(); - m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); - FXSYS_assert(m_pRuleDataStore != NULL); - for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { - CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; - rules.m_pStaticStore = m_pRuleDataStore; - rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); - } -} -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; - } -} -int32_t CFDE_CSSStyleSelector::MatchDeclarations( - IFDE_CSSTagProvider* pTag, - CFDE_CSSDeclarationArray& matchedDecls, - FDE_CSSPERSUDO ePersudoType) { - FXSYS_assert(m_pAccelerator != NULL && pTag != NULL); - FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); - FXSYS_assert(pCache != NULL && 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) { - continue; - } - if (ePersudoType == FDE_CSSPERSUDO_NONE) { - MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType); - if (pCache->HashTag()) { - MatchRules(pCache, rules.GetTagRuleData(pCache->HashTag()), - ePersudoType); - } - int32_t iCount = pCache->CountHashClass(); - for (int32_t i = 0; i < iCount; i++) { - pCache->SetClassIndex(i); - MatchRules(pCache, rules.GetClassRuleData(pCache->HashClass()), - ePersudoType); - } - } else { - MatchRules(pCache, rules.GetPersudoRuleData(), ePersudoType); - } - - std::sort(m_MatchedRules.begin(), m_MatchedRules.end(), - [](const FDE_CSSRuleData* p1, const FDE_CSSRuleData* p2) { - return p1->dwPriority < p2->dwPriority; - }); - for (const auto& rule : m_MatchedRules) - matchedDecls.Add(rule->pDeclaration); - m_MatchedRules.clear(); - } - return matchedDecls.GetSize(); -} - -void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache, - FDE_CSSRuleData* pList, - FDE_CSSPERSUDO ePersudoType) { - while (pList) { - if (MatchSelector(pCache, pList->pSelector, ePersudoType)) - m_MatchedRules.push_back(pList); - pList = pList->pNext; - } -} - -FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, - IFDE_CSSSelector* pSel, - FDE_CSSPERSUDO ePersudoType) { - FX_DWORD dwHash; - while (pSel != NULL && pCache != NULL) { - switch (pSel->GetType()) { - case FDE_CSSSELECTORTYPE_Descendant: - dwHash = pSel->GetNameHash(); - while ((pCache = pCache->GetParent()) != NULL) { - if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { - continue; - } - if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) { - return TRUE; - } - } - return FALSE; - case FDE_CSSSELECTORTYPE_ID: - dwHash = pCache->HashID(); - if (dwHash != pSel->GetNameHash()) { - return FALSE; - } - break; - case FDE_CSSSELECTORTYPE_Class: - dwHash = pCache->HashClass(); - if (dwHash != pSel->GetNameHash()) { - return FALSE; - } - break; - case FDE_CSSSELECTORTYPE_Element: - dwHash = pSel->GetNameHash(); - if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { - return FALSE; - } - break; - case FDE_CSSSELECTORTYPE_Persudo: - dwHash = FDE_GetCSSPersudoByEnum(ePersudoType)->dwHash; - if (dwHash != pSel->GetNameHash()) { - return FALSE; - } - break; - default: - FXSYS_assert(FALSE); - break; - } - pSel = pSel->GetNextSelector(); - } - return pSel == NULL && pCache != NULL; -} - -void CFDE_CSSStyleSelector::ComputeStyle( - IFDE_CSSTagProvider* pTag, - const IFDE_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); - } - CFDE_CSSDeclaration* pDecl = NULL; - CFX_WideStringC wsAttri, wsValue; - FX_DWORD dwAttriHash; - do { - pTag->GetNextAttribute(pos, wsAttri, wsValue); - dwAttriHash = - FX_HashCode_String_GetW(wsAttri.GetPtr(), wsAttri.GetLength(), TRUE); - static const FX_DWORD s_dwStyleHash = - FX_HashCode_String_GetW(L"style", 5, TRUE); - static const FX_DWORD s_dwAlignHash = - FX_HashCode_String_GetW(L"align", 5, TRUE); - if (dwAttriHash == s_dwStyleHash) { - if (pDecl == NULL) { - pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; - } - AppendInlineStyle(pDecl, wsValue.GetPtr(), wsValue.GetLength()); - } else if (dwAttriHash == s_dwAlignHash) { - if (pDecl == NULL) { - pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; - } - FDE_CSSPROPERTYARGS args; - args.pStringCache = NULL; - args.pStaticStore = m_pInlineStyleStore; - args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); - pDecl->AddProperty(&args, wsValue.GetPtr(), wsValue.GetLength()); - } - } while (pos != NULL); - if (pDecl != NULL) { - CFDE_CSSDeclarationArray decls; - decls.SetSize(iDeclCount + 1); - IFDE_CSSDeclaration** ppInline = decls.GetData(); - FXSYS_memcpy(ppInline, ppDeclArray, - iDeclCount * sizeof(IFDE_CSSDeclaration*)); - ppInline[iDeclCount++] = pDecl; - ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount, - pDestStyle); - ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline, - iDeclCount, pDestStyle); - return; - } - } - if (iDeclCount > 0) { - FXSYS_assert(ppDeclArray != NULL); - ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle); - ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle); - } -} -void CFDE_CSSStyleSelector::ApplyDeclarations( - FX_BOOL bPriority, - const IFDE_CSSDeclaration** ppDeclArray, - int32_t iDeclCount, - IFDE_CSSComputedStyle* pDestStyle) { - CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; - IFDE_CSSValue* pVal; - FX_BOOL bImportant; - int32_t i; - if (bPriority) { - IFDE_CSSValue *pLastest = NULL, *pImportant = NULL; - for (i = 0; i < iDeclCount; ++i) { - pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant); - if (pVal == NULL) { - continue; - } else if (bImportant) { - pImportant = pVal; - } else { - pLastest = pVal; - } - } - if (pImportant) { - ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle); - } else if (pLastest) { - ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle); - } - } else { - CFDE_CSSDeclarationArray importants; - const IFDE_CSSDeclaration* pDecl = NULL; - FDE_CSSPROPERTY eProp; - FX_POSITION pos; - for (i = 0; i < iDeclCount; ++i) { - pDecl = ppDeclArray[i]; - pos = pDecl->GetStartPosition(); - while (pos != NULL) { - pDecl->GetNextProperty(pos, eProp, pVal, bImportant); - if (eProp == FDE_CSSPROPERTY_FontSize) { - continue; - } else if (!bImportant) { - ApplyProperty(eProp, pVal, pComputedStyle); - } else if (importants.GetSize() == 0 || - importants[importants.GetUpperBound()] != pDecl) { - importants.Add((IFDE_CSSDeclaration*)pDecl); - } - } - } - iDeclCount = importants.GetSize(); - for (i = 0; i < iDeclCount; ++i) { - pDecl = importants[i]; - pos = pDecl->GetStartPosition(); - while (pos != NULL) { - pDecl->GetNextProperty(pos, eProp, pVal, bImportant); - if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) { - ApplyProperty(eProp, pVal, pComputedStyle); - } - } - } - CFX_WideString wsName, wsValue; - pos = pDecl->GetStartCustom(); - while (pos) { - pDecl->GetNextCustom(pos, wsName, wsValue); - pComputedStyle->AddCustomStyle(wsName, wsValue); - } - } -} -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) { - 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); - } - } - } else { - break; - } - } - } - pSyntax->Release(); -} -#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData) -#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData) -#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize) -void CFDE_CSSStyleSelector::ApplyProperty( - FDE_CSSPROPERTY eProperty, - IFDE_CSSValue* pValue, - CFDE_CSSComputedStyle* pComputedStyle) { - if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { - IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; - FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); - switch (eProperty) { - case FDE_CSSPROPERTY_Display: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eDisplay = ToDisplay(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_FontSize: { - FX_FLOAT& fFontSize = FDE_CSSFONTSIZE; - if (eType >= FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - fFontSize = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); - } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - fFontSize = ToFontSize(pPrimitive->GetEnum(), fFontSize); - } - } break; - case FDE_CSSPROPERTY_LineHeight: - if (eType == FDE_CSSPRIMITIVETYPE_Number) { - FDE_CSSINHERITS.m_fLineHeight = - pPrimitive->GetFloat() * FDE_CSSFONTSIZE; - } else if (eType > FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - FDE_CSSINHERITS.m_fLineHeight = - ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); - } - break; - case FDE_CSSPROPERTY_TextAlign: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eTextAligh = ToTextAlign(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_TextIndent: - SetLengthWithPercent(FDE_CSSINHERITS.m_TextIndent, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_FontWeight: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_wFontWeight = ToFontWeight(pPrimitive->GetEnum()); - } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { - int32_t iValue = (int32_t)pPrimitive->GetFloat() / 100; - if (iValue >= 1 && iValue <= 9) { - FDE_CSSINHERITS.m_wFontWeight = iValue * 100; - } - } - break; - case FDE_CSSPROPERTY_FontStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eFontStyle = ToFontStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_Color: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSINHERITS.m_dwFontColor = pPrimitive->GetRGBColor(); - } - break; - case FDE_CSSPROPERTY_MarginLeft: - FDE_CSSNONINHERITS.m_bHasMargin |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.left, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MarginTop: - FDE_CSSNONINHERITS.m_bHasMargin |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.top, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MarginRight: - FDE_CSSNONINHERITS.m_bHasMargin |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.right, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MarginBottom: - FDE_CSSNONINHERITS.m_bHasMargin |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.bottom, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_PaddingLeft: - FDE_CSSNONINHERITS.m_bHasPadding |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.left, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_PaddingTop: - FDE_CSSNONINHERITS.m_bHasPadding |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.top, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_PaddingRight: - FDE_CSSNONINHERITS.m_bHasPadding |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.right, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_PaddingBottom: - FDE_CSSNONINHERITS.m_bHasPadding |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.bottom, - eType, pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BorderLeftWidth: - FDE_CSSNONINHERITS.m_bHasBorder |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.left, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BorderTopWidth: - FDE_CSSNONINHERITS.m_bHasBorder |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.top, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BorderRightWidth: - FDE_CSSNONINHERITS.m_bHasBorder |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.right, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BorderBottomWidth: - FDE_CSSNONINHERITS.m_bHasBorder |= - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.bottom, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BorderLeftStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBDRLeftStyle = - ToBorderStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BorderTopStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBDRTopStyle = - ToBorderStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BorderRightStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBDRRightStyle = - ToBorderStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BorderBottomStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBDRBottomStyle = - ToBorderStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BorderLeftColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwBDRLeftColor = pPrimitive->GetRGBColor(); - } - break; - case FDE_CSSPROPERTY_BorderTopColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwBDRTopColor = pPrimitive->GetRGBColor(); - } - break; - case FDE_CSSPROPERTY_BorderRightColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwBDRRightColor = pPrimitive->GetRGBColor(); - } - break; - case FDE_CSSPROPERTY_BorderBottomColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwBDRBottomColor = pPrimitive->GetRGBColor(); - } - break; - case FDE_CSSPROPERTY_ListStyleType: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eListStyleType = - ToListStyleType(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_ListStylePosition: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eListStylePosition = - ToListStylePosition(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BackgroundColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwBKGColor = pPrimitive->GetRGBColor(); - } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_dwBKGColor = 0; - } - break; - case FDE_CSSPROPERTY_Visibility: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eVisibility = ToVisibility(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_Width: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cx, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_Height: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cy, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MinWidth: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cx, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MinHeight: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cy, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MaxWidth: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cx, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_MaxHeight: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cy, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_VerticalAlign: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eVerticalAlign = - ToVerticalAlign(pPrimitive->GetEnum()); - } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - FDE_CSSNONINHERITS.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number; - FDE_CSSNONINHERITS.m_fVerticalAlign = - ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); - } - break; - case FDE_CSSPROPERTY_WhiteSpace: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eWhiteSpace = ToWhiteSpace(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_TextTransform: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eTextTransform = - ToTextTransform(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_FontVariant: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eFontVariant = ToFontVariant(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_LetterSpacing: - if (eType == FDE_CSSPRIMITIVETYPE_Percent) { - break; - } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - SetLengthWithPercent(FDE_CSSINHERITS.m_LetterSpacing, eType, - pPrimitive, FDE_CSSFONTSIZE); - } - break; - case FDE_CSSPROPERTY_WordSpacing: - if (eType == FDE_CSSPRIMITIVETYPE_Percent) { - break; - } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - SetLengthWithPercent(FDE_CSSINHERITS.m_WordSpacing, eType, pPrimitive, - FDE_CSSFONTSIZE); - } - break; - case FDE_CSSPROPERTY_Float: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eFloat = ToFloat(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_Clear: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eClear = ToClear(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_WritingMode: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eWritingMode = ToWritingMode(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_WordBreak: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eWordBreak = ToWordBreak(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_Widows: - if (eType == FDE_CSSPRIMITIVETYPE_Number) { - FDE_CSSINHERITS.m_iWidows = (int32_t)pPrimitive->GetFloat(); - } - break; - case FDE_CSSPROPERTY_Orphans: - if (eType == FDE_CSSPRIMITIVETYPE_Number) { - FDE_CSSINHERITS.m_iOrphans = (int32_t)pPrimitive->GetFloat(); - } - break; - case FDE_CSSPROPERTY_TextEmphasisColor: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - switch (pPrimitive->GetEnum()) { - case FDE_CSSPROPERTYVALUE_Transparent: - FDE_CSSINHERITS.m_dwTextEmphasisColor = 0; - FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; - break; - case FDE_CSSPROPERTYVALUE_Currentcolor: - FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = TRUE; - break; - default: - break; - } - } else if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSINHERITS.m_dwTextEmphasisColor = pPrimitive->GetRGBColor(); - FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; - } - break; - case FDE_CSSPROPERTY_PageBreakBefore: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_ePageBreakBefore = - ToPageBreak(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_PageBreakAfter: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_ePageBreakAfter = - ToPageBreak(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_PageBreakInside: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_ePageBreakInside = - ToPageBreak(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_OverflowX: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eOverflowX = ToOverflow(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_OverflowY: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eOverflowY = ToOverflow(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_LineBreak: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eLineBreak = ToLineBreak(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_ColumnCount: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); - } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { - FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Point, - pPrimitive->GetFloat()); - } - break; - case FDE_CSSPROPERTY_ColumnGap: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnGap, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_ColumnRuleColor: - if (eType == FDE_CSSPRIMITIVETYPE_RGB) { - FDE_CSSNONINHERITS.m_dwColumnRuleColor = pPrimitive->GetRGBColor(); - FDE_CSSNONINHERITS.m_bColumnRuleColorSame = FALSE; - } - break; - case FDE_CSSPROPERTY_ColumnRuleStyle: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eColumnRuleStyle = - ToBorderStyle(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_ColumnRuleWidth: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_ColumnWidth: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType, - pPrimitive, FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_BackgroundImage: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_pszBKGImage = NULL; - } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { - int32_t iLength; - FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength); - } - break; - case FDE_CSSPROPERTY_Position: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_Top: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_Bottom: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_Left: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_Right: - SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive, - FDE_CSSFONTSIZE); - break; - case FDE_CSSPROPERTY_ListStyleImage: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_pszListStyleImage = NULL; - } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { - int32_t iLength; - FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength); - } - break; - case FDE_CSSPROPERTY_CaptionSide: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BackgroundRepeat: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBKGRepeat = ToBKGRepeat(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_BackgroundAttachment: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSNONINHERITS.m_eBKGAttachment = - ToBKGAttachment(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_RubyAlign: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eRubyAlign = ToRubyAlign(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_RubyOverhang: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eRubyOverhang = - ToRubyOverhang(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_RubyPosition: - if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - FDE_CSSINHERITS.m_eRubyPosition = - ToRubyPosition(pPrimitive->GetEnum()); - } - break; - case FDE_CSSPROPERTY_RubySpan: - FDE_CSSNONINHERITS.m_pRubySpan = pPrimitive; - break; - default: - break; - } - } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) { - IFDE_CSSValueList* pList = (IFDE_CSSValueList*)pValue; - int32_t iCount = pList->CountValues(); - if (iCount > 0) { - switch (eProperty) { - case FDE_CSSPROPERTY_FontFamily: - FDE_CSSINHERITS.m_pFontFamily = pList; - break; - case FDE_CSSPROPERTY_TextDecoration: - FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList); - break; - case FDE_CSSPROPERTY_CounterIncrement: { - if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { - FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; - } - FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList); - } break; - case FDE_CSSPROPERTY_CounterReset: { - if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { - FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; - } - FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList); - } break; - case FDE_CSSPROPERTY_Content: - FDE_CSSNONINHERITS.m_pContentList = pList; - break; - case FDE_CSSPROPERTY_Quotes: - FDE_CSSINHERITS.m_pQuotes = pList; - break; - case FDE_CSSPROPERTY_TextCombine: { - for (int32_t i = 0; i < pList->CountValues(); i++) { - IFDE_CSSPrimitiveValue* pVal = - (IFDE_CSSPrimitiveValue*)pList->GetValue(i); - switch (pVal->GetPrimitiveType()) { - case FDE_CSSPRIMITIVETYPE_Enum: { - switch (pVal->GetEnum()) { - case FDE_CSSPROPERTYVALUE_None: { - FDE_CSSNONINHERITS.m_eTextCombine = FDE_CSSTEXTCOMBINE_None; - FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; - } break; - case FDE_CSSPROPERTYVALUE_Horizontal: { - FDE_CSSNONINHERITS.m_eTextCombine = - FDE_CSSTEXTCOMBINE_Horizontal; - FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; - } break; - default: - break; - } - } break; - case FDE_CSSPRIMITIVETYPE_Number: - FDE_CSSNONINHERITS.m_fTextCombineNumber = pVal->GetFloat(); - break; - default: - break; - } - } - } break; - case FDE_CSSPROPERTY_TextEmphasisStyle: { - FDE_CSSTEXTEMPHASISFILL eFill; - FDE_CSSTEXTEMPHASISMARK eMark; - for (int32_t i = 0; i < pList->CountValues(); i++) { - IFDE_CSSPrimitiveValue* pVal = - (IFDE_CSSPrimitiveValue*)pList->GetValue(i); - switch (pVal->GetPrimitiveType()) { - case FDE_CSSPRIMITIVETYPE_Enum: { - if (ToTextEmphasisFill(pVal->GetEnum(), eFill)) { - FDE_CSSINHERITS.m_eTextEmphasisFill = eFill; - continue; - } else if (ToTextEmphasisMark(pVal->GetEnum(), eMark)) { - FDE_CSSINHERITS.m_eTextEmphasisMark = eMark; - } - } break; - case FDE_CSSPRIMITIVETYPE_String: { - FDE_CSSINHERITS.m_eTextEmphasisMark = - FDE_CSSTEXTEMPHASISMARK_Custom; - int32_t iLen; - FDE_CSSINHERITS.m_pszTextEmphasisCustomMark = - pVal->GetString(iLen); - } break; - default: - break; - } - } - } break; - default: - break; - } - } - } else { - FXSYS_assert(FALSE); - } -} -FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, - FX_FLOAT fValue, - FX_FLOAT fPercentBase) { - switch (eUnit) { - case FDE_CSSPRIMITIVETYPE_PX: - case FDE_CSSPRIMITIVETYPE_Number: - return fValue * 72 / 96; - case FDE_CSSPRIMITIVETYPE_PT: - return fValue; - case FDE_CSSPRIMITIVETYPE_EMS: - case FDE_CSSPRIMITIVETYPE_EXS: - return fValue * fPercentBase; - case FDE_CSSPRIMITIVETYPE_Percent: - return fValue * fPercentBase / 100.0f; - case FDE_CSSPRIMITIVETYPE_CM: - return fValue * 28.3464f; - case FDE_CSSPRIMITIVETYPE_MM: - return fValue * 2.8346f; - case FDE_CSSPRIMITIVETYPE_IN: - return fValue * 72.0f; - case FDE_CSSPRIMITIVETYPE_PC: - return fValue / 12.0f; - default: - return fValue; - } -} -FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - default: - return FDE_CSSRUBYSPAN_None; - } -} -FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Before: - return FDE_CSSRUBYPOSITION_Before; - case FDE_CSSPROPERTYVALUE_After: - return FDE_CSSRUBYPOSITION_After; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSRUBYPOSITION_Right; - case FDE_CSSPROPERTYVALUE_Inline: - return FDE_CSSRUBYPOSITION_Inline; - default: - return FDE_CSSRUBYPOSITION_Before; - } -} -FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSRUBYOVERHANG_Auto; - case FDE_CSSPROPERTYVALUE_Start: - return FDE_CSSRUBYOVERHANG_Start; - case FDE_CSSPROPERTYVALUE_End: - return FDE_CSSRUBYOVERHANG_End; - case FDE_CSSPROPERTYVALUE_None: - default: - return FDE_CSSRUBYOVERHANG_None; - } -} -FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSRUBYALIGN_Auto; - case FDE_CSSPROPERTYVALUE_Start: - return FDE_CSSRUBYALIGN_Start; - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSRUBYALIGN_End; - case FDE_CSSPROPERTYVALUE_Center: - return FDE_CSSRUBYALIGN_Center; - case FDE_CSSPROPERTYVALUE_End: - return FDE_CSSRUBYALIGN_End; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSRUBYALIGN_Right; - case FDE_CSSPROPERTYVALUE_DistributeLetter: - return FDE_CSSRUBYALIGN_DistributeLetter; - case FDE_CSSPROPERTYVALUE_DistributeSpace: - return FDE_CSSRUBYALIGN_DistributeSpace; - case FDE_CSSPROPERTYVALUE_LineEdge: - return FDE_CSSRUBYALIGN_LineEdge; - default: - return FDE_CSSRUBYALIGN_Auto; - } -} -FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark( - FDE_CSSPROPERTYVALUE eValue, - FDE_CSSTEXTEMPHASISMARK& eMark) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - eMark = FDE_CSSTEXTEMPHASISMARK_None; - return TRUE; - case FDE_CSSPROPERTYVALUE_Dot: - eMark = FDE_CSSTEXTEMPHASISMARK_Dot; - return TRUE; - case FDE_CSSPROPERTYVALUE_Circle: - eMark = FDE_CSSTEXTEMPHASISMARK_Circle; - return TRUE; - case FDE_CSSPROPERTYVALUE_DoubleCircle: - eMark = FDE_CSSTEXTEMPHASISMARK_DoubleCircle; - return TRUE; - case FDE_CSSPROPERTYVALUE_Triangle: - eMark = FDE_CSSTEXTEMPHASISMARK_Triangle; - return TRUE; - case FDE_CSSPROPERTYVALUE_Sesame: - eMark = FDE_CSSTEXTEMPHASISMARK_Sesame; - return TRUE; - default: - return FALSE; - } -} -FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill( - FDE_CSSPROPERTYVALUE eValue, - FDE_CSSTEXTEMPHASISFILL& eFill) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Filled: - eFill = FDE_CSSTEXTEMPHASISFILL_Filled; - return TRUE; - case FDE_CSSPROPERTYVALUE_Open: - eFill = FDE_CSSTEXTEMPHASISFILL_Open; - return TRUE; - default: - return FALSE; - } -} -FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Fixed: - return FDE_CSSBKGATTACHMENT_Fixed; - case FDE_CSSPROPERTYVALUE_Scroll: - return FDE_CSSBKGATTACHMENT_Scroll; - default: - return FDE_CSSBKGATTACHMENT_Fixed; - } -} -FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Top: - return FDE_CSSCAPTIONSIDE_Top; - case FDE_CSSPROPERTYVALUE_Bottom: - return FDE_CSSCAPTIONSIDE_Bottom; - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSCAPTIONSIDE_Left; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSCAPTIONSIDE_Right; - case FDE_CSSPROPERTYVALUE_Before: - return FDE_CSSCAPTIONSIDE_Before; - case FDE_CSSPROPERTYVALUE_After: - return FDE_CSSCAPTIONSIDE_After; - default: - return FDE_CSSCAPTIONSIDE_Top; - } -} -FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Static: - return FDE_CSSPOSITION_Static; - case FDE_CSSPROPERTYVALUE_Relative: - return FDE_CSSPOSITION_Relative; - case FDE_CSSPROPERTYVALUE_Fixed: - return FDE_CSSPOSITION_Fixed; - case FDE_CSSPROPERTYVALUE_Absolute: - return FDE_CSSPOSITION_Absolute; - default: - return FDE_CSSPOSITION_Static; - } -} -FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSCURSOR_Auto; - case FDE_CSSPROPERTYVALUE_Crosshair: - return FDE_CSSCURSOR_Crosshair; - case FDE_CSSPROPERTYVALUE_Default: - return FDE_CSSCURSOR_Default; - case FDE_CSSPROPERTYVALUE_Pointer: - return FDE_CSSCURSOR_Pointer; - case FDE_CSSPROPERTYVALUE_Move: - return FDE_CSSCURSOR_Move; - case FDE_CSSPROPERTYVALUE_EResize: - return FDE_CSSCURSOR_EResize; - case FDE_CSSPROPERTYVALUE_NeResize: - return FDE_CSSCURSOR_NeResize; - case FDE_CSSPROPERTYVALUE_NwResize: - return FDE_CSSCURSOR_NwResize; - case FDE_CSSPROPERTYVALUE_NResize: - return FDE_CSSCURSOR_NResize; - case FDE_CSSPROPERTYVALUE_SeResize: - return FDE_CSSCURSOR_SeResize; - case FDE_CSSPROPERTYVALUE_SwResize: - return FDE_CSSCURSOR_SwResize; - default: - return FDE_CSSCURSOR_Auto; - } -} -FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Repeat: - return FDE_CSSBKGREPEAT_Repeat; - case FDE_CSSPROPERTYVALUE_RepeatX: - return FDE_CSSBKGREPEAT_RepeatX; - case FDE_CSSPROPERTYVALUE_RepeatY: - return FDE_CSSBKGREPEAT_RepeatY; - case FDE_CSSPROPERTYVALUE_NoRepeat: - return FDE_CSSBKGREPEAT_NoRepeat; - default: - return FDE_CSSBKGREPEAT_Repeat; - } -} -FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Horizontal: - return FDE_CSSTEXTCOMBINE_Horizontal; - case FDE_CSSPROPERTYVALUE_None: - default: - return FDE_CSSTEXTCOMBINE_None; - } -} -FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSLINEBREAK_Auto; - case FDE_CSSPROPERTYVALUE_Loose: - return FDE_CSSLINEBREAK_Loose; - case FDE_CSSPROPERTYVALUE_Normal: - return FDE_CSSLINEBREAK_Normal; - case FDE_CSSPROPERTYVALUE_Strict: - return FDE_CSSLINEBREAK_Strict; - default: - return FDE_CSSLINEBREAK_Auto; - } -} -FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Visible: - return FDE_CSSOVERFLOW_Visible; - case FDE_CSSPROPERTYVALUE_Hidden: - return FDE_CSSOVERFLOW_Hidden; - case FDE_CSSPROPERTYVALUE_Scroll: - return FDE_CSSOVERFLOW_Scroll; - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSOVERFLOW_Auto; - case FDE_CSSPROPERTYVALUE_NoDisplay: - return FDE_CSSOVERFLOW_NoDisplay; - case FDE_CSSPROPERTYVALUE_NoContent: - return FDE_CSSOVERFLOW_NoContent; - default: - return FDE_CSSOVERFLOW_Visible; - } -} -FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_HorizontalTb: - return FDE_CSSWRITINGMODE_HorizontalTb; - case FDE_CSSPROPERTYVALUE_VerticalRl: - return FDE_CSSWRITINGMODE_VerticalRl; - case FDE_CSSPROPERTYVALUE_VerticalLr: - return FDE_CSSWRITINGMODE_VerticalLr; - default: - return FDE_CSSWRITINGMODE_HorizontalTb; - } -} -FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Normal: - return FDE_CSSWORDBREAK_Normal; - case FDE_CSSPROPERTYVALUE_KeepAll: - return FDE_CSSWORDBREAK_KeepAll; - case FDE_CSSPROPERTYVALUE_BreakAll: - return FDE_CSSWORDBREAK_BreakAll; - case FDE_CSSPROPERTYVALUE_KeepWords: - return FDE_CSSWORDBREAK_KeepWords; - default: - return FDE_CSSWORDBREAK_Normal; - } -} -FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSFLOAT_Left; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSFLOAT_Right; - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSFLOAT_None; - default: - return FDE_CSSFLOAT_None; - } -} -FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSCLEAR_None; - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSCLEAR_Left; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSCLEAR_Right; - case FDE_CSSPROPERTYVALUE_Both: - return FDE_CSSCLEAR_Both; - default: - return FDE_CSSCLEAR_None; - } -} -FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Avoid: - return FDE_CSSPAGEBREAK_Avoid; - case FDE_CSSPROPERTYVALUE_Auto: - return FDE_CSSPAGEBREAK_Auto; - case FDE_CSSPROPERTYVALUE_Always: - return FDE_CSSPAGEBREAK_Always; - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSPAGEBREAK_Left; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSPAGEBREAK_Right; - default: - return FDE_CSSPAGEBREAK_Auto; - } -} -FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Inline: - return FDE_CSSDISPLAY_Inline; - case FDE_CSSPROPERTYVALUE_Block: - return FDE_CSSDISPLAY_Block; - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSDISPLAY_None; - case FDE_CSSPROPERTYVALUE_ListItem: - return FDE_CSSDISPLAY_ListItem; - case FDE_CSSPROPERTYVALUE_TableCell: - return FDE_CSSDISPLAY_TableCell; - case FDE_CSSPROPERTYVALUE_TableRow: - return FDE_CSSDISPLAY_TableRow; - case FDE_CSSPROPERTYVALUE_Table: - return FDE_CSSDISPLAY_Table; - case FDE_CSSPROPERTYVALUE_TableCaption: - return FDE_CSSDISPLAY_TableCaption; - case FDE_CSSPROPERTYVALUE_TableRowGroup: - return FDE_CSSDISPLAY_TableRowGroup; - case FDE_CSSPROPERTYVALUE_TableHeaderGroup: - return FDE_CSSDISPLAY_TableHeaderGroup; - case FDE_CSSPROPERTYVALUE_TableFooterGroup: - return FDE_CSSDISPLAY_TableFooterGroup; - case FDE_CSSPROPERTYVALUE_TableColumnGroup: - return FDE_CSSDISPLAY_TableColumnGroup; - case FDE_CSSPROPERTYVALUE_TableColumn: - return FDE_CSSDISPLAY_TableColumn; - case FDE_CSSPROPERTYVALUE_InlineTable: - return FDE_CSSDISPLAY_InlineTable; - case FDE_CSSPROPERTYVALUE_InlineBlock: - return FDE_CSSDISPLAY_InlineBlock; - case FDE_CSSPROPERTYVALUE_RunIn: - return FDE_CSSDISPLAY_RunIn; - case FDE_CSSPROPERTYVALUE_Ruby: - return FDE_CSSDISPLAY_Ruby; - case FDE_CSSPROPERTYVALUE_RubyBase: - return FDE_CSSDISPLAY_RubyBase; - case FDE_CSSPROPERTYVALUE_RubyText: - return FDE_CSSDISPLAY_RubyText; - case FDE_CSSPROPERTYVALUE_RubyBaseGroup: - return FDE_CSSDISPLSY_RubyBaseGroup; - case FDE_CSSPROPERTYVALUE_RubyTextGroup: - return FDE_CSSDISPLAY_RubyTextGroup; - default: - return FDE_CSSDISPLAY_Inline; - } -} -FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Left: - return FDE_CSSTEXTALIGN_Left; - case FDE_CSSPROPERTYVALUE_Center: - return FDE_CSSTEXTALIGN_Center; - case FDE_CSSPROPERTYVALUE_Right: - return FDE_CSSTEXTALIGN_Right; - case FDE_CSSPROPERTYVALUE_Justify: - return FDE_CSSTEXTALIGN_Justify; - default: - return FDE_CSSTEXTALIGN_Left; - } -} -FX_WORD CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Normal: - return 400; - case FDE_CSSPROPERTYVALUE_Bold: - return 700; - case FDE_CSSPROPERTYVALUE_Bolder: - return 900; - case FDE_CSSPROPERTYVALUE_Lighter: - return 200; - default: - return 400; - } -} -FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Italic: - case FDE_CSSPROPERTYVALUE_Oblique: - return FDE_CSSFONTSTYLE_Italic; - default: - return FDE_CSSFONTSTYLE_Normal; - } -} -FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSBORDERSTYLE_None; - case FDE_CSSPROPERTYVALUE_Solid: - return FDE_CSSBORDERSTYLE_Solid; - case FDE_CSSPROPERTYVALUE_Hidden: - return FDE_CSSBORDERSTYLE_Hidden; - case FDE_CSSPROPERTYVALUE_Dotted: - return FDE_CSSBORDERSTYLE_Dotted; - case FDE_CSSPROPERTYVALUE_Dashed: - return FDE_CSSBORDERSTYLE_Dashed; - case FDE_CSSPROPERTYVALUE_Double: - return FDE_CSSBORDERSTYLE_Double; - case FDE_CSSPROPERTYVALUE_Groove: - return FDE_CSSBORDERSTYLE_Groove; - case FDE_CSSPROPERTYVALUE_Ridge: - return FDE_CSSBORDERSTYLE_Ridge; - case FDE_CSSPROPERTYVALUE_Inset: - return FDE_CSSBORDERSTYLE_Inset; - case FDE_CSSPROPERTYVALUE_Outset: - return FDE_CSSBORDERSTYLE_outset; - default: - return FDE_CSSBORDERSTYLE_None; - } -} -FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent( - FDE_CSSLENGTH& width, - FDE_CSSPRIMITIVETYPE eType, - IFDE_CSSPrimitiveValue* pPrimitive, - FX_FLOAT fFontSize) { - if (eType == FDE_CSSPRIMITIVETYPE_Percent) { - width.Set(FDE_CSSLENGTHUNIT_Percent, pPrimitive->GetFloat() / 100.0f); - return width.NonZero(); - } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && - eType <= FDE_CSSPRIMITIVETYPE_PC) { - FX_FLOAT fValue = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); - width.Set(FDE_CSSLENGTHUNIT_Point, fValue); - return width.NonZero(); - } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { - switch (pPrimitive->GetEnum()) { - case FDE_CSSPROPERTYVALUE_Auto: - width.Set(FDE_CSSLENGTHUNIT_Auto); - return TRUE; - case FDE_CSSPROPERTYVALUE_None: - width.Set(FDE_CSSLENGTHUNIT_None); - return TRUE; - case FDE_CSSPROPERTYVALUE_Thin: - width.Set(FDE_CSSLENGTHUNIT_Point, 2); - return TRUE; - case FDE_CSSPROPERTYVALUE_Medium: - width.Set(FDE_CSSLENGTHUNIT_Point, 3); - return TRUE; - case FDE_CSSPROPERTYVALUE_Thick: - width.Set(FDE_CSSLENGTHUNIT_Point, 4); - return TRUE; - default: - return FALSE; - } - } - return FALSE; -} -FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue, - FX_FLOAT fCurFontSize) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_XxSmall: - return m_fDefFontSize / 1.2f / 1.2f / 1.2f; - case FDE_CSSPROPERTYVALUE_XSmall: - return m_fDefFontSize / 1.2f / 1.2f; - case FDE_CSSPROPERTYVALUE_Small: - return m_fDefFontSize / 1.2f; - case FDE_CSSPROPERTYVALUE_Medium: - return m_fDefFontSize; - case FDE_CSSPROPERTYVALUE_Large: - return m_fDefFontSize * 1.2f; - case FDE_CSSPROPERTYVALUE_XLarge: - return m_fDefFontSize * 1.2f * 1.2f; - case FDE_CSSPROPERTYVALUE_XxLarge: - return m_fDefFontSize * 1.2f * 1.2f * 1.2f; - case FDE_CSSPROPERTYVALUE_Larger: - return fCurFontSize * 1.2f; - case FDE_CSSPROPERTYVALUE_Smaller: - return fCurFontSize / 1.2f; - default: - return fCurFontSize; - } -} -FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Baseline: - return FDE_CSSVERTICALALIGN_Baseline; - case FDE_CSSPROPERTYVALUE_Middle: - return FDE_CSSVERTICALALIGN_Middle; - case FDE_CSSPROPERTYVALUE_Bottom: - return FDE_CSSVERTICALALIGN_Bottom; - case FDE_CSSPROPERTYVALUE_Super: - return FDE_CSSVERTICALALIGN_Super; - case FDE_CSSPROPERTYVALUE_Sub: - return FDE_CSSVERTICALALIGN_Sub; - case FDE_CSSPROPERTYVALUE_Top: - return FDE_CSSVERTICALALIGN_Top; - case FDE_CSSPROPERTYVALUE_TextTop: - return FDE_CSSVERTICALALIGN_TextTop; - case FDE_CSSPROPERTYVALUE_TextBottom: - return FDE_CSSVERTICALALIGN_TextBottom; - default: - return FDE_CSSVERTICALALIGN_Baseline; - } -} -FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSLISTSTYLETYPE_None; - case FDE_CSSPROPERTYVALUE_Disc: - return FDE_CSSLISTSTYLETYPE_Disc; - case FDE_CSSPROPERTYVALUE_Circle: - return FDE_CSSLISTSTYLETYPE_Circle; - case FDE_CSSPROPERTYVALUE_Square: - return FDE_CSSLISTSTYLETYPE_Square; - case FDE_CSSPROPERTYVALUE_Decimal: - return FDE_CSSLISTSTYLETYPE_Decimal; - case FDE_CSSPROPERTYVALUE_DecimalLeadingZero: - return FDE_CSSLISTSTYLETYPE_DecimalLeadingZero; - case FDE_CSSPROPERTYVALUE_LowerRoman: - return FDE_CSSLISTSTYLETYPE_LowerRoman; - case FDE_CSSPROPERTYVALUE_UpperRoman: - return FDE_CSSLISTSTYLETYPE_UpperRoman; - case FDE_CSSPROPERTYVALUE_LowerGreek: - return FDE_CSSLISTSTYLETYPE_LowerGreek; - case FDE_CSSPROPERTYVALUE_LowerLatin: - return FDE_CSSLISTSTYLETYPE_LowerLatin; - case FDE_CSSPROPERTYVALUE_UpperLatin: - return FDE_CSSLISTSTYLETYPE_UpperLatin; - case FDE_CSSPROPERTYVALUE_Armenian: - return FDE_CSSLISTSTYLETYPE_Armenian; - case FDE_CSSPROPERTYVALUE_Georgian: - return FDE_CSSLISTSTYLETYPE_Georgian; - case FDE_CSSPROPERTYVALUE_LowerAlpha: - return FDE_CSSLISTSTYLETYPE_LowerAlpha; - case FDE_CSSPROPERTYVALUE_UpperAlpha: - return FDE_CSSLISTSTYLETYPE_UpperAlpha; - case FDE_CSSPROPERTYVALUE_CjkIdeographic: - return FDE_CSSLISTSTYLETYPE_CjkIdeographic; - case FDE_CSSPROPERTYVALUE_Hebrew: - return FDE_CSSLISTSTYLETYPE_Hebrew; - case FDE_CSSLISTSTYLETYPE_Hiragana: - return FDE_CSSLISTSTYLETYPE_Hiragana; - case FDE_CSSLISTSTYLETYPE_HiraganaIroha: - return FDE_CSSLISTSTYLETYPE_HiraganaIroha; - case FDE_CSSLISTSTYLETYPE_Katakana: - return FDE_CSSLISTSTYLETYPE_Katakana; - case FDE_CSSLISTSTYLETYPE_KatakanaIroha: - return FDE_CSSLISTSTYLETYPE_KatakanaIroha; - default: - return FDE_CSSLISTSTYLETYPE_Disc; - } -} -FDE_CSSLISTSTYLEPOSITION CFDE_CSSStyleSelector::ToListStylePosition( - FDE_CSSPROPERTYVALUE eValue) { - return eValue == FDE_CSSPROPERTYVALUE_Inside - ? FDE_CSSLISTSTYLEPOSITION_Inside - : FDE_CSSLISTSTYLEPOSITION_Outside; -} -FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Visible: - return FDE_CSSVISIBILITY_Visible; - case FDE_CSSPROPERTYVALUE_Hidden: - return FDE_CSSVISIBILITY_Hidden; - case FDE_CSSPROPERTYVALUE_Collapse: - return FDE_CSSVISIBILITY_Collapse; - default: - return FDE_CSSVISIBILITY_Visible; - } -} -FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_Normal: - return FDE_CSSWHITESPACE_Normal; - case FDE_CSSPROPERTYVALUE_Pre: - return FDE_CSSWHITESPACE_Pre; - case FDE_CSSPROPERTYVALUE_Nowrap: - return FDE_CSSWHITESPACE_Nowrap; - case FDE_CSSPROPERTYVALUE_PreWrap: - return FDE_CSSWHITESPACE_PreWrap; - case FDE_CSSPROPERTYVALUE_PreLine: - return FDE_CSSWHITESPACE_PreLine; - default: - return FDE_CSSWHITESPACE_Normal; - } -} -FX_DWORD CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) { - FX_DWORD dwDecoration = 0; - for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { - IFDE_CSSPrimitiveValue* pPrimitive = - (IFDE_CSSPrimitiveValue*)pValue->GetValue(i); - if (pPrimitive->GetPrimitiveType() == FDE_CSSPRIMITIVETYPE_Enum) { - switch (pPrimitive->GetEnum()) { - case FDE_CSSPROPERTYVALUE_Underline: - dwDecoration |= FDE_CSSTEXTDECORATION_Underline; - break; - case FDE_CSSPROPERTYVALUE_LineThrough: - dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; - break; - case FDE_CSSPROPERTYVALUE_Overline: - dwDecoration |= FDE_CSSTEXTDECORATION_Overline; - break; - case FDE_CSSPROPERTYVALUE_Blink: - dwDecoration |= FDE_CSSTEXTDECORATION_Blink; - break; - case FDE_CSSPROPERTYVALUE_Double: - dwDecoration |= FDE_CSSTEXTDECORATION_Double; - break; - default: - break; - } - } - } - return dwDecoration; -} -FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform( - FDE_CSSPROPERTYVALUE eValue) { - switch (eValue) { - case FDE_CSSPROPERTYVALUE_None: - return FDE_CSSTEXTTRANSFORM_None; - case FDE_CSSPROPERTYVALUE_Capitalize: - return FDE_CSSTEXTTRANSFORM_Capitalize; - case FDE_CSSPROPERTYVALUE_Uppercase: - return FDE_CSSTEXTTRANSFORM_UpperCase; - case FDE_CSSPROPERTYVALUE_Lowercase: - return FDE_CSSTEXTTRANSFORM_LowerCase; - default: - return FDE_CSSTEXTTRANSFORM_None; - } -} -FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( - FDE_CSSPROPERTYVALUE eValue) { - return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps - : FDE_CSSFONTVARIANT_Normal; -} diff --git a/xfa/src/fde/css/fde_cssstyleselector.h b/xfa/src/fde/css/fde_cssstyleselector.h deleted file mode 100644 index 5f5ee095be..0000000000 --- a/xfa/src/fde/css/fde_cssstyleselector.h +++ /dev/null @@ -1,901 +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_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_ - -#include <vector> - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fde/css/fde_css.h" -#include "xfa/src/fde/css/fde_csscache.h" -#include "xfa/src/fde/css/fde_cssdeclaration.h" -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_system.h" - -#define FDE_CSSUNIVERSALHASH ('*') - -class FDE_CSSRuleData : public CFX_Target { - public: - FDE_CSSRuleData(IFDE_CSSSelector* pSel, - IFDE_CSSDeclaration* pDecl, - FX_DWORD dwPos); - - IFDE_CSSSelector* pSelector; - IFDE_CSSDeclaration* pDeclaration; - FX_DWORD dwPriority; - FDE_CSSRuleData* pNext; -}; - -class CFDE_CSSRuleCollection : public CFX_Target { - public: - CFDE_CSSRuleCollection() - : m_pStaticStore(nullptr), - m_pUniversalRules(nullptr), - m_pPersudoRules(nullptr), - m_iSelectors(0) {} - ~CFDE_CSSRuleCollection() { Clear(); } - void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, - FX_DWORD dwMediaList, - IFX_FontMgr* pFontMgr); - void Clear(); - - int32_t CountSelectors() const { return m_iSelectors; } - FDE_CSSRuleData* GetIDRuleData(FX_DWORD dwIDHash) { - void* pData; - return m_IDRules.Lookup((void*)(uintptr_t)dwIDHash, pData) - ? (FDE_CSSRuleData*)pData - : NULL; - } - FDE_CSSRuleData* GetTagRuleData(FX_DWORD dwTagHasn) { - void* pData; - return m_TagRules.Lookup((void*)(uintptr_t)dwTagHasn, pData) - ? (FDE_CSSRuleData*)pData - : NULL; - } - FDE_CSSRuleData* GetClassRuleData(FX_DWORD dwIDHash) { - void* pData; - return m_ClassRules.Lookup((void*)(uintptr_t)dwIDHash, pData) - ? (FDE_CSSRuleData*)pData - : NULL; - } - FDE_CSSRuleData* GetUniversalRuleData() { return m_pUniversalRules; } - FDE_CSSRuleData* GetPersudoRuleData() { return m_pPersudoRules; } - IFX_MEMAllocator* m_pStaticStore; - - protected: - void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, - IFDE_CSSRule* pRule, - FX_DWORD dwMediaList, - IFX_FontMgr* pFontMgr); - void AddRuleTo(CFX_MapPtrToPtr& map, - FX_DWORD dwKey, - IFDE_CSSSelector* pSel, - IFDE_CSSDeclaration* pDecl); - FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData); - FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel, - IFDE_CSSDeclaration* pDecl); - CFX_MapPtrToPtr m_IDRules; - CFX_MapPtrToPtr m_TagRules; - CFX_MapPtrToPtr m_ClassRules; - FDE_CSSRuleData* m_pUniversalRules; - FDE_CSSRuleData* m_pPersudoRules; - int32_t m_iSelectors; -}; -class CFDE_CSSAccelerator; -class CFDE_CSSComputedStyle; -class CFDE_CSSStyleSelector : public IFDE_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(FX_DWORD dwMediaList); - virtual IFDE_CSSAccelerator* InitAccelerator(); - virtual 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); - - protected: - void Reset(); - void MatchRules(FDE_CSSTagCache* pCache, - FDE_CSSRuleData* pList, - FDE_CSSPERSUDO ePersudoType); - FX_BOOL MatchSelector(FDE_CSSTagCache* pCache, - IFDE_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, - int32_t iDeclCount, - IFDE_CSSComputedStyle* pDestStyle); - void ApplyProperty(FDE_CSSPROPERTY eProperty, - IFDE_CSSValue* pValue, - CFDE_CSSComputedStyle* pComputedStyle); - - FX_FLOAT ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, - FX_FLOAT fValue, - FX_FLOAT fPercentBase); - FX_BOOL SetLengthWithPercent(FDE_CSSLENGTH& width, - FDE_CSSPRIMITIVETYPE eType, - IFDE_CSSPrimitiveValue* pPrimitive, - FX_FLOAT fFontSize); - FX_FLOAT ToFontSize(FDE_CSSPROPERTYVALUE eValue, FX_FLOAT fCurFontSize); - FDE_CSSDISPLAY ToDisplay(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSTEXTALIGN ToTextAlign(FDE_CSSPROPERTYVALUE eValue); - FX_WORD ToFontWeight(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSFONTSTYLE ToFontStyle(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSBORDERSTYLE ToBorderStyle(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSVERTICALALIGN ToVerticalAlign(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSLISTSTYLETYPE ToListStyleType(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSLISTSTYLEPOSITION ToListStylePosition(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSVISIBILITY ToVisibility(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSWHITESPACE ToWhiteSpace(FDE_CSSPROPERTYVALUE eValue); - FX_DWORD ToTextDecoration(IFDE_CSSValueList* pList); - FDE_CSSTEXTTRANSFORM ToTextTransform(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSFONTVARIANT ToFontVariant(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSFLOAT ToFloat(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSCLEAR ToClear(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSWRITINGMODE ToWritingMode(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSWORDBREAK ToWordBreak(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSPAGEBREAK ToPageBreak(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSOVERFLOW ToOverflow(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSLINEBREAK ToLineBreak(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSTEXTCOMBINE ToTextCombine(FDE_CSSPROPERTYVALUE eValue); - FX_BOOL ToTextEmphasisMark(FDE_CSSPROPERTYVALUE eValue, - FDE_CSSTEXTEMPHASISMARK& eMark); - FX_BOOL ToTextEmphasisFill(FDE_CSSPROPERTYVALUE eValue, - FDE_CSSTEXTEMPHASISFILL& eFill); - FDE_CSSCURSOR ToCursor(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSPOSITION ToPosition(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSCAPTIONSIDE ToCaptionSide(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSBKGREPEAT ToBKGRepeat(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSBKGATTACHMENT ToBKGAttachment(FDE_CSSPROPERTYVALUE eValue); - FDE_CSSRUBYALIGN ToRubyAlign(FDE_CSSPROPERTYVALUE eValue); - 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; - 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; - CFDE_CSSAccelerator* m_pAccelerator; - std::vector<FDE_CSSRuleData*> m_MatchedRules; -}; - -struct FDE_CSSCOUNTERDATA { - public: - FDE_CSSCOUNTERDATA() { FXSYS_memset(this, 0, sizeof(FDE_CSSCOUNTERDATA)); } - FX_BOOL GetCounterIncrement(int32_t& iValue) { - iValue = m_iIncVal; - return m_bIncrement; - } - FX_BOOL GetCounterReset(int32_t& iValue) { - iValue = m_iResetVal; - return m_bReset; - } - - const FX_WCHAR* m_pszIdent; - FX_BOOL m_bIncrement; - FX_BOOL m_bReset; - int32_t m_iIncVal; - int32_t m_iResetVal; -}; - -class CFDE_CSSCounterStyle { - public: - CFDE_CSSCounterStyle() : m_pCounterInc(NULL), m_pCounterReset(NULL) {} - 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; - } - - protected: - 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() { - FXSYS_memset(this, 0, sizeof(CFDE_CSSInheritedData)); - m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_fFontSize = 12.0f; - m_fLineHeight = 14.0f; - m_wFontWeight = 400; - m_dwFontColor = 0xFF000000; - m_iWidows = 2; - m_bTextEmphasisColorCurrent = TRUE; - m_iOrphans = 2; - } - const FX_WCHAR* m_pszListStyleImage; - FDE_CSSLENGTH m_LetterSpacing; - FDE_CSSLENGTH m_WordSpacing; - FDE_CSSLENGTH m_TextIndent; - IFDE_CSSValueList* m_pFontFamily; - IFDE_CSSValueList* m_pQuotes; - IFDE_CSSValueList* m_pCursorUris; - FDE_CSSCURSOR m_eCursor; - FX_FLOAT m_fFontSize; - FX_FLOAT m_fLineHeight; - FX_ARGB m_dwFontColor; - FX_ARGB m_dwTextEmphasisColor; - FX_WORD m_wFontWeight; - int32_t m_iWidows; - int32_t m_iOrphans; - const FX_WCHAR* m_pszTextEmphasisCustomMark; - FX_WORD m_eFontVariant : 1; - FX_WORD m_eFontStyle : 1; - FX_WORD m_bTextEmphasisColorCurrent : 1; - FX_WORD m_eTextAligh : 2; - FX_WORD m_eVisibility : 2; - FX_WORD m_eWhiteSpace : 3; - FX_WORD m_eTextTransform : 2; - FX_WORD m_eWritingMode : 2; - FX_WORD m_eWordBreak : 2; - FX_WORD m_eLineBreak : 2; - FX_WORD m_eTextEmphasisFill : 1; - FX_WORD m_eTextEmphasisMark : 3; - FX_WORD m_eCaptionSide : 3; - - FX_WORD m_eRubyAlign : 4; - FX_WORD m_eRubyOverhang : 2; - FX_WORD m_eRubyPosition : 2; -}; -class CFDE_CSSNonInheritedData { - public: - void Reset() { - FXSYS_memset(this, 0, sizeof(CFDE_CSSNonInheritedData)); - m_MarginWidth = m_BorderWidth = - m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None); - m_eDisplay = FDE_CSSDISPLAY_Inline; - m_fVerticalAlign = 0.0f; - m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); - m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal); - m_bColumnRuleColorSame = TRUE; - m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto); - m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto); - m_eTextCombine = FDE_CSSTEXTCOMBINE_None; - } - - IFDE_CSSValueList* m_pContentList; - CFDE_CSSCounterStyle* m_pCounterStyle; - FDE_CSSRECT m_MarginWidth; - FDE_CSSRECT m_BorderWidth; - FDE_CSSRECT m_PaddingWidth; - FDE_CSSSIZE m_BoxSize; - FDE_CSSSIZE m_MinBoxSize; - FDE_CSSSIZE m_MaxBoxSize; - FDE_CSSPOINT m_BKGPosition; - const FX_WCHAR* m_pszBKGImage; - FX_ARGB m_dwBKGColor; - FX_ARGB m_dwBDRLeftColor; - FX_ARGB m_dwBDRTopColor; - FX_ARGB m_dwBDRRightColor; - FX_ARGB m_dwBDRBottomColor; - IFDE_CSSValue* m_pRubySpan; - FDE_CSSLENGTH m_ColumnCount; - FDE_CSSLENGTH m_ColumnGap; - FDE_CSSLENGTH m_ColumnRuleWidth; - FDE_CSSLENGTH m_ColumnWidth; - FX_ARGB m_dwColumnRuleColor; - FDE_CSSLENGTH m_Top; - FDE_CSSLENGTH m_Bottom; - FDE_CSSLENGTH m_Left; - FDE_CSSLENGTH m_Right; - - FX_FLOAT m_fVerticalAlign; - FX_FLOAT m_fTextCombineNumber; - FX_DWORD m_eBDRLeftStyle : 4; - FX_DWORD m_eBDRTopStyle : 4; - FX_DWORD m_eBDRRightStyle : 4; - FX_DWORD m_eBDRBottomStyle : 4; - FX_DWORD m_eDisplay : 5; - FX_DWORD m_eVerticalAlign : 4; - FX_DWORD m_eListStyleType : 5; - FX_DWORD m_eColumnRuleStyle : 4; - FX_DWORD m_ePageBreakInside : 3; - FX_DWORD m_ePageBreakAfter : 3; - FX_DWORD m_ePageBreakBefore : 3; - FX_DWORD m_ePosition : 2; - FX_DWORD m_eBKGRepeat : 2; - FX_DWORD m_eFloat : 2; - FX_DWORD m_eClear : 2; - FX_DWORD m_eOverflowX : 3; - FX_DWORD m_eOverflowY : 3; - FX_DWORD m_eListStylePosition : 1; - FX_DWORD m_eBKGAttachment : 1; - FX_DWORD m_bHasMargin : 1; - FX_DWORD m_bHasBorder : 1; - FX_DWORD m_bHasPadding : 1; - FX_DWORD m_dwTextDecoration : 5; - FX_DWORD m_eTextCombine : 1; - FX_DWORD m_bColumnRuleColorSame : 1; - FX_DWORD m_bHasTextCombineNumber : 1; -}; -class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle, - public IFDE_CSSFontStyle, - public IFDE_CSSBoundaryStyle, - 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) - : m_dwRefCount(1), m_pAllocator(pAlloc) {} - ~CFDE_CSSComputedStyle() {} - virtual FX_DWORD AddRef() { return ++m_dwRefCount; } - virtual FX_DWORD Release() { - FX_DWORD dwRefCount = --m_dwRefCount; - if (dwRefCount == 0) { - if (m_NonInheritedData.m_pCounterStyle != NULL) { - delete m_NonInheritedData.m_pCounterStyle; - } - FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); - } - return dwRefCount; - } - - virtual void Reset() { - 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; - } - virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const { - return (IFDE_CSSMultiColumnStyle * const) this; - } - virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const { - return (IFDE_CSSGeneratedContentStyle * const) this; - } - virtual IFDE_CSSRubyStyle* GetRubyStyle() const { - return (IFDE_CSSRubyStyle * const) this; - } - virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName, - CFX_WideString& wsValue) const { - for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) { - if (wsName == m_CustomProperties[i]) { - wsValue = m_CustomProperties[i + 1]; - return TRUE; - } - } - 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 { - 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))) - ->GetString(index); - } - virtual FX_WORD GetFontWeight() const { - return m_InheritedData.m_wFontWeight; - } - virtual FDE_CSSFONTVARIANT GetFontVariant() const { - return (FDE_CSSFONTVARIANT)m_InheritedData.m_eFontVariant; - } - virtual FDE_CSSFONTSTYLE GetFontStyle() const { - return (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(FX_WORD wFontWeight) { - m_InheritedData.m_wFontWeight = wFontWeight; - } - virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) { - m_InheritedData.m_eFontVariant = eFontVariant; - } - virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) { - m_InheritedData.m_eFontStyle = eFontStyle; - } - virtual void SetFontSize(FX_FLOAT fFontSize) { - 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; - } - - virtual const FDE_CSSRECT* GetBorderWidth() const { - return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth) - : NULL; - } - virtual const FDE_CSSRECT* GetMarginWidth() const { - return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth) - : NULL; - } - virtual const FDE_CSSRECT* GetPaddingWidth() const { - 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; - } - - 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) { - m_NonInheritedData.m_MarginWidth = rect; - m_NonInheritedData.m_bHasMargin = TRUE; - } - virtual void SetPaddingWidth(const FDE_CSSRECT& rect) { - 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; - } - 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 { - return m_InheritedData.m_fLineHeight; - } - virtual FDE_CSSWHITESPACE GetWhiteSpace() const { - return (FDE_CSSWHITESPACE)m_InheritedData.m_eWhiteSpace; - } - virtual const FDE_CSSLENGTH& GetTextIndent() const { - return m_InheritedData.m_TextIndent; - } - virtual FDE_CSSTEXTALIGN GetTextAlign() const { - return (FDE_CSSTEXTALIGN)m_InheritedData.m_eTextAligh; - } - virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const { - return (FDE_CSSVERTICALALIGN)m_NonInheritedData.m_eVerticalAlign; - } - virtual FX_FLOAT GetNumberVerticalAlign() const { - return m_NonInheritedData.m_fVerticalAlign; - } - virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const { - return (FDE_CSSTEXTTRANSFORM)m_InheritedData.m_eTextTransform; - } - virtual FX_DWORD GetTextDecoration() const { - return m_NonInheritedData.m_dwTextDecoration; - } - virtual const FDE_CSSLENGTH& GetLetterSpacing() const { - 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) { - m_InheritedData.m_fLineHeight = fLineHeight; - } - virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) { - m_InheritedData.m_eWhiteSpace = eWhiteSpace; - } - virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) { - m_InheritedData.m_TextIndent = textIndent; - } - virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) { - m_InheritedData.m_eTextAligh = eTextAlign; - } - virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) { - m_NonInheritedData.m_eVerticalAlign = eVerticalAlign; - } - virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) { - 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(FX_DWORD dwTextDecoration) { - m_NonInheritedData.m_dwTextDecoration = dwTextDecoration; - } - virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) { - 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); - } - FX_DWORD m_dwRefCount; - IFX_MEMAllocator* m_pAllocator; - CFDE_CSSInheritedData m_InheritedData; - CFDE_CSSNonInheritedData m_NonInheritedData; - CFX_WideStringArray m_CustomProperties; -}; - -#endif // XFA_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_ diff --git a/xfa/src/fde/css/fde_cssstylesheet.cpp b/xfa/src/fde/css/fde_cssstylesheet.cpp deleted file mode 100644 index 9b18dd2552..0000000000 --- a/xfa/src/fde/css/fde_cssstylesheet.cpp +++ /dev/null @@ -1,509 +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/src/fde/css/fde_cssstylesheet.h" - -#include "xfa/src/fde/css/fde_cssdatatable.h" -#include "xfa/src/fde/css/fde_csssyntax.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" - -IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() { - 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}" - L"li{display:list-item}head{display:none}table{display:table}tr{display:" - L"table-row}thead{display:table-header-group}tbody{display:table-row-" - L"group}tfoot{display:table-footer-group}" - L"col{display:table-column}colgroup{display:table-column-group}td,th{" - L"display:table-cell}caption{display:table-caption}th{font-weight:bolder;" - L"text-align:center}caption{text-align:center}" - L"body{margin:0}h1{font-size:2em;margin:.67em " - L"0}h2{font-size:1.5em;margin:.75em 0}h3{font-size:1.17em;margin:.83em " - L"0}h4,p,blockquote,ul,fieldset,form,ol,dl,dir,menu{margin:1.12em 0}" - L"h5{font-size:.83em;margin:1.5em 0}h6{font-size:.75em;margin:1.67em " - L"0}h1,h2,h3,h4,h5,h6,b,strong{font-weight:bolder}blockquote{margin-left:" - L"40px;margin-right:40px}i,cite,em,var,address{font-style:italic}" - L"pre,tt,code,kbd,samp{font-family:monospace}pre{white-space:pre}button," - L"textarea,input,select{display:inline-block}big{font-size:1.17em}small," - L"sub,sup{font-size:.83em}sub{vertical-align:sub}" - L"sup{vertical-align:super}table{border-spacing:2px}thead,tbody,tfoot{" - L"vertical-align:middle}td,th,tr{vertical-align:inherit}s,strike,del{" - L"text-decoration:line-through}hr{border:1px inset silver}" - L"ol,ul,dir,menu,dd{margin-left:40px}ol{list-style-type:decimal}ol ul,ul " - L"ol,ul ul,ol " - L"ol{margin-top:0;margin-bottom:0}u,ins{text-decoration:underline}center{" - L"text-align:center}" - L"ruby{display:ruby}rt{display:ruby-text;font-size:.5em}rb{display:ruby-" - L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}" - L"q:before{content:open-quote}q:after{content:close-quote}" - L"rp{display:none}"; - return IFDE_CSSStyleSheet::LoadFromBuffer( - CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); -} - -IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( - const CFX_WideString& szUrl, - IFX_Stream* pStream, - FX_WORD wCodePage, - FX_DWORD dwMediaList) { - CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); - if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { - pStyleSheet->Release(); - pStyleSheet = NULL; - } - return pStyleSheet; -} -IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( - const CFX_WideString& szUrl, - const FX_WCHAR* pBuffer, - int32_t iBufSize, - FX_WORD wCodePage, - FX_DWORD dwMediaList) { - CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); - if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { - pStyleSheet->Release(); - pStyleSheet = NULL; - } - return pStyleSheet; -} -CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList) - : m_wCodePage(FX_CODEPAGE_UTF8), - m_wRefCount(1), - m_dwMediaList(dwMediaList), - m_pAllocator(NULL) { - FXSYS_assert(m_dwMediaList > 0); -} -CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() { - Reset(); -} -void CFDE_CSSStyleSheet::Reset() { - for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { - IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); - switch (pRule->GetType()) { - case FDE_CSSRULETYPE_Style: - ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); - break; - case FDE_CSSRULETYPE_Media: - ((CFDE_CSSMediaRule*)pRule)->~CFDE_CSSMediaRule(); - break; - case FDE_CSSRULETYPE_FontFace: - ((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule(); - break; - default: - FXSYS_assert(FALSE); - break; - } - } - m_RuleArray.RemoveAll(); - m_Selectors.RemoveAll(); - m_StringCache.RemoveAll(); - if (m_pAllocator) { - m_pAllocator->Release(); - m_pAllocator = NULL; - } -} -FX_DWORD CFDE_CSSStyleSheet::AddRef() { - return ++m_wRefCount; -} -FX_DWORD CFDE_CSSStyleSheet::Release() { - FX_DWORD dwRefCount = --m_wRefCount; - if (dwRefCount == 0) { - delete this; - } - return dwRefCount; -} -int32_t CFDE_CSSStyleSheet::CountRules() const { - return m_RuleArray.GetSize(); -} -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, - FX_WORD wCodePage) { - FXSYS_assert(pStream != NULL); - IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); - if (pSyntax == NULL) { - return FALSE; - } - if (pStream->GetCodePage() != wCodePage) { - pStream->SetCodePage(wCodePage); - } - FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax); - pSyntax->Release(); - m_wCodePage = wCodePage; - m_szUrl = szUrl; - return bRet; -} -FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl, - const FX_WCHAR* pBuffer, - int32_t iBufSize, - FX_WORD 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(); - m_wCodePage = wCodePage; - m_szUrl = szUrl; - return bRet; -} -FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) { - Reset(); - m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); - if (m_pAllocator == NULL) { - return FALSE; - } - FDE_CSSSYNTAXSTATUS eStatus; - do { - switch (eStatus = pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_StyleRule: - eStatus = LoadStyleRule(pSyntax, m_RuleArray); - break; - case FDE_CSSSYNTAXSTATUS_MediaRule: - eStatus = LoadMediaRule(pSyntax); - break; - case FDE_CSSSYNTAXSTATUS_FontFaceRule: - eStatus = LoadFontFaceRule(pSyntax, m_RuleArray); - break; - case FDE_CSSSYNTAXSTATUS_ImportRule: - eStatus = LoadImportRule(pSyntax); - break; - case FDE_CSSSYNTAXSTATUS_PageRule: - eStatus = LoadPageRule(pSyntax); - break; - default: - break; - } - } while (eStatus >= FDE_CSSSYNTAXSTATUS_None); - m_Selectors.RemoveAll(); - m_StringCache.RemoveAll(); - return eStatus != FDE_CSSSYNTAXSTATUS_Error; -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( - IFDE_CSSSyntaxParser* pSyntax) { - FX_DWORD dwMediaList = 0; - CFDE_CSSMediaRule* pMediaRule = NULL; - for (;;) { - switch (pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_MediaType: { - int32_t iLen; - const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen); - FDE_LPCCSSMEDIATYPETABLE pMediaType = - FDE_GetCSSMediaTypeByName(psz, iLen); - if (pMediaType != NULL) { - dwMediaList |= pMediaType->wValue; - } - } break; - case FDE_CSSSYNTAXSTATUS_StyleRule: - if (pMediaRule == NULL) { - SkipRuleSet(pSyntax); - } else { - FDE_CSSSYNTAXSTATUS eStatus = - LoadStyleRule(pSyntax, pMediaRule->GetArray()); - if (eStatus < FDE_CSSSYNTAXSTATUS_None) { - return eStatus; - } - } - break; - case FDE_CSSSYNTAXSTATUS_DeclOpen: - if ((dwMediaList & m_dwMediaList) > 0 && pMediaRule == NULL) { - pMediaRule = - FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList); - m_RuleArray.Add(pMediaRule); - } - break; - case FDE_CSSSYNTAXSTATUS_DeclClose: - return FDE_CSSSYNTAXSTATUS_None; - FDE_CSSSWITCHDEFAULTS(); - } - } -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule( - IFDE_CSSSyntaxParser* pSyntax, - CFDE_CSSRuleArray& ruleArray) { - m_Selectors.RemoveAt(0, m_Selectors.GetSize()); - CFDE_CSSStyleRule* pStyleRule = NULL; - const FX_WCHAR* pszValue = NULL; - int32_t iValueLen = 0; - FDE_CSSPROPERTYARGS propertyArgs; - propertyArgs.pStaticStore = m_pAllocator; - propertyArgs.pStringCache = &m_StringCache; - propertyArgs.pProperty = NULL; - CFX_WideString wsName; - for (;;) { - switch (pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_Selector: { - pszValue = pSyntax->GetCurrentString(iValueLen); - IFDE_CSSSelector* pSelector = - CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen); - if (pSelector != NULL) { - m_Selectors.Add(pSelector); - } - } break; - case FDE_CSSSYNTAXSTATUS_PropertyName: - pszValue = pSyntax->GetCurrentString(iValueLen); - propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); - if (propertyArgs.pProperty == NULL) { - wsName = CFX_WideStringC(pszValue, iValueLen); - } - break; - case FDE_CSSSYNTAXSTATUS_PropertyValue: - if (propertyArgs.pProperty != NULL) { - pszValue = pSyntax->GetCurrentString(iValueLen); - if (iValueLen > 0) { - pStyleRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, - iValueLen); - } - } else if (iValueLen > 0) { - pszValue = pSyntax->GetCurrentString(iValueLen); - if (iValueLen > 0) { - pStyleRule->GetDeclImp().AddProperty( - &propertyArgs, wsName, wsName.GetLength(), pszValue, iValueLen); - } - } - break; - case FDE_CSSSYNTAXSTATUS_DeclOpen: - if (pStyleRule == NULL && m_Selectors.GetSize() > 0) { - pStyleRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSStyleRule; - pStyleRule->SetSelector(m_pAllocator, m_Selectors); - ruleArray.Add(pStyleRule); - } else { - SkipRuleSet(pSyntax); - return FDE_CSSSYNTAXSTATUS_None; - } - break; - case FDE_CSSSYNTAXSTATUS_DeclClose: - if (pStyleRule != NULL && - pStyleRule->GetDeclImp().GetStartPosition() == NULL) { - pStyleRule->~CFDE_CSSStyleRule(); - ruleArray.RemoveLast(1); - } - return FDE_CSSSYNTAXSTATUS_None; - FDE_CSSSWITCHDEFAULTS(); - } - } -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule( - IFDE_CSSSyntaxParser* pSyntax, - CFDE_CSSRuleArray& ruleArray) { - CFDE_CSSFontFaceRule* pFontFaceRule = NULL; - const FX_WCHAR* pszValue = NULL; - int32_t iValueLen = 0; - FDE_CSSPROPERTYARGS propertyArgs; - propertyArgs.pStaticStore = m_pAllocator; - propertyArgs.pStringCache = &m_StringCache; - propertyArgs.pProperty = NULL; - for (;;) { - switch (pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_PropertyName: - pszValue = pSyntax->GetCurrentString(iValueLen); - propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); - break; - case FDE_CSSSYNTAXSTATUS_PropertyValue: - if (propertyArgs.pProperty != NULL) { - pszValue = pSyntax->GetCurrentString(iValueLen); - if (iValueLen > 0) { - pFontFaceRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, - iValueLen); - } - } - break; - case FDE_CSSSYNTAXSTATUS_DeclOpen: - if (pFontFaceRule == NULL) { - pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule; - ruleArray.Add(pFontFaceRule); - } - break; - case FDE_CSSSYNTAXSTATUS_DeclClose: - return FDE_CSSSYNTAXSTATUS_None; - FDE_CSSSWITCHDEFAULTS(); - } - } - return FDE_CSSSYNTAXSTATUS_None; -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule( - IFDE_CSSSyntaxParser* pSyntax) { - for (;;) { - switch (pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_ImportClose: - return FDE_CSSSYNTAXSTATUS_None; - case FDE_CSSSYNTAXSTATUS_URI: - break; - FDE_CSSSWITCHDEFAULTS(); - } - } -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule( - IFDE_CSSSyntaxParser* pSyntax) { - return SkipRuleSet(pSyntax); -} -FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet( - IFDE_CSSSyntaxParser* pSyntax) { - for (;;) { - switch (pSyntax->DoSyntaxParse()) { - case FDE_CSSSYNTAXSTATUS_Selector: - case FDE_CSSSYNTAXSTATUS_DeclOpen: - case FDE_CSSSYNTAXSTATUS_PropertyName: - case FDE_CSSSYNTAXSTATUS_PropertyValue: - break; - case FDE_CSSSYNTAXSTATUS_DeclClose: - return FDE_CSSSYNTAXSTATUS_None; - FDE_CSSSWITCHDEFAULTS(); - } - } - return FDE_CSSSYNTAXSTATUS_None; -} -void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore, - const CFDE_CSSSelectorArray& list) { - FXSYS_assert(m_ppSelector == NULL); - m_iSelectors = list.GetSize(); - m_ppSelector = (IFDE_CSSSelector**)pStaticStore->Alloc( - m_iSelectors * sizeof(IFDE_CSSSelector*)); - for (int32_t i = 0; i < m_iSelectors; ++i) { - m_ppSelector[i] = list.GetAt(i); - } -} -CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { - for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { - IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); - switch (pRule->GetType()) { - case FDE_CSSRULETYPE_Style: - ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); - break; - default: - FXSYS_assert(FALSE); - break; - } - } -} -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 == ':'); - const FX_WCHAR* pStart = psz; - while (psz < pEnd) { - FX_WCHAR wch = *psz; - if (FDE_IsCSSChar(wch) || wch == ':') { - ++psz; - } else { - break; - } - } - return psz - pStart; -} -int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { - const FX_WCHAR* pStart = psz; - while (psz < pEnd) { - FX_WCHAR wch = *psz; - if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' || - wch == '-') { - ++psz; - } else { - break; - } - } - 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); - const FX_WCHAR* pStart = psz; - const FX_WCHAR* pEnd = psz + iLen; - for (; psz < pEnd; ++psz) { - switch (*psz) { - case '>': - case '[': - case '+': - return NULL; - } - } - CFDE_CSSSelector *pFirst = NULL, *pLast = NULL; - CFDE_CSSSelector *pPersudoFirst = NULL, *pPersudoLast = NULL; - for (psz = pStart; psz < pEnd;) { - FX_WCHAR wch = *psz; - if (wch == '.' || wch == '#') { - if (psz == pStart || psz[-1] == ' ') { - CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) - CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, TRUE); - if (p == NULL) { - return NULL; - } - if (pFirst != NULL) { - pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); - p->SetNext(pFirst); - } - pFirst = pLast = p; - } - FXSYS_assert(pLast != NULL); - int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd); - if (iNameLen == 0) { - return NULL; - } - FDE_CSSSELECTORTYPE eType = - wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID; - CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) - CFDE_CSSSelector(eType, psz, iNameLen, FALSE); - if (p == NULL) { - return NULL; - } - p->SetNext(pLast->GetNextSelector()); - pLast->SetNext(p); - pLast = p; - psz += iNameLen; - } else if (FDE_IsCSSChar(wch) || wch == '*') { - int32_t iNameLen = wch == '*' ? 1 : FDE_GetCSSNameLen(psz, pEnd); - if (iNameLen == 0) { - return NULL; - } - CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) - CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, TRUE); - if (p == NULL) { - return NULL; - } - if (pFirst == NULL) { - pFirst = pLast = p; - } else { - pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); - p->SetNext(pFirst); - pFirst = pLast = p; - } - psz += iNameLen; - } else if (wch == ':') { - int32_t iNameLen = FDE_GetCSSPersudoLen(psz, pEnd); - if (iNameLen == 0) { - return NULL; - } - CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) - CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, TRUE); - if (p == NULL) { - return NULL; - } - if (pPersudoFirst == NULL) { - pPersudoFirst = pPersudoLast = p; - } else { - pPersudoLast->SetNext(p); - pPersudoLast = p; - } - psz += iNameLen; - } else if (wch == ' ') { - psz++; - } else { - return NULL; - } - } - if (pPersudoFirst == NULL) { - return pFirst; - } else { - pPersudoLast->SetNext(pFirst); - return pPersudoFirst; - } -} diff --git a/xfa/src/fde/css/fde_cssstylesheet.h b/xfa/src/fde/css/fde_cssstylesheet.h deleted file mode 100644 index 5e11c74b4e..0000000000 --- a/xfa/src/fde/css/fde_cssstylesheet.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_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_ - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fde/css/fde_cssdeclaration.h" - -class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target { - public: - CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, - const FX_WCHAR* psz, - int32_t iLen, - FX_BOOL bIgnoreCase) - : m_eType(eType), - m_dwHash(FX_HashCode_String_GetW(psz, iLen, bIgnoreCase)), - m_pNext(NULL) {} - virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; } - - virtual FX_DWORD GetNameHash() const { return m_dwHash; } - - virtual IFDE_CSSSelector* GetNextSelector() const { return m_pNext; } - static IFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore, - const FX_WCHAR* psz, - int32_t iLen); - void SetNext(IFDE_CSSSelector* pNext) { m_pNext = pNext; } - - protected: - static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore, - const FX_WCHAR* psz, - int32_t& iOff, - int32_t iLen, - FDE_CSSSELECTORTYPE eType); - void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; } - FDE_CSSSELECTORTYPE m_eType; - FX_DWORD m_dwHash; - IFDE_CSSSelector* m_pNext; -}; -typedef CFX_ArrayTemplate<IFDE_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 { - return m_ppSelector[index]; - } - - virtual IFDE_CSSDeclaration* GetDeclaration() const { - return (IFDE_CSSDeclaration*)&m_Declaration; - } - CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } - void SetSelector(IFX_MEMAllocator* pStaticStore, - const CFDE_CSSSelectorArray& list); - - protected: - CFDE_CSSDeclaration m_Declaration; - IFDE_CSSSelector** m_ppSelector; - int32_t m_iSelectors; -}; -class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target { - public: - CFDE_CSSMediaRule(FX_DWORD dwMediaList) : m_dwMediaList(dwMediaList) {} - ~CFDE_CSSMediaRule(); - - virtual FX_DWORD GetMediaList() const { return m_dwMediaList; } - - virtual int32_t CountRules() const { return m_RuleArray.GetSize(); } - virtual IFDE_CSSRule* GetRule(int32_t index) { - return m_RuleArray.GetAt(index); - } - CFDE_CSSRuleArray& GetArray() { return m_RuleArray; } - - protected: - FX_DWORD m_dwMediaList; - CFDE_CSSRuleArray m_RuleArray; -}; -class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target { - public: - virtual IFDE_CSSDeclaration* GetDeclaration() const { - return (IFDE_CSSDeclaration*)&m_Declaration; - } - CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } - - protected: - CFDE_CSSDeclaration m_Declaration; -}; -#define FDE_CSSSWITCHDEFAULTS() \ - case FDE_CSSSYNTAXSTATUS_EOS: \ - return FDE_CSSSYNTAXSTATUS_EOS; \ - case FDE_CSSSYNTAXSTATUS_Error: \ - default: \ - return FDE_CSSSYNTAXSTATUS_Error; -class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target { - public: - CFDE_CSSStyleSheet(FX_DWORD dwMediaList); - ~CFDE_CSSStyleSheet(); - virtual FX_DWORD AddRef(); - virtual FX_DWORD Release(); - - virtual FX_BOOL GetUrl(CFX_WideString& szUrl) { - szUrl = m_szUrl; - return szUrl.GetLength() > 0; - } - virtual FX_DWORD GetMediaList() const { return m_dwMediaList; } - virtual FX_WORD GetCodePage() const { return m_wCodePage; } - virtual int32_t CountRules() const; - virtual IFDE_CSSRule* GetRule(int32_t index); - FX_BOOL LoadFromStream(const CFX_WideString& szUrl, - IFX_Stream* pStream, - FX_WORD wCodePage); - FX_BOOL LoadFromBuffer(const CFX_WideString& szUrl, - const FX_WCHAR* pBuffer, - int32_t iBufSize, - FX_WORD wCodePage); - - protected: - void Reset(); - FX_BOOL LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax); - FDE_CSSSYNTAXSTATUS LoadStyleRule(IFDE_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, - CFDE_CSSRuleArray& ruleArray); - FDE_CSSSYNTAXSTATUS SkipRuleSet(IFDE_CSSSyntaxParser* pSyntax); - FX_WORD m_wCodePage; - FX_WORD m_wRefCount; - FX_DWORD m_dwMediaList; - IFX_MEMAllocator* m_pAllocator; - CFDE_CSSRuleArray m_RuleArray; - CFX_WideString m_szUrl; - CFDE_CSSSelectorArray m_Selectors; - CFX_MapPtrToPtr m_StringCache; -}; - -#endif // XFA_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_ diff --git a/xfa/src/fde/css/fde_csssyntax.cpp b/xfa/src/fde/css/fde_csssyntax.cpp deleted file mode 100644 index 5fe502e8b9..0000000000 --- a/xfa/src/fde/css/fde_csssyntax.cpp +++ /dev/null @@ -1,487 +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/src/fde/css/fde_csssyntax.h" - -#include "xfa/src/fde/css/fde_cssdatatable.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" - -#ifdef _cplusplus -extern "C" { -#endif - -inline FX_BOOL FDE_IsSelectorStart(FX_WCHAR wch) { - return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') || - (wch >= 'A' && wch <= 'Z'); -} - -#ifdef _cplusplus -}; -#endif - -IFDE_CSSSyntaxParser* IFDE_CSSSyntaxParser::Create() { - return new CFDE_CSSSyntaxParser; -} -CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser() - : m_pStream(NULL), - m_iStreamPos(0), - m_iPlaneSize(0), - m_iTextDatLen(0), - m_dwCheck((FX_DWORD)-1), - m_eMode(FDE_CSSSYNTAXMODE_RuleSet), - m_eStatus(FDE_CSSSYNTAXSTATUS_None) {} -CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() { - m_TextData.Reset(); - m_TextPlane.Reset(); -} -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); - Reset(bOnlyDeclaration); - if (!m_TextData.EstimateSize(iTextDataSize)) { - return FALSE; - } - uint8_t bom[4]; - m_pStream = pStream; - m_iStreamPos = m_pStream->GetBOM(bom); - m_iPlaneSize = iCSSPlaneSize; - return TRUE; -} -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); - Reset(bOnlyDeclaration); - if (!m_TextData.EstimateSize(iTextDatSize)) { - return FALSE; - } - return m_TextPlane.AttachBuffer(pBuffer, iBufferSize); -} -void CFDE_CSSSyntaxParser::Reset(FX_BOOL bOnlyDeclaration) { - m_TextPlane.Reset(); - m_TextData.Reset(); - m_pStream = NULL; - m_iStreamPos = 0; - m_iTextDatLen = 0; - m_dwCheck = (FX_DWORD)-1; - m_eStatus = FDE_CSSSYNTAXSTATUS_None; - m_eMode = bOnlyDeclaration ? FDE_CSSSYNTAXMODE_PropertyName - : FDE_CSSSYNTAXMODE_RuleSet; -} -FDE_CSSSYNTAXSTATUS CFDE_CSSSyntaxParser::DoSyntaxParse() { - while (m_eStatus >= FDE_CSSSYNTAXSTATUS_None) { - if (m_TextPlane.IsEOF()) { - if (m_pStream == NULL) { - if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue && - m_TextData.GetLength() > 0) { - SaveTextData(); - return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue; - } - return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS; - } - FX_BOOL bEOS; - int32_t iLen = m_TextPlane.LoadFromStream(m_pStream, m_iStreamPos, - m_iPlaneSize, bEOS); - m_iStreamPos = m_pStream->GetPosition(); - if (iLen < 1) { - if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue && - m_TextData.GetLength() > 0) { - SaveTextData(); - return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue; - } - return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS; - } - } - FX_WCHAR wch; - while (!m_TextPlane.IsEOF()) { - wch = m_TextPlane.GetChar(); - switch (m_eMode) { - case FDE_CSSSYNTAXMODE_RuleSet: - switch (wch) { - case '@': - m_TextPlane.MoveNext(); - SwitchMode(FDE_CSSSYNTAXMODE_AtRule); - break; - case '}': - m_TextPlane.MoveNext(); - if (RestoreMode()) { - return FDE_CSSSYNTAXSTATUS_DeclClose; - } else { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - break; - case '/': - if (m_TextPlane.GetNextChar() == '*') { - m_ModeStack.Push(m_eMode); - SwitchMode(FDE_CSSSYNTAXMODE_Comment); - break; - } - default: - if (wch <= ' ') { - m_TextPlane.MoveNext(); - } else if (FDE_IsSelectorStart(wch)) { - SwitchMode(FDE_CSSSYNTAXMODE_Selector); - return FDE_CSSSYNTAXSTATUS_StyleRule; - } else { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - break; - } - break; - case FDE_CSSSYNTAXMODE_Selector: - switch (wch) { - case ',': - m_TextPlane.MoveNext(); - SwitchMode(FDE_CSSSYNTAXMODE_Selector); - if (m_iTextDatLen > 0) { - return FDE_CSSSYNTAXSTATUS_Selector; - } - break; - case '{': - if (m_TextData.GetLength() > 0) { - SaveTextData(); - return FDE_CSSSYNTAXSTATUS_Selector; - } else { - m_TextPlane.MoveNext(); - m_ModeStack.Push(FDE_CSSSYNTAXMODE_RuleSet); - SwitchMode(FDE_CSSSYNTAXMODE_PropertyName); - return FDE_CSSSYNTAXSTATUS_DeclOpen; - } - break; - case '/': - if (m_TextPlane.GetNextChar() == '*') { - if (SwitchToComment() > 0) { - return FDE_CSSSYNTAXSTATUS_Selector; - } - break; - } - default: - AppendChar(wch); - break; - } - break; - case FDE_CSSSYNTAXMODE_PropertyName: - switch (wch) { - case ':': - m_TextPlane.MoveNext(); - SwitchMode(FDE_CSSSYNTAXMODE_PropertyValue); - return FDE_CSSSYNTAXSTATUS_PropertyName; - case '}': - m_TextPlane.MoveNext(); - if (RestoreMode()) { - return FDE_CSSSYNTAXSTATUS_DeclClose; - } else { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - break; - case '/': - if (m_TextPlane.GetNextChar() == '*') { - if (SwitchToComment() > 0) { - return FDE_CSSSYNTAXSTATUS_PropertyName; - } - break; - } - default: - AppendChar(wch); - break; - } - break; - case FDE_CSSSYNTAXMODE_PropertyValue: - switch (wch) { - case ';': - m_TextPlane.MoveNext(); - case '}': - SwitchMode(FDE_CSSSYNTAXMODE_PropertyName); - return FDE_CSSSYNTAXSTATUS_PropertyValue; - case '/': - if (m_TextPlane.GetNextChar() == '*') { - if (SwitchToComment() > 0) { - return FDE_CSSSYNTAXSTATUS_PropertyValue; - } - break; - } - default: - AppendChar(wch); - break; - } - break; - case FDE_CSSSYNTAXMODE_Comment: - if (wch == '/' && m_TextData.GetLength() > 0 && - m_TextData.GetAt(m_TextData.GetLength() - 1) == '*') { - RestoreMode(); - } else { - m_TextData.AppendChar(wch); - } - m_TextPlane.MoveNext(); - break; - case FDE_CSSSYNTAXMODE_MediaType: - switch (wch) { - case ',': - m_TextPlane.MoveNext(); - SwitchMode(FDE_CSSSYNTAXMODE_MediaType); - if (m_iTextDatLen > 0) { - return FDE_CSSSYNTAXSTATUS_MediaType; - } - break; - case '{': { - FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); - if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_MediaRule) { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - if (m_TextData.GetLength() > 0) { - SaveTextData(); - return FDE_CSSSYNTAXSTATUS_MediaType; - } else { - m_TextPlane.MoveNext(); - *pMode = FDE_CSSSYNTAXMODE_RuleSet; - SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); - return FDE_CSSSYNTAXSTATUS_DeclOpen; - } - } break; - case ';': { - FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); - if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - if (m_TextData.GetLength() > 0) { - SaveTextData(); - if (IsImportEnabled()) { - return FDE_CSSSYNTAXSTATUS_MediaType; - } - } else { - FX_BOOL bEnabled = IsImportEnabled(); - m_TextPlane.MoveNext(); - m_ModeStack.Pop(); - SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); - if (bEnabled) { - DisableImport(); - return FDE_CSSSYNTAXSTATUS_ImportClose; - } - } - } break; - case '/': - if (m_TextPlane.GetNextChar() == '*') { - if (SwitchToComment() > 0) { - return FDE_CSSSYNTAXSTATUS_MediaType; - } - break; - } - default: - AppendChar(wch); - break; - } - break; - case FDE_CSSSYNTAXMODE_URI: { - FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); - if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) { - return m_eStatus = FDE_CSSSYNTAXSTATUS_Error; - } - if (wch <= ' ' || wch == ';') { - int32_t iURIStart, iURILength = m_TextData.GetLength(); - if (iURILength > 0 && - FDE_ParseCSSURI(m_TextData.GetBuffer(), iURILength, iURIStart, - iURILength)) { - m_TextData.Subtract(iURIStart, iURILength); - SwitchMode(FDE_CSSSYNTAXMODE_MediaType); - if (IsImportEnabled()) { - return FDE_CSSSYNTAXSTATUS_URI; - } else { - break; - } - } - } - AppendChar(wch); - } break; - case FDE_CSSSYNTAXMODE_AtRule: - if (wch > ' ') { - AppendChar(wch); - } else { - int32_t iLen = m_TextData.GetLength(); - const FX_WCHAR* psz = m_TextData.GetBuffer(); - if (FXSYS_wcsncmp(L"charset", psz, iLen) == 0) { - SwitchMode(FDE_CSSSYNTAXMODE_Charset); - } else if (FXSYS_wcsncmp(L"import", psz, iLen) == 0) { - m_ModeStack.Push(FDE_CSSSYNTAXMODE_Import); - SwitchMode(FDE_CSSSYNTAXMODE_URI); - if (IsImportEnabled()) { - return FDE_CSSSYNTAXSTATUS_ImportRule; - } else { - break; - } - } else if (FXSYS_wcsncmp(L"media", psz, iLen) == 0) { - m_ModeStack.Push(FDE_CSSSYNTAXMODE_MediaRule); - SwitchMode(FDE_CSSSYNTAXMODE_MediaType); - return FDE_CSSSYNTAXSTATUS_MediaRule; - } else if (FXSYS_wcsncmp(L"font-face", psz, iLen) == 0) { - SwitchMode(FDE_CSSSYNTAXMODE_Selector); - return FDE_CSSSYNTAXSTATUS_FontFaceRule; - } else if (FXSYS_wcsncmp(L"page", psz, iLen) == 0) { - SwitchMode(FDE_CSSSYNTAXMODE_Selector); - return FDE_CSSSYNTAXSTATUS_PageRule; - } else { - SwitchMode(FDE_CSSSYNTAXMODE_UnknownRule); - } - } - break; - case FDE_CSSSYNTAXMODE_Charset: - if (wch == ';') { - m_TextPlane.MoveNext(); - SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); - if (IsCharsetEnabled()) { - DisableCharset(); - if (m_iTextDatLen > 0) { - if (m_pStream != NULL) { - FX_WORD wCodePage = FX_GetCodePageFormStringW( - m_TextData.GetBuffer(), m_iTextDatLen); - if (wCodePage < 0xFFFF && - m_pStream->GetCodePage() != wCodePage) { - m_pStream->SetCodePage(wCodePage); - } - } - return FDE_CSSSYNTAXSTATUS_Charset; - } - } - } else { - AppendChar(wch); - } - break; - case FDE_CSSSYNTAXMODE_UnknownRule: - if (wch == ';') { - SwitchMode(FDE_CSSSYNTAXMODE_RuleSet); - } - m_TextPlane.MoveNext(); - break; - default: - FXSYS_assert(FALSE); - break; - } - } - } - return m_eStatus; -} -FX_BOOL CFDE_CSSSyntaxParser::IsImportEnabled() const { - if ((m_dwCheck & FDE_CSSSYNTAXCHECK_AllowImport) == 0) { - return FALSE; - } - if (m_ModeStack.GetSize() > 1) { - return FALSE; - } - return TRUE; -} -inline FX_BOOL CFDE_CSSSyntaxParser::AppendChar(FX_WCHAR wch) { - m_TextPlane.MoveNext(); - if (m_TextData.GetLength() > 0 || wch > ' ') { - m_TextData.AppendChar(wch); - return TRUE; - } - return FALSE; -} -inline int32_t CFDE_CSSSyntaxParser::SaveTextData() { - m_iTextDatLen = m_TextData.TrimEnd(); - m_TextData.Clear(); - return m_iTextDatLen; -} -inline void CFDE_CSSSyntaxParser::SwitchMode(FDE_CSSSYNTAXMODE eMode) { - m_eMode = eMode; - SaveTextData(); -} -inline int32_t CFDE_CSSSyntaxParser::SwitchToComment() { - int32_t iLength = m_TextData.GetLength(); - m_ModeStack.Push(m_eMode); - SwitchMode(FDE_CSSSYNTAXMODE_Comment); - return iLength; -} -inline FX_BOOL CFDE_CSSSyntaxParser::RestoreMode() { - FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement(); - if (pMode == NULL) { - return FALSE; - } - SwitchMode(*pMode); - m_ModeStack.Pop(); - return TRUE; -} -const FX_WCHAR* CFDE_CSSSyntaxParser::GetCurrentString(int32_t& iLength) const { - iLength = m_iTextDatLen; - return m_TextData.GetBuffer(); -} -CFDE_CSSTextBuf::CFDE_CSSTextBuf() - : m_bExtBuf(FALSE), - m_pBuffer(NULL), - m_iBufLen(0), - m_iDatLen(0), - m_iDatPos(0) {} -CFDE_CSSTextBuf::~CFDE_CSSTextBuf() { - Reset(); -} -void CFDE_CSSTextBuf::Reset() { - if (!m_bExtBuf) { - FX_Free(m_pBuffer); - m_pBuffer = NULL; - } - m_iDatPos = m_iDatLen = m_iBufLen; -} -FX_BOOL CFDE_CSSTextBuf::AttachBuffer(const FX_WCHAR* pBuffer, - int32_t iBufLen) { - Reset(); - m_pBuffer = (FX_WCHAR*)pBuffer; - m_iDatLen = m_iBufLen = iBufLen; - return m_bExtBuf = TRUE; -} -FX_BOOL CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) { - FXSYS_assert(iAllocSize > 0); - Clear(); - m_bExtBuf = FALSE; - return ExpandBuf(iAllocSize); -} -int32_t CFDE_CSSTextBuf::LoadFromStream(IFX_Stream* pTxtStream, - int32_t iStreamOffset, - int32_t iMaxChars, - FX_BOOL& bEOS) { - FXSYS_assert(iStreamOffset >= 0 && iMaxChars > 0); - Clear(); - m_bExtBuf = FALSE; - if (!ExpandBuf(iMaxChars)) { - return 0; - } - if (pTxtStream->GetPosition() != iStreamOffset) { - pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset); - } - m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS); - return m_iDatLen; -} -FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) { - if (m_bExtBuf) { - return FALSE; - } - if (!m_pBuffer) { - m_pBuffer = FX_Alloc(FX_WCHAR, iDesiredSize); - } else if (m_iBufLen != iDesiredSize) { - m_pBuffer = FX_Realloc(FX_WCHAR, m_pBuffer, iDesiredSize); - } else { - return TRUE; - } - if (!m_pBuffer) { - m_iBufLen = 0; - return FALSE; - } - m_iBufLen = iDesiredSize; - return TRUE; -} -void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) { - FXSYS_assert(iStart >= 0 && iLength > 0); - if (iLength > m_iDatLen - iStart) { - iLength = m_iDatLen - iStart; - } - if (iLength < 0) { - iLength = 0; - } else { - FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR)); - } - m_iDatLen = iLength; -} diff --git a/xfa/src/fde/css/fde_csssyntax.h b/xfa/src/fde/css/fde_csssyntax.h deleted file mode 100644 index dc7acdb3d5..0000000000 --- a/xfa/src/fde/css/fde_csssyntax.h +++ /dev/null @@ -1,119 +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_SRC_FDE_CSS_FDE_CSSSYNTAX_H_ -#define XFA_SRC_FDE_CSS_FDE_CSSSYNTAX_H_ - -#include "xfa/src/fde/css/fde_css.h" -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_stream.h" - -class CFDE_CSSTextBuf : public CFX_Target { - public: - CFDE_CSSTextBuf(); - ~CFDE_CSSTextBuf(); - FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen); - FX_BOOL EstimateSize(int32_t iAllocSize); - int32_t LoadFromStream(IFX_Stream* pTxtStream, - int32_t iStreamOffset, - int32_t iMaxChars, - FX_BOOL& bEOS); - FX_BOOL AppendChar(FX_WCHAR wch) { - if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2)) { - return FALSE; - } - return (m_pBuffer[m_iDatLen++] = wch), TRUE; - } - void Clear() { m_iDatPos = m_iDatLen = 0; } - void Reset(); - int32_t TrimEnd() { - while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') { - --m_iDatLen; - } - AppendChar(0); - return --m_iDatLen; - } - void Subtract(int32_t iStart, int32_t iLength); - FX_BOOL IsEOF() const { return m_iDatPos >= m_iDatLen; } - FX_WCHAR GetAt(int32_t index) const { return m_pBuffer[index]; } - FX_WCHAR GetChar() const { return m_pBuffer[m_iDatPos]; } - FX_WCHAR GetNextChar() const { - return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pBuffer[m_iDatPos + 1]; - } - void MoveNext() { m_iDatPos++; } - int32_t GetLength() const { return m_iDatLen; } - const FX_WCHAR* GetBuffer() const { return m_pBuffer; } - - protected: - FX_BOOL ExpandBuf(int32_t iDesiredSize); - FX_BOOL m_bExtBuf; - FX_WCHAR* m_pBuffer; - int32_t m_iBufLen; - int32_t m_iDatLen; - int32_t m_iDatPos; -}; - -#define FDE_CSSSYNTAXCHECK_AllowCharset 1 -#define FDE_CSSSYNTAXCHECK_AllowImport 2 - -enum FDE_CSSSYNTAXMODE { - FDE_CSSSYNTAXMODE_RuleSet, - FDE_CSSSYNTAXMODE_Comment, - FDE_CSSSYNTAXMODE_AtRule, - FDE_CSSSYNTAXMODE_UnknownRule, - FDE_CSSSYNTAXMODE_Charset, - FDE_CSSSYNTAXMODE_Import, - FDE_CSSSYNTAXMODE_MediaRule, - FDE_CSSSYNTAXMODE_URI, - FDE_CSSSYNTAXMODE_MediaType, - FDE_CSSSYNTAXMODE_Selector, - FDE_CSSSYNTAXMODE_PropertyName, - FDE_CSSSYNTAXMODE_PropertyValue, -}; - -class CFDE_CSSSyntaxParser : public IFDE_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; - - protected: - void Reset(FX_BOOL bOnlyDeclaration); - void SwitchMode(FDE_CSSSYNTAXMODE eMode); - int32_t SwitchToComment(); - - FX_BOOL RestoreMode(); - FX_BOOL AppendChar(FX_WCHAR wch); - int32_t SaveTextData(); - FX_BOOL IsCharsetEnabled() const { - return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0; - } - 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; - CFDE_CSSTextBuf m_TextData; - CFDE_CSSTextBuf m_TextPlane; - int32_t m_iTextDatLen; - FX_DWORD m_dwCheck; - FDE_CSSSYNTAXMODE m_eMode; - FDE_CSSSYNTAXSTATUS m_eStatus; - CFX_StackTemplate<FDE_CSSSYNTAXMODE> m_ModeStack; -}; - -#endif // XFA_SRC_FDE_CSS_FDE_CSSSYNTAX_H_ diff --git a/xfa/src/fde/fde_brush.h b/xfa/src/fde/fde_brush.h deleted file mode 100644 index 00edeebe73..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_BRUSH_H_ -#define XFA_SRC_FDE_FDE_BRUSH_H_ - -#include "core/include/fxcrt/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_SRC_FDE_FDE_BRUSH_H_ diff --git a/xfa/src/fde/fde_devbasic.cpp b/xfa/src/fde/fde_devbasic.cpp deleted file mode 100644 index c119110846..0000000000 --- a/xfa/src/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/src/fde/fde_devbasic.h" - -#include <cstdint> - -#include "xfa/src/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/xfa/src/fde/fde_devbasic.h b/xfa/src/fde/fde_devbasic.h deleted file mode 100644 index 6b27bebb0c..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_DEVBASIC_H_ -#define XFA_SRC_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_SRC_FDE_FDE_DEVBASIC_H_ diff --git a/xfa/src/fde/fde_gedevice.cpp b/xfa/src/fde/fde_gedevice.cpp deleted file mode 100644 index 13ae1bb330..0000000000 --- a/xfa/src/fde/fde_gedevice.cpp +++ /dev/null @@ -1,573 +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/src/fde/fde_gedevice.h" - -#include <algorithm> - -#include "xfa/src/fde/fde_brush.h" -#include "xfa/src/fde/fde_devbasic.h" -#include "xfa/src/fde/fde_geobject.h" -#include "xfa/src/fde/fde_image.h" -#include "xfa/src/fde/fde_pen.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) - : m_pDevice(pDevice), - m_bOwnerDevice(bOwnerDevice), - m_pCharPos(NULL), - m_iCharCount(0) { - FXSYS_assert(pDevice != NULL); - 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() { - FX_Free(m_pCharPos); - if (m_bOwnerDevice) - delete m_pDevice; -} -int32_t CFDE_FxgeDevice::GetWidth() const { - return m_pDevice->GetWidth(); -} -int32_t CFDE_FxgeDevice::GetHeight() const { - return m_pDevice->GetHeight(); -} -FDE_HDEVICESTATE CFDE_FxgeDevice::SaveState() { - m_pDevice->SaveState(); - return NULL; -} -void CFDE_FxgeDevice::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) { - 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() { - return m_rtClip; -} -FX_BOOL CFDE_FxgeDevice::SetClipPath(const IFDE_Path* pClip) { - return FALSE; -} -IFDE_Path* CFDE_FxgeDevice::GetClipPath() const { - return NULL; -} -FX_FLOAT CFDE_FxgeDevice::GetDpiX() const { - return 96; -} -FX_FLOAT CFDE_FxgeDevice::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); - CFX_RectF srcRect; - if (pSrcRect) { - srcRect = *pSrcRect; - } else { - srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); - } - if (srcRect.IsEmpty()) { - return FALSE; - } - CFX_Matrix dib2fxdev; - if (pImgMatrix) { - dib2fxdev = *pImgMatrix; - } else { - dib2fxdev.SetIdentity(); - } - dib2fxdev.a = dstRect.width; - dib2fxdev.d = -dstRect.height; - dib2fxdev.e = dstRect.left; - dib2fxdev.f = dstRect.bottom(); - if (pDevMatrix) { - dib2fxdev.Concat(*pDevMatrix); - } - void* handle = NULL; - m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, - handle); - while (m_pDevice->ContinueDIBits(handle, NULL)) { - } - 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); - 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_ - FX_DWORD 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(); -#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); -#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.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_ - } -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - FxFont.SetSubstFont(nullptr); - FxFont.SetFace(nullptr); -#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - return TRUE; - } break; - default: - return FALSE; - } -} -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) { - CFX_PointsF points; - points.Add(pt1); - points.Add(pt2); - points.Add(pt3); - points.Add(pt4); - CFDE_Path path; - 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) { - 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) { - 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) { - 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) { - 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) { - CFDE_Path* pGePath = (CFDE_Path*)pPath; - if (pGePath == NULL) { - return FALSE; - } - CFX_GraphStateData graphState; - if (!CreatePen(pPen, fPenWidth, graphState)) { - return FALSE; - } - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - return FALSE; - } - graphState.m_LineCap = (CFX_GraphStateData::LineCap)pPen->GetLineCap(); - graphState.m_LineJoin = (CFX_GraphStateData::LineJoin)pPen->GetLineJoin(); - 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; - } - } - 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) { - 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) { - return FALSE; - } - CFX_DIBitmap mask; - if (!FDE_GetStockHatchMask(iStyle, mask)) { - 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; -} -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/xfa/src/fde/fde_gedevice.h b/xfa/src/fde/fde_gedevice.h deleted file mode 100644 index fa91ab151a..0000000000 --- a/xfa/src/fde/fde_gedevice.h +++ /dev/null @@ -1,136 +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_SRC_FDE_FDE_GEDEVICE_H_ -#define XFA_SRC_FDE_FDE_GEDEVICE_H_ - -#include "xfa/src/fde/fde_renderdevice.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target { - public: - CFDE_FxgeDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice); - ~CFDE_FxgeDevice(); - virtual void Release() { delete this; } - - 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(); - - virtual FX_FLOAT GetDpiX() const; - virtual 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, - IFX_Font* pFont, - const FXTEXT_CHARPOS* pCharPos, - int32_t iCount, - FX_FLOAT fFontSize, - const CFX_Matrix* pMatrix); - FX_BOOL DrawStringPath(IFDE_Brush* pBrush, - IFX_Font* pFont, - const FXTEXT_CHARPOS* pCharPos, - int32_t iCount, - FX_FLOAT fFontSize, - const CFX_Matrix* pMatrix); - - protected: - FX_BOOL CreatePen(IFDE_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; - FXTEXT_CHARPOS* m_pCharPos; - int32_t m_iCharCount; -}; - -#endif // XFA_SRC_FDE_FDE_GEDEVICE_H_ diff --git a/xfa/src/fde/fde_geobject.cpp b/xfa/src/fde/fde_geobject.cpp deleted file mode 100644 index 3170692fe7..0000000000 --- a/xfa/src/fde/fde_geobject.cpp +++ /dev/null @@ -1,255 +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/src/fde/fde_geobject.h" - -#include "xfa/src/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) { - pPoint->m_Flag |= FXPT_CLOSEFIGURE; - } - return TRUE; -} -FX_PATHPOINT* CFDE_Path::GetLastPoint(int32_t iCount) const { - if (iCount < 1) { - return NULL; - } - int32_t iPoints = m_Path.GetPointCount(); - if (iCount > iPoints) { - return NULL; - } - 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; - } - 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) { - FX_PATHPOINT* p = AddPoints(3); - p[0].m_PointX = p1.x; - p[0].m_PointY = p1.y; - p[0].m_Flag = FXPT_BEZIERTO; - p[1].m_PointX = p2.x; - p[1].m_PointY = p2.y; - p[1].m_Flag = FXPT_BEZIERTO; - p[2].m_PointX = p3.x; - 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, - FX_FLOAT endAngle) { - FX_FLOAT rx = rect.width / 2; - FX_FLOAT ry = rect.height / 2; - FX_FLOAT cx = rect.left + rx; - FX_FLOAT cy = rect.top + ry; - FX_FLOAT alpha = - FXSYS_atan2(rx * FXSYS_sin(startAngle), ry * FXSYS_cos(startAngle)); - FX_FLOAT beta = - FXSYS_atan2(rx * FXSYS_sin(endAngle), ry * FXSYS_cos(endAngle)); - if (FXSYS_fabs(beta - alpha) > FX_PI) { - if (beta > alpha) { - beta -= 2 * FX_PI; - } 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); - FX_FLOAT sin_alpha = FXSYS_sin(alpha); - FX_FLOAT sin_beta = FXSYS_sin(beta); - FX_FLOAT cos_alpha = FXSYS_cos(alpha); - FX_FLOAT cos_beta = FXSYS_cos(beta); - if (bStart) - MoveTo(CFX_PointF(cx + rx * cos_alpha, cy + ry * sin_alpha)); - - BezierTo(CFX_PointF(cx + rx * (cos_alpha - bcp * sin_alpha), - cy + ry * (sin_alpha + bcp * cos_alpha)), - CFX_PointF(cx + rx * (cos_beta + bcp * sin_beta), - cy + ry * (sin_beta - bcp * cos_beta)), - CFX_PointF(cx + rx * cos_beta, cy + ry * sin_beta)); -} - -void CFDE_Path::AddBezier(const CFX_PointsF& points) { - 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) { - return; - } - const CFX_PointF* p = points.GetData(); - const CFX_PointF* pEnd = p + iCount; - MoveTo(p[0]); - 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) { - 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) { - r = bClosed ? (r - iCount) : (iCount - 1); - } - 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) { - return; - } - CFX_PointsF tangents; - GetCurveTangents(points, tangents, bClosed, fTension); - const CFX_PointF* pPoints = points.GetData(); - CFX_PointF* pTangents = tangents.GetData(); - MoveTo(pPoints[0]); - for (int32_t i = 0; i < iLast; ++i) { - BezierTo(CFX_PointF(pPoints[i].x + pTangents[i].x, - pPoints[i].y + pTangents[i].y), - CFX_PointF(pPoints[i + 1].x - pTangents[i + 1].x, - pPoints[i + 1].y - pTangents[i + 1].y), - CFX_PointF(pPoints[i + 1].x, pPoints[i + 1].y)); - } - if (bClosed) { - BezierTo(CFX_PointF(pPoints[iLast].x + pTangents[iLast].x, - pPoints[iLast].y + pTangents[iLast].y), - CFX_PointF(pPoints[0].x - pTangents[0].x, - pPoints[0].y - pTangents[0].y), - CFX_PointF(pPoints[0].x, pPoints[0].y)); - CloseFigure(); - } -} -void CFDE_Path::AddEllipse(const CFX_RectF& rect) { - FX_FLOAT fStartAngle = 0; - FX_FLOAT fEndAngle = FX_PI / 2; - for (int32_t i = 0; i < 4; ++i) { - ArcTo(i == 0, rect, fStartAngle, fEndAngle); - fStartAngle += FX_PI / 2; - fEndAngle += FX_PI / 2; - } - 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 || - FXSYS_fabs(pLast->m_PointY - pt1.y) > 0.001) { - MoveTo(pt1); - } - LineTo(pt2); -} -void CFDE_Path::AddPath(const IFDE_Path* pSrc, FX_BOOL bConnect) { - CFDE_Path* pPath = (CFDE_Path*)pSrc; - if (pPath == NULL) { - return; - } - int32_t iCount = pPath->m_Path.GetPointCount(); - if (iCount < 1) { - return; - } - if (bConnect) { - LineTo(pPath->m_Path.GetPointX(0), pPath->m_Path.GetPointY(0)); - } - m_Path.Append(&pPath->m_Path, NULL); -} -void CFDE_Path::AddPolygon(const CFX_PointsF& points) { - int32_t iCount = points.GetSize(); - if (iCount < 2) { - return; - } - AddLines(points); - const CFX_PointF* p = points.GetData(); - if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f || - FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) { - LineTo(p[0]); - } - CloseFigure(); -} -void CFDE_Path::AddLines(const CFX_PointsF& points) { - int32_t iCount = points.GetSize(); - if (iCount < 2) { - return; - } - const CFX_PointF* p = points.GetData(); - const CFX_PointF* pEnd = p + iCount; - MoveTo(p[0]); - for (++p; p < pEnd; ++p) { - LineTo(*p); - } -} -void CFDE_Path::AddRectangle(const CFX_RectF& rect) { - MoveTo(rect.TopLeft()); - LineTo(rect.TopRight()); - LineTo(rect.BottomRight()); - 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 { - CFX_FloatRect rect = m_Path.GetBoundingBox(fLineWidth, fMiterLimit); - bbox.Set(rect.left, rect.top, rect.Width(), rect.Height()); - bbox.Normalize(); -} diff --git a/xfa/src/fde/fde_geobject.h b/xfa/src/fde/fde_geobject.h deleted file mode 100644 index 1f5cc4d056..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_GEOBJECT_H_ -#define XFA_SRC_FDE_FDE_GEOBJECT_H_ - -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fde/fde_path.h" -#include "xfa/src/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_SRC_FDE_FDE_GEOBJECT_H_ diff --git a/xfa/src/fde/fde_image.h b/xfa/src/fde/fde_image.h deleted file mode 100644 index a9f16dee6f..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_IMAGE_H_ -#define XFA_SRC_FDE_FDE_IMAGE_H_ - -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_stream.h" -#include "xfa/src/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_SRC_FDE_FDE_IMAGE_H_ diff --git a/xfa/src/fde/fde_iterator.cpp b/xfa/src/fde/fde_iterator.cpp deleted file mode 100644 index 71be02ea9d..0000000000 --- a/xfa/src/fde/fde_iterator.cpp +++ /dev/null @@ -1,98 +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/src/fde/fde_iterator.h" - -#include "xfa/src/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); - m_CanvasStack.RemoveAll(); - FDE_CANVASITEM canvas; - canvas.hCanvas = NULL; - canvas.pCanvas = pCanvas; - canvas.hPos = pCanvas->GetFirstPosition(NULL); - if (canvas.hPos == NULL) { - return FALSE; - } - return m_CanvasStack.Push(canvas) == 0; -} -FX_BOOL CFDE_VisualSetIterator::FilterObjects(FX_DWORD dwObjects) { - if (m_CanvasStack.GetSize() == 0) { - return FALSE; - } - while (m_CanvasStack.GetSize() > 1) { - m_CanvasStack.Pop(); - } - m_dwFilter = dwObjects & ~(FX_DWORD)FDE_VISUALOBJ_Widget; - if (dwObjects & FDE_VISUALOBJ_Widget) { - m_dwFilter |= 0xFF00; - } - FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement(); - FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL); - pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(NULL); - return pCanvas->hPos != NULL; -} -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) { - break; - } - m_CanvasStack.Pop(); - continue; - } - do { - FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext( - pCanvas->hCanvas, pCanvas->hPos, pVisualSet); - FXSYS_assert(hObj != NULL); - FDE_VISUALOBJTYPE eType = pVisualSet->GetType(); - if (eType == FDE_VISUALOBJ_Canvas) { - FDE_CANVASITEM canvas; - canvas.hCanvas = hObj; - canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet; - canvas.hPos = canvas.pCanvas->GetFirstPosition(hObj); - m_CanvasStack.Push(canvas); - break; - } - FX_DWORD dwObj = - (eType == FDE_VISUALOBJ_Widget) - ? (FX_DWORD)((IFDE_WidgetSet*)pVisualSet)->GetWidgetType(hObj) - : (FX_DWORD)eType; - if ((m_dwFilter & dwObj) != 0) { - if (ppCanvasSet) { - *ppCanvasSet = pCanvas->pCanvas; - } - if (phCanvasObj) { - *phCanvasObj = pCanvas->hCanvas; - } - return hObj; - } - } while (pCanvas->hPos != NULL); - } - if (ppCanvasSet) { - *ppCanvasSet = NULL; - } - if (phCanvasObj) { - *phCanvasObj = NULL; - } - pVisualSet = NULL; - return NULL; -} diff --git a/xfa/src/fde/fde_iterator.h b/xfa/src/fde/fde_iterator.h deleted file mode 100644 index 2bb4c1a19f..0000000000 --- a/xfa/src/fde/fde_iterator.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_SRC_FDE_FDE_ITERATOR_H_ -#define XFA_SRC_FDE_FDE_ITERATOR_H_ - -#include "xfa/src/fde/fde_visualset.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -struct FDE_CANVASITEM { - IFDE_CanvasSet* pCanvas; - FDE_HVISUALOBJ hCanvas; - FX_POSITION hPos; -}; - -class CFDE_VisualSetIterator : public IFDE_VisualSetIterator, - public CFX_Target { - public: - CFDE_VisualSetIterator(); - ~CFDE_VisualSetIterator(); - virtual void Release() { delete this; } - - virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas); - virtual FX_BOOL FilterObjects(FX_DWORD dwObjects = 0xFFFFFFFF); - - virtual void Reset(); - virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet, - FDE_HVISUALOBJ* phCanvasObj = NULL, - IFDE_CanvasSet** ppCanvasSet = NULL); - - protected: - FX_DWORD m_dwFilter; - CFX_StackTemplate<FDE_CANVASITEM> m_CanvasStack; -}; - -#endif // XFA_SRC_FDE_FDE_ITERATOR_H_ diff --git a/xfa/src/fde/fde_object.cpp b/xfa/src/fde/fde_object.cpp deleted file mode 100644 index 1350ae9e9b..0000000000 --- a/xfa/src/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/src/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/xfa/src/fde/fde_object.h b/xfa/src/fde/fde_object.h deleted file mode 100644 index d9e5737fa0..0000000000 --- a/xfa/src/fde/fde_object.h +++ /dev/null @@ -1,246 +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_SRC_FDE_FDE_OBJECT_H_ -#define XFA_SRC_FDE_FDE_OBJECT_H_ - -#include <cstdint> - -#include "core/include/fxge/fx_dib.h" -#include "xfa/src/fde/fde_brush.h" -#include "xfa/src/fde/fde_pen.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -class CFDE_Pen : public IFDE_Pen, 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_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 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 { - public: - CFDE_TextureBrush() : m_iWrap(0), m_pImage(NULL), m_bAutoRelease(FALSE) { - m_Matrix.SetIdentity(); - } - - 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; - } - - 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; -}; - -#endif // XFA_SRC_FDE_FDE_OBJECT_H_ diff --git a/xfa/src/fde/fde_path.h b/xfa/src/fde/fde_path.h deleted file mode 100644 index a6a8d674d6..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_PATH_H_ -#define XFA_SRC_FDE_FDE_PATH_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "core/include/fxcrt/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_SRC_FDE_FDE_PATH_H_ diff --git a/xfa/src/fde/fde_pen.h b/xfa/src/fde/fde_pen.h deleted file mode 100644 index adaa2da256..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_PEN_H_ -#define XFA_SRC_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_SRC_FDE_FDE_PEN_H_ diff --git a/xfa/src/fde/fde_render.cpp b/xfa/src/fde/fde_render.cpp deleted file mode 100644 index b4330cc084..0000000000 --- a/xfa/src/fde/fde_render.cpp +++ /dev/null @@ -1,291 +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/src/fde/fde_render.h" - -#include "xfa/src/fde/fde_renderdevice.h" -#include "xfa/src/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, - FX_DWORD 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_Transform(), - m_pCharPos(NULL), - m_iCharPosCount(0), - m_pIterator(NULL) { - m_Transform.SetIdentity(); -} -CFDE_RenderContext::~CFDE_RenderContext() { - StopRender(); -} -FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice, - IFDE_CanvasSet* pCanvasSet, - const CFX_Matrix& tmDoc2Device) { - if (m_pRenderDevice != NULL) { - return FALSE; - } - if (pRenderDevice == NULL) { - return FALSE; - } - if (pCanvasSet == NULL) { - 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); - } - return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects(); -} -FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { - if (m_pRenderDevice == NULL) { - return FDE_RENDERSTATUS_Failed; - } - if (m_pIterator == NULL) { - return FDE_RENDERSTATUS_Failed; - } - FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused; - CFX_Matrix rm; - rm.SetReverse(m_Transform); - CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect(); - if (rtDocClip.IsEmpty()) { - rtDocClip.left = rtDocClip.top = 0; - rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth(); - rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight(); - } - rm.TransformRect(rtDocClip); - IFDE_VisualSet* pVisualSet; - FDE_HVISUALOBJ hVisualObj; - CFX_RectF rtObj; - int32_t iCount = 0; - while (TRUE) { - hVisualObj = m_pIterator->GetNext(pVisualSet); - if (hVisualObj == NULL || pVisualSet == NULL) { - eStatus = FDE_RENDERSTATUS_Done; - break; - } - rtObj.Empty(); - pVisualSet->GetRect(hVisualObj, 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); - break; - default: - break; - } - if (iCount >= 100 && pPause != NULL && 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; - } - 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); - IFX_Font* pFont = pTextSet->GetFont(hText); - if (pFont == NULL) { - return; - } - int32_t iCount = pTextSet->GetDisplayPos(hText, NULL, 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) { - m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount); - } else if (m_iCharPosCount < iCount) { - m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, 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); - FDE_HDEVICESTATE hState; - FX_BOOL bClip = ApplyClip(pTextSet, hText, hState); - m_pRenderDevice->DrawString(m_pSolidBrush, pFont, m_pCharPos, iCount, - fFontSize, &m_Transform); - 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)) { - return FALSE; - } - CFX_RectF rtObj; - pVisualSet->GetRect(hObj, rtObj); - rtClip.Offset(rtObj.left, rtObj.top); - m_Transform.TransformRect(rtClip); - const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect(); - rtClip.Intersect(rtDevClip); - hState = m_pRenderDevice->SaveState(); - return m_pRenderDevice->SetClipRect(rtClip); -} -void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) { - m_pRenderDevice->RestoreState(hState); -} diff --git a/xfa/src/fde/fde_render.h b/xfa/src/fde/fde_render.h deleted file mode 100644 index 2995d10aae..0000000000 --- a/xfa/src/fde/fde_render.h +++ /dev/null @@ -1,40 +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_SRC_FDE_FDE_RENDER_H_ -#define XFA_SRC_FDE_FDE_RENDER_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "xfa/src/fde/fde_visualset.h" - -class IFDE_RenderDevice; - -void FDE_GetPageMatrix(CFX_Matrix& pageMatrix, - const CFX_RectF& docPageRect, - const CFX_Rect& devicePageRect, - int32_t iRotate, - FX_DWORD dwCoordinatesType = 0); -enum FDE_RENDERSTATUS { - FDE_RENDERSTATUS_Reset = 0, - FDE_RENDERSTATUS_Paused, - FDE_RENDERSTATUS_Done, - FDE_RENDERSTATUS_Failed, -}; - -class IFDE_RenderContext { - 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; -}; - -#endif // XFA_SRC_FDE_FDE_RENDER_H_ diff --git a/xfa/src/fde/fde_renderdevice.h b/xfa/src/fde/fde_renderdevice.h deleted file mode 100644 index 63a36642d9..0000000000 --- a/xfa/src/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_SRC_FDE_FDE_RENDERDEVICE_H_ -#define XFA_SRC_FDE_FDE_RENDERDEVICE_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "core/include/fxge/fx_font.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fde/fde_path.h" -#include "xfa/src/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_SRC_FDE_FDE_RENDERDEVICE_H_ diff --git a/xfa/src/fde/fde_visualset.h b/xfa/src/fde/fde_visualset.h deleted file mode 100644 index 71c431f1fc..0000000000 --- a/xfa/src/fde/fde_visualset.h +++ /dev/null @@ -1,123 +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_SRC_FDE_FDE_VISUALSET_H_ -#define XFA_SRC_FDE_FDE_VISUALSET_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "core/include/fxcrt/fx_system.h" -#include "core/include/fxge/fx_dib.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fde/fde_brush.h" -#include "xfa/src/fde/fde_image.h" -#include "xfa/src/fde/fde_path.h" -#include "xfa/src/fde/fde_pen.h" -#include "xfa/src/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, -}; - -typedef struct FDE_HVISUALOBJ_ { void* pData; } const* FDE_HVISUALOBJ; - -class IFDE_VisualSet { - public: - virtual ~IFDE_VisualSet() {} - virtual FDE_VISUALOBJTYPE GetType() = 0; - virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) = 0; - virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) = 0; - virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; - virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; -}; - -class IFDE_CanvasSet : public IFDE_VisualSet { - public: - virtual FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) = 0; - virtual FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas, - FX_POSITION& pos, - IFDE_VisualSet*& pVisualSet) = 0; - virtual FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas, - IFDE_VisualSet*& pVisualSet) = 0; -}; - -class IFDE_TextSet : public IFDE_VisualSet { - public: - virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) = 0; - virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText) = 0; - virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) = 0; - virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) = 0; - virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL) = 0; - virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, - 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(FX_DWORD 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_SRC_FDE_FDE_VISUALSET_H_ diff --git a/xfa/src/fde/tto/fde_textout.cpp b/xfa/src/fde/tto/fde_textout.cpp deleted file mode 100644 index fc3e4ab24b..0000000000 --- a/xfa/src/fde/tto/fde_textout.cpp +++ /dev/null @@ -1,1120 +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/src/fde/tto/fde_textout.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_coordinates.h" -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fde/fde_brush.h" -#include "xfa/src/fde/fde_pen.h" -#include "xfa/src/fde/fde_renderdevice.h" -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_utils.h" -#include "xfa/src/fgas/layout/fgas_textbreak.h" - -namespace { - -struct FDE_TTOPIECE { - public: - int32_t iStartChar; - int32_t iChars; - FX_DWORD 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(FX_DWORD 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(FX_DWORD 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(FX_DWORD 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; - FX_DWORD m_dwStyles; - FX_DWORD 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), - m_fLineSpace(m_fFontSize), - m_fLinePos(0.0f), - m_fTolerance(0.0f), - m_iAlignment(0), - m_iTxtBkAlignment(0), - m_pCharWidths(NULL), - m_iChars(0), - m_pEllCharWidths(NULL), - m_iEllChars(0), - m_wParagraphBkChar(L'\n'), - m_TxtColor(0xFF000000), - m_dwStyles(0), - m_dwTxtBkStyles(0), - m_bElliChanged(FALSE), - m_iEllipsisWidth(0), - m_ttoLines(5), - m_iCurLine(0), - 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_Matrix.SetIdentity(); - m_rtClip.Reset(); - m_rtLogicClip.Reset(); -} -CFDE_TextOut::~CFDE_TextOut() { - if (m_pTxtBreak) { - m_pTxtBreak->Release(); - } - 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); - m_pFont = pFont; - m_pTxtBreak->SetFont(pFont); -} -void CFDE_TextOut::SetFontSize(FX_FLOAT fFontSize) { - FXSYS_assert(fFontSize > 0); - m_fFontSize = fFontSize; - m_pTxtBreak->SetFontSize(fFontSize); -} -void CFDE_TextOut::SetTextColor(FX_ARGB color) { - m_TxtColor = color; -} -void CFDE_TextOut::SetStyles(FX_DWORD dwStyles) { - m_dwStyles = dwStyles; - m_dwTxtBkStyles = 0; - if (dwStyles & FDE_TTOSTYLE_SingleLine) { - m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_SingleLine; - } - if (dwStyles & FDE_TTOSTYLE_ExpandTab) { - m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ExpandTab; - } - if (dwStyles & FDE_TTOSTYLE_ArabicShapes) { - m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ArabicShapes; - } - if (dwStyles & FDE_TTOSTYLE_RTL) { - m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_RTLReadingOrder; - } - if (dwStyles & FDE_TTOSTYLE_ArabicContext) { - m_dwTxtBkStyles |= FX_TXTLAYOUTSTYLE_ArabicContext; - } - if (dwStyles & FDE_TTOSTYLE_VerticalLayout) { - m_dwTxtBkStyles |= - (FX_TXTLAYOUTSTYLE_VerticalChars | FX_TXTLAYOUTSTYLE_VerticalLayout); - } - m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles); -} -void CFDE_TextOut::SetTabWidth(FX_FLOAT fTabWidth) { - FXSYS_assert(fTabWidth > 1.0f); - m_pTxtBreak->SetTabWidth(fTabWidth, FALSE); -} -void CFDE_TextOut::SetEllipsisString(const CFX_WideString& wsEllipsis) { - m_bElliChanged = TRUE; - m_wsEllipsis = wsEllipsis; -} -void CFDE_TextOut::SetParagraphBreakChar(FX_WCHAR wch) { - m_wParagraphBkChar = wch; - m_pTxtBreak->SetParagraphBreakChar(wch); -} -void CFDE_TextOut::SetAlignment(int32_t iAlignment) { - m_iAlignment = iAlignment; - switch (m_iAlignment) { - case FDE_TTOALIGNMENT_TopCenter: - case FDE_TTOALIGNMENT_Center: - case FDE_TTOALIGNMENT_BottomCenter: - m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Center; - break; - case FDE_TTOALIGNMENT_TopRight: - case FDE_TTOALIGNMENT_CenterRight: - case FDE_TTOALIGNMENT_BottomRight: - m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Right; - break; - default: - m_iTxtBkAlignment = FX_TXTLINEALIGNMENT_Left; - break; - } - m_pTxtBreak->SetAlignment(m_iTxtBkAlignment); -} -void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) { - FXSYS_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); -} -void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) { - FXSYS_assert(pDevice != NULL); - if (m_pRenderDevice != NULL) { - m_pRenderDevice->Release(); - } - m_pRenderDevice = IFDE_RenderDevice::Create(pDevice); -} -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()); -} -void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) { - m_rtClip = rtClip; -} -void CFDE_TextOut::SetLogicClipRect(const CFX_RectF& rtClip) { - m_rtLogicClip = rtClip; -} -void CFDE_TextOut::SetMatrix(const CFX_Matrix& matrix) { - m_Matrix = matrix; -} -void CFDE_TextOut::SetLineBreakTolerance(FX_FLOAT fTolerance) { - m_fTolerance = fTolerance; - m_pTxtBreak->SetLineBreakTolerance(m_fTolerance); -} -int32_t CFDE_TextOut::GetTotalLines() { - return m_iTotalLines; -} -void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_Size& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y); - CalcSize(pwsStr, iLength, rtText); - size.x = (int32_t)rtText.Width(); - size.y = (int32_t)rtText.Height(); -} -void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); - CalcSize(pwsStr, iLength, rtText); - size.x = rtText.Width(); - size.y = rtText.Height(); -} -void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(), - (FX_FLOAT)rect.Height()); - CalcSize(pwsStr, iLength, rtText); - rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(), - (int32_t)rtText.Height()); -} -void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_RectF& rect) { - if (pwsStr == NULL || iLength < 1) { - rect.width = 0.0f; - rect.height = 0.0f; - } else { - CFX_Matrix rm; - rm.SetReverse(m_Matrix); - rm.TransformRect(rect); - CalcTextSize(pwsStr, iLength, rect); - m_Matrix.TransformRect(rect); - } -} -void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); - CalcLogicSize(pwsStr, iLength, rtText); - size.x = rtText.Width(); - size.y = rtText.Height(); -} -void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_RectF& rect) { - if (pwsStr == NULL || iLength < 1) { - rect.width = 0.0f; - rect.height = 0.0f; - } else { - CalcTextSize(pwsStr, iLength, rect); - } -} -void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr, - int32_t iLength, - CFX_RectF& rect) { - FXSYS_assert(m_pFont != NULL && m_fFontSize >= 1.0f); - SetLineWidth(rect); - m_iTotalLines = 0; - const FX_WCHAR* pStr = pwsStr; - FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); - FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); - FX_FLOAT fWidth = 0.0f; - FX_FLOAT fHeight = 0.0f; - FX_FLOAT fStartPos = bVertical ? rect.bottom() : rect.right(); - FX_DWORD dwBreakStatus = 0; - FX_WCHAR wPreChar = 0; - FX_WCHAR wch; - FX_WCHAR wBreak = 0; - while (iLength-- > 0) { - wch = *pStr++; - if (wBreak == 0 && (wch == L'\n' || wch == L'\r')) { - wBreak = wch; - m_pTxtBreak->SetParagraphBreakChar(wch); - } - if (bHotKey && wch == L'&' && wPreChar != L'&') { - wPreChar = wch; - continue; - } - dwBreakStatus = m_pTxtBreak->AppendChar(wch); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight); - } - wPreChar = 0; - } - dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight); - } - m_pTxtBreak->Reset(); - FX_FLOAT fInc = rect.Height() - fHeight; - if (bVertical) { - fInc = rect.Width() - fHeight; - } - if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && - m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { - fInc /= 2.0f; - } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { - fInc = 0.0f; - } - if (bVertical) { - rect.top += fStartPos; - rect.left += fInc; - rect.width = fHeight; - rect.height = std::min(fWidth, rect.Height()); - } else { - rect.left += fStartPos; - rect.top += fInc; - rect.width = std::min(fWidth, rect.Width()); - rect.height = fHeight; - if (m_dwStyles & FDE_TTOSTYLE_LastLineHeight) { - rect.height -= m_fLineSpace - m_fFontSize; - } - } -} -void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) { - if ((m_dwStyles & FDE_TTOSTYLE_SingleLine) == 0) { - FX_FLOAT fLineWidth = 0.0f; - if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) { - if (rect.Height() < 1.0f) { - rect.height = m_fFontSize * 1000.0f; - } - fLineWidth = rect.Height(); - } else { - if (rect.Width() < 1.0f) { - rect.width = m_fFontSize * 1000.0f; - } - fLineWidth = rect.Width(); - } - m_pTxtBreak->SetLineWidth(fLineWidth); - } -} -FX_BOOL CFDE_TextOut::RetrieveLineWidth(FX_DWORD dwBreakStatus, - FX_FLOAT& fStartPos, - FX_FLOAT& fWidth, - FX_FLOAT& fHeight) { - if (dwBreakStatus <= FX_TXTBREAK_PieceBreak) { - return FALSE; - } - FX_FLOAT fLineStep = - (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; - FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); - FX_FLOAT fLineWidth = 0.0f; - int32_t iCount = m_pTxtBreak->CountBreakPieces(); - for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); - fLineWidth += (FX_FLOAT)pPiece->m_iWidth / 20000.0f; - fStartPos = std::min(fStartPos, (FX_FLOAT)pPiece->m_iStartPos / 20000.0f); - } - m_pTxtBreak->ClearBreakPieces(); - if (dwBreakStatus == FX_TXTBREAK_ParagraphBreak) { - m_pTxtBreak->Reset(); - } - if (!bLineWrap && dwBreakStatus == FX_TXTBREAK_LineBreak) { - fWidth += fLineWidth; - } else { - fWidth = std::max(fWidth, fLineWidth); - fHeight += fLineStep; - } - m_iTotalLines++; - return TRUE; -} -void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, - int32_t iLength, - int32_t x, - int32_t y) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)x, (FX_FLOAT)y, m_fFontSize * 1000.0f, - m_fFontSize * 1000.0f); - DrawText(pwsStr, iLength, rtText); -} -void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, - int32_t iLength, - FX_FLOAT x, - FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); - DrawText(pwsStr, iLength, rtText); -} -void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, - int32_t iLength, - const CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.width, - (FX_FLOAT)rect.height); - DrawText(pwsStr, iLength, rtText); -} -void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, - int32_t iLength, - const CFX_RectF& rect) { - CFX_RectF rtText; - rtText.Set(rect.left, rect.top, rect.width, rect.height); - CFX_Matrix rm; - rm.SetReverse(m_Matrix); - rm.TransformRect(rtText); - DrawText(pwsStr, iLength, rtText, m_rtClip); -} -void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, - int32_t iLength, - FX_FLOAT x, - FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); - DrawLogicText(pwsStr, iLength, rtText); -} -void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, - int32_t iLength, - const CFX_RectF& rect) { - CFX_RectF rtClip; - rtClip.Set(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, - m_rtLogicClip.height); - m_Matrix.TransformRect(rtClip); - DrawText(pwsStr, iLength, rect, rtClip); -} -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); - if (pwsStr == NULL || iLength < 1) { - return; - } - if (rect.width < m_fFontSize || rect.height < m_fFontSize) { - return; - } - FX_FLOAT fLineWidth = rect.width; - if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) { - fLineWidth = rect.height; - } - m_pTxtBreak->SetLineWidth(fLineWidth); - m_ttoLines.RemoveAll(TRUE); - m_wsText.Empty(); - LoadText(pwsStr, iLength, rect); - if (m_dwStyles & FDE_TTOSTYLE_Ellipsis) { - ReplaceWidthEllipsis(); - } - Reload(rect); - DoAlignment(rect); - OnDraw(rtClip); -} -void CFDE_TextOut::ExpandBuffer(int32_t iSize, int32_t iType) { - switch (iType) { - case 0: - if (!m_pCharWidths) { - m_pCharWidths = FX_Alloc(int32_t, iSize); - m_iChars = iSize; - } else if (m_iChars < iSize) { - m_pCharWidths = FX_Realloc(int32_t, m_pCharWidths, iSize); - m_iChars = iSize; - } - FXSYS_memset(m_pCharWidths, 0, iSize * sizeof(int32_t)); - break; - case 1: - if (!m_pEllCharWidths) { - m_pEllCharWidths = FX_Alloc(int32_t, iSize); - m_iEllChars = iSize; - } else if (m_iEllChars < iSize) { - m_pEllCharWidths = FX_Realloc(int32_t, m_pEllCharWidths, iSize); - m_iEllChars = iSize; - } - FXSYS_memset(m_pEllCharWidths, 0, iSize * sizeof(int32_t)); - break; - case 2: - if (m_pCharPos == NULL) { - m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iSize); - m_iCharPosSize = iSize; - } else if (m_iCharPosSize < iSize) { - m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iSize); - m_iCharPosSize = iSize; - } - break; - } -} -void CFDE_TextOut::LoadEllipsis() { - if (!m_bElliChanged) { - return; - } - m_bElliChanged = FALSE; - m_iEllipsisWidth = 0; - int32_t iLength = m_wsEllipsis.GetLength(); - if (iLength < 1) { - return; - } - ExpandBuffer(iLength, 1); - const FX_WCHAR* pStr = (const FX_WCHAR*)m_wsEllipsis; - int32_t* pCharWidths = m_pEllCharWidths; - FX_DWORD dwBreakStatus; - FX_WCHAR wch; - while (iLength-- > 0) { - wch = *pStr++; - dwBreakStatus = m_pTxtBreak->AppendChar(wch); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetrieveEllPieces(pCharWidths); - } - } - dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetrieveEllPieces(pCharWidths); - } - m_pTxtBreak->Reset(); -} -void CFDE_TextOut::RetrieveEllPieces(int32_t*& pCharWidths) { - int32_t iCount = m_pTxtBreak->CountBreakPieces(); - CFX_Char* pTC; - for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); - int32_t iPieceChars = pPiece->GetLength(); - for (int32_t j = 0; j < iPieceChars; j++) { - pTC = pPiece->GetCharPtr(j); - if (pTC->m_iCharWidth <= 0) { - *pCharWidths = 0; - } else { - *pCharWidths = pTC->m_iCharWidth; - } - m_iEllipsisWidth += *pCharWidths; - pCharWidths++; - } - } - m_pTxtBreak->ClearBreakPieces(); -} -void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr, - int32_t iLength, - const CFX_RectF& rect) { - FX_WCHAR* pStr = m_wsText.GetBuffer(iLength); - int32_t iTxtLength = iLength; - ExpandBuffer(iTxtLength, 0); - FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); - FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); - FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); - FX_FLOAT fLineStep = - (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; - FX_FLOAT fLineStop = bVertical ? rect.left : rect.bottom(); - m_fLinePos = bVertical ? rect.right() : rect.top; - if (bVertical) { - fLineStep = -fLineStep; - } - m_hotKeys.RemoveAll(); - int32_t iStartChar = 0; - int32_t iChars = 0; - int32_t iPieceWidths = 0; - FX_DWORD dwBreakStatus; - FX_WCHAR wch; - FX_BOOL bRet = FALSE; - while (iTxtLength-- > 0) { - wch = *pwsStr++; - if (wch == L'&' && bHotKey && (pStr - 1) != NULL && *(pStr - 1) != L'&') { - if (iTxtLength > 0) { - m_hotKeys.Add(iChars); - } - continue; - } - *pStr++ = wch; - iChars++; - dwBreakStatus = m_pTxtBreak->AppendChar(wch); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - FX_BOOL bEndofLine = - RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, FALSE, rect); - if (bEndofLine && (bLineWrap || (dwBreakStatus > FX_TXTBREAK_LineBreak && - !bLineWrap))) { - iPieceWidths = 0; - m_iCurLine++; - m_fLinePos += fLineStep; - } - if ((bVertical && m_fLinePos + fLineStep < fLineStop) || - (!bVertical && m_fLinePos + fLineStep > fLineStop)) { - int32_t iCurLine = m_iCurLine; - if (bEndofLine) { - iCurLine--; - } - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iCurLine); - pLine->m_bNewReload = TRUE; - bRet = TRUE; - break; - } - } - } - dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak && !bRet) { - RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, FALSE, rect); - } - m_pTxtBreak->ClearBreakPieces(); - m_pTxtBreak->Reset(); - m_wsText.ReleaseBuffer(iLength); -} -FX_BOOL CFDE_TextOut::RetriecePieces(FX_DWORD dwBreakStatus, - int32_t& iStartChar, - int32_t& iPieceWidths, - FX_BOOL bReload, - const CFX_RectF& rect) { - FX_BOOL bSingleLine = !!(m_dwStyles & FDE_TTOSTYLE_SingleLine); - FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); - FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); - FX_FLOAT fLineStep = - (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; - if (bVertical) { - fLineStep = -fLineStep; - } - CFX_Char* pTC = NULL; - FX_BOOL bNeedReload = FALSE; - FX_FLOAT fLineWidth = bVertical ? rect.Height() : rect.Width(); - int32_t iLineWidth = FXSYS_round(fLineWidth * 20000.0f); - int32_t iCount = m_pTxtBreak->CountBreakPieces(); - for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); - int32_t iPieceChars = pPiece->GetLength(); - int32_t iChar = iStartChar; - int32_t iWidth = 0; - int32_t j = 0; - for (; j < iPieceChars; j++) { - pTC = pPiece->GetCharPtr(j); - int32_t iCurCharWidth = pTC->m_iCharWidth > 0 ? pTC->m_iCharWidth : 0; - if (bSingleLine || !bLineWrap) { - if (iLineWidth - iPieceWidths - iWidth < iCurCharWidth) { - bNeedReload = TRUE; - break; - } - } - iWidth += iCurCharWidth; - m_pCharWidths[iChar++] = iCurCharWidth; - } - if (j == 0 && !bReload) { - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine); - pLine->m_bNewReload = TRUE; - } else if (j > 0) { - CFX_RectF rtPiece; - if (bVertical) { - rtPiece.left = m_fLinePos; - rtPiece.top = rect.top + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; - rtPiece.width = fLineStep; - rtPiece.height = iWidth / 20000.0f; - } else { - rtPiece.left = rect.left + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; - rtPiece.top = m_fLinePos; - rtPiece.width = iWidth / 20000.0f; - rtPiece.height = fLineStep; - } - FDE_TTOPIECE ttoPiece; - ttoPiece.iStartChar = iStartChar; - ttoPiece.iChars = j; - ttoPiece.rtPiece = rtPiece; - ttoPiece.dwCharStyles = pPiece->m_dwCharStyles; - if (FX_IsOdd(pPiece->m_iBidiLevel)) { - ttoPiece.dwCharStyles |= FX_TXTCHARSTYLE_OddBidiLevel; - } - AppendPiece(ttoPiece, bNeedReload, (bReload && i == iCount - 1)); - } - iStartChar += iPieceChars; - iPieceWidths += iWidth; - } - m_pTxtBreak->ClearBreakPieces(); - FX_BOOL bRet = bSingleLine || bLineWrap || (!bLineWrap && bNeedReload) || - dwBreakStatus == FX_TXTBREAK_ParagraphBreak; - return bRet; -} -void CFDE_TextOut::AppendPiece(const FDE_TTOPIECE& ttoPiece, - FX_BOOL bNeedReload, - FX_BOOL bEnd) { - if (m_iCurLine >= m_ttoLines.GetSize()) { - CFDE_TTOLine ttoLine; - ttoLine.m_bNewReload = bNeedReload; - m_iCurPiece = ttoLine.AddPiece(m_iCurPiece, ttoPiece); - m_iCurLine = m_ttoLines.Add(ttoLine); - } else { - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine); - pLine->m_bNewReload = bNeedReload; - m_iCurPiece = pLine->AddPiece(m_iCurPiece, ttoPiece); - if (bEnd) { - int32_t iPieces = pLine->GetSize(); - if (m_iCurPiece < iPieces) { - pLine->RemoveLast(iPieces - m_iCurPiece - 1); - } - } - } - if (!bEnd && bNeedReload) { - m_iCurPiece = 0; - } -} -void CFDE_TextOut::ReplaceWidthEllipsis() { - LoadEllipsis(); - int32_t iLength = m_wsEllipsis.GetLength(); - if (iLength < 1) { - return; - } - int32_t iLines = m_ttoLines.GetSize(); - for (int32_t i = 0; i < iLines; i++) { - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); - if (!pLine->m_bNewReload) { - continue; - } - int32_t iEllipsisCharIndex = iLength - 1; - int32_t iCharWidth = 0; - int32_t iCharCount = 0; - int32_t iPiece = pLine->GetSize(); - while (iPiece-- > 0) { - FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(iPiece); - if (pPiece == NULL) { - break; - } - for (int32_t j = pPiece->iChars - 1; j >= 0; j--) { - if (iEllipsisCharIndex < 0) { - break; - } - int32_t index = pPiece->iStartChar + j; - iCharWidth += m_pCharWidths[index]; - iCharCount++; - if (iCharCount <= iLength) { - m_wsText.SetAt(index, m_wsEllipsis.GetAt(iEllipsisCharIndex)); - m_pCharWidths[index] = m_pEllCharWidths[iEllipsisCharIndex]; - } else if (iCharWidth <= m_iEllipsisWidth) { - m_wsText.SetAt(index, 0); - m_pCharWidths[index] = 0; - } - iEllipsisCharIndex--; - } - if (iEllipsisCharIndex < 0) { - break; - } - } - } -} -void CFDE_TextOut::Reload(const CFX_RectF& rect) { - int32_t iCount = m_ttoLines.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); - if (pLine == NULL || !pLine->m_bNewReload) { - continue; - } - m_iCurLine = i; - m_iCurPiece = 0; - ReloadLinePiece(pLine, rect); - } -} -void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) { - const FX_WCHAR* pwsStr = (const FX_WCHAR*)m_wsText; - FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); - int32_t iPieceWidths = 0; - FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); - int32_t iStartChar = pPiece->iStartChar; - m_fLinePos = bVertical ? pPiece->rtPiece.left : pPiece->rtPiece.top; - int32_t iPieceCount = pLine->GetSize(); - int32_t iPieceIndex = 0; - FX_DWORD dwBreakStatus = 0; - FX_WCHAR wch; - while (iPieceIndex < iPieceCount) { - int32_t iStar = iStartChar; - int32_t iEnd = pPiece->iChars + iStar; - while (iStar < iEnd) { - wch = *(pwsStr + iStar); - dwBreakStatus = m_pTxtBreak->AppendChar(wch); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); - } - iStar++; - } - iPieceIndex++; - pPiece = pLine->GetPtrAt(iPieceIndex); - } - dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, TRUE, rect); - } - m_pTxtBreak->Reset(); -} -void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { - FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); - FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); - int32_t iLines = m_ttoLines.GetSize(); - if (iLines < 1) { - return; - } - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1); - FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0); - if (pPiece == NULL) { - return; - } - FX_FLOAT fLineStopD = - bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom(); - FX_FLOAT fInc = fLineStopS - fLineStopD; - if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && - m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { - fInc /= 2.0f; - } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { - fInc = 0.0f; - } - if (fInc < 1.0f) { - return; - } - for (int32_t i = 0; i < iLines; i++) { - 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); - if (bVertical) { - pPiece->rtPiece.left += fInc; - } else { - pPiece->rtPiece.top += fInc; - } - } - } -} -void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { - if (m_pRenderDevice == NULL) { - return; - } - int32_t iLines = m_ttoLines.GetSize(); - if (iLines < 1) { - return; - } - IFDE_SolidBrush* pBrush = - (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid); - pBrush->SetColor(m_TxtColor); - IFDE_Pen* pPen = NULL; - FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState(); - if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { - m_pRenderDevice->SetClipRect(rtClip); - } - for (int32_t i = 0; i < iLines; i++) { - 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); - if (pPiece == NULL) { - continue; - } - int32_t iCount = GetDisplayPos(pPiece); - if (iCount > 0) { - m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, - m_fFontSize, &m_Matrix); - } - DrawLine(pPiece, pPen); - } - } - m_pRenderDevice->RestoreState(hDev); - if (pBrush) { - pBrush->Release(); - } - if (pPen) { - pPen->Release(); - } -} -int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) { - FX_TXTRUN tr; - ToTextRun(pPiece, tr); - 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); - 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; - 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; -} -void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_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) { - return; - } - if (pPen == NULL) { - pPen = IFDE_Pen::Create(); - pPen->SetColor(m_TxtColor); - } - IFDE_Path* pPath = IFDE_Path::Create(); - int32_t iLineCount = 0; - CFX_RectF rtText = pPiece->rtPiece; - CFX_PointF pt1, pt2; - if (bUnderLine) { - if (bVertical) { - pt1.x = rtText.left; - pt1.y = rtText.top; - pt2.x = rtText.left; - pt2.y = rtText.bottom(); - } else { - pt1.x = rtText.left; - pt1.y = rtText.bottom(); - pt2.x = rtText.right(); - pt2.y = rtText.bottom(); - } - pPath->AddLine(pt1, pt2); - iLineCount++; - } - if (bStrikeOut) { - if (bVertical) { - pt1.x = rtText.left + rtText.width * 2.0f / 5.0f; - pt1.y = rtText.top; - pt2.x = pt1.x; - pt2.y = rtText.bottom(); - } else { - pt1.x = rtText.left; - pt1.y = rtText.bottom() - rtText.height * 2.0f / 5.0f; - pt2.x = rtText.right(); - pt2.y = pt1.y; - } - pPath->AddLine(pt1, pt2); - iLineCount++; - } - if (bHotKey) { - int32_t iHotKeys = m_hotKeys.GetSize(); - int32_t iCount = GetCharRects(pPiece); - if (iCount > 0) { - for (int32_t i = 0; i < iHotKeys; i++) { - int32_t iCharIndex = m_hotKeys.GetAt(i); - if (iCharIndex >= pPiece->iStartChar && - iCharIndex < pPiece->iStartChar + pPiece->iChars) { - CFX_RectF rect = m_rectArray.GetAt(iCharIndex - pPiece->iStartChar); - if (bVertical) { - pt1.x = rect.left; - pt1.y = rect.top; - pt2.x = rect.left; - pt2.y = rect.bottom(); - } else { - pt1.x = rect.left; - pt1.y = rect.bottom(); - pt2.x = rect.right(); - pt2.y = rect.bottom(); - } - pPath->AddLine(pt1, pt2); - iLineCount++; - } - } - } - } - if (iLineCount > 0) { - m_pRenderDevice->DrawPath(pPen, 1, pPath, &m_Matrix); - } - pPath->Release(); -} -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; - m_iPieceCount++; - } else { - FDE_TTOPIECE& piece = m_pieces.GetAt(index); - piece = ttoPiece; - } - return index; -} -int32_t CFDE_TTOLine::GetSize() const { - return m_iPieceCount; -} -FDE_LPTTOPIECE CFDE_TTOLine::GetPtrAt(int32_t index) { - if (index >= m_iPieceCount) { - return NULL; - } - return m_pieces.GetPtrAt(index); -} -void CFDE_TTOLine::RemoveLast(int32_t iCount) { - m_pieces.RemoveLast(iCount); -} -void CFDE_TTOLine::RemoveAll(FX_BOOL bLeaveMemory) { - m_pieces.RemoveAll(bLeaveMemory); -} diff --git a/xfa/src/fde/tto/fde_textout.h b/xfa/src/fde/tto/fde_textout.h deleted file mode 100644 index 0b8074bad7..0000000000 --- a/xfa/src/fde/tto/fde_textout.h +++ /dev/null @@ -1,102 +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_SRC_FDE_TTO_FDE_TEXTOUT_H_ -#define XFA_SRC_FDE_TTO_FDE_TEXTOUT_H_ - -#include "core/include/fxge/fx_dib.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fgas/font/fgas_font.h" - -#define FDE_TTOSTYLE_Underline 0x0001 -#define FDE_TTOSTYLE_Strikeout 0x0002 -#define FDE_TTOSTYLE_VerticalLayout 0x0004 -#define FDE_TTOSTYLE_SingleLine 0x0010 -#define FDE_TTOSTYLE_ExpandTab 0x0020 -#define FDE_TTOSTYLE_HotKey 0x0040 -#define FDE_TTOSTYLE_Ellipsis 0x0080 -#define FDE_TTOSTYLE_LineWrap 0x0100 -#define FDE_TTOSTYLE_ArabicShapes 0x0200 -#define FDE_TTOSTYLE_RTL 0x0400 -#define FDE_TTOSTYLE_ArabicContext 0x0800 -#define FDE_TTOSTYLE_LastLineHeight 0x1000 -#define FDE_TTOALIGNMENT_TopLeft 0 -#define FDE_TTOALIGNMENT_TopCenter 1 -#define FDE_TTOALIGNMENT_TopRight 2 -#define FDE_TTOALIGNMENT_TopAuto 3 -#define FDE_TTOALIGNMENT_CenterLeft 4 -#define FDE_TTOALIGNMENT_Center 5 -#define FDE_TTOALIGNMENT_CenterRight 6 -#define FDE_TTOALIGNMENT_CenterAuto 7 -#define FDE_TTOALIGNMENT_BottomLeft 8 -#define FDE_TTOALIGNMENT_BottomCenter 9 -#define FDE_TTOALIGNMENT_BottomRight 10 -#define FDE_TTOALIGNMENT_BottomAuto 11 - -class IFDE_TextOut { - 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(FX_DWORD 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; -}; - -#endif // XFA_SRC_FDE_TTO_FDE_TEXTOUT_H_ diff --git a/xfa/src/fde/xml/fde_xml.h b/xfa/src/fde/xml/fde_xml.h deleted file mode 100644 index 03e2a60806..0000000000 --- a/xfa/src/fde/xml/fde_xml.h +++ /dev/null @@ -1,226 +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_SRC_FDE_XML_FDE_XML_H_ -#define XFA_SRC_FDE_XML_FDE_XML_H_ - -#include "xfa/src/fgas/crt/fgas_stream.h" -#include "xfa/src/fgas/crt/fgas_utils.h" - -class IFDE_XMLNode; -class IFDE_XMLInstruction; -class IFDE_XMLDeclaration; -class IFDE_XMLElement; -class IFDE_XMLText; -class IFDE_XMLDoc; -class IFDE_XMLParser; -class IFDE_XMLSyntaxParser; - -enum FDE_XMLNODETYPE { - FDE_XMLNODE_Unknown = 0, - FDE_XMLNODE_Instruction, - FDE_XMLNODE_Element, - FDE_XMLNODE_Text, - FDE_XMLNODE_CharData, -}; - -struct FDE_XMLNODE { - int32_t iNodeNum; - FDE_XMLNODETYPE eNodeType; -}; -typedef CFX_StackTemplate<FDE_XMLNODE> CFDE_XMLNodeStack; - -FX_BOOL FDE_IsXMLValidChar(FX_WCHAR ch); -FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch); -FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar); - -class IFDE_XMLNode { - public: - virtual ~IFDE_XMLNode() {} - virtual void Release() = 0; - virtual FDE_XMLNODETYPE GetType() const = 0; - virtual int32_t CountChildNodes() const = 0; - virtual IFDE_XMLNode* GetChildNode(int32_t index) const = 0; - virtual int32_t GetChildNodeIndex(IFDE_XMLNode* pNode) const = 0; - virtual IFDE_XMLNode* GetPath(const FX_WCHAR* pPath, - int32_t iLength = -1, - FX_BOOL bQualifiedName = TRUE) const = 0; - virtual int32_t InsertChildNode(IFDE_XMLNode* pNode, int32_t index = -1) = 0; - virtual void RemoveChildNode(IFDE_XMLNode* pNode) = 0; - virtual void DeleteChildren() = 0; - enum NodeItem { - Root = 0, - Parent, - FirstSibling, - PriorSibling, - NextSibling, - LastSibling, - FirstNeighbor, - PriorNeighbor, - NextNeighbor, - LastNeighbor, - FirstChild, - LastChild - }; - virtual IFDE_XMLNode* GetNodeItem(NodeItem eItem) const = 0; - virtual int32_t GetNodeLevel() const = 0; - virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem, - IFDE_XMLNode* pNode) = 0; - virtual IFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) = 0; - virtual IFDE_XMLNode* Clone(FX_BOOL bRecursive) = 0; - virtual void SaveXMLNode(IFX_Stream* pXMLStream) = 0; -}; -class IFDE_XMLInstruction : public IFDE_XMLNode { - public: - static IFDE_XMLInstruction* Create(const CFX_WideString& wsTarget); - virtual void GetTargetName(CFX_WideString& wsTarget) const = 0; - virtual int32_t CountAttributes() const = 0; - virtual FX_BOOL GetAttribute(int32_t index, - CFX_WideString& wsAttriName, - CFX_WideString& wsAttriValue) const = 0; - virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0; - virtual void GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = NULL) const = 0; - virtual void SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue) = 0; - virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue = 0) const = 0; - virtual void SetInteger(const FX_WCHAR* pwsAttriName, - int32_t iAttriValue) = 0; - virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue = 0) const = 0; - virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0; - virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0; - virtual int32_t CountData() const = 0; - virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const = 0; - virtual void AppendData(const CFX_WideString& wsData) = 0; - virtual void RemoveData(int32_t index) = 0; -}; -class IFDE_XMLElement : public IFDE_XMLNode { - public: - static IFDE_XMLElement* Create(const CFX_WideString& wsTag); - virtual void GetTagName(CFX_WideString& wsTag) const = 0; - virtual void GetLocalTagName(CFX_WideString& wsTag) const = 0; - virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const = 0; - virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const = 0; - virtual int32_t CountAttributes() const = 0; - virtual FX_BOOL GetAttribute(int32_t index, - CFX_WideString& wsAttriName, - CFX_WideString& wsAttriValue) const = 0; - virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0; - virtual void GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = NULL) const = 0; - virtual void SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue) = 0; - virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue = 0) const = 0; - virtual void SetInteger(const FX_WCHAR* pwsAttriName, - int32_t iAttriValue) = 0; - virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue = 0) const = 0; - virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0; - virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0; - virtual void GetTextData(CFX_WideString& wsText) const = 0; - virtual void SetTextData(const CFX_WideString& wsText) = 0; -}; -class IFDE_XMLText : public IFDE_XMLNode { - public: - static IFDE_XMLText* Create(const CFX_WideString& wsText); - virtual void GetText(CFX_WideString& wsText) const = 0; - virtual void SetText(const CFX_WideString& wsText) = 0; -}; -class IFDE_XMLDeclaration : public IFDE_XMLNode { - public: -}; -class IFDE_XMLCharData : public IFDE_XMLDeclaration { - public: - static IFDE_XMLCharData* Create(const CFX_WideString& wsCData); - virtual ~IFDE_XMLCharData() {} - - virtual void GetCharData(CFX_WideString& wsCData) const = 0; - virtual void SetCharData(const CFX_WideString& wsCData) = 0; -}; - -struct FDE_XMLREADERHANDLER { - void* pData; - void (*OnTagEnter)(FDE_XMLREADERHANDLER* pThis, - FDE_XMLNODETYPE eType, - const CFX_WideString& wsTagName); - void (*OnTagBreak)(FDE_XMLREADERHANDLER* pThis, - const CFX_WideString& wsTagName); - void (*OnTagClose)(FDE_XMLREADERHANDLER* pThis, - const CFX_WideString& wsTagName); - void (*OnAttribute)(FDE_XMLREADERHANDLER* pThis, - const CFX_WideString& wsName, - const CFX_WideString& wsValue); - void (*OnData)(FDE_XMLREADERHANDLER* pThis, - FDE_XMLNODETYPE eType, - const CFX_WideString& wsValue); -}; - -class IFDE_XMLDoc { - public: - static IFDE_XMLDoc* Create(); - virtual ~IFDE_XMLDoc() {} - virtual void Release() = 0; - virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, - int32_t iXMLPlaneSize = 8192, - int32_t iTextDataSize = 256, - FDE_XMLREADERHANDLER* pHandler = NULL) = 0; - virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser) = 0; - virtual int32_t DoLoad(IFX_Pause* pPause = NULL) = 0; - virtual void CloseXML() = 0; - virtual IFDE_XMLNode* GetRoot() const = 0; - virtual void SaveXML(IFX_Stream* pXMLStream = NULL, - FX_BOOL bSaveBOM = TRUE) = 0; - virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode) = 0; -}; -class IFDE_XMLParser { - public: - virtual ~IFDE_XMLParser() {} - virtual void Release() = 0; - virtual int32_t DoParser(IFX_Pause* pPause) = 0; -}; -#define FDE_XMLSYNTAXSTATUS_None 0x00 -#define FDE_XMLSYNTAXSTATUS_InstructionOpen 0x01 -#define FDE_XMLSYNTAXSTATUS_InstructionClose 0x02 -#define FDE_XMLSYNTAXSTATUS_ElementOpen 0x03 -#define FDE_XMLSYNTAXSTATUS_ElementBreak 0x04 -#define FDE_XMLSYNTAXSTATUS_ElementClose 0x05 -#define FDE_XMLSYNTAXSTATUS_TargetName 0x06 -#define FDE_XMLSYNTAXSTATUS_TagName 0x07 -#define FDE_XMLSYNTAXSTATUS_AttriName 0x08 -#define FDE_XMLSYNTAXSTATUS_AttriValue 0x09 -#define FDE_XMLSYNTAXSTATUS_Text 0x0A -#define FDE_XMLSYNTAXSTATUS_CData 0x0B -#define FDE_XMLSYNTAXSTATUS_TargetData 0x0C -#define FDE_XMLSYNTAXSTATUS_Error 0xFE -#define FDE_XMLSYNTAXSTATUS_EOS 0xFF -class IFDE_XMLSyntaxParser { - public: - static IFDE_XMLSyntaxParser* Create(); - virtual ~IFDE_XMLSyntaxParser() {} - virtual void Release() = 0; - virtual void Init(IFX_Stream* pStream, - int32_t iXMLPlaneSize, - int32_t iTextDataSize = 256) = 0; - virtual FX_DWORD DoSyntaxParse() = 0; - virtual int32_t GetStatus() const = 0; - virtual int32_t GetCurrentPos() const = 0; - virtual FX_FILESIZE GetCurrentBinaryPos() const = 0; - virtual int32_t GetCurrentNodeNumber() const = 0; - virtual int32_t GetLastNodeNumber() const = 0; - virtual void GetTargetName(CFX_WideString& wsTarget) const = 0; - virtual void GetTagName(CFX_WideString& wsTag) const = 0; - virtual void GetAttributeName(CFX_WideString& wsAttriName) const = 0; - virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const = 0; - virtual void GetTextData(CFX_WideString& wsText) const = 0; - virtual void GetTargetData(CFX_WideString& wsData) const = 0; -}; - -#endif // XFA_SRC_FDE_XML_FDE_XML_H_ diff --git a/xfa/src/fde/xml/fde_xml_imp.cpp b/xfa/src/fde/xml/fde_xml_imp.cpp deleted file mode 100644 index 94e5de6b93..0000000000 --- a/xfa/src/fde/xml/fde_xml_imp.cpp +++ /dev/null @@ -1,2100 +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/src/fde/xml/fde_xml_imp.h" - -#include <algorithm> - -#include "xfa/src/fgas/crt/fgas_system.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" - -#define FDE_XMLVALIDCHARRANGENUM 5 - -static const FX_WCHAR g_XMLValidCharRange[FDE_XMLVALIDCHARRANGENUM][2] = { - {0x09, 0x09}, - {0x0A, 0x0A}, - {0x0D, 0x0D}, - {0x20, 0xD7FF}, - {0xE000, 0xFFFD}}; - -FX_BOOL FDE_IsXMLValidChar(FX_WCHAR ch) { - int32_t iStart = 0, iEnd = FDE_XMLVALIDCHARRANGENUM - 1, iMid; - while (iStart <= iEnd) { - iMid = (iStart + iEnd) / 2; - if (ch < g_XMLValidCharRange[iMid][0]) { - iEnd = iMid - 1; - } else if (ch > g_XMLValidCharRange[iMid][1]) { - iStart = iMid + 1; - } else { - return TRUE; - } - } - return FALSE; -} -FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch) { - return ch == L' ' || ch == 0x0A || ch == 0x0D || ch == 0x09; -} - -struct FDE_XMLNAMECHAR { - FX_WCHAR wStart; - FX_WCHAR wEnd; - FX_BOOL bStartChar; -}; - -#define FDE_XMLNAMECHARSNUM 20 -static FDE_XMLNAMECHAR g_XMLNameChars[FDE_XMLNAMECHARSNUM] = { - {L'-', L'.', FALSE}, {L'0', L'9', FALSE}, {L':', L':', FALSE}, - {L'A', L'Z', TRUE}, {L'_', L'_', TRUE}, {L'a', L'z', TRUE}, - {0xB7, 0xB7, FALSE}, {0xC0, 0xD6, TRUE}, {0xD8, 0xF6, TRUE}, - {0xF8, 0x02FF, TRUE}, {0x0300, 0x036F, FALSE}, {0x0370, 0x037D, TRUE}, - {0x037F, 0x1FFF, TRUE}, {0x200C, 0x200D, TRUE}, {0x203F, 0x2040, FALSE}, - {0x2070, 0x218F, TRUE}, {0x2C00, 0x2FEF, TRUE}, {0x3001, 0xD7FF, TRUE}, - {0xF900, 0xFDCF, TRUE}, {0xFDF0, 0xFFFD, TRUE}, -}; - -FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar) { - int32_t iStart = 0, iEnd = FDE_XMLNAMECHARSNUM - 1, iMid; - while (iStart <= iEnd) { - iMid = (iStart + iEnd) / 2; - if (ch < g_XMLNameChars[iMid].wStart) { - iEnd = iMid - 1; - } else if (ch > g_XMLNameChars[iMid].wEnd) { - iStart = iMid + 1; - } else { - if (bFirstChar) { - return g_XMLNameChars[iMid].bStartChar; - } - return TRUE; - } - } - return FALSE; -} - -CFDE_XMLNode::CFDE_XMLNode() - : m_pParent(NULL), m_pChild(NULL), m_pPrior(NULL), m_pNext(NULL) {} -CFDE_XMLNode::~CFDE_XMLNode() { - DeleteChildren(); -} -void CFDE_XMLNode::DeleteChildren() { - CFDE_XMLNode *pChild = m_pChild, *pTemp; - while (pChild != NULL) { - pTemp = pChild->m_pNext; - pChild->Release(); - pChild = pTemp; - } - m_pChild = NULL; -} -int32_t CFDE_XMLNode::CountChildNodes() const { - int32_t iCount = 0; - CFDE_XMLNode* pChild = m_pChild; - while (pChild != NULL) { - iCount++; - pChild = pChild->m_pNext; - } - return iCount; -} -CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { - CFDE_XMLNode* pChild = m_pChild; - while (pChild != NULL) { - if (index == 0) { - return pChild; - } - index--; - pChild = pChild->m_pNext; - } - return NULL; -} -int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { - int32_t index = 0; - CFDE_XMLNode* pChild = m_pChild; - while (pChild != NULL) { - if (pChild == pNode) { - return index; - } - index++; - pChild = pChild->m_pNext; - } - return -1; -} -CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, - int32_t iLength, - FX_BOOL bQualifiedName) const { - FXSYS_assert(pPath != NULL); - if (iLength < 0) { - iLength = FXSYS_wcslen(pPath); - } - if (iLength == 0) { - return NULL; - } - CFX_WideString csPath; - const FX_WCHAR* pStart = pPath; - const FX_WCHAR* pEnd = pPath + iLength; - FX_WCHAR ch; - while (pStart < pEnd) { - ch = *pStart++; - if (ch == L'/') { - break; - } else { - csPath += ch; - } - } - iLength -= pStart - pPath; - CFDE_XMLNode* pFind = NULL; - if (csPath.GetLength() < 1) { - pFind = GetNodeItem(IFDE_XMLNode::Root); - } else if (csPath.Compare(L"..") == 0) { - pFind = m_pParent; - } else if (csPath.Compare(L".") == 0) { - pFind = (CFDE_XMLNode*)this; - } else { - CFX_WideString wsTag; - CFDE_XMLNode* pNode = m_pChild; - while (pNode != NULL) { - if (pNode->GetType() == FDE_XMLNODE_Element) { - if (bQualifiedName) { - ((CFDE_XMLElement*)pNode)->GetTagName(wsTag); - } else { - ((CFDE_XMLElement*)pNode)->GetLocalTagName(wsTag); - } - if (wsTag.Compare(csPath) == 0) { - if (iLength < 1) { - pFind = pNode; - } else { - pFind = pNode->GetPath(pStart, iLength, bQualifiedName); - } - if (pFind != NULL) { - return pFind; - } - } - } - pNode = pNode->m_pNext; - } - } - if (pFind == NULL || iLength < 1) { - return pFind; - } - return pFind->GetPath(pStart, iLength, bQualifiedName); -} -int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { - FXSYS_assert(pNode != NULL); - pNode->m_pParent = this; - if (m_pChild == NULL) { - m_pChild = pNode; - pNode->m_pPrior = NULL; - pNode->m_pNext = NULL; - return 0; - } else if (index == 0) { - pNode->m_pNext = m_pChild; - pNode->m_pPrior = NULL; - m_pChild->m_pPrior = pNode; - m_pChild = pNode; - return 0; - } - int32_t iCount = 0; - CFDE_XMLNode* pFind = m_pChild; - while (++iCount != index && pFind->m_pNext != NULL) { - pFind = pFind->m_pNext; - } - pNode->m_pPrior = pFind; - pNode->m_pNext = pFind->m_pNext; - if (pFind->m_pNext != NULL) { - pFind->m_pNext->m_pPrior = pNode; - } - pFind->m_pNext = pNode; - return iCount; -} -void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) { - FXSYS_assert(m_pChild != NULL && pNode != NULL); - if (m_pChild == pNode) { - m_pChild = pNode->m_pNext; - } else { - pNode->m_pPrior->m_pNext = pNode->m_pNext; - } - if (pNode->m_pNext != NULL) { - pNode->m_pNext->m_pPrior = pNode->m_pPrior; - } - pNode->m_pParent = NULL; - pNode->m_pNext = NULL; - pNode->m_pPrior = NULL; -} -CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const { - switch (eItem) { - case IFDE_XMLNode::Root: { - CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; - while (pParent->m_pParent != NULL) { - pParent = pParent->m_pParent; - } - return pParent; - } - case IFDE_XMLNode::Parent: - return m_pParent; - case IFDE_XMLNode::FirstSibling: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pPrior != NULL) { - pItem = pItem->m_pPrior; - } - return pItem == (CFDE_XMLNode*)this ? NULL : pItem; - } - case IFDE_XMLNode::PriorSibling: - return m_pPrior; - case IFDE_XMLNode::NextSibling: - return m_pNext; - case IFDE_XMLNode::LastSibling: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pNext != NULL) { - pItem = pItem->m_pNext; - } - return pItem == (CFDE_XMLNode*)this ? NULL : pItem; - } - case IFDE_XMLNode::FirstNeighbor: { - CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; - while (pParent->m_pParent != NULL) { - pParent = pParent->m_pParent; - } - return pParent == (CFDE_XMLNode*)this ? NULL : pParent; - } - case IFDE_XMLNode::PriorNeighbor: { - if (m_pPrior == NULL) { - return m_pParent; - } - CFDE_XMLNode* pItem = m_pPrior; - while (CFDE_XMLNode* pTemp = pItem->m_pChild) { - pItem = pTemp; - while ((pTemp = pItem->m_pNext) != NULL) { - pItem = pTemp; - } - } - return pItem; - } - case IFDE_XMLNode::NextNeighbor: { - if (m_pChild != NULL) { - return m_pChild; - } - if (m_pNext != NULL) { - return m_pNext; - } - CFDE_XMLNode* pItem = m_pParent; - while (pItem != NULL) { - if (pItem->m_pNext != NULL) { - return pItem->m_pNext; - } - pItem = pItem->m_pParent; - } - return NULL; - } - case IFDE_XMLNode::LastNeighbor: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pParent != NULL) { - pItem = pItem->m_pParent; - } - while (TRUE) { - while (pItem->m_pNext != NULL) { - pItem = pItem->m_pNext; - } - if (pItem->m_pChild == NULL) { - break; - } - pItem = pItem->m_pChild; - } - return pItem == (CFDE_XMLNode*)this ? NULL : pItem; - } - case IFDE_XMLNode::FirstChild: - return m_pChild; - case IFDE_XMLNode::LastChild: { - if (m_pChild == NULL) { - return NULL; - } - CFDE_XMLNode* pChild = m_pChild; - while (pChild->m_pNext != NULL) { - pChild = pChild->m_pNext; - } - return pChild; - } - default: - break; - } - return NULL; -} -int32_t CFDE_XMLNode::GetNodeLevel() const { - int32_t iLevel = 0; - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while ((pItem = pItem->m_pParent) != NULL) { - iLevel++; - } - return iLevel; -} -FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem, - CFDE_XMLNode* pNode) { - FXSYS_assert(pNode != NULL); - switch (eItem) { - case IFDE_XMLNode::NextSibling: { - pNode->m_pParent = m_pParent; - pNode->m_pNext = m_pNext; - pNode->m_pPrior = this; - if (m_pNext) { - m_pNext->m_pPrior = pNode; - } - m_pNext = pNode; - return TRUE; - } - case IFDE_XMLNode::PriorSibling: { - pNode->m_pParent = m_pParent; - pNode->m_pNext = this; - pNode->m_pPrior = m_pPrior; - if (m_pPrior) { - m_pPrior->m_pNext = pNode; - } else if (m_pParent) { - m_pParent->m_pChild = pNode; - } - m_pPrior = pNode; - return TRUE; - } - default: - return FALSE; - } - return FALSE; -} -CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) { - CFDE_XMLNode* pNode = NULL; - switch (eItem) { - case IFDE_XMLNode::NextSibling: - if (m_pNext) { - pNode = m_pNext; - m_pNext = pNode->m_pNext; - if (m_pNext) { - m_pNext->m_pPrior = this; - } - pNode->m_pParent = NULL; - pNode->m_pNext = NULL; - pNode->m_pPrior = NULL; - } - break; - default: - break; - } - return pNode; -} -CFDE_XMLNode* CFDE_XMLNode::Clone(FX_BOOL bRecursive) { - return NULL; -} -void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { - CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; - FXSYS_assert(pXMLStream != NULL && pNode != NULL); - switch (pNode->GetType()) { - case FDE_XMLNODE_Instruction: { - CFX_WideString ws; - CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; - if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { - ws = L"<?xml version=\"1.0\" encoding=\""; - FX_WORD wCodePage = pXMLStream->GetCodePage(); - if (wCodePage == FX_CODEPAGE_UTF16LE) { - ws += L"UTF-16"; - } else if (wCodePage == FX_CODEPAGE_UTF16BE) { - ws += L"UTF-16be"; - } else { - ws += L"UTF-8"; - } - ws += L"\"?>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } else { - ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); - pXMLStream->WriteString(ws, ws.GetLength()); - CFX_WideStringArray& attributes = pInstruction->m_Attributes; - int32_t i, iCount = attributes.GetSize(); - CFX_WideString wsValue; - for (i = 0; i < iCount; i += 2) { - ws = L" "; - ws += attributes[i]; - ws += L"=\""; - wsValue = attributes[i + 1]; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - CFX_WideStringArray& targetdata = pInstruction->m_TargetData; - iCount = targetdata.GetSize(); - for (i = 0; i < iCount; i++) { - ws = L" \""; - ws += targetdata[i]; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - ws = L"?>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } - } break; - case FDE_XMLNODE_Element: { - CFX_WideString ws; - ws = L"<"; - ws += ((CFDE_XMLElement*)pNode)->m_wsTag; - pXMLStream->WriteString(ws, ws.GetLength()); - CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; - int32_t iCount = attributes.GetSize(); - CFX_WideString wsValue; - for (int32_t i = 0; i < iCount; i += 2) { - ws = L" "; - ws += attributes[i]; - ws += L"=\""; - wsValue = attributes[i + 1]; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - if (pNode->m_pChild == NULL) { - ws = L"\n/>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } else { - ws = L"\n>"; - pXMLStream->WriteString(ws, ws.GetLength()); - CFDE_XMLNode* pChild = pNode->m_pChild; - while (pChild != NULL) { - pChild->SaveXMLNode(pXMLStream); - pChild = pChild->m_pNext; - } - ws = L"</"; - ws += ((CFDE_XMLElement*)pNode)->m_wsTag; - ws += L"\n>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } - } break; - case FDE_XMLNODE_Text: { - CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; - ws.Replace(L"&", L"&"); - ws.Replace(L"<", L"<"); - ws.Replace(L">", L">"); - ws.Replace(L"\'", L"'"); - ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws, 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()); - } break; - case FDE_XMLNODE_Unknown: - break; - default: - break; - } -} -void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { - if (!m_pChild) { - return; - } - CFDE_XMLNode* pNext = m_pChild; - CFDE_XMLNode* pCloneNext = pNext->Clone(TRUE); - pClone->InsertChildNode(pCloneNext); - pNext = pNext->m_pNext; - while (pNext) { - CFDE_XMLNode* pChild = pNext->Clone(TRUE); - pCloneNext->InsertNodeItem(IFDE_XMLNode::NextSibling, pChild); - pCloneNext = pChild; - pNext = pNext->m_pNext; - } -} -IFDE_XMLInstruction* IFDE_XMLInstruction::Create( - const CFX_WideString& wsTarget) { - return (IFDE_XMLInstruction*)new CFDE_XMLInstruction(wsTarget); -} -CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) - : m_wsTarget(wsTarget) { - FXSYS_assert(m_wsTarget.GetLength() > 0); -} -CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { - CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); - if (!pClone) { - return pClone; - } - pClone->m_Attributes.Copy(m_Attributes); - pClone->m_TargetData.Copy(m_TargetData); - if (bRecursive) { - CloneChildren(pClone); - } - return pClone; -} -int32_t CFDE_XMLInstruction::CountAttributes() const { - return m_Attributes.GetSize() / 2; -} -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); - for (int32_t i = 0; i < iCount; i += 2) { - if (index == 0) { - wsAttriName = m_Attributes[i]; - wsAttriValue = m_Attributes[i + 1]; - return TRUE; - } - index--; - } - return FALSE; -} -FX_BOOL CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { - int32_t iCount = m_Attributes.GetSize(); - for (int32_t i = 0; i < iCount; i += 2) { - if (m_Attributes[i].Compare(pwsAttriName) == 0) { - return TRUE; - } - } - return FALSE; -} -void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue) const { - int32_t iCount = m_Attributes.GetSize(); - for (int32_t i = 0; i < iCount; i += 2) { - if (m_Attributes[i].Compare(pwsAttriName) == 0) { - wsAttriValue = m_Attributes[i + 1]; - return; - } - } - wsAttriValue = pwsDefValue; -} -void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue) { - FXSYS_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) { - m_Attributes[i] = wsAttriName; - m_Attributes[i + 1] = wsAttriValue; - return; - } - } - m_Attributes.Add(wsAttriName); - m_Attributes.Add(wsAttriValue); -} -int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue) const { - 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 iDefValue; -} -void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, - int32_t iAttriValue) { - CFX_WideString wsValue; - wsValue.Format(L"%d", iAttriValue); - SetString(pwsAttriName, wsValue); -} -FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue) const { - 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 fDefValue; -} -void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fAttriValue) { - CFX_WideString wsValue; - wsValue.Format(L"%f", fAttriValue); - SetString(pwsAttriName, wsValue); -} -void CFDE_XMLInstruction::RemoveAttribute(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) { - m_Attributes.RemoveAt(i + 1); - m_Attributes.RemoveAt(i); - return; - } - } -} -int32_t CFDE_XMLInstruction::CountData() const { - return m_TargetData.GetSize(); -} -FX_BOOL CFDE_XMLInstruction::GetData(int32_t index, - CFX_WideString& wsData) const { - if (index < 0 || index >= m_TargetData.GetSize()) { - return FALSE; - } - wsData = m_TargetData[index]; - return TRUE; -} -void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { - m_TargetData.Add(wsData); -} -void CFDE_XMLInstruction::RemoveData(int32_t index) { - m_TargetData.RemoveAt(index); -} -IFDE_XMLElement* IFDE_XMLElement::Create(const CFX_WideString& wsTag) { - return (IFDE_XMLElement*)new CFDE_XMLElement(wsTag); -} -CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) - : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() { - FXSYS_assert(m_wsTag.GetLength() > 0); -} -CFDE_XMLElement::~CFDE_XMLElement() { - m_Attributes.RemoveAll(); -} -CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { - CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag); - if (!pClone) { - return NULL; - } - pClone->m_Attributes.Copy(m_Attributes); - if (bRecursive) { - CloneChildren(pClone); - } else { - CFX_WideString wsText; - CFDE_XMLNode* pChild = m_pChild; - while (pChild != NULL) { - switch (pChild->GetType()) { - case FDE_XMLNODE_Text: - wsText += ((CFDE_XMLText*)pChild)->m_wsText; - break; - default: - break; - } - pChild = pChild->m_pNext; - } - pClone->SetTextData(wsText); - } - return pClone; -} -void CFDE_XMLElement::GetTagName(CFX_WideString& wsTag) const { - wsTag = m_wsTag; -} -void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { - FX_STRSIZE iFind = m_wsTag.Find(L':', 0); - if (iFind < 0) { - wsTag = m_wsTag; - } else { - wsTag = m_wsTag.Right(m_wsTag.GetLength() - iFind - 1); - } -} -void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { - FX_STRSIZE iFind = m_wsTag.Find(L':', 0); - if (iFind < 0) { - wsPrefix.Empty(); - } else { - wsPrefix = m_wsTag.Left(iFind); - } -} -void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { - CFX_WideString wsAttri(L"xmlns"), wsPrefix; - GetNamespacePrefix(wsPrefix); - if (wsPrefix.GetLength() > 0) { - wsAttri += L":"; - wsAttri += wsPrefix; - } - wsNamespace.Empty(); - 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)) { - pNode = pNode->GetNodeItem(IFDE_XMLNode::Parent); - continue; - } - pElement->GetString(wsAttri, wsNamespace); - break; - } -} -int32_t CFDE_XMLElement::CountAttributes() const { - return m_Attributes.GetSize() / 2; -} -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); - for (int32_t i = 0; i < iCount; i += 2) { - if (index == 0) { - wsAttriName = m_Attributes[i]; - wsAttriValue = m_Attributes[i + 1]; - return TRUE; - } - index--; - } - return FALSE; -} -FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { - int32_t iCount = m_Attributes.GetSize(); - for (int32_t i = 0; i < iCount; i += 2) { - if (m_Attributes[i].Compare(pwsAttriName) == 0) { - return TRUE; - } - } - return FALSE; -} -void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue) const { - int32_t iCount = m_Attributes.GetSize(); - for (int32_t i = 0; i < iCount; i += 2) { - if (m_Attributes[i].Compare(pwsAttriName) == 0) { - wsAttriValue = m_Attributes[i + 1]; - return; - } - } - wsAttriValue = pwsDefValue; -} -void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue) { - FXSYS_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) { - m_Attributes[i] = wsAttriName; - m_Attributes[i + 1] = wsAttriValue; - return; - } - } - m_Attributes.Add(wsAttriName); - m_Attributes.Add(wsAttriValue); -} -int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue) const { - 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 iDefValue; -} -void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, - int32_t iAttriValue) { - CFX_WideString wsValue; - wsValue.Format(L"%d", iAttriValue); - SetString(pwsAttriName, wsValue); -} -FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue) const { - 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 fDefValue; -} -void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fAttriValue) { - CFX_WideString wsValue; - wsValue.Format(L"%f", fAttriValue); - SetString(pwsAttriName, wsValue); -} -void CFDE_XMLElement::RemoveAttribute(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) { - m_Attributes.RemoveAt(i + 1); - m_Attributes.RemoveAt(i); - return; - } - } -} -void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { - CFX_WideTextBuf buffer; - CFDE_XMLNode* pChild = m_pChild; - while (pChild != NULL) { - switch (pChild->GetType()) { - case FDE_XMLNODE_Text: - buffer << ((CFDE_XMLText*)pChild)->m_wsText; - break; - case FDE_XMLNODE_CharData: - buffer << ((CFDE_XMLCharData*)pChild)->m_wsCharData; - break; - default: - break; - } - pChild = pChild->m_pNext; - } - wsText = buffer.GetWideString(); -} -void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { - if (wsText.GetLength() < 1) { - return; - } - InsertChildNode(new CFDE_XMLText(wsText)); -} -IFDE_XMLText* IFDE_XMLText::Create(const CFX_WideString& wsText) { - return (IFDE_XMLText*)new CFDE_XMLText(wsText); -} -CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) - : CFDE_XMLNode(), m_wsText(wsText) {} -CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { - CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); - return pClone; -} -IFDE_XMLCharData* IFDE_XMLCharData::Create(const CFX_WideString& wsCData) { - return (IFDE_XMLCharData*)new CFDE_XMLCharData(wsCData); -} -CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) - : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} -CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { - CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); - return pClone; -} -IFDE_XMLDoc* IFDE_XMLDoc::Create() { - return (IFDE_XMLDoc*)new CFDE_XMLDoc; -} -CFDE_XMLDoc::CFDE_XMLDoc() - : m_pRoot(NULL), m_pSyntaxParser(NULL), m_pXMLParser(NULL) { - Reset(TRUE); - CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml"); - m_pRoot->InsertChildNode(pXML); -} -CFDE_XMLDoc::~CFDE_XMLDoc() { - Reset(FALSE); -} -void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { - m_iStatus = 0; - m_pStream = NULL; - if (bInitRoot) { - if (m_pRoot == NULL) { - m_pRoot = new CFDE_XMLNode; - } else { - m_pRoot->DeleteChildren(); - } - } else { - if (m_pRoot != NULL) { - m_pRoot->Release(); - m_pRoot = NULL; - } - } - ReleaseParser(); -} -void CFDE_XMLDoc::ReleaseParser() { - if (m_pXMLParser != NULL) { - m_pXMLParser->Release(); - m_pXMLParser = NULL; - } - if (m_pSyntaxParser != NULL) { - m_pSyntaxParser->Release(); - m_pSyntaxParser = NULL; - } -} -FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, - int32_t iXMLPlaneSize, - int32_t iTextDataSize, - FDE_XMLREADERHANDLER* pHandler) { - if (pXMLStream == NULL) { - return FALSE; - } - Reset(TRUE); - iXMLPlaneSize = iXMLPlaneSize / 1024; - if (iXMLPlaneSize < 1) { - iXMLPlaneSize = 1; - } - iXMLPlaneSize *= 1024; - if (iXMLPlaneSize < 4096) { - iXMLPlaneSize = 4096; - } - iTextDataSize = iTextDataSize / 128; - if (iTextDataSize < 1) { - iTextDataSize = 1; - } - iTextDataSize *= 128; - if (iTextDataSize < 128) { - iTextDataSize = 128; - } - m_pStream = pXMLStream; - FX_WORD wCodePage = m_pStream->GetCodePage(); - if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && - wCodePage != FX_CODEPAGE_UTF8) { - m_pStream->SetCodePage(FX_CODEPAGE_UTF8); - } - m_pSyntaxParser = IFDE_XMLSyntaxParser::Create(); - if (m_pSyntaxParser == NULL) { - return FALSE; - } - m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize); - if (pHandler == NULL) { - m_pXMLParser = new CFDE_XMLDOMParser(m_pRoot, m_pSyntaxParser); - } else { - m_pXMLParser = new CFDE_XMLSAXParser(pHandler, m_pSyntaxParser); - } - return TRUE; -} -FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) { - if (pXMLParser == NULL) { - return FALSE; - } - Reset(TRUE); - m_pXMLParser = pXMLParser; - return m_pXMLParser != NULL; -} -int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { - if (m_iStatus >= 100) { - return m_iStatus; - } - FXSYS_assert(m_pXMLParser != NULL); - return m_iStatus = m_pXMLParser->DoParser(pPause); -} -void CFDE_XMLDoc::CloseXML() { - ReleaseParser(); -} -void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) { - CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; - FXSYS_assert(pXMLStream != NULL && pNode != NULL); - switch (pNode->GetType()) { - case FDE_XMLNODE_Instruction: { - CFX_WideString ws; - CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; - if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { - ws = L"<?xml version=\"1.0\" encoding=\""; - FX_WORD wCodePage = pXMLStream->GetCodePage(); - if (wCodePage == FX_CODEPAGE_UTF16LE) { - ws += L"UTF-16"; - } else if (wCodePage == FX_CODEPAGE_UTF16BE) { - ws += L"UTF-16be"; - } else { - ws += L"UTF-8"; - } - ws += L"\"?>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } else { - ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget); - pXMLStream->WriteString(ws, ws.GetLength()); - CFX_WideStringArray& attributes = pInstruction->m_Attributes; - int32_t i, iCount = attributes.GetSize(); - CFX_WideString wsValue; - for (i = 0; i < iCount; i += 2) { - ws = L" "; - ws += attributes[i]; - ws += L"=\""; - wsValue = attributes[i + 1]; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - CFX_WideStringArray& targetdata = pInstruction->m_TargetData; - iCount = targetdata.GetSize(); - for (i = 0; i < iCount; i++) { - ws = L" \""; - ws += targetdata[i]; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - ws = L"?>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } - } break; - case FDE_XMLNODE_Element: { - CFX_WideString ws; - ws = L"<"; - ws += ((CFDE_XMLElement*)pNode)->m_wsTag; - pXMLStream->WriteString(ws, ws.GetLength()); - CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes; - int32_t iCount = attributes.GetSize(); - CFX_WideString wsValue; - for (int32_t i = 0; i < iCount; i += 2) { - ws = L" "; - ws += attributes[i]; - ws += L"=\""; - wsValue = attributes[i + 1]; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws, ws.GetLength()); - } - if (pNode->m_pChild == NULL) { - ws = L"\n/>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } else { - ws = L"\n>"; - pXMLStream->WriteString(ws, ws.GetLength()); - CFDE_XMLNode* pChild = pNode->m_pChild; - while (pChild != NULL) { - SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pChild); - pChild = pChild->m_pNext; - } - ws = L"</"; - ws += ((CFDE_XMLElement*)pNode)->m_wsTag; - ws += L"\n>"; - pXMLStream->WriteString(ws, ws.GetLength()); - } - } break; - case FDE_XMLNODE_Text: { - CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; - ws.Replace(L"&", L"&"); - ws.Replace(L"<", L"<"); - ws.Replace(L">", L">"); - ws.Replace(L"\'", L"'"); - ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws, 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()); - } break; - case FDE_XMLNODE_Unknown: - break; - default: - break; - } -} -void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { - if (pXMLStream == NULL || pXMLStream == m_pStream) { - 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); - FX_WORD wCodePage = pXMLStream->GetCodePage(); - if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && - wCodePage != FX_CODEPAGE_UTF8) { - wCodePage = FX_CODEPAGE_UTF8; - pXMLStream->SetCodePage(wCodePage); - } - if (bSaveBOM) { - pXMLStream->WriteString(L"\xFEFF", 1); - } - CFDE_XMLNode* pNode = m_pRoot->m_pChild; - while (pNode != NULL) { - SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pNode); - pNode = pNode->m_pNext; - } - if (pXMLStream == m_pStream) { - int32_t iPos = pXMLStream->GetPosition(); - pXMLStream->SetLength(iPos); - } -} -CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, - IFDE_XMLSyntaxParser* pParser) - : m_pParser(pParser), - m_pParent(pRoot), - m_pChild(NULL), - m_NodeStack(16), - m_ws1(), - m_ws2() { - m_NodeStack.Push(m_pParent); -} -CFDE_XMLDOMParser::~CFDE_XMLDOMParser() { - m_NodeStack.RemoveAll(); - m_ws1.Empty(); - m_ws2.Empty(); -} -int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) { - FX_DWORD dwRet; - int32_t iCount = 0; - while (TRUE) { - dwRet = m_pParser->DoSyntaxParse(); - switch (dwRet) { - case FDE_XMLSYNTAXSTATUS_InstructionOpen: - break; - case FDE_XMLSYNTAXSTATUS_InstructionClose: - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_ElementOpen: - case FDE_XMLSYNTAXSTATUS_ElementBreak: - break; - case FDE_XMLSYNTAXSTATUS_ElementClose: - if (m_pChild->GetType() != FDE_XMLNODE_Element) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pParser->GetTagName(m_ws1); - ((CFDE_XMLElement*)m_pChild)->GetTagName(m_ws2); - if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_ws2) != 0) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_NodeStack.Pop(); - if (m_NodeStack.GetSize() < 1) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pParent = (CFDE_XMLNode*)*m_NodeStack.GetTopElement(); - m_pChild = m_pParent; - iCount++; - break; - case FDE_XMLSYNTAXSTATUS_TargetName: - m_pParser->GetTargetName(m_ws1); - m_pChild = new CFDE_XMLInstruction(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_ws1.Empty(); - break; - case FDE_XMLSYNTAXSTATUS_TagName: - m_pParser->GetTagName(m_ws1); - m_pChild = new CFDE_XMLElement(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_NodeStack.Push(m_pChild); - m_pParent = m_pChild; - break; - case FDE_XMLSYNTAXSTATUS_AttriName: - m_pParser->GetAttributeName(m_ws1); - break; - case FDE_XMLSYNTAXSTATUS_AttriValue: - if (m_pChild == NULL) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pParser->GetAttributeName(m_ws2); - if (m_pChild->GetType() == FDE_XMLNODE_Element) { - ((CFDE_XMLElement*)m_pChild)->SetString(m_ws1, m_ws2); - } else if (m_pChild->GetType() == FDE_XMLNODE_Instruction) { - ((CFDE_XMLInstruction*)m_pChild)->SetString(m_ws1, m_ws2); - } - m_ws1.Empty(); - break; - case FDE_XMLSYNTAXSTATUS_Text: - m_pParser->GetTextData(m_ws1); - m_pChild = new CFDE_XMLText(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_CData: - m_pParser->GetTextData(m_ws1); - m_pChild = new CFDE_XMLCharData(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_TargetData: - if (m_pChild == NULL || - m_pChild->GetType() != FDE_XMLNODE_Instruction) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - if (!m_ws1.IsEmpty()) { - ((CFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); - } - m_pParser->GetTargetData(m_ws1); - ((CFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); - m_ws1.Empty(); - break; - default: - break; - } - if (dwRet == FDE_XMLSYNTAXSTATUS_Error || - dwRet == FDE_XMLSYNTAXSTATUS_EOS) { - break; - } - if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) { - break; - } - } - return m_pParser->GetStatus(); -} -CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, - IFDE_XMLSyntaxParser* pParser) - : m_pHandler(pHandler), - m_pParser(pParser), - m_TagStack(16), - m_pTagTop(NULL), - m_ws1(), - m_ws2() {} -CFDE_XMLSAXParser::~CFDE_XMLSAXParser() { - m_TagStack.RemoveAll(); - m_ws1.Empty(); - m_ws2.Empty(); -} -int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) { - FX_DWORD dwRet = 0; - int32_t iCount = 0; - while (TRUE) { - dwRet = m_pParser->DoSyntaxParse(); - switch (dwRet) { - case FDE_XMLSYNTAXSTATUS_ElementBreak: - if (m_pTagTop == NULL) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - if (m_pTagTop->eType == FDE_XMLNODE_Element) { - m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName); - } - break; - case FDE_XMLSYNTAXSTATUS_ElementClose: - if (m_pTagTop == NULL || m_pTagTop->eType != FDE_XMLNODE_Element) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pParser->GetTagName(m_ws1); - if (m_ws1.GetLength() > 0 && m_ws1.Compare(m_pTagTop->wsTagName) != 0) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } else if (m_ws1.GetLength() == 0) { - m_pHandler->OnTagBreak(m_pHandler, m_pTagTop->wsTagName); - } - m_pHandler->OnTagClose(m_pHandler, m_pTagTop->wsTagName); - Pop(); - iCount++; - break; - case FDE_XMLSYNTAXSTATUS_TargetName: { - m_pParser->GetTargetName(m_ws1); - CFDE_XMLTAG xmlTag; - xmlTag.wsTagName = m_ws1; - xmlTag.eType = FDE_XMLNODE_Instruction; - Push(xmlTag); - m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Instruction, - m_pTagTop->wsTagName); - m_ws1.Empty(); - } break; - case FDE_XMLSYNTAXSTATUS_TagName: { - m_pParser->GetTargetName(m_ws1); - CFDE_XMLTAG xmlTag; - xmlTag.wsTagName = m_ws1; - xmlTag.eType = FDE_XMLNODE_Element; - Push(xmlTag); - m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Element, - m_pTagTop->wsTagName); - } break; - case FDE_XMLSYNTAXSTATUS_AttriName: - m_pParser->GetTargetName(m_ws1); - break; - case FDE_XMLSYNTAXSTATUS_AttriValue: - m_pParser->GetAttributeName(m_ws2); - if (m_pTagTop == NULL) { - dwRet = FDE_XMLSYNTAXSTATUS_Error; - break; - } - if (m_pTagTop->eType == FDE_XMLNODE_Element) { - m_pHandler->OnAttribute(m_pHandler, m_ws1, m_ws2); - } - m_ws1.Empty(); - break; - case FDE_XMLSYNTAXSTATUS_CData: - m_pParser->GetTextData(m_ws1); - m_pHandler->OnData(m_pHandler, FDE_XMLNODE_CharData, m_ws1); - break; - case FDE_XMLSYNTAXSTATUS_Text: - m_pParser->GetTextData(m_ws1); - m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Text, m_ws1); - break; - case FDE_XMLSYNTAXSTATUS_TargetData: - m_pParser->GetTargetData(m_ws1); - m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Instruction, m_ws1); - m_ws1.Empty(); - break; - default: - break; - } - if (dwRet == FDE_XMLSYNTAXSTATUS_Error || - dwRet == FDE_XMLSYNTAXSTATUS_EOS) { - break; - } - if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) { - break; - } - } - return m_pParser->GetStatus(); -} -inline void CFDE_XMLSAXParser::Push(const CFDE_XMLTAG& xmlTag) { - m_TagStack.Push(xmlTag); - m_pTagTop = m_TagStack.GetTopElement(); -} -inline void CFDE_XMLSAXParser::Pop() { - m_TagStack.Pop(); - m_pTagTop = m_TagStack.GetTopElement(); -} - -CFDE_BlockBuffer::CFDE_BlockBuffer(int32_t iAllocStep) - : m_iDataLength(0), - m_iBufferSize(0), - m_iAllocStep(iAllocStep), - m_iStartPosition(0) {} -CFDE_BlockBuffer::~CFDE_BlockBuffer() { - ClearBuffer(); -} -FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { - iIndexInBlock = 0; - if (!m_BlockArray.GetSize()) { - return nullptr; - } - int32_t iRealIndex = m_iStartPosition + m_iDataLength; - if (iRealIndex == m_iBufferSize) { - FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); - m_BlockArray.Add(pBlock); - m_iBufferSize += m_iAllocStep; - return pBlock; - } - iIndexInBlock = iRealIndex % m_iAllocStep; - return (FX_WCHAR*)m_BlockArray[iRealIndex / m_iAllocStep]; -} -FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { - ClearBuffer(); - int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1; - for (int32_t i = 0; i < iNumOfBlock; i++) { - m_BlockArray.Add(FX_Alloc(FX_WCHAR, m_iAllocStep)); - } - m_iBufferSize = iNumOfBlock * m_iAllocStep; - return TRUE; -} -void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { - if (iIndex < 0) { - return; - } - int32_t iRealIndex = m_iStartPosition + iIndex; - int32_t iBlockIndex = iRealIndex / m_iAllocStep; - int32_t iInnerIndex = iRealIndex % m_iAllocStep; - int32_t iBlockSize = m_BlockArray.GetSize(); - if (iBlockIndex >= iBlockSize) { - int32_t iNewBlocks = iBlockIndex - iBlockSize + 1; - do { - FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); - m_BlockArray.Add(pBlock); - m_iBufferSize += m_iAllocStep; - } while (--iNewBlocks); - } - FX_WCHAR* pTextData = (FX_WCHAR*)m_BlockArray[iBlockIndex]; - *(pTextData + iInnerIndex) = ch; - if (m_iDataLength <= iIndex) { - m_iDataLength = iIndex + 1; - } -} -int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) { - if (iCount <= 0) { - return m_iDataLength; - } - if (iCount >= m_iDataLength) { - Reset(FALSE); - return 0; - } - if (bDirection) { - m_iStartPosition += iCount; - m_iDataLength -= iCount; - } else { - m_iDataLength -= iCount; - } - return m_iDataLength; -} -void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, - int32_t iStart, - int32_t iLength) const { - wsTextData.Empty(); - int32_t iMaybeDataLength = m_iBufferSize - 1 - m_iStartPosition; - if (iStart < 0 || iStart > iMaybeDataLength) { - return; - } - if (iLength == -1 || iLength > iMaybeDataLength) { - iLength = iMaybeDataLength; - } - if (iLength <= 0) { - return; - } - FX_WCHAR* pBuf = wsTextData.GetBuffer(iLength); - if (!pBuf) { - return; - } - int32_t iStartBlockIndex = 0; - int32_t iStartInnerIndex = 0; - TextDataIndex2BufIndex(iStart, iStartBlockIndex, iStartInnerIndex); - int32_t iEndBlockIndex = 0; - int32_t iEndInnerIndex = 0; - TextDataIndex2BufIndex(iStart + iLength, iEndBlockIndex, iEndInnerIndex); - int32_t iPointer = 0; - for (int32_t i = iStartBlockIndex; i <= iEndBlockIndex; i++) { - int32_t iBufferPointer = 0; - int32_t iCopyLength = m_iAllocStep; - if (i == iStartBlockIndex) { - iCopyLength -= iStartInnerIndex; - iBufferPointer = iStartInnerIndex; - } - if (i == iEndBlockIndex) { - iCopyLength -= ((m_iAllocStep - 1) - iEndInnerIndex); - } - FX_WCHAR* pBlockBuf = (FX_WCHAR*)m_BlockArray[i]; - FXSYS_memcpy(pBuf + iPointer, pBlockBuf + iBufferPointer, - iCopyLength * sizeof(FX_WCHAR)); - iPointer += iCopyLength; - } - wsTextData.ReleaseBuffer(iLength); -} -void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, - int32_t& iBlockIndex, - int32_t& iInnerIndex) const { - FXSYS_assert(iIndex >= 0); - int32_t iRealIndex = m_iStartPosition + iIndex; - iBlockIndex = iRealIndex / m_iAllocStep; - iInnerIndex = iRealIndex % m_iAllocStep; -} -void CFDE_BlockBuffer::ClearBuffer() { - m_iBufferSize = 0; - 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(); -} - -IFDE_XMLSyntaxParser* IFDE_XMLSyntaxParser::Create() { - return new CFDE_XMLSyntaxParser; -} - -CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser() - : m_pStream(nullptr), - m_iXMLPlaneSize(-1), - m_iCurrentPos(0), - m_iCurrentNodeNum(-1), - m_iLastNodeNum(-1), - m_iParsedChars(0), - m_iParsedBytes(0), - m_pBuffer(nullptr), - m_iBufferChars(0), - m_bEOS(FALSE), - m_pStart(nullptr), - m_pEnd(nullptr), - m_XMLNodeStack(16), - m_iAllocStep(m_BlockBuffer.GetAllocStep()), - m_iDataLength(m_BlockBuffer.GetDataLengthRef()), - m_pCurrentBlock(nullptr), - m_iIndexInBlock(0), - m_iTextDataLength(0), - m_dwStatus(FDE_XMLSYNTAXSTATUS_None), - m_dwMode(FDE_XMLSYNTAXMODE_Text), - m_wQuotationMark(0), - m_iEntityStart(-1), - m_SkipStack(16) { - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; -} -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); - int32_t iStreamLength = pStream->GetLength(); - FXSYS_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); - m_pStart = m_pEnd = m_pBuffer; - FXSYS_assert(!m_BlockBuffer.IsInitialized()); - m_BlockBuffer.InitBuffer(); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_iParsedBytes = m_iParsedChars = 0; - m_iBufferChars = 0; -} -FX_DWORD CFDE_XMLSyntaxParser::DoSyntaxParse() { - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || - m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { - return m_dwStatus; - } - FXSYS_assert(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized()); - int32_t iStreamLength = m_pStream->GetLength(); - int32_t iPos; - FX_WCHAR ch; - FX_DWORD dwStatus = FDE_XMLSYNTAXSTATUS_None; - while (TRUE) { - if (m_pStart >= m_pEnd) { - if (m_bEOS || m_iCurrentPos >= iStreamLength) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS; - return m_dwStatus; - } - m_iParsedChars += (m_pEnd - m_pBuffer); - m_iParsedBytes = m_iCurrentPos; - if (m_pStream->GetPosition() != m_iCurrentPos) { - m_pStream->Seek(FX_STREAMSEEK_Begin, m_iCurrentPos); - } - m_iBufferChars = - m_pStream->ReadString(m_pBuffer, m_iXMLPlaneSize, m_bEOS); - iPos = m_pStream->GetPosition(); - if (m_iBufferChars < 1) { - m_iCurrentPos = iStreamLength; - m_dwStatus = FDE_XMLSYNTAXSTATUS_EOS; - return m_dwStatus; - } - m_iCurrentPos = iPos; - m_pStart = m_pBuffer; - m_pEnd = m_pBuffer + m_iBufferChars; - } - while (m_pStart < m_pEnd) { - ch = *m_pStart; - switch (m_dwMode) { - case FDE_XMLSYNTAXMODE_Text: - if (ch == L'<') { - if (m_iDataLength > 0) { - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_iEntityStart = -1; - dwStatus = FDE_XMLSYNTAXSTATUS_Text; - } else { - m_pStart++; - m_dwMode = FDE_XMLSYNTAXMODE_Node; - } - } else { - ParseTextChar(ch); - } - break; - case FDE_XMLSYNTAXMODE_Node: - if (ch == L'!') { - m_pStart++; - m_dwMode = FDE_XMLSYNTAXMODE_SkipCommentOrDecl; - } else if (ch == L'/') { - m_pStart++; - m_dwMode = FDE_XMLSYNTAXMODE_CloseElement; - } else if (ch == L'?') { - m_iLastNodeNum++; - m_iCurrentNodeNum = m_iLastNodeNum; - m_CurNode.iNodeNum = m_iLastNodeNum; - m_CurNode.eNodeType = FDE_XMLNODE_Instruction; - m_XMLNodeStack.Push(m_CurNode); - m_pStart++; - m_dwMode = FDE_XMLSYNTAXMODE_Target; - dwStatus = FDE_XMLSYNTAXSTATUS_InstructionOpen; - } else { - m_iLastNodeNum++; - m_iCurrentNodeNum = m_iLastNodeNum; - m_CurNode.iNodeNum = m_iLastNodeNum; - m_CurNode.eNodeType = FDE_XMLNODE_Element; - m_XMLNodeStack.Push(m_CurNode); - m_dwMode = FDE_XMLSYNTAXMODE_Tag; - dwStatus = FDE_XMLSYNTAXSTATUS_ElementOpen; - } - break; - case FDE_XMLSYNTAXMODE_Target: - case FDE_XMLSYNTAXMODE_Tag: - if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { - if (m_iDataLength < 1) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } else { - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (m_dwMode != FDE_XMLSYNTAXMODE_Target) { - dwStatus = FDE_XMLSYNTAXSTATUS_TagName; - } else { - dwStatus = FDE_XMLSYNTAXSTATUS_TargetName; - } - m_dwMode = FDE_XMLSYNTAXMODE_AttriName; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - m_pStart++; - } - break; - case FDE_XMLSYNTAXMODE_AttriName: - if (m_iDataLength < 1 && FDE_IsXMLWhiteSpace(ch)) { - m_pStart++; - break; - } - if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { - if (m_iDataLength < 1) { - if (m_CurNode.eNodeType == FDE_XMLNODE_Element) { - if (ch == L'>' || ch == L'/') { - m_dwMode = FDE_XMLSYNTAXMODE_BreakElement; - break; - } - } else if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - if (ch == L'?') { - m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction; - m_pStart++; - } else { - m_dwMode = FDE_XMLSYNTAXMODE_TargetData; - } - break; - } - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } else { - if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - if (ch != '=' && !FDE_IsXMLWhiteSpace(ch)) { - m_dwMode = FDE_XMLSYNTAXMODE_TargetData; - break; - } - } - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_dwMode = FDE_XMLSYNTAXMODE_AttriEqualSign; - dwStatus = FDE_XMLSYNTAXSTATUS_AttriName; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - m_pStart++; - } - break; - case FDE_XMLSYNTAXMODE_AttriEqualSign: - if (FDE_IsXMLWhiteSpace(ch)) { - m_pStart++; - break; - } - if (ch != L'=') { - if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - m_dwMode = FDE_XMLSYNTAXMODE_TargetData; - break; - } - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } else { - m_dwMode = FDE_XMLSYNTAXMODE_AttriQuotation; - m_pStart++; - } - break; - case FDE_XMLSYNTAXMODE_AttriQuotation: - if (FDE_IsXMLWhiteSpace(ch)) { - m_pStart++; - break; - } - if (ch != L'\"' && ch != L'\'') { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } else { - m_wQuotationMark = ch; - m_dwMode = FDE_XMLSYNTAXMODE_AttriValue; - m_pStart++; - } - break; - case FDE_XMLSYNTAXMODE_AttriValue: - if (ch == m_wQuotationMark) { - if (m_iEntityStart > -1) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - m_iTextDataLength = m_iDataLength; - m_wQuotationMark = 0; - m_BlockBuffer.Reset(); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_pStart++; - m_dwMode = FDE_XMLSYNTAXMODE_AttriName; - dwStatus = FDE_XMLSYNTAXSTATUS_AttriValue; - } else { - ParseTextChar(ch); - } - break; - case FDE_XMLSYNTAXMODE_CloseInstruction: - if (ch != L'>') { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - m_dwMode = FDE_XMLSYNTAXMODE_TargetData; - } else if (m_iDataLength > 0) { - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; - } else { - m_pStart++; - FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement(); - if (pXMLNode == NULL) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - m_XMLNodeStack.Pop(); - pXMLNode = m_XMLNodeStack.GetTopElement(); - if (pXMLNode == NULL) { - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; - } else { - m_CurNode = *pXMLNode; - } - m_iCurrentNodeNum = m_CurNode.iNodeNum; - m_BlockBuffer.Reset(); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_dwMode = FDE_XMLSYNTAXMODE_Text; - dwStatus = FDE_XMLSYNTAXSTATUS_InstructionClose; - } - break; - case FDE_XMLSYNTAXMODE_BreakElement: - if (ch == L'>') { - m_dwMode = FDE_XMLSYNTAXMODE_Text; - dwStatus = FDE_XMLSYNTAXSTATUS_ElementBreak; - } else if (ch == L'/') { - m_dwMode = FDE_XMLSYNTAXMODE_CloseElement; - } else { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - m_pStart++; - break; - case FDE_XMLSYNTAXMODE_CloseElement: - if (!FDE_IsXMLNameChar(ch, m_iDataLength < 1)) { - if (ch == L'>') { - FDE_XMLNODE* pXMLNode = m_XMLNodeStack.GetTopElement(); - if (pXMLNode == NULL) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - m_XMLNodeStack.Pop(); - pXMLNode = m_XMLNodeStack.GetTopElement(); - if (pXMLNode == NULL) { - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; - } else { - m_CurNode = *pXMLNode; - } - m_iCurrentNodeNum = m_CurNode.iNodeNum; - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_dwMode = FDE_XMLSYNTAXMODE_Text; - dwStatus = FDE_XMLSYNTAXSTATUS_ElementClose; - } else if (!FDE_IsXMLWhiteSpace(ch)) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - } - m_pStart++; - break; - case FDE_XMLSYNTAXMODE_SkipCommentOrDecl: - if (ch == '-') { - m_dwMode = FDE_XMLSYNTAXMODE_SkipComment; - } else { - m_dwMode = FDE_XMLSYNTAXMODE_SkipDeclNode; - m_SkipChar = L'>'; - m_SkipStack.Push(L'>'); - } - break; - case FDE_XMLSYNTAXMODE_SkipDeclNode: - if (m_SkipChar == L'\'' || m_SkipChar == L'\"') { - m_pStart++; - if (ch != m_SkipChar) { - break; - } - m_SkipStack.Pop(); - FX_DWORD* pDWord = m_SkipStack.GetTopElement(); - if (pDWord == NULL) { - m_dwMode = FDE_XMLSYNTAXMODE_Text; - } else { - m_SkipChar = (FX_WCHAR)*pDWord; - } - } else { - switch (ch) { - case L'<': - m_SkipChar = L'>'; - m_SkipStack.Push(L'>'); - break; - case L'[': - m_SkipChar = L']'; - m_SkipStack.Push(L']'); - break; - case L'(': - m_SkipChar = L')'; - m_SkipStack.Push(L')'); - break; - case L'\'': - m_SkipChar = L'\''; - m_SkipStack.Push(L'\''); - break; - case L'\"': - m_SkipChar = L'\"'; - m_SkipStack.Push(L'\"'); - break; - default: - if (ch == m_SkipChar) { - m_SkipStack.Pop(); - FX_DWORD* pDWord = m_SkipStack.GetTopElement(); - if (pDWord == NULL) { - if (m_iDataLength >= 9) { - CFX_WideString wsHeader; - m_BlockBuffer.GetTextData(wsHeader, 0, 7); - if (wsHeader.Equal(FX_WSTRC(L"[CDATA["))) { - CFX_WideString wsTailer; - m_BlockBuffer.GetTextData(wsTailer, m_iDataLength - 2, - 2); - if (wsTailer.Equal(FX_WSTRC(L"]]"))) { - m_BlockBuffer.DeleteTextChars(7, TRUE); - m_BlockBuffer.DeleteTextChars(2, FALSE); - dwStatus = FDE_XMLSYNTAXSTATUS_CData; - } - } - } - m_iTextDataLength = m_iDataLength; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_dwMode = FDE_XMLSYNTAXMODE_Text; - } else { - m_SkipChar = (FX_WCHAR)*pDWord; - } - } - break; - } - if (m_SkipStack.GetSize() > 0) { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - } - m_pStart++; - } - break; - case FDE_XMLSYNTAXMODE_SkipComment: - if (ch == L'-') { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = L'-'; - m_iDataLength++; - } else if (ch == L'>') { - if (m_iDataLength > 1) { - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_dwMode = FDE_XMLSYNTAXMODE_Text; - } - } else { - m_BlockBuffer.Reset(); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - } - m_pStart++; - break; - case FDE_XMLSYNTAXMODE_TargetData: - if (FDE_IsXMLWhiteSpace(ch)) { - if (m_iDataLength < 1) { - m_pStart++; - break; - } else if (m_wQuotationMark == 0) { - m_iTextDataLength = m_iDataLength; - m_wQuotationMark = 0; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_pStart++; - dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; - break; - } - } - if (ch == '?') { - m_dwMode = FDE_XMLSYNTAXMODE_CloseInstruction; - m_pStart++; - } else if (ch == '\"') { - if (m_wQuotationMark == 0) { - m_wQuotationMark = ch; - m_pStart++; - } else if (ch == m_wQuotationMark) { - m_iTextDataLength = m_iDataLength; - m_wQuotationMark = 0; - m_BlockBuffer.Reset(); - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_pStart++; - dwStatus = FDE_XMLSYNTAXSTATUS_TargetData; - } else { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - return m_dwStatus; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = - m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return FDE_XMLSYNTAXSTATUS_Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - m_pStart++; - } - break; - default: - break; - } - if (dwStatus != FDE_XMLSYNTAXSTATUS_None) { - return dwStatus; - } - } - } - return 0; -} - -CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() { - if (m_pCurrentBlock) { - m_pCurrentBlock = NULL; - } - FX_Free(m_pBuffer); -} - -int32_t CFDE_XMLSyntaxParser::GetStatus() const { - if (m_pStream == NULL) { - return -1; - } - int32_t iStreamLength = m_pStream->GetLength(); - if (iStreamLength < 1) { - return 100; - } - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) { - return -1; - } - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { - return 100; - } - return m_iParsedBytes * 100 / iStreamLength; -} -static int32_t FX_GetUTF8EncodeLength(const FX_WCHAR* pSrc, int32_t iSrcLen) { - FX_DWORD unicode = 0; - int32_t iDstNum = 0; - while (iSrcLen-- > 0) { - unicode = *pSrc++; - int nbytes = 0; - if ((FX_DWORD)unicode < 0x80) { - nbytes = 1; - } else if ((FX_DWORD)unicode < 0x800) { - nbytes = 2; - } else if ((FX_DWORD)unicode < 0x10000) { - nbytes = 3; - } else if ((FX_DWORD)unicode < 0x200000) { - nbytes = 4; - } else if ((FX_DWORD)unicode < 0x4000000) { - nbytes = 5; - } else { - nbytes = 6; - } - iDstNum += nbytes; - } - return iDstNum; -} -FX_FILESIZE CFDE_XMLSyntaxParser::GetCurrentBinaryPos() const { - if (m_pStream == NULL) { - return 0; - } - int32_t nSrcLen = m_pStart - m_pBuffer; - int32_t nDstLen = FX_GetUTF8EncodeLength(m_pBuffer, nSrcLen); - return m_iParsedBytes + nDstLen; -} - -void CFDE_XMLSyntaxParser::ParseTextChar(FX_WCHAR ch) { - if (m_iIndexInBlock == m_iAllocStep) { - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - if (!m_pCurrentBlock) { - return; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_iDataLength++; - if (m_iEntityStart > -1 && ch == L';') { - CFX_WideString csEntity; - m_BlockBuffer.GetTextData(csEntity, m_iEntityStart + 1, - (m_iDataLength - 1) - m_iEntityStart - 1); - int32_t iLen = csEntity.GetLength(); - if (iLen > 0) { - if (csEntity[0] == L'#') { - ch = 0; - FX_WCHAR w; - if (iLen > 1 && csEntity[1] == L'x') { - for (int32_t i = 2; i < iLen; i++) { - w = csEntity[i]; - if (w >= L'0' && w <= L'9') { - ch = (ch << 4) + w - L'0'; - } else if (w >= L'A' && w <= L'F') { - ch = (ch << 4) + w - 55; - } else if (w >= L'a' && w <= L'f') { - ch = (ch << 4) + w - 87; - } else { - break; - } - } - } else { - for (int32_t i = 1; i < iLen; i++) { - w = csEntity[i]; - if (w < L'0' || w > L'9') { - break; - } - ch = ch * 10 + w - L'0'; - } - } - if (ch != 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, ch); - m_iEntityStart++; - } - } else { - if (csEntity.Compare(L"amp") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'&'); - m_iEntityStart++; - } else if (csEntity.Compare(L"lt") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'<'); - m_iEntityStart++; - } else if (csEntity.Compare(L"gt") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'>'); - m_iEntityStart++; - } else if (csEntity.Compare(L"apos") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'\''); - m_iEntityStart++; - } else if (csEntity.Compare(L"quot") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'\"'); - m_iEntityStart++; - } - } - } - m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); - m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); - m_iEntityStart = -1; - } else { - if (m_iEntityStart < 0 && ch == L'&') { - m_iEntityStart = m_iDataLength - 1; - } - } - m_pStart++; -} diff --git a/xfa/src/fde/xml/fde_xml_imp.h b/xfa/src/fde/xml/fde_xml_imp.h deleted file mode 100644 index 815d746d31..0000000000 --- a/xfa/src/fde/xml/fde_xml_imp.h +++ /dev/null @@ -1,354 +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_SRC_FDE_XML_FDE_XML_IMP_H_ -#define XFA_SRC_FDE_XML_FDE_XML_IMP_H_ - -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fde/xml/fde_xml.h" -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_stream.h" - -class CFDE_BlockBuffer; -class CFDE_XMLInstruction; -class CFDE_XMLElement; -class CFDE_XMLText; -class CFDE_XMLDoc; -class IFDE_XMLParser; -class CFDE_XMLDOMParser; -class CFDE_XMLSAXParser; -class CFDE_XMLSyntaxParser; - -class CFDE_XMLNode : public CFX_Target { - public: - CFDE_XMLNode(); - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } - virtual int32_t CountChildNodes() const; - virtual CFDE_XMLNode* GetChildNode(int32_t index) const; - virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; - virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, - int32_t iLength = -1, - FX_BOOL bQualifiedName = TRUE) const; - virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); - virtual void RemoveChildNode(CFDE_XMLNode* pNode); - virtual void DeleteChildren(); - virtual CFDE_XMLNode* GetNodeItem(IFDE_XMLNode::NodeItem eItem) const; - virtual int32_t GetNodeLevel() const; - virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem, - CFDE_XMLNode* pNode); - virtual CFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem); - virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); - virtual void SaveXMLNode(IFX_Stream* pXMLStream); - - public: - ~CFDE_XMLNode(); - void CloneChildren(CFDE_XMLNode* pClone); - CFDE_XMLNode* m_pParent; - CFDE_XMLNode* m_pChild; - CFDE_XMLNode* m_pPrior; - CFDE_XMLNode* m_pNext; -}; -class CFDE_XMLInstruction : public CFDE_XMLNode { - public: - CFDE_XMLInstruction(const CFX_WideString& wsTarget); - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; } - virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); - virtual void GetTargetName(CFX_WideString& wsTarget) const { - wsTarget = m_wsTarget; - } - virtual int32_t CountAttributes() const; - virtual FX_BOOL GetAttribute(int32_t index, - CFX_WideString& wsAttriName, - CFX_WideString& wsAttriValue) const; - virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; - virtual void GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = NULL) const; - virtual void SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue); - virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue = 0) const; - virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); - virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue = 0) const; - virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); - virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); - virtual int32_t CountData() const; - virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; - virtual void AppendData(const CFX_WideString& wsData); - virtual void RemoveData(int32_t index); - - public: - ~CFDE_XMLInstruction() {} - CFX_WideString m_wsTarget; - CFX_WideStringArray m_Attributes; - CFX_WideStringArray m_TargetData; -}; -class CFDE_XMLElement : public CFDE_XMLNode { - public: - CFDE_XMLElement(const CFX_WideString& wsTag); - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; } - virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); - virtual void GetTagName(CFX_WideString& wsTag) const; - virtual void GetLocalTagName(CFX_WideString& wsTag) const; - virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; - virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const; - virtual int32_t CountAttributes() const; - virtual FX_BOOL GetAttribute(int32_t index, - CFX_WideString& wsAttriName, - CFX_WideString& wsAttriValue) const; - virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; - virtual void GetString(const FX_WCHAR* pwsAttriName, - CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = NULL) const; - virtual void SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue); - virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, - int32_t iDefValue = 0) const; - virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); - virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, - FX_FLOAT fDefValue = 0) const; - virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); - virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); - virtual void GetTextData(CFX_WideString& wsText) const; - virtual void SetTextData(const CFX_WideString& wsText); - - public: - ~CFDE_XMLElement(); - CFX_WideString m_wsTag; - CFX_WideStringArray m_Attributes; -}; -class CFDE_XMLText : public CFDE_XMLNode { - public: - CFDE_XMLText(const CFX_WideString& wsText); - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; } - virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); - virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } - virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } - - public: - ~CFDE_XMLText() {} - CFX_WideString m_wsText; -}; -class CFDE_XMLDeclaration : public CFDE_XMLNode { - public: - CFDE_XMLDeclaration() : CFDE_XMLNode() {} -}; -class CFDE_XMLCharData : public CFDE_XMLDeclaration { - public: - CFDE_XMLCharData(const CFX_WideString& wsCData); - - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; } - virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); - virtual void GetCharData(CFX_WideString& wsCharData) const { - wsCharData = m_wsCharData; - } - virtual void SetCharData(const CFX_WideString& wsCData) { - m_wsCharData = wsCData; - } - - public: - ~CFDE_XMLCharData() {} - - CFX_WideString m_wsCharData; -}; -class CFDE_XMLDoc : public CFX_Target { - public: - CFDE_XMLDoc(); - ~CFDE_XMLDoc(); - virtual void Release() { delete this; } - virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, - int32_t iXMLPlaneSize = 8192, - int32_t iTextDataSize = 256, - FDE_XMLREADERHANDLER* pHandler = NULL); - virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser); - virtual int32_t DoLoad(IFX_Pause* pPause = NULL); - virtual void CloseXML(); - virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } - virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE); - virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode); - - protected: - IFX_Stream* m_pStream; - int32_t m_iStatus; - CFDE_XMLNode* m_pRoot; - IFDE_XMLSyntaxParser* m_pSyntaxParser; - IFDE_XMLParser* m_pXMLParser; - void Reset(FX_BOOL bInitRoot); - void ReleaseParser(); -}; -typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; -class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target { - public: - CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, IFDE_XMLSyntaxParser* pParser); - ~CFDE_XMLDOMParser(); - - virtual void Release() { delete this; } - virtual int32_t DoParser(IFX_Pause* pPause); - - private: - IFDE_XMLSyntaxParser* m_pParser; - CFDE_XMLNode* m_pParent; - CFDE_XMLNode* m_pChild; - CFDE_XMLDOMNodeStack m_NodeStack; - CFX_WideString m_ws1; - CFX_WideString m_ws2; -}; -class CFDE_XMLTAG : public CFX_Target { - public: - CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {} - CFDE_XMLTAG(const CFDE_XMLTAG& src) - : wsTagName(src.wsTagName), eType(src.eType) {} - CFX_WideString wsTagName; - FDE_XMLNODETYPE eType; -}; -typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; -class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target { - public: - CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, - IFDE_XMLSyntaxParser* pParser); - ~CFDE_XMLSAXParser(); - - virtual void Release() { delete this; } - virtual int32_t DoParser(IFX_Pause* pPause); - - private: - void Push(const CFDE_XMLTAG& xmlTag); - void Pop(); - FDE_XMLREADERHANDLER* m_pHandler; - IFDE_XMLSyntaxParser* m_pParser; - CFDE_XMLTagStack m_TagStack; - CFDE_XMLTAG* m_pTagTop; - CFX_WideString m_ws1; - CFX_WideString m_ws2; -}; - -class CFDE_BlockBuffer : public CFX_Target { - public: - CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); - ~CFDE_BlockBuffer(); - - FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); - FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } - void ReleaseBuffer() { delete this; } - FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); - inline int32_t GetAllocStep() const { return m_iAllocStep; } - inline int32_t& GetDataLengthRef() { return m_iDataLength; } - inline void Reset(FX_BOOL bReserveData = TRUE) { - if (!bReserveData) { - m_iStartPosition = 0; - } - m_iDataLength = 0; - } - void SetTextChar(int32_t iIndex, FX_WCHAR ch); - int32_t DeleteTextChars(int32_t iCount, FX_BOOL bDirection = TRUE); - void GetTextData(CFX_WideString& wsTextData, - int32_t iStart = 0, - int32_t iLength = -1) const; - - protected: - inline void TextDataIndex2BufIndex(const int32_t iIndex, - int32_t& iBlockIndex, - int32_t& iInnerIndex) const; - void ClearBuffer(); - CFX_PtrArray m_BlockArray; - int32_t m_iDataLength; - int32_t m_iBufferSize; - int32_t m_iAllocStep; - int32_t m_iStartPosition; -}; - -#define FDE_XMLSYNTAXMODE_Text 0 -#define FDE_XMLSYNTAXMODE_Node 1 -#define FDE_XMLSYNTAXMODE_Target 2 -#define FDE_XMLSYNTAXMODE_Tag 3 -#define FDE_XMLSYNTAXMODE_AttriName 4 -#define FDE_XMLSYNTAXMODE_AttriEqualSign 5 -#define FDE_XMLSYNTAXMODE_AttriQuotation 6 -#define FDE_XMLSYNTAXMODE_AttriValue 7 -#define FDE_XMLSYNTAXMODE_Entity 8 -#define FDE_XMLSYNTAXMODE_EntityDecimal 9 -#define FDE_XMLSYNTAXMODE_EntityHex 10 -#define FDE_XMLSYNTAXMODE_CloseInstruction 11 -#define FDE_XMLSYNTAXMODE_BreakElement 12 -#define FDE_XMLSYNTAXMODE_CloseElement 13 -#define FDE_XMLSYNTAXMODE_SkipDeclNode 14 -#define FDE_XMLSYNTAXMODE_DeclCharData 15 -#define FDE_XMLSYNTAXMODE_SkipComment 16 -#define FDE_XMLSYNTAXMODE_SkipCommentOrDecl 17 -#define FDE_XMLSYNTAXMODE_TargetData 18 -class CFDE_XMLSyntaxParser : public IFDE_XMLSyntaxParser, public CFX_Target { - public: - CFDE_XMLSyntaxParser(); - ~CFDE_XMLSyntaxParser(); - virtual void Release() { delete this; } - virtual void Init(IFX_Stream* pStream, - int32_t iXMLPlaneSize, - int32_t iTextDataSize = 256); - virtual FX_DWORD DoSyntaxParse(); - virtual int32_t GetStatus() const; - virtual int32_t GetCurrentPos() const { - return m_iParsedChars + (m_pStart - m_pBuffer); - } - virtual FX_FILESIZE GetCurrentBinaryPos() const; - virtual int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } - virtual int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } - - virtual void GetTargetName(CFX_WideString& wsTarget) const { - m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength); - } - virtual void GetTagName(CFX_WideString& wsTag) const { - m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength); - } - virtual void GetAttributeName(CFX_WideString& wsAttriName) const { - m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength); - } - virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const { - m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength); - } - virtual void GetTextData(CFX_WideString& wsText) const { - m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength); - } - virtual void GetTargetData(CFX_WideString& wsData) const { - m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength); - } - - protected: - IFX_Stream* m_pStream; - int32_t m_iXMLPlaneSize; - int32_t m_iCurrentPos; - int32_t m_iCurrentNodeNum; - int32_t m_iLastNodeNum; - int32_t m_iParsedChars; - int32_t m_iParsedBytes; - FX_WCHAR* m_pBuffer; - int32_t m_iBufferChars; - FX_BOOL m_bEOS; - FX_WCHAR* m_pStart; - FX_WCHAR* m_pEnd; - FDE_XMLNODE m_CurNode; - CFDE_XMLNodeStack m_XMLNodeStack; - CFDE_BlockBuffer m_BlockBuffer; - int32_t m_iAllocStep; - int32_t& m_iDataLength; - FX_WCHAR* m_pCurrentBlock; - int32_t m_iIndexInBlock; - int32_t m_iTextDataLength; - FX_DWORD m_dwStatus; - FX_DWORD m_dwMode; - FX_WCHAR m_wQuotationMark; - int32_t m_iEntityStart; - CFX_DWordStack m_SkipStack; - FX_WCHAR m_SkipChar; - inline void ParseTextChar(FX_WCHAR ch); -}; - -#endif // XFA_SRC_FDE_XML_FDE_XML_IMP_H_ diff --git a/xfa/src/fee/fde_txtedtbuf.cpp b/xfa/src/fee/fde_txtedtbuf.cpp deleted file mode 100644 index 93a12dd282..0000000000 --- a/xfa/src/fee/fde_txtedtbuf.cpp +++ /dev/null @@ -1,403 +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/src/fee/fde_txtedtbuf.h" - -#include <algorithm> - -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" - -#define FDE_DEFCHUNKCOUNT 2 -#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9 -#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB -#define FDE_TXTEDT_ZEROWIDTHSPACE 0x200B - -CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias) - : m_pBuf(pBuf), - m_nCurChunk(0), - m_nCurIndex(0), - m_nIndex(0), - m_Alias(wcAlias) { - FXSYS_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; - if (m_nCurIndex > 0) { - m_nCurIndex--; - } else { - while (m_nCurChunk > 0) { - --m_nCurChunk; - lpChunk = - (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk]; - if (lpChunk->nUsed > 0) { - m_nCurIndex = lpChunk->nUsed - 1; - break; - } - } - } - FXSYS_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]; - 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]; - if (lpChunkTemp->nUsed > 0) { - m_nCurIndex = 0; - break; - } - } - } - m_nIndex++; - return TRUE; - } -} -void CFDE_TxtEdtBufIter::SetAt(int32_t nIndex) { - FXSYS_assert(nIndex >= 0 && nIndex < m_pBuf->m_nTotal); - CFDE_TxtEdtBuf::FDE_CHUNKPLACE cp; - m_pBuf->Index2CP(nIndex, cp); - m_nIndex = nIndex; - m_nCurChunk = cp.nChunkIndex; - m_nCurIndex = cp.nCharIndex; -} -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); - 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_Alias; -} -FX_BOOL CFDE_TxtEdtBufIter::IsEOF(FX_BOOL bTail) const { - return bTail ? m_nIndex == (m_pBuf->GetTextLength() - 2) : m_nIndex == 0; -} -IFX_CharIter* CFDE_TxtEdtBufIter::Clone() { - CFDE_TxtEdtBufIter* pIter = new CFDE_TxtEdtBufIter(m_pBuf); - pIter->m_nCurChunk = m_nCurChunk; - pIter->m_nCurIndex = m_nCurIndex; - pIter->m_nIndex = m_nIndex; - pIter->m_Alias = m_Alias; - return pIter; -} -CFDE_TxtEdtBuf::CFDE_TxtEdtBuf(int32_t nDefChunkSize) - : m_nChunkSize(nDefChunkSize), - m_nTotal(0), - m_bChanged(FALSE), - m_pAllocator(NULL) { - FXSYS_assert(m_nChunkSize); - ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize); -} -void CFDE_TxtEdtBuf::Release() { - delete this; -} -CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() { - Clear(TRUE); - m_pAllocator->Release(); - m_Chunks.RemoveAll(); -} -FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) { - FXSYS_assert(nChunkSize); - ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize); - return TRUE; -} -int32_t CFDE_TxtEdtBuf::GetChunkSize() const { - return m_nChunkSize; -} -int32_t CFDE_TxtEdtBuf::GetTextLength() const { - return m_nTotal; -} -void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) { - FXSYS_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)); - lpChunk->nUsed = 0; - m_Chunks.Add(lpChunk); - } - int32_t nTotalCount = m_Chunks.GetSize(); - const FX_WCHAR* lpSrcBuf = wsText.c_str(); - int32_t nLeave = nTextLength; - int32_t nCopyedLength = m_nChunkSize; - for (i = 0; i < nTotalCount && nLeave > 0; i++) { - if (nLeave < nCopyedLength) { - nCopyedLength = nLeave; - } - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; - FXSYS_memcpy(lpChunk->wChars, lpSrcBuf, nCopyedLength * sizeof(FX_WCHAR)); - nLeave -= nCopyedLength; - lpSrcBuf += nCopyedLength; - lpChunk->nUsed = nCopyedLength; - } - m_nTotal = nTextLength; - m_bChanged = TRUE; -} -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; - 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]; - nTotal += pChunkHeader->nUsed; - if (nTotal > nIndex) { - break; - } - } - FXSYS_assert(pChunkHeader); - return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)]; -} -void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText, - int32_t nBegin, - int32_t nLength) const { - FDE_CHUNKPLACE cp; - Index2CP(nBegin, cp); - int32_t nLeave = nLength; - 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]; - int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex; - FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex; - while (nLeave > 0) { - if (nLeave <= nCopyLength) { - nCopyLength = nLeave; - } - FXSYS_memcpy(lpDstBuf, lpSrcBuf, nCopyLength * sizeof(FX_WCHAR)); - nChunkIndex++; - if (nChunkIndex >= nCount) { - break; - } - lpChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[nChunkIndex]; - lpSrcBuf = lpChunkHeader->wChars; - nLeave -= nCopyLength; - lpDstBuf += nCopyLength; - nCopyLength = lpChunkHeader->nUsed; - } - wsText.ReleaseBuffer(); -} -void CFDE_TxtEdtBuf::Insert(int32_t nPos, - const FX_WCHAR* lpText, - int32_t nLength) { - FXSYS_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]; - int32_t nCopy = lpChunk->nUsed - cp.nCharIndex; - FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex, - nCopy * sizeof(FX_WCHAR)); - lpChunk->nUsed -= nCopy; - cp.nChunkIndex++; - m_Chunks.InsertAt(cp.nChunkIndex, lpNewChunk); - lpNewChunk->nUsed = nCopy; - cp.nCharIndex = 0; - } - if (cp.nChunkIndex != 0) { - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex - 1]; - if (lpChunk->nUsed != m_nChunkSize) { - cp.nChunkIndex--; - int32_t nFree = m_nChunkSize - lpChunk->nUsed; - int32_t nCopy = std::min(nLengthTemp, nFree); - FXSYS_memcpy(lpChunk->wChars + lpChunk->nUsed, lpText, - nCopy * sizeof(FX_WCHAR)); - lpText += nCopy; - nLengthTemp -= nCopy; - lpChunk->nUsed += nCopy; - cp.nChunkIndex++; - } - } - while (nLengthTemp > 0) { - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( - sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); - FXSYS_assert(lpChunk); - int32_t nCopy = std::min(nLengthTemp, m_nChunkSize); - FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR)); - lpText += nCopy; - nLengthTemp -= nCopy; - lpChunk->nUsed = nCopy; - m_Chunks.InsertAt(cp.nChunkIndex, lpChunk); - cp.nChunkIndex++; - } - m_nTotal += nLength; - m_bChanged = TRUE; -} -void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) { - FXSYS_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]; - int32_t nFirstPart = cpEnd.nCharIndex + 1; - int32_t nMovePart = lpChunk->nUsed - nFirstPart; - if (nMovePart != 0) { - int32_t nDelete = std::min(nFirstPart, nLength); - FXSYS_memmove(lpChunk->wChars + nFirstPart - nDelete, - lpChunk->wChars + nFirstPart, nMovePart * sizeof(FX_WCHAR)); - lpChunk->nUsed -= nDelete; - nLength -= nDelete; - cpEnd.nChunkIndex--; - } - while (nLength > 0) { - lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex]; - int32_t nDeleted = std::min(lpChunk->nUsed, nLength); - lpChunk->nUsed -= nDeleted; - if (lpChunk->nUsed == 0) { - m_pAllocator->Free(lpChunk); - m_Chunks.RemoveAt(cpEnd.nChunkIndex); - lpChunk = NULL; - } - nLength -= nDeleted; - cpEnd.nChunkIndex--; - } - m_bChanged = TRUE; -} -void CFDE_TxtEdtBuf::Clear(FX_BOOL bRelease) { - int32_t i = 0; - int32_t nCount = m_Chunks.GetSize(); - if (bRelease) { - while (i < nCount) { - m_pAllocator->Free(m_Chunks[i++]); - } - m_Chunks.RemoveAll(); - } else { - while (i < nCount) { - ((FDE_LPCHUNKHEADER)m_Chunks[i++])->nUsed = 0; - } - } - m_nTotal = 0; - m_bChanged = TRUE; -} -FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) { - if (m_bChanged == FALSE) { - return TRUE; - } - if (m_nTotal == 0) { - return TRUE; - } - int32_t nCount = m_Chunks.GetSize(); - if (nCount == 0) { - return TRUE; - } - int32_t i = 0; - for (; i < nCount; i++) { - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; - if (lpChunk->nUsed == 0) { - m_pAllocator->Free(lpChunk); - m_Chunks.RemoveAt(i); - --i; - --nCount; - } - } - if (pPause != NULL && pPause->NeedToPauseNow()) { - return FALSE; - } - FDE_LPCHUNKHEADER lpPreChunk = (FDE_LPCHUNKHEADER)m_Chunks[0]; - FDE_LPCHUNKHEADER lpCurChunk = NULL; - for (i = 1; i < nCount; i++) { - lpCurChunk = (FDE_LPCHUNKHEADER)m_Chunks[i]; - if (lpPreChunk->nUsed + lpCurChunk->nUsed <= m_nChunkSize) { - FXSYS_memcpy(lpPreChunk->wChars + lpPreChunk->nUsed, lpCurChunk->wChars, - lpCurChunk->nUsed * sizeof(FX_WCHAR)); - lpPreChunk->nUsed += lpCurChunk->nUsed; - m_pAllocator->Free(lpCurChunk); - m_Chunks.RemoveAt(i); - --i; - --nCount; - } else { - lpPreChunk = lpCurChunk; - } - if (pPause != NULL && pPause->NeedToPauseNow()) { - return FALSE; - } - } - m_bChanged = FALSE; - return TRUE; -} -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; - } - 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); - lpChunkHeader->nUsed = 0; - m_Chunks.Add(lpChunkHeader); - m_nTotal = 0; -} -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; - } - return nTotal; -} -void CFDE_TxtEdtBuf::Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const { - FXSYS_assert(nIndex <= GetTextLength()); - if (nIndex == m_nTotal) { - cp.nChunkIndex = m_Chunks.GetSize() - 1; - cp.nCharIndex = ((FDE_LPCHUNKHEADER)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; - if (nTotal > nIndex) { - break; - } - } - cp.nChunkIndex = i; - cp.nCharIndex = ((FDE_LPCHUNKHEADER)m_Chunks[i])->nUsed - (nTotal - nIndex); -} diff --git a/xfa/src/fee/fde_txtedtbuf.h b/xfa/src/fee/fde_txtedtbuf.h deleted file mode 100644 index 9fb6ac1b87..0000000000 --- a/xfa/src/fee/fde_txtedtbuf.h +++ /dev/null @@ -1,92 +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_SRC_FEE_FDE_TXTEDTBUF_H_ -#define XFA_SRC_FEE_FDE_TXTEDTBUF_H_ - -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" -#include "xfa/src/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); - - 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(); - - private: - CFDE_TxtEdtBuf* m_pBuf; - int32_t m_nCurChunk; - int32_t m_nCurIndex; - int32_t m_nIndex; - FX_WCHAR m_Alias; -}; -class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf { - friend class CFDE_TxtEdtBufIter; - struct _FDE_CHUNKHEADER { - int32_t nUsed; - FX_WCHAR wChars[1]; - }; - typedef _FDE_CHUNKHEADER FDE_CHUNKHEADER; - typedef _FDE_CHUNKHEADER* FDE_LPCHUNKHEADER; - 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; - - int32_t m_nChunkSize; - - int32_t m_nTotal; - FX_BOOL m_bChanged; - CFX_PtrArray m_Chunks; - IFX_MEMAllocator* m_pAllocator; -}; - -#endif // XFA_SRC_FEE_FDE_TXTEDTBUF_H_ diff --git a/xfa/src/fee/fde_txtedtengine.cpp b/xfa/src/fee/fde_txtedtengine.cpp deleted file mode 100644 index 9f8fe5b4e6..0000000000 --- a/xfa/src/fee/fde_txtedtengine.cpp +++ /dev/null @@ -1,1783 +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/src/fee/fde_txtedtengine.h" - -#include <algorithm> - -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fee/fde_txtedtbuf.h" -#include "xfa/src/fee/fde_txtedtparag.h" -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" -#include "xfa/src/fee/ifde_txtedtpage.h" - -#define FDE_PAGEWIDTH_MAX 0xFFFF -#define FDE_TXTPLATESIZE (1024 * 12) -#define FDE_UNICODE_PARAGRAPH_SPERATOR (0x2029) -#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), - m_nLineCount(0), - m_nAnchorPos(-1), - m_nLayoutPos(0), - m_fCaretPosReserve(0.0), - m_nCaret(0), - m_bBefore(TRUE), - m_nCaretPage(0), - m_dwFindFlags(0), - m_bLock(FALSE), - m_nLimit(0), - m_wcAliasChar(L'*'), - m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto), - m_bAutoLineEnd(TRUE), - m_wLineEnd(FDE_UNICODE_PARAGRAPH_SPERATOR) { - FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF)); - m_pTxtBuf = new CFDE_TxtEdtBuf(); - m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); -} -CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() { - if (m_pTxtBuf) { - m_pTxtBuf->Release(); - m_pTxtBuf = NULL; - } - if (m_pTextBreak) { - m_pTextBreak->Release(); - m_pTextBreak = NULL; - } - RemoveAllParags(); - RemoveAllPages(); - m_Param.pEventSink = NULL; - ClearSelection(); -} -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); - } - FXSYS_memcpy(&m_Param, ¶ms, sizeof(FDE_TXTEDTPARAMS)); - m_wLineEnd = params.wLineBreakChar; - m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); - UpdateTxtBreak(); -} -const FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() const { - return &m_Param; -} -int32_t CFDE_TxtEdtEngine::CountPages() const { - if (m_nLineCount == 0) { - return 0; - } - return ((m_nLineCount - 1) / m_nPageLineCount) + 1; -} -IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) { - if (m_PagePtrArray.GetSize() <= nIndex) { - return NULL; - } - return (IFDE_TxtEdtPage*)m_PagePtrArray[nIndex]; -} -FX_BOOL CFDE_TxtEdtEngine::SetBufChunkSize(int32_t nChunkSize) { - return m_pTxtBuf->SetChunkSize(nChunkSize); -} -void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) { - ResetEngine(); - int32_t nIndex = 0; - if (pStream != NULL && pStream->GetLength()) { - int32_t nStreamLength = pStream->GetLength(); - FX_BOOL bValid = TRUE; - if (m_nLimit > 0 && nStreamLength > m_nLimit) { - bValid = FALSE; - } - FX_BOOL bPreIsCR = FALSE; - if (bValid) { - uint8_t bom[4]; - int32_t nPos = pStream->GetBOM(bom); - pStream->Seek(FX_STREAMSEEK_Begin, nPos); - int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize()); - FX_WCHAR* lpwstr = FX_Alloc(FX_WCHAR, nPlateSize); - FX_BOOL bEos = false; - while (!bEos) { - int32_t nRead = pStream->ReadString(lpwstr, nPlateSize, bEos); - bPreIsCR = ReplaceParagEnd(lpwstr, nRead, bPreIsCR); - m_pTxtBuf->Insert(nIndex, lpwstr, nRead); - nIndex += nRead; - } - FX_Free(lpwstr); - } - } - m_pTxtBuf->Insert(nIndex, &m_wLineEnd, 1); - RebuildParagraphs(); -} -void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) { - ResetEngine(); - int32_t nLength = wsText.GetLength(); - if (nLength > 0) { - CFX_WideString wsTemp; - FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength); - FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR)); - ReplaceParagEnd(lpBuffer, nLength, FALSE); - wsTemp.ReleaseBuffer(nLength); - if (m_nLimit > 0 && nLength > m_nLimit) { - wsTemp.Delete(m_nLimit, nLength - m_nLimit); - nLength = m_nLimit; - } - m_pTxtBuf->SetText(wsTemp); - } - m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1); - RebuildParagraphs(); -} -int32_t CFDE_TxtEdtEngine::GetTextLength() const { - return GetTextBufLength(); -} -void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount) { - int32_t nTextBufLength = GetTextBufLength(); - if (nCount == -1) { - nCount = nTextBufLength - nStart; - } - m_pTxtBuf->GetRange(wsText, nStart, nCount); - RecoverParagEnd(wsText); -} - -void CFDE_TxtEdtEngine::ClearText() { - DeleteRange(0, -1); -} -int32_t CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret) const { - rtCaret = m_rtCaret; - return m_nCaret; -} -int32_t CFDE_TxtEdtEngine::GetCaretPos() const { - if (IsLocked()) { - return 0; - } - return m_nCaret + (m_bBefore ? 0 : 1); -} -int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { - if (IsLocked()) { - return 0; - } - FXSYS_assert(nIndex >= 0 && nIndex <= GetTextBufLength()); - if (m_PagePtrArray.GetSize() <= m_nCaretPage) { - return 0; - } - m_bBefore = bBefore; - m_nCaret = nIndex; - MovePage2Char(m_nCaret); - GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); - if (!m_bBefore) { - m_nCaret++; - m_bBefore = TRUE; - } - m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) - ? m_rtCaret.top - : m_rtCaret.left; - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); - m_nAnchorPos = -1; - return m_nCaret; -} -int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, - FX_BOOL bShift, - FX_BOOL bCtrl) { - if (IsLocked()) { - return 0; - } - if (m_PagePtrArray.GetSize() <= m_nCaretPage) { - return 0; - } - FX_BOOL bSelChange = FALSE; - if (IsSelect()) { - ClearSelection(); - bSelChange = TRUE; - } - if (bShift) { - if (m_nAnchorPos == -1) { - m_nAnchorPos = m_nCaret; - } - } else { - m_nAnchorPos = -1; - } - FX_BOOL bVertical = m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; - switch (eMoveCaret) { - case MC_Left: { - if (bVertical) { - CFX_PointF ptCaret; - if (MoveUp(ptCaret)) { - UpdateCaretIndex(ptCaret); - } - } else { - FX_BOOL bBefore = TRUE; - int32_t nIndex = MoveBackward(bBefore); - if (nIndex >= 0) { - UpdateCaretRect(nIndex, bBefore); - } - } - } break; - case MC_Right: { - if (bVertical) { - CFX_PointF ptCaret; - if (MoveDown(ptCaret)) { - UpdateCaretIndex(ptCaret); - } - } else { - FX_BOOL bBefore = TRUE; - int32_t nIndex = MoveForward(bBefore); - if (nIndex >= 0) { - UpdateCaretRect(nIndex, bBefore); - } - } - } break; - case MC_Up: { - if (bVertical) { - FX_BOOL bBefore = TRUE; - int32_t nIndex = MoveBackward(bBefore); - if (nIndex >= 0) { - UpdateCaretRect(nIndex, bBefore); - } - } else { - CFX_PointF ptCaret; - if (MoveUp(ptCaret)) { - UpdateCaretIndex(ptCaret); - } - } - } break; - case MC_Down: { - if (bVertical) { - FX_BOOL bBefore = TRUE; - int32_t nIndex = MoveForward(bBefore); - if (nIndex >= 0) { - UpdateCaretRect(nIndex, bBefore); - } - } else { - CFX_PointF ptCaret; - if (MoveDown(ptCaret)) { - UpdateCaretIndex(ptCaret); - } - } - } break; - case MC_WordBackward: - break; - case MC_WordForward: - break; - case MC_LineStart: - MoveLineStart(); - break; - case MC_LineEnd: - MoveLineEnd(); - break; - case MC_ParagStart: - MoveParagStart(); - break; - case MC_ParagEnd: - MoveParagEnd(); - break; - case MC_PageDown: - break; - case MC_PageUp: - break; - case MC_Home: - MoveHome(); - break; - case MC_End: - MoveEnd(); - break; - default: - break; - } - if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { - AddSelRange(std::min(m_nAnchorPos, m_nCaret), - FXSYS_abs(m_nAnchorPos - m_nCaret)); - m_Param.pEventSink->On_SelChanged(this); - } - if (bSelChange) { - m_Param.pEventSink->On_SelChanged(this); - } - return m_nCaret; -} -void CFDE_TxtEdtEngine::Lock() { - m_bLock = TRUE; -} -void CFDE_TxtEdtEngine::Unlock() { - m_bLock = FALSE; -} -FX_BOOL CFDE_TxtEdtEngine::IsLocked() const { - return m_bLock; -} -int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLength) { - if (IsLocked()) { - return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - CFX_WideString wsTemp; - FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength); - FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR)); - ReplaceParagEnd(lpBuffer, nLength, FALSE); - wsTemp.ReleaseBuffer(nLength); - FX_BOOL bPart = FALSE; - if (m_nLimit > 0) { - 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); - nTotalLength -= lpSelRange->nCount; - } - int32_t nExpectLength = nTotalLength + nLength; - if (nTotalLength == m_nLimit) { - return FDE_TXTEDT_MODIFY_RET_F_Full; - } - if (nExpectLength > m_nLimit) { - nLength -= (nExpectLength - m_nLimit); - bPart = TRUE; - } - } - if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) || - (m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) { - int32_t nTemp = nLength; - if (m_Param.dwMode & FDE_TEXTEDITMODE_Password) { - CFX_WideString wsText; - while (nLength > 0) { - GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); - int32_t nTotal = wsText.GetLength(); - FX_WCHAR* lpBuf = wsText.GetBuffer(nTotal); - for (int32_t i = 0; i < nTotal; i++) { - lpBuf[i] = m_wcAliasChar; - } - wsText.ReleaseBuffer(nTotal); - if (IsFitArea(wsText)) { - break; - } - nLength--; - } - } else { - CFX_WideString wsText; - while (nLength > 0) { - GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); - if (IsFitArea(wsText)) { - break; - } - nLength--; - } - } - if (nLength == 0) { - return FDE_TXTEDT_MODIFY_RET_F_Full; - } - if (nLength < nTemp) { - bPart = TRUE; - } - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { - CFX_WideString wsText; - GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { - return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } - } - if (IsSelect()) { - DeleteSelect(); - } - if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { - IFDE_TxtEdtDoRecord* pRecord = - new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength); - CFX_ByteString bsDoRecord; - pRecord->Serialize(bsDoRecord); - m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); - pRecord->Release(); - } - GetText(m_ChangeInfo.wsPrevText, 0); - Inner_Insert(m_nCaret, lpBuffer, nLength); - m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; - m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength); - nStart = m_nCaret; - nStart += nLength; - FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); - FX_BOOL bBefore = TRUE; - if (wChar != L'\n' && wChar != L'\r') { - nStart--; - bBefore = FALSE; - } - SetCaretPos(nStart, bBefore); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal; -} -int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) { - if (IsLocked()) { - return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - if (IsSelect()) { - DeleteSelect(); - return FDE_TXTEDT_MODIFY_RET_S_Normal; - } - - int32_t nCount = 1; - if (bBackspace) { - if (nStart == 0) { - return FDE_TXTEDT_MODIFY_RET_F_Boundary; - } - if (nStart > 2 && m_pTxtBuf->GetCharByIndex(nStart - 1) == L'\n' && - m_pTxtBuf->GetCharByIndex(nStart - 2) == L'\r') { - nStart--; - nCount++; - } - nStart--; - } else { - if (nStart == GetTextBufLength()) { - return FDE_TXTEDT_MODIFY_RET_F_Full; - } - if ((nStart + 1 < GetTextBufLength()) && - (m_pTxtBuf->GetCharByIndex(nStart) == L'\r') && - (m_pTxtBuf->GetCharByIndex(nStart + 1) == L'\n')) { - nCount++; - } - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { - CFX_WideString wsText; - GetPreDeleteText(wsText, nStart, nCount); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { - return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } - } - if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { - CFX_WideString wsRange; - m_pTxtBuf->GetRange(wsRange, nStart, nCount); - IFDE_TxtEdtDoRecord* pRecord = - new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange); - CFX_ByteString bsDoRecord; - pRecord->Serialize(bsDoRecord); - m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); - pRecord->Release(); - } - m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; - GetText(m_ChangeInfo.wsDelete, nStart, nCount); - Inner_DeleteRange(nStart, nCount); - SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0), - (bBackspace || nStart == 0)); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - return FDE_TXTEDT_MODIFY_RET_S_Normal; -} -int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) { - if (IsLocked()) { - return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - if (nCount == -1) { - nCount = GetTextBufLength(); - } - if (nCount == 0) { - return FDE_TXTEDT_MODIFY_RET_S_Normal; - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { - CFX_WideString wsText; - GetPreDeleteText(wsText, nStart, nCount); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { - return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } - } - DeleteRange_DoRecord(nStart, nCount); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - SetCaretPos(nStart, TRUE); - return FDE_TXTEDT_MODIFY_RET_S_Normal; -} -int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart, - int32_t nLength, - const CFX_WideString& wsReplace) { - if (IsLocked()) { - return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - if (nStart < 0 || (nStart + nLength > GetTextBufLength())) { - return FDE_TXTEDT_MODIFY_RET_F_Boundary; - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { - CFX_WideString wsText; - GetPreReplaceText(wsText, nStart, nLength, wsReplace.c_str(), - wsReplace.GetLength()); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { - return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } - } - if (IsSelect()) { - ClearSelection(); - } - m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace; - GetText(m_ChangeInfo.wsDelete, nStart, nLength); - if (nLength > 0) { - Inner_DeleteRange(nStart, nLength); - } - int32_t nTextLength = wsReplace.GetLength(); - if (nTextLength > 0) { - Inner_Insert(nStart, wsReplace.c_str(), nTextLength); - } - m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength); - nStart += nTextLength; - FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); - FX_BOOL bBefore = TRUE; - if (wChar != L'\n' && wChar != L'\r') { - nStart--; - bBefore = FALSE; - } - SetCaretPos(nStart, bBefore); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - return FDE_TXTEDT_MODIFY_RET_S_Normal; -} -void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) { - m_nLimit = nLimit; -} -void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) { - m_wcAliasChar = wcAlias; -} - -void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) { - FDE_LPTXTEDTSELRANGE lpTemp = NULL; - int32_t nRangeCount = m_SelRangePtrArr.GetSize(); - int32_t i = 0; - for (i = 0; i < nRangeCount; i++) { - lpTemp = m_SelRangePtrArr[i]; - if (lpTemp->nStart == nStart && lpTemp->nCount == nCount) { - delete lpTemp; - m_SelRangePtrArr.RemoveAt(i); - return; - } - } -} - -void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { - if (nCount == -1) { - nCount = GetTextLength() - nStart; - } - int32_t nSize = m_SelRangePtrArr.GetSize(); - if (nSize <= 0) { - FDE_LPTXTEDTSELRANGE 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; - lpTemp = m_SelRangePtrArr[nSize - 1]; - if (nStart >= lpTemp->nStart + lpTemp->nCount) { - FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; - lpSelRange->nStart = nStart; - lpSelRange->nCount = nCount; - m_SelRangePtrArr.Add(lpSelRange); - m_Param.pEventSink->On_SelChanged(this); - return; - } - int32_t nEnd = nStart + nCount - 1; - FX_BOOL bBegin = FALSE; - int32_t nRangeBgn = 0; - int32_t nRangeCnt = 0; - for (int32_t i = 0; i < nSize; i++) { - lpTemp = m_SelRangePtrArr[i]; - int32_t nTempBgn = lpTemp->nStart; - int32_t nTempEnd = nTempBgn + lpTemp->nCount - 1; - if (bBegin) { - if (nEnd < nTempBgn) { - break; - } else if (nStart >= nTempBgn && nStart <= nTempEnd) { - nRangeCnt++; - break; - } - nRangeCnt++; - } else { - if (nStart <= nTempEnd) { - nRangeBgn = i; - if (nEnd < nTempBgn) { - break; - } - nRangeCnt = 1; - bBegin = TRUE; - } - } - } - if (nRangeCnt == 0) { - FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; - lpSelRange->nStart = nStart; - lpSelRange->nCount = nCount; - m_SelRangePtrArr.InsertAt(nRangeBgn, lpSelRange); - } else { - lpTemp = m_SelRangePtrArr[nRangeBgn]; - lpTemp->nStart = nStart; - lpTemp->nCount = nCount; - nRangeCnt--; - nRangeBgn++; - while (nRangeCnt--) { - delete m_SelRangePtrArr[nRangeBgn]; - m_SelRangePtrArr.RemoveAt(nRangeBgn); - } - } - m_Param.pEventSink->On_SelChanged(this); -} - -int32_t CFDE_TxtEdtEngine::CountSelRanges() { - return m_SelRangePtrArr.GetSize(); -} -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; - } - } - m_SelRangePtrArr.RemoveAll(); - if (nCount && m_Param.pEventSink) { - m_Param.pEventSink->On_SelChanged(this); - } -} -FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) { - if (IsLocked()) { - return FALSE; - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) { - return FALSE; - } - IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsRedo); - FXSYS_assert(pDoRecord); - if (pDoRecord == NULL) { - return FALSE; - } - FX_BOOL bOK = pDoRecord->Redo(); - pDoRecord->Release(); - return bOK; -} -FX_BOOL CFDE_TxtEdtEngine::Undo(const CFX_ByteStringC& bsUndo) { - if (IsLocked()) { - return FALSE; - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) { - return FALSE; - } - IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsUndo); - FXSYS_assert(pDoRecord); - if (pDoRecord == NULL) { - return FALSE; - } - FX_BOOL bOK = pDoRecord->Undo(); - pDoRecord->Release(); - return bOK; -} -int32_t CFDE_TxtEdtEngine::StartLayout() { - Lock(); - RemoveAllPages(); - m_nLayoutPos = 0; - m_nLineCount = 0; - return 0; -} -int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) { - int32_t nCount = m_ParagPtrArray.GetSize(); - CFDE_TxtEdtParag* pParag = NULL; - int32_t nLineCount = 0; - for (; m_nLayoutPos < nCount; m_nLayoutPos++) { - pParag = m_ParagPtrArray[m_nLayoutPos]; - pParag->CalcLines(); - nLineCount += pParag->m_nLineCount; - if ((pPause != NULL) && (nLineCount > m_nPageLineCount) && - pPause->NeedToPauseNow()) { - m_nLineCount += nLineCount; - return (++m_nLayoutPos * 100) / nCount; - } - } - m_nLineCount += nLineCount; - return 100; -} -void CFDE_TxtEdtEngine::EndLayout() { - UpdatePages(); - int32_t nLength = GetTextLength(); - if (m_nCaret > nLength) { - m_nCaret = nLength; - } - int32_t nIndex = m_nCaret; - if (!m_bBefore) { - nIndex--; - } - m_rtCaret.Set(0, 0, 1, m_Param.fFontSize); - Unlock(); -} -FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) { - return m_pTxtBuf->Optimize(pPause); -} -IFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const { - return (IFDE_TxtEdtBuf*)m_pTxtBuf; -} -int32_t CFDE_TxtEdtEngine::GetTextBufLength() const { - return m_pTxtBuf->GetTextLength() - 1; -} -IFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const { - return m_pTextBreak; -} -int32_t CFDE_TxtEdtEngine::GetLineCount() const { - return m_nLineCount; -} -int32_t CFDE_TxtEdtEngine::GetPageLineCount() const { - return m_nPageLineCount; -} -int32_t CFDE_TxtEdtEngine::CountParags() const { - return m_ParagPtrArray.GetSize(); -} -IFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const { - return m_ParagPtrArray[nParagIndex]; -} -IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() { - if (!m_pTxtBuf) { - return NULL; - } - return new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf); -} -int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag, - int32_t nStartLineofParag, - int32_t nLineIndex, - int32_t& nStartLine) const { - int32_t nLineTotal = nStartLineofParag; - int32_t nCount = m_ParagPtrArray.GetSize(); - CFDE_TxtEdtParag* pParag = NULL; - int32_t i = nStartParag; - for (; i < nCount; i++) { - pParag = m_ParagPtrArray[i]; - nLineTotal += pParag->m_nLineCount; - if (nLineTotal > nLineIndex) { - break; - } - } - nStartLine = nLineTotal - pParag->m_nLineCount; - return i; -} -void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText, - int32_t nIndex, - int32_t nLength) { - GetText(wsText, 0, GetTextBufLength()); - wsText.Delete(nIndex, nLength); -} -void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText, - int32_t nIndex, - const FX_WCHAR* lpText, - int32_t nLength) { - GetText(wsText, 0, GetTextBufLength()); - int32_t nSelIndex = 0; - int32_t nSelLength = 0; - int32_t nSelCount = CountSelRanges(); - while (nSelCount--) { - nSelLength = GetSelRange(nSelCount, nSelIndex); - wsText.Delete(nSelIndex, nSelLength); - nIndex = nSelIndex; - } - CFX_WideString wsTemp; - int32_t nOldLength = wsText.GetLength(); - const FX_WCHAR* pOldBuffer = wsText.c_str(); - FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength); - FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR)); - FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR)); - FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex, - (nOldLength - nIndex) * sizeof(FX_WCHAR)); - wsTemp.ReleaseBuffer(nOldLength + nLength); - wsText = wsTemp; -} -void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText, - int32_t nIndex, - int32_t nOriginLength, - const FX_WCHAR* lpText, - int32_t nLength) { - GetText(wsText, 0, GetTextBufLength()); - int32_t nSelIndex = 0; - int32_t nSelLength = 0; - int32_t nSelCount = CountSelRanges(); - while (nSelCount--) { - nSelLength = GetSelRange(nSelCount, nSelIndex); - wsText.Delete(nSelIndex, nSelLength); - } - wsText.Delete(nIndex, nOriginLength); - int32_t i = 0; - for (i = 0; i < nLength; i++) { - wsText.Insert(nIndex++, lpText[i]); - } -} -void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLength) { - FXSYS_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; - } - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - int32_t nReserveLineCount = pParag->m_nLineCount; - int32_t nReserveCharStart = pParag->m_nCharStart; - int32_t nLeavePart = ParagPos.nCharIndex; - int32_t nCutPart = pParag->m_nCharCount - ParagPos.nCharIndex; - int32_t nTextStart = 0; - FX_WCHAR wCurChar = L' '; - const FX_WCHAR* lpPos = lpText; - FX_BOOL bFirst = TRUE; - int32_t nParagIndex = ParagPos.nParagIndex; - for (i = 0; i < nLength; i++, lpPos++) { - wCurChar = *lpPos; - if (wCurChar == m_wLineEnd) { - if (bFirst) { - pParag->m_nCharCount = nLeavePart + (i - nTextStart + 1); - pParag->m_nLineCount = -1; - nReserveCharStart += pParag->m_nCharCount; - bFirst = FALSE; - } else { - pParag = new CFDE_TxtEdtParag(this); - pParag->m_nLineCount = -1; - pParag->m_nCharCount = i - nTextStart + 1; - pParag->m_nCharStart = nReserveCharStart; - m_ParagPtrArray.InsertAt(++nParagIndex, pParag); - nReserveCharStart += pParag->m_nCharCount; - } - nTextStart = i + 1; - } - } - if (bFirst) { - pParag->m_nCharCount += nLength; - pParag->m_nLineCount = -1; - bFirst = FALSE; - } else { - pParag = new CFDE_TxtEdtParag(this); - pParag->m_nLineCount = -1; - pParag->m_nCharCount = nLength - nTextStart + nCutPart; - pParag->m_nCharStart = nReserveCharStart; - m_ParagPtrArray.InsertAt(++nParagIndex, pParag); - } - m_pTxtBuf->Insert(nStart, lpText, nLength); - int32_t nTotalLineCount = 0; - for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) { - pParag = m_ParagPtrArray[i]; - pParag->CalcLines(); - nTotalLineCount += pParag->m_nLineCount; - } - m_nLineCount += nTotalLineCount - nReserveLineCount; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); - UpdatePages(); -} - -void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { - if (nCount == -1) { - nCount = m_pTxtBuf->GetTextLength() - nStart; - } - int32_t nEnd = nStart + nCount - 1; - FXSYS_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.nParagIndex < m_ParagPtrArray.GetSize() - 1) { - ParagPosEnd.nParagIndex++; - } else { - bLastParag = TRUE; - } - } - int32_t nTotalLineCount = 0; - int32_t nTotalCharCount = 0; - int32_t i = 0; - for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) { - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i]; - pParag->CalcLines(); - nTotalLineCount += pParag->m_nLineCount; - nTotalCharCount += pParag->m_nCharCount; - } - 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; - m_ParagPtrArray.RemoveAt(nNextParagIndex); - } - if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) { - pParag = m_ParagPtrArray[ParagPosBgn.nParagIndex]; - pParag->m_nCharCount = nTotalCharCount - nCount; - pParag->CalcLines(); - nTotalLineCount -= pParag->m_nLineCount; - } - int32_t nParagCount = m_ParagPtrArray.GetSize(); - for (i = nNextParagIndex; i < nParagCount; i++) { - m_ParagPtrArray[i]->m_nCharStart -= nCount; - } - m_nLineCount -= nTotalLineCount; - UpdatePages(); - int32_t nPageCount = CountPages(); - if (m_nCaretPage >= nPageCount) { - m_nCaretPage = nPageCount - 1; - } - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); -} -void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart, - int32_t nCount, - FX_BOOL bSel) { - FXSYS_assert(nStart >= 0); - if (nCount == -1) { - nCount = GetTextLength() - nStart; - } - FXSYS_assert((nStart + nCount) <= m_pTxtBuf->GetTextLength()); - - if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { - CFX_WideString wsRange; - m_pTxtBuf->GetRange(wsRange, nStart, nCount); - IFDE_TxtEdtDoRecord* pRecord = new CFDE_TxtEdtDoRecord_DeleteRange( - this, nStart, m_nCaret, wsRange, bSel); - CFX_ByteString bsDoRecord; - pRecord->Serialize(bsDoRecord); - m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord); - pRecord->Release(); - } - m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; - GetText(m_ChangeInfo.wsDelete, nStart, nCount); - Inner_DeleteRange(nStart, nCount); -} -void CFDE_TxtEdtEngine::ResetEngine() { - RemoveAllPages(); - RemoveAllParags(); - ClearSelection(); - m_nCaret = 0; - m_pTxtBuf->Clear(FALSE); - m_nCaret = 0; -} -void CFDE_TxtEdtEngine::RebuildParagraphs() { - RemoveAllParags(); - FX_WCHAR wChar = L' '; - int32_t nParagStart = 0; - int32_t nIndex = 0; - IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((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; - 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; - } - } - m_ParagPtrArray.RemoveAll(); -} -void CFDE_TxtEdtEngine::RemoveAllPages() { - int32_t nCount = m_PagePtrArray.GetSize(); - int32_t i = 0; - for (i = 0; i < nCount; i++) { - IFDE_TxtEdtPage* pPage = m_PagePtrArray[i]; - if (pPage) { - pPage->Release(); - } - } - m_PagePtrArray.RemoveAll(); -} -void CFDE_TxtEdtEngine::UpdateParags() { - int32_t nCount = m_ParagPtrArray.GetSize(); - if (nCount == 0) { - return; - } - CFDE_TxtEdtParag* pParag = NULL; - int32_t nLineCount = 0; - int32_t i = 0; - for (i = 0; i < nCount; i++) { - pParag = m_ParagPtrArray[i]; - if (pParag->m_nLineCount == -1) { - pParag->CalcLines(); - } - nLineCount += pParag->m_nLineCount; - } - m_nLineCount = nLineCount; -} -void CFDE_TxtEdtEngine::UpdatePages() { - if (m_nLineCount == 0) { - return; - } - int32_t nPageCount = (m_nLineCount - 1) / (m_nPageLineCount) + 1; - int32_t nSize = m_PagePtrArray.GetSize(); - if (nSize == nPageCount) { - return; - } - if (nSize > nPageCount) { - IFDE_TxtEdtPage* pPage = NULL; - int32_t i = 0; - for (i = nSize - 1; i >= nPageCount; i--) { - pPage = m_PagePtrArray[i]; - if (pPage) { - pPage->Release(); - } - m_PagePtrArray.RemoveAt(i); - } - m_Param.pEventSink->On_PageCountChanged(this); - return; - } - if (nSize < nPageCount) { - IFDE_TxtEdtPage* pPage = NULL; - int32_t i = 0; - for (i = nSize; i < nPageCount; i++) { - pPage = IFDE_TxtEdtPage::Create(this, i); - m_PagePtrArray.Add(pPage); - } - m_Param.pEventSink->On_PageCountChanged(this); - return; - } -} -void CFDE_TxtEdtEngine::UpdateTxtBreak() { - FX_DWORD dwStyle = m_pTextBreak->GetLayoutStyles(); - if (m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines) { - dwStyle &= ~FX_TXTLAYOUTSTYLE_SingleLine; - } else { - dwStyle |= FX_TXTLAYOUTSTYLE_SingleLine; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - dwStyle |= FX_TXTLAYOUTSTYLE_VerticalLayout; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalLayout; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve) { - dwStyle |= FX_TXTLAYOUTSTYLE_ReverseLine; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_ReverseLine; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_RTL) { - dwStyle |= FX_TXTLAYOUTSTYLE_RTLReadingOrder; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_RTLReadingOrder; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) { - dwStyle |= FX_TXTLAYOUTSTYLE_CombText; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_CombText; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CharVertial) { - dwStyle |= FX_TXTLAYOUTSTYLE_VerticalChars; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_VerticalChars; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ExpandTab) { - dwStyle |= FX_TXTLAYOUTSTYLE_ExpandTab; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_ExpandTab; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ArabicContext) { - dwStyle |= FX_TXTLAYOUTSTYLE_ArabicContext; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_ArabicContext; - } - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_ArabicShapes) { - dwStyle |= FX_TXTLAYOUTSTYLE_ArabicShapes; - } else { - dwStyle &= ~FX_TXTLAYOUTSTYLE_ArabicShapes; - } - m_pTextBreak->SetLayoutStyles(dwStyle); - FX_DWORD dwAligment = 0; - if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Justified) { - dwAligment |= FX_TXTLINEALIGNMENT_Justified; - } else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Distributed) { - dwAligment |= FX_TXTLINEALIGNMENT_Distributed; - } - if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Center) { - dwAligment |= FX_TXTLINEALIGNMENT_Center; - } else if (m_Param.dwAlignment & FDE_TEXTEDITALIGN_Right) { - dwAligment |= FX_TXTLINEALIGNMENT_Right; - } - m_pTextBreak->SetAlignment(dwAligment); - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { - m_pTextBreak->SetLineWidth(m_Param.fPlateHeight); - } else { - m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX); - } - } else { - if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { - m_pTextBreak->SetLineWidth(m_Param.fPlateWidth); - } else { - m_pTextBreak->SetLineWidth(FDE_PAGEWIDTH_MAX); - } - } - m_nPageLineCount = m_Param.nLineCount; - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) { - FX_FLOAT fCombWidth = - m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical - ? m_Param.fPlateHeight - : m_Param.fPlateWidth; - if (m_nLimit > 0) { - fCombWidth /= m_nLimit; - } - m_pTextBreak->SetCombWidth(fCombWidth); - } - m_pTextBreak->SetFont(m_Param.pFont); - m_pTextBreak->SetFontSize(m_Param.fFontSize); - m_pTextBreak->SetTabWidth(m_Param.fTabWidth, m_Param.bTabEquidistant); - m_pTextBreak->SetDefaultChar(m_Param.wDefChar); - m_pTextBreak->SetParagraphBreakChar(m_Param.wLineBreakChar); - m_pTextBreak->SetCharRotation(m_Param.nCharRotation); - m_pTextBreak->SetLineBreakTolerance(m_Param.fFontSize * 0.2f); - m_pTextBreak->SetHorizontalScale(m_Param.nHorzScale); - m_pTextBreak->SetCharSpace(m_Param.fCharSpace); -} -FX_BOOL CFDE_TxtEdtEngine::ReplaceParagEnd(FX_WCHAR*& lpText, - int32_t& nLength, - FX_BOOL bPreIsCR) { - for (int32_t i = 0; i < nLength; i++) { - FX_WCHAR wc = lpText[i]; - switch (wc) { - case L'\r': { - lpText[i] = m_wLineEnd; - bPreIsCR = TRUE; - } break; - case L'\n': { - if (bPreIsCR == TRUE) { - int32_t nNext = i + 1; - if (nNext < nLength) { - FXSYS_memmove(lpText + i, lpText + nNext, - (nLength - nNext) * sizeof(FX_WCHAR)); - } - i--; - nLength--; - bPreIsCR = FALSE; - if (m_bAutoLineEnd) { - m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_CRLF; - m_bAutoLineEnd = FALSE; - } - } else { - lpText[i] = m_wLineEnd; - if (m_bAutoLineEnd) { - m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_LF; - m_bAutoLineEnd = FALSE; - } - } - } break; - default: { - if (bPreIsCR && m_bAutoLineEnd) { - m_nFirstLineEnd = FDE_TXTEDIT_LINEEND_CR; - m_bAutoLineEnd = FALSE; - } - bPreIsCR = FALSE; - } break; - } - } - return bPreIsCR; -} -void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) { - FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r'; - if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) { - CFX_ArrayTemplate<int32_t> PosArr; - int32_t nLength = wsText.GetLength(); - int32_t i = 0; - FX_WCHAR* lpPos = (FX_WCHAR*)(const FX_WCHAR*)wsText; - for (i = 0; i < nLength; i++, lpPos++) { - if (*lpPos == m_wLineEnd) { - *lpPos = wc; - PosArr.Add(i); - } - } - const FX_WCHAR* lpSrcBuf = wsText.c_str(); - CFX_WideString wsTemp; - int32_t nCount = PosArr.GetSize(); - FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount); - int32_t nDstPos = 0; - int32_t nSrcPos = 0; - for (i = 0; i < nCount; i++) { - int32_t nPos = PosArr[i]; - int32_t nCopyLen = nPos - nSrcPos + 1; - FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, - nCopyLen * sizeof(FX_WCHAR)); - nDstPos += nCopyLen; - nSrcPos += nCopyLen; - lpDstBuf[nDstPos] = L'\n'; - nDstPos++; - } - if (nSrcPos < nLength) { - FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos, - (nLength - nSrcPos) * sizeof(FX_WCHAR)); - } - wsTemp.ReleaseBuffer(nLength + nCount); - wsText = wsTemp; - } else { - int32_t nLength = wsText.GetLength(); - FX_WCHAR* lpBuf = (FX_WCHAR*)(const FX_WCHAR*)wsText; - for (int32_t i = 0; i < nLength; i++, lpBuf++) { - if (*lpBuf == m_wLineEnd) { - *lpBuf = wc; - } - } - } -} -int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { - FXSYS_assert(nIndex >= 0); - FXSYS_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); - int32_t nPageCharStart = pPage->GetCharStart(); - int32_t nPageCharCount = pPage->GetCharCount(); - if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) { - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); - return m_nCaretPage; - } - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); - } - CFDE_TxtEdtParag* pParag = NULL; - int32_t nLineCount = 0; - int32_t nParagCount = m_ParagPtrArray.GetSize(); - 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)) { - break; - } - nLineCount += pParag->m_nLineCount; - } - pParag->LoadParag(); - int32_t nLineStart = -1; - int32_t nLineCharCount = -1; - for (i = 0; i < pParag->m_nLineCount; i++) { - pParag->GetLineRange(i, nLineStart, nLineCharCount); - if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount)) { - break; - } - } - FXSYS_assert(i < pParag->m_nLineCount); - 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()); - int32_t nCount = m_ParagPtrArray.GetSize(); - int32_t nBgn = 0; - int32_t nMid = 0; - int32_t nEnd = nCount - 1; - while (nEnd > nBgn) { - nMid = (nBgn + nEnd) / 2; - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nMid]; - if (nIndex < pParag->m_nCharStart) { - nEnd = nMid - 1; - } else if (nIndex >= (pParag->m_nCharStart + pParag->m_nCharCount)) { - nBgn = nMid + 1; - } else { - break; - } - } - if (nBgn == nEnd) { - nMid = nBgn; - } - FXSYS_assert(nIndex >= m_ParagPtrArray[nMid]->m_nCharStart && - (nIndex < m_ParagPtrArray[nMid]->m_nCharStart + - m_ParagPtrArray[nMid]->m_nCharCount)); - ParagPos.nParagIndex = nMid; - ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->m_nCharStart; -} -int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) { - if (m_nCaret == m_pTxtBuf->GetTextLength() - 1) { - return -1; - } - int32_t nCaret = m_nCaret; - if ((nCaret + 1 < m_pTxtBuf->GetTextLength()) && - (m_pTxtBuf->GetCharByIndex(nCaret) == L'\r') && - (m_pTxtBuf->GetCharByIndex(nCaret + 1) == L'\n')) { - nCaret++; - } - nCaret++; - bBefore = TRUE; - return nCaret; -} -int32_t CFDE_TxtEdtEngine::MoveBackward(FX_BOOL& bBefore) { - if (m_nCaret == 0) { - return FALSE; - } - int32_t nCaret = m_nCaret; - if (nCaret > 2 && m_pTxtBuf->GetCharByIndex(nCaret - 1) == L'\n' && - m_pTxtBuf->GetCharByIndex(nCaret - 2) == L'\r') { - nCaret--; - } - nCaret--; - bBefore = TRUE; - return nCaret; -} -FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) { - IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage); - const CFX_RectF& rtContent = pPage->GetContentsBox(); - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - ptCaret.x = m_rtCaret.left + m_rtCaret.width / 2 - m_Param.fLineSpace; - ptCaret.y = m_fCaretPosReserve; - FX_BOOL bLineReserve = - m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; - if (ptCaret.x < rtContent.left) { - if (bLineReserve) { - if (m_nCaretPage == CountPages() - 1) { - return FALSE; - } - } else { - if (m_nCaretPage == 0) { - return FALSE; - } - } - if (bLineReserve) { - m_nCaretPage++; - } 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(); - } - } else { - ptCaret.x = m_fCaretPosReserve; - ptCaret.y = m_rtCaret.top + m_rtCaret.height / 2 - m_Param.fLineSpace; - if (ptCaret.y < rtContent.top) { - if (m_nCaretPage == 0) { - return FALSE; - } - 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(); - } - } - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) { - IFDE_TxtEdtPage* pPage = GetPage(m_nCaretPage); - const CFX_RectF& rtContent = pPage->GetContentsBox(); - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - ptCaret.x = m_rtCaret.left + m_rtCaret.width / 2 + m_Param.fLineSpace; - ptCaret.y = m_fCaretPosReserve; - if (ptCaret.x >= rtContent.right()) { - FX_BOOL bLineReserve = - m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; - if (bLineReserve) { - if (m_nCaretPage == 0) { - return FALSE; - } - } else { - if (m_nCaretPage == CountPages() - 1) { - return FALSE; - } - } - if (bLineReserve) { - m_nCaretPage--; - } 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; - } - } else { - ptCaret.x = m_fCaretPosReserve; - ptCaret.y = m_rtCaret.top + m_rtCaret.height / 2 + m_Param.fLineSpace; - if (ptCaret.y >= rtContent.bottom()) { - if (m_nCaretPage == CountPages() - 1) { - return FALSE; - } - 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; - } - } - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() { - int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; - FDE_TXTEDTPARAGPOS ParagPos; - TextPos2ParagPos(nIndex, ParagPos); - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - pParag->LoadParag(); - int32_t nLineCount = pParag->m_nLineCount; - int32_t i = 0; - int32_t nStart = 0; - int32_t nCount = 0; - for (; i < nLineCount; i++) { - pParag->GetLineRange(i, nStart, nCount); - if (nIndex >= nStart && nIndex < nStart + nCount) { - break; - } - } - UpdateCaretRect(nStart, TRUE); - pParag->UnloadParag(); - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() { - int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; - FDE_TXTEDTPARAGPOS ParagPos; - TextPos2ParagPos(nIndex, ParagPos); - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - pParag->LoadParag(); - int32_t nLineCount = pParag->m_nLineCount; - int32_t i = 0; - int32_t nStart = 0; - int32_t nCount = 0; - for (; i < nLineCount; i++) { - pParag->GetLineRange(i, nStart, nCount); - if (nIndex >= nStart && nIndex < nStart + nCount) { - break; - } - } - nIndex = nStart + nCount - 1; - FXSYS_assert(nIndex <= GetTextBufLength()); - FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex); - FX_BOOL bBefore = FALSE; - if (nIndex <= GetTextBufLength()) { - if (wChar == L'\r') { - bBefore = TRUE; - } else if (wChar == L'\n' && nIndex > nStart) { - bBefore = TRUE; - nIndex--; - wChar = m_pTxtBuf->GetCharByIndex(nIndex); - if (wChar != L'\r') { - nIndex++; - } - } - } - UpdateCaretRect(nIndex, bBefore); - pParag->UnloadParag(); - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() { - int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; - FDE_TXTEDTPARAGPOS ParagPos; - TextPos2ParagPos(nIndex, ParagPos); - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - UpdateCaretRect(pParag->m_nCharStart, TRUE); - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() { - int32_t nIndex = m_bBefore ? m_nCaret : m_nCaret - 1; - FDE_TXTEDTPARAGPOS ParagPos; - TextPos2ParagPos(nIndex, ParagPos); - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - nIndex = pParag->m_nCharStart + pParag->m_nCharCount - 1; - FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex); - if (wChar == L'\n' && nIndex > 0) { - nIndex--; - wChar = m_pTxtBuf->GetCharByIndex(nIndex); - if (wChar != L'\r') { - nIndex++; - } - } - UpdateCaretRect(nIndex, TRUE); - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveHome() { - UpdateCaretRect(0, TRUE); - return TRUE; -} -FX_BOOL CFDE_TxtEdtEngine::MoveEnd() { - UpdateCaretRect(GetTextBufLength(), TRUE); - return TRUE; -} - -FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) { - IFDE_TextOut* pTextOut = IFDE_TextOut::Create(); - pTextOut->SetLineSpace(m_Param.fLineSpace); - pTextOut->SetFont(m_Param.pFont); - pTextOut->SetFontSize(m_Param.fFontSize); - CFX_RectF rcText; - FXSYS_memset(&rcText, 0, sizeof(rcText)); - FX_DWORD dwStyle = 0; - if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) { - dwStyle |= FDE_TTOSTYLE_SingleLine; - } - if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { - dwStyle |= FDE_TTOSTYLE_LineWrap; - rcText.width = m_Param.fPlateWidth; - } else { - rcText.width = 65535; - } - pTextOut->SetStyles(dwStyle); - wsText += L"\n"; - pTextOut->CalcLogicSize(wsText, wsText.GetLength(), rcText); - pTextOut->Release(); - wsText.Delete(wsText.GetLength() - 1); - if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) && - (rcText.width > m_Param.fPlateWidth)) { - return FALSE; - } - if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Vert) && - (rcText.height > m_Param.fLineSpace * m_Param.nLineCount)) { - return FALSE; - } - return TRUE; -} -void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore) { - MovePage2Char(nIndex); - GetCaretRect(m_rtCaret, m_nCaretPage, nIndex, bBefore); - m_nCaret = nIndex; - m_bBefore = bBefore; - if (!m_bBefore) { - m_nCaret++; - m_bBefore = TRUE; - } - m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) - ? m_rtCaret.top - : m_rtCaret.left; - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); -} -void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, - int32_t nPageIndex, - int32_t nCaret, - FX_BOOL bBefore) { - IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); - FX_BOOL bCombText = m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText; - int32_t nIndexInpage = nCaret - pPage->GetCharStart(); - if (bBefore && bCombText && nIndexInpage > 0) { - nIndexInpage--; - bBefore = FALSE; - } - int32_t nBIDILevel = pPage->GetCharRect(nIndexInpage, rtCaret, bCombText); - if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - if ((!FX_IsOdd(nBIDILevel) && !bBefore) || - (FX_IsOdd(nBIDILevel) && bBefore)) { - rtCaret.Offset(0, rtCaret.height - 1.0f); - } - if (rtCaret.height == 0 && rtCaret.top > 1.0f) { - rtCaret.top -= 1.0f; - } - rtCaret.height = 1.0f; - } else { - if ((!FX_IsOdd(nBIDILevel) && !bBefore) || - (FX_IsOdd(nBIDILevel) && bBefore)) { - rtCaret.Offset(rtCaret.width - 1.0f, 0); - } - if (rtCaret.width == 0 && rtCaret.left > 1.0f) { - rtCaret.left -= 1.0f; - } - rtCaret.width = 1.0f; - } - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); -} -void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) { - IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); - m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore); - GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); - if (!m_bBefore) { - m_nCaret++; - m_bBefore = TRUE; - } - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); -} -FX_BOOL CFDE_TxtEdtEngine::IsSelect() { - return m_SelRangePtrArr.GetSize() > 0; -} -void CFDE_TxtEdtEngine::DeleteSelect() { - int32_t nCountRange = CountSelRanges(); - if (nCountRange > 0) { - int32_t nSelStart; - int32_t nSelCount; - while (nCountRange > 0) { - nSelCount = GetSelRange(--nCountRange, nSelStart); - FDE_LPTXTEDTSELRANGE lpTemp = m_SelRangePtrArr[nCountRange]; - delete lpTemp; - m_SelRangePtrArr.RemoveAt(nCountRange); - DeleteRange_DoRecord(nSelStart, nSelCount, TRUE); - } - ClearSelection(); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - m_Param.pEventSink->On_SelChanged(this); - SetCaretPos(nSelStart, TRUE); - return; - } -} -IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create( - const CFX_ByteStringC& bsDoRecord) { - const FX_CHAR* lpBuf = bsDoRecord.GetCStr(); - int32_t nType = *((int32_t*)lpBuf); - switch (nType) { - 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 NULL; -} -CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( - const CFX_ByteStringC& bsDoRecord) { - Deserialize(bsDoRecord); -} -CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert( - CFDE_TxtEdtEngine* pEngine, - int32_t nCaret, - const FX_WCHAR* lpText, - int32_t nLength) - : m_pEngine(pEngine), m_nCaret(nCaret) { - FXSYS_assert(pEngine); - FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength); - FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR)); - m_wsInsert.ReleaseBuffer(); -} -CFDE_TxtEdtDoRecord_Insert::~CFDE_TxtEdtDoRecord_Insert() {} -void CFDE_TxtEdtDoRecord_Insert::Release() { - delete this; -} -FX_BOOL CFDE_TxtEdtDoRecord_Insert::Undo() { - if (m_pEngine->IsSelect()) { - m_pEngine->ClearSelection(); - } - m_pEngine->Inner_DeleteRange(m_nCaret, m_wsInsert.GetLength()); - FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; - m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; - m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); - m_pEngine->SetCaretPos(m_nCaret, TRUE); - return TRUE; -} -FX_BOOL CFDE_TxtEdtDoRecord_Insert::Redo() { - m_pEngine->Inner_Insert(m_nCaret, m_wsInsert.c_str(), m_wsInsert.GetLength()); - FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; - m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; - m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); - m_pEngine->SetCaretPos(m_nCaret, FALSE); - return TRUE; -} -void CFDE_TxtEdtDoRecord_Insert::Serialize(CFX_ByteString& bsDoRecord) const { - CFX_ArchiveSaver ArchiveSaver; - ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_INS); - ArchiveSaver << (int32_t)(uintptr_t)m_pEngine; - ArchiveSaver << m_nCaret; - ArchiveSaver << m_wsInsert; - int32_t nLength = ArchiveSaver.GetLength(); - const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); - FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); - FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); - bsDoRecord.ReleaseBuffer(nLength); -} -void CFDE_TxtEdtDoRecord_Insert::Deserialize( - const CFX_ByteStringC& bsDoRecord) { - CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(), - bsDoRecord.GetLength()); - int32_t nType = 0; - ArchiveLoader >> nType; - FXSYS_assert(nType == FDE_TXTEDT_DORECORD_INS); - int32_t nEngine = 0; - ArchiveLoader >> nEngine; - m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; - ArchiveLoader >> m_nCaret; - ArchiveLoader >> m_wsInsert; -} -CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange( - const CFX_ByteStringC& bsDoRecord) { - Deserialize(bsDoRecord); -} -CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange( - CFDE_TxtEdtEngine* pEngine, - int32_t nIndex, - int32_t nCaret, - const CFX_WideString& wsRange, - FX_BOOL bSel) - : m_pEngine(pEngine), - m_bSel(bSel), - m_nIndex(nIndex), - m_nCaret(nCaret), - m_wsRange(wsRange) { - FXSYS_assert(pEngine); -} -CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {} -void CFDE_TxtEdtDoRecord_DeleteRange::Release() { - delete this; -} -FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Undo() { - if (m_pEngine->IsSelect()) { - m_pEngine->ClearSelection(); - } - m_pEngine->Inner_Insert(m_nIndex, m_wsRange.c_str(), m_wsRange.GetLength()); - if (m_bSel) { - m_pEngine->AddSelRange(m_nIndex, m_wsRange.GetLength()); - } - FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; - m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; - m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); - m_pEngine->SetCaretPos(m_nCaret, TRUE); - return TRUE; -} -FX_BOOL CFDE_TxtEdtDoRecord_DeleteRange::Redo() { - m_pEngine->Inner_DeleteRange(m_nIndex, m_wsRange.GetLength()); - if (m_bSel) { - m_pEngine->RemoveSelRange(m_nIndex, m_wsRange.GetLength()); - } - FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; - m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; - m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); - m_pEngine->SetCaretPos(m_nIndex, TRUE); - return TRUE; -} -void CFDE_TxtEdtDoRecord_DeleteRange::Serialize( - CFX_ByteString& bsDoRecord) const { - CFX_ArchiveSaver ArchiveSaver; - ArchiveSaver << int32_t(FDE_TXTEDT_DORECORD_DEL); - ArchiveSaver << (int32_t)(uintptr_t)m_pEngine; - ArchiveSaver << (int32_t)m_bSel; - ArchiveSaver << m_nIndex; - ArchiveSaver << m_nCaret; - ArchiveSaver << m_wsRange; - int32_t nLength = ArchiveSaver.GetLength(); - const uint8_t* lpSrcBuf = ArchiveSaver.GetBuffer(); - FX_CHAR* lpDstBuf = bsDoRecord.GetBuffer(nLength); - FXSYS_memcpy(lpDstBuf, lpSrcBuf, nLength); - bsDoRecord.ReleaseBuffer(nLength); -} -void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize( - const CFX_ByteStringC& bsDoRecord) { - CFX_ArchiveLoader ArchiveLoader((const uint8_t*)bsDoRecord.GetCStr(), - bsDoRecord.GetLength()); - int32_t nType = 0; - ArchiveLoader >> nType; - FXSYS_assert(nType == FDE_TXTEDT_DORECORD_DEL); - int32_t nEngine = 0; - ArchiveLoader >> nEngine; - m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine; - int32_t iSel = 0; - ArchiveLoader >> iSel; - m_bSel = !!iSel; - ArchiveLoader >> m_nIndex; - ArchiveLoader >> m_nCaret; - ArchiveLoader >> m_wsRange; -} diff --git a/xfa/src/fee/fde_txtedtengine.h b/xfa/src/fee/fde_txtedtengine.h deleted file mode 100644 index ef1270f3d5..0000000000 --- a/xfa/src/fee/fde_txtedtengine.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 XFA_SRC_FEE_FDE_TXTEDTENGINE_H_ -#define XFA_SRC_FEE_FDE_TXTEDTENGINE_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" - -class IFX_TxtBreak; -class IFX_CharIter; -class CFDE_TxtEdtParag; -class CFDE_TxtEdtDoRecord_Insert; -class CFDE_TxtEdtDoRecord_DeleteRange; - -class IFDE_TxtEdtDoRecord { - public: - static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord); - virtual ~IFDE_TxtEdtDoRecord() {} - virtual void Release() = 0; - virtual FX_BOOL Redo() = 0; - virtual FX_BOOL Undo() = 0; - 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; - - 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 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(); - - virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo); - virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo); - - virtual int32_t StartLayout(); - virtual int32_t DoLayout(IFX_Pause* pPause); - virtual 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; - int32_t GetTextBufLength() const; - IFX_TxtBreak* GetTextBreak() const; - int32_t GetLineCount() const; - int32_t GetPageLineCount() const; - - int32_t Line2Parag(int32_t nStartParag, - int32_t nStartLineofParag, - int32_t nLineIndex, - int32_t& nStartLine) const; - FX_WCHAR GetAliasChar() const { return m_wcAliasChar; } - - protected: - virtual ~CFDE_TxtEdtEngine(); - - private: - void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); - void GetPreDeleteText(CFX_WideString& wsText, - int32_t nIndex, - int32_t nLength); - void GetPreInsertText(CFX_WideString& wsText, - int32_t nIndex, - const FX_WCHAR* lpText, - int32_t nLength); - void GetPreReplaceText(CFX_WideString& wsText, - int32_t nIndex, - int32_t nOriginLength, - const FX_WCHAR* lpText, - int32_t nLength); - - void Inner_DeleteRange(int32_t nStart, int32_t nCount = -1); - void DeleteRange_DoRecord(int32_t nStart, - int32_t nCount, - FX_BOOL bSel = FALSE); - void ResetEngine(); - void RebuildParagraphs(); - void RemoveAllParags(); - void RemoveAllPages(); - void UpdateParags(); - void UpdatePages(); - void UpdateTxtBreak(); - - FX_BOOL ReplaceParagEnd(FX_WCHAR*& lpText, - int32_t& nLength, - FX_BOOL bPreIsCR = FALSE); - void RecoverParagEnd(CFX_WideString& wsText); - int32_t MovePage2Char(int32_t nIndex); - void TextPos2ParagPos(int32_t nIndex, FDE_TXTEDTPARAGPOS& ParagPos) const; - int32_t MoveForward(FX_BOOL& bBefore); - int32_t MoveBackward(FX_BOOL& bBefore); - FX_BOOL MoveUp(CFX_PointF& ptCaret); - FX_BOOL MoveDown(CFX_PointF& ptCaret); - FX_BOOL MoveLineStart(); - FX_BOOL MoveLineEnd(); - FX_BOOL MoveParagStart(); - FX_BOOL MoveParagEnd(); - FX_BOOL MoveHome(); - FX_BOOL MoveEnd(); - FX_BOOL IsFitArea(CFX_WideString& wsText); - void UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore = TRUE); - void GetCaretRect(CFX_RectF& rtCaret, - int32_t nPageIndex, - int32_t nCaret, - FX_BOOL bBefore = TRUE); - void UpdateCaretIndex(const CFX_PointF& ptCaret); - - FX_BOOL IsSelect(); - void DeleteSelect(); - - IFDE_TxtEdtBuf* m_pTxtBuf; - IFX_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; - int32_t m_nPageLineCount; - int32_t m_nLineCount; - int32_t m_nAnchorPos; - int32_t m_nLayoutPos; - FX_FLOAT m_fCaretPosReserve; - int32_t m_nCaret; - FX_BOOL m_bBefore; - int32_t m_nCaretPage; - CFX_RectF m_rtCaret; - FX_DWORD m_dwFindFlags; - FX_BOOL m_bLock; - int32_t m_nLimit; - FX_WCHAR m_wcAliasChar; - int32_t m_nFirstLineEnd; - FX_BOOL m_bAutoLineEnd; - FX_WCHAR m_wLineEnd; - FDE_TXTEDT_TEXTCHANGE_INFO m_ChangeInfo; -}; - -class CFDE_TxtEdtDoRecord_Insert : public IFDE_TxtEdtDoRecord { - public: - CFDE_TxtEdtDoRecord_Insert(const CFX_ByteStringC& bsDoRecord); - CFDE_TxtEdtDoRecord_Insert(CFDE_TxtEdtEngine* pEngine, - int32_t nCaret, - const FX_WCHAR* lpText, - int32_t nLength); - virtual void Release(); - virtual FX_BOOL Undo(); - virtual FX_BOOL Redo(); - virtual void Serialize(CFX_ByteString& bsDoRecord) const; - - protected: - ~CFDE_TxtEdtDoRecord_Insert(); - void Deserialize(const CFX_ByteStringC& bsDoRecord); - - private: - CFDE_TxtEdtEngine* m_pEngine; - int32_t m_nCaret; - CFX_WideString m_wsInsert; -}; - -class CFDE_TxtEdtDoRecord_DeleteRange : public IFDE_TxtEdtDoRecord { - public: - CFDE_TxtEdtDoRecord_DeleteRange(const CFX_ByteStringC& bsDoRecord); - CFDE_TxtEdtDoRecord_DeleteRange(CFDE_TxtEdtEngine* pEngine, - int32_t nIndex, - int32_t nCaret, - const CFX_WideString& wsRange, - FX_BOOL bSel = FALSE); - virtual void Release(); - virtual FX_BOOL Undo(); - virtual FX_BOOL Redo(); - virtual void Serialize(CFX_ByteString& bsDoRecord) const; - - protected: - ~CFDE_TxtEdtDoRecord_DeleteRange(); - void Deserialize(const CFX_ByteStringC& bsDoRecord); - - private: - CFDE_TxtEdtEngine* m_pEngine; - FX_BOOL m_bSel; - int32_t m_nIndex; - int32_t m_nCaret; - CFX_WideString m_wsRange; -}; - -#endif // XFA_SRC_FEE_FDE_TXTEDTENGINE_H_ diff --git a/xfa/src/fee/fde_txtedtpage.cpp b/xfa/src/fee/fde_txtedtpage.cpp deleted file mode 100644 index 932832fd6f..0000000000 --- a/xfa/src/fee/fde_txtedtpage.cpp +++ /dev/null @@ -1,650 +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/src/fee/fde_txtedtpage.h" - -#include <algorithm> - -#include "xfa/src/fee/fx_wordbreak/fx_wordbreak.h" -#include "xfa/src/fee/fde_txtedtbuf.h" -#include "xfa/src/fee/fde_txtedtengine.h" -#include "xfa/src/fee/fde_txtedtparag.h" -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" -#include "xfa/src/fee/ifde_txtedtpage.h" - -#define FDE_TXTEDT_TOLERANCE 0.1f - -IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(IFDE_TxtEdtEngine* pEngine, - int32_t nIndex) { - return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex); -} -CFDE_TxtEdtTextSet::CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage) - : m_pPage(pPage) {} -CFDE_TxtEdtTextSet::~CFDE_TxtEdtTextSet() {} -FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() { - return FDE_VISUALOBJ_Text; -} -FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj, - CFX_RectF& bbox) { - return FALSE; -} -FX_BOOL CFDE_TxtEdtTextSet::GetMatrix(FDE_HVISUALOBJ hVisualObj, - CFX_Matrix& matrix) { - return FALSE; -} -FX_BOOL CFDE_TxtEdtTextSet::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { - rt = ((FDE_TEXTEDITPIECE*)(hVisualObj))->rtPiece; - return TRUE; -} -FX_BOOL CFDE_TxtEdtTextSet::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { - return FALSE; -} -int32_t CFDE_TxtEdtTextSet::GetString(FDE_HVISUALOBJ hText, - CFX_WideString& wsText) { - FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; - FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount); - for (int32_t i = 0; i < pPiece->nCount; i++) { - pBuffer[i] = m_pPage->GetChar((void*)hText, i); - } - wsText.ReleaseBuffer(pPiece->nCount); - return pPiece->nCount; -} -IFX_Font* CFDE_TxtEdtTextSet::GetFont(FDE_HVISUALOBJ hText) { - return m_pPage->GetEngine()->GetEditParams()->pFont; -} -FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize(FDE_HVISUALOBJ hText) { - return m_pPage->GetEngine()->GetEditParams()->fFontSize; -} -FX_ARGB CFDE_TxtEdtTextSet::GetFontColor(FDE_HVISUALOBJ hText) { - return m_pPage->GetEngine()->GetEditParams()->dwFontColor; -} -int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode, - CFX_WideString* pWSForms) { - if (hText == NULL) { - return 0; - } - FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; - int32_t nLength = pPiece->nCount; - if (nLength < 1) { - return 0; - } - CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); - const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); - IFX_TxtBreak* pBreak = pEngine->GetTextBreak(); - FX_DWORD 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; - tr.dwStyles = dwLayoutStyle; - tr.iCharRotation = pTextParams->nCharRotation; - tr.dwCharStyles = pPiece->dwCharStyles; - tr.pRect = &(pPiece->rtPiece); - tr.wLineBreakChar = pTextParams->wLineBreakChar; - return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms); -} -int32_t CFDE_TxtEdtTextSet::GetCharRects(FDE_HVISUALOBJ hText, - CFX_RectFArray& rtArray) { - return GetCharRects_Impl(hText, rtArray); -} -int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText, - CFX_RectFArray& rtArray, - FX_BOOL bBBox) { - if (hText == NULL) { - return 0; - } - FDE_TEXTEDITPIECE* pPiece = (FDE_TEXTEDITPIECE*)hText; - CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine()); - int32_t nLength = pPiece->nCount; - if (nLength < 1) { - return 0; - } - const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams(); - FX_DWORD dwLayoutStyle = pEngine->GetTextBreak()->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; - tr.dwStyles = dwLayoutStyle; - tr.iCharRotation = pTextParams->nCharRotation; - tr.dwCharStyles = pPiece->dwCharStyles; - tr.pRect = &(pPiece->rtPiece); - tr.wLineBreakChar = pTextParams->wLineBreakChar; - return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox); -} -CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) - : m_pIter(nullptr), - m_pTextSet(nullptr), - m_pBgnParag(nullptr), - m_pEndParag(nullptr), - m_nRefCount(0), - m_nPageStart(-1), - m_nCharCount(0), - m_nPageIndex(nPageIndex), - m_bLoaded(FALSE), - m_pCharWidth(nullptr) { - FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); - FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); - FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); - 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; - } -} -void CFDE_TxtEdtPage::Release() { - delete this; -} -IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { - return (IFDE_TxtEdtEngine*)m_pEditEngine; -} -FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { - return FDE_VISUALOBJ_Text; -} -FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) { - return FALSE; -} -FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj, - CFX_Matrix& matrix) { - return FALSE; -} -FX_BOOL CFDE_TxtEdtPage::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { - return FALSE; -} -FX_BOOL CFDE_TxtEdtPage::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) { - return FALSE; -} -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); - if (m_nRefCount < 1) { - return 0; - } - int32_t nCount = m_PieceMassArr.GetSize(); - for (int32_t i = 0; i < nCount; i++) { - const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); - if (nIndex >= pPiece->nStart && - nIndex < (pPiece->nStart + pPiece->nCount)) { - CFX_RectFArray rectArr; - if (bBBox) { - m_pTextSet->GetCharRects_Impl((FDE_HVISUALOBJ)pPiece, rectArr, bBBox); - } else { - m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr); - } - rect = rectArr[nIndex - pPiece->nStart]; - return pPiece->nBidiLevel; - } - } - FXSYS_assert(0); - return 0; -} -int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, - FX_BOOL& bBefore) { - FX_BOOL bVertical = m_pEditEngine->GetEditParams()->dwLayoutStyles & - FDE_TEXTEDITLAYOUT_DocVertical; - CFX_PointF ptF = fPoint; - NormalizePt2Rect(ptF, m_rtPageContents, FDE_TXTEDT_TOLERANCE); - int32_t nCount = m_PieceMassArr.GetSize(); - CFX_RectF rtLine; - int32_t nBgn = 0; - int32_t nEnd = 0; - FX_BOOL bInLine = FALSE; - int32_t i = 0; - for (i = 0; i < nCount; i++) { - const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); - if (!bInLine && (bVertical ? (pPiece->rtPiece.left <= ptF.x && - pPiece->rtPiece.right() > ptF.x) - : (pPiece->rtPiece.top <= ptF.y && - pPiece->rtPiece.bottom() > ptF.y))) { - nBgn = nEnd = i; - rtLine = pPiece->rtPiece; - bInLine = TRUE; - } else if (bInLine) { - if (bVertical ? (!(pPiece->rtPiece.left <= ptF.x && - pPiece->rtPiece.right() > ptF.x)) - : (pPiece->rtPiece.bottom() <= ptF.y || - pPiece->rtPiece.top > ptF.y)) { - nEnd = i - 1; - break; - } else { - rtLine.Union(pPiece->rtPiece); - } - } - } - NormalizePt2Rect(ptF, rtLine, FDE_TXTEDT_TOLERANCE); - int32_t nCaret = 0; - FDE_TEXTEDITPIECE* pPiece = NULL; - for (i = nBgn; i <= nEnd; i++) { - pPiece = m_PieceMassArr.GetPtrAt(i); - nCaret = m_nPageStart + pPiece->nStart; - if (pPiece->rtPiece.Contains(ptF)) { - CFX_RectFArray rectArr; - m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr); - int32_t nRtCount = rectArr.GetSize(); - for (int32_t j = 0; j < nRtCount; j++) { - if (rectArr[j].Contains(ptF)) { - nCaret = m_nPageStart + pPiece->nStart + j; - if (nCaret >= m_pEditEngine->GetTextBufLength()) { - bBefore = TRUE; - return m_pEditEngine->GetTextBufLength(); - } - FX_WCHAR wChar = m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret); - if (wChar == L'\n' || wChar == L'\r') { - if (wChar == L'\n') { - if (m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret - 1) == - L'\r') { - nCaret--; - } - } - bBefore = TRUE; - return nCaret; - } - if (bVertical - ? (ptF.y > ((rectArr[j].top + rectArr[j].bottom()) / 2)) - : (ptF.x > ((rectArr[j].left + rectArr[j].right()) / 2))) { - bBefore = FX_IsOdd(pPiece->nBidiLevel); - } else { - bBefore = !FX_IsOdd(pPiece->nBidiLevel); - } - return nCaret; - } - } - } - } - bBefore = TRUE; - return nCaret; -} -int32_t CFDE_TxtEdtPage::GetCharStart() const { - return m_nPageStart; -} -int32_t CFDE_TxtEdtPage::GetCharCount() const { - return m_nCharCount; -} -int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip, - FXTEXT_CHARPOS*& pCharPos, - CFX_RectF* pBBox) const { - pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount); - int32_t nCharPosCount = 0; - FDE_HVISUALOBJ hVisualObj = NULL; - int32_t nVisualObjCount = m_PieceMassArr.GetSize(); - FXTEXT_CHARPOS* pos = pCharPos; - CFX_RectF rtObj; - for (int32_t i = 0; i < nVisualObjCount; i++) { - hVisualObj = (FDE_HVISUALOBJ)m_PieceMassArr.GetPtrAt(i); - m_pTextSet->GetRect(hVisualObj, rtObj); - if (!rtClip.IntersectWith(rtObj)) { - continue; - } - int32_t nCount = m_pTextSet->GetDisplayPos(hVisualObj, pos, FALSE); - nCharPosCount += nCount; - pos += nCount; - } - if ((nCharPosCount * 5) < (m_nCharCount << 2)) { - FXTEXT_CHARPOS* pTemp = FX_Alloc(FXTEXT_CHARPOS, nCharPosCount); - FXSYS_memcpy(pTemp, pCharPos, sizeof(FXTEXT_CHARPOS) * nCharPosCount); - FX_Free(pCharPos); - pCharPos = pTemp; - } - return nCharPosCount; -} -void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart, - int32_t nCount, - CFX_RectFArray& RectFArr) const { - int32_t nPieceCount = m_PieceMassArr.GetSize(); - int32_t nEnd = nStart + nCount - 1; - FX_BOOL bInRange = FALSE; - for (int32_t i = 0; i < nPieceCount; i++) { - FDE_TEXTEDITPIECE* piece = m_PieceMassArr.GetPtrAt(i); - if (!bInRange) { - if (nStart >= piece->nStart && nStart < (piece->nStart + piece->nCount)) { - int32_t nRangeEnd = piece->nCount - 1; - FX_BOOL bEnd = FALSE; - if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { - nRangeEnd = nEnd - piece->nStart; - bEnd = TRUE; - } - CFX_RectFArray rcArr; - m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr); - CFX_RectF rectPiece = rcArr[nStart - piece->nStart]; - rectPiece.Union(rcArr[nRangeEnd]); - RectFArr.Add(rectPiece); - if (bEnd) { - return; - } - bInRange = TRUE; - } - } else { - if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) { - CFX_RectFArray rcArr; - m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr); - CFX_RectF rectPiece = rcArr[0]; - rectPiece.Union(rcArr[nEnd - piece->nStart]); - RectFArr.Add(rectPiece); - return; - } - RectFArr.Add(piece->rtPiece); - } - } -} - -int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { - if (m_nRefCount < 0) { - return -1; - } - IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); - FX_BOOL bBefore; - int32_t nIndex = GetCharIndex(fPoint, bBefore); - if (nIndex == m_pEditEngine->GetTextBufLength()) { - nIndex = m_pEditEngine->GetTextBufLength() - 1; - } - if (nIndex < 0) { - return -1; - } - IFX_WordBreak* pIter = FX_WordBreak_Create(); - pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); - pIter->SetAt(nIndex); - nCount = pIter->GetWordLength(); - int32_t nRet = pIter->GetWordPos(); - pIter->Release(); - return nRet; -} -FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) { - return m_bLoaded; -} -int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, - IFX_Pause* pPause) { - if (m_nRefCount > 0) { - m_nRefCount++; - return m_nRefCount; - } - IFDE_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(); - pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - pBreak->ClearBreakPieces(); - int32_t nPageLineCount = m_pEditEngine->GetPageLineCount(); - int32_t nStartLine = nPageLineCount * m_nPageIndex; - int32_t nEndLine = std::min((nStartLine + nPageLineCount - 1), - (m_pEditEngine->GetLineCount() - 1)); - int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, - nEndLineInParag; - nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); - m_pBgnParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nBgnParag); - m_pBgnParag->LoadParag(); - m_pBgnParag->GetLineRange(nStartLine - nStartLineInParag, nPageStart, nTemp); - nEndParag = m_pEditEngine->Line2Parag(nBgnParag, nStartLineInParag, nEndLine, - nEndLineInParag); - m_pEndParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nEndParag); - m_pEndParag->LoadParag(); - m_pEndParag->GetLineRange(nEndLine - nEndLineInParag, nPageEnd, nTemp); - nPageEnd += (nTemp - 1); - FX_BOOL bVertial = pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical; - FX_BOOL bLineReserve = - pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_LineReserve; - FX_FLOAT fLineStart = - bVertial - ? (bLineReserve ? (pParams->fPlateWidth - pParams->fLineSpace) : 0.0f) - : 0.0f; - FX_FLOAT fLineStep = - (bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace; - FX_FLOAT fLinePos = fLineStart; - if (m_pTextSet == NULL) { - m_pTextSet = new CFDE_TxtEdtTextSet(this); - } - m_PieceMassArr.RemoveAll(TRUE); - FX_DWORD dwBreakStatus = FX_TXTBREAK_None; - int32_t nPieceStart = 0; - if (m_pCharWidth != NULL) { - delete[] m_pCharWidth; - } - m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1]; - pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - pBreak->ClearBreakPieces(); - m_nPageStart = nPageStart; - m_nCharCount = nPageEnd - nPageStart + 1; - FX_BOOL bReload = FALSE; - FX_FLOAT fDefCharWidth = 0; - IFX_CharIter* pIter = m_pIter->Clone(); - pIter->SetAt(nPageStart); - m_pIter->SetAt(nPageStart); - FX_BOOL bFirstPiece = TRUE; - do { - if (bReload) { - dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } else { - FX_WCHAR wAppend = pIter->GetChar(); - dwBreakStatus = pBreak->AppendChar(wAppend); - } - if (pIter->GetAt() == nPageEnd && dwBreakStatus < FX_TXTBREAK_LineBreak) { - dwBreakStatus = pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - int32_t nPieceCount = pBreak->CountBreakPieces(); - for (int32_t j = 0; j < nPieceCount; j++) { - const CFX_TxtPiece* pPiece = pBreak->GetBreakPiece(j); - FDE_TEXTEDITPIECE TxtEdtPiece; - FXSYS_memset(&TxtEdtPiece, 0, sizeof(FDE_TEXTEDITPIECE)); - TxtEdtPiece.nBidiLevel = pPiece->m_iBidiLevel; - TxtEdtPiece.nCount = pPiece->GetLength(); - TxtEdtPiece.nStart = nPieceStart; - TxtEdtPiece.dwCharStyles = pPiece->m_dwCharStyles; - if (FX_IsOdd(pPiece->m_iBidiLevel)) { - TxtEdtPiece.dwCharStyles |= FX_TXTCHARSTYLE_OddBidiLevel; - } - FX_FLOAT fParaBreakWidth = 0.0f; - if (pPiece->m_dwStatus > FX_TXTBREAK_PieceBreak) { - FX_WCHAR wRtChar = pParams->wLineBreakChar; - if (TxtEdtPiece.nCount >= 2) { - FX_WCHAR wChar = pBuf->GetCharByIndex( - m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 1); - FX_WCHAR wCharPre = pBuf->GetCharByIndex( - m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 2); - if (wChar == wRtChar) { - fParaBreakWidth += fDefCharWidth; - } - if (wCharPre == wRtChar) { - fParaBreakWidth += fDefCharWidth; - } - } else if (TxtEdtPiece.nCount >= 1) { - FX_WCHAR wChar = pBuf->GetCharByIndex( - m_nPageStart + TxtEdtPiece.nStart + TxtEdtPiece.nCount - 1); - if (wChar == wRtChar) { - fParaBreakWidth += fDefCharWidth; - } - } - } - if (pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { - TxtEdtPiece.rtPiece.left = fLinePos; - TxtEdtPiece.rtPiece.top = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; - TxtEdtPiece.rtPiece.width = pParams->fLineSpace; - TxtEdtPiece.rtPiece.height = - (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; - } else { - TxtEdtPiece.rtPiece.left = (FX_FLOAT)pPiece->m_iStartPos / 20000.0f; - TxtEdtPiece.rtPiece.top = fLinePos; - TxtEdtPiece.rtPiece.width = - (FX_FLOAT)pPiece->m_iWidth / 20000.0f + fParaBreakWidth; - TxtEdtPiece.rtPiece.height = pParams->fLineSpace; - } - if (bFirstPiece) { - m_rtPageContents = TxtEdtPiece.rtPiece; - bFirstPiece = FALSE; - } else { - m_rtPageContents.Union(TxtEdtPiece.rtPiece); - } - nPieceStart += TxtEdtPiece.nCount; - m_PieceMassArr.Add(TxtEdtPiece); - for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) { - CFX_Char* ptc = pPiece->GetCharPtr(k); - m_pCharWidth[TxtEdtPiece.nStart + k] = ptc->m_iCharWidth; - } - } - fLinePos += fLineStep; - pBreak->ClearBreakPieces(); - } - if (pIter->GetAt() == nPageEnd && dwBreakStatus == FX_TXTBREAK_LineBreak) { - bReload = TRUE; - pIter->Next(TRUE); - } - } while (pIter->Next(FALSE) && (pIter->GetAt() <= nPageEnd)); - if (m_rtPageContents.left != 0) { - FX_FLOAT fDelta = 0.0f; - if (m_rtPageContents.width < pParams->fPlateWidth) { - if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Right) { - fDelta = pParams->fPlateWidth - m_rtPageContents.width; - } else if (pParams->dwAlignment & FDE_TEXTEDITALIGN_Center) { - if ((pParams->dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText) && - m_nCharCount > 1) { - int32_t nCount = m_nCharCount - 1; - int32_t n = (m_pEditEngine->m_nLimit - nCount) / 2; - fDelta = (m_rtPageContents.width / nCount) * n; - } else { - fDelta = (pParams->fPlateWidth - m_rtPageContents.width) / 2; - } - } - } - FX_FLOAT fOffset = m_rtPageContents.left - fDelta; - int32_t nCount = m_PieceMassArr.GetSize(); - for (int32_t i = 0; i < nCount; i++) { - FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i); - pPiece->rtPiece.Offset(-fOffset, 0.0f); - } - m_rtPageContents.Offset(-fOffset, 0.0f); - } - if (m_pEditEngine->GetEditParams()->dwLayoutStyles & - FDE_TEXTEDITLAYOUT_LastLineHeight) { - m_rtPageContents.height -= pParams->fLineSpace - pParams->fFontSize; - int32_t nCount = m_PieceMassArr.GetSize(); - 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); - 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; - } -} - -const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() { - return m_rtPageContents; -} -FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) { - if (m_PieceMassArr.GetSize() < 1) { - return NULL; - } - return (FX_POSITION)1; -} -FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas, - FX_POSITION& pos, - IFDE_VisualSet*& pVisualSet) { - if (m_pTextSet == NULL) { - pos = NULL; - return NULL; - } - int32_t nPos = (int32_t)(uintptr_t)pos; - pVisualSet = m_pTextSet; - if (nPos + 1 > m_PieceMassArr.GetSize()) { - pos = NULL; - } else { - pos = (FX_POSITION)(uintptr_t)(nPos + 1); - } - return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1)); -} -FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas, - IFDE_VisualSet*& pVisualSet) { - return NULL; -} -FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const { - int32_t nIndex = - m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index; - if (nIndex != m_pIter->GetAt()) { - m_pIter->SetAt(nIndex); - } - FX_WCHAR wChar = m_pIter->GetChar(); - m_pIter->Next(); - return wChar; -} -int32_t CFDE_TxtEdtPage::GetWidth(void* pIdentity, int32_t index) const { - int32_t nWidth = - m_pCharWidth[((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index]; - return nWidth; -} -void CFDE_TxtEdtPage::NormalizePt2Rect(CFX_PointF& ptF, - const CFX_RectF& rtF, - FX_FLOAT fTolerance) const { - if (rtF.Contains(ptF.x, ptF.y)) { - return; - } - if (ptF.x < rtF.left) { - ptF.x = rtF.left; - } else if (ptF.x >= rtF.right()) { - ptF.x = rtF.right() - fTolerance; - } - if (ptF.y < rtF.top) { - ptF.y = rtF.top; - } else if (ptF.y >= rtF.bottom()) { - ptF.y = rtF.bottom() - fTolerance; - } -} diff --git a/xfa/src/fee/fde_txtedtpage.h b/xfa/src/fee/fde_txtedtpage.h deleted file mode 100644 index 2ea0725de5..0000000000 --- a/xfa/src/fee/fde_txtedtpage.h +++ /dev/null @@ -1,168 +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_SRC_FEE_FDE_TXTEDTPAGE_H_ -#define XFA_SRC_FEE_FDE_TXTEDTPAGE_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fde/fde_visualset.h" -#include "xfa/src/fee/ifde_txtedtpage.h" -#include "xfa/src/fgas/crt/fgas_utils.h" - -class IFX_CharIter; -class CFDE_TxtEdtEngine; -class CFDE_TxtEdtPage; -class CFDE_TxtEdtParag; - -enum FDE_TXTEDT_CHARTYPE { - FDE_TXTEDT_CHARTYPE_Unknown = 0, - FDE_TXTEDT_CHARTYPE_Tab, - FDE_TXTEDT_CHARTYPE_Space, - FDE_TXTEDT_CHARTYPE_Punctuation, - FDE_TXTEDT_CHARTYPE_LineBreak, - FDE_TXTEDT_CHARTYPE_Number, - FDE_TXTEDT_CHARTYPE_Char, - FDE_TXTEDT_CHARTYPE_CJK, -}; - -inline FDE_TXTEDT_CHARTYPE FDE_GetEditSelCharType(FX_WCHAR wChar) { - if (wChar == 0x9) { - return FDE_TXTEDT_CHARTYPE_Tab; - } else if (wChar == 0x20 || wChar == 0xA0) { - return FDE_TXTEDT_CHARTYPE_Space; - } else if (wChar == 0x9 || wChar == 0x20 || wChar == 0xA0 || - (wChar >= L'!' && wChar <= L'/') || - (wChar >= L':' && wChar <= L'@') || - (wChar >= L'[' && wChar <= L'^') || - (wChar >= L'{' && wChar <= L'~') || wChar == 0x60) { - return FDE_TXTEDT_CHARTYPE_Punctuation; - } else if (wChar == 0x0a || wChar == 0x0d) { - return FDE_TXTEDT_CHARTYPE_LineBreak; - } else if (wChar >= '0' && wChar <= '9') { - return FDE_TXTEDT_CHARTYPE_Number; - } else if ((wChar >= 0x2e80 && wChar <= 0x2eff) || - (wChar >= 0x3000 && wChar <= 0x303f) || - (wChar >= 0x31c0 && wChar <= 0x31ef) || - (wChar >= 0x3200 && wChar <= 0x32ff) || - (wChar >= 0x3300 && wChar <= 0x33ff) || - (wChar >= 0x3400 && wChar <= 0x4dbf) || - (wChar >= 0x4e00 && wChar <= 0x9fff) || - (wChar >= 0xf900 && wChar <= 0xfaff) || - (wChar >= 0xfe30 && wChar <= 0xfe4f)) { - return FDE_TXTEDT_CHARTYPE_CJK; - } else { - return FDE_TXTEDT_CHARTYPE_Char; - } -} - -struct FDE_TEXTEDITPIECE { - int32_t nStart; - int32_t nCount; - int32_t nBidiLevel; - CFX_RectF rtPiece; - FX_DWORD dwCharStyles; -}; -typedef CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> CFDE_TXTEDTPieceMassArray; - -class CFDE_TxtEdtTextSet : public IFDE_TextSet { - public: - CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage); - ~CFDE_TxtEdtTextSet(); - - virtual FDE_VISUALOBJTYPE GetType(); - virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox); - virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix); - virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt); - virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt); - virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText); - virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText); - virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText); - virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText); - virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL); - virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, CFX_RectFArray& rtArray); - virtual int32_t GetCharRects_Impl(FDE_HVISUALOBJ hText, - CFX_RectFArray& rtArray, - FX_BOOL bBBox = FALSE); - - private: - CFDE_TxtEdtPage* m_pPage; -}; - -class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { - public: - CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nLineIndex); - - // IFDE_TxtEditPage: - void Release() override; - IFDE_TxtEdtEngine* GetEngine() const override; - int32_t GetCharRect(int32_t nIndex, - CFX_RectF& rect, - FX_BOOL bBBox = FALSE) const override; - int32_t GetCharIndex(const CFX_PointF& fPoint, FX_BOOL& bBefore) override; - void CalcRangeRectArray(int32_t nStart, - int32_t nCount, - CFX_RectFArray& RectFArr) const override; - int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) override; - int32_t GetCharStart() const override; - int32_t GetCharCount() const override; - int32_t GetDisplayPos(const CFX_RectF& rtClip, - FXTEXT_CHARPOS*& pCharPos, - CFX_RectF* pBBox) const override; - FX_BOOL IsLoaded(const CFX_RectF* pClipBox) override; - int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) override; - void UnloadPage(const CFX_RectF* pClipBox) override; - const CFX_RectF& GetContentsBox() override; - - // IFDE_VisualSet: - FDE_VISUALOBJTYPE GetType() override; - FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override; - FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override; - FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override; - FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override; - - // IFDE_CanvasSet: - FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) override; - FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas, - FX_POSITION& pos, - IFDE_VisualSet*& pVisualSet) override; - FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas, - IFDE_VisualSet*& pVisualSet) override; - - // IFX_TxtAccess: - FX_WCHAR GetChar(void* pIdentity, int32_t index) const override; - int32_t GetWidth(void* pIdentity, int32_t index) const override; - - protected: - virtual ~CFDE_TxtEdtPage(); - - private: - void NormalizePt2Rect(CFX_PointF& ptF, - const CFX_RectF& rtF, - FX_FLOAT fTolerance) const; - - IFX_CharIter* m_pIter; - CFDE_TxtEdtTextSet* m_pTextSet; - CFDE_TxtEdtEngine* m_pEditEngine; - CFDE_TXTEDTPieceMassArray m_PieceMassArr; - CFDE_TxtEdtParag* m_pBgnParag; - CFDE_TxtEdtParag* m_pEndParag; - int32_t m_nRefCount; - int32_t m_nPageStart; - int32_t m_nCharCount; - int32_t m_nPageIndex; - FX_BOOL m_bLoaded; - CFX_RectF m_rtPage; - CFX_RectF m_rtPageMargin; - CFX_RectF m_rtPageContents; - CFX_RectF m_rtPageCanvas; - int32_t* m_pCharWidth; -}; - -#endif // XFA_SRC_FEE_FDE_TXTEDTPAGE_H_ diff --git a/xfa/src/fee/fde_txtedtparag.cpp b/xfa/src/fee/fde_txtedtparag.cpp deleted file mode 100644 index 32f846b52b..0000000000 --- a/xfa/src/fee/fde_txtedtparag.cpp +++ /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 - -#include "xfa/src/fee/fde_txtedtparag.h" - -#include "xfa/src/fee/fde_txtedtbuf.h" -#include "xfa/src/fee/fde_txtedtengine.h" -#include "xfa/src/fee/fx_wordbreak/fx_wordbreak.h" -#include "xfa/src/fee/ifde_txtedtbuf.h" -#include "xfa/src/fee/ifde_txtedtengine.h" -#include "xfa/src/fgas/layout/fgas_textbreak.h" - -CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine) - : m_nCharStart(0), - m_nCharCount(0), - m_nLineCount(0), - m_lpData(NULL), - m_pEngine(pEngine) { - FXSYS_assert(m_pEngine); -} -CFDE_TxtEdtParag::~CFDE_TxtEdtParag() { - if (m_lpData != NULL) { - FX_Free(m_lpData); - } -} -void CFDE_TxtEdtParag::LoadParag() { - if (m_lpData != NULL) { - ((int32_t*)m_lpData)[0]++; - return; - } - IFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); - IFDE_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); - pIter->SetAt(m_nCharStart); - int32_t nEndIndex = m_nCharStart + m_nCharCount; - CFX_ArrayTemplate<int32_t> LineBaseArr; - FX_BOOL bReload = FALSE; - FX_DWORD dwBreakStatus = FX_TXTBREAK_None; - do { - if (bReload) { - dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } else { - FX_WCHAR wAppend = pIter->GetChar(); - dwBreakStatus = pTxtBreak->AppendChar(wAppend); - } - if (pIter->GetAt() + 1 == nEndIndex && - dwBreakStatus < FX_TXTBREAK_LineBreak) { - dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - int32_t nCount = pTxtBreak->CountBreakPieces(); - int32_t nTotal = 0; - for (int32_t j = 0; j < nCount; j++) { - const CFX_TxtPiece* Piece = pTxtBreak->GetBreakPiece(j); - nTotal += Piece->GetLength(); - } - LineBaseArr.Add(nTotal); - pTxtBreak->ClearBreakPieces(); - } - if ((pIter->GetAt() + 1 == nEndIndex) && - (dwBreakStatus == FX_TXTBREAK_LineBreak)) { - bReload = TRUE; - pIter->Next(TRUE); - } - } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); - pIter->Release(); - pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - pTxtBreak->ClearBreakPieces(); - int32_t nLineCount = LineBaseArr.GetSize(); - m_nLineCount = nLineCount; - if (m_lpData == NULL) { - m_lpData = FX_Alloc(int32_t, nLineCount + 1); - } else { - m_lpData = FX_Realloc(int32_t, m_lpData, (nLineCount + 1)); - } - int32_t* pIntArr = (int32_t*)m_lpData; - pIntArr[0] = 1; - m_nLineCount = nLineCount; - pIntArr++; - for (int32_t j = 0; j < nLineCount; j++, pIntArr++) { - *pIntArr = LineBaseArr[j]; - } - LineBaseArr.RemoveAll(); -} -void CFDE_TxtEdtParag::UnloadParag() { - FXSYS_assert(m_lpData != NULL); - ((int32_t*)m_lpData)[0]--; - FXSYS_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); - int32_t nCount = 0; - FX_DWORD dwBreakStatus = FX_TXTBREAK_None; - int32_t nEndIndex = m_nCharStart + m_nCharCount; - pIter->SetAt(m_nCharStart); - FX_BOOL bReload = FALSE; - do { - if (bReload) { - dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } else { - FX_WCHAR wAppend = pIter->GetChar(); - dwBreakStatus = pTxtBreak->AppendChar(wAppend); - } - if (pIter->GetAt() + 1 == nEndIndex && - dwBreakStatus < FX_TXTBREAK_LineBreak) { - dwBreakStatus = pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - } - if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { - nCount++; - pTxtBreak->ClearBreakPieces(); - } - if ((pIter->GetAt() + 1 == nEndIndex) && - (dwBreakStatus == FX_TXTBREAK_LineBreak)) { - bReload = TRUE; - pIter->Next(TRUE); - } - } while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex)); - pIter->Release(); - pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); - pTxtBreak->ClearBreakPieces(); - m_nLineCount = nCount; -} -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); - nStart = m_nCharStart; - pLineBaseArr++; - for (int32_t i = 0; i < nLineIndex; i++) { - nStart += *pLineBaseArr; - pLineBaseArr++; - } - nCount = *pLineBaseArr; -} diff --git a/xfa/src/fee/fde_txtedtparag.h b/xfa/src/fee/fde_txtedtparag.h deleted file mode 100644 index 5af04970a1..0000000000 --- a/xfa/src/fee/fde_txtedtparag.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_SRC_FEE_FDE_TXTEDTPARAG_H_ -#define XFA_SRC_FEE_FDE_TXTEDTPARAG_H_ - -#include "xfa/src/fee/ifde_txtedtengine.h" - -class CFDE_TxtEdtEngine; - -class CFDE_TxtEdtParag : public IFDE_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; - void LoadParag(); - void UnloadParag(); - void CalcLines(); - int32_t m_nCharStart; - int32_t m_nCharCount; - int32_t m_nLineCount; - - private: - void* m_lpData; - CFDE_TxtEdtEngine* m_pEngine; -}; - -#endif // XFA_SRC_FEE_FDE_TXTEDTPARAG_H_ diff --git a/xfa/src/fee/fx_wordbreak/fx_wordbreak.h b/xfa/src/fee/fx_wordbreak/fx_wordbreak.h deleted file mode 100644 index f67afb6305..0000000000 --- a/xfa/src/fee/fx_wordbreak/fx_wordbreak.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_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ -#define XFA_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxcrt/fx_system.h" - -class IFX_CharIter; - -class IFX_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; -}; -IFX_WordBreak* FX_WordBreak_Create(); - -#endif // XFA_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_H_ diff --git a/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.cpp b/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.cpp deleted file mode 100644 index 036b4f80fa..0000000000 --- a/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.cpp +++ /dev/null @@ -1,238 +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/src/fee/fx_wordbreak/fx_wordbreak_impl.h" - -FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint) { - FX_DWORD dwProperty = - (FX_DWORD)gs_FX_WordBreak_CodePointProperties[wcCodePoint >> 1]; - 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()); -} -CFX_CharIter::~CFX_CharIter() {} -void CFX_CharIter::Release() { - delete this; -} -FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) { - if (bPrev) { - if (m_nIndex <= 0) { - return FALSE; - } - m_nIndex--; - } else { - if (m_nIndex + 1 >= m_wsText.GetLength()) { - return FALSE; - } - m_nIndex++; - } - return TRUE; -} -FX_WCHAR CFX_CharIter::GetChar() { - return m_wsText.GetAt(m_nIndex); -} -void CFX_CharIter::SetAt(int32_t nIndex) { - if (nIndex < 0 || nIndex >= m_wsText.GetLength()) { - return; - } - m_nIndex = nIndex; -} -int32_t CFX_CharIter::GetAt() const { - return m_nIndex; -} -FX_BOOL CFX_CharIter::IsEOF(FX_BOOL bTail) const { - return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0); -} -IFX_CharIter* CFX_CharIter::Clone() { - CFX_CharIter* pIter = new CFX_CharIter(m_wsText); - 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; -} -void CFX_WordBreak::Attach(IFX_CharIter* pIter) { - FXSYS_assert(pIter); - m_pCurIter = pIter; -} -void CFX_WordBreak::Attach(const CFX_WideString& wsText) { - m_pCurIter = 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)) { - return FALSE; - } - pIter->Next(bPrev); - if (!FindNextBreakPos(pIter, bPrev, TRUE)) { - pIter->Release(); - return FALSE; - } - if (bPrev) { - m_pCurIter->Release(); - m_pCurIter = m_pPreIter; - m_pCurIter->Next(TRUE); - m_pPreIter = pIter; - } else { - m_pPreIter->Release(); - m_pPreIter = m_pCurIter; - m_pPreIter->Next(); - m_pCurIter = pIter; - } - return TRUE; -} -void CFX_WordBreak::SetAt(int32_t nIndex) { - if (m_pPreIter) { - m_pPreIter->Release(); - m_pPreIter = NULL; - } - m_pCurIter->SetAt(nIndex); - FindNextBreakPos(m_pCurIter, TRUE, FALSE); - m_pPreIter = m_pCurIter; - m_pCurIter = m_pPreIter->Clone(); - FindNextBreakPos(m_pCurIter, FALSE, FALSE); -} -int32_t CFX_WordBreak::GetWordPos() const { - return m_pPreIter->GetAt(); -} -int32_t CFX_WordBreak::GetWordLength() const { - return m_pCurIter->GetAt() - m_pPreIter->GetAt() + 1; -} -void CFX_WordBreak::GetWord(CFX_WideString& wsWord) const { - int32_t nWordLength = GetWordLength(); - if (nWordLength <= 0) { - return; - } - FX_WCHAR* lpBuf = wsWord.GetBuffer(nWordLength); - 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) { - break; - } - } - pTempIter->Release(); - wsWord.ReleaseBuffer(nWordLength); -} -FX_BOOL CFX_WordBreak::IsEOF(FX_BOOL bTail) const { - return m_pCurIter->IsEOF(bTail); -} -FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter, - FX_BOOL bPrev, - FX_BOOL bFromNext) { - FX_WordBreakProp ePreType = FX_WordBreakProp_None; - FX_WordBreakProp eCurType = FX_WordBreakProp_None; - FX_WordBreakProp eNextType = FX_WordBreakProp_None; - if (pIter->IsEOF(!bPrev)) { - return TRUE; - } - if (!(bFromNext || pIter->IsEOF(bPrev))) { - pIter->Next(!bPrev); - FX_WCHAR wcTemp = pIter->GetChar(); - ePreType = FX_GetWordBreakProperty(wcTemp); - pIter->Next(bPrev); - } - FX_WCHAR wcTemp = pIter->GetChar(); - eCurType = FX_GetWordBreakProperty(wcTemp); - FX_BOOL bFirst = TRUE; - do { - pIter->Next(bPrev); - FX_WCHAR wcTemp = pIter->GetChar(); - eNextType = FX_GetWordBreakProperty(wcTemp); - FX_WORD wBreak = - gs_FX_WordBreak_Table[eCurType] & ((FX_WORD)(1 << eNextType)); - if (wBreak) { - if (pIter->IsEOF(!bPrev)) { - pIter->Next(!bPrev); - return TRUE; - } - if (bFirst) { - int32_t nFlags = 0; - if (eCurType == FX_WordBreakProp_MidLetter) { - if (eNextType == FX_WordBreakProp_ALetter) { - nFlags = 1; - } - } else if (eCurType == FX_WordBreakProp_MidNum) { - if (eNextType == FX_WordBreakProp_Numberic) { - nFlags = 2; - } - } else if (eCurType == FX_WordBreakProp_MidNumLet) { - if (eNextType == FX_WordBreakProp_ALetter) { - nFlags = 1; - } else if (eNextType == FX_WordBreakProp_Numberic) { - nFlags = 2; - } - } - if (nFlags > 0) { - FXSYS_assert(nFlags <= 2); - if (!((nFlags == 1 && ePreType == FX_WordBreakProp_ALetter) || - (nFlags == 2 && ePreType == FX_WordBreakProp_Numberic))) { - pIter->Next(!bPrev); - return TRUE; - } - pIter->Next(bPrev); - wBreak = FALSE; - } - bFirst = FALSE; - } - if (wBreak) { - int32_t nFlags = 0; - if (eNextType == FX_WordBreakProp_MidLetter) { - if (eCurType == FX_WordBreakProp_ALetter) { - nFlags = 1; - } - } else if (eNextType == FX_WordBreakProp_MidNum) { - if (eCurType == FX_WordBreakProp_Numberic) { - nFlags = 2; - } - } else if (eNextType == FX_WordBreakProp_MidNumLet) { - if (eCurType == FX_WordBreakProp_ALetter) { - nFlags = 1; - } else if (eCurType == FX_WordBreakProp_Numberic) { - nFlags = 2; - } - } - if (nFlags <= 0) { - pIter->Next(!bPrev); - return TRUE; - } - FXSYS_assert(nFlags <= 2); - pIter->Next(bPrev); - wcTemp = pIter->GetChar(); - eNextType = (FX_WordBreakProp)FX_GetWordBreakProperty(wcTemp); - if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) || - (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) { - pIter->Next(!bPrev); - pIter->Next(!bPrev); - return TRUE; - } - } - } - ePreType = eCurType; - eCurType = eNextType; - bFirst = FALSE; - } while (!pIter->IsEOF(!bPrev)); - return TRUE; -} -IFX_WordBreak* FX_WordBreak_Create() { - return new CFX_WordBreak; -} diff --git a/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h b/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h deleted file mode 100644 index 253d83b9dc..0000000000 --- a/xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h +++ /dev/null @@ -1,78 +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_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_ -#define XFA_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_ - -#include <cstdint> - -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fee/fx_wordbreak/fx_wordbreak.h" -#include "xfa/src/fee/fx_wordbreak/fx_wordbreak_impl.h" -#include "xfa/src/fee/ifde_txtedtengine.h" - -extern const FX_WORD gs_FX_WordBreak_Table[16]; -extern const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1]; -enum FX_WordBreakProp { - FX_WordBreakProp_None = 0, - FX_WordBreakProp_CR, - FX_WordBreakProp_LF, - FX_WordBreakProp_NewLine, - FX_WordBreakProp_Extend, - FX_WordBreakProp_Format, - FX_WordBreakProp_KataKana, - FX_WordBreakProp_ALetter, - FX_WordBreakProp_MidLetter, - FX_WordBreakProp_MidNum, - FX_WordBreakProp_MidNumLet, - FX_WordBreakProp_Numberic, - 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_SRC_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_ diff --git a/xfa/src/fee/fx_wordbreak/fx_wordbreakdata.cpp b/xfa/src/fee/fx_wordbreak/fx_wordbreakdata.cpp deleted file mode 100644 index ea1a31fb3c..0000000000 --- a/xfa/src/fee/fx_wordbreak/fx_wordbreakdata.cpp +++ /dev/null @@ -1,2748 +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/src/fee/fx_wordbreak/fx_wordbreak_impl.h" - -const FX_WORD gs_FX_WordBreak_Table[16] = { - 0xFFFF, 0xFFF9, 0xFFFB, 0xFFFB, 0xFFFB, 0xFFFB, 0xEFBB, 0xE77B, - 0xFFFB, 0xFFFB, 0xFFFB, 0xE77B, 0xE73B, 0xFFFB, 0xFFFB, 0xFFFB, -}; - -const uint8_t gs_FX_WordBreak_CodePointProperties[(0xFFFF - 1) / 2 + 1] = - // NOLINTNEXTLINE - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x90, 0xA0, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x89, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x0C, - 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x70, 0x05, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x70, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x70, 0x00, - 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x77, 0x77, 0x70, 0x77, - 0x00, 0x77, 0x77, 0x90, 0x00, 0x00, 0x00, 0x78, 0x77, 0x70, 0x70, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x04, 0x44, 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x09, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x04, 0x04, 0x40, 0x44, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x70, 0x00, 0x00, 0x77, 0x77, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x40, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x0B, 0x90, 0x77, 0x47, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x44, - 0x44, 0x44, 0x45, 0x44, 0x44, 0x44, 0x47, 0x74, 0x40, 0x44, 0x44, 0x77, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x70, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x05, 0x74, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x07, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x77, 0x00, - 0x90, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x44, 0x44, 0x74, 0x44, 0x44, 0x44, 0x44, 0x74, 0x44, - 0x74, 0x44, 0x44, 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, 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, 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, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x47, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x40, 0x74, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x07, 0x70, 0x00, 0x00, - 0x07, 0x77, 0x77, 0x77, 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x07, - 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x77, 0x77, 0x70, 0x70, 0x00, 0x77, 0x77, 0x00, 0x47, 0x44, - 0x44, 0x44, 0x40, 0x04, 0x40, 0x04, 0x44, 0x70, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x77, 0x07, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x07, 0x77, - 0x77, 0x70, 0x00, 0x07, 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x07, 0x70, - 0x77, 0x00, 0x40, 0x44, 0x44, 0x40, 0x00, 0x04, 0x40, 0x04, 0x44, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x07, 0x77, 0x70, 0x70, 0x00, 0x00, 0x00, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0x44, 0x77, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x07, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, 0x44, 0x44, 0x44, 0x04, - 0x44, 0x04, 0x44, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x07, - 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, - 0x44, 0x44, 0x40, 0x04, 0x40, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x44, - 0x00, 0x00, 0x77, 0x07, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x07, 0x77, - 0x77, 0x70, 0x00, 0x77, 0x70, 0x77, 0x77, 0x00, 0x07, 0x70, 0x70, 0x77, - 0x00, 0x07, 0x70, 0x00, 0x77, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x00, 0x00, 0x44, 0x44, 0x40, 0x00, 0x44, 0x40, 0x44, 0x44, 0x00, - 0x70, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x77, 0x70, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x07, 0x77, 0x77, 0x00, 0x07, 0x44, 0x44, 0x44, 0x40, 0x44, - 0x40, 0x44, 0x44, 0x00, 0x00, 0x00, 0x04, 0x40, 0x77, 0x00, 0x00, 0x00, - 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, 0x77, 0x77, 0x77, 0x70, 0x77, - 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x77, 0x77, 0x00, 0x47, 0x44, - 0x44, 0x44, 0x40, 0x44, 0x40, 0x44, 0x44, 0x00, 0x00, 0x00, 0x04, 0x40, - 0x00, 0x00, 0x00, 0x70, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, 0x77, - 0x77, 0x77, 0x70, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x00, 0x07, 0x44, 0x44, 0x44, 0x40, 0x44, 0x40, 0x44, 0x44, 0x00, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x77, 0x44, 0x00, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, - 0x00, 0x44, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, - 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x07, 0x77, 0x77, 0x77, 0x77, 0x07, 0x00, 0x77, 0x77, 0x77, 0x70, - 0x00, 0x40, 0x00, 0x04, 0x44, 0x44, 0x40, 0x40, 0x44, 0x44, 0x44, 0x44, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 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, 0x04, 0x00, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x40, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x44, 0x44, - 0x44, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x44, 0x77, 0x77, 0x77, 0x77, - 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x04, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x44, 0x77, 0x77, 0x00, 0x00, - 0x44, 0x44, 0x44, 0x44, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x40, 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, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x40, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x44, 0x40, 0x44, 0x40, 0x04, - 0x44, 0x44, 0x44, 0x00, 0x04, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x04, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x70, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x70, 0x70, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x70, - 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x70, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x77, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, - 0x77, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, - 0x70, 0x44, 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, 0x00, 0x00, 0x55, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x74, 0x70, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xB0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 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, 0x04, 0x44, - 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x04, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x44, 0x47, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x47, 0x77, - 0x77, 0x77, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x47, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, - 0x44, 0x40, 0x00, 0x77, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x07, 0x77, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x47, 0x77, 0x74, 0x77, 0x77, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x44, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x07, 0x07, 0x07, 0x07, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x70, 0x00, 0x77, 0x70, 0x77, - 0x77, 0x77, 0x70, 0x00, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x77, 0x70, 0x77, - 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x55, - 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x08, - 0x33, 0x55, 0x55, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, - 0xC0, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x50, 0x00, 0x00, 0x55, 0x55, 0x55, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x70, 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, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x70, 0x00, 0x07, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x07, 0x00, - 0x07, 0x77, 0x77, 0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x77, 0x77, 0x07, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x00, 0x00, 0x07, 0x77, - 0x77, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, - 0x00, 0x07, 0x77, 0x74, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x70, - 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, - 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x70, - 0x77, 0x77, 0x77, 0x70, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, - 0x06, 0x66, 0x66, 0x00, 0x00, 0x07, 0x70, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x46, 0x60, 0x00, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0x66, 0x66, 0x00, 0x00, 0x07, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x07, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 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, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 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, 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, 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, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x70, 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, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x70, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x74, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x44, 0x07, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x07, 0x70, 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, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x77, 0x77, - 0x77, 0x47, 0x77, 0x47, 0x77, 0x74, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x77, 0x77, 0x77, 0x00, 0x07, 0x00, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x44, 0x44, 0x44, 0x44, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, - 0x44, 0x44, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x74, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x74, 0x77, 0x77, 0x77, 0x77, 0x44, 0x00, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 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, 0x40, 0x44, 0x40, 0x04, - 0x40, 0x00, 0x00, 0x44, 0x04, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x74, 0x44, 0x44, 0x44, 0x40, 0x44, 0x00, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x07, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x77, 0x77, 0x00, 0x00, 0x07, 0x47, 0x77, 0x77, 0x77, 0x77, - 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x77, 0x77, 0x70, 0x70, - 0x77, 0x07, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x90, 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xCC, 0x90, 0xA0, 0x98, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x77, 0x70, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x05, - 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x89, 0x00, 0x00, 0x07, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x0C, 0x07, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x44, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x70, - 0x00, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, 0x00, 0x77, 0x77, 0x77, - 0x00, 0x77, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x00, 0x00, -}; diff --git a/xfa/src/fee/ifde_txtedtbuf.h b/xfa/src/fee/ifde_txtedtbuf.h deleted file mode 100644 index 8cc7dfeab5..0000000000 --- a/xfa/src/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_SRC_FEE_IFDE_TXTEDTBUF_H_ -#define XFA_SRC_FEE_IFDE_TXTEDTBUF_H_ - -#include "core/include/fxcrt/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_SRC_FEE_IFDE_TXTEDTBUF_H_ diff --git a/xfa/src/fee/ifde_txtedtengine.h b/xfa/src/fee/ifde_txtedtengine.h deleted file mode 100644 index f49e086768..0000000000 --- a/xfa/src/fee/ifde_txtedtengine.h +++ /dev/null @@ -1,258 +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_SRC_FEE_IFDE_TXTEDTENGINE_H_ -#define XFA_SRC_FEE_IFDE_TXTEDTENGINE_H_ - -#include "core/include/fxge/fx_dib.h" -#include "xfa/src/fgas/font/fgas_font.h" - -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) -#define FDE_TEXTEDITMODE_LimitArea_Vert (1L << 3) -#define FDE_TEXTEDITMODE_LimitArea_Horz (1L << 4) -#define FDE_TEXTEDITMODE_NoRedoUndo (1L << 5) -#define FDE_TEXTEDITMODE_FIELD_TAB (1L << 6) -#define FDE_TEXTEDITMODE_FIELD_AUTO (1L << 7) -#define FDE_TEXTEDITMODE_Validate (1L << 8) -#define FDE_TEXTEDITMODE_Password (1L << 9) - -#define FDE_TEXTEDITALIGN_Left (0L << 0) -#define FDE_TEXTEDITALIGN_Center (1L << 0) -#define FDE_TEXTEDITALIGN_Right (2L << 0) -#define FDE_TEXTEDITALIGN_Normal (1L << 3) -#define FDE_TEXTEDITALIGN_Justified (1L << 4) -#define FDE_TEXTEDITALIGN_Distributed (1L << 5) - -#define FDE_TEXTEDITLAYOUT_DocVertical (1L << 0) -#define FDE_TEXTEDITLAYOUT_CharVertial (1L << 1) -#define FDE_TEXTEDITLAYOUT_LineReserve (1L << 2) -#define FDE_TEXTEDITLAYOUT_RTL (1L << 3) -#define FDE_TEXTEDITLAYOUT_CombText (1L << 4) -#define FDE_TEXTEDITLAYOUT_ExpandTab (1L << 5) -#define FDE_TEXTEDITLAYOUT_ArabicContext (1L << 6) -#define FDE_TEXTEDITLAYOUT_ArabicShapes (1L << 7) -#define FDE_TEXTEDITLAYOUT_LastLineHeight (1L << 8) - -enum FDE_TXTEDTMOVECARET { - MC_MoveNone = 0, - MC_Left, - MC_Right, - MC_Up, - MC_Down, - MC_WordBackward, - MC_WordForward, - MC_LineStart, - MC_LineEnd, - MC_ParagStart, - MC_ParagEnd, - MC_PageUp, - MC_PageDown, - MC_Home, - MC_End, -}; -enum FDE_TXTEDT_MODIFY_RET { - FDE_TXTEDT_MODIFY_RET_F_Tab = -6, - FDE_TXTEDT_MODIFY_RET_F_Locked = -5, - FDE_TXTEDT_MODIFY_RET_F_Invalidate = -4, - FDE_TXTEDT_MODIFY_RET_F_Boundary = -3, - FDE_TXTEDT_MODIFY_RET_F_Full = -2, - FDE_TXTEDT_MODIFY_RET_F_Normal = -1, - FDE_TXTEDT_MODIFY_RET_S_Normal = 0, - FDE_TXTEDT_MODIFY_RET_S_Full = 1, - FDE_TXTEDT_MODIFY_RET_S_Part = 2, - 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() - : fPlateWidth(0), - fPlateHeight(0), - nLineCount(0), - dwLayoutStyles(0), - dwAlignment(0), - dwMode(0), - pFont(NULL), - fFontSize(10.0f), - dwFontColor(0xff000000), - fLineSpace(10.0f), - fTabWidth(36), - bTabEquidistant(FALSE), - wDefChar(0xFEFF), - wLineBreakChar('\n'), - nCharRotation(0), - nLineEnd(0), - nHorzScale(100), - fCharSpace(0), - pEventSink(NULL) {} - FX_FLOAT fPlateWidth; - FX_FLOAT fPlateHeight; - int32_t nLineCount; - FX_DWORD dwLayoutStyles; - FX_DWORD dwAlignment; - FX_DWORD dwMode; - IFX_Font* pFont; - FX_FLOAT fFontSize; - FX_ARGB dwFontColor; - FX_FLOAT fLineSpace; - FX_FLOAT fTabWidth; - FX_BOOL bTabEquidistant; - FX_WCHAR wDefChar; - FX_WCHAR wLineBreakChar; - int32_t nCharRotation; - int32_t nLineEnd; - int32_t nHorzScale; - FX_FLOAT fCharSpace; - IFDE_TxtEdtEventSink* 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 { - 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; - virtual int32_t GetAt() const = 0; - 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_SRC_FEE_IFDE_TXTEDTENGINE_H_ diff --git a/xfa/src/fee/ifde_txtedtpage.h b/xfa/src/fee/ifde_txtedtpage.h deleted file mode 100644 index f76498d7ed..0000000000 --- a/xfa/src/fee/ifde_txtedtpage.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_SRC_FEE_IFDE_TXTEDTPAGE_H_ -#define XFA_SRC_FEE_IFDE_TXTEDTPAGE_H_ - -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fde/fde_visualset.h" -#include "xfa/src/fgas/layout/fgas_textbreak.h" - -class IFDE_TxtEdtEngine; -class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess { - public: - static IFDE_TxtEdtPage* Create(IFDE_TxtEdtEngine* pEngine, int32_t nIndex); - - virtual void Release() = 0; - - virtual IFDE_TxtEdtEngine* GetEngine() const = 0; - virtual int32_t GetCharRect(int32_t nIndex, - CFX_RectF& rect, - FX_BOOL bBBox = FALSE) const = 0; - virtual int32_t GetCharIndex(const CFX_PointF& fPoint, FX_BOOL& bBefore) = 0; - virtual void CalcRangeRectArray(int32_t nStart, - int32_t nCount, - CFX_RectFArray& RectFArr) const = 0; - virtual int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) = 0; - virtual int32_t GetCharStart() const = 0; - virtual int32_t GetCharCount() const = 0; - - virtual int32_t GetDisplayPos(const CFX_RectF& rtClip, - FXTEXT_CHARPOS*& pCharPos, - CFX_RectF* pBBox) const = 0; - virtual FX_BOOL IsLoaded(const CFX_RectF* pClipBox) = 0; - virtual int32_t LoadPage(const CFX_RectF* pClipBox, IFX_Pause* pPause) = 0; - virtual void UnloadPage(const CFX_RectF* pClipBox) = 0; - virtual const CFX_RectF& GetContentsBox() = 0; -}; - -#endif // XFA_SRC_FEE_IFDE_TXTEDTPAGE_H_ diff --git a/xfa/src/fgas/crt/fgas_algorithm.cpp b/xfa/src/fgas/crt/fgas_algorithm.cpp deleted file mode 100644 index 60b43ac886..0000000000 --- a/xfa/src/fgas/crt/fgas_algorithm.cpp +++ /dev/null @@ -1,306 +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/src/fgas/crt/fgas_algorithm.h" - -#include "core/include/fxcrt/fx_basic.h" - -#ifdef __cplusplus -extern "C" { -#endif - -static const FX_CHAR g_FXBase64EncoderMap[64] = { - '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', - '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', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', -}; - -struct FX_BASE64DATA { - FX_DWORD data1 : 2; - FX_DWORD data2 : 6; - FX_DWORD data3 : 4; - FX_DWORD data4 : 4; - FX_DWORD data5 : 6; - FX_DWORD data6 : 2; - FX_DWORD data7 : 8; -}; - -static void FX_Base64EncodePiece(const FX_BASE64DATA& src, - int32_t iBytes, - FX_CHAR dst[4]) { - dst[0] = g_FXBase64EncoderMap[src.data2]; - FX_DWORD b = src.data1 << 4; - if (iBytes > 1) { - b |= src.data4; - } - dst[1] = g_FXBase64EncoderMap[b]; - if (iBytes > 1) { - b = src.data3 << 2; - if (iBytes > 2) { - b |= src.data6; - } - dst[2] = g_FXBase64EncoderMap[b]; - if (iBytes > 2) { - dst[3] = g_FXBase64EncoderMap[src.data5]; - } else { - dst[3] = '='; - } - } else { - dst[2] = dst[3] = '='; - } -} -int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst) { - FXSYS_assert(pSrc != NULL); - if (iSrcLen < 1) { - return 0; - } - if (pDst == NULL) { - int32_t iDstLen = iSrcLen / 3 * 4; - if ((iSrcLen % 3) != 0) { - iDstLen += 4; - } - return iDstLen; - } - FX_BASE64DATA srcData; - int32_t iBytes = 3; - FX_CHAR* pDstEnd = pDst; - while (iSrcLen > 0) { - if (iSrcLen > 2) { - ((uint8_t*)&srcData)[0] = *pSrc++; - ((uint8_t*)&srcData)[1] = *pSrc++; - ((uint8_t*)&srcData)[2] = *pSrc++; - iSrcLen -= 3; - } else { - *((FX_DWORD*)&srcData) = 0; - ((uint8_t*)&srcData)[0] = *pSrc++; - if (iSrcLen > 1) { - ((uint8_t*)&srcData)[1] = *pSrc++; - } - iBytes = iSrcLen; - iSrcLen = 0; - } - FX_Base64EncodePiece(srcData, iBytes, pDstEnd); - pDstEnd += 4; - } - return pDstEnd - pDst; -} - -static const uint8_t g_FXBase64DecoderMap[256] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, - 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, - 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, -}; -static void FX_Base64DecodePiece(const FX_CHAR src[4], - int32_t iChars, - FX_BASE64DATA& dst, - int32_t& iBytes) { - FXSYS_assert(iChars > 0 && iChars < 5); - iBytes = 1; - dst.data2 = g_FXBase64DecoderMap[(uint8_t)src[0]]; - if (iChars > 1) { - uint8_t b = g_FXBase64DecoderMap[(uint8_t)src[1]]; - dst.data1 = b >> 4; - dst.data4 = b; - if (iChars > 2) { - iBytes = 2; - b = g_FXBase64DecoderMap[(uint8_t)src[2]]; - dst.data3 = b >> 2; - dst.data6 = b; - if (iChars > 3) { - iBytes = 3; - dst.data5 = g_FXBase64DecoderMap[(uint8_t)src[3]]; - } else { - dst.data5 = 0; - } - } else { - dst.data3 = 0; - } - } else { - dst.data1 = 0; - } -} -int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) { - FXSYS_assert(pSrc != NULL); - if (iSrcLen < 1) { - return 0; - } - while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { - iSrcLen--; - } - if (iSrcLen < 1) { - return 0; - } - if (pDst == NULL) { - int32_t iDstLen = iSrcLen / 4 * 3; - iSrcLen %= 4; - if (iSrcLen == 1) { - iDstLen += 1; - } else if (iSrcLen == 2) { - iDstLen += 1; - } else if (iSrcLen == 3) { - iDstLen += 2; - } - return iDstLen; - } - FX_CHAR srcData[4]; - FX_BASE64DATA dstData; - int32_t iChars = 4, iBytes; - uint8_t* pDstEnd = pDst; - while (iSrcLen > 0) { - if (iSrcLen > 3) { - *((FX_DWORD*)srcData) = *((FX_DWORD*)pSrc); - pSrc += 4; - iSrcLen -= 4; - } else { - *((FX_DWORD*)&dstData) = 0; - *((FX_DWORD*)srcData) = 0; - srcData[0] = *pSrc++; - if (iSrcLen > 1) { - srcData[1] = *pSrc++; - } - if (iSrcLen > 2) { - srcData[2] = *pSrc++; - } - iChars = iSrcLen; - iSrcLen = 0; - } - FX_Base64DecodePiece(srcData, iChars, dstData, iBytes); - *pDstEnd++ = ((uint8_t*)&dstData)[0]; - if (iBytes > 1) { - *pDstEnd++ = ((uint8_t*)&dstData)[1]; - } - if (iBytes > 2) { - *pDstEnd++ = ((uint8_t*)&dstData)[2]; - } - } - return pDstEnd - pDst; -} -int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) { - FXSYS_assert(pSrc != NULL); - if (iSrcLen < 1) { - return 0; - } - while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { - iSrcLen--; - } - if (iSrcLen < 1) { - return 0; - } - if (pDst == NULL) { - int32_t iDstLen = iSrcLen / 4 * 3; - iSrcLen %= 4; - if (iSrcLen == 1) { - iDstLen += 1; - } else if (iSrcLen == 2) { - iDstLen += 1; - } else if (iSrcLen == 3) { - iDstLen += 2; - } - return iDstLen; - } - FX_CHAR srcData[4]; - FX_BASE64DATA dstData; - int32_t iChars = 4, iBytes; - uint8_t* pDstEnd = pDst; - while (iSrcLen > 0) { - if (iSrcLen > 3) { - srcData[0] = (FX_CHAR)*pSrc++; - srcData[1] = (FX_CHAR)*pSrc++; - srcData[2] = (FX_CHAR)*pSrc++; - srcData[3] = (FX_CHAR)*pSrc++; - iSrcLen -= 4; - } else { - *((FX_DWORD*)&dstData) = 0; - *((FX_DWORD*)srcData) = 0; - srcData[0] = (FX_CHAR)*pSrc++; - if (iSrcLen > 1) { - srcData[1] = (FX_CHAR)*pSrc++; - } - if (iSrcLen > 2) { - srcData[2] = (FX_CHAR)*pSrc++; - } - iChars = iSrcLen; - iSrcLen = 0; - } - FX_Base64DecodePiece(srcData, iChars, dstData, iBytes); - *pDstEnd++ = ((uint8_t*)&dstData)[0]; - if (iBytes > 1) { - *pDstEnd++ = ((uint8_t*)&dstData)[1]; - } - if (iBytes > 2) { - *pDstEnd++ = ((uint8_t*)&dstData)[2]; - } - } - return pDstEnd - pDst; -} - -static const uint8_t g_FXHex2DecMap[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, - 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, - 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; -uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow) { - return (g_FXHex2DecMap[hexHigh] << 4) + g_FXHex2DecMap[hexLow]; -} -int32_t FX_SeparateStringW(const FX_WCHAR* pStr, - int32_t iStrLen, - FX_WCHAR delimiter, - CFX_WideStringArray& pieces) { - if (pStr == NULL) { - return 0; - } - if (iStrLen < 0) { - iStrLen = FXSYS_wcslen(pStr); - } - const FX_WCHAR* pToken = pStr; - const FX_WCHAR* pEnd = pStr + iStrLen; - while (TRUE) { - if (pStr >= pEnd || delimiter == *pStr) { - CFX_WideString sub(pToken, pStr - pToken); - pieces.Add(sub); - pToken = pStr + 1; - if (pStr >= pEnd) { - break; - } - } - pStr++; - } - return pieces.GetSize(); -} -#ifdef __cplusplus -} -#endif diff --git a/xfa/src/fgas/crt/fgas_algorithm.h b/xfa/src/fgas/crt/fgas_algorithm.h deleted file mode 100644 index f819716820..0000000000 --- a/xfa/src/fgas/crt/fgas_algorithm.h +++ /dev/null @@ -1,54 +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_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ -#define XFA_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ - -#include <cstdint> - -#include "core/include/fxcrt/fx_basic.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); -int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); -int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); -uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); -int32_t FX_SeparateStringW(const FX_WCHAR* pStr, - int32_t iStrLen, - FX_WCHAR delimiter, - CFX_WideStringArray& pieces); -#ifdef __cplusplus -}; -#endif - -template <class baseType> -class CFX_DSPATemplate { - public: - int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { - FXSYS_assert(pArray != NULL); - if (iCount < 1) { - return -1; - } - int32_t iStart = 0, iEnd = iCount - 1, iMid; - do { - iMid = (iStart + iEnd) / 2; - const baseType& v = pArray[iMid]; - if (find == v) { - return iMid; - } else if (find < v) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return -1; - } -}; - -#endif // XFA_SRC_FGAS_CRT_FGAS_ALGORITHM_H_ diff --git a/xfa/src/fgas/crt/fgas_codepage.cpp b/xfa/src/fgas/crt/fgas_codepage.cpp deleted file mode 100644 index 622c4174bc..0000000000 --- a/xfa/src/fgas/crt/fgas_codepage.cpp +++ /dev/null @@ -1,343 +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/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fgas/crt/fgas_language.h" - -static const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { - {0, 1252}, {1, 0}, {2, 42}, {77, 10000}, {78, 10001}, - {79, 10003}, {80, 10008}, {81, 10002}, {83, 10005}, {84, 10004}, - {85, 10006}, {86, 10081}, {87, 10021}, {88, 10029}, {89, 10007}, - {128, 932}, {129, 949}, {130, 1361}, {134, 936}, {136, 950}, - {161, 1253}, {162, 1254}, {163, 1258}, {177, 1255}, {178, 1256}, - {186, 1257}, {204, 1251}, {222, 874}, {238, 1250}, {254, 437}, - {255, 850}, -}; -FX_WORD FX_GetCodePageFromCharset(uint8_t charset) { - int32_t iEnd = sizeof(g_FXCharset2CodePageTable) / sizeof(FX_CHARSET_MAP) - 1; - FXSYS_assert(iEnd >= 0); - int32_t iStart = 0, iMid; - do { - iMid = (iStart + iEnd) / 2; - const FX_CHARSET_MAP& cp = g_FXCharset2CodePageTable[iMid]; - if (charset == cp.charset) { - return cp.codepage; - } else if (charset < cp.charset) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return 0xFFFF; -} -static const FX_CHARSET_MAP g_FXCodepage2CharsetTable[] = { - {1, 0}, {2, 42}, {254, 437}, {255, 850}, {222, 874}, - {128, 932}, {134, 936}, {129, 949}, {136, 950}, {238, 1250}, - {204, 1251}, {0, 1252}, {161, 1253}, {162, 1254}, {177, 1255}, - {178, 1256}, {186, 1257}, {163, 1258}, {130, 1361}, {77, 10000}, - {78, 10001}, {79, 10003}, {80, 10008}, {81, 10002}, {83, 10005}, - {84, 10004}, {85, 10006}, {86, 10081}, {87, 10021}, {88, 10029}, - {89, 10007}, -}; -FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage) { - int32_t iEnd = sizeof(g_FXCodepage2CharsetTable) / sizeof(FX_CHARSET_MAP) - 1; - FXSYS_assert(iEnd >= 0); - int32_t iStart = 0, iMid; - do { - iMid = (iStart + iEnd) / 2; - const FX_CHARSET_MAP& cp = g_FXCodepage2CharsetTable[iMid]; - if (codepage == cp.codepage) { - return cp.charset; - } else if (codepage < cp.codepage) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return 0xFFFF; -} -const FX_LANG2CPMAP g_FXLang2CodepageTable[] = { - {FX_LANG_Arabic_SaudiArabia, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Bulgarian_Bulgaria, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Catalan_Catalan, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Chinese_Taiwan, FX_CODEPAGE_ChineseTraditional}, - {FX_LANG_CzechRepublic, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Danish_Denmark, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_German_Germany, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Greek_Greece, FX_CODEPAGE_MSWin_Greek}, - {FX_LANG_English_UnitedStates, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_TraditionalSort, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Finnish_Finland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_France, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Hebrew_Israel, FX_CODEPAGE_MSWin_Hebrew}, - {FX_LANG_Hungarian_Hungary, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Icelandic_Iceland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Italian_Italy, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Japanese_Japan, FX_CODEPAGE_ShiftJIS}, - {FX_LANG_Korean_Korea, FX_CODEPAGE_Korean}, - {FX_LANG_Dutch_Netherlands, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Norwegian_Bokmal, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Polish_Poland, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Portuguese_Brazil, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Romanian_Romania, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Russian_Russia, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Croatian_Croatia, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Slovak_Slovakia, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Albanian_Albania, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Swedish_Sweden, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Thai_Thailand, FX_CODEPAGE_MSDOS_Thai}, - {FX_LANG_Turkish_Turkey, FX_CODEPAGE_MSWin_Turkish}, - {FX_LANG_Urdu_Pakistan, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Indonesian_Indonesia, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Ukrainian_Ukraine, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Belarusian_Belarus, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Slovenian_Slovenia, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Estonian_Estonia, FX_CODEPAGE_MSWin_Baltic}, - {FX_LANG_Latvian_Latvia, FX_CODEPAGE_MSWin_Baltic}, - {FX_LANG_Lithuanian_Lithuania, FX_CODEPAGE_MSWin_Baltic}, - {FX_LANG_Persian, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Vietnamese_Vietnam, FX_CODEPAGE_MSWin_Vietnamese}, - {FX_LANG_Armenian_Armenia, FX_CODEPAGE_DefANSI}, - {FX_LANG_Azerbaijan_Latin, FX_CODEPAGE_MSWin_Turkish}, - {FX_LANG_Basque_Basque, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Macedonian, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Afrikaans_SouthAfrica, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Georgian_Georgia, FX_CODEPAGE_DefANSI}, - {FX_LANG_Faroese_FaroeIslands, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Hindi_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Malay_Malaysia, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Kazakh_Kazakhstan, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Kyrgyz_Kyrgyzstan, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Kiswahili_Kenya, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Uzbek_LatinUzbekistan, FX_CODEPAGE_MSWin_Turkish}, - {FX_LANG_Tatar_Russia, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Punjabi_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Gujarati_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Tamil_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Telugu_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Kannada_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Marathi_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_SanskritIndia, FX_CODEPAGE_DefANSI}, - {FX_LANG_Mongolian_CyrillicMongolia, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Galician_Galician, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Konkani_India, FX_CODEPAGE_DefANSI}, - {FX_LANG_Syriac_Syria, FX_CODEPAGE_DefANSI}, - {FX_LANG_Divehi_Maldives, FX_CODEPAGE_DefANSI}, - {FX_LANG_Arabic_Iraq, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Chinese_PRC, FX_CODEPAGE_ChineseSimplified}, - {FX_LANG_German_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_English_UnitedKingdom, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Mexico, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_Belgium, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Italian_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Dutch_Belgium, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Norwegian_Nynorsk, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Portuguese_Portugal, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_SerbianLatin_Serbia, FX_CODEPAGE_MSWin_EasternEuropean}, - {FX_LANG_Swedish_Finland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Azerbaijan_Cyrillic, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Malay_BruneiDarussalam, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Uzbek_CyrillicUzbekistan, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Arabic_Egypt, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Chinese_HongKong, FX_CODEPAGE_ChineseTraditional}, - {FX_LANG_German_Austria, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_English_Australia, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_InternationalSort, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_Canada, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_SerbianCyrillic_Serbia, FX_CODEPAGE_MSWin_Cyrillic}, - {FX_LANG_Arabic_Libya, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Chinese_Singapore, FX_CODEPAGE_ChineseSimplified}, - {FX_LANG_German_Luxembourg, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_English_Canada, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Guatemala, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_Switzerland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Algeria, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Chinese_Macao, FX_CODEPAGE_ChineseTraditional}, - {FX_LANG_German_Liechtenstein, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_English_NewZealand, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_CostaRica, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_Luxembourg, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Morocco, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Ireland, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Panama, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_French_Monaco, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Tunisia, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_SouthAfrica, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_DominicanRepublic, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Oman, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Jamaica, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Venezuela, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Yemen, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Caribbean, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Colombia, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Syria, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Belize, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Peru, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Jordan, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_TrinidadTobago, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Argentina, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Lebanon, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Zimbabwe, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Ecuador, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Kuwait, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_English_Philippines, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Chile, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_UAE, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Spanish_Uruguay, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Bahrain, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Spanish_Paraguay, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Arabic_Qatar, FX_CODEPAGE_MSWin_Arabic}, - {FX_LANG_Spanish_Bolivia, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_ElSalvador, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Honduras, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_Nicaragua, FX_CODEPAGE_MSWin_WesternEuropean}, - {FX_LANG_Spanish_PuertoRico, FX_CODEPAGE_MSWin_WesternEuropean}, -}; -FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage) { - int32_t iEnd = sizeof(g_FXLang2CodepageTable) / sizeof(FX_LANG2CPMAP) - 1; - FXSYS_assert(iEnd >= 0); - int32_t iStart = 0, iMid; - do { - iMid = (iStart + iEnd) / 2; - const FX_LANG2CPMAP& cp = g_FXLang2CodepageTable[iMid]; - if (wLanguage == cp.wLanguage) { - return cp.wCodepage; - } else if (wLanguage < cp.wLanguage) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return 0xFFFF; -} -static const FX_STR2CPHASH g_FXCPHashTable[] = { - {0xd45, 0x6faf}, {0xd46, 0x6fb0}, {0xd47, 0x6fb1}, - {0xd48, 0x6fb2}, {0xd49, 0x4e6}, {0xd4d, 0x6fbd}, - {0xe9e, 0x4e4}, {0xc998, 0x1b5}, {0x18ef0, 0x3a8}, - {0x19f85, 0x5182}, {0x2e2335, 0x3b6}, {0x325153, 0x5182}, - {0x145bded, 0x2716}, {0x3c9a5f2, 0xc6f3}, {0x4c45f2d, 0x3a4}, - {0x4c45f4e, 0xc431}, {0x58caf51, 0x4e4}, {0x5a5cd7d, 0x3a8}, - {0x5a6c6a7, 0x4e4}, {0x5a6ca0b, 0x1b5}, {0x5a6cd68, 0x307}, - {0x5a6d8d3, 0x4e4}, {0x5a6d948, 0x354}, {0x5a6d96b, 0x362}, - {0x5a6d984, 0x366}, {0x5a90e35, 0x1b5}, {0x5e0cf00, 0x6fb5}, - {0x609c324, 0x551}, {0x617d97f, 0x5182}, {0x6a6fd91, 0xfde8}, - {0x6a6fd92, 0xfde9}, {0x6b102de, 0xcadc}, {0x6b10f48, 0x4e89}, - {0x1020805f, 0x4e4}, {0x10f0524c, 0x6fb5}, {0x11d558fe, 0x6fb0}, - {0x13898d19, 0xc42d}, {0x13898d3a, 0xc431}, {0x138a319e, 0x6fb1}, - {0x14679c09, 0x96c6}, {0x153f0a3d, 0x6fb2}, {0x1576eeb3, 0x4e20}, - {0x169a0ce6, 0xc6f9}, {0x16f3e2dc, 0x6fb3}, {0x18a8bb7a, 0x6fb4}, - {0x1a5d9419, 0x6fb5}, {0x1a847b48, 0x3a8}, {0x1b762419, 0xcec8}, - {0x1b9d7847, 0x475}, {0x1c126cb9, 0x6fb6}, {0x1ccdbc7d, 0x4f42}, - {0x1d330f5f, 0x2714}, {0x1dc74559, 0x4e6}, {0x1edd80da, 0x4e4}, - {0x23e4b03d, 0xfde8}, {0x24f28a16, 0x4f3d}, {0x286e7a32, 0x2715}, - {0x2c7c18ed, 0x3a8}, {0x2e2103b7, 0x2713}, {0x304bf479, 0x6fb4}, - {0x304bf47d, 0x6fb5}, {0x309bb869, 0xfde8}, {0x309bb86a, 0xfde9}, - {0x33664357, 0x3b6}, {0x352d6b49, 0x3a4}, {0x36f5661c, 0x1b5}, - {0x392e8f48, 0xcadc}, {0x3dc7c64c, 0x47c}, {0x3ed2e8e1, 0x4e4}, - {0x3f0c2fea, 0xcaed}, {0x3f0fef8f, 0xc6f2}, {0x3f5e130f, 0x5182}, - {0x47174d1f, 0x3a8}, {0x49686b7b, 0x6fb4}, {0x4b80b0d9, 0x3a4}, - {0x4dcda97a, 0x4e4}, {0x4dcda9b6, 0x4e4}, {0x4e881e6a, 0x5221}, - {0x4ffdf5a1, 0x36a}, {0x4ffdf5a5, 0x6fbd}, {0x5241ce16, 0x4e8b}, - {0x546bab9d, 0x4e4}, {0x54a3d64e, 0x6fb6}, {0x562179bd, 0x5161}, - {0x57c1df15, 0xc6f7}, {0x61ff6e62, 0x4f36}, {0x6359c7d8, 0x4f35}, - {0x63f3c335, 0x3a8}, {0x645a0f78, 0x477}, {0x691ac2fd, 0x275f}, - {0x6dc2eab0, 0x2d0}, {0x6dc2eeef, 0x35e}, {0x6dc2ef10, 0x36a}, - {0x7103138a, 0x47d}, {0x710dfbd0, 0xc6f5}, {0x7319f6cb, 0x36a}, - {0x745096ad, 0x3a8}, {0x74866229, 0x4e8c}, {0x77185fa5, 0x3a8}, - {0x7953f002, 0x6faf}, {0x7953f003, 0x6fb0}, {0x7953f004, 0x6fb1}, - {0x7953f005, 0x6fb2}, {0x7953f006, 0x6fb7}, {0x7953f00a, 0x6fbd}, - {0x7c577571, 0x2761}, {0x7e8c8ff1, 0x479}, {0x8031f47f, 0x3b5}, - {0x8031f481, 0x3b5}, {0x80c4a710, 0x5187}, {0x857c7e14, 0xfde8}, - {0x857c7e15, 0xfde9}, {0x86b59c90, 0x4e4}, {0x86b59c91, 0x6fb0}, - {0x86b59c92, 0x6fb1}, {0x86b59c93, 0x6fb2}, {0x86b59c94, 0x6fb3}, - {0x86b59c95, 0x6fb4}, {0x86b59c96, 0x6fb5}, {0x86b59c97, 0x4e7}, - {0x86b59c98, 0x4e6}, {0x8b4b24ec, 0x5190}, {0x8face362, 0x4e4}, - {0x8ff9ec2a, 0xfde9}, {0x919d3989, 0xcadc}, {0x9967e5ad, 0x4e22}, - {0x99f8b933, 0x6fbd}, {0x9bd2a380, 0x4fc7}, {0x9befad23, 0x4f38}, - {0x9c7ac649, 0x4f3c}, {0xa02468db, 0xdeae}, {0xa02468ec, 0xdeab}, - {0xa024692a, 0xdeaa}, {0xa0246997, 0xdeb2}, {0xa02469ff, 0xdeb0}, - {0xa0246a3d, 0xdeb1}, {0xa0246a8c, 0xdeaf}, {0xa0246a9a, 0xdeb3}, - {0xa0246b16, 0xdeac}, {0xa0246b1a, 0xdead}, {0xa071addc, 0x4b1}, - {0xa38b62dc, 0x474}, {0xa4c09fed, 0x3a8}, {0xa51e86e5, 0x4e7}, - {0xa67ab13e, 0x3a4}, {0xa7414244, 0x51a9}, {0xa9ddbead, 0xc6fb}, - {0xab24ffab, 0x4e8a}, {0xabef8ac4, 0x2710}, {0xabfa20ac, 0x6fb4}, - {0xad36895e, 0x4e2}, {0xad36895f, 0x4e3}, {0xaf310e90, 0x402}, - {0xaf31166f, 0x4e8}, {0xaf7277a5, 0x3b6}, {0xafc0d8b3, 0x96c6}, - {0xb0fd5dba, 0xcae0}, {0xb0fd5e95, 0xcadc}, {0xb1052893, 0x7149}, - {0xb1e98745, 0x36a}, {0xb277e91c, 0x5166}, {0xb2f7eac5, 0xcae0}, - {0xb2f7eba0, 0xcadc}, {0xb2f7ebc1, 0x3b5}, {0xb53fa77d, 0x3a8}, - {0xb6391138, 0x6fb5}, {0xb7358b7f, 0x6fb6}, {0xb8c42b40, 0x4e4}, - {0xb8c42ea4, 0x1b5}, {0xb8c439e7, 0x2e1}, {0xb8c43a61, 0x307}, - {0xb8c43d6c, 0x4e4}, {0xb8c43ddf, 0x352}, {0xb8c43de1, 0x354}, - {0xb8c43de6, 0x359}, {0xb8c43dff, 0x35d}, {0xb8c43e04, 0x362}, - {0xb8c43e07, 0x365}, {0xbcd29a7f, 0x3a8}, {0xbce34e78, 0x5182}, - {0xbce34e7b, 0x556a}, {0xbce81504, 0x3b5}, {0xbd8a4c95, 0x272d}, - {0xbdd89dad, 0x4e4}, {0xbdd89dae, 0x6fb0}, {0xbdd89daf, 0x6fb1}, - {0xbdd89db0, 0x6fb2}, {0xbdd89db1, 0x4e6}, {0xbdd89db5, 0x6fbd}, - {0xc1756e9f, 0x36b}, {0xc7482444, 0x47a}, {0xc9281c18, 0x4e4}, - {0xc9ef95df, 0x47b}, {0xccc9db0d, 0x4e4}, {0xccc9db0e, 0x6fb0}, - {0xcd73425f, 0x3b6}, {0xce38b40b, 0x4b0}, {0xce99e549, 0x25}, - {0xcf598740, 0x4e7}, {0xcf6d6f78, 0x4e4}, {0xcf758df6, 0x3a4}, - {0xd1266e51, 0x6fb5}, {0xd2910213, 0x2718}, {0xd29196bb, 0x2712}, - {0xd3eb2fc2, 0x476}, {0xd442dc2c, 0x4fc4}, {0xd9da4da4, 0x2711}, - {0xdbad2f42, 0x4e4}, {0xdbad2f43, 0x6fb0}, {0xdbad2f44, 0x6fb1}, - {0xdbad2f45, 0x6fb2}, {0xdbad2f46, 0x6fb3}, {0xdbad2f47, 0x6fb4}, - {0xdbad2f48, 0x6fb5}, {0xdbad2f49, 0x6fb6}, {0xdbad2f4a, 0x4e6}, - {0xdc438033, 0x4f31}, {0xdccb439b, 0x477}, {0xdccdc626, 0x3b5}, - {0xdd80a595, 0x4e4}, {0xdd80a596, 0x6fb0}, {0xdd80a59e, 0x6fb1}, - {0xdd80a5b4, 0x6fb2}, {0xdd80a5d9, 0x6fb5}, {0xdd80a5da, 0x6fb4}, - {0xdd80a5fa, 0x6fb6}, {0xdd80a615, 0x6fb3}, {0xdd80a619, 0x4e6}, - {0xdd80a61a, 0x3b5}, {0xdd80c0f8, 0x4e9f}, {0xdf7e46ff, 0x4fc8}, - {0xdf8680fd, 0x556a}, {0xdfb0bd6e, 0xc42d}, {0xdff05486, 0x2c4}, - {0xe3323399, 0x3a4}, {0xe60412dd, 0x3b5}, {0xeee47add, 0x4b0}, - {0xf021a186, 0x4e2}, {0xf021a187, 0x4e3}, {0xf021a188, 0x4e4}, - {0xf021a189, 0x4e5}, {0xf021a18a, 0x4e6}, {0xf021a18b, 0x4e7}, - {0xf021a18c, 0x4e8}, {0xf021a18d, 0x4e9}, {0xf021a18e, 0x4ea}, - {0xf0700456, 0x6fb3}, {0xf274f175, 0x3b5}, {0xf2a9730b, 0x3a8}, - {0xf3d463c2, 0x3a4}, {0xf52a70a3, 0xc42e}, {0xf5693147, 0x6fb3}, - {0xf637e157, 0x478}, {0xfc213f3a, 0x2717}, {0xff654d14, 0x3b5}, -}; -FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) { - FXSYS_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; - int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1; - FXSYS_assert(iEnd >= 0); - do { - iMid = (iStart + iEnd) / 2; - const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid]; - if (uHash == cp.uHash) { - return (FX_WORD)cp.uCodePage; - } else if (uHash < cp.uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return 0xFFFF; -} -FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength) { - if (iLength < 0) { - iLength = FXSYS_wcslen(pStr); - } - if (iLength == 0) { - return 0xFFFF; - } - CFX_ByteString csStr; - FX_CHAR* pBuf = csStr.GetBuffer(iLength + 1); - for (int32_t i = 0; i < iLength; ++i) { - *pBuf++ = (FX_CHAR)*pStr++; - } - csStr.ReleaseBuffer(iLength); - return FX_GetCodePageFromStringA(csStr, iLength); -} diff --git a/xfa/src/fgas/crt/fgas_codepage.h b/xfa/src/fgas/crt/fgas_codepage.h deleted file mode 100644 index e9111d1ec4..0000000000 --- a/xfa/src/fgas/crt/fgas_codepage.h +++ /dev/null @@ -1,179 +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_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ -#define XFA_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ - -#include "core/include/fxcrt/fx_basic.h" - -#define FX_CODEPAGE_DefANSI 0 -#define FX_CODEPAGE_DefOEM 1 -#define FX_CODEPAGE_DefMAC 2 -#define FX_CODEPAGE_Thread 3 -#define FX_CODEPAGE_Symbol 42 -#define FX_CODEPAGE_MSDOS_US 437 -#define FX_CODEPAGE_Arabic_ASMO708 708 -#define FX_CODEPAGE_Arabic_ASMO449Plus 709 -#define FX_CODEPAGE_Arabic_Transparent 710 -#define FX_CODEPAGE_Arabic_NafithaEnhanced 711 -#define FX_CODEPAGE_Arabic_TransparentASMO 720 -#define FX_CODEPAGE_MSDOS_Greek1 737 -#define FX_CODEPAGE_MSDOS_Baltic 775 -#define FX_CODEPAGE_MSWin31_WesternEuropean 819 -#define FX_CODEPAGE_MSDOS_WesternEuropean 850 -#define FX_CODEPAGE_MSDOS_EasternEuropean 852 -#define FX_CODEPAGE_MSDOS_Latin3 853 -#define FX_CODEPAGE_MSDOS_Cyrillic 855 -#define FX_CODEPAGE_MSDOS_Turkish 857 -#define FX_CODEPAGE_MSDOS_Latin1Euro 858 -#define FX_CODEPAGE_MSDOS_Portuguese 860 -#define FX_CODEPAGE_MSDOS_Icelandic 861 -#define FX_CODEPAGE_MSDOS_Hebrew 862 -#define FX_CODEPAGE_MSDOS_FrenchCanadian 863 -#define FX_CODEPAGE_MSDOS_Arabic 864 -#define FX_CODEPAGE_MSDOS_Norwegian 865 -#define FX_CODEPAGE_MSDOS_Russian 866 -#define FX_CODEPAGE_MSDOS_Greek2 869 -#define FX_CODEPAGE_MSDOS_Thai 874 -#define FX_CODEPAGE_MSDOS_KamenickyCS 895 -#define FX_CODEPAGE_ShiftJIS 932 -#define FX_CODEPAGE_ChineseSimplified 936 -#define FX_CODEPAGE_Korean 949 -#define FX_CODEPAGE_ChineseTraditional 950 -#define FX_CODEPAGE_UTF16LE 1200 -#define FX_CODEPAGE_UTF16BE 1201 -#define FX_CODEPAGE_MSWin_EasternEuropean 1250 -#define FX_CODEPAGE_MSWin_Cyrillic 1251 -#define FX_CODEPAGE_MSWin_WesternEuropean 1252 -#define FX_CODEPAGE_MSWin_Greek 1253 -#define FX_CODEPAGE_MSWin_Turkish 1254 -#define FX_CODEPAGE_MSWin_Hebrew 1255 -#define FX_CODEPAGE_MSWin_Arabic 1256 -#define FX_CODEPAGE_MSWin_Baltic 1257 -#define FX_CODEPAGE_MSWin_Vietnamese 1258 -#define FX_CODEPAGE_Johab 1361 -#define FX_CODEPAGE_MAC_Roman 10000 -#define FX_CODEPAGE_MAC_ShiftJIS 10001 -#define FX_CODEPAGE_MAC_ChineseTraditional 10002 -#define FX_CODEPAGE_MAC_Korean 10003 -#define FX_CODEPAGE_MAC_Arabic 10004 -#define FX_CODEPAGE_MAC_Hebrew 10005 -#define FX_CODEPAGE_MAC_Greek 10006 -#define FX_CODEPAGE_MAC_Cyrillic 10007 -#define FX_CODEPAGE_MAC_ChineseSimplified 10008 -#define FX_CODEPAGE_MAC_Thai 10021 -#define FX_CODEPAGE_MAC_EasternEuropean 10029 -#define FX_CODEPAGE_MAC_Turkish 10081 -#define FX_CODEPAGE_UTF32LE 12000 -#define FX_CODEPAGE_UTF32BE 12001 -#define FX_CODEPAGE_ISO8859_1 28591 -#define FX_CODEPAGE_ISO8859_2 28592 -#define FX_CODEPAGE_ISO8859_3 28593 -#define FX_CODEPAGE_ISO8859_4 28594 -#define FX_CODEPAGE_ISO8859_5 28595 -#define FX_CODEPAGE_ISO8859_6 28596 -#define FX_CODEPAGE_ISO8859_7 28597 -#define FX_CODEPAGE_ISO8859_8 28598 -#define FX_CODEPAGE_ISO8859_9 28599 -#define FX_CODEPAGE_ISO8859_10 28600 -#define FX_CODEPAGE_ISO8859_11 28601 -#define FX_CODEPAGE_ISO8859_12 28602 -#define FX_CODEPAGE_ISO8859_13 28603 -#define FX_CODEPAGE_ISO8859_14 28604 -#define FX_CODEPAGE_ISO8859_15 28605 -#define FX_CODEPAGE_ISO8859_16 28606 -#define FX_CODEPAGE_ISCII_Devanagari 57002 -#define FX_CODEPAGE_ISCII_Bengali 57003 -#define FX_CODEPAGE_ISCII_Tamil 57004 -#define FX_CODEPAGE_ISCII_Telugu 57005 -#define FX_CODEPAGE_ISCII_Assamese 57006 -#define FX_CODEPAGE_ISCII_Oriya 57007 -#define FX_CODEPAGE_ISCII_Kannada 57008 -#define FX_CODEPAGE_ISCII_Malayalam 57009 -#define FX_CODEPAGE_ISCII_Gujarati 57010 -#define FX_CODEPAGE_ISCII_Punjabi 57011 -#define FX_CODEPAGE_UTF7 65000 -#define FX_CODEPAGE_UTF8 65001 -#define FX_CHARSET_ANSI 0 -#define FX_CHARSET_Default 1 -#define FX_CHARSET_Symbol 2 -#define FX_CHARSET_MAC_Roman 77 -#define FX_CHARSET_MAC_ShiftJIS 78 -#define FX_CHARSET_MAC_Korean 79 -#define FX_CHARSET_MAC_ChineseSimplified 80 -#define FX_CHARSET_MAC_ChineseTriditional 81 -#define FX_CHARSET_MAC_Johab 82 -#define FX_CHARSET_MAC_Hebrew 83 -#define FX_CHARSET_MAC_Arabic 84 -#define FX_CHARSET_MAC_Greek 85 -#define FX_CHARSET_MAC_Turkish 86 -#define FX_CHARSET_MAC_Thai 87 -#define FX_CHARSET_MAC_EasternEuropean 88 -#define FX_CHARSET_MAC_Cyrillic 89 -#define FX_CHARSET_ShiftJIS 128 -#define FX_CHARSET_Korean 129 -#define FX_CHARSET_Johab 130 -#define FX_CHARSET_ChineseSimplified 134 -#define FX_CHARSET_ChineseTriditional 136 -#define FX_CHARSET_MSWin_Greek 161 -#define FX_CHARSET_MSWin_Turkish 162 -#define FX_CHARSET_MSWin_Vietnamese 163 -#define FX_CHARSET_MSWin_Hebrew 177 -#define FX_CHARSET_MSWin_Arabic 178 -#define FX_CHARSET_ArabicTraditional 179 -#define FX_CHARSET_ArabicUser 180 -#define FX_CHARSET_HebrewUser 181 -#define FX_CHARSET_MSWin_Baltic 186 -#define FX_CHARSET_MSWin_Cyrillic 204 -#define FX_CHARSET_Thai 222 -#define FX_CHARSET_MSWin_EasterEuropean 238 -#define FX_CHARSET_US 254 -#define FX_CHARSET_OEM 255 - -FX_WORD FX_GetCodePageFromCharset(uint8_t charset); -FX_WORD FX_GetCharsetFromCodePage(FX_WORD codepage); -FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength); -FX_WORD FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength); -FX_WORD FX_GetDefCodePageByLanguage(FX_WORD wLanguage); -void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength); -void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc, - FX_WCHAR* pDst, - int32_t iLength); -void FX_UTF16ToWChar(void* pBuffer, int32_t iLength); -void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16, - FX_WCHAR* pWChar, - int32_t iLength); -void FX_WCharToUTF16(void* pBuffer, int32_t iLength); -void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar, - FX_WORD* pUTF16, - int32_t iLength); -int32_t FX_DecodeString(FX_WORD wCodePage, - const FX_CHAR* pSrc, - int32_t* pSrcLen, - FX_WCHAR* pDst, - int32_t* pDstLen, - FX_BOOL bErrBreak = FALSE); -int32_t FX_UTF8Decode(const FX_CHAR* pSrc, - int32_t* pSrcLen, - FX_WCHAR* pDst, - int32_t* pDstLen); - -struct FX_STR2CPHASH { - uint32_t uHash; - uint32_t uCodePage; -}; - -struct FX_CHARSET_MAP { - uint16_t charset; - uint16_t codepage; -}; - -struct FX_LANG2CPMAP { - FX_WORD wLanguage; - FX_WORD wCodepage; -}; - -#endif // XFA_SRC_FGAS_CRT_FGAS_CODEPAGE_H_ diff --git a/xfa/src/fgas/crt/fgas_encode.cpp b/xfa/src/fgas/crt/fgas_encode.cpp deleted file mode 100644 index 564ccf63c4..0000000000 --- a/xfa/src/fgas/crt/fgas_encode.cpp +++ /dev/null @@ -1,193 +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/src/fgas/crt/fgas_codepage.h" - -void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) { - FXSYS_assert(pStr != NULL); - if (iLength < 0) { - iLength = FXSYS_wcslen(pStr); - } - FX_WORD wch; - if (sizeof(FX_WCHAR) > 2) { - while (iLength-- > 0) { - wch = (FX_WORD)*pStr; - wch = (wch >> 8) | (wch << 8); - wch &= 0x00FF; - *pStr++ = wch; - } - } else { - while (iLength-- > 0) { - wch = (FX_WORD)*pStr; - wch = (wch >> 8) | (wch << 8); - *pStr++ = wch; - } - } -} -void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc, - FX_WCHAR* pDst, - int32_t iLength) { - FXSYS_assert(pSrc != NULL && pDst != NULL); - if (iLength < 0) { - iLength = FXSYS_wcslen(pSrc); - } - FX_WORD wch; - if (sizeof(FX_WCHAR) > 2) { - while (iLength-- > 0) { - wch = (FX_WORD)*pSrc++; - wch = (wch >> 8) | (wch << 8); - wch &= 0x00FF; - *pDst++ = wch; - } - } else { - while (iLength-- > 0) { - wch = (FX_WORD)*pSrc++; - wch = (wch >> 8) | (wch << 8); - *pDst++ = wch; - } - } -} -void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) { - FXSYS_assert(pBuffer != NULL && iLength > 0); - if (sizeof(FX_WCHAR) == 2) { - return; - } - FX_WORD* pSrc = (FX_WORD*)pBuffer; - FX_WCHAR* pDst = (FX_WCHAR*)pBuffer; - while (--iLength >= 0) { - pDst[iLength] = (FX_WCHAR)pSrc[iLength]; - } -} -void FX_UTF16ToWCharCopy(const FX_WORD* pUTF16, - FX_WCHAR* pWChar, - int32_t iLength) { - FXSYS_assert(pUTF16 != NULL && pWChar != NULL && iLength > 0); - if (sizeof(FX_WCHAR) == 2) { - FXSYS_memcpy(pWChar, pUTF16, iLength * sizeof(FX_WCHAR)); - } else { - while (--iLength >= 0) { - pWChar[iLength] = (FX_WCHAR)pUTF16[iLength]; - } - } -} -void FX_WCharToUTF16(void* pBuffer, int32_t iLength) { - FXSYS_assert(pBuffer != NULL && iLength > 0); - if (sizeof(FX_WCHAR) == 2) { - return; - } - const FX_WCHAR* pSrc = (const FX_WCHAR*)pBuffer; - FX_WORD* pDst = (FX_WORD*)pBuffer; - while (--iLength >= 0) { - *pDst++ = (FX_WORD)*pSrc++; - } -} -void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar, - FX_WORD* pUTF16, - int32_t iLength) { - FXSYS_assert(pWChar != NULL && pUTF16 != NULL && iLength > 0); - if (sizeof(FX_WCHAR) == 2) { - FXSYS_memcpy(pUTF16, pWChar, iLength * sizeof(FX_WCHAR)); - } else { - while (--iLength >= 0) { - *pUTF16++ = (FX_WORD)*pWChar++; - } - } -} -inline FX_DWORD FX_DWordFromBytes(const uint8_t* pStr) { - return FXBSTR_ID(pStr[3], pStr[2], pStr[1], pStr[0]); -} -inline FX_WORD FX_WordFromBytes(const uint8_t* pStr) { - return (pStr[1] << 8 | pStr[0]); -} -int32_t FX_DecodeString(FX_WORD wCodePage, - const FX_CHAR* pSrc, - int32_t* pSrcLen, - FX_WCHAR* pDst, - int32_t* pDstLen, - FX_BOOL bErrBreak) { - if (wCodePage == FX_CODEPAGE_UTF8) { - return FX_UTF8Decode(pSrc, pSrcLen, pDst, pDstLen); - } - return -1; -} -int32_t FX_UTF8Decode(const FX_CHAR* pSrc, - int32_t* pSrcLen, - FX_WCHAR* pDst, - int32_t* pDstLen) { - if (pSrcLen == NULL || pDstLen == NULL) { - return -1; - } - int32_t iSrcLen = *pSrcLen; - if (iSrcLen < 1) { - *pSrcLen = *pDstLen = 0; - return 1; - } - int32_t iDstLen = *pDstLen; - FX_BOOL bValidDst = (pDst != NULL && iDstLen > 0); - FX_DWORD dwCode = 0; - int32_t iPending = 0; - int32_t iSrcNum = 0, iDstNum = 0; - int32_t k = 0; - int32_t iIndex = 0; - k = 1; - while (iIndex < iSrcLen) { - uint8_t byte = (uint8_t) * (pSrc + iIndex); - if (byte < 0x80) { - iPending = 0; - k = 1; - iDstNum++; - iSrcNum += k; - if (bValidDst) { - *pDst++ = byte; - if (iDstNum >= iDstLen) { - break; - } - } - } else if (byte < 0xc0) { - if (iPending < 1) { - break; - } - iPending--; - dwCode |= (byte & 0x3f) << (iPending * 6); - if (iPending == 0) { - iDstNum++; - iSrcNum += k; - if (bValidDst) { - *pDst++ = dwCode; - if (iDstNum >= iDstLen) { - break; - } - } - } - } else if (byte < 0xe0) { - iPending = 1; - k = 2; - dwCode = (byte & 0x1f) << 6; - } else if (byte < 0xf0) { - iPending = 2; - k = 3; - dwCode = (byte & 0x0f) << 12; - } else if (byte < 0xf8) { - iPending = 3; - k = 4; - dwCode = (byte & 0x07) << 18; - } else if (byte < 0xfc) { - iPending = 4; - k = 5; - dwCode = (byte & 0x03) << 24; - } else if (byte < 0xfe) { - iPending = 5; - k = 6; - dwCode = (byte & 0x01) << 30; - } else { - break; - } - iIndex++; - } - *pSrcLen = iSrcNum; - *pDstLen = iDstNum; - return 1; -} diff --git a/xfa/src/fgas/crt/fgas_language.h b/xfa/src/fgas/crt/fgas_language.h deleted file mode 100644 index 15f32e1379..0000000000 --- a/xfa/src/fgas/crt/fgas_language.h +++ /dev/null @@ -1,269 +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_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ -#define XFA_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ - -#define FX_LANG_Neutral 0x0000 -#define FX_LANG_Invariant 0x007f -#define FX_LANG_UserDefault 0x0400 -#define FX_LANG_SystemDefault 0x0800 -#define FX_LANG_Afrikaans_SouthAfrica 0x0436 -#define FX_LANG_Albanian_Albania 0x041c -#define FX_LANG_Alsatian_France 0x0484 -#define FX_LANG_Amharic_Ethiopia 0x045e -#define FX_LANG_Arabic_Algeria 0x1401 -#define FX_LANG_Arabic_Bahrain 0x3c01 -#define FX_LANG_Arabic_Egypt 0x0c01 -#define FX_LANG_Arabic_Iraq 0x0801 -#define FX_LANG_Arabic_Jordan 0x2c01 -#define FX_LANG_Arabic_Kuwait 0x3401 -#define FX_LANG_Arabic_Lebanon 0x3001 -#define FX_LANG_Arabic_Libya 0x1001 -#define FX_LANG_Arabic_Morocco 0x1801 -#define FX_LANG_Arabic_Oman 0x2001 -#define FX_LANG_Arabic_Qatar 0x4001 -#define FX_LANG_Arabic_SaudiArabia 0x0401 -#define FX_LANG_Arabic_Syria 0x2801 -#define FX_LANG_Arabic_Tunisia 0x1c01 -#define FX_LANG_Arabic_UAE 0x3801 -#define FX_LANG_Arabic_Yemen 0x2401 -#define FX_LANG_Armenian_Armenia 0x042b -#define FX_LANG_Assamese_India 0x044d -#define FX_LANG_Azerbaijan_Cyrillic 0x082c -#define FX_LANG_Azerbaijan_Latin 0x042c -#define FX_LANG_Bashkir_Russia 0x046d -#define FX_LANG_Basque_Basque 0x042d -#define FX_LANG_Belarusian_Belarus 0x0423 -#define FX_LANG_Bengali_Bangladesh 0x0845 -#define FX_LANG_Bengali_India 0x0445 -#define FX_LANG_Bosnia_Herzegovina 0x101a -#define FX_LANG_Bosnian_Cyrillic 0x201a -#define FX_LANG_Bosnian_Latin 0x141a -#define FX_LANG_Breton_France 0x047e -#define FX_LANG_Bulgarian_Bulgaria 0x0402 -#define FX_LANG_Burmese 0x0455 -#define FX_LANG_Catalan_Catalan 0x0403 -#define FX_LANG_Cherokee 0x045c -#define FX_LANG_Chinese_HongKong 0x0c04 -#define FX_LANG_Chinese_Macao 0x1404 -#define FX_LANG_Chinese_PRC 0x0804 -#define FX_LANG_Chinese_Singapore 0x1004 -#define FX_LANG_Chinese_Taiwan 0x0404 -#define FX_LANG_Corsican_France 0x0483 -#define FX_LANG_Croatian_Croatia 0x041a -#define FX_LANG_Croatian_Latin 0x101a -#define FX_LANG_CustomCurrent 0x0c00 -#define FX_LANG_CzechRepublic 0x0405 -#define FX_LANG_Danish_Denmark 0x0406 -#define FX_LANG_Dari_Afghanistan 0x048c -#define FX_LANG_Divehi_Maldives 0x0465 -#define FX_LANG_Dutch_Belgium 0x0813 -#define FX_LANG_Dutch_Netherlands 0x0413 -#define FX_LANG_Dutch_Preferred 0x0013 -#define FX_LANG_Dzongkha 0x0851 -#define FX_LANG_Edo 0x0466 -#define FX_LANG_English_Australia 0x0c09 -#define FX_LANG_English_Belize 0x2809 -#define FX_LANG_English_Canada 0x1009 -#define FX_LANG_English_Caribbean 0x2409 -#define FX_LANG_English_HongKong 0x3c09 -#define FX_LANG_English_India 0x4009 -#define FX_LANG_English_Indonesia 0x3809 -#define FX_LANG_English_Ireland 0x1809 -#define FX_LANG_English_Jamaica 0x2009 -#define FX_LANG_English_Malaysia 0x4409 -#define FX_LANG_English_NewZealand 0x1409 -#define FX_LANG_English_Philippines 0x3409 -#define FX_LANG_English_Singapore 0x4809 -#define FX_LANG_English_SouthAfrica 0x1c09 -#define FX_LANG_English_TrinidadTobago 0x2c09 -#define FX_LANG_English_UnitedKingdom 0x0809 -#define FX_LANG_English_UnitedStates 0x0409 -#define FX_LANG_English_Zimbabwe 0x3009 -#define FX_LANG_Estonian_Estonia 0x0425 -#define FX_LANG_Faroese_FaroeIslands 0x0438 -#define FX_LANG_Filipino_Philippines 0x0464 -#define FX_LANG_Finnish_Finland 0x040b -#define FX_LANG_French_Belgium 0x080c -#define FX_LANG_French_Cameroon 0x2c0c -#define FX_LANG_French_Canada 0x0c0c -#define FX_LANG_French_CongoDRC 0x240c -#define FX_LANG_French_CotedIvoire 0x300c -#define FX_LANG_French_France 0x040c -#define FX_LANG_French_Haiti 0x3c0c -#define FX_LANG_French_Luxembourg 0x140c -#define FX_LANG_French_Mali 0x340c -#define FX_LANG_French_Monaco 0x180c -#define FX_LANG_French_Morocco 0x380c -#define FX_LANG_French_Reunion 0x200c -#define FX_LANG_French_Senegal 0x280c -#define FX_LANG_French_Switzerland 0x100c -#define FX_LANG_French_WestIndies 0x1c0c -#define FX_LANG_Frisian_Netherlands 0x0462 -#define FX_LANG_Fulfulde 0x0467 -#define FX_LANG_Gaelic_Ireland 0x083c -#define FX_LANG_Gaelic_Scotland 0x043c -#define FX_LANG_Galician_Galician 0x0456 -#define FX_LANG_Georgian_Georgia 0x0437 -#define FX_LANG_German_Austria 0x0c07 -#define FX_LANG_German_Germany 0x0407 -#define FX_LANG_German_Liechtenstein 0x1407 -#define FX_LANG_German_Luxembourg 0x1007 -#define FX_LANG_German_Switzerland 0x0807 -#define FX_LANG_Greek_Greece 0x0408 -#define FX_LANG_Greenlandic_Greenland 0x046f -#define FX_LANG_Guarani 0x0474 -#define FX_LANG_Gujarati_India 0x0447 -#define FX_LANG_Hausa_LatinNigeria 0x0468 -#define FX_LANG_Hawaiian 0x0475 -#define FX_LANG_Hebrew_Israel 0x040d -#define FX_LANG_Hindi_India 0x0439 -#define FX_LANG_Hungarian_Hungary 0x040e -#define FX_LANG_Ibibio_Nigeria 0x0469 -#define FX_LANG_Icelandic_Iceland 0x040f -#define FX_LANG_Igbo_Nigeria 0x0470 -#define FX_LANG_Indonesian_Indonesia 0x0421 -#define FX_LANG_Inuktitut_LatinCanada 0x085d -#define FX_LANG_Inuktitut_SyllabicsCanada 0x045d -#define FX_LANG_IsiXhosa_SouthAfrica 0x0434 -#define FX_LANG_IsiZulu_SouthAfrica 0x0435 -#define FX_LANG_Italian_Italy 0x0410 -#define FX_LANG_Italian_Switzerland 0x0810 -#define FX_LANG_Japanese_Japan 0x0411 -#define FX_LANG_Kannada_India 0x044b -#define FX_LANG_Kanuri 0x0471 -#define FX_LANG_Kashmiri 0x0860 -#define FX_LANG_Kashmiri_Arabic 0x0460 -#define FX_LANG_Kazakh_Kazakhstan 0x043f -#define FX_LANG_Khmer_Cambodia 0x0453 -#define FX_LANG_Kiche_Guatemala 0x0486 -#define FX_LANG_Kinyarwanda_Rwanda 0x0487 -#define FX_LANG_Kiswahili_Kenya 0x0441 -#define FX_LANG_Konkani_India 0x0457 -#define FX_LANG_Korean_Korea 0x0412 -#define FX_LANG_Kyrgyz_Kyrgyzstan 0x0440 -#define FX_LANG_Lao_LaoPDR 0x0454 -#define FX_LANG_Latin 0x0476 -#define FX_LANG_Latvian_Latvia 0x0426 -#define FX_LANG_Lithuanian_Lithuania 0x0427 -#define FX_LANG_LithuanianTrad 0x0827 -#define FX_LANG_Lower Sorbian_Germany 0x082e -#define FX_LANG_Luxembourgish_Luxembourg 0x046e -#define FX_LANG_Macedonian 0x042f -#define FX_LANG_Malay_BruneiDarussalam 0x083e -#define FX_LANG_Malay_Malaysia 0x043e -#define FX_LANG_Malayalam_India 0x044c -#define FX_LANG_Maldivian 0x0465 -#define FX_LANG_Maltese_Malta 0x043a -#define FX_LANG_Manipuri 0x0458 -#define FX_LANG_Maori_NewZealand 0x0481 -#define FX_LANG_Mapudungun_Chile 0x047a -#define FX_LANG_Marathi_India 0x044e -#define FX_LANG_Mohawk_Mohawk 0x047c -#define FX_LANG_Mongolian_CyrillicMongolia 0x0450 -#define FX_LANG_Mongolian_TraditionalMongolian 0x0850 -#define FX_LANG_Nepali_India 0x0861 -#define FX_LANG_Nepali_Nepal 0x0461 -#define FX_LANG_Norwegian_Bokmal 0x0414 -#define FX_LANG_Norwegian_Nynorsk 0x0814 -#define FX_LANG_Occitan_France 0x0482 -#define FX_LANG_Oriya_India 0x0448 -#define FX_LANG_Oromo 0x0472 -#define FX_LANG_Papiamentu 0x0479 -#define FX_LANG_Pashto_Afghanistan 0x0463 -#define FX_LANG_Persian 0x0429 -#define FX_LANG_Polish_Poland 0x0415 -#define FX_LANG_Portuguese_Brazil 0x0416 -#define FX_LANG_Portuguese_Portugal 0x0816 -#define FX_LANG_Punjabi_India 0x0446 -#define FX_LANG_Punjabi_Pakistan 0x0846 -#define FX_LANG_Quechua_Bolivia 0x046b -#define FX_LANG_Quechua_Ecuador 0x086b -#define FX_LANG_Quechua_Peru 0x0c6b -#define FX_LANG_Romanian_Moldova 0x0818 -#define FX_LANG_Romanian_Romania 0x0418 -#define FX_LANG_Romansh_Switzerland 0x0417 -#define FX_LANG_Russian_Moldova 0x0819 -#define FX_LANG_Russian_Russia 0x0419 -#define FX_LANG_Sami_InariFinland 0x243b -#define FX_LANG_Sami_LuleNorway 0x103b -#define FX_LANG_Sami_LuleSweden 0x143b -#define FX_LANG_Sami_NorthernFinland 0x0c3b -#define FX_LANG_Sami_NorthernNorway 0x043b -#define FX_LANG_Sami_NorthernSweden 0x083b -#define FX_LANG_Sami_SkoltFinland 0x203b -#define FX_LANG_Sami_SouthernNorway 0x183b -#define FX_LANG_Sami_SouthernSweden 0x1c3b -#define FX_LANG_SanskritIndia 0x044f -#define FX_LANG_SerbianCyrillic_BosniaHerzegovina 0x1c1a -#define FX_LANG_SerbianCyrillic_Serbia 0x0c1a -#define FX_LANG_SerbianLatin_BosniaHerzegovina 0x181a -#define FX_LANG_SerbianLatin_Serbia 0x081a -#define FX_LANG_SesothoSaLeboa 0x046c -#define FX_LANG_Setswana_SouthAfrica 0x0432 -#define FX_LANG_Sindhi_Arabic 0x0859 -#define FX_LANG_Sindhi_Devanagari 0x0459 -#define FX_LANG_Sinhala_SriLanka 0x045b -#define FX_LANG_Slovak_Slovakia 0x041b -#define FX_LANG_Slovenian_Slovenia 0x0424 -#define FX_LANG_Somali 0x0477 -#define FX_LANG_Spanish_Argentina 0x2c0a -#define FX_LANG_Spanish_Bolivia 0x400a -#define FX_LANG_Spanish_Chile 0x340a -#define FX_LANG_Spanish_Colombia 0x240a -#define FX_LANG_Spanish_CostaRica 0x140a -#define FX_LANG_Spanish_DominicanRepublic 0x1c0a -#define FX_LANG_Spanish_Ecuador 0x300a -#define FX_LANG_Spanish_ElSalvador 0x440a -#define FX_LANG_Spanish_Guatemala 0x100a -#define FX_LANG_Spanish_Honduras 0x480a -#define FX_LANG_Spanish_Mexico 0x080a -#define FX_LANG_Spanish_Nicaragua 0x4c0a -#define FX_LANG_Spanish_Panama 0x180a -#define FX_LANG_Spanish_Paraguay 0x3c0a -#define FX_LANG_Spanish_Peru 0x280a -#define FX_LANG_Spanish_PuertoRico 0x500a -#define FX_LANG_Spanish_InternationalSort 0x0c0a -#define FX_LANG_Spanish_TraditionalSort 0x040a -#define FX_LANG_Spanish_UnitedStates 0x540a -#define FX_LANG_Spanish_Uruguay 0x380a -#define FX_LANG_Spanish_Venezuela 0x200a -#define FX_LANG_Sutu_SouthAfrica 0x0430 -#define FX_LANG_Swedish_Finland 0x081d -#define FX_LANG_Swedish_Sweden 0x041d -#define FX_LANG_Syriac_Syria 0x045a -#define FX_LANG_Tajik_CyrillicTajikistan 0x0428 -#define FX_LANG_Tamazight_ArabicMorocco 0x045f -#define FX_LANG_Tamazight_LatinAlgeria 0x085f -#define FX_LANG_Tamil_India 0x0449 -#define FX_LANG_Tatar_Russia 0x0444 -#define FX_LANG_Telugu_India 0x044a -#define FX_LANG_Thai_Thailand 0x041e -#define FX_LANG_TibetanPRC 0x0451 -#define FX_LANG_Tigrigna_Eritrea 0x0873 -#define FX_LANG_Tigrigna_Ethiopia 0x0473 -#define FX_LANG_Tsonga 0x0431 -#define FX_LANG_Turkish_Turkey 0x041f -#define FX_LANG_Turkmen_Turkmenistan 0x0442 -#define FX_LANG_UighurPRC 0x0480 -#define FX_LANG_Ukrainian_Ukraine 0x0422 -#define FX_LANG_UpperSorbian_Germany 0x042e -#define FX_LANG_Urdu_Pakistan 0x0420 -#define FX_LANG_Urdu_India 0x0820 -#define FX_LANG_Uzbek_CyrillicUzbekistan 0x0843 -#define FX_LANG_Uzbek_LatinUzbekistan 0x0443 -#define FX_LANG_Venda 0x0433 -#define FX_LANG_Vietnamese_Vietnam 0x042a -#define FX_LANG_Welsh_UnitedKingdom 0x0452 -#define FX_LANG_Wolof_Senegal 0x0488 -#define FX_LANG_Xhosa 0x0434 -#define FX_LANG_Yakut_Russia 0x0485 -#define FX_LANG_YiPRC 0x0478 -#define FX_LANG_Yiddish 0x043d -#define FX_LANG_Yoruba_Nigeria 0x046a - -#endif // XFA_SRC_FGAS_CRT_FGAS_LANGUAGE_H_ diff --git a/xfa/src/fgas/crt/fgas_memory.cpp b/xfa/src/fgas/crt/fgas_memory.cpp deleted file mode 100644 index c88c7e3aac..0000000000 --- a/xfa/src/fgas/crt/fgas_memory.cpp +++ /dev/null @@ -1,446 +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/src/fgas/crt/fgas_memory.h" - -#include <algorithm> - -namespace { - -class CFX_DefStore : public IFX_MEMAllocator, 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; } -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -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 { - 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; } - - protected: - size_t m_iAllocatedSize; - size_t m_iDefChunkSize; - FX_STATICSTORECHUNK* m_pChunk; - FX_STATICSTORECHUNK* m_pLastChunk; - FX_STATICSTORECHUNK* AllocChunk(size_t size); - 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; } - - FX_FIXEDSTORECHUNK* pNextChunk; - size_t iChunkSize; - size_t iFreeNum; -}; -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(pop) -#endif - -class CFX_FixedStore : public IFX_MEMAllocator, 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; } - - protected: - FX_FIXEDSTORECHUNK* AllocChunk(); - - size_t m_iBlockSize; - size_t m_iDefChunkSize; - 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) - -IFX_MEMAllocator* FX_CreateAllocator(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; - } -} -CFX_StaticStore::CFX_StaticStore(size_t iDefChunkSize) - : m_iAllocatedSize(0), - m_iDefChunkSize(iDefChunkSize), - m_pChunk(NULL), - m_pLastChunk(NULL) { - FXSYS_assert(m_iDefChunkSize != 0); -} -CFX_StaticStore::~CFX_StaticStore() { - FX_STATICSTORECHUNK* pChunk = m_pChunk; - while (pChunk) { - FX_STATICSTORECHUNK* pNext = pChunk->pNextChunk; - FX_Free(pChunk); - pChunk = pNext; - } -} -FX_STATICSTORECHUNK* CFX_StaticStore::AllocChunk(size_t size) { - FXSYS_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) { - m_pChunk = pChunk; - } else { - m_pLastChunk->pNextChunk = pChunk; - } - m_pLastChunk = pChunk; - return pChunk; -} -FX_STATICSTORECHUNK* CFX_StaticStore::FindChunk(size_t size) { - FXSYS_assert(size != 0); - if (m_pLastChunk == NULL || 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); - FX_STATICSTORECHUNK* pChunk = FindChunk(size); - FXSYS_assert(pChunk->iFreeSize >= size); - uint8_t* p = (uint8_t*)pChunk; - p += sizeof(FX_STATICSTORECHUNK) + pChunk->iChunkSize - pChunk->iFreeSize; - pChunk->iFreeSize -= size; - m_iAllocatedSize += size; - return p; -} -size_t CFX_StaticStore::SetDefChunkSize(size_t size) { - FXSYS_assert(size != 0); - size_t v = m_iDefChunkSize; - m_iDefChunkSize = size; - return v; -} -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); -} -CFX_FixedStore::~CFX_FixedStore() { - FX_FIXEDSTORECHUNK* pChunk = m_pChunk; - while (pChunk) { - FX_FIXEDSTORECHUNK* pNext = pChunk->pNextChunk; - FX_Free(pChunk); - pChunk = pNext; - } -} -FX_FIXEDSTORECHUNK* CFX_FixedStore::AllocChunk() { - int32_t iTotalSize = sizeof(FX_FIXEDSTORECHUNK) + m_iDefChunkSize + - m_iBlockSize * m_iDefChunkSize; - FX_FIXEDSTORECHUNK* pChunk = - (FX_FIXEDSTORECHUNK*)FX_Alloc(uint8_t, iTotalSize); - if (pChunk == NULL) { - return NULL; - } - FXSYS_memset(pChunk->FirstFlag(), 0, m_iDefChunkSize); - pChunk->pNextChunk = m_pChunk; - pChunk->iChunkSize = m_iDefChunkSize; - pChunk->iFreeNum = m_iDefChunkSize; - m_pChunk = pChunk; - return pChunk; -} -void* CFX_FixedStore::Alloc(size_t size) { - if (size > m_iBlockSize) { - return NULL; - } - FX_FIXEDSTORECHUNK* pChunk = m_pChunk; - while (pChunk != NULL) { - if (pChunk->iFreeNum > 0) { - break; - } - pChunk = pChunk->pNextChunk; - } - if (pChunk == NULL) { - 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); - 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* pChunk = m_pChunk; - uint8_t* pStart = NULL; - uint8_t* pEnd; - while (pChunk != NULL) { - pStart = pChunk->FirstBlock(); - if (pBlock >= pStart) { - pEnd = pStart + m_iBlockSize * pChunk->iChunkSize; - if (pBlock < pEnd) { - break; - } - } - pPrior = pChunk, pChunk = pChunk->pNextChunk; - } - FXSYS_assert(pChunk != NULL); - size_t iPos = ((uint8_t*)pBlock - pStart) / m_iBlockSize; - FXSYS_assert(iPos < pChunk->iChunkSize); - uint8_t* pFlags = pChunk->FirstFlag(); - if (pFlags[iPos] == 0) { - return; - } - pFlags[iPos] = 0; - pChunk->iFreeNum++; - if (pChunk->iFreeNum == pChunk->iChunkSize) { - if (pPrior == NULL) { - m_pChunk = pChunk->pNextChunk; - } else { - pPrior->pNextChunk = pChunk->pNextChunk; - } - FX_Free(pChunk); - } -} -size_t CFX_FixedStore::SetDefChunkSize(size_t iChunkSize) { - FXSYS_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; -} diff --git a/xfa/src/fgas/crt/fgas_memory.h b/xfa/src/fgas/crt/fgas_memory.h deleted file mode 100644 index 90a8ddaf9a..0000000000 --- a/xfa/src/fgas/crt/fgas_memory.h +++ /dev/null @@ -1,59 +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_SRC_FGAS_CRT_FGAS_MEMORY_H_ -#define XFA_SRC_FGAS_CRT_FGAS_MEMORY_H_ - -#include "core/include/fxcrt/fx_memory.h" -#include "core/include/fxcrt/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 { - public: - virtual ~IFX_MEMAllocator() {} - virtual void Release() = 0; - 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, - 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) { - return pAllocator->Alloc(size); - } - void operator delete(void* p, IFX_MEMAllocator* pAllocator) { - pAllocator->Free(p); - } - void* operator new(size_t size, void* place) { return place; } - void operator delete(void* p, void* place) {} -}; - -#define FXTARGET_NewWith(__allocator__) new (__allocator__) -#define FXTARGET_DeleteWith(__class__, __allocator__, pointer) \ - { \ - (pointer)->~__class__(); \ - (pointer)->operator delete((pointer), (__allocator__)); \ - } - -#endif // XFA_SRC_FGAS_CRT_FGAS_MEMORY_H_ diff --git a/xfa/src/fgas/crt/fgas_stream.cpp b/xfa/src/fgas/crt/fgas_stream.cpp deleted file mode 100644 index c515b56662..0000000000 --- a/xfa/src/fgas/crt/fgas_stream.cpp +++ /dev/null @@ -1,1626 +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/src/fgas/crt/fgas_stream.h" - -#include <algorithm> - -#include "xfa/src/fgas/crt/fgas_system.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" - -namespace { - -class CFX_StreamImp { - public: - virtual void Release() { delete this; } - virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } - virtual int32_t GetLength() const = 0; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; - virtual int32_t GetPosition() = 0; - virtual FX_BOOL IsEOF() const = 0; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS) = 0; - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; - virtual void Flush() = 0; - virtual FX_BOOL SetLength(int32_t iLength) = 0; - - protected: - CFX_StreamImp(); - virtual ~CFX_StreamImp() {} - FX_DWORD m_dwAccess; -}; - -class CFX_FileStreamImp : public CFX_StreamImp { - public: - CFX_FileStreamImp(); - virtual ~CFX_FileStreamImp(); - FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - - protected: - FXSYS_FILE* m_hFile; - int32_t m_iLength; -}; - -class CFX_BufferStreamImp : public CFX_StreamImp { - public: - CFX_BufferStreamImp(); - virtual ~CFX_BufferStreamImp() {} - FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - uint8_t* m_pData; - int32_t m_iTotalSize; - int32_t m_iPosition; - int32_t m_iLength; -}; - -class CFX_FileReadStreamImp : public CFX_StreamImp { - public: - CFX_FileReadStreamImp(); - virtual ~CFX_FileReadStreamImp() {} - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return 0; - } - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { - return 0; - } - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - IFX_FileRead* m_pFileRead; - int32_t m_iPosition; - int32_t m_iLength; -}; - -class CFX_BufferReadStreamImp : public CFX_StreamImp { - public: - CFX_BufferReadStreamImp(); - ~CFX_BufferReadStreamImp(); - FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead); - - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return 0; - } - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { - return 0; - } - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - private: - IFX_BufferRead* m_pBufferRead; - FX_BOOL m_bReleaseBufferRead; - int32_t m_iPosition; - int32_t m_iBufferSize; -}; - -class CFX_FileWriteStreamImp : public CFX_StreamImp { - public: - CFX_FileWriteStreamImp(); - virtual ~CFX_FileWriteStreamImp() {} - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition() { return m_iPosition; } - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS) { - return 0; - } - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - protected: - IFX_FileWrite* m_pFileWrite; - int32_t m_iPosition; -}; - -enum FX_STREAMTYPE { - FX_SREAMTYPE_Unknown = 0, - FX_STREAMTYPE_File, - FX_STREAMTYPE_Buffer, - FX_STREAMTYPE_Stream, - FX_STREAMTYPE_BufferRead, -}; - -class CFX_Stream : public IFX_Stream { - public: - CFX_Stream(); - ~CFX_Stream(); - FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, FX_DWORD dwAccess); - FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, FX_DWORD dwAccess); - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess); - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); - FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead); - virtual void Release(); - virtual IFX_Stream* Retain(); - virtual FX_DWORD GetAccessModes() const { return m_dwAccess; } - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - virtual int32_t GetBOM(uint8_t bom[4]) const; - virtual FX_WORD GetCodePage() const; - virtual FX_WORD SetCodePage(FX_WORD wCodePage); - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength); - - protected: - FX_STREAMTYPE m_eStreamType; - CFX_StreamImp* m_pStreamImp; - FX_DWORD m_dwAccess; - int32_t m_iTotalSize; - int32_t m_iPosition; - int32_t m_iStart; - int32_t m_iLength; - int32_t m_iRefCount; -}; - -class CFX_TextStream : public IFX_Stream { - public: - CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream); - ~CFX_TextStream(); - virtual void Release(); - virtual IFX_Stream* Retain(); - - virtual FX_DWORD GetAccessModes() const; - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); - virtual void Flush(); - virtual FX_BOOL SetLength(int32_t iLength); - - virtual int32_t GetBOM(uint8_t bom[4]) const; - virtual FX_WORD GetCodePage() const; - virtual FX_WORD SetCodePage(FX_WORD wCodePage); - - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength); - - protected: - FX_WORD m_wCodePage; - int32_t m_wBOMLength; - FX_DWORD m_dwBOM; - uint8_t* m_pBuf; - int32_t m_iBufSize; - FX_BOOL m_bDelStream; - IFX_Stream* m_pStreamImp; - int32_t m_iRefCount; - void InitStream(); -}; - -class CFGAS_FileRead : public IFX_FileRead { - public: - CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream); - virtual ~CFGAS_FileRead(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - protected: - FX_BOOL m_bReleaseStream; - IFX_Stream* m_pStream; -}; - -class CFX_BufferAccImp : public IFX_FileRead { - public: - CFX_BufferAccImp(IFX_BufferRead* pBufferRead, - FX_FILESIZE iFileSize, - FX_BOOL bReleaseStream); - virtual ~CFX_BufferAccImp(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - protected: - IFX_BufferRead* m_pBufferRead; - FX_BOOL m_bReleaseStream; - FX_FILESIZE m_iBufSize; -}; - -class CFGAS_FileWrite : public IFX_FileWrite { - public: - CFGAS_FileWrite(IFX_Stream* pStream, FX_BOOL bReleaseStream); - virtual ~CFGAS_FileWrite(); - virtual void Release() { delete this; } - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL Flush(); - virtual FX_BOOL WriteBlock(const void* pData, size_t size); - virtual FX_BOOL WriteBlock(const void* pData, - FX_FILESIZE offset, - size_t size); - - protected: - IFX_Stream* m_pStream; - FX_BOOL m_bReleaseStream; -}; - -} // namespace - -IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, - FX_DWORD dwAccess, - int32_t iFileSize, - FX_BOOL bReleaseBufferRead) { - CFX_Stream* pSR = new CFX_Stream; - if (!pSR->LoadBufferRead(pBufferRead, iFileSize, dwAccess, - bReleaseBufferRead)) { - pSR->Release(); - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} -IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, - FX_DWORD dwAccess) { - CFX_Stream* pSR = new CFX_Stream; - if (!pSR->LoadFileRead(pFileRead, dwAccess)) { - pSR->Release(); - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} -IFX_Stream* IFX_Stream::CreateStream(IFX_FileWrite* pFileWrite, - FX_DWORD dwAccess) { - CFX_Stream* pSR = new CFX_Stream; - if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) { - pSR->Release(); - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} -IFX_Stream* IFX_Stream::CreateStream(const FX_WCHAR* pszFileName, - FX_DWORD dwAccess) { - CFX_Stream* pSR = new CFX_Stream; - if (!pSR->LoadFile(pszFileName, dwAccess)) { - pSR->Release(); - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} -IFX_Stream* IFX_Stream::CreateStream(uint8_t* pData, - int32_t length, - FX_DWORD dwAccess) { - CFX_Stream* pSR = new CFX_Stream; - if (!pSR->LoadBuffer(pData, length, dwAccess)) { - pSR->Release(); - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} - -CFX_StreamImp::CFX_StreamImp() : m_dwAccess(0) {} -CFX_FileStreamImp::CFX_FileStreamImp() - : CFX_StreamImp(), m_hFile(NULL), m_iLength(0) {} -CFX_FileStreamImp::~CFX_FileStreamImp() { - if (m_hFile != NULL) { - FXSYS_fclose(m_hFile); - } -} -FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName, - FX_DWORD dwAccess) { - FXSYS_assert(m_hFile == NULL); - FXSYS_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; - if (dwAccess & FX_STREAMACCESS_Write) { - if (dwAccess & FX_STREAMACCESS_Append) { - wsMode = L"a+b"; - } else if (dwAccess & FX_STREAMACCESS_Truncate) { - wsMode = L"w+b"; - } else { - wsMode = L"r+b"; - } - } else { - wsMode = L"rb"; - } - m_hFile = FXSYS_wfopen(pszSrcFileName, wsMode); - - if (!m_hFile) { - if (dwAccess & FX_STREAMACCESS_Write) { - if (dwAccess & FX_STREAMACCESS_Create) - m_hFile = FXSYS_wfopen(pszSrcFileName, L"w+b"); - - if (!m_hFile) { - m_hFile = FXSYS_wfopen(pszSrcFileName, L"r+b"); - if (!m_hFile) - return FALSE; - - if (dwAccess & FX_STREAMACCESS_Truncate) - FX_fsetsize(m_hFile, 0); - } - } else { - return FALSE; - } - } -#else - CFX_ByteString wsMode; - if (dwAccess & FX_STREAMACCESS_Write) { - if (dwAccess & FX_STREAMACCESS_Append) { - wsMode = "a+b"; - } else if (dwAccess & FX_STREAMACCESS_Truncate) { - wsMode = "w+b"; - } else { - wsMode = "r+b"; - } - } else { - wsMode = "rb"; - } - CFX_ByteString szFileName = CFX_ByteString::FromUnicode(pszSrcFileName); - m_hFile = FXSYS_fopen(szFileName, wsMode); - if (m_hFile == NULL) { - if (dwAccess & FX_STREAMACCESS_Write) { - if (dwAccess & FX_STREAMACCESS_Create) { - m_hFile = FXSYS_fopen(szFileName, "w+b"); - } - if (m_hFile == NULL) { - m_hFile = FXSYS_fopen(szFileName, "r+b"); - if (m_hFile == NULL) { - return FALSE; - } - if (dwAccess & FX_STREAMACCESS_Truncate) { - FX_fsetsize(m_hFile, 0); - } - } - } else { - return FALSE; - } - } -#endif - m_dwAccess = dwAccess; - if ((dwAccess & (FX_STREAMACCESS_Write | FX_STREAMACCESS_Truncate)) == - (FX_STREAMACCESS_Write | FX_STREAMACCESS_Truncate)) { - m_iLength = 0; - } else { - m_iLength = FX_filelength(m_hFile); - } - return TRUE; -} -int32_t CFX_FileStreamImp::GetLength() const { - FXSYS_assert(m_hFile != NULL); - return m_iLength; -} -int32_t CFX_FileStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - FXSYS_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); - return FXSYS_ftell(m_hFile); -} -FX_BOOL CFX_FileStreamImp::IsEOF() const { - FXSYS_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); - 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); - if (m_iLength <= 0) { - return 0; - } - int32_t iPosition = FXSYS_ftell(m_hFile); - int32_t iLen = std::min((m_iLength - iPosition) / 2, iMaxLength); - if (iLen <= 0) { - return 0; - } - iLen = FXSYS_fread(pStr, 2, iLen, m_hFile); - int32_t iCount = 0; - while (*pStr != L'\0' && iCount < iLen) { - pStr++, iCount++; - } - iPosition += iCount * 2; - if (FXSYS_ftell(m_hFile) != iPosition) { - FXSYS_fseek(m_hFile, iPosition, 0); - } - bEOS = (iPosition >= m_iLength); - return iCount; -} -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); - int32_t iRet = FXSYS_fwrite(pBuffer, 1, iBufferSize, m_hFile); - if (iRet != 0) { - int32_t iPos = FXSYS_ftell(m_hFile); - if (iPos > m_iLength) { - m_iLength = iPos; - } - } - 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); - int32_t iRet = FXSYS_fwrite(pStr, 2, iLength, m_hFile); - if (iRet != 0) { - int32_t iPos = FXSYS_ftell(m_hFile); - if (iPos > m_iLength) { - m_iLength = iPos; - } - } - return iRet; -} -void CFX_FileStreamImp::Flush() { - FXSYS_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); - FX_BOOL bRet = FX_fsetsize(m_hFile, iLength); - m_iLength = FX_filelength(m_hFile); - return bRet; -} -CFX_FileReadStreamImp::CFX_FileReadStreamImp() - : m_pFileRead(NULL), m_iPosition(0), m_iLength(0) {} -FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_FileRead* pFileRead, - FX_DWORD dwAccess) { - FXSYS_assert(m_pFileRead == NULL && pFileRead != NULL); - if (dwAccess & FX_STREAMACCESS_Write) { - return FALSE; - } - m_pFileRead = pFileRead; - m_iLength = m_pFileRead->GetSize(); - return TRUE; -} -int32_t CFX_FileReadStreamImp::GetLength() const { - return m_iLength; -} -int32_t CFX_FileReadStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - switch (eSeek) { - case FX_STREAMSEEK_Begin: - m_iPosition = iOffset; - break; - case FX_STREAMSEEK_Current: - m_iPosition += iOffset; - break; - case FX_STREAMSEEK_End: - m_iPosition = m_iLength + iOffset; - break; - } - if (m_iPosition < 0) { - m_iPosition = 0; - } else if (m_iPosition >= m_iLength) { - m_iPosition = m_iLength; - } - return m_iPosition; -} -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); - if (iBufferSize > m_iLength - m_iPosition) { - iBufferSize = m_iLength - m_iPosition; - } - if (m_pFileRead->ReadBlock(pBuffer, m_iPosition, iBufferSize)) { - m_iPosition += iBufferSize; - return iBufferSize; - } - return 0; -} -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); - iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; - if (iMaxLength <= 0) { - return 0; - } - int32_t i = 0; - while (i < iMaxLength && pStr[i] != L'\0') { - ++i; - } - bEOS = (m_iPosition >= m_iLength) || pStr[i] == L'\0'; - return i; -} -CFX_BufferReadStreamImp::CFX_BufferReadStreamImp() - : m_pBufferRead(NULL), - m_bReleaseBufferRead(FALSE), - m_iPosition(0), - m_iBufferSize(0) {} -CFX_BufferReadStreamImp::~CFX_BufferReadStreamImp() { - if (m_bReleaseBufferRead && m_pBufferRead != NULL) { - m_pBufferRead->Release(); - } -} -FX_BOOL CFX_BufferReadStreamImp::LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead) { - FXSYS_assert(m_pBufferRead == NULL && pBufferRead != NULL); - if (dwAccess & FX_STREAMACCESS_Write) { - return FALSE; - } - m_bReleaseBufferRead = bReleaseBufferRead; - m_pBufferRead = pBufferRead; - m_iBufferSize = iFileSize; - if (m_iBufferSize >= 0) { - return TRUE; - } - if (!m_pBufferRead->ReadNextBlock(TRUE)) { - return FALSE; - } - m_iBufferSize = m_pBufferRead->GetBlockSize(); - while (!m_pBufferRead->IsEOF()) { - m_pBufferRead->ReadNextBlock(FALSE); - m_iBufferSize += m_pBufferRead->GetBlockSize(); - } - return TRUE; -} -int32_t CFX_BufferReadStreamImp::GetLength() const { - return m_iBufferSize; -} -int32_t CFX_BufferReadStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - int32_t iLength = GetLength(); - switch (eSeek) { - case FX_STREAMSEEK_Begin: - m_iPosition = iOffset; - break; - case FX_STREAMSEEK_Current: - m_iPosition += iOffset; - break; - case FX_STREAMSEEK_End: - m_iPosition = iLength + iOffset; - break; - } - if (m_iPosition < 0) { - m_iPosition = 0; - } else if (m_iPosition >= iLength) { - m_iPosition = iLength; - } - return m_iPosition; -} -FX_BOOL CFX_BufferReadStreamImp::IsEOF() const { - return m_pBufferRead ? m_pBufferRead->IsEOF() : TRUE; -} -int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, - int32_t iBufferSize) { - FXSYS_assert(m_pBufferRead != NULL); - FXSYS_assert(pBuffer != NULL && iBufferSize > 0); - int32_t iLength = GetLength(); - if (m_iPosition >= iLength) { - return 0; - } - if (iBufferSize > iLength - m_iPosition) { - iBufferSize = iLength - m_iPosition; - } - FX_DWORD dwBlockOffset = m_pBufferRead->GetBlockOffset(); - FX_DWORD dwBlockSize = m_pBufferRead->GetBlockSize(); - if (m_iPosition < (int32_t)dwBlockOffset) { - if (!m_pBufferRead->ReadNextBlock(TRUE)) { - return 0; - } - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - dwBlockSize = m_pBufferRead->GetBlockSize(); - } - while (m_iPosition < (int32_t)dwBlockOffset || - m_iPosition >= (int32_t)(dwBlockOffset + dwBlockSize)) { - if (m_pBufferRead->IsEOF() || !m_pBufferRead->ReadNextBlock(FALSE)) { - break; - } - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - dwBlockSize = m_pBufferRead->GetBlockSize(); - } - if (m_iPosition < (int32_t)dwBlockOffset || - m_iPosition >= (int32_t)(dwBlockOffset + dwBlockSize)) { - return 0; - } - const uint8_t* pBufferTmp = m_pBufferRead->GetBlockBuffer(); - FX_DWORD dwOffsetTmp = m_iPosition - dwBlockOffset; - FX_DWORD dwCopySize = - std::min(iBufferSize, (int32_t)(dwBlockSize - dwOffsetTmp)); - FXSYS_memcpy(pBuffer, pBufferTmp + dwOffsetTmp, dwCopySize); - dwOffsetTmp = dwCopySize; - iBufferSize -= dwCopySize; - while (iBufferSize > 0) { - if (!m_pBufferRead->ReadNextBlock(FALSE)) { - break; - } - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - dwBlockSize = m_pBufferRead->GetBlockSize(); - pBufferTmp = m_pBufferRead->GetBlockBuffer(); - dwCopySize = std::min((FX_DWORD)iBufferSize, dwBlockSize); - FXSYS_memcpy(pBuffer + dwOffsetTmp, pBufferTmp, dwCopySize); - dwOffsetTmp += dwCopySize; - iBufferSize -= dwCopySize; - } - m_iPosition += dwOffsetTmp; - return dwOffsetTmp; -} -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); - iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; - if (iMaxLength <= 0) { - return 0; - } - int32_t i = 0; - while (i < iMaxLength && pStr[i] != L'\0') { - ++i; - } - bEOS = (m_iPosition >= GetLength()) || pStr[i] == L'\0'; - return i; -} -CFX_FileWriteStreamImp::CFX_FileWriteStreamImp() - : m_pFileWrite(NULL), m_iPosition(0) {} -FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite(IFX_FileWrite* pFileWrite, - FX_DWORD dwAccess) { - FXSYS_assert(m_pFileWrite == NULL && pFileWrite != NULL); - if (dwAccess & FX_STREAMACCESS_Read) { - return FALSE; - } - if (dwAccess & FX_STREAMACCESS_Append) { - m_iPosition = pFileWrite->GetSize(); - } - m_pFileWrite = pFileWrite; - return TRUE; -} -int32_t CFX_FileWriteStreamImp::GetLength() const { - if (!m_pFileWrite) { - return 0; - } - return (int32_t)m_pFileWrite->GetSize(); -} -int32_t CFX_FileWriteStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - int32_t iLength = GetLength(); - switch (eSeek) { - case FX_STREAMSEEK_Begin: - m_iPosition = iOffset; - break; - case FX_STREAMSEEK_Current: - m_iPosition += iOffset; - break; - case FX_STREAMSEEK_End: - m_iPosition = iLength + iOffset; - break; - } - if (m_iPosition < 0) { - m_iPosition = 0; - } else if (m_iPosition >= iLength) { - m_iPosition = iLength; - } - return m_iPosition; -} -FX_BOOL CFX_FileWriteStreamImp::IsEOF() const { - return m_iPosition >= GetLength(); -} -int32_t CFX_FileWriteStreamImp::WriteData(const uint8_t* pBuffer, - int32_t iBufferSize) { - if (!m_pFileWrite) { - return 0; - } - if (m_pFileWrite->WriteBlock(pBuffer, m_iPosition, iBufferSize)) { - m_iPosition += iBufferSize; - } - return iBufferSize; -} -int32_t CFX_FileWriteStreamImp::WriteString(const FX_WCHAR* pStr, - int32_t iLength) { - return WriteData((const uint8_t*)pStr, iLength * sizeof(FX_WCHAR)); -} -void CFX_FileWriteStreamImp::Flush() { - if (m_pFileWrite) { - m_pFileWrite->Flush(); - } -} -CFX_BufferStreamImp::CFX_BufferStreamImp() - : CFX_StreamImp(), - m_pData(NULL), - m_iTotalSize(0), - m_iPosition(0), - m_iLength(0) {} -FX_BOOL CFX_BufferStreamImp::LoadBuffer(uint8_t* pData, - int32_t iTotalSize, - FX_DWORD dwAccess) { - FXSYS_assert(m_pData == NULL); - FXSYS_assert(pData != NULL && iTotalSize > 0); - m_dwAccess = dwAccess; - m_pData = pData; - m_iTotalSize = iTotalSize; - m_iPosition = 0; - m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iTotalSize; - return TRUE; -} -int32_t CFX_BufferStreamImp::GetLength() const { - FXSYS_assert(m_pData != NULL); - return m_iLength; -} -int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - FXSYS_assert(m_pData != NULL); - if (eSeek == FX_STREAMSEEK_Begin) { - m_iPosition = iOffset; - } else if (eSeek == FX_STREAMSEEK_Current) { - m_iPosition += iOffset; - } else if (eSeek == FX_STREAMSEEK_End) { - m_iPosition = m_iLength + iOffset; - } - if (m_iPosition > m_iLength) { - m_iPosition = m_iLength; - } - if (m_iPosition < 0) { - m_iPosition = 0; - } - return m_iPosition; -} -int32_t CFX_BufferStreamImp::GetPosition() { - FXSYS_assert(m_pData != NULL); - return m_iPosition; -} -FX_BOOL CFX_BufferStreamImp::IsEOF() const { - FXSYS_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); - int32_t iLen = std::min(m_iLength - m_iPosition, iBufferSize); - if (iLen <= 0) { - return 0; - } - FXSYS_memcpy(pBuffer, m_pData + m_iPosition, iLen); - m_iPosition += iLen; - return iLen; -} -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); - int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength); - if (iLen <= 0) { - return 0; - } - const FX_WCHAR* pSrc = (const FX_WCHAR*)(FX_CHAR*)(m_pData + m_iPosition); - int32_t iCount = 0; - while (*pSrc != L'\0' && iCount < iLen) { - *pStr++ = *pSrc++, iCount++; - } - m_iPosition += iCount * 2; - bEOS = (*pSrc == L'\0') || (m_iPosition >= m_iLength); - return iCount; -} -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); - int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize); - if (iLen <= 0) { - return 0; - } - FXSYS_memcpy(m_pData + m_iPosition, pBuffer, iLen); - m_iPosition += iLen; - if (m_iPosition > m_iLength) { - m_iLength = m_iPosition; - } - return iLen; -} -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); - int32_t iLen = std::min((m_iTotalSize - m_iPosition) / 2, iLength); - if (iLen <= 0) { - return 0; - } - FXSYS_memcpy(m_pData + m_iPosition, pStr, iLen * 2); - m_iPosition += iLen * 2; - if (m_iPosition > m_iLength) { - m_iLength = m_iPosition; - } - return iLen; -} -IFX_Stream* IFX_Stream::CreateTextStream(IFX_Stream* pBaseStream, - FX_BOOL bDeleteOnRelease) { - FXSYS_assert(pBaseStream != NULL); - return new CFX_TextStream(pBaseStream, bDeleteOnRelease); -} -CFX_TextStream::CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream) - : m_wCodePage(FX_CODEPAGE_DefANSI), - m_wBOMLength(0), - m_dwBOM(0), - m_pBuf(NULL), - m_iBufSize(0), - m_bDelStream(bDelStream), - m_pStreamImp(pStream), - m_iRefCount(1) { - FXSYS_assert(m_pStreamImp != NULL); - m_pStreamImp->Retain(); - InitStream(); -} -CFX_TextStream::~CFX_TextStream() { - m_pStreamImp->Release(); - if (m_bDelStream) { - m_pStreamImp->Release(); - } - if (m_pBuf != NULL) { - FX_Free(m_pBuf); - } -} -void CFX_TextStream::InitStream() { - int32_t iPosition = m_pStreamImp->GetPosition(); - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, 0); - m_pStreamImp->ReadData((uint8_t*)&m_dwBOM, 3); -#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ - m_dwBOM &= 0x00FFFFFF; - if (m_dwBOM == 0x00BFBBEF) { - m_wBOMLength = 3; - m_wCodePage = FX_CODEPAGE_UTF8; - } else { - m_dwBOM &= 0x0000FFFF; - if (m_dwBOM == 0x0000FFFE) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16BE; - } else if (m_dwBOM == 0x0000FEFF) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16LE; - } else { - m_wBOMLength = 0; - m_dwBOM = 0; - m_wCodePage = FXSYS_GetACP(); - } - } -#else - m_dwBOM &= 0xFFFFFF00; - if (m_dwBOM == 0xEFBBBF00) { - m_wBOMLength = 3; - m_wCodePage = FX_CODEPAGE_UTF8; - } else { - m_dwBOM &= 0xFFFF0000; - if (m_dwBOM == 0xFEFF0000) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16BE; - } else if (m_dwBOM == 0xFFFE0000) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16LE; - } else { - m_wBOMLength = 0; - m_dwBOM = 0; - m_wCodePage = FXSYS_GetACP(); - } - } -#endif - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, std::max(m_wBOMLength, iPosition)); -} -void CFX_TextStream::Release() { - if (--m_iRefCount < 1) { - delete this; - } -} -IFX_Stream* CFX_TextStream::Retain() { - m_iRefCount++; - return this; -} -FX_DWORD CFX_TextStream::GetAccessModes() const { - return m_pStreamImp->GetAccessModes() | FX_STREAMACCESS_Text; -} -int32_t CFX_TextStream::GetLength() const { - return m_pStreamImp->GetLength(); -} -int32_t CFX_TextStream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - return m_pStreamImp->Seek(eSeek, iOffset); -} -int32_t CFX_TextStream::GetPosition() { - return m_pStreamImp->GetPosition(); -} -FX_BOOL CFX_TextStream::IsEOF() const { - return m_pStreamImp->IsEOF(); -} -int32_t CFX_TextStream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - return m_pStreamImp->ReadData(pBuffer, iBufferSize); -} -int32_t CFX_TextStream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return m_pStreamImp->WriteData(pBuffer, iBufferSize); -} -void CFX_TextStream::Flush() { - m_pStreamImp->Flush(); -} -FX_BOOL CFX_TextStream::SetLength(int32_t iLength) { - return m_pStreamImp->SetLength(iLength); -} -FX_WORD CFX_TextStream::GetCodePage() const { - return m_wCodePage; -} -IFX_Stream* CFX_TextStream::CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength) { - IFX_Stream* pSR = - m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength); - if (pSR == NULL) { - return NULL; - } - if (dwAccess & FX_STREAMACCESS_Text) { - return new CFX_TextStream(pSR, TRUE); - } - return pSR; -} -int32_t CFX_TextStream::GetBOM(uint8_t bom[4]) const { - if (m_wBOMLength < 1) { - return 0; - } - *(FX_DWORD*)bom = m_dwBOM; - return m_wBOMLength; -} -FX_WORD CFX_TextStream::SetCodePage(FX_WORD wCodePage) { - if (m_wBOMLength > 0) { - return m_wCodePage; - } - FX_WORD v = m_wCodePage; - m_wCodePage = wCodePage; - return v; -} -int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize) { - FXSYS_assert(pStr != NULL && iMaxLength > 0); - if (m_pStreamImp == NULL) { - return -1; - } - int32_t iLen; - if (m_wCodePage == FX_CODEPAGE_UTF16LE || - m_wCodePage == FX_CODEPAGE_UTF16BE) { - int32_t iBytes = pByteSize == NULL ? iMaxLength * 2 : *pByteSize; - iLen = m_pStreamImp->ReadData((uint8_t*)pStr, iBytes); - iMaxLength = iLen / 2; - if (sizeof(FX_WCHAR) > 2) { - FX_UTF16ToWChar(pStr, iMaxLength); - } -#if _FX_ENDIAN_ == _FX_BIG_ENDIAN_ - if (m_wCodePage == FX_CODEPAGE_UTF16LE) { - FX_SwapByteOrder(pStr, iMaxLength); - } -#else - if (m_wCodePage == FX_CODEPAGE_UTF16BE) { - FX_SwapByteOrder(pStr, iMaxLength); - } -#endif - } else { - int32_t pos = m_pStreamImp->GetPosition(); - int32_t iBytes = pByteSize == NULL ? iMaxLength : *pByteSize; - iBytes = std::min(iBytes, m_pStreamImp->GetLength() - pos); - if (iBytes > 0) { - if (m_pBuf == NULL) { - m_pBuf = FX_Alloc(uint8_t, iBytes); - m_iBufSize = iBytes; - } else if (iBytes > m_iBufSize) { - m_pBuf = FX_Realloc(uint8_t, m_pBuf, iBytes); - m_iBufSize = iBytes; - } - iLen = m_pStreamImp->ReadData(m_pBuf, iBytes); - int32_t iSrc = iLen; - int32_t iDecode = FX_DecodeString(m_wCodePage, (const FX_CHAR*)m_pBuf, - &iSrc, pStr, &iMaxLength, TRUE); - m_pStreamImp->Seek(FX_STREAMSEEK_Current, iSrc - iLen); - if (iDecode < 1) { - return -1; - } - } else { - iMaxLength = 0; - } - } - bEOS = m_pStreamImp->IsEOF(); - return iMaxLength; -} -int32_t CFX_TextStream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { - FXSYS_assert(pStr != NULL && iLength > 0); - if ((m_pStreamImp->GetAccessModes() & FX_STREAMACCESS_Write) == 0) { - return -1; - } - if (m_wCodePage == FX_CODEPAGE_UTF8) { - int32_t len = iLength; - CFX_UTF8Encoder encoder; - while (len-- > 0) { - encoder.Input(*pStr++); - } - CFX_ByteStringC bsResult = encoder.GetResult(); - m_pStreamImp->WriteData((const uint8_t*)bsResult.GetCStr(), - bsResult.GetLength()); - } - return iLength; -} -CFX_Stream::CFX_Stream() - : m_eStreamType(FX_SREAMTYPE_Unknown), - m_pStreamImp(NULL), - m_dwAccess(0), - m_iTotalSize(0), - m_iPosition(0), - m_iStart(0), - m_iLength(0), - m_iRefCount(1) {} -CFX_Stream::~CFX_Stream() { - if (m_eStreamType != FX_STREAMTYPE_Stream && m_pStreamImp != NULL) { - m_pStreamImp->Release(); - } -} -FX_BOOL CFX_Stream::LoadFile(const FX_WCHAR* pszSrcFileName, - FX_DWORD dwAccess) { - if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { - return FALSE; - } - if (pszSrcFileName == NULL || FXSYS_wcslen(pszSrcFileName) < 1) { - return FALSE; - } - m_pStreamImp = new CFX_FileStreamImp(); - FX_BOOL bRet = - ((CFX_FileStreamImp*)m_pStreamImp)->LoadFile(pszSrcFileName, dwAccess); - if (!bRet) { - m_pStreamImp->Release(); - m_pStreamImp = NULL; - } else { - m_eStreamType = FX_STREAMTYPE_File; - m_dwAccess = dwAccess; - m_iLength = m_pStreamImp->GetLength(); - } - return bRet; -} -FX_BOOL CFX_Stream::LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess) { - if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { - return FALSE; - } - if (pFileRead == NULL) { - return FALSE; - } - m_pStreamImp = new CFX_FileReadStreamImp(); - FX_BOOL bRet = - ((CFX_FileReadStreamImp*)m_pStreamImp)->LoadFileRead(pFileRead, dwAccess); - if (!bRet) { - m_pStreamImp->Release(); - m_pStreamImp = NULL; - } else { - m_eStreamType = FX_STREAMTYPE_File; - m_dwAccess = dwAccess; - m_iLength = m_pStreamImp->GetLength(); - } - return bRet; -} -FX_BOOL CFX_Stream::LoadFileWrite(IFX_FileWrite* pFileWrite, - FX_DWORD dwAccess) { - if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { - return FALSE; - } - if (pFileWrite == NULL) { - return FALSE; - } - m_pStreamImp = new CFX_FileWriteStreamImp(); - FX_BOOL bRet = ((CFX_FileWriteStreamImp*)m_pStreamImp) - ->LoadFileWrite(pFileWrite, dwAccess); - if (!bRet) { - m_pStreamImp->Release(); - m_pStreamImp = NULL; - } else { - m_eStreamType = FX_STREAMTYPE_File; - m_dwAccess = dwAccess; - m_iLength = m_pStreamImp->GetLength(); - } - return bRet; -} -FX_BOOL CFX_Stream::LoadBuffer(uint8_t* pData, - int32_t iTotalSize, - FX_DWORD dwAccess) { - if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { - return FALSE; - } - if (pData == NULL || iTotalSize < 1) { - return FALSE; - } - m_pStreamImp = new CFX_BufferStreamImp(); - FX_BOOL bRet = ((CFX_BufferStreamImp*)m_pStreamImp) - ->LoadBuffer(pData, iTotalSize, dwAccess); - if (!bRet) { - m_pStreamImp->Release(); - m_pStreamImp = NULL; - } else { - m_eStreamType = FX_STREAMTYPE_Buffer; - m_dwAccess = dwAccess; - m_iLength = m_pStreamImp->GetLength(); - } - return bRet; -} -FX_BOOL CFX_Stream::LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - FX_DWORD dwAccess, - FX_BOOL bReleaseBufferRead) { - if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp != NULL) { - return FALSE; - } - if (!pBufferRead) { - return FALSE; - } - m_pStreamImp = new CFX_BufferReadStreamImp; - FX_BOOL bRet = ((CFX_BufferReadStreamImp*)m_pStreamImp) - ->LoadBufferRead(pBufferRead, iFileSize, dwAccess, - bReleaseBufferRead); - if (!bRet) { - m_pStreamImp->Release(); - m_pStreamImp = NULL; - } else { - m_eStreamType = FX_STREAMTYPE_BufferRead; - m_dwAccess = dwAccess; - m_iLength = m_pStreamImp->GetLength(); - } - return bRet; -} -void CFX_Stream::Release() { - if (--m_iRefCount < 1) { - delete this; - } -} -IFX_Stream* CFX_Stream::Retain() { - m_iRefCount++; - return this; -} -int32_t CFX_Stream::GetLength() const { - if (m_pStreamImp == NULL) { - return -1; - } - if (m_eStreamType == FX_STREAMTYPE_File || - m_eStreamType == FX_STREAMTYPE_Buffer) { - return m_pStreamImp->GetLength(); - } - return m_iLength; -} -int32_t CFX_Stream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - if (m_pStreamImp == NULL) { - return -1; - } - if (m_eStreamType == FX_STREAMTYPE_File || - m_eStreamType == FX_STREAMTYPE_Buffer) { - return m_iPosition = m_pStreamImp->Seek(eSeek, iOffset); - } - int32_t iEnd = m_iStart + m_iLength; - int32_t iPosition = m_iStart + iOffset; - if (eSeek == FX_STREAMSEEK_Begin) { - m_iPosition = iPosition; - } else if (eSeek == FX_STREAMSEEK_Current) { - m_iPosition += iOffset; - } else if (eSeek == FX_STREAMSEEK_End) { - m_iPosition = iEnd + iOffset; - } - if (m_iPosition > iEnd) { - m_iPosition = iEnd; - } - if (m_iPosition < m_iStart) { - m_iPosition = m_iStart; - } - return m_iPosition - m_iStart; -} -int32_t CFX_Stream::GetPosition() { - if (m_pStreamImp == NULL) { - return -1; - } - if (m_eStreamType == FX_STREAMTYPE_File || - m_eStreamType == FX_STREAMTYPE_Buffer) { - return m_iPosition = m_pStreamImp->GetPosition(); - } - return m_iPosition - m_iStart; -} -FX_BOOL CFX_Stream::IsEOF() const { - if (m_pStreamImp == NULL) { - return TRUE; - } - if (m_eStreamType == FX_STREAMTYPE_File || - m_eStreamType == FX_STREAMTYPE_Buffer) { - return m_pStreamImp->IsEOF(); - } - return m_iPosition >= m_iStart + m_iLength; -} -int32_t CFX_Stream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - FXSYS_assert(pBuffer != NULL && iBufferSize > 0); - if (m_pStreamImp == NULL) { - return -1; - } - int32_t iLen = std::min(m_iStart + m_iLength - m_iPosition, iBufferSize); - if (iLen <= 0) { - return 0; - } - if (m_pStreamImp->GetPosition() != m_iPosition) { - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); - } - iLen = m_pStreamImp->ReadData(pBuffer, iLen); - m_iPosition = m_pStreamImp->GetPosition(); - return iLen; -} -int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize) { - FXSYS_assert(pStr != NULL && iMaxLength > 0); - if (m_pStreamImp == NULL) { - return -1; - } - int32_t iEnd = m_iStart + m_iLength; - int32_t iLen = iEnd - m_iPosition; - if (pByteSize != NULL) { - iLen = std::min(iLen, *pByteSize); - } - iLen = std::min(iEnd / 2, iMaxLength); - if (iLen <= 0) { - return 0; - } - if (m_pStreamImp->GetPosition() != m_iPosition) { - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); - } - iLen = m_pStreamImp->ReadString(pStr, iLen, bEOS); - m_iPosition = m_pStreamImp->GetPosition(); - if (iLen > 0 && m_iPosition >= iEnd) { - bEOS = TRUE; - } - return iLen; -} -int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - FXSYS_assert(pBuffer != NULL && iBufferSize > 0); - if (m_pStreamImp == NULL) { - return -1; - } - if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { - return -1; - } - int32_t iLen = iBufferSize; - if (m_eStreamType == FX_STREAMTYPE_Stream) { - iLen = std::min(m_iStart + m_iTotalSize - m_iPosition, iBufferSize); - if (iLen <= 0) { - return 0; - } - } - int32_t iEnd = m_iStart + m_iLength; - if (m_pStreamImp->GetPosition() != m_iPosition) { - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); - } - iLen = m_pStreamImp->WriteData(pBuffer, iLen); - m_iPosition = m_pStreamImp->GetPosition(); - if (m_iPosition > iEnd) { - m_iLength = m_iPosition - m_iStart; - } - return iLen; -} -int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { - FXSYS_assert(pStr != NULL && iLength > 0); - if (m_pStreamImp == NULL) { - return -1; - } - if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { - return -1; - } - int32_t iLen = iLength; - if (m_eStreamType == FX_STREAMTYPE_Stream) { - iLen = std::min((m_iStart + m_iTotalSize - m_iPosition) / 2, iLength); - if (iLen <= 0) { - return 0; - } - } - int32_t iEnd = m_iStart + m_iLength; - if (m_pStreamImp->GetPosition() != m_iPosition) { - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); - } - iLen = m_pStreamImp->WriteString(pStr, iLen); - m_iPosition = m_pStreamImp->GetPosition(); - if (m_iPosition > iEnd) { - m_iLength = m_iPosition - m_iStart; - } - return iLen; -} -void CFX_Stream::Flush() { - if (m_pStreamImp == NULL) { - return; - } - if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { - return; - } - m_pStreamImp->Flush(); -} -FX_BOOL CFX_Stream::SetLength(int32_t iLength) { - if (m_pStreamImp == NULL) { - return FALSE; - } - if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { - return FALSE; - } - return m_pStreamImp->SetLength(iLength); -} -int32_t CFX_Stream::GetBOM(uint8_t bom[4]) const { - if (m_pStreamImp == NULL) { - return -1; - } - return 0; -} -FX_WORD CFX_Stream::GetCodePage() const { -#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ - return FX_CODEPAGE_UTF16LE; -#else - return FX_CODEPAGE_UTF16BE; -#endif -} -FX_WORD CFX_Stream::SetCodePage(FX_WORD wCodePage) { -#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ - return FX_CODEPAGE_UTF16LE; -#else - return FX_CODEPAGE_UTF16BE; -#endif -} -IFX_Stream* CFX_Stream::CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength) { - FXSYS_assert(iLength > 0); - if (m_pStreamImp == NULL) { - return NULL; - } - if ((m_dwAccess & FX_STREAMACCESS_Text) != 0 && - (dwAccess & FX_STREAMACCESS_Text) == 0) { - return NULL; - } - if ((m_dwAccess & FX_STREAMACCESS_Write) == 0 && - (dwAccess & FX_STREAMACCESS_Write) != 0) { - return NULL; - } - int32_t iStart = m_iStart + iOffset; - int32_t iTotal = m_iStart + m_iLength; - if (iStart < m_iStart || iStart >= iTotal) { - return NULL; - } - int32_t iEnd = iStart + iLength; - if (iEnd < iStart || iEnd > iTotal) { - return NULL; - } - CFX_Stream* pShared = new CFX_Stream; - pShared->m_eStreamType = FX_STREAMTYPE_Stream; - pShared->m_pStreamImp = m_pStreamImp; - pShared->m_dwAccess = dwAccess; - pShared->m_iTotalSize = iLength; - pShared->m_iPosition = iStart; - pShared->m_iStart = iStart; - pShared->m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iLength; - if (dwAccess & FX_STREAMACCESS_Text) { - return IFX_Stream::CreateTextStream(pShared, TRUE); - } - return pShared; -} -IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream) { - FXSYS_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); -} -CFGAS_FileRead::~CFGAS_FileRead() { - if (m_bReleaseStream) { - m_pStream->Release(); - } -} -FX_FILESIZE CFGAS_FileRead::GetSize() { - return (FX_FILESIZE)m_pStream->GetLength(); -} -FX_BOOL CFGAS_FileRead::ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) { - m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset); - int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size); - return iLen == (int32_t)size; -} - -IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead, - FX_FILESIZE iFileSize, - FX_BOOL bReleaseStream) { - if (!pBufferRead) { - return NULL; - } - return new CFX_BufferAccImp(pBufferRead, iFileSize, bReleaseStream); -} -CFX_BufferAccImp::CFX_BufferAccImp(IFX_BufferRead* pBufferRead, - FX_FILESIZE iFileSize, - FX_BOOL bReleaseStream) - : m_pBufferRead(pBufferRead), - m_bReleaseStream(bReleaseStream), - m_iBufSize(iFileSize) { - FXSYS_assert(m_pBufferRead); -} -CFX_BufferAccImp::~CFX_BufferAccImp() { - if (m_bReleaseStream && m_pBufferRead) { - m_pBufferRead->Release(); - } -} -FX_FILESIZE CFX_BufferAccImp::GetSize() { - if (!m_pBufferRead) { - return 0; - } - if (m_iBufSize >= 0) { - return m_iBufSize; - } - if (!m_pBufferRead->ReadNextBlock(TRUE)) { - return 0; - } - m_iBufSize = (FX_FILESIZE)m_pBufferRead->GetBlockSize(); - while (!m_pBufferRead->IsEOF()) { - m_pBufferRead->ReadNextBlock(FALSE); - m_iBufSize += (FX_FILESIZE)m_pBufferRead->GetBlockSize(); - } - return m_iBufSize; -} -FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) { - if (!m_pBufferRead) { - return FALSE; - } - if (!buffer || !size) { - return TRUE; - } - FX_FILESIZE dwBufSize = GetSize(); - if (offset >= dwBufSize) { - return FALSE; - } - size_t dwBlockSize = m_pBufferRead->GetBlockSize(); - FX_FILESIZE dwBlockOffset = m_pBufferRead->GetBlockOffset(); - if (offset < dwBlockOffset) { - if (!m_pBufferRead->ReadNextBlock(TRUE)) { - return FALSE; - } - dwBlockSize = m_pBufferRead->GetBlockSize(); - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - } - while (offset < dwBlockOffset || - offset >= (FX_FILESIZE)(dwBlockOffset + dwBlockSize)) { - if (m_pBufferRead->IsEOF() || !m_pBufferRead->ReadNextBlock(FALSE)) { - break; - } - dwBlockSize = m_pBufferRead->GetBlockSize(); - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - } - if (offset < dwBlockOffset || - offset >= (FX_FILESIZE)(dwBlockOffset + dwBlockSize)) { - return FALSE; - } - const uint8_t* pBuffer = m_pBufferRead->GetBlockBuffer(); - const FX_FILESIZE dwOffset = offset - dwBlockOffset; - size_t dwCopySize = - std::min(size, static_cast<size_t>(dwBlockSize - dwOffset)); - FXSYS_memcpy(buffer, pBuffer + dwOffset, dwCopySize); - offset = dwCopySize; - size -= dwCopySize; - while (size) { - if (!m_pBufferRead->ReadNextBlock(FALSE)) { - break; - } - dwBlockOffset = m_pBufferRead->GetBlockOffset(); - dwBlockSize = m_pBufferRead->GetBlockSize(); - pBuffer = m_pBufferRead->GetBlockBuffer(); - dwCopySize = std::min(size, dwBlockSize); - FXSYS_memcpy(((uint8_t*)buffer) + offset, pBuffer, dwCopySize); - offset += dwCopySize; - size -= dwCopySize; - } - return TRUE; -} - -IFX_FileWrite* FX_CreateFileWrite(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream) { - FXSYS_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); -} -CFGAS_FileWrite::~CFGAS_FileWrite() { - if (m_bReleaseStream) { - m_pStream->Release(); - } -} -FX_FILESIZE CFGAS_FileWrite::GetSize() { - return m_pStream->GetLength(); -} -FX_BOOL CFGAS_FileWrite::Flush() { - m_pStream->Flush(); - return TRUE; -} -FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, size_t size) { - return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) == - (int32_t)size; -} -FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, - FX_FILESIZE offset, - size_t size) { - m_pStream->Seek(FX_STREAMSEEK_Begin, offset); - int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size); - return iLen == (int32_t)size; -} diff --git a/xfa/src/fgas/crt/fgas_stream.h b/xfa/src/fgas/crt/fgas_stream.h deleted file mode 100644 index cc40a76cc6..0000000000 --- a/xfa/src/fgas/crt/fgas_stream.h +++ /dev/null @@ -1,78 +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_SRC_FGAS_CRT_FGAS_STREAM_H_ -#define XFA_SRC_FGAS_CRT_FGAS_STREAM_H_ - -#include "core/include/fxcrt/fx_stream.h" -#include "core/include/fxcrt/fx_system.h" - -class IFX_Stream; - -IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream = FALSE); -IFX_FileRead* FX_CreateFileRead(IFX_BufferRead* pBufferRead, - FX_FILESIZE iFileSize = -1, - FX_BOOL bReleaseStream = TRUE); -IFX_FileWrite* FX_CreateFileWrite(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream = FALSE); -enum FX_STREAMACCESS { - FX_STREAMACCESS_Binary = 0x00, - FX_STREAMACCESS_Text = 0x01, - FX_STREAMACCESS_Read = 0x02, - FX_STREAMACCESS_Write = 0x04, - FX_STREAMACCESS_Truncate = 0x10, - FX_STREAMACCESS_Append = 0x20, - FX_STREAMACCESS_Create = 0x80, -}; - -enum FX_STREAMSEEK { - FX_STREAMSEEK_Begin = 0, - FX_STREAMSEEK_Current, - FX_STREAMSEEK_End, -}; - -class IFX_Stream { - public: - static IFX_Stream* CreateStream(IFX_FileRead* pFileRead, FX_DWORD dwAccess); - static IFX_Stream* CreateStream(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess); - static IFX_Stream* CreateStream(const FX_WCHAR* pszFileName, - FX_DWORD dwAccess); - static IFX_Stream* CreateStream(uint8_t* pData, - int32_t length, - FX_DWORD dwAccess); - static IFX_Stream* CreateStream(IFX_BufferRead* pBufferRead, - FX_DWORD dwAccess, - int32_t iFileSize = -1, - FX_BOOL bReleaseBufferRead = TRUE); - static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, - FX_BOOL bDeleteOnRelease); - virtual ~IFX_Stream() {} - virtual void Release() = 0; - virtual IFX_Stream* Retain() = 0; - virtual FX_DWORD GetAccessModes() const = 0; - virtual int32_t GetLength() const = 0; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; - virtual int32_t GetPosition() = 0; - virtual FX_BOOL IsEOF() const = 0; - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL) = 0; - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; - virtual void Flush() = 0; - virtual FX_BOOL SetLength(int32_t iLength) = 0; - virtual int32_t GetBOM(uint8_t bom[4]) const = 0; - virtual FX_WORD GetCodePage() const = 0; - virtual FX_WORD SetCodePage(FX_WORD wCodePage) = 0; - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength) = 0; -}; - -#endif // XFA_SRC_FGAS_CRT_FGAS_STREAM_H_ diff --git a/xfa/src/fgas/crt/fgas_system.cpp b/xfa/src/fgas/crt/fgas_system.cpp deleted file mode 100644 index a4ca7546e0..0000000000 --- a/xfa/src/fgas/crt/fgas_system.cpp +++ /dev/null @@ -1,117 +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/src/fgas/crt/fgas_system.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_system.h" - -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ -#include <io.h> -#elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_Mini_ -#include <sys/times.h> -#endif - -namespace { - -inline FX_BOOL FX_isupper(int32_t ch) { - return ch >= 'A' && ch <= 'Z'; -} - -inline int32_t FX_tolower(int32_t ch) { - return FX_isupper(ch) ? (ch + 0x20) : 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); - FX_WCHAR wch1 = 0, wch2 = 0; - while (count-- > 0) { - wch1 = (FX_WCHAR)FX_tolower(*s1++); - wch2 = (FX_WCHAR)FX_tolower(*s2++); - if (wch1 != wch2) { - break; - } - } - return wch1 - wch2; -} - -int32_t FX_filelength(FXSYS_FILE* file) { - FXSYS_assert(file != NULL); -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ - return _filelength(_fileno(file)); -#else - int32_t iPos = FXSYS_ftell(file); - FXSYS_fseek(file, 0, FXSYS_SEEK_END); - int32_t iLen = FXSYS_ftell(file); - FXSYS_fseek(file, iPos, FXSYS_SEEK_SET); - return iLen; -#endif -} - -FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size) { - FXSYS_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_ - HANDLE hFile = _fileno(file); - FX_DWORD dwPos = ::SetFilePointer(hFile, 0, 0, FILE_CURRENT); - ::SetFilePointer(hFile, size, 0, FILE_BEGIN); - FX_BOOL bRet = ::SetEndOfFile(hFile); - ::SetFilePointer(hFile, (int32_t)dwPos, 0, FILE_BEGIN); - return bRet; -#else - return FALSE; -#endif -} - -FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { - FXSYS_assert(pwsStr != NULL); - if (iLength < 0) { - iLength = FXSYS_wcslen(pwsStr); - } - if (iLength == 0) { - return 0.0f; - } - int32_t iUsedLen = 0; - FX_BOOL bNegtive = FALSE; - switch (pwsStr[iUsedLen]) { - case '-': - bNegtive = TRUE; - case '+': - iUsedLen++; - break; - } - FX_FLOAT fValue = 0.0f; - while (iUsedLen < iLength) { - FX_WCHAR wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') { - fValue = fValue * 10.0f + (wch - L'0'); - } else { - break; - } - iUsedLen++; - } - if (iUsedLen < iLength && pwsStr[iUsedLen] == L'.') { - FX_FLOAT fPrecise = 0.1f; - while (++iUsedLen < iLength) { - FX_WCHAR wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') { - fValue += (wch - L'0') * fPrecise; - fPrecise *= 0.1f; - } else { - break; - } - } - } - if (pUsedLen) { - *pUsedLen = iUsedLen; - } - return bNegtive ? -fValue : fValue; -} diff --git a/xfa/src/fgas/crt/fgas_system.h b/xfa/src/fgas/crt/fgas_system.h deleted file mode 100644 index fb5a88efb5..0000000000 --- a/xfa/src/fgas/crt/fgas_system.h +++ /dev/null @@ -1,23 +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_SRC_FGAS_CRT_FGAS_SYSTEM_H_ -#define XFA_SRC_FGAS_CRT_FGAS_SYSTEM_H_ - -#include "core/include/fxcrt/fx_system.h" - -#define FX_RAD2DEG(r) ((r)*180.0f / FX_PI) -#define FX_DEG2RAD(a) ((a)*FX_PI / 180.0f) - -FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, - int32_t iLength = -1, - int32_t* pUsedLen = NULL); -int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); - -int32_t FX_filelength(FXSYS_FILE* file); -FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size); - -#endif // XFA_SRC_FGAS_CRT_FGAS_SYSTEM_H_ diff --git a/xfa/src/fgas/crt/fgas_utils.cpp b/xfa/src/fgas/crt/fgas_utils.cpp deleted file mode 100644 index 8b3ed0aa0b..0000000000 --- a/xfa/src/fgas/crt/fgas_utils.cpp +++ /dev/null @@ -1,434 +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/src/fgas/crt/fgas_utils.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_basic.h" - -class FX_BASEARRAYDATA : public CFX_Target { - public: - FX_BASEARRAYDATA(int32_t growsize, int32_t blocksize) - : iGrowSize(growsize), - iBlockSize(blocksize), - iTotalCount(0), - iBlockCount(0), - pBuffer(nullptr) {} - - ~FX_BASEARRAYDATA() { FX_Free(pBuffer); } - - int32_t iGrowSize; - int32_t iBlockSize; - int32_t iTotalCount; - int32_t iBlockCount; - uint8_t* pBuffer; -}; -CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) { - FXSYS_assert(iGrowSize > 0 && iBlockSize > 0); - m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize); -} -CFX_BaseArray::~CFX_BaseArray() { - RemoveAll(); - delete m_pData; -} -int32_t CFX_BaseArray::GetSize() const { - return m_pData->iBlockCount; -} -int32_t CFX_BaseArray::GetBlockSize() const { - return m_pData->iBlockSize; -} -uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) { - FXSYS_assert(index > -1); - uint8_t*& pBuffer = m_pData->pBuffer; - int32_t& iTotalCount = m_pData->iTotalCount; - int32_t iBlockSize = m_pData->iBlockSize; - if (index >= iTotalCount) { - int32_t iGrowSize = m_pData->iGrowSize; - iTotalCount = (index / iGrowSize + 1) * iGrowSize; - int32_t iNewSize = iTotalCount * iBlockSize; - if (!pBuffer) { - pBuffer = FX_Alloc(uint8_t, iNewSize); - } else { - pBuffer = FX_Realloc(uint8_t, pBuffer, iNewSize); - } - } - int32_t& iBlockCount = m_pData->iBlockCount; - if (index >= iBlockCount) { - iBlockCount = index + 1; - } - return pBuffer + index * iBlockSize; -} -uint8_t* CFX_BaseArray::GetAt(int32_t index) const { - FXSYS_assert(index > -1 && index < m_pData->iBlockCount); - return m_pData->pBuffer + index * m_pData->iBlockSize; -} -uint8_t* CFX_BaseArray::GetBuffer() const { - return m_pData->pBuffer; -} -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); - int32_t& iBlockCount = m_pData->iBlockCount; - int32_t iAdded = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iAdded); - if (iCount < 0) { - iCount = iAdded; - } - if (iStart + iCount > iAdded) { - iCount = iAdded - iStart; - } - if (iCount < 1) { - return 0; - } - uint8_t* pDst = m_pData->pBuffer + iBlockCount * iBlockSize; - AddSpaceTo(iBlockCount + iCount - 1); - FXSYS_memcpy(pDst, src.m_pData->pBuffer + iStart * iBlockSize, - iCount * iBlockSize); - return iCount; -} -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); - int32_t iCopied = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iCopied); - if (iCount < 0) { - iCount = iCopied; - } - if (iStart + iCount > iCopied) { - iCount = iCopied - iStart; - } - if (iCount < 1) { - return 0; - } - RemoveAll(TRUE); - AddSpaceTo(iCount - 1); - FXSYS_memcpy(m_pData->pBuffer, src.m_pData->pBuffer + iStart * iBlockSize, - iCount * iBlockSize); - return iCount; -} -int32_t CFX_BaseArray::RemoveLast(int32_t iCount) { - int32_t& iBlockCount = m_pData->iBlockCount; - if (iCount < 0 || iCount > iBlockCount) { - iCount = iBlockCount; - iBlockCount = 0; - } else { - iBlockCount -= iCount; - } - return iCount; -} -void CFX_BaseArray::RemoveAll(FX_BOOL bLeaveMemory) { - if (!bLeaveMemory) { - uint8_t*& pBuffer = m_pData->pBuffer; - if (pBuffer != NULL) { - FX_Free(pBuffer); - pBuffer = NULL; - } - m_pData->iTotalCount = 0; - } - m_pData->iBlockCount = 0; -} - -CFX_BaseMassArrayImp::CFX_BaseMassArrayImp(int32_t iChunkSize, - int32_t iBlockSize) - : 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_pData->SetSize(16); -} -CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() { - RemoveAll(); - delete m_pData; -} -uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { - FXSYS_assert(index > -1); - uint8_t* pChunk; - if (index < m_iBlockCount) { - pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); - } else { - int32_t iMemSize = m_iChunkSize * m_iBlockSize; - while (TRUE) { - if (index < m_iChunkCount * m_iChunkSize) { - pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); - break; - } else { - pChunk = FX_Alloc(uint8_t, iMemSize); - if (m_iChunkCount < m_pData->GetSize()) { - m_pData->SetAt(m_iChunkCount, pChunk); - } else { - m_pData->Add(pChunk); - } - m_iChunkCount++; - } - } - } - FXSYS_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); - uint8_t* pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); - FXSYS_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); - int32_t iAdded = src.m_iBlockCount; - FXSYS_assert(iStart > -1 && iStart < iAdded); - if (iCount < 0) { - iCount = iAdded; - } - if (iStart + iCount > iAdded) { - iCount = iAdded - iStart; - } - if (iCount < 1) { - return m_iBlockCount; - } - int32_t iBlockCount = m_iBlockCount; - int32_t iTotal = m_iBlockCount + iCount; - AddSpaceTo(iTotal - 1); - Append(iBlockCount, src, iStart, iCount); - return m_iBlockCount; -} -int32_t CFX_BaseMassArrayImp::Copy(const CFX_BaseMassArrayImp& src, - int32_t iStart, - int32_t iCount) { - FXSYS_assert(m_iBlockSize == src.m_iBlockSize); - int32_t iCopied = src.m_iBlockCount; - FXSYS_assert(iStart > -1); - if (iStart >= iCopied) { - return 0; - } - RemoveAll(TRUE); - if (iCount < 0) { - iCount = iCopied; - } - if (iStart + iCount > iCopied) { - iCount = iCopied - iStart; - } - if (iCount < 1) { - return 0; - } - if (m_iBlockCount < iCount) { - AddSpaceTo(iCount - 1); - } - Append(0, src, iStart, iCount); - return m_iBlockCount; -} - -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); - - int32_t iDstChunkIndex = iDstStart / m_iChunkSize; - int32_t iSrcChunkIndex = iSrcStart / src.m_iChunkSize; - uint8_t* pDstChunk = (uint8_t*)GetAt(iDstStart); - uint8_t* pSrcChunk = (uint8_t*)src.GetAt(iSrcStart); - int32_t iDstChunkSize = m_iChunkSize - (iDstStart % m_iChunkSize); - int32_t iSrcChunkSize = src.m_iChunkSize - (iSrcStart % src.m_iChunkSize); - int32_t iCopySize = - std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); - int32_t iCopyBytes = iCopySize * m_iBlockSize; - while (iSrcCount > 0) { - FXSYS_assert(pDstChunk != NULL && pSrcChunk != NULL); - FXSYS_memcpy(pDstChunk, pSrcChunk, iCopyBytes); - iSrcCount -= iCopySize; - iSrcChunkSize -= iCopySize; - if (iSrcChunkSize < 1) { - iSrcChunkSize = src.m_iChunkSize; - iSrcChunkIndex++; - pSrcChunk = (uint8_t*)src.m_pData->GetAt(iSrcChunkIndex); - } else { - pSrcChunk += iCopyBytes; - } - iDstChunkSize -= iCopySize; - if (iDstChunkSize < 1) { - iDstChunkSize = m_iChunkSize; - iDstChunkIndex++; - pDstChunk = (uint8_t*)m_pData->GetAt(iDstChunkIndex); - } else { - pDstChunk += iCopyBytes; - } - iCopySize = std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); - iCopyBytes = iCopySize * m_iBlockSize; - } -} -int32_t CFX_BaseMassArrayImp::RemoveLast(int32_t iCount) { - if (iCount < 0 || iCount >= m_iBlockCount) { - m_iBlockCount = 0; - } else { - m_iBlockCount -= iCount; - } - return m_iBlockCount; -} -void CFX_BaseMassArrayImp::RemoveAll(FX_BOOL bLeaveMemory) { - if (bLeaveMemory) { - m_iBlockCount = 0; - return; - } - for (int32_t i = 0; i < m_iChunkCount; i++) { - void* p = m_pData->GetAt(i); - if (p == NULL) { - continue; - } - FX_Free(p); - } - m_pData->RemoveAll(); - m_iChunkCount = 0; - m_iBlockCount = 0; -} -CFX_BaseMassArray::CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize) { - m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize); -} -CFX_BaseMassArray::~CFX_BaseMassArray() { - delete m_pData; -} -int32_t CFX_BaseMassArray::GetSize() const { - return m_pData->m_iBlockCount; -} -uint8_t* CFX_BaseMassArray::AddSpaceTo(int32_t index) { - return m_pData->AddSpaceTo(index); -} -uint8_t* CFX_BaseMassArray::GetAt(int32_t index) const { - return m_pData->GetAt(index); -} -int32_t CFX_BaseMassArray::Append(const CFX_BaseMassArray& src, - int32_t iStart, - int32_t iCount) { - return m_pData->Append(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount); -} -int32_t CFX_BaseMassArray::Copy(const CFX_BaseMassArray& src, - int32_t iStart, - int32_t iCount) { - return m_pData->Copy(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount); -} -int32_t CFX_BaseMassArray::RemoveLast(int32_t iCount) { - return m_pData->RemoveLast(iCount); -} -void CFX_BaseMassArray::RemoveAll(FX_BOOL bLeaveMemory) { - m_pData->RemoveAll(bLeaveMemory); -} - -struct FX_BASEDISCRETEARRAYDATA { - int32_t iBlockSize; - int32_t iChunkSize; - int32_t iChunkCount; - CFX_PtrArray ChunkBuffer; -}; - -CFX_BaseDiscreteArray::CFX_BaseDiscreteArray(int32_t iChunkSize, - int32_t iBlockSize) { - FXSYS_assert(iChunkSize > 0 && iBlockSize > 0); - FX_BASEDISCRETEARRAYDATA* pData = new FX_BASEDISCRETEARRAYDATA; - m_pData = pData; - pData->ChunkBuffer.SetSize(16); - pData->iChunkCount = 0; - pData->iChunkSize = iChunkSize; - pData->iBlockSize = iBlockSize; -} -CFX_BaseDiscreteArray::~CFX_BaseDiscreteArray() { - RemoveAll(); - delete static_cast<FX_BASEDISCRETEARRAYDATA*>(m_pData); -} -uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) { - FXSYS_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); - } - if (!pChunk) { - pChunk = FX_Alloc2D(uint8_t, iChunkSize, pData->iBlockSize); - FXSYS_memset(pChunk, 0, iChunkSize * pData->iBlockSize); - pData->ChunkBuffer.SetAtGrow(iChunk, pChunk); - if (iChunkCount <= iChunk) { - iChunkCount = iChunk + 1; - } - } - return pChunk + (index % iChunkSize) * pData->iBlockSize; -} -uint8_t* CFX_BaseDiscreteArray::GetAt(int32_t index) const { - FXSYS_assert(index > -1); - 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; - } - return pChunk + (index % iChunkSize) * pData->iBlockSize; -} -void CFX_BaseDiscreteArray::RemoveAll() { - FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData; - CFX_PtrArray& 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); - } - ChunkBuffer.RemoveAll(); - iChunkCount = 0; -} -CFX_BaseStack::CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize) { - m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize); -} -CFX_BaseStack::~CFX_BaseStack() { - delete (CFX_BaseMassArrayImp*)m_pData; -} -uint8_t* CFX_BaseStack::Push() { - return m_pData->AddSpace(); -} -void CFX_BaseStack::Pop() { - int32_t& iBlockCount = m_pData->m_iBlockCount; - if (iBlockCount < 1) { - return; - } - iBlockCount--; -} -uint8_t* CFX_BaseStack::GetTopElement() const { - int32_t iSize = m_pData->m_iBlockCount; - if (iSize < 1) { - return NULL; - } - return m_pData->GetAt(iSize - 1); -} -int32_t CFX_BaseStack::GetSize() const { - return m_pData->m_iBlockCount; -} -uint8_t* CFX_BaseStack::GetAt(int32_t index) const { - return m_pData->GetAt(index); -} -void CFX_BaseStack::RemoveAll(FX_BOOL bLeaveMemory) { - m_pData->RemoveAll(bLeaveMemory); -} diff --git a/xfa/src/fgas/crt/fgas_utils.h b/xfa/src/fgas/crt/fgas_utils.h deleted file mode 100644 index f52255a5d3..0000000000 --- a/xfa/src/fgas/crt/fgas_utils.h +++ /dev/null @@ -1,737 +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_SRC_FGAS_CRT_FGAS_UTILS_H_ -#define XFA_SRC_FGAS_CRT_FGAS_UTILS_H_ - -#include "core/include/fxcrt/fx_coordinates.h" -#include "xfa/src/fgas/crt/fgas_memory.h" - -class FX_BASEARRAYDATA; - -template <class baseType> -class CFX_CPLTree; - -class CFX_BaseArray : public CFX_Target { - protected: - CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); - ~CFX_BaseArray(); - int32_t GetSize() const; - int32_t GetBlockSize() const; - uint8_t* AddSpaceTo(int32_t index); - uint8_t* GetAt(int32_t index) const; - uint8_t* GetBuffer() const; - int32_t Append(const CFX_BaseArray& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t Copy(const CFX_BaseArray& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t RemoveLast(int32_t iCount = -1); - void RemoveAll(FX_BOOL bLeaveMemory = FALSE); - - FX_BASEARRAYDATA* m_pData; -}; - -template <class baseType> -class CFX_BaseArrayTemplate : public CFX_BaseArray { - public: - CFX_BaseArrayTemplate(int32_t iGrowSize = 100) - : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} - CFX_BaseArrayTemplate(int32_t iGrowSize, int32_t iBlockSize) - : CFX_BaseArray(iGrowSize, iBlockSize) {} - int32_t GetSize() const { return CFX_BaseArray::GetSize(); } - int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } - baseType* AddSpace() { - return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize()); - } - int32_t Add(const baseType& element) { - int32_t index = CFX_BaseArray::GetSize(); - *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; - return index; - } - baseType* GetBuffer() const { return (baseType*)CFX_BaseArray::GetBuffer(); } - baseType& GetAt(int32_t index) const { - return *(baseType*)CFX_BaseArray::GetAt(index); - } - baseType* GetPtrAt(int32_t index) const { - return (baseType*)CFX_BaseArray::GetAt(index); - } - void SetAt(int32_t index, const baseType& element) { - *(baseType*)CFX_BaseArray::GetAt(index) = element; - } - void SetAtGrow(int32_t index, const baseType& element) { - *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; - } - int32_t Append(const CFX_BaseArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - return CFX_BaseArray::Append(src, iStart, iCount); - } - int32_t Copy(const CFX_BaseArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - return CFX_BaseArray::Copy(src, iStart, iCount); - } - int32_t RemoveLast(int32_t iCount = -1) { - return CFX_BaseArray::RemoveLast(iCount); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - CFX_BaseArray::RemoveAll(bLeaveMemory); - } -}; -typedef CFX_BaseArrayTemplate<void*> CFDE_PtrArray; -typedef CFX_BaseArrayTemplate<FX_DWORD> CFDE_DWordArray; -typedef CFX_BaseArrayTemplate<FX_WORD> CFDE_WordArray; - -template <class baseType> -class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray { - public: - CFX_ObjectBaseArrayTemplate(int32_t iGrowSize = 100) - : CFX_BaseArray(iGrowSize, sizeof(baseType)) {} - ~CFX_ObjectBaseArrayTemplate() { RemoveAll(FALSE); } - int32_t GetSize() const { return CFX_BaseArray::GetSize(); } - int32_t GetBlockSize() const { return CFX_BaseArray::GetBlockSize(); } - int32_t Add(const baseType& element) { - int32_t index = CFX_BaseArray::GetSize(); - baseType* p = (baseType*)CFX_BaseArray::AddSpaceTo(index); - new ((void*)p) baseType(element); - return index; - } - baseType& GetAt(int32_t index) const { - return *(baseType*)CFX_BaseArray::GetAt(index); - } - baseType* GetPtrAt(int32_t index) const { - return (baseType*)CFX_BaseArray::GetAt(index); - } - int32_t Append(const CFX_ObjectBaseArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - FXSYS_assert(GetBlockSize() == src.GetBlockSize()); - if (iCount == 0) { - return 0; - } - int32_t iSize = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iSize); - if (iCount < 0) { - iCount = iSize; - } - if (iStart + iCount > iSize) { - iCount = iSize - iStart; - } - if (iCount < 1) { - return 0; - } - iSize = CFX_BaseArray::GetSize(); - CFX_BaseArray::AddSpaceTo(iSize + iCount - 1); - uint8_t** pStart = CFX_BaseArray::GetAt(iSize); - int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); - iSize = iStart + iCount; - for (int32_t i = iStart; i < iSize; i++) { - FXTARGET_NewWith((void*)pStart) baseType(src.GetAt(i)); - pStart += iBlockSize; - } - return iCount; - } - int32_t Copy(const CFX_ObjectBaseArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - FXSYS_assert(GetBlockSize() == src.GetBlockSize()); - if (iCount == 0) { - return 0; - } - int32_t iSize = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iSize); - if (iCount < 0) { - iCount = iSize; - } - if (iStart + iCount > iSize) { - iCount = iSize - iStart; - } - if (iCount < 1) { - return 0; - } - RemoveAll(TRUE); - CFX_BaseArray::AddSpaceTo(iCount - 1); - uint8_t** pStart = CFX_BaseArray::GetAt(0); - int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); - iSize = iStart + iCount; - for (int32_t i = iStart; i < iSize; i++) { - new ((void*)pStart) baseType(src.GetAt(i)); - pStart += iBlockSize; - } - return iCount; - } - int32_t RemoveLast(int32_t iCount = -1) { - int32_t iSize = CFX_BaseArray::GetSize(); - if (iCount < 0 || iCount > iSize) { - iCount = iSize; - } - if (iCount == 0) { - return iSize; - } - for (int32_t i = iSize - iCount; i < iSize; i++) { - ((baseType*)GetPtrAt(i))->~baseType(); - } - return CFX_BaseArray::RemoveLast(iCount); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - int32_t iSize = CFX_BaseArray::GetSize(); - for (int32_t i = 0; i < iSize; i++) { - ((baseType*)GetPtrAt(i))->~baseType(); - } - CFX_BaseArray::RemoveAll(bLeaveMemory); - } -}; - -class CFX_BaseMassArrayImp : public CFX_Target { - public: - CFX_BaseMassArrayImp(int32_t iChunkSize, int32_t iBlockSize); - ~CFX_BaseMassArrayImp(); - uint8_t* AddSpace() { return AddSpaceTo(m_iBlockCount); } - uint8_t* AddSpaceTo(int32_t index); - uint8_t* GetAt(int32_t index) const; - int32_t Append(const CFX_BaseMassArrayImp& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t Copy(const CFX_BaseMassArrayImp& src, - int32_t iStart = 0, - 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; - - protected: - void Append(int32_t iDstStart, - const CFX_BaseMassArrayImp& src, - int32_t iSrcStart = 0, - int32_t iSrcCount = -1); -}; - -class CFX_BaseMassArray : public CFX_Target { - protected: - CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); - ~CFX_BaseMassArray(); - int32_t GetSize() const; - uint8_t* AddSpaceTo(int32_t index); - uint8_t* GetAt(int32_t index) const; - int32_t Append(const CFX_BaseMassArray& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t Copy(const CFX_BaseMassArray& src, - int32_t iStart = 0, - int32_t iCount = -1); - int32_t RemoveLast(int32_t iCount = -1); - void RemoveAll(FX_BOOL bLeaveMemory = FALSE); - CFX_BaseMassArrayImp* m_pData; -}; - -template <class baseType> -class CFX_MassArrayTemplate : public CFX_BaseMassArray { - public: - CFX_MassArrayTemplate(int32_t iChunkSize = 100) - : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} - CFX_MassArrayTemplate(int32_t iChunkSize, int32_t iBlockSize) - : CFX_BaseMassArray(iChunkSize, iBlockSize) {} - int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } - baseType* AddSpace() { - return (baseType*)CFX_BaseMassArray::AddSpaceTo( - CFX_BaseMassArray::GetSize()); - } - int32_t Add(const baseType& element) { - int32_t index = CFX_BaseMassArray::GetSize(); - *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; - return index; - } - baseType& GetAt(int32_t index) const { - return *(baseType*)CFX_BaseMassArray::GetAt(index); - } - baseType* GetPtrAt(int32_t index) const { - return (baseType*)CFX_BaseMassArray::GetAt(index); - } - void SetAt(int32_t index, const baseType& element) { - *(baseType*)CFX_BaseMassArray::GetAt(index) = element; - } - void SetAtGrow(int32_t index, const baseType& element) { - *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; - } - int32_t Append(const CFX_MassArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - return CFX_BaseMassArray::Append(src, iStart, iCount); - } - int32_t Copy(const CFX_MassArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - return CFX_BaseMassArray::Copy(src, iStart, iCount); - } - int32_t RemoveLast(int32_t iCount = -1) { - return CFX_BaseMassArray::RemoveLast(iCount); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - CFX_BaseMassArray::RemoveAll(bLeaveMemory); - } -}; -typedef CFX_MassArrayTemplate<void*> CFX_PtrMassArray; -typedef CFX_MassArrayTemplate<int32_t> CFX_Int32MassArray; -typedef CFX_MassArrayTemplate<FX_DWORD> CFX_DWordMassArray; -typedef CFX_MassArrayTemplate<FX_WORD> CFX_WordMassArray; -typedef CFX_MassArrayTemplate<CFX_Rect> CFX_RectMassArray; -typedef CFX_MassArrayTemplate<CFX_RectF> CFX_RectFMassArray; - -template <class baseType> -class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray { - public: - CFX_ObjectMassArrayTemplate(int32_t iChunkSize = 100) - : CFX_BaseMassArray(iChunkSize, sizeof(baseType)) {} - ~CFX_ObjectMassArrayTemplate() { RemoveAll(FALSE); } - int32_t GetSize() const { return CFX_BaseMassArray::GetSize(); } - int32_t Add(const baseType& element) { - int32_t index = CFX_BaseMassArray::GetSize(); - baseType* p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index); - new ((void*)p) baseType(element); - return index; - } - baseType& GetAt(int32_t index) const { - return *(baseType*)CFX_BaseMassArray::GetAt(index); - } - baseType* GetPtrAt(int32_t index) const { - return (baseType*)CFX_BaseMassArray::GetAt(index); - } - int32_t Append(const CFX_ObjectMassArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - if (iCount == 0) { - return CFX_BaseMassArray::GetSize(); - } - int32_t iSize = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iSize); - if (iCount < 0) { - iCount = iSize; - } - int32_t iEnd = iStart + iCount; - if (iEnd > iSize) { - iEnd = iSize; - } - for (int32_t i = iStart; i < iEnd; i++) { - Add(src.GetAt(i)); - } - return CFX_BaseMassArray::GetSize(); - } - int32_t Copy(const CFX_ObjectMassArrayTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - if (iCount == 0) { - return CFX_BaseMassArray::GetSize(); - } - int32_t iSize = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iSize); - if (iCount < 0) { - iCount = iSize; - } - int32_t iEnd = iStart + iCount; - if (iEnd > iSize) { - iEnd = iSize; - } - RemoveAll(TRUE); - for (int32_t i = iStart; i < iEnd; i++) { - Add(src.GetAt(i)); - } - return CFX_BaseMassArray::GetSize(); - } - int32_t RemoveLast(int32_t iCount = -1) { - int32_t iSize = CFX_BaseMassArray::GetSize(); - if (iCount < 0 || iCount > iSize) { - iCount = iSize; - } - if (iCount == 0) { - return iSize; - } - for (int32_t i = iSize - iCount; i < iSize; i++) { - ((baseType*)GetPtrAt(i))->~baseType(); - } - return CFX_BaseMassArray::RemoveLast(iCount); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - int32_t iSize = CFX_BaseMassArray::GetSize(); - for (int32_t i = 0; i < iSize; i++) { - ((baseType*)GetPtrAt(i))->~baseType(); - } - CFX_BaseMassArray::RemoveAll(bLeaveMemory); - } -}; - -class CFX_BaseDiscreteArray : public CFX_Target { - protected: - CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); - ~CFX_BaseDiscreteArray(); - uint8_t* AddSpaceTo(int32_t index); - uint8_t* GetAt(int32_t index) const; - void RemoveAll(); - void* m_pData; -}; - -template <class baseType> -class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { - public: - CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) - : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {} - baseType& GetAt(int32_t index, const baseType& defValue) const { - baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); - return p == NULL ? (baseType&)defValue : *p; - } - baseType* GetPtrAt(int32_t index) const { - return (baseType*)CFX_BaseDiscreteArray::GetAt(index); - } - void SetAtGrow(int32_t index, const baseType& element) { - *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; - } - void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } -}; -typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray; -typedef CFX_DiscreteArrayTemplate<FX_DWORD> CFX_DWordDiscreteArray; -typedef CFX_DiscreteArrayTemplate<FX_WORD> CFX_WordDiscreteArray; - -class CFX_BaseStack : public CFX_Target { - protected: - CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize); - ~CFX_BaseStack(); - uint8_t* Push(); - void Pop(); - uint8_t* GetTopElement() const; - int32_t GetSize() const; - uint8_t* GetAt(int32_t index) const; - void RemoveAll(FX_BOOL bLeaveMemory = FALSE); - CFX_BaseMassArrayImp* m_pData; -}; - -template <class baseType> -class CFX_StackTemplate : public CFX_BaseStack { - public: - CFX_StackTemplate(int32_t iChunkSize = 100) - : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} - int32_t Push(const baseType& element) { - int32_t index = CFX_BaseStack::GetSize(); - *(baseType*)CFX_BaseStack::Push() = element; - return index; - } - void Pop() { CFX_BaseStack::Pop(); } - baseType* GetTopElement() const { - return (baseType*)CFX_BaseStack::GetTopElement(); - } - int32_t GetSize() const { return CFX_BaseStack::GetSize(); } - baseType* GetAt(int32_t index) const { - return (baseType*)CFX_BaseStack::GetAt(index); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - CFX_BaseStack::RemoveAll(bLeaveMemory); - } -}; -typedef CFX_StackTemplate<void*> CFX_PtrStack; -typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack; -typedef CFX_StackTemplate<FX_WORD> CFX_WordStack; -typedef CFX_StackTemplate<int32_t> CFX_Int32Stack; - -template <class baseType> -class CFX_ObjectStackTemplate : public CFX_BaseStack { - public: - CFX_ObjectStackTemplate(int32_t iChunkSize = 100) - : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} - ~CFX_ObjectStackTemplate() { RemoveAll(); } - int32_t Push(const baseType& element) { - int32_t index = CFX_BaseStack::GetSize(); - baseType* p = (baseType*)CFX_BaseStack::Push(); - new ((void*)p) baseType(element); - return index; - } - void Pop() { - baseType* p = (baseType*)CFX_BaseStack::GetTopElement(); - if (p != NULL) { - p->~baseType(); - } - CFX_BaseStack::Pop(); - } - baseType* GetTopElement() const { - return (baseType*)CFX_BaseStack::GetTopElement(); - } - int32_t GetSize() const { return CFX_BaseStack::GetSize(); } - baseType* GetAt(int32_t index) const { - return (baseType*)CFX_BaseStack::GetAt(index); - } - void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { - int32_t iSize = CFX_BaseStack::GetSize(); - for (int32_t i = 0; i < iSize; i++) { - ((baseType*)CFX_BaseStack::GetAt(i))->~baseType(); - } - CFX_BaseStack::RemoveAll(bLeaveMemory); - } - int32_t Copy(const CFX_ObjectStackTemplate& src, - int32_t iStart = 0, - int32_t iCount = -1) { - if (iCount == 0) { - return CFX_BaseStack::GetSize(); - } - int32_t iSize = src.GetSize(); - FXSYS_assert(iStart > -1 && iStart < iSize); - if (iCount < 0) { - iCount = iSize; - } - int32_t iEnd = iStart + iCount; - if (iEnd > iSize) { - iEnd = iSize; - } - RemoveAll(TRUE); - for (int32_t i = iStart; i < iEnd; i++) { - Push(*src.GetAt(i)); - } - return CFX_BaseStack::GetSize(); - } -}; - -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_SRC_FGAS_CRT_FGAS_UTILS_H_ diff --git a/xfa/src/fgas/font/fgas_font.h b/xfa/src/fgas/font/fgas_font.h deleted file mode 100644 index 0484dee3e6..0000000000 --- a/xfa/src/fgas/font/fgas_font.h +++ /dev/null @@ -1,285 +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_SRC_FGAS_FONT_FGAS_FONT_H_ -#define XFA_SRC_FGAS_FONT_FGAS_FONT_H_ - -#include "core/include/fxge/fx_font.h" -#include "xfa/src/fgas/crt/fgas_stream.h" - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_utils.h" -#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - -class IFX_Font; -class IFX_FontMgr; - -#define FX_FONTSTYLE_Normal 0x00 -#define FX_FONTSTYLE_FixedPitch 0x01 -#define FX_FONTSTYLE_Serif 0x02 -#define FX_FONTSTYLE_Symbolic 0x04 -#define FX_FONTSTYLE_Script 0x08 -#define FX_FONTSTYLE_Italic 0x40 -#define FX_FONTSTYLE_Bold 0x40000 -#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic) -#define FX_FONTSTYLE_ExactMatch 0x80000000 -#define FX_FONTDECORATION_Underline 0x00000001 -#define FX_FONTDECORATION_Strikeout 0x00000002 -#define FX_FONTDECORATION_Overline 0x00000004 -#define FX_FONTDECORATION_Emphasis 0x00000008 -#define FX_FONTDECORATION_Superscript 0x00000010 -#define FX_FONTDECORATION_Subscript 0x00000020 -#define FX_FONTDECORATION_SmallCapital 0x00000040 -#define FX_FONTDECORATION_Capital 0x00000080 -#define FX_FONTDECORATION_Lowercase 0x000000C0 -#define FX_FONTDECORATION_Raised 0x00000100 -#define FX_FONTDECORATION_Sunken 0x00000200 -#define FX_FONTDECORATION_Shadow 0x00000400 -#define FX_FONTDECORATION_BoundingShape 0x20000000 -#define FX_FONTDECORATION_Hide 0x40000000 -#define FX_FONTDECORATION_StrokeFill 0x80000000 -#define FX_BOUNDINGSHAPE_None 0 -#define FX_BOUNDINGSHAPE_Circle 1 -#define FX_BOUNDINGSHAPE_Square 2 -#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, - FX_DWORD dwFontStyles, - FX_WORD wCodePage, - IFX_FontMgr* pFontMgr); - static IFX_Font* LoadFont(const uint8_t* pBuffer, - int32_t iLength, - IFX_FontMgr* pFontMgr); - static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr); - static IFX_Font* LoadFont(IFX_Stream* pFontStream, - IFX_FontMgr* pFontMgr, - FX_BOOL bSaveStream = FALSE); - static IFX_Font* LoadFont(CFX_Font* pExtFont, - IFX_FontMgr* pFontMgr, - FX_BOOL bTakeOver = FALSE); - virtual ~IFX_Font() {} - virtual void Release() = 0; - virtual IFX_Font* Retain() = 0; - virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0; - virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0; - virtual void GetPsName(CFX_WideString& wsName) const = 0; - virtual FX_DWORD GetFontStyles() const = 0; - virtual uint8_t GetCharSet() const = 0; - virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bCharCode = FALSE) = 0; - virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, - FX_BOOL bCharCode = FALSE) = 0; - virtual int32_t GetAscent() const = 0; - virtual int32_t GetDescent() const = 0; - virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, - FX_BOOL bCharCode = FALSE) = 0; - virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; - virtual int32_t GetItalicAngle() const = 0; - 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; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0; -#endif -}; -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -struct FX_FONTMATCHPARAMS { - const FX_WCHAR* pwsFamily; - FX_DWORD dwFontStyles; - FX_DWORD dwUSB; - FX_DWORD dwMatchFlags; - FX_WCHAR wUnicode; - FX_WORD wCodePage; -}; -typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS; -typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS; - -struct FX_FONTSIGNATURE { - FX_DWORD fsUsb[4]; - FX_DWORD fsCsb[2]; -}; -inline bool operator==(const FX_FONTSIGNATURE& left, - const FX_FONTSIGNATURE& right) { - return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] && - left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] && - left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1]; -} - -struct FX_FONTDESCRIPTOR { - FX_WCHAR wsFontFace[32]; - FX_DWORD dwFontStyles; - 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) { - return left.uCharSet == right.uCharSet && - left.dwFontStyles == right.dwFontStyles && - left.FontSignature == right.FontSignature && - FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0; -} - -#define FX_FONTMATCHPARA_MacthStyle 0x01 -#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); -FX_LPMatchFont FX_GetDefFontMatchor(); -class IFX_FontMgr { - public: - static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator, - FX_LPMatchFont pMatcher = NULL, - void* pUserData = NULL); - virtual ~IFX_FontMgr() {} - virtual void Release() = 0; - virtual IFX_Font* GetDefFontByCodePage( - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByCharset( - uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByUnicode( - FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByLanguage( - FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF) = 0; - virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName) = 0; - virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, - const FX_WCHAR* pszFontAlias = NULL, - FX_DWORD dwFontStyles = 0, - FX_WORD wCodePage = 0, - FX_BOOL bSaveStream = FALSE) = 0; - virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF) = 0; - 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, - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByCharset( - IFX_FontMgr* pFontMgr, - uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByUnicode( - IFX_FontMgr* pFontMgr, - FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByLanguage( - IFX_FontMgr* pFontMgr, - FX_WORD wLanguage, - FX_DWORD 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(); -class IFX_FontMgr { - public: - static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum, - IFX_FontMgrDelegate* pDelegate = NULL, - void* pUserData = NULL); - virtual ~IFX_FontMgr() {} - virtual void Release() = 0; - virtual IFX_Font* GetDefFontByCodePage( - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByCharset( - uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByUnicode( - FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetDefFontByLanguage( - FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - inline IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); - } - virtual IFX_Font* GetFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; - virtual IFX_Font* LoadFont(const uint8_t* pBuffer, - int32_t iLength, - int32_t iFaceIndex, - int32_t* pFaceCount = NULL) = 0; - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, - int32_t iFaceIndex, - int32_t* pFaceCount = NULL) = 0; - virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, - int32_t iFaceIndex, - int32_t* pFaceCount = NULL, - FX_BOOL bSaveStream = FALSE) = 0; - - virtual void ClearFontCache() = 0; - virtual void RemoveFont(IFX_Font* pFont) = 0; -}; -#endif - -#endif // XFA_SRC_FGAS_FONT_FGAS_FONT_H_ diff --git a/xfa/src/fgas/font/fgas_fontutils.cpp b/xfa/src/fgas/font/fgas_fontutils.cpp deleted file mode 100644 index 62f26f515a..0000000000 --- a/xfa/src/fgas/font/fgas_fontutils.cpp +++ /dev/null @@ -1,153 +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/src/fgas/font/fgas_fontutils.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/font/fgas_font.h" - -FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles) { - FX_DWORD dwHash = wCodePage; - if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { - dwHash |= 0x00010000; - } - if (dwFontStyles & FX_FONTSTYLE_Serif) { - dwHash |= 0x00020000; - } - if (dwFontStyles & FX_FONTSTYLE_Symbolic) { - dwHash |= 0x00040000; - } - if (dwFontStyles & FX_FONTSTYLE_Script) { - dwHash |= 0x00080000; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - dwHash |= 0x00100000; - } - if (dwFontStyles & FX_FONTSTYLE_Bold) { - dwHash |= 0x00200000; - } - return dwHash; -} -FX_DWORD FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - CFX_WideString wsFont(pszFontFamily); - if (dwFontStyles & FX_FONTSTYLE_Bold) { - wsFont += L"Bold"; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - wsFont += L"Italic"; - } - wsFont += wCodePage; - return FX_HashCode_String_GetW((const FX_WCHAR*)wsFont, wsFont.GetLength()); -} -static const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { - {0x0000, 0x007F, 0, 1252}, {0x0080, 0x00FF, 1, 1252}, - {0x0100, 0x017F, 2, 1250}, {0x0180, 0x024F, 3, 1250}, - {0x0250, 0x02AF, 4, 0xFFFF}, {0x02B0, 0x02FF, 5, 0xFFFF}, - {0x0300, 0x036F, 6, 0xFFFF}, {0x0370, 0x03FF, 7, 1253}, - {0x0400, 0x04FF, 9, 1251}, {0x0500, 0x052F, 9, 0xFFFF}, - {0x0530, 0x058F, 10, 0xFFFF}, {0x0590, 0x05FF, 11, 1255}, - {0x0600, 0x06FF, 13, 1256}, {0x0700, 0x074F, 71, 0xFFFF}, - {0x0750, 0x077F, 13, 0xFFFF}, {0x0780, 0x07BF, 72, 0xFFFF}, - {0x07C0, 0x07FF, 14, 0xFFFF}, {0x0800, 0x08FF, 999, 0xFFFF}, - {0x0900, 0x097F, 15, 0xFFFF}, {0x0980, 0x09FF, 16, 0xFFFF}, - {0x0A00, 0x0A7F, 17, 0xFFFF}, {0x0A80, 0x0AFF, 18, 0xFFFF}, - {0x0B00, 0x0B7F, 19, 0xFFFF}, {0x0B80, 0x0BFF, 20, 0xFFFF}, - {0x0C00, 0x0C7F, 21, 0xFFFF}, {0x0C80, 0x0CFF, 22, 0xFFFF}, - {0x0D00, 0x0D7F, 23, 0xFFFF}, {0x0D80, 0x0DFF, 73, 0xFFFF}, - {0x0E00, 0x0E7F, 24, 874}, {0x0E80, 0x0EFF, 25, 0xFFFF}, - {0x0F00, 0x0FFF, 70, 0xFFFF}, {0x1000, 0x109F, 74, 0xFFFF}, - {0x10A0, 0x10FF, 26, 0xFFFF}, {0x1100, 0x11FF, 28, 0xFFFF}, - {0x1200, 0x137F, 75, 0xFFFF}, {0x1380, 0x139F, 75, 0xFFFF}, - {0x13A0, 0x13FF, 76, 0xFFFF}, {0x1400, 0x167F, 77, 0xFFFF}, - {0x1680, 0x169F, 78, 0xFFFF}, {0x16A0, 0x16FF, 79, 0xFFFF}, - {0x1700, 0x171F, 84, 0xFFFF}, {0x1720, 0x173F, 84, 0xFFFF}, - {0x1740, 0x175F, 84, 0xFFFF}, {0x1760, 0x177F, 84, 0xFFFF}, - {0x1780, 0x17FF, 80, 0xFFFF}, {0x1800, 0x18AF, 81, 0xFFFF}, - {0x18B0, 0x18FF, 999, 0xFFFF}, {0x1900, 0x194F, 93, 0xFFFF}, - {0x1950, 0x197F, 94, 0xFFFF}, {0x1980, 0x19DF, 95, 0xFFFF}, - {0x19E0, 0x19FF, 80, 0xFFFF}, {0x1A00, 0x1A1F, 96, 0xFFFF}, - {0x1A20, 0x1AFF, 999, 0xFFFF}, {0x1B00, 0x1B7F, 27, 0xFFFF}, - {0x1B80, 0x1BBF, 112, 0xFFFF}, {0x1BC0, 0x1BFF, 999, 0xFFFF}, - {0x1C00, 0x1C4F, 113, 0xFFFF}, {0x1C50, 0x1C7F, 114, 0xFFFF}, - {0x1C80, 0x1CFF, 999, 0xFFFF}, {0x1D00, 0x1D7F, 4, 0xFFFF}, - {0x1D80, 0x1DBF, 4, 0xFFFF}, {0x1DC0, 0x1DFF, 6, 0xFFFF}, - {0x1E00, 0x1EFF, 29, 0xFFFF}, {0x1F00, 0x1FFF, 30, 0xFFFF}, - {0x2000, 0x206F, 31, 0xFFFF}, {0x2070, 0x209F, 32, 0xFFFF}, - {0x20A0, 0x20CF, 33, 0xFFFF}, {0x20D0, 0x20FF, 34, 0xFFFF}, - {0x2100, 0x214F, 35, 0xFFFF}, {0x2150, 0x215F, 36, 0xFFFF}, - {0x2160, 0x216B, 36, 936}, {0x216C, 0x216F, 36, 0xFFFF}, - {0x2170, 0x2179, 36, 936}, {0x217A, 0x218F, 36, 0xFFFF}, - {0x2190, 0x2199, 37, 949}, {0x219A, 0x21FF, 37, 0xFFFF}, - {0x2200, 0x22FF, 38, 0xFFFF}, {0x2300, 0x23FF, 39, 0xFFFF}, - {0x2400, 0x243F, 40, 0xFFFF}, {0x2440, 0x245F, 41, 0xFFFF}, - {0x2460, 0x2473, 42, 932}, {0x2474, 0x249B, 42, 936}, - {0x249C, 0x24E9, 42, 949}, {0x24EA, 0x24FF, 42, 0xFFFF}, - {0x2500, 0x2573, 43, 936}, {0x2574, 0x257F, 43, 0xFFFF}, - {0x2580, 0x2580, 44, 0xFFFF}, {0x2581, 0x258F, 44, 936}, - {0x2590, 0x259F, 44, 0xFFFF}, {0x25A0, 0x25FF, 45, 0xFFFF}, - {0x2600, 0x26FF, 46, 0xFFFF}, {0x2700, 0x27BF, 47, 0xFFFF}, - {0x27C0, 0x27EF, 38, 0xFFFF}, {0x27F0, 0x27FF, 37, 0xFFFF}, - {0x2800, 0x28FF, 82, 0xFFFF}, {0x2900, 0x297F, 37, 0xFFFF}, - {0x2980, 0x29FF, 38, 0xFFFF}, {0x2A00, 0x2AFF, 38, 0xFFFF}, - {0x2B00, 0x2BFF, 37, 0xFFFF}, {0x2C00, 0x2C5F, 97, 0xFFFF}, - {0x2C60, 0x2C7F, 29, 0xFFFF}, {0x2C80, 0x2CFF, 8, 0xFFFF}, - {0x2D00, 0x2D2F, 26, 0xFFFF}, {0x2D30, 0x2D7F, 98, 0xFFFF}, - {0x2D80, 0x2DDF, 75, 0xFFFF}, {0x2DE0, 0x2DFF, 9, 0xFFFF}, - {0x2E00, 0x2E7F, 31, 0xFFFF}, {0x2E80, 0x2EFF, 59, 0xFFFF}, - {0x2F00, 0x2FDF, 59, 0xFFFF}, {0x2FE0, 0x2FEF, 999, 0xFFFF}, - {0x2FF0, 0x2FFF, 59, 0xFFFF}, {0x3000, 0x303F, 48, 0xFFFF}, - {0x3040, 0x309F, 49, 932}, {0x30A0, 0x30FF, 50, 932}, - {0x3100, 0x3129, 51, 936}, {0x312A, 0x312F, 51, 0xFFFF}, - {0x3130, 0x318F, 52, 949}, {0x3190, 0x319F, 59, 0xFFFF}, - {0x31A0, 0x31BF, 51, 0xFFFF}, {0x31C0, 0x31EF, 61, 0xFFFF}, - {0x31F0, 0x31FF, 50, 0xFFFF}, {0x3200, 0x321C, 54, 949}, - {0x321D, 0x325F, 54, 0xFFFF}, {0x3260, 0x327F, 54, 949}, - {0x3280, 0x32FF, 54, 0xFFFF}, {0x3300, 0x3387, 55, 0xFFFF}, - {0x3388, 0x33D0, 55, 949}, {0x33D1, 0x33FF, 55, 0xFFFF}, - {0x3400, 0x4DBF, 59, 0xFFFF}, {0x4DC0, 0x4DFF, 99, 0xFFFF}, - {0x4E00, 0x9FA5, 59, 936}, {0x9FA6, 0x9FFF, 59, 0xFFFF}, - {0xA000, 0xA48F, 83, 0xFFFF}, {0xA490, 0xA4CF, 83, 0xFFFF}, - {0xA4D0, 0xA4FF, 999, 0xFFFF}, {0xA500, 0xA63F, 12, 0xFFFF}, - {0xA640, 0xA69F, 9, 0xFFFF}, {0xA6A0, 0xA6FF, 999, 0xFFFF}, - {0xA700, 0xA71F, 5, 0xFFFF}, {0xA720, 0xA7FF, 29, 0xFFFF}, - {0xA800, 0xA82F, 100, 0xFFFF}, {0xA830, 0xA8FF, 999, 0xFFFF}, - {0xA840, 0xA87F, 53, 0xFFFF}, {0xA880, 0xA8DF, 115, 0xFFFF}, - {0xA8E0, 0xA8FF, 999, 0xFFFF}, {0xA900, 0xA92F, 116, 0xFFFF}, - {0xA930, 0xA95F, 117, 0xFFFF}, {0xA960, 0xA9FF, 999, 0xFFFF}, - {0xAA00, 0xAA5F, 118, 0xFFFF}, {0xAA60, 0xABFF, 999, 0xFFFF}, - {0xAC00, 0xD7AF, 56, 949}, {0xD7B0, 0xD7FF, 999, 0xFFFF}, - {0xD800, 0xDB7F, 57, 0xFFFF}, {0xDB80, 0xDBFF, 57, 0xFFFF}, - {0xDC00, 0xDFFF, 57, 0xFFFF}, {0xE000, 0xE814, 60, 0xFFFF}, - {0xE815, 0xE864, 60, 936}, {0xE865, 0xF8FF, 60, 0xFFFF}, - {0xF900, 0xFA0B, 61, 949}, {0xFA0C, 0xFA0D, 61, 936}, - {0xFA0E, 0xFA2D, 61, 932}, {0xFA2E, 0xFAFF, 61, 0xFFFF}, - {0xFB00, 0xFB4F, 62, 0xFFFF}, {0xFB50, 0xFDFF, 63, 1256}, - {0xFE00, 0xFE0F, 91, 0xFFFF}, {0xFE10, 0xFE1F, 65, 0xFFFF}, - {0xFE20, 0xFE2F, 64, 0xFFFF}, {0xFE30, 0xFE4F, 65, 0xFFFF}, - {0xFE50, 0xFE6F, 66, 0xFFFF}, {0xFE70, 0xFEFF, 67, 1256}, - {0xFF00, 0xFF5F, 68, 936}, {0xFF60, 0xFF9F, 68, 932}, - {0xFFA0, 0xFFEF, 68, 0xFFFF}, -}; - -const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode) { - int32_t iEnd = sizeof(g_FXGdiFontUSBTable) / sizeof(FGAS_FONTUSB) - 1; - FXSYS_assert(iEnd >= 0); - int32_t iStart = 0, iMid; - do { - iMid = (iStart + iEnd) / 2; - const FGAS_FONTUSB& usb = g_FXGdiFontUSBTable[iMid]; - if (wUnicode < usb.wStartUnicode) { - iEnd = iMid - 1; - } else if (wUnicode > usb.wEndUnicode) { - iStart = iMid + 1; - } else { - return &usb; - } - } while (iStart <= iEnd); - return NULL; -} diff --git a/xfa/src/fgas/font/fgas_fontutils.h b/xfa/src/fgas/font/fgas_fontutils.h deleted file mode 100644 index 4cceb68574..0000000000 --- a/xfa/src/fgas/font/fgas_fontutils.h +++ /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 - -#ifndef XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ -#define XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ - -#include "core/include/fxcrt/fx_string.h" - -struct FGAS_FONTUSB { - FX_WCHAR wStartUnicode; - FX_WCHAR wEndUnicode; - FX_WORD wBitField; - FX_WORD wCodePage; -}; - -FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles); -FX_DWORD FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage); -const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode); - -#endif // XFA_SRC_FGAS_FONT_FGAS_FONTUTILS_H_ diff --git a/xfa/src/fgas/font/fgas_gefont.cpp b/xfa/src/fgas/font/fgas_gefont.cpp deleted file mode 100644 index df614a57c3..0000000000 --- a/xfa/src/fgas/font/fgas_gefont.cpp +++ /dev/null @@ -1,572 +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/src/fgas/font/fgas_gefont.h" - -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fgas/font/fgas_fontutils.h" - -IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage, - IFX_FontMgr* pFontMgr) { -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (NULL != pFontMgr) { - return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); - } - return NULL; -#else - CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); - if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) { - pFont->Release(); - return NULL; - } - return pFont; -#endif -} -IFX_Font* IFX_Font::LoadFont(const uint8_t* pBuffer, - int32_t iLength, - IFX_FontMgr* pFontMgr) { -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (NULL != pFontMgr) { - return pFontMgr->LoadFont(pBuffer, iLength, 0, NULL); - } - return NULL; -#else - CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); - if (!pFont->LoadFont(pBuffer, iLength)) { - pFont->Release(); - return NULL; - } - return pFont; -#endif -} -IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFileName, - IFX_FontMgr* pFontMgr) { -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (NULL != pFontMgr) { - return pFontMgr->LoadFont(pszFileName, 0, NULL); - } - return NULL; -#else - CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); - if (!pFont->LoadFont(pszFileName)) { - pFont->Release(); - return NULL; - } - return pFont; -#endif -} -IFX_Font* IFX_Font::LoadFont(IFX_Stream* pFontStream, - IFX_FontMgr* pFontMgr, - FX_BOOL bSaveStream) { -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (NULL != pFontMgr) { - return pFontMgr->LoadFont(pFontStream, 0, NULL); - } - return NULL; -#else - CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); - if (!pFont->LoadFont(pFontStream, bSaveStream)) { - pFont->Release(); - return NULL; - } - return pFont; -#endif -} -IFX_Font* IFX_Font::LoadFont(CFX_Font* pExtFont, - IFX_FontMgr* pFontMgr, - FX_BOOL bTakeOver) { - CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); - if (!pFont->LoadFont(pExtFont, bTakeOver)) { - pFont->Release(); - return NULL; - } - return pFont; -} -CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr) - : -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_bUseLogFontStyle(FALSE), - m_dwLogFontStyle(0), -#endif - m_pFont(NULL), - m_pFontMgr(pFontMgr), - m_iRefCount(1), - m_bExtFont(FALSE), - m_pStream(NULL), - m_pFileRead(NULL), - m_pFontEncoding(NULL), - m_pCharWidthMap(NULL), - m_pRectArray(NULL), - m_pBBoxMap(NULL), - m_pProvider(NULL), - m_wCharSet(0xFFFF), - m_SubstFonts(), - m_FontMapper(16) { -} - -CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles) - : -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_bUseLogFontStyle(FALSE), - m_dwLogFontStyle(0), -#endif - m_pFont(NULL), - m_pFontMgr(src.m_pFontMgr), - m_iRefCount(1), - m_bExtFont(FALSE), - m_pStream(NULL), - m_pFileRead(NULL), - m_pFontEncoding(NULL), - m_pCharWidthMap(NULL), - m_pRectArray(NULL), - 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); - m_pFont->LoadClone(src.m_pFont); - CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); - if (!pSubst) { - pSubst = new CFX_SubstFont; - m_pFont->SetSubstFont(pSubst); - } - pSubst->m_Weight = - (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; - if (dwFontStyles & FX_FONTSTYLE_Italic) { - pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; - } - 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(); - } - m_SubstFonts.RemoveAll(); - m_FontMapper.RemoveAll(); - if (m_pFileRead != NULL) { - m_pFileRead->Release(); - } - if (m_pStream != NULL) { - 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_pFont; - } -} -void CFX_GEFont::Release() { - if (--m_iRefCount < 1) { - if (m_pFontMgr != NULL) { - m_pFontMgr->RemoveFont(this); - } - delete this; - } -} -IFX_Font* CFX_GEFont::Retain() { - ++m_iRefCount; - return this; -} -FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - if (m_pFont) { - return FALSE; - } - CFX_ByteString csFontFamily; - if (pszFontFamily != NULL) { - csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); - } - FX_DWORD dwFlags = 0; - if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { - dwFlags |= FXFONT_FIXED_PITCH; - } - if (dwFontStyles & FX_FONTSTYLE_Serif) { - dwFlags |= FXFONT_SERIF; - } - if (dwFontStyles & FX_FONTSTYLE_Symbolic) { - dwFlags |= FXFONT_SYMBOLIC; - } - if (dwFontStyles & FX_FONTSTYLE_Script) { - dwFlags |= FXFONT_SCRIPT; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - dwFlags |= FXFONT_ITALIC; - } - if (dwFontStyles & FX_FONTSTYLE_Bold) { - dwFlags |= FXFONT_BOLD; - } - if (dwFontStyles & FX_FONTSTYLE_ExactMatch) { - dwFlags |= FXFONT_EXACTMATCH; - } - int32_t iWeight = - (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; - FX_WORD wCharSet = FX_GetCharsetFromCodePage(wCodePage); - if (wCharSet == 0xFFFF) { - wCharSet = FXSYS_GetACP(); - } - m_wCharSet = wCharSet; - m_pFont = new CFX_Font; - if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { - csFontFamily += ",BoldItalic"; - } else if (dwFlags & FXFONT_BOLD) { - csFontFamily += ",Bold"; - } else if (dwFlags & FXFONT_ITALIC) { - csFontFamily += ",Italic"; - } - m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage); - FX_BOOL bRet = m_pFont->GetFace() != nullptr; - if (bRet) { - bRet = InitFont(); - } - return bRet; -} -FX_BOOL CFX_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) { - if (m_pFont) { - return FALSE; - } - m_pFont = new CFX_Font; - FX_BOOL bRet = m_pFont->LoadEmbedded(pBuffer, length); - if (bRet) { - bRet = InitFont(); - } - m_wCharSet = 0xFFFF; - return bRet; -} -FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFileName) { - if (m_pFont || m_pStream || m_pFileRead) { - return FALSE; - } - m_pStream = IFX_Stream::CreateStream( - pszFileName, FX_STREAMACCESS_Binary | FX_STREAMACCESS_Read); - m_pFileRead = FX_CreateFileRead(m_pStream); - FX_BOOL bRet = FALSE; - if (m_pStream && m_pFileRead) { - m_pFont = new CFX_Font; - bRet = m_pFont->LoadFile(m_pFileRead); - if (bRet) { - bRet = InitFont(); - } else { - m_pFileRead->Release(); - m_pFileRead = nullptr; - } - } - m_wCharSet = 0xFFFF; - return bRet; -} -FX_BOOL CFX_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) { - if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) { - return FALSE; - } - if (bSaveStream) { - m_pStream = pFontStream; - } - m_pFileRead = FX_CreateFileRead(pFontStream); - m_pFont = new CFX_Font; - FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead); - if (bRet) { - bRet = InitFont(); - } else { - m_pFileRead->Release(); - m_pFileRead = nullptr; - } - m_wCharSet = 0xFFFF; - return bRet; -} -FX_BOOL CFX_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) { - if (m_pFont || !pExtFont) { - return FALSE; - } - m_pFont = pExtFont; - FX_BOOL bRet = !!m_pFont; - if (bRet) { - m_bExtFont = !bTakeOver; - bRet = InitFont(); - } else { - m_bExtFont = TRUE; - } - m_wCharSet = 0xFFFF; - return bRet; -} -FX_BOOL CFX_GEFont::InitFont() { - if (!m_pFont) { - return FALSE; - } - if (!m_pFontEncoding) { - m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont); - if (!m_pFontEncoding) { - return FALSE; - } - } - if (!m_pCharWidthMap) { - m_pCharWidthMap = new CFX_WordDiscreteArray(1024); - } - if (!m_pRectArray) { - m_pRectArray = new CFX_RectMassArray(16); - } - if (!m_pBBoxMap) { - m_pBBoxMap = new CFX_MapPtrToPtr(16); - } - return TRUE; -} -IFX_Font* CFX_GEFont::Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage) { - if (GetFontStyles() == dwFontStyles) { - return Retain(); - } - return new CFX_GEFont(*this, dwFontStyles); -} -uint8_t CFX_GEFont::GetCharSet() const { - if (m_wCharSet != 0xFFFF) { - return (uint8_t)m_wCharSet; - } - if (!m_pFont->GetSubstFont()) { - return FX_CHARSET_Default; - } - return m_pFont->GetSubstFont()->m_Charset; -} -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()); - } else { - wsFamily = CFX_WideString::FromLocal(m_pFont->GetSubstFont()->m_Family); - } -} -void CFX_GEFont::GetPsName(CFX_WideString& wsName) const { - wsName = m_pFont->GetPsName(); -} -FX_DWORD CFX_GEFont::GetFontStyles() const { - FXSYS_assert(m_pFont != NULL); -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_bUseLogFontStyle) { - return m_dwLogFontStyle; - } -#endif - FX_DWORD dwStyles = 0; - if (!m_pFont->GetSubstFont()) { - if (m_pFont->IsBold()) { - dwStyles |= FX_FONTSTYLE_Bold; - } - if (m_pFont->IsItalic()) { - dwStyles |= FX_FONTSTYLE_Italic; - } - } else { - if (m_pFont->GetSubstFont()->m_Weight == FXFONT_FW_BOLD) { - dwStyles |= FX_FONTSTYLE_Bold; - } - if (m_pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_ITALIC) { - dwStyles |= FX_FONTSTYLE_Italic; - } - } - return dwStyles; -} -FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bCharCode) { - return GetCharWidth(wUnicode, iWidth, TRUE, bCharCode); -} -FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bRecursive, - FX_BOOL bCharCode) { - FXSYS_assert(m_pCharWidthMap != NULL); - iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); - if (iWidth < 1) { - if (!m_pProvider || - !m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) { - IFX_Font* pFont = NULL; - int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont != NULL) { - if (pFont == (IFX_Font*)this) { - iWidth = m_pFont->GetGlyphWidth(iGlyph); - if (iWidth < 0) { - iWidth = -1; - } - } else if (((CFX_GEFont*)pFont) - ->GetCharWidth(wUnicode, iWidth, FALSE, bCharCode)) { - return TRUE; - } - } else { - iWidth = -1; - } - } - m_pCharWidthMap->SetAtGrow(wUnicode, (int16_t)iWidth); - } else if (iWidth == 65535) { - iWidth = -1; - } - return iWidth > 0; -} -FX_BOOL CFX_GEFont::GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, - FX_BOOL bCharCode) { - return GetCharBBox(wUnicode, bbox, TRUE, bCharCode); -} -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); - void* pRect = NULL; - if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { - IFX_Font* pFont = NULL; - int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont != NULL) { - if (pFont == (IFX_Font*)this) { - FX_RECT rtBBox; - if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { - CFX_Rect rt; - rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); - int32_t index = m_pRectArray->Add(rt); - pRect = m_pRectArray->GetPtrAt(index); - m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); - } - } else if (((CFX_GEFont*)pFont) - ->GetCharBBox(wUnicode, bbox, FALSE, bCharCode)) { - return TRUE; - } - } - } - if (!pRect) - return FALSE; - - bbox = *static_cast<const CFX_Rect*>(pRect); - return TRUE; -} -FX_BOOL CFX_GEFont::GetBBox(CFX_Rect& bbox) { - FX_RECT rt(0, 0, 0, 0); - FX_BOOL bRet = m_pFont->GetBBox(rt); - if (bRet) { - bbox.left = rt.left; - bbox.width = rt.Width(); - bbox.top = rt.bottom; - bbox.height = -rt.Height(); - } - return bRet; -} -int32_t CFX_GEFont::GetItalicAngle() const { - if (!m_pFont->GetSubstFont()) { - return 0; - } - return m_pFont->GetSubstFont()->m_ItalicAngle; -} -int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { - return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode); -} -int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, - FX_BOOL bRecursive, - IFX_Font** ppFont, - FX_BOOL bCharCode) { - FXSYS_assert(m_pFontEncoding != NULL); - int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); - if (iGlyphIndex > 0) { - if (ppFont != NULL) { - *ppFont = (IFX_Font*)this; - } - return iGlyphIndex; - } - const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); - if (pFontUSB == NULL) { - return 0xFFFF; - } - FX_WORD wBitField = pFontUSB->wBitField; - if (wBitField >= 128) { - return 0xFFFF; - } - IFX_Font* pFont = NULL; - m_FontMapper.Lookup((void*)(uintptr_t)wUnicode, (void*&)pFont); - if (pFont != NULL && pFont != (IFX_Font*)this) { - iGlyphIndex = - ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); - if (iGlyphIndex != 0xFFFF) { - int32_t i = m_SubstFonts.Find(pFont); - if (i > -1) { - iGlyphIndex |= ((i + 1) << 24); - if (ppFont != NULL) { - *ppFont = pFont; - } - return iGlyphIndex; - } - } - } - if (m_pFontMgr != NULL && bRecursive) { - CFX_WideString wsFamily; - GetFamilyName(wsFamily); -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - IFX_Font* pFont = m_pFontMgr->GetDefFontByUnicode( - wUnicode, GetFontStyles(), (const FX_WCHAR*)wsFamily); -#else - IFX_Font* pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), - (const FX_WCHAR*)wsFamily); - if (NULL == pFont) { - pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL); - } -#endif - if (pFont != NULL) { - if (pFont == (IFX_Font*)this) { - pFont->Release(); - return 0xFFFF; - } - m_FontMapper.SetAt((void*)(uintptr_t)wUnicode, (void*)pFont); - int32_t i = m_SubstFonts.GetSize(); - m_SubstFonts.Add(pFont); - iGlyphIndex = - ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); - if (iGlyphIndex != 0xFFFF) { - iGlyphIndex |= ((i + 1) << 24); - if (ppFont != NULL) { - *ppFont = pFont; - } - return iGlyphIndex; - } - } - } - return 0xFFFF; -} -int32_t CFX_GEFont::GetAscent() const { - return m_pFont->GetAscent(); -} -int32_t CFX_GEFont::GetDescent() const { - return m_pFont->GetDescent(); -} -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]; - ((CFX_GEFont*)pFont)->Reset(); - } - if (m_pCharWidthMap != NULL) { - m_pCharWidthMap->RemoveAll(); - } - if (m_pBBoxMap != NULL) { - m_pBBoxMap->RemoveAll(); - } - if (m_pRectArray != NULL) { - m_pRectArray->RemoveAll(); - } -} -IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const { - iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24; - return iGlyphIndex == 0 ? (IFX_Font*)this - : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1]; -} diff --git a/xfa/src/fgas/font/fgas_gefont.h b/xfa/src/fgas/font/fgas_gefont.h deleted file mode 100644 index 1bc8a6a902..0000000000 --- a/xfa/src/fgas/font/fgas_gefont.h +++ /dev/null @@ -1,92 +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_SRC_FGAS_FONT_FGAS_GEFONT_H_ -#define XFA_SRC_FGAS_FONT_FGAS_GEFONT_H_ - -#include "xfa/src/fgas/crt/fgas_utils.h" -#include "xfa/src/fgas/font/fgas_font.h" - -#define FXFONT_SUBST_ITALIC 0x02 - -class CFX_GEFont : public IFX_Font { - public: - CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles); - CFX_GEFont(IFX_FontMgr* pFontMgr); - ~CFX_GEFont(); - virtual void Release(); - virtual IFX_Font* Retain(); - FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage); - FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length); - FX_BOOL LoadFont(const FX_WCHAR* pszFileName); - FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream); - FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE); - virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0); - virtual void GetFamilyName(CFX_WideString& wsFamily) const; - virtual void GetPsName(CFX_WideString& wsName) const; - virtual FX_DWORD GetFontStyles() const; - virtual uint8_t GetCharSet() const; - virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bCharCode = FALSE); - virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE); - virtual int32_t GetAscent() const; - virtual int32_t GetDescent() const; - virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, - FX_BOOL bCharCode = FALSE); - virtual FX_BOOL GetBBox(CFX_Rect& bbox); - virtual int32_t GetItalicAngle() const; - 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) { - m_pProvider = pProvider; - } -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) { - m_bUseLogFontStyle = TRUE; - m_dwLogFontStyle = dwLogFontStyle; - } -#endif - - protected: -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - FX_BOOL m_bUseLogFontStyle; - FX_DWORD m_dwLogFontStyle; -#endif - CFX_Font* m_pFont; - IFX_FontMgr* m_pFontMgr; - int32_t m_iRefCount; - FX_BOOL m_bExtFont; - IFX_Stream* m_pStream; - IFX_FileRead* m_pFileRead; - CFX_UnicodeEncoding* m_pFontEncoding; - CFX_WordDiscreteArray* m_pCharWidthMap; - CFX_RectMassArray* m_pRectArray; - CFX_MapPtrToPtr* m_pBBoxMap; - IFX_FontProvider* m_pProvider; - FX_WORD m_wCharSet; - CFX_PtrArray m_SubstFonts; - CFX_MapPtrToPtr m_FontMapper; - FX_BOOL InitFont(); - FX_BOOL GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, - FX_BOOL bRecursive, - FX_BOOL bCharCode = FALSE); - FX_BOOL GetCharWidth(FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bRecursive, - FX_BOOL bCharCode = FALSE); - int32_t GetGlyphIndex(FX_WCHAR wUnicode, - FX_BOOL bRecursive, - IFX_Font** ppFont, - FX_BOOL bCharCode = FALSE); -}; - -#endif // XFA_SRC_FGAS_FONT_FGAS_GEFONT_H_ diff --git a/xfa/src/fgas/font/fgas_stdfontmgr.cpp b/xfa/src/fgas/font/fgas_stdfontmgr.cpp deleted file mode 100644 index 99f1fdda44..0000000000 --- a/xfa/src/fgas/font/fgas_stdfontmgr.cpp +++ /dev/null @@ -1,1515 +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/src/fgas/font/fgas_stdfontmgr.h" - -#include "core/include/fxcrt/fx_stream.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/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), - 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) { - if (m_pEnumerator != NULL) { - m_pEnumerator(m_FontFaces, m_pUserData, NULL, 0xFEFF); - } - if (m_pMatcher == NULL) { - m_pMatcher = FX_DefFontMatcher; - } - FXSYS_assert(m_pMatcher != NULL); -} -CFX_StdFontMgrImp::~CFX_StdFontMgrImp() { - m_FontFaces.RemoveAll(); - m_CPFonts.RemoveAll(); - m_FamilyFonts.RemoveAll(); - m_UnicodeFonts.RemoveAll(); - m_BufferFonts.RemoveAll(); - 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(); -} -IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage( - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - FX_DWORD dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); - IFX_Font* pFont = NULL; - if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; - } - FX_LPCFONTDESCRIPTOR 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); - pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); - if (pFont != NULL) { - m_Fonts.Add(pFont); - m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - return LoadFont(pFont, dwFontStyles, wCodePage); - } - return NULL; -} -IFX_Font* CFX_StdFontMgrImp::GetDefFontByCharset( - uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, - pszFontFamily); -} - -IFX_Font* CFX_StdFontMgrImp::GetDefFontByUnicode( - FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - const FGAS_FONTUSB* pRet = FGAS_GetUnicodeBitField(wUnicode); - if (pRet->wBitField == 999) - return nullptr; - - FX_DWORD dwHash = - FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); - IFX_Font* pFont = nullptr; - if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) - return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr; - - FX_LPCFONTDESCRIPTOR pFD = - FindFont(pszFontFamily, dwFontStyles, FALSE, pRet->wCodePage, - pRet->wBitField, wUnicode); - if (!pFD && pszFontFamily) { - pFD = FindFont(nullptr, dwFontStyles, FALSE, pRet->wCodePage, - pRet->wBitField, wUnicode); - } - if (!pFD) - return nullptr; - - FX_WORD wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); - const FX_WCHAR* pFontFace = pFD->wsFontFace; - pFont = IFX_Font::LoadFont(pFontFace, dwFontStyles, wCodePage, this); - if (pFont) { - m_Fonts.Add(pFont); - m_UnicodeFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); - m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - dwHash = FGAS_GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage); - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - return LoadFont(pFont, dwFontStyles, wCodePage); - } - return nullptr; -} - -IFX_Font* CFX_StdFontMgrImp::GetDefFontByLanguage( - FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), - dwFontStyles, pszFontFamily); -} -IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - FX_DWORD dwHash = - FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); - IFX_Font* pFont = NULL; - if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; - } - FX_LPCFONTDESCRIPTOR pFD = NULL; - if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { - if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == - NULL) { - return NULL; - } - } - FXSYS_assert(pFD != NULL); - if (wCodePage == 0xFFFF) { - wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); - } - pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); - if (pFont != NULL) { - m_Fonts.Add(pFont); - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); - m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - return LoadFont(pFont, dwFontStyles, wCodePage); - } - return NULL; -} -IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { - FXSYS_assert(pBuffer != NULL && iLength > 0); - IFX_Font* pFont = NULL; - if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { - if (pFont != NULL) { - return pFont->Retain(); - } - } - pFont = IFX_Font::LoadFont(pBuffer, iLength, this); - if (pFont != NULL) { - m_Fonts.Add(pFont); - m_BufferFonts.SetAt((void*)pBuffer, pFont); - return pFont->Retain(); - } - return NULL; -} -IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { - FXSYS_assert(pszFileName != NULL); - FX_DWORD dwHash = FX_HashCode_String_GetW(pszFileName, -1); - IFX_Font* pFont = NULL; - if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - if (pFont != NULL) { - return pFont->Retain(); - } - } - pFont = IFX_Font::LoadFont(pszFileName, NULL); - if (pFont != NULL) { - m_Fonts.Add(pFont); - m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - return pFont->Retain(); - } - return NULL; -} -IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, - const FX_WCHAR* pszFontAlias, - FX_DWORD dwFontStyles, - FX_WORD wCodePage, - FX_BOOL bSaveStream) { - FXSYS_assert(pFontStream != NULL && pFontStream->GetLength() > 0); - IFX_Font* pFont = NULL; - if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { - if (pFont != NULL) { - if (pszFontAlias != NULL) { - FX_DWORD dwHash = - FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - } - return LoadFont(pFont, dwFontStyles, wCodePage); - } - } - pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream); - if (pFont != NULL) { - m_Fonts.Add(pFont); - m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); - if (pszFontAlias != NULL) { - FX_DWORD dwHash = - FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - } - return LoadFont(pFont, dwFontStyles, wCodePage); - } - return NULL; -} -IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - FXSYS_assert(pSrcFont != NULL); - if (pSrcFont->GetFontStyles() == dwFontStyles) { - return pSrcFont->Retain(); - } - void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, - (void*)(uintptr_t)wCodePage}; - FX_DWORD dwHash = - FX_HashCode_String_GetA((const FX_CHAR*)buffer, 3 * sizeof(void*)); - IFX_Font* pFont = NULL; - if (m_DeriveFonts.GetCount() > 0) { - m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); - if (pFont != NULL) { - return pFont->Retain(); - } - } - pFont = pSrcFont->Derive(dwFontStyles, wCodePage); - if (pFont != NULL) { - m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); - int32_t index = m_Fonts.Find(pFont); - if (index < 0) { - m_Fonts.Add(pFont); - pFont->Retain(); - } - return pFont; - } - 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(); - } - } -} -void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) { - FX_POSITION pos = fontMap.GetStartPosition(); - void* pKey; - void* pFind; - while (pos != NULL) { - pFind = NULL; - fontMap.GetNextAssoc(pos, pKey, pFind); - if (pFind != (void*)pFont) { - continue; - } - fontMap.RemoveKey(pKey); - break; - } -} -void CFX_StdFontMgrImp::RemoveFont(IFX_Font* pFont) { - RemoveFont(m_CPFonts, pFont); - RemoveFont(m_FamilyFonts, pFont); - RemoveFont(m_UnicodeFonts, pFont); - RemoveFont(m_BufferFonts, pFont); - RemoveFont(m_FileFonts, pFont); - RemoveFont(m_StreamFonts, pFont); - RemoveFont(m_DeriveFonts, pFont); - int32_t iFind = m_Fonts.Find(pFont); - if (iFind > -1) { - m_Fonts.RemoveAt(iFind, 1); - } -} -FX_LPCFONTDESCRIPTOR CFX_StdFontMgrImp::FindFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_DWORD dwMatchFlags, - FX_WORD wCodePage, - FX_DWORD dwUSB, - FX_WCHAR wUnicode) { - if (m_pMatcher == NULL) { - return NULL; - } - FX_FONTMATCHPARAMS params; - FXSYS_memset(¶ms, 0, sizeof(params)); - params.dwUSB = dwUSB; - params.wUnicode = wUnicode; - params.wCodePage = wCodePage; - params.pwsFamily = pszFontFamily; - params.dwFontStyles = dwFontStyles; - params.dwMatchFlags = dwMatchFlags; - FX_LPCFONTDESCRIPTOR pDesc = m_pMatcher(¶ms, m_FontFaces, m_pUserData); - if (pDesc) { - return pDesc; - } - if (pszFontFamily && m_pEnumerator) { - CFX_FontDescriptors namedFonts; - m_pEnumerator(namedFonts, m_pUserData, pszFontFamily, wUnicode); - params.pwsFamily = NULL; - pDesc = m_pMatcher(¶ms, namedFonts, m_pUserData); - if (pDesc == NULL) { - return NULL; - } - for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { - FX_LPCFONTDESCRIPTOR pMatch = m_FontFaces.GetPtrAt(i); - if (*pMatch == *pDesc) { - return pMatch; - } - } - int index = m_FontFaces.Add(*pDesc); - return m_FontFaces.GetPtrAt(index); - } - return NULL; -} -FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, - const CFX_FontDescriptors& fonts, - void* pUserData) { - FX_LPCFONTDESCRIPTOR 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); - if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == - FX_FONTSTYLE_BoldItalic) { - continue; - } - if (pParams->pwsFamily) { - if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) { - continue; - } - if (pFont->uCharSet == FX_CHARSET_Symbol) { - return pFont; - } - } - if (pFont->uCharSet == FX_CHARSET_Symbol) { - continue; - } - if (pParams->wCodePage != 0xFFFF) { - if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage) { - continue; - } - } else { - if (pParams->dwUSB < 128) { - FX_DWORD dwByte = pParams->dwUSB / 32; - FX_DWORD dwUSB = 1 << (pParams->dwUSB % 32); - if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) { - continue; - } - } - } - if (bMatchStyle) { - if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) { - return pFont; - } else { - continue; - } - } - if (pParams->pwsFamily != NULL) { - if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { - return pFont; - } - } - int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); - if (iBestSimilar < iSimilarValue) { - iBestSimilar = iSimilarValue; - pBestFont = pFont; - } - } - return iBestSimilar < 1 ? NULL : pBestFont; -} -int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, FX_DWORD dwFontStyles) { - int32_t iValue = 0; - if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == - (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { - iValue += 64; - } - if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == - (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { - iValue += 32; - } - if ((dwFontStyles & FX_FONTSTYLE_Serif) == - (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) { - iValue += 16; - } - if ((dwFontStyles & FX_FONTSTYLE_Script) == - (pFont->dwFontStyles & FX_FONTSTYLE_Script)) { - iValue += 8; - } - return iValue; -} -FX_LPMatchFont FX_GetDefFontMatchor() { - return FX_DefFontMatcher; -} -FX_DWORD FX_GetGdiFontStyles(const LOGFONTW& lf) { - FX_DWORD dwStyles = 0; - if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH) { - dwStyles |= FX_FONTSTYLE_FixedPitch; - } - uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0; - if (nFamilies == FF_ROMAN) { - dwStyles |= FX_FONTSTYLE_Serif; - } - if (nFamilies == FF_SCRIPT) { - dwStyles |= FX_FONTSTYLE_Script; - } - if (lf.lfCharSet == SYMBOL_CHARSET) { - dwStyles |= FX_FONTSTYLE_Symbolic; - } - return dwStyles; -} -static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, - NEWTEXTMETRICEX* lpntme, - DWORD dwFontType, - LPARAM lParam) { - if (dwFontType != TRUETYPE_FONTTYPE) { - return 1; - } - const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont; - if (lf.lfFaceName[0] == L'@') { - return 1; - } - FX_LPFONTDESCRIPTOR pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); - FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); - pFont->uCharSet = lf.lfCharSet; - pFont->dwFontStyles = FX_GetGdiFontStyles(lf); - FXSYS_wcsncpy(pFont->wsFontFace, (const FX_WCHAR*)lf.lfFaceName, 31); - pFont->wsFontFace[31] = 0; - FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, - sizeof(lpntme->ntmFontSig)); - ((CFX_FontDescriptors*)lParam)->Add(*pFont); - FX_Free(pFont); - return 1; -} -static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, - void* pUserData, - const FX_WCHAR* pwsFaceName, - FX_WCHAR wUnicode) { - HDC hDC = ::GetDC(NULL); - LOGFONTW lfFind; - FXSYS_memset(&lfFind, 0, sizeof(lfFind)); - lfFind.lfCharSet = DEFAULT_CHARSET; - if (pwsFaceName) { - FXSYS_wcsncpy((FX_WCHAR*)lfFind.lfFaceName, pwsFaceName, 31); - lfFind.lfFaceName[31] = 0; - } - EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, - (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); - ::ReleaseDC(NULL, hDC); -} -FX_LPEnumAllFonts FX_GetDefFontEnumerator() { - return FX_EnumGdiFonts; -} -#else -const FX_CHAR* g_FontFolders[] = { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ - "/usr/share/fonts", "/usr/share/X11/fonts/Type1", - "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ - "/system/fonts", -#endif -}; - -CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { - for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) - m_FolderPaths.Add(g_FontFolders[i]); -} - -CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { -Restart: - void* pCurHandle = - m_FolderQueue.GetSize() == 0 - ? NULL - : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; - if (NULL == pCurHandle) { - if (m_FolderPaths.GetSize() < 1) { - return ""; - } - pCurHandle = FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1]); - FX_HandleParentPath hpp; - hpp.pFileHandle = pCurHandle; - hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; - m_FolderQueue.Add(hpp); - } - CFX_ByteString bsName; - FX_BOOL bFolder; - CFX_ByteString bsFolderSpearator = - CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); - while (TRUE) { - if (!FX_GetNextFile(pCurHandle, bsName, bFolder)) { - FX_CloseFolder(pCurHandle); - m_FolderQueue.RemoveAt(m_FolderQueue.GetSize() - 1); - if (m_FolderQueue.GetSize() == 0) { - m_FolderPaths.RemoveAt(m_FolderPaths.GetSize() - 1); - if (m_FolderPaths.GetSize() == 0) { - return ""; - } else { - goto Restart; - } - } - pCurHandle = - m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; - continue; - } - if (bsName == "." || bsName == "..") { - continue; - } - if (bFolder) { - FX_HandleParentPath hpp; - hpp.bsParentPath = - m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + - bsFolderSpearator + bsName; - hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath); - if (hpp.pFileHandle == NULL) { - continue; - } - m_FolderQueue.Add(hpp); - pCurHandle = hpp.pFileHandle; - continue; - } - bsName = - m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + - bsFolderSpearator + bsName; - break; - } - return bsName; -} -FX_POSITION CFX_FontSourceEnum_File::GetStartPosition(void* pUserData) { - 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); - 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()) { - return pFontMgr; - } - delete pFontMgr; - return NULL; -} -CFX_FontMgrImp::CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum, - IFX_FontMgrDelegate* pDelegate, - void* pUserData) - : m_pFontSource(pFontEnum), - m_pDelegate(pDelegate), - m_pUserData(pUserData) {} - -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); - pFontStream->Release(); - } - 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(); - IFX_FileAccess* pFontSource = nullptr; - IFX_FileRead* pFontStream = nullptr; - while (pos) { - pFontSource = m_pFontSource->GetNext(pos); - pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); - if (!pFontStream) { - pFontSource->Release(); - continue; - } - RegisterFaces(pFontStream, nullptr); - pFontStream->Release(); - pFontSource->Release(); - } - if (m_InstalledFonts.GetSize() == 0) - return FALSE; - return TRUE; -} -FX_BOOL CFX_FontMgrImp::EnumFonts() { - if (EnumFontsFromFontMapper()) - return TRUE; - return EnumFontsFromFiles(); -} -void CFX_FontMgrImp::Release() { - for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) { - delete m_InstalledFonts[i]; - } - FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - CFX_FontDescriptorInfos* pDescs; - m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); - if (NULL != pDescs) { - delete pDescs; - } - } - pos = m_Hash2Fonts.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - CFX_ArrayTemplate<IFX_Font*>* pFonts; - m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); - if (NULL != pFonts) { - delete pFonts; - } - } - m_Hash2Fonts.RemoveAll(); - pos = m_Hash2FileAccess.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - IFX_FileAccess* pFileAccess; - m_Hash2FileAccess.GetNextAssoc(pos, dwHash, pFileAccess); - if (NULL != pFileAccess) { - pFileAccess->Release(); - } - } - pos = m_FileAccess2IFXFont.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - IFX_Font* pFont; - m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); - if (NULL != pFont) { - pFont->Release(); - } - } - pos = m_IFXFont2FileRead.GetStartPosition(); - while (pos) { - IFX_Font* pFont; - IFX_FileRead* pFileRead; - m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); - pFileRead->Release(); - } - delete this; -} -IFX_Font* CFX_FontMgrImp::GetDefFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByCodePage( - this, wCodePage, dwFontStyles, - pszFontFamily); -} -IFX_Font* CFX_FontMgrImp::GetDefFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return NULL == m_pDelegate ? NULL - : m_pDelegate->GetDefFontByCharset( - this, nCharset, dwFontStyles, pszFontFamily); -} -IFX_Font* CFX_FontMgrImp::GetDefFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return NULL == m_pDelegate ? NULL - : m_pDelegate->GetDefFontByUnicode( - this, wUnicode, dwFontStyles, pszFontFamily); -} -IFX_Font* CFX_FontMgrImp::GetDefFontByLanguage(FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByLanguage( - this, wLanguage, dwFontStyles, - pszFontFamily); -} -IFX_Font* CFX_FontMgrImp::GetFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - CFX_ByteString bsHash; - bsHash.Format("%d, %d", wCodePage, dwFontStyles); - bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); - FX_DWORD dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); - CFX_ArrayTemplate<IFX_Font*>* pFonts = NULL; - IFX_Font* pFont = NULL; - if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { - if (NULL == pFonts) { - return NULL; - } - if (0 != pFonts->GetSize()) { - return pFonts->GetAt(0)->Retain(); - } - } - if (!pFonts) - pFonts = new CFX_ArrayTemplate<IFX_Font*>; - m_Hash2Fonts.SetAt(dwHash, pFonts); - CFX_FontDescriptorInfos* sortedFonts = NULL; - 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; - } - 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) { - pFont->SetLogicalFontStyle(dwFontStyles); - } - pFonts->Add(pFont); - return pFont; -} -IFX_Font* CFX_FontMgrImp::GetFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, - pszFontFamily); -} -IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily) { - IFX_Font* pFont = nullptr; - if (m_FailedUnicodes2NULL.Lookup(wUnicode, pFont)) - return nullptr; - const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); - FX_WORD wCodePage = x ? x->wCodePage : 0xFFFF; - FX_WORD wBitField = x ? x->wBitField : 0x03E7; - CFX_ByteString bsHash; - if (wCodePage == 0xFFFF) - bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); - else - bsHash.Format("%d, %d", wCodePage, dwFontStyles); - bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); - FX_DWORD dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); - CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr; - if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { - if (!pFonts) - return nullptr; - for (int32_t i = 0; i < pFonts->GetSize(); ++i) { - if (VerifyUnicode(pFonts->GetAt(i), wUnicode)) - return pFonts->GetAt(i)->Retain(); - } - } - if (!pFonts) - pFonts = new CFX_ArrayTemplate<IFX_Font*>; - m_Hash2Fonts.SetAt(dwHash, pFonts); - CFX_FontDescriptorInfos* sortedFonts = nullptr; - if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { - sortedFonts = new CFX_FontDescriptorInfos; - MatchFonts(*sortedFonts, wCodePage, dwFontStyles, - CFX_WideString(pszFontFamily), wUnicode); - m_Hash2CandidateList.SetAt(dwHash, sortedFonts); - } - for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) { - CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont; - if (!VerifyUnicode(pDesc, wUnicode)) - continue; - if (pDesc->m_pFileAccess) - pFont = LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr); - else - pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); - if (!pFont) - continue; - pFont->SetLogicalFontStyle(dwFontStyles); - pFonts->Add(pFont); - return pFont; - } - if (!pszFontFamily) - m_FailedUnicodes2NULL.SetAt(wUnicode, nullptr); - return nullptr; -} -FX_BOOL CFX_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, - FX_WCHAR wcUnicode) { - IFX_FileRead* pFileRead = nullptr; - if (pDesc->m_pFileAccess) - pFileRead = pDesc->m_pFileAccess->CreateFileStream(FX_FILEMODE_ReadOnly); - else - pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); - if (!pFileRead) - return FALSE; - FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); - FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); - FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); - pFileRead->Release(); - if (!pFace) - return FALSE; - if (FXFT_Get_Face_External_Stream(pFace)) - FXFT_Clear_Face_External_Stream(pFace); - FXFT_Done_Face(pFace); - return !retCharmap && retIndex; -} -FX_BOOL CFX_FontMgrImp::VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode) { - if (NULL == 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)) { - return FALSE; - } - if (0 == FXFT_Get_Char_Index(pFace, wcUnicode)) { - FXFT_Set_Charmap(pFace, charmap); - return FALSE; - } - return TRUE; -} -IFX_Font* CFX_FontMgrImp::GetFontByLanguage(FX_WORD wLanguage, - FX_DWORD 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}; - FX_DWORD 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; - } -} -IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName, - int32_t iFaceIndex, - int32_t* pFaceCount) { - CFX_ByteString bsHash; - bsHash += CFX_WideString(pszFileName).UTF8Encode(); - FX_DWORD dwHash = - FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength()); - IFX_FileAccess* pFontAccess = NULL; - 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; - } -} -IFX_Font* CFX_FontMgrImp::LoadFont(IFX_Stream* pFontStream, - int32_t iFaceIndex, - int32_t* pFaceCount, - FX_BOOL bSaveStream) { - void* Hash[1] = {(void*)(uintptr_t)pFontStream}; - FX_DWORD 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; - } -} -IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, - int32_t iFaceIndex, - int32_t* pFaceCount, - FX_BOOL bWantCache) { - FX_DWORD dwHash = 0; - IFX_Font* pFont = NULL; - if (bWantCache) { - CFX_ByteString bsHash; - bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); - dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); - if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { - if (NULL != pFont) { - if (NULL != 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) { - delete pInternalFont; - return NULL; - } - if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { - delete pInternalFont; - pFontStream->Release(); - return NULL; - } - pFont = IFX_Font::LoadFont(pInternalFont, this, TRUE); - if (NULL == pFont) { - delete pInternalFont; - pFontStream->Release(); - return NULL; - } - if (bWantCache) { - m_FileAccess2IFXFont.SetAt(dwHash, pFont); - } - m_IFXFont2FileRead.SetAt(pFont, pFontStream); - if (NULL != 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) { - 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; - 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) { - return 0; - } - IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; - int res = pFile->ReadBlock(buffer, offset, count); - if (res) { - return count; - } - return 0; -} -void _ftStreamClose(FXFT_Stream stream) {} -}; - -FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, - int32_t iFaceIndex) { - if (!pFontStream) - return nullptr; - - CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); - pFontMgr->InitFTLibrary(); - FXFT_Library library = pFontMgr->GetFTLibrary(); - if (!library) - return nullptr; - - FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); - FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); - ftStream->base = NULL; - ftStream->descriptor.pointer = pFontStream; - ftStream->pos = 0; - ftStream->size = (unsigned long)pFontStream->GetSize(); - ftStream->read = _ftStreamRead; - ftStream->close = _ftStreamClose; - - FXFT_Open_Args ftArgs; - FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); - ftArgs.flags |= FT_OPEN_STREAM; - ftArgs.stream = ftStream; - - FXFT_Face pFace = NULL; - if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { - FX_Free(ftStream); - return nullptr; - } - - FXFT_Set_Pixel_Sizes(pFace, 0, 64); - return pFace; -} - -IFX_FileRead* CFX_FontMgrImp::CreateFontStream( - CFX_FontMapper* pFontMapper, - IFX_SystemFontInfo* pSystemFontInfo, - FX_DWORD index) { - int iExact = 0; - void* hFont = pSystemFontInfo->MapFont( - 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact); - if (!hFont) - return nullptr; - FX_DWORD 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); -} - -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) - return CreateFontStream(pFontMapper, pSystemFontInfo, i); - } - return nullptr; -} -int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const CFX_WideString& FontName, - FX_WCHAR wcUnicode) { - MatchedFonts.RemoveAll(); - CFX_WideString wsNormalizedFontName = FontName; - static const int32_t nMax = 0xffff; - CFX_FontDescriptor* pFont = NULL; - 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) { - continue; - } - FX_FontDescriptorInfo FontInfo; - FontInfo.pFont = pFont; - FontInfo.nPenalty = nPenalty; - MatchedFonts.Add(FontInfo); - if (MatchedFonts.GetSize() == nMax) { - break; - } - } - if (MatchedFonts.GetSize() == 0) { - return 0; - } - CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; - ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); - return MatchedFonts.GetSize(); -} -struct FX_BitCodePage { - FX_WORD wBit; - FX_WORD wCodePage; -}; -static const FX_BitCodePage g_Bit2CodePage[] = { - {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, - {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, - {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, - {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, - {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, - {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0}, - {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0}, - {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0}, - {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862}, - {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775}, - {60, 737}, {61, 708}, {62, 850}, {63, 437}, -}; - -FX_WORD FX_GetCodePageBit(FX_WORD wCodePage) { - for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) { - if (g_Bit2CodePage[i].wCodePage == wCodePage) - return g_Bit2CodePage[i].wBit; - } - return (FX_WORD)-1; -} - -FX_WORD FX_GetUnicodeBit(FX_WCHAR wcUnicode) { - const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode); - return x ? x->wBitField : 999; -} - -int32_t CFX_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled, - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const CFX_WideString& FontName, - FX_WCHAR wcUnicode) { - int32_t nPenalty = 30000; - if (0 != FontName.GetLength()) { - if (FontName != pInstalled->m_wsFaceName) { - int32_t i; - for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { - if (pInstalled->m_wsFamilyNames[i] == FontName) { - break; - } - } - if (i == pInstalled->m_wsFamilyNames.GetSize()) { - nPenalty += 0xFFFF; - } else { - nPenalty -= 28000; - } - } else { - nPenalty -= 30000; - } - if (30000 == nPenalty && - 0 == IsPartName(pInstalled->m_wsFaceName, FontName)) { - int32_t i; - for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { - if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) { - break; - } - } - if (i == pInstalled->m_wsFamilyNames.GetSize()) { - nPenalty += 0xFFFF; - } else { - nPenalty -= 26000; - } - } else { - nPenalty -= 27000; - } - } - FX_DWORD dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles; - if (dwStyleMask & FX_FONTSTYLE_Bold) { - nPenalty += 4500; - } - if (dwStyleMask & FX_FONTSTYLE_FixedPitch) { - nPenalty += 10000; - } - if (dwStyleMask & FX_FONTSTYLE_Italic) { - nPenalty += 10000; - } - if (dwStyleMask & FX_FONTSTYLE_Serif) { - nPenalty += 500; - } - if (dwStyleMask & FX_FONTSTYLE_Symbolic) { - nPenalty += 0xFFFF; - } - if (nPenalty >= 0xFFFF) { - return 0xFFFF; - } - FX_WORD wBit = - ((0 == wCodePage || 0xFFFF == wCodePage) ? (FX_WORD)-1 - : FX_GetCodePageBit(wCodePage)); - if (wBit != (FX_WORD)-1) { - FXSYS_assert(wBit < 64); - if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) { - nPenalty += 0xFFFF; - } else { - nPenalty -= 60000; - } - } - wBit = - ((0 == wcUnicode || 0xFFFE == wcUnicode) ? (FX_WORD)999 - : FX_GetUnicodeBit(wcUnicode)); - if (wBit != (FX_WORD)999) { - FXSYS_assert(wBit < 128); - if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) { - nPenalty += 0xFFFF; - } else { - nPenalty -= 60000; - } - } - return nPenalty; -} -void CFX_FontMgrImp::ClearFontCache() { - FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - CFX_FontDescriptorInfos* pDescs; - m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); - if (NULL != pDescs) { - delete pDescs; - } - } - pos = m_FileAccess2IFXFont.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - IFX_Font* pFont; - m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); - if (NULL != pFont) { - pFont->Release(); - } - } - pos = m_IFXFont2FileRead.GetStartPosition(); - while (pos) { - IFX_Font* pFont; - IFX_FileRead* pFileRead; - m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); - pFileRead->Release(); - } -} -void CFX_FontMgrImp::RemoveFont(IFX_Font* pEFont) { - if (NULL == pEFont) { - return; - } - IFX_FileRead* pFileRead; - if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { - pFileRead->Release(); - m_IFXFont2FileRead.RemoveKey(pEFont); - } - FX_POSITION pos; - pos = m_FileAccess2IFXFont.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - IFX_Font* pCFont; - m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pCFont); - if (pCFont == pEFont) { - m_FileAccess2IFXFont.RemoveKey(dwHash); - break; - } - } - pos = m_Hash2Fonts.GetStartPosition(); - while (pos) { - FX_DWORD dwHash; - CFX_ArrayTemplate<IFX_Font*>* pFonts; - m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); - if (NULL != pFonts) { - for (int32_t i = 0; i < pFonts->GetSize(); i++) { - if (pFonts->GetAt(i) == pEFont) { - pFonts->SetAt(i, NULL); - } - } - } else { - m_Hash2Fonts.RemoveKey(dwHash); - } - } -} -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)) { - 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_WordArray Charsets; - GetCharsets(pFace, Charsets); - GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); - unsigned long nLength = 0; - FT_ULong dwTag; - uint8_t* pTable = NULL; - 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) { - pTable = FX_Alloc(uint8_t, nLength); - error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL); - if (0 != error) { - FX_Free(pTable); - pTable = NULL; - } - } - GetNames(pTable, pFont->m_wsFamilyNames); - if (NULL != 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_nFaceIndex = pFace->face_index; - if (pFontAccess) - pFont->m_pFileAccess = pFontAccess->Retain(); - else - pFont->m_pFileAccess = nullptr; - Fonts.Add(pFont); -} -void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream, - const CFX_WideString* pFaceName) { - int32_t index = 0; - int32_t num_faces = 0; - do { - FXFT_Face pFace = LoadFace(pFontStream, index++); - if (!pFace) - continue; - // All faces keep number of faces. It can be retrieved from any one face. - if (!num_faces) - num_faces = pFace->num_faces; - RegisterFace(pFace, m_InstalledFonts, pFaceName, nullptr); - if (FXFT_Get_Face_External_Stream(pFace)) - FXFT_Clear_Face_External_Stream(pFace); - FXFT_Done_Face(pFace); - } while (index < num_faces); -} -FX_DWORD CFX_FontMgrImp::GetFlags(FXFT_Face pFace) { - FX_DWORD flag = 0; - if (FT_IS_FIXED_WIDTH(pFace)) { - flag |= FX_FONTSTYLE_FixedPitch; - } - TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); - if (!pOS2) { - return flag; - } - if (pOS2->ulCodePageRange1 & (1 << 31)) { - flag |= FX_FONTSTYLE_Symbolic; - } - if (pOS2->panose[0] == 2) { - uint8_t uSerif = pOS2->panose[1]; - if ((uSerif > 1 && uSerif < 10) || uSerif > 13) { - flag |= FX_FONTSTYLE_Serif; - } - } - return flag; -} -#define GetUInt8(p) ((uint8_t)((p)[0])) -#define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) -#define GetUInt32(p) \ - ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) -void CFX_FontMgrImp::GetNames(const uint8_t* name_table, - CFX_WideStringArray& Names) { - if (NULL == name_table) { - return; - } - uint8_t* lpTable = (uint8_t*)name_table; - CFX_WideString wsFamily; - uint8_t* sp = lpTable + 2; - uint8_t* lpNameRecord = lpTable + 6; - uint16_t nNameCount = GetUInt16(sp); - uint8_t* lpStr = lpTable + GetUInt16(sp + 2); - for (uint16_t j = 0; j < nNameCount; j++) { - uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); - if (nNameID != 1) { - continue; - } - 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(); - if (nPlatformID != 1) { - for (uint16_t k = 0; k < nNameLength / 2; k++) { - FX_WCHAR wcTemp = GetUInt16(lpStr + nNameOffset + k * 2); - wsFamily += wcTemp; - } - Names.Add(wsFamily); - } else { - for (uint16_t k = 0; k < nNameLength; k++) { - FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k); - wsFamily += wcTemp; - } - Names.Add(wsFamily); - } - } -} -#undef GetUInt8 -#undef GetUInt16 -#undef GetUInt32 -struct FX_BIT2CHARSET { - FX_WORD wBit; - FX_WORD wCharset; -}; -FX_BIT2CHARSET g_FX_Bit2Charset1[16] = { - {1 << 0, FX_CHARSET_ANSI}, - {1 << 1, FX_CHARSET_MSWin_EasterEuropean}, - {1 << 2, FX_CHARSET_MSWin_Cyrillic}, - {1 << 3, FX_CHARSET_MSWin_Greek}, - {1 << 4, FX_CHARSET_MSWin_Turkish}, - {1 << 5, FX_CHARSET_MSWin_Hebrew}, - {1 << 6, FX_CHARSET_MSWin_Arabic}, - {1 << 7, FX_CHARSET_MSWin_Baltic}, - {1 << 8, FX_CHARSET_MSWin_Vietnamese}, - {1 << 9, FX_CHARSET_Default}, - {1 << 10, FX_CHARSET_Default}, - {1 << 11, FX_CHARSET_Default}, - {1 << 12, FX_CHARSET_Default}, - {1 << 13, FX_CHARSET_Default}, - {1 << 14, FX_CHARSET_Default}, - {1 << 15, FX_CHARSET_Default}, -}; -FX_BIT2CHARSET g_FX_Bit2Charset2[16] = { - {1 << 0, FX_CHARSET_Thai}, - {1 << 1, FX_CHARSET_ShiftJIS}, - {1 << 2, FX_CHARSET_ChineseSimplified}, - {1 << 3, FX_CHARSET_Korean}, - {1 << 4, FX_CHARSET_ChineseTriditional}, - {1 << 5, FX_CHARSET_Johab}, - {1 << 6, FX_CHARSET_Default}, - {1 << 7, FX_CHARSET_Default}, - {1 << 8, FX_CHARSET_Default}, - {1 << 9, FX_CHARSET_Default}, - {1 << 10, FX_CHARSET_Default}, - {1 << 11, FX_CHARSET_Default}, - {1 << 12, FX_CHARSET_Default}, - {1 << 13, FX_CHARSET_Default}, - {1 << 14, FX_CHARSET_OEM}, - {1 << 15, FX_CHARSET_Symbol}, -}; -FX_BIT2CHARSET g_FX_Bit2Charset3[16] = { - {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, - {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, - {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, - {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, - {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, - {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, - {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, - {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default}, -}; -FX_BIT2CHARSET g_FX_Bit2Charset4[16] = { - {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, - {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, - {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, - {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, - {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, - {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, - {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, - {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US}, -}; -#define CODEPAGERANGE_IMPLEMENT(n) \ - for (int32_t i = 0; i < 16; i++) { \ - if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) { \ - Charsets.Add(g_FX_Bit2Charset##n[i].wCharset); \ - } \ - } -void CFX_FontMgrImp::GetCharsets(FXFT_Face pFace, CFX_WordArray& Charsets) { - Charsets.RemoveAll(); - TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); - if (NULL != pOS2) { - FX_WORD a1, a2, a3, a4; - a1 = pOS2->ulCodePageRange1 & 0x0000ffff; - CODEPAGERANGE_IMPLEMENT(1); - a2 = (pOS2->ulCodePageRange1 >> 16) & 0x0000ffff; - CODEPAGERANGE_IMPLEMENT(2); - a3 = pOS2->ulCodePageRange2 & 0x0000ffff; - CODEPAGERANGE_IMPLEMENT(3); - a4 = (pOS2->ulCodePageRange2 >> 16) & 0x0000ffff; - CODEPAGERANGE_IMPLEMENT(4); - } else { - Charsets.Add(FX_CHARSET_Default); - } -} -#undef CODEPAGERANGE_IMPLEMENT -void CFX_FontMgrImp::GetUSBCSB(FXFT_Face pFace, FX_DWORD* USB, FX_DWORD* CSB) { - TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); - if (NULL != pOS2) { - USB[0] = pOS2->ulUnicodeRange1; - USB[1] = pOS2->ulUnicodeRange2; - USB[2] = pOS2->ulUnicodeRange3; - USB[3] = pOS2->ulUnicodeRange4; - CSB[0] = pOS2->ulCodePageRange1; - CSB[1] = pOS2->ulCodePageRange2; - } else { - USB[0] = 0; - USB[1] = 0; - USB[2] = 0; - USB[3] = 0; - CSB[0] = 0; - CSB[1] = 0; - } -} -int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, - const CFX_WideString& Name2) { - if (Name1.Find((const FX_WCHAR*)Name2) != -1) { - return 1; - } - return 0; -} -#endif diff --git a/xfa/src/fgas/font/fgas_stdfontmgr.h b/xfa/src/fgas/font/fgas_stdfontmgr.h deleted file mode 100644 index cf16033919..0000000000 --- a/xfa/src/fgas/font/fgas_stdfontmgr.h +++ /dev/null @@ -1,252 +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_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ -#define XFA_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ - -#include "core/include/fxcrt/fx_ext.h" -#include "core/include/fxge/fx_freetype.h" -#include "core/include/fxge/fx_ge.h" -#include "third_party/freetype/include/freetype/fttypes.h" -#include "xfa/src/fgas/font/fgas_font.h" - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, FX_DWORD dwFontStyles); -FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, - const CFX_FontDescriptors& fonts, - void* pUserData); - -class CFX_StdFontMgrImp : public IFX_FontMgr { - public: - CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator, - FX_LPMatchFont pMatcher, - void* pUserData); - ~CFX_StdFontMgrImp(); - virtual void Release() { delete this; } - virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF); - virtual IFX_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength); - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName); - virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, - const FX_WCHAR* pszFontAlias = NULL, - FX_DWORD dwFontStyles = 0, - FX_WORD wCodePage = 0, - FX_BOOL bSaveStream = FALSE); - virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF); - virtual void ClearFontCache(); - virtual void RemoveFont(IFX_Font* pFont); - - protected: - FX_LPMatchFont m_pMatcher; - FX_LPEnumAllFonts m_pEnumerator; - CFX_FontDescriptors m_FontFaces; - CFX_PtrArray m_Fonts; - CFX_MapPtrToPtr m_CPFonts; - CFX_MapPtrToPtr m_FamilyFonts; - CFX_MapPtrToPtr m_UnicodeFonts; - CFX_MapPtrToPtr m_BufferFonts; - 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, - FX_DWORD dwFontStyles, - FX_DWORD dwMatchFlags, - FX_WORD wCodePage, - FX_DWORD dwUSB = 999, - FX_WCHAR wUnicode = 0); - IFX_Font* GetFont(FX_LPCFONTDESCRIPTOR pFD, FX_DWORD dwFontStyles); -}; -FX_DWORD FX_GetGdiFontStyles(const LOGFONTW& lf); - -#else - -class CFX_FontDescriptor { - public: - CFX_FontDescriptor() - : m_pFileAccess(NULL), m_nFaceIndex(0), m_dwFontStyles(0) { - m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; - m_dwCsb[0] = m_dwCsb[1] = 0; - } - ~CFX_FontDescriptor() { - if (NULL != m_pFileAccess) { - m_pFileAccess->Release(); - } - } - IFX_FileAccess* m_pFileAccess; - int32_t m_nFaceIndex; - CFX_WideString m_wsFaceName; - CFX_WideStringArray m_wsFamilyNames; - FX_DWORD m_dwFontStyles; - FX_DWORD m_dwUsb[4]; - FX_DWORD m_dwCsb[2]; -}; -typedef CFX_ArrayTemplate<CFX_FontDescriptor*> CFX_FontDescriptors; - -struct FX_FontDescriptorInfo { - public: - CFX_FontDescriptor* pFont; - int32_t nPenalty; - - bool operator>(const FX_FontDescriptorInfo& other) const { - return nPenalty > other.nPenalty; - } - bool operator<(const FX_FontDescriptorInfo& other) const { - return nPenalty < other.nPenalty; - } - bool operator==(const FX_FontDescriptorInfo& other) const { - return nPenalty == other.nPenalty; - } -}; -typedef CFX_ArrayTemplate<FX_FontDescriptorInfo> CFX_FontDescriptorInfos; - -struct FX_HandleParentPath { - FX_HandleParentPath() {} - FX_HandleParentPath(const FX_HandleParentPath& x) { - pFileHandle = x.pFileHandle; - bsParentPath = x.bsParentPath; - } - void* pFileHandle; - CFX_ByteString bsParentPath; -}; - -class CFX_FontSourceEnum_File : public IFX_FontSourceEnum { - 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); - - private: - CFX_ByteString GetNextFile(); - CFX_WideString m_wsNext; - CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue; - CFX_ByteStringArray m_FolderPaths; -}; -typedef CFX_MapPtrTemplate<FX_DWORD, IFX_FileAccess*> CFX_HashFileMap; -typedef CFX_MapPtrTemplate<FX_DWORD, IFX_Font*> CFX_HashFontMap; -typedef CFX_MapPtrTemplate<FX_DWORD, CFX_FontDescriptorInfos*> - CFX_HashFontDescsMap; -typedef CFX_MapPtrTemplate<FX_DWORD, CFX_ArrayTemplate<IFX_Font*>*> - CFX_HashFontsMap; -typedef CFX_MapPtrTemplate<FX_WCHAR, IFX_Font*> CFX_UnicodeFontMap; -typedef CFX_MapPtrTemplate<IFX_FileAccess*, CFX_ArrayTemplate<IFX_Font*>*> - CFX_FileFontMap; -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); - virtual void Release(); - virtual IFX_Font* GetDefFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetDefFontByLanguage(FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetFontByCodePage(FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetFontByCharset(uint8_t nCharset, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetFontByUnicode(FX_WCHAR wUnicode, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* GetFontByLanguage(FX_WORD wLanguage, - FX_DWORD dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL); - virtual IFX_Font* LoadFont(const uint8_t* pBuffer, - int32_t iLength, - int32_t iFaceIndex, - int32_t* pFaceCount); - virtual IFX_Font* LoadFont(const FX_WCHAR* pszFileName, - int32_t iFaceIndex, - int32_t* pFaceCount); - virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, - int32_t iFaceIndex, - int32_t* pFaceCount, - FX_BOOL bSaveStream = FALSE); - virtual IFX_Font* LoadFont(const CFX_WideString& wsFaceName, - int32_t iFaceIndex, - int32_t* pFaceCount); - virtual void ClearFontCache(); - virtual void RemoveFont(IFX_Font* pFont); - FX_BOOL EnumFonts(); - FX_BOOL EnumFontsFromFontMapper(); - FX_BOOL EnumFontsFromFiles(); - - protected: - void RegisterFace(FXFT_Face pFace, - CFX_FontDescriptors& Fonts, - const CFX_WideString* pFaceName, - IFX_FileAccess* pFontAccess); - void RegisterFaces(IFX_FileRead* pFontStream, - const CFX_WideString* pFaceName); - void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); - void GetCharsets(FXFT_Face pFace, CFX_WordArray& Charsets); - void GetUSBCSB(FXFT_Face pFace, FX_DWORD* USB, FX_DWORD* CSB); - FX_DWORD GetFlags(FXFT_Face pFace); - CFX_FontDescriptors m_InstalledFonts; - FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); - FX_BOOL VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode); - int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); - int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const CFX_WideString& FontName, - FX_WCHAR wcUnicode = 0xFFFE); - int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, - FX_WORD wCodePage, - FX_DWORD dwFontStyles, - const CFX_WideString& FontName, - FX_WCHAR wcUnicode = 0xFFFE); - IFX_Font* LoadFont(IFX_FileAccess* pFontAccess, - int32_t iFaceIndex, - int32_t* pFaceCount, - FX_BOOL bWantCache = FALSE); - FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); - IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, - IFX_SystemFontInfo* pSystemFontInfo, - FX_DWORD 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; -}; -#endif - -#endif // XFA_SRC_FGAS_FONT_FGAS_STDFONTMGR_H_ diff --git a/xfa/src/fgas/layout/fgas_linebreak.cpp b/xfa/src/fgas/layout/fgas_linebreak.cpp deleted file mode 100644 index b43b8007b4..0000000000 --- a/xfa/src/fgas/layout/fgas_linebreak.cpp +++ /dev/null @@ -1,320 +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/src/fgas/layout/fgas_linebreak.h" - -#include "core/include/fxcrt/fx_ucd.h" - -const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32] = { - {FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBPB, FX_LBPB, FX_LBPB, FX_LBCP, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBPB, FX_LBPB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBPB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBPB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBIB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBIB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBIB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBIB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBIB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBDB, FX_LBPB, FX_LBPB, FX_LBPB, FX_LBDB, FX_LBPB, - FX_LBDB, FX_LBIB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBPB, FX_LBPB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBPB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBDB, FX_LBPB, FX_LBIB, FX_LBDB, FX_LBIB, FX_LBPB, FX_LBPB, FX_LBPB, - FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBDB, FX_LBIB, FX_LBIB, - FX_LBDB, FX_LBDB, FX_LBPB, FX_LBCB, FX_LBPB, FX_LBDB, FX_LBDB, FX_LBDB, - FX_LBDB, FX_LBDB, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, - {FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, - FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN, FX_LBUN}, -}; - -void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, - FX_LINEBREAKTYPE* pBrkType, - int32_t iLength) { - if (iLength < 2) { - return; - } - FX_DWORD dwCur, dwNext; - FX_WCHAR wch; - wch = *pwsText++; - dwCur = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; - iLength--; - for (int32_t i = 0; i < iLength; i++) { - wch = *pwsText++; - dwNext = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; - if (dwNext == FX_CBP_SP) { - pBrkType[i] = FX_LBT_PROHIBITED_BRK; - } else { - pBrkType[i] = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (dwCur << 5) + dwNext); - } - dwCur = dwNext; - } - pBrkType[iLength] = FX_LBT_INDIRECT_BRK; -} -void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, - int32_t iLength, - CFX_Int32MassArray& bp) { - if (iLength < 2) { - return; - } - FX_LINEBREAKTYPE eType; - FX_DWORD dwCur, dwNext; - FX_WCHAR wch; - wch = *pwsText++; - dwCur = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; - iLength--; - for (int32_t i = 0; i < iLength; i++) { - wch = *pwsText++; - dwNext = kTextLayoutCodeProperties[(FX_WORD)wch] & 0x003F; - if (dwNext == FX_CBP_SP) { - eType = FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (dwCur << 5) + dwNext); - } - if (eType == FX_LBT_DIRECT_BRK) { - bp.Add(i); - } - dwCur = dwNext; - } -} diff --git a/xfa/src/fgas/layout/fgas_linebreak.h b/xfa/src/fgas/layout/fgas_linebreak.h deleted file mode 100644 index 7b91124bc2..0000000000 --- a/xfa/src/fgas/layout/fgas_linebreak.h +++ /dev/null @@ -1,40 +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_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ -#define XFA_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ - -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fgas/crt/fgas_utils.h" - -enum FX_LINEBREAKTYPE { - FX_LBT_UNKNOWN = 0x00, - FX_LBT_DIRECT_BRK = 0x1A, - FX_LBT_INDIRECT_BRK = 0x2B, - FX_LBT_COM_INDIRECT_BRK = 0x3C, - FX_LBT_COM_PROHIBITED_BRK = 0x4D, - FX_LBT_PROHIBITED_BRK = 0x5E, - FX_LBT_HANGUL_SPACE_BRK = 0x6F, -}; - -#define FX_LBUN FX_LBT_UNKNOWN -#define FX_LBDB FX_LBT_DIRECT_BRK -#define FX_LBIB FX_LBT_INDIRECT_BRK -#define FX_LBCB FX_LBT_COM_INDIRECT_BRK -#define FX_LBCP FX_LBT_COM_PROHIBITED_BRK -#define FX_LBPB FX_LBT_PROHIBITED_BRK -#define FX_LBHS FX_LBT_HANGUL_SPACE_BRK - -extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32]; - -void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, - FX_LINEBREAKTYPE* pBrkType, - int32_t iLength); -void FX_GetLineBreakPositions(const FX_WCHAR* pwsText, - int32_t iLength, - CFX_Int32MassArray& bp); - -#endif // XFA_SRC_FGAS_LAYOUT_FGAS_LINEBREAK_H_ diff --git a/xfa/src/fgas/layout/fgas_rtfbreak.cpp b/xfa/src/fgas/layout/fgas_rtfbreak.cpp deleted file mode 100644 index 7e4ab4c08c..0000000000 --- a/xfa/src/fgas/layout/fgas_rtfbreak.cpp +++ /dev/null @@ -1,1691 +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/src/fgas/layout/fgas_rtfbreak.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_arb.h" -#include "xfa/src/fgas/layout/fgas_linebreak.h" -#include "xfa/src/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(FX_DWORD dwPolicies); - ~CFX_RTFBreak(); - void Release() override { delete this; } - void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; - void SetLineStartPos(FX_FLOAT fLinePos) override; - FX_DWORD GetLayoutStyles() const override { return m_dwLayoutStyles; } - void SetLayoutStyles(FX_DWORD 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; - FX_DWORD AppendChar(FX_WCHAR wch) override; - FX_DWORD EndBreak(FX_DWORD 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; - FX_DWORD AppendChar_CharCode(FX_WCHAR wch); - FX_DWORD AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); - - protected: - FX_DWORD m_dwPolicies; - IFX_ArabicChar* m_pArabicChar; - int32_t m_iBoundaryStart; - int32_t m_iBoundaryEnd; - FX_DWORD 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; - FX_DWORD m_dwCharType; - FX_DWORD 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(FX_DWORD 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; - FX_DWORD GetUnifiedCharType(FX_DWORD 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, - FX_DWORD dwStatus); - void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); - void EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD dwStatus); -}; - -} // namespace - -IFX_RTFBreak* IFX_RTFBreak::Create(FX_DWORD dwPolicies) { - return new CFX_RTFBreak(dwPolicies); -} -CFX_RTFBreak::CFX_RTFBreak(FX_DWORD dwPolicies) - : m_dwPolicies(dwPolicies), - m_pArabicChar(NULL), - m_iBoundaryStart(0), - m_iBoundaryEnd(2000000), - m_dwLayoutStyles(0), - m_bPagination(FALSE), - m_bVertical(FALSE), - m_bSingleLine(FALSE), - m_bCharCode(FALSE), - m_pFont(NULL), - m_iFontHeight(240), - m_iFontSize(240), - m_iTabWidth(720000), - m_PositionedTabs(), - m_bOrphanLine(FALSE), - m_wDefChar(0xFEFF), - m_iDefChar(0), - m_wLineBreakChar(L'\n'), - m_iHorizontalScale(100), - m_iVerticalScale(100), - m_iLineRotation(0), - m_iCharRotation(0), - m_iRotation(0), - m_iCharSpace(0), - m_bWordSpace(FALSE), - m_iWordSpace(0), - m_bRTL(FALSE), - m_iAlignment(FX_RTFLINEALIGNMENT_Left), - m_pUserData(NULL), - m_dwCharType(0), - m_dwIdentity(0), - m_RTFLine1(), - m_RTFLine2(), - 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(); - } -} -void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { - if (fLineStart > fLineEnd) - return; - m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); - m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); - m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); - m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); -} -void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { - int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); - iLinePos = std::min(iLinePos, m_iBoundaryEnd); - iLinePos = std::max(iLinePos, m_iBoundaryStart); - m_pCurLine->m_iStart = iLinePos; -} -void CFX_RTFBreak::SetLayoutStyles(FX_DWORD dwLayoutStyles) { - if (m_dwLayoutStyles == dwLayoutStyles) { - return; - } - SetBreakStatus(); - m_dwLayoutStyles = dwLayoutStyles; - m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; - m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; - m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; - m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; - m_iLineRotation = GetLineRotation(m_dwLayoutStyles); - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; -} -void CFX_RTFBreak::SetFont(IFX_Font* pFont) { - if (pFont == NULL) { - return; - } - if (m_pFont == pFont) { - return; - } - SetBreakStatus(); - m_pFont = pFont; - m_iDefChar = 0; - if (m_pFont != NULL) { - m_iFontHeight = m_iFontSize; - if (m_wDefChar != 0xFEFF) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - m_iDefChar *= m_iFontSize; - } - } -} -void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - if (m_iFontSize == iFontSize) { - return; - } - SetBreakStatus(); - m_iFontSize = iFontSize; - m_iDefChar = 0; - if (m_pFont != NULL) { - m_iFontHeight = m_iFontSize; - if (m_wDefChar != 0xFEFF) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - m_iDefChar *= m_iFontSize; - } - } -} -void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { - m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); -} -void CFX_RTFBreak::AddPositionedTab(FX_FLOAT fTabPos) { - int32_t iLineEnd = m_iBoundaryEnd; - int32_t iTabPos = FXSYS_round(fTabPos * 20000.0f) + m_iBoundaryStart; - if (iTabPos > iLineEnd) { - iTabPos = iLineEnd; - } - if (m_PositionedTabs.Find(iTabPos, 0) > -1) { - return; - } - int32_t iCount = m_PositionedTabs.GetSize(); - int32_t iFind = 0; - for (; iFind < iCount; iFind++) { - if (m_PositionedTabs[iFind] > iTabPos) { - break; - } - } - m_PositionedTabs.InsertAt(iFind, iTabPos); - if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { - m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; - } else { - m_bOrphanLine = FALSE; - } -} -void CFX_RTFBreak::SetPositionedTabs(const CFX_FloatArray& tabs) { - m_PositionedTabs.RemoveAll(); - int32_t iCount = tabs.GetSize(); - m_PositionedTabs.SetSize(iCount); - int32_t iLineEnd = m_iBoundaryEnd; - int32_t iTabPos; - for (int32_t i = 0; i < iCount; i++) { - iTabPos = FXSYS_round(tabs[i] * 20000.0f) + m_iBoundaryStart; - if (iTabPos > iLineEnd) { - iTabPos = iLineEnd; - } - m_PositionedTabs[i] = iTabPos; - } - if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { - m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; - } else { - m_bOrphanLine = FALSE; - } -} -void CFX_RTFBreak::ClearPositionedTabs() { - m_PositionedTabs.RemoveAll(); - m_bOrphanLine = FALSE; -} -void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { - m_wDefChar = wch; - m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - if (m_iDefChar < 0) { - m_iDefChar = 0; - } else { - m_iDefChar *= m_iFontSize; - } - } -} -void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { - if (wch != L'\r' && wch != L'\n') { - return; - } - m_wLineBreakChar = wch; -} -void CFX_RTFBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) { - m_iTolerance = FXSYS_round(fTolerance * 20000.0f); -} -void CFX_RTFBreak::SetHorizontalScale(int32_t iScale) { - if (iScale < 0) { - iScale = 0; - } - if (m_iHorizontalScale == iScale) { - return; - } - SetBreakStatus(); - m_iHorizontalScale = iScale; -} -void CFX_RTFBreak::SetVerticalScale(int32_t iScale) { - if (iScale < 0) { - iScale = 0; - } - if (m_iVerticalScale == iScale) { - return; - } - SetBreakStatus(); - m_iVerticalScale = iScale; -} -void CFX_RTFBreak::SetCharRotation(int32_t iCharRotation) { - if (iCharRotation < 0) { - iCharRotation += (-iCharRotation / 4 + 1) * 4; - } else if (iCharRotation > 3) { - iCharRotation -= (iCharRotation / 4) * 4; - } - if (m_iCharRotation == iCharRotation) { - return; - } - SetBreakStatus(); - m_iCharRotation = iCharRotation; - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; -} -void CFX_RTFBreak::SetCharSpace(FX_FLOAT fCharSpace) { - m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); -} -void CFX_RTFBreak::SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) { - m_bWordSpace = !bDefault; - m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f); -} -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); - m_iAlignment = iAlignment; -} -void CFX_RTFBreak::SetUserData(IFX_Unknown* pUserData) { - if (m_pUserData == pUserData) { - return; - } - SetBreakStatus(); - if (m_pUserData != NULL) { - m_pUserData->Release(); - } - m_pUserData = pUserData; - if (m_pUserData != NULL) { - m_pUserData->AddRef(); - } -} -static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; -int32_t CFX_RTFBreak::GetLineRotation(FX_DWORD dwStyles) const { - return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; -} -void CFX_RTFBreak::SetBreakStatus() { - m_dwIdentity++; - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 1) { - return; - } - CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); - if (tc.m_dwStatus == 0) { - tc.m_dwStatus = FX_RTFBREAK_PieceBreak; - } -} -CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { - CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; - int32_t iCount = tca.GetSize(); - if (index < 0 || index >= iCount) { - return NULL; - } - CFX_RTFChar* pTC; - int32_t iStart = iCount - 1; - while (iStart > -1) { - pTC = tca.GetDataPtr(iStart--); - if (pTC->m_iCharWidth >= 0 || - pTC->GetCharType() != FX_CHARTYPE_Combination) { - if (--index < 0) { - return pTC; - } - } - } - return NULL; -} -CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { - if (bReady) { - if (m_iReady == 1) { - return (CFX_RTFLine*)&m_RTFLine1; - } else if (m_iReady == 2) { - return (CFX_RTFLine*)&m_RTFLine2; - } else { - return NULL; - } - } - FXSYS_assert(m_pCurLine != NULL); - return m_pCurLine; -} -CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { - CFX_RTFLine* pRTFLine = GetRTFLine(bReady); - if (pRTFLine == NULL) { - return NULL; - } - return &pRTFLine->m_LinePieces; -} -inline FX_DWORD CFX_RTFBreak::GetUnifiedCharType(FX_DWORD dwType) const { - return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; -} -int32_t CFX_RTFBreak::GetLastPositionedTab() const { - int32_t iCount = m_PositionedTabs.GetSize(); - if (iCount < 1) { - return m_iBoundaryStart; - } - return m_PositionedTabs[iCount - 1]; -} -FX_BOOL CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const { - int32_t iCount = m_PositionedTabs.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - if (m_PositionedTabs[i] > iTabPos) { - iTabPos = m_PositionedTabs[i]; - return TRUE; - } - } - return FALSE; -} -typedef FX_DWORD (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)( - CFX_RTFChar* pCurChar, - int32_t iRotation); -static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = { - &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab, - &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control, - &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others, - &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic, - &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, - &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, - &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, - &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, -}; -FX_DWORD CFX_RTFBreak::AppendChar(FX_WCHAR wch) { - FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL); - if (m_bCharCode) { - return AppendChar_CharCode(wch); - } - FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; - FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); - CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; - CFX_RTFChar* pCurChar = tca.AddSpace(); - pCurChar->m_dwStatus = 0; - pCurChar->m_wCharCode = wch; - pCurChar->m_dwCharProps = dwProps; - pCurChar->m_dwCharStyles = 0; - pCurChar->m_dwLayoutStyles = 0; - pCurChar->m_iFontSize = m_iFontSize; - pCurChar->m_iFontHeight = m_iFontHeight; - pCurChar->m_iHorizontalScale = m_iHorizontalScale; - pCurChar->m_iVertialScale = m_iVerticalScale; - pCurChar->m_nRotation = m_iCharRotation; - pCurChar->m_iCharWidth = 0; - pCurChar->m_dwIdentity = m_dwIdentity; - if (m_pUserData != NULL) { - m_pUserData->AddRef(); - } - pCurChar->m_pUserData = m_pUserData; - FX_DWORD dwRet1 = FX_RTFBREAK_None; - if (dwType != FX_CHARTYPE_Combination && - GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { - if (!m_bSingleLine && !m_bOrphanLine && m_dwCharType > 0 && - m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { - dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); - int32_t iCount = m_pCurLine->CountChars(); - if (iCount > 0) { - pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); - } - } - } - } - int32_t iRotation = m_iRotation; - if (m_bVertical && (dwProps & 0x8000) != 0) { - iRotation = (iRotation + 1) % 4; - } - FX_DWORD dwRet2 = - (this->*g_FX_RTFBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( - pCurChar, iRotation); - m_dwCharType = dwType; - return std::max(dwRet1, dwRet2); -} -FX_DWORD CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { - FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL); - FXSYS_assert(m_bCharCode); - m_pCurLine->m_iMBCSChars++; - CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; - CFX_RTFChar* pCurChar = tca.AddSpace(); - pCurChar->m_dwStatus = 0; - pCurChar->m_wCharCode = wch; - pCurChar->m_dwCharProps = 0; - pCurChar->m_dwCharStyles = 0; - pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; - pCurChar->m_iFontSize = m_iFontSize; - pCurChar->m_iFontHeight = m_iFontHeight; - pCurChar->m_iHorizontalScale = m_iHorizontalScale; - pCurChar->m_iVertialScale = m_iVerticalScale; - pCurChar->m_nRotation = m_iCharRotation; - pCurChar->m_iCharWidth = 0; - pCurChar->m_dwIdentity = m_dwIdentity; - if (m_pUserData != NULL) { - m_pUserData->AddRef(); - } - pCurChar->m_pUserData = m_pUserData; - int32_t iCharWidth = 0; - if (m_bVertical != FX_IsOdd(m_iRotation)) { - iCharWidth = 1000; - } else { - if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { - iCharWidth = m_iDefChar; - } - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorizontalScale / 100; - iCharWidth += m_iCharSpace; - pCurChar->m_iCharWidth = iCharWidth; - m_pCurLine->m_iWidth += iCharWidth; - m_dwCharType = 0; - if (!m_bSingleLine && - m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - return EndBreak(FX_RTFBREAK_LineBreak); - } - return FX_RTFBREAK_None; -} -FX_DWORD CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar, - int32_t iRotation) { - int32_t iCharWidth = 0; - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else { - if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, - m_bCharCode)) { - iCharWidth = 0; - } - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorizontalScale / 100; - CFX_RTFChar* pLastChar = GetLastChar(0); - if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { - iCharWidth = -iCharWidth; - } else { - m_dwCharType = FX_CHARTYPE_Combination; - } - pCurChar->m_iCharWidth = iCharWidth; - if (iCharWidth > 0) { - m_pCurLine->m_iWidth += iCharWidth; - } - return FX_RTFBREAK_None; -} -FX_DWORD CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar, - int32_t iRotation) { - if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) { - FX_BOOL bBreak = FALSE; - if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { - bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance); - } - int32_t& iLineWidth = m_pCurLine->m_iWidth; - int32_t iCharWidth = iLineWidth; - if (GetPositionedTab(iCharWidth)) { - iCharWidth -= iLineWidth; - } else { - iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth; - } - pCurChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - if (!m_bSingleLine && !m_bOrphanLine && bBreak) { - return EndBreak(FX_RTFBREAK_LineBreak); - } - } - return FX_RTFBREAK_None; -} -FX_DWORD CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar, - int32_t iRotation) { - FX_DWORD dwRet2 = FX_RTFBREAK_None; - if (!m_bSingleLine) { - switch (pCurChar->m_wCharCode) { - case L'\v': - case 0x2028: - dwRet2 = FX_RTFBREAK_LineBreak; - break; - case L'\f': - dwRet2 = FX_RTFBREAK_PageBreak; - break; - case 0x2029: - dwRet2 = FX_RTFBREAK_ParagraphBreak; - break; - default: - if (pCurChar->m_wCharCode == m_wLineBreakChar) { - dwRet2 = FX_RTFBREAK_ParagraphBreak; - } - break; - } - if (dwRet2 != FX_RTFBREAK_None) { - dwRet2 = EndBreak(dwRet2); - } - } - return dwRet2; -} -FX_DWORD CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, - int32_t iRotation) { - CFX_RTFChar* pLastChar = NULL; - int32_t& iLineWidth = m_pCurLine->m_iWidth; - int32_t iCharWidth = 0; - FX_WCHAR wForm; - FX_BOOL bAlef = FALSE; - if (m_dwCharType >= FX_CHARTYPE_ArabicAlef && - m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { - pLastChar = GetLastChar(1); - if (pLastChar != NULL) { - iLineWidth -= pLastChar->m_iCharWidth; - CFX_RTFChar* pPrevChar = GetLastChar(2); - wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar); - bAlef = (wForm == 0xFEFF && - pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); - int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; - if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { - iLastRotation++; - } - if (m_bVertical != FX_IsOdd(iLastRotation)) { - iCharWidth = 1000; - } else { - if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode)) { - if (!m_pFont->GetCharWidth(pLastChar->m_wCharCode, iCharWidth, - m_bCharCode)) { - iCharWidth = m_iDefChar; - } - } - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorizontalScale / 100; - pLastChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - iCharWidth = 0; - } - } - wForm = - m_pArabicChar->GetFormChar(pCurChar, (bAlef ? NULL : pLastChar), NULL); - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode) && - !m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, - m_bCharCode)) { - iCharWidth = m_iDefChar; - } - - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorizontalScale / 100; - pCurChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - m_pCurLine->m_iArabicChars++; - if (!m_bSingleLine && !m_bOrphanLine && - m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - return EndBreak(FX_RTFBREAK_LineBreak); - } - return FX_RTFBREAK_None; -} -FX_DWORD CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar, - int32_t iRotation) { - FX_DWORD dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); - FX_WCHAR wForm; - if (dwType == FX_CHARTYPE_Numeric) { - if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) { - wForm = pCurChar->m_wCharCode + 0x0630; - } else { - wForm = pCurChar->m_wCharCode; - } - } else if (m_bRTL || m_bVertical) { - wForm = FX_GetMirrorChar(pCurChar->m_wCharCode, pCurChar->m_dwCharProps, - m_bRTL, m_bVertical); - } else { - wForm = pCurChar->m_wCharCode; - } - int32_t iCharWidth = 0; - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else { - if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode)) { - iCharWidth = m_iDefChar; - } - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorizontalScale / 100; - iCharWidth += m_iCharSpace; - if (dwType == FX_CHARTYPE_Space && m_bWordSpace) { - iCharWidth += m_iWordSpace; - } - pCurChar->m_iCharWidth = iCharWidth; - m_pCurLine->m_iWidth += iCharWidth; - FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || - (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0); - if (!m_bSingleLine && !m_bOrphanLine && bBreak && - m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - return EndBreak(FX_RTFBREAK_LineBreak); - } - return FX_RTFBREAK_None; -} -FX_DWORD CFX_RTFBreak::EndBreak(FX_DWORD dwStatus) { - FXSYS_assert(dwStatus >= FX_RTFBREAK_PieceBreak && - dwStatus <= FX_RTFBREAK_PageBreak); - m_dwIdentity++; - CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; - int32_t iCount = pCurPieces->GetSize(); - if (iCount > 0) { - CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); - if (dwStatus > FX_RTFBREAK_PieceBreak) { - pLastPiece->m_dwStatus = dwStatus; - } else { - dwStatus = pLastPiece->m_dwStatus; - } - return dwStatus; - } else { - CFX_RTFLine* pLastLine = GetRTFLine(TRUE); - if (pLastLine != NULL) { - pCurPieces = &pLastLine->m_LinePieces; - iCount = pCurPieces->GetSize(); - if (iCount-- > 0) { - CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); - if (dwStatus > FX_RTFBREAK_PieceBreak) { - pLastPiece->m_dwStatus = dwStatus; - } else { - dwStatus = pLastPiece->m_dwStatus; - } - return dwStatus; - } - return FX_RTFBREAK_None; - } - iCount = m_pCurLine->CountChars(); - if (iCount < 1) { - return FX_RTFBREAK_None; - } - CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); - tc.m_dwStatus = dwStatus; - if (dwStatus <= FX_RTFBREAK_PieceBreak) { - return dwStatus; - } - } - m_iReady = (m_pCurLine == &m_RTFLine1) ? 1 : 2; - CFX_RTFLine* pNextLine = - (m_pCurLine == &m_RTFLine1) ? &m_RTFLine2 : &m_RTFLine1; - FX_BOOL bAllChars = (m_iAlignment > FX_RTFLINEALIGNMENT_Right); - CFX_TPOArray tpos; - if (EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) { - goto EndBreak_Ret; - } - if (!m_bCharCode) { - EndBreak_BidiLine(tpos, dwStatus); - } - if (!m_bPagination && m_iAlignment > FX_RTFLINEALIGNMENT_Left) { - EndBreak_Alignment(tpos, bAllChars, dwStatus); - } -EndBreak_Ret: - m_pCurLine = pNextLine; - m_pCurLine->m_iStart = m_iBoundaryStart; - CFX_RTFChar* pTC = GetLastChar(0); - m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); - return dwStatus; -} -FX_BOOL CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, - FX_BOOL bAllChars, - FX_DWORD dwStatus) { - FX_BOOL bDone = FALSE; - if (!m_bSingleLine && !m_bOrphanLine && - m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); - switch (tc.GetCharType()) { - case FX_CHARTYPE_Tab: - if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { - SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); - bDone = TRUE; - } - break; - case FX_CHARTYPE_Control: - break; - case FX_CHARTYPE_Space: - if ((m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0) { - SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); - bDone = TRUE; - } - break; - default: - SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); - bDone = TRUE; - break; - } - } - if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { - const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); - const CFX_RTFChar* pTC; - CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; - CFX_RTFPiece tp; - tp.m_pChars = &m_pCurLine->m_LineChars; - FX_BOOL bNew = TRUE; - FX_DWORD dwIdentity = (FX_DWORD)-1; - int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; - for (int32_t i = 0; i <= iLast;) { - pTC = pCurChars + i; - if (bNew) { - tp.m_iStartChar = i; - tp.m_iStartPos += tp.m_iWidth; - tp.m_iWidth = 0; - tp.m_dwStatus = pTC->m_dwStatus; - tp.m_iFontSize = pTC->m_iFontSize; - tp.m_iFontHeight = pTC->m_iFontHeight; - tp.m_iHorizontalScale = pTC->m_iHorizontalScale; - tp.m_iVerticalScale = pTC->m_iVertialScale; - tp.m_dwLayoutStyles = pTC->m_dwLayoutStyles; - dwIdentity = pTC->m_dwIdentity; - tp.m_dwIdentity = dwIdentity; - tp.m_pUserData = pTC->m_pUserData; - j = i; - bNew = FALSE; - } - if (i == iLast || pTC->m_dwStatus != FX_RTFBREAK_None || - pTC->m_dwIdentity != dwIdentity) { - tp.m_iChars = i - j; - if (pTC->m_dwIdentity == dwIdentity) { - tp.m_dwStatus = pTC->m_dwStatus; - tp.m_iWidth += pTC->m_iCharWidth; - tp.m_iChars += 1; - i++; - } - pCurPieces->Add(tp); - bNew = TRUE; - } else { - tp.m_iWidth += pTC->m_iCharWidth; - i++; - } - } - return TRUE; - } - if (bAllChars && !bDone) { - int32_t iEndPos = m_pCurLine->GetLineEnd(); - GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, TRUE); - } - return FALSE; -} -void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus) { - FX_TPO tpo; - CFX_RTFPiece tp; - CFX_RTFChar* pTC; - int32_t i, j; - CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; - int32_t iCount = m_pCurLine->CountChars(); - FX_BOOL bDone = (!m_bPagination && !m_bCharCode && - (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); - if (bDone) { - int32_t iBidiNum = 0; - for (i = 0; i < iCount; i++) { - pTC = chars.GetDataPtr(i); - pTC->m_iBidiPos = i; - if (pTC->GetCharType() != FX_CHARTYPE_Control) { - iBidiNum = i; - } - if (i == 0) { - pTC->m_iBidiLevel = 1; - } - } - FX_BidiLine(chars, iBidiNum + 1, m_bRTL ? 1 : 0); - } else { - for (i = 0; i < iCount; i++) { - pTC = chars.GetDataPtr(i); - pTC->m_iBidiLevel = 0; - pTC->m_iBidiPos = 0; - pTC->m_iBidiOrder = 0; - } - } - tp.m_dwStatus = FX_RTFBREAK_PieceBreak; - tp.m_iStartPos = m_pCurLine->m_iStart; - tp.m_pChars = &chars; - CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; - int32_t iBidiLevel = -1, iCharWidth; - FX_DWORD dwIdentity = (FX_DWORD)-1; - i = j = 0; - while (i < iCount) { - pTC = chars.GetDataPtr(i); - if (iBidiLevel < 0) { - iBidiLevel = pTC->m_iBidiLevel; - iCharWidth = pTC->m_iCharWidth; - if (iCharWidth < 1) { - tp.m_iWidth = 0; - } else { - tp.m_iWidth = iCharWidth; - } - tp.m_iBidiLevel = iBidiLevel; - tp.m_iBidiPos = pTC->m_iBidiOrder; - tp.m_iFontSize = pTC->m_iFontSize; - tp.m_iFontHeight = pTC->m_iFontHeight; - tp.m_iHorizontalScale = pTC->m_iHorizontalScale; - tp.m_iVerticalScale = pTC->m_iVertialScale; - dwIdentity = pTC->m_dwIdentity; - tp.m_dwIdentity = dwIdentity; - tp.m_pUserData = pTC->m_pUserData; - tp.m_dwStatus = FX_RTFBREAK_PieceBreak; - i++; - } else if (iBidiLevel != pTC->m_iBidiLevel || - pTC->m_dwIdentity != dwIdentity) { - tp.m_iChars = i - tp.m_iStartChar; - pCurPieces->Add(tp); - tp.m_iStartPos += tp.m_iWidth; - tp.m_iStartChar = i; - tpo.index = j++; - tpo.pos = tp.m_iBidiPos; - tpos.Add(tpo); - iBidiLevel = -1; - } else { - iCharWidth = pTC->m_iCharWidth; - if (iCharWidth > 0) { - tp.m_iWidth += iCharWidth; - } - i++; - } - } - if (i > tp.m_iStartChar) { - tp.m_dwStatus = dwStatus; - tp.m_iChars = i - tp.m_iStartChar; - pCurPieces->Add(tp); - tpo.index = j; - tpo.pos = tp.m_iBidiPos; - tpos.Add(tpo); - } - if (!m_bCharCode) { - j = tpos.GetSize() - 1; - FX_TEXTLAYOUT_PieceSort(tpos, 0, j); - int32_t iStartPos = m_pCurLine->m_iStart; - for (i = 0; i <= j; i++) { - tpo = tpos.GetAt(i); - CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); - ttp.m_iStartPos = iStartPos; - iStartPos += ttp.m_iWidth; - } - } -} -void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD dwStatus) { - CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; - int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; - int32_t iCount = pCurPieces->GetSize(); - FX_BOOL bFind = FALSE; - FX_DWORD dwCharType; - int32_t i, j; - FX_TPO tpo; - for (i = iCount - 1; i > -1; i--) { - tpo = tpos.GetAt(i); - CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); - if (!bFind) { - iNetWidth = ttp.GetEndPos(); - } - FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); - j = bArabic ? 0 : ttp.m_iChars - 1; - while (j > -1 && j < ttp.m_iChars) { - const CFX_RTFChar& tc = ttp.GetChar(j); - if (tc.m_nBreakType == FX_LBT_DIRECT_BRK) { - iGapChars++; - } - if (!bFind || !bAllChars) { - dwCharType = tc.GetCharType(); - if (dwCharType == FX_CHARTYPE_Space || - dwCharType == FX_CHARTYPE_Control) { - if (!bFind) { - iCharWidth = tc.m_iCharWidth; - if (bAllChars && iCharWidth > 0) { - iNetWidth -= iCharWidth; - } - } - } else { - bFind = TRUE; - if (!bAllChars) { - break; - } - } - } - j += bArabic ? 1 : -1; - } - if (!bAllChars && bFind) { - break; - } - } - int32_t iOffset = m_iBoundaryEnd - iNetWidth; - int32_t iLowerAlignment = (m_iAlignment & FX_RTFLINEALIGNMENT_LowerMask); - int32_t iHigherAlignment = (m_iAlignment & FX_RTFLINEALIGNMENT_HigherMask); - if (iGapChars > 0 && (iHigherAlignment == FX_RTFLINEALIGNMENT_Distributed || - (iHigherAlignment == FX_RTFLINEALIGNMENT_Justified && - dwStatus != FX_RTFBREAK_ParagraphBreak))) { - int32_t iStart = -1; - for (i = 0; i < iCount; i++) { - tpo = tpos.GetAt(i); - CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); - if (iStart < 0) { - iStart = ttp.m_iStartPos; - } else { - ttp.m_iStartPos = iStart; - } - int32_t k; - for (j = 0; j < ttp.m_iChars; j++) { - CFX_RTFChar& tc = ttp.GetChar(j); - if (tc.m_nBreakType != FX_LBT_DIRECT_BRK || tc.m_iCharWidth < 0) { - continue; - } - k = iOffset / iGapChars; - tc.m_iCharWidth += k; - ttp.m_iWidth += k; - iOffset -= k; - iGapChars--; - if (iGapChars < 1) { - break; - } - } - iStart += ttp.m_iWidth; - } - } else if (iLowerAlignment > FX_RTFLINEALIGNMENT_Left) { - if (iLowerAlignment == FX_RTFLINEALIGNMENT_Center) { - iOffset /= 2; - } - if (iOffset > 0) { - for (i = 0; i < iCount; i++) { - CFX_RTFPiece& ttp = pCurPieces->GetAt(i); - ttp.m_iStartPos += iOffset; - } - } - } -} -int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, - int32_t& iEndPos, - FX_BOOL bAllChars, - FX_BOOL bOnlyBrk) { - int32_t iLength = tca.GetSize() - 1; - if (iLength < 1) { - return iLength; - } - int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, - iLast = -1, iLastPos = -1; - if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) { - if (!bAllChars || m_bCharCode) { - return iLength; - } - iBreak = iLength; - iBreakPos = iEndPos; - } - CFX_RTFChar* pCharArray = tca.GetData(); - if (m_bCharCode) { - const CFX_RTFChar* pChar; - int32_t iCharWidth; - while (iLength > 0) { - if (iEndPos <= m_iBoundaryEnd) { - break; - } - pChar = pCharArray + iLength--; - iCharWidth = pChar->m_iCharWidth; - if (iCharWidth > 0) { - iEndPos -= iCharWidth; - } - } - return iLength; - } - FX_BOOL bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0; - FX_BOOL bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0; - FX_BOOL bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0; - FX_BOOL bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0; - FX_LINEBREAKTYPE eType; - FX_DWORD nCodeProp, nCur, nNext; - CFX_RTFChar* pCur = pCharArray + iLength--; - if (bAllChars) { - pCur->m_nBreakType = FX_LBT_UNKNOWN; - } - nCodeProp = pCur->m_dwCharProps; - nNext = nCodeProp & 0x003F; - int32_t iCharWidth = pCur->m_iCharWidth; - if (iCharWidth > 0) { - iEndPos -= iCharWidth; - } - while (iLength >= 0) { - pCur = pCharArray + iLength; - nCodeProp = pCur->m_dwCharProps; - nCur = nCodeProp & 0x003F; - FX_BOOL bNeedBreak = FALSE; - if (nCur == FX_CBP_SP) { - bNeedBreak = !bSpaceBreak; - if (nNext == FX_CBP_SP) { - eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); - } - } else if (nCur == FX_CBP_TB) { - bNeedBreak = !bTabBreak; - if (nNext == FX_CBP_TB) { - eType = bTabBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); - } - } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { - eType = FX_LBT_DIRECT_BRK; - } else if (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS) { - eType = FX_LBT_DIRECT_BRK; - } else { - if (nNext == FX_CBP_SP) { - eType = FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); - } - } - if (bAllChars) { - pCur->m_nBreakType = eType; - } - if (!bOnlyBrk) { - iCharWidth = pCur->m_iCharWidth; - FX_BOOL bBreak = FALSE; - if (nCur == FX_CBP_TB && bTabBreak) { - bBreak = iCharWidth > 0 && iEndPos - iCharWidth <= m_iBoundaryEnd; - } else { - bBreak = iEndPos <= m_iBoundaryEnd; - } - if (m_bSingleLine || m_bOrphanLine || bBreak || bNeedBreak) { - if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) { - iBreak = iLength; - iBreakPos = iEndPos; - if (!bAllChars) { - return iLength; - } - } else if (eType == FX_LBT_INDIRECT_BRK && iIndirect < 0) { - iIndirect = iLength; - iIndirectPos = iEndPos; - } - if (iLast < 0) { - iLast = iLength; - iLastPos = iEndPos; - } - } - if (iCharWidth > 0) { - iEndPos -= iCharWidth; - } - } - nNext = nCodeProp & 0x003F; - iLength--; - } - if (bOnlyBrk) { - return 0; - } - if (iBreak > -1) { - iEndPos = iBreakPos; - return iBreak; - } - if (iIndirect > -1) { - iEndPos = iIndirectPos; - return iIndirect; - } - if (iLast > -1) { - iEndPos = iLastPos; - return iLast; - } - return 0; -} -void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, - CFX_RTFLine* pNextLine, - FX_BOOL bAllChars) { - FXSYS_assert(pCurLine != NULL && pNextLine != NULL); - int32_t iCount = pCurLine->CountChars(); - if (iCount < 2) { - return; - } - int32_t iEndPos = pCurLine->GetLineEnd(); - CFX_RTFCharArray& curChars = pCurLine->m_LineChars; - int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); - if (iCharPos < 0) { - iCharPos = 0; - } - iCharPos++; - if (iCharPos >= iCount) { - pNextLine->RemoveAll(TRUE); - CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); - pTC->m_nBreakType = FX_LBT_UNKNOWN; - return; - } - CFX_RTFCharArray& nextChars = pNextLine->m_LineChars; - int cur_size = curChars.GetSize(); - nextChars.SetSize(cur_size - iCharPos); - FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), - (cur_size - iCharPos) * sizeof(CFX_RTFChar)); - iCount -= iCharPos; - cur_size = curChars.GetSize(); - curChars.RemoveAt(cur_size - iCount, iCount); - pNextLine->m_iStart = pCurLine->m_iStart; - pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos; - pCurLine->m_iWidth = iEndPos; - CFX_RTFChar* tc = curChars.GetDataPtr(iCharPos - 1); - tc->m_nBreakType = FX_LBT_UNKNOWN; - iCount = nextChars.GetSize(); - CFX_RTFChar* pNextChars = nextChars.GetData(); - for (int32_t i = 0; i < iCount; i++) { - CFX_RTFChar* tc = pNextChars + i; - if (tc->GetCharType() >= FX_CHARTYPE_ArabicAlef) { - pCurLine->m_iArabicChars--; - pNextLine->m_iArabicChars++; - } - if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { - pCurLine->m_iMBCSChars--; - pNextLine->m_iMBCSChars++; - } - tc->m_dwStatus = 0; - } -} -int32_t CFX_RTFBreak::CountBreakPieces() const { - CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); - if (pRTFPieces == NULL) { - return 0; - } - return pRTFPieces->GetSize(); -} -const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { - CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); - if (pRTFPieces == NULL) { - return NULL; - } - if (index < 0 || index >= pRTFPieces->GetSize()) { - return NULL; - } - return pRTFPieces->GetPtrAt(index); -} -void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { - rect.top = 0; - CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); - if (pRTFLine == NULL) { - rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; - rect.width = rect.height = 0; - return; - } - rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; - rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; - CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; - int32_t iCount = rtfPieces.GetSize(); - if (iCount < 1) { - rect.width = 0; - return; - } - CFX_RTFPiece* pBreakPiece; - int32_t iLineHeight = 0, iMax; - for (int32_t i = 0; i < iCount; i++) { - pBreakPiece = rtfPieces.GetPtrAt(i); - int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * - pBreakPiece->m_iVerticalScale / 100.0f); - iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); - if (i == 0) { - iLineHeight = iMax; - } else if (iLineHeight < iMax) { - iLineHeight = iMax; - } - } - rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; -} -void CFX_RTFBreak::ClearBreakPieces() { - CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); - if (pRTFLine != NULL) { - pRTFLine->RemoveAll(TRUE); - } - m_iReady = 0; -} -void CFX_RTFBreak::Reset() { - m_dwCharType = 0; - m_RTFLine1.RemoveAll(TRUE); - m_RTFLine2.RemoveAll(TRUE); -} -int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode, - CFX_WideString* pWSForms, - FX_AdjustCharDisplayPos pAdjustPos) const { - if (pText == NULL || pText->iLength < 1) { - return 0; - } - FXSYS_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; - IFX_Font* pFont = pText->pFont; - FX_DWORD dwStyles = pText->dwLayoutStyles; - CFX_RectF rtText(*pText->pRect); - FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); - FX_FLOAT fFontSize = pText->fFontSize; - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - int32_t iAscent = pFont->GetAscent(); - int32_t iDescent = pFont->GetDescent(); - int32_t iMaxHeight = iAscent - iDescent; - FX_FLOAT fFontHeight = fFontSize; - FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; - FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; - FX_BOOL bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; - FX_BOOL bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; - FX_BOOL bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0; - FX_BOOL bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; - int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation; - int32_t iCharRotation; - FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm; - int32_t iWidth, iCharWidth, iCharHeight; - FX_FLOAT fX, fY, fCharWidth, fCharHeight; - int32_t iHorScale = pText->iHorizontalScale; - int32_t iVerScale = pText->iVerticalScale; - FX_BOOL bEmptyChar; - FX_DWORD dwProps, dwCharType; - fX = rtText.left; - fY = rtText.top; - if (bVerticalDoc) { - fX += (rtText.width - fFontSize) / 2.0f; - if (bRTLPiece) { - fY = rtText.bottom(); - } - } else { - if (bRTLPiece) { - fX = rtText.right(); - } - fY += fAscent; - } - int32_t iCount = 0; - for (int32_t i = 0; i <= iLength; i++) { - wch = *pStr++; - iWidth = *pWidths++; - if (!bMBCSCode) { - dwProps = FX_GetUnicodeProperties(wch); - dwCharType = (dwProps & FX_CHARTYPEBITSMASK); - if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) { - wPrev = 0xFEFF; - continue; - } - } else { - dwProps = 0; - dwCharType = 0; - } - if (iWidth != 0) { - iCharWidth = iWidth; - if (iCharWidth < 0) { - iCharWidth = -iCharWidth; - } - if (!bMBCSCode) { - bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && - dwCharType <= FX_CHARTYPE_Control); - } else { - bEmptyChar = FALSE; - } - if (!bEmptyChar) { - iCount++; - } - if (pCharPos != NULL) { - iCharWidth /= iFontSize; - wForm = wch; - if (!bMBCSCode) { - if (dwCharType >= FX_CHARTYPE_ArabicAlef) { - if (i < iLength) { - wNext = *pStr; - if (*pWidths < 0) { - if (i + 1 < iLength) { - wNext = pStr[1]; - } - } - } else { - wNext = 0xFEFF; - } - wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext); - } else if (bRTLPiece || bVerticalChar) { - wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar); - } else if (dwCharType == FX_CHARTYPE_Numeric && bArabicNumber) { - wForm = wch + 0x0630; - } - dwProps = FX_GetUnicodeProperties(wForm); - } - iCharRotation = iRotation; - if (!bMBCSCode && bVerticalChar && (dwProps & 0x8000) != 0) { - iCharRotation++; - iCharRotation %= 4; - } - if (!bEmptyChar) { - if (bCharCode) { - pCharPos->m_GlyphIndex = wch; - } else { - pCharPos->m_GlyphIndex = pFont->GetGlyphIndex(wForm, bMBCSCode); - if (pCharPos->m_GlyphIndex == 0xFFFF) { - pCharPos->m_GlyphIndex = pFont->GetGlyphIndex(wch, bMBCSCode); - } - } - pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; - pCharPos->m_FontCharWidth = iCharWidth; - if (pWSForms) { - *pWSForms += wForm; - } - } - if (bVerticalDoc) { - iCharHeight = iCharWidth; - iCharWidth = 1000; - } else { - iCharHeight = 1000; - } - fCharWidth = fFontSize * iCharWidth / 1000.0f; - fCharHeight = fFontSize * iCharHeight / 1000.0f; - if (!bMBCSCode && bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { - if (bVerticalDoc) { - fY -= fCharHeight; - } else { - fX -= fCharWidth; - } - } - if (!bEmptyChar) { - CFX_PointF ptOffset; - FX_BOOL bAdjusted = FALSE; - if (pAdjustPos) { - bAdjusted = pAdjustPos(wForm, bMBCSCode, pFont, fFontSize, - bVerticalChar, ptOffset); - } - if (!pAdjustPos && bVerticalChar && (dwProps & 0x00010000) != 0) { - CFX_Rect rtBBox; - rtBBox.Reset(); - if (pFont->GetCharBBox(wForm, rtBBox, bMBCSCode)) { - ptOffset.x = fFontSize * (850 - rtBBox.right()) / 1000.0f; - ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; - } - } - pCharPos->m_OriginX = fX + ptOffset.x; - pCharPos->m_OriginY = fY - ptOffset.y; - } - if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { - if (bVerticalDoc) { - fY += fCharHeight; - } else { - fX += fCharWidth; - } - } - if (!bEmptyChar) { - pCharPos->m_bGlyphAdjust = TRUE; - if (bVerticalDoc) { - if (iCharRotation == 0) { - pCharPos->m_AdjustMatrix[0] = -1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent * iVerScale / 100.0f; - } else if (iCharRotation == 1) { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = -1; - pCharPos->m_AdjustMatrix[2] = -1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= - fDescent + fAscent * iVerScale / 100.0f - fAscent; - } else if (iCharRotation == 2) { - pCharPos->m_AdjustMatrix[0] = 1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY += fAscent; - } else { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = 1; - pCharPos->m_AdjustMatrix[2] = 1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; - pCharPos->m_OriginY += fCharWidth; - } - } else { - if (iCharRotation == 0) { - pCharPos->m_AdjustMatrix[0] = -1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent * iVerScale / 100.0f - fAscent; - } else if (iCharRotation == 1) { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = -1; - pCharPos->m_AdjustMatrix[2] = -1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; - pCharPos->m_OriginY -= fAscent + fDescent; - } else if (iCharRotation == 2) { - pCharPos->m_AdjustMatrix[0] = 1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY -= fAscent; - } else { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = 1; - pCharPos->m_AdjustMatrix[2] = 1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent * iVerScale / 100.0f; - } - } - if (iHorScale != 100 || iVerScale != 100) { - pCharPos->m_AdjustMatrix[0] = - pCharPos->m_AdjustMatrix[0] * iHorScale / 100.0f; - pCharPos->m_AdjustMatrix[1] = - pCharPos->m_AdjustMatrix[1] * iHorScale / 100.0f; - pCharPos->m_AdjustMatrix[2] = - pCharPos->m_AdjustMatrix[2] * iVerScale / 100.0f; - pCharPos->m_AdjustMatrix[3] = - pCharPos->m_AdjustMatrix[3] * iVerScale / 100.0f; - } - pCharPos++; - } - } - } - if (iWidth > 0) { - wPrev = wch; - } - } - return iCount; -} -int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, - CFX_RectFArray& rtArray, - FX_BOOL bCharBBox) const { - if (pText == NULL || pText->iLength < 1) { - return 0; - } - FXSYS_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; - CFX_RectF rect(*pText->pRect); - FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); - FX_FLOAT fFontSize = pText->fFontSize; - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - FX_FLOAT fScale = fFontSize / 1000.0f; - IFX_Font* pFont = pText->pFont; - if (pFont == NULL) { - bCharBBox = FALSE; - } - CFX_Rect bbox; - bbox.Set(0, 0, 0, 0); - if (bCharBBox) { - bCharBBox = pFont->GetBBox(bbox); - } - FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); - FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); - rtArray.RemoveAll(); - rtArray.SetSize(iLength); - FX_DWORD dwStyles = pText->dwLayoutStyles; - FX_BOOL bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; - FX_BOOL bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; - FX_BOOL bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; - FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar; - int32_t iCharSize; - FX_FLOAT fCharSize, fStart; - if (bVertical) { - fStart = bRTLPiece ? rect.bottom() : rect.top; - } else { - fStart = bRTLPiece ? rect.right() : rect.left; - } - for (int32_t i = 0; i < iLength; i++) { - wch = *pStr++; - iCharSize = *pWidths++; - fCharSize = (FX_FLOAT)iCharSize / 20000.0f; - FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); - if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || - (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { - bRet = FALSE; - } - if (bRet) { - iCharSize = iFontSize * 500; - fCharSize = fFontSize / 2.0f; - } - if (bVertical) { - rect.top = fStart; - if (bRTLPiece) { - rect.top -= fCharSize; - fStart -= fCharSize; - } else { - fStart += fCharSize; - } - rect.height = fCharSize; - } else { - rect.left = fStart; - if (bRTLPiece) { - rect.left -= fCharSize; - fStart -= fCharSize; - } else { - fStart += fCharSize; - } - rect.width = fCharSize; - } - if (bCharBBox && !bRet) { - int32_t iCharWidth = 1000; - pFont->GetCharWidth(wch, iCharWidth); - FX_FLOAT fRTLeft = 0, fCharWidth = 0; - if (iCharWidth > 0) { - fCharWidth = iCharWidth * fScale; - fRTLeft = fLeft; - if (bCombText) { - fRTLeft = (rect.width - fCharWidth) / 2.0f; - } - } - CFX_RectF rtBBoxF; - if (bVertical) { - rtBBoxF.top = rect.left + fRTLeft; - rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; - rtBBoxF.height = fCharWidth; - rtBBoxF.width = fHeight; - rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); - } else { - rtBBoxF.left = rect.left + fRTLeft; - rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; - rtBBoxF.width = fCharWidth; - rtBBoxF.height = fHeight; - rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); - } - rtArray.SetAt(i, rtBBoxF); - continue; - } - rtArray.SetAt(i, rect); - } - return iLength; -} diff --git a/xfa/src/fgas/layout/fgas_rtfbreak.h b/xfa/src/fgas/layout/fgas_rtfbreak.h deleted file mode 100644 index 24cf2e32cb..0000000000 --- a/xfa/src/fgas/layout/fgas_rtfbreak.h +++ /dev/null @@ -1,237 +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_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ -#define XFA_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ - -#include "core/include/fxcrt/fx_ucd.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fgas/crt/fgas_memory.h" -#include "xfa/src/fgas/crt/fgas_utils.h" -#include "xfa/src/fgas/layout/fgas_textbreak.h" -#include "xfa/src/fgas/layout/fgas_unicode.h" - -class IFX_Unknown; -class IFX_Font; - -#define FX_RTFBREAKPOLICY_None 0x00 -#define FX_RTFBREAKPOLICY_SpaceBreak 0x01 -#define FX_RTFBREAKPOLICY_NumberBreak 0x02 -#define FX_RTFBREAKPOLICY_InfixBreak 0x04 -#define FX_RTFBREAKPOLICY_TabBreak 0x08 -#define FX_RTFBREAKPOLICY_OrphanPositionedTab 0x10 -#define FX_RTFBREAK_None 0x00 -#define FX_RTFBREAK_PieceBreak 0x01 -#define FX_RTFBREAK_LineBreak 0x02 -#define FX_RTFBREAK_ParagraphBreak 0x03 -#define FX_RTFBREAK_PageBreak 0x04 -#define FX_RTFLAYOUTSTYLE_Pagination 0x01 -#define FX_RTFLAYOUTSTYLE_VerticalLayout 0x02 -#define FX_RTFLAYOUTSTYLE_VerticalChars 0x04 -#define FX_RTFLAYOUTSTYLE_LineDirection 0x08 -#define FX_RTFLAYOUTSTYLE_ExpandTab 0x10 -#define FX_RTFLAYOUTSTYLE_ArabicNumber 0x20 -#define FX_RTFLAYOUTSTYLE_SingleLine 0x40 -#define FX_RTFLAYOUTSTYLE_MBCSCode 0x80 -#define FX_RTFCHARSTYLE_Alignment 0x000F -#define FX_RTFCHARSTYLE_ArabicNumber 0x0010 -#define FX_RTFCHARSTYLE_ArabicShadda 0x0020 -#define FX_RTFCHARSTYLE_OddBidiLevel 0x0040 -#define FX_RTFCHARSTYLE_RTLReadingOrder 0x0080 -#define FX_RTFCHARSTYLE_ArabicContext 0x0300 -#define FX_RTFCHARSTYLE_ArabicIndic 0x0400 -#define FX_RTFCHARSTYLE_ArabicComma 0x0800 -#define FX_RTFLINEALIGNMENT_Left 0 -#define FX_RTFLINEALIGNMENT_Center 1 -#define FX_RTFLINEALIGNMENT_Right 2 -#define FX_RTFLINEALIGNMENT_Justified (1 << 2) -#define FX_RTFLINEALIGNMENT_Distributed (2 << 2) -#define FX_RTFLINEALIGNMENT_JustifiedLeft \ - (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Justified) -#define FX_RTFLINEALIGNMENT_JustifiedCenter \ - (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Justified) -#define FX_RTFLINEALIGNMENT_JustifiedRight \ - (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Justified) -#define FX_RTFLINEALIGNMENT_DistributedLeft \ - (FX_RTFLINEALIGNMENT_Left | FX_RTFLINEALIGNMENT_Distributed) -#define FX_RTFLINEALIGNMENT_DistributedCenter \ - (FX_RTFLINEALIGNMENT_Center | FX_RTFLINEALIGNMENT_Distributed) -#define FX_RTFLINEALIGNMENT_DistributedRight \ - (FX_RTFLINEALIGNMENT_Right | FX_RTFLINEALIGNMENT_Distributed) -#define FX_RTFLINEALIGNMENT_LowerMask 0x03 -#define FX_RTFLINEALIGNMENT_HigherMask 0x0C - -struct FX_RTFTEXTOBJ { - FX_RTFTEXTOBJ() { - pStr = NULL; - pWidths = NULL; - iLength = 0; - pFont = NULL; - fFontSize = 12.0f; - dwLayoutStyles = 0; - iCharRotation = 0; - iBidiLevel = 0; - pRect = NULL; - wLineBreakChar = L'\n'; - iHorizontalScale = 100; - iVerticalScale = 100; - } - - const FX_WCHAR* pStr; - int32_t* pWidths; - int32_t iLength; - IFX_Font* pFont; - FX_FLOAT fFontSize; - FX_DWORD dwLayoutStyles; - int32_t iCharRotation; - int32_t iBidiLevel; - const CFX_RectF* pRect; - FX_WCHAR wLineBreakChar; - int32_t iHorizontalScale; - int32_t iVerticalScale; -}; - -class CFX_RTFPiece : public CFX_Target { - public: - CFX_RTFPiece() - : m_dwStatus(FX_RTFBREAK_PieceBreak), - m_iStartPos(0), - m_iWidth(-1), - m_iStartChar(0), - m_iChars(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_iFontSize(0), - m_iFontHeight(0), - m_iHorizontalScale(100), - m_iVerticalScale(100), - m_dwLayoutStyles(0), - m_dwIdentity(0), - m_pChars(NULL), - m_pUserData(NULL) {} - ~CFX_RTFPiece() { Reset(); } - void AppendChar(const CFX_RTFChar& tc) { - FXSYS_assert(m_pChars != NULL); - m_pChars->Add(tc); - if (m_iWidth < 0) { - m_iWidth = tc.m_iCharWidth; - } else { - m_iWidth += tc.m_iCharWidth; - } - m_iChars++; - } - int32_t GetEndPos() const { - return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; - } - 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); - return *m_pChars->GetDataPtr(m_iStartChar + index); - } - CFX_RTFChar* GetCharPtr(int32_t index) const { - FXSYS_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); - int32_t iEndChar = m_iStartChar + m_iChars; - CFX_RTFChar* pChar; - for (int32_t i = m_iStartChar; i < iEndChar; i++) { - pChar = m_pChars->GetDataPtr(i); - *pText++ = (FX_WCHAR)pChar->m_wCharCode; - } - } - void GetString(CFX_WideString& wsText) const { - FX_WCHAR* pText = wsText.GetBuffer(m_iChars); - GetString(pText); - wsText.ReleaseBuffer(m_iChars); - } - void GetWidths(int32_t* pWidths) const { - FXSYS_assert(pWidths != NULL); - int32_t iEndChar = m_iStartChar + m_iChars; - CFX_RTFChar* pChar; - for (int32_t i = m_iStartChar; i < iEndChar; i++) { - pChar = m_pChars->GetDataPtr(i); - *pWidths++ = pChar->m_iCharWidth; - } - } - void Reset() { - m_dwStatus = FX_RTFBREAK_PieceBreak; - if (m_iWidth > -1) { - m_iStartPos += m_iWidth; - } - m_iWidth = -1; - m_iStartChar += m_iChars; - m_iChars = 0; - m_iBidiLevel = 0; - m_iBidiPos = 0; - m_iHorizontalScale = 100; - m_iVerticalScale = 100; - } - FX_DWORD m_dwStatus; - int32_t m_iStartPos; - int32_t m_iWidth; - int32_t m_iStartChar; - int32_t m_iChars; - int32_t m_iBidiLevel; - int32_t m_iBidiPos; - int32_t m_iFontSize; - int32_t m_iFontHeight; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; - FX_DWORD m_dwLayoutStyles; - FX_DWORD m_dwIdentity; - CFX_RTFCharArray* m_pChars; - IFX_Unknown* m_pUserData; -}; -typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray; - -class IFX_RTFBreak { - public: - static IFX_RTFBreak* Create(FX_DWORD 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 FX_DWORD GetLayoutStyles() const = 0; - virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD AppendChar(FX_WCHAR wch) = 0; - virtual FX_DWORD EndBreak(FX_DWORD 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; -}; - -#endif // XFA_SRC_FGAS_LAYOUT_FGAS_RTFBREAK_H_ diff --git a/xfa/src/fgas/layout/fgas_textbreak.cpp b/xfa/src/fgas/layout/fgas_textbreak.cpp deleted file mode 100644 index af7be50a51..0000000000 --- a/xfa/src/fgas/layout/fgas_textbreak.cpp +++ /dev/null @@ -1,1824 +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/src/fgas/layout/fgas_textbreak.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_arb.h" -#include "core/include/fxcrt/fx_memory.h" -#include "xfa/src/fgas/layout/fgas_linebreak.h" -#include "xfa/src/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(FX_DWORD dwPolicies); - ~CFX_TxtBreak(); - virtual void Release() { delete this; } - virtual void SetLineWidth(FX_FLOAT fLineWidth); - virtual void SetLinePos(FX_FLOAT fLinePos); - virtual FX_DWORD GetLayoutStyles() const { return m_dwLayoutStyles; } - virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD GetContextCharStyles() const; - virtual void SetContextCharStyles(FX_DWORD dwCharStyles); - virtual void SetCombWidth(FX_FLOAT fCombWidth); - virtual void SetUserData(void* pUserData); - virtual FX_DWORD AppendChar(FX_WCHAR wch); - virtual FX_DWORD EndBreak(FX_DWORD 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, FX_DWORD dwProps); - FX_DWORD AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation); - FX_DWORD AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation); - - protected: - FX_DWORD m_dwPolicies; - FX_BOOL m_bPagination; - IFX_ArabicChar* m_pArabicChar; - int32_t m_iLineWidth; - FX_DWORD 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; - FX_DWORD m_dwContextCharStyles; - int32_t m_iCombWidth; - void* m_pUserData; - FX_DWORD 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(FX_DWORD 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; - FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; - void ResetArabicContext(); - void ResetContextCharStyles(); - void EndBreak_UpdateArabicShapes(); - FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine, - FX_BOOL bAllChars, - FX_DWORD dwStatus); - void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); - void EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD 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(FX_DWORD dwPolicies) { - return new CFX_TxtBreak(dwPolicies); -} -CFX_TxtBreak::CFX_TxtBreak(FX_DWORD dwPolicies) - : m_dwPolicies(dwPolicies), - m_pArabicChar(NULL), - m_iLineWidth(2000000), - m_dwLayoutStyles(0), - m_bVertical(FALSE), - m_bArabicContext(FALSE), - m_bArabicShapes(FALSE), - m_bRTL(FALSE), - m_bSingleLine(FALSE), - m_bCombText(FALSE), - m_iArabicContext(1), - m_iCurArabicContext(1), - m_pFont(NULL), - m_iFontSize(240), - m_bEquidistant(TRUE), - m_iTabWidth(720000), - m_wDefChar(0xFEFF), - m_wParagBreakChar(L'\n'), - m_iDefChar(0), - m_iLineRotation(0), - m_iCharRotation(0), - m_iRotation(0), - m_iAlignment(FX_TXTLINEALIGNMENT_Left), - m_dwContextCharStyles(0), - m_iCombWidth(360000), - m_pUserData(NULL), - m_dwCharType(0), - m_bArabicNumber(FALSE), - m_bArabicComma(FALSE), - m_pCurLine(NULL), - m_iReady(0), - m_iTolerance(0), - m_iHorScale(100), - 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)); - } else { - m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_TxtChar)); - m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_TxtChar)); - } - m_pCurLine = m_pTxtLine1; - ResetArabicContext(); -} -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); -} -void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) { - int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); - if (iLinePos < 0) { - iLinePos = 0; - } - if (iLinePos > m_iLineWidth) { - iLinePos = m_iLineWidth; - } - m_pCurLine->m_iStart = iLinePos; - m_pCurLine->m_iWidth += iLinePos; -} -void CFX_TxtBreak::SetLayoutStyles(FX_DWORD dwLayoutStyles) { - m_dwLayoutStyles = dwLayoutStyles; - m_bVertical = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0; - m_bArabicContext = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicContext) != 0; - m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; - m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; - m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; - m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; - ResetArabicContext(); - m_iLineRotation = GetLineRotation(m_dwLayoutStyles); - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; -} -void CFX_TxtBreak::SetFont(IFX_Font* pFont) { - if (pFont == NULL) { - return; - } - if (m_pFont == pFont) { - return; - } - SetBreakStatus(); - m_pFont = pFont; - m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - m_iDefChar *= m_iFontSize; - } -} -void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - if (m_iFontSize == iFontSize) { - return; - } - SetBreakStatus(); - m_iFontSize = iFontSize; - m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - m_iDefChar *= m_iFontSize; - } -} -void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { - m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); - if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { - m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; - } - m_bEquidistant = bEquidistant; -} -void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { - m_wDefChar = wch; - m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { - m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); - if (m_iDefChar < 0) { - m_iDefChar = 0; - } else { - m_iDefChar *= m_iFontSize; - } - } -} -void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { - if (wch != L'\r' && wch != L'\n') { - return; - } - m_wParagBreakChar = wch; -} -void CFX_TxtBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) { - m_iTolerance = FXSYS_round(fTolerance * 20000.0f); -} -void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) { - if (iCharRotation < 0) { - iCharRotation += (-iCharRotation / 4 + 1) * 4; - } else if (iCharRotation > 3) { - iCharRotation -= (iCharRotation / 4) * 4; - } - if (m_iCharRotation == iCharRotation) { - return; - } - SetBreakStatus(); - m_iCharRotation = iCharRotation; - m_iRotation = m_iLineRotation + m_iCharRotation; - m_iRotation %= 4; -} -void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { - FXSYS_assert(iAlignment >= FX_TXTLINEALIGNMENT_Left && - iAlignment <= FX_TXTLINEALIGNMENT_Distributed); - m_iAlignment = iAlignment; - ResetArabicContext(); -} -void CFX_TxtBreak::ResetContextCharStyles() { - m_dwContextCharStyles = m_bArabicContext ? m_iCurAlignment : m_iAlignment; - if (m_bArabicNumber) { - m_dwContextCharStyles |= FX_TXTCHARSTYLE_ArabicNumber; - } - if (m_bArabicComma) { - m_dwContextCharStyles |= FX_TXTCHARSTYLE_ArabicComma; - } - if ((m_bArabicContext && m_bCurRTL) || (!m_bArabicContext && m_bRTL)) { - m_dwContextCharStyles |= FX_TXTCHARSTYLE_RTLReadingOrder; - } - m_dwContextCharStyles |= (m_iArabicContext << 8); -} -FX_DWORD CFX_TxtBreak::GetContextCharStyles() const { - return m_dwContextCharStyles; -} -void CFX_TxtBreak::SetContextCharStyles(FX_DWORD dwCharStyles) { - m_iCurAlignment = dwCharStyles & 0x0F; - m_bArabicNumber = (dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; - m_bArabicComma = (dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; - m_bCurRTL = (dwCharStyles & FX_TXTCHARSTYLE_RTLReadingOrder) != 0; - m_iCurArabicContext = m_iArabicContext = ((dwCharStyles & 0x0300) >> 8); - ResetContextCharStyles(); -} -void CFX_TxtBreak::SetCombWidth(FX_FLOAT fCombWidth) { - m_iCombWidth = FXSYS_round(fCombWidth * 20000.0f); -} -void CFX_TxtBreak::SetUserData(void* pUserData) { - if (m_pUserData == pUserData) { - return; - } - SetBreakStatus(); - m_pUserData = pUserData; -} -void CFX_TxtBreak::SetBreakStatus() { - if (m_bPagination) { - return; - } - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 1) { - return; - } - CFX_TxtChar* pTC = (CFX_TxtChar*)m_pCurLine->GetCharPtr(iCount - 1); - if (pTC->m_dwStatus == 0) { - pTC->m_dwStatus = FX_TXTBREAK_PieceBreak; - } -} -void CFX_TxtBreak::SetHorizontalScale(int32_t iScale) { - if (iScale < 0) { - iScale = 0; - } - if (iScale == m_iHorScale) { - return; - } - SetBreakStatus(); - m_iHorScale = iScale; -} -void CFX_TxtBreak::SetVerticalScale(int32_t iScale) { - if (iScale < 0) { - iScale = 0; - } - if (iScale == m_iHorScale) { - return; - } - SetBreakStatus(); - m_iVerScale = iScale; -} -void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { - m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); -} -static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; -int32_t CFX_TxtBreak::GetLineRotation(FX_DWORD dwStyles) const { - return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; -} -CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { - CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; - int32_t iCount = ca.GetSize(); - if (index < 0 || index >= iCount) { - return NULL; - } - CFX_TxtChar* pTC; - int32_t iStart = iCount - 1; - while (iStart > -1) { - pTC = ca.GetDataPtr(iStart--); - if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { - continue; - } - if (--index < 0) { - return pTC; - } - } - return NULL; -} -CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { - if (!bReady) { - return m_pCurLine; - } - if (m_iReady == 1) { - return m_pTxtLine1; - } else if (m_iReady == 2) { - return m_pTxtLine2; - } else { - return NULL; - } -} -CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { - CFX_TxtLine* pTxtLine = GetTxtLine(bReady); - if (pTxtLine == NULL) { - return NULL; - } - return pTxtLine->m_pLinePieces; -} -inline FX_DWORD CFX_TxtBreak::GetUnifiedCharType(FX_DWORD dwType) const { - return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; -} -void CFX_TxtBreak::ResetArabicContext() { - if (m_bArabicContext) { - m_bCurRTL = m_iCurArabicContext > 1; - m_iCurAlignment = m_iCurArabicContext > 1 ? FX_TXTLINEALIGNMENT_Right - : FX_TXTLINEALIGNMENT_Left; - m_iCurAlignment |= (m_iAlignment & FX_TXTLINEALIGNMENT_HigherMask); - m_bArabicNumber = m_iArabicContext >= 1 && m_bArabicShapes; - } else { - if (m_bPagination) { - m_bCurRTL = FALSE; - m_iCurAlignment = 0; - } else { - m_bCurRTL = m_bRTL; - m_iCurAlignment = m_iAlignment; - } - if (m_bRTL) { - m_bArabicNumber = m_iArabicContext >= 1; - } else { - m_bArabicNumber = m_iArabicContext > 1; - } - m_bArabicNumber = m_bArabicNumber && m_bArabicShapes; - } - m_bArabicComma = m_bArabicNumber; - ResetContextCharStyles(); -} -void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, FX_DWORD dwProps) { - if (!m_bPagination) { - ((CFX_TxtChar*)pCurChar)->m_dwStatus = 0; - ((CFX_TxtChar*)pCurChar)->m_pUserData = m_pUserData; - } - if (m_bArabicContext || m_bArabicShapes) { - int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; - int32_t iArabicContext = - (iBidiCls == FX_BIDICLASS_R || iBidiCls == FX_BIDICLASS_AL) - ? 2 - : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 - : 1); - if (iArabicContext != m_iArabicContext && iArabicContext != 1) { - m_iArabicContext = iArabicContext; - if (m_iCurArabicContext == 1) { - m_iCurArabicContext = iArabicContext; - } - ResetArabicContext(); - if (!m_bPagination) { - CFX_TxtChar* pLastChar = (CFX_TxtChar*)GetLastChar(1, FALSE); - if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { - pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; - } - } - } - } - pCurChar->m_dwCharStyles = m_dwContextCharStyles; -} -FX_DWORD CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar, - int32_t iRotation) { - FXSYS_assert(pCurChar != NULL); - FX_WCHAR wch = pCurChar->m_wCharCode; - FX_WCHAR wForm; - int32_t iCharWidth = 0; - CFX_Char* pLastChar; - pCurChar->m_iCharWidth = -1; - if (m_bCombText) { - iCharWidth = m_iCombWidth; - } else { - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else { - wForm = wch; - if (!m_bPagination) { - pLastChar = GetLastChar(0, FALSE); - if (pLastChar != NULL && - (((CFX_TxtChar*)pLastChar)->m_dwCharStyles & - FX_TXTCHARSTYLE_ArabicShadda) == 0) { - FX_BOOL bShadda = FALSE; - if (wch == 0x0651) { - FX_WCHAR wLast = pLastChar->m_wCharCode; - if (wLast >= 0x064C && wLast <= 0x0650) { - wForm = FX_GetArabicFromShaddaTable(wLast); - bShadda = TRUE; - } - } else if (wch >= 0x064C && wch <= 0x0650) { - if (pLastChar->m_wCharCode == 0x0651) { - wForm = FX_GetArabicFromShaddaTable(wch); - bShadda = TRUE; - } - } - if (bShadda) { - ((CFX_TxtChar*)pLastChar)->m_dwCharStyles |= - FX_TXTCHARSTYLE_ArabicShadda; - ((CFX_TxtChar*)pLastChar)->m_iCharWidth = 0; - ((CFX_TxtChar*)pCurChar)->m_dwCharStyles |= - FX_TXTCHARSTYLE_ArabicShadda; - } - } - } - if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { - iCharWidth = 0; - } - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorScale / 100; - } - pCurChar->m_iCharWidth = -iCharWidth; - return FX_TXTBREAK_None; -} -FX_DWORD CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation) { - m_dwCharType = FX_CHARTYPE_Tab; - if ((m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ExpandTab) == 0) { - return FX_TXTBREAK_None; - } - int32_t& iLineWidth = m_pCurLine->m_iWidth; - int32_t iCharWidth; - if (m_bCombText) { - iCharWidth = m_iCombWidth; - } else { - if (m_bEquidistant) { - iCharWidth = iLineWidth; - iCharWidth = m_iTabWidth * (iCharWidth / m_iTabWidth + 1) - iCharWidth; - if (iCharWidth < FX_TXTBREAK_MinimumTabWidth) { - iCharWidth += m_iTabWidth; - } - } else { - iCharWidth = m_iTabWidth; - } - } - pCurChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - if (!m_bSingleLine && iLineWidth >= m_iLineWidth + m_iTolerance) { - return EndBreak(FX_TXTBREAK_LineBreak); - } - return FX_TXTBREAK_None; -} -FX_DWORD CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar, - int32_t iRotation) { - m_dwCharType = FX_CHARTYPE_Control; - FX_DWORD dwRet = FX_TXTBREAK_None; - if (!m_bSingleLine) { - FX_WCHAR wch = pCurChar->m_wCharCode; - switch (wch) { - case L'\v': - case 0x2028: - dwRet = FX_TXTBREAK_LineBreak; - break; - case L'\f': - dwRet = FX_TXTBREAK_PageBreak; - break; - case 0x2029: - dwRet = FX_TXTBREAK_ParagraphBreak; - break; - default: - if (wch == m_wParagBreakChar) { - dwRet = FX_TXTBREAK_ParagraphBreak; - } - break; - } - if (dwRet != FX_TXTBREAK_None) { - dwRet = EndBreak(dwRet); - } - } - return dwRet; -} -FX_DWORD CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar, - int32_t iRotation) { - FX_DWORD dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); - int32_t& iLineWidth = m_pCurLine->m_iWidth; - FX_WCHAR wForm; - int32_t iCharWidth = 0; - CFX_Char* pLastChar = NULL; - FX_BOOL bAlef = FALSE; - if (!m_bCombText && m_dwCharType >= FX_CHARTYPE_ArabicAlef && - m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { - pLastChar = GetLastChar(1); - if (pLastChar != NULL) { - iCharWidth = pLastChar->m_iCharWidth; - if (iCharWidth > 0) { - iLineWidth -= iCharWidth; - } - CFX_Char* pPrevChar = GetLastChar(2); - wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar); - bAlef = (wForm == 0xFEFF && - pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); - int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; - if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { - iLastRotation++; - } - if (m_bVertical != FX_IsOdd(iLastRotation)) { - iCharWidth = 1000; - } else { - m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); - } - if (wForm == 0xFEFF) { - iCharWidth = m_iDefChar; - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorScale / 100; - pLastChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - iCharWidth = 0; - } - } - m_dwCharType = dwType; - wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); - if (m_bCombText) { - iCharWidth = m_iCombWidth; - } else { - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else { - m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); - } - if (wForm == 0xFEFF) { - iCharWidth = m_iDefChar; - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorScale / 100; - } - pCurChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - m_pCurLine->m_iArabicChars++; - if (!m_bSingleLine && iLineWidth > m_iLineWidth + m_iTolerance) { - return EndBreak(FX_TXTBREAK_LineBreak); - } - return FX_TXTBREAK_None; -} -FX_DWORD CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar, - int32_t iRotation) { - FX_DWORD dwProps = pCurChar->m_dwCharProps; - FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); - int32_t& iLineWidth = m_pCurLine->m_iWidth; - int32_t iCharWidth = 0; - m_dwCharType = dwType; - FX_WCHAR wch = pCurChar->m_wCharCode; - FX_WCHAR wForm = wch; - if (dwType == FX_CHARTYPE_Numeric) { - if (m_bArabicNumber) { - wForm = wch + 0x0630; - pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicIndic; - } - } else if (wch == L',') { - if (m_bArabicShapes && m_iCurArabicContext > 0) { - wForm = 0x060C; - pCurChar->m_dwCharStyles |= FX_TXTCHARSTYLE_ArabicComma; - } - } else if (m_bCurRTL || m_bVertical) { - wForm = FX_GetMirrorChar(wch, dwProps, m_bCurRTL, m_bVertical); - } - if (m_bCombText) { - iCharWidth = m_iCombWidth; - } else { - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { - iCharWidth = m_iDefChar; - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorScale / 100; - } - iCharWidth += m_iCharSpace; - pCurChar->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || - (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0); - if (!m_bSingleLine && bBreak && iLineWidth > m_iLineWidth + m_iTolerance) { - return EndBreak(FX_TXTBREAK_LineBreak); - } - return FX_TXTBREAK_None; -} -typedef FX_DWORD (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)(CFX_Char* pCurChar, - int32_t iRotation); -static const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = { - &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab, - &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control, - &CFX_TxtBreak::AppendChar_Combination, &CFX_TxtBreak::AppendChar_Others, - &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Arabic, - &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic, - &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic, - &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Others, - &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Others, -}; -FX_DWORD CFX_TxtBreak::AppendChar(FX_WCHAR wch) { - FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; - FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); - CFX_TxtChar* pCurChar = m_pCurLine->m_pLineChars->AddSpace(); - pCurChar->m_wCharCode = (FX_WORD)wch; - pCurChar->m_nRotation = m_iCharRotation; - pCurChar->m_dwCharProps = dwProps; - pCurChar->m_dwCharStyles = 0; - pCurChar->m_iCharWidth = 0; - pCurChar->m_iHorizontalScale = m_iHorScale; - pCurChar->m_iVertialScale = m_iVerScale; - pCurChar->m_dwStatus = 0; - pCurChar->m_iBidiClass = 0; - pCurChar->m_iBidiLevel = 0; - pCurChar->m_iBidiPos = 0; - pCurChar->m_iBidiOrder = 0; - pCurChar->m_pUserData = NULL; - AppendChar_PageLoad(pCurChar, dwProps); - FX_DWORD dwRet1 = FX_TXTBREAK_None; - if (dwType != FX_CHARTYPE_Combination && - GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { - if (m_dwCharType > 0 && - m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { - if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { - dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); - int32_t iCount = m_pCurLine->CountChars(); - if (iCount > 0) { - pCurChar = m_pCurLine->m_pLineChars->GetDataPtr(iCount - 1); - } - } - } - } - int32_t iRotation = m_iRotation; - if (m_bVertical && (dwProps & 0x8000) != 0) { - iRotation = (iRotation + 1) % 4; - } - FX_DWORD dwRet2 = - (this->*g_FX_TxtBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( - pCurChar, iRotation); - return std::max(dwRet1, dwRet2); -} -void CFX_TxtBreak::EndBreak_UpdateArabicShapes() { - FXSYS_assert(m_bArabicShapes); - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 2) { - return; - } - int32_t& iLineWidth = m_pCurLine->m_iWidth; - CFX_Char *pCur, *pNext; - pCur = m_pCurLine->GetCharPtr(0); - FX_BOOL bPrevNum = (pCur->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; - pCur = m_pCurLine->GetCharPtr(1); - FX_WCHAR wch, wForm; - FX_BOOL bNextNum; - int32_t i = 1, iCharWidth, iRotation; - do { - i++; - if (i < iCount) { - pNext = m_pCurLine->GetCharPtr(i); - bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; - } else { - pNext = NULL; - bNextNum = FALSE; - } - wch = pCur->m_wCharCode; - if (wch == L'.') { - if (bPrevNum && bNextNum) { - iRotation = m_iRotation; - if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { - iRotation = ((iRotation + 1) & 0x03); - } - wForm = wch == L'.' ? 0x066B : 0x066C; - iLineWidth -= pCur->m_iCharWidth; - if (m_bCombText) { - iCharWidth = m_iCombWidth; - } else { - if (m_bVertical != FX_IsOdd(iRotation)) { - iCharWidth = 1000; - } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, FALSE)) { - iCharWidth = m_iDefChar; - } - iCharWidth *= m_iFontSize; - iCharWidth = iCharWidth * m_iHorScale / 100; - } - pCur->m_iCharWidth = iCharWidth; - iLineWidth += iCharWidth; - } - } - bPrevNum = (pCur->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; - pCur = pNext; - } while (i < iCount); -} -FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, - FX_BOOL bAllChars, - FX_DWORD dwStatus) { - int32_t iCount = m_pCurLine->CountChars(); - FX_BOOL bDone = FALSE; - CFX_Char* pTC; - if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) { - pTC = m_pCurLine->GetCharPtr(iCount - 1); - switch (pTC->GetCharType()) { - case FX_CHARTYPE_Tab: - case FX_CHARTYPE_Control: - break; - case FX_CHARTYPE_Space: - if ((m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0) { - SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); - bDone = TRUE; - } - break; - default: - SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); - bDone = TRUE; - break; - } - } - iCount = m_pCurLine->CountChars(); - CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; - CFX_TxtPiece tp; - if (m_bPagination) { - tp.m_dwStatus = dwStatus; - tp.m_iStartPos = m_pCurLine->m_iStart; - tp.m_iWidth = m_pCurLine->m_iWidth; - tp.m_iStartChar = 0; - tp.m_iChars = iCount; - tp.m_pChars = m_pCurLine->m_pLineChars; - tp.m_pUserData = m_pUserData; - pTC = m_pCurLine->GetCharPtr(0); - tp.m_dwCharStyles = pTC->m_dwCharStyles; - tp.m_iHorizontalScale = pTC->m_iHorizontalScale; - tp.m_iVerticalScale = pTC->m_iVertialScale; - pCurPieces->Add(tp); - m_pCurLine = pNextLine; - m_dwCharType = 0; - return TRUE; - } - if (bAllChars && !bDone) { - int32_t iEndPos = m_pCurLine->m_iWidth; - GetBreakPos(*m_pCurLine->m_pLineChars, iEndPos, bAllChars, TRUE); - } - return FALSE; -} -void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus) { - CFX_TxtPiece tp; - FX_TPO tpo; - CFX_TxtChar* pTC; - int32_t i, j; - CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars; - int32_t iCount = m_pCurLine->CountChars(); - FX_BOOL bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL); - if (!m_bPagination && bDone) { - int32_t iBidiNum = 0; - for (i = 0; i < iCount; i++) { - pTC = chars.GetDataPtr(i); - pTC->m_iBidiPos = i; - if (pTC->GetCharType() != FX_CHARTYPE_Control) { - iBidiNum = i; - } - if (i == 0) { - pTC->m_iBidiLevel = 1; - } - } - FX_BidiLine(chars, iBidiNum + 1, m_bCurRTL ? 1 : 0); - } - CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; - if (!m_bPagination && - (bDone || (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_MutipleFormat) != 0)) { - tp.m_dwStatus = FX_TXTBREAK_PieceBreak; - tp.m_iStartPos = m_pCurLine->m_iStart; - tp.m_pChars = m_pCurLine->m_pLineChars; - int32_t iBidiLevel = -1, iCharWidth; - i = 0, j = -1; - while (i < iCount) { - pTC = chars.GetDataPtr(i); - if (iBidiLevel < 0) { - iBidiLevel = pTC->m_iBidiLevel; - tp.m_iWidth = 0; - tp.m_iBidiLevel = iBidiLevel; - tp.m_iBidiPos = pTC->m_iBidiOrder; - tp.m_dwCharStyles = pTC->m_dwCharStyles; - tp.m_pUserData = pTC->m_pUserData; - tp.m_iHorizontalScale = pTC->m_iHorizontalScale; - tp.m_iVerticalScale = pTC->m_iVertialScale; - tp.m_dwStatus = FX_TXTBREAK_PieceBreak; - } - if (iBidiLevel != pTC->m_iBidiLevel || pTC->m_dwStatus != 0) { - if (iBidiLevel == pTC->m_iBidiLevel) { - tp.m_dwStatus = pTC->m_dwStatus; - iCharWidth = pTC->m_iCharWidth; - if (iCharWidth > 0) { - tp.m_iWidth += iCharWidth; - } - i++; - } - tp.m_iChars = i - tp.m_iStartChar; - pCurPieces->Add(tp); - tp.m_iStartPos += tp.m_iWidth; - tp.m_iStartChar = i; - tpo.index = ++j; - tpo.pos = tp.m_iBidiPos; - tpos.Add(tpo); - iBidiLevel = -1; - } else { - iCharWidth = pTC->m_iCharWidth; - if (iCharWidth > 0) { - tp.m_iWidth += iCharWidth; - } - i++; - } - } - if (i > tp.m_iStartChar) { - tp.m_dwStatus = dwStatus; - tp.m_iChars = i - tp.m_iStartChar; - pCurPieces->Add(tp); - tpo.index = ++j; - tpo.pos = tp.m_iBidiPos; - tpos.Add(tpo); - } - if (j > -1) { - if (j > 0) { - FX_TEXTLAYOUT_PieceSort(tpos, 0, j); - int32_t iStartPos = 0; - for (i = 0; i <= j; i++) { - tpo = tpos.GetAt(i); - CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); - ttp.m_iStartPos = iStartPos; - iStartPos += ttp.m_iWidth; - } - } - CFX_TxtPiece& ttp = pCurPieces->GetAt(j); - ttp.m_dwStatus = dwStatus; - } - } else { - tp.m_dwStatus = dwStatus; - tp.m_iStartPos = m_pCurLine->m_iStart; - tp.m_iWidth = m_pCurLine->m_iWidth; - tp.m_iStartChar = 0; - tp.m_iChars = iCount; - tp.m_pChars = m_pCurLine->m_pLineChars; - tp.m_pUserData = m_pUserData; - pTC = chars.GetDataPtr(0); - tp.m_dwCharStyles = pTC->m_dwCharStyles; - tp.m_iHorizontalScale = pTC->m_iHorizontalScale; - tp.m_iVerticalScale = pTC->m_iVertialScale; - pCurPieces->Add(tp); - tpo.index = 0; - tpo.pos = 0; - tpos.Add(tpo); - } -} -void CFX_TxtBreak::EndBreak_Alignment(CFX_TPOArray& tpos, - FX_BOOL bAllChars, - FX_DWORD dwStatus) { - int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; - CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; - int32_t i, j, iCount = pCurPieces->GetSize(); - FX_BOOL bFind = FALSE; - FX_TPO tpo; - CFX_TxtChar* pTC; - FX_DWORD dwCharType; - for (i = iCount - 1; i > -1; i--) { - tpo = tpos.GetAt(i); - CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); - if (!bFind) { - iNetWidth = ttp.GetEndPos(); - } - FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); - j = bArabic ? 0 : ttp.m_iChars - 1; - while (j > -1 && j < ttp.m_iChars) { - pTC = ttp.GetCharPtr(j); - if (pTC->m_nBreakType == FX_LBT_DIRECT_BRK) { - iGapChars++; - } - if (!bFind || !bAllChars) { - dwCharType = pTC->GetCharType(); - if (dwCharType == FX_CHARTYPE_Space || - dwCharType == FX_CHARTYPE_Control) { - if (!bFind) { - iCharWidth = pTC->m_iCharWidth; - if (bAllChars && iCharWidth > 0) { - iNetWidth -= iCharWidth; - } - } - } else { - bFind = TRUE; - if (!bAllChars) { - break; - } - } - } - j += bArabic ? 1 : -1; - } - if (!bAllChars && bFind) { - break; - } - } - int32_t iOffset = m_iLineWidth - iNetWidth; - int32_t iLowerAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_LowerMask); - int32_t iHigherAlignment = (m_iCurAlignment & FX_TXTLINEALIGNMENT_HigherMask); - if (iGapChars > 0 && (iHigherAlignment == FX_TXTLINEALIGNMENT_Distributed || - (iHigherAlignment == FX_TXTLINEALIGNMENT_Justified && - dwStatus != FX_TXTBREAK_ParagraphBreak))) { - int32_t iStart = -1; - for (i = 0; i < iCount; i++) { - tpo = tpos.GetAt(i); - CFX_TxtPiece& ttp = pCurPieces->GetAt(tpo.index); - if (iStart < -1) { - iStart = ttp.m_iStartPos; - } else { - ttp.m_iStartPos = iStart; - } - int32_t k; - for (j = 0; j < ttp.m_iChars; j++) { - pTC = ttp.GetCharPtr(j); - if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0) { - continue; - } - k = iOffset / iGapChars; - pTC->m_iCharWidth += k; - ttp.m_iWidth += k; - iOffset -= k; - iGapChars--; - if (iGapChars < 1) { - break; - } - } - iStart += ttp.m_iWidth; - } - } else if (iLowerAlignment > FX_TXTLINEALIGNMENT_Left) { - if (iLowerAlignment == FX_TXTLINEALIGNMENT_Center) { - iOffset /= 2; - } - if (iOffset > 0) { - for (i = 0; i < iCount; i++) { - CFX_TxtPiece& ttp = pCurPieces->GetAt(i); - ttp.m_iStartPos += iOffset; - } - } - } -} -FX_DWORD CFX_TxtBreak::EndBreak(FX_DWORD dwStatus) { - FXSYS_assert(dwStatus >= FX_TXTBREAK_PieceBreak && - dwStatus <= FX_TXTBREAK_PageBreak); - CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces; - int32_t iCount = pCurPieces->GetSize(); - if (iCount > 0) { - CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); - if (dwStatus > FX_TXTBREAK_PieceBreak) { - pLastPiece->m_dwStatus = dwStatus; - } else { - dwStatus = pLastPiece->m_dwStatus; - } - return dwStatus; - } else { - CFX_TxtLine* pLastLine = GetTxtLine(TRUE); - if (pLastLine != NULL) { - pCurPieces = pLastLine->m_pLinePieces; - iCount = pCurPieces->GetSize(); - if (iCount-- > 0) { - CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); - if (dwStatus > FX_TXTBREAK_PieceBreak) { - pLastPiece->m_dwStatus = dwStatus; - } else { - dwStatus = pLastPiece->m_dwStatus; - } - return dwStatus; - } - return FX_TXTBREAK_None; - } - iCount = m_pCurLine->CountChars(); - if (iCount < 1) { - return FX_TXTBREAK_None; - } - if (!m_bPagination) { - CFX_TxtChar* pTC = m_pCurLine->GetCharPtr(iCount - 1); - pTC->m_dwStatus = dwStatus; - } - if (dwStatus <= FX_TXTBREAK_PieceBreak) { - return dwStatus; - } - } - m_iReady = (m_pCurLine == m_pTxtLine1) ? 1 : 2; - CFX_TxtLine* pNextLine = - (m_pCurLine == m_pTxtLine1) ? m_pTxtLine2 : m_pTxtLine1; - FX_BOOL bAllChars = (m_iCurAlignment > FX_TXTLINEALIGNMENT_Right); - CFX_TPOArray tpos; - CFX_Char* pTC; - if (m_bArabicShapes) { - EndBreak_UpdateArabicShapes(); - } - if (EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) { - goto EndBreak_Ret; - } - EndBreak_BidiLine(tpos, dwStatus); - if (!m_bPagination && m_iCurAlignment > FX_TXTLINEALIGNMENT_Left) { - EndBreak_Alignment(tpos, bAllChars, dwStatus); - } -EndBreak_Ret: - m_pCurLine = pNextLine; - pTC = GetLastChar(0, FALSE); - m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); - if (dwStatus == FX_TXTBREAK_ParagraphBreak) { - m_iArabicContext = m_iCurArabicContext = 1; - ResetArabicContext(); - } - return dwStatus; -} -int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, - int32_t& iEndPos, - FX_BOOL bAllChars, - FX_BOOL bOnlyBrk) { - int32_t iLength = ca.GetSize() - 1; - if (iLength < 1) { - return iLength; - } - int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, - iLast = -1, iLastPos = -1; - if (m_bSingleLine || iEndPos <= m_iLineWidth) { - if (!bAllChars) { - return iLength; - } - iBreak = iLength; - iBreakPos = iEndPos; - } - FX_BOOL bSpaceBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0; - FX_BOOL bNumberBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_NumberBreak) != 0; - FX_LINEBREAKTYPE eType; - FX_DWORD nCodeProp, nCur, nNext; - CFX_Char* pCur = ca.GetDataPtr(iLength--); - if (bAllChars) { - pCur->m_nBreakType = FX_LBT_UNKNOWN; - } - nCodeProp = pCur->m_dwCharProps; - nNext = nCodeProp & 0x003F; - int32_t iCharWidth = pCur->m_iCharWidth; - if (iCharWidth > 0) { - iEndPos -= iCharWidth; - } - while (iLength >= 0) { - pCur = ca.GetDataPtr(iLength); - nCodeProp = pCur->m_dwCharProps; - nCur = nCodeProp & 0x003F; - if (nCur == FX_CBP_SP) { - if (nNext == FX_CBP_SP) { - eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); - } - } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { - eType = FX_LBT_DIRECT_BRK; - } else { - if (nNext == FX_CBP_SP) { - eType = FX_LBT_PROHIBITED_BRK; - } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); - } - } - if (bAllChars) { - pCur->m_nBreakType = (uint8_t)eType; - } - if (!bOnlyBrk) { - if (m_bSingleLine || iEndPos <= m_iLineWidth || - (nCur == FX_CBP_SP && !bSpaceBreak)) { - if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) { - iBreak = iLength; - iBreakPos = iEndPos; - if (!bAllChars) { - return iLength; - } - } else if (eType == FX_LBT_INDIRECT_BRK && iIndirect < 0) { - iIndirect = iLength; - iIndirectPos = iEndPos; - } - if (iLast < 0) { - iLast = iLength; - iLastPos = iEndPos; - } - } - iCharWidth = pCur->m_iCharWidth; - if (iCharWidth > 0) { - iEndPos -= iCharWidth; - } - } - nNext = nCodeProp & 0x003F; - iLength--; - } - if (bOnlyBrk) { - return 0; - } - if (iBreak > -1) { - iEndPos = iBreakPos; - return iBreak; - } - if (iIndirect > -1) { - iEndPos = iIndirectPos; - return iIndirect; - } - if (iLast > -1) { - iEndPos = iLastPos; - return iLast; - } - return 0; -} -void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, - CFX_TxtLine* pNextLine, - FX_BOOL bAllChars) { - FXSYS_assert(pCurLine != NULL && pNextLine != NULL); - int32_t iCount = pCurLine->CountChars(); - if (iCount < 2) { - return; - } - int32_t iEndPos = pCurLine->m_iWidth; - CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; - int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); - if (iCharPos < 0) { - iCharPos = 0; - } - iCharPos++; - if (iCharPos >= iCount) { - pNextLine->RemoveAll(TRUE); - CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); - pTC->m_nBreakType = FX_LBT_UNKNOWN; - return; - } - CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars; - int cur_size = curChars.GetSize(); - nextChars.SetSize(cur_size - iCharPos); - FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), - (cur_size - iCharPos) * sizeof(CFX_TxtChar)); - iCount -= iCharPos; - cur_size = curChars.GetSize(); - curChars.RemoveAt(cur_size - iCount, iCount); - pCurLine->m_iWidth = iEndPos; - CFX_TxtChar* pTC = curChars.GetDataPtr(iCharPos - 1); - pTC->m_nBreakType = FX_LBT_UNKNOWN; - iCount = nextChars.GetSize(); - int32_t iCharWidth, iWidth = 0; - for (int32_t i = 0; i < iCount; i++) { - pTC = nextChars.GetDataPtr(i); - if (pTC->GetCharType() >= FX_CHARTYPE_ArabicAlef) { - pCurLine->m_iArabicChars--; - pNextLine->m_iArabicChars++; - } - iCharWidth = pTC->m_iCharWidth; - if (iCharWidth > 0) { - iWidth += iCharWidth; - } - if (m_bPagination) { - continue; - } - pTC->m_dwStatus = 0; - } - pNextLine->m_iWidth = iWidth; -} -int32_t CFX_TxtBreak::CountBreakChars() const { - CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); - return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); -} -int32_t CFX_TxtBreak::CountBreakPieces() const { - CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); - if (pTxtPieces == NULL) { - return 0; - } - return pTxtPieces->GetSize(); -} -const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { - CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); - if (pTxtPieces == NULL) { - return NULL; - } - if (index < 0 || index >= pTxtPieces->GetSize()) { - return NULL; - } - return pTxtPieces->GetPtrAt(index); -} -void CFX_TxtBreak::ClearBreakPieces() { - CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); - if (pTxtLine != NULL) { - pTxtLine->RemoveAll(TRUE); - } - m_iReady = 0; -} -void CFX_TxtBreak::Reset() { - m_dwCharType = 0; - m_iArabicContext = m_iCurArabicContext = 1; - ResetArabicContext(); - m_pTxtLine1->RemoveAll(TRUE); - m_pTxtLine2->RemoveAll(TRUE); -} - -struct FX_FORMCHAR { - FX_WORD wch; - FX_WORD wForm; - int32_t iWidth; -}; - -int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode, - CFX_WideString* pWSForms, - FX_AdjustCharDisplayPos pAdjustPos) const { - if (pTxtRun == NULL || pTxtRun->iLength < 1) { - return 0; - } - IFX_TxtAccess* pAccess = pTxtRun->pAccess; - void* pIdentity = pTxtRun->pIdentity; - const FX_WCHAR* pStr = pTxtRun->pStr; - int32_t* pWidths = pTxtRun->pWidths; - int32_t iLength = pTxtRun->iLength - 1; - IFX_Font* pFont = pTxtRun->pFont; - FX_DWORD dwStyles = pTxtRun->dwStyles; - CFX_RectF rtText(*pTxtRun->pRect); - FX_BOOL bRTLPiece = - (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; - FX_BOOL bArabicNumber = - (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; - FX_BOOL bArabicComma = - (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; - FX_FLOAT fFontSize = pTxtRun->fFontSize; - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - int32_t iAscent = pFont->GetAscent(); - int32_t iDescent = pFont->GetDescent(); - int32_t iMaxHeight = iAscent - iDescent; - FX_FLOAT fFontHeight = fFontSize; - FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; - FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; - FX_BOOL bVerticalDoc = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; - FX_BOOL bVerticalChar = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0; - int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation; - int32_t iCharRotation; - FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm, wLast = 0xFEFF; - int32_t iWidth, iCharWidth, iCharHeight; - FX_FLOAT fX, fY, fCharWidth, fCharHeight; - int32_t iHorScale = pTxtRun->iHorizontalScale; - int32_t iVerScale = pTxtRun->iVerticalScale; - FX_BOOL bSkipSpace = pTxtRun->bSkipSpace; - FX_BOOL bEmptyChar, bShadda = FALSE, bLam = FALSE; - FX_DWORD dwProps, dwCharType; - FX_FORMCHAR formChars[3]; - FX_FLOAT fYBase; - fX = rtText.left; - if (bVerticalDoc) { - fX += (rtText.width - fFontSize) / 2.0f; - fYBase = bRTLPiece ? rtText.bottom() : rtText.top; - fY = fYBase; - } else { - if (bRTLPiece) { - fX = rtText.right(); - } - fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f; - fY = fYBase + fAscent; - } - int32_t iCount = 0, iNext, iForms; - for (int32_t i = 0; i <= iLength; i++) { - if (pAccess != NULL) { - wch = pAccess->GetChar(pIdentity, i); - iWidth = pAccess->GetWidth(pIdentity, i); - } else { - wch = *pStr++; - iWidth = *pWidths++; - } - dwProps = FX_GetUnicodeProperties(wch); - dwCharType = (dwProps & FX_CHARTYPEBITSMASK); - if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) { - wPrev = 0xFEFF; - wLast = wch; - continue; - } - if (dwCharType >= FX_CHARTYPE_ArabicAlef) { - if (i < iLength) { - if (pAccess != NULL) { - iNext = i + 1; - while (iNext <= iLength) { - wNext = pAccess->GetChar(pIdentity, iNext); - dwProps = FX_GetUnicodeProperties(wNext); - if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { - break; - } - iNext++; - } - if (iNext > iLength) { - wNext = 0xFEFF; - } - } else { - int32_t j = -1; - do { - j++; - if (i + j >= iLength) { - break; - } - wNext = pStr[j]; - dwProps = FX_GetUnicodeProperties(wNext); - } while ((dwProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination); - if (i + j >= iLength) { - wNext = 0xFEFF; - } - } - } else { - wNext = 0xFEFF; - } - wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext); - bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); - } else if (dwCharType == FX_CHARTYPE_Combination) { - wForm = wch; - if (wch >= 0x064C && wch <= 0x0651) { - if (bShadda) { - wForm = 0xFEFF; - bShadda = FALSE; - } else { - wNext = 0xFEFF; - if (pAccess != NULL) { - iNext = i + 1; - if (iNext <= iLength) { - wNext = pAccess->GetChar(pIdentity, iNext); - } - } else { - if (i < iLength) { - wNext = *pStr; - } - } - if (wch == 0x0651) { - if (wNext >= 0x064C && wNext <= 0x0650) { - wForm = FX_GetArabicFromShaddaTable(wNext); - bShadda = TRUE; - } - } else { - if (wNext == 0x0651) { - wForm = FX_GetArabicFromShaddaTable(wch); - bShadda = TRUE; - } - } - } - } else { - bShadda = FALSE; - } - } else if (dwCharType == FX_CHARTYPE_Numeric) { - wForm = wch; - if (bArabicNumber) { - wForm += 0x0630; - } - } else if (wch == L'.') { - wForm = wch; - if (bArabicNumber) { - wNext = 0xFEFF; - if (pAccess != NULL) { - iNext = i + 1; - if (iNext <= iLength) { - wNext = pAccess->GetChar(pIdentity, iNext); - } - } else { - if (i < iLength) { - wNext = *pStr; - } - } - if (wNext >= L'0' && wNext <= L'9') { - wForm = 0x066B; - } - } - } else if (wch == L',') { - wForm = wch; - if (bArabicComma) { - wForm = 0x060C; - } - } else if (bRTLPiece || bVerticalChar) { - wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar); - } else { - wForm = wch; - } - if (dwCharType != FX_CHARTYPE_Combination) { - bShadda = FALSE; - } - if (dwCharType < FX_CHARTYPE_ArabicAlef) { - bLam = FALSE; - } - dwProps = FX_GetUnicodeProperties(wForm); - iCharRotation = iRotation; - if (bVerticalChar && (dwProps & 0x8000) != 0) { - iCharRotation++; - } - iCharRotation %= 4; - bEmptyChar = - (dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control); - if (wForm == 0xFEFF) { - bEmptyChar = TRUE; - } - iForms = bLam ? 3 : 1; - iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; - if (pCharPos == NULL) { - if (iWidth > 0) { - wPrev = wch; - } - wLast = wch; - continue; - } - iCharWidth = iWidth; - if (iCharWidth < 0) { - iCharWidth = -iCharWidth; - } - iCharWidth /= iFontSize; - formChars[0].wch = wch; - formChars[0].wForm = wForm; - formChars[0].iWidth = iCharWidth; - if (bLam) { - formChars[1].wForm = 0x0651; - iCharWidth = 0; - pFont->GetCharWidth(0x0651, iCharWidth, FALSE); - formChars[1].iWidth = iCharWidth; - formChars[2].wForm = 0x0670; - iCharWidth = 0; - pFont->GetCharWidth(0x0670, iCharWidth, FALSE); - formChars[2].iWidth = iCharWidth; - } - for (int32_t j = 0; j < iForms; j++) { - wForm = (FX_WCHAR)formChars[j].wForm; - iCharWidth = formChars[j].iWidth; - if (j > 0) { - dwCharType = FX_CHARTYPE_Combination; - wch = wForm; - wLast = (FX_WCHAR)formChars[j - 1].wForm; - } - if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { - pCharPos->m_GlyphIndex = - bCharCode ? wch : pFont->GetGlyphIndex(wForm, FALSE); - pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; - pCharPos->m_FontCharWidth = iCharWidth; - if (pWSForms) { - *pWSForms += wForm; - } - } - if (bVerticalDoc) { - iCharHeight = iCharWidth; - iCharWidth = 1000; - } else { - iCharHeight = 1000; - } - fCharWidth = fFontSize * iCharWidth / 1000.0f; - fCharHeight = fFontSize * iCharHeight / 1000.0f; - if (bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { - if (bVerticalDoc) { - fY -= fCharHeight; - } else { - fX -= fCharWidth; - } - } - if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { - pCharPos->m_OriginX = fX; - pCharPos->m_OriginY = fY; - if ((dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0) { - int32_t iFormWidth = iCharWidth; - pFont->GetCharWidth(wForm, iFormWidth, FALSE); - FX_FLOAT fOffset = fFontSize * (iCharWidth - iFormWidth) / 2000.0f; - if (bVerticalDoc) { - pCharPos->m_OriginY += fOffset; - } else { - pCharPos->m_OriginX += fOffset; - } - } - if (dwCharType == FX_CHARTYPE_Combination) { - CFX_Rect rtBBox; - rtBBox.Reset(); - if (pFont->GetCharBBox(wForm, rtBBox, FALSE)) { - pCharPos->m_OriginY = - fYBase + fFontSize - - fFontSize * (FX_FLOAT)rtBBox.height / (FX_FLOAT)iMaxHeight; - } - if (wForm == wch && wLast != 0xFEFF) { - FX_DWORD dwLastProps = FX_GetUnicodeProperties(wLast); - if ((dwLastProps & FX_CHARTYPEBITSMASK) == - FX_CHARTYPE_Combination) { - CFX_Rect rtBBox; - rtBBox.Reset(); - if (pFont->GetCharBBox(wLast, rtBBox, FALSE)) { - pCharPos->m_OriginY -= fFontSize * rtBBox.height / iMaxHeight; - } - } - } - } - CFX_PointF ptOffset; - FX_BOOL bAdjusted = FALSE; - if (pAdjustPos) { - bAdjusted = pAdjustPos(wForm, bCharCode, pFont, fFontSize, - bVerticalChar, ptOffset); - } - if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) { - CFX_Rect rtBBox; - rtBBox.Reset(); - if (pFont->GetCharBBox(wForm, rtBBox, FALSE)) { - ptOffset.x = fFontSize * (850 - rtBBox.right()) / iMaxHeight; - ptOffset.y = fFontSize * (iAscent - rtBBox.top - 150) / iMaxHeight; - } - } - pCharPos->m_OriginX += ptOffset.x; - pCharPos->m_OriginY -= ptOffset.y; - } - if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { - if (bVerticalDoc) { - fY += fCharHeight; - } else { - fX += fCharWidth; - } - } - if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { - pCharPos->m_bGlyphAdjust = TRUE; - if (bVerticalDoc) { - if (iCharRotation == 0) { - pCharPos->m_AdjustMatrix[0] = -1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent; - } else if (iCharRotation == 1) { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = -1; - pCharPos->m_AdjustMatrix[2] = -1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; - } else if (iCharRotation == 2) { - pCharPos->m_AdjustMatrix[0] = 1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY += fAscent; - } else { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = 1; - pCharPos->m_AdjustMatrix[2] = 1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; - } - } else { - if (iCharRotation == 0) { - pCharPos->m_AdjustMatrix[0] = -1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = 1; - } else if (iCharRotation == 1) { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = -1; - pCharPos->m_AdjustMatrix[2] = -1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; - pCharPos->m_OriginY -= fAscent + fDescent; - } else if (iCharRotation == 2) { - pCharPos->m_AdjustMatrix[0] = 1; - pCharPos->m_AdjustMatrix[1] = 0; - pCharPos->m_AdjustMatrix[2] = 0; - pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY -= fAscent; - } else { - pCharPos->m_AdjustMatrix[0] = 0; - pCharPos->m_AdjustMatrix[1] = 1; - pCharPos->m_AdjustMatrix[2] = 1; - pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; - } - } - if (iHorScale != 100 || iVerScale != 100) { - pCharPos->m_AdjustMatrix[0] = - pCharPos->m_AdjustMatrix[0] * iHorScale / 100.0f; - pCharPos->m_AdjustMatrix[1] = - pCharPos->m_AdjustMatrix[1] * iHorScale / 100.0f; - pCharPos->m_AdjustMatrix[2] = - pCharPos->m_AdjustMatrix[2] * iVerScale / 100.0f; - pCharPos->m_AdjustMatrix[3] = - pCharPos->m_AdjustMatrix[3] * iVerScale / 100.0f; - } - pCharPos++; - } - } - if (iWidth > 0) { - wPrev = (FX_WCHAR)formChars[0].wch; - } - wLast = wch; - } - return iCount; -} -int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, - CFX_RectFArray& rtArray, - FX_BOOL bCharBBox) const { - if (pTxtRun == NULL || pTxtRun->iLength < 1) { - return 0; - } - IFX_TxtAccess* pAccess = pTxtRun->pAccess; - void* pIdentity = pTxtRun->pIdentity; - const FX_WCHAR* pStr = pTxtRun->pStr; - int32_t* pWidths = pTxtRun->pWidths; - int32_t iLength = pTxtRun->iLength; - CFX_RectF rect(*pTxtRun->pRect); - FX_BOOL bRTLPiece = - (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; - FX_FLOAT fFontSize = pTxtRun->fFontSize; - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); - FX_FLOAT fScale = fFontSize / 1000.0f; - IFX_Font* pFont = pTxtRun->pFont; - if (pFont == NULL) { - bCharBBox = FALSE; - } - CFX_Rect bbox; - bbox.Set(0, 0, 0, 0); - if (bCharBBox) { - bCharBBox = pFont->GetBBox(bbox); - } - FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); - FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); - rtArray.RemoveAll(); - rtArray.SetSize(iLength); - FX_BOOL bVertical = - (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; - FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; - FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; - FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; - int32_t iCharSize; - FX_FLOAT fCharSize, fStart; - if (bVertical) { - fStart = bRTLPiece ? rect.bottom() : rect.top; - } else { - fStart = bRTLPiece ? rect.right() : rect.left; - } - for (int32_t i = 0; i < iLength; i++) { - if (pAccess != NULL) { - wch = pAccess->GetChar(pIdentity, i); - iCharSize = pAccess->GetWidth(pIdentity, i); - } else { - wch = *pStr++; - iCharSize = *pWidths++; - } - fCharSize = (FX_FLOAT)iCharSize / 20000.0f; - FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); - if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || - (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { - bRet = FALSE; - } - if (bRet) { - iCharSize = iFontSize * 500; - fCharSize = fFontSize / 2.0f; - } - if (bVertical) { - rect.top = fStart; - if (bRTLPiece) { - rect.top -= fCharSize; - fStart -= fCharSize; - } else { - fStart += fCharSize; - } - rect.height = fCharSize; - } else { - rect.left = fStart; - if (bRTLPiece) { - rect.left -= fCharSize; - fStart -= fCharSize; - } else { - fStart += fCharSize; - } - rect.width = fCharSize; - } - if (bCharBBox && !bRet) { - int32_t iCharWidth = 1000; - pFont->GetCharWidth(wch, iCharWidth); - FX_FLOAT fRTLeft = 0, fCharWidth = 0; - if (iCharWidth > 0) { - fCharWidth = iCharWidth * fScale; - fRTLeft = fLeft; - if (bCombText) { - fRTLeft = (rect.width - fCharWidth) / 2.0f; - } - } - CFX_RectF rtBBoxF; - if (bVertical) { - rtBBoxF.top = rect.left + fRTLeft; - rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; - rtBBoxF.height = fCharWidth; - rtBBoxF.width = fHeight; - rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); - } else { - rtBBoxF.left = rect.left + fRTLeft; - rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; - rtBBoxF.width = fCharWidth; - rtBBoxF.height = fHeight; - rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); - } - rtArray.SetAt(i, rtBBoxF); - continue; - } - rtArray.SetAt(i, rect); - } - return iLength; -} diff --git a/xfa/src/fgas/layout/fgas_textbreak.h b/xfa/src/fgas/layout/fgas_textbreak.h deleted file mode 100644 index 65fba720d5..0000000000 --- a/xfa/src/fgas/layout/fgas_textbreak.h +++ /dev/null @@ -1,222 +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_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ -#define XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ - -#include "core/include/fxcrt/fx_ucd.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fgas/crt/fgas_utils.h" -#include "xfa/src/fgas/layout/fgas_unicode.h" - -class IFX_Font; -class CFX_Char; -class IFX_TxtAccess; -class CFX_TxtChar; -class CFX_TxtPiece; -class IFX_TxtBreak; - -#define FX_TXTBREAKPOLICY_None 0x00 -#define FX_TXTBREAKPOLICY_Pagination 0x01 -#define FX_TXTBREAKPOLICY_SpaceBreak 0x02 -#define FX_TXTBREAKPOLICY_NumberBreak 0x04 -#define FX_TXTBREAK_None 0x00 -#define FX_TXTBREAK_PieceBreak 0x01 -#define FX_TXTBREAK_LineBreak 0x02 -#define FX_TXTBREAK_ParagraphBreak 0x03 -#define FX_TXTBREAK_PageBreak 0x04 -#define FX_TXTBREAK_ControlChar 0x10 -#define FX_TXTBREAK_BreakChar 0x20 -#define FX_TXTBREAK_UnknownChar 0x40 -#define FX_TXTBREAK_RemoveChar 0x80 -#define FX_TXTLAYOUTSTYLE_MutipleFormat 0x0001 -#define FX_TXTLAYOUTSTYLE_VerticalLayout 0x0002 -#define FX_TXTLAYOUTSTYLE_VerticalChars 0x0004 -#define FX_TXTLAYOUTSTYLE_ReverseLine 0x0008 -#define FX_TXTLAYOUTSTYLE_ArabicContext 0x0010 -#define FX_TXTLAYOUTSTYLE_ArabicShapes 0x0020 -#define FX_TXTLAYOUTSTYLE_RTLReadingOrder 0x0040 -#define FX_TXTLAYOUTSTYLE_ExpandTab 0x0100 -#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200 -#define FX_TXTLAYOUTSTYLE_CombText 0x0400 -#define FX_TXTCHARSTYLE_Alignment 0x000F -#define FX_TXTCHARSTYLE_ArabicNumber 0x0010 -#define FX_TXTCHARSTYLE_ArabicShadda 0x0020 -#define FX_TXTCHARSTYLE_OddBidiLevel 0x0040 -#define FX_TXTCHARSTYLE_RTLReadingOrder 0x0080 -#define FX_TXTCHARSTYLE_ArabicContext 0x0300 -#define FX_TXTCHARSTYLE_ArabicIndic 0x0400 -#define FX_TXTCHARSTYLE_ArabicComma 0x0800 -#define FX_TXTLINEALIGNMENT_Left 0 -#define FX_TXTLINEALIGNMENT_Center 1 -#define FX_TXTLINEALIGNMENT_Right 2 -#define FX_TXTLINEALIGNMENT_Justified (1 << 2) -#define FX_TXTLINEALIGNMENT_Distributed (2 << 2) -#define FX_TXTLINEALIGNMENT_JustifiedLeft \ - (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Justified) -#define FX_TXTLINEALIGNMENT_JustifiedCenter \ - (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Justified) -#define FX_TXTLINEALIGNMENT_JustifiedRight \ - (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Justified) -#define FX_TXTLINEALIGNMENT_DistributedLeft \ - (FX_TXTLINEALIGNMENT_Left | FX_TXTLINEALIGNMENT_Distributed) -#define FX_TXTLINEALIGNMENT_DistributedCenter \ - (FX_TXTLINEALIGNMENT_Center | FX_TXTLINEALIGNMENT_Distributed) -#define FX_TXTLINEALIGNMENT_DistributedRight \ - (FX_TXTLINEALIGNMENT_Right | FX_TXTLINEALIGNMENT_Distributed) -#define FX_TXTLINEALIGNMENT_LowerMask 0x03 -#define FX_TXTLINEALIGNMENT_HigherMask 0x0C -#define FX_TXTBREAK_MinimumTabWidth 160000 - -class IFX_TxtAccess { - public: - virtual ~IFX_TxtAccess() {} - virtual FX_WCHAR GetChar(void* pIdentity, int32_t index) const = 0; - virtual int32_t GetWidth(void* pIdentity, int32_t index) const = 0; -}; - -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; - } - - IFX_TxtAccess* pAccess; - void* pIdentity; - const FX_WCHAR* pStr; - int32_t* pWidths; - int32_t iLength; - IFX_Font* pFont; - FX_FLOAT fFontSize; - FX_DWORD dwStyles; - int32_t iHorizontalScale; - int32_t iVerticalScale; - int32_t iCharRotation; - FX_DWORD dwCharStyles; - const CFX_RectF* pRect; - FX_WCHAR wLineBreakChar; - FX_BOOL bSkipSpace; -}; - -class CFX_TxtPiece : public CFX_Target { - public: - CFX_TxtPiece() - : m_dwStatus(FX_TXTBREAK_PieceBreak), - m_iStartPos(0), - m_iWidth(-1), - m_iStartChar(0), - m_iChars(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_iHorizontalScale(100), - m_iVerticalScale(100), - m_dwCharStyles(0), - m_pChars(NULL), - m_pUserData(NULL) {} - int32_t GetEndPos() const { - return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; - } - 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); - return m_pChars->GetDataPtr(m_iStartChar + index); - } - void GetString(FX_WCHAR* pText) const { - FXSYS_assert(pText != NULL); - int32_t iEndChar = m_iStartChar + m_iChars; - CFX_Char* pChar; - for (int32_t i = m_iStartChar; i < iEndChar; i++) { - pChar = m_pChars->GetDataPtr(i); - *pText++ = (FX_WCHAR)pChar->m_wCharCode; - } - } - - void GetString(CFX_WideString& wsText) const { - FX_WCHAR* pText = wsText.GetBuffer(m_iChars); - GetString(pText); - wsText.ReleaseBuffer(m_iChars); - } - void GetWidths(int32_t* pWidths) const { - FXSYS_assert(pWidths != NULL); - int32_t iEndChar = m_iStartChar + m_iChars; - CFX_Char* pChar; - for (int32_t i = m_iStartChar; i < iEndChar; i++) { - pChar = m_pChars->GetDataPtr(i); - *pWidths++ = pChar->m_iCharWidth; - } - } - FX_DWORD m_dwStatus; - int32_t m_iStartPos; - int32_t m_iWidth; - int32_t m_iStartChar; - int32_t m_iChars; - int32_t m_iBidiLevel; - int32_t m_iBidiPos; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; - FX_DWORD m_dwCharStyles; - CFX_TxtCharArray* m_pChars; - void* m_pUserData; -}; -typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray; - -class IFX_TxtBreak { - public: - static IFX_TxtBreak* Create(FX_DWORD dwPolicies); - virtual ~IFX_TxtBreak() {} - virtual void Release() = 0; - virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0; - virtual void SetLinePos(FX_FLOAT fLinePos) = 0; - virtual FX_DWORD GetLayoutStyles() const = 0; - virtual void SetLayoutStyles(FX_DWORD 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 FX_DWORD GetContextCharStyles() const = 0; - virtual void SetContextCharStyles(FX_DWORD dwCharStyles) = 0; - virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0; - virtual void SetUserData(void* pUserData) = 0; - virtual FX_DWORD AppendChar(FX_WCHAR wch) = 0; - virtual FX_DWORD EndBreak(FX_DWORD 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; -}; - -#endif // XFA_SRC_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ diff --git a/xfa/src/fgas/layout/fgas_unicode.cpp b/xfa/src/fgas/layout/fgas_unicode.cpp deleted file mode 100644 index f463d753b5..0000000000 --- a/xfa/src/fgas/layout/fgas_unicode.cpp +++ /dev/null @@ -1,117 +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/src/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()); - if (iStart >= iEnd) { - return; - } - int32_t i = iStart, j = iEnd; - FX_TPO *pCur = tpos.GetPtrAt(iStart), *pSort; - int32_t v = pCur->pos; - while (i < j) { - while (j > i) { - pSort = tpos.GetPtrAt(j); - if (pSort->pos < v) { - FX_TPO t = *pSort; - *pSort = *pCur; - *pCur = t; - pCur = pSort; - break; - } - j--; - } - while (i < j) { - pSort = tpos.GetPtrAt(i); - if (pSort->pos > v) { - FX_TPO t = *pSort; - *pSort = *pCur; - *pCur = t; - pCur = pSort; - break; - } - i++; - } - } - i--, j++; - if (iStart < i) { - FX_TEXTLAYOUT_PieceSort(tpos, iStart, i); - } - if (j < iEnd) { - FX_TEXTLAYOUT_PieceSort(tpos, j, iEnd); - } -} -static const FX_JAPCHARPROPERTYEX gs_FX_JapCharPropertysEx[] = { - {0x3001, 0x13}, {0x3002, 0x13}, {0x3041, 0x23}, {0x3043, 0x23}, - {0x3045, 0x23}, {0x3047, 0x23}, {0x3049, 0x23}, {0x3063, 0x23}, - {0x3083, 0x23}, {0x3085, 0x23}, {0x3087, 0x23}, {0x308E, 0x23}, - {0x3095, 0x23}, {0x3096, 0x23}, {0x30A1, 0x23}, {0x30A3, 0x23}, - {0x30A5, 0x23}, {0x30A7, 0x23}, {0x30A9, 0x23}, {0x30C3, 0x23}, - {0x30E3, 0x23}, {0x30E5, 0x23}, {0x30E7, 0x23}, {0x30EE, 0x23}, - {0x30F5, 0x23}, {0x30F6, 0x23}, {0x30FB, 0x22}, {0x31F0, 0x23}, - {0x31F1, 0x23}, {0x31F2, 0x23}, {0x31F3, 0x23}, {0x31F4, 0x23}, - {0x31F5, 0x23}, {0x31F6, 0x23}, {0x31F7, 0x23}, {0x31F8, 0x23}, - {0x31F9, 0x23}, {0x31FA, 0x23}, {0x31FB, 0x23}, {0x31FC, 0x23}, - {0x31FD, 0x23}, {0x31FE, 0x23}, {0x31FF, 0x23}, -}; -const FX_JAPCHARPROPERTYEX* FX_GetJapCharPropertyEx(FX_WCHAR wch) { - int32_t iStart = 0; - int32_t iEnd = - sizeof(gs_FX_JapCharPropertysEx) / sizeof(FX_JAPCHARPROPERTYEX); - while (iStart <= iEnd) { - int32_t iMid = (iStart + iEnd) / 2; - FX_WCHAR wJapChar = gs_FX_JapCharPropertysEx[iMid].wChar; - if (wch == wJapChar) { - return gs_FX_JapCharPropertysEx + iMid; - } else if (wch < wJapChar) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } - return NULL; -} -FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, - FX_BOOL bMBCSCode, - IFX_Font* pFont, - FX_FLOAT fFontSize, - FX_BOOL bVertical, - CFX_PointF& ptOffset) { - if (pFont == NULL || !bVertical) { - return FALSE; - } - if (wch < 0x3001 || wch > 0x31FF) { - return FALSE; - } - const FX_JAPCHARPROPERTYEX* pJapChar = FX_GetJapCharPropertyEx(wch); - if (pJapChar == NULL) { - return FALSE; - } - CFX_Rect rtBBox; - rtBBox.Reset(); - if (pFont->GetCharBBox(wch, rtBBox, bMBCSCode)) { - switch (pJapChar->uAlign & 0xF0) { - case FX_JAPCHARPROPERTYEX_Top: - ptOffset.y = fFontSize * (1000 - rtBBox.height) / 1200.0f; - break; - case FX_JAPCHARPROPERTYEX_Middle: - ptOffset.y = fFontSize * (1000 - rtBBox.height) / 6000.0f; - break; - } - switch (pJapChar->uAlign & 0x0F) { - case FX_JAPCHARPROPERTYEX_Center: - ptOffset.x = fFontSize * (600 - rtBBox.right()) / 1000.0f; - break; - case FX_JAPCHARPROPERTYEX_Right: - ptOffset.x = fFontSize * (950 - rtBBox.right()) / 1000.0f; - break; - } - } - return TRUE; -} diff --git a/xfa/src/fgas/layout/fgas_unicode.h b/xfa/src/fgas/layout/fgas_unicode.h deleted file mode 100644 index f25da87e96..0000000000 --- a/xfa/src/fgas/layout/fgas_unicode.h +++ /dev/null @@ -1,47 +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_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ -#define XFA_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ - -#include "xfa/src/fgas/font/fgas_font.h" -#include "xfa/src/fgas/crt/fgas_utils.h" - -#define FX_JAPCHARPROPERTYEX_Left 0x01 -#define FX_JAPCHARPROPERTYEX_Center 0x02 -#define FX_JAPCHARPROPERTYEX_Right 0x03 -#define FX_JAPCHARPROPERTYEX_Top 0x10 -#define FX_JAPCHARPROPERTYEX_Middle 0x20 -#define FX_JAPCHARPROPERTYEX_Bottom 0x30 - -struct FX_TPO { - int32_t index; - int32_t pos; -}; -typedef CFX_MassArrayTemplate<FX_TPO> CFX_TPOArray; - -void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd); - -struct FX_JAPCHARPROPERTYEX { - FX_WCHAR wChar; - uint8_t uAlign; -}; - -const FX_JAPCHARPROPERTYEX* FX_GetJapCharPropertyEx(FX_WCHAR wch); -typedef FX_BOOL (*FX_AdjustCharDisplayPos)(FX_WCHAR wch, - FX_BOOL bMBCSCode, - IFX_Font* pFont, - FX_FLOAT fFontSize, - FX_BOOL bVertical, - CFX_PointF& ptOffset); -FX_BOOL FX_AdjustJapCharDisplayPos(FX_WCHAR wch, - FX_BOOL bMBCSCode, - IFX_Font* pFont, - FX_FLOAT fFontSize, - FX_BOOL bVertical, - CFX_PointF& ptOffset); - -#endif // XFA_SRC_FGAS_LAYOUT_FGAS_UNICODE_H_ diff --git a/xfa/src/fgas/localization/fgas_datetime.cpp b/xfa/src/fgas/localization/fgas_datetime.cpp deleted file mode 100644 index e803b490d6..0000000000 --- a/xfa/src/fgas/localization/fgas_datetime.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 "core/include/fxcrt/fx_system.h" -#include "xfa/src/fgas/localization/fgas_datetime.h" - -#if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ - _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ -#include <sys/time.h> -#include <time.h> -#endif - -const uint8_t g_FXDaysPerMonth[12] = {31, 28, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31}; -const uint8_t g_FXDaysPerLeapMonth[12] = {31, 29, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31}; -const int32_t g_FXDaysBeforeMonth[12] = {0, 31, 59, 90, 120, 151, - 181, 212, 243, 273, 304, 334}; -const int32_t g_FXDaysBeforeLeapMonth[12] = {0, 31, 60, 91, 121, 152, - 182, 213, 244, 274, 305, 335}; -const int32_t g_FXDaysPerYear = 365; -const int32_t g_FXDaysPerLeapYear = 366; -const int32_t g_FXDaysPer4Years = 1461; -const int32_t g_FXDaysPer100Years = 36524; -const int32_t g_FXDaysPer400Years = 146097; -const int64_t g_FXMillisecondsPerSecond = 1000; -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); - return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; -} -int32_t FX_DaysInYear(int32_t iYear) { - FXSYS_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); - 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); - const int32_t* p = - FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; - return p[iMonth - 1]; -} -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)); - int64_t iDays = FX_DaysBeforeMonthInYear(iYear, iMonth); - iDays += iDay; - if (!bIncludeThisDay) { - iDays--; - } - if (iYear > 0) { - iYear--; - } else { - iDays -= FX_DaysInYear(iYear); - iYear++; - } - return iDays + (int64_t)iYear * 365 + iYear / 4 - iYear / 100 + iYear / 400; -} -static void FX_DaysToDate(int64_t iDays, - int32_t& iYear, - uint8_t& iMonth, - uint8_t& iDay) { - FX_BOOL bBC = iDays < 0; - if (bBC) { - iDays = -iDays; - } - iYear = 1; - iMonth = 1; - iDay = 1; - if (iDays >= g_FXDaysPer400Years) { - iYear += (int32_t)(iDays / g_FXDaysPer400Years * 400); - iDays %= g_FXDaysPer400Years; - } - if (iDays >= g_FXDaysPer100Years) { - if (iDays == g_FXDaysPer100Years * 4) { - iYear += 300; - iDays -= g_FXDaysPer100Years * 3; - } else { - iYear += (int32_t)(iDays / g_FXDaysPer100Years * 100); - iDays %= g_FXDaysPer100Years; - } - } - if (iDays >= g_FXDaysPer4Years) { - iYear += (int32_t)(iDays / g_FXDaysPer4Years * 4); - iDays %= g_FXDaysPer4Years; - } - while (TRUE) { - int32_t iYearDays = FX_DaysInYear(iYear); - if (iDays < iYearDays) { - if (bBC) { - iYear = -iYear; - iDays = iYearDays - iDays; - } - break; - } - iYear++; - iDays -= iYearDays; - } - while (TRUE) { - int32_t iMonthDays = FX_DaysInMonth(iYear, iMonth); - if (iDays < iMonthDays) { - break; - } - iMonth++; - iDays -= iMonthDays; - } - iDay += (uint8_t)iDays; -} - -struct FXUT_SYSTEMTIME { - FX_WORD wYear; - FX_WORD wMonth; - FX_WORD wDayOfWeek; - FX_WORD wDay; - FX_WORD wHour; - FX_WORD wMinute; - FX_WORD wSecond; - FX_WORD wMilliseconds; -}; - -void CFX_Unitime::Now() { - FXUT_SYSTEMTIME utLocal; -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ - ::GetLocalTime((LPSYSTEMTIME)&utLocal); -#elif _FX_OS_ != _FX_EMBEDDED_ -#if 1 - timeval curTime; - gettimeofday(&curTime, NULL); -#else - struct timespec curTime; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); -#endif - struct tm st; - localtime_r(&curTime.tv_sec, &st); - utLocal.wYear = st.tm_year + 1900; - utLocal.wMonth = st.tm_mon + 1; - utLocal.wDayOfWeek = st.tm_wday; - utLocal.wDay = st.tm_mday; - utLocal.wHour = st.tm_hour; - utLocal.wMinute = st.tm_min; - utLocal.wSecond = st.tm_sec; - utLocal.wMilliseconds = curTime.tv_usec / 1000; -#endif - Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, - (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, - (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); -} -void CFX_Unitime::SetGMTime() { - FXUT_SYSTEMTIME utLocal; -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ - ::GetSystemTime((LPSYSTEMTIME)&utLocal); -#elif _FX_OS_ != _FX_EMBEDDED_ -#if 1 - timeval curTime; - gettimeofday(&curTime, NULL); -#else - struct timespec curTime; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); -#endif - struct tm st; - gmtime_r(&curTime.tv_sec, &st); - utLocal.wYear = st.tm_year + 1900; - utLocal.wMonth = st.tm_mon + 1; - utLocal.wDayOfWeek = st.tm_wday; - utLocal.wDay = st.tm_mday; - utLocal.wHour = st.tm_hour; - utLocal.wMinute = st.tm_min; - utLocal.wSecond = st.tm_sec; - utLocal.wMilliseconds = curTime.tv_usec / 1000; -#endif - Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, - (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, - (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); -} -void CFX_Unitime::Set(int32_t year, - uint8_t month, - uint8_t day, - uint8_t hour, - uint8_t minute, - uint8_t second, - FX_WORD millisecond) { - FXSYS_assert(hour <= 23); - FXSYS_assert(minute <= 59); - FXSYS_assert(second <= 59); - FXSYS_assert(millisecond <= 999); - m_iUnitime = (int64_t)hour * g_FXMillisecondsPerHour + - (int64_t)minute * g_FXMillisecondsPerMinute + - (int64_t)second * g_FXMillisecondsPerSecond + millisecond; - if (year > 0) { - m_iUnitime = - m_iUnitime + - FX_DateToDays(year, month, day, FALSE) * g_FXMillisecondsPerDay; - } -} -void CFX_Unitime::Set(FX_UNITIME t) { - m_iUnitime = t; -} -int32_t CFX_Unitime::GetYear() const { - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - return iYear; -} -uint8_t CFX_Unitime::GetMonth() const { - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - return iMonth; -} -uint8_t CFX_Unitime::GetDay() const { - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - return iDay; -} -FX_WEEKDAY CFX_Unitime::GetDayOfWeek() const { - int32_t v = (int32_t)((m_iUnitime / g_FXMillisecondsPerDay + 1) % 7); - if (v < 0) { - v += 7; - } - return (FX_WEEKDAY)v; -} -FX_WORD CFX_Unitime::GetDayOfYear() const { - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - return FX_DaysBeforeMonthInYear(iYear, iMonth) + iDay; -} -int64_t CFX_Unitime::GetDayOfAD() const { - FX_BOOL bBC = m_iUnitime < 0; - int64_t iDays = m_iUnitime / g_FXMillisecondsPerDay; - iDays += bBC ? -1 : 0; - if (bBC && (m_iUnitime % g_FXMillisecondsPerDay) == 0) { - iDays++; - } - return iDays; -} -uint8_t CFX_Unitime::GetHour() const { - int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerDay); - if (v < 0) { - v += g_FXMillisecondsPerDay; - } - return (uint8_t)(v / g_FXMillisecondsPerHour); -} -uint8_t CFX_Unitime::GetMinute() const { - int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerHour); - if (v < 0) { - v += g_FXMillisecondsPerHour; - } - return (uint8_t)(v / g_FXMillisecondsPerMinute); -} -uint8_t CFX_Unitime::GetSecond() const { - int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerMinute); - if (v < 0) { - v += g_FXMillisecondsPerMinute; - } - return (uint8_t)(v / g_FXMillisecondsPerSecond); -} -FX_WORD CFX_Unitime::GetMillisecond() const { - int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerSecond); - if (v < 0) { - v += g_FXMillisecondsPerSecond; - } - return (FX_WORD)v; -} -FX_BOOL CFX_Unitime::AddYears(int32_t iYears) { - FX_UNITIME ut = m_iUnitime; - if (ut < 0) { - ut = -ut; - } - FX_UNITIME r = ut % g_FXMillisecondsPerDay; - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - iYear += iYears; - if (iYear == 0) { - iYear = iYears > 0 ? 1 : -1; - } - m_iUnitime = - FX_DateToDays(iYear, iMonth, iDay, FALSE) * g_FXMillisecondsPerDay; - m_iUnitime += (iYear < 0) ? -r : r; - return TRUE; -} -FX_BOOL CFX_Unitime::AddMonths(int32_t iMonths) { - FX_BOOL b = iMonths > 0; - FX_UNITIME ut = m_iUnitime; - if (ut < 0) { - ut = -ut; - } - FX_UNITIME r = ut % g_FXMillisecondsPerDay; - int32_t iYear; - uint8_t iMonth, iDay; - FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); - iMonths += iMonth; - while (iMonths < 1) { - iYear--, iMonths += 12; - } - while (iMonths > 12) { - iYear++, iMonths -= 12; - } - if (iYear == 0) { - iYear = b ? 1 : -1; - } - m_iUnitime = FX_DateToDays(iYear, (uint8_t)iMonths, iDay, FALSE) * - g_FXMillisecondsPerDay; - m_iUnitime += (iYear < 0) ? -r : r; - return TRUE; -} -FX_BOOL CFX_Unitime::AddDays(int32_t iDays) { - m_iUnitime += (int64_t)iDays * g_FXMillisecondsPerDay; - return TRUE; -} -FX_BOOL CFX_Unitime::AddHours(int32_t iHours) { - m_iUnitime += (int64_t)iHours * g_FXMillisecondsPerHour; - return TRUE; -} -FX_BOOL CFX_Unitime::AddMinutes(int32_t iMinutes) { - m_iUnitime += (int64_t)iMinutes * g_FXMillisecondsPerMinute; - return TRUE; -} -FX_BOOL CFX_Unitime::AddSeconds(int32_t iSeconds) { - m_iUnitime += ((int64_t)iSeconds) * g_FXMillisecondsPerSecond; - return TRUE; -} -FX_BOOL CFX_Unitime::AddMilliseconds(int32_t iMilliseconds) { - m_iUnitime += iMilliseconds; - return TRUE; -} -FX_BOOL CFX_DateTime::Set(int32_t year, - uint8_t month, - uint8_t day, - uint8_t hour, - uint8_t minute, - uint8_t second, - FX_WORD millisecond) { - ASSERT(year != 0); - ASSERT(month >= 1 && month <= 12); - ASSERT(day >= 1 && day <= FX_DaysInMonth(year, month)); - ASSERT(hour <= 23); - ASSERT(minute <= 59); - ASSERT(second <= 59); - ASSERT(millisecond <= 999); - m_DateTime.Date.sDate.year = year; - m_DateTime.Date.sDate.month = month; - m_DateTime.Date.sDate.day = day; - m_DateTime.Time.sTime.hour = hour; - m_DateTime.Time.sTime.minute = minute; - m_DateTime.Time.sTime.second = second; - m_DateTime.Time.sTime.millisecond = millisecond; - return TRUE; -} -FX_BOOL CFX_DateTime::FromUnitime(FX_UNITIME t) { - CFX_Unitime ut(t); - FX_DaysToDate(ut.GetDayOfAD(), m_DateTime.Date.sDate.year, - m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day); - m_DateTime.Date.sDate.day = ut.GetHour(); - m_DateTime.Time.sTime.minute = ut.GetMinute(); - m_DateTime.Time.sTime.second = ut.GetSecond(); - m_DateTime.Time.sTime.millisecond = ut.GetMillisecond(); - return TRUE; -} -FX_UNITIME CFX_DateTime::ToUnitime() const { - FX_UNITIME v = - (int64_t)m_DateTime.Date.sDate.day * g_FXMillisecondsPerHour + - (int64_t)m_DateTime.Time.sTime.minute * g_FXMillisecondsPerMinute + - (int64_t)m_DateTime.Time.sTime.second * g_FXMillisecondsPerSecond + - m_DateTime.Time.sTime.millisecond; - v += FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, - m_DateTime.Date.sDate.day, FALSE) * - g_FXMillisecondsPerDay; - return v; -} -int32_t CFX_DateTime::GetYear() const { - return m_DateTime.Date.sDate.year; -} -uint8_t CFX_DateTime::GetMonth() const { - return m_DateTime.Date.sDate.month; -} -uint8_t CFX_DateTime::GetDay() const { - return m_DateTime.Date.sDate.day; -} -FX_WEEKDAY CFX_DateTime::GetDayOfWeek() const { - int32_t v = (int32_t)(FX_DateToDays(m_DateTime.Date.sDate.year, - m_DateTime.Date.sDate.month, - m_DateTime.Date.sDate.day, TRUE) % - 7); - if (v < 0) { - v += 7; - } - return (FX_WEEKDAY)v; -} -FX_WORD CFX_DateTime::GetDayOfYear() const { - return FX_DaysBeforeMonthInYear(m_DateTime.Date.sDate.year, - m_DateTime.Date.sDate.month) + - m_DateTime.Date.sDate.day; -} -int64_t CFX_DateTime::GetDayOfAD() const { - return FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, - m_DateTime.Date.sDate.day, TRUE); -} -uint8_t CFX_DateTime::GetHour() const { - return m_DateTime.Date.sDate.day; -} -uint8_t CFX_DateTime::GetMinute() const { - return m_DateTime.Time.sTime.minute; -} -uint8_t CFX_DateTime::GetSecond() const { - return m_DateTime.Time.sTime.second; -} -FX_WORD CFX_DateTime::GetMillisecond() const { - return m_DateTime.Time.sTime.millisecond; -} -FX_BOOL CFX_DateTime::AddYears(int32_t iYears) { - if (iYears == 0) { - return FALSE; - } - int32_t v = m_DateTime.Date.sDate.year + iYears; - if (v >= 0 && m_DateTime.Date.sDate.year < 0) { - v++; - } else if (v <= 0 && m_DateTime.Date.sDate.year > 0) { - v--; - } - m_DateTime.Date.sDate.year = v; - return TRUE; -} -FX_BOOL CFX_DateTime::AddMonths(int32_t iMonths) { - if (iMonths == 0) { - return FALSE; - } - FX_BOOL b = iMonths > 0; - iMonths += m_DateTime.Date.sDate.month; - while (iMonths < 1) { - m_DateTime.Date.sDate.year--; - if (m_DateTime.Date.sDate.year == 0) { - m_DateTime.Date.sDate.year = -1; - } - iMonths += 12; - } - while (iMonths > 12) { - m_DateTime.Date.sDate.year++; - if (m_DateTime.Date.sDate.year == 0) { - m_DateTime.Date.sDate.year = 1; - } - iMonths -= 12; - } - if (m_DateTime.Date.sDate.year == 0) { - m_DateTime.Date.sDate.year = b ? 1 : -1; - } - m_DateTime.Date.sDate.month = (uint8_t)iMonths; - return TRUE; -} -FX_BOOL CFX_DateTime::AddDays(int32_t iDays) { - if (iDays == 0) { - return FALSE; - } - int64_t v1 = - FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, - m_DateTime.Date.sDate.day, TRUE); - int64_t v2 = v1 + iDays; - if (v2 <= 0 && v1 > 0) { - v2--; - } else if (v2 >= 0 && v1 < 0) { - v2++; - } - FX_DaysToDate(v2, m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, - m_DateTime.Date.sDate.day); - return TRUE; -} -FX_BOOL CFX_DateTime::AddHours(int32_t iHours) { - if (iHours == 0) { - return FALSE; - } - iHours += m_DateTime.Date.sDate.day; - int32_t iDays = iHours / 24; - iHours %= 24; - if (iHours < 0) { - iDays--, iHours += 24; - } - m_DateTime.Date.sDate.day = (uint8_t)iHours; - if (iDays != 0) { - AddDays(iDays); - } - return TRUE; -} -FX_BOOL CFX_DateTime::AddMinutes(int32_t iMinutes) { - if (iMinutes == 0) { - return FALSE; - } - iMinutes += m_DateTime.Time.sTime.minute; - int32_t iHours = iMinutes / 60; - iMinutes %= 60; - if (iMinutes < 0) { - iHours--, iMinutes += 60; - } - m_DateTime.Time.sTime.minute = (uint8_t)iMinutes; - if (iHours != 0) { - AddHours(iHours); - } - return TRUE; -} -FX_BOOL CFX_DateTime::AddSeconds(int32_t iSeconds) { - if (iSeconds == 0) { - return FALSE; - } - iSeconds += m_DateTime.Time.sTime.second; - int32_t iMinutes = iSeconds / 60; - iSeconds %= 60; - if (iSeconds < 0) { - iMinutes--, iSeconds += 60; - } - m_DateTime.Time.sTime.second = (uint8_t)iSeconds; - if (iMinutes != 0) { - AddMinutes(iMinutes); - } - return TRUE; -} -FX_BOOL CFX_DateTime::AddMilliseconds(int32_t iMilliseconds) { - if (iMilliseconds == 0) { - return FALSE; - } - iMilliseconds += m_DateTime.Time.sTime.millisecond; - int32_t iSeconds = (int32_t)(iMilliseconds / g_FXMillisecondsPerSecond); - iMilliseconds %= g_FXMillisecondsPerSecond; - if (iMilliseconds < 0) { - iSeconds--, iMilliseconds += g_FXMillisecondsPerSecond; - } - m_DateTime.Time.sTime.millisecond = (FX_WORD)iMilliseconds; - if (iSeconds != 0) { - AddSeconds(iSeconds); - } - return TRUE; -} diff --git a/xfa/src/fgas/localization/fgas_datetime.h b/xfa/src/fgas/localization/fgas_datetime.h deleted file mode 100644 index 5dd70ccc65..0000000000 --- a/xfa/src/fgas/localization/fgas_datetime.h +++ /dev/null @@ -1,406 +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_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ -#define XFA_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ - -#include "core/include/fxcrt/fx_system.h" - -class CFX_Unitime; -class CFX_DateTime; - -typedef int64_t FX_UNITIME; -enum FX_WEEKDAY { - FX_Sunday = 0, - FX_Monday, - FX_Tuesday, - FX_Wednesday, - FX_Thursday, - FX_Friday, - FX_Saturday, -}; - -FX_BOOL FX_IsLeapYear(int32_t iYear); -int32_t FX_DaysInYear(int32_t iYear); -uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); - -class CFX_Unitime { - public: - CFX_Unitime() { m_iUnitime = 0; } - CFX_Unitime(FX_UNITIME iUnitime) { m_iUnitime = iUnitime; } - CFX_Unitime(const CFX_Unitime& unitime) { m_iUnitime = unitime.m_iUnitime; } - operator FX_UNITIME*() { return &m_iUnitime; } - operator FX_UNITIME const*() const { return &m_iUnitime; } - operator FX_UNITIME&() { return m_iUnitime; } - operator const FX_UNITIME&() const { return m_iUnitime; } - CFX_Unitime& operator=(const CFX_Unitime& t) { - m_iUnitime = t.m_iUnitime; - return *this; - } - CFX_Unitime& operator=(FX_UNITIME t) { - m_iUnitime = t; - return *this; - } - CFX_Unitime& operator+=(const CFX_Unitime& t) { - m_iUnitime += t.m_iUnitime; - return *this; - } - CFX_Unitime& operator+=(FX_UNITIME t) { - m_iUnitime += t; - return *this; - } - CFX_Unitime& operator-=(const CFX_Unitime& t) { - m_iUnitime -= t.m_iUnitime; - return *this; - } - CFX_Unitime& operator-=(FX_UNITIME t) { - m_iUnitime -= t; - return *this; - } - void Now(); - void SetGMTime(); - void Set(int32_t year, - uint8_t month, - uint8_t day, - uint8_t hour = 0, - uint8_t minute = 0, - uint8_t second = 0, - FX_WORD millisecond = 0); - void Set(FX_UNITIME t); - int32_t GetYear() const; - uint8_t GetMonth() const; - uint8_t GetDay() const; - FX_WEEKDAY GetDayOfWeek() const; - FX_WORD GetDayOfYear() const; - int64_t GetDayOfAD() const; - uint8_t GetHour() const; - uint8_t GetMinute() const; - uint8_t GetSecond() const; - FX_WORD GetMillisecond() const; - FX_BOOL AddYears(int32_t iYears); - FX_BOOL AddMonths(int32_t iMonths); - FX_BOOL AddDays(int32_t iDays); - FX_BOOL AddHours(int32_t iHours); - FX_BOOL AddMinutes(int32_t iMinutes); - FX_BOOL AddSeconds(int32_t iSeconds); - FX_BOOL AddMilliseconds(int32_t iMilliseconds); - friend CFX_Unitime operator+(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime); - } - friend CFX_Unitime operator+(const CFX_Unitime& t1, FX_UNITIME t2) { - return CFX_Unitime(t1.m_iUnitime + t2); - } - friend CFX_Unitime operator+(FX_UNITIME t1, const CFX_Unitime& t2) { - return CFX_Unitime(t1 + t2.m_iUnitime); - } - friend CFX_Unitime operator-(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime); - } - friend CFX_Unitime operator-(const CFX_Unitime& t1, FX_UNITIME t2) { - return CFX_Unitime(t1.m_iUnitime + t2); - } - friend CFX_Unitime operator-(FX_UNITIME t1, const CFX_Unitime& t2) { - return CFX_Unitime(t1 + t2.m_iUnitime); - } - friend bool operator==(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime == t2.m_iUnitime; - } - friend bool operator==(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime == t2; - } - friend bool operator==(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 == t2.m_iUnitime; - } - friend bool operator!=(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime != t2.m_iUnitime; - } - friend bool operator!=(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime != t2; - } - friend bool operator!=(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 != t2.m_iUnitime; - } - friend bool operator>(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime > t2.m_iUnitime; - } - friend bool operator>(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime > t2; - } - friend bool operator>(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 > t2.m_iUnitime; - } - friend bool operator>=(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime >= t2.m_iUnitime; - } - friend bool operator>=(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime >= t2; - } - friend bool operator>=(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 >= t2.m_iUnitime; - } - friend bool operator<(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime < t2.m_iUnitime; - } - friend bool operator<(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime < t2; - } - friend bool operator<(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 < t2.m_iUnitime; - } - friend bool operator<=(const CFX_Unitime& t1, const CFX_Unitime& t2) { - return t1.m_iUnitime <= t2.m_iUnitime; - } - friend bool operator<=(const CFX_Unitime& t1, FX_UNITIME t2) { - return t1.m_iUnitime <= t2; - } - friend bool operator<=(FX_UNITIME t1, const CFX_Unitime& t2) { - return t1 <= t2.m_iUnitime; - } - - private: - FX_UNITIME m_iUnitime; -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -struct FX_DATE { - int32_t year; - uint8_t month; - uint8_t day; -}; - -struct FX_TIME { - uint8_t hour; - uint8_t minute; - uint8_t second; - FX_WORD millisecond; -}; - -struct FX_TIMEZONE { - int8_t tzHour; - uint8_t tzMinute; -}; - -struct FX_DATETIME { - union { - struct { - int32_t year; - uint8_t month; - uint8_t day; - } sDate; - FX_DATE aDate; - } Date; - union { - struct { - uint8_t hour; - uint8_t minute; - uint8_t second; - FX_WORD millisecond; - } sTime; - FX_TIME aTime; - } 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; - FX_WORD 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 - -class CFX_DateTime { - public: - CFX_DateTime() {} - CFX_DateTime(const FX_DATETIME& dt) { m_DateTime = dt; } - CFX_DateTime(const CFX_DateTime& dt) { m_DateTime = dt.m_DateTime; } - virtual ~CFX_DateTime() {} - operator FX_DATETIME*() { return &m_DateTime; } - operator const FX_DATETIME*() const { return &m_DateTime; } - operator FX_DATETIME&() { return m_DateTime; } - operator const FX_DATETIME&() const { return m_DateTime; } - CFX_DateTime& operator=(const CFX_DateTime& dt) { - m_DateTime = dt.m_DateTime; - return *this; - } - CFX_DateTime& operator=(const FX_DATETIME& dt) { - m_DateTime = dt; - return *this; - } - CFX_DateTime& operator+=(const CFX_DateTime& dt) { - FromUnitime(ToUnitime() + dt.ToUnitime()); - return *this; - } - CFX_DateTime& operator+=(const FX_DATETIME& dt) { - FromUnitime(ToUnitime() + ((const CFX_DateTime&)dt).ToUnitime()); - return *this; - } - CFX_DateTime& operator-=(const CFX_DateTime& dt) { - FromUnitime(ToUnitime() - dt.ToUnitime()); - return *this; - } - CFX_DateTime& operator-=(const FX_DATETIME& dt) { - FromUnitime(ToUnitime() - ((const CFX_DateTime&)dt).ToUnitime()); - return *this; - } - virtual FX_BOOL Set(int32_t year, - uint8_t month, - uint8_t day, - uint8_t hour = 0, - uint8_t minute = 0, - uint8_t second = 0, - FX_WORD millisecond = 0); - virtual FX_BOOL FromUnitime(FX_UNITIME t); - virtual FX_UNITIME ToUnitime() const; - virtual int32_t GetYear() const; - virtual uint8_t GetMonth() const; - virtual uint8_t GetDay() const; - virtual FX_WEEKDAY GetDayOfWeek() const; - virtual FX_WORD GetDayOfYear() const; - virtual int64_t GetDayOfAD() const; - virtual uint8_t GetHour() const; - virtual uint8_t GetMinute() const; - virtual uint8_t GetSecond() const; - virtual FX_WORD GetMillisecond() const; - virtual FX_BOOL AddYears(int32_t iYears); - virtual FX_BOOL AddMonths(int32_t iMonths); - virtual FX_BOOL AddDays(int32_t iDays); - virtual FX_BOOL AddHours(int32_t iHours); - virtual FX_BOOL AddMinutes(int32_t iMinutes); - virtual FX_BOOL AddSeconds(int32_t iSeconds); - virtual FX_BOOL AddMilliseconds(int32_t iMilliseconds); - friend CFX_DateTime operator+(const CFX_DateTime& dt1, - const CFX_DateTime& dt2) { - CFX_DateTime dt; - dt.FromUnitime(dt1.ToUnitime() + dt2.ToUnitime()); - return dt; - } - friend CFX_DateTime operator+(const CFX_DateTime& dt1, - const FX_DATETIME& dt2) { - CFX_DateTime dt; - dt.FromUnitime(dt1.ToUnitime() + ((const CFX_DateTime&)dt2).ToUnitime()); - return dt; - } - friend CFX_DateTime operator+(const FX_DATETIME& dt1, - const CFX_DateTime& dt2) { - CFX_DateTime dt; - dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() + dt2.ToUnitime()); - return dt; - } - friend CFX_DateTime operator-(const CFX_DateTime& dt1, - const CFX_DateTime& dt2) { - CFX_DateTime dt; - dt.FromUnitime(dt1.ToUnitime() - dt2.ToUnitime()); - return dt; - } - friend CFX_DateTime operator-(const CFX_DateTime& dt1, - const FX_DATETIME& dt2) { - CFX_DateTime dt; - dt.FromUnitime(dt1.ToUnitime() - ((const CFX_DateTime&)dt2).ToUnitime()); - return dt; - } - friend CFX_DateTime operator-(const FX_DATETIME& dt1, - const CFX_DateTime& dt2) { - CFX_DateTime dt; - dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() - dt2.ToUnitime()); - return dt; - } - friend FX_BOOL operator==(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), - static_cast<const FX_DATETIME*>(dt2), - sizeof(FX_DATETIME)) == 0; - } - friend FX_BOOL operator==(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), &dt2, - sizeof(FX_DATETIME)) == 0; - } - friend FX_BOOL operator==(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return FXSYS_memcmp(&dt1, static_cast<const FX_DATETIME*>(dt2), - sizeof(FX_DATETIME)) == 0; - } - friend FX_BOOL operator!=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), - static_cast<const FX_DATETIME*>(dt2), - sizeof(FX_DATETIME)) != 0; - } - friend FX_BOOL operator!=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return FXSYS_memcmp(static_cast<const FX_DATETIME*>(dt1), &dt2, - sizeof(FX_DATETIME)) != 0; - } - friend FX_BOOL operator!=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return FXSYS_memcmp(&dt1, static_cast<const FX_DATETIME*>(dt2), - sizeof(FX_DATETIME)) != 0; - } - friend FX_BOOL operator>(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return dt1.ToUnitime() > dt2.ToUnitime(); - } - friend FX_BOOL operator>(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return dt1.ToUnitime() > ((const CFX_DateTime&)dt2).ToUnitime(); - } - friend FX_BOOL operator>(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return ((const CFX_DateTime&)dt1).ToUnitime() > dt2.ToUnitime(); - } - friend FX_BOOL operator>=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return dt1.ToUnitime() >= dt2.ToUnitime(); - } - friend FX_BOOL operator>=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return dt1.ToUnitime() >= ((const CFX_DateTime&)dt2).ToUnitime(); - } - friend FX_BOOL operator>=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return ((const CFX_DateTime&)dt1).ToUnitime() >= dt2.ToUnitime(); - } - friend FX_BOOL operator<(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return dt1.ToUnitime() < dt2.ToUnitime(); - } - friend FX_BOOL operator<(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return dt1.ToUnitime() < ((const CFX_DateTime&)dt2).ToUnitime(); - } - friend FX_BOOL operator<(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return ((const CFX_DateTime&)dt1).ToUnitime() < dt2.ToUnitime(); - } - friend FX_BOOL operator<=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) { - return dt1.ToUnitime() <= dt2.ToUnitime(); - } - friend FX_BOOL operator<=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) { - return dt1.ToUnitime() <= ((const CFX_DateTime&)dt2).ToUnitime(); - } - friend FX_BOOL operator<=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) { - return ((const CFX_DateTime&)dt1).ToUnitime() <= dt2.ToUnitime(); - } - - private: - FX_DATETIME m_DateTime; -}; - -#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_DATETIME_H_ diff --git a/xfa/src/fgas/localization/fgas_locale.cpp b/xfa/src/fgas/localization/fgas_locale.cpp deleted file mode 100644 index 1eaa0ebd48..0000000000 --- a/xfa/src/fgas/localization/fgas_locale.cpp +++ /dev/null @@ -1,5030 +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 <algorithm> - -#include "core/include/fxcrt/fx_ext.h" -#include "core/include/fxcrt/fx_xml.h" -#include "xfa/src/fgas/localization/fgas_localeimp.h" - -#define FX_LOCALECATEGORY_DateHash 0xbde9abde -#define FX_LOCALECATEGORY_TimeHash 0x2d71b00f -#define FX_LOCALECATEGORY_DateTimeHash 0x158c72ed -#define FX_LOCALECATEGORY_NumHash 0x0b4ff870 -#define FX_LOCALECATEGORY_TextHash 0x2d08af85 -#define FX_LOCALECATEGORY_ZeroHash 0x568cb500 -#define FX_LOCALECATEGORY_NullHash 0x052931bb - -struct FX_LOCALESUBCATEGORYINFO { - uint32_t uHash; - const FX_WCHAR* pName; - int32_t eSubCategory; -}; - -static const FX_LOCALESUBCATEGORYINFO g_FXLocaleDateTimeSubCatData[] = { - {0x14da2125, L"default", FX_LOCALEDATETIMESUBCATEGORY_Default}, - {0x9041d4b0, L"short", FX_LOCALEDATETIMESUBCATEGORY_Short}, - {0xa084a381, L"medium", FX_LOCALEDATETIMESUBCATEGORY_Medium}, - {0xcdce56b3, L"full", FX_LOCALEDATETIMESUBCATEGORY_Full}, - {0xf6b4afb0, L"long", FX_LOCALEDATETIMESUBCATEGORY_Long}, -}; -static const int32_t g_iFXLocaleDateTimeSubCatCount = - sizeof(g_FXLocaleDateTimeSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); - -static const FX_LOCALESUBCATEGORYINFO g_FXLocaleNumSubCatData[] = { - {0x46f95531, L"percent", FX_LOCALENUMPATTERN_Percent}, - {0x4c4e8acb, L"currency", FX_LOCALENUMPATTERN_Currency}, - {0x54034c2f, L"decimal", FX_LOCALENUMPATTERN_Decimal}, - {0x7568e6ae, L"integer", FX_LOCALENUMPATTERN_Integer}, -}; -static const int32_t g_iFXLocaleNumSubCatCount = - sizeof(g_FXLocaleNumSubCatData) / sizeof(FX_LOCALESUBCATEGORYINFO); - -struct FX_LOCALETIMEZONEINFO { - FX_DWORD uHash; - int16_t iHour; - int16_t iMinute; -}; - -static const FX_LOCALETIMEZONEINFO g_FXLocaleTimeZoneData[] = { - {FXBSTR_ID(0, 'C', 'D', 'T'), -5, 0}, {FXBSTR_ID(0, 'C', 'S', 'T'), -6, 0}, - {FXBSTR_ID(0, 'E', 'D', 'T'), -4, 0}, {FXBSTR_ID(0, 'E', 'S', 'T'), -5, 0}, - {FXBSTR_ID(0, 'M', 'D', 'T'), -6, 0}, {FXBSTR_ID(0, 'M', 'S', 'T'), -7, 0}, - {FXBSTR_ID(0, 'P', 'D', 'T'), -7, 0}, {FXBSTR_ID(0, 'P', 'S', 'T'), -8, 0}, -}; - -static const CFX_WideStringC gs_wsTextSymbols = FX_WSTRC(L"AXO09"); -static const CFX_WideStringC gs_wsTimeSymbols = FX_WSTRC(L"hHkKMSFAzZ"); -static const CFX_WideStringC gs_wsDateSymbols = FX_WSTRC(L"DJMEeGgYwW"); -static const CFX_WideStringC gs_wsConstChars = FX_WSTRC(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.GetPtr() + nStart, ch); - return (lpsz == NULL) ? -1 : (FX_STRSIZE)(lpsz - wsSymbols.GetPtr()); -} -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); -} -CFX_Locale::CFX_Locale(CXML_Element* pLocaleData) { - m_pElement = pLocaleData; -} -CFX_Locale::~CFX_Locale() {} -CFX_WideString CFX_Locale::GetName() { - return CFX_WideString(); -} -static CFX_WideString FX_GetXMLContent(const CFX_ByteStringC& bsSpace, - CXML_Element* pxmlElement, - const CFX_ByteStringC& bsTag, - const CFX_WideStringC& wsName) { - CXML_Element* pDatePattern = NULL; - int32_t nCount = pxmlElement->CountElements(bsSpace, bsTag); - int32_t i = 0; - for (; i < nCount; i++) { - pDatePattern = pxmlElement->GetElement(bsSpace, bsTag, i); - if (pDatePattern->GetAttrValue("name") == wsName) { - break; - } - } - if (i < nCount && pDatePattern) { - return pDatePattern->GetContent(0); - } - return L""; -} -void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const { - if (!m_pElement) { - return; - } - CFX_ByteString bsSpace; - CFX_WideString wsName = gs_LocalNumberSymbols[eType]; - CXML_Element* pNumberSymbols = - m_pElement->GetElement(bsSpace, "numberSymbols"); - if (!pNumberSymbols) { - return; - } - wsNumSymbol = - FX_GetXMLContent(bsSpace, pNumberSymbols, "numberSymbol", wsName); -} -void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { - if (!m_pElement) { - return; - } - CFX_ByteString bsSpace; - CXML_Element* pNumberSymbols = - m_pElement->GetElement(bsSpace, "dateTimeSymbols"); - if (!pNumberSymbols) { - return; - } - wsDtSymbol = pNumberSymbols->GetContent(0); -} -static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, - const CFX_ByteString& symbol_type, - int32_t index, - FX_BOOL bAbbr, - CFX_WideString& wsName) { - CFX_ByteString bsSpace; - CFX_ByteString pstrSymbolNames = symbol_type + "Names"; - CXML_Element* pChild = pXmlElement->GetElement(bsSpace, "calendarSymbols"); - if (!pChild) { - return; - } - CXML_Element* pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames); - if (!pSymbolNames) { - return; - } - if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { - pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames, 1); - } - if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { - CXML_Element* pSymbolName = - pSymbolNames->GetElement(bsSpace, symbol_type, index); - if (pSymbolName) { - wsName = pSymbolName->GetContent(0); - } - } -} -void CFX_Locale::GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr) const { - if (!m_pElement) { - return; - } - FX_GetCalendarSymbol(m_pElement, "month", nMonth, bAbbr, wsMonthName); -} -void CFX_Locale::GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr) const { - if (!m_pElement) { - return; - } - FX_GetCalendarSymbol(m_pElement, "day", nWeek, bAbbr, wsDayName); -} -void CFX_Locale::GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM) const { - if (!m_pElement) { - return; - } - FX_GetCalendarSymbol(m_pElement, "meridiem", bAM ? 0 : 1, FALSE, - wsMeridiemName); -} -static int32_t FX_ParseTimeZone(const FX_WCHAR* pStr, - int32_t iLen, - FX_TIMEZONE& tz) { - tz.tzHour = 0; - tz.tzMinute = 0; - if (iLen < 0) { - return 0; - } - int32_t iStart = 1; - int32_t iEnd = iStart + 2; - while (iStart < iLen && iStart < iEnd) { - tz.tzHour = tz.tzHour * 10 + pStr[iStart++] - '0'; - } - if (iStart < iLen && pStr[iStart] == ':') { - iStart++; - } - iEnd = iStart + 2; - while (iStart < iLen && iStart < iEnd) { - tz.tzMinute = tz.tzMinute * 10 + pStr[iStart++] - '0'; - } - if (pStr[0] == '-') { - tz.tzHour = -tz.tzHour; - } - return iStart; -} -void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { - tz.tzHour = 0; - tz.tzMinute = 0; - if (!m_pElement) { - return; - } - CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone"); - if (pxmlTimeZone) { - CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); - FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz); - } -} -void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { - if (!m_pElement) { - return; - } - FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); -} -static void FX_GetPattern(CXML_Element* pXmlElement, - const CFX_ByteString& bsCategory, - const CFX_WideString& wsSubCategory, - CFX_WideString& wsPattern) { - CFX_ByteString bsSpace; - CXML_Element* pDatePatterns = - pXmlElement->GetElement(bsSpace, bsCategory + "s"); - if (!pDatePatterns) { - return; - } - wsPattern = - FX_GetXMLContent(bsSpace, pDatePatterns, bsCategory, wsSubCategory); -} -static void FX_GetDateTimePattern(CXML_Element* pXmlElement, - const CFX_ByteString& bsCategory, - FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) { - CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; - FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); -} -void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - if (!m_pElement) { - return; - } - FX_GetDateTimePattern(m_pElement, "datePattern", eType, wsPattern); -} -void CFX_Locale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - if (!m_pElement) { - return; - } - FX_GetDateTimePattern(m_pElement, "timePattern", eType, wsPattern); -} -void CFX_Locale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const { - CFX_WideString wsType = g_FXLocaleNumSubCatData[eType].pName; - FX_GetPattern(m_pElement, "numberPattern", wsType, wsPattern); -} -static FX_BOOL FX_IsDigit(FX_WCHAR c) { - return c >= '0' && c <= '9'; -} -static FX_BOOL FX_IsAlpha(FX_WCHAR c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); -} -static FX_BOOL FX_IsSpace(FX_WCHAR c) { - return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09); -} -static const FX_FLOAT gs_fraction_scales[] = { - 0.1f, 0.01f, 0.001f, 0.0001f, - 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, - 0.000000001f, 0.0000000001f, 0.00000000001f}; -static const int32_t gs_fraction_count = - sizeof(gs_fraction_scales) / sizeof(FX_FLOAT); - -class CFX_LCNumeric { - public: - CFX_LCNumeric(); - CFX_LCNumeric(int64_t integral, - uint32_t fractional = 0, - int32_t exponent = 0); - CFX_LCNumeric(FX_FLOAT dbRetValue); - CFX_LCNumeric(double dbvalue); - CFX_LCNumeric(CFX_WideString& wsNumeric); - - FX_FLOAT GetFloat() const; - double GetDouble() const; - CFX_WideString ToString() const; - CFX_WideString ToString(int32_t nTreading, FX_BOOL bTrimTailZeros) const; - - int64_t m_Integral; - uint32_t m_Fractional; - int32_t m_Exponent; -}; - -static FX_BOOL FX_WStringToNumeric(const CFX_WideString& wsValue, - CFX_LCNumeric& lcnum) { - lcnum.m_Integral = 0; - lcnum.m_Fractional = 0; - lcnum.m_Exponent = 0; - - if (wsValue.IsEmpty()) - return FALSE; - - const int32_t nIntegralMaxLen = 17; - int32_t cc = 0; - bool bNegative = false; - bool bExpSign = false; - const FX_WCHAR* str = (const FX_WCHAR*)wsValue; - int32_t len = wsValue.GetLength(); - while (cc < len && FX_IsSpace(str[cc])) - cc++; - - if (cc >= len) - return FALSE; - - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bNegative = true; - cc++; - } - int32_t nIntegralLen = 0; - while (cc < len) { - if (str[cc] == '.') - break; - - if (!FX_IsDigit(str[cc])) { - if ((str[cc] == 'E' || str[cc] == 'e')) - break; - else - return FALSE; - } - if (nIntegralLen < nIntegralMaxLen) { - lcnum.m_Integral = lcnum.m_Integral * 10 + str[cc] - '0'; - nIntegralLen++; - } - cc++; - } - - lcnum.m_Integral = bNegative ? -lcnum.m_Integral : lcnum.m_Integral; - if (cc < len && str[cc] == '.') { - int scale = 0; - double fraction = 0.0; - cc++; - while (cc < len) { - if (scale >= gs_fraction_count) { - while (cc < len) { - if (!FX_IsDigit(str[cc])) - break; - cc++; - } - } - if (!FX_IsDigit(str[cc])) { - if ((str[cc] == 'E' || str[cc] == 'e')) - break; - else - return FALSE; - } - fraction += gs_fraction_scales[scale] * (str[cc] - '0'); - scale++; - cc++; - } - lcnum.m_Fractional = (FX_DWORD)(fraction * 4294967296.0); - } - if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = true; - cc++; - } - } - while (cc < len) { - if (FX_IsDigit(str[cc])) - return FALSE; - lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; - cc++; - } - lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; - } - return TRUE; -} - -CFX_LCNumeric::CFX_LCNumeric() { - m_Integral = 0; - m_Fractional = 0; - m_Exponent = 0; -} -CFX_LCNumeric::CFX_LCNumeric(int64_t integral, - FX_DWORD fractional, - int32_t exponent) { - m_Integral = integral; - m_Fractional = fractional; - m_Exponent = exponent; -} -CFX_LCNumeric::CFX_LCNumeric(FX_FLOAT dbRetValue) { - m_Integral = (int64_t)dbRetValue; - m_Fractional = (FX_DWORD)(((dbRetValue > 0) ? (dbRetValue - m_Integral) - : (m_Integral - dbRetValue)) * - 4294967296); - m_Exponent = 0; -} -CFX_LCNumeric::CFX_LCNumeric(double dbvalue) { - m_Integral = (int64_t)dbvalue; - m_Fractional = (FX_DWORD)( - ((dbvalue > 0) ? (dbvalue - m_Integral) : (m_Integral - dbvalue)) * - 4294967296); - m_Exponent = 0; -} -CFX_LCNumeric::CFX_LCNumeric(CFX_WideString& wsNumeric) { - FX_WStringToNumeric(wsNumeric, *this); -} -FX_FLOAT CFX_LCNumeric::GetFloat() const { - FX_FLOAT dbRetValue = m_Fractional / 4294967296.0f; - dbRetValue = m_Integral + (m_Integral >= 0 ? dbRetValue : -dbRetValue); - if (m_Exponent != 0) { - dbRetValue *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); - } - return dbRetValue; -} -double CFX_LCNumeric::GetDouble() const { - double value = m_Fractional / 4294967296.0; - value = m_Integral + (m_Integral >= 0 ? value : -value); - if (m_Exponent != 0) { - value *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); - } - return value; -} - -CFX_WideString CFX_LCNumeric::ToString() const { - return ToString(8, TRUE); -} - -CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading, - FX_BOOL bTrimTailZeros) const { - CFX_WideString wsFormat; - wsFormat.Format(L"%%.%df", nTreading); - CFX_WideString wsResult; - wsResult.Format(wsFormat.c_str(), GetDouble()); - if (bTrimTailZeros && nTreading > 0) { - wsResult.TrimRight(L"0"); - wsResult.TrimRight(L"."); - } - 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* pToken = pStr; - const FX_WCHAR* pEnd = pStr + iStrLen; - FX_BOOL iQuote = FALSE; - while (TRUE) { - if (pStr >= pEnd) { - CFX_WideString sub(pToken, pStr - pToken); - wsPatterns.Add(sub); - return; - } else if (*pStr == '\'') { - iQuote = !iQuote; - } else if (*pStr == L'|' && !iQuote) { - CFX_WideString sub(pToken, pStr - pToken); - wsPatterns.Add(sub); - pToken = pStr + 1; - } - pStr++; - } -} -static CFX_WideString FX_GetLiteralText(const FX_WCHAR* pStrPattern, - int32_t& iPattern, - int32_t iLenPattern) { - CFX_WideString wsOutput; - if (pStrPattern[iPattern] != '\'') { - return wsOutput; - } - iPattern++; - int32_t iQuote = 1; - while (iPattern < iLenPattern) { - if (pStrPattern[iPattern] == '\'') { - iQuote++; - if ((iPattern + 1 >= iLenPattern) || - ((pStrPattern[iPattern + 1] != '\'') && (iQuote % 2 == 0))) { - break; - } else { - iQuote++; - } - iPattern++; - } else if (pStrPattern[iPattern] == '\\' && (iPattern + 1 < iLenPattern) && - pStrPattern[iPattern + 1] == 'u') { - int32_t iKeyValue = 0; - iPattern += 2; - int32_t i = 0; - while (iPattern < iLenPattern && i++ < 4) { - FX_WCHAR ch = pStrPattern[iPattern++]; - if ((ch >= '0' && ch <= '9')) { - iKeyValue = iKeyValue * 16 + ch - '0'; - } else if ((ch >= 'a' && ch <= 'f')) { - iKeyValue = iKeyValue * 16 + ch - 'a' + 10; - } else if ((ch >= 'A' && ch <= 'F')) { - iKeyValue = iKeyValue * 16 + ch - 'A' + 10; - } - } - if (iKeyValue != 0) { - wsOutput += (FX_WCHAR)(iKeyValue & 0x0000FFFF); - } - continue; - } - wsOutput += pStrPattern[iPattern++]; - } - return wsOutput; -} -static CFX_WideString FX_GetLiteralTextReverse(const FX_WCHAR* pStrPattern, - int32_t& iPattern) { - CFX_WideString wsOutput; - if (pStrPattern[iPattern] != '\'') { - return wsOutput; - } - iPattern--; - int32_t iQuote = 1; - while (iPattern >= 0) { - if (pStrPattern[iPattern] == '\'') { - iQuote++; - if (iPattern - 1 >= 0 || - ((pStrPattern[iPattern - 1] != '\'') && (iQuote % 2 == 0))) { - break; - } else { - iQuote++; - } - iPattern--; - } else if (pStrPattern[iPattern] == '\\' && - pStrPattern[iPattern + 1] == 'u') { - iPattern--; - int32_t iKeyValue = 0; - int32_t iLen = wsOutput.GetLength(); - int32_t i = 1; - for (; i < iLen && i < 5; i++) { - FX_WCHAR ch = wsOutput[i]; - if ((ch >= '0' && ch <= '9')) { - iKeyValue = iKeyValue * 16 + ch - '0'; - } else if ((ch >= 'a' && ch <= 'f')) { - iKeyValue = iKeyValue * 16 + ch - 'a' + 10; - } else if ((ch >= 'A' && ch <= 'F')) { - iKeyValue = iKeyValue * 16 + ch - 'A' + 10; - } - } - if (iKeyValue != 0) { - wsOutput.Delete(0, i); - wsOutput = (FX_WCHAR)(iKeyValue & 0x0000FFFF) + wsOutput; - } - continue; - } - wsOutput = pStrPattern[iPattern--] + wsOutput; - } - return wsOutput; -} -FX_LOCALECATEGORY CFX_FormatString::GetCategory( - const CFX_WideString& wsPattern) { - FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; - int32_t ccf = 0; - int32_t iLenf = wsPattern.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; - FX_BOOL bBraceOpen = FALSE; - while (ccf < iLenf) { - if (pStr[ccf] == '\'') { - FX_GetLiteralText(pStr, ccf, iLenf); - } else if (!bBraceOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) { - CFX_WideString wsCategory(pStr[ccf]); - ccf++; - while (TRUE) { - if (ccf == iLenf) { - return eCategory; - } - if (pStr[ccf] == '.' || pStr[ccf] == '(') { - break; - } - if (pStr[ccf] == '{') { - bBraceOpen = TRUE; - break; - } - wsCategory += pStr[ccf]; - ccf++; - } - FX_DWORD dwHash = - FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength()); - if (dwHash == FX_LOCALECATEGORY_DateHash) { - if (eCategory == FX_LOCALECATEGORY_Time) { - return FX_LOCALECATEGORY_DateTime; - } - eCategory = FX_LOCALECATEGORY_Date; - } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { - if (eCategory == FX_LOCALECATEGORY_Date) { - return FX_LOCALECATEGORY_DateTime; - } - eCategory = FX_LOCALECATEGORY_Time; - } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { - return FX_LOCALECATEGORY_DateTime; - } else if (dwHash == FX_LOCALECATEGORY_TextHash) { - return FX_LOCALECATEGORY_Text; - } else if (dwHash == FX_LOCALECATEGORY_NumHash) { - return FX_LOCALECATEGORY_Num; - } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { - return FX_LOCALECATEGORY_Zero; - } else if (dwHash == FX_LOCALECATEGORY_NullHash) { - return FX_LOCALECATEGORY_Null; - } - } else if (pStr[ccf] == '}') { - bBraceOpen = FALSE; - } - ccf++; - } - return eCategory; -} -static FX_WORD FX_WStringToLCID(const FX_WCHAR* pstrLCID) { - if (!pstrLCID) { - return 0; - } - wchar_t* pEnd; - return (FX_WORD)wcstol((wchar_t*)pstrLCID, &pEnd, 16); -} -FX_WORD CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { - return FX_WStringToLCID(GetLocaleName(wsPattern)); -} -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; - while (ccf < iLenf) { - if (pStr[ccf] == '\'') { - FX_GetLiteralText(pStr, ccf, iLenf); - } else if (pStr[ccf] == '(') { - ccf++; - CFX_WideString wsLCID; - while (ccf < iLenf && pStr[ccf] != ')') { - wsLCID += pStr[ccf++]; - } - return wsLCID; - } - ccf++; - } - return CFX_WideString(); -} -IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, - const CFX_WideStringC& wsCategory, - CFX_WideString& wsPurgePattern) { - IFX_Locale* pLocale = NULL; - int32_t ccf = 0; - int32_t iLenf = wsPattern.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; - FX_BOOL bBrackOpen = FALSE; - 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) { - CFX_WideString wsSearchCategory(pStr[ccf]); - ccf++; - while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && - pStr[ccf] != '(') { - wsSearchCategory += pStr[ccf]; - ccf++; - } - if (wsSearchCategory != wsCategory) { - continue; - } - while (ccf < iLenf) { - if (pStr[ccf] == '(') { - ccf++; - CFX_WideString wsLCID; - while (ccf < iLenf && pStr[ccf] != ')') { - wsLCID += pStr[ccf++]; - } - pLocale = GetPatternLocale(wsLCID); - } else if (pStr[ccf] == '{') { - bBrackOpen = TRUE; - break; - } - ccf++; - } - } else if (pStr[ccf] != '}') { - wsPurgePattern += pStr[ccf]; - } - ccf++; - } - if (!bBrackOpen) { - wsPurgePattern = wsPattern; - } - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - return pLocale; -} -#define FX_NUMSTYLE_Percent 0x01 -#define FX_NUMSTYLE_Exponent 0x02 -#define FX_NUMSTYLE_DotVorv 0x04 -IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, - int32_t& iDotIndex, - FX_DWORD& dwStyle, - CFX_WideString& wsPurgePattern) { - dwStyle = 0; - IFX_Locale* pLocale = NULL; - int32_t ccf = 0; - int32_t iLenf = wsPattern.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; - FX_BOOL bFindDot = FALSE; - FX_BOOL bBrackOpen = FALSE; - 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) { - CFX_WideString wsCategory(pStr[ccf]); - ccf++; - while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && - pStr[ccf] != '(') { - wsCategory += pStr[ccf]; - ccf++; - } - if (wsCategory != FX_WSTRC(L"num")) { - bBrackOpen = TRUE; - ccf = 0; - continue; - } - while (ccf < iLenf) { - if (pStr[ccf] == '(') { - ccf++; - CFX_WideString wsLCID; - while (ccf < iLenf && pStr[ccf] != ')') { - wsLCID += pStr[ccf++]; - } - pLocale = GetPatternLocale(wsLCID); - } else if (pStr[ccf] == '{') { - bBrackOpen = TRUE; - break; - } else if (pStr[ccf] == '.') { - CFX_WideString wsSubCategory; - ccf++; - while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { - wsSubCategory += pStr[ccf++]; - } - FX_DWORD dwSubHash = - FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); - FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; - for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { - if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { - eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] - .eSubCategory; - break; - } - } - wsSubCategory.Empty(); - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - FXSYS_assert(pLocale != NULL); - pLocale->GetNumPattern(eSubCategory, wsSubCategory); - iDotIndex = wsSubCategory.Find('.'); - if (iDotIndex > 0) { - iDotIndex += wsPurgePattern.GetLength(); - bFindDot = TRUE; - dwStyle |= FX_NUMSTYLE_DotVorv; - } - wsPurgePattern += wsSubCategory; - if (eSubCategory == FX_LOCALENUMPATTERN_Percent) { - dwStyle |= FX_NUMSTYLE_Percent; - } - continue; - } - ccf++; - } - } else if (pStr[ccf] == 'E') { - dwStyle |= FX_NUMSTYLE_Exponent; - wsPurgePattern += pStr[ccf]; - } else if (pStr[ccf] == '%') { - dwStyle |= FX_NUMSTYLE_Percent; - wsPurgePattern += pStr[ccf]; - } else if (pStr[ccf] != '}') { - wsPurgePattern += pStr[ccf]; - } - if (!bFindDot) { - if (pStr[ccf] == '.' || pStr[ccf] == 'V' || pStr[ccf] == 'v') { - bFindDot = TRUE; - iDotIndex = wsPurgePattern.GetLength() - 1; - dwStyle |= FX_NUMSTYLE_DotVorv; - } - } - ccf++; - } - if (!bFindDot) { - iDotIndex = wsPurgePattern.GetLength(); - } - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - return pLocale; -} -static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum, - const CFX_WideString& wsDotSymbol, - int32_t& iDotIndex) { - int32_t ccf = 0; - int32_t iLenf = wsNum.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; - 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)) { - iDotIndex = ccf; - return TRUE; - } - ccf++; - } - iDotIndex = wsNum.Find('.'); - if (iDotIndex < 0) { - iDotIndex = iLenf; - return FALSE; - } - return TRUE; -} -FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, - const CFX_WideString& wsPattern, - CFX_WideString& wsValue) { - wsValue.Empty(); - if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsTextFormat; - GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); - if (wsTextFormat.IsEmpty()) { - return FALSE; - } - int32_t iText = 0, iPattern = 0; - const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; - int32_t iLenText = wsSrcText.GetLength(); - const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern && iText < iLenText) { - switch (pStrPattern[iPattern]) { - case '\'': { - CFX_WideString wsLiteral = - FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - int32_t iLiteralLen = wsLiteral.GetLength(); - if (iText + iLiteralLen > iLenText || - FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, - iLiteralLen)) { - wsValue = wsSrcText; - return FALSE; - } - iText += iLiteralLen; - iPattern++; - break; - } - case 'A': - if (FX_IsAlpha(pStrText[iText])) { - wsValue += pStrText[iText]; - iText++; - } - iPattern++; - break; - case 'X': - wsValue += pStrText[iText]; - iText++; - iPattern++; - break; - case 'O': - case '0': - if (FX_IsDigit(pStrText[iText]) || FX_IsAlpha(pStrText[iText])) { - wsValue += pStrText[iText]; - iText++; - } - iPattern++; - break; - case '9': - if (FX_IsDigit(pStrText[iText])) { - wsValue += pStrText[iText]; - iText++; - } - iPattern++; - break; - default: - if (pStrPattern[iPattern] != pStrText[iText]) { - wsValue = wsSrcText; - return FALSE; - } - iPattern++; - iText++; - break; - } - } - return iPattern == iLenPattern && iText == iLenText; -} -FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, - const CFX_WideString& wsPattern, - FX_FLOAT& fValue) { - fValue = 0.0f; - if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - int32_t dot_index_f = -1; - FX_DWORD dwFormatStyle = 0; - CFX_WideString wsNumFormat; - IFX_Locale* pLocale = - GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); - if (!pLocale || wsNumFormat.IsEmpty()) { - return FALSE; - } - int32_t iExponent = 0; - CFX_WideString wsDotSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); - CFX_WideString wsGroupSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); - int32_t iGroupLen = wsGroupSymbol.GetLength(); - CFX_WideString wsMinus; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); - int32_t iMinusLen = wsMinus.GetLength(); - int cc = 0, ccf = 0; - const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; - int len = wsSrcNum.GetLength(); - const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; - int lenf = wsNumFormat.GetLength(); - double dbRetValue = 0; - double coeff = 1; - FX_BOOL bHavePercentSymbol = FALSE; - FX_BOOL bNeg = FALSE; - FX_BOOL bReverseParse = FALSE; - int32_t dot_index = 0; - if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && - (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { - bReverseParse = TRUE; - } - bReverseParse = FALSE; - if (bReverseParse) { - ccf = lenf - 1; - cc = len - 1; - while (ccf > dot_index_f && cc >= 0) { - switch (strf[ccf]) { - case '\'': { - 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)) { - return FALSE; - } - cc--; - ccf--; - break; - } - case '9': - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; - coeff *= 0.1; - cc--; - ccf--; - break; - case 'z': - if (cc >= 0) { - dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; - coeff *= 0.1; - cc--; - } - ccf--; - break; - case 'Z': - if (str[cc] != ' ') { - dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; - coeff *= 0.1; - } - cc--; - ccf--; - break; - case 'S': - if (str[cc] == '+' || str[cc] == ' ') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 's': - if (str[cc] == '+') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 'E': { - if (cc >= dot_index) { - return FALSE; - } - FX_BOOL bExpSign = FALSE; - while (cc >= 0) { - if (str[cc] == 'E' || str[cc] == 'e') { - break; - } - if (FX_IsDigit(str[cc])) { - iExponent = iExponent + (str[cc] - '0') * 10; - cc--; - continue; - } else if (str[cc] == '+') { - cc--; - continue; - } else if (cc - iMinusLen + 1 > 0 && - !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), - (const FX_WCHAR*)wsMinus, iMinusLen)) { - bExpSign = TRUE; - cc -= iMinusLen; - } else { - return FALSE; - } - } - cc--; - iExponent = bExpSign ? -iExponent : iExponent; - ccf--; - } break; - case '$': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - } break; - case 'r': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { - if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'R': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'b': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { - if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'B': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case '.': - case 'V': - case 'v': - return FALSE; - case '%': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - bHavePercentSymbol = TRUE; - } break; - case '8': - while (ccf < lenf && strf[ccf] == '8') { - ccf++; - } - while (cc < len && FX_IsDigit(str[cc])) { - dbRetValue = (str[cc] - '0') * coeff + dbRetValue; - coeff *= 0.1; - cc++; - } - break; - case ',': { - if (cc >= 0) { - cc -= iGroupLen - 1; - if (cc >= 0 && - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, - iGroupLen) == 0) { - cc--; - } else { - cc += iGroupLen - 1; - } - } - ccf--; - } break; - case '(': - if (str[cc] == L'(') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - case ')': - if (str[cc] == L')') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - default: - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc--; - ccf--; - } - } - dot_index = cc + 1; - } - ccf = dot_index_f - 1; - cc = dot_index - 1; - coeff = 1; - while (ccf >= 0 && cc >= 0) { - switch (strf[ccf]) { - case '\'': { - 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)) { - return FALSE; - } - cc--; - ccf--; - break; - } - case '9': - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 10; - cc--; - ccf--; - break; - case 'z': - if (FX_IsDigit(str[cc])) { - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 10; - cc--; - } - ccf--; - break; - case 'Z': - if (str[cc] != ' ') { - if (FX_IsDigit(str[cc])) { - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 10; - cc--; - } - } else { - cc--; - } - ccf--; - break; - case 'S': - if (str[cc] == '+' || str[cc] == ' ') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 's': - if (str[cc] == '+') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 'E': { - if (cc >= dot_index) { - return FALSE; - } - FX_BOOL bExpSign = FALSE; - while (cc >= 0) { - if (str[cc] == 'E' || str[cc] == 'e') { - break; - } - if (FX_IsDigit(str[cc])) { - iExponent = iExponent + (str[cc] - '0') * 10; - cc--; - continue; - } else if (str[cc] == '+') { - cc--; - continue; - } else if (cc - iMinusLen + 1 > 0 && - !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), - (const FX_WCHAR*)wsMinus, iMinusLen)) { - bExpSign = TRUE; - cc -= iMinusLen; - } else { - return FALSE; - } - } - cc--; - iExponent = bExpSign ? -iExponent : iExponent; - ccf--; - } break; - case '$': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - } break; - case 'r': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { - if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'R': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'b': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { - if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'B': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case '.': - case 'V': - case 'v': - return FALSE; - case '%': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - bHavePercentSymbol = TRUE; - } break; - case '8': - return FALSE; - case ',': { - if (cc >= 0) { - cc -= iGroupLen - 1; - if (cc >= 0 && - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, - iGroupLen) == 0) { - cc--; - } else { - cc += iGroupLen - 1; - } - } - ccf--; - } break; - case '(': - if (str[cc] == L'(') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - case ')': - if (str[cc] == L')') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - default: - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc--; - ccf--; - } - } - if (cc >= 0) { - return FALSE; - } - if (!bReverseParse) { - ccf = dot_index_f + 1; - cc = (dot_index == len) ? len : dot_index + 1; - coeff = 0.1; - while (cc < len && ccf < lenf) { - switch (strf[ccf]) { - case '\'': { - 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)) { - return FALSE; - } - cc += iLiteralLen; - ccf++; - break; - } - case '9': - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - { - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 0.1; - } - cc++; - ccf++; - break; - case 'z': - if (FX_IsDigit(str[cc])) { - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 0.1; - cc++; - } - ccf++; - break; - case 'Z': - if (str[cc] != ' ') { - if (FX_IsDigit(str[cc])) { - dbRetValue = dbRetValue + (str[cc] - '0') * coeff; - coeff *= 0.1; - cc++; - } - } else { - cc++; - } - ccf++; - break; - case 'S': - if (str[cc] == '+' || str[cc] == ' ') { - cc++; - } else { - if (cc + iMinusLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - bNeg = TRUE; - cc += iMinusLen; - } - ccf++; - break; - case 's': - if (str[cc] == '+') { - cc++; - } else { - if (cc + iMinusLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - bNeg = TRUE; - cc += iMinusLen; - } - ccf++; - break; - case 'E': { - if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { - return FALSE; - } - FX_BOOL bExpSign = FALSE; - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = TRUE; - cc++; - } - } - while (cc < len) { - if (!FX_IsDigit(str[cc])) { - break; - } - iExponent = iExponent * 10 + str[cc] - '0'; - cc++; - } - iExponent = bExpSign ? -iExponent : iExponent; - ccf++; - } break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, - wsSymbol); - int32_t iSymbolLen = wsSymbol.GetLength(); - if (cc + iSymbolLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { - return FALSE; - } - cc += iSymbolLen; - ccf++; - } break; - case 'c': - if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { - if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'C': - if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'd': - if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { - if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'D': - if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case '.': - case 'V': - case 'v': - return FALSE; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - int32_t iSysmbolLen = wsSymbol.GetLength(); - if (cc + iSysmbolLen <= len && - !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, - iSysmbolLen)) { - cc += iSysmbolLen; - } - ccf++; - bHavePercentSymbol = TRUE; - } break; - case '8': { - while (ccf < lenf && strf[ccf] == '8') { - ccf++; - } - while (cc < len && FX_IsDigit(str[cc])) { - dbRetValue = (str[cc] - '0') * coeff + dbRetValue; - coeff *= 0.1; - cc++; - } - } break; - case ',': { - if (cc + iGroupLen <= len && - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, - iGroupLen) == 0) { - cc += iGroupLen; - } - ccf++; - } break; - case '(': - if (str[cc] == L'(') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc++; - ccf++; - break; - case ')': - if (str[cc] == L')') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc++; - ccf++; - break; - default: - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc++; - ccf++; - } - } - if (cc != len) { - return FALSE; - } - } - if (iExponent) { - dbRetValue *= FXSYS_pow(10, (FX_FLOAT)iExponent); - } - if (bHavePercentSymbol) { - dbRetValue /= 100.0; - } - if (bNeg) { - dbRetValue = -dbRetValue; - } - fValue = (FX_FLOAT)dbRetValue; - return TRUE; -} -void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) { - int32_t iCount = wsNum.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum; - FX_WCHAR* pDst = wsResult.GetBuffer(iCount); - int32_t nIndex = 0; - FX_BOOL bMinus = FALSE; - int32_t i = 0; - for (i = 0; i < iCount; i++) { - FX_WCHAR wc = pStr[i]; - if (wc == '.') { - break; - } - if ((wc == L'0' || wc == L' ' || wc == '+') && nIndex == 0) { - continue; - } - if (wc == '-') { - pDst[nIndex++] = wc; - bMinus = TRUE; - continue; - } - if (wc == L'0' && nIndex == 1 && bMinus) { - continue; - } - pDst[nIndex++] = wc; - } - if (bMinus && nIndex == 1) { - pDst[nIndex++] = '0'; - } - if (nIndex == 0) { - wsResult.ReleaseBuffer(0); - pDst = wsResult.GetBuffer(iCount + 1); - pDst[nIndex++] = '0'; - } - int32_t j = 0; - for (j = iCount - 1; j > i; j--) { - FX_WCHAR wc = pStr[j]; - if (wc != L'0' && wc != L' ') { - break; - } - } - if (j > i) { - pDst[nIndex++] = '.'; - FXSYS_wcsncpy(pDst + nIndex, pStr + i + 1, j - i); - nIndex += j - i; - } - wsResult.ReleaseBuffer(nIndex); -} -FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsValue) { - wsValue.Empty(); - if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - int32_t dot_index_f = -1; - FX_DWORD dwFormatStyle = 0; - CFX_WideString wsNumFormat; - IFX_Locale* pLocale = - GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); - if (!pLocale || wsNumFormat.IsEmpty()) { - return FALSE; - } - int32_t iExponent = 0; - CFX_WideString wsDotSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); - CFX_WideString wsGroupSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); - int32_t iGroupLen = wsGroupSymbol.GetLength(); - CFX_WideString wsMinus; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); - int32_t iMinusLen = wsMinus.GetLength(); - int cc = 0, ccf = 0; - const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; - int len = wsSrcNum.GetLength(); - const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; - int lenf = wsNumFormat.GetLength(); - FX_BOOL bHavePercentSymbol = FALSE; - FX_BOOL bNeg = FALSE; - FX_BOOL bReverseParse = FALSE; - int32_t dot_index = 0; - if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && - (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { - bReverseParse = TRUE; - } - bReverseParse = FALSE; - ccf = dot_index_f - 1; - cc = dot_index - 1; - while (ccf >= 0 && cc >= 0) { - switch (strf[ccf]) { - case '\'': { - 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)) { - return FALSE; - } - cc--; - ccf--; - break; - } - case '9': - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wsValue = CFX_WideStringC(str[cc]) + wsValue; - cc--; - ccf--; - break; - case 'z': - if (FX_IsDigit(str[cc])) { - wsValue = CFX_WideStringC(str[cc]) + wsValue; - cc--; - } - ccf--; - break; - case 'Z': - if (str[cc] != ' ') { - if (FX_IsDigit(str[cc])) { - wsValue = CFX_WideStringC(str[cc]) + wsValue; - cc--; - } - } else { - cc--; - } - ccf--; - break; - case 'S': - if (str[cc] == '+' || str[cc] == ' ') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 's': - if (str[cc] == '+') { - cc--; - } else { - cc -= iMinusLen - 1; - if (cc < 0 || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - cc--; - bNeg = TRUE; - } - ccf--; - break; - case 'E': { - if (cc >= dot_index) { - return FALSE; - } - FX_BOOL bExpSign = FALSE; - while (cc >= 0) { - if (str[cc] == 'E' || str[cc] == 'e') { - break; - } - if (FX_IsDigit(str[cc])) { - iExponent = iExponent + (str[cc] - '0') * 10; - cc--; - continue; - } else if (str[cc] == '+') { - cc--; - continue; - } else if (cc - iMinusLen + 1 > 0 && - !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), - (const FX_WCHAR*)wsMinus, iMinusLen)) { - bExpSign = TRUE; - cc -= iMinusLen; - } else { - return FALSE; - } - } - cc--; - iExponent = bExpSign ? -iExponent : iExponent; - ccf--; - } break; - case '$': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - } break; - case 'r': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { - if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'R': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'b': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { - if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case 'B': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { - bNeg = TRUE; - cc -= 2; - } - ccf -= 2; - } else { - ccf--; - } - break; - case '.': - case 'V': - case 'v': - return FALSE; - case '%': { - CFX_WideString wsSymbol; - 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)) { - return FALSE; - } - cc--; - ccf--; - bHavePercentSymbol = TRUE; - } break; - case '8': - return FALSE; - case ',': { - if (cc >= 0) { - cc -= iGroupLen - 1; - if (cc >= 0 && - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, - iGroupLen) == 0) { - cc--; - } else { - cc += iGroupLen - 1; - } - } - ccf--; - } break; - case '(': - if (str[cc] == L'(') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - case ')': - if (str[cc] == L')') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc--; - ccf--; - break; - default: - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc--; - ccf--; - } - } - if (cc >= 0) { - if (str[cc] == '-') { - bNeg = TRUE; - cc--; - } - if (cc >= 0) { - return FALSE; - } - } - if (dot_index < len && (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { - wsValue += '.'; - } - if (!bReverseParse) { - ccf = dot_index_f + 1; - cc = (dot_index == len) ? len : dot_index + 1; - while (cc < len && ccf < lenf) { - switch (strf[ccf]) { - case '\'': { - 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)) { - return FALSE; - } - cc += iLiteralLen; - ccf++; - break; - } - case '9': - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - { wsValue += str[cc]; } - cc++; - ccf++; - break; - case 'z': - if (FX_IsDigit(str[cc])) { - wsValue += str[cc]; - cc++; - } - ccf++; - break; - case 'Z': - if (str[cc] != ' ') { - if (FX_IsDigit(str[cc])) { - wsValue += str[cc]; - cc++; - } - } else { - cc++; - } - ccf++; - break; - case 'S': - if (str[cc] == '+' || str[cc] == ' ') { - cc++; - } else { - if (cc + iMinusLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - bNeg = TRUE; - cc += iMinusLen; - } - ccf++; - break; - case 's': - if (str[cc] == '+') { - cc++; - } else { - if (cc + iMinusLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) { - return FALSE; - } - bNeg = TRUE; - cc += iMinusLen; - } - ccf++; - break; - case 'E': { - if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { - return FALSE; - } - FX_BOOL bExpSign = FALSE; - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = TRUE; - cc++; - } - } - while (cc < len) { - if (!FX_IsDigit(str[cc])) { - break; - } - iExponent = iExponent * 10 + str[cc] - '0'; - cc++; - } - iExponent = bExpSign ? -iExponent : iExponent; - ccf++; - } break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, - wsSymbol); - int32_t iSymbolLen = wsSymbol.GetLength(); - if (cc + iSymbolLen > len || - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) { - return FALSE; - } - cc += iSymbolLen; - ccf++; - } break; - case 'c': - if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { - if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'C': - if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'd': - if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { - if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case 'D': - if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { - if (str[cc] == ' ') { - cc++; - } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { - bNeg = TRUE; - cc += 2; - } - ccf += 2; - } - break; - case '.': - case 'V': - case 'v': - return FALSE; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - int32_t iSysmbolLen = wsSymbol.GetLength(); - if (cc + iSysmbolLen <= len && - !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, - iSysmbolLen)) { - cc += iSysmbolLen; - } - ccf++; - bHavePercentSymbol = TRUE; - } break; - case '8': { - while (ccf < lenf && strf[ccf] == '8') { - ccf++; - } - while (cc < len && FX_IsDigit(str[cc])) { - wsValue += str[cc]; - cc++; - } - } break; - case ',': { - if (cc + iGroupLen <= len && - FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol, - iGroupLen) == 0) { - cc += iGroupLen; - } - ccf++; - } break; - case '(': - if (str[cc] == L'(') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc++; - ccf++; - break; - case ')': - if (str[cc] == L')') { - bNeg = TRUE; - } else if (str[cc] != L' ') { - return FALSE; - } - cc++; - ccf++; - break; - default: - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc++; - ccf++; - } - } - if (cc != len) { - return FALSE; - } - } - if (iExponent || bHavePercentSymbol) { - CFX_Decimal decimal = CFX_Decimal(wsValue); - if (iExponent) { - decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); - } - if (bHavePercentSymbol) { - decimal = decimal / CFX_Decimal(100); - } - wsValue = decimal; - } - if (bNeg) { - wsValue = CFX_WideStringC('-') + wsValue; - } - return TRUE; -} -FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( - const CFX_WideString& wsPattern, - IFX_Locale*& pLocale, - CFX_WideString& wsDatePattern, - CFX_WideString& wsTimePattern) { - pLocale = NULL; - CFX_WideString wsTempPattern; - FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; - int32_t ccf = 0; - int32_t iLenf = wsPattern.GetLength(); - const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; - int32_t iFindCategory = 0; - FX_BOOL bBraceOpen = FALSE; - 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) { - CFX_WideString wsCategory(pStr[ccf]); - ccf++; - while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && - pStr[ccf] != '(') { - if (pStr[ccf] == 'T') { - wsDatePattern = wsPattern.Left(ccf); - wsTimePattern = wsPattern.Right(wsPattern.GetLength() - ccf); - wsTimePattern.SetAt(0, ' '); - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - return FX_DATETIMETYPE_DateTime; - } - wsCategory += pStr[ccf]; - ccf++; - } - if (!(iFindCategory & 1) && wsCategory == FX_WSTRC(L"date")) { - iFindCategory |= 1; - eCategory = FX_LOCALECATEGORY_Date; - if (iFindCategory & 2) { - iFindCategory = 4; - } - } else if (!(iFindCategory & 2) && wsCategory == FX_WSTRC(L"time")) { - iFindCategory |= 2; - eCategory = FX_LOCALECATEGORY_Time; - } else if (wsCategory == FX_WSTRC(L"datetime")) { - iFindCategory = 3; - eCategory = FX_LOCALECATEGORY_DateTime; - } else { - continue; - } - while (ccf < iLenf) { - if (pStr[ccf] == '(') { - ccf++; - CFX_WideString wsLCID; - while (ccf < iLenf && pStr[ccf] != ')') { - wsLCID += pStr[ccf++]; - } - pLocale = GetPatternLocale(wsLCID); - } else if (pStr[ccf] == '{') { - bBraceOpen = TRUE; - break; - } else if (pStr[ccf] == '.') { - CFX_WideString wsSubCategory; - ccf++; - while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { - wsSubCategory += pStr[ccf++]; - } - FX_DWORD dwSubHash = - FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength()); - FX_LOCALEDATETIMESUBCATEGORY eSubCategory = - FX_LOCALEDATETIMESUBCATEGORY_Medium; - for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) { - if (g_FXLocaleDateTimeSubCatData[i].uHash == dwSubHash) { - eSubCategory = - (FX_LOCALEDATETIMESUBCATEGORY)g_FXLocaleDateTimeSubCatData[i] - .eSubCategory; - break; - } - } - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - FXSYS_assert(pLocale != NULL); - switch (eCategory) { - case FX_LOCALECATEGORY_Date: - pLocale->GetDatePattern(eSubCategory, wsDatePattern); - wsDatePattern = wsTempPattern + wsDatePattern; - break; - case FX_LOCALECATEGORY_Time: - pLocale->GetTimePattern(eSubCategory, wsTimePattern); - wsTimePattern = wsTempPattern + wsTimePattern; - break; - case FX_LOCALECATEGORY_DateTime: - pLocale->GetDatePattern(eSubCategory, wsDatePattern); - wsDatePattern = wsTempPattern + wsDatePattern; - pLocale->GetTimePattern(eSubCategory, wsTimePattern); - break; - default: - break; - } - wsTempPattern.Empty(); - continue; - } - ccf++; - } - } else if (pStr[ccf] == '}') { - bBraceOpen = FALSE; - if (!wsTempPattern.IsEmpty()) { - if (eCategory == FX_LOCALECATEGORY_Time) { - wsTimePattern = wsTempPattern; - } else if (eCategory == FX_LOCALECATEGORY_Date) { - wsDatePattern = wsTempPattern; - } - wsTempPattern.Empty(); - } - } else { - wsTempPattern += pStr[ccf]; - } - ccf++; - } - if (!wsTempPattern.IsEmpty()) { - if (eCategory == FX_LOCALECATEGORY_Date) { - wsDatePattern += wsTempPattern; - } else { - wsTimePattern += wsTempPattern; - } - } - if (!pLocale) { - pLocale = m_pLocaleMgr->GetDefLocale(); - } - if (!iFindCategory) { - wsTimePattern.Empty(); - wsDatePattern = wsPattern; - } - return (FX_DATETIMETYPE)iFindCategory; -} -static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, - const CFX_WideString& wsDatePattern, - IFX_Locale* pLocale, - CFX_Unitime& datetime, - int32_t& cc) { - int32_t year = 1900; - int32_t month = 1; - int32_t day = 1; - int32_t ccf = 0; - const FX_WCHAR* str = (const FX_WCHAR*)wsDate; - int32_t len = wsDate.GetLength(); - const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; - int32_t lenf = wsDatePattern.GetLength(); - 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)) { - return FALSE; - } - cc += iLiteralLen; - ccf++; - continue; - } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc++; - ccf++; - continue; - } - FX_DWORD dwSymbolNum = 1; - FX_DWORD dwSymbol = strf[ccf++]; - while (ccf < lenf && strf[ccf] == dwSymbol) { - ccf++; - dwSymbolNum++; - } - dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); - if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - day = str[cc++] - '0'; - if (cc < len && FX_IsDigit(str[cc])) { - day = day * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - day = str[cc++] - '0'; - if (cc < len) { - day = day * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { - int i = 0; - while (cc < len && i < 3 && FX_IsDigit(str[cc])) { - cc++; - i++; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { - cc += 3; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - month = str[cc++] - '0'; - if (cc < len && FX_IsDigit(str[cc])) { - month = month * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - month = str[cc++] - '0'; - if (cc < len) { - month = month * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { - CFX_WideString wsMonthNameAbbr; - FX_WORD i = 0; - for (; i < 12; i++) { - pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); - if (wsMonthNameAbbr.IsEmpty()) { - continue; - } - if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc, - wsMonthNameAbbr.GetLength())) { - break; - } - } - if (i < 12) { - cc += wsMonthNameAbbr.GetLength(); - month = i + 1; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { - CFX_WideString wsMonthName; - FX_WORD i = 0; - for (; i < 12; i++) { - pLocale->GetMonthName(i, wsMonthName, FALSE); - if (wsMonthName.IsEmpty()) { - continue; - } - if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc, - wsMonthName.GetLength())) { - break; - } - } - if (i < 12) { - cc += wsMonthName.GetLength(); - month = i + 1; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { - cc += 1; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { - CFX_WideString wsDayNameAbbr; - FX_WORD i = 0; - for (; i < 7; i++) { - pLocale->GetDayName(i, wsDayNameAbbr, TRUE); - if (wsDayNameAbbr.IsEmpty()) { - continue; - } - if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc, - wsDayNameAbbr.GetLength())) { - break; - } - } - if (i < 12) { - cc += wsDayNameAbbr.GetLength(); - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { - CFX_WideString wsDayName; - int32_t i = 0; - for (; i < 7; i++) { - pLocale->GetDayName(i, wsDayName, FALSE); - if (wsDayName == L"") { - continue; - } - if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayName, str + cc, - wsDayName.GetLength())) { - break; - } - } - if (i < 12) { - cc += wsDayName.GetLength(); - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { - cc += 1; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { - cc += 2; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { - if (cc + 2 > len) { - return FALSE; - } - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - year = str[cc++] - '0'; - if (cc >= len || !FX_IsDigit(str[cc])) { - return FALSE; - } - year = year * 10 + str[cc++] - '0'; - if (year <= 29) { - year += 2000; - } else { - year += 1900; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { - int i = 0; - year = 0; - if (cc + 4 > len) { - return FALSE; - } - while (i < 4) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - year = year * 10 + str[cc] - '0'; - cc++; - i++; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { - cc += 1; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { - cc += 2; - } - } - if (cc < len) { - return FALSE; - } - CFX_Unitime ut; - ut.Set(year, month, day); - datetime = datetime + ut; - return cc; -} -static void FX_ResolveZone(uint8_t& wHour, - uint8_t& wMinute, - FX_TIMEZONE tzDiff, - IFX_Locale* pLocale) { - int32_t iMinuteDiff = wHour * 60 + wMinute; - FX_TIMEZONE tzLocale; - pLocale->GetTimeZone(tzLocale); - iMinuteDiff += tzLocale.tzHour * 60 + - (tzLocale.tzHour < 0 ? -tzLocale.tzMinute : tzLocale.tzMinute); - iMinuteDiff -= tzDiff.tzHour * 60 + - (tzDiff.tzHour < 0 ? -tzDiff.tzMinute : tzDiff.tzMinute); - while (iMinuteDiff > 1440) { - iMinuteDiff -= 1440; - } - while (iMinuteDiff < 0) { - iMinuteDiff += 1440; - } - wHour = iMinuteDiff / 60; - wMinute = iMinuteDiff % 60; -} -static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, - const CFX_WideString& wsTimePattern, - IFX_Locale* pLocale, - CFX_Unitime& datetime, - int32_t& cc) { - uint8_t hour = 0; - uint8_t minute = 0; - uint8_t second = 0; - FX_WORD millisecond = 0; - int32_t ccf = 0; - const FX_WCHAR* str = (const FX_WCHAR*)wsTime; - int len = wsTime.GetLength(); - const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; - int lenf = wsTimePattern.GetLength(); - FX_BOOL bHasA = FALSE; - FX_BOOL bPM = FALSE; - 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)) { - return FALSE; - } - cc += iLiteralLen; - ccf++; - continue; - } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) { - if (strf[ccf] != str[cc]) { - return FALSE; - } - cc++; - ccf++; - continue; - } - FX_DWORD dwSymbolNum = 1; - FX_DWORD dwSymbol = strf[ccf++]; - while (ccf < lenf && strf[ccf] == dwSymbol) { - ccf++; - dwSymbolNum++; - } - dwSymbol = (dwSymbol << 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') || - dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - hour = str[cc++] - '0'; - if (cc < len && FX_IsDigit(str[cc])) { - hour = hour * 10 + str[cc++] - '0'; - } - if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1') && hour == 24) { - hour = 0; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2') || - dwSymbol == FXBSTR_ID(0, 0, 'H', '2') || - dwSymbol == FXBSTR_ID(0, 0, 'h', '2') || - dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - hour = str[cc++] - '0'; - if (cc >= len) { - return FALSE; - } - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - hour = hour * 10 + str[cc++] - '0'; - if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2') && hour == 24) { - hour = 0; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - minute = str[cc++] - '0'; - if (cc < len && FX_IsDigit(str[cc])) { - minute = minute * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - minute = str[cc++] - '0'; - if (cc >= len) { - return FALSE; - } - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - minute = minute * 10 + str[cc++] - '0'; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - second = str[cc++] - '0'; - if (cc < len && FX_IsDigit(str[cc])) { - second = second * 10 + str[cc++] - '0'; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - second = str[cc++] - '0'; - if (cc >= len) { - return FALSE; - } - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - second = second * 10 + str[cc++] - '0'; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { - if (cc + 3 >= len) { - return FALSE; - } - int i = 0; - while (i < 3) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - millisecond = millisecond * 10 + str[cc++] - '0'; - i++; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { - CFX_WideString wsAM; - pLocale->GetMeridiemName(wsAM, TRUE); - CFX_WideString wsPM; - pLocale->GetMeridiemName(wsPM, FALSE); - if ((cc + wsAM.GetLength() <= len) && - (CFX_WideStringC(str + cc, wsAM.GetLength()) == wsAM)) { - cc += wsAM.GetLength(); - bHasA = TRUE; - } else if ((cc + wsPM.GetLength() <= len) && - (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { - cc += wsPM.GetLength(); - bHasA = TRUE; - bPM = TRUE; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { - if (cc + 3 > len) { - continue; - } - FX_DWORD dwHash = str[cc++]; - dwHash = (dwHash << 8) | str[cc++]; - dwHash = (dwHash << 8) | str[cc++]; - if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { - FX_TIMEZONE tzDiff; - tzDiff.tzHour = 0; - tzDiff.tzMinute = 0; - if (cc < len && (str[cc] == '-' || str[cc] == '+')) { - cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); - } - FX_ResolveZone(hour, minute, tzDiff, pLocale); - } else { - const FX_LOCALETIMEZONEINFO* pEnd = - g_FXLocaleTimeZoneData + FX_ArraySize(g_FXLocaleTimeZoneData); - const FX_LOCALETIMEZONEINFO* pTimeZoneInfo = - std::lower_bound(g_FXLocaleTimeZoneData, pEnd, dwHash, - [](const FX_LOCALETIMEZONEINFO& info, - FX_DWORD hash) { return info.uHash < hash; }); - if (pTimeZoneInfo < pEnd && dwHash == pTimeZoneInfo->uHash) { - hour += pTimeZoneInfo->iHour; - minute += pTimeZoneInfo->iHour > 0 ? pTimeZoneInfo->iMinute - : -pTimeZoneInfo->iMinute; - } - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { - if (str[cc] != 'Z') { - FX_TIMEZONE tzDiff; - cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); - FX_ResolveZone(hour, minute, tzDiff, pLocale); - } else { - cc++; - } - } - } - if (bHasA) { - if (bPM) { - hour += 12; - if (hour == 24) { - hour = 12; - } - } else { - if (hour == 12) { - hour = 0; - } - } - } - CFX_Unitime ut; - ut.Set(0, 0, 0, hour, minute, second, millisecond); - datetime = datetime + ut; - return cc; -} -FX_BOOL CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, - const CFX_WideString& wsPattern, - FX_DATETIMETYPE eDateTimeType, - CFX_Unitime& dtValue) { - dtValue.Set(0); - if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; - FX_DATETIMETYPE eCategory = - GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); - if (!pLocale) { - return FALSE; - } - if (eCategory == FX_DATETIMETYPE_Unknown) { - eCategory = eDateTimeType; - } - if (eCategory == FX_DATETIMETYPE_Unknown) { - return FALSE; - } - if (eCategory == FX_DATETIMETYPE_TimeDate) { - int32_t iStart = 0; - if (!FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, - iStart)) { - return FALSE; - } - if (!FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, - iStart)) { - return FALSE; - } - } else { - int32_t iStart = 0; - if ((eCategory & FX_DATETIMETYPE_Date) && - !FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, - iStart)) { - return FALSE; - } - if ((eCategory & FX_DATETIMETYPE_Time) && - !FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, - iStart)) { - return FALSE; - } - } - return TRUE; -} -FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, - const CFX_WideString& wsPattern) { - CFX_WideString wsTextFormat; - GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); - int32_t iText = 0, iPattern = 0; - const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; - int32_t iLenText = wsSrcText.GetLength(); - const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern && iText < iLenText) { - if (pStrPattern[iPattern] == '\'') { - CFX_WideString wsLiteral = - FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - int32_t iLiteralLen = wsLiteral.GetLength(); - if (iText + iLiteralLen > iLenText || - FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, - iLiteralLen)) { - return FALSE; - } - iText += iLiteralLen; - iPattern++; - continue; - } else if (pStrPattern[iPattern] != pStrText[iText]) { - return FALSE; - } else { - iText++; - iPattern++; - } - } - return iPattern == iLenPattern && iText == iLenText; -} -FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, - const CFX_WideString& wsPattern) { - CFX_WideString wsTextFormat; - GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); - int32_t iText = 0, iPattern = 0; - const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText; - int32_t iLenText = wsSrcText.GetLength(); - const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern && iText < iLenText) { - if (pStrPattern[iPattern] == '\'') { - CFX_WideString wsLiteral = - FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - int32_t iLiteralLen = wsLiteral.GetLength(); - if (iText + iLiteralLen > iLenText || - FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral, - iLiteralLen)) { - return FALSE; - } - iText += iLiteralLen; - iPattern++; - continue; - } else if (pStrPattern[iPattern] != pStrText[iText]) { - return FALSE; - } else { - iText++; - iPattern++; - } - } - return iPattern == iLenPattern && iText == iLenText; -} -FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsPattern.IsEmpty()) { - return FALSE; - } - int32_t iLenText = wsSrcText.GetLength(); - if (iLenText == 0) { - return FALSE; - } - 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; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern) { - switch (pStrPattern[iPattern]) { - case '\'': { - wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - iPattern++; - break; - } - case 'A': - if (iText >= iLenText || !FX_IsAlpha(pStrText[iText])) { - return FALSE; - } - wsOutput += pStrText[iText++]; - iPattern++; - break; - case 'X': - if (iText >= iLenText) { - return FALSE; - } - wsOutput += pStrText[iText++]; - iPattern++; - break; - case 'O': - case '0': - if (iText >= iLenText || - (!FX_IsDigit(pStrText[iText]) && !FX_IsAlpha(pStrText[iText]))) { - return FALSE; - } - wsOutput += pStrText[iText++]; - iPattern++; - break; - case '9': - if (iText >= iLenText || !FX_IsDigit(pStrText[iText])) { - return FALSE; - } - wsOutput += pStrText[iText++]; - iPattern++; - break; - default: - wsOutput += pStrPattern[iPattern++]; - break; - } - } - return iText == iLenText; -} -static int32_t FX_GetNumTrailingLimit(const CFX_WideString& wsFormat, - int iDotPos, - FX_BOOL& bTrimTailZeros) { - if (iDotPos < 0) { - return 0; - } - int32_t iCount = wsFormat.GetLength(); - int32_t iTreading = 0; - for (iDotPos++; iDotPos < iCount; iDotPos++) { - FX_WCHAR wc = wsFormat[iDotPos]; - if (wc == L'z' || wc == L'9' || wc == 'Z') { - iTreading++; - bTrimTailZeros = (wc == L'9' ? FALSE : TRUE); - } - } - return iTreading; -} -FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - int32_t dot_index_f = -1; - FX_DWORD dwNumStyle = 0; - CFX_WideString wsNumFormat; - IFX_Locale* pLocale = - GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); - if (!pLocale || wsNumFormat.IsEmpty()) { - return FALSE; - } - int32_t cc = 0, ccf = 0; - const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; - int lenf = wsNumFormat.GetLength(); - CFX_WideString wsSrcNum = wsInputNum; - wsSrcNum.TrimLeft('0'); - if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { - wsSrcNum.Insert(0, '0'); - } - CFX_Decimal decimal = CFX_Decimal(wsSrcNum); - if (dwNumStyle & FX_NUMSTYLE_Percent) { - decimal = decimal * CFX_Decimal(100); - wsSrcNum = decimal; - } - int32_t exponent = 0; - if (dwNumStyle & FX_NUMSTYLE_Exponent) { - int fixed_count = 0; - while (ccf < dot_index_f) { - switch (strf[ccf]) { - case '\'': - FX_GetLiteralText(strf, ccf, dot_index_f); - break; - case '9': - case 'z': - case 'Z': - fixed_count++; - break; - } - ccf++; - } - int threshold = 1; - while (fixed_count > 1) { - threshold *= 10; - fixed_count--; - } - if (decimal != CFX_Decimal(0)) { - if (decimal < CFX_Decimal(threshold)) { - decimal = decimal * CFX_Decimal(10); - exponent = -1; - while (decimal < CFX_Decimal(threshold)) { - decimal = decimal * CFX_Decimal(10); - exponent -= 1; - } - } else if (decimal > CFX_Decimal(threshold)) { - threshold *= 10; - while (decimal > CFX_Decimal(threshold)) { - decimal = decimal / CFX_Decimal(10); - exponent += 1; - } - } - } - } - FX_BOOL bTrimTailZeros = FALSE; - int32_t iTreading = - FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); - int32_t scale = decimal.GetScale(); - if (iTreading < scale) { - decimal.SetScale(iTreading); - wsSrcNum = decimal; - } - if (bTrimTailZeros && scale > 0 && iTreading > 0) { - wsSrcNum.TrimRight(L"0"); - wsSrcNum.TrimRight(L"."); - } - CFX_WideString wsGroupSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); - FX_BOOL bNeg = FALSE; - if (wsSrcNum[0] == '-') { - bNeg = TRUE; - wsSrcNum.Delete(0, 1); - } - FX_BOOL bAddNeg = FALSE; - const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum; - int len = wsSrcNum.GetLength(); - int dot_index = wsSrcNum.Find('.'); - if (dot_index == -1) { - dot_index = len; - } - ccf = dot_index_f - 1; - cc = dot_index - 1; - while (ccf >= 0) { - switch (strf[ccf]) { - case '9': - if (cc >= 0) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - cc--; - } else { - wsOutput = CFX_WideStringC(L'0') + wsOutput; - } - ccf--; - break; - case 'z': - if (cc >= 0) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - if (str[0] != '0') { - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - } - cc--; - } - ccf--; - break; - case 'Z': - if (cc >= 0) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - if (str[0] == '0') { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } else { - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - } - cc--; - } else { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } - ccf--; - break; - case 'S': - if (bNeg) { - CFX_WideString wsMinusSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); - wsOutput = wsMinusSymbol + wsOutput; - bAddNeg = TRUE; - } else { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } - ccf--; - break; - case 's': - if (bNeg) { - CFX_WideString wsMinusSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); - wsOutput = wsMinusSymbol + wsOutput; - bAddNeg = TRUE; - } - ccf--; - break; - case 'E': { - CFX_WideString wsExp; - wsExp.Format(L"E%+d", exponent); - wsOutput = wsExp + wsOutput; - } - ccf--; - break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); - wsOutput = wsSymbol + wsOutput; - } - ccf--; - break; - case 'r': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { - if (bNeg) { - wsOutput = L"CR" + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'R': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { - if (bNeg) { - wsOutput = L"CR" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'b': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { - if (bNeg) { - wsOutput = L"db" + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'B': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { - if (bNeg) { - wsOutput = L"DB" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - wsOutput = wsSymbol + wsOutput; - } - ccf--; - break; - case ',': - if (cc >= 0) { - wsOutput = wsGroupSymbol + wsOutput; - } - ccf--; - break; - case '(': - if (bNeg) { - wsOutput = L"(" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - bAddNeg = TRUE; - ccf--; - break; - case ')': - if (bNeg) { - wsOutput = L")" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf--; - break; - case '\'': - wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; - ccf--; - break; - default: - wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; - ccf--; - } - } - if (cc >= 0) { - int nPos = dot_index % 3; - wsOutput.Empty(); - for (int32_t i = 0; i < dot_index; i++) { - if (i % 3 == nPos && i != 0) { - wsOutput += wsGroupSymbol; - } - wsOutput += wsSrcNum[i]; - } - if (dot_index < len) { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); - wsOutput += wsSymbol; - wsOutput += wsSrcNum.Right(len - dot_index - 1); - } - if (bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = wsMinusymbol + wsOutput; - } - return FALSE; - } - if (dot_index_f == wsNumFormat.GetLength()) { - if (!bAddNeg && bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = wsMinusymbol + wsOutput; - } - return TRUE; - } - CFX_WideString wsDotSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); - if (strf[dot_index_f] == 'V') { - wsOutput += wsDotSymbol; - } else if (strf[dot_index_f] == '.') { - if (dot_index < len) { - wsOutput += wsDotSymbol; - } else { - if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { - wsOutput += wsDotSymbol; - } - } - } - ccf = dot_index_f + 1; - cc = dot_index + 1; - while (ccf < lenf) { - switch (strf[ccf]) { - case '\'': - wsOutput += FX_GetLiteralText(strf, ccf, lenf); - ccf++; - break; - case '9': - if (cc < len) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wsOutput += str[cc]; - cc++; - } else { - wsOutput += L'0'; - } - ccf++; - break; - case 'z': - if (cc < len) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wsOutput += str[cc]; - cc++; - } - ccf++; - break; - case 'Z': - if (cc < len) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wsOutput += str[cc]; - cc++; - } else { - wsOutput += L'0'; - } - ccf++; - break; - case 'E': { - CFX_WideString wsExp; - wsExp.Format(L"E%+d", exponent); - wsOutput += wsExp; - } - ccf++; - break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); - wsOutput += wsSymbol; - } - ccf++; - break; - case 'c': - if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { - if (bNeg) { - wsOutput += L"CR"; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'C': - if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { - if (bNeg) { - wsOutput += L"CR"; - } else { - wsOutput += L" "; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'd': - if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { - if (bNeg) { - wsOutput += L"db"; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'D': - if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { - if (bNeg) { - wsOutput += L"DB"; - } else { - wsOutput += L" "; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - wsOutput += wsSymbol; - } - ccf++; - break; - case '8': { - while (ccf < lenf && strf[ccf] == '8') { - ccf++; - } - while (cc < len && FX_IsDigit(str[cc])) { - wsOutput += str[cc]; - cc++; - } - } break; - case ',': - wsOutput += wsGroupSymbol; - ccf++; - break; - case '(': - if (bNeg) { - wsOutput += '('; - } else { - wsOutput += ' '; - } - bAddNeg = TRUE; - ccf++; - break; - case ')': - if (bNeg) { - wsOutput += ')'; - } else { - wsOutput += ' '; - } - ccf++; - break; - default: - ccf++; - } - } - if (!bAddNeg && bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = - wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); - } - return TRUE; -} -FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - int32_t dot_index_f = -1; - FX_DWORD dwNumStyle = 0; - CFX_WideString wsNumFormat; - IFX_Locale* pLocale = - GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); - if (!pLocale || wsNumFormat.IsEmpty()) { - return FALSE; - } - int32_t cc = 0, ccf = 0; - const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; - int lenf = wsNumFormat.GetLength(); - double dbOrgRaw = lcNum.GetDouble(); - double dbRetValue = dbOrgRaw; - if (dwNumStyle & FX_NUMSTYLE_Percent) { - dbRetValue *= 100; - } - int32_t exponent = 0; - if (dwNumStyle & FX_NUMSTYLE_Exponent) { - int fixed_count = 0; - while (ccf < dot_index_f) { - switch (strf[ccf]) { - case '\'': - FX_GetLiteralText(strf, ccf, dot_index_f); - break; - case '9': - case 'z': - case 'Z': - fixed_count++; - break; - } - ccf++; - } - int threshold = 1; - while (fixed_count > 1) { - threshold *= 10; - fixed_count--; - } - if (dbRetValue != 0) { - if (dbRetValue < threshold) { - dbRetValue *= 10; - exponent = -1; - while (dbRetValue < threshold) { - dbRetValue *= 10; - exponent -= 1; - } - } else if (dbRetValue > threshold) { - threshold *= 10; - while (dbRetValue > threshold) { - dbRetValue /= 10; - exponent += 1; - } - } - } - } - if (dwNumStyle & (FX_NUMSTYLE_Percent | FX_NUMSTYLE_Exponent)) { - lcNum = CFX_LCNumeric(dbRetValue); - } - FX_BOOL bTrimTailZeros = FALSE; - int32_t iTreading = - FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); - CFX_WideString wsNumeric = lcNum.ToString(iTreading, bTrimTailZeros); - if (wsNumeric.IsEmpty()) { - return FALSE; - } - CFX_WideString wsGroupSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); - FX_BOOL bNeg = FALSE; - if (wsNumeric[0] == '-') { - bNeg = TRUE; - wsNumeric.Delete(0, 1); - } - FX_BOOL bAddNeg = FALSE; - const FX_WCHAR* str = (const FX_WCHAR*)wsNumeric; - int len = wsNumeric.GetLength(); - int dot_index = wsNumeric.Find('.'); - if (dot_index == -1) { - dot_index = len; - } - ccf = dot_index_f - 1; - cc = dot_index - 1; - while (ccf >= 0) { - switch (strf[ccf]) { - case '9': - if (cc >= 0) { - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - cc--; - } else { - wsOutput = CFX_WideStringC(L'0') + wsOutput; - } - ccf--; - break; - case 'z': - if (cc >= 0) { - if (lcNum.m_Integral != 0) { - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - } - cc--; - } - ccf--; - break; - case 'Z': - if (cc >= 0) { - if (lcNum.m_Integral == 0) { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } else { - wsOutput = CFX_WideStringC(str[cc]) + wsOutput; - } - cc--; - } else { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } - ccf--; - break; - case 'S': - if (bNeg) { - CFX_WideString wsMinusSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); - wsOutput = wsMinusSymbol + wsOutput; - bAddNeg = TRUE; - } else { - wsOutput = CFX_WideStringC(L' ') + wsOutput; - } - ccf--; - break; - case 's': - if (bNeg) { - CFX_WideString wsMinusSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); - wsOutput = wsMinusSymbol + wsOutput; - bAddNeg = TRUE; - } - ccf--; - break; - case 'E': { - CFX_WideString wsExp; - wsExp.Format(L"E%+d", exponent); - wsOutput = wsExp + wsOutput; - } - ccf--; - break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); - wsOutput = wsSymbol + wsOutput; - } - ccf--; - break; - case 'r': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { - if (bNeg) { - wsOutput = L"CR" + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'R': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { - if (bNeg) { - wsOutput = L"CR" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'b': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { - if (bNeg) { - wsOutput = L"db" + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case 'B': - if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { - if (bNeg) { - wsOutput = L"DB" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf -= 2; - bAddNeg = TRUE; - } - break; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - wsOutput = wsSymbol + wsOutput; - } - ccf--; - break; - case ',': - if (cc >= 0) { - wsOutput = wsGroupSymbol + wsOutput; - } - ccf--; - break; - case '(': - if (bNeg) { - wsOutput = L"(" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - bAddNeg = TRUE; - ccf--; - break; - case ')': - if (bNeg) { - wsOutput = L")" + wsOutput; - } else { - wsOutput = L" " + wsOutput; - } - ccf--; - break; - case '\'': - wsOutput = FX_GetLiteralTextReverse(strf, ccf) + wsOutput; - ccf--; - break; - default: - wsOutput = CFX_WideStringC(strf[ccf]) + wsOutput; - ccf--; - } - } - if (cc >= 0) { - int nPos = dot_index % 3; - wsOutput.Empty(); - for (int32_t i = 0; i < dot_index; i++) { - if (i % 3 == nPos && i != 0) { - wsOutput += wsGroupSymbol; - } - wsOutput += wsNumeric[i]; - } - if (dot_index < len) { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); - wsOutput += wsSymbol; - wsOutput += wsNumeric.Right(len - dot_index - 1); - } - if (bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = wsMinusymbol + wsOutput; - } - return FALSE; - } - if (dot_index_f == wsNumFormat.GetLength()) { - if (!bAddNeg && bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = wsMinusymbol + wsOutput; - } - return TRUE; - } - CFX_WideString wsDotSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); - if (strf[dot_index_f] == 'V') { - wsOutput += wsDotSymbol; - } else if (strf[dot_index_f] == '.') { - if (dot_index < len) { - wsOutput += wsDotSymbol; - } else { - if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { - wsOutput += wsDotSymbol; - } - } - } - ccf = dot_index_f + 1; - cc = dot_index + 1; - while (ccf < lenf) { - switch (strf[ccf]) { - case '\'': - wsOutput += FX_GetLiteralText(strf, ccf, lenf); - ccf++; - break; - case '9': - if (cc < len) { - wsOutput += str[cc]; - cc++; - } else { - wsOutput += L'0'; - } - ccf++; - break; - case 'z': - if (cc < len) { - wsOutput += str[cc]; - cc++; - } - ccf++; - break; - case 'Z': - if (cc < len) { - wsOutput += str[cc]; - cc++; - } else { - wsOutput += L'0'; - } - ccf++; - break; - case 'E': { - CFX_WideString wsExp; - wsExp.Format(L"E%+d", exponent); - wsOutput += wsExp; - } - ccf++; - break; - case '$': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); - wsOutput += wsSymbol; - } - ccf++; - break; - case 'c': - if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { - if (bNeg) { - wsOutput += L"CR"; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'C': - if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { - if (bNeg) { - wsOutput += L"CR"; - } else { - wsOutput += L" "; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'd': - if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { - if (bNeg) { - wsOutput += L"db"; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case 'D': - if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { - if (bNeg) { - wsOutput += L"DB"; - } else { - wsOutput += L" "; - } - ccf += 2; - bAddNeg = TRUE; - } - break; - case '%': { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); - wsOutput += wsSymbol; - } - ccf++; - break; - case '8': { - while (ccf < lenf && strf[ccf] == '8') { - ccf++; - } - while (cc < len && FX_IsDigit(str[cc])) { - wsOutput += str[cc]; - cc++; - } - } break; - case ',': - wsOutput += wsGroupSymbol; - ccf++; - break; - case '(': - if (bNeg) { - wsOutput += '('; - } else { - wsOutput += ' '; - } - bAddNeg = TRUE; - ccf++; - break; - case ')': - if (bNeg) { - wsOutput += ')'; - } else { - wsOutput += ' '; - } - ccf++; - break; - default: - ccf++; - } - } - if (!bAddNeg && bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = - wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); - } - return TRUE; -} -FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - return FormatStrNum(wsSrcNum, wsPattern, wsOutput); -} -FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsPattern.IsEmpty()) { - return FALSE; - } - CFX_LCNumeric lcNum(fNum); - return FormatLCNumeric(lcNum, wsPattern, wsOutput); -} -FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, - CFX_Unitime& datetime) { - int32_t year = 1900; - int32_t month = 1; - int32_t day = 1; - FX_WORD wYear = 0; - int cc_start = 0, cc = 0; - const FX_WCHAR* str = (const FX_WCHAR*)wsDate; - int len = wsDate.GetLength(); - if (len > 10) { - return FALSE; - } - while (cc < len && cc < 4) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - wYear = wYear * 10 + str[cc++] - '0'; - } - year = wYear; - if (cc < 4 || wYear < 1900) { - return FALSE; - } - if (cc < len) { - if (str[cc] == '-') { - cc++; - } - cc_start = cc; - uint8_t tmpM = 0; - while (cc < len && cc < cc_start + 2) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - tmpM = tmpM * 10 + str[cc++] - '0'; - } - month = tmpM; - if (cc == cc_start + 1 || tmpM > 12 || tmpM < 1) { - return FALSE; - } - if (cc < len) { - if (str[cc] == '-') { - cc++; - } - uint8_t tmpD = 0; - cc_start = cc; - while (cc < len && cc < cc_start + 2) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - tmpD = tmpD * 10 + str[cc++] - '0'; - } - day = tmpD; - if (tmpD < 1) { - return FALSE; - } - if ((tmpM == 1 || tmpM == 3 || tmpM == 5 || tmpM == 7 || tmpM == 8 || - tmpM == 10 || tmpM == 12) && - tmpD > 31) { - return FALSE; - } - if ((tmpM == 4 || tmpM == 6 || tmpM == 9 || tmpM == 11) && tmpD > 30) { - return FALSE; - } - FX_BOOL iLeapYear; - if ((wYear % 4 == 0 && wYear % 100 != 0) || wYear % 400 == 0) { - iLeapYear = TRUE; - } else { - iLeapYear = FALSE; - } - if ((iLeapYear && tmpM == 2 && tmpD > 29) || - (!iLeapYear && tmpM == 2 && tmpD > 28)) { - return FALSE; - } - } - } - CFX_Unitime ut; - ut.Set(year, month, day); - datetime = datetime + ut; - return TRUE; -} -FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime, - CFX_Unitime& datetime, - IFX_Locale* pLocale) { - if (wsTime.GetLength() == 0) { - return FALSE; - } - uint8_t hour = 0; - uint8_t minute = 0; - uint8_t second = 0; - FX_WORD millisecond = 0; - int cc_start = 0, cc = cc_start; - const FX_WCHAR* str = (const FX_WCHAR*)wsTime.GetPtr(); - int len = wsTime.GetLength(); - while (cc < len && cc < 2) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - hour = hour * 10 + str[cc++] - '0'; - } - if (cc < 2 || hour >= 24) { - return FALSE; - } - if (cc < len) { - if (str[cc] == ':') { - cc++; - } - cc_start = cc; - while (cc < len && cc < cc_start + 2) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - minute = minute * 10 + str[cc++] - '0'; - } - if (cc == cc_start + 1 || minute >= 60) { - return FALSE; - } - if (cc < len) { - if (str[cc] == ':') { - cc++; - } - cc_start = cc; - while (cc < len && cc < cc_start + 2) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - second = second * 10 + str[cc++] - '0'; - } - if (cc == cc_start + 1 || second >= 60) { - return FALSE; - } - if (cc < len) { - if (str[cc] == '.') { - cc++; - cc_start = cc; - while (cc < len && cc < cc_start + 3) { - if (!FX_IsDigit(str[cc])) { - return FALSE; - } - millisecond = millisecond * 10 + str[cc++] - '0'; - } - if (cc < cc_start + 3 || millisecond >= 1000) { - return FALSE; - } - } - if (cc < len) { - FX_TIMEZONE tzDiff; - tzDiff.tzHour = 0; - tzDiff.tzMinute = 0; - if (str[cc] != 'Z') { - cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); - } - FX_ResolveZone(hour, minute, tzDiff, pLocale); - } - } - } - } - CFX_Unitime ut; - ut.Set(0, 0, 0, hour, minute, second, millisecond); - datetime = datetime + ut; - return TRUE; -} -static FX_WORD FX_GetSolarMonthDays(FX_WORD year, FX_WORD month) { - if (month % 2) { - return 31; - } else if (month == 2) { - return FX_IsLeapYear(year) ? 29 : 28; - } - return 30; -} -static FX_WORD FX_GetWeekDay(FX_WORD year, FX_WORD month, FX_WORD day) { - FX_WORD g_month_day[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}; - FX_WORD nDays = - (year - 1) % 7 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; - nDays += g_month_day[month - 1] + day; - if (FX_IsLeapYear(year) && month > 2) { - nDays++; - } - return nDays % 7; -} -static FX_WORD FX_GetWeekOfMonth(FX_WORD year, FX_WORD month, FX_WORD day) { - FX_WORD week_day = FX_GetWeekDay(year, month, 1); - FX_WORD week_index = 0; - week_index += day / 7; - day = day % 7; - if (week_day + day > 7) { - week_index++; - } - return week_index; -} -static FX_WORD FX_GetWeekOfYear(FX_WORD year, FX_WORD month, FX_WORD day) { - FX_WORD nDays = 0; - for (FX_WORD i = 1; i < month; i++) { - nDays += FX_GetSolarMonthDays(year, i); - } - nDays += day; - FX_WORD week_day = FX_GetWeekDay(year, 1, 1); - FX_WORD week_index = 1; - week_index += nDays / 7; - nDays = nDays % 7; - if (week_day + nDays > 7) { - week_index++; - } - return week_index; -} -static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, - IFX_Locale* pLocale, - const CFX_Unitime& datetime, - CFX_WideString& wsResult) { - FX_BOOL bRet = TRUE; - int32_t year = datetime.GetYear(); - uint8_t month = datetime.GetMonth(); - uint8_t day = datetime.GetDay(); - int32_t ccf = 0; - const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern; - int32_t lenf = wsDatePattern.GetLength(); - while (ccf < lenf) { - if (strf[ccf] == '\'') { - wsResult += FX_GetLiteralText(strf, ccf, lenf); - ccf++; - continue; - } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) { - wsResult += strf[ccf++]; - continue; - } - FX_DWORD dwSymbolNum = 1; - FX_DWORD dwSymbol = strf[ccf++]; - while (ccf < lenf && strf[ccf] == dwSymbol) { - ccf++; - dwSymbolNum++; - } - dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); - if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { - CFX_WideString wsDay; - wsDay.Format(L"%d", day); - wsResult += wsDay; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { - CFX_WideString wsDay; - wsDay.Format(L"%02d", day); - wsResult += wsDay; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { - FX_WORD nDays = 0; - for (int i = 1; i < month; i++) { - nDays += FX_GetSolarMonthDays(year, i); - } - nDays += day; - CFX_WideString wsDays; - wsDays.Format(L"%d", nDays); - wsResult += wsDays; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { - FX_WORD nDays = 0; - for (int i = 1; i < month; i++) { - nDays += FX_GetSolarMonthDays(year, i); - } - nDays += day; - CFX_WideString wsDays; - wsDays.Format(L"%03d", nDays); - wsResult += wsDays; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { - CFX_WideString wsMonth; - wsMonth.Format(L"%d", month); - wsResult += wsMonth; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { - CFX_WideString wsMonth; - wsMonth.Format(L"%02d", month); - wsResult += wsMonth; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { - CFX_WideString wsTemp; - pLocale->GetMonthName(month - 1, wsTemp, TRUE); - wsResult += wsTemp; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { - CFX_WideString wsTemp; - pLocale->GetMonthName(month - 1, wsTemp, FALSE); - wsResult += wsTemp; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { - FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); - CFX_WideString wsWeekDay; - wsWeekDay.Format(L"%d", wWeekDay + 1); - wsResult += wsWeekDay; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { - FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); - CFX_WideString wsTemp; - pLocale->GetDayName(wWeekDay, wsTemp, TRUE); - wsResult += wsTemp; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { - FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); - if (pLocale) { - CFX_WideString wsTemp; - pLocale->GetDayName(wWeekDay, wsTemp, FALSE); - wsResult += wsTemp; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { - FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); - CFX_WideString wsWeekDay; - wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); - wsResult += wsWeekDay; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { - CFX_WideString wsTemp; - pLocale->GetEraName(wsTemp, year < 0); - wsResult += wsTemp; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { - CFX_WideString wsYear; - wsYear.Format(L"%02d", year % 100); - wsResult += wsYear; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { - CFX_WideString wsYear; - wsYear.Format(L"%d", year); - wsResult += wsYear; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { - FX_WORD week_index = FX_GetWeekOfMonth(year, month, day); - CFX_WideString wsWeekInMonth; - wsWeekInMonth.Format(L"%d", week_index); - wsResult += wsWeekInMonth; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { - FX_WORD week_index = FX_GetWeekOfYear(year, month, day); - CFX_WideString wsWeekInYear; - wsWeekInYear.Format(L"%02d", week_index); - wsResult += wsWeekInYear; - } - } - return bRet; -} -static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern, - IFX_Locale* pLocale, - const CFX_Unitime& datetime, - CFX_WideString& wsResult) { - FX_BOOL bGMT = FALSE; - FX_BOOL bRet = TRUE; - uint8_t hour = datetime.GetHour(); - uint8_t minute = datetime.GetMinute(); - uint8_t second = datetime.GetSecond(); - FX_WORD millisecond = datetime.GetMillisecond(); - int32_t ccf = 0; - const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; - int32_t lenf = wsTimePattern.GetLength(); - FX_WORD wHour = hour; - FX_BOOL bPM = FALSE; - if (wsTimePattern.Find('A') != -1) { - if (wHour >= 12) { - bPM = TRUE; - } - } - while (ccf < lenf) { - if (strf[ccf] == '\'') { - wsResult += FX_GetLiteralText(strf, ccf, lenf); - ccf++; - continue; - } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) < 0) { - wsResult += strf[ccf++]; - continue; - } - FX_DWORD dwSymbolNum = 1; - FX_DWORD dwSymbol = strf[ccf++]; - while (ccf < lenf && strf[ccf] == dwSymbol) { - ccf++; - dwSymbolNum++; - } - dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); - if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) { - if (wHour > 12) { - wHour -= 12; - } - CFX_WideString wsHour; - wsHour.Format(L"%d", wHour == 0 ? 12 : wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'h', '2')) { - if (wHour > 12) { - wHour -= 12; - } - CFX_WideString wsHour; - wsHour.Format(L"%02d", wHour == 0 ? 12 : wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { - CFX_WideString wsHour; - wsHour.Format(L"%d", wHour == 0 ? 24 : wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { - CFX_WideString wsHour; - wsHour.Format(L"%02d", wHour == 0 ? 24 : wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1')) { - if (wHour > 12) { - wHour -= 12; - } - CFX_WideString wsHour; - wsHour.Format(L"%d", wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'H', '1')) { - CFX_WideString wsHour; - wsHour.Format(L"%d", wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2')) { - if (wHour > 12) { - wHour -= 12; - } - CFX_WideString wsHour; - wsHour.Format(L"%02d", wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'H', '2')) { - CFX_WideString wsHour; - wsHour.Format(L"%02d", wHour); - wsResult += wsHour; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { - CFX_WideString wsMinute; - wsMinute.Format(L"%d", minute); - wsResult += wsMinute; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { - CFX_WideString wsMinute; - wsMinute.Format(L"%02d", minute); - wsResult += wsMinute; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { - CFX_WideString wsSecond; - wsSecond.Format(L"%d", second); - wsResult += wsSecond; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { - CFX_WideString wsSecond; - wsSecond.Format(L"%02d", second); - wsResult += wsSecond; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { - CFX_WideString wsMilliseconds; - wsMilliseconds.Format(L"%03d", millisecond); - wsResult += wsMilliseconds; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { - CFX_WideString wsMeridiem; - pLocale->GetMeridiemName(wsMeridiem, !bPM); - wsResult += wsMeridiem; - } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { - wsResult += FX_WSTRC(L"GMT"); - FX_TIMEZONE tz; - pLocale->GetTimeZone(tz); - if (!bGMT && (tz.tzHour != 0 || tz.tzMinute != 0)) { - if (tz.tzHour < 0) { - wsResult += FX_WSTRC(L"-"); - } else { - wsResult += FX_WSTRC(L"+"); - } - CFX_WideString wsTimezone; - wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); - wsResult += wsTimezone; - } - } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { - FX_TIMEZONE tz; - pLocale->GetTimeZone(tz); - if (!bGMT && tz.tzHour != 0 && tz.tzMinute != 0) { - if (tz.tzHour < 0) { - wsResult += FX_WSTRC(L"-"); - } else { - wsResult += FX_WSTRC(L"+"); - } - CFX_WideString wsTimezone; - wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); - wsResult += wsTimezone; - } - } - } - return bRet; -} -static FX_BOOL FX_FormatDateTime(const CFX_Unitime& dt, - const CFX_WideString& wsDatePattern, - const CFX_WideString& wsTimePattern, - FX_BOOL bDateFirst, - IFX_Locale* pLocale, - CFX_WideString& wsOutput) { - FX_BOOL bRet = TRUE; - CFX_WideString wsDateOut, wsTimeOut; - if (!wsDatePattern.IsEmpty()) { - bRet &= FX_DateFormat(wsDatePattern, pLocale, dt, wsDateOut); - } - if (!wsTimePattern.IsEmpty()) { - bRet &= FX_TimeFormat(wsTimePattern, pLocale, dt, wsTimeOut); - } - wsOutput = bDateFirst ? wsDateOut + wsTimeOut : wsTimeOut + wsDateOut; - return bRet; -} -FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; - FX_DATETIMETYPE eCategory = - GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); - if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { - return FALSE; - } - CFX_Unitime dt(0); - int32_t iT = wsSrcDateTime.Find(L"T"); - if (iT < 0) { - if (eCategory == FX_DATETIMETYPE_Date) { - FX_DateFromCanonical(wsSrcDateTime, dt); - } else if (eCategory == FX_DATETIMETYPE_Time) { - FX_TimeFromCanonical(wsSrcDateTime, dt, pLocale); - } - } else { - FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); - FX_TimeFromCanonical( - wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1), dt, pLocale); - } - return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, - eCategory != FX_DATETIMETYPE_TimeDate, pLocale, - wsOutput); -} -FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput, - FX_DATETIMETYPE eDateTimeType) { - if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; - FX_DATETIMETYPE eCategory = - GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); - if (!pLocale) { - return FALSE; - } - if (eCategory == FX_DATETIMETYPE_Unknown) { - if (eDateTimeType == FX_DATETIMETYPE_Time) { - wsTimePattern = wsDatePattern; - wsDatePattern.Empty(); - } - eCategory = eDateTimeType; - } - if (eCategory == FX_DATETIMETYPE_Unknown) { - return FALSE; - } - CFX_Unitime dt(0); - int32_t iT = wsSrcDateTime.Find(L"T"); - if (iT < 0) { - if (eCategory == FX_DATETIMETYPE_Date && - FX_DateFromCanonical(wsSrcDateTime, dt)) { - return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, - wsOutput); - } else if (eCategory == FX_DATETIMETYPE_Time && - FX_TimeFromCanonical(wsSrcDateTime, 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, - wsSrcDateTime.GetLength() - iT - 1); - if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { - return FALSE; - } - if (FX_DateFromCanonical(wsSrcDate, dt) && - FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { - return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, - eCategory != FX_DATETIMETYPE_TimeDate, pLocale, - wsOutput); - } - } - return FALSE; -} -FX_BOOL CFX_FormatString::FormatDateTime(const CFX_Unitime& dt, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; - FX_DATETIMETYPE eCategory = - GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); - if (!pLocale) { - return FALSE; - } - return FX_FormatDateTime(dt, wsPattern, wsTimePattern, - eCategory != FX_DATETIMETYPE_TimeDate, pLocale, - wsOutput); -} -FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsTextFormat; - GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); - int32_t iPattern = 0; - const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern) { - if (pStrPattern[iPattern] == '\'') { - wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - iPattern++; - continue; - } else { - wsOutput += pStrPattern[iPattern++]; - continue; - } - } - return TRUE; -} -FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, - CFX_WideString& wsOutput) { - if (wsPattern.IsEmpty()) { - return FALSE; - } - CFX_WideString wsTextFormat; - GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); - int32_t iPattern = 0; - const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat; - int32_t iLenPattern = wsTextFormat.GetLength(); - while (iPattern < iLenPattern) { - if (pStrPattern[iPattern] == '\'') { - wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); - iPattern++; - continue; - } else { - wsOutput += pStrPattern[iPattern++]; - continue; - } - } - return TRUE; -} -IFX_Locale* CFX_FormatString::GetPatternLocale( - const CFX_WideStringC& wsLocale) { - if (m_bUseLCID) { - } - return m_pLocaleMgr->GetLocaleByName(wsLocale); -} -#define FXMATH_DECIMAL_SCALELIMIT 0x1c -#define FXMATH_DECIMAL_NEGMASK (0x80000000L) -#define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) -#define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ - (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) -#define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ - FXMATH_DECIMAL_FORCEBOOL((FLAGS)&FXMATH_DECIMAL_NEGMASK) -#define FXMATH_DECIMAL_FLAGS2SCALE(FLAGS) \ - ((uint8_t)(((FLAGS) & ~FXMATH_DECIMAL_NEGMASK) >> 0x10)) -#define FXMATH_DECIMAL_RSHIFT32BIT(x) ((x) >> 0x10 >> 0x10) -#define FXMATH_DECIMAL_LSHIFT32BIT(x) ((x) << 0x10 << 0x10) -static inline uint8_t fxmath_decimal_helper_div10(uint64_t& phi, - uint64_t& pmid, - uint64_t& plo) { - uint8_t retVal; - pmid += FXMATH_DECIMAL_LSHIFT32BIT(phi % 0xA); - phi /= 0xA; - plo += FXMATH_DECIMAL_LSHIFT32BIT(pmid % 0xA); - pmid /= 0xA; - retVal = plo % 0xA; - plo /= 0xA; - return retVal; -} -static inline uint8_t fxmath_decimal_helper_div10_any(uint64_t nums[], - uint8_t numcount) { - uint8_t retVal = 0; - for (int i = numcount - 1; i > 0; i--) { - nums[i - 1] += FXMATH_DECIMAL_LSHIFT32BIT(nums[i] % 0xA); - nums[i] /= 0xA; - } - if (numcount) { - retVal = nums[0] % 0xA; - nums[0] /= 0xA; - } - return retVal; -} -static inline void fxmath_decimal_helper_mul10(uint64_t& phi, - uint64_t& pmid, - uint64_t& plo) { - plo *= 0xA; - pmid = pmid * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(plo); - plo = (uint32_t)plo; - phi = phi * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(pmid); - pmid = (uint32_t)pmid; -} -static inline void fxmath_decimal_helper_mul10_any(uint64_t nums[], - uint8_t numcount) { - nums[0] *= 0xA; - for (int i = 1; i < numcount; i++) { - nums[i] = nums[i] * 0xA + FXMATH_DECIMAL_RSHIFT32BIT(nums[i - 1]); - nums[i - 1] = (uint32_t)nums[i - 1]; - } -} -static inline void fxmath_decimal_helper_normalize(uint64_t& phi, - uint64_t& pmid, - uint64_t& plo) { - phi += FXMATH_DECIMAL_RSHIFT32BIT(pmid); - pmid = (uint32_t)pmid; - pmid += FXMATH_DECIMAL_RSHIFT32BIT(plo); - plo = (uint32_t)plo; - phi += FXMATH_DECIMAL_RSHIFT32BIT(pmid); - pmid = (uint32_t)pmid; -} -static inline void fxmath_decimal_helper_normalize_any(uint64_t nums[], - uint8_t len) { - { - for (int i = len - 2; i > 0; i--) { - nums[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(nums[i]); - nums[i] = (uint32_t)nums[i]; - } - } - { - for (int i = 0; i < len - 1; i++) { - nums[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(nums[i]); - nums[i] = (uint32_t)nums[i]; - } - } -} -static inline int8_t fxmath_decimal_helper_raw_compare(uint32_t hi1, - uint32_t mid1, - uint32_t lo1, - uint32_t hi2, - uint32_t mid2, - uint32_t lo2) { - int8_t retVal = 0; - if (!retVal) { - retVal += (hi1 > hi2 ? 1 : (hi1 < hi2 ? -1 : 0)); - } - if (!retVal) { - retVal += (mid1 > mid2 ? 1 : (mid1 < mid2 ? -1 : 0)); - } - if (!retVal) { - retVal += (lo1 > lo2 ? 1 : (lo1 < lo2 ? -1 : 0)); - } - return retVal; -} -static inline int8_t fxmath_decimal_helper_raw_compare_any(uint64_t a[], - uint8_t al, - uint64_t b[], - uint8_t bl) { - int8_t retVal = 0; - for (int i = std::max(al - 1, bl - 1); i >= 0; i--) { - uint64_t l = (i >= al ? 0 : a[i]), r = (i >= bl ? 0 : b[i]); - retVal += (l > r ? 1 : (l < r ? -1 : 0)); - if (retVal) { - return retVal; - } - } - return retVal; -} -static inline void fxmath_decimal_helper_dec_any(uint64_t a[], uint8_t al) { - for (int i = 0; i < al; i++) { - if (a[i]--) { - return; - } - } -} -static inline void fxmath_decimal_helper_inc_any(uint64_t a[], uint8_t al) { - for (int i = 0; i < al; i++) { - a[i]++; - if ((uint32_t)a[i] == a[i]) { - return; - } - a[i] = 0; - } -} -static inline void fxmath_decimal_helper_raw_mul(uint64_t a[], - uint8_t al, - uint64_t b[], - uint8_t bl, - uint64_t c[], - uint8_t cl) { - assert(al + bl <= cl); - { - for (int i = 0; i < cl; i++) { - c[i] = 0; - } - } - { - for (int i = 0; i < al; i++) { - for (int j = 0; j < bl; j++) { - uint64_t m = (uint64_t)a[i] * b[j]; - c[i + j] += (uint32_t)m; - c[i + j + 1] += FXMATH_DECIMAL_RSHIFT32BIT(m); - } - } - } - { - for (int i = 0; i < cl - 1; i++) { - c[i + 1] += FXMATH_DECIMAL_RSHIFT32BIT(c[i]); - c[i] = (uint32_t)c[i]; - } - } - { - for (int i = 0; i < cl; i++) { - c[i] = (uint32_t)c[i]; - } - } -} -static inline void fxmath_decimal_helper_raw_div(uint64_t a[], - uint8_t al, - uint64_t b[], - uint8_t bl, - uint64_t c[], - uint8_t cl) { - int i; - for (i = 0; i < cl; i++) { - c[i] = 0; - } - uint64_t left[16] = {0}, right[16] = {0}; - left[0] = 0; - for (i = 0; i < al; i++) { - right[i] = a[i]; - } - uint64_t tmp[16]; - while (fxmath_decimal_helper_raw_compare_any(left, al, right, al) <= 0) { - uint64_t cur[16]; - for (i = 0; i < al; i++) { - cur[i] = left[i] + right[i]; - } - for (i = al - 1; i >= 0; i--) { - if (i) { - cur[i - 1] += FXMATH_DECIMAL_LSHIFT32BIT(cur[i] % 2); - } - cur[i] /= 2; - } - fxmath_decimal_helper_raw_mul(cur, al, b, bl, tmp, 16); - switch (fxmath_decimal_helper_raw_compare_any(tmp, 16, a, al)) { - case -1: - for (i = 0; i < 16; i++) { - left[i] = cur[i]; - } - left[0]++; - fxmath_decimal_helper_normalize_any(left, al); - break; - case 1: - for (i = 0; i < 16; i++) { - right[i] = cur[i]; - } - fxmath_decimal_helper_dec_any(right, al); - break; - case 0: - for (i = 0; i < std::min(al, cl); i++) { - c[i] = cur[i]; - } - return; - } - } - for (i = 0; i < std::min(al, cl); i++) { - c[i] = left[i]; - } -} -static inline FX_BOOL fxmath_decimal_helper_outofrange(uint64_t a[], - uint8_t al, - uint8_t goal) { - for (int i = goal; i < al; i++) { - if (a[i]) { - return TRUE; - } - } - return FALSE; -} -static inline void fxmath_decimal_helper_shrinkintorange(uint64_t a[], - uint8_t al, - uint8_t goal, - uint8_t& scale) { - FX_BOOL bRoundUp = FALSE; - while (scale != 0 && (scale > FXMATH_DECIMAL_SCALELIMIT || - fxmath_decimal_helper_outofrange(a, al, goal))) { - bRoundUp = fxmath_decimal_helper_div10_any(a, al) >= 5; - scale--; - } - if (bRoundUp) { - fxmath_decimal_helper_normalize_any(a, goal); - fxmath_decimal_helper_inc_any(a, goal); - } -} -static inline void fxmath_decimal_helper_truncate(uint64_t& phi, - uint64_t& pmid, - uint64_t& plo, - uint8_t& scale, - uint8_t minscale = 0) { - while (scale > minscale) { - uint64_t thi = phi, tmid = pmid, tlo = plo; - if (fxmath_decimal_helper_div10(thi, tmid, tlo) != 0) { - break; - } - phi = thi, pmid = tmid, plo = tlo; - scale--; - } -} -CFX_Decimal::CFX_Decimal() { - m_uLo = m_uMid = m_uHi = m_uFlags = 0; -} -CFX_Decimal::CFX_Decimal(uint64_t val) { - m_uLo = (uint32_t)val; - m_uMid = (uint32_t)FXMATH_DECIMAL_RSHIFT32BIT(val); - m_uHi = 0; - m_uFlags = 0; -} -CFX_Decimal::CFX_Decimal(uint32_t val) { - m_uLo = (uint32_t)val; - m_uMid = m_uHi = 0; - m_uFlags = 0; -} -CFX_Decimal::CFX_Decimal(uint32_t lo, - uint32_t mid, - uint32_t hi, - FX_BOOL neg, - uint8_t scale) { - scale = (scale > FXMATH_DECIMAL_SCALELIMIT ? 0 : scale); - m_uLo = lo; - m_uMid = mid; - m_uHi = hi; - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(neg && IsNotZero(), scale); -} -CFX_Decimal::CFX_Decimal(int32_t val) { - if (val >= 0) { - *this = CFX_Decimal((uint32_t)val); - } else { - *this = CFX_Decimal((uint32_t)-val); - SetNegate(); - } -} -CFX_Decimal::CFX_Decimal(int64_t val) { - if (val >= 0) { - *this = CFX_Decimal((uint64_t)val); - } else { - *this = CFX_Decimal((uint64_t)-val); - SetNegate(); - } -} -CFX_Decimal::CFX_Decimal(FX_FLOAT val, uint8_t scale) { - FX_FLOAT newval = fabs(val); - uint64_t phi, pmid, plo; - plo = (uint64_t)newval; - pmid = (uint64_t)(newval / 1e32); - phi = (uint64_t)(newval / 1e64); - newval = FXSYS_fmod(newval, 1.0f); - for (uint8_t iter = 0; iter < scale; iter++) { - fxmath_decimal_helper_mul10(phi, pmid, plo); - newval *= 10; - plo += (uint64_t)newval; - newval = FXSYS_fmod(newval, 1.0f); - } - plo += FXSYS_round(newval); - fxmath_decimal_helper_normalize(phi, pmid, plo); - m_uHi = (uint32_t)phi; - m_uMid = (uint32_t)pmid; - m_uLo = (uint32_t)plo; - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale); -} -CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) { - const FX_WCHAR* str = strObj.GetPtr(); - const FX_WCHAR* strBound = str + strObj.GetLength(); - FX_BOOL pointmet = 0; - FX_BOOL negmet = 0; - uint8_t scale = 0; - m_uHi = m_uMid = m_uLo = 0; - while (str != strBound && *str == ' ') { - str++; - } - if (str != strBound && *str == '-') { - negmet = 1; - str++; - } else if (str != strBound && *str == '+') { - str++; - } - while (str != strBound && ((*str >= '0' && *str <= '9') || *str == '.') && - scale < FXMATH_DECIMAL_SCALELIMIT) { - if (*str == '.') { - if (pointmet) { - goto cont; - } - pointmet = 1; - } else { - m_uHi = m_uHi * 0xA + FXMATH_DECIMAL_RSHIFT32BIT((uint64_t)m_uMid * 0xA); - m_uMid = m_uMid * 0xA + FXMATH_DECIMAL_RSHIFT32BIT((uint64_t)m_uLo * 0xA); - m_uLo = m_uLo * 0xA + (*str - '0'); - if (pointmet) { - scale++; - } - } - cont: - str++; - } - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); -} - -CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { - *this = CFX_Decimal(CFX_WideString::FromLocal(strObj)); -} - -CFX_Decimal::operator CFX_WideString() const { - CFX_WideString retString; - CFX_WideString tmpbuf; - uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; - while (phi || pmid || plo) { - tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; - } - uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); - uint8_t scale = (uint8_t)FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); - while (scale >= outputlen) { - tmpbuf += '0'; - outputlen++; - } - if (FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero()) { - retString += '-'; - } - for (uint8_t idx = 0; idx < outputlen; idx++) { - if (idx == (outputlen - scale) && scale != 0) { - retString += '.'; - } - retString += tmpbuf[outputlen - 1 - idx]; - } - return retString; -} -CFX_Decimal::operator double() const { - double pow = (double)(1 << 16) * (1 << 16); - double base = - ((double)m_uHi) * pow * pow + ((double)m_uMid) * pow + ((double)m_uLo); - int8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); - FX_BOOL bNeg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags); - return (bNeg ? -1 : 1) * base * ::pow(10.0, -scale); -} -void CFX_Decimal::SetScale(uint8_t newscale) { - uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); - if (newscale > oldscale) { - uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; - for (uint8_t iter = 0; iter < newscale - oldscale; iter++) { - fxmath_decimal_helper_mul10(phi, pmid, plo); - } - m_uHi = (uint32_t)phi; - m_uMid = (uint32_t)pmid; - m_uLo = (uint32_t)plo; - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( - FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), newscale); - } else if (newscale < oldscale) { - uint64_t phi, pmid, plo; - phi = 0, pmid = 0, plo = 5; - { - for (uint8_t iter = 0; iter < oldscale - newscale - 1; iter++) { - fxmath_decimal_helper_mul10(phi, pmid, plo); - } - } - phi += m_uHi; - pmid += m_uMid; - plo += m_uLo; - fxmath_decimal_helper_normalize(phi, pmid, plo); - { - for (uint8_t iter = 0; iter < oldscale - newscale; iter++) { - fxmath_decimal_helper_div10(phi, pmid, plo); - } - } - m_uHi = (uint32_t)phi; - m_uMid = (uint32_t)pmid; - m_uLo = (uint32_t)plo; - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( - FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), newscale); - } -} -uint8_t CFX_Decimal::GetScale() { - uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); - return oldscale; -} -void CFX_Decimal::SetAbs() { - m_uFlags &= ~FXMATH_DECIMAL_NEGMASK; -} -void CFX_Decimal::SetNegate() { - if (IsNotZero()) { - m_uFlags ^= FXMATH_DECIMAL_NEGMASK; - } -} -void CFX_Decimal::FloorOrCeil(FX_BOOL bFloor) { - uint64_t nums[3] = {m_uLo, m_uMid, m_uHi}; - FX_BOOL bDataLoss = FALSE; - for (int i = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); i > 0; i--) { - bDataLoss = fxmath_decimal_helper_div10_any(nums, 3) || bDataLoss; - } - if (bDataLoss && (bFloor ? FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) - : !FXMATH_DECIMAL_FLAGS2NEG(m_uFlags))) { - fxmath_decimal_helper_inc_any(nums, 3); - } - m_uHi = (uint32_t)nums[2]; - m_uMid = (uint32_t)nums[1]; - m_uLo = (uint32_t)nums[0]; - m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( - FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), 0); -} -void CFX_Decimal::SetFloor() { - FloorOrCeil(TRUE); -} -void CFX_Decimal::SetCeiling() { - FloorOrCeil(FALSE); -} -void CFX_Decimal::SetTruncate() { - FloorOrCeil(!FXMATH_DECIMAL_FLAGS2NEG(m_uFlags)); -} -void CFX_Decimal::Swap(CFX_Decimal& val) { - uint32_t tmp; - tmp = m_uHi; - m_uHi = val.m_uHi; - val.m_uHi = tmp; - tmp = m_uMid; - m_uMid = val.m_uMid; - val.m_uMid = tmp; - tmp = m_uLo; - m_uLo = val.m_uLo; - val.m_uLo = tmp; - tmp = m_uFlags; - m_uFlags = val.m_uFlags; - val.m_uFlags = tmp; -} -int8_t CFX_Decimal::Compare(const CFX_Decimal& val) const { - CFX_Decimal lhs = *this, rhs = val; - int8_t retVal = 0; - if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { - uint8_t scale = std::min(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); - lhs.SetScale(scale); - rhs.SetScale(scale); - } - retVal = -(FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) - - FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)); - if (retVal) { - return retVal; - } - retVal = fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, - rhs.m_uHi, rhs.m_uMid, rhs.m_uLo); - return (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) ? -retVal : retVal); -} -CFX_Decimal CFX_Decimal::AddOrMinus(const CFX_Decimal& val, - FX_BOOL isAdding) const { - CFX_Decimal lhs = *this, rhs = val; - if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { - uint8_t scale = std::max(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); - lhs.SetScale(scale); - rhs.SetScale(scale); - } - if (!isAdding) { - rhs.SetNegate(); - } - if (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) == - FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)) { - uint64_t phi = lhs.m_uHi, pmid = lhs.m_uMid, plo = lhs.m_uLo; - phi += rhs.m_uHi; - pmid += rhs.m_uMid; - plo += rhs.m_uLo; - fxmath_decimal_helper_normalize(phi, pmid, plo); - if (FXMATH_DECIMAL_RSHIFT32BIT(phi) && - FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != 0) { - fxmath_decimal_helper_div10(phi, pmid, plo); - lhs.m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( - FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags), - FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) - 1); - } - lhs.m_uHi = (uint32_t)phi; - lhs.m_uMid = (uint32_t)pmid; - lhs.m_uLo = (uint32_t)plo; - return lhs; - } else { - if (fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, - rhs.m_uHi, rhs.m_uMid, - rhs.m_uLo) < 0) { - lhs.Swap(rhs); - } - lhs.m_uHi -= rhs.m_uHi; - if (lhs.m_uMid < rhs.m_uMid) { - lhs.m_uHi--; - } - lhs.m_uMid -= rhs.m_uMid; - if (lhs.m_uLo < rhs.m_uLo) { - if (!lhs.m_uMid) { - lhs.m_uHi--; - } - lhs.m_uMid--; - } - lhs.m_uLo -= rhs.m_uLo; - return lhs; - } -} -CFX_Decimal CFX_Decimal::Multiply(const CFX_Decimal& val) const { - uint64_t a[3] = {m_uLo, m_uMid, m_uHi}, - b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}; - uint64_t c[6]; - fxmath_decimal_helper_raw_mul(a, 3, b, 3, c, 6); - FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ - FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); - uint8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) + - FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); - fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); - return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, - scale); -} -CFX_Decimal CFX_Decimal::Divide(const CFX_Decimal& val) const { - if (!val.IsNotZero()) { - return CFX_Decimal(); - } - FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ - FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); - uint64_t a[7] = {m_uLo, m_uMid, m_uHi}, - b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}, c[7] = {0}; - uint8_t scale = 0; - if (FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) < - FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags)) { - for (int i = FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags) - - FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); - i > 0; i--) { - fxmath_decimal_helper_mul10_any(a, 7); - } - } else { - scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) - - FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); - } - uint8_t minscale = scale; - if (!IsNotZero()) { - return CFX_Decimal(0, 0, 0, 0, minscale); - } - while (!a[6]) { - fxmath_decimal_helper_mul10_any(a, 7); - scale++; - } - fxmath_decimal_helper_div10_any(a, 7); - scale--; - fxmath_decimal_helper_raw_div(a, 6, b, 3, c, 7); - fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); - fxmath_decimal_helper_truncate(c[2], c[1], c[0], scale, minscale); - return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, - scale); -} -CFX_Decimal CFX_Decimal::Modulus(const CFX_Decimal& val) const { - CFX_Decimal lhs = *this, rhs_abs = val; - rhs_abs.SetAbs(); - if (!rhs_abs.IsNotZero()) { - return *this; - } - while (TRUE) { - CFX_Decimal lhs_abs = lhs; - lhs_abs.SetAbs(); - if (lhs_abs < rhs_abs) { - break; - } - CFX_Decimal quot = lhs / rhs_abs; - quot.SetTruncate(); - lhs = lhs - quot * rhs_abs; - } - return lhs; -} -bool CFX_Decimal::operator==(const CFX_Decimal& val) const { - return Compare(val) == 0; -} -bool CFX_Decimal::operator<=(const CFX_Decimal& val) const { - return Compare(val) <= 0; -} -bool CFX_Decimal::operator>=(const CFX_Decimal& val) const { - return Compare(val) >= 0; -} -bool CFX_Decimal::operator!=(const CFX_Decimal& val) const { - return Compare(val) != 0; -} -bool CFX_Decimal::operator<(const CFX_Decimal& val) const { - return Compare(val) < 0; -} -bool CFX_Decimal::operator>(const CFX_Decimal& val) const { - return Compare(val) > 0; -} -CFX_Decimal CFX_Decimal::operator+(const CFX_Decimal& val) const { - return AddOrMinus(val, TRUE); -} -CFX_Decimal CFX_Decimal::operator-(const CFX_Decimal& val) const { - return AddOrMinus(val, FALSE); -} -CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { - return Multiply(val); -} -CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { - return Divide(val); -} -CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { - return Modulus(val); -} diff --git a/xfa/src/fgas/localization/fgas_locale.h b/xfa/src/fgas/localization/fgas_locale.h deleted file mode 100644 index 03dd518715..0000000000 --- a/xfa/src/fgas/localization/fgas_locale.h +++ /dev/null @@ -1,206 +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_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ -#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ - -#include "core/include/fxcrt/fx_xml.h" -#include "xfa/src/fgas/localization/fgas_datetime.h" - -class CFX_Unitime; - -enum FX_LOCALENUMSYMBOL { - FX_LOCALENUMSYMBOL_Decimal, - FX_LOCALENUMSYMBOL_Grouping, - FX_LOCALENUMSYMBOL_Percent, - FX_LOCALENUMSYMBOL_Minus, - FX_LOCALENUMSYMBOL_Zero, - FX_LOCALENUMSYMBOL_CurrencySymbol, - FX_LOCALENUMSYMBOL_CurrencyName, -}; -enum FX_LOCALEDATETIMESUBCATEGORY { - FX_LOCALEDATETIMESUBCATEGORY_Default, - FX_LOCALEDATETIMESUBCATEGORY_Short, - FX_LOCALEDATETIMESUBCATEGORY_Medium, - FX_LOCALEDATETIMESUBCATEGORY_Full, - FX_LOCALEDATETIMESUBCATEGORY_Long, -}; -enum FX_LOCALENUMSUBCATEGORY { - FX_LOCALENUMPATTERN_Percent, - FX_LOCALENUMPATTERN_Currency, - FX_LOCALENUMPATTERN_Decimal, - FX_LOCALENUMPATTERN_Integer, -}; -enum FX_LOCALECATEGORY { - FX_LOCALECATEGORY_Unknown, - FX_LOCALECATEGORY_Date, - FX_LOCALECATEGORY_Time, - FX_LOCALECATEGORY_DateTime, - FX_LOCALECATEGORY_Num, - FX_LOCALECATEGORY_Text, - FX_LOCALECATEGORY_Zero, - FX_LOCALECATEGORY_Null, -}; -enum FX_DATETIMETYPE { - FX_DATETIMETYPE_Unknown, - FX_DATETIMETYPE_Date, - FX_DATETIMETYPE_Time, - FX_DATETIMETYPE_DateTime, - FX_DATETIMETYPE_TimeDate, -}; - -class IFX_Locale { - public: - static IFX_Locale* Create(CXML_Element* pLocaleData); - - virtual ~IFX_Locale() {} - virtual void Release() = 0; - - virtual CFX_WideString GetName() = 0; - - virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const = 0; - virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0; - virtual void GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr = TRUE) const = 0; - virtual void GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr = TRUE) const = 0; - virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM = TRUE) const = 0; - virtual void GetTimeZone(FX_TIMEZONE& tz) const = 0; - virtual void GetEraName(CFX_WideString& wsEraName, - FX_BOOL bAD = TRUE) const = 0; - virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const = 0; - virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const = 0; - virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const = 0; -}; - -class IFX_LocaleMgr { - public: - virtual ~IFX_LocaleMgr() {} - virtual void Release() = 0; - virtual FX_WORD GetDefLocaleID() = 0; - virtual IFX_Locale* GetDefLocale() = 0; - virtual IFX_Locale* GetLocale(FX_WORD lcid) = 0; - virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName) = 0; -}; -IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, - FX_WORD wDefaultLCID); -void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult); -FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, - CFX_Unitime& datetime); -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 FX_WORD 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(); - CFX_Decimal(uint32_t val); - CFX_Decimal(uint64_t val); - CFX_Decimal(int32_t val); - CFX_Decimal(int64_t val); - CFX_Decimal(FX_FLOAT val, uint8_t scale = 3); - CFX_Decimal(const CFX_WideStringC& str); - CFX_Decimal(const CFX_ByteStringC& str); - operator CFX_WideString() const; - operator double() const; - bool operator==(const CFX_Decimal& val) const; - bool operator<=(const CFX_Decimal& val) const; - bool operator>=(const CFX_Decimal& val) const; - bool operator!=(const CFX_Decimal& val) const; - bool operator<(const CFX_Decimal& val) const; - bool operator>(const CFX_Decimal& val) const; - CFX_Decimal operator+(const CFX_Decimal& val) const; - CFX_Decimal operator-(const CFX_Decimal& val) const; - CFX_Decimal operator*(const CFX_Decimal& val) const; - CFX_Decimal operator/(const CFX_Decimal& val) const; - CFX_Decimal operator%(const CFX_Decimal& val) const; - void SetScale(uint8_t newScale); - uint8_t GetScale(); - void SetAbs(); - void SetNegate(); - void SetFloor(); - void SetCeiling(); - void SetTruncate(); - - protected: - CFX_Decimal(uint32_t hi, - uint32_t mid, - uint32_t lo, - FX_BOOL neg, - uint8_t scale); - inline FX_BOOL IsNotZero() const { return m_uHi || m_uMid || m_uLo; } - inline int8_t Compare(const CFX_Decimal& val) const; - inline void Swap(CFX_Decimal& val); - inline void FloorOrCeil(FX_BOOL bFloor); - CFX_Decimal AddOrMinus(const CFX_Decimal& val, FX_BOOL isAdding) const; - CFX_Decimal Multiply(const CFX_Decimal& val) const; - CFX_Decimal Divide(const CFX_Decimal& val) const; - CFX_Decimal Modulus(const CFX_Decimal& val) const; - uint32_t m_uFlags; - uint32_t m_uHi; - uint32_t m_uLo; - uint32_t m_uMid; -}; - -#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_ diff --git a/xfa/src/fgas/localization/fgas_localeimp.h b/xfa/src/fgas/localization/fgas_localeimp.h deleted file mode 100644 index 5da8b51208..0000000000 --- a/xfa/src/fgas/localization/fgas_localeimp.h +++ /dev/null @@ -1,122 +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_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ -#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ - -#include "xfa/src/fgas/localization/fgas_locale.h" - -class CFX_LCNumeric; - -class CFX_Locale : public IFX_Locale { - public: - CFX_Locale(CXML_Element* pLocaleData); - virtual void Release() { delete this; } - - virtual CFX_WideString GetName(); - virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const; - - virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; - virtual void GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM = TRUE) const; - virtual void GetTimeZone(FX_TIMEZONE& tz) const; - virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; - - virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const; - - protected: - virtual ~CFX_Locale(); - CXML_Element* m_pElement; -}; - -class CFX_FormatString : public IFX_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 FX_WORD 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); - - protected: - virtual ~CFX_FormatString(); - IFX_Locale* GetTextFormat(const CFX_WideString& wsPattern, - const CFX_WideStringC& wsCategory, - CFX_WideString& wsPurgePattern); - IFX_Locale* GetNumericFormat(const CFX_WideString& wsPattern, - int32_t& iDotIndex, - FX_DWORD& dwStyle, - CFX_WideString& wsPurgePattern); - FX_BOOL FormatStrNum(const CFX_WideStringC& wsInputNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput); - FX_BOOL FormatLCNumeric(CFX_LCNumeric& lcNum, - const CFX_WideString& wsPattern, - CFX_WideString& wsOutput); - FX_DATETIMETYPE GetDateTimeFormat(const CFX_WideString& wsPattern, - IFX_Locale*& pLocale, - CFX_WideString& wsDatePattern, - CFX_WideString& wsTimePattern); - IFX_Locale* GetPatternLocale(const CFX_WideStringC& wsLocale); - IFX_LocaleMgr* m_pLocaleMgr; - FX_BOOL m_bUseLCID; -}; - -#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEIMP_H_ diff --git a/xfa/src/fgas/localization/fgas_localemgr.cpp b/xfa/src/fgas/localization/fgas_localemgr.cpp deleted file mode 100644 index 81dbfd3885..0000000000 --- a/xfa/src/fgas/localization/fgas_localemgr.cpp +++ /dev/null @@ -1,97 +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/src/fgas/localization/fgas_localemgr.h" - -#include "core/include/fxcrt/fx_xml.h" - -IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, - FX_WORD wDefaultLCID) { - void* pPathHandle = FX_OpenFolder(pszLocalPath); - if (!pPathHandle) { - return NULL; - } - CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID); - CFX_WideString wsFileName; - FX_BOOL bFolder = FALSE; - while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) { - if (!bFolder) { - if (wsFileName.GetLength() < 4) { - continue; - } - CFX_WideString wsExt = wsFileName.Right(4); - wsExt.MakeLower(); - if (wsExt != L".xml") { - continue; - } - CFX_WideString wsFullPath(pszLocalPath); - wsFullPath += L"\\" + wsFileName; - IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath); - if (!pRead) { - continue; - } - CXML_Element* pXmlLocale = CXML_Element::Parse(pRead); - pRead->Release(); - CFX_ByteString bssp = pXmlLocale->GetNamespace(); - if (bssp == "http://www.foxitsoftware.com/localization") { - CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid"); - wchar_t* pEnd = NULL; - FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16); - if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) { - delete pXmlLocale; - } else { - pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale); - } - } else { - delete pXmlLocale; - } - } - } - FX_CloseFolder(pPathHandle); - return pLocaleMgr; -} -CFX_LocaleMgr::CFX_LocaleMgr(FX_WORD wDefLCID) : m_wDefLCID(wDefLCID) {} -CFX_LocaleMgr::~CFX_LocaleMgr() { - FX_POSITION ps = m_lcid2locale.GetStartPosition(); - while (ps) { - void* plcid; - IFX_Locale* pLocale = NULL; - m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale); - pLocale->Release(); - } - m_lcid2locale.RemoveAll(); - ps = m_lcid2xml.GetStartPosition(); - while (ps) { - void* plcid; - CXML_Element* pxml = NULL; - m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml); - delete pxml; - } - m_lcid2xml.RemoveAll(); -} -FX_WORD CFX_LocaleMgr::GetDefLocaleID() { - return m_wDefLCID; -} -IFX_Locale* CFX_LocaleMgr::GetDefLocale() { - return GetLocale(m_wDefLCID); -} -IFX_Locale* CFX_LocaleMgr::GetLocale(FX_WORD lcid) { - IFX_Locale* pLocale = - (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid); - if (!pLocale) { - CXML_Element* pxml = - (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid); - if (pxml) { - pLocale = IFX_Locale::Create(pxml); - m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale); - } - } - return pLocale; -} -IFX_Locale* CFX_LocaleMgr::GetLocaleByName( - const CFX_WideStringC& wsLocaleName) { - return NULL; -} diff --git a/xfa/src/fgas/localization/fgas_localemgr.h b/xfa/src/fgas/localization/fgas_localemgr.h deleted file mode 100644 index f2693c7f60..0000000000 --- a/xfa/src/fgas/localization/fgas_localemgr.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_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ -#define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ - -#include "xfa/src/fgas/localization/fgas_locale.h" - -class CFX_LocaleMgr : public IFX_LocaleMgr { - public: - CFX_LocaleMgr(FX_WORD wDefLCID); - virtual void Release() { delete this; } - virtual FX_WORD GetDefLocaleID(); - virtual IFX_Locale* GetDefLocale(); - virtual IFX_Locale* GetLocale(FX_WORD lcid); - virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName); - CFX_MapPtrToPtr m_lcid2xml; - - protected: - ~CFX_LocaleMgr(); - CFX_MapPtrToPtr m_lcid2locale; - FX_WORD m_wDefLCID; -}; - -#endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_ diff --git a/xfa/src/fgas/xml/fgas_sax.h b/xfa/src/fgas/xml/fgas_sax.h deleted file mode 100644 index 50762d4401..0000000000 --- a/xfa/src/fgas/xml/fgas_sax.h +++ /dev/null @@ -1,68 +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_SRC_FGAS_XML_FGAS_SAX_H_ -#define XFA_SRC_FGAS_XML_FGAS_SAX_H_ - -#include "core/include/fxcrt/fx_basic.h" - -#define FX_SAXPARSEMODE_NotConvert_amp 0x0001 -#define FX_SAXPARSEMODE_NotConvert_lt 0x0002 -#define FX_SAXPARSEMODE_NotConvert_gt 0x0004 -#define FX_SAXPARSEMODE_NotConvert_apos 0x0008 -#define FX_SAXPARSEMODE_NotConvert_quot 0x0010 -#define FX_SAXPARSEMODE_NotConvert_sharp 0x0020 -#define FX_SAXPARSEMODE_NotSkipSpace 0x0100 - -enum FX_SAXNODE { - FX_SAXNODE_Unknown = 0, - FX_SAXNODE_Instruction, - FX_SAXNODE_Declaration, - FX_SAXNODE_Comment, - FX_SAXNODE_Tag, - FX_SAXNODE_Text, - FX_SAXNODE_CharData, -}; - -class IFX_SAXReaderHandler { - public: - virtual ~IFX_SAXReaderHandler() {} - virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName, - FX_SAXNODE eType, - FX_DWORD 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, - FX_DWORD dwStartPos) = 0; - virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos) = 0; - virtual void OnTagEnd(void* pTag, - const CFX_ByteStringC& bsTagName, - FX_DWORD dwEndPos) = 0; - virtual void OnTargetData(void* pTag, - FX_SAXNODE eType, - const CFX_ByteStringC& bsData, - FX_DWORD dwStartPos) = 0; -}; - -class IFX_SAXReader { - public: - virtual ~IFX_SAXReader() {} - virtual void Release() = 0; - virtual int32_t StartParse(IFX_FileRead* pFile, - FX_DWORD dwStart = 0, - FX_DWORD dwLen = -1, - FX_DWORD dwParseMode = 0) = 0; - virtual int32_t ContinueParse(IFX_Pause* pPause = NULL) = 0; - virtual void SkipCurrentNode() = 0; - virtual void SetHandler(IFX_SAXReaderHandler* pHandler) = 0; -}; -IFX_SAXReader* FX_SAXReader_Create(); - -#endif // XFA_SRC_FGAS_XML_FGAS_SAX_H_ diff --git a/xfa/src/fgas/xml/fgas_sax_imp.cpp b/xfa/src/fgas/xml/fgas_sax_imp.cpp deleted file mode 100644 index f30a357497..0000000000 --- a/xfa/src/fgas/xml/fgas_sax_imp.cpp +++ /dev/null @@ -1,688 +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/src/fgas/xml/fgas_sax_imp.h" - -#include <algorithm> - -namespace { - -const FX_DWORD kSaxFileBufSize = 32768; - -} // namespace - -IFX_SAXReader* FX_SAXReader_Create() { - return new CFX_SAXReader; -} -CFX_SAXFile::CFX_SAXFile() - : m_pFile(NULL), - m_dwStart(0), - m_dwEnd(0), - m_dwCur(0), - m_pBuf(NULL), - m_dwBufSize(0), - m_dwBufIndex(0) {} -FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile, - FX_DWORD dwStart, - FX_DWORD dwLen) { - FXSYS_assert(m_pFile == NULL && pFile != NULL); - FX_DWORD dwSize = pFile->GetSize(); - if (dwStart >= dwSize) { - return FALSE; - } - if (dwLen == -1 || dwStart + dwLen > dwSize) { - dwLen = dwSize - dwStart; - } - if (dwLen == 0) { - return FALSE; - } - m_dwBufSize = std::min(dwLen, kSaxFileBufSize); - m_pBuf = FX_Alloc(uint8_t, m_dwBufSize); - if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) { - return FALSE; - } - m_dwStart = dwStart; - m_dwEnd = dwStart + dwLen; - m_dwCur = dwStart; - m_pFile = pFile; - m_dwBufIndex = 0; - return TRUE; -} -FX_BOOL CFX_SAXFile::ReadNextBlock() { - FXSYS_assert(m_pFile != NULL); - FX_DWORD dwSize = m_dwEnd - m_dwCur; - if (dwSize == 0) { - return FALSE; - } - m_dwBufSize = std::min(dwSize, kSaxFileBufSize); - if (!m_pFile->ReadBlock(m_pBuf, m_dwCur, m_dwBufSize)) { - return FALSE; - } - m_dwBufIndex = 0; - return TRUE; -} -void CFX_SAXFile::Reset() { - if (m_pBuf) { - FX_Free(m_pBuf); - m_pBuf = NULL; - } - m_pFile = NULL; -} -CFX_SAXReader::CFX_SAXReader() - : m_File(), - m_pHandler(nullptr), - m_iState(-1), - m_pRoot(nullptr), - m_pCurItem(nullptr), - m_dwItemID(0), - m_iDataSize(256), - m_iNameSize(256), - m_dwParseMode(0), - m_pCommentContext(nullptr) { - m_pszData = FX_Alloc(uint8_t, m_iDataSize); - m_pszName = FX_Alloc(uint8_t, m_iNameSize); -} -CFX_SAXReader::~CFX_SAXReader() { - Reset(); - if (m_pszData) { - FX_Free(m_pszData); - m_pszData = NULL; - } - if (m_pszName) { - FX_Free(m_pszName); - m_pszName = NULL; - } -} -void CFX_SAXReader::Reset() { - m_File.Reset(); - CFX_SAXItem* pItem = m_pRoot; - while (pItem) { - CFX_SAXItem* pNext = pItem->m_pNext; - delete pItem; - pItem = pNext; - } - m_pRoot = NULL; - m_pCurItem = NULL; - m_dwItemID = 0; - m_SkipStack.RemoveAll(); - m_SkipChar = 0; - m_iDataLength = 0; - m_iEntityStart = -1; - m_iNameLength = 0; - m_iDataPos = 0; - if (m_pCommentContext) { - delete m_pCommentContext; - m_pCommentContext = NULL; - } -} -inline void CFX_SAXReader::Push() { - CFX_SAXItem* pNew = new CFX_SAXItem; - pNew->m_dwID = ++m_dwItemID; - pNew->m_bSkip = m_pCurItem->m_bSkip; - pNew->m_pPrev = m_pCurItem; - m_pCurItem->m_pNext = pNew; - m_pCurItem = pNew; -} -inline void CFX_SAXReader::Pop() { - if (!m_pCurItem) { - return; - } - CFX_SAXItem* pPrev = m_pCurItem->m_pPrev; - pPrev->m_pNext = NULL; - delete m_pCurItem; - m_pCurItem = pPrev; -} -inline void CFX_SAXReader::AppendData(uint8_t ch) { - ReallocDataBuffer(); - m_pszData[m_iDataPos++] = ch; -} -inline void CFX_SAXReader::AppendName(uint8_t ch) { - ReallocNameBuffer(); - m_pszName[m_iDataPos++] = ch; -} -void CFX_SAXReader::ReallocDataBuffer() { - if (m_iDataPos < m_iDataSize) { - return; - } - if (m_iDataSize <= 1024 * 1024) { - m_iDataSize *= 2; - } else { - m_iDataSize += 1024 * 1024; - } - m_pszData = (uint8_t*)FX_Realloc(uint8_t, m_pszData, m_iDataSize); -} -void CFX_SAXReader::ReallocNameBuffer() { - if (m_iDataPos < m_iNameSize) { - return; - } - if (m_iNameSize <= 1024 * 1024) { - m_iNameSize *= 2; - } else { - m_iNameSize += 1024 * 1024; - } - m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize); -} -inline FX_BOOL CFX_SAXReader::SkipSpace(uint8_t ch) { - return (m_dwParseMode & FX_SAXPARSEMODE_NotSkipSpace) == 0 && ch < 0x21; -} -int32_t CFX_SAXReader::StartParse(IFX_FileRead* pFile, - FX_DWORD dwStart, - FX_DWORD dwLen, - FX_DWORD dwParseMode) { - m_iState = -1; - Reset(); - if (!m_File.StartFile(pFile, dwStart, dwLen)) { - return -1; - } - m_iState = 0; - m_eMode = FX_SAXMODE_Text; - m_ePrevMode = FX_SAXMODE_Text; - m_bCharData = FALSE; - m_dwDataOffset = 0; - m_pRoot = m_pCurItem = new CFX_SAXItem; - m_pCurItem->m_dwID = ++m_dwItemID; - m_dwParseMode = dwParseMode; - return 0; -} -typedef void (CFX_SAXReader::*FX_SAXReader_LPFParse)(); -static const FX_SAXReader_LPFParse g_FX_SAXReader_LPFParse[FX_SAXMODE_MAX] = { - &CFX_SAXReader::ParseText, - &CFX_SAXReader::ParseNodeStart, - &CFX_SAXReader::ParseDeclOrComment, - &CFX_SAXReader::ParseDeclNode, - &CFX_SAXReader::ParseComment, - &CFX_SAXReader::ParseCommentContent, - &CFX_SAXReader::ParseTagName, - &CFX_SAXReader::ParseTagAttributeName, - &CFX_SAXReader::ParseTagAttributeEqual, - &CFX_SAXReader::ParseTagAttributeValue, - &CFX_SAXReader::ParseMaybeClose, - &CFX_SAXReader::ParseTagClose, - &CFX_SAXReader::ParseTagEnd, - &CFX_SAXReader::ParseTargetData, -}; -int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) { - if (m_iState < 0 || m_iState > 99) { - return m_iState; - } - while (m_File.m_dwCur < m_File.m_dwEnd) { - FX_DWORD& index = m_File.m_dwBufIndex; - FX_DWORD size = m_File.m_dwBufSize; - const uint8_t* pBuf = m_File.m_pBuf; - while (index < size) { - m_CurByte = pBuf[index]; - (this->*g_FX_SAXReader_LPFParse[m_eMode])(); - index++; - } - m_File.m_dwCur += index; - m_iState = (m_File.m_dwCur - m_File.m_dwStart) * 100 / - (m_File.m_dwEnd - m_File.m_dwStart); - if (m_File.m_dwCur >= m_File.m_dwEnd) { - break; - } - if (!m_File.ReadNextBlock()) { - m_iState = -2; - break; - } - m_dwDataOffset = 0; - if (pPause && pPause->NeedToPauseNow()) { - break; - } - } - return m_iState; -} -void CFX_SAXReader::ParseChar(uint8_t ch) { - ReallocDataBuffer(); - m_pszData[m_iDataPos] = ch; - if (m_iEntityStart > -1 && ch == ';') { - int32_t iSaveEntityStart = m_iEntityStart; - CFX_ByteString csEntity(m_pszData + m_iEntityStart + 1, - m_iDataPos - m_iEntityStart - 1); - int32_t iLen = csEntity.GetLength(); - if (iLen > 0) { - if (csEntity[0] == '#') { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_sharp) == 0) { - ch = 0; - uint8_t w; - if (iLen > 1 && csEntity[1] == 'x') { - for (int32_t i = 2; i < iLen; i++) { - w = csEntity[i]; - if (w >= '0' && w <= '9') { - ch = (ch << 4) + w - '0'; - } else if (w >= 'A' && w <= 'F') { - ch = (ch << 4) + w - 55; - } else if (w >= 'a' && w <= 'f') { - ch = (ch << 4) + w - 87; - } else { - break; - } - } - } else { - for (int32_t i = 1; i < iLen; i++) { - w = csEntity[i]; - if (w < '0' || w > '9') { - break; - } - ch = ch * 10 + w - '0'; - } - } - if (ch != 0) { - m_pszData[m_iEntityStart++] = ch; - } - } - } else { - if (csEntity.Compare("amp") == 0) { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_amp) == 0) { - m_pszData[m_iEntityStart++] = '&'; - } - } else if (csEntity.Compare("lt") == 0) { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_lt) == 0) { - m_pszData[m_iEntityStart++] = '<'; - } - } else if (csEntity.Compare("gt") == 0) { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_gt) == 0) { - m_pszData[m_iEntityStart++] = '>'; - } - } else if (csEntity.Compare("apos") == 0) { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_apos) == 0) { - m_pszData[m_iEntityStart++] = '\''; - } - } else if (csEntity.Compare("quot") == 0) { - if ((m_dwParseMode & FX_SAXPARSEMODE_NotConvert_quot) == 0) { - m_pszData[m_iEntityStart++] = '\"'; - } - } - } - } - if (iSaveEntityStart != m_iEntityStart) { - m_iDataPos = m_iEntityStart; - m_iEntityStart = -1; - } else { - m_iDataPos++; - m_iEntityStart = -1; - } - } else { - if (m_iEntityStart < 0 && ch == '&') { - m_iEntityStart = m_iDataPos; - } - m_iDataPos++; - } -} -void CFX_SAXReader::ParseText() { - if (m_CurByte == '<') { - if (m_iDataPos > 0) { - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyData(); - } - } - Push(); - m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; - m_eMode = FX_SAXMODE_NodeStart; - return; - } - if (m_iDataPos < 1 && SkipSpace(m_CurByte)) { - return; - } - ParseChar(m_CurByte); -} -void CFX_SAXReader::ParseNodeStart() { - if (m_CurByte == '?') { - m_pCurItem->m_eNode = FX_SAXNODE_Instruction; - m_eMode = FX_SAXMODE_TagName; - return; - } - if (m_CurByte == '!') { - m_eMode = FX_SAXMODE_DeclOrComment; - return; - } - if (m_CurByte == '/') { - m_eMode = FX_SAXMODE_TagEnd; - return; - } - if (m_CurByte == '>') { - Pop(); - m_eMode = FX_SAXMODE_Text; - return; - } - if (m_CurByte > 0x20) { - m_dwDataOffset = m_File.m_dwBufIndex; - m_pCurItem->m_eNode = FX_SAXNODE_Tag; - m_eMode = FX_SAXMODE_TagName; - AppendData(m_CurByte); - } -} -void CFX_SAXReader::ParseDeclOrComment() { - if (m_CurByte == '-') { - m_eMode = FX_SAXMODE_Comment; - m_pCurItem->m_eNode = FX_SAXNODE_Comment; - if (m_pCommentContext == NULL) { - m_pCommentContext = new CFX_SAXCommentContext; - } - m_pCommentContext->m_iHeaderCount = 1; - m_pCommentContext->m_iTailCount = 0; - } else { - m_eMode = FX_SAXMODE_DeclNode; - m_dwDataOffset = m_File.m_dwBufIndex; - m_SkipChar = '>'; - m_SkipStack.Add('>'); - SkipNode(); - } -} -void CFX_SAXReader::ParseComment() { - m_pCommentContext->m_iHeaderCount = 2; - m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; - m_eMode = FX_SAXMODE_CommentContent; -} -void CFX_SAXReader::ParseCommentContent() { - if (m_CurByte == '-') { - m_pCommentContext->m_iTailCount++; - } else if (m_CurByte == '>' && m_pCommentContext->m_iTailCount == 2) { - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyTargetData(); - } - Pop(); - m_eMode = FX_SAXMODE_Text; - } else { - while (m_pCommentContext->m_iTailCount > 0) { - AppendData('-'); - m_pCommentContext->m_iTailCount--; - } - AppendData(m_CurByte); - } -} -void CFX_SAXReader::ParseDeclNode() { - SkipNode(); -} -void CFX_SAXReader::ParseTagName() { - if (m_CurByte < 0x21 || m_CurByte == '/' || m_CurByte == '>' || - m_CurByte == '?') { - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyEnter(); - } - if (m_CurByte < 0x21) { - m_eMode = FX_SAXMODE_TagAttributeName; - } else if (m_CurByte == '/' || m_CurByte == '?') { - m_ePrevMode = m_eMode; - m_eMode = FX_SAXMODE_TagMaybeClose; - } else { - if (m_pHandler) { - NotifyBreak(); - } - m_eMode = FX_SAXMODE_Text; - } - } else { - AppendData(m_CurByte); - } -} -void CFX_SAXReader::ParseTagAttributeName() { - if (m_CurByte < 0x21 || m_CurByte == '=') { - if (m_iDataPos < 1 && m_CurByte < 0x21) { - return; - } - m_iNameLength = m_iDataPos; - m_iDataPos = 0; - m_SkipChar = 0; - m_eMode = m_CurByte == '=' ? FX_SAXMODE_TagAttributeValue - : FX_SAXMODE_TagAttributeEqual; - return; - } - if (m_CurByte == '/' || m_CurByte == '>' || m_CurByte == '?') { - if (m_CurByte == '/' || m_CurByte == '?') { - m_ePrevMode = m_eMode; - m_eMode = FX_SAXMODE_TagMaybeClose; - } else { - if (m_pHandler) { - NotifyBreak(); - } - m_eMode = FX_SAXMODE_Text; - } - return; - } - if (m_iDataPos < 1) { - m_dwDataOffset = m_File.m_dwBufIndex; - } - AppendName(m_CurByte); -} -void CFX_SAXReader::ParseTagAttributeEqual() { - if (m_CurByte == '=') { - m_SkipChar = 0; - m_eMode = FX_SAXMODE_TagAttributeValue; - return; - } else if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) { - m_iDataPos = m_iNameLength; - AppendName(0x20); - m_eMode = FX_SAXMODE_TargetData; - ParseTargetData(); - } -} -void CFX_SAXReader::ParseTagAttributeValue() { - if (m_SkipChar) { - if (m_SkipChar == m_CurByte) { - { - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyAttribute(); - } - } - m_SkipChar = 0; - m_eMode = FX_SAXMODE_TagAttributeName; - return; - } - ParseChar(m_CurByte); - return; - } - if (m_CurByte < 0x21) { - return; - } - if (m_iDataPos < 1) { - if (m_CurByte == '\'' || m_CurByte == '\"') { - m_SkipChar = m_CurByte; - } - } -} -void CFX_SAXReader::ParseMaybeClose() { - if (m_CurByte == '>') { - if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) { - m_iNameLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyTargetData(); - } - } - ParseTagClose(); - m_eMode = FX_SAXMODE_Text; - } else if (m_ePrevMode == FX_SAXMODE_TagName) { - AppendData('/'); - m_eMode = FX_SAXMODE_TagName; - m_ePrevMode = FX_SAXMODE_Text; - ParseTagName(); - } else if (m_ePrevMode == FX_SAXMODE_TagAttributeName) { - AppendName('/'); - m_eMode = FX_SAXMODE_TagAttributeName; - m_ePrevMode = FX_SAXMODE_Text; - ParseTagAttributeName(); - } else if (m_ePrevMode == FX_SAXMODE_TargetData) { - AppendName('?'); - m_eMode = FX_SAXMODE_TargetData; - m_ePrevMode = FX_SAXMODE_Text; - ParseTargetData(); - } -} -void CFX_SAXReader::ParseTagClose() { - m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; - if (m_pHandler) { - NotifyClose(); - } - Pop(); -} -void CFX_SAXReader::ParseTagEnd() { - if (m_CurByte < 0x21) { - return; - } - if (m_CurByte == '>') { - Pop(); - m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_pHandler) { - NotifyEnd(); - } - Pop(); - m_eMode = FX_SAXMODE_Text; - } else { - ParseChar(m_CurByte); - } -} -void CFX_SAXReader::ParseTargetData() { - if (m_CurByte == '?') { - m_ePrevMode = m_eMode; - m_eMode = FX_SAXMODE_TagMaybeClose; - } else { - AppendName(m_CurByte); - } -} -void CFX_SAXReader::SkipNode() { - int32_t iLen = m_SkipStack.GetSize(); - if (m_SkipChar == '\'' || m_SkipChar == '\"') { - if (m_CurByte != m_SkipChar) { - return; - } - iLen--; - FXSYS_assert(iLen > -1); - m_SkipStack.RemoveAt(iLen, 1); - m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; - return; - } - switch (m_CurByte) { - case '<': - m_SkipChar = '>'; - m_SkipStack.Add('>'); - break; - case '[': - m_SkipChar = ']'; - m_SkipStack.Add(']'); - break; - case '(': - m_SkipChar = ')'; - m_SkipStack.Add(')'); - break; - case '\'': - m_SkipChar = '\''; - m_SkipStack.Add('\''); - break; - case '\"': - m_SkipChar = '\"'; - m_SkipStack.Add('\"'); - break; - default: - if (m_CurByte == m_SkipChar) { - iLen--; - m_SkipStack.RemoveAt(iLen, 1); - m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0; - if (iLen == 0 && m_CurByte == '>') { - m_iDataLength = m_iDataPos; - m_iDataPos = 0; - if (m_iDataLength >= 9 && - FXSYS_memcmp(m_pszData, "[CDATA[", 7 * sizeof(uint8_t)) == 0 && - FXSYS_memcmp(m_pszData + m_iDataLength - 2, "]]", - 2 * sizeof(uint8_t)) == 0) { - Pop(); - m_iDataLength -= 9; - m_dwDataOffset += 7; - FXSYS_memmove(m_pszData, m_pszData + 7, - m_iDataLength * sizeof(uint8_t)); - m_bCharData = TRUE; - if (m_pHandler) { - NotifyData(); - } - m_bCharData = FALSE; - } else { - Pop(); - } - m_eMode = FX_SAXMODE_Text; - } - } - break; - } - if (iLen > 0) { - 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 = - m_pHandler->OnTagEnter(CFX_ByteStringC(m_pszData, m_iDataLength), - 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, - CFX_ByteStringC(m_pszName, m_iNameLength), - CFX_ByteStringC(m_pszData, m_iDataLength)); - } -} -void CFX_SAXReader::NotifyBreak() { - FXSYS_assert(m_pHandler != NULL); - 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); - } -} -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), - m_dwNodePos); - } else if (m_pCurItem->m_eNode == FX_SAXNODE_Comment) { - m_pHandler->OnTargetData(m_pCurItem->m_pNode, m_pCurItem->m_eNode, - CFX_ByteStringC(m_pszData, m_iDataLength), - m_dwNodePos); - } -} -void CFX_SAXReader::SkipCurrentNode() { - if (!m_pCurItem) { - return; - } - m_pCurItem->m_bSkip = TRUE; -} -void CFX_SAXReader::SetHandler(IFX_SAXReaderHandler* pHandler) { - m_pHandler = pHandler; -} diff --git a/xfa/src/fgas/xml/fgas_sax_imp.h b/xfa/src/fgas/xml/fgas_sax_imp.h deleted file mode 100644 index a65f2abaa9..0000000000 --- a/xfa/src/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_SRC_FGAS_XML_FGAS_SAX_IMP_H_ -#define XFA_SRC_FGAS_XML_FGAS_SAX_IMP_H_ - -#include "xfa/src/fgas/xml/fgas_sax.h" - -class CFX_SAXFile { - public: - CFX_SAXFile(); - FX_BOOL StartFile(IFX_FileRead* pFile, FX_DWORD dwStart, FX_DWORD dwLen); - FX_BOOL ReadNextBlock(); - void Reset(); - IFX_FileRead* m_pFile; - FX_DWORD m_dwStart; - FX_DWORD m_dwEnd; - FX_DWORD m_dwCur; - uint8_t* m_pBuf; - FX_DWORD m_dwBufSize; - FX_DWORD 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; - FX_DWORD 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, - FX_DWORD dwStart = 0, - FX_DWORD dwLen = -1, - FX_DWORD 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; - FX_DWORD m_dwItemID; - FX_SAXMODE m_eMode; - FX_SAXMODE m_ePrevMode; - FX_BOOL m_bCharData; - uint8_t m_CurByte; - FX_DWORD m_dwDataOffset; - CFX_ByteArray m_SkipStack; - uint8_t m_SkipChar; - FX_DWORD 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; - FX_DWORD 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_SRC_FGAS_XML_FGAS_SAX_IMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/src/fwl/basewidget/fwl_barcodeimp.cpp deleted file mode 100644 index af604f15a6..0000000000 --- a/xfa/src/fwl/basewidget/fwl_barcodeimp.cpp +++ /dev/null @@ -1,221 +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/src/fwl/basewidget/fwl_barcodeimp.h" - -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fwl/basewidget/fwl_editimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -// static -IFWL_Barcode* IFWL_Barcode::Create(const CFWL_WidgetImpProperties& properties) { - IFWL_Barcode* pBarcode = new IFWL_Barcode; - CFWL_BarcodeImp* pBarcodeImpl = new CFWL_BarcodeImp(properties, nullptr); - pBarcode->SetImpl(pBarcodeImpl); - pBarcodeImpl->SetInterface(pBarcode); - return pBarcode; -} -IFWL_Barcode::IFWL_Barcode() {} -void IFWL_Barcode::SetType(BC_TYPE type) { - static_cast<CFWL_BarcodeImp*>(GetImpl())->SetType(type); -} -FX_BOOL IFWL_Barcode::IsProtectedType() { - return static_cast<CFWL_BarcodeImp*>(GetImpl())->IsProtectedType(); -} - -CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_EditImp(properties, pOuter), - m_pBarcodeEngine(NULL), - m_dwStatus(0), - m_type(BC_UNKNOWN) {} -CFWL_BarcodeImp::~CFWL_BarcodeImp() { - ReleaseBarcodeEngine(); -} -FWL_ERR CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_Barcode; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_BarcodeImp::GetClassID() const { - return FWL_CLASSHASH_Barcode; -} -FWL_ERR 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; -} -FWL_ERR CFWL_BarcodeImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - ReleaseBarcodeEngine(); - return CFWL_EditImp::Finalize(); -} -FWL_ERR CFWL_BarcodeImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - FWL_ERR ret = CFWL_EditImp::Update(); - GenerateBarcodeImageCache(); - return ret; -} -FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - GenerateBarcodeImageCache(); - if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) { - return FWL_ERR_Succeeded; - } - CFX_Matrix mt; - mt.e = m_rtClient.left; - mt.f = m_rtClient.top; - if (pMatrix) { - mt.Concat(*pMatrix); - } - int32_t errorCode = 0; - if (!m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix, - errorCode)) { - return FWL_ERR_Indefinite; - } - return FWL_ERR_Succeeded; - } - return CFWL_EditImp::DrawWidget(pGraphics, pMatrix); -} -void CFWL_BarcodeImp::GenerateBarcodeImageCache() { - if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) - return; - m_dwStatus = 0; - CreateBarcodeEngine(); - IFWL_BarcodeDP* pData = - static_cast<IFWL_BarcodeDP*>(m_pProperties->m_pDataProvider); - if (!pData) - return; - if (!m_pBarcodeEngine) - return; - CFX_WideString wsText; - if (GetText(wsText) != FWL_ERR_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)); - 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)); - if (pFontSize) { - m_pBarcodeEngine->SetFontSize(*pFontSize); - } - FX_ARGB* pFontColor = static_cast<FX_ARGB*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_TextColor)); - if (pFontColor) { - m_pBarcodeEngine->SetFontColor(*pFontColor); - } - m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height)); - m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width)); - FX_DWORD dwAttributeMask = pData->GetBarcodeAttributeMask(); - if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) { - m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) { - m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) { - m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) { - m_pBarcodeEngine->SetDataLength(pData->GetDataLength()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) { - m_pBarcodeEngine->SetCalChecksum(pData->GetCalChecksum()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) { - m_pBarcodeEngine->SetPrintChecksum(pData->GetPrintChecksum()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) { - m_pBarcodeEngine->SetTextLocation(pData->GetTextLocation()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) { - m_pBarcodeEngine->SetWideNarrowRatio(pData->GetWideNarrowRatio()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) { - m_pBarcodeEngine->SetStartChar(pData->GetStartChar()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) { - m_pBarcodeEngine->SetEndChar(pData->GetEndChar()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) { - m_pBarcodeEngine->SetVersion(pData->GetVersion()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) { - m_pBarcodeEngine->SetErrorCorrectionLevel(pData->GetErrorCorrectionLevel()); - } - if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) { - m_pBarcodeEngine->SetTruncated(pData->GetTruncated()); - } - int32_t errorCode = 0; - m_dwStatus = m_pBarcodeEngine->Encode(wsText, 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); - } -} -void CFWL_BarcodeImp::ReleaseBarcodeEngine() { - if (m_pBarcodeEngine) { - m_pBarcodeEngine->Release(); - m_pBarcodeEngine = NULL; - } -} -void CFWL_BarcodeImp::SetType(BC_TYPE type) { - if (m_type == type) { - return; - } - ReleaseBarcodeEngine(); - m_type = type; - m_dwStatus = XFA_BCS_NeedUpdate; -} -FWL_ERR CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) { - ReleaseBarcodeEngine(); - m_dwStatus = XFA_BCS_NeedUpdate; - return CFWL_EditImp::SetText(wsText); -} -FX_BOOL CFWL_BarcodeImp::IsProtectedType() { - if (!m_pBarcodeEngine) { - return TRUE; - } - BC_TYPE tEngineType = m_pBarcodeEngine->GetType(); - if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 || - tEngineType == BC_DATAMATRIX) { - return TRUE; - } - return FALSE; -} -CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner) - : CFWL_EditImpDelegate(pOwner) {} -FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - FX_DWORD dwFlag = pEvent->GetClassID(); - if (dwFlag == FWL_EVTHASH_EDT_TextChanged) { - CFWL_BarcodeImp* pOwner = static_cast<CFWL_BarcodeImp*>(m_pOwner); - pOwner->ReleaseBarcodeEngine(); - pOwner->m_dwStatus = XFA_BCS_NeedUpdate; - } - return CFWL_EditImpDelegate::OnProcessEvent(pEvent); -} diff --git a/xfa/src/fwl/basewidget/fwl_barcodeimp.h b/xfa/src/fwl/basewidget/fwl_barcodeimp.h deleted file mode 100644 index eedcb16024..0000000000 --- a/xfa/src/fwl/basewidget/fwl_barcodeimp.h +++ /dev/null @@ -1,54 +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_SRC_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ - -#include "xfa/include/fwl/basewidget/fwl_barcode.h" -#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" -#include "xfa/include/fwl/basewidget/fxmath_barcode.h" -#include "xfa/src/fwl/basewidget/fwl_editimp.h" - -class CFWL_WidgetImpProperties; -class CFWL_BarcodeImpDelegate; -class IFWL_Widget; - -#define XFA_BCS_NeedUpdate 0x0001 -#define XFA_BCS_EncodeSuccess 0x0002 - -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 FX_DWORD 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); - FX_BOOL IsProtectedType(); - - protected: - void GenerateBarcodeImageCache(); - void CreateBarcodeEngine(); - void ReleaseBarcodeEngine(); - IFX_Barcode* m_pBarcodeEngine; - FX_DWORD 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; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_BARCODEIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_caretimp.cpp b/xfa/src/fwl/basewidget/fwl_caretimp.cpp deleted file mode 100644 index 752f889dcf..0000000000 --- a/xfa/src/fwl/basewidget/fwl_caretimp.cpp +++ /dev/null @@ -1,157 +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/src/fwl/basewidget/fwl_caretimp.h" - -#include "xfa/include/fwl/basewidget/fwl_caret.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -// static -IFWL_Caret* IFWL_Caret::Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_Caret* pCaret = new IFWL_Caret; - CFWL_CaretImp* pCaretImpl = new CFWL_CaretImp(properties, pOuter); - pCaret->SetImpl(pCaretImpl); - pCaretImpl->SetInterface(pCaret); - return pCaret; -} -IFWL_Caret::IFWL_Caret() {} -FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) { - return static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag); -} -FWL_ERR IFWL_Caret::GetFrequency(FX_DWORD& elapse) { - return static_cast<CFWL_CaretImp*>(GetImpl())->GetFrequency(elapse); -} -FWL_ERR IFWL_Caret::SetFrequency(FX_DWORD elapse) { - return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); -} -FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) { - return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); -} - -CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_hTimer(nullptr), - m_dwElapse(400), - m_bSetColor(FALSE) { - m_pTimer = new CFWL_CaretTimer(this); - SetStates(FWL_STATE_CAT_HightLight); -} -CFWL_CaretImp::~CFWL_CaretImp() { - if (m_pTimer) { - delete m_pTimer; - m_pTimer = NULL; - } -} -FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_Caret; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_CaretImp::GetClassID() const { - return FWL_CLASSHASH_Caret; -} -FWL_ERR CFWL_CaretImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_CaretImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CaretImp::Finalize() { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - m_hTimer = NULL; - } - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - m_hTimer = NULL; - } - if (bFlag) { - m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); - } - return SetStates(FWL_WGTSTATE_Invisible, !bFlag); -} -FWL_ERR CFWL_CaretImp::GetFrequency(FX_DWORD& elapse) { - elapse = m_dwElapse; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CaretImp::SetFrequency(FX_DWORD elapse) { - m_dwElapse = elapse; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) { - m_bSetColor = TRUE; - m_crFill = crFill; - return FWL_ERR_Succeeded; -} -FX_BOOL 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); - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_pGraphics = pGraphics; - param.m_rtPart = rect; - 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) { - param.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶m); - return FWL_ERR_Succeeded; -} - -CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret) - : m_pCaret(pCaret) {} - -int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) { - if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) { - m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE); - } else { - m_pCaret->SetStates(FWL_STATE_CAT_HightLight); - } - CFX_RectF rt; - m_pCaret->GetWidgetRect(rt); - rt.Set(0, 0, rt.width + 1, rt.height); - 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); -} diff --git a/xfa/src/fwl/basewidget/fwl_caretimp.h b/xfa/src/fwl/basewidget/fwl_caretimp.h deleted file mode 100644 index e3dde63ab6..0000000000 --- a/xfa/src/fwl/basewidget/fwl_caretimp.h +++ /dev/null @@ -1,67 +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_SRC_FWL_BASEWIDGET_FWL_CARETIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_CARETIMP_H_ - -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_CaretImpDelegate; - -class CFWL_CaretImp : public CFWL_WidgetImp { - public: - CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - virtual ~CFWL_CaretImp(); - - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; - virtual FX_DWORD GetClassID() const; - - 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(FX_DWORD& elapse); - virtual FWL_ERR SetFrequency(FX_DWORD elapse); - virtual FWL_ERR SetColor(CFX_Color crFill); - - protected: - FX_BOOL DrawCaretBK(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - class CFWL_CaretTimer : public IFWL_Timer { - public: - explicit CFWL_CaretTimer(CFWL_CaretImp* pCaret); - ~CFWL_CaretTimer() override {} - int32_t Run(FWL_HTIMER hTimer) override; - CFWL_CaretImp* const m_pCaret; - }; - CFWL_CaretTimer* m_pTimer; - FWL_HTIMER m_hTimer; - FX_DWORD 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; - - protected: - CFWL_CaretImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_CARETIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_checkboximp.cpp b/xfa/src/fwl/basewidget/fwl_checkboximp.cpp deleted file mode 100644 index 16cc8f7080..0000000000 --- a/xfa/src/fwl/basewidget/fwl_checkboximp.cpp +++ /dev/null @@ -1,555 +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/src/fwl/basewidget/fwl_checkboximp.h" - -#include <algorithm> - -#include "xfa/include/fwl/basewidget/fwl_checkbox.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -#define FWL_CKB_CaptionMargin 5 - -// static -IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_CheckBox* pCheckBox = new IFWL_CheckBox; - CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter); - pCheckBox->SetImpl(pCheckBoxImpl); - pCheckBoxImpl->SetInterface(pCheckBox); - return pCheckBox; -} -IFWL_CheckBox::IFWL_CheckBox() {} -int32_t IFWL_CheckBox::GetCheckState() { - return static_cast<CFWL_CheckBoxImp*>(GetImpl())->GetCheckState(); -} -FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck) { - return static_cast<CFWL_CheckBoxImp*>(GetImpl())->SetCheckState(iCheck); -} - -CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), - m_iTTOAlign(FDE_TTOALIGNMENT_Center), - m_bBtnDown(FALSE) { - m_rtClient.Reset(); - m_rtBox.Reset(); - m_rtCaption.Reset(); - m_rtFocus.Reset(); -} -CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {} -FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_CheckBox; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_CheckBoxImp::GetClassID() const { - return FWL_CLASSHASH_CheckBox; -} -FWL_ERR CFWL_CheckBoxImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_CheckBoxImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CheckBoxImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR 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; - if (!m_pProperties->m_pDataProvider) - return FWL_ERR_Indefinite; - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); - if (wsCaption.GetLength() > 0) { - CFX_SizeF sz = CalcTextSize( - wsCaption, m_pProperties->m_pThemeProvider, - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); - rect.Set(0, 0, sz.x, sz.y); - } - rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin); - IFWL_CheckBoxDP* pData = - static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); - FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); - rect.width += fCheckBox; - if (rect.height < fCheckBox) { - rect.height = fCheckBox; - } - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CheckBoxImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - UpdateTextOutStyles(); - Layout(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider, - pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix); - } - int32_t dwStates = GetPartStates(); - { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_CKB_Background; - param.m_dwStates = dwStates; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - param.m_pData = &m_rtFocus; - } - pTheme->DrawBackground(¶m); - param.m_iPart = FWL_PART_CKB_CheckBox; - param.m_rtPart = m_rtBox; - pTheme->DrawBackground(¶m); - } - if (!m_pProperties->m_pDataProvider) - return FWL_ERR_Indefinite; - { - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); - int32_t iLen = wsCaption.GetLength(); - if (iLen <= 0) - return FWL_ERR_Indefinite; - CFWL_ThemeText textParam; - textParam.m_pWidget = m_pInterface; - textParam.m_iPart = FWL_PART_CKB_Caption; - textParam.m_dwStates = dwStates; - textParam.m_pGraphics = pGraphics; - if (pMatrix) { - textParam.m_matrix.Concat(*pMatrix); - } - textParam.m_rtPart = m_rtCaption; - textParam.m_wsText = wsCaption; - textParam.m_dwTTOStyles = m_dwTTOStyles; - textParam.m_iTTOAlign = m_iTTOAlign; - pTheme->DrawText(&textParam); - } - return FWL_ERR_Succeeded; -} -int32_t CFWL_CheckBoxImp::GetCheckState() { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) && - ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Neutral)) { - return 2; - } - if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Checked) { - return 1; - } - return 0; -} -FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) { - m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; - switch (iCheck) { - case 0: { - break; - } - case 1: { - m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; - break; - } - case 2: { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { - m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; - } - break; - } - default: {} - } - Repaint(&m_rtClient); - return FWL_ERR_Succeeded; -} -void CFWL_CheckBoxImp::Layout() { - int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f); - int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f); - m_pProperties->m_rtWidget.width = (FX_FLOAT)width; - m_pProperties->m_rtWidget.height = (FX_FLOAT)height; - GetClientRect(m_rtClient); - FX_FLOAT fBoxTop = m_rtClient.top; - FX_FLOAT fBoxLeft = m_rtClient.left; - FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0; - FX_FLOAT fClientRight = m_rtClient.right(); - FX_FLOAT fClientBottom = m_rtClient.bottom(); - if (!m_pProperties->m_pDataProvider) - return; - IFWL_CheckBoxDP* pData = - static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); - FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { - case FWL_STYLEEXT_CKB_Top: { - fBoxTop = m_rtClient.top; - break; - } - case FWL_STYLEEXT_CKB_Bottom: { - fBoxTop = fClientBottom - fCheckBox; - break; - } - case FWL_STYLEEXT_CKB_VCenter: - default: { - fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2; - fBoxTop = FXSYS_floor(fBoxTop); - } - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_LeftText) { - fBoxLeft = fClientRight - fCheckBox; - fTextLeft = m_rtClient.left; - fTextRight = fBoxLeft; - } else { - fTextLeft = fBoxLeft + fCheckBox; - fTextRight = fClientRight; - } - 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); - CFX_RectF rtFocus; - rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, - m_rtCaption.height); - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); - if (wsCaption.IsEmpty()) { - m_rtFocus.Set(0, 0, 0, 0); - } else { - CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, - m_iTTOAlign, rtFocus); - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) { - FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); - FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height); - FX_FLOAT fLeft = m_rtCaption.left; - FX_FLOAT fTop = m_rtCaption.top; - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) == - FWL_STYLEEXT_CKB_Center) { - fLeft = m_rtCaption.left + (m_rtCaption.width - fWidth) / 2; - } else if ((m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_CKB_HLayoutMask) == FWL_STYLEEXT_CKB_Right) { - fLeft = m_rtCaption.right() - fWidth; - } - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) == - FWL_STYLEEXT_CKB_VCenter) { - fTop = m_rtCaption.top + (m_rtCaption.height - fHeight) / 2; - } else if ((m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) { - fTop = m_rtCaption.bottom() - fHeight; - } - m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); - } else { - m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height); - } - m_rtFocus.Inflate(1, 1); - } -} -FX_DWORD CFWL_CheckBoxImp::GetPartStates() { - int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked; - if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Neutral) { - dwStates = FWL_PARTSTATE_CKB_Neutral; - } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Checked) { - dwStates = FWL_PARTSTATE_CKB_Checked; - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - dwStates |= FWL_PARTSTATE_CKB_Disabled; - } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) { - dwStates |= FWL_PARTSTATE_CKB_Hovered; - } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) { - dwStates |= FWL_PARTSTATE_CKB_Pressed; - } else { - dwStates |= FWL_PARTSTATE_CKB_Normal; - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - dwStates |= FWL_PARTSTATE_CKB_Focused; - } - return dwStates; -} -void CFWL_CheckBoxImp::UpdateTextOutStyles() { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - switch (m_pProperties->m_dwStyleExes & - (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) { - case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - break; - } - case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; - break; - } - case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopRight; - break; - } - case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; - break; - } - case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - break; - } - case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; - break; - } - case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft; - break; - } - case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter; - break; - } - case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; - break; - } - default: {} - } - m_dwTTOStyles = 0; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { - m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) { - m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap; - } else { - m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; - } -} -void CFWL_CheckBoxImp::NextStates() { - FX_DWORD dwFirststate = m_pProperties->m_dwStates; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { - if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Unchecked) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr->IsFormDisabled()) { - CFX_PtrArray radioarr; - pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); - IFWL_CheckBox* pCheckBox = NULL; - int32_t iCount = radioarr.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); - if (pCheckBox != m_pInterface && - pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { - pCheckBox->SetCheckState(0); - CFX_RectF rt; - pCheckBox->GetWidgetRect(rt); - rt.left = rt.top = 0; - m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); - break; - } - } - } - m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; - } - } else { - if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Neutral) { - m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { - m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; - } - } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == - FWL_STATE_CKB_Checked) { - m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; - } else { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { - m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; - } else { - m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; - } - } - } - Repaint(&m_rtClient); - FX_DWORD dwLaststate = m_pProperties->m_dwStates; - if (dwFirststate != dwLaststate) { - CFWL_EvtCkbCheckStateChanged wmCheckBoxState; - wmCheckBoxState.m_pSrcTarget = m_pInterface; - DispatchEvent(&wmCheckBoxState); - } -} -CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { - OnActivate(pMessage); - break; - } - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD 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; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { - OnKeyDown(pKey); - } - break; - } - default: { iRet = 0; } - } - 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::OnActivate(CFWL_Message* pMsg) { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; - m_pOwner->Repaint(&(m_pOwner->m_rtClient)); -} -void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - } - m_pOwner->Repaint(&(m_pOwner->m_rtClient)); -} -void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - return; - } - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->SetFocus(TRUE); - } - m_pOwner->m_bBtnDown = TRUE; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; - m_pOwner->Repaint(&(m_pOwner->m_rtClient)); -} -void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - if (!m_pOwner->m_bBtnDown) { - return; - } - m_pOwner->m_bBtnDown = FALSE; - if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - return; - } - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed; - m_pOwner->NextStates(); -} -void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - return; - } - FX_BOOL bRepaint = FALSE; - if (m_pOwner->m_bBtnDown) { - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) { - bRepaint = TRUE; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; - } - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) { - bRepaint = TRUE; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; - } - } else { - if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) { - bRepaint = TRUE; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed; - } - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { - bRepaint = TRUE; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; - } - } - } else { - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { - bRepaint = TRUE; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; - } - } - } - if (bRepaint) { - m_pOwner->Repaint(&(m_pOwner->m_rtBox)); - } -} -void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_bBtnDown) { - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; - } - m_pOwner->Repaint(&(m_pOwner->m_rtBox)); -} -void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { - if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { - m_pOwner->DispatchKeyEvent(pMsg); - return; - } - if (pMsg->m_dwKeyCode == FWL_VKEY_Return || - pMsg->m_dwKeyCode == FWL_VKEY_Space) { - m_pOwner->NextStates(); - } -} diff --git a/xfa/src/fwl/basewidget/fwl_checkboximp.h b/xfa/src/fwl/basewidget/fwl_checkboximp.h deleted file mode 100644 index 98702aaa59..0000000000 --- a/xfa/src/fwl/basewidget/fwl_checkboximp.h +++ /dev/null @@ -1,64 +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_SRC_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_ - -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_CheckBoxImpDelegate; - -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 FX_DWORD 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); - - protected: - void Layout(); - FX_DWORD GetPartStates(); - void UpdateTextOutStyles(); - void NextStates(); - CFX_RectF m_rtClient; - CFX_RectF m_rtBox; - CFX_RectF m_rtCaption; - CFX_RectF m_rtFocus; - FX_DWORD 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; - - protected: - void OnActivate(CFWL_Message* pMsg); - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - CFWL_CheckBoxImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_comboboximp.cpp b/xfa/src/fwl/basewidget/fwl_comboboximp.cpp deleted file mode 100644 index 5eef96eebf..0000000000 --- a/xfa/src/fwl/basewidget/fwl_comboboximp.cpp +++ /dev/null @@ -1,1819 +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/src/fwl/basewidget/fwl_comboboximp.h" - -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/basewidget/fwl_editimp.h" -#include "xfa/src/fwl/basewidget/fwl_formproxyimp.h" -#include "xfa/src/fwl/basewidget/fwl_listboximp.h" -#include "xfa/src/fwl/basewidget/fwl_scrollbarimp.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -// static -IFWL_ComboBox* IFWL_ComboBox::Create( - const CFWL_WidgetImpProperties& properties) { - IFWL_ComboBox* pComboBox = new IFWL_ComboBox; - CFWL_ComboBoxImp* pComboBoxImpl = new CFWL_ComboBoxImp(properties, nullptr); - pComboBox->SetImpl(pComboBoxImpl); - pComboBoxImpl->SetInterface(pComboBox); - return pComboBox; -} -IFWL_ComboBox::IFWL_ComboBox() {} -int32_t IFWL_ComboBox::GetCurSel() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetCurSel(); -} -FWL_ERR IFWL_ComboBox::SetCurSel(int32_t iSel) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetCurSel(iSel); -} -FWL_ERR 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 { - return static_cast<CFWL_ComboBoxImp*>(GetImpl()) - ->GetEditText(wsText, nStart, nCount); -} -FWL_ERR IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl()) - ->SetEditSelRange(nStart, nCount); -} -int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl()) - ->GetEditSelRange(nIndex, nStart); -} -int32_t IFWL_ComboBox::GetEditLimit() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditLimit(); -} -FWL_ERR IFWL_ComboBox::SetEditLimit(int32_t nLimit) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditLimit(nLimit); -} -FWL_ERR IFWL_ComboBox::EditDoClipboard(int32_t iCmd) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDoClipboard(iCmd); -} -FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(bsRecord); -} -FX_BOOL IFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(bsRecord); -} -IFWL_ListBox* IFWL_ComboBox::GetListBoxt() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetListBoxt(); -} -FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->AfterFocusShowDropList(); -} -FX_ERR IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->OpenDropDownList(bActivate); -} -FX_BOOL IFWL_ComboBox::EditCanUndo() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanUndo(); -} -FX_BOOL IFWL_ComboBox::EditCanRedo() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanRedo(); -} -FX_BOOL IFWL_ComboBox::EditUndo() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(); -} -FX_BOOL IFWL_ComboBox::EditRedo() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(); -} -FX_BOOL IFWL_ComboBox::EditCanCopy() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCopy(); -} -FX_BOOL IFWL_ComboBox::EditCanCut() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCut(); -} -FX_BOOL IFWL_ComboBox::EditCanSelectAll() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanSelectAll(); -} -FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCopy(wsCopy); -} -FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCut(wsCut); -} -FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditPaste(wsPaste); -} -FX_BOOL IFWL_ComboBox::EditSelectAll() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditSelectAll(); -} -FX_BOOL IFWL_ComboBox::EditDelete() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDelete(); -} -FX_BOOL IFWL_ComboBox::EditDeSelect() { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDeSelect(); -} -FWL_ERR IFWL_ComboBox::GetBBox(CFX_RectF& rect) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetBBox(rect); -} -FWL_ERR IFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - return static_cast<CFWL_ComboBoxImp*>(GetImpl()) - ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} - -CFWL_ComboEditImp::CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_EditImp(properties, pOuter) { - m_pOuter = static_cast<CFWL_ComboBoxImp*>(pOuter->GetImpl()); -} - -CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner) - : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} -int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - 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; - } - backDefault = FALSE; - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) && - ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { - m_pOwner->SetSelected(); - m_pOwner->SetComboBoxFocus(TRUE); - } - break; - } - default: {} - } - if (!backDefault) { - return 1; - } - return CFWL_EditImpDelegate::OnProcessMessage(pMessage); -} -void CFWL_ComboEditImp::ClearSelected() { - ClearSelections(); - Repaint(&m_rtClient); -} -void CFWL_ComboEditImp::SetSelected() { - FlagFocus(TRUE); - EndCaret(); - AddSelRange(0); -} -void CFWL_ComboEditImp::EndCaret() { - m_pEdtEngine->MoveCaretPos(MC_End); -} -void CFWL_ComboEditImp::FlagFocus(FX_BOOL bSet) { - if (bSet) { - m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } else { - m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - ShowCaret(FALSE); - } -} -void CFWL_ComboEditImp::SetComboBoxFocus(FX_BOOL bSet) { - m_pOuter->SetFocus(bSet); -} -CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) { - FXSYS_assert(pOuter != NULL); -} -FWL_ERR CFWL_ComboListImp::Initialize() { - if (CFWL_ListBoxImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - delete m_pDelegate; - m_pDelegate = new CFWL_ComboListImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboListImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_ListBoxImp::Finalize(); -} -int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) { - if (wsMatch.IsEmpty()) { - return -1; - } - if (!m_pProperties->m_pDataProvider) - return -1; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); - FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); - if (!pos) { - return i; - } - } - return -1; -} -void CFWL_ComboListImp::ChangeSelected(int32_t iSel) { - if (!m_pProperties->m_pDataProvider) - return; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); - CFX_RectF rtInvalidate; - rtInvalidate.Reset(); - FWL_HLISTITEM hOld = GetSelItem(0); - int32_t iOld = pData->GetItemIndex(m_pInterface, hOld); - if (iOld == iSel) { - return; - } else if (iOld > -1) { - GetItemRect(iOld, rtInvalidate); - SetSelItem(hOld, FALSE); - } - if (hItem) { - CFX_RectF rect; - GetItemRect(iSel, rect); - rtInvalidate.Union(rect); - FWL_HLISTITEM hSel = pData->GetItem(m_pInterface, iSel); - SetSelItem(hSel, TRUE); - } - if (!rtInvalidate.IsEmpty()) { - Repaint(&rtInvalidate); - } -} -int32_t CFWL_ComboListImp::CountItems() { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - return pData ? pData->CountItems(m_pInterface) : 0; -} -void CFWL_ComboListImp::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, nIndex); - pData->GetItemRect(m_pInterface, hItem, rtItem); -} -void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { - fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top; - IFWL_Widget* pOwner = GetOwner(); - if (!pOwner) - return; - pOwner->TransformTo(m_pOuter, fx, 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) { - if (!pMessage) - return 0; - FX_DWORD 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) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { - CFX_RectF rect; - m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { - pMsg->m_fx -= rect.left; - pMsg->m_fy -= rect.top; - IFWL_WidgetDelegate* pDelegate = - m_pOwner->m_pVertScrollBar->SetDelegate(NULL); - return pDelegate->OnProcessMessage(pMsg); - } - } - FX_DWORD dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_MouseMove: { - backDefault = FALSE; - OnDropListMouseMove(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonDown: { - backDefault = FALSE; - OnDropListLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - backDefault = FALSE; - OnDropListLButtonUp(pMsg); - break; - } - default: {} - } - } else if (dwHashCode == FWL_MSGHASH_Key) { - backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage)); - } - if (!backDefault) { - return 1; - } - return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage); -} -void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (!bSet) { - CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); - CFWL_ComboBoxImp* pOuter = - static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); - if (pKill->m_pSetFocus == m_pOwner->m_pOuter || - pKill->m_pSetFocus == pOuter->m_pEdit.get()) { - pOuter->ShowDropList(FALSE); - } - } -} -int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (m_pOwner->m_bNotifyOwner) { - m_pOwner->m_bNotifyOwner = FALSE; - } - if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { - CFX_RectF rect; - m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { - return 1; - } - } - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (hItem) { - if (!m_pOwner->m_pProperties->m_pDataProvider) - return 0; - IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( - m_pOwner->m_pProperties->m_pDataProvider); - int32_t iSel = pData->GetItemIndex(m_pOwner->m_pInterface, hItem); - CFWL_EvtCmbHoverChanged event; - event.m_pSrcTarget = m_pOwner->m_pOuter; - event.m_iCurHover = iSel; - m_pOwner->DispatchEvent(&event); - m_pOwner->ChangeSelected(iSel); - } - } else if (m_pOwner->m_bNotifyOwner) { - m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); - CFWL_ComboBoxImp* pOuter = - static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); - pOuter->m_pDelegate->OnProcessMessage(pMsg); - } - return 1; -} -int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - return 0; - } - CFWL_ComboBoxImp* pOuter = - static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); - pOuter->ShowDropList(FALSE); - return 1; -} -int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { - CFWL_ComboBoxImp* pOuter = - static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); - if (m_pOwner->m_bNotifyOwner) { - m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); - pOuter->m_pDelegate->OnProcessMessage(pMsg); - } else { - if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { - CFX_RectF rect; - m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { - return 1; - } - } - pOuter->ShowDropList(FALSE); - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (hItem) { - pOuter->ProcessSelChanged(TRUE); - } - } - return 1; -} -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) { - FX_DWORD dwKeyCode = pKey->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Return: - case FWL_VKEY_Escape: { - pOuter->ShowDropList(FALSE); - return 1; - } - case FWL_VKEY_Up: - case FWL_VKEY_Down: { - OnDropListKeyDown(pKey); - pOuter->SetDelegate(nullptr); - pOuter->ProcessSelChanged(FALSE); - return 1; - } - default: { bPropagate = TRUE; } - } - } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) { - bPropagate = TRUE; - } - if (bPropagate) { - pKey->m_pDstTarget = m_pOwner->m_pOuter; - pOuter->m_pDelegate->OnProcessMessage(pKey); - return 1; - } - return 0; -} -void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) { - FX_DWORD dwKeyCode = pKey->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Home: - case FWL_VKEY_End: { - CFWL_ComboBoxImp* pOuter = - static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); - IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( - m_pOwner->m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = - pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel); - hItem = m_pOwner->GetItem(hItem, dwKeyCode); - if (!hItem) { - break; - } - m_pOwner->SetSelection(hItem, hItem, TRUE); - m_pOwner->ScrollToVisible(hItem); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, - m_pOwner->m_pProperties->m_rtWidget.height); - m_pOwner->Repaint(&rtInvalidate); - break; - } - default: {} - } -} -CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_pForm(NULL), - m_bLButtonDown(FALSE), - m_iCurSel(-1), - m_iBtnState(FWL_PARTSTATE_CMB_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 { - wsClass = FWL_CLASS_ComboBox; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_ComboBoxImp::GetClassID() const { - return FWL_CLASSHASH_ComboBox; -} -FWL_ERR 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. - 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) { - 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(); - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { - CFWL_WidgetImpProperties prop2; - m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop2, m_pInterface)); - m_pEdit->Initialize(); - static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); - } - if (m_pEdit) { - m_pEdit->SetParent(m_pInterface); - } - SetStates(m_pProperties->m_dwStates); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::Finalize() { - if (m_pEdit) { - m_pEdit->Finalize(); - } - m_pListBox->Finalize(); - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - rect.Reset(); - FX_BOOL bIsDropDown = IsDropDownStyle(); - if (bIsDropDown && m_pEdit) { - m_pEdit->GetWidgetRect(rect, TRUE); - } else { - rect.width = 100; - rect.height = 16; - } - if (!m_pProperties->m_pThemeProvider) { - ReSetTheme(); - } - FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - if (!pFWidth) - return FWL_ERR_Indefinite; - rect.Inflate(0, 0, *pFWidth, 0); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD 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; - if (bAddDropDown && !m_pEdit) { - CFWL_WidgetImpProperties prop; - m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, nullptr)); - m_pEdit->Initialize(); - static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); - m_pEdit->SetParent(m_pInterface); - } else if (bRemoveDropDown && m_pEdit) { - m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -FWL_ERR CFWL_ComboBoxImp::Update() { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_Update(); - } - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - ReSetTheme(); - FX_BOOL bDropDown = IsDropDownStyle(); - if (bDropDown && m_pEdit) { - ReSetEditAlignment(); - } - if (m_pProperties->m_pThemeProvider == NULL) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - Layout(); - CFWL_ThemePart part; - 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; -} -FX_DWORD 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) { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_DrawWidget(pGraphics, pMatrix); - } - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - FX_BOOL bIsDropDown = IsDropDownStyle(); - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_CMB_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_CMB_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_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = rtTextBk; - if (m_iCurSel >= 0) { - IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->m_pProperties->m_pDataProvider); - void* p = pData->GetItemData(m_pListBox.get(), - pData->GetItem(m_pListBox.get(), m_iCurSel)); - if (p != NULL) { - param.m_pData = p; - } - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - param.m_dwStates = FWL_PARTSTATE_CMB_Disabled; - } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && - (m_iCurSel >= 0)) { - param.m_dwStates = FWL_PARTSTATE_CMB_Selected; - } else { - param.m_dwStates = FWL_PARTSTATE_CMB_Normal; - } - pTheme->DrawBackground(¶m); - if (m_iCurSel >= 0) { - if (!m_pListBox) - return FWL_ERR_Indefinite; - CFX_WideString wsText; - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->GetItemText(hItem, wsText); - CFWL_ThemeText param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_CMB_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; - param.m_wsText = wsText; - param.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - param.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; - pTheme->DrawText(¶m); - } - } - { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_CMB_DropDownButton; - param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_CMB_Disabled - : m_iBtnState; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtBtn; - pTheme->DrawBackground(¶m); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { - if (!pThemeProvider) - return FWL_ERR_Indefinite; - m_pProperties->m_pThemeProvider = pThemeProvider; - if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox.get())) { - m_pListBox->SetThemeProvider(pThemeProvider); - } - if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit.get())) { - m_pEdit->SetThemeProvider(pThemeProvider); - } - return FWL_ERR_Succeeded; -} -int32_t CFWL_ComboBoxImp::GetCurSel() { - return m_iCurSel; -} -FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { - int32_t iCount = - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems(); - FX_BOOL bClearSel = iSel < 0 || iSel >= iCount; - FX_BOOL bDropDown = IsDropDownStyle(); - if (bDropDown && m_pEdit) { - if (bClearSel) { - m_pEdit->SetText(CFX_WideString()); - } else { - CFX_WideString wsText; - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->GetItemText(hItem, wsText); - m_pEdit->SetText(wsText); - } - m_pEdit->Update(); - } - m_iCurSel = bClearSel ? -1 : iSel; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { - FX_BOOL bIsDropDown = IsDropDownStyle(); - if (bIsDropDown && m_pEdit) { - m_pEdit->SetStates(dwStates, bSet); - } - if (m_pListBox) { - m_pListBox->SetStates(dwStates, bSet); - } - return CFWL_WidgetImp::SetStates(dwStates, bSet); -} -FWL_ERR CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) { - if (!m_pEdit) - return FWL_ERR_Indefinite; - m_pEdit->SetText(wsText); - return m_pEdit->Update(); -} -int32_t CFWL_ComboBoxImp::GetEditTextLength() const { - if (!m_pEdit) - return -1; - return m_pEdit->GetTextLength(); -} -FWL_ERR 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) { - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); - return m_pListBox->GetItemText(hItem, wsText); - } - return FWL_ERR_Indefinite; -} -FWL_ERR CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) { - if (!m_pEdit) - return FWL_ERR_Indefinite; - static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->ClearSelected(); - m_pEdit->AddSelRange(nStart, nCount); - return FWL_ERR_Succeeded; -} -int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t& nStart) { - if (!m_pEdit) - return -1; - return m_pEdit->GetSelRange(nIndex, nStart); -} -int32_t CFWL_ComboBoxImp::GetEditLimit() { - if (!m_pEdit) - return -1; - return m_pEdit->GetLimit(); -} -FWL_ERR CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) { - if (!m_pEdit) - return FWL_ERR_Indefinite; - return m_pEdit->SetLimit(nLimit); -} -FWL_ERR CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) { - if (!m_pEdit) - return FWL_ERR_Indefinite; - return m_pEdit->DoClipboard(iCmd); -} -FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord) { - if (!m_pEdit) - return FALSE; - return m_pEdit->Redo(bsRecord); -} -FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) { - if (!m_pEdit) - return FALSE; - return m_pEdit->Undo(bsRecord); -} -IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { - return m_pListBox.get(); -} -FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { - if (!m_bNeedShowList) { - return FALSE; - } - if (m_pEdit) { - MatchEditText(); - } - ShowDropList(TRUE); - m_bNeedShowList = FALSE; - return TRUE; -} -FX_ERR CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) { - ShowDropList(bActivate); - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_ComboBoxImp::EditCanUndo() { - return m_pEdit->CanUndo(); -} -FX_BOOL CFWL_ComboBoxImp::EditCanRedo() { - return m_pEdit->CanRedo(); -} -FX_BOOL CFWL_ComboBoxImp::EditUndo() { - return m_pEdit->Undo(); -} -FX_BOOL CFWL_ComboBoxImp::EditRedo() { - return m_pEdit->Redo(); -} -FX_BOOL CFWL_ComboBoxImp::EditCanCopy() { - return m_pEdit->CountSelRanges() > 0; -} -FX_BOOL CFWL_ComboBoxImp::EditCanCut() { - if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { - return FALSE; - } - return m_pEdit->CountSelRanges() > 0; -} -FX_BOOL CFWL_ComboBoxImp::EditCanSelectAll() { - return m_pEdit->GetTextLength() > 0; -} -FX_BOOL CFWL_ComboBoxImp::EditCopy(CFX_WideString& wsCopy) { - return m_pEdit->Copy(wsCopy); -} -FX_BOOL CFWL_ComboBoxImp::EditCut(CFX_WideString& wsCut) { - return m_pEdit->Cut(wsCut); -} -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; -} -FX_BOOL CFWL_ComboBoxImp::EditDelete() { - return m_pEdit->ClearText() == FWL_ERR_Succeeded; -} -FX_BOOL CFWL_ComboBoxImp::EditDeSelect() { - return m_pEdit->ClearSelections() == FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_GetBBox(rect); - } - rect = m_pProperties->m_rtWidget; - if (m_pListBox && IsDropListShowed()) { - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList); - rtList.Offset(rect.left, rect.top); - rect.Union(rtList); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::EditModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - if (m_pEdit != NULL) { - return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); - } else { - return FWL_ERR_Parameter_Invalid; - } -} -FX_FLOAT CFWL_ComboBoxImp::GetListHeight() { - return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) - ->GetListHeight(m_pInterface); -} -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_pWidget = m_pInterface; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtHandler; - m_pProperties->m_pThemeProvider->DrawBackground(¶m); -} -void CFWL_ComboBoxImp::ShowDropList(FX_BOOL bActivate) { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_ShowDropList(bActivate); - } - FX_BOOL bDropList = IsDropListShowed(); - if (bDropList == bActivate) { - return; - } - if (!m_pForm) { - InitProxyForm(); - } - m_pListProxyDelegate->Reset(); - if (bActivate) { - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->ChangeSelected(m_iCurSel); - ReSetListItemAlignment(); - FX_DWORD dwStyleAdd = m_pProperties->m_dwStyleExes & - (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); - m_pListBox->ModifyStylesEx(dwStyleAdd, 0); - m_pListBox->GetWidgetRect(m_rtList, TRUE); - FX_FLOAT fHeight = GetListHeight(); - if (fHeight > 0) { - if (m_rtList.height > GetListHeight()) { - m_rtList.height = GetListHeight(); - m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); - } - } - CFX_RectF rtAnchor; - rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - FX_FLOAT fMinHeight = 0; - if (m_rtList.width < m_rtClient.width) { - m_rtList.width = m_rtClient.width; - } - m_rtProxy = m_rtList; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { - m_rtProxy.height += m_fComboFormHandler; - } - GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { - FX_FLOAT fx = 0; - FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2; - TransformTo(NULL, fx, fy); - m_bUpFormHandler = fy > m_rtProxy.top; - if (m_bUpFormHandler) { - m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler); - m_rtList.top = m_fComboFormHandler; - } else { - m_rtHandler.Set(0, m_rtList.height, m_rtList.width, - m_fComboFormHandler); - } - } - m_pForm->SetWidgetRect(m_rtProxy); - m_pForm->Update(); - m_pListBox->SetWidgetRect(m_rtList); - m_pListBox->Update(); - CFWL_EvtCmbPreDropDown ev; - ev.m_pSrcTarget = m_pInterface; - DispatchEvent(&ev); - m_fItemHeight = - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_fItemHeight; - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(TRUE); - m_pForm->DoModal(); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(FALSE); - } else { - m_pForm->EndDoModal(); - CFWL_EvtCmbCloseUp ev; - ev.m_pSrcTarget = m_pInterface; - DispatchEvent(&ev); - m_bLButtonDown = FALSE; - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_bNotifyOwner = - TRUE; - SetFocus(TRUE); - } -} -FX_BOOL CFWL_ComboBoxImp::IsDropListShowed() { - return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); -} -FX_BOOL CFWL_ComboBoxImp::IsDropDownStyle() const { - return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown; -} -void CFWL_ComboBoxImp::MatchEditText() { - CFX_WideString wsText; - m_pEdit->GetText(wsText); - int32_t iMatch = - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->MatchItem(wsText); - if (iMatch != m_iCurSel) { - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->ChangeSelected(iMatch); - if (iMatch >= 0) { - SynchrEditText(iMatch); - } - } else if (iMatch >= 0) { - static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); - } - m_iCurSel = iMatch; -} -void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem) { - CFX_WideString wsText; - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iListItem); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->GetItemText(hItem, wsText); - m_pEdit->SetText(wsText); - m_pEdit->Update(); - static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); -} -void CFWL_ComboBoxImp::Layout() { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_Layout(); - } - GetClientRect(m_rtClient); - FX_FLOAT* pFWidth = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - if (!pFWidth) - return; - FX_FLOAT fBtn = *pFWidth; - m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, - m_rtClient.height); - FX_BOOL bIsDropDown = IsDropDownStyle(); - if (bIsDropDown && m_pEdit) { - CFX_RectF rtEdit; - rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, - m_rtClient.height); - m_pEdit->SetWidgetRect(rtEdit); - if (m_iCurSel >= 0) { - CFX_WideString wsText; - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->GetItemText(hItem, wsText); - m_pEdit->LockUpdate(); - m_pEdit->SetText(wsText); - m_pEdit->UnlockUpdate(); - } - m_pEdit->Update(); - } -} -void CFWL_ComboBoxImp::ReSetTheme() { - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (!pTheme) { - pTheme = GetAvailableTheme(); - m_pProperties->m_pThemeProvider = pTheme; - } - if (m_pListBox) { - if (!m_pListBox->GetThemeProvider() && - pTheme->IsValidWidget(m_pListBox.get())) { - m_pListBox->SetThemeProvider(pTheme); - } - } - if (m_pEdit) { - if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit.get())) { - m_pEdit->SetThemeProvider(pTheme); - } - } -} -void CFWL_ComboBoxImp::ReSetEditAlignment() { - if (!m_pEdit) - return; - FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; - FX_DWORD dwAdd = 0; - switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { - case FWL_STYLEEXT_CMB_EditHCenter: { - dwAdd |= FWL_STYLEEXT_EDT_HCenter; - break; - } - case FWL_STYLEEXT_CMB_EditHFar: { - dwAdd |= FWL_STYLEEXT_EDT_HFar; - break; - } - default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; } - } - switch (dwStylExes & FWL_STYLEEXT_CMB_EditVAlignMask) { - case FWL_STYLEEXT_CMB_EditVCenter: { - dwAdd |= FWL_STYLEEXT_EDT_VCenter; - break; - } - case FWL_STYLEEXT_CMB_EditVFar: { - dwAdd |= FWL_STYLEEXT_EDT_VFar; - break; - } - default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; } - } - if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) { - dwAdd |= FWL_STYLEEXT_EDT_Justified; - } - if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) { - dwAdd |= FWL_STYLEEXT_EDT_Distributed; - } - m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | - FWL_STYLEEXT_EDT_HAlignModeMask | - FWL_STYLEEXT_EDT_VAlignMask); -} -void CFWL_ComboBoxImp::ReSetListItemAlignment() { - if (!m_pListBox) - return; - FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; - FX_DWORD dwAdd = 0; - switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { - case FWL_STYLEEXT_CMB_ListItemCenterAlign: { - dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; - } - case FWL_STYLEEXT_CMB_ListItemRightAlign: { - dwAdd |= FWL_STYLEEXT_LTB_RightAlign; - } - default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; } - } - m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); -} -void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) { - IFWL_ComboBoxDP* pDatas = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - m_iCurSel = pDatas->GetItemIndex(m_pInterface, m_pListBox->GetSelItem(0)); - FX_BOOL bDropDown = IsDropDownStyle(); - if (bDropDown) { - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); - if (hItem) { - CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); - if (m_pEdit) { - m_pEdit->SetText(wsText); - m_pEdit->Update(); - static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); - } - CFWL_EvtCmbSelChanged ev; - ev.bLButtonUp = bLButtonUp; - ev.m_pSrcTarget = m_pInterface; - ev.iArraySels.Add(m_iCurSel); - DispatchEvent(&ev); - } - } else { - 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; - propForm.m_dwStates = FWL_WGTSTATE_Invisible; - CFX_WideString className; - m_pForm = IFWL_Form::CreateFormProxy(propForm, &className, m_pListBox.get()); - m_pForm->Initialize(); - m_pProxy = static_cast<CFWL_FormProxyImp*>(m_pForm->GetImpl()); - m_pListBox->SetParent(m_pForm); - 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. - m_pDelegate = new CFWL_ComboBoxImpDelegate(this); - DisForm_InitComboList(); - DisForm_InitComboEdit(); - return FWL_ERR_Succeeded; -} -void CFWL_ComboBoxImp::DisForm_InitComboList() { - if (m_pListBox) { - return; - } - CFWL_WidgetImpProperties prop; - prop.m_pParent = m_pInterface; - prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; - prop.m_dwStates = FWL_WGTSTATE_Invisible; - prop.m_pDataProvider = m_pProperties->m_pDataProvider; - prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pListBox.reset(IFWL_ListBox::CreateComboList(prop, m_pInterface)); - m_pListBox->Initialize(); -} -void CFWL_ComboBoxImp::DisForm_InitComboEdit() { - if (m_pEdit) { - return; - } - CFWL_WidgetImpProperties prop; - prop.m_pParent = m_pInterface; - prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, m_pInterface)); - m_pEdit->Initialize(); - static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); -} -void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) { - FX_BOOL bDropList = DisForm_IsDropListShowed(); - if (bDropList == bActivate) { - return; - } - if (bActivate) { - CFWL_EvtCmbPreDropDown preEvent; - preEvent.m_pSrcTarget = m_pInterface; - DispatchEvent(&preEvent); - CFWL_ComboListImp* pComboList = - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()); - int32_t iItems = pComboList->CountItems(); - if (iItems < 1) { - return; - } - ReSetListItemAlignment(); - pComboList->ChangeSelected(m_iCurSel); - FX_FLOAT fItemHeight = pComboList->GetItemHeigt(); - FX_FLOAT fBorder = GetBorderSize(); - FX_FLOAT fPopupMin = 0.0f; - if (iItems > 3) { - fPopupMin = fItemHeight * 3 + fBorder * 2; - } - FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; - CFX_RectF rtList; - rtList.left = m_rtClient.left; - rtList.width = m_pProperties->m_rtWidget.width; - rtList.top = 0; - rtList.height = 0; - GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); - m_pListBox->SetWidgetRect(rtList); - m_pListBox->Update(); - } else { - SetFocus(TRUE); - } - m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); - if (bActivate) { - CFWL_EvtCmbPostDropDown postEvent; - postEvent.m_pSrcTarget = m_pInterface; - DispatchEvent(&postEvent); - } - CFX_RectF rect; - m_pListBox->GetWidgetRect(rect); - rect.Inflate(2, 2); - Repaint(&rect); -} -FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed() { - return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); -} -FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - if (!m_pEdit) { - DisForm_InitComboEdit(); - } - FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown; - FX_BOOL bDelDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown; - dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; - m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; - if (bAddDropDown) { - m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); - } else if (bDelDropDown) { - m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); - } - return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -FWL_ERR CFWL_ComboBoxImp::DisForm_Update() { - if (m_iLock) { - return FWL_ERR_Indefinite; - } - if (m_pEdit) { - ReSetEditAlignment(); - } - ReSetTheme(); - Layout(); - return FWL_ERR_Succeeded; -} -FX_DWORD 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 (DisForm_IsDropListShowed()) { - m_pListBox->GetWidgetRect(rect); - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - } - return FWL_WGTHITTEST_Unknown; -} -FWL_ERR 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); - if (pMatrix) { - mtOrg = *pMatrix; - } - FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed(); - pGraphics->SaveGraphState(); - pGraphics->ConcatMatrix(&mtOrg); - if (!m_rtBtn.IsEmpty(0.1f)) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_CMB_DropDownButton; - param.m_dwStates = m_iBtnState; - param.m_pGraphics = pGraphics; - param.m_rtPart = m_rtBtn; - pTheme->DrawBackground(¶m); - } - pGraphics->RestoreGraphState(); - if (m_pEdit) { - CFX_RectF rtEdit; - m_pEdit->GetWidgetRect(rtEdit); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); - mt.Concat(mtOrg); - m_pEdit->DrawWidget(pGraphics, &mt); - } - if (bListShowed) { - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtList.left, rtList.top); - mt.Concat(mtOrg); - m_pListBox->DrawWidget(pGraphics, &mt); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) { - rect = m_pProperties->m_rtWidget; - if (m_pListBox && DisForm_IsDropListShowed()) { - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList); - rtList.Offset(rect.left, rect.top); - rect.Union(rtList); - } - return FWL_ERR_Succeeded; -} -void CFWL_ComboBoxImp::DisForm_Layout() { - GetClientRect(m_rtClient); - m_rtContent = m_rtClient; - FX_FLOAT* pFWidth = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - if (!pFWidth) - return; - FX_FLOAT borderWidth = 0; - { borderWidth = FWL_PART_CMB_Border; } - 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)); - if (pUIMargin) { - m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } - FX_BOOL bIsDropDown = IsDropDownStyle(); - if (bIsDropDown && m_pEdit) { - CFX_RectF rtEdit; - rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, - m_rtContent.height); - m_pEdit->SetWidgetRect(rtEdit); - if (m_iCurSel >= 0) { - CFX_WideString wsText; - IFWL_ComboBoxDP* pData = - static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); - static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) - ->GetItemText(hItem, wsText); - m_pEdit->LockUpdate(); - m_pEdit->SetText(wsText); - m_pEdit->UnlockUpdate(); - } - m_pEdit->Update(); - } -} -CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - return DisForm_OnProcessMessage(pMessage); - } - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - FX_BOOL iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD 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; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - OnKey(static_cast<CFWL_MsgKey*>(pMessage)); - break; - } - default: { iRet = 0; } - } - CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); - return iRet; -} -FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - FX_DWORD dwFlag = pEvent->GetClassID(); - if (dwFlag == FWL_EVTHASH_LTB_DrawItem) { - CFWL_EvtLtbDrawItem* pDrawItemEvent = - static_cast<CFWL_EvtLtbDrawItem*>(pEvent); - CFWL_EvtCmbDrawItem pTemp; - pTemp.m_pSrcTarget = m_pOwner->m_pInterface; - pTemp.m_pGraphics = pDrawItemEvent->m_pGraphics; - pTemp.m_index = pDrawItemEvent->m_index; - pTemp.m_rtItem = pDrawItemEvent->m_rect; - m_pOwner->DispatchEvent(&pTemp); - } else if (dwFlag == FWL_EVTHASH_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) { - CFWL_EvtEdtTextChanged* pTextChangedEvent = - static_cast<CFWL_EvtEdtTextChanged*>(pEvent); - CFWL_EvtCmbEditChanged pTemp; - pTemp.m_pSrcTarget = m_pOwner->m_pInterface; - pTemp.wsInsert = pTextChangedEvent->wsInsert; - pTemp.wsDelete = pTextChangedEvent->wsDelete; - 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::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - IFWL_Target* pDstTarget = pMsg->m_pDstTarget; - IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget; - FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) { - if (!m_pOwner->m_pEdit) - return; - static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) - ->SetSelected(); - } else { - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) { - if (!m_pOwner->m_pEdit) - return; - static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) - ->FlagFocus(FALSE); - static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) - ->ClearSelected(); - } else { - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - } -} -void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - return; - } - FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); - CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient; - FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); - if (bClickBtn) { - if (bDropDown && m_pOwner->m_pEdit) { - m_pOwner->MatchEditText(); - } - m_pOwner->m_bLButtonDown = TRUE; - m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Pressed; - m_pOwner->Repaint(&m_pOwner->m_rtClient); - m_pOwner->ShowDropList(TRUE); - m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_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; - } else { - m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_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; - } else { - m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal; - } - if ((iOldState != m_pOwner->m_iBtnState) && - !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == - FWL_WGTSTATE_Disabled)) { - m_pOwner->Repaint(&m_pOwner->m_rtBtn); - } -} -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->Repaint(&m_pOwner->m_rtBtn); - } -} -void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) { - FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; - if (dwKeyCode == FWL_VKEY_Tab) { - m_pOwner->DispatchKeyEvent(pMsg); - return; - } - if (pMsg->m_pDstTarget == m_pOwner->m_pInterface) - DoSubCtrlKey(pMsg); -} -void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) { - FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; - const bool bUp = dwKeyCode == FWL_VKEY_Up; - const bool bDown = dwKeyCode == FWL_VKEY_Down; - if (bUp || bDown) { - int32_t iCount = - static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) - ->CountItems(); - if (iCount < 1) { - return; - } - FX_BOOL bMatchEqual = FALSE; - int32_t iCurSel = m_pOwner->m_iCurSel; - FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); - if (bDropDown && m_pOwner->m_pEdit) { - CFX_WideString wsText; - m_pOwner->m_pEdit->GetText(wsText); - iCurSel = static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) - ->MatchItem(wsText); - if (iCurSel >= 0) { - CFX_WideString wsTemp; - IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>( - m_pOwner->m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel); - static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) - ->GetItemText(hItem, wsTemp); - bMatchEqual = wsText.Equal(wsTemp); - } - } - if (iCurSel < 0) { - iCurSel = 0; - } else if (!bDropDown || bMatchEqual) { - if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) { - return; - } - if (bUp) { - iCurSel--; - } else { - iCurSel++; - } - } - m_pOwner->m_iCurSel = iCurSel; - if (bDropDown && m_pOwner->m_pEdit) { - m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); - } else { - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - return; - } - FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); - if (bDropDown) { - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMsg); - } -} -int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( - CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - FX_BOOL backDefault = TRUE; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - backDefault = FALSE; - DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - backDefault = FALSE; - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - DisForm_OnLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - backDefault = FALSE; - CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) { - break; - } - if (m_pOwner->DisForm_IsDropListShowed() && - pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { - FX_DWORD dwKeyCode = pKey->m_dwKeyCode; - FX_BOOL bListKey = - dwKeyCode == FWL_VKEY_Up || dwKeyCode == FWL_VKEY_Down || - dwKeyCode == FWL_VKEY_Return || dwKeyCode == FWL_VKEY_Escape; - if (bListKey) { - IFWL_WidgetDelegate* pDelegate = - m_pOwner->m_pListBox->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMessage); - break; - } - } - DisForm_OnKey(pKey); - break; - } - default: {} - } - if (!backDefault) { - return 1; - } - return 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; - FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); - if (bClickBtn) { - if (m_pOwner->DisForm_IsDropListShowed()) { - m_pOwner->DisForm_ShowDropList(FALSE); - return; - } - { - if (m_pOwner->m_pEdit) { - m_pOwner->MatchEditText(); - } - m_pOwner->DisForm_ShowDropList(TRUE); - } - } -} -void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { - CFWL_MsgSetFocus msg; - msg.m_pDstTarget = m_pOwner->m_pEdit.get(); - msg.m_pSrcTarget = NULL; - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(&msg); - } - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - m_pOwner->DisForm_ShowDropList(FALSE); - CFWL_MsgKillFocus msg; - msg.m_pDstTarget = NULL; - msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(&msg); - } -} -void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { - FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; - const bool bUp = dwKeyCode == FWL_VKEY_Up; - const bool bDown = dwKeyCode == FWL_VKEY_Down; - if (bUp || bDown) { - CFWL_ComboListImp* pComboList = - static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()); - int32_t iCount = pComboList->CountItems(); - if (iCount < 1) { - return; - } - FX_BOOL bMatchEqual = FALSE; - int32_t iCurSel = m_pOwner->m_iCurSel; - if (m_pOwner->m_pEdit) { - CFX_WideString wsText; - m_pOwner->m_pEdit->GetText(wsText); - iCurSel = pComboList->MatchItem(wsText); - if (iCurSel >= 0) { - CFX_WideString wsTemp; - FWL_HLISTITEM item = m_pOwner->m_pListBox->GetSelItem(iCurSel); - m_pOwner->m_pListBox->GetItemText(item, wsTemp); - bMatchEqual = wsText.Equal(wsTemp); - } - } - if (iCurSel < 0) { - iCurSel = 0; - } else if (bMatchEqual) { - if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) { - return; - } - if (bUp) { - iCurSel--; - } else { - iCurSel++; - } - } - m_pOwner->m_iCurSel = iCurSel; - m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); - return; - } - if (m_pOwner->m_pEdit) { - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMsg); - } -} -CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate( - IFWL_Form* pForm, - CFWL_ComboBoxImp* pComboBox) - : m_bLButtonDown(FALSE), - m_bLButtonUpSelf(FALSE), - m_fStartPos(0), - m_pForm(pForm), - m_pComboBox(pComboBox) {} -int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - if (dwMsgCode == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD 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; - } - default: {} - } - } - 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); -} -FWL_ERR 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) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - CFX_RectF rtWidget; - m_pForm->GetWidgetRect(rtWidget); - rtWidget.left = rtWidget.top = 0; - if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_bLButtonDown = TRUE; - pDriver->SetGrab(m_pForm, TRUE); - } else { - m_bLButtonDown = FALSE; - pDriver->SetGrab(m_pForm, FALSE); - m_pComboBox->ShowDropList(FALSE); - } -} -void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - m_bLButtonDown = FALSE; - IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); - if (!pThread) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - pDriver->SetGrab(m_pForm, FALSE); - if (m_bLButtonUpSelf) { - CFX_RectF rect; - m_pForm->GetWidgetRect(rect); - rect.left = rect.top = 0; - if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && - m_pComboBox->IsDropListShowed()) { - m_pComboBox->ShowDropList(FALSE); - } - } else { - m_bLButtonUpSelf = TRUE; - } -} -void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {} -void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) { - m_pComboBox->ShowDropList(FALSE); -} -void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, - FX_BOOL bSet) { - if (!bSet) { - if (pMsg->m_pSetFocus == NULL) { - m_pComboBox->ShowDropList(FALSE); - } - } -} diff --git a/xfa/src/fwl/basewidget/fwl_comboboximp.h b/xfa/src/fwl/basewidget/fwl_comboboximp.h deleted file mode 100644 index 000e0afe9c..0000000000 --- a/xfa/src/fwl/basewidget/fwl_comboboximp.h +++ /dev/null @@ -1,237 +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_SRC_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ - -#include <memory> - -#include "xfa/src/fwl/basewidget/fwl_editimp.h" -#include "xfa/src/fwl/basewidget/fwl_listboximp.h" - -class CFWL_WidgetImp; -class CFWL_WidgetImpProperties; -class CFWL_WidgetImpDelegate; -class CFWL_ListBoxImp; -class CFWL_ListBoxImpDelegate; -class CFWL_FormProxyImp; -class IFWL_Widget; -class CFWL_ComboEditImp; -class CFWL_ComboEditImpDelegate; -class CFWL_ComboListImp; -class CFWL_ComboListImpDelegate; -class CFWL_ComboBoxImp; -class CFWL_ComboBoxImpDelegate; -class CFWL_ComboProxyImpDelegate; -class CFWL_ComboEditImp : public CFWL_EditImp { - public: - CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - - void ClearSelected(); - void SetSelected(); - void EndCaret(); - void FlagFocus(FX_BOOL bSet); - - protected: - void SetComboBoxFocus(FX_BOOL bSet); - CFWL_ComboBoxImp* m_pOuter; - friend class CFWL_ComboEditImpDelegate; -}; -class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate { - public: - CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner); - int32_t OnProcessMessage(CFWL_Message* pMessage) override; - - protected: - CFWL_ComboEditImp* m_pOwner; -}; -class CFWL_ComboListImp : public CFWL_ListBoxImp { - public: - CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - 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; - - protected: - void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg); - int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg); - int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg); - int32_t OnDropListKey(CFWL_MsgKey* pKey); - void OnDropListKeyDown(CFWL_MsgKey* pKey); - CFWL_ComboListImp* m_pOwner; -}; -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 FX_DWORD 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(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved); - virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); - virtual FWL_ERR Update(); - virtual FX_DWORD 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(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved); - - protected: - void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); - FX_FLOAT GetListHeight(); - void ShowDropList(FX_BOOL bActivate); - FX_BOOL IsDropListShowed(); - FX_BOOL IsDropDownStyle() const; - void MatchEditText(); - void SynchrEditText(int32_t iListItem); - void Layout(); - void ReSetTheme(); - void ReSetEditAlignment(); - void ReSetListItemAlignment(); - void ProcessSelChanged(FX_BOOL bLButtonUp); - void InitProxyForm(); - FWL_ERR DisForm_Initialize(); - void DisForm_InitComboList(); - void DisForm_InitComboEdit(); - void DisForm_ShowDropList(FX_BOOL bActivate); - FX_BOOL DisForm_IsDropListShowed(); - FWL_ERR DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved); - FWL_ERR DisForm_Update(); - FX_DWORD 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); - void DisForm_Layout(); - - CFX_RectF m_rtClient; - CFX_RectF m_rtContent; - CFX_RectF m_rtBtn; - CFX_RectF m_rtList; - CFX_RectF m_rtProxy; - CFX_RectF m_rtHandler; - std::unique_ptr<IFWL_Edit> m_pEdit; - std::unique_ptr<IFWL_ListBox> m_pListBox; - IFWL_Form* m_pForm; - FX_BOOL m_bLButtonDown; - FX_BOOL m_bUpFormHandler; - int32_t m_iCurSel; - int32_t m_iBtnState; - FX_FLOAT m_fComboFormHandler; - FX_FLOAT m_fItemHeight; - 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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKey(CFWL_MsgKey* pMsg); - void DoSubCtrlKey(CFWL_MsgKey* pMsg); - - protected: - int32_t 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); - - protected: - CFWL_ComboBoxImp* m_pOwner; - friend class CFWL_ComboEditImpDelegate; - friend class CFWL_ComboListImpDelegate; -}; -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 Reset() { m_bLButtonUpSelf = FALSE; } - - protected: - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnDeactive(CFWL_MsgDeactivate* pMsg); - void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet); - FX_BOOL m_bLButtonDown; - FX_BOOL m_bLButtonUpSelf; - FX_FLOAT m_fStartPos; - IFWL_Form* m_pForm; - CFWL_ComboBoxImp* m_pComboBox; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/src/fwl/basewidget/fwl_datetimepickerimp.cpp deleted file mode 100644 index c969418c3a..0000000000 --- a/xfa/src/fwl/basewidget/fwl_datetimepickerimp.cpp +++ /dev/null @@ -1,1161 +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/src/fwl/basewidget/fwl_datetimepickerimp.h" - -#include "xfa/include/fwl/basewidget/fwl_spinbutton.h" -#include "xfa/src/fwl/basewidget/fwl_editimp.h" -#include "xfa/src/fwl/basewidget/fwl_formproxyimp.h" -#include "xfa/src/fwl/basewidget/fwl_monthcalendarimp.h" -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -#define FWL_DTP_WIDTH 100 -#define FWL_DTP_HEIGHT 20 - -// static -IFWL_DateTimePicker* IFWL_DateTimePicker::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_DateTimePicker* pDateTimePicker = new IFWL_DateTimePicker; - CFWL_DateTimePickerImp* pDateTimePickerImpl = - new CFWL_DateTimePickerImp(properties, pOuter); - pDateTimePicker->SetImpl(pDateTimePickerImpl); - pDateTimePickerImpl->SetInterface(pDateTimePicker); - return pDateTimePicker; -} - -// Static -IFWL_DateTimeForm* IFWL_DateTimeForm::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_DateTimeForm* pDateTimeForm = new IFWL_DateTimeForm; - CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter); - pDateTimeForm->SetImpl(pFormProxyImpl); - pFormProxyImpl->SetInterface(pDateTimeForm); - return pDateTimeForm; -} - -// static -IFWL_DateTimeCalender* IFWL_DateTimeCalender::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_DateTimeCalender* pDateTimeCalendar = new IFWL_DateTimeCalender; - CFWL_DateTimeCalendar* pDateTimeCalendarImpl = - new CFWL_DateTimeCalendar(properties, pOuter); - pDateTimeCalendar->SetImpl(pDateTimeCalendarImpl); - pDateTimeCalendarImpl->SetInterface(pDateTimeCalendar); - return pDateTimeCalendar; -} - -// static -IFWL_DateTimeEdit* IFWL_DateTimeEdit::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_DateTimeEdit* pDateTimeEdit = new IFWL_DateTimeEdit; - CFWL_DateTimeEdit* pDateTimeEditImpl = - new CFWL_DateTimeEdit(properties, pOuter); - pDateTimeEdit->SetImpl(pDateTimeEditImpl); - pDateTimeEditImpl->SetInterface(pDateTimeEdit); - return pDateTimeEdit; -} - -IFWL_DateTimePicker::IFWL_DateTimePicker() {} -int32_t IFWL_DateTimePicker::CountSelRanges() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) - ->GetDataTimeEdit() - ->CountSelRanges(); -} -int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) - ->GetDataTimeEdit() - ->GetSelRange(nIndex, nStart); -} -FWL_ERR 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) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) - ->SetCurSel(iYear, iMonth, iDay); -} -FWL_ERR 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 { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) - ->GetEditText(wsText, nStart, nCount); -} -FX_BOOL IFWL_DateTimePicker::CanUndo() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanUndo(); -} -FX_BOOL IFWL_DateTimePicker::CanRedo() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanRedo(); -} -FX_BOOL IFWL_DateTimePicker::Undo() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Undo(); -} -FX_BOOL IFWL_DateTimePicker::Redo() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Redo(); -} -FX_BOOL IFWL_DateTimePicker::CanCopy() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCopy(); -} -FX_BOOL IFWL_DateTimePicker::CanCut() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCut(); -} -FX_BOOL IFWL_DateTimePicker::CanSelectAll() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanSelectAll(); -} -FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Copy(wsCopy); -} -FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Cut(wsCut); -} -FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Paste(wsPaste); -} -FX_BOOL IFWL_DateTimePicker::SelectAll() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SelectAll(); -} -FX_BOOL IFWL_DateTimePicker::Delete() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Delete(); -} -FX_BOOL IFWL_DateTimePicker::DeSelect() { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect(); -} -FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect); -} -FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { - return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit); -} -FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD 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() { - m_pDelegate = new CFWL_DateTimeEditImpDelegate(this); - if (CFWL_EditImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - return FWL_ERR_Succeeded; -} -FWL_ERR 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) { - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - return DisForm_OnProcessMessage(pMessage); - } - FX_DWORD dwHashCode = pMessage->GetClassID(); - if (dwHashCode == FWL_MSGHASH_SetFocus || - dwHashCode == FWL_MSGHASH_KillFocus) { - IFWL_Widget* pOuter = m_pOwner->GetOuter(); - IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMessage); - } - return 1; -} -int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( - CFWL_Message* pMessage) { - FX_DWORD dwHashCode = pMessage->GetClassID(); - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - if (dwHashCode == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); - if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || - pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } - CFWL_DateTimePickerImp* pDateTime = - static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); - if (pDateTime->IsMonthCalendarShowed()) { - CFX_RectF rtInvalidate; - pDateTime->GetWidgetRect(rtInvalidate); - pDateTime->ShowMonthCalendar(FALSE); - rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); - pDateTime->Repaint(&rtInvalidate); - } - } - } else if (dwHashCode == FWL_MSGHASH_Key) { - return CFWL_EditImpDelegate::OnProcessMessage(pMessage); - } - } - return 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; - delete m_pDelegate; - m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR 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( - CFWL_Message* pMessage) { - FX_DWORD dwCode = pMessage->GetClassID(); - if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) { - IFWL_Widget* pOuter = m_pOwner->GetOuter(); - IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); - return pDelegate->OnProcessMessage(pMessage); - } else if (dwCode == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { - OnLButtonDownEx(pMsg); - return 1; - } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { - OnLButtonUpEx(pMsg); - return 1; - } - } - return 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->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->NextMonth(); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { - if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == - 0) { - m_pOwner->JumpToToday(); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - } else { - IFWL_DateTimePicker* pIPicker = - static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); - CFWL_DateTimePickerImp* pPicker = - static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); - if (pPicker->IsMonthCalendarShowed()) { - m_bFlag = 1; - } - } -} -void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - return DisForm_OnLButtonUpEx(pMsg); - } - if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iLBtnPartStates = 0; - m_pOwner->Repaint(&m_pOwner->m_rtLBtn); - return; - } - if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iRBtnPartStates = 0; - m_pOwner->Repaint(&m_pOwner->m_rtRBtn); - return; - } - if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { - return; - } - int32_t iOldSel = 0; - if (m_pOwner->m_arrSelDays.GetSize() > 0) { - iOldSel = m_pOwner->m_arrSelDays[0]; - } - int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - CFX_RectF rt; - IFWL_DateTimePicker* pIPicker = - static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); - CFWL_DateTimePickerImp* pPicker = - static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); - 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); - CFX_RectF rtInvalidate(lpDatesInfo->rect); - if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { - lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); - rtInvalidate.Union(lpDatesInfo->rect); - } - m_pOwner->AddSelDay(iCurSel); - if (!m_pOwner->m_pOuter) - return; - pPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, - iCurSel); - pPicker->ShowMonthCalendar(FALSE); - } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { - IFWL_DateTimePicker* pIPicker = - static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); - CFWL_DateTimePickerImp* pPicker = - static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl()); - pPicker->ShowMonthCalendar(FALSE); - } - m_bFlag = 0; -} -void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { - return; - } - FX_BOOL bRepaint = FALSE; - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, 0, 0); - if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { - int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - bRepaint = m_pOwner->m_iHovered != iHover; - if (bRepaint) { - if (m_pOwner->m_iHovered > 0) { - m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); - } - if (iHover > 0) { - CFX_RectF rtDay; - m_pOwner->GetDayRect(iHover, rtDay); - if (rtInvalidate.IsEmpty()) { - rtInvalidate = rtDay; - } else { - rtInvalidate.Union(rtDay); - } - } - } - m_pOwner->m_iHovered = iHover; - CFWL_Event_DtpHoverChanged ev; - ev.hoverday = iHover; - m_pOwner->DispatchEvent(&ev); - } else { - bRepaint = m_pOwner->m_iHovered > 0; - if (bRepaint) { - m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); - } - m_pOwner->m_iHovered = -1; - } - if (bRepaint && !rtInvalidate.IsEmpty()) { - m_pOwner->Repaint(&rtInvalidate); - } -} -int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( - CFWL_Message* pMessage) { - if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { - DisForm_OnLButtonUpEx(pMsg); - return 1; - } - } - return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); -} -void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( - CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iLBtnPartStates = 0; - m_pOwner->Repaint(&(m_pOwner->m_rtLBtn)); - return; - } - if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iRBtnPartStates = 0; - m_pOwner->Repaint(&(m_pOwner->m_rtRBtn)); - return; - } - if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { - return; - } - int32_t iOldSel = 0; - if (m_pOwner->m_arrSelDays.GetSize() > 0) { - iOldSel = m_pOwner->m_arrSelDays[0]; - } - 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); - CFX_RectF rtInvalidate(lpDatesInfo->rect); - if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { - lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); - rtInvalidate.Union(lpDatesInfo->rect); - } - m_pOwner->AddSelDay(iCurSel); - CFWL_DateTimePickerImp* pDateTime = - static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); - pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, - iCurSel); - pDateTime->ShowMonthCalendar(FALSE); - } -} -CFWL_DateTimePickerImp::CFWL_DateTimePickerImp( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_iBtnState(1), - m_iYear(-1), - m_iMonth(-1), - m_iDay(-1), - m_bLBtnDown(FALSE), - m_pEdit(nullptr), - m_pMonthCal(nullptr), - m_pForm(nullptr) { - m_rtBtn.Set(0, 0, 0, 0); -} -CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {} -FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_DateTimePicker; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_DateTimePickerImp::GetClassID() const { - return FWL_CLASSHASH_DateTimePicker; -} -FWL_ERR CFWL_DateTimePickerImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); - m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; - CFWL_WidgetImpProperties propMonth; - propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; - propMonth.m_dwStates = FWL_WGTSTATE_Invisible; - propMonth.m_pDataProvider = &m_MonthCalendarDP; - propMonth.m_pParent = m_pInterface; - propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); - m_pMonthCal->Initialize(); - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); - rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); - m_pMonthCal->SetWidgetRect(rtMonthCal); - CFWL_WidgetImpProperties propEdit; - propEdit.m_pParent = m_pInterface; - propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); - m_pEdit->Initialize(); - RegisterEventTarget(m_pMonthCal.get()); - RegisterEventTarget(m_pEdit.get()); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::Finalize() { - if (m_pEdit) { - m_pEdit->Finalize(); - } - if (m_pMonthCal) { - m_pMonthCal->Finalize(); - } - if (m_pForm) { - m_pForm->Finalize(); - } - UnregisterEventTarget(); - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR 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); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::Update() { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_Update(); - } - if (m_iLock) { - return FWL_ERR_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)); - if (!pFWidth) - return FWL_ERR_Indefinite; - FX_FLOAT fBtn = *pFWidth; - m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, - m_rtClient.height - 1); - CFX_RectF rtEdit; - rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, - m_rtClient.height); - m_pEdit->SetWidgetRect(rtEdit); - ReSetEditAlignment(); - m_pEdit->Update(); - 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); - } - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); - CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, - rtMonthCal.width, rtMonthCal.height); - m_pMonthCal->SetWidgetRect(rtPopUp); - m_pMonthCal->Update(); - return FWL_ERR_Succeeded; -} -FX_DWORD 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 (IsMonthCalendarShowed()) { - CFX_RectF rect; - m_pMonthCal->GetWidgetRect(rect); - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - } - return FWL_WGTHITTEST_Unknown; -} -FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix); - } - if (!m_rtBtn.IsEmpty()) { - DrawDropDownButton(pGraphics, pTheme, pMatrix); - } - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_DrawWidget(pGraphics, pMatrix); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) { - m_pProperties->m_pThemeProvider = pTP; - m_pMonthCal->SetThemeProvider(pTP); - return FWL_ERR_Succeeded; -} -FWL_ERR 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; -} -FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - if (iYear <= 0 || iYear >= 3000) - return FWL_ERR_Indefinite; - if (iMonth <= 0 || iMonth >= 13) - return FWL_ERR_Indefinite; - if (iDay <= 0 || iDay >= 32) - return FWL_ERR_Indefinite; - m_iYear = iYear; - m_iMonth = iMonth; - m_iDay = iDay; - m_pMonthCal->SetSelect(iYear, iMonth, iDay); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) { - if (!m_pEdit) - return FWL_ERR_Indefinite; - int32_t 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 { - if (m_pEdit) { - return m_pEdit->GetText(wsText, nStart, nCount); - } - return FWL_ERR_Indefinite; -} -FX_BOOL CFWL_DateTimePickerImp::CanUndo() { - return m_pEdit->CanUndo(); -} -FX_BOOL CFWL_DateTimePickerImp::CanRedo() { - return m_pEdit->CanRedo(); -} -FX_BOOL CFWL_DateTimePickerImp::Undo() { - return m_pEdit->Undo(); -} -FX_BOOL CFWL_DateTimePickerImp::Redo() { - return m_pEdit->Redo(); -} -FX_BOOL CFWL_DateTimePickerImp::CanCopy() { - int32_t nCount = m_pEdit->CountSelRanges(); - return nCount > 0; -} -FX_BOOL CFWL_DateTimePickerImp::CanCut() { - if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { - return FALSE; - } - int32_t nCount = m_pEdit->CountSelRanges(); - return nCount > 0; -} -FX_BOOL CFWL_DateTimePickerImp::CanSelectAll() { - return m_pEdit->GetTextLength() > 0; -} -FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) { - return m_pEdit->Copy(wsCopy); -} -FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) { - return m_pEdit->Cut(wsCut); -} -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; -} -FX_BOOL CFWL_DateTimePickerImp::Delete() { - return m_pEdit->ClearText() == FWL_ERR_Succeeded; -} -FX_BOOL CFWL_DateTimePickerImp::DeSelect() { - return m_pEdit->ClearSelections() == FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_GetBBox(rect); - } - rect = m_pProperties->m_rtWidget; - if (IsMonthCalendarShowed()) { - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth); - rtMonth.Offset(m_pProperties->m_rtWidget.left, - m_pProperties->m_rtWidget.top); - rect.Union(rtMonth); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) { - return m_pEdit->SetLimit(nLimit); -} -FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == - FWL_STYLEEXT_DTP_Spin) { - CFWL_WidgetImpProperties prop; - prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; - prop.m_pParent = m_pInterface; - prop.m_rtWidget = m_rtBtn; - IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(prop, m_pInterface); - pSpin->Initialize(); - } else { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_DTP_DropDownButton; - param.m_dwStates = m_iBtnState; - param.m_pGraphics = pGraphics; - param.m_rtPart = m_rtBtn; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶m); - } -} -void CFWL_DateTimePickerImp::FormatDateString(int32_t iYear, - int32_t iMonth, - int32_t iDay, - CFX_WideString& wsText) { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == - FWL_STYLEEXT_DTP_ShortDateFormat) { - wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay); - } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == - FWL_STYLEEXT_DTP_LongDateFormat) { - wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); - } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) == - FWL_STYLEEXT_DTP_TimeFormat) { - } -} -void CFWL_DateTimePickerImp::ShowMonthCalendar(FX_BOOL bActivate) { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_ShowMonthCalendar(bActivate); - } - if (IsMonthCalendarShowed() == bActivate) { - return; - } - if (!m_pForm) { - InitProxyForm(); - } - if (bActivate) { - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth); - CFX_RectF rtAnchor; - rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); - m_pForm->SetWidgetRect(rtMonth); - rtMonth.left = rtMonth.top = 0; - m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); - m_pMonthCal->SetWidgetRect(rtMonth); - m_pMonthCal->Update(); - m_pForm->DoModal(); - } else { - m_pForm->EndDoModal(); - } -} -FX_BOOL CFWL_DateTimePickerImp::IsMonthCalendarShowed() { - if (m_pWidgetMgr->IsFormDisabled()) { - return DisForm_IsMonthCalendarShowed(); - } - if (!m_pForm) - return FALSE; - return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); -} -void CFWL_DateTimePickerImp::ReSetEditAlignment() { - if (!m_pEdit) - return; - FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; - FX_DWORD dwAdd = 0; - switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) { - case FWL_STYLEEXT_DTP_EditHCenter: { - dwAdd |= FWL_STYLEEXT_EDT_HCenter; - break; - } - case FWL_STYLEEXT_DTP_EditHFar: { - dwAdd |= FWL_STYLEEXT_EDT_HFar; - break; - } - default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; } - } - switch (dwStylExes & FWL_STYLEEXT_DTP_EditVAlignMask) { - case FWL_STYLEEXT_DTP_EditVCenter: { - dwAdd |= FWL_STYLEEXT_EDT_VCenter; - break; - } - case FWL_STYLEEXT_DTP_EditVFar: { - dwAdd |= FWL_STYLEEXT_EDT_VFar; - break; - } - default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; } - } - if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) { - dwAdd |= FWL_STYLEEXT_EDT_Justified; - } - if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) { - dwAdd |= FWL_STYLEEXT_EDT_Distributed; - } - m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | - FWL_STYLEEXT_EDT_HAlignModeMask | - FWL_STYLEEXT_EDT_VAlignMask); -} -void CFWL_DateTimePickerImp::ProcessSelChanged(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - m_iYear = iYear; - m_iMonth = iMonth; - m_iDay = iDay; - CFX_WideString wsText; - FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); - m_pEdit->SetText(wsText); - m_pEdit->Update(); - Repaint(&m_rtClient); - CFWL_Event_DtpSelectChanged ev; - ev.m_pSrcTarget = m_pInterface; - ev.iYear = m_iYear; - ev.iMonth = m_iMonth; - ev.iDay = m_iDay; - DispatchEvent(&ev); -} -void CFWL_DateTimePickerImp::InitProxyForm() { - if (m_pForm) - return; - if (!m_pMonthCal) - return; - CFWL_WidgetImpProperties propForm; - propForm.m_dwStyles = FWL_WGTSTYLE_Popup; - propForm.m_dwStates = FWL_WGTSTATE_Invisible; - propForm.m_pOwner = m_pInterface; - m_pForm.reset(IFWL_DateTimeForm::Create(propForm, m_pMonthCal.get())); - m_pForm->Initialize(); - m_pMonthCal->SetParent(m_pForm.get()); -} -IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { - return m_pEdit.get(); -} -FWL_ERR 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; -} -void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { - if (m_pMonthCal) { - return; - } - CFWL_WidgetImpProperties propMonth; - propMonth.m_dwStyles = - FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; - propMonth.m_dwStates = FWL_WGTSTATE_Invisible; - propMonth.m_pParent = m_pInterface; - propMonth.m_pDataProvider = &m_MonthCalendarDP; - propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); - m_pMonthCal->Initialize(); - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); - rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); - m_pMonthCal->SetWidgetRect(rtMonthCal); -} -void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit() { - if (m_pEdit) { - return; - } - CFWL_WidgetImpProperties propEdit; - propEdit.m_pParent = m_pInterface; - propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); - m_pEdit->Initialize(); -} -FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed() { - if (!m_pMonthCal) - return FALSE; - return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); -} -void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { - FX_BOOL bShowed = IsMonthCalendarShowed(); - if (bShowed == bActivate) { - return; - } - if (bActivate) { - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); - FX_FLOAT fPopupMin = rtMonthCal.height; - FX_FLOAT fPopupMax = rtMonthCal.height; - CFX_RectF rtAnchor(m_pProperties->m_rtWidget); - rtAnchor.width = rtMonthCal.width; - rtMonthCal.left = m_rtClient.left; - rtMonthCal.top = rtAnchor.Height(); - GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); - m_pMonthCal->SetWidgetRect(rtMonthCal); - if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) { - m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); - } - m_pMonthCal->Update(); - } - m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); - if (bActivate) { - CFWL_MsgSetFocus msg; - msg.m_pDstTarget = m_pMonthCal.get(); - msg.m_pSrcTarget = m_pEdit.get(); - IFWL_WidgetDelegate* pDelegate = m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(&msg); - } - CFX_RectF rtInvalidate, rtCal; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - m_pMonthCal->GetWidgetRect(rtCal); - rtInvalidate.Union(rtCal); - rtInvalidate.Inflate(2, 2); - Repaint(&rtInvalidate); -} -FX_DWORD 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()) { - rect.width += m_fBtn; - } - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - if (IsMonthCalendarShowed()) { - m_pMonthCal->GetWidgetRect(rect); - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - } - return FWL_WGTHITTEST_Unknown; -} -FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() { - FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || - m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || - 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) { - 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) { - 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)); - if (!pWidth) - return 0; - m_fBtn = *pWidth; - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); - CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, - rtMonthCal.width, rtMonthCal.height); - m_pMonthCal->SetWidgetRect(rtPopUp); - m_pMonthCal->Update(); - return FWL_ERR_Succeeded; -} -FWL_ERR 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; -} -FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) { - rect = m_pProperties->m_rtWidget; - if (DisForm_IsNeedShowButton()) { - rect.width += m_fBtn; - } - if (IsMonthCalendarShowed()) { - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth); - rtMonth.Offset(m_pProperties->m_rtWidget.left, - m_pProperties->m_rtWidget.top); - rect.Union(rtMonth); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (m_pEdit) { - CFX_RectF rtEdit; - m_pEdit->GetWidgetRect(rtEdit); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); - if (pMatrix) { - mt.Concat(*pMatrix); - } - m_pEdit->DrawWidget(pGraphics, &mt); - } - if (IsMonthCalendarShowed()) { - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); - if (pMatrix) { - mt.Concat(*pMatrix); - } - m_pMonthCal->DrawWidget(pGraphics, &mt); - } - return FWL_ERR_Succeeded; -} -CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( - CFWL_DateTimePickerImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( - CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMouse->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMouse); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMouse); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMouse); - break; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMouse); - break; - } - default: {} - } - 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); -} -FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget( - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOwner->DrawWidget(pGraphics, pMatrix); -} -void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (!pMsg) - return; - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - return DisForm_OnFocusChanged(pMsg, bSet); - } - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } else { - m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() && - m_pOwner->IsMonthCalendarShowed()) { - m_pOwner->ShowMonthCalendar(FALSE); - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - if (!pMsg) - return; - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->SetFocus(TRUE); - } - if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (m_pOwner->IsMonthCalendarShowed()) { - m_pOwner->ShowMonthCalendar(FALSE); - CFWL_Event_DtpCloseUp ev; - m_pOwner->DispatchEvent(&ev); - } else { - if (!(m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_DTP_TimeFormat)) { - m_pOwner->ShowMonthCalendar(TRUE); - CFWL_Event_DtpDropDown ev; - m_pOwner->DispatchEvent(&ev); - } else { - } - m_pOwner->m_bLBtnDown = TRUE; - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - } -} -void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - if (!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; - } else { - m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_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->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->Repaint(&m_pOwner->m_rtBtn); -} -void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - CFX_RectF rtInvalidate(m_pOwner->m_rtBtn); - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if (m_pOwner->m_pEdit && - !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { - m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0, - m_pOwner->m_fBtn, - m_pOwner->m_pProperties->m_rtWidget.height - 1); - } - rtInvalidate = m_pOwner->m_rtBtn; - pMsg->m_pDstTarget = m_pOwner->m_pEdit.get(); - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMsg); - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - m_pOwner->m_rtBtn.Set(0, 0, 0, 0); - if (m_pOwner->DisForm_IsMonthCalendarShowed()) { - m_pOwner->ShowMonthCalendar(FALSE); - } - if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { - pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMsg); - } - } - rtInvalidate.Inflate(2, 2); - m_pOwner->Repaint(&rtInvalidate); -} diff --git a/xfa/src/fwl/basewidget/fwl_datetimepickerimp.h b/xfa/src/fwl/basewidget/fwl_datetimepickerimp.h deleted file mode 100644 index 4bc1063db5..0000000000 --- a/xfa/src/fwl/basewidget/fwl_datetimepickerimp.h +++ /dev/null @@ -1,235 +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_SRC_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ - -#include <memory> - -#include "xfa/include/fwl/core/fwl_form.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" -#include "xfa/src/fwl/basewidget/fwl_editimp.h" -#include "xfa/src/fwl/basewidget/fwl_monthcalendarimp.h" - -class CFWL_WidgetImp; -class CFWL_WidgetImpProperties; -class CFWL_WidgetImpDelegate; -class CFWL_DateTimeEdit; -class CFWL_DateTimeEditImpDelegate; -class CFWL_DateTimeCalendar; -class CFWL_DateTimeCalendarImpDelegate; -class CFWL_DateTimePickerImp; -class CFWL_DateTimePickerImpDelegate; - -class IFWL_DateTimeForm : public IFWL_Form { - public: - static IFWL_DateTimeForm* Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - - protected: - IFWL_DateTimeForm() {} -}; - -class IFWL_DateTimeCalender : public IFWL_MonthCalendar { - public: - static IFWL_DateTimeCalender* Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - - protected: - IFWL_DateTimeCalender() {} -}; - -class IFWL_DateTimeEdit : public IFWL_Edit { - public: - static IFWL_DateTimeEdit* Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - - protected: - IFWL_DateTimeEdit() {} -}; - -class CFWL_DateTimeEdit : public CFWL_EditImp { - public: - CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - friend class CFWL_DateTimeEditImpDelegate; -}; -class CFWL_DateTimeEditImpDelegate : public CFWL_EditImpDelegate { - public: - CFWL_DateTimeEditImpDelegate(CFWL_DateTimeEdit* pOwner); - int32_t OnProcessMessage(CFWL_Message* pMessage) override; - - private: - int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage); - - protected: - CFWL_DateTimeEdit* m_pOwner; -}; -class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp { - public: - CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - friend class CFWL_DateTimeCalendarImpDelegate; -}; -class CFWL_DateTimeCalendarImpDelegate : public CFWL_MonthCalendarImpDelegate { - public: - CFWL_DateTimeCalendarImpDelegate(CFWL_DateTimeCalendar* pOwner); - int32_t 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_OnLButtonUpEx(CFWL_MsgMouse* pMsg); - - protected: - CFWL_DateTimeCalendar* m_pOwner; - FX_BOOL m_bFlag; -}; -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 FX_DWORD 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 FX_DWORD 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; - - 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(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved); - - public: - IFWL_DateTimeEdit* GetDataTimeEdit(); - - protected: - void DrawDropDownButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void FormatDateString(int32_t iYear, - int32_t iMonth, - int32_t iDay, - CFX_WideString& wsText); - void ShowMonthCalendar(FX_BOOL bActivate); - FX_BOOL IsMonthCalendarShowed(); - void ReSetEditAlignment(); - void InitProxyForm(); - void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); - - private: - FWL_ERR DisForm_Initialize(); - void DisForm_InitDateTimeCalendar(); - void DisForm_InitDateTimeEdit(); - FX_BOOL DisForm_IsMonthCalendarShowed(); - void DisForm_ShowMonthCalendar(FX_BOOL bActivate); - FX_DWORD 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); - - protected: - CFX_RectF m_rtBtn; - CFX_RectF m_rtClient; - int32_t m_iBtnState; - int32_t m_iYear; - int32_t m_iMonth; - int32_t m_iDay; - FX_BOOL m_bLBtnDown; - std::unique_ptr<IFWL_DateTimeEdit> m_pEdit; - std::unique_ptr<IFWL_DateTimeCalender> m_pMonthCal; - std::unique_ptr<IFWL_DateTimeForm> m_pForm; - FX_FLOAT m_fBtn; - class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP { - public: - CFWL_MonthCalendarImpDP() { - m_iCurYear = 2010; - m_iCurMonth = 3; - m_iCurDay = 29; - } - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - return FWL_ERR_Succeeded; - } - virtual int32_t GetCurDay(IFWL_Widget* pWidget) { return m_iCurDay; } - virtual int32_t GetCurMonth(IFWL_Widget* pWidget) { return m_iCurMonth; } - virtual int32_t GetCurYear(IFWL_Widget* pWidget) { return m_iCurYear; } - int32_t m_iCurDay; - int32_t m_iCurYear; - int32_t m_iCurMonth; - }; - - CFWL_MonthCalendarImpDP m_MonthCalendarDP; - friend class CFWL_DateTimeEditImpDelegate; - friend class CFWL_DateTimeCalendar; - friend class CFWL_DateTimeCalendarImpDelegate; - friend class CFWL_DateTimePickerImpDelegate; -}; -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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - - CFWL_DateTimePickerImp* m_pOwner; - - private: - void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_editimp.cpp b/xfa/src/fwl/basewidget/fwl_editimp.cpp deleted file mode 100644 index 662fa91ec1..0000000000 --- a/xfa/src/fwl/basewidget/fwl_editimp.cpp +++ /dev/null @@ -1,2152 +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/src/fwl/basewidget/fwl_editimp.h" - -#include <algorithm> -#include <vector> - -#include "xfa/include/fwl/basewidget/fwl_caret.h" -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/fde_render.h" -#include "xfa/src/fde/fde_renderdevice.h" -#include "xfa/src/fee/ifde_txtedtpage.h" -#include "xfa/src/fwl/basewidget/fwl_caretimp.h" -#include "xfa/src/fwl/basewidget/fwl_comboboximp.h" -#include "xfa/src/fwl/basewidget/fwl_scrollbarimp.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -// static -IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_Edit* pEdit = new IFWL_Edit; - CFWL_EditImp* pEditImpl = new CFWL_EditImp(properties, pOuter); - pEdit->SetImpl(pEditImpl); - pEditImpl->SetInterface(pEdit); - return pEdit; -} -// static -IFWL_Edit* IFWL_Edit::CreateComboEdit( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_Edit* pEdit = new IFWL_Edit; - CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); - pEdit->SetImpl(pComboEditImpl); - pComboEditImpl->SetInterface(pEdit); - return pEdit; -} -IFWL_Edit::IFWL_Edit() {} -FWL_ERR 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 { - return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); -} -FWL_ERR IFWL_Edit::ClearText() { - return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); -} -int32_t IFWL_Edit::GetCaretPos() const { - return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); -} -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) { - return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); -} -int32_t IFWL_Edit::CountSelRanges() { - return static_cast<CFWL_EditImp*>(GetImpl())->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() { - 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) { - return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); -} -FWL_ERR 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) { - return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); -} -FWL_ERR IFWL_Edit::DeleteSelections() { - return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); -} -FWL_ERR 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) { - return static_cast<CFWL_EditImp*>(GetImpl()) - ->Replace(nStart, nLen, wsReplace); -} -FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) { - return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); -} -FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { - return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); -} -FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { - return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); -} -FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { - return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); -} -FX_BOOL IFWL_Edit::Delete() { - return static_cast<CFWL_EditImp*>(GetImpl())->Delete(); -} -FX_BOOL IFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { - return static_cast<CFWL_EditImp*>(GetImpl())->Redo(bsRecord); -} -FX_BOOL IFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { - return static_cast<CFWL_EditImp*>(GetImpl())->Undo(bsRecord); -} -FX_BOOL IFWL_Edit::Undo() { - return static_cast<CFWL_EditImp*>(GetImpl())->Undo(); -} -FX_BOOL IFWL_Edit::Redo() { - return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); -} -FX_BOOL IFWL_Edit::CanUndo() { - return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); -} -FX_BOOL IFWL_Edit::CanRedo() { - return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); -} -FWL_ERR 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) { - return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); -} -FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { - return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); -} -FWL_ERR IFWL_Edit::SetBackColor(FX_DWORD dwColor) { - return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); -} -FWL_ERR 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) { - return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); -} -FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) { - return static_cast<CFWL_EditImp*>(GetImpl()) - ->GetSuggestWords(pointf, sSuggest); -} -FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - 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), - m_fVAlignOffset(0.0f), - m_fScrollOffsetX(0.0f), - m_fScrollOffsetY(0.0f), - m_pEdtEngine(NULL), - m_bLButtonDown(FALSE), - m_nSelStart(0), - m_nLimit(-1), - m_fSpaceAbove(0), - m_fSpaceBelow(0), - m_fFontSize(0), - m_bSetRange(FALSE), - m_iMin(-1), - m_iMax(0xFFFFFFF), - m_backColor(0), - m_updateBackColor(FALSE), - m_iCurRecord(-1), - m_iMaxRecord(128) { - m_rtClient.Reset(); - m_rtEngine.Reset(); - m_rtStatic.Reset(); -} -CFWL_EditImp::~CFWL_EditImp() { - if (m_pEdtEngine) { - m_pEdtEngine->Release(); - m_pEdtEngine = NULL; - } - ClearRecord(); -} -FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_Edit; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_EditImp::GetClassID() const { - return FWL_CLASSHASH_Edit; -} -FWL_ERR CFWL_EditImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - if (!m_pDelegate) { - m_pDelegate = new CFWL_EditImpDelegate(this); - } - InitCaret(); - if (!m_pEdtEngine) { - InitEngine(); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::Finalize() { - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - ShowCaret(FALSE); - } - if (m_pHorzScrollBar) { - m_pHorzScrollBar->Finalize(); - } - if (m_pVertScrollBar) { - m_pVertScrollBar->Finalize(); - } - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (m_pEdtEngine) { - int32_t iTextLen = m_pEdtEngine->GetTextLength(); - if (iTextLen > 0) { - CFX_WideString wsText; - m_pEdtEngine->GetText(wsText, 0); - CFX_SizeF sz = CalcTextSize( - wsText, m_pProperties->m_pThemeProvider, - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); - rect.Set(0, 0, sz.x, sz.y); - } - } - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - if (IsShowScrollBar(TRUE)) { - FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - rect.width += *pfWidth; - rect.width += FWL_EDIT_Margin; - } - if (IsShowScrollBar(FALSE)) { - FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - rect.height += *pfWidth; - rect.height += FWL_EDIT_Margin; - } - } - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetStates(FX_DWORD 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); -} -FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { - return CFWL_WidgetImp::SetWidgetRect(rect); -} -FWL_ERR CFWL_EditImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - Layout(); - if (m_rtClient.IsEmpty()) { - return FWL_ERR_Indefinite; - } - UpdateEditEngine(); - UpdateVAlignment(); - UpdateScroll(); - InitCaret(); - return FWL_ERR_Succeeded; -} -FX_DWORD 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 (IsShowScrollBar(FALSE)) { - CFX_RectF rect; - m_pHorzScrollBar->GetWidgetRect(rect); - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_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); - } -} -void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData, - int32_t nStart, - int32_t nCount, - FX_FLOAT fOffSetX, - FX_FLOAT fOffSetY) { - FX_FLOAT fStartX = 0.0f; - FX_FLOAT fEndX = 0.0f; - FX_FLOAT fY = 0.0f; - FX_FLOAT fStep = 0.0f; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - CFX_RectFArray rectArray; - CFX_RectF rectText; - const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); - FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * - txtEdtParams->fFontSize / 1000; - pPage->CalcRangeRectArray(nStart, nCount, rectArray); - for (int i = 0; i < rectArray.GetSize(); i++) { - rectText = rectArray.GetAt(i); - fY = rectText.top + fAsent + fOffSetY; - fStep = txtEdtParams->fFontSize / 16.0f; - fStartX = rectText.left + fOffSetX; - fEndX = fStartX + rectText.Width(); - AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); - } -} -int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { - return 0; -} -FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) { - int32_t nWordCount = 0; - int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); - if (nWordCount < 1) { - return FALSE; - } - CFX_WideString wsSpell; - GetText(wsSpell, nWordStart, nWordCount); - CFX_ByteString sLatinWord; - for (int i = 0; i < nWordCount; i++) { - if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { - break; - } - sLatinWord += (FX_CHAR)wsSpell[i]; - } - if (sLatinWord.IsEmpty()) { - return FALSE; - } - CFWL_EvtEdtCheckWord checkWordEvent; - checkWordEvent.m_pSrcTarget = m_pInterface; - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = TRUE; - DispatchEvent(&checkWordEvent); - if (checkWordEvent.bCheckWord) { - return FALSE; - } - CFWL_EvtEdtGetSuggestWords suggestWordsEvent; - suggestWordsEvent.m_pSrcTarget = m_pInterface; - suggestWordsEvent.bsWord = sLatinWord; - suggestWordsEvent.bsArraySuggestWords = sSuggest; - suggestWordsEvent.bSuggestWords = FALSE; - DispatchEvent(&checkWordEvent); - return suggestWordsEvent.bSuggestWords; -} -FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - int32_t nWordCount = 0; - int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); - if (nWordCount < 1) { - return FALSE; - } - CFX_WideString wsSpell; - GetText(wsSpell, nWordStart, nWordCount); - for (int i = 0; i < nWordCount; i++) { - if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { - nWordCount = i; - break; - } - } - int32_t nDestLen = bsReplace.GetLength(); - CFX_WideString wsDest; - FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); - for (int32_t i = 0; i < nDestLen; i++) { - pBuffer[i] = bsReplace[i]; - } - wsDest.ReleaseBuffer(nDestLen); - Replace(nWordStart, nWordCount, wsDest); - return TRUE; -} -void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - pGraphics->SaveGraphState(); - if (pMatrix) { - pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); - } - FX_ARGB cr = 0xFFFF0000; - CFX_Color crLine(cr); - CFWL_EvtEdtCheckWord checkWordEvent; - checkWordEvent.m_pSrcTarget = m_pInterface; - CFX_ByteString sLatinWord; - CFX_Path pathSpell; - pathSpell.Create(); - int32_t nStart = 0; - FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; - FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; - CFX_WideString wsSpell; - GetText(wsSpell); - int32_t nContentLen = wsSpell.GetLength(); - for (int i = 0; i < nContentLen; i++) { - if (FX_EDIT_ISLATINWORD(wsSpell[i])) { - if (sLatinWord.IsEmpty()) { - nStart = i; - } - sLatinWord += (FX_CHAR)wsSpell[i]; - } else { - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = TRUE; - DispatchEvent(&checkWordEvent); - if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { - AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, - fOffSetY); - } - sLatinWord.Empty(); - } - } - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = TRUE; - DispatchEvent(&checkWordEvent); - if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { - AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, - fOffSetY); - } - if (!pathSpell.IsEmpty()) { - CFX_RectF rtClip = m_rtEngine; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - pGraphics->SetClipRect(rtClip); - pGraphics->SetStrokeColor(&crLine); - pGraphics->SetLineWidth(0); - pGraphics->StrokePath(&pathSpell, NULL); - } - pGraphics->RestoreGraphState(); -} -FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - if (m_rtClient.IsEmpty()) { - return FWL_ERR_Indefinite; - } - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (!m_pWidgetMgr->IsFormDisabled()) { - DrawTextBk(pGraphics, pTheme, pMatrix); - } - if (m_pEdtEngine) { - DrawContent(pGraphics, pTheme, pMatrix); - } - if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && - !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { - DrawSpellCheck(pGraphics, pMatrix); - } - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_EDT_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_EDT_Edge, pTheme, pMatrix); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { - if (!pThemeProvider) - return FWL_ERR_Indefinite; - if (m_pHorzScrollBar) { - m_pHorzScrollBar->SetThemeProvider(pThemeProvider); - } - if (m_pVertScrollBar) { - m_pVertScrollBar->SetThemeProvider(pThemeProvider); - } - if (m_pCaret) { - m_pCaret->SetThemeProvider(pThemeProvider); - } - m_pProperties->m_pThemeProvider = pThemeProvider; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) { - m_pEdtEngine->SetText(wsText); - return FWL_ERR_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 { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - m_pEdtEngine->GetText(wsText, nStart, nCount); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::ClearText() { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - m_pEdtEngine->ClearText(); - return FWL_ERR_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) { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - m_pEdtEngine->AddSelRange(nStart, nCount); - return FWL_ERR_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() { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - m_pEdtEngine->ClearSelection(); - return FWL_ERR_Succeeded; -} -int32_t CFWL_EditImp::GetLimit() { - return m_nLimit; -} -FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) { - m_nLimit = nLimit; - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - m_pEdtEngine->SetLimit(nLimit); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { - if (!m_pEdtEngine) - return FWL_ERR_Indefinite; - m_pEdtEngine->SetAliasChar(wAlias); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLen) { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - return FWL_ERR_Indefinite; - } - m_pEdtEngine->Insert(nStart, lpText, nLen); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::DeleteSelections() { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - int32_t iCount = m_pEdtEngine->CountSelRanges(); - if (iCount > 0) { - m_pEdtEngine->Delete(-1); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - 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; -} -FWL_ERR 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; -} -FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - return FWL_ERR_Succeeded; - } - return FWL_ERR_Indefinite; -} -FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { - if (!m_pEdtEngine) - return FALSE; - int32_t nCount = m_pEdtEngine->CountSelRanges(); - if (nCount == 0) { - return FALSE; - } - wsCopy.Empty(); - 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(); - } - return TRUE; -} -FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { - if (!m_pEdtEngine) - return FALSE; - int32_t nCount = m_pEdtEngine->CountSelRanges(); - if (nCount == 0) { - return FALSE; - } - wsCut.Empty(); - 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(); - } - 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()); - if (iError < 0) { - ProcessInsertError(iError); - return FALSE; - } - return TRUE; -} -FX_BOOL CFWL_EditImp::Delete() { - if (!m_pEdtEngine) - return FALSE; - int32_t nCount = m_pEdtEngine->CountSelRanges(); - 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) { - 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) { - return TRUE; - } - return m_pEdtEngine->Undo(bsRecord); -} -FX_BOOL CFWL_EditImp::Undo() { - if (!CanUndo()) { - return FALSE; - } - CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; - return Undo(bsRecord); -} -FX_BOOL CFWL_EditImp::Redo() { - if (!CanRedo()) { - return FALSE; - } - CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; - return Redo(bsRecord); -} -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) { - if (!m_pEdtEngine) - return FWL_ERR_Succeeded; - FDE_LPTXTEDTPARAMS pParams = - (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams(); - pParams->fTabWidth = fTabWidth; - pParams->bTabEquidistant = bEquidistant; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { - m_pOuter = pOuter; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { - m_iMin = iMin; - m_iMax = iMax; - m_bSetRange = TRUE; - return FWL_ERR_Succeeded; -} -void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit, - int32_t nPage, - FX_BOOL bVisible) { - if (m_rtEngine.IsEmpty()) { - return; - } - if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - return; - } - FX_BOOL bRepaintContent = UpdateOffset(); - UpdateCaret(); - CFX_RectF rtInvalid; - rtInvalid.Set(0, 0, 0, 0); - FX_BOOL bRepaintScroll = FALSE; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { - IFWL_ScrollBar* pScroll = UpdateScroll(); - if (pScroll) { - pScroll->GetWidgetRect(rtInvalid); - bRepaintScroll = TRUE; - } - } - if (bRepaintContent || bRepaintScroll) { - if (bRepaintContent) { - rtInvalid.Union(m_rtEngine); - } - Repaint(&rtInvalid); - } -} -void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, - FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { - FX_DWORD dwStyleEx = m_pProperties->m_dwStyleExes; - 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; - CFX_RectF rtTemp; - GetClientRect(rtTemp); - FX_BOOL bHSelfAdaption = - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; - FX_BOOL bVSelfAdaption = - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; - FX_BOOL bNeedUpdate = FALSE; - if (bHSelfAdaption || bVSelfAdaption) { - CFWL_EvtEdtPreSelfAdaption evt; - evt.m_pSrcTarget = m_pInterface; - evt.bHSelfAdaption = TRUE; - evt.bVSelfAdaption = TRUE; - FX_FLOAT fWidth; - FX_FLOAT fHight; - fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width; - fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height; - evt.rtAfterChange.Set(0, 0, fWidth, fHight); - DispatchEvent(&evt); - if (!evt.bHSelfAdaption) { - ModifyStylesEx( - 0, FWL_STYLEEXT_EDT_HSelfAdaption | FWL_STYLEEXT_EDT_AutoHScroll); - } - if (!evt.bVSelfAdaption) { - ModifyStylesEx( - 0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll); - } - bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || - (bVSelfAdaption && !evt.bVSelfAdaption); - } - FX_FLOAT fContentWidth1 = fContentWidth; - FX_FLOAT fContentHeight1 = fContentHeight; - if (bNeedUpdate) { - UpdateEditParams(); - UpdateEditLayout(); - IFDE_TxtEdtPage* page1 = m_pEdtEngine->GetPage(0); - fContentWidth1 = page1->GetContentsBox().width; - fContentHeight1 = page1->GetContentsBox().height; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { - rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); - m_pProperties->m_rtWidget.width = fContentWidth1; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { - rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); - m_pProperties->m_rtWidget.height = fContentHeight1; - } - CFWL_EvtEdtTextChanged event; - event.m_pSrcTarget = m_pInterface; - event.nChangeType = ChangeInfo.nChangeType; - event.wsInsert = ChangeInfo.wsInsert; - event.wsDelete = ChangeInfo.wsDelete; - event.wsPrevText = ChangeInfo.wsPrevText; - DispatchEvent(&event); - LayoutScrollBar(); - Repaint(&rtTemp); -} -void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) { - CFX_RectF rtTemp; - GetClientRect(rtTemp); - Repaint(&rtTemp); -} -FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose) { - IFDE_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, - int32_t nPageIndex, - int32_t nPurpose) { - IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; - IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); - if (!pPage) - return FALSE; - pPage->UnloadPage(nullptr); - return TRUE; -} - -void CFWL_EditImp::On_AddDoRecord(IFDE_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, - CFX_WideString& wsText) { - IFWL_Widget* pDst = GetOuter(); - if (!pDst) { - pDst = m_pInterface; - } - CFWL_EvtEdtValidate event; - event.pDstWidget = pDst; - event.m_pSrcTarget = m_pInterface; - event.wsInsert = wsText; - event.bValidate = TRUE; - DispatchEvent(&event); - return event.bValidate; -} -FWL_ERR CFWL_EditImp::SetBackgroundColor(FX_DWORD color) { - m_backColor = color; - m_updateBackColor = TRUE; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { - m_wsFont = wsFont; - m_fFontSize = fSize; - return FWL_ERR_Succeeded; -} -void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { - m_fScrollOffsetY = fScrollOffset; -} -void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - 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_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly - ? FWL_PARTSTATE_EDT_ReadOnly - : FWL_PARTSTATE_EDT_Normal; - FX_DWORD dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); - if (dwStates) { - param.m_dwStates = FWL_PARTSTATE_EDT_Disable; - } - param.m_pGraphics = pGraphics; - param.m_matrix = *pMatrix; - param.m_rtPart = m_rtClient; - pTheme->DrawBackground(¶m); - if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { - return; - } - CFX_RectF rtScorll; - m_pHorzScrollBar->GetWidgetRect(rtScorll); - CFX_RectF rtStatic; - 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_rtPart = rtStatic; - pTheme->DrawBackground(¶m); -} -void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!m_pEdtEngine) - return; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - if (!pPage) - return; - pGraphics->SaveGraphState(); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { - pGraphics->SaveGraphState(); - } - CFX_RectF rtClip = m_rtEngine; - FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; - FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - FX_BOOL bShowSel = - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); - if (bShowSel) { - IFWL_Widget* pForm = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); - if (pForm) { - bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != - FWL_WGTSTATE_Deactivated; - } - } - int32_t nSelCount = m_pEdtEngine->CountSelRanges(); - if (bShowSel && nSelCount > 0) { - int32_t nPageCharStart = pPage->GetCharStart(); - int32_t nPageCharCount = pPage->GetCharCount(); - int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; - int32_t nCharCount; - int32_t nCharStart; - CFX_RectFArray rectArr; - int32_t i = 0; - for (i = 0; i < nSelCount; i++) { - nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart); - int32_t nCharEnd = nCharStart + nCharCount - 1; - if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { - continue; - } - int32_t nBgn = std::max(nCharStart, nPageCharStart); - int32_t nEnd = std::min(nCharEnd, nPageCharEnd); - pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, - rectArr); - } - int32_t nCount = rectArr.GetSize(); - CFX_Path path; - path.Create(); - for (i = 0; i < nCount; i++) { - rectArr[i].left += fOffSetX; - rectArr[i].top += fOffSetY; - path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width, - rectArr[i].height); - } - pGraphics->SetClipRect(rtClip); - CFWL_ThemeBackground param; - param.m_pGraphics = pGraphics; - param.m_matrix = *pMatrix; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_EDT_Background; - param.m_pPath = &path; - pTheme->DrawBackground(¶m); - } - 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; - pRenderDevice->SetClipRect(rtClip); - pRenderContext->StartRender(pRenderDevice, pPage, mt); - pRenderContext->DoRender(NULL); - pRenderContext->Release(); - pRenderDevice->Release(); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { - pGraphics->RestoreGraphState(); - CFX_Path path; - path.Create(); - int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1; - FX_FLOAT fStep = m_rtEngine.width / iLimit; - FX_FLOAT fLeft = m_rtEngine.left + 1; - for (int32_t i = 1; i < iLimit; i++) { - fLeft += fStep; - path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); - } - CFWL_ThemeBackground param; - param.m_pGraphics = pGraphics; - param.m_matrix = *pMatrix; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_EDT_CombTextLine; - param.m_pPath = &path; - pTheme->DrawBackground(¶m); - } - pGraphics->RestoreGraphState(); -} -void CFWL_EditImp::UpdateEditEngine() { - UpdateEditParams(); - UpdateEditLayout(); - if (m_nLimit > -1) { - m_pEdtEngine->SetLimit(m_nLimit); - } -} -void CFWL_EditImp::UpdateEditParams() { - FDE_TXTEDTPARAMS params; - params.nHorzScale = 100; - params.fPlateWidth = m_rtEngine.width; - params.fPlateHeight = m_rtEngine.height; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) { - params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) { - params.dwMode |= FDE_TEXTEDITMODE_Validate; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) { - params.dwMode |= FDE_TEXTEDITMODE_Password; - } - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { - case FWL_STYLEEXT_EDT_HNear: { - params.dwAlignment |= FDE_TEXTEDITALIGN_Left; - break; - } - case FWL_STYLEEXT_EDT_HCenter: { - params.dwAlignment |= FDE_TEXTEDITALIGN_Center; - break; - } - case FWL_STYLEEXT_EDT_HFar: { - params.dwAlignment |= FDE_TEXTEDITALIGN_Right; - break; - } - default: {} - } - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { - case FWL_STYLEEXT_EDT_Justified: { - params.dwAlignment |= FDE_TEXTEDITALIGN_Justified; - break; - } - case FWL_STYLEEXT_EDT_Distributed: { - params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed; - break; - } - default: { params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; } - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { - params.dwMode |= FDE_TEXTEDITMODE_MultiLines; - if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { - params.dwMode |= - FDE_TEXTEDITMODE_AutoLineWrap | FDE_TEXTEDITMODE_LimitArea_Horz; - } - if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0) { - params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Vert; - } else { - params.fPlateHeight = 0x00FFFFFF; - } - } else { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { - params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz; - } - } - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; - } - FX_FLOAT* pFontSize = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); - if (!pFontSize) - return; - m_fFontSize = *pFontSize; - FX_DWORD* pFontColor = - static_cast<FX_DWORD*>(GetThemeCapacity(FWL_WGTCAPACITY_TextColor)); - if (!pFontColor) - return; - params.dwFontColor = *pFontColor; - FX_FLOAT* pLineHeight = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_LineHeight)); - if (!pLineHeight) - return; - params.fLineSpace = *pLineHeight; - IFX_Font* pFont = - static_cast<IFX_Font*>(GetThemeCapacity(FWL_WGTCAPACITY_Font)); - if (!pFont) - return; - params.pFont = pFont; - params.fFontSize = m_fFontSize; - params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace); - if (params.nLineCount <= 0) { - params.nLineCount = 1; - } - params.fTabWidth = params.fFontSize * 1; - params.bTabEquidistant = TRUE; - params.wLineBreakChar = L'\n'; - params.nCharRotation = 0; - params.pEventSink = this; - m_pEdtEngine->SetEditParams(params); -} - -void CFWL_EditImp::UpdateEditLayout() { - if (m_pEdtEngine->GetTextLength() <= 0) - m_pEdtEngine->SetTextByStream(nullptr); - - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - if (pPage) - pPage->UnloadPage(nullptr); - - m_pEdtEngine->StartLayout(); - m_pEdtEngine->DoLayout(nullptr); - m_pEdtEngine->EndLayout(); - pPage = m_pEdtEngine->GetPage(0); - if (pPage) - pPage->LoadPage(nullptr, nullptr); -} - -FX_BOOL CFWL_EditImp::UpdateOffset() { - CFX_RectF rtCaret; - m_pEdtEngine->GetCaretRect(rtCaret); - FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; - FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; - rtCaret.Offset(fOffSetX, fOffSetY); - const CFX_RectF& rtEidt = m_rtEngine; - if (rtEidt.Contains(rtCaret)) { - 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; - } - } - if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) { - m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom(); - if (m_fScrollOffsetY < 0) { - m_fScrollOffsetY = 0; - } - } - 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_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar, - FX_FLOAT fPosChanged) { - if (pScrollBar == m_pHorzScrollBar.get()) { - m_fScrollOffsetX += fPosChanged; - } else { - m_fScrollOffsetY += fPosChanged; - } - return TRUE; -} -void CFWL_EditImp::UpdateVAlignment() { - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - if (!pPage) - return; - const CFX_RectF& rtFDE = pPage->GetContentsBox(); - FX_FLOAT fOffsetY = 0.0f; - FX_FLOAT fSpaceAbove = 0.0f; - FX_FLOAT fSpaceBelow = 0.0f; - CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( - GetThemeCapacity(FWL_WGTCAPACITY_SpaceAboveBelow)); - if (pSpace) { - fSpaceAbove = pSpace->x; - fSpaceBelow = pSpace->y; - } - if (fSpaceAbove < 0.1f) { - fSpaceAbove = 0; - } - if (fSpaceBelow < 0.1f) { - fSpaceBelow = 0; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) { - fOffsetY = (m_rtEngine.height - rtFDE.height) / 2; - if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2 && - fSpaceAbove < fSpaceBelow) { - return; - } - fOffsetY += (fSpaceAbove - fSpaceBelow) / 2; - } else if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) { - fOffsetY = (m_rtEngine.height - rtFDE.height); - fOffsetY -= fSpaceBelow; - } else { - fOffsetY += fSpaceAbove; - } - m_fVAlignOffset = fOffsetY; - if (m_fVAlignOffset < 0) { - m_fVAlignOffset = 0; - } -} -void CFWL_EditImp::UpdateCaret() { - CFX_RectF rtFDE; - m_pEdtEngine->GetCaretRect(rtFDE); - rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, - m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); - CFX_RectF rtCaret; - rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); - CFX_RectF temp = rtCaret; - CFX_RectF rtClient; - GetClientRect(rtClient); - rtCaret.Intersect(rtClient); - if (rtCaret.left > rtClient.right()) { - FX_FLOAT right = rtCaret.right(); - rtCaret.left = rtClient.right() - 1; - rtCaret.width = right - rtCaret.left; - } - FX_BOOL bIntersect = !rtCaret.IsEmpty(); - FX_BOOL bShow = TRUE; - FX_BOOL bShowWhole = FALSE; - if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || !bIntersect) { - bShow = FALSE; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption && - temp.right() > m_rtEngine.right()) { - bShowWhole = TRUE; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption && - temp.bottom() > m_rtEngine.bottom()) { - bShowWhole = TRUE; - } else { - bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect); - } - if (bShowWhole) { - rtCaret = temp; - } - ShowCaret(bShow, &rtCaret); -} -IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() { - FX_BOOL bShowHorz = - m_pHorzScrollBar && - ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); - FX_BOOL bShowVert = - m_pVertScrollBar && - ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); - if (!bShowHorz && !bShowVert) { - return NULL; - } - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - if (!pPage) - return NULL; - const CFX_RectF& rtFDE = pPage->GetContentsBox(); - IFWL_ScrollBar* pRepaint = NULL; - if (bShowHorz) { - CFX_RectF rtScroll; - m_pHorzScrollBar->GetWidgetRect(rtScroll); - if (rtScroll.width < rtFDE.width) { - m_pHorzScrollBar->LockUpdate(); - FX_FLOAT fRange = rtFDE.width - rtScroll.width; - m_pHorzScrollBar->SetRange(0.0f, fRange); - FX_FLOAT fPos = m_fScrollOffsetX; - if (fPos < 0.0f) { - fPos = 0.0f; - } - if (fPos > fRange) { - fPos = fRange; - } - m_pHorzScrollBar->SetPos(fPos); - m_pHorzScrollBar->SetTrackPos(fPos); - m_pHorzScrollBar->SetPageSize(rtScroll.width); - m_pHorzScrollBar->SetStepSize(rtScroll.width / 10); - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); - m_pHorzScrollBar->UnlockUpdate(); - m_pHorzScrollBar->Update(); - pRepaint = m_pHorzScrollBar.get(); - } else if ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { - m_pHorzScrollBar->LockUpdate(); - m_pHorzScrollBar->SetRange(0, -1); - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); - m_pHorzScrollBar->UnlockUpdate(); - m_pHorzScrollBar->Update(); - pRepaint = m_pHorzScrollBar.get(); - } - } - if (bShowVert) { - CFX_RectF rtScroll; - m_pVertScrollBar->GetWidgetRect(rtScroll); - if (rtScroll.height < rtFDE.height) { - m_pVertScrollBar->LockUpdate(); - FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace; - FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; - if (fRange < fStep) { - fRange = fStep; - } - m_pVertScrollBar->SetRange(0.0f, fRange); - FX_FLOAT fPos = m_fScrollOffsetY; - if (fPos < 0.0f) { - fPos = 0.0f; - } - if (fPos > fRange) { - fPos = fRange; - } - m_pVertScrollBar->SetPos(fPos); - m_pVertScrollBar->SetTrackPos(fPos); - m_pVertScrollBar->SetPageSize(rtScroll.height); - m_pVertScrollBar->SetStepSize(fStep); - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); - m_pVertScrollBar->UnlockUpdate(); - m_pVertScrollBar->Update(); - pRepaint = m_pVertScrollBar.get(); - } else if ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { - m_pVertScrollBar->LockUpdate(); - m_pVertScrollBar->SetRange(0, -1); - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); - m_pVertScrollBar->UnlockUpdate(); - m_pVertScrollBar->Update(); - pRepaint = m_pVertScrollBar.get(); - } - } - return pRepaint; -} -FX_BOOL CFWL_EditImp::IsShowScrollBar(FX_BOOL bVert) { - FX_BOOL bShow = - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) - ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == - FWL_WGTSTATE_Focused - : TRUE; - if (bVert) { - return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && - IsContentHeightOverflow(); - } - return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); -} -FX_BOOL CFWL_EditImp::IsContentHeightOverflow() { - if (!m_pEdtEngine) - return FALSE; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); - if (!pPage) - return FALSE; - return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; -} -int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) { - int32_t nCount = m_RecordArr.GetSize(); - if (m_iCurRecord == nCount - 1) { - if (nCount == m_iMaxRecord) { - m_RecordArr.RemoveAt(0); - m_iCurRecord--; - } - } else { - for (int32_t i = nCount - 1; i > m_iCurRecord; i--) { - m_RecordArr.RemoveAt(i); - } - } - m_RecordArr.Add(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)); - if (!pfWidth) - return; - FX_FLOAT fWidth = *pfWidth; - if (!m_pOuter) { - CFX_RectF* pUIMargin = - static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin)); - if (pUIMargin) { - m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } - } else if (m_pOuter->GetClassID() == FWL_CLASSHASH_DateTimePicker) { - CFWL_ThemePart part; - part.m_pWidget = m_pOuter; - CFX_RectF* pUIMargin = - static_cast<CFX_RectF*>(m_pOuter->GetThemeProvider()->GetCapacity( - &part, FWL_WGTCAPACITY_UIMargin)); - if (pUIMargin) { - m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } - } - FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); - FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); - if (bShowVertScrollbar) { - 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); - } else { - rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, - m_rtClient.height); - if (bShowHorzScrollbar) { - rtVertScr.height -= fWidth; - } - m_rtEngine.width -= fWidth; - } - m_pVertScrollBar->SetWidgetRect(rtVertScr); - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - m_pVertScrollBar->Update(); - } else if (m_pVertScrollBar) { - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (bShowHorzScrollbar) { - 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, - m_rtClient.width, fWidth); - } else { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, - m_rtClient.width, fWidth); - if (bShowVertScrollbar) { - rtHoriScr.width -= fWidth; - } - m_rtEngine.height -= fWidth; - } - m_pHorzScrollBar->SetWidgetRect(rtHoriScr); - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - m_pHorzScrollBar->Update(); - } else if (m_pHorzScrollBar) { - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } -} -void CFWL_EditImp::LayoutScrollBar() { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == - 0) { - return; - } - FX_FLOAT* pfWidth = NULL; - FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE); - FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE); - if (bShowVertScrollbar) { - if (!m_pVertScrollBar) { - pfWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(FWL_WGTCAPACITY_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); - } else { - rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, - m_rtClient.height); - if (bShowHorzScrollbar) { - rtVertScr.height -= fWidth; - } - } - m_pVertScrollBar->SetWidgetRect(rtVertScr); - m_pVertScrollBar->Update(); - } - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - } else if (m_pVertScrollBar) { - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (bShowHorzScrollbar) { - if (!m_pHorzScrollBar) { - if (!pfWidth) { - pfWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(FWL_WGTCAPACITY_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, - m_rtClient.width, fWidth); - } else { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, - m_rtClient.width, fWidth); - if (bShowVertScrollbar) { - rtHoriScr.width -= (fWidth); - } - } - m_pHorzScrollBar->SetWidgetRect(rtHoriScr); - m_pHorzScrollBar->Update(); - } - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - } else if (m_pHorzScrollBar) { - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (bShowVertScrollbar || bShowHorzScrollbar) { - UpdateScroll(); - } -} -void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) { - pt.x += -m_rtEngine.left + m_fScrollOffsetX; - pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY; -} -void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { - return; - } - CFWL_WidgetImpProperties prop; - prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; - prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; - prop.m_pParent = m_pInterface; - prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; - IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); - pScrollBar->Initialize(); - (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); -} -void CFWL_EditImp::InitEngine() { - if (m_pEdtEngine) { - return; - } - m_pEdtEngine = IFDE_TxtEdtEngine::Create(); -} -extern FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, - FX_BOOL bVisible, - const CFX_RectF* pRtAnchor); -void CFWL_EditImp::ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect) { - if (m_pCaret) { - m_pCaret->ShowCaret(bVisible); - if (bVisible && !pRect->IsEmpty()) { - m_pCaret->SetWidgetRect(*pRect); - } - Repaint(&m_rtEngine); - } else { - IFWL_Widget* pOuter = m_pInterface; - if (bVisible) { - pRect->Offset(m_pProperties->m_rtWidget.left, - m_pProperties->m_rtWidget.top); - } - while (pOuter->GetOuter()) { - pOuter = pOuter->GetOuter(); - if (bVisible) { - CFX_RectF rtOuter; - pOuter->GetWidgetRect(rtOuter); - pRect->Offset(rtOuter.left, rtOuter.top); - } - } - FWL_ShowCaret(pOuter, bVisible, pRect); - } -} -FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum) { - if (!m_pEdtEngine) { - return FALSE; - } - if (!m_bSetRange) { - return TRUE; - } - CFX_WideString wsOld, wsText; - m_pEdtEngine->GetText(wsText, 0); - if (wsText.IsEmpty()) { - if (cNum == L'0') { - return FALSE; - } - return TRUE; - } - int32_t caretPos = m_pEdtEngine->GetCaretPos(); - int32_t iSel = CountSelRanges(); - if (iSel == 0) { - if (cNum == L'0' && caretPos == 0) { - return FALSE; - } - int32_t nLen = wsText.GetLength(); - CFX_WideString l = wsText.Mid(0, caretPos); - CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); - CFX_WideString wsNew = l + cNum + r; - if (wsNew.GetInteger() <= m_iMax) { - return TRUE; - } - } else { - if (wsText.GetInteger() <= m_iMax) { - return TRUE; - } - } - return FALSE; -} -void CFWL_EditImp::InitCaret() { - if (!m_pCaret) { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { - CFWL_WidgetImpProperties prop; - m_pCaret.reset(IFWL_Caret::Create(prop, m_pInterface)); - m_pCaret->Initialize(); - m_pCaret->SetParent(m_pInterface); - m_pCaret->SetStates(m_pProperties->m_dwStates); - } - } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == - 0) { - m_pCaret.reset(); - } -} -void CFWL_EditImp::ClearRecord() { - m_iCurRecord = -1; - m_RecordArr.RemoveAll(); -} -void CFWL_EditImp::ProcessInsertError(int32_t iError) { - switch (iError) { - case -2: { - CFWL_EvtEdtTextFull textFullEvent; - textFullEvent.m_pSrcTarget = m_pInterface; - DispatchEvent(&textFullEvent); - break; - } - default: {} - } -} -CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { - DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); - break; - } - case FWL_MSGHASH_Deactivate: { - DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); - break; - } - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonDblClk: { - OnButtonDblClk(pMsg); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMsg); - break; - } - case FWL_MSGMOUSECMD_RButtonDown: { - DoButtonDown(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - FX_DWORD dwCmd = pKey->m_dwCmd; - if (dwCmd == FWL_MSGKEYCMD_KeyDown) { - OnKeyDown(pKey); - } else if (dwCmd == FWL_MSGKEYCMD_Char) { - OnChar(pKey); - } - break; - } - default: { iRet = 0; } - } - CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); - return iRet; -} -FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - if (!pEvent) - return FWL_ERR_Indefinite; - FX_DWORD dwHashCode = pEvent->GetClassID(); - if (dwHashCode != FWL_EVTHASH_Scroll) { - return FWL_ERR_Succeeded; - } - IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; - if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && - m_pOwner->m_pVertScrollBar) || - (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && - m_pOwner->m_pHorzScrollBar)) { - CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(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::DoActivate(CFWL_MsgActivate* pMsg) { - m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { - m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->SetFocus(TRUE); - } - if (!m_pOwner->m_pEdtEngine) { - m_pOwner->UpdateEditEngine(); - } - IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); - if (!pPage) - return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - m_pOwner->DeviceToEngine(pt); - FX_BOOL bBefore = TRUE; - int32_t nIndex = pPage->GetCharIndex(pt, bBefore); - if (nIndex < 0) { - nIndex = 0; - } - m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); -} -void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { - FX_DWORD dwStyleEx = m_pOwner->GetStylesEx(); - FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret; - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if (!m_pOwner->m_pEdtEngine) { - m_pOwner->UpdateEditEngine(); - } - m_pOwner->UpdateVAlignment(); - m_pOwner->UpdateOffset(); - m_pOwner->UpdateCaret(); - } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - m_pOwner->ShowCaret(FALSE); - if (m_pOwner->m_pEdtEngine && - (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { - int32_t nSel = m_pOwner->CountSelRanges(); - if (nSel > 0) { - m_pOwner->ClearSelections(); - bRepaint = TRUE; - } - m_pOwner->SetCaretPos(0); - m_pOwner->UpdateOffset(); - } - m_pOwner->ClearRecord(); - } - m_pOwner->LayoutScrollBar(); - if (bRepaint) { - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, - m_pOwner->m_pProperties->m_rtWidget.height); - m_pOwner->Repaint(&rtInvalidate); - } -} -void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - DoCursor(pMsg); - if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - return; - } - m_pOwner->m_bLButtonDown = TRUE; - m_pOwner->SetGrab(TRUE); - DoButtonDown(pMsg); - int32_t nIndex = m_pOwner->m_pEdtEngine->GetCaretPos(); - FX_BOOL bRepaint = FALSE; - int32_t iCount = m_pOwner->m_pEdtEngine->CountSelRanges(); - if (iCount > 0) { - m_pOwner->m_pEdtEngine->ClearSelection(); - bRepaint = TRUE; - } - FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; - if (bShift && m_pOwner->m_nSelStart != nIndex) { - int32_t iStart = std::min(m_pOwner->m_nSelStart, nIndex); - int32_t iEnd = std::max(m_pOwner->m_nSelStart, nIndex); - m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart); - bRepaint = TRUE; - } else { - m_pOwner->m_nSelStart = nIndex; - } - if (bRepaint) { - m_pOwner->Repaint(&m_pOwner->m_rtEngine); - } -} -void CFWL_EditImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - DoCursor(pMsg); - m_pOwner->m_bLButtonDown = FALSE; - m_pOwner->SetGrab(FALSE); -} -void CFWL_EditImpDelegate::OnButtonDblClk(CFWL_MsgMouse* pMsg) { - if (!m_pOwner->m_pEdtEngine) - return; - DoCursor(pMsg); - IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); - if (!pPage) - return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - m_pOwner->DeviceToEngine(pt); - int32_t nCount = 0; - int32_t nIndex = pPage->SelectWord(pt, nCount); - if (nIndex < 0) { - return; - } - m_pOwner->m_pEdtEngine->AddSelRange(nIndex, nCount); - m_pOwner->m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE); - m_pOwner->Repaint(&m_pOwner->m_rtEngine); -} -void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (!m_pOwner->m_pEdtEngine) - return; - DoCursor(pMsg); - if (m_pOwner->m_nSelStart == -1 || !m_pOwner->m_bLButtonDown) { - return; - } - IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0); - if (!pPage) - return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - m_pOwner->DeviceToEngine(pt); - FX_BOOL bBefore = TRUE; - int32_t nIndex = pPage->GetCharIndex(pt, bBefore); - m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); - nIndex = m_pOwner->m_pEdtEngine->GetCaretPos(); - m_pOwner->m_pEdtEngine->ClearSelection(); - if (nIndex != m_pOwner->m_nSelStart) { - int32_t nLen = m_pOwner->m_pEdtEngine->GetTextLength(); - if (m_pOwner->m_nSelStart >= nLen) { - m_pOwner->m_nSelStart = nLen; - } - m_pOwner->m_pEdtEngine->AddSelRange( - std::min(m_pOwner->m_nSelStart, nIndex), - FXSYS_abs(nIndex - m_pOwner->m_nSelStart)); - } -} -void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { - if (!m_pOwner->m_pEdtEngine) - return; - FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; - FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; - FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; - FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Left: { - MoveCaret = MC_Left; - break; - } - case FWL_VKEY_Right: { - MoveCaret = MC_Right; - break; - } - case FWL_VKEY_Up: { - MoveCaret = MC_Up; - break; - } - case FWL_VKEY_Down: { - MoveCaret = MC_Down; - break; - } - case FWL_VKEY_Home: { - if (bCtrl) { - MoveCaret = MC_Home; - } else { - MoveCaret = MC_LineStart; - } - break; - } - case FWL_VKEY_End: { - if (bCtrl) { - MoveCaret = MC_End; - } else { - MoveCaret = MC_LineEnd; - } - break; - } - case FWL_VKEY_Insert: { - break; - } - case FWL_VKEY_Delete: { - if ((m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_EDT_ReadOnly) || - (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - break; - } - int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos(); -#if (_FX_OS_ == _FX_MACOSX_) - m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE); -#else - m_pOwner->m_pEdtEngine->Delete(nCaret); -#endif - break; - } - case FWL_VKEY_F2: { - break; - } - case FWL_VKEY_Tab: { - m_pOwner->DispatchKeyEvent(pMsg); - break; - } - default: { -#if (_FX_OS_ == _FX_MACOSX_) - if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) { -#else - if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { -#endif - if (dwKeyCode == 0x43 || dwKeyCode == 0x63) { - m_pOwner->DoClipboard(1); - return; - } - if (dwKeyCode == 0x58 || dwKeyCode == 0x78) { - m_pOwner->DoClipboard(2); - return; - } - if (dwKeyCode == 0x56 || dwKeyCode == 0x76) { - m_pOwner->DoClipboard(3); - return; - } - } - } - } - if (MoveCaret != MC_MoveNone) { - m_pOwner->m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl); - } -} -void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey* pMsg) { - if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - return; - } - if (!m_pOwner->m_pEdtEngine) - return; - int32_t iError = 0; - FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; - int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos(); - switch (c) { - case FWL_VKEY_Back: { - m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE); - break; - } - case 0x0A: { - break; - } - case FWL_VKEY_Escape: { - break; - } - case FWL_VKEY_Tab: { - iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\t", 1); - break; - } - case FWL_VKEY_Return: { - if (m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_EDT_WantReturn) { - iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\n", 1); - } - break; - } - default: { - if (!m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) { - if (((pMsg->m_dwKeyCode < FWL_VKEY_0) && - (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) || - pMsg->m_dwKeyCode > FWL_VKEY_9) { - break; - } - if (!m_pOwner->ValidateNumberChar(c)) { - break; - } - } - } -#if (_FX_OS_ == _FX_MACOSX_) - if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) -#else - if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) -#endif - { - break; - } - iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1); - break; - } - } - if (iError < 0) { - m_pOwner->ProcessInsertError(iError); - } -} -FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, - FX_DWORD dwCode, - FX_FLOAT fPos) { - CFX_SizeF fs; - pScrollBar->GetRange(fs.x, fs.y); - FX_FLOAT iCurPos = pScrollBar->GetPos(); - FX_FLOAT fStep = pScrollBar->GetStepSize(); - switch (dwCode) { - case FWL_SCBCODE_Min: { - fPos = fs.x; - break; - } - case FWL_SCBCODE_Max: { - fPos = fs.y; - break; - } - case FWL_SCBCODE_StepBackward: { - fPos -= fStep; - if (fPos < fs.x + fStep / 2) { - fPos = fs.x; - } - break; - } - case FWL_SCBCODE_StepForward: { - fPos += fStep; - if (fPos > fs.y - fStep / 2) { - fPos = fs.y; - } - break; - } - case FWL_SCBCODE_PageBackward: { - fPos -= pScrollBar->GetPageSize(); - if (fPos < fs.x) { - fPos = fs.x; - } - break; - } - case FWL_SCBCODE_PageForward: { - fPos += pScrollBar->GetPageSize(); - if (fPos > fs.y) { - fPos = fs.y; - } - break; - } - case FWL_SCBCODE_Pos: - case FWL_SCBCODE_TrackPos: { - break; - } - case FWL_SCBCODE_EndScroll: { - return FALSE; - } - default: {} - } - if (iCurPos != fPos) { - pScrollBar->SetPos(fPos); - pScrollBar->SetTrackPos(fPos); - m_pOwner->UpdateOffset(pScrollBar, fPos - iCurPos); - if (m_pOwner->m_pEdtEngine) { - m_pOwner->UpdateCaret(); - } - CFX_RectF rect; - m_pOwner->GetWidgetRect(rect); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); - m_pOwner->Repaint(&rtInvalidate); - } - return TRUE; -} -void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} diff --git a/xfa/src/fwl/basewidget/fwl_editimp.h b/xfa/src/fwl/basewidget/fwl_editimp.h deleted file mode 100644 index 6e6b35c947..0000000000 --- a/xfa/src/fwl/basewidget/fwl_editimp.h +++ /dev/null @@ -1,208 +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_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ - -#include <memory> -#include <vector> - -#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" -#include "xfa/src/fee/ifde_txtedtengine.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class CFWL_WidgetImpDelegate; -class IFWL_Caret; -class CFWL_EditImp; -class CFWL_EditImpDelegate; - -class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { - public: - CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); - ~CFWL_EditImp() override; - - // CFWL_WidgetImp: - FWL_ERR GetClassName(CFX_WideString& wsClass) const override; - FX_DWORD 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; - FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy) override; - FWL_ERR SetStates(FX_DWORD 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; - - virtual FWL_ERR 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 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 int32_t CountSelRanges(); - virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - virtual FWL_ERR 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 FX_BOOL Copy(CFX_WideString& wsCopy); - virtual FX_BOOL Cut(CFX_WideString& wsCut); - virtual FX_BOOL Paste(const CFX_WideString& wsPaste); - virtual FX_BOOL Delete(); - virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord); - virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord); - virtual FX_BOOL Undo(); - 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, - 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, - int32_t nPageIndex, - int32_t nPurpose) override; - FX_BOOL On_PageUnload(IFDE_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(FX_DWORD color); - virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); - void SetScrollOffset(FX_FLOAT fScrollOffset); - FX_BOOL GetSuggestWords(CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest); - FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); - - protected: - void DrawTextBk(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawContent(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void UpdateEditEngine(); - void UpdateEditParams(); - void UpdateEditLayout(); - FX_BOOL UpdateOffset(); - FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); - void UpdateVAlignment(); - void UpdateCaret(); - IFWL_ScrollBar* UpdateScroll(); - void Layout(); - void LayoutScrollBar(); - void DeviceToEngine(CFX_PointF& pt); - void InitScrollBar(FX_BOOL bVert = TRUE); - void InitEngine(); - virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL); - FX_BOOL ValidateNumberChar(FX_WCHAR cNum); - void InitCaret(); - void ClearRecord(); - FX_BOOL IsShowScrollBar(FX_BOOL bVert); - FX_BOOL IsContentHeightOverflow(); - int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord); - void ProcessInsertError(int32_t iError); - - void DrawSpellCheck(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = NULL); - void AddSpellCheckObj(CFX_Path& PathData, - int32_t nStart, - int32_t nCount, - FX_FLOAT fOffSetX, - FX_FLOAT fOffSetY); - int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); - CFX_RectF m_rtClient; - CFX_RectF m_rtEngine; - CFX_RectF m_rtStatic; - FX_FLOAT m_fVAlignOffset; - FX_FLOAT m_fScrollOffsetX; - FX_FLOAT m_fScrollOffsetY; - IFDE_TxtEdtEngine* m_pEdtEngine; - FX_BOOL m_bLButtonDown; - int32_t m_nSelStart; - int32_t m_nLimit; - FX_FLOAT m_fSpaceAbove; - FX_FLOAT m_fSpaceBelow; - FX_FLOAT m_fFontSize; - FX_ARGB m_argbSel; - FX_BOOL m_bSetRange; - int32_t m_iMin; - int32_t m_iMax; - std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; - std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; - std::unique_ptr<IFWL_Caret> m_pCaret; - CFX_WideString m_wsCache; - friend class CFWL_TxtEdtEventSink; - friend class CFWL_EditImpDelegate; - FX_DWORD m_backColor; - FX_BOOL m_updateBackColor; - CFX_WideString m_wsFont; - CFX_ByteStringArray m_RecordArr; - int32_t m_iCurRecord; - int32_t m_iMaxRecord; -}; - -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; - - protected: - void DoActivate(CFWL_MsgActivate* pMsg); - void DoDeactivate(CFWL_MsgDeactivate* pMsg); - void DoButtonDown(CFWL_MsgMouse* pMsg); - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnButtonDblClk(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - void OnChar(CFWL_MsgKey* pMsg); - FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos); - void DoCursor(CFWL_MsgMouse* pMsg); - CFWL_EditImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_formproxyimp.cpp b/xfa/src/fwl/basewidget/fwl_formproxyimp.cpp deleted file mode 100644 index 3985f00b77..0000000000 --- a/xfa/src/fwl/basewidget/fwl_formproxyimp.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/src/fwl/basewidget/fwl_formproxyimp.h" - -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/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 { - wsClass = FWL_CLASS_FormProxy; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_FormProxyImp::GetClassID() const { - return FWL_CLASSHASH_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; - m_pDelegate = new CFWL_FormProxyImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_FormProxyImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_FormProxyImp::Update() { - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_FormProxyImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return FWL_ERR_Succeeded; -} -CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pOuter->SetDelegate(NULL); - return pDelegate->OnProcessMessage(pMessage); -} diff --git a/xfa/src/fwl/basewidget/fwl_formproxyimp.h b/xfa/src/fwl/basewidget/fwl_formproxyimp.h deleted file mode 100644 index 56ef05360c..0000000000 --- a/xfa/src/fwl/basewidget/fwl_formproxyimp.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_SRC_FWL_BASEWIDGET_FWL_FORMPROXYIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_FORMPROXYIMP_H_ - -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class CFWL_FormProxyImpDelegate; - -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 FX_DWORD 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); - - protected: - friend class CFWL_FormProxyImpDelegate; -}; -class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate { - public: - CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner); - int32_t OnProcessMessage(CFWL_Message* pMessage) override; - - protected: - CFWL_FormProxyImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_FORMPROXYIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_listboximp.cpp b/xfa/src/fwl/basewidget/fwl_listboximp.cpp deleted file mode 100644 index aac2d27bdf..0000000000 --- a/xfa/src/fwl/basewidget/fwl_listboximp.cpp +++ /dev/null @@ -1,1241 +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/src/fwl/basewidget/fwl_listboximp.h" - -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/basewidget/fwl_comboboximp.h" -#include "xfa/src/fwl/basewidget/fwl_scrollbarimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -#define FWL_LISTBOX_ItemTextMargin 2 - -// static -IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_ListBox* pListBox = new IFWL_ListBox; - CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter); - pListBox->SetImpl(pListBoxImpl); - pListBoxImpl->SetInterface(pListBox); - return pListBox; -} -// static -IFWL_ListBox* IFWL_ListBox::CreateComboList( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_ListBox* pListBox = new IFWL_ListBox; - CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter); - pListBox->SetImpl(pComboListImpl); - pComboListImpl->SetInterface(pListBox); - return pListBox; -} -IFWL_ListBox::IFWL_ListBox() {} -int32_t IFWL_ListBox::CountSelItems() { - return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); -} -FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { - return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(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) { - return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); -} -FWL_ERR 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) { - 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) - : CFWL_WidgetImp(properties, pOuter), - m_dwTTOStyles(0), - m_iTTOAligns(0), - m_hAnchor(NULL), - m_fScorllBarWidth(0), - m_bLButtonDown(FALSE), - m_pScrollBarTP(NULL) { - m_rtClient.Reset(); - m_rtConent.Reset(); - m_rtStatic.Reset(); -} -CFWL_ListBoxImp::~CFWL_ListBoxImp() {} -FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_ListBox; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_ListBoxImp::GetClassID() const { - return FWL_CLASSHASH_ListBox; -} -FWL_ERR CFWL_ListBoxImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_ListBoxImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBoxImp::Finalize() { - if (m_pVertScrollBar) { - m_pVertScrollBar->Finalize(); - } - if (m_pHorzScrollBar) { - m_pHorzScrollBar->Finalize(); - } - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_ListBoxImp::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(); - } - CFX_SizeF fs = CalcSize(TRUE); - rect.Set(0, 0, fs.x, fs.y); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBoxImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - m_iTTOAligns = FDE_TTOALIGNMENT_Center; - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { - case FWL_STYLEEXT_LTB_LeftAlign: { - m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; - break; - } - case FWL_STYLEEXT_LTB_RightAlign: { - m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; - break; - } - case FWL_STYLEEXT_LTB_CenterAlign: - default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } - } - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { - m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } - m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; - m_fScorllBarWidth = GetScrollWidth(); - SortItem(); - CalcSize(); - return FWL_ERR_Succeeded; -} -FX_DWORD 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 (IsShowScrollBar(TRUE)) { - CFX_RectF rect; - m_pVertScrollBar->GetWidgetRect(rect); - if (rect.Contains(fx, fy)) { - return FWL_WGTHITTEST_VScrollBar; - } - } - if (m_rtClient.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - return FWL_WGTHITTEST_Unknown; -} -FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - pGraphics->SaveGraphState(); - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_LTB_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_LTB_Edge, pTheme, pMatrix); - } - CFX_RectF rtClip(m_rtConent); - if (IsShowScrollBar(FALSE)) { - rtClip.height -= m_fScorllBarWidth; - } - if (IsShowScrollBar(TRUE)) { - rtClip.width -= m_fScorllBarWidth; - } - if (pMatrix) { - pMatrix->TransformRect(rtClip); - } - pGraphics->SetClipRect(rtClip); - if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { - DrawBkground(pGraphics, pTheme, pMatrix); - } - DrawItems(pGraphics, pTheme, pMatrix); - pGraphics->RestoreGraphState(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { - if (!pThemeProvider) - return FWL_ERR_Indefinite; - if (!pThemeProvider->IsValidWidget(m_pInterface)) { - m_pScrollBarTP = pThemeProvider; - return FWL_ERR_Succeeded; - } - m_pProperties->m_pThemeProvider = pThemeProvider; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ListBoxImp::CountSelItems() { - if (!m_pProperties->m_pDataProvider) - return 0; - int32_t iRet = 0; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - continue; - } - FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); - if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { - iRet++; - } - } - return iRet; -} -FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { - if (!m_pProperties->m_pDataProvider) - return NULL; - int32_t index = 0; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - return NULL; - } - FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); - if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { - if (index == nIndexSel) { - return hItem; - } else { - index++; - } - } - } - return NULL; -} -int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { - if (!m_pProperties->m_pDataProvider) - return -1; - int32_t index = 0; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - return -1; - } - FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); - if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { - if (index == nIndex) { - return i; - } else { - index++; - } - } - } - return -1; -} -FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { - if (!m_pProperties->m_pDataProvider) - return FWL_ERR_Indefinite; - if (!hItem) { - if (bSelect) { - SelectAll(); - } else { - ClearSelection(); - SetFocusItem(NULL); - } - return FWL_ERR_Indefinite; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { - SetSelectionDirect(hItem, bSelect); - } else { - SetSelection(hItem, hItem, bSelect); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, - CFX_WideString& wsText) { - if (!m_pProperties->m_pDataProvider) - return FWL_ERR_Indefinite; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - if (!hItem) - return FWL_ERR_Indefinite; - pData->GetItemText(m_pInterface, hItem, wsText); - return FWL_ERR_Succeeded; -} -FWL_ERR 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_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; -} -FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, - FX_DWORD dwKeyCode) { - FWL_HLISTITEM hRet = NULL; - switch (dwKeyCode) { - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Home: - case FWL_VKEY_End: { - const bool bUp = dwKeyCode == FWL_VKEY_Up; - const bool bDown = dwKeyCode == FWL_VKEY_Down; - const bool bHome = dwKeyCode == FWL_VKEY_Home; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iDstItem = -1; - if (bUp || bDown) { - int32_t index = pData->GetItemIndex(m_pInterface, hItem); - iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; - } else if (bHome) { - iDstItem = 0; - } else { - int32_t iCount = pData->CountItems(m_pInterface); - iDstItem = iCount - 1; - } - hRet = pData->GetItem(m_pInterface, iDstItem); - break; - } - default: {} - } - return hRet; -} -void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, - FWL_HLISTITEM hEnd, - FX_BOOL bSelected) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iStart = pData->GetItemIndex(m_pInterface, hStart); - int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd); - if (iStart > iEnd) { - int32_t iTemp = iStart; - iStart = iEnd; - iEnd = iTemp; - } - if (bSelected) { - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - SetSelectionDirect(hItem, FALSE); - } - } - for (; iStart <= iEnd; iStart++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart); - SetSelectionDirect(hItem, bSelected); - } -} -void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FX_DWORD dwOldStyle = pData->GetItemStyles(m_pInterface, hItem); - bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected - : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; - pData->SetItemStyles(m_pInterface, hItem, dwOldStyle); -} -FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem); - return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; -} -void CFWL_ListBoxImp::ClearSelection() { - FX_BOOL bMulti = - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem); - FX_BOOL bFindSel = dwState & FWL_ITEMSTATE_LTB_Selected; - if (!bFindSel) { - continue; - } - SetSelectionDirect(hItem, FALSE); - if (!bMulti) { - return; - } - } -} -void CFWL_ListBoxImp::SelectAll() { - FX_BOOL bMulti = - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; - if (!bMulti) { - return; - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - if (iCount > 0) { - FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0); - FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1); - SetSelection(hItemStart, hItemEnd, FALSE); - } -} -FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem() { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) - return NULL; - if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) { - return hItem; - } - } - return NULL; -} -void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hFocus = GetFocusedItem(); - if (hItem != hFocus) { - if (hFocus) { - FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hFocus); - dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; - pData->SetItemStyles(m_pInterface, hFocus, dwStyle); - } - if (hItem) { - FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem); - dwStyle |= FWL_ITEMSTATE_LTB_Focused; - pData->SetItemStyles(m_pInterface, hItem, dwStyle); - } - } -} -FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - fx -= m_rtConent.left, fy -= m_rtConent.top; - FX_FLOAT fPosX = 0.0f; - if (m_pHorzScrollBar) { - fPosX = m_pHorzScrollBar->GetPos(); - } - FX_FLOAT fPosY = 0.0; - if (m_pVertScrollBar) { - fPosY = m_pVertScrollBar->GetPos(); - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t nCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < nCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - continue; - } - CFX_RectF rtItem; - pData->GetItemRect(m_pInterface, hItem, rtItem); - rtItem.Offset(-fPosX, -fPosY); - if (rtItem.Contains(fx, fy)) { - return hItem; - } - } - return NULL; -} -FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, - CFX_RectF& rtCheck) { - if (!m_pProperties->m_pDataProvider) - return FALSE; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { - return FALSE; - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->GetItemCheckRect(m_pInterface, hItem, rtCheck); - return TRUE; -} -FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) { - if (!m_pProperties->m_pDataProvider) - return FALSE; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { - return FALSE; - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - return (pData->GetItemCheckState(m_pInterface, hItem) & - FWL_ITEMSTATE_LTB_Checked); -} -FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) { - if (!m_pProperties->m_pDataProvider) - return FALSE; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { - return FALSE; - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemCheckState(m_pInterface, hItem, - bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); - return TRUE; -} -FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem) { - if (!m_pVertScrollBar) - return FALSE; - CFX_RectF rtItem; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->GetItemRect(m_pInterface, hItem, rtItem); - FX_BOOL bScroll = FALSE; - FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); - rtItem.Offset(0, -fPosY + m_rtConent.top); - if (rtItem.top < m_rtConent.top) { - fPosY += rtItem.top - m_rtConent.top; - bScroll = TRUE; - } else if (rtItem.bottom() > m_rtConent.bottom()) { - fPosY += rtItem.bottom() - m_rtConent.bottom(); - bScroll = TRUE; - } - if (!bScroll) { - return FALSE; - } - m_pVertScrollBar->SetPos(fPosY); - m_pVertScrollBar->SetTrackPos(fPosY); - Repaint(&m_rtClient); - return TRUE; -} -void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pTheme) - return; - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_LTB_Background; - param.m_dwStates = 0; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtClient; - if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) { - param.m_pData = &m_rtStatic; - } - if (!IsEnabled()) { - param.m_dwStates = FWL_PARTSTATE_LTB_Disabled; - } - pTheme->DrawBackground(¶m); -} -void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - FX_FLOAT fPosX = 0.0f; - if (m_pHorzScrollBar) { - fPosX = m_pHorzScrollBar->GetPos(); - } - FX_FLOAT fPosY = 0.0f; - if (m_pVertScrollBar) { - fPosY = m_pVertScrollBar->GetPos(); - } - CFX_RectF rtView(m_rtConent); - if (m_pHorzScrollBar) { - rtView.height -= m_fScorllBarWidth; - } - if (m_pVertScrollBar) { - rtView.width -= m_fScorllBarWidth; - } - FX_BOOL bMultiCol = - m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - continue; - } - CFX_RectF rtItem; - pData->GetItemRect(m_pInterface, hItem, rtItem); - rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); - if (rtItem.bottom() < m_rtConent.top) { - continue; - } - if (rtItem.top >= m_rtConent.bottom()) { - break; - } - if (bMultiCol && rtItem.left > m_rtConent.right()) { - break; - } - if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) { - CFWL_EvtLtbDrawItem ev; - ev.m_pSrcTarget = m_pInterface; - ev.m_pGraphics = pGraphics; - ev.m_matrix = *pMatrix; - ev.m_index = i; - ev.m_rect = rtItem; - DispatchEvent(&ev); - } else { - DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix); - } - } -} -void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FWL_HLISTITEM hItem, - int32_t Index, - const CFX_RectF& rtItem, - const CFX_Matrix* pMatrix) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FX_DWORD dwItemStyles = pData->GetItemStyles(m_pInterface, hItem); - FX_DWORD dwPartStates = FWL_PARTSTATE_LTB_Normal; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - dwPartStates = FWL_PARTSTATE_LTB_Disabled; - } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { - dwPartStates = FWL_PARTSTATE_LTB_Selected; - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && - dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { - dwPartStates |= FWL_PARTSTATE_LTB_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_dwStates = dwPartStates; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtItem; - param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); - CFX_RectF rtFocus(rtItem); - param.m_pData = &rtFocus; - if (m_pVertScrollBar && !m_pHorzScrollBar && - (dwPartStates & FWL_PARTSTATE_LTB_Focused)) { - param.m_rtPart.left += 1; - param.m_rtPart.width -= (m_fScorllBarWidth + 1); - rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); - } - pTheme->DrawBackground(¶m); - } - { - FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; - if (bHasIcon) { - CFX_RectF rtDIB; - CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem); - rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); - if (pDib) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_LTB_Icon; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtDIB; - param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); - param.m_pImage = pDib; - pTheme->DrawBackground(¶m); - } - } - FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check; - if (bHasCheck) { - CFX_RectF rtCheck; - rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); - rtCheck.Deflate(2, 2, 2, 2); - pData->SetItemCheckRect(m_pInterface, hItem, rtCheck); - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_LTB_Check; - param.m_pGraphics = pGraphics; - if (GetItemChecked(hItem)) { - param.m_dwStates = FWL_PARTSTATE_LTB_Checked; - } else { - param.m_dwStates = FWL_PARTSTATE_LTB_UnChecked; - } - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtCheck; - param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); - pTheme->DrawBackground(¶m); - } - CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); - if (wsText.GetLength() <= 0) { - return; - } - CFX_RectF rtText(rtItem); - rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); - 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_dwStates = dwPartStates; - textParam.m_pGraphics = pGraphics; - textParam.m_matrix.Concat(*pMatrix); - textParam.m_rtPart = rtText; - textParam.m_wsText = wsText; - textParam.m_dwTTOStyles = m_dwTTOStyles; - textParam.m_iTTOAlign = m_iTTOAligns; - textParam.m_dwData = (FX_DWORD)(uintptr_t)(&itemData); - pTheme->DrawText(&textParam); - } -} -CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { - CFX_SizeF fs; - if (!m_pProperties->m_pThemeProvider) - return fs; - - GetClientRect(m_rtClient); - m_rtConent = m_rtClient; - CFX_RectF rtUIMargin; - rtUIMargin.Set(0, 0, 0, 0); - if (!m_pOuter) { - CFX_RectF* pUIMargin = - static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin)); - if (pUIMargin) { - m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } - } - FX_FLOAT fWidth = 0; - if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - if (!bAutoSize) { - } - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - 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_pData = m_pProperties->m_pDataProvider; - itemPart.m_dwData = i; - CFX_RectF r; - m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); - if (!bAutoSize) { - CFX_RectF rtItem; - rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemRect(m_pInterface, hItem, rtItem); - } - fs.y += r.height; - if (fs.x < r.width) { - fs.x = r.width; - fWidth = r.width; - } - } - } else { - fWidth = GetMaxTextWidth(); - fWidth += 2 * FWL_LISTBOX_ItemTextMargin; - if (!bAutoSize) { - FX_FLOAT fActualWidth = - m_rtClient.width - rtUIMargin.left - rtUIMargin.width; - if (fWidth < fActualWidth) { - fWidth = fActualWidth; - } - } - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - m_fItemHeight = GetItemHeigt(); - FX_BOOL bHasIcon; - bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; - if (bHasIcon) { - fWidth += m_fItemHeight; - } - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i); - GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); - } - } - if (bAutoSize) { - return fs; - } - FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; - FX_FLOAT iHeight = m_rtClient.height; - FX_BOOL bShowVertScr = - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && - (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll); - FX_BOOL bShowHorzScr = - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && - (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll); - if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) { - bShowVertScr = (fs.y > iHeight); - } - if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) { - bShowHorzScr = (fs.x > iWidth); - } - CFX_SizeF szRange; - if (bShowVertScr) { - if (!m_pVertScrollBar) { - InitScrollBar(); - } - CFX_RectF rtScrollBar; - rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, - m_fScorllBarWidth, m_rtClient.height - 1); - if (bShowHorzScr) { - rtScrollBar.height -= m_fScorllBarWidth; - } - m_pVertScrollBar->SetWidgetRect(rtScrollBar); - szRange.x = 0, szRange.y = fs.y - m_rtConent.height; - if (szRange.y < m_fItemHeight) { - szRange.y = m_fItemHeight; - } - m_pVertScrollBar->SetRange(szRange.x, szRange.y); - m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); - m_pVertScrollBar->SetStepSize(m_fItemHeight); - FX_FLOAT fPos = m_pVertScrollBar->GetPos(); - if (fPos < 0) { - fPos = 0; - } - if (fPos > szRange.y) { - fPos = szRange.y; - } - m_pVertScrollBar->SetPos(fPos); - m_pVertScrollBar->SetTrackPos(fPos); - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == - 0 || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - } - m_pVertScrollBar->Update(); - } else if (m_pVertScrollBar) { - m_pVertScrollBar->SetPos(0); - m_pVertScrollBar->SetTrackPos(0); - m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (bShowHorzScr) { - if (!m_pHorzScrollBar) { - InitScrollBar(FALSE); - } - CFX_RectF rtScrollBar; - rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, - m_rtClient.width, m_fScorllBarWidth); - if (bShowVertScr) { - rtScrollBar.width -= m_fScorllBarWidth; - } - m_pHorzScrollBar->SetWidgetRect(rtScrollBar); - szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; - m_pHorzScrollBar->SetRange(szRange.x, szRange.y); - m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); - m_pHorzScrollBar->SetStepSize(fWidth / 10); - FX_FLOAT fPos = m_pHorzScrollBar->GetPos(); - if (fPos < 0) { - fPos = 0; - } - if (fPos > szRange.y) { - fPos = szRange.y; - } - m_pHorzScrollBar->SetPos(fPos); - m_pHorzScrollBar->SetTrackPos(fPos); - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == - 0 || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE); - } - m_pHorzScrollBar->Update(); - } else if (m_pHorzScrollBar) { - m_pHorzScrollBar->SetPos(0); - m_pHorzScrollBar->SetTrackPos(0); - m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (bShowVertScr && bShowHorzScr) { - m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, - m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, - m_fScorllBarWidth); - } - return fs; -} -void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, - FWL_HLISTITEM hItem, - FX_FLOAT fWidth, - FX_FLOAT m_fItemHeight, - FX_BOOL bAutoSize) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { - } else { - if (!bAutoSize) { - CFX_RectF rtItem; - rtItem.Set(0, size.y, fWidth, m_fItemHeight); - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemRect(m_pInterface, hItem, rtItem); - } - size.x = fWidth; - size.y += m_fItemHeight; - } -} -FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() { - FX_FLOAT fRet = 0.0f; - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(m_pInterface); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { - continue; - } - CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); - CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); - if (sz.x > fRet) { - fRet = sz.x; - } - } - return fRet; -} -FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() { - FX_FLOAT* pfWidth = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); - if (!pfWidth) - return 0; - return *pfWidth; -} -FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { - FX_FLOAT* pfFont = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); - if (!pfFont) - return 20; - return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin; -} -void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { - return; - } - CFWL_WidgetImpProperties prop; - prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; - prop.m_dwStates = FWL_WGTSTATE_Invisible; - prop.m_pParent = m_pInterface; - prop.m_pThemeProvider = m_pScrollBarTP; - IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); - 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(); - if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { - return FALSE; - } - return !(m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_LTB_ShowScrollBarFocus) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); -} -void CFWL_ListBoxImp::ProcessSelChanged() { - CFWL_EvtLtbSelChanged selEvent; - selEvent.m_pSrcTarget = m_pInterface; - CFX_Int32Array arrSels; - int32_t iCount = CountSelItems(); - for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM item = GetSelItem(i); - if (item == NULL) { - continue; - } - selEvent.iarraySels.Add(i); - } - DispatchEvent(&selEvent); -} -CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - if (!m_pOwner->IsEnabled()) { - return 1; - } - FX_DWORD dwMsgCode = pMessage->GetClassID(); - int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_MouseWheel: { - OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) - OnKeyDown(pMsg); - break; - } - default: { iRet = 0; } - } - CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); - return iRet; -} -FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - if (!pEvent) - return FWL_ERR_Indefinite; - if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) { - return FWL_ERR_Succeeded; - } - IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; - if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && - m_pOwner->m_pVertScrollBar) || - (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && - m_pOwner->m_pHorzScrollBar)) { - CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(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::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { - if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { - if (m_pOwner->m_pVertScrollBar) { - m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); - } - if (m_pOwner->m_pHorzScrollBar) { - m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); - } - } - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); - } else { - m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - m_pOwner->m_bLButtonDown = TRUE; - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->SetFocus(TRUE); - } - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (!hItem) { - return; - } - if (m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_LTB_MultiSelection) { - if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { - FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem); - m_pOwner->SetSelectionDirect(hItem, !bSelected); - m_pOwner->m_hAnchor = hItem; - } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { - if (m_pOwner->m_hAnchor) { - m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); - } else { - m_pOwner->SetSelectionDirect(hItem, TRUE); - } - } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - m_pOwner->m_hAnchor = hItem; - } - } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - } - if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { - FWL_HLISTITEM hSelectedItem = - m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - CFX_RectF rtCheck; - m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck); - FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem); - if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (bChecked) { - m_pOwner->SetItemChecked(hItem, FALSE); - } else { - m_pOwner->SetItemChecked(hItem, TRUE); - } - m_pOwner->Update(); - } - } - m_pOwner->SetFocusItem(hItem); - m_pOwner->ScrollToVisible(hItem); - m_pOwner->SetGrab(TRUE); - m_pOwner->ProcessSelChanged(); - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_bLButtonDown) { - m_pOwner->m_bLButtonDown = FALSE; - m_pOwner->SetGrab(FALSE); - DispatchSelChangedEv(); - } -} -void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) { - if (!m_pOwner->IsShowScrollBar(TRUE)) { - return; - } - IFWL_WidgetDelegate* pDelegate = - m_pOwner->m_pVertScrollBar->SetDelegate(NULL); - pDelegate->OnProcessMessage(pMsg); -} -void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { - FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Tab: - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Home: - case FWL_VKEY_End: { - FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem(); - hItem = m_pOwner->GetItem(hItem, dwKeyCode); - FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; - FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; - OnVK(hItem, bShift, bCtrl); - DispatchSelChangedEv(); - m_pOwner->ProcessSelChanged(); - break; - } - default: {} - } -} -void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, - FX_BOOL bShift, - FX_BOOL bCtrl) { - if (!hItem) { - return; - } - if (m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_LTB_MultiSelection) { - if (bCtrl) { - } else if (bShift) { - if (m_pOwner->m_hAnchor) { - m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); - } else { - m_pOwner->SetSelectionDirect(hItem, TRUE); - } - } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - m_pOwner->m_hAnchor = hItem; - } - } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - } - m_pOwner->SetFocusItem(hItem); - m_pOwner->ScrollToVisible(hItem); - { - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, - m_pOwner->m_pProperties->m_rtWidget.height); - m_pOwner->Repaint(&rtInvalidate); - } -} -FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, - FX_DWORD dwCode, - FX_FLOAT fPos) { - CFX_SizeF fs; - pScrollBar->GetRange(fs.x, fs.y); - FX_FLOAT iCurPos = pScrollBar->GetPos(); - FX_FLOAT fStep = pScrollBar->GetStepSize(); - switch (dwCode) { - case FWL_SCBCODE_Min: { - fPos = fs.x; - break; - } - case FWL_SCBCODE_Max: { - fPos = fs.y; - break; - } - case FWL_SCBCODE_StepBackward: { - fPos -= fStep; - if (fPos < fs.x + fStep / 2) { - fPos = fs.x; - } - break; - } - case FWL_SCBCODE_StepForward: { - fPos += fStep; - if (fPos > fs.y - fStep / 2) { - fPos = fs.y; - } - break; - } - case FWL_SCBCODE_PageBackward: { - fPos -= pScrollBar->GetPageSize(); - if (fPos < fs.x) { - fPos = fs.x; - } - break; - } - case FWL_SCBCODE_PageForward: { - fPos += pScrollBar->GetPageSize(); - if (fPos > fs.y) { - fPos = fs.y; - } - break; - } - case FWL_SCBCODE_Pos: - case FWL_SCBCODE_TrackPos: - break; - case FWL_SCBCODE_EndScroll: - return FALSE; - } - if (iCurPos != fPos) { - pScrollBar->SetPos(fPos); - pScrollBar->SetTrackPos(fPos); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - return TRUE; -} -void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { - CFWL_EvtLtbSelChanged ev; - ev.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&ev); -} diff --git a/xfa/src/fwl/basewidget/fwl_listboximp.h b/xfa/src/fwl/basewidget/fwl_listboximp.h deleted file mode 100644 index 614b76c495..0000000000 --- a/xfa/src/fwl/basewidget/fwl_listboximp.h +++ /dev/null @@ -1,121 +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_SRC_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ - -#include <memory> - -#include "xfa/include/fwl/basewidget/fwl_combobox.h" -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/basewidget/fwl_listbox.h" -#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_ListBoxImpDelegate; - -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 FX_DWORD 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 FX_DWORD 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); - - protected: - FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode); - void SetSelection(FWL_HLISTITEM hStart, - FWL_HLISTITEM hEnd, - FX_BOOL bSelected); - void SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect); - FX_BOOL IsItemSelected(FWL_HLISTITEM hItem); - void ClearSelection(); - void SelectAll(); - FWL_HLISTITEM GetFocusedItem(); - void SetFocusItem(FWL_HLISTITEM hItem); - FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); - FX_BOOL GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF& rtCheck); - FX_BOOL SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked); - FX_BOOL GetItemChecked(FWL_HLISTITEM hItem); - FX_BOOL ScrollToVisible(FWL_HLISTITEM hItem); - void DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawItems(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawItem(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FWL_HLISTITEM hItem, - int32_t Index, - const CFX_RectF& rtItem, - const CFX_Matrix* pMatrix = NULL); - void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); - CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); - void GetItemSize(CFX_SizeF& size, - FWL_HLISTITEM hItem, - FX_FLOAT fWidth, - FX_FLOAT fHeight, - FX_BOOL bAutoSize = FALSE); - FX_FLOAT GetMaxTextWidth(); - 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; - std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; - std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; - FX_DWORD m_dwTTOStyles; - int32_t m_iTTOAligns; - FWL_HLISTITEM m_hAnchor; - FX_FLOAT m_fItemHeight; - 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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - void OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl); - FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos); - void DispatchSelChangedEv(); - CFWL_ListBoxImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/src/fwl/basewidget/fwl_monthcalendarimp.cpp deleted file mode 100644 index 8bea9f1a11..0000000000 --- a/xfa/src/fwl/basewidget/fwl_monthcalendarimp.cpp +++ /dev/null @@ -1,1098 +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/src/fwl/basewidget/fwl_monthcalendarimp.h" - -#include <algorithm> - -#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -#define MONTHCAL_HSEP_HEIGHT 1 -#define MONTHCAL_VSEP_WIDTH 1 -#define MONTHCAL_HMARGIN 3 -#define MONTHCAL_VMARGIN 2 -#define MONTHCAL_ROWS 9 -#define MONTHCAL_COLUMNS 7 -#define MONTHCAL_HEADER_BTN_VMARGIN 7 -#define MONTHCAL_HEADER_BTN_HMARGIN 5 - -// static -IFWL_MonthCalendar* IFWL_MonthCalendar::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_MonthCalendar* pMonthCalendar = new IFWL_MonthCalendar; - CFWL_MonthCalendarImp* pMonthCalendarImpl = - new CFWL_MonthCalendarImp(properties, pOuter); - pMonthCalendar->SetImpl(pMonthCalendarImpl); - pMonthCalendarImpl->SetInterface(pMonthCalendar); - return pMonthCalendar; -} -IFWL_MonthCalendar::IFWL_MonthCalendar() {} -int32_t IFWL_MonthCalendar::CountSelect() { - return static_cast<CFWL_MonthCalendarImp*>(GetImpl())->CountSelect(); -} -FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear, - int32_t& iMonth, - int32_t& iDay, - int32_t nIndex) { - return static_cast<CFWL_MonthCalendarImp*>(GetImpl()) - ->GetSelect(iYear, iMonth, iDay, nIndex); -} -FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - return static_cast<CFWL_MonthCalendarImp*>(GetImpl()) - ->SetSelect(iYear, iMonth, iDay); -} - -CFWL_MonthCalendarImp::CFWL_MonthCalendarImp( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_iCurYear(2011), - m_iCurMonth(1), - m_iYear(2011), - m_iMonth(1), - m_iDay(1), - m_iHovered(-1), - m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal), - m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal) { - m_rtHead.Reset(); - m_rtWeek.Reset(); - m_rtLBtn.Reset(); - m_rtRBtn.Reset(); - m_rtDates.Reset(); - m_rtHSep.Reset(); - m_rtHeadText.Reset(); - m_rtToday.Reset(); - m_rtTodayFlag.Reset(); - m_rtClient.Reset(); - m_rtWeekNum.Reset(); - m_rtWeekNumSep.Reset(); - m_pDateTime = new CFX_DateTime; - 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 { - wsClass = FWL_CLASS_MonthCalendar; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_MonthCalendarImp::GetClassID() const { - return FWL_CLASSHASH_MonthCalendar; -} -FWL_ERR CFWL_MonthCalendarImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_MonthCalendarImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_MonthCalendarImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect, - FX_BOOL bAutoSize) { - if (bAutoSize) { - CFX_SizeF fs = CalcSize(TRUE); - rect.Set(0, 0, fs.x, fs.y); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_MonthCalendarImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - GetCapValue(); - if (!m_bInit) { - m_bInit = InitDate(); - } - ClearDateItem(); - ReSetDateItem(); - LayOut(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_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); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_MCD_Edge, pTheme, pMatrix); - } - DrawBkground(pGraphics, pTheme, pMatrix); - DrawHeadBK(pGraphics, pTheme, pMatrix); - DrawLButton(pGraphics, pTheme, pMatrix); - DrawRButton(pGraphics, pTheme, pMatrix); - DrawSeperator(pGraphics, pTheme, pMatrix); - DrawDatesInBK(pGraphics, pTheme, pMatrix); - DrawDatesInCircle(pGraphics, pTheme, pMatrix); - DrawCaption(pGraphics, pTheme, pMatrix); - DrawWeek(pGraphics, pTheme, pMatrix); - DrawDatesIn(pGraphics, pTheme, pMatrix); - DrawDatesOut(pGraphics, pTheme, pMatrix); - DrawToday(pGraphics, pTheme, pMatrix); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { - DrawWeekNumberSep(pGraphics, pTheme, pMatrix); - DrawWeekNumber(pGraphics, pTheme, pMatrix); - } - return FWL_ERR_Succeeded; -} -int32_t CFWL_MonthCalendarImp::CountSelect() { - return m_arrSelDays.GetSize(); -} -FX_BOOL CFWL_MonthCalendarImp::GetSelect(int32_t& iYear, - int32_t& iMonth, - int32_t& iDay, - int32_t nIndex) { - if (nIndex >= m_arrSelDays.GetSize()) { - return FALSE; - } - iYear = m_iCurYear; - iMonth = m_iCurMonth; - iDay = m_arrSelDays[nIndex]; - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::SetSelect(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - ChangeToMonth(iYear, iMonth); - return AddSelDay(iDay); -} -void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_Background; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_rtPart = m_rtClient; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_Header; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_rtPart = m_rtHead; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_LBtn; - params.m_pGraphics = pGraphics; - params.m_dwStates = m_iLBtnPartStates; - params.m_rtPart = m_rtLBtn; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_RBtn; - params.m_pGraphics = pGraphics; - params.m_dwStates = m_iRBtnPartStates; - params.m_rtPart = m_rtRBtn; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - 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_pGraphics = pGraphics; - int32_t iYear; - int32_t iMonth; - iYear = m_iCurYear; - iMonth = m_iCurMonth; - CFX_WideString wsCation; - GetHeadText(iYear, iMonth, wsCation); - textParam.m_wsText = wsCation; - m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider); - CalcHeadSize(); - textParam.m_rtPart = m_rtHeadText; - textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { - textParam.m_matrix.Concat(*pMatrix); - } - pTheme->DrawText(&textParam); -} -void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_HSeparator; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_rtPart = m_rtHSep; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_DateInBK; - params.m_pGraphics = pGraphics; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - int32_t iCount = m_arrDates.GetSize(); - 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; - if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) == - 0) && - pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { - params.m_dwStates |= FWL_PARTSTATE_MCD_Flagged; - } - if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) { - params.m_dwStates |= FWL_PARTSTATE_MCD_Focused; - } - } else if (j == m_iHovered - 1) { - params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered; - } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { - params.m_dwStates = FWL_PARTSTATE_MCD_Flagged; - pTheme->DrawBackground(¶ms); - } - params.m_rtPart = pDataInfo->rect; - pTheme->DrawBackground(¶ms); - params.m_dwStates = 0; - } -} -void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeText params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_Week; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - CFX_RectF rtDayOfWeek; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - 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(¶ms, i + FWL_MCCAPACITY_Sun)); - params.m_rtPart = rtDayOfWeek; - params.m_wsText = *wsWeekDay; - params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - pTheme->DrawText(¶ms); - } -} -void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeText params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_WeekNum; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; - CFX_WideString wsWeekNum; - params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - int32_t iWeekNum = 0; - int32_t iMonthNum = m_pDateTime->GetMonth(); - int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); - int32_t iTemp = 0; - FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei; - FX_FLOAT fHStartPos = m_rtClient.left; - for (int32_t i = 1; i <= iDayNum; i += 7) { - iTemp++; - iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i); - m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, - m_fWeekNumWid, m_fDateCellHei); - wsWeekNum.Format(L"%d", iWeekNum); - params.m_wsText = wsWeekNum; - params.m_rtPart = m_rtWeekNum; - pTheme->DrawText(¶ms); - } -} -void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_WeekNumSep; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_rtPart = m_rtWeekNumSep; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { - return; - } - CFWL_ThemeText params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_Today; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; - CFX_WideString* wsDay = static_cast<CFX_WideString*>( - pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today)); - CFX_WideString wsText; - GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); - params.m_wsText = *wsDay + wsText; - m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); - CalcTodaySize(); - params.m_rtPart = m_rtToday; - params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawText(¶ms); -} -void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeText params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_DatesIn; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - int32_t iCount = m_arrDates.GetSize(); - for (int32_t j = 0; j < iCount; j++) { - FWL_DATEINFO* pDataInfo = (FWL_DATEINFO*)m_arrDates.GetAt(j); - params.m_wsText = pDataInfo->wsDay; - params.m_rtPart = pDataInfo->rect; - params.m_dwStates = pDataInfo->dwStates; - if (j + 1 == m_iHovered) { - params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered; - } - params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - pTheme->DrawText(¶ms); - } -} -void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeText params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_DatesOut; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawText(¶ms); -} -void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { - return; - } - if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) { - return; - } - if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) { - return; - } - FWL_DATEINFO* pDate = (FWL_DATEINFO*)m_arrDates[m_iDay - 1]; - if (!pDate) - return; - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_DateInCircle; - params.m_pGraphics = pGraphics; - params.m_rtPart = pDate->rect; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { - return; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { - return; - } - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_MCD_TodayCircle; - params.m_pGraphics = pGraphics; - params.m_dwStates = FWL_PARTSTATE_MCD_Normal; - params.m_rtPart = m_rtTodayFlag; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶ms); -} -CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) { - if (!m_pProperties->m_pThemeProvider) - return CFX_SizeF(); - - if (!bAutoSize) { - GetClientRect(m_rtClient); - return CFX_SizeF(m_rtClient.width, m_rtClient.height); - } - - CFX_SizeF fs; - 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 (FX_DWORD week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) { - wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, week)); - CFX_SizeF sz = CalcTextSize(*wsText, 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++) { - CFX_WideString wsDay; - wsDay.Format(L"%d", day); - CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider); - fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x; - fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y; - } - m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5) - : (int)(fDayMaxW + 0.5)); - m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH; - fs.x = m_szCell.x * MONTHCAL_COLUMNS + - MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 + - MONTHCAL_HEADER_BTN_HMARGIN * 2; - FX_FLOAT fMonthMaxW = 0.0f; - FX_FLOAT fMonthMaxH = 0.0f; - for (FX_DWORD month = FWL_MCCAPACITY_January; - month <= FWL_MCCAPACITY_December; month++) { - wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, month)); - CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); - fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; - fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; - } - CFX_WideString wsYear; - GetHeadText(m_iYear, m_iMonth, wsYear); - CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); - fMonthMaxH = std::max(fMonthMaxH, szYear.y); - m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH); - fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2; - 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(¶ms, FWL_MCCAPACITY_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; - fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + - MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4; - return fs; -} - -void CFWL_MonthCalendarImp::CalcHeadSize() { - FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2; - FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2; - m_rtHeadText.Set(m_rtClient.left + fHeadHMargin, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + - MONTHCAL_VMARGIN + fHeadVMargin, - m_szHead.x, m_szHead.y); -} -void CFWL_MonthCalendarImp::CalcTodaySize() { - m_rtTodayFlag.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, - m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, - m_szCell.x, m_szToday.y); - m_rtToday.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + - MONTHCAL_HMARGIN * 2, - m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, - m_szToday.x, m_szToday.y); -} -void CFWL_MonthCalendarImp::LayOut() { - GetClientRect(m_rtClient); - { - m_rtHead.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); - m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtHead.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y + MONTHCAL_VMARGIN * 2); - m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - - MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtHSep.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, - m_rtWeek.bottom() - MONTHCAL_VMARGIN, - m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, - MONTHCAL_HSEP_HEIGHT); - m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtWeek.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y * (MONTHCAL_ROWS - 3) + - MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); - } - CalDateItem(); -} -void CFWL_MonthCalendarImp::CalDateItem() { - FX_BOOL bNewWeek = FALSE; - int32_t iWeekOfMonth = 0; - FX_FLOAT fLeft = m_rtDates.left; - FX_FLOAT fTop = m_rtDates.top; - int32_t iCount = m_arrDates.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(i); - if (bNewWeek) { - iWeekOfMonth++; - bNewWeek = FALSE; - } - pDateInfo->rect.Set( - fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), - fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), - m_szCell.x + (MONTHCAL_HMARGIN * 2), - m_szCell.y + (MONTHCAL_VMARGIN * 2)); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { - pDateInfo->rect.Offset(m_fWeekNumWid, 0); - } - if (pDateInfo->iDayOfWeek >= 6) { - bNewWeek = TRUE; - } - } -} -void CFWL_MonthCalendarImp::GetCapValue() { - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart part; - part.m_pWidget = m_pInterface; - m_fHeadWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_WIDTH)); - m_fHeadHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_Height)); - m_fHeadBtnWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH)); - m_fHeadBtnHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT)); - m_fHeadBtnHMargin = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN)); - m_fHeadBtnVMargin = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN)); - m_fHeadTextWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT)); - m_fHeadTextHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT)); - m_fHeadTextHMargin = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN)); - m_fHeadTextVMargin = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN)); - m_fHSepWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_WIDTH)); - m_fHSepHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_HEIGHT)); - m_fWeekNumWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH)); - m_fSepDOffset = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_DOFFSET)); - m_fSepX = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_X)); - m_fSepY = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_Y)); - m_fWeekNumHeigh = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT)); - m_fWeekWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_WIDTH)); - m_fWeekHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_HEIGHT)); - m_fDateCellWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH)); - m_fDateCellHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT)); - m_fTodayWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_WIDHT)); - m_fTodayHei = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_HEIGHT)); - m_fTodayFlagWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT)); - m_fMCWid = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_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)); -} -int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - return 0; -} -FX_BOOL CFWL_MonthCalendarImp::GetMinDate(int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) { - iYear = m_dtMin.iYear; - iMonth = m_dtMin.iMonth; - iDay = m_dtMin.iDay; - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::SetMinDate(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - m_dtMin = DATE(iYear, iMonth, iDay); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::GetMaxDate(int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) { - iYear = m_dtMax.iYear; - iMonth = m_dtMax.iMonth; - iDay = m_dtMax.iDay; - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::SetMaxDate(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - m_dtMax = DATE(iYear, iMonth, iDay); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::InitDate() { - if (m_pProperties->m_pDataProvider) { - IFWL_MonthCalendarDP* pDateProv = - static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); - m_iYear = pDateProv->GetCurYear(m_pInterface); - m_iMonth = pDateProv->GetCurMonth(m_pInterface); - m_iDay = pDateProv->GetCurDay(m_pInterface); - m_iCurYear = m_iYear; - m_iCurMonth = m_iMonth; - } else { - m_iDay = 1; - m_iMonth = 1; - m_iYear = 1; - m_iCurYear = m_iYear; - m_iCurMonth = m_iMonth; - } - GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); - GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); - m_dtMin = DATE(1500, 12, 1); - m_dtMax = DATE(2200, 1, 1); - return TRUE; -} -void CFWL_MonthCalendarImp::ClearDateItem() { - int32_t iCount = m_arrDates.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - FWL_DATEINFO* pData = (FWL_DATEINFO*)m_arrDates.GetAt(i); - delete pData; - } - m_arrDates.RemoveAll(); -} -void CFWL_MonthCalendarImp::ReSetDateItem() { - m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); - int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); - int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); - for (int32_t i = 0; i < iDays; i++) { - if (iDayOfWeek >= 7) { - iDayOfWeek = 0; - } - CFX_WideString wsDay; - wsDay.Format(L"%d", i + 1); - FX_DWORD dwStates = 0; - if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { - dwStates |= FWL_ITEMSTATE_MCD_Flag; - } - if (m_arrSelDays.Find(i + 1) != -1) { - dwStates |= FWL_ITEMSTATE_MCD_Selected; - } - CFX_RectF rtDate; - rtDate.Set(0, 0, 0, 0); - m_arrDates.Add( - new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); - iDayOfWeek++; - } -} -FX_BOOL CFWL_MonthCalendarImp::NextMonth() { - int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; - if (iMonth >= 12) { - iMonth = 1; - iYear++; - } else { - iMonth++; - } - DATE dt(m_iCurYear, m_iCurMonth, 1); - if (!(dt < m_dtMax)) { - return FALSE; - } - m_iCurYear = iYear, m_iCurMonth = iMonth; - ChangeToMonth(m_iCurYear, m_iCurMonth); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::PrevMonth() { - int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; - if (iMonth <= 1) { - iMonth = 12; - iYear--; - } else { - iMonth--; - } - DATE dt(m_iCurYear, m_iCurMonth, 1); - if (!(dt > m_dtMin)) { - return FALSE; - } - m_iCurYear = iYear, m_iCurMonth = iMonth; - ChangeToMonth(m_iCurYear, m_iCurMonth); - return TRUE; -} -void CFWL_MonthCalendarImp::ChangeToMonth(int32_t iYear, int32_t iMonth) { - m_iCurYear = iYear; - m_iCurMonth = iMonth; - m_iHovered = -1; - ClearDateItem(); - ReSetDateItem(); - CalDateItem(); - GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); -} -FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll) { - if (iDay == -1 && !bAll) { - return FALSE; - } - if (bAll) { - int32_t iCount = m_arrSelDays.GetSize(); - int32_t iDatesCount = m_arrDates.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - int32_t iSelDay = m_arrSelDays.GetAt(i); - if (iSelDay <= iDatesCount) { - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iSelDay - 1); - pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; - } - } - m_arrSelDays.RemoveAll(); - } else { - int32_t index = m_arrSelDays.Find(iDay); - if (index == -1) { - return FALSE; - } - int32_t iSelDay = m_arrSelDays.GetAt(iDay); - int32_t iDatesCount = m_arrDates.GetSize(); - if (iSelDay <= iDatesCount) { - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iSelDay - 1); - pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; - } - m_arrSelDays.RemoveAt(index); - } - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay) { - FXSYS_assert(iDay > 0); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { - } else { - if (m_arrSelDays.Find(iDay) == -1) { - RemoveSelDay(-1, TRUE); - if (iDay <= m_arrDates.GetSize()) { - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(iDay - 1); - pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; - } - m_arrSelDays.Add(iDay); - } - } - return TRUE; -} -FX_BOOL CFWL_MonthCalendarImp::JumpToToday() { - if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { - m_iCurYear = m_iYear; - m_iCurMonth = m_iMonth; - ChangeToMonth(m_iYear, m_iMonth); - AddSelDay(m_iDay); - } else { - if (m_arrSelDays.Find(m_iDay) == -1) { - AddSelDay(m_iDay); - } - } - return TRUE; -} -void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear, - int32_t iMonth, - CFX_WideString& wsHead) { - FXSYS_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", - L"September", L"October", L"November", L"December"}; - wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear); -} -void CFWL_MonthCalendarImp::GetTodayText(int32_t iYear, - int32_t iMonth, - int32_t iDay, - CFX_WideString& wsToday) { - wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear); -} -int32_t CFWL_MonthCalendarImp::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { - int32_t iCount = m_arrDates.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates.GetAt(i); - if (pDateInfo->rect.Contains(x, y)) { - return ++i; - } - } - return -1; -} -FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { - if (iDay <= 0 || iDay > m_arrDates.GetSize()) { - return FALSE; - } - FWL_DATEINFO* pDateInfo = (FWL_DATEINFO*)m_arrDates[iDay - 1]; - if (!pDateInfo) - return FALSE; - rtDay = pDateInfo->rect; - return TRUE; -} -CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( - CFWL_MonthCalendarImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( - CFWL_Message* pMessage) { - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Key: { - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMouse->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMouse); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMouse); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMouse); - break; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMouse); - 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::OnActivate(CFWL_Message* pMsg) {} - -void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -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->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->NextMonth(); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { - if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == - 0) { - m_pOwner->JumpToToday(); - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } - } else { - if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { - } else { - int32_t iOldSel = 0; - if (m_pOwner->m_arrSelDays.GetSize() > 0) { - iOldSel = m_pOwner->m_arrSelDays[0]; - } else { - return; - } - int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel; - if (bSelChanged) { - FWL_DATEINFO* lpDatesInfo = - (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iCurSel - 1); - CFX_RectF rtInvalidate(lpDatesInfo->rect); - if (iOldSel > 0) { - lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1); - rtInvalidate.Union(lpDatesInfo->rect); - } - m_pOwner->AddSelDay(iCurSel); - CFWL_EvtClick wmClick; - wmClick.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&wmClick); - CFWL_EventMcdDateChanged wmDateSelected; - wmDateSelected.m_iStartDay = iCurSel; - wmDateSelected.m_iEndDay = iCurSel; - wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth; - wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear; - wmDateSelected.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&wmDateSelected); - m_pOwner->Repaint(&rtInvalidate); - } - } - } -} -void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iLBtnPartStates = 0; - m_pOwner->Repaint(&m_pOwner->m_rtLBtn); - } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_iRBtnPartStates = 0; - m_pOwner->Repaint(&m_pOwner->m_rtRBtn); - } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { - int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - if (iDay != -1) { - m_pOwner->AddSelDay(iDay); - } - } -} -void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { - return; - } - FX_BOOL bRepaint = FALSE; - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, 0, 0); - if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { - int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - bRepaint = m_pOwner->m_iHovered != iHover; - if (bRepaint) { - if (m_pOwner->m_iHovered > 0) { - m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); - } - if (iHover > 0) { - CFX_RectF rtDay; - m_pOwner->GetDayRect(iHover, rtDay); - if (rtInvalidate.IsEmpty()) { - rtInvalidate = rtDay; - } else { - rtInvalidate.Union(rtDay); - } - } - } - m_pOwner->m_iHovered = iHover; - } else { - bRepaint = m_pOwner->m_iHovered > 0; - if (bRepaint) { - m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); - } - m_pOwner->m_iHovered = -1; - } - if (bRepaint && !rtInvalidate.IsEmpty()) { - m_pOwner->Repaint(&rtInvalidate); - } -} -void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_iHovered > 0) { - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, 0, 0); - m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); - m_pOwner->m_iHovered = -1; - if (!rtInvalidate.IsEmpty()) { - m_pOwner->Repaint(&rtInvalidate); - } - } -} diff --git a/xfa/src/fwl/basewidget/fwl_monthcalendarimp.h b/xfa/src/fwl/basewidget/fwl_monthcalendarimp.h deleted file mode 100644 index b2a21dc72a..0000000000 --- a/xfa/src/fwl/basewidget/fwl_monthcalendarimp.h +++ /dev/null @@ -1,243 +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_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ - -#include "xfa/src/fgas/localization/fgas_datetime.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_MonthCalendarImpDelegate; - -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 FX_DWORD 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); - - protected: - struct DATE { - DATE() : iYear(0), iMonth(0), iDay(0) {} - DATE(int32_t year, int32_t month, int32_t day) - : iYear(year), iMonth(month), iDay(day) {} - FX_BOOL operator<(const DATE& right) { - if (iYear < right.iYear) { - return TRUE; - } else if (iYear == right.iYear) { - if (iMonth < right.iMonth) { - return TRUE; - } else if (iMonth == right.iMonth) { - return iDay < right.iDay; - } - } - return FALSE; - } - FX_BOOL operator>(const DATE& right) { - if (iYear > right.iYear) { - return TRUE; - } else if (iYear == right.iYear) { - if (iMonth > right.iMonth) { - return TRUE; - } else if (iMonth == right.iMonth) { - return iDay > right.iDay; - } - } - return FALSE; - } - int32_t iYear; - int32_t iMonth; - int32_t iDay; - }; - - void DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawHeadBK(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawLButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawRButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawCaption(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawSeperator(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawDatesInBK(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawWeek(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawWeekNumber(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawWeekNumberSep(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawToday(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawDatesIn(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawDatesOut(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawDatesInCircle(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawTodayCircle(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); - void LayOut(); - void CalcHeadSize(); - void CalcTodaySize(); - void CalDateItem(); - void GetCapValue(); - int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay); - FX_BOOL GetMinDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); - FX_BOOL SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay); - FX_BOOL GetMaxDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); - FX_BOOL SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay); - FX_BOOL InitDate(); - void ClearDateItem(); - void ReSetDateItem(); - FX_BOOL NextMonth(); - FX_BOOL PrevMonth(); - void ChangeToMonth(int32_t iYear, int32_t iMonth); - FX_BOOL RemoveSelDay(int32_t iDay, FX_BOOL bAll = FALSE); - FX_BOOL AddSelDay(int32_t iDay); - FX_BOOL JumpToToday(); - void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); - void GetTodayText(int32_t iYear, - int32_t iMonth, - int32_t iDay, - CFX_WideString& wsToday); - int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); - FX_BOOL GetDayRect(int32_t iDay, CFX_RectF& rtDay); - - FX_BOOL m_bInit; - CFX_RectF m_rtHead; - CFX_RectF m_rtWeek; - CFX_RectF m_rtLBtn; - CFX_RectF m_rtRBtn; - CFX_RectF m_rtDates; - CFX_RectF m_rtHSep; - CFX_RectF m_rtHeadText; - CFX_RectF m_rtToday; - CFX_RectF m_rtTodayFlag; - CFX_RectF m_rtWeekNum; - CFX_RectF m_rtWeekNumSep; - CFX_RectF m_rtTemp; - CFX_WideString m_wsHead; - CFX_WideString m_wsToday; - CFX_DateTime* m_pDateTime; - CFX_PtrArray m_arrDates; - int32_t m_iCurYear; - int32_t m_iCurMonth; - int32_t m_iYear; - int32_t m_iMonth; - int32_t m_iDay; - int32_t m_iHovered; - int32_t m_iLBtnPartStates; - int32_t m_iRBtnPartStates; - DATE m_dtMin; - DATE m_dtMax; - CFX_SizeF m_szHead; - CFX_SizeF m_szCell; - CFX_SizeF m_szToday; - CFX_ArrayTemplate<int32_t> m_arrSelDays; - int32_t m_iMaxSel; - CFX_RectF m_rtClient; - FX_FLOAT m_fHeadWid; - FX_FLOAT m_fHeadHei; - FX_FLOAT m_fHeadBtnWid; - FX_FLOAT m_fHeadBtnHei; - FX_FLOAT m_fHeadBtnHMargin; - FX_FLOAT m_fHeadBtnVMargin; - FX_FLOAT m_fHeadTextWid; - FX_FLOAT m_fHeadTextHei; - FX_FLOAT m_fHeadTextHMargin; - FX_FLOAT m_fHeadTextVMargin; - FX_FLOAT m_fHSepWid; - FX_FLOAT m_fHSepHei; - FX_FLOAT m_fWeekNumWid; - FX_FLOAT m_fSepDOffset; - FX_FLOAT m_fSepX; - FX_FLOAT m_fSepY; - FX_FLOAT m_fWeekNumHeigh; - FX_FLOAT m_fWeekWid; - FX_FLOAT m_fWeekHei; - FX_FLOAT m_fDateCellWid; - FX_FLOAT m_fDateCellHei; - FX_FLOAT m_fTodayWid; - FX_FLOAT m_fTodayHei; - FX_FLOAT m_fTodayFlagWid; - FX_FLOAT m_fMCWid; - FX_FLOAT m_fMCHei; - friend class CFWL_MonthCalendarImpDelegate; -}; - -struct FWL_DATEINFO { - FWL_DATEINFO(int32_t day, - int32_t dayofweek, - FX_DWORD dwSt, - CFX_RectF rc, - CFX_WideString& wsday) - : iDay(day), - iDayOfWeek(dayofweek), - dwStates(dwSt), - rect(rc), - wsDay(wsday) {} - int32_t iDay; - int32_t iDayOfWeek; - FX_DWORD dwStates; - CFX_RectF rect; - CFX_WideString wsDay; -}; - -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; - - protected: - void OnActivate(CFWL_Message* pMsg); - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - CFWL_MonthCalendarImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_pictureboximp.cpp b/xfa/src/fwl/basewidget/fwl_pictureboximp.cpp deleted file mode 100644 index d0efaf3d2a..0000000000 --- a/xfa/src/fwl/basewidget/fwl_pictureboximp.cpp +++ /dev/null @@ -1,151 +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/src/fwl/basewidget/fwl_pictureboximp.h" - -#include "xfa/include/fwl/lightwidget/picturebox.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -// static -IFWL_PictureBox* IFWL_PictureBox::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_PictureBox* pPictureBox = new IFWL_PictureBox; - CFWL_PictureBoxImp* pPictureBoxImpl = - new CFWL_PictureBoxImp(properties, pOuter); - pPictureBox->SetImpl(pPictureBoxImpl); - pPictureBoxImpl->SetInterface(pPictureBox); - return pPictureBox; -} -IFWL_PictureBox::IFWL_PictureBox() {} - -CFWL_PictureBoxImp::CFWL_PictureBoxImp( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_bTop(FALSE), - m_bVCenter(FALSE), - m_bButton(FALSE) { - m_rtClient.Reset(); - m_rtImage.Reset(); - m_matrix.SetIdentity(); -} -CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {} -FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_PictureBox; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_PictureBoxImp::GetClassID() const { - return FWL_CLASSHASH_PictureBox; -} -FWL_ERR CFWL_PictureBoxImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_PictureBoxImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBoxImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR 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; - CFX_DIBitmap* pBitmap = - static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) - ->GetPicture(m_pInterface); - if (pBitmap) { - rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), - (FX_FLOAT)pBitmap->GetHeight()); - } - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBoxImp::Update() { - if (IsLocked()) { - return FWL_ERR_Succeeded; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - GetClientRect(m_rtClient); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_PTB_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_PTB_Edge, pTheme, pMatrix); - } - DrawBkground(pGraphics, pTheme, pMatrix); - return FWL_ERR_Succeeded; -} -void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - IFWL_PictureBoxDP* pPictureDP = - static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); - if (!pPictureDP) - return; - - CFX_DIBitmap* pPicture = pPictureDP->GetPicture(m_pInterface); - CFX_Matrix matrix; - pPictureDP->GetMatrix(m_pInterface, matrix); - if (!pPicture) - return; - - matrix.Concat(*pMatrix); - FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth(); - FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight(); - if (fx > m_rtClient.width) { - fx = m_rtClient.width; - } - if (fy > m_rtClient.height) { - fy = m_rtClient.height; - } - pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, - (m_rtClient.height - fy) / 2), - &matrix); -} -FX_BOOL CFWL_PictureBoxImp::VStyle(FX_BOOL dwStyle) { - switch (dwStyle & FWL_STYLEEXT_PTB_VAlignMask) { - case FWL_STYLEEXT_PTB_Top: { - return m_bTop = TRUE; - break; - } - case FWL_STYLEEXT_PTB_Vcenter: { - return m_bVCenter = TRUE; - break; - } - case FWL_STYLEEXT_PTB_Bottom: { - return m_bButton = TRUE; - break; - } - } - 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); -} diff --git a/xfa/src/fwl/basewidget/fwl_pictureboximp.h b/xfa/src/fwl/basewidget/fwl_pictureboximp.h deleted file mode 100644 index cfa50afb70..0000000000 --- a/xfa/src/fwl/basewidget/fwl_pictureboximp.h +++ /dev/null @@ -1,53 +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_SRC_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_ - -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_PictureBoxImpDelegate; - -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 FX_DWORD 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); - - protected: - 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; - CFX_Matrix m_matrix; - 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; - - protected: - CFWL_PictureBoxImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/src/fwl/basewidget/fwl_pushbuttonimp.cpp deleted file mode 100644 index 4ed0e3bfec..0000000000 --- a/xfa/src/fwl/basewidget/fwl_pushbuttonimp.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/src/fwl/basewidget/fwl_pushbuttonimp.h" - -#include "xfa/include/fwl/basewidget/fwl_pushbutton.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -// static -IFWL_PushButton* IFWL_PushButton::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_PushButton* pPushButton = new IFWL_PushButton; - CFWL_PushButtonImp* pPushButtonImpl = - new CFWL_PushButtonImp(properties, pOuter); - pPushButton->SetImpl(pPushButtonImpl); - pPushButtonImpl->SetInterface(pPushButton); - return pPushButton; -} -IFWL_PushButton::IFWL_PushButton() {} - -CFWL_PushButtonImp::CFWL_PushButtonImp( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_bBtnDown(FALSE), - m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), - m_iTTOAlign(FDE_TTOALIGNMENT_Center) { - 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 { - wsClass = FWL_CLASS_PushButton; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_PushButtonImp::GetClassID() const { - return FWL_CLASSHASH_PushButton; -} -FWL_ERR CFWL_PushButtonImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_PushButtonImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PushButtonImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (m_pProperties->m_pThemeProvider == NULL) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - CFX_WideString wsCaption; - IFWL_PushButtonDP* pData = - static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); - if (pData) { - pData->GetCaption(m_pInterface, wsCaption); - } - int32_t iLen = wsCaption.GetLength(); - if (iLen > 0) { - CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); - rect.Set(0, 0, sz.x, sz.y); - } - FX_FLOAT* fcaption = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); - rect.Inflate(*fcaption, *fcaption); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { - if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { - m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; - return FWL_ERR_Succeeded; - } - return CFWL_WidgetImp::SetStates(dwStates, bSet); -} -FWL_ERR CFWL_PushButtonImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - UpdateTextOutStyles(); - GetClientRect(m_rtClient); - m_rtCaption = m_rtClient; - FX_FLOAT* fcaption = - static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); - m_rtCaption.Inflate(-*fcaption, -*fcaption); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_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, - pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider, - pMatrix); - } - DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); - CFX_Matrix matrix; - matrix.Concat(*pMatrix); - FX_FLOAT iPicwidth = 0; - FX_FLOAT ipicheight = 0; - CFX_WideString wsCaption; - if (pData) { - pData->GetCaption(m_pInterface, wsCaption); - } - CFX_RectF rtText; - rtText.Set(0, 0, 0, 0); - if (!wsCaption.IsEmpty()) { - CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); - } - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { - case FWL_STYLEEXT_PSB_TextOnly: - DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); - break; - case FWL_STYLEEXT_PSB_IconOnly: - if (pData) { - pPicture = pData->GetPicture(m_pInterface); - } - if (pPicture) { - CFX_PointF point; - switch (m_iTTOAlign) { - case 0: { - point.x = m_rtClient.left; - point.y = m_rtClient.top; - break; - } - case 1: { - point.x = m_rtClient.left + - (m_rtClient.width / 2 - pPicture->GetWidth() / 2); - point.y = m_rtClient.top; - break; - } - case 2: - point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); - point.y = m_rtClient.top; - break; - case 4: - point.x = m_rtClient.left; - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - break; - case 5: - point.x = m_rtClient.left + - (m_rtClient.width / 2 - pPicture->GetWidth() / 2); - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - break; - case 6: - point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - break; - case 8: - point.x = m_rtClient.left; - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - break; - case 9: - point.x = m_rtClient.left + - (m_rtClient.width / 2 - pPicture->GetWidth() / 2); - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - break; - case 10: - point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - break; - } - pGraphics->DrawImage(pPicture, point, &matrix); - } - break; - case FWL_STYLEEXT_PSB_TextIcon: - if (pPicture) { - CFX_PointF point; - switch (m_iTTOAlign) { - case 0: { - point.x = m_rtClient.left; - point.y = m_rtClient.top; - iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); - ipicheight = - pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; - break; - } - case 1: { - point.x = - m_rtClient.left + (m_rtClient.width / 2 - - (pPicture->GetWidth() + rtText.width) / 2); - point.y = m_rtClient.top; - iPicwidth = pPicture->GetWidth() - - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + - rtText.width / 2 - 7; - ipicheight = - pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; - break; - } - case 2: - point.x = m_rtClient.left + m_rtClient.width - - pPicture->GetWidth() - rtText.width; - point.y = m_rtClient.top; - iPicwidth = m_rtClient.left + m_rtClient.width - point.x - - pPicture->GetWidth() - rtText.width + 7; - ipicheight = - pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; - break; - case 4: - point.x = m_rtClient.left; - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7; - break; - case 5: - point.x = - m_rtClient.left + (m_rtClient.width / 2 - - (pPicture->GetWidth() + rtText.width) / 2); - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - iPicwidth = pPicture->GetWidth() - - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + - rtText.width / 2 - 7; - break; - case 6: - point.x = m_rtClient.left + m_rtClient.width - - pPicture->GetWidth() - rtText.width; - point.y = m_rtClient.top + m_rtClient.height / 2 - - pPicture->GetHeight() / 2; - iPicwidth = m_rtClient.left + m_rtClient.width - point.x - - pPicture->GetWidth() - rtText.width + 7; - break; - case 8: - point.x = m_rtClient.left; - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); - ipicheight -= rtText.height / 2; - break; - case 9: - point.x = - m_rtClient.left + (m_rtClient.width / 2 - - (pPicture->GetWidth() + rtText.width) / 2); - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - iPicwidth = pPicture->GetWidth() - - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + - rtText.width / 2 - 7; - ipicheight -= rtText.height / 2; - break; - case 10: - point.x = m_rtClient.left + m_rtClient.width - - pPicture->GetWidth() - rtText.width; - point.y = - m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); - iPicwidth = m_rtClient.left + m_rtClient.width - point.x - - pPicture->GetWidth() - rtText.width + 7; - ipicheight -= rtText.height / 2; - break; - } - pGraphics->DrawImage(pPicture, point, &matrix); - } - matrix.e += m_rtClient.left + iPicwidth; - matrix.f += m_rtClient.top + ipicheight; - DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); - break; - } - return FWL_ERR_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_dwStates = GetPartStates(); - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - param.m_pData = &m_rtCaption; - } - pTheme->DrawBackground(¶m); -} -void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!m_pProperties->m_pDataProvider) - return; - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); - if (wsCaption.IsEmpty()) { - return; - } - CFWL_ThemeText param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_PSB_Caption; - param.m_dwStates = GetPartStates(); - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtCaption; - param.m_wsText = wsCaption; - param.m_dwTTOStyles = m_dwTTOStyles; - param.m_iTTOAlign = m_iTTOAlign; - pTheme->DrawText(¶m); -} -FX_DWORD CFWL_PushButtonImp::GetPartStates() { - FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - dwStates |= FWL_PARTSTATE_PSB_Focused; - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { - dwStates = FWL_PARTSTATE_PSB_Disabled; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { - dwStates |= FWL_PARTSTATE_PSB_Pressed; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { - dwStates |= FWL_PARTSTATE_PSB_Hovered; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { - dwStates |= FWL_PARTSTATE_PSB_Default; - } - return dwStates; -} -void CFWL_PushButtonImp::UpdateTextOutStyles() { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - switch (m_pProperties->m_dwStyleExes & - (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { - case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - break; - } - case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; - break; - } - case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: { - m_iTTOAlign = FDE_TTOALIGNMENT_TopRight; - break; - } - case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; - break; - } - case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - break; - } - case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; - break; - } - case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft; - break; - } - case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter; - break; - } - case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: { - m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; - break; - } - default: {} - } - m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { - m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } -} -CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( - CFWL_PushButtonImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - if (!m_pOwner->IsEnabled()) { - return 1; - } - int32_t iRet = 1; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD 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; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_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::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { - m_pOwner->SetFocus(TRUE); - } - m_pOwner->m_bBtnDown = TRUE; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - m_pOwner->m_bBtnDown = FALSE; - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; - } - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - CFWL_EvtClick wmClick; - wmClick.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&wmClick); - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - FX_BOOL bRepaint = FALSE; - if (m_pOwner->m_bBtnDown) { - if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; - bRepaint = TRUE; - } - if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; - bRepaint = TRUE; - } - } else { - if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; - bRepaint = TRUE; - } - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; - bRepaint = TRUE; - } - } - } else { - if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { - return; - } - if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { - m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; - bRepaint = TRUE; - } - } - if (bRepaint) { - m_pOwner->Repaint(&m_pOwner->m_rtClient); - } -} -void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { - m_pOwner->m_bBtnDown = FALSE; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; - m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -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; - m_pOwner->DispatchEvent(&wmMouse); - CFWL_EvtClick wmClick; - wmClick.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&wmClick); - return; - } - if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) { - return; - } - m_pOwner->DispatchKeyEvent(pMsg); -} diff --git a/xfa/src/fwl/basewidget/fwl_pushbuttonimp.h b/xfa/src/fwl/basewidget/fwl_pushbuttonimp.h deleted file mode 100644 index 5869074ba7..0000000000 --- a/xfa/src/fwl/basewidget/fwl_pushbuttonimp.h +++ /dev/null @@ -1,65 +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_SRC_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_ - -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_PushButtonImpDelegate; - -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 FX_DWORD 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(FX_DWORD dwStates, FX_BOOL bSet = TRUE); - virtual FWL_ERR Update(); - virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = NULL); - - 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); - FX_DWORD GetPartStates(); - void UpdateTextOutStyles(); - CFX_RectF m_rtClient; - CFX_RectF m_rtCaption; - FX_BOOL m_bBtnDown; - FX_DWORD 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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - CFWL_PushButtonImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/src/fwl/basewidget/fwl_scrollbarimp.cpp deleted file mode 100644 index c43ebbbc85..0000000000 --- a/xfa/src/fwl/basewidget/fwl_scrollbarimp.cpp +++ /dev/null @@ -1,805 +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/src/fwl/basewidget/fwl_scrollbarimp.h" - -#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -#define FWL_SCROLLBAR_Elapse 500 -#define FWL_SCROLLBAR_MinThumb 5 - -// static -IFWL_ScrollBar* IFWL_ScrollBar::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar; - CFWL_ScrollBarImp* pScrollBarImpl = new CFWL_ScrollBarImp(properties, pOuter); - pScrollBar->SetImpl(pScrollBarImpl); - pScrollBarImpl->SetInterface(pScrollBar); - return pScrollBar; -} -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) { - return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetRange(fMin, fMax); -} -FWL_ERR 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) { - 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) { - 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) { - 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) { - return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); -} -FX_BOOL IFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { - return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); -} -CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : CFWL_WidgetImp(properties, pOuter), - m_hTimer(nullptr), - m_fRangeMin(0), - m_fRangeMax(-1), - m_fPageSize(0), - 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_fLastTrackPos(0), - m_cpTrackPointX(0), - m_cpTrackPointY(0), - m_iMouseWheel(0), - m_bTrackMouseLeave(FALSE), - m_bMouseHover(FALSE), - m_bMouseDown(FALSE), - m_bRepaintThumb(FALSE), - m_fButtonLen(0), - m_bMinSize(FALSE), - m_bCustomLayout(FALSE), - m_fMinThumb(FWL_SCROLLBAR_MinThumb) { - m_rtClient.Reset(); - m_rtThumb.Reset(); - m_rtMinBtn.Reset(); - m_rtMaxBtn.Reset(); - m_rtMinTrack.Reset(); - m_rtMaxTrack.Reset(); -} -CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {} -FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_ScrollBar; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_ScrollBarImp::GetClassID() const { - return FWL_CLASSHASH_ScrollBar; -} -FWL_ERR CFWL_ScrollBarImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_ScrollBarImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ScrollBarImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR 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)); - if (!pfMinWidth) - return FWL_ERR_Indefinite; - if (IsVertical()) { - rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); - } else { - rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); - } - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ScrollBarImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - Layout(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (HasBorder()) { - DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_SCB_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; -} -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) { - fMin = m_fRangeMin; - fMax = m_fRangeMax; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { - m_fRangeMin = fMin; - m_fRangeMax = fMax; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ScrollBarImp::GetPageSize() { - return m_fPageSize; -} -FWL_ERR CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) { - m_fPageSize = fPageSize; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ScrollBarImp::GetStepSize() { - return m_fStepSize; -} -FWL_ERR CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) { - m_fStepSize = fStepSize; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ScrollBarImp::GetPos() { - return m_fPos; -} -FWL_ERR CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) { - m_fPos = fPos; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() { - return m_fTrackPos; -} -FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) { - m_fTrackPos = fTrackPos; - CalcThumbButtonRect(m_rtThumb); - CalcMinTrackRect(m_rtMinTrack); - CalcMaxTrackRect(m_rtMaxTrack); - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_ScrollBarImp::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { - switch (dwCode) { - case FWL_SCBCODE_Min: - case FWL_SCBCODE_Max: - case FWL_SCBCODE_PageBackward: - case FWL_SCBCODE_PageForward: - case FWL_SCBCODE_StepBackward: - break; - case FWL_SCBCODE_StepForward: - break; - case FWL_SCBCODE_Pos: - case FWL_SCBCODE_TrackPos: - case FWL_SCBCODE_EndScroll: - break; - default: { return FALSE; } - } - return OnScroll(dwCode, fPos); -} -int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - } - if (!SendEvent()) { - m_hTimer = FWL_StartTimer(this, 0); - } - return 1; -} -FWL_ERR CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { - m_pOuter = pOuter; - return FWL_ERR_Succeeded; -} -void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FX_BOOL bLower, - 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_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_SCB_Disabled - : (bLower ? m_iMinTrackState : m_iMaxTrackState); - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack; - pTheme->DrawBackground(¶m); -} -void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FX_BOOL bMinBtn, - 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_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_SCB_Disabled - : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState); - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; - if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { - pTheme->DrawBackground(¶m); - } -} -void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!IsEnabled()) { - } - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_SCB_Thumb; - param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_SCB_Disabled - : m_iThumbButtonState; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtThumb; - pTheme->DrawBackground(¶m); -} -void CFWL_ScrollBarImp::Layout() { - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart part; - part.m_pWidget = m_pInterface; - m_fMinThumb = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size)); - m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface); - GetClientRect(m_rtClient); - CalcButtonLen(); - CalcMinButtonRect(m_rtMinBtn); - CalcMaxButtonRect(m_rtMaxBtn); - CalcThumbButtonRect(m_rtThumb); - CalcMinTrackRect(m_rtMinTrack); - CalcMaxTrackRect(m_rtMaxTrack); -} -void CFWL_ScrollBarImp::CalcButtonLen() { - m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height; - FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width; - if (fLength < m_fButtonLen * 2) { - m_fButtonLen = fLength / 2; - m_bMinSize = TRUE; - } else { - m_bMinSize = FALSE; - } -} -void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF& rect) { - if (m_bCustomLayout) { - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart pPart; - pPart.m_rtPart = m_rtMinBtn; - pPart.m_pWidget = m_pInterface; - pPart.m_iPart = FWL_PART_SCB_ForeArrow; - pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_SCB_Disabled - : m_iMinButtonState; - pTheme->GetPartRect(&pPart, rect); - } else { - rect.left = m_rtClient.left; - rect.top = m_rtClient.top; - rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; - rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; - } -} -void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF& rect) { - if (m_bCustomLayout) { - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart pPart; - pPart.m_rtPart = m_rtMaxBtn; - pPart.m_pWidget = m_pInterface; - pPart.m_iPart = FWL_PART_SCB_BackArrow; - pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) - ? FWL_PARTSTATE_SCB_Disabled - : m_iMaxButtonState; - pTheme->GetPartRect(&pPart, rect); - } else { - rect.left = - IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen; - rect.top = - IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top; - rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; - rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; - } -} -void CFWL_ScrollBarImp::CalcThumbButtonRect(CFX_RectF& rect) { - if (!IsEnabled()) { - m_rtThumb.Reset(); - return; - } - if (m_bMinSize) { - m_rtThumb.Empty(); - return; - } - FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; - memset(&rect, 0, sizeof(CFX_Rect)); - if (fRange < 0) { - if (IsVertical()) { - rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0); - } else { - rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height); - } - return; - } - CFX_RectF rtClient = m_rtClient; - FX_FLOAT fLength = IsVertical() ? rtClient.height : rtClient.width; - FX_FLOAT fSize = m_fButtonLen; - if (m_bCustomLayout) { - if (IsVertical()) { - fLength = fLength - m_rtMinBtn.height - m_rtMaxBtn.height; - if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) { - fLength = 0.0f; - } - } else { - fLength = fLength - m_rtMinBtn.width - m_rtMaxBtn.width; - if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) { - fLength = 0.0f; - } - } - } else { - fLength -= fSize * 2.0f; - if (fLength < fSize) { - fLength = 0.0f; - } - } - FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength); - if (fThumbSize < m_fMinThumb) { - fThumbSize = m_fMinThumb; - } - FX_FLOAT fDiff = fLength - fThumbSize; - if (fDiff < 0.0f) { - fDiff = 0.0f; - } - FX_FLOAT fTrackPos = m_fTrackPos; - if (fTrackPos > m_fRangeMax) { - fTrackPos = m_fRangeMax; - } - if (fTrackPos < m_fRangeMin) { - fTrackPos = m_fRangeMin; - } - if (!fRange) - return; - if (m_bCustomLayout) { - FX_FLOAT iPos = fDiff * (fTrackPos - m_fRangeMin) / fRange; - rect.left = rtClient.left; - if (!IsVertical()) { - if ((m_rtMinBtn.right() == m_rtMaxBtn.left && m_rtMinBtn.width > 0 && - m_rtMaxBtn.width > 0) || - (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width)) { - rect.left += iPos; - } else { - rect.left += m_rtMinBtn.right() + iPos; - } - } - rect.top = rtClient.top; - if (IsVertical()) { - if ((m_rtMinBtn.bottom() == m_rtMaxBtn.top && m_rtMinBtn.height > 0 && - m_rtMaxBtn.height > 0) || - (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height)) { - rect.top += iPos; - } else { - rect.top += m_rtMinBtn.bottom() + iPos; - } - } - rect.width = IsVertical() ? rtClient.width : fThumbSize; - rect.height = IsVertical() ? fThumbSize : rtClient.height; - } else { - FX_FLOAT iPos = fSize + fDiff * (fTrackPos - m_fRangeMin) / fRange; - rect.left = rtClient.left; - if (!IsVertical()) { - rect.left += iPos; - } - rect.top = rtClient.top; - if (IsVertical()) { - rect.top += iPos; - } - rect.width = IsVertical() ? rtClient.width : fThumbSize; - rect.height = IsVertical() ? fThumbSize : rtClient.height; - } -} -void CFWL_ScrollBarImp::CalcMinTrackRect(CFX_RectF& rect) { - if (m_bMinSize) { - rect.Empty(); - return; - } - FX_FLOAT fBottom = m_rtThumb.bottom(); - FX_FLOAT fRight = m_rtThumb.right(); - FX_FLOAT ix = (m_rtThumb.left + fRight) / 2; - FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2; - rect.left = m_rtClient.left; - rect.top = m_rtClient.top; - FX_BOOL bVertical = IsVertical(); - rect.width = bVertical ? m_rtClient.width : ix; - rect.height = bVertical ? iy : m_rtClient.height; - if (m_bCustomLayout) { - if (bVertical) { - if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { - rect.top = m_rtClient.top; - } else if (m_rtMinBtn.top < m_rtThumb.top) { - rect.top = m_rtMinBtn.bottom(); - rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top); - } - } else { - if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { - rect.left = m_rtClient.left; - } else if (m_rtMinBtn.left < m_rtThumb.left) { - rect.left = m_rtMinBtn.right(); - rect.width -= (m_rtMinBtn.right() - m_rtClient.left); - } - } - } -} -void CFWL_ScrollBarImp::CalcMaxTrackRect(CFX_RectF& rect) { - if (m_bMinSize) { - rect.Empty(); - return; - } - FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; - FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; - FX_BOOL bVertical = IsVertical(); - rect.left = bVertical ? m_rtClient.left : ix; - rect.top = bVertical ? iy : m_rtClient.top; - rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix; - rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height; - if (m_bCustomLayout) { - if (bVertical) { - if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && - m_rtMaxBtn.height > 0) { - rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); - } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { - rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); - } - } else { - if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && - m_rtMaxBtn.width > 0) { - rect.width -= (m_rtClient.right() - m_rtMinBtn.left); - } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { - rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); - } - } - } -} -FX_FLOAT CFWL_ScrollBarImp::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { - FX_FLOAT fDiffX = fx - m_cpTrackPointX; - FX_FLOAT fDiffY = fy - m_cpTrackPointY; - FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; - FX_FLOAT fPos; - if (m_bCustomLayout) { - if (IsVertical()) { - if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { - fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height); - } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) { - fPos = fRange * fDiffY / - (m_rtMinBtn.top - m_rtClient.top - m_rtThumb.height); - } else { - fPos = fRange * fDiffY / - (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); - } - } else { - if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { - fPos = fRange * fDiffX / (m_rtClient.width - m_rtThumb.width); - } else if (m_rtMinBtn.right() == m_rtMaxBtn.left) { - fPos = fRange * fDiffX / - (m_rtMinBtn.left - m_rtClient.left - m_rtThumb.width); - } else { - fPos = fRange * fDiffX / - (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); - } - } - } else { - if (IsVertical()) { - fPos = fRange * fDiffY / - (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); - } else { - fPos = fRange * fDiffX / - (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); - } - } - fPos += m_fLastTrackPos; - if (fPos < m_fRangeMin) { - fPos = m_fRangeMin; - } - if (fPos > m_fRangeMax) { - fPos = m_fRangeMax; - } - return fPos; -} -void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) { - FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled; - if (bDisabled || m_bCustomLayout) { - rect = bLower ? m_rtMinTrack : m_rtMaxTrack; - } else { - FX_FLOAT fW = m_rtThumb.width / 2; - FX_FLOAT fH = m_rtThumb.height / 2; - FX_BOOL bVert = IsVertical(); - if (bLower) { - if (bVert) { - FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; - fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f; - rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height, - m_rtMinTrack.width, fMinTrackHeight); - } else { - FX_FLOAT fMinTrackWidth = - m_rtMinTrack.width - fW - m_rtMinBtn.width + 2; - fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f; - rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top, - fMinTrackWidth, m_rtMinTrack.height); - } - } else { - if (bVert) { - FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height; - fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f; - rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width, - fMaxTrackHeight); - } else { - FX_FLOAT fMaxTrackWidth = - m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; - fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; - rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, - m_rtMaxTrack.height); - } - } - } -} -FX_BOOL CFWL_ScrollBarImp::SendEvent() { - if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) { - DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos); - return FALSE; - } - if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) { - DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos); - return FALSE; - } - if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) { - DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos); - return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); - } - if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) { - DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); - return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); - } - if (m_iMouseWheel) { - FX_WORD dwCode = - m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; - DoScroll(dwCode, m_fTrackPos); - } - return TRUE; -} -FX_BOOL CFWL_ScrollBarImp::OnScroll(FX_DWORD dwCode, FX_FLOAT fPos) { - FX_BOOL bRet = TRUE; - CFWL_EvtScroll ev; - ev.m_iScrollCode = dwCode; - ev.m_pSrcTarget = m_pInterface; - ev.m_fPos = fPos; - ev.m_pRet = &bRet; - DispatchEvent(&ev); - return bRet; -} -CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - int32_t iRet = 1; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - if (dwMsgCode == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); - break; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(); - break; - } - default: { iRet = 0; } - } - } else if (dwMsgCode == FWL_MSGHASH_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::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pOwner->IsEnabled()) { - return; - } - m_pOwner->m_bMouseDown = TRUE; - m_pOwner->SetGrab(TRUE); - m_pOwner->m_cpTrackPointX = fx; - m_pOwner->m_cpTrackPointY = fy; - m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos; - if (m_pOwner->m_rtMinBtn.Contains(fx, fy)) { - DoMouseDown(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); - } else { - if (m_pOwner->m_rtThumb.Contains(fx, fy)) { - DoMouseDown(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, - fy); - } else { - if (m_pOwner->m_rtMaxBtn.Contains(fx, fy)) { - DoMouseDown(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, - fy); - } else { - if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) { - DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, - fy); - } else { - DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, - fy); - } - } - } - } - if (!m_pOwner->SendEvent()) { - m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); - } -} -void CFWL_ScrollBarImpDelegate::OnLButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - FWL_StopTimer(m_pOwner->m_hTimer); - m_pOwner->m_bMouseDown = FALSE; - DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); - DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); - DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); - DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); - DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); - m_pOwner->SetGrab(FALSE); -} -void CFWL_ScrollBarImpDelegate::OnMouseMove(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); - DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); - DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); - DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); - DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); -} -void CFWL_ScrollBarImpDelegate::OnMouseLeave() { - DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); - DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); - DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); - DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); - DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); -} -void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, - FX_FLOAT fy, - FX_DWORD dwFlags, - FX_FLOAT fDeltaX, - FX_FLOAT fDeltaY) { - m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; - m_pOwner->SendEvent(); - m_pOwner->m_iMouseWheel = 0; -} -void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!rtItem.Contains(fx, fy)) { - return; - } - if (iState == FWL_PARTSTATE_SCB_Pressed) { - return; - } - iState = FWL_PARTSTATE_SCB_Pressed; - m_pOwner->Repaint(&rtItem); -} -void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy) { - int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered - : FWL_PARTSTATE_SCB_Normal; - if (iState == iNewState) { - return; - } - iState = iNewState; - m_pOwner->Repaint(&rtItem); - m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos); -} -void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - 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; - if (iState == iNewState) { - return; - } - iState = iNewState; - m_pOwner->Repaint(&rtItem); - } else if ((2 == iItem) && - (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) { - FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy); - m_pOwner->m_fTrackPos = fPos; - m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos); - } -} -void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState) { - if (iState == FWL_PARTSTATE_SCB_Normal) { - return; - } - iState = FWL_PARTSTATE_SCB_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) { - return; - } - iState = FWL_PARTSTATE_SCB_Hovered; - m_pOwner->Repaint(&rtItem); -} diff --git a/xfa/src/fwl/basewidget/fwl_scrollbarimp.h b/xfa/src/fwl/basewidget/fwl_scrollbarimp.h deleted file mode 100644 index be1f25470e..0000000000 --- a/xfa/src/fwl/basewidget/fwl_scrollbarimp.h +++ /dev/null @@ -1,139 +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_SRC_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ - -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_ScrollBarImpDelegate; - -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 FX_DWORD 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(FX_DWORD dwCode, FX_FLOAT fPos = 0.0f); - virtual FWL_ERR SetOuter(IFWL_Widget* pOuter); - virtual int32_t Run(FWL_HTIMER hTimer); - - protected: - void DrawTrack(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FX_BOOL bLower = TRUE, - const CFX_Matrix* pMatrix = NULL); - void DrawArrowBtn(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - FX_BOOL bMinBtn = TRUE, - const CFX_Matrix* pMatrix = NULL); - void DrawThumb(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void Layout(); - void CalcButtonLen(); - void CalcMinButtonRect(CFX_RectF& rect); - void CalcMaxButtonRect(CFX_RectF& rect); - void CalcThumbButtonRect(CFX_RectF& rect); - void CalcMinTrackRect(CFX_RectF& rect); - void CalcMaxTrackRect(CFX_RectF& rect); - FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); - void GetTrackRect(CFX_RectF& rect, FX_BOOL bLower = TRUE); - FX_BOOL SendEvent(); - FX_BOOL OnScroll(FX_DWORD dwCode, FX_FLOAT fPos); - - FWL_HTIMER m_hTimer; - FX_FLOAT m_fRangeMin; - FX_FLOAT m_fRangeMax; - FX_FLOAT m_fPageSize; - FX_FLOAT m_fStepSize; - FX_FLOAT m_fPos; - FX_FLOAT m_fTrackPos; - int32_t m_iMinButtonState; - int32_t m_iMaxButtonState; - int32_t m_iThumbButtonState; - int32_t m_iMinTrackState; - int32_t m_iMaxTrackState; - FX_FLOAT m_fLastTrackPos; - FX_FLOAT m_cpTrackPointX; - FX_FLOAT m_cpTrackPointY; - int32_t m_iMouseWheel; - FX_BOOL m_bTrackMouseLeave; - FX_BOOL m_bMouseHover; - FX_BOOL m_bMouseDown; - FX_BOOL m_bRepaintThumb; - FX_FLOAT m_fButtonLen; - FX_BOOL m_bMinSize; - CFX_RectF m_rtClient; - CFX_RectF m_rtThumb; - CFX_RectF m_rtMinBtn; - CFX_RectF m_rtMaxBtn; - CFX_RectF m_rtMinTrack; - 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; - - protected: - void OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - void OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - void OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - void OnMouseLeave(); - void OnMouseWheel(FX_FLOAT fx, - FX_FLOAT fy, - FX_DWORD dwFlags, - FX_FLOAT fDeltaX, - FX_FLOAT fDeltaY); - void DoMouseDown(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); - void DoMouseUp(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); - void DoMouseMove(int32_t iItem, - const CFX_RectF& rtItem, - int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); - void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); - void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); - - CFWL_ScrollBarImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/src/fwl/basewidget/fwl_spinbuttonimp.cpp deleted file mode 100644 index fd7c226102..0000000000 --- a/xfa/src/fwl/basewidget/fwl_spinbuttonimp.cpp +++ /dev/null @@ -1,429 +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/src/fwl/basewidget/fwl_spinbuttonimp.h" - -#include "xfa/include/fwl/basewidget/fwl_spinbutton.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -#define FWL_SPN_MinWidth 18 -#define FWL_SPN_MinHeight 32 -#define FWL_SPIN_Elapse 200 - -// static -IFWL_SpinButton* IFWL_SpinButton::Create( - const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_SpinButton* pSpinButton = new IFWL_SpinButton; - CFWL_SpinButtonImp* pSpinButtonImpl = - new CFWL_SpinButtonImp(properties, nullptr); - pSpinButton->SetImpl(pSpinButtonImpl); - pSpinButtonImpl->SetInterface(pSpinButton); - return pSpinButton; -} -IFWL_SpinButton::IFWL_SpinButton() {} -FWL_ERR IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { - return static_cast<CFWL_SpinButtonImp*>(GetImpl()) - ->EnableButton(bEnable, bUp); -} -FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) { - return static_cast<CFWL_SpinButtonImp*>(GetImpl())->IsButtonEnable(bUp); -} - -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_iButtonIndex(0), - m_bLButtonDwn(FALSE), - m_hTimer(NULL) { - m_rtClient.Reset(); - m_rtUpButton.Reset(); - m_rtDnButton.Reset(); - m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; -} -CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {} -FWL_ERR CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_SpinButton; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_SpinButtonImp::GetClassID() const { - return FWL_CLASSHASH_SpinButton; -} -FWL_ERR CFWL_SpinButtonImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - m_pDelegate = new CFWL_SpinButtonImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_SpinButtonImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight); - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_SpinButtonImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - GetClientRect(m_rtClient); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { - m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, - m_rtClient.height / 2); - m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, - m_rtClient.width, m_rtClient.height / 2); - } else { - m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, - m_rtClient.height); - m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, - m_rtClient.width / 2, m_rtClient.height); - } - return FWL_ERR_Succeeded; -} -FX_DWORD 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; - } - 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; -} -FWL_ERR CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics) - return FWL_ERR_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); - } - if (HasEdge()) { - DrawEdge(pGraphics, FWL_PART_SPB_Edge, pTheme, pMatrix); - } - DrawUpButton(pGraphics, pTheme, pMatrix); - DrawDownButton(pGraphics, pTheme, pMatrix); - return FWL_ERR_Succeeded; -} -int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) { - if (m_hTimer) { - CFWL_EvtSpbClick wmPosChanged; - wmPosChanged.m_pSrcTarget = m_pInterface; - wmPosChanged.m_bUp = m_iButtonIndex == 0; - DispatchEvent(&wmPosChanged); - } - return 1; -} -FWL_ERR CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { - if (bUp) { - if (bEnable) { - m_dwUpState = FWL_PARTSTATE_SPB_Normal; - } else { - m_dwUpState = FWL_PARTSTATE_SPB_Disabled; - } - } else { - if (bEnable) { - m_dwDnState = FWL_PARTSTATE_SPB_Normal; - } else { - m_dwDnState = FWL_PARTSTATE_SPB_Disabled; - } - } - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp) { - if (bUp) { - return (m_dwUpState != FWL_PARTSTATE_SPB_Disabled); - } - return (m_dwDnState != FWL_PARTSTATE_SPB_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_pGraphics = pGraphics; - params.m_dwStates = m_dwUpState + 1; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - params.m_rtPart = m_rtUpButton; - pTheme->DrawBackground(¶ms); -} -void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = m_pInterface; - params.m_iPart = FWL_PART_SPB_DownButton; - params.m_pGraphics = pGraphics; - params.m_dwStates = m_dwDnState + 1; - if (pMatrix) { - params.m_matrix.Concat(*pMatrix); - } - params.m_rtPart = m_rtDnButton; - pTheme->DrawBackground(¶ms); -} -CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate( - CFWL_SpinButtonImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - int32_t iRet = 1; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - FX_DWORD 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; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMsg); - break; - } - default: {} - } - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_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::OnFocusChanged(CFWL_Message* pMsg, - FX_BOOL bSet) { - if (bSet) { - m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); - } else { - m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - m_pOwner->m_bLButtonDwn = TRUE; - m_pOwner->SetGrab(TRUE); - m_pOwner->SetFocus(TRUE); - if (!m_pOwner->m_pProperties->m_pDataProvider) - return; - FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && - m_pOwner->IsButtonEnable(TRUE)); - FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && - m_pOwner->IsButtonEnable(FALSE)); - if (!bUpPress && !bDnPress) { - return; - } - if (bUpPress) { - m_pOwner->m_iButtonIndex = 0; - m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Pressed; - } - if (bDnPress) { - m_pOwner->m_iButtonIndex = 1; - m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Pressed; - } - CFWL_EvtSpbClick wmPosChanged; - wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; - wmPosChanged.m_bUp = bUpPress; - 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); -} -void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_pProperties->m_dwStates & FWL_PARTSTATE_SPB_Disabled) { - return; - } - m_pOwner->m_bLButtonDwn = FALSE; - m_pOwner->SetGrab(FALSE); - m_pOwner->SetFocus(FALSE); - if (m_pOwner->m_hTimer) { - FWL_StopTimer(m_pOwner->m_hTimer); - m_pOwner->m_hTimer = NULL; - } - FX_BOOL bRepaint = FALSE; - CFX_RectF rtInvalidate; - if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Pressed && - m_pOwner->IsButtonEnable(TRUE)) { - m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; - bRepaint = TRUE; - rtInvalidate = m_pOwner->m_rtUpButton; - } else if (m_pOwner->m_dwDnState == FWL_PARTSTATE_SPB_Pressed && - m_pOwner->IsButtonEnable(FALSE)) { - m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; - bRepaint = TRUE; - rtInvalidate = m_pOwner->m_rtDnButton; - } - if (bRepaint) { - m_pOwner->Repaint(&rtInvalidate); - } -} -void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (!m_pOwner->m_pProperties->m_pDataProvider) - return; - if (m_pOwner->m_bLButtonDwn) { - return; - } - FX_BOOL bRepaint = FALSE; - CFX_RectF rtInvlidate; - 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; - bRepaint = TRUE; - rtInvlidate = m_pOwner->m_rtUpButton; - } - if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && - m_pOwner->IsButtonEnable(FALSE)) { - m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; - if (bRepaint) { - rtInvlidate.Union(m_pOwner->m_rtDnButton); - } else { - rtInvlidate = m_pOwner->m_rtDnButton; - } - bRepaint = TRUE; - } - } - if (!m_pOwner->IsButtonEnable(FALSE)) { - m_pOwner->EnableButton(FALSE, FALSE); - } - } 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; - bRepaint = TRUE; - rtInvlidate = m_pOwner->m_rtDnButton; - } - if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && - m_pOwner->IsButtonEnable(TRUE)) { - m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; - if (bRepaint) { - rtInvlidate.Union(m_pOwner->m_rtUpButton); - } else { - rtInvlidate = m_pOwner->m_rtUpButton; - } - 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; - 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 (bRepaint) { - rtInvlidate.Union(m_pOwner->m_rtDnButton); - } else { - rtInvlidate = m_pOwner->m_rtDnButton; - } - bRepaint = TRUE; - } - } - if (bRepaint) { - m_pOwner->Repaint(&rtInvlidate); - } -} -void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { - if (!pMsg) - return; - if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && - m_pOwner->IsButtonEnable(TRUE)) { - m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal; - } - if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && - m_pOwner->IsButtonEnable(FALSE)) { - m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal; - } - m_pOwner->Repaint(&m_pOwner->m_rtClient); -} -void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { - if (!m_pOwner->m_pProperties->m_pDataProvider) - return; - FX_BOOL bUp = - pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; - FX_BOOL bDown = - pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; - if (!bUp && !bDown) { - return; - } - FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE); - FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE); - if (!bUpEnable && !bDownEnable) { - return; - } - CFWL_EvtSpbClick wmPosChanged; - wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; - wmPosChanged.m_bUp = bUpEnable; - m_pOwner->DispatchEvent(&wmPosChanged); - m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton - : &m_pOwner->m_rtDnButton); -} diff --git a/xfa/src/fwl/basewidget/fwl_spinbuttonimp.h b/xfa/src/fwl/basewidget/fwl_spinbuttonimp.h deleted file mode 100644 index 769db28c30..0000000000 --- a/xfa/src/fwl/basewidget/fwl_spinbuttonimp.h +++ /dev/null @@ -1,69 +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_SRC_FWL_BASEWIDGET_FWL_SPINBUTTONIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_SPINBUTTONIMP_H_ - -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class CFWL_SpinButtonImpDelegate; - -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 FX_DWORD 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 FX_DWORD 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); - FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); - - protected: - 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; - FX_DWORD m_dwUpState; - FX_DWORD m_dwDnState; - 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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - CFWL_SpinButtonImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_SPINBUTTONIMP_H_ diff --git a/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.cpp deleted file mode 100644 index 696a2e2b39..0000000000 --- a/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.cpp +++ /dev/null @@ -1,293 +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/src/fwl/basewidget/fwl_tooltipctrlimp.h" - -#include "xfa/include/fwl/basewidget/fwl_tooltipctrl.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -// static -IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) { - IFWL_ToolTip* pToolTip = new IFWL_ToolTip; - CFWL_ToolTipImp* pToolTipImpl = new CFWL_ToolTipImp(properties, pOuter); - pToolTip->SetImpl(pToolTipImpl); - pToolTipImpl->SetInterface(pToolTip); - return pToolTip; -} -FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { - return static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor); -} -FWL_ERR IFWL_ToolTip::Show() { - return static_cast<CFWL_ToolTipImp*>(GetImpl())->Show(); -} -FWL_ERR IFWL_ToolTip::Hide() { - return 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), - m_bBtnDown(FALSE), - m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), - m_iTTOAlign(FDE_TTOALIGNMENT_Center), - m_hTimerShow(NULL), - m_hTimerHide(NULL), - m_pTimer(NULL) { - m_rtClient.Set(0, 0, 0, 0); - m_rtCaption.Set(0, 0, 0, 0); - m_rtAnchor.Set(0, 0, 0, 0); - 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 { - wsClass = FWL_CLASS_ToolTip; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_ToolTipImp::GetClassID() const { - return FWL_CLASSHASH_ToolTip; -} -FWL_ERR 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; - m_pDelegate = new CFWL_ToolTipImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTipImp::Finalize() { - delete m_pDelegate; - m_pDelegate = nullptr; - return CFWL_WidgetImp::Finalize(); -} -FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (m_pProperties->m_pThemeProvider == NULL) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - CFX_WideString wsCaption; - IFWL_ToolTipDP* pData = - static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); - if (pData) { - pData->GetCaption(m_pInterface, wsCaption); - } - int32_t iLen = wsCaption.GetLength(); - 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; - } - CFWL_WidgetImp::GetWidgetRect(rect, TRUE); - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTipImp::Update() { - if (IsLocked()) { - return FWL_ERR_Indefinite; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - UpdateTextOutStyles(); - GetClientRect(m_rtClient); - m_rtCaption = m_rtClient; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) { - FX_FLOAT x = 0; - FX_FLOAT y = 0; - FX_FLOAT t = 0; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (pTheme) { - CFWL_ThemePart part; - part.m_pWidget = m_pInterface; - x = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); - y = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); - } - rect = m_pProperties->m_rtWidget; - rect.Offset(-rect.left, -rect.top); - rect.Deflate(x, t, x, y); - return FWL_ERR_Succeeded; -} -FWL_ERR 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; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - DrawBkground(pGraphics, pTheme, pMatrix); - DrawText(pGraphics, pTheme, pMatrix); - return FWL_ERR_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_dwStates = m_pProperties->m_dwStates; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { - param.m_pData = &m_rtCaption; - } - pTheme->DrawBackground(¶m); -} -void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!m_pProperties->m_pDataProvider) - return; - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); - if (wsCaption.IsEmpty()) { - return; - } - CFWL_ThemeText param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_TTP_Caption; - param.m_dwStates = m_pProperties->m_dwStates; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - param.m_rtPart = m_rtCaption; - param.m_wsText = wsCaption; - param.m_dwTTOStyles = m_dwTTOStyles; - param.m_iTTOAlign = m_iTTOAlign; - pTheme->DrawText(¶m); -} -void CFWL_ToolTipImp::UpdateTextOutStyles() { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { - m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { - m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; - } -} -FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { - m_rtAnchor = rtAnchor; - return TRUE; -} -FWL_ERR 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)) { - m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); - } - return TRUE; -} -FWL_ERR CFWL_ToolTipImp::Hide() { - SetStates(FWL_WGTSTATE_Invisible, TRUE); - if (m_hTimerHide) { - FWL_StopTimer(m_hTimerHide); - m_hTimerHide = NULL; - } - if (m_hTimerShow) { - FWL_StopTimer(m_hTimerShow); - m_hTimerShow = NULL; - } - return TRUE; -} -FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD 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); -} -void CFWL_ToolTipImp::RefreshToolTipPos() { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { - CFX_RectF rtPopup; - CFX_RectF rtWidget(m_pProperties->m_rtWidget); - CFX_RectF rtAnchor(m_rtAnchor); - rtPopup.Set(0, 0, 0, 0); - FX_FLOAT fx = rtAnchor.Center().x + 20; - FX_FLOAT fy = rtAnchor.Center().y + 20; - rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); - FX_FLOAT fScreenWidth = 0; - FX_FLOAT fScreenHeight = 0; - GetScreenSize(fScreenWidth, fScreenHeight); - if (rtPopup.bottom() > fScreenHeight) { - rtPopup.Offset(0, fScreenHeight - rtPopup.bottom()); - } - if (rtPopup.right() > fScreenWidth) { - rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); - } - if (rtPopup.left < 0) { - rtPopup.Offset(0 - rtPopup.left, 0); - } - if (rtPopup.top < 0) { - rtPopup.Offset(0, 0 - rtPopup.top); - } - SetWidgetRect(rtPopup); - Update(); - } -} -CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) - : m_pToolTip(pToolTip) {} -int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { - if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { - if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { - m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); - m_pToolTip->RefreshToolTipPos(); - FWL_StopTimer(m_pToolTip->m_hTimerShow); - m_pToolTip->m_hTimerShow = NULL; - return TRUE; - } - } - if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { - m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); - FWL_StopTimer(m_pToolTip->m_hTimerHide); - m_pToolTip->m_hTimerHide = NULL; - return TRUE; - } - 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; -} -FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOwner->DrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h b/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h deleted file mode 100644 index 08fb7b0639..0000000000 --- a/xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h +++ /dev/null @@ -1,86 +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_SRC_FWL_BASEWIDGET_FWL_TOOLTIPCTRLIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FWL_TOOLTIPCTRLIMP_H_ - -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_WidgetImpProperties; -class IFWL_Widget; -class CFWL_ToolTipImpDelegate; - -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 FX_DWORD 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(FX_DWORD dwStates, FX_BOOL bSet); - virtual FWL_ERR GetClientRect(CFX_RectF& rect); - FWL_ERR SetAnchor(const CFX_RectF& rtAnchor); - FWL_ERR Show(); - FWL_ERR 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(); - 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; - }; - CFX_RectF m_rtClient; - CFX_RectF m_rtCaption; - FX_BOOL m_bBtnDown; - FX_DWORD m_dwTTOStyles; - int32_t m_iTTOAlign; - CFX_RectF m_rtAnchor; - FWL_HTIMER m_hTimerShow; - FWL_HTIMER m_hTimerHide; - 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; - - protected: - void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - CFWL_ToolTipImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FWL_TOOLTIPCTRLIMP_H_ diff --git a/xfa/src/fwl/basewidget/fxmath_barcodeimp.cpp b/xfa/src/fwl/basewidget/fxmath_barcodeimp.cpp deleted file mode 100644 index 8c9bfe432c..0000000000 --- a/xfa/src/fwl/basewidget/fxmath_barcodeimp.cpp +++ /dev/null @@ -1,385 +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/src/fwl/basewidget/fxmath_barcodeimp.h" - -static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { - switch (type) { - case BC_CODE39: - return new CBC_Code39(); - case BC_CODABAR: - return new CBC_Codabar(); - case BC_CODE128: - return new CBC_Code128(BC_CODE128_B); - case BC_CODE128_B: - return new CBC_Code128(BC_CODE128_B); - case BC_CODE128_C: - return new CBC_Code128(BC_CODE128_C); - case BC_EAN8: - return new CBC_EAN8(); - case BC_UPCA: - return new CBC_UPCA(); - case BC_EAN13: - return new CBC_EAN13(); - case BC_QR_CODE: - return new CBC_QRCode(); - case BC_PDF417: - return new CBC_PDF417I(); - case BC_DATAMATRIX: - return new CBC_DataMatrix(); - case BC_UNKNOWN: - default: - return NULL; - } -} -CFX_Barcode::CFX_Barcode() {} -CFX_Barcode::~CFX_Barcode() { - if (m_pBCEngine) { - delete m_pBCEngine; - m_pBCEngine = NULL; - } -} -FX_BOOL CFX_Barcode::Crreate(BC_TYPE type) { - m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type); - return m_pBCEngine != NULL; -} -void CFX_Barcode::Release() { - delete this; -} -BC_TYPE CFX_Barcode::GetType() { - return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; -} -FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { - return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; -} -FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { - return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; -} -FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth) { - return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE; -} -FX_BOOL CFX_Barcode::SetHeight(int32_t height) { - return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE; -} -FX_BOOL CFX_Barcode::SetWidth(int32_t width) { - return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE; -} -FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine - ? static_cast<CBC_OneCode*>(m_pBCEngine) - ->CheckContentValidity(contents) - : TRUE; - default: - return TRUE; - } -} -FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) - ->SetPrintChecksum(checksum), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetDataLength(int32_t length) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) - ->SetDataLength(length), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine) - ->SetCalChecksum(state), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine - ? static_cast<CBC_OneCode*>(m_pBCEngine)->SetFont(pFont) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine - ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontSize(size), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine - ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontStyle(style), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) { - switch (GetType()) { - case BC_CODE39: - case BC_CODABAR: - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - case BC_EAN8: - case BC_EAN13: - case BC_UPCA: - return m_pBCEngine - ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color), - TRUE) - : FALSE; - default: - return FALSE; - } -} -FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_CODE39: - memptr = (memptrtype)&CBC_Code39::SetTextLocation; - break; - case BC_CODABAR: - memptr = (memptrtype)&CBC_Codabar::SetTextLocation; - break; - case BC_CODE128: - case BC_CODE128_B: - case BC_CODE128_C: - memptr = (memptrtype)&CBC_Code128::SetTextLocation; - break; - default: - break; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE; -} -FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_CODE39: - memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; - break; - case BC_CODABAR: - memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; - break; - default: - break; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE; -} -FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_CODABAR: - memptr = (memptrtype)&CBC_Codabar::SetStartChar; - break; - default: - break; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE; -} -FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_CODABAR: - memptr = (memptrtype)&CBC_Codabar::SetEndChar; - break; - default: - break; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE; -} -FX_BOOL CFX_Barcode::SetVersion(int32_t version) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_QR_CODE: - memptr = (memptrtype)&CBC_QRCode::SetVersion; - break; - default: - break; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE; -} -FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { - typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_QR_CODE: - memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; - break; - case BC_PDF417: - memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; - break; - default: - return FALSE; - } - return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE; -} -FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { - typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL); - memptrtype memptr = NULL; - switch (GetType()) { - case BC_PDF417: - memptr = (memptrtype)&CBC_PDF417I::SetTruncated; - break; - default: - break; - } - 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) { - if (!m_pBCEngine) { - return FALSE; - } - return m_pBCEngine->Encode(contents, isDevice, e); -} -FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device, - const CFX_Matrix* matirx, - int32_t& e) { - if (!m_pBCEngine) { - return FALSE; - } - return m_pBCEngine->RenderDevice(device, matirx, e); -} -FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - if (!m_pBCEngine) { - return FALSE; - } - 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; - t = (BC_TYPE)((int32_t)t + 1)) { - CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); - if (!pTmpEngine) { - continue; - } - CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode); - if (errorCode == BCExceptionNO) { - return ret; - } - } - errorCode = BCExceptionUnSupportedBarcode; - 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; - t = (BC_TYPE)((int32_t)t + 1)) { - CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); - if (!pTmpEngine) { - continue; - } - CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); - if (errorCode == BCExceptionNO) { - return ret; - } - } - errorCode = BCExceptionUnSupportedBarcode; - return CFX_WideString(); -} -IFX_Barcode* FX_Barcode_Create(BC_TYPE type) { - CFX_Barcode* pBarcode = new CFX_Barcode; - if (pBarcode->Crreate(type)) { - return pBarcode; - } - pBarcode->Release(); - return NULL; -} diff --git a/xfa/src/fwl/basewidget/fxmath_barcodeimp.h b/xfa/src/fwl/basewidget/fxmath_barcodeimp.h deleted file mode 100644 index 22cb97bcc4..0000000000 --- a/xfa/src/fwl/basewidget/fxmath_barcodeimp.h +++ /dev/null @@ -1,56 +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_SRC_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_ -#define XFA_SRC_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_ - -#include "xfa/include/fwl/basewidget/fxmath_barcode.h" - -class CFX_Barcode : public IFX_Barcode { - public: - CFX_Barcode(); - ~CFX_Barcode(); - FX_BOOL Crreate(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); - - protected: - CBC_CodeBase* m_pBCEngine; -}; - -#endif // XFA_SRC_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_ diff --git a/xfa/src/fwl/core/fwl_appimp.cpp b/xfa/src/fwl/core/fwl_appimp.cpp deleted file mode 100644 index 43a3d0badf..0000000000 --- a/xfa/src/fwl/core/fwl_appimp.cpp +++ /dev/null @@ -1,114 +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/src/fwl/core/fwl_appimp.h" - -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) { - IFWL_App* pApp = new IFWL_App; - pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter)); - return pApp; -} -FWL_ERR IFWL_App::Initialize() { - return static_cast<CFWL_AppImp*>(GetImpl())->Initialize(); -} -FWL_ERR IFWL_App::Finalize() { - return static_cast<CFWL_AppImp*>(GetImpl())->Finalize(); -} -IFWL_AdapterNative* 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); -} -FWL_ERR IFWL_App::Exit(int32_t iExitCode) { - return 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_AppImp::~CFWL_AppImp() { - CFWL_ToolTipContainer::DeleteInstance(); -} - -FWL_ERR CFWL_AppImp::Initialize() { - if (!m_pWidgetMgr) { - m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative)); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_AppImp::Finalize() { - m_pWidgetMgr.reset(); - return FWL_ERR_Succeeded; -} -IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const { - return m_pAdapterNative; -} -IFWL_AdapterWidgetMgr* 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) { - m_pThemeProvider = pThemeProvider; - return FWL_ERR_Succeeded; -} -FWL_ERR 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() { - IFWL_App* pApp = FWL_GetApp(); - if (!pApp) - return NULL; - return pApp->GetAdapterNative(); -} -IFWL_ThemeProvider* FWL_GetThemeProvider() { - return NULL; -} -static IFWL_App* _theApp = NULL; -IFWL_App* FWL_GetApp() { - return _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); -} diff --git a/xfa/src/fwl/core/fwl_appimp.h b/xfa/src/fwl/core/fwl_appimp.h deleted file mode 100644 index fa4ffecc65..0000000000 --- a/xfa/src/fwl/core/fwl_appimp.h +++ /dev/null @@ -1,38 +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_SRC_FWL_CORE_FWL_APPIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_APPIMP_H_ - -#include <memory> - -#include "xfa/src/fwl/core/fwl_threadimp.h" - -class CFWL_WidgetMgr; -class IFWL_AdapterNative; -class IFWL_WidgetMgr; -class IFWL_ThemeProvider; -class IFWL_App; - -class CFWL_AppImp : public CFWL_NoteThreadImp { - 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; - std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr; - IFWL_ThemeProvider* m_pThemeProvider; -}; - -#endif // XFA_SRC_FWL_CORE_FWL_APPIMP_H_ diff --git a/xfa/src/fwl/core/fwl_contentimp.cpp b/xfa/src/fwl/core/fwl_contentimp.cpp deleted file mode 100644 index d415e33a26..0000000000 --- a/xfa/src/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/src/fwl/core/fwl_contentimp.h" - -#include "xfa/include/fwl/core/fwl_content.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.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/xfa/src/fwl/core/fwl_contentimp.h b/xfa/src/fwl/core/fwl_contentimp.h deleted file mode 100644 index d2b0277a86..0000000000 --- a/xfa/src/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_SRC_FWL_CORE_FWL_CONTENTIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_CONTENTIMP_H_ - -#include "xfa/src/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_SRC_FWL_CORE_FWL_CONTENTIMP_H_ diff --git a/xfa/src/fwl/core/fwl_formimp.cpp b/xfa/src/fwl/core/fwl_formimp.cpp deleted file mode 100644 index 558ee00f9c..0000000000 --- a/xfa/src/fwl/core/fwl_formimp.cpp +++ /dev/null @@ -1,1175 +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/src/fwl/core/fwl_formimp.h" - -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_content.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/basewidget/fwl_formproxyimp.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -#define FWL_SYSBTNSIZE 21 -#define FWL_SYSBTNMARGIN 5 -#define FWL_SYSBTNSPAN 2 -#define FWL_CornerEnlarge 10 - -// static -IFWL_Form* IFWL_Form::CreateFormProxy(CFWL_WidgetImpProperties& properties, - CFX_WideString* classname, - IFWL_Widget* pOuter) { - IFWL_Form* pForm = new IFWL_Form; - CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter); - pForm->SetImpl(pFormProxyImpl); - pFormProxyImpl->SetInterface(pForm); - return pForm; -} -IFWL_Form::IFWL_Form() {} -FWL_FORMSIZE IFWL_Form::GetFormSize() { - return static_cast<CFWL_FormImp*>(GetImpl())->GetFormSize(); -} -FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { - return static_cast<CFWL_FormImp*>(GetImpl())->SetFormSize(eFormSize); -} -IFWL_Widget* IFWL_Form::DoModal() { - return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(); -} -IFWL_Widget* IFWL_Form::DoModal(FX_DWORD& dwCommandID) { - return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(dwCommandID); -} -FWL_ERR IFWL_Form::EndDoModal() { - return static_cast<CFWL_FormImp*>(GetImpl())->EndDoModal(); -} -FWL_ERR 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), - m_fCXBorder(0), - m_fCYBorder(0), - m_iCaptureBtn(-1), - m_iSysBox(0), - m_eResizeType(FORM_RESIZETYPE_None), - m_bLButtonDown(FALSE), - m_bMaximized(FALSE), - m_bSetMaximize(FALSE), - m_bCustomizeLayout(FALSE), - m_eFormSize(FWL_FORMSIZE_Manual), - m_bDoModalFlag(FALSE), - m_pBigIcon(NULL), - m_pSmallIcon(NULL), - m_bMouseIn(FALSE) { - m_rtRelative.Reset(); - m_rtCaption.Reset(); - m_rtRestore.Reset(); - m_rtCaptionText.Reset(); - m_rtIcon.Reset(); -} -CFWL_FormImp::~CFWL_FormImp() { - RemoveSysButtons(); - delete m_pNoteLoop; -} -FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const { - wsClass = FWL_CLASS_Form; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_FormImp::GetClassID() const { - return FWL_CLASSHASH_Form; -} -FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const { - if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) { - return TRUE; - } - return CFWL_PanelImp::IsInstance(wsClass); -} -FWL_ERR CFWL_FormImp::Initialize() { - if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) - return FWL_ERR_Indefinite; - RegisterForm(); - RegisterEventTarget(); - m_pDelegate = new CFWL_FormImpDelegate(this); - return FWL_ERR_Succeeded; -} -FWL_ERR 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) { - 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; -} -FWL_ERR 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; - } -#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; -#else - FX_FLOAT x = 0; - FX_FLOAT y = 0; - FX_FLOAT t = 0; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (pTheme) { - CFWL_ThemePart part; - part.m_pWidget = m_pInterface; - x = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); - y = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); - t = *static_cast<FX_FLOAT*>( - pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption)); - } - rect = m_pProperties->m_rtWidget; - rect.Offset(-rect.left, -rect.top); - rect.Deflate(x, t, x, y); - return FWL_ERR_Succeeded; -#endif -} -FWL_ERR CFWL_FormImp::Update() { - if (m_iLock > 0) { - return FWL_ERR_Succeeded; - } - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } -#ifdef FWL_UseMacSystemBorder -#else - SetThemeData(); - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { - UpdateIcon(); - } -#endif - UpdateCaption(); - Layout(); - return FWL_ERR_Succeeded; -} -FX_DWORD 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; - } - 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.height - m_fCXBorder); - if (rtCap.Contains(fx, fy)) { - return FWL_WGTHITTEST_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); - 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, - 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, - 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 (!pGraphics) - return FWL_ERR_Indefinite; - if (!m_pProperties->m_pThemeProvider) - return FWL_ERR_Indefinite; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - FX_BOOL bInactive = !IsActive(); - int32_t iState = - bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal; - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { - DrawBackground(pGraphics, pTheme); - } -#ifdef FWL_UseMacSystemBorder - return FWL_ERR_Succeeded; -#endif - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_dwStates = iState; - param.m_pGraphics = pGraphics; - param.m_rtPart = m_rtRelative; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { - param.m_iPart = FWL_PART_FRM_Border; - pTheme->DrawBackground(¶m); - } - 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_rtPart = rtEdge; - param.m_dwStates = iState; - pTheme->DrawBackground(¶m); - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { - param.m_iPart = FWL_PART_FRM_Caption; - param.m_dwStates = iState; - param.m_rtPart = m_rtCaption; - pTheme->DrawBackground(¶m); - DrawCaptionText(pGraphics, pTheme, pMatrix); - } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { - param.m_iPart = FWL_PART_FRM_NarrowCaption; - param.m_dwStates = iState; - param.m_rtPart = m_rtCaption; - pTheme->DrawBackground(¶m); - DrawCaptionText(pGraphics, pTheme, pMatrix); - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { - param.m_iPart = FWL_PART_FRM_Icon; - if (HasIcon()) { - DrawIconImage(pGraphics, pTheme, pMatrix); - } - } -#if (_FX_OS_ == _FX_MACOSX_) - { - if (m_pCloseBox) { - param.m_iPart = FWL_PART_FRM_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_rtPart = m_pCloseBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - if (m_pMaxBox) { - param.m_iPart = FWL_PART_FRM_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_rtPart = m_pMaxBox->m_rtBtn; - param.m_dwData = m_bMaximized; - pTheme->DrawBackground(¶m); - } - if (m_pMinBox) { - param.m_iPart = FWL_PART_FRM_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_rtPart = m_pMinBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - m_bMouseIn = FALSE; - } -#else - { - if (m_pCloseBox) { - param.m_iPart = FWL_PART_FRM_CloseBox; - param.m_dwStates = m_pCloseBox->GetPartState(); - param.m_rtPart = m_pCloseBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - if (m_pMaxBox) { - param.m_iPart = FWL_PART_FRM_MaximizeBox; - param.m_dwStates = m_pMaxBox->GetPartState(); - param.m_rtPart = m_pMaxBox->m_rtBtn; - param.m_dwData = m_bMaximized; - pTheme->DrawBackground(¶m); - } - if (m_pMinBox) { - param.m_iPart = FWL_PART_FRM_MinimizeBox; - param.m_dwStates = m_pMinBox->GetPartState(); - param.m_rtPart = m_pMinBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - } -#endif - return FWL_ERR_Succeeded; -} -FWL_FORMSIZE CFWL_FormImp::GetFormSize() { - return m_eFormSize; -} -FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) { - m_eFormSize = eFormSize; - return FWL_ERR_Succeeded; -} -IFWL_Widget* CFWL_FormImp::DoModal() { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return NULL; - IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); - if (!pDriver) - return NULL; - m_pNoteLoop = new CFWL_NoteLoop(this); - pDriver->PushNoteLoop(m_pNoteLoop); - m_bDoModalFlag = TRUE; - SetStates(FWL_WGTSTATE_Invisible, FALSE); - pDriver->Run(); -#if (_FX_OS_ == _FX_MACOSX_) -#else - pDriver->PopNoteLoop(); -#endif - delete m_pNoteLoop; - m_pNoteLoop = NULL; - return NULL; -} -IFWL_Widget* CFWL_FormImp::DoModal(FX_DWORD& dwCommandID) { - return DoModal(); -} -FWL_ERR CFWL_FormImp::EndDoModal() { - if (!m_pNoteLoop) - return FWL_ERR_Indefinite; - m_bDoModalFlag = FALSE; -#if (_FX_OS_ == _FX_MACOSX_) - m_pNoteLoop->EndModalLoop(); - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return FWL_ERR_Indefinite; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - if (!pDriver) - return FWL_ERR_Indefinite; - pDriver->PopNoteLoop(); - SetStates(FWL_WGTSTATE_Invisible, TRUE); - return FWL_ERR_Succeeded; -#else - SetStates(FWL_WGTSTATE_Invisible, TRUE); - return m_pNoteLoop->EndModalLoop(); -#endif -} -FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) { - return FWL_ERR_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_pGraphics = pGraphics; - param.m_rtPart = m_rtRelative; - param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder, - m_fCXBorder); - pTheme->DrawBackground(¶m); -} -CFWL_WidgetImp* CFWL_FormImp::GetSubFocus() { - return m_pSubFocus; -} -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(); - FX_DWORD 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) - return; - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); - if (!pWidgetMgr) - return; - 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; - } -} -void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) { -#ifdef FWL_UseMacSystemBorder - rtContent = m_rtRelative; -#else - GetEdgeRect(rtContent); - if (HasEdge()) { - FX_FLOAT fEdge = GetEdgeWidth(); - rtContent.Deflate(fEdge, fEdge); - } -#endif -} -CFWL_SysBtn* CFWL_FormImp::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { - return m_pCloseBox; - } - if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { - return m_pMaxBox; - } - if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { - return m_pMinBox; - } - if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) { - return m_pCaptionBox; - } - return NULL; -} -CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(FX_DWORD dwState) { - if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) { - return m_pCloseBox; - } - if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) { - return m_pMaxBox; - } - if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) { - return m_pMinBox; - } - if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) { - return m_pCaptionBox; - } - return NULL; -} -CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex) { - if (nIndex < 0) { - return NULL; - } - CFX_PtrArray arrBtn; - if (m_pMinBox) { - arrBtn.Add(m_pMinBox); - } - if (m_pMaxBox) { - arrBtn.Add(m_pMaxBox); - } - if (m_pCloseBox) { - arrBtn.Add(m_pCloseBox); - } - return static_cast<CFWL_SysBtn*>(arrBtn[nIndex]); -} -int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn* pBtn) { - CFX_PtrArray arrBtn; - if (m_pMinBox) { - arrBtn.Add(m_pMinBox); - } - if (m_pMaxBox) { - arrBtn.Add(m_pMaxBox); - } - if (m_pCloseBox) { - arrBtn.Add(m_pCloseBox); - } - return arrBtn.Find(pBtn); -} -FX_FLOAT CFWL_FormImp::GetCaptionHeight() { - FX_DWORD dwCapacity = 0; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { - dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption; - } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { - dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption; - } - if (dwCapacity > 0) { - FX_FLOAT* pfCapHeight = - static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); - return pfCapHeight ? *pfCapHeight : 0; - } - return 0; -} -void CFWL_FormImp::DrawCaptionText(CFX_Graphics* pGs, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFX_WideString wsText; - IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; - pData->GetCaption(m_pInterface, wsText); - if (wsText.IsEmpty()) { - return; - } - CFWL_ThemeText textParam; - textParam.m_pWidget = m_pInterface; - textParam.m_iPart = FWL_PART_FRM_Caption; - textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal; - textParam.m_pGraphics = pGs; - if (pMatrix) { - textParam.m_matrix.Concat(*pMatrix); - } - CFX_RectF rtText; - if (m_bCustomizeLayout) { - rtText = m_rtCaptionText; - rtText.top -= 5; - } else { - rtText = m_rtCaption; - FX_FLOAT fpos; - fpos = HasIcon() ? 29.0f : 13.0f; - rtText.left += fpos; - } - textParam.m_rtPart = rtText; - textParam.m_wsText = wsText; - textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis; - textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center - : FDE_TTOALIGNMENT_CenterLeft; - pTheme->DrawText(&textParam); -} -void CFWL_FormImp::DrawIconImage(CFX_Graphics* pGs, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - IFWL_FormDP* pData = - 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_pGraphics = pGs; - param.m_pImage = pData->GetIcon(m_pInterface, FALSE); - param.m_rtPart = m_rtIcon; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶m); -} -void CFWL_FormImp::GetEdgeRect(CFX_RectF& rtEdge) { - rtEdge = m_rtRelative; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { - FX_FLOAT fCX = GetBorderSize(); - FX_FLOAT fCY = GetBorderSize(FALSE); - rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); - } -} -void CFWL_FormImp::SetWorkAreaRect() { - m_rtRestore = m_pProperties->m_rtWidget; - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return; - m_bSetMaximize = TRUE; - pWidgetMgr->SetMaximize_Native(m_pInterface); - Repaint(&m_rtRelative); -} -void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} -void CFWL_FormImp::Layout() { - GetRelativeRect(m_rtRelative); -#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)); - m_fCYBorder = - *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CYBorder)); - RemoveSysButtons(); - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface); - FX_FLOAT fCapHeight = GetCaptionHeight(); - if (fCapHeight > 0) { - m_rtCaption = m_rtRelative; - m_rtCaption.height = fCapHeight; - } - m_iSysBox = 0; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { - m_pCloseBox = new CFWL_SysBtn; - if (m_bCustomizeLayout) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_FRM_CloseBox; - pTheme->GetPartRect(¶m, m_pCloseBox->m_rtBtn); - } else { - m_pCloseBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); - } - m_iSysBox++; - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) { - m_pMaxBox = new CFWL_SysBtn; - if (m_bCustomizeLayout) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_FRM_MaximizeBox; - pTheme->GetPartRect(¶m, 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); - } else { - m_pMaxBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); - } - } - m_iSysBox++; - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) { - m_pMinBox = new CFWL_SysBtn; - if (m_bCustomizeLayout) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_FRM_MinimizeBox; - pTheme->GetPartRect(¶m, 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); - } 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); - } else { - m_pMinBox->m_rtBtn.Set( - m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE, - FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE); - } - } - m_iSysBox++; - } - IFWL_FormDP* pData = - static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && - pData->GetIcon(m_pInterface, FALSE)) { - if (m_bCustomizeLayout) { - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = FWL_PART_FRM_Icon; - CFX_WideString wsText; - m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText); - param.m_pData = &wsText; - pTheme->GetPartRect(¶m, m_rtIcon); - } else { - m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, - m_fSmallIconSz); - } - } - if (m_bCustomizeLayout) { - CFWL_ThemeText parma; - parma.m_pWidget = m_pInterface; - parma.m_iPart = FWL_PART_FRM_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) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - if (!pDriver) - return; - pDriver->RegisterForm(this); -} -void CFWL_FormImp::UnRegisterForm() { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - if (!pDriver) - return; - pDriver->UnRegisterForm(this); -} -FX_BOOL CFWL_FormImp::IsDoModal() { - return m_bDoModalFlag; -} -void CFWL_FormImp::SetThemeData() { - m_fSmallIconSz = - *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon)); - m_fBigIconSz = - *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon)); -} -FX_BOOL CFWL_FormImp::HasIcon() { - IFWL_FormDP* pData = - static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); - return !!pData->GetIcon(m_pInterface, FALSE); -} -void CFWL_FormImp::UpdateIcon() { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return; - IFWL_FormDP* pData = - 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) { - m_pBigIcon = pBigIcon; - pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE); - } - if (pSmallIcon && pSmallIcon != m_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()); - if (!pWidgetMgr) - return; - IFWL_FormDP* pData = - static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); - if (!pData) - return; - CFX_WideString text; - pData->GetCaption(m_pInterface, text); - pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text); -} -void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, - FX_FLOAT& fWidth, - FX_FLOAT fCurX, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - FX_BOOL bLeft) { - FX_FLOAT fx = fCurX; - FX_FLOAT fy = 0; - TransformTo(NULL, fx, fy); - FX_FLOAT fTemp = - bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); - if (fTemp >= fLimitMin && fTemp <= fLimitMax) { - fWidth = fTemp; - fLeft += bLeft ? (fx - fLeft - fSpace) : 0; - } else { - if (fTemp < fLimitMin && fWidth > fLimitMin) { - fLeft += bLeft ? (fWidth - fLimitMin) : 0; - fWidth = fLimitMin; - } else if (fTemp > fLimitMax && fWidth < fLimitMax) { - fLeft -= bLeft ? (fLimitMax - fWidth) : 0; - fWidth = fLimitMax; - } - } -} -void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop, - FX_FLOAT& fHeight, - FX_FLOAT fCurY, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - FX_BOOL bTop) { - FX_FLOAT fx = 0; - FX_FLOAT fy = fCurY; - TransformTo(NULL, fx, fy); - FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); - if (fTemp >= fLimitMin && fTemp <= fLimitMax) { - fHeight = fTemp; - fTop += bTop ? (fy - fTop - fSpace) : 0; - } else { - if (fTemp < fLimitMin && fHeight > fLimitMin) { - fTop += bTop ? (fHeight - fLimitMin) : 0; - fHeight = fLimitMin; - } else if (fTemp > fLimitMax && fHeight < fLimitMax) { - fTop -= bTop ? (fLimitMax - fHeight) : 0; - fHeight = fLimitMax; - } - } -} -CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner) - : m_pOwner(pOwner) {} -int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { -#ifdef FWL_UseMacSystemBorder - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; - m_pOwner->Repaint(&m_pOwner->m_rtRelative); - break; - } - case FWL_MSGHASH_Deactivate: { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; - m_pOwner->Repaint(&m_pOwner->m_rtRelative); - break; - } - } - return FWL_ERR_Succeeded; -#else - if (!pMessage) - return 0; - FX_DWORD dwMsgCode = pMessage->GetClassID(); - int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; - IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread(); - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); - IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; - if (pSubFocus && pSubFocus != pDriver->GetFocus()) { - pDriver->SetFocus(pSubFocus); - } - m_pOwner->Repaint(&m_pOwner->m_rtRelative); - break; - } - case FWL_MSGHASH_Deactivate: { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; - IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread(); - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); - IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; - if (pSubFocus) { - if (pSubFocus == pDriver->GetFocus()) { - pDriver->SetFocus(NULL); - } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { - CFWL_MsgKillFocus ms; - IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessMessage(&ms); - } - } - } - m_pOwner->Repaint(&m_pOwner->m_rtRelative); - break; - } - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - switch (pMsg->m_dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMsg); - break; - } - case FWL_MSGMOUSECMD_MouseHover: { - OnMouseHover(pMsg); - break; - } - case FWL_MSGMOUSECMD_MouseLeave: { - OnMouseLeave(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonDblClk: { - OnLButtonDblClk(pMsg); - break; - } - } - break; - } - case FWL_MSGHASH_Size: { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return 0; - pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); - 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.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: { - OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); - break; - } - case FWL_MSGHASH_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) { - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOwner->DrawWidget(pGraphics, pMatrix); -} -void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { - m_pOwner->SetGrab(TRUE); - m_pOwner->m_bLButtonDown = TRUE; - m_pOwner->m_eResizeType = FORM_RESIZETYPE_None; - CFWL_SysBtn* pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn); - 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 - - 2 * m_pOwner->m_fCYBorder, - m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder); - if (pPressBtn) { - pPressBtn->SetPressed(); - m_pOwner->Repaint(&pPressBtn->m_rtBtn); - } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap; - } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && - (m_pOwner->m_pProperties->m_dwStyleExes & - FWL_STYLEEXT_FRM_Resize) && - !m_pOwner->m_bMaximized) { - m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); - } - m_pOwner->m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); - m_pOwner->m_InfoStart.m_szStart = - CFX_SizeF(m_pOwner->m_pProperties->m_rtWidget.width, - m_pOwner->m_pProperties->m_rtWidget.height); -} -void CFWL_FormImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { - m_pOwner->SetGrab(FALSE); - m_pOwner->m_bLButtonDown = FALSE; - CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - CFWL_SysBtn* pPressedBtn = - m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn); - if (!pPressedBtn || pPointBtn != pPressedBtn) { - return; - } - if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) { - pPressedBtn->SetNormal(); - } - if (pPressedBtn == m_pOwner->m_pMaxBox) { - if (m_pOwner->m_bMaximized) { - m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); - m_pOwner->Update(); - m_pOwner->Repaint(); - } else { - m_pOwner->SetWorkAreaRect(); - 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 { - CFWL_EvtClose eClose; - eClose.m_pSrcTarget = m_pOwner->m_pInterface; - m_pOwner->DispatchEvent(&eClose); - } -} -void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (m_pOwner->m_bLButtonDown) { - return; - } - if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && - (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && - !m_pOwner->m_bMaximized) { - m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); - } - CFX_RectF rtInvalidate; - rtInvalidate.Reset(); - CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - CFWL_SysBtn* pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); -#if (_FX_OS_ == _FX_MACOSX_) - { - if (pOldHover && pPointBtn != pOldHover) { - pOldHover->SetNormal(); - } - if (pPointBtn && pPointBtn != pOldHover) { - pPointBtn->SetHover(); - } - if (m_pOwner->m_pCloseBox) { - rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn; - } - if (m_pOwner->m_pMaxBox) { - if (rtInvalidate.IsEmpty()) { - rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn; - } else { - rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn); - } - } - if (m_pOwner->m_pMinBox) { - if (rtInvalidate.IsEmpty()) { - rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn; - } else { - rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn); - } - } - if (!rtInvalidate.IsEmpty() && - rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_pOwner->m_bMouseIn = TRUE; - } - } -#else - { - if (pOldHover && pPointBtn != pOldHover) { - pOldHover->SetNormal(); - rtInvalidate = pOldHover->m_rtBtn; - } - if (pPointBtn && pPointBtn != pOldHover) { - pPointBtn->SetHover(); - if (rtInvalidate.IsEmpty()) { - rtInvalidate = pPointBtn->m_rtBtn; - } else { - rtInvalidate.Union(pPointBtn->m_rtBtn); - } - } - } -#endif - if (!rtInvalidate.IsEmpty()) { - m_pOwner->Repaint(&rtInvalidate); - } -} -void CFWL_FormImpDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) { - m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); -} -void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { - CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); - if (pHover) { - pHover->SetNormal(); - m_pOwner->Repaint(&pHover->m_rtBtn); - } - if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && - !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) { - if (m_pOwner->m_bMaximized) { - m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); - } else { - m_pOwner->SetWorkAreaRect(); - } - m_pOwner->Update(); - m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; - } -} -void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { - m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; - m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; -} -void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { - CFWL_EvtClose eClose; - 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/xfa/src/fwl/core/fwl_formimp.h b/xfa/src/fwl/core/fwl_formimp.h deleted file mode 100644 index ad31da807c..0000000000 --- a/xfa/src/fwl/core/fwl_formimp.h +++ /dev/null @@ -1,193 +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_SRC_FWL_CORE_FWL_FORMIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_FORMIMP_H_ - -#include "xfa/include/fwl/core/fwl_form.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -class CFWL_NoteLoop; -class CFWL_WidgetImpProperties; -class CFWL_MsgMouse; -class IFWL_Widget; -class IFWL_ThemeProvider; -class CFWL_SysBtn; -class CFWL_FormImp; -class CFWL_FormImpDelegate; - -#define FWL_SYSBUTTONSTATE_Hover 0x0001 -#define FWL_SYSBUTTONSTATE_Pressed 0x0002 -#define FWL_SYSBUTTONSTATE_Disabled 0x0010 -class CFWL_SysBtn { - public: - CFWL_SysBtn() { - m_rtBtn.Set(0, 0, 0, 0); - 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; } - void SetNormal() { m_dwState &= 0xFFF0; } - void SetPressed() { - SetNormal(); - m_dwState |= FWL_SYSBUTTONSTATE_Pressed; - } - void SetHover() { - SetNormal(); - m_dwState |= FWL_SYSBUTTONSTATE_Hover; - } - void SetDisabled(FX_BOOL bDisabled) { - bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled - : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; - } - int32_t GetPartState() { - return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1)); - } - - CFX_RectF m_rtBtn; - FX_DWORD 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 { - public: - CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); - virtual ~CFWL_FormImp(); - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; - virtual FX_DWORD 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 FX_DWORD 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(FX_DWORD& dwCommandID); - virtual FWL_ERR EndDoModal(); - virtual FWL_ERR SetBorderRegion(CFX_Path* pPath); - virtual 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); - void RemoveSysButtons(); - void CalcContentRect(CFX_RectF& rtContent); - CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); - CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState); - CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); - int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn); - FX_FLOAT GetCaptionHeight(); - void DrawCaptionText(CFX_Graphics* pGs, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawIconImage(CFX_Graphics* pGs, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void GetEdgeRect(CFX_RectF& rtEdge); - void SetWorkAreaRect(); - void SetCursor(FX_FLOAT fx, FX_FLOAT fy); - void Layout(); - void ReSetSysBtn(); - void RegisterForm(); - void UnRegisterForm(); - FX_BOOL IsDoModal(); - void SetThemeData(); - FX_BOOL HasIcon(); - void UpdateIcon(); - void UpdateCaption(); - void DoWidthLimit(FX_FLOAT& fLeft, - FX_FLOAT& fWidth, - FX_FLOAT fCurX, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - FX_BOOL bLeft); - void DoHeightLimit(FX_FLOAT& fTop, - FX_FLOAT& fHeight, - FX_FLOAT fCurY, - FX_FLOAT fSpace, - 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; - CFX_RectF m_rtCaption; - CFX_RectF m_rtIcon; - CFWL_SysBtn* m_pCloseBox; - CFWL_SysBtn* m_pMinBox; - CFWL_SysBtn* m_pMaxBox; - CFWL_SysBtn* m_pCaptionBox; - CFWL_NoteLoop* m_pNoteLoop; - CFWL_WidgetImp* m_pSubFocus; - RestoreInfo m_InfoStart; - FX_FLOAT m_fCXBorder; - FX_FLOAT m_fCYBorder; - int32_t m_iCaptureBtn; - int32_t m_iSysBox; - int32_t m_eResizeType; - FX_BOOL m_bLButtonDown; - FX_BOOL m_bMaximized; - FX_BOOL m_bSetMaximize; - FX_BOOL m_bCustomizeLayout; - FWL_FORMSIZE m_eFormSize; - FX_BOOL m_bDoModalFlag; - FX_FLOAT m_fSmallIconSz; - FX_FLOAT m_fBigIconSz; - CFX_DIBitmap* m_pBigIcon; - CFX_DIBitmap* m_pSmallIcon; - 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; - - protected: - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseHover(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnLButtonDblClk(CFWL_MsgMouse* pMsg); - void OnWindowMove(CFWL_MsgWindowMove* pMsg); - void OnClose(CFWL_MsgClose* pMsg); - CFWL_FormImp* m_pOwner; -}; - -#endif // XFA_SRC_FWL_CORE_FWL_FORMIMP_H_ diff --git a/xfa/src/fwl/core/fwl_gridimp.cpp b/xfa/src/fwl/core/fwl_gridimp.cpp deleted file mode 100644 index 1230fa2655..0000000000 --- a/xfa/src/fwl/core/fwl_gridimp.cpp +++ /dev/null @@ -1,1378 +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/src/fwl/core/fwl_gridimp.h" - -#include "xfa/src/fwl/core/fwl_contentimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.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; -} -FX_DWORD 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/xfa/src/fwl/core/fwl_gridimp.h b/xfa/src/fwl/core/fwl_gridimp.h deleted file mode 100644 index 326b236295..0000000000 --- a/xfa/src/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_SRC_FWL_CORE_FWL_GRIDIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_GRIDIMP_H_ - -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_content.h" -#include "xfa/include/fwl/core/fwl_grid.h" -#include "xfa/src/fwl/core/fwl_contentimp.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]; - FX_DWORD 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 FX_DWORD 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_SRC_FWL_CORE_FWL_GRIDIMP_H_ diff --git a/xfa/src/fwl/core/fwl_noteimp.cpp b/xfa/src/fwl/core/fwl_noteimp.cpp deleted file mode 100644 index 3a46446362..0000000000 --- a/xfa/src/fwl/core/fwl_noteimp.cpp +++ /dev/null @@ -1,1097 +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/src/fwl/core/fwl_noteimp.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/basewidget/fwl_tooltipctrl.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_grid.h" -#include "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.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) { -#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(); - if (!pDriver) - return FWL_ERR_Indefinite; - pDriver->SendNote(&ev); -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) - } -#endif - return FWL_ERR_Indefinite; -} -CFWL_WidgetImp* CFWL_NoteLoop::GetForm() { - return m_pForm; -} -FX_BOOL CFWL_NoteLoop::ContinueModal() { - return m_bContinueModal; -} -FWL_ERR 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; -} -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; - } - FX_DWORD vrKey, rValue; - while (pos) { - accel.GetNextAssoc(pos, vrKey, rValue); - FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8; - FX_DWORD 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) { - m_pForm = pForm; - return FWL_ERR_Succeeded; -} -void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand) { - CFWL_EvtMenuCommand ev; - ev.m_iCommand = dwCommand; - IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); - if (!pDriver) - return; - pDriver->SendNote(&ev); -} -CFWL_NoteDriver::CFWL_NoteDriver() - : m_sendEventCalled(0), - m_maxSize(500), - m_bFullScreen(FALSE), - m_pHover(nullptr), - m_pFocus(nullptr), - m_pGrab(nullptr), - m_hook(nullptr) { - 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)); - } - } - 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)); - } - } - return TRUE; -} -extern void FWL_PostMessageToMainRoop(CFWL_Message* pMessage); -FX_BOOL CFWL_NoteDriver::PostMessage(CFWL_Message* pMessage) { - FWL_PostMessageToMainRoop(pMessage); - return TRUE; -} -#define FWL_NoteDriver_EventKey 1100 -FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource, - FX_DWORD dwFilter) { - FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData( - (void*)(uintptr_t)FWL_NoteDriver_EventKey); - if (dwkey == 0) { - void* random = FX_Random_MT_Start(0); - dwkey = rand(); - FX_Random_MT_Close(random); - pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, - (void*)(uintptr_t)dwkey, 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; -} -FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { - FX_DWORD dwkey = (FX_DWORD)(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; -} -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 { - return FWL_GetApp(); -} -FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) { - m_noteLoopQueue.Add(pNoteLoop); - return FWL_ERR_Succeeded; -} -IFWL_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)); - m_noteLoopQueue.RemoveAt(pos - 1); - return p; -} -FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) { - if (m_pFocus == pFocus) { - return TRUE; - } - IFWL_Widget* pPrev = m_pFocus; - m_pFocus = pFocus; - if (pPrev) { - CFWL_MsgKillFocus ms; - ms.m_pDstTarget = pPrev; - ms.m_pSrcTarget = pPrev; - if (bNotify) { - ms.m_dwExtend = 1; - } - IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessMessage(&ms); - } - } - if (pFocus) { - IFWL_Widget* pWidget = - FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm); - CFWL_FormImp* pForm = - pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; - if (pForm) { - CFWL_WidgetImp* pNewFocus = - static_cast<CFWL_WidgetImp*>(pFocus->GetImpl()); - pForm->SetSubFocus(pNewFocus); - } - CFWL_MsgSetFocus ms; - ms.m_pDstTarget = pFocus; - if (bNotify) { - ms.m_dwExtend = 1; - } - IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessMessage(&ms); - } - } - return TRUE; -} -FWL_ERR 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); - } - } -#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; -} -IFWL_Widget* CFWL_NoteDriver::GetFocus() { - return m_pFocus; -} -IFWL_Widget* CFWL_NoteDriver::GetHover() { - return m_pHover; -} -void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) { - m_pHover = pHover; -} -void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) { - m_pGrab = bSet ? pGrab : NULL; -} -void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { - if (m_pFocus == pNoteTarget) { - m_pFocus = NULL; - } - if (m_pHover == pNoteTarget) { - m_pHover = NULL; - } - if (m_pGrab == pNoteTarget) { - m_pGrab = NULL; - } -} -void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { - if (m_pFocus == pNoteTarget) { - m_pFocus = NULL; - } - if (m_pHover == pNoteTarget) { - m_pHover = NULL; - } - if (m_pGrab == pNoteTarget) { - m_pGrab = NULL; - } - UnregisterEventTarget(pNoteTarget); - int32_t count = m_forms.GetSize(); - for (int32_t nIndex = 0; nIndex < count; nIndex++) { - CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]); - if (!pForm) { - continue; - } - CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); - if (!pSubFocus) - return; - if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) { - pForm->SetSubFocus(NULL); - } - } -} -void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget* pNoteTarget, - FX_BOOL bFullScreen) { - m_bFullScreen = bFullScreen; -} -FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) { - if (!pForm) - return FWL_ERR_Indefinite; - if (m_forms.Find(pForm) >= 0) { - return FWL_ERR_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; - pLoop->SetMainForm(pForm); - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) { - if (!pForm) - return FWL_ERR_Indefinite; - int32_t nIndex = m_forms.Find(pForm); - if (nIndex < 0) { - return FWL_ERR_Indefinite; - } - m_forms.RemoveAt(nIndex); - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) { - pMessage->Retain(); - m_noteQueue.Add(pMessage); - return TRUE; -} -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]); - 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); - } - pMessage->Release(); - return TRUE; -} -CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() { - int32_t size = m_noteLoopQueue.GetSize(); - if (size <= 0) - return NULL; - 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() - ? pMessage->m_pDstTarget - : GetMessageForm(pMessage->m_pDstTarget); - if (!pMessageForm) - return FALSE; - if (DispatchMessage(pMessage, pMessageForm)) { - if (pMessage->GetClassID() == FWL_MSGHASH_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: { - bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_Deactivate: { - bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage), - pMessageForm); - break; - } - case FWL_MSGHASH_SetFocus: { - bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_KillFocus: { - bRet = - DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_Key: { - bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_Mouse: { - bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_MouseWheel: { - bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm); - break; - } - case FWL_MSGHASH_Size: { - bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage)); - break; - } - case FWL_MSGHASH_Cursor: { - bRet = TRUE; - break; - } - case FWL_MSGHASH_WindowMove: { - bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage), - pMessageForm); - break; - } - case FWL_MSGHASH_DropFiles: { - bRet = - DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm); - break; - } - default: { - bRet = TRUE; - break; - } - } - if (bRet) { - IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL); - 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; - if (iTrackLoop == 1) { - if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) { - return FALSE; - } - if (pMsg->m_pSrcTarget && - pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) { - return FALSE; - } - if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) { - return FALSE; - } - return TRUE; - } - IFWL_Widget* pDst = pMsg->m_pDstTarget; - if (!pDst) - return FALSE; -#if (_FX_OS_ == _FX_MACOSX_) - if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) { - return TRUE; - } -#endif - return pDst != pMessageForm && - !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) && - !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")); -} -FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (pWidgetMgr->IsFormDisabled()) { - m_pFocus = pMsg->m_pDstTarget; - return TRUE; - } else { - IFWL_Widget* pWidget = pMsg->m_pDstTarget; - CFWL_FormImp* pForm = - pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; - if (pForm) { - CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); - if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { - pMsg->m_pDstTarget = pSubFocus->GetInterface(); - if (m_pFocus != pMsg->m_pDstTarget) { - m_pFocus = pMsg->m_pDstTarget; - return TRUE; - } - } - } - } - return FALSE; -} -FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (pWidgetMgr->IsFormDisabled()) { - if (m_pFocus == pMsg->m_pDstTarget) { - m_pFocus = NULL; - } - return TRUE; - } - IFWL_Widget* pWidget = pMsg->m_pDstTarget; - CFWL_FormImp* pForm = - pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; - if (pForm) { - CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); - if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { - pMsg->m_pDstTarget = pSubFocus->GetInterface(); - if (m_pFocus == pMsg->m_pDstTarget) { - m_pFocus = NULL; - return TRUE; - } - } - } - return FALSE; -} -FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { -#if (_FX_OS_ != _FX_MACOSX_) - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && - pMsg->m_dwKeyCode == FWL_VKEY_Tab) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); - IFWL_Widget* pFocus = m_pFocus; - if (m_pFocus) { - if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) != - pForm) { - pFocus = NULL; - } - } - FX_BOOL bFind = FALSE; - IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind); - if (!pNextTabStop) { - bFind = FALSE; - pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind); - } - if (pNextTabStop == pFocus) { - return TRUE; - } - if (pNextTabStop) { - SetFocus(pNextTabStop); - } - return TRUE; - } -#endif - if (!m_pFocus) { - if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && - pMsg->m_dwKeyCode == FWL_VKEY_Return) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); - if (defButton) { - pMsg->m_pDstTarget = defButton; - return TRUE; - } - } - return FALSE; - } - pMsg->m_pDstTarget = m_pFocus; - return TRUE; -} -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) { - return pMsg->m_pDstTarget != NULL; - } - if (pMsg->m_pDstTarget != pMessageForm) { - pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); - } - if (!DoMouseEx(pMsg, pMessageForm)) { - pMsg->m_pDstTarget = pMessageForm; - } - return TRUE; -} -FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg, - IFWL_Widget* pMessageForm) { - 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; -} -FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return FALSE; - pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth, - (FX_FLOAT)pMsg->m_iHeight); - return TRUE; -} -FX_BOOL CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove* pMsg, - IFWL_Widget* pMessageForm) { - return pMsg->m_pDstTarget == pMessageForm; -} -FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg, - IFWL_Widget* pMessageForm) { - return pMsg->m_pDstTarget == pMessageForm; -} -FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return FALSE; - IFWL_Widget* pTarget = NULL; - if (m_pGrab) - pTarget = m_pGrab; - 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) { - pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); - } - } - if (!pTarget) - return FALSE; - pMsg->m_pDstTarget = pTarget; - return TRUE; -} -void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { - IFWL_Widget* pTarget = pMsg->m_pDstTarget; - if (pTarget == m_pHover) { - return; - } - if (m_pHover) { - CFWL_MsgMouse msLeave; - msLeave.m_pDstTarget = m_pHover; - msLeave.m_fx = pMsg->m_fx; - 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); - } - if (pTarget->GetClassID() == FWL_CLASSHASH_Form) { - m_pHover = NULL; - return; - } - m_pHover = pTarget; - CFWL_MsgMouse msHover; - msHover.m_pDstTarget = pTarget; - 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); -} -FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { - if (pMessage->GetClassID() == FWL_MSGHASH_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)) { - 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) { - 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; - 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; - } - if (!pMessageForm && pDstTarget) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - if (!pWidgetMgr) - return NULL; - 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; - } - } -} -class CFWL_CoreToopTipDP : public IFWL_ToolTipDP { - public: - FWL_ERR 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); - CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget); - CFX_RectF GetAnchor(); - CFWL_CoreToopTipDP(); - - CFX_WideString m_wsCaption; - int32_t m_nInitDelayTime; - int32_t m_nAutoPopDelayTime; - CFX_RectF m_fAnchor; -}; -CFWL_CoreToopTipDP::CFWL_CoreToopTipDP() { - m_nInitDelayTime = 500; - m_nAutoPopDelayTime = 50000; - m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); -} -FWL_ERR CFWL_CoreToopTipDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsCaption; - return FWL_ERR_Succeeded; -} -int32_t CFWL_CoreToopTipDP::GetInitialDelay(IFWL_Widget* pWidget) { - return m_nInitDelayTime; -} -int32_t CFWL_CoreToopTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { - return m_nAutoPopDelayTime; -} -CFX_DIBitmap* CFWL_CoreToopTipDP::GetToolTipIcon(IFWL_Widget* pWidget) { - return NULL; -} -CFX_SizeF CFWL_CoreToopTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) { - return CFX_SizeF(); -} -CFX_RectF CFWL_CoreToopTipDP::GetAnchor() { - return m_fAnchor; -} -CFWL_EventTarget::~CFWL_EventTarget() { - m_eventSources.RemoveAll(); -} -int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, - FX_DWORD dwFilter) { - if (pSource) { - m_eventSources.SetAt(pSource, dwFilter); - return m_eventSources.GetCount(); - } - return 1; -} -FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { - IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); - if (!pDelegate) - return FALSE; - if (m_eventSources.GetCount() == 0) { - pDelegate->OnProcessEvent(pEvent); - return TRUE; - } - FX_POSITION pos = m_eventSources.GetStartPosition(); - while (pos) { - IFWL_Widget* pSource = NULL; - FX_DWORD dwFilter = 0; - m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); - if (pSource == pEvent->m_pSrcTarget || - pEvent->GetClassID() == FWL_EVTHASH_Idle) { - if (IsFilterEvent(pEvent, dwFilter)) { - pDelegate->OnProcessEvent(pEvent); - return TRUE; - } - } - } - return FALSE; -} -FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter) { - 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; - } - } - return bRet; -} - -CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL; - -CFWL_ToolTipContainer::CFWL_ToolTipContainer() - : pCurTarget(NULL), m_pToolTipImp(NULL) { - m_ToolTipDp = new CFWL_CoreToopTipDP; - m_ToolTipDp->m_nInitDelayTime = 0; - m_ToolTipDp->m_nAutoPopDelayTime = 2000; -} -CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { - if (m_pToolTipImp) { - IFWL_ToolTip* pToolTip = - static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface()); - pToolTip->Finalize(); - delete pToolTip; - } - delete m_ToolTipDp; -} -// static -CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { - 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; - } -} -FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) { - if (m_arrWidget.Find((void*)pTarget) < 0) { - m_arrWidget.Add((void*)pTarget); - return FWL_ERR_Succeeded; - } - return FWL_ERR_Indefinite; -} -FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) { - int index = m_arrWidget.Find((void*)pTarget); - if (index >= 0) { - m_arrWidget.RemoveAt(index); - return FWL_ERR_Succeeded; - } - return FWL_ERR_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]); - if (p->GetWidget() == pWedget) { - pCurTarget = p; - return TRUE; - } - } - return FALSE; -} -FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt, - IFWL_Widget* pOwner) { - if (HasToolTip(pEvt->m_pDstTarget)) { - if (NULL == m_pToolTipImp) { - CFWL_WidgetImpProperties prop; - prop.m_pDataProvider = m_ToolTipDp; - prop.m_pOwner = pOwner; - CFX_RectF rtTooltip; - rtTooltip.Set(150, 150, 100, 50); - prop.m_rtWidget = rtTooltip; - IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr); - pToolTip->Initialize(); - m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl()); - m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0); - m_pToolTipImp->SetStates(FWL_WGTSTATE_Invisible, TRUE); - } - if (pCurTarget->IsShowed()) { - CFX_WideString wsCaption; - pCurTarget->GetCaption(wsCaption); - if (!wsCaption.IsEmpty()) { - m_ToolTipDp->m_wsCaption = wsCaption; - } - CFX_RectF rt; - CFX_SizeF sz; - pCurTarget->GetToolTipSize(sz); - if (sz.x > 0 && sz.y > 0) { - rt.width = sz.x; - rt.height = sz.y; - } else { - CFX_RectF r; - m_pToolTipImp->GetWidgetRect(r, TRUE); - rt.width = r.width; - rt.height = r.height; - } - CFX_PointF pt(pEvt->m_fx, pEvt->m_fy); - if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) { - rt.left = pt.x; - rt.top = pt.y; - m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0); - } else { - CFX_RectF rtAnchor; - pCurTarget->GetWidget()->GetClientRect(rtAnchor); - pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top); - m_pToolTipImp->SetAnchor(rtAnchor); - m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor); - } - m_pToolTipImp->SetWidgetRect(rt); - m_pToolTipImp->Update(); - m_pToolTipImp->Show(); - } - return TRUE; - } - return FALSE; -} -FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) { - if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { - m_pToolTipImp->Hide(); - pCurTarget = NULL; - return TRUE; - } - return FALSE; -} -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/xfa/src/fwl/core/fwl_noteimp.h b/xfa/src/fwl/core/fwl_noteimp.h deleted file mode 100644 index 72e1a8ef96..0000000000 --- a/xfa/src/fwl/core/fwl_noteimp.h +++ /dev/null @@ -1,157 +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_SRC_FWL_CORE_FWL_NOTEIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_NOTEIMP_H_ - -#include "xfa/include/fwl/core/fwl_note.h" - -class CFWL_WidgetImp; -class CFWL_ToolTipImp; -class CFWL_CoreToopTipDP; -class CFWL_NoteDriver; -class CFWL_EventTarget; -class CFWL_ToolTipContainer; - -class CFWL_NoteLoop : public IFWL_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_WidgetImp* GetForm(); - FX_BOOL ContinueModal(); - FWL_ERR EndModalLoop(); - FX_BOOL TranslateAccelerator(CFWL_Message* pMessage); - FWL_ERR SetMainForm(CFWL_WidgetImp* pForm); - - protected: - void GenerateCommondEvent(FX_DWORD dwCommand); - - CFWL_WidgetImp* m_pForm; - FX_BOOL m_bContinueModal; -}; -class CFWL_NoteDriver : public IFWL_NoteDriver { - public: - CFWL_NoteDriver(); - ~CFWL_NoteDriver() override; - - // IFWL_NoteDriver: - FX_BOOL SendNote(CFWL_Note* pNote) override; - FX_BOOL PostMessage(CFWL_Message* pMessage) override; - FWL_ERR RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource = NULL, - FX_DWORD 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; - - 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); - 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: - FX_BOOL DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); - FX_BOOL DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoSize(CFWL_MsgSize* pMsg); - FX_BOOL DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); - FX_BOOL DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); - void MouseSecondary(CFWL_MsgMouse* pMsg); - 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; - 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*, FX_DWORD> CFWL_EventSource; -class CFWL_EventTarget { - public: - CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener) - : m_pListener(pListener), m_pNoteDriver(pNoteDriver), m_bInvalid(FALSE) {} - ~CFWL_EventTarget(); - int32_t SetEventSource(IFWL_Widget* pSource, - FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); - FX_BOOL ProcessEvent(CFWL_Event* pEvent); - FX_BOOL IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter); - FX_BOOL IsInvalid() { return m_bInvalid; } - void FlagInvalid() { m_bInvalid = TRUE; } - - protected: - CFWL_EventSource m_eventSources; - IFWL_Widget* m_pListener; - CFWL_NoteDriver* m_pNoteDriver; - FX_BOOL m_bInvalid; -}; -class CFWL_ToolTipContainer { - public: - static CFWL_ToolTipContainer* getInstance(); - static void DeleteInstance(); - - FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget); - FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget); - IFWL_ToolTipTarget* GetCurrentToolTipTarget(); - - FX_BOOL HasToolTip(IFWL_Widget* pWidget); - - 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(); - - IFWL_ToolTipTarget* pCurTarget; - CFWL_ToolTipImp* m_pToolTipImp; - CFWL_CoreToopTipDP* m_ToolTipDp; - CFX_PtrArray m_arrWidget; - - private: - static CFWL_ToolTipContainer* s_pInstance; -}; - -#endif // XFA_SRC_FWL_CORE_FWL_NOTEIMP_H_ diff --git a/xfa/src/fwl/core/fwl_panelimp.cpp b/xfa/src/fwl/core/fwl_panelimp.cpp deleted file mode 100644 index 7d6c8ee874..0000000000 --- a/xfa/src/fwl/core/fwl_panelimp.cpp +++ /dev/null @@ -1,152 +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/src/fwl/core/fwl_panelimp.h" - -#include "xfa/include/fwl/core/fwl_content.h" -#include "xfa/include/fwl/core/fwl_grid.h" -#include "xfa/include/fwl/core/fwl_panel.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.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; -} -FX_DWORD 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/xfa/src/fwl/core/fwl_panelimp.h b/xfa/src/fwl/core/fwl_panelimp.h deleted file mode 100644 index 1bd7159054..0000000000 --- a/xfa/src/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_SRC_FWL_CORE_FWL_PANELIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_PANELIMP_H_ - -#include "xfa/src/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 FX_DWORD 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_SRC_FWL_CORE_FWL_PANELIMP_H_ diff --git a/xfa/src/fwl/core/fwl_sdadapterimp.cpp b/xfa/src/fwl/core/fwl_sdadapterimp.cpp deleted file mode 100644 index fedd6b285d..0000000000 --- a/xfa/src/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/include/fwl/adapter/fwl_sdadapterimp.h" - -#include "core/include/fxcrt/fx_system.h" -#include "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h" -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.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, - FX_DWORD 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; -} -FX_DWORD CFWL_SDAdapterWidgetMgr::GetKeyState(FX_DWORD 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/xfa/src/fwl/core/fwl_targetimp.cpp b/xfa/src/fwl/core/fwl_targetimp.cpp deleted file mode 100644 index 0c8d5fbce0..0000000000 --- a/xfa/src/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/src/fwl/core/fwl_targetimp.h" - -FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const { - return m_pImpl->GetClassName(wsClass); -} -FX_DWORD 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; -} -FX_DWORD 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/xfa/src/fwl/core/fwl_targetimp.h b/xfa/src/fwl/core/fwl_targetimp.h deleted file mode 100644 index e243d39e9b..0000000000 --- a/xfa/src/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_SRC_FWL_CORE_FWL_TARGETIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_TARGETIMP_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/include/fwl/core/fwl_target.h" - -class CFWL_TargetImp { - public: - virtual ~CFWL_TargetImp(); - - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; - virtual FX_DWORD GetClassID() const; - virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - CFWL_TargetImp(); -}; - -#endif // XFA_SRC_FWL_CORE_FWL_TARGETIMP_H_ diff --git a/xfa/src/fwl/core/fwl_threadimp.cpp b/xfa/src/fwl/core/fwl_threadimp.cpp deleted file mode 100644 index 28df34eade..0000000000 --- a/xfa/src/fwl/core/fwl_threadimp.cpp +++ /dev/null @@ -1,38 +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/src/fwl/core/fwl_threadimp.h" - -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.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/xfa/src/fwl/core/fwl_threadimp.h b/xfa/src/fwl/core/fwl_threadimp.h deleted file mode 100644 index eaf30e6350..0000000000 --- a/xfa/src/fwl/core/fwl_threadimp.h +++ /dev/null @@ -1,40 +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_SRC_FWL_CORE_FWL_THREADIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_THREADIMP_H_ - -#include "xfa/include/fwl/core/fwl_thread.h" // For FWL_HTHREAD. - -class CFWL_NoteDriver; -class IFWL_NoteDriver; - -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_SRC_FWL_CORE_FWL_THREADIMP_H_ diff --git a/xfa/src/fwl/core/fwl_timerimp.cpp b/xfa/src/fwl/core/fwl_timerimp.cpp deleted file mode 100644 index 503c0f759e..0000000000 --- a/xfa/src/fwl/core/fwl_timerimp.cpp +++ /dev/null @@ -1,36 +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/include/fwl/adapter/fwl_adapternative.h" -#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_timer.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" - -FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer, - FX_DWORD dwElapse, - FX_BOOL bImmediately) { - IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative(); - if (!pAdapterNative) - return NULL; - IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); - if (!pAdapterTimerMgr) - return NULL; - FWL_HTIMER hTimer = NULL; - pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately); - return hTimer; -} -int32_t FWL_StopTimer(FWL_HTIMER hTimer) { - IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative(); - if (!pAdapterNative) - return FWL_ERR_Indefinite; - IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); - if (!pAdapterTimerMgr) - return FWL_ERR_Indefinite; - return pAdapterTimerMgr->Stop(hTimer); -} diff --git a/xfa/src/fwl/core/fwl_widgetimp.cpp b/xfa/src/fwl/core/fwl_widgetimp.cpp deleted file mode 100644 index 32d80d1fb3..0000000000 --- a/xfa/src/fwl/core/fwl_widgetimp.cpp +++ /dev/null @@ -1,1101 +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/src/fwl/core/fwl_widgetimp.h" - -#include <algorithm> - -#include "xfa/include/fwl/adapter/fwl_adapternative.h" -#include "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h" -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/basewidget/fwl_combobox.h" -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" -#include "xfa/include/fwl/basewidget/fwl_menu.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_content.h" -#include "xfa/include/fwl/core/fwl_form.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -FWL_ERR 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) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetGlobalRect(rect); -} -FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->SetWidgetRect(rect); -} -FWL_ERR 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) { - 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) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->SetOwner(pOwner); -} -IFWL_Widget* IFWL_Widget::GetOuter() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOuter(); -} -FX_DWORD IFWL_Widget::GetStyles() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStyles(); -} -FWL_ERR IFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, - FX_DWORD dwStylesRemoved) { - return static_cast<CFWL_WidgetImp*>(GetImpl()) - ->ModifyStyles(dwStylesAdded, dwStylesRemoved); -} -FX_DWORD IFWL_Widget::GetStylesEx() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx(); -} -FWL_ERR IFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - return static_cast<CFWL_WidgetImp*>(GetImpl()) - ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -FX_DWORD IFWL_Widget::GetStates() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates(); -} -FWL_ERR IFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet); -} -FWL_ERR 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() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->Update(); -} -FWL_ERR IFWL_Widget::LockUpdate() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->LockUpdate(); -} -FWL_ERR IFWL_Widget::UnlockUpdate() { - return static_cast<CFWL_WidgetImp*>(GetImpl())->UnlockUpdate(); -} -FX_DWORD 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) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, fx, fy); -} -FWL_ERR 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) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetMatrix(matrix, bGlobal); -} -FWL_ERR 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) { - 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) { - return static_cast<CFWL_WidgetImp*>(GetImpl()) - ->SetThemeProvider(pThemeProvider); -} -FWL_ERR 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(); -} -CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { - return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); -} -FWL_ERR CFWL_WidgetImp::Initialize() { - IFWL_App* pApp = FWL_GetApp(); - if (!pApp) - return FWL_ERR_Indefinite; - IFWL_AdapterNative* 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())); - 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); - } - return FWL_ERR_Succeeded; -} -FWL_ERR 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; -} -FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (bAutoSize) { - if (HasEdge()) { - FX_FLOAT fEdge = GetEdgeWidth(); - rect.Inflate(fEdge, fEdge); - } - if (HasBorder()) { - FX_FLOAT fBorder = GetBorderSize(); - rect.Inflate(fBorder, fBorder); - } - } else { - rect = m_pProperties->m_rtWidget; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) { - IFWL_Widget* pForm = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); - if (!pForm) - return FWL_ERR_Indefinite; - rect.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - if (pForm == m_pInterface) { - return FWL_ERR_Succeeded; - } - return TransformTo(pForm, rect); -} -FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { - CFX_RectF rtOld = m_pProperties->m_rtWidget; - m_pProperties->m_rtWidget = rect; - if (IsChild()) { - if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || - FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { - CFWL_EvtSizeChanged ev; - ev.m_pSrcTarget = m_pInterface; - ev.m_rtOld = rtOld; - ev.m_rtNew = rect; - IFWL_WidgetDelegate* pDelegate = SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessEvent(&ev); - } - } - return FWL_ERR_Succeeded; - } - m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { - GetEdgeRect(rect); - if (HasEdge()) { - FX_FLOAT fEdge = GetEdgeWidth(); - rect.Deflate(fEdge, fEdge); - } - return FWL_ERR_Succeeded; -} -IFWL_Widget* CFWL_WidgetImp::GetParent() { - return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent); -} -FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) { - m_pProperties->m_pParent = pParent; - m_pWidgetMgr->SetParent(pParent, m_pInterface); - return FWL_ERR_Succeeded; -} -IFWL_Widget* CFWL_WidgetImp::GetOwner() { - return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner); -} -FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) { - m_pProperties->m_pOwner = pOwner; - m_pWidgetMgr->SetOwner(pOwner, m_pInterface); - return FWL_ERR_Succeeded; -} -IFWL_Widget* CFWL_WidgetImp::GetOuter() { - return m_pOuter; -} -FX_DWORD CFWL_WidgetImp::GetStyles() { - return m_pProperties->m_dwStyles; -} -FWL_ERR CFWL_WidgetImp::ModifyStyles(FX_DWORD dwStylesAdded, - FX_DWORD dwStylesRemoved) { - m_pProperties->m_dwStyles = - (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_WidgetImp::GetStylesEx() { - return m_pProperties->m_dwStyleExes; -} -FWL_ERR CFWL_WidgetImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - m_pProperties->m_dwStyleExes = - (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_WidgetImp::GetStates() { - return m_pProperties->m_dwStates; -} -static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, - IFWL_Widget* widget, - CFWL_NoteDriver* noteDriver) { - IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); - while (child) { - noteDriver->NotifyTargetHide(child); - NotifyHideChildWidget(widgetMgr, child, noteDriver); - child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); - } -} -FWL_ERR CFWL_WidgetImp::SetStates(FX_DWORD 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); - } - } - return ret; -} -FWL_ERR 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; -} -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_ERR CFWL_WidgetImp::LockUpdate() { - m_iLock++; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::UnlockUpdate() { - if (IsLocked()) { - m_iLock--; - } - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rtClient; - GetClientRect(rtClient); - if (rtClient.Contains(fx, fy)) { - return FWL_WGTHITTEST_Client; - } - if (HasEdge()) { - CFX_RectF rtEdge; - GetEdgeRect(rtEdge); - if (rtEdge.Contains(fx, fy)) { - return FWL_WGTHITTEST_Edge; - } - } - if (HasBorder()) { - CFX_RectF rtRelative; - GetRelativeRect(rtRelative); - if (rtRelative.Contains(fx, fy)) { - return FWL_WGTHITTEST_Border; - } - } - return FWL_WGTHITTEST_Unknown; -} -FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, - FX_FLOAT& fx, - FX_FLOAT& fy) { - if (m_pWidgetMgr->IsFormDisabled()) { - CFX_SizeF szOffset; - if (IsParent(pWidget)) { - szOffset = GetOffsetFromParent(pWidget); - } else { - szOffset = pWidget->GetOffsetFromParent(m_pInterface); - szOffset.x = -szOffset.x; - szOffset.y = -szOffset.y; - } - fx += szOffset.x; - fy += szOffset.y; - return FWL_ERR_Succeeded; - } - CFX_RectF r; - CFX_Matrix m; - IFWL_Widget* parent = GetParent(); - if (parent) { - GetWidgetRect(r); - fx += r.left; - fy += r.top; - GetMatrix(m, TRUE); - m.TransformPoint(fx, fy); - } - IFWL_Widget* form1 = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); - if (!form1) - return FWL_ERR_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; - } - IFWL_Widget* form2 = - m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm); - if (!form2) - return FWL_ERR_Indefinite; - if (form1 != form2) { - form1->GetWidgetRect(r); - fx += r.left; - fy += r.top; - 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) { - pWidget->GetMatrix(m, TRUE); - CFX_Matrix m1; - m1.SetIdentity(); - m1.SetReverse(m); - m1.TransformPoint(fx, fy); - pWidget->GetWidgetRect(r); - fx -= r.left; - fy -= r.top; - } - return FWL_ERR_Succeeded; -} -FWL_ERR 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) { - if (!m_pProperties) - return FWL_ERR_Indefinite; - if (bGlobal) { - IFWL_Widget* parent = GetParent(); - CFX_PtrArray parents; - while (parent) { - parents.Add(parent); - parent = parent->GetParent(); - } - matrix.SetIdentity(); - CFX_Matrix ctmOnParent; - 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->GetMatrix(ctmOnParent, FALSE); - parent->GetWidgetRect(rect); - matrix.Concat(ctmOnParent, TRUE); - matrix.Translate(rect.left, rect.top, TRUE); - } - matrix.Concat(m_pProperties->m_ctmOnParent, TRUE); - parents.RemoveAll(); - } else { - matrix = m_pProperties->m_ctmOnParent; - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) { - if (!m_pProperties) - return FWL_ERR_Indefinite; - IFWL_Widget* parent = GetParent(); - if (!parent) { - return FWL_ERR_Indefinite; - } - m_pProperties->m_ctmOnParent = matrix; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return FWL_ERR_Indefinite; -} -IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() { - return m_pProperties->m_pThemeProvider; -} -FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { - m_pProperties->m_pThemeProvider = pThemeProvider; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) { - m_pProperties->m_pDataProvider = pDataProvider; - return FWL_ERR_Succeeded; -} -IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate( - IFWL_WidgetDelegate* pDelegate) { - if (!m_pCurDelegate) { - m_pCurDelegate = m_pDelegate; - } - if (!pDelegate) { - return m_pCurDelegate; - } - IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; - m_pCurDelegate = pDelegate; - return pOldDelegate; -} -IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const { - return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface()); -} -FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) { - m_pOwnerThread = pOwnerThread; - return FWL_ERR_Succeeded; -} -IFWL_Widget* CFWL_WidgetImp::GetInterface() const { - return m_pInterface; -} -void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { - m_pInterface = pInterface; -} -CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter) - : m_pProperties(new CFWL_WidgetImpProperties), - m_pPrivateData(NULL), - m_pDelegate(NULL), - m_pCurDelegate(NULL), - m_pOuter(pOuter), - m_pInterface(NULL), - m_iLock(0) { - *m_pProperties = properties; - m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - FXSYS_assert(m_pWidgetMgr != NULL); -} -CFWL_WidgetImp::~CFWL_WidgetImp() { - if (m_pPrivateData) { - delete m_pPrivateData; - m_pPrivateData = NULL; - } - if (m_pProperties) { - delete m_pProperties; - m_pProperties = NULL; - } -} -FX_BOOL CFWL_WidgetImp::IsEnabled() const { - return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; -} -FX_BOOL CFWL_WidgetImp::IsVisible() const { - return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; -} -FX_BOOL CFWL_WidgetImp::IsActive() const { - return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; -} -FX_BOOL CFWL_WidgetImp::IsOverLapper() const { - return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == - FWL_WGTSTYLE_OverLapper; -} -FX_BOOL CFWL_WidgetImp::IsPopup() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup); -} -FX_BOOL CFWL_WidgetImp::IsChild() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child); -} -FX_BOOL CFWL_WidgetImp::IsLocked() const { - return m_iLock > 0; -} -FX_BOOL CFWL_WidgetImp::IsOffscreen() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); -} -FX_BOOL CFWL_WidgetImp::HasBorder() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); -} -FX_BOOL CFWL_WidgetImp::HasEdge() const { - return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask); -} -void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) { - rtEdge = m_pProperties->m_rtWidget; - rtEdge.left = rtEdge.top = 0; - if (HasBorder()) { - FX_FLOAT fCX = GetBorderSize(); - FX_FLOAT fCY = GetBorderSize(FALSE); - rtEdge.Deflate(fCX, fCY); - } -} -FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) { - FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( - bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder)); - if (!pfBorder) - return 0; - return *pfBorder; -} -FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() { - FX_DWORD dwCapacity = 0; - switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) { - case FWL_WGTSTYLE_EdgeFlat: { - dwCapacity = FWL_WGTCAPACITY_EdgeFlat; - break; - } - case FWL_WGTSTYLE_EdgeRaised: { - dwCapacity = FWL_WGTCAPACITY_EdgeRaised; - break; - } - case FWL_WGTSTYLE_EdgeSunken: { - dwCapacity = FWL_WGTCAPACITY_EdgeSunken; - break; - } - } - if (dwCapacity > 0) { - FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); - return fRet ? *fRet : 0; - } - return 0; -} -void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) { - rect = m_pProperties->m_rtWidget; - rect.left = rect.top = 0; -} -void* CFWL_WidgetImp::GetThemeCapacity(FX_DWORD dwCapacity) { - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - if (!pTheme) - return NULL; - CFWL_ThemePart part; - part.m_pWidget = m_pInterface; - return pTheme->GetCapacity(&part, dwCapacity); -} -IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { - if (m_pProperties->m_pThemeProvider) { - return m_pProperties->m_pThemeProvider; - } - IFWL_Widget* pUp = m_pInterface; - do { - FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) - ? FWL_WGTRELATION_Owner - : FWL_WGTRELATION_Parent; - pUp = m_pWidgetMgr->GetWidget(pUp, relation); - if (pUp) { - IFWL_ThemeProvider* pRet = pUp->GetThemeProvider(); - if (pRet && pRet->IsValidWidget(m_pInterface)) { - return pRet; - } - } - } while (pUp); - return FWL_GetApp()->GetThemeProvider(); -} -CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() { - IFWL_Widget* pRet = m_pOuter; - if (!pRet) - return nullptr; - while (IFWL_Widget* pOuter = pRet->GetOuter()) { - pRet = pOuter; - } - return static_cast<CFWL_WidgetImp*>(pRet->GetImpl()); -} -#define FWL_WGT_CalcHeight 2048 -#define FWL_WGT_CalcWidth 2048 -#define FWL_WGT_CalcMultiLineDefWidth 120.0f -CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString& wsText, - IFWL_ThemeProvider* pTheme, - FX_BOOL bMultiLine, - int32_t iLineWidth) { - if (!pTheme) - return CFX_SizeF(); - - CFWL_ThemeText calPart; - calPart.m_pWidget = m_pInterface; - calPart.m_wsText = wsText; - calPart.m_dwTTOStyles = - bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; - calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - CFX_RectF rect; - FX_FLOAT fWidth = bMultiLine - ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth - : FWL_WGT_CalcMultiLineDefWidth) - : FWL_WGT_CalcWidth; - rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); - pTheme->CalcTextRect(&calPart, rect); - return CFX_SizeF(rect.width, rect.height); -} -void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText, - IFWL_ThemeProvider* pTheme, - FX_DWORD dwTTOStyles, - int32_t iTTOAlign, - CFX_RectF& rect) { - CFWL_ThemeText calPart; - calPart.m_pWidget = m_pInterface; - calPart.m_wsText = wsText; - calPart.m_dwTTOStyles = dwTTOStyles; - calPart.m_iTTOAlign = iTTOAlign; - pTheme->CalcTextRect(&calPart, rect); -} -void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { - if (m_pWidgetMgr->IsFormDisabled()) - return; - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - if (!pDriver) - return; - IFWL_Widget* curFocus = pDriver->GetFocus(); - if (bFocus && curFocus != m_pInterface) { - pDriver->SetFocus(m_pInterface); - } else if (!bFocus && curFocus == m_pInterface) { - pDriver->SetFocus(NULL); - } -} -void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->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()) { - return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, - fMaxHeight, rtAnchor, rtPopup); - } else { - return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); - } - } - return FALSE; -} -FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - FX_FLOAT fx = 0; - FX_FLOAT fy = 0; - FX_FLOAT fScreenWidth = 0; - FX_FLOAT fScreenHeight = 0; - GetScreenSize(fScreenWidth, fScreenHeight); - if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { - FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; - FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; - TransformTo(NULL, fx, fy); - if (fRight + fx > fScreenWidth || bLeft) { - rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, - rtPopup.height); - } else { - rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, - rtPopup.height); - } - } else { - FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; - TransformTo(NULL, fx, fy); - if (fBottom + fy > fScreenHeight) { - rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, - rtPopup.height); - } else { - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, - rtPopup.height); - } - } - rtPopup.Offset(fx, fy); - return TRUE; -} -FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - FX_FLOAT fx = 0; - FX_FLOAT fy = 0; - FX_FLOAT fScreenWidth = 0; - FX_FLOAT fScreenHeight = 0; - GetScreenSize(fScreenWidth, fScreenHeight); - FX_FLOAT fPopHeight = rtPopup.height; - if (rtPopup.height > fMaxHeight) { - fPopHeight = fMaxHeight; - } else if (rtPopup.height < fMinHeight) { - fPopHeight = fMinHeight; - } - FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); - FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; - TransformTo(NULL, fx, fy); - if (fBottom + fy > fScreenHeight) { - rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); - } else { - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); - } - rtPopup.Offset(fx, fy); - return TRUE; -} -FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - FX_FLOAT fx = 0; - FX_FLOAT fy = 0; - FX_FLOAT fScreenWidth = 0; - FX_FLOAT fScreenHeight = 0; - GetScreenSize(fScreenWidth, fScreenHeight); - TransformTo(NULL, fx, fy); - if (rtAnchor.bottom() + fy > fScreenHeight) { - rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, - rtPopup.height); - } else { - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, - rtPopup.height); - } - rtPopup.Offset(fx, fy); - return TRUE; -} -FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { - return FALSE; -} -void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, - FX_DWORD dwFilter) { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); -} -void CFWL_WidgetImp::UnregisterEventTarget() { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - pNoteDriver->UnregisterEventTarget(m_pInterface); -} -void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { - if (!pNote) - return; - CFWL_EvtKey* pEvent = new CFWL_EvtKey; - pEvent->m_pSrcTarget = m_pInterface; - pEvent->m_dwCmd = pNote->m_dwCmd; - pEvent->m_dwKeyCode = pNote->m_dwKeyCode; - pEvent->m_dwFlags = pNote->m_dwFlags; - DispatchEvent(pEvent); - pEvent->Release(); -} -void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { - if (m_pOuter) { - IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); - pDelegate->OnProcessEvent(pEvent); - return; - } - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - pNoteDriver->SendNote(pEvent); -} -void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { - if (pRect) { - m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); - return; - } - CFX_RectF rect; - rect = m_pProperties->m_rtWidget; - rect.left = rect.top = 0; - m_pWidgetMgr->RepaintWidget(m_pInterface, &rect); -} -void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics, - int32_t iPartBk, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFX_RectF rtRelative; - GetRelativeRect(rtRelative); - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = iPartBk; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix, TRUE); - } - param.m_rtPart = rtRelative; - pTheme->DrawBackground(¶m); -} -void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics, - int32_t iPartBorder, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFX_RectF rtRelative; - GetRelativeRect(rtRelative); - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = iPartBorder; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix, TRUE); - } - param.m_rtPart = rtRelative; - pTheme->DrawBackground(¶m); -} -void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics, - int32_t iPartEdge, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFX_RectF rtEdge; - GetEdgeRect(rtEdge); - CFWL_ThemeBackground param; - param.m_pWidget = m_pInterface; - param.m_iPart = iPartEdge; - param.m_pGraphics = pGraphics; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix, TRUE); - } - param.m_rtPart = rtEdge; - pTheme->DrawBackground(¶m); -} -void CFWL_WidgetImp::NotifyDriver() { - IFWL_NoteThread* pThread = GetOwnerThread(); - if (!pThread) - return; - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); - if (!pDriver) - return; - pDriver->NotifyTargetDestroy(m_pInterface); -} -CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { - if (pParent == GetInterface()) - return CFX_SizeF(); - - IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); - if (!pWidgetMgr) - return CFX_SizeF(); - - CFX_SizeF szRet(m_pProperties->m_rtWidget.left, - m_pProperties->m_rtWidget.top); - - IFWL_Widget* pDstWidget = GetParent(); - while (pDstWidget && pDstWidget != pParent) { - CFX_RectF rtDst; - pDstWidget->GetWidgetRect(rtDst); - szRet += CFX_SizeF(rtDst.left, rtDst.top); - pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent); - } - return szRet; -} -FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) { - IFWL_Widget* pUpWidget = GetParent(); - while (pUpWidget) { - if (pUpWidget == pParent) - return TRUE; - pUpWidget = pUpWidget->GetParent(); - } - return FALSE; -} -CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} -int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage->m_pDstTarget) - return 0; - CFWL_WidgetImp* pWidget = - static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl()); - FX_DWORD dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_Mouse: { - CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); - CFWL_EvtMouse evt; - evt.m_pSrcTarget = pWidget->m_pInterface; - evt.m_pDstTarget = pWidget->m_pInterface; - evt.m_dwCmd = pMsgMouse->m_dwCmd; - evt.m_dwFlags = pMsgMouse->m_dwFlags; - evt.m_fx = pMsgMouse->m_fx; - evt.m_fy = pMsgMouse->m_fy; - pWidget->DispatchEvent(&evt); - break; - } - case FWL_MSGHASH_MouseWheel: { - CFWL_MsgMouseWheel* pMsgMouseWheel = - static_cast<CFWL_MsgMouseWheel*>(pMessage); - CFWL_EvtMouseWheel evt; - evt.m_pSrcTarget = pWidget->m_pInterface; - evt.m_pDstTarget = pWidget->m_pInterface; - evt.m_dwFlags = pMsgMouseWheel->m_dwFlags; - evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX; - evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY; - evt.m_fx = pMsgMouseWheel->m_fx; - evt.m_fy = pMsgMouseWheel->m_fy; - pWidget->DispatchEvent(&evt); - break; - } - case FWL_MSGHASH_Key: { - CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); - CFWL_EvtKey evt; - evt.m_pSrcTarget = pWidget->m_pInterface; - evt.m_pDstTarget = pWidget->m_pInterface; - evt.m_dwKeyCode = pMsgKey->m_dwKeyCode; - evt.m_dwFlags = pMsgKey->m_dwFlags; - evt.m_dwCmd = pMsgKey->m_dwCmd; - pWidget->DispatchEvent(&evt); - break; - } - case FWL_MSGHASH_SetFocus: { - CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage); - CFWL_EvtSetFocus evt; - evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; - evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget; - evt.m_pSetFocus = pWidget->m_pInterface; - pWidget->DispatchEvent(&evt); - break; - } - case FWL_MSGHASH_KillFocus: { - CFWL_MsgKillFocus* pMsgKillFocus = - static_cast<CFWL_MsgKillFocus*>(pMessage); - CFWL_EvtKillFocus evt; - evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget; - evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; - evt.m_pKillFocus = pWidget->m_pInterface; - pWidget->DispatchEvent(&evt); - break; - } - default: {} - } - 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; -} - -// 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, FX_DWORD dwStates) { - static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStates = - dwStates; -} -void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD 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; -} diff --git a/xfa/src/fwl/core/fwl_widgetimp.h b/xfa/src/fwl/core/fwl_widgetimp.h deleted file mode 100644 index d0dcf3cfc1..0000000000 --- a/xfa/src/fwl/core/fwl_widgetimp.h +++ /dev/null @@ -1,162 +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_SRC_FWL_CORE_FWL_WIDGETIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_WIDGETIMP_H_ - -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" - -class CFWL_NoteThreadImp; -class CFWL_WidgetImpProperties; -class CFWL_WidgetMgr; -class IFWL_DataProvider; -class IFWL_ThemeProvider; -class IFWL_Widget; -class IFWL_WidgetDelegate; - -class CFWL_WidgetImp : public CFWL_TargetImp { - public: - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - 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 IFWL_Widget* GetParent(); - virtual FWL_ERR SetParent(IFWL_Widget* pParent); - virtual IFWL_Widget* GetOwner(); - virtual FWL_ERR SetOwner(IFWL_Widget* pOwner); - virtual IFWL_Widget* GetOuter(); - virtual FX_DWORD GetStyles(); - virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, - FX_DWORD dwStylesRemoved); - virtual FX_DWORD GetStylesEx(); - virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved); - virtual FX_DWORD GetStates(); - virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); - virtual FWL_ERR 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 FX_DWORD 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 IFWL_ThemeProvider* GetThemeProvider(); - virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); - virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider); - virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); - virtual IFWL_NoteThread* GetOwnerThread() const; - FWL_ERR SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread); - IFWL_Widget* GetInterface() const; - void SetInterface(IFWL_Widget* pInterface); - CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); - - protected: - CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, - IFWL_Widget* pOuter); - virtual ~CFWL_WidgetImp(); - FX_BOOL IsEnabled() const; - FX_BOOL IsVisible() const; - FX_BOOL IsActive() const; - FX_BOOL IsOverLapper() const; - FX_BOOL IsPopup() const; - FX_BOOL IsChild() const; - FX_BOOL IsLocked() const; - FX_BOOL IsOffscreen() const; - FX_BOOL HasBorder() const; - FX_BOOL HasEdge() const; - void GetEdgeRect(CFX_RectF& rtEdge); - FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE); - FX_FLOAT GetEdgeWidth(); - void GetRelativeRect(CFX_RectF& rect); - void* GetThemeCapacity(FX_DWORD dwCapacity); - IFWL_ThemeProvider* GetAvailableTheme(); - CFWL_WidgetImp* GetRootOuter(); - CFX_SizeF CalcTextSize(const CFX_WideString& wsText, - IFWL_ThemeProvider* pTheme, - FX_BOOL bMultiLine = FALSE, - int32_t iLineWidth = -1); - void CalcTextRect(const CFX_WideString& wsText, - IFWL_ThemeProvider* pTheme, - FX_DWORD dwTTOStyles, - int32_t iTTOAlign, - CFX_RectF& rect); - void SetFocus(FX_BOOL bFocus); - void SetGrab(FX_BOOL bSet); - FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); - void RegisterEventTarget(IFWL_Widget* pEventSource = NULL, - FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); - void UnregisterEventTarget(); - void DispatchKeyEvent(CFWL_MsgKey* pNote); - void DispatchEvent(CFWL_Event* pEvent); - void Repaint(const CFX_RectF* pRect = NULL); - void DrawBackground(CFX_Graphics* pGraphics, - int32_t iPartBk, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawBorder(CFX_Graphics* pGraphics, - int32_t iPartBorder, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = NULL); - void DrawEdge(CFX_Graphics* pGraphics, - int32_t 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_WidgetImpProperties* m_pProperties; - CFX_PrivateData* m_pPrivateData; - IFWL_WidgetDelegate* m_pDelegate; - IFWL_WidgetDelegate* m_pCurDelegate; - 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, FX_DWORD dwStates); - friend void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD 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; -}; - -#endif // XFA_SRC_FWL_CORE_FWL_WIDGETIMP_H_ diff --git a/xfa/src/fwl/core/fwl_widgetmgrimp.cpp b/xfa/src/fwl/core/fwl_widgetmgrimp.cpp deleted file mode 100644 index aeb655b9ad..0000000000 --- a/xfa/src/fwl/core/fwl_widgetmgrimp.cpp +++ /dev/null @@ -1,1075 +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/src/fwl/core/fwl_widgetmgrimp.h" - -#include "xfa/include/fwl/adapter/fwl_adapternative.h" -#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/core/fwl_form.h" -#include "xfa/src/fwl/core/fwl_appimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { -#if (_FX_OS_ == _FX_MACOSX_) - return FALSE; -#else - 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) { - m_pDelegate = new CFWL_WidgetMgrDelegate(this); - m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); - FXSYS_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) { - void* pWidget; - CFWL_WidgetMgrItem* pItem; - m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem); - delete pItem; - } - m_mapWidgetItem.RemoveAll(); - if (m_pDelegate) { - delete m_pDelegate; - m_pDelegate = NULL; - } -} -int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - return TravelWidgetMgr(pParentItem, NULL, NULL); -} -IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget* pParent) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - IFWL_Widget* pWidget = NULL; - TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget); - return pWidget; -} -IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget* pWidget, - FWL_WGTRELATION eRelation) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - return NULL; - } - IFWL_Widget* pRet = NULL; - switch (eRelation) { - case FWL_WGTRELATION_Parent: { - pRet = pItem->pParent ? pItem->pParent->pWidget : NULL; - break; - } - case FWL_WGTRELATION_Owner: { - pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL; - break; - } - case FWL_WGTRELATION_FirstSibling: { - pItem = pItem->pPrevious; - while (pItem && pItem->pPrevious) { - pItem = pItem->pPrevious; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_PriorSibling: { - pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL; - break; - } - case FWL_WGTRELATION_NextSibling: { - pRet = pItem->pNext ? pItem->pNext->pWidget : NULL; - break; - } - case FWL_WGTRELATION_LastSibling: { - pItem = pItem->pNext; - while (pItem && pItem->pNext) { - pItem = pItem->pNext; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_FirstChild: { - pRet = pItem->pChild ? pItem->pChild->pWidget : NULL; - break; - } - case FWL_WGTRELATION_LastChild: { - pItem = pItem->pChild; - while (pItem && pItem->pNext) { - pItem = pItem->pNext; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_SystemForm: { - while (pItem) { - if (IsAbleNative(pItem->pWidget)) { - pRet = pItem->pWidget; - break; - } - pItem = pItem->pParent; - } - break; - } - default: {} - } - return pRet; -} -int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) - return -1; - return TravelWidgetMgr(pItem->pParent, NULL, pItem); -} -FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) - return FALSE; - if (!pItem->pParent) - return FALSE; - CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; - int32_t i = 0; - while (pChild) { - if (pChild == pItem) { - if (i == nIndex) { - return TRUE; - } - if (pChild->pPrevious) { - pChild->pPrevious->pNext = pChild->pNext; - } - if (pChild->pNext) { - pChild->pNext->pPrevious = pChild->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - pItem->pNext = NULL; - pItem->pPrevious = NULL; - break; - } - if (!pChild->pNext) { - break; - } - pChild = pChild->pNext; - ++i; - } - pChild = pItem->pParent->pChild; - if (pChild) { - if (nIndex < 0) { - while (pChild->pNext) { - pChild = pChild->pNext; - } - pChild->pNext = pItem; - pItem->pPrevious = pChild; - pItem->pNext = NULL; - return TRUE; - } - i = 0; - while (i < nIndex && pChild->pNext) { - pChild = pChild->pNext; - ++i; - } - if (!pChild->pNext) { - pChild->pNext = pItem; - pItem->pPrevious = pChild; - pItem->pNext = NULL; - return TRUE; - } - if (pChild->pPrevious) { - pItem->pPrevious = pChild->pPrevious; - pChild->pPrevious->pNext = pItem; - } - pChild->pPrevious = pItem; - pItem->pNext = pChild; - if (pItem->pParent->pChild == pChild) { - pItem->pParent->pChild = pItem; - } - } else { - pItem->pParent->pChild = pItem; - pItem->pPrevious = NULL; - pItem->pNext = NULL; - } - return TRUE; -} -FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect) { - if (!m_pAdapter) - return FWL_ERR_Indefinite; - IFWL_Widget* pNative = pWidget; - CFX_RectF rect(*pRect); - if (IsFormDisabled()) { - IFWL_Widget* pOuter = pWidget->GetOuter(); - while (pOuter) { - CFX_RectF rtTemp; - pNative->GetWidgetRect(rtTemp); - rect.left += rtTemp.left; - rect.top += rtTemp.top; - pNative = pOuter; - pOuter = pOuter->GetOuter(); - } - } else if (!IsAbleNative(pWidget)) { - pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm); - if (!pNative) - return FWL_ERR_Indefinite; - pWidget->TransformTo(pNative, rect.left, rect.top); - } - AddRedrawCounts(pNative); - return m_pAdapter->RepaintWidget(pNative, &rect); -} -void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL); - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - pItem = new CFWL_WidgetMgrItem; - pItem->pWidget = pWidget; - m_mapWidgetItem.SetAt(pWidget, pItem); - } - if (pItem->pParent && pItem->pParent != pParentItem) { - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - } - pItem->pParent = pParentItem; - SetWidgetIndex(pWidget, -1); -} -void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, - IFWL_Widget* pChild, - int32_t nIndex) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - if (!pParentItem) { - pParentItem = new CFWL_WidgetMgrItem; - pParentItem->pWidget = pParent; - m_mapWidgetItem.SetAt(pParent, pParentItem); - CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL); - pParentItem->pParent = pRoot; - SetWidgetIndex(pParent, -1); - } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); - if (!pItem) { - pItem = new CFWL_WidgetMgrItem; - pItem->pWidget = pChild; - m_mapWidgetItem.SetAt(pChild, pItem); - } - if (pItem->pParent && pItem->pParent != pParentItem) { - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - } - pItem->pParent = pParentItem; - SetWidgetIndex(pChild, nIndex); -} -void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - return; - } - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent && pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - CFWL_WidgetMgrItem* pChild = pItem->pChild; - while (pChild) { - CFWL_WidgetMgrItem* pNext = pChild->pNext; - RemoveWidget(pChild->pWidget); - pChild = pNext; - } - m_mapWidgetItem.RemoveKey(pWidget); - delete pItem; -} -void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner); - if (!pParentItem) { - pParentItem = new CFWL_WidgetMgrItem; - pParentItem->pWidget = pOwner; - m_mapWidgetItem.SetAt(pOwner, pParentItem); - CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL); - pParentItem->pParent = pRoot; - SetWidgetIndex(pOwner, -1); - } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned); - if (!pItem) { - pItem = new CFWL_WidgetMgrItem; - pItem->pWidget = pOwned; - m_mapWidgetItem.SetAt(pOwned, pItem); - } - pItem->pOwner = pParentItem; -} -void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); - if (!pItem) - return; - if (pItem->pParent && pItem->pParent != pParentItem) { - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - pItem->pNext = NULL; - pItem->pPrevious = NULL; - } - 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 { - if (pTemp == pParent) { - return TRUE; - } - pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); - } 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) { - if (FWL_UseOffscreen(pWidget)) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem->iRedrawCounter++; - if (pItem->pOffscreen) { - CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); - if (pDevice && pDevice->GetBitmap()) { - CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); - if (pBitmap->GetWidth() - rect.width > 1 || - pBitmap->GetHeight() - rect.height > 1) { - delete pItem->pOffscreen; - pItem->pOffscreen = NULL; - } - } - } -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - 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); -} -IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, - FX_FLOAT x, - FX_FLOAT y) { - if (!parent) - return NULL; - FX_FLOAT x1; - FX_FLOAT y1; - IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); - while (child) { - if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { - x1 = x; - y1 = y; - CFX_Matrix matrixOnParent; - child->GetMatrix(matrixOnParent); - CFX_Matrix m; - m.SetIdentity(); - m.SetReverse(matrixOnParent); - m.TransformPoint(x1, y1); - CFX_RectF bounds; - child->GetWidgetRect(bounds); - if (bounds.Contains(x1, y1)) { - x1 -= bounds.left; - y1 -= bounds.top; - return GetWidgetAtPoint(child, x1, y1); - } - } - child = GetWidget(child, FWL_WGTRELATION_PriorSibling); - } - return parent; -} -void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!FWL_UseOffscreen(pForm)) { - return; - } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm); - if (pItem->pOffscreen) { - delete pItem->pOffscreen; - pItem->pOffscreen = NULL; - } -} -IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, - IFWL_Widget* focus, - FX_BOOL& bFind) { - IFWL_Widget* child = - FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild); - while (child) { - if (focus == child) { - bFind = TRUE; - } - if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && - (!focus || (focus != child && bFind))) { - return child; - } - IFWL_Widget* bRet = nextTab(child, focus, bFind); - if (bRet) { - return bRet; - } - child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); - } - return NULL; -} -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++; - } - 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; -} -IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( - IFWL_Widget* pRadioButton) { - if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) { - return pRadioButton; - } - IFWL_Widget* pNext = pRadioButton; - while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) { - if (pNext->GetStyles() & FWL_WGTSTYLE_Group) { - return pNext; - } - } - 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) { - return pNext; - } - } - 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) { - 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); - } - return; - } - IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); - do { - group.Add(pNext); - pNext = GetSiblingRadioButton(pNext, TRUE); - if (!pNext) { - if (pFirst->GetClassID() == 3811304691) { - pNext = pFirst; - } else { - pNext = GetSiblingRadioButton(pFirst, TRUE); - } - } - } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); -} -IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { - if ((pParent->GetClassID() == 3521614244) && - (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) && - (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { - return child; - } - IFWL_Widget* find = GetDefaultButton(child); - if (find) { - return find; - } - child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); - } - return NULL; -} -void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - (pItem->iRedrawCounter)++; -} -void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem->iRedrawCounter = 0; -} -CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(IFWL_Widget* pWidget) { - return static_cast<CFWL_WidgetMgrItem*>(m_mapWidgetItem.GetValueAt(pWidget)); -} -int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget) { - if (!pParent) { - return 0; - } - int32_t iCount = 0; - CFWL_WidgetMgrItem* pChild = pParent->pChild; - while (pChild) { - iCount++; - if (pIndex) { - if (*pIndex == 0) { - *pWidget = pChild->pWidget; - return iCount; - } - pIndex--; - } - if (pItem && pItem == pChild) { - return iCount - 1; - } - pChild = pChild->pNext; - } - if (pIndex) { - return 0; - } else if (pItem) { - return -1; - } - return iCount - 1; -} -FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { - return FALSE; - } - FX_DWORD dwStyles = pWidget->GetStyles(); - return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == - FWL_WGTSTYLE_OverLapper) || - (dwStyles & FWL_WGTSTYLE_Popup); -} -FX_BOOL CFWL_WidgetMgr::IsThreadEnabled() { - return !(m_dwCapability & FWL_WGTMGR_DisableThread); -} -FX_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(); - return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); -} -CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) - : m_pWidgetMgr(pWidgetMgr) {} -FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(FX_DWORD dwCapability) { - m_pWidgetMgr->m_dwCapability = dwCapability; - return FWL_ERR_Succeeded; -} -int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { - if (!pMessage) - return 0; - if (!pMessage->m_pDstTarget) - return 0; - IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; - IFWL_NoteThread* pNoteThread = pDstWidget->GetOwnerThread(); - if (!pNoteThread) - return 0; - CFWL_NoteDriver* pNoteDriver = - static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver()); - if (!pNoteDriver) - return 0; - if (m_pWidgetMgr->IsThreadEnabled()) { - pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); - } - if (m_pWidgetMgr->IsFormDisabled()) { - pNoteDriver->ProcessMessage(pMessage); - } else { - pNoteDriver->QueueMessage(pMessage); - } -#if (_FX_OS_ == _FX_MACOSX_) - CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); - if (pTopLoop) { - pNoteDriver->UnqueueMessage(pTopLoop); - } -#endif - if (m_pWidgetMgr->IsThreadEnabled()) { - pMessage->Release(); - } - return FWL_ERR_Succeeded; -} -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; - 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; - } - 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); - pDelegate->OnDrawWidget(pTemp, pMatrix); - pGraphics->GetClipRect(clipBounds); - clipCopy = clipBounds; -#elif(_FX_OS_ == _FX_MACOSX_) - if (m_pWidgetMgr->IsFormDisabled()) { - IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); - pDelegate->OnDrawWidget(pTemp, pMatrix); - pGraphics->GetClipRect(clipBounds); - clipCopy = clipBounds; - } 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); - } - } -#endif - if (!m_pWidgetMgr->IsFormDisabled()) { - CFX_RectF rtClient; - pWidget->GetClientRect(rtClient); - clipBounds.Intersect(rtClient); - } - 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) { - continue; - } - CFX_RectF rtWidget; - child->GetWidgetRect(rtWidget); - if (rtWidget.IsEmpty()) { - continue; - } - CFX_Matrix widgetMatrix; - CFX_RectF clipBounds(rtWidget); - if (!bFormDisable) { - child->GetMatrix(widgetMatrix, TRUE); - } - if (pMatrix) { - widgetMatrix.Concat(*pMatrix); - } - if (!bFormDisable) { - widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); - clipBounds.Intersect(rtClip); - if (clipBounds.IsEmpty()) { - continue; - } - pGraphics->SaveGraphState(); - pGraphics->SetClipRect(clipBounds); - } - widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); - IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL); - if (pDelegate) { - if (m_pWidgetMgr->IsFormDisabled() || - IsNeedRepaint(child, &widgetMatrix, rtClip)) { - pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); - } - } - 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)) { - return pGraphics; - } - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); - if (!pItem->pOffscreen) { - pItem->pOffscreen = new CFX_Graphics; - CFX_RectF rect; - pWidget->GetWidgetRect(rect); - pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, - FXDIB_Argb); - } - CFX_RectF rect; - pGraphics->GetClipRect(rect); - pItem->pOffscreen->SetClipRect(rect); - return pItem->pOffscreen; -} -void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - CFX_RectF& rtClip, - const CFX_Matrix* pMatrix) { - if (FWL_UseOffscreen(pWidget)) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); - pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, - pMatrix); -#ifdef _WIN32 - pItem->pOffscreen->ClearClip(); -#endif - } - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(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) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); - if (pItem && pItem->iRedrawCounter > 0) { - pItem->iRedrawCounter = 0; - return TRUE; - } - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget); - rtWidget.left = rtWidget.top = 0; - pMatrix->TransformRect(rtWidget); - if (!rtWidget.IntersectWith(rtDirty)) { - return FALSE; - } - IFWL_Widget* pChild = - FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); - 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]; - 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; - 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; - hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = - hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; - hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = - rtWidget.width + rtWidget.left; - hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; - hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = - hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; - hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = - hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; - hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = - rtWidget.height + rtWidget.top; - do { - CFX_RectF rect; - pChild->GetWidgetRect(rect); - CFX_RectF r = rect; - r.left += rtWidget.left; - r.top += rtWidget.top; - if (r.IsEmpty()) { - continue; - } - if (r.Contains(rtDirty)) { - return FALSE; - } - if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) { - bChildIntersectWithDirty = TRUE; - } - if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { - bOrginPtIntersectWidthChild = rect.Contains(0, 0); - } - if (rtChilds.IsEmpty()) { - rtChilds = rect; - } 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) { - continue; - } - if (!rtDirty.Contains(hitPoint[i].hitPoint)) { - hitPoint[i].bNotContainByDirty = TRUE; - continue; - } - if (r.Contains(hitPoint[i].hitPoint)) { - hitPoint[i].bNotNeedRepaint = TRUE; - } - } - } while ((pChild = FWL_GetWidgetMgr()->GetWidget( - pChild, FWL_WGTRELATION_NextSibling)) != NULL); - if (!bChildIntersectWithDirty) { - return TRUE; - } - if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { - return TRUE; - } - 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) { - repaintPoint--; - } - } - if (repaintPoint > 0) { - return TRUE; - } - pMatrix->TransformRect(rtChilds); - 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)) { - 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)) { - 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/xfa/src/fwl/core/fwl_widgetmgrimp.h b/xfa/src/fwl/core/fwl_widgetmgrimp.h deleted file mode 100644 index f3dfb36017..0000000000 --- a/xfa/src/fwl/core/fwl_widgetmgrimp.h +++ /dev/null @@ -1,170 +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_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_ -#define XFA_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_ - -#include "xfa/include/fwl/core/fwl_widgetmgr.h" - -class IFWL_Widget; -class IFWL_AdapterWidgetMgr; -class CFWL_WidgetMgrDelegate; -class IFWL_AdapterNative; - -class CFWL_WidgetMgrItem { - public: - CFWL_WidgetMgrItem() - : pParent(NULL), - pOwner(NULL), - pChild(NULL), - pPrevious(NULL), - pNext(NULL), - pWidget(NULL), - pOffscreen(NULL), - iRedrawCounter(0) -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - , - bOutsideChanged(FALSE) -#endif - { - } - ~CFWL_WidgetMgrItem() { - if (pOffscreen) { - delete pOffscreen; - pOffscreen = NULL; - } - } - CFWL_WidgetMgrItem* pParent; - CFWL_WidgetMgrItem* pOwner; - CFWL_WidgetMgrItem* pChild; - CFWL_WidgetMgrItem* pPrevious; - CFWL_WidgetMgrItem* pNext; - IFWL_Widget* pWidget; - CFX_Graphics* pOffscreen; - int32_t iRedrawCounter; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - FX_BOOL bOutsideChanged; -#endif -}; - -class CFWL_WidgetMgr : public IFWL_WidgetMgr { - public: - CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative); - ~CFWL_WidgetMgr() override; - - // IFWL_WidgetMgr: - int32_t CountWidgets(IFWL_Widget* pParent = NULL) override; - IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override; - IFWL_Widget* GetWidget(IFWL_Widget* pWidget, - 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; - FX_DWORD GetCapability() override { return m_dwCapability; } - - void AddWidget(IFWL_Widget* pWidget); - void InsertWidget(IFWL_Widget* pParent, - IFWL_Widget* pChild, - int32_t nIndex = -1); - void RemoveWidget(IFWL_Widget* pWidget); - 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); - 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); - 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; } - CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget); - FX_BOOL IsThreadEnabled(); - FX_BOOL IsFormDisabled(); - FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget, - FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); - - protected: - int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget = NULL); - FX_BOOL IsAbleNative(IFWL_Widget* pWidget); - CFX_MapPtrToPtr m_mapWidgetItem; - IFWL_AdapterWidgetMgr* m_pAdapter; - CFWL_WidgetMgrDelegate* m_pDelegate; - friend class CFWL_WidgetMgrDelegate; - FX_DWORD m_dwCapability; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - CFX_RectF m_rtScreen; -#endif -}; - -class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate { - public: - CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); - ~CFWL_WidgetMgrDelegate() override {} - - // IFWL_WidgetMgrDelegate: - FWL_ERR OnSetCapability( - FX_DWORD 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; - - protected: - void DrawChild(IFWL_Widget* pParent, - const CFX_RectF& rtClip, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix); - CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix); - void DrawWidgetAfter(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - CFX_RectF& rtClip, - const CFX_Matrix* pMatrix); - FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget, - CFX_Matrix* pMatrix, - const CFX_RectF& rtDirty); - FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget); - - CFWL_WidgetMgr* m_pWidgetMgr; -}; - -#endif // XFA_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_ diff --git a/xfa/src/fwl/lightwidget/caret.cpp b/xfa/src/fwl/lightwidget/caret.cpp deleted file mode 100644 index bb5fd4cf9e..0000000000 --- a/xfa/src/fwl/lightwidget/caret.cpp +++ /dev/null @@ -1,47 +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/include/fwl/lightwidget/caret.h" - -#include <memory> - -#include "xfa/include/fwl/basewidget/fwl_caret.h" -#include "xfa/include/fwl/lightwidget/edit.h" -#include "xfa/src/fwl/core/fwl_targetimp.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(FX_DWORD& elapse) { - return static_cast<IFWL_Caret*>(m_pIface)->GetFrequency(elapse); -} -FWL_ERR CFWL_Caret::SetFrequency(FX_DWORD 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/xfa/src/fwl/lightwidget/datetimepicker.cpp b/xfa/src/fwl/lightwidget/datetimepicker.cpp deleted file mode 100644 index 957ed87fed..0000000000 --- a/xfa/src/fwl/lightwidget/datetimepicker.cpp +++ /dev/null @@ -1,144 +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/include/fwl/lightwidget/datetimepicker.h" - -#include <memory> - -#include "xfa/include/fwl/core/fwl_error.h" -#include "xfa/include/fwl/core/fwl_note.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" - -CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { - return new CFWL_DateTimePicker; -} -FWL_ERR CFWL_DateTimePicker::Initialize( - const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker( - IFWL_DateTimePicker::Create( - m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), - nullptr)); - FWL_ERR ret = pDateTimePicker->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pDateTimePicker.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} - -FWL_ERR 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; -} -int32_t CFWL_DateTimePicker::CountSelRanges() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CountSelRanges(); -} -int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { - return static_cast<IFWL_DateTimePicker*>(m_pIface) - ->GetSelRange(nIndex, nStart); -} -FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetEditText(wsText); -} -FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditText(wsText); -} -FWL_ERR 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) { - return static_cast<IFWL_DateTimePicker*>(m_pIface) - ->SetCurSel(iYear, iMonth, iDay); -} -CFWL_DateTimePicker::CFWL_DateTimePicker() {} -CFWL_DateTimePicker::~CFWL_DateTimePicker() {} -CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() { - m_iYear = 2011; - m_iMonth = 1; - m_iDay = 1; -} -FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( - IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsData; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday( - IFWL_Widget* pWidget, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) { - iYear = m_iYear; - iMonth = m_iMonth; - iDay = m_iDay; - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_DateTimePicker::CanUndo() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanUndo(); -} -FX_BOOL CFWL_DateTimePicker::CanRedo() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanRedo(); -} -FX_BOOL CFWL_DateTimePicker::Undo() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Undo(); -} -FX_BOOL CFWL_DateTimePicker::Redo() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Redo(); -} -FX_BOOL CFWL_DateTimePicker::CanCopy() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCopy(); -} -FX_BOOL CFWL_DateTimePicker::CanCut() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCut(); -} -FX_BOOL CFWL_DateTimePicker::CanSelectAll() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanSelectAll(); -} -FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCopy); -} -FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCut); -} -FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Paste(wsPaste); -} -FX_BOOL CFWL_DateTimePicker::SelectAll() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->SelectAll(); -} -FX_BOOL CFWL_DateTimePicker::Delete() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->Delete(); -} -FX_BOOL CFWL_DateTimePicker::DeSelect() { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->DeSelect(); -} -FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetBBox(rect); -} -FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { - return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditLimit(nLimit); -} -FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - return static_cast<IFWL_DateTimePicker*>(m_pIface) - ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); -} diff --git a/xfa/src/fwl/lightwidget/tooltipctrl.cpp b/xfa/src/fwl/lightwidget/tooltipctrl.cpp deleted file mode 100644 index 5a308c4c84..0000000000 --- a/xfa/src/fwl/lightwidget/tooltipctrl.cpp +++ /dev/null @@ -1,111 +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/include/fwl/lightwidget/tooltipctrl.h" - -#include <memory> - -#include "xfa/src/fwl/core/fwl_formimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_panelimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_threadimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" - -CFWL_ToolTip* CFWL_ToolTip::Create() { - return new CFWL_ToolTip; -} -FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_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) { - return ret; - } - m_pIface = pToolTip.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { - wsCaption = m_tooltipData.m_wsCaption; - return FWL_ERR_Succeeded; -} -FWL_ERR 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) { - 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) { - 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) { - 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) { - 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); -} -FWL_ERR CFWL_ToolTip::Show() { - return static_cast<IFWL_ToolTip*>(m_pIface)->Show(); -} -FWL_ERR CFWL_ToolTip::Hide() { - return static_cast<IFWL_ToolTip*>(m_pIface)->Hide(); -} -CFWL_ToolTip::CFWL_ToolTip() {} -CFWL_ToolTip::~CFWL_ToolTip() {} -CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { - m_wsCaption = L""; - m_nInitDelayTime = 500; - m_nAutoPopDelayTime = 50000; - m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); -} -FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsCaption; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { - return m_nInitDelayTime; -} -int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { - return m_nAutoPopDelayTime; -} -CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( - IFWL_Widget* pWidget) { - return m_pBitmap; -} -CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( - IFWL_Widget* pWidget) { - return m_fIconSize; -} -CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { - return m_fAnchor; -} diff --git a/xfa/src/fwl/lightwidget/widget.cpp b/xfa/src/fwl/lightwidget/widget.cpp deleted file mode 100644 index 58fb2a71d1..0000000000 --- a/xfa/src/fwl/lightwidget/widget.cpp +++ /dev/null @@ -1,318 +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/include/fwl/lightwidget/widget.h" - -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/include/fwl/core/fwl_thread.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_noteimp.h" -#include "xfa/src/fwl/core/fwl_targetimp.h" -#include "xfa/src/fwl/core/fwl_widgetimp.h" -#include "xfa/src/fwl/core/fwl_widgetmgrimp.h" - -CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties( - IFWL_DataProvider* pDataProvider) const { - CFWL_WidgetImpProperties result; - result.m_ctmOnParent = m_ctmOnParent; - result.m_rtWidget = m_rtWidget; - result.m_dwStyles = m_dwStyles; - result.m_dwStyleExes = m_dwStyleExes; - result.m_dwStates = m_dwStates; - if (m_pParent) - result.m_pParent = m_pParent->GetWidget(); - if (m_pOwner) - result.m_pOwner = m_pOwner->GetWidget(); - result.m_pDataProvider = pDataProvider; - return result; -} -IFWL_Widget* CFWL_Widget::GetWidget() { - return m_pIface; -} -FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetClassName(wsClass); -} -FX_DWORD CFWL_Widget::GetClassID() const { - if (!m_pIface) - return 0; - return m_pIface->GetClassID(); -} -FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { - if (!m_pIface) - return FALSE; - return m_pIface->IsInstance(wsClass); -} -static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); -FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); -} -FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetWidgetRect(rect, bAutoSize); -} -FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetGlobalRect(rect); -} -FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetWidgetRect(rect); -} -FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetClientRect(rect); -} -CFWL_Widget* CFWL_Widget::GetParent() { - if (!m_pIface) - return NULL; - IFWL_Widget* parent = m_pIface->GetParent(); - if (parent) { - return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); - } - return NULL; -} -FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); -} -CFWL_Widget* CFWL_Widget::GetOwner() { - if (!m_pIface) - return NULL; - return NULL; -} -FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return FWL_ERR_Succeeded; -} -FX_DWORD CFWL_Widget::GetStyles() { - if (!m_pIface) - return 0; - return m_pIface->GetStyles(); -} -FWL_ERR CFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, - FX_DWORD dwStylesRemoved) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); -} -FX_DWORD CFWL_Widget::GetStylesEx() { - if (!m_pIface) - return 0; - return m_pIface->GetStylesEx(); -} -FWL_ERR CFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, - FX_DWORD dwStylesExRemoved) { - return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -FX_DWORD CFWL_Widget::GetStates() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetStates(); -} -FWL_ERR CFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetStates(dwStates, bSet); -} -FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetPrivateData(module_id, pData, callback); -} -void* CFWL_Widget::GetPrivateData(void* module_id) { - if (!m_pIface) - return NULL; - return m_pIface->GetPrivateData(module_id); -} -FWL_ERR CFWL_Widget::Update() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->Update(); -} -FWL_ERR CFWL_Widget::LockUpdate() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->LockUpdate(); -} -FWL_ERR CFWL_Widget::UnlockUpdate() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->UnlockUpdate(); -} -FX_DWORD CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pIface) - return 0; - return m_pIface->HitTest(fx, fy); -} -FWL_ERR 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); -} -FWL_ERR 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); -} -FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetMatrix(matrix, bGlobal); -} -FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetMatrix(matrix); -} -FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->DrawWidget(pGraphics, pMatrix); -} -IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { - if (!m_pIface) - return NULL; - m_pDelegate = m_pIface->SetDelegate(pDelegate); - return m_pDelegate; -} -CFWL_Widget::CFWL_Widget() - : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { - m_pProperties = new CFWL_WidgetProperties; - m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); - FXSYS_assert(m_pWidgetMgr != NULL); -} -CFWL_Widget::~CFWL_Widget() { - delete m_pProperties; - if (m_pIface) { - m_pIface->Finalize(); - delete m_pIface; - } -} -FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - CFX_RectF rect; - if (pRect) { - rect = *pRect; - } else { - m_pIface->GetWidgetRect(rect); - rect.left = rect.top = 0; - } - return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); -} -FWL_ERR 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(); - if (!pDriver) - return FWL_ERR_Indefinite; - if (bFocus) { - pDriver->SetFocus(m_pIface); - } else { - if (pDriver->GetFocus() == m_pIface) { - pDriver->SetFocus(NULL); - } - } - return FWL_ERR_Succeeded; -} -FWL_ERR 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(); - if (!pDriver) - return FWL_ERR_Indefinite; - pDriver->SetGrab(m_pIface, bSet); - return FWL_ERR_Succeeded; -} -void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, - FX_DWORD dwFilter) { - if (!m_pIface) - return; - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - IFWL_Widget* pEventSourceImp = - !pEventSource ? NULL : pEventSource->GetWidget(); - pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); -} -void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { - if (!m_pIface) - return; - if (m_pIface->GetOuter()) { - return; - } - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - pNoteDriver->SendNote(pEvent); -} -#define FWL_WGT_CalcHeight 2048 -#define FWL_WGT_CalcWidth 2048 -#define FWL_WGT_CalcMultiLineDefWidth 120.0f -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(); - - CFWL_ThemeText calPart; - calPart.m_pWidget = m_pIface; - calPart.m_wsText = wsText; - calPart.m_dwTTOStyles = - bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; - calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - CFX_RectF rect; - FX_FLOAT fWidth = bMultiLine - ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth - : FWL_WGT_CalcMultiLineDefWidth) - : FWL_WGT_CalcWidth; - rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); - pTheme->CalcTextRect(&calPart, rect); - return CFX_SizeF(rect.width, rect.height); -} -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; -} diff --git a/xfa/src/fwl/theme/checkboxtp.cpp b/xfa/src/fwl/theme/checkboxtp.cpp deleted file mode 100644 index ccad2bc733..0000000000 --- a/xfa/src/fwl/theme/checkboxtp.cpp +++ /dev/null @@ -1,532 +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/include/fwl/theme/checkboxtp.h" - -#include "xfa/include/fwl/basewidget/fwl_checkbox.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/src/fde/tto/fde_textout.h" - -#define CHECKBOX_SIZE_SIGNMARGIN 3 -#define CHECKBOX_SIZE_SIGNBORDER 2 -#define CHECKBOX_SIZE_SIGNPATH 100 -#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; - SetThemeData(0); -} -CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } - 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; -} -FX_DWORD CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget, - FX_DWORD dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -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 - ? FWLTHEME_CAPACITY_TextDisColor - : FWLTHEME_CAPACITY_TextColor); - return CFWL_WidgetTP::DrawText(pParams); -} -FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_CKB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CKB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CKB_Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - if (pParams->m_dwStates & FWL_PARTSTATE_CKB_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: { - 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)) { - 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); - break; - } - default: { return FALSE; } - } - return TRUE; -} -FWL_ERR CFWL_CheckBoxTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_CheckBoxTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_DWORD dwStates, - CFX_Matrix* pMatrix) { - dwStates &= 0x03; - int32_t fillMode = FXFILL_WINDING; - FX_DWORD dwStyleEx = pWidget->GetStylesEx(); - dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; - CFX_Path path; - path.Create(); - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_BOOL bClipSign = - (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_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); - } - } 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); - path.AddEllipse(rtClip); - } - } - int32_t iTheme = 1; - if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) { - iTheme = 2; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Pressed) { - iTheme = 3; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Disabled) { - iTheme = 4; - } - if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) { - iTheme += 4; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == - FWL_PARTSTATE_CKB_Neutral) { - iTheme += 8; - } - DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, - m_pThemeData->clrBoxBk[iTheme][0], - m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); -} -void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_DWORD dwStates, - CFX_Matrix* pMatrix) { - CFX_RectF rtSign(*pRtBox); - rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN); - FX_DWORD 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)) { - 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; - } - } - } - if (bCheck) { - FX_DWORD dwStyle = pWidget->GetStylesEx(); - switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { - case FWL_STYLEEXT_CKB_SignShapeCheck: { - DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCircle: { - rtSign.Deflate(1, 1); - DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCross: { - DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeDiamond: { - DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeSquare: { - DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeStar: { - DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - } - } else { - FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix); - } -} -void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - CFX_Matrix* pMatrix) { - ((CFX_RectF*)pRtSign)->Inflate(-3, -3); - FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix); -} -void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - if (!m_pCheckPath) { - initCheckPath(pRtSign->width); - } - CFX_Matrix mt; - mt.SetIdentity(); - mt.Translate(pRtSign->left, pRtSign->top); - mt.Concat(*pMatrix); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - path.AddEllipse(*pRtSign); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fRight = pRtSign->right(); - FX_FLOAT fBottom = pRtSign->bottom(); - path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom); - path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(&crFill); - pGraphics->SetLineWidth(1.0f); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fWidth = pRtSign->width; - FX_FLOAT fHeight = pRtSign->height; - FX_FLOAT fBottom = pRtSign->bottom(); - path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); - path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, fBottom); - path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, - pRtSign->height); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fBottom = pRtSign->bottom(); - FX_FLOAT fRadius = - (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); - CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, - (pRtSign->top + fBottom) / 2.0f); - FX_FLOAT px[5], py[5]; - FX_FLOAT fAngel = FX_PI / 10.0f; - for (int32_t i = 0; i < 5; i++) { - px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); - py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); - fAngel += FX_PI * 2 / 5.0f; - } - path.MoveTo(px[0], py[0]); - int32_t nNext = 0; - for (int32_t j = 0; j < 5; j++) { - nNext += 2; - if (nNext >= 5) { - nNext -= 5; - } - path.LineTo(px[nNext], py[nNext]); - } - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_BOOL bDisable, - CFX_Matrix* pMatrix) { - switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) { - case FWL_STYLEEXT_CKB_ShapeSolidSquare: { - DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenSquare: { - Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, - pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSolidCircle: { - DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenCircle: { - Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, - pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - } -} -void CFWL_CheckBoxTP::SetThemeData(FX_DWORD dwID) { - FX_DWORD* pData = (FX_DWORD*)&m_pThemeData->clrBoxBk; - if (dwID) { - *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114); - m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); - m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138); - m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26); - m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); - m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); - m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); - } else { - *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128); - m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); - m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128); - m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26); - m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); - m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); - m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); - } -} -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; - 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); - CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f); - CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f); - CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f); - CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f); - CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f); - CFX_PointF pt32(fWidth / 4.0f, fBottom); - CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f), - fBottom + fHeight * 4 / 5.0f); - CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f), - fBottom + fHeight * 4 / 5.0f); - CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f); - CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f); - CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f); - CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f); - m_pCheckPath->MoveTo(pt1.x, pt1.y); - FX_FLOAT px1 = pt12.x - pt1.x; - 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); - 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); - 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); - 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); - 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; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, 0, 0); - mt.Scale(fScale, fScale); - CFX_PathData* pData = m_pCheckPath->GetPathData(); - pData->Transform(&mt); - } -} diff --git a/xfa/src/fwl/theme/formtp.cpp b/xfa/src/fwl/theme/formtp.cpp deleted file mode 100644 index e8f3b6addc..0000000000 --- a/xfa/src/fwl/theme/formtp.cpp +++ /dev/null @@ -1,893 +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/include/fwl/theme/formtp.h" - -#include "xfa/include/fwl/core/fwl_form.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/src/fde/tto/fde_textout.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 - -CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) { - m_pThemeData = new SBThemeData; - SetThemeData(0); - m_rtDisLBorder.Reset(); - m_rtDisRBorder.Reset(); - m_rtDisBBorder.Reset(); - m_rtDisCaption.Reset(); -} -CFWL_FormTP::~CFWL_FormTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } -} -FWL_ERR CFWL_FormTP::Initialize() { - InitTTO(); - InitCaption(TRUE); - InitCaption(FALSE); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_FormTP::Finalize() { - FinalizeTTO(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } - if (m_pDeactivebitmap) { - delete m_pDeactivebitmap; - m_pDeactivebitmap = NULL; - } - return CFWL_WidgetTP::Finalize(); -} -FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - FX_DWORD dwHash = pWidget->GetClassID(); - return dwHash == FWL_CLASSHASH_Form; -} -FX_DWORD CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget, - FX_DWORD dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - InitCaption(TRUE); - InitCaption(FALSE); - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - int32_t iActive = 0; - if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) { - iActive = 1; - } - FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; - switch (pParams->m_dwStates & 0x03) { - case FWL_PARTSTATE_FRM_Hover: { - eState = FWLTHEME_STATE_Hover; - break; - } - case FWL_PARTSTATE_FRM_Pressed: { - eState = FWLTHEME_STATE_Pressed; - break; - } - case FWL_PARTSTATE_FRM_Disabled: { - eState = FWLTHEME_STATE_Disabale; - break; - } - default: {} - } - switch (pParams->m_iPart) { - case FWL_PART_FRM_Border: { - DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_FRM_Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - break; - } - case FWL_PART_FRM_Caption: { - DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_NarrowCaption: { - DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_CloseBox: { - DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_MinimizeBox: { - DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_MaximizeBox: { - DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - pParams->m_dwData, &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_Icon: { - DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart, - eState, &pParams->m_matrix, iActive); - break; - } - default: {} - } - return TRUE; -} -FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) - return FALSE; - if (pParams->m_iPart == FWL_PART_FRM_Caption) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } else { - m_pTextOut->SetTextColor(0xFF000000); - } - return CFWL_WidgetTP::DrawText(pParams); -} -void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart, - FX_DWORD dwCapacity) { - FX_BOOL bDefPro = FALSE; - FX_BOOL bDwordVal = FALSE; - switch (dwCapacity) { - case FWL_WGTCAPACITY_CXBorder: { - m_fValue = FWLTHEME_CAPACITY_CXFormBorder; - break; - } - case FWL_WGTCAPACITY_CYBorder: { - m_fValue = FWLTHEME_CAPACITY_CYFormBorder; - break; - } - case FWL_WGTCAPACITY_FRM_CYCaption: { - m_fValue = FWLTHEME_CAPACITY_CYCaption; - break; - } - case FWL_WGTCAPACITY_FRM_CYNarrowCaption: { - m_fValue = FWLTHEME_CAPACITY_CYCaption; - break; - } - case FWL_WGTCAPACITY_TextColor: { - bDwordVal = TRUE; - m_dwValue = FWLTHEME_CAPACITY_FormTextColor; - break; - } - case FWL_WGTCAPACITY_FRM_BigIcon: { - m_fValue = FWLTHEME_CAPACITY_BigIconSize; - break; - } - case FWL_WGTCAPACITY_FRM_SmallIcon: { - m_fValue = FWLTHEME_CAPACITY_SmallIconSize; - break; - } - default: { bDefPro = TRUE; } - } - if (!bDefPro) { - if (bDwordVal) { - return &m_dwValue; - } - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart, - CFX_RectF& rtPart) { - switch (pThemePart->m_iPart) { - case FWL_PART_FRM_CloseBox: { - CalCloseBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_MaximizeBox: { - CalMaxBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_MinimizeBox: { - CalMinBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_HeadText: { - CalCaption(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_Icon: { - CalIcon(pThemePart->m_pWidget, rtPart); - break; - } - default: {} - } - return FWL_ERR_Succeeded; -} -void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - FX_DWORD dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - 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); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); - } -} -void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - FX_DWORD dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - 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); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + - FWLTHEME_FORMBTN_Span * 2, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); - } -} -void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - FX_DWORD dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - 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); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + - FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 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); -} -void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {} -void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - CFX_RectF rt; - rt.Set(pRect->left, pRect->top, 1, pRect->height); - FX_FLOAT fBottom, fRight; - fBottom = pRect->bottom(); - fRight = pRect->right(); - CFX_Path path; - path.Create(); - CFX_Color clrLine; - path.Clear(); - path.MoveTo(pRect->left, pRect->top); - path.LineTo(pRect->left, fBottom - 1); - path.LineTo(fRight - 1, fBottom - 1); - path.LineTo(fRight - 1, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][2]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 1, pRect->top); - path.LineTo(pRect->left + 1, fBottom - 2); - path.LineTo(fRight - 2, fBottom - 2); - path.LineTo(fRight - 2, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][1]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 2, pRect->top); - path.LineTo(pRect->left + 2, fBottom - 3); - path.LineTo(fRight - 3, fBottom - 3); - path.LineTo(fRight - 3, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][0]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 3, pRect->top); - path.LineTo(pRect->left + 3, fBottom - 4); - path.LineTo(fRight - 4, fBottom - 4); - path.LineTo(fRight - 4, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][4]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29); - m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, - pRect->height - 29); - m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4); - m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29); -} -void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - CFX_RectF rt; - FX_FLOAT fBottom, fRight; - fBottom = pRect->bottom(); - fRight = pRect->right(); - rt.Set(pRect->left, pRect->top, pRect->width, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt, - pMatrix); - rt.Offset(0, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt, - pMatrix); - rt.Offset(0, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt, - pMatrix); - rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt, - pMatrix); - rt.Offset(0, -1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt, - pMatrix); - rt.Set(pRect->left, pRect->top, 1, pRect->height); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt, - pMatrix); - rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt, - pMatrix); - rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt, - pMatrix); - rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt, - pMatrix); - rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt, - pMatrix); - rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt, - pMatrix); - CFX_RectF rect(*pRect); - rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5); - if (iActive == 0) { - pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix); - } else { - pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix); - } -} -void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) {} -void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - pGraphics->SaveGraphState(); - CFX_RectF rt(*pRect); - pGraphics->SetLineWidth(1.0f); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); - path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); - CFX_Color crFill; - crFill = m_pThemeData->clrBtnEdgeOut[iActive]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); - path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); - path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); - path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); - crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); - path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); - crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); - path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); - crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); - DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, - fBottom - 2, - m_pThemeData->clrCloseBtBKStart[iActive][eState - 1], - m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path, - FXFILL_WINDING, pMatrix); - CFX_RectF rtX(*pRect); - rtX.Inflate(-5, -5); - path.Clear(); - FX_FLOAT frtXRight = rtX.right(); - FX_FLOAT frtXBottom = rtX.bottom(); - path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom); - path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom); - path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1); - path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top); - path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top); - path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1); - CFX_Color clrLine(0xffffffff); - pGraphics->SetLineWidth(1.0f); - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - pGraphics->SaveGraphState(); - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - CFX_RectF rt(*pRect); - pGraphics->SetLineWidth(1.0f); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); - path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); - CFX_Color crFill; - crFill = m_pThemeData->clrBtnEdgeOut[iActive]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); - path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); - path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); - path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); - crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); - path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); - crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); - path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); - crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); - path.Clear(); - path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); - DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, - fBottom - 2, - m_pThemeData->clrNormalBtBKStart[iActive][eState - 1], - m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path, - FXFILL_WINDING, pMatrix); -} -void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); - CFX_RectF rtMin; - rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14, - pRect->height - 18); - FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix); -} -void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - FX_BOOL bMax, - CFX_Matrix* pMatrix, - int32_t iActive) { - DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - if (bMax) { - CFX_Path path; - path.Create(); - path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14, - pRect->top + 6); - path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11, - pRect->top + 9); - pGraphics->SaveGraphState(); - pGraphics->SetLineWidth(2); - CFX_Color crStroke(0xFFFFFFFF); - pGraphics->SetStrokeColor(&crStroke); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->SetLineWidth(1); - path.Clear(); - path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4, - pRect->top + 14); - path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10, - pRect->top + 14); - path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13, - pRect->top + 11); - path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10, - pRect->top + 14); - path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12, - pRect->top + 11); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); - } else { - CFX_RectF rtMax(*pRect); - rtMax.Inflate(-5, -5); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10, - fHeight - 10); - path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12, - fHeight - 14); - pGraphics->SaveGraphState(); - CFX_Color crFill(0xFFFFFFFF); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); - } -} -void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics, - CFX_DIBitmap* pDIBitmap, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix); -} -void CFWL_FormTP::SetThemeData(FX_DWORD dwID) { - m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255); - m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148); - m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5); - m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176); - m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71); - m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20); - m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33); - m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107); - m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54); - m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74); - m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51); - m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28); - m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13); - if (dwID) { - m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131); - m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128); - m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94); - m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133); - m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125); - m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103); - m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79); - m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201); - m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133); - m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121); - m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103); - m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162); - m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84); - m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208); - m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112); - m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190); - m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88); - m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137); - m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83); - m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123); - m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); - m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); - m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94); - m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133); - m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127); - m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133); - } else { - m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226); - m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226); - m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200); - m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220); - m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210); - m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234); - m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193); - m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139); - m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238); - m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255); - m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252); - m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255); - m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207); - m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112); - m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188); - m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250); - m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248); - m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255); - m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255); - m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245); - m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187); - m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245); - m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195); - m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244); - m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185); - m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); - m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); - m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241); - m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220); - m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160); - m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140); - m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239); - } - m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0]; - m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0]; - m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1]; - m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1]; - m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2]; - m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2]; - m_pThemeData->clrCloseBtEdgeLight[1][0] = - m_pThemeData->clrCloseBtEdgeLight[0][0]; - m_pThemeData->clrCloseBtEdgeDark[1][0] = - m_pThemeData->clrCloseBtEdgeDark[0][0]; - m_pThemeData->clrCloseBtEdgeLight[1][1] = - m_pThemeData->clrCloseBtEdgeLight[0][1]; - m_pThemeData->clrCloseBtEdgeDark[1][1] = - m_pThemeData->clrCloseBtEdgeDark[0][1]; - m_pThemeData->clrCloseBtEdgeLight[1][2] = - m_pThemeData->clrCloseBtEdgeLight[0][2]; - m_pThemeData->clrCloseBtEdgeDark[1][2] = - m_pThemeData->clrCloseBtEdgeDark[0][2]; - m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0]; - m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1]; - m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2]; - m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3]; - m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2]; - m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1]; - m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0]; - m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0]; - m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1]; - m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2]; - m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0]; - m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1]; - m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2]; - m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0]; - m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1]; - m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2]; - m_pThemeData->clrNormalBtBKStart[1][2] = - m_pThemeData->clrNormalBtBKStart[0][2]; - m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2]; - m_pThemeData->clrNormalBtBKStart[1][0] = - m_pThemeData->clrNormalBtBKStart[0][0]; - m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0]; - m_pThemeData->clrNormalBtBKStart[1][1] = - m_pThemeData->clrNormalBtBKStart[0][1]; - m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1]; - m_pThemeData->clrNormalBtEdgeLight[1][0] = - m_pThemeData->clrNormalBtEdgeLight[0][0]; - m_pThemeData->clrNormalBtEdgeDark[1][0] = - m_pThemeData->clrNormalBtEdgeDark[0][0]; - m_pThemeData->clrNormalBtEdgeLight[1][1] = - m_pThemeData->clrNormalBtEdgeLight[0][1]; - m_pThemeData->clrNormalBtEdgeDark[1][1] = - m_pThemeData->clrNormalBtEdgeDark[0][1]; - m_pThemeData->clrNormalBtEdgeLight[1][2] = - m_pThemeData->clrNormalBtEdgeLight[0][2]; - m_pThemeData->clrNormalBtEdgeDark[1][2] = - m_pThemeData->clrNormalBtEdgeDark[0][2]; - m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0]; - m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1]; - m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2]; - m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0]; - m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0]; - m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1]; - m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2]; - m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3]; - m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4]; - m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0]; - DeactiveForm(); -} -void CFWL_FormTP::DeactiveForm() { - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][3]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][4]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorderLight[1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][2]); -} -void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) { - int32_t iAlfaF, iRF, iGF, iBF; - int32_t iAlfaB, iRB, iGB, iBB; - ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF); - ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB); - clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255, - iGB + (iGF - iGB) * iAlfaF / 255, - iBB + (iBF - iBB) * iAlfaF / 255); -} -void CFWL_FormTP::InitCaption(FX_BOOL bActive) { - if (bActive) { - CFX_FxgeDevice dev; - CFX_Graphics gs; - CFX_Path path; - path.Create(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } - m_pActiveBitmap = new CFX_DIBitmap; - m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); - dev.Attach(m_pActiveBitmap); - gs.Create(&dev); - path.AddRectangle(0, 0, 1, 5); - DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], - m_pThemeData->clrHeadBK[0][1], &path); - path.Clear(); - path.AddRectangle(0, 5, 1, 15); - 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], - 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; - } - m_pDeactivebitmap = new CFX_DIBitmap; - m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); - dev.Attach(m_pDeactivebitmap); - gs.Create(&dev); - path.AddRectangle(0, 0, 1, 5); - DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], - m_pThemeData->clrHeadBK[1][1], &path); - path.Clear(); - path.AddRectangle(0, 5, 1, 15); - 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], - m_pThemeData->clrHeadBK[1][3], &path); - } -} diff --git a/xfa/src/fwl/theme/monthcalendartp.cpp b/xfa/src/fwl/theme/monthcalendartp.cpp deleted file mode 100644 index 0dea73f675..0000000000 --- a/xfa/src/fwl/theme/monthcalendartp.cpp +++ /dev/null @@ -1,582 +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/include/fwl/theme/monthcalendartp.h" - -#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/src/fde/tto/fde_textout.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 - -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; -} -FX_DWORD CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget, - FX_DWORD dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_MCD_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Background: { - DrawTotalBK(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Header: { - DrawHeadBk(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_LBtn: { -#ifdef THEME_XPSimilar - 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 - 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: { - DrawHSeperator(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_DatesIn: { - DrawDatesInBK(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_TodayCircle: { - DrawTodayCircle(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_DateInCircle: { - DrawDatesInCircle(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_WeekNumSep: { - DrawWeekNumSep(pParams, &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) - return FALSE; - if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && - !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && - (pParams->m_dwStates & - (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } else if (pParams->m_iPart == FWL_PART_MCD_Caption) { - m_pTextOut->SetTextColor(m_pThemeData->clrCaption); - } else { - m_pTextOut->SetTextColor(0xFF000000); - } - return CFWL_WidgetTP::DrawText(pParams); -} -void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart, - FX_DWORD dwCapacity) { - FX_BOOL bDefPro = FALSE; - FX_BOOL bDwordVal = FALSE; - switch (dwCapacity) { - case FWL_WGTCAPACITY_MC_HEADER_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_Height: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: { - bDwordVal = TRUE; - m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HSEP_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_VSEP_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_WEEK_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_SEP_DOFFSET: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET; - break; - } - case FWL_WGTCAPACITY_MC_SEP_X: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_X; - break; - } - case FWL_WGTCAPACITY_MC_SEP_Y: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_Y; - break; - } - case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_WIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT; - break; - } - case FWL_WGTCAPACITY_MC_WIDTH: { - m_fValue = FWL_MC_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEIGHT: { - m_fValue = FWL_MC_HEIGHT; - break; - } - case FWL_MCCAPACITY_Sun: { - wsResource = L"Sun"; - return &wsResource; - } - case FWL_MCCAPACITY_Mon: { - wsResource = L"Mon"; - return &wsResource; - } - case FWL_MCCAPACITY_Tue: { - wsResource = L"Tue"; - return &wsResource; - } - case FWL_MCCAPACITY_Wed: { - wsResource = L"Wed"; - return &wsResource; - } - case FWL_MCCAPACITY_Thu: { - wsResource = L"Thu"; - return &wsResource; - } - case FWL_MCCAPACITY_Fri: { - wsResource = L"Fri"; - return &wsResource; - } - case FWL_MCCAPACITY_Sat: { - wsResource = L"Sat"; - return &wsResource; - } - case FWL_MCCAPACITY_January: { - wsResource = L"January"; - return &wsResource; - } - case FWL_MCCAPACITY_February: { - wsResource = L"February"; - return &wsResource; - } - case FWL_MCCAPACITY_March: { - wsResource = L"March"; - return &wsResource; - } - case FWL_MCCAPACITY_April: { - wsResource = L"April"; - return &wsResource; - } - case FWL_MCCAPACITY_May: { - wsResource = L"May"; - return &wsResource; - } - case FWL_MCCAPACITY_June: { - wsResource = L"June"; - return &wsResource; - } - case FWL_MCCAPACITY_July: { - wsResource = L"July"; - return &wsResource; - } - case FWL_MCCAPACITY_August: { - wsResource = L"August"; - return &wsResource; - } - case FWL_MCCAPACITY_September: { - wsResource = L"September"; - return &wsResource; - } - case FWL_MCCAPACITY_October: { - wsResource = L"October"; - return &wsResource; - } - case FWL_MCCAPACITY_November: { - wsResource = L"November"; - return &wsResource; - } - case FWL_MCCAPACITY_December: { - wsResource = L"December"; - return &wsResource; - } - case FWL_MCCAPACITY_Today: { - wsResource = L"Today"; - return &wsResource; - } - default: { bDefPro = TRUE; } - } - if (!bDefPro) { - if (bDwordVal) { - return &m_dwValue; - } - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -FWL_ERR CFWL_MonthCalendarTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_MonthCalendarTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtTotal(pParams->m_rtPart); - path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrBK(m_pThemeData->clrBK); - pParams->m_pGraphics->SetFillColor(&clrBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtHead = pParams->m_rtPart; - path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHeadBK(m_pThemeData->clrBK); - pParams->m_pGraphics->SetFillColor(&clrHeadBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtLBtn; - rtLBtn = pParams->m_rtPart; - path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); - pParams->m_pGraphics->SaveGraphState(); - 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) { - CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242)); - pParams->m_pGraphics->SetFillColor(&clrLBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249)); - pParams->m_pGraphics->SetFillColor(&clrLBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - path.Clear(); - path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.top + rtLBtn.height / 4); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.bottom() - rtLBtn.height / 4); - CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); - pParams->m_pGraphics->SetStrokeColor(&clrFlag); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtRBtn; - rtRBtn = pParams->m_rtPart; - path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); - pParams->m_pGraphics->SaveGraphState(); - 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) { - CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242)); - pParams->m_pGraphics->SetFillColor(&clrRBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249)); - pParams->m_pGraphics->SetFillColor(&clrRBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - path.Clear(); - path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, - rtRBtn.top + rtRBtn.height / 2); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, - rtRBtn.bottom() - rtRBtn.height / 4); - CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); - pParams->m_pGraphics->SetStrokeColor(&clrFlag); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtHSep; - rtHSep = pParams->m_rtPart; - path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); - path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHSep(m_pThemeData->clrSeperator); - pParams->m_pGraphics->SetStrokeColor(&clrHSep); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtWeekSep; - rtWeekSep = pParams->m_rtPart; - path.MoveTo(rtWeekSep.left, rtWeekSep.top); - path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHSep(m_pThemeData->clrSeperator); - pParams->m_pGraphics->SetStrokeColor(&clrHSep); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - pParams->m_pGraphics->SaveGraphState(); - if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - CFX_Color clrSelDayBK; - 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) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesHoverBK; - pParams->m_pGraphics->SetFillColor(&clrSelDayBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - pParams->m_pGraphics->RestoreGraphState(); - return FALSE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesCircle; - pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtTodayCircle; - rtTodayCircle = pParams->m_rtPart; - path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, - rtTodayCircle.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrTodayCircle; - clrTodayCircle = m_pThemeData->clrDatesCircle; - pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(FX_DWORD dwFWLStates) { - if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) { - return FWLTHEME_STATE_Hover; - } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) { - return FWLTHEME_STATE_Pressed; - } - return FWLTHEME_STATE_Normal; -} -void CFWL_MonthCalendarTP::SetThemeData(FX_DWORD dwThemeID) { - if (dwThemeID == 0) { - m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255); - m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239); - m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251); - m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239); - m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209); - m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); - m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); - } else { - m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0); - m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64); - m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191); - m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183); - m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0); - m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); - m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); - } -} diff --git a/xfa/src/fwl/theme/widgettp.cpp b/xfa/src/fwl/theme/widgettp.cpp deleted file mode 100644 index c26a62c561..0000000000 --- a/xfa/src/fwl/theme/widgettp.cpp +++ /dev/null @@ -1,840 +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/include/fwl/theme/widgettp.h" - -#include <algorithm> - -#include "xfa/include/fwl/core/fwl_widgetmgr.h" -#include "xfa/src/fde/tto/fde_textout.h" - -static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { - IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); - IFWL_Widget* pChild = - pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); - while (pChild) { - IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); - if (pTheme) { - pTheme->SetThemeID(pChild, dwThemeID, FALSE); - } - FWL_SetChildThemeID(pChild, dwThemeID); - pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); - } -} -FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { - return FALSE; -} -FX_DWORD CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { - return m_dwThemeID; -} -FX_DWORD CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, - FX_DWORD dwThemeID, - FX_BOOL bChildren) { - FX_DWORD dwOld = m_dwThemeID; - m_dwThemeID = dwThemeID; - if (CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); - } - if (bChildren) { - FWL_SetChildThemeID(pWidget, dwThemeID); - } - return dwOld; -} -FWL_ERR 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; -} -FWL_ERR 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; -} -FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { - return TRUE; -} -FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) { - InitTTO(); - } - int32_t iLen = pParams->m_wsText.GetLength(); - if (iLen <= 0) - return FALSE; - CFX_Graphics* pGraphics = pParams->m_pGraphics; - m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - CFX_Matrix* pMatrix = &pParams->m_matrix; - pMatrix->Concat(*pGraphics->GetMatrix()); - m_pTextOut->SetMatrix(*pMatrix); - m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); - return TRUE; -} -void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, - FX_DWORD dwCapacity) { - switch (dwCapacity) { - case FWL_WGTCAPACITY_CXBorder: { - m_fValue = FWLTHEME_CAPACITY_CXBorder; - break; - } - case FWL_WGTCAPACITY_CYBorder: { - m_fValue = FWLTHEME_CAPACITY_CYBorder; - break; - } - case FWL_WGTCAPACITY_EdgeFlat: { - m_fValue = FWLTHEME_CAPACITY_EdgeFlat; - break; - } - case FWL_WGTCAPACITY_EdgeRaised: { - m_fValue = FWLTHEME_CAPACITY_EdgeRaised; - break; - } - case FWL_WGTCAPACITY_EdgeSunken: { - m_fValue = FWLTHEME_CAPACITY_EdgeSunken; - break; - } - case FWL_WGTCAPACITY_FontSize: { - m_fValue = FWLTHEME_CAPACITY_FontSize; - break; - } - case FWL_WGTCAPACITY_TextColor: { - m_dwValue = FWLTHEME_CAPACITY_TextColor; - return &m_dwValue; - } - case FWL_WGTCAPACITY_ScrollBarWidth: { - m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth; - break; - } - case FWL_WGTCAPACITY_Font: { - return m_pFDEFont; - } - case FWL_WGTCAPACITY_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; - break; - } - case FWL_WGTCAPACITY_UIMargin: { - m_rtMargin.Set(0, 0, 0, 0); - return &m_rtMargin; - } - default: { return NULL; } - } - return &m_fValue; -} -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; -} -FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy) { - return TRUE; -} -FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { - if (!pParams) - return FALSE; - if (!m_pTextOut) - 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); - return TRUE; -} -FWL_ERR CFWL_WidgetTP::Initialize() { - m_dwThemeID = 0; - _ctm.SetIdentity(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetTP::Finalize() { - if (!m_pTextOut) { - FinalizeTTO(); - } - return FWL_ERR_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; - } - 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; - } - m_pTextOut->SetFont(pFont); - m_pTextOut->SetFontSize(fFontSize); - m_pTextOut->SetTextColor(rgbFont); - return FWL_ERR_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_pFDEFont = - CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); - m_pTextOut = IFDE_TextOut::Create(); - 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; -} -FX_ERR CFWL_WidgetTP::FinalizeTTO() { - if (m_pTextOut) { - m_pTextOut->Release(); - m_pTextOut = NULL; - } - return FWL_ERR_Succeeded; -} -#ifdef THEME_XPSimilar -void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, - FX_DWORD dwStyles, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 - ? ArgbEncode(255, 127, 157, 185) - : FWLTHEME_COLOR_Green_BKSelected); - pGraphics->SetStrokeColor(&crStroke); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, - pRect->height - 1); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - crStroke = ArgbEncode(255, 255, 255, 255); - pGraphics->SetStrokeColor(&crStroke); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, - pRect->height - 3); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -#else -void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, - FX_DWORD 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, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - if (eType == FWLTHEME_EDGE_Flat) { - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - CFX_Color cr(ArgbEncode(255, 100, 100, 100)); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4, - pRect->height - 4); - cr.Set(0xFFFFFFFF); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - FX_FLOAT fLeft = pRect->left; - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fTop = pRect->top; - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fHalfWidth = fWidth / 2.0f; - CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); - pGraphics->SetFillColor(&crLT); - CFX_Path pathLT; - pathLT.Create(); - pathLT.MoveTo(fLeft, fBottom - fHalfWidth); - pathLT.LineTo(fLeft, fTop); - pathLT.LineTo(fRight - fHalfWidth, fTop); - pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); - pathLT.LineTo(fLeft, fBottom - fHalfWidth); - pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); - pGraphics->SetFillColor(&crLT); - pathLT.Clear(); - pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth); - pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth); - pathLT.LineTo(fRight - fWidth, fTop + fWidth); - pathLT.LineTo(fLeft + fWidth, fTop + fWidth); - pathLT.LineTo(fLeft + fWidth, fBottom - fWidth); - pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth); - pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); - pGraphics->SetFillColor(&crRB); - CFX_Path pathRB; - pathRB.Create(); - pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth); - pathRB.LineTo(fRight - fWidth, fBottom - fWidth); - pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); - pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); - crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); - pGraphics->SetFillColor(&crRB); - pathRB.Clear(); - pathRB.MoveTo(fRight, fTop); - pathRB.LineTo(fRight, fBottom); - pathRB.LineTo(fLeft, fBottom); - pathRB.LineTo(fLeft, fBottom - fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fTop); - pathRB.LineTo(fRight, fTop); - pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); - } - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics, - FWLTHEME_EDGE eType, - FX_FLOAT fWidth, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Path path; - path.Create(); - path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, - FWLTHEME_PI * 3 / 4, FWLTHEME_PI); - CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); - pGraphics->SetStrokeColor(&crFill1); - pGraphics->StrokePath(&path, pMatrix); - CFX_RectF rtInner(*pRect); - 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); - 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); - 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); - CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); - pGraphics->SetStrokeColor(&crFill4); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - pGraphics->SaveGraphState(); - CFX_Color crFill(ArgbEncode(255, 0, 0, 0)); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::FillBackground(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix); -} -void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color crFill(fillColor); - pGraphics->SetFillColor(&crFill); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, - FX_FLOAT fx1, - FX_FLOAT fy1, - FX_FLOAT fx2, - FX_FLOAT fy2, - FX_ARGB beginColor, - FX_ARGB endColor, - CFX_Path* path, - int32_t fillMode, - CFX_Matrix* pMatrix) { - if (!pGraphics || !path) - return; - - CFX_PointF begPoint(fx1, fy1); - CFX_PointF endPoint(fx2, fy2); - CFX_Shading shading; - shading.CreateAxial(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); - pGraphics->SaveGraphState(); - CFX_Color color1(&shading); - pGraphics->SetFillColor(&color1); - pGraphics->FillPath(path, fillMode, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fRingWidth, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color cr(fillColor); - pGraphics->SetFillColor(&cr); - CFX_Path path; - path.Create(); - CFX_RectF rtInner(*pRect); - rtInner.Deflate(fRingWidth, fRingWidth); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fWidth, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - if (fWidth > pRect->width / 2) { - return; - } - pGraphics->SaveGraphState(); - CFX_Color cr(fillColor); - pGraphics->SetFillColor(&cr); - CFX_Path path; - path.Create(); - path.AddEllipse(*pRect); - CFX_RectF rtIn(*pRect); - rtIn.Inflate(-fWidth, -fWidth); - path.AddEllipse(rtIn); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color cr(0xFF000000); - pGraphics->SetStrokeColor(&cr); - FX_FLOAT DashPattern[2] = {1, 1}; - pGraphics->SetLineDash(0.0f, DashPattern, 2); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -#define FWLTHEME_ARROW_Denominator 3 -void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argbFill, - FX_BOOL bPressed, - CFX_Matrix* pMatrix) { - CFX_RectF rtArrow(*pRect); - CFX_Path path; - path.Create(); - FX_FLOAT fBtn = - std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; - rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; - rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; - rtArrow.width = fBtn; - rtArrow.height = fBtn; - if (bPressed) { - rtArrow.Offset(1, 1); - } - switch (eDict) { - case FWLTHEME_DIRECTION_Up: { - path.MoveTo(rtArrow.left, rtArrow.bottom()); - path.LineTo(rtArrow.right(), rtArrow.bottom()); - path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top); - path.LineTo(rtArrow.left, rtArrow.bottom()); - break; - } - case FWLTHEME_DIRECTION_Left: { - path.MoveTo(rtArrow.right(), rtArrow.top); - path.LineTo(rtArrow.right(), rtArrow.bottom()); - path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2); - path.LineTo(rtArrow.right(), rtArrow.top); - break; - } - case FWLTHEME_DIRECTION_Right: { - path.MoveTo(rtArrow.left, rtArrow.top); - path.LineTo(rtArrow.left, rtArrow.bottom()); - path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2); - path.LineTo(rtArrow.left, rtArrow.top); - break; - } - case FWLTHEME_DIRECTION_Down: - default: { - path.MoveTo(rtArrow.left, rtArrow.top); - path.LineTo(rtArrow.right(), rtArrow.top); - path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom()); - path.LineTo(rtArrow.left, rtArrow.top); - } - } - pGraphics->SaveGraphState(); - CFX_Color cr(argbFill); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argSign, - CFX_Matrix* pMatrix) { - FX_BOOL bVert = - (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); - FX_FLOAT fLeft = - (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); - FX_FLOAT fTop = - (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); - CFX_Path path; - path.Create(); - switch (eDict) { - case FWLTHEME_DIRECTION_Down: { - path.MoveTo(fLeft, fTop + 1); - path.LineTo(fLeft + 4, fTop + 5); - path.LineTo(fLeft + 8, fTop + 1); - path.LineTo(fLeft + 7, fTop); - path.LineTo(fLeft + 4, fTop + 3); - path.LineTo(fLeft + 1, fTop); - break; - } - case FWLTHEME_DIRECTION_Up: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 8, fTop + 4); - path.LineTo(fLeft + 7, fTop + 5); - path.LineTo(fLeft + 4, fTop + 2); - path.LineTo(fLeft + 1, fTop + 5); - break; - } - case FWLTHEME_DIRECTION_Right: { - path.MoveTo(fLeft + 1, fTop); - path.LineTo(fLeft + 5, fTop + 4); - path.LineTo(fLeft + 1, fTop + 8); - path.LineTo(fLeft, fTop + 7); - path.LineTo(fLeft + 3, fTop + 4); - path.LineTo(fLeft, fTop + 1); - break; - } - case FWLTHEME_DIRECTION_Left: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 5, fTop + 1); - path.LineTo(fLeft + 2, fTop + 4); - path.LineTo(fLeft + 5, fTop + 7); - path.LineTo(fLeft + 4, fTop + 8); - break; - } - } - CFX_Color cr(argSign); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); -} -void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - if (!CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); - } - CFWL_ArrowData::CColorData* pColorData = - CFWL_ArrowData::GetInstance()->m_pColorData; - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, - pColorData->clrStart[eState - 1], - pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, - pMatrix); - CFX_Color rcStroke; - rcStroke.Set(pColorData->clrBorder[eState - 1]); - pGraphics->SetStrokeColor(&rcStroke); - pGraphics->StrokePath(&path, pMatrix); -} -void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - DrawBtn(pGraphics, pRect, eState, pMatrix); - if (!CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); - } - CFWL_ArrowData::CColorData* pColorData = - 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)( - ((FX_WORD)srcColor.a * n + (FX_WORD)renderColor.a * scale) >> 8); - dstColor.r = (uint8_t)( - ((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8); - dstColor.g = (uint8_t)( - ((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8); - dstColor.b = (uint8_t)( - ((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8); - return dstColor; -} -CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) { - SetColorData(0); -} -CFWL_FontData::CFWL_FontData() - : m_dwStyles(0), - m_dwCodePage(0), - m_pFont(0), - m_pFontMgr(NULL) -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - , - m_pFontSource(NULL) -#endif -{ -} -CFWL_FontData::~CFWL_FontData() { - if (m_pFont) { - m_pFont->Release(); - } - if (m_pFontMgr) { - m_pFontMgr->Release(); - } -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_pFontSource != NULL) { - m_pFontSource->Release(); - } -#endif -} -FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && - m_dwCodePage == wCodePage; -} -FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD dwCodePage) { - m_wsFamily = wsFontFamily; - m_dwStyles = dwFontStyles; - m_dwCodePage = dwCodePage; - if (!m_pFontMgr) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); -#else - m_pFontSource = FX_CreateDefaultFontSourceEnum(); - m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); -#endif - } - m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, - m_pFontMgr); - return m_pFont != NULL; -} - -CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr; -CFWL_FontManager* CFWL_FontManager::GetInstance() { - if (!s_FontManager) - s_FontManager = new CFWL_FontManager; - return s_FontManager; -} -void CFWL_FontManager::DestroyInstance() { - delete s_FontManager; - s_FontManager = nullptr; -} -CFWL_FontManager::CFWL_FontManager() {} -CFWL_FontManager::~CFWL_FontManager() {} -IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - for (const auto& pData : m_FontsArray) { - if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) - return pData->GetFont(); - } - std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData); - if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) - return nullptr; - m_FontsArray.push_back(std::move(pFontData)); - return m_FontsArray.back()->GetFont(); -} -FX_BOOL FWLTHEME_Init() { - return TRUE; -} -void FWLTHEME_Release() { - CFWL_ArrowData::DestroyInstance(); - CFWL_FontManager::DestroyInstance(); -} -FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) { - return 0xffff0000 & dwThemeID; -} -FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) { - return 0x0000ffff & dwThemeID; -} -FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) { - return (dwLayout << 16) | (0x0000FFFF & dwColor); -} -CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; -CFWL_ArrowData* CFWL_ArrowData::GetInstance() { - if (!m_pInstance) { - m_pInstance = new CFWL_ArrowData; - } - return m_pInstance; -} -FX_BOOL CFWL_ArrowData::IsInstance() { - return (m_pInstance != NULL); -} -void CFWL_ArrowData::DestroyInstance() { - if (m_pInstance) { - delete m_pInstance; - m_pInstance = NULL; - } -} -CFWL_ArrowData::~CFWL_ArrowData() { - if (m_pColorData) { - delete m_pColorData; - m_pColorData = NULL; - } -} -void CFWL_ArrowData::SetColorData(FX_DWORD dwID) { - if (!m_pColorData) { - m_pColorData = new CColorData; - } - if (dwID) { - m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); - m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); - m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); - m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); - m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); - m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); - m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186); - m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); - m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117); - m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155); - m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117); - m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); - m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); - } else { - m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249); - m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233); - m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219); - m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); - m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254); - m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255); - m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241); - m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); - m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); - m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); - m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); - m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); - m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); - } -} diff --git a/xfa/src/fxbarcode/BC_BarCode.cpp b/xfa/src/fxbarcode/BC_BarCode.cpp deleted file mode 100644 index 644ead3294..0000000000 --- a/xfa/src/fxbarcode/BC_BarCode.cpp +++ /dev/null @@ -1,877 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" -#include "xfa/src/fxbarcode/BC_DecoderResult.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h" - -CBC_CodeBase::CBC_CodeBase() {} -CBC_CodeBase::~CBC_CodeBase() {} -FX_BOOL CBC_CodeBase::SetCharEncoding(int32_t encoding) { - if (m_pBCWriter) { - return m_pBCWriter->SetCharEncoding(encoding); - } - return FALSE; -} -FX_BOOL CBC_CodeBase::SetModuleHeight(int32_t moduleHeight) { - if (m_pBCWriter) { - return m_pBCWriter->SetModuleHeight(moduleHeight); - } - return FALSE; -} -FX_BOOL CBC_CodeBase::SetModuleWidth(int32_t moduleWidth) { - if (m_pBCWriter) { - return m_pBCWriter->SetModuleWidth(moduleWidth); - } - return FALSE; -} -FX_BOOL CBC_CodeBase::SetHeight(int32_t height) { - if (m_pBCWriter) { - return m_pBCWriter->SetHeight(height); - } - return FALSE; -} -FX_BOOL CBC_CodeBase::SetWidth(int32_t width) { - if (m_pBCWriter) { - return m_pBCWriter->SetWidth(width); - } - return FALSE; -} -void CBC_CodeBase::SetBackgroundColor(FX_ARGB backgroundColor) { - if (m_pBCWriter) { - m_pBCWriter->SetBackgroundColor(backgroundColor); - } -} -void CBC_CodeBase::SetBarcodeColor(FX_ARGB foregroundColor) { - if (m_pBCWriter) { - m_pBCWriter->SetBarcodeColor(foregroundColor); - } -} -CBC_OneCode::CBC_OneCode() {} -CBC_OneCode::~CBC_OneCode() {} -FX_BOOL CBC_OneCode::CheckContentValidity(const CFX_WideStringC& contents) { - if (m_pBCWriter) { - return ((CBC_OneDimWriter*)m_pBCWriter)->CheckContentValidity(contents); - } - return FALSE; -} -CFX_WideString CBC_OneCode::FilterContents(const CFX_WideStringC& contents) { - CFX_WideString tmp; - if (m_pBCWriter == NULL) { - return tmp; - } - return ((CBC_OneDimWriter*)m_pBCWriter)->FilterContents(contents); -} -void CBC_OneCode::SetPrintChecksum(FX_BOOL checksum) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetPrintChecksum(checksum); - } -} -void CBC_OneCode::SetDataLength(int32_t length) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetDataLength(length); - } -} -void CBC_OneCode::SetCalChecksum(FX_BOOL calc) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetCalcChecksum(calc); - } -} -FX_BOOL CBC_OneCode::SetFont(CFX_Font* cFont) { - if (m_pBCWriter) { - return ((CBC_OneDimWriter*)m_pBCWriter)->SetFont(cFont); - } - return FALSE; -} -void CBC_OneCode::SetFontSize(FX_FLOAT size) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetFontSize(size); - } -} -void CBC_OneCode::SetFontStyle(int32_t style) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetFontStyle(style); - } -} -void CBC_OneCode::SetFontColor(FX_ARGB color) { - if (m_pBCWriter) { - ((CBC_OneDimWriter*)m_pBCWriter)->SetFontColor(color); - } -} -CBC_Code39::CBC_Code39() { - m_pBCReader = (CBC_Reader*)new (CBC_OnedCode39Reader); - m_pBCWriter = (CBC_Writer*)new (CBC_OnedCode39Writer); -} -CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit) { - m_pBCReader = (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit); - m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer; -} -CBC_Code39::CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode) { - m_pBCReader = - (CBC_Reader*)new CBC_OnedCode39Reader(usingCheckDigit, extendedMode); - m_pBCWriter = (CBC_Writer*)new CBC_OnedCode39Writer(extendedMode); -} -CBC_Code39::~CBC_Code39() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_Code39::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_CODE_39; - int32_t outWidth = 0; - int32_t outHeight = 0; - CFX_WideString filtercontents = - ((CBC_OnedCode39Writer*)m_pBCWriter)->FilterContents(contents); - CFX_WideString renderContents = - ((CBC_OnedCode39Writer*)m_pBCWriter)->RenderTextContents(contents); - m_renderContents = renderContents; - CFX_ByteString byteString = filtercontents.UTF8Encode(); - uint8_t* data = static_cast<CBC_OnedCode39Writer*>(m_pBCWriter) - ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderResult(renderContents, 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, - int32_t& e) { - CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter) - ->encodedContents(m_renderContents, e); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, renderCon, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -FX_BOOL CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - CFX_WideString renderCon = ((CBC_OnedCode39Writer*)m_pBCWriter) - ->encodedContents(m_renderContents, e); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderBitmapResult(pOutBitmap, renderCon, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_Code39::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -FX_BOOL CBC_Code39::SetTextLocation(BC_TEXT_LOC location) { - if (m_pBCWriter) { - return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetTextLocation(location); - } - return FALSE; -} -FX_BOOL CBC_Code39::SetWideNarrowRatio(int32_t ratio) { - if (m_pBCWriter) { - return ((CBC_OnedCode39Writer*)m_pBCWriter)->SetWideNarrowRatio(ratio); - } - return FALSE; -} -CBC_Codabar::CBC_Codabar() { - m_pBCReader = (CBC_Reader*)new (CBC_OnedCodaBarReader); - m_pBCWriter = (CBC_Writer*)new (CBC_OnedCodaBarWriter); -} -CBC_Codabar::~CBC_Codabar() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_Codabar::SetStartChar(FX_CHAR start) { - if (m_pBCWriter) { - return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetStartChar(start); - } - return FALSE; -} -FX_BOOL CBC_Codabar::SetEndChar(FX_CHAR end) { - if (m_pBCWriter) { - return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetEndChar(end); - } - return FALSE; -} -FX_BOOL CBC_Codabar::SetTextLocation(BC_TEXT_LOC location) { - return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetTextLocation(location); -} -FX_BOOL CBC_Codabar::SetWideNarrowRatio(int32_t ratio) { - if (m_pBCWriter) { - return ((CBC_OnedCodaBarWriter*)m_pBCWriter)->SetWideNarrowRatio(ratio); - } - return FALSE; -} -FX_BOOL CBC_Codabar::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_CODABAR; - int32_t outWidth = 0; - int32_t outHeight = 0; - CFX_WideString filtercontents = - ((CBC_OneDimWriter*)m_pBCWriter)->FilterContents(contents); - CFX_ByteString byteString = filtercontents.UTF8Encode(); - m_renderContents = filtercontents; - uint8_t* data = static_cast<CBC_OnedCodaBarWriter*>(m_pBCWriter) - ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderResult(filtercontents, 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, - int32_t& e) { - CFX_WideString renderCon = - ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedContents(m_renderContents); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, renderCon, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -FX_BOOL CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - CFX_WideString renderCon = - ((CBC_OnedCodaBarWriter*)m_pBCWriter)->encodedContents(m_renderContents); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderBitmapResult(pOutBitmap, renderCon, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_Codabar::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_Code128::CBC_Code128(BC_TYPE type) { - m_pBCReader = (CBC_Reader*)new (CBC_OnedCode128Reader); - m_pBCWriter = (CBC_Writer*)new CBC_OnedCode128Writer(type); -} -CBC_Code128::~CBC_Code128() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_Code128::SetTextLocation(BC_TEXT_LOC location) { - if (m_pBCWriter) { - return ((CBC_OnedCode128Writer*)m_pBCWriter)->SetTextLocation(location); - } - return FALSE; -} -FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_CODE_128; - int32_t outWidth = 0; - int32_t outHeight = 0; - 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); - 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, 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, - int32_t& e) { - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_Code128::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_EAN8::CBC_EAN8() { - m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN8Reader); - m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN8Writer); -} -CBC_EAN8::~CBC_EAN8() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) { - CFX_WideString encodeContents = - ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); - int32_t length = encodeContents.GetLength(); - if (length <= 7) { - for (int32_t i = 0; i < 7 - length; i++) { - encodeContents = FX_WCHAR('0') + encodeContents; - } - CFX_ByteString byteString = encodeContents.UTF8Encode(); - int32_t checksum = - ((CBC_OnedEAN8Writer*)m_pBCWriter)->CalcChecksum(byteString); - encodeContents += FX_WCHAR(checksum - 0 + '0'); - } - if (length > 8) { - encodeContents = encodeContents.Mid(0, 8); - } - return encodeContents; -} -FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_EAN_8; - int32_t outWidth = 0; - int32_t outHeight = 0; - CFX_WideString encodeContents = Preprocess(contents); - CFX_ByteString byteString = encodeContents.UTF8Encode(); - m_renderContents = encodeContents; - uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter) - ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderResult(encodeContents, 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, - int32_t& e) { - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_EAN8::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_EAN13::CBC_EAN13() { - m_pBCReader = (CBC_Reader*)new (CBC_OnedEAN13Reader); - m_pBCWriter = (CBC_Writer*)new (CBC_OnedEAN13Writer); -} -CBC_EAN13::~CBC_EAN13() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -CFX_WideString CBC_EAN13::Preprocess(const CFX_WideStringC& contents) { - CFX_WideString encodeContents = - ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); - int32_t length = encodeContents.GetLength(); - if (length <= 12) { - for (int32_t i = 0; i < 12 - length; i++) { - encodeContents = FX_WCHAR('0') + encodeContents; - } - CFX_ByteString byteString = encodeContents.UTF8Encode(); - int32_t checksum = - ((CBC_OnedEAN13Writer*)m_pBCWriter)->CalcChecksum(byteString); - byteString += checksum - 0 + '0'; - encodeContents = byteString.UTF8Decode(); - } - if (length > 13) { - encodeContents = encodeContents.Mid(0, 13); - } - return encodeContents; -} -FX_BOOL CBC_EAN13::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_EAN_13; - int32_t outWidth = 0; - int32_t outHeight = 0; - CFX_WideString encodeContents = Preprocess(contents); - CFX_ByteString byteString = encodeContents.UTF8Encode(); - m_renderContents = encodeContents; - uint8_t* data = static_cast<CBC_OnedEAN13Writer*>(m_pBCWriter) - ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderResult(encodeContents, 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, - int32_t& e) { - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_EAN13::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_UPCA::CBC_UPCA() { - m_pBCReader = (CBC_Reader*)new (CBC_OnedUPCAReader); - ((CBC_OnedUPCAReader*)m_pBCReader)->Init(); - m_pBCWriter = (CBC_Writer*)new (CBC_OnedUPCAWriter); -} -CBC_UPCA::~CBC_UPCA() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -CFX_WideString CBC_UPCA::Preprocess(const CFX_WideStringC& contents) { - CFX_WideString encodeContents = - ((CBC_OnedEAN8Writer*)m_pBCWriter)->FilterContents(contents); - int32_t length = encodeContents.GetLength(); - if (length <= 11) { - for (int32_t i = 0; i < 11 - length; i++) { - encodeContents = FX_WCHAR('0') + encodeContents; - } - CFX_ByteString byteString = encodeContents.UTF8Encode(); - int32_t checksum = - ((CBC_OnedUPCAWriter*)m_pBCWriter)->CalcChecksum(byteString); - byteString += checksum - 0 + '0'; - encodeContents = byteString.UTF8Decode(); - } - if (length > 12) { - encodeContents = encodeContents.Mid(0, 12); - } - return encodeContents; -} -FX_BOOL CBC_UPCA::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - if (contents.IsEmpty()) { - e = BCExceptionNoContents; - return FALSE; - } - BCFORMAT format = BCFORMAT_UPC_A; - int32_t outWidth = 0; - int32_t outHeight = 0; - CFX_WideString encodeContents = Preprocess(contents); - CFX_ByteString byteString = encodeContents.UTF8Encode(); - m_renderContents = encodeContents; - ((CBC_OnedUPCAWriter*)m_pBCWriter)->Init(); - uint8_t* data = static_cast<CBC_OnedUPCAWriter*>(m_pBCWriter) - ->Encode(byteString, format, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderResult(encodeContents, 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, - int32_t& e) { - ((CBC_OneDimWriter*)m_pBCWriter) - ->RenderDeviceResult(device, matirx, m_renderContents, 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, 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& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_UPCA::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_QRCode::CBC_QRCode() { - m_pBCReader = (CBC_Reader*)new (CBC_QRCodeReader); - ((CBC_QRCodeReader*)m_pBCReader)->Init(); - m_pBCWriter = (CBC_Writer*)new (CBC_QRCodeWriter); -} -CBC_QRCode::~CBC_QRCode() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_QRCode::SetVersion(int32_t version) { - if (version < 0 || version > 40) { - return FALSE; - } - if (m_pBCWriter == NULL) { - return FALSE; - } - return ((CBC_QRCodeWriter*)m_pBCWriter)->SetVersion(version); -} -FX_BOOL CBC_QRCode::SetErrorCorrectionLevel(int32_t level) { - if (level < 0 || level > 3) { - return FALSE; - } - if (m_pBCWriter == NULL) { - return FALSE; - } - return ((CBC_TwoDimWriter*)m_pBCWriter)->SetErrorCorrectionLevel(level); -} -FX_BOOL CBC_QRCode::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - 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); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); - FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -FX_BOOL CBC_QRCode::RenderDevice(CFX_RenderDevice* device, - const CFX_Matrix* matirx, - int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); - return TRUE; -} -FX_BOOL CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -CFX_WideString CBC_QRCode::Decode(uint8_t* buf, - int32_t width, - int32_t hight, - int32_t& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_QRCode::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_PDF417I::CBC_PDF417I() { - m_pBCReader = (CBC_Reader*)new (CBC_PDF417Reader); - m_pBCWriter = (CBC_Writer*)new (CBC_PDF417Writer); -} -CBC_PDF417I::~CBC_PDF417I() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_PDF417I::SetErrorCorrectionLevel(int32_t level) { - ((CBC_PDF417Writer*)m_pBCWriter)->SetErrorCorrectionLevel(level); - return TRUE; -} -void CBC_PDF417I::SetTruncated(FX_BOOL truncated) { - ((CBC_PDF417Writer*)m_pBCWriter)->SetTruncated(truncated); -} -FX_BOOL CBC_PDF417I::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - int32_t outWidth = 0; - int32_t outHeight = 0; - uint8_t* data = ((CBC_PDF417Writer*)m_pBCWriter) - ->Encode(contents, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); - FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -FX_BOOL CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, - const CFX_Matrix* matirx, - int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); - return TRUE; -} -FX_BOOL CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -CFX_WideString CBC_PDF417I::Decode(uint8_t* buf, - int32_t width, - int32_t hight, - int32_t& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_PDF417I::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} -CBC_DataMatrix::CBC_DataMatrix() { - m_pBCReader = (CBC_Reader*)new (CBC_DataMatrixReader); - ((CBC_DataMatrixReader*)m_pBCReader)->Init(); - m_pBCWriter = (CBC_Writer*)new (CBC_DataMatrixWriter); -} -CBC_DataMatrix::~CBC_DataMatrix() { - if (m_pBCReader) { - delete (m_pBCReader); - m_pBCReader = NULL; - } - if (m_pBCWriter) { - delete (m_pBCWriter); - m_pBCWriter = NULL; - } -} -FX_BOOL CBC_DataMatrix::Encode(const CFX_WideStringC& contents, - FX_BOOL isDevice, - int32_t& e) { - int32_t outWidth = 0; - int32_t outHeight = 0; - uint8_t* data = ((CBC_DataMatrixWriter*)m_pBCWriter) - ->Encode(contents, outWidth, outHeight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e); - FX_Free(data); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, - const CFX_Matrix* matirx, - int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx); - return TRUE; -} -FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { - ((CBC_TwoDimWriter*)m_pBCWriter)->RenderBitmapResult(pOutBitmap, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return TRUE; -} -CFX_WideString CBC_DataMatrix::Decode(uint8_t* buf, - int32_t width, - int32_t hight, - int32_t& e) { - CFX_WideString str; - return str; -} -CFX_WideString CBC_DataMatrix::Decode(CFX_DIBitmap* pBitmap, int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - 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()); -} diff --git a/xfa/src/fxbarcode/BC_Binarizer.cpp b/xfa/src/fxbarcode/BC_Binarizer.cpp deleted file mode 100644 index 8e214561c6..0000000000 --- a/xfa/src/fxbarcode/BC_Binarizer.cpp +++ /dev/null @@ -1,34 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" - -CBC_Binarizer::CBC_Binarizer(CBC_LuminanceSource* source) { - m_source = source; -} -CBC_Binarizer::~CBC_Binarizer() {} -CBC_LuminanceSource* CBC_Binarizer::GetLuminanceSource() { - return m_source; -} diff --git a/xfa/src/fxbarcode/BC_Binarizer.h b/xfa/src/fxbarcode/BC_Binarizer.h deleted file mode 100644 index ed1ac9c19c..0000000000 --- a/xfa/src/fxbarcode/BC_Binarizer.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_SRC_FXBARCODE_BC_BINARIZER_H_ -#define XFA_SRC_FXBARCODE_BC_BINARIZER_H_ - -#include <cstdint> - -class CBC_LuminanceSource; -class CBC_CommonBitMatrix; -class CBC_CommonBitArray; - -class CBC_Binarizer { - public: - CBC_Binarizer(CBC_LuminanceSource* source); - virtual ~CBC_Binarizer(); - CBC_LuminanceSource* GetLuminanceSource(); - virtual CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e) = 0; - virtual CBC_CommonBitArray* GetBlackRow(int32_t y, - CBC_CommonBitArray* row, - int32_t& e) = 0; - - private: - CBC_LuminanceSource* m_source; -}; - -#endif // XFA_SRC_FXBARCODE_BC_BINARIZER_H_ diff --git a/xfa/src/fxbarcode/BC_BinaryBitmap.cpp b/xfa/src/fxbarcode/BC_BinaryBitmap.cpp deleted file mode 100644 index be6258ef1f..0000000000 --- a/xfa/src/fxbarcode/BC_BinaryBitmap.cpp +++ /dev/null @@ -1,61 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_BinaryBitmap::CBC_BinaryBitmap(CBC_Binarizer* binarizer) - : m_binarizer(binarizer), m_matrix(NULL) {} -CBC_BinaryBitmap::~CBC_BinaryBitmap() { - delete m_matrix; -} -int32_t CBC_BinaryBitmap::GetHeight() { - return m_binarizer->GetLuminanceSource()->GetHeight(); -} -int32_t CBC_BinaryBitmap::GetWidth() { - return m_binarizer->GetLuminanceSource()->GetWidth(); -} -CBC_CommonBitMatrix* CBC_BinaryBitmap::GetMatrix(int32_t& e) { - if (m_matrix == NULL) { - m_matrix = m_binarizer->GetBlackMatrix(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return m_matrix; -} -CBC_CommonBitArray* CBC_BinaryBitmap::GetBlackRow(int32_t y, - CBC_CommonBitArray* row, - int32_t& e) { - CBC_CommonBitArray* temp = m_binarizer->GetBlackRow(y, row, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CBC_CommonBitMatrix* CBC_BinaryBitmap::GetBlackMatrix(int32_t& e) { - if (m_matrix == NULL) { - m_matrix = m_binarizer->GetBlackMatrix(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return m_matrix; -} diff --git a/xfa/src/fxbarcode/BC_BinaryBitmap.h b/xfa/src/fxbarcode/BC_BinaryBitmap.h deleted file mode 100644 index 5d34c546ff..0000000000 --- a/xfa/src/fxbarcode/BC_BinaryBitmap.h +++ /dev/null @@ -1,33 +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_SRC_FXBARCODE_BC_BINARYBITMAP_H_ -#define XFA_SRC_FXBARCODE_BC_BINARYBITMAP_H_ - -#include <cstdint> - -class CBC_Binarizer; -class CBC_CommonBitMatrix; -class CBC_CommonBitArray; - -class CBC_BinaryBitmap { - public: - CBC_BinaryBitmap(CBC_Binarizer* binarizer); - virtual ~CBC_BinaryBitmap(); - int32_t GetWidth(); - int32_t GetHeight(); - CBC_CommonBitMatrix* GetMatrix(int32_t& e); - CBC_CommonBitArray* GetBlackRow(int32_t y, - CBC_CommonBitArray* row, - int32_t& e); - CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e); - - private: - CBC_Binarizer* m_binarizer; - CBC_CommonBitMatrix* m_matrix; -}; - -#endif // XFA_SRC_FXBARCODE_BC_BINARYBITMAP_H_ diff --git a/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp b/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp deleted file mode 100644 index b2fc8a5eac..0000000000 --- a/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp +++ /dev/null @@ -1,171 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcodec/fx_codec.h" -#include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/utils.h" - -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(); - 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; - 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) { - status = pImageCodec->GetFrames(frames, &pause); - } - if (status != FXCODEC_STATUS_DECODE_READY) { - goto except; - } - status = pImageCodec->StartDecode(bitmap, 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) { - 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; -} -CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource( - const CFX_WideString& filename) - : CBC_LuminanceSource(0, 0), m_filename(filename) { - m_height = 0; - m_width = 0; - m_bytesPerLine = 0; - m_top = 0; - m_left = 0; -} -void CBC_BufferedImageLuminanceSource::Init(int32_t& e) { - IFX_FileRead* fileread = FX_CreateFileRead(m_filename); - m_pBitmap = CreateDIBSource(fileread); - if (m_pBitmap == NULL) { - e = BCExceptionLoadFile; - return; - } - m_pBitmap->ConvertFormat(FXDIB_Argb); - m_height = m_pBitmap->GetHeight(); - m_width = m_pBitmap->GetWidth(); - m_rgbData.SetSize(m_height * m_width); - m_bytesPerLine = m_width * 4; - m_top = 0; - m_left = 0; -} -CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource( - CFX_DIBitmap* pBitmap) - : CBC_LuminanceSource(0, 0) { - m_pBitmap = pBitmap->Clone(); - m_pBitmap->ConvertFormat(FXDIB_Argb); - m_height = m_pBitmap->GetHeight(); - m_width = m_pBitmap->GetWidth(); - m_rgbData.SetSize(m_height * m_width); - m_bytesPerLine = m_width * 4; - 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; - } - int32_t width = m_width; - if (row.GetSize() == 0 || row.GetSize() < width) { - row.SetSize(width); - } - if (m_rgbData.GetSize() == 0 || m_rgbData.GetSize() < width) { - m_rgbData.SetSize(width); - } - int32_t* rowLine = (int32_t*)m_pBitmap->GetScanline(y); - int32_t x; - for (x = 0; x < width; x++) { - int32_t pixel = rowLine[x]; - int32_t luminance = (306 * ((pixel >> 16) & 0xFF) + - 601 * ((pixel >> 8) & 0xFF) + 117 * (pixel & 0xFF)) >> - 10; - row[x] = (uint8_t)luminance; - } - return &row; -} -CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetMatrix() { - CFX_ByteArray* matirx = new CFX_ByteArray(); - matirx->SetSize(m_bytesPerLine * m_height); - int32_t* rgb = (int32_t*)m_pBitmap->GetBuffer(); - int32_t y; - for (y = 0; y < m_height; y++) { - int32_t offset = y * m_width; - int32_t x; - for (x = 0; x < m_width; x++) { - int32_t pixel = rgb[offset + x]; - int32_t luminance = - (306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) + - 117 * (pixel & 0xFF)) >> - 10; - (*matirx)[offset + x] = (uint8_t)luminance; - } - } - return matirx; -} diff --git a/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h b/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h deleted file mode 100644 index 5696d5b554..0000000000 --- a/xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ -#define XFA_SRC_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxge/fx_dib.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" - -class CBC_BufferedImageLuminanceSource : public CBC_LuminanceSource { - public: - explicit CBC_BufferedImageLuminanceSource(const CFX_WideString& filename); - explicit CBC_BufferedImageLuminanceSource(CFX_DIBitmap* pBitmap); - virtual ~CBC_BufferedImageLuminanceSource(); - - CFX_ByteArray* GetRow(int32_t y, CFX_ByteArray& row, int32_t& e); - CFX_ByteArray* GetMatrix(); - virtual void Init(int32_t& e); - - private: - int32_t m_bytesPerLine; - int32_t m_left; - int32_t m_top; - CFX_Int32Array m_rgbData; - CFX_DIBitmap* m_pBitmap; - const CFX_WideString m_filename; -}; - -#endif // XFA_SRC_FXBARCODE_BC_BUFFEREDIMAGELUMINANCESOURCE_H_ diff --git a/xfa/src/fxbarcode/BC_DecoderResult.h b/xfa/src/fxbarcode/BC_DecoderResult.h deleted file mode 100644 index fce22a741b..0000000000 --- a/xfa/src/fxbarcode/BC_DecoderResult.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_SRC_FXBARCODE_BC_DECODERRESULT_H_ -#define XFA_SRC_FXBARCODE_BC_DECODERRESULT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_DecoderResult { - public: - CBC_DecoderResult(CFX_ByteArray* rawBytes, - CFX_ByteString text, - CFX_ByteString ecLevel); - virtual ~CBC_DecoderResult(); - CFX_ByteArray* getRawBytes(); - CFX_ByteString getText(); - CFX_ByteString getECLevel(); - int32_t getErrorsCorrected(); - void setErrorsCorrected(int32_t errorsCorrected); - int32_t getErasures(); - void setErasures(int32_t erasures); - void* getOther(); - void setOther(void* other); - - private: - CFX_ByteArray* m_rawBytes; - CFX_ByteString m_text; - CFX_ByteString m_ecLevel; - int32_t m_errorsCorrected; - int32_t m_erasures; - void* m_other; -}; - -#endif // XFA_SRC_FXBARCODE_BC_DECODERRESULT_H_ diff --git a/xfa/src/fxbarcode/BC_Dimension.cpp b/xfa/src/fxbarcode/BC_Dimension.cpp deleted file mode 100644 index 253a4ea7e0..0000000000 --- a/xfa/src/fxbarcode/BC_Dimension.cpp +++ /dev/null @@ -1,46 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -CBC_Dimension::CBC_Dimension() {} -CBC_Dimension::CBC_Dimension(int32_t width, int32_t height, int32_t& e) { - if (width < 0 || height < 0) { - e = BCExceptionHeightAndWidthMustBeAtLeast1; - } - m_width = width; - m_height = height; -} -CBC_Dimension::~CBC_Dimension() {} -int32_t CBC_Dimension::getWidth() { - return m_width; -} -int32_t CBC_Dimension::getHeight() { - return m_height; -} -int32_t CBC_Dimension::hashCode() { - return m_width * 32713 + m_height; -} -CFX_WideString CBC_Dimension::toString() { - return (FX_WCHAR)(m_width + (FX_WCHAR)'x' + m_height); -} diff --git a/xfa/src/fxbarcode/BC_Dimension.h b/xfa/src/fxbarcode/BC_Dimension.h deleted file mode 100644 index d6780f0fed..0000000000 --- a/xfa/src/fxbarcode/BC_Dimension.h +++ /dev/null @@ -1,29 +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_SRC_FXBARCODE_BC_DIMENSION_H_ -#define XFA_SRC_FXBARCODE_BC_DIMENSION_H_ - -#include <cstdint> - -#include "core/include/fxcrt/fx_string.h" - -class CBC_Dimension { - public: - CBC_Dimension(); - CBC_Dimension(int32_t width, int32_t height, int32_t& e); - virtual ~CBC_Dimension(); - int32_t getWidth(); - int32_t getHeight(); - int32_t hashCode(); - CFX_WideString toString(); - - private: - int32_t m_width; - int32_t m_height; -}; - -#endif // XFA_SRC_FXBARCODE_BC_DIMENSION_H_ diff --git a/xfa/src/fxbarcode/BC_Library.cpp b/xfa/src/fxbarcode/BC_Library.cpp deleted file mode 100644 index a5ec431db9..0000000000 --- a/xfa/src/fxbarcode/BC_Library.cpp +++ /dev/null @@ -1,121 +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/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" -#include "xfa/src/fxbarcode/BC_DecoderResult.h" -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" -#include "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" - -void BC_Library_Init() { - CBC_QRCoderErrorCorrectionLevel::Initialize(); - CBC_QRCoderMode::Initialize(); - CBC_QRCoderVersion::Initialize(); - CBC_QRDataMask::Initialize(); - CBC_ReedSolomonGF256::Initialize(); - CBC_DataMatrixVersion::Initialize(); - CBC_SymbolInfo::Initialize(); - CBC_ErrorCorrection::Initialize(); - CBC_PDF417HighLevelEncoder::Initialize(); - int32_t e = 0; - CBC_PDF417ECModulusGF::Initialize(e); - CBC_DecodedBitStreamPaser::Initialize(); - CBC_PDF417CodewordDecoder::Initialize(); - CBC_PDF417ECErrorCorrection::Initialize(e); - CBC_PDF417ScanningDecoder::Initialize(); -} -void BC_Library_Destory() { - CBC_QRCoderErrorCorrectionLevel::Finalize(); - CBC_QRCoderMode::Finalize(); - CBC_QRCoderVersion::Finalize(); - CBC_QRDataMask::Finalize(); - CBC_ReedSolomonGF256::Finalize(); - CBC_DataMatrixVersion::Finalize(); - CBC_SymbolInfo::Finalize(); - CBC_ErrorCorrection::Finalize(); - CBC_PDF417HighLevelEncoder::Finalize(); - CBC_DecodedBitStreamPaser::Finalize(); - CBC_PDF417CodewordDecoder::Finalize(); - CBC_PDF417ECErrorCorrection::Finalize(); - CBC_PDF417ECModulusGF::Finalize(); - CBC_PDF417ScanningDecoder::Finalize(); -} diff --git a/xfa/src/fxbarcode/BC_LuminanceSource.cpp b/xfa/src/fxbarcode/BC_LuminanceSource.cpp deleted file mode 100644 index 02ff694ca1..0000000000 --- a/xfa/src/fxbarcode/BC_LuminanceSource.cpp +++ /dev/null @@ -1,33 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" - -CBC_LuminanceSource::CBC_LuminanceSource(int32_t width, int32_t height) - : m_width(width), m_height(height) {} -CBC_LuminanceSource::~CBC_LuminanceSource() {} -int32_t CBC_LuminanceSource::GetWidth() { - return m_width; -} -int32_t CBC_LuminanceSource::GetHeight() { - return m_height; -} diff --git a/xfa/src/fxbarcode/BC_LuminanceSource.h b/xfa/src/fxbarcode/BC_LuminanceSource.h deleted file mode 100644 index 862fa2475f..0000000000 --- a/xfa/src/fxbarcode/BC_LuminanceSource.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_SRC_FXBARCODE_BC_LUMINANCESOURCE_H_ -#define XFA_SRC_FXBARCODE_BC_LUMINANCESOURCE_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_LuminanceSource { - public: - CBC_LuminanceSource(int32_t width, int32_t height); - virtual ~CBC_LuminanceSource(); - int32_t GetWidth(); - int32_t GetHeight(); - - virtual CFX_ByteArray* GetRow(int32_t y, CFX_ByteArray& row, int32_t& e) = 0; - virtual CFX_ByteArray* GetMatrix() = 0; - - protected: - int32_t m_width; - int32_t m_height; -}; - -#endif // XFA_SRC_FXBARCODE_BC_LUMINANCESOURCE_H_ diff --git a/xfa/src/fxbarcode/BC_Reader.cpp b/xfa/src/fxbarcode/BC_Reader.cpp deleted file mode 100644 index 15d161f174..0000000000 --- a/xfa/src/fxbarcode/BC_Reader.cpp +++ /dev/null @@ -1,10 +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/src/fxbarcode/BC_Reader.h" - -CBC_Reader::CBC_Reader() {} -CBC_Reader::~CBC_Reader() {} diff --git a/xfa/src/fxbarcode/BC_Reader.h b/xfa/src/fxbarcode/BC_Reader.h deleted file mode 100644 index 062268a6e7..0000000000 --- a/xfa/src/fxbarcode/BC_Reader.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_SRC_FXBARCODE_BC_READER_H_ -#define XFA_SRC_FXBARCODE_BC_READER_H_ - -#include "core/include/fxcrt/fx_string.h" - -class CBC_BinaryBitmap; - -class CBC_Reader { - public: - CBC_Reader(); - virtual ~CBC_Reader(); - virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e) = 0; - virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) = 0; -}; - -#endif // XFA_SRC_FXBARCODE_BC_READER_H_ diff --git a/xfa/src/fxbarcode/BC_ResultPoint.cpp b/xfa/src/fxbarcode/BC_ResultPoint.cpp deleted file mode 100644 index 492f156da7..0000000000 --- a/xfa/src/fxbarcode/BC_ResultPoint.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" - -CBC_ResultPoint::CBC_ResultPoint(FX_FLOAT x, FX_FLOAT y) : m_x(x), m_y(y) {} -FX_FLOAT CBC_ResultPoint::GetX() { - return m_x; -} -FX_FLOAT CBC_ResultPoint::GetY() { - return m_y; -} diff --git a/xfa/src/fxbarcode/BC_ResultPoint.h b/xfa/src/fxbarcode/BC_ResultPoint.h deleted file mode 100644 index 6e00a26c79..0000000000 --- a/xfa/src/fxbarcode/BC_ResultPoint.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_BC_RESULTPOINT_H_ -#define XFA_SRC_FXBARCODE_BC_RESULTPOINT_H_ - -#include "core/include/fxcrt/fx_system.h" - -class CBC_ResultPoint { - public: - CBC_ResultPoint(); - CBC_ResultPoint(FX_FLOAT x, FX_FLOAT y); - virtual ~CBC_ResultPoint() {} - virtual FX_FLOAT GetX(); - virtual FX_FLOAT GetY(); - - protected: - FX_FLOAT m_x; - FX_FLOAT m_y; -}; - -#endif // XFA_SRC_FXBARCODE_BC_RESULTPOINT_H_ diff --git a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp deleted file mode 100644 index a5483026eb..0000000000 --- a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp +++ /dev/null @@ -1,148 +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 <algorithm> - -#include "third_party/base/numerics/safe_math.h" -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" - -CBC_TwoDimWriter::CBC_TwoDimWriter() { - m_iCorrectLevel = 1; - m_bFixedSize = TRUE; - m_output = NULL; -} -CBC_TwoDimWriter::~CBC_TwoDimWriter() { - delete m_output; -} -void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device, - const CFX_Matrix* matrix) { - CFX_GraphStateData stateData; - CFX_PathData path; - path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height); - device->DrawPath(&path, matrix, &stateData, m_backgroundColor, - m_backgroundColor, FXFILL_ALTERNATE); - int32_t leftPos = 0; - int32_t topPos = 0; - if (m_bFixedSize) { - leftPos = (m_Width - m_output->GetWidth()) / 2; - topPos = (m_Height - m_output->GetHeight()) / 2; - } - CFX_Matrix matri = *matrix; - if (m_Width < m_output->GetWidth() && m_Height < m_output->GetHeight()) { - CFX_Matrix matriScale( - (FX_FLOAT)m_Width / (FX_FLOAT)m_output->GetWidth(), 0.0, 0.0, - (FX_FLOAT)m_Height / (FX_FLOAT)m_output->GetHeight(), 0.0, 0.0); - matriScale.Concat(*matrix); - matri = matriScale; - } - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - CFX_PathData rect; - rect.AppendRect((FX_FLOAT)leftPos + x, (FX_FLOAT)topPos + y, - (FX_FLOAT)(leftPos + x + 1), (FX_FLOAT)(topPos + y + 1)); - CFX_GraphStateData stateData; - if (m_output->Get(x, y)) { - device->DrawPath(&rect, &matri, &stateData, m_barColor, 0, - FXFILL_WINDING); - } - } - } -} -void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, - int32_t& e) { - if (m_bFixedSize) { - pOutBitmap = CreateDIBitmap(m_Width, m_Height); - } else { - pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); - } - if (!pOutBitmap) { - e = BCExceptionFailToCreateBitmap; - return; - } - pOutBitmap->Clear(m_backgroundColor); - int32_t leftPos = 0; - int32_t topPos = 0; - if (m_bFixedSize) { - leftPos = (m_Width - m_output->GetWidth()) / 2; - topPos = (m_Height - m_output->GetHeight()) / 2; - } - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - if (m_output->Get(x, y)) { - pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor); - } - } - } - if (!m_bFixedSize) { - CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); - if (pOutBitmap) { - delete pOutBitmap; - } - pOutBitmap = pStretchBitmap; - } -} -void CBC_TwoDimWriter::RenderResult(uint8_t* code, - int32_t codeWidth, - int32_t codeHeight, - int32_t& e) { - int32_t inputWidth = codeWidth; - int32_t inputHeight = codeHeight; - int32_t tempWidth = inputWidth + 2; - int32_t tempHeight = inputHeight + 2; - FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight); - moduleHSize = std::min(moduleHSize, 8.0f); - moduleHSize = std::max(moduleHSize, 1.0f); - pdfium::base::CheckedNumeric<int32_t> scaledWidth = tempWidth; - pdfium::base::CheckedNumeric<int32_t> scaledHeight = tempHeight; - scaledWidth *= moduleHSize; - scaledHeight *= moduleHSize; - - int32_t outputWidth = scaledWidth.ValueOrDie(); - int32_t outputHeight = scaledHeight.ValueOrDie(); - if (m_bFixedSize) { - if (m_Width < outputWidth || m_Height < outputHeight) { - e = BCExceptionBitmapSizeError; - return; - } - } else { - if (m_Width > outputWidth || m_Height > outputHeight) { - outputWidth = (int32_t)(outputWidth * - ceil((FX_FLOAT)m_Width / (FX_FLOAT)outputWidth)); - outputHeight = (int32_t)( - outputHeight * ceil((FX_FLOAT)m_Height / (FX_FLOAT)outputHeight)); - } - } - int32_t multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth); - int32_t multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight); - if (m_bFixedSize) { - multiX = std::min(multiX, multiY); - multiY = multiX; - } - int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2; - int32_t topPadding = (outputHeight - (inputHeight * multiY)) / 2; - if (leftPadding < 0) { - leftPadding = 0; - } - if (topPadding < 0) { - topPadding = 0; - } - m_output = new CBC_CommonBitMatrix; - m_output->Init(outputWidth, outputHeight); - for (int32_t inputY = 0, outputY = topPadding; - (inputY < inputHeight) && (outputY < outputHeight - multiY); - inputY++, outputY += multiY) { - for (int32_t inputX = 0, outputX = leftPadding; - (inputX < inputWidth) && (outputX < outputWidth - multiX); - inputX++, outputX += multiX) { - if (code[inputX + inputY * inputWidth] == 1) { - m_output->SetRegion(outputX, outputY, multiX, multiY, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } - } -} diff --git a/xfa/src/fxbarcode/BC_TwoDimWriter.h b/xfa/src/fxbarcode/BC_TwoDimWriter.h deleted file mode 100644 index c46691c619..0000000000 --- a/xfa/src/fxbarcode/BC_TwoDimWriter.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_SRC_FXBARCODE_BC_TWODIMWRITER_H_ -#define XFA_SRC_FXBARCODE_BC_TWODIMWRITER_H_ - -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fxbarcode/BC_Writer.h" - -class CBC_CommonBitMatrix; - -class CBC_TwoDimWriter : public CBC_Writer { - public: - CBC_TwoDimWriter(); - virtual ~CBC_TwoDimWriter(); - virtual void RenderResult(uint8_t* code, - int32_t codeWidth, - int32_t codeHeight, - int32_t& e); - virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, int32_t& e); - virtual void RenderDeviceResult(CFX_RenderDevice* device, - const CFX_Matrix* matrix); - virtual FX_BOOL SetErrorCorrectionLevel(int32_t level) = 0; - virtual int32_t GetErrorCorrectionLevel() { return m_iCorrectLevel; } - - protected: - int32_t m_iCorrectLevel; - FX_BOOL m_bFixedSize; - CBC_CommonBitMatrix* m_output; -}; - -#endif // XFA_SRC_FXBARCODE_BC_TWODIMWRITER_H_ diff --git a/xfa/src/fxbarcode/BC_UtilCodingConvert.cpp b/xfa/src/fxbarcode/BC_UtilCodingConvert.cpp deleted file mode 100644 index dd42cdb5cc..0000000000 --- a/xfa/src/fxbarcode/BC_UtilCodingConvert.cpp +++ /dev/null @@ -1,53 +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/src/fxbarcode/BC_UtilCodingConvert.h" - -CBC_UtilCodingConvert::CBC_UtilCodingConvert() {} - -CBC_UtilCodingConvert::~CBC_UtilCodingConvert() {} - -void CBC_UtilCodingConvert::UnicodeToLocale(const CFX_WideString& src, - CFX_ByteString& dst) { - dst = CFX_ByteString::FromUnicode(src); -} - -void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src, - CFX_ByteString& dst) { - CFX_WideString unicode = CFX_WideString::FromLocal(src); - dst = unicode.UTF8Encode(); -} - -void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src, - CFX_ByteArray& dst) { - CFX_WideString unicode = CFX_WideString::FromLocal(src); - CFX_ByteString utf8 = unicode.UTF8Encode(); - for (int32_t i = 0; i < utf8.GetLength(); i++) { - dst.Add(utf8[i]); - } -} - -void CBC_UtilCodingConvert::Utf8ToLocale(const CFX_ByteArray& src, - CFX_ByteString& dst) { - CFX_ByteString utf8; - for (int32_t i = 0; i < src.GetSize(); i++) { - utf8 += src[i]; - } - CFX_WideString unicode = CFX_WideString::FromUTF8(utf8, utf8.GetLength()); - 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); - dst = CFX_ByteString::FromUnicode(unicode); -} - -void CBC_UtilCodingConvert::UnicodeToUTF8(const CFX_WideString& src, - CFX_ByteString& dst) { - dst = src.UTF8Encode(); -} diff --git a/xfa/src/fxbarcode/BC_UtilCodingConvert.h b/xfa/src/fxbarcode/BC_UtilCodingConvert.h deleted file mode 100644 index 2cfd81a176..0000000000 --- a/xfa/src/fxbarcode/BC_UtilCodingConvert.h +++ /dev/null @@ -1,29 +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_SRC_FXBARCODE_BC_UTILCODINGCONVERT_H_ -#define XFA_SRC_FXBARCODE_BC_UTILCODINGCONVERT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_UtilCodingConvert { - public: - CBC_UtilCodingConvert(); - virtual ~CBC_UtilCodingConvert(); - static void UnicodeToLocale(const CFX_WideString& source, - CFX_ByteString& result); - static void LocaleToUtf8(const CFX_ByteString& source, - CFX_ByteString& result); - static void LocaleToUtf8(const CFX_ByteString& source, CFX_ByteArray& result); - static void Utf8ToLocale(const CFX_ByteArray& source, CFX_ByteString& result); - static void Utf8ToLocale(const uint8_t* source, - int32_t count, - CFX_ByteString& result); - static void UnicodeToUTF8(const CFX_WideString& source, - CFX_ByteString& result); -}; - -#endif // XFA_SRC_FXBARCODE_BC_UTILCODINGCONVERT_H_ diff --git a/xfa/src/fxbarcode/BC_UtilRSS.cpp b/xfa/src/fxbarcode/BC_UtilRSS.cpp deleted file mode 100644 index dcc12e2268..0000000000 --- a/xfa/src/fxbarcode/BC_UtilRSS.cpp +++ /dev/null @@ -1,164 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_UtilRSS.h" - -#include <memory> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_UtilRSS::CBC_UtilRSS() {} -CBC_UtilRSS::~CBC_UtilRSS() {} -CFX_Int32Array* CBC_UtilRSS::GetRssWidths(int32_t val, - int32_t n, - int32_t elements, - int32_t maxWidth, - FX_BOOL noNarrow) { - std::unique_ptr<CFX_Int32Array> widths(new CFX_Int32Array); - widths->SetSize(elements); - int32_t bar; - int32_t narrowMask = 0; - for (bar = 0; bar < elements - 1; bar++) { - narrowMask |= (1 << bar); - int32_t elmWidth = 1; - int32_t subVal; - while (TRUE) { - subVal = Combins(n - elmWidth - 1, elements - bar - 2); - if (noNarrow && (narrowMask == 0) && - (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { - subVal -= Combins(n - elmWidth - (elements - bar), elements - bar - 2); - } - if (elements - bar - 1 > 1) { - int32_t lessVal = 0; - for (int32_t mxwElement = n - elmWidth - (elements - bar - 2); - mxwElement > maxWidth; mxwElement--) { - lessVal += Combins(n - elmWidth - mxwElement - 1, elements - bar - 3); - } - subVal -= lessVal * (elements - 1 - bar); - } else if (n - elmWidth > maxWidth) { - subVal--; - } - val -= subVal; - if (val < 0) { - break; - } - elmWidth++; - narrowMask &= ~(1 << bar); - } - val += subVal; - n -= elmWidth; - (*widths)[bar] = elmWidth; - } - (*widths)[bar] = n; - return widths.release(); -} -int32_t CBC_UtilRSS::GetRSSvalue(CFX_Int32Array& widths, - int32_t maxWidth, - FX_BOOL noNarrow) { - int32_t elements = widths.GetSize(); - int32_t n = 0; - for (int32_t i = 0; i < elements; i++) { - n += widths[i]; - } - int32_t val = 0; - int32_t narrowMask = 0; - for (int32_t bar = 0; bar < elements - 1; bar++) { - int32_t elmWidth; - for (elmWidth = 1, narrowMask |= (1 << bar); elmWidth < widths[bar]; - elmWidth++, narrowMask &= ~(1 << bar)) { - int32_t subVal = Combins(n - elmWidth - 1, elements - bar - 2); - if (noNarrow && (narrowMask == 0) && - (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { - subVal -= Combins(n - elmWidth - (elements - bar), elements - bar - 2); - } - if (elements - bar - 1 > 1) { - int32_t lessVal = 0; - for (int32_t mxwElement = n - elmWidth - (elements - bar - 2); - mxwElement > maxWidth; mxwElement--) { - lessVal += Combins(n - elmWidth - mxwElement - 1, elements - bar - 3); - } - subVal -= lessVal * (elements - 1 - bar); - } else if (n - elmWidth > maxWidth) { - subVal--; - } - val += subVal; - } - n -= elmWidth; - } - return val; -} -int32_t CBC_UtilRSS::Combins(int32_t n, int32_t r) { - int32_t maxDenom; - int32_t minDenom; - if (n - r > r) { - minDenom = r; - maxDenom = n - r; - } else { - minDenom = n - r; - maxDenom = r; - } - int32_t val = 1; - int32_t j = 1; - for (int32_t i = n; i > maxDenom; i--) { - val *= i; - if (j <= minDenom) { - val /= j; - j++; - } - } - while (j <= minDenom) { - val /= j; - j++; - } - return val; -} -CFX_Int32Array* CBC_UtilRSS::Elements(CFX_Int32Array& eDist, - int32_t N, - int32_t K) { - CFX_Int32Array* widths = new CFX_Int32Array; - widths->SetSize(eDist.GetSize() + 2); - int32_t twoK = K << 1; - (*widths)[0] = 1; - int32_t i; - int32_t minEven = 10; - int32_t barSum = 1; - for (i = 1; i < twoK - 2; i += 2) { - (*widths)[i] = eDist[i - 1] - (*widths)[i - 1]; - (*widths)[i + 1] = eDist[i] - (*widths)[i]; - barSum += (*widths)[i] + (*widths)[i + 1]; - if ((*widths)[i] < minEven) { - minEven = (*widths)[i]; - } - } - (*widths)[twoK - 1] = N - barSum; - if ((*widths)[twoK - 1] < minEven) { - minEven = (*widths)[twoK - 1]; - } - if (minEven > 1) { - for (i = 0; i < twoK; i += 2) { - (*widths)[i] += minEven - 1; - (*widths)[i + 1] -= minEven - 1; - } - } - return widths; -} diff --git a/xfa/src/fxbarcode/BC_UtilRSS.h b/xfa/src/fxbarcode/BC_UtilRSS.h deleted file mode 100644 index 825a555744..0000000000 --- a/xfa/src/fxbarcode/BC_UtilRSS.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_BC_UTILRSS_H_ -#define XFA_SRC_FXBARCODE_BC_UTILRSS_H_ - -#include <cstdint> - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_UtilRSS { - public: - virtual ~CBC_UtilRSS(); - static int32_t GetRSSvalue(CFX_Int32Array& widths, - int32_t maxWidth, - FX_BOOL noNarrow); - - protected: - static CFX_Int32Array* GetRssWidths(int32_t val, - int32_t n, - int32_t elements, - int32_t maxWidth, - FX_BOOL noNarrow); - static int32_t Combins(int32_t n, int32_t r); - static CFX_Int32Array* Elements(CFX_Int32Array& eDist, int32_t N, int32_t K); - - private: - CBC_UtilRSS(); -}; - -#endif // XFA_SRC_FXBARCODE_BC_UTILRSS_H_ diff --git a/xfa/src/fxbarcode/BC_Utils.cpp b/xfa/src/fxbarcode/BC_Utils.cpp deleted file mode 100644 index 5c681a99d7..0000000000 --- a/xfa/src/fxbarcode/BC_Utils.cpp +++ /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 - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString& dst, - FX_DWORD first, - FX_DWORD last, - int32_t count, - FX_CHAR c) { - if (first > last || count <= 0) { - return FALSE; - } - dst.Delete(first, last - first); - for (int32_t i = 0; i < count; i++) { - dst.Insert(0, c); - } - return TRUE; -} -void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c) { - for (int32_t i = 0; i < count; i++) { - dst += c; - } -} -void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba) { - for (int32_t i = 0; i < ba.GetSize(); i++) { - 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/xfa/src/fxbarcode/BC_Writer.cpp b/xfa/src/fxbarcode/BC_Writer.cpp deleted file mode 100644 index 87b856a61e..0000000000 --- a/xfa/src/fxbarcode/BC_Writer.cpp +++ /dev/null @@ -1,56 +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/src/fxbarcode/BC_Writer.h" - -CBC_Writer::CBC_Writer() { - m_CharEncoding = 0; - m_ModuleHeight = 1; - m_ModuleWidth = 1; - m_Height = 320; - m_Width = 640; - m_colorSpace = FXDIB_Argb; - m_barColor = 0xff000000; - m_backgroundColor = 0xffffffff; -} -CBC_Writer::~CBC_Writer() {} -FX_BOOL CBC_Writer::SetCharEncoding(int32_t encoding) { - m_CharEncoding = encoding; - return TRUE; -} -FX_BOOL CBC_Writer::SetModuleHeight(int32_t moduleHeight) { - if (moduleHeight > 10 || moduleHeight < 1) { - return FALSE; - } - m_ModuleHeight = moduleHeight; - return TRUE; -} -FX_BOOL CBC_Writer::SetModuleWidth(int32_t moduleWidth) { - if (moduleWidth > 10 || moduleWidth < 1) { - return FALSE; - } - m_ModuleWidth = moduleWidth; - return TRUE; -} -FX_BOOL CBC_Writer::SetHeight(int32_t height) { - m_Height = height; - return TRUE; -} -FX_BOOL CBC_Writer::SetWidth(int32_t width) { - m_Width = width; - return TRUE; -} -void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) { - m_backgroundColor = backgroundColor; -} -void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { - m_barColor = foregroundColor; -} -CFX_DIBitmap* CBC_Writer::CreateDIBitmap(int32_t width, int32_t height) { - CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; - pDIBitmap->Create(width, height, m_colorSpace); - return pDIBitmap; -} diff --git a/xfa/src/fxbarcode/BC_Writer.h b/xfa/src/fxbarcode/BC_Writer.h deleted file mode 100644 index a1ebfd0dff..0000000000 --- a/xfa/src/fxbarcode/BC_Writer.h +++ /dev/null @@ -1,38 +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_SRC_FXBARCODE_BC_WRITER_H_ -#define XFA_SRC_FXBARCODE_BC_WRITER_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxge/fx_dib.h" -#include "xfa/src/fxbarcode/utils.h" - -class CBC_Writer { - public: - CBC_Writer(); - virtual ~CBC_Writer(); - virtual FX_BOOL SetCharEncoding(int32_t 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 void SetBackgroundColor(FX_ARGB backgroundColor); - virtual void SetBarcodeColor(FX_ARGB foregroundColor); - - protected: - CFX_DIBitmap* CreateDIBitmap(int32_t width, int32_t height); - int32_t m_CharEncoding; - int32_t m_ModuleHeight; - int32_t m_ModuleWidth; - int32_t m_Height; - int32_t m_Width; - FXDIB_Format m_colorSpace; - FX_ARGB m_barColor; - FX_ARGB m_backgroundColor; -}; - -#endif // XFA_SRC_FXBARCODE_BC_WRITER_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp deleted file mode 100644 index 43f1758720..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp +++ /dev/null @@ -1,113 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array) { - m_size = array->GetSize(); - m_bits.Copy(array->GetBits()); -} -CBC_CommonBitArray::CBC_CommonBitArray() { - m_bits.SetSize(1); - m_size = 0; -} -CBC_CommonBitArray::CBC_CommonBitArray(int32_t size) { - m_bits.SetSize((size + 31) >> 5); - m_size = size; -} -CBC_CommonBitArray::~CBC_CommonBitArray() { - m_size = 0; -} -int32_t CBC_CommonBitArray::GetSize() { - return m_size; -} -CFX_Int32Array& CBC_CommonBitArray::GetBits() { - return m_bits; -} -int32_t CBC_CommonBitArray::GetSizeInBytes() { - return (m_size + 7) >> 3; -} -FX_BOOL CBC_CommonBitArray::Get(int32_t i) { - return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0; -} -void CBC_CommonBitArray::Set(int32_t i) { - m_bits[i >> 5] |= 1 << (i & 0x1F); -} -void CBC_CommonBitArray::Flip(int32_t i) { - m_bits[i >> 5] ^= 1 << (i & 0x1F); -} -void CBC_CommonBitArray::SetBulk(int32_t i, int32_t newBits) { - m_bits[i >> 5] = newBits; -} -void CBC_CommonBitArray::Clear() { - FXSYS_memset(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(int32_t)); -} -FX_BOOL CBC_CommonBitArray::IsRange(int32_t start, - int32_t end, - FX_BOOL value, - int32_t& e) { - if (end < start) { - e = BCExceptionEndLessThanStart; - return FALSE; - } - if (end == start) { - return TRUE; - } - end--; - int32_t firstInt = start >> 5; - int32_t lastInt = end >> 5; - int32_t i; - for (i = firstInt; i <= lastInt; i++) { - int32_t firstBit = i > firstInt ? 0 : start & 0x1F; - int32_t lastBit = i < lastInt ? 31 : end & 0x1F; - int32_t mask; - if (firstBit == 0 && lastBit == 31) { - mask = -1; - } else { - mask = 0; - for (int32_t j = firstBit; j <= lastBit; j++) { - mask |= 1 << j; - } - } - if ((m_bits[i] & mask) != (value ? mask : 0)) { - return FALSE; - } - } - return TRUE; -} -int32_t* CBC_CommonBitArray::GetBitArray() { - return &m_bits[0]; -} -void CBC_CommonBitArray::Reverse() { - int32_t* newBits = FX_Alloc(int32_t, m_bits.GetSize()); - FXSYS_memset(newBits, 0x00, m_bits.GetSize() * sizeof(int32_t)); - int32_t size = m_size; - int32_t i; - for (i = 0; i < size; i++) { - if (Get(size - i - 1)) { - newBits[i >> 5] |= 1 << (i & 0x1F); - } - } - FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t)); - FX_Free(newBits); -} diff --git a/xfa/src/fxbarcode/common/BC_CommonBitArray.h b/xfa/src/fxbarcode/common/BC_CommonBitArray.h deleted file mode 100644 index bf2b3559b7..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitArray.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_SRC_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitArray { - public: - CBC_CommonBitArray(CBC_CommonBitArray* array); - CBC_CommonBitArray(int32_t size); - CBC_CommonBitArray(); - virtual ~CBC_CommonBitArray(); - int32_t GetSize(); - CFX_Int32Array& GetBits(); - int32_t GetSizeInBytes(); - FX_BOOL Get(int32_t i); - void Set(int32_t i); - void Flip(int32_t i); - void SetBulk(int32_t i, int32_t newBits); - FX_BOOL IsRange(int32_t start, int32_t end, FX_BOOL value, int32_t& e); - int32_t* GetBitArray(); - void Reverse(); - void Clear(); - - private: - int32_t m_size; - CFX_Int32Array m_bits; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp deleted file mode 100644 index 3a8fa15e2b..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp +++ /dev/null @@ -1,146 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_CommonBitMatrix::CBC_CommonBitMatrix() { - m_width = 0; - m_height = 0; - m_rowSize = 0; - m_bits = NULL; -} -void CBC_CommonBitMatrix::Init(int32_t dimension) { - m_width = dimension; - m_height = dimension; - int32_t rowSize = (m_height + 31) >> 5; - m_rowSize = rowSize; - m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { - m_width = width; - m_height = height; - int32_t rowSize = (width + 31) >> 5; - m_rowSize = rowSize; - m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { - FX_Free(m_bits); -} -FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - if (offset >= m_rowSize * m_height || offset < 0) { - return false; - } - return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; -} -int32_t* CBC_CommonBitMatrix::GetBits() { - return m_bits; -} -void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - if (offset >= m_rowSize * m_height || offset < 0) { - return; - } - m_bits[offset] |= 1 << (x & 0x1f); -} -void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - m_bits[offset] ^= 1 << (x & 0x1f); -} -void CBC_CommonBitMatrix::Clear() { - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -void CBC_CommonBitMatrix::SetRegion(int32_t left, - int32_t top, - int32_t width, - int32_t height, - int32_t& e) { - if (top < 0 || left < 0) { - e = BCExceptionLeftAndTopMustBeNonnegative; - return; - } - if (height < 1 || width < 1) { - e = BCExceptionHeightAndWidthMustBeAtLeast1; - return; - } - int32_t right = left + width; - int32_t bottom = top + height; - if (m_height < bottom || m_width < right) { - e = BCExceptionRegionMustFitInsideMatrix; - return; - } - int32_t y; - for (y = top; y < bottom; y++) { - int32_t offset = y * m_rowSize; - int32_t x; - for (x = left; x < right; x++) { - m_bits[offset + (x >> 5)] |= 1 << (x & 0x1f); - } - } -} -CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y, - CBC_CommonBitArray* row) { - CBC_CommonBitArray* rowArray = NULL; - if (row == NULL || row->GetSize() < m_width) { - rowArray = new CBC_CommonBitArray(m_width); - } else { - rowArray = new CBC_CommonBitArray(row); - } - int32_t offset = y * m_rowSize; - int32_t x; - for (x = 0; x < m_rowSize; x++) { - rowArray->SetBulk(x << 5, m_bits[offset + x]); - } - return rowArray; -} -void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) { - int32_t l = y * m_rowSize; - for (int32_t i = 0; i < m_rowSize; i++) { - m_bits[l] = row->GetBitArray()[i]; - l++; - } -} -void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) { - for (int32_t i = 0; i < col->GetBits().GetSize(); i++) { - m_bits[i * m_rowSize + y] = col->GetBitArray()[i]; - } -} -int32_t CBC_CommonBitMatrix::GetWidth() { - return m_width; -} -int32_t CBC_CommonBitMatrix::GetHeight() { - return m_height; -} -int32_t CBC_CommonBitMatrix::GetRowSize() { - return m_rowSize; -} -int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { - if (m_width != m_height) { - e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; - return 0; - } - return m_width; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h deleted file mode 100644 index 86838a1d91..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h +++ /dev/null @@ -1,46 +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_SRC_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ - -#include "core/include/fxcrt/fx_system.h" - -class CBC_CommonBitArray; - -class CBC_CommonBitMatrix { - public: - CBC_CommonBitMatrix(); - virtual ~CBC_CommonBitMatrix(); - FX_BOOL Get(int32_t x, int32_t y); - void Set(int32_t x, int32_t y); - void Flip(int32_t x, int32_t y); - void Clear(); - void SetRegion(int32_t left, - int32_t top, - int32_t width, - int32_t height, - int32_t& e); - CBC_CommonBitArray* GetRow(int32_t y, CBC_CommonBitArray* row); - void SetRow(int32_t y, CBC_CommonBitArray* row); - CBC_CommonBitArray* GetCol(int32_t y, CBC_CommonBitArray* row); - void SetCol(int32_t y, CBC_CommonBitArray* col); - int32_t GetWidth(); - int32_t GetHeight(); - int32_t GetRowSize(); - int32_t GetDimension(int32_t& e); - virtual void Init(int32_t dimension); - virtual void Init(int32_t width, int32_t height); - int32_t* GetBits(); - - private: - int32_t m_width; - int32_t m_height; - int32_t m_rowSize; - int32_t* m_bits; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp b/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp deleted file mode 100644 index dc10002f84..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp +++ /dev/null @@ -1,71 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitSource.h" - -CBC_CommonBitSource::CBC_CommonBitSource(CFX_ByteArray* bytes) { - m_bytes.Copy((*bytes)); - m_bitOffset = 0; - m_byteOffset = 0; -} -CBC_CommonBitSource::~CBC_CommonBitSource() {} -int32_t CBC_CommonBitSource::ReadBits(int32_t numBits, int32_t& e) { - if (numBits < 1 || numBits > 32) { - e = BCExceptionIllegalArgument; - return 0; - } - int32_t result = 0; - if (m_bitOffset > 0) { - int32_t bitsLeft = 8 - m_bitOffset; - int32_t toRead = numBits < bitsLeft ? numBits : bitsLeft; - int32_t bitsToNotRead = bitsLeft - toRead; - int32_t mask = (0xff >> (8 - toRead)) << bitsToNotRead; - result = (m_bytes[m_byteOffset] & mask) >> bitsToNotRead; - numBits -= toRead; - m_bitOffset += toRead; - if (m_bitOffset == 8) { - m_bitOffset = 0; - m_byteOffset++; - } - } - if (numBits > 0) { - while (numBits >= 8) { - result = (result << 8) | (m_bytes[m_byteOffset] & 0xff); - m_byteOffset++; - numBits -= 8; - } - if (numBits > 0) { - int32_t bitsToNotRead = 8 - numBits; - int32_t mask = (0xff >> bitsToNotRead) << bitsToNotRead; - result = (result << numBits) | - ((m_bytes[m_byteOffset] & mask) >> bitsToNotRead); - m_bitOffset += numBits; - } - } - return result; -} -int32_t CBC_CommonBitSource::Available() { - return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset; -} -int32_t CBC_CommonBitSource::getByteOffset() { - return m_byteOffset; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonBitSource.h b/xfa/src/fxbarcode/common/BC_CommonBitSource.h deleted file mode 100644 index 0e2a4bfb58..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonBitSource.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_SRC_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -class CBC_CommonBitSource { - public: - CBC_CommonBitSource(CFX_ByteArray* bytes); - virtual ~CBC_CommonBitSource(); - int32_t ReadBits(int32_t numBits, int32_t& e); - int32_t Available(); - int32_t getByteOffset(); - - private: - CFX_ByteArray m_bytes; - int32_t m_byteOffset; - int32_t m_bitOffset; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONBITSOURCE_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp deleted file mode 100644 index 1a6ef9f63f..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp +++ /dev/null @@ -1,99 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> - -#include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" - -CBC_CommonByteArray::CBC_CommonByteArray() { - m_bytes = NULL; - m_size = 0; - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - FXSYS_memset(m_bytes, 0, size); - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - FXSYS_memcpy(m_bytes, byteArray, size); - m_index = size; -} -CBC_CommonByteArray::~CBC_CommonByteArray() { - FX_Free(m_bytes); -} -int32_t CBC_CommonByteArray::At(int32_t index) { - return m_bytes[index] & 0xff; -} -void CBC_CommonByteArray::Set(int32_t index, int32_t value) { - m_bytes[index] = (uint8_t)value; -} -int32_t CBC_CommonByteArray::Size() { - return m_size; -} -FX_BOOL CBC_CommonByteArray::IsEmpty() { - return m_size == 0; -} -void CBC_CommonByteArray::AppendByte(int32_t value) { - if (m_size == 0 || m_index >= m_size) { - int32_t newSize = std::max(32, m_size << 1); - Reserve(newSize); - } - m_bytes[m_index] = (uint8_t)value; - m_index++; -} -void CBC_CommonByteArray::Reserve(int32_t capacity) { - if (m_bytes == NULL || m_size < capacity) { - uint8_t* newArray = FX_Alloc(uint8_t, capacity); - if (m_bytes) { - FXSYS_memcpy(newArray, m_bytes, m_size); - FXSYS_memset(newArray + m_size, 0, capacity - m_size); - } else { - FXSYS_memset(newArray, 0, capacity); - } - FX_Free(m_bytes); - m_bytes = newArray; - m_size = capacity; - } -} -void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - FXSYS_memcpy(m_bytes, source + offset, count); - m_index = count; -} -void CBC_CommonByteArray::Set(CFX_ByteArray* source, - int32_t offset, - int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - int32_t i; - for (i = 0; i < count; i++) { - m_bytes[i] = source->operator[](i + offset); - } - m_index = m_size; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.h b/xfa/src/fxbarcode/common/BC_CommonByteArray.h deleted file mode 100644 index c8fb05d50a..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonByteArray.h +++ /dev/null @@ -1,33 +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_SRC_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonByteArray { - private: - int32_t m_size; - int32_t m_index; - uint8_t* m_bytes; - - public: - CBC_CommonByteArray(); - CBC_CommonByteArray(int32_t size); - CBC_CommonByteArray(uint8_t* byteArray, int32_t size); - virtual ~CBC_CommonByteArray(); - int32_t At(int32_t index); - void Set(int32_t index, int32_t value); - int32_t Size(); - FX_BOOL IsEmpty(); - void AppendByte(int32_t value); - void Reserve(int32_t capacity); - void Set(uint8_t* source, int32_t offset, int32_t count); - void Set(CFX_ByteArray* source, int32_t offset, int32_t count); -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp deleted file mode 100644 index 69c39a766c..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp +++ /dev/null @@ -1,64 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcrt/fx_memory.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" - -CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) { - m_height = height; - m_width = width; - m_bytes = NULL; -} -void CBC_CommonByteMatrix::Init() { - m_bytes = FX_Alloc2D(uint8_t, m_height, m_width); - FXSYS_memset(m_bytes, 0xff, m_height * m_width); -} -CBC_CommonByteMatrix::~CBC_CommonByteMatrix() { - FX_Free(m_bytes); -} -int32_t CBC_CommonByteMatrix::GetHeight() { - return m_height; -} -int32_t CBC_CommonByteMatrix::GetWidth() { - return m_width; -} -uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) { - return m_bytes[y * m_width + x]; -} -void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) { - m_bytes[y * m_width + x] = (uint8_t)value; -} -void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) { - m_bytes[y * m_width + x] = value; -} -void CBC_CommonByteMatrix::clear(uint8_t value) { - int32_t y; - for (y = 0; y < m_height; y++) { - int32_t x; - for (x = 0; x < m_width; x++) { - m_bytes[y * m_width + x] = value; - } - } -} -uint8_t* CBC_CommonByteMatrix::GetArray() { - return m_bytes; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h deleted file mode 100644 index d9af45d2f3..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ - -#include <stdint.h> - -#include "core/include/fxcrt/fx_system.h" - -class CBC_CommonByteMatrix { - public: - CBC_CommonByteMatrix(int32_t width, int32_t height); - virtual ~CBC_CommonByteMatrix(); - int32_t GetHeight(); - int32_t GetWidth(); - uint8_t Get(int32_t x, int32_t y); - uint8_t* GetArray(); - - void Set(int32_t x, int32_t y, int32_t value); - void Set(int32_t x, int32_t y, uint8_t value); - void clear(uint8_t value); - virtual void Init(); - - private: - uint8_t* m_bytes; - int32_t m_width; - int32_t m_height; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp deleted file mode 100644 index 58347c37bd..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h" -#include "xfa/src/fxbarcode/common/BC_CommonECI.h" - -void CBC_CommonCharacterSetECI::initialize() {} -CBC_CommonCharacterSetECI::CBC_CommonCharacterSetECI( - int32_t value, - CFX_ByteString encodingName) - : CBC_CommonECI(value), m_encodingName(encodingName) {} -CBC_CommonCharacterSetECI::~CBC_CommonCharacterSetECI() {} -CFX_ByteString CBC_CommonCharacterSetECI::GetEncodingName() { - return m_encodingName; -} -void CBC_CommonCharacterSetECI::AddCharacterSet(int32_t value, - CFX_ByteString encodingName) {} -CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByValue( - int32_t value) { - return NULL; -} -CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByName( - const CFX_ByteString& name) { - return NULL; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h deleted file mode 100644 index c593b94f7a..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h +++ /dev/null @@ -1,29 +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_SRC_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fxbarcode/common/BC_CommonECI.h" - -class CBC_CommonCharacterSetECI : public CBC_CommonECI { - public: - CBC_CommonCharacterSetECI(int32_t value, CFX_ByteString encodingName); - virtual ~CBC_CommonCharacterSetECI(); - CFX_ByteString GetEncodingName(); - static void AddCharacterSet(int32_t value, CFX_ByteString encodingName); - int32_t GetValue(); - static CBC_CommonCharacterSetECI* GetCharacterSetECIByValue(int32_t value); - static CBC_CommonCharacterSetECI* GetCharacterSetECIByName( - const CFX_ByteString& name); - - private: - CFX_ByteString m_encodingName; - static void initialize(); -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONCHARACTERSETECI_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp deleted file mode 100644 index a4ad0c4e65..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp +++ /dev/null @@ -1,77 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_CommonDecoderResult::CBC_CommonDecoderResult() {} -void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes, - const CFX_ByteString& text, - const CFX_Int32Array& byteSegments, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t& e) { - if (text.IsEmpty()) { - e = BCExceptionIllegalArgument; - return; - } - m_rawBytes.Copy(rawBytes); - m_text = text; - m_byteSegments.Copy(byteSegments); - m_ecLevel = ecLevel; - m_other = NULL; -} -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()) { - e = BCExceptionIllegalArgument; - return; - } - m_rawBytes.Copy(rawBytes); - m_text = text; - m_pdf417byteSegments.Copy(byteSegments); - m_pdf417ecLevel = ecLevel; - m_other = NULL; -} -void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other) { - m_other = other; -} -CBC_CommonDecoderResult::~CBC_CommonDecoderResult() { - delete m_other; -} -const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() { - return m_rawBytes; -} -const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments() { - return m_byteSegments; -} -const CFX_ByteString& CBC_CommonDecoderResult::GetText() { - return m_text; -} -CBC_QRCoderErrorCorrectionLevel* CBC_CommonDecoderResult::GetECLevel() { - return m_ecLevel; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h deleted file mode 100644 index 185f38d082..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h +++ /dev/null @@ -1,45 +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_SRC_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_QRCoderErrorCorrectionLevel; -class CBC_PDF417ResultMetadata; - -class CBC_CommonDecoderResult { - public: - CBC_CommonDecoderResult(); - virtual ~CBC_CommonDecoderResult(); - const CFX_ByteArray& GetRawBytes(); - const CFX_ByteString& GetText(); - const CFX_Int32Array& GetByteSegments(); - CBC_QRCoderErrorCorrectionLevel* GetECLevel(); - virtual void Init(const CFX_ByteArray& rawBytes, - const CFX_ByteString& text, - const CFX_Int32Array& byteSegments, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - 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); - - private: - 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; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONDECODERRESULT_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.cpp b/xfa/src/fxbarcode/common/BC_CommonECI.cpp deleted file mode 100644 index 146c9e24ba..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonECI.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h" -#include "xfa/src/fxbarcode/common/BC_CommonECI.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_CommonECI::CBC_CommonECI(int32_t value) { - m_value = value; -} -CBC_CommonECI::~CBC_CommonECI() {} -int32_t CBC_CommonECI::GetValue() { - return m_value; -} -CBC_CommonECI* CBC_CommonECI::GetEICByValue(int32_t value, int32_t& e) { - if (value < 0 || value > 999999) { - e = BCExceptionBadECI; - return NULL; - } - if (value < 900) { - } - return NULL; -} diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.h b/xfa/src/fxbarcode/common/BC_CommonECI.h deleted file mode 100644 index e0dc797fbf..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonECI.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_SRC_FXBARCODE_COMMON_BC_COMMONECI_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONECI_H_ - -#include <stdint.h> - -class CBC_CommonECI { - public: - CBC_CommonECI(int32_t value); - virtual ~CBC_CommonECI(); - - int32_t GetValue(); - static CBC_CommonECI* GetEICByValue(int32_t value, int32_t& e); - - private: - int32_t m_value; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONECI_H_ diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp deleted file mode 100644 index 897d9537fd..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp +++ /dev/null @@ -1,153 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" - -#include <memory> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11, - FX_FLOAT a21, - FX_FLOAT a31, - FX_FLOAT a12, - FX_FLOAT a22, - FX_FLOAT a32, - FX_FLOAT a13, - FX_FLOAT a23, - FX_FLOAT a33) - : m_a11(a11), - m_a12(a12), - m_a13(a13), - m_a21(a21), - m_a22(a22), - m_a23(a23), - m_a31(a31), - m_a32(a32), - m_a33(a33) { -} -CBC_CommonPerspectiveTransform::~CBC_CommonPerspectiveTransform() {} -CBC_CommonPerspectiveTransform* -CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3, - FX_FLOAT x0p, - FX_FLOAT y0p, - FX_FLOAT x1p, - FX_FLOAT y1p, - FX_FLOAT x2p, - FX_FLOAT y2p, - FX_FLOAT x3p, - FX_FLOAT y3p) { - std::unique_ptr<CBC_CommonPerspectiveTransform> qToS( - QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3)); - std::unique_ptr<CBC_CommonPerspectiveTransform> sToQ( - SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)); - return sToQ->Times(*(qToS.get())); -} -void CBC_CommonPerspectiveTransform::TransformPoints(CFX_FloatArray* points) { - int32_t max = points->GetSize(); - FX_FLOAT a11 = m_a11; - FX_FLOAT a12 = m_a12; - FX_FLOAT a13 = m_a13; - FX_FLOAT a21 = m_a21; - FX_FLOAT a22 = m_a22; - FX_FLOAT a23 = m_a23; - FX_FLOAT a31 = m_a31; - FX_FLOAT a32 = m_a32; - FX_FLOAT a33 = m_a33; - int32_t i; - for (i = 0; i < max; i += 2) { - FX_FLOAT x = (*points)[i]; - FX_FLOAT y = (*points)[i + 1]; - FX_FLOAT denominator = a13 * x + a23 * y + a33; - (*points)[i] = (a11 * x + a21 * y + a31) / denominator; - (*points)[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } -} -CBC_CommonPerspectiveTransform* -CBC_CommonPerspectiveTransform::SquareToQuadrilateral(FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3) { - FX_FLOAT dy2 = y3 - y2; - FX_FLOAT dy3 = y0 - y1 + y2 - y3; - if ((dy2 == 0.0f) && (dy3 == 0.0f)) { - return new CBC_CommonPerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, - y2 - y1, y0, 0.0f, 0.0f, 1.0f); - } else { - FX_FLOAT dx1 = x1 - x2; - FX_FLOAT dx2 = x3 - x2; - FX_FLOAT dx3 = x0 - x1 + x2 - x3; - FX_FLOAT dy1 = y1 - y2; - FX_FLOAT denominator = dx1 * dy2 - dx2 * dy1; - FX_FLOAT a13 = (dx3 * dy2 - dx2 * dy3) / denominator; - FX_FLOAT a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - return new CBC_CommonPerspectiveTransform( - x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, - y3 - y0 + a23 * y3, y0, a13, a23, 1.0f); - } -} -CBC_CommonPerspectiveTransform* -CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3) { - std::unique_ptr<CBC_CommonPerspectiveTransform> temp1( - SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); - return temp1->BuildAdjoint(); -} -CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::BuildAdjoint() { - return new CBC_CommonPerspectiveTransform( - m_a22 * m_a33 - m_a23 * m_a32, m_a23 * m_a31 - m_a21 * m_a33, - m_a21 * m_a32 - m_a22 * m_a31, m_a13 * m_a32 - m_a12 * m_a33, - m_a11 * m_a33 - m_a13 * m_a31, m_a12 * m_a31 - m_a11 * m_a32, - m_a12 * m_a23 - m_a13 * m_a22, m_a13 * m_a21 - m_a11 * m_a23, - m_a11 * m_a22 - m_a12 * m_a21); -} -CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::Times( - CBC_CommonPerspectiveTransform& other) { - return new CBC_CommonPerspectiveTransform( - m_a11 * other.m_a11 + m_a21 * other.m_a12 + m_a31 * other.m_a13, - m_a11 * other.m_a21 + m_a21 * other.m_a22 + m_a31 * other.m_a23, - m_a11 * other.m_a31 + m_a21 * other.m_a32 + m_a31 * other.m_a33, - m_a12 * other.m_a11 + m_a22 * other.m_a12 + m_a32 * other.m_a13, - m_a12 * other.m_a21 + m_a22 * other.m_a22 + m_a32 * other.m_a23, - m_a12 * other.m_a31 + m_a22 * other.m_a32 + m_a32 * other.m_a33, - m_a13 * other.m_a11 + m_a23 * other.m_a12 + m_a33 * other.m_a13, - m_a13 * other.m_a21 + m_a23 * other.m_a22 + m_a33 * other.m_a23, - m_a13 * other.m_a31 + m_a23 * other.m_a32 + m_a33 * other.m_a33); -} diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h deleted file mode 100644 index dfe0ce1f2d..0000000000 --- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h +++ /dev/null @@ -1,65 +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_SRC_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonPerspectiveTransform { - public: - CBC_CommonPerspectiveTransform(FX_FLOAT a11, - FX_FLOAT a21, - FX_FLOAT a31, - FX_FLOAT a12, - FX_FLOAT a22, - FX_FLOAT a32, - FX_FLOAT a13, - FX_FLOAT a23, - FX_FLOAT a33); - virtual ~CBC_CommonPerspectiveTransform(); - static CBC_CommonPerspectiveTransform* QuadrilateralToQuadrilateral( - FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3, - FX_FLOAT x0p, - FX_FLOAT y0p, - FX_FLOAT x1p, - FX_FLOAT y1p, - FX_FLOAT x2p, - FX_FLOAT y2p, - FX_FLOAT x3p, - FX_FLOAT y3p); - static CBC_CommonPerspectiveTransform* SquareToQuadrilateral(FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3); - static CBC_CommonPerspectiveTransform* QuadrilateralToSquare(FX_FLOAT x0, - FX_FLOAT y0, - FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_FLOAT x3, - FX_FLOAT y3); - CBC_CommonPerspectiveTransform* BuildAdjoint(); - CBC_CommonPerspectiveTransform* Times(CBC_CommonPerspectiveTransform& other); - void TransformPoints(CFX_FloatArray* points); - - private: - FX_FLOAT m_a11, m_a12, m_a13, m_a21, m_a22, m_a23, m_a31, m_a32, m_a33; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_COMMONPERSPECTIVETRANSFORM_H_ diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp deleted file mode 100644 index 8babc9c78f..0000000000 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp +++ /dev/null @@ -1,173 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" - -#include <memory> - -#include "xfa/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t LUMINANCE_BITS = 5; -const int32_t LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; -const int32_t LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; - -CBC_GlobalHistogramBinarizer::CBC_GlobalHistogramBinarizer( - CBC_LuminanceSource* source) - : CBC_Binarizer(source) {} -CBC_GlobalHistogramBinarizer::~CBC_GlobalHistogramBinarizer() {} -CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow( - int32_t y, - CBC_CommonBitArray* row, - int32_t& e) { - CBC_LuminanceSource* source = GetLuminanceSource(); - int32_t width = source->GetWidth(); - std::unique_ptr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width)); - InitArrays(width); - CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e); - if (e != BCExceptionNO) { - return result.release(); - } - CFX_Int32Array localBuckets; - localBuckets.Copy(m_buckets); - int32_t x; - for (x = 0; x < width; x++) { - int32_t pixel = (*localLuminances)[x] & 0xff; - localBuckets[pixel >> LUMINANCE_SHIFT]++; - } - int32_t blackPoint = EstimateBlackPoint(localBuckets, e); - if (e != BCExceptionNO) { - return result.release(); - } - int32_t left = (*localLuminances)[0] & 0xff; - int32_t center = (*localLuminances)[1] & 0xff; - for (x = 1; x < width - 1; x++) { - int32_t right = (*localLuminances)[x + 1] & 0xff; - int32_t luminance = ((center << 2) - left - right) >> 1; - if (luminance < blackPoint) { - result->Set(x); - } - left = center; - center = right; - } - return result.release(); -} -CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { - CBC_LuminanceSource* source = GetLuminanceSource(); - int32_t width = source->GetWidth(); - int32_t height = source->GetHeight(); - std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix()); - matrix->Init(width, height); - InitArrays(width); - CFX_Int32Array localBuckets; - localBuckets.Copy(m_buckets); - int32_t y; - for (y = 1; y < 5; y++) { - int32_t row = height * y / 5; - CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t right = (width << 2) / 5; - int32_t x; - for (x = width / 5; x < right; x++) { - int32_t pixel = (*localLuminances)[x] & 0xff; - localBuckets[pixel >> LUMINANCE_SHIFT]++; - } - } - int32_t blackPoint = EstimateBlackPoint(localBuckets, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix()); - for (y = 0; y < height; y++) { - int32_t offset = y * width; - for (int32_t x = 0; x < width; x++) { - int32_t pixel = (*localLuminances)[offset + x] & 0xff; - if (pixel < blackPoint) { - matrix->Set(x, y); - } - } - } - return matrix.release(); -} -void CBC_GlobalHistogramBinarizer::InitArrays(int32_t luminanceSize) { - if (m_luminance.GetSize() < luminanceSize) { - m_luminance.SetSize(luminanceSize); - } - if (m_buckets.GetSize() <= 0) { - m_buckets.SetSize(LUMINANCE_BUCKETS); - } else { - int32_t x; - for (x = 0; x < LUMINANCE_BUCKETS; x++) { - m_buckets[x] = 0; - } - } -} -int32_t CBC_GlobalHistogramBinarizer::EstimateBlackPoint( - CFX_Int32Array& buckets, - int32_t& e) { - int32_t numBuckets = buckets.GetSize(); - int32_t maxBucketCount = 0; - int32_t firstPeak = 0; - int32_t firstPeakSize = 0; - int32_t x; - for (x = 0; x < numBuckets; x++) { - if (buckets[x] > firstPeakSize) { - firstPeak = x; - firstPeakSize = buckets[x]; - } - if (buckets[x] > maxBucketCount) { - maxBucketCount = buckets[x]; - } - } - int32_t secondPeak = 0; - int32_t secondPeakScore = 0; - for (x = 0; x < numBuckets; x++) { - int32_t distanceToBiggest = x - firstPeak; - int32_t score = buckets[x] * distanceToBiggest * distanceToBiggest; - if (score > secondPeakScore) { - secondPeak = x; - secondPeakScore = score; - } - } - if (firstPeak > secondPeak) { - int32_t temp = firstPeak; - firstPeak = secondPeak; - secondPeak = temp; - } - if (secondPeak - firstPeak <= numBuckets >> 4) { - e = BCExceptionRead; - return 0; - } - int32_t bestValley = secondPeak - 1; - int32_t bestValleyScore = -1; - for (x = secondPeak - 1; x > firstPeak; x--) { - int32_t fromFirst = x - firstPeak; - int32_t score = fromFirst * fromFirst * (secondPeak - x) * - (maxBucketCount - buckets[x]); - if (score > bestValleyScore) { - bestValley = x; - bestValleyScore = score; - } - } - return bestValley << LUMINANCE_SHIFT; -} diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h deleted file mode 100644 index 56c2794fbe..0000000000 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/BC_Binarizer.h" - -class CBC_CommonBitArray; -class CBC_CommonBitMatrix; -class CBC_LuminanceSource; - -class CBC_GlobalHistogramBinarizer : public CBC_Binarizer { - public: - CBC_GlobalHistogramBinarizer(CBC_LuminanceSource* source); - virtual ~CBC_GlobalHistogramBinarizer(); - - void InitArrays(int32_t luminanceSize); - CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e); - CBC_CommonBitArray* GetBlackRow(int32_t y, - CBC_CommonBitArray* row, - int32_t& e); - static int32_t EstimateBlackPoint(CFX_Int32Array& buckets, int32_t& e); - - private: - CFX_ByteArray m_luminance; - CFX_Int32Array m_buckets; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp deleted file mode 100644 index 4e33691e08..0000000000 --- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp +++ /dev/null @@ -1,254 +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 -// Original code is licensed as follows: -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" - -#include <memory> - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector( - CBC_CommonBitMatrix* image) { - m_image = image; - m_height = image->GetHeight(); - m_width = image->GetWidth(); - m_leftInit = (m_width - INIT_SIZE) >> 1; - m_rightInit = (m_width + INIT_SIZE) >> 1; - m_upInit = (m_height - INIT_SIZE) >> 1; - m_downInit = (m_height + INIT_SIZE) >> 1; -} -void CBC_WhiteRectangleDetector::Init(int32_t& e) { - if (m_upInit < 0 || m_leftInit < 0 || m_downInit >= m_height || - m_rightInit >= m_width) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector( - CBC_CommonBitMatrix* image, - int32_t initSize, - int32_t x, - int32_t y) { - m_image = image; - m_height = image->GetHeight(); - m_width = image->GetWidth(); - int32_t halfsize = initSize >> 1; - m_leftInit = x - halfsize; - m_rightInit = x + halfsize; - m_upInit = y - halfsize; - m_downInit = y + halfsize; -} -CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector() {} -CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) { - int32_t left = m_leftInit; - int32_t right = m_rightInit; - int32_t up = m_upInit; - int32_t down = m_downInit; - FX_BOOL sizeExceeded = FALSE; - FX_BOOL aBlackPointFoundOnBorder = TRUE; - FX_BOOL atLeastOneBlackPointFoundOnBorder = FALSE; - while (aBlackPointFoundOnBorder) { - aBlackPointFoundOnBorder = FALSE; - FX_BOOL rightBorderNotWhite = TRUE; - while (rightBorderNotWhite && right < m_width) { - rightBorderNotWhite = ContainsBlackPoint(up, down, right, FALSE); - if (rightBorderNotWhite) { - right++; - aBlackPointFoundOnBorder = TRUE; - } - } - if (right >= m_width) { - sizeExceeded = TRUE; - break; - } - FX_BOOL bottomBorderNotWhite = TRUE; - while (bottomBorderNotWhite && down < m_height) { - bottomBorderNotWhite = ContainsBlackPoint(left, right, down, TRUE); - if (bottomBorderNotWhite) { - down++; - aBlackPointFoundOnBorder = TRUE; - } - } - if (down >= m_height) { - sizeExceeded = TRUE; - break; - } - FX_BOOL leftBorderNotWhite = TRUE; - while (leftBorderNotWhite && left >= 0) { - leftBorderNotWhite = ContainsBlackPoint(up, down, left, FALSE); - if (leftBorderNotWhite) { - left--; - aBlackPointFoundOnBorder = TRUE; - } - } - if (left < 0) { - sizeExceeded = TRUE; - break; - } - FX_BOOL topBorderNotWhite = TRUE; - while (topBorderNotWhite && up >= 0) { - topBorderNotWhite = ContainsBlackPoint(left, right, up, TRUE); - if (topBorderNotWhite) { - up--; - aBlackPointFoundOnBorder = TRUE; - } - } - if (up < 0) { - sizeExceeded = TRUE; - break; - } - if (aBlackPointFoundOnBorder) { - atLeastOneBlackPointFoundOnBorder = TRUE; - } - } - if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) { - int32_t maxSize = right - left; - std::unique_ptr<CBC_ResultPoint> z; - for (int32_t i = 1; i < maxSize; i++) { - z.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), - (FX_FLOAT)(left + i), (FX_FLOAT)(down))); - if (z) - break; - } - if (z.get() == NULL) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - std::unique_ptr<CBC_ResultPoint> t; - for (int32_t j = 1; j < maxSize; j++) { - t.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), - (FX_FLOAT)(left + j), (FX_FLOAT)up)); - if (t) - break; - } - if (t.get() == NULL) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - std::unique_ptr<CBC_ResultPoint> x; - for (int32_t k = 1; k < maxSize; k++) { - x.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), - (FX_FLOAT)(right - k), (FX_FLOAT)up)); - if (x) - break; - } - if (x.get() == NULL) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - std::unique_ptr<CBC_ResultPoint> y; - for (int32_t m = 1; m < maxSize; m++) { - y.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), - (FX_FLOAT)(right - m), (FX_FLOAT)down)); - if (y) - break; - } - if (y.get() == NULL) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return CenterEdges(y.get(), z.get(), x.get(), t.get()); - } else { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return NULL; -} -int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d) { - return (int32_t)(d + 0.5f); -} -CBC_ResultPoint* CBC_WhiteRectangleDetector::GetBlackPointOnSegment( - FX_FLOAT aX, - FX_FLOAT aY, - FX_FLOAT bX, - FX_FLOAT bY) { - int32_t dist = DistanceL2(aX, aY, bX, bY); - float xStep = (bX - aX) / dist; - float yStep = (bY - aY) / dist; - for (int32_t i = 0; i < dist; i++) { - int32_t x = Round(aX + i * xStep); - int32_t y = Round(aY + i * yStep); - if (m_image->Get(x, y)) { - return new CBC_ResultPoint((FX_FLOAT)x, (FX_FLOAT)y); - } - } - return NULL; -} -int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX, - FX_FLOAT aY, - FX_FLOAT bX, - FX_FLOAT bY) { - float xDiff = aX - bX; - 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) { - float yi = y->GetX(); - float yj = y->GetY(); - float zi = z->GetX(); - float zj = z->GetY(); - float xi = x->GetX(); - 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; - } -} -FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a, - int32_t b, - int32_t fixed, - FX_BOOL horizontal) { - if (horizontal) { - for (int32_t x = a; x <= b; x++) { - if (m_image->Get(x, fixed)) { - return TRUE; - } - } - } else { - for (int32_t y = a; y <= b; y++) { - if (m_image->Get(fixed, y)) { - return TRUE; - } - } - } - return FALSE; -} diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h deleted file mode 100644 index 4af04ac1fc..0000000000 --- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h +++ /dev/null @@ -1,54 +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_SRC_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ -#define XFA_SRC_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_ResultPoint; - -class CBC_WhiteRectangleDetector { - public: - CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image); - CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image, - int32_t initSize, - int32_t x, - int32_t y); - virtual ~CBC_WhiteRectangleDetector(); - CFX_PtrArray* Detect(int32_t& e); - virtual void Init(int32_t& e); - - private: - int32_t Round(float d); - CBC_ResultPoint* GetBlackPointOnSegment(FX_FLOAT aX, - FX_FLOAT aY, - 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); - FX_BOOL ContainsBlackPoint(int32_t a, - int32_t b, - int32_t fixed, - FX_BOOL horizontal); - - static const int32_t INIT_SIZE = 30; - static const int32_t CORR = 1; - - CBC_CommonBitMatrix* m_image; - int32_t m_height; - int32_t m_width; - int32_t m_leftInit; - int32_t m_rightInit; - int32_t m_downInit; - int32_t m_upInit; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_BC_WHITERECTANGLEDETECTOR_H_ diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp deleted file mode 100644 index 3e6de6ef06..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ /dev/null @@ -1,104 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) { - m_field = field; -} -void CBC_ReedSolomonEncoder::Init() { - m_cachedGenerators.Add(new CBC_ReedSolomonGF256Poly(m_field, 1)); -} -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]); - for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) { - CFX_Int32Array temp; - temp.Add(1); - temp.Add(m_field->Exp(d - 1)); - CBC_ReedSolomonGF256Poly temp_poly; - temp_poly.Init(m_field, &temp, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_ReedSolomonGF256Poly* nextGenerator = - lastGenerator->Multiply(&temp_poly, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - m_cachedGenerators.Add(nextGenerator); - lastGenerator = nextGenerator; - } - } - return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]); -} -void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode, - int32_t ecBytes, - int32_t& e) { - if (ecBytes == 0) { - e = BCExceptionNoCorrectionBytes; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t dataBytes = toEncode->GetSize() - ecBytes; - if (dataBytes <= 0) { - e = BCExceptionNoDataBytesProvided; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CFX_Int32Array infoCoefficients; - infoCoefficients.SetSize(dataBytes); - for (int32_t x = 0; x < dataBytes; x++) { - infoCoefficients[x] = toEncode->operator[](x); - } - CBC_ReedSolomonGF256Poly info; - info.Init(m_field, &infoCoefficients, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - 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)); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_ReedSolomonGF256Poly* remainder = - (CBC_ReedSolomonGF256Poly*)(temp->operator[](1)); - CFX_Int32Array* coefficients = remainder->GetCoefficients(); - int32_t numZeroCoefficients = ecBytes - coefficients->GetSize(); - for (int32_t i = 0; i < numZeroCoefficients; i++) { - (*toEncode)[dataBytes + i] = 0; - } - for (int32_t y = 0; y < coefficients->GetSize(); y++) { - (*toEncode)[dataBytes + numZeroCoefficients + y] = - coefficients->operator[](y); - } - for (int32_t k = 0; k < temp->GetSize(); k++) { - delete (CBC_ReedSolomonGF256Poly*)(*temp)[k]; - } -} -CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() { - for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) { - delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i]; - } -} diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h deleted file mode 100644 index 71eacc5e76..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h +++ /dev/null @@ -1,29 +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_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ -#define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ - -#include "core/include/fxcrt/fx_basic.h" - -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(); -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp deleted file mode 100644 index abdcaf0c88..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp +++ /dev/null @@ -1,221 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" - -#include <memory> -#include <utility> - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) { - m_field = field; -} -CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder() {} -void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, - int32_t twoS, - int32_t& e) { - CBC_ReedSolomonGF256Poly poly; - poly.Init(m_field, received, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CFX_Int32Array syndromeCoefficients; - syndromeCoefficients.SetSize(twoS); - FX_BOOL dataMatrix = FALSE; - FX_BOOL noError = TRUE; - for (int32_t i = 0; i < twoS; i++) { - int32_t eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i)); - syndromeCoefficients[twoS - 1 - i] = eval; - if (eval != 0) { - noError = FALSE; - } - } - if (noError) { - return; - } - CBC_ReedSolomonGF256Poly syndrome; - syndrome.Init(m_field, &syndromeCoefficients, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CBC_ReedSolomonGF256Poly> temp( - m_field->BuildMonomial(twoS, 1, e)); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CFX_PtrArray> 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<CFX_Int32Array> errorLocations( - FindErrorLocations(sigma.get(), e)); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CFX_Int32Array> errorMagnitudes( - FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e)); - BC_EXCEPTION_CHECK_ReturnVoid(e); - for (int32_t k = 0; k < errorLocations->GetSize(); k++) { - int32_t position = - received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (position < 0) { - e = BCExceptionBadErrorLocation; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract( - (*received)[position], (*errorMagnitudes)[k]); - } -} -CFX_PtrArray* 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); - std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - while (r->GetDegree() >= R / 2) { - std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast); - std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast); - std::unique_ptr<CBC_ReedSolomonGF256Poly> tLastlast = std::move(tLast); - rLast = std::move(r); - sLast = std::move(s); - tLast = std::move(t); - if (rLast->IsZero()) { - e = BCExceptionR_I_1IsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - r.reset(rLastLast->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree()); - int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - 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); - q.reset(q->AddOrSubtract(build.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply( - rLast->MultiplyByMonomial(degreeDiff, scale, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - r.reset(r->AddOrSubtract(multiply.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1( - q->Multiply(sLast.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - s.reset(temp1->AddOrSubtract(sLastLast.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5( - q->Multiply(tLast.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - t.reset(temp5->AddOrSubtract(tLastlast.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t sigmaTildeAtZero = t->GetCoefficients(0); - if (sigmaTildeAtZero == 0) { - e = BCExceptionIsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* temp = new CFX_PtrArray; - temp->Add(sigma.release()); - temp->Add(omega.release()); - return temp; -} -CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations( - CBC_ReedSolomonGF256Poly* errorLocator, - int32_t& e) { - int32_t numErrors = errorLocator->GetDegree(); - if (numErrors == 1) { - std::unique_ptr<CFX_Int32Array> temp(new CFX_Int32Array); - temp->Add(errorLocator->GetCoefficients(1)); - return temp.release(); - } - CFX_Int32Array* tempT = new CFX_Int32Array; - tempT->SetSize(numErrors); - std::unique_ptr<CFX_Int32Array> result(tempT); - int32_t ie = 0; - for (int32_t i = 1; i < 256 && ie < numErrors; i++) { - if (errorLocator->EvaluateAt(i) == 0) { - (*result)[ie] = m_field->Inverse(i, ie); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - ie++; - } - } - if (ie != numErrors) { - e = BCExceptionDegreeNotMatchRoots; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return result.release(); -} -CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( - CBC_ReedSolomonGF256Poly* errorEvaluator, - CFX_Int32Array* errorLocations, - FX_BOOL dataMatrix, - int32_t& e) { - int32_t s = errorLocations->GetSize(); - CFX_Int32Array* temp = new CFX_Int32Array; - temp->SetSize(s); - std::unique_ptr<CFX_Int32Array> result(temp); - for (int32_t i = 0; i < s; i++) { - int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t denominator = 1; - for (int32_t j = 0; j < s; j++) { - if (i != j) { - denominator = m_field->Multiply( - denominator, CBC_ReedSolomonGF256::AddOrSubtract( - 1, m_field->Multiply(errorLocations->operator[](j), - xiInverse))); - } - } - int32_t temp = m_field->Inverse(denominator, temp); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - (*result)[i] = - m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp); - } - return result.release(); -} diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h deleted file mode 100644 index 092033ca39..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.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_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ -#define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -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_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, - int32_t& e); - CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, - CFX_Int32Array* errorLocations, - FX_BOOL dataMatrix, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_ diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp deleted file mode 100644 index e5002ce6ee..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ /dev/null @@ -1,124 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = NULL; -CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = NULL; -void CBC_ReedSolomonGF256::Initialize() { - QRCodeFild = new CBC_ReedSolomonGF256(0x011D); - QRCodeFild->Init(); - DataMatrixField = new CBC_ReedSolomonGF256(0x012D); - DataMatrixField->Init(); -} -void CBC_ReedSolomonGF256::Finalize() { - if (QRCodeFild) { - delete QRCodeFild; - } - QRCodeFild = NULL; - if (DataMatrixField) { - delete DataMatrixField; - } - DataMatrixField = NULL; -} -CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) { - int32_t x = 1; - for (int32_t j = 0; j < 256; j++) { - m_expTable[j] = x; - x <<= 1; - if (x >= 0x100) { - x ^= primitive; - } - } - for (int32_t i = 0; i < 255; i++) { - m_logTable[m_expTable[i]] = i; - } - m_logTable[0] = 0; -} -void CBC_ReedSolomonGF256::Init() { - m_zero = new CBC_ReedSolomonGF256Poly(this, 0); - m_one = new CBC_ReedSolomonGF256Poly(this, 1); -} -CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() { - delete m_zero; - delete m_one; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() { - return m_zero; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() { - return m_one; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( - int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionDegreeIsNegative; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - if (coefficient == 0) { - CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; - } - CFX_Int32Array coefficients; - coefficients.SetSize(degree + 1); - coefficients[0] = coefficient; - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(this, &coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { - return a ^ b; -} -int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { - return m_expTable[a]; -} -int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - return m_logTable[a]; -} -int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - return m_expTable[255 - m_logTable[a]]; -} -int32_t CBC_ReedSolomonGF256::Multiply(int32_t a, int32_t b) { - if (a == 0 || b == 0) { - return 0; - } - if (a == 1) { - return b; - } - if (b == 1) { - return a; - } - return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; -} diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h deleted file mode 100644 index b351a03079..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.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_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ -#define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -class CBC_ReedSolomonGF256Poly; -class CBC_ReedSolomonGF256 { - public: - static void Initialize(); - static void Finalize(); - static CBC_ReedSolomonGF256* QRCodeFild; - static CBC_ReedSolomonGF256* DataMatrixField; - CBC_ReedSolomonGF256(int32_t primitive); - virtual ~CBC_ReedSolomonGF256(); - CBC_ReedSolomonGF256Poly* GetZero(); - CBC_ReedSolomonGF256Poly* GetOne(); - CBC_ReedSolomonGF256Poly* BuildMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - static int32_t AddOrSubtract(int32_t a, int32_t b); - int32_t Exp(int32_t a); - int32_t Log(int32_t a, int32_t& e); - int32_t Inverse(int32_t a, int32_t& e); - int32_t Multiply(int32_t a, int32_t b); - virtual void Init(); - - private: - int32_t m_expTable[256]; - int32_t m_logTable[256]; - CBC_ReedSolomonGF256Poly* m_zero; - CBC_ReedSolomonGF256Poly* m_one; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp deleted file mode 100644 index f138009ffa..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ /dev/null @@ -1,254 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" - -CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, - int32_t coefficients) { - if (field == NULL) { - return; - } - m_field = field; - m_coefficients.Add(coefficients); -} -CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() { - m_field = NULL; -} -void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, - CFX_Int32Array* coefficients, - int32_t& e) { - if (coefficients == NULL || coefficients->GetSize() == 0) { - e = BCExceptionCoefficientsSizeIsNull; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - m_field = field; - int32_t coefficientsLength = coefficients->GetSize(); - if ((coefficientsLength > 1 && (*coefficients)[0] == 0)) { - int32_t firstNonZero = 1; - while ((firstNonZero < coefficientsLength) && - ((*coefficients)[firstNonZero] == 0)) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - m_coefficients.Copy(*(m_field->GetZero()->GetCoefficients())); - } else { - m_coefficients.SetSize(coefficientsLength - firstNonZero); - for (int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) { - m_coefficients[j] = coefficients->operator[](i); - } - } - } else { - m_coefficients.Copy(*coefficients); - } -} -CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() { - return &m_coefficients; -} -int32_t CBC_ReedSolomonGF256Poly::GetDegree() { - return m_coefficients.GetSize() - 1; -} -FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() { - return m_coefficients[0] == 0; -} -int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) { - return m_coefficients[m_coefficients.GetSize() - 1 - degree]; -} -int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) { - if (a == 0) { - return GetCoefficients(0); - } - int32_t size = m_coefficients.GetSize(); - if (a == 1) { - int32_t result = 0; - for (int32_t i = 0; i < size; i++) { - result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[i]); - } - return result; - } - int32_t result = m_coefficients[0]; - for (int32_t j = 1; j < size; j++) { - result = CBC_ReedSolomonGF256::AddOrSubtract(m_field->Multiply(a, result), - m_coefficients[j]); - } - return result; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) { - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract( - CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (IsZero()) { - return other->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - if (other->IsZero()) { - return Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CFX_Int32Array smallerCoefficients; - smallerCoefficients.Copy(m_coefficients); - CFX_Int32Array largerCoefficients; - largerCoefficients.Copy(*(other->GetCoefficients())); - if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { - CFX_Int32Array temp; - temp.Copy(smallerCoefficients); - smallerCoefficients.Copy(largerCoefficients); - largerCoefficients.Copy(temp); - } - CFX_Int32Array sumDiff; - sumDiff.SetSize(largerCoefficients.GetSize()); - int32_t lengthDiff = - largerCoefficients.GetSize() - smallerCoefficients.GetSize(); - for (int32_t i = 0; i < lengthDiff; i++) { - sumDiff[i] = largerCoefficients[i]; - } - for (int32_t j = lengthDiff; j < largerCoefficients.GetSize(); j++) { - sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract( - smallerCoefficients[j - lengthDiff], largerCoefficients[j])); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &sumDiff, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply( - CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (IsZero() || other->IsZero()) { - CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; - } - CFX_Int32Array aCoefficients; - aCoefficients.Copy(m_coefficients); - int32_t aLength = m_coefficients.GetSize(); - CFX_Int32Array bCoefficients; - bCoefficients.Copy(*(other->GetCoefficients())); - int32_t bLength = other->GetCoefficients()->GetSize(); - CFX_Int32Array product; - product.SetSize(aLength + bLength - 1); - for (int32_t i = 0; i < aLength; i++) { - int32_t aCoeff = m_coefficients[i]; - for (int32_t j = 0; j < bLength; j++) { - product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract( - product[i + j], - m_field->Multiply(aCoeff, other->GetCoefficients()->operator[](j))); - } - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, - int32_t& e) { - if (scalar == 0) { - CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; - } - if (scalar == 1) { - return Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t size = m_coefficients.GetSize(); - CFX_Int32Array product; - product.SetSize(size); - for (int32_t i = 0; i < size; i++) { - product[i] = m_field->Multiply(m_coefficients[i], scalar); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial( - int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionDegreeIsNegative; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - if (coefficient == 0) { - CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; - } - int32_t size = m_coefficients.GetSize(); - CFX_Int32Array product; - product.SetSize(size + degree); - for (int32_t i = 0; i < size; i++) { - product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (other->IsZero()) { - e = BCExceptionDivideByZero; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( - m_field->GetZero()->Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); - int32_t inverseDenominatorLeadingTeam = - m_field->Inverse(denominatorLeadingTerm, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { - int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); - int32_t scale = - m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), - inverseDenominatorLeadingTeam); - std::unique_ptr<CBC_ReedSolomonGF256Poly> term( - other->MultiplyByMonomial(degreeDifference, scale, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( - m_field->BuildMonomial(degreeDifference, scale, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - remainder.reset(remainder->AddOrSubtract(term.get(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CFX_PtrArray* tempPtrA = new CFX_PtrArray; - tempPtrA->Add(quotient.release()); - tempPtrA->Add(remainder.release()); - return tempPtrA; -} -CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() { - m_coefficients.RemoveAll(); -} diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h deleted file mode 100644 index 71e4a09dd3..0000000000 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h +++ /dev/null @@ -1,43 +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_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ -#define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_ReedSolomonGF256; - -class CBC_ReedSolomonGF256Poly { - public: - CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); - CBC_ReedSolomonGF256Poly(); - virtual ~CBC_ReedSolomonGF256Poly(); - int32_t GetCoefficients(int32_t degree); - CFX_Int32Array* GetCoefficients(); - int32_t GetDegree(); - FX_BOOL IsZero(); - int32_t EvaluateAt(int32_t a); - CBC_ReedSolomonGF256Poly* AddOrSubtract(CBC_ReedSolomonGF256Poly* other, - int32_t& e); - CBC_ReedSolomonGF256Poly* Multiply(CBC_ReedSolomonGF256Poly* other, - int32_t& e); - CBC_ReedSolomonGF256Poly* Multiply(int32_t scalar, int32_t& e); - CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - CFX_PtrArray* 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; - CFX_Int32Array m_coefficients; -}; - -#endif // XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp deleted file mode 100644 index 6c4633e605..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp +++ /dev/null @@ -1,98 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_ASCIIEncoder::CBC_ASCIIEncoder() {} -CBC_ASCIIEncoder::~CBC_ASCIIEncoder() {} -int32_t CBC_ASCIIEncoder::getEncodingMode() { - return ASCII_ENCODATION; -} -void CBC_ASCIIEncoder::Encode(CBC_EncoderContext& context, int32_t& e) { - int32_t n = CBC_HighLevelEncoder::determineConsecutiveDigitCount( - context.m_msg, context.m_pos); - if (n >= 2) { - FX_WCHAR code = - encodeASCIIDigits(context.m_msg.GetAt(context.m_pos), - context.m_msg.GetAt(context.m_pos + 1), e); - if (e != BCExceptionNO) { - return; - } - context.writeCodeword(code); - context.m_pos += 2; - } else { - FX_WCHAR c = context.getCurrentChar(); - int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( - context.m_msg, context.m_pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - switch (newMode) { - case BASE256_ENCODATION: - context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_BASE256); - context.signalEncoderChange(BASE256_ENCODATION); - return; - case C40_ENCODATION: - context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_C40); - context.signalEncoderChange(C40_ENCODATION); - return; - case X12_ENCODATION: - context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_ANSIX12); - context.signalEncoderChange(X12_ENCODATION); - break; - case TEXT_ENCODATION: - context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_TEXT); - context.signalEncoderChange(TEXT_ENCODATION); - break; - case EDIFACT_ENCODATION: - context.writeCodeword(CBC_HighLevelEncoder::LATCH_TO_EDIFACT); - context.signalEncoderChange(EDIFACT_ENCODATION); - break; - default: - e = BCExceptionIllegalStateIllegalMode; - return; - } - } else if (CBC_HighLevelEncoder::isExtendedASCII(c)) { - context.writeCodeword(CBC_HighLevelEncoder::UPPER_SHIFT); - context.writeCodeword((FX_WCHAR)(c - 128 + 1)); - context.m_pos++; - } else { - context.writeCodeword((FX_WCHAR)(c + 1)); - context.m_pos++; - } - } -} -FX_WCHAR CBC_ASCIIEncoder::encodeASCIIDigits(FX_WCHAR digit1, - FX_WCHAR digit2, - int32_t& e) { - if (CBC_HighLevelEncoder::isDigit(digit1) && - CBC_HighLevelEncoder::isDigit(digit2)) { - int32_t num = (digit1 - 48) * 10 + (digit2 - 48); - return (FX_WCHAR)(num + 130); - } - e = BCExceptionIllegalArgumentNotGigits; - return 0; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h b/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h deleted file mode 100644 index 932b353ad4..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.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_SRC_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -class CBC_EncoderContext; - -class CBC_ASCIIEncoder : public CBC_Encoder { - public: - CBC_ASCIIEncoder(); - virtual ~CBC_ASCIIEncoder(); - int32_t getEncodingMode(); - void Encode(CBC_EncoderContext& context, int32_t& e); - - private: - static FX_WCHAR encodeASCIIDigits(FX_WCHAR digit1, - FX_WCHAR digit2, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_ASCIIENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.cpp deleted file mode 100644 index c719fb9e4f..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_Base256Encoder::CBC_Base256Encoder() {} -CBC_Base256Encoder::~CBC_Base256Encoder() {} -int32_t CBC_Base256Encoder::getEncodingMode() { - return BASE256_ENCODATION; -} -void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { - CFX_WideString buffer; - buffer += (FX_WCHAR)'\0'; - while (context.hasMoreCharacters()) { - FX_WCHAR c = context.getCurrentChar(); - buffer += c; - context.m_pos++; - int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( - context.m_msg, context.m_pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - context.signalEncoderChange(newMode); - break; - } - } - int32_t dataCount = buffer.GetLength() - 1; - FX_CHAR buf[128]; - FXSYS_itoa(dataCount, buf, 10); - buffer.SetAt(0, FX_WCHAR(*buf) - '0'); - int32_t lengthFieldSize = 1; - int32_t currentSize = - context.getCodewordCount() + dataCount + lengthFieldSize; - context.updateSymbolInfo(currentSize, e); - if (e != BCExceptionNO) { - return; - } - FX_BOOL mustPad = (context.m_symbolInfo->m_dataCapacity - currentSize) > 0; - if (context.hasMoreCharacters() || mustPad) { - if (dataCount <= 249) { - buffer.SetAt(0, (FX_WCHAR)dataCount); - } else if (dataCount > 249 && dataCount <= 1555) { - buffer.SetAt(0, (FX_WCHAR)((dataCount / 250) + 249)); - buffer.Insert(1, (FX_WCHAR)(dataCount % 250)); - } else { - e = BCExceptionIllegalStateMessageLengthInvalid; - return; - } - } - for (int32_t i = 0, c = buffer.GetLength(); i < c; i++) { - context.writeCodeword( - randomize255State(buffer.GetAt(i), context.getCodewordCount() + 1)); - } -} -FX_WCHAR CBC_Base256Encoder::randomize255State(FX_WCHAR ch, - int32_t codewordPosition) { - int32_t pseudoRandom = ((149 * codewordPosition) % 255) + 1; - int32_t tempVariable = ch + pseudoRandom; - if (tempVariable <= 255) { - return (FX_WCHAR)tempVariable; - } else { - return (FX_WCHAR)(tempVariable - 256); - } -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h b/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h deleted file mode 100644 index c7aa18c2c8..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h +++ /dev/null @@ -1,23 +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_SRC_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -class CBC_Base256Encoder : public CBC_Encoder { - public: - CBC_Base256Encoder(); - virtual ~CBC_Base256Encoder(); - int32_t getEncodingMode(); - void Encode(CBC_EncoderContext& context, int32_t& e); - - private: - static FX_WCHAR randomize255State(FX_WCHAR ch, int32_t codewordPosition); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_BASE256ENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.cpp deleted file mode 100644 index 01ececb4b7..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.cpp +++ /dev/null @@ -1,198 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_C40Encoder::CBC_C40Encoder() {} -CBC_C40Encoder::~CBC_C40Encoder() {} -int32_t CBC_C40Encoder::getEncodingMode() { - return C40_ENCODATION; -} -void CBC_C40Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { - CFX_WideString buffer; - while (context.hasMoreCharacters()) { - FX_WCHAR c = context.getCurrentChar(); - context.m_pos++; - int32_t lastCharSize = encodeChar(c, buffer, e); - if (e != BCExceptionNO) { - return; - } - int32_t unwritten = (buffer.GetLength() / 3) * 2; - int32_t curCodewordCount = context.getCodewordCount() + unwritten; - context.updateSymbolInfo(curCodewordCount, e); - if (e != BCExceptionNO) { - return; - } - int32_t available = context.m_symbolInfo->m_dataCapacity - curCodewordCount; - if (!context.hasMoreCharacters()) { - CFX_WideString removed; - if ((buffer.GetLength() % 3) == 2) { - if (available < 2 || available > 2) { - lastCharSize = - backtrackOneCharacter(context, buffer, removed, lastCharSize, e); - if (e != BCExceptionNO) { - return; - } - } - } - while ((buffer.GetLength() % 3) == 1 && - ((lastCharSize <= 3 && available != 1) || lastCharSize > 3)) { - lastCharSize = - backtrackOneCharacter(context, buffer, removed, lastCharSize, e); - if (e != BCExceptionNO) { - return; - } - } - break; - } - int32_t count = buffer.GetLength(); - if ((count % 3) == 0) { - int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( - context.m_msg, context.m_pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - context.signalEncoderChange(newMode); - break; - } - } - } - handleEOD(context, buffer, e); -} -void CBC_C40Encoder::writeNextTriplet(CBC_EncoderContext& context, - CFX_WideString& buffer) { - context.writeCodewords(encodeToCodewords(buffer, 0)); - buffer.Delete(0, 3); -} -void CBC_C40Encoder::handleEOD(CBC_EncoderContext& context, - CFX_WideString& buffer, - int32_t& e) { - int32_t unwritten = (buffer.GetLength() / 3) * 2; - int32_t rest = buffer.GetLength() % 3; - int32_t curCodewordCount = context.getCodewordCount() + unwritten; - context.updateSymbolInfo(curCodewordCount, e); - if (e != BCExceptionNO) { - return; - } - int32_t available = context.m_symbolInfo->m_dataCapacity - curCodewordCount; - if (rest == 2) { - buffer += (FX_WCHAR)'\0'; - while (buffer.GetLength() >= 3) { - writeNextTriplet(context, buffer); - } - if (context.hasMoreCharacters()) { - context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); - } - } else if (available == 1 && rest == 1) { - while (buffer.GetLength() >= 3) { - writeNextTriplet(context, buffer); - } - if (context.hasMoreCharacters()) { - context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); - } - context.m_pos--; - } else if (rest == 0) { - while (buffer.GetLength() >= 3) { - writeNextTriplet(context, buffer); - } - if (available > 0 || context.hasMoreCharacters()) { - context.writeCodeword(CBC_HighLevelEncoder::C40_UNLATCH); - } - } else { - e = BCExceptionIllegalStateUnexpectedCase; - return; - } - context.signalEncoderChange(ASCII_ENCODATION); -} -int32_t CBC_C40Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { - if (c == ' ') { - sb += (FX_WCHAR)'\3'; - return 1; - } else if ((c >= '0') && (c <= '9')) { - sb += (FX_WCHAR)(c - 48 + 4); - return 1; - } else if ((c >= 'A') && (c <= 'Z')) { - sb += (FX_WCHAR)(c - 65 + 14); - return 1; - } else if (c <= 0x1f) { - sb += (FX_WCHAR)'\0'; - sb += c; - return 2; - } else if ((c >= '!') && (c <= '/')) { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 33); - return 2; - } else if ((c >= ':') && (c <= '@')) { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 58 + 15); - return 2; - } else if ((c >= '[') && (c <= '_')) { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 91 + 22); - return 2; - } else if ((c >= 60) && (c <= 0x7f)) { - sb += (FX_WCHAR)'\2'; - sb += (FX_WCHAR)(c - 96); - return 2; - } else if (c >= 80) { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)0x001e; - int32_t len = 2; - len += encodeChar((c - 128), sb, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - return len; - } else { - e = BCExceptionIllegalArgument; - return 0; - } -} -int32_t CBC_C40Encoder::backtrackOneCharacter(CBC_EncoderContext& context, - CFX_WideString& buffer, - CFX_WideString& removed, - int32_t lastCharSize, - int32_t& e) { - int32_t count = buffer.GetLength(); - buffer.Delete(count - lastCharSize, count); - context.m_pos--; - FX_WCHAR c = context.getCurrentChar(); - lastCharSize = encodeChar(c, removed, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - context.resetSymbolInfo(); - return lastCharSize; -} -CFX_WideString CBC_C40Encoder::encodeToCodewords(CFX_WideString sb, - int32_t startPos) { - FX_WCHAR c1 = sb.GetAt(startPos); - FX_WCHAR c2 = sb.GetAt(startPos + 1); - FX_WCHAR c3 = sb.GetAt(startPos + 2); - int32_t v = (1600 * c1) + (40 * c2) + c3 + 1; - FX_WCHAR cw1 = (FX_WCHAR)(v / 256); - FX_WCHAR cw2 = (FX_WCHAR)(v % 256); - CFX_WideString b1(cw1); - CFX_WideString b2(cw2); - return b1 + b2; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h b/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h deleted file mode 100644 index ebc67efb17..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -class CBC_C40Encoder : public CBC_Encoder { - public: - CBC_C40Encoder(); - virtual ~CBC_C40Encoder(); - virtual int32_t getEncodingMode(); - virtual void Encode(CBC_EncoderContext& context, int32_t& e); - static void writeNextTriplet(CBC_EncoderContext& context, - CFX_WideString& buffer); - virtual void handleEOD(CBC_EncoderContext& context, - CFX_WideString& buffer, - int32_t& e); - virtual int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); - - private: - int32_t backtrackOneCharacter(CBC_EncoderContext& context, - CFX_WideString& buffer, - CFX_WideString& removed, - int32_t lastCharSize, - int32_t& e); - static CFX_WideString encodeToCodewords(CFX_WideString sb, int32_t startPos); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_C40ENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp deleted file mode 100644 index 9315b167e7..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp +++ /dev/null @@ -1,378 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_DataMatrixBitMatrixParser::CBC_DataMatrixBitMatrixParser() { - m_mappingBitMatrix = NULL; - m_version = NULL; - m_readMappingMatrix = NULL; -} -void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, - int32_t& e) { - int32_t dimension = bitMatrix->GetHeight(); - if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { - e = BCExceptionFormatException; - return; - } - m_version = ReadVersion(bitMatrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - m_mappingBitMatrix = ExtractDataRegion(bitMatrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - m_readMappingMatrix = new CBC_CommonBitMatrix(); - m_readMappingMatrix->Init(m_mappingBitMatrix->GetWidth(), - m_mappingBitMatrix->GetHeight()); -} -CBC_DataMatrixBitMatrixParser::~CBC_DataMatrixBitMatrixParser() { - delete m_mappingBitMatrix; - delete m_readMappingMatrix; -} -CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::GetVersion() { - return m_version; -} -CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion( - CBC_CommonBitMatrix* bitMatrix, - int32_t& e) { - int32_t rows = bitMatrix->GetHeight(); - int32_t columns = bitMatrix->GetWidth(); - CBC_DataMatrixVersion* temp = - CBC_DataMatrixVersion::GetVersionForDimensions(rows, columns, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return temp; -} -CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) { - std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray()); - result->SetSize(m_version->GetTotalCodewords()); - int32_t resultOffset = 0; - int32_t row = 4; - int32_t column = 0; - int32_t numRows = m_mappingBitMatrix->GetHeight(); - int32_t numColumns = m_mappingBitMatrix->GetWidth(); - FX_BOOL corner1Read = FALSE; - FX_BOOL corner2Read = FALSE; - FX_BOOL corner3Read = FALSE; - FX_BOOL corner4Read = FALSE; - do { - if ((row == numRows) && (column == 0) && !corner1Read) { - (*result)[resultOffset++] = (uint8_t)ReadCorner1(numRows, numColumns); - row -= 2; - column += 2; - corner1Read = TRUE; - } else if ((row == numRows - 2) && (column == 0) && - ((numColumns & 0x03) != 0) && !corner2Read) { - (*result)[resultOffset++] = (uint8_t)ReadCorner2(numRows, numColumns); - row -= 2; - column += 2; - corner2Read = TRUE; - } else if ((row == numRows + 4) && (column == 2) && - ((numColumns & 0x07) == 0) && !corner3Read) { - (*result)[resultOffset++] = (uint8_t)ReadCorner3(numRows, numColumns); - row -= 2; - column += 2; - corner3Read = TRUE; - } else if ((row == numRows - 2) && (column == 0) && - ((numColumns & 0x07) == 4) && !corner4Read) { - (*result)[resultOffset++] = (uint8_t)ReadCorner4(numRows, numColumns); - row -= 2; - column += 2; - corner4Read = TRUE; - } else { - do { - if ((row < numRows) && (column >= 0) && - !m_readMappingMatrix->Get(column, row)) { - if (resultOffset < (*result).GetSize()) { - (*result)[resultOffset++] = - (uint8_t)ReadUtah(row, column, numRows, numColumns); - } - } - row -= 2; - column += 2; - } while ((row >= 0) && (column < numColumns)); - row += 1; - column += 3; - do { - if ((row >= 0) && (column < numColumns) && - !m_readMappingMatrix->Get(column, row)) { - if (resultOffset < (*result).GetSize()) { - (*result)[resultOffset++] = - (uint8_t)ReadUtah(row, column, numRows, numColumns); - } - } - row += 2; - column -= 2; - } while ((row < numRows) && (column >= 0)); - row += 3; - column += 1; - } - } while ((row < numRows) || (column < numColumns)); - if (resultOffset != m_version->GetTotalCodewords()) { - e = BCExceptionFormatException; - return NULL; - } - return result.release(); -} -FX_BOOL CBC_DataMatrixBitMatrixParser::ReadModule(int32_t row, - int32_t column, - int32_t numRows, - int32_t numColumns) { - if (row < 0) { - row += numRows; - column += 4 - ((numRows + 4) & 0x07); - } - if (column < 0) { - column += numColumns; - row += 4 - ((numColumns + 4) & 0x07); - } - m_readMappingMatrix->Set(column, row); - return m_mappingBitMatrix->Get(column, row); -} -int32_t CBC_DataMatrixBitMatrixParser::ReadUtah(int32_t row, - int32_t column, - int32_t numRows, - int32_t numColumns) { - int32_t currentByte = 0; - if (ReadModule(row - 2, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row - 2, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row - 1, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row - 1, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row - 1, column, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row, column - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row, column - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(row, column, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; -} -int32_t CBC_DataMatrixBitMatrixParser::ReadCorner1(int32_t numRows, - int32_t numColumns) { - int32_t currentByte = 0; - if (ReadModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 1, 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 1, 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; -} -int32_t CBC_DataMatrixBitMatrixParser::ReadCorner2(int32_t numRows, - int32_t numColumns) { - int32_t currentByte = 0; - if (ReadModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 4, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; -} -int32_t CBC_DataMatrixBitMatrixParser::ReadCorner3(int32_t numRows, - int32_t numColumns) { - int32_t currentByte = 0; - if (ReadModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 3, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; -} -int32_t CBC_DataMatrixBitMatrixParser::ReadCorner4(int32_t numRows, - int32_t numColumns) { - int32_t currentByte = 0; - if (ReadModule(numRows - 3, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 2, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(numRows - 1, 0, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 2, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(0, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(1, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(2, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - currentByte <<= 1; - if (ReadModule(3, numColumns - 1, numRows, numColumns)) { - currentByte |= 1; - } - return currentByte; -} -CBC_CommonBitMatrix* CBC_DataMatrixBitMatrixParser::ExtractDataRegion( - CBC_CommonBitMatrix* bitMatrix, - int32_t& e) { - int32_t symbolSizeRows = m_version->GetSymbolSizeRows(); - int32_t symbolSizeColumns = m_version->GetSymbolSizeColumns(); - if (bitMatrix->GetHeight() != symbolSizeRows) { - e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; - return NULL; - } - int32_t dataRegionSizeRows = m_version->GetDataRegionSizeRows(); - int32_t dataRegionSizeColumns = m_version->GetDataRegionSizeColumns(); - int32_t numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; - int32_t numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; - int32_t sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; - int32_t sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; - CBC_CommonBitMatrix* bitMatrixWithoutAlignment = new CBC_CommonBitMatrix(); - bitMatrixWithoutAlignment->Init(sizeDataRegionColumn, sizeDataRegionRow); - int32_t dataRegionRow; - for (dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { - int32_t dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; - int32_t dataRegionColumn; - for (dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; - ++dataRegionColumn) { - int32_t dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; - int32_t i; - for (i = 0; i < dataRegionSizeRows; ++i) { - int32_t readRowOffset = - dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; - int32_t writeRowOffset = dataRegionRowOffset + i; - int32_t j; - for (j = 0; j < dataRegionSizeColumns; ++j) { - int32_t readColumnOffset = - dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; - if (bitMatrix->Get(readColumnOffset, readRowOffset)) { - int32_t writeColumnOffset = dataRegionColumnOffset + j; - bitMatrixWithoutAlignment->Set(writeColumnOffset, writeRowOffset); - } - } - } - } - } - return bitMatrixWithoutAlignment; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h deleted file mode 100644 index 967e08ddfd..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h +++ /dev/null @@ -1,45 +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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_DataMatrixVersion; - -class CBC_DataMatrixBitMatrixParser { - public: - CBC_DataMatrixBitMatrixParser(); - virtual ~CBC_DataMatrixBitMatrixParser(); - CBC_DataMatrixVersion* GetVersion(); - CFX_ByteArray* ReadCodewords(int32_t& e); - FX_BOOL ReadModule(int32_t row, - int32_t column, - int32_t numRows, - int32_t numColumns); - int32_t ReadUtah(int32_t row, - int32_t column, - int32_t numRows, - int32_t numColumns); - int32_t ReadCorner1(int32_t numRows, int32_t numColumns); - int32_t ReadCorner2(int32_t numRows, int32_t numColumns); - int32_t ReadCorner3(int32_t numRows, int32_t numColumns); - int32_t ReadCorner4(int32_t numRows, int32_t numColumns); - CBC_CommonBitMatrix* ExtractDataRegion(CBC_CommonBitMatrix* bitMatrix, - int32_t& e); - virtual void Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e); - - private: - static CBC_DataMatrixVersion* ReadVersion(CBC_CommonBitMatrix* bitMatrix, - int32_t& e); - CBC_CommonBitMatrix* m_mappingBitMatrix; - CBC_CommonBitMatrix* m_readMappingMatrix; - CBC_DataMatrixVersion* m_version; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXBITMATRIXPARSER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp deleted file mode 100644 index fbd0ea1c9e..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ /dev/null @@ -1,115 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" - -#include <memory> - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_DataMatrixDataBlock::~CBC_DataMatrixDataBlock() {} -CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(int32_t numDataCodewords, - CFX_ByteArray* codewords) { - m_codewords.Copy(*codewords); - m_numDataCodewords = numDataCodewords; -} -CFX_PtrArray* 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(); - int32_t i; - for (i = 0; i < ecBlockArray.GetSize(); i++) { - totalBlocks += ((ECB*)ecBlockArray[i])->GetCount(); - } - std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); - result->SetSize(totalBlocks); - int32_t numResultBlocks = 0; - int32_t j; - for (j = 0; j < ecBlockArray.GetSize(); j++) { - for (i = 0; i < ((ECB*)ecBlockArray[j])->GetCount(); i++) { - int32_t numDataCodewords = ((ECB*)ecBlockArray[j])->GetDataCodewords(); - int32_t numBlockCodewords = ecBlocks->GetECCodewords() + numDataCodewords; - CFX_ByteArray codewords; - codewords.SetSize(numBlockCodewords); - (*result)[numResultBlocks++] = - new CBC_DataMatrixDataBlock(numDataCodewords, &codewords); - codewords.SetSize(0); - } - } - int32_t longerBlocksTotalCodewords = - ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize(); - int32_t longerBlocksNumDataCodewords = - longerBlocksTotalCodewords - ecBlocks->GetECCodewords(); - int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; - int32_t rawCodewordsOffset = 0; - for (i = 0; i < shorterBlocksNumDataCodewords; i++) { - int32_t j; - for (j = 0; j < numResultBlocks; j++) { - if (rawCodewordsOffset < rawCodewords->GetSize()) { - ((CBC_DataMatrixDataBlock*)(*result)[j]) - ->GetCodewords() - -> - operator[](i) = (*rawCodewords)[rawCodewordsOffset++]; - } - } - } - const bool specialVersion = version->GetVersionNumber() == 24; - int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks; - for (j = 0; j < numLongerBlocks; j++) { - if (rawCodewordsOffset < rawCodewords->GetSize()) { - ((CBC_DataMatrixDataBlock*)(*result)[j]) - ->GetCodewords() - -> - operator[](longerBlocksNumDataCodewords - 1) = - (*rawCodewords)[rawCodewordsOffset++]; - } - } - int32_t max = - ((CBC_DataMatrixDataBlock*)(*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++]; - } - } - } - if (rawCodewordsOffset != rawCodewords->GetSize()) { - e = BCExceptionIllegalArgument; - return NULL; - } - return result.release(); -} -int32_t CBC_DataMatrixDataBlock::GetNumDataCodewords() { - return m_numDataCodewords; -} -CFX_ByteArray* CBC_DataMatrixDataBlock::GetCodewords() { - return &m_codewords; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h deleted file mode 100644 index 68a4ceacc7..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_DataMatrixVersion; - -class CBC_DataMatrixDataBlock { - public: - virtual ~CBC_DataMatrixDataBlock(); - - int32_t GetNumDataCodewords(); - CFX_ByteArray* GetCodewords(); - - static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords, - CBC_DataMatrixVersion* version, - int32_t& e); - - private: - int32_t m_numDataCodewords; - CFX_ByteArray m_codewords; - - CBC_DataMatrixDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp deleted file mode 100644 index f378fff05d..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp +++ /dev/null @@ -1,473 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitSource.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" - -const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::C40_BASIC_SET_CHARS[] = { - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '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::C40_SHIFT2_SET_CHARS[] = { - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', - '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_'}; -const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { - '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '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}; -const int32_t CBC_DataMatrixDecodedBitStreamParser::PAD_ENCODE = 0; -const int32_t CBC_DataMatrixDecodedBitStreamParser::ASCII_ENCODE = 1; -const int32_t CBC_DataMatrixDecodedBitStreamParser::C40_ENCODE = 2; -const int32_t CBC_DataMatrixDecodedBitStreamParser::TEXT_ENCODE = 3; -const int32_t CBC_DataMatrixDecodedBitStreamParser::ANSIX12_ENCODE = 4; -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) { - CBC_CommonBitSource bits(&bytes); - CFX_ByteString result; - CFX_ByteString resultTrailer; - CFX_Int32Array byteSegments; - int32_t mode = ASCII_ENCODE; - do { - if (mode == 1) { - mode = DecodeAsciiSegment(&bits, result, resultTrailer, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else { - switch (mode) { - case 2: - DecodeC40Segment(&bits, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - case 3: - DecodeTextSegment(&bits, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - case 4: - DecodeAnsiX12Segment(&bits, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - case 5: - DecodeEdifactSegment(&bits, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - case 6: - DecodeBase256Segment(&bits, result, byteSegments, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - default: - e = BCExceptionFormatException; - return NULL; - } - mode = ASCII_ENCODE; - } - } while (mode != PAD_ENCODE && bits.Available() > 0); - if (resultTrailer.GetLength() > 0) { - 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); - return tempCp; -} -int32_t CBC_DataMatrixDecodedBitStreamParser::DecodeAsciiSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - CFX_ByteString& resultTrailer, - int32_t& e) { - FX_CHAR buffer[128]; - FX_BOOL upperShift = FALSE; - do { - int32_t oneByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - if (oneByte == 0) { - e = BCExceptionFormatException; - return 0; - } else if (oneByte <= 128) { - oneByte = upperShift ? oneByte + 128 : oneByte; - upperShift = FALSE; - result += ((FX_CHAR)(oneByte - 1)); - return ASCII_ENCODE; - } else if (oneByte == 129) { - return PAD_ENCODE; - } else if (oneByte <= 229) { - int32_t value = oneByte - 130; - FXSYS_itoa(value, buffer, 10); - if (value < 10) { - result += '0'; - buffer[1] = '\0'; - } else { - buffer[2] = '\0'; - } - result += buffer; - } else if (oneByte == 230) { - return C40_ENCODE; - } else if (oneByte == 231) { - return BASE256_ENCODE; - } else if (oneByte == 232 || oneByte == 233 || oneByte == 234) { - } else if (oneByte == 235) { - upperShift = TRUE; - } else if (oneByte == 236) { - result += "[)>"; - result += 0x1E; - result += "05"; - result += 0x1D; - resultTrailer.Insert(0, 0x1E); - resultTrailer.Insert(0 + 1, 0x04); - } else if (oneByte == 237) { - result += "[)>"; - result += 0x1E; - result += "06"; - result += 0x1D; - resultTrailer.Insert(0, 0x1E); - resultTrailer.Insert(0 + 1, 0x04); - } else if (oneByte == 238) { - return ANSIX12_ENCODE; - } else if (oneByte == 239) { - return TEXT_ENCODE; - } else if (oneByte == 240) { - return EDIFACT_ENCODE; - } else if (oneByte == 241) { - } else if (oneByte >= 242) { - if (oneByte == 254 && bits->Available() == 0) { - } else { - e = BCExceptionFormatException; - return 0; - } - } - } while (bits->Available() > 0); - return ASCII_ENCODE; -} -void CBC_DataMatrixDecodedBitStreamParser::DecodeC40Segment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e) { - FX_BOOL upperShift = FALSE; - CFX_Int32Array cValues; - cValues.SetSize(3); - do { - if (bits->Available() == 8) { - return; - } - int32_t firstByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (firstByte == 254) { - return; - } - int32_t tempp = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - ParseTwoBytes(firstByte, tempp, cValues); - int32_t shift = 0; - int32_t i; - for (i = 0; i < 3; i++) { - int32_t cValue = cValues[i]; - switch (shift) { - case 0: - if (cValue < 3) { - shift = cValue + 1; - } else if (cValue < 27) { - FX_CHAR c40char = C40_BASIC_SET_CHARS[cValue]; - if (upperShift) { - result += (FX_CHAR)(c40char + 128); - upperShift = FALSE; - } else { - result += c40char; - } - } else { - e = BCExceptionFormatException; - return; - } - break; - case 1: - if (upperShift) { - result += (FX_CHAR)(cValue + 128); - upperShift = FALSE; - } else { - result += cValue; - } - shift = 0; - break; - case 2: - if (cValue < 27) { - FX_CHAR c40char = C40_SHIFT2_SET_CHARS[cValue]; - if (upperShift) { - result += (FX_CHAR)(c40char + 128); - upperShift = FALSE; - } else { - result += c40char; - } - } else if (cValue == 27) { - e = BCExceptionFormatException; - return; - } else if (cValue == 30) { - upperShift = TRUE; - } else { - e = BCExceptionFormatException; - return; - } - shift = 0; - break; - case 3: - if (upperShift) { - result += (FX_CHAR)(cValue + 224); - upperShift = FALSE; - } else { - result += (FX_CHAR)(cValue + 96); - } - shift = 0; - break; - default: - break; - e = BCExceptionFormatException; - return; - } - } - } while (bits->Available() > 0); -} -void CBC_DataMatrixDecodedBitStreamParser::DecodeTextSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e) { - FX_BOOL upperShift = FALSE; - CFX_Int32Array cValues; - cValues.SetSize(3); - int32_t shift = 0; - do { - if (bits->Available() == 8) { - return; - } - int32_t firstByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (firstByte == 254) { - return; - } - int32_t inTp = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - ParseTwoBytes(firstByte, inTp, cValues); - for (int32_t i = 0; i < 3; i++) { - int32_t cValue = cValues[i]; - switch (shift) { - case 0: - if (cValue < 3) { - shift = cValue + 1; - } else if (cValue < 40) { - FX_CHAR textChar = TEXT_BASIC_SET_CHARS[cValue]; - if (upperShift) { - result += (FX_CHAR)(textChar + 128); - upperShift = FALSE; - } else { - result += textChar; - } - } else { - e = BCExceptionFormatException; - return; - } - break; - case 1: - if (upperShift) { - result += (FX_CHAR)(cValue + 128); - upperShift = FALSE; - } else { - result += cValue; - } - shift = 0; - break; - case 2: - if (cValue < 27) { - FX_CHAR c40char = C40_SHIFT2_SET_CHARS[cValue]; - if (upperShift) { - result += (FX_CHAR)(c40char + 128); - upperShift = FALSE; - } else { - result += c40char; - } - } else if (cValue == 27) { - e = BCExceptionFormatException; - return; - } else if (cValue == 30) { - upperShift = TRUE; - } else { - e = BCExceptionFormatException; - return; - } - shift = 0; - break; - case 3: - if (cValue < 19) { - FX_CHAR textChar = TEXT_SHIFT3_SET_CHARS[cValue]; - if (upperShift) { - result += (FX_CHAR)(textChar + 128); - upperShift = FALSE; - } else { - result += textChar; - } - shift = 0; - } else { - e = BCExceptionFormatException; - return; - } - break; - default: - break; - e = BCExceptionFormatException; - return; - } - } - } while (bits->Available() > 0); -} -void CBC_DataMatrixDecodedBitStreamParser::DecodeAnsiX12Segment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e) { - CFX_Int32Array cValues; - cValues.SetSize(3); - do { - if (bits->Available() == 8) { - return; - } - int32_t firstByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (firstByte == 254) { - return; - } - int32_t iTemp1 = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - ParseTwoBytes(firstByte, iTemp1, cValues); - int32_t i; - for (i = 0; i < 3; i++) { - int32_t cValue = cValues[i]; - if (cValue == 0) { - BC_FX_ByteString_Append(result, 1, '\r'); - } else if (cValue == 1) { - BC_FX_ByteString_Append(result, 1, '*'); - } else if (cValue == 2) { - BC_FX_ByteString_Append(result, 1, '>'); - } else if (cValue == 3) { - BC_FX_ByteString_Append(result, 1, ' '); - } else if (cValue < 14) { - BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 44)); - } else if (cValue < 40) { - BC_FX_ByteString_Append(result, 1, (FX_CHAR)(cValue + 51)); - } else { - e = BCExceptionFormatException; - return; - } - } - } while (bits->Available() > 0); -} -void CBC_DataMatrixDecodedBitStreamParser::ParseTwoBytes( - int32_t firstByte, - int32_t secondByte, - CFX_Int32Array& result) { - int32_t fullBitValue = (firstByte << 8) + secondByte - 1; - int32_t temp = fullBitValue / 1600; - result[0] = temp; - fullBitValue -= temp * 1600; - temp = fullBitValue / 40; - result[1] = temp; - result[2] = fullBitValue - temp * 40; -} - -void CBC_DataMatrixDecodedBitStreamParser::DecodeEdifactSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e) { - FX_CHAR buffer[128]; - FX_BOOL unlatch = FALSE; - do { - if (bits->Available() <= 16) - return; - - for (int32_t i = 0; i < 4; i++) { - int32_t edifactValue = bits->ReadBits(6, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (edifactValue == 0x1F) - unlatch = TRUE; - - if (!unlatch) { - if ((edifactValue & 32) == 0) - edifactValue |= 64; - result += FXSYS_itoa(edifactValue, buffer, 10); - } - } - } while (!unlatch && bits->Available() > 0); -} - -void CBC_DataMatrixDecodedBitStreamParser::DecodeBase256Segment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - CFX_Int32Array& byteSegments, - int32_t& e) { - int32_t codewordPosition = 1 + bits->getByteOffset(); - int32_t iTmp = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t d1 = Unrandomize255State(iTmp, codewordPosition++); - int32_t count; - if (d1 == 0) { - count = bits->Available() / 8; - } else if (d1 < 250) { - count = d1; - } else { - int32_t iTmp3 = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - count = 250 * (d1 - 249) + Unrandomize255State(iTmp3, codewordPosition++); - } - if (count < 0) { - e = BCExceptionFormatException; - return; - } - CFX_ByteArray* bytes = new CFX_ByteArray(); - bytes->SetSize(count); - int32_t i; - for (i = 0; i < count; i++) { - if (bits->Available() < 8) { - e = BCExceptionFormatException; - delete bytes; - return; - } - int32_t iTemp5 = bits->ReadBits(8, e); - if (e != BCExceptionNO) { - delete bytes; - return; - } - bytes->SetAt(i, Unrandomize255State(iTemp5, codewordPosition++)); - } - BC_FX_ByteString_Append(result, *bytes); - delete bytes; -} -uint8_t CBC_DataMatrixDecodedBitStreamParser::Unrandomize255State( - int32_t randomizedBase256Codeword, - int32_t base256CodewordPosition) { - int32_t pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; - int32_t tempVariable = randomizedBase256Codeword - pseudoRandomNumber; - return (uint8_t)(tempVariable >= 0 ? tempVariable : tempVariable + 256); -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h deleted file mode 100644 index eba1828d19..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h +++ /dev/null @@ -1,58 +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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ -class CBC_CommonDecoderResult; -class CBC_CommonBitSource; -class CBC_DataMatrixDecodedBitStreamParser { - public: - CBC_DataMatrixDecodedBitStreamParser(); - virtual ~CBC_DataMatrixDecodedBitStreamParser(); - static CBC_CommonDecoderResult* Decode(CFX_ByteArray& bytes, int32_t& e); - - private: - static int32_t DecodeAsciiSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - CFX_ByteString& resultTrailer, - int32_t& e); - static void DecodeC40Segment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e); - static void DecodeTextSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e); - static void DecodeAnsiX12Segment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e); - static void ParseTwoBytes(int32_t firstByte, - int32_t secondByte, - CFX_Int32Array& result); - static void DecodeEdifactSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t& e); - static void DecodeBase256Segment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - CFX_Int32Array& byteSegments, - int32_t& e); - static uint8_t Unrandomize255State(int32_t randomizedBase256Codeword, - int32_t base256CodewordPosition); - - static const FX_CHAR C40_BASIC_SET_CHARS[]; - static const FX_CHAR C40_SHIFT2_SET_CHARS[]; - - static const FX_CHAR TEXT_BASIC_SET_CHARS[]; - static const FX_CHAR TEXT_SHIFT3_SET_CHARS[]; - static const int32_t PAD_ENCODE; - static const int32_t ASCII_ENCODE; - static const int32_t C40_ENCODE; - static const int32_t TEXT_ENCODE; - static const int32_t ANSIX12_ENCODE; - static const int32_t EDIFACT_ENCODE; - static const int32_t BASE256_ENCODE; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp deleted file mode 100644 index 423cefc65f..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ /dev/null @@ -1,114 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" - -CBC_DataMatrixDecoder::CBC_DataMatrixDecoder() { - m_rsDecoder = NULL; -} -void CBC_DataMatrixDecoder::Init() { - m_rsDecoder = - new CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::DataMatrixField); -} -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); - CBC_DataMatrixVersion* version = parser.GetVersion(); - std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* dataBlocks = - CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - 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(); - } - 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(); - CorrectErrors(*codewordBytes, numDataCodewords, e); - if (e != BCExceptionNO) { - for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; - } - delete dataBlocks; - dataBlocks = NULL; - return NULL; - } - int32_t i; - for (i = 0; i < numDataCodewords; i++) { - resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i]; - } - } - for (i = 0; i < (dataBlocks->GetSize()); i++) { - delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; - } - delete dataBlocks; - dataBlocks = NULL; - CBC_CommonDecoderResult* resultR = - CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return resultR; -} -void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes, - int32_t numDataCodewords, - int32_t& e) { - int32_t numCodewords = codewordBytes.GetSize(); - CFX_Int32Array codewordsInts; - codewordsInts.SetSize(numCodewords); - int32_t i; - for (i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords; - m_rsDecoder->Decode(&codewordsInts, numECCodewords, e); - if (e != BCExceptionNO) { - e = BCExceptionChecksumException; - return; - } - for (i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (uint8_t)codewordsInts[i]; - } -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h deleted file mode 100644 index d80a51247f..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_ReedSolomonDecoder; -class CBC_CommonDecoderResult; -class CBC_CommonBitMatrix; - -class CBC_DataMatrixDecoder { - public: - CBC_DataMatrixDecoder(); - virtual ~CBC_DataMatrixDecoder(); - CBC_CommonDecoderResult* Decode(CBC_CommonBitMatrix* bits, int32_t& e); - virtual void Init(); - - private: - void CorrectErrors(CFX_ByteArray& codewordBytes, - int32_t numDataCodewords, - int32_t& e); - CBC_ReedSolomonDecoder* m_rsDecoder; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp deleted file mode 100644 index c29c64862a..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp +++ /dev/null @@ -1,406 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" - -#include <algorithm> -#include <memory> - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" -#include "xfa/src/fxbarcode/utils.h" - -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) {} -void CBC_DataMatrixDetector::Init(int32_t& e) { - m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); - m_rectangleDetector->Init(e); - BC_EXCEPTION_CHECK_ReturnVoid(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]; - delete cornerPoints; - cornerPoints = NULL; - CFX_PtrArray 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]; - 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]); - transitions.RemoveAll(); - CBC_ResultPoint* maybeTopLeft = NULL; - CBC_ResultPoint* bottomLeft = NULL; - CBC_ResultPoint* maybeBottomRight = NULL; - FX_POSITION itBegin = pointCount.GetStartPosition(); - while (itBegin) { - CBC_ResultPoint* key = 0; - int32_t value = 0; - pointCount.GetNextAssoc(itBegin, key, value); - if (value == 2) { - bottomLeft = key; - } else { - if (maybeBottomRight == NULL) { - maybeBottomRight = key; - } else { - maybeTopLeft = key; - } - } - } - if (maybeTopLeft == NULL || bottomLeft == NULL || maybeBottomRight == NULL) { - delete pointA; - delete pointB; - delete pointC; - delete pointD; - e = BCExceptionNotFound; - return NULL; - } - CFX_PtrArray 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; - int32_t value; - if (!pointCount.Lookup(pointA, value)) { - topRight = pointA; - } else if (!pointCount.Lookup(pointB, value)) { - topRight = pointB; - } else if (!pointCount.Lookup(pointC, value)) { - topRight = pointC; - } else { - topRight = pointD; - } - int32_t dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, topRight)) - ->GetTransitions(); - int32_t dimensionRight = std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, topRight)) - ->GetTransitions(); - if ((dimensionTop & 0x01) == 1) { - dimensionTop++; - } - dimensionTop += 2; - if ((dimensionRight & 0x01) == 1) { - dimensionRight++; - } - dimensionRight += 2; - std::unique_ptr<CBC_CommonBitMatrix> bits; - std::unique_ptr<CBC_ResultPoint> correctedTopRight; - if (4 * dimensionTop >= 7 * dimensionRight || - 4 * dimensionRight >= 7 * dimensionTop) { - correctedTopRight.reset( - CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, - dimensionTop, dimensionRight)); - if (correctedTopRight.get() == NULL) { - correctedTopRight.reset(topRight); - } else { - delete topRight; - topRight = NULL; - } - dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, correctedTopRight.get())) - ->GetTransitions(); - dimensionRight = - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, correctedTopRight.get())) - ->GetTransitions(); - if ((dimensionTop & 0x01) == 1) { - dimensionTop++; - } - if ((dimensionRight & 0x01) == 1) { - dimensionRight++; - } - bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, - correctedTopRight.get(), dimensionTop, dimensionRight, - e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else { - int32_t dimension = std::min(dimensionRight, dimensionTop); - correctedTopRight.reset( - CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); - if (correctedTopRight.get() == NULL) { - correctedTopRight.reset(topRight); - } else { - delete topRight; - topRight = NULL; - } - int32_t dimensionCorrected = - std::max(std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, correctedTopRight.get())) - ->GetTransitions(), - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, correctedTopRight.get())) - ->GetTransitions()); - dimensionCorrected++; - if ((dimensionCorrected & 0x01) == 1) { - dimensionCorrected++; - } - bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, - correctedTopRight.get(), dimensionCorrected, - dimensionCorrected, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CFX_PtrArray* result = new CFX_PtrArray; - result->SetSize(4); - result->Add(topLeft); - result->Add(bottomLeft); - result->Add(bottomRight); - result->Add(correctedTopRight.release()); - return new CBC_QRDetectorResult(bits.release(), result); -} -CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - int32_t dimensionTop, - int32_t dimensionRight) { - FX_FLOAT corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimensionTop; - int32_t norm = Distance(topLeft, topRight); - FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; - FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( - topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); - corr = Distance(bottomLeft, topLeft) / (FX_FLOAT)dimensionRight; - norm = Distance(bottomRight, topRight); - cos = (topRight->GetX() - bottomRight->GetX()) / norm; - sin = (topRight->GetY() - bottomRight->GetY()) / norm; - std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( - topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); - if (!IsValid(c1.get())) { - if (IsValid(c2.get())) { - return c2.release(); - } - return NULL; - } else if (!IsValid(c2.get())) { - return c1.release(); - } - int32_t l1 = FXSYS_abs(dimensionTop - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, c1.get())) - ->GetTransitions()) + - FXSYS_abs(dimensionRight - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, c1.get())) - ->GetTransitions()); - int32_t l2 = FXSYS_abs(dimensionTop - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, c2.get())) - ->GetTransitions()) + - FXSYS_abs(dimensionRight - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, c2.get())) - ->GetTransitions()); - if (l1 <= l2) { - return c1.release(); - } - return c2.release(); -} -CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - int32_t dimension) { - FX_FLOAT corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; - int32_t norm = Distance(topLeft, topRight); - FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; - FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - std::unique_ptr<CBC_ResultPoint> c1(new CBC_ResultPoint( - topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); - corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; - norm = Distance(bottomRight, topRight); - cos = (topRight->GetX() - bottomRight->GetX()) / norm; - sin = (topRight->GetY() - bottomRight->GetY()) / norm; - std::unique_ptr<CBC_ResultPoint> c2(new CBC_ResultPoint( - topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); - if (!IsValid(c1.get())) { - if (IsValid(c2.get())) { - return c2.release(); - } - return NULL; - } else if (!IsValid(c2.get())) { - return c1.release(); - } - int32_t l1 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, c1.get())) - ->GetTransitions() - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, c1.get())) - ->GetTransitions()); - int32_t l2 = FXSYS_abs(std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(topLeft, c2.get())) - ->GetTransitions() - - std::unique_ptr<CBC_ResultPointsAndTransitions>( - TransitionsBetween(bottomRight, c2.get())) - ->GetTransitions()); - return l1 <= l2 ? c1.release() : c2.release(); -} -FX_BOOL CBC_DataMatrixDetector::IsValid(CBC_ResultPoint* p) { - return p->GetX() >= 0 && p->GetX() < m_image->GetWidth() && p->GetY() > 0 && - p->GetY() < m_image->GetHeight(); -} -int32_t CBC_DataMatrixDetector::Round(FX_FLOAT d) { - return (int32_t)(d + 0.5f); -} -int32_t CBC_DataMatrixDetector::Distance(CBC_ResultPoint* a, - CBC_ResultPoint* b) { - return Round( - (FX_FLOAT)sqrt((a->GetX() - b->GetX()) * (a->GetX() - b->GetX()) + - (a->GetY() - b->GetY()) * (a->GetY() - b->GetY()))); -} -void CBC_DataMatrixDetector::Increment( - CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table, - CBC_ResultPoint* key) { - int32_t value; - if (table.Lookup(key, value)) { - table.SetAt(key, INTEGERS[value + 1]); - } else { - table.SetAt(key, INTEGERS[1]); - } -} -CBC_CommonBitMatrix* CBC_DataMatrixDetector::SampleGrid( - CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topRight, - int32_t dimensionX, - int32_t dimensionY, - int32_t& e) { - CBC_QRGridSampler& sampler = CBC_QRGridSampler::GetInstance(); - CBC_CommonBitMatrix* cbm = sampler.SampleGrid( - image, dimensionX, dimensionY, 0.5f, 0.5f, dimensionX - 0.5f, 0.5f, - dimensionX - 0.5f, dimensionY - 0.5f, 0.5f, dimensionY - 0.5f, - topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(), - bottomRight->GetX(), bottomRight->GetY(), bottomLeft->GetX(), - bottomLeft->GetY(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return cbm; -} -CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween( - CBC_ResultPoint* from, - CBC_ResultPoint* to) { - int32_t fromX = (int32_t)from->GetX(); - int32_t fromY = (int32_t)from->GetY(); - int32_t toX = (int32_t)to->GetX(); - int32_t toY = (int32_t)to->GetY(); - FX_BOOL steep = FXSYS_abs(toY - fromY) > FXSYS_abs(toX - fromX); - if (steep) { - int32_t temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - int32_t dx = FXSYS_abs(toX - fromX); - int32_t dy = FXSYS_abs(toY - fromY); - int32_t error = -dx >> 1; - int32_t ystep = fromY < toY ? 1 : -1; - int32_t xstep = fromX < toX ? 1 : -1; - int32_t transitions = 0; - FX_BOOL inBlack = m_image->Get(steep ? fromY : fromX, steep ? fromX : fromY); - for (int32_t x = fromX, y = fromY; x != toX; x += xstep) { - FX_BOOL isBlack = m_image->Get(steep ? y : x, steep ? x : y); - if (isBlack != inBlack) { - transitions++; - inBlack = isBlack; - } - error += dy; - if (error > 0) { - if (y == toY) { - break; - } - y += ystep; - error -= dx; - } - } - 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]); - 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]; - } else if (acDistance >= bcDistance && acDistance >= abDistance) { - topLeft = (CBC_ResultPoint*)(*patterns)[1]; - topRight = (CBC_ResultPoint*)(*patterns)[0]; - bottomLeft = (CBC_ResultPoint*)(*patterns)[2]; - } else { - topLeft = (CBC_ResultPoint*)(*patterns)[2]; - topRight = (CBC_ResultPoint*)(*patterns)[0]; - bottomLeft = (CBC_ResultPoint*)(*patterns)[1]; - } - if ((bottomLeft->GetY() - topLeft->GetY()) * - (topRight->GetX() - topLeft->GetX()) < - (bottomLeft->GetX() - topLeft->GetX()) * - (topRight->GetY() - topLeft->GetY())) { - CBC_ResultPoint* temp = topRight; - topRight = bottomLeft; - bottomLeft = temp; - } - (*patterns)[0] = bottomLeft; - (*patterns)[1] = topLeft; - (*patterns)[2] = topRight; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h deleted file mode 100644 index 34cbcb9418..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h +++ /dev/null @@ -1,78 +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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_WhiteRectangleDetector; -class CBC_ResultPoint; -class CBC_QRDetectorResult; -class CBC_DataMatrixDetector; -class ResultPointsAndTransitions; -class CBC_ResultPointsAndTransitions { - public: - CBC_ResultPointsAndTransitions(CBC_ResultPoint* from, - CBC_ResultPoint* to, - int32_t transitions) { - m_from = from; - m_to = to; - m_transitions = transitions; - } - ~CBC_ResultPointsAndTransitions() {} - CBC_ResultPoint* GetFrom() { return m_from; } - CBC_ResultPoint* GetTo() { return m_to; } - int32_t GetTransitions() { 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); - virtual ~CBC_DataMatrixDetector(); - CBC_QRDetectorResult* Detect(int32_t& e); - CBC_ResultPoint* CorrectTopRightRectangular(CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - int32_t dimensionTop, - int32_t dimensionRight); - CBC_ResultPoint* CorrectTopRight(CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - int32_t dimension); - CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* bottomRight, - CBC_ResultPoint* topRight, - int32_t dimensionX, - int32_t dimensionY, - int32_t& e); - CBC_ResultPointsAndTransitions* TransitionsBetween(CBC_ResultPoint* from, - CBC_ResultPoint* to); - FX_BOOL IsValid(CBC_ResultPoint* p); - int32_t Distance(CBC_ResultPoint* a, CBC_ResultPoint* b); - void Increment(CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table, - CBC_ResultPoint* key); - int32_t Round(FX_FLOAT d); - void OrderBestPatterns(CFX_PtrArray* patterns); - virtual void Init(int32_t& e); - - private: - static const int32_t INTEGERS[5]; - - CBC_CommonBitMatrix* m_image; - CBC_WhiteRectangleDetector* m_rectangleDetector; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp deleted file mode 100644 index 36a238b007..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp +++ /dev/null @@ -1,65 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" - -#include <memory> - -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_DataMatrixReader::CBC_DataMatrixReader() { - m_decoder = NULL; -} -void CBC_DataMatrixReader::Init() { - m_decoder = new CBC_DataMatrixDecoder; - m_decoder->Init(); -} -CBC_DataMatrixReader::~CBC_DataMatrixReader() { - delete m_decoder; -} -CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - CBC_CommonBitMatrix* cdr = image->GetBlackMatrix(e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_DataMatrixDetector detector(cdr); - detector.Init(e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - std::unique_ptr<CBC_QRDetectorResult> detectorResult(detector.Detect(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - std::unique_ptr<CBC_CommonDecoderResult> decodeResult( - m_decoder->Decode(detectorResult->GetBits(), e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return decodeResult->GetText(); -} -CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, - int32_t& e) { - CFX_ByteString bs = Decode(image, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return bs; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h deleted file mode 100644 index 5389c4857b..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ - -#include "xfa/src/fxbarcode/BC_Reader.h" - -class CBC_BinaryBitmap; -class CBC_DataMatrixDecoder; - -class CBC_DataMatrixReader : public CBC_Reader { - public: - CBC_DataMatrixReader(); - virtual ~CBC_DataMatrixReader(); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int hints, int32_t& e); - - virtual void Init(); - - private: - CBC_DataMatrixDecoder* m_decoder; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp deleted file mode 100644 index 2e7685dbb6..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.cpp +++ /dev/null @@ -1,40 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_DataMatrixSymbolInfo144::CBC_DataMatrixSymbolInfo144() - : CBC_SymbolInfo(FALSE, 1558, 620, 22, 22, 36) { - m_rsBlockData = -1; - m_rsBlockError = 62; -} -CBC_DataMatrixSymbolInfo144::~CBC_DataMatrixSymbolInfo144() {} -int32_t CBC_DataMatrixSymbolInfo144::getInterleavedBlockCount() { - return 10; -} -int32_t CBC_DataMatrixSymbolInfo144getDataLengthForInterleavedBlock( - int32_t index) { - return (index <= 8) ? 156 : 155; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h deleted file mode 100644 index 607e8937cd..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" - -class CBC_DataMatrixSymbolInfo144 : public CBC_SymbolInfo { - public: - CBC_DataMatrixSymbolInfo144(); - virtual ~CBC_DataMatrixSymbolInfo144(); - int32_t getInterleavedBlockCount(); - int32_t getDataLengthForInterleavedBlock(int32_t index); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXSYMBOLINFO144_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp deleted file mode 100644 index 4fb3a3fad6..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp +++ /dev/null @@ -1,173 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdint.h> - -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL; - -void CBC_DataMatrixVersion::Initialize() { - VERSIONS = new CFX_PtrArray(); -} -void CBC_DataMatrixVersion::Finalize() { - for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { - delete ((CBC_DataMatrixVersion*)(VERSIONS->GetAt(i))); - } - VERSIONS->RemoveAll(); - delete VERSIONS; -} -CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber, - int32_t symbolSizeRows, - int32_t symbolSizeColumns, - int32_t dataRegionSizeRows, - int32_t dataRegionSizeColumns, - ECBlocks* ecBlocks) { - m_versionNumber = versionNumber; - m_symbolSizeRows = symbolSizeRows; - m_symbolSizeColumns = symbolSizeColumns; - m_dataRegionSizeRows = dataRegionSizeRows; - m_dataRegionSizeColumns = dataRegionSizeColumns; - m_ecBlocks = ecBlocks; - int32_t total = 0; - int32_t ecCodewords = ecBlocks->GetECCodewords(); - const CFX_PtrArray& ecbArray = ecBlocks->GetECBlocks(); - for (int32_t i = 0; i < ecbArray.GetSize(); i++) { - total += ((ECB*)ecbArray[i])->GetCount() * - (((ECB*)ecbArray[i])->GetDataCodewords() + ecCodewords); - } - m_totalCodewords = total; -} -CBC_DataMatrixVersion::~CBC_DataMatrixVersion() { - delete m_ecBlocks; -} -int32_t CBC_DataMatrixVersion::GetVersionNumber() { - return m_versionNumber; -} -int32_t CBC_DataMatrixVersion::GetSymbolSizeRows() { - return m_symbolSizeRows; -} -int32_t CBC_DataMatrixVersion::GetSymbolSizeColumns() { - return m_symbolSizeColumns; -} -int32_t CBC_DataMatrixVersion::GetDataRegionSizeRows() { - return m_dataRegionSizeRows; -} -int32_t CBC_DataMatrixVersion::GetDataRegionSizeColumns() { - return m_dataRegionSizeColumns; -} -int32_t CBC_DataMatrixVersion::GetTotalCodewords() { - return m_totalCodewords; -} -ECBlocks* CBC_DataMatrixVersion::GetECBlocks() { - return m_ecBlocks; -} -void CBC_DataMatrixVersion::ReleaseAll() { - for (int32_t i = 0; i < VERSIONS->GetSize(); i++) { - delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i); - } - VERSIONS->RemoveAll(); -} -CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions( - int32_t numRows, - int32_t numColumns, - int32_t& e) { - if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { - e = BCExceptionNotFound; - return NULL; - } - if (VERSIONS->GetSize() == 0) { - VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8, - new ECBlocks(5, new ECB(1, 3)))); - VERSIONS->Add(new CBC_DataMatrixVersion(2, 12, 12, 10, 10, - new ECBlocks(7, new ECB(1, 5)))); - VERSIONS->Add(new CBC_DataMatrixVersion(3, 14, 14, 12, 12, - new ECBlocks(10, new ECB(1, 8)))); - VERSIONS->Add(new CBC_DataMatrixVersion(4, 16, 16, 14, 14, - new ECBlocks(12, new ECB(1, 12)))); - VERSIONS->Add(new CBC_DataMatrixVersion(5, 18, 18, 16, 16, - new ECBlocks(14, new ECB(1, 18)))); - VERSIONS->Add(new CBC_DataMatrixVersion(6, 20, 20, 18, 18, - new ECBlocks(18, new ECB(1, 22)))); - VERSIONS->Add(new CBC_DataMatrixVersion(7, 22, 22, 20, 20, - new ECBlocks(20, new ECB(1, 30)))); - VERSIONS->Add(new CBC_DataMatrixVersion(8, 24, 24, 22, 22, - new ECBlocks(24, new ECB(1, 36)))); - VERSIONS->Add(new CBC_DataMatrixVersion(9, 26, 26, 24, 24, - new ECBlocks(28, new ECB(1, 44)))); - VERSIONS->Add(new CBC_DataMatrixVersion(10, 32, 32, 14, 14, - new ECBlocks(36, new ECB(1, 62)))); - VERSIONS->Add(new CBC_DataMatrixVersion(11, 36, 36, 16, 16, - new ECBlocks(42, new ECB(1, 86)))); - VERSIONS->Add(new CBC_DataMatrixVersion(12, 40, 40, 18, 18, - new ECBlocks(48, new ECB(1, 114)))); - VERSIONS->Add(new CBC_DataMatrixVersion(13, 44, 44, 20, 20, - new ECBlocks(56, new ECB(1, 144)))); - VERSIONS->Add(new CBC_DataMatrixVersion(14, 48, 48, 22, 22, - new ECBlocks(68, new ECB(1, 174)))); - VERSIONS->Add(new CBC_DataMatrixVersion(15, 52, 52, 24, 24, - new ECBlocks(42, new ECB(2, 102)))); - VERSIONS->Add(new CBC_DataMatrixVersion(16, 64, 64, 14, 14, - new ECBlocks(56, new ECB(2, 140)))); - VERSIONS->Add(new CBC_DataMatrixVersion(17, 72, 72, 16, 16, - new ECBlocks(36, new ECB(4, 92)))); - VERSIONS->Add(new CBC_DataMatrixVersion(18, 80, 80, 18, 18, - new ECBlocks(48, new ECB(4, 114)))); - VERSIONS->Add(new CBC_DataMatrixVersion(19, 88, 88, 20, 20, - new ECBlocks(56, new ECB(4, 144)))); - VERSIONS->Add(new CBC_DataMatrixVersion(20, 96, 96, 22, 22, - new ECBlocks(68, new ECB(4, 174)))); - VERSIONS->Add(new CBC_DataMatrixVersion(21, 104, 104, 24, 24, - new ECBlocks(56, new ECB(6, 136)))); - VERSIONS->Add(new CBC_DataMatrixVersion(22, 120, 120, 18, 18, - new ECBlocks(68, new ECB(6, 175)))); - VERSIONS->Add(new CBC_DataMatrixVersion(23, 132, 132, 20, 20, - new ECBlocks(62, new ECB(8, 163)))); - VERSIONS->Add(new CBC_DataMatrixVersion( - 24, 144, 144, 22, 22, - new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))); - VERSIONS->Add(new CBC_DataMatrixVersion(25, 8, 18, 6, 16, - new ECBlocks(7, new ECB(1, 5)))); - VERSIONS->Add(new CBC_DataMatrixVersion(26, 8, 32, 6, 14, - new ECBlocks(11, new ECB(1, 10)))); - VERSIONS->Add(new CBC_DataMatrixVersion(27, 12, 26, 10, 24, - new ECBlocks(14, new ECB(1, 16)))); - VERSIONS->Add(new CBC_DataMatrixVersion(28, 12, 36, 10, 16, - new ECBlocks(18, new ECB(1, 22)))); - VERSIONS->Add(new CBC_DataMatrixVersion(29, 16, 36, 14, 16, - new ECBlocks(24, new ECB(1, 32)))); - VERSIONS->Add(new CBC_DataMatrixVersion(30, 16, 48, 14, 22, - new ECBlocks(28, new ECB(1, 49)))); - } - 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]; - } - } - e = BCExceptionNotFound; - return NULL; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h deleted file mode 100644 index 0a29e2b49c..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h +++ /dev/null @@ -1,92 +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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ - -#include "core/include/fxcrt/fx_basic.h" - -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; } - - int32_t GetDataCodewords() { return m_dataCodewords; } - - private: - int32_t m_count; - int32_t m_dataCodewords; -}; - -class ECBlocks { - public: - ECBlocks(int32_t ecCodewords, ECB* ecBlocks) { - m_ecCodewords = ecCodewords; - m_ecBlocks.Add(ecBlocks); - } - - ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) { - m_ecCodewords = ecCodewords; - m_ecBlocks.Add(ecBlocks1); - m_ecBlocks.Add(ecBlocks2); - } - ~ECBlocks() { - for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { - delete (ECB*)m_ecBlocks[i]; - } - m_ecBlocks.RemoveAll(); - } - - int32_t GetECCodewords() { return m_ecCodewords; } - - const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; } - - private: - int32_t m_ecCodewords; - CFX_PtrArray m_ecBlocks; -}; - -class CBC_DataMatrixVersion { - public: - CBC_DataMatrixVersion(int32_t versionNumber, - int32_t symbolSizeRows, - int32_t symbolSizeColumns, - int32_t dataRegionSizeRows, - int32_t dataRegionSizeColumns, - ECBlocks* ecBlocks); - virtual ~CBC_DataMatrixVersion(); - static void Initialize(); - static void Finalize(); - int32_t GetVersionNumber(); - int32_t GetSymbolSizeRows(); - int32_t GetSymbolSizeColumns(); - int32_t GetDataRegionSizeRows(); - int32_t GetDataRegionSizeColumns(); - int32_t GetTotalCodewords(); - ECBlocks* GetECBlocks(); - static CBC_DataMatrixVersion* GetVersionForDimensions(int32_t numRows, - int32_t numColumns, - int32_t& e); - static void ReleaseAll(); - - private: - int32_t m_versionNumber; - int32_t m_symbolSizeRows; - int32_t m_symbolSizeColumns; - int32_t m_dataRegionSizeRows; - int32_t m_dataRegionSizeColumns; - ECBlocks* m_ecBlocks; - int32_t m_totalCodewords; - static CFX_PtrArray* VERSIONS; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp deleted file mode 100644 index 5a6a082808..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp +++ /dev/null @@ -1,136 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" -#include "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h" - -CBC_DataMatrixWriter::CBC_DataMatrixWriter() {} -CBC_DataMatrixWriter::~CBC_DataMatrixWriter() {} -FX_BOOL CBC_DataMatrixWriter::SetErrorCorrectionLevel(int32_t level) { - m_iCorrectLevel = level; - return TRUE; -} -uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - if (outWidth < 0 || outHeight < 0) { - e = BCExceptionHeightAndWidthMustBeAtLeast1; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CBC_SymbolShapeHint::SymbolShapeHint shape = - CBC_SymbolShapeHint::FORCE_SQUARE; - CBC_Dimension* minSize = NULL; - CBC_Dimension* maxSize = NULL; - CFX_WideString ecLevel; - CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel( - contents, ecLevel, shape, minSize, maxSize, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup( - encoded.GetLength(), shape, minSize, maxSize, TRUE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_WideString codewords = - CBC_ErrorCorrection::encodeECC200(encoded, symbolInfo, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_DefaultPlacement* placement = - new CBC_DefaultPlacement(codewords, symbolInfo->getSymbolDataWidth(e), - symbolInfo->getSymbolDataHeight(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - placement->place(); - CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - outWidth = bytematrix->GetWidth(); - outHeight = bytematrix->GetHeight(); - uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); - FXSYS_memcpy(result, bytematrix->GetArray(), outWidth * outHeight); - delete bytematrix; - delete placement; - return result; -} -CBC_CommonByteMatrix* CBC_DataMatrixWriter::encodeLowLevel( - CBC_DefaultPlacement* placement, - CBC_SymbolInfo* symbolInfo, - int32_t& e) { - int32_t symbolWidth = symbolInfo->getSymbolDataWidth(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t symbolHeight = symbolInfo->getSymbolDataHeight(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_CommonByteMatrix* matrix = new CBC_CommonByteMatrix( - symbolInfo->getSymbolWidth(e), symbolInfo->getSymbolHeight(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - matrix->Init(); - int32_t matrixY = 0; - for (int32_t y = 0; y < symbolHeight; y++) { - int32_t matrixX; - if ((y % symbolInfo->m_matrixHeight) == 0) { - matrixX = 0; - for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { - matrix->Set(matrixX, matrixY, (x % 2) == 0); - matrixX++; - } - matrixY++; - } - matrixX = 0; - for (int32_t x = 0; x < symbolWidth; x++) { - if ((x % symbolInfo->m_matrixWidth) == 0) { - matrix->Set(matrixX, matrixY, TRUE); - matrixX++; - } - matrix->Set(matrixX, matrixY, placement->getBit(x, y)); - matrixX++; - if ((x % symbolInfo->m_matrixWidth) == symbolInfo->m_matrixWidth - 1) { - matrix->Set(matrixX, matrixY, (y % 2) == 0); - matrixX++; - } - } - matrixY++; - if ((y % symbolInfo->m_matrixHeight) == symbolInfo->m_matrixHeight - 1) { - matrixX = 0; - for (int32_t x = 0; x < symbolInfo->getSymbolWidth(e); x++) { - matrix->Set(matrixX, matrixY, TRUE); - matrixX++; - } - matrixY++; - } - } - return matrix; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h deleted file mode 100644 index d1abbbc451..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixWriter.h +++ /dev/null @@ -1,33 +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_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ - -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" - -class CBC_CommonByteMatrix; -class CBC_DefaultPlacement; -class CBC_SymbolInfo; - -class CBC_DataMatrixWriter : public CBC_TwoDimWriter { - public: - CBC_DataMatrixWriter(); - virtual ~CBC_DataMatrixWriter(); - uint8_t* Encode(const CFX_WideString& contents, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - FX_BOOL SetErrorCorrectionLevel(int32_t level); - - private: - static CBC_CommonByteMatrix* encodeLowLevel(CBC_DefaultPlacement* placement, - CBC_SymbolInfo* symbolInfo, - int32_t& e); - int32_t m_iCorrectLevel; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXWRITER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp deleted file mode 100644 index f021b75282..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.cpp +++ /dev/null @@ -1,164 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -CBC_DefaultPlacement::CBC_DefaultPlacement(CFX_WideString codewords, - int32_t numcols, - int32_t numrows) { - m_codewords = codewords; - m_numcols = numcols; - m_numrows = numrows; - m_bits.SetSize(numcols * numrows); - for (int32_t i = 0; i < numcols * numrows; i++) { - m_bits[i] = (uint8_t)2; - } -} -CBC_DefaultPlacement::~CBC_DefaultPlacement() { - m_bits.RemoveAll(); -} -int32_t CBC_DefaultPlacement::getNumrows() { - return m_numrows; -} -int32_t CBC_DefaultPlacement::getNumcols() { - return m_numcols; -} -CFX_ByteArray& CBC_DefaultPlacement::getBits() { - return m_bits; -} -FX_BOOL CBC_DefaultPlacement::getBit(int32_t col, int32_t row) { - return m_bits[row * m_numcols + col] == 1; -} -void CBC_DefaultPlacement::setBit(int32_t col, int32_t row, FX_BOOL bit) { - m_bits[row * m_numcols + col] = bit ? (uint8_t)1 : (uint8_t)0; -} -FX_BOOL CBC_DefaultPlacement::hasBit(int32_t col, int32_t row) { - return m_bits[row * m_numcols + col] != 2; -} -void CBC_DefaultPlacement::place() { - int32_t pos = 0; - int32_t row = 4; - int32_t col = 0; - do { - if ((row == m_numrows) && (col == 0)) { - corner1(pos++); - } - if ((row == m_numrows - 2) && (col == 0) && ((m_numcols % 4) != 0)) { - corner2(pos++); - } - if ((row == m_numrows - 2) && (col == 0) && (m_numcols % 8 == 4)) { - corner3(pos++); - } - if ((row == m_numrows + 4) && (col == 2) && ((m_numcols % 8) == 0)) { - corner4(pos++); - } - do { - if ((row < m_numrows) && (col >= 0) && !hasBit(col, row)) { - utah(row, col, pos++); - } - row -= 2; - col += 2; - } while (row >= 0 && (col < m_numcols)); - row++; - col += 3; - do { - if ((row >= 0) && (col < m_numcols) && !hasBit(col, row)) { - utah(row, col, pos++); - } - row += 2; - col -= 2; - } while ((row < m_numrows) && (col >= 0)); - row += 3; - col++; - } while ((row < m_numrows) || (col < m_numcols)); - if (!hasBit(m_numcols - 1, m_numrows - 1)) { - setBit(m_numcols - 1, m_numrows - 1, TRUE); - setBit(m_numcols - 2, m_numrows - 2, TRUE); - } -} -void CBC_DefaultPlacement::module(int32_t row, - int32_t col, - int32_t pos, - int32_t bit) { - if (row < 0) { - row += m_numrows; - col += 4 - ((m_numrows + 4) % 8); - } - if (col < 0) { - col += m_numcols; - row += 4 - ((m_numcols + 4) % 8); - } - int32_t v = m_codewords.GetAt(pos); - v &= 1 << (8 - bit); - setBit(col, row, v != 0); -} -void CBC_DefaultPlacement::utah(int32_t row, int32_t col, int32_t pos) { - module(row - 2, col - 2, pos, 1); - module(row - 2, col - 1, pos, 2); - module(row - 1, col - 2, pos, 3); - module(row - 1, col - 1, pos, 4); - module(row - 1, col, pos, 5); - module(row, col - 2, pos, 6); - module(row, col - 1, pos, 7); - module(row, col, pos, 8); -} -void CBC_DefaultPlacement::corner1(int32_t pos) { - module(m_numrows - 1, 0, pos, 1); - module(m_numrows - 1, 1, pos, 2); - module(m_numrows - 1, 2, pos, 3); - module(0, m_numcols - 2, pos, 4); - module(0, m_numcols - 1, pos, 5); - module(1, m_numcols - 1, pos, 6); - module(2, m_numcols - 1, pos, 7); - module(3, m_numcols - 1, pos, 8); -} -void CBC_DefaultPlacement::corner2(int32_t pos) { - module(m_numrows - 3, 0, pos, 1); - module(m_numrows - 2, 0, pos, 2); - module(m_numrows - 1, 0, pos, 3); - module(0, m_numcols - 4, pos, 4); - module(0, m_numcols - 3, pos, 5); - module(0, m_numcols - 2, pos, 6); - module(0, m_numcols - 1, pos, 7); - module(1, m_numcols - 1, pos, 8); -} -void CBC_DefaultPlacement::corner3(int32_t pos) { - module(m_numrows - 3, 0, pos, 1); - module(m_numrows - 2, 0, pos, 2); - module(m_numrows - 1, 0, pos, 3); - module(0, m_numcols - 2, pos, 4); - module(0, m_numcols - 1, pos, 5); - module(1, m_numcols - 1, pos, 6); - module(2, m_numcols - 1, pos, 7); - module(3, m_numcols - 1, pos, 8); -} -void CBC_DefaultPlacement::corner4(int32_t pos) { - module(m_numrows - 1, 0, pos, 1); - module(m_numrows - 1, m_numcols - 1, pos, 2); - module(0, m_numcols - 3, pos, 3); - module(0, m_numcols - 2, pos, 4); - module(0, m_numcols - 1, pos, 5); - module(1, m_numcols - 3, pos, 6); - module(1, m_numcols - 2, pos, 7); - module(1, m_numcols - 1, pos, 8); -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h b/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h deleted file mode 100644 index be67f3c05a..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_DefaultPlacement.h +++ /dev/null @@ -1,40 +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_SRC_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_DefaultPlacement { - public: - CBC_DefaultPlacement(CFX_WideString codewords, - int32_t numcols, - int32_t numrows); - virtual ~CBC_DefaultPlacement(); - - int32_t getNumrows(); - int32_t getNumcols(); - CFX_ByteArray& getBits(); - FX_BOOL getBit(int32_t col, int32_t row); - void setBit(int32_t col, int32_t row, FX_BOOL bit); - FX_BOOL hasBit(int32_t col, int32_t row); - void place(); - - private: - CFX_WideString m_codewords; - int32_t m_numrows; - int32_t m_numcols; - CFX_ByteArray m_bits; - void module(int32_t row, int32_t col, int32_t pos, int32_t bit); - void utah(int32_t row, int32_t col, int32_t pos); - void corner1(int32_t pos); - void corner2(int32_t pos); - void corner3(int32_t pos); - void corner4(int32_t pos); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_DEFAULTPLACEMENT_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.cpp deleted file mode 100644 index 006c85117d..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.cpp +++ /dev/null @@ -1,154 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_EdifactEncoder::CBC_EdifactEncoder() {} -CBC_EdifactEncoder::~CBC_EdifactEncoder() {} -int32_t CBC_EdifactEncoder::getEncodingMode() { - return EDIFACT_ENCODATION; -} -void CBC_EdifactEncoder::Encode(CBC_EncoderContext& context, int32_t& e) { - CFX_WideString buffer; - while (context.hasMoreCharacters()) { - FX_WCHAR c = context.getCurrentChar(); - encodeChar(c, buffer, e); - if (e != BCExceptionNO) { - return; - } - context.m_pos++; - int32_t count = buffer.GetLength(); - if (count >= 4) { - context.writeCodewords(encodeToCodewords(buffer, 0, e)); - if (e != BCExceptionNO) { - return; - } - buffer.Delete(0, 4); - int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( - context.m_msg, context.m_pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - context.signalEncoderChange(ASCII_ENCODATION); - break; - } - } - } - buffer += (FX_WCHAR)31; - handleEOD(context, buffer, e); -} -void CBC_EdifactEncoder::handleEOD(CBC_EncoderContext& context, - CFX_WideString buffer, - int32_t& e) { - int32_t count = buffer.GetLength(); - if (count == 0) { - return; - } - if (count == 1) { - context.updateSymbolInfo(e); - if (e != BCExceptionNO) { - return; - } - int32_t available = - context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); - int32_t remaining = context.getRemainingCharacters(); - if (remaining == 0 && available <= 2) { - return; - } - } - if (count > 4) { - e = BCExceptionIllegalStateCountMustNotExceed4; - return; - } - int32_t restChars = count - 1; - CFX_WideString encoded = encodeToCodewords(buffer, 0, e); - if (e != BCExceptionNO) { - return; - } - FX_BOOL endOfSymbolReached = !context.hasMoreCharacters(); - FX_BOOL restInAscii = endOfSymbolReached && restChars <= 2; - if (restChars <= 2) { - context.updateSymbolInfo(context.getCodewordCount() + restChars, e); - if (e != BCExceptionNO) { - return; - } - int32_t available = - context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); - if (available >= 3) { - restInAscii = FALSE; - context.updateSymbolInfo(context.getCodewordCount() + encoded.GetLength(), - e); - if (e != BCExceptionNO) { - return; - } - } - } - if (restInAscii) { - context.resetSymbolInfo(); - context.m_pos -= restChars; - } else { - context.writeCodewords(encoded); - } - context.signalEncoderChange(ASCII_ENCODATION); -} -void CBC_EdifactEncoder::encodeChar(FX_WCHAR c, - CFX_WideString& sb, - int32_t& e) { - if (c >= ' ' && c <= '?') { - sb += c; - } else if (c >= '@' && c <= '^') { - sb += (FX_WCHAR)(c - 64); - } else { - CBC_HighLevelEncoder::illegalCharacter(c, e); - } -} -CFX_WideString CBC_EdifactEncoder::encodeToCodewords(CFX_WideString sb, - int32_t startPos, - int32_t& e) { - int32_t len = sb.GetLength() - startPos; - if (len == 0) { - e = BCExceptionNoContents; - return (FX_WCHAR*)""; - } - FX_WCHAR c1 = sb.GetAt(startPos); - FX_WCHAR c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0; - FX_WCHAR c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0; - FX_WCHAR c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0; - int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; - FX_WCHAR cw1 = (FX_WCHAR)((v >> 16) & 255); - FX_WCHAR cw2 = (FX_WCHAR)((v >> 8) & 255); - FX_WCHAR cw3 = (FX_WCHAR)(v & 255); - CFX_WideString res; - res += cw1; - if (len >= 2) { - res += cw2; - } - if (len >= 3) { - res += cw3; - } - return res; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h b/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h deleted file mode 100644 index 4d905edb63..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h +++ /dev/null @@ -1,29 +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_SRC_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" - -class CBC_EdifactEncoder : public CBC_Encoder { - public: - CBC_EdifactEncoder(); - virtual ~CBC_EdifactEncoder(); - int32_t getEncodingMode(); - void Encode(CBC_EncoderContext& context, int32_t& e); - - private: - static void handleEOD(CBC_EncoderContext& context, - CFX_WideString buffer, - int32_t& e); - static void encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); - static CFX_WideString encodeToCodewords(CFX_WideString sb, - int32_t startPos, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_EDIFACTENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_Encoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_Encoder.cpp deleted file mode 100644 index 5a5ca3f5a4..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_Encoder.cpp +++ /dev/null @@ -1,10 +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/src/fxbarcode/datamatrix/BC_Encoder.h" - -CBC_Encoder::CBC_Encoder() {} -CBC_Encoder::~CBC_Encoder() {} diff --git a/xfa/src/fxbarcode/datamatrix/BC_Encoder.h b/xfa/src/fxbarcode/datamatrix/BC_Encoder.h deleted file mode 100644 index a11b19cc74..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_Encoder.h +++ /dev/null @@ -1,21 +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_SRC_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ - -#include "xfa/src/fxbarcode/utils.h" - -class CBC_EncoderContext; -class CBC_Encoder { - public: - CBC_Encoder(); - virtual ~CBC_Encoder(); - virtual int32_t getEncodingMode() = 0; - virtual void Encode(CBC_EncoderContext& context, int32_t& e) = 0; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_ENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.cpp b/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.cpp deleted file mode 100644 index 54aa5349b0..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.cpp +++ /dev/null @@ -1,111 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, - CFX_WideString ecLevel, - int32_t& e) { - CFX_ByteString dststr; - CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr); - CFX_WideString sb; - int32_t c = dststr.GetLength(); - for (int32_t i = 0; i < c; i++) { - FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff); - if (ch == '?' && dststr.GetAt(i) != '?') { - e = BCExceptionCharactersOutsideISO88591Encoding; - } - sb += ch; - } - m_msg = sb; - m_shape = FORCE_NONE; - m_newEncoding = -1; - m_pos = 0; - m_symbolInfo = NULL; - m_skipAtEnd = 0; - m_maxSize = NULL; - m_minSize = NULL; -} -CBC_EncoderContext::~CBC_EncoderContext() {} -void CBC_EncoderContext::setSymbolShape(SymbolShapeHint shape) { - m_shape = shape; -} -void CBC_EncoderContext::setSizeConstraints(CBC_Dimension* minSize, - CBC_Dimension* maxSize) { - m_maxSize = maxSize; - m_minSize = minSize; -} -CFX_WideString CBC_EncoderContext::getMessage() { - return m_msg; -} -void CBC_EncoderContext::setSkipAtEnd(int32_t count) { - m_skipAtEnd = count; -} -FX_WCHAR CBC_EncoderContext::getCurrentChar() { - return m_msg.GetAt(m_pos); -} -FX_WCHAR CBC_EncoderContext::getCurrent() { - return m_msg.GetAt(m_pos); -} -void CBC_EncoderContext::writeCodewords(CFX_WideString codewords) { - m_codewords += codewords; -} -void CBC_EncoderContext::writeCodeword(FX_WCHAR codeword) { - m_codewords += codeword; -} -int32_t CBC_EncoderContext::getCodewordCount() { - return m_codewords.GetLength(); -} -void CBC_EncoderContext::signalEncoderChange(int32_t encoding) { - m_newEncoding = encoding; -} -void CBC_EncoderContext::resetEncoderSignal() { - m_newEncoding = -1; -} -FX_BOOL CBC_EncoderContext::hasMoreCharacters() { - return m_pos < getTotalMessageCharCount(); -} -int32_t CBC_EncoderContext::getRemainingCharacters() { - return getTotalMessageCharCount() - m_pos; -} -void CBC_EncoderContext::updateSymbolInfo(int32_t& e) { - updateSymbolInfo(getCodewordCount(), e); -} -void CBC_EncoderContext::updateSymbolInfo(int32_t len, int32_t& e) { - if (m_symbolInfo == NULL || len > m_symbolInfo->m_dataCapacity) { - m_symbolInfo = - CBC_SymbolInfo::lookup(len, m_shape, m_minSize, m_maxSize, true, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_EncoderContext::resetSymbolInfo() { - m_shape = FORCE_NONE; -} -int32_t CBC_EncoderContext::getTotalMessageCharCount() { - return m_msg.GetLength() - m_skipAtEnd; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h b/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h deleted file mode 100644 index 076581c7aa..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -class CBC_SymbolInfo; -class CBC_Dimension; - -class CBC_EncoderContext : public CBC_SymbolShapeHint { - public: - CBC_EncoderContext(const CFX_WideString msg, - CFX_WideString ecLevel, - int32_t& e); - virtual ~CBC_EncoderContext(); - void setSymbolShape(SymbolShapeHint shape); - void setSizeConstraints(CBC_Dimension* minSize, CBC_Dimension* maxSize); - CFX_WideString getMessage(); - void setSkipAtEnd(int32_t count); - FX_WCHAR getCurrentChar(); - FX_WCHAR getCurrent(); - void writeCodewords(CFX_WideString codewords); - void writeCodeword(FX_WCHAR codeword); - int32_t getCodewordCount(); - void signalEncoderChange(int32_t encoding); - void resetEncoderSignal(); - FX_BOOL hasMoreCharacters(); - int32_t getRemainingCharacters(); - void updateSymbolInfo(int32_t& e); - void updateSymbolInfo(int32_t len, int32_t& e); - void resetSymbolInfo(); - - public: - CFX_WideString m_msg; - CFX_WideString m_codewords; - int32_t m_pos; - int32_t m_newEncoding; - CBC_SymbolInfo* m_symbolInfo; - - private: - int32_t getTotalMessageCharCount(); - - private: - SymbolShapeHint m_shape; - CBC_Dimension* m_minSize; - CBC_Dimension* m_maxSize; - int32_t m_skipAtEnd; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.cpp deleted file mode 100644 index d5ae9bf9bf..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -int32_t CBC_ErrorCorrection::FACTOR_SETS[] = {5, 7, 10, 11, 12, 14, 18, 20, - 24, 28, 36, 42, 48, 56, 62, 68}; -int32_t CBC_ErrorCorrection::FACTORS[][100] = { - {228, 48, 15, 111, 62}, - {23, 68, 144, 134, 240, 92, 254}, - {28, 24, 185, 166, 223, 248, 116, 255, 110, 61}, - {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120}, - {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242}, - {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185}, - {83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, - 90, 188}, - {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, - 174, 186, 172}, - {52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, - 254, 124, 12, 181, 184, 96, 50, 193}, - {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, - 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255}, - {245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, - 182, 229, 18, 2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, - 225, 98, 81, 112}, - {77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, - 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, - 69, 50, 150, 177, 226, 5, 9, 5}, - {245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, - 191, 106, 16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, - 186, 240, 82, 44, 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19}, - {175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, - 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, - 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, - 155, 43, 203, 107, 233, 53, 143, 46}, - {242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, - 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, - 71, 161, 44, 147, 6, 27, 218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31, - 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, 11, 204}, - {220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, - 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, - 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, 96, 210, 231, 136, - 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211, 189, 64, 54, 108, 153, - 132, 63, 96, 103, 82, 186}}; -int32_t CBC_ErrorCorrection::MODULO_VALUE = 0x12D; -int32_t CBC_ErrorCorrection::LOG[256] = {0}; -int32_t CBC_ErrorCorrection::ALOG[256] = {0}; -void CBC_ErrorCorrection::Initialize() { - int32_t p = 1; - for (int32_t i = 0; i < 255; i++) { - ALOG[i] = p; - LOG[p] = i; - p <<= 1; - if (p >= 256) { - p ^= MODULO_VALUE; - } - } -} -void CBC_ErrorCorrection::Finalize() {} -CBC_ErrorCorrection::CBC_ErrorCorrection() {} -CBC_ErrorCorrection::~CBC_ErrorCorrection() {} -CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, - CBC_SymbolInfo* symbolInfo, - int32_t& e) { - if (codewords.GetLength() != symbolInfo->m_dataCapacity) { - e = BCExceptionIllegalArgument; - return (FX_WCHAR*)""; - } - CFX_WideString sb; - sb += codewords; - int32_t blockCount = symbolInfo->getInterleavedBlockCount(); - if (blockCount == 1) { - CFX_WideString ecc = - createECCBlock(codewords, symbolInfo->m_errorCodewords, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - sb += ecc; - } else { - CFX_Int32Array dataSizes; - dataSizes.SetSize(blockCount); - CFX_Int32Array errorSizes; - errorSizes.SetSize(blockCount); - CFX_Int32Array startPos; - startPos.SetSize(blockCount); - for (int32_t i = 0; i < blockCount; i++) { - dataSizes[i] = symbolInfo->getDataLengthForInterleavedBlock(i + 1); - errorSizes[i] = symbolInfo->getErrorLengthForInterleavedBlock(i + 1); - startPos[i] = 0; - if (i > 0) { - startPos[i] = startPos[i - 1] + dataSizes[i]; - } - } - for (int32_t block = 0; block < blockCount; block++) { - CFX_WideString temp; - for (int32_t d = block; d < symbolInfo->m_dataCapacity; d += blockCount) { - temp += (FX_WCHAR)codewords.GetAt(d); - } - CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - int32_t pos = 0; - for (int32_t l = block; l < errorSizes[block] * blockCount; - l += blockCount) { - sb.SetAt(symbolInfo->m_dataCapacity + l, ecc.GetAt(pos++)); - } - } - } - return sb; -} -CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords, - int32_t numECWords, - int32_t& e) { - return createECCBlock(codewords, 0, codewords.GetLength(), numECWords, e); -} -CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords, - int32_t start, - 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) { - e = BCExceptionIllegalArgument; - return (FX_WCHAR*)""; - } - FX_WORD* ecc = FX_Alloc(FX_WORD, numECWords); - FXSYS_memset(ecc, 0, numECWords * sizeof(FX_WORD)); - for (int32_t l = start; l < start + len; l++) { - FX_WORD m = ecc[numECWords - 1] ^ codewords.GetAt(l); - for (int32_t k = numECWords - 1; k > 0; k--) { - if (m != 0 && FACTORS[table][k] != 0) { - ecc[k] = (FX_WORD)(ecc[k - 1] ^ - ALOG[(LOG[m] + LOG[FACTORS[table][k]]) % 255]); - } else { - ecc[k] = ecc[k - 1]; - } - } - if (m != 0 && FACTORS[table][0] != 0) { - ecc[0] = (FX_WORD)ALOG[(LOG[m] + LOG[FACTORS[table][0]]) % 255]; - } else { - ecc[0] = 0; - } - } - CFX_WideString strecc; - for (int32_t j = 0; j < numECWords; j++) { - strecc += (FX_WCHAR)ecc[numECWords - j - 1]; - } - FX_Free(ecc); - return strecc; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h b/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.h deleted file mode 100644 index 951b9ea572..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_ErrorCorrection.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_SRC_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ - -class CBC_SymbolInfo; -class CBC_ErrorCorrection { - public: - CBC_ErrorCorrection(); - virtual ~CBC_ErrorCorrection(); - static void Initialize(); - static void Finalize(); - static CFX_WideString encodeECC200(CFX_WideString codewords, - CBC_SymbolInfo* symbolInfo, - int32_t& e); - - private: - static int32_t FACTOR_SETS[]; - static int32_t FACTORS[][100]; - static int32_t MODULO_VALUE; - static int32_t LOG[256]; - static int32_t ALOG[256]; - - private: - static CFX_WideString createECCBlock(CFX_WideString codewords, - int32_t numECWords, - int32_t& e); - static CFX_WideString createECCBlock(CFX_WideString codewords, - int32_t start, - int32_t len, - int32_t numECWords, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_ERRORCORRECTION_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp deleted file mode 100644 index 21e1b6bb51..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp +++ /dev/null @@ -1,375 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <limits> - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_ASCIIEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Base256Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EdifactEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" -#include "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h" -#include "xfa/src/fxbarcode/utils.h" - -FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_C40 = 230; -FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_BASE256 = 231; -FX_WCHAR CBC_HighLevelEncoder::UPPER_SHIFT = 235; -FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_ANSIX12 = 238; -FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_TEXT = 239; -FX_WCHAR CBC_HighLevelEncoder::LATCH_TO_EDIFACT = 240; -FX_WCHAR CBC_HighLevelEncoder::C40_UNLATCH = 254; -FX_WCHAR CBC_HighLevelEncoder::X12_UNLATCH = 254; -FX_WCHAR CBC_HighLevelEncoder::PAD = 129; -FX_WCHAR CBC_HighLevelEncoder::MACRO_05 = 236; -FX_WCHAR CBC_HighLevelEncoder::MACRO_06 = 237; -const wchar_t* CBC_HighLevelEncoder::MACRO_05_HEADER = L"[)>05"; -const wchar_t* CBC_HighLevelEncoder::MACRO_06_HEADER = L"[)>06"; -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); - for (int32_t i = 0; i < bytestr.GetLength(); i++) { - m_bytearray.Add(bytestr.GetAt(i)); - } - return m_bytearray; -} -CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, - CFX_WideString ecLevel, - int32_t& e) { - return encodeHighLevel(msg, ecLevel, FORCE_NONE, NULL, NULL, e); -} -CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, - CFX_WideString ecLevel, - SymbolShapeHint shape, - CBC_Dimension* minSize, - CBC_Dimension* maxSize, - int32_t& e) { - CBC_EncoderContext context(msg, ecLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - context.setSymbolShape(shape); - context.setSizeConstraints(minSize, maxSize); - if ((msg.Mid(0, 6) == MACRO_05_HEADER) && - (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { - context.writeCodeword(MACRO_05); - context.setSkipAtEnd(2); - context.m_pos += 6; - } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) && - (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { - context.writeCodeword(MACRO_06); - 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()); - 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*)""; - } - if (context.m_newEncoding >= 0) { - encodingMode = context.m_newEncoding; - context.resetEncoderSignal(); - } - } - 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*)""; - } - int32_t capacity = context.m_symbolInfo->m_dataCapacity; - if (len < capacity) { - if (encodingMode != ASCII_ENCODATION && - encodingMode != BASE256_ENCODATION) { - context.writeCodeword(0x00fe); - } - } - CFX_WideString codewords = context.m_codewords; - if (codewords.GetLength() < capacity) { - codewords += PAD; - } - 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, - int32_t startpos, - int32_t currentMode) { - if (startpos >= msg.GetLength()) { - return currentMode; - } - CFX_FloatArray charCounts; - if (currentMode == ASCII_ENCODATION) { - charCounts.Add(0); - charCounts.Add(1); - charCounts.Add(1); - charCounts.Add(1); - charCounts.Add(1); - charCounts.Add(1.25f); - } else { - charCounts.Add(1); - charCounts.Add(2); - charCounts.Add(2); - charCounts.Add(2); - charCounts.Add(2); - charCounts.Add(2.25f); - charCounts[currentMode] = 0; - } - int32_t charsProcessed = 0; - while (TRUE) { - if ((startpos + charsProcessed) == msg.GetLength()) { - FX_DWORD min = std::numeric_limits<int32_t>::max(); - CFX_ByteArray mins; - mins.SetSize(6); - CFX_Int32Array intCharCounts; - intCharCounts.SetSize(6); - min = findMinimums(charCounts, intCharCounts, min, mins); - int32_t minCount = getMinimumCount(mins); - if (intCharCounts[ASCII_ENCODATION] == min) { - return ASCII_ENCODATION; - } - if (minCount == 1 && mins[BASE256_ENCODATION] > 0) { - return BASE256_ENCODATION; - } - if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { - return EDIFACT_ENCODATION; - } - if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { - return TEXT_ENCODATION; - } - if (minCount == 1 && mins[X12_ENCODATION] > 0) { - return X12_ENCODATION; - } - return C40_ENCODATION; - } - FX_WCHAR c = msg.GetAt(startpos + charsProcessed); - charsProcessed++; - if (isDigit(c)) { - charCounts[ASCII_ENCODATION] += 0.5; - } else if (isExtendedASCII(c)) { - charCounts[ASCII_ENCODATION] = - (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); - charCounts[ASCII_ENCODATION] += 2; - } else { - charCounts[ASCII_ENCODATION] = - (FX_FLOAT)ceil(charCounts[ASCII_ENCODATION]); - charCounts[ASCII_ENCODATION]++; - } - if (isNativeC40(c)) { - charCounts[C40_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[C40_ENCODATION] += 8.0f / 3.0f; - } else { - charCounts[C40_ENCODATION] += 4.0f / 3.0f; - } - if (isNativeText(c)) { - charCounts[TEXT_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[TEXT_ENCODATION] += 8.0f / 3.0f; - } else { - charCounts[TEXT_ENCODATION] += 4.0f / 3.0f; - } - if (isNativeX12(c)) { - charCounts[X12_ENCODATION] += 2.0f / 3.0f; - } else if (isExtendedASCII(c)) { - charCounts[X12_ENCODATION] += 13.0f / 3.0f; - } else { - charCounts[X12_ENCODATION] += 10.0f / 3.0f; - } - if (isNativeEDIFACT(c)) { - charCounts[EDIFACT_ENCODATION] += 3.0f / 4.0f; - } else if (isExtendedASCII(c)) { - charCounts[EDIFACT_ENCODATION] += 17.0f / 4.0f; - } else { - charCounts[EDIFACT_ENCODATION] += 13.0f / 4.0f; - } - if (isSpecialB256(c)) { - charCounts[BASE256_ENCODATION] += 4; - } else { - charCounts[BASE256_ENCODATION]++; - } - if (charsProcessed >= 4) { - CFX_Int32Array intCharCounts; - intCharCounts.SetSize(6); - CFX_ByteArray mins; - mins.SetSize(6); - findMinimums(charCounts, intCharCounts, - std::numeric_limits<int32_t>::max(), mins); - int32_t minCount = getMinimumCount(mins); - if (intCharCounts[ASCII_ENCODATION] < intCharCounts[BASE256_ENCODATION] && - intCharCounts[ASCII_ENCODATION] < intCharCounts[C40_ENCODATION] && - intCharCounts[ASCII_ENCODATION] < intCharCounts[TEXT_ENCODATION] && - intCharCounts[ASCII_ENCODATION] < intCharCounts[X12_ENCODATION] && - intCharCounts[ASCII_ENCODATION] < intCharCounts[EDIFACT_ENCODATION]) { - return ASCII_ENCODATION; - } - if (intCharCounts[BASE256_ENCODATION] < intCharCounts[ASCII_ENCODATION] || - (mins[C40_ENCODATION] + mins[TEXT_ENCODATION] + mins[X12_ENCODATION] + - mins[EDIFACT_ENCODATION]) == 0) { - return BASE256_ENCODATION; - } - if (minCount == 1 && mins[EDIFACT_ENCODATION] > 0) { - return EDIFACT_ENCODATION; - } - if (minCount == 1 && mins[TEXT_ENCODATION] > 0) { - return TEXT_ENCODATION; - } - if (minCount == 1 && mins[X12_ENCODATION] > 0) { - return X12_ENCODATION; - } - if (intCharCounts[C40_ENCODATION] + 1 < intCharCounts[ASCII_ENCODATION] && - intCharCounts[C40_ENCODATION] + 1 < - intCharCounts[BASE256_ENCODATION] && - intCharCounts[C40_ENCODATION] + 1 < - intCharCounts[EDIFACT_ENCODATION] && - intCharCounts[C40_ENCODATION] + 1 < intCharCounts[TEXT_ENCODATION]) { - if (intCharCounts[C40_ENCODATION] < intCharCounts[X12_ENCODATION]) { - return C40_ENCODATION; - } - if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) { - int32_t p = startpos + charsProcessed + 1; - while (p < msg.GetLength()) { - FX_WCHAR tc = msg.GetAt(p); - if (isX12TermSep(tc)) { - return X12_ENCODATION; - } - if (!isNativeX12(tc)) { - break; - } - p++; - } - return C40_ENCODATION; - } - } - } - } -} -FX_BOOL CBC_HighLevelEncoder::isDigit(FX_WCHAR ch) { - return ch >= '0' && ch <= '9'; -} -FX_BOOL CBC_HighLevelEncoder::isExtendedASCII(FX_WCHAR ch) { - return ch >= 128 && ch <= 255; -} -int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg, - int32_t startpos) { - int32_t count = 0; - int32_t len = msg.GetLength(); - int32_t idx = startpos; - if (idx < len) { - FX_WCHAR ch = msg.GetAt(idx); - while (isDigit(ch) && idx < len) { - count++; - idx++; - if (idx < len) { - ch = msg.GetAt(idx); - } - } - } - return count; -} -void CBC_HighLevelEncoder::illegalCharacter(FX_WCHAR c, int32_t& e) { - e = BCExceptionIllegalArgument; -} -FX_WCHAR CBC_HighLevelEncoder::randomize253State(FX_WCHAR ch, - int32_t codewordPosition) { - int32_t pseudoRandom = ((149 * codewordPosition) % 253) + 1; - int32_t tempVariable = ch + pseudoRandom; - return tempVariable <= 254 ? (FX_WCHAR)tempVariable - : (FX_WCHAR)(tempVariable - 254); -} -int32_t CBC_HighLevelEncoder::findMinimums(CFX_FloatArray& charCounts, - CFX_Int32Array& intCharCounts, - int32_t min, - CFX_ByteArray& mins) { - for (int32_t l = 0; l < mins.GetSize(); l++) { - mins[l] = (uint8_t)0; - } - for (int32_t i = 0; i < 6; i++) { - intCharCounts[i] = (int32_t)ceil(charCounts[i]); - int32_t current = intCharCounts[i]; - if (min > current) { - min = current; - for (int32_t j = 0; j < mins.GetSize(); j++) { - mins[j] = (uint8_t)0; - } - } - if (min == current) { - mins[i]++; - } - } - return min; -} -int32_t CBC_HighLevelEncoder::getMinimumCount(CFX_ByteArray& mins) { - int32_t minCount = 0; - for (int32_t i = 0; i < 6; i++) { - minCount += mins[i]; - } - return minCount; -} -FX_BOOL CBC_HighLevelEncoder::isNativeC40(FX_WCHAR ch) { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z'); -} -FX_BOOL CBC_HighLevelEncoder::isNativeText(FX_WCHAR ch) { - return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z'); -} -FX_BOOL CBC_HighLevelEncoder::isNativeX12(FX_WCHAR ch) { - return isX12TermSep(ch) || (ch == ' ') || (ch >= '0' && ch <= '9') || - (ch >= 'A' && ch <= 'Z'); -} -FX_BOOL CBC_HighLevelEncoder::isX12TermSep(FX_WCHAR ch) { - return (ch == '\r') || (ch == '*') || (ch == '>'); -} -FX_BOOL CBC_HighLevelEncoder::isNativeEDIFACT(FX_WCHAR ch) { - return ch >= ' ' && ch <= '^'; -} -FX_BOOL CBC_HighLevelEncoder::isSpecialB256(FX_WCHAR ch) { - return FALSE; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h b/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h deleted file mode 100644 index 2ac64695eb..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h +++ /dev/null @@ -1,76 +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_SRC_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ - -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -#define ASCII_ENCODATION 0 -#define C40_ENCODATION 1 -#define TEXT_ENCODATION 2 -#define X12_ENCODATION 3 -#define EDIFACT_ENCODATION 4 -#define BASE256_ENCODATION 5 - -class CBC_HighLevelEncoder : public CBC_SymbolShapeHint { - public: - CBC_HighLevelEncoder(); - virtual ~CBC_HighLevelEncoder(); - CFX_ByteArray& getBytesForMessage(CFX_WideString msg); - static CFX_WideString encodeHighLevel(CFX_WideString msg, - CFX_WideString ecLevel, - int32_t& e); - static CFX_WideString encodeHighLevel(CFX_WideString msg, - CFX_WideString ecLevel, - SymbolShapeHint shape, - CBC_Dimension* minSize, - CBC_Dimension* maxSize, - int32_t& e); - static int32_t lookAheadTest(CFX_WideString msg, - int32_t startpos, - int32_t currentMode); - static FX_BOOL isDigit(FX_WCHAR ch); - static FX_BOOL isExtendedASCII(FX_WCHAR ch); - static int32_t determineConsecutiveDigitCount(CFX_WideString msg, - int32_t startpos); - static void illegalCharacter(FX_WCHAR c, int32_t& e); - - public: - static FX_WCHAR LATCH_TO_C40; - static FX_WCHAR LATCH_TO_BASE256; - static FX_WCHAR UPPER_SHIFT; - static FX_WCHAR LATCH_TO_ANSIX12; - static FX_WCHAR LATCH_TO_TEXT; - static FX_WCHAR LATCH_TO_EDIFACT; - static FX_WCHAR C40_UNLATCH; - static FX_WCHAR X12_UNLATCH; - - private: - static FX_WCHAR PAD; - static FX_WCHAR MACRO_05; - static FX_WCHAR MACRO_06; - static const wchar_t* MACRO_05_HEADER; - static const wchar_t* MACRO_06_HEADER; - static const wchar_t MACRO_TRAILER; - CFX_ByteArray m_bytearray; - - private: - static FX_WCHAR randomize253State(FX_WCHAR ch, int32_t codewordPosition); - static int32_t findMinimums(CFX_FloatArray& charCounts, - CFX_Int32Array& intCharCounts, - int32_t min, - CFX_ByteArray& mins); - static int32_t getMinimumCount(CFX_ByteArray& mins); - static FX_BOOL isNativeC40(FX_WCHAR ch); - static FX_BOOL isNativeText(FX_WCHAR ch); - static FX_BOOL isNativeX12(FX_WCHAR ch); - static FX_BOOL isX12TermSep(FX_WCHAR ch); - static FX_BOOL isNativeEDIFACT(FX_WCHAR ch); - static FX_BOOL isSpecialB256(FX_WCHAR ch); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.cpp deleted file mode 100644 index 7909054533..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.cpp +++ /dev/null @@ -1,255 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -#define SYMBOLS_COUNT 30 - -CBC_SymbolInfo* CBC_SymbolInfo::m_PROD_SYMBOLS[30] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -CBC_SymbolInfo* CBC_SymbolInfo::m_symbols[30] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -void CBC_SymbolInfo::Initialize() { - m_PROD_SYMBOLS[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1); - m_PROD_SYMBOLS[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1); - m_PROD_SYMBOLS[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1); - m_PROD_SYMBOLS[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1); - m_PROD_SYMBOLS[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2); - m_PROD_SYMBOLS[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1); - m_PROD_SYMBOLS[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1); - m_PROD_SYMBOLS[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1); - m_PROD_SYMBOLS[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1); - m_PROD_SYMBOLS[9] = new CBC_SymbolInfo(TRUE, 22, 18, 16, 10, 2); - m_PROD_SYMBOLS[10] = new CBC_SymbolInfo(FALSE, 30, 20, 20, 20, 1); - m_PROD_SYMBOLS[11] = new CBC_SymbolInfo(TRUE, 32, 24, 16, 14, 2); - m_PROD_SYMBOLS[12] = new CBC_SymbolInfo(FALSE, 36, 24, 22, 22, 1); - m_PROD_SYMBOLS[13] = new CBC_SymbolInfo(FALSE, 44, 28, 24, 24, 1); - m_PROD_SYMBOLS[14] = new CBC_SymbolInfo(TRUE, 49, 28, 22, 14, 2); - m_PROD_SYMBOLS[15] = new CBC_SymbolInfo(FALSE, 62, 36, 14, 14, 4); - m_PROD_SYMBOLS[16] = new CBC_SymbolInfo(FALSE, 86, 42, 16, 16, 4); - m_PROD_SYMBOLS[17] = new CBC_SymbolInfo(FALSE, 114, 48, 18, 18, 4); - m_PROD_SYMBOLS[18] = new CBC_SymbolInfo(FALSE, 144, 56, 20, 20, 4); - m_PROD_SYMBOLS[19] = new CBC_SymbolInfo(FALSE, 174, 68, 22, 22, 4); - m_PROD_SYMBOLS[20] = new CBC_SymbolInfo(FALSE, 204, 84, 24, 24, 4, 102, 42); - m_PROD_SYMBOLS[21] = new CBC_SymbolInfo(FALSE, 280, 112, 14, 14, 16, 140, 56); - m_PROD_SYMBOLS[22] = new CBC_SymbolInfo(FALSE, 368, 144, 16, 16, 16, 92, 36); - m_PROD_SYMBOLS[23] = new CBC_SymbolInfo(FALSE, 456, 192, 18, 18, 16, 114, 48); - m_PROD_SYMBOLS[24] = new CBC_SymbolInfo(FALSE, 576, 224, 20, 20, 16, 144, 56); - m_PROD_SYMBOLS[25] = new CBC_SymbolInfo(FALSE, 696, 272, 22, 22, 16, 174, 68); - m_PROD_SYMBOLS[26] = new CBC_SymbolInfo(FALSE, 816, 336, 24, 24, 16, 136, 56); - m_PROD_SYMBOLS[27] = - new CBC_SymbolInfo(FALSE, 1050, 408, 18, 18, 36, 175, 68); - m_PROD_SYMBOLS[28] = - new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62); - m_PROD_SYMBOLS[29] = new CBC_DataMatrixSymbolInfo144(); - for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { - m_symbols[i] = m_PROD_SYMBOLS[i]; - } -} -void CBC_SymbolInfo::Finalize() { - for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { - delete m_PROD_SYMBOLS[i]; - m_PROD_SYMBOLS[i] = NULL; - m_symbols[i] = NULL; - } -} -CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, - int32_t dataCapacity, - int32_t errorCodewords, - int32_t matrixWidth, - int32_t matrixHeight, - int32_t dataRegions) { - m_rectangular = rectangular; - m_dataCapacity = dataCapacity; - m_errorCodewords = errorCodewords; - m_matrixWidth = matrixWidth; - m_matrixHeight = matrixHeight; - m_dataRegions = dataRegions; - m_rsBlockData = dataCapacity; - m_rsBlockError = errorCodewords; -} -CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, - int32_t dataCapacity, - int32_t errorCodewords, - int32_t matrixWidth, - int32_t matrixHeight, - int32_t dataRegions, - int32_t rsBlockData, - int32_t rsBlockError) { - m_rectangular = rectangular; - m_dataCapacity = dataCapacity; - m_errorCodewords = errorCodewords; - m_matrixWidth = matrixWidth; - m_matrixHeight = matrixHeight; - m_dataRegions = dataRegions; - m_rsBlockData = rsBlockData; - m_rsBlockError = rsBlockError; -} -CBC_SymbolInfo::~CBC_SymbolInfo() {} - -CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, int32_t& e) { - return lookup(dataCodewords, FORCE_NONE, TRUE, e); -} -CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, - SymbolShapeHint shape, - int32_t& e) { - return lookup(dataCodewords, shape, TRUE, e); -} -CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, - FX_BOOL allowRectangular, - FX_BOOL fail, - int32_t& e) { - SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; - return lookup(dataCodewords, shape, fail, e); -} -CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, - SymbolShapeHint shape, - FX_BOOL fail, - int32_t& e) { - return lookup(dataCodewords, shape, NULL, NULL, fail, e); -} -CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, - SymbolShapeHint shape, - CBC_Dimension* minSize, - CBC_Dimension* maxSize, - FX_BOOL fail, - int32_t& e) { - for (int32_t i = 0; i < SYMBOLS_COUNT; i++) { - CBC_SymbolInfo* symbol = m_symbols[i]; - if (shape == FORCE_SQUARE && symbol->m_rectangular) { - continue; - } - if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { - continue; - } - if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || - symbol->getSymbolHeight(e) < minSize->getHeight())) { - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - continue; - } - if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() || - symbol->getSymbolHeight(e) > maxSize->getHeight())) { - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - continue; - } - if (dataCodewords <= symbol->m_dataCapacity) { - return symbol; - } - } - if (fail) { - e = BCExceptionIllegalDataCodewords; - return NULL; - } - return NULL; -} -int32_t CBC_SymbolInfo::getHorizontalDataRegions(int32_t& e) { - switch (m_dataRegions) { - case 1: - return 1; - case 2: - return 2; - case 4: - return 2; - case 16: - return 4; - case 36: - return 6; - default: - e = BCExceptionCannotHandleThisNumberOfDataRegions; - return 0; - } -} -int32_t CBC_SymbolInfo::getVerticalDataRegions(int32_t& e) { - switch (m_dataRegions) { - case 1: - return 1; - case 2: - return 1; - case 4: - return 2; - case 16: - return 4; - case 36: - return 6; - default: - e = BCExceptionCannotHandleThisNumberOfDataRegions; - return 0; - } -} -int32_t CBC_SymbolInfo::getSymbolDataWidth(int32_t& e) { - return getHorizontalDataRegions(e) * m_matrixWidth; -} -int32_t CBC_SymbolInfo::getSymbolDataHeight(int32_t& e) { - return getVerticalDataRegions(e) * m_matrixHeight; -} -int32_t CBC_SymbolInfo::getSymbolWidth(int32_t& e) { - return getSymbolDataWidth(e) + (getHorizontalDataRegions(e) * 2); -} -int32_t CBC_SymbolInfo::getSymbolHeight(int32_t& e) { - return getSymbolDataHeight(e) + (getVerticalDataRegions(e) * 2); -} -int32_t CBC_SymbolInfo::getCodewordCount() { - return m_dataCapacity + m_errorCodewords; -} -int32_t CBC_SymbolInfo::getInterleavedBlockCount() { - return m_dataCapacity / m_rsBlockData; -} -int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { - return m_rsBlockData; -} -int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { - return m_rsBlockError; -} -CFX_WideString CBC_SymbolInfo::toString(int32_t& e) { - CFX_WideString sb; - sb += (FX_WCHAR*)(m_rectangular ? "Rectangular Symbol:" : "Square Symbol:"); - sb += (FX_WCHAR*)" data region "; - sb += m_matrixWidth; - sb += (FX_WCHAR)'x'; - sb += m_matrixHeight; - sb += (FX_WCHAR*)", symbol size "; - sb += getSymbolWidth(e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - sb += (FX_WCHAR)'x'; - sb += getSymbolHeight(e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - sb += (FX_WCHAR*)", symbol data size "; - sb += getSymbolDataWidth(e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - sb += (FX_WCHAR)'x'; - sb += getSymbolDataHeight(e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); - sb += (FX_WCHAR*)", codewords "; - sb += m_dataCapacity; - sb += (FX_WCHAR)'+'; - sb += m_errorCodewords; - return sb; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h b/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h deleted file mode 100644 index acbc038ef3..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h +++ /dev/null @@ -1,83 +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_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxcrt/fx_system.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -class CBC_Dimension; - -class CBC_SymbolInfo : public CBC_SymbolShapeHint { - public: - CBC_SymbolInfo(FX_BOOL rectangular, - int32_t dataCapacity, - int32_t errorCodewords, - int32_t matrixWidth, - int32_t matrixHeight, - int32_t dataRegions); - virtual ~CBC_SymbolInfo(); - static void Initialize(); - static void Finalize(); - static void overrideSymbolSet(CBC_SymbolInfo* override); - static CBC_SymbolInfo* lookup(int32_t dataCodewords, int32_t& e); - static CBC_SymbolInfo* lookup(int32_t dataCodewords, - SymbolShapeHint shape, - int32_t& e); - static CBC_SymbolInfo* lookup(int32_t dataCodewords, - FX_BOOL allowRectangular, - FX_BOOL fail, - int32_t& e); - static CBC_SymbolInfo* lookup(int32_t dataCodewords, - SymbolShapeHint shape, - FX_BOOL fail, - int32_t& e); - static CBC_SymbolInfo* lookup(int32_t dataCodewords, - SymbolShapeHint shape, - CBC_Dimension* minSize, - CBC_Dimension* maxSize, - FX_BOOL fail, - int32_t& e); - int32_t getHorizontalDataRegions(int32_t& e); - int32_t getVerticalDataRegions(int32_t& e); - int32_t getSymbolDataWidth(int32_t& e); - int32_t getSymbolDataHeight(int32_t& e); - int32_t getSymbolWidth(int32_t& e); - int32_t getSymbolHeight(int32_t& e); - int32_t getCodewordCount(); - int32_t getInterleavedBlockCount(); - int32_t getDataLengthForInterleavedBlock(int32_t index); - int32_t getErrorLengthForInterleavedBlock(int32_t index); - CFX_WideString toString(int32_t& e); - - public: - int32_t m_dataCapacity; - int32_t m_errorCodewords; - int32_t m_matrixWidth; - int32_t m_matrixHeight; - int32_t m_rsBlockData; - int32_t m_rsBlockError; - static CBC_SymbolInfo* m_PROD_SYMBOLS[30]; - - private: - static CBC_SymbolInfo* m_symbols[30]; - FX_BOOL m_rectangular; - int32_t m_dataRegions; - - private: - CBC_SymbolInfo(FX_BOOL rectangular, - int32_t dataCapacity, - int32_t errorCodewords, - int32_t matrixWidth, - int32_t matrixHeight, - int32_t dataRegions, - int32_t rsBlockData, - int32_t rsBlockError); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp b/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp deleted file mode 100644 index 52c9960257..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.cpp +++ /dev/null @@ -1,26 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" - -CBC_SymbolShapeHint::CBC_SymbolShapeHint() {} -CBC_SymbolShapeHint::~CBC_SymbolShapeHint() {} diff --git a/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h b/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h deleted file mode 100644 index ea8acdfb0f..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h +++ /dev/null @@ -1,21 +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_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ - -class CBC_SymbolShapeHint { - public: - CBC_SymbolShapeHint(); - virtual ~CBC_SymbolShapeHint(); - enum SymbolShapeHint { - FORCE_NONE, - FORCE_SQUARE, - FORCE_RECTANGLE, - }; -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_SYMBOLSHAPEHINT_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.cpp deleted file mode 100644 index ec340f30e7..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.cpp +++ /dev/null @@ -1,98 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" -#include "xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h" - -CBC_TextEncoder::CBC_TextEncoder() {} -CBC_TextEncoder::~CBC_TextEncoder() {} -int32_t CBC_TextEncoder::getEncodingMode() { - return TEXT_ENCODATION; -} -int32_t CBC_TextEncoder::encodeChar(FX_WCHAR c, - CFX_WideString& sb, - int32_t& e) { - if (c == ' ') { - sb += (FX_WCHAR)'\3'; - return 1; - } - if (c >= '0' && c <= '9') { - sb += (FX_WCHAR)(c - 48 + 4); - return 1; - } - if (c >= 'a' && c <= 'z') { - sb += (FX_WCHAR)(c - 97 + 14); - return 1; - } - if (c <= 0x1f) { - sb += (FX_WCHAR)'\0'; - sb += c; - return 2; - } - if (c >= '!' && c <= '/') { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 33); - return 2; - } - if (c >= ':' && c <= '@') { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 58 + 15); - return 2; - } - if (c >= '[' && c <= '_') { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)(c - 91 + 22); - return 2; - } - if (c == 0x0060) { - sb += (FX_WCHAR)'\2'; - sb += (FX_WCHAR)(c - 96); - return 2; - } - if (c >= 'A' && c <= 'Z') { - sb += (FX_WCHAR)'\2'; - sb += (FX_WCHAR)(c - 65 + 1); - return 2; - } - if (c >= '{' && c <= 0x007f) { - sb += (FX_WCHAR)'\2'; - sb += (FX_WCHAR)(c - 123 + 27); - return 2; - } - if (c >= 0x0080) { - sb += (FX_WCHAR)'\1'; - sb += (FX_WCHAR)0x001e; - int32_t len = 2; - len += encodeChar((FX_WCHAR)(c - 128), sb, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - return len; - } - CBC_HighLevelEncoder::illegalCharacter(c, e); - return -1; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h b/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h deleted file mode 100644 index 399b21bb90..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_TextEncoder.h +++ /dev/null @@ -1,19 +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_SRC_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ - -class CBC_TextEncoder; -class CBC_TextEncoder : public CBC_C40Encoder { - public: - CBC_TextEncoder(); - virtual ~CBC_TextEncoder(); - int32_t getEncodingMode(); - int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_TEXTENCODER_H_ diff --git a/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.cpp deleted file mode 100644 index 759279d526..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.cpp +++ /dev/null @@ -1,100 +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 -// Original code is licensed as follows: -/* - * Copyright 2006-2007 Jeremias Maerki. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Dimension.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/datamatrix/BC_C40Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_Encoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_EncoderContext.h" -#include "xfa/src/fxbarcode/datamatrix/BC_HighLevelEncoder.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolInfo.h" -#include "xfa/src/fxbarcode/datamatrix/BC_SymbolShapeHint.h" -#include "xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h" - -CBC_X12Encoder::CBC_X12Encoder() {} -CBC_X12Encoder::~CBC_X12Encoder() {} -int32_t CBC_X12Encoder::getEncodingMode() { - return X12_ENCODATION; -} -void CBC_X12Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { - CFX_WideString buffer; - while (context.hasMoreCharacters()) { - FX_WCHAR c = context.getCurrentChar(); - context.m_pos++; - encodeChar(c, buffer, e); - if (e != BCExceptionNO) { - return; - } - int32_t count = buffer.GetLength(); - if ((count % 3) == 0) { - writeNextTriplet(context, buffer); - int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( - context.m_msg, context.m_pos, getEncodingMode()); - if (newMode != getEncodingMode()) { - context.signalEncoderChange(newMode); - break; - } - } - } - handleEOD(context, buffer, e); -} -void CBC_X12Encoder::handleEOD(CBC_EncoderContext& context, - CFX_WideString& buffer, - int32_t& e) { - context.updateSymbolInfo(e); - if (e != BCExceptionNO) { - return; - } - int32_t available = - context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); - int32_t count = buffer.GetLength(); - if (count == 2) { - context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); - context.m_pos -= 2; - context.signalEncoderChange(ASCII_ENCODATION); - } else if (count == 1) { - context.m_pos--; - if (available > 1) { - context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); - } - context.signalEncoderChange(ASCII_ENCODATION); - } -} -int32_t CBC_X12Encoder::encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e) { - if (c == '\r') { - sb += (FX_WCHAR)'\0'; - } else if (c == '*') { - sb += (FX_WCHAR)'\1'; - } else if (c == '>') { - sb += (FX_WCHAR)'\2'; - } else if (c == ' ') { - sb += (FX_WCHAR)'\3'; - } else if (c >= '0' && c <= '9') { - sb += (FX_WCHAR)(c - 48 + 4); - } else if (c >= 'A' && c <= 'Z') { - sb += (FX_WCHAR)(c - 65 + 14); - } else { - CBC_HighLevelEncoder::illegalCharacter(c, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - } - return 1; -} diff --git a/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h b/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.h deleted file mode 100644 index 62b35feb66..0000000000 --- a/xfa/src/fxbarcode/datamatrix/BC_X12Encoder.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_SRC_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ -#define XFA_SRC_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ - -class CBC_C40Encoder; -class CBC_X12Encoder; -class CBC_X12Encoder : public CBC_C40Encoder { - public: - CBC_X12Encoder(); - virtual ~CBC_X12Encoder(); - int32_t getEncodingMode(); - void Encode(CBC_EncoderContext& context, int32_t& e); - void handleEOD(CBC_EncoderContext& context, - CFX_WideString& buffer, - int32_t& e); - int32_t encodeChar(FX_WCHAR c, CFX_WideString& sb, int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_DATAMATRIX_BC_X12ENCODER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDReader.cpp deleted file mode 100644 index 9ecb20e671..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> -#include <memory> - -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_OneDReader::CBC_OneDReader() {} -CBC_OneDReader::~CBC_OneDReader() {} -CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { - CFX_ByteString strtemp = Decode(image, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return strtemp; -} -CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - CFX_ByteString strtemp = DeDecode(image, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return strtemp; -} -CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - int32_t height = image->GetHeight(); - int32_t middle = height >> 1; - FX_BOOL tryHarder = FALSE; - int32_t rowStep = std::max(1, height >> (tryHarder ? 8 : 5)); - int32_t maxLines; - if (tryHarder) { - maxLines = height; - } else { - maxLines = 15; - } - for (int32_t x = 0; x < maxLines; x++) { - int32_t rowStepsAboveOrBelow = (x + 1) >> 1; - const bool isAbove = (x & 0x01) == 0; - int32_t rowNumber = - middle + - rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow); - if (rowNumber < 0 || rowNumber >= height) { - break; - } - std::unique_ptr<CBC_CommonBitArray> row( - image->GetBlackRow(rowNumber, nullptr, e)); - if (e != BCExceptionNO) { - e = BCExceptionNO; - continue; - } - for (int32_t attempt = 0; attempt < 2; attempt++) { - if (attempt == 1) { - row->Reverse(); - } - CFX_ByteString result = DecodeRow(rowNumber, row.get(), hints, e); - if (e != BCExceptionNO) { - e = BCExceptionNO; - continue; - } - return result; - } - } - e = BCExceptionNotFound; - return ""; -} -void CBC_OneDReader::RecordPattern(CBC_CommonBitArray* row, - int32_t start, - CFX_Int32Array* counters, - int32_t& e) { - int32_t numCounters = counters->GetSize(); - for (int32_t i = 0; i < numCounters; i++) { - (*counters)[i] = 0; - } - int32_t end = row->GetSize(); - if (start >= end) { - e = BCExceptionNotFound; - return; - } - FX_BOOL isWhite = !row->Get(start); - int32_t counterPosition = 0; - int32_t j = start; - while (j < end) { - FX_BOOL pixel = row->Get(j); - if (pixel ^ isWhite) { - (*counters)[counterPosition]++; - } else { - counterPosition++; - if (counterPosition == numCounters) { - break; - } else { - (*counters)[counterPosition] = 1; - isWhite = !isWhite; - } - } - j++; - } - if (!(counterPosition == numCounters || - (counterPosition == numCounters - 1 && j == end))) { - e = BCExceptionNotFound; - return; - } -} -void CBC_OneDReader::RecordPatternInReverse(CBC_CommonBitArray* row, - int32_t start, - CFX_Int32Array* counters, - int32_t& e) { - int32_t numTransitionsLeft = counters->GetSize(); - FX_BOOL last = row->Get(start); - while (start > 0 && numTransitionsLeft >= 0) { - if (row->Get(--start) != last) { - numTransitionsLeft--; - last = !last; - } - } - if (numTransitionsLeft >= 0) { - e = BCExceptionNotFound; - return; - } - RecordPattern(row, start + 1, counters, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -int32_t CBC_OneDReader::PatternMatchVariance(CFX_Int32Array* counters, - const int32_t* pattern, - int32_t maxIndividualVariance) { - int32_t numCounters = counters->GetSize(); - int32_t total = 0; - int32_t patternLength = 0; - for (int32_t i = 0; i < numCounters; i++) { - total += (*counters)[i]; - patternLength += pattern[i]; - } - if (total < patternLength) { -#undef max - return FXSYS_IntMax; - } - int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength; - maxIndividualVariance = - (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT; - int32_t totalVariance = 0; - for (int32_t x = 0; x < numCounters; x++) { - int32_t counter = (*counters)[x] << INTEGER_MATH_SHIFT; - int32_t scaledPattern = pattern[x] * unitBarWidth; - int32_t variance = counter > scaledPattern ? counter - scaledPattern - : scaledPattern - counter; - if (variance > maxIndividualVariance) { -#undef max - return FXSYS_IntMax; - } - totalVariance += variance; - } - return totalVariance / total; -} diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.h b/xfa/src/fxbarcode/oned/BC_OneDReader.h deleted file mode 100644 index bcd7cbc8b5..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ - -#include "xfa/src/fxbarcode/BC_Reader.h" - -class CBC_BinaryBitmap; -class CBC_CommonBitArray; - -class CBC_OneDReader : public CBC_Reader { - public: - CBC_OneDReader(); - virtual ~CBC_OneDReader(); - virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); - virtual CFX_ByteString Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e); - virtual CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - return ""; - } - - private: - CFX_ByteString DeDecode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); - - protected: - static const int32_t INTEGER_MATH_SHIFT = 8; - static const int32_t PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << 8; - - void RecordPattern(CBC_CommonBitArray* row, - int32_t start, - CFX_Int32Array* counters, - int32_t& e); - void RecordPatternInReverse(CBC_CommonBitArray* row, - int32_t start, - CFX_Int32Array* counters, - int32_t& e); - int32_t PatternMatchVariance(CFX_Int32Array* counters, - const int32_t* pattern, - int32_t maxIndividualVariance); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp deleted file mode 100644 index 07b8657189..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp +++ /dev/null @@ -1,219 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" - -#include <memory> - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_OneDimReader::START_END_PATTERN[3] = {1, 1, 1}; -const int32_t CBC_OneDimReader::MIDDLE_PATTERN[5] = {1, 1, 1, 1, 1}; -const int32_t CBC_OneDimReader::L_PATTERNS[10][4] = { - {3, 2, 1, 1}, {2, 2, 2, 1}, {2, 1, 2, 2}, {1, 4, 1, 1}, {1, 1, 3, 2}, - {1, 2, 3, 1}, {1, 1, 1, 4}, {1, 3, 1, 2}, {1, 2, 1, 3}, {3, 1, 1, 2}}; -const int32_t CBC_OneDimReader::L_AND_G_PATTERNS[20][4] = { - {3, 2, 1, 1}, {2, 2, 2, 1}, {2, 1, 2, 2}, {1, 4, 1, 1}, {1, 1, 3, 2}, - {1, 2, 3, 1}, {1, 1, 1, 4}, {1, 3, 1, 2}, {1, 2, 1, 3}, {3, 1, 1, 2}, - {1, 1, 2, 3}, {1, 2, 2, 2}, {2, 2, 1, 2}, {1, 1, 4, 1}, {2, 3, 1, 1}, - {1, 3, 2, 1}, {4, 1, 1, 1}, {2, 1, 3, 1}, {3, 1, 2, 1}, {2, 1, 1, 3}}; - -CBC_OneDimReader::CBC_OneDimReader() {} -CBC_OneDimReader::~CBC_OneDimReader() {} -CFX_Int32Array* CBC_OneDimReader::FindStartGuardPattern(CBC_CommonBitArray* row, - int32_t& e) { - FX_BOOL foundStart = FALSE; - CFX_Int32Array* startRange = NULL; - CFX_Int32Array startEndPattern; - startEndPattern.SetSize(3); - startEndPattern[0] = START_END_PATTERN[0]; - startEndPattern[1] = START_END_PATTERN[1]; - startEndPattern[2] = START_END_PATTERN[2]; - int32_t nextStart = 0; - while (!foundStart) { - delete startRange; - startRange = FindGuardPattern(row, nextStart, FALSE, &startEndPattern, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t start = (*startRange)[0]; - nextStart = (*startRange)[1]; - if (start <= 1) { - break; - } - int32_t quietStart = start - (nextStart - start); - if (quietStart >= 0) { - FX_BOOL booT = row->IsRange(quietStart, start, FALSE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - foundStart = booT; - } - } - return startRange; -} -CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - std::unique_ptr<CFX_Int32Array> result(FindStartGuardPattern(row, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CFX_ByteString temp = DecodeRow(rowNumber, row, result.get(), hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return temp; -} -CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - CFX_Int32Array* startGuardRange, - int32_t hints, - int32_t& e) { - CFX_ByteString result; - DecodeMiddle(row, startGuardRange, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - FX_BOOL b = CheckChecksum(result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - if (!b) { - e = BCExceptionChecksumException; - return ""; - } - return result; -} -FX_BOOL CBC_OneDimReader::CheckChecksum(CFX_ByteString& s, int32_t& e) { - FX_BOOL temp = CheckStandardUPCEANChecksum(s, e); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - return temp; -} -FX_BOOL CBC_OneDimReader::CheckStandardUPCEANChecksum(CFX_ByteString& s, - int32_t& e) { - int32_t length = s.GetLength(); - if (length == 0) { - return FALSE; - } - int32_t sum = 0; - for (int32_t i = length - 2; i >= 0; i -= 2) { - int32_t digit = (int32_t)s[i] - (int32_t)'0'; - if (digit < 0 || digit > 9) { - e = BCExceptionFormatException; - return FALSE; - } - sum += digit; - } - sum *= 3; - for (int32_t j = length - 1; j >= 0; j -= 2) { - int32_t digit = (int32_t)s[j] - (int32_t)'0'; - if (digit < 0 || digit > 9) { - e = BCExceptionFormatException; - return FALSE; - } - sum += digit; - } - return sum % 10 == 0; -} -CFX_Int32Array* CBC_OneDimReader::DecodeEnd(CBC_CommonBitArray* row, - int32_t endStart, - int32_t& e) { - CFX_Int32Array startEndPattern; - startEndPattern.Add(START_END_PATTERN[0]); - startEndPattern.Add(START_END_PATTERN[1]); - startEndPattern.Add(START_END_PATTERN[2]); - CFX_Int32Array* FindGuard = - FindGuardPattern(row, endStart, FALSE, &startEndPattern, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return FindGuard; -} -CFX_Int32Array* CBC_OneDimReader::FindGuardPattern(CBC_CommonBitArray* row, - int32_t rowOffset, - FX_BOOL whiteFirst, - CFX_Int32Array* pattern, - int32_t& e) { - int32_t patternLength = pattern->GetSize(); - CFX_Int32Array counters; - counters.SetSize(patternLength); - int32_t width = row->GetSize(); - FX_BOOL isWhite = FALSE; - while (rowOffset < width) { - isWhite = !row->Get(rowOffset); - if (whiteFirst == isWhite) { - break; - } - rowOffset++; - } - int32_t counterPosition = 0; - int32_t patternStart = rowOffset; - for (int32_t x = rowOffset; x < width; x++) { - FX_BOOL pixel = row->Get(x); - if (pixel ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (PatternMatchVariance(&counters, &(*pattern)[0], - MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { - CFX_Int32Array* result = new CFX_Int32Array(); - result->SetSize(2); - (*result)[0] = patternStart; - (*result)[1] = x; - return result; - } - patternStart += counters[0] + counters[1]; - for (int32_t y = 2; y < patternLength; y++) { - counters[y - 2] = counters[y]; - } - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return NULL; -} -int32_t CBC_OneDimReader::DecodeDigit(CBC_CommonBitArray* row, - CFX_Int32Array* counters, - int32_t rowOffset, - const int32_t* patterns, - int32_t patternLength, - int32_t& e) { - RecordPattern(row, rowOffset, counters, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - int32_t bestVariance = MAX_AVG_VARIANCE; - int32_t bestMatch = -1; - int32_t max = patternLength; - for (int32_t i = 0; i < max; i++) { - int32_t variance = PatternMatchVariance(counters, &patterns[i * 4], - MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = i; - } - } - if (bestMatch >= 0) { - return bestMatch; - } else { - e = BCExceptionNotFound; - return 0; - } - return 0; -} diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.h b/xfa/src/fxbarcode/oned/BC_OneDimReader.h deleted file mode 100644 index 9e5789afb9..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.h +++ /dev/null @@ -1,66 +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_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" - -class CBC_CommonBitArray; - -class CBC_OneDimReader : public CBC_OneDReader { - private: - static const int32_t MAX_AVG_VARIANCE = (int32_t)(256 * 0.48f); - static const int32_t MAX_INDIVIDUAL_VARIANCE = (int32_t)(256 * 0.7f); - - FX_BOOL CheckStandardUPCEANChecksum(CFX_ByteString& s, int32_t& e); - - public: - static const int32_t START_END_PATTERN[3]; - static const int32_t MIDDLE_PATTERN[5]; - static const int32_t L_PATTERNS[10][4]; - static const int32_t L_AND_G_PATTERNS[20][4]; - - CBC_OneDimReader(); - virtual ~CBC_OneDimReader(); - - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e); - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - CFX_Int32Array* startGuardRange, - int32_t hints, - int32_t& e); - - protected: - CFX_Int32Array* FindStartGuardPattern(CBC_CommonBitArray* row, int32_t& e); - virtual FX_BOOL CheckChecksum(CFX_ByteString& s, int32_t& e); - CFX_Int32Array* FindGuardPattern(CBC_CommonBitArray* row, - int32_t rowOffset, - FX_BOOL whiteFirst, - CFX_Int32Array* pattern, - int32_t& e); - int32_t DecodeDigit(CBC_CommonBitArray* row, - CFX_Int32Array* counters, - int32_t rowOffset, - const int32_t* patterns, - int32_t patternLength, - int32_t& e); - virtual int32_t DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultResult, - int32_t& e) { - return 0; - } - virtual CFX_Int32Array* DecodeEnd(CBC_CommonBitArray* row, - int32_t endStart, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp deleted file mode 100644 index 121b72cb05..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp +++ /dev/null @@ -1,437 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" - -#include <algorithm> -#include <memory> - -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" - -CBC_OneDimWriter::CBC_OneDimWriter() { - m_locTextLoc = BC_TEXT_LOC_BELOWEMBED; - m_bPrintChecksum = TRUE; - m_iDataLenth = 0; - m_bCalcChecksum = FALSE; - m_pFont = NULL; - m_fFontSize = 10; - m_iFontStyle = 0; - m_fontColor = 0xff000000; - m_iContentLen = 0; - m_bLeftPadding = FALSE; - m_bRightPadding = FALSE; - m_output = NULL; -} -CBC_OneDimWriter::~CBC_OneDimWriter() { - delete m_output; -} -void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) { - m_bPrintChecksum = checksum; -} -void CBC_OneDimWriter::SetDataLength(int32_t length) { - m_iDataLenth = length; -} -void CBC_OneDimWriter::SetCalcChecksum(int32_t state) { - m_bCalcChecksum = state; -} -FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) { - if (cFont == NULL) { - return FALSE; - } - m_pFont = cFont; - return TRUE; -} -void CBC_OneDimWriter::SetFontSize(FX_FLOAT size) { - m_fFontSize = size; -} -void CBC_OneDimWriter::SetFontStyle(int32_t style) { - m_iFontStyle = style; -} -void CBC_OneDimWriter::SetFontColor(FX_ARGB color) { - m_fontColor = color; -} -FX_WCHAR CBC_OneDimWriter::Upper(FX_WCHAR ch) { - if (ch >= 'a' && ch <= 'z') { - ch = ch - ('a' - 'A'); - } - return ch; -} -uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - uint8_t* ret = NULL; - outHeight = 1; - if (m_Width >= 20) { - ret = Encode(contents, outWidth, e); - } else { - ret = Encode(contents, outWidth, e); - } - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -int32_t CBC_OneDimWriter::AppendPattern(uint8_t* target, - int32_t pos, - const int32_t* pattern, - int32_t patternLength, - int32_t startColor, - int32_t& e) { - if (startColor != 0 && startColor != 1) { - e = BCExceptionValueMustBeEither0or1; - return 0; - } - uint8_t color = (uint8_t)startColor; - int32_t numAdded = 0; - for (int32_t i = 0; i < patternLength; i++) { - for (int32_t j = 0; j < pattern[i]; j++) { - target[pos] = color; - pos += 1; - numAdded += 1; - } - color ^= 1; - } - return numAdded; -} -void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, - FXTEXT_CHARPOS* charPos, - CFX_Font* cFont, - FX_FLOAT geWidth, - int32_t fontSize, - FX_FLOAT& charsLen) { - std::unique_ptr<CFX_UnicodeEncodingEx> encoding( - FX_CreateFontEncodingEx(cFont)); - - int32_t length = text.GetLength(); - FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength()); - FX_FLOAT charWidth = 0; - for (int32_t j = 0; j < text.GetLength(); j++) { - pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); - int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); - int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); - FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0); - charWidth += temp; - } - charsLen = charWidth; - FX_FLOAT leftPositon = (FX_FLOAT)(geWidth - charsLen) / 2.0f; - if (leftPositon < 0 && geWidth == 0) { - leftPositon = 0; - } - FX_FLOAT penX = 0.0; - FX_FLOAT penY = - (FX_FLOAT)FXSYS_abs(cFont->GetDescent()) * (FX_FLOAT)fontSize / 1000.0f; - FX_FLOAT left = leftPositon; - FX_FLOAT top = 0.0; - charPos[0].m_OriginX = penX + left; - charPos[0].m_OriginY = penY + top; - charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[0]); - charPos[0].m_FontCharWidth = cFont->GetGlyphWidth(charPos[0].m_GlyphIndex); -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - charPos[0].m_ExtGID = charPos[0].m_GlyphIndex; -#endif - penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; - for (int32_t i = 1; i < length; i++) { - charPos[i].m_OriginX = penX + left; - charPos[i].m_OriginY = penY + top; - charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); - charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - charPos[i].m_ExtGID = charPos[i].m_GlyphIndex; -#endif - penX += - (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; - } - FX_Free(pCharCode); -} -void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, - const CFX_Matrix* matrix, - const CFX_ByteString str, - FX_FLOAT geWidth, - FXTEXT_CHARPOS* pCharPos, - FX_FLOAT locX, - FX_FLOAT locY, - int32_t barWidth) { - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - CFX_FloatRect rect((FX_FLOAT)locX, (FX_FLOAT)locY, (FX_FLOAT)(locX + geWidth), - (FX_FLOAT)(locY + iTextHeight)); - if (geWidth != m_Width) { - rect.right -= 1; - } - matrix->TransformRect(rect); - FX_RECT re = rect.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)locX, - (FX_FLOAT)(locY + iFontSize)); - if (matrix) { - affine_matrix.Concat(*matrix); - } - device->DrawNormalText(str.GetLength(), pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, - m_fontColor, FXTEXT_CLEARTYPE); -} -void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, - const CFX_ByteString str, - FX_FLOAT geWidth, - FXTEXT_CHARPOS* pCharPos, - FX_FLOAT locX, - FX_FLOAT locY, - int32_t barWidth) { - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - CFX_FxgeDevice ge; - ge.Create((int)geWidth, iTextHeight, m_colorSpace); - FX_RECT geRect(0, 0, (int)geWidth, iTextHeight); - ge.FillRect(&geRect, m_backgroundColor); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); - ge.DrawNormalText(str.GetLength(), pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); - CFX_FxgeDevice geBitmap; - geBitmap.Attach(pOutBitmap); - geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY); -} -void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { - e = BCExceptionIllegalArgument; - return; - } - if (m_pFont == NULL) { - e = BCExceptionNullPointer; - return; - } - CFX_ByteString str = FX_UTF8Encode(contents); - int32_t iLen = str.GetLength(); - FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); - FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); - FX_FLOAT charsLen = 0; - FX_FLOAT geWidth = 0; - if (m_locTextLoc == BC_TEXT_LOC_ABOVEEMBED || - m_locTextLoc == BC_TEXT_LOC_BELOWEMBED) { - geWidth = 0; - } else if (m_locTextLoc == BC_TEXT_LOC_ABOVE || - m_locTextLoc == BC_TEXT_LOC_BELOW) { - geWidth = (FX_FLOAT)barWidth; - } - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - CalcTextInfo(str, pCharPos, m_pFont, geWidth, iFontSize, charsLen); - if (charsLen < 1) { - return; - } - int32_t locX = 0; - int32_t locY = 0; - switch (m_locTextLoc) { - case BC_TEXT_LOC_ABOVEEMBED: - locX = (int32_t)(barWidth - charsLen) / 2; - locY = 0; - geWidth = charsLen; - break; - case BC_TEXT_LOC_ABOVE: - locX = 0; - locY = 0; - geWidth = (FX_FLOAT)barWidth; - break; - case BC_TEXT_LOC_BELOWEMBED: - locX = (int32_t)(barWidth - charsLen) / 2; - locY = m_Height - iTextHeight; - geWidth = charsLen; - break; - case BC_TEXT_LOC_BELOW: - default: - locX = 0; - locY = m_Height - iTextHeight; - geWidth = (FX_FLOAT)barWidth; - break; - } - if (device) { - ShowDeviceChars(device, matrix, str, geWidth, pCharPos, (FX_FLOAT)locX, - (FX_FLOAT)locY, barWidth); - } else { - ShowBitmapChars(pOutBitmap, str, geWidth, pCharPos, (FX_FLOAT)locX, - (FX_FLOAT)locY, barWidth); - } - FX_Free(pCharPos); -} -void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e) { - if (m_output == NULL) { - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight()); - pOutBitmap->Clear(m_backgroundColor); - if (!pOutBitmap) { - e = BCExceptionFailToCreateBitmap; - return; - } - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - if (m_output->Get(x, y)) { - pOutBitmap->SetPixel(x, y, m_barColor); - } - } - } - int32_t i = 0; - for (; i < contents.GetLength(); i++) - if (contents.GetAt(i) != ' ') { - break; - } - if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { - ShowChars(contents, pOutBitmap, NULL, NULL, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height); - if (pOutBitmap) { - delete pOutBitmap; - } - pOutBitmap = pStretchBitmap; -} -void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, - const CFX_Matrix* matrix, - const CFX_WideStringC& contents, - int32_t& e) { - if (m_output == NULL) { - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - CFX_GraphStateData stateData; - CFX_PathData path; - path.AppendRect(0, 0, (FX_FLOAT)m_Width, (FX_FLOAT)m_Height); - device->DrawPath(&path, matrix, &stateData, m_backgroundColor, - m_backgroundColor, FXFILL_ALTERNATE); - CFX_Matrix matri(m_outputHScale, 0.0, 0.0, (FX_FLOAT)m_Height, 0.0, 0.0); - matri.Concat(*matrix); - for (int32_t x = 0; x < m_output->GetWidth(); x++) { - for (int32_t y = 0; y < m_output->GetHeight(); y++) { - CFX_PathData rect; - rect.AppendRect((FX_FLOAT)x, (FX_FLOAT)y, (FX_FLOAT)(x + 1), - (FX_FLOAT)(y + 1)); - CFX_GraphStateData stateData; - if (m_output->Get(x, y)) { - device->DrawPath(&rect, &matri, &stateData, m_barColor, 0, - FXFILL_WINDING); - } - } - } - int32_t i = 0; - for (; i < contents.GetLength(); i++) - if (contents.GetAt(i) != ' ') { - break; - } - if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { - ShowChars(contents, NULL, device, matrix, m_barWidth, m_multiple, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - if (codeLength < 1) { - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (m_ModuleHeight < 20.0) { - m_ModuleHeight = 20; - } - int32_t codeOldLength = codeLength; - int32_t leftPadding = 0; - int32_t rightPadding = 0; - if (m_bLeftPadding) { - leftPadding = 7; - } - if (m_bRightPadding) { - rightPadding = 7; - } - codeLength += leftPadding; - codeLength += rightPadding; - m_outputHScale = 1.0; - if (m_Width > 0) { - m_outputHScale = (FX_FLOAT)m_Width / (FX_FLOAT)codeLength; - } - if (!isDevice) { - m_outputHScale = - std::max(m_outputHScale, static_cast<FX_FLOAT>(m_ModuleWidth)); - } - FX_FLOAT dataLengthScale = 1.0; - if (m_iDataLenth > 0 && contents.GetLength() != 0) { - dataLengthScale = FX_FLOAT(contents.GetLength()) / FX_FLOAT(m_iDataLenth); - } - if (m_iDataLenth > 0 && contents.GetLength() == 0) { - dataLengthScale = FX_FLOAT(1) / FX_FLOAT(m_iDataLenth); - } - m_multiple = 1; - if (!isDevice) { - m_multiple = (int32_t)ceil(m_outputHScale * dataLengthScale); - } - int32_t outputHeight = 1; - if (!isDevice) { - if (m_Height == 0) { - outputHeight = std::max(20, m_ModuleHeight); - } else { - outputHeight = m_Height; - } - } - int32_t outputWidth = codeLength; - if (!isDevice) { - outputWidth = (int32_t)(codeLength * m_multiple / dataLengthScale); - } - m_barWidth = m_Width; - if (!isDevice) { - m_barWidth = codeLength * m_multiple; - } - m_output = new CBC_CommonBitMatrix; - m_output->Init(outputWidth, outputHeight); - int32_t outputX = leftPadding * m_multiple; - for (int32_t inputX = 0; inputX < codeOldLength; inputX++) { - if (code[inputX] == 1) { - if (outputX >= outputWidth) { - break; - } - if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { - m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); - break; - } - m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - outputX += m_multiple; - } -} diff --git a/xfa/src/fxbarcode/oned/BC_OneDimWriter.h b/xfa/src/fxbarcode/oned/BC_OneDimWriter.h deleted file mode 100644 index f8001dc5c7..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OneDimWriter.h +++ /dev/null @@ -1,120 +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_SRC_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ - -#include "core/include/fxge/fx_ge.h" -#include "xfa/include/fxbarcode/BC_BarCode.h" -#include "xfa/src/fxbarcode/BC_Writer.h" - -class CBC_CommonBitMatrix; -class CFX_Font; -class CFX_RenderDevice; - -class CBC_OneDimWriter : public CBC_Writer { - public: - CBC_OneDimWriter(); - virtual ~CBC_OneDimWriter(); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - virtual uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e) { - return NULL; - } - virtual void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e); - virtual void RenderDeviceResult(CFX_RenderDevice* device, - const CFX_Matrix* matrix, - const CFX_WideStringC& contents, - int32_t& e); - virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents) { - return TRUE; - } - virtual CFX_WideString FilterContents(const CFX_WideStringC& contents) { - return CFX_WideString(); - } - virtual CFX_WideString RenderTextContents(const CFX_WideStringC& contents) { - return CFX_WideString(); - } - virtual void SetPrintChecksum(FX_BOOL checksum); - virtual void SetDataLength(int32_t length); - virtual void SetCalcChecksum(int32_t state); - virtual void SetFontSize(FX_FLOAT size); - virtual void SetFontStyle(int32_t style); - virtual void SetFontColor(FX_ARGB color); - virtual FX_BOOL SetFont(CFX_Font* cFont); - - protected: - FX_BOOL m_bPrintChecksum; - int32_t m_iDataLenth; - FX_BOOL m_bCalcChecksum; - CFX_Font* m_pFont; - FX_FLOAT m_fFontSize; - int32_t m_iFontStyle; - FX_DWORD m_fontColor; - BC_TEXT_LOC m_locTextLoc; - int32_t m_iContentLen; - FX_BOOL m_bLeftPadding; - FX_BOOL m_bRightPadding; - CBC_CommonBitMatrix* m_output; - int32_t m_barWidth; - int32_t m_multiple; - FX_FLOAT m_outputHScale; - void CalcTextInfo(const CFX_ByteString& text, - FXTEXT_CHARPOS* charPos, - CFX_Font* cFont, - FX_FLOAT geWidth, - int32_t fontSize, - FX_FLOAT& charsLen); - virtual void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e); - virtual void ShowBitmapChars(CFX_DIBitmap* pOutBitmap, - const CFX_ByteString str, - FX_FLOAT geWidth, - FXTEXT_CHARPOS* pCharPos, - FX_FLOAT locX, - FX_FLOAT locY, - int32_t barWidth); - virtual void ShowDeviceChars(CFX_RenderDevice* device, - const CFX_Matrix* matrix, - const CFX_ByteString str, - FX_FLOAT geWidth, - FXTEXT_CHARPOS* pCharPos, - FX_FLOAT locX, - FX_FLOAT locY, - int32_t barWidth); - int32_t AppendPattern(uint8_t* target, - int32_t pos, - const int32_t* pattern, - int32_t patternLength, - int32_t startColor, - int32_t& e); - FX_WCHAR Upper(FX_WCHAR ch); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDIMWRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp deleted file mode 100644 index 5d2d447efc..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp +++ /dev/null @@ -1,212 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" - -#include <algorithm> -#include <memory> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" -#include "xfa/src/fxbarcode/utils.h" - -const FX_CHAR* CBC_OnedCodaBarReader::ALPHABET_STRING = - "0123456789-$:/.+ABCDTN"; -const int32_t CBC_OnedCodaBarReader::CHARACTER_ENCODINGS[22] = { - 0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, - 0x030, 0x048, 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, - 0x01A, 0x029, 0x00B, 0x00E, 0x01A, 0x029}; -const FX_CHAR CBC_OnedCodaBarReader::STARTEND_ENCODING[8] = { - 'E', '*', 'A', 'B', 'C', 'D', 'T', 'N'}; - -CBC_OnedCodaBarReader::CBC_OnedCodaBarReader() {} -CBC_OnedCodaBarReader::~CBC_OnedCodaBarReader() {} -CFX_ByteString CBC_OnedCodaBarReader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - std::unique_ptr<CFX_Int32Array> start(FindAsteriskPattern(row, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - (*start)[1] = 0; - int32_t nextStart = (*start)[1]; - int32_t end = row->GetSize(); - while (nextStart < end && !row->Get(nextStart)) { - nextStart++; - } - CFX_ByteString result; - CFX_Int32Array counters; - counters.SetSize(7); - FX_CHAR decodedChar; - int32_t lastStart; - do { - RecordPattern(row, nextStart, &counters, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - decodedChar = ToNarrowWidePattern(&counters); - if (decodedChar == '!') { - e = BCExceptionNotFound; - return ""; - } - result += decodedChar; - lastStart = nextStart; - for (int32_t i = 0; i < counters.GetSize(); i++) { - nextStart += counters[i]; - } - while (nextStart < end && !row->Get(nextStart)) { - nextStart++; - } - } while (nextStart < end); - int32_t lastPatternSize = 0; - for (int32_t j = 0; j < counters.GetSize(); j++) { - lastPatternSize += counters[j]; - } - int32_t whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; - if (nextStart != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) { - e = BCExceptionNotFound; - return ""; - } - if (result.GetLength() < 2) { - e = BCExceptionNotFound; - return ""; - } - FX_CHAR startchar = result[0]; - if (!ArrayContains(STARTEND_ENCODING, startchar)) { - e = BCExceptionNotFound; - return ""; - } - int32_t len = result.GetLength(); - CFX_ByteString temp = result; - for (int32_t k = 1; k < result.GetLength(); k++) { - if (ArrayContains(STARTEND_ENCODING, result[k])) { - if ((k + 1) != result.GetLength()) { - result.Delete(1, k); - k = 1; - } - } - } - if (result.GetLength() < 5) { - int32_t index = temp.Find(result.Mid(1, result.GetLength() - 1)); - if (index == len - (result.GetLength() - 1)) { - e = BCExceptionNotFound; - return ""; - } - } - if (result.GetLength() > minCharacterLength) { - result = result.Mid(1, result.GetLength() - 2); - } else { - e = BCExceptionNotFound; - return ""; - } - return result; -} -CFX_Int32Array* CBC_OnedCodaBarReader::FindAsteriskPattern( - CBC_CommonBitArray* row, - int32_t& e) { - int32_t width = row->GetSize(); - int32_t rowOffset = 0; - while (rowOffset < width) { - if (row->Get(rowOffset)) { - break; - } - rowOffset++; - } - int32_t counterPosition = 0; - CFX_Int32Array counters; - counters.SetSize(7); - int32_t patternStart = rowOffset; - FX_BOOL isWhite = FALSE; - int32_t patternLength = counters.GetSize(); - for (int32_t i = rowOffset; i < width; i++) { - FX_BOOL pixel = row->Get(i); - if (pixel ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (ArrayContains(STARTEND_ENCODING, ToNarrowWidePattern(&counters))) { - FX_BOOL btemp3 = - row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), - patternStart, FALSE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (btemp3) { - CFX_Int32Array* result = new CFX_Int32Array(); - result->SetSize(2); - (*result)[0] = patternStart; - (*result)[1] = i; - return result; - } - } - patternStart += counters[0] + counters[1]; - for (int32_t y = 2; y < patternLength; y++) { - counters[y - 2] = counters[y]; - } - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - e = BCExceptionNotFound; - return NULL; -} -FX_BOOL CBC_OnedCodaBarReader::ArrayContains(const FX_CHAR array[], - FX_CHAR key) { - for (int32_t i = 0; i < 8; i++) { - if (array[i] == key) { - return TRUE; - } - } - return FALSE; -} -FX_CHAR CBC_OnedCodaBarReader::ToNarrowWidePattern(CFX_Int32Array* counter) { - int32_t numCounters = counter->GetSize(); - if (numCounters < 1) { - return '!'; - } - int32_t averageCounter = 0; - int32_t totalCounters = 0; - for (int32_t i = 0; i < numCounters; i++) { - totalCounters += (*counter)[i]; - } - averageCounter = totalCounters / numCounters; - int32_t pattern = 0; - int32_t wideCounters = 0; - for (int32_t j = 0; j < numCounters; j++) { - if ((*counter)[j] > averageCounter) { - pattern |= 1 << (numCounters - 1 - j); - wideCounters++; - } - } - if ((wideCounters == 2) || (wideCounters == 3)) { - for (int32_t k = 0; k < 22; k++) { - if (CHARACTER_ENCODINGS[k] == pattern) { - return (ALPHABET_STRING)[k]; - } - } - } - return '!'; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h deleted file mode 100644 index 49c136f4fd..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h +++ /dev/null @@ -1,36 +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_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" - -class CBC_CommonBitArray; -class CBC_OneDReader; - -class CBC_OnedCodaBarReader : public CBC_OneDReader { - public: - CBC_OnedCodaBarReader(); - virtual ~CBC_OnedCodaBarReader(); - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e); - CFX_Int32Array* FindAsteriskPattern(CBC_CommonBitArray* row, int32_t& e); - FX_BOOL ArrayContains(const FX_CHAR array[], FX_CHAR key); - FX_CHAR ToNarrowWidePattern(CFX_Int32Array* counter); - - static const FX_CHAR* ALPHABET_STRING; - static const int32_t CHARACTER_ENCODINGS[22]; - - private: - static const int32_t minCharacterLength = 3; - static const FX_CHAR STARTEND_ENCODING[8]; -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp deleted file mode 100644 index 5d363814af..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ /dev/null @@ -1,231 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h" - -const FX_CHAR CBC_OnedCodaBarWriter::START_END_CHARS[] = { - 'A', 'B', 'C', 'D', 'T', 'N', '*', 'E', 'a', 'b', 'c', 'd', 't', 'n', 'e'}; -const FX_CHAR CBC_OnedCodaBarWriter::CONTENT_CHARS[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', '-', '$', '/', ':', '+', '.'}; - -CBC_OnedCodaBarWriter::CBC_OnedCodaBarWriter() { - m_chStart = 'A'; - m_chEnd = 'B'; - m_iWideNarrRatio = 2; -} -CBC_OnedCodaBarWriter::~CBC_OnedCodaBarWriter() {} -FX_BOOL CBC_OnedCodaBarWriter::SetStartChar(FX_CHAR start) { - for (size_t i = 0; i < FX_ArraySize(START_END_CHARS); ++i) { - if (START_END_CHARS[i] == start) { - m_chStart = start; - return TRUE; - } - } - return FALSE; -} - -FX_BOOL CBC_OnedCodaBarWriter::SetEndChar(FX_CHAR end) { - for (size_t i = 0; i < FX_ArraySize(START_END_CHARS); ++i) { - if (START_END_CHARS[i] == end) { - m_chEnd = end; - return TRUE; - } - } - return FALSE; -} -void CBC_OnedCodaBarWriter::SetDataLength(int32_t length) { - m_iDataLenth = length + 2; -} -FX_BOOL CBC_OnedCodaBarWriter::SetTextLocation(BC_TEXT_LOC location) { - if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { - return FALSE; - } - m_locTextLoc = location; - return TRUE; -} -FX_BOOL CBC_OnedCodaBarWriter::SetWideNarrowRatio(int32_t ratio) { - if (ratio < 2 || ratio > 3) { - return FALSE; - } - m_iWideNarrRatio = ratio; - return TRUE; -} -FX_BOOL CBC_OnedCodaBarWriter::FindChar(FX_WCHAR ch, FX_BOOL isContent) { - if (isContent) { - for (size_t i = 0; i < FX_ArraySize(CONTENT_CHARS); ++i) { - if (ch == (FX_WCHAR)CONTENT_CHARS[i]) { - return TRUE; - } - } - for (size_t j = 0; j < FX_ArraySize(START_END_CHARS); ++j) { - if (ch == (FX_WCHAR)START_END_CHARS[j]) { - return TRUE; - } - } - return FALSE; - } else { - for (size_t i = 0; i < FX_ArraySize(CONTENT_CHARS); ++i) { - if (ch == (FX_WCHAR)CONTENT_CHARS[i]) { - return TRUE; - } - } - return FALSE; - } -} -FX_BOOL CBC_OnedCodaBarWriter::CheckContentValidity( - const CFX_WideStringC& contents) { - FX_WCHAR ch; - int32_t index = 0; - for (index = 0; index < contents.GetLength(); index++) { - ch = contents.GetAt(index); - if (FindChar(ch, FALSE)) { - continue; - } else { - return FALSE; - } - } - return TRUE; -} -CFX_WideString CBC_OnedCodaBarWriter::FilterContents( - const CFX_WideStringC& contents) { - CFX_WideString filtercontents; - FX_WCHAR ch; - for (int32_t index = 0; index < contents.GetLength(); index++) { - ch = contents.GetAt(index); - if (ch > 175) { - index++; - continue; - } - if (FindChar(ch, TRUE)) { - filtercontents += ch; - } else { - continue; - } - } - return filtercontents; -} -uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_CODABAR) { - e = BCExceptionOnlyEncodeCODEBAR; - return NULL; - } - uint8_t* ret = - CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedCodaBarWriter::Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e) { - CBC_OnedCodaBarReader CodaBarR; - CFX_ByteString data = m_chStart + contents + m_chEnd; - m_iContentLen = data.GetLength(); - uint8_t* result = FX_Alloc2D(uint8_t, m_iWideNarrRatio * 7, data.GetLength()); - FX_CHAR ch; - int32_t position = 0; - for (int32_t index = 0; index < data.GetLength(); index++) { - ch = data.GetAt(index); - if (((ch >= 'a') && (ch <= 'z'))) { - ch = ch - 32; - } - switch (ch) { - case 'T': - ch = 'A'; - break; - case 'N': - ch = 'B'; - break; - case '*': - ch = 'C'; - break; - case 'E': - ch = 'D'; - break; - default: - break; - } - int32_t code = 0; - int32_t len = (int32_t)strlen(CodaBarR.ALPHABET_STRING); - for (int32_t i = 0; i < len; i++) { - if (ch == CodaBarR.ALPHABET_STRING[i]) { - code = CodaBarR.CHARACTER_ENCODINGS[i]; - break; - } - } - uint8_t color = 1; - int32_t counter = 0; - int32_t bit = 0; - while (bit < 7) { - result[position] = color; - position++; - if (((code >> (6 - bit)) & 1) == 0 || counter == m_iWideNarrRatio - 1) { - color = !color; - bit++; - counter = 0; - } else { - counter++; - } - } - if (index < data.GetLength() - 1) { - result[position] = 0; - position++; - } - } - outLength = position; - return result; -} -CFX_WideString CBC_OnedCodaBarWriter::encodedContents( - const CFX_WideStringC& contents) { - CFX_WideString strStart(m_chStart); - CFX_WideString strEnd(m_chEnd); - return strStart + contents + strEnd; -} -void CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - CBC_OneDimWriter::RenderResult(encodedContents(contents), code, codeLength, - isDevice, e); -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h b/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h deleted file mode 100644 index 8f9ca5883d..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarWriter.h +++ /dev/null @@ -1,54 +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_SRC_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ - -enum BC_TEXT_LOC; -class CBC_OneDimWriter; -class CBC_OnedCodaBarWriter; -class CBC_OnedCodaBarWriter : public CBC_OneDimWriter { - public: - CBC_OnedCodaBarWriter(); - virtual ~CBC_OnedCodaBarWriter(); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - CFX_WideString encodedContents(const CFX_WideStringC& contents); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - FX_BOOL SetStartChar(FX_CHAR start); - FX_BOOL SetEndChar(FX_CHAR end); - void SetDataLength(int32_t length); - FX_BOOL SetTextLocation(BC_TEXT_LOC location); - FX_BOOL SetWideNarrowRatio(int32_t ratio); - FX_BOOL FindChar(FX_WCHAR ch, FX_BOOL isContent); - - private: - void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - static const FX_CHAR START_END_CHARS[]; - static const FX_CHAR CONTENT_CHARS[]; - FX_CHAR m_chStart; - FX_CHAR m_chEnd; - int32_t m_iWideNarrRatio; -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARWRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp deleted file mode 100644 index 41a6ad1d05..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_OnedCode128Reader::CODE_PATTERNS[107][7] = { - {2, 1, 2, 2, 2, 2, 0}, {2, 2, 2, 1, 2, 2, 0}, {2, 2, 2, 2, 2, 1, 0}, - {1, 2, 1, 2, 2, 3, 0}, {1, 2, 1, 3, 2, 2, 0}, {1, 3, 1, 2, 2, 2, 0}, - {1, 2, 2, 2, 1, 3, 0}, {1, 2, 2, 3, 1, 2, 0}, {1, 3, 2, 2, 1, 2, 0}, - {2, 2, 1, 2, 1, 3, 0}, {2, 2, 1, 3, 1, 2, 0}, {2, 3, 1, 2, 1, 2, 0}, - {1, 1, 2, 2, 3, 2, 0}, {1, 2, 2, 1, 3, 2, 0}, {1, 2, 2, 2, 3, 1, 0}, - {1, 1, 3, 2, 2, 2, 0}, {1, 2, 3, 1, 2, 2, 0}, {1, 2, 3, 2, 2, 1, 0}, - {2, 2, 3, 2, 1, 1, 0}, {2, 2, 1, 1, 3, 2, 0}, {2, 2, 1, 2, 3, 1, 0}, - {2, 1, 3, 2, 1, 2, 0}, {2, 2, 3, 1, 1, 2, 0}, {3, 1, 2, 1, 3, 1, 0}, - {3, 1, 1, 2, 2, 2, 0}, {3, 2, 1, 1, 2, 2, 0}, {3, 2, 1, 2, 2, 1, 0}, - {3, 1, 2, 2, 1, 2, 0}, {3, 2, 2, 1, 1, 2, 0}, {3, 2, 2, 2, 1, 1, 0}, - {2, 1, 2, 1, 2, 3, 0}, {2, 1, 2, 3, 2, 1, 0}, {2, 3, 2, 1, 2, 1, 0}, - {1, 1, 1, 3, 2, 3, 0}, {1, 3, 1, 1, 2, 3, 0}, {1, 3, 1, 3, 2, 1, 0}, - {1, 1, 2, 3, 1, 3, 0}, {1, 3, 2, 1, 1, 3, 0}, {1, 3, 2, 3, 1, 1, 0}, - {2, 1, 1, 3, 1, 3, 0}, {2, 3, 1, 1, 1, 3, 0}, {2, 3, 1, 3, 1, 1, 0}, - {1, 1, 2, 1, 3, 3, 0}, {1, 1, 2, 3, 3, 1, 0}, {1, 3, 2, 1, 3, 1, 0}, - {1, 1, 3, 1, 2, 3, 0}, {1, 1, 3, 3, 2, 1, 0}, {1, 3, 3, 1, 2, 1, 0}, - {3, 1, 3, 1, 2, 1, 0}, {2, 1, 1, 3, 3, 1, 0}, {2, 3, 1, 1, 3, 1, 0}, - {2, 1, 3, 1, 1, 3, 0}, {2, 1, 3, 3, 1, 1, 0}, {2, 1, 3, 1, 3, 1, 0}, - {3, 1, 1, 1, 2, 3, 0}, {3, 1, 1, 3, 2, 1, 0}, {3, 3, 1, 1, 2, 1, 0}, - {3, 1, 2, 1, 1, 3, 0}, {3, 1, 2, 3, 1, 1, 0}, {3, 3, 2, 1, 1, 1, 0}, - {3, 1, 4, 1, 1, 1, 0}, {2, 2, 1, 4, 1, 1, 0}, {4, 3, 1, 1, 1, 1, 0}, - {1, 1, 1, 2, 2, 4, 0}, {1, 1, 1, 4, 2, 2, 0}, {1, 2, 1, 1, 2, 4, 0}, - {1, 2, 1, 4, 2, 1, 0}, {1, 4, 1, 1, 2, 2, 0}, {1, 4, 1, 2, 2, 1, 0}, - {1, 1, 2, 2, 1, 4, 0}, {1, 1, 2, 4, 1, 2, 0}, {1, 2, 2, 1, 1, 4, 0}, - {1, 2, 2, 4, 1, 1, 0}, {1, 4, 2, 1, 1, 2, 0}, {1, 4, 2, 2, 1, 1, 0}, - {2, 4, 1, 2, 1, 1, 0}, {2, 2, 1, 1, 1, 4, 0}, {4, 1, 3, 1, 1, 1, 0}, - {2, 4, 1, 1, 1, 2, 0}, {1, 3, 4, 1, 1, 1, 0}, {1, 1, 1, 2, 4, 2, 0}, - {1, 2, 1, 1, 4, 2, 0}, {1, 2, 1, 2, 4, 1, 0}, {1, 1, 4, 2, 1, 2, 0}, - {1, 2, 4, 1, 1, 2, 0}, {1, 2, 4, 2, 1, 1, 0}, {4, 1, 1, 2, 1, 2, 0}, - {4, 2, 1, 1, 1, 2, 0}, {4, 2, 1, 2, 1, 1, 0}, {2, 1, 2, 1, 4, 1, 0}, - {2, 1, 4, 1, 2, 1, 0}, {4, 1, 2, 1, 2, 1, 0}, {1, 1, 1, 1, 4, 3, 0}, - {1, 1, 1, 3, 4, 1, 0}, {1, 3, 1, 1, 4, 1, 0}, {1, 1, 4, 1, 1, 3, 0}, - {1, 1, 4, 3, 1, 1, 0}, {4, 1, 1, 1, 1, 3, 0}, {4, 1, 1, 3, 1, 1, 0}, - {1, 1, 3, 1, 4, 1, 0}, {1, 1, 4, 1, 3, 1, 0}, {3, 1, 1, 1, 4, 1, 0}, - {4, 1, 1, 1, 3, 1, 0}, {2, 1, 1, 4, 1, 2, 0}, {2, 1, 1, 2, 1, 4, 0}, - {2, 1, 1, 2, 3, 2, 0}, {2, 3, 3, 1, 1, 1, 2}}; - -CBC_OnedCode128Reader::CBC_OnedCode128Reader() {} -CBC_OnedCode128Reader::~CBC_OnedCode128Reader() {} -CFX_Int32Array* CBC_OnedCode128Reader::FindStartPattern(CBC_CommonBitArray* row, - int32_t& e) { - int32_t width = row->GetSize(); - int32_t rowOffset = 0; - while (rowOffset < width) { - if (row->Get(rowOffset)) { - break; - } - rowOffset++; - } - int32_t counterPosition = 0; - CFX_Int32Array counters; - counters.SetSize(6); - int32_t patternStart = rowOffset; - FX_BOOL isWhite = FALSE; - int32_t patternLength = counters.GetSize(); - for (int32_t i = rowOffset; i < width; i++) { - FX_BOOL pixel = row->Get(i); - if (pixel ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - int32_t bestVariance = MAX_AVG_VARIANCE; - int32_t bestMatch = -1; - for (int32_t startCode = CODE_START_A; startCode <= CODE_START_C; - startCode++) { - int32_t variance = PatternMatchVariance( - &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = startCode; - } - } - if (bestMatch >= 0) { - FX_BOOL btemp2 = - row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), - patternStart, FALSE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (btemp2) { - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(3); - (*result)[0] = patternStart; - (*result)[1] = i; - (*result)[2] = bestMatch; - return result; - } - } - patternStart += counters[0] + counters[1]; - for (int32_t y = 2; y < patternLength; y++) { - counters[y - 2] = counters[y]; - } - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - e = BCExceptionNotFound; - return NULL; -} -int32_t CBC_OnedCode128Reader::DecodeCode(CBC_CommonBitArray* row, - CFX_Int32Array* counters, - int32_t rowOffset, - int32_t& e) { - RecordPattern(row, rowOffset, counters, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - int32_t bestVariance = MAX_AVG_VARIANCE; - int32_t bestMatch = -1; - for (int32_t d = 0; d < 107; d++) { - int32_t variance = PatternMatchVariance(counters, &CODE_PATTERNS[d][0], - MAX_INDIVIDUAL_VARIANCE); - if (variance < bestVariance) { - bestVariance = variance; - bestMatch = d; - } - } - if (bestMatch >= 0) { - return bestMatch; - } else { - e = BCExceptionNotFound; - return 0; - } - return 0; -} -CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - CFX_Int32Array* startPatternInfo = FindStartPattern(row, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - int32_t startCode = (*startPatternInfo)[2]; - int32_t codeSet; - switch (startCode) { - case 103: - codeSet = CODE_CODE_A; - break; - case 104: - codeSet = CODE_CODE_B; - break; - case 105: - codeSet = CODE_CODE_C; - break; - default: - if (startPatternInfo) { - startPatternInfo->RemoveAll(); - delete startPatternInfo; - startPatternInfo = NULL; - } - e = BCExceptionFormatException; - return ""; - } - FX_BOOL done = FALSE; - FX_BOOL isNextShifted = FALSE; - CFX_ByteString result; - int32_t lastStart = (*startPatternInfo)[0]; - int32_t nextStart = (*startPatternInfo)[1]; - if (startPatternInfo) { - startPatternInfo->RemoveAll(); - delete startPatternInfo; - startPatternInfo = NULL; - } - CFX_Int32Array counters; - counters.SetSize(6); - int32_t lastCode = 0; - int32_t code = 0; - int32_t checksumTotal = startCode; - int32_t multiplier = 0; - FX_BOOL lastCharacterWasPrintable = TRUE; - while (!done) { - FX_BOOL unshift = isNextShifted; - isNextShifted = FALSE; - lastCode = code; - code = DecodeCode(row, &counters, nextStart, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - if (code != CODE_STOP) { - lastCharacterWasPrintable = TRUE; - } - if (code != CODE_STOP) { - multiplier++; - checksumTotal += multiplier * code; - } - lastStart = nextStart; - for (int32_t i = 0; i < counters.GetSize(); i++) { - nextStart += counters[i]; - } - switch (code) { - case 103: - case 104: - case 105: - e = BCExceptionFormatException; - return ""; - } - switch (codeSet) { - case 101: - if (code < 64) { - result += (FX_CHAR)(' ' + code); - } else if (code < 96) { - result += (FX_CHAR)(code - 64); - } else { - if (code != CODE_STOP) { - lastCharacterWasPrintable = FALSE; - } - switch (code) { - case 102: - case 97: - case 96: - case 101: - break; - case 98: - isNextShifted = TRUE; - codeSet = CODE_CODE_B; - break; - case 100: - codeSet = CODE_CODE_B; - break; - case 99: - codeSet = CODE_CODE_C; - break; - case 106: - done = TRUE; - break; - } - } - break; - case 100: - if (code < 96) { - result += (FX_CHAR)(' ' + code); - } else { - if (code != CODE_STOP) { - lastCharacterWasPrintable = FALSE; - } - switch (code) { - case 102: - case 97: - case 96: - case 100: - break; - case 98: - isNextShifted = TRUE; - codeSet = CODE_CODE_A; - break; - case 101: - codeSet = CODE_CODE_A; - break; - case 99: - codeSet = CODE_CODE_C; - break; - case 106: - done = TRUE; - break; - } - } - break; - case 99: - if (code < 100) { - if (code < 10) { - result += '0'; - } - FX_CHAR temp[128]; - // TODO(dsinclair): Should this be snprintf? - sprintf(temp, "%d", code); - result += temp; - } else { - if (code != CODE_STOP) { - lastCharacterWasPrintable = FALSE; - } - switch (code) { - case 102: - break; - case 101: - codeSet = CODE_CODE_A; - break; - case 100: - codeSet = CODE_CODE_B; - break; - case 106: - done = TRUE; - break; - } - } - break; - } - if (unshift) { - codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A; - } - } - int32_t width = row->GetSize(); - while (nextStart < width && row->Get(nextStart)) { - nextStart++; - } - FX_BOOL boolT1 = row->IsRange( - nextStart, std::min(width, nextStart + (nextStart - lastStart) / 2), - FALSE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - if (!boolT1) { - e = BCExceptionNotFound; - return ""; - } - checksumTotal -= multiplier * lastCode; - if (checksumTotal % 103 != lastCode) { - e = BCExceptionChecksumException; - return ""; - } - int32_t resultLength = result.GetLength(); - if (resultLength > 0 && lastCharacterWasPrintable) { - if (codeSet == CODE_CODE_C) { - result = result.Mid(0, result.GetLength() - 2); - } else { - result = result.Mid(0, result.GetLength() - 1); - } - } - if (result.GetLength() == 0) { - e = BCExceptionFormatException; - return ""; - } - return result; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h deleted file mode 100644 index 1d2c6a1ce0..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h +++ /dev/null @@ -1,49 +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_SRC_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ - -class CBC_OneDReader; -class CBC_CommonBitArray; -class CBC_OnedCode128Reader : public CBC_OneDReader { - public: - CBC_OnedCode128Reader(); - virtual ~CBC_OnedCode128Reader(); - virtual CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e); - - static const int32_t CODE_PATTERNS[107][7]; - - private: - static const int32_t MAX_AVG_VARIANCE = (int32_t)(256 * 0.25f); - static const int32_t MAX_INDIVIDUAL_VARIANCE = (int32_t)(256 * 0.7f); - - static const int32_t CODE_SHIFT = 98; - static const int32_t CODE_CODE_C = 99; - static const int32_t CODE_CODE_B = 100; - static const int32_t CODE_CODE_A = 101; - static const int32_t CODE_FNC_1 = 102; - static const int32_t CODE_FNC_2 = 97; - static const int32_t CODE_FNC_3 = 96; - static const int32_t CODE_FNC_4_A = 101; - static const int32_t CODE_FNC_4_B = 100; - - static const int32_t CODE_START_A = 103; - static const int32_t CODE_START_B = 104; - static const int32_t CODE_START_C = 105; - static const int32_t CODE_STOP = 106; - - CFX_Int32Array* FindStartPattern(CBC_CommonBitArray* row, int32_t& e); - int32_t DecodeCode(CBC_CommonBitArray* row, - CFX_Int32Array* counters, - int32_t rowOffset, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE128READER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.cpp deleted file mode 100644 index c8977d3171..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.cpp +++ /dev/null @@ -1,235 +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 -// Original code is licensed as follows: -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h" - -const int32_t CBC_OnedCode128Writer::CODE_CODE_B = 100; -const int32_t CBC_OnedCode128Writer::CODE_CODE_C = 99; -const int32_t CBC_OnedCode128Writer::CODE_START_B = 104; -const int32_t CBC_OnedCode128Writer::CODE_START_C = 105; -const int32_t CBC_OnedCode128Writer::CODE_STOP = 106; - -CBC_OnedCode128Writer::CBC_OnedCode128Writer() { - m_codeFormat = BC_CODE128_B; -} -CBC_OnedCode128Writer::CBC_OnedCode128Writer(BC_TYPE type) { - m_codeFormat = type; -} -CBC_OnedCode128Writer::~CBC_OnedCode128Writer() {} -BC_TYPE CBC_OnedCode128Writer::GetType() { - return m_codeFormat; -} -FX_BOOL CBC_OnedCode128Writer::CheckContentValidity( - const CFX_WideStringC& contents) { - FX_BOOL ret = TRUE; - int32_t position = 0; - int32_t patternIndex = -1; - if (m_codeFormat == BC_CODE128_B || m_codeFormat == BC_CODE128_C) { - while (position < contents.GetLength()) { - patternIndex = (int32_t)contents.GetAt(position); - if (patternIndex >= 32 && patternIndex <= 126 && patternIndex != 34) { - position++; - continue; - } else { - ret = FALSE; - break; - } - position++; - } - } else { - ret = FALSE; - } - return ret; -} -CFX_WideString CBC_OnedCode128Writer::FilterContents( - const CFX_WideStringC& contents) { - CFX_WideString filterChineseChar; - FX_WCHAR ch; - for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); - if (ch > 175) { - i++; - continue; - } - filterChineseChar += ch; - } - CFX_WideString filtercontents; - if (m_codeFormat == BC_CODE128_B) { - for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { - ch = filterChineseChar.GetAt(i); - if (ch >= 32 && ch <= 126) { - filtercontents += ch; - } else { - continue; - } - } - } else if (m_codeFormat == BC_CODE128_C) { - for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { - ch = filterChineseChar.GetAt(i); - if (ch >= 32 && ch <= 106) { - filtercontents += ch; - } else { - continue; - } - } - } else { - filtercontents = contents; - } - return filtercontents; -} -FX_BOOL CBC_OnedCode128Writer::SetTextLocation(BC_TEXT_LOC location) { - if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { - return FALSE; - } - m_locTextLoc = location; - return TRUE; -} -uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_CODE_128) { - e = BCExceptionOnlyEncodeCODE_128; - return NULL; - } - uint8_t* ret = - CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -FX_BOOL CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents, - int32_t start, - int32_t length) { - int32_t end = start + length; - for (int32_t i = start; i < end; i++) { - if (contents[i] < '0' || contents[i] > '9') { - return FALSE; - } - } - 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; - } - CFX_PtrArray patterns; - int32_t checkSum = 0; - if (m_codeFormat == BC_CODE128_B) { - checkSum = Encode128B(contents, patterns); - } else if (m_codeFormat == BC_CODE128_C) { - checkSum = Encode128C(contents, patterns); - } else { - e = BCExceptionFormatException; - return NULL; - } - checkSum %= 103; - patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]); - patterns.Add((int32_t*)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]; - for (int32_t j = 0; j < 7; j++) { - codeWidth += pattern[j]; - } - } - outLength = codeWidth; - 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]; - pos += AppendPattern(result, pos, pattern, 7, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - return result; -} -int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents, - CFX_PtrArray& patterns) { - int32_t checkSum = 0; - int32_t checkWeight = 1; - int32_t position = 0; - patterns.Add((int32_t*)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]); - checkSum += patternIndex * checkWeight; - if (position != 0) { - checkWeight++; - } - } - return checkSum; -} -int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents, - CFX_PtrArray& patterns) { - int32_t checkSum = 0; - int32_t checkWeight = 1; - int32_t position = 0; - patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]); - checkSum += CODE_START_C * checkWeight; - while (position < contents.GetLength()) { - int32_t patternIndex = 0; - FX_CHAR ch = contents.GetAt(position); - if (ch < '0' || ch > '9') { - patternIndex = (int32_t)ch; - position++; - } else { - patternIndex = FXSYS_atoi(contents.Mid(position, 2)); - if (contents.GetAt(position + 1) < '0' || - contents.GetAt(position + 1) > '9') { - position += 1; - } else { - position += 2; - } - } - patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]); - checkSum += patternIndex * checkWeight; - if (position != 0) { - checkWeight++; - } - } - return checkSum; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h b/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h deleted file mode 100644 index 1fbb02832b..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Writer.h +++ /dev/null @@ -1,49 +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_SRC_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ - -class CBC_OneDimWriter; -class CBC_OnedCode128Writer : public CBC_OneDimWriter { - public: - CBC_OnedCode128Writer(); - CBC_OnedCode128Writer(BC_TYPE type); - virtual ~CBC_OnedCode128Writer(); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - FX_BOOL SetTextLocation(BC_TEXT_LOC location); - BC_TYPE GetType(); - - private: - 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); - BC_TYPE m_codeFormat; - static const int32_t CODE_START_B; - static const int32_t CODE_START_C; - static const int32_t CODE_CODE_B; - static const int32_t CODE_CODE_C; - static const int32_t CODE_STOP; -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE128WRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp deleted file mode 100644 index 689cf4c87e..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp +++ /dev/null @@ -1,290 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" -#include "xfa/src/fxbarcode/utils.h" - -const FX_CHAR* CBC_OnedCode39Reader::ALPHABET_STRING = - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; -const FX_CHAR* CBC_OnedCode39Reader::CHECKSUM_STRING = - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; -const int32_t CBC_OnedCode39Reader::CHARACTER_ENCODINGS[44] = { - 0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, - 0x064, 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, - 0x04C, 0x01C, 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, - 0x106, 0x046, 0x016, 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, - 0x085, 0x184, 0x0C4, 0x094, 0x0A8, 0x0A2, 0x08A, 0x02A}; -const int32_t CBC_OnedCode39Reader::ASTERISK_ENCODING = 0x094; - -CBC_OnedCode39Reader::CBC_OnedCode39Reader() - : m_usingCheckDigit(FALSE), m_extendedMode(FALSE) { -} -CBC_OnedCode39Reader::CBC_OnedCode39Reader(FX_BOOL usingCheckDigit) - : m_usingCheckDigit(usingCheckDigit), m_extendedMode(FALSE) { -} -CBC_OnedCode39Reader::CBC_OnedCode39Reader(FX_BOOL usingCheckDigit, - FX_BOOL extendedMode) - : m_usingCheckDigit(usingCheckDigit), m_extendedMode(extendedMode) { -} -CBC_OnedCode39Reader::~CBC_OnedCode39Reader() {} -CFX_ByteString CBC_OnedCode39Reader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - CFX_Int32Array* start = FindAsteriskPattern(row, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - int32_t nextStart = (*start)[1]; - delete start; - int32_t end = row->GetSize(); - while (nextStart < end && !row->Get(nextStart)) { - nextStart++; - } - CFX_ByteString result; - CFX_Int32Array counters; - counters.SetSize(9); - FX_CHAR decodedChar; - do { - RecordPattern(row, nextStart, &counters, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - int32_t pattern = ToNarrowWidePattern(&counters); - if (pattern < 0) { - e = BCExceptionNotFound; - return ""; - } - decodedChar = PatternToChar(pattern, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - result += decodedChar; - for (int32_t i = 0; i < counters.GetSize(); i++) { - nextStart += counters[i]; - } - while (nextStart < end && !row->Get(nextStart)) { - nextStart++; - } - } while (decodedChar != '*'); - result = result.Mid(0, result.GetLength() - 1); - int32_t lastPatternSize = 0; - for (int32_t j = 0; j < counters.GetSize(); j++) { - lastPatternSize += counters[j]; - } - if (m_usingCheckDigit) { - int32_t max = result.GetLength() - 1; - int32_t total = 0; - int32_t len = (int32_t)strlen(ALPHABET_STRING); - for (int32_t k = 0; k < max; k++) { - for (int32_t j = 0; j < len; j++) - if (ALPHABET_STRING[j] == result[k]) { - total += j; - } - } - if (result[max] != (ALPHABET_STRING)[total % 43]) { - e = BCExceptionChecksumException; - return ""; - } - result = result.Mid(0, result.GetLength() - 1); - } - if (result.GetLength() == 0) { - e = BCExceptionNotFound; - return ""; - } - if (m_extendedMode) { - CFX_ByteString bytestr = DecodeExtended(result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return bytestr; - } else { - return result; - } -} -CFX_Int32Array* CBC_OnedCode39Reader::FindAsteriskPattern( - CBC_CommonBitArray* row, - int32_t& e) { - int32_t width = row->GetSize(); - int32_t rowOffset = 0; - while (rowOffset < width) { - if (row->Get(rowOffset)) { - break; - } - rowOffset++; - } - int32_t counterPosition = 0; - CFX_Int32Array counters; - counters.SetSize(9); - int32_t patternStart = rowOffset; - FX_BOOL isWhite = FALSE; - int32_t patternLength = counters.GetSize(); - for (int32_t i = rowOffset; i < width; i++) { - FX_BOOL pixel = row->Get(i); - if (pixel ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { - FX_BOOL bT1 = - row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), - patternStart, FALSE, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (bT1) { - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(2); - (*result)[0] = patternStart; - (*result)[1] = i; - return result; - } - } - patternStart += counters[0] + counters[1]; - for (int32_t y = 2; y < patternLength; y++) { - counters[y - 2] = counters[y]; - } - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - e = BCExceptionNotFound; - return NULL; -} -int32_t CBC_OnedCode39Reader::ToNarrowWidePattern(CFX_Int32Array* counters) { - int32_t numCounters = counters->GetSize(); - int32_t maxNarrowCounter = 0; - int32_t wideCounters; - do { -#undef max - int32_t minCounter = FXSYS_IntMax; - for (int32_t i = 0; i < numCounters; i++) { - int32_t counter = (*counters)[i]; - if (counter < minCounter && counter > maxNarrowCounter) { - minCounter = counter; - } - } - maxNarrowCounter = minCounter; - wideCounters = 0; - int32_t totalWideCountersWidth = 0; - int32_t pattern = 0; - for (int32_t j = 0; j < numCounters; j++) { - int32_t counter = (*counters)[j]; - if ((*counters)[j] > maxNarrowCounter) { - pattern |= 1 << (numCounters - 1 - j); - wideCounters++; - totalWideCountersWidth += counter; - } - } - if (wideCounters == 3) { - for (int32_t k = 0; k < numCounters && wideCounters > 0; k++) { - int32_t counter = (*counters)[k]; - if ((*counters)[k] > maxNarrowCounter) { - wideCounters--; - if ((counter << 1) >= totalWideCountersWidth) { - return -1; - } - } - } - return pattern; - } - } while (wideCounters > 3); - return -1; -} -FX_CHAR CBC_OnedCode39Reader::PatternToChar(int32_t pattern, int32_t& e) { - for (int32_t i = 0; i < 44; i++) { - if (CHARACTER_ENCODINGS[i] == pattern) { - return (ALPHABET_STRING)[i]; - } - } - e = BCExceptionNotFound; - return 0; -} -CFX_ByteString CBC_OnedCode39Reader::DecodeExtended(CFX_ByteString& encoded, - int32_t& e) { - int32_t length = encoded.GetLength(); - CFX_ByteString decoded; - FX_CHAR c, next; - for (int32_t i = 0; i < length; i++) { - c = encoded[i]; - if (c == '+' || c == '$' || c == '%' || c == '/') { - next = encoded[i + 1]; - FX_CHAR decodedChar = '\0'; - switch (c) { - case '+': - if (next >= 'A' && next <= 'Z') { - decodedChar = (FX_CHAR)(next + 32); - } else { - e = BCExceptionFormatException; - return ""; - } - break; - case '$': - if (next >= 'A' && next <= 'Z') { - decodedChar = (FX_CHAR)(next - 64); - } else { - e = BCExceptionFormatException; - return ""; - } - break; - case '%': - if (next >= 'A' && next <= 'E') { - decodedChar = (FX_CHAR)(next - 38); - } else if (next >= 'F' && next <= 'J') { - decodedChar = (FX_CHAR)(next - 11); - } else if (next >= 'K' && next <= 'O' && next != 'M' && next != 'N') { - decodedChar = (FX_CHAR)(next + 16); - } else if (next >= 'P' && next <= 'S') { - decodedChar = (FX_CHAR)(next + 43); - } else if (next == 'U') { - decodedChar = (FX_CHAR)0; - } else if (next == 'V') { - decodedChar = (FX_CHAR)64; - } else if (next == 'W') { - decodedChar = (FX_CHAR)96; - } else if (next == 'T' || next == 'X' || next == 'Y' || next == 'Z') { - decodedChar = (FX_CHAR)127; - } else { - e = BCExceptionFormatException; - return ""; - } - break; - case '/': - if (next >= 'A' && next <= 'O') { - decodedChar = (FX_CHAR)(next - 32); - } else if (next == 'Z') { - decodedChar = ':'; - } else { - e = BCExceptionFormatException; - return ""; - } - break; - } - decoded += decodedChar; - i++; - } else { - decoded += c; - } - } - return decoded; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h deleted file mode 100644 index b5573b1bdf..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h +++ /dev/null @@ -1,36 +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_SRC_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ - -class CBC_OneDReader; -class CBC_CommonBitArray; -class CBC_OnedCode39Reader : public CBC_OneDReader { - public: - static const FX_CHAR* ALPHABET_STRING; - static const FX_CHAR* CHECKSUM_STRING; - static const int32_t CHARACTER_ENCODINGS[44]; - static const int32_t ASTERISK_ENCODING; - CBC_OnedCode39Reader(); - CBC_OnedCode39Reader(FX_BOOL usingCheckDigit); - CBC_OnedCode39Reader(FX_BOOL usingCheckDigit, FX_BOOL extendedMode); - virtual ~CBC_OnedCode39Reader(); - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e); - - private: - FX_BOOL m_usingCheckDigit; - FX_BOOL m_extendedMode; - CFX_Int32Array* FindAsteriskPattern(CBC_CommonBitArray* row, int32_t& e); - int32_t ToNarrowWidePattern(CFX_Int32Array* counters); - FX_CHAR PatternToChar(int32_t pattern, int32_t& e); - CFX_ByteString DecodeExtended(CFX_ByteString& encoded, int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE39READER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.cpp deleted file mode 100644 index 5b33965622..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ /dev/null @@ -1,364 +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 -// Original code is licensed as follows: -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h" - -CBC_OnedCode39Writer::CBC_OnedCode39Writer() { - m_extendedMode = FALSE; - m_iWideNarrRatio = 3; -} -CBC_OnedCode39Writer::CBC_OnedCode39Writer(FX_BOOL extendedMode) { - m_iWideNarrRatio = 3; - m_extendedMode = extendedMode; -} -CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {} -FX_BOOL CBC_OnedCode39Writer::CheckContentValidity( - const CFX_WideStringC& contents) { - if (m_extendedMode) { - return CheckExtendedContentValidity(contents); - } - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || - (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || ch == (FX_WCHAR)'-' || - ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || - ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || - ch == (FX_WCHAR)'%') { - continue; - } - return FALSE; - } - return TRUE; -} -FX_BOOL CBC_OnedCode39Writer::CheckExtendedContentValidity( - const CFX_WideStringC& contents) { - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if (ch > 127) { - return FALSE; - } - } - return TRUE; -} -CFX_WideString CBC_OnedCode39Writer::FilterContents( - const CFX_WideStringC& contents) { - if (m_extendedMode) { - return FilterExtendedContents(contents); - } - CFX_WideString filtercontents; - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { - continue; - } - if (ch > 175) { - i++; - continue; - } else { - ch = Upper(ch); - } - if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || - (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || ch == (FX_WCHAR)'-' || - ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || - ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || - ch == (FX_WCHAR)'%') { - filtercontents += ch; - } - } - return filtercontents; -} -CFX_WideString CBC_OnedCode39Writer::FilterExtendedContents( - const CFX_WideStringC& contents) { - CFX_WideString filtercontents; - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { - continue; - } - if (ch > 175) { - i++; - continue; - } - if (ch > 127 && ch < 176) { - continue; - } - if (ch == 0) { - filtercontents += '%'; - filtercontents += 'U'; - } else if (ch >= 1 && ch <= 26) { - filtercontents += '$'; - filtercontents += (ch + 64); - } else if (ch >= 27 && ch <= 31) { - filtercontents += '%'; - filtercontents += (ch + 38); - } else if (ch >= 33 && ch <= 47 && ch != 45 && ch != 46) { - filtercontents += '/'; - filtercontents += (ch + 32); - } else if (ch == 58) { - filtercontents += '/'; - filtercontents += 'Z'; - } else if (ch >= 59 && ch <= 63) { - filtercontents += '%'; - filtercontents += ch + 11; - } else if (ch == 64) { - filtercontents += '%'; - filtercontents += 'V'; - } else if (ch >= 91 && ch <= 95) { - filtercontents += '%'; - filtercontents += ch - 16; - } else if (ch == 96) { - filtercontents += '%'; - filtercontents += 'W'; - } else if (ch >= 97 && ch <= 122) { - filtercontents += '+'; - filtercontents += ch - 32; - } else if (ch >= 123 && ch <= 126) { - filtercontents += '%'; - filtercontents += ch - 43; - } else if (ch == 127) { - filtercontents += '%'; - filtercontents += 'T'; - } else { - filtercontents += ch; - } - } - return filtercontents; -} -CFX_WideString CBC_OnedCode39Writer::RenderTextContents( - const CFX_WideStringC& contents) { - if (m_extendedMode) { - return RenderExtendedTextContents(contents); - } - CFX_WideString renderContents; - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { - continue; - } - if (ch > 175) { - i++; - continue; - } - if ((ch >= (FX_WCHAR)'0' && ch <= (FX_WCHAR)'9') || - (ch >= (FX_WCHAR)'A' && ch <= (FX_WCHAR)'Z') || - (ch >= (FX_WCHAR)'a' && ch <= (FX_WCHAR)'z') || ch == (FX_WCHAR)'-' || - ch == (FX_WCHAR)'.' || ch == (FX_WCHAR)' ' || ch == (FX_WCHAR)'*' || - ch == (FX_WCHAR)'$' || ch == (FX_WCHAR)'/' || ch == (FX_WCHAR)'+' || - ch == (FX_WCHAR)'%') { - renderContents += ch; - } - } - return renderContents; -} -CFX_WideString CBC_OnedCode39Writer::RenderExtendedTextContents( - const CFX_WideStringC& contents) { - CFX_WideString renderContents; - for (int32_t i = 0; i < contents.GetLength(); i++) { - FX_WCHAR ch = contents.GetAt(i); - if (ch == (FX_WCHAR)'*' && (i == 0 || i == contents.GetLength() - 1)) { - continue; - } - if (ch > 175) { - i++; - continue; - } - if (ch > 127 && ch < 176) { - continue; - } - renderContents += ch; - } - return renderContents; -} -FX_BOOL CBC_OnedCode39Writer::SetTextLocation(BC_TEXT_LOC location) { - if (location < BC_TEXT_LOC_NONE || location > BC_TEXT_LOC_BELOWEMBED) { - return FALSE; - } - m_locTextLoc = location; - return TRUE; -} -FX_BOOL CBC_OnedCode39Writer::SetWideNarrowRatio(int32_t ratio) { - if (ratio < 2 || ratio > 3) { - return FALSE; - } - m_iWideNarrRatio = ratio; - return TRUE; -} -uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_CODE_39) { - e = BCExceptionOnlyEncodeCODE_39; - return NULL; - } - uint8_t* ret = - CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -void CBC_OnedCode39Writer::ToIntArray(int32_t a, int32_t* toReturn) { - for (int32_t i = 0; i < 9; i++) { - toReturn[i] = (a & (1 << i)) == 0 ? 1 : m_iWideNarrRatio; - } -} -FX_CHAR CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString& contents, - int32_t& e) { - int32_t length = contents.GetLength(); - if (length > 80) { - e = BCExceptionContentsLengthShouldBetween1and80; - return '*'; - } - int32_t checksum = 0; - int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); - for (int32_t i = 0; i < contents.GetLength(); i++) { - int32_t j = 0; - for (; j < len; j++) { - if (CBC_OnedCode39Reader::ALPHABET_STRING[j] == contents[i]) { - if (contents[i] != '*') { - checksum += j; - break; - } else { - break; - } - } - } - if (j >= len) { - e = BCExceptionUnSupportedString; - return '*'; - } - } - checksum = checksum % 43; - return CBC_OnedCode39Reader::CHECKSUM_STRING[checksum]; -} -uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents, - int32_t& outlength, - int32_t& e) { - FX_CHAR checksum = CalcCheckSum(contents, e); - if (checksum == '*') { - return NULL; - } - int32_t widths[9] = {0}; - int32_t wideStrideNum = 3; - int32_t narrStrideNum = 9 - wideStrideNum; - CFX_ByteString encodedContents = contents; - if (m_bCalcChecksum) { - encodedContents += checksum; - } - m_iContentLen = encodedContents.GetLength(); - int32_t codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2 + - 1 + m_iContentLen; - int32_t len = (int32_t)strlen(CBC_OnedCode39Reader::ALPHABET_STRING); - for (int32_t j = 0; j < m_iContentLen; j++) { - for (int32_t i = 0; i < len; i++) { - if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[j]) { - ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths); - for (int32_t k = 0; k < 9; k++) { - codeWidth += widths[k]; - } - } - } - } - outlength = codeWidth; - uint8_t* result = FX_Alloc(uint8_t, codeWidth); - ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); - int32_t pos = AppendPattern(result, 0, widths, 9, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - int32_t narrowWhite[] = {1}; - pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - for (int32_t l = m_iContentLen - 1; l >= 0; l--) { - for (int32_t i = 0; i < len; i++) { - if (CBC_OnedCode39Reader::ALPHABET_STRING[i] == encodedContents[l]) { - ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[i], widths); - pos += AppendPattern(result, pos, widths, 9, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - } - pos += AppendPattern(result, pos, narrowWhite, 1, 0, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - ToIntArray(CBC_OnedCode39Reader::CHARACTER_ENCODINGS[39], widths); - pos += AppendPattern(result, pos, widths, 9, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - for (int32_t i = 0; i < codeWidth / 2; i++) { - result[i] ^= result[codeWidth - 1 - i]; - result[codeWidth - 1 - i] ^= result[i]; - result[i] ^= result[codeWidth - 1 - i]; - } - return result; -} -CFX_WideString CBC_OnedCode39Writer::encodedContents( - const CFX_WideStringC& contents, - int32_t& e) { - 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"")); - str += checksum; - encodedContents += checksum; - } - return encodedContents; -} -void CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - CFX_WideString encodedCon = encodedContents(contents, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_OneDimWriter::RenderResult(encodedCon, code, codeLength, isDevice, e); -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h b/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h deleted file mode 100644 index d453b49b48..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Writer.h +++ /dev/null @@ -1,53 +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_SRC_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ - -enum BC_TEXT_LOC; -class CBC_OneDimWriter; -class CBC_OnedCode39Writer : public CBC_OneDimWriter { - public: - CBC_OnedCode39Writer(); - CBC_OnedCode39Writer(FX_BOOL extendedMode); - virtual ~CBC_OnedCode39Writer(); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e); - void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - CFX_WideString encodedContents(const CFX_WideStringC& contents, int32_t& e); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - FX_BOOL CheckExtendedContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - CFX_WideString FilterExtendedContents(const CFX_WideStringC& contents); - CFX_WideString RenderTextContents(const CFX_WideStringC& contents); - CFX_WideString RenderExtendedTextContents(const CFX_WideStringC& contents); - FX_BOOL SetTextLocation(BC_TEXT_LOC loction); - FX_BOOL SetWideNarrowRatio(int32_t ratio); - - private: - void ToIntArray(int32_t a, int32_t* toReturn); - FX_CHAR CalcCheckSum(const CFX_ByteString& contents, int32_t& e); - int32_t m_iWideNarrRatio; - FX_BOOL m_extendedMode; -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDCODE39WRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp deleted file mode 100644 index 1cb08cd9b8..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.cpp +++ /dev/null @@ -1,96 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[10] = { - 0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A}; - -CBC_OnedEAN13Reader::CBC_OnedEAN13Reader() {} -CBC_OnedEAN13Reader::~CBC_OnedEAN13Reader() {} -void CBC_OnedEAN13Reader::DetermineFirstDigit(CFX_ByteString& result, - int32_t lgPatternFound, - int32_t& e) { - for (int32_t d = 0; d < 10; d++) { - if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) { - result.Insert(0, (FX_CHAR)('0' + d)); - return; - } - } - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -int32_t CBC_OnedEAN13Reader::DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultString, - int32_t& e) { - CFX_Int32Array counters; - counters.Add(0); - counters.Add(0); - counters.Add(0); - counters.Add(0); - int32_t end = row->GetSize(); - int32_t rowOffset = (*startRange)[1]; - int32_t lgPatternFound = 0; - for (int32_t x = 0; x < 6 && rowOffset < end; x++) { - int32_t bestMatch = - DecodeDigit(row, &counters, rowOffset, - &(CBC_OneDimReader::L_AND_G_PATTERNS[0][0]), 20, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - resultString += (FX_CHAR)('0' + bestMatch % 10); - for (int32_t i = 0; i < counters.GetSize(); i++) { - rowOffset += counters[i]; - } - if (bestMatch >= 10) { - lgPatternFound |= 1 << (5 - x); - } - } - DetermineFirstDigit(resultString, lgPatternFound, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - CFX_Int32Array result; - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]); - CFX_Int32Array* middleRange = - FindGuardPattern(row, rowOffset, TRUE, &result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - rowOffset = (*middleRange)[1]; - delete middleRange; - for (int32_t Y = 0; Y < 6 && rowOffset < end; Y++) { - int32_t bestMatch = - DecodeDigit(row, &counters, rowOffset, - &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - resultString += (FX_CHAR)('0' + bestMatch); - for (int32_t k = 0; k < counters.GetSize(); k++) { - rowOffset += counters[k]; - } - } - return rowOffset; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h b/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h deleted file mode 100644 index 795cc2fbde..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.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_SRC_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ -class CBC_OneDimReader; -class CBC_CommonBitArray; -class CBC_OnedEAN13Reader; -class CBC_OnedEAN13Reader : public CBC_OneDimReader { - public: - static const int32_t FIRST_DIGIT_ENCODINGS[10]; - CBC_OnedEAN13Reader(); - virtual ~CBC_OnedEAN13Reader(); - - private: - void DetermineFirstDigit(CFX_ByteString& result, - int32_t lgPatternFound, - int32_t& e); - - protected: - int32_t DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultString, - int32_t& e); - friend class CBC_OnedUPCAReader; -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN13READER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp deleted file mode 100644 index 1a026da98f..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ /dev/null @@ -1,301 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h" - -CBC_OnedEAN13Writer::CBC_OnedEAN13Writer() { - m_bLeftPadding = TRUE; - m_codeWidth = 3 + (7 * 6) + 5 + (7 * 6) + 3; -} -CBC_OnedEAN13Writer::~CBC_OnedEAN13Writer() {} -FX_BOOL CBC_OnedEAN13Writer::CheckContentValidity( - const CFX_WideStringC& contents) { - for (int32_t i = 0; i < contents.GetLength(); i++) { - if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { - continue; - } else { - return FALSE; - } - } - return TRUE; -} -CFX_WideString CBC_OnedEAN13Writer::FilterContents( - const CFX_WideStringC& contents) { - CFX_WideString filtercontents; - FX_WCHAR ch; - for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); - if (ch > 175) { - i++; - continue; - } - if (ch >= '0' && ch <= '9') { - filtercontents += ch; - } - } - return filtercontents; -} -int32_t CBC_OnedEAN13Writer::CalcChecksum(const CFX_ByteString& contents) { - int32_t odd = 0; - int32_t even = 0; - int32_t j = 1; - for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { - if (j % 2) { - odd += FXSYS_atoi(contents.Mid(i, 1)); - } else { - even += FXSYS_atoi(contents.Mid(i, 1)); - } - j++; - } - int32_t checksum = (odd * 3 + even) % 10; - checksum = (10 - checksum) % 10; - return (checksum); -} -uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_EAN_13) { - e = BCExceptionOnlyEncodeEAN_13; - } - uint8_t* ret = - CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e) { - if (contents.GetLength() != 13) { - e = BCExceptionDigitLengthShould13; - return NULL; - } - m_iDataLenth = 13; - int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1)); - int32_t parities = CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit]; - outLength = m_codeWidth; - uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); - int32_t pos = 0; - pos += - AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - int32_t i = 0; - for (i = 1; i <= 6; i++) { - int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); - if ((parities >> (6 - i) & 1) == 1) { - digit += 10; - } - pos += AppendPattern(result, pos, CBC_OneDimReader::L_AND_G_PATTERNS[digit], - 4, 0, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - for (i = 7; i <= 12; i++) { - int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); - pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, - e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - pos += - AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - return result; -} -void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { - e = BCExceptionIllegalArgument; - return; - } - int32_t leftPadding = 7 * multiple; - int32_t leftPosition = 3 * multiple + leftPadding; - CFX_ByteString str = FX_UTF8Encode(contents); - int32_t iLen = str.GetLength(); - FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); - FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); - CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - CFX_ByteString tempStr = str.Mid(1, 6); - int32_t strWidth = multiple * 42; - if (pOutBitmap == NULL) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect( - (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_FloatRect rect1( - (FX_FLOAT)(leftPosition + 47 * multiple), - (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)(leftPosition + 47 * multiple + strWidth - 0.5), - (FX_FLOAT)m_Height); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - int32_t strWidth1 = multiple * 7; - CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); - CFX_FloatRect rect2(0.0f, (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)strWidth1 - 0.5f, (FX_FLOAT)m_Height); - matr2.Concat(*matrix); - matr2.TransformRect(rect2); - re = rect2.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - } - FX_FLOAT blank = 0.0; - iLen = tempStr.GetLength(); - if (pOutBitmap == NULL) { - strWidth = (int32_t)(strWidth * m_outputHScale); - } - CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, - blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb); - FX_RECT rect(0, 0, strWidth, iTextHeight); - ge.FillRect(&rect, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)leftPosition * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight) + iFontSize); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 1, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(7, 6); - iLen = tempStr.GetLength(); - CalcTextInfo(tempStr, pCharPos + 7, m_pFont, (FX_FLOAT)strWidth, iFontSize, - blank); - if (pOutBitmap) { - FX_RECT rect1(0, 0, strWidth, iTextHeight); - ge.FillRect(&rect1, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple, - m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1( - 1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)(leftPosition + 47 * multiple) * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 7, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(0, 1); - iLen = tempStr.GetLength(); - strWidth = multiple * 7; - if (pOutBitmap == NULL) { - strWidth = (int32_t)(strWidth * m_outputHScale); - } - CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, - blank); - if (pOutBitmap) { - delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - FX_Free(pCharPos); -} -void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h b/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h deleted file mode 100644 index 8fd42733f3..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h +++ /dev/null @@ -1,53 +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_SRC_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ - -class CBC_OneDimWriter; -class CBC_OnedEAN13Writer; -class CBC_OnedEAN13Writer : public CBC_OneDimWriter { - private: - int32_t m_codeWidth; - - public: - CBC_OnedEAN13Writer(); - virtual ~CBC_OnedEAN13Writer(); - - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e); - void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - int32_t CalcChecksum(const CFX_ByteString& contents); - - protected: - void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN13WRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp deleted file mode 100644 index 8d13d26347..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.cpp +++ /dev/null @@ -1,82 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_OnedEAN8Reader::CBC_OnedEAN8Reader() {} -CBC_OnedEAN8Reader::~CBC_OnedEAN8Reader() {} -int32_t CBC_OnedEAN8Reader::DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultResult, - int32_t& e) { - CFX_Int32Array counters; - counters.Add(0); - counters.Add(0); - counters.Add(0); - counters.Add(0); - int32_t end = row->GetSize(); - int32_t rowOffset = (*startRange)[1]; - int32_t rowOffsetLeft = rowOffset; - for (int32_t x = 0; x < 4 && rowOffset < end; x++) { - int32_t bestMatch = - DecodeDigit(row, &counters, rowOffset, - &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - resultResult += (FX_CHAR)('0' + bestMatch); - for (int32_t i = 0; i < counters.GetSize(); i++) { - rowOffset += counters[i]; - } - } - int32_t RowOffsetLen = (rowOffset - rowOffsetLeft) / 4; - CFX_Int32Array result; - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[0]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[1]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[2]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[3]); - result.Add(CBC_OneDimReader::MIDDLE_PATTERN[4]); - CFX_Int32Array* middleRange = - FindGuardPattern(row, rowOffset, TRUE, &result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - int32_t rowOffsetMid = rowOffset; - rowOffset = (*middleRange)[1]; - if ((rowOffset - rowOffsetMid) > RowOffsetLen) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - delete middleRange; - for (int32_t y = 0; y < 4 && rowOffset < end; y++) { - int32_t bestMatch = - DecodeDigit(row, &counters, rowOffset, - &(CBC_OneDimReader::L_PATTERNS[0][0]), 10, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - resultResult += (FX_CHAR)('0' + bestMatch); - for (int32_t i = 0; i < counters.GetSize(); i++) { - rowOffset += counters[i]; - } - } - return rowOffset; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h b/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h deleted file mode 100644 index b9f14d6c85..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Reader.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ - -class CBC_OneDimReader; -class CBC_CommonBitArray; -class CBC_OnedEAN8Reader; -class CBC_OnedEAN8Reader : public CBC_OneDimReader { - public: - CBC_OnedEAN8Reader(); - virtual ~CBC_OnedEAN8Reader(); - - protected: - int32_t DecodeMiddle(CBC_CommonBitArray*, - CFX_Int32Array* startRange, - CFX_ByteString& result, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8READER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp deleted file mode 100644 index 9981575112..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ /dev/null @@ -1,268 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h" - -CBC_OnedEAN8Writer::CBC_OnedEAN8Writer() { - m_iDataLenth = 8; - m_codeWidth = 3 + (7 * 4) + 5 + (7 * 4) + 3; -} -CBC_OnedEAN8Writer::~CBC_OnedEAN8Writer() {} -void CBC_OnedEAN8Writer::SetDataLength(int32_t length) { - m_iDataLenth = 8; -} -FX_BOOL CBC_OnedEAN8Writer::SetTextLocation(BC_TEXT_LOC location) { - if (location == BC_TEXT_LOC_BELOWEMBED) { - m_locTextLoc = location; - return TRUE; - } - return FALSE; -} -FX_BOOL CBC_OnedEAN8Writer::CheckContentValidity( - const CFX_WideStringC& contents) { - for (int32_t i = 0; i < contents.GetLength(); i++) { - if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { - continue; - } else { - return FALSE; - } - } - return TRUE; -} -CFX_WideString CBC_OnedEAN8Writer::FilterContents( - const CFX_WideStringC& contents) { - CFX_WideString filtercontents; - FX_WCHAR ch; - for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); - if (ch > 175) { - i++; - continue; - } - if (ch >= '0' && ch <= '9') { - filtercontents += ch; - } - } - return filtercontents; -} -int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) { - int32_t odd = 0; - int32_t even = 0; - int32_t j = 1; - for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { - if (j % 2) { - odd += FXSYS_atoi(contents.Mid(i, 1)); - } else { - even += FXSYS_atoi(contents.Mid(i, 1)); - } - j++; - } - int32_t checksum = (odd * 3 + even) % 10; - checksum = (10 - checksum) % 10; - return (checksum); -} -uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_EAN_8) { - e = BCExceptionOnlyEncodeEAN_8; - return NULL; - } - uint8_t* ret = - CBC_OneDimWriter::Encode(contents, format, outWidth, outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e) { - if (contents.GetLength() != 8) { - e = BCExceptionDigitLengthMustBe8; - return NULL; - } - outLength = m_codeWidth; - uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); - int32_t pos = 0; - pos += - AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - int32_t i = 0; - for (i = 0; i <= 3; i++) { - int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); - pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0, - e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - for (i = 4; i <= 7; i++) { - int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); - pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, - e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - } - pos += - AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); - if (e != BCExceptionNO) { - FX_Free(result); - return NULL; - } - return result; -} -void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { - e = BCExceptionIllegalArgument; - return; - } - int32_t leftPosition = 3 * multiple; - CFX_ByteString str = FX_UTF8Encode(contents); - int32_t iLength = str.GetLength(); - FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLength); - FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLength); - CFX_ByteString tempStr = str.Mid(0, 4); - int32_t iLen = tempStr.GetLength(); - int32_t strWidth = 7 * multiple * 4; - FX_FLOAT blank = 0.0; - CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect( - (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect1( - (FX_FLOAT)(leftPosition + 33 * multiple), - (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)(leftPosition + 33 * multiple + strWidth - 0.5), - (FX_FLOAT)m_Height); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - } - if (pOutBitmap == NULL) { - strWidth = (int32_t)(strWidth * m_outputHScale); - } - CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, - blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)leftPosition * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - affine_matrix1.Concat(*matrix); - device->DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(4, 4); - iLen = tempStr.GetLength(); - CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (FX_FLOAT)strWidth, iFontSize, - blank); - if (pOutBitmap) { - delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple, - m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1( - 1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)(leftPosition + 33 * multiple) * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 4, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - FX_Free(pCharPos); -} -void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h b/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h deleted file mode 100644 index fd858fcc02..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedEAN8Writer.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ - -enum BC_TEXT_LOC; -class CBC_OneDimWriter; -class CBC_OnedEAN8Writer; -class CBC_OnedEAN8Writer : public CBC_OneDimWriter { - private: - int32_t m_codeWidth; - - public: - CBC_OnedEAN8Writer(); - virtual ~CBC_OnedEAN8Writer(); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e); - void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - void SetDataLength(int32_t length); - FX_BOOL SetTextLocation(BC_TEXT_LOC location); - int32_t CalcChecksum(const CFX_ByteString& contents); - - protected: - void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDEAN8WRITER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp deleted file mode 100644 index 416b08ae9a..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.cpp +++ /dev/null @@ -1,97 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Reader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_OnedUPCAReader::CBC_OnedUPCAReader() { - m_ean13Reader = NULL; -} -void CBC_OnedUPCAReader::Init() { - m_ean13Reader = new CBC_OnedEAN13Reader; -} -CBC_OnedUPCAReader::~CBC_OnedUPCAReader() { - delete m_ean13Reader; -} -CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e) { - CFX_ByteString bytestring = - m_ean13Reader->DecodeRow(rowNumber, row, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CFX_ByteString temp = MaybeReturnResult(bytestring, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return temp; -} -CFX_ByteString CBC_OnedUPCAReader::DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - CFX_Int32Array* startGuardRange, - int32_t hints, - int32_t& e) { - CFX_ByteString bytestring = - m_ean13Reader->DecodeRow(rowNumber, row, startGuardRange, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CFX_ByteString temp = MaybeReturnResult(bytestring, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return temp; -} -CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { - CFX_ByteString bytestring = m_ean13Reader->Decode(image, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CFX_ByteString temp = MaybeReturnResult(bytestring, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return temp; -} -CFX_ByteString CBC_OnedUPCAReader::Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - CFX_ByteString bytestring = m_ean13Reader->Decode(image, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CFX_ByteString temp = MaybeReturnResult(bytestring, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return temp; -} -int32_t CBC_OnedUPCAReader::DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultString, - int32_t& e) { - int32_t temp = m_ean13Reader->DecodeMiddle(row, startRange, resultString, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - return temp; -} -CFX_ByteString CBC_OnedUPCAReader::MaybeReturnResult(CFX_ByteString& result, - int32_t& e) { - if (result[0] == '0') { - result.Delete(0); - return result; - } else { - e = BCExceptionFormatException; - return ""; - } - return ""; -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h b/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h deleted file mode 100644 index 2b6bd1785a..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAReader.h +++ /dev/null @@ -1,43 +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_SRC_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ - -class CBC_BinaryBitmap; -class CBC_CommonBitArray; -class CBC_OneDimReader; -class CBC_OnedEAN13Reader; -class CBC_OnedUPCAReader; -class CBC_OnedUPCAReader : public CBC_OneDimReader { - private: - CBC_OnedEAN13Reader* m_ean13Reader; - - public: - CBC_OnedUPCAReader(); - virtual ~CBC_OnedUPCAReader(); - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - int32_t hints, - int32_t& e); - CFX_ByteString DecodeRow(int32_t rowNumber, - CBC_CommonBitArray* row, - CFX_Int32Array* startGuardRange, - int32_t hints, - int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); - virtual void Init(); - - protected: - int32_t DecodeMiddle(CBC_CommonBitArray* row, - CFX_Int32Array* startRange, - CFX_ByteString& resultString, - int32_t& e); - CFX_ByteString MaybeReturnResult(CFX_ByteString& result, int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_ diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp deleted file mode 100644 index fe4a8e7824..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ /dev/null @@ -1,286 +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 -// Original code is licensed as follows: -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimWriter.h" -#include "xfa/src/fxbarcode/oned/BC_OnedEAN13Writer.h" -#include "xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h" - -CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() { - m_subWriter = NULL; - m_bLeftPadding = TRUE; - m_bRightPadding = TRUE; -} -void CBC_OnedUPCAWriter::Init() { - m_subWriter = new CBC_OnedEAN13Writer; -} -CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { - delete m_subWriter; -} -FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( - const CFX_WideStringC& contents) { - int32_t i = 0; - for (i = 0; i < contents.GetLength(); i++) { - if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { - continue; - } else { - return FALSE; - } - } - return TRUE; -} -CFX_WideString CBC_OnedUPCAWriter::FilterContents( - const CFX_WideStringC& contents) { - CFX_WideString filtercontents; - FX_WCHAR ch; - for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); - if (ch > 175) { - i++; - continue; - } - if (ch >= '0' && ch <= '9') { - filtercontents += ch; - } - } - return filtercontents; -} -int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) { - int32_t odd = 0; - int32_t even = 0; - int32_t j = 1; - for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { - if (j % 2) { - odd += FXSYS_atoi(contents.Mid(i, 1)); - } else { - even += FXSYS_atoi(contents.Mid(i, 1)); - } - j++; - } - int32_t checksum = (odd * 3 + even) % 10; - checksum = (10 - checksum) % 10; - return (checksum); -} -uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - if (format != BCFORMAT_UPC_A) { - e = BCExceptionOnlyEncodeUPC_A; - return NULL; - } - CFX_ByteString toEAN13String = '0' + contents; - m_iDataLenth = 13; - uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, - outHeight, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return ret; -} -void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { - e = BCExceptionIllegalArgument; - return; - } - int32_t leftPadding = 7 * multiple; - int32_t leftPosition = 10 * multiple + leftPadding; - CFX_ByteString str = FX_UTF8Encode(contents); - int32_t iLen = str.GetLength(); - FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); - FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); - CFX_ByteString tempStr = str.Mid(1, 5); - FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; - FX_FLOAT blank = 0.0; - CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } - iLen = tempStr.GetLength(); - int32_t iFontSize = (int32_t)fabs(m_fFontSize); - int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { - CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect( - (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); - matr.Concat(*matrix); - matr.TransformRect(rect); - FX_RECT re = rect.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect1( - (FX_FLOAT)(leftPosition + 40 * multiple), - (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), - (FX_FLOAT)m_Height); - matr1.Concat(*matrix); - matr1.TransformRect(rect1); - re = rect1.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7; - CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height); - matr2.Concat(*matrix); - matr2.TransformRect(rect2); - re = rect2.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); - CFX_FloatRect rect3( - (FX_FLOAT)(leftPosition + 85 * multiple), - (FX_FLOAT)(m_Height - iTextHeight), - (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5), - (FX_FLOAT)m_Height); - matr3.Concat(*matrix); - matr3.TransformRect(rect3); - re = rect3.GetOutterRect(); - device->FillRect(&re, m_backgroundColor); - } - if (pOutBitmap == NULL) { - strWidth = strWidth * m_outputHScale; - } - CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); - CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); - CFX_FxgeDevice ge; - if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)leftPosition * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 1, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(6, 5); - iLen = tempStr.GetLength(); - CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); - ge.FillRect(&rect2, m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, - m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1( - 1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 6, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(0, 1); - iLen = tempStr.GetLength(); - strWidth = (FX_FLOAT)multiple * 7; - if (pOutBitmap == NULL) { - strWidth = strWidth * m_outputHScale; - } - CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - tempStr = str.Mid(11, 1); - iLen = tempStr.GetLength(); - CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); - if (pOutBitmap) { - delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); - ge.GetBitmap()->Clear(m_backgroundColor); - ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, - CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, - (CFX_Matrix*)&affine_matrix, m_fontColor, - FXTEXT_CLEARTYPE); - geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, - m_Height - iTextHeight); - } else { - CFX_Matrix affine_matrix1( - 1.0, 0.0, 0.0, -1.0, - (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, - (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); - if (matrix) { - affine_matrix1.Concat(*matrix); - } - device->DrawNormalText(iLen, pCharPos + 11, m_pFont, - CFX_GEModule::Get()->GetFontCache(), - (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, - m_fontColor, FXTEXT_CLEARTYPE); - } - FX_Free(pCharPos); -} -void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e) { - CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); -} diff --git a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h b/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h deleted file mode 100644 index 6146425b0b..0000000000 --- a/xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ -#define XFA_SRC_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ - -class CBC_OnedEAN13Writer; -class CBC_OnedUPCAWriter; -class CBC_OnedUPCAWriter : public CBC_OneDimWriter { - private: - CBC_OnedEAN13Writer* m_subWriter; - - public: - CBC_OnedUPCAWriter(); - virtual ~CBC_OnedUPCAWriter(); - virtual void Init(); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - int32_t& outLength, - int32_t& e) { - return nullptr; - } - void RenderResult(const CFX_WideStringC& contents, - uint8_t* code, - int32_t codeLength, - FX_BOOL isDevice, - int32_t& e); - FX_BOOL CheckContentValidity(const CFX_WideStringC& contents); - CFX_WideString FilterContents(const CFX_WideStringC& contents); - int32_t CalcChecksum(const CFX_ByteString& contents); - - protected: - void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp deleted file mode 100644 index c06f8112da..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp +++ /dev/null @@ -1,586 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" -#include "xfa/src/fxbarcode/utils.h" - -int32_t CBC_PDF417::START_PATTERN = 0x1fea8; -int32_t CBC_PDF417::STOP_PATTERN = 0x3fa29; -int32_t CBC_PDF417::CODEWORD_TABLE[][1000] = { - {0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470, - 0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, - 0x1d678, 0x1eb3e, 0x158c0, 0x1ac70, 0x15860, 0x15dc0, 0x1aef0, 0x1d77c, - 0x15ce0, 0x1ae78, 0x1d73e, 0x15c70, 0x1ae3c, 0x15ef0, 0x1af7c, 0x15e78, - 0x1af3e, 0x15f7c, 0x1f5fa, 0x1d2e0, 0x1e978, 0x1f4be, 0x1a4c0, 0x1d270, - 0x1e93c, 0x1a460, 0x1d238, 0x14840, 0x1a430, 0x1d21c, 0x14820, 0x1a418, - 0x14810, 0x1a6e0, 0x1d378, 0x1e9be, 0x14cc0, 0x1a670, 0x1d33c, 0x14c60, - 0x1a638, 0x1d31e, 0x14c30, 0x1a61c, 0x14ee0, 0x1a778, 0x1d3be, 0x14e70, - 0x1a73c, 0x14e38, 0x1a71e, 0x14f78, 0x1a7be, 0x14f3c, 0x14f1e, 0x1a2c0, - 0x1d170, 0x1e8bc, 0x1a260, 0x1d138, 0x1e89e, 0x14440, 0x1a230, 0x1d11c, - 0x14420, 0x1a218, 0x14410, 0x14408, 0x146c0, 0x1a370, 0x1d1bc, 0x14660, - 0x1a338, 0x1d19e, 0x14630, 0x1a31c, 0x14618, 0x1460c, 0x14770, 0x1a3bc, - 0x14738, 0x1a39e, 0x1471c, 0x147bc, 0x1a160, 0x1d0b8, 0x1e85e, 0x14240, - 0x1a130, 0x1d09c, 0x14220, 0x1a118, 0x1d08e, 0x14210, 0x1a10c, 0x14208, - 0x1a106, 0x14360, 0x1a1b8, 0x1d0de, 0x14330, 0x1a19c, 0x14318, 0x1a18e, - 0x1430c, 0x14306, 0x1a1de, 0x1438e, 0x14140, 0x1a0b0, 0x1d05c, 0x14120, - 0x1a098, 0x1d04e, 0x14110, 0x1a08c, 0x14108, 0x1a086, 0x14104, 0x141b0, - 0x14198, 0x1418c, 0x140a0, 0x1d02e, 0x1a04c, 0x1a046, 0x14082, 0x1cae0, - 0x1e578, 0x1f2be, 0x194c0, 0x1ca70, 0x1e53c, 0x19460, 0x1ca38, 0x1e51e, - 0x12840, 0x19430, 0x12820, 0x196e0, 0x1cb78, 0x1e5be, 0x12cc0, 0x19670, - 0x1cb3c, 0x12c60, 0x19638, 0x12c30, 0x12c18, 0x12ee0, 0x19778, 0x1cbbe, - 0x12e70, 0x1973c, 0x12e38, 0x12e1c, 0x12f78, 0x197be, 0x12f3c, 0x12fbe, - 0x1dac0, 0x1ed70, 0x1f6bc, 0x1da60, 0x1ed38, 0x1f69e, 0x1b440, 0x1da30, - 0x1ed1c, 0x1b420, 0x1da18, 0x1ed0e, 0x1b410, 0x1da0c, 0x192c0, 0x1c970, - 0x1e4bc, 0x1b6c0, 0x19260, 0x1c938, 0x1e49e, 0x1b660, 0x1db38, 0x1ed9e, - 0x16c40, 0x12420, 0x19218, 0x1c90e, 0x16c20, 0x1b618, 0x16c10, 0x126c0, - 0x19370, 0x1c9bc, 0x16ec0, 0x12660, 0x19338, 0x1c99e, 0x16e60, 0x1b738, - 0x1db9e, 0x16e30, 0x12618, 0x16e18, 0x12770, 0x193bc, 0x16f70, 0x12738, - 0x1939e, 0x16f38, 0x1b79e, 0x16f1c, 0x127bc, 0x16fbc, 0x1279e, 0x16f9e, - 0x1d960, 0x1ecb8, 0x1f65e, 0x1b240, 0x1d930, 0x1ec9c, 0x1b220, 0x1d918, - 0x1ec8e, 0x1b210, 0x1d90c, 0x1b208, 0x1b204, 0x19160, 0x1c8b8, 0x1e45e, - 0x1b360, 0x19130, 0x1c89c, 0x16640, 0x12220, 0x1d99c, 0x1c88e, 0x16620, - 0x12210, 0x1910c, 0x16610, 0x1b30c, 0x19106, 0x12204, 0x12360, 0x191b8, - 0x1c8de, 0x16760, 0x12330, 0x1919c, 0x16730, 0x1b39c, 0x1918e, 0x16718, - 0x1230c, 0x12306, 0x123b8, 0x191de, 0x167b8, 0x1239c, 0x1679c, 0x1238e, - 0x1678e, 0x167de, 0x1b140, 0x1d8b0, 0x1ec5c, 0x1b120, 0x1d898, 0x1ec4e, - 0x1b110, 0x1d88c, 0x1b108, 0x1d886, 0x1b104, 0x1b102, 0x12140, 0x190b0, - 0x1c85c, 0x16340, 0x12120, 0x19098, 0x1c84e, 0x16320, 0x1b198, 0x1d8ce, - 0x16310, 0x12108, 0x19086, 0x16308, 0x1b186, 0x16304, 0x121b0, 0x190dc, - 0x163b0, 0x12198, 0x190ce, 0x16398, 0x1b1ce, 0x1638c, 0x12186, 0x16386, - 0x163dc, 0x163ce, 0x1b0a0, 0x1d858, 0x1ec2e, 0x1b090, 0x1d84c, 0x1b088, - 0x1d846, 0x1b084, 0x1b082, 0x120a0, 0x19058, 0x1c82e, 0x161a0, 0x12090, - 0x1904c, 0x16190, 0x1b0cc, 0x19046, 0x16188, 0x12084, 0x16184, 0x12082, - 0x120d8, 0x161d8, 0x161cc, 0x161c6, 0x1d82c, 0x1d826, 0x1b042, 0x1902c, - 0x12048, 0x160c8, 0x160c4, 0x160c2, 0x18ac0, 0x1c570, 0x1e2bc, 0x18a60, - 0x1c538, 0x11440, 0x18a30, 0x1c51c, 0x11420, 0x18a18, 0x11410, 0x11408, - 0x116c0, 0x18b70, 0x1c5bc, 0x11660, 0x18b38, 0x1c59e, 0x11630, 0x18b1c, - 0x11618, 0x1160c, 0x11770, 0x18bbc, 0x11738, 0x18b9e, 0x1171c, 0x117bc, - 0x1179e, 0x1cd60, 0x1e6b8, 0x1f35e, 0x19a40, 0x1cd30, 0x1e69c, 0x19a20, - 0x1cd18, 0x1e68e, 0x19a10, 0x1cd0c, 0x19a08, 0x1cd06, 0x18960, 0x1c4b8, - 0x1e25e, 0x19b60, 0x18930, 0x1c49c, 0x13640, 0x11220, 0x1cd9c, 0x1c48e, - 0x13620, 0x19b18, 0x1890c, 0x13610, 0x11208, 0x13608, 0x11360, 0x189b8, - 0x1c4de, 0x13760, 0x11330, 0x1cdde, 0x13730, 0x19b9c, 0x1898e, 0x13718, - 0x1130c, 0x1370c, 0x113b8, 0x189de, 0x137b8, 0x1139c, 0x1379c, 0x1138e, - 0x113de, 0x137de, 0x1dd40, 0x1eeb0, 0x1f75c, 0x1dd20, 0x1ee98, 0x1f74e, - 0x1dd10, 0x1ee8c, 0x1dd08, 0x1ee86, 0x1dd04, 0x19940, 0x1ccb0, 0x1e65c, - 0x1bb40, 0x19920, 0x1eedc, 0x1e64e, 0x1bb20, 0x1dd98, 0x1eece, 0x1bb10, - 0x19908, 0x1cc86, 0x1bb08, 0x1dd86, 0x19902, 0x11140, 0x188b0, 0x1c45c, - 0x13340, 0x11120, 0x18898, 0x1c44e, 0x17740, 0x13320, 0x19998, 0x1ccce, - 0x17720, 0x1bb98, 0x1ddce, 0x18886, 0x17710, 0x13308, 0x19986, 0x17708, - 0x11102, 0x111b0, 0x188dc, 0x133b0, 0x11198, 0x188ce, 0x177b0, 0x13398, - 0x199ce, 0x17798, 0x1bbce, 0x11186, 0x13386, 0x111dc, 0x133dc, 0x111ce, - 0x177dc, 0x133ce, 0x1dca0, 0x1ee58, 0x1f72e, 0x1dc90, 0x1ee4c, 0x1dc88, - 0x1ee46, 0x1dc84, 0x1dc82, 0x198a0, 0x1cc58, 0x1e62e, 0x1b9a0, 0x19890, - 0x1ee6e, 0x1b990, 0x1dccc, 0x1cc46, 0x1b988, 0x19884, 0x1b984, 0x19882, - 0x1b982, 0x110a0, 0x18858, 0x1c42e, 0x131a0, 0x11090, 0x1884c, 0x173a0, - 0x13190, 0x198cc, 0x18846, 0x17390, 0x1b9cc, 0x11084, 0x17388, 0x13184, - 0x11082, 0x13182, 0x110d8, 0x1886e, 0x131d8, 0x110cc, 0x173d8, 0x131cc, - 0x110c6, 0x173cc, 0x131c6, 0x110ee, 0x173ee, 0x1dc50, 0x1ee2c, 0x1dc48, - 0x1ee26, 0x1dc44, 0x1dc42, 0x19850, 0x1cc2c, 0x1b8d0, 0x19848, 0x1cc26, - 0x1b8c8, 0x1dc66, 0x1b8c4, 0x19842, 0x1b8c2, 0x11050, 0x1882c, 0x130d0, - 0x11048, 0x18826, 0x171d0, 0x130c8, 0x19866, 0x171c8, 0x1b8e6, 0x11042, - 0x171c4, 0x130c2, 0x171c2, 0x130ec, 0x171ec, 0x171e6, 0x1ee16, 0x1dc22, - 0x1cc16, 0x19824, 0x19822, 0x11028, 0x13068, 0x170e8, 0x11022, 0x13062, - 0x18560, 0x10a40, 0x18530, 0x10a20, 0x18518, 0x1c28e, 0x10a10, 0x1850c, - 0x10a08, 0x18506, 0x10b60, 0x185b8, 0x1c2de, 0x10b30, 0x1859c, 0x10b18, - 0x1858e, 0x10b0c, 0x10b06, 0x10bb8, 0x185de, 0x10b9c, 0x10b8e, 0x10bde, - 0x18d40, 0x1c6b0, 0x1e35c, 0x18d20, 0x1c698, 0x18d10, 0x1c68c, 0x18d08, - 0x1c686, 0x18d04, 0x10940, 0x184b0, 0x1c25c, 0x11b40, 0x10920, 0x1c6dc, - 0x1c24e, 0x11b20, 0x18d98, 0x1c6ce, 0x11b10, 0x10908, 0x18486, 0x11b08, - 0x18d86, 0x10902, 0x109b0, 0x184dc, 0x11bb0, 0x10998, 0x184ce, 0x11b98, - 0x18dce, 0x11b8c, 0x10986, 0x109dc, 0x11bdc, 0x109ce, 0x11bce, 0x1cea0, - 0x1e758, 0x1f3ae, 0x1ce90, 0x1e74c, 0x1ce88, 0x1e746, 0x1ce84, 0x1ce82, - 0x18ca0, 0x1c658, 0x19da0, 0x18c90, 0x1c64c, 0x19d90, 0x1cecc, 0x1c646, - 0x19d88, 0x18c84, 0x19d84, 0x18c82, 0x19d82, 0x108a0, 0x18458, 0x119a0, - 0x10890, 0x1c66e, 0x13ba0, 0x11990, 0x18ccc, 0x18446, 0x13b90, 0x19dcc, - 0x10884, 0x13b88, 0x11984, 0x10882, 0x11982, 0x108d8, 0x1846e, 0x119d8, - 0x108cc, 0x13bd8, 0x119cc, 0x108c6, 0x13bcc, 0x119c6, 0x108ee, 0x119ee, - 0x13bee, 0x1ef50, 0x1f7ac, 0x1ef48, 0x1f7a6, 0x1ef44, 0x1ef42, 0x1ce50, - 0x1e72c, 0x1ded0, 0x1ef6c, 0x1e726, 0x1dec8, 0x1ef66, 0x1dec4, 0x1ce42, - 0x1dec2, 0x18c50, 0x1c62c, 0x19cd0, 0x18c48, 0x1c626, 0x1bdd0, 0x19cc8, - 0x1ce66, 0x1bdc8, 0x1dee6, 0x18c42, 0x1bdc4, 0x19cc2, 0x1bdc2, 0x10850, - 0x1842c, 0x118d0, 0x10848, 0x18426, 0x139d0, 0x118c8, 0x18c66, 0x17bd0, - 0x139c8, 0x19ce6, 0x10842, 0x17bc8, 0x1bde6, 0x118c2, 0x17bc4, 0x1086c, - 0x118ec, 0x10866, 0x139ec, 0x118e6, 0x17bec, 0x139e6, 0x17be6, 0x1ef28, - 0x1f796, 0x1ef24, 0x1ef22, 0x1ce28, 0x1e716, 0x1de68, 0x1ef36, 0x1de64, - 0x1ce22, 0x1de62, 0x18c28, 0x1c616, 0x19c68, 0x18c24, 0x1bce8, 0x19c64, - 0x18c22, 0x1bce4, 0x19c62, 0x1bce2, 0x10828, 0x18416, 0x11868, 0x18c36, - 0x138e8, 0x11864, 0x10822, 0x179e8, 0x138e4, 0x11862, 0x179e4, 0x138e2, - 0x179e2, 0x11876, 0x179f6, 0x1ef12, 0x1de34, 0x1de32, 0x19c34, 0x1bc74, - 0x1bc72, 0x11834, 0x13874, 0x178f4, 0x178f2, 0x10540, 0x10520, 0x18298, - 0x10510, 0x10508, 0x10504, 0x105b0, 0x10598, 0x1058c, 0x10586, 0x105dc, - 0x105ce, 0x186a0, 0x18690, 0x1c34c, 0x18688, 0x1c346, 0x18684, 0x18682, - 0x104a0, 0x18258, 0x10da0, 0x186d8, 0x1824c, 0x10d90, 0x186cc, 0x10d88, - 0x186c6, 0x10d84, 0x10482, 0x10d82, 0x104d8, 0x1826e, 0x10dd8, 0x186ee, - 0x10dcc, 0x104c6, 0x10dc6, 0x104ee, 0x10dee, 0x1c750, 0x1c748, 0x1c744, - 0x1c742, 0x18650, 0x18ed0, 0x1c76c, 0x1c326, 0x18ec8, 0x1c766, 0x18ec4, - 0x18642, 0x18ec2, 0x10450, 0x10cd0, 0x10448, 0x18226, 0x11dd0, 0x10cc8, - 0x10444, 0x11dc8, 0x10cc4, 0x10442, 0x11dc4, 0x10cc2, 0x1046c, 0x10cec, - 0x10466, 0x11dec, 0x10ce6, 0x11de6, 0x1e7a8, 0x1e7a4, 0x1e7a2, 0x1c728, - 0x1cf68, 0x1e7b6, 0x1cf64, 0x1c722, 0x1cf62, 0x18628, 0x1c316, 0x18e68, - 0x1c736, 0x19ee8, 0x18e64, 0x18622, 0x19ee4, 0x18e62, 0x19ee2, 0x10428, - 0x18216, 0x10c68, 0x18636, 0x11ce8, 0x10c64, 0x10422, 0x13de8, 0x11ce4, - 0x10c62, 0x13de4, 0x11ce2, 0x10436, 0x10c76, 0x11cf6, 0x13df6, 0x1f7d4, - 0x1f7d2, 0x1e794, 0x1efb4, 0x1e792, 0x1efb2, 0x1c714, 0x1cf34, 0x1c712, - 0x1df74, 0x1cf32, 0x1df72, 0x18614, 0x18e34, 0x18612, 0x19e74, 0x18e32, - 0x1bef4}, - {0x1f560, 0x1fab8, 0x1ea40, 0x1f530, 0x1fa9c, 0x1ea20, 0x1f518, 0x1fa8e, - 0x1ea10, 0x1f50c, 0x1ea08, 0x1f506, 0x1ea04, 0x1eb60, 0x1f5b8, 0x1fade, - 0x1d640, 0x1eb30, 0x1f59c, 0x1d620, 0x1eb18, 0x1f58e, 0x1d610, 0x1eb0c, - 0x1d608, 0x1eb06, 0x1d604, 0x1d760, 0x1ebb8, 0x1f5de, 0x1ae40, 0x1d730, - 0x1eb9c, 0x1ae20, 0x1d718, 0x1eb8e, 0x1ae10, 0x1d70c, 0x1ae08, 0x1d706, - 0x1ae04, 0x1af60, 0x1d7b8, 0x1ebde, 0x15e40, 0x1af30, 0x1d79c, 0x15e20, - 0x1af18, 0x1d78e, 0x15e10, 0x1af0c, 0x15e08, 0x1af06, 0x15f60, 0x1afb8, - 0x1d7de, 0x15f30, 0x1af9c, 0x15f18, 0x1af8e, 0x15f0c, 0x15fb8, 0x1afde, - 0x15f9c, 0x15f8e, 0x1e940, 0x1f4b0, 0x1fa5c, 0x1e920, 0x1f498, 0x1fa4e, - 0x1e910, 0x1f48c, 0x1e908, 0x1f486, 0x1e904, 0x1e902, 0x1d340, 0x1e9b0, - 0x1f4dc, 0x1d320, 0x1e998, 0x1f4ce, 0x1d310, 0x1e98c, 0x1d308, 0x1e986, - 0x1d304, 0x1d302, 0x1a740, 0x1d3b0, 0x1e9dc, 0x1a720, 0x1d398, 0x1e9ce, - 0x1a710, 0x1d38c, 0x1a708, 0x1d386, 0x1a704, 0x1a702, 0x14f40, 0x1a7b0, - 0x1d3dc, 0x14f20, 0x1a798, 0x1d3ce, 0x14f10, 0x1a78c, 0x14f08, 0x1a786, - 0x14f04, 0x14fb0, 0x1a7dc, 0x14f98, 0x1a7ce, 0x14f8c, 0x14f86, 0x14fdc, - 0x14fce, 0x1e8a0, 0x1f458, 0x1fa2e, 0x1e890, 0x1f44c, 0x1e888, 0x1f446, - 0x1e884, 0x1e882, 0x1d1a0, 0x1e8d8, 0x1f46e, 0x1d190, 0x1e8cc, 0x1d188, - 0x1e8c6, 0x1d184, 0x1d182, 0x1a3a0, 0x1d1d8, 0x1e8ee, 0x1a390, 0x1d1cc, - 0x1a388, 0x1d1c6, 0x1a384, 0x1a382, 0x147a0, 0x1a3d8, 0x1d1ee, 0x14790, - 0x1a3cc, 0x14788, 0x1a3c6, 0x14784, 0x14782, 0x147d8, 0x1a3ee, 0x147cc, - 0x147c6, 0x147ee, 0x1e850, 0x1f42c, 0x1e848, 0x1f426, 0x1e844, 0x1e842, - 0x1d0d0, 0x1e86c, 0x1d0c8, 0x1e866, 0x1d0c4, 0x1d0c2, 0x1a1d0, 0x1d0ec, - 0x1a1c8, 0x1d0e6, 0x1a1c4, 0x1a1c2, 0x143d0, 0x1a1ec, 0x143c8, 0x1a1e6, - 0x143c4, 0x143c2, 0x143ec, 0x143e6, 0x1e828, 0x1f416, 0x1e824, 0x1e822, - 0x1d068, 0x1e836, 0x1d064, 0x1d062, 0x1a0e8, 0x1d076, 0x1a0e4, 0x1a0e2, - 0x141e8, 0x1a0f6, 0x141e4, 0x141e2, 0x1e814, 0x1e812, 0x1d034, 0x1d032, - 0x1a074, 0x1a072, 0x1e540, 0x1f2b0, 0x1f95c, 0x1e520, 0x1f298, 0x1f94e, - 0x1e510, 0x1f28c, 0x1e508, 0x1f286, 0x1e504, 0x1e502, 0x1cb40, 0x1e5b0, - 0x1f2dc, 0x1cb20, 0x1e598, 0x1f2ce, 0x1cb10, 0x1e58c, 0x1cb08, 0x1e586, - 0x1cb04, 0x1cb02, 0x19740, 0x1cbb0, 0x1e5dc, 0x19720, 0x1cb98, 0x1e5ce, - 0x19710, 0x1cb8c, 0x19708, 0x1cb86, 0x19704, 0x19702, 0x12f40, 0x197b0, - 0x1cbdc, 0x12f20, 0x19798, 0x1cbce, 0x12f10, 0x1978c, 0x12f08, 0x19786, - 0x12f04, 0x12fb0, 0x197dc, 0x12f98, 0x197ce, 0x12f8c, 0x12f86, 0x12fdc, - 0x12fce, 0x1f6a0, 0x1fb58, 0x16bf0, 0x1f690, 0x1fb4c, 0x169f8, 0x1f688, - 0x1fb46, 0x168fc, 0x1f684, 0x1f682, 0x1e4a0, 0x1f258, 0x1f92e, 0x1eda0, - 0x1e490, 0x1fb6e, 0x1ed90, 0x1f6cc, 0x1f246, 0x1ed88, 0x1e484, 0x1ed84, - 0x1e482, 0x1ed82, 0x1c9a0, 0x1e4d8, 0x1f26e, 0x1dba0, 0x1c990, 0x1e4cc, - 0x1db90, 0x1edcc, 0x1e4c6, 0x1db88, 0x1c984, 0x1db84, 0x1c982, 0x1db82, - 0x193a0, 0x1c9d8, 0x1e4ee, 0x1b7a0, 0x19390, 0x1c9cc, 0x1b790, 0x1dbcc, - 0x1c9c6, 0x1b788, 0x19384, 0x1b784, 0x19382, 0x1b782, 0x127a0, 0x193d8, - 0x1c9ee, 0x16fa0, 0x12790, 0x193cc, 0x16f90, 0x1b7cc, 0x193c6, 0x16f88, - 0x12784, 0x16f84, 0x12782, 0x127d8, 0x193ee, 0x16fd8, 0x127cc, 0x16fcc, - 0x127c6, 0x16fc6, 0x127ee, 0x1f650, 0x1fb2c, 0x165f8, 0x1f648, 0x1fb26, - 0x164fc, 0x1f644, 0x1647e, 0x1f642, 0x1e450, 0x1f22c, 0x1ecd0, 0x1e448, - 0x1f226, 0x1ecc8, 0x1f666, 0x1ecc4, 0x1e442, 0x1ecc2, 0x1c8d0, 0x1e46c, - 0x1d9d0, 0x1c8c8, 0x1e466, 0x1d9c8, 0x1ece6, 0x1d9c4, 0x1c8c2, 0x1d9c2, - 0x191d0, 0x1c8ec, 0x1b3d0, 0x191c8, 0x1c8e6, 0x1b3c8, 0x1d9e6, 0x1b3c4, - 0x191c2, 0x1b3c2, 0x123d0, 0x191ec, 0x167d0, 0x123c8, 0x191e6, 0x167c8, - 0x1b3e6, 0x167c4, 0x123c2, 0x167c2, 0x123ec, 0x167ec, 0x123e6, 0x167e6, - 0x1f628, 0x1fb16, 0x162fc, 0x1f624, 0x1627e, 0x1f622, 0x1e428, 0x1f216, - 0x1ec68, 0x1f636, 0x1ec64, 0x1e422, 0x1ec62, 0x1c868, 0x1e436, 0x1d8e8, - 0x1c864, 0x1d8e4, 0x1c862, 0x1d8e2, 0x190e8, 0x1c876, 0x1b1e8, 0x1d8f6, - 0x1b1e4, 0x190e2, 0x1b1e2, 0x121e8, 0x190f6, 0x163e8, 0x121e4, 0x163e4, - 0x121e2, 0x163e2, 0x121f6, 0x163f6, 0x1f614, 0x1617e, 0x1f612, 0x1e414, - 0x1ec34, 0x1e412, 0x1ec32, 0x1c834, 0x1d874, 0x1c832, 0x1d872, 0x19074, - 0x1b0f4, 0x19072, 0x1b0f2, 0x120f4, 0x161f4, 0x120f2, 0x161f2, 0x1f60a, - 0x1e40a, 0x1ec1a, 0x1c81a, 0x1d83a, 0x1903a, 0x1b07a, 0x1e2a0, 0x1f158, - 0x1f8ae, 0x1e290, 0x1f14c, 0x1e288, 0x1f146, 0x1e284, 0x1e282, 0x1c5a0, - 0x1e2d8, 0x1f16e, 0x1c590, 0x1e2cc, 0x1c588, 0x1e2c6, 0x1c584, 0x1c582, - 0x18ba0, 0x1c5d8, 0x1e2ee, 0x18b90, 0x1c5cc, 0x18b88, 0x1c5c6, 0x18b84, - 0x18b82, 0x117a0, 0x18bd8, 0x1c5ee, 0x11790, 0x18bcc, 0x11788, 0x18bc6, - 0x11784, 0x11782, 0x117d8, 0x18bee, 0x117cc, 0x117c6, 0x117ee, 0x1f350, - 0x1f9ac, 0x135f8, 0x1f348, 0x1f9a6, 0x134fc, 0x1f344, 0x1347e, 0x1f342, - 0x1e250, 0x1f12c, 0x1e6d0, 0x1e248, 0x1f126, 0x1e6c8, 0x1f366, 0x1e6c4, - 0x1e242, 0x1e6c2, 0x1c4d0, 0x1e26c, 0x1cdd0, 0x1c4c8, 0x1e266, 0x1cdc8, - 0x1e6e6, 0x1cdc4, 0x1c4c2, 0x1cdc2, 0x189d0, 0x1c4ec, 0x19bd0, 0x189c8, - 0x1c4e6, 0x19bc8, 0x1cde6, 0x19bc4, 0x189c2, 0x19bc2, 0x113d0, 0x189ec, - 0x137d0, 0x113c8, 0x189e6, 0x137c8, 0x19be6, 0x137c4, 0x113c2, 0x137c2, - 0x113ec, 0x137ec, 0x113e6, 0x137e6, 0x1fba8, 0x175f0, 0x1bafc, 0x1fba4, - 0x174f8, 0x1ba7e, 0x1fba2, 0x1747c, 0x1743e, 0x1f328, 0x1f996, 0x132fc, - 0x1f768, 0x1fbb6, 0x176fc, 0x1327e, 0x1f764, 0x1f322, 0x1767e, 0x1f762, - 0x1e228, 0x1f116, 0x1e668, 0x1e224, 0x1eee8, 0x1f776, 0x1e222, 0x1eee4, - 0x1e662, 0x1eee2, 0x1c468, 0x1e236, 0x1cce8, 0x1c464, 0x1dde8, 0x1cce4, - 0x1c462, 0x1dde4, 0x1cce2, 0x1dde2, 0x188e8, 0x1c476, 0x199e8, 0x188e4, - 0x1bbe8, 0x199e4, 0x188e2, 0x1bbe4, 0x199e2, 0x1bbe2, 0x111e8, 0x188f6, - 0x133e8, 0x111e4, 0x177e8, 0x133e4, 0x111e2, 0x177e4, 0x133e2, 0x177e2, - 0x111f6, 0x133f6, 0x1fb94, 0x172f8, 0x1b97e, 0x1fb92, 0x1727c, 0x1723e, - 0x1f314, 0x1317e, 0x1f734, 0x1f312, 0x1737e, 0x1f732, 0x1e214, 0x1e634, - 0x1e212, 0x1ee74, 0x1e632, 0x1ee72, 0x1c434, 0x1cc74, 0x1c432, 0x1dcf4, - 0x1cc72, 0x1dcf2, 0x18874, 0x198f4, 0x18872, 0x1b9f4, 0x198f2, 0x1b9f2, - 0x110f4, 0x131f4, 0x110f2, 0x173f4, 0x131f2, 0x173f2, 0x1fb8a, 0x1717c, - 0x1713e, 0x1f30a, 0x1f71a, 0x1e20a, 0x1e61a, 0x1ee3a, 0x1c41a, 0x1cc3a, - 0x1dc7a, 0x1883a, 0x1987a, 0x1b8fa, 0x1107a, 0x130fa, 0x171fa, 0x170be, - 0x1e150, 0x1f0ac, 0x1e148, 0x1f0a6, 0x1e144, 0x1e142, 0x1c2d0, 0x1e16c, - 0x1c2c8, 0x1e166, 0x1c2c4, 0x1c2c2, 0x185d0, 0x1c2ec, 0x185c8, 0x1c2e6, - 0x185c4, 0x185c2, 0x10bd0, 0x185ec, 0x10bc8, 0x185e6, 0x10bc4, 0x10bc2, - 0x10bec, 0x10be6, 0x1f1a8, 0x1f8d6, 0x11afc, 0x1f1a4, 0x11a7e, 0x1f1a2, - 0x1e128, 0x1f096, 0x1e368, 0x1e124, 0x1e364, 0x1e122, 0x1e362, 0x1c268, - 0x1e136, 0x1c6e8, 0x1c264, 0x1c6e4, 0x1c262, 0x1c6e2, 0x184e8, 0x1c276, - 0x18de8, 0x184e4, 0x18de4, 0x184e2, 0x18de2, 0x109e8, 0x184f6, 0x11be8, - 0x109e4, 0x11be4, 0x109e2, 0x11be2, 0x109f6, 0x11bf6, 0x1f9d4, 0x13af8, - 0x19d7e, 0x1f9d2, 0x13a7c, 0x13a3e, 0x1f194, 0x1197e, 0x1f3b4, 0x1f192, - 0x13b7e, 0x1f3b2, 0x1e114, 0x1e334, 0x1e112, 0x1e774, 0x1e332, 0x1e772, - 0x1c234, 0x1c674, 0x1c232, 0x1cef4, 0x1c672, 0x1cef2, 0x18474, 0x18cf4, - 0x18472, 0x19df4, 0x18cf2, 0x19df2, 0x108f4, 0x119f4, 0x108f2, 0x13bf4, - 0x119f2, 0x13bf2, 0x17af0, 0x1bd7c, 0x17a78, 0x1bd3e, 0x17a3c, 0x17a1e, - 0x1f9ca, 0x1397c, 0x1fbda, 0x17b7c, 0x1393e, 0x17b3e, 0x1f18a, 0x1f39a, - 0x1f7ba, 0x1e10a, 0x1e31a, 0x1e73a, 0x1ef7a, 0x1c21a, 0x1c63a, 0x1ce7a, - 0x1defa, 0x1843a, 0x18c7a, 0x19cfa, 0x1bdfa, 0x1087a, 0x118fa, 0x139fa, - 0x17978, 0x1bcbe, 0x1793c, 0x1791e, 0x138be, 0x179be, 0x178bc, 0x1789e, - 0x1785e, 0x1e0a8, 0x1e0a4, 0x1e0a2, 0x1c168, 0x1e0b6, 0x1c164, 0x1c162, - 0x182e8, 0x1c176, 0x182e4, 0x182e2, 0x105e8, 0x182f6, 0x105e4, 0x105e2, - 0x105f6, 0x1f0d4, 0x10d7e, 0x1f0d2, 0x1e094, 0x1e1b4, 0x1e092, 0x1e1b2, - 0x1c134, 0x1c374, 0x1c132, 0x1c372, 0x18274, 0x186f4, 0x18272, 0x186f2, - 0x104f4, 0x10df4, 0x104f2, 0x10df2, 0x1f8ea, 0x11d7c, 0x11d3e, 0x1f0ca, - 0x1f1da, 0x1e08a, 0x1e19a, 0x1e3ba, 0x1c11a, 0x1c33a, 0x1c77a, 0x1823a, - 0x1867a, 0x18efa, 0x1047a, 0x10cfa, 0x11dfa, 0x13d78, 0x19ebe, 0x13d3c, - 0x13d1e, 0x11cbe, 0x13dbe, 0x17d70, 0x1bebc, 0x17d38, 0x1be9e, 0x17d1c, - 0x17d0e, 0x13cbc, 0x17dbc, 0x13c9e, 0x17d9e, 0x17cb8, 0x1be5e, 0x17c9c, - 0x17c8e, 0x13c5e, 0x17cde, 0x17c5c, 0x17c4e, 0x17c2e, 0x1c0b4, 0x1c0b2, - 0x18174, 0x18172, 0x102f4, 0x102f2, 0x1e0da, 0x1c09a, 0x1c1ba, 0x1813a, - 0x1837a, 0x1027a, 0x106fa, 0x10ebe, 0x11ebc, 0x11e9e, 0x13eb8, 0x19f5e, - 0x13e9c, 0x13e8e, 0x11e5e, 0x13ede, 0x17eb0, 0x1bf5c, 0x17e98, 0x1bf4e, - 0x17e8c, 0x17e86, 0x13e5c, 0x17edc, 0x13e4e, 0x17ece, 0x17e58, 0x1bf2e, - 0x17e4c, 0x17e46, 0x13e2e, 0x17e6e, 0x17e2c, 0x17e26, 0x10f5e, 0x11f5c, - 0x11f4e, 0x13f58, 0x19fae, 0x13f4c, 0x13f46, 0x11f2e, 0x13f6e, 0x13f2c, - 0x13f26}, - {0x1abe0, 0x1d5f8, 0x153c0, 0x1a9f0, 0x1d4fc, 0x151e0, 0x1a8f8, 0x1d47e, - 0x150f0, 0x1a87c, 0x15078, 0x1fad0, 0x15be0, 0x1adf8, 0x1fac8, 0x159f0, - 0x1acfc, 0x1fac4, 0x158f8, 0x1ac7e, 0x1fac2, 0x1587c, 0x1f5d0, 0x1faec, - 0x15df8, 0x1f5c8, 0x1fae6, 0x15cfc, 0x1f5c4, 0x15c7e, 0x1f5c2, 0x1ebd0, - 0x1f5ec, 0x1ebc8, 0x1f5e6, 0x1ebc4, 0x1ebc2, 0x1d7d0, 0x1ebec, 0x1d7c8, - 0x1ebe6, 0x1d7c4, 0x1d7c2, 0x1afd0, 0x1d7ec, 0x1afc8, 0x1d7e6, 0x1afc4, - 0x14bc0, 0x1a5f0, 0x1d2fc, 0x149e0, 0x1a4f8, 0x1d27e, 0x148f0, 0x1a47c, - 0x14878, 0x1a43e, 0x1483c, 0x1fa68, 0x14df0, 0x1a6fc, 0x1fa64, 0x14cf8, - 0x1a67e, 0x1fa62, 0x14c7c, 0x14c3e, 0x1f4e8, 0x1fa76, 0x14efc, 0x1f4e4, - 0x14e7e, 0x1f4e2, 0x1e9e8, 0x1f4f6, 0x1e9e4, 0x1e9e2, 0x1d3e8, 0x1e9f6, - 0x1d3e4, 0x1d3e2, 0x1a7e8, 0x1d3f6, 0x1a7e4, 0x1a7e2, 0x145e0, 0x1a2f8, - 0x1d17e, 0x144f0, 0x1a27c, 0x14478, 0x1a23e, 0x1443c, 0x1441e, 0x1fa34, - 0x146f8, 0x1a37e, 0x1fa32, 0x1467c, 0x1463e, 0x1f474, 0x1477e, 0x1f472, - 0x1e8f4, 0x1e8f2, 0x1d1f4, 0x1d1f2, 0x1a3f4, 0x1a3f2, 0x142f0, 0x1a17c, - 0x14278, 0x1a13e, 0x1423c, 0x1421e, 0x1fa1a, 0x1437c, 0x1433e, 0x1f43a, - 0x1e87a, 0x1d0fa, 0x14178, 0x1a0be, 0x1413c, 0x1411e, 0x141be, 0x140bc, - 0x1409e, 0x12bc0, 0x195f0, 0x1cafc, 0x129e0, 0x194f8, 0x1ca7e, 0x128f0, - 0x1947c, 0x12878, 0x1943e, 0x1283c, 0x1f968, 0x12df0, 0x196fc, 0x1f964, - 0x12cf8, 0x1967e, 0x1f962, 0x12c7c, 0x12c3e, 0x1f2e8, 0x1f976, 0x12efc, - 0x1f2e4, 0x12e7e, 0x1f2e2, 0x1e5e8, 0x1f2f6, 0x1e5e4, 0x1e5e2, 0x1cbe8, - 0x1e5f6, 0x1cbe4, 0x1cbe2, 0x197e8, 0x1cbf6, 0x197e4, 0x197e2, 0x1b5e0, - 0x1daf8, 0x1ed7e, 0x169c0, 0x1b4f0, 0x1da7c, 0x168e0, 0x1b478, 0x1da3e, - 0x16870, 0x1b43c, 0x16838, 0x1b41e, 0x1681c, 0x125e0, 0x192f8, 0x1c97e, - 0x16de0, 0x124f0, 0x1927c, 0x16cf0, 0x1b67c, 0x1923e, 0x16c78, 0x1243c, - 0x16c3c, 0x1241e, 0x16c1e, 0x1f934, 0x126f8, 0x1937e, 0x1fb74, 0x1f932, - 0x16ef8, 0x1267c, 0x1fb72, 0x16e7c, 0x1263e, 0x16e3e, 0x1f274, 0x1277e, - 0x1f6f4, 0x1f272, 0x16f7e, 0x1f6f2, 0x1e4f4, 0x1edf4, 0x1e4f2, 0x1edf2, - 0x1c9f4, 0x1dbf4, 0x1c9f2, 0x1dbf2, 0x193f4, 0x193f2, 0x165c0, 0x1b2f0, - 0x1d97c, 0x164e0, 0x1b278, 0x1d93e, 0x16470, 0x1b23c, 0x16438, 0x1b21e, - 0x1641c, 0x1640e, 0x122f0, 0x1917c, 0x166f0, 0x12278, 0x1913e, 0x16678, - 0x1b33e, 0x1663c, 0x1221e, 0x1661e, 0x1f91a, 0x1237c, 0x1fb3a, 0x1677c, - 0x1233e, 0x1673e, 0x1f23a, 0x1f67a, 0x1e47a, 0x1ecfa, 0x1c8fa, 0x1d9fa, - 0x191fa, 0x162e0, 0x1b178, 0x1d8be, 0x16270, 0x1b13c, 0x16238, 0x1b11e, - 0x1621c, 0x1620e, 0x12178, 0x190be, 0x16378, 0x1213c, 0x1633c, 0x1211e, - 0x1631e, 0x121be, 0x163be, 0x16170, 0x1b0bc, 0x16138, 0x1b09e, 0x1611c, - 0x1610e, 0x120bc, 0x161bc, 0x1209e, 0x1619e, 0x160b8, 0x1b05e, 0x1609c, - 0x1608e, 0x1205e, 0x160de, 0x1605c, 0x1604e, 0x115e0, 0x18af8, 0x1c57e, - 0x114f0, 0x18a7c, 0x11478, 0x18a3e, 0x1143c, 0x1141e, 0x1f8b4, 0x116f8, - 0x18b7e, 0x1f8b2, 0x1167c, 0x1163e, 0x1f174, 0x1177e, 0x1f172, 0x1e2f4, - 0x1e2f2, 0x1c5f4, 0x1c5f2, 0x18bf4, 0x18bf2, 0x135c0, 0x19af0, 0x1cd7c, - 0x134e0, 0x19a78, 0x1cd3e, 0x13470, 0x19a3c, 0x13438, 0x19a1e, 0x1341c, - 0x1340e, 0x112f0, 0x1897c, 0x136f0, 0x11278, 0x1893e, 0x13678, 0x19b3e, - 0x1363c, 0x1121e, 0x1361e, 0x1f89a, 0x1137c, 0x1f9ba, 0x1377c, 0x1133e, - 0x1373e, 0x1f13a, 0x1f37a, 0x1e27a, 0x1e6fa, 0x1c4fa, 0x1cdfa, 0x189fa, - 0x1bae0, 0x1dd78, 0x1eebe, 0x174c0, 0x1ba70, 0x1dd3c, 0x17460, 0x1ba38, - 0x1dd1e, 0x17430, 0x1ba1c, 0x17418, 0x1ba0e, 0x1740c, 0x132e0, 0x19978, - 0x1ccbe, 0x176e0, 0x13270, 0x1993c, 0x17670, 0x1bb3c, 0x1991e, 0x17638, - 0x1321c, 0x1761c, 0x1320e, 0x1760e, 0x11178, 0x188be, 0x13378, 0x1113c, - 0x17778, 0x1333c, 0x1111e, 0x1773c, 0x1331e, 0x1771e, 0x111be, 0x133be, - 0x177be, 0x172c0, 0x1b970, 0x1dcbc, 0x17260, 0x1b938, 0x1dc9e, 0x17230, - 0x1b91c, 0x17218, 0x1b90e, 0x1720c, 0x17206, 0x13170, 0x198bc, 0x17370, - 0x13138, 0x1989e, 0x17338, 0x1b99e, 0x1731c, 0x1310e, 0x1730e, 0x110bc, - 0x131bc, 0x1109e, 0x173bc, 0x1319e, 0x1739e, 0x17160, 0x1b8b8, 0x1dc5e, - 0x17130, 0x1b89c, 0x17118, 0x1b88e, 0x1710c, 0x17106, 0x130b8, 0x1985e, - 0x171b8, 0x1309c, 0x1719c, 0x1308e, 0x1718e, 0x1105e, 0x130de, 0x171de, - 0x170b0, 0x1b85c, 0x17098, 0x1b84e, 0x1708c, 0x17086, 0x1305c, 0x170dc, - 0x1304e, 0x170ce, 0x17058, 0x1b82e, 0x1704c, 0x17046, 0x1302e, 0x1706e, - 0x1702c, 0x17026, 0x10af0, 0x1857c, 0x10a78, 0x1853e, 0x10a3c, 0x10a1e, - 0x10b7c, 0x10b3e, 0x1f0ba, 0x1e17a, 0x1c2fa, 0x185fa, 0x11ae0, 0x18d78, - 0x1c6be, 0x11a70, 0x18d3c, 0x11a38, 0x18d1e, 0x11a1c, 0x11a0e, 0x10978, - 0x184be, 0x11b78, 0x1093c, 0x11b3c, 0x1091e, 0x11b1e, 0x109be, 0x11bbe, - 0x13ac0, 0x19d70, 0x1cebc, 0x13a60, 0x19d38, 0x1ce9e, 0x13a30, 0x19d1c, - 0x13a18, 0x19d0e, 0x13a0c, 0x13a06, 0x11970, 0x18cbc, 0x13b70, 0x11938, - 0x18c9e, 0x13b38, 0x1191c, 0x13b1c, 0x1190e, 0x13b0e, 0x108bc, 0x119bc, - 0x1089e, 0x13bbc, 0x1199e, 0x13b9e, 0x1bd60, 0x1deb8, 0x1ef5e, 0x17a40, - 0x1bd30, 0x1de9c, 0x17a20, 0x1bd18, 0x1de8e, 0x17a10, 0x1bd0c, 0x17a08, - 0x1bd06, 0x17a04, 0x13960, 0x19cb8, 0x1ce5e, 0x17b60, 0x13930, 0x19c9c, - 0x17b30, 0x1bd9c, 0x19c8e, 0x17b18, 0x1390c, 0x17b0c, 0x13906, 0x17b06, - 0x118b8, 0x18c5e, 0x139b8, 0x1189c, 0x17bb8, 0x1399c, 0x1188e, 0x17b9c, - 0x1398e, 0x17b8e, 0x1085e, 0x118de, 0x139de, 0x17bde, 0x17940, 0x1bcb0, - 0x1de5c, 0x17920, 0x1bc98, 0x1de4e, 0x17910, 0x1bc8c, 0x17908, 0x1bc86, - 0x17904, 0x17902, 0x138b0, 0x19c5c, 0x179b0, 0x13898, 0x19c4e, 0x17998, - 0x1bcce, 0x1798c, 0x13886, 0x17986, 0x1185c, 0x138dc, 0x1184e, 0x179dc, - 0x138ce, 0x179ce, 0x178a0, 0x1bc58, 0x1de2e, 0x17890, 0x1bc4c, 0x17888, - 0x1bc46, 0x17884, 0x17882, 0x13858, 0x19c2e, 0x178d8, 0x1384c, 0x178cc, - 0x13846, 0x178c6, 0x1182e, 0x1386e, 0x178ee, 0x17850, 0x1bc2c, 0x17848, - 0x1bc26, 0x17844, 0x17842, 0x1382c, 0x1786c, 0x13826, 0x17866, 0x17828, - 0x1bc16, 0x17824, 0x17822, 0x13816, 0x17836, 0x10578, 0x182be, 0x1053c, - 0x1051e, 0x105be, 0x10d70, 0x186bc, 0x10d38, 0x1869e, 0x10d1c, 0x10d0e, - 0x104bc, 0x10dbc, 0x1049e, 0x10d9e, 0x11d60, 0x18eb8, 0x1c75e, 0x11d30, - 0x18e9c, 0x11d18, 0x18e8e, 0x11d0c, 0x11d06, 0x10cb8, 0x1865e, 0x11db8, - 0x10c9c, 0x11d9c, 0x10c8e, 0x11d8e, 0x1045e, 0x10cde, 0x11dde, 0x13d40, - 0x19eb0, 0x1cf5c, 0x13d20, 0x19e98, 0x1cf4e, 0x13d10, 0x19e8c, 0x13d08, - 0x19e86, 0x13d04, 0x13d02, 0x11cb0, 0x18e5c, 0x13db0, 0x11c98, 0x18e4e, - 0x13d98, 0x19ece, 0x13d8c, 0x11c86, 0x13d86, 0x10c5c, 0x11cdc, 0x10c4e, - 0x13ddc, 0x11cce, 0x13dce, 0x1bea0, 0x1df58, 0x1efae, 0x1be90, 0x1df4c, - 0x1be88, 0x1df46, 0x1be84, 0x1be82, 0x13ca0, 0x19e58, 0x1cf2e, 0x17da0, - 0x13c90, 0x19e4c, 0x17d90, 0x1becc, 0x19e46, 0x17d88, 0x13c84, 0x17d84, - 0x13c82, 0x17d82, 0x11c58, 0x18e2e, 0x13cd8, 0x11c4c, 0x17dd8, 0x13ccc, - 0x11c46, 0x17dcc, 0x13cc6, 0x17dc6, 0x10c2e, 0x11c6e, 0x13cee, 0x17dee, - 0x1be50, 0x1df2c, 0x1be48, 0x1df26, 0x1be44, 0x1be42, 0x13c50, 0x19e2c, - 0x17cd0, 0x13c48, 0x19e26, 0x17cc8, 0x1be66, 0x17cc4, 0x13c42, 0x17cc2, - 0x11c2c, 0x13c6c, 0x11c26, 0x17cec, 0x13c66, 0x17ce6, 0x1be28, 0x1df16, - 0x1be24, 0x1be22, 0x13c28, 0x19e16, 0x17c68, 0x13c24, 0x17c64, 0x13c22, - 0x17c62, 0x11c16, 0x13c36, 0x17c76, 0x1be14, 0x1be12, 0x13c14, 0x17c34, - 0x13c12, 0x17c32, 0x102bc, 0x1029e, 0x106b8, 0x1835e, 0x1069c, 0x1068e, - 0x1025e, 0x106de, 0x10eb0, 0x1875c, 0x10e98, 0x1874e, 0x10e8c, 0x10e86, - 0x1065c, 0x10edc, 0x1064e, 0x10ece, 0x11ea0, 0x18f58, 0x1c7ae, 0x11e90, - 0x18f4c, 0x11e88, 0x18f46, 0x11e84, 0x11e82, 0x10e58, 0x1872e, 0x11ed8, - 0x18f6e, 0x11ecc, 0x10e46, 0x11ec6, 0x1062e, 0x10e6e, 0x11eee, 0x19f50, - 0x1cfac, 0x19f48, 0x1cfa6, 0x19f44, 0x19f42, 0x11e50, 0x18f2c, 0x13ed0, - 0x19f6c, 0x18f26, 0x13ec8, 0x11e44, 0x13ec4, 0x11e42, 0x13ec2, 0x10e2c, - 0x11e6c, 0x10e26, 0x13eec, 0x11e66, 0x13ee6, 0x1dfa8, 0x1efd6, 0x1dfa4, - 0x1dfa2, 0x19f28, 0x1cf96, 0x1bf68, 0x19f24, 0x1bf64, 0x19f22, 0x1bf62, - 0x11e28, 0x18f16, 0x13e68, 0x11e24, 0x17ee8, 0x13e64, 0x11e22, 0x17ee4, - 0x13e62, 0x17ee2, 0x10e16, 0x11e36, 0x13e76, 0x17ef6, 0x1df94, 0x1df92, - 0x19f14, 0x1bf34, 0x19f12, 0x1bf32, 0x11e14, 0x13e34, 0x11e12, 0x17e74, - 0x13e32, 0x17e72, 0x1df8a, 0x19f0a, 0x1bf1a, 0x11e0a, 0x13e1a, 0x17e3a, - 0x1035c, 0x1034e, 0x10758, 0x183ae, 0x1074c, 0x10746, 0x1032e, 0x1076e, - 0x10f50, 0x187ac, 0x10f48, 0x187a6, 0x10f44, 0x10f42, 0x1072c, 0x10f6c, - 0x10726, 0x10f66, 0x18fa8, 0x1c7d6, 0x18fa4, 0x18fa2, 0x10f28, 0x18796, - 0x11f68, 0x18fb6, 0x11f64, 0x10f22, 0x11f62, 0x10716, 0x10f36, 0x11f76, - 0x1cfd4, 0x1cfd2, 0x18f94, 0x19fb4, 0x18f92, 0x19fb2, 0x10f14, 0x11f34, - 0x10f12, 0x13f74, 0x11f32, 0x13f72, 0x1cfca, 0x18f8a, 0x19f9a, 0x10f0a, - 0x11f1a, 0x13f3a, 0x103ac, 0x103a6, 0x107a8, 0x183d6, 0x107a4, 0x107a2, - 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x10794, 0x10fb4, 0x10792, 0x10fb2, - 0x1c7ea}}; -FX_FLOAT CBC_PDF417::PREFERRED_RATIO = 3.0f; -FX_FLOAT CBC_PDF417::DEFAULT_MODULE_WIDTH = 0.357f; -FX_FLOAT CBC_PDF417::HEIGHT = 2.0f; -CBC_PDF417::CBC_PDF417() { - m_compact = FALSE; - m_compaction = AUTO; - m_minCols = 1; - m_maxCols = 30; - m_maxRows = 90; - m_minRows = 3; - m_barcodeMatrix = NULL; -} -CBC_PDF417::CBC_PDF417(FX_BOOL compact) { - m_compact = compact; - m_compaction = AUTO; - m_minCols = 1; - m_maxCols = 30; - m_maxRows = 90; - m_minRows = 3; - m_barcodeMatrix = NULL; -} -CBC_PDF417::~CBC_PDF417() { - if (m_barcodeMatrix) { - delete m_barcodeMatrix; - } -} -CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() { - return m_barcodeMatrix; -} -void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, - int32_t errorCorrectionLevel, - int32_t& e) { - int32_t errorCorrectionCodeWords = - CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( - errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CFX_WideString highLevel = - CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t sourceCodeWords = highLevel.GetLength(); - CFX_Int32Array* dimension = - determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t cols = dimension->GetAt(0); - int32_t rows = dimension->GetAt(1); - delete dimension; - int32_t pad = getNumberOfPadCodewords(sourceCodeWords, - errorCorrectionCodeWords, cols, rows); - if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { - e = BCExceptionEncodedMessageContainsTooManyCodeWords; - return; - } - int32_t n = sourceCodeWords + pad + 1; - CFX_WideString sb; - sb += (FX_WCHAR)n; - sb += highLevel; - for (int32_t i = 0; i < pad; i++) { - sb += (FX_WCHAR)900; - } - CFX_WideString dataCodewords(sb); - CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( - dataCodewords, errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CFX_WideString fullCodewords = dataCodewords + ec; - m_barcodeMatrix = new CBC_BarcodeMatrix(rows, cols); - encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, - m_barcodeMatrix); -} -void CBC_PDF417::setDimensions(int32_t maxCols, - int32_t minCols, - int32_t maxRows, - int32_t minRows) { - m_maxCols = maxCols; - m_minCols = minCols; - m_maxRows = maxRows; - m_minRows = minRows; -} -void CBC_PDF417::setCompaction(Compaction compaction) { - m_compaction = compaction; -} -void CBC_PDF417::setCompact(FX_BOOL compact) { - m_compact = compact; -} -int32_t CBC_PDF417::calculateNumberOfRows(int32_t m, int32_t k, int32_t c) { - int32_t r = ((m + 1 + k) / c) + 1; - if (c * r >= (m + 1 + k + c)) { - r--; - } - return r; -} -int32_t CBC_PDF417::getNumberOfPadCodewords(int32_t m, - int32_t k, - int32_t c, - int32_t r) { - int32_t n = c * r - k; - return n > m + 1 ? n - m - 1 : 0; -} -void CBC_PDF417::encodeChar(int32_t pattern, - int32_t len, - CBC_BarcodeRow* logic) { - int32_t map = 1 << (len - 1); - FX_BOOL last = ((pattern & map) != 0); - int32_t width = 0; - for (int32_t i = 0; i < len; i++) { - FX_BOOL black = ((pattern & map) != 0); - if (last == black) { - width++; - } else { - logic->addBar(last, width); - last = black; - width = 1; - } - map >>= 1; - } - logic->addBar(last, width); -} -void CBC_PDF417::encodeLowLevel(CFX_WideString fullCodewords, - int32_t c, - int32_t r, - int32_t errorCorrectionLevel, - CBC_BarcodeMatrix* logic) { - int32_t idx = 0; - for (int32_t y = 0; y < r; y++) { - int32_t cluster = y % 3; - logic->startRow(); - encodeChar(START_PATTERN, 17, logic->getCurrentRow()); - int32_t left; - int32_t right; - if (cluster == 0) { - left = (30 * (y / 3)) + ((r - 1) / 3); - right = (30 * (y / 3)) + (c - 1); - } else if (cluster == 1) { - left = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); - right = (30 * (y / 3)) + ((r - 1) / 3); - } else { - left = (30 * (y / 3)) + (c - 1); - right = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3); - } - int32_t pattern = CODEWORD_TABLE[cluster][left]; - encodeChar(pattern, 17, logic->getCurrentRow()); - for (int32_t x = 0; x < c; x++) { - pattern = CODEWORD_TABLE[cluster][fullCodewords.GetAt(idx)]; - encodeChar(pattern, 17, logic->getCurrentRow()); - idx++; - } - if (m_compact) { - encodeChar(STOP_PATTERN, 1, logic->getCurrentRow()); - } else { - pattern = CODEWORD_TABLE[cluster][right]; - encodeChar(pattern, 17, logic->getCurrentRow()); - encodeChar(STOP_PATTERN, 18, logic->getCurrentRow()); - } - } -} -CFX_Int32Array* CBC_PDF417::determineDimensions( - int32_t sourceCodeWords, - int32_t errorCorrectionCodeWords, - int32_t& e) { - FX_FLOAT ratio = 0.0f; - CFX_Int32Array* dimension = NULL; - for (int32_t cols = m_minCols; cols <= m_maxCols; cols++) { - int32_t rows = - calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols); - if (rows < m_minRows) { - break; - } - if (rows > m_maxRows) { - continue; - } - FX_FLOAT newRatio = - ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); - if (dimension && - fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { - continue; - } - ratio = newRatio; - if (dimension) { - delete dimension; - } - dimension = new CFX_Int32Array; - dimension->Add(cols); - dimension->Add(rows); - } - if (dimension == NULL) { - int32_t rows = calculateNumberOfRows(sourceCodeWords, - errorCorrectionCodeWords, m_minCols); - if (rows < m_minRows) { - dimension = new CFX_Int32Array; - dimension->Add(m_minCols); - dimension->Add(m_minRows); - } else if (rows >= 3 && rows <= 90) { - dimension = new CFX_Int32Array; - dimension->Add(m_minCols); - dimension->Add(rows); - } - } - if (dimension == NULL) { - e = BCExceptionUnableToFitMessageInColumns; - return NULL; - } - return dimension; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417.h b/xfa/src/fxbarcode/pdf417/BC_PDF417.h deleted file mode 100644 index a7a4649461..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417.h +++ /dev/null @@ -1,64 +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_SRC_FXBARCODE_PDF417_BC_PDF417_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" - -class CBC_BarcodeRow; -class CBC_BarcodeMatrix; - -class CBC_PDF417 { - public: - CBC_PDF417(); - CBC_PDF417(FX_BOOL compact); - virtual ~CBC_PDF417(); - CBC_BarcodeMatrix* getBarcodeMatrix(); - void generateBarcodeLogic(CFX_WideString msg, - int32_t errorCorrectionLevel, - int32_t& e); - void setDimensions(int32_t maxCols, - int32_t minCols, - int32_t maxRows, - int32_t minRows); - void setCompaction(Compaction compaction); - void setCompact(FX_BOOL compact); - - private: - static int32_t START_PATTERN; - static int32_t STOP_PATTERN; - static int32_t CODEWORD_TABLE[][1000]; - static FX_FLOAT PREFERRED_RATIO; - static FX_FLOAT DEFAULT_MODULE_WIDTH; - static FX_FLOAT HEIGHT; - CBC_BarcodeMatrix* m_barcodeMatrix; - FX_BOOL m_compact; - Compaction m_compaction; - int32_t m_minCols; - int32_t m_maxCols; - int32_t m_maxRows; - int32_t m_minRows; - - private: - static int32_t calculateNumberOfRows(int32_t m, int32_t k, int32_t c); - static int32_t getNumberOfPadCodewords(int32_t m, - int32_t k, - int32_t c, - int32_t r); - static void encodeChar(int32_t pattern, int32_t len, CBC_BarcodeRow* logic); - void encodeLowLevel(CFX_WideString fullCodewords, - int32_t c, - int32_t r, - int32_t errorCorrectionLevel, - CBC_BarcodeMatrix* logic); - CFX_Int32Array* determineDimensions(int32_t sourceCodeWords, - int32_t errorCorrectionCodeWords, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp deleted file mode 100644 index fbc252e202..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp +++ /dev/null @@ -1,90 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" - -CBC_BarcodeMatrix::CBC_BarcodeMatrix(int32_t height, int32_t width) { - m_matrix.SetSize(height + 2); - for (int32_t i = 0, matrixLength = m_matrix.GetSize(); i < matrixLength; - i++) { - m_matrix[i] = new CBC_BarcodeRow((width + 4) * 17 + 1); - } - m_width = width * 17; - m_height = height + 2; - m_currentRow = 0; - m_outHeight = 0; - 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(); - m_matrixOut.RemoveAll(); -} -void CBC_BarcodeMatrix::set(int32_t x, int32_t y, uint8_t value) { - ((CBC_BarcodeRow*)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)); -} -void CBC_BarcodeMatrix::startRow() { - ++m_currentRow; -} -CBC_BarcodeRow* CBC_BarcodeMatrix::getCurrentRow() { - return (CBC_BarcodeRow*)m_matrix[m_currentRow]; -} -int32_t CBC_BarcodeMatrix::getWidth() { - return m_outWidth; -} -int32_t CBC_BarcodeMatrix::getHeight() { - return m_outHeight; -} -CFX_ByteArray& CBC_BarcodeMatrix::getMatrix() { - return getScaledMatrix(1, 1); -} -CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t scale) { - return getScaledMatrix(scale, scale); -} -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)); - int32_t xMax = bytearray.GetSize(); - m_matrixOut.SetSize(xMax * yMax); - m_outWidth = xMax; - m_outHeight = yMax; - 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)); - } - k = i * xMax; - for (int32_t l = 0; l < xMax; l++) { - m_matrixOut[k + l] = bytearray.GetAt(l); - } - } - return m_matrixOut; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h deleted file mode 100644 index 15e1c3f2bb..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h +++ /dev/null @@ -1,38 +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_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_BarcodeRow; -class CBC_BarcodeMatrix { - public: - CBC_BarcodeMatrix(); - CBC_BarcodeMatrix(int32_t height, int32_t width); - virtual ~CBC_BarcodeMatrix(); - void set(int32_t x, int32_t y, uint8_t value); - void setMatrix(int32_t x, int32_t y, FX_BOOL black); - void startRow(); - CBC_BarcodeRow* getCurrentRow(); - CFX_ByteArray& getMatrix(); - CFX_ByteArray& getScaledMatrix(int32_t scale); - CFX_ByteArray& getScaledMatrix(int32_t xScale, int32_t yScale); - int32_t getWidth(); - int32_t getHeight(); - - private: - CFX_PtrArray m_matrix; - CFX_ByteArray m_matrixOut; - int32_t m_currentRow; - int32_t m_height; - int32_t m_width; - int32_t m_outWidth; - int32_t m_outHeight; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.cpp deleted file mode 100644 index 87aacb1ff9..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" - -CBC_BarcodeMetadata::CBC_BarcodeMetadata(int32_t columnCount, - int32_t rowCountUpperPart, - int32_t rowCountLowerPart, - int32_t errorCorrectionLevel) { - m_columnCount = columnCount; - m_rowCountUpperPart = rowCountUpperPart; - m_rowCountLowerPart = rowCountLowerPart; - m_errorCorrectionLevel = errorCorrectionLevel; - m_rowCount = m_rowCountUpperPart + m_rowCountLowerPart; -} -CBC_BarcodeMetadata::~CBC_BarcodeMetadata() {} -int32_t CBC_BarcodeMetadata::getColumnCount() { - return m_columnCount; -} -int32_t CBC_BarcodeMetadata::getErrorCorrectionLevel() { - return m_errorCorrectionLevel; -} -int32_t CBC_BarcodeMetadata::getRowCount() { - return m_rowCount; -} -int32_t CBC_BarcodeMetadata::getRowCountUpperPart() { - return m_rowCountUpperPart; -} -int32_t CBC_BarcodeMetadata::getRowCountLowerPart() { - return m_rowCountLowerPart; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h deleted file mode 100644 index 6d4b95e8f9..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h +++ /dev/null @@ -1,33 +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_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ - -#include <stdint.h> - -class CBC_BarcodeMetadata { - public: - CBC_BarcodeMetadata(int32_t columnCount, - int32_t rowCountUpperPart, - int32_t rowCountLowerPart, - int32_t errorCorrectionLevel); - virtual ~CBC_BarcodeMetadata(); - int32_t getColumnCount(); - int32_t getErrorCorrectionLevel(); - int32_t getRowCount(); - int32_t getRowCountUpperPart(); - int32_t getRowCountLowerPart(); - - private: - int32_t m_columnCount; - int32_t m_errorCorrectionLevel; - int32_t m_rowCountUpperPart; - int32_t m_rowCountLowerPart; - int32_t m_rowCount; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEMETADATA_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp deleted file mode 100644 index 41e1955c48..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.cpp +++ /dev/null @@ -1,53 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" - -CBC_BarcodeRow::CBC_BarcodeRow(int32_t width) { - m_row.SetSize(width); - m_currentLocation = 0; -} -CBC_BarcodeRow::~CBC_BarcodeRow() { - m_output.RemoveAll(); - m_row.RemoveAll(); -} -void CBC_BarcodeRow::set(int32_t x, uint8_t value) { - m_row.SetAt(x, value); -} -void CBC_BarcodeRow::set(int32_t x, FX_BOOL black) { - m_row.SetAt(x, (uint8_t)(black ? 1 : 0)); -} -void CBC_BarcodeRow::addBar(FX_BOOL black, int32_t width) { - for (int32_t ii = 0; ii < width; ii++) { - set(m_currentLocation++, black); - } -} -CFX_ByteArray& CBC_BarcodeRow::getRow() { - return m_row; -} -CFX_ByteArray& CBC_BarcodeRow::getScaledRow(int32_t scale) { - m_output.SetSize(m_row.GetSize() * scale); - for (int32_t i = 0; i < m_output.GetSize(); i++) { - m_output[i] = (m_row[i / scale]); - } - return m_output; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.h deleted file mode 100644 index f387a62740..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeRow.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_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_BarcodeRow { - public: - CBC_BarcodeRow(int32_t width); - virtual ~CBC_BarcodeRow(); - void set(int32_t x, uint8_t value); - void set(int32_t x, FX_BOOL black); - void addBar(FX_BOOL black, int32_t width); - CFX_ByteArray& getRow(); - CFX_ByteArray& getScaledRow(int32_t scale); - - private: - CFX_ByteArray m_row; - CFX_ByteArray m_output; - int32_t m_currentLocation; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEROW_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp deleted file mode 100644 index 7ecb1a7b30..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.cpp +++ /dev/null @@ -1,61 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" - -CBC_BarcodeValue::CBC_BarcodeValue() {} -CBC_BarcodeValue::~CBC_BarcodeValue() {} -void CBC_BarcodeValue::setValue(int32_t value) { - int32_t confidence = 0; - for (int32_t i = 0; i < m_keys.GetSize(); i++) { - if (m_keys.GetAt(i) == value) { - confidence = m_values.GetAt(i); - m_values.SetAt(i, confidence + 1); - return; - } - } - confidence = 1; - m_keys.Add(value); - m_values.Add(confidence); -} -CFX_Int32Array* CBC_BarcodeValue::getValue() { - int32_t maxConfidence = -1; - CFX_Int32Array* result = new CFX_Int32Array; - for (int32_t i = 0; i < m_keys.GetSize(); i++) { - if (m_values.GetAt(i) > maxConfidence) { - maxConfidence = m_values.GetAt(i); - result->RemoveAll(); - result->Add(m_keys.GetAt(i)); - } else if (m_values.GetAt(i) == maxConfidence) { - result->Add(m_keys.GetAt(i)); - } - } - return result; -} -int32_t CBC_BarcodeValue::getConfidence(int32_t value) { - for (int32_t i = 0; i < m_keys.GetSize(); i++) - if (m_keys.GetAt(i) == value) { - return m_values.GetAt(i); - } - return -1; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h b/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h deleted file mode 100644 index 8e567d7ec8..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_BarcodeValue { - public: - CBC_BarcodeValue(); - virtual ~CBC_BarcodeValue(); - void setValue(int32_t value); - CFX_Int32Array* getValue(); - int32_t getConfidence(int32_t value); - - private: - CFX_Int32Array m_keys; - CFX_Int32Array m_values; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp deleted file mode 100644 index 6deef4c969..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp +++ /dev/null @@ -1,207 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_BoundingBox::CBC_BoundingBox(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomRight, - int32_t& e) { - if ((topLeft == NULL && topRight == NULL) || - (bottomLeft == NULL && bottomRight == NULL) || - (topLeft && bottomLeft == NULL) || (topRight && bottomRight == NULL)) { - e = BCExceptionNotFoundInstance; - } - init(image, topLeft, bottomLeft, topRight, bottomRight); -} -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; - } -} -CBC_BoundingBox* CBC_BoundingBox::merge(CBC_BoundingBox* leftBox, - CBC_BoundingBox* rightBox, - int32_t& e) { - CBC_BoundingBox* boundingBox = NULL; - if (leftBox == NULL) { - boundingBox = new CBC_BoundingBox(rightBox); - return boundingBox; - } - if (rightBox == NULL) { - boundingBox = new CBC_BoundingBox(leftBox); - return boundingBox; - } - boundingBox = new CBC_BoundingBox(leftBox->m_image, leftBox->m_topLeft, - leftBox->m_bottomLeft, rightBox->m_topRight, - rightBox->m_bottomRight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return boundingBox; -} -CBC_BoundingBox* CBC_BoundingBox::addMissingRows(int32_t missingStartRows, - int32_t missingEndRows, - FX_BOOL isLeft, - int32_t& e) { - CBC_ResultPoint* newTopLeft = m_topLeft; - CBC_ResultPoint* newBottomLeft = m_bottomLeft; - CBC_ResultPoint* newTopRight = m_topRight; - CBC_ResultPoint* newBottomRight = m_bottomRight; - CBC_ResultPoint* newTop = NULL; - CBC_ResultPoint* newBottom = NULL; - if (missingStartRows > 0) { - CBC_ResultPoint* top = isLeft ? m_topLeft : m_topRight; - int32_t newMinY = (int32_t)top->GetY() - missingStartRows; - if (newMinY < 0) { - newMinY = 0; - } - newTop = new CBC_ResultPoint((FX_FLOAT)top->GetX(), (FX_FLOAT)newMinY); - if (isLeft) { - newTopLeft = newTop; - } else { - newTopRight = newTop; - } - } - if (missingEndRows > 0) { - CBC_ResultPoint* bottom = isLeft ? m_bottomLeft : m_bottomRight; - int32_t newMaxY = (int32_t)bottom->GetY() + missingEndRows; - if (newMaxY >= m_image->GetHeight()) { - newMaxY = m_image->GetHeight() - 1; - } - newBottom = - new CBC_ResultPoint((FX_FLOAT)bottom->GetX(), (FX_FLOAT)newMaxY); - if (isLeft) { - newBottomLeft = newBottom; - } else { - newBottomRight = newBottom; - } - } - calculateMinMaxValues(); - CBC_BoundingBox* boundingBox = new CBC_BoundingBox( - m_image, newTopLeft, newBottomLeft, newTopRight, newBottomRight, e); - delete newTop; - delete newBottom; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return boundingBox; -} -void CBC_BoundingBox::setTopRight(CBC_ResultPoint topRight) { - if (m_topRight) { - delete m_topRight; - } - m_topRight = new CBC_ResultPoint(topRight.GetX(), topRight.GetY()); - calculateMinMaxValues(); -} -void CBC_BoundingBox::setBottomRight(CBC_ResultPoint bottomRight) { - if (m_bottomRight) { - delete m_bottomRight; - } - m_bottomRight = new CBC_ResultPoint(bottomRight.GetX(), bottomRight.GetY()); - calculateMinMaxValues(); -} -int32_t CBC_BoundingBox::getMinX() { - return m_minX; -} -int32_t CBC_BoundingBox::getMaxX() { - return m_maxX; -} -int32_t CBC_BoundingBox::getMinY() { - return m_minY; -} -int32_t CBC_BoundingBox::getMaxY() { - return m_maxY; -} -CBC_ResultPoint* CBC_BoundingBox::getTopLeft() { - return m_topLeft; -} -CBC_ResultPoint* CBC_BoundingBox::getTopRight() { - return m_topRight; -} -CBC_ResultPoint* CBC_BoundingBox::getBottomLeft() { - return m_bottomLeft; -} -CBC_ResultPoint* CBC_BoundingBox::getBottomRight() { - return m_bottomRight; -} -void CBC_BoundingBox::init(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomRight) { - m_topLeft = NULL; - m_bottomLeft = NULL; - m_topRight = NULL; - m_bottomRight = NULL; - m_image = image; - if (topLeft) { - m_topLeft = new CBC_ResultPoint(topLeft->GetX(), topLeft->GetY()); - } - if (bottomLeft) { - m_bottomLeft = new CBC_ResultPoint(bottomLeft->GetX(), bottomLeft->GetY()); - } - if (topRight) { - m_topRight = new CBC_ResultPoint(topRight->GetX(), topRight->GetY()); - } - if (bottomRight) { - m_bottomRight = - new CBC_ResultPoint(bottomRight->GetX(), bottomRight->GetY()); - } - calculateMinMaxValues(); -} -void CBC_BoundingBox::calculateMinMaxValues() { - if (m_topLeft == NULL) { - m_topLeft = new CBC_ResultPoint(0, m_topRight->GetY()); - m_bottomLeft = new CBC_ResultPoint(0, m_bottomRight->GetY()); - } else if (m_topRight == NULL) { - m_topRight = new CBC_ResultPoint((FX_FLOAT)m_image->GetWidth() - 1, - (FX_FLOAT)m_topLeft->GetY()); - m_bottomRight = new CBC_ResultPoint((FX_FLOAT)m_image->GetWidth() - 1, - (FX_FLOAT)m_bottomLeft->GetY()); - } - m_minX = (int32_t)(m_topLeft->GetX() < m_bottomLeft->GetX() - ? m_topLeft->GetX() - : m_bottomLeft->GetX()); - m_maxX = (int32_t)(m_topRight->GetX() > m_bottomRight->GetX() - ? m_topRight->GetX() - : m_bottomRight->GetX()); - m_minY = - (int32_t)(m_topLeft->GetY() < m_topRight->GetY() ? m_topLeft->GetY() - : m_topRight->GetY()); - m_maxY = (int32_t)(m_bottomLeft->GetY() > m_bottomRight->GetY() - ? m_bottomLeft->GetY() - : m_bottomRight->GetY()); -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h b/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h deleted file mode 100644 index c241572985..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h +++ /dev/null @@ -1,61 +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_SRC_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ - -#include "core/include/fxcrt/fx_system.h" - -class CBC_CommonBitMatrix; -class CBC_ResultPoint; - -class CBC_BoundingBox { - public: - CBC_BoundingBox(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomRight, - int32_t& e); - CBC_BoundingBox(CBC_BoundingBox* boundingBox); - virtual ~CBC_BoundingBox(); - static CBC_BoundingBox* merge(CBC_BoundingBox* leftBox, - CBC_BoundingBox* rightBox, - int32_t& e); - CBC_BoundingBox* addMissingRows(int32_t missingStartRows, - int32_t missingEndRows, - FX_BOOL isLeft, - int32_t& e); - void setTopRight(CBC_ResultPoint topRight); - void setBottomRight(CBC_ResultPoint bottomRight); - int32_t getMinX(); - int32_t getMaxX(); - int32_t getMinY(); - int32_t getMaxY(); - CBC_ResultPoint* getTopLeft(); - CBC_ResultPoint* getTopRight(); - CBC_ResultPoint* getBottomLeft(); - CBC_ResultPoint* getBottomRight(); - - private: - CBC_CommonBitMatrix* m_image; - CBC_ResultPoint* m_topLeft; - CBC_ResultPoint* m_bottomLeft; - CBC_ResultPoint* m_topRight; - CBC_ResultPoint* m_bottomRight; - int32_t m_minX; - int32_t m_maxX; - int32_t m_minY; - int32_t m_maxY; - void init(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomRight); - void calculateMinMaxValues(); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417BOUNDINGBOX_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.cpp deleted file mode 100644 index f8b627a8b4..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" - -int32_t CBC_Codeword::BARCODE_ROW_UNKNOWN = -1; -CBC_Codeword::CBC_Codeword(int32_t startX, - int32_t endX, - int32_t bucket, - int32_t cvalue) { - m_startX = startX; - m_endX = endX; - m_bucket = bucket; - m_value = cvalue; - m_rowNumber = BARCODE_ROW_UNKNOWN; -} -CBC_Codeword::~CBC_Codeword() {} -FX_BOOL CBC_Codeword::hasValidRowNumber() { - return isValidRowNumber(m_rowNumber); -} -FX_BOOL CBC_Codeword::isValidRowNumber(int32_t rowNumber) { - return m_rowNumber != BARCODE_ROW_UNKNOWN && - m_bucket == (m_rowNumber % 3) * 3; -} -void CBC_Codeword::setRowNumberAsRowIndicatorColumn() { - m_rowNumber = (m_value / 30) * 3 + m_bucket / 3; -} -int32_t CBC_Codeword::getWidth() { - return m_endX - m_startX; -} -int32_t CBC_Codeword::getStartX() { - return m_startX; -} -int32_t CBC_Codeword::getEndX() { - return m_endX; -} -int32_t CBC_Codeword::getBucket() { - return m_bucket; -} -int32_t CBC_Codeword::getValue() { - return m_value; -} -int32_t CBC_Codeword::getRowNumber() { - return m_rowNumber; -} -void CBC_Codeword::setRowNumber(int32_t rowNumber) { - m_rowNumber = rowNumber; -} -CFX_ByteString CBC_Codeword::toString() { - return m_rowNumber + (FX_CHAR)'|' + m_value; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h deleted file mode 100644 index e2eb52c9ba..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.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_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_Codeword { - public: - CBC_Codeword(int32_t startX, int32_t endX, int32_t bucket, int32_t value); - virtual ~CBC_Codeword(); - FX_BOOL hasValidRowNumber(); - FX_BOOL isValidRowNumber(int32_t rowNumber); - void setRowNumberAsRowIndicatorColumn(); - int32_t getWidth(); - int32_t getStartX(); - int32_t getEndX(); - int32_t getBucket(); - int32_t getValue(); - int32_t getRowNumber(); - void setRowNumber(int32_t rowNumber); - CFX_ByteString toString(); - - private: - static int32_t BARCODE_ROW_UNKNOWN; - int32_t m_startX; - int32_t m_endX; - int32_t m_bucket; - int32_t m_value; - int32_t m_rowNumber; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORD_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp deleted file mode 100644 index ea1e38765a..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp +++ /dev/null @@ -1,117 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <limits> - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" - -#define SYMBOL_TABLE_Length 2787 - -FX_FLOAT CBC_PDF417CodewordDecoder::RATIOS_TABLE[2787][8] = {{0}}; - -CBC_PDF417CodewordDecoder::CBC_PDF417CodewordDecoder() {} -CBC_PDF417CodewordDecoder::~CBC_PDF417CodewordDecoder() {} -void CBC_PDF417CodewordDecoder::Initialize() { - for (int32_t i = 0; i < SYMBOL_TABLE_Length; i++) { - int32_t currentSymbol = CBC_PDF417Common::SYMBOL_TABLE[i]; - int32_t currentBit = currentSymbol & 0x1; - for (int32_t j = 0; j < CBC_PDF417Common::BARS_IN_MODULE; j++) { - FX_FLOAT size = 0.0f; - while ((currentSymbol & 0x1) == currentBit) { - size += 1.0f; - currentSymbol >>= 1; - } - currentBit = currentSymbol & 0x1; - RATIOS_TABLE[i][CBC_PDF417Common::BARS_IN_MODULE - j - 1] = - size / CBC_PDF417Common::MODULES_IN_CODEWORD; - } - } -} -void CBC_PDF417CodewordDecoder::Finalize() {} -int32_t CBC_PDF417CodewordDecoder::getDecodedValue( - CFX_Int32Array& moduleBitCount) { - CFX_Int32Array* array = sampleBitCounts(moduleBitCount); - int32_t decodedValue = getDecodedCodewordValue(*array); - delete array; - if (decodedValue != -1) { - return decodedValue; - } - return getClosestDecodedValue(moduleBitCount); -} -CFX_Int32Array* CBC_PDF417CodewordDecoder::sampleBitCounts( - CFX_Int32Array& moduleBitCount) { - FX_FLOAT bitCountSum = - (FX_FLOAT)CBC_PDF417Common::getBitCountSum(moduleBitCount); - CFX_Int32Array* bitCount = new CFX_Int32Array(); - bitCount->SetSize(CBC_PDF417Common::BARS_IN_MODULE); - int32_t bitCountIndex = 0; - int32_t sumPreviousBits = 0; - for (int32_t i = 0; i < CBC_PDF417Common::MODULES_IN_CODEWORD; i++) { - FX_FLOAT sampleIndex = - bitCountSum / (2 * CBC_PDF417Common::MODULES_IN_CODEWORD) + - (i * bitCountSum) / CBC_PDF417Common::MODULES_IN_CODEWORD; - if (sumPreviousBits + moduleBitCount.GetAt(bitCountIndex) <= sampleIndex) { - sumPreviousBits += moduleBitCount.GetAt(bitCountIndex); - bitCountIndex++; - } - bitCount->SetAt(bitCountIndex, bitCount->GetAt(bitCountIndex) + 1); - } - return bitCount; -} -int32_t CBC_PDF417CodewordDecoder::getDecodedCodewordValue( - CFX_Int32Array& moduleBitCount) { - int32_t decodedValue = getBitValue(moduleBitCount); - return CBC_PDF417Common::getCodeword(decodedValue) == -1 ? -1 : decodedValue; -} -int32_t CBC_PDF417CodewordDecoder::getBitValue(CFX_Int32Array& moduleBitCount) { - int64_t result = 0; - for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) { - for (int32_t bit = 0; bit < moduleBitCount.GetAt(i); bit++) { - result = (result << 1) | (i % 2 == 0 ? 1 : 0); - } - } - return (int32_t)result; -} -int32_t CBC_PDF417CodewordDecoder::getClosestDecodedValue( - CFX_Int32Array& moduleBitCount) { - int32_t bitCountSum = CBC_PDF417Common::getBitCountSum(moduleBitCount); - CFX_FloatArray bitCountRatios; - bitCountRatios.SetSize(CBC_PDF417Common::BARS_IN_MODULE); - for (int32_t i = 0; i < bitCountRatios.GetSize(); i++) { - bitCountRatios[i] = moduleBitCount.GetAt(i) / (FX_FLOAT)bitCountSum; - } - FX_FLOAT bestMatchError = std::numeric_limits<int32_t>::max(); - int32_t bestMatch = -1; - for (int32_t j = 0; j < SYMBOL_TABLE_Length; j++) { - FX_FLOAT error = 0.0f; - for (int32_t k = 0; k < CBC_PDF417Common::BARS_IN_MODULE; k++) { - FX_FLOAT diff = RATIOS_TABLE[j][k] - bitCountRatios[k]; - error += diff * diff; - } - if (error < bestMatchError) { - bestMatchError = error; - bestMatch = CBC_PDF417Common::SYMBOL_TABLE[j]; - } - } - return bestMatch; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h b/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h deleted file mode 100644 index 149a640676..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.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_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_PDF417CodewordDecoder { - public: - CBC_PDF417CodewordDecoder(); - virtual ~CBC_PDF417CodewordDecoder(); - static void Initialize(); - static void Finalize(); - static int32_t getDecodedValue(CFX_Int32Array& moduleBitCount); - - private: - static FX_FLOAT RATIOS_TABLE[][8]; - static CFX_Int32Array* sampleBitCounts(CFX_Int32Array& moduleBitCount); - static int32_t getDecodedCodewordValue(CFX_Int32Array& moduleBitCount); - static int32_t getBitValue(CFX_Int32Array& moduleBitCount); - static int32_t getClosestDecodedValue(CFX_Int32Array& moduleBitCount); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417CODEWORDDECODER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Common.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Common.cpp deleted file mode 100644 index 5bd2dafbe8..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Common.cpp +++ /dev/null @@ -1,651 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" - -int32_t CBC_PDF417Common::NUMBER_OF_CODEWORDS = 929; -int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE = NUMBER_OF_CODEWORDS - 1; -int32_t CBC_PDF417Common::MIN_ROWS_IN_BARCODE = 3; -int32_t CBC_PDF417Common::MAX_ROWS_IN_BARCODE = 90; -int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_ROW = 32; -int32_t CBC_PDF417Common::MODULES_IN_CODEWORD = 17; -int32_t CBC_PDF417Common::MODULES_IN_STOP_PATTERN = 18; -int32_t CBC_PDF417Common::BARS_IN_MODULE = 8; -CFX_Int32Array* CBC_PDF417Common::EMPTY_INT_ARRAY = NULL; -int32_t CBC_PDF417Common::SYMBOL_TABLE[] = { - 0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, - 0x1035c, 0x10396, 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, - 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, - 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, - 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c, 0x10540, 0x10578, - 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2, - 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, - 0x106b8, 0x106de, 0x106fa, 0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, - 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, - 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, - 0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc, 0x108c6, - 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e, - 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, - 0x109ce, 0x109dc, 0x109e2, 0x109e4, 0x109e8, 0x109f6, 0x10a08, 0x10a10, - 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, - 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, - 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e, - 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c, - 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, - 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70, 0x10d7e, 0x10d82, 0x10d84, - 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, - 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, - 0x10e6e, 0x10e86, 0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, - 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, - 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, - 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a, 0x11082, 0x11084, - 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee, - 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, - 0x11186, 0x11198, 0x111b0, 0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, - 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, - 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, - 0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410, 0x1141e, - 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618, - 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, - 0x11770, 0x1177e, 0x11782, 0x11784, 0x11788, 0x11790, 0x1179e, 0x117a0, - 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, - 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, - 0x118c2, 0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e, - 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e, - 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, - 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, - 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98, - 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, - 0x11c16, 0x11c26, 0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, - 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, - 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, - 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, - 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28, - 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, - 0x11e84, 0x11e88, 0x11e90, 0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, - 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, - 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, - 0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4, 0x12108, - 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0, - 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, - 0x12220, 0x12278, 0x122f0, 0x12306, 0x1230c, 0x12330, 0x1233e, 0x12360, - 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, - 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, - 0x12660, 0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782, - 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8, - 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, - 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, - 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08, - 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, - 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, - 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, - 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, - 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc, 0x131d8, 0x131f2, - 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308, - 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, - 0x133be, 0x133ce, 0x133dc, 0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, - 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, - 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, - 0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c, 0x137b8, - 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816, - 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, - 0x13898, 0x138b0, 0x138be, 0x138ce, 0x138dc, 0x138e2, 0x138e4, 0x138e8, - 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, - 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, - 0x13a0c, 0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, - 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e, - 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, - 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36, 0x13c42, 0x13c48, 0x13c50, - 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, - 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, - 0x13d10, 0x13d1e, 0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, - 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, - 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, - 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, - 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46, - 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, - 0x140bc, 0x14104, 0x14108, 0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, - 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, - 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, - 0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c, 0x1438e, - 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410, - 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, - 0x14618, 0x14630, 0x1463e, 0x14660, 0x1467c, 0x146c0, 0x146f8, 0x1471c, - 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, - 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, - 0x14840, 0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, - 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0, - 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, - 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0, 0x14fce, 0x14fdc, 0x15020, - 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0, - 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, - 0x15df8, 0x15e08, 0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, - 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, - 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, - 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184, 0x16188, 0x16190, - 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4, - 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, - 0x16308, 0x16310, 0x1631e, 0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, - 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, - 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, - 0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c, 0x16640, - 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e, - 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, - 0x167ec, 0x1681c, 0x16838, 0x16870, 0x168e0, 0x168fc, 0x169c0, 0x169f8, - 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, - 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, - 0x16f1c, 0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e, - 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046, - 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, - 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c, 0x17118, 0x17130, 0x1713e, - 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8, - 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, - 0x17230, 0x1723e, 0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, - 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, - 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, - 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0, 0x1760e, 0x1761c, - 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e, - 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, - 0x177e2, 0x177e4, 0x177e8, 0x17822, 0x17824, 0x17828, 0x17836, 0x17842, - 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, - 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, - 0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910, 0x1791e, - 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0, - 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, - 0x17a08, 0x17a10, 0x17a1e, 0x17a20, 0x17a3c, 0x17a40, 0x17a78, 0x17af0, - 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, - 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, - 0x17c2e, 0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68, - 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0, - 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, - 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, - 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, - 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, - 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, - 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, - 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, - 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a, 0x18446, 0x18458, - 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc, - 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, - 0x1853e, 0x18560, 0x1857c, 0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, - 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, - 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, - 0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6, 0x186cc, - 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796, - 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, - 0x1884c, 0x18858, 0x1886e, 0x18872, 0x18874, 0x18886, 0x18898, 0x188b0, - 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, - 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, - 0x189d0, 0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e, - 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e, - 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, - 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4, 0x18c22, 0x18c24, 0x18c28, - 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, - 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, - 0x18d04, 0x18d08, 0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, - 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, - 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, - 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa, 0x18f16, 0x18f26, - 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94, - 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, - 0x19058, 0x19072, 0x19074, 0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, - 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, - 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, - 0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260, 0x1927c, - 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390, - 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, - 0x193f4, 0x19430, 0x1943e, 0x19460, 0x1947c, 0x194c0, 0x194f8, 0x195f0, - 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, - 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, - 0x197b0, 0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822, - 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882, - 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, - 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c, 0x19940, 0x19978, 0x19986, - 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e, - 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, - 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, - 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, - 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, - 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90, 0x19da0, 0x19dcc, - 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58, - 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, - 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, - 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, - 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, - 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, - 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c, - 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, - 0x1a218, 0x1a230, 0x1a23e, 0x1a260, 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, - 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, - 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, - 0x1a418, 0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, - 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704, - 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, - 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, - 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, - 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, - 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, - 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, - 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, - 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, - 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c, - 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, - 0x1b204, 0x1b208, 0x1b210, 0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, - 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, - 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, - 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, - 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e, - 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, - 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, 0x1b938, 0x1b970, 0x1b97e, 0x1b982, - 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, - 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, - 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, - 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72, - 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, - 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, - 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, - 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, - 0x1be50, 0x1be5e, 0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, - 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, - 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, - 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, - 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268, - 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, - 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, - 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, - 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, - 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, - 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc, - 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, - 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, 0x1c658, 0x1c66e, 0x1c672, 0x1c674, - 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, - 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, - 0x1c744, 0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, - 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c, - 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, - 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, - 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, - 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, - 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, - 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, - 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, - 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, - 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18, - 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, - 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, - 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, - 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, - 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, - 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c, - 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, - 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, - 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, - 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, - 0x1d21c, 0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, - 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386, - 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, - 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, - 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, - 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, - 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, - 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, - 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, - 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, - 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c, - 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, - 0x1db82, 0x1db84, 0x1db88, 0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, - 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, - 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, - 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, - 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4, - 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, - 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, - 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, - 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, - 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, - 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142, - 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, - 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222, 0x1e224, 0x1e228, 0x1e236, - 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, - 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, - 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, - 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, - 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, - 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, - 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510, - 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, - 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, - 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, - 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, - 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, - 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6, - 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, - 0x1e848, 0x1e850, 0x1e85e, 0x1e866, 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, - 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, - 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, - 0x1e93c, 0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, - 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08, - 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, - 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, - 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, - 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, - 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, - 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, - 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, - 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, - 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2, - 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, - 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, - 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, - 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, - 0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, - 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246, - 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, - 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, - 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, - 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, - 0x1f426, 0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, - 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc, - 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, - 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, - 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, - 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, - 0x1f650, 0x1f65e, 0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, - 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, - 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, - 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, - 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934, - 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, - 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, - 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, - 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, - 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, - 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4, - 0x1fba8, 0x1fbb6, 0x1fbda}; -int32_t CBC_PDF417Common::CODEWORD_TABLE[] = { - 2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, - 902, 896, 908, 868, 865, 861, 859, 2511, 873, 871, 1780, 835, - 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, - 807, 2482, 806, 2480, 815, 814, 813, 812, 2484, 817, 816, 1745, - 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752, - 2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, - 787, 781, 747, 739, 736, 2413, 754, 752, 1719, 692, 689, 681, - 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, - 631, 2341, 627, 2338, 651, 646, 643, 2345, 654, 652, 1652, 1650, - 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, - 608, 606, 2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, - 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909, 2509, 2507, - 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, - 2485, 1748, 836, 834, 832, 830, 2494, 827, 2492, 843, 841, 839, - 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, - 2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, - 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591, 588, 576, 569, 566, - 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, - 1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492, 485, 482, 2249, - 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, - 419, 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, - 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155, 2152, 378, 377, - 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, - 1416, 1414, 385, 1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441, - 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, - 756, 753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, - 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332, - 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, - 645, 2346, 655, 653, 1653, 1651, 1649, 1655, 2612, 2597, 2595, 2571, - 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900, - 910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, - 866, 863, 2513, 876, 874, 1782, 2720, 2713, 2711, 2697, 2694, 2691, - 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, - 2639, 1822, 2654, 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, - 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142, 332, 2140, - 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, - 2132, 1354, 1352, 1349, 1356, 262, 257, 2101, 253, 2096, 2093, 274, - 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, - 1318, 2052, 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, - 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266, 1264, 1261, - 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, - 2006, 159, 2003, 2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184, - 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, - 2313, 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, - 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275, - 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, - 2247, 470, 2244, 465, 2241, 493, 488, 484, 2250, 498, 495, 1536, - 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, - 414, 412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, - 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434, 1477, 1475, 2478, - 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, - 2440, 792, 789, 785, 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, - 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353, 1661, - 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, - 683, 2372, 701, 698, 705, 1691, 1689, 2619, 2617, 2610, 2608, 2605, - 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, - 1795, 2573, 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, - 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539, 906, 903, 911, - 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, - 1824, 2673, 2671, 2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, - 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133, 131, - 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, - 112, 110, 1974, 107, 1973, 104, 1971, 1969, 122, 121, 119, 117, - 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, - 1953, 81, 1952, 78, 1950, 1948, 1945, 94, 93, 91, 1959, 88, - 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, - 100, 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, - 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64, 1931, 61, - 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, - 1043, 1050, 1049, 12, 10, 1869, 1867, 1864, 1861, 21, 1880, 19, - 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, - 974, 32, 30, 991, 989, 987, 984, 34, 995, 994, 992, 2151, - 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, - 1359, 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, - 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308, 305, 2131, 302, - 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, - 1351, 1357, 2092, 2091, 2089, 2087, 1276, 2084, 1274, 2081, 1271, 259, - 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, - 279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, - 2032, 1203, 2029, 1200, 1197, 207, 2053, 205, 2051, 201, 2049, 2046, - 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, - 1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, - 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590, 2288, - 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, - 571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258, 1545, 2255, 1544, - 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, - 546, 543, 549, 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, - 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480, 477, 2248, - 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, - 2476, 2474, 2479, 2469, 2468, 2466, 2464, 1730, 2473, 2471, 2453, 2452, - 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, - 2427, 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, - 1727, 2444, 2442, 793, 791, 788, 795, 2388, 2386, 2384, 1697, 2381, - 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, - 2410, 2407, 751, 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, - 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592, 2590, 2587, - 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, - 2554, 1796, 2574, 2572, 2569, 2578, 1847, 1846, 2722, 1843, 1842, 1840, - 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695, - 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, - 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818, 2726, 2776, 782, 740, - 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, - 1645, 1643, 1640, 1648, 602, 600, 597, 595, 2320, 593, 2318, 609, - 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, - 892, 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, - 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632, 2630, 2746, - 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, - 1564, 476, 467, 463, 2240, 486, 483, 1524, 1521, 1518, 1529, 411, - 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, - 2210, 366, 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, - 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412, 1421, 2175, - 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, - 674, 668, 2363, 665, 2360, 685, 1684, 1681, 626, 624, 622, 2335, - 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, - 925, 2530, 2527, 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, - 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759, 2757, - 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, - 300, 296, 2126, 315, 312, 1347, 1342, 1350, 261, 258, 250, 2097, - 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, - 203, 2048, 195, 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, - 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997, 150, - 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, - 1170, 1167, 170, 1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188, - 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, - 518, 512, 2268, 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, - 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395, 2185, - 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, - 1456, 1470, 2455, 799, 2433, 2430, 779, 776, 773, 2397, 2394, 2390, - 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, - 673, 670, 667, 688, 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, - 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718, 2709, - 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, - 2760, 2758, 142, 141, 1139, 1138, 134, 132, 129, 126, 1982, 1129, - 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, - 115, 1109, 1108, 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, - 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98, - 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, - 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920, 1031, 1030, - 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, - 1046, 1044, 1944, 1943, 1941, 11, 9, 1868, 7, 1865, 1862, 1859, - 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, - 26, 23, 983, 981, 978, 975, 33, 971, 31, 990, 988, 985, - 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, - 323, 2135, 339, 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, - 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090, - 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, - 1300, 1314, 189, 2038, 186, 2036, 183, 2033, 2030, 2026, 206, 198, - 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, - 2300, 2286, 2284, 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, - 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569, 1567, - 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, - 474, 491, 1527, 1525, 1522, 2475, 2467, 2465, 2451, 2449, 2446, 801, - 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, - 2382, 2379, 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, - 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579, 1800, 2591, 2550, - 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, - 1833, 1831, 2690, 2688, 2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, - 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636, 1633, - 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, - 1775, 822, 820, 1757, 1755, 1584, 524, 1560, 1558, 468, 464, 1514, - 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, - 2208, 364, 361, 358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, - 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672, 669, - 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, - 1637, 1635, 920, 918, 884, 880, 889, 849, 848, 847, 846, 2497, - 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, - 1340, 1338, 1335, 1343, 255, 251, 247, 1296, 1291, 1288, 265, 1302, - 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210, - 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, - 1162, 1160, 1158, 1155, 161, 1152, 157, 1173, 1171, 1168, 1165, 168, - 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, - 1562, 1559, 458, 447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, - 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460, 2209, - 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, - 656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519, 2516, 885, 883, - 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, - 1125, 1124, 1122, 1127, 109, 106, 102, 1103, 1102, 1100, 1098, 116, - 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, - 1060, 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, - 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029, - 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, - 4, 1863, 1, 1860, 956, 954, 952, 949, 946, 17, 14, 969, - 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, - 1896, 986, 1905, 1903, 350, 349, 1381, 329, 327, 324, 1368, 1366, - 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, - 237, 2086, 233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, - 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231, 1229, 1226, - 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, - 1586, 507, 506, 504, 502, 2257, 499, 2254, 515, 1563, 1561, 445, - 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, - 1512, 2447, 798, 797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, - 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546, 2543, - 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, - 1732, 1731, 1735, 1814, 1707, 1670, 1668, 1631, 1629, 1626, 1634, 1599, - 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, - 1504, 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, - 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394, 1404, 2171, 2170, 1708, - 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, - 1336, 1286, 1281, 1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, - 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150, 1148, 1146, - 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, - 2017, 2016, 2014, 2019, 1582, 510, 1556, 1553, 452, 448, 1506, 1500, - 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, - 1709, 662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, - 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094, 1092, 103, 1101, - 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, - 1071, 1964, 1963, 1007, 1006, 1004, 1002, 999, 41, 996, 37, 1017, - 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940, - 938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, - 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897, 1379, 325, - 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, - 1283, 1280, 1294, 2112, 188, 185, 181, 178, 2028, 1219, 1217, 1215, - 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, - 500, 513, 1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, - 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706, 2377, - 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, - 1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385, 1395, 2169, 2167, - 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, - 1207, 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, - 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, 1433, 1431, 1428, 1425, - 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, - 1055, 1052, 1062, 1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, - 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951, - 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, - 1358, 1327, 1325, 1322, 1331, 1277, 1275, 1272, 1269, 235, 1284, 2110, - 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, - 1551, 1548, 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, - 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208, 2058, 2054, - 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, - 1656, 1975, 1053, 1957, 1954, 1001, 998, 1924, 1921, 1918, 1928, 937, - 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270, - 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, - 1478, 1491, 1700}; - -CBC_PDF417Common::CBC_PDF417Common() {} -CBC_PDF417Common::~CBC_PDF417Common() {} -int32_t CBC_PDF417Common::getBitCountSum(CFX_Int32Array& moduleBitCount) { - int32_t bitCountSum = 0; - for (int32_t i = 0; i < moduleBitCount.GetSize(); i++) { - int32_t count = moduleBitCount.GetAt(i); - bitCountSum += count; - } - return bitCountSum; -} -int32_t CBC_PDF417Common::getCodeword(FX_DWORD symbol) { - FX_DWORD sym = symbol & 0x3FFFF; - int32_t i = findCodewordIndex(sym); - if (i == -1) { - return -1; - } - return (CODEWORD_TABLE[i] - 1) % NUMBER_OF_CODEWORDS; -} -int32_t CBC_PDF417Common::findCodewordIndex(FX_DWORD symbol) { - int32_t first = 0; - int32_t upto = sizeof(SYMBOL_TABLE) / sizeof(SYMBOL_TABLE[0]); - while (first < upto) { - int32_t mid = ((FX_DWORD)(first + upto)) >> 1; - if (symbol < (FX_DWORD)SYMBOL_TABLE[mid]) { - upto = mid; - } else if (symbol > (FX_DWORD)SYMBOL_TABLE[mid]) { - first = mid + 1; - } else { - return mid; - } - } - return -1; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Common.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Common.h deleted file mode 100644 index f145b25383..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Common.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_PDF417_BC_PDF417COMMON_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417COMMON_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_PDF417Common { - public: - CBC_PDF417Common(); - virtual ~CBC_PDF417Common(); - static int32_t getBitCountSum(CFX_Int32Array& moduleBitCount); - static int32_t getCodeword(FX_DWORD symbol); - static int32_t NUMBER_OF_CODEWORDS; - static int32_t MAX_CODEWORDS_IN_BARCODE; - static int32_t MIN_ROWS_IN_BARCODE; - static int32_t MAX_ROWS_IN_BARCODE; - static int32_t MAX_CODEWORDS_IN_ROW; - static int32_t MODULES_IN_CODEWORD; - static int32_t MODULES_IN_STOP_PATTERN; - static int32_t BARS_IN_MODULE; - static int32_t SYMBOL_TABLE[]; - static int32_t CODEWORD_TABLE[]; - - private: - static CFX_Int32Array* EMPTY_INT_ARRAY; - static int32_t findCodewordIndex(FX_DWORD symbol); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417COMMON_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.cpp deleted file mode 100644 index 01e85d64c0..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.cpp +++ /dev/null @@ -1,26 +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 -// Original code is licensed as follows: -/* - * Copyright 2011 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" - -CBC_Compaction::CBC_Compaction() {} -CBC_Compaction::~CBC_Compaction() {} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h deleted file mode 100644 index 4c60e2d841..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h +++ /dev/null @@ -1,18 +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_SRC_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ - -class CBC_Compaction; -enum Compaction { AUTO, TEXT, BYTES, NUMERIC }; -class CBC_Compaction { - public: - CBC_Compaction(); - virtual ~CBC_Compaction(); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417COMPACTION_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp deleted file mode 100644 index 7a04fddebe..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp +++ /dev/null @@ -1,493 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" - -#include <stdlib.h> - -#include "third_party/bigint/BigIntegerLibrary.hh" -#include "xfa/src/fxbarcode/BC_DecoderResult.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" -#include "xfa/src/fxbarcode/utils.h" - -#define TEXT_COMPACTION_MODE_LATCH 900 -#define BYTE_COMPACTION_MODE_LATCH 901 -#define NUMERIC_COMPACTION_MODE_LATCH 902 -#define BYTE_COMPACTION_MODE_LATCH_6 924 -#define BEGIN_MACRO_PDF417_CONTROL_BLOCK 928 -#define BEGIN_MACRO_PDF417_OPTIONAL_FIELD 923 -#define MACRO_PDF417_TERMINATOR 922 -#define MODE_SHIFT_TO_BYTE_COMPACTION_MODE 913 - -int32_t CBC_DecodedBitStreamPaser::MAX_NUMERIC_CODEWORDS = 15; -int32_t CBC_DecodedBitStreamPaser::NUMBER_OF_SEQUENCE_CODEWORDS = 2; -int32_t CBC_DecodedBitStreamPaser::PL = 25; -int32_t CBC_DecodedBitStreamPaser::LL = 27; -int32_t CBC_DecodedBitStreamPaser::AS = 27; -int32_t CBC_DecodedBitStreamPaser::ML = 28; -int32_t CBC_DecodedBitStreamPaser::AL = 28; -int32_t CBC_DecodedBitStreamPaser::PS = 29; -int32_t CBC_DecodedBitStreamPaser::PAL = 29; -FX_CHAR CBC_DecodedBitStreamPaser::PUNCT_CHARS[29] = { - ';', '<', '>', '@', '[', '\\', '}', '_', '`', '~', - '!', '\r', '\t', ',', ':', '\n', '-', '.', '$', '/', - '"', '|', '*', '(', ')', '?', '{', '}', '\''}; -FX_CHAR CBC_DecodedBitStreamPaser::MIXED_CHARS[30] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '&', '\r', '\t', - ',', ':', '#', '-', '.', '$', '/', '+', '%', '*', '=', '^'}; - -void CBC_DecodedBitStreamPaser::Initialize() {} -void CBC_DecodedBitStreamPaser::Finalize() {} -CBC_DecodedBitStreamPaser::CBC_DecodedBitStreamPaser() {} -CBC_DecodedBitStreamPaser::~CBC_DecodedBitStreamPaser() {} -CBC_CommonDecoderResult* CBC_DecodedBitStreamPaser::decode( - CFX_Int32Array& codewords, - CFX_ByteString ecLevel, - int32_t& e) { - CFX_ByteString result; - int32_t codeIndex = 1; - int32_t code = codewords.GetAt(codeIndex); - codeIndex++; - CBC_PDF417ResultMetadata* resultMetadata = new CBC_PDF417ResultMetadata; - while (codeIndex < codewords[0]) { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - codeIndex = textCompaction(codewords, codeIndex, result); - break; - case BYTE_COMPACTION_MODE_LATCH: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case NUMERIC_COMPACTION_MODE_LATCH: - codeIndex = numericCompaction(codewords, codeIndex, result, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case BYTE_COMPACTION_MODE_LATCH_6: - codeIndex = byteCompaction(code, codewords, codeIndex, result); - break; - case BEGIN_MACRO_PDF417_CONTROL_BLOCK: - codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata, e); - if (e != BCExceptionNO) { - delete resultMetadata; - return NULL; - } - break; - default: - codeIndex--; - codeIndex = textCompaction(codewords, codeIndex, result); - break; - } - if (codeIndex < codewords.GetSize()) { - code = codewords[codeIndex++]; - } else { - e = BCExceptionFormatInstance; - delete resultMetadata; - return NULL; - } - } - if (result.GetLength() == 0) { - e = BCExceptionFormatInstance; - delete resultMetadata; - return NULL; - } - CFX_ByteArray rawBytes; - CFX_PtrArray byteSegments; - CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); - tempCd->Init(rawBytes, result, byteSegments, ecLevel, e); - if (e != BCExceptionNO) { - delete resultMetadata; - return NULL; - } - tempCd->setOther(resultMetadata); - return tempCd; -} -int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock( - CFX_Int32Array& codewords, - int32_t codeIndex, - CBC_PDF417ResultMetadata* resultMetadata, - int32_t& e) { - if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { - e = BCExceptionFormatInstance; - return -1; - } - CFX_Int32Array segmentIndexArray; - segmentIndexArray.SetSize(NUMBER_OF_SEQUENCE_CODEWORDS); - for (int32_t i = 0; i < NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) { - segmentIndexArray.SetAt(i, codewords[codeIndex]); - } - CFX_ByteString str = - decodeBase900toBase10(segmentIndexArray, NUMBER_OF_SEQUENCE_CODEWORDS, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - resultMetadata->setSegmentIndex(atoi(str.GetBuffer(str.GetLength()))); - CFX_ByteString fileId; - codeIndex = textCompaction(codewords, codeIndex, fileId); - resultMetadata->setFileId(fileId); - if (codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { - codeIndex++; - CFX_Int32Array additionalOptionCodeWords; - additionalOptionCodeWords.SetSize(codewords[0] - codeIndex); - int32_t additionalOptionCodeWordsIndex = 0; - FX_BOOL end = FALSE; - while ((codeIndex < codewords[0]) && !end) { - int32_t code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - additionalOptionCodeWords[additionalOptionCodeWordsIndex++] = code; - } else { - switch (code) { - case MACRO_PDF417_TERMINATOR: - resultMetadata->setLastSegment(TRUE); - codeIndex++; - end = TRUE; - break; - default: - e = BCExceptionFormatInstance; - return -1; - } - } - } - CFX_Int32Array array; - array.SetSize(additionalOptionCodeWordsIndex); - array.Copy(additionalOptionCodeWords); - resultMetadata->setOptionalData(array); - } else if (codewords[codeIndex] == MACRO_PDF417_TERMINATOR) { - resultMetadata->setLastSegment(TRUE); - codeIndex++; - } - return codeIndex; -} -int32_t CBC_DecodedBitStreamPaser::textCompaction(CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result) { - CFX_Int32Array textCompactionData; - textCompactionData.SetSize((codewords[0] - codeIndex) << 1); - CFX_Int32Array byteCompactionData; - byteCompactionData.SetSize((codewords[0] - codeIndex) << 1); - int32_t index = 0; - FX_BOOL end = FALSE; - while ((codeIndex < codewords[0]) && !end) { - int32_t code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - textCompactionData[index] = code / 30; - textCompactionData[index + 1] = code % 30; - index += 2; - } else { - switch (code) { - case TEXT_COMPACTION_MODE_LATCH: - textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; - break; - case BYTE_COMPACTION_MODE_LATCH: - codeIndex--; - end = TRUE; - break; - case NUMERIC_COMPACTION_MODE_LATCH: - codeIndex--; - end = TRUE; - break; - case BEGIN_MACRO_PDF417_CONTROL_BLOCK: - codeIndex--; - end = TRUE; - break; - case BEGIN_MACRO_PDF417_OPTIONAL_FIELD: - codeIndex--; - end = TRUE; - break; - case MACRO_PDF417_TERMINATOR: - codeIndex--; - end = TRUE; - break; - case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: - textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; - code = codewords[codeIndex++]; - byteCompactionData[index] = code; - index++; - break; - case BYTE_COMPACTION_MODE_LATCH_6: - codeIndex--; - end = TRUE; - break; - } - } - } - decodeTextCompaction(textCompactionData, byteCompactionData, index, result); - return codeIndex; -} -void CBC_DecodedBitStreamPaser::decodeTextCompaction( - CFX_Int32Array& textCompactionData, - CFX_Int32Array& byteCompactionData, - int32_t length, - CFX_ByteString& result) { - Mode subMode = ALPHA; - Mode priorToShiftMode = ALPHA; - int32_t i = 0; - while (i < length) { - int32_t subModeCh = textCompactionData[i]; - FX_CHAR ch = 0; - switch (subMode) { - case ALPHA: - if (subModeCh < 26) { - ch = (FX_CHAR)('A' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == LL) { - subMode = LOWER; - } else if (subModeCh == ML) { - subMode = MIXED; - } else if (subModeCh == PS) { - priorToShiftMode = subMode; - subMode = PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result += (FX_CHAR)byteCompactionData[i]; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - case LOWER: - if (subModeCh < 26) { - ch = (FX_CHAR)('a' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == AS) { - priorToShiftMode = subMode; - subMode = ALPHA_SHIFT; - } else if (subModeCh == ML) { - subMode = MIXED; - } else if (subModeCh == PS) { - priorToShiftMode = subMode; - subMode = PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result += (FX_CHAR)byteCompactionData[i]; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - case MIXED: - if (subModeCh < PL) { - ch = MIXED_CHARS[subModeCh]; - } else { - if (subModeCh == PL) { - subMode = PUNCT; - } else if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == LL) { - subMode = LOWER; - } else if (subModeCh == AL) { - subMode = ALPHA; - } else if (subModeCh == PS) { - priorToShiftMode = subMode; - subMode = PUNCT_SHIFT; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result += (FX_CHAR)byteCompactionData[i]; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - case PUNCT: - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - if (subModeCh == PAL) { - subMode = ALPHA; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result += (FX_CHAR)byteCompactionData[i]; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - case ALPHA_SHIFT: - subMode = priorToShiftMode; - if (subModeCh < 26) { - ch = (FX_CHAR)('A' + subModeCh); - } else { - if (subModeCh == 26) { - ch = ' '; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - case PUNCT_SHIFT: - subMode = priorToShiftMode; - if (subModeCh < PAL) { - ch = PUNCT_CHARS[subModeCh]; - } else { - if (subModeCh == PAL) { - subMode = ALPHA; - } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result += (FX_CHAR)byteCompactionData[i]; - } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { - subMode = ALPHA; - } - } - break; - } - if (ch != 0) { - result += ch; - } - i++; - } -} -int32_t CBC_DecodedBitStreamPaser::byteCompaction(int32_t mode, - CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result) { - if (mode == BYTE_COMPACTION_MODE_LATCH) { - int32_t count = 0; - int64_t value = 0; - FX_WORD* decodedData = FX_Alloc(FX_WORD, 6); - CFX_Int32Array byteCompactedCodewords; - byteCompactedCodewords.SetSize(6); - FX_BOOL end = FALSE; - int32_t nextCode = codewords[codeIndex++]; - while ((codeIndex < codewords[0]) && !end) { - byteCompactedCodewords[count++] = nextCode; - value = 900 * value + nextCode; - nextCode = codewords[codeIndex++]; - if (nextCode == TEXT_COMPACTION_MODE_LATCH || - nextCode == BYTE_COMPACTION_MODE_LATCH || - nextCode == NUMERIC_COMPACTION_MODE_LATCH || - nextCode == BYTE_COMPACTION_MODE_LATCH_6 || - nextCode == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - nextCode == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - nextCode == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = TRUE; - } else { - if ((count % 5 == 0) && (count > 0)) { - int32_t j = 0; - for (; j < 6; ++j) { - decodedData[5 - j] = (FX_WORD)(value % 256); - value >>= 8; - } - for (j = 0; j < 6; ++j) { - result += (FX_CHAR)decodedData[j]; - } - count = 0; - } - } - } - FX_Free(decodedData); - if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) { - byteCompactedCodewords[count++] = nextCode; - } - for (int32_t i = 0; i < count; i++) { - result += (FX_CHAR)(FX_WORD)byteCompactedCodewords[i]; - } - } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { - int32_t count = 0; - int64_t value = 0; - FX_BOOL end = FALSE; - while (codeIndex < codewords[0] && !end) { - int32_t code = codewords[codeIndex++]; - if (code < TEXT_COMPACTION_MODE_LATCH) { - count++; - value = 900 * value + code; - } else { - if (code == TEXT_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH || - code == NUMERIC_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH_6 || - code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - code == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = TRUE; - } - } - if ((count % 5 == 0) && (count > 0)) { - FX_WORD* decodedData = FX_Alloc(FX_WORD, 6); - int32_t j = 0; - for (; j < 6; ++j) { - decodedData[5 - j] = (FX_WORD)(value & 0xFF); - value >>= 8; - } - for (j = 0; j < 6; ++j) { - result += (FX_CHAR)decodedData[j]; - } - count = 0; - FX_Free(decodedData); - } - } - } - return codeIndex; -} -int32_t CBC_DecodedBitStreamPaser::numericCompaction(CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result, - int32_t& e) { - int32_t count = 0; - FX_BOOL end = FALSE; - CFX_Int32Array numericCodewords; - numericCodewords.SetSize(MAX_NUMERIC_CODEWORDS); - while (codeIndex < codewords[0] && !end) { - int32_t code = codewords[codeIndex++]; - if (codeIndex == codewords[0]) { - end = TRUE; - } - if (code < TEXT_COMPACTION_MODE_LATCH) { - numericCodewords[count] = code; - count++; - } else { - if (code == TEXT_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH || - code == BYTE_COMPACTION_MODE_LATCH_6 || - code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || - code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || - code == MACRO_PDF417_TERMINATOR) { - codeIndex--; - end = TRUE; - } - } - if (count % MAX_NUMERIC_CODEWORDS == 0 || - code == NUMERIC_COMPACTION_MODE_LATCH || end) { - CFX_ByteString s = decodeBase900toBase10(numericCodewords, count, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - result += s; - count = 0; - } - } - return codeIndex; -} -CFX_ByteString CBC_DecodedBitStreamPaser::decodeBase900toBase10( - CFX_Int32Array& codewords, - int32_t count, - int32_t& e) { - BigInteger result = 0; - BigInteger nineHundred(900); - for (int32_t i = 0; i < count; i++) { - result = result * nineHundred + BigInteger(codewords[i]); - } - CFX_ByteString resultString(bigIntegerToString(result).c_str()); - if (resultString.GetAt(0) != '1') { - e = BCExceptionFormatInstance; - return ' '; - } - return resultString.Mid(1, resultString.GetLength() - 1); -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h b/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h deleted file mode 100644 index 52901c66bf..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h +++ /dev/null @@ -1,63 +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_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "core/include/fxcrt/fx_string.h" - -class CBC_CommonDecoderResult; -class CBC_PDF417ResultMetadata; - -class CBC_DecodedBitStreamPaser { - public: - CBC_DecodedBitStreamPaser(); - virtual ~CBC_DecodedBitStreamPaser(); - static void Initialize(); - static void Finalize(); - static CBC_CommonDecoderResult* decode(CFX_Int32Array& codewords, - CFX_ByteString ecLevel, - int32_t& e); - - private: - enum Mode { ALPHA, LOWER, MIXED, PUNCT, ALPHA_SHIFT, PUNCT_SHIFT }; - static int32_t MAX_NUMERIC_CODEWORDS; - static int32_t PL; - static int32_t LL; - static int32_t AS; - static int32_t ML; - static int32_t AL; - static int32_t PS; - static int32_t PAL; - static FX_CHAR PUNCT_CHARS[29]; - static FX_CHAR MIXED_CHARS[30]; - static int32_t NUMBER_OF_SEQUENCE_CODEWORDS; - static int32_t decodeMacroBlock(CFX_Int32Array& codewords, - int32_t codeIndex, - CBC_PDF417ResultMetadata* resultMetadata, - int32_t& e); - static int32_t textCompaction(CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result); - static void decodeTextCompaction(CFX_Int32Array& textCompactionData, - CFX_Int32Array& byteCompactionData, - int32_t length, - CFX_ByteString& result); - static int32_t byteCompaction(int32_t mode, - CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result); - static int32_t numericCompaction(CFX_Int32Array& codewords, - int32_t codeIndex, - CFX_ByteString& result, - int32_t& e); - static CFX_ByteString decodeBase900toBase10(CFX_Int32Array& codewords, - int32_t count, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp deleted file mode 100644 index b9eee7c446..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp +++ /dev/null @@ -1,339 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" - -int32_t CBC_DetectionResult::ADJUST_ROW_NUMBER_SKIP = 2; - -CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, - CBC_BoundingBox* boundingBox) { - m_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; - } -} -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)); - adjustIndicatorColumnRowNumbers( - (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt( - m_barcodeColumnCount + 1)); - int32_t unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE; - int32_t previousUnadjustedCount; - do { - previousUnadjustedCount = unadjustedCodewordCount; - unadjustedCodewordCount = adjustRowNumbers(); - } while (unadjustedCodewordCount > 0 && - unadjustedCodewordCount < previousUnadjustedCount); - return m_detectionResultColumns; -} -void CBC_DetectionResult::setBoundingBox(CBC_BoundingBox* boundingBox) { - m_boundingBox = boundingBox; -} -CBC_BoundingBox* CBC_DetectionResult::getBoundingBox() { - return m_boundingBox; -} -void CBC_DetectionResult::setDetectionResultColumn( - int32_t barcodeColumn, - CBC_DetectionResultColumn* detectionResultColumn) { - m_detectionResultColumns[barcodeColumn] = detectionResultColumn; -} -CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn( - int32_t barcodeColumn) { - return (CBC_DetectionResultColumn*)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]; - } - CFX_ByteString result; - for (int32_t codewordsRow = 0; - codewordsRow < rowIndicatorColumn->getCodewords()->GetSize(); - codewordsRow++) { - result += (FX_CHAR)codewordsRow; - for (int32_t barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount + 2; - barcodeColumn++) { - if (m_detectionResultColumns[barcodeColumn] == NULL) { - result += " | "; - continue; - } - CBC_Codeword* codeword = - (CBC_Codeword*)((CBC_DetectionResultColumn*) - m_detectionResultColumns[barcodeColumn]) - ->getCodewords() - ->GetAt(codewordsRow); - if (codeword == NULL) { - result += " | "; - continue; - } - result += codeword->getRowNumber(); - result += codeword->getValue(); - } - } - return result; -} -void CBC_DetectionResult::adjustIndicatorColumnRowNumbers( - CBC_DetectionResultColumn* detectionResultColumn) { - if (detectionResultColumn) { - ((CBC_DetectionResultRowIndicatorColumn*)detectionResultColumn) - ->adjustCompleteIndicatorColumnRowNumbers(*m_barcodeMetadata); - } -} -int32_t CBC_DetectionResult::adjustRowNumbers() { - int32_t unadjustedCount = adjustRowNumbersByRow(); - if (unadjustedCount == 0) { - return 0; - } - for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; - barcodeColumn++) { - CFX_PtrArray* codewords = - ((CBC_DetectionResultColumn*)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()) { - adjustRowNumbers(barcodeColumn, codewordsRow, codewords); - } - } - } - return unadjustedCount; -} -int32_t CBC_DetectionResult::adjustRowNumbersByRow() { - adjustRowNumbersFromBothRI(); - int32_t unadjustedCount = adjustRowNumbersFromLRI(); - return unadjustedCount + adjustRowNumbersFromRRI(); -} -int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() { - if (m_detectionResultColumns[0] == NULL || - m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { - return 0; - } - CFX_PtrArray* LRIcodewords = - ((CBC_DetectionResultColumn*)m_detectionResultColumns[0])->getCodewords(); - CFX_PtrArray* RRIcodewords = - ((CBC_DetectionResultColumn*) - 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()) { - 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) { - continue; - } - codeword->setRowNumber( - ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber()); - if (!codeword->hasValidRowNumber()) { - ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]) - ->getCodewords() - ->SetAt(codewordsRow, NULL); - } - } - } - } - return 0; -} -int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { - if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { - return 0; - } - int32_t unadjustedCount = 0; - CFX_PtrArray* codewords = - ((CBC_DetectionResultColumn*)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(); - 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); - if (codeword) { - invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, - invalidRowCounts, codeword); - if (!codeword->hasValidRowNumber()) { - unadjustedCount++; - } - } - } - } - return unadjustedCount; -} -int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { - if (m_detectionResultColumns[0] == NULL) { - return 0; - } - int32_t unadjustedCount = 0; - CFX_PtrArray* codewords = - ((CBC_DetectionResultColumn*)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(); - 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); - if (codeword) { - invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, - invalidRowCounts, codeword); - if (!codeword->hasValidRowNumber()) { - unadjustedCount++; - } - } - } - } - return unadjustedCount; -} -int32_t CBC_DetectionResult::adjustRowNumberIfValid( - int32_t rowIndicatorRowNumber, - int32_t invalidRowCounts, - CBC_Codeword* codeword) { - if (codeword == NULL) { - return invalidRowCounts; - } - if (!codeword->hasValidRowNumber()) { - if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { - codeword->setRowNumber(rowIndicatorRowNumber); - invalidRowCounts = 0; - } else { - ++invalidRowCounts; - } - } - 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; - if (m_detectionResultColumns[barcodeColumn + 1]) { - nextColumnCodewords = ((CBC_DetectionResultColumn*) - m_detectionResultColumns[barcodeColumn + 1]) - ->getCodewords(); - } - CFX_PtrArray otherCodewords; - otherCodewords.SetSize(14); - otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow); - otherCodewords[3] = nextColumnCodewords->GetAt(codewordsRow); - if (codewordsRow > 0) { - otherCodewords[0] = codewords->GetAt(codewordsRow - 1); - otherCodewords[4] = previousColumnCodewords->GetAt(codewordsRow - 1); - otherCodewords[5] = nextColumnCodewords->GetAt(codewordsRow - 1); - } - if (codewordsRow > 1) { - otherCodewords[8] = codewords->GetAt(codewordsRow - 2); - otherCodewords[10] = previousColumnCodewords->GetAt(codewordsRow - 2); - otherCodewords[11] = nextColumnCodewords->GetAt(codewordsRow - 2); - } - if (codewordsRow < codewords->GetSize() - 1) { - otherCodewords[1] = codewords->GetAt(codewordsRow + 1); - otherCodewords[6] = previousColumnCodewords->GetAt(codewordsRow + 1); - otherCodewords[7] = nextColumnCodewords->GetAt(codewordsRow + 1); - } - if (codewordsRow < codewords->GetSize() - 2) { - otherCodewords[9] = codewords->GetAt(codewordsRow + 2); - otherCodewords[12] = previousColumnCodewords->GetAt(codewordsRow + 2); - otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2); - } - for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { - CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i); - if (adjustRowNumber(codeword, otherCodeword)) { - return; - } - } -} -FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, - CBC_Codeword* otherCodeword) { - if (otherCodeword == NULL) { - return FALSE; - } - if (otherCodeword->hasValidRowNumber() && - otherCodeword->getBucket() == codeword->getBucket()) { - codeword->setRowNumber(otherCodeword->getRowNumber()); - return TRUE; - } - return FALSE; -} -int32_t CBC_DetectionResult::getBarcodeColumnCount() { - return m_barcodeColumnCount; -} -int32_t CBC_DetectionResult::getBarcodeRowCount() { - return m_barcodeMetadata->getRowCount(); -} -int32_t CBC_DetectionResult::getBarcodeECLevel() { - return m_barcodeMetadata->getErrorCorrectionLevel(); -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h deleted file mode 100644 index 969d513c7e..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.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_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ - -class CBC_BarcodeMetadata; -class CBC_BoundingBox; -class CBC_Codeword; -class CBC_DetectionResultColumn; -class CBC_DetectionResult { - public: - CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, - CBC_BoundingBox* boundingBox); - virtual ~CBC_DetectionResult(); - CFX_PtrArray& getDetectionResultColumns(); - void setBoundingBox(CBC_BoundingBox* boundingBox); - CBC_BoundingBox* getBoundingBox(); - void setDetectionResultColumn( - int32_t barcodeColumn, - CBC_DetectionResultColumn* detectionResultColumn); - CBC_DetectionResultColumn* getDetectionResultColumn(int32_t barcodeColumn); - CFX_ByteString toString(); - - int32_t getBarcodeColumnCount(); - int32_t getBarcodeRowCount(); - int32_t getBarcodeECLevel(); - - private: - static int32_t ADJUST_ROW_NUMBER_SKIP; - CBC_BarcodeMetadata* m_barcodeMetadata; - CFX_PtrArray m_detectionResultColumns; - CBC_BoundingBox* m_boundingBox; - int32_t m_barcodeColumnCount; - - private: - void adjustIndicatorColumnRowNumbers( - CBC_DetectionResultColumn* detectionResultColumn); - int32_t adjustRowNumbers(); - int32_t adjustRowNumbersByRow(); - int32_t adjustRowNumbersFromBothRI(); - int32_t adjustRowNumbersFromRRI(); - int32_t adjustRowNumbersFromLRI(); - static int32_t adjustRowNumberIfValid(int32_t rowIndicatorRowNumber, - int32_t invalidRowCounts, - CBC_Codeword* codeword); - void adjustRowNumbers(int32_t barcodeColumn, - int32_t codewordsRow, - CFX_PtrArray* codewords); - static FX_BOOL adjustRowNumber(CBC_Codeword* codeword, - CBC_Codeword* otherCodeword); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULT_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp deleted file mode 100644 index e375b7c30f..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp +++ /dev/null @@ -1,101 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" - -int32_t CBC_DetectionResultColumn::MAX_NEARBY_DISTANCE = 5; - -CBC_DetectionResultColumn::CBC_DetectionResultColumn( - CBC_BoundingBox* boundingBox) { - m_boundingBox = boundingBox; - m_codewords = new CFX_PtrArray; - 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); - } - m_codewords->RemoveAll(); - delete m_codewords; -} -CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(int32_t imageRow) { - CBC_Codeword* codeword = getCodeword(imageRow); - if (codeword) { - return codeword; - } - for (int32_t i = 1; i < MAX_NEARBY_DISTANCE; i++) { - int32_t nearImageRow = imageRowToCodewordIndex(imageRow) - i; - if (nearImageRow >= 0) { - codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); - if (codeword) { - return codeword; - } - } - nearImageRow = imageRowToCodewordIndex(imageRow) + i; - if (nearImageRow < m_codewords->GetSize()) { - codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); - if (codeword) { - return codeword; - } - } - } - return NULL; -} -int32_t CBC_DetectionResultColumn::imageRowToCodewordIndex(int32_t imageRow) { - return imageRow - m_boundingBox->getMinY(); -} -int32_t CBC_DetectionResultColumn::codewordIndexToImageRow( - int32_t codewordIndex) { - return m_boundingBox->getMinY() + codewordIndex; -} -void CBC_DetectionResultColumn::setCodeword(int32_t imageRow, - CBC_Codeword* codeword) { - m_codewords->SetAt(imageRowToCodewordIndex(imageRow), codeword); -} -CBC_Codeword* CBC_DetectionResultColumn::getCodeword(int32_t imageRow) { - return (CBC_Codeword*)m_codewords->GetAt(imageRowToCodewordIndex(imageRow)); -} -CBC_BoundingBox* CBC_DetectionResultColumn::getBoundingBox() { - return m_boundingBox; -} -CFX_PtrArray* CBC_DetectionResultColumn::getCodewords() { - return m_codewords; -} -CFX_ByteString CBC_DetectionResultColumn::toString() { - CFX_ByteString result; - int32_t row = 0; - for (int32_t i = 0; i < m_codewords->GetSize(); i++) { - CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i); - if (codeword == NULL) { - result += (FX_CHAR)row; - row++; - continue; - } - result += (FX_CHAR)row; - result += codeword->getRowNumber(); - result += codeword->getValue(); - row++; - } - return result; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h deleted file mode 100644 index 279b2c1057..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h +++ /dev/null @@ -1,33 +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_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ - -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_ByteString toString(); - - public: - CBC_BoundingBox* m_boundingBox; - CFX_PtrArray* m_codewords; - - private: - static int32_t MAX_NEARBY_DISTANCE; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTCOLUMN_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp deleted file mode 100644 index 403c34c5fd..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp +++ /dev/null @@ -1,267 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_DetectionResultRowIndicatorColumn::CBC_DetectionResultRowIndicatorColumn( - CBC_BoundingBox* boundingBox, - FX_BOOL isLeft) - : CBC_DetectionResultColumn(boundingBox) { - m_isLeft = isLeft; -} -CBC_DetectionResultRowIndicatorColumn:: - ~CBC_DetectionResultRowIndicatorColumn() {} -void CBC_DetectionResultRowIndicatorColumn::setRowNumbers() { - for (int32_t i = 0; i < m_codewords->GetSize(); i++) { - CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i); - if (codeword) { - codeword->setRowNumberAsRowIndicatorColumn(); - } - } -} -int32_t -CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers( - CBC_BarcodeMetadata barcodeMetadata) { - CFX_PtrArray* codewords = getCodewords(); - setRowNumbers(); - removeIncorrectCodewords(codewords, barcodeMetadata); - CBC_BoundingBox* boundingBox = getBoundingBox(); - CBC_ResultPoint* top = - m_isLeft ? boundingBox->getTopLeft() : boundingBox->getTopRight(); - CBC_ResultPoint* bottom = - m_isLeft ? boundingBox->getBottomLeft() : boundingBox->getBottomRight(); - int32_t firstRow = imageRowToCodewordIndex((int32_t)top->GetY()); - int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY()); - FX_FLOAT averageRowHeight = - (lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount(); - int32_t barcodeRow = -1; - int32_t maxRowHeight = 1; - int32_t currentRowHeight = 0; - for (int32_t codewordsRow = firstRow; codewordsRow < lastRow; - codewordsRow++) { - if (codewords->GetAt(codewordsRow) == NULL) { - continue; - } - CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); - int32_t rowDifference = codeword->getRowNumber() - barcodeRow; - if (rowDifference == 0) { - currentRowHeight++; - } else if (rowDifference == 1) { - maxRowHeight = - maxRowHeight > currentRowHeight ? maxRowHeight : currentRowHeight; - currentRowHeight = 1; - barcodeRow = codeword->getRowNumber(); - } else if (rowDifference < 0) { - codewords->SetAt(codewordsRow, NULL); - } else if (codeword->getRowNumber() >= barcodeMetadata.getRowCount()) { - codewords->SetAt(codewordsRow, NULL); - } else if (rowDifference > codewordsRow) { - codewords->SetAt(codewordsRow, NULL); - } else { - int32_t checkedRows; - if (maxRowHeight > 2) { - checkedRows = (maxRowHeight - 2) * rowDifference; - } else { - checkedRows = rowDifference; - } - FX_BOOL closePreviousCodewordFound = checkedRows >= codewordsRow; - for (int32_t i = 1; i <= checkedRows && !closePreviousCodewordFound; - i++) { - closePreviousCodewordFound = codewords->GetAt(codewordsRow - i) != NULL; - } - if (closePreviousCodewordFound) { - codewords->SetAt(codewordsRow, NULL); - } else { - barcodeRow = codeword->getRowNumber(); - currentRowHeight = 1; - } - } - } - return (int32_t)(averageRowHeight + 0.5); -} -CFX_Int32Array* CBC_DetectionResultRowIndicatorColumn::getRowHeights( - int32_t& e) { - CBC_BarcodeMetadata* barcodeMetadata = getBarcodeMetadata(); - if (barcodeMetadata == NULL) { - e = BCExceptionCannotMetadata; - return NULL; - } - adjustIncompleteIndicatorColumnRowNumbers(*barcodeMetadata); - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(barcodeMetadata->getRowCount()); - for (int32_t i = 0; i < getCodewords()->GetSize(); i++) { - CBC_Codeword* codeword = (CBC_Codeword*)getCodewords()->GetAt(i); - if (codeword) { - result->SetAt(codeword->getRowNumber(), - result->GetAt(codeword->getRowNumber()) + 1); - } - } - return result; -} -int32_t CBC_DetectionResultRowIndicatorColumn:: - adjustIncompleteIndicatorColumnRowNumbers( - CBC_BarcodeMetadata barcodeMetadata) { - CBC_BoundingBox* boundingBox = getBoundingBox(); - CBC_ResultPoint* top = - m_isLeft ? boundingBox->getTopLeft() : boundingBox->getTopRight(); - CBC_ResultPoint* bottom = - m_isLeft ? boundingBox->getBottomLeft() : boundingBox->getBottomRight(); - int32_t firstRow = imageRowToCodewordIndex((int32_t)top->GetY()); - int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY()); - FX_FLOAT averageRowHeight = - (lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount(); - CFX_PtrArray* codewords = getCodewords(); - int32_t barcodeRow = -1; - int32_t maxRowHeight = 1; - int32_t currentRowHeight = 0; - for (int32_t codewordsRow = firstRow; codewordsRow < lastRow; - codewordsRow++) { - if (codewords->GetAt(codewordsRow) == NULL) { - continue; - } - CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); - codeword->setRowNumberAsRowIndicatorColumn(); - int32_t rowDifference = codeword->getRowNumber() - barcodeRow; - if (rowDifference == 0) { - currentRowHeight++; - } else if (rowDifference == 1) { - maxRowHeight = - maxRowHeight > currentRowHeight ? maxRowHeight : currentRowHeight; - currentRowHeight = 1; - barcodeRow = codeword->getRowNumber(); - } else if (codeword->getRowNumber() >= barcodeMetadata.getRowCount()) { - codewords->SetAt(codewordsRow, NULL); - } else { - barcodeRow = codeword->getRowNumber(); - currentRowHeight = 1; - } - } - return (int32_t)(averageRowHeight + 0.5); -} -CBC_BarcodeMetadata* -CBC_DetectionResultRowIndicatorColumn::getBarcodeMetadata() { - CFX_PtrArray* 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); - if (codeword == NULL) { - continue; - } - codeword->setRowNumberAsRowIndicatorColumn(); - int32_t rowIndicatorValue = codeword->getValue() % 30; - int32_t codewordRowNumber = codeword->getRowNumber(); - if (!m_isLeft) { - codewordRowNumber += 2; - } - switch (codewordRowNumber % 3) { - case 0: - barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1); - break; - case 1: - barcodeECLevel.setValue(rowIndicatorValue / 3); - barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3); - break; - case 2: - barcodeColumnCount.setValue(rowIndicatorValue + 1); - break; - } - } - if ((barcodeColumnCount.getValue()->GetSize() == 0) || - (barcodeRowCountUpperPart.getValue()->GetSize() == 0) || - (barcodeRowCountLowerPart.getValue()->GetSize() == 0) || - (barcodeECLevel.getValue()->GetSize() == 0) || - barcodeColumnCount.getValue()->GetAt(0) < 1 || - barcodeRowCountUpperPart.getValue()->GetAt(0) + - barcodeRowCountLowerPart.getValue()->GetAt(0) < - CBC_PDF417Common::MIN_ROWS_IN_BARCODE || - barcodeRowCountUpperPart.getValue()->GetAt(0) + - barcodeRowCountLowerPart.getValue()->GetAt(0) > - CBC_PDF417Common::MAX_ROWS_IN_BARCODE) { - return NULL; - } - CBC_BarcodeMetadata* barcodeMetadata = - new CBC_BarcodeMetadata(barcodeColumnCount.getValue()->GetAt(0), - barcodeRowCountUpperPart.getValue()->GetAt(0), - barcodeRowCountLowerPart.getValue()->GetAt(0), - barcodeECLevel.getValue()->GetAt(0)); - removeIncorrectCodewords(codewords, *barcodeMetadata); - return barcodeMetadata; -} -FX_BOOL CBC_DetectionResultRowIndicatorColumn::isLeft() { - return m_isLeft; -} -CFX_ByteString CBC_DetectionResultRowIndicatorColumn::toString() { - return (CFX_ByteString) "IsLeft: " + (CFX_ByteString)m_isLeft + '\n' + - CBC_DetectionResultColumn::toString(); -} -void CBC_DetectionResultRowIndicatorColumn::removeIncorrectCodewords( - CFX_PtrArray* codewords, - CBC_BarcodeMetadata barcodeMetadata) { - for (int32_t codewordRow = 0; codewordRow < codewords->GetSize(); - codewordRow++) { - CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordRow); - if (codeword == NULL) { - continue; - } - int32_t rowIndicatorValue = codeword->getValue() % 30; - int32_t codewordRowNumber = codeword->getRowNumber(); - if (codewordRowNumber > barcodeMetadata.getRowCount()) { - codewords->SetAt(codewordRow, NULL); - continue; - } - if (!m_isLeft) { - codewordRowNumber += 2; - } - switch (codewordRowNumber % 3) { - case 0: - if (rowIndicatorValue * 3 + 1 != - barcodeMetadata.getRowCountUpperPart()) { - codewords->SetAt(codewordRow, NULL); - } - break; - case 1: - if (rowIndicatorValue / 3 != - barcodeMetadata.getErrorCorrectionLevel() || - rowIndicatorValue % 3 != barcodeMetadata.getRowCountLowerPart()) { - codewords->SetAt(codewordRow, NULL); - } - break; - case 2: - if (rowIndicatorValue + 1 != barcodeMetadata.getColumnCount()) { - codewords->SetAt(codewordRow, NULL); - } - break; - } - } -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h deleted file mode 100644 index e235586fcd..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ - -class CBC_BarcodeMetadata; -class CBC_BoundingBox; -class CBC_DetectionResultRowIndicatorColumn; -class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn { - public: - CBC_DetectionResultRowIndicatorColumn(CBC_BoundingBox* boundingBox, - FX_BOOL isLeft); - virtual ~CBC_DetectionResultRowIndicatorColumn(); - void setRowNumbers(); - int32_t adjustCompleteIndicatorColumnRowNumbers( - CBC_BarcodeMetadata barcodeMetadata); - CFX_Int32Array* getRowHeights(int32_t& e); - int32_t adjustIncompleteIndicatorColumnRowNumbers( - CBC_BarcodeMetadata barcodeMetadata); - CBC_BarcodeMetadata* getBarcodeMetadata(); - FX_BOOL isLeft(); - CFX_ByteString toString(); - - private: - FX_BOOL m_isLeft; - void removeIncorrectCodewords(CFX_PtrArray* codewords, - CBC_BarcodeMetadata barcodeMetadata); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp deleted file mode 100644 index 54556af97c..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp +++ /dev/null @@ -1,352 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/utils.h" - -#define INTEGER_MAX 2147483647 - -int32_t CBC_Detector::INDEXES_START_PATTERN[] = {0, 4, 1, 5}; -int32_t CBC_Detector::INDEXES_STOP_PATTERN[] = {6, 2, 7, 3}; -int32_t CBC_Detector::INTEGER_MATH_SHIFT = 8; -int32_t CBC_Detector::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 - << INTEGER_MATH_SHIFT; -int32_t CBC_Detector::MAX_AVG_VARIANCE = - (int32_t)(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); -int32_t CBC_Detector::MAX_INDIVIDUAL_VARIANCE = - (int32_t)(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f); -int32_t CBC_Detector::START_PATTERN[] = {8, 1, 1, 1, 1, 1, 1, 3}; -int32_t CBC_Detector::STOP_PATTERN[] = {7, 1, 1, 3, 1, 1, 1, 2, 1}; -int32_t CBC_Detector::MAX_PIXEL_DRIFT = 3; -int32_t CBC_Detector::MAX_PATTERN_DRIFT = 5; -int32_t CBC_Detector::SKIPPED_ROW_COUNT_MAX = 25; -int32_t CBC_Detector::ROW_STEP = 5; -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); - if (barcodeCoordinates->GetSize() == 0) { - rotate180(bitMatrix); - barcodeCoordinates = detect(multiple, bitMatrix); - } - if (barcodeCoordinates->GetSize() == 0) { - e = BCExceptionUnSupportedBarcode; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CBC_PDF417DetectorResult* detectorResult = - new CBC_PDF417DetectorResult(bitMatrix, barcodeCoordinates); - return detectorResult; -} -void CBC_Detector::rotate180(CBC_CommonBitMatrix* bitMatrix) { - int32_t width = bitMatrix->GetWidth(); - int32_t height = bitMatrix->GetHeight(); - CBC_CommonBitArray* firstRowBitArray = new CBC_CommonBitArray(width); - CBC_CommonBitArray* secondRowBitArray = new CBC_CommonBitArray(width); - CBC_CommonBitArray* tmpBitArray = new CBC_CommonBitArray(width); - for (int32_t y = 0; y<(height + 1)>> 1; y++) { - CBC_CommonBitArray* temp = - bitMatrix->GetRow(height - 1 - y, secondRowBitArray); - CBC_CommonBitArray* tempfirstRow = firstRowBitArray; - firstRowBitArray = bitMatrix->GetRow(y, tempfirstRow); - delete tempfirstRow; - CBC_CommonBitArray* row = mirror(temp, tmpBitArray); - delete temp; - bitMatrix->SetRow(y, row); - delete row; - CBC_CommonBitArray* rowfirstRow = mirror(firstRowBitArray, tmpBitArray); - bitMatrix->SetRow(height - 1 - y, rowfirstRow); - delete rowfirstRow; - } - delete tmpBitArray; - delete firstRowBitArray; - delete secondRowBitArray; -} -CBC_CommonBitArray* CBC_Detector::mirror(CBC_CommonBitArray* input, - CBC_CommonBitArray* result) { - CBC_CommonBitArray* array = new CBC_CommonBitArray(result->GetSize()); - array->Clear(); - int32_t size = input->GetSize(); - for (int32_t i = 0; i < size; i++) { - if (input->Get(i)) { - array->Set(size - 1 - i); - } - } - return array; -} -CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, - CBC_CommonBitMatrix* bitMatrix) { - CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray; - int32_t row = 0; - int32_t column = 0; - FX_BOOL foundBarcodeInRow = FALSE; - while (row < bitMatrix->GetHeight()) { - CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); - if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { - if (!foundBarcodeInRow) { - if (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); - if (barcodeCoordinate->GetAt(1)) { - row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); - } - if (barcodeCoordinate->GetAt(3)) { - row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); - } - } - row += ROW_STEP; - if (vertices) { - delete (vertices); - } - continue; - } - foundBarcodeInRow = TRUE; - barcodeCoordinates->Add(vertices); - if (!multiple) { - break; - } - if (vertices->GetAt(2)) { - column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); - row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); - } else { - column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetX(); - row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetY(); - } - } - return barcodeCoordinates; -} -CFX_PtrArray* 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; - 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; - if (result->GetAt(4)) { - startColumn = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetX(); - startRow = (int32_t)((CBC_ResultPoint*)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; - return result; -} -void CBC_Detector::copyToResult(CFX_PtrArray* result, - CFX_PtrArray* 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; - result->SetSize(4); - FX_BOOL found = FALSE; - CFX_Int32Array counters; - counters.SetSize(patternLength); - for (; startRow < height; startRow += ROW_STEP) { - CFX_Int32Array* loc = - findGuardPattern(matrix, startColumn, startRow, width, FALSE, pattern, - patternLength, counters); - if (loc) { - while (startRow > 0) { - CFX_Int32Array* previousRowLoc = - findGuardPattern(matrix, startColumn, --startRow, width, FALSE, - pattern, patternLength, counters); - if (previousRowLoc) { - delete loc; - loc = previousRowLoc; - } else { - startRow++; - break; - } - } - result->SetAt( - 0, new CBC_ResultPoint((FX_FLOAT)loc->GetAt(0), (FX_FLOAT)startRow)); - result->SetAt( - 1, new CBC_ResultPoint((FX_FLOAT)loc->GetAt(1), (FX_FLOAT)startRow)); - found = TRUE; - delete loc; - break; - } - } - int32_t stopRow = startRow + 1; - 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()); - for (; stopRow < height; stopRow++) { - CFX_Int32Array* loc = - findGuardPattern(matrix, previousRowLoc[0], stopRow, width, FALSE, - pattern, patternLength, counters); - if (loc && abs(previousRowLoc[0] - loc->GetAt(0)) < MAX_PATTERN_DRIFT && - abs(previousRowLoc[1] - loc->GetAt(1)) < MAX_PATTERN_DRIFT) { - previousRowLoc.Copy(*loc); - skippedRowCount = 0; - } else { - if (skippedRowCount > SKIPPED_ROW_COUNT_MAX) { - delete loc; - break; - } else { - skippedRowCount++; - } - } - delete loc; - } - stopRow -= skippedRowCount + 1; - result->SetAt(2, new CBC_ResultPoint((FX_FLOAT)previousRowLoc.GetAt(0), - (FX_FLOAT)stopRow)); - result->SetAt(3, new CBC_ResultPoint((FX_FLOAT)previousRowLoc.GetAt(1), - (FX_FLOAT)stopRow)); - } - if (stopRow - startRow < BARCODE_MIN_HEIGHT) { - for (int32_t i = 0; i < result->GetSize(); i++) { - result->SetAt(i, NULL); - } - } - return result; -} -CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, - int32_t column, - int32_t row, - int32_t width, - FX_BOOL whiteFirst, - int32_t* pattern, - int32_t patternLength, - CFX_Int32Array& counters) { - for (int32_t i = 0; i < counters.GetSize(); i++) { - counters.SetAt(i, 0); - } - FX_BOOL isWhite = whiteFirst; - int32_t patternStart = column; - int32_t pixelDrift = 0; - CFX_Int32Array* intarray = new CFX_Int32Array; - while (matrix->Get(patternStart, row) && patternStart > 0 && - pixelDrift++ < MAX_PIXEL_DRIFT) { - patternStart--; - } - int32_t x = patternStart; - int32_t counterPosition = 0; - for (; x < width; x++) { - FX_BOOL pixel = matrix->Get(x, row); - if (pixel ^ isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < - MAX_AVG_VARIANCE) { - intarray->Add(patternStart); - intarray->Add(x); - return intarray; - } - patternStart += counters[0] + counters[1]; - for (int32_t l = 2, k = 0; l < patternLength; l++, k++) { - counters.SetAt(k, counters.GetAt(l)); - } - counters.SetAt(patternLength - 2, 0); - counters.SetAt(patternLength - 1, 0); - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - if (counterPosition == patternLength - 1) { - if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < - MAX_AVG_VARIANCE) { - intarray->Add(patternStart); - intarray->Add(x - 1); - return intarray; - } - } - delete intarray; - return NULL; -} -int32_t CBC_Detector::patternMatchVariance(CFX_Int32Array& counters, - int32_t* pattern, - int32_t maxIndividualVariance) { - int32_t numCounters = counters.GetSize(); - int32_t total = 0; - int32_t patternLength = 0; - for (int32_t i = 0; i < numCounters; i++) { - total += counters[i]; - patternLength += pattern[i]; - } - if (total < patternLength) { - return INTEGER_MAX; - } - int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength; - maxIndividualVariance = - (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT; - int32_t totalVariance = 0; - for (int32_t x = 0; x < numCounters; x++) { - int32_t counter = counters[x] << INTEGER_MATH_SHIFT; - int32_t scaledPattern = pattern[x] * unitBarWidth; - int32_t variance = counter > scaledPattern ? counter - scaledPattern - : scaledPattern - counter; - if (variance > maxIndividualVariance) { - return INTEGER_MAX; - } - totalVariance += variance; - } - return totalVariance / total; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h deleted file mode 100644 index e18a2b5151..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h +++ /dev/null @@ -1,69 +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_SRC_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ - -class CBC_PDF417DetectorResult; -class CBC_BinaryBitmap; -class CBC_CommonBitMatrix; -class CBC_CommonBitArray; - -class CBC_Detector { - public: - CBC_Detector(); - virtual ~CBC_Detector(); - static CBC_PDF417DetectorResult* detect(CBC_BinaryBitmap* image, - int32_t hints, - FX_BOOL multiple, - int32_t& e); - static void rotate180(CBC_CommonBitMatrix* bitMatrix); - static CBC_CommonBitArray* mirror(CBC_CommonBitArray* input, - CBC_CommonBitArray* result); - - private: - static int32_t INDEXES_START_PATTERN[]; - static int32_t INDEXES_STOP_PATTERN[]; - static int32_t INTEGER_MATH_SHIFT; - static int32_t PATTERN_MATCH_RESULT_SCALE_FACTOR; - static int32_t MAX_AVG_VARIANCE; - static int32_t MAX_INDIVIDUAL_VARIANCE; - static int32_t START_PATTERN[]; - static int32_t STOP_PATTERN[]; - static int32_t MAX_PIXEL_DRIFT; - static int32_t MAX_PATTERN_DRIFT; - 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, - 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 CFX_Int32Array* findGuardPattern(CBC_CommonBitMatrix* matrix, - int32_t column, - int32_t row, - int32_t width, - FX_BOOL whiteFirst, - int32_t* pattern, - int32_t patternLength, - CFX_Int32Array& counters); - static int32_t patternMatchVariance(CFX_Int32Array& counters, - int32_t* pattern, - int32_t maxIndividualVariance); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp deleted file mode 100644 index 395c53954b..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/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() { - 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(); - delete temp; - } - m_points->RemoveAll(); - delete m_points; -} -CBC_CommonBitMatrix* CBC_PDF417DetectorResult::getBits() { - return m_bits; -} - -CFX_PtrArray* CBC_PDF417DetectorResult::getPoints() { - return m_points; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h deleted file mode 100644 index b0b365e9a9..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h +++ /dev/null @@ -1,26 +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_SRC_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; - -class CBC_PDF417DetectorResult { - public: - CBC_PDF417DetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points); - virtual ~CBC_PDF417DetectorResult(); - CBC_CommonBitMatrix* getBits(); - CFX_PtrArray* getPoints(); - - private: - CBC_CommonBitMatrix* m_bits; - CFX_PtrArray* m_points; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.cpp deleted file mode 100644 index 18edeacddb..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.cpp +++ /dev/null @@ -1,46 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.h" - -CBC_Dimensions::CBC_Dimensions(int32_t minCols, - int32_t maxCols, - int32_t minRows, - int32_t maxRows) { - m_minCols = minCols; - m_maxCols = maxCols; - m_minRows = minRows; - m_maxRows = maxRows; -} -CBC_Dimensions::~CBC_Dimensions() {} -int32_t CBC_Dimensions::getMinCols() { - return m_minCols; -} -int32_t CBC_Dimensions::getMaxCols() { - return m_maxCols; -} -int32_t CBC_Dimensions::getMinRows() { - return m_minRows; -} -int32_t CBC_Dimensions::getMaxRows() { - return m_maxRows; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.h deleted file mode 100644 index 9b69fc4a8a..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Dimensions.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_SRC_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ - -#include <stdint.h> - -class CBC_Dimensions { - public: - CBC_Dimensions(int32_t minCols, - int32_t maxCols, - int32_t minRows, - int32_t maxRows); - virtual ~CBC_Dimensions(); - int32_t getMinCols(); - int32_t getMaxCols(); - int32_t getMinRows(); - int32_t getMaxRows(); - - private: - int32_t m_minCols; - int32_t m_maxCols; - int32_t m_minRows; - int32_t m_maxRows; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DIMENSIONS_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp deleted file mode 100644 index aea60df578..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp +++ /dev/null @@ -1,389 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_PDF417ECModulusGF* CBC_PDF417ECErrorCorrection::m_field = NULL; - -void CBC_PDF417ECErrorCorrection::Initialize(int32_t& e) { - m_field = - new CBC_PDF417ECModulusGF(CBC_PDF417Common::NUMBER_OF_CODEWORDS, 3, e); -} -void CBC_PDF417ECErrorCorrection::Finalize() { - delete m_field; -} -CBC_PDF417ECErrorCorrection::CBC_PDF417ECErrorCorrection() {} -CBC_PDF417ECErrorCorrection::~CBC_PDF417ECErrorCorrection() {} -int32_t CBC_PDF417ECErrorCorrection::decode(CFX_Int32Array& received, - int32_t numECCodewords, - CFX_Int32Array& erasures, - int32_t& e) { - CBC_PDF417ECModulusPoly poly(m_field, received, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - CFX_Int32Array S; - S.SetSize(numECCodewords); - FX_BOOL error = FALSE; - for (int32_t l = numECCodewords; l > 0; l--) { - int32_t eval = poly.evaluateAt(m_field->exp(l)); - S[numECCodewords - l] = eval; - if (eval != 0) { - error = TRUE; - } - } - if (!error) { - return 0; - } - CBC_PDF417ECModulusPoly* syndrome = - new CBC_PDF417ECModulusPoly(m_field, S, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - CBC_PDF417ECModulusPoly* buildmonomial = - m_field->buildMonomial(numECCodewords, 1, e); - if (e != BCExceptionNO) { - delete syndrome; - return -1; - } - CFX_PtrArray* sigmaOmega = - runEuclideanAlgorithm(buildmonomial, syndrome, numECCodewords, e); - delete buildmonomial; - delete syndrome; - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - CBC_PDF417ECModulusPoly* sigma = - (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(0); - CBC_PDF417ECModulusPoly* omega = - (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(1); - CFX_Int32Array* errorLocations = findErrorLocations(sigma, e); - if (e != BCExceptionNO) { - for (int32_t i = 0; i < sigmaOmega->GetSize(); i++) { - delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(i); - } - sigmaOmega->RemoveAll(); - delete sigmaOmega; - return -1; - } - CFX_Int32Array* errorMagnitudes = - findErrorMagnitudes(omega, sigma, *errorLocations, e); - if (e != BCExceptionNO) { - delete errorLocations; - for (int32_t i = 0; i < sigmaOmega->GetSize(); i++) { - delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(i); - } - sigmaOmega->RemoveAll(); - delete sigmaOmega; - return -1; - } - for (int32_t i = 0; i < errorLocations->GetSize(); i++) { - int32_t log = m_field->log(errorLocations->GetAt(i), e); - - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - int32_t position = received.GetSize() - 1 - log; - if (position < 0) { - e = BCExceptionChecksumException; - delete errorLocations; - delete errorMagnitudes; - for (int32_t j = 0; j < sigmaOmega->GetSize(); j++) { - delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(j); - } - sigmaOmega->RemoveAll(); - delete sigmaOmega; - return -1; - } - received[position] = - m_field->subtract(received[position], errorMagnitudes->GetAt(i)); - } - int32_t result = errorLocations->GetSize(); - delete errorLocations; - delete errorMagnitudes; - for (int32_t k = 0; k < sigmaOmega->GetSize(); k++) { - delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(k); - } - sigmaOmega->RemoveAll(); - delete sigmaOmega; - return result; -} -CFX_PtrArray* 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; - b = temp; - } - CBC_PDF417ECModulusPoly* rLast = a; - CBC_PDF417ECModulusPoly* r = b; - CBC_PDF417ECModulusPoly* tLast = m_field->getZero(); - CBC_PDF417ECModulusPoly* t = m_field->getOne(); - CBC_PDF417ECModulusPoly* qtemp = NULL; - CBC_PDF417ECModulusPoly* rtemp = NULL; - CBC_PDF417ECModulusPoly* ttemp = NULL; - int32_t i = 0; - int32_t j = 0; - int32_t m = 0; - int32_t n = 0; - while (r->getDegree() >= R / 2) { - CBC_PDF417ECModulusPoly* rLastLast = rLast; - CBC_PDF417ECModulusPoly* tLastLast = tLast; - rLast = r; - tLast = t; - m = i; - n = j; - if (rLast->isZero()) { - e = BCExceptionChecksumException; - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - 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; - } - while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { - int32_t degreeDiff = r->getDegree() - rLast->getDegree(); - int32_t scale = - m_field->multiply(r->getCoefficient(r->getDegree()), dltInverse); - 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; - } - q = q->add(buildmonomial, e); - delete buildmonomial; - if (qtemp) { - delete qtemp; - } - if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - 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; - } - CBC_PDF417ECModulusPoly* temp = r; - r = temp->subtract(multiply, e); - delete multiply; - if (m > 1 && i > m) { - delete temp; - temp = NULL; - } - if (e != BCExceptionNO) { - if (qtemp) { - delete qtemp; - } - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - rtemp = r; - i = m + 1; - } - ttemp = q->multiply(tLast, e); - if (qtemp) { - delete qtemp; - qtemp = NULL; - } - if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - t = ttemp->subtract(tLastLast, e); - if (n > 1 && j > n) { - delete tLastLast; - } - delete ttemp; - if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; - } - ttemp = t; - t = ttemp->negative(e); - delete ttemp; - if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; - } - ttemp = t; - j++; - } - int32_t sigmaTildeAtZero = t->getCoefficient(0); - if (sigmaTildeAtZero == 0) { - e = BCExceptionChecksumException; - if (rtemp) { - delete rtemp; - } - if (ttemp) { - delete ttemp; - } - return NULL; - } - 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 ttemp; - } - if (e != BCExceptionNO) { - if (rtemp) { - delete rtemp; - } - return NULL; - } - CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); - if (rtemp) { - delete rtemp; - } - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* modulusPoly = new CFX_PtrArray; - modulusPoly->Add(sigma); - modulusPoly->Add(omega); - return modulusPoly; -} -CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( - CBC_PDF417ECModulusPoly* errorLocator, - int32_t& e) { - int32_t numErrors = errorLocator->getDegree(); - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(numErrors); - int32_t ee = 0; - for (int32_t i = 1; i < m_field->getSize() && ee < numErrors; i++) { - if (errorLocator->evaluateAt(i) == 0) { - result->SetAt(ee, m_field->inverse(i, e)); - if (e != BCExceptionNO) { - delete result; - return NULL; - } - ee++; - } - } - if (ee != numErrors) { - e = BCExceptionChecksumException; - delete result; - return NULL; - } - return result; -} -CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorMagnitudes( - CBC_PDF417ECModulusPoly* errorEvaluator, - CBC_PDF417ECModulusPoly* errorLocator, - CFX_Int32Array& errorLocations, - int32_t& e) { - int32_t errorLocatorDegree = errorLocator->getDegree(); - CFX_Int32Array formalDerivativeCoefficients; - formalDerivativeCoefficients.SetSize(errorLocatorDegree); - for (int32_t l = 1; l <= errorLocatorDegree; l++) { - formalDerivativeCoefficients[errorLocatorDegree - l] = - m_field->multiply(l, errorLocator->getCoefficient(l)); - } - CBC_PDF417ECModulusPoly formalDerivative(m_field, - formalDerivativeCoefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t s = errorLocations.GetSize(); - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(s); - for (int32_t i = 0; i < s; i++) { - int32_t xiInverse = m_field->inverse(errorLocations[i], e); - if (e != BCExceptionNO) { - delete result; - return NULL; - } - int32_t numerator = - m_field->subtract(0, errorEvaluator->evaluateAt(xiInverse)); - int32_t denominator = - m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); - if (e != BCExceptionNO) { - delete result; - return NULL; - } - result->SetAt(i, m_field->multiply(numerator, denominator)); - } - return result; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h deleted file mode 100644 index 8966ae109c..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.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_SRC_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ - -class CBC_PDF417ECModulusGF; -class CBC_PDF417ECModulusPoly; -class CBC_PDF417ECErrorCorrection { - public: - CBC_PDF417ECErrorCorrection(); - virtual ~CBC_PDF417ECErrorCorrection(); - static void Initialize(int32_t& e); - static void Finalize(); - static int32_t decode(CFX_Int32Array& received, - int32_t numECCodewords, - CFX_Int32Array& erasures, - int32_t& e); - - private: - static CBC_PDF417ECModulusGF* m_field; - static CFX_PtrArray* runEuclideanAlgorithm(CBC_PDF417ECModulusPoly* a, - CBC_PDF417ECModulusPoly* b, - int32_t R, - int32_t& e); - static CFX_Int32Array* findErrorLocations( - CBC_PDF417ECModulusPoly* errorLocator, - int32_t& e); - static CFX_Int32Array* findErrorMagnitudes( - CBC_PDF417ECModulusPoly* errorEvaluator, - CBC_PDF417ECModulusPoly* errorLocator, - CFX_Int32Array& errorLocations, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECERRORCORRECTION_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp deleted file mode 100644 index 1ba77dac16..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.cpp +++ /dev/null @@ -1,120 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_PDF417ECModulusGF* CBC_PDF417ECModulusGF::PDF417_GF = NULL; -void CBC_PDF417ECModulusGF::Initialize(int32_t& e) { - PDF417_GF = - new CBC_PDF417ECModulusGF(CBC_PDF417Common::NUMBER_OF_CODEWORDS, 3, e); -} -void CBC_PDF417ECModulusGF::Finalize() { - delete PDF417_GF; -} -CBC_PDF417ECModulusGF::CBC_PDF417ECModulusGF(int32_t modulus, - int32_t generator, - int32_t& e) { - m_modulus = modulus; - m_expTable.SetSize(modulus); - m_logTable.SetSize(modulus); - int32_t x = 1; - for (int32_t i = 0; i < modulus; i++) { - m_expTable[i] = x; - x = (x * generator) % modulus; - } - for (int32_t j = 0; j < modulus - 1; j++) { - m_logTable[m_expTable[j]] = j; - } - CFX_Int32Array zero; - zero.Add(0); - m_zero = new CBC_PDF417ECModulusPoly(this, zero, e); - CFX_Int32Array one; - one.Add(1); - m_one = new CBC_PDF417ECModulusPoly(this, one, e); -} -CBC_PDF417ECModulusGF::~CBC_PDF417ECModulusGF() { - delete m_zero; - delete m_one; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::getZero() { - return m_zero; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::getOne() { - return m_one; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusGF::buildMonomial( - int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionIllegalArgument; - return NULL; - } - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (coefficient == 0) { - modulusPoly = new CBC_PDF417ECModulusPoly(m_zero->getField(), - m_zero->getCoefficients(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - CFX_Int32Array coefficients; - coefficients.SetSize(degree + 1); - coefficients[0] = coefficient; - modulusPoly = new CBC_PDF417ECModulusPoly(this, coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -int32_t CBC_PDF417ECModulusGF::add(int32_t a, int32_t b) { - return (a + b) % m_modulus; -} -int32_t CBC_PDF417ECModulusGF::subtract(int32_t a, int32_t b) { - return (m_modulus + a - b) % m_modulus; -} -int32_t CBC_PDF417ECModulusGF::exp(int32_t a) { - return m_expTable[a]; -} -int32_t CBC_PDF417ECModulusGF::log(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionIllegalArgument; - return -1; - } - return m_logTable[a]; -} -int32_t CBC_PDF417ECModulusGF::inverse(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionIllegalArgument; - return -1; - } - return m_expTable[m_modulus - m_logTable[a] - 1]; -} -int32_t CBC_PDF417ECModulusGF::multiply(int32_t a, int32_t b) { - if (a == 0 || b == 0) { - return 0; - } - return m_expTable[(m_logTable[a] + m_logTable[b]) % (m_modulus - 1)]; -} -int32_t CBC_PDF417ECModulusGF::getSize() { - return m_modulus; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h deleted file mode 100644 index f5d245b0e3..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.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_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ - -class CBC_PDF417ECModulusPoly; -class CBC_PDF417ECModulusGF { - public: - CBC_PDF417ECModulusGF(int32_t modulus, int32_t generator, int32_t& e); - virtual ~CBC_PDF417ECModulusGF(); - static void Initialize(int32_t& e); - static void Finalize(); - CBC_PDF417ECModulusPoly* getZero(); - CBC_PDF417ECModulusPoly* getOne(); - CBC_PDF417ECModulusPoly* buildMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - int32_t add(int32_t a, int32_t b); - int32_t subtract(int32_t a, int32_t b); - int32_t exp(int32_t a); - int32_t log(int32_t a, int32_t& e); - int32_t inverse(int32_t a, int32_t& e); - int32_t multiply(int32_t a, int32_t b); - int32_t getSize(); - static CBC_PDF417ECModulusGF* PDF417_GF; - - private: - CFX_Int32Array m_expTable; - CFX_Int32Array m_logTable; - CBC_PDF417ECModulusPoly* m_zero; - CBC_PDF417ECModulusPoly* m_one; - int32_t m_modulus; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSGF_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp deleted file mode 100644 index 04f7752b65..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp +++ /dev/null @@ -1,332 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_PDF417ECModulusPoly::CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, - CFX_Int32Array& coefficients, - int32_t& e) { - if (coefficients.GetSize() == 0) { - e = BCExceptionIllegalArgument; - } - m_field = field; - int32_t coefficientsLength = coefficients.GetSize(); - if (coefficientsLength > 1 && coefficients[0] == 0) { - int32_t firstNonZero = 1; - while (firstNonZero < coefficientsLength && - coefficients[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - m_coefficients = field->getZero()->m_coefficients; - } else { - m_coefficients.SetSize(coefficientsLength - firstNonZero); - int32_t l = 0; - for (int32_t i = firstNonZero; - i < firstNonZero + m_coefficients.GetSize(); i++) { - m_coefficients.SetAt(l, coefficients.GetAt(i)); - l++; - } - } - } else { - m_coefficients.Copy(coefficients); - } -} -CBC_PDF417ECModulusPoly::~CBC_PDF417ECModulusPoly() {} -CFX_Int32Array& CBC_PDF417ECModulusPoly::getCoefficients() { - return m_coefficients; -} -CBC_PDF417ECModulusGF* CBC_PDF417ECModulusPoly::getField() { - return m_field; -} -int32_t CBC_PDF417ECModulusPoly::getDegree() { - return m_coefficients.GetSize() - 1; -} -FX_BOOL CBC_PDF417ECModulusPoly::isZero() { - return m_coefficients[0] == 0; -} -int32_t CBC_PDF417ECModulusPoly::getCoefficient(int32_t degree) { - return m_coefficients[m_coefficients.GetSize() - 1 - degree]; -} -int32_t CBC_PDF417ECModulusPoly::evaluateAt(int32_t a) { - if (a == 0) { - return getCoefficient(0); - } - int32_t size = m_coefficients.GetSize(); - if (a == 1) { - int32_t result = 0; - for (int32_t l = 0; l < m_coefficients.GetSize(); l++) { - int32_t coefficient = m_coefficients.GetAt(l); - result = m_field->add(result, coefficient); - } - return result; - } - int32_t result = m_coefficients[0]; - for (int32_t i = 1; i < size; i++) { - result = m_field->add(m_field->multiply(a, result), m_coefficients[i]); - } - return result; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::add( - CBC_PDF417ECModulusPoly* other, - int32_t& e) { - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (isZero()) { - modulusPoly = new CBC_PDF417ECModulusPoly(other->getField(), - other->getCoefficients(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - if (other->isZero()) { - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - CFX_Int32Array smallerCoefficients; - smallerCoefficients.Copy(m_coefficients); - CFX_Int32Array largerCoefficients; - largerCoefficients.Copy(other->m_coefficients); - if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { - CFX_Int32Array temp; - temp.Copy(smallerCoefficients); - smallerCoefficients.Copy(largerCoefficients); - largerCoefficients.Copy(temp); - } - CFX_Int32Array sumDiff; - sumDiff.SetSize(largerCoefficients.GetSize()); - int32_t lengthDiff = - largerCoefficients.GetSize() - smallerCoefficients.GetSize(); - for (int32_t l = 0; l < lengthDiff; l++) { - sumDiff.SetAt(l, largerCoefficients.GetAt(l)); - } - for (int32_t i = lengthDiff; i < largerCoefficients.GetSize(); i++) { - sumDiff[i] = m_field->add(smallerCoefficients[i - lengthDiff], - largerCoefficients[i]); - } - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, sumDiff, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::subtract( - CBC_PDF417ECModulusPoly* other, - int32_t& e) { - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (other->isZero()) { - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - CBC_PDF417ECModulusPoly* poly = other->negative(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - modulusPoly = add(poly, e); - delete poly; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply( - CBC_PDF417ECModulusPoly* other, - int32_t& e) { - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (isZero() || other->isZero()) { - modulusPoly = - new CBC_PDF417ECModulusPoly(m_field->getZero()->getField(), - m_field->getZero()->getCoefficients(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - CFX_Int32Array aCoefficients; - aCoefficients.Copy(m_coefficients); - int32_t aLength = aCoefficients.GetSize(); - CFX_Int32Array bCoefficients; - bCoefficients.Copy(other->m_coefficients); - int32_t bLength = bCoefficients.GetSize(); - CFX_Int32Array product; - product.SetSize(aLength + bLength - 1); - for (int32_t i = 0; i < aLength; i++) { - int32_t aCoeff = aCoefficients[i]; - for (int32_t j = 0; j < bLength; j++) { - product[i + j] = m_field->add( - product[i + j], m_field->multiply(aCoeff, bCoefficients[j])); - } - } - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::negative(int32_t& e) { - int32_t size = m_coefficients.GetSize(); - CFX_Int32Array negativeCoefficients; - negativeCoefficients.SetSize(size); - for (int32_t i = 0; i < size; i++) { - negativeCoefficients[i] = m_field->subtract(0, m_coefficients[i]); - } - CBC_PDF417ECModulusPoly* modulusPoly = - new CBC_PDF417ECModulusPoly(m_field, negativeCoefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(int32_t scalar, - int32_t& e) { - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (scalar == 0) { - modulusPoly = - new CBC_PDF417ECModulusPoly(m_field->getZero()->getField(), - m_field->getZero()->getCoefficients(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - if (scalar == 1) { - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - int32_t size = m_coefficients.GetSize(); - CFX_Int32Array product; - product.SetSize(size); - for (int32_t i = 0; i < size; i++) { - product[i] = m_field->multiply(m_coefficients[i], scalar); - } - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); - 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; - } - CBC_PDF417ECModulusPoly* modulusPoly = NULL; - if (coefficient == 0) { - modulusPoly = new CBC_PDF417ECModulusPoly( - m_field->getZero()->m_field, m_field->getZero()->m_coefficients, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; - } - int32_t size = m_coefficients.GetSize(); - CFX_Int32Array product; - product.SetSize(size + degree); - for (int32_t i = 0; i < size; i++) { - product[i] = m_field->multiply(m_coefficients[i], coefficient); - } - modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return modulusPoly; -} -CFX_PtrArray* 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; - } - int32_t denominatorLeadingTerm = other->getCoefficient(other->getDegree()); - int32_t inverseDenominatorLeadingTerm = - m_field->inverse(denominatorLeadingTerm, e); - if (e != BCExceptionNO) { - delete quotient; - delete remainder; - return NULL; - } - 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; - } - } - CFX_PtrArray* modulusPoly = new CFX_PtrArray; - modulusPoly->Add(quotient); - modulusPoly->Add(remainder); - return modulusPoly; -} -CFX_ByteString CBC_PDF417ECModulusPoly::toString() { - CFX_ByteString result; - for (int32_t degree = getDegree(); degree >= 0; degree--) { - int32_t coefficient = getCoefficient(degree); - if (coefficient != 0) { - if (coefficient < 0) { - result += " - "; - coefficient = -coefficient; - } else { - if (result.GetLength() > 0) { - result += " + "; - } - } - if (degree == 0 || coefficient != 1) { - result += coefficient; - } - if (degree != 0) { - if (degree == 1) { - result += 'x'; - } else { - result += "x^"; - result += degree; - } - } - } - } - return result; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h deleted file mode 100644 index 89384fcd69..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.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_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ - -class CBC_PDF417ECModulusGF; -class CBC_PDF417ECModulusPoly { - public: - CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, - CFX_Int32Array& coefficients, - int32_t& e); - virtual ~CBC_PDF417ECModulusPoly(); - CFX_Int32Array& getCoefficients(); - CBC_PDF417ECModulusGF* getField(); - int32_t getDegree(); - FX_BOOL isZero(); - int32_t getCoefficient(int32_t degree); - int32_t evaluateAt(int32_t a); - CBC_PDF417ECModulusPoly* add(CBC_PDF417ECModulusPoly* other, int32_t& e); - CBC_PDF417ECModulusPoly* subtract(CBC_PDF417ECModulusPoly* other, int32_t& e); - CBC_PDF417ECModulusPoly* multiply(CBC_PDF417ECModulusPoly* other, int32_t& e); - CBC_PDF417ECModulusPoly* negative(int32_t& e); - CBC_PDF417ECModulusPoly* multiply(int32_t scalar, int32_t& e); - CBC_PDF417ECModulusPoly* multiplyByMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - CFX_PtrArray* divide(CBC_PDF417ECModulusPoly* other, int32_t& e); - CFX_ByteString toString(); - - private: - CBC_PDF417ECModulusGF* m_field; - CFX_Int32Array m_coefficients; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp deleted file mode 100644 index 5fb2d8e21e..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp +++ /dev/null @@ -1,165 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" -#include "xfa/src/fxbarcode/utils.h" - -int32_t CBC_PDF417ErrorCorrection::EC_COEFFICIENTS[][2500] = { - {27, 917}, - {522, 568, 723, 809}, - {237, 308, 436, 284, 646, 653, 428, 379}, - {274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176, - 65}, - {361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193, - 517, 273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330, - 63, 410}, - {539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381, - 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762, - 283, 184, 440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651, - 201, 488, 502, 648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843, - 623, 264, 543}, - {521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749, - 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908, - 490, 704, 516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686, - 606, 860, 569, 193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379, - 712, 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507, - 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380, 602, 754, 336, - 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845, - 454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517, - 834, 315, 550, 86, 801, 4, 108, 539}, - {524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138, - 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280, - 828, 757, 710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801, - 700, 799, 137, 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257, - 284, 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684, - 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399, 908, 103, 511, - 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730, 433, - 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, 580, - 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263, 318, 374, - 601, 192, 605, 142, 673, 687, 234, 722, 384, 177, 752, 607, 640, 455, 193, - 689, 707, 805, 641, 48, 60, 732, 621, 895, 544, 261, 852, 655, 309, 697, - 755, 756, 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32, 144, - 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914, 342, 126, 32, 681, - 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383, 228, 749, 760, - 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20, - 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, 251, 688, 95, - 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10}, - {352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350, - 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193, - 352, 781, 846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640, - 268, 794, 534, 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37, - 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761, - 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20, - 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729, 567, - 744, 390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384, - 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151, 429, - 531, 207, 676, 710, 89, 168, 304, 402, 40, 708, 575, 162, 864, 229, 65, - 861, 841, 512, 164, 477, 221, 92, 358, 785, 288, 357, 850, 836, 827, 736, - 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248, 361, - 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902, 452, 167, - 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124, 298, 332, - 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283, 711, 472, - 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, 383, - 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729, 624, - 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772, - 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35, - 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247, - 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519, - 644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513, - 56, 252, 341, 242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310, - 756, 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590, - 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, 782, 210, 815, 905, 303, - 843, 922, 281, 73, 469, 791, 660, 162, 498, 308, 155, 422, 907, 817, 187, - 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667, - 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, 5, 39, 923, - 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534, 105, 667, 488, 640, - 672, 576, 540, 316, 486, 721, 610, 46, 656, 447, 171, 616, 464, 190, 531, - 297, 321, 762, 752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596, - 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407, 164, 332, 899, - 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647, 63, 310, 863, - 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263}}; - -CBC_PDF417ErrorCorrection::CBC_PDF417ErrorCorrection() {} -CBC_PDF417ErrorCorrection::~CBC_PDF417ErrorCorrection() {} -int32_t CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( - int32_t errorCorrectionLevel, - int32_t& e) { - if (errorCorrectionLevel < 0 || errorCorrectionLevel > 8) { - e = BCExceptionErrorCorrectionLevelMustBeBetween0And8; - return -1; - } - return 1 << (errorCorrectionLevel + 1); -} -int32_t CBC_PDF417ErrorCorrection::getRecommendedMinimumErrorCorrectionLevel( - int32_t n, - int32_t& e) { - if (n <= 0) { - e = BCExceptionIllegalArgumentnMustBeAbove0; - return -1; - } - if (n <= 40) { - return 2; - } - if (n <= 160) { - return 3; - } - if (n <= 320) { - return 4; - } - if (n <= 863) { - return 5; - } - e = BCExceptionNoRecommendationPossible; - return -1; -} -CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection( - CFX_WideString dataCodewords, - int32_t errorCorrectionLevel, - int32_t& e) { - int32_t k = getErrorCorrectionCodewordCount(errorCorrectionLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); - FX_WCHAR* ech = FX_Alloc(FX_WCHAR, k); - FXSYS_memset(ech, 0, k * sizeof(FX_WCHAR)); - int32_t sld = dataCodewords.GetLength(); - for (int32_t i = 0; i < sld; i++) { - int32_t t1 = (dataCodewords.GetAt(i) + ech[k - 1]) % 929; - int32_t t2; - int32_t t3; - for (int32_t j = k - 1; j >= 1; j--) { - t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][j]) % 929; - t3 = 929 - t2; - ech[j] = (FX_WCHAR)((ech[j - 1] + t3) % 929); - } - t2 = (t1 * EC_COEFFICIENTS[errorCorrectionLevel][0]) % 929; - t3 = 929 - t2; - ech[0] = (FX_WCHAR)(t3 % 929); - } - CFX_WideString sb; - for (int32_t j = k - 1; j >= 0; j--) { - if (ech[j] != 0) { - ech[j] = (FX_WCHAR)(929 - ech[j]); - } - sb += (FX_WCHAR)ech[j]; - } - FX_Free(ech); - return sb; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h deleted file mode 100644 index 1c73173e55..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.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_SRC_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ - -#include <stdint.h> - -#include "core/include/fxcrt/fx_string.h" - -class CBC_PDF417ErrorCorrection { - public: - CBC_PDF417ErrorCorrection(); - virtual ~CBC_PDF417ErrorCorrection(); - static int32_t getErrorCorrectionCodewordCount(int32_t errorCorrectionLevel, - int32_t& e); - static int32_t getRecommendedMinimumErrorCorrectionLevel(int32_t n, - int32_t& e); - static CFX_WideString generateErrorCorrection(CFX_WideString dataCodewords, - int32_t errorCorrectionLevel, - int32_t& e); - - private: - static int32_t EC_COEFFICIENTS[][2500]; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp deleted file mode 100644 index 89fed29ffa..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp +++ /dev/null @@ -1,427 +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 -// Original code is licensed as follows: -/* - * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" - -#include "third_party/bigint/BigIntegerLibrary.hh" -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "xfa/src/fxbarcode/utils.h" - -#define SUBMODE_ALPHA 0 -#define SUBMODE_LOWER 1 -#define SUBMODE_MIXED 2 - -int32_t CBC_PDF417HighLevelEncoder::TEXT_COMPACTION = 0; -int32_t CBC_PDF417HighLevelEncoder::BYTE_COMPACTION = 1; -int32_t CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION = 2; -int32_t CBC_PDF417HighLevelEncoder::SUBMODE_PUNCTUATION = 3; -int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_TEXT = 900; -int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE_PADDED = 901; -int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_NUMERIC = 902; -int32_t CBC_PDF417HighLevelEncoder::SHIFT_TO_BYTE = 913; -int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE = 924; -uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = { - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58, - 35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0}; -uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = { - 59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58, - 10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0}; -int32_t CBC_PDF417HighLevelEncoder::MIXED[128] = {0}; -int32_t CBC_PDF417HighLevelEncoder::PUNCTUATION[128] = {0}; - -void CBC_PDF417HighLevelEncoder::Initialize() { - Inverse(); -} -void CBC_PDF417HighLevelEncoder::Finalize() {} -CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel( - CFX_WideString wideMsg, - Compaction compaction, - int32_t& e) { - CFX_ByteString bytes; - CBC_UtilCodingConvert::UnicodeToUTF8(wideMsg, bytes); - CFX_WideString msg; - int32_t len = bytes.GetLength(); - for (int32_t i = 0; i < len; i++) { - FX_WCHAR ch = (FX_WCHAR)(bytes.GetAt(i) & 0xff); - if (ch == '?' && bytes.GetAt(i) != '?') { - e = BCExceptionCharactersOutsideISO88591Encoding; - return (FX_WCHAR*)""; - } - msg += ch; - } - CFX_ByteArray byteArr; - for (int32_t k = 0; k < bytes.GetLength(); k++) { - byteArr.Add(bytes.GetAt(k)); - } - CFX_WideString sb; - len = msg.GetLength(); - int32_t p = 0; - int32_t textSubMode = SUBMODE_ALPHA; - if (compaction == TEXT) { - encodeText(msg, p, len, sb, textSubMode); - } else if (compaction == BYTES) { - encodeBinary(&byteArr, p, byteArr.GetSize(), BYTE_COMPACTION, sb); - } else if (compaction == NUMERIC) { - sb += (FX_WCHAR)LATCH_TO_NUMERIC; - encodeNumeric(msg, p, len, sb); - } else { - int32_t encodingMode = LATCH_TO_TEXT; - while (p < len) { - int32_t n = determineConsecutiveDigitCount(msg, p); - if (n >= 13) { - sb += (FX_WCHAR)LATCH_TO_NUMERIC; - encodingMode = NUMERIC_COMPACTION; - textSubMode = SUBMODE_ALPHA; - encodeNumeric(msg, p, n, sb); - p += n; - } else { - int32_t t = determineConsecutiveTextCount(msg, p); - if (t >= 5 || n == len) { - if (encodingMode != TEXT_COMPACTION) { - sb += (FX_WCHAR)LATCH_TO_TEXT; - encodingMode = TEXT_COMPACTION; - textSubMode = SUBMODE_ALPHA; - } - textSubMode = encodeText(msg, p, t, sb, textSubMode); - p += t; - } else { - int32_t b = determineConsecutiveBinaryCount(msg, &byteArr, p, e); - BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR)' '); - if (b == 0) { - b = 1; - } - if (b == 1 && encodingMode == TEXT_COMPACTION) { - encodeBinary(&byteArr, p, 1, TEXT_COMPACTION, sb); - } else { - encodeBinary(&byteArr, p, b, encodingMode, sb); - encodingMode = BYTE_COMPACTION; - textSubMode = SUBMODE_ALPHA; - } - p += b; - } - } - } - } - return sb; -} - -void CBC_PDF417HighLevelEncoder::Inverse() { - for (size_t l = 0; l < FX_ArraySize(MIXED); ++l) - MIXED[l] = -1; - - for (uint8_t i = 0; i < FX_ArraySize(TEXT_MIXED_RAW); ++i) { - uint8_t b = TEXT_MIXED_RAW[i]; - if (b != 0) - MIXED[b] = i; - } - - for (size_t l = 0; l < FX_ArraySize(PUNCTUATION); ++l) - PUNCTUATION[l] = -1; - - for (uint8_t i = 0; i < FX_ArraySize(TEXT_PUNCTUATION_RAW); ++i) { - uint8_t b = TEXT_PUNCTUATION_RAW[i]; - if (b != 0) - PUNCTUATION[b] = i; - } -} - -int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, - int32_t startpos, - int32_t count, - CFX_WideString& sb, - int32_t initialSubmode) { - CFX_WideString tmp; - int32_t submode = initialSubmode; - int32_t idx = 0; - while (TRUE) { - FX_WCHAR ch = msg.GetAt(startpos + idx); - switch (submode) { - case SUBMODE_ALPHA: - if (isAlphaUpper(ch)) { - if (ch == ' ') { - tmp += (FX_WCHAR)26; - } else { - tmp += (FX_WCHAR)(ch - 65); - } - } else { - if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp += (FX_WCHAR)27; - continue; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp += (FX_WCHAR)28; - continue; - } else { - tmp += (FX_WCHAR)29; - tmp += PUNCTUATION[ch]; - break; - } - } - break; - case SUBMODE_LOWER: - if (isAlphaLower(ch)) { - if (ch == ' ') { - tmp += (FX_WCHAR)26; - } else { - tmp += (FX_WCHAR)(ch - 97); - } - } else { - if (isAlphaUpper(ch)) { - tmp += (FX_WCHAR)27; - tmp += (FX_WCHAR)(ch - 65); - break; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp += (FX_WCHAR)28; - continue; - } else { - tmp += (FX_WCHAR)29; - tmp += PUNCTUATION[ch]; - break; - } - } - break; - case SUBMODE_MIXED: - if (isMixed(ch)) { - tmp += MIXED[ch]; - } else { - if (isAlphaUpper(ch)) { - submode = SUBMODE_ALPHA; - tmp += (FX_WCHAR)28; - continue; - } else if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp += (FX_WCHAR)27; - continue; - } else { - if (startpos + idx + 1 < count) { - FX_WCHAR next = msg.GetAt(startpos + idx + 1); - if (isPunctuation(next)) { - submode = SUBMODE_PUNCTUATION; - tmp += (FX_WCHAR)25; - continue; - } - } - tmp += (FX_WCHAR)29; - tmp += PUNCTUATION[ch]; - } - } - break; - default: - if (isPunctuation(ch)) { - tmp += PUNCTUATION[ch]; - } else { - submode = SUBMODE_ALPHA; - tmp += (FX_WCHAR)29; - continue; - } - } - idx++; - if (idx >= count) { - break; - } - } - FX_WCHAR h = 0; - int32_t len = tmp.GetLength(); - for (int32_t i = 0; i < len; i++) { - FX_BOOL odd = (i % 2) != 0; - if (odd) { - h = (FX_WCHAR)((h * 30) + tmp.GetAt(i)); - sb += h; - } else { - h = tmp.GetAt(i); - } - } - if ((len % 2) != 0) { - sb += (FX_WCHAR)((h * 30) + 29); - } - return submode; -} -void CBC_PDF417HighLevelEncoder::encodeBinary(CFX_ByteArray* bytes, - int32_t startpos, - int32_t count, - int32_t startmode, - CFX_WideString& sb) { - if (count == 1 && startmode == TEXT_COMPACTION) { - sb += (FX_WCHAR)SHIFT_TO_BYTE; - } - int32_t idx = startpos; - int32_t i = 0; - if (count >= 6) { - sb += (FX_WCHAR)LATCH_TO_BYTE; - FX_WCHAR chars[5]; - while ((startpos + count - idx) >= 6) { - int64_t t = 0; - for (i = 0; i < 6; i++) { - t <<= 8; - t += bytes->GetAt(idx + i) & 0xff; - } - for (i = 0; i < 5; i++) { - chars[i] = (FX_WCHAR)(t % 900); - t /= 900; - } - for (i = 4; i >= 0; i--) { - sb += (chars[i]); - } - idx += 6; - } - } - if (idx < startpos + count) { - sb += (FX_WCHAR)LATCH_TO_BYTE_PADDED; - } - for (i = idx; i < startpos + count; i++) { - int32_t ch = bytes->GetAt(i) & 0xff; - sb += (FX_WCHAR)ch; - } -} -void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg, - int32_t startpos, - int32_t count, - CFX_WideString& sb) { - int32_t idx = 0; - BigInteger num900 = 900; - while (idx < count) { - CFX_WideString tmp; - int32_t len = 44 < count - idx ? 44 : count - idx; - CFX_ByteString part = - ((FX_WCHAR)'1' + msg.Mid(startpos + idx, len)).UTF8Encode(); - BigInteger bigint = stringToBigInteger(part.c_str()); - do { - int32_t c = (bigint % num900).toInt(); - tmp += (FX_WCHAR)(c); - bigint = bigint / num900; - } while (!bigint.isZero()); - for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { - sb += tmp.GetAt(i); - } - idx += len; - } -} -FX_BOOL CBC_PDF417HighLevelEncoder::isDigit(FX_WCHAR ch) { - return ch >= '0' && ch <= '9'; -} -FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaUpper(FX_WCHAR ch) { - return ch == ' ' || (ch >= 'A' && ch <= 'Z'); -} -FX_BOOL CBC_PDF417HighLevelEncoder::isAlphaLower(FX_WCHAR ch) { - return ch == ' ' || (ch >= 'a' && ch <= 'z'); -} -FX_BOOL CBC_PDF417HighLevelEncoder::isMixed(FX_WCHAR ch) { - return MIXED[ch] != -1; -} -FX_BOOL CBC_PDF417HighLevelEncoder::isPunctuation(FX_WCHAR ch) { - return PUNCTUATION[ch] != -1; -} -FX_BOOL CBC_PDF417HighLevelEncoder::isText(FX_WCHAR ch) { - return ch == '\t' || ch == '\n' || ch == '\r' || (ch >= 32 && ch <= 126); -} -int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount( - CFX_WideString msg, - int32_t startpos) { - int32_t count = 0; - int32_t len = msg.GetLength(); - int32_t idx = startpos; - if (idx < len) { - FX_WCHAR ch = msg.GetAt(idx); - while (isDigit(ch) && idx < len) { - count++; - idx++; - if (idx < len) { - ch = msg.GetAt(idx); - } - } - } - return count; -} -int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount( - CFX_WideString msg, - int32_t startpos) { - int32_t len = msg.GetLength(); - int32_t idx = startpos; - while (idx < len) { - FX_WCHAR ch = msg.GetAt(idx); - int32_t numericCount = 0; - while (numericCount < 13 && isDigit(ch) && idx < len) { - numericCount++; - idx++; - if (idx < len) { - ch = msg.GetAt(idx); - } - } - if (numericCount >= 13) { - return idx - startpos - numericCount; - } - if (numericCount > 0) { - continue; - } - ch = msg.GetAt(idx); - if (!isText(ch)) { - break; - } - idx++; - } - return idx - startpos; -} -int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( - CFX_WideString msg, - CFX_ByteArray* bytes, - int32_t startpos, - int32_t& e) { - int32_t len = msg.GetLength(); - int32_t idx = startpos; - while (idx < len) { - FX_WCHAR ch = msg.GetAt(idx); - int32_t numericCount = 0; - while (numericCount < 13 && isDigit(ch)) { - numericCount++; - int32_t i = idx + numericCount; - if (i >= len) { - break; - } - ch = msg.GetAt(i); - } - if (numericCount >= 13) { - return idx - startpos; - } - int32_t textCount = 0; - while (textCount < 5 && isText(ch)) { - textCount++; - int32_t i = idx + textCount; - if (i >= len) { - break; - } - ch = msg.GetAt(i); - } - if (textCount >= 5) { - return idx - startpos; - } - ch = msg.GetAt(idx); - if (bytes->GetAt(idx) == 63 && ch != '?') { - e = BCExceptionNonEncodableCharacterDetected; - return -1; - } - idx++; - } - return idx - startpos; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h b/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h deleted file mode 100644 index 6ce363d08f..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.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_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" - -class CBC_PDF417HighLevelEncoder { - public: - static CFX_WideString encodeHighLevel(CFX_WideString msg, - Compaction compaction, - int32_t& e); - static void Inverse(); - static void Initialize(); - static void Finalize(); - - private: - static int32_t TEXT_COMPACTION; - static int32_t BYTE_COMPACTION; - static int32_t NUMERIC_COMPACTION; - static int32_t SUBMODE_PUNCTUATION; - static int32_t LATCH_TO_TEXT; - static int32_t LATCH_TO_BYTE_PADDED; - static int32_t LATCH_TO_NUMERIC; - static int32_t SHIFT_TO_BYTE; - static int32_t LATCH_TO_BYTE; - static uint8_t TEXT_MIXED_RAW[]; - static uint8_t TEXT_PUNCTUATION_RAW[]; - static int32_t MIXED[128]; - static int32_t PUNCTUATION[128]; - static int32_t encodeText(CFX_WideString msg, - int32_t startpos, - int32_t count, - CFX_WideString& sb, - int32_t initialSubmode); - static void encodeBinary(CFX_ByteArray* bytes, - int32_t startpos, - int32_t count, - int32_t startmode, - CFX_WideString& sb); - static void encodeNumeric(CFX_WideString msg, - int32_t startpos, - int32_t count, - CFX_WideString& sb); - static FX_BOOL isDigit(FX_WCHAR ch); - static FX_BOOL isAlphaUpper(FX_WCHAR ch); - static FX_BOOL isAlphaLower(FX_WCHAR ch); - static FX_BOOL isMixed(FX_WCHAR ch); - static FX_BOOL isPunctuation(FX_WCHAR ch); - static FX_BOOL isText(FX_WCHAR ch); - static int32_t determineConsecutiveDigitCount(CFX_WideString msg, - int32_t startpos); - static int32_t determineConsecutiveTextCount(CFX_WideString msg, - int32_t startpos); - static int32_t determineConsecutiveBinaryCount(CFX_WideString msg, - CFX_ByteArray* bytes, - int32_t startpos, - int32_t& e); - - friend class PDF417HighLevelEncoder_EncodeNumeric_Test; - friend class PDF417HighLevelEncoder_EncodeBinary_Test; - friend class PDF417HighLevelEncoder_EncodeText_Test; - friend class PDF417HighLevelEncoder_ConsecutiveDigitCount_Test; - friend class PDF417HighLevelEncoder_ConsecutiveTextCount_Test; - friend class PDF417HighLevelEncoder_ConsecutiveBinaryCount_Test; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp deleted file mode 100644 index b0f717e5bc..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp +++ /dev/null @@ -1,239 +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. - -#include "core/include/fxcrt/fx_basic.h" -#include "testing/fx_string_testhelpers.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" - -TEST(PDF417HighLevelEncoder, EncodeHighLevel) { - // TODO(tsepez): implement test cases. -} - -TEST(PDF417HighLevelEncoder, EncodeText) { - // TODO(tsepez): implement test cases. -} - -TEST(PDF417HighLevelEncoder, EncodeBinary) { - struct EncodeBinaryCase { - const char* input; - int offset; - int count; - int startmode; - const wchar_t* expected; - int expected_length; - } encode_binary_cases[] = { - // Empty string encodes as empty string. - {"", 0, 0, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, L"", 0}, - - // Fewer than 6 characters encodes as prefix without compaction. - {"xxxxx", 0, 5, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, - L"\x0385xxxxx", 6}, - - // 6 charcters triggerst text encoding compaction. - {"xxxxxx", 0, 6, CBC_PDF417HighLevelEncoder::TEXT_COMPACTION, - L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6}, - - // Same result if initially in numeric compaction mode. - {"xxxxxx", 0, 6, CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION, - L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6}, - }; - - CBC_PDF417HighLevelEncoder::Initialize(); - for (size_t i = 0; i < FX_ArraySize(encode_binary_cases); ++i) { - EncodeBinaryCase* ptr = &encode_binary_cases[i]; - CFX_ByteArray input_array; - size_t input_length = strlen(ptr->input); - input_array.SetSize(input_length); - for (size_t j = 0; j < input_length; ++j) { - input_array.SetAt(j, ptr->input[j]); - } - CFX_WideString expected(ptr->expected, ptr->expected_length); - CFX_WideString result; - CBC_PDF417HighLevelEncoder::encodeBinary( - &input_array, ptr->offset, ptr->count, ptr->startmode, result); - EXPECT_EQ(expected, result) << " for case number " << i; - } - CBC_PDF417HighLevelEncoder::Finalize(); -} - -TEST(PDF417HighLevelEncoder, EncodeNumeric) { - struct EncodeNumericCase { - const wchar_t* input; - int offset; - int count; - const wchar_t* expected; - int expected_length; - } encode_numeric_cases[] = { - // Empty string encodes as empty string. - {L"", 0, 0, L"", 0}, - - // Single 0 should encode as 10 base-900 == a. - {L"0", 0, 1, L"\x000a", 1}, - - // 800 should encode as 1800 base-900 == 2,0. - {L"800", 0, 3, L"\x0002\x0000", 2}, - - // Test longer strings and sub-strings. - {L"123456", 0, 6, L"\x0001\x015c\x0100", 3}, - {L"123456", 0, 5, L"\x007c\x02e9", 2}, - {L"123456", 1, 5, L"\x0089\x009c", 2}, - {L"123456", 2, 2, L"\x0086", 1}, - - // Up to 44 characters encodes as 15 base-900 words. - {L"00000000000000000000000000000000000000000000", - 0, - 44, - L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" - L"\x0090\x020b\x019b\x0064", - 15}, - - // 45 characters should encode as same 15 words followed by one additional - // word. - {L"000000000000000000000000000000000000000000000", - 0, - 45, - L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" - L"\x0090\x020b\x019b\x0064\x000a", - 16}, - - // 44 characters followed by 800 should encode as 15 words followed by - // 1800 base-900 == 2,0. - {L"00000000000000000000000000000000000000000000800", - 0, - 47, - L"\x01b5\x006f\x02cc\x0084\x01bc\x0076\x00b3\x005c\x01f0\x034f\x01e6" - L"\x0090\x020b\x019b\x0064\x0002\x0000", - 17}, - - // Even longer input. - {L"10000000000000000000000000000000000000000000000000", - 0, - 50, - L"\x01e0\x02f0\x036d\x02ad\x029c\x01ea\x0011\x000b\x02d6\x023c\x0108" - L"\x02bb\x0023\x02d2\x00c8\x0001\x00d3\x0064", - 18}, - }; - - CBC_PDF417HighLevelEncoder::Initialize(); - for (size_t i = 0; i < FX_ArraySize(encode_numeric_cases); ++i) { - EncodeNumericCase* ptr = &encode_numeric_cases[i]; - CFX_WideString input(ptr->input); - CFX_WideString expected(ptr->expected, ptr->expected_length); - CFX_WideString result; - CBC_PDF417HighLevelEncoder::encodeNumeric(input, ptr->offset, ptr->count, - result); - EXPECT_EQ(expected, result) << " for case number " << i; - } - CBC_PDF417HighLevelEncoder::Finalize(); -} - -TEST(PDF417HighLevelEncoder, ConsecutiveDigitCount) { - struct ConsecutiveDigitCase { - const wchar_t* input; - int offset; - int expected_count; - } consecutive_digit_cases[] = { - // Empty string contains 0 consecuitve digits. - {L"", 0, 0}, - - // Single non-digit character contains 0 consecutive digits. - {L"X", 0, 0}, - - // Leading non-digit followed by digits contains 0 consecutive. - {L"X123", 0, 0}, - - // Single digit contains 1 consecutive digit. - {L"1", 0, 1}, - - // Single digit followe by non-digit contains 1 consecutive digit. - {L"1Z", 0, 1}, - - // Test longer strings. - {L"123FOO45678", 0, 3}, - - // Test subtring starting in digits field. - {L"123FOO45678", 3, 0}, - - // Test subtring starting in non-digits field. - {L"123FOO45678", 3, 0}, - - // Test substring starting in digits field following non-digit field. - {L"123FOO45678", 6, 5}, - }; - - CBC_PDF417HighLevelEncoder::Initialize(); - for (size_t i = 0; i < FX_ArraySize(consecutive_digit_cases); ++i) { - ConsecutiveDigitCase* ptr = &consecutive_digit_cases[i]; - CFX_WideString input(ptr->input); - int actual_count = - CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(input, - ptr->offset); - EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; - } - CBC_PDF417HighLevelEncoder::Finalize(); -} - -TEST(PDF417HighLevelEncoder, ConsecutiveTextCount) { - struct ConsecutiveTextCase { - const wchar_t* input; - int offset; - int expected_count; - } consecutive_text_cases[] = { - // Empty string contains 0 consecutive text characters. - {L"", 0, 0}, - - // Single text character is 1 consecutive text characters. - {L"X", 0, 1}, - - // Trailing numbers count as text characters. - {L"X123", 0, 4}, - - // Leading numbers count as text characters. - {L"123X", 0, 4}, - - // Embedded lo-value binary characters terminate text runs. - {L"ABC\x0001XXXX", 0, 3}, - - // Embedded hi-value binary characters terminate text runs. - {L"ABC\x0100XXXX", 0, 3}, - - // Text run still found after indexing past lo-value character. - {L"ABC\x0001XXXX", 4, 4}, - - // Text run still found after indexing past hi-value character. - {L"ABC\x0100XXXX", 4, 4}, - - // Leading hi-value character results in 0 consecutive characters. - {L"\x0100XXX", 0, 0}, - - // Up to 12 numbers count as text. - {L"123456789012", 0, 12}, - - // 13 or more numbers are compresssed using numeric compression, not text. - {L"1234567890123", 0, 0}, - - // Leading Text character doesn't affect the 12 character case. - {L"X123456789012", 0, 13}, - - // Leading Text character doesn't affect the 13 character case. - {L"X1234567890123", 0, 1}, - - // Jumping between numbers and letters works properly. - {L"XXX121XXX12345678901234", 0, 9}, - }; - - CBC_PDF417HighLevelEncoder::Initialize(); - for (size_t i = 0; i < FX_ArraySize(consecutive_text_cases); ++i) { - ConsecutiveTextCase* ptr = &consecutive_text_cases[i]; - CFX_WideString input(ptr->input); - int actual_count = - CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(input, - ptr->offset); - EXPECT_EQ(ptr->expected_count, actual_count) << " for case number " << i; - } - CBC_PDF417HighLevelEncoder::Finalize(); -} - -TEST(PDF417HighLevelEncoder, ConsecutiveBinaryCount) {} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.cpp deleted file mode 100644 index 6365e27efb..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.cpp +++ /dev/null @@ -1,149 +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 -// Original code is licensed as follows: -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <limits> - -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_DecoderResult.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Detector.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectorResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_PDF417Reader::CBC_PDF417Reader() {} -CBC_PDF417Reader::~CBC_PDF417Reader() {} - -CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, int32_t& e) { - return Decode(image, 0, e); -} -CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, - FX_BOOL multiple, - int32_t hints, - int32_t& e) { - CFX_ByteString results; - 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; - e = BCExceptiontNotFoundInstance; - return ""; - } - results += ResultTemp->GetText(); - delete ResultTemp; - } - delete detectorResult; - return results; -} -CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - CFX_ByteString bs = Decode(image, FALSE, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return bs; -} -int32_t CBC_PDF417Reader::getMaxWidth(CBC_ResultPoint* p1, - CBC_ResultPoint* p2) { - if (p1 == NULL || p2 == NULL) { - return 0; - } - return (int32_t)FXSYS_fabs(p1->GetX() - p2->GetX()); -} -int32_t CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1, - CBC_ResultPoint* p2) { - if (!p1 || !p2) - 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::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; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.h deleted file mode 100644 index 5c19d86b97..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Reader.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_SRC_FXBARCODE_PDF417_BC_PDF417READER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417READER_H_ - -class CBC_BinaryBitmap; -class CBC_ResultPoint; -class CBC_PDF417Reader; -class CBC_PDF417Reader : public CBC_Reader { - public: - CBC_PDF417Reader(); - virtual ~CBC_PDF417Reader(); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, - FX_BOOL multiple, - int32_t hints, - int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); - - 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); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417READER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.cpp deleted file mode 100644 index 5bfcdee412..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h" - -CBC_PDF417ResultMetadata::CBC_PDF417ResultMetadata() {} -CBC_PDF417ResultMetadata::~CBC_PDF417ResultMetadata() {} -int32_t CBC_PDF417ResultMetadata::getSegmentIndex() { - return m_segmentIndex; -} -void CBC_PDF417ResultMetadata::setSegmentIndex(int32_t segmentIndex) { - m_segmentIndex = segmentIndex; -} -CFX_ByteString CBC_PDF417ResultMetadata::getFileId() { - return m_fileId; -} -void CBC_PDF417ResultMetadata::setFileId(CFX_ByteString fileId) { - m_fileId = fileId; -} -CFX_Int32Array& CBC_PDF417ResultMetadata::getOptionalData() { - return m_optionalData; -} -void CBC_PDF417ResultMetadata::setOptionalData(CFX_Int32Array& optionalData) { - m_optionalData.Copy(optionalData); -} -FX_BOOL CBC_PDF417ResultMetadata::isLastSegment() { - return m_lastSegment; -} -void CBC_PDF417ResultMetadata::setLastSegment(FX_BOOL lastSegment) { - m_lastSegment = lastSegment; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h deleted file mode 100644 index a70d3efc4a..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.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_SRC_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_PDF417ResultMetadata { - public: - CBC_PDF417ResultMetadata(); - virtual ~CBC_PDF417ResultMetadata(); - int32_t getSegmentIndex(); - void setSegmentIndex(int32_t segmentIndex); - CFX_ByteString getFileId(); - void setFileId(CFX_ByteString fileId); - CFX_Int32Array& getOptionalData(); - void setOptionalData(CFX_Int32Array& optionalData); - FX_BOOL isLastSegment(); - void setLastSegment(FX_BOOL lastSegment); - - private: - int32_t m_segmentIndex; - CFX_ByteString m_fileId; - CFX_Int32Array m_optionalData; - FX_BOOL m_lastSegment; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417RESULTMETADATA_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp deleted file mode 100644 index 820b15e91d..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp +++ /dev/null @@ -1,752 +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 -// Original code is licensed as follows: -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_DecoderResult.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMetadata.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeValue.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Codeword.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Common.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusGF.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h" -#include "xfa/src/fxbarcode/utils.h" - -int32_t CBC_PDF417ScanningDecoder::CODEWORD_SKEW_SIZE = 2; -int32_t CBC_PDF417ScanningDecoder::MAX_ERRORS = 3; -int32_t CBC_PDF417ScanningDecoder::MAX_EC_CODEWORDS = 512; -CBC_PDF417ECErrorCorrection* CBC_PDF417ScanningDecoder::errorCorrection = NULL; - -CBC_PDF417ScanningDecoder::CBC_PDF417ScanningDecoder() {} -CBC_PDF417ScanningDecoder::~CBC_PDF417ScanningDecoder() {} -void CBC_PDF417ScanningDecoder::Initialize() { - errorCorrection = new CBC_PDF417ECErrorCorrection; -} -void CBC_PDF417ScanningDecoder::Finalize() { - delete errorCorrection; -} -CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode( - CBC_CommonBitMatrix* image, - CBC_ResultPoint* imageTopLeft, - CBC_ResultPoint* imageBottomLeft, - CBC_ResultPoint* imageTopRight, - CBC_ResultPoint* imageBottomRight, - int32_t minCodewordWidth, - int32_t maxCodewordWidth, - int32_t& e) { - CBC_BoundingBox* boundingBox = new CBC_BoundingBox( - image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn = NULL; - CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn = NULL; - CBC_DetectionResult* detectionResult = NULL; - for (int32_t i = 0; i < 2; i++) { - if (imageTopLeft) { - leftRowIndicatorColumn = - getRowIndicatorColumn(image, boundingBox, *imageTopLeft, TRUE, - minCodewordWidth, maxCodewordWidth); - } - if (imageTopRight) { - rightRowIndicatorColumn = - getRowIndicatorColumn(image, boundingBox, *imageTopRight, FALSE, - minCodewordWidth, maxCodewordWidth); - } - detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn, e); - if (e != BCExceptionNO) { - e = BCExceptiontNotFoundInstance; - delete leftRowIndicatorColumn; - delete rightRowIndicatorColumn; - delete boundingBox; - return NULL; - } - if (i == 0 && (detectionResult->getBoundingBox()->getMinY() < - boundingBox->getMinY() || - detectionResult->getBoundingBox()->getMaxY() > - boundingBox->getMaxY())) { - delete boundingBox; - boundingBox = detectionResult->getBoundingBox(); - } else { - detectionResult->setBoundingBox(boundingBox); - break; - } - } - int32_t maxBarcodeColumn = detectionResult->getBarcodeColumnCount() + 1; - detectionResult->setDetectionResultColumn(0, leftRowIndicatorColumn); - detectionResult->setDetectionResultColumn(maxBarcodeColumn, - rightRowIndicatorColumn); - FX_BOOL leftToRight = leftRowIndicatorColumn != NULL; - for (int32_t barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn; - barcodeColumnCount++) { - int32_t barcodeColumn = leftToRight ? barcodeColumnCount - : maxBarcodeColumn - barcodeColumnCount; - if (detectionResult->getDetectionResultColumn(barcodeColumn)) { - continue; - } - CBC_DetectionResultColumn* detectionResultColumn = NULL; - if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) { - detectionResultColumn = new CBC_DetectionResultRowIndicatorColumn( - boundingBox, barcodeColumn == 0); - } else { - detectionResultColumn = new CBC_DetectionResultColumn(boundingBox); - } - detectionResult->setDetectionResultColumn(barcodeColumn, - detectionResultColumn); - int32_t startColumn = -1; - int32_t previousStartColumn = startColumn; - for (int32_t imageRow = boundingBox->getMinY(); - imageRow <= boundingBox->getMaxY(); imageRow++) { - startColumn = - getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight); - if (startColumn < 0 || startColumn > boundingBox->getMaxX()) { - if (previousStartColumn == -1) { - continue; - } - startColumn = previousStartColumn; - } - CBC_Codeword* codeword = detectCodeword( - image, boundingBox->getMinX(), boundingBox->getMaxX(), leftToRight, - startColumn, imageRow, minCodewordWidth, maxCodewordWidth); - if (codeword) { - detectionResultColumn->setCodeword(imageRow, codeword); - previousStartColumn = startColumn; - minCodewordWidth = minCodewordWidth < codeword->getWidth() - ? minCodewordWidth - : codeword->getWidth(); - maxCodewordWidth = maxCodewordWidth > codeword->getWidth() - ? maxCodewordWidth - : codeword->getWidth(); - } - } - } - CBC_CommonDecoderResult* decoderresult = - createDecoderResult(detectionResult, e); - if (e != BCExceptionNO) { - delete detectionResult; - return NULL; - } - return decoderresult; -} -CFX_ByteString CBC_PDF417ScanningDecoder::toString( - CFX_PtrArray* 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); - if (barcodeValue->getValue()->GetSize() == 0) { - result += ""; - } else { - result += barcodeValue->getValue()->GetAt(0); - result += - barcodeValue->getConfidence(barcodeValue->getValue()->GetAt(0)); - } - } - } - return result; -} -CBC_DetectionResult* CBC_PDF417ScanningDecoder::merge( - CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, - CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn, - int32_t& e) { - if (leftRowIndicatorColumn == NULL && rightRowIndicatorColumn == NULL) { - e = BCExceptionIllegalArgument; - return NULL; - } - CBC_BarcodeMetadata* barcodeMetadata = - getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn); - if (barcodeMetadata == NULL) { - e = BCExceptionCannotMetadata; - return NULL; - } - CBC_BoundingBox* leftboundingBox = - adjustBoundingBox(leftRowIndicatorColumn, e); - if (e != BCExceptionNO) { - delete barcodeMetadata; - return NULL; - } - CBC_BoundingBox* rightboundingBox = - adjustBoundingBox(rightRowIndicatorColumn, e); - if (e != BCExceptionNO) { - delete barcodeMetadata; - return NULL; - } - CBC_BoundingBox* boundingBox = - CBC_BoundingBox::merge(leftboundingBox, rightboundingBox, e); - if (e != BCExceptionNO) { - delete barcodeMetadata; - return NULL; - } - CBC_DetectionResult* detectionresult = - new CBC_DetectionResult(barcodeMetadata, boundingBox); - return detectionresult; -} -CBC_BoundingBox* CBC_PDF417ScanningDecoder::adjustBoundingBox( - CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn, - int32_t& e) { - if (rowIndicatorColumn == NULL) { - return NULL; - } - CFX_Int32Array* rowHeights = rowIndicatorColumn->getRowHeights(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t maxRowHeight = getMax(*rowHeights); - int32_t missingStartRows = 0; - for (int32_t i = 0; i < rowHeights->GetSize(); i++) { - int32_t rowHeight = rowHeights->GetAt(i); - missingStartRows += maxRowHeight - rowHeight; - if (rowHeight > 0) { - break; - } - } - CFX_PtrArray* codewords = rowIndicatorColumn->getCodewords(); - for (int32_t row = 0; missingStartRows > 0 && codewords->GetAt(row) == NULL; - row++) { - missingStartRows--; - } - int32_t missingEndRows = 0; - for (int32_t row1 = rowHeights->GetSize() - 1; row1 >= 0; row1--) { - missingEndRows += maxRowHeight - rowHeights->GetAt(row1); - if (rowHeights->GetAt(row1) > 0) { - break; - } - } - for (int32_t row2 = codewords->GetSize() - 1; - missingEndRows > 0 && codewords->GetAt(row2) == NULL; row2--) { - missingEndRows--; - } - CBC_BoundingBox* boundingBox = - rowIndicatorColumn->getBoundingBox()->addMissingRows( - missingStartRows, missingEndRows, rowIndicatorColumn->isLeft(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return boundingBox; -} -int32_t CBC_PDF417ScanningDecoder::getMax(CFX_Int32Array& values) { - int32_t maxValue = -1; - for (int32_t i = 0; i < values.GetSize(); i++) { - int32_t value = values.GetAt(i); - maxValue = maxValue > value ? maxValue : value; - } - return maxValue; -} -CBC_BarcodeMetadata* CBC_PDF417ScanningDecoder::getBarcodeMetadata( - CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, - CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn) { - CBC_BarcodeMetadata* leftBarcodeMetadata = NULL; - CBC_BarcodeMetadata* rightBarcodeMetadata = NULL; - if (leftRowIndicatorColumn == NULL || - (leftBarcodeMetadata = leftRowIndicatorColumn->getBarcodeMetadata()) == - NULL) { - return rightRowIndicatorColumn == NULL - ? NULL - : rightRowIndicatorColumn->getBarcodeMetadata(); - } - if (rightRowIndicatorColumn == NULL || - (rightBarcodeMetadata = rightRowIndicatorColumn->getBarcodeMetadata()) == - NULL) { - return leftRowIndicatorColumn == NULL - ? NULL - : leftRowIndicatorColumn->getBarcodeMetadata(); - } - if (leftBarcodeMetadata->getColumnCount() != - rightBarcodeMetadata->getColumnCount() && - leftBarcodeMetadata->getErrorCorrectionLevel() != - rightBarcodeMetadata->getErrorCorrectionLevel() && - leftBarcodeMetadata->getRowCount() != - rightBarcodeMetadata->getRowCount()) { - delete leftBarcodeMetadata; - delete rightBarcodeMetadata; - return NULL; - } - delete rightBarcodeMetadata; - return leftBarcodeMetadata; -} -CBC_DetectionResultRowIndicatorColumn* -CBC_PDF417ScanningDecoder::getRowIndicatorColumn(CBC_CommonBitMatrix* image, - CBC_BoundingBox* boundingBox, - CBC_ResultPoint startPoint, - FX_BOOL leftToRight, - int32_t minCodewordWidth, - int32_t maxCodewordWidth) { - CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn = - new CBC_DetectionResultRowIndicatorColumn(boundingBox, leftToRight); - for (int32_t i = 0; i < 2; i++) { - int32_t increment = i == 0 ? 1 : -1; - int32_t startColumn = (int32_t)startPoint.GetX(); - for (int32_t imageRow = (int32_t)startPoint.GetY(); - imageRow <= boundingBox->getMaxY() && - imageRow >= boundingBox->getMinY(); - imageRow += increment) { - CBC_Codeword* codeword = - detectCodeword(image, 0, image->GetWidth(), leftToRight, startColumn, - imageRow, minCodewordWidth, maxCodewordWidth); - if (codeword) { - rowIndicatorColumn->setCodeword(imageRow, codeword); - if (leftToRight) { - startColumn = codeword->getStartX(); - } else { - startColumn = codeword->getEndX(); - } - } - } - } - return rowIndicatorColumn; -} -void CBC_PDF417ScanningDecoder::adjustCodewordCount( - CBC_DetectionResult* detectionResult, - CFX_PtrArray* barcodeMatrix, - int32_t& e) { - CFX_Int32Array* numberOfCodewords = - ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(0))->GetAt(1)) - ->getValue(); - int32_t calculatedNumberOfCodewords = - detectionResult->getBarcodeColumnCount() * - detectionResult->getBarcodeRowCount() - - getNumberOfECCodeWords(detectionResult->getBarcodeECLevel()); - if (numberOfCodewords->GetSize() == 0) { - if (calculatedNumberOfCodewords < 1 || - 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); - } else if (numberOfCodewords->GetAt(0) != calculatedNumberOfCodewords) { - ((CBC_BarcodeValue*)((CFX_PtrArray*)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); - 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(); - delete temp; - } - barcodeMatrix->RemoveAll(); - delete barcodeMatrix; - return NULL; - } - CFX_Int32Array erasures; - CFX_Int32Array codewords; - codewords.SetSize(detectionResult->getBarcodeRowCount() * - detectionResult->getBarcodeColumnCount()); - CFX_PtrArray 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(); - int32_t codewordIndex = - row * detectionResult->getBarcodeColumnCount() + l; - if (values->GetSize() == 0) { - erasures.Add(codewordIndex); - } else if (values->GetSize() == 1) { - codewords[codewordIndex] = values->GetAt(0); - } else { - ambiguousIndexesList.Add(codewordIndex); - ambiguousIndexValuesList.Add(values); - } - } - } - CFX_PtrArray 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); - } - 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); - return decoderResult; -} -CBC_CommonDecoderResult* -CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues( - int32_t ecLevel, - CFX_Int32Array& codewords, - CFX_Int32Array& erasureArray, - CFX_Int32Array& ambiguousIndexes, - CFX_PtrArray& ambiguousIndexValues, - int32_t& e) { - CFX_Int32Array ambiguousIndexCount; - ambiguousIndexCount.SetSize(ambiguousIndexes.GetSize()); - int32_t tries = 100; - while (tries-- > 0) { - for (int32_t l = 0; l < ambiguousIndexCount.GetSize(); l++) { - codewords[ambiguousIndexes[l]] = - ((CFX_Int32Array*)ambiguousIndexValues.GetAt(l)) - ->GetAt(ambiguousIndexCount[l]); - } - CBC_CommonDecoderResult* decoderResult = - decodeCodewords(codewords, ecLevel, erasureArray, e); - if (e != BCExceptionNO) { - e = BCExceptionNO; - continue; - } else { - return decoderResult; - } - if (ambiguousIndexCount.GetSize() == 0) { - e = BCExceptionChecksumInstance; - return NULL; - } - for (int32_t i = 0; i < ambiguousIndexCount.GetSize(); i++) { - if (ambiguousIndexCount[i] < - ((CFX_Int32Array*)(ambiguousIndexValues.GetAt(i)))->GetSize() - 1) { - ambiguousIndexCount[i]++; - break; - } else { - ambiguousIndexCount[i] = 0; - if (i == ambiguousIndexCount.GetSize() - 1) { - e = BCExceptionChecksumInstance; - return NULL; - } - } - } - } - e = BCExceptionChecksumInstance; - return NULL; -} -CFX_PtrArray* CBC_PDF417ScanningDecoder::createBarcodeMatrix( - CBC_DetectionResult* detectionResult) { - CFX_PtrArray* barcodeMatrix = new CFX_PtrArray; - 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; - temp->SetSize(detectionResult->getBarcodeColumnCount() + 2); - for (colume = 0; colume < detectionResult->getBarcodeColumnCount() + 2; - colume++) { - temp->SetAt(colume, 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(); - for (int32_t l = 0; l < temp->GetSize(); l++) { - CBC_Codeword* codeword = (CBC_Codeword*)temp->GetAt(l); - if (codeword == NULL || codeword->getRowNumber() == -1) { - continue; - } - ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt( - codeword->getRowNumber())) - ->GetAt(colume)) - ->setValue(codeword->getValue()); - } - } - return barcodeMatrix; -} -FX_BOOL CBC_PDF417ScanningDecoder::isValidBarcodeColumn( - CBC_DetectionResult* detectionResult, - int32_t barcodeColumn) { - return barcodeColumn >= 0 && - barcodeColumn <= detectionResult->getBarcodeColumnCount() + 1; -} -int32_t CBC_PDF417ScanningDecoder::getStartColumn( - CBC_DetectionResult* detectionResult, - int32_t barcodeColumn, - int32_t imageRow, - FX_BOOL leftToRight) { - int32_t offset = leftToRight ? 1 : -1; - CBC_Codeword* codeword = NULL; - if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) - ->getCodeword(imageRow); - } - if (codeword) { - return leftToRight ? codeword->getEndX() : codeword->getStartX(); - } - codeword = detectionResult->getDetectionResultColumn(barcodeColumn) - ->getCodewordNearby(imageRow); - if (codeword) { - return leftToRight ? codeword->getStartX() : codeword->getEndX(); - } - if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) - ->getCodewordNearby(imageRow); - } - if (codeword) { - return leftToRight ? codeword->getEndX() : codeword->getStartX(); - } - int32_t skippedColumns = 0; - while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { - barcodeColumn -= offset; - for (int32_t i = 0; - i < detectionResult->getDetectionResultColumn(barcodeColumn) - ->getCodewords() - ->GetSize(); - i++) { - CBC_Codeword* previousRowCodeword = - (CBC_Codeword*)detectionResult->getDetectionResultColumn( - barcodeColumn) - ->getCodewords() - ->GetAt(i); - if (previousRowCodeword) { - return (leftToRight ? previousRowCodeword->getEndX() - : previousRowCodeword->getStartX()) + - offset * skippedColumns * (previousRowCodeword->getEndX() - - previousRowCodeword->getStartX()); - } - } - skippedColumns++; - } - return leftToRight ? detectionResult->getBoundingBox()->getMinX() - : detectionResult->getBoundingBox()->getMaxX(); -} -CBC_Codeword* CBC_PDF417ScanningDecoder::detectCodeword( - CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t startColumn, - int32_t imageRow, - int32_t minCodewordWidth, - int32_t maxCodewordWidth) { - startColumn = adjustCodewordStartColumn(image, minColumn, maxColumn, - leftToRight, startColumn, imageRow); - CFX_Int32Array* moduleBitCount = getModuleBitCount( - image, minColumn, maxColumn, leftToRight, startColumn, imageRow); - if (moduleBitCount == NULL) { - return NULL; - } - int32_t endColumn; - int32_t codewordBitCount = CBC_PDF417Common::getBitCountSum(*moduleBitCount); - if (leftToRight) { - endColumn = startColumn + codewordBitCount; - } else { - for (int32_t i = 0; i<moduleBitCount->GetSize()>> 1; i++) { - int32_t tmpCount = moduleBitCount->GetAt(i); - moduleBitCount->SetAt( - i, moduleBitCount->GetAt(moduleBitCount->GetSize() - 1 - i)); - moduleBitCount->SetAt(moduleBitCount->GetSize() - 1 - i, tmpCount); - } - endColumn = startColumn; - startColumn = endColumn - codewordBitCount; - } - int32_t decodedValue = - CBC_PDF417CodewordDecoder::getDecodedValue(*moduleBitCount); - int32_t codeword = CBC_PDF417Common::getCodeword(decodedValue); - delete moduleBitCount; - if (codeword == -1) { - return NULL; - } - return new CBC_Codeword(startColumn, endColumn, - getCodewordBucketNumber(decodedValue), codeword); -} -CFX_Int32Array* CBC_PDF417ScanningDecoder::getModuleBitCount( - CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t startColumn, - int32_t imageRow) { - int32_t imageColumn = startColumn; - CFX_Int32Array* moduleBitCount = new CFX_Int32Array; - moduleBitCount->SetSize(8); - int32_t moduleNumber = 0; - int32_t increment = leftToRight ? 1 : -1; - FX_BOOL previousPixelValue = leftToRight; - while (((leftToRight && imageColumn < maxColumn) || - (!leftToRight && imageColumn >= minColumn)) && - moduleNumber < moduleBitCount->GetSize()) { - if (image->Get(imageColumn, imageRow) == previousPixelValue) { - moduleBitCount->SetAt(moduleNumber, - moduleBitCount->GetAt(moduleNumber) + 1); - imageColumn += increment; - } else { - moduleNumber++; - previousPixelValue = !previousPixelValue; - } - } - if (moduleNumber == moduleBitCount->GetSize() || - (((leftToRight && imageColumn == maxColumn) || - (!leftToRight && imageColumn == minColumn)) && - moduleNumber == moduleBitCount->GetSize() - 1)) { - return moduleBitCount; - } - delete moduleBitCount; - return NULL; -} -int32_t CBC_PDF417ScanningDecoder::getNumberOfECCodeWords( - int32_t barcodeECLevel) { - return 2 << barcodeECLevel; -} -int32_t CBC_PDF417ScanningDecoder::adjustCodewordStartColumn( - CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t codewordStartColumn, - int32_t imageRow) { - int32_t correctedStartColumn = codewordStartColumn; - int32_t increment = leftToRight ? -1 : 1; - for (int32_t i = 0; i < 2; i++) { - while (((leftToRight && correctedStartColumn >= minColumn) || - (!leftToRight && correctedStartColumn < maxColumn)) && - leftToRight == image->Get(correctedStartColumn, imageRow)) { - if (abs(codewordStartColumn - correctedStartColumn) > - CODEWORD_SKEW_SIZE) { - return codewordStartColumn; - } - correctedStartColumn += increment; - } - increment = -increment; - leftToRight = !leftToRight; - } - return correctedStartColumn; -} -FX_BOOL CBC_PDF417ScanningDecoder::checkCodewordSkew(int32_t codewordSize, - int32_t minCodewordWidth, - int32_t maxCodewordWidth) { - return minCodewordWidth - CODEWORD_SKEW_SIZE <= codewordSize && - codewordSize <= maxCodewordWidth + CODEWORD_SKEW_SIZE; -} -CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decodeCodewords( - CFX_Int32Array& codewords, - int32_t ecLevel, - CFX_Int32Array& erasures, - int32_t& e) { - if (codewords.GetSize() == 0) { - e = BCExceptionFormatInstance; - return NULL; - } - int32_t numECCodewords = 1 << (ecLevel + 1); - correctErrors(codewords, erasures, numECCodewords, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - verifyCodewordCount(codewords, numECCodewords, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_ByteString bytestring; - CBC_CommonDecoderResult* decoderResult = CBC_DecodedBitStreamPaser::decode( - codewords, bytestring.FormatInteger(ecLevel), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return decoderResult; -} -int32_t CBC_PDF417ScanningDecoder::correctErrors(CFX_Int32Array& codewords, - CFX_Int32Array& erasures, - int32_t numECCodewords, - int32_t& e) { - if ((erasures.GetSize() != 0 && - erasures.GetSize() > (numECCodewords / 2 + MAX_ERRORS)) || - numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) { - e = BCExceptionChecksumInstance; - return -1; - } - int32_t result = CBC_PDF417ECErrorCorrection::decode( - codewords, numECCodewords, erasures, e); - BC_EXCEPTION_CHECK_ReturnValue(e, -1); - return result; -} -void CBC_PDF417ScanningDecoder::verifyCodewordCount(CFX_Int32Array& codewords, - int32_t numECCodewords, - int32_t& e) { - if (codewords.GetSize() < 4) { - e = BCExceptionFormatInstance; - return; - } - int32_t numberOfCodewords = codewords.GetAt(0); - if (numberOfCodewords > codewords.GetSize()) { - e = BCExceptionFormatInstance; - return; - } - if (numberOfCodewords == 0) { - if (numECCodewords < codewords.GetSize()) { - codewords[0] = codewords.GetSize() - numECCodewords; - } else { - e = BCExceptionFormatInstance; - return; - } - } -} -CFX_Int32Array* CBC_PDF417ScanningDecoder::getBitCountForCodeword( - int32_t codeword) { - CFX_Int32Array* result = new CFX_Int32Array; - result->SetSize(8); - int32_t previousValue = 0; - int32_t i = result->GetSize() - 1; - while (TRUE) { - if ((codeword & 0x1) != previousValue) { - previousValue = codeword & 0x1; - i--; - if (i < 0) { - break; - } - } - result->SetAt(i, result->GetAt(i) + 1); - codeword >>= 1; - } - return result; -} -int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber(int32_t codeword) { - CFX_Int32Array* array = getBitCountForCodeword(codeword); - int32_t result = getCodewordBucketNumber(*array); - delete array; - return result; -} -int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber( - CFX_Int32Array& moduleBitCount) { - return (moduleBitCount.GetAt(0) - moduleBitCount.GetAt(2) + - moduleBitCount.GetAt(4) - moduleBitCount.GetAt(6) + 9) % - 9; -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h b/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h deleted file mode 100644 index ca310d2c44..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h +++ /dev/null @@ -1,119 +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_SRC_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ - -class CBC_CommonDecoderResult; -class CBC_CommonBitMatrix; -class CBC_Codeword; -class CBC_BoundingBox; -class CBC_ResultPoint; -class CBC_BarcodeMetadata; -class CBC_DetectionResult; -class CBC_DetectionResultRowIndicatorColumn; - -class CBC_PDF417ScanningDecoder { - public: - CBC_PDF417ScanningDecoder(); - virtual ~CBC_PDF417ScanningDecoder(); - static void Initialize(); - static void Finalize(); - static CBC_CommonDecoderResult* decode(CBC_CommonBitMatrix* image, - CBC_ResultPoint* imageTopLeft, - CBC_ResultPoint* imageBottomLeft, - CBC_ResultPoint* imageTopRight, - CBC_ResultPoint* imageBottomRight, - int32_t minCodewordWidth, - int32_t maxCodewordWidth, - int32_t& e); - static CFX_ByteString toString(CFX_PtrArray* barcodeMatrix); - - private: - static int32_t CODEWORD_SKEW_SIZE; - static int32_t MAX_ERRORS; - static int32_t MAX_EC_CODEWORDS; - static CBC_PDF417ECErrorCorrection* errorCorrection; - static CBC_DetectionResult* merge( - CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, - CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn, - int32_t& e); - static CBC_BoundingBox* adjustBoundingBox( - CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn, - int32_t& e); - static int32_t getMax(CFX_Int32Array& values); - static CBC_BarcodeMetadata* getBarcodeMetadata( - CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, - CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn); - static CBC_DetectionResultRowIndicatorColumn* getRowIndicatorColumn( - CBC_CommonBitMatrix* image, - CBC_BoundingBox* boundingBox, - CBC_ResultPoint startPoint, - FX_BOOL leftToRight, - int32_t minCodewordWidth, - int32_t maxCodewordWidth); - static void adjustCodewordCount(CBC_DetectionResult* detectionResult, - CFX_PtrArray* barcodeMatrix, - int32_t& e); - static CBC_CommonDecoderResult* createDecoderResult( - CBC_DetectionResult* detectionResult, - int32_t& e); - static CBC_CommonDecoderResult* createDecoderResultFromAmbiguousValues( - int32_t ecLevel, - CFX_Int32Array& codewords, - CFX_Int32Array& erasureArray, - CFX_Int32Array& ambiguousIndexes, - CFX_PtrArray& ambiguousIndexValues, - int32_t& e); - static CFX_PtrArray* createBarcodeMatrix( - CBC_DetectionResult* detectionResult); - static FX_BOOL isValidBarcodeColumn(CBC_DetectionResult* detectionResult, - int32_t barcodeColumn); - static int32_t getStartColumn(CBC_DetectionResult* detectionResult, - int32_t barcodeColumn, - int32_t imageRow, - FX_BOOL leftToRight); - static CBC_Codeword* detectCodeword(CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t startColumn, - int32_t imageRow, - int32_t minCodewordWidth, - int32_t maxCodewordWidth); - static CFX_Int32Array* getModuleBitCount(CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t startColumn, - int32_t imageRow); - static int32_t getNumberOfECCodeWords(int32_t barcodeECLevel); - static int32_t adjustCodewordStartColumn(CBC_CommonBitMatrix* image, - int32_t minColumn, - int32_t maxColumn, - FX_BOOL leftToRight, - int32_t codewordStartColumn, - int32_t imageRow); - static FX_BOOL checkCodewordSkew(int32_t codewordSize, - int32_t minCodewordWidth, - int32_t maxCodewordWidth); - static CBC_CommonDecoderResult* decodeCodewords(CFX_Int32Array& codewords, - int32_t ecLevel, - CFX_Int32Array& erasures, - int32_t& e); - static int32_t correctErrors(CFX_Int32Array& codewords, - CFX_Int32Array& erasures, - int32_t numECCodewords, - int32_t& e); - static void verifyCodewordCount(CFX_Int32Array& codewords, - int32_t numECCodewords, - int32_t& e); - static CFX_Int32Array* getBitCountForCodeword(int32_t codeword); - static int32_t getCodewordBucketNumber(int32_t codeword); - static int32_t getCodewordBucketNumber(CFX_Int32Array& moduleBitCount); -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_ diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp deleted file mode 100644 index 97cd9d82c4..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.cpp +++ /dev/null @@ -1,115 +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 -// Original code is licensed as follows: -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Compaction.h" -#include "xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h" - -CBC_PDF417Writer::CBC_PDF417Writer() { - m_bFixedSize = FALSE; -} -CBC_PDF417Writer::~CBC_PDF417Writer() { - m_bTruncated = TRUE; -} -FX_BOOL CBC_PDF417Writer::SetErrorCorrectionLevel(int32_t level) { - if (level < 0 || level > 8) { - return FALSE; - } - m_iCorrectLevel = level; - return TRUE; -} -void CBC_PDF417Writer::SetTruncated(FX_BOOL truncated) { - m_bTruncated = truncated; -} -uint8_t* CBC_PDF417Writer::Encode(const CFX_WideString& contents, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - CBC_PDF417 encoder; - int32_t col = (m_Width / m_ModuleWidth - 69) / 17; - int32_t row = m_Height / (m_ModuleWidth * 20); - if (row >= 3 && row <= 90 && col >= 1 && col <= 30) { - encoder.setDimensions(col, col, row, row); - } else if (col >= 1 && col <= 30) { - encoder.setDimensions(col, col, 90, 3); - } else if (row >= 3 && row <= 90) { - encoder.setDimensions(30, 1, row, row); - } - encoder.generateBarcodeLogic(contents, m_iCorrectLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t lineThickness = 2; - int32_t aspectRatio = 4; - CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix(); - CFX_ByteArray originalScale; - originalScale.Copy(barcodeMatrix->getScaledMatrix( - lineThickness, aspectRatio * lineThickness)); - int32_t width = outWidth; - int32_t height = outHeight; - outWidth = barcodeMatrix->getWidth(); - outHeight = barcodeMatrix->getHeight(); - FX_BOOL rotated = FALSE; - if ((height > width) ^ (outWidth < outHeight)) { - rotateArray(originalScale, outHeight, outWidth); - rotated = TRUE; - int32_t temp = outHeight; - outHeight = outWidth; - outWidth = temp; - } - int32_t scaleX = width / outWidth; - int32_t scaleY = height / outHeight; - int32_t scale; - if (scaleX < scaleY) { - scale = scaleX; - } else { - scale = scaleY; - } - if (scale > 1) { - originalScale.RemoveAll(); - originalScale.Copy(barcodeMatrix->getScaledMatrix( - scale * lineThickness, scale * aspectRatio * lineThickness)); - if (rotated) { - rotateArray(originalScale, outHeight, outWidth); - int32_t temp = outHeight; - outHeight = outWidth; - outWidth = temp; - } - } - uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth); - FXSYS_memcpy(result, originalScale.GetData(), outHeight * outWidth); - return result; -} -void CBC_PDF417Writer::rotateArray(CFX_ByteArray& bitarray, - int32_t height, - int32_t width) { - CFX_ByteArray temp; - temp.Copy(bitarray); - for (int32_t ii = 0; ii < height; ii++) { - int32_t inverseii = height - ii - 1; - for (int32_t jj = 0; jj < width; jj++) { - bitarray[jj * height + inverseii] = temp[ii * width + jj]; - } - } -} diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h b/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.h deleted file mode 100644 index 3bfae5e05d..0000000000 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Writer.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_SRC_FXBARCODE_PDF417_BC_PDF417WRITER_H_ -#define XFA_SRC_FXBARCODE_PDF417_BC_PDF417WRITER_H_ - -class CBC_TwoDimWriter; -class CBC_PDF417Writer; -class CBC_PDF417Writer : public CBC_TwoDimWriter { - public: - CBC_PDF417Writer(); - virtual ~CBC_PDF417Writer(); - uint8_t* Encode(const CFX_WideString& contents, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - FX_BOOL SetErrorCorrectionLevel(int32_t level); - void SetTruncated(FX_BOOL truncated); - - private: - void rotateArray(CFX_ByteArray& bitarray, int32_t width, int32_t height); - FX_BOOL m_bTruncated; -}; - -#endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417WRITER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.cpp b/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.cpp deleted file mode 100644 index 1a2069030e..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" -#include "xfa/src/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() {} -CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetBottomLeft() { - return m_bottomLeft; -} -CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopLeft() { - return m_topLeft; -} -CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopRight() { - return m_topRight; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h b/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h deleted file mode 100644 index 14316e5a16..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.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_SRC_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_QRFinderPattern; - -class CBC_QRFinderPatternInfo { - 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_SRC_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp b/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp deleted file mode 100644 index 50b25f8535..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp +++ /dev/null @@ -1,49 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h" - -CBC_QRAlignmentPattern::CBC_QRAlignmentPattern(FX_FLOAT posX, - FX_FLOAT posY, - FX_FLOAT estimateModuleSize) - : CBC_ResultPoint(posX, posY), m_moduleSize(estimateModuleSize) {} -CBC_QRAlignmentPattern::~CBC_QRAlignmentPattern() {} -FX_FLOAT CBC_QRAlignmentPattern::GetX() { - return m_x; -} -FX_FLOAT CBC_QRAlignmentPattern::GetY() { - return m_y; -} -FX_BOOL CBC_QRAlignmentPattern::AboutEquals(FX_FLOAT moduleSize, - FX_FLOAT i, - FX_FLOAT j) { - if ((FXSYS_fabs(i - GetY()) <= moduleSize) && - (FXSYS_fabs(j - GetX()) <= moduleSize)) { - FX_FLOAT moduleSizeDiff = FXSYS_fabs(moduleSize - m_moduleSize); - return (moduleSizeDiff <= 1.0f) || (moduleSizeDiff / m_moduleSize <= 1.0f); - } - return FALSE; -} -CBC_QRAlignmentPattern* CBC_QRAlignmentPattern::Clone() { - return new CBC_QRAlignmentPattern(m_x, m_y, m_moduleSize); -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h b/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h deleted file mode 100644 index f40d371631..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ -class CBC_ResultPoint; -class CBC_QRAlignmentPattern : public CBC_ResultPoint { - private: - FX_FLOAT m_moduleSize; - - public: - CBC_QRAlignmentPattern(FX_FLOAT posX, - FX_FLOAT posY, - FX_FLOAT estimateModuleSize); - virtual ~CBC_QRAlignmentPattern(); - FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j); - FX_FLOAT GetX(); - FX_FLOAT GetY(); - CBC_QRAlignmentPattern* Clone(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp deleted file mode 100644 index 2d1aa433a0..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp +++ /dev/null @@ -1,200 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPattern.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h" - -CBC_QRAlignmentPatternFinder::CBC_QRAlignmentPatternFinder( - CBC_CommonBitMatrix* image, - int32_t startX, - int32_t startY, - int32_t width, - int32_t height, - FX_FLOAT moduleSize) - : m_image(image), - m_startX(startX), - m_startY(startY), - m_width(width), - m_height(height), - 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(); -} -CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::Find(int32_t& e) { - int32_t startX = m_startX; - int32_t height = m_height; - int32_t maxJ = startX + m_width; - int32_t middleI = m_startY + (height >> 1); - CFX_Int32Array stateCount; - stateCount.SetSize(3); - for (int32_t iGen = 0; iGen < height; iGen++) { - int32_t i = - middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - int32_t j = startX; - while (j < maxJ && !m_image->Get(j, i)) { - j++; - } - int32_t currentState = 0; - while (j < maxJ) { - if (m_image->Get(j, i)) { - if (currentState == 1) { - stateCount[currentState]++; - } else { - if (currentState == 2) { - if (FoundPatternCross(stateCount)) { - CBC_QRAlignmentPattern* confirmed = - HandlePossibleCenter(stateCount, i, j); - if (confirmed) { - return confirmed; - } - } - stateCount[0] = stateCount[2]; - stateCount[1] = 1; - stateCount[2] = 0; - currentState = 1; - } else { - stateCount[++currentState]++; - } - } - } else { - if (currentState == 1) { - currentState++; - } - stateCount[currentState]++; - } - j++; - } - if (FoundPatternCross(stateCount)) { - CBC_QRAlignmentPattern* confirmed = - HandlePossibleCenter(stateCount, i, maxJ); - if (confirmed) { - return confirmed; - } - } - } - if (m_possibleCenters.GetSize() != 0) { - return ((CBC_QRAlignmentPattern*)(m_possibleCenters[0]))->Clone(); - } - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return NULL; -} -FX_FLOAT CBC_QRAlignmentPatternFinder::CenterFromEnd( - const CFX_Int32Array& stateCount, - int32_t end) { - return (FX_FLOAT)(end - stateCount[2]) - stateCount[1] / 2.0f; -} -FX_BOOL CBC_QRAlignmentPatternFinder::FoundPatternCross( - const CFX_Int32Array& stateCount) { - FX_FLOAT moduleSize = m_moduleSize; - FX_FLOAT maxVariance = moduleSize / 2.0f; - for (int32_t i = 0; i < 3; i++) { - if (fabs(moduleSize - stateCount[i]) >= maxVariance) { - return false; - } - } - return TRUE; -} -FX_FLOAT CBC_QRAlignmentPatternFinder::CrossCheckVertical( - int32_t startI, - int32_t centerJ, - int32_t maxCount, - int32_t originalStateCountTotal) { - int32_t maxI = m_image->GetHeight(); - CFX_Int32Array stateCount; - stateCount.Copy(m_crossCheckStateCount); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - int32_t i = startI; - while (i >= 0 && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - if (i < 0 || stateCount[1] > maxCount) { - return FXSYS_nan(); - } - while (i >= 0 && !m_image->Get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return FXSYS_nan(); - } - i = startI + 1; - while (i < maxI && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i++; - } - if (i == maxI || stateCount[1] > maxCount) { - return FXSYS_nan(); - } - while (i < maxI && !m_image->Get(centerJ, i) && stateCount[2] <= maxCount) { - stateCount[2]++; - i++; - } - if (stateCount[2] > maxCount) { - return FXSYS_nan(); - } - int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * abs(stateCountTotal - originalStateCountTotal) >= - originalStateCountTotal) { - return FXSYS_nan(); - } - return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i) - : FXSYS_nan(); -} -CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::HandlePossibleCenter( - const CFX_Int32Array& stateCount, - int32_t i, - int32_t j) { - int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - FX_FLOAT centerJ = CenterFromEnd(stateCount, j); - FX_FLOAT centerI = CrossCheckVertical(i, (int32_t)centerJ, 2 * stateCount[1], - stateCountTotal); - if (!FXSYS_isnan(centerI)) { - FX_FLOAT estimatedModuleSize = - (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]); - if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) { - return new CBC_QRAlignmentPattern(centerJ, centerI, - estimatedModuleSize); - } - } - m_possibleCenters.Add( - new CBC_QRAlignmentPattern(centerJ, centerI, estimatedModuleSize)); - } - return NULL; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h b/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h deleted file mode 100644 index d1fff0aa3c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h +++ /dev/null @@ -1,47 +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_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/utils.h" - -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, - int32_t startY, - int32_t width, - int32_t height, - FX_FLOAT moduleSize); - virtual ~CBC_QRAlignmentPatternFinder(); - FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount); - FX_FLOAT CrossCheckVertical(int32_t startI, - int32_t startJ, - int32_t maxCount, - int32_t originalStateCountTotal); - CBC_QRAlignmentPattern* Find(int32_t& e); - CBC_QRAlignmentPattern* HandlePossibleCenter(const CFX_Int32Array& stateCount, - int32_t i, - int32_t j); - static FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp deleted file mode 100644 index 7426d95d4c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp +++ /dev/null @@ -1,183 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRBitMatrixParser::CBC_QRBitMatrixParser() {} -void CBC_QRBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e) { - m_dimension = bitMatrix->GetDimension(e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - m_tempBitMatrix = bitMatrix; - if (m_dimension < 21 || (m_dimension & 0x03) != 1) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - m_bitMatrix = m_tempBitMatrix; - m_parsedFormatInfo = NULL; - m_version = NULL; -} -CBC_QRBitMatrixParser::~CBC_QRBitMatrixParser() { - delete m_parsedFormatInfo; -} -CBC_QRCoderFormatInformation* CBC_QRBitMatrixParser::ReadFormatInformation( - int32_t& e) { - if (m_parsedFormatInfo) { - return m_parsedFormatInfo; - } - int32_t formatInfoBits = 0; - int32_t j; - for (j = 0; j < 6; j++) { - formatInfoBits = CopyBit(8, j, formatInfoBits); - } - formatInfoBits = CopyBit(8, 7, formatInfoBits); - formatInfoBits = CopyBit(8, 8, formatInfoBits); - formatInfoBits = CopyBit(7, 8, formatInfoBits); - for (int32_t i = 5; i >= 0; i--) { - formatInfoBits = CopyBit(i, 8, formatInfoBits); - } - m_parsedFormatInfo = - CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits); - if (m_parsedFormatInfo) { - return m_parsedFormatInfo; - } - int32_t dimension = m_bitMatrix->GetDimension(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - formatInfoBits = 0; - int32_t iMin = dimension - 8; - for (j = dimension - 1; j >= iMin; j--) { - formatInfoBits = CopyBit(j, 8, formatInfoBits); - } - for (int32_t k = dimension - 7; k < dimension; k++) { - formatInfoBits = CopyBit(8, k, formatInfoBits); - } - m_parsedFormatInfo = - CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits); - if (m_parsedFormatInfo) { - return m_parsedFormatInfo; - } - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return NULL; -} -CBC_QRCoderVersion* CBC_QRBitMatrixParser::ReadVersion(int32_t& e) { - if (m_version) { - return m_version; - } - int32_t dimension = m_bitMatrix->GetDimension(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t provisionVersion = (dimension - 17) >> 2; - if (provisionVersion <= 6) { - CBC_QRCoderVersion* qrv = - CBC_QRCoderVersion::GetVersionForNumber(provisionVersion, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qrv; - } - int32_t versionBits = 0; - for (int32_t i = 5; i >= 0; i--) { - int32_t jMin = dimension - 11; - for (int32_t j = dimension - 9; j >= jMin; j--) { - versionBits = CopyBit(i, j, versionBits); - } - } - m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (m_version && m_version->GetDimensionForVersion() == dimension) { - return m_version; - } - versionBits = 0; - for (int32_t j = 5; j >= 0; j--) { - int32_t iMin = dimension - 11; - for (int32_t i = dimension - 9; i >= iMin; i--) { - versionBits = CopyBit(i, j, versionBits); - } - } - m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (m_version && m_version->GetDimensionForVersion() == dimension) { - return m_version; - } - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return NULL; -} -int32_t CBC_QRBitMatrixParser::CopyBit(int32_t i, - int32_t j, - int32_t versionBits) { - return m_bitMatrix->Get(j, i) ? (versionBits << 1) | 0x1 : versionBits << 1; -} -CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) { - CBC_QRCoderFormatInformation* formatInfo = ReadFormatInformation(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL) CBC_QRCoderVersion* version = - ReadVersion(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRDataMask* dataMask = - CBC_QRDataMask::ForReference((int32_t)(formatInfo->GetDataMask()), 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); - std::unique_ptr<CBC_CommonBitMatrix> functionPattern( - version->BuildFunctionPattern(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - FX_BOOL readingUp = TRUE; - std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray); - result->SetSize(version->GetTotalCodeWords()); - int32_t resultOffset = 0; - int32_t currentByte = 0; - int32_t bitsRead = 0; - for (int32_t j = dimension - 1; j > 0; j -= 2) { - if (j == 6) { - j--; - } - for (int32_t count = 0; count < dimension; count++) { - int32_t i = readingUp ? dimension - 1 - count : count; - for (int32_t col = 0; col < 2; col++) { - if (!functionPattern->Get(j - col, i)) { - bitsRead++; - currentByte <<= 1; - if (m_bitMatrix->Get(j - col, i)) { - currentByte |= 1; - } - if (bitsRead == 8) { - (*result)[resultOffset++] = (uint8_t)currentByte; - bitsRead = 0; - currentByte = 0; - } - } - } - } - readingUp ^= TRUE; - } - if (resultOffset != version->GetTotalCodeWords()) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return result.release(); -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h deleted file mode 100644 index c93be6db9a..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h +++ /dev/null @@ -1,34 +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_SRC_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_QRCoderVersion; -class CBC_QRCoderFormatInformation; - -class CBC_QRBitMatrixParser { - private: - CBC_CommonBitMatrix* m_bitMatrix; - CBC_CommonBitMatrix* m_tempBitMatrix; - CBC_QRCoderVersion* m_version; - CBC_QRCoderFormatInformation* m_parsedFormatInfo; - int32_t m_dimension; - - public: - CBC_QRBitMatrixParser(); - virtual ~CBC_QRBitMatrixParser(); - CBC_QRCoderFormatInformation* ReadFormatInformation(int32_t& e); - CBC_QRCoderVersion* ReadVersion(int32_t& e); - int32_t CopyBit(int32_t i, int32_t j, int32_t versionBits); - CFX_ByteArray* ReadCodewords(int32_t& e); - virtual void Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp deleted file mode 100644 index 896a3a107b..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp +++ /dev/null @@ -1,108 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" - -#include <memory> - -#include "xfa/src/fxbarcode/BC_Binarizer.h" -#include "xfa/src/fxbarcode/BC_BinaryBitmap.h" -#include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" -#include "xfa/src/fxbarcode/BC_LuminanceSource.h" -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" - -CBC_QRCodeReader::CBC_QRCodeReader() : m_decoder(NULL) {} -void CBC_QRCodeReader::Init() { - m_decoder = new CBC_QRCoderDecoder; - m_decoder->Init(); -} -CBC_QRCodeReader::~CBC_QRCodeReader() { - delete m_decoder; -} -CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, - int32_t hints, - int32_t& e) { - CBC_CommonBitMatrix* matrix = image->GetMatrix(e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_QRDetector detector(matrix); - std::unique_ptr<CBC_QRDetectorResult> detectorResult( - detector.Detect(hints, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - std::unique_ptr<CBC_CommonDecoderResult> decodeResult( - m_decoder->Decode(detectorResult->GetBits(), 0, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return (decodeResult->GetText()); -} -CFX_ByteString CBC_QRCodeReader::Decode(const CFX_WideString& filename, - int32_t hints, - int32_t byteModeDecode, - int32_t& e) { - CBC_BufferedImageLuminanceSource source(filename); - source.Init(e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_GlobalHistogramBinarizer binarizer(&source); - CBC_BinaryBitmap bitmap(&binarizer); - CFX_ByteString bs = Decode(&bitmap, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return bs; -} -CFX_ByteString CBC_QRCodeReader::Decode(CFX_DIBitmap* pBitmap, - int32_t hints, - int32_t byteModeDecode, - int32_t& e) { - CBC_BufferedImageLuminanceSource source(pBitmap); - CBC_GlobalHistogramBinarizer binarizer(&source); - CBC_BinaryBitmap bitmap(&binarizer); - CFX_ByteString bs = Decode(&bitmap, hints, e); - BC_EXCEPTION_CHECK_ReturnValue(e, ""); - return bs; -} -CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { - CFX_ByteString bs = Decode(image, 0, e); - BC_EXCEPTION_CHECK_ReturnValue(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; - } - CBC_QRCoderMode::Destroy(); - CBC_QRCoderErrorCorrectionLevel::Destroy(); - CBC_QRDataMask::Destroy(); - CBC_QRCoderVersion::Destroy(); -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h deleted file mode 100644 index 7edb12b937..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h +++ /dev/null @@ -1,40 +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_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ - -#include <stdint.h> - -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fxbarcode/BC_Reader.h" - -class CBC_BinaryBitmap; -class CBC_QRCoderDecoder; -class CFX_DIBitmap; - -class CBC_QRCodeReader : public CBC_Reader { - private: - CBC_QRCoderDecoder* m_decoder; - - public: - CBC_QRCodeReader(); - virtual ~CBC_QRCodeReader(); - CFX_ByteString Decode(CFX_DIBitmap* pBitmap, - int32_t hints, - int32_t byteModeDecode, - int32_t& e); - CFX_ByteString Decode(const CFX_WideString& filename, - int32_t hints, - int32_t byteModeDecode, - int32_t& e); - static void ReleaseAll(); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t hints, int32_t& e); - CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e); - virtual void Init(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.cpp deleted file mode 100644 index e51b9260ef..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.cpp +++ /dev/null @@ -1,107 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_Reader.h" -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" - -CBC_QRCodeWriter::CBC_QRCodeWriter() { - m_bFixedSize = TRUE; - m_iCorrectLevel = 1; - m_iVersion = 0; -} -CBC_QRCodeWriter::~CBC_QRCodeWriter() {} -void CBC_QRCodeWriter::ReleaseAll() { - CBC_QRCodeReader::ReleaseAll(); -} -FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) { - if (version < 0 || version > 40) { - return FALSE; - } - m_iVersion = version; - return TRUE; -} -FX_BOOL CBC_QRCodeWriter::SetErrorCorrectionLevel(int32_t level) { - if (level < 0 || level > 3) { - return FALSE; - } - m_iCorrectLevel = level; - return TRUE; -} -uint8_t* CBC_QRCodeWriter::Encode(const CFX_WideString& contents, - int32_t ecLevel, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - CBC_QRCoderErrorCorrectionLevel* ec = NULL; - switch (ecLevel) { - case 0: - ec = CBC_QRCoderErrorCorrectionLevel::L; - break; - case 1: - ec = CBC_QRCoderErrorCorrectionLevel::M; - break; - case 2: - ec = CBC_QRCoderErrorCorrectionLevel::Q; - break; - case 3: - ec = CBC_QRCoderErrorCorrectionLevel::H; - break; - default: { - e = BCExceptionUnSupportEclevel; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - } - CBC_QRCoder qr; - if (m_iVersion > 0 && m_iVersion < 41) { - CFX_ByteString byteStr = contents.UTF8Encode(); - CBC_QRCoderEncoder::Encode(byteStr, ec, &qr, e, m_iVersion); - } else { - CBC_QRCoderEncoder::Encode(contents, ec, &qr, e); - } - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - outWidth = qr.GetMatrixWidth(); - outHeight = qr.GetMatrixWidth(); - uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); - FXSYS_memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); - return result; -} -uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e) { - return NULL; -} -uint8_t* CBC_QRCodeWriter::Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e) { - return NULL; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h b/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.h deleted file mode 100644 index ceb6547640..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeWriter.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_SRC_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ - -#include "xfa/src/fxbarcode/BC_TwoDimWriter.h" - -class CBC_TwoDimWriter; -class CBC_QRCodeWriter : public CBC_TwoDimWriter { - public: - CBC_QRCodeWriter(); - virtual ~CBC_QRCodeWriter(); - uint8_t* Encode(const CFX_WideString& contents, - int32_t ecLevel, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t hints, - int32_t& e); - uint8_t* Encode(const CFX_ByteString& contents, - BCFORMAT format, - int32_t& outWidth, - int32_t& outHeight, - int32_t& e); - FX_BOOL SetVersion(int32_t version); - FX_BOOL SetErrorCorrectionLevel(int32_t level); - static void ReleaseAll(); - - private: - int32_t m_iVersion; -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEWRITER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoder.cpp deleted file mode 100644 index be46f2dec5..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoder.cpp +++ /dev/null @@ -1,124 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRCoder::CBC_QRCoder() { - m_mode = NULL; - m_ecLevel = NULL; - m_version = -1; - m_matrixWidth = -1; - m_maskPattern = -1; - m_numTotalBytes = -1; - m_numDataBytes = -1; - m_numECBytes = -1; - m_numRSBlocks = -1; - m_matrix = NULL; -} -CBC_QRCoder::~CBC_QRCoder() { - delete m_matrix; -} -CBC_QRCoderMode* CBC_QRCoder::GetMode() { - return m_mode; -} -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() { - return m_ecLevel; -} -int32_t CBC_QRCoder::GetVersion() { - return m_version; -} -int32_t CBC_QRCoder::GetMatrixWidth() { - return m_matrixWidth; -} -int32_t CBC_QRCoder::GetMaskPattern() { - return m_maskPattern; -} -int32_t CBC_QRCoder::GetNumTotalBytes() { - return m_numTotalBytes; -} -int32_t CBC_QRCoder::GetNumDataBytes() { - return m_numDataBytes; -} -int32_t CBC_QRCoder::GetNumECBytes() { - return m_numECBytes; -} -int32_t CBC_QRCoder::GetNumRSBlocks() { - return m_numRSBlocks; -} -CBC_CommonByteMatrix* CBC_QRCoder::GetMatrix() { - return m_matrix; -} -int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { - int32_t value = m_matrix->Get(x, y); - if (!(value == 0 || value == 1)) { - e = BCExceptionValueMustBeEither0or1; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - return value; -} -FX_BOOL CBC_QRCoder::IsValid() { - return m_mode && m_ecLevel && m_version != -1 && m_matrixWidth != -1 && - m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 && - m_numECBytes != -1 && m_numRSBlocks != -1 && - IsValidMaskPattern(m_maskPattern) && - m_numTotalBytes == m_numDataBytes + m_numECBytes && m_matrix && - m_matrixWidth == m_matrix->GetWidth() && - m_matrix->GetWidth() == m_matrix->GetHeight(); -} -void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) { - m_mode = value; -} -void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) { - m_ecLevel = ecLevel; -} -void CBC_QRCoder::SetVersion(int32_t version) { - m_version = version; -} -void CBC_QRCoder::SetMatrixWidth(int32_t width) { - m_matrixWidth = width; -} -void CBC_QRCoder::SetMaskPattern(int32_t pattern) { - m_maskPattern = pattern; -} -void CBC_QRCoder::SetNumDataBytes(int32_t bytes) { - m_numDataBytes = bytes; -} -void CBC_QRCoder::SetNumTotalBytes(int32_t value) { - m_numTotalBytes = value; -} -void CBC_QRCoder::SetNumRSBlocks(int32_t block) { - m_numRSBlocks = block; -} -void CBC_QRCoder::SetNumECBytes(int32_t value) { - m_numECBytes = value; -} -FX_BOOL CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { - return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; -} -void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) { - m_matrix = value; -} -const int32_t CBC_QRCoder::NUM_MASK_PATTERNS = 8; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoder.h deleted file mode 100644 index 6a44b53a6d..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoder.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_SRC_FXBARCODE_QRCODE_BC_QRCODER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODER_H_ - -class CBC_QRCoderErrorCorrectionLevel; -class CBC_QRCoderMode; -class CBC_CommonByteMatrix; - -class CBC_QRCoder { - private: - CBC_QRCoderMode* m_mode; - CBC_QRCoderErrorCorrectionLevel* m_ecLevel; - int32_t m_version; - int32_t m_matrixWidth; - int32_t m_maskPattern; - int32_t m_numTotalBytes; - int32_t m_numDataBytes; - int32_t m_numECBytes; - int32_t m_numRSBlocks; - CBC_CommonByteMatrix* m_matrix; - - public: - static const int32_t NUM_MASK_PATTERNS; - CBC_QRCoder(); - virtual ~CBC_QRCoder(); - CBC_QRCoderMode* GetMode(); - CBC_QRCoderErrorCorrectionLevel* GetECLevel(); - int32_t GetVersion(); - int32_t GetMatrixWidth(); - int32_t GetMaskPattern(); - int32_t GetNumTotalBytes(); - int32_t GetNumDataBytes(); - int32_t GetNumECBytes(); - int32_t GetNumRSBlocks(); - CBC_CommonByteMatrix* GetMatrix(); - int32_t At(int32_t x, int32_t y, int32_t& e); - FX_BOOL IsValid(); - - void SetMode(CBC_QRCoderMode* value); - void SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel); - void SetVersion(int32_t version); - void SetMatrixWidth(int32_t width); - void SetMaskPattern(int32_t pattern); - void SetNumDataBytes(int32_t bytes); - void SetNumTotalBytes(int32_t value); - void SetNumECBytes(int32_t value); - void SetNumRSBlocks(int32_t block); - void SetMatrix(CBC_CommonByteMatrix* value); - static FX_BOOL IsValidMaskPattern(int32_t maskPattern); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.cpp deleted file mode 100644 index ad1b3200ab..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.cpp +++ /dev/null @@ -1,124 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/include/fxcrt/fx_memory.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRCoderBitVector::CBC_QRCoderBitVector() { - m_sizeInBits = 0; - m_size = 32; -} -void CBC_QRCoderBitVector::Init() { - m_array = FX_Alloc(uint8_t, m_size); -} -CBC_QRCoderBitVector::~CBC_QRCoderBitVector() { - FX_Free(m_array); -} -void CBC_QRCoderBitVector::Clear() { - FX_Free(m_array); - m_sizeInBits = 0; - m_size = 32; - m_array = FX_Alloc(uint8_t, m_size); -} -int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) { - if (index < 0 || index >= m_sizeInBits) { - e = BCExceptionBadIndexException; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - int32_t value = m_array[index >> 3] & 0xff; - return (value >> (7 - (index & 0x7))) & 1; -} -int32_t CBC_QRCoderBitVector::sizeInBytes() { - return (m_sizeInBits + 7) >> 3; -} -int32_t CBC_QRCoderBitVector::Size() { - return m_sizeInBits; -} -void CBC_QRCoderBitVector::AppendBit(int32_t bit, int32_t& e) { - if (!(bit == 0 || bit == 1)) { - e = BCExceptionBadValueException; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t numBitsInLastByte = m_sizeInBits & 0x7; - if (numBitsInLastByte == 0) { - AppendByte(0); - m_sizeInBits -= 8; - } - m_array[m_sizeInBits >> 3] |= (bit << (7 - numBitsInLastByte)); - ++m_sizeInBits; -} -void CBC_QRCoderBitVector::AppendBits(int32_t value, - int32_t numBits, - int32_t& e) { - if (numBits < 0 || numBits > 32) { - e = BCExceptionBadNumBitsException; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t numBitsLeft = numBits; - while (numBitsLeft > 0) { - if ((m_sizeInBits & 0x7) == 0 && numBitsLeft >= 8) { - int32_t newByte = (value >> (numBitsLeft - 8)) & 0xff; - AppendByte(newByte); - numBitsLeft -= 8; - } else { - int32_t bit = (value >> (numBitsLeft - 1)) & 1; - AppendBit(bit, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - --numBitsLeft; - } - } -} -void CBC_QRCoderBitVector::AppendBitVector(CBC_QRCoderBitVector* bits, - int32_t& e) { - int32_t size = bits->Size(); - for (int32_t i = 0; i < size; i++) { - int32_t num = bits->At(i, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendBit(num, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) - } -} -void CBC_QRCoderBitVector::XOR(CBC_QRCoderBitVector* other, int32_t& e) { - if (m_sizeInBits != other->Size()) { - e = BCExceptioncanNotOperatexorOperator; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t sizeInBytes = (m_sizeInBits + 7) >> 3; - for (int32_t i = 0; i < sizeInBytes; ++i) { - m_array[i] ^= (other->GetArray())[i]; - } -} -uint8_t* CBC_QRCoderBitVector::GetArray() { - return m_array; -} -void CBC_QRCoderBitVector::AppendByte(int32_t value) { - if ((m_sizeInBits >> 3) == m_size) { - uint8_t* newArray = FX_Alloc(uint8_t, m_size << 1); - FXSYS_memcpy(newArray, m_array, m_size); - FX_Free(m_array); - m_array = newArray; - m_size = m_size << 1; - } - m_array[m_sizeInBits >> 3] = (uint8_t)value; - m_sizeInBits += 8; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h deleted file mode 100644 index 86c40527a1..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.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_SRC_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ - -#include <stdint.h> - -class CBC_QRCoderBitVector { - private: - int32_t m_sizeInBits; - uint8_t* m_array; - int32_t m_size; - - void AppendByte(int32_t value); - - public: - CBC_QRCoderBitVector(); - virtual ~CBC_QRCoderBitVector(); - int32_t At(int32_t index, int32_t& e); - int32_t Size(); - int32_t sizeInBytes(); - void AppendBit(int32_t bit, int32_t& e); - void AppendBits(int32_t value, int32_t numBits, int32_t& e); - void AppendBitVector(CBC_QRCoderBitVector* bits, int32_t& e); - void XOR(CBC_QRCoderBitVector* other, int32_t& e); - uint8_t* GetArray(); - void Clear(); - virtual void Init(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERBITVECTOR_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp deleted file mode 100644 index b9accd6097..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.cpp +++ /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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h" - -CBC_QRCoderBlockPair::CBC_QRCoderBlockPair( - CBC_CommonByteArray* data, - CBC_CommonByteArray* errorCorrection) { - m_dataBytes = data; - m_errorCorrectionBytes = errorCorrection; -} -CBC_QRCoderBlockPair::~CBC_QRCoderBlockPair() { - delete m_dataBytes; - delete m_errorCorrectionBytes; -} -CBC_CommonByteArray* CBC_QRCoderBlockPair::GetDataBytes() { - return m_dataBytes; -} -CBC_CommonByteArray* CBC_QRCoderBlockPair::GetErrorCorrectionBytes() { - return m_errorCorrectionBytes; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h deleted file mode 100644 index 30551fe610..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ - -class CBC_CommonByteArray; -class CBC_QRCoderBlockPair { - private: - CBC_CommonByteArray* m_dataBytes; - CBC_CommonByteArray* m_errorCorrectionBytes; - - public: - CBC_QRCoderBlockPair(CBC_CommonByteArray* data, - CBC_CommonByteArray* errorCorrection); - virtual ~CBC_QRCoderBlockPair(); - - CBC_CommonByteArray* GetDataBytes(); - CBC_CommonByteArray* GetErrorCorrectionBytes(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERBLOCKPAIR_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp deleted file mode 100644 index dd310217d4..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp +++ /dev/null @@ -1,129 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" - -CBC_QRCoderDecoder::CBC_QRCoderDecoder() { - m_rsDecoder = NULL; -} - -void CBC_QRCoderDecoder::Init() { - m_rsDecoder = new CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::QRCodeFild); -} -CBC_QRCoderDecoder::~CBC_QRCoderDecoder() { - delete m_rsDecoder; -} -CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(FX_BOOL* image, - int32_t width, - int32_t height, - int32_t& e) { - CBC_CommonBitMatrix bits; - bits.Init(width); - for (int32_t i = 0; i < width; i++) { - for (int32_t j = 0; j < height; j++) { - if (image[i * width + j]) { - bits.Set(j, i); - } - } - } - CBC_CommonDecoderResult* cdr = Decode(&bits, height, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return cdr; -} -CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits, - int32_t byteModeDecode, - int32_t& e) { - CBC_QRBitMatrixParser parser; - parser.Init(bits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRCoderVersion* version = parser.ReadVersion(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRCoderFormatInformation* temp = parser.ReadFormatInformation(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel(); - std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CFX_PtrArray* 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(); - } - CFX_ByteArray resultBytes; - for (int32_t j = 0; j < dataBlocks->GetSize(); j++) { - CBC_QRDataBlock* dataBlock = (CBC_QRDataBlock*)((*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]; - } - dataBlocks->RemoveAll(); - delete dataBlocks; - dataBlocks = NULL; - return NULL; - } - for (int32_t i = 0; i < numDataCodewords; i++) { - resultBytes.Add((*codewordBytes)[i]); - } - } - for (int32_t k = 0; k < dataBlocks->GetSize(); k++) { - delete (CBC_QRDataBlock*)(*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); - return cdr; -} -void CBC_QRCoderDecoder::CorrectErrors(CFX_ByteArray* codewordBytes, - int32_t numDataCodewords, - int32_t& e) { - int32_t numCodewords = codewordBytes->GetSize(); - CFX_Int32Array codewordsInts; - codewordsInts.SetSize(numCodewords); - for (int32_t i = 0; i < numCodewords; i++) { - codewordsInts[i] = (int32_t)((*codewordBytes)[i] & 0xff); - } - int32_t numECCodewords = codewordBytes->GetSize() - numDataCodewords; - m_rsDecoder->Decode(&codewordsInts, numECCodewords, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - for (int32_t k = 0; k < numDataCodewords; k++) { - (*codewordBytes)[k] = (uint8_t)codewordsInts[k]; - } -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h deleted file mode 100644 index e2e53a796c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.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_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_ReedSolomonDecoder; -class CBC_CommonDecoderResult; - -class CBC_QRCoderDecoder { - private: - CBC_ReedSolomonDecoder* m_rsDecoder; - - public: - CBC_QRCoderDecoder(); - virtual ~CBC_QRCoderDecoder(); - - CBC_CommonDecoderResult* Decode(FX_BOOL* image, - int32_t width, - int32_t height, - int32_t& e); - CBC_CommonDecoderResult* Decode(CBC_CommonBitMatrix* bits, - int32_t byteModeDecode, - int32_t& e); - void CorrectErrors(CFX_ByteArray* codewordBytes, - int32_t numDataCodewords, - int32_t& e); - virtual void Init(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.cpp deleted file mode 100644 index 4dc394daae..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" - -CBC_QRCoderECB::CBC_QRCoderECB(int32_t count, int32_t dataCodeWords) { - m_dataCodeWords = dataCodeWords; - m_count = count; -} -CBC_QRCoderECB::~CBC_QRCoderECB() {} -int32_t CBC_QRCoderECB::GetCount() { - return m_count; -} -int32_t CBC_QRCoderECB::GetDataCodeWords() { - return m_dataCodeWords; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h deleted file mode 100644 index c269e38093..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderECB.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_SRC_FXBARCODE_QRCODE_BC_QRCODERECB_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERECB_H_ - -#include <stdint.h> - -class CBC_QRCoderECB { - private: - int32_t m_count; - int32_t m_dataCodeWords; - - public: - CBC_QRCoderECB(int32_t count, int32_t dataCodeWords); - virtual ~CBC_QRCoderECB(); - int32_t GetCount(); - int32_t GetDataCodeWords(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERECB_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp deleted file mode 100644 index c418651483..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp +++ /dev/null @@ -1,59 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" - -CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock, - CBC_QRCoderECB* ecBlocks) { - m_ecCodeWordsPerBlock = ecCodeWordsPerBlock; - m_ecBlocks.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_QRCoderECBlocks::~CBC_QRCoderECBlocks() { - for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { - delete ((CBC_QRCoderECB*)(m_ecBlocks[i])); - } - m_ecBlocks.RemoveAll(); -} -int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() { - return m_ecCodeWordsPerBlock; -} -int32_t CBC_QRCoderECBlocks::GetNumBlocks() { - int32_t total = 0; - for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { - total += ((CBC_QRCoderECB*)(m_ecBlocks[i]))->GetCount(); - } - return total; -} -int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() { - return m_ecCodeWordsPerBlock * GetNumBlocks(); -} -CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks() { - return &m_ecBlocks; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h deleted file mode 100644 index 7d25eee42b..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.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_SRC_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ - -#include "core/include/fxcrt/fx_basic.h" - -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(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp deleted file mode 100644 index eb31ddc301..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ /dev/null @@ -1,961 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" - -#include <algorithm> -#include <memory> - -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" - -const int32_t CBC_QRCoderEncoder::m_alphaNumbericTable[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1}; - -CBC_QRCoderEncoder::CBC_QRCoderEncoder() {} -CBC_QRCoderEncoder::~CBC_QRCoderEncoder() {} -class Make_Pair { - public: - CBC_QRCoderMode* m_mode; - CFX_ByteString m_string; - - private: - Make_Pair(const Make_Pair& mode_string) {} - Make_Pair& operator=(Make_Pair& mode_string) { - if (this == &mode_string) { - return *this; - } - m_mode = mode_string.m_mode; - m_string = mode_string.m_string; - return *this; - } - - public: - Make_Pair(CBC_QRCoderMode* mode, const CFX_ByteString& str) - : m_mode(mode), m_string(str) {} - ~Make_Pair() {} -}; -void CBC_QRCoderEncoder::Encode(const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e, - int32_t versionSpecify) { - if (versionSpecify == 0) { - EncodeWithAutoVersion(content, ecLevel, qrCode, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) - } else if (versionSpecify > 0 && versionSpecify <= 40) { - EncodeWithSpecifyVersion(content, ecLevel, qrCode, versionSpecify, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else { - e = BCExceptionVersionMust1_40; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::AppendECI(CBC_QRCoderBitVector* bits) {} -void CBC_QRCoderEncoder::AppendDataModeLenghInfo( - CFX_PtrArray& splitResult, - CBC_QRCoderBitVector& headerAndDataBits, - CBC_QRCoderMode* tempMode, - CBC_QRCoder* qrCode, - CFX_ByteString& encoding, - int32_t& e) { - for (int32_t i = 0; i < splitResult.GetSize(); i++) { - tempMode = ((Make_Pair*)splitResult[i])->m_mode; - if (tempMode == CBC_QRCoderMode::sGBK) { - AppendModeInfo(tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), - qrCode->GetVersion(), tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, - &headerAndDataBits, encoding, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (tempMode == CBC_QRCoderMode::sBYTE) { - CFX_ByteArray bytes; - CBC_UtilCodingConvert::LocaleToUtf8( - ((Make_Pair*)splitResult[i])->m_string, bytes); - AppendModeInfo(tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendLengthInfo(bytes.GetSize(), qrCode->GetVersion(), tempMode, - &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - Append8BitBytes(bytes, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (tempMode == CBC_QRCoderMode::sALPHANUMERIC) { - AppendModeInfo(tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), - qrCode->GetVersion(), tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, - &headerAndDataBits, encoding, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (tempMode == CBC_QRCoderMode::sNUMERIC) { - AppendModeInfo(tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendLengthInfo(((Make_Pair*)splitResult[i])->m_string.GetLength(), - qrCode->GetVersion(), tempMode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - AppendBytes(((Make_Pair*)splitResult[i])->m_string, tempMode, - &headerAndDataBits, encoding, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else { - e = BCExceptionUnknown; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } -} -void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content, - CFX_PtrArray& result) { - int32_t index = 0, flag = 0; - while ( - (((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || - ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && - (index < content.GetLength())) { - index += 2; - } - if (index != flag) { - result.Add( - new Make_Pair(CBC_QRCoderMode::sGBK, content.Mid(flag, index - flag))); - } - flag = index; - if (index >= content.GetLength()) { - return; - } - while ( - GetAlphaNumericCode((uint8_t)content[index]) == -1 && - !(((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) || - ((uint8_t)content[index] >= 0xB0 && (uint8_t)content[index] <= 0xFA)) && - (index < content.GetLength())) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - if (IsDBCSLeadByte((uint8_t)content[index])) -#else - if ((uint8_t)content[index] > 127) -#endif - { - index += 2; - } else { - index++; - } - } - if (index != flag) { - result.Add( - new Make_Pair(CBC_QRCoderMode::sBYTE, content.Mid(flag, index - flag))); - } - flag = index; - if (index >= content.GetLength()) { - return; - } - while (FXSYS_Isdigit((uint8_t)content[index]) && - (index < content.GetLength())) { - index++; - } - if (index != flag) { - result.Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC, - content.Mid(flag, index - flag))); - } - flag = index; - if (index >= content.GetLength()) { - return; - } - while (GetAlphaNumericCode((uint8_t)content[index]) != -1 && - (index < content.GetLength())) { - index++; - } - if (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); -} -int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst, - CBC_QRCoderMode* modeSecond, - int32_t versionNum, - int32_t& e) { - if (versionNum == 0) { - return 0; - } - if ((modeFirst == CBC_QRCoderMode::sALPHANUMERIC) && - (modeSecond == CBC_QRCoderMode::sBYTE)) { - if (versionNum >= 1 && versionNum <= 9) { - return 11; - } else if (versionNum >= 10 && versionNum <= 26) { - return 15; - } else if (versionNum >= 27 && versionNum <= 40) { - return 16; - } else { - e = BCExceptionNoSuchVersion; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - } else if ((modeSecond == CBC_QRCoderMode::sALPHANUMERIC) && - (modeFirst == CBC_QRCoderMode::sNUMERIC)) { - if (versionNum >= 1 && versionNum <= 9) { - return 13; - } else if (versionNum >= 10 && versionNum <= 26) { - return 15; - } else if (versionNum >= 27 && versionNum <= 40) { - return 17; - } else { - e = BCExceptionNoSuchVersion; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - } else if ((modeSecond == CBC_QRCoderMode::sBYTE) && - (modeFirst == CBC_QRCoderMode::sNUMERIC)) { - if (versionNum >= 1 && versionNum <= 9) { - return 6; - } else if (versionNum >= 10 && versionNum <= 26) { - return 8; - } else if (versionNum >= 27 && versionNum <= 40) { - return 9; - } else { - e = BCExceptionNoSuchVersion; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - } - return -1; -} -void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& 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]; - if (first->m_mode == CBC_QRCoderMode::sALPHANUMERIC) { - int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC, - CBC_QRCoderMode::sBYTE, versionNum, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if ((second->m_mode == CBC_QRCoderMode::sBYTE) && - (first->m_string.GetLength() < tmp)) { - CFX_ByteString str = first->m_string + second->m_string; - second->m_string = str; - delete first; - result.RemoveAt(i); - i--; - mergeNum++; - } - } else if (first->m_mode == CBC_QRCoderMode::sBYTE) { - if (second->m_mode == CBC_QRCoderMode::sBYTE) { - first->m_string += second->m_string; - delete second; - result.RemoveAt(i + 1); - i--; - mergeNum++; - } - } else if (first->m_mode == CBC_QRCoderMode::sNUMERIC) { - int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC, - CBC_QRCoderMode::sBYTE, versionNum, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if ((second->m_mode == CBC_QRCoderMode::sBYTE) && - (first->m_string.GetLength() < tmp)) { - CFX_ByteString str = first->m_string + second->m_string; - second->m_string = str; - delete first; - result.RemoveAt(i); - i--; - mergeNum++; - } - tmp = GetSpanByVersion(CBC_QRCoderMode::sNUMERIC, - CBC_QRCoderMode::sALPHANUMERIC, versionNum, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if ((second->m_mode == CBC_QRCoderMode::sALPHANUMERIC) && - (first->m_string.GetLength() < tmp)) { - CFX_ByteString str = first->m_string + second->m_string; - second->m_string = str; - delete first; - result.RemoveAt(i); - i--; - mergeNum++; - } - } - } - if (mergeNum == 0) { - return; - } - MergeString(result, versionNum, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, - int32_t versionNumber, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoderMode* mode, - CBC_QRCoder* qrCode, - int32_t& e) { - qrCode->SetECLevel(ecLevel); - qrCode->SetMode(mode); - CBC_QRCoderVersion* version = - CBC_QRCoderVersion::GetVersionForNumber(versionNumber, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t numBytes = version->GetTotalCodeWords(); - CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); - int32_t numEcBytes = ecBlocks->GetTotalECCodeWords(); - int32_t numRSBlocks = ecBlocks->GetNumBlocks(); - int32_t numDataBytes = numBytes - numEcBytes; - if (numDataBytes >= numInputBytes + 3) { - qrCode->SetVersion(versionNumber); - qrCode->SetNumTotalBytes(numBytes); - qrCode->SetNumDataBytes(numDataBytes); - qrCode->SetNumRSBlocks(numRSBlocks); - qrCode->SetNumECBytes(numEcBytes); - qrCode->SetMatrixWidth(version->GetDimensionForVersion()); - return; - } - e = BCExceptionCannotFindBlockInfo; - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderEncoder::EncodeWithSpecifyVersion( - const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t versionSpecify, - int32_t& e) { - CFX_ByteString encoding = "utf8"; - CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; - CFX_PtrArray splitResult; - CBC_QRCoderBitVector dataBits; - dataBits.Init(); - 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); - if (e != BCExceptionNO) { - for (int32_t y = 0; y < splitResult.GetSize(); y++) { - delete (Make_Pair*)splitResult[y]; - } - splitResult.RemoveAll(); - return; - } - } - int32_t numInputBytes = dataBits.sizeInBytes(); - CBC_QRCoderBitVector headerAndDataBits; - 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(); - 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(); - 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]; - } - splitResult.RemoveAll(); - CBC_QRCoderBitVector finalBits; - finalBits.Init(); - InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), - qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), - &finalBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); - matrix->Init(); - int32_t maskPattern = ChooseMaskPattern( - &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - qrCode->SetMaskPattern(maskPattern); - CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), - qrCode->GetVersion(), - qrCode->GetMaskPattern(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - qrCode->SetMatrix(matrix.release()); - if (!qrCode->IsValid()) { - e = BCExceptionInvalidQRCode; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::EncodeWithAutoVersion( - const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e) { - CFX_ByteString encoding = "utf8"; - CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE; - CFX_PtrArray splitResult; - CBC_QRCoderBitVector dataBits; - dataBits.Init(); - 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); - if (e != BCExceptionNO) { - for (int32_t l = 0; l < splitResult.GetSize(); l++) { - delete (Make_Pair*)splitResult[l]; - } - splitResult.RemoveAll(); - return; - } - } - int32_t numInputBytes = dataBits.sizeInBytes(); - InitQRCode(numInputBytes, ecLevel, mode, qrCode, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderBitVector headerAndDataBits; - headerAndDataBits.Init(); - tempMode = NULL; - int32_t versionNum = qrCode->GetVersion(); -sign: - AppendDataModeLenghInfo(splitResult, headerAndDataBits, tempMode, qrCode, - encoding, e); - if (e != BCExceptionNO) { - goto catchException; - } - numInputBytes = headerAndDataBits.sizeInBytes(); - TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); - if (e != BCExceptionNO) { - goto catchException; - } -catchException: - if (e != BCExceptionNO) { - int32_t e1 = BCExceptionNO; - InitQRCode(numInputBytes, ecLevel, mode, qrCode, e1); - if (e1 != BCExceptionNO) { - e = e1; - return; - } - versionNum++; - if (versionNum <= 40) { - headerAndDataBits.Clear(); - e = BCExceptionNO; - goto sign; - } else { - for (int32_t j = 0; j < splitResult.GetSize(); j++) { - delete (Make_Pair*)splitResult[j]; - } - splitResult.RemoveAll(); - return; - } - } - for (int32_t k = 0; k < splitResult.GetSize(); k++) { - delete (Make_Pair*)splitResult[k]; - } - splitResult.RemoveAll(); - CBC_QRCoderBitVector finalBits; - finalBits.Init(); - InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), - qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), - &finalBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); - matrix->Init(); - int32_t maskPattern = ChooseMaskPattern( - &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - qrCode->SetMaskPattern(maskPattern); - CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), - qrCode->GetVersion(), - qrCode->GetMaskPattern(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(matrix.release()); - if (!qrCode->IsValid()) { - e = BCExceptionInvalidQRCode; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e) { - CFX_ByteString encoding = "utf8"; - CFX_ByteString utf8Data; - CBC_UtilCodingConvert::UnicodeToUTF8(content, utf8Data); - CBC_QRCoderMode* mode = ChooseMode(utf8Data, encoding); - CBC_QRCoderBitVector dataBits; - dataBits.Init(); - AppendBytes(utf8Data, mode, &dataBits, encoding, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t numInputBytes = dataBits.sizeInBytes(); - InitQRCode(numInputBytes, ecLevel, mode, qrCode, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_QRCoderBitVector headerAndDataBits; - headerAndDataBits.Init(); - AppendModeInfo(mode, &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t numLetters = mode == CBC_QRCoderMode::sBYTE ? dataBits.sizeInBytes() - : content.GetLength(); - AppendLengthInfo(numLetters, qrCode->GetVersion(), mode, &headerAndDataBits, - e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - headerAndDataBits.AppendBitVector(&dataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) - TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_QRCoderBitVector finalBits; - finalBits.Init(); - InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(), - qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), - &finalBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - std::unique_ptr<CBC_CommonByteMatrix> matrix(new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); - matrix->Init(); - int32_t maskPattern = ChooseMaskPattern( - &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - qrCode->SetMaskPattern(maskPattern); - CBC_QRCoderMatrixUtil::BuildMatrix(&finalBits, qrCode->GetECLevel(), - qrCode->GetVersion(), - qrCode->GetMaskPattern(), matrix.get(), e); - BC_EXCEPTION_CHECK_ReturnVoid(e) qrCode->SetMatrix(matrix.release()); - if (!qrCode->IsValid()) { - e = BCExceptionInvalidQRCode; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::TerminateBits(int32_t numDataBytes, - CBC_QRCoderBitVector* bits, - int32_t& e) { - int32_t capacity = numDataBytes << 3; - if (bits->Size() > capacity) { - e = BCExceptionDataTooMany; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t i = 0; i < 4 && bits->Size() < capacity; ++i) { - bits->AppendBit(0, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t numBitsInLastByte = bits->Size() % 8; - if (numBitsInLastByte > 0) { - int32_t numPaddingBits = 8 - numBitsInLastByte; - for (int32_t j = 0; j < numPaddingBits; ++j) { - bits->AppendBit(0, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) - } - } - if (bits->Size() % 8 != 0) { - e = BCExceptionDigitLengthMustBe8; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t numPaddingBytes = numDataBytes - bits->sizeInBytes(); - for (int32_t k = 0; k < numPaddingBytes; ++k) { - if (k % 2 == 0) { - bits->AppendBits(0xec, 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else { - bits->AppendBits(0x11, 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } - if (bits->Size() != capacity) { - e = BCExceptionBitsNotEqualCacity; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -int32_t CBC_QRCoderEncoder::ChooseMaskPattern( - CBC_QRCoderBitVector* bits, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - int32_t minPenalty = 65535; - int32_t bestMaskPattern = -1; - for (int32_t maskPattern = 0; maskPattern < CBC_QRCoder::NUM_MASK_PATTERNS; - maskPattern++) { - CBC_QRCoderMatrixUtil::BuildMatrix(bits, ecLevel, version, maskPattern, - matrix, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - int32_t penalty = CalculateMaskPenalty(matrix); - if (penalty < minPenalty) { - minPenalty = penalty; - bestMaskPattern = maskPattern; - } - } - return bestMaskPattern; -} -int32_t CBC_QRCoderEncoder::CalculateMaskPenalty(CBC_CommonByteMatrix* matrix) { - int32_t penalty = 0; - penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1(matrix); - penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2(matrix); - penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(matrix); - penalty += CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(matrix); - return penalty; -} -CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, - CFX_ByteString encoding) { - if (encoding.Compare("SHIFT_JIS") == 0) { - return CBC_QRCoderMode::sKANJI; - } - FX_BOOL hasNumeric = FALSE; - FX_BOOL hasAlphaNumeric = FALSE; - for (int32_t i = 0; i < content.GetLength(); i++) { - if (isdigit((uint8_t)content[i])) { - hasNumeric = TRUE; - } else if (GetAlphaNumericCode((uint8_t)content[i]) != -1) { - hasAlphaNumeric = TRUE; - } else { - return CBC_QRCoderMode::sBYTE; - } - } - if (hasAlphaNumeric) { - return CBC_QRCoderMode::sALPHANUMERIC; - } else if (hasNumeric) { - return CBC_QRCoderMode::sNUMERIC; - } - return CBC_QRCoderMode::sBYTE; -} -int32_t CBC_QRCoderEncoder::GetAlphaNumericCode(int32_t code) { - if (code < 96 && code >= 0) { - return m_alphaNumbericTable[code]; - } - return -1; -} -void CBC_QRCoderEncoder::AppendBytes(const CFX_ByteString& content, - CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - CFX_ByteString encoding, - int32_t& e) { - if (mode == CBC_QRCoderMode::sNUMERIC) { - AppendNumericBytes(content, bits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) { - AppendAlphaNumericBytes(content, bits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (mode == CBC_QRCoderMode::sBYTE) { - Append8BitBytes(content, bits, encoding, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (mode == CBC_QRCoderMode::sKANJI) { - AppendKanjiBytes(content, bits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else if (mode == CBC_QRCoderMode::sGBK) { - AppendGBKBytes(content, bits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } else { - e = BCExceptionUnsupportedMode; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::AppendNumericBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e) { - int32_t length = content.GetLength(); - int32_t i = 0; - while (i < length) { - int32_t num1 = content[i] - '0'; - if (i + 2 < length) { - int32_t num2 = content[i + 1] - '0'; - int32_t num3 = content[i + 2] - '0'; - bits->AppendBits(num1 * 100 + num2 * 10 + num3, 10, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) i += 3; - } else if (i + 1 < length) { - int32_t num2 = content[i + 1] - '0'; - bits->AppendBits(num1 * 10 + num2, 7, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) i += 2; - } else { - bits->AppendBits(num1, 4, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - i++; - } - } -} -void CBC_QRCoderEncoder::AppendAlphaNumericBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e) { - int32_t length = content.GetLength(); - int32_t i = 0; - while (i < length) { - int32_t code1 = GetAlphaNumericCode(content[i]); - if (code1 == -1) { - e = BCExceptionInvalidateCharacter; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (i + 1 < length) { - int32_t code2 = GetAlphaNumericCode(content[i + 1]); - if (code2 == -1) { - e = BCExceptionInvalidateCharacter; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - bits->AppendBits(code1 * 45 + code2, 11, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - i += 2; - } else { - bits->AppendBits(code1, 6, e); - BC_EXCEPTION_CHECK_ReturnVoid(e) i++; - } - } -} -void CBC_QRCoderEncoder::AppendGBKBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e) { - int32_t length = content.GetLength(); - FX_DWORD value = 0; - for (int32_t i = 0; i < length; i += 2) { - value = (FX_DWORD)((uint8_t)content[i] << 8 | (uint8_t)content[i + 1]); - if (value <= 0xAAFE && value >= 0xA1A1) { - value -= 0xA1A1; - } else if (value <= 0xFAFE && value >= 0xB0A1) { - value -= 0xA6A1; - } else { - e = BCExceptionInvalidateCharacter; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - value = (FX_DWORD)((value >> 8) * 0x60) + (FX_DWORD)(value & 0xff); - bits->AppendBits(value, 13, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::Append8BitBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - CFX_ByteString encoding, - int32_t& e) { - for (int32_t i = 0; i < content.GetLength(); i++) { - bits->AppendBits(content[i], 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::Append8BitBytes(CFX_ByteArray& bytes, - CBC_QRCoderBitVector* bits, - int32_t& e) { - for (int32_t i = 0; i < bytes.GetSize(); i++) { - bits->AppendBits(bytes[i], 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::AppendKanjiBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e) { - CFX_ByteArray bytes; - FX_DWORD value = 0; - for (int32_t i = 0; i < bytes.GetSize(); i += 2) { - value = (FX_DWORD)((uint8_t)(content[i] << 8) | (uint8_t)content[i + 1]); - if (value <= 0x9ffc && value >= 0x8140) { - value -= 0x8140; - } else if (value <= 0xebbf && value >= 0xe040) { - value -= 0xc140; - } else { - e = BCExceptionInvalidateCharacter; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - value = (FX_DWORD)((value >> 8) * 0xc0) + (FX_DWORD)(value & 0xff); - bits->AppendBits(value, 13, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::InitQRCode(int32_t numInputBytes, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoderMode* mode, - CBC_QRCoder* qrCode, - int32_t& e) { - qrCode->SetECLevel(ecLevel); - qrCode->SetMode(mode); - for (int32_t versionNum = 1; versionNum <= 40; versionNum++) { - CBC_QRCoderVersion* version = - CBC_QRCoderVersion::GetVersionForNumber(versionNum, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t numBytes = version->GetTotalCodeWords(); - CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); - int32_t numEcBytes = ecBlocks->GetTotalECCodeWords(); - int32_t numRSBlocks = ecBlocks->GetNumBlocks(); - int32_t numDataBytes = numBytes - numEcBytes; - if (numDataBytes >= numInputBytes + 3) { - qrCode->SetVersion(versionNum); - qrCode->SetNumTotalBytes(numBytes); - qrCode->SetNumDataBytes(numDataBytes); - qrCode->SetNumRSBlocks(numRSBlocks); - qrCode->SetNumECBytes(numEcBytes); - qrCode->SetMatrixWidth(version->GetDimensionForVersion()); - return; - } - } - e = BCExceptionCannotFindBlockInfo; - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderEncoder::AppendModeInfo(CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - int32_t& e) { - bits->AppendBits(mode->GetBits(), 4, e); - if (mode == CBC_QRCoderMode::sGBK) { - bits->AppendBits(1, 4, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::AppendLengthInfo(int32_t numLetters, - int32_t version, - CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - int32_t& e) { - CBC_QRCoderVersion* qcv = CBC_QRCoderVersion::GetVersionForNumber(version, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t numBits = mode->GetCharacterCountBits(qcv, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (numBits > ((1 << numBits) - 1)) { - return; - } - if (mode == CBC_QRCoderMode::sGBK) { - bits->AppendBits(numLetters / 2, numBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - bits->AppendBits(numLetters, numBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits, - int32_t numTotalBytes, - int32_t numDataBytes, - int32_t numRSBlocks, - CBC_QRCoderBitVector* result, - int32_t& e) { - if (bits->sizeInBytes() != numDataBytes) { - e = BCExceptionBitsBytesNotMatch; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t dataBytesOffset = 0; - int32_t maxNumDataBytes = 0; - int32_t maxNumEcBytes = 0; - CFX_PtrArray blocks; - int32_t i; - for (i = 0; i < numRSBlocks; i++) { - int32_t numDataBytesInBlock; - int32_t numEcBytesInBlosk; - GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, - numRSBlocks, i, numDataBytesInBlock, - numEcBytesInBlosk); - CBC_CommonByteArray* dataBytes = new CBC_CommonByteArray; - dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); - CBC_CommonByteArray* ecBytes = - GenerateECBytes(dataBytes, numEcBytesInBlosk, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - blocks.Add(new CBC_QRCoderBlockPair(dataBytes, ecBytes)); - maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); - maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); - dataBytesOffset += numDataBytesInBlock; - } - if (numDataBytes != dataBytesOffset) { - e = BCExceptionBytesNotMatchOffset; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - 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(); - if (x < dataBytes->Size()) { - result->AppendBits(dataBytes->At(x), 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } - } - 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(); - if (y < ecBytes->Size()) { - result->AppendBits(ecBytes->At(y), 8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } - } - for (int32_t k = 0; k < blocks.GetSize(); k++) { - delete (CBC_QRCoderBlockPair*)blocks[k]; - } - if (numTotalBytes != result->sizeInBytes()) { - e = BCExceptionSizeInBytesDiffer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderEncoder::GetNumDataBytesAndNumECBytesForBlockID( - int32_t numTotalBytes, - int32_t numDataBytes, - int32_t numRSBlocks, - int32_t blockID, - int32_t& numDataBytesInBlock, - int32_t& numECBytesInBlock) { - if (blockID >= numRSBlocks) { - return; - } - int32_t numRsBlocksInGroup2 = numTotalBytes % numRSBlocks; - int32_t numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2; - int32_t numTotalBytesInGroup1 = numTotalBytes / numRSBlocks; - int32_t numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1; - int32_t numDataBytesInGroup1 = numDataBytes / numRSBlocks; - int32_t numDataBytesInGroup2 = numDataBytesInGroup1 + 1; - int32_t numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1; - int32_t numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2; - if (blockID < numRsBlocksInGroup1) { - numDataBytesInBlock = numDataBytesInGroup1; - numECBytesInBlock = numEcBytesInGroup1; - } else { - numDataBytesInBlock = numDataBytesInGroup2; - numECBytesInBlock = numEcBytesInGroup2; - } -} -CBC_CommonByteArray* CBC_QRCoderEncoder::GenerateECBytes( - CBC_CommonByteArray* dataBytes, - int32_t numEcBytesInBlock, - int32_t& e) { - int32_t numDataBytes = dataBytes->Size(); - CFX_Int32Array toEncode; - toEncode.SetSize(numDataBytes + numEcBytesInBlock); - for (int32_t i = 0; i < numDataBytes; i++) { - toEncode[i] = (dataBytes->At(i)); - } - CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); - encode.Init(); - encode.Encode(&toEncode, numEcBytesInBlock, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); - for (int32_t j = 0; j < numEcBytesInBlock; j++) { - ecBytes->Set(j, toEncode[numDataBytes + j]); - } - return ecBytes; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h deleted file mode 100644 index f1b6504b2f..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h +++ /dev/null @@ -1,133 +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_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "core/include/fxcrt/fx_string.h" - -class CBC_QRCoder; -class CBC_QRCoderErrorCorrectionLevel; -class CBC_QRCoderMode; -class CBC_QRCoderBitVector; -class CBC_CommonByteArray; -class CBC_CommonByteMatrix; - -class CBC_QRCoderEncoder { - private: - static const int32_t m_alphaNumbericTable[96]; - - public: - CBC_QRCoderEncoder(); - virtual ~CBC_QRCoderEncoder(); - - static void Encode(const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e, - int32_t versionSpecify = 0); - static void Encode(const CFX_WideString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e); - static void EncodeWithSpecifyVersion(const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t versionSpecify, - int32_t& e); - static void EncodeWithAutoVersion(const CFX_ByteString& content, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoder* qrCode, - int32_t& e); - static CBC_QRCoderMode* ChooseMode(const CFX_ByteString& content, - CFX_ByteString encoding); - static int32_t GetAlphaNumericCode(int32_t code); - static void AppendECI(CBC_QRCoderBitVector* bits); - static void AppendBytes(const CFX_ByteString& content, - CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - CFX_ByteString encoding, - int32_t& e); - static void AppendNumericBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void AppendAlphaNumericBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void Append8BitBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - CFX_ByteString encoding, - int32_t& e); - static void Append8BitBytes(CFX_ByteArray& bytes, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void AppendKanjiBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void AppendGBKBytes(const CFX_ByteString& content, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void InitQRCode(int32_t numInputBytes, - int32_t versionNumber, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoderMode* mode, - CBC_QRCoder* qrCode, - int32_t& e); - static void InitQRCode(int32_t numInputBytes, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - CBC_QRCoderMode* mode, - CBC_QRCoder* qrCode, - int32_t& e); - static void AppendModeInfo(CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void AppendLengthInfo(int32_t numLetters, - int32_t version, - CBC_QRCoderMode* mode, - CBC_QRCoderBitVector* bits, - int32_t& e); - - static void InterleaveWithECBytes(CBC_QRCoderBitVector* bits, - int32_t numTotalBytes, - int32_t numDataBytes, - int32_t numRSBlocks, - CBC_QRCoderBitVector* result, - int32_t& e); - static void GetNumDataBytesAndNumECBytesForBlockID( - int32_t numTotalBytes, - int32_t numDataBytes, - int32_t numRSBlocks, - int32_t blockID, - int32_t& numDataBytesInBlock, - int32_t& numECBytesInBlocks); - static CBC_CommonByteArray* GenerateECBytes(CBC_CommonByteArray* dataBytes, - int32_t numEcBytesInBlock, - int32_t& e); - static int32_t ChooseMaskPattern(CBC_QRCoderBitVector* bits, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static int32_t CalculateMaskPenalty(CBC_CommonByteMatrix* matrix); - static void TerminateBits(int32_t numDataBytes, - CBC_QRCoderBitVector* bits, - int32_t& e); - static int32_t GetSpanByVersion(CBC_QRCoderMode* modeFirst, - 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); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp deleted file mode 100644 index ea239bdc0c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.cpp +++ /dev/null @@ -1,92 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" - -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::L = NULL; -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::M = NULL; -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::Q = NULL; -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::H = NULL; - -CBC_QRCoderErrorCorrectionLevel::CBC_QRCoderErrorCorrectionLevel( - int32_t ordinal, - int32_t bits, - FX_CHAR* name) { - m_name += name; - m_ordinal = ordinal; - m_bits = bits; -} -CBC_QRCoderErrorCorrectionLevel::~CBC_QRCoderErrorCorrectionLevel() {} -void CBC_QRCoderErrorCorrectionLevel::Initialize() { - L = new CBC_QRCoderErrorCorrectionLevel(0, 0x01, (FX_CHAR*)"L"); - M = new CBC_QRCoderErrorCorrectionLevel(1, 0x00, (FX_CHAR*)"M"); - Q = new CBC_QRCoderErrorCorrectionLevel(2, 0x03, (FX_CHAR*)"Q"); - H = new CBC_QRCoderErrorCorrectionLevel(3, 0x02, (FX_CHAR*)"H"); -} -void CBC_QRCoderErrorCorrectionLevel::Finalize() { - delete L; - delete M; - delete Q; - delete H; -} -int32_t CBC_QRCoderErrorCorrectionLevel::Ordinal() { - return m_ordinal; -} -int32_t CBC_QRCoderErrorCorrectionLevel::GetBits() { - return m_bits; -} -CFX_ByteString CBC_QRCoderErrorCorrectionLevel::GetName() { - return m_name; -} -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoderErrorCorrectionLevel::ForBits( - int32_t bits) { - switch (bits) { - case 0x00: - return M; - case 0x01: - return L; - case 0x02: - return H; - case 0x03: - return Q; - default: - return NULL; - } -} -void CBC_QRCoderErrorCorrectionLevel::Destroy() { - if (L) { - delete CBC_QRCoderErrorCorrectionLevel::L; - L = NULL; - } - if (M) { - delete CBC_QRCoderErrorCorrectionLevel::M; - M = NULL; - } - if (H) { - delete CBC_QRCoderErrorCorrectionLevel::H; - H = NULL; - } - if (Q) { - delete CBC_QRCoderErrorCorrectionLevel::Q; - Q = NULL; - } -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h deleted file mode 100644 index 77142423bf..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.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_SRC_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ - -#include "core/include/fxcrt/fx_string.h" - -class CBC_QRCoderErrorCorrectionLevel { - private: - int32_t m_ordinal; - int32_t m_bits; - CFX_ByteString m_name; - CBC_QRCoderErrorCorrectionLevel(int32_t ordinal, int32_t bits, FX_CHAR* name); - CBC_QRCoderErrorCorrectionLevel(); - - public: - static CBC_QRCoderErrorCorrectionLevel* L; - static CBC_QRCoderErrorCorrectionLevel* M; - static CBC_QRCoderErrorCorrectionLevel* Q; - static CBC_QRCoderErrorCorrectionLevel* H; - virtual ~CBC_QRCoderErrorCorrectionLevel(); - static void Initialize(); - static void Finalize(); - int32_t Ordinal(); - int32_t GetBits(); - CFX_ByteString GetName(); - static void Destroy(); - static CBC_QRCoderErrorCorrectionLevel* ForBits(int32_t bits); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERERRORCORRECTIONLEVEL_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp deleted file mode 100644 index 97c6c2a091..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp +++ /dev/null @@ -1,95 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_QRCoderFormatInformation::FORMAT_INFO_MASK_QR = 0X5412; -const int32_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}, -}; -const int32_t CBC_QRCoderFormatInformation::BITS_SET_IN_HALF_BYTE[] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; - -CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo) { - m_errorCorrectLevl = - 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; - return BITS_SET_IN_HALF_BYTE[a & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 4) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 8) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 12) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 16) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 20) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] + - BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F]; -} -uint8_t CBC_QRCoderFormatInformation::GetDataMask() { - return m_dataMask; -} -CBC_QRCoderErrorCorrectionLevel* -CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() { - return m_errorCorrectLevl; -} -CBC_QRCoderFormatInformation* -CBC_QRCoderFormatInformation::DecodeFormatInformation( - int32_t maskedFormatInfo) { - CBC_QRCoderFormatInformation* formatInfo = - DoDecodeFormatInformation(maskedFormatInfo); - if (formatInfo) - 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++) { - int32_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; - int32_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/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h deleted file mode 100644 index 61870d788d..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.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_SRC_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ - -class CBC_QRCoderErrorCorrectionLevel; -class CBC_QRCoderFormatInformation { - private: - static const int32_t FORMAT_INFO_MASK_QR; - static const int32_t FORMAT_INFO_DECODE_LOOKUP[32][2]; - static const int32_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(); - 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); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp deleted file mode 100644 index 840d542fc3..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp +++ /dev/null @@ -1,198 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRCoderMaskUtil::CBC_QRCoderMaskUtil() {} -CBC_QRCoderMaskUtil::~CBC_QRCoderMaskUtil() {} -int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( - CBC_CommonByteMatrix* matrix) { - return ApplyMaskPenaltyRule1Internal(matrix, TRUE) + - ApplyMaskPenaltyRule1Internal(matrix, FALSE); -} - -int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( - CBC_CommonByteMatrix* matrix) { - int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); - int32_t width = matrix->GetWidth(); - int32_t height = matrix->GetHeight(); - for (int32_t y = 0; y < height - 1; y++) { - for (int32_t x = 0; x < width - 1; x++) { - int32_t value = array[y * width + x]; - if (value == array[y * width + x + 1] && - value == array[(y + 1) * width + x] && - value == array[(y + 1) * width + x + 1]) { - penalty++; - } - } - } - return 3 * penalty; -} - -int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( - CBC_CommonByteMatrix* matrix) { - int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); - int32_t width = matrix->GetWidth(); - int32_t height = matrix->GetHeight(); - for (int32_t y = 0; y < height; ++y) { - for (int32_t x = 0; x < width; ++x) { - if (x == 0 && - ((y >= 0 && y <= 6) || (y >= height - 7 && y <= height - 1))) { - continue; - } - if (x == width - 7 && (y >= 0 && y <= 6)) { - continue; - } - if (y == 0 && - ((x >= 0 && x <= 6) || (x >= width - 7 && x <= width - 1))) { - continue; - } - if (y == height - 7 && (x >= 0 && x <= 6)) { - continue; - } - if (x + 6 < width && array[y * width + x] == 1 && - array[y * width + x + 1] == 0 && array[y * width + x + 2] == 1 && - array[y * width + x + 3] == 1 && array[y * width + x + 4] == 1 && - array[y * width + x + 5] == 0 && array[y * width + x + 6] == 1 && - ((x + 10 < width && array[y * width + x + 7] == 0 && - array[y * width + x + 8] == 0 && array[y * width + x + 9] == 0 && - array[y * width + x + 10] == 0) || - (x - 4 >= 0 && array[y * width + x - 1] == 0 && - array[y * width + x - 2] == 0 && array[y * width + x - 3] == 0 && - array[y * width + x - 4] == 0))) { - penalty += 40; - } - if (y + 6 < height && array[y * width + x] == 1 && - array[(y + 1) * width + x] == 0 && array[(y + 2) * width + x] == 1 && - array[(y + 3) * width + x] == 1 && array[(y + 4) * width + x] == 1 && - array[(y + 5) * width + x] == 0 && array[(y + 6) * width + x] == 1 && - ((y + 10 < height && array[(y + 7) * width + x] == 0 && - array[(y + 8) * width + x] == 0 && - array[(y + 9) * width + x] == 0 && - array[(y + 10) * width + x] == 0) || - (y - 4 >= 0 && array[(y - 1) * width + x] == 0 && - array[(y - 2) * width + x] == 0 && - array[(y - 3) * width + x] == 0 && - array[(y - 4) * width + x] == 0))) { - penalty += 40; - } - } - } - return penalty; -} -int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4( - CBC_CommonByteMatrix* matrix) { - int32_t numDarkCells = 0; - uint8_t* array = matrix->GetArray(); - int32_t width = matrix->GetWidth(); - int32_t height = matrix->GetHeight(); - for (int32_t y = 0; y < height; ++y) { - for (int32_t x = 0; x < width; ++x) { - if (array[y * width + x] == 1) { - numDarkCells += 1; - } - } - } - int32_t numTotalCells = matrix->GetHeight() * matrix->GetWidth(); - double darkRatio = (double)numDarkCells / numTotalCells; - return abs((int32_t)(darkRatio * 100 - 50) / 5) * 5 * 10; -} -FX_BOOL CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern, - int32_t x, - int32_t y, - int32_t& e) { - if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) { - e = (BCExceptionInvalidateMaskPattern); - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - } - int32_t intermediate = 0, temp = 0; - switch (maskPattern) { - case 0: - intermediate = (y + x) & 0x1; - break; - case 1: - intermediate = y & 0x1; - break; - case 2: - intermediate = x % 3; - break; - case 3: - intermediate = (y + x) % 3; - break; - case 4: - intermediate = ((y >> 1) + (x / 3)) & 0x1; - break; - case 5: - temp = y * x; - intermediate = (temp & 0x1) + (temp % 3); - break; - case 6: - temp = y * x; - intermediate = (((temp & 0x1) + (temp % 3)) & 0x1); - break; - case 7: - temp = y * x; - intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1); - break; - default: { - e = BCExceptionInvalidateMaskPattern; - BC_EXCEPTION_CHECK_ReturnValue(e, FALSE); - } - } - return intermediate == 0; -} -int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal( - CBC_CommonByteMatrix* matrix, - FX_BOOL isHorizontal) { - int32_t penalty = 0; - int32_t numSameBitCells = 0; - int32_t prevBit = -1; - int32_t width = matrix->GetWidth(); - int32_t height = matrix->GetHeight(); - int32_t iLimit = isHorizontal ? height : width; - int32_t jLimit = isHorizontal ? width : height; - uint8_t* array = matrix->GetArray(); - for (int32_t i = 0; i < iLimit; ++i) { - for (int32_t j = 0; j < jLimit; ++j) { - int32_t bit = isHorizontal ? array[i * width + j] : array[j * width + i]; - if (bit == prevBit) { - numSameBitCells += 1; - if (numSameBitCells == 5) { - penalty += 3; - } else if (numSameBitCells > 5) { - penalty += 1; - } - } else { - numSameBitCells = 1; - prevBit = bit; - } - } - numSameBitCells = 0; - } - return penalty; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h deleted file mode 100644 index ad6274c8a2..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.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_SRC_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ -class CBC_CommonByteMatrix; -class CBC_QRCoderMaskUtil { - public: - CBC_QRCoderMaskUtil(); - virtual ~CBC_QRCoderMaskUtil(); - static FX_BOOL GetDataMaskBit(int32_t maskPattern, - int32_t x, - int32_t y, - int32_t& e); - - static int32_t ApplyMaskPenaltyRule1(CBC_CommonByteMatrix* matrix); - static int32_t ApplyMaskPenaltyRule2(CBC_CommonByteMatrix* matrix); - static int32_t ApplyMaskPenaltyRule3(CBC_CommonByteMatrix* matrix); - static int32_t ApplyMaskPenaltyRule4(CBC_CommonByteMatrix* matrix); - static int32_t ApplyMaskPenaltyRule1Internal(CBC_CommonByteMatrix* matrix, - FX_BOOL isHorizontal); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMASKUTIL_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp deleted file mode 100644 index bf1d258d2a..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp +++ /dev/null @@ -1,478 +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 -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_QRCoderMatrixUtil::POSITION_DETECTION_PATTERN[7][7] = { - {1, 1, 1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1}, - {1, 0, 0, 0, 0, 0, 1}, - {1, 1, 1, 1, 1, 1, 1}}; -const int32_t CBC_QRCoderMatrixUtil::HORIZONTAL_SEPARATION_PATTERN[1][8] = { - {0, 0, 0, 0, 0, 0, 0, 0}}; -const int32_t CBC_QRCoderMatrixUtil::VERTICAL_SEPARATION_PATTERN[7][1] = - {{0}, {0}, {0}, {0}, {0}, {0}, {0}}; -const int32_t CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN[5][5] = { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}}; -const int32_t - CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7] = - // NOLINTNEXTLINE - { - {-1, -1, -1, -1, -1, -1, -1}, {6, 18, -1, -1, -1, -1, -1}, - {6, 22, -1, -1, -1, -1, -1}, {6, 26, -1, -1, -1, -1, -1}, - {6, 30, -1, -1, -1, -1, -1}, {6, 34, -1, -1, -1, -1, -1}, - {6, 22, 38, -1, -1, -1, -1}, {6, 24, 42, -1, -1, -1, -1}, - {6, 26, 46, -1, -1, -1, -1}, {6, 28, 50, -1, -1, -1, -1}, - {6, 30, 54, -1, -1, -1, -1}, {6, 32, 58, -1, -1, -1, -1}, - {6, 34, 62, -1, -1, -1, -1}, {6, 26, 46, 66, -1, -1, -1}, - {6, 26, 48, 70, -1, -1, -1}, {6, 26, 50, 74, -1, -1, -1}, - {6, 30, 54, 78, -1, -1, -1}, {6, 30, 56, 82, -1, -1, -1}, - {6, 30, 58, 86, -1, -1, -1}, {6, 34, 62, 90, -1, -1, -1}, - {6, 28, 50, 72, 94, -1, -1}, {6, 26, 50, 74, 98, -1, -1}, - {6, 30, 54, 78, 102, -1, -1}, {6, 28, 54, 80, 106, -1, -1}, - {6, 32, 58, 84, 110, -1, -1}, {6, 30, 58, 86, 114, -1, -1}, - {6, 34, 62, 90, 118, -1, -1}, {6, 26, 50, 74, 98, 122, -1}, - {6, 30, 54, 78, 102, 126, -1}, {6, 26, 52, 78, 104, 130, -1}, - {6, 30, 56, 82, 108, 134, -1}, {6, 34, 60, 86, 112, 138, -1}, - {6, 30, 58, 86, 114, 142, -1}, {6, 34, 62, 90, 118, 146, -1}, - {6, 30, 54, 78, 102, 126, 150}, {6, 24, 50, 76, 102, 128, 154}, - {6, 28, 54, 80, 106, 132, 158}, {6, 32, 58, 84, 110, 136, 162}, - {6, 26, 54, 82, 110, 138, 166}, {6, 30, 58, 86, 114, 142, 170}, -}; -const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_COORDINATES[15][2] = { - {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 7}, {8, 8}, - {7, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8}, -}; -const int32_t CBC_QRCoderMatrixUtil::VERSION_INFO_POLY = 0x1f25; -const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_POLY = 0x0537; -const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_MASK_PATTERN = 0x5412; - -void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - matrix->clear((uint8_t)-1); -} -void CBC_QRCoderMatrixUtil::BuildMatrix( - CBC_QRCoderBitVector* dataBits, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t version, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - ClearMatrix(matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedBasicPatterns(version, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedTypeInfo(ecLevel, maskPattern, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - MaybeEmbedVersionInfo(version, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedDataBits(dataBits, maskPattern, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - EmbedPositionDetectionPatternsAndSeparators(matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedDarkDotAtLeftBottomCorner(matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - MaybeEmbedPositionAdjustmentPatterns(version, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedTimingPatterns(matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderMatrixUtil::EmbedTypeInfo( - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - CBC_QRCoderBitVector typeInfoBits; - typeInfoBits.Init(); - MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - for (int32_t i = 0; i < typeInfoBits.Size(); i++) { - int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t x1 = TYPE_INFO_COORDINATES[i][0]; - int32_t y1 = TYPE_INFO_COORDINATES[i][1]; - matrix->Set(x1, y1, bit); - if (i < 8) { - int32_t x2 = matrix->GetWidth() - i - 1; - int32_t y2 = 8; - matrix->Set(x2, y2, bit); - } else { - int32_t x2 = 8; - int32_t y2 = matrix->GetHeight() - 7 + (i - 8); - matrix->Set(x2, y2, bit); - } - } -} -void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (version < 7) { - return; - } - CBC_QRCoderBitVector versionInfoBits; - versionInfoBits.Init(); - MakeVersionInfoBits(version, &versionInfoBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t bitIndex = 6 * 3 - 1; - for (int32_t i = 0; i < 6; i++) { - for (int32_t j = 0; j < 3; j++) { - int32_t bit = versionInfoBits.At(bitIndex, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - bitIndex--; - matrix->Set(i, matrix->GetHeight() - 11 + j, bit); - matrix->Set(matrix->GetHeight() - 11 + j, i, bit); - } - } -} -void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL || dataBits == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t bitIndex = 0; - int32_t direction = -1; - int32_t x = matrix->GetWidth() - 1; - int32_t y = matrix->GetHeight() - 1; - while (x > 0) { - if (x == 6) { - x -= 1; - } - while (y >= 0 && y < matrix->GetHeight()) { - if (y == 6) { - y += direction; - continue; - } - for (int32_t i = 0; i < 2; i++) { - int32_t xx = x - i; - if (!IsEmpty(matrix->Get(xx, y))) { - continue; - } - int32_t bit; - if (bitIndex < dataBits->Size()) { - bit = dataBits->At(bitIndex, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - bitIndex++; - } else { - bit = 0; - } - if (maskPattern != -1) { - FX_BOOL bol = - CBC_QRCoderMaskUtil::GetDataMaskBit(maskPattern, xx, y, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (bol) { - bit ^= 0x01; - } - } - matrix->Set(xx, y, bit); - } - y += direction; - } - direction = -direction; - y += direction; - x -= 2; - } - if (bitIndex != dataBits->Size()) { - return; - } -} -int32_t CBC_QRCoderMatrixUtil::CalculateBCHCode(int32_t value, int32_t poly) { - int32_t msbSetInPoly = FindMSBSet(poly); - value <<= msbSetInPoly - 1; - while (FindMSBSet(value) >= msbSetInPoly) { - value ^= poly << (FindMSBSet(value) - msbSetInPoly); - } - return value; -} -void CBC_QRCoderMatrixUtil::MakeTypeInfoBits( - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t maskPattern, - CBC_QRCoderBitVector* bits, - int32_t& e) { - if (bits == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) { - e = BCExceptionBadMask; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern; - BC_EXCEPTION_CHECK_ReturnVoid(e); - bits->AppendBits(typeInfo, 5, e); - int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY); - BC_EXCEPTION_CHECK_ReturnVoid(e); - bits->AppendBits(bchCode, 10, e); - CBC_QRCoderBitVector maskBits; - maskBits.Init(); - maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - bits->XOR(&maskBits, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (bits->Size() != 15) { - e = BCExceptionBitSizeNot15; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version, - CBC_QRCoderBitVector* bits, - int32_t& e) { - if (bits == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - bits->AppendBits(version, 6, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY); - bits->AppendBits(bchCode, 12, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (bits->Size() != 18) { - e = BCExceptionBitSizeNot18; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } -} -FX_BOOL CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) { - return (uint8_t)value == 0xff; -} -FX_BOOL CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) { - return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 || - (uint8_t)value == 0x01); -} -void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) { - int32_t bit = (i + 1) % 2; - if (!IsValidValue(matrix->Get(i, 6))) { - e = BCExceptionInvalidateImageData; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (IsEmpty(matrix->Get(i, 6))) { - matrix->Set(i, 6, bit); - } - if (!IsValidValue(matrix->Get(6, i))) { - e = BCExceptionInvalidateImageData; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (IsEmpty(matrix->Get(6, i))) { - matrix->Set(6, i, bit); - } - } -} -void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner( - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (matrix->Get(8, matrix->GetHeight() - 8) == 0) { - e = BCExceptionHeight_8BeZero; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - matrix->Set(8, matrix->GetHeight() - 8, 1); -} -void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern( - int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t x = 0; x < 8; x++) { - if (!IsEmpty(matrix->Get(xStart + x, yStart))) { - e = BCExceptionInvalidateData; - BC_EXCEPTION_CHECK_ReturnVoid(e) - } - matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]); - } -} -void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern( - int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t y = 0; y < 7; y++) { - if (!IsEmpty(matrix->Get(xStart, yStart + y))) { - e = BCExceptionInvalidateData; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]); - } -} -void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern( - int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t y = 0; y < 5; y++) { - for (int32_t x = 0; x < 5; x++) { - if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) { - e = BCExceptionInvalidateData; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]); - } - } -} -void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern( - int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - for (int32_t y = 0; y < 7; y++) { - for (int32_t x = 0; x < 7; x++) { - if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) { - e = BCExceptionInvalidateData; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]); - } - } -} -void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators( - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - int32_t pdpWidth = 7; - EmbedPositionDetectionPattern(0, 0, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedPositionDetectionPattern(matrix->GetWidth() - pdpWidth, 0, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedPositionDetectionPattern(0, matrix->GetWidth() - pdpWidth, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t hspWidth = 8; - EmbedHorizontalSeparationPattern(0, hspWidth - 1, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedHorizontalSeparationPattern(matrix->GetWidth() - hspWidth, hspWidth - 1, - matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedHorizontalSeparationPattern(0, matrix->GetWidth() - hspWidth, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t vspSize = 7; - EmbedVerticalSeparationPattern(vspSize, 0, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedVerticalSeparationPattern(matrix->GetHeight() - vspSize - 1, 0, matrix, - e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - EmbedVerticalSeparationPattern(vspSize, matrix->GetHeight() - vspSize, matrix, - e); - BC_EXCEPTION_CHECK_ReturnVoid(e); -} -void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns( - int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e) { - if (matrix == NULL) { - e = BCExceptionNullPointer; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if (version < 2) { - return; - } - int32_t index = version - 1; - int32_t const* coordinates = - &(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]); - int32_t numCoordinate = 7; - for (int32_t i = 0; i < numCoordinate; i++) { - for (int32_t j = 0; j < numCoordinate; j++) { - int32_t y = coordinates[i]; - int32_t x = coordinates[j]; - if (x == -1 || y == -1) { - continue; - } - if (IsEmpty(matrix->Get(x, y))) { - EmbedPositionAdjustmentPattern(x - 2, y - 2, matrix, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - } - } -} -int32_t CBC_QRCoderMatrixUtil::FindMSBSet(int32_t value) { - int32_t numDigits = 0; - while (value != 0) { - value >>= 1; - ++numDigits; - } - return numDigits; -} -CBC_QRCoderMatrixUtil::CBC_QRCoderMatrixUtil() {} -CBC_QRCoderMatrixUtil::~CBC_QRCoderMatrixUtil() {} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h deleted file mode 100644 index 6676b8389d..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h +++ /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 - -#ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ - -class CBC_CommonByteMatrix; -class CBC_QRCoderErrorCorrectionLevel; -class CBC_QRCoderBitVector; -class CBC_QRCoderMatrixUtil { - private: - static const int32_t POSITION_DETECTION_PATTERN[7][7]; - static const int32_t VERTICAL_SEPARATION_PATTERN[7][1]; - static const int32_t HORIZONTAL_SEPARATION_PATTERN[1][8]; - static const int32_t POSITION_ADJUSTMENT_PATTERN[5][5]; - static const int32_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7]; - static const int32_t TYPE_INFO_COORDINATES[15][2]; - static const int32_t VERSION_INFO_POLY; - static const int32_t TYPE_INFO_POLY; - static const int32_t TYPE_INFO_MASK_PATTERN; - - public: - CBC_QRCoderMatrixUtil(); - virtual ~CBC_QRCoderMatrixUtil(); - static void ClearMatrix(CBC_CommonByteMatrix* matrix, int32_t& e); - static void BuildMatrix(CBC_QRCoderBitVector* dataBits, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t version, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedBasicPatterns(int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedTypeInfo(CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedDataBits(CBC_QRCoderBitVector* dataBits, - int32_t maskPattern, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void MaybeEmbedVersionInfo(int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static int32_t FindMSBSet(int32_t value); - static int32_t CalculateBCHCode(int32_t code, int32_t poly); - static void MakeTypeInfoBits(CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t maskPattern, - CBC_QRCoderBitVector* bits, - int32_t& e); - static void MakeVersionInfoBits(int32_t version, - CBC_QRCoderBitVector* bits, - int32_t& e); - static FX_BOOL IsEmpty(int32_t value); - static FX_BOOL IsValidValue(int32_t value); - static void EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, int32_t& e); - static void EmbedDarkDotAtLeftBottomCorner(CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedHorizontalSeparationPattern(int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedVerticalSeparationPattern(int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedPositionAdjustmentPattern(int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedPositionDetectionPattern(int32_t xStart, - int32_t yStart, - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void EmbedPositionDetectionPatternsAndSeparators( - CBC_CommonByteMatrix* matrix, - int32_t& e); - static void MaybeEmbedPositionAdjustmentPatterns(int32_t version, - CBC_CommonByteMatrix* matrix, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.cpp deleted file mode 100644 index 337d21a9e9..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.cpp +++ /dev/null @@ -1,179 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sALPHANUMERIC = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sKANJI = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sECI = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sGBK = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sTERMINATOR = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_FIRST_POSITION = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sFNC1_SECOND_POSITION = NULL; -CBC_QRCoderMode* CBC_QRCoderMode::sSTRUCTURED_APPEND = NULL; - -CBC_QRCoderMode::CBC_QRCoderMode(int32_t* characterCountBitsForVersions, - int32_t x1, - int32_t x2, - int32_t x3, - int32_t bits, - CFX_ByteString name) { - m_characterCountBitsForVersions = characterCountBitsForVersions; - if (m_characterCountBitsForVersions) { - m_characterCountBitsForVersions[0] = x1; - m_characterCountBitsForVersions[1] = x2; - m_characterCountBitsForVersions[2] = x3; - } - m_name += name; - m_bits = bits; -} -CBC_QRCoderMode::~CBC_QRCoderMode() { - FX_Free(m_characterCountBitsForVersions); -} -void CBC_QRCoderMode::Initialize() { - sBYTE = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 16, 16, 0x4, "BYTE"); - sALPHANUMERIC = - new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 9, 11, 13, 0x2, "ALPHANUMERIC"); - sECI = new CBC_QRCoderMode(NULL, 0, 0, 0, 0x7, "ECI"); - sKANJI = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 10, 12, 0x8, "KANJI"); - sNUMERIC = - new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 10, 12, 14, 0x1, "NUMERIC"); - sGBK = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 8, 10, 12, 0x0D, "GBK"); - sTERMINATOR = - new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 0, 0, 0, 0x00, "TERMINATOR"); - sFNC1_FIRST_POSITION = - new CBC_QRCoderMode(NULL, 0, 0, 0, 0x05, "FNC1_FIRST_POSITION"); - sFNC1_SECOND_POSITION = - new CBC_QRCoderMode(NULL, 0, 0, 0, 0x09, "FNC1_SECOND_POSITION"); - sSTRUCTURED_APPEND = new CBC_QRCoderMode(FX_Alloc(int32_t, 3), 0, 0, 0, 0x03, - "STRUCTURED_APPEND"); -} -void CBC_QRCoderMode::Finalize() { - delete sBYTE; - delete sALPHANUMERIC; - delete sECI; - delete sKANJI; - delete sNUMERIC; - delete sGBK; - delete sTERMINATOR; - delete sFNC1_FIRST_POSITION; - delete sFNC1_SECOND_POSITION; - delete sSTRUCTURED_APPEND; -} -CBC_QRCoderMode* CBC_QRCoderMode::ForBits(int32_t bits, int32_t& e) { - switch (bits) { - case 0x0: - return sTERMINATOR; - case 0x1: - return sNUMERIC; - case 0x2: - return sALPHANUMERIC; - case 0x3: - return sSTRUCTURED_APPEND; - case 0x4: - return sBYTE; - case 0x5: - return sFNC1_FIRST_POSITION; - case 0x7: - return sECI; - case 0x8: - return sKANJI; - case 0x9: - return sFNC1_SECOND_POSITION; - case 0x0D: - return sGBK; - default: { - e = BCExceptionUnsupportedMode; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - } - return NULL; -} -int32_t CBC_QRCoderMode::GetBits() { - return m_bits; -} -CFX_ByteString CBC_QRCoderMode::GetName() { - return m_name; -} -int32_t CBC_QRCoderMode::GetCharacterCountBits(CBC_QRCoderVersion* version, - int32_t& e) { - if (m_characterCountBitsForVersions == NULL) { - e = BCExceptionCharacterNotThisMode; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - int32_t number = version->GetVersionNumber(); - int32_t offset; - if (number <= 9) { - offset = 0; - } else if (number <= 26) { - offset = 1; - } else { - offset = 2; - } - return m_characterCountBitsForVersions[offset]; -} -void CBC_QRCoderMode::Destroy() { - if (sBYTE) { - delete CBC_QRCoderMode::sBYTE; - sBYTE = NULL; - } - if (sNUMERIC) { - delete CBC_QRCoderMode::sNUMERIC; - sNUMERIC = NULL; - } - if (sALPHANUMERIC) { - delete CBC_QRCoderMode::sALPHANUMERIC; - sALPHANUMERIC = NULL; - } - if (sKANJI) { - delete CBC_QRCoderMode::sKANJI; - sKANJI = NULL; - } - if (sECI) { - delete CBC_QRCoderMode::sECI; - sECI = NULL; - } - if (sGBK) { - delete CBC_QRCoderMode::sGBK; - sGBK = NULL; - } - if (sTERMINATOR) { - delete CBC_QRCoderMode::sTERMINATOR; - sTERMINATOR = NULL; - } - if (sFNC1_FIRST_POSITION) { - delete CBC_QRCoderMode::sFNC1_FIRST_POSITION; - sFNC1_FIRST_POSITION = NULL; - } - if (sFNC1_SECOND_POSITION) { - delete CBC_QRCoderMode::sFNC1_SECOND_POSITION; - sFNC1_SECOND_POSITION = NULL; - } - if (sSTRUCTURED_APPEND) { - delete CBC_QRCoderMode::sSTRUCTURED_APPEND; - sSTRUCTURED_APPEND = NULL; - } -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h deleted file mode 100644 index 9098b35beb..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h +++ /dev/null @@ -1,51 +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_SRC_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ - -#include <stdint.h> - -#include "core/include/fxcrt/fx_string.h" - -class CBC_QRCoderVersion; - -class CBC_QRCoderMode { - private: - int32_t* m_characterCountBitsForVersions; - int32_t m_bits; - CFX_ByteString m_name; - CBC_QRCoderMode(int32_t* characterCountBitsForVersions, - int32_t x1, - int32_t x2, - int32_t x3, - int32_t bits, - CFX_ByteString name); - CBC_QRCoderMode(); - - public: - static CBC_QRCoderMode* sBYTE; - static CBC_QRCoderMode* sNUMERIC; - static CBC_QRCoderMode* sALPHANUMERIC; - static CBC_QRCoderMode* sKANJI; - static CBC_QRCoderMode* sECI; - static CBC_QRCoderMode* sGBK; - static CBC_QRCoderMode* sTERMINATOR; - static CBC_QRCoderMode* sFNC1_FIRST_POSITION; - static CBC_QRCoderMode* sFNC1_SECOND_POSITION; - static CBC_QRCoderMode* sSTRUCTURED_APPEND; - virtual ~CBC_QRCoderMode(); - - static void Initialize(); - static void Finalize(); - static CBC_QRCoderMode* ForBits(int32_t bits, int32_t& e); - int32_t GetCharacterCountBits(CBC_QRCoderVersion* version, int32_t& e); - int32_t GetBits(); - CFX_ByteString GetName(); - static void Destroy(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERMODE_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.cpp deleted file mode 100644 index 86e08c933c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.cpp +++ /dev/null @@ -1,769 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_QRCoderVersion::VERSION_DECODE_INFO[] = { - 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, - 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, - 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; - -void CBC_QRCoderVersion::Initialize() { - VERSION = new CFX_PtrArray(); -} -void CBC_QRCoderVersion::Finalize() { - for (int32_t i = 0; i < VERSION->GetSize(); i++) { - CBC_QRCoderVersion* v = (CBC_QRCoderVersion*)(VERSION->GetAt(i)); - delete v; - } - delete VERSION; -} -CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber, - CBC_QRCoderECBlocks* ecBlocks1, - CBC_QRCoderECBlocks* ecBlocks2, - 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); - int32_t total = 0; - int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock(); - CFX_PtrArray* ecbArray = ecBlocks1->GetECBlocks(); - for (int32_t i = 0; i < ecbArray->GetSize(); i++) { - CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)((*ecbArray)[i]); - total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords); - } - m_totalCodeWords = total; - switch (versionNumber) { - case 1: - break; - case 2: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(18); - break; - case 3: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(22); - break; - case 4: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - break; - case 5: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - break; - case 6: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - break; - case 7: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(22); - m_alignmentPatternCenters.Add(38); - break; - case 8: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(24); - m_alignmentPatternCenters.Add(42); - break; - case 9: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(46); - break; - case 10: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(28); - m_alignmentPatternCenters.Add(50); - break; - case 11: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(54); - break; - case 12: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(32); - m_alignmentPatternCenters.Add(58); - break; - case 13: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - m_alignmentPatternCenters.Add(62); - break; - case 14: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(46); - m_alignmentPatternCenters.Add(66); - break; - case 15: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(48); - m_alignmentPatternCenters.Add(70); - break; - case 16: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(50); - m_alignmentPatternCenters.Add(74); - break; - case 17: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(78); - break; - case 18: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(56); - m_alignmentPatternCenters.Add(82); - break; - case 19: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(86); - break; - case 20: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - m_alignmentPatternCenters.Add(62); - m_alignmentPatternCenters.Add(90); - break; - case 21: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(28); - m_alignmentPatternCenters.Add(50); - m_alignmentPatternCenters.Add(72); - m_alignmentPatternCenters.Add(94); - break; - case 22: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(50); - m_alignmentPatternCenters.Add(74); - m_alignmentPatternCenters.Add(98); - break; - case 23: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(74); - m_alignmentPatternCenters.Add(102); - break; - case 24: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(28); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(80); - m_alignmentPatternCenters.Add(106); - break; - case 25: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(32); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(84); - m_alignmentPatternCenters.Add(110); - break; - case 26: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(86); - m_alignmentPatternCenters.Add(114); - break; - case 27: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - m_alignmentPatternCenters.Add(62); - m_alignmentPatternCenters.Add(90); - m_alignmentPatternCenters.Add(118); - break; - case 28: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(50); - m_alignmentPatternCenters.Add(74); - m_alignmentPatternCenters.Add(98); - m_alignmentPatternCenters.Add(122); - break; - case 29: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(78); - m_alignmentPatternCenters.Add(102); - m_alignmentPatternCenters.Add(126); - break; - case 30: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(52); - m_alignmentPatternCenters.Add(78); - m_alignmentPatternCenters.Add(104); - m_alignmentPatternCenters.Add(130); - break; - case 31: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(56); - m_alignmentPatternCenters.Add(82); - m_alignmentPatternCenters.Add(108); - m_alignmentPatternCenters.Add(134); - break; - case 32: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - m_alignmentPatternCenters.Add(60); - m_alignmentPatternCenters.Add(86); - m_alignmentPatternCenters.Add(112); - m_alignmentPatternCenters.Add(138); - break; - case 33: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(86); - m_alignmentPatternCenters.Add(114); - m_alignmentPatternCenters.Add(142); - break; - case 34: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(34); - m_alignmentPatternCenters.Add(62); - m_alignmentPatternCenters.Add(90); - m_alignmentPatternCenters.Add(118); - m_alignmentPatternCenters.Add(146); - break; - case 35: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(78); - m_alignmentPatternCenters.Add(102); - m_alignmentPatternCenters.Add(126); - m_alignmentPatternCenters.Add(150); - break; - case 36: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(24); - m_alignmentPatternCenters.Add(50); - m_alignmentPatternCenters.Add(76); - m_alignmentPatternCenters.Add(102); - m_alignmentPatternCenters.Add(128); - m_alignmentPatternCenters.Add(154); - break; - case 37: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(28); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(80); - m_alignmentPatternCenters.Add(106); - m_alignmentPatternCenters.Add(132); - m_alignmentPatternCenters.Add(158); - break; - case 38: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(32); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(84); - m_alignmentPatternCenters.Add(110); - m_alignmentPatternCenters.Add(136); - m_alignmentPatternCenters.Add(162); - break; - case 39: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(26); - m_alignmentPatternCenters.Add(54); - m_alignmentPatternCenters.Add(82); - m_alignmentPatternCenters.Add(110); - m_alignmentPatternCenters.Add(138); - m_alignmentPatternCenters.Add(166); - break; - case 40: - m_alignmentPatternCenters.Add(6); - m_alignmentPatternCenters.Add(30); - m_alignmentPatternCenters.Add(58); - m_alignmentPatternCenters.Add(86); - m_alignmentPatternCenters.Add(114); - m_alignmentPatternCenters.Add(142); - m_alignmentPatternCenters.Add(170); - 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++; - } - } -} -int32_t CBC_QRCoderVersion::GetVersionNumber() { - return m_versionNumber; -} -CFX_Int32Array* CBC_QRCoderVersion::GetAlignmentPatternCenters() { - return &m_alignmentPatternCenters; -} -int32_t CBC_QRCoderVersion::GetTotalCodeWords() { - return m_totalCodeWords; -} -int32_t CBC_QRCoderVersion::GetDimensionForVersion() { - return 17 + 4 * m_versionNumber; -} -CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel( - CBC_QRCoderErrorCorrectionLevel* ecLevel) { - return (CBC_QRCoderECBlocks*)m_ecBlocks[ecLevel->Ordinal()]; -} -CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension( - int32_t dimension, - int32_t& e) { - if ((dimension % 4) != 1) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CBC_QRCoderVersion* qcv = GetVersionForNumber((dimension - 17) >> 2, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qcv; -} -CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation( - int32_t versionBits, - int32_t& e) { - int32_t bestDifference = FXSYS_IntMax; - int32_t bestVersion = 0; - for (int32_t i = 0; i < 34; i++) { - int32_t targetVersion = VERSION_DECODE_INFO[i]; - if (targetVersion == versionBits) { - CBC_QRCoderVersion* qcv = GetVersionForNumber(i + 7, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qcv; - } - int32_t bitsDifference = CBC_QRCoderFormatInformation::NumBitsDiffering( - versionBits, targetVersion); - if (bitsDifference < bestDifference) { - bestVersion = i + 7; - bestDifference = bitsDifference; - } - } - if (bestDifference <= 3) { - CBC_QRCoderVersion* qcv = GetVersionForNumber(bestVersion, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qcv; - } - return NULL; -} -CBC_CommonBitMatrix* CBC_QRCoderVersion::BuildFunctionPattern(int32_t& e) { - int32_t dimension = GetDimensionForVersion(); - CBC_CommonBitMatrix* bitMatrix = new CBC_CommonBitMatrix(); - bitMatrix->Init(dimension); - bitMatrix->SetRegion(0, 0, 9, 9, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - bitMatrix->SetRegion(dimension - 8, 0, 8, 9, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - bitMatrix->SetRegion(0, dimension - 8, 9, 8, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t max = m_alignmentPatternCenters.GetSize(); - for (int32_t x = 0; x < max; x++) { - int32_t i = m_alignmentPatternCenters[x] - 2; - for (int32_t y = 0; y < max; y++) { - if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { - continue; - } - bitMatrix->SetRegion(m_alignmentPatternCenters[y] - 2, i, 5, 5, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - } - bitMatrix->SetRegion(6, 9, 1, dimension - 17, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - bitMatrix->SetRegion(9, 6, dimension - 17, 1, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (m_versionNumber > 6) { - bitMatrix->SetRegion(dimension - 11, 0, 3, 6, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - bitMatrix->SetRegion(0, dimension - 11, 6, 3, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return bitMatrix; -} -CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber( - int32_t versionNumber, - int32_t& e) { - if (VERSION->GetSize() == 0) { - VERSION->Add(new CBC_QRCoderVersion( - 1, new CBC_QRCoderECBlocks(7, new CBC_QRCoderECB(1, 19)), - new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 16)), - new CBC_QRCoderECBlocks(13, new CBC_QRCoderECB(1, 13)), - new CBC_QRCoderECBlocks(17, new CBC_QRCoderECB(1, 9)))); - VERSION->Add(new CBC_QRCoderVersion( - 2, new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 34)), - new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(1, 28)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(1, 22)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 3, new CBC_QRCoderECBlocks(15, new CBC_QRCoderECB(1, 55)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 44)), - new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 17)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 4, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(1, 80)), - new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 32)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(2, 24)), - new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 9)))); - VERSION->Add(new CBC_QRCoderVersion( - 5, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 108)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 43)), - new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 15), - new CBC_QRCoderECB(2, 16)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 11), - new CBC_QRCoderECB(2, 12)))); - VERSION->Add(new CBC_QRCoderVersion( - 6, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68)), - new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 27)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 19)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 15)))); - VERSION->Add(new CBC_QRCoderVersion( - 7, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(2, 78)), - new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(4, 31)), - new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 14), - new CBC_QRCoderECB(4, 15)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 13), - new CBC_QRCoderECB(1, 14)))); - VERSION->Add(new CBC_QRCoderVersion( - 8, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 97)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 38), - new CBC_QRCoderECB(2, 39)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(4, 18), - new CBC_QRCoderECB(2, 19)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 14), - new CBC_QRCoderECB(2, 15)))); - VERSION->Add(new CBC_QRCoderVersion( - 9, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 116)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(3, 36), - new CBC_QRCoderECB(2, 37)), - new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 16), - new CBC_QRCoderECB(4, 17)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 12), - new CBC_QRCoderECB(4, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 10, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68), - new CBC_QRCoderECB(2, 69)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 43), - new CBC_QRCoderECB(1, 44)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(6, 19), - new CBC_QRCoderECB(2, 20)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 15), - new CBC_QRCoderECB(2, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 11, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 81)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 50), - new CBC_QRCoderECB(4, 51)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 22), - new CBC_QRCoderECB(4, 23)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(3, 12), - new CBC_QRCoderECB(8, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 12, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 92), - new CBC_QRCoderECB(2, 93)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(6, 36), - new CBC_QRCoderECB(2, 37)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 20), - new CBC_QRCoderECB(6, 21)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 14), - new CBC_QRCoderECB(4, 15)))); - VERSION->Add(new CBC_QRCoderVersion( - 13, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 107)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(8, 37), - new CBC_QRCoderECB(1, 38)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(8, 20), - new CBC_QRCoderECB(4, 21)), - new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(12, 11), - new CBC_QRCoderECB(4, 12)))); - VERSION->Add(new CBC_QRCoderVersion( - 14, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 115), - new CBC_QRCoderECB(1, 116)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 40), - new CBC_QRCoderECB(5, 41)), - new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(11, 16), - new CBC_QRCoderECB(5, 17)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12), - new CBC_QRCoderECB(5, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 15, new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(5, 87), - new CBC_QRCoderECB(1, 88)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 41), - new CBC_QRCoderECB(5, 42)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 24), - new CBC_QRCoderECB(7, 25)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12), - new CBC_QRCoderECB(7, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 16, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 98), - new CBC_QRCoderECB(1, 99)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 45), - new CBC_QRCoderECB(3, 46)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(15, 19), - new CBC_QRCoderECB(2, 20)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 15), - new CBC_QRCoderECB(13, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 17, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 107), - new CBC_QRCoderECB(5, 108)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46), - new CBC_QRCoderECB(1, 47)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 22), - new CBC_QRCoderECB(15, 23)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14), - new CBC_QRCoderECB(17, 15)))); - VERSION->Add(new CBC_QRCoderVersion( - 18, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 120), - new CBC_QRCoderECB(1, 121)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 43), - new CBC_QRCoderECB(4, 44)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22), - new CBC_QRCoderECB(1, 23)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14), - new CBC_QRCoderECB(19, 15)))); - VERSION->Add(new CBC_QRCoderVersion( - 19, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 113), - new CBC_QRCoderECB(4, 114)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 44), - new CBC_QRCoderECB(11, 45)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 21), - new CBC_QRCoderECB(4, 22)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 13), - new CBC_QRCoderECB(16, 14)))); - VERSION->Add(new CBC_QRCoderVersion( - 20, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 107), - new CBC_QRCoderECB(5, 108)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 41), - new CBC_QRCoderECB(13, 42)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24), - new CBC_QRCoderECB(5, 25)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(15, 15), - new CBC_QRCoderECB(10, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 21, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 116), - new CBC_QRCoderECB(4, 117)), - new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 42)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22), - new CBC_QRCoderECB(6, 23)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 16), - new CBC_QRCoderECB(6, 17)))); - VERSION->Add(new CBC_QRCoderVersion( - 22, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 111), - new CBC_QRCoderECB(7, 112)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 46)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24), - new CBC_QRCoderECB(16, 25)), - new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(34, 13)))); - VERSION->Add(new CBC_QRCoderVersion( - 23, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 121), - new CBC_QRCoderECB(5, 122)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 47), - new CBC_QRCoderECB(14, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24), - new CBC_QRCoderECB(14, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(16, 15), - new CBC_QRCoderECB(14, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 24, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 117), - new CBC_QRCoderECB(4, 118)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 45), - new CBC_QRCoderECB(14, 46)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24), - new CBC_QRCoderECB(16, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(30, 16), - new CBC_QRCoderECB(2, 17)))); - VERSION->Add(new CBC_QRCoderVersion( - 25, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(8, 106), - new CBC_QRCoderECB(4, 107)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(8, 47), - new CBC_QRCoderECB(13, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24), - new CBC_QRCoderECB(22, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15), - new CBC_QRCoderECB(13, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 26, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 114), - new CBC_QRCoderECB(2, 115)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 46), - new CBC_QRCoderECB(4, 47)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(28, 22), - new CBC_QRCoderECB(6, 23)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(33, 16), - new CBC_QRCoderECB(4, 17)))); - VERSION->Add(new CBC_QRCoderVersion( - 27, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 122), - new CBC_QRCoderECB(4, 123)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(22, 45), - new CBC_QRCoderECB(3, 46)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 23), - new CBC_QRCoderECB(26, 24)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 15), - new CBC_QRCoderECB(28, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 28, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 117), - new CBC_QRCoderECB(10, 118)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 45), - new CBC_QRCoderECB(23, 46)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 24), - new CBC_QRCoderECB(31, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15), - new CBC_QRCoderECB(31, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 29, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 116), - new CBC_QRCoderECB(7, 117)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(21, 45), - new CBC_QRCoderECB(7, 46)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 23), - new CBC_QRCoderECB(37, 24)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15), - new CBC_QRCoderECB(26, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 30, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 115), - new CBC_QRCoderECB(10, 116)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 47), - new CBC_QRCoderECB(10, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24), - new CBC_QRCoderECB(25, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15), - new CBC_QRCoderECB(25, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 31, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115), - new CBC_QRCoderECB(3, 116)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 46), - new CBC_QRCoderECB(29, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 24), - new CBC_QRCoderECB(1, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15), - new CBC_QRCoderECB(28, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 32, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46), - new CBC_QRCoderECB(23, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 24), - new CBC_QRCoderECB(35, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15), - new CBC_QRCoderECB(35, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 33, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115), - new CBC_QRCoderECB(1, 116)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46), - new CBC_QRCoderECB(21, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(29, 24), - new CBC_QRCoderECB(19, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15), - new CBC_QRCoderECB(46, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 34, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115), - new CBC_QRCoderECB(6, 116)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46), - new CBC_QRCoderECB(23, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(44, 24), - new CBC_QRCoderECB(7, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(59, 16), - new CBC_QRCoderECB(1, 17)))); - VERSION->Add(new CBC_QRCoderVersion( - 35, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 121), - new CBC_QRCoderECB(7, 122)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(12, 47), - new CBC_QRCoderECB(26, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(39, 24), - new CBC_QRCoderECB(14, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15), - new CBC_QRCoderECB(41, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 36, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 121), - new CBC_QRCoderECB(14, 122)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 47), - new CBC_QRCoderECB(34, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(46, 24), - new CBC_QRCoderECB(10, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 15), - new CBC_QRCoderECB(64, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 37, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 122), - new CBC_QRCoderECB(4, 123)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(29, 46), - new CBC_QRCoderECB(14, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(49, 24), - new CBC_QRCoderECB(10, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(24, 15), - new CBC_QRCoderECB(46, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 38, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 122), - new CBC_QRCoderECB(18, 123)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(13, 46), - new CBC_QRCoderECB(32, 47)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(48, 24), - new CBC_QRCoderECB(14, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 15), - new CBC_QRCoderECB(32, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 39, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 117), - new CBC_QRCoderECB(4, 118)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(40, 47), - new CBC_QRCoderECB(7, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(43, 24), - new CBC_QRCoderECB(22, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 15), - new CBC_QRCoderECB(67, 16)))); - VERSION->Add(new CBC_QRCoderVersion( - 40, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 118), - new CBC_QRCoderECB(6, 119)), - new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(18, 47), - new CBC_QRCoderECB(31, 48)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(34, 24), - new CBC_QRCoderECB(34, 25)), - new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 15), - new CBC_QRCoderECB(61, 16)))); - } - if (versionNumber < 1 || versionNumber > 40) { - e = BCExceptionIllegalArgument; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - return (CBC_QRCoderVersion*)(*VERSION)[versionNumber - 1]; -} -void CBC_QRCoderVersion::Destroy() { - int32_t i; - for (i = 0; i < VERSION->GetSize(); i++) { - delete ((CBC_QRCoderVersion*)(*VERSION)[i]); - } -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h deleted file mode 100644 index ceb6f91930..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h +++ /dev/null @@ -1,54 +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_SRC_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_QRCoderECBlocks; -class CBC_CommonBitMatrix; -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(); - static void Finalize(); - - int32_t GetVersionNumber(); - int32_t GetTotalCodeWords(); - int32_t GetDimensionForVersion(); - CBC_CommonBitMatrix* BuildFunctionPattern(int32_t& e); - CFX_Int32Array* GetAlignmentPatternCenters(); - CBC_QRCoderECBlocks* GetECBlocksForLevel( - CBC_QRCoderErrorCorrectionLevel* ecLevel); - static CBC_QRCoderVersion* GetVersionForNumber(int32_t versionNumber, - int32_t& e); - static CBC_QRCoderVersion* GetProvisionalVersionForDimension( - int32_t dimension, - int32_t& e); - static CBC_QRCoderVersion* DecodeVersionInformation(int32_t versionBits, - int32_t& e); - static void Destroy(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp deleted file mode 100644 index 185e16c5b7..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp +++ /dev/null @@ -1,111 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" - -#include <memory> - -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRDataBlock::CBC_QRDataBlock(int32_t numDataCodewords, - CFX_ByteArray* codewords) - : m_numDataCodewords(numDataCodewords), m_codewords(codewords) {} -CBC_QRDataBlock::~CBC_QRDataBlock() { - delete m_codewords; -} -int32_t CBC_QRDataBlock::GetNumDataCodewords() { - return m_numDataCodewords; -} -CFX_ByteArray* CBC_QRDataBlock::GetCodewords() { - return m_codewords; -} -CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks( - CFX_ByteArray* rawCodewords, - CBC_QRCoderVersion* version, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t& e) { - if (rawCodewords->GetSize() != version->GetTotalCodeWords()) { - e = BCExceptionIllegalArgument; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel); - int32_t totalBlocks = 0; - CFX_PtrArray* ecBlockArray = ecBlocks->GetECBlocks(); - int32_t i = 0; - for (i = 0; i < ecBlockArray->GetSize(); i++) { - totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount(); - } - std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray()); - result->SetSize(totalBlocks); - int32_t numResultBlocks = 0; - for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) { - CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)(*ecBlockArray)[j]; - for (int32_t k = 0; k < ecBlock->GetCount(); k++) { - int32_t numDataCodewords = ecBlock->GetDataCodeWords(); - int32_t numBlockCodewords = - ecBlocks->GetECCodeWordsPerBlock() + numDataCodewords; - CFX_ByteArray* bytearray = new CFX_ByteArray(); - bytearray->SetSize(numBlockCodewords); - (*result)[numResultBlocks++] = - new CBC_QRDataBlock(numDataCodewords, bytearray); - } - } - int32_t shorterBlocksTotalCodewords = - ((CBC_QRDataBlock*)(*result)[0])->m_codewords->GetSize(); - int32_t longerBlocksStartAt = result->GetSize() - 1; - while (longerBlocksStartAt >= 0) { - int32_t numCodewords = ((CBC_QRDataBlock*)(*result)[longerBlocksStartAt]) - ->m_codewords->GetSize(); - if (numCodewords == shorterBlocksTotalCodewords) { - break; - } - longerBlocksStartAt--; - } - longerBlocksStartAt++; - int32_t shorterBlocksNumDataCodewords = - shorterBlocksTotalCodewords - ecBlocks->GetECCodeWordsPerBlock(); - int32_t rawCodewordsOffset = 0; - 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++]; - } - } - for (x = longerBlocksStartAt; x < numResultBlocks; x++) { - (*(((CBC_QRDataBlock*)(*result)[x]) - ->m_codewords))[shorterBlocksNumDataCodewords] = - (*rawCodewords)[rawCodewordsOffset++]; - } - int32_t max = ((CBC_QRDataBlock*)(*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] = - (*rawCodewords)[rawCodewordsOffset++]; - } - } - return result.release(); -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h deleted file mode 100644 index de53ca49d4..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.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_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ - -#include "core/include/fxcrt/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); - - public: - virtual ~CBC_QRDataBlock(); - int32_t GetNumDataCodewords(); - CFX_ByteArray* GetCodewords(); - static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords, - CBC_QRCoderVersion* version, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataMask.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDataMask.cpp deleted file mode 100644 index a5a8a3a73b..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataMask.cpp +++ /dev/null @@ -1,118 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" -#include "xfa/src/fxbarcode/utils.h" - -static int32_t N_DATA_MASKS = 0; -CFX_PtrArray* CBC_QRDataMask::DATA_MASKS = NULL; - -void CBC_QRDataMask::Initialize() { - DATA_MASKS = new CFX_PtrArray(); - N_DATA_MASKS = BuildDataMasks(); -} -void CBC_QRDataMask::Finalize() { - Destroy(); - delete DATA_MASKS; -} -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; - } - } -} -void CBC_QRDataMask::UnmaskBitMatirx(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)) { - 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); - } - return (CBC_QRDataMask*)(*DATA_MASKS)[reference]; -} -class DataMask000 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { return ((x + y) % 2) == 0; } -}; -class DataMask001 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { return (x % 2) == 0; } -}; -class DataMask010 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { return y % 3 == 0; } -}; -class DataMask011 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { return (x + y) % 3 == 0; } -}; -class DataMask100 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { - return (((x >> 1) + (y / 3)) % 2) == 0; - } -}; -class DataMask101 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { - size_t temp = x * y; - return (temp % 2) + (temp % 3) == 0; - } -}; -class DataMask110 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { - size_t temp = x * y; - return (((temp % 2) + (temp % 3)) % 2) == 0; - } -}; -class DataMask111 : public CBC_QRDataMask { - public: - FX_BOOL IsMasked(int32_t x, int32_t y) { - return ((((x + y) % 2) + ((x * y) % 3)) % 2) == 0; - } -}; -int32_t CBC_QRDataMask::BuildDataMasks() { - DATA_MASKS->Add(new DataMask000); - DATA_MASKS->Add(new DataMask001); - DATA_MASKS->Add(new DataMask010); - DATA_MASKS->Add(new DataMask011); - DATA_MASKS->Add(new DataMask100); - DATA_MASKS->Add(new DataMask101); - DATA_MASKS->Add(new DataMask110); - DATA_MASKS->Add(new DataMask111); - return DATA_MASKS->GetSize(); -} -CBC_QRDataMask::CBC_QRDataMask() {} -CBC_QRDataMask::~CBC_QRDataMask() {} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataMask.h b/xfa/src/fxbarcode/qrcode/BC_QRDataMask.h deleted file mode 100644 index cbf8d47a0e..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataMask.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_SRC_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ - -#include "core/include/fxcrt/fx_basic.h" - -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(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRDATAMASK_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp deleted file mode 100644 index ed97280932..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp +++ /dev/null @@ -1,273 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitSource.h" -#include "xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h" -#include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" -#include "xfa/src/fxbarcode/common/BC_CommonECI.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h" - -const FX_CHAR* CBC_QRDecodedBitStreamParser::UTF_8 = "utf8"; -const FX_CHAR CBC_QRDecodedBitStreamParser::ALPHANUMERIC_CHARS[45] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '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', ' ', '$', '%', '*', '+', '-', '.', '/', ':'}; - -CBC_QRDecodedBitStreamParser::CBC_QRDecodedBitStreamParser() {} -CBC_QRDecodedBitStreamParser::~CBC_QRDecodedBitStreamParser() {} -CBC_CommonDecoderResult* CBC_QRDecodedBitStreamParser::Decode( - CFX_ByteArray* bytes, - CBC_QRCoderVersion* version, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t byteModeDecode, - int32_t& e) { - CBC_CommonBitSource bits(bytes); - CFX_ByteString result; - CBC_CommonCharacterSetECI* currentCharacterSetECI = NULL; - FX_BOOL fc1Infact = FALSE; - CFX_Int32Array byteSegments; - CBC_QRCoderMode* mode = NULL; - do { - if (bits.Available() < 4) { - mode = CBC_QRCoderMode::sTERMINATOR; - } else { - int32_t iTemp1 = bits.ReadBits(4, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - mode = CBC_QRCoderMode::ForBits(iTemp1, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (mode == NULL) { - e = BCExceptionUnSupportMode; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - } - if (!(mode == CBC_QRCoderMode::sTERMINATOR)) { - if (mode == CBC_QRCoderMode::sFNC1_FIRST_POSITION || - mode == CBC_QRCoderMode::sFNC1_SECOND_POSITION) { - fc1Infact = TRUE; - } else if (mode == CBC_QRCoderMode::sSTRUCTURED_APPEND) { - bits.ReadBits(16, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else if (mode == CBC_QRCoderMode::sECI) { - int32_t value = ParseECIValue(&bits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - currentCharacterSetECI = - CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(value); - } else { - if (mode == CBC_QRCoderMode::sGBK) { - bits.ReadBits(4, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t numBits = mode->GetCharacterCountBits(version, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t count = bits.ReadBits(numBits, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - if (mode == CBC_QRCoderMode::sNUMERIC) { - DecodeNumericSegment(&bits, result, count, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) { - DecodeAlphanumericSegment(&bits, result, count, fc1Infact, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else if (mode == CBC_QRCoderMode::sBYTE) { - DecodeByteSegment(&bits, result, count, currentCharacterSetECI, - &byteSegments, byteModeDecode, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else if (mode == CBC_QRCoderMode::sGBK) { - DecodeGBKSegment(&bits, result, count, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else if (mode == CBC_QRCoderMode::sKANJI) { - DecodeKanjiSegment(&bits, result, count, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } else { - e = BCExceptionUnSupportMode; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - } - } - } while (!(mode == CBC_QRCoderMode::sTERMINATOR)); - CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); - tempCd->Init(*bytes, result, byteSegments, ecLevel, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return tempCd; -} -void CBC_QRDecodedBitStreamParser::DecodeGBKSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e) { - CFX_ByteString buffer; - while (count > 0) { - int32_t twoBytes = bits->ReadBits(13, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060); - if (assembledTwoBytes <= 0x0095d) { - assembledTwoBytes += 0x0a1a1; - } else { - assembledTwoBytes += 0x0a6a1; - } - buffer += (uint8_t)(assembledTwoBytes >> 8); - buffer += (uint8_t)assembledTwoBytes; - count--; - } - CBC_UtilCodingConvert::LocaleToUtf8(buffer, result); -} -void CBC_QRDecodedBitStreamParser::DecodeKanjiSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e) { - CFX_ByteString buffer; - while (count > 0) { - int32_t twoBytes = bits->ReadBits(13, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - int32_t assembledTwoBytes = ((twoBytes / 0x0c0) << 8) | (twoBytes % 0x0c0); - if (assembledTwoBytes <= 0x01f00) { - assembledTwoBytes += 0x08140; - } else { - assembledTwoBytes += 0x0c140; - } - buffer += (uint8_t)(assembledTwoBytes >> 8); - buffer += (uint8_t)assembledTwoBytes; - count--; - } - CBC_UtilCodingConvert::LocaleToUtf8(buffer, result); -} -void CBC_QRDecodedBitStreamParser::DecodeByteSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - CBC_CommonCharacterSetECI* currentCharacterSetECI, - CFX_Int32Array* byteSegments, - int32_t byteModeDecode, - int32_t& e) { - if (count < 0) { - e = BCExceptionNotFound; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - if ((count << 3) > bits->Available()) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - uint8_t* readBytes = FX_Alloc(uint8_t, count); - FXSYS_memset(readBytes, 0x00, count); - for (int32_t i = 0; i < count; i++) { - readBytes[i] = (uint8_t)bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - CFX_ByteString bs(readBytes, count); - result += bs; - FX_Free(readBytes); -} -void CBC_QRDecodedBitStreamParser::DecodeAlphanumericSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - FX_BOOL fac1InEffect, - int32_t& e) { - int32_t start = result.GetLength(); - while (count > 1) { - int32_t nextTwoCharsBits = bits->ReadBits(11, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - BC_FX_ByteString_Append(result, 1, - ALPHANUMERIC_CHARS[nextTwoCharsBits / 45]); - BC_FX_ByteString_Append(result, 1, - ALPHANUMERIC_CHARS[nextTwoCharsBits % 45]); - count -= 2; - } - if (count == 1) { - int32_t itemp = bits->ReadBits(6, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[itemp]); - } - if (fac1InEffect) { - for (int32_t i = start; i < result.GetLength(); i++) { - if (result[i] == '%') { - if ((i < result.GetLength() - 1) && result[i + 1] == '%') { - result.Delete(i + 1, 1); - } else { - result.SetAt(i, (FX_CHAR)0x1d); - } - } - } - } -} -void CBC_QRDecodedBitStreamParser::DecodeNumericSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e) { - while (count >= 3) { - int32_t threeDigitsBits = bits->ReadBits(10, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (threeDigitsBits >= 1000) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - BC_FX_ByteString_Append(result, 1, - ALPHANUMERIC_CHARS[threeDigitsBits / 100]); - BC_FX_ByteString_Append(result, 1, - ALPHANUMERIC_CHARS[(threeDigitsBits / 10) % 10]); - BC_FX_ByteString_Append(result, 1, - ALPHANUMERIC_CHARS[threeDigitsBits % 10]); - count -= 3; - } - if (count == 2) { - int32_t twoDigitBits = bits->ReadBits(7, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (twoDigitBits >= 100) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits / 10]); - BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits % 10]); - } else if (count == 1) { - int32_t digitBits = bits->ReadBits(4, e); - BC_EXCEPTION_CHECK_ReturnVoid(e); - if (digitBits >= 10) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[digitBits]); - } -} -const CFX_ByteString CBC_QRDecodedBitStreamParser::GuessEncoding( - CFX_ByteArray* bytes) { - return *UTF_8; -} -int32_t CBC_QRDecodedBitStreamParser::ParseECIValue(CBC_CommonBitSource* bits, - int32_t& e) { - int32_t firstByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - if ((firstByte & 0x80) == 0) { - return firstByte & 0x7f; - } else if ((firstByte & 0xc0) == 0x80) { - int32_t secondByte = bits->ReadBits(8, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - return ((firstByte & 0x3f) << 8) | secondByte; - } else if ((firstByte & 0xe0) == 0xc0) { - int32_t secondThirdByte = bits->ReadBits(16, e); - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - return ((firstByte & 0x1f) << 16) | secondThirdByte; - } - e = BCExceptionBadECI; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - return 0; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h b/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h deleted file mode 100644 index ca64ab0fb0..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h +++ /dev/null @@ -1,59 +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_SRC_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ - -class CBC_CommonDecoderResult; -class CBC_QRCoderErrorCorrectionLevel; -class CBC_CommonBitSource; -class CBC_QRCoderVersion; -class CBC_CommonCharacterSetECI; -class CBC_QRDecodedBitStreamParser { - private: - static const FX_CHAR ALPHANUMERIC_CHARS[45]; - static const FX_CHAR* UTF_8; - CBC_QRDecodedBitStreamParser(); - - public: - virtual ~CBC_QRDecodedBitStreamParser(); - static CBC_CommonDecoderResult* Decode( - CFX_ByteArray* bytes, - CBC_QRCoderVersion* version, - CBC_QRCoderErrorCorrectionLevel* ecLevel, - int32_t byteModeDecode, - int32_t& e); - - static const CFX_ByteString GuessEncoding(CFX_ByteArray* bytes); - static int32_t ParseECIValue(CBC_CommonBitSource* bits, int32_t& e); - static void DecodeGBKSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e); - static void DecodeKanjiSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e); - static void DecodeNumericSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - int32_t& e); - static void DecodeAlphanumericSegment(CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - FX_BOOL fac1InEffect, - int32_t& e); - static void DecodeByteSegment( - CBC_CommonBitSource* bits, - CFX_ByteString& result, - int32_t count, - CBC_CommonCharacterSetECI* currentCharacterSetECI, - CFX_Int32Array* byteSegments, - int32_t byteModeDecode, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp deleted file mode 100644 index 72ce42fc4c..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp +++ /dev/null @@ -1,278 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" - -#include <algorithm> -#include <memory> - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" - -CBC_QRDetector::CBC_QRDetector(CBC_CommonBitMatrix* image) : m_image(image) {} -CBC_QRDetector::~CBC_QRDetector() {} -CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { - CBC_QRFinderPatternFinder finder(m_image); - std::unique_ptr<CBC_QRFinderPatternInfo> info(finder.Find(hints, e)); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRDetectorResult* qdr = ProcessFinderPatternInfo(info.get(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qdr; -} -CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( - CBC_QRFinderPatternInfo* info, - int32_t& e) { - std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft()); - std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight()); - std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft()); - FX_FLOAT moduleSize = - CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); - if (moduleSize < 1.0f) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t dimension = ComputeDimension(topLeft.get(), topRight.get(), - bottomLeft.get(), moduleSize, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_QRCoderVersion* provisionalVersion = - CBC_QRCoderVersion::GetProvisionalVersionForDimension(dimension, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - int32_t modulesBetweenFPCenters = - provisionalVersion->GetDimensionForVersion() - 7; - CBC_QRAlignmentPattern* alignmentPattern = NULL; - if (provisionalVersion->GetAlignmentPatternCenters()->GetSize() > 0) { - FX_FLOAT bottomRightX = - topRight->GetX() - topLeft->GetX() + bottomLeft->GetX(); - FX_FLOAT bottomRightY = - topRight->GetY() - topLeft->GetY() + bottomLeft->GetY(); - FX_FLOAT correctionToTopLeft = - 1.0f - 3.0f / (FX_FLOAT)modulesBetweenFPCenters; - FX_FLOAT xtemp = (topLeft->GetX() + - correctionToTopLeft * (bottomRightX - topLeft->GetX())); - int32_t estAlignmentX = (int32_t)xtemp; - FX_FLOAT ytemp = (topLeft->GetY() + - correctionToTopLeft * (bottomRightY - topLeft->GetY())); - int32_t estAlignmentY = (int32_t)ytemp; - for (int32_t i = 4; i <= 16; i <<= 1) { - CBC_QRAlignmentPattern* temp = FindAlignmentInRegion( - moduleSize, estAlignmentX, estAlignmentY, (FX_FLOAT)i, e); - alignmentPattern = temp; - break; - } - } - CBC_CommonBitMatrix* bits = - 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()); - points->Add(alignmentPattern); - } - return new CBC_QRDetectorResult(bits, points); -} -CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid( - CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* alignmentPattern, - int32_t dimension, - int32_t& e) { - FX_FLOAT dimMinusThree = (FX_FLOAT)dimension - 3.5f; - FX_FLOAT bottomRightX; - FX_FLOAT bottomRightY; - FX_FLOAT sourceBottomRightX; - FX_FLOAT sourceBottomRightY; - if (alignmentPattern) { - bottomRightX = alignmentPattern->GetX(); - bottomRightY = alignmentPattern->GetY(); - sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f; - } else { - bottomRightX = (topRight->GetX() - topLeft->GetX()) + bottomLeft->GetX(); - bottomRightY = (topRight->GetY() - topLeft->GetY()) + bottomLeft->GetY(); - sourceBottomRightX = sourceBottomRightY = dimMinusThree; - } - CBC_QRGridSampler& sampler = CBC_QRGridSampler::GetInstance(); - CBC_CommonBitMatrix* cbm = sampler.SampleGrid( - image, dimension, dimension, 3.5f, 3.5f, dimMinusThree, 3.5f, - sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree, - topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(), - bottomRightX, bottomRightY, bottomLeft->GetX(), bottomLeft->GetY(), e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return cbm; -} -int32_t CBC_QRDetector::ComputeDimension(CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft, - FX_FLOAT moduleSize, - int32_t& e) { - int32_t tltrCentersDimension = Round( - CBC_QRFinderPatternFinder::Distance(topLeft, topRight) / moduleSize); - int32_t tlblCentersDimension = Round( - CBC_QRFinderPatternFinder::Distance(topLeft, bottomLeft) / moduleSize); - int32_t dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; - switch (dimension & 0x03) { - case 0: - dimension++; - break; - case 2: - dimension--; - break; - case 3: { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, 0); - } - } - return dimension; -} -FX_FLOAT CBC_QRDetector::CalculateModuleSize(CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft) { - return (CalculateModuleSizeOneWay(topLeft, topRight) + - CalculateModuleSizeOneWay(topLeft, bottomLeft)) / - 2.0f; -} -FX_FLOAT CBC_QRDetector::CalculateModuleSizeOneWay( - CBC_ResultPoint* pattern, - CBC_ResultPoint* otherPattern) { - FX_FLOAT moduleSizeEst1 = SizeOfBlackWhiteBlackRunBothWays( - (int32_t)pattern->GetX(), (int32_t)pattern->GetY(), - (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY()); - FX_FLOAT moduleSizeEst2 = SizeOfBlackWhiteBlackRunBothWays( - (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY(), - (int32_t)pattern->GetX(), (int32_t)pattern->GetY()); - if (FXSYS_isnan(moduleSizeEst1)) { - return moduleSizeEst2; - } - if (FXSYS_isnan(moduleSizeEst2)) { - return moduleSizeEst1; - } - return (moduleSizeEst1 + moduleSizeEst2) / 14.0f; -} -int32_t CBC_QRDetector::Round(FX_FLOAT d) { - return (int32_t)(d + 0.5f); -} -FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRunBothWays(int32_t fromX, - int32_t fromY, - int32_t toX, - int32_t toY) { - FX_FLOAT result = SizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY); - int32_t otherToX = fromX - (toX - fromX); - if (otherToX < 0) { - otherToX = -1; - } else if (otherToX >= m_image->GetWidth()) { - otherToX = m_image->GetWidth(); - } - int32_t otherToY = fromY - (toY - fromY); - if (otherToY < 0) { - otherToY = -1; - } else if (otherToY >= m_image->GetHeight()) { - otherToY = m_image->GetHeight(); - } - result += SizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); - return result - 1.0f; -} -FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRun(int32_t fromX, - int32_t fromY, - int32_t toX, - int32_t toY) { - FX_BOOL steep = FXSYS_abs(toY - fromY) > FXSYS_abs(toX - fromX); - if (steep) { - int32_t temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - int32_t dx = FXSYS_abs(toX - fromX); - int32_t dy = FXSYS_abs(toY - fromY); - int32_t error = -dx >> 1; - int32_t ystep = fromY < toY ? 1 : -1; - int32_t xstep = fromX < toX ? 1 : -1; - int32_t state = 0; - for (int32_t x = fromX, y = fromY; x != toX; x += xstep) { - int32_t realX = steep ? y : x; - int32_t realY = steep ? x : y; - if (state == 1) { - if (m_image->Get(realX, realY)) { - state++; - } - } else { - if (!m_image->Get(realX, realY)) { - state++; - } - } - if (state == 3) { - int32_t diffX = x - fromX; - int32_t diffY = y - fromY; - return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY)); - } - error += dy; - if (error > 0) { - y += ystep; - error -= dx; - } - } - int32_t diffX = toX - fromX; - int32_t diffY = toY - fromY; - return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY)); -} -CBC_QRAlignmentPattern* CBC_QRDetector::FindAlignmentInRegion( - FX_FLOAT overallEstModuleSize, - int32_t estAlignmentX, - int32_t estAlignmentY, - FX_FLOAT allowanceFactor, - int32_t& e) { - int32_t allowance = (int32_t)(allowanceFactor * overallEstModuleSize); - int32_t alignmentAreaLeftX = std::max(0, estAlignmentX - allowance); - int32_t alignmentAreaRightX = - std::min(m_image->GetWidth() - 1, estAlignmentX + allowance); - if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - int32_t alignmentAreaTopY = std::max(0, estAlignmentY - allowance); - int32_t alignmentAreaBottomY = - std::min(m_image->GetHeight() - 1, estAlignmentY + allowance); - CBC_QRAlignmentPatternFinder alignmentFinder( - m_image, alignmentAreaLeftX, alignmentAreaTopY, - alignmentAreaRightX - alignmentAreaLeftX, - alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize); - CBC_QRAlignmentPattern* qap = alignmentFinder.Find(e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - return qap; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h b/xfa/src/fxbarcode/qrcode/BC_QRDetector.h deleted file mode 100644 index 67cbeb44d6..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h +++ /dev/null @@ -1,63 +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_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_ResultPoint; -class CBC_CommonBitMatrix; -class CBC_QRDetectorResult; -class CBC_QRFinderPatternInfo; -class CBC_QRAlignmentPattern; - -class CBC_QRDetector { - private: - CBC_CommonBitMatrix* m_image; - - public: - CBC_QRDetector(CBC_CommonBitMatrix* image); - virtual ~CBC_QRDetector(); - - CBC_CommonBitMatrix* GetImage(); - CBC_QRDetectorResult* Detect(int32_t hints, int32_t& e); - CBC_QRDetectorResult* ProcessFinderPatternInfo(CBC_QRFinderPatternInfo* info, - int32_t& e); - FX_FLOAT CalculateModuleSize(CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft); - FX_FLOAT CalculateModuleSizeOneWay(CBC_ResultPoint* pattern, - CBC_ResultPoint* otherPattern); - FX_FLOAT SizeOfBlackWhiteBlackRunBothWays(int32_t fromX, - int32_t fromY, - int32_t toX, - int32_t toY); - FX_FLOAT SizeOfBlackWhiteBlackRun(int32_t fromX, - int32_t fromY, - int32_t toX, - int32_t toY); - CBC_QRAlignmentPattern* FindAlignmentInRegion(FX_FLOAT overallEstModuleSize, - int32_t estAlignmentX, - int32_t estAlignmentY, - FX_FLOAT allowanceFactor, - int32_t& e); - static int32_t Round(FX_FLOAT d); - static int32_t ComputeDimension(CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft, - FX_FLOAT moduleSize, - int32_t& e); - static CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, - CBC_ResultPoint* topLeft, - CBC_ResultPoint* topRight, - CBC_ResultPoint* bottomLeft, - CBC_ResultPoint* alignmentPattern, - int32_t dimension, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.cpp deleted file mode 100644 index df83d35be7..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.cpp +++ /dev/null @@ -1,43 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" - -CBC_QRDetectorResult::CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, - CFX_PtrArray* 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; -} -CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() { - return m_bits; -} -CFX_PtrArray* CBC_QRDetectorResult::GetPoints() { - return m_points; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h b/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h deleted file mode 100644 index e2397db7ef..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h +++ /dev/null @@ -1,26 +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_SRC_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; - -class CBC_QRDetectorResult { - private: - CBC_CommonBitMatrix* m_bits; - CFX_PtrArray* m_points; - - public: - CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points); - virtual ~CBC_QRDetectorResult(); - CBC_CommonBitMatrix* GetBits(); - CFX_PtrArray* GetPoints(); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.cpp b/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.cpp deleted file mode 100644 index b4482cae1d..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.cpp +++ /dev/null @@ -1,68 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" - -CBC_QRFinderPattern::CBC_QRFinderPattern(FX_FLOAT x, - FX_FLOAT posY, - FX_FLOAT estimatedModuleSize) - : CBC_ResultPoint(x, posY), - m_estimatedModuleSize(estimatedModuleSize), - m_count(1) {} -CBC_QRFinderPattern::~CBC_QRFinderPattern() { - m_count = 0; - m_x = 0.0f; - m_y = 0.0f; - m_estimatedModuleSize = 0.0f; -} -CBC_QRFinderPattern* CBC_QRFinderPattern::Clone() { - CBC_QRFinderPattern* temp = - new CBC_QRFinderPattern(m_x, m_y, m_estimatedModuleSize); - temp->m_count = m_count; - return temp; -} -FX_FLOAT CBC_QRFinderPattern::GetEstimatedModuleSize() { - return m_estimatedModuleSize; -} -int32_t CBC_QRFinderPattern::GetCount() { - return m_count; -} -void CBC_QRFinderPattern::IncrementCount() { - m_count++; -} -FX_BOOL CBC_QRFinderPattern::AboutEquals(FX_FLOAT moduleSize, - FX_FLOAT i, - FX_FLOAT j) { - if ((fabs(i - GetY()) <= moduleSize) && (fabs(j - GetX()) <= moduleSize)) { - FX_FLOAT moduleSizeDiff = fabs(moduleSize - m_estimatedModuleSize); - return (moduleSizeDiff <= 1.0f) || - (moduleSizeDiff / m_estimatedModuleSize <= 1.0f); - } - return false; -} -FX_FLOAT CBC_QRFinderPattern::GetX() { - return m_x; -} -FX_FLOAT CBC_QRFinderPattern::GetY() { - return m_y; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h b/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h deleted file mode 100644 index 3e71034de3..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.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_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ - -class CBC_ResultPoint; -class CBC_QRFinderPattern; -class CBC_QRFinderPattern : public CBC_ResultPoint { - private: - FX_FLOAT m_estimatedModuleSize; - int32_t m_count; - - public: - CBC_QRFinderPattern(FX_FLOAT x, FX_FLOAT posY, FX_FLOAT estimatedModuleSize); - virtual ~CBC_QRFinderPattern(); - - int32_t GetCount(); - FX_FLOAT GetX(); - FX_FLOAT GetY(); - FX_FLOAT GetEstimatedModuleSize(); - void IncrementCount(); - FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j); - CBC_QRFinderPattern* Clone(); -}; -typedef CBC_QRFinderPattern FinderPattern; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp deleted file mode 100644 index f5a3c7aead..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp +++ /dev/null @@ -1,477 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" - -#include <memory> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxbarcode/BC_ResultPoint.h" -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" -#include "xfa/src/fxbarcode/utils.h" - -const int32_t CBC_QRFinderPatternFinder::CENTER_QUORUM = 2; -const int32_t CBC_QRFinderPatternFinder::MIN_SKIP = 3; -const int32_t CBC_QRFinderPatternFinder::MAX_MODULES = 57; -const int32_t CBC_QRFinderPatternFinder::INTEGER_MATH_SHIFT = 8; - -CBC_QRFinderPatternFinder::CBC_QRFinderPatternFinder( - CBC_CommonBitMatrix* image) { - m_image = image; - 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(); -} -class ClosestToAverageComparator { - private: - FX_FLOAT m_averageModuleSize; - - public: - ClosestToAverageComparator(FX_FLOAT averageModuleSize) - : m_averageModuleSize(averageModuleSize) {} - int32_t operator()(FinderPattern* a, FinderPattern* b) { - FX_FLOAT dA = - (FX_FLOAT)fabs(a->GetEstimatedModuleSize() - m_averageModuleSize); - FX_FLOAT dB = - (FX_FLOAT)fabs(b->GetEstimatedModuleSize() - m_averageModuleSize); - return dA < dB ? -1 : dA > dB ? 1 : 0; - } -}; -class CenterComparator { - public: - int32_t operator()(FinderPattern* a, FinderPattern* b) { - return b->GetCount() - a->GetCount(); - } -}; -CBC_CommonBitMatrix* CBC_QRFinderPatternFinder::GetImage() { - return m_image; -} -CFX_Int32Array& CBC_QRFinderPatternFinder::GetCrossCheckStateCount() { - m_crossCheckStateCount[0] = 0; - m_crossCheckStateCount[1] = 0; - m_crossCheckStateCount[2] = 0; - m_crossCheckStateCount[3] = 0; - m_crossCheckStateCount[4] = 0; - return m_crossCheckStateCount; -} -CFX_PtrArray* CBC_QRFinderPatternFinder::GetPossibleCenters() { - return &m_possibleCenters; -} -CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint, - int32_t& e) { - int32_t maxI = m_image->GetHeight(); - int32_t maxJ = m_image->GetWidth(); - int32_t iSkip = (3 * maxI) / (4 * MAX_MODULES); - if (iSkip < MIN_SKIP || 0) { - iSkip = MIN_SKIP; - } - FX_BOOL done = FALSE; - CFX_Int32Array stateCount; - stateCount.SetSize(5); - for (int32_t i = iSkip - 1; i < maxI && !done; i += iSkip) { - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - int32_t currentState = 0; - for (int32_t j = 0; j < maxJ; j++) { - if (m_image->Get(j, i)) { - if ((currentState & 1) == 1) { - currentState++; - } - stateCount[currentState]++; - } else { - if ((currentState & 1) == 0) { - if (currentState == 4) { - if (FoundPatternCross(stateCount)) { - FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, j); - if (confirmed) { - iSkip = 2; - if (m_hasSkipped) { - done = HaveMultiplyConfirmedCenters(); - } else { - int32_t rowSkip = FindRowSkip(); - if (rowSkip > stateCount[2]) { - i += rowSkip - stateCount[2] - iSkip; - j = maxJ - 1; - } - } - } else { - do { - j++; - } while (j < maxJ && !m_image->Get(j, i)); - j--; - } - currentState = 0; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - stateCount[3] = 0; - stateCount[4] = 0; - } else { - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - currentState = 3; - } - } else { - stateCount[++currentState]++; - } - } else { - stateCount[currentState]++; - } - } - } - if (FoundPatternCross(stateCount)) { - FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, maxJ); - if (confirmed) { - iSkip = stateCount[0]; - if (m_hasSkipped) { - done = HaveMultiplyConfirmedCenters(); - } - } - } - } - std::unique_ptr<CFX_PtrArray> 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; - if (bcDistance >= abDistance && bcDistance >= acDistance) { - topLeft = (CBC_QRFinderPattern*)(*patterns)[0]; - topRight = (CBC_QRFinderPattern*)(*patterns)[1]; - bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2]; - } else if (acDistance >= bcDistance && acDistance >= abDistance) { - topLeft = (CBC_QRFinderPattern*)(*patterns)[1]; - topRight = (CBC_QRFinderPattern*)(*patterns)[0]; - bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2]; - } else { - topLeft = (CBC_QRFinderPattern*)(*patterns)[2]; - topRight = (CBC_QRFinderPattern*)(*patterns)[0]; - bottomLeft = (CBC_QRFinderPattern*)(*patterns)[1]; - } - if ((bottomLeft->GetY() - topLeft->GetY()) * - (topRight->GetX() - topLeft->GetX()) < - (bottomLeft->GetX() - topLeft->GetX()) * - (topRight->GetY() - topLeft->GetY())) { - CBC_QRFinderPattern* temp = topRight; - topRight = bottomLeft; - bottomLeft = temp; - } - (*patterns)[0] = bottomLeft; - (*patterns)[1] = topLeft; - (*patterns)[2] = topRight; -} -FX_FLOAT CBC_QRFinderPatternFinder::Distance(CBC_ResultPoint* point1, - CBC_ResultPoint* point2) { - FX_FLOAT dx = point1->GetX() - point2->GetX(); - FX_FLOAT dy = point1->GetY() - point2->GetY(); - return (FX_FLOAT)FXSYS_sqrt(dx * dx + dy * dy); -} -FX_FLOAT CBC_QRFinderPatternFinder::CenterFromEnd( - const CFX_Int32Array& stateCount, - int32_t end) { - return (FX_FLOAT)(end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; -} -FX_BOOL CBC_QRFinderPatternFinder::FoundPatternCross( - const CFX_Int32Array& stateCount) { - int32_t totalModuleSize = 0; - for (int32_t i = 0; i < 5; i++) { - int32_t count = stateCount[i]; - if (count == 0) { - return FALSE; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) { - return FALSE; - } - int32_t moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; - int32_t maxVariance = moduleSize / 2; - return FXSYS_abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < - maxVariance && - FXSYS_abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < - maxVariance && - FXSYS_abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < - 3 * maxVariance && - FXSYS_abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < - maxVariance && - FXSYS_abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < - maxVariance; -} -FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckVertical( - int32_t startI, - int32_t centerJ, - int32_t maxCount, - int32_t originalStateCountTotal) { - CBC_CommonBitMatrix* image = m_image; - int32_t maxI = image->GetHeight(); - CFX_Int32Array& stateCount = GetCrossCheckStateCount(); - int32_t i = startI; - while (i >= 0 && image->Get(centerJ, i)) { - stateCount[2]++; - i--; - } - if (i < 0) { - return FXSYS_nan(); - } - while (i >= 0 && !image->Get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - if (i < 0 || stateCount[1] > maxCount) { - return FXSYS_nan(); - } - while (i >= 0 && image->Get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return FXSYS_nan(); - } - i = startI + 1; - while (i < maxI && image->Get(centerJ, i)) { - stateCount[2]++; - i++; - } - if (i == maxI) { - return FXSYS_nan(); - } - while (i < maxI && !image->Get(centerJ, i) && stateCount[3] < maxCount) { - stateCount[3]++; - i++; - } - if (i == maxI || stateCount[3] >= maxCount) { - return FXSYS_nan(); - } - while (i < maxI && image->Get(centerJ, i) && stateCount[4] < maxCount) { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) { - return FXSYS_nan(); - } - int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + - stateCount[3] + stateCount[4]; - if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >= - originalStateCountTotal) { - return FXSYS_nan(); - } - return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i) - : FXSYS_nan(); -} -FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckHorizontal( - int32_t startJ, - int32_t centerI, - int32_t maxCount, - int32_t originalStateCountTotal) { - CBC_CommonBitMatrix* image = m_image; - int32_t maxJ = image->GetWidth(); - CFX_Int32Array& stateCount = GetCrossCheckStateCount(); - int32_t j = startJ; - while (j >= 0 && image->Get(j, centerI)) { - stateCount[2]++; - j--; - } - if (j < 0) { - return FXSYS_nan(); - } - while (j >= 0 && !image->Get(j, centerI) && stateCount[1] <= maxCount) { - stateCount[1]++; - j--; - } - if (j < 0 || stateCount[1] > maxCount) { - return FXSYS_nan(); - } - while (j >= 0 && image->Get(j, centerI) && stateCount[0] <= maxCount) { - stateCount[0]++; - j--; - } - if (stateCount[0] > maxCount) { - return FXSYS_nan(); - } - j = startJ + 1; - while (j < maxJ && image->Get(j, centerI)) { - stateCount[2]++; - j++; - } - if (j == maxJ) { - return FXSYS_nan(); - } - while (j < maxJ && !image->Get(j, centerI) && stateCount[3] < maxCount) { - stateCount[3]++; - j++; - } - if (j == maxJ || stateCount[3] >= maxCount) { - return FXSYS_nan(); - } - while (j < maxJ && image->Get(j, centerI) && stateCount[4] < maxCount) { - stateCount[4]++; - j++; - } - if (stateCount[4] >= maxCount) { - return FXSYS_nan(); - } - int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + - stateCount[3] + stateCount[4]; - if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >= - originalStateCountTotal) { - return FXSYS_nan(); - } - return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, j) - : FXSYS_nan(); -} -FX_BOOL CBC_QRFinderPatternFinder::HandlePossibleCenter( - const CFX_Int32Array& stateCount, - int32_t i, - int32_t j) { - int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + - stateCount[3] + stateCount[4]; - FX_FLOAT centerJ = CenterFromEnd(stateCount, j); - FX_FLOAT centerI = - CrossCheckVertical(i, (int32_t)centerJ, stateCount[2], stateCountTotal); - if (!FXSYS_isnan(centerI)) { - centerJ = CrossCheckHorizontal((int32_t)centerJ, (int32_t)centerI, - stateCount[2], stateCountTotal); - if (!FXSYS_isnan(centerJ)) { - FX_FLOAT estimatedModuleSize = (FX_FLOAT)stateCountTotal / 7.0f; - 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]); - if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) { - center->IncrementCount(); - found = TRUE; - break; - } - } - if (!found) { - m_possibleCenters.Add( - new CBC_QRFinderPattern(centerJ, centerI, estimatedModuleSize)); - } - return TRUE; - } - } - return FALSE; -} -int32_t CBC_QRFinderPatternFinder::FindRowSkip() { - int32_t max = m_possibleCenters.GetSize(); - if (max <= 1) { - return 0; - } - FinderPattern* firstConfirmedCenter = NULL; - for (int32_t i = 0; i < max; i++) { - CBC_QRFinderPattern* center = (CBC_QRFinderPattern*)m_possibleCenters[i]; - if (center->GetCount() >= CENTER_QUORUM) { - if (firstConfirmedCenter == NULL) { - firstConfirmedCenter = center; - } else { - m_hasSkipped = TRUE; - return (int32_t)((fabs(firstConfirmedCenter->GetX() - center->GetX()) - - fabs(firstConfirmedCenter->GetY() - center->GetY())) / - 2); - } - } - } - return 0; -} -FX_BOOL CBC_QRFinderPatternFinder::HaveMultiplyConfirmedCenters() { - int32_t confirmedCount = 0; - FX_FLOAT totalModuleSize = 0.0f; - int32_t max = m_possibleCenters.GetSize(); - int32_t i; - for (i = 0; i < max; i++) { - CBC_QRFinderPattern* pattern = (CBC_QRFinderPattern*)m_possibleCenters[i]; - if (pattern->GetCount() >= CENTER_QUORUM) { - confirmedCount++; - totalModuleSize += pattern->GetEstimatedModuleSize(); - } - } - if (confirmedCount < 3) { - return FALSE; - } - 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]; - 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) { - int32_t startSize = m_possibleCenters.GetSize(); - if (m_possibleCenters.GetSize() < 3) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - } - 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(); - } - 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]; - if (fabs(pattern->GetEstimatedModuleSize() - average) > 0.2f * average) { - delete pattern; - m_possibleCenters.RemoveAt(j); - j--; - } - } - } - if (m_possibleCenters.GetSize() > 3) { - BC_FX_PtrArray_Sort(m_possibleCenters, centerComparator); - } - CFX_PtrArray* vec = new CFX_PtrArray(); - 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(); - return vec; -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h deleted file mode 100644 index b7640491f0..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.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_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; -class CBC_QRFinderPattern; -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(); - int32_t FindRowSkip(); - CBC_CommonBitMatrix* GetImage(); - CBC_QRFinderPatternInfo* Find(int32_t hint, int32_t& e); - - CFX_Int32Array& GetCrossCheckStateCount(); - CFX_PtrArray* GetPossibleCenters(); - CFX_PtrArray* SelectBestpatterns(int32_t& e); - - FX_BOOL HandlePossibleCenter(const CFX_Int32Array& stateCount, - int32_t i, - int32_t j); - FX_BOOL HaveMultiplyConfirmedCenters(); - FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end); - FX_FLOAT CrossCheckVertical(int32_t startI, - int32_t centerJ, - int32_t maxCount, - int32_t originalStateCountTotal); - FX_FLOAT CrossCheckHorizontal(int32_t startJ, - int32_t CenterI, - int32_t maxCOunt, - int32_t originalStateCountTotal); - static void OrderBestPatterns(CFX_PtrArray* patterns); - static FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount); - static FX_FLOAT Distance(CBC_ResultPoint* point1, CBC_ResultPoint* point2); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp deleted file mode 100644 index 87f0fd072e..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp +++ /dev/null @@ -1,139 +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 -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" - -#include <memory> - -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" -#include "xfa/src/fxbarcode/utils.h" - -CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler; - -CBC_QRGridSampler::CBC_QRGridSampler() {} -CBC_QRGridSampler::~CBC_QRGridSampler() {} -CBC_QRGridSampler& CBC_QRGridSampler::GetInstance() { - return m_gridSampler; -} -void CBC_QRGridSampler::CheckAndNudgePoints(CBC_CommonBitMatrix* image, - CFX_FloatArray* points, - int32_t& e) { - int32_t width = image->GetWidth(); - int32_t height = image->GetHeight(); - FX_BOOL nudged = TRUE; - int32_t offset; - for (offset = 0; offset < points->GetSize() && nudged; offset += 2) { - int32_t x = (int32_t)(*points)[offset]; - int32_t y = (int32_t)(*points)[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - nudged = FALSE; - if (x == -1) { - (*points)[offset] = 0.0f; - nudged = TRUE; - } else if (x == width) { - (*points)[offset] = (FX_FLOAT)(width - 1); - nudged = TRUE; - } - if (y == -1) { - (*points)[offset + 1] = 0.0f; - nudged = TRUE; - } else if (y == height) { - (*points)[offset + 1] = (FX_FLOAT)(height - 1); - nudged = TRUE; - } - } - nudged = TRUE; - for (offset = (*points).GetSize() - 2; offset >= 0 && nudged; offset -= 2) { - int32_t x = (int32_t)(*points)[offset]; - int32_t y = (int32_t)(*points)[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) { - e = BCExceptionRead; - BC_EXCEPTION_CHECK_ReturnVoid(e); - } - nudged = FALSE; - if (x == -1) { - (*points)[offset] = 0.0f; - nudged = TRUE; - } else if (x == width) { - (*points)[offset] = (FX_FLOAT)(width - 1); - nudged = TRUE; - } - if (y == -1) { - (*points)[offset + 1] = 0.0f; - nudged = TRUE; - } else if (y == height) { - (*points)[offset + 1] = (FX_FLOAT)(height - 1); - nudged = TRUE; - } - } -} -CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image, - int32_t dimensionX, - int32_t dimensionY, - FX_FLOAT p1ToX, - FX_FLOAT p1ToY, - FX_FLOAT p2ToX, - FX_FLOAT p2ToY, - FX_FLOAT p3ToX, - FX_FLOAT p3ToY, - FX_FLOAT p4ToX, - FX_FLOAT p4ToY, - FX_FLOAT p1FromX, - FX_FLOAT p1FromY, - FX_FLOAT p2FromX, - FX_FLOAT p2FromY, - FX_FLOAT p3FromX, - FX_FLOAT p3FromY, - FX_FLOAT p4FromX, - FX_FLOAT p4FromY, - int32_t& e) { - std::unique_ptr<CBC_CommonPerspectiveTransform> transform( - CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral( - p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, - p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)); - std::unique_ptr<CBC_CommonBitMatrix> bits(new CBC_CommonBitMatrix()); - bits->Init(dimensionX, dimensionY); - CFX_FloatArray points; - points.SetSize(dimensionX << 1); - for (int32_t y = 0; y < dimensionY; y++) { - int32_t max = points.GetSize(); - FX_FLOAT iValue = (FX_FLOAT)(y + 0.5f); - int32_t x; - for (x = 0; x < max; x += 2) { - points[x] = (FX_FLOAT)((x >> 1) + 0.5f); - points[x + 1] = iValue; - } - transform->TransformPoints(&points); - CheckAndNudgePoints(image, &points, e); - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - for (x = 0; x < max; x += 2) { - if (image->Get((int32_t)points[x], (int32_t)points[x + 1])) { - bits->Set(x >> 1, y); - } - } - } - return bits.release(); -} diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h deleted file mode 100644 index ce75ac8d05..0000000000 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.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_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ -#define XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ - -#include "core/include/fxcrt/fx_basic.h" - -class CBC_CommonBitMatrix; - -class CBC_QRGridSampler { - private: - static CBC_QRGridSampler m_gridSampler; - - public: - CBC_QRGridSampler(); - virtual ~CBC_QRGridSampler(); - virtual CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image, - int32_t dimensionX, - int32_t dimensionY, - FX_FLOAT p1ToX, - FX_FLOAT p1ToY, - FX_FLOAT p2ToX, - FX_FLOAT p2ToY, - FX_FLOAT p3ToX, - FX_FLOAT p3ToY, - FX_FLOAT p4ToX, - FX_FLOAT p4ToY, - FX_FLOAT p1FromX, - FX_FLOAT p1FromY, - FX_FLOAT p2FromX, - FX_FLOAT p2FromY, - FX_FLOAT p3FromX, - FX_FLOAT p3FromY, - FX_FLOAT p4FromX, - FX_FLOAT p4FromY, - int32_t& e); - - static CBC_QRGridSampler& GetInstance(); - static void CheckAndNudgePoints(CBC_CommonBitMatrix* image, - CFX_FloatArray* points, - int32_t& e); -}; - -#endif // XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ diff --git a/xfa/src/fxbarcode/utils.h b/xfa/src/fxbarcode/utils.h deleted file mode 100644 index 23830d5656..0000000000 --- a/xfa/src/fxbarcode/utils.h +++ /dev/null @@ -1,183 +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_SRC_FXBARCODE_UTILS_H_ -#define XFA_SRC_FXBARCODE_UTILS_H_ - -#include "core/include/fxcrt/fx_basic.h" - -typedef CFX_MapPtrTemplate<void*, int32_t> CFX_PtrToInt32; -FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString& dst, - FX_DWORD first, - FX_DWORD last, - int32_t count, - 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> -#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ - _FX_OS_ == _FX_IOS_) -#include <limits.h> -#endif -#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) -#define FXSYS_isnan(x) _isnan(x) -#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_) -#include <cmath> -#define FXSYS_isnan(x) std::isnan(x) -#elif(_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_) -#include <math.h> -#define FXSYS_isnan(x) isnan(x) -#endif -#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) -#define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN()) -#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ - _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_) -#define FXSYS_nan() NAN -#endif -enum BCFORMAT { - BCFORMAT_UNSPECIFY = -1, - BCFORMAT_CODABAR, - BCFORMAT_CODE_39, - BCFORMAT_CODE_128, - BCFORMAT_CODE_128B, - BCFORMAT_CODE_128C, - BCFORMAT_EAN_8, - BCFORMAT_UPC_A, - BCFORMAT_EAN_13, - BCFORMAT_PDF_417, - BCFORMAT_DATAMATRIX, - BCFORMAT_QR_CODE -}; -#define BCFORMAT_ECLEVEL_L 0 -#define BCFORMAT_ECLEVEL_M 1 -#define BCFORMAT_ECLEVEL_Q 2 -#define BCFORMAT_ECLEVEL_H 3 -#include <ctype.h> -#define FXSYS_IntMax INT_MAX -#define FXSYS_Isdigit isdigit -#define BCExceptionNO 0 -#define BCExceptionNotFound 1 -#define BCExceptionEndLessThanStart 2 -#define BCExceptionUnknownDecoder 3 -#define BCExceptionRotateNotSupported 4 -#define BCExceptionHeightAndWidthMustBeAtLeast1 5 -#define BCExceptionRegionMustFitInsideMatrix 6 -#define BCExceptionCanNotCallGetDimensionOnNonSquareMatrix 7 -#define BCExceptionFormatException 8 -#define BCExceptionIllegalArgumentMustMatchVersionSize 9 -#define BCExceptionChecksumException 10 -#define BCExceptionIllegalArgumentInvalidFirstDigit 11 -#define BCExceptionIllegalArgumentInvalidSecondDigit 12 -#define BCExceptionRuntimeDecodingInvalidISO_IEC 13 -#define BCExceptionRuntimeDecodingInvalidAlphanumeric 14 -#define BCExceptionLeftAndTopMustBeNonnegative 15 -#define BCExceptionIllegalArgument 16 -#define BCExceptionBadECI 17 -#define BCExceptionUnSupportedBarcode 18 -#define BCExceptionUnSupportedString 19 -#define BCExceptionDigitLengthMustBe8 20 -#define BCExceptionDataCheckException 21 -#define BCExceptionExtractNumberValueFromBitArray 22 -#define BCExceptionRead 23 -#define BCExceptionRequestedRowIsOutSizeTheImage 24 -#define BCExceptionNoContents 26 -#define BCExceptionUnSupportEclevel 27 -#define BCExceptionUnSupportMode 28 -#define BCExceptionReferenceMustBeBetween0And7 29 -#define BCExceptionBadErrorLocation 30 -#define BCExceptionDegreeIsNegative 31 -#define BCExceptionDivideByZero 32 -#define BCExceptionCoefficientsSizeIsNull 33 -#define BCExceptionNoCorrectionBytes 34 -#define BCExceptionNoDataBytesProvided 35 -#define BCExceptionR_I_1IsZero 36 -#define BCExceptionAIsZero 37 -#define BCExceptionIsZero 38 -#define BCExceptionDegreeNotMatchRoots 39 -#define BCExceptionContentsLengthShouldBetween1and80 40 -#define BCExceptionOnlyEncodeCODE_128 41 -#define BCExceptionOnlyEncodeCODE_39 42 -#define BCExceptionOnlyEncodeEAN_13 43 -#define BCExceptionOnlyEncodeEAN_8 44 -#define BCExceptionOnlyEncodeITF 45 -#define BCExceptionDigitLengthShould13 46 -#define BCExceptionDigitLengthMustBe6or8or10or12or14or16or20or24or44 47 -#define BCExceptionOnlyEncodeUPC_A 48 -#define BCExceptionDigitLengthShouldBe12 49 -#define BCExceptionValueMustBeEither0or1 50 -#define BCExceptionReedsolomnDecodeException 51 -#define BCExceptionBadIndexException 52 -#define BCExceptionBadValueException 53 -#define BCExceptionBadNumBitsException 54 -#define BCExceptioncanNotOperatexorOperator 55 -#define BCExceptionVersionMust1_40 56 -#define BCExceptionUnknown 57 -#define BCExceptionNoSuchVersion 58 -#define BCExceptionCannotFindBlockInfo 59 -#define BCExceptionDataTooBig 60 -#define BCExceptionInvalidQRCode 61 -#define BCExceptionDataTooMany 62 -#define BCExceptionBitsNotEqualCacity 63 -#define BCExceptionUnsupportedMode 64 -#define BCExceptionInvalidateCharacter 65 -#define BCExceptionBytesNotMatchOffset 66 -#define BCExceptionSizeInBytesDiffer 67 -#define BCExceptionInvalidateMaskPattern 68 -#define BCExceptionNullPointer 69 -#define BCExceptionBadMask 70 -#define BCExceptionBitSizeNot15 71 -#define BCExceptionBitSizeNot18 72 -#define BCExceptionInvalidateImageData 73 -#define BCExceptionHeight_8BeZero 74 -#define BCExceptionCharacterNotThisMode 75 -#define BCExceptionBitsBytesNotMatch 76 -#define BCExceptionInvalidateData 77 -#define BCExceptionLoadFile 78 -#define BCExceptionPDF417EncodeFail 79 -#define BCExceptionFailToCreateBitmap 80 -#define BCExceptionLoadFontFail 81 -#define BCExceptionOnlyEncodeCODEBAR 82 -#define BCExceptionCodabarShouldStartWithOneOfABCD 83 -#define BCExceptionCodabarShouldEndWithOneOfTNE 84 -#define BCExceptionCodabarEncodeCharsInvalid 85 -#define BCExceptionOnlyEncodeDATAMATRIX 86 -#define BCExceptionCharactersOutsideISO88591Encoding 87 -#define BCExceptionIllegalDataCodewords 88 -#define BCExceptionCannotHandleThisNumberOfDataRegions 89 -#define BCExceptionIllegalStateUnexpectedCase 90 -#define BCExceptionIllegalStateCountMustNotExceed4 91 -#define BCExceptionIllegalStateMessageLengthInvalid 92 -#define BCExceptionIllegalArgumentNotGigits 93 -#define BCExceptionIllegalStateIllegalMode 94 -#define BCExceptionOnlyEncodePDF417 95 -#define BCExceptionNonEncodableCharacterDetected 96 -#define BCExceptionErrorCorrectionLevelMustBeBetween0And8 97 -#define BCExceptionNoRecommendationPossible 98 -#define BCExceptionIllegalArgumentnMustBeAbove0 99 -#define BCExceptionUnableToFitMessageInColumns 100 -#define BCExceptionEncodedMessageContainsTooManyCodeWords 101 -#define BCExceptionBitmapSizeError 102 -#define BCExceptionFormatInstance 102 -#define BCExceptionChecksumInstance 103 -#define BCExceptiontNotFoundInstance 104 -#define BCExceptionNotFoundInstance 105 -#define BCExceptionCannotMetadata 106 -#define TWO_DIGIT_DATA_LENGTH_SIZE 24 -#define THREE_DIGIT_DATA_LENGTH_SIZE 23 -#define THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH_SIZE 57 -#define FOUR_DIGIT_DATA_LENGTH_SIZE 17 -#define BC_EXCEPTION_CHECK_ReturnVoid(e) \ - if (e != BCExceptionNO) \ - return; -#define BC_EXCEPTION_CHECK_ReturnValue(e, v) \ - if (e != BCExceptionNO) \ - return v; - -#endif // XFA_SRC_FXBARCODE_UTILS_H_ diff --git a/xfa/src/fxfa/app/xfa_checksum.cpp b/xfa/src/fxfa/app/xfa_checksum.cpp deleted file mode 100644 index 3df37cf156..0000000000 --- a/xfa/src/fxfa/app/xfa_checksum.cpp +++ /dev/null @@ -1,190 +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/src/fxfa/app/xfa_checksum.h" - -#include "core/include/fdrm/fx_crypt.h" -#include "xfa/src/fgas/crt/fgas_algorithm.h" - -CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) - : m_pContext(pContext) { - FXSYS_assert(m_pContext); -} -CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} -void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName, - FX_SAXNODE eType, - FX_DWORD dwStartPos) { - UpdateChecksum(TRUE); - if (eType != FX_SAXNODE_Tag && eType != FX_SAXNODE_Instruction) { - return NULL; - } - m_SAXContext.m_eNode = eType; - CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; - textBuf << "<"; - if (eType == FX_SAXNODE_Instruction) { - textBuf << "?"; - } - textBuf << bsTagName; - m_SAXContext.m_bsTagName = bsTagName; - return &m_SAXContext; -} -void CXFA_SAXReaderHandler::OnTagAttribute(void* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue) { - if (pTag == NULL) { - return; - } - CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; - textBuf << " " << bsAttri << "=\"" << bsValue << "\""; -} -void CXFA_SAXReaderHandler::OnTagBreak(void* pTag) { - if (pTag == NULL) { - return; - } - CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; - textBuf << ">"; - UpdateChecksum(FALSE); -} -void CXFA_SAXReaderHandler::OnTagData(void* pTag, - FX_SAXNODE eType, - const CFX_ByteStringC& bsData, - FX_DWORD dwStartPos) { - if (pTag == NULL) { - return; - } - CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; - if (eType == FX_SAXNODE_CharData) { - textBuf << "<![CDATA["; - } - textBuf << bsData; - if (eType == FX_SAXNODE_CharData) { - textBuf << "]]>"; - } -} -void CXFA_SAXReaderHandler::OnTagClose(void* pTag, FX_DWORD dwEndPos) { - if (pTag == NULL) { - return; - } - CXFA_SAXContext* pSAXContext = (CXFA_SAXContext*)pTag; - CFX_ByteTextBuf& textBuf = pSAXContext->m_TextBuf; - if (pSAXContext->m_eNode == FX_SAXNODE_Instruction) { - textBuf << "?>"; - } else if (pSAXContext->m_eNode == FX_SAXNODE_Tag) { - textBuf << "></" << pSAXContext->m_bsTagName << ">"; - } - UpdateChecksum(FALSE); -} -void CXFA_SAXReaderHandler::OnTagEnd(void* pTag, - const CFX_ByteStringC& bsTagName, - FX_DWORD dwEndPos) { - if (pTag == NULL) { - return; - } - CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; - textBuf << "</" << bsTagName << ">"; - UpdateChecksum(FALSE); -} -void CXFA_SAXReaderHandler::OnTargetData(void* pTag, - FX_SAXNODE eType, - const CFX_ByteStringC& bsData, - FX_DWORD dwStartPos) { - if (pTag == NULL && eType != FX_SAXNODE_Comment) { - return; - } - if (eType == FX_SAXNODE_Comment) { - CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; - textBuf << "<!--" << bsData << "-->"; - UpdateChecksum(FALSE); - } else { - CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; - textBuf << " " << bsData; - } -} -void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) { - int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); - if (iLength < 1) { - return; - } - uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); - FX_BOOL bUpdata = TRUE; - if (bCheckSpace) { - bUpdata = FALSE; - for (int32_t i = 0; i < iLength; i++) { - bUpdata = (pBuffer[i] > 0x20); - if (bUpdata) { - break; - } - } - } - if (bUpdata) { - m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); - } - m_SAXContext.m_TextBuf.Clear(); -} -IXFA_ChecksumContext* XFA_Checksum_Create() { - return new CXFA_ChecksumContext; -} -CXFA_ChecksumContext::CXFA_ChecksumContext() - : m_pSAXReader(NULL), m_pByteContext(NULL) {} -CXFA_ChecksumContext::~CXFA_ChecksumContext() { - FinishChecksum(); -} -FX_BOOL 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; -} -FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile, - FX_FILESIZE offset, - size_t size) { - if (m_pSAXReader == NULL) { - return FALSE; - } - if (pSrcFile == NULL) { - return FALSE; - } - if (size < 1) { - size = pSrcFile->GetSize(); - } - CXFA_SAXReaderHandler handler(this); - m_pSAXReader->SetHandler(&handler); - if (m_pSAXReader->StartParse( - pSrcFile, (FX_DWORD)offset, (FX_DWORD)size, - FX_SAXPARSEMODE_NotSkipSpace | FX_SAXPARSEMODE_NotConvert_amp | - FX_SAXPARSEMODE_NotConvert_lt | FX_SAXPARSEMODE_NotConvert_gt | - FX_SAXPARSEMODE_NotConvert_sharp) < 0) { - return FALSE; - } - return m_pSAXReader->ContinueParse(NULL) > 99; -} -void CXFA_ChecksumContext::FinishChecksum() { - if (m_pSAXReader) { - m_pSAXReader->Release(); - m_pSAXReader = NULL; - } - if (m_pByteContext) { - uint8_t digest[20]; - FXSYS_memset(digest, 0, 20); - CRYPT_SHA1Finish(m_pByteContext, digest); - int32_t nLen = FX_Base64EncodeA(digest, 20, NULL); - FX_CHAR* pBuffer = m_bsChecksum.GetBuffer(nLen); - FX_Base64EncodeA(digest, 20, pBuffer); - m_bsChecksum.ReleaseBuffer(nLen); - FX_Free(m_pByteContext); - m_pByteContext = NULL; - } -} -void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { - bsChecksum = m_bsChecksum; -} -void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { - if (m_pByteContext) { - CRYPT_SHA1Update(m_pByteContext, bsText.GetPtr(), bsText.GetLength()); - } -} diff --git a/xfa/src/fxfa/app/xfa_checksum.h b/xfa/src/fxfa/app/xfa_checksum.h deleted file mode 100644 index fb004d37c1..0000000000 --- a/xfa/src/fxfa/app/xfa_checksum.h +++ /dev/null @@ -1,73 +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_SRC_FXFA_APP_XFA_CHECKSUM_H_ -#define XFA_SRC_FXFA_APP_XFA_CHECKSUM_H_ - -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fgas/xml/fgas_sax.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, - FX_DWORD 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, - FX_DWORD dwStartPos); - virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos); - virtual void OnTagEnd(void* pTag, - const CFX_ByteStringC& bsTagName, - FX_DWORD dwEndPos); - - virtual void OnTargetData(void* pTag, - FX_SAXNODE eType, - const CFX_ByteStringC& bsData, - FX_DWORD dwStartPos); - - protected: - void UpdateChecksum(FX_BOOL bCheckSpace); - CXFA_ChecksumContext* m_pContext; - CXFA_SAXContext m_SAXContext; -}; - -class CXFA_ChecksumContext : public IXFA_ChecksumContext { - public: - CXFA_ChecksumContext(); - virtual ~CXFA_ChecksumContext(); - virtual void Release() { delete this; } - virtual FX_BOOL StartChecksum(); - virtual FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile, - FX_FILESIZE offset = 0, - size_t size = 0); - virtual void FinishChecksum(); - virtual 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_SRC_FXFA_APP_XFA_CHECKSUM_H_ diff --git a/xfa/src/fxfa/app/xfa_ffapp.cpp b/xfa/src/fxfa/app/xfa_ffapp.cpp deleted file mode 100644 index d37eaf5b83..0000000000 --- a/xfa/src/fxfa/app/xfa_ffapp.cpp +++ /dev/null @@ -1,190 +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/src/fxfa/app/xfa_ffapp.h" - -#include <algorithm> - -#include "xfa/include/fwl/core/fwl_widgetmgr.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdochandler.h" -#include "xfa/src/fxfa/app/xfa_ffwidgethandler.h" -#include "xfa/src/fxfa/app/xfa_fontmgr.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/app/xfa_fwltheme.h" - -CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { - int32_t iCount = streams.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CPDF_StreamAcc& acc = m_Data.Add(); - acc.LoadAllData(streams[i]); - } -} -FX_FILESIZE CXFA_FileRead::GetSize() { - FX_DWORD dwSize = 0; - int32_t iCount = m_Data.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CPDF_StreamAcc& acc = m_Data[i]; - dwSize += acc.GetSize(); - } - return dwSize; -} -FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) { - int32_t iCount = m_Data.GetSize(); - int32_t index = 0; - while (index < iCount) { - CPDF_StreamAcc& acc = m_Data[index]; - FX_FILESIZE dwSize = acc.GetSize(); - if (offset < dwSize) { - break; - } - offset -= dwSize; - index++; - } - while (index < iCount) { - CPDF_StreamAcc& acc = m_Data[index]; - FX_DWORD dwSize = acc.GetSize(); - size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset)); - FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); - size -= dwRead; - if (size == 0) { - return TRUE; - } - buffer = (uint8_t*)buffer + dwRead; - offset = 0; - index++; - } - return FALSE; -} -// static -IXFA_App* IXFA_App::Create(IXFA_AppProvider* pProvider) { - return new CXFA_FFApp(pProvider); -} -// virtual -IXFA_App::~IXFA_App() {} -CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) - : m_pDocHandler(nullptr), - m_pFWLTheme(nullptr), - m_pProvider(pProvider), - m_pFontMgr(nullptr), -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_pFontSource(nullptr), -#endif - m_pAdapterWidgetMgr(nullptr), - m_pWidgetMgrDelegate(nullptr), - m_pFDEFontMgr(nullptr), - m_pMenuHandler(nullptr), - m_pAdapterThreadMgr(nullptr) { - m_pFWLApp = IFWL_App::Create(this); - FWL_SetApp(m_pFWLApp); - m_pFWLApp->Initialize(); - IXFA_TimeZoneProvider::Create(); -} -CXFA_FFApp::~CXFA_FFApp() { - delete m_pDocHandler; - if (m_pFWLApp) { - m_pFWLApp->Finalize(); - m_pFWLApp->Release(); - delete m_pFWLApp; - } - if (m_pFWLTheme) - m_pFWLTheme->Release(); - delete m_pAdapterWidgetMgr; - delete m_pAdapterThreadMgr; - delete m_pMenuHandler; - IXFA_TimeZoneProvider::Destroy(); - delete m_pFontMgr; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_pFontSource) - m_pFontSource->Release(); -#endif - if (m_pFDEFontMgr) - m_pFDEFontMgr->Release(); -} -IXFA_MenuHandler* CXFA_FFApp::GetMenuHandler() { - if (!m_pMenuHandler) { - m_pMenuHandler = new CXFA_FFMenuHandler; - } - return m_pMenuHandler; -} -IXFA_DocHandler* CXFA_FFApp::GetDocHandler() { - if (!m_pDocHandler) { - m_pDocHandler = new CXFA_FFDocHandler; - } - return m_pDocHandler; -} -IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, - IFX_FileRead* pStream, - FX_BOOL bTakeOverFile) { - CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); - FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); - if (!bSuccess) { - delete pDoc; - pDoc = NULL; - } - return pDoc; -} -IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, - CPDF_Document* pPDFDoc) { - if (pPDFDoc == NULL) { - return NULL; - } - CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); - FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); - if (!bSuccess) { - delete pDoc; - pDoc = NULL; - } - return pDoc; -} - -void CXFA_FFApp::SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) { - if (!m_pFontMgr) { - m_pFontMgr = new CXFA_FontMgr(); - } - m_pFontMgr->SetDefFontMgr(pFontMgr); -} -CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { - return m_pFontMgr; -} -IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() { - if (!m_pFDEFontMgr) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - m_pFDEFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); -#else - m_pFontSource = FX_CreateDefaultFontSourceEnum(); - m_pFDEFontMgr = IFX_FontMgr::Create(m_pFontSource); -#endif - } - return m_pFDEFontMgr; -} -CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { - if (!m_pFWLTheme) { - m_pFWLTheme = new CXFA_FWLTheme(this); - } - return m_pFWLTheme; -} -IFWL_AdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( - IFWL_WidgetMgrDelegate* pDelegate) { - if (!m_pAdapterWidgetMgr) { - m_pAdapterWidgetMgr = new CXFA_FWLAdapterWidgetMgr; - pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread | - FWL_WGTMGR_DisableForm); - m_pWidgetMgrDelegate = pDelegate; - } - 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/xfa/src/fxfa/app/xfa_ffapp.h b/xfa/src/fxfa/app/xfa_ffapp.h deleted file mode 100644 index ba6a0f2034..0000000000 --- a/xfa/src/fxfa/app/xfa_ffapp.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_SRC_FXFA_APP_XFA_FFAPP_H_ -#define XFA_SRC_FXFA_APP_XFA_FFAPP_H_ - -#include "core/include/fpdfapi/cpdf_stream.h" -#include "xfa/include/fwl/adapter/fwl_adapternative.h" -#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fgas/font/fgas_font.h" - -class CXFA_FWLAdapterWidgetMgr; -class CXFA_FWLTheme; -class CXFA_FFDocHandler; -class CXFA_FFMenuHandler; -class CXFA_FontMgr; - -class CXFA_FileRead : public IFX_FileRead { - public: - explicit CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams); - - virtual FX_FILESIZE GetSize(); - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - virtual void Release() { delete this; } - - protected: - CFX_ObjectArray<CPDF_StreamAcc> m_Data; -}; - -class CXFA_FFApp : public IXFA_App, public IFWL_AdapterNative { - public: - CXFA_FFApp(IXFA_AppProvider* pProvider); - ~CXFA_FFApp() override; - - // IFXFA_App: - IXFA_DocHandler* GetDocHandler() override; - IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider, - IFX_FileRead* pStream, - FX_BOOL bTakeOverFile) override; - IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider, - CPDF_Document* pPDFDoc) override; - IXFA_AppProvider* GetAppProvider() override { return m_pProvider; } - void SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) override; - IXFA_MenuHandler* GetMenuHandler() override; - - // IFWL_AdapterNative: - IFWL_AdapterWidgetMgr* GetWidgetMgr( - IFWL_WidgetMgrDelegate* pDelegate) override; - IFWL_AdapterThreadMgr* GetThreadMgr() override; - IFWL_AdapterTimerMgr* GetTimerMgr() override; - - CXFA_FontMgr* GetXFAFontMgr(); - IFX_FontMgr* GetFDEFontMgr(); - CXFA_FWLTheme* GetFWLTheme(); - IFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() { - return m_pWidgetMgrDelegate; - } - - protected: - CXFA_FFDocHandler* m_pDocHandler; - IFWL_App* m_pFWLApp; - CXFA_FWLTheme* m_pFWLTheme; - IXFA_AppProvider* m_pProvider; - CXFA_FontMgr* m_pFontMgr; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - IFX_FontSourceEnum* m_pFontSource; -#endif - CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr; - IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; - IFX_FontMgr* m_pFDEFontMgr; - CXFA_FFMenuHandler* m_pMenuHandler; - CFWL_SDAdapterThreadMgr* m_pAdapterThreadMgr; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFAPP_H_ diff --git a/xfa/src/fxfa/app/xfa_ffbarcode.cpp b/xfa/src/fxfa/app/xfa_ffbarcode.cpp deleted file mode 100644 index e1d4aa11c1..0000000000 --- a/xfa/src/fxfa/app/xfa_ffbarcode.cpp +++ /dev/null @@ -1,235 +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/src/fxfa/app/xfa_ffbarcode.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/lightwidget/barcode.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_fftextedit.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" - -static XFA_LPCBARCODETYPEENUMINFO XFA_GetBarcodeTypeByName( - const CFX_WideStringC& wsName); -CXFA_FFBarcode::CXFA_FFBarcode(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pPageView, pDataAcc) {} -CXFA_FFBarcode::~CXFA_FFBarcode() {} -FX_BOOL CXFA_FFBarcode::LoadWidget() { - CFWL_Barcode* pFWLBarcode = CFWL_Barcode::Create(); - if (pFWLBarcode) { - pFWLBarcode->Initialize(); - } - m_pNormalWidget = pFWLBarcode; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLBarcode->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - m_pNormalWidget->DrawWidget(pGS, &mt); -} -void CXFA_FFBarcode::UpdateWidgetProperty() { - CXFA_FFTextEdit::UpdateWidgetProperty(); - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; - CFX_WideString wsType = GetDataAcc()->GetBarcodeType(); - XFA_LPCBARCODETYPEENUMINFO pBarcodeTypeInfo = - XFA_GetBarcodeTypeByName(wsType); - pBarCodeWidget->SetType(pBarcodeTypeInfo->eBCType); - CXFA_WidgetAcc* pAcc = GetDataAcc(); - int32_t intVal; - FX_CHAR charVal; - FX_BOOL boolVal; - FX_FLOAT floatVal; - if (pAcc->GetBarcodeAttribute_CharEncoding(intVal)) { - pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); - } - if (pAcc->GetBarcodeAttribute_Checksum(intVal)) { - pBarCodeWidget->SetCalChecksum(intVal); - } - if (pAcc->GetBarcodeAttribute_DataLength(intVal)) { - pBarCodeWidget->SetDataLength(intVal); - } - if (pAcc->GetBarcodeAttribute_StartChar(charVal)) { - pBarCodeWidget->SetStartChar(charVal); - } - if (pAcc->GetBarcodeAttribute_EndChar(charVal)) { - pBarCodeWidget->SetEndChar(charVal); - } - if (pAcc->GetBarcodeAttribute_ECLevel(intVal)) { - pBarCodeWidget->SetErrorCorrectionLevel(intVal); - } - if (pAcc->GetBarcodeAttribute_ModuleWidth(intVal)) { - pBarCodeWidget->SetModuleWidth(intVal); - } - if (pAcc->GetBarcodeAttribute_ModuleHeight(intVal)) { - pBarCodeWidget->SetModuleHeight(intVal); - } - if (pAcc->GetBarcodeAttribute_PrintChecksum(boolVal)) { - pBarCodeWidget->SetPrintChecksum(boolVal); - } - if (pAcc->GetBarcodeAttribute_TextLocation(intVal)) { - pBarCodeWidget->SetTextLocation((BC_TEXT_LOC)intVal); - } - if (pAcc->GetBarcodeAttribute_Truncate(boolVal)) { - pBarCodeWidget->SetTruncated(boolVal); - } - if (pAcc->GetBarcodeAttribute_WideNarrowRatio(floatVal)) { - pBarCodeWidget->SetWideNarrowRatio((int32_t)floatVal); - } - if (pBarcodeTypeInfo->eName == XFA_BARCODETYPE_code3Of9 || - pBarcodeTypeInfo->eName == XFA_BARCODETYPE_ean8 || - pBarcodeTypeInfo->eName == XFA_BARCODETYPE_ean13 || - pBarcodeTypeInfo->eName == XFA_BARCODETYPE_upcA) { - pBarCodeWidget->SetPrintChecksum(TRUE); - } -} -FX_BOOL CXFA_FFBarcode::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { - return FALSE; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - return CXFA_FFTextEdit::OnLButtonDown(dwFlags, fx, fy); -} -FX_BOOL CXFA_FFBarcode::OnRButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { - return FALSE; - } - return CXFA_FFTextEdit::OnRButtonDown(dwFlags, fx, fy); -} -extern const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[] = { - {0x7fb4a18, L"ean13", XFA_BARCODETYPE_ean13, BC_EAN13}, - {0x8d13a3d, L"code11", XFA_BARCODETYPE_code11, BC_UNKNOWN}, - {0x8d149a8, L"code49", XFA_BARCODETYPE_code49, BC_UNKNOWN}, - {0x8d16347, L"code93", XFA_BARCODETYPE_code93, BC_UNKNOWN}, - {0x91a92e2, L"upsMaxicode", XFA_BARCODETYPE_upsMaxicode, BC_UNKNOWN}, - {0xa7d48dc, L"fim", XFA_BARCODETYPE_fim, BC_UNKNOWN}, - {0xb359fe9, L"msi", XFA_BARCODETYPE_msi, BC_UNKNOWN}, - {0x121f738c, L"code2Of5Matrix", XFA_BARCODETYPE_code2Of5Matrix, BC_UNKNOWN}, - {0x15358616, L"ucc128", XFA_BARCODETYPE_ucc128, BC_UNKNOWN}, - {0x1f4bfa05, L"rfid", XFA_BARCODETYPE_rfid, BC_UNKNOWN}, - {0x1fda71bc, L"rss14Stacked", XFA_BARCODETYPE_rss14Stacked, BC_UNKNOWN}, - {0x22065087, L"ean8add2", XFA_BARCODETYPE_ean8add2, BC_UNKNOWN}, - {0x2206508a, L"ean8add5", XFA_BARCODETYPE_ean8add5, BC_UNKNOWN}, - {0x2278366c, L"codabar", XFA_BARCODETYPE_codabar, BC_CODABAR}, - {0x2a039a8d, L"telepen", XFA_BARCODETYPE_telepen, BC_UNKNOWN}, - {0x323ed337, L"upcApwcd", XFA_BARCODETYPE_upcApwcd, BC_UNKNOWN}, - {0x347a1846, L"postUSIMB", XFA_BARCODETYPE_postUSIMB, BC_UNKNOWN}, - {0x391bb836, L"code128", XFA_BARCODETYPE_code128, BC_CODE128}, - {0x398eddaf, L"dataMatrix", XFA_BARCODETYPE_dataMatrix, BC_DATAMATRIX}, - {0x3cff60a8, L"upcEadd2", XFA_BARCODETYPE_upcEadd2, BC_UNKNOWN}, - {0x3cff60ab, L"upcEadd5", XFA_BARCODETYPE_upcEadd5, BC_UNKNOWN}, - {0x402cb188, L"code2Of5Standard", XFA_BARCODETYPE_code2Of5Standard, - BC_UNKNOWN}, - {0x411764f7, L"aztec", XFA_BARCODETYPE_aztec, BC_UNKNOWN}, - {0x44d4e84c, L"ean8", XFA_BARCODETYPE_ean8, BC_EAN8}, - {0x48468902, L"ucc128sscc", XFA_BARCODETYPE_ucc128sscc, BC_UNKNOWN}, - {0x4880aea4, L"upcAadd2", XFA_BARCODETYPE_upcAadd2, BC_UNKNOWN}, - {0x4880aea7, L"upcAadd5", XFA_BARCODETYPE_upcAadd5, BC_UNKNOWN}, - {0x54f18256, L"code2Of5Industrial", XFA_BARCODETYPE_code2Of5Industrial, - BC_UNKNOWN}, - {0x58e15f25, L"rss14Limited", XFA_BARCODETYPE_rss14Limited, BC_UNKNOWN}, - {0x5c08d1b9, L"postAUSReplyPaid", XFA_BARCODETYPE_postAUSReplyPaid, - BC_UNKNOWN}, - {0x5fa700bd, L"rss14", XFA_BARCODETYPE_rss14, BC_UNKNOWN}, - {0x631a7e35, L"logmars", XFA_BARCODETYPE_logmars, BC_UNKNOWN}, - {0x6a236236, L"pdf417", XFA_BARCODETYPE_pdf417, BC_PDF417}, - {0x6d098ece, L"upcean2", XFA_BARCODETYPE_upcean2, BC_UNKNOWN}, - {0x6d098ed1, L"upcean5", XFA_BARCODETYPE_upcean5, BC_UNKNOWN}, - {0x76b04eed, L"code3Of9extended", XFA_BARCODETYPE_code3Of9extended, - BC_UNKNOWN}, - {0x7c7db84a, L"maxicode", XFA_BARCODETYPE_maxicode, BC_UNKNOWN}, - {0x8266f7f7, L"ucc128random", XFA_BARCODETYPE_ucc128random, BC_UNKNOWN}, - {0x83eca147, L"postUSDPBC", XFA_BARCODETYPE_postUSDPBC, BC_UNKNOWN}, - {0x8dd71de0, L"postAUSStandard", XFA_BARCODETYPE_postAUSStandard, - BC_UNKNOWN}, - {0x98adad85, L"plessey", XFA_BARCODETYPE_plessey, BC_UNKNOWN}, - {0x9f84cce6, L"ean13pwcd", XFA_BARCODETYPE_ean13pwcd, BC_UNKNOWN}, - {0xb514fbe9, L"upcA", XFA_BARCODETYPE_upcA, BC_UPCA}, - {0xb514fbed, L"upcE", XFA_BARCODETYPE_upcE, BC_UNKNOWN}, - {0xb5c6a853, L"ean13add2", XFA_BARCODETYPE_ean13add2, BC_UNKNOWN}, - {0xb5c6a856, L"ean13add5", XFA_BARCODETYPE_ean13add5, BC_UNKNOWN}, - {0xb81fc512, L"postUKRM4SCC", XFA_BARCODETYPE_postUKRM4SCC, BC_UNKNOWN}, - {0xbad34b22, L"code128SSCC", XFA_BARCODETYPE_code128SSCC, BC_UNKNOWN}, - {0xbfbe0cf6, L"postUS5Zip", XFA_BARCODETYPE_postUS5Zip, BC_UNKNOWN}, - {0xc56618e8, L"pdf417macro", XFA_BARCODETYPE_pdf417macro, BC_UNKNOWN}, - {0xca730f8a, L"code2Of5Interleaved", XFA_BARCODETYPE_code2Of5Interleaved, - BC_UNKNOWN}, - {0xd0097ac6, L"rss14Expanded", XFA_BARCODETYPE_rss14Expanded, BC_UNKNOWN}, - {0xd25a0240, L"postAUSCust2", XFA_BARCODETYPE_postAUSCust2, BC_UNKNOWN}, - {0xd25a0241, L"postAUSCust3", XFA_BARCODETYPE_postAUSCust3, BC_UNKNOWN}, - {0xd53ed3e7, L"rss14Truncated", XFA_BARCODETYPE_rss14Truncated, BC_UNKNOWN}, - {0xe72bcd57, L"code128A", XFA_BARCODETYPE_code128A, BC_UNKNOWN}, - {0xe72bcd58, L"code128B", XFA_BARCODETYPE_code128B, BC_CODE128_B}, - {0xe72bcd59, L"code128C", XFA_BARCODETYPE_code128C, BC_CODE128_C}, - {0xee83c50f, L"rss14StackedOmni", XFA_BARCODETYPE_rss14StackedOmni, - BC_UNKNOWN}, - {0xf2a18f7e, L"QRCode", XFA_BARCODETYPE_QRCode, BC_QR_CODE}, - {0xfaeaf37f, L"postUSStandard", XFA_BARCODETYPE_postUSStandard, BC_UNKNOWN}, - {0xfb48155c, L"code3Of9", XFA_BARCODETYPE_code3Of9, BC_CODE39}, -}; -extern const int32_t g_iXFABarcodeTypeCount = - sizeof(g_XFABarCodeTypeEnumData) / sizeof(XFA_BARCODETYPEENUMINFO); -static 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.GetPtr(), iLength, TRUE); - int32_t iStart = 0, iEnd = g_iXFABarcodeTypeCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - XFA_LPCBARCODETYPEENUMINFO pInfo = g_XFABarCodeTypeEnumData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} diff --git a/xfa/src/fxfa/app/xfa_ffbarcode.h b/xfa/src/fxfa/app/xfa_ffbarcode.h deleted file mode 100644 index d2f8058296..0000000000 --- a/xfa/src/fxfa/app/xfa_ffbarcode.h +++ /dev/null @@ -1,101 +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_SRC_FXFA_APP_XFA_FFBARCODE_H_ -#define XFA_SRC_FXFA_APP_XFA_FFBARCODE_H_ - -#include "xfa/include/fxbarcode/BC_BarCode.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_fftextedit.h" - -class CXFA_FFBarcode : public CXFA_FFTextEdit { - public: - CXFA_FFBarcode(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFBarcode(); - virtual FX_BOOL LoadWidget(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual void UpdateWidgetProperty(); - virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); -}; - -enum XFA_BARCODETYPEENUM { - XFA_BARCODETYPE_aztec, - XFA_BARCODETYPE_codabar, - XFA_BARCODETYPE_code11, - XFA_BARCODETYPE_code128, - XFA_BARCODETYPE_code128A, - XFA_BARCODETYPE_code128B, - XFA_BARCODETYPE_code128C, - XFA_BARCODETYPE_code128SSCC, - XFA_BARCODETYPE_code2Of5Industrial, - XFA_BARCODETYPE_code2Of5Interleaved, - XFA_BARCODETYPE_code2Of5Matrix, - XFA_BARCODETYPE_code2Of5Standard, - XFA_BARCODETYPE_code3Of9, - XFA_BARCODETYPE_code3Of9extended, - XFA_BARCODETYPE_code49, - XFA_BARCODETYPE_code93, - XFA_BARCODETYPE_dataMatrix, - XFA_BARCODETYPE_ean13, - XFA_BARCODETYPE_ean13add2, - XFA_BARCODETYPE_ean13add5, - XFA_BARCODETYPE_ean13pwcd, - XFA_BARCODETYPE_ean8, - XFA_BARCODETYPE_ean8add2, - XFA_BARCODETYPE_ean8add5, - XFA_BARCODETYPE_fim, - XFA_BARCODETYPE_logmars, - XFA_BARCODETYPE_maxicode, - XFA_BARCODETYPE_msi, - XFA_BARCODETYPE_pdf417, - XFA_BARCODETYPE_pdf417macro, - XFA_BARCODETYPE_plessey, - XFA_BARCODETYPE_postAUSCust2, - XFA_BARCODETYPE_postAUSCust3, - XFA_BARCODETYPE_postAUSReplyPaid, - XFA_BARCODETYPE_postAUSStandard, - XFA_BARCODETYPE_postUKRM4SCC, - XFA_BARCODETYPE_postUS5Zip, - XFA_BARCODETYPE_postUSDPBC, - XFA_BARCODETYPE_postUSIMB, - XFA_BARCODETYPE_postUSStandard, - XFA_BARCODETYPE_QRCode, - XFA_BARCODETYPE_rfid, - XFA_BARCODETYPE_rss14, - XFA_BARCODETYPE_rss14Expanded, - XFA_BARCODETYPE_rss14Limited, - XFA_BARCODETYPE_rss14Stacked, - XFA_BARCODETYPE_rss14StackedOmni, - XFA_BARCODETYPE_rss14Truncated, - XFA_BARCODETYPE_telepen, - XFA_BARCODETYPE_ucc128, - XFA_BARCODETYPE_ucc128random, - XFA_BARCODETYPE_ucc128sscc, - XFA_BARCODETYPE_upcA, - XFA_BARCODETYPE_upcAadd2, - XFA_BARCODETYPE_upcAadd5, - XFA_BARCODETYPE_upcApwcd, - XFA_BARCODETYPE_upcE, - XFA_BARCODETYPE_upcEadd2, - XFA_BARCODETYPE_upcEadd5, - XFA_BARCODETYPE_upcean2, - XFA_BARCODETYPE_upcean5, - XFA_BARCODETYPE_upsMaxicode -}; -struct XFA_BARCODETYPEENUMINFO { - uint32_t uHash; - const FX_WCHAR* pName; - XFA_BARCODETYPEENUM eName; - BC_TYPE eBCType; -}; -typedef XFA_BARCODETYPEENUMINFO const* XFA_LPCBARCODETYPEENUMINFO; -extern const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[]; - -#endif // XFA_SRC_FXFA_APP_XFA_FFBARCODE_H_ diff --git a/xfa/src/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/src/fxfa/app/xfa_ffcheckbutton.cpp deleted file mode 100644 index e5a6e809c4..0000000000 --- a/xfa/src/fxfa/app/xfa_ffcheckbutton.cpp +++ /dev/null @@ -1,335 +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/src/fxfa/app/xfa_ffcheckbutton.h" - -#include "xfa/include/fwl/core/fwl_widgetmgr.h" -#include "xfa/include/fwl/lightwidget/checkbox.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) { - m_rtCheckBox.Set(0, 0, 0, 0); -} -CXFA_FFCheckButton::~CXFA_FFCheckButton() {} -FX_BOOL CXFA_FFCheckButton::LoadWidget() { - CFWL_CheckBox* pCheckBox = CFWL_CheckBox::Create(); - pCheckBox->Initialize(); - m_pNormalWidget = pCheckBox; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = m_pNormalWidget->SetDelegate(this); - if (m_pDataAcc->IsRadioButton()) { - pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); - } - m_pNormalWidget = (CFWL_Widget*)pCheckBox; - m_pNormalWidget->SetPrivateData(m_pNormalWidget->GetWidget(), this, NULL); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); - SetFWLCheckState(eState); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFCheckButton::UpdateWidgetProperty() { - CFWL_CheckBox* pCheckBox = (CFWL_CheckBox*)m_pNormalWidget; - if (!m_pNormalWidget) { - return; - } - FX_FLOAT fSize = m_pDataAcc->GetCheckButtonSize(); - pCheckBox->SetBoxSize(fSize); - FX_DWORD dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross; - int32_t iCheckMark = m_pDataAcc->GetCheckButtonMark(); - switch (iCheckMark) { - case XFA_ATTRIBUTEENUM_Check: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCheck; - break; - case XFA_ATTRIBUTEENUM_Circle: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; - break; - case XFA_ATTRIBUTEENUM_Cross: - break; - case XFA_ATTRIBUTEENUM_Diamond: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeDiamond; - break; - case XFA_ATTRIBUTEENUM_Square: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeSquare; - break; - case XFA_ATTRIBUTEENUM_Star: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeStar; - break; - default: { - int32_t iShape = m_pDataAcc->GetCheckButtonShape(); - if (iShape == XFA_ATTRIBUTEENUM_Round) { - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; - } - } break; - } - if (m_pDataAcc->IsAllowNeutral()) { - dwStyleEx |= FWL_STYLEEXT_CKB_3State; - } - pCheckBox->ModifyStylesEx( - dwStyleEx, FWL_STYLEEXT_CKB_SignShapeMask | FWL_STYLEEXT_CKB_3State); -} -FX_BOOL CXFA_FFCheckButton::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - FX_FLOAT fCheckSize = m_pDataAcc->GetCheckButtonSize(); - CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - if (mgWidget) { - XFA_RectWidthoutMargin(rtWidget, mgWidget); - } - int32_t iCapPlacement = -1; - FX_FLOAT fCapReserve = 0; - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence()) { - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); - iCapPlacement = caption.GetPlacementType(); - fCapReserve = caption.GetReserve(); - if (fCapReserve <= 0) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { - fCapReserve = rtWidget.height - fCheckSize; - } else { - fCapReserve = rtWidget.width - fCheckSize; - } - } - } - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - m_rtUI = rtWidget; - CXFA_Margin mgCap = caption.GetMargin(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: { - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(mgCap); - m_rtUI.width -= fCapReserve; - m_rtUI.left += fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Top: { - m_rtCaption.height = fCapReserve; - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - m_rtUI.height -= fCapReserve; - m_rtUI.top += fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Right: { - m_rtCaption.left = m_rtCaption.right() - fCapReserve; - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(mgCap); - m_rtUI.width -= fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Bottom: { - m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; - m_rtCaption.height = fCapReserve; - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - m_rtUI.height -= fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Inline: - break; - default: - iHorzAlign = XFA_ATTRIBUTEENUM_Right; - break; - } - if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { - m_rtUI.left += (m_rtUI.width - fCheckSize) / 2; - } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { - m_rtUI.left = m_rtUI.right() - fCheckSize; - } - if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { - m_rtUI.top += (m_rtUI.height - fCheckSize) / 2; - } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { - m_rtUI.top = m_rtUI.bottom() - fCheckSize; - } - m_rtUI.width = fCheckSize; - m_rtUI.height = fCheckSize; - AddUIMargin(iCapPlacement); - m_rtCheckBox = m_rtUI; - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - if (borderUI) { - CXFA_Margin margin = borderUI.GetMargin(); - if (margin) { - XFA_RectWidthoutMargin(m_rtUI, margin); - } - } - m_rtUI.Normalize(); - LayoutCaption(); - SetFWLRect(); - if (m_pNormalWidget) { - m_pNormalWidget->Update(); - } - return TRUE; -} -void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) { - m_rtCaption.top += m_rtCaption.height; - } - if (m_rtCaption.width < 0) { - m_rtCaption.left += m_rtCaption.width; - m_rtCaption.width = -m_rtCaption.width; - } -} -void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); - m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2; - FX_FLOAT fLeftAddRight = rtUIMargin.left + rtUIMargin.width; - FX_FLOAT fTopAddBottom = rtUIMargin.top + rtUIMargin.height; - if (m_rtUI.width < fLeftAddRight) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right || - iCapPlacement == XFA_ATTRIBUTEENUM_Left) { - m_rtUI.left -= fLeftAddRight - m_rtUI.width; - } else { - m_rtUI.left -= 2 * (fLeftAddRight - m_rtUI.width); - } - m_rtUI.width += 2 * (fLeftAddRight - m_rtUI.width); - } - if (m_rtUI.height < fTopAddBottom) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) { - m_rtUI.left -= fTopAddBottom - m_rtUI.height; - } - m_rtUI.top -= fTopAddBottom - m_rtUI.height; - m_rtUI.height += 2 * (fTopAddBottom - m_rtUI.height); - } -} -void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate, - m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round - ? XFA_DRAWBOX_ForceRound - : 0); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, - m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), - pGS, &mt); -} -FX_BOOL CXFA_FFCheckButton::OnLButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - if (!IsButtonDown()) { - return FALSE; - } - SetButtonDown(FALSE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { - XFA_CHECKSTATE eCheckState = XFA_CHECKSTATE_Off; - FX_DWORD dwState = m_pNormalWidget->GetStates(); - if (dwState & FWL_STATE_CKB_Checked) { - eCheckState = XFA_CHECKSTATE_On; - } else if (dwState & FWL_STATE_CKB_Neutral) { - eCheckState = XFA_CHECKSTATE_Neutral; - } - return eCheckState; -} -FX_BOOL CXFA_FFCheckButton::CommitData() { - XFA_CHECKSTATE eCheckState = FWLState2XFAState(); - m_pDataAcc->SetCheckState(eCheckState, TRUE); - return TRUE; -} -FX_BOOL CXFA_FFCheckButton::IsDataChanged() { - XFA_CHECKSTATE eCheckState = FWLState2XFAState(); - return m_pDataAcc->GetCheckState() != eCheckState; -} -void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { - if (eCheckState == XFA_CHECKSTATE_Neutral) { - m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral, TRUE); - } else { - m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked, - eCheckState == XFA_CHECKSTATE_On); - } -} -FX_BOOL CXFA_FFCheckButton::UpdateFWLData() { - if (!m_pNormalWidget) { - return FALSE; - } - XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); - SetFWLCheckState(eState); - m_pNormalWidget->Update(); - return TRUE; -} -int32_t CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - FX_DWORD dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_CKB_CheckStateChanged: { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); - CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup(); - if (ProcessCommittedData()) { - eParam.m_pTarget = pFFExclGroup; - if (pFFExclGroup) { - m_pDocView->AddValidateWidget(pFFExclGroup); - m_pDocView->AddCalculateWidgetAcc(pFFExclGroup); - pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); - } - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); - } else { - SetFWLCheckState(m_pDataAcc->GetCheckState()); - } - if (pFFExclGroup) { - eParam.m_pTarget = pFFExclGroup; - pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - } - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - break; - } - default: {} - } - return m_pOldDelegate->OnProcessEvent(pEvent); -} -FWL_ERR CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/src/fxfa/app/xfa_ffcheckbutton.h b/xfa/src/fxfa/app/xfa_ffcheckbutton.h deleted file mode 100644 index 9731d4d53b..0000000000 --- a/xfa/src/fxfa/app/xfa_ffcheckbutton.h +++ /dev/null @@ -1,43 +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_SRC_FXFA_APP_XFA_FFCHECKBUTTON_H_ -#define XFA_SRC_FXFA_APP_XFA_FFCHECKBUTTON_H_ - -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" - -class CXFA_FFCheckButton : public CXFA_FFField { - public: - CXFA_FFCheckButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFCheckButton(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - - virtual FX_BOOL LoadWidget(); - virtual FX_BOOL PerformLayout(); - virtual FX_BOOL UpdateFWLData(); - virtual void UpdateWidgetProperty(); - virtual FX_BOOL OnLButtonUp(FX_DWORD 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); - - protected: - virtual FX_BOOL CommitData(); - virtual FX_BOOL IsDataChanged(); - void CapLeftRightPlacement(CXFA_Margin mgCap); - void AddUIMargin(int32_t iCapPlacement); - XFA_CHECKSTATE FWLState2XFAState(); - IFWL_WidgetDelegate* m_pOldDelegate; - CFX_RectF m_rtCheckBox; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFCHECKBUTTON_H_ diff --git a/xfa/src/fxfa/app/xfa_ffchoicelist.cpp b/xfa/src/fxfa/app/xfa_ffchoicelist.cpp deleted file mode 100644 index cb481f56a4..0000000000 --- a/xfa/src/fxfa/app/xfa_ffchoicelist.cpp +++ /dev/null @@ -1,530 +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/src/fxfa/app/xfa_ffchoicelist.h" - -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/lightwidget/combobox.h" -#include "xfa/include/fwl/lightwidget/listbox.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" - -CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} -CXFA_FFListBox::~CXFA_FFListBox() { - if (m_pNormalWidget) { - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(pWidget); - } -} -FX_BOOL CXFA_FFListBox::LoadWidget() { - CFWL_ListBox* pListBox = CFWL_ListBox::Create(); - pListBox->Initialize(); - pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, - 0xFFFFFFFF); - m_pNormalWidget = (CFWL_Widget*)pListBox; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - CFX_WideStringArray wsLabelArray; - m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); - int32_t iItems = wsLabelArray.GetSize(); - for (int32_t i = 0; i < iItems; i++) { - pListBox->AddString(wsLabelArray[i]); - } - FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; - if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { - dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - CFX_Int32Array iSelArray; - m_pDataAcc->GetSelectedItems(iSelArray); - int32_t iSelCount = iSelArray.GetSize(); - for (int32_t j = 0; j < iSelCount; j++) { - FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]); - pListBox->SetSelItem(item, TRUE); - } - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -FX_BOOL CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { - FX_BOOL flag = ProcessCommittedData(); - if (!flag) { - UpdateFWLData(); - } - CXFA_FFField::OnKillFocus(pNewFocus); - return TRUE; -} -FX_BOOL CXFA_FFListBox::CommitData() { - CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); - int32_t iSels = pListBox->CountSelItems(); - CFX_Int32Array iSelArray; - for (int32_t i = 0; i < iSels; i++) { - iSelArray.Add(pListBox->GetSelIndex(i)); - } - m_pDataAcc->SetSelectdItems(iSelArray, TRUE); - return TRUE; -} -FX_BOOL CXFA_FFListBox::IsDataChanged() { - CFX_Int32Array iSelArray; - m_pDataAcc->GetSelectedItems(iSelArray); - int32_t iOldSels = iSelArray.GetSize(); - CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; - int32_t iSels = pListBox->CountSelItems(); - if (iOldSels == iSels) { - int32_t iIndex = 0; - for (; iIndex < iSels; iIndex++) { - FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[iIndex]); - if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) { - break; - } - } - if (iIndex == iSels) { - return FALSE; - } - } - return TRUE; -} -FX_DWORD CXFA_FFListBox::GetAlignment() { - FX_DWORD dwExtendedStyle = 0; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - int32_t iHorz = para.GetHorizontalAlign(); - switch (iHorz) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; - break; - case XFA_ATTRIBUTEENUM_Justify: - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; - break; - } - } - return dwExtendedStyle; -} -FX_BOOL CXFA_FFListBox::UpdateFWLData() { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); - CFX_ArrayTemplate<FWL_HLISTITEM> selItemArray; - CFX_Int32Array iSelArray; - m_pDataAcc->GetSelectedItems(iSelArray); - int32_t iSelCount = iSelArray.GetSize(); - for (int32_t j = 0; j < iSelCount; j++) { - FWL_HLISTITEM lpItemSel = pListBox->GetSelItem(iSelArray[j]); - selItemArray.Add(lpItemSel); - } - pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE); - for (int32_t i = 0; i < iSelCount; i++) { - ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], TRUE); - } - m_pNormalWidget->Update(); - return TRUE; -} -void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, - const CFX_Int32Array& arrSels) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; - int32_t iSels = pListBox->CountSelItems(); - if (iSels > 0) { - pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText); - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} -void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { - FWL_HLISTITEM item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); - ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, - int32_t nIndex) { - CFX_WideString wsTemp(wsLabel); - ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -void CXFA_FFListBox::DeleteItem(int32_t nIndex) { - if (nIndex < 0) { - ((CFWL_ListBox*)m_pNormalWidget)->DeleteAll(); - } else { - ((CFWL_ListBox*)m_pNormalWidget) - ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex)); - } - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - FX_DWORD dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_LTB_SelChanged: { - CFX_Int32Array arrSels; - OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); - break; - } - default: {} - } - return m_pOldDelegate->OnProcessEvent(pEvent); -} -FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} - -CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} - -CXFA_FFComboBox::~CXFA_FFComboBox() {} - -FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus) { - if (bDrawFocus) - return FALSE; - return CXFA_FFWidget::GetBBox(rtBox, dwStatus); -} - -FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFX_RectF rtWidget; - ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); - if (rtWidget.Contains(fx, fy)) { - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_FFComboBox::LoadWidget() { - CFWL_ComboBox* pComboBox = CFWL_ComboBox::Create(); - pComboBox->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pComboBox; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - CFX_WideStringArray wsLabelArray; - m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); - int32_t iItems = wsLabelArray.GetSize(); - for (int32_t i = 0; i < iItems; i++) { - pComboBox->AddString(wsLabelArray[i]); - } - CFX_Int32Array iSelArray; - m_pDataAcc->GetSelectedItems(iSelArray); - int32_t iSelCount = iSelArray.GetSize(); - if (iSelCount > 0) { - pComboBox->SetCurSel(iSelArray[0]); - } else { - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); - pComboBox->SetEditText(wsText); - } - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFComboBox::UpdateWidgetProperty() { - CFWL_ComboBox* pComboBox = (CFWL_ComboBox*)m_pNormalWidget; - if (!pComboBox) { - return; - } - FX_DWORD dwExtendedStyle = 0; - FX_DWORD dwEditStyles = - FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->IsChoiceListAllowTextEntry()) { - dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; - } - pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); -} -FX_BOOL CXFA_FFComboBox::OnRButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) - return FALSE; - - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); - return TRUE; -} -FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { - FX_BOOL flag = ProcessCommittedData(); - if (!flag) { - UpdateFWLData(); - } - CXFA_FFField::OnKillFocus(pNewWidget); - return TRUE; -} -void CXFA_FFComboBox::OpenDropDownList() { - ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(TRUE); -} -FX_BOOL CXFA_FFComboBox::CommitData() { - return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); -} -FX_BOOL CXFA_FFComboBox::IsDataChanged() { - CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); - CFX_WideString wsText; - pFWLcombobox->GetEditText(wsText); - int32_t iCursel = pFWLcombobox->GetCurSel(); - if (iCursel >= 0) { - CFX_WideString wsSel; - pFWLcombobox->GetTextByIndex(iCursel, wsSel); - if (wsSel == wsText) { - m_pDataAcc->GetChoiceListItem(wsText, iCursel, TRUE); - } - } - CFX_WideString wsOldValue; - m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); - if (wsOldValue != wsText) { - m_wsNewValue = wsText; - return TRUE; - } - return FALSE; -} -void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { - pParam->m_eType = XFA_EVENT_Change; - pParam->m_pTarget = m_pDataAcc; - CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); - pFWLcombobox->GetEditText(pParam->m_wsNewText); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); -} -FX_DWORD CXFA_FFComboBox::GetAlignment() { - FX_DWORD dwExtendedStyle = 0; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - int32_t iHorz = para.GetHorizontalAlign(); - switch (iHorz) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= - FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - break; - default: - dwExtendedStyle |= - FWL_STYLEEXT_CMB_EditHNear | FWL_STYLEEXT_CMB_ListItemLeftAlign; - break; - } - int32_t iVert = para.GetVerticalAlign(); - switch (iVert) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; - break; - } - } - return dwExtendedStyle; -} -FX_BOOL CXFA_FFComboBox::UpdateFWLData() { - if (!m_pNormalWidget) { - return FALSE; - } - CFX_Int32Array iSelArray; - m_pDataAcc->GetSelectedItems(iSelArray); - int32_t iSelCount = iSelArray.GetSize(); - if (iSelCount > 0) { - ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); - } else { - CFX_WideString wsText; - ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); - ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); - } - m_pNormalWidget->Update(); - return TRUE; -} -FX_BOOL CXFA_FFComboBox::CanUndo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditCanUndo(); -} -FX_BOOL CXFA_FFComboBox::CanRedo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditCanRedo(); -} -FX_BOOL CXFA_FFComboBox::Undo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditUndo(); -} -FX_BOOL CXFA_FFComboBox::Redo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditRedo(); -} -FX_BOOL CXFA_FFComboBox::CanCopy() { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCopy(); -} -FX_BOOL CXFA_FFComboBox::CanCut() { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCut(); -} -FX_BOOL CXFA_FFComboBox::CanPaste() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - (m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open); -} -FX_BOOL CXFA_FFComboBox::CanSelectAll() { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanSelectAll(); -} -FX_BOOL CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditCopy(wsCopy); -} -FX_BOOL CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditCut(wsCut); -} -FX_BOOL CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste); -} -FX_BOOL CXFA_FFComboBox::SelectAll() { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll(); -} -FX_BOOL CXFA_FFComboBox::Delete() { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete(); -} -FX_BOOL CXFA_FFComboBox::DeSelect() { - return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect(); -} -void CXFA_FFComboBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { - if (bSelected) { - ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(nIndex); - } else { - ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); - } - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, - int32_t nIndex) { - ((CFWL_ComboBox*)m_pNormalWidget)->AddString(wsLabel); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { - if (nIndex < 0) { - ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAll(); - } else { - ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAt(nIndex); - } - m_pNormalWidget->Update(); - AddInvalidateRect(); -} -void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget, - const CFX_WideString& wsChanged) { - CXFA_EventParam eParam; - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - eParam.m_wsChange = wsChanged; - FWLEventSelChange(&eParam); -} -void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget, - const CFX_Int32Array& arrSels, - FX_BOOL bLButtonUp) { - CXFA_EventParam eParam; - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - FWLEventSelChange(&eParam); - if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && - bLButtonUp) { - m_pDocView->SetFocusWidgetAcc(NULL); - } -} -void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_PreOpen; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam); -} -void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_PostOpen; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); -} - -int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - FX_DWORD dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_CMB_SelChanged: { - CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent; - OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels, - postEvent->bLButtonUp); - break; - } - case FWL_EVTHASH_CMB_EditChanged: { - CFX_WideString wsChanged; - OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); - break; - } - case FWL_EVTHASH_CMB_PreDropDown: { - OnPreOpen(m_pNormalWidget->GetWidget()); - break; - } - case FWL_EVTHASH_CMB_PostDropDown: { - OnPostOpen(m_pNormalWidget->GetWidget()); - break; - } - default: {} - } - return m_pOldDelegate->OnProcessEvent(pEvent); -} -FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/src/fxfa/app/xfa_ffchoicelist.h b/xfa/src/fxfa/app/xfa_ffchoicelist.h deleted file mode 100644 index 781360f8ad..0000000000 --- a/xfa/src/fxfa/app/xfa_ffchoicelist.h +++ /dev/null @@ -1,96 +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_SRC_FXFA_APP_XFA_FFCHOICELIST_H_ -#define XFA_SRC_FXFA_APP_XFA_FFCHOICELIST_H_ - -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" - -class CXFA_FFListBox : public CXFA_FFField { - public: - CXFA_FFListBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFListBox(); - virtual FX_BOOL LoadWidget(); - virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); - - protected: - virtual FX_BOOL CommitData(); - virtual FX_BOOL UpdateFWLData(); - virtual FX_BOOL IsDataChanged(); - FX_DWORD GetAlignment(); - - public: - void OnSelectChanged(IFWL_Widget* pWidget, const CFX_Int32Array& arrSels); - 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); - - protected: - IFWL_WidgetDelegate* m_pOldDelegate; -}; -class CXFA_FFComboBox : public CXFA_FFField { - public: - CXFA_FFComboBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFComboBox(); - virtual FX_BOOL GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus = FALSE); - virtual FX_BOOL LoadWidget(); - virtual void UpdateWidgetProperty(); - virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); - 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 CanPaste(); - 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(); - void OpenDropDownList(); - - protected: - virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL CommitData(); - virtual FX_BOOL UpdateFWLData(); - virtual FX_BOOL IsDataChanged(); - FX_DWORD GetAlignment(); - void FWLEventSelChange(CXFA_EventParam* pParam); - - CFX_WideString m_wsNewValue; - - public: - void OnTextChanged(IFWL_Widget* pWidget, const CFX_WideString& wsChanged); - void OnSelectChanged(IFWL_Widget* pWidget, - const CFX_Int32Array& arrSels, - FX_BOOL bLButtonUp); - void OnPreOpen(IFWL_Widget* pWidget); - void OnPostOpen(IFWL_Widget* pWidget); - 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); - - protected: - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFCHOICELIST_H_ diff --git a/xfa/src/fxfa/app/xfa_ffdoc.cpp b/xfa/src/fxfa/app/xfa_ffdoc.cpp deleted file mode 100644 index 0e45417399..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdoc.cpp +++ /dev/null @@ -1,431 +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/src/fxfa/app/xfa_ffdoc.h" - -#include "core/include/fpdfapi/cpdf_array.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfdoc/fpdf_doc.h" -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/include/fwl/core/fwl_note.h" -#include "xfa/src/fgas/crt/fgas_algorithm.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_ffnotify.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fontmgr.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" - -CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) - : m_pDocProvider(pDocProvider), - m_pDocument(nullptr), - m_pStream(nullptr), - m_pApp(pApp), - m_pNotify(nullptr), - m_pPDFDoc(nullptr), - m_dwDocType(XFA_DOCTYPE_Static), - m_bOwnStream(TRUE) {} -CXFA_FFDoc::~CXFA_FFDoc() { - CloseDoc(); -} -FX_DWORD CXFA_FFDoc::GetDocType() { - return m_dwDocType; -} -int32_t CXFA_FFDoc::StartLoad() { - m_pNotify = new CXFA_FFNotify(this); - IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify); - int32_t iStatus = pDocParser->StartParse(m_pStream); - m_pDocument = pDocParser->GetDocument(); - return iStatus; -} -FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, - uint8_t*& pByteBuffer, - int32_t& iBufferSize) { - IFDE_XMLElement* pDocumentElement = NULL; - for (IFDE_XMLNode* pXMLNode = - pPDFElement->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFX_WideString wsTagName; - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - pXMLElement->GetTagName(wsTagName); - if (wsTagName.Equal(FX_WSTRC(L"document"))) { - pDocumentElement = pXMLElement; - break; - } - } - } - if (!pDocumentElement) { - return FALSE; - } - IFDE_XMLElement* pChunkElement = NULL; - for (IFDE_XMLNode* pXMLNode = - pDocumentElement->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFX_WideString wsTagName; - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - pXMLElement->GetTagName(wsTagName); - if (wsTagName.Equal(FX_WSTRC(L"chunk"))) { - pChunkElement = pXMLElement; - break; - } - } - } - if (!pChunkElement) { - return FALSE; - } - CFX_WideString wsPDFContent; - pChunkElement->GetTextData(wsPDFContent); - iBufferSize = FX_Base64DecodeW(wsPDFContent, 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); - return TRUE; -} -void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) { - CXFA_Node* pChildNode = pNewRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - CXFA_Node* pOriginChild = - pOriginRoot->GetFirstChildByName(pChildNode->GetNameHash()); - if (pOriginChild) { - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } else { - CXFA_Node* pNextSibling = - pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pNewRoot->RemoveChild(pChildNode); - pOriginRoot->InsertChild(pChildNode); - pChildNode = pNextSibling; - pNextSibling = NULL; - } - } -} -int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { - int32_t iStatus = m_pDocument->GetParser()->DoParse(pPause); - if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) { - CXFA_Node* pPDFNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Pdf)); - if (!pPDFNode) { - return XFA_PARSESTATUS_SyntaxErr; - } - IFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); - if (pPDFXML->GetType() != FDE_XMLNODE_Element) { - return XFA_PARSESTATUS_SyntaxErr; - } - int32_t iBufferSize = 0; - uint8_t* pByteBuffer = NULL; - IFX_FileRead* pXFAReader = NULL; - if (XFA_GetPDFContentsFromPDFXML(pPDFXML, pByteBuffer, iBufferSize)) { - pXFAReader = FX_CreateMemoryStream(pByteBuffer, iBufferSize, TRUE); - } else { - CFX_WideString wsHref; - ((IFDE_XMLElement*)pPDFXML)->GetString(L"href", wsHref); - if (!wsHref.IsEmpty()) { - pXFAReader = GetDocProvider()->OpenLinkedFile(this, wsHref); - } - } - if (!pXFAReader) { - return XFA_PARSESTATUS_SyntaxErr; - } - CPDF_Document* pPDFDocument = - GetDocProvider()->OpenPDF(this, pXFAReader, TRUE); - FXSYS_assert(!m_pPDFDoc); - if (!OpenDoc(pPDFDocument)) { - return XFA_PARSESTATUS_SyntaxErr; - } - IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument, TRUE); - if (!pParser) { - return XFA_PARSESTATUS_SyntaxErr; - } - CXFA_Node* pRootNode = NULL; - if (pParser->StartParse(m_pStream) == XFA_PARSESTATUS_Ready && - pParser->DoParse(NULL) == XFA_PARSESTATUS_Done) { - pRootNode = pParser->GetRootNode(); - } - if (pRootNode && m_pDocument->GetRoot()) { - XFA_XPDPacket_MergeRootNode(m_pDocument->GetRoot(), pRootNode); - iStatus = XFA_PARSESTATUS_Done; - } else { - iStatus = XFA_PARSESTATUS_StatusErr; - } - pParser->Release(); - pParser = NULL; - } - return iStatus; -} -void CXFA_FFDoc::StopLoad() { - m_pApp->GetXFAFontMgr()->LoadDocFonts(this); - m_dwDocType = XFA_DOCTYPE_Static; - CXFA_Node* pConfig = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); - if (!pConfig) { - return; - } - CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); - if (!pAcrobat) { - return; - } - CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_ELEMENT_Acrobat7); - if (!pAcrobat7) { - return; - } - CXFA_Node* pDynamicRender = - pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); - if (!pDynamicRender) { - return; - } - CFX_WideString wsType; - if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { - m_dwDocType = XFA_DOCTYPE_Dynamic; - } -} -IXFA_DocView* CXFA_FFDoc::CreateDocView(FX_DWORD 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; -} -CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* 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; - } - } - return NULL; -} -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; -} -FX_BOOL CXFA_FFDoc::OpenDoc(IFX_FileRead* pStream, FX_BOOL bTakeOverFile) { - m_bOwnStream = bTakeOverFile; - m_pStream = pStream; - return TRUE; -} -FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { - if (pPDFDoc == NULL) { - return FALSE; - } - CPDF_Dictionary* pRoot = pPDFDoc->GetRoot(); - if (pRoot == NULL) { - return FALSE; - } - CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); - if (pAcroForm == NULL) { - return FALSE; - } - CPDF_Object* pElementXFA = pAcroForm->GetElementValue("XFA"); - if (pElementXFA == NULL) { - return FALSE; - } - CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; - if (pElementXFA->IsArray()) { - CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; - FX_DWORD count = pXFAArray->GetCount() / 2; - for (FX_DWORD i = 0; i < count; i++) { - if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) - xfaStreams.Add(pStream); - } - } else if (pElementXFA->IsStream()) { - xfaStreams.Add((CPDF_Stream*)pElementXFA); - } - if (xfaStreams.GetSize() < 1) { - return FALSE; - } - IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); - m_pPDFDoc = pPDFDoc; - if (m_pStream) { - m_pStream->Release(); - m_pStream = NULL; - } - m_pStream = pFileRead; - m_bOwnStream = TRUE; - 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) { - 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(); - if (m_pDocument) { - IXFA_Parser* pParser = m_pDocument->GetParser(); - pParser->Release(); - m_pDocument = NULL; - } - if (m_pNotify) { - delete m_pNotify; - m_pNotify = NULL; - } - 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_mapNamedImages.RemoveAll(); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->ClearEventTargets(FALSE); - return TRUE; -} -void CXFA_FFDoc::SetDocType(FX_DWORD dwType) { - m_dwDocType = dwType; -} -CPDF_Document* CXFA_FFDoc::GetPDFDoc() { - return m_pPDFDoc; -} - -CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - if (!m_pPDFDoc) - return nullptr; - - FX_DWORD dwHash = - FX_HashCode_String_GetW(wsName.GetPtr(), 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); - } - - CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); - if (!pRoot) - return nullptr; - - CPDF_Dictionary* pNames = pRoot->GetDictBy("Names"); - if (!pNames) - return nullptr; - - CPDF_Dictionary* pXFAImages = pNames->GetDictBy("XFAImages"); - if (!pXFAImages) - return nullptr; - - CPDF_NameTree nametree(pXFAImages); - CFX_ByteString bsName = PDF_EncodeText(wsName.GetPtr(), wsName.GetLength()); - CPDF_Object* pObject = nametree.LookupValue(bsName); - if (!pObject) { - int32_t iCount = nametree.GetCount(); - for (int32_t i = 0; i < iCount; i++) { - CFX_ByteString bsTemp; - CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); - if (bsTemp == bsName) { - pObject = pTempObject; - break; - } - } - } - - if (!pObject || !pObject->IsStream()) - 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; -} - -IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { - FX_DWORD packetHash = - FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); - CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); - if (!pNode) { - return NULL; - } - IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); - return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) - ? (IFDE_XMLElement*)pXMLNode - : NULL; -} -FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - IXFA_ChecksumContext* pCSContext) { - IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); - if (!pExport) { - return FALSE; - } - FX_DWORD packetHash = - FX_HashCode_String_GetW(wsPackage.GetPtr(), 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; -} -FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { - FX_BOOL bRet = FALSE; - IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); - if (pImport) { - bRet = pImport->ImportData(pStream); - pImport->Release(); - } - return bRet; -} diff --git a/xfa/src/fxfa/app/xfa_ffdoc.h b/xfa/src/fxfa/app/xfa_ffdoc.h deleted file mode 100644 index c5980138aa..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdoc.h +++ /dev/null @@ -1,64 +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_SRC_FXFA_APP_XFA_FFDOC_H_ -#define XFA_SRC_FXFA_APP_XFA_FFDOC_H_ - -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fxfa/parser/xfa_document.h" - -class CXFA_FFApp; -class CXFA_FFNotify; -class CXFA_FFDocView; - -struct FX_IMAGEDIB_AND_DPI { - CFX_DIBSource* pDibSource; - int32_t iImageXDpi; - int32_t iImageYDpi; -}; - -class CXFA_FFDoc : public IXFA_Doc { - public: - CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider); - ~CXFA_FFDoc(); - IXFA_DocProvider* GetDocProvider() { return m_pDocProvider; } - FX_DWORD GetDocType(); - int32_t StartLoad(); - int32_t DoLoad(IFX_Pause* pPause = NULL); - void StopLoad(); - IXFA_DocView* CreateDocView(FX_DWORD dwView = 0); - FX_BOOL OpenDoc(IFX_FileRead* pStream, FX_BOOL bTakeOverFile); - FX_BOOL OpenDoc(CPDF_Document* pPDFDoc); - FX_BOOL CloseDoc(); - void SetDocType(FX_DWORD dwType); - CXFA_Document* GetXFADoc() { return m_pDocument; } - CXFA_FFApp* GetApp() { return m_pApp; } - CXFA_FFDocView* GetDocView(IXFA_DocLayout* pLayout); - CXFA_FFDocView* GetDocView(); - CPDF_Document* GetPDFDoc(); - CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi); - IFDE_XMLElement* GetPackageData(const CFX_WideStringC& wsPackage); - FX_BOOL SavePackage(const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - IXFA_ChecksumContext* pCSContext = NULL); - FX_BOOL ImportData(IFX_FileRead* pStream, FX_BOOL bXDP = TRUE); - - protected: - IXFA_DocProvider* m_pDocProvider; - CXFA_Document* m_pDocument; - IFX_FileRead* m_pStream; - CXFA_FFApp* m_pApp; - CXFA_FFNotify* m_pNotify; - CPDF_Document* m_pPDFDoc; - CFX_MapPtrToPtr m_mapNamedImages; - CFX_MapPtrToPtr m_mapTypeToDocView; - FX_DWORD m_dwDocType; - FX_BOOL m_bOwnStream; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFDOC_H_ diff --git a/xfa/src/fxfa/app/xfa_ffdochandler.cpp b/xfa/src/fxfa/app/xfa_ffdochandler.cpp deleted file mode 100644 index f2473659ec..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdochandler.cpp +++ /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 - -#include "xfa/src/fxfa/app/xfa_ffdochandler.h" - -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -CXFA_FFDocHandler::CXFA_FFDocHandler() {} -CXFA_FFDocHandler::~CXFA_FFDocHandler() {} -void CXFA_FFDocHandler::ReleaseDoc(IXFA_Doc* hDoc) { - delete hDoc; // virtual dtor. -} -IXFA_DocProvider* CXFA_FFDocHandler::GetDocProvider(IXFA_Doc* hDoc) { - return static_cast<CXFA_FFDoc*>(hDoc)->GetDocProvider(); -} -FX_DWORD CXFA_FFDocHandler::GetDocType(IXFA_Doc* hDoc) { - return static_cast<CXFA_FFDoc*>(hDoc)->GetDocType(); -} -int32_t CXFA_FFDocHandler::StartLoad(IXFA_Doc* hDoc) { - return static_cast<CXFA_FFDoc*>(hDoc)->StartLoad(); -} -int32_t CXFA_FFDocHandler::DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause) { - return static_cast<CXFA_FFDoc*>(hDoc)->DoLoad(pPause); -} -void CXFA_FFDocHandler::StopLoad(IXFA_Doc* hDoc) { - static_cast<CXFA_FFDoc*>(hDoc)->StopLoad(); -} - -IXFA_DocView* CXFA_FFDocHandler::CreateDocView(IXFA_Doc* hDoc, - FX_DWORD dwView) { - return static_cast<CXFA_FFDoc*>(hDoc)->CreateDocView(dwView); -} -int32_t CXFA_FFDocHandler::CountPackages(IXFA_Doc* hDoc) { - return 0; -} -void CXFA_FFDocHandler::GetPackageName(IXFA_Doc* hDoc, - int32_t iPackage, - CFX_WideStringC& wsPackage) {} -IFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( - IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage) { - return static_cast<CXFA_FFDoc*>(hDoc)->GetPackageData(wsPackage); -} -FX_BOOL CXFA_FFDocHandler::SavePackage(IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - IXFA_ChecksumContext* pCSContext) { - return static_cast<CXFA_FFDoc*>(hDoc) - ->SavePackage(wsPackage, pFile, pCSContext); -} -FX_BOOL CXFA_FFDocHandler::CloseDoc(IXFA_Doc* hDoc) { - return static_cast<CXFA_FFDoc*>(hDoc)->CloseDoc(); -} - -FX_BOOL CXFA_FFDocHandler::ImportData(IXFA_Doc* hDoc, - IFX_FileRead* pStream, - FX_BOOL bXDP) { - return static_cast<CXFA_FFDoc*>(hDoc)->ImportData(pStream, bXDP); -} -void CXFA_FFDocHandler::SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime) { - static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc()->InitScriptContext(hRuntime); -} -FXJSE_HVALUE CXFA_FFDocHandler::GetXFAScriptObject(IXFA_Doc* hDoc) { - CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); - if (!pXFADoc) { - return NULL; - } - IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) { - return NULL; - } - return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); -} -XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(IXFA_Doc* hDoc) { - CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); - if (!pXFADoc) { - return XFA_ATTRIBUTEENUM_Unknown; - } - CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); - if (!pForm) { - return XFA_ATTRIBUTEENUM_Unknown; - } - CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform); - if (!pSubForm) { - return XFA_ATTRIBUTEENUM_Unknown; - } - return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); -} -FX_BOOL CXFA_FFDocHandler::RunDocScript(IXFA_Doc* hDoc, - XFA_SCRIPTTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - FXJSE_HVALUE hThisObject) { - CXFA_Document* pXFADoc = static_cast<CXFA_FFDoc*>(hDoc)->GetXFADoc(); - if (!pXFADoc) { - return FALSE; - } - IXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) { - return FALSE; - } - return pScriptContext->RunScript( - (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, hRetValue, - hThisObject ? (CXFA_Object*)FXJSE_Value_ToObject(hThisObject, NULL) - : NULL); -} diff --git a/xfa/src/fxfa/app/xfa_ffdochandler.h b/xfa/src/fxfa/app/xfa_ffdochandler.h deleted file mode 100644 index e324bff81d..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdochandler.h +++ /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 - -#ifndef XFA_SRC_FXFA_APP_XFA_FFDOCHANDLER_H_ -#define XFA_SRC_FXFA_APP_XFA_FFDOCHANDLER_H_ - -#include "xfa/include/fxfa/fxfa.h" - -class CXFA_FFDocHandler : public IXFA_DocHandler { - public: - CXFA_FFDocHandler(); - ~CXFA_FFDocHandler(); - virtual void ReleaseDoc(IXFA_Doc* hDoc); - virtual IXFA_DocProvider* GetDocProvider(IXFA_Doc* hDoc); - virtual FX_DWORD GetDocType(IXFA_Doc* hDoc); - virtual int32_t StartLoad(IXFA_Doc* hDoc); - virtual int32_t DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause = NULL); - virtual void StopLoad(IXFA_Doc* hDoc); - - virtual IXFA_DocView* CreateDocView(IXFA_Doc* hDoc, FX_DWORD dwView = 0); - virtual int32_t CountPackages(IXFA_Doc* hDoc); - virtual void GetPackageName(IXFA_Doc* hDoc, - int32_t iPackage, - CFX_WideStringC& wsPackage); - virtual IFDE_XMLElement* GetPackageData(IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage); - virtual FX_BOOL SavePackage(IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - IXFA_ChecksumContext* pCSContext = NULL); - virtual FX_BOOL CloseDoc(IXFA_Doc* hDoc); - virtual FX_BOOL ImportData(IXFA_Doc* hDoc, - IFX_FileRead* pStream, - FX_BOOL bXDP = TRUE); - virtual void SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime); - virtual FXJSE_HVALUE GetXFAScriptObject(IXFA_Doc* hDoc); - virtual XFA_ATTRIBUTEENUM GetRestoreState(IXFA_Doc* hDoc); - virtual FX_BOOL RunDocScript(IXFA_Doc* hDoc, - XFA_SCRIPTTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - FXJSE_HVALUE hThisObject); - - protected: -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFDOCHANDLER_H_ diff --git a/xfa/src/fxfa/app/xfa_ffdocview.cpp b/xfa/src/fxfa/app/xfa_ffdocview.cpp deleted file mode 100644 index 3c94a69d87..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdocview.cpp +++ /dev/null @@ -1,932 +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/src/fxfa/app/xfa_ffdocview.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffbarcode.h" -#include "xfa/src/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/src/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdraw.h" -#include "xfa/src/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffimage.h" -#include "xfa/src/fxfa/app/xfa_ffimageedit.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffpath.h" -#include "xfa/src/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/src/fxfa/app/xfa_ffsignature.h" -#include "xfa/src/fxfa/app/xfa_ffsubform.h" -#include "xfa/src/fxfa/app/xfa_fftext.h" -#include "xfa/src/fxfa/app/xfa_fftextedit.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/src/fxfa/app/xfa_ffwidgethandler.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = { - XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, - XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, - XFA_ATTRIBUTEENUM_Enter, XFA_ATTRIBUTEENUM_Exit, - XFA_ATTRIBUTEENUM_Full, XFA_ATTRIBUTEENUM_IndexChange, - XFA_ATTRIBUTEENUM_Initialize, XFA_ATTRIBUTEENUM_MouseDown, - XFA_ATTRIBUTEENUM_MouseEnter, XFA_ATTRIBUTEENUM_MouseExit, - XFA_ATTRIBUTEENUM_MouseUp, XFA_ATTRIBUTEENUM_PostExecute, - XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, - XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, - XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, - XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, - XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, - XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, - XFA_ATTRIBUTEENUM_Unknown, -}; -CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) - : m_bLayoutEvent(FALSE), - m_pListFocusWidget(nullptr), - m_bInLayoutStatus(FALSE), - m_pDoc(pDoc), - m_pWidgetHandler(nullptr), - m_pXFADocLayout(nullptr), - m_pFocusAcc(nullptr), - m_pFocusWidget(nullptr), - 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; -} -void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { - RunBindItems(); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange); -} -int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; - m_pDoc->GetXFADoc()->DoProtoMerge(); - m_pDoc->GetXFADoc()->DoDataMerge(); - m_pXFADocLayout = GetXFALayout(); - int32_t iStatus = m_pXFADocLayout->StartLayout(); - if (iStatus < 0) { - return iStatus; - } - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return iStatus; - } - InitLayout(pRootItem); - InitCalculate(pRootItem); - InitValidate(pRootItem); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE); - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; - return iStatus; -} -int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { - int32_t iStatus = 100; - iStatus = m_pXFADocLayout->DoLayout(pPause); - if (iStatus != 100) { - return iStatus; - } - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; - return iStatus; -} -void CXFA_FFDocView::StopLayout() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return; - } - CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform); - if (!pSubformNode) { - return; - } - CXFA_Node* pPageSetNode = - pSubformNode->GetFirstChildByClass(XFA_ELEMENT_PageSet); - if (!pPageSetNode) { - return; - } - RunCalculateWidgets(); - RunValidate(); - InitLayout(pPageSetNode); - InitCalculate(pPageSetNode); - InitValidate(pPageSetNode); - ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady); - RunCalculateWidgets(); - RunValidate(); - if (RunLayout()) { - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); - } - m_CalculateAccs.RemoveAll(); - if (m_pFocusAcc && !m_pFocusWidget) { - SetFocusWidgetAcc(m_pFocusAcc); - } - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; -} -int32_t CXFA_FFDocView::GetLayoutStatus() { - return m_iStatus; -} -void CXFA_FFDocView::ShowNullTestMsg() { - int32_t iCount = m_arrNullTestMsg.GetSize(); - CXFA_FFApp* pApp = m_pDoc->GetApp(); - IXFA_AppProvider* pAppProvider = pApp->GetAppProvider(); - if (pAppProvider && iCount) { - int32_t iRemain = iCount > 7 ? iCount - 7 : 0; - iCount -= iRemain; - CFX_WideString wsMsg; - for (int32_t i = 0; i < iCount; i++) { - wsMsg += m_arrNullTestMsg[i] + FX_WSTRC(L"\n"); - } - if (iRemain > 0) { - CFX_WideString wsLimit; - pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit); - if (!wsLimit.IsEmpty()) { - CFX_WideString wsTemp; - wsTemp.Format((const FX_WCHAR*)wsLimit, iRemain); - wsMsg += FX_WSTRC(L"\n") + wsTemp; - } - } - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); - pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); - } - m_arrNullTestMsg.RemoveAll(); -} -void CXFA_FFDocView::UpdateDocView() { - if (IsUpdateLocked()) { - return; - } - 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]); - InitCalculate(pNode); - InitValidate(pNode); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE); - } - m_NewAddedNodes.RemoveAll(); - RunSubformIndexChange(); - RunCalculateWidgets(); - RunValidate(); - ShowNullTestMsg(); - if (RunLayout() && m_bLayoutEvent) { - RunEventLayoutReady(); - } - m_bLayoutEvent = FALSE; - m_CalculateAccs.RemoveAll(); - RunInvalidate(); - UnlockUpdate(); -} -int32_t CXFA_FFDocView::CountPageViews() { - if (!m_pXFADocLayout) { - return 0; - } - return m_pXFADocLayout->CountPages(); -} -IXFA_PageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { - if (!m_pXFADocLayout) { - return NULL; - } - return static_cast<CXFA_FFPageView*>(m_pXFADocLayout->GetPage(nIndex)); -} -IXFA_Widget* CXFA_FFDocView::GetWidgetByName(const CFX_WideStringC& wsName) { - return GetWidgetByName(wsName, NULL); -} -CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( - const CFX_WideStringC& wsName) { - return GetWidgetAccByName(wsName, NULL); -} -IXFA_DocLayout* CXFA_FFDocView::GetXFALayout() const { - return m_pDoc->GetXFADoc()->GetDocLayout(); -} -FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_Node* pNode = pWidgetAcc->GetNode(); - XFA_ELEMENT eType = pNode->GetClassID(); - 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); - } - return TRUE; -} -void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { - m_bLayoutEvent = TRUE; - FX_BOOL bChanged = FALSE; - CXFA_Node* pFormNode = NULL; - if (pWidgetAcc) { - bChanged = ResetSingleWidgetAccData(pWidgetAcc); - pFormNode = pWidgetAcc->GetNode(); - } else { - pFormNode = GetRootSubform(); - } - if (!pFormNode) { - return; - } - if (pFormNode->GetClassID() != XFA_ELEMENT_Field && - pFormNode->GetClassID() != XFA_ELEMENT_ExclGroup) { - CXFA_WidgetAccIterator Iterator(this, pFormNode); - while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { - bChanged |= ResetSingleWidgetAccData(pAcc); - if (pAcc->GetNode()->GetClassID() == XFA_ELEMENT_ExclGroup) { - Iterator.SkipTree(); - } - } - } - if (bChanged) { - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); - } -} -int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, - CXFA_WidgetAcc* pWidgetAcc) { - if (pParam == NULL) { - return XFA_EVENTERROR_Error; - } - if (pParam->m_eType == XFA_EVENT_Validate) { - CFX_WideString wsValidateStr = FX_WSTRC(L"preSubmit"); - CXFA_Node* pConfigItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); - if (pConfigItem) { - CXFA_Node* pValidateNode = NULL; - CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_ELEMENT_Acrobat); - pValidateNode = - pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_ELEMENT_Validate) : NULL; - if (!pValidateNode) { - CXFA_Node* pPresentNode = pConfigItem->GetChild(0, XFA_ELEMENT_Present); - pValidateNode = pPresentNode - ? pPresentNode->GetChild(0, XFA_ELEMENT_Validate) - : NULL; - } - if (pValidateNode) { - wsValidateStr = pValidateNode->GetContent(); - } - } - FX_BOOL bValidate = FALSE; - switch (pParam->m_iValidateActivities) { - case XFA_VALIDATE_preSubmit: - bValidate = wsValidateStr.Find(L"preSubmit") != -1; - break; - case XFA_VALIDATE_prePrint: - bValidate = wsValidateStr.Find(L"prePrint") != -1; - break; - case XFA_VALIDATE_preExecute: - bValidate = wsValidateStr.Find(L"preExecute") != -1; - break; - case XFA_VALIDATE_preSave: - bValidate = wsValidateStr.Find(L"preSave") != -1; - break; - } - if (!bValidate) { - return XFA_EVENTERROR_Sucess; - } - } - CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : NULL; - if (!pNode) { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return XFA_EVENTERROR_Error; - } - pNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform); - } - ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady); - return XFA_EVENTERROR_Sucess; -} -IXFA_WidgetHandler* CXFA_FFDocView::GetWidgetHandler() { - if (!m_pWidgetHandler) { - m_pWidgetHandler = new CXFA_FFWidgetHandler(this); - } - return m_pWidgetHandler; -} -IXFA_WidgetIterator* CXFA_FFDocView::CreateWidgetIterator() { - CXFA_Node* pFormRoot = GetRootSubform(); - if (!pFormRoot) { - return NULL; - } - return new CXFA_FFDocWidgetIterator(this, pFormRoot); -} -IXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( - XFA_WIDGETORDER eOrder) { - CXFA_Node* pFormRoot = GetRootSubform(); - if (!pFormRoot) { - return NULL; - } - return new CXFA_WidgetAccIterator(this, pFormRoot); -} -IXFA_Widget* CXFA_FFDocView::GetFocusWidget() { - return m_pFocusWidget; -} -void CXFA_FFDocView::KillFocus() { - if (m_pFocusWidget && - (m_pFocusWidget->GetStatus() & XFA_WIDGETSTATUS_Focused)) { - (m_pFocusWidget)->OnKillFocus(NULL); - } - m_pFocusAcc = NULL; - m_pFocusWidget = NULL; - m_pOldFocusWidget = NULL; -} -FX_BOOL CXFA_FFDocView::SetFocus(IXFA_Widget* hWidget) { - CXFA_FFWidget* pNewFocus = (CXFA_FFWidget*)hWidget; - if (m_pOldFocusWidget == pNewFocus) { - return FALSE; - } - CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; - m_pOldFocusWidget = pNewFocus; - if (pOldFocus) { - if (m_pFocusWidget != m_pOldFocusWidget && - (pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Focused)) { - m_pFocusWidget = pOldFocus; - pOldFocus->OnKillFocus(pNewFocus); - } else if ((pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { - if (!pOldFocus->IsLoaded()) { - pOldFocus->LoadWidget(); - } - pOldFocus->OnSetFocus(m_pFocusWidget); - m_pFocusWidget = pOldFocus; - pOldFocus->OnKillFocus(pNewFocus); - } - } - if (m_pFocusWidget == m_pOldFocusWidget) { - return FALSE; - } - pNewFocus = m_pOldFocusWidget; - if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { - m_pFocusAcc = NULL; - m_pFocusWidget = NULL; - m_pListFocusWidget = NULL; - m_pOldFocusWidget = NULL; - return FALSE; - } - if (pNewFocus && (pNewFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { - if (!pNewFocus->IsLoaded()) { - pNewFocus->LoadWidget(); - } - pNewFocus->OnSetFocus(m_pFocusWidget); - } - m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : NULL; - m_pFocusWidget = pNewFocus; - m_pOldFocusWidget = m_pFocusWidget; - return TRUE; -} -CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { - return m_pFocusAcc; -} -void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_FFWidget* pNewFocus = - pWidgetAcc ? pWidgetAcc->GetNextWidget(NULL) : NULL; - if (SetFocus(pNewFocus)) { - m_pFocusAcc = pWidgetAcc; - if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { - m_pDoc->GetDocProvider()->SetFocusWidget(m_pDoc, m_pFocusWidget); - } - } -} -void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { - if (m_pFocusAcc == pWidget->GetDataAcc()) { - m_pFocusAcc = NULL; - m_pFocusWidget = NULL; - m_pOldFocusWidget = NULL; - } -} -static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, - CXFA_WidgetAcc* pWidgetAcc, - CXFA_EventParam* pParam) { - if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { - return XFA_EVENTERROR_NotExist; - } - if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { - return XFA_EVENTERROR_NotExist; - } - switch (pParam->m_eType) { - case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); - case XFA_EVENT_Validate: - if (((CXFA_FFDoc*)pDocView->GetDoc()) - ->GetDocProvider() - ->IsValidationsEnabled(pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(0x01); - } - return XFA_EVENTERROR_Disabled; - case XFA_EVENT_InitCalculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { - return XFA_EVENTERROR_NotExist; - } - if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return XFA_EVENTERROR_Disabled; - } - CXFA_Script script = calc.GetScript(); - return pWidgetAcc->ExecuteScript(script, pParam); - } - default: - break; - } - int32_t iRet = - pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); - return iRet; -} -int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady, - FX_BOOL bRecursive, - CXFA_Node* pExclude) { - int32_t iRet = XFA_EVENTERROR_NotExist; - if (pFormNode == pExclude) { - return iRet; - } - XFA_ELEMENT elementType = pFormNode->GetClassID(); - if (elementType == XFA_ELEMENT_Field) { - if (eEventType == XFA_EVENT_IndexChange) { - return iRet; - } - CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); - if (pWidgetAcc == NULL) { - return iRet; - } - CXFA_EventParam eParam; - eParam.m_eType = eEventType; - eParam.m_pTarget = pWidgetAcc; - eParam.m_bIsFormReady = bIsFormReady; - return XFA_ProcessEvent(this, pWidgetAcc, &eParam); - } - if (bRecursive) { - for (CXFA_Node* pNode = pFormNode->GetNodeItem( - XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_OBJECTTYPE_ContainerNode)) { - elementType = pNode->GetClassID(); - if (elementType != XFA_ELEMENT_Variables && - elementType != XFA_ELEMENT_Draw) { - iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, - bRecursive, pExclude); - } - } - } - CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); - if (pWidgetAcc == NULL) { - return iRet; - } - CXFA_EventParam eParam; - eParam.m_eType = eEventType; - eParam.m_pTarget = pWidgetAcc; - eParam.m_bIsFormReady = bIsFormReady; - iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam); - return iRet; -} -CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideStringC& 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* CXFA_FFDocView::GetWidgetAccByName( - const CFX_WideStringC& wsName, - CXFA_WidgetAcc* pRefWidgetAcc) { - CFX_WideString wsExpression; - FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; - IXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext(); - if (!pScriptContext) { - return NULL; - } - CXFA_Node* refNode = NULL; - if (pRefWidgetAcc) { - refNode = pRefWidgetAcc->GetNode(); - wsExpression = wsName; - } else { - wsExpression = L"$form." + wsName; - } - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = pScriptContext->ResolveObjects(refNode, wsExpression, - resoveNodeRS, dwStyle); - if (iRet < 1) { - return NULL; - } - if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - CXFA_Node* pNode = resoveNodeRS.nodes[0]->AsNode(); - if (pNode) { - return (CXFA_WidgetAcc*)pNode->GetWidgetData(); - } - } - return NULL; -} -void CXFA_FFDocView::OnPageEvent(IXFA_LayoutPage* pSender, - XFA_PAGEEVENT eEvent, - int32_t iPageIndex) { - 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(); -} -void CXFA_FFDocView::LockUpdate() { - m_iLock++; -} -void CXFA_FFDocView::UnlockUpdate() { - m_iLock--; -} -FX_BOOL CXFA_FFDocView::IsUpdateLocked() { - return m_iLock; -} -void CXFA_FFDocView::ClearInvalidateList() { - FX_POSITION ps = m_mapPageInvalidate.GetStartPosition(); - while (ps) { - void* pPageView = NULL; - CFX_RectF* pRect = NULL; - m_mapPageInvalidate.GetNextAssoc(ps, pPageView, (void*&)pRect); - delete pRect; - } - m_mapPageInvalidate.RemoveAll(); -} -void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, - const CFX_RectF& rtInvalidate) { - AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); -} -void CXFA_FFDocView::AddInvalidateRect(IXFA_PageView* pPageView, - const CFX_RectF& rtInvalidate) { - CFX_RectF* pRect = (CFX_RectF*)m_mapPageInvalidate.GetValueAt(pPageView); - if (!pRect) { - pRect = new CFX_RectF; - pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, - rtInvalidate.height); - m_mapPageInvalidate.SetAt(pPageView, pRect); - } else { - pRect->Union(rtInvalidate); - } -} -void CXFA_FFDocView::RunInvalidate() { - FX_POSITION ps = m_mapPageInvalidate.GetStartPosition(); - while (ps) { - IXFA_PageView* pPageView = NULL; - CFX_RectF* pRect = NULL; - m_mapPageInvalidate.GetNextAssoc(ps, (void*&)pPageView, (void*&)pRect); - m_pDoc->GetDocProvider()->InvalidateRect(pPageView, *pRect); - delete pRect; - } - m_mapPageInvalidate.RemoveAll(); -} -FX_BOOL CXFA_FFDocView::RunLayout() { - LockUpdate(); - m_bInLayoutStatus = TRUE; - if (!m_pXFADocLayout->IncrementLayout() && - m_pXFADocLayout->StartLayout() < 100) { - m_pXFADocLayout->DoLayout(); - UnlockUpdate(); - m_bInLayoutStatus = FALSE; - return TRUE; - } - m_bInLayoutStatus = FALSE; - UnlockUpdate(); - return FALSE; -} -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_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData(); - if (!pWidgetAcc) { - continue; - } - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_IndexChange; - eParam.m_pTarget = pWidgetAcc; - pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); - } - m_IndexChangedSubforms.RemoveAll(); -} -void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode) { - m_NewAddedNodes.Add(pNode); - InitLayout(pNode); -} -void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { - FXSYS_assert(pNode->GetClassID() == XFA_ELEMENT_Subform); - m_IndexChangedSubforms.Add(pNode); -} -void CXFA_FFDocView::RunDocClose() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return; - } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose); -} -void CXFA_FFDocView::DestroyDocView() { - ClearInvalidateList(); - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; - m_iLock = 0; - m_ValidateAccs.RemoveAll(); - m_bindItems.RemoveAll(); - m_CalculateAccs.RemoveAll(); -} -FX_BOOL CXFA_FFDocView::IsStaticNotify() { - return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; -} -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]; - if (pCurrentAcc != pWidgetAcc) { - m_CalculateAccs.Add(pWidgetAcc); - } -} -void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { - CXFA_CalcData* pGlobalData = - (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]; - 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]; - if (pCurrentAcc != pResultAcc) { - m_CalculateAccs.Add(pResultAcc); - } - } -} -void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { - while (iIndex < m_CalculateAccs.GetSize()) { - CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex]; - AddCalculateNodeNotify(pCurAcc->GetNode()); - int32_t iRefCount = - (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); - iRefCount++; - pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, - (void*)(uintptr_t)iRefCount); - if (iRefCount > 11) { - break; - } - if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Sucess) { - AddValidateWidget(pCurAcc); - } - iIndex++; - RunCalculateRecursive(iIndex); - } -} -int32_t CXFA_FFDocView::RunCalculateWidgets() { - if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { - return XFA_EVENTERROR_Disabled; - } - int32_t iCounts = m_CalculateAccs.GetSize(); - int32_t iIndex = 0; - if (iCounts > 0) { - RunCalculateRecursive(iIndex); - } - for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) { - CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i]; - pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); - } - m_CalculateAccs.RemoveAll(); - return XFA_EVENTERROR_Sucess; -} -void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { - if (m_ValidateAccs.Find(pWidget) < 0) { - m_ValidateAccs.Add(pWidget); - } -} -FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate); - return TRUE; -} -FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { - if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { - return FALSE; - } - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate); - m_ValidateAccs.RemoveAll(); - return TRUE; -} -FX_BOOL CXFA_FFDocView::RunValidate() { - if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { - return FALSE; - } - int32_t iCounts = m_ValidateAccs.GetSize(); - for (int32_t i = 0; i < iCounts; i++) { - CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i]; - if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { - continue; - } - pAcc->ProcessValidate(); - } - m_ValidateAccs.RemoveAll(); - return TRUE; -} -FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return FALSE; - } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); - RunLayout(); - return TRUE; -} -void CXFA_FFDocView::RunBindItems() { - 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)) { - continue; - } - CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i]) - ->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData(); - if (!pAcc) { - continue; - } - CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i])); - IXFA_ScriptContext* pScriptContext = - pWidgetNode->GetDocument()->GetScriptContext(); - CFX_WideStringC wsRef; - binditems.GetRef(wsRef); - FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_ALL; - XFA_RESOLVENODE_RS rs; - pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); - int32_t iCount = rs.nodes.GetSize(); - pAcc->DeleteItem(-1); - if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) { - continue; - } - CFX_WideStringC wsValueRef, wsLabelRef; - binditems.GetValueRef(wsValueRef); - binditems.GetLabelRef(wsLabelRef); - const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; - const bool bLabelUseContent = - wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$"); - const bool bValueUseContent = - wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$"); - CFX_WideString wsValue, wsLabel; - FX_DWORD uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef), - wsValueRef.GetLength()); - for (int32_t i = 0; i < iCount; i++) { - CXFA_Object* refObj = rs.nodes[i]; - if (!refObj->IsNode()) { - continue; - } - CXFA_Node* refNode = refObj->AsNode(); - if (bValueUseContent) { - wsValue = refNode->GetContent(); - } else { - CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash); - if (nodeValue == NULL) { - wsValue = refNode->GetContent(); - } else { - wsValue = nodeValue->GetContent(); - } - } - if (!bUseValue) { - if (bLabelUseContent) { - wsLabel = refNode->GetContent(); - } else { - CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); - if (nodeLabel) - wsLabel = nodeLabel->GetContent(); - } - } else { - wsLabel = wsValue; - } - pAcc->InsertItem(wsLabel, wsValue); - } - } - m_bindItems.RemoveAll(); -} -void CXFA_FFDocView::SetChangeMark() { - if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { - return; - } - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); -} -CXFA_Node* CXFA_FFDocView::GetRootSubform() { - CXFA_Node* pFormPacketNode = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pFormPacketNode) { - return NULL; - } - return pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform); -} -CXFA_FFDocWidgetIterator::CXFA_FFDocWidgetIterator(CXFA_FFDocView* pDocView, - CXFA_Node* pTravelRoot) - : m_ContentIterator(pTravelRoot) { - m_pDocView = pDocView; - m_pCurWidget = NULL; -} -CXFA_FFDocWidgetIterator::~CXFA_FFDocWidgetIterator() {} -void CXFA_FFDocWidgetIterator::Reset() { - m_ContentIterator.Reset(); - m_pCurWidget = NULL; -} -IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToFirst() { - return NULL; -} -IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToLast() { - return NULL; -} -IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToNext() { - CXFA_Node* pItem = m_pCurWidget ? m_ContentIterator.MoveToNext() - : m_ContentIterator.GetCurrent(); - while (pItem) { - 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->LoadWidget(); - } - return m_pCurWidget; - } - } - pItem = m_ContentIterator.MoveToNext(); - } - return NULL; -} -IXFA_Widget* CXFA_FFDocWidgetIterator::MoveToPrevious() { - return NULL; -} -IXFA_Widget* CXFA_FFDocWidgetIterator::GetCurrentWidget() { - return NULL; -} -FX_BOOL CXFA_FFDocWidgetIterator::SetCurrentWidget(IXFA_Widget* hWidget) { - return FALSE; -} -IXFA_WidgetAccIterator* XFA_WidgetAccIterator_Create( - CXFA_WidgetAcc* pTravelRoot, - XFA_WIDGETORDER eOrder) { - if (!pTravelRoot) { - return NULL; - } - return new CXFA_WidgetAccIterator(pTravelRoot->GetDocView(), - pTravelRoot->GetNode()); -} -CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, - CXFA_Node* pTravelRoot) - : m_ContentIterator(pTravelRoot) { - m_pDocView = pDocView; - m_pCurWidgetAcc = NULL; -} -CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} -void CXFA_WidgetAccIterator::Reset() { - m_pCurWidgetAcc = NULL; - m_ContentIterator.Reset(); -} -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() { - return NULL; -} -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() { - return NULL; -} -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { - CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() - : m_ContentIterator.GetCurrent(); - while (pItem) { - if ((m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData())) { - return m_pCurWidgetAcc; - } - pItem = m_ContentIterator.MoveToNext(); - } - return NULL; -} -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { - return NULL; -} -CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { - return NULL; -} -FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { - return FALSE; -} -void CXFA_WidgetAccIterator::SkipTree() { - m_ContentIterator.SkipChildrenAndMoveToNext(); - m_pCurWidgetAcc = NULL; -} diff --git a/xfa/src/fxfa/app/xfa_ffdocview.h b/xfa/src/fxfa/app/xfa_ffdocview.h deleted file mode 100644 index 6ca9d2d015..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdocview.h +++ /dev/null @@ -1,170 +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_SRC_FXFA_APP_XFA_FFDOCVIEW_H_ -#define XFA_SRC_FXFA_APP_XFA_FFDOCVIEW_H_ - -#include "xfa/src/fxfa/app/xfa_ffdoc.h" - -class CXFA_FFWidgetHandler; -class CXFA_FFDoc; -class CXFA_FFWidget; -extern const XFA_ATTRIBUTEENUM gs_EventActivity[]; -enum XFA_DOCVIEW_LAYOUTSTATUS { - XFA_DOCVIEW_LAYOUTSTATUS_None, - XFA_DOCVIEW_LAYOUTSTATUS_Start, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitialize, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitCalculate, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitValidate, - XFA_DOCVIEW_LAYOUTSTATUS_FormFormReady, - XFA_DOCVIEW_LAYOUTSTATUS_Doing, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitialize, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitCalculate, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitValidate, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetFormReady, - XFA_DOCVIEW_LAYOUTSTATUS_LayoutReady, - XFA_DOCVIEW_LAYOUTSTATUS_DocReady, - XFA_DOCVIEW_LAYOUTSTATUS_End -}; -class CXFA_FFDocView : public IXFA_DocView { - public: - CXFA_FFDocView(CXFA_FFDoc* pDoc); - ~CXFA_FFDocView(); - - virtual IXFA_Doc* GetDoc() { return m_pDoc; } - virtual int32_t StartLayout(int32_t iStartPage = 0); - virtual int32_t DoLayout(IFX_Pause* pPause = NULL); - virtual void StopLayout(); - virtual int32_t GetLayoutStatus(); - virtual void UpdateDocView(); - virtual int32_t CountPageViews(); - virtual IXFA_PageView* GetPageView(int32_t nIndex); - virtual IXFA_Widget* GetWidgetByName(const CFX_WideStringC& wsName); - virtual CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName); - virtual void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = NULL); - virtual int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, - CXFA_WidgetAcc* pWidgetAcc = NULL); - virtual IXFA_WidgetHandler* GetWidgetHandler(); - virtual IXFA_WidgetIterator* CreateWidgetIterator(); - virtual IXFA_WidgetAccIterator* CreateWidgetAccIterator( - XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder); - virtual IXFA_Widget* GetFocusWidget(); - virtual void KillFocus(); - virtual FX_BOOL SetFocus(IXFA_Widget* hWidget); - CXFA_FFWidget* GetWidgetByName(const CFX_WideStringC& wsName, - CXFA_FFWidget* pRefWidget = NULL); - CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName, - CXFA_WidgetAcc* pRefWidgetAcc = NULL); - IXFA_DocLayout* GetXFALayout() const; - void OnPageEvent(IXFA_LayoutPage* pSender, - XFA_PAGEEVENT eEvent, - int32_t iPageIndex); - void LockUpdate(); - void UnlockUpdate(); - FX_BOOL IsUpdateLocked(); - void ClearInvalidateList(); - void AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF& rtInvalidate); - void AddInvalidateRect(IXFA_PageView* pPageView, - const CFX_RectF& rtInvalidate); - void RunInvalidate(); - void RunDocClose(); - void DestroyDocView(); - - FX_BOOL InitValidate(CXFA_Node* pNode); - FX_BOOL RunValidate(); - - void SetChangeMark(); - - void AddValidateWidget(CXFA_WidgetAcc* pWidget); - void AddCalculateNodeNotify(CXFA_Node* pNodeChange); - void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); - int32_t RunCalculateWidgets(); - FX_BOOL IsStaticNotify(); - FX_BOOL RunLayout(); - void RunSubformIndexChange(); - void AddNewFormNode(CXFA_Node* pNode); - void AddIndexChangedSubform(CXFA_Node* pNode); - CXFA_WidgetAcc* GetFocusWidgetAcc(); - void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); - void DeleteLayoutItem(CXFA_FFWidget* pWidget); - int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady = FALSE, - FX_BOOL bRecursive = TRUE, - CXFA_Node* pExclude = NULL); - FX_BOOL m_bLayoutEvent; - CFX_WideStringArray m_arrNullTestMsg; - CXFA_FFWidget* m_pListFocusWidget; - FX_BOOL m_bInLayoutStatus; - - protected: - FX_BOOL RunEventLayoutReady(); - void RunBindItems(); - FX_BOOL InitCalculate(CXFA_Node* pNode); - void InitLayout(CXFA_Node* pNode); - void RunCalculateRecursive(int32_t& iIndex); - void ShowNullTestMsg(); - FX_BOOL ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); - CXFA_Node* GetRootSubform(); - - CXFA_FFDoc* m_pDoc; - CXFA_FFWidgetHandler* m_pWidgetHandler; - IXFA_DocLayout* m_pXFADocLayout; - CXFA_WidgetAcc* m_pFocusAcc; - 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; - 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; } - - virtual void Reset(); - virtual IXFA_Widget* MoveToFirst(); - virtual IXFA_Widget* MoveToLast(); - virtual IXFA_Widget* MoveToNext(); - virtual IXFA_Widget* MoveToPrevious(); - virtual IXFA_Widget* GetCurrentWidget(); - virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); - - protected: - CXFA_ContainerIterator m_ContentIterator; - CXFA_FFDocView* m_pDocView; - CXFA_FFWidget* m_pCurWidget; -}; -class CXFA_WidgetAccIterator : public IXFA_WidgetAccIterator { - public: - CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot); - virtual ~CXFA_WidgetAccIterator(); - virtual void Release() { delete this; } - virtual void Reset(); - virtual CXFA_WidgetAcc* MoveToFirst(); - virtual CXFA_WidgetAcc* MoveToLast(); - virtual CXFA_WidgetAcc* MoveToNext(); - virtual CXFA_WidgetAcc* MoveToPrevious(); - virtual CXFA_WidgetAcc* GetCurrentWidgetAcc(); - virtual FX_BOOL SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget); - virtual void SkipTree(); - - protected: - CXFA_ContainerIterator m_ContentIterator; - CXFA_FFDocView* m_pDocView; - CXFA_WidgetAcc* m_pCurWidgetAcc; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFDOCVIEW_H_ diff --git a/xfa/src/fxfa/app/xfa_ffdraw.cpp b/xfa/src/fxfa/app/xfa_ffdraw.cpp deleted file mode 100644 index e3be99b5ec..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdraw.cpp +++ /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 - -#include "xfa/src/fxfa/app/xfa_ffdraw.h" - -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFDraw::CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pPageView, pDataAcc) {} -CXFA_FFDraw::~CXFA_FFDraw() {} diff --git a/xfa/src/fxfa/app/xfa_ffdraw.h b/xfa/src/fxfa/app/xfa_ffdraw.h deleted file mode 100644 index 467c0728cc..0000000000 --- a/xfa/src/fxfa/app/xfa_ffdraw.h +++ /dev/null @@ -1,19 +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_SRC_FXFA_APP_XFA_FFDRAW_H_ -#define XFA_SRC_FXFA_APP_XFA_FFDRAW_H_ - -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -class CXFA_FFDraw : public CXFA_FFWidget { - public: - CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFDraw(); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFDRAW_H_ diff --git a/xfa/src/fxfa/app/xfa_ffexclgroup.cpp b/xfa/src/fxfa/app/xfa_ffexclgroup.cpp deleted file mode 100644 index 4fde5ef6e0..0000000000 --- a/xfa/src/fxfa/app/xfa_ffexclgroup.cpp +++ /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 - -#include "xfa/src/fxfa/app/xfa_ffexclgroup.h" - -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pPageView, pDataAcc) {} -CXFA_FFExclGroup::~CXFA_FFExclGroup() {} -void CXFA_FFExclGroup::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); -} diff --git a/xfa/src/fxfa/app/xfa_ffexclgroup.h b/xfa/src/fxfa/app/xfa_ffexclgroup.h deleted file mode 100644 index 52416f9c70..0000000000 --- a/xfa/src/fxfa/app/xfa_ffexclgroup.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_SRC_FXFA_APP_XFA_FFEXCLGROUP_H_ -#define XFA_SRC_FXFA_APP_XFA_FFEXCLGROUP_H_ - -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -class CXFA_FFExclGroup : public CXFA_FFWidget { - public: - CXFA_FFExclGroup(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFExclGroup(); - - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFEXCLGROUP_H_ diff --git a/xfa/src/fxfa/app/xfa_fffield.cpp b/xfa/src/fxfa/app/xfa_fffield.cpp deleted file mode 100644 index 607434c5b7..0000000000 --- a/xfa/src/fxfa/app/xfa_fffield.cpp +++ /dev/null @@ -1,835 +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/src/fxfa/app/xfa_fffield.h" - -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/core/fwl_widgetmgr.h" -#include "xfa/include/fwl/lightwidget/edit.h" -#include "xfa/include/fwl/lightwidget/picturebox.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwltheme.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) { - m_rtUI.Set(0, 0, 0, 0); - m_rtCaption.Set(0, 0, 0, 0); -} -CXFA_FFField::~CXFA_FFField() { - CXFA_FFField::UnloadWidget(); -} - -FX_BOOL CXFA_FFField::GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus) { - if (!bDrawFocus) - return CXFA_FFWidget::GetBBox(rtBox, dwStatus); - - XFA_ELEMENT type = (XFA_ELEMENT)m_pDataAcc->GetUIType(); - if (type == XFA_ELEMENT_Button || type == XFA_ELEMENT_CheckButton || - type == XFA_ELEMENT_ImageEdit || type == XFA_ELEMENT_Signature || - type == XFA_ELEMENT_ChoiceList) { - rtBox = m_rtUI; - CFX_Matrix mt; - GetRotateMatrix(mt); - mt.TransformRect(rtBox); - return TRUE; - } - return FALSE; -} - -void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, FALSE); - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), - pGS, &mt); -} -void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - FX_BOOL bEllipse) { - if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return; - } - if ((dwStatus & XFA_WIDGETSTATUS_Highlight) && - m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) { - CXFA_FFDoc* pDoc = GetDoc(); - CFX_Color crHighlight(pDoc->GetDocProvider()->GetHighlightColor(pDoc)); - pGS->SetFillColor(&crHighlight); - CFX_Path path; - path.Create(); - if (bEllipse) { - path.AddEllipse(m_rtUI); - } else { - path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); - } - pGS->FillPath(&path, FXFILL_WINDING, pMatrix); - } -} -void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { - if (m_dwStatus & XFA_WIDGETSTATUS_Focused) { - CFX_Color cr(0xFF000000); - pGS->SetStrokeColor(&cr); - FX_FLOAT DashPattern[2] = {1, 1}; - pGS->SetLineDash(0.0f, DashPattern, 2); - pGS->SetLineWidth(0, FALSE); - CFX_Path path; - path.Create(); - path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); - pGS->StrokePath(&path, pMatrix); - } -} -void CXFA_FFField::SetFWLThemeProvider() { - if (m_pNormalWidget) { - m_pNormalWidget->m_pIface->SetThemeProvider(GetApp()->GetFWLTheme()); - } -} -FX_BOOL CXFA_FFField::IsLoaded() { - return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); -} -FX_BOOL CXFA_FFField::LoadWidget() { - SetFWLThemeProvider(); - m_pDataAcc->LoadCaption(); - PerformLayout(); - return TRUE; -} -void CXFA_FFField::UnloadWidget() { - delete m_pNormalWidget; - m_pNormalWidget = nullptr; -} -void CXFA_FFField::SetEditScrollOffset() { - XFA_ELEMENT eType = m_pDataAcc->GetUIType(); - if (eType == XFA_ELEMENT_TextEdit || eType == XFA_ELEMENT_NumericEdit || - eType == XFA_ELEMENT_PasswordEdit) { - FX_FLOAT fScrollOffset = 0; - CXFA_FFField* pPrev = static_cast<CXFA_FFField*>(GetPrev()); - if (pPrev) { - CFX_RectF rtMargin; - m_pDataAcc->GetUIMargin(rtMargin); - fScrollOffset = -rtMargin.top; - } - while (pPrev) { - fScrollOffset += pPrev->m_rtUI.height; - pPrev = static_cast<CXFA_FFField*>(pPrev->GetPrev()); - } - ((CFWL_Edit*)m_pNormalWidget)->SetScrollOffset(fScrollOffset); - } -} -FX_BOOL CXFA_FFField::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - CapPlacement(); - LayoutCaption(); - SetFWLRect(); - SetEditScrollOffset(); - if (m_pNormalWidget) { - m_pNormalWidget->Update(); - } - return TRUE; -} -void CXFA_FFField::CapPlacement() { - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); - if (mgWidget) { - CXFA_LayoutItem* pItem = this; - FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { - rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); - } else { - if (pItem->GetPrev() == NULL) { - rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); - } else if (pItem->GetNext() == NULL) { - rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); - } else { - rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); - } - } - } - XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - FX_FLOAT fCapReserve = 0; - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { - m_rtCaption.Set(0, 0, 0, 0); - } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { - m_rtCaption.Set(0, 0, 0, 0); - } else { - fCapReserve = caption.GetReserve(); - CXFA_LayoutItem* pItem = this; - if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); - } else { - pItem = pItem->GetFirst(); - pItem->GetRect(m_rtCaption); - pItem = pItem->GetNext(); - while (pItem) { - CFX_RectF rtRect; - pItem->GetRect(rtRect); - m_rtCaption.height += rtRect.Height(); - pItem = pItem->GetNext(); - } - XFA_RectWidthoutMargin(m_rtCaption, mgWidget); - } - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (fCapReserve <= 0 && pCapTextLayout) { - CFX_SizeF size; - CFX_SizeF minSize; - CFX_SizeF maxSize; - pCapTextLayout->CalcSize(minSize, maxSize, size); - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { - fCapReserve = size.y; - } else { - fCapReserve = size.x; - } - } - } - } - m_rtUI = rtWidget; - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: { - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.width -= fCapReserve; - m_rtUI.left += fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Top: { - m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.top += fCapReserve; - m_rtUI.height -= fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Right: { - m_rtCaption.left = m_rtCaption.right() - fCapReserve; - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.width -= fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Bottom: { - m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; - m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.height -= fCapReserve; - } break; - case XFA_ATTRIBUTEENUM_Inline: - break; - default: - break; - } - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - if (borderUI) { - CXFA_Margin margin = borderUI.GetMargin(); - if (margin) { - XFA_RectWidthoutMargin(m_rtUI, margin); - } - } - m_rtUI.Normalize(); -} -void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); - m_rtCaption.left += rtUIMargin.left; - if (CXFA_Margin mgCap = caption.GetMargin()) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) { - m_rtCaption.top += m_rtCaption.height; - } - } - FX_FLOAT fWidth = rtUIMargin.left + rtUIMargin.width; - FX_FLOAT fHeight = m_rtCaption.height + rtUIMargin.top + rtUIMargin.height; - if (fWidth > rtWidget.width) { - m_rtUI.width += fWidth - rtWidget.width; - } - if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { - m_rtUI.height = XFA_MINUI_HEIGHT; - m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; - } else if (fHeight > rtWidget.height) { - m_rtUI.height += fHeight - rtWidget.height; - if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { - m_rtCaption.top += fHeight - rtWidget.height; - } - } -} -void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); - m_rtCaption.top += rtUIMargin.top; - m_rtCaption.height -= rtUIMargin.top; - if (CXFA_Margin mgCap = caption.GetMargin()) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) { - m_rtCaption.top += m_rtCaption.height; - } - } - FX_FLOAT fWidth = m_rtCaption.width + rtUIMargin.left + rtUIMargin.width; - FX_FLOAT fHeight = rtUIMargin.top + rtUIMargin.height; - if (fWidth > rtWidget.width) { - m_rtUI.width += fWidth - rtWidget.width; - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) { - m_rtCaption.left += fWidth - rtWidget.width; - } - } - if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { - m_rtUI.height = XFA_MINUI_HEIGHT; - m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; - } else if (fHeight > rtWidget.height) { - m_rtUI.height += fHeight - rtWidget.height; - } -} -void CXFA_FFField::UpdateFWL() { - if (m_pNormalWidget) { - m_pNormalWidget->Update(); - } -} -FX_DWORD CXFA_FFField::UpdateUIProperty() { - CXFA_Node* pUiNode = m_pDataAcc->GetUIChild(); - FX_DWORD dwStyle = 0; - if (pUiNode && pUiNode->GetClassID() == XFA_ELEMENT_DefaultUi) { - dwStyle = FWL_STYLEEXT_EDT_ReadOnly; - } - return dwStyle; -} -void CXFA_FFField::SetFWLRect() { - if (!m_pNormalWidget) { - return; - } - CFX_RectF rtUi = m_rtUI; - if (rtUi.width < 1.0) { - FXSYS_assert(rtUi.width < 1.0); - rtUi.width = 1.0; - } - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - FX_FLOAT fFontSize = m_pDataAcc->GetFontSize(); - if (rtUi.height < fFontSize) { - rtUi.height = fFontSize; - } - } - m_pNormalWidget->SetWidgetRect(rtUi); -} -FX_BOOL CXFA_FFField::OnMouseEnter() { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseEnter; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnMouseExit() { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { - if (!m_pNormalWidget) { - return; - } - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget); - fx -= rtWidget.left; - fy -= rtWidget.top; -} -FX_BOOL CXFA_FFField::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return FALSE; - } - if (!PtInActiveRect(fx, fy)) { - return FALSE; - } - SetButtonDown(TRUE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - if (!IsButtonDown()) { - return FALSE; - } - SetButtonDown(FALSE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnLButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDblClk; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_MouseMove; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouseWheel ms; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_fDeltaX = zDelta; - ms.m_fDeltaY = 0; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnRButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return FALSE; - } - if (!PtInActiveRect(fx, fy)) { - return FALSE; - } - SetButtonDown(TRUE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - if (!IsButtonDown()) { - return FALSE; - } - SetButtonDown(FALSE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnRButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDblClk; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - TranslateFWLMessage(&ms); - return TRUE; -} - -FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { - CXFA_FFWidget::OnSetFocus(pOldWidget); - if (!m_pNormalWidget) { - return FALSE; - } - CFWL_MsgSetFocus ms; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - m_dwStatus |= XFA_WIDGETSTATUS_Focused; - AddInvalidateRect(); - return TRUE; -} -FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { - if (!m_pNormalWidget) { - return CXFA_FFWidget::OnKillFocus(pNewWidget); - } - CFWL_MsgKillFocus ms; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; - AddInvalidateRect(); - CXFA_FFWidget::OnKillFocus(pNewWidget); - return TRUE; -} -FX_BOOL CXFA_FFField::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return FALSE; - } - CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_KeyDown; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwKeyCode; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return FALSE; - } - CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_KeyUp; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwKeyCode; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFField::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return FALSE; - } - if (dwChar == FWL_VKEY_Tab) { - return TRUE; - } - if (!m_pNormalWidget) { - return FALSE; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - CFWL_MsgKey ms; - ms.m_dwCmd = FWL_MSGKEYCMD_Char; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwChar; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_DWORD CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pNormalWidget) { - FX_FLOAT ffx = fx, ffy = fy; - FWLToClient(ffx, ffy); - FX_DWORD dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy); - if (dwWidgetHit != FWL_WGTHITTEST_Unknown) { - return FWL_WGTHITTEST_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; -} -FX_BOOL CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { - return TRUE; -} -FX_BOOL CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget); - if (rtWidget.Contains(fx, fy)) { - return TRUE; - } - return FALSE; -} -void CXFA_FFField::LayoutCaption() { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextLayout) - return; - - FX_FLOAT fHeight = 0; - pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height), - &fHeight); - if (m_rtCaption.height < fHeight) - m_rtCaption.height = fHeight; -} -void CXFA_FFField::RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextLayout) { - return; - } - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { - if (!pCapTextLayout->IsLoaded()) { - pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height)); - } - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - CFX_RectF rtClip = m_rtCaption; - rtClip.Intersect(rtWidget); - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); - } -} -FX_BOOL CXFA_FFField::ProcessCommittedData() { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - if (!IsDataChanged()) { - return FALSE; - } - if (CalculateOverride() != 1) { - return FALSE; - } - if (!CommitData()) { - return FALSE; - } - m_pDocView->SetChangeMark(); - m_pDocView->AddValidateWidget(m_pDataAcc); - return TRUE; -} -int32_t CXFA_FFField::CalculateOverride() { - CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup(); - if (!pAcc) { - return CalculateWidgetAcc(m_pDataAcc); - } - if (CalculateWidgetAcc(pAcc) == 0) { - return 0; - } - CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); - if (!pNode) { - return 1; - } - CXFA_WidgetAcc* pWidgetAcc = NULL; - while (pNode) { - pWidgetAcc = (CXFA_WidgetAcc*)pNode->GetWidgetData(); - if (!pWidgetAcc) { - return 1; - } - if (CalculateWidgetAcc(pWidgetAcc) == 0) { - return 0; - } - pNode = pWidgetAcc->GetExclGroupNextMember(pNode); - } - return 1; -} -int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { - CXFA_Calculate calc = pAcc->GetCalculate(); - if (!calc) { - return 1; - } - XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); - if (calc) { - int32_t iOverride = calc.GetOverride(); - switch (iOverride) { - case XFA_ATTRIBUTEENUM_Error: { - if (version <= XFA_VERSION_204) { - return 1; - } - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (pAppProvider) { - CFX_WideString wsMessage; - CFX_WideString wsWarning; - pAppProvider->LoadString(XFA_IDS_NotModifyField, wsWarning); - wsMessage += wsWarning; - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle); - pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); - } - } - return 0; - case XFA_ATTRIBUTEENUM_Warning: { - if (version <= XFA_VERSION_204) { - CXFA_Script script = calc.GetScript(); - if (!script) { - return 1; - } - CFX_WideString wsExpression; - script.GetExpression(wsExpression); - if (wsExpression.IsEmpty()) { - return 1; - } - } - if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return 1; - } - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (pAppProvider) { - CFX_WideString wsMessage; - calc.GetMessageText(wsMessage); - if (!wsMessage.IsEmpty()) { - wsMessage += L"\r\n"; - } - CFX_WideString wsWarning; - pAppProvider->LoadString(XFA_IDS_ModifyField, wsWarning); - wsMessage += wsWarning; - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle); - if (pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); - return 1; - } - } - return 0; - } - case XFA_ATTRIBUTEENUM_Ignore: - return 0; - case XFA_ATTRIBUTEENUM_Disabled: - pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); - default: - return 1; - } - } - return 1; -} -FX_BOOL CXFA_FFField::CommitData() { - return FALSE; -} -FX_BOOL CXFA_FFField::IsDataChanged() { - return FALSE; -} -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) { - FX_DWORD dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_Mouse: { - CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent; - if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) { - 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) { - 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) { - 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) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_MouseUp; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseUp, &eParam); - } - break; - } - case FWL_EVTHASH_Click: { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Click; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - break; - } - default: {} - } - return FWL_ERR_Succeeded; -} -FWL_ERR CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return FWL_ERR_Succeeded; -} diff --git a/xfa/src/fxfa/app/xfa_fffield.h b/xfa/src/fxfa/app/xfa_fffield.h deleted file mode 100644 index e2699c97b2..0000000000 --- a/xfa/src/fxfa/app/xfa_fffield.h +++ /dev/null @@ -1,100 +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_SRC_FXFA_APP_XFA_FFFIELD_H_ -#define XFA_SRC_FXFA_APP_XFA_FFFIELD_H_ - -#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" -#include "xfa/include/fwl/core/fwl_widget.h" -#include "xfa/include/fwl/lightwidget/widget.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -#define XFA_MINUI_HEIGHT 4.32f -#define XFA_DEFAULTUI_HEIGHT 2.0f - -class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { - public: - CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFField(); - - virtual FX_BOOL GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus = FALSE); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL IsLoaded(); - virtual FX_BOOL LoadWidget(); - virtual void UnloadWidget(); - virtual FX_BOOL PerformLayout(); - virtual void UpdateFWL(); - FX_DWORD UpdateUIProperty(); - virtual FX_BOOL OnMouseEnter(); - virtual FX_BOOL OnMouseExit(); - virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - - virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); - virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); - virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); - virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); - - protected: - virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); - virtual void SetFWLRect(); - void SetFWLThemeProvider(); - CFWL_Widget* GetNormalWidget() { return m_pNormalWidget; } - void FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy); - void LayoutCaption(); - void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = NULL); - - int32_t CalculateOverride(); - int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc); - FX_BOOL ProcessCommittedData(); - virtual FX_BOOL CommitData(); - virtual FX_BOOL IsDataChanged(); - void DrawHighlight(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - FX_BOOL bEllipse = FALSE); - void DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix); - void TranslateFWLMessage(CFWL_Message* pMessage); - void CapPlacement(); - void CapTopBottomPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement); - void CapLeftRightPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement); - 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); - - protected: - CFWL_Widget* m_pNormalWidget; - CFX_RectF m_rtUI; - CFX_RectF m_rtCaption; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFFIELD_H_ diff --git a/xfa/src/fxfa/app/xfa_ffimage.cpp b/xfa/src/fxfa/app/xfa_ffimage.cpp deleted file mode 100644 index 37c5991544..0000000000 --- a/xfa/src/fxfa/app/xfa_ffimage.cpp +++ /dev/null @@ -1,67 +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/src/fxfa/app/xfa_ffimage.h" - -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdraw.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFImage::CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pPageView, pDataAcc) {} -CXFA_FFImage::~CXFA_FFImage() { - CXFA_FFImage::UnloadWidget(); -} -FX_BOOL CXFA_FFImage::IsLoaded() { - return GetDataAcc()->GetImageImage() != NULL; -} -FX_BOOL CXFA_FFImage::LoadWidget() { - if (GetDataAcc()->GetImageImage()) { - return TRUE; - } - GetDataAcc()->LoadImageImage(); - return CXFA_FFDraw::LoadWidget(); -} -void CXFA_FFImage::UnloadWidget() { - GetDataAcc()->SetImageImage(NULL); -} -void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - if (CFX_DIBitmap* pDIBitmap = GetDataAcc()->GetImageImage()) { - CFX_RectF rtImage; - GetRectWithoutRotate(rtImage); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - XFA_RectWidthoutMargin(rtImage, mgWidget); - } - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - CXFA_Value value = m_pDataAcc->GetFormValue(); - CXFA_Image imageObj = value.GetImage(); - int32_t iAspect = imageObj.GetAspect(); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, - iImageYDpi, iHorzAlign, iVertAlign); - } -} diff --git a/xfa/src/fxfa/app/xfa_ffimage.h b/xfa/src/fxfa/app/xfa_ffimage.h deleted file mode 100644 index 5767e16a7b..0000000000 --- a/xfa/src/fxfa/app/xfa_ffimage.h +++ /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 - -#ifndef XFA_SRC_FXFA_APP_XFA_FFIMAGE_H_ -#define XFA_SRC_FXFA_APP_XFA_FFIMAGE_H_ - -#include "xfa/src/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFImage : public CXFA_FFDraw { - public: - CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFImage(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL IsLoaded(); - virtual FX_BOOL LoadWidget(); - virtual void UnloadWidget(); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFIMAGE_H_ diff --git a/xfa/src/fxfa/app/xfa_ffimageedit.cpp b/xfa/src/fxfa/app/xfa_ffimageedit.cpp deleted file mode 100644 index 68e4009139..0000000000 --- a/xfa/src/fxfa/app/xfa_ffimageedit.cpp +++ /dev/null @@ -1,183 +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/src/fxfa/app/xfa_ffimageedit.h" - -#include "xfa/include/fwl/core/fwl_app.h" -#include "xfa/include/fwl/lightwidget/picturebox.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} -CXFA_FFImageEdit::~CXFA_FFImageEdit() { - CXFA_FFImageEdit::UnloadWidget(); -} -FX_BOOL CXFA_FFImageEdit::LoadWidget() { - CFWL_PictureBox* pPictureBox = new CFWL_PictureBox; - if (pPictureBox) { - pPictureBox->Initialize(); - } - m_pNormalWidget = (CFWL_Widget*)pPictureBox; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = pPictureBox->SetDelegate(this); - CXFA_FFField::LoadWidget(); - if (m_pDataAcc->GetImageEditImage()) { - return TRUE; - } - UpdateFWLData(); - return TRUE; -} -void CXFA_FFImageEdit::UnloadWidget() { - m_pDataAcc->SetImageEditImage(NULL); - CXFA_FFField::UnloadWidget(); -} -void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - if (CFX_DIBitmap* pDIBitmap = m_pDataAcc->GetImageEditImage()) { - CFX_RectF rtImage; - m_pNormalWidget->GetWidgetRect(rtImage); - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; - if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - if (CXFA_Image imageObj = value.GetImage()) { - iAspect = imageObj.GetAspect(); - } - } - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, - iImageYDpi, iHorzAlign, iVertAlign); - } -} -FX_BOOL CXFA_FFImageEdit::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - if (!PtInActiveRect(fx, fy)) { - return FALSE; - } - SetButtonDown(TRUE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; - 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, wsFilter, 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, CFX_WideStringC(), wsImage); - m_pDataAcc->LoadImageEditImage(); - AddInvalidateRect(); - m_pDocView->SetChangeMark(); - return TRUE; -} -void CXFA_FFImageEdit::SetFWLRect() { - if (!m_pNormalWidget) { - return; - } - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); - CFX_RectF rtImage(m_rtUI); - rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, - rtUIMargin.height); - m_pNormalWidget->SetWidgetRect(rtImage); -} -FX_BOOL CXFA_FFImageEdit::CommitData() { - return TRUE; -} -FX_BOOL CXFA_FFImageEdit::UpdateFWLData() { - m_pDataAcc->SetImageEditImage(NULL); - m_pDataAcc->LoadImageEditImage(); - return TRUE; -} -int32_t CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - return m_pOldDelegate->OnProcessEvent(pEvent); -} -FWL_ERR CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/src/fxfa/app/xfa_ffimageedit.h b/xfa/src/fxfa/app/xfa_ffimageedit.h deleted file mode 100644 index d7438ae2e4..0000000000 --- a/xfa/src/fxfa/app/xfa_ffimageedit.h +++ /dev/null @@ -1,36 +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_SRC_FXFA_APP_XFA_FFIMAGEEDIT_H_ -#define XFA_SRC_FXFA_APP_XFA_FFIMAGEEDIT_H_ - -#include "xfa/src/fxfa/app/xfa_fffield.h" - -class CXFA_FFImageEdit : public CXFA_FFField { - public: - CXFA_FFImageEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFImageEdit(); - - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL LoadWidget(); - virtual void UnloadWidget(); - virtual FX_BOOL OnLButtonDown(FX_DWORD 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); - - protected: - virtual void SetFWLRect(); - virtual FX_BOOL UpdateFWLData(); - virtual FX_BOOL CommitData(); - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFIMAGEEDIT_H_ diff --git a/xfa/src/fxfa/app/xfa_ffnotify.cpp b/xfa/src/fxfa/app/xfa_ffnotify.cpp deleted file mode 100644 index 6b9094c77b..0000000000 --- a/xfa/src/fxfa/app/xfa_ffnotify.cpp +++ /dev/null @@ -1,648 +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/src/fxfa/app/xfa_ffnotify.h" - -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffbarcode.h" -#include "xfa/src/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/src/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_ffdraw.h" -#include "xfa/src/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffimage.h" -#include "xfa/src/fxfa/app/xfa_ffimageedit.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffpath.h" -#include "xfa/src/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/src/fxfa/app/xfa_ffsignature.h" -#include "xfa/src/fxfa/app/xfa_ffsubform.h" -#include "xfa/src/fxfa/app/xfa_fftext.h" -#include "xfa/src/fxfa/app/xfa_fftextedit.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/src/fxfa/app/xfa_ffwidgethandler.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -static void XFA_FFDeleteWidgetAcc(void* pData) { - delete static_cast<CXFA_WidgetAcc*>(pData); -} -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { - XFA_FFDeleteWidgetAcc, NULL}; -CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} -CXFA_FFNotify::~CXFA_FFNotify() {} -void CXFA_FFNotify::OnPageEvent(IXFA_LayoutPage* pSender, - XFA_PAGEEVENT eEvent, - void* pParam) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); - if (!pDocView) { - return; - } - pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam); -} -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::OnWidgetDataEvent(CXFA_WidgetData* pSender, - FX_DWORD dwEvent, - void* pParam, - void* pAdditional, - void* pAdditional2) { - 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); - } - } break; - } -} -CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { - IXFA_DocLayout* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); - XFA_ELEMENT eType = pNode->GetClassID(); - if (eType == XFA_ELEMENT_PageArea) { - return new CXFA_FFPageView(pDocView, pNode); - } - if (eType == XFA_ELEMENT_ContentArea) { - return new CXFA_ContainerLayoutItem(pNode); - } - CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); - if (!pAcc) { - return new CXFA_ContentLayoutItem(pNode); - } - CXFA_FFPageView* pPageView = NULL; - CXFA_FFWidget* pWidget = NULL; - switch (pAcc->GetUIType()) { - case XFA_ELEMENT_Barcode: - pWidget = new CXFA_FFBarcode(pPageView, pAcc); - break; - case XFA_ELEMENT_Button: - pWidget = new CXFA_FFPushButton(pPageView, pAcc); - break; - case XFA_ELEMENT_CheckButton: - pWidget = new CXFA_FFCheckButton(pPageView, pAcc); - break; - case XFA_ELEMENT_ChoiceList: { - if (pAcc->IsListBox()) { - pWidget = new CXFA_FFListBox(pPageView, pAcc); - } else { - pWidget = new CXFA_FFComboBox(pPageView, pAcc); - } - } break; - case XFA_ELEMENT_DateTimeEdit: - pWidget = new CXFA_FFDateTimeEdit(pPageView, pAcc); - break; - case XFA_ELEMENT_ImageEdit: - pWidget = new CXFA_FFImageEdit(pPageView, pAcc); - break; - case XFA_ELEMENT_NumericEdit: - pWidget = new CXFA_FFNumericEdit(pPageView, pAcc); - break; - case XFA_ELEMENT_PasswordEdit: - pWidget = new CXFA_FFPasswordEdit(pPageView, pAcc); - break; - case XFA_ELEMENT_Signature: - pWidget = new CXFA_FFSignature(pPageView, pAcc); - break; - case XFA_ELEMENT_TextEdit: - pWidget = new CXFA_FFTextEdit(pPageView, pAcc); - break; - case XFA_ELEMENT_Arc: - pWidget = new CXFA_FFArc(pPageView, pAcc); - break; - case XFA_ELEMENT_Line: - pWidget = new CXFA_FFLine(pPageView, pAcc); - break; - case XFA_ELEMENT_Rectangle: - pWidget = new CXFA_FFRectangle(pPageView, pAcc); - break; - case XFA_ELEMENT_Text: - pWidget = new CXFA_FFText(pPageView, pAcc); - break; - case XFA_ELEMENT_Image: - pWidget = new CXFA_FFImage(pPageView, pAcc); - break; - case XFA_ELEMENT_Draw: - pWidget = new CXFA_FFDraw(pPageView, pAcc); - break; - case XFA_ELEMENT_Subform: - pWidget = new CXFA_FFSubForm(pPageView, pAcc); - break; - case XFA_ELEMENT_ExclGroup: - pWidget = new CXFA_FFExclGroup(pPageView, pAcc); - break; - case XFA_ELEMENT_DefaultUi: - default: - pWidget = NULL; - break; - } - if (!pWidget) { - return NULL; - } - pWidget->SetDocView(pDocView); - return pWidget; -} -void CXFA_FFNotify::OnLayoutEvent(IXFA_DocLayout* 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) { - CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); - if (!pAcc) { - return; - } - pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); -} -FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, - int32_t iBlockIndex, - FX_FLOAT& fCalcHeightPos) { - CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); - if (!pAcc) { - return FALSE; - } - return (XFA_LAYOUTRESULT)pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); -} -FX_BOOL CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { - FX_BOOL bRet = FALSE; - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return bRet; - } - CXFA_WidgetAcc* pWidgetAcc = - static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData()); - if (!pWidgetAcc) { - return bRet; - } - CXFA_EventParam EventParam; - EventParam.m_eType = XFA_EVENT_Unknown; - FXJSE_HVALUE pRetValue = NULL; - int32_t iRet = - pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); - if (iRet == XFA_EVENTERROR_Sucess && pRetValue) { - bRet = FXJSE_Value_ToBoolean(pRetValue); - FXJSE_Value_Release(pRetValue); - } - return bRet; -} -int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady, - FX_BOOL bRecursive, - CXFA_WidgetAcc* pExclude) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return XFA_EVENTERROR_NotExist; - } - return pDocView->ExecEventActivityByDeepFirst( - pFormNode, eEventType, bIsFormReady, bRecursive, - pExclude ? pExclude->GetNode() : NULL); -} -void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - CXFA_WidgetAcc* pWidgetAcc = - static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); - if (!pWidgetAcc) { - return; - } - pDocView->AddCalculateWidgetAcc(pWidgetAcc); - pDocView->AddValidateWidget(pWidgetAcc); -} -IXFA_Doc* CXFA_FFNotify::GetHDOC() { - return m_pDoc; -} -IXFA_DocProvider* CXFA_FFNotify::GetDocProvider() { - return m_pDoc->GetDocProvider(); -} -IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { - return m_pDoc->GetApp()->GetAppProvider(); -} -IXFA_WidgetHandler* CXFA_FFNotify::GetWidgetHandler() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - return pDocView ? pDocView->GetWidgetHandler() : NULL; -} -IXFA_Widget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { - return XFA_GetWidgetFromLayoutItem(pLayoutItem); -} -void CXFA_FFNotify::OpenDropDownList(IXFA_Widget* hWidget) { - CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget); - if (pWidget->GetDataAcc()->GetUIType() != XFA_ELEMENT_ChoiceList) { - return; - } - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - pDocView->LockUpdate(); - static_cast<CXFA_FFComboBox*>(pWidget)->OpenDropDownList(); - pDocView->UnlockUpdate(); - pDocView->UpdateDocView(); -} -CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { - CFX_Unitime dataTime; - dataTime.Now(); - CFX_WideString wsDateTime; - wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), - dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), - dataTime.GetMinute(), dataTime.GetSecond()); - return wsDateTime; -} -void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - pDocView->ResetWidgetData(static_cast<CXFA_WidgetAcc*>(pWidgetData)); -} -int32_t CXFA_FFNotify::GetLayoutStatus() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - return pDocView ? pDocView->GetLayoutStatus() : 0; -} -void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - pDocView->AddNewFormNode(pNode); -} -void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - pDocView->AddIndexChangedSubform(pSubformNode); -} -CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return NULL; - } - CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); - return pAcc ? pAcc->GetNode() : NULL; -} -void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - CXFA_WidgetAcc* pAcc = - 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) { - return; - } - XFA_ELEMENT iType = pNode->GetClassID(); - if (XFA_IsCreateWidget(iType)) { - CXFA_WidgetAcc* pAcc = - new CXFA_WidgetAcc(pDocView, static_cast<CXFA_Node*>(pNode)); - pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); - return; - } - switch (iType) { - case XFA_ELEMENT_BindItems: - pDocView->m_bindItems.Add(pNode); - break; - case XFA_ELEMENT_Validate: { - pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE); - } break; - default: - break; - } -} -void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, - void* pParam, - void* pParam2) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) { - return; - } - FX_DWORD 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(); - } - } - } - } -} -void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, - void* pParam, - void* pParam2, - void* pParam3, - void* pParam4) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - FX_DWORD 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) { - 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; - } - } - 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); - } - } -} -void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, - void* pParam, - void* pParam2) { - if (!pSender->IsFormContainer()) { - return; - } - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) { - return; - } - 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_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::OnLayoutItemAdd(CXFA_FFDocView* pDocView, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2) { - CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); - int32_t iPageIdx = (int32_t)(uintptr_t)pParam; - IXFA_PageView* pNewPageView = pDocView->GetPageView(iPageIdx); - FX_DWORD dwStatus = (FX_DWORD)(uintptr_t)pParam2; - FX_DWORD dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | - XFA_WIDGETSTATUS_Printable; - pWidget->ModifyStatus(dwStatus, dwFilter); - IXFA_PageView* pPrePageView = pWidget->GetPageView(); - if (pPrePageView != pNewPageView || - (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); - } - if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || - !(dwStatus & XFA_WIDGETSTATUS_Visible)) { - return; - } - if (pWidget->IsLoaded()) { - CFX_RectF rtOld; - pWidget->GetWidgetRect(rtOld); - if (rtOld != pWidget->ReCacheWidgetRect()) - pWidget->PerformLayout(); - } else { - pWidget->LoadWidget(); - } - pWidget->AddInvalidateRect(nullptr); -} -void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, - IXFA_DocLayout* 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, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2) {} -void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2) { - CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); - if (!pWidget) { - return; - } - FX_DWORD dwStatus = (FX_DWORD)(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(); - } - } - } - FX_DWORD dwOldStatus = pWidget->GetStatus(); - FX_DWORD dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | - XFA_WIDGETSTATUS_Printable; - if ((dwOldStatus & dwFilter) == dwStatus) { - return; - } - pWidget->ModifyStatus(dwStatus, dwFilter); -} diff --git a/xfa/src/fxfa/app/xfa_ffnotify.h b/xfa/src/fxfa/app/xfa_ffnotify.h deleted file mode 100644 index 0e0b77bed6..0000000000 --- a/xfa/src/fxfa/app/xfa_ffnotify.h +++ /dev/null @@ -1,99 +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_SRC_FXFA_APP_XFA_FFNOTIFY_H_ -#define XFA_SRC_FXFA_APP_XFA_FFNOTIFY_H_ - -#include "xfa/src/fxfa/parser/xfa_document.h" - -class CXFA_FFNotify : public IXFA_Notify { - public: - CXFA_FFNotify(CXFA_FFDoc* pDoc); - ~CXFA_FFNotify(); - - virtual void OnPageEvent(IXFA_LayoutPage* pSender, - XFA_PAGEEVENT eEvent, - void* pParam = NULL); - - virtual void OnNodeEvent(CXFA_Node* pSender, - XFA_NODEEVENT eEvent, - void* pParam = NULL, - void* pParam2 = NULL, - void* pParam3 = NULL, - void* pParam4 = NULL); - virtual void OnWidgetDataEvent(CXFA_WidgetData* pSender, - FX_DWORD dwEvent, - void* pParam = NULL, - void* pAdditional = NULL, - void* pAdditional2 = NULL); - virtual CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode); - virtual void OnLayoutEvent(IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - XFA_LAYOUTEVENT eEvent, - void* pParam = NULL, - void* pParam2 = NULL); - - virtual void StartFieldDrawLayout(CXFA_Node* pItem, - FX_FLOAT& fCalcWidth, - FX_FLOAT& fCalcHeight); - virtual FX_BOOL FindSplitPos(CXFA_Node* pItem, - int32_t iBlockIndex, - FX_FLOAT& fCalcHeightPos); - virtual FX_BOOL RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem); - virtual int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady = FALSE, - FX_BOOL bRecursive = TRUE, - CXFA_WidgetAcc* pExclude = NULL); - virtual void AddCalcValidate(CXFA_Node* pNode); - virtual IXFA_Doc* GetHDOC(); - virtual IXFA_DocProvider* GetDocProvider(); - virtual IXFA_AppProvider* GetAppProvider(); - virtual IXFA_WidgetHandler* GetWidgetHandler(); - virtual IXFA_Widget* GetHWidget(CXFA_LayoutItem* pLayoutItem); - virtual void OpenDropDownList(IXFA_Widget* hWidget); - virtual CFX_WideString GetCurrentDateTime(); - virtual void ResetData(CXFA_WidgetData* pWidgetData = NULL); - virtual int32_t GetLayoutStatus(); - virtual void RunNodeInitialize(CXFA_Node* pNode); - virtual void RunSubformIndexChange(CXFA_Node* pSubformNode); - virtual CXFA_Node* GetFocusWidgetNode(); - virtual 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, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2); - void OnLayoutItemRemoving(CXFA_FFDocView* pDocView, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2); - void OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2); - void OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, - IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - void* pParam, - void* pParam2); - CXFA_FFDoc* m_pDoc; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFNOTIFY_H_ diff --git a/xfa/src/fxfa/app/xfa_ffpageview.cpp b/xfa/src/fxfa/app/xfa_ffpageview.cpp deleted file mode 100644 index ba4c9709eb..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpageview.cpp +++ /dev/null @@ -1,424 +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/src/fxfa/app/xfa_ffpageview.h" - -#include "xfa/src/fde/fde_render.h" -#include "xfa/src/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/src/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffimageedit.h" -#include "xfa/src/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/src/fxfa/app/xfa_fftextedit.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" - -CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) - : CXFA_ContainerLayoutItem(pPageArea), - m_pDocView(pDocView), - m_bLoaded(FALSE) {} -CXFA_FFPageView::~CXFA_FFPageView() {} -IXFA_DocView* CXFA_FFPageView::GetDocView() { - return m_pDocView; -} -int32_t CXFA_FFPageView::GetPageViewIndex() { - return GetPageIndex(); -} -void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) { - CFX_SizeF sz; - GetPageSize(sz); - rtPage.Set(0, 0, sz); -} -void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt, - const CFX_Rect& rtDisp, - int32_t iRotate) { - 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; -} -IXFA_Widget* 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); - FX_DWORD dwFlag = pWidget->OnHitTest(fWidgetx, fWidgety); - if ((FWL_WGTHITTEST_Client == dwFlag || - FWL_WGTHITTEST_HyperLink == dwFlag)) { - break; - } - } - pIterator->Release(); - return pWidget; -} -IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( - FX_DWORD dwTraverseWay, - FX_DWORD dwWidgetFilter) { - switch (dwTraverseWay) { - case XFA_TRAVERSEWAY_Tranvalse: - return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter); - case XFA_TRAVERSEWAY_Form: - return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); - } - return NULL; -} -static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget, - FX_DWORD dwFilter, - FX_BOOL bTraversal, - FX_BOOL bIgnorerelevant) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - FX_DWORD dwType = dwFilter & XFA_WIDGETFILTER_AllType; - if ((dwType == XFA_WIDGETFILTER_Field) && - (pWidgetAcc->GetClassID() != XFA_ELEMENT_Field)) { - return FALSE; - } - FX_DWORD 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; -} -CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, - FX_DWORD dwFilter) { - m_pPageView = pPageView; - m_dwFilter = dwFilter; - m_sIterator.Init(pPageView); - m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) - ->GetXFADoc() - ->GetCurVersionMode() < XFA_VERSION_205; -} -CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} -void CXFA_FFPageWidgetIterator::Reset() { - m_sIterator.Reset(); -} -IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToFirst() { - m_sIterator.Reset(); - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToNext()) { - if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return NULL; -} -IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToLast() { - m_sIterator.SetCurrent(NULL); - return MoveToPrevious(); -} -IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToNext() { - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToNext()) { - if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return NULL; -} -IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToPrevious() { - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToPrev()) { - if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return NULL; -} -IXFA_Widget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { - CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); - return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; -} -FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(IXFA_Widget* hWidget) { - CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget); - return pWidget && m_sIterator.SetCurrent(pWidget); -} -IXFA_Widget* CXFA_FFPageWidgetIterator::GetWidget( - CXFA_LayoutItem* pLayoutItem) { - if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { - return NULL; - } - if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { - pWidget->LoadWidget(); - } - return pWidget; - } - return NULL; -} -CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( - CXFA_FFPageView* pPageView, - FX_DWORD dwFilter) - : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { - m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) - ->GetXFADoc() - ->GetCurVersionMode() < XFA_VERSION_205; - Reset(); -} -CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} -void CXFA_FFTabOrderPageWidgetIterator::Release() { - delete this; -} -void CXFA_FFTabOrderPageWidgetIterator::Reset() { - CreateTabOrderWidgetArray(); - m_iCurWidget = -1; -} -IXFA_Widget* 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)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - } - return NULL; -} -IXFA_Widget* 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)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - } - return NULL; -} -IXFA_Widget* 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)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - m_iCurWidget = -1; - return NULL; -} -IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { - for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { - if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - m_iCurWidget = -1; - return NULL; -} -IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { - if (m_iCurWidget >= 0) { - return m_TabOrderWidgetArray[m_iCurWidget]; - } - return NULL; -} -FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( - IXFA_Widget* hWidget) { - int32_t iWidgetIndex = - m_TabOrderWidgetArray.Find(static_cast<CXFA_FFWidget*>(hWidget)); - if (iWidgetIndex >= 0) { - m_iCurWidget = iWidgetIndex; - return TRUE; - } - return FALSE; -} -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( - CXFA_FFWidget* pWidget) { - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_ELEMENT_Traversal); - if (pTraversal) { - CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_ELEMENT_Traverse); - if (pTraverse) { - CFX_WideString wsTraverseWidgetName; - if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { - return FindWidgetByName(wsTraverseWidgetName, pWidget); - } - } - } - return NULL; -} -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( - const CFX_WideStringC& wsWidgetName, - CXFA_FFWidget* pRefWidget) { - return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); -} -void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { - m_TabOrderWidgetArray.RemoveAll(); - CXFA_WidgetArray SpaceOrderWidgetArray; - CreateSpaceOrderWidgetArray(SpaceOrderWidgetArray); - int32_t nWidgetCount = SpaceOrderWidgetArray.GetSize(); - if (nWidgetCount < 1) { - return; - } - CXFA_FFWidget* hWidget = SpaceOrderWidgetArray[0]; - for (; m_TabOrderWidgetArray.GetSize() < nWidgetCount;) { - if (m_TabOrderWidgetArray.Find(hWidget) < 0) { - m_TabOrderWidgetArray.Add(hWidget); - CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); - if (pWidgetAcc->GetUIType() == XFA_ELEMENT_ExclGroup) { - int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget) + 1; - while (TRUE) { - CXFA_FFWidget* pRadio = - SpaceOrderWidgetArray[(iWidgetIndex) % nWidgetCount]; - if (pRadio->GetDataAcc()->GetExclGroup() != pWidgetAcc) { - break; - } - if (m_TabOrderWidgetArray.Find(hWidget) < 0) { - m_TabOrderWidgetArray.Add(pRadio); - } - iWidgetIndex++; - } - } - if (CXFA_FFWidget* hTraverseWidget = GetTraverseWidget(hWidget)) { - hWidget = hTraverseWidget; - continue; - } - } - int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget); - hWidget = SpaceOrderWidgetArray[(iWidgetIndex + 1) % nWidgetCount]; - } -} -static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, - const void* phWidget2) { - CXFA_FFWidget* pWidget1 = (*(CXFA_TabParam**)phWidget1)->m_pWidget; - CXFA_FFWidget* pWidget2 = (*(CXFA_TabParam**)phWidget2)->m_pWidget; - CFX_RectF rt1, rt2; - pWidget1->GetWidgetRect(rt1); - pWidget2->GetWidgetRect(rt2); - FX_FLOAT x1 = rt1.left, y1 = rt1.top, x2 = rt2.left, y2 = rt2.top; - if (y1 < y2 || (y1 - y2 < XFA_FLOAT_PERCISION && x1 < x2)) { - return -1; - } - return 1; -} -void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( - CXFA_LayoutItemIterator* sIterator, - CXFA_LayoutItem* pContainerItem, - CXFA_TabParam* pContainer, - FX_BOOL& bCurrentItem, - FX_BOOL& bContentArea, - FX_BOOL bMarsterPage) { - CFX_PtrArray tabParams; - CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext(); - while (pSearchItem) { - if (!pSearchItem->IsContentLayoutItem()) { - bContentArea = TRUE; - pSearchItem = sIterator->MoveToNext(); - continue; - } - if (bMarsterPage && bContentArea) { - break; - } - if (bMarsterPage || bContentArea) { - CXFA_FFWidget* hWidget = GetWidget(pSearchItem); - if (!hWidget) { - pSearchItem = sIterator->MoveToNext(); - continue; - } - if (pContainerItem && (pSearchItem->GetParent() != pContainerItem)) { - bCurrentItem = TRUE; - break; - } - CXFA_TabParam* pParam = new CXFA_TabParam; - pParam->m_pWidget = hWidget; - tabParams.Add(pParam); - if (XFA_IsLayoutElement(pSearchItem->GetFormNode()->GetClassID(), TRUE)) { - OrderContainer(sIterator, pSearchItem, pParam, bCurrentItem, - bContentArea, bMarsterPage); - } - } - if (bCurrentItem) { - pSearchItem = sIterator->GetCurrent(); - bCurrentItem = FALSE; - } else { - pSearchItem = sIterator->MoveToNext(); - } - } - int32_t iChildren = tabParams.GetSize(); - if (iChildren > 1) { - FXSYS_qsort(tabParams.GetData(), iChildren, sizeof(void*), - XFA_TabOrderWidgetComparator); - } - for (int32_t iStart = 0; iStart < iChildren; iStart++) { - CXFA_TabParam* pParam = (CXFA_TabParam*)tabParams[iStart]; - pContainer->m_Children.Add(pParam->m_pWidget); - if (pParam->m_Children.GetSize() > 0) { - pContainer->m_Children.Append(pParam->m_Children); - } - delete pParam; - } - tabParams.RemoveAll(); -} -void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( - CXFA_WidgetArray& WidgetArray) { - CXFA_LayoutItemIterator sIterator; - sIterator.Init(m_pPageView); - CXFA_TabParam* pParam = new CXFA_TabParam; - FX_BOOL bCurrentItem = FALSE; - FX_BOOL bContentArea = FALSE; - OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea); - if (pParam->m_Children.GetSize() > 0) { - WidgetArray.Append(pParam->m_Children); - } - sIterator.Reset(); - bCurrentItem = FALSE; - bContentArea = FALSE; - pParam->m_Children.RemoveAll(); - OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea, TRUE); - if (pParam->m_Children.GetSize() > 0) { - WidgetArray.Append(pParam->m_Children); - } - delete pParam; -} -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( - CXFA_LayoutItem* pLayoutItem) { - if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { - pWidget->LoadWidget(); - } - return pWidget; - } - return NULL; -} diff --git a/xfa/src/fxfa/app/xfa_ffpageview.h b/xfa/src/fxfa/app/xfa_ffpageview.h deleted file mode 100644 index 58e63774b8..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpageview.h +++ /dev/null @@ -1,111 +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_SRC_FXFA_APP_XFA_FFPAGEVIEW_H_ -#define XFA_SRC_FXFA_APP_XFA_FFPAGEVIEW_H_ - -#include "xfa/src/fxfa/parser/xfa_doclayout.h" - -class CXFA_FFWidget; -class CXFA_FFDocView; -class CXFA_FFPageView : public CXFA_ContainerLayoutItem, public IXFA_PageView { - public: - CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); - ~CXFA_FFPageView() override; - - // IFXA_PageView: - IXFA_DocView* GetDocView() override; - int32_t GetPageViewIndex() override; - void GetPageViewRect(CFX_RectF& rtPage) override; - void GetDisplayMatrix(CFX_Matrix& mt, - const CFX_Rect& rtDisp, - int32_t iRotate) override; - int32_t LoadPageView(IFX_Pause* pPause = NULL) override; - void UnloadPageView() override; - IXFA_Widget* GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) override; - IXFA_WidgetIterator* CreateWidgetIterator( - FX_DWORD dwTraverseWay = XFA_TRAVERSEWAY_Form, - FX_DWORD dwWidgetFilter = XFA_WIDGETFILTER_Visible | - XFA_WIDGETFILTER_Viewable | - XFA_WIDGETFILTER_AllType) override; - - FX_BOOL IsPageViewLoaded(); - - protected: - CXFA_FFDocView* m_pDocView; - FX_BOOL m_bLoaded; -}; -typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem, - CXFA_TraverseStrategy_LayoutItem> - CXFA_LayoutItemIterator; -class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { - public: - CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, FX_DWORD dwFilter); - virtual ~CXFA_FFPageWidgetIterator(); - virtual void Release() { delete this; } - - virtual void Reset(); - virtual IXFA_Widget* MoveToFirst(); - virtual IXFA_Widget* MoveToLast(); - virtual IXFA_Widget* MoveToNext(); - virtual IXFA_Widget* MoveToPrevious(); - virtual IXFA_Widget* GetCurrentWidget(); - virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); - - protected: - IXFA_Widget* GetWidget(CXFA_LayoutItem* pLayoutItem); - CXFA_FFPageView* m_pPageView; - IXFA_Widget* m_hCurWidget; - FX_DWORD m_dwFilter; - FX_BOOL m_bIgnorerelevant; - CXFA_LayoutItemIterator m_sIterator; -}; -typedef CFX_ArrayTemplate<CXFA_FFWidget*> CXFA_WidgetArray; -class CXFA_TabParam { - public: - CXFA_TabParam() : m_pWidget(NULL) {} - ~CXFA_TabParam() {} - - CXFA_FFWidget* m_pWidget; - CXFA_WidgetArray m_Children; -}; -class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { - public: - CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, - FX_DWORD dwFilter); - virtual ~CXFA_FFTabOrderPageWidgetIterator(); - - virtual void Release(); - - virtual void Reset(); - virtual IXFA_Widget* MoveToFirst(); - virtual IXFA_Widget* MoveToLast(); - virtual IXFA_Widget* MoveToNext(); - virtual IXFA_Widget* MoveToPrevious(); - virtual IXFA_Widget* GetCurrentWidget(); - virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget); - - protected: - CXFA_WidgetArray m_TabOrderWidgetArray; - CXFA_FFPageView* m_pPageView; - FX_DWORD m_dwFilter; - int32_t m_iCurWidget; - FX_BOOL m_bIgnorerelevant; - CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget); - CXFA_FFWidget* FindWidgetByName(const CFX_WideStringC& wsWidgetName, - CXFA_FFWidget* pRefWidget); - void CreateTabOrderWidgetArray(); - void CreateSpaceOrderWidgetArray(CXFA_WidgetArray& WidgetArray); - CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); - void OrderContainer(CXFA_LayoutItemIterator* sIterator, - CXFA_LayoutItem* pContainerItem, - CXFA_TabParam* pContainer, - FX_BOOL& bCurrentItem, - FX_BOOL& bContentArea, - FX_BOOL bMarsterPage = FALSE); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFPAGEVIEW_H_ diff --git a/xfa/src/fxfa/app/xfa_ffpath.cpp b/xfa/src/fxfa/app/xfa_ffpath.cpp deleted file mode 100644 index 6f744c9753..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpath.cpp +++ /dev/null @@ -1,159 +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/src/fxfa/app/xfa_ffpath.h" - -#include "xfa/include/fxgraphics/fx_graphics.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdraw.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pPageView, pDataAcc) {} -CXFA_FFLine::~CXFA_FFLine() {} -void CXFA_FFLine::GetRectFromHand(CFX_RectF& rect, - int32_t iHand, - FX_FLOAT fLineWidth) { - FX_FLOAT fHalfWidth = fLineWidth / 2.0f; - if (rect.height < 1.0f) { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.top -= fHalfWidth; - break; - case XFA_ATTRIBUTEENUM_Right: - rect.top += fHalfWidth; - } - } else if (rect.width < 1.0f) { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.left += fHalfWidth; - break; - case XFA_ATTRIBUTEENUM_Right: - rect.left += fHalfWidth; - break; - } - } else { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.Inflate(fHalfWidth, fHalfWidth); - break; - case XFA_ATTRIBUTEENUM_Right: - rect.Deflate(fHalfWidth, fHalfWidth); - break; - } - } -} -void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) { - return; - } - CXFA_Line lineObj = value.GetLine(); - FX_ARGB lineColor = 0xFF000000; - int32_t iStrokeType = 0; - FX_FLOAT fLineWidth = 1.0f; - FX_BOOL bSlope = lineObj.GetSlop(); - int32_t iCap = 0; - CXFA_Edge edge = lineObj.GetEdge(); - if (edge) { - if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { - return; - } - lineColor = edge.GetColor(); - iStrokeType = edge.GetStrokeType(); - fLineWidth = edge.GetThickness(); - iCap = edge.GetCapType(); - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CFX_RectF rtLine; - GetRectWithoutRotate(rtLine); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - XFA_RectWidthoutMargin(rtLine, mgWidget); - } - GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth); - CFX_Path linePath; - linePath.Create(); - if (bSlope && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) { - linePath.AddLine(rtLine.right(), rtLine.top, rtLine.left, rtLine.bottom()); - } else { - linePath.AddLine(rtLine.left, rtLine.top, rtLine.right(), rtLine.bottom()); - } - CFX_Color color(lineColor); - pGS->SaveGraphState(); - pGS->SetLineWidth(fLineWidth, TRUE); - XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap); - pGS->SetStrokeColor(&color); - pGS->SetLineCap(XFA_LineCapToFXGE(iCap)); - pGS->StrokePath(&linePath, &mtRotate); - pGS->RestoreGraphState(); -} -CXFA_FFArc::CXFA_FFArc(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pPageView, pDataAcc) {} -CXFA_FFArc::~CXFA_FFArc() {} -void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) { - return; - } - CXFA_Arc arcObj = value.GetArc(); - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CFX_RectF rtArc; - GetRectWithoutRotate(rtArc); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - XFA_RectWidthoutMargin(rtArc, mgWidget); - } - DrawBorder(pGS, arcObj, rtArc, &mtRotate); -} -CXFA_FFRectangle::CXFA_FFRectangle(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pPageView, pDataAcc) {} -CXFA_FFRectangle::~CXFA_FFRectangle() {} -void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) { - return; - } - CXFA_Rectangle rtObj = value.GetRectangle(); - CFX_RectF rect; - GetRectWithoutRotate(rect); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - XFA_RectWidthoutMargin(rect, mgWidget); - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - DrawBorder(pGS, rtObj, rect, &mtRotate); -} diff --git a/xfa/src/fxfa/app/xfa_ffpath.h b/xfa/src/fxfa/app/xfa_ffpath.h deleted file mode 100644 index a215812b90..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpath.h +++ /dev/null @@ -1,43 +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_SRC_FXFA_APP_XFA_FFPATH_H_ -#define XFA_SRC_FXFA_APP_XFA_FFPATH_H_ - -#include "xfa/src/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFLine : public CXFA_FFDraw { - public: - CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFLine(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - - private: - void GetRectFromHand(CFX_RectF& rect, int32_t iHand, FX_FLOAT fLineWidth); -}; -class CXFA_FFArc : public CXFA_FFDraw { - public: - CXFA_FFArc(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFArc(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); -}; -class CXFA_FFRectangle : public CXFA_FFDraw { - public: - CXFA_FFRectangle(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFRectangle(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFPATH_H_ diff --git a/xfa/src/fxfa/app/xfa_ffpushbutton.cpp b/xfa/src/fxfa/app/xfa_ffpushbutton.cpp deleted file mode 100644 index 492a13544c..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpushbutton.cpp +++ /dev/null @@ -1,249 +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/src/fxfa/app/xfa_ffpushbutton.h" - -#include "xfa/include/fwl/core/fwl_widgetmgr.h" -#include "xfa/include/fwl/lightwidget/pushbutton.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), - m_pRolloverTextLayout(NULL), - m_pDownTextLayout(NULL), - m_pDownProvider(NULL), - m_pRollProvider(NULL), - m_pOldDelegate(NULL) {} -CXFA_FFPushButton::~CXFA_FFPushButton() { - CXFA_FFPushButton::UnloadWidget(); -} -void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - RenderHighlightCaption(pGS, &mtRotate); - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), - pGS, &mt); -} -FX_BOOL CXFA_FFPushButton::LoadWidget() { - FXSYS_assert(m_pNormalWidget == NULL); - CFWL_PushButton* pPushButton = CFWL_PushButton::Create(); - if (pPushButton) { - pPushButton->Initialize(); - } - m_pOldDelegate = pPushButton->SetDelegate(this); - m_pNormalWidget = (CFWL_Widget*)pPushButton; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - LoadHighlightCaption(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFPushButton::UpdateWidgetProperty() { - FX_DWORD dwStyleEx = 0; - switch (m_pDataAcc->GetButtonHighlight()) { - case XFA_ATTRIBUTEENUM_Inverted: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteInverted; - break; - case XFA_ATTRIBUTEENUM_Outline: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteOutLine; - break; - case XFA_ATTRIBUTEENUM_Push: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HilitePush; - break; - default: - break; - } - 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; - } - CXFA_FFField::UnloadWidget(); -} -FX_BOOL CXFA_FFPushButton::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - m_rtUI = rtWidget; - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - XFA_RectWidthoutMargin(rtWidget, mgWidget); - } - CXFA_Caption caption = m_pDataAcc->GetCaption(); - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height); - if (CXFA_Margin mgCap = caption.GetMargin()) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - } - LayoutHighlightCaption(); - SetFWLRect(); - if (m_pNormalWidget) { - m_pNormalWidget->Update(); - } - return TRUE; -} -FX_FLOAT CXFA_FFPushButton::GetLineWidth() { - CXFA_Border border = m_pDataAcc->GetBorder(); - if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { - CXFA_Edge edge = border.GetEdge(0); - return edge.GetThickness(); - } - return 0; -} -FX_ARGB CXFA_FFPushButton::GetLineColor() { - return 0xFF000000; -} -FX_ARGB CXFA_FFPushButton::GetFillColor() { - return 0xFFFFFFFF; -} -void CXFA_FFPushButton::LoadHighlightCaption() { - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - { - CFX_WideString wsRollover; - FX_BOOL bRichText; - if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { - if (m_pRollProvider == NULL) { - m_pRollProvider = - new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover); - } - m_pRolloverTextLayout = new CXFA_TextLayout(m_pRollProvider); - } - CFX_WideString wsDown; - if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { - if (m_pDownProvider == NULL) { - m_pDownProvider = - new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down); - } - m_pDownTextLayout = new CXFA_TextLayout(m_pDownProvider); - } - } - } -} -void CXFA_FFPushButton::LayoutHighlightCaption() { - CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height); - LayoutCaption(); - if (m_pRolloverTextLayout) { - m_pRolloverTextLayout->Layout(sz); - } - if (m_pDownTextLayout) { - m_pDownTextLayout->Layout(sz); - } -} -void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, - CFX_Matrix* pMatrix) { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - CFX_RectF rtClip = m_rtCaption; - rtClip.Intersect(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - { - FX_DWORD dwState = m_pNormalWidget->GetStates(); - if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && - (dwState & FWL_STATE_PSB_Hovered)) { - if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip)) { - return; - } - } else if (m_pRolloverTextLayout && (dwState & FWL_STATE_PSB_Hovered)) { - if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) { - return; - } - } - } - if (pCapTextLayout) { - pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); - } - } -} -int32_t CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) { - m_pOldDelegate->OnProcessEvent(pEvent); - return CXFA_FFField::OnProcessEvent(pEvent); -} -FWL_ERR 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)) { - CFX_RectF rtFill; - m_pNormalWidget->GetWidgetRect(rtFill); - rtFill.left = rtFill.top = 0; - FX_FLOAT fLineWith = GetLineWidth(); - rtFill.Deflate(fLineWith, fLineWith); - CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); - pGraphics->SetFillColor(&cr); - CFX_Path path; - path.Create(); - path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); - pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); - } - } else if (m_pNormalWidget->GetStylesEx() & - XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { - if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && - (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - FX_FLOAT fLineWidth = GetLineWidth(); - CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255)); - pGraphics->SetStrokeColor(&cr); - pGraphics->SetLineWidth(fLineWidth); - CFX_Path path; - path.Create(); - CFX_RectF rect; - m_pNormalWidget->GetWidgetRect(rect); - 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/xfa/src/fxfa/app/xfa_ffpushbutton.h b/xfa/src/fxfa/app/xfa_ffpushbutton.h deleted file mode 100644 index 19e72a7796..0000000000 --- a/xfa/src/fxfa/app/xfa_ffpushbutton.h +++ /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 - -#ifndef XFA_SRC_FXFA_APP_XFA_FFPUSHBUTTON_H_ -#define XFA_SRC_FXFA_APP_XFA_FFPUSHBUTTON_H_ - -#include "xfa/src/fxfa/app/xfa_fffield.h" - -#define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) -#define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0) -#define XFA_FWL_PSBSTYLEEXT_HilitePush (2L << 0) -#define XFA_FWL_PSBSTYLEEXT_HiliteOutLine (4L << 0) - -class CXFA_TextProvider; - -class CXFA_FFPushButton : public CXFA_FFField { - public: - CXFA_FFPushButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFPushButton(); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL LoadWidget(); - 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); - - protected: - void LoadHighlightCaption(); - void LayoutHighlightCaption(); - void RenderHighlightCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = NULL); - FX_FLOAT GetLineWidth(); - FX_ARGB GetLineColor(); - FX_ARGB GetFillColor(); - CXFA_TextLayout* m_pRolloverTextLayout; - CXFA_TextLayout* m_pDownTextLayout; - CXFA_TextProvider* m_pDownProvider; - CXFA_TextProvider* m_pRollProvider; - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFPUSHBUTTON_H_ diff --git a/xfa/src/fxfa/app/xfa_ffsignature.cpp b/xfa/src/fxfa/app/xfa_ffsignature.cpp deleted file mode 100644 index 9c4d31bbc4..0000000000 --- a/xfa/src/fxfa/app/xfa_ffsignature.cpp +++ /dev/null @@ -1,120 +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/src/fxfa/app/xfa_ffsignature.h" - -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFSignature::CXFA_FFSignature(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc) {} -CXFA_FFSignature::~CXFA_FFSignature() {} -FX_BOOL CXFA_FFSignature::LoadWidget() { - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, FALSE); - CFX_RectF rtWidget = m_rtUI; - IXFA_DocProvider* pDocProvider = m_pDataAcc->GetDoc()->GetDocProvider(); - FXSYS_assert(pDocProvider); - pDocProvider->RenderCustomWidget(this, pGS, &mtRotate, rtWidget); -} -FX_BOOL CXFA_FFSignature::OnMouseEnter() { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnMouseExit() { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnLButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnLButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnMouseMove(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnRButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnRButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnRButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - return FALSE; -} -FX_BOOL CXFA_FFSignature::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { - return FALSE; -} -FX_DWORD CXFA_FFSignature::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pNormalWidget) { - FX_FLOAT ffx = fx, ffy = fy; - FWLToClient(ffx, ffy); - FX_DWORD dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy); - if (dwWidgetHit != FWL_WGTHITTEST_Unknown) { - return FWL_WGTHITTEST_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; -} -FX_BOOL CXFA_FFSignature::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} diff --git a/xfa/src/fxfa/app/xfa_ffsignature.h b/xfa/src/fxfa/app/xfa_ffsignature.h deleted file mode 100644 index 6c7a614157..0000000000 --- a/xfa/src/fxfa/app/xfa_ffsignature.h +++ /dev/null @@ -1,43 +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_SRC_FXFA_APP_XFA_FFSIGNATURE_H_ -#define XFA_SRC_FXFA_APP_XFA_FFSIGNATURE_H_ - -#include "xfa/src/fxfa/app/xfa_fffield.h" - -class CXFA_FFSignature final : public CXFA_FFField { - public: - CXFA_FFSignature(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFSignature(); - - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL LoadWidget(); - virtual FX_BOOL OnMouseEnter(); - virtual FX_BOOL OnMouseExit(); - virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - - virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); - virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFSIGNATURE_H_ diff --git a/xfa/src/fxfa/app/xfa_ffsubform.cpp b/xfa/src/fxfa/app/xfa_ffsubform.cpp deleted file mode 100644 index 8845a36ed9..0000000000 --- a/xfa/src/fxfa/app/xfa_ffsubform.cpp +++ /dev/null @@ -1,17 +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/src/fxfa/app/xfa_ffsubform.h" - -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFSubForm::CXFA_FFSubForm(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pPageView, pDataAcc) {} -CXFA_FFSubForm::~CXFA_FFSubForm() {} diff --git a/xfa/src/fxfa/app/xfa_ffsubform.h b/xfa/src/fxfa/app/xfa_ffsubform.h deleted file mode 100644 index cb82f91c64..0000000000 --- a/xfa/src/fxfa/app/xfa_ffsubform.h +++ /dev/null @@ -1,19 +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_SRC_FXFA_APP_XFA_FFSUBFORM_H_ -#define XFA_SRC_FXFA_APP_XFA_FFSUBFORM_H_ - -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -class CXFA_FFSubForm : public CXFA_FFWidget { - public: - CXFA_FFSubForm(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFSubForm(); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFSUBFORM_H_ diff --git a/xfa/src/fxfa/app/xfa_fftext.cpp b/xfa/src/fxfa/app/xfa_fftext.cpp deleted file mode 100644 index 95d408ce71..0000000000 --- a/xfa/src/fxfa/app/xfa_fftext.cpp +++ /dev/null @@ -1,179 +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/src/fxfa/app/xfa_fftext.h" - -#include "xfa/include/fwl/core/fwl_widgetdef.h" -#include "xfa/include/fxgraphics/fx_graphics.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdraw.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -CXFA_FFText::CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pPageView, pDataAcc) {} -CXFA_FFText::~CXFA_FFText() {} -void CXFA_FFText::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - { - CFX_Matrix mtRotate; - GetRotateMatrix(mtRotate); - if (pMatrix) { - mtRotate.Concat(*pMatrix); - } - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (pTextLayout) { - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_RectF rtText; - GetRectWithoutRotate(rtText); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - CXFA_LayoutItem* pItem = this; - if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { - XFA_RectWidthoutMargin(rtText, mgWidget); - } else { - FX_FLOAT fLeftInset, fRightInset, fTopInset = 0, fBottomInset = 0; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - if (pItem->GetPrev() == NULL) { - mgWidget.GetTopInset(fTopInset); - } else if (pItem->GetNext() == NULL) { - mgWidget.GetBottomInset(fBottomInset); - } - rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); - } - } - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtText.left, rtText.top); - CFX_RectF rtClip = rtText; - mtRotate.TransformRect(rtClip); - mt.Concat(mtRotate); - pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); - } - } -} -FX_BOOL CXFA_FFText::IsLoaded() { - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - return pTextLayout && !pTextLayout->m_bHasBlock; -} -FX_BOOL CXFA_FFText::PerformLayout() { - CXFA_FFDraw::PerformLayout(); - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (!pTextLayout) { - return FALSE; - } - if (!pTextLayout->m_bHasBlock) { - return TRUE; - } - pTextLayout->m_Blocks.RemoveAll(); - CXFA_LayoutItem* pItem = this; - if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { - return TRUE; - } - pItem = pItem->GetFirst(); - while (pItem) { - CFX_RectF rtText; - pItem->GetRect(rtText); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - if (pItem->GetPrev() == NULL) { - FX_FLOAT fTopInset; - mgWidget.GetTopInset(fTopInset); - rtText.height -= fTopInset; - } else if (pItem->GetNext() == NULL) { - FX_FLOAT fBottomInset; - mgWidget.GetBottomInset(fBottomInset); - rtText.height -= fBottomInset; - } - } - pTextLayout->ItemBlocks(rtText, pItem->GetIndex()); - pItem = pItem->GetNext(); - } - pTextLayout->m_bHasBlock = FALSE; - return TRUE; -} -FX_BOOL CXFA_FFText::OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rtBox; - GetRectWithoutRotate(rtBox); - if (!rtBox.Contains(fx, fy)) { - return FALSE; - } - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); - if (NULL == wsURLContent) { - return FALSE; - } - SetButtonDown(TRUE); - return TRUE; -} -FX_BOOL CXFA_FFText::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rtBox; - GetRectWithoutRotate(rtBox); - if (!rtBox.Contains(fx, fy)) { - return FALSE; - } - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); - if (NULL == wsURLContent) { - return FALSE; - } - return TRUE; -} -FX_BOOL CXFA_FFText::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!IsButtonDown()) { - return FALSE; - } - SetButtonDown(FALSE); - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); - if (NULL == wsURLContent) { - return FALSE; - } - CXFA_FFDoc* pDoc = GetDoc(); - pDoc->GetDocProvider()->GotoURL(pDoc, CFX_WideStringC(wsURLContent), FALSE); - return TRUE; -} -FX_DWORD 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; -} -const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (NULL == pTextLayout) { - return NULL; - } - FX_FLOAT x(fx), y(fy); - FWLToClient(x, y); - const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines(); - int32_t iCount = pPieceLines->GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); - int32_t iPieces = pPieceLine->m_textPieces.GetSize(); - for (int32_t j = 0; j < iPieces; j++) { - XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); - if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { - return pPiece->pLinkData->GetLinkURL(); - } - } - } - return NULL; -} -void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { - CFX_RectF rtWidget; - GetRectWithoutRotate(rtWidget); - fx -= rtWidget.left; - fy -= rtWidget.top; -} diff --git a/xfa/src/fxfa/app/xfa_fftext.h b/xfa/src/fxfa/app/xfa_fftext.h deleted file mode 100644 index 673d157fd3..0000000000 --- a/xfa/src/fxfa/app/xfa_fftext.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_SRC_FXFA_APP_XFA_FFTEXT_H_ -#define XFA_SRC_FXFA_APP_XFA_FFTEXT_H_ - -#include "xfa/src/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFText : public CXFA_FFDraw { - public: - CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFText(); - virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_DWORD OnHitTest(FX_FLOAT fx, FX_FLOAT fy); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - virtual FX_BOOL IsLoaded(); - virtual FX_BOOL PerformLayout(); - - private: - virtual const FX_WCHAR* GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy); - void FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFTEXT_H_ diff --git a/xfa/src/fxfa/app/xfa_fftextedit.cpp b/xfa/src/fxfa/app/xfa_fftextedit.cpp deleted file mode 100644 index f828939327..0000000000 --- a/xfa/src/fxfa/app/xfa_fftextedit.cpp +++ /dev/null @@ -1,796 +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/src/fxfa/app/xfa_fftextedit.h" - -#include <vector> - -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/lightwidget/datetimepicker.h" -#include "xfa/include/fwl/lightwidget/edit.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" -#include "xfa/src/fxfa/parser/xfa_localevalue.h" - -CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} -CXFA_FFTextEdit::~CXFA_FFTextEdit() { - if (m_pNormalWidget) { - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(pWidget); - } -} -FX_BOOL CXFA_FFTextEdit::LoadWidget() { - CFWL_Edit* pFWLEdit = CFWL_Edit::Create(); - pFWLEdit->Initialize(); - m_pNormalWidget = pFWLEdit; - IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); - IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(pWidget, pWidget); - m_pOldDelegate = m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLEdit->SetText(wsText); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFTextEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; - if (!pWidget) { - return; - } - FX_DWORD dwStyle = 0; - FX_DWORD dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | - FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->IsMultiLine()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; - if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwStyle |= FWL_WGTSTYLE_VScroll; - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; - } - } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; - } - XFA_ELEMENT eType = XFA_ELEMENT_UNKNOWN; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); - if (eType == XFA_ELEMENT_ExData) { - iMaxChars = 0; - } - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells == 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); - } else if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } else { - pWidget->SetLimit(iMaxChars); - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} -FX_BOOL CXFA_FFTextEdit::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!PtInActiveRect(fx, fy)) { - return FALSE; - } - if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - SetButtonDown(TRUE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown; - 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); - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::OnRButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - if (!PtInActiveRect(fx, fy)) { - return FALSE; - } - if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - SetButtonDown(TRUE); - CFWL_MsgMouse ms; - ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::OnRButtonUp(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) - return FALSE; - - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { - m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; - if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - CXFA_FFWidget::OnSetFocus(pOldWidget); - CFWL_MsgSetFocus ms; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { - CFWL_MsgKillFocus ms; - ms.m_pDstTarget = m_pNormalWidget->m_pIface; - ms.m_pSrcTarget = NULL; - TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; - SetEditScrollOffset(); - ProcessCommittedData(); - UpdateFWLData(); - AddInvalidateRect(); - CXFA_FFWidget::OnKillFocus(pNewWidget); - m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::CommitData() { - CFX_WideString wsText; - ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); - if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { - m_pDataAcc->UpdateUIDisplay(this); - return TRUE; - } - ValidateNumberField(wsText); - return FALSE; -} -void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { - CXFA_WidgetAcc* pAcc = GetDataAcc(); - if (pAcc && pAcc->GetUIType() == XFA_ELEMENT_NumericEdit) { - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - 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, wsTitle, XFA_MBICON_Error, XFA_MB_OK); - } - } -} -FX_BOOL CXFA_FFTextEdit::IsDataChanged() { - return (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) != 0; -} -FX_DWORD CXFA_FFTextEdit::GetAlignment() { - FX_DWORD dwExtendedStyle = 0; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - int32_t iHorz = para.GetHorizontalAlign(); - switch (iHorz) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; - break; - } - int32_t iVert = para.GetVerticalAlign(); - switch (iVert) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; - break; - } - } - return dwExtendedStyle; -} -FX_BOOL CXFA_FFTextEdit::UpdateFWLData() { - if (!m_pNormalWidget) { - return FALSE; - } - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) { - eType = XFA_VALUEPICTURE_Edit; - } - FX_BOOL bUpdate = FALSE; - if (m_pDataAcc->GetUIType() == XFA_ELEMENT_TextEdit && - m_pDataAcc->GetNumberOfCells() < 0) { - XFA_ELEMENT elementType = XFA_ELEMENT_UNKNOWN; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); - if (elementType == XFA_ELEMENT_ExData) { - iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; - } - if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) { - ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars); - bUpdate = TRUE; - } - } - if (m_pDataAcc->GetUIType() == XFA_ELEMENT_Barcode) { - int32_t nDataLen = 0; - if (eType == XFA_VALUEPICTURE_Edit) - m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen); - static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen); - bUpdate = TRUE; - } - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - CFX_WideString wsOldText; - ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); - if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { - ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); - bUpdate = TRUE; - } - if (bUpdate) { - m_pNormalWidget->Update(); - } - return TRUE; -} -FX_BOOL CXFA_FFTextEdit::CanUndo() { - return ((CFWL_Edit*)m_pNormalWidget)->CanUndo(); -} -FX_BOOL CXFA_FFTextEdit::CanRedo() { - return ((CFWL_Edit*)m_pNormalWidget)->CanRedo(); -} -FX_BOOL CXFA_FFTextEdit::Undo() { - return ((CFWL_Edit*)m_pNormalWidget)->Undo(); -} -FX_BOOL CXFA_FFTextEdit::Redo() { - return ((CFWL_Edit*)m_pNormalWidget)->Redo(); -} -FX_BOOL CXFA_FFTextEdit::CanCopy() { - int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); - return nCount > 0; -} -FX_BOOL CXFA_FFTextEdit::CanCut() { - if (m_pNormalWidget->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { - return FALSE; - } - int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); - return nCount > 0; -} -FX_BOOL CXFA_FFTextEdit::CanPaste() { - return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; -} -FX_BOOL CXFA_FFTextEdit::CanSelectAll() { - return ((CFWL_Edit*)m_pNormalWidget)->GetTextLength() > 0; -} -FX_BOOL CXFA_FFTextEdit::Copy(CFX_WideString& wsCopy) { - return ((CFWL_Edit*)m_pNormalWidget)->Copy(wsCopy); -} -FX_BOOL CXFA_FFTextEdit::Cut(CFX_WideString& wsCut) { - return ((CFWL_Edit*)m_pNormalWidget)->Cut(wsCut); -} -FX_BOOL CXFA_FFTextEdit::Paste(const CFX_WideString& wsPaste) { - return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); -} -FX_BOOL CXFA_FFTextEdit::SelectAll() { - int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); - return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount); -} -FX_BOOL CXFA_FFTextEdit::Delete() { - return ((CFWL_Edit*)m_pNormalWidget)->Delete(); -} -FX_BOOL CXFA_FFTextEdit::DeSelect() { - return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections(); -} -FX_BOOL CXFA_FFTextEdit::GetSuggestWords( - CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) { - if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { - return FALSE; - } - FWLToClient(pointf.x, pointf.y); - return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); -} -FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord( - CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { - return FALSE; - } - FWLToClient(pointf.x, pointf.y); - return ((CFWL_Edit*)m_pNormalWidget) - ->ReplaceSpellCheckWord(pointf, bsReplace); -} -void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText) { - m_dwStatus |= XFA_WIDGETSTATUS_TextEditValueChanged; - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_wsChange = wsChanged; - eParam.m_pTarget = m_pDataAcc; - eParam.m_wsPrevText = wsPrevText; - CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); - if (m_pDataAcc->GetUIType() == XFA_ELEMENT_DateTimeEdit) { - CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; - pDateTime->GetEditText(eParam.m_wsNewText); - int32_t iSels = pDateTime->CountSelRanges(); - if (iSels) { - eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); - } - } else { - pEdit->GetText(eParam.m_wsNewText); - int32_t iSels = pEdit->CountSelRanges(); - if (iSels) { - eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); - } - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} -void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Full; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); -} - -FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { - if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { - return TRUE; - } - return GetDoc()->GetDocProvider()->CheckWord(GetDoc(), sWord); -} -FX_BOOL CXFA_FFTextEdit::GetSuggestWords( - const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest) { - if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { - return FALSE; - } - return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); -} -int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { - return m_pOldDelegate->OnProcessMessage(pMessage); -} -FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - FX_DWORD dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_EDT_TextChanged: { - CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; - CFX_WideString wsChange; - OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); - break; - } - case FWL_EVTHASH_EDT_TextFull: { - OnTextFull(m_pNormalWidget->GetWidget()); - break; - } - case FWL_EVTHASH_EDT_CheckWord: { - CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); - CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; - event->bCheckWord = CheckWord(event->bsWord); - break; - } - case FWL_EVTHASH_EDT_GetSuggestWords: { - CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; - event->bSuggestWords = - GetSuggestWords(event->bsWord, event->bsArraySuggestWords); - break; - } - default: {} - } - return m_pOldDelegate->OnProcessEvent(pEvent); -} -FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} -CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pPageView, pDataAcc) {} -CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} -FX_BOOL CXFA_FFNumericEdit::LoadWidget() { - CFWL_Edit* pWidget = CFWL_Edit::Create(); - pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; - IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); - IFWL_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->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFNumericEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; - if (!pWidget) { - return; - } - FX_DWORD dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - } - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } - dwExtendedStyle |= GetAlignment(); - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} -FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { - FX_DWORD dwEventID = pEvent->GetClassID(); - if (dwEventID == FWL_EVTHASH_EDT_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); - } -} -FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, - CFX_WideString& wsText) { - CFX_WideString wsPattern; - m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); - if (!wsPattern.IsEmpty()) { - return TRUE; - } - int32_t iLeads = 0; - m_pDataAcc->GetLeadDigits(iLeads); - int32_t iFracs = 0; - m_pDataAcc->GetFracDigits(iFracs); - CFX_WideString wsFormat; - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); - widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); - return widgetValue.ValidateNumericTemp(wsText, wsFormat, - m_pDataAcc->GetLocal()); -} -CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pPageView, pDataAcc) {} -CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} -FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { - CFWL_Edit* pWidget = CFWL_Edit::Create(); - pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; - IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); - IFWL_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->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFPasswordEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = (CFWL_Edit*)m_pNormalWidget; - if (!pWidget) { - return; - } - FX_DWORD dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - CFX_WideString wsPassWord; - m_pDataAcc->GetPasswordChar(wsPassWord); - if (!wsPassWord.IsEmpty()) { - pWidget->SetAliasChar(wsPassWord.GetAt(0)); - } - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} -CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pPageView, pDataAcc) {} - -CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} - -FX_BOOL CXFA_FFDateTimeEdit::GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus) { - if (bDrawFocus) - return FALSE; - return CXFA_FFWidget::GetBBox(rtBox, dwStatus); -} - -FX_BOOL CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return FALSE; - } - CFX_RectF rtWidget; - ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); - if (rtWidget.Contains(fx, fy)) { - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { - CFWL_DateTimePicker* pWidget = CFWL_DateTimePicker::Create(); - pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; - IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); - IFWL_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); - if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - switch (value.GetChildValueClassID()) { - case XFA_ELEMENT_Date: { - if (!wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); - CFX_Unitime date = lcValue.GetDate(); - if ((FX_UNITIME)date != 0) { - pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } - } break; - default: - break; - } - } - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} -void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { - CFWL_DateTimePicker* pWidget = (CFWL_DateTimePicker*)m_pNormalWidget; - if (!pWidget) { - return; - } - FX_DWORD dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; - dwExtendedStyle |= UpdateUIProperty(); - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - FX_DWORD dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwEditStyles |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetEditLimit(iNumCells); - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - } - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; - } - pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); -} -FX_DWORD CXFA_FFDateTimeEdit::GetAlignment() { - FX_DWORD dwExtendedStyle = 0; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - int32_t iHorz = para.GetHorizontalAlign(); - switch (iHorz) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; - break; - } - int32_t iVert = para.GetVerticalAlign(); - switch (iVert) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; - break; - } - } - return dwExtendedStyle; -} -FX_BOOL CXFA_FFDateTimeEdit::CommitData() { - CFX_WideString wsText; - ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); - if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { - m_pDataAcc->UpdateUIDisplay(this); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { - if (!m_pNormalWidget) { - return FALSE; - } - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) { - eType = XFA_VALUEPICTURE_Edit; - } - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); - if (IsFocused() && !wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); - CFX_Unitime date = lcValue.GetDate(); - if (lcValue.IsValid()) { - if ((FX_UNITIME)date != 0) { - ((CFWL_DateTimePicker*)m_pNormalWidget) - ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } - } - m_pNormalWidget->Update(); - return TRUE; -} -FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() { - if (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) { - return TRUE; - } - CFX_WideString wsText; - ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); - CFX_WideString wsOldValue; - m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); - return wsOldValue != wsText; -} -FX_BOOL CXFA_FFDateTimeEdit::CanUndo() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo(); -} -FX_BOOL CXFA_FFDateTimeEdit::CanRedo() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanRedo(); -} -FX_BOOL CXFA_FFDateTimeEdit::Undo() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Undo(); -} -FX_BOOL CXFA_FFDateTimeEdit::Redo() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Redo(); -} -FX_BOOL CXFA_FFDateTimeEdit::CanCopy() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCopy(); -} -FX_BOOL CXFA_FFDateTimeEdit::CanCut() { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return FALSE; - } - return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCut(); -} -FX_BOOL CXFA_FFDateTimeEdit::CanPaste() { - return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; -} -FX_BOOL CXFA_FFDateTimeEdit::CanSelectAll() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanSelectAll(); -} -FX_BOOL CXFA_FFDateTimeEdit::Copy(CFX_WideString& wsCopy) { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Copy(wsCopy); -} -FX_BOOL CXFA_FFDateTimeEdit::Cut(CFX_WideString& wsCut) { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Cut(wsCut); -} -FX_BOOL CXFA_FFDateTimeEdit::Paste(const CFX_WideString& wsPaste) { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Paste(wsPaste); -} -FX_BOOL CXFA_FFDateTimeEdit::SelectAll() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->SelectAll(); -} -FX_BOOL CXFA_FFDateTimeEdit::Delete() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->Delete(); -} -FX_BOOL CXFA_FFDateTimeEdit::DeSelect() { - return ((CFWL_DateTimePicker*)m_pNormalWidget)->DeSelect(); -} -void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay) { - CFX_WideString wsPicture; - m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); - CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); - CFX_Unitime dt; - dt.Set(iYear, iMonth, iDay); - date.SetDate(dt); - CFX_WideString wsDate; - date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), - XFA_VALUEPICTURE_Edit); - CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; - pDateTime->SetEditText(wsDate); - pDateTime->Update(); - GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} -FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { - FX_DWORD dwEventID = pEvent->GetClassID(); - if (dwEventID == FWL_EVTHASH_DTP_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); - } -} diff --git a/xfa/src/fxfa/app/xfa_fftextedit.h b/xfa/src/fxfa/app/xfa_fftextedit.h deleted file mode 100644 index a87300dec0..0000000000 --- a/xfa/src/fxfa/app/xfa_fftextedit.h +++ /dev/null @@ -1,138 +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_SRC_FXFA_APP_XFA_FFTEXTEDIT_H_ -#define XFA_SRC_FXFA_APP_XFA_FFTEXTEDIT_H_ - -#include <vector> - -#include "xfa/src/fxfa/app/xfa_fffield.h" - -class CXFA_FFTextEdit : public CXFA_FFField { - public: - CXFA_FFTextEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFTextEdit() override; - - // CXFA_FFField: - FX_BOOL LoadWidget() override; - void UpdateWidgetProperty() override; - FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget) override; - FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget) override; - FX_BOOL CanUndo() override; - FX_BOOL CanRedo() override; - FX_BOOL Undo() override; - FX_BOOL Redo() override; - FX_BOOL CanCopy() override; - FX_BOOL CanCut() override; - FX_BOOL CanPaste() override; - FX_BOOL CanSelectAll() override; - FX_BOOL Copy(CFX_WideString& wsCopy) override; - FX_BOOL Cut(CFX_WideString& wsCut) override; - FX_BOOL Paste(const CFX_WideString& wsPaste) override; - FX_BOOL SelectAll() override; - FX_BOOL Delete() override; - FX_BOOL DeSelect() override; - FX_BOOL GetSuggestWords(CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) override; - FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, - 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 OnTextChanged(IFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText); - void OnTextFull(IFWL_Widget* pWidget); - FX_BOOL CheckWord(const CFX_ByteStringC& sWord); - FX_BOOL GetSuggestWords(const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest); - - protected: - FX_DWORD GetAlignment(); - FX_BOOL CommitData() override; - FX_BOOL UpdateFWLData() override; - FX_BOOL IsDataChanged() override; - void ValidateNumberField(const CFX_WideString& wsText); - - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -class CXFA_FFNumericEdit : public CXFA_FFTextEdit { - public: - CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFNumericEdit(); - virtual FX_BOOL LoadWidget(); - virtual void UpdateWidgetProperty(); - virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); - - public: - FX_BOOL OnValidate(IFWL_Widget* pWidget, CFX_WideString& wsText); -}; -class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { - public: - CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFPasswordEdit(); - virtual FX_BOOL LoadWidget(); - virtual void UpdateWidgetProperty(); - - protected: -}; -enum XFA_DATETIMETYPE { - XFA_DATETIMETYPE_Date = 0, - XFA_DATETIMETYPE_Time, - XFA_DATETIMETYPE_DateAndTime -}; -class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { - public: - CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFDateTimeEdit(); - - virtual FX_BOOL GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus = FALSE); - virtual FX_BOOL LoadWidget(); - virtual void UpdateWidgetProperty(); - - 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 CanPaste(); - 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(); - - protected: - FX_DWORD GetAlignment(); - - virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL CommitData(); - virtual FX_BOOL UpdateFWLData(); - virtual FX_BOOL IsDataChanged(); - - public: - void OnSelectChanged(IFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay); - virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFTEXTEDIT_H_ diff --git a/xfa/src/fxfa/app/xfa_ffwidget.cpp b/xfa/src/fxfa/app/xfa_ffwidget.cpp deleted file mode 100644 index cc947b0ad4..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidget.cpp +++ /dev/null @@ -1,1961 +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/src/fxfa/app/xfa_ffwidget.h" - -#include <algorithm> - -#include "core/include/fpdfapi/fpdf_page.h" -#include "core/include/fxcodec/fx_codec.h" -#include "xfa/include/fxgraphics/fx_graphics.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, - CXFA_WidgetAcc* pDataAcc) - : CXFA_ContentLayoutItem(pDataAcc->GetNode()), - m_pPageView(pPageView), - m_pDataAcc(pDataAcc) { - m_rtWidget.Set(0, 0, 0, 0); -} -CXFA_FFWidget::~CXFA_FFWidget() {} -IXFA_PageView* CXFA_FFWidget::GetPageView() { - return m_pPageView; -} -void CXFA_FFWidget::SetPageView(IXFA_PageView* pPageView) { - m_pPageView = static_cast<CXFA_FFPageView*>(pPageView); -} -void CXFA_FFWidget::GetWidgetRect(CFX_RectF& rtWidget) { - 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; - GetRect(m_rtWidget); - return m_rtWidget; -} -void CXFA_FFWidget::GetRectWithoutRotate(CFX_RectF& rtWidget) { - GetWidgetRect(rtWidget); - FX_FLOAT fValue = 0; - switch (m_pDataAcc->GetRotate()) { - case 90: - rtWidget.top = rtWidget.bottom(); - fValue = rtWidget.width; - rtWidget.width = rtWidget.height; - rtWidget.height = fValue; - break; - case 180: - rtWidget.left = rtWidget.right(); - rtWidget.top = rtWidget.bottom(); - break; - case 270: - rtWidget.left = rtWidget.right(); - fValue = rtWidget.width; - rtWidget.width = rtWidget.height; - rtWidget.height = fValue; - break; - } -} -FX_DWORD CXFA_FFWidget::GetStatus() { - return m_dwStatus; -} - -void CXFA_FFWidget::ModifyStatus(FX_DWORD dwAdded, FX_DWORD dwRemoved) { - m_dwStatus = (m_dwStatus & ~dwRemoved) | dwAdded; -} - -FX_BOOL CXFA_FFWidget::GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus) { - if (bDrawFocus) - return FALSE; - if (m_pPageView) - m_pPageView->GetPageViewRect(rtBox); - return TRUE; -} - -CXFA_WidgetAcc* CXFA_FFWidget::GetDataAcc() { - return m_pDataAcc; -} -FX_BOOL CXFA_FFWidget::GetToolTip(CFX_WideString& wsToolTip) { - if (CXFA_Assist assist = m_pDataAcc->GetAssist()) { - if (CXFA_ToolTip toolTip = assist.GetToolTip()) { - return toolTip.GetTip(wsToolTip); - } - } - return GetCaptionText(wsToolTip); -} -void CXFA_FFWidget::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_DWORD dwStatus, - int32_t iRotate) { - if (!IsMatchVisibleStatus(dwStatus)) { - return; - } - CXFA_Border border = m_pDataAcc->GetBorder(); - if (border) { - CFX_RectF rtBorder; - GetRectWithoutRotate(rtBorder); - CXFA_Margin margin = border.GetMargin(); - if (margin) { - XFA_RectWidthoutMargin(rtBorder, margin); - } - rtBorder.Normalize(); - DrawBorder(pGS, border, rtBorder, pMatrix); - } -} -FX_BOOL CXFA_FFWidget::IsLoaded() { - return m_pPageView != NULL; -} -FX_BOOL CXFA_FFWidget::LoadWidget() { - PerformLayout(); - return TRUE; -} -void CXFA_FFWidget::UnloadWidget() {} -FX_BOOL CXFA_FFWidget::PerformLayout() { - ReCacheWidgetRect(); - return TRUE; -} -FX_BOOL CXFA_FFWidget::UpdateFWLData() { - return FALSE; -} -void CXFA_FFWidget::UpdateWidgetProperty() {} -void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS, - CXFA_Box box, - const CFX_RectF& rtBorder, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags) { - XFA_DrawBox(box, pGS, rtBorder, pMatrix, dwFlags); -} -void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { - if (!pRect) { - CFX_RectF rtWidget; - GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); - rtWidget.Inflate(2, 2); - GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, rtWidget, - XFA_INVALIDATE_CurrentPage); - } else { - GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, *pRect, - XFA_INVALIDATE_CurrentPage); - } -} -void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { - CFX_RectF rtWidget; - if (pRect) { - rtWidget = *pRect; - } else { - GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); - rtWidget.Inflate(2, 2); - } - m_pDocView->AddInvalidateRect(m_pPageView, rtWidget); -} -FX_BOOL CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) { - CXFA_TextLayout* pCapTextlayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextlayout) { - return FALSE; - } - pCapTextlayout->GetText(wsCap); - return TRUE; -} -FX_BOOL CXFA_FFWidget::IsFocused() { - return m_dwStatus & XFA_WIDGETSTATUS_Focused; -} -FX_BOOL CXFA_FFWidget::OnMouseEnter() { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnMouseExit() { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnLButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnLButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnRButtonDown(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnRButtonDblClk(FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - return FALSE; -} - -FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { - CXFA_FFWidget* pParent = GetParent(); - if (pParent && !pParent->IsAncestorOf(pOldWidget)) { - pParent->OnSetFocus(pOldWidget); - } - m_dwStatus |= XFA_WIDGETSTATUS_Focused; - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Enter; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Enter, &eParam); - return TRUE; -} -FX_BOOL CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; - EventKillFocus(); - if (pNewWidget) { - CXFA_FFWidget* pParent = GetParent(); - if (pParent && !pParent->IsAncestorOf(pNewWidget)) { - pParent->OnKillFocus(pNewWidget); - } - } - return TRUE; -} -FX_BOOL CXFA_FFWidget::OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnChar(FX_DWORD dwChar, FX_DWORD dwFlags) { - return FALSE; -} -FX_DWORD CXFA_FFWidget::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} -FX_BOOL CXFA_FFWidget::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { - return FALSE; -} -void CXFA_FFWidget::Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy) { - CFX_Matrix mt; - GetRotateMatrix(mt); - if (mt.IsIdentity()) { - return; - } - CFX_Matrix mtReverse; - mtReverse.SetReverse(mt); - mtReverse.TransformPoint(fx, fy); -} -static void XFA_GetMatrix(CFX_Matrix& m, - int32_t iRotate, - int32_t at, - const CFX_RectF& rt) { - if (!iRotate) { - return; - } - FX_FLOAT fAnchorX, fAnchorY; - switch (at) { - case XFA_ATTRIBUTEENUM_TopLeft: - fAnchorX = rt.left, fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_TopCenter: - fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_TopRight: - fAnchorX = rt.right(), fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_MiddleLeft: - fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_MiddleCenter: - fAnchorX = (rt.left + rt.right()) / 2, - fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_MiddleRight: - fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_BottomLeft: - fAnchorX = rt.left, fAnchorY = rt.bottom(); - break; - case XFA_ATTRIBUTEENUM_BottomCenter: - fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom(); - break; - case XFA_ATTRIBUTEENUM_BottomRight: - fAnchorX = rt.right(), fAnchorY = rt.bottom(); - break; - } - switch (iRotate) { - case 90: - m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY, - m.f = fAnchorX + fAnchorY; - break; - case 180: - m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2, - m.f = fAnchorY * 2; - break; - case 270: - m.a = 0, m.b = 1, m.c = -1, m.d = 0, m.e = fAnchorX + fAnchorY, - m.f = fAnchorY - fAnchorX; - break; - } -} -void CXFA_FFWidget::GetRotateMatrix(CFX_Matrix& mt) { - mt.Set(1, 0, 0, 1, 0, 0); - int32_t iRotate = m_pDataAcc->GetRotate(); - if (!iRotate) { - return; - } - CFX_RectF rcWidget; - GetRectWithoutRotate(rcWidget); - XFA_ATTRIBUTEENUM at = XFA_ATTRIBUTEENUM_TopLeft; - XFA_GetMatrix(mt, iRotate, at, rcWidget); -} -FX_BOOL CXFA_FFWidget::IsLayoutRectEmpty() { - CFX_RectF rtLayout; - GetRectWithoutRotate(rtLayout); - return rtLayout.width < 0.1f && rtLayout.height < 0.1f; -} -CXFA_FFWidget* CXFA_FFWidget::GetParent() { - CXFA_Node* pParentNode = - m_pDataAcc->GetNode()->GetNodeItem(XFA_NODEITEM_Parent); - if (pParentNode) { - CXFA_WidgetAcc* pParentWidgetAcc = - (CXFA_WidgetAcc*)pParentNode->GetWidgetData(); - if (pParentWidgetAcc) { - return pParentWidgetAcc->GetNextWidget(NULL); - } - } - return NULL; -} -FX_BOOL CXFA_FFWidget::IsAncestorOf(CXFA_FFWidget* pWidget) { - if (!pWidget) { - return FALSE; - } - CXFA_Node* pNode = m_pDataAcc->GetNode(); - CXFA_Node* pChildNode = pWidget->GetDataAcc()->GetNode(); - while (pChildNode) { - if (pChildNode == pNode) { - return TRUE; - } - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_Parent); - } - return FALSE; -} -FX_BOOL CXFA_FFWidget::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rtWidget; - GetWidgetRect(rtWidget); - if (rtWidget.Contains(fx, fy)) { - return TRUE; - } - return FALSE; -} -CXFA_FFDocView* CXFA_FFWidget::GetDocView() { - return m_pDocView; -} -CXFA_FFDoc* CXFA_FFWidget::GetDoc() { - return (CXFA_FFDoc*)m_pDocView->GetDoc(); -} -CXFA_FFApp* CXFA_FFWidget::GetApp() { - return GetDoc()->GetApp(); -} -IXFA_AppProvider* CXFA_FFWidget::GetAppProvider() { - return GetApp()->GetAppProvider(); -} -void CXFA_FFWidget::GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth) { - fMinWidth = fMaxWidth = 0; - FX_FLOAT fWidth = 0; - if (m_pDataAcc->GetWidth(fWidth)) { - fMinWidth = fMaxWidth = fWidth; - } else { - m_pDataAcc->GetMinWidth(fMinWidth); - m_pDataAcc->GetMaxWidth(fMaxWidth); - } -} -void CXFA_FFWidget::GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight) { - fMinHeight = fMaxHeight = 0; - FX_FLOAT fHeight = 0; - if (m_pDataAcc->GetHeight(fHeight)) { - fMinHeight = fMaxHeight = fHeight; - } else { - m_pDataAcc->GetMinHeight(fMinHeight); - m_pDataAcc->GetMaxHeight(fMaxHeight); - } -} -FX_BOOL CXFA_FFWidget::IsMatchVisibleStatus(FX_DWORD dwStatus) { - return m_dwStatus & XFA_WIDGETSTATUS_Visible; -} -void CXFA_FFWidget::EventKillFocus() { - if (m_dwStatus & XFA_WIDGETSTATUS_Access) { - m_dwStatus &= ~XFA_WIDGETSTATUS_Access; - return; - } - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Exit; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam); -} -FX_BOOL CXFA_FFWidget::IsButtonDown() { - 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; -} -int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, - int32_t iStrokeType, - int32_t iCapType) { - switch (iStrokeType) { - case XFA_ATTRIBUTEENUM_DashDot: { - FX_FLOAT dashArray[] = {4, 1, 2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - } - pGraphics->SetLineDash(0, dashArray, 4); - return FX_DASHSTYLE_DashDot; - } - case XFA_ATTRIBUTEENUM_DashDotDot: { - FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - dashArray[5] = 2; - } - pGraphics->SetLineDash(0, dashArray, 6); - return FX_DASHSTYLE_DashDotDot; - } - case XFA_ATTRIBUTEENUM_Dashed: { - FX_FLOAT dashArray[] = {5, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - } - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dash; - } - case XFA_ATTRIBUTEENUM_Dotted: { - FX_FLOAT dashArray[] = {2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - } - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dot; - } - default: - break; - } - pGraphics->SetLineDash(FX_DASHSTYLE_Solid); - return FX_DASHSTYLE_Solid; -} -CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) { - switch (iLineCap) { - case XFA_ATTRIBUTEENUM_Round: - return CFX_GraphStateData::LineCapRound; - case XFA_ATTRIBUTEENUM_Butt: - return CFX_GraphStateData::LineCapButt; - default: - break; - } - 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, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - FX_DWORD flags, - int blendType = FXDIB_BLEND_NORMAL); - FX_BOOL Continue(IFX_Pause* pPause); - - protected: - CFX_RenderDevice* m_pDevice; - int m_Status; - CFX_Matrix m_ImageMatrix; - CFX_DIBSource* m_pDIBSource; - CFX_DIBitmap* m_pCloneConvert; - int m_BitmapAlpha; - FX_ARGB m_FillArgb; - FX_DWORD m_Flags; - CFX_ImageTransformer* m_pTransformer; - void* m_DeviceHandle; - int32_t m_BlendType; - FX_BOOL m_Result; - FX_BOOL m_bPrint; - FX_BOOL StartDIBSource(); - void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency); -}; -CXFA_ImageRenderer::CXFA_ImageRenderer() { - m_pDevice = NULL; - m_Status = 0; - m_pDIBSource = NULL; - m_pCloneConvert = NULL; - 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) { - m_pDevice->CancelDIBits(m_DeviceHandle); - } -} -FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, - CFX_DIBSource* pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - FX_DWORD flags, - int blendType) { - m_pDevice = pDevice; - m_pDIBSource = pDIBSource; - m_FillArgb = bitmap_argb; - m_BitmapAlpha = bitmap_alpha; - m_ImageMatrix = *pImage2Device; - m_Flags = flags; - m_BlendType = blendType; - return StartDIBSource(); -} -FX_BOOL CXFA_ImageRenderer::StartDIBSource() { - if (m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_FillArgb, - &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, - m_BlendType)) { - if (m_DeviceHandle) { - m_Status = 3; - return TRUE; - } - return FALSE; - } - CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); - FX_RECT image_rect = image_rect_f.GetOutterRect(); - int dest_width = image_rect.Width(); - int dest_height = image_rect.Height(); - if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || - (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { - if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return FALSE; - } - CFX_DIBSource* pDib = m_pDIBSource; - if (m_pDIBSource->HasAlpha() && - !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && - !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { - m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); - if (!m_pCloneConvert) { - m_Result = FALSE; - return FALSE; - } - pDib = m_pCloneConvert; - } - 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); - return TRUE; - } - if (m_ImageMatrix.a < 0) { - dest_width = -dest_width; - } - 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; - if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { - if (m_pDevice->StretchDIBits(m_pDIBSource, dest_left, dest_top, dest_width, - dest_height, m_Flags, NULL, m_BlendType)) { - return FALSE; - } - } - if (m_pDIBSource->IsAlphaMask()) { - if (m_BitmapAlpha != 255) { - m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); - } - if (m_pDevice->StretchBitMask(m_pDIBSource, dest_left, dest_top, dest_width, - dest_height, m_FillArgb, m_Flags)) { - return FALSE; - } - } - if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return TRUE; - } - FX_RECT clip_box = m_pDevice->GetClipBox(); - FX_RECT dest_rect = clip_box; - dest_rect.Intersect(image_rect); - 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); - if (pStretched) { - CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb, - m_BitmapAlpha, m_BlendType, FALSE); - delete pStretched; - pStretched = NULL; - } - return FALSE; -} -FX_BOOL CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { - if (m_Status == 2) { - if (m_pTransformer->Continue(pPause)) { - return TRUE; - } - CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); - if (pBitmap == NULL) { - return FALSE; - } - if (pBitmap->IsAlphaMask()) { - 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); - } else { - if (m_BitmapAlpha != 255) { - pBitmap->MultiplyAlpha(m_BitmapAlpha); - } - m_Result = m_pDevice->SetDIBits(pBitmap, m_pTransformer->m_ResultLeft, - m_pTransformer->m_ResultTop, m_BlendType); - } - delete pBitmap; - return FALSE; - } else if (m_Status == 3) { - return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); - } - return FALSE; -} -void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency) { - if (pDIBitmap == NULL) { - 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) { - pDIBitmap->MultiplyAlpha(bitmap_alpha); - } - if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { - return; - } - } else { - FX_DWORD fill_argb = (mask_argb); - if (bitmap_alpha < 255) { - ((uint8_t*)&fill_argb)[3] = - ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; - } - if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { - return; - } - } - } - FX_BOOL bBackAlphaRequired = blend_mode && bIsolated; - FX_BOOL bGetBackGround = - ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || - (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && - (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); - if (bGetBackGround) { - if (bIsolated || !bGroup) { - if (pDIBitmap->IsAlphaMask()) { - return; - } - m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode); - } else { - FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), - top + pDIBitmap->GetHeight()); - rect.Intersect(m_pDevice->GetClipBox()); - CFX_DIBitmap* pClone = NULL; - FX_BOOL bClone = FALSE; - if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { - bClone = TRUE; - pClone = m_pDevice->GetBackDrop()->Clone(&rect); - CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); - pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pForeBitmap, rect.left, rect.top); - left = left >= 0 ? 0 : left; - top = top >= 0 ? 0 : top; - if (!pDIBitmap->IsAlphaMask()) - pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pDIBitmap, left, top, blend_mode); - else - pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pDIBitmap, mask_argb, left, top, blend_mode); - } else { - pClone = pDIBitmap; - } - if (m_pDevice->GetBackDrop()) { - m_pDevice->SetDIBits(pClone, rect.left, rect.top); - } else { - if (pDIBitmap->IsAlphaMask()) { - return; - } - m_pDevice->SetDIBits(pDIBitmap, rect.left, rect.top, blend_mode); - } - if (bClone) { - delete pClone; - } - } - return; - } - if (pDIBitmap->HasAlpha() && - !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { - CFX_DIBitmap* pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb); - if (!pCloneConvert) { - return; - } - CXFA_ImageRenderer imageRender; - FX_BOOL bRet = imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb, - m_BitmapAlpha, &m_ImageMatrix, m_Flags); - while (bRet) { - bRet = imageRender.Continue(NULL); - } - delete pCloneConvert; - return; - } -} -void XFA_DrawImage(CFX_Graphics* pGS, - const CFX_RectF& rtImage, - CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, - int32_t iAspect, - int32_t iImageXDpi, - int32_t iImageYDpi, - int32_t iHorzAlign, - int32_t iVertAlign) { - if (rtImage.IsEmpty()) { - return; - } - if (!pDIBitmap || !pDIBitmap->GetBuffer()) { - return; - } - FX_FLOAT fWidth = - XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - FX_FLOAT fHeight = - XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); - CFX_RectF rtFit; - rtFit.Set(rtImage.left, rtImage.top, fWidth, fHeight); - switch (iAspect) { - case XFA_ATTRIBUTEENUM_Fit: { - FX_FLOAT f1 = rtImage.height / rtFit.height; - FX_FLOAT f2 = rtImage.width / rtFit.width; - f1 = std::min(f1, f2); - rtFit.height = rtFit.height * f1; - rtFit.width = rtFit.width * f1; - } break; - case XFA_ATTRIBUTEENUM_Actual: - break; - case XFA_ATTRIBUTEENUM_Height: { - FX_FLOAT f1 = rtImage.height / rtFit.height; - rtFit.height = rtImage.height; - rtFit.width = f1 * rtFit.width; - } break; - case XFA_ATTRIBUTEENUM_None: - rtFit.height = rtImage.height; - rtFit.width = rtImage.width; - break; - case XFA_ATTRIBUTEENUM_Width: { - FX_FLOAT f1 = rtImage.width / rtFit.width; - rtFit.width = rtImage.width; - rtFit.height = rtFit.height * f1; - } break; - } - if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { - rtFit.left += (rtImage.width - rtFit.width) / 2; - } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { - rtFit.left = rtImage.right() - rtFit.width; - } - if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { - rtFit.top += (rtImage.height - rtFit.height) / 2; - } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { - rtFit.top = rtImage.bottom() - rtImage.height; - } - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - pRenderDevice->SaveState(); - CFX_PathData path; - path.AppendRect(rtImage.left, rtImage.bottom(), rtImage.right(), rtImage.top); - pRenderDevice->SetClip_PathFill(&path, pMatrix, FXFILL_WINDING); - CFX_Matrix mtImage(1, 0, 0, -1, 0, 1); - mtImage.Concat(rtFit.width, 0, 0, rtFit.height, rtFit.left, rtFit.top); - mtImage.Concat(*pMatrix); - CXFA_ImageRenderer imageRender; - FX_BOOL bRet = imageRender.Start(pRenderDevice, pDIBitmap, 0, 255, &mtImage, - FXDIB_INTERPOL); - while (bRet) { - bRet = imageRender.Continue(NULL); - } - pRenderDevice->RestoreState(); -} - -static const uint8_t g_inv_base64[128] = { - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, - 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, - 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 255, 255, 255, 255, 255, -}; - -static uint8_t* XFA_RemoveBase64Whitespace(const uint8_t* pStr, int32_t iLen) { - uint8_t* pCP; - int32_t i = 0, j = 0; - if (iLen == 0) { - iLen = FXSYS_strlen((FX_CHAR*)pStr); - } - pCP = FX_Alloc(uint8_t, iLen + 1); - for (; i < iLen; i++) { - if ((pStr[i] & 128) == 0) { - if (g_inv_base64[pStr[i]] != 0xFF || pStr[i] == '=') { - pCP[j++] = pStr[i]; - } - } - } - pCP[j] = '\0'; - return pCP; -} -static int32_t XFA_Base64Decode(const FX_CHAR* pStr, uint8_t* pOutBuffer) { - if (pStr == NULL) { - return 0; - } - uint8_t* pBuffer = - XFA_RemoveBase64Whitespace((uint8_t*)pStr, FXSYS_strlen((FX_CHAR*)pStr)); - if (pBuffer == NULL) { - return 0; - } - int32_t iLen = FXSYS_strlen((FX_CHAR*)pBuffer); - int32_t i = 0, j = 0; - FX_DWORD dwLimb = 0; - for (; i + 3 < iLen; i += 4) { - if (pBuffer[i] == '=' || pBuffer[i + 1] == '=' || pBuffer[i + 2] == '=' || - pBuffer[i + 3] == '=') { - if (pBuffer[i] == '=' || pBuffer[i + 1] == '=') { - break; - } - if (pBuffer[i + 2] == '=') { - dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 6) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 1]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 4) & 0xFF; - j++; - } else { - dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 12) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 1]] << 6) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 2]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 10) & 0xFF; - pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 2) & 0xFF; - j += 2; - } - } else { - dwLimb = ((FX_DWORD)g_inv_base64[pBuffer[i]] << 18) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 1]] << 12) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 2]] << 6) | - ((FX_DWORD)g_inv_base64[pBuffer[i + 3]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 16) & 0xff; - pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 8) & 0xff; - pOutBuffer[j + 2] = (uint8_t)(dwLimb)&0xff; - j += 3; - } - } - FX_Free(pBuffer); - return j; -} -static FX_CHAR g_base64_chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len) { - FX_CHAR* out = NULL; - int i, j; - FX_DWORD limb; - out = FX_Alloc(FX_CHAR, ((buf_len * 8 + 5) / 6) + 5); - for (i = 0, j = 0, limb = 0; i + 2 < buf_len; i += 3, j += 4) { - limb = ((FX_DWORD)buf[i] << 16) | ((FX_DWORD)buf[i + 1] << 8) | - ((FX_DWORD)buf[i + 2]); - out[j] = g_base64_chars[(limb >> 18) & 63]; - out[j + 1] = g_base64_chars[(limb >> 12) & 63]; - out[j + 2] = g_base64_chars[(limb >> 6) & 63]; - out[j + 3] = g_base64_chars[(limb)&63]; - } - switch (buf_len - i) { - case 0: - break; - case 1: - limb = ((FX_DWORD)buf[i]); - out[j++] = g_base64_chars[(limb >> 2) & 63]; - out[j++] = g_base64_chars[(limb << 4) & 63]; - out[j++] = '='; - out[j++] = '='; - break; - case 2: - limb = ((FX_DWORD)buf[i] << 8) | ((FX_DWORD)buf[i + 1]); - out[j++] = g_base64_chars[(limb >> 10) & 63]; - out[j++] = g_base64_chars[(limb >> 4) & 63]; - out[j++] = g_base64_chars[(limb << 2) & 63]; - out[j++] = '='; - break; - default: - break; - } - out[j] = '\0'; - return out; -} -FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType) { - CFX_WideString wsContentType(wsType); - wsContentType.MakeLower(); - if (wsContentType == FX_WSTRC(L"image/jpg")) { - return FXCODEC_IMAGE_JPG; - } - if (wsContentType == FX_WSTRC(L"image/png")) { - return FXCODEC_IMAGE_PNG; - } - if (wsContentType == FX_WSTRC(L"image/gif")) { - return FXCODEC_IMAGE_GIF; - } - if (wsContentType == FX_WSTRC(L"image/bmp")) { - return FXCODEC_IMAGE_BMP; - } - if (wsContentType == FX_WSTRC(L"image/tif")) { - return FXCODEC_IMAGE_TIF; - } - return FXCODEC_IMAGE_UNKNOWN; -} -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - FX_BOOL& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - CFX_WideString wsHref; - pImage->GetHref(wsHref); - CFX_WideString wsImage; - pImage->GetContent(wsImage); - if (wsHref.IsEmpty() && wsImage.IsEmpty()) { - return NULL; - } - CFX_WideString wsContentType; - pImage->GetContentType(wsContentType); - FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); - CFX_ByteString bsContent; - uint8_t* pImageBuffer = NULL; - IFX_FileRead* pImageFileRead = NULL; - if (wsImage.GetLength() > 0) { - XFA_ATTRIBUTEENUM iEncoding = - (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); - if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { - 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); - 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()); - } - } 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, iImageXDpi, iImageYDpi); - if (pBitmap) { - bNameImage = TRUE; - return pBitmap; - } - } - pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); - } - if (!pImageFileRead) { - FX_Free(pImageBuffer); - return NULL; - } - bNameImage = FALSE; - CFX_DIBitmap* pBitmap = - XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); - FX_Free(pImageBuffer); - pImageFileRead->Release(); - return pBitmap; -} -static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, - int32_t iComponents, - int32_t iBitsPerComponent) { - FXDIB_Format dibFormat = FXDIB_Argb; - switch (type) { - case FXCODEC_IMAGE_BMP: - case FXCODEC_IMAGE_JPG: - case FXCODEC_IMAGE_TIF: { - dibFormat = FXDIB_Rgb32; - int32_t bpp = iComponents * iBitsPerComponent; - if (bpp <= 24) { - dibFormat = FXDIB_Rgb; - } - } break; - case FXCODEC_IMAGE_PNG: - default: - break; - } - return dibFormat; -} -CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) { - return NULL; - } - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) { - return NULL; - } - CFX_DIBAttribute dibAttr; - CFX_DIBitmap* pBitmap = NULL; - ICodec_ProgressiveDecoder* pProgressiveDecoder = - pCodecMgr->CreateProgressiveDecoder(); - pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr); - switch (dibAttr.m_wDPIUnit) { - case FXCODEC_RESUNIT_CENTIMETER: - dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI * 2.54f); - dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI * 2.54f); - break; - case FXCODEC_RESUNIT_METER: - dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI / (FX_FLOAT)100 * 2.54f); - dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI / (FX_FLOAT)100 * 2.54f); - break; - default: - break; - } - iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96); - iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96); - if (pProgressiveDecoder->GetWidth() > 0 && - pProgressiveDecoder->GetHeight() > 0) { - type = pProgressiveDecoder->GetType(); - int32_t iComponents = pProgressiveDecoder->GetNumComponents(); - int32_t iBpc = pProgressiveDecoder->GetBPC(); - FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); - pBitmap = new CFX_DIBitmap(); - pBitmap->Create(pProgressiveDecoder->GetWidth(), - pProgressiveDecoder->GetHeight(), dibFormat); - pBitmap->Clear(0xffffffff); - int32_t nFrames; - if ((pProgressiveDecoder->GetFrames(nFrames) == - FXCODEC_STATUS_DECODE_READY) && - (nFrames > 0)) { - pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), - pBitmap->GetHeight()); - pProgressiveDecoder->ContinueDecode(); - } - } - delete pProgressiveDecoder; - return pBitmap; -} -void XFA_RectWidthoutMargin(CFX_RectF& rt, const CXFA_Margin& mg, FX_BOOL bUI) { - if (!mg) { - return; - } - FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; - mg.GetLeftInset(fLeftInset); - mg.GetTopInset(fTopInset); - mg.GetRightInset(fRightInset); - mg.GetBottomInset(fBottomInset); - rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); -} -CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) { - XFA_ELEMENT iType = pLayoutItem->GetFormNode()->GetClassID(); - if (XFA_IsCreateWidget(iType)) { - return static_cast<CXFA_FFWidget*>(pLayoutItem); - } - return nullptr; -} -FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType) { - return iType == XFA_ELEMENT_Field || iType == XFA_ELEMENT_Draw || - iType == XFA_ELEMENT_Subform || iType == XFA_ELEMENT_ExclGroup; -} -static void XFA_BOX_GetPath_Arc(CXFA_Box box, - CFX_RectF rtDraw, - CFX_Path& fillPath, - FX_DWORD dwFlags) { - FX_FLOAT a, b; - a = rtDraw.width / 2.0f; - b = rtDraw.height / 2.0f; - if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - a = b = std::min(a, b); - } - CFX_PointF center = rtDraw.Center(); - rtDraw.left = center.x - a; - rtDraw.top = center.y - b; - rtDraw.width = a + a; - rtDraw.height = b + b; - FX_FLOAT startAngle = 0, sweepAngle = 360; - FX_BOOL bStart = box.GetStartAngle(startAngle); - FX_BOOL bEnd = box.GetSweepAngle(sweepAngle); - if (!bStart && !bEnd) { - fillPath.AddEllipse(rtDraw); - return; - } - startAngle = -startAngle * FX_PI / 180.0f; - sweepAngle = -sweepAngle * FX_PI / 180.0f; - fillPath.AddArc(rtDraw.left, rtDraw.top, rtDraw.width, rtDraw.height, - startAngle, sweepAngle); -} -static void XFA_BOX_GetPath(CXFA_Box box, - const CXFA_StrokeArray& strokes, - CFX_RectF rtWidget, - CFX_Path& path, - int32_t nIndex, - FX_BOOL bStart, - FX_BOOL bCorner) { - FXSYS_assert(nIndex >= 0 && nIndex < 8); - FX_BOOL bInverted, bRound; - FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX, - offsetEX, offsetEY; - CFX_PointF cpStart, cp, cp1, cp2; - CFX_RectF rtRadius; - int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; - CXFA_Corner corner1(strokes[n].GetNode()); - CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); - fRadius1 = bCorner ? corner1.GetRadius() : 0; - fRadius2 = bCorner ? corner2.GetRadius() : 0; - bInverted = corner1.IsInverted(); - offsetY = 0.0f; - offsetX = 0.0f; - bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; - FX_FLOAT halfAfter = 0.0f; - FX_FLOAT halfBefore = 0.0f; - CXFA_Stroke stroke = strokes[nIndex]; - if (stroke.IsCorner()) { - CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; - CXFA_Stroke edgeAfter = strokes[nIndex + 1]; - if (stroke.IsInverted()) { - if (!stroke.SameStyles(edgeBefore)) { - halfBefore = edgeBefore.GetThickness() / 2; - } - if (!stroke.SameStyles(edgeAfter)) { - halfAfter = edgeAfter.GetThickness() / 2; - } - } - } else { - CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8]; - CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8]; - if (!bRound && !bInverted) { - { halfBefore = edgeBefore.GetThickness() / 2; } - { halfAfter = edgeAfter.GetThickness() / 2; } - } - } - offsetEX = 0.0f; - offsetEY = 0.0f; - if (bRound) { - sy = FX_PI / 2; - } - switch (nIndex) { - case 0: - case 1: - cp1 = rtWidget.TopLeft(); - cp2 = rtWidget.TopRight(); - if (nIndex == 0) { - cpStart.x = cp1.x - halfBefore; - cpStart.y = cp1.y + fRadius1, offsetY = -halfAfter; - } else { - cpStart.x = cp1.x + fRadius1 - halfBefore, cpStart.y = cp1.y, - offsetEX = halfAfter; - } - vx = 1, vy = 1; - nx = -1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI / 2 : FX_PI; - } else { - sx = 1, sy = 0; - } - break; - case 2: - case 3: - cp1 = rtWidget.TopRight(); - cp2 = rtWidget.BottomRight(); - if (nIndex == 2) { - cpStart.x = cp1.x - fRadius1, cpStart.y = cp1.y - halfBefore, - offsetX = halfAfter; - } else { - cpStart.x = cp1.x, cpStart.y = cp1.y + fRadius1 - halfBefore, - offsetEY = halfAfter; - } - vx = -1, vy = 1; - nx = 0, ny = -1; - if (bRound) { - sx = bInverted ? FX_PI : FX_PI * 3 / 2; - } else { - sx = 0, sy = 1; - } - break; - case 4: - case 5: - cp1 = rtWidget.BottomRight(); - cp2 = rtWidget.BottomLeft(); - if (nIndex == 4) { - cpStart.x = cp1.x + halfBefore, cpStart.y = cp1.y - fRadius1, - offsetY = halfAfter; - } else { - cpStart.x = cp1.x - fRadius1 + halfBefore, cpStart.y = cp1.y, - offsetEX = -halfAfter; - } - vx = -1, vy = -1; - nx = 1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI * 3 / 2 : 0; - } else { - sx = -1, sy = 0; - } - break; - case 6: - case 7: - cp1 = rtWidget.BottomLeft(); - cp2 = rtWidget.TopLeft(); - if (nIndex == 6) { - cpStart.x = cp1.x + fRadius1, cpStart.y = cp1.y + halfBefore, - offsetX = -halfAfter; - } else { - cpStart.x = cp1.x, cpStart.y = cp1.y - fRadius1 + halfBefore, - offsetEY = -halfAfter; - } - vx = 1, vy = -1; - nx = 0, ny = 1; - if (bRound) { - sx = bInverted ? 0 : FX_PI / 2; - } else { - sx = 0, sy = -1; - } - break; - } - if (bStart) { - path.MoveTo(cpStart.x, cpStart.y); - } - if (nIndex & 1) { - path.LineTo(cp2.x + fRadius2 * nx + offsetEX, - cp2.y + fRadius2 * ny + offsetEY); - return; - } - if (bRound) { - if (fRadius1 < 0) { - sx -= FX_PI; - } - if (bInverted) { - sy *= -1; - } - rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2, - fRadius1 * 2 * vx - offsetX * 2, - fRadius1 * 2 * vy - offsetY * 2); - rtRadius.Normalize(); - if (bInverted) { - rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - } - path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx, - sy); - } else { - if (bInverted) { - cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; - } else { - cp = cp1; - } - path.LineTo(cp.x, cp.y); - path.LineTo(cp1.x + fRadius1 * sx + offsetX, - cp1.y + fRadius1 * sy + offsetY); - } -} -static void XFA_BOX_GetFillPath(CXFA_Box box, - const CXFA_StrokeArray& strokes, - CFX_RectF rtWidget, - CFX_Path& fillPath, - FX_WORD dwFlags) { - if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - CXFA_Edge edge = box.GetEdge(0); - FX_FLOAT fThickness = edge.GetThickness(); - if (fThickness < 0) { - fThickness = 0; - } - FX_FLOAT fHalf = fThickness / 2; - int32_t iHand = box.GetHand(); - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.Inflate(fHalf, fHalf); - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.Deflate(fHalf, fHalf); - } - XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags); - return; - } - FX_BOOL bSameStyles = TRUE; - int32_t i; - CXFA_Stroke stroke1 = strokes[0]; - for (i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { - bSameStyles = FALSE; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - for (i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { - bSameStyles = FALSE; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) { - bSameStyles = FALSE; - } - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { - bSameStyles = FALSE; - } - } - } - if (bSameStyles) { - fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); - return; - } - FX_BOOL bInverted, bRound; - FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny; - CFX_PointF cp, cp1, cp2; - CFX_RectF rtRadius; - for (int32_t i = 0; i < 8; i += 2) { - CXFA_Corner corner1(strokes[i].GetNode()); - CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); - fRadius1 = corner1.GetRadius(); - fRadius2 = corner2.GetRadius(); - bInverted = corner1.IsInverted(); - bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; - if (bRound) { - sy = FX_PI / 2; - } - switch (i) { - case 0: - cp1 = rtWidget.TopLeft(); - cp2 = rtWidget.TopRight(); - vx = 1, vy = 1; - nx = -1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI / 2 : FX_PI; - } else { - sx = 1, sy = 0; - } - break; - case 2: - cp1 = rtWidget.TopRight(); - cp2 = rtWidget.BottomRight(); - vx = -1, vy = 1; - nx = 0, ny = -1; - if (bRound) { - sx = bInverted ? FX_PI : FX_PI * 3 / 2; - } else { - sx = 0, sy = 1; - } - break; - case 4: - cp1 = rtWidget.BottomRight(); - cp2 = rtWidget.BottomLeft(); - vx = -1, vy = -1; - nx = 1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI * 3 / 2 : 0; - } else { - sx = -1, sy = 0; - } - break; - case 6: - cp1 = rtWidget.BottomLeft(); - cp2 = rtWidget.TopLeft(); - vx = 1, vy = -1; - nx = 0, ny = 1; - if (bRound) { - sx = bInverted ? 0 : FX_PI / 2; - } else { - sx = 0, sy = -1; - } - break; - } - if (i == 0) { - fillPath.MoveTo(cp1.x, cp1.y + fRadius1); - } - if (bRound) { - if (fRadius1 < 0) { - sx -= FX_PI; - } - if (bInverted) { - sy *= -1; - } - rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); - rtRadius.Normalize(); - if (bInverted) { - rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - } - fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, - rtRadius.height, sx, sy); - } else { - if (bInverted) { - cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; - } else { - cp = cp1; - } - fillPath.LineTo(cp.x, cp.y); - fillPath.LineTo(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy); - } - fillPath.LineTo(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny); - } -} -static void XFA_BOX_Fill_Radial(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetRadial(crEnd); - CFX_Shading shading; - if (iType != XFA_ATTRIBUTEENUM_ToEdge) { - FX_ARGB temp = crEnd; - crEnd = crStart; - crStart = temp; - } - shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, - FXSYS_sqrt(rtFill.Width() * rtFill.Width() + - rtFill.Height() * rtFill.Height()) / - 2, - TRUE, TRUE, crStart, crEnd); - CFX_Color cr(&shading); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill_Pattern(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetPattern(crEnd); - int32_t iHatch = FX_HATCHSTYLE_Cross; - switch (iType) { - case XFA_ATTRIBUTEENUM_CrossDiagonal: - iHatch = FX_HATCHSTYLE_DiagonalCross; - break; - case XFA_ATTRIBUTEENUM_DiagonalLeft: - iHatch = FX_HATCHSTYLE_ForwardDiagonal; - break; - case XFA_ATTRIBUTEENUM_DiagonalRight: - iHatch = FX_HATCHSTYLE_BackwardDiagonal; - break; - case XFA_ATTRIBUTEENUM_Horizontal: - iHatch = FX_HATCHSTYLE_Horizontal; - break; - case XFA_ATTRIBUTEENUM_Vertical: - iHatch = FX_HATCHSTYLE_Vertical; - break; - default: - break; - } - CFX_Pattern pattern; - pattern.Create(iHatch, crEnd, crStart); - CFX_Color cr(&pattern); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill_Linear(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart = fill.GetColor(); - FX_ARGB crEnd; - int32_t iType = fill.GetLinear(crEnd); - CFX_PointF ptStart; - CFX_PointF ptEnd; - switch (iType) { - case XFA_ATTRIBUTEENUM_ToRight: - ptStart = CFX_PointF(rtFill.left, rtFill.top); - ptEnd = CFX_PointF(rtFill.right(), rtFill.top); - break; - case XFA_ATTRIBUTEENUM_ToBottom: - ptStart = CFX_PointF(rtFill.left, rtFill.top); - ptEnd = CFX_PointF(rtFill.left, rtFill.bottom()); - break; - case XFA_ATTRIBUTEENUM_ToLeft: - ptStart = CFX_PointF(rtFill.right(), rtFill.top); - ptEnd = CFX_PointF(rtFill.left, rtFill.top); - break; - case XFA_ATTRIBUTEENUM_ToTop: - ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); - ptEnd = CFX_PointF(rtFill.left, rtFill.top); - break; - default: - break; - } - CFX_Shading shading; - shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); - CFX_Color cr(&shading); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill(CXFA_Box box, - const CXFA_StrokeArray& strokes, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags) { - CXFA_Fill fill = box.GetFill(); - if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { - return; - } - pGS->SaveGraphState(); - CFX_Path fillPath; - fillPath.Create(); - XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, - (dwFlags & XFA_DRAWBOX_ForceRound) != 0); - fillPath.Close(); - int32_t eType = fill.GetFillType(); - switch (eType) { - case XFA_ELEMENT_Radial: - XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix); - break; - case XFA_ELEMENT_Pattern: - XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix); - break; - case XFA_ELEMENT_Linear: - XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix); - break; - default: { - FX_ARGB cr; - if (eType == XFA_ELEMENT_Stipple) { - int32_t iRate = fill.GetStipple(cr); - if (iRate == 0) { - iRate = 100; - } - int32_t a = 0; - FX_COLORREF rgb; - ArgbDecode(cr, a, rgb); - cr = ArgbEncode(iRate * a / 100, rgb); - } else { - cr = fill.GetColor(); - } - CFX_Color fillColor(cr); - pGS->SetFillColor(&fillColor); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); - } break; - } - pGS->RestoreGraphState(); -} -static void XFA_BOX_StrokePath(CXFA_Stroke stroke, - CFX_Path* pPath, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix) { - if (!stroke || !stroke.IsVisible()) { - return; - } - FX_FLOAT fThickness = stroke.GetThickness(); - if (fThickness < 0.001f) { - return; - } - pGS->SaveGraphState(); - if (stroke.IsCorner() && fThickness > 2 * stroke.GetRadius()) { - fThickness = 2 * stroke.GetRadius(); - } - pGS->SetLineWidth(fThickness, TRUE); - pGS->SetLineCap(CFX_GraphStateData::LineCapButt); - XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(), - XFA_ATTRIBUTEENUM_Butt); - CFX_Color fxColor(stroke.GetColor()); - pGS->SetStrokeColor(&fxColor); - pGS->StrokePath(pPath, pMatrix); - pGS->RestoreGraphState(); -} -static void XFA_BOX_StrokeArc(CXFA_Box box, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags) { - CXFA_Edge edge = box.GetEdge(0); - if (!edge || !edge.IsVisible()) { - return; - } - FX_BOOL bVisible = FALSE; - FX_FLOAT fThickness = 0; - int32_t i3DType = box.Get3DStyle(bVisible, fThickness); - if (i3DType) { - if (bVisible && fThickness >= 0.001f) { - dwFlags |= XFA_DRAWBOX_Lowered3D; - } - } - FX_FLOAT fHalf = edge.GetThickness() / 2; - if (fHalf < 0) { - fHalf = 0; - } - int32_t iHand = box.GetHand(); - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.Inflate(fHalf, fHalf); - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.Deflate(fHalf, fHalf); - } - if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 || - (dwFlags & XFA_DRAWBOX_Lowered3D) == 0) { - if (fHalf < 0.001f) { - return; - } - CFX_Path arcPath; - arcPath.Create(); - XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); - XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); - return; - } - pGS->SaveGraphState(); - pGS->SetLineWidth(fHalf); - FX_FLOAT a, b; - a = rtWidget.width / 2.0f; - b = rtWidget.height / 2.0f; - if (dwFlags & XFA_DRAWBOX_ForceRound) { - a = b = std::min(a, b); - } - CFX_PointF center = rtWidget.Center(); - rtWidget.left = center.x - a; - rtWidget.top = center.y - b; - rtWidget.width = a + a; - rtWidget.height = b + b; - FX_FLOAT startAngle = 0, sweepAngle = 360; - startAngle = startAngle * FX_PI / 180.0f; - sweepAngle = -sweepAngle * FX_PI / 180.0f; - CFX_Path arcPath; - arcPath.Create(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - 3.0f * FX_PI / 4.0f, FX_PI); - CFX_Color cr(0xFF808080); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - -1.0f * FX_PI / 4.0f, FX_PI); - cr.Set(0xFFFFFFFF); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - rtWidget.Deflate(fHalf, fHalf); - arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - 3.0f * FX_PI / 4.0f, FX_PI); - cr.Set(0xFF404040); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - -1.0f * FX_PI / 4.0f, FX_PI); - cr.Set(0xFFC0C0C0); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - pGS->RestoreGraphState(); -} -static void XFA_Draw3DRect(CFX_Graphics* pGraphic, - const CFX_RectF& rt, - FX_FLOAT fLineWidth, - CFX_Matrix* pMatrix, - FX_ARGB argbTopLeft, - FX_ARGB argbBottomRight) { - CFX_Color crLT(argbTopLeft); - pGraphic->SetFillColor(&crLT); - FX_FLOAT fBottom = rt.bottom(); - FX_FLOAT fRight = rt.right(); - CFX_Path pathLT; - pathLT.Create(); - pathLT.MoveTo(rt.left, fBottom); - pathLT.LineTo(rt.left, rt.top); - pathLT.LineTo(fRight, rt.top); - pathLT.LineTo(fRight - fLineWidth, rt.top + fLineWidth); - pathLT.LineTo(rt.left + fLineWidth, rt.top + fLineWidth); - pathLT.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); - pathLT.LineTo(rt.left, fBottom); - pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - CFX_Color crRB(argbBottomRight); - pGraphic->SetFillColor(&crRB); - CFX_Path pathRB; - pathRB.Create(); - pathRB.MoveTo(fRight, rt.top); - pathRB.LineTo(fRight, fBottom); - pathRB.LineTo(rt.left, fBottom); - pathRB.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); - pathRB.LineTo(fRight - fLineWidth, fBottom - fLineWidth); - pathRB.LineTo(fRight - fLineWidth, rt.top + fLineWidth); - pathRB.LineTo(fRight, rt.top); - pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS, - CFX_RectF rt, - FX_FLOAT fThickness, - CFX_Matrix* pMatrix) { - FX_FLOAT fHalfWidth = fThickness / 2.0f; - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - CFX_Color cr(0xFF000000); - pGS->SetFillColor(&cr); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left, rt.top, rt.width, rt.height); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF808080, 0xFFC0C0C0); -} -static void XFA_BOX_Stroke_3DRect_Raised(CFX_Graphics* pGS, - CFX_RectF rt, - FX_FLOAT fThickness, - CFX_Matrix* pMatrix) { - FX_FLOAT fHalfWidth = fThickness / 2.0f; - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - CFX_Color cr(0xFF000000); - pGS->SetFillColor(&cr); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left, rt.top, rt.width, rt.height); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); -} -static void XFA_BOX_Stroke_3DRect_Etched(CFX_Graphics* pGS, - CFX_RectF rt, - FX_FLOAT fThickness, - CFX_Matrix* pMatrix) { - FX_FLOAT fHalfWidth = fThickness / 2.0f; - XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFFFFFFFF); - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); -} -static void XFA_BOX_Stroke_3DRect_Embossed(CFX_Graphics* pGS, - CFX_RectF rt, - FX_FLOAT fThickness, - CFX_Matrix* pMatrix) { - FX_FLOAT fHalfWidth = fThickness / 2.0f; - XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); -} -static void XFA_BOX_Stroke_Rect(CXFA_Box box, - const CXFA_StrokeArray& strokes, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix) { - FX_BOOL bVisible = FALSE; - FX_FLOAT fThickness = 0; - int32_t i3DType = box.Get3DStyle(bVisible, fThickness); - if (i3DType) { - if (!bVisible || fThickness < 0.001f) { - return; - } - switch (i3DType) { - case XFA_ATTRIBUTEENUM_Lowered: - XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Raised: - XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Etched: - XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Embossed: - XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, pMatrix); - break; - } - return; - } - FX_BOOL bClose = FALSE; - FX_BOOL bSameStyles = TRUE; - int32_t i; - CXFA_Stroke stroke1 = strokes[0]; - for (i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { - bSameStyles = FALSE; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - bClose = TRUE; - for (i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { - bSameStyles = FALSE; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) { - bSameStyles = FALSE; - } - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { - bSameStyles = FALSE; - } - } - } - FX_BOOL bStart = TRUE; - CFX_Path path; - path.Create(); - for (i = 0; i < 8; i++) { - CXFA_Stroke stroke1 = strokes[i]; - if ((i % 1) == 0 && stroke1.GetRadius() < 0) { - FX_BOOL bEmpty = path.IsEmpty(); - if (!bEmpty) { - XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); - path.Clear(); - } - bStart = TRUE; - continue; - } - XFA_BOX_GetPath(box, strokes, rtWidget, path, i, bStart, !bSameStyles); - CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; - bStart = !stroke1.SameStyles(stroke2); - if (bStart) { - XFA_BOX_StrokePath(stroke1, &path, pGS, pMatrix); - path.Clear(); - } - } - FX_BOOL bEmpty = path.IsEmpty(); - if (!bEmpty) { - if (bClose) { - path.Close(); - } - XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); - } -} -static void XFA_BOX_Stroke(CXFA_Box box, - const CXFA_StrokeArray& strokes, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags) { - if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); - return; - } - bool bVisible = false; - for (int32_t j = 0; j < 4; j++) { - if (strokes[j * 2 + 1].IsVisible()) { - bVisible = true; - break; - } - } - if (!bVisible) { - return; - } - for (int32_t i = 1; i < 8; i += 2) { - CXFA_Edge edge(strokes[i].GetNode()); - FX_FLOAT fThickness = edge.GetThickness(); - if (fThickness < 0) { - fThickness = 0; - } - FX_FLOAT fHalf = fThickness / 2; - int32_t iHand = box.GetHand(); - switch (i) { - case 1: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.top -= fHalf; - rtWidget.height += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.top += fHalf; - rtWidget.height -= fHalf; - } - break; - case 3: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.width += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.width -= fHalf; - } - break; - case 5: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.height += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.height -= fHalf; - } - break; - case 7: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.left -= fHalf; - rtWidget.width += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.left += fHalf; - rtWidget.width -= fHalf; - } - break; - } - } - XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix); -} -void XFA_DrawBox(CXFA_Box box, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags) { - if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { - return; - } - int32_t iType = box.GetClassID(); - if (iType != XFA_ELEMENT_Arc && iType != XFA_ELEMENT_Border && - iType != XFA_ELEMENT_Rectangle) { - return; - } - CXFA_StrokeArray strokes; - if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { - box.GetStrokes(strokes); - } - XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); - XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); -} diff --git a/xfa/src/fxfa/app/xfa_ffwidget.h b/xfa/src/fxfa/app/xfa_ffwidget.h deleted file mode 100644 index 5ff4295a52..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidget.h +++ /dev/null @@ -1,187 +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_SRC_FXFA_APP_XFA_FFWIDGET_H_ -#define XFA_SRC_FXFA_APP_XFA_FFWIDGET_H_ - -#include <vector> - -#include "core/include/fxcodec/fx_codec_def.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" - -class CXFA_FFPageView; -class CXFA_FFDocView; -class CXFA_FFDoc; -class CXFA_FFApp; - -inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) { - return fPx * 72.0f / fDpi; -} -#define XFA_FLOAT_PERCISION 0.001f -enum XFA_WIDGETITEM { - XFA_WIDGETITEM_Parent, - XFA_WIDGETITEM_FirstChild, - XFA_WIDGETITEM_NextSibling, - XFA_WIDGETITEM_PrevSibling, -}; -class CXFA_CalcData { - public: - CXFA_CalcData() : m_iRefCount(0) {} - ~CXFA_CalcData() { m_Globals.RemoveAll(); } - CFX_PtrArray m_Globals; - int32_t m_iRefCount; -}; -class CXFA_FFWidget : public IXFA_Widget, - public CFX_PrivateData, - public CXFA_ContentLayoutItem { - public: - CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); - virtual ~CXFA_FFWidget(); - IXFA_PageView* GetPageView(); - void SetPageView(IXFA_PageView* pPageView); - void GetWidgetRect(CFX_RectF& rtWidget); - CFX_RectF ReCacheWidgetRect(); - FX_DWORD GetStatus(); - void ModifyStatus(FX_DWORD dwAdded, FX_DWORD dwRemoved); - virtual FX_BOOL GetBBox(CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus = FALSE); - CXFA_WidgetAcc* GetDataAcc(); - FX_BOOL GetToolTip(CFX_WideString& wsToolTip); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_DWORD dwStatus = 0, - int32_t iRotate = 0); - - virtual FX_BOOL IsLoaded(); - virtual FX_BOOL LoadWidget(); - virtual void UnloadWidget(); - virtual FX_BOOL PerformLayout(); - virtual FX_BOOL UpdateFWLData(); - virtual void UpdateWidgetProperty(); - virtual FX_BOOL OnMouseEnter(); - virtual FX_BOOL OnMouseExit(); - virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnMouseWheel(FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy); - - virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); - virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); - virtual FX_BOOL OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags); - virtual FX_BOOL OnChar(FX_DWORD dwChar, FX_DWORD dwFlags); - virtual FX_DWORD 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; } - virtual FX_BOOL Undo() { return FALSE; } - virtual FX_BOOL Redo() { return FALSE; } - virtual FX_BOOL CanCopy() { return FALSE; } - virtual FX_BOOL CanCut() { return FALSE; } - virtual FX_BOOL CanPaste() { return FALSE; } - virtual FX_BOOL CanSelectAll() { return FALSE; } - virtual FX_BOOL CanDelete() { return CanCut(); } - virtual FX_BOOL CanDeSelect() { return CanCopy(); } - virtual FX_BOOL Copy(CFX_WideString& wsCopy) { return FALSE; } - virtual FX_BOOL Cut(CFX_WideString& wsCut) { return FALSE; } - virtual FX_BOOL Paste(const CFX_WideString& wsPaste) { return FALSE; } - virtual FX_BOOL SelectAll() { return FALSE; } - virtual FX_BOOL Delete() { return FALSE; } - virtual FX_BOOL DeSelect() { return FALSE; } - virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) { - return FALSE; - } - virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return FALSE; - } - CXFA_FFDocView* GetDocView(); - void SetDocView(CXFA_FFDocView* pDocView) { m_pDocView = pDocView; } - CXFA_FFDoc* GetDoc(); - CXFA_FFApp* GetApp(); - IXFA_AppProvider* GetAppProvider(); - void InvalidateWidget(const CFX_RectF* pRect = NULL); - void AddInvalidateRect(const CFX_RectF* pRect = NULL); - FX_BOOL GetCaptionText(CFX_WideString& wsCap); - FX_BOOL IsFocused(); - void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy); - void GetRotateMatrix(CFX_Matrix& mt); - FX_BOOL IsLayoutRectEmpty(); - CXFA_FFWidget* GetParent(); - FX_BOOL IsAncestorOf(CXFA_FFWidget* pWidget); - - protected: - virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); - void DrawBorder(CFX_Graphics* pGS, - CXFA_Box box, - const CFX_RectF& rtBorder, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags = 0); - void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); - void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); - void GetRectWithoutRotate(CFX_RectF& rtWidget); - FX_BOOL IsMatchVisibleStatus(FX_DWORD dwStatus); - - void EventKillFocus(); - FX_BOOL IsButtonDown(); - void SetButtonDown(FX_BOOL bSet); - CXFA_FFDocView* m_pDocView; - CXFA_FFPageView* m_pPageView; - CXFA_WidgetAcc* m_pDataAcc; - CFX_RectF m_rtWidget; -}; -int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, - int32_t iStrokeType, - int32_t iCapType); -CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); -void XFA_DrawImage(CFX_Graphics* pGS, - const CFX_RectF& rtImage, - CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, - int32_t iAspect, - int32_t iImageXDpi, - int32_t iImageYDpi, - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - FX_BOOL& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi); -CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi); -FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType); -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 -#define XFA_DRAWBOX_Lowered3D 2 -void XFA_DrawBox(CXFA_Box box, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - FX_DWORD dwFlags = 0); - -#endif // XFA_SRC_FXFA_APP_XFA_FFWIDGET_H_ diff --git a/xfa/src/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/src/fxfa/app/xfa_ffwidgetacc.cpp deleted file mode 100644 index 10aaad0dc5..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidgetacc.cpp +++ /dev/null @@ -1,1714 +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/src/fxfa/app/xfa_ffwidgetacc.h" - -#include <algorithm> - -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/src/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffpageview.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fontmgr.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/app/xfa_textlayout.h" -#include "xfa/src/fxfa/parser/xfa_localevalue.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -static void XFA_FFDeleteCalcData(void* pData) { - if (pData) { - delete ((CXFA_CalcData*)pData); - } -} -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = { - XFA_FFDeleteCalcData, NULL}; -class CXFA_WidgetLayoutData { - public: - CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {} - virtual ~CXFA_WidgetLayoutData() {} - virtual void Release() { delete this; } - FX_FLOAT m_fWidgetHeight; -}; -class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { - public: - CXFA_TextLayoutData() : m_pTextLayout(NULL), m_pTextProvider(NULL) {} - ~CXFA_TextLayoutData() { - if (m_pTextLayout) { - delete m_pTextLayout; - } - m_pTextLayout = NULL; - if (m_pTextProvider) { - delete m_pTextProvider; - } - m_pTextProvider = NULL; - } - void LoadText(CXFA_WidgetAcc* pAcc) { - if (m_pTextLayout) - return; - - m_pTextProvider = new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Text); - m_pTextLayout = new CXFA_TextLayout(m_pTextProvider); - } - CXFA_TextLayout* m_pTextLayout; - CXFA_TextProvider* m_pTextProvider; -}; -class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { - public: - CXFA_ImageLayoutData() - : m_pDIBitmap(NULL), - m_bNamedImage(FALSE), - m_iImageXDpi(0), - m_iImageYDpi(0) {} - - ~CXFA_ImageLayoutData() { - if (m_pDIBitmap && !m_bNamedImage) { - delete m_pDIBitmap; - } - m_pDIBitmap = NULL; - } - - FX_BOOL LoadImageData(CXFA_WidgetAcc* pAcc) { - if (m_pDIBitmap) { - return TRUE; - } - CXFA_Value value = pAcc->GetFormValue(); - if (!value) { - return FALSE; - } - CXFA_Image imageObj = value.GetImage(); - if (!imageObj) { - return FALSE; - } - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, - m_iImageXDpi, m_iImageYDpi)); - return m_pDIBitmap != NULL; - } - - CFX_DIBitmap* m_pDIBitmap; - FX_BOOL m_bNamedImage; - 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; - } - } - FX_BOOL LoadCaption(CXFA_WidgetAcc* pAcc) { - 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; - } - CXFA_TextLayout* m_pCapTextLayout; - CXFA_TextProvider* m_pCapTextProvider; - IFDE_TextOut* m_pTextOut; - CFX_FloatArray* m_pFieldSplitArray; -}; -class CXFA_TextEditData : public CXFA_FieldLayoutData { - public: -}; -class CXFA_ImageEditData : public CXFA_FieldLayoutData { - public: - CXFA_ImageEditData() - : m_pDIBitmap(NULL), - m_bNamedImage(FALSE), - m_iImageXDpi(0), - m_iImageYDpi(0) {} - - ~CXFA_ImageEditData() { - if (m_pDIBitmap && !m_bNamedImage) { - delete m_pDIBitmap; - } - m_pDIBitmap = NULL; - } - FX_BOOL LoadImageData(CXFA_WidgetAcc* pAcc) { - if (m_pDIBitmap) { - return TRUE; - } - CXFA_Value value = pAcc->GetFormValue(); - if (!value) { - return FALSE; - } - CXFA_Image imageObj = value.GetImage(); - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, - m_iImageXDpi, m_iImageYDpi)); - return m_pDIBitmap != NULL; - } - CFX_DIBitmap* m_pDIBitmap; - FX_BOOL m_bNamedImage; - int32_t m_iImageXDpi; - int32_t m_iImageYDpi; -}; -CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode) - : CXFA_WidgetData(pNode), - m_pDocView(pDocView), - m_pLayoutData(NULL), - m_nRecursionDepth(0) {} -CXFA_WidgetAcc::~CXFA_WidgetAcc() { - if (m_pLayoutData) { - m_pLayoutData->Release(); - m_pLayoutData = NULL; - } -} -FX_BOOL CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) { - if (iNameType == 0) { - m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); - return !wsName.IsEmpty(); - } - 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())) { - wsName.Delete(0, wsPre.GetLength()); - } - } - return TRUE; -} -CXFA_Node* CXFA_WidgetAcc::GetDatasets() { - return m_pNode->GetBindData(); -} -FX_BOOL CXFA_WidgetAcc::ProcessValueChanged() { - m_pDocView->AddValidateWidget(this); - m_pDocView->AddCalculateWidgetAcc(this); - m_pDocView->RunCalculateWidgets(); - m_pDocView->RunValidate(); - return TRUE; -} -void CXFA_WidgetAcc::ResetData() { - CFX_WideString wsValue; - XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); - switch (eUIType) { - case XFA_ELEMENT_ImageEdit: { - CXFA_Value imageValue = GetDefaultValue(); - CXFA_Image image = imageValue.GetImage(); - CFX_WideString wsContentType, wsHref; - if (image) { - image.GetContent(wsValue); - image.GetContentType(wsContentType); - image.GetHref(wsHref); - } - SetImageEdit(wsContentType, wsHref, wsValue); - } break; - case XFA_ELEMENT_ExclGroup: { - CXFA_Node* pNextChild = m_pNode->GetNodeItem( - XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); - while (pNextChild) { - CXFA_Node* pChild = pNextChild; - CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); - if (!pAcc) { - continue; - } - CXFA_Value defValue(NULL); - if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) { - defValue.GetChildValueContent(wsValue); - SetValue(wsValue, XFA_VALUEPICTURE_Raw); - pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); - } else { - CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); - if (!pItems) { - continue; - } - CFX_WideString itemText; - if (pItems->CountChildren(XFA_ELEMENT_UNKNOWN) > 1) { - itemText = pItems->GetChild(1, XFA_ELEMENT_UNKNOWN)->GetContent(); - } - pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw); - } - pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_OBJECTTYPE_ContainerNode); - } - } break; - case XFA_ELEMENT_ChoiceList: - ClearAllSelections(); - default: - if (CXFA_Value defValue = GetDefaultValue()) { - defValue.GetChildValueContent(wsValue); - } - SetValue(wsValue, XFA_VALUEPICTURE_Raw); - break; - } -} -void CXFA_WidgetAcc::SetImageEdit(const CFX_WideStringC& wsContentType, - const CFX_WideStringC& wsHref, - const CFX_WideStringC& wsData) { - CXFA_Image image = GetFormValue().GetImage(); - if (image) { - image.SetContentType(wsContentType); - image.SetHref(wsHref); - } - CFX_WideString wsFormatValue(wsData); - GetFormatDataValue(wsData, wsFormatValue); - m_pNode->SetContent(wsData, wsFormatValue, TRUE); - CXFA_Node* pBind = GetDatasets(); - if (!pBind) { - image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); - return; - } - pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); - CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pHrefNode) { - pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); - } else { - IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); - FXSYS_assert(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode)->SetString(FX_WSTRC(L"href"), wsHref); - } -} - -CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { - CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) { - return NULL; - } - return (CXFA_WidgetAcc*)pExcl->GetWidgetData(); -} -CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { - return m_pDocView; -} -CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { - return (CXFA_FFDoc*)m_pDocView->GetDoc(); -} -CXFA_FFApp* CXFA_WidgetAcc::GetApp() { - return GetDoc()->GetApp(); -} -IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { - return GetApp()->GetAppProvider(); -} -int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, - CXFA_EventParam* pEventParam) { - if (GetClassID() == XFA_ELEMENT_Draw) { - return XFA_EVENTERROR_NotExist; - } - int32_t iRet = XFA_EVENTERROR_NotExist; - CXFA_NodeArray eventArray; - int32_t iCounts = - GetEventByActivity(iActivity, eventArray, pEventParam->m_bIsFormReady); - for (int32_t i = 0; i < iCounts; i++) { - CXFA_Event event(eventArray[i]); - int32_t result = ProcessEvent(event, pEventParam); - if (i == 0) { - iRet = result; - } else if (result == XFA_EVENTERROR_Sucess) { - iRet = result; - } - } - return iRet; -} -int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event, - CXFA_EventParam* pEventParam) { - if (!event) { - return XFA_EVENTERROR_NotExist; - } - switch (event.GetEventType()) { - case XFA_ELEMENT_Execute: - break; - case XFA_ELEMENT_Script: { - CXFA_Script script = event.GetScript(); - return ExecuteScript(script, pEventParam); - } break; - case XFA_ELEMENT_SignData: - break; - case XFA_ELEMENT_Submit: { - CXFA_Submit submit = event.GetSubmit(); - return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); - } - default: - break; - } - return XFA_EVENTERROR_NotExist; -} -int32_t CXFA_WidgetAcc::ProcessCalculate() { - if (GetClassID() == XFA_ELEMENT_Draw) { - return XFA_EVENTERROR_NotExist; - } - CXFA_Calculate calc = GetCalculate(); - if (!calc) { - return XFA_EVENTERROR_NotExist; - } - if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return XFA_EVENTERROR_Disabled; - } - CXFA_EventParam EventParam; - EventParam.m_eType = XFA_EVENT_Calculate; - CXFA_Script script = calc.GetScript(); - int32_t iRet = ExecuteScript(script, &EventParam); - if (iRet == XFA_EVENTERROR_Sucess) { - 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_Sucess; - } - } - return iRet; -} -void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, - int32_t iRet, - FXJSE_HVALUE pRetValue, - FX_BOOL bVersionFlag) { - if (iRet == XFA_EVENTERROR_Sucess && pRetValue) { - if (FXJSE_Value_IsBoolean(pRetValue) && !FXJSE_Value_ToBoolean(pRetValue)) { - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return; - } - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); - CFX_WideString wsScriptMsg; - validate.GetScriptMessageText(wsScriptMsg); - int32_t eScriptTest = validate.GetScriptTest(); - if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { - if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return; - } - if (wsScriptMsg.IsEmpty()) { - GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag); - } - if (bVersionFlag) { - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); - return; - } - if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); - } - } else { - if (wsScriptMsg.IsEmpty()) { - GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag); - } - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); - } - } - } -} -int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, - FX_BOOL bVersionFlag) { - CFX_WideString wsRawValue = GetRawValue(); - if (!wsRawValue.IsEmpty()) { - CFX_WideString wsPicture; - validate.GetPicture(wsPicture); - if (wsPicture.IsEmpty()) { - return XFA_EVENTERROR_NotExist; - } - IFX_Locale* pLocale = GetLocal(); - if (!pLocale) { - return XFA_EVENTERROR_NotExist; - } - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this); - if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) { - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return XFA_EVENTERROR_NotExist; - } - CFX_WideString wsFormatMsg; - validate.GetFormatMessageText(wsFormatMsg); - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); - int32_t eFormatTest = validate.GetFormatTest(); - if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { - if (wsFormatMsg.IsEmpty()) { - GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag); - } - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); - return XFA_EVENTERROR_Sucess; - } - if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return XFA_EVENTERROR_NotExist; - } - if (wsFormatMsg.IsEmpty()) { - GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag); - } - if (bVersionFlag) { - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); - return XFA_EVENTERROR_Sucess; - } - if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); - } - return XFA_EVENTERROR_Sucess; - } - } - return XFA_EVENTERROR_NotExist; -} -int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, - int32_t iFlags, - FX_BOOL bVersionFlag) { - CFX_WideString wsValue; - GetValue(wsValue, XFA_VALUEPICTURE_Raw); - if (!wsValue.IsEmpty()) { - return XFA_EVENTERROR_Sucess; - } - if (m_bIsNull && (m_bPreNull == m_bIsNull)) { - return XFA_EVENTERROR_Sucess; - } - int32_t eNullTest = validate.GetNullTest(); - CFX_WideString wsNullMsg; - validate.GetNullMessageText(wsNullMsg); - if (iFlags & 0x01) { - int32_t iRet = XFA_EVENTERROR_Sucess; - if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - iRet = XFA_EVENTERROR_Error; - } - if (!wsNullMsg.IsEmpty()) { - if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - m_pDocView->m_arrNullTestMsg.Add(wsNullMsg); - return XFA_EVENTERROR_Error; - } - return XFA_EVENTERROR_Sucess; - } - return iRet; - } - if (wsNullMsg.IsEmpty() && bVersionFlag && - eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - return XFA_EVENTERROR_Error; - } - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return XFA_EVENTERROR_NotExist; - } - CFX_WideString wsCaptionName; - CFX_WideString wsTitle; - pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); - switch (eNullTest) { - case XFA_ATTRIBUTEENUM_Error: { - if (wsNullMsg.IsEmpty()) { - GetValidateCaptionName(wsCaptionName, bVersionFlag); - CFX_WideString wsError; - pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError); - wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName); - } - pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); - return XFA_EVENTERROR_Error; - } - case XFA_ATTRIBUTEENUM_Warning: { - if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return TRUE; - } - if (wsNullMsg.IsEmpty()) { - GetValidateCaptionName(wsCaptionName, bVersionFlag); - CFX_WideString wsWarning; - pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning); - wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, - (const FX_WCHAR*)wsCaptionName); - } - if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE); - } - return XFA_EVENTERROR_Error; - } - case XFA_ATTRIBUTEENUM_Disabled: - default: - break; - } - return XFA_EVENTERROR_Sucess; -} -void CXFA_WidgetAcc::GetValidateCaptionName(CFX_WideString& wsCaptionName, - FX_BOOL bVersionFlag) { - if (!bVersionFlag) { - CXFA_Caption caption = GetCaption(); - if (caption) { - CXFA_Value capValue = caption.GetValue(); - if (capValue) { - CXFA_Text capText = capValue.GetText(); - if (capText) { - capText.GetContent(wsCaptionName); - } - } - } - } - if (wsCaptionName.IsEmpty()) { - GetName(wsCaptionName); - } -} -void CXFA_WidgetAcc::GetValidateMessage(IXFA_AppProvider* pAppProvider, - CFX_WideString& wsMessage, - FX_BOOL bError, - FX_BOOL bVersionFlag) { - CFX_WideString wsCaptionName; - GetValidateCaptionName(wsCaptionName, bVersionFlag); - CFX_WideString wsError; - if (bVersionFlag) { - pAppProvider->LoadString(XFA_IDS_ValidateFailed, wsError); - wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName); - return; - } - if (bError) { - pAppProvider->LoadString(XFA_IDS_ValidateError, wsError); - wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName); - return; - } - CFX_WideString wsWarning; - pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning); - wsMessage.Format(wsWarning, (const FX_WCHAR*)wsCaptionName, - (const FX_WCHAR*)wsCaptionName); -} -int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { - if (GetClassID() == XFA_ELEMENT_Draw) { - return XFA_EVENTERROR_NotExist; - } - CXFA_Validate validate = GetValidate(); - if (!validate) { - return XFA_EVENTERROR_NotExist; - } - FX_BOOL bInitDoc = validate.GetNode()->HasFlag(XFA_NODEFLAG_NeedsInitApp); - FX_BOOL bStatus = - m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; - int32_t iFormat = 0; - FXJSE_HVALUE pRetValue = NULL; - int32_t iRet = XFA_EVENTERROR_NotExist; - CXFA_Script script = validate.GetScript(); - if (script) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Validate; - eParam.m_pTarget = this; - iRet = ExecuteScript(script, &eParam, - ((bInitDoc || bStatus) && GetRawValue().IsEmpty()) - ? nullptr - : &pRetValue); - } - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); - FX_BOOL bVersionFlag = FALSE; - if (version < XFA_VERSION_208) { - bVersionFlag = TRUE; - } - if (bInitDoc) { - validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, FALSE, FALSE); - } else { - iFormat = ProcessFormatTestValidate(validate, bVersionFlag); - if (!bVersionFlag) { - bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); - } - iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); - } - if (iFormat != XFA_EVENTERROR_Sucess) { - ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag); - } - if (pRetValue) { - FXJSE_Value_Release(pRetValue); - } - return iRet | iFormat; -} -int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script, - CXFA_EventParam* pEventParam, - FXJSE_HVALUE* pRetValue) { - static const uint32_t MAX_RECURSION_DEPTH = 2; - if (m_nRecursionDepth > MAX_RECURSION_DEPTH) - return XFA_EVENTERROR_Sucess; - FXSYS_assert(pEventParam); - if (!script) { - return XFA_EVENTERROR_NotExist; - } - if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server) { - return XFA_EVENTERROR_Disabled; - } - CFX_WideString wsExpression; - script.GetExpression(wsExpression); - if (wsExpression.IsEmpty()) { - return XFA_EVENTERROR_NotExist; - } - XFA_SCRIPTTYPE eScriptType = script.GetContentType(); - if (eScriptType == XFA_SCRIPTTYPE_Unkown) { - return XFA_EVENTERROR_Sucess; - } - CXFA_FFDoc* pDoc = GetDoc(); - IXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); - pContext->SetEventParam(*pEventParam); - pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); - CXFA_NodeArray refNodes; - if (pEventParam->m_eType == XFA_EVENT_InitCalculate || - pEventParam->m_eType == XFA_EVENT_Calculate) { - pContext->SetNodesOfRunScript(&refNodes); - } - FXJSE_HVALUE hRetValue = FXJSE_Value_Create(pContext->GetRuntime()); - ++m_nRecursionDepth; - FX_BOOL bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, - wsExpression, hRetValue, m_pNode); - --m_nRecursionDepth; - int32_t iRet = XFA_EVENTERROR_Error; - if (bRet) { - iRet = XFA_EVENTERROR_Sucess; - if (pEventParam->m_eType == XFA_EVENT_Calculate || - pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if (!FXJSE_Value_IsUndefined(hRetValue)) { - if (!FXJSE_Value_IsNull(hRetValue)) { - CFX_ByteString bsString; - FXJSE_Value_ToUTF8String(hRetValue, bsString); - pEventParam->m_wsResult = - CFX_WideString::FromUTF8(bsString, bsString.GetLength()); - } - iRet = XFA_EVENTERROR_Sucess; - } else { - iRet = XFA_EVENTERROR_Error; - } - if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if ((iRet == XFA_EVENTERROR_Sucess) && - (GetRawValue() != pEventParam->m_wsResult)) { - SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); - m_pDocView->AddValidateWidget(this); - } - } - int32_t iRefs = refNodes.GetSize(); - for (int32_t r = 0; r < iRefs; r++) { - CXFA_WidgetAcc* pRefAcc = (CXFA_WidgetAcc*)refNodes[r]->GetWidgetData(); - if (pRefAcc && pRefAcc == this) { - continue; - } - CXFA_Node* pRefNode = refNodes[r]; - CXFA_CalcData* pGlobalData = - (CXFA_CalcData*)pRefNode->GetUserData(XFA_CalcData); - if (!pGlobalData) { - pGlobalData = new CXFA_CalcData; - pRefNode->SetUserData(XFA_CalcData, pGlobalData, - &gs_XFADeleteCalcData); - } - if (pGlobalData->m_Globals.Find(this) < 0) { - pGlobalData->m_Globals.Add(this); - } - } - } - } - if (pRetValue) { - *pRetValue = hRetValue; - } else { - FXJSE_Value_Release(hRetValue); - } - pContext->SetNodesOfRunScript(NULL); - return iRet; -} -CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) { - CXFA_LayoutItem* pLayout = nullptr; - if (pWidget) { - pLayout = pWidget->GetNext(); - } else { - pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode); - } - return static_cast<CXFA_FFWidget*>(pLayout); -} -void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) { - CXFA_FFWidget* pWidget = NULL; - while ((pWidget = GetNextWidget(pWidget))) { - if (pWidget == pExcept || !pWidget->IsLoaded() || - (GetUIType() != XFA_ELEMENT_CheckButton && pWidget->IsFocused())) { - continue; - } - pWidget->UpdateFWLData(); - pWidget->AddInvalidateRect(); - } -} -void CXFA_WidgetAcc::NotifyEvent(FX_DWORD 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) { - return; - } - LoadCaption(); - XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); - int32_t iCapPlacement = caption.GetPlacementType(); - FX_FLOAT fCapReserve = caption.GetReserve(); - const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; - const bool bReserveExit = fCapReserve > 0.01; - CXFA_TextLayout* pCapTextLayout = - ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout; - if (pCapTextLayout) { - if (!bVert && eUIType != XFA_ELEMENT_Button) { - szCap.x = fCapReserve; - } - CFX_SizeF minSize; - pCapTextLayout->CalcSize(minSize, szCap, szCap); - if (bReserveExit) { - bVert ? szCap.y = fCapReserve : szCap.x = fCapReserve; - } - } else { - FX_FLOAT fFontSize = 10.0f; - if (CXFA_Font font = caption.GetFont()) { - fFontSize = font.GetFontSize(); - } else if (CXFA_Font widgetfont = GetFont()) { - fFontSize = widgetfont.GetFontSize(); - } - if (bVert) { - szCap.y = fCapReserve > 0 ? fCapReserve : fFontSize; - } else { - szCap.x = fCapReserve > 0 ? fCapReserve : 0; - szCap.y = fFontSize; - } - } - if (CXFA_Margin mgCap = caption.GetMargin()) { - FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; - mgCap.GetLeftInset(fLeftInset); - mgCap.GetTopInset(fTopInset); - mgCap.GetRightInset(fRightInset); - mgCap.GetBottomInset(fBottomInset); - if (bReserveExit) { - bVert ? (szCap.x += fLeftInset + fRightInset) - : (szCap.y += fTopInset + fBottomInset); - } else { - szCap.x += fLeftInset + fRightInset; - szCap.y += fTopInset + fBottomInset; - } - } -} -FX_BOOL CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { - CFX_SizeF szCap; - CalcCaptionSize(szCap); - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); - size.x += rtUIMargin.left + rtUIMargin.width; - size.y += rtUIMargin.top + rtUIMargin.height; - if (szCap.x > 0 && szCap.y > 0) { - int32_t iCapPlacement = GetCaption().GetPlacementType(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.x += szCap.x; - size.y = std::max(size.y, szCap.y); - } break; - case XFA_ATTRIBUTEENUM_Top: - case XFA_ATTRIBUTEENUM_Bottom: { - size.y += szCap.y; - size.x = std::max(size.x, szCap.x); - } - default: - break; - } - } - return CalculateWidgetAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetTopInset(fTopInset); - mgWidget.GetRightInset(fRightInset); - mgWidget.GetBottomInset(fBottomInset); - size.x += fLeftInset + fRightInset; - size.y += fTopInset + fBottomInset; - } - CXFA_Para para = GetPara(); - if (para) { - size.x += para.GetMarginLeft(); - size.x += para.GetTextIndent(); - } - FX_FLOAT fVal = 0, fMin = 0, fMax = 0; - if (GetWidth(fVal)) { - size.x = fVal; - } else { - if (GetMinWidth(fMin)) { - size.x = std::max(size.x, fMin); - } - if (GetMaxWidth(fMax) && fMax > 0) { - size.x = std::min(size.x, fMax); - } - } - fVal = 0, fMin = 0, fMax = 0; - if (GetHeight(fVal)) { - size.y = fVal; - } else { - if (GetMinHeight(fMin)) { - size.y = std::max(size.y, fMin); - } - if (GetMaxHeight(fMax) && fMax > 0) { - size.y = std::min(size.y, fMax); - } - } - return TRUE; -} -void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { - FX_FLOAT fFontSize = GetFontSize(); - CFX_WideString wsText; - GetValue(wsText, XFA_VALUEPICTURE_Display); - if (wsText.IsEmpty()) { - size.y += fFontSize; - return; - } - FX_WCHAR wcEnter = '\n'; - FX_WCHAR wsLast = wsText.GetAt(wsText.GetLength() - 1); - 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; - pTextOut->SetFont(GetFDEFont()); - pTextOut->SetFontSize(fFontSize); - pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); - pTextOut->SetLineSpace(GetLineHeight()); - FX_DWORD dwStyles = FDE_TTOSTYLE_LastLineHeight; - if (GetUIType() == XFA_ELEMENT_TextEdit && IsMultiLine()) { - dwStyles |= FDE_TTOSTYLE_LineWrap; - } - pTextOut->SetStyles(dwStyles); - } - ((CXFA_FieldLayoutData*)m_pLayoutData) - ->m_pTextOut->CalcLogicSize(wsText, wsText.GetLength(), size); -} -FX_BOOL CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { - if (size.x > 0) { - CFX_SizeF szOrz = size; - CFX_SizeF szCap; - CalcCaptionSize(szCap); - FX_BOOL bCapExit = szCap.x > 0.01 && szCap.y > 0.01; - int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - if (bCapExit) { - iCapPlacement = GetCaption().GetPlacementType(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.x -= szCap.x; - } - default: - break; - } - } - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); - size.x -= rtUIMargin.left + rtUIMargin.width; - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - size.x -= fLeftInset + fRightInset; - } - CalculateTextContentSize(size); - size.y += rtUIMargin.top + rtUIMargin.height; - if (bCapExit) { - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.y = std::max(size.y, szCap.y); - } break; - case XFA_ATTRIBUTEENUM_Top: - case XFA_ATTRIBUTEENUM_Bottom: { - size.y += szCap.y; - } - default: - break; - } - } - size.x = szOrz.x; - return CalculateWidgetAutoSize(size); - } - CalculateTextContentSize(size); - return CalculateFieldAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) { - FX_FLOAT fCheckSize = GetCheckButtonSize(); - size.x = size.y = fCheckSize; - return CalculateFieldAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) { - CalcCaptionSize(size); - return CalculateWidgetAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { - if (!GetImageImage()) { - LoadImageImage(); - } - size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageImage()) { - CFX_RectF rtImage, rtFit; - rtImage.Set(0, 0, 0, 0); - rtFit.Set(0, 0, 0, 0); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageDpi(iImageXDpi, iImageYDpi); - rtImage.width = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - rtImage.height = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); - if (GetWidth(rtFit.width)) { - GetWidthWithoutMargin(rtFit.width); - } else { - rtFit.width = rtImage.width; - } - if (GetHeight(rtFit.height)) { - GetHeightWithoutMargin(rtFit.height); - } else { - rtFit.height = rtImage.height; - } - size.x = rtFit.width; - size.y = rtFit.height; - } - return CalculateWidgetAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { - if (!GetImageEditImage()) { - LoadImageEditImage(); - } - size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { - CFX_RectF rtImage, rtFit; - rtImage.Set(0, 0, 0, 0); - rtFit.Set(0, 0, 0, 0); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageEditDpi(iImageXDpi, iImageYDpi); - rtImage.width = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - rtImage.height = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); - if (GetWidth(rtFit.width)) { - GetWidthWithoutMargin(rtFit.width); - } else { - rtFit.width = rtImage.width; - } - if (GetHeight(rtFit.height)) { - GetHeightWithoutMargin(rtFit.height); - } else { - rtFit.height = rtImage.height; - } - size.x = rtFit.width; - size.y = rtFit.height; - } - return CalculateFieldAutoSize(size); -} -FX_BOOL CXFA_WidgetAcc::LoadImageImage() { - InitLayoutData(); - return ((CXFA_ImageLayoutData*)m_pLayoutData)->LoadImageData(this); -} -FX_BOOL CXFA_WidgetAcc::LoadImageEditImage() { - InitLayoutData(); - return ((CXFA_ImageEditData*)m_pLayoutData)->LoadImageData(this); -} -void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { - iImageXDpi = ((CXFA_ImageLayoutData*)m_pLayoutData)->m_iImageXDpi; - iImageYDpi = ((CXFA_ImageLayoutData*)m_pLayoutData)->m_iImageYDpi; -} -void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { - iImageXDpi = ((CXFA_ImageEditData*)m_pLayoutData)->m_iImageXDpi; - iImageYDpi = ((CXFA_ImageEditData*)m_pLayoutData)->m_iImageYDpi; -} -FX_BOOL CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { - LoadText(); - CXFA_TextLayout* pTextLayout = - ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; - if (pTextLayout) { - size.x = pTextLayout->StartLayout(size.x); - size.y = pTextLayout->GetLayoutHeight(); - } - return CalculateWidgetAutoSize(size); -} -void CXFA_WidgetAcc::LoadText() { - InitLayoutData(); - ((CXFA_TextLayoutData*)m_pLayoutData)->LoadText(this); -} -FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoWidth(FX_FLOAT fWidthCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - fWidthCalc += fLeftInset + fRightInset; - } - FX_FLOAT fMin = 0, fMax = 0; - if (GetMinWidth(fMin)) { - fWidthCalc = std::max(fWidthCalc, fMin); - } - if (GetMaxWidth(fMax) && fMax > 0) { - fWidthCalc = std::min(fWidthCalc, fMax); - } - return fWidthCalc; -} -FX_FLOAT CXFA_WidgetAcc::GetWidthWithoutMargin(FX_FLOAT fWidthCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - fWidthCalc -= fLeftInset + fRightInset; - } - return fWidthCalc; -} -FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoHeight(FX_FLOAT fHeightCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fTopInset, fBottomInset; - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - fHeightCalc += fTopInset + fBottomInset; - } - FX_FLOAT fMin = 0, fMax = 0; - if (GetMinHeight(fMin)) { - fHeightCalc = std::max(fHeightCalc, fMin); - } - if (GetMaxHeight(fMax) && fMax > 0) { - fHeightCalc = std::min(fHeightCalc, fMax); - } - return fHeightCalc; -} -FX_FLOAT CXFA_WidgetAcc::GetHeightWithoutMargin(FX_FLOAT fHeightCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - FX_FLOAT fTopInset, fBottomInset; - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - fHeightCalc -= fTopInset + fBottomInset; - } - return fHeightCalc; -} -void CXFA_WidgetAcc::StartWidgetLayout(FX_FLOAT& fCalcWidth, - FX_FLOAT& fCalcHeight) { - InitLayoutData(); - XFA_ELEMENT eUIType = GetUIType(); - if (eUIType == XFA_ELEMENT_Text) { - m_pLayoutData->m_fWidgetHeight = -1; - GetHeight(m_pLayoutData->m_fWidgetHeight); - StartTextLayout(fCalcWidth, fCalcHeight); - return; - } - if (fCalcWidth > 0 && fCalcHeight > 0) { - return; - } - m_pLayoutData->m_fWidgetHeight = -1; - FX_FLOAT fWidth = 0; - if (fCalcWidth > 0 && fCalcHeight < 0) { - if (!GetHeight(fCalcHeight)) { - CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); - } - m_pLayoutData->m_fWidgetHeight = fCalcHeight; - return; - } - if (fCalcWidth < 0 && fCalcHeight < 0) { - if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) { - CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); - } - fCalcWidth = fWidth; - } - m_pLayoutData->m_fWidgetHeight = fCalcHeight; -} -void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_ELEMENT eUIType, - FX_FLOAT& fWidth, - FX_FLOAT& fCalcHeight) { - CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); - switch (eUIType) { - case XFA_ELEMENT_Barcode: - case XFA_ELEMENT_ChoiceList: - case XFA_ELEMENT_Signature: - CalculateFieldAutoSize(sz); - break; - case XFA_ELEMENT_ImageEdit: - CalculateImageEditAutoSize(sz); - break; - case XFA_ELEMENT_Button: - CalculatePushButtonAutoSize(sz); - break; - case XFA_ELEMENT_CheckButton: - CalculateCheckButtonAutoSize(sz); - break; - case XFA_ELEMENT_DateTimeEdit: - case XFA_ELEMENT_NumericEdit: - case XFA_ELEMENT_PasswordEdit: - case XFA_ELEMENT_TextEdit: - CalculateTextEditAutoSize(sz); - break; - case XFA_ELEMENT_Image: - CalculateImageAutoSize(sz); - break; - case XFA_ELEMENT_Arc: - case XFA_ELEMENT_Line: - case XFA_ELEMENT_Rectangle: - case XFA_ELEMENT_Subform: - case XFA_ELEMENT_ExclGroup: - CalculateWidgetAutoSize(sz); - break; - default: - break; - } - fWidth = sz.x; - m_pLayoutData->m_fWidgetHeight = sz.y; - fCalcHeight = sz.y; -} -FX_BOOL CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, - FX_FLOAT& fCalcHeight) { - XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); - if (eUIType == XFA_ELEMENT_Subform) { - return FALSE; - } - if (eUIType != XFA_ELEMENT_Text && eUIType != XFA_ELEMENT_TextEdit && - eUIType != XFA_ELEMENT_NumericEdit && - eUIType != XFA_ELEMENT_PasswordEdit) { - fCalcHeight = 0; - return TRUE; - } - FX_FLOAT fTopInset = 0; - FX_FLOAT fBottomInset = 0; - if (iBlockIndex == 0) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - } - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); - fTopInset += rtUIMargin.top; - fBottomInset += rtUIMargin.width; - } - if (eUIType == XFA_ELEMENT_Text) { - FX_FLOAT fHeight = fCalcHeight; - if (iBlockIndex == 0) { - fCalcHeight = fCalcHeight - fTopInset; - if (fCalcHeight < 0) { - fCalcHeight = 0; - } - } - CXFA_TextLayout* pTextLayout = - ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; - pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight, - m_pLayoutData->m_fWidgetHeight - fTopInset); - if (fCalcHeight != 0) { - if (iBlockIndex == 0) { - fCalcHeight = fCalcHeight + fTopInset; - } - if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { - return FALSE; - } - } - return TRUE; - } - XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - FX_FLOAT fCapReserve = 0; - if (iBlockIndex == 0) { - CXFA_Caption caption = GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); - fCapReserve = caption.GetReserve(); - } - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && - fCalcHeight < fCapReserve + fTopInset) { - fCalcHeight = 0; - return TRUE; - } - if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && - m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) { - fCalcHeight = 0; - return TRUE; - } - if (iCapPlacement != XFA_ATTRIBUTEENUM_Top) { - fCapReserve = 0; - } - } - int32_t iLinesCount = 0; - FX_FLOAT fHeight = m_pLayoutData->m_fWidgetHeight; - CFX_WideString wsText; - GetValue(wsText, XFA_VALUEPICTURE_Display); - if (wsText.IsEmpty()) { - iLinesCount = 1; - } else { - if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut) { - FX_FLOAT fWidth = 0; - GetWidth(fWidth); - CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); - } - iLinesCount = - ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut->GetTotalLines(); - } - if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray) { - ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray = - new CFX_FloatArray; - } - CFX_FloatArray* pFieldArray = - ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray; - int32_t iFieldSplitCount = pFieldArray->GetSize(); - for (int32_t i = 0; i < iBlockIndex * 3; i += 3) { - iLinesCount -= (int32_t)pFieldArray->GetAt(i + 1); - fHeight -= pFieldArray->GetAt(i + 2); - } - if (iLinesCount == 0) { - return FALSE; - } - FX_FLOAT fLineHeight = GetLineHeight(); - FX_FLOAT fFontSize = GetFontSize(); - FX_FLOAT fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize; - FX_FLOAT fSpaceAbove = 0; - FX_FLOAT fStartOffset = 0; - if (fHeight > 0.1f && iBlockIndex == 0) { - fStartOffset = fTopInset; - fHeight -= (fTopInset + fBottomInset); - if (CXFA_Para para = GetPara()) { - fSpaceAbove = para.GetSpaceAbove(); - FX_FLOAT fSpaceBelow = para.GetSpaceBelow(); - fHeight -= (fSpaceAbove + fSpaceBelow); - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Top: - fStartOffset += fSpaceAbove; - break; - case XFA_ATTRIBUTEENUM_Middle: - fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove); - break; - case XFA_ATTRIBUTEENUM_Bottom: - fStartOffset += (fHeight - fTextHeight + fSpaceAbove); - break; - } - } - if (fStartOffset < 0.1f) { - fStartOffset = 0; - } - } - for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) { - fStartOffset = pFieldArray->GetAt(i * 3) - pFieldArray->GetAt(i * 3 + 2); - if (fStartOffset < 0.1f) { - fStartOffset = 0; - } - } - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - pFieldArray->SetAt(0, fStartOffset); - } else { - pFieldArray->Add(fStartOffset); - } - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); - FX_BOOL bCanSplitNoContent = FALSE; - XFA_ATTRIBUTEENUM eLayoutMode; - GetNode() - ->GetNodeItem(XFA_NODEITEM_Parent) - ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, TRUE); - if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position || - eLayoutMode == XFA_ATTRIBUTEENUM_Tb || - eLayoutMode == XFA_ATTRIBUTEENUM_Row || - eLayoutMode == XFA_ATTRIBUTEENUM_Table) && - version > XFA_VERSION_208) { - bCanSplitNoContent = TRUE; - } - if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb || - eLayoutMode == XFA_ATTRIBUTEENUM_Row || - eLayoutMode == XFA_ATTRIBUTEENUM_Table) && - version <= XFA_VERSION_208) { - if (fStartOffset < fCalcHeight) { - bCanSplitNoContent = TRUE; - } else { - fCalcHeight = 0; - return TRUE; - } - } - if (bCanSplitNoContent) { - if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) { - fCalcHeight = 0; - return TRUE; - } - if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) { - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - pFieldArray->SetAt(iBlockIndex * 3 + 1, 0); - pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); - } else { - pFieldArray->Add(0); - pFieldArray->Add(fCalcHeight); - } - return FALSE; - } - if (fCalcHeight - fStartOffset < fLineHeight) { - fCalcHeight = fStartOffset; - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - pFieldArray->SetAt(iBlockIndex * 3 + 1, 0); - pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); - } else { - pFieldArray->Add(0); - pFieldArray->Add(fCalcHeight); - } - return TRUE; - } - FX_FLOAT fTextNum = - fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset; - int32_t iLineNum = - (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight); - if (iLineNum >= iLinesCount) { - if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) { - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLinesCount); - pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight); - } else { - pFieldArray->Add((FX_FLOAT)iLinesCount); - pFieldArray->Add(fCalcHeight); - } - return FALSE; - } - if (fHeight - fStartOffset - fTextHeight < fFontSize) { - iLineNum -= 1; - if (iLineNum == 0) { - fCalcHeight = 0; - return TRUE; - } - } else { - iLineNum = (int32_t)(fTextNum / fLineHeight); - } - } - if (iLineNum > 0) { - FX_FLOAT fSplitHeight = - iLineNum * fLineHeight + fCapReserve + fStartOffset; - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLineNum); - pFieldArray->SetAt(iBlockIndex * 3 + 2, fSplitHeight); - } else { - pFieldArray->Add((FX_FLOAT)iLineNum); - pFieldArray->Add(fSplitHeight); - } - if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { - return FALSE; - } - fCalcHeight = fSplitHeight; - return TRUE; - } - } - fCalcHeight = 0; - return TRUE; -} -void CXFA_WidgetAcc::InitLayoutData() { - if (m_pLayoutData) { - return; - } - switch (GetUIType()) { - case XFA_ELEMENT_Text: - m_pLayoutData = new CXFA_TextLayoutData; - return; - case XFA_ELEMENT_TextEdit: - m_pLayoutData = new CXFA_TextEditData; - return; - case XFA_ELEMENT_Image: - m_pLayoutData = new CXFA_ImageLayoutData; - return; - case XFA_ELEMENT_ImageEdit: - m_pLayoutData = new CXFA_ImageEditData; - return; - default: - break; - } - if (GetClassID() == XFA_ELEMENT_Field) { - m_pLayoutData = new CXFA_FieldLayoutData; - } else { - m_pLayoutData = new CXFA_WidgetLayoutData; - } -} -void CXFA_WidgetAcc::StartTextLayout(FX_FLOAT& fCalcWidth, - FX_FLOAT& fCalcHeight) { - LoadText(); - CXFA_TextLayout* pTextLayout = - ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; - FX_FLOAT fTextHeight = 0; - if (fCalcWidth > 0 && fCalcHeight > 0) { - FX_FLOAT fWidth = GetWidthWithoutMargin(fCalcWidth); - pTextLayout->StartLayout(fWidth); - fTextHeight = fCalcHeight; - fTextHeight = GetHeightWithoutMargin(fTextHeight); - pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); - return; - } - if (fCalcWidth > 0 && fCalcHeight < 0) { - FX_FLOAT fWidth = GetWidthWithoutMargin(fCalcWidth); - pTextLayout->StartLayout(fWidth); - } - if (fCalcWidth < 0 && fCalcHeight < 0) { - FX_FLOAT fMaxWidth = -1; - FX_BOOL bRet = GetWidth(fMaxWidth); - if (bRet) { - FX_FLOAT fWidth = GetWidthWithoutMargin(fMaxWidth); - pTextLayout->StartLayout(fWidth); - } else { - FX_FLOAT fWidth = pTextLayout->StartLayout(fMaxWidth); - fMaxWidth = CalculateWidgetAutoWidth(fWidth); - fWidth = GetWidthWithoutMargin(fMaxWidth); - pTextLayout->StartLayout(fWidth); - } - fCalcWidth = fMaxWidth; - } - if (m_pLayoutData->m_fWidgetHeight < 0) { - m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight(); - m_pLayoutData->m_fWidgetHeight = - CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight); - } - fTextHeight = m_pLayoutData->m_fWidgetHeight; - fTextHeight = GetHeightWithoutMargin(fTextHeight); - pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); - fCalcHeight = m_pLayoutData->m_fWidgetHeight; -} -FX_BOOL CXFA_WidgetAcc::LoadCaption() { - InitLayoutData(); - return ((CXFA_FieldLayoutData*)m_pLayoutData)->LoadCaption(this); -} -CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() { - return m_pLayoutData - ? ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout - : NULL; -} -CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { - return m_pLayoutData ? ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout - : NULL; -} -CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() { - return m_pLayoutData ? ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap - : NULL; -} -CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() { - return m_pLayoutData ? ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap - : NULL; -} -void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) { - if (((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap == newImage) { - return; - } - if (((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap && - !((CXFA_ImageLayoutData*)m_pLayoutData)->m_bNamedImage) { - delete ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap; - ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap = NULL; - } - ((CXFA_ImageLayoutData*)m_pLayoutData)->m_pDIBitmap = newImage; -} -void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) { - if (((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap == newImage) { - return; - } - if (((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap && - !((CXFA_ImageEditData*)m_pLayoutData)->m_bNamedImage) { - delete ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap; - ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap = NULL; - } - ((CXFA_ImageEditData*)m_pLayoutData)->m_pDIBitmap = newImage; -} -CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { - return m_pLayoutData; -} -IFX_Font* CXFA_WidgetAcc::GetFDEFont() { - CFX_WideStringC wsFontName = FX_WSTRC(L"Courier"); - FX_DWORD dwFontStyle = 0; - if (CXFA_Font font = GetFont()) { - if (font.IsBold()) { - dwFontStyle |= FX_FONTSTYLE_Bold; - } - if (font.IsItalic()) { - dwFontStyle |= FX_FONTSTYLE_Italic; - } - font.GetTypeface(wsFontName); - } - CXFA_FFDoc* pDoc = GetDoc(); - return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName, - dwFontStyle); -} -FX_FLOAT CXFA_WidgetAcc::GetFontSize() { - FX_FLOAT fFontSize = 10.0f; - if (CXFA_Font font = GetFont()) { - fFontSize = font.GetFontSize(); - } - return fFontSize < 0.1f ? 10.0f : fFontSize; -} -FX_FLOAT CXFA_WidgetAcc::GetLineHeight() { - FX_FLOAT fLineHeight = 0; - if (CXFA_Para para = GetPara()) { - fLineHeight = para.GetLineHeight(); - } - if (fLineHeight < 1) { - fLineHeight = GetFontSize() * 1.2f; - } - return fLineHeight; -} -FX_ARGB CXFA_WidgetAcc::GetTextColor() { - if (CXFA_Font font = GetFont()) { - return font.GetColor(); - } - return 0xFF000000; -} -CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { - bRichText = FALSE; - if (m_pTextNode) { - if (m_pTextNode->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - m_pTextNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, - FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - bRichText = TRUE; - } - } - return m_pTextNode; - } - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { - CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); - CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_ELEMENT_Value); - if (!pValueNode) { - return NULL; - } - CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - bRichText = TRUE; - } - } - return pChildNode; - } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { - CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); - IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); - FXSYS_assert(pXMLNode); - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLChild; - if (XFA_RecognizeRichText(pElement)) { - bRichText = TRUE; - } - } - } - return pBind; - } else if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) { - CXFA_Node* pCaptionNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); - if (pCaptionNode == NULL) { - return NULL; - } - CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_ELEMENT_Value); - if (pValueNode == NULL) { - return NULL; - } - CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - bRichText = TRUE; - } - } - return pChildNode; - } - CXFA_Node* pItemNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Items); - if (pItemNode == NULL) { - return NULL; - } - CXFA_Node* pNode = pItemNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pNode) { - CFX_WideStringC wsName; - pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); - if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && - wsName == FX_WSTRC(L"rollover")) { - return pNode; - } - if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == FX_WSTRC(L"down")) { - return pNode; - } - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - return NULL; -} -CXFA_Para CXFA_TextProvider::GetParaNode() { - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { - return m_pWidgetAcc->GetPara(); - } - CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); - return CXFA_Para(pNode->GetChild(0, XFA_ELEMENT_Para)); -} -CXFA_Font CXFA_TextProvider::GetFontNode() { - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { - return m_pWidgetAcc->GetFont(); - } - CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_ELEMENT_Caption); - pNode = pNode->GetChild(0, XFA_ELEMENT_Font); - if (pNode) { - return CXFA_Font(pNode); - } - return m_pWidgetAcc->GetFont(); -} -FX_BOOL CXFA_TextProvider::IsCheckButtonAndAutoWidth() { - XFA_ELEMENT eType = m_pWidgetAcc->GetUIType(); - if (eType == XFA_ELEMENT_CheckButton) { - FX_FLOAT fWidth = 0; - return !m_pWidgetAcc->GetWidth(fWidth); - } - return FALSE; -} -FX_BOOL CXFA_TextProvider::GetEmbbedObj(FX_BOOL bURI, - FX_BOOL bRaw, - const CFX_WideString& wsAttr, - CFX_WideString& wsValue) { - if (m_eType != XFA_TEXTPROVIDERTYPE_Text) { - return FALSE; - } - if (bURI) { - CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); - CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_Document* pDocument = pWidgetNode->GetDocument(); - CXFA_Node* pIDNode = NULL; - CXFA_WidgetAcc* pEmbAcc = NULL; - if (pParent) { - pIDNode = pDocument->GetNodeByID(pParent, wsAttr); - } - if (!pIDNode) { - pIDNode = pDocument->GetNodeByID( - ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), wsAttr); - } - if (pIDNode) { - pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); - } - if (pEmbAcc) { - pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); - return TRUE; - } - } - return FALSE; -} diff --git a/xfa/src/fxfa/app/xfa_ffwidgetacc.h b/xfa/src/fxfa/app/xfa_ffwidgetacc.h deleted file mode 100644 index 19bd28d393..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidgetacc.h +++ /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 - -#ifndef XFA_SRC_FXFA_APP_XFA_FFWIDGETACC_H_ -#define XFA_SRC_FXFA_APP_XFA_FFWIDGETACC_H_ - -#include "xfa/src/fxfa/app/xfa_textlayout.h" - -enum XFA_TEXTPROVIDERTYPE { - XFA_TEXTPROVIDERTYPE_Text, - XFA_TEXTPROVIDERTYPE_Datasets, - XFA_TEXTPROVIDERTYPE_Caption, - XFA_TEXTPROVIDERTYPE_Rollover, - XFA_TEXTPROVIDERTYPE_Down, -}; -class CXFA_TextProvider : public IXFA_TextProvider { - public: - CXFA_TextProvider(CXFA_WidgetAcc* pWidgetAcc, - XFA_TEXTPROVIDERTYPE eType, - CXFA_Node* pTextNode = NULL) - : m_pWidgetAcc(pWidgetAcc), m_eType(eType), m_pTextNode(pTextNode) { - FXSYS_assert(m_pWidgetAcc); - } - virtual ~CXFA_TextProvider() {} - virtual CXFA_Node* GetTextNode(FX_BOOL& bRichText); - virtual CXFA_Para GetParaNode(); - virtual CXFA_Font GetFontNode(); - virtual FX_BOOL IsCheckButtonAndAutoWidth(); - virtual CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); } - virtual FX_BOOL GetEmbbedObj(FX_BOOL bURI, - FX_BOOL bRaw, - const CFX_WideString& wsAttr, - CFX_WideString& wsValue); - - protected: - CXFA_WidgetAcc* m_pWidgetAcc; - XFA_TEXTPROVIDERTYPE m_eType; - CXFA_Node* m_pTextNode; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFWIDGETACC_H_ diff --git a/xfa/src/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/src/fxfa/app/xfa_ffwidgethandler.cpp deleted file mode 100644 index bea7586180..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidgethandler.cpp +++ /dev/null @@ -1,634 +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/src/fxfa/app/xfa_ffwidgethandler.h" - -#include <vector> - -#include "xfa/src/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_ffdocview.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" -#include "xfa/src/fxfa/app/xfa_fwladapter.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" - -CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) - : m_pDocView(pDocView) {} -CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} -IXFA_PageView* CXFA_FFWidgetHandler::GetPageView(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->GetPageView(); -} -void CXFA_FFWidgetHandler::GetRect(IXFA_Widget* hWidget, CFX_RectF& rt) { - static_cast<CXFA_FFWidget*>(hWidget)->GetWidgetRect(rt); -} -FX_DWORD CXFA_FFWidgetHandler::GetStatus(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->GetStatus(); -} -FX_BOOL CXFA_FFWidgetHandler::GetBBox(IXFA_Widget* hWidget, - CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus) { - return static_cast<CXFA_FFWidget*>(hWidget) - ->GetBBox(rtBox, dwStatus, bDrawFocus); -} -CXFA_WidgetAcc* CXFA_FFWidgetHandler::GetDataAcc(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->GetDataAcc(); -} -void CXFA_FFWidgetHandler::GetName(IXFA_Widget* hWidget, - CFX_WideString& wsName, - int32_t iNameType) { - static_cast<CXFA_FFWidget*>(hWidget)->GetDataAcc()->GetName(wsName, - iNameType); -} -FX_BOOL CXFA_FFWidgetHandler::GetToolTip(IXFA_Widget* hWidget, - CFX_WideString& wsToolTip) { - return static_cast<CXFA_FFWidget*>(hWidget)->GetToolTip(wsToolTip); -} -void CXFA_FFWidgetHandler::SetPrivateData(IXFA_Widget* hWidget, - void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback) { - static_cast<CXFA_FFWidget*>(hWidget) - ->SetPrivateData(module_id, pData, callback); -} -void* CXFA_FFWidgetHandler::GetPrivateData(IXFA_Widget* hWidget, - void* module_id) { - return static_cast<CXFA_FFWidget*>(hWidget)->GetPrivateData(module_id); -} -FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(IXFA_Widget* hWidget) { - m_pDocView->LockUpdate(); - FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnMouseEnter(); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(IXFA_Widget* hWidget) { - m_pDocView->LockUpdate(); - FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnMouseExit(); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - m_pDocView->LockUpdate(); - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonDown(dwFlags, fx, fy); - if (bRet && m_pDocView->SetFocus(hWidget)) { - ((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->SetFocusWidget(m_pDocView->GetDoc(), (IXFA_Widget*)hWidget); - } - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - m_pDocView->LockUpdate(); - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - m_pDocView->m_bLayoutEvent = TRUE; - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonUp(dwFlags, fx, fy); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnLButtonDblClk(dwFlags, fx, fy); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnMouseMove(dwFlags, fx, fy); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget) - ->OnMouseWheel(dwFlags, zDelta, fx, fy); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonDown(dwFlags, fx, fy); - if (bRet && m_pDocView->SetFocus(hWidget)) { - ((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->SetFocusWidget(m_pDocView->GetDoc(), (IXFA_Widget*)hWidget); - } - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonUp(dwFlags, fx, fy); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnRButtonDblClk(dwFlags, fx, fy); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(IXFA_Widget* hWidget, - FX_DWORD dwKeyCode, - FX_DWORD dwFlags) { - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnKeyDown(dwKeyCode, dwFlags); - m_pDocView->RunInvalidate(); - m_pDocView->UpdateDocView(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(IXFA_Widget* hWidget, - FX_DWORD dwKeyCode, - FX_DWORD dwFlags) { - FX_BOOL bRet = - static_cast<CXFA_FFWidget*>(hWidget)->OnKeyUp(dwKeyCode, dwFlags); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_BOOL CXFA_FFWidgetHandler::OnChar(IXFA_Widget* hWidget, - FX_DWORD dwChar, - FX_DWORD dwFlags) { - FX_BOOL bRet = static_cast<CXFA_FFWidget*>(hWidget)->OnChar(dwChar, dwFlags); - m_pDocView->RunInvalidate(); - return bRet; -} -FX_DWORD CXFA_FFWidgetHandler::OnHitTest(IXFA_Widget* hWidget, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!(static_cast<CXFA_FFWidget*>(hWidget)->GetStatus() & - XFA_WIDGETSTATUS_Visible)) { - return FWL_WGTHITTEST_Unknown; - } - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - return static_cast<CXFA_FFWidget*>(hWidget)->OnHitTest(fx, fy); -} -FX_BOOL CXFA_FFWidgetHandler::OnSetCursor(IXFA_Widget* hWidget, - FX_FLOAT fx, - FX_FLOAT fy) { - static_cast<CXFA_FFWidget*>(hWidget)->Rotate2Normal(fx, fy); - return static_cast<CXFA_FFWidget*>(hWidget)->OnSetCursor(fx, fy); -} -void CXFA_FFWidgetHandler::RenderWidget(IXFA_Widget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - FX_BOOL bHighlight) { - static_cast<CXFA_FFWidget*>(hWidget)->RenderWidget( - pGS, pMatrix, bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); -} -FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, - XFA_EVENTTYPE eEventType) { - if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) { - return FALSE; - } - if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { - return FALSE; - } - switch (eEventType) { - case XFA_EVENT_Calculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { - return FALSE; - } - if (calc.GetScript()) { - return TRUE; - } - return FALSE; - } - case XFA_EVENT_Validate: { - CXFA_Validate val = pWidgetAcc->GetValidate(); - if (!val) { - return FALSE; - } - if (val.GetScript()) { - return TRUE; - } - return FALSE; - } - default: - break; - } - CXFA_NodeArray eventArray; - return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], - eventArray); -} -int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, - CXFA_EventParam* pParam) { - if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { - return XFA_EVENTERROR_NotExist; - } - if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { - return XFA_EVENTERROR_NotExist; - } - switch (pParam->m_eType) { - case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); - case XFA_EVENT_Validate: - if (((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->IsValidationsEnabled(m_pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(); - } - return XFA_EVENTERROR_Disabled; - case XFA_EVENT_InitCalculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { - return XFA_EVENTERROR_NotExist; - } - if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { - return XFA_EVENTERROR_Disabled; - } - CXFA_Script script = calc.GetScript(); - return pWidgetAcc->ExecuteScript(script, pParam); - } - default: - break; - } - int32_t iRet = - pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); - return iRet; -} -IXFA_Widget* CXFA_FFWidgetHandler::CreateWidget(IXFA_Widget* hParent, - XFA_WIDGETTYPE eType, - IXFA_Widget* hBefore) { - CXFA_Node* pParentFormItem = - hParent ? static_cast<CXFA_FFWidget*>(hParent)->GetDataAcc()->GetNode() - : NULL; - CXFA_Node* pBeforeFormItem = - hBefore ? static_cast<CXFA_FFWidget*>(hBefore)->GetDataAcc()->GetNode() - : NULL; - CXFA_Node* pNewFormItem = - CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); - if (pNewFormItem == NULL) { - return NULL; - } - pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); - pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); - m_pDocView->RunLayout(); - CXFA_LayoutItem* pLayout = - m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); - return (IXFA_Widget*)pLayout; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( - XFA_WIDGETTYPE eType, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - switch (eType) { - case XFA_WIDGETTYPE_Barcode: - return NULL; - case XFA_WIDGETTYPE_PushButton: - return CreatePushButton(pParent, pBefore); - case XFA_WIDGETTYPE_CheckButton: - return CreateCheckButton(pParent, pBefore); - case XFA_WIDGETTYPE_ExcludeGroup: - return CreateExclGroup(pParent, pBefore); - case XFA_WIDGETTYPE_RadioButton: - return CreateRadioButton(pParent, pBefore); - case XFA_WIDGETTYPE_Arc: - return CreateArc(pParent, pBefore); - case XFA_WIDGETTYPE_Rectangle: - return CreateRectangle(pParent, pBefore); - case XFA_WIDGETTYPE_Image: - return CreateImage(pParent, pBefore); - case XFA_WIDGETTYPE_Line: - return CreateLine(pParent, pBefore); - case XFA_WIDGETTYPE_Text: - return CreateText(pParent, pBefore); - case XFA_WIDGETTYPE_DatetimeEdit: - return CreateDatetimeEdit(pParent, pBefore); - case XFA_WIDGETTYPE_DecimalField: - return CreateDecimalField(pParent, pBefore); - case XFA_WIDGETTYPE_NumericField: - return CreateNumericField(pParent, pBefore); - case XFA_WIDGETTYPE_Signature: - return CreateSignature(pParent, pBefore); - case XFA_WIDGETTYPE_TextEdit: - return CreateTextEdit(pParent, pBefore); - case XFA_WIDGETTYPE_DropdownList: - return CreateDropdownList(pParent, pBefore); - case XFA_WIDGETTYPE_ListBox: - return CreateListBox(pParent, pBefore); - case XFA_WIDGETTYPE_ImageField: - return CreateImageField(pParent, pBefore); - case XFA_WIDGETTYPE_PasswordEdit: - return CreatePasswordEdit(pParent, pBefore); - case XFA_WIDGETTYPE_Subform: - return CreateSubform(pParent, pBefore); - default: - break; - } - return NULL; -} -CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); - 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); - CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); - pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); - pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); - CreateFontNode(pCaption); - CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); - pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); - CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); - pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); - 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); - CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); - pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); -} -CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); - CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_ELEMENT_Ui); - CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_ELEMENT_CheckButton); - pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); - CreateValueNode(XFA_ELEMENT_Date, pField); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateNumericField(pParent, pBefore); - CreateValueNode(XFA_ELEMENT_Decimal, pField); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_Signature, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDropdownList(pParent, pBefore); - CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); - pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); - pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); - CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); - pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateFormItem(XFA_ELEMENT_Field, pParent, pBefore); - CreateCopyNode(eElement, CreateCopyNode(XFA_ELEMENT_Ui, pField)); - CreateFontNode(pField); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); -} -CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); -} -CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); - CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); - CreateCopyNode(XFA_ELEMENT_TextEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); - CreateFontNode(pField); - return pField; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pDraw = CreateFormItem(XFA_ELEMENT_Draw, pParent, pBefore); - CreateValueNode(eElement, pDraw); - return pDraw; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pSubform = CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); - return pSubform; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; - CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE); - if (pParent) - pParent->InsertChild(pNewFormItem, pBefore); - return pNewFormItem; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; - CXFA_Node* pNewNode = - CreateTemplateNode(eElement, pTemplateParent, - pBefore ? pBefore->GetTemplateNode() : NULL) - ->Clone(FALSE); - if (pParent) - pParent->InsertChild(pNewNode, pBefore); - return pNewNode; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Document* pXFADoc = GetXFADoc(); - CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode( - XFA_XDPPACKET_Template, eElement); - if (pParent) - pParent->InsertChild(pNewTemplateNode, pBefore); - return pNewTemplateNode; -} -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); - return pFont; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, - FX_DWORD dwFlags, - FX_FLOAT fInsets[4]) const { - CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); - if (dwFlags & 0x01) { - pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, - CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x02) { - pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, - CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x04) { - pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, - CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); - } - if (dwFlags & 0x08) { - pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, - CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); - } - return pMargin; -} -CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, - CXFA_Node* pParent) const { - CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); - CreateCopyNode(eValue, pValue); - return pValue; -} -IXFA_ObjFactory* CXFA_FFWidgetHandler::GetObjFactory() const { - return GetXFADoc()->GetParser()->GetFactory(); -} -CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { - return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); -} -CXFA_FFMenuHandler::CXFA_FFMenuHandler() {} -CXFA_FFMenuHandler::~CXFA_FFMenuHandler() {} -FX_BOOL CXFA_FFMenuHandler::CanCopy(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanCopy(); -} -FX_BOOL CXFA_FFMenuHandler::CanCut(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanCut(); -} -FX_BOOL CXFA_FFMenuHandler::CanPaste(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanPaste(); -} -FX_BOOL CXFA_FFMenuHandler::CanSelectAll(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanSelectAll(); -} -FX_BOOL CXFA_FFMenuHandler::CanDelete(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanDelete(); -} -FX_BOOL CXFA_FFMenuHandler::CanDeSelect(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanDeSelect(); -} -FX_BOOL CXFA_FFMenuHandler::Copy(IXFA_Widget* hWidget, CFX_WideString& wsText) { - return static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsText); -} -FX_BOOL CXFA_FFMenuHandler::Cut(IXFA_Widget* hWidget, CFX_WideString& wsText) { - return static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsText); -} -FX_BOOL CXFA_FFMenuHandler::Paste(IXFA_Widget* hWidget, - const CFX_WideString& wsText) { - return static_cast<CXFA_FFWidget*>(hWidget)->Paste(wsText); -} -FX_BOOL CXFA_FFMenuHandler::SelectAll(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->SelectAll(); -} -FX_BOOL CXFA_FFMenuHandler::Delete(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->Delete(); -} -FX_BOOL CXFA_FFMenuHandler::DeSelect(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->DeSelect(); -} -FX_BOOL CXFA_FFMenuHandler::CanUndo(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanUndo(); -} -FX_BOOL CXFA_FFMenuHandler::CanRedo(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->CanRedo(); -} -FX_BOOL CXFA_FFMenuHandler::Undo(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->Undo(); -} -FX_BOOL CXFA_FFMenuHandler::Redo(IXFA_Widget* hWidget) { - return static_cast<CXFA_FFWidget*>(hWidget)->Redo(); -} -FX_BOOL CXFA_FFMenuHandler::GetSuggestWords( - IXFA_Widget* hWidget, - CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest) { - return static_cast<CXFA_FFWidget*>(hWidget) - ->GetSuggestWords(pointf, sSuggest); -} -FX_BOOL CXFA_FFMenuHandler::ReplaceSpellCheckWord( - IXFA_Widget* hWidget, - CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return static_cast<CXFA_FFWidget*>(hWidget) - ->ReplaceSpellCheckWord(pointf, bsReplace); -} diff --git a/xfa/src/fxfa/app/xfa_ffwidgethandler.h b/xfa/src/fxfa/app/xfa_ffwidgethandler.h deleted file mode 100644 index 73de9e2c94..0000000000 --- a/xfa/src/fxfa/app/xfa_ffwidgethandler.h +++ /dev/null @@ -1,176 +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_SRC_FXFA_APP_XFA_FFWIDGETHANDLER_H_ -#define XFA_SRC_FXFA_APP_XFA_FFWIDGETHANDLER_H_ - -#include <vector> - -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fxfa/parser/xfa_document.h" - -class CXFA_FFDocView; - -class CXFA_FFWidgetHandler : public IXFA_WidgetHandler { - public: - CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView); - ~CXFA_FFWidgetHandler(); - virtual IXFA_Widget* CreateWidget(IXFA_Widget* hParent, - XFA_WIDGETTYPE eType, - IXFA_Widget* hBefore = NULL); - virtual IXFA_PageView* GetPageView(IXFA_Widget* hWidget); - virtual void GetRect(IXFA_Widget* hWidget, CFX_RectF& rt); - virtual FX_DWORD GetStatus(IXFA_Widget* hWidget); - virtual FX_BOOL GetBBox(IXFA_Widget* hWidget, - CFX_RectF& rtBox, - FX_DWORD dwStatus, - FX_BOOL bDrawFocus = FALSE); - virtual CXFA_WidgetAcc* GetDataAcc(IXFA_Widget* hWidget); - virtual void GetName(IXFA_Widget* hWidget, - CFX_WideString& wsName, - int32_t iNameType = 0); - virtual FX_BOOL GetToolTip(IXFA_Widget* hWidget, CFX_WideString& wsToolTip); - virtual void SetPrivateData(IXFA_Widget* hWidget, - void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback); - virtual void* GetPrivateData(IXFA_Widget* hWidget, void* module_id); - virtual FX_BOOL OnMouseEnter(IXFA_Widget* hWidget); - virtual FX_BOOL OnMouseExit(IXFA_Widget* hWidget); - virtual FX_BOOL OnLButtonDown(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnLButtonUp(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnLButtonDblClk(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnMouseMove(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnMouseWheel(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDown(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonUp(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL OnRButtonDblClk(IXFA_Widget* hWidget, - FX_DWORD dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); - - virtual FX_BOOL OnKeyDown(IXFA_Widget* hWidget, - FX_DWORD dwKeyCode, - FX_DWORD dwFlags); - virtual FX_BOOL OnKeyUp(IXFA_Widget* hWidget, - FX_DWORD dwKeyCode, - FX_DWORD dwFlags); - virtual FX_BOOL OnChar(IXFA_Widget* hWidget, - FX_DWORD dwChar, - FX_DWORD dwFlags); - virtual FX_DWORD OnHitTest(IXFA_Widget* hWidget, FX_FLOAT fx, FX_FLOAT fy); - virtual FX_BOOL OnSetCursor(IXFA_Widget* hWidget, FX_FLOAT fx, FX_FLOAT fy); - virtual void RenderWidget(IXFA_Widget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix = NULL, - FX_BOOL bHighlight = FALSE); - virtual FX_BOOL HasEvent(CXFA_WidgetAcc* pWidgetAcc, - XFA_EVENTTYPE eEventType); - virtual int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, - CXFA_EventParam* pParam); - - protected: - CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - - CXFA_Node* CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateField(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDraw(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - - CXFA_Node* CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateFormItem(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateCopyNode(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore = NULL) const; - CXFA_Node* CreateTemplateNode(XFA_ELEMENT eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateFontNode(CXFA_Node* pParent) const; - CXFA_Node* CreateMarginNode(CXFA_Node* pParent, - FX_DWORD dwFlags, - FX_FLOAT fInsets[4]) const; - CXFA_Node* CreateValueNode(XFA_ELEMENT eValue, CXFA_Node* pParent) const; - IXFA_ObjFactory* GetObjFactory() const; - CXFA_Document* GetXFADoc() const; - - CXFA_FFDocView* m_pDocView; -}; - -class CXFA_FFMenuHandler : public IXFA_MenuHandler { - public: - CXFA_FFMenuHandler(); - ~CXFA_FFMenuHandler(); - virtual FX_BOOL CanCopy(IXFA_Widget* hWidget); - virtual FX_BOOL CanCut(IXFA_Widget* hWidget); - virtual FX_BOOL CanPaste(IXFA_Widget* hWidget); - virtual FX_BOOL CanSelectAll(IXFA_Widget* hWidget); - virtual FX_BOOL CanDelete(IXFA_Widget* hWidget); - virtual FX_BOOL CanDeSelect(IXFA_Widget* hWidget); - virtual FX_BOOL Copy(IXFA_Widget* hWidget, CFX_WideString& wsText); - virtual FX_BOOL Cut(IXFA_Widget* hWidget, CFX_WideString& wsText); - virtual FX_BOOL Paste(IXFA_Widget* hWidget, const CFX_WideString& wsText); - virtual FX_BOOL SelectAll(IXFA_Widget* hWidget); - virtual FX_BOOL Delete(IXFA_Widget* hWidget); - virtual FX_BOOL DeSelect(IXFA_Widget* hWidget); - virtual FX_BOOL CanUndo(IXFA_Widget* hWidget); - virtual FX_BOOL CanRedo(IXFA_Widget* hWidget); - virtual FX_BOOL Undo(IXFA_Widget* hWidget); - virtual FX_BOOL Redo(IXFA_Widget* hWidget); - virtual FX_BOOL GetSuggestWords(IXFA_Widget* hWidget, - CFX_PointF pointf, - std::vector<CFX_ByteString>& sSuggest); - virtual FX_BOOL ReplaceSpellCheckWord(IXFA_Widget* hWidget, - CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FFWIDGETHANDLER_H_ diff --git a/xfa/src/fxfa/app/xfa_fontmgr.cpp b/xfa/src/fxfa/app/xfa_fontmgr.cpp deleted file mode 100644 index 3c7b1cba74..0000000000 --- a/xfa/src/fxfa/app/xfa_fontmgr.cpp +++ /dev/null @@ -1,2089 +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/src/fxfa/app/xfa_fontmgr.h" - -#include <algorithm> - -#include "core/include/fpdfapi/cpdf_dictionary.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfapi/fpdf_resource.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -static const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"Arial", 0, 936}, - {0x01e4f102, L"YouYuan", L"Arial", 1, 936}, - {0x030549dc, L"LiSu", L"Arial", 1, 936}, - {0x032edd44, L"Simhei", L"Arial", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", L"Arial", 2, 1252}, - {0x03ed90e6, L"Nina", L"Arial", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", L"Arial", 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Arial", 0, 1252}, - {0x089b18a9, L"Arial", L"Arial", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Arial", 8, 1252}, - {0x0bb003e7, L"Kartika", L"Arial", 2, 1252}, - {0x0bb469df, L"VinerHandITC", L"Arial", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Arial", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"Arial", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Kokila,Arial Narrow", 0, 847}, - {0x0e7de0f9, L"Playbill", L"Arial", 0, 1252}, - {0x0eff47c3, L"STHupo", L"Arial", 0, 936}, - {0x107ad374, L"Constantia", L"Arial", 2, 1252}, - {0x12194c2d, L"KunstlerScript", L"Arial", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0x158c4049, L"Garamond", L"Arial", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"Arial", 0, 936}, - {0x161ed07e, L"MSGothic", L"Arial", 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", L"Arial", 0, 1252}, - {0x18d1188f, L"Cambria", L"Arial", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Arial", 0, 936}, - {0x1a92d115, L"MingLiU", L"Arial", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", L"Arial", 0, 1252}, - {0x1d649596, L"BasemicTimes", L"Arial", 0, 1252}, - {0x1e34ee60, L"BellMT", L"Arial", 2, 1252}, - {0x1eb36945, L"CooperBlack", L"Arial", 2, 1252}, - {0x1ef7787d, L"BatangChe", L"Arial", 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", L"Arial", 8, 1252}, - {0x220877aa, L"Candara", L"Arial", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", L"Arial", 8, 1252}, - {0x251059c3, L"Chiller", L"Arial", 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", L"Arial", 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Arial", 8, 1252}, - {0x29711eb9, L"STLiti", L"Arial", 0, 936}, - {0x2b1993b4, L"Basemic", L"Arial", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Arial", 0, 1252}, - {0x2c147529, L"FootlightMTLight", L"Arial", 0, 1252}, - {0x2c198928, L"HarlowSolid", L"Arial", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", L"Arial", 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Arial", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Arial", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", L"Arial", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"Arial", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", L"Arial", 0, 1252}, - {0x31327817, L"MyriadPro", - L"Calibri,Corbel,Candara,Cambria Math,Franklin Gothic Medium,Arial " - L"Narrow,Times New Roman", - 0, 1252}, - {0x32244975, L"Helvetica", L"Arial", 0, 1252}, - {0x32ac995c, L"Terminal", L"Arial", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Arial", 0, 1252}, - {0x33bb65f2, L"Sylfaen", L"Arial", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Arial", 2, 1252}, - {0x3412bf31, L"SimSun-PUA", L"Arial", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", L"Arial", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"Arial", 2, 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Arial", 0, 1252}, - {0x3cdae668, L"FreestyleScript", L"Arial", 8, 1252}, - {0x3d55aed7, L"Jokerman", L"Arial", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Arial", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"Arial", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Arial", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"Arial", 1, 936}, - {0x3f6c36a8, L"Gautami", L"Arial", 0, 1252}, - {0x3ff32662, L"Chiller-Regular", L"Arial", 0, 1252}, - {0x409de312, L"ModernNo.20", L"Arial", 2, 1252}, - {0x41443c5e, L"Georgia", L"Arial", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", - L"Arial,Arial Unicode MS,Book Antiqua,Dotum,Georgia", 0, 1252}, - {0x421976c4, L"Modern-Regular", L"Arial", 2, 1252}, - {0x422a7252, L"Stencil", L"Arial", 0, 1252}, - {0x42c8554f, L"Fixedsys", L"Arial", 0, 1252}, - {0x435cb41d, L"Roman", L"Arial", 0, 1252}, - {0x47882383, L"CourierNew", L"Arial", 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", L"Arial", 0, 1252}, - {0x480bf7a4, L"CourierStd", L"Courier New,Verdana", 0, 1252}, - {0x481ad6ed, L"VladimirScript", L"Arial", 8, 1252}, - {0x4911577a, L"YouYuan", L"Arial", 1, 936}, - {0x4a788d72, L"STXingkai", L"Arial", 0, 936}, - {0x4bf88566, L"SegoeCondensed", L"Arial", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", L"Arial", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Arial", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", L"Courier New,Verdana", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"Arial", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", L"Arial", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", L"Arial", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"Arial", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", L"Arial", 0, 1252}, - {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, - {0x5792e759, L"STKaiti", L"Arial", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Arial", 0, 1252}, - {0x594e2da4, L"Vrinda", L"Arial", 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Arial", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", L"Arial", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"Batang,Bookman Old Style,Consolas,STZhongsong", 0, 936}, - {0x5fefbfad, L"Batang", L"Arial", 2, 1252}, - {0x605342b9, L"DotumChe", L"Arial", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Arial", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", L"Arial", 0, 1252}, - {0x626608a9, L"MVBoli", L"Arial", 0, 1252}, - {0x630501a3, L"SmallFonts", L"Arial", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"Arial", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"Arial", 0, 936}, - {0x673a9e5f, L"Tunga", L"Arial", 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Arial", 0, 1252}, - {0x696259b7, L"Corbel", L"Arial", 0, 1252}, - {0x696ee9be, L"STXihei", L"Arial", 0, 936}, - {0x6c59cf69, L"Dotum", L"Arial", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Arial", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", L"Arial", 0, 1252}, - {0x71b41801, L"Verdana", L"Arial", 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Arial", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Arial", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Arial", 0, 1252}, - {0x74cb44ee, L"NSimSun", L"Arial", 1, 936}, - {0x76b4d7ff, L"Shruti", L"Arial", 0, 1252}, - {0x788b3533, L"Webdings", L"Arial", 6, 42}, - {0x797dde99, L"MSSerif", L"Arial", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", L"Arial", 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", L"Arial", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", L"Arial", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", - L"Centaur,Calibri,STSong,Bell MT,Garamond,Times New Roman", 0, 936}, - {0x83581825, L"Modern", L"Arial", 0, 1252}, - {0x835a2823, L"Algerian", L"Arial", 0, 1252}, - {0x83dab9f5, L"Script", L"Arial", 0, 1252}, - {0x847b56da, L"Tahoma", L"Arial", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"Arial", 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Arial", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Arial", 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Arial", 0, 1252}, - {0x8e8d43b2, L"Centaur", L"Arial", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Arial", 0, 1252}, - {0x90794800, L"BellGothicStdLight", L"Bell MT,Calibri,Times New Roman", 0, - 1252}, - {0x909b516a, L"Century", L"Arial", 2, 1252}, - {0x92ae370d, L"MSOutlook", L"Arial", 4, 42}, - {0x93c9fbf1, L"LucidaFax", L"Arial", 2, 1252}, - {0x9565085e, L"BookAntiqua", L"Arial", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"Arial,Arial Unicode MS,Cambria,BatangChe", - 0, 949}, - {0x9bbadd6b, L"ColonnaMT", L"Arial", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", L"Arial", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"Arial", 0, 1252}, - {0xa0607db1, L"GungsuhChe", L"Arial", 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"Arial", 2, 1252}, - {0xa1429b36, L"Symbol", L"Arial", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"Arial", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"Arial", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", L"Arial", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"Arial", 0, 936}, - {0xa8d83ece, L"CalifornianFB", L"Arial", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", L"Arial", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", L"Arial", 0, 1252}, - {0xade5337c, L"MSUIGothic", L"Arial", 0, 1252}, - {0xb08dd941, L"WideLatin", L"Arial", 2, 1252}, - {0xb207f05d, L"PoorRichard", L"Arial", 2, 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Arial", 0, 1252}, - {0xb5545399, L"Marlett", L"Arial", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", L"Arial", 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", L"Arial", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Arial", 2, 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Batang,Century,Dotum", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Arial", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"Arial", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", L"Bell MT,Berlin Sans FB,Calibri", 0, 1252}, - {0xc318b0af, L"MyriadProLight", L"Calibri,STFangsong,Times New Roman", 0, - 1252}, - {0xc65e5659, L"CambriaMath", L"Arial", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", L"Arial", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Arial", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Arial", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", L"Arial", 0, 1252}, - {0xcca00cc5, L"System", L"Arial", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Arial", 0, 1252}, - {0xccc5818c, L"EuroSign", L"Arial", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", L"Arial", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0xcfe5755f, L"Simhei", L"Arial", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Arial", 0, 1252}, - {0xd060e7ef, L"Vivaldi", L"Arial", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Arial", 0, 1252}, - {0xd107243f, L"SimSun", L"Arial", 0, 936}, - {0xd1881562, L"ArialNarrow", L"Arial Narrow", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", L"Arial", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", L"Arial", 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", L"Arial", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Arial", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", L"Arial", 0, 1252}, - {0xd8e8a027, L"LucidaSans", L"Arial", 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", L"Arial", 2, 1252}, - {0xda7e551e, L"STSong", L"Arial", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"Arial", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Arial", 0, 936}, - {0xdaeb0713, L"STSong", L"Arial", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Arial", 0, 936}, - {0xdb00a3d9, L"Broadway", L"Arial", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Arial", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Arial", 0, 936}, - {0xdb69595a, L"STHupo", L"Arial", 0, 936}, - {0xdba0082c, L"STXihei", L"Arial", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Arial", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Arial", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", L"Arial", 8, 1252}, - {0xdcc7009c, L"Harrington", L"Arial", 0, 1252}, - {0xdd712466, L"ArialBlack", L"Arial", 0, 1252}, - {0xdde87b3e, L"Impact", L"Arial", 0, 1252}, - {0xdf69fb32, L"SnapITC", L"Arial", 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", L"Arial", 0, 1252}, - {0xe0f705c0, L"KristenITC", L"Arial", 8, 1252}, - {0xe1427573, L"Raavi", L"Arial", 0, 1252}, - {0xe2cea0cb, L"Magneto", L"Arial", 0, 1252}, - {0xe36a9e17, L"Ravie", L"Arial", 0, 1252}, - {0xe433f8e2, L"Parchment", L"Arial", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"Arial", 4, 42}, - {0xe4e2c405, L"MTExtra", L"Arial", 6, 42}, - {0xe618cc35, L"InformalRoman", L"Arial", 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Arial", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"Arial", 0, 1252}, - {0xe90fb013, L"TempusSansITC", L"Arial", 0, 1252}, - {0xec637b42, L"Consolas", L"Verdana", 1, 1252}, - {0xed3a683b, L"STXinwei", L"Arial", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", L"Arial", 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", L"Arial", 0, 1252}, - {0xf1028030, L"Mangal", L"Arial", 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", L"Arial", 0, 1252}, - {0xf210f06a, L"ArialMT", L"Arial", 0, 1252}, - {0xf477f16a, L"Latha", L"Arial", 0, 1252}, - {0xf616f3dd, L"LiSu", L"Arial", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Arial", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", L"Arial", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", L"Arial", 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Batang,Century,Dotum", 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ -static const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 0, 936}, - {0x01e4f102, L"YouYuan", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 1, 936}, - {0x030549dc, L"LiSu", - L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " - L"Mono,WenQuanYi Micro Hei", - 1, 936}, - {0x032edd44, L"Simhei", - L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " - L"Mono,WenQuanYi Micro Hei", - 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", L"Droid Sans Japanese,FreeSerif", 2, - 1252}, - {0x03ed90e6, L"Nina", L"FreeSerif", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans Thai,Droid Sans " - L"Armenian,Untitled1,utkal,Lohit Oriya", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", - L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei", 0, 1252}, - {0x089b18a9, L"Arial", - L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif,WenQuanYi Micro Hei", - 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Droid Sans Japanese,FreeSerif", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"FreeSans,Liberation Sans,Liberation Sans Narrow,Nimbus Sans " - L"L,Garuda,FreeSerif,WenQuanYi Micro Hei", - 2, 1252}, - {0x0bb469df, L"VinerHandITC", - L"Droid Sans Japanese,Ubuntu,Liberation Sans,Liberation Serif", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"FreeSerif", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Droid Sans Japanese,Waree", 0, 847}, - {0x0e7de0f9, L"Playbill", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Ethiopic,Droid Sans Japanese,FreeSerif", - 0, 1252}, - {0x0eff47c3, L"STHupo", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0x107ad374, L"Constantia", - L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei,Ubuntu", 2, 1252}, - {0x12194c2d, L"KunstlerScript", L"Droid Sans Japanese,Liberation Serif", 8, - 1252}, - {0x135ef6a1, L"MinionProSmBd", L"Liberation Serif", 0, 1252}, - {0x158c4049, L"Garamond", - L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 2, 1252}, - {0x160ecb24, L"STZhongsong", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x161ed07e, L"MSGothic", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,AR PL " - L"UMing CN,AR PL UMing HK,AR PL UMing TW", - 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Sans", 0, - 1252}, - {0x18d1188f, L"Cambria", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, - 1252}, - {0x18eaf350, L"ArialUnicodeMS", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x1a92d115, L"MingLiU", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", - L"Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, 1252}, - {0x1d649596, L"BasemicTimes", - L"Liberation Serif,Times New Roman,Droid Sans Japanese,FreeSerif,Ubuntu", - 0, 1252}, - {0x1e34ee60, L"BellMT", - L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"KacstQurn,Droid Sans Japanese,FreeMono,Liberation Mono, WenQuanYi Micro " - L"Hei Mono", - 2, 1252}, - {0x1ef7787d, L"BatangChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " - L"TW,WenQuanYi Zen Hei,WenQuanYi Micro Hei", - 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Japanese,URW Chancery L,Liberation Sans", - 8, 1252}, - {0x220877aa, L"Candara", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 8, 1252}, - {0x251059c3, L"Chiller", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Japanese,Liberation Sans", - 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", - L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,AR PL UKai " - L"HK", - 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Droid Sans Japanese,Liberation Sans", - 8, 1252}, - {0x29711eb9, L"STLiti", L"AR PL UKai HK", 0, 936}, - {0x2b1993b4, L"Basemic", - L"Liberation Serif,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Droid Sans Japanese,Liberation Sans", 0, - 1252}, - {0x2c147529, L"FootlightMTLight", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,Liberation Sans", - 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"DejaVu Sans", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"AR PL UKai HK", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"KacstQurn,Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"DejaVu Serif", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x31327817, L"MyriadPro", - L"Ubuntu Condensed,Droid Sans Japanese, FreeSerif", 0, 1252}, - {0x32244975, L"Helvetica", - L"Ubuntu,DejaVu Sans Condensed,Liberation Sans,Liberation Sans " - L"Narrow,Nimbus Sans L", - 0, 1252}, - {0x32ac995c, L"Terminal", L"DejaVu Serif", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Droid Sans Japanese,DejaVu Serif", 0, - 1252}, - {0x33bb65f2, L"Sylfaen", L"Droid Sans Japanese,DejaVu Sans", 2, 1252}, - {0x3402c30e, L"MSPMincho", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 2, - 1252}, - {0x3412bf31, L"SimSun-PUA", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing CN,AR PL UMing HK", 0, - 936}, - {0x36eb39b9, L"BerlinSansFB", - L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"Droid Sans Japanese,DejaVu Serif", 2, - 1252}, - {0x3a257d03, L"FangSong_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei", 0, 1252}, - {0x3c7d1d07, L"Garamond3LTStd", - L"Droid Sans Japanese,Ubuntu Condensed,DejaVu Sans Condensed,Liberation " - L"Serif,Ubuntu,FreeSerif", - 2, 1252}, - {0x3cdae668, L"FreestyleScript", - L"KacstQurn,Droid Sans Japanese,DejaVu Sans", 8, 1252}, - {0x3d55aed7, L"Jokerman", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x3d5b4385, L"PMingLiU", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Droid Sans Japanese,Ubuntu", 0, - 1252}, - {0x3e6aa32d, L"NSimSun", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Droid Arabic Naskh,Droid Sans Ethiopic, mry_KacstQurn,Droid Sans " - L"Japanese,FreeSans", - 0, 1252}, - {0x3ff32662, L"Chiller-Regular", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,FreeSans", 0, 1252}, - {0x409de312, L"ModernNo.20", - L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,Nimbus Sans L,FreeSans", 2, - 1252}, - {0x41443c5e, L"Georgia", L"Droid Sans Japanese,FreeSans", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", L"FreeSans", 0, 1252}, - {0x421976c4, L"Modern-Regular", L"FreeSans", 2, 1252}, - {0x422a7252, L"Stencil", L"Droid Sans Japanese,FreeSans,Liberation Sans", 0, - 1252}, - {0x42c8554f, L"Fixedsys", L"FreeSerif", 0, 1252}, - {0x435cb41d, L"Roman", L"FreeSerif", 0, 1252}, - {0x47882383, L"CourierNew", - L"FreeMono,WenQuanYi Micro Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL " - L"UKai TW,AR PL UKai TW MBE,DejaVu Sans", - 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0x480bf7a4, L"CourierStd", L"DejaVu Sans", 0, 1252}, - {0x481ad6ed, L"VladimirScript", L"Droid Sans Japanese,DejaVu Serif", 8, - 1252}, - {0x4911577a, L"YouYuan", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, - 936}, - {0x4a788d72, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0x4bf88566, L"SegoeCondensed", L"FreeSerif", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0x4ea967ce, L"GulimChe", - L"WenQuanYi Zen Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL " - L"UKai TW MBE", - 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"FreeMono,Liberation Mono,Andale Mono,WenQuanYi Micro Hei Mono", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"FreeSerif", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", L"FreeSerif", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"Droid Sans Japanese,URW Chancery L,FreeSerif", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", - L"Ubuntu Mono,DejaVu Sans Mono,Nimbus Mono L,Liberation Mono,Courier 10 " - L"Pitch,FreeMono", - 0, 1252}, - {0x574d4d3d, L"AdobeArabic", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x5792e759, L"STKaiti", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0x594e2da4, L"Vrinda", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Arabic " - L"Naskh,mry_KacstQurn,Droid Sans Japanese,FreeSans,FreeSerif", - 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 0, 1252}, - {0x5e16ac91, L"TrajanPro", - L"Nimbus Sans L,AR PL UMing HK,AR PL UKai HK,AR PL UMing TW,AR PL UMing " - L"TW MBE,DejaVu Sans,DejaVu Serif", - 0, 1252}, - {0x5f388196, L"ITCLegacySansStdMedium", - L"Liberation Serif,FreeSerif,FreeSans,Ubuntu", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x5fefbfad, L"Batang", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 2, 1252}, - {0x605342b9, L"DotumChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, - 1252}, - {0x608c5f9a, L"KaiTi_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif,DejaVu Sans", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Ethiopic,Droid Sans Japanese,DejaVu Sans", - 0, 1252}, - {0x630501a3, L"SmallFonts", L"DejaVu Serif", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", - L"AR PL UMing CN,AR PL UKai CN, AR PL UMing HK", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,DejaVu Serif", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0x696259b7, L"Corbel", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x696ee9be, L"STXihei", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0x6c59cf69, L"Dotum", L"WenQuanYi Zen Hei Mono", 0, 1252}, - {0x707fa561, L"Gungsuh", L"WenQuanYi Zen Hei Mono", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"KacstArt,KacstBookm,KacstDecorative,KacstDigital,KacstFarsi,KacstLetter," - L"KacstOffice,Dingbats,FreeSerif", - 0, 1252}, - {0x71b41801, L"Verdana", - L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,DejaVu Sans", - 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Japanese,FreeSerif", 0, - 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Droid Sans Japanese,FreeSerif", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Droid Sans Japanese,AR PL UKai HK", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Droid Sans Japanese,DejaVu Serif", 0, - 1252}, - {0x74cb44ee, L"NSimSun", L"WenQuanYi Zen Hei Mono", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,FreeSans", - 0, 1252}, - {0x788b3533, L"Webdings", L"FreeSans", 6, 42}, - {0x797dde99, L"MSSerif", L"FreeSans", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", - L"WenQuanYi Micro Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", - 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Ubuntu Mono,Liberation Mono,DejaVu Sans Mono", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x83581825, L"Modern", L"FreeSans", 0, 1252}, - {0x835a2823, L"Algerian", - L"KacstQurn,Droid Sans Japanese,FreeSans,Liberation Sans,Ubuntu", 0, 1252}, - {0x83dab9f5, L"Script", L"FreeSans", 0, 1252}, - {0x847b56da, L"Tahoma", - L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x8c6a499e, L"Gulim", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x8e8d43b2, L"Centaur", - L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Liberation Sans", 0, 1252}, - {0x90794800, L"BellGothicStdLight", L"Liberation Sans", 0, 1252}, - {0x909b516a, L"Century", - L"Droid Sans Japanese,Liberation Sans,Liberation Mono,Liberation Serif", 2, - 1252}, - {0x92ae370d, L"MSOutlook", L"Liberation Sans", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"KacstQurn,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,Liberation Sans", - 2, 1252}, - {0x9565085e, L"BookAntiqua", - L"Droid Sans Japanese,Liberation Sans,Liberation Serif", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"AR PL UMing HK", 0, 949}, - {0x9bbadd6b, L"ColonnaMT", - L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"FreeSerif", 0, 1252}, - {0xa0607db1, L"GungsuhChe", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"FreeSerif", 2, 1252}, - {0xa1429b36, L"Symbol", L"FreeSerif", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"FreeSerif", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"FreeSerif", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,FreeSerif", - 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"AR PL UMing CN", 0, 936}, - {0xa8d83ece, L"CalifornianFB", L"Droid Sans Japanese,FreeSerif", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans " - L"Thai,utkal,Kedage,Mallige,AR PL UKai CN", - 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"KacstQurn,Droid Sans Japanese,Liberation Serif", 0, 1252}, - {0xade5337c, L"MSUIGothic", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0xb08dd941, L"WideLatin", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,Liberation Serif", - 2, 1252}, - {0xb12765e0, L"ITCLegacySansStdBook", - L"AR PL UMing HK,AR PL UKai HK,FreeSerif,Ubuntu,FreeSans", 0, 1252}, - {0xb207f05d, L"PoorRichard", L"Droid Sans Japanese,Liberation Serif", 2, - 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0xb5545399, L"Marlett", L"Liberation Serif", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", - L"KacstQurn,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,Liberation Serif", - 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif", - 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Droid Sans Japanese,Liberation Sans", 2, - 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Droid Sans Japanese,DejaVu Serif", - 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"DejaVu Sans", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", L"Droid Sans Japanese,Ubuntu,Liberation Serif", - 0, 1252}, - {0xc318b0af, L"MyriadProLight", - L"Droid Sans Japanese,AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 1252}, - {0xc65e5659, L"CambriaMath", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, - 1252}, - {0xc75c8f05, L"LucidaConsole", - L"Liberation Mono,DejaVu Sans Mono,FreeMono,WenQuanYi Micro Hei Mono", 1, - 1252}, - {0xca7c35d6, L"Calibri", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xcb7190f9, L"Magneto-Bold", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,DejaVu Serif", - 0, 1252}, - {0xcca00cc5, L"System", L"DejaVu Sans", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0xccc5818c, L"EuroSign", L"DejaVu Serif", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Serif", 0, - 1252}, - {0xcf7b8fdb, L"MinionPro", L"DejaVu Sans", 0, 1252}, - {0xcfe5755f, L"Simhei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 936}, - {0xd011f4ee, L"MSPGothic", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 0, - 1252}, - {0xd060e7ef, L"Vivaldi", - L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Droid Sans Japanese,Ubuntu", 0, - 1252}, - {0xd107243f, L"SimSun", L"WenQuanYi Zen Hei Mono", 0, 936}, - {0xd1881562, L"ArialNarrow", - L"Liberation Sans Narrow,Droid Sans Japanese,FreeSerif", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", - L"Droid Sans Japanese,FreeMono,Liberation Mono", 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,URW Chancery " - L"L,KacstOne,Liberation Sans", - 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Liberation Sans Narrow,Nimbus Sans L,KacstQurn,Droid Arabic Naskh,Droid " - L"Sans Ethiopic,DejaVu Serif Condensed,Liberation Mono,Ubuntu", - 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, - {0xda7e551e, L"STSong", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0xdaa6842d, L"STZhongsong", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xdaaab93f, L"STFangsong", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdaeb0713, L"STSong", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdafedbef, L"STCaiyun", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdb00a3d9, L"Broadway", - L"KacstQurn,Droid Sans Japanese,DejaVu Sans,FreeMono,Liberation Mono", 0, - 1252}, - {0xdb1f5ad4, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdb326e7f, L"STKaiti", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdb69595a, L"STHupo", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdba0082c, L"STXihei", - L" WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdbd0ab18, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdc1a7db1, L"STLiti", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdc33075f, L"KristenITC-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " - L"Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xdcc7009c, L"Harrington", - L"KacstQurn,Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, - 1252}, - {0xdd712466, L"ArialBlack", - L"Droid Sans Japanese,DejaVu Sans,DejaVu Serif,FreeMono", 0, 1252}, - {0xdde87b3e, L"Impact", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Liberation Sans Narrow,Ubuntu Condensed,DejaVu Sans,DejaVu " - L"Serif,FreeMono", - 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, - 1252}, - {0xe0f705c0, L"KristenITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " - L"Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xe1427573, L"Raavi", - L"Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,FreeSerif,Liberation Serif,Khmer OS", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " - L"Serif,DejaVu Serif Condensed,DejaVu Sans", - 0, 1252}, - {0xe36a9e17, L"Ravie", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " - L"Serif,DejaVu Sans,FreeMono", - 0, 1252}, - {0xe433f8e2, L"Parchment", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"DejaVu Serif", 4, 42}, - {0xe4e2c405, L"MTExtra", L"DejaVu Serif", 6, 42}, - {0xe618cc35, L"InformalRoman", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,Nimbus Sans L,DejaVu Sans Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"DejaVu Sans,DejaVu Sans Condensed,FreeSerif", 0, - 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"DejaVu Serif", 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"Droid Sans Japanese,Ubuntu,Liberation Serif,FreeSerif", 0, 1252}, - {0xec637b42, L"Consolas", - L"DejaVu Sans Condensed,AR PL UKai CN,AR PL UKai HK,AR PL UKai " - L"TW,FreeSerif,FreeSans", - 1, 1252}, - {0xed3a683b, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans " - L"L,KacstQurn,Liberation Mono", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"KacstQurn,Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, - 1252}, - {0xf1028030, L"Mangal", - L"FreeSans,TSCu_Paranar,Garuda,Liberation Sans,Liberation Sans " - L"Narrow,Nimbus Sans L", - 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Droid Sans Japanese,DejaVu Serif Condensed,DejaVu Sans " - L"Condensed,Liberation Sans,Ubuntu", - 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Liberation Sans,Liberation Sans Narrow,FreeSans,Nimbus Sans L,Khmer OS " - L"System,Khmer OS", - 0, 1252}, - {0xf477f16a, L"Latha", - L"Liberation Sans Narrow,Nimbus Sans L,Droid Arabic " - L"Naskh,mry_KacstQurn,FreeSerif,Nimbus Sans L", - 0, 1252}, - {0xf616f3dd, L"LiSu", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, - 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif,DejaVu Sans,FreeMono", - 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ -static const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0x01e4f102, L"YouYuan", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x030549dc, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x032edd44, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", - L"Noteworthy,Avenir Next Condensed,Impact", 2, 1252}, - {0x03ed90e6, L"Nina", L"Microsoft Sans Serif", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"LastResort,Apple " - L"Chancery,STIXVariants,STIXSizeOneSym,STIXSizeOneSym,Apple Braille", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, - {0x089b18a9, L"Arial", - L"Arial Unicode MS,Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Arial Narrow,Impact", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Damascus", 2, 1252}, - {0x0bb469df, L"VinerHandITC", L"Comic Sans MS,Songti SC,STSong", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Apple Symbols", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Avenir Next Condensed Ultra Light", 0, 847}, - {0x0e7de0f9, L"Playbill", L"STIXNonUnicode", 0, 1252}, - {0x0eff47c3, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0x107ad374, L"Constantia", L"Arial Unicode MS,Palatino,Baskerville", 2, - 1252}, - {0x12194c2d, L"KunstlerScript", - L"Avenir Next Condensed Demi Bold,Arial Narrow", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x158c4049, L"Garamond", L"Impact,Arial Narrow", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"STFangsong,Songti SC", 0, 936}, - {0x161ed07e, L"MSGothic", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " - L"TW,Microsoft Sans Serif,Apple Symbols", - 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", L"STHeiti,Arial Black", 0, 1252}, - {0x18d1188f, L"Cambria", L"Arial Unicode MS", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Microsoft Sans Serif,Apple Symbols", 0, - 936}, - {0x1a92d115, L"MingLiU", L"Heiti SC,STHeiti", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", L"Damascus,Impact,Arial Narrow", 0, 1252}, - {0x1d649596, L"BasemicTimes", L"Liberation Serif,Impact,Arial Narrow", 0, - 1252}, - {0x1e34ee60, L"BellMT", - L"Papyrus,STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"Marion,STIXNonUnicode,Arial Rounded MT Bold,Lucida Grande", 2, 1252}, - {0x1ef7787d, L"BatangChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Heiti TC", - 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", - L"STIXNonUnicode,Damascus,Arial Narrow,Avenir Next Condensed,Cochin", 8, - 1252}, - {0x220877aa, L"Candara", L"Cochin,Baskerville,Marion", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"STIXNonUnicode,Nadeem,Zapf Dingbats", 8, 1252}, - {0x251059c3, L"Chiller", - L"Zapf Dingbats,Damascus,STIXNonUnicode,Papyrus,KufiStandardGK,Baghdad", 0, - 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", - L"Tahoma,Apple Symbols,Apple LiGothic,Arial Unicode MS,Lucida " - L"Grande,Microsoft Sans Serif", - 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Microsoft Sans Serif,Apple Symbols", 8, - 1252}, - {0x29711eb9, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, - {0x2b1993b4, L"Basemic", L"Impact,Arial Narrow", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x2c147529, L"FootlightMTLight", - L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans,Noteworthy", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"PT Sans Narrow,Papyrus,Damascus,STIXNonUnicode,Arial Rounded MT " - L"Bold,Comic Sans MS,Avenir Next", - 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Kaiti SC,Songti SC", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"Impact,Avenir Next Condensed Demi Bold,American Typewriter", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x3115525a, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x31327817, L"MyriadPro", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x32244975, L"Helvetica", - L"Arial Narrow,Arial Unicode MS,Damascus,STIXNonUnicode", 0, 1252}, - {0x32ac995c, L"Terminal", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x33bb65f2, L"Sylfaen", L"Arial Unicode MS,Marion", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Arial Unicode MS,Apple SD Gothic Neo", 2, - 1252}, - {0x3412bf31, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", L"American Typewriter,Impact", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"STIXGeneral,.Helvetica Neue Desk UI", 2, - 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x3cdae668, L"FreestyleScript", L"Nadeem,Zapf Dingbats,STIXNonUnicode", 8, - 1252}, - {0x3d55aed7, L"Jokerman", - L"Papyrus,Lucida Grande,Heiti TC,American Typewriter", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Heiti SC,STHeiti", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"American Typewriter,Marion", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Impact,Arial Narrow", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"STHeiti,STFangsong", 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Damascus,STIXNonUnicode,STIXGeneral,American Typewriter", 0, 1252}, - {0x3ff32662, L"Chiller-Regular", L"Papyrus,KufiStandardGK,Baghdad", 0, - 1252}, - {0x409de312, L"ModernNo.20", L"Avenir Next Condensed,Impact", 2, 1252}, - {0x41443c5e, L"Georgia", L".Helvetica Neue Desk UI,Arial Unicode MS", 2, - 1252}, - {0x4160ade5, L"BellGothicStdBlack", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x421976c4, L"Modern-Regular", L"Impact", 2, 1252}, - {0x422a7252, L"Stencil", L"STIXNonUnicode,Songti SC,Georgia,Baskerville", 0, - 1252}, - {0x42c8554f, L"Fixedsys", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x435cb41d, L"Roman", L"Arial Narrow", 0, 1252}, - {0x47882383, L"CourierNew", L"PCMyungjo,Osaka,Arial Unicode MS,Songti SC", - 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", - L"STIXNonUnicode,American Typewriter,Avenir Next Condensed Heavy", 0, - 1252}, - {0x480bf7a4, L"CourierStd", L"Courier New", 0, 1252}, - {0x481ad6ed, L"VladimirScript", - L"STIXNonUnicode,Avenir Next Condensed,Impact", 8, 1252}, - {0x4911577a, L"YouYuan", L"STHeiti,Heiti TC", 1, 936}, - {0x4a788d72, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, - {0x4bf88566, L"SegoeCondensed", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", - L"STIXNonUnicode,American Typewriter,Impact", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Arial Unicode MS,Heiti TC,STFangsong", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"Courier New,Andale Mono,Ayuthaya,PCMyungjo,Osaka", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x531b3dea, L"BasemicSymbol", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", L"Menlo,Courier New,Andale Mono", 0, - 1252}, - {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, - {0x5792e759, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Lucida Grande,Arial Unicode MS,Menlo", - 0, 1252}, - {0x594e2da4, L"Vrinda", L"Geeza Pro,Damascus,STIXGeneral,Gill Sans", 0, - 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"Avenir Next Condensed Heavy,PT Sans,Avenir Next Condensed", 0, 1252}, - {0x5e16ac91, L"TrajanPro", L"Arial Narrow,PT Sans Narrow,Damascus", 0, - 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"AppleMyungjo,AppleGothic,Arial Unicode MS", 0, 936}, - {0x5fefbfad, L"Batang", L"Arial Unicode MS,Songti SC", 2, 1252}, - {0x605342b9, L"DotumChe", L"Arial Unicode MS,Heiti TC", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti,Heiti TC", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black,Avenir Next Heavy", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Apple Braille,Geeza Pro,Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x630501a3, L"SmallFonts", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Damascus,STIXNonUnicode,Avenir Next Condensed,Avenir Next Condensed " - L"Ultra Light,Futura", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x696259b7, L"Corbel", L"Cochin,Baskerville,Marion", 0, 1252}, - {0x696ee9be, L"STXihei", L"STHeiti,Heiti TC,Songti SC,Arial Unicode MS", 0, - 936}, - {0x6c59cf69, L"Dotum", L"Arial Unicode MS,Songti SC", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Arial Unicode MS,Heiti TC", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"STIXSizeFourSym,STIXSizeThreeSym,STIXSizeTwoSym,STIXSizeOneSym", 0, - 1252}, - {0x71b41801, L"Verdana", - L"Tahoma,Marion,Apple Symbols,.Helvetica Neue Desk UI,Lucida " - L"Grande,Courier New", - 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Palatino,Arial Unicode MS", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x74001694, L"MyriadProBlack", L"Palatino,Baskerville,Marion,Cochin", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x74cb44ee, L"NSimSun", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Damascus,STIXNonUnicode,Arial Unicode MS,American Typewriter", 0, 1252}, - {0x788b3533, L"Webdings", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0x797dde99, L"MSSerif", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Apple SD Gothic Neo", - 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"STIXNonUnicode,Arial Unicode MS,Baskerville,Avenir Next Medium", 0, - 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Comic Sans MS,Avenir Next,Arial Rounded MT Bold", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", L"Heiti TC,STHeiti", 0, 936}, - {0x83581825, L"Modern", L"Avenir Next Condensed,Impact", 0, 1252}, - {0x835a2823, L"Algerian", - L"STIXNonUnicode,Baskerville,Avenir Next Medium,American Typewriter", 0, - 1252}, - {0x83dab9f5, L"Script", L"Arial Narrow", 0, 1252}, - {0x847b56da, L"Tahoma", L"Songti SC,Apple Symbols", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Arial Unicode MS,Songti SC", 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Nadeem,Al Bayan", 0, 1252}, - {0x8e8d43b2, L"Centaur", L"Avenir Next Condensed,Noteworthy,Impact", 2, - 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x90794800, L"BellGothicStdLight", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x909b516a, L"Century", L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", - 2, 1252}, - {0x92ae370d, L"MSOutlook", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"PT Sans Narrow,Papyrus,Kokonor,Geeza Pro,Arial Rounded MT Bold,Lucida " - L"Grande,Futura", - 2, 1252}, - {0x9565085e, L"BookAntiqua", L"Palatino,Microsoft Sans Serif,Apple Symbols", - 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"AHiragino Sans GB,Heiti TC,STHeiti", 0, - 949}, - {0x9bbadd6b, L"ColonnaMT", L"Noteworthy,Avenir Next Condensed,Impact", 0, - 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, - {0xa0607db1, L"GungsuhChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Heiti TC,STFangsong", - 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"Zapfino,Arial Black,STHeiti", 2, 1252}, - {0xa1429b36, L"Symbol", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"STIXNonUnicode,Arial Narrow,Avenir Next Condensed Demi Bold", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0xa8d83ece, L"CalifornianFB", - L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"STIXVariants,STIXSizeOneSym,Apple Braille", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"STIXNonUnicode,Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, - 1252}, - {0xade5337c, L"MSUIGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, - 1252}, - {0xb08dd941, L"WideLatin", - L"Marion,Papyrus,Nanum Pen Script,Zapf Dingbats,Damascus,Zapfino,Arial " - L"Black,STHeiti", - 2, 1252}, - {0xb12765e0, L"ITCLegacySansStdBook", - L"LastResort,.Helvetica Neue Desk UI,Arial Unicode MS,Palatino", 0, 1252}, - {0xb207f05d, L"PoorRichard", L"Noteworthy,Avenir Next Condensed,Impact", 2, - 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Nadeem,Al Bayan,STIXNonUnicode", 0, - 1252}, - {0xb5545399, L"Marlett", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", - L"Damascus,STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", L"STHeiti,Arial Black", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Microsoft Sans Serif,Apple Symbols", 2, - 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Heiti TC,STHeiti", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", - L"American Typewriter,Avenir Next Condensed Heavy", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0xc16c0118, L"AdobeHebrew", - L".Helvetica Neue Desk UI,Palatino,American Typewriter", 0, 1252}, - {0xc318b0af, L"MyriadProLight", L"Palatino,Baskerville,Marion", 0, 1252}, - {0xc65e5659, L"CambriaMath", L"Arial Unicode MS", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", L"Courier New,Menlo,Andale Mono", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Apple Symbols,HeadLineA", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", L"Lucida Grande", 0, 1252}, - {0xcca00cc5, L"System", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Lucida Grande", 0, 1252}, - {0xccc5818c, L"EuroSign", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0xcfe5755f, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, - 1252}, - {0xd060e7ef, L"Vivaldi", - L"STIXNonUnicode,Arial Unicode MS,Avenir Medium,Avenir Next Medium", 8, - 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Impact,Arial Narrow", 0, 1252}, - {0xd107243f, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0xd1881562, L"ArialNarrow", L"PT Sans Narrow,Apple Symbols", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", - L"Damascus,Georgia,.Helvetica Neue Desk UI,Lucida Grande,Arial Unicode MS", - 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"STIXNonUnicode,Arial Unicode MS,Avenir Next,Avenir", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"Impact,Avenir Next Condensed Demi Bold", 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Arial Narrow,Khmer MN,Kokonor,Damascus,Microsoft Sans Serif,Apple " - L"Symbols", - 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"STIXGeneral,.Helvetica Neue Desk UI,Trebuchet MS", 2, 1252}, - {0xda7e551e, L"STSong", L"Arial Unicode MS", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"STFangsong,Songti SC,STSong", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdaeb0713, L"STSong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdb00a3d9, L"Broadway", - L"Papyrus,STIXNonUnicode,Arial Black,Avenir Next Heavy,Heiti TC", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdb69595a, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdba0082c, L"STXihei", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", - L"STIXNonUnicode,Damascus,Songti SC,STSong", 8, 1252}, - {0xdcc7009c, L"Harrington", - L"STIXNonUnicode,Avenir Next Condensed Heavy,Noteworthy", 0, 1252}, - {0xdd712466, L"ArialBlack", L"Geeza Pro,Damascus,Songti SC,STSong", 0, - 1252}, - {0xdde87b3e, L"Impact", L"Arial Narrow,Marion", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Arial Narrow,PT Sans Narrow,Marion,STHeiti,Arial Black", 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, - {0xe0f705c0, L"KristenITC", L"Songti SC,STSong", 8, 1252}, - {0xe1427573, L"Raavi", - L"Damascus,STIXNonUnicode,Marion,Papyrus,Avenir Next Condensed " - L"Heavy,American Typewriter", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"STIXNonUnicode,Damascus,Geeza Pro,Lucida Grande,Georgia,Heiti TC", 0, - 1252}, - {0xe36a9e17, L"Ravie", L"STHeiti,Arial Black", 0, 1252}, - {0xe433f8e2, L"Parchment", L"Microsoft Sans Serif,Apple Symbols", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0xe4e2c405, L"MTExtra", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xe618cc35, L"InformalRoman", L"Arial Narrow", 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Apple Symbols", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 0, 1252}, - {0xec637b42, L"Consolas", - L"AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL UKai TW MBE,AR PL UMing " - L"CN,AR PL UMing HK,Microsoft Sans Serif,Tahoma", - 1, 1252}, - {0xed3a683b, L"STXinwei", L"Kaiti SC,Songti SC,", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Arial Narrow,Avenir Next Condensed Demi Bold,Avenir Next " - L"Condensed,Avenir Next Condensed Medium,STHeiti,Arial Black", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, - {0xf1028030, L"Mangal", - L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Tahoma", 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Papyrus,Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Arial Unicode MS,Arial Narrow,STIXNonUnicode,Damascus,Avenir Next " - L"Condensed Demi Bold,Avenir Next Condensed Medium,Avenir Next Condensed", - 0, 1252}, - {0xf477f16a, L"Latha", - L"Arial Narrow,Damascus,STIXNonUnicode,American Typewriter", 0, 1252}, - {0xf616f3dd, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Geeza Pro,Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black", 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Heiti TC,STHeiti", 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ -static const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"Droid Sans Fallback", 0, 936}, - {0x01e4f102, L"YouYuan", L"Droid Sans Fallback", 1, 936}, - {0x030549dc, L"LiSu", L"Droid Sans Fallback", 1, 936}, - {0x032edd44, L"Simhei", L"Droid Sans Fallback", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " - L"Naskh,Droid Sans Ethiopic", - 2, 1252}, - {0x03ed90e6, L"Nina", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"Droid Sans Thai,Droid Sans Armenian,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,Droid Sans Fallback", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Droid Sans Fallback", 0, 1252}, - {0x089b18a9, L"Arial", L"Droid Sans Fallback", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 2, 1252}, - {0x0bb469df, L"VinerHandITC", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Droid Sans Fallback", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 847}, - {0x0e7de0f9, L"Playbill", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x0eff47c3, L"STHupo", L"Droid Sans Fallback", 0, 936}, - {0x107ad374, L"Constantia", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x12194c2d, L"KunstlerScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x158c4049, L"Garamond", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, - {0x161ed07e, L"MSGothic", L"Droid Sans Fallback", 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x18d1188f, L"Cambria", L"Droid Sans Fallback", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Droid Sans Fallback", 0, 936}, - {0x1a92d115, L"MingLiU", L"Droid Sans Fallback", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x1d649596, L"BasemicTimes", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x1e34ee60, L"BellMT", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x1ef7787d, L"BatangChe", L"Droid Sans Fallback", 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, - 1252}, - {0x220877aa, L"Candara", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x251059c3, L"Chiller", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", L"Droid Sans Fallback", 0, 1252}, - {0x28154c81, L"Parchment-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x29711eb9, L"STLiti", L"Droid Sans Fallback", 0, 936}, - {0x2b1993b4, L"Basemic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c147529, L"FootlightMTLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x31327817, L"MyriadPro", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x32244975, L"Helvetica", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, - {0x32ac995c, L"Terminal", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x33bb65f2, L"Sylfaen", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Droid Sans Fallback", 2, 1252}, - {0x3412bf31, L"SimSun-PUA", L"Droid Sans Fallback", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x3cdae668, L"FreestyleScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x3d55aed7, L"Jokerman", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Droid Sans Fallback", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"Droid Sans Fallback", 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono,Droid Sans Fallback", - 0, 1252}, - {0x3ff32662, L"Chiller-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x409de312, L"ModernNo.20", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x41443c5e, L"Georgia", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x421976c4, L"Modern-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x422a7252, L"Stencil", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x42c8554f, L"Fixedsys", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x435cb41d, L"Roman", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x47882383, L"CourierNew", L"Droid Sans Fallback", 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x480bf7a4, L"CourierStd", L"Droid Sans Fallback", 0, 1252}, - {0x481ad6ed, L"VladimirScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x4911577a, L"YouYuan", L"Droid Sans Fallback", 1, 936}, - {0x4a788d72, L"STXingkai", L"Droid Sans Fallback", 0, 936}, - {0x4bf88566, L"SegoeCondensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Droid Sans Fallback", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Mono,Droid Serif,Droid Sans Fallback", - 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", - L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic", 0, 1252}, - {0x574d4d3d, L"AdobeArabic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5792e759, L"STKaiti", L"Droid Sans Fallback", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Fallback", 0, 1252}, - {0x594e2da4, L"Vrinda", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", L"Droid Sans Fallback", 0, 936}, - {0x5fefbfad, L"Batang", L"Droid Sans Fallback", 2, 1252}, - {0x605342b9, L"DotumChe", L"Droid Sans Fallback", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0x630501a3, L"SmallFonts", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono,Droid Sans Fallback", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x696259b7, L"Corbel", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x696ee9be, L"STXihei", L"Droid Sans Fallback", 0, 936}, - {0x6c59cf69, L"Dotum", L"Droid Sans Fallback", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Droid Sans Fallback", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"Droid Arabic Naskh,Droid Sans Armenian,Droid Sans Ethiopic,Droid Sans " - L"Georgian,Droid Sans Hebrew,Droid Sans Thai", - 0, 1252}, - {0x71b41801, L"Verdana", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Fallback", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x74cb44ee, L"NSimSun", L"Droid Sans Fallback", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x788b3533, L"Webdings", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0x797dde99, L"MSSerif", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", L"Droid Sans Fallback", 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", L"Droid Sans Fallback", 0, 936}, - {0x83581825, L"Modern", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x835a2823, L"Algerian", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x83dab9f5, L"Script", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x847b56da, L"Tahoma", L"Droid Sans Fallback", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"Droid Sans Fallback", 0, 1252}, - {0x8b5cac0e, L"Onyx", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Droid Sans Fallback", 0, 1252}, - {0x8e0af790, L"JuiceITC", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8e8d43b2, L"Centaur", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x90794800, L"BellGothicStdLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x909b516a, L"Century", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x92ae370d, L"MSOutlook", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0x9565085e, L"BookAntiqua", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"Droid Sans Fallback", 0, 949}, - {0x9bbadd6b, L"ColonnaMT", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, - {0x9d73008e, L"MSSansSerif", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xa0607db1, L"GungsuhChe", L"Droid Sans Fallback", 1, 1252}, - {0xa0bcf6a1, L"LatinWide", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xa1429b36, L"Symbol", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa1fa5abc, L"Wingdings2", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa1fa5abd, L"Wingdings3", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0xa8d83ece, L"CalifornianFB", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xade5337c, L"MSUIGothic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb08dd941, L"WideLatin", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0xb207f05d, L"PoorRichard", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xb3bc492f, L"JuiceITC-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb5545399, L"Marlett", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", L"Droid Arabic Naskh,Droid Sans Ethiopic", 0, - 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Droid Sans Fallback", 2, 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Droid Sans Fallback", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " - L"Naskh,Droid Sans Ethiopic", - 0, 1252}, - {0xc318b0af, L"MyriadProLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xc65e5659, L"CambriaMath", L"Droid Sans Fallback", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", - L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Droid Sans Fallback", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcca00cc5, L"System", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xccc5818c, L"EuroSign", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcfe5755f, L"Simhei", L"Droid Sans Fallback", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Droid Sans Fallback", 0, 1252}, - {0xd060e7ef, L"Vivaldi", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd107243f, L"SimSun", L"Droid Sans Fallback", 0, 936}, - {0xd1881562, L"ArialNarrow", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", L"Droid Serif,Roboto,Droid Sans Fallback", 8, - 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Droid Sans Fallback", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xda7e551e, L"STSong", L"Droid Sans Fallback", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Droid Sans Fallback", 0, 936}, - {0xdaeb0713, L"STSong", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, - {0xdb00a3d9, L"Broadway", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Droid Sans Fallback", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Droid Sans Fallback", 0, 936}, - {0xdb69595a, L"STHupo", L"Droid Sans Fallback", 0, 936}, - {0xdba0082c, L"STXihei", L"Droid Sans Fallback", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Droid Sans Fallback", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Droid Sans Fallback", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, - {0xdcc7009c, L"Harrington", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdd712466, L"ArialBlack", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdde87b3e, L"Impact", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Droid Serif,Roboto,Droid Serif,Droid Sans Mono", 0, 1252}, - {0xe0f705c0, L"KristenITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, - {0xe1427573, L"Raavi", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xe36a9e17, L"Ravie", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xe433f8e2, L"Parchment", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xe43dff4a, L"Wingdings", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0xe4e2c405, L"MTExtra", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xe618cc35, L"InformalRoman", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 8, 1252}, - {0xe6c27ffc, L"Mistral", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Droid Sans Fallback", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xec637b42, L"Consolas", L"Droid Sans Fallback", 1, 1252}, - {0xed3a683b, L"STXinwei", L"Droid Sans Fallback", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xf1028030, L"Mangal", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, - {0xf477f16a, L"Latha", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xf616f3dd, L"LiSu", L"Droid Sans Fallback", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Droid Sans Fallback", 0, 936}, -}; -#endif -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_ - FX_DWORD dwLocalNameHash = FX_HashCode_String_GetW( - wsLocalName.GetPtr(), wsLocalName.GetLength(), TRUE); - int32_t iStart = 0; - int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1; - int32_t iMid = 0; - do { - iMid = (iStart + iEnd) / 2; - FX_DWORD dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash; - if (dwFontNameHash == dwLocalNameHash) { - wsEnglishName = g_XFAFontsMap[iMid].pPsName; - break; - } else if (dwFontNameHash < dwLocalNameHash) { - iStart = iMid + 1; - } else { - 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; - wsFontNameTemp.Remove(L' '); - FX_DWORD dwCurFontNameHash = - FX_HashCode_String_GetW(wsFontNameTemp, wsFontNameTemp.GetLength(), TRUE); - int32_t iStart = 0; - int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1; - int32_t iMid = 0; - const XFA_FONTINFO* pFontInfo = NULL; - do { - iMid = (iStart + iEnd) / 2; - FX_DWORD dwFontNameHash = g_XFAFontsMap[iMid].dwFontNameHash; - if (dwFontNameHash == dwCurFontNameHash) { - pFontInfo = &g_XFAFontsMap[iMid]; - break; - } else if (dwFontNameHash < dwCurFontNameHash) { - iStart = iMid + 1; - } else { - iEnd = iMid - 1; - } - } while (iEnd >= iStart); - return pFontInfo; -#else - return NULL; -#endif -} -// static -IXFA_FontMgr* IXFA_FontMgr::CreateDefault() { - return new CXFA_DefFontMgr; -} -// virtual -IXFA_FontMgr::~IXFA_FontMgr() {} -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(); -} - -IFX_Font* CXFA_DefFontMgr::GetFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - CFX_WideString wsFontName = wsFontFamily; - IFX_FontMgr* pFDEFontMgr = - static_cast<CXFA_FFDoc*>(hDoc)->GetApp()->GetFDEFontMgr(); - IFX_Font* pFont = pFDEFontMgr->LoadFont(wsFontName, dwFontStyles, wCodePage); - if (!pFont) { - const XFA_FONTINFO* pCurFont = XFA_GetFontINFOByFontName(wsFontName); - if (pCurFont && pCurFont->pReplaceFont) { - FX_DWORD dwStyle = 0; - if (dwFontStyles & FX_FONTSTYLE_Bold) { - dwStyle |= FX_FONTSTYLE_Bold; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - dwStyle |= FX_FONTSTYLE_Italic; - } - const FX_WCHAR* pReplace = pCurFont->pReplaceFont; - int32_t iLength = FXSYS_wcslen(pReplace); - while (iLength > 0) { - const FX_WCHAR* pNameText = pReplace; - while (*pNameText != L',' && iLength > 0) { - pNameText++; - iLength--; - } - CFX_WideString wsReplace = - CFX_WideString(pReplace, pNameText - pReplace); - pFont = pFDEFontMgr->LoadFont(wsReplace, dwStyle, wCodePage); - if (pFont) { - break; - } - iLength--; - pNameText++; - pReplace = pNameText; - } - } - } - if (pFont) { - m_CacheFonts.Add(pFont); - } - return pFont; -} - -IFX_Font* CXFA_DefFontMgr::GetDefaultFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - IFX_FontMgr* pFDEFontMgr = ((CXFA_FFDoc*)hDoc)->GetApp()->GetFDEFontMgr(); - IFX_Font* pFont = - pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); - if (!pFont) - pFont = - pFDEFontMgr->LoadFont((const FX_WCHAR*)NULL, dwFontStyles, wCodePage); - FXSYS_assert(pFont); - if (pFont) { - m_CacheFonts.Add(pFont); - } - return pFont; -} -struct XFA_PDFFONTNAME { - const FX_CHAR* lpPsName; - const FX_CHAR* lpNormal; - const FX_CHAR* lpBold; - const FX_CHAR* lpItalic; - const FX_CHAR* lpBoldItalic; -}; -const XFA_PDFFONTNAME g_XFAPDFFontName[] = { - {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"}, - {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold", - "MyriadPro-LightIt", "MyriadPro-SemiboldIt"}, -}; -CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) { - m_pDoc = pDoc; -} -CXFA_PDFFontMgr::~CXFA_PDFFontMgr() { - m_FDE2PDFFont.RemoveAll(); - for (const auto& pair : m_FontMap) { - if (pair.second) - pair.second->Release(); - } -} -IFX_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, - FX_BOOL bBold, - FX_BOOL bItalic, - CPDF_Font** pDstPDFFont, - FX_BOOL bStrictMatch) { - CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); - if (pDoc == NULL) { - return NULL; - } - CPDF_Dictionary* pFontSetDict = - pDoc->GetRoot()->GetDictBy("AcroForm")->GetDictBy("DR"); - if (!pFontSetDict) { - return NULL; - } - pFontSetDict = (CPDF_Dictionary*)pFontSetDict->GetDictBy("Font"); - if (!pFontSetDict) { - return NULL; - } - strPsName.Remove(' '); - IFX_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); - for (const auto& it : *pFontSetDict) { - const CFX_ByteString& key = it.first; - CPDF_Object* pObj = it.second; - if (!PsNameMatchDRFontName(strPsName, bBold, bItalic, key, bStrictMatch)) { - continue; - } - CPDF_Object* pDirect = pObj->GetDirect(); - if (!pDirect || !pDirect->IsDictionary()) { - return NULL; - } - CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)pDirect; - if (pFontDict->GetStringBy("Type") != "Font") { - return NULL; - } - CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); - if (!pPDFFont) { - return NULL; - } - if (!pPDFFont->IsEmbedded()) { - *pDstPDFFont = pPDFFont; - return NULL; - } - return IFX_Font::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); - } - return NULL; -} -IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch) { - FX_DWORD dwHashCode = - FX_HashCode_String_GetW(wsFontFamily.GetPtr(), wsFontFamily.GetLength()); - 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); - 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); - IFX_Font* pFont = - FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); - if (pFont) - m_FontMap[strKey] = pFont; - return pFont; -} -CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName( - const CFX_ByteString& strPsName, - FX_BOOL bBold, - FX_BOOL bItalic) { - int32_t nCount = sizeof(g_XFAPDFFontName) / sizeof(XFA_PDFFONTNAME); - for (int32_t i = 0; i < nCount; i++) { - if (strPsName == g_XFAPDFFontName[i].lpPsName) { - int32_t index = 1 + ((bItalic << 1) | bBold); - return *(&g_XFAPDFFontName[i].lpPsName + index); - } - } - return strPsName; -} -FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( - const CFX_ByteStringC& bsPsName, - FX_BOOL bBold, - FX_BOOL bItalic, - const CFX_ByteString& bsDRFontName, - FX_BOOL bStrictMatch) { - CFX_ByteString bsDRName = bsDRFontName; - bsDRName.Remove('-'); - int32_t iPsLen = bsPsName.GetLength(); - int32_t nIndex = bsDRName.Find(bsPsName); - if (nIndex != -1 && !bStrictMatch) { - return TRUE; - } - if (nIndex != 0) { - return FALSE; - } - int32_t iDifferLength = bsDRName.GetLength() - iPsLen; - if (iDifferLength > 1 || (bBold || bItalic)) { - int32_t iBoldIndex = bsDRName.Find("Bold"); - FX_BOOL bBoldFont = iBoldIndex > 0; - if (bBold ^ bBoldFont) { - return FALSE; - } - if (bBoldFont) { - iDifferLength = - std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); - } - FX_BOOL bItalicFont = TRUE; - if (bsDRName.Find("Italic") > 0) { - iDifferLength -= 6; - } else if (bsDRName.Find("It") > 0) { - iDifferLength -= 2; - } else if (bsDRName.Find("Oblique") > 0) { - iDifferLength -= 7; - } else { - bItalicFont = FALSE; - } - if (bItalic ^ bItalicFont) { - return FALSE; - } - if (iDifferLength > 1) { - CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength); - if (bsDRTailer.Equal("MT") || bsDRTailer.Equal("PSMT") || - bsDRTailer.Equal("Regular") || bsDRTailer.Equal("Reg")) { - return TRUE; - } - if (bBoldFont || bItalicFont) { - return FALSE; - } - FX_BOOL bMatch = FALSE; - switch (bsPsName.GetAt(iPsLen - 1)) { - case 'L': { - if (bsDRName.Right(5).Equal("Light")) { - bMatch = TRUE; - } - } break; - case 'R': { - if (bsDRName.Right(7).Equal("Regular") || - bsDRName.Right(3).Equal("Reg")) { - bMatch = TRUE; - } - } break; - case 'M': { - if (bsDRName.Right(5).Equal("Medium")) { - bMatch = TRUE; - } - } break; - default: - break; - } - return bMatch; - } - } - return TRUE; -} -FX_BOOL CXFA_PDFFontMgr::GetCharWidth(IFX_Font* pFont, - FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bCharCode) { - if (wUnicode != 0x20 || bCharCode) { - return FALSE; - } - CPDF_Font* pPDFFont = (CPDF_Font*)m_FDE2PDFFont.GetValueAt(pFont); - if (!pPDFFont) { - return FALSE; - } - wUnicode = (FX_WCHAR)pPDFFont->CharCodeFromUnicode(wUnicode); - iWidth = pPDFFont->GetCharWidthF(wUnicode); - return TRUE; -} -CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(NULL) {} -CXFA_FontMgr::~CXFA_FontMgr() { - DelAllMgrMap(); -} -IFX_Font* CXFA_FontMgr::GetFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage) { - FX_DWORD dwHash = FX_HashCode_String_GetW(wsFontFamily.GetPtr(), - wsFontFamily.GetLength(), FALSE); - CFX_ByteString bsKey; - bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); - auto it = m_FontMap.find(bsKey); - if (it != m_FontMap.end()) - return it->second; - CFX_WideString wsEnglishName; - XFA_LocalFontNameToEnglishName(wsFontFamily, wsEnglishName); - CXFA_PDFFontMgr* pMgr = (CXFA_PDFFontMgr*)m_PDFFontMgrArray.GetValueAt(hDoc); - CPDF_Font* pPDFFont = NULL; - IFX_Font* pFont = NULL; - if (pMgr) { - pFont = pMgr->GetFont(wsEnglishName, dwFontStyles, &pPDFFont); - if (pFont) - return pFont; - } - if (!pFont && m_pDefFontMgr) { - pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); - } - if (!pFont && pMgr) { - pPDFFont = NULL; - pFont = pMgr->GetFont(wsEnglishName, dwFontStyles, &pPDFFont, FALSE); - if (pFont) - return pFont; - } - if (!pFont && m_pDefFontMgr) { - pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, - wCodePage); - } - if (pFont) { - if (pPDFFont) { - pMgr->m_FDE2PDFFont.SetAt(pFont, pPDFFont); - pFont->SetFontProvider(pMgr); - } - m_FontMap[bsKey] = pFont; - } - return pFont; -} -void CXFA_FontMgr::LoadDocFonts(IXFA_Doc* hDoc) { - if (!m_PDFFontMgrArray.GetValueAt(hDoc)) { - m_PDFFontMgrArray.SetAt(hDoc, new CXFA_PDFFontMgr((CXFA_FFDoc*)hDoc)); - } -} -void CXFA_FontMgr::ReleaseDocFonts(IXFA_Doc* hDoc) { - CXFA_PDFFontMgr* pMgr = NULL; - if (m_PDFFontMgrArray.Lookup(hDoc, (void*&)pMgr)) { - delete pMgr; - m_PDFFontMgrArray.RemoveKey(hDoc); - } -} -void CXFA_FontMgr::DelAllMgrMap() { - FX_POSITION ps = m_PDFFontMgrArray.GetStartPosition(); - while (ps) { - IXFA_Doc* hDoc = NULL; - CXFA_PDFFontMgr* pMgr = NULL; - m_PDFFontMgrArray.GetNextAssoc(ps, (void*&)hDoc, (void*&)pMgr); - delete pMgr; - } - m_PDFFontMgrArray.RemoveAll(); - m_FontMap.clear(); -} -void CXFA_FontMgr::SetDefFontMgr(IXFA_FontMgr* pFontMgr) { - m_pDefFontMgr = pFontMgr; -} diff --git a/xfa/src/fxfa/app/xfa_fontmgr.h b/xfa/src/fxfa/app/xfa_fontmgr.h deleted file mode 100644 index c77e96d329..0000000000 --- a/xfa/src/fxfa/app/xfa_fontmgr.h +++ /dev/null @@ -1,100 +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_SRC_FXFA_APP_XFA_FONTMGR_H_ -#define XFA_SRC_FXFA_APP_XFA_FONTMGR_H_ - -#include <map> - -#include "core/include/fxcrt/fx_ext.h" -#include "core/include/fxcrt/fx_system.h" -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fgas/font/fgas_font.h" - -class CPDF_Font; - -struct XFA_FONTINFO { - FX_DWORD dwFontNameHash; - const FX_WCHAR* pPsName; - const FX_WCHAR* pReplaceFont; - FX_WORD dwStyles; - FX_WORD wCodePage; -}; - -class CXFA_DefFontMgr : public IXFA_FontMgr { - public: - CXFA_DefFontMgr() {} - ~CXFA_DefFontMgr() override; - - // IXFA_FontMgr: - IFX_Font* GetFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF) override; - IFX_Font* GetDefaultFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF) override; - - protected: - CFX_PtrArray m_CacheFonts; -}; - -class CXFA_PDFFontMgr : public IFX_FontProvider { - public: - CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); - ~CXFA_PDFFontMgr(); - IFX_Font* GetFont(const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch = TRUE); - FX_BOOL GetCharWidth(IFX_Font* pFont, - FX_WCHAR wUnicode, - int32_t& iWidth, - FX_BOOL bCharCode); - CFX_MapPtrToPtr m_FDE2PDFFont; - - protected: - IFX_Font* FindFont(CFX_ByteString strFamilyName, - FX_BOOL bBold, - FX_BOOL bItalic, - CPDF_Font** pPDFFont, - FX_BOOL bStrictMatch = TRUE); - CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, - FX_BOOL bBold, - FX_BOOL bItalic); - FX_BOOL PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, - FX_BOOL bBold, - FX_BOOL bItalic, - const CFX_ByteString& bsDRFontName, - FX_BOOL bStrictMatch = TRUE); - - CXFA_FFDoc* m_pDoc; - std::map<CFX_ByteString, IFX_Font*> m_FontMap; -}; - -class CXFA_FontMgr { - public: - CXFA_FontMgr(); - ~CXFA_FontMgr(); - IFX_Font* GetFont(IXFA_Doc* hDoc, - const CFX_WideStringC& wsFontFamily, - FX_DWORD dwFontStyles, - FX_WORD wCodePage = 0xFFFF); - void LoadDocFonts(IXFA_Doc* hDoc); - void ReleaseDocFonts(IXFA_Doc* hDoc); - - void SetDefFontMgr(IXFA_FontMgr* pFontMgr); - - protected: - void DelAllMgrMap(); - - CFX_MapPtrToPtr m_PDFFontMgrArray; - IXFA_FontMgr* m_pDefFontMgr; - std::map<CFX_ByteString, IFX_Font*> m_FontMap; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FONTMGR_H_ diff --git a/xfa/src/fxfa/app/xfa_fwladapter.cpp b/xfa/src/fxfa/app/xfa_fwladapter.cpp deleted file mode 100644 index a43cd9c084..0000000000 --- a/xfa/src/fxfa/app/xfa_fwladapter.cpp +++ /dev/null @@ -1,61 +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/src/fxfa/app/xfa_fwladapter.h" - -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/xfa_fffield.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -void FWL_PostMessageToMainRoop(CFWL_Message* pMessage) {} -FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, - FX_BOOL bVisible, - const CFX_RectF* pRtAnchor) { - CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget); - if (!pXFAWidget) { - return FALSE; - } - IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider(); - if (!pDocProvider) { - return FALSE; - } - if (bVisible) { - CFX_Matrix mt; - pXFAWidget->GetRotateMatrix(mt); - CFX_RectF rt(*pRtAnchor); - mt.TransformRect(rt); - pDocProvider->DisplayCaret(pXFAWidget, bVisible, &rt); - return TRUE; - } - pDocProvider->DisplayCaret(pXFAWidget, bVisible, pRtAnchor); - return TRUE; -} - -FWL_ERR CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect) { - if (!pWidget) - return FWL_ERR_Indefinite; - CXFA_FFField* pField = (CXFA_FFField*)pWidget->GetPrivateData(pWidget); - if (!pField) - return FWL_ERR_Indefinite; - pField->AddInvalidateRect(nullptr); - return FWL_ERR_Succeeded; -} - -FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, - FX_FLOAT fMinHeight, - FX_FLOAT fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - CXFA_FFWidget* pFFWidget = (CXFA_FFWidget*)(pWidget->GetPrivateData(pWidget)); - CFX_Matrix mt; - pFFWidget->GetRotateMatrix(mt); - CFX_RectF rtRotateAnchor(rtAnchor); - mt.TransformRect(rtRotateAnchor); - pFFWidget->GetDoc()->GetDocProvider()->GetPopupPos( - pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); - return TRUE; -} diff --git a/xfa/src/fxfa/app/xfa_fwladapter.h b/xfa/src/fxfa/app/xfa_fwladapter.h deleted file mode 100644 index daa8413ea3..0000000000 --- a/xfa/src/fxfa/app/xfa_fwladapter.h +++ /dev/null @@ -1,22 +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_SRC_FXFA_APP_XFA_FWLADAPTER_H_ -#define XFA_SRC_FXFA_APP_XFA_FWLADAPTER_H_ - -#include "xfa/include/fwl/adapter/fwl_sdadapterimp.h" - -class CXFA_FWLAdapterWidgetMgr : public CFWL_SDAdapterWidgetMgr { - 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); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FWLADAPTER_H_ diff --git a/xfa/src/fxfa/app/xfa_fwltheme.cpp b/xfa/src/fxfa/app/xfa_fwltheme.cpp deleted file mode 100644 index e13917bf7b..0000000000 --- a/xfa/src/fxfa/app/xfa_fwltheme.cpp +++ /dev/null @@ -1,424 +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/src/fxfa/app/xfa_fwltheme.h" - -#include "xfa/include/fwl/basewidget/fwl_barcode.h" -#include "xfa/include/fwl/basewidget/fwl_caret.h" -#include "xfa/include/fwl/basewidget/fwl_checkbox.h" -#include "xfa/include/fwl/basewidget/fwl_combobox.h" -#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" -#include "xfa/include/fwl/basewidget/fwl_edit.h" -#include "xfa/include/fwl/basewidget/fwl_listbox.h" -#include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" -#include "xfa/include/fwl/basewidget/fwl_picturebox.h" -#include "xfa/include/fwl/basewidget/fwl_pushbutton.h" -#include "xfa/include/fwl/basewidget/fwl_scrollbar.h" -#include "xfa/src/fde/tto/fde_textout.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { - IFWL_Widget* pOuter = pWidget; - while (pOuter->GetOuter()) { - pOuter = pOuter->GetOuter(); - } - if (pOuter) { - return (CXFA_FFWidget*)pOuter->GetPrivateData(pOuter); - } - return NULL; -} -CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { - m_pTextOut = NULL; - m_dwCapacity = 0; - m_fCapacity = 0; - m_pCalendarFont = NULL; - m_Rect.Set(0, 0, 0, 0); - m_pCheckBoxTP = new CXFA_FWLCheckBoxTP; - m_pListBoxTP = new CFWL_ListBoxTP; - m_pPictureBoxTP = new CFWL_PictureBoxTP; - m_pSrollBarTP = new CFWL_ScrollBarTP; - m_pEditTP = new CXFA_FWLEditTP; - m_pComboBoxTP = new CFWL_ComboBoxTP; - m_pMonthCalendarTP = new CFWL_MonthCalendarTP; - m_pDateTimePickerTP = new CFWL_DateTimePickerTP; - m_pPushButtonTP = new CFWL_PushButtonTP; - m_pCaretTP = new CFWL_CaretTP; - m_pBarcodeTP = new CFWL_BarcodeTP; - Initialize(); -} -CXFA_FWLTheme::~CXFA_FWLTheme() { - Finalize(); - delete m_pCheckBoxTP; - delete m_pListBoxTP; - delete m_pPictureBoxTP; - delete m_pSrollBarTP; - delete m_pEditTP; - delete m_pComboBoxTP; - delete m_pMonthCalendarTP; - delete m_pDateTimePickerTP; - delete m_pPushButtonTP; - delete m_pCaretTP; - delete m_pBarcodeTP; -} -static const FX_WCHAR* g_FWLTheme_CalFonts[] = { - L"Arial", L"Courier New", L"DejaVu Sans", -}; -FWL_ERR CXFA_FWLTheme::Initialize() { - m_pTextOut = IFDE_TextOut::Create(); - 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, - m_pApp->GetFDEFontMgr()); - } - if (!m_pCalendarFont) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( - FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); -#else - m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( - FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); -#endif - } - - FXSYS_assert(NULL != m_pCalendarFont); - FWLTHEME_Init(); - return FWL_ERR_Succeeded; -} -FWL_ERR CXFA_FWLTheme::Finalize() { - if (m_pTextOut) { - m_pTextOut->Release(); - m_pTextOut = NULL; - } - if (m_pCalendarFont) { - m_pCalendarFont->Release(); - m_pCalendarFont = NULL; - } - FWLTHEME_Release(); - return FWL_ERR_Succeeded; -} -FX_BOOL CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) { - return TRUE; -} -FX_DWORD CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) { - return 0; -} -FX_DWORD CXFA_FWLTheme::SetThemeID(IFWL_Widget* pWidget, - FX_DWORD 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) { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) { - return FWL_ERR_Indefinite; - } - 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) && - !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && - (pParams->m_dwStates & - (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } - if (pParams->m_iPart == FWL_PART_MCD_Caption) { - if (m_pMonthCalendarTP->GetThemeID(pParams->m_pWidget) == 0) { - m_pTextOut->SetTextColor(ArgbEncode(0xff, 0, 153, 255)); - } else { - m_pTextOut->SetTextColor(ArgbEncode(0xff, 128, 128, 0)); - } - } - CFX_Graphics* pGraphics = pParams->m_pGraphics; - CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); - if (!pRenderDevice) - return FALSE; - m_pTextOut->SetRenderDevice(pRenderDevice); - CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); - if (pMatrix) { - mtPart.Concat(*pMatrix); - } - m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(), - pParams->m_rtPart); - return TRUE; - } - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) { - return FWL_ERR_Indefinite; - } - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - CFX_Graphics* pGraphics = pParams->m_pGraphics; - CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); - if (!pRenderDevice) - return FALSE; - m_pTextOut->SetRenderDevice(pRenderDevice); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetFont(pAcc->GetFDEFont()); - m_pTextOut->SetFontSize(pAcc->GetFontSize()); - m_pTextOut->SetTextColor(pAcc->GetTextColor()); - CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); - if (pMatrix) { - mtPart.Concat(*pMatrix); - } - m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(), - pParams->m_rtPart); - return TRUE; -} -void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart, - FX_DWORD dwCapacity) { - switch (dwCapacity) { - case FWL_WGTCAPACITY_Font: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - return pWidget->GetDataAcc()->GetFDEFont(); - } - } break; - case FWL_WGTCAPACITY_FontSize: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_fCapacity = pWidget->GetDataAcc()->GetFontSize(); - return &m_fCapacity; - } - } break; - case FWL_WGTCAPACITY_TextColor: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_dwCapacity = pWidget->GetDataAcc()->GetTextColor(); - return &m_dwCapacity; - } - } break; - case FWL_WGTCAPACITY_LineHeight: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_fCapacity = pWidget->GetDataAcc()->GetLineHeight(); - return &m_fCapacity; - } - } break; - case FWL_WGTCAPACITY_ScrollBarWidth: { - m_fCapacity = 9; - return &m_fCapacity; - } break; - case FWL_WGTCAPACITY_UIMargin: { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); - if (pWidget) { - CXFA_LayoutItem* pItem = pWidget; - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - pWidgetAcc->GetUIMargin(m_Rect); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - m_Rect.left += para.GetMarginLeft(); - if (pWidgetAcc->IsMultiLine()) { - m_Rect.width += para.GetMarginRight(); - } - } - if (pItem->GetPrev() == NULL) { - if (pItem->GetNext()) { - m_Rect.height = 0; - } - } else if (pItem->GetNext() == NULL) { - m_Rect.top = 0; - } else { - m_Rect.top = 0; - m_Rect.height = 0; - } - } - return &m_Rect; - } break; - case FWL_WGTCAPACITY_SpaceAboveBelow: { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); - if (pWidget) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - m_SizeAboveBelow.x = para.GetSpaceAbove(); - m_SizeAboveBelow.y = para.GetSpaceBelow(); - } - } - return &m_SizeAboveBelow; - } break; - default: - break; - } - if (pThemePart->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar && - dwCapacity >= FWL_MCCAPACITY_Sun && dwCapacity <= FWL_MCCAPACITY_Today) { - 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; - } - } - } - return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); -} -FX_BOOL CXFA_FWLTheme::IsCustomizedLayout(IFWL_Widget* pWidget) { - return GetTheme(pWidget)->IsCustomizedLayout(pWidget); -} -FWL_ERR CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) { - CFX_RectF rect; - return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rect); -} -FX_BOOL CXFA_FWLTheme::IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy) { - 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) { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) { - return FWL_ERR_Indefinite; - } - if (!pParams) - return FALSE; - if (!m_pTextOut) - return FALSE; - m_pTextOut->SetFont(m_pCalendarFont); - m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); - 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); - return TRUE; - } - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) { - return FWL_ERR_Indefinite; - } - 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); - return TRUE; -} -CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) { - switch (pWidget->GetClassID()) { - case FWL_CLASSHASH_CheckBox: - return m_pCheckBoxTP; - case FWL_CLASSHASH_ListBox: - return m_pListBoxTP; - case FWL_CLASSHASH_PictureBox: - return m_pPictureBoxTP; - case FWL_CLASSHASH_ScrollBar: - return m_pSrollBarTP; - case FWL_CLASSHASH_Edit: - return m_pEditTP; - case FWL_CLASSHASH_ComboBox: - return m_pComboBoxTP; - case FWL_CLASSHASH_MonthCalendar: - return m_pMonthCalendarTP; - case FWL_CLASSHASH_DateTimePicker: - return m_pDateTimePickerTP; - case FWL_CLASSHASH_PushButton: - return m_pPushButtonTP; - case FWL_CLASSHASH_Caret: - return m_pCaretTP; - case FWL_CLASSHASH_Barcode: - return m_pBarcodeTP; - default: - break; - } - return NULL; -} -CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {} -FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (pParams->m_iPart != FWL_PART_CKB_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)) { - DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); - } - return TRUE; -} -void CXFA_FWLCheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - int32_t iState, - CFX_Matrix* pMatrix) { - CFX_RectF rtSign(*pRtBox); - FX_DWORD dwColor = 0xFF000000; - if ((iState & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) { - dwColor = 0xFFA9A9A9; - } - { - FX_DWORD dwStyle = pWidget->GetStylesEx(); - rtSign.Deflate(rtSign.width / 4, rtSign.height / 4); - switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { - case FWL_STYLEEXT_CKB_SignShapeCheck: - DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); - break; - case FWL_STYLEEXT_CKB_SignShapeCircle: - DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); - break; - case FWL_STYLEEXT_CKB_SignShapeCross: - DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); - break; - case FWL_STYLEEXT_CKB_SignShapeDiamond: - DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); - break; - case FWL_STYLEEXT_CKB_SignShapeSquare: - DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); - break; - case FWL_STYLEEXT_CKB_SignShapeStar: - DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); - break; - default: - break; - } - } -} -CXFA_FWLEditTP::CXFA_FWLEditTP() {} -CXFA_FWLEditTP::~CXFA_FWLEditTP() {} -FX_BOOL CXFA_FWLEditTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (FWL_PART_EDT_CombTextLine == pParams->m_iPart) { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - FX_ARGB cr = 0xFF000000; - FX_FLOAT fWidth = 1.0f; - if (CXFA_Border borderUI = pWidget->GetDataAcc()->GetUIBorder()) { - CXFA_Edge edge = borderUI.GetEdge(0); - if (edge) { - cr = edge.GetColor(); - fWidth = edge.GetThickness(); - } - } - CFX_Color crLine(cr); - pParams->m_pGraphics->SetStrokeColor(&crLine); - pParams->m_pGraphics->SetLineWidth(fWidth); - pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); - return TRUE; - } - return CFWL_EditTP::DrawBackground(pParams); -} diff --git a/xfa/src/fxfa/app/xfa_fwltheme.h b/xfa/src/fxfa/app/xfa_fwltheme.h deleted file mode 100644 index 1882311f86..0000000000 --- a/xfa/src/fxfa/app/xfa_fwltheme.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_SRC_FXFA_APP_XFA_FWLTHEME_H_ -#define XFA_SRC_FXFA_APP_XFA_FWLTHEME_H_ - -#include "xfa/include/fwl/core/fwl_target.h" -#include "xfa/include/fwl/core/fwl_theme.h" -#include "xfa/include/fwl/theme/barcodetp.h" -#include "xfa/include/fwl/theme/carettp.h" -#include "xfa/include/fwl/theme/checkboxtp.h" -#include "xfa/include/fwl/theme/comboboxtp.h" -#include "xfa/include/fwl/theme/datetimepickertp.h" -#include "xfa/include/fwl/theme/edittp.h" -#include "xfa/include/fwl/theme/listboxtp.h" -#include "xfa/include/fwl/theme/monthcalendartp.h" -#include "xfa/include/fwl/theme/pictureboxtp.h" -#include "xfa/include/fwl/theme/pushbuttontp.h" -#include "xfa/include/fwl/theme/scrollbartp.h" -#include "xfa/include/fwl/theme/widgettp.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" - -class CXFA_FWLTheme : public IFWL_ThemeProvider { - public: - CXFA_FWLTheme(CXFA_FFApp* pApp); - virtual ~CXFA_FWLTheme(); - virtual FWL_ERR Release() { - delete this; - return FWL_ERR_Succeeded; - } - virtual IFWL_Target* Retain() { return NULL; } - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { - return FWL_ERR_Succeeded; - } - virtual FX_DWORD GetHashCode() const { return 0; } - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_DWORD GetThemeID(IFWL_Widget* pWidget); - virtual FX_DWORD SetThemeID(IFWL_Widget* pWidget, - FX_DWORD 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, FX_DWORD dwCapacity); - virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget); - virtual FWL_ERR 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_ERR SetThemeMatrix(IFWL_Widget* pWidget, - const CFX_Matrix& matrix) { - return FWL_ERR_Succeeded; - } - virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { - return FWL_ERR_Succeeded; - } - - protected: - CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget); - CFWL_CheckBoxTP* m_pCheckBoxTP; - CFWL_ListBoxTP* m_pListBoxTP; - CFWL_PictureBoxTP* m_pPictureBoxTP; - CFWL_ScrollBarTP* m_pSrollBarTP; - CFWL_EditTP* m_pEditTP; - CFWL_ComboBoxTP* m_pComboBoxTP; - CFWL_MonthCalendarTP* m_pMonthCalendarTP; - CFWL_DateTimePickerTP* m_pDateTimePickerTP; - CFWL_PushButtonTP* m_pPushButtonTP; - CFWL_CaretTP* m_pCaretTP; - CFWL_BarcodeTP* m_pBarcodeTP; - IFDE_TextOut* m_pTextOut; - FX_FLOAT m_fCapacity; - FX_DWORD m_dwCapacity; - IFX_Font* m_pCalendarFont; - CFX_WideString m_wsResource; - CXFA_FFApp* m_pApp; - CFX_RectF m_Rect; - CFX_SizeF m_SizeAboveBelow; -}; -class CXFA_FWLCheckBoxTP : public CFWL_CheckBoxTP { - public: - CXFA_FWLCheckBoxTP(); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - - protected: - void DrawCheckSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - int32_t iState, - CFX_Matrix* pMatrix); -}; -class CXFA_FWLEditTP : public CFWL_EditTP { - public: - CXFA_FWLEditTP(); - virtual ~CXFA_FWLEditTP(); - - public: - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); -}; - -#endif // XFA_SRC_FXFA_APP_XFA_FWLTHEME_H_ diff --git a/xfa/src/fxfa/app/xfa_rendercontext.cpp b/xfa/src/fxfa/app/xfa_rendercontext.cpp deleted file mode 100644 index cc5402eb99..0000000000 --- a/xfa/src/fxfa/app/xfa_rendercontext.cpp +++ /dev/null @@ -1,77 +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/src/fxfa/app/xfa_rendercontext.h" - -#include "xfa/include/fxgraphics/fx_graphics.h" -#include "xfa/src/fxfa/app/xfa_ffwidget.h" - -#define XFA_RENDERCONTEXT_MaxCount 30 - -IXFA_RenderContext* XFA_RenderContext_Create() { - return new CXFA_RenderContext; -} -CXFA_RenderContext::CXFA_RenderContext() { - m_pWidgetIterator = NULL; - m_pWidget = NULL; - m_pPageView = NULL; - m_pGS = NULL; - m_dwStatus = 0; - m_matrix.SetIdentity(); - m_rtClipRect.Reset(); -} -CXFA_RenderContext::~CXFA_RenderContext() { - StopRender(); -} -int32_t CXFA_RenderContext::StartRender(IXFA_PageView* pPageView, - CFX_Graphics* pGS, - const CFX_Matrix& matrix, - const CXFA_RenderOptions& options) { - m_pPageView = pPageView; - m_pGS = pGS; - m_matrix = matrix; - m_options = options; - CFX_RectF rtPage; - pGS->GetClipRect(rtPage); - CFX_Matrix mtRes; - 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; - FX_DWORD dwFilterType = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_AllType | - (m_options.m_bPrint ? XFA_WIDGETSTATUS_Printable - : XFA_WIDGETSTATUS_Viewable); - m_pWidgetIterator = - m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType); - m_pWidget = m_pWidgetIterator->MoveToNext(); - return XFA_RENDERSTATUS_Ready; -} -int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { - int32_t iCount = 0; - while (m_pWidget) { - CXFA_FFWidget* pWidget = (CXFA_FFWidget*)m_pWidget; - CFX_RectF rtWidgetBox; - pWidget->GetBBox(rtWidgetBox, XFA_WIDGETSTATUS_Visible); - rtWidgetBox.width += 1; - rtWidgetBox.height += 1; - if (rtWidgetBox.IntersectWith(m_rtClipRect)) { - pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus); - } - m_pWidget = m_pWidgetIterator->MoveToNext(); - iCount++; - if (iCount > XFA_RENDERCONTEXT_MaxCount && pPause && - pPause->NeedToPauseNow()) { - return XFA_RENDERSTATUS_ToBeContinued; - } - } - return XFA_RENDERSTATUS_Done; -} -void CXFA_RenderContext::StopRender() { - if (m_pWidgetIterator) { - m_pWidgetIterator->Release(); - m_pWidgetIterator = NULL; - } -} diff --git a/xfa/src/fxfa/app/xfa_rendercontext.h b/xfa/src/fxfa/app/xfa_rendercontext.h deleted file mode 100644 index 9ed975c1fa..0000000000 --- a/xfa/src/fxfa/app/xfa_rendercontext.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_SRC_FXFA_APP_XFA_RENDERCONTEXT_H_ -#define XFA_SRC_FXFA_APP_XFA_RENDERCONTEXT_H_ - -#include "xfa/include/fxfa/fxfa.h" - -class CXFA_RenderContext : public IXFA_RenderContext { - public: - CXFA_RenderContext(); - virtual ~CXFA_RenderContext(); - virtual void Release() { delete this; } - virtual int32_t StartRender(IXFA_PageView* pPageView, - CFX_Graphics* pGS, - const CFX_Matrix& matrix, - const CXFA_RenderOptions& options); - virtual int32_t DoRender(IFX_Pause* pPause = NULL); - virtual void StopRender(); - - protected: - IXFA_WidgetIterator* m_pWidgetIterator; - IXFA_Widget* m_pWidget; - IXFA_PageView* m_pPageView; - CFX_Graphics* m_pGS; - CFX_Matrix m_matrix; - CXFA_RenderOptions m_options; - FX_DWORD m_dwStatus; - CFX_RectF m_rtClipRect; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_RENDERCONTEXT_H_ diff --git a/xfa/src/fxfa/app/xfa_textlayout.cpp b/xfa/src/fxfa/app/xfa_textlayout.cpp deleted file mode 100644 index b8a9ec433e..0000000000 --- a/xfa/src/fxfa/app/xfa_textlayout.cpp +++ /dev/null @@ -1,2001 +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/src/fxfa/app/xfa_textlayout.h" - -#include <algorithm> - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fde/fde_pen.h" -#include "xfa/src/fgas/crt/fgas_algorithm.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fxfa/app/xfa_ffapp.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/app/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, - int32_t iDeclCount) { - if (iDeclCount <= 0 || ppDeclArray == NULL) { - return; - } - m_dwMatchedDecls = iDeclCount; - m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount); - FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, - iDeclCount * sizeof(IFDE_CSSDeclaration*)); -} -CXFA_TextParser::~CXFA_TextParser() { - if (m_pUASheet) - m_pUASheet->Release(); - if (m_pSelector) - m_pSelector->Release(); - if (m_pAllocator) - m_pAllocator->Release(); - FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); - while (ps) { - IFDE_XMLNode* pXMLNode; - CXFA_TextParseContext* pParseContext; - m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); - if (pParseContext) - FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); - } - m_mapXMLNodeToParseContext.RemoveAll(); -} -void CXFA_TextParser::Reset() { - FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); - while (ps) { - IFDE_XMLNode* pXMLNode; - CXFA_TextParseContext* pParseContext; - m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); - if (pParseContext) - FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); - } - m_mapXMLNodeToParseContext.RemoveAll(); - if (m_pAllocator) { - m_pAllocator->Release(); - m_pAllocator = NULL; - } -} -void CXFA_TextParser::InitCSSData(IXFA_TextProvider* pTextProvider) { - if (pTextProvider == NULL) { - return; - } - if (m_pSelector == NULL) { - CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); - IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); - FXSYS_assert(pFontMgr); - m_pSelector = IFDE_CSSStyleSelector::Create(); - m_pSelector->SetFontMgr(pFontMgr); - FX_FLOAT fFontSize = 10; - CXFA_Font font = pTextProvider->GetFontNode(); - if (font) { - fFontSize = font.GetFontSize(); - } - m_pSelector->SetDefFontSize(fFontSize); - } - if (m_pUASheet == NULL) { - m_pUASheet = LoadDefaultSheetStyle(); - m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); - m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); - } -} -IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { - static const FX_WCHAR s_pStyle[] = - L"html,body,ol,p,ul{display:block}" - L"li{display:list-item}" - L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" - L"margin-bottom:0}ul,ol{margin:1.12em 0}" - L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-" - L"style:italic}" - L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" - L"size:.66em}"; - return IFDE_CSSStyleSheet::LoadFromBuffer( - CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); -} -IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( - IXFA_TextProvider* pTextProvider) { - CXFA_Font font = pTextProvider->GetFontNode(); - CXFA_Para para = pTextProvider->GetParaNode(); - IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL); - IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); - IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); - FX_FLOAT fLineHeight = 0, fFontSize = 10; - if (para) { - fLineHeight = para.GetLineHeight(); - FDE_CSSLENGTH indent; - indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); - pParaStyle->SetTextIndent(indent); - FDE_CSSTEXTALIGN hAlgin = FDE_CSSTEXTALIGN_Left; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - hAlgin = FDE_CSSTEXTALIGN_Center; - break; - case XFA_ATTRIBUTEENUM_Right: - hAlgin = FDE_CSSTEXTALIGN_Right; - break; - case XFA_ATTRIBUTEENUM_Justify: - hAlgin = FDE_CSSTEXTALIGN_Justify; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - hAlgin = FDE_CSSTEXTALIGN_JustifyAll; - break; - } - pParaStyle->SetTextAlign(hAlgin); - FDE_CSSRECT rtMarginWidth; - rtMarginWidth.left.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginLeft()); - rtMarginWidth.top.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceAbove()); - rtMarginWidth.right.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginRight()); - rtMarginWidth.bottom.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceBelow()); - pStyle->GetBoundaryStyles()->SetMarginWidth(rtMarginWidth); - } - if (font) { - pFontStyle->SetColor(font.GetColor()); - pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFONTSTYLE_Italic - : FDE_CSSFONTSTYLE_Normal); - pFontStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD - : FXFONT_FW_NORMAL); - pParaStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); - fFontSize = font.GetFontSize(); - FDE_CSSLENGTH letterSpacing; - letterSpacing.Set(FDE_CSSLENGTHUNIT_Point, font.GetLetterSpacing()); - pParaStyle->SetLetterSpacing(letterSpacing); - FX_DWORD dwDecoration = 0; - if (font.GetLineThrough() > 0) { - dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; - } - if (font.GetUnderline() > 1) { - dwDecoration |= FDE_CSSTEXTDECORATION_Double; - } else if (font.GetUnderline() > 0) { - dwDecoration |= FDE_CSSTEXTDECORATION_Underline; - } - pParaStyle->SetTextDecoration(dwDecoration); - } - pParaStyle->SetLineHeight(fLineHeight); - pFontStyle->SetFontSize(fFontSize); - return pStyle; -} -IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( - IFDE_CSSComputedStyle* pParentStyle) { - IFDE_CSSComputedStyle* pNewStyle = - m_pSelector->CreateComputedStyle(pParentStyle); - FXSYS_assert(pNewStyle); - if (pParentStyle) { - IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles(); - FX_DWORD dwDecoration = pParaStyle->GetTextDecoration(); - FX_FLOAT fBaseLine = 0; - if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { - fBaseLine = pParaStyle->GetNumberVerticalAlign(); - } - pParaStyle = pNewStyle->GetParagraphStyles(); - pParaStyle->SetTextDecoration(dwDecoration); - pParaStyle->SetNumberVerticalAlign(fBaseLine); - IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles(); - const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth(); - if (pRect) { - pBoundarytyle = pNewStyle->GetBoundaryStyles(); - pBoundarytyle->SetMarginWidth(*pRect); - } - } - return pNewStyle; -} -IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( - IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle) { - CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( - m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); - if (!pContext) - return nullptr; - pContext->m_pParentStyle = pParentStyle; - pParentStyle->AddRef(); - CXFA_CSSTagProvider tagProvider; - ParseTagInfo(pXMLNode, tagProvider); - if (tagProvider.m_bContent) - return nullptr; - IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); - IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); - pCSSAccel->OnEnterTag(&tagProvider); - m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), - pContext->CountDecls(), pStyle); - pCSSAccel->OnLeaveTag(&tagProvider); - return pStyle; -} -void CXFA_TextParser::DoParse(IFDE_XMLNode* pXMLContainer, - IXFA_TextProvider* pTextProvider) { - if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { - return; - } - m_pAllocator = - FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider)); - InitCSSData(pTextProvider); - IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); - ParseRichText(pXMLContainer, pRootStyle); - pRootStyle->Release(); -} -void CXFA_TextParser::ParseRichText(IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle) { - if (pXMLNode == NULL) { - return; - } - CXFA_CSSTagProvider tagProvider; - ParseTagInfo(pXMLNode, tagProvider); - if (!tagProvider.m_bTagAviliable) { - return; - } - IFDE_CSSComputedStyle* pNewStyle = NULL; - if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || - (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { - CXFA_TextParseContext* pTextContext = - FXTARGET_NewWith(m_pAllocator) CXFA_TextParseContext; - FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; - if (!tagProvider.m_bContent) { - pNewStyle = CreateStyle(pParentStyle); - IFDE_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(); - m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls, - pNewStyle); - pCSSAccel->OnLeaveTag(&tagProvider); - if (iMatchedDecls > 0) { - pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); - } - eDisplay = pNewStyle->GetPositionStyles()->GetDisplay(); - } - pTextContext->SetDisplay(eDisplay); - m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); - } - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - ParseRichText(pXMLChild, pNewStyle); - } - if (pNewStyle) - pNewStyle->Release(); -} -void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, - CXFA_CSSTagProvider& tagProvider) { - static const FX_DWORD s_XFATagName[] = { - 0x61, 0x62, 0x69, 0x70, 0x0001f714, - 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, - 0xa73e3af2, 0xb182eaae, 0xdb8ac455, - }; - CFX_WideString wsName; - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - pXMLElement->GetLocalTagName(wsName); - tagProvider.SetTagNameObj(wsName); - FX_DWORD dwHashCode = - FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); - static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(FX_DWORD); - CFX_DSPATemplate<FX_DWORD> lookup; - tagProvider.m_bTagAviliable = - lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; - CFX_WideString wsValue; - pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); - if (!wsValue.IsEmpty()) { - tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); - } - } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { - tagProvider.m_bTagAviliable = TRUE; - tagProvider.m_bContent = TRUE; - } -} -int32_t CXFA_TextParser::GetVAlgin(IXFA_TextProvider* pTextProvider) const { - int32_t iAlign = XFA_ATTRIBUTEENUM_Top; - CXFA_Para para = pTextProvider->GetParaNode(); - if (para) { - iAlign = para.GetVerticalAlign(); - } - return iAlign; -} -FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const { - CFX_WideString wsValue; - if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue)) { - CXFA_Measurement ms(wsValue); - return ms.ToUnit(XFA_UNIT_Pt); - } - return 36; -} -int32_t CXFA_TextParser::CountTabs(IFDE_CSSComputedStyle* pStyle) const { - CFX_WideString wsValue; - if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-count"), wsValue)) { - return wsValue.GetInteger(); - } - return 0; -} -FX_BOOL CXFA_TextParser::IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const { - CFX_WideString wsValue; - if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { - wsValue.MakeLower(); - return wsValue == FX_WSTRC(L"yes"); - } - return FALSE; -} -IFX_Font* CXFA_TextParser::GetFont(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { - CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); - FX_DWORD dwStyle = 0; - CXFA_Font font = pTextProvider->GetFontNode(); - if (font) { - font.GetTypeface(wsFamily); - if (font.IsBold()) { - dwStyle |= FX_FONTSTYLE_Bold; - } - if (font.IsItalic()) { - dwStyle |= FX_FONTSTYLE_Italic; - } - } - if (pStyle) { - IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); - int32_t iCount = pFontStyle->CountFontFamilies(); - if (iCount > 0) { - wsFamily = pFontStyle->GetFontFamily(iCount - 1); - } - dwStyle = 0; - if (pFontStyle->GetFontWeight() > FXFONT_FW_NORMAL) { - dwStyle |= FX_FONTSTYLE_Bold; - } - if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) { - dwStyle |= FX_FONTSTYLE_Italic; - } - } - CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); - CXFA_FontMgr* pFontMgr = pDoc->GetApp()->GetXFAFontMgr(); - return pFontMgr->GetFont(pDoc, wsFamily, dwStyle); -} -FX_FLOAT CXFA_TextParser::GetFontSize(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { - if (pStyle) - return pStyle->GetFontStyles()->GetFontSize(); - - CXFA_Font font = pTextProvider->GetFontNode(); - if (font) { - return font.GetFontSize(); - } - return 10; -} -int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - IFDE_XMLNode* pXMLNode) const { - if (pStyle) { - CFX_WideString wsValue; - if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"), - wsValue)) { - return wsValue.GetInteger(); - } - while (pXMLNode) { - CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( - m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); - if (pContext && pContext->m_pParentStyle && - pContext->m_pParentStyle->GetCustomStyle( - FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) { - return wsValue.GetInteger(); - } - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); - } - } - if (CXFA_Font font = pTextProvider->GetFontNode()) { - return static_cast<int32_t>(font.GetHorizontalScale()); - } - return 100; -} -int32_t CXFA_TextParser::GetVerScale(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { - if (pStyle) { - CFX_WideString wsValue; - if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-vertical-scale"), wsValue)) { - return wsValue.GetInteger(); - } - } - if (CXFA_Font font = pTextProvider->GetFontNode()) { - return (int32_t)font.GetVerticalScale(); - } - return 100; -} -void CXFA_TextParser::GetUnderline(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - int32_t& iUnderline, - int32_t& iPeriod) const { - iUnderline = 0; - iPeriod = XFA_ATTRIBUTEENUM_All; - if (pStyle) { - FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); - if (dwDecoration & FDE_CSSTEXTDECORATION_Double) { - iUnderline = 2; - } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) { - iUnderline = 1; - } - CFX_WideString wsValue; - if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) { - if (wsValue == FX_WSTRC(L"word")) { - iPeriod = XFA_ATTRIBUTEENUM_Word; - } - } else if (CXFA_Font font = pTextProvider->GetFontNode()) { - iPeriod = font.GetUnderlinePeriod(); - } - } else { - CXFA_Font font = pTextProvider->GetFontNode(); - if (font) { - iUnderline = font.GetUnderline(); - iPeriod = font.GetUnderlinePeriod(); - } - } -} -void CXFA_TextParser::GetLinethrough(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - int32_t& iLinethrough) const { - if (pStyle) { - FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); - iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; - } else { - CXFA_Font font = pTextProvider->GetFontNode(); - if (font) { - iLinethrough = font.GetLineThrough(); - } - } -} -FX_ARGB CXFA_TextParser::GetColor(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { - if (pStyle) - return pStyle->GetFontStyles()->GetColor(); - - if (CXFA_Font font = pTextProvider->GetFontNode()) - return font.GetColor(); - - return 0xFF000000; -} -FX_FLOAT CXFA_TextParser::GetBaseline(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const { - if (pStyle) { - IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); - if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { - return pParaStyle->GetNumberVerticalAlign(); - } - } else if (CXFA_Font font = pTextProvider->GetFontNode()) { - return font.GetBaselineShift(); - } - return 0; -} -FX_FLOAT CXFA_TextParser::GetLineHeight(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - FX_BOOL bFirst, - FX_FLOAT fVerScale) const { - FX_FLOAT fLineHeight = 0; - if (pStyle) { - fLineHeight = pStyle->GetParagraphStyles()->GetLineHeight(); - } else if (CXFA_Para para = pTextProvider->GetParaNode()) { - fLineHeight = para.GetLineHeight(); - } - if (bFirst) { - FX_FLOAT fFontSize = GetFontSize(pTextProvider, pStyle); - if (fLineHeight < 0.1f) { - fLineHeight = fFontSize; - } else { - fLineHeight = std::min(fLineHeight, fFontSize); - } - } else if (fLineHeight < 0.1f) { - fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; - } - fLineHeight *= fVerScale; - return fLineHeight; -} -FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, - IFDE_XMLNode* pXMLNode, - CFX_WideString& wsValue) { - wsValue.Empty(); - if (pXMLNode == NULL) { - return FALSE; - } - FX_BOOL bRet = FALSE; - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLNode; - CFX_WideString wsAttr; - pElement->GetString(FX_WSTRC(L"xfa:embed").GetPtr(), wsAttr); - if (wsAttr.IsEmpty()) { - return FALSE; - } - if (wsAttr.GetAt(0) == L'#') { - wsAttr.Delete(0); - } - CFX_WideString ws; - pElement->GetString(FX_WSTRC(L"xfa:embedType").GetPtr(), ws); - if (ws.IsEmpty()) { - ws = L"som"; - } else { - ws.MakeLower(); - } - FX_BOOL bURI = (ws == FX_WSTRC(L"uri")); - if (!bURI && ws != FX_WSTRC(L"som")) { - return FALSE; - } - ws.Empty(); - pElement->GetString(FX_WSTRC(L"xfa:embedMode").GetPtr(), ws); - if (ws.IsEmpty()) { - ws = L"formatted"; - } else { - ws.MakeLower(); - } - FX_BOOL bRaw = (ws == FX_WSTRC(L"raw")); - if (!bRaw && ws != FX_WSTRC(L"formatted")) { - return FALSE; - } - bRet = pTextProvider->GetEmbbedObj(bURI, bRaw, wsAttr, wsValue); - } - return bRet; -} -CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( - IFDE_XMLNode* pXMLNode) { - return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( - pXMLNode); -} -enum XFA_TABSTOPSSTATUS { - XFA_TABSTOPSSTATUS_Error, - XFA_TABSTOPSSTATUS_EOS, - XFA_TABSTOPSSTATUS_None, - XFA_TABSTOPSSTATUS_Alignment, - XFA_TABSTOPSSTATUS_StartLeader, - XFA_TABSTOPSSTATUS_Leader, - XFA_TABSTOPSSTATUS_Location, -}; -FX_BOOL CXFA_TextParser::GetTabstops( - IFDE_CSSComputedStyle* pStyle, - CXFA_TextTabstopsContext* pTabstopContext) { - if (pStyle == NULL || pTabstopContext == NULL) { - return FALSE; - } - CFX_WideString wsValue; - if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && - !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { - return FALSE; - } - int32_t iLength = wsValue.GetLength(); - const FX_WCHAR* pTabStops = wsValue; - int32_t iCur = 0; - int32_t iLast = 0; - CFX_WideString wsAlign; - XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None; - FX_WCHAR ch; - while (iCur < iLength) { - ch = pTabStops[iCur]; - switch (eStatus) { - case XFA_TABSTOPSSTATUS_None: - if (ch <= ' ') { - iCur++; - } else { - eStatus = XFA_TABSTOPSSTATUS_Alignment; - iLast = iCur; - } - break; - case XFA_TABSTOPSSTATUS_Alignment: - if (ch == ' ') { - wsAlign = CFX_WideStringC(pTabStops + iLast, iCur - iLast); - eStatus = XFA_TABSTOPSSTATUS_StartLeader; - iCur++; - while (iCur < iLength && pTabStops[iCur] <= ' ') { - iCur++; - } - iLast = iCur; - } else { - iCur++; - } - break; - case XFA_TABSTOPSSTATUS_StartLeader: - if (ch != 'l') { - eStatus = XFA_TABSTOPSSTATUS_Location; - } else { - int32_t iCount = 0; - while (iCur < iLength) { - ch = pTabStops[iCur]; - iCur++; - if (ch == '(') { - iCount++; - } else if (ch == ')') { - iCount--; - if (iCount == 0) { - break; - } - } - } - while (iCur < iLength && pTabStops[iCur] <= ' ') { - iCur++; - } - iLast = iCur; - eStatus = XFA_TABSTOPSSTATUS_Location; - } - break; - case XFA_TABSTOPSSTATUS_Location: - if (ch == ' ') { - FX_DWORD dwHashCode = - FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); - CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); - FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); - pTabstopContext->Append(dwHashCode, fPos); - wsAlign.Empty(); - eStatus = XFA_TABSTOPSSTATUS_None; - } - iCur++; - break; - default: - break; - } - } - if (!wsAlign.IsEmpty()) { - FX_DWORD dwHashCode = - FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); - CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); - FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); - pTabstopContext->Append(dwHashCode, fPos); - } - return TRUE; -} -CXFA_TextLayout::CXFA_TextLayout(IXFA_TextProvider* pTextProvider) - : m_bHasBlock(FALSE), - m_pTextProvider(pTextProvider), - m_pTextDataNode(nullptr), - m_bRichText(FALSE), - m_pAllocator(nullptr), - m_pBreak(nullptr), - m_pLoader(nullptr), - m_iLines(0), - m_fMaxWidth(0), - m_pTabstopContext(nullptr), - m_bBlockContinue(TRUE) { - FXSYS_assert(m_pTextProvider); -} -CXFA_TextLayout::~CXFA_TextLayout() { - m_textParser.Reset(); - delete m_pLoader; - delete m_pTabstopContext; - Unload(); -} -void CXFA_TextLayout::Unload() { - int32_t iCount = m_pieceLines.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CXFA_PieceLine* pLine = m_pieceLines.GetAt(i); - FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator, pLine); - } - m_pieceLines.RemoveAll(); - if (m_pBreak) { - m_pBreak->Release(); - m_pBreak = NULL; - } - if (m_pAllocator) { - m_pAllocator->Release(); - m_pAllocator = NULL; - } -} -const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { - return &m_pieceLines; -} -void CXFA_TextLayout::GetTextDataNode() { - if (m_pTextProvider == NULL) { - return; - } - CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); - if (pNode && m_bRichText) { - m_textParser.Reset(); - } - m_pTextDataNode = pNode; -} -IFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { - IFDE_XMLNode* pXMLContainer = NULL; - if (m_bRichText) { - IFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); - if (!pXMLRoot) { - return pXMLContainer; - } - for (IFDE_XMLNode* pXMLChild = - pXMLRoot->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; - CFX_WideString wsTag; - pXMLElement->GetLocalTagName(wsTag); - if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { - pXMLContainer = pXMLChild; - break; - } - } - } - } - return pXMLContainer; -} -IFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { - FX_DWORD dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; - if (!bDefault) { - dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; - } - IFX_RTFBreak* pBreak = IFX_RTFBreak::Create(0); - pBreak->SetLayoutStyles(dwStyle); - pBreak->SetLineBreakChar(L'\n'); - pBreak->SetLineBreakTolerance(1); - pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); - pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); - return pBreak; -} -void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { - CXFA_Font font = m_pTextProvider->GetFontNode(); - CXFA_Para para = m_pTextProvider->GetParaNode(); - FX_FLOAT fStart = 0; - FX_FLOAT fStartPos = 0; - if (para) { - int32_t iAlign = FX_RTFLINEALIGNMENT_Left; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - iAlign = FX_RTFLINEALIGNMENT_Center; - break; - case XFA_ATTRIBUTEENUM_Right: - iAlign = FX_RTFLINEALIGNMENT_Right; - break; - case XFA_ATTRIBUTEENUM_Justify: - iAlign = FX_RTFLINEALIGNMENT_Justified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - iAlign = FX_RTFLINEALIGNMENT_Distributed; - break; - } - m_pBreak->SetAlignment(iAlign); - fStart = para.GetMarginLeft(); - if (m_pTextProvider->IsCheckButtonAndAutoWidth()) { - if (iAlign != FX_RTFLINEALIGNMENT_Left) { - fLineWidth -= para.GetMarginRight(); - } - } else { - fLineWidth -= para.GetMarginRight(); - } - if (fLineWidth < 0) { - fLineWidth = fStart; - } - fStartPos = fStart; - FX_FLOAT fIndent = para.GetTextIndent(); - if (fIndent > 0) { - fStartPos += fIndent; - } - } - m_pBreak->SetLineBoundary(fStart, fLineWidth); - m_pBreak->SetLineStartPos(fStartPos); - if (font) { - m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); - m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); - m_pBreak->SetCharSpace(font.GetLetterSpacing()); - } - FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL); - m_pBreak->SetFontSize(fFontSize); - m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); - m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); -} -void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, - FDE_CSSDISPLAY eDisplay, - FX_FLOAT fLineWidth, - IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle) { - if (pStyle == NULL) { - InitBreak(fLineWidth); - return; - } - IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); - if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { - int32_t iAlign = FX_RTFLINEALIGNMENT_Left; - switch (pParaStyle->GetTextAlign()) { - case FDE_CSSTEXTALIGN_Right: - iAlign = FX_RTFLINEALIGNMENT_Right; - break; - case FDE_CSSTEXTALIGN_Center: - iAlign = FX_RTFLINEALIGNMENT_Center; - break; - case FDE_CSSTEXTALIGN_Justify: - iAlign = FX_RTFLINEALIGNMENT_Justified; - break; - case FDE_CSSTEXTALIGN_JustifyAll: - iAlign = FX_RTFLINEALIGNMENT_Distributed; - break; - default: - break; - } - m_pBreak->SetAlignment(iAlign); - FX_FLOAT fStart = 0; - const FDE_CSSRECT* pRect = pStyle->GetBoundaryStyles()->GetMarginWidth(); - const FDE_CSSRECT* pPaddingRect = - pStyle->GetBoundaryStyles()->GetPaddingWidth(); - if (pRect) { - fStart = pRect->left.GetValue(); - fLineWidth -= pRect->right.GetValue(); - if (pPaddingRect) { - fStart += pPaddingRect->left.GetValue(); - fLineWidth -= pPaddingRect->right.GetValue(); - } - if (eDisplay == FDE_CSSDISPLAY_ListItem) { - const FDE_CSSRECT* pParRect = - pParentStyle->GetBoundaryStyles()->GetMarginWidth(); - const FDE_CSSRECT* pParPaddingRect = - pParentStyle->GetBoundaryStyles()->GetPaddingWidth(); - if (pParRect) { - fStart += pParRect->left.GetValue(); - fLineWidth -= pParRect->right.GetValue(); - if (pParPaddingRect) { - fStart += pParPaddingRect->left.GetValue(); - fLineWidth -= pParPaddingRect->right.GetValue(); - } - } - FDE_CSSRECT pNewRect; - pNewRect.left.Set(FDE_CSSLENGTHUNIT_Point, fStart); - pNewRect.right.Set(FDE_CSSLENGTHUNIT_Point, pRect->right.GetValue()); - pNewRect.top.Set(FDE_CSSLENGTHUNIT_Point, pRect->top.GetValue()); - pNewRect.bottom.Set(FDE_CSSLENGTHUNIT_Point, pRect->bottom.GetValue()); - pStyle->GetBoundaryStyles()->SetMarginWidth(pNewRect); - } - } - m_pBreak->SetLineBoundary(fStart, fLineWidth); - FX_FLOAT fIndent = pParaStyle->GetTextIndent().GetValue(); - if (fIndent > 0) { - fStart += fIndent; - } - m_pBreak->SetLineStartPos(fStart); - m_pBreak->SetTabWidth(m_textParser.GetTabInterval(pStyle)); - if (m_pTabstopContext == NULL) { - m_pTabstopContext = new CXFA_TextTabstopsContext; - } - m_textParser.GetTabstops(pStyle, m_pTabstopContext); - for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) { - XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i); - m_pBreak->AddPositionedTab(pTab->fTabstops); - } - } - FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); - m_pBreak->SetFontSize(fFontSize); - m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); - m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, pStyle)); - m_pBreak->SetHorizontalScale( - m_textParser.GetHorScale(m_pTextProvider, pStyle, pXMLNode)); - m_pBreak->SetVerticalScale(m_textParser.GetVerScale(m_pTextProvider, pStyle)); - m_pBreak->SetCharSpace(pParaStyle->GetLetterSpacing().GetValue()); -} -int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { - GetTextDataNode(); - wsText.Empty(); - if (m_bRichText) { - } else { - wsText = m_pTextDataNode->GetContent(); - } - return wsText.GetLength(); -} -FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { - if (m_pLoader == NULL) { - return 0; - } - int32_t iCount = m_pLoader->m_lineHeights.GetSize(); - if (iCount == 0 && m_pLoader->m_fWidth > 0) { - CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); - CFX_SizeF szDef; - m_pLoader->m_bSaveLineHeight = TRUE; - m_pLoader->m_fLastPos = 0; - CalcSize(szMax, szMax, szDef); - m_pLoader->m_bSaveLineHeight = FALSE; - return szDef.y; - } - FX_FLOAT fHeight = m_pLoader->m_fHeight; - if (fHeight < 0.1f) { - fHeight = 0; - for (int32_t i = 0; i < iCount; i++) { - fHeight += m_pLoader->m_lineHeights.ElementAt(i); - } - } - return fHeight; -} -FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) { - if (m_pLoader == NULL) { - m_pLoader = new CXFA_LoaderContext; - } - if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && - FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { - m_pLoader->m_lineHeights.RemoveAll(); - m_Blocks.RemoveAll(); - Unload(); - m_pLoader->m_fStartLineOffset = 0; - } - m_pLoader->m_fWidth = fWidth; - if (fWidth < 0) { - CFX_SizeF szMax; - CFX_SizeF szDef; - m_pLoader->m_bSaveLineHeight = TRUE; - m_pLoader->m_fLastPos = 0; - CalcSize(szMax, szMax, szDef); - m_pLoader->m_bSaveLineHeight = FALSE; - fWidth = szDef.x; - } - return fWidth; -} -FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, - FX_FLOAT& fCalcHeight, - FX_FLOAT fContentAreaHeight, - FX_FLOAT fTextHeight) { - if (m_pLoader == NULL) { - return FALSE; - } - int32_t iBlockCount = m_Blocks.GetSize(); - FX_FLOAT fHeight = fTextHeight; - if (fHeight < 0) { - fHeight = GetLayoutHeight(); - } - m_pLoader->m_fHeight = fHeight; - if (fContentAreaHeight < 0) { - return FALSE; - } - m_bHasBlock = TRUE; - if (iBlockCount == 0 && fHeight > 0) { - fHeight = fTextHeight - GetLayoutHeight(); - if (fHeight > 0) { - int32_t iAlign = m_textParser.GetVAlgin(m_pTextProvider); - if (iAlign == XFA_ATTRIBUTEENUM_Middle) { - fHeight /= 2.0f; - } else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) { - fHeight = 0; - } - m_pLoader->m_fStartLineOffset = fHeight; - } - } - FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; - int32_t iLineIndex = 0; - if (iBlockCount > 1) { - if (iBlockCount >= (iBlockIndex + 1) * 2) { - iLineIndex = m_Blocks.ElementAt(iBlockIndex * 2); - } else { - iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + - m_Blocks.ElementAt(iBlockCount - 2); - } - if (m_pLoader->m_BlocksHeight.GetSize() > 0) { - for (int32_t i = 0; i < iBlockIndex; i++) { - fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); - } - } - } - int32_t iCount = m_pLoader->m_lineHeights.GetSize(); - int32_t i = 0; - for (i = iLineIndex; i < iCount; i++) { - FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); - if ((i == iLineIndex) && (fLineHeight - fContentAreaHeight > 0.001)) { - fCalcHeight = 0; - return TRUE; - } - if (fLinePos + fLineHeight - fContentAreaHeight > 0.001) { - if (iBlockCount >= (iBlockIndex + 1) * 2) { - m_Blocks.SetAt(iBlockIndex * 2, iLineIndex); - m_Blocks.SetAt(iBlockIndex * 2 + 1, i - iLineIndex); - } else { - m_Blocks.Add(iLineIndex); - m_Blocks.Add(i - iLineIndex); - } - if (i == iLineIndex) { - if (fCalcHeight <= fLinePos) { - if (m_pLoader->m_BlocksHeight.GetSize() > iBlockIndex * 2 && - (m_pLoader->m_BlocksHeight.GetAt(iBlockIndex * 2) == - iBlockIndex)) { - m_pLoader->m_BlocksHeight.SetAt(iBlockIndex * 2 + 1, fCalcHeight); - } else { - m_pLoader->m_BlocksHeight.Add((FX_FLOAT)iBlockIndex); - m_pLoader->m_BlocksHeight.Add(fCalcHeight); - } - } - return TRUE; - } - fCalcHeight = fLinePos; - return TRUE; - } - fLinePos += fLineHeight; - } - return FALSE; -} -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) { - defaultSize.x = maxSize.x; - if (defaultSize.x < 1) { - defaultSize.x = 0xFFFF; - } - if (m_pBreak) - m_pBreak->Release(); - - m_pBreak = CreateBreak(FALSE); - FX_FLOAT fLinePos = 0; - m_iLines = 0; - m_fMaxWidth = 0; - Loader(defaultSize, fLinePos, FALSE); - if (fLinePos < 0.1f) { - fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); - } - if (m_pTabstopContext) { - delete m_pTabstopContext; - m_pTabstopContext = NULL; - } - 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; - } - Unload(); - m_pBreak = CreateBreak(TRUE); - if (m_pLoader) { - m_pLoader->m_iTotalLines = -1; - m_pLoader->m_iChar = 0; - } - m_iLines = 0; - FX_FLOAT fLinePos = 0; - Loader(size, fLinePos, TRUE); - UpdateAlign(size.y, fLinePos); - if (m_pTabstopContext) { - delete m_pTabstopContext; - m_pTabstopContext = NULL; - } - if (fHeight) { - *fHeight = fLinePos; - } - return TRUE; -} -FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { - if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { - return FALSE; - } - if (m_pLoader->m_fWidth < 1) { - return FALSE; - } - m_pLoader->m_iTotalLines = -1; - m_iLines = 0; - FX_FLOAT fLinePos = 0; - CXFA_Node* pNode = NULL; - CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); - int32_t iCount = m_Blocks.GetSize(); - int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); - iBlocksHeightCount /= 2; - if (iBlock < iBlocksHeightCount) { - return TRUE; - } - if (iBlock == iBlocksHeightCount) { - Unload(); - m_pBreak = CreateBreak(TRUE); - fLinePos = m_pLoader->m_fStartLineOffset; - for (int32_t i = 0; i < iBlocksHeightCount; i++) { - fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); - } - m_pLoader->m_iChar = 0; - if (iCount > 1) { - m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); - } - Loader(szText, fLinePos, TRUE); - if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) { - UpdateAlign(szText.y, fLinePos); - } - } else if (m_pTextDataNode) { - iBlock *= 2; - if (iBlock < iCount - 2) { - m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock + 1); - } - m_pBreak->Reset(); - if (m_bRichText) { - IFDE_XMLNode* pContainerNode = GetXMLContainerNode(); - if (!pContainerNode) { - return TRUE; - } - IFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; - if (pXMLNode == NULL) { - return TRUE; - } - IFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; - for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, - m_pLoader->m_pParentStyle, TRUE); - if (!bFlag) { - break; - } - } - while (pXMLNode == NULL) { - pXMLNode = pSaveXMLNode->GetNodeItem(IFDE_XMLNode::Parent); - if (pXMLNode == pContainerNode) { - break; - } - FX_BOOL bFlag = - LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, - TRUE, NULL, FALSE); - if (!bFlag) { - break; - } - pSaveXMLNode = pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); - if (!pXMLNode) { - continue; - } - for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, - m_pLoader->m_pParentStyle, TRUE); - if (!bFlag) { - break; - } - } - } - } else { - pNode = m_pLoader->m_pNode; - if (pNode == NULL) { - return TRUE; - } - LoadText(pNode, szText, fLinePos, TRUE); - } - } - if (iBlock == iCount) { - delete m_pTabstopContext; - m_pTabstopContext = nullptr; - delete m_pLoader; - m_pLoader = nullptr; - } - return TRUE; -} -void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) { - if (!m_pLoader) { - return; - } - int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize(); - if (iCountHeight == 0) { - return; - } - FX_BOOL bEndItem = TRUE; - int32_t iBlockCount = m_Blocks.GetSize(); - FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset; - int32_t iLineIndex = 0; - if (iBlockIndex > 0) { - int32_t iBlockHeightCount = m_pLoader->m_BlocksHeight.GetSize(); - iBlockHeightCount /= 2; - if (iBlockHeightCount >= iBlockIndex) { - for (int32_t i = 0; i < iBlockIndex; i++) { - fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); - } - } else { - fLinePos = 0; - } - iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) + - m_Blocks.ElementAt(iBlockCount - 2); - } - int32_t i = 0; - for (i = iLineIndex; i < iCountHeight; i++) { - FX_FLOAT fLineHeight = m_pLoader->m_lineHeights.ElementAt(i); - if (fLinePos + fLineHeight - rtText.height > 0.001) { - m_Blocks.Add(iLineIndex); - m_Blocks.Add(i - iLineIndex); - bEndItem = FALSE; - break; - } - fLinePos += fLineHeight; - } - if (iCountHeight > 0 && (i - iLineIndex) > 0 && bEndItem) { - m_Blocks.Add(iLineIndex); - m_Blocks.Add(i - iLineIndex); - } -} -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) { - return 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); - if (m_pieceLines.GetSize() == 0) { - int32_t iBlockCount = CountBlocks(); - for (int32_t i = 0; i < iBlockCount; i++) { - Layout(i); - } - } - FXTEXT_CHARPOS* pCharPos = NULL; - int32_t iCharCount = 0; - int32_t iLineStart = 0; - int32_t iPieceLines = m_pieceLines.GetSize(); - int32_t iCount = m_Blocks.GetSize(); - if (iCount > 0) { - iBlock *= 2; - if (iBlock < iCount) { - iLineStart = m_Blocks.ElementAt(iBlock); - iPieceLines = m_Blocks.ElementAt(iBlock + 1); - } else { - iPieceLines = 0; - } - } - for (int32_t i = 0; i < iPieceLines; i++) { - if (i + iLineStart >= m_pieceLines.GetSize()) { - break; - } - CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i + iLineStart); - int32_t iPieces = pPieceLine->m_textPieces.GetSize(); - int32_t j = 0; - for (j = 0; j < iPieces; j++) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); - int32_t iChars = pPiece->iChars; - if (iCharCount < iChars) { - FX_Free(pCharPos); - pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars); - iCharCount = iChars; - } - FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); - RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device); - } - for (j = 0; j < iPieces; j++) { - RenderPath(pDevice, pPen, 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) { - fHeight -= fBottom; - if (fHeight < 0.1f) { - return; - } - switch (m_textParser.GetVAlgin(m_pTextProvider)) { - case XFA_ATTRIBUTEENUM_Middle: - fHeight /= 2.0f; - break; - case XFA_ATTRIBUTEENUM_Bottom: - break; - default: - return; - } - int32_t iCount = m_pieceLines.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i); - int32_t iPieces = pPieceLine->m_textPieces.GetSize(); - for (int32_t j = 0; j < iPieces; j++) { - XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); - CFX_RectF& rect = pPiece->rtPiece; - rect.top += fHeight; - } - } -} -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); - } - GetTextDataNode(); - if (m_pTextDataNode == NULL) { - return TRUE; - } - if (m_bRichText) { - IFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); - if (pXMLContainer) { - if (!m_textParser.IsParsed()) { - m_textParser.DoParse(pXMLContainer, m_pTextProvider); - } - IFDE_CSSComputedStyle* pRootStyle = - m_textParser.CreateRootStyle(m_pTextProvider); - LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); - pRootStyle->Release(); - } - } else { - LoadText(m_pTextDataNode, szText, fLinePos, bSavePieces); - } - return TRUE; -} -void CXFA_TextLayout::LoadText(CXFA_Node* pNode, - const CFX_SizeF& szText, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces) { - InitBreak(szText.x); - CXFA_Para para = m_pTextProvider->GetParaNode(); - FX_FLOAT fSpaceAbove = 0; - if (para) { - fSpaceAbove = para.GetSpaceAbove(); - if (fSpaceAbove < 0.1f) { - fSpaceAbove = 0; - } - int32_t verAlign = para.GetVerticalAlign(); - switch (verAlign) { - case XFA_ATTRIBUTEENUM_Top: - case XFA_ATTRIBUTEENUM_Middle: - case XFA_ATTRIBUTEENUM_Bottom: { - fLinePos += fSpaceAbove; - break; - } - } - } - CFX_WideString wsText = pNode->GetContent(); - wsText.TrimRight(L" "); - FX_BOOL bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces); - if (bRet && m_pLoader) { - m_pLoader->m_pNode = pNode; - } else { - EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); - } -} -FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, - const CFX_SizeF& szText, - FX_FLOAT& fLinePos, - IFDE_CSSComputedStyle* pParentStyle, - FX_BOOL bSavePieces, - CXFA_LinkUserData* pLinkData, - FX_BOOL bEndBreak, - FX_BOOL bIsOl, - int32_t iLiCount) { - if (pXMLNode == NULL) { - return FALSE; - } - CXFA_TextParseContext* pContext = - m_textParser.GetParseContextFromMap(pXMLNode); - FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; - FX_BOOL bContentNode = FALSE; - FX_FLOAT fSpaceBelow = 0; - IFDE_CSSComputedStyle* pStyle = NULL; - CFX_WideString wsName; - if (bEndBreak) { - FX_BOOL bCurOl = FALSE; - FX_BOOL bCurLi = FALSE; - IFDE_XMLElement* pElement = NULL; - if (pContext) { - if (m_bBlockContinue || - (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { - m_bBlockContinue = TRUE; - } - if (pXMLNode->GetType() == FDE_XMLNODE_Text) { - bContentNode = TRUE; - } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - pElement = (IFDE_XMLElement*)pXMLNode; - pElement->GetLocalTagName(wsName); - } - if (wsName == FX_WSTRC(L"ol")) { - bIsOl = TRUE; - bCurOl = TRUE; - } - if (m_bBlockContinue || bContentNode == FALSE) { - eDisplay = pContext->GetDisplay(); - if (eDisplay != FDE_CSSDISPLAY_Block && - eDisplay != FDE_CSSDISPLAY_Inline && - eDisplay != FDE_CSSDISPLAY_ListItem) { - return TRUE; - } - pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle); - InitBreak(bContentNode ? pParentStyle : pStyle, eDisplay, szText.x, - pXMLNode, pParentStyle); - if ((eDisplay == FDE_CSSDISPLAY_Block || - eDisplay == FDE_CSSDISPLAY_ListItem) && - pStyle && - (wsName.IsEmpty() || - (wsName != FX_WSTRC(L"body") && wsName != FX_WSTRC(L"html") && - wsName != FX_WSTRC(L"ol") && wsName != FX_WSTRC(L"ul")))) { - const FDE_CSSRECT* pRect = - pStyle->GetBoundaryStyles()->GetMarginWidth(); - if (pRect) { - fLinePos += pRect->top.GetValue(); - fSpaceBelow = pRect->bottom.GetValue(); - } - } - if (wsName == FX_WSTRC(L"a")) { - CFX_WideString wsLinkContent; - FXSYS_assert(pElement); - pElement->GetString(FX_WSTRC(L"href").GetPtr(), wsLinkContent); - if (!wsLinkContent.IsEmpty()) { - pLinkData = FXTARGET_NewWith(m_pAllocator) CXFA_LinkUserData( - m_pAllocator, - wsLinkContent.GetBuffer(wsLinkContent.GetLength())); - wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); - } - } - int32_t iTabCount = - m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); - FX_BOOL bSpaceRun = - m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); - CFX_WideString wsText; - if (bContentNode && iTabCount == 0) { - ((IFDE_XMLText*)pXMLNode)->GetText(wsText); - } else if (wsName == FX_WSTRC(L"br")) { - wsText = L'\n'; - } else if (wsName == FX_WSTRC(L"li")) { - bCurLi = TRUE; - if (bIsOl) { - wsText.Format(L"%d. ", iLiCount); - } else { - wsText = 0x00B7 + FX_WSTRC(L" "); - } - } else if (!bContentNode) { - if (iTabCount > 0) { - while (iTabCount-- > 0) - wsText += L'\t'; - } else { - m_textParser.GetEmbbedObj(m_pTextProvider, pXMLNode, wsText); - } - } - int32_t iLength = wsText.GetLength(); - if (iLength > 0 && bContentNode && !bSpaceRun) { - ProcessText(wsText); - } - if (m_pLoader) { - if (wsText.GetLength() > 0 && - (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { - wsText.TrimLeft(0x20); - } - if (FDE_CSSDISPLAY_Block == eDisplay) { - m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; - } else if (FDE_CSSDISPLAY_Inline == eDisplay && - (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { - m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; - } else if (wsText.GetLength() > 0 && - (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { - m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; - } else if (wsText.GetLength() != 0) { - m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; - } - } - if (wsText.GetLength() > 0) { - if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { - if (pLinkData) { - pLinkData->AddRef(); - } - CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator) - CXFA_TextUserData(m_pAllocator, - bContentNode ? pParentStyle : pStyle, - pLinkData); - m_pBreak->SetUserData(pUserData); - } - if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { - if (m_pLoader) { - m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; - } - if (IsEnd(bSavePieces)) { - if (m_pLoader && m_pLoader->m_iTotalLines > -1) { - m_pLoader->m_pXMLNode = pXMLNode; - m_pLoader->m_pParentStyle = pParentStyle; - } - if (pStyle) - pStyle->Release(); - return FALSE; - } - return TRUE; - } - } - } - } - FX_BOOL ret = TRUE; - for (IFDE_XMLNode* pChildNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (bCurOl) { - iLiCount++; - } - ret = LoadRichText(pChildNode, szText, fLinePos, - pContext ? pStyle : pParentStyle, bSavePieces, - pLinkData, TRUE, bIsOl, iLiCount); - if (ret == FALSE) { - return FALSE; - } - } - if (m_pLoader) { - if (FDE_CSSDISPLAY_Block == eDisplay) { - m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; - } - } - if (bCurLi) { - EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); - } - } else { - if (pContext) { - eDisplay = pContext->GetDisplay(); - } - } - if (m_bBlockContinue) { - if (pContext && !bContentNode) { - FX_DWORD dwStatus = (eDisplay == FDE_CSSDISPLAY_Block) - ? FX_RTFBREAK_ParagraphBreak - : FX_RTFBREAK_PieceBreak; - EndBreak(dwStatus, fLinePos, bSavePieces); - if (eDisplay == FDE_CSSDISPLAY_Block) { - fLinePos += fSpaceBelow; - if (m_pTabstopContext) { - m_pTabstopContext->RemoveAll(); - } - } - if (wsName == FX_WSTRC(L"a")) { - if (pLinkData) { - pLinkData->Release(); - pLinkData = nullptr; - } - } - if (IsEnd(bSavePieces)) { - if (pStyle) { - pStyle->Release(); - } - if (m_pLoader && m_pLoader->m_iTotalLines > -1) { - m_pLoader->m_pXMLNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); - m_pLoader->m_pParentStyle = pParentStyle; - } - return FALSE; - } - } - } - if (pStyle) - pStyle->Release(); - return TRUE; -} -FX_BOOL CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, - FX_FLOAT& fLinePos, - FX_FLOAT fSpaceAbove, - FX_BOOL bSavePieces) { - FX_DWORD dwStatus = 0; - int32_t iChar = 0; - if (m_pLoader) { - iChar = m_pLoader->m_iChar; - } - int32_t iLength = wsText.GetLength(); - for (int32_t i = iChar; i < iLength; i++) { - FX_WCHAR wch = wsText.GetAt(i); - if (wch == 0xA0) { - wch = 0x20; - } - if ((dwStatus = m_pBreak->AppendChar(wch)) > FX_RTFBREAK_PieceBreak) { - AppendTextLine(dwStatus, fLinePos, bSavePieces); - if (IsEnd(bSavePieces)) { - if (m_pLoader) - m_pLoader->m_iChar = i; - return TRUE; - } - if (dwStatus == FX_RTFBREAK_ParagraphBreak && m_bRichText) { - fLinePos += fSpaceAbove; - } - } - } - if (m_pLoader) { - m_pLoader->m_iChar = 0; - } - return FALSE; -} -FX_BOOL CXFA_TextLayout::IsEnd(FX_BOOL bSavePieces) { - if (!bSavePieces) { - return FALSE; - } - if (m_pLoader && m_pLoader->m_iTotalLines > 0) { - return m_iLines >= m_pLoader->m_iTotalLines; - } - return FALSE; -} -void CXFA_TextLayout::ProcessText(CFX_WideString& wsText) { - int32_t iLen = wsText.GetLength(); - if (iLen == 0) { - return; - } - FX_WCHAR* psz = wsText.GetBuffer(iLen); - int32_t iTrimLeft = 0; - FX_WCHAR wch = 0, wPrev = 0; - for (int32_t i = 0; i < iLen; i++) { - wch = psz[i]; - if (wch < 0x20) { - wch = 0x20; - } - if (wch == 0x20 && wPrev == 0x20) { - continue; - } - wPrev = wch; - psz[iTrimLeft++] = wch; - } - wsText.ReleaseBuffer(iLen); - wsText = wsText.Left(iTrimLeft); -} -void CXFA_TextLayout::EndBreak(FX_DWORD dwStatus, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces) { - dwStatus = m_pBreak->EndBreak(dwStatus); - if (dwStatus > FX_RTFBREAK_PieceBreak) { - AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); - } -} -void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, - CXFA_PieceLine* pPieceLine) { - if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { - return; - } - if (pStyle == NULL || pPieceLine == NULL) { - return; - } - int32_t iPieces = pPieceLine->m_textPieces.GetSize(); - if (iPieces == 0) { - return; - } - XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); - int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; - int32_t iCount = m_textParser.CountTabs(pStyle); - if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { - return; - } - if (iCount > 0) { - iTabstopsIndex++; - m_pTabstopContext->m_bTabstops = TRUE; - FX_FLOAT fRight = 0; - if (iPieces > 1) { - XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); - fRight = p->rtPiece.right(); - } - m_pTabstopContext->m_fTabWidth = - pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; - } else if (iTabstopsIndex > -1) { - FX_FLOAT fLeft = 0; - if (m_pTabstopContext->m_bTabstops) { - XFA_TABSTOPS* pTabstops = - m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); - FX_DWORD dwAlgin = pTabstops->dwAlign; - if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) { - fLeft = pPiece->rtPiece.width / 2.0f; - } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) || - dwAlgin == FX_HashCode_String_GetW(L"before", 6)) { - fLeft = pPiece->rtPiece.width; - } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) { - int32_t iChars = pPiece->iChars; - for (int32_t i = 0; i < iChars; i++) { - if (pPiece->pszText[i] == L'.') { - break; - } - fLeft += pPiece->pWidths[i] / 20000.0f; - } - } - m_pTabstopContext->m_fLeft = - std::min(fLeft, m_pTabstopContext->m_fTabWidth); - m_pTabstopContext->m_bTabstops = FALSE; - m_pTabstopContext->m_fTabWidth = 0; - } - pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; - } -} -void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces, - FX_BOOL bEndBreak) { - int32_t iPieces = m_pBreak->CountBreakPieces(); - if (iPieces < 1) { - return; - } - IFDE_CSSComputedStyle* pStyle = NULL; - if (bSavePieces) { - CXFA_PieceLine* pPieceLine = FXTARGET_NewWith(m_pAllocator) CXFA_PieceLine; - m_pieceLines.Add(pPieceLine); - if (m_pTabstopContext) { - m_pTabstopContext->Reset(); - } - FX_FLOAT fLineStep = 0, fBaseLine = 0; - int32_t i = 0; - for (i = 0; i < iPieces; i++) { - const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i); - CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData; - if (pUserData) - pStyle = pUserData->m_pStyle; - FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; - XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator) XFA_TextPiece(); - pTP->pszText = - (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR)); - pTP->pWidths = - (int32_t*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(int32_t)); - pTP->iChars = pPiece->m_iChars; - pPiece->GetString(pTP->pszText); - pPiece->GetWidths(pTP->pWidths); - pTP->iBidiLevel = pPiece->m_iBidiLevel; - pTP->iHorScale = pPiece->m_iHorizontalScale; - pTP->iVerScale = pPiece->m_iVerticalScale; - m_textParser.GetUnderline(m_pTextProvider, pStyle, pTP->iUnderline, - pTP->iPeriod); - m_textParser.GetLinethrough(m_pTextProvider, pStyle, pTP->iLineThrough); - pTP->dwColor = m_textParser.GetColor(m_pTextProvider, pStyle); - pTP->pFont = m_textParser.GetFont(m_pTextProvider, pStyle); - pTP->fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); - pTP->rtPiece.left = pPiece->m_iStartPos / 20000.0f; - pTP->rtPiece.width = pPiece->m_iWidth / 20000.0f; - pTP->rtPiece.height = (FX_FLOAT)pPiece->m_iFontSize * fVerScale / 20.0f; - FX_FLOAT fBaseLineTemp = - m_textParser.GetBaseline(m_pTextProvider, pStyle); - pTP->rtPiece.top = fBaseLineTemp; - pPieceLine->m_textPieces.Add(pTP); - FX_FLOAT fLineHeight = m_textParser.GetLineHeight( - m_pTextProvider, pStyle, m_iLines == 0, fVerScale); - if (fBaseLineTemp > 0) { - FX_FLOAT fLineHeightTmp = fBaseLineTemp + pTP->rtPiece.height; - if (fLineHeight < fLineHeightTmp) { - fLineHeight = fLineHeightTmp; - } else { - fBaseLineTemp = 0; - } - } else if (fBaseLine < -fBaseLineTemp) { - fBaseLine = -fBaseLineTemp; - } - fLineStep = std::max(fLineStep, fLineHeight); - if (pUserData && pUserData->m_pLinkData) { - pUserData->m_pLinkData->AddRef(); - pTP->pLinkData = pUserData->m_pLinkData; - } else { - pTP->pLinkData = NULL; - } - DoTabstops(pStyle, pPieceLine); - } - for (i = 0; i < iPieces; i++) { - XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); - FX_FLOAT& fTop = pTP->rtPiece.top; - FX_FLOAT fBaseLineTemp = fTop; - fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; - fTop = std::max(0.0f, fTop); - } - fLinePos += fLineStep + fBaseLine; - } else { - FX_FLOAT fLineStep = 0; - FX_FLOAT fLineWidth = 0; - for (int32_t i = 0; i < iPieces; i++) { - const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i); - CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData; - if (pUserData) - pStyle = pUserData->m_pStyle; - FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; - FX_FLOAT fBaseLine = m_textParser.GetBaseline(m_pTextProvider, pStyle); - FX_FLOAT fLineHeight = m_textParser.GetLineHeight( - m_pTextProvider, pStyle, m_iLines == 0, fVerScale); - if (fBaseLine > 0) { - FX_FLOAT fLineHeightTmp = - fBaseLine + (FX_FLOAT)pPiece->m_iFontSize * fVerScale / 20.0f; - if (fLineHeight < fLineHeightTmp) { - fLineHeight = fLineHeightTmp; - } - } - fLineStep = std::max(fLineStep, fLineHeight); - fLineWidth += pPiece->m_iWidth / 20000.0f; - } - fLinePos += fLineStep; - m_fMaxWidth = std::max(m_fMaxWidth, fLineWidth); - if (m_pLoader && m_pLoader->m_bSaveLineHeight) { - FX_FLOAT fHeight = fLinePos - m_pLoader->m_fLastPos; - m_pLoader->m_fLastPos = fLinePos; - m_pLoader->m_lineHeights.Add(fHeight); - } - } - if (pStyle) { - pStyle->AddRef(); - } - m_pBreak->ClearBreakPieces(); - if (dwStatus == FX_RTFBREAK_ParagraphBreak) { - m_pBreak->Reset(); - if (!pStyle && bEndBreak) { - CXFA_Para para = m_pTextProvider->GetParaNode(); - if (para) { - FX_FLOAT fStartPos = para.GetMarginLeft(); - FX_FLOAT fIndent = para.GetTextIndent(); - if (fIndent > 0) { - fStartPos += fIndent; - } - FX_FLOAT fSpaceBelow = para.GetSpaceBelow(); - if (fSpaceBelow < 0.1f) { - fSpaceBelow = 0; - } - m_pBreak->SetLineStartPos(fStartPos); - fLinePos += fSpaceBelow; - } - } - } - if (pStyle) { - FX_FLOAT fStart = 0; - const FDE_CSSRECT* pRect = pStyle->GetBoundaryStyles()->GetMarginWidth(); - if (pRect) { - fStart = pRect->left.GetValue(); - } - FX_FLOAT fTextIndent = - pStyle->GetParagraphStyles()->GetTextIndent().GetValue(); - if (fTextIndent < 0) { - fStart -= fTextIndent; - } - m_pBreak->SetLineStartPos(fStart); - pStyle->Release(); - } - m_iLines++; -} -void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, - IFDE_SolidBrush* pBrush, - CXFA_PieceLine* pPieceLine, - int32_t iPiece, - FXTEXT_CHARPOS* pCharPos, - const CFX_Matrix& tmDoc2Device) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); - int32_t iCount = GetDisplayPos(pPiece, pCharPos); - if (iCount > 0) { - pBrush->SetColor(pPiece->dwColor); - pDevice->DrawString(pBrush, pPiece->pFont, pCharPos, iCount, - pPiece->fFontSize, &tmDoc2Device); - } - pPieceLine->m_charCounts.Add(iCount); -} -void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, - IFDE_Pen* pPen, - CXFA_PieceLine* pPieceLine, - int32_t iPiece, - FXTEXT_CHARPOS* pCharPos, - const CFX_Matrix& tmDoc2Device) { - XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); - FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; - FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; - if (bNoUnderline && bNoLineThrough) { - return; - } - pPen->SetColor(pPiece->dwColor); - IFDE_Path* pPath = IFDE_Path::Create(); - int32_t iChars = GetDisplayPos(pPiece, pCharPos); - if (iChars > 0) { - CFX_PointF pt1, pt2; - FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; - int32_t i = 0; - if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { - for (int32_t i = 0; i < pPiece->iUnderline; i++) { - for (int32_t j = 0; j < iChars; j++) { - pt1.x = pCharPos[j].m_OriginX; - pt2.x = - pt1.x + pCharPos[j].m_FontCharWidth * pPiece->fFontSize / 1000.0f; - pt1.y = pt2.y = fEndY; - pPath->AddLine(pt1, pt2); - } - fEndY += 2.0f; - } - } else { - pt1.x = pCharPos[0].m_OriginX; - pt2.x = - pCharPos[iChars - 1].m_OriginX + - pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; - for (int32_t i = 0; i < pPiece->iUnderline; i++) { - pt1.y = pt2.y = fEndY; - pPath->AddLine(pt1, pt2); - fEndY += 2.0f; - } - } - fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; - pt1.x = pCharPos[0].m_OriginX; - pt2.x = pCharPos[iChars - 1].m_OriginX + - pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; - for (i = 0; i < pPiece->iLineThrough; i++) { - pt1.y = pt2.y = fEndY; - pPath->AddLine(pt1, pt2); - fEndY += 2.0f; - } - } else { - if (bNoLineThrough && - (bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) { - goto XFA_RenderPathRet; - } - int32_t iCharsTmp = 0; - int32_t iPiecePrev = iPiece, iPieceNext = iPiece; - while (iPiecePrev > 0) { - iPiecePrev--; - iCharsTmp = pPieceLine->m_charCounts.GetAt(iPiecePrev); - if (iCharsTmp > 0) { - break; - } - } - if (iCharsTmp == 0) { - goto XFA_RenderPathRet; - } - iCharsTmp = 0; - int32_t iPieces = pPieceLine->m_textPieces.GetSize(); - while (iPieceNext < iPieces - 1) { - iPieceNext++; - iCharsTmp = pPieceLine->m_charCounts.GetAt(iPieceNext); - if (iCharsTmp > 0) { - break; - } - } - if (iCharsTmp == 0) { - goto XFA_RenderPathRet; - } - FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f; - pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev); - iChars = GetDisplayPos(pPiece, pCharPos); - if (iChars < 1) { - goto XFA_RenderPathRet; - } - 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; - } - fEndX = pCharPos[0].m_OriginX; - CFX_PointF pt1, pt2; - pt1.x = fOrgX, pt2.x = fEndX; - FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; - int32_t i = 0; - for (i = 0; i < pPiece->iUnderline; i++) { - pt1.y = pt2.y = fEndY; - pPath->AddLine(pt1, pt2); - fEndY += 2.0f; - } - fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; - for (i = 0; i < pPiece->iLineThrough; i++) { - pt1.y = pt2.y = fEndY; - pPath->AddLine(pt1, pt2); - fEndY += 2.0f; - } - } - pDevice->DrawPath(pPen, 1, pPath, &tmDoc2Device); -XFA_RenderPathRet: - pPath->Release(); -} -int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode) { - if (pPiece == NULL) { - return 0; - } - FX_RTFTEXTOBJ tr; - if (!ToRun(pPiece, tr)) { - return 0; - } - return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); -} -FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { - int32_t iLength = pPiece->iChars; - if (iLength < 1) { - return FALSE; - } - tr.pStr = pPiece->pszText; - tr.pFont = pPiece->pFont; - tr.pRect = &pPiece->rtPiece; - tr.pWidths = pPiece->pWidths; - tr.iLength = iLength; - tr.fFontSize = pPiece->fFontSize; - tr.iBidiLevel = pPiece->iBidiLevel; - tr.iCharRotation = 0; - tr.wLineBreakChar = L'\n'; - tr.iVerticalScale = pPiece->iVerScale; - tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; - tr.iHorizontalScale = pPiece->iHorScale; - return TRUE; -} diff --git a/xfa/src/fxfa/app/xfa_textlayout.h b/xfa/src/fxfa/app/xfa_textlayout.h deleted file mode 100644 index 2d8d1bf15e..0000000000 --- a/xfa/src/fxfa/app/xfa_textlayout.h +++ /dev/null @@ -1,425 +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_SRC_FXFA_APP_XFA_TEXTLAYOUT_H_ -#define XFA_SRC_FXFA_APP_XFA_TEXTLAYOUT_H_ - -#include "xfa/src/fde/css/fde_css.h" -#include "xfa/src/fde/fde_brush.h" -#include "xfa/src/fde/fde_renderdevice.h" -#include "xfa/src/fgas/layout/fgas_rtfbreak.h" -#include "xfa/src/fxfa/app/xfa_ffdoc.h" -#include "xfa/src/fxfa/parser/xfa_object.h" - -#define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001 - -class CXFA_Para; -class CXFA_Font; -class CXFA_TextTabstopsContext; - -class IXFA_TextProvider { - public: - virtual ~IXFA_TextProvider() {} - virtual CXFA_Node* GetTextNode(FX_BOOL& bRichText) = 0; - virtual CXFA_Para GetParaNode() = 0; - virtual CXFA_Font GetFontNode() = 0; - virtual FX_BOOL IsCheckButtonAndAutoWidth() = 0; - virtual CXFA_FFDoc* GetDocNode() = 0; - virtual FX_BOOL GetEmbbedObj(FX_BOOL bURI, - FX_BOOL bRaw, - const CFX_WideString& wsAttr, - CFX_WideString& wsValue) = 0; -}; - -class CXFA_CSSTagProvider : public IFDE_CSSTagProvider { - public: - CXFA_CSSTagProvider() : m_bTagAviliable(FALSE), m_bContent(FALSE) {} - virtual ~CXFA_CSSTagProvider(); - virtual CFX_WideStringC GetTagName() { return m_wsTagName; } - 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); - FX_BOOL m_bTagAviliable; - FX_BOOL m_bContent; - - protected: - CFX_WideString m_wsTagName; - CFX_MapPtrToPtr m_Attributes; -}; - -class CXFA_TextParseContext : public CFX_Target { - public: - CXFA_TextParseContext() - : m_pParentStyle(nullptr), - m_ppMatchedDecls(nullptr), - m_dwMatchedDecls(0), - m_eDisplay(FDE_CSSDISPLAY_None) {} - ~CXFA_TextParseContext() { - if (m_pParentStyle) - m_pParentStyle->Release(); - FX_Free(m_ppMatchedDecls); - } - 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; - } - FX_DWORD CountDecls() const { return m_dwMatchedDecls; } - IFDE_CSSComputedStyle* m_pParentStyle; - - protected: - IFDE_CSSDeclaration** m_ppMatchedDecls; - FX_DWORD m_dwMatchedDecls; - FDE_CSSDISPLAY m_eDisplay; -}; - -class CXFA_TextParser { - public: - CXFA_TextParser() : m_pAllocator(NULL), m_pSelector(NULL), m_pUASheet(NULL) {} - virtual ~CXFA_TextParser(); - void Reset(); - void DoParse(IFDE_XMLNode* pXMLContainer, IXFA_TextProvider* pTextProvider); - IFDE_CSSComputedStyle* CreateRootStyle(IXFA_TextProvider* pTextProvider); - IFDE_CSSComputedStyle* ComputeStyle(IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle); - FX_BOOL IsParsed() const { return m_pAllocator != NULL; } - - int32_t GetVAlgin(IXFA_TextProvider* pTextProvider) const; - FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const; - int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const; - FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const; - FX_BOOL GetTabstops(IFDE_CSSComputedStyle* pStyle, - CXFA_TextTabstopsContext* pTabstopContext); - IFX_Font* GetFont(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; - FX_FLOAT GetFontSize(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; - int32_t GetHorScale(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - IFDE_XMLNode* pXMLNode) const; - int32_t GetVerScale(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; - void GetUnderline(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - int32_t& iUnderline, - int32_t& iPeriod) const; - void GetLinethrough(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - int32_t& iLinethrough) const; - FX_ARGB GetColor(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; - FX_FLOAT GetBaseline(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle) const; - FX_FLOAT GetLineHeight(IXFA_TextProvider* pTextProvider, - IFDE_CSSComputedStyle* pStyle, - FX_BOOL bFirst, - FX_FLOAT fVerScale) const; - FX_BOOL GetEmbbedObj(IXFA_TextProvider* pTextProvider, - IFDE_XMLNode* pXMLNode, - CFX_WideString& wsValue); - CXFA_TextParseContext* GetParseContextFromMap(IFDE_XMLNode* pXMLNode); - - private: - void InitCSSData(IXFA_TextProvider* pTextProvider); - void ParseRichText(IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle); - void ParseTagInfo(IFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); - IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); - IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); - IFX_MEMAllocator* m_pAllocator; - IFDE_CSSStyleSelector* m_pSelector; - IFDE_CSSStyleSheet* m_pUASheet; - CFX_MapPtrTemplate<IFDE_XMLNode*, CXFA_TextParseContext*> - m_mapXMLNodeToParseContext; -}; - -class CXFA_LoaderContext { - public: - CXFA_LoaderContext() - : m_bSaveLineHeight(FALSE), - m_fWidth(0), - m_fHeight(0), - m_fLastPos(0), - m_fStartLineOffset(0), - m_iChar(0), - m_iTotalLines(-1), - m_pXMLNode(NULL), - m_pNode(NULL), - m_pParentStyle(NULL), - m_dwFlags(0) {} - FX_BOOL m_bSaveLineHeight; - FX_FLOAT m_fWidth; - FX_FLOAT m_fHeight; - FX_FLOAT m_fLastPos; - FX_FLOAT m_fStartLineOffset; - int32_t m_iChar; - int32_t m_iLines; - int32_t m_iTotalLines; - IFDE_XMLNode* m_pXMLNode; - CXFA_Node* m_pNode; - IFDE_CSSComputedStyle* m_pParentStyle; - CFX_ArrayTemplate<FX_FLOAT> m_lineHeights; - FX_DWORD m_dwFlags; - CFX_FloatArray m_BlocksHeight; -}; - -class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target { - public: - CXFA_LinkUserData(IFX_MEMAllocator* pAllocator, FX_WCHAR* pszText) - : m_pAllocator(pAllocator), m_dwRefCount(1) { - m_pszURLContent = pszText; - } - ~CXFA_LinkUserData() {} - virtual FX_DWORD Release() { - FX_DWORD dwRefCount = --m_dwRefCount; - if (dwRefCount <= 0) { - FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); - } - return dwRefCount; - } - virtual FX_DWORD AddRef() { return ++m_dwRefCount; } - - public: - const FX_WCHAR* GetLinkURL() { return m_pszURLContent; } - - protected: - IFX_MEMAllocator* m_pAllocator; - FX_DWORD m_dwRefCount; - CFX_WideString m_pszURLContent; -}; - -class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { - public: - CXFA_TextUserData(IFX_MEMAllocator* pAllocator, IFDE_CSSComputedStyle* pStyle) - : m_pStyle(pStyle), - m_pLinkData(nullptr), - m_pAllocator(pAllocator), - m_dwRefCount(0) { - FXSYS_assert(m_pAllocator); - if (m_pStyle) - m_pStyle->AddRef(); - } - CXFA_TextUserData(IFX_MEMAllocator* pAllocator, - IFDE_CSSComputedStyle* pStyle, - CXFA_LinkUserData* pLinkData) - : m_pStyle(pStyle), - m_pLinkData(pLinkData), - m_pAllocator(pAllocator), - m_dwRefCount(0) { - FXSYS_assert(m_pAllocator); - if (m_pStyle) - m_pStyle->AddRef(); - } - ~CXFA_TextUserData() { - if (m_pStyle) - m_pStyle->Release(); - if (m_pLinkData) - m_pLinkData->Release(); - } - virtual FX_DWORD Release() { - FX_DWORD dwRefCount = --m_dwRefCount; - if (dwRefCount == 0) { - FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); - } - return dwRefCount; - } - virtual FX_DWORD AddRef() { return ++m_dwRefCount; } - - IFDE_CSSComputedStyle* m_pStyle; - CXFA_LinkUserData* m_pLinkData; - - protected: - IFX_MEMAllocator* m_pAllocator; - FX_DWORD m_dwRefCount; -}; - -class XFA_TextPiece : public CFX_Target { - public: - XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} - ~XFA_TextPiece() { - if (pLinkData) - pLinkData->Release(); - } - - FX_WCHAR* pszText; - int32_t iChars; - int32_t* pWidths; - int32_t iHorScale; - int32_t iVerScale; - int32_t iBidiLevel; - int32_t iUnderline; - int32_t iPeriod; - int32_t iLineThrough; - IFX_Font* pFont; - FX_ARGB dwColor; - FX_FLOAT fFontSize; - CFX_RectF rtPiece; - CXFA_LinkUserData* pLinkData; -}; -typedef CFX_ArrayTemplate<XFA_TextPiece*> CXFA_PieceArray; - -class CXFA_PieceLine : public CFX_Target { - public: - CXFA_PieceLine() {} - CXFA_PieceArray m_textPieces; - CFX_Int32Array m_charCounts; -}; -typedef CFX_ArrayTemplate<CXFA_PieceLine*> CXFA_PieceLineArray; - -struct XFA_TABSTOPS { - FX_DWORD dwAlign; - FX_FLOAT fTabstops; -}; - -class CXFA_TextTabstopsContext { - public: - CXFA_TextTabstopsContext() - : m_iTabCount(0), - m_iTabIndex(-1), - m_bTabstops(FALSE), - m_fTabWidth(0), - m_fLeft(0) {} - void Append(FX_DWORD dwAlign, FX_FLOAT fTabstops) { - int32_t i = 0; - for (i = 0; i < m_iTabCount; i++) { - XFA_TABSTOPS* pTabstop = m_tabstops.GetDataPtr(i); - if (fTabstops < pTabstop->fTabstops) { - break; - } - } - m_tabstops.InsertSpaceAt(i, 1); - XFA_TABSTOPS tabstop; - tabstop.dwAlign = dwAlign; - tabstop.fTabstops = fTabstops; - m_tabstops.SetAt(i, tabstop); - m_iTabCount++; - } - void RemoveAll() { - m_tabstops.RemoveAll(); - m_iTabCount = 0; - } - void Reset() { - m_iTabIndex = -1; - m_bTabstops = FALSE; - m_fTabWidth = 0; - m_fLeft = 0; - } - CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops; - int32_t m_iTabCount; - int32_t m_iTabIndex; - FX_BOOL m_bTabstops; - FX_FLOAT m_fTabWidth; - FX_FLOAT m_fLeft; -}; - -class CXFA_TextLayout { - public: - CXFA_TextLayout(IXFA_TextProvider* pTextProvider); - virtual ~CXFA_TextLayout(); - int32_t GetText(CFX_WideString& wsText); - FX_FLOAT GetLayoutHeight(); - FX_FLOAT StartLayout(FX_FLOAT fWidth = -1); - FX_BOOL DoLayout(int32_t iBlockIndex, - FX_FLOAT& fCalcHeight, - FX_FLOAT fContentAreaHeight = -1, - FX_FLOAT fTextHeight = -1); - - FX_BOOL CalcSize(const CFX_SizeF& minSize, - const CFX_SizeF& maxSize, - CFX_SizeF& defaultSize); - FX_BOOL Layout(const CFX_SizeF& size, FX_FLOAT* fHeight = NULL); - void ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex); - FX_BOOL DrawString(CFX_RenderDevice* pFxDevice, - const CFX_Matrix& tmDoc2Device, - const CFX_RectF& rtClip, - int32_t iBlock = 0); - FX_BOOL IsLoaded() const { return m_pieceLines.GetSize() > 0; } - void Unload(); - const CXFA_PieceLineArray* GetPieceLines(); - - FX_BOOL m_bHasBlock; - CFX_Int32Array m_Blocks; - - private: - void GetTextDataNode(); - IFDE_XMLNode* GetXMLContainerNode(); - IFX_RTFBreak* CreateBreak(FX_BOOL bDefault); - void InitBreak(FX_FLOAT fLineWidth); - void InitBreak(IFDE_CSSComputedStyle* pStyle, - FDE_CSSDISPLAY eDisplay, - FX_FLOAT fLineWidth, - IFDE_XMLNode* pXMLNode, - IFDE_CSSComputedStyle* pParentStyle = NULL); - FX_BOOL Loader(const CFX_SizeF& szText, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces = TRUE); - void LoadText(CXFA_Node* pNode, - const CFX_SizeF& szText, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces); - FX_BOOL LoadRichText(IFDE_XMLNode* pXMLNode, - const CFX_SizeF& szText, - FX_FLOAT& fLinePos, - IFDE_CSSComputedStyle* pParentStyle, - FX_BOOL bSavePieces, - CXFA_LinkUserData* pLinkData = NULL, - FX_BOOL bEndBreak = TRUE, - FX_BOOL bIsOl = FALSE, - int32_t iLiCount = 0); - FX_BOOL AppendChar(const CFX_WideString& wsText, - FX_FLOAT& fLinePos, - FX_FLOAT fSpaceAbove, - FX_BOOL bSavePieces); - void AppendTextLine(FX_DWORD dwStatus, - FX_FLOAT& fLinePos, - FX_BOOL bSavePieces, - FX_BOOL bEndBreak = FALSE); - void EndBreak(FX_DWORD dwStatus, FX_FLOAT& fLinePos, FX_BOOL bDefault); - 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, - CXFA_PieceLine* pPieceLine, - int32_t iPiece, - FXTEXT_CHARPOS* pCharPos, - const CFX_Matrix& tmDoc2Device); - void RenderPath(IFDE_RenderDevice* pDevice, - IFDE_Pen* pPen, - CXFA_PieceLine* pPieceLine, - int32_t iPiece, - FXTEXT_CHARPOS* pCharPos, - const CFX_Matrix& tmDoc2Device); - int32_t GetDisplayPos(const XFA_TextPiece* pPiece, - FXTEXT_CHARPOS* pCharPos, - FX_BOOL bCharCode = FALSE); - FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); - void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); - FX_BOOL Layout(int32_t iBlock); - int32_t CountBlocks() const; - - IXFA_TextProvider* m_pTextProvider; - CXFA_Node* m_pTextDataNode; - FX_BOOL m_bRichText; - IFX_MEMAllocator* m_pAllocator; - IFX_RTFBreak* m_pBreak; - CXFA_LoaderContext* m_pLoader; - int32_t m_iLines; - FX_FLOAT m_fMaxWidth; - CXFA_TextParser m_textParser; - CXFA_PieceLineArray m_pieceLines; - CXFA_TextTabstopsContext* m_pTabstopContext; - FX_BOOL m_bBlockContinue; -}; - -#endif // XFA_SRC_FXFA_APP_XFA_TEXTLAYOUT_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_error.cpp b/xfa/src/fxfa/fm2js/xfa_error.cpp deleted file mode 100644 index 71706dff5d..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_error.cpp +++ /dev/null @@ -1,21 +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/src/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""; -} diff --git a/xfa/src/fxfa/fm2js/xfa_error.h b/xfa/src/fxfa/fm2js/xfa_error.h deleted file mode 100644 index 7c11080a09..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_error.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_SRC_FXFA_FM2JS_XFA_ERROR_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_ERROR_H_ - -#include "core/include/fxcrt/fx_string.h" -#include "core/include/fxcrt/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 -}; - -class CXFA_FMErrorInfo { - public: - CXFA_FMErrorInfo() : linenum(0) {} - ~CXFA_FMErrorInfo() {} - FX_DWORD linenum; - CFX_WideString message; -}; -const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg); - -#endif // XFA_SRC_FXFA_FM2JS_XFA_ERROR_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_expression.cpp b/xfa/src/fxfa/fm2js/xfa_expression.cpp deleted file mode 100644 index 25c5b4b63b..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_expression.cpp +++ /dev/null @@ -1,627 +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/src/fxfa/fm2js/xfa_expression.h" - -#include "core/include/fxcrt/fx_basic.h" - -namespace { - -const CFX_WideStringC RUNTIMEBLOCKTEMPARRAY = - FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array"); - -const CFX_WideStringC RUNTIMEBLOCKTEMPARRAYINDEX = - FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array_index"); - -} // namespace - -CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line) - : m_type(XFA_FM_EXPTYPE_UNKNOWN), m_line(line) {} - -CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type) - : m_type(type), m_line(line) {} - -void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} - -void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} - -CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( - FX_DWORD line, - FX_BOOL isGlobal, - const CFX_WideStringC& wsName, - CFX_WideStringCArray* pArguments, - CFX_PtrArray* pExpressions) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC), - m_wsName(wsName), - m_pArguments(pArguments), - m_pExpressions(pExpressions), - m_isGlobal(isGlobal) {} - -CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() { - if (m_pArguments) { - m_pArguments->RemoveAll(); - 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(); - delete m_pExpressions; - } -} - -void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { - if (m_isGlobal && (!m_pExpressions || m_pExpressions->GetSize() == 0)) { - javascript << FX_WSTRC(L"// comments only"); - return; - } - if (m_isGlobal) { - javascript << FX_WSTRC(L"(\n"); - } - javascript << FX_WSTRC(L"function "); - if (m_wsName.GetAt(0) == L'!') { - CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); - javascript << tempName; - } else { - javascript << m_wsName; - } - javascript << FX_WSTRC(L"("); - if (m_pArguments != 0) { - CFX_WideStringC identifier = 0; - for (int i = 0; i < m_pArguments->GetSize(); ++i) { - identifier = m_pArguments->GetAt(i); - if (identifier.GetAt(0) == L'!') { - CFX_WideString tempIdentifier = - EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1); - javascript << tempIdentifier; - } else { - javascript << identifier; - } - if (i + 1 < m_pArguments->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - } - javascript << FX_WSTRC(L")\n{\n"); - javascript << FX_WSTRC(L"var "); - javascript << RUNTIMEFUNCTIONRETURNVALUE; - 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)); - if (i + 1 < m_pExpressions->GetSize()) { - e->ToJavaScript(javascript); - } else { - e->ToImpliedReturnJS(javascript); - } - } - } - javascript << FX_WSTRC(L"return "); - if (m_isGlobal) { - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L")"); - } else { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - } - javascript << FX_WSTRC(L";\n}\n"); - if (m_isGlobal) { - javascript << FX_WSTRC(L").call(this);\n"); - } -} - -void CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {} - -CXFA_FMVarExpression::CXFA_FMVarExpression(FX_DWORD line, - const CFX_WideStringC& wsName, - CXFA_FMExpression* pInit) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_VAR), - m_wsName(wsName), - m_pInit(pInit) {} - -void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"var "); - CFX_WideString tempName = m_wsName; - if (m_wsName.GetAt(0) == L'!') { - tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); - } - javascript << tempName; - javascript << FX_WSTRC(L" = "); - if (m_pInit) { - m_pInit->ToJavaScript(javascript); - javascript << tempName; - javascript << FX_WSTRC(L" = "); - javascript << XFA_FM_EXPTypeToString(VARFILTER); - javascript << FX_WSTRC(L"("); - javascript << tempName; - javascript << FX_WSTRC(L");\n"); - } else { - javascript << FX_WSTRC(L"\"\";\n"); - } -} - -void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"var "); - CFX_WideString tempName = m_wsName; - if (m_wsName.GetAt(0) == L'!') { - tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); - } - javascript << tempName; - javascript << FX_WSTRC(L" = "); - if (m_pInit) { - m_pInit->ToJavaScript(javascript); - javascript << tempName; - javascript << FX_WSTRC(L" = "); - javascript << XFA_FM_EXPTypeToString(VARFILTER); - javascript << FX_WSTRC(L"("); - javascript << tempName; - javascript << FX_WSTRC(L");\n"); - } else { - javascript << FX_WSTRC(L"\"\";\n"); - } - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = "); - javascript << tempName; - javascript << FX_WSTRC(L";\n"); -} - -CXFA_FMExpExpression::CXFA_FMExpExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExpression) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_EXP), m_pExpression(pExpression) {} - -void CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - if (m_pExpression->GetOperatorToken() == TOKassign) { - m_pExpression->ToJavaScript(javascript); - } else { - m_pExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n"); - } -} - -void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - if (m_pExpression->GetOperatorToken() == TOKassign) { - m_pExpression->ToImpliedReturnJS(javascript); - } else { - if (m_pExpression->GetOperatorToken() == TOKstar || - m_pExpression->GetOperatorToken() == TOKdotstar || - m_pExpression->GetOperatorToken() == TOKdotscream || - m_pExpression->GetOperatorToken() == TOKdotdot || - m_pExpression->GetOperatorToken() == TOKdot) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L");\n"); - } else { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = "); - m_pExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n"); - } - } -} - -CXFA_FMBlockExpression::CXFA_FMBlockExpression(FX_DWORD line, - CFX_PtrArray* 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(); - delete m_pExpressionList; - } -} - -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); - } - } - javascript << FX_WSTRC(L"}\n"); -} - -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)); - if (i + 1 == m_pExpressionList->GetSize()) { - e->ToImpliedReturnJS(javascript); - } else { - e->ToJavaScript(javascript); - } - } - } - javascript << FX_WSTRC(L"}\n"); -} - -CXFA_FMDoExpression::CXFA_FMDoExpression(FX_DWORD line, - CXFA_FMExpression* pList) - : CXFA_FMExpression(line), m_pList(pList) {} - -void CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - m_pList->ToJavaScript(javascript); -} - -void CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - m_pList->ToImpliedReturnJS(javascript); -} - -CXFA_FMIfExpression::CXFA_FMIfExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExpression, - CXFA_FMExpression* pIfExpression, - CXFA_FMExpression* pElseExpression) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_IF), - m_pExpression(pExpression), - m_pIfExpression(pIfExpression), - m_pElseExpression(pElseExpression) {} - -void CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"if ("); - if (m_pExpression) { - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - } - javascript << FX_WSTRC(L")\n"); - if (m_pIfExpression) { - m_pIfExpression->ToJavaScript(javascript); - } - if (m_pElseExpression) { - if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { - javascript << FX_WSTRC(L"else\n"); - javascript << FX_WSTRC(L"{\n"); - m_pElseExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L"}\n"); - } else { - javascript << FX_WSTRC(L"else\n"); - m_pElseExpression->ToJavaScript(javascript); - } - } -} - -void CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"if ("); - if (m_pExpression) { - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pExpression->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - } - javascript << FX_WSTRC(L")\n"); - if (m_pIfExpression) { - m_pIfExpression->ToImpliedReturnJS(javascript); - } - if (m_pElseExpression) { - if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { - javascript << FX_WSTRC(L"else\n"); - javascript << FX_WSTRC(L"{\n"); - m_pElseExpression->ToImpliedReturnJS(javascript); - javascript << FX_WSTRC(L"}\n"); - } else { - javascript << FX_WSTRC(L"else\n"); - m_pElseExpression->ToImpliedReturnJS(javascript); - } - } -} - -CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {} - -void CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} - -void CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {} - -CXFA_FMWhileExpression::CXFA_FMWhileExpression( - FX_DWORD line, - CXFA_FMSimpleExpression* pCondition, - CXFA_FMExpression* pExpression) - : CXFA_FMLoopExpression(line), - m_pCondition(pCondition), - m_pExpression(pExpression) {} - -void CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"while ("); - m_pCondition->ToJavaScript(javascript); - javascript << FX_WSTRC(L")\n"); - m_pExpression->ToJavaScript(javascript); -} - -void CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"while ("); - m_pCondition->ToJavaScript(javascript); - javascript << FX_WSTRC(L")\n"); - m_pExpression->ToImpliedReturnJS(javascript); -} - -CXFA_FMBreakExpression::CXFA_FMBreakExpression(FX_DWORD line) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_BREAK) {} - -CXFA_FMBreakExpression::~CXFA_FMBreakExpression() {} - -void CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"break;\n"); -} - -void CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"break;\n"); -} - -CXFA_FMContinueExpression::CXFA_FMContinueExpression(FX_DWORD line) - : CXFA_FMExpression(line, XFA_FM_EXPTYPE_CONTINUE) {} - -CXFA_FMContinueExpression::~CXFA_FMContinueExpression() {} - -void CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"continue;\n"); -} - -void CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"continue;\n"); -} - -CXFA_FMForExpression::CXFA_FMForExpression(FX_DWORD line, - const CFX_WideStringC& wsVariant, - CXFA_FMSimpleExpression* pAssignment, - CXFA_FMSimpleExpression* pAccessor, - int32_t iDirection, - CXFA_FMSimpleExpression* pStep, - CXFA_FMExpression* pList) - : CXFA_FMLoopExpression(line), - m_wsVariant(wsVariant), - m_pAssignment(pAssignment), - m_pAccessor(pAccessor), - m_iDirection(iDirection), - m_pStep(pStep), - m_pList(pList) {} - -void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"{\nvar "); - CFX_WideString tempVariant; - if (m_wsVariant.GetAt(0) == L'!') { - tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1); - javascript << tempVariant; - } else { - tempVariant = m_wsVariant; - javascript << m_wsVariant; - } - javascript << FX_WSTRC(L" = null;\n"); - javascript << FX_WSTRC(L"for ("); - javascript << tempVariant; - javascript << FX_WSTRC(L" = "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAssignment->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - if (m_iDirection == 1) { - javascript << FX_WSTRC(L" <= "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAccessor->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - javascript << FX_WSTRC(L" += "); - } else { - javascript << FX_WSTRC(L" >= "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAccessor->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - javascript << FX_WSTRC(L" -= "); - } - if (m_pStep) { - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pStep->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - } else { - javascript << FX_WSTRC(L"1"); - } - javascript << FX_WSTRC(L")\n"); - m_pList->ToJavaScript(javascript); - javascript << FX_WSTRC(L"}\n"); -} - -void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"{\nvar "); - CFX_WideString tempVariant; - if (m_wsVariant.GetAt(0) == L'!') { - tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1); - javascript << tempVariant; - } else { - tempVariant = m_wsVariant; - javascript << m_wsVariant; - } - javascript << FX_WSTRC(L" = null;\n"); - javascript << FX_WSTRC(L"for ("); - javascript << tempVariant; - javascript << FX_WSTRC(L" = "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAssignment->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - if (m_iDirection == 1) { - javascript << FX_WSTRC(L" <= "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAccessor->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - javascript << FX_WSTRC(L" += "); - } else { - javascript << FX_WSTRC(L" >= "); - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pAccessor->ToJavaScript(javascript); - javascript << FX_WSTRC(L"); "); - javascript << tempVariant; - javascript << FX_WSTRC(L" -= "); - } - if (m_pStep) { - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << FX_WSTRC(L"("); - m_pStep->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - } else { - javascript << FX_WSTRC(L"1"); - } - javascript << FX_WSTRC(L")\n"); - m_pList->ToImpliedReturnJS(javascript); - javascript << FX_WSTRC(L"}\n"); -} - -CXFA_FMForeachExpression::CXFA_FMForeachExpression( - FX_DWORD line, - const CFX_WideStringC& wsIdentifier, - CFX_PtrArray* pAccessors, - CXFA_FMExpression* pList) - : CXFA_FMLoopExpression(line), - m_wsIdentifier(wsIdentifier), - m_pAccessors(pAccessors), - m_pList(pList) {} - -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(); - delete m_pAccessors; - } -} - -void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"{\n"); - javascript << FX_WSTRC(L"var "); - if (m_wsIdentifier.GetAt(0) == L'!') { - CFX_WideString tempIdentifier = - EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); - javascript << tempIdentifier; - } else { - javascript << m_wsIdentifier; - } - javascript << FX_WSTRC(L" = null;\n"); - javascript << FX_WSTRC(L"var "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L" = "); - 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)); - s->ToJavaScript(javascript); - if (i + 1 < m_pAccessors->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - javascript << FX_WSTRC(L");\n"); - javascript << FX_WSTRC(L"var "); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"while("); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L" < "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L".length)\n{\n"); - if (m_wsIdentifier.GetAt(0) == L'!') { - CFX_WideString tempIdentifier = - EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); - javascript << tempIdentifier; - } else { - javascript << m_wsIdentifier; - } - javascript << FX_WSTRC(L" = "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L"["); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L"++];\n"); - m_pList->ToJavaScript(javascript); - javascript << FX_WSTRC(L"}\n"); - javascript << FX_WSTRC(L"}\n"); -} - -void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"{\n"); - javascript << FX_WSTRC(L"var "); - if (m_wsIdentifier.GetAt(0) == L'!') { - CFX_WideString tempIdentifier = - EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); - javascript << tempIdentifier; - } else { - javascript << m_wsIdentifier; - } - javascript << FX_WSTRC(L" = null;\n"); - javascript << FX_WSTRC(L"var "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L" = "); - 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)); - s->ToJavaScript(javascript); - if (i + 1 < m_pAccessors->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - javascript << FX_WSTRC(L");\n"); - javascript << FX_WSTRC(L"var "); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L" = 0;\n"); - javascript << FX_WSTRC(L"while("); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L" < "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L".length)\n{\n"); - if (m_wsIdentifier.GetAt(0) == L'!') { - CFX_WideString tempIdentifier = - EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1); - javascript << tempIdentifier; - } else { - javascript << m_wsIdentifier; - } - javascript << FX_WSTRC(L" = "); - javascript << RUNTIMEBLOCKTEMPARRAY; - javascript << FX_WSTRC(L"["); - javascript << RUNTIMEBLOCKTEMPARRAYINDEX; - javascript << FX_WSTRC(L"++];\n"); - m_pList->ToImpliedReturnJS(javascript); - javascript << FX_WSTRC(L"}\n"); - javascript << FX_WSTRC(L"}\n"); -} diff --git a/xfa/src/fxfa/fm2js/xfa_expression.h b/xfa/src/fxfa/fm2js/xfa_expression.h deleted file mode 100644 index ffcce1c4e0..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_expression.h +++ /dev/null @@ -1,191 +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_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ - -#include <memory> - -#include "xfa/src/fxfa/fm2js/xfa_simpleexpression.h" - -enum XFA_FM_EXPTYPE { - XFA_FM_EXPTYPE_UNKNOWN, - XFA_FM_EXPTYPE_FUNC, - XFA_FM_EXPTYPE_VAR, - XFA_FM_EXPTYPE_EXP, - XFA_FM_EXPTYPE_BLOCK, - XFA_FM_EXPTYPE_IF, - XFA_FM_EXPTYPE_BREAK, - XFA_FM_EXPTYPE_CONTINUE, -}; - -class CXFA_FMExpression { - public: - explicit CXFA_FMExpression(FX_DWORD line); - CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type); - virtual ~CXFA_FMExpression() {} - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); - FX_DWORD GetLine() { return m_line; } - XFA_FM_EXPTYPE GetExpType() const { return m_type; } - - protected: - XFA_FM_EXPTYPE m_type; - FX_DWORD m_line; -}; - -class CXFA_FMFunctionDefinition : public CXFA_FMExpression { - public: - CXFA_FMFunctionDefinition(FX_DWORD line, - FX_BOOL isGlobal, - const CFX_WideStringC& wsName, - CFX_WideStringCArray* pArguments, - CFX_PtrArray* 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; - FX_BOOL m_isGlobal; -}; - -class CXFA_FMVarExpression : public CXFA_FMExpression { - public: - CXFA_FMVarExpression(FX_DWORD line, - const CFX_WideStringC& wsName, - CXFA_FMExpression* pInit); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - CFX_WideStringC m_wsName; - std::unique_ptr<CXFA_FMExpression> m_pInit; -}; - -class CXFA_FMExpExpression : public CXFA_FMExpression { - public: - CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; -}; - -class CXFA_FMBlockExpression : public CXFA_FMExpression { - public: - CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList); - ~CXFA_FMBlockExpression() override; - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - CFX_PtrArray* m_pExpressionList; -}; - -class CXFA_FMDoExpression : public CXFA_FMExpression { - public: - CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - std::unique_ptr<CXFA_FMExpression> m_pList; -}; - -class CXFA_FMIfExpression : public CXFA_FMExpression { - public: - CXFA_FMIfExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExpression, - CXFA_FMExpression* pIfExpression, - CXFA_FMExpression* pElseExpression); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; - std::unique_ptr<CXFA_FMExpression> m_pIfExpression; - std::unique_ptr<CXFA_FMExpression> m_pElseExpression; -}; - -class CXFA_FMLoopExpression : public CXFA_FMExpression { - public: - explicit CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} - ~CXFA_FMLoopExpression() override; - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; -}; - -class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { - public: - CXFA_FMWhileExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pCodition, - CXFA_FMExpression* pExpression); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - std::unique_ptr<CXFA_FMSimpleExpression> m_pCondition; - std::unique_ptr<CXFA_FMExpression> m_pExpression; -}; - -class CXFA_FMBreakExpression : public CXFA_FMExpression { - public: - explicit CXFA_FMBreakExpression(FX_DWORD line); - ~CXFA_FMBreakExpression() override; - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; -}; - -class CXFA_FMContinueExpression : public CXFA_FMExpression { - public: - explicit CXFA_FMContinueExpression(FX_DWORD line); - ~CXFA_FMContinueExpression() override; - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; -}; - -class CXFA_FMForExpression : public CXFA_FMLoopExpression { - public: - CXFA_FMForExpression(FX_DWORD line, - const CFX_WideStringC& wsVariant, - CXFA_FMSimpleExpression* pAssignment, - CXFA_FMSimpleExpression* pAccessor, - int32_t iDirection, - CXFA_FMSimpleExpression* pStep, - CXFA_FMExpression* pList); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf&) override; - - private: - CFX_WideStringC m_wsVariant; - std::unique_ptr<CXFA_FMSimpleExpression> m_pAssignment; - std::unique_ptr<CXFA_FMSimpleExpression> m_pAccessor; - int32_t m_iDirection; - std::unique_ptr<CXFA_FMSimpleExpression> m_pStep; - std::unique_ptr<CXFA_FMExpression> m_pList; -}; - -class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { - public: - CXFA_FMForeachExpression(FX_DWORD line, - const CFX_WideStringC& wsIdentifier, - CFX_PtrArray* 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; - std::unique_ptr<CXFA_FMExpression> m_pList; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_fm2jsapi.cpp b/xfa/src/fxfa/fm2js/xfa_fm2jsapi.cpp deleted file mode 100644 index c59aedc6ac..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fm2jsapi.cpp +++ /dev/null @@ -1,65 +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/src/fxfa/fm2js/xfa_fm2jsapi.h" - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jscontext.h" -#include "xfa/src/fxfa/fm2js/xfa_program.h" -#include "xfa/src/fxfa/parser/xfa_document.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, - CFX_WideTextBuf& wsJavascript, - CFX_WideString& wsError) { - if (wsFormcalc.IsEmpty()) { - wsJavascript.Clear(); - wsError.Empty(); - return 0; - } - int32_t status = 0; - CXFA_FMProgram program; - status = program.Init(wsFormcalc); - if (status) { - wsError = program.GetError().message; - return status; - } - status = program.ParseProgram(); - if (status) { - wsError = program.GetError().message; - return status; - } - program.TranslateProgram(wsJavascript); - return 0; -} -XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate() { - return (XFA_HFM2JSCONTEXT)CXFA_FM2JSContext::Create(); -} -void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, - FXJSE_HRUNTIME hScriptRuntime, - FXJSE_HCONTEXT hScriptContext, - CXFA_Document* pDocument) { - CXFA_FM2JSContext* pContext = - reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); - pContext->Initialize(hScriptRuntime, hScriptContext, pDocument); -} -void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, - FXJSE_HVALUE hValue) { - CXFA_FM2JSContext* pContext = - reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); - pContext->GlobalPropertyGetter(hValue); -} -void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext) { - CXFA_FM2JSContext* pContext = - reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); - pContext->Release(); -} -#ifdef __cplusplus -} -#endif diff --git a/xfa/src/fxfa/fm2js/xfa_fm2jsapi.h b/xfa/src/fxfa/fm2js/xfa_fm2jsapi.h deleted file mode 100644 index ce6d7c9a93..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fm2jsapi.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_SRC_FXFA_FM2JS_XFA_FM2JSAPI_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_FM2JSAPI_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/include/fxjse/fxjse.h" -#include "xfa/src/fxfa/parser/xfa_document.h" - -#define FOXIT_XFA_FM2JS_FORMCALC_RUNTIME "foxit_xfa_formcalc_runtime" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct XFA_HFM2JSCONTEXT_ { void** pData; } * XFA_HFM2JSCONTEXT; -int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, - CFX_WideTextBuf& wsJavascript, - CFX_WideString& wsError); -XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate(); -void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, - FXJSE_HRUNTIME hScriptRuntime, - FXJSE_HCONTEXT hScriptContext, - CXFA_Document* pDocument); -void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, - FXJSE_HVALUE hValue); -void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext); - -#ifdef __cplusplus -} -#endif - -#endif // XFA_SRC_FXFA_FM2JS_XFA_FM2JSAPI_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/src/fxfa/fm2js/xfa_fm2jscontext.cpp deleted file mode 100644 index c27223ac5c..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fm2jscontext.cpp +++ /dev/null @@ -1,7223 +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/src/fxfa/fm2js/xfa_fm2jscontext.h" - -#include <time.h> - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/localization/fgas_locale.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localevalue.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" - -#define FINANCIAL_PRECISION 0.00000001 - -namespace { - -struct XFA_FMHtmlReserveCode { - uint32_t m_uCode; - const FX_WCHAR* m_htmlReserve; -}; -struct XFA_FMHtmlHashedReserveCode { - uint32_t m_uHash; - const FX_WCHAR* m_htmlReserve; - uint32_t m_uCode; -}; - -const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { - {0x00018b62, L"Mu", 924}, {0x00019083, L"Nu", 925}, - {0x00019ab9, L"Pi", 928}, {0x0001c3c1, L"Xi", 926}, - {0x000210ac, L"ge", 8805}, {0x000210bb, L"gt", 62}, - {0x00022a51, L"le", 8804}, {0x00022a60, L"lt", 60}, - {0x00022f82, L"mu", 956}, {0x00023493, L"ne", 8800}, - {0x00023497, L"ni", 8715}, {0x000234a3, L"nu", 957}, - {0x000239c1, L"or", 8744}, {0x00023ed9, L"pi", 960}, - {0x000267e1, L"xi", 958}, {0x00c41789, L"lceil", 8968}, - {0x00eef34f, L"thetasym", 977}, {0x012d7ead, L"lcirc", 206}, - {0x01637b56, L"agrave", 224}, {0x020856da, L"crarr", 8629}, - {0x022188c3, L"gamma", 947}, {0x033586d3, L"nbsp", 160}, - {0x04f4c358, L"nsub", 8836}, {0x0581466a, L"dagger", 8224}, - {0x06b1f790, L"oelig", 339}, {0x06e490d4, L"Chi", 935}, - {0x0718c6a1, L"ETH", 208}, {0x07196ada, L"Eta", 919}, - {0x07f667ca, L"Ugrave", 217}, {0x083a8a21, L"Phi", 934}, - {0x083ac28c, L"Psi", 936}, {0x086f26a9, L"Rho", 929}, - {0x089b5b51, L"aring", 229}, {0x08a39f4a, L"Tau", 932}, - {0x08b6188b, L"THORN", 222}, {0x09ce792a, L"icirc", 238}, - {0x09f9d61e, L"amp", 38}, {0x09f9db33, L"and", 8743}, - {0x09f9db36, L"ang", 8736}, {0x0a2e3514, L"cap", 8745}, - {0x0a2e58f4, L"chi", 967}, {0x0a2e9ba8, L"cup", 8746}, - {0x0a4897d0, L"deg", 176}, {0x0a6332fa, L"eta", 951}, - {0x0a633301, L"eth", 240}, {0x0acc4d4b, L"int", 8747}, - {0x0b1b3d35, L"loz", 9674}, {0x0b1b4c8b, L"lrm", 8206}, - {0x0b4fd9b1, L"not", 172}, {0x0b845241, L"phi", 966}, - {0x0b84576f, L"piv", 982}, {0x0b848aac, L"psi", 968}, - {0x0bb8df5e, L"reg", 174}, {0x0bb8eec9, L"rho", 961}, - {0x0bb9034b, L"rlm", 8207}, {0x0bd33d14, L"shy", 173}, - {0x0bd34229, L"sim", 8764}, {0x0bd37faa, L"sub", 8834}, - {0x0bd37fb5, L"sum", 8721}, {0x0bd37fb8, L"sup", 8835}, - {0x0bed676a, L"tau", 964}, {0x0c07f32e, L"uml", 168}, - {0x0c71032c, L"yen", 165}, {0x0c7f2889, L"szlig", 223}, - {0x0c8badbb, L"zwj", 8205}, {0x10ba4dba, L"Egrave", 200}, - {0x10f1ea24, L"para", 182}, {0x10f1ea37, L"part", 8706}, - {0x115b2337, L"perp", 8869}, {0x12b10d15, L"prod", 8719}, - {0x12b10d21, L"prop", 8733}, {0x12dfa9f4, L"rfloor", 8971}, - {0x12eb4736, L"Agrave", 192}, {0x12fff2b7, L"pund", 163}, - {0x13fda9f2, L"tilde", 732}, {0x1417fd62, L"times", 215}, - {0x154fc726, L"ecirc", 234}, {0x165aa451, L"sigma", 963}, - {0x1709124a, L"Dagger", 8225}, {0x192f78d5, L"iexcl", 161}, - {0x1b7ed8d7, L"rArr", 8658}, {0x1ec88c68, L"rang", 9002}, - {0x1ec8a0f7, L"rarr", 8594}, {0x1eda07f3, L"atilde", 227}, - {0x1f3182c4, L"real", 8476}, {0x1fc34f8b, L"yacute", 253}, - {0x20d11522, L"acirc", 226}, {0x21933a9b, L"rsaquo", 8250}, - {0x21f44907, L"uacute", 250}, {0x220cca72, L"acute", 180}, - {0x242cded1, L"alefsym", 8501}, {0x2655c66a, L"delta", 948}, - {0x269e4b4d, L"exist", 8707}, {0x273379fa, L"micro", 181}, - {0x27a37440, L"forall", 8704}, {0x2854e62c, L"minus", 8722}, - {0x28636f81, L"cedil", 184}, {0x2887357b, L"iacute", 237}, - {0x2994d5ff, L"frac12", 189}, {0x2994d601, L"frac14", 188}, - {0x2994e043, L"frac34", 190}, {0x2a1feb41, L"lambda", 955}, - {0x2ab215f3, L"apos", 39}, {0x2ab82ef7, L"eacute", 233}, - {0x2b3592ef, L"auml", 228}, {0x2ce92873, L"aacute", 225}, - {0x2daff48a, L"oslash", 248}, {0x2ef68882, L"aelig", 230}, - {0x3061d3d3, L"Atilde", 195}, {0x314b1b6b, L"Yacute", 221}, - {0x337c14e7, L"Uacute", 218}, {0x37676aca, L"cent", 162}, - {0x37d0b841, L"circ", 710}, {0x386e7947, L"cong", 8773}, - {0x386e839b, L"copy", 169}, {0x3a0e225a, L"Epsilon", 917}, - {0x3ba7b721, L"Lambda", 923}, {0x3bd9abe6, L"Alpha", 913}, - {0x3c3ffad7, L"Eacute", 201}, {0x3cfaf69f, L"brvbar", 166}, - {0x3d54a489, L"omega", 969}, {0x3e70f453, L"Aacute", 193}, - {0x3f37c06a, L"Oslash", 216}, {0x40e1b34e, L"diams", 9830}, - {0x416596df, L"plusmn", 177}, {0x4354ff16, L"Ucirc", 219}, - {0x454fce6a, L"Upsilon", 933}, {0x4610ad35, L"emsp", 8195}, - {0x462afb76, L"ensp", 8194}, {0x46e30073, L"euml", 235}, - {0x46e31a1b, L"euro", 8364}, {0x46f2eada, L"lowast", 8727}, - {0x4dca26cf, L"Auml", 196}, {0x4e2d6083, L"image", 8465}, - {0x4f964ee8, L"notin", 8713}, {0x50917a7a, L"epsilon", 949}, - {0x52f9a4cd, L"Kappa", 922}, {0x5496f410, L"Ocirc", 212}, - {0x568cbf34, L"zeta", 950}, {0x57badd20, L"ntilde", 241}, - {0x58662109, L"zwnj", 8204}, {0x5b39870f, L"empty", 8709}, - {0x5bd3268a, L"upsilon", 965}, {0x5e2bf8a3, L"Gamma", 915}, - {0x5f73c13a, L"rsquo", 8217}, {0x61f2bc4d, L"iota", 953}, - {0x625bbcf3, L"isin", 8712}, {0x62906df7, L"iuml", 239}, - {0x64a5cb31, L"Aring", 197}, {0x66f25c4a, L"sbquo", 8218}, - {0x6851ab60, L"spades", 9824}, {0x6942a900, L"Ntilde", 209}, - {0x69779453, L"Euml", 203}, {0x6cda6e23, L"current", 164}, - {0x70b5b634, L"lsquo", 8216}, {0x715a3706, L"Ecirc", 202}, - {0x71e8bf8d, L"tdquo", 8221}, {0x72651431, L"Sigma", 931}, - {0x7569813b, L"iquest", 191}, {0x776a436a, L"equiv", 8801}, - {0x79215314, L"Zeta", 918}, {0x79b81224, L"ograve", 242}, - {0x7c2f8b23, L"macr", 175}, {0x7cdb8502, L"Acirc", 194}, - {0x8185c62e, L"ndash", 8211}, {0x8260364a, L"Delta", 916}, - {0x846619ad, L"mdash", 8212}, {0x8550fb50, L"OElig", 338}, - {0x88eb5b85, L"ldquo", 8220}, {0x8b3fde04, L"Ograve", 210}, - {0x8bc5794b, L"ordf", 170}, {0x8bc57952, L"ordm", 186}, - {0x8c14923d, L"ouml", 246}, {0x8c5a7cd6, L"theta", 952}, - {0x8d61812b, L"thorn", 254}, {0x912b95aa, L"asymp", 8776}, - {0x947faf81, L"middot", 183}, {0x9629202e, L"lfloor", 8970}, - {0x972e9ec1, L"otilde", 245}, {0x9748f231, L"otimes", 8855}, - {0x995f1469, L"Omega", 937}, {0x99eb5349, L"quot", 34}, - {0x9aeb639e, L"hellip", 8230}, {0xa0ae2f86, L"Scaron", 352}, - {0xa4dcb0d5, L"lsaquo", 8249}, {0xa53dbf41, L"oacute", 243}, - {0xa5ae9e7b, L"bdquo", 8222}, {0xa602d7ba, L"sdot", 8901}, - {0xa61ce86f, L"sect", 167}, {0xa6e4c3d7, L"sigmaf", 962}, - {0xa7c1c74f, L"sube", 8838}, {0xa7c20ee9, L"sup1", 185}, - {0xa7c20eea, L"sup2", 178}, {0xa7c20eeb, L"sup3", 179}, - {0xa7c20f1d, L"supe", 8839}, {0xa8b66aa1, L"Otilde", 213}, - {0xad958c42, L"AElig", 198}, {0xaea9261d, L"Ouml", 214}, - {0xb040eafa, L"uArr", 8657}, {0xb07c2e1c, L"beta", 946}, - {0xb220e92f, L"bull", 8226}, {0xb22750c4, L"ccedil", 231}, - {0xb38ab31a, L"uarr", 8593}, {0xb598b683, L"uuml", 252}, - {0xb6c58b21, L"Oacute", 211}, {0xb6d2a617, L"oline", 8254}, - {0xba9fd989, L"dArr", 8659}, {0xbb5ccd41, L"lgrave", 204}, - {0xbd39b44c, L"weierp", 8472}, {0xbde9a1a9, L"darr", 8595}, - {0xc027e329, L"permil", 8240}, {0xc2451389, L"upsih", 978}, - {0xc3af1ca4, L"Ccedil", 199}, {0xcd164249, L"fnof", 402}, - {0xcf6c8467, L"hearts", 9829}, {0xd1228390, L"trade", 8482}, - {0xd1462407, L"yuml", 255}, {0xd2cf2253, L"oplus", 8853}, - {0xd310c1fc, L"Beta", 914}, {0xd59c4d74, L"infin", 8734}, - {0xd64d470d, L"hArr", 8660}, {0xd67d9c75, L"divide", 247}, - {0xd698dd37, L"Omicron", 927}, {0xd82d4a63, L"Uuml", 220}, - {0xd9970f2d, L"harr", 8596}, {0xda91fd99, L"clubs", 9827}, - {0xdbe5bdcc, L"there4", 8756}, {0xdd7671bd, L"prime", 8242}, - {0xdfcf3c06, L"alpha", 945}, {0xe0213063, L"saron", 353}, - {0xe1911d83, L"radic", 8730}, {0xe2e75468, L"raquo", 187}, - {0xe6e27a5e, L"lacute", 205}, {0xe74a8f36, L"ucirc", 251}, - {0xe864ecb6, L"Theta", 920}, {0xecddde5e, L"nabla", 8711}, - {0xed1c3557, L"omicron", 959}, {0xef82228f, L"rceil", 8969}, - {0xf1fab491, L"lArr", 8656}, {0xf3dab7e7, L"Yuml", 376}, - {0xf4294962, L"laquo", 171}, {0xf5446822, L"lang", 9001}, - {0xf5447cb1, L"larr", 8592}, {0xf66e9bea, L"ugrave", 249}, - {0xf6b4ce70, L"lota", 921}, {0xf6ef34ed, L"kappa", 954}, - {0xf72a3a56, L"thinsp", 8201}, {0xf752801a, L"luml", 207}, - {0xf88c8430, L"ocirc", 244}, {0xf9676178, L"frasl", 8260}, - {0xfd01885e, L"igrave", 236}, {0xff3281da, L"egrave", 232}, -}; - -const XFA_FMHtmlReserveCode reservesForEncode[] = { - {34, L"quot"}, {38, L"amp"}, {39, L"apos"}, - {60, L"lt"}, {62, L"gt"}, {160, L"nbsp"}, - {161, L"iexcl"}, {162, L"cent"}, {163, L"pund"}, - {164, L"current"}, {165, L"yen"}, {166, L"brvbar"}, - {167, L"sect"}, {168, L"uml"}, {169, L"copy"}, - {170, L"ordf"}, {171, L"laquo"}, {172, L"not"}, - {173, L"shy"}, {174, L"reg"}, {175, L"macr"}, - {176, L"deg"}, {177, L"plusmn"}, {178, L"sup2"}, - {179, L"sup3"}, {180, L"acute"}, {181, L"micro"}, - {182, L"para"}, {183, L"middot"}, {184, L"cedil"}, - {185, L"sup1"}, {186, L"ordm"}, {187, L"raquo"}, - {188, L"frac14"}, {189, L"frac12"}, {190, L"frac34"}, - {191, L"iquest"}, {192, L"Agrave"}, {193, L"Aacute"}, - {194, L"Acirc"}, {195, L"Atilde"}, {196, L"Auml"}, - {197, L"Aring"}, {198, L"AElig"}, {199, L"Ccedil"}, - {200, L"Egrave"}, {201, L"Eacute"}, {202, L"Ecirc"}, - {203, L"Euml"}, {204, L"lgrave"}, {205, L"lacute"}, - {206, L"lcirc"}, {207, L"luml"}, {208, L"ETH"}, - {209, L"Ntilde"}, {210, L"Ograve"}, {211, L"Oacute"}, - {212, L"Ocirc"}, {213, L"Otilde"}, {214, L"Ouml"}, - {215, L"times"}, {216, L"Oslash"}, {217, L"Ugrave"}, - {218, L"Uacute"}, {219, L"Ucirc"}, {220, L"Uuml"}, - {221, L"Yacute"}, {222, L"THORN"}, {223, L"szlig"}, - {224, L"agrave"}, {225, L"aacute"}, {226, L"acirc"}, - {227, L"atilde"}, {228, L"auml"}, {229, L"aring"}, - {230, L"aelig"}, {231, L"ccedil"}, {232, L"egrave"}, - {233, L"eacute"}, {234, L"ecirc"}, {235, L"euml"}, - {236, L"igrave"}, {237, L"iacute"}, {238, L"icirc"}, - {239, L"iuml"}, {240, L"eth"}, {241, L"ntilde"}, - {242, L"ograve"}, {243, L"oacute"}, {244, L"ocirc"}, - {245, L"otilde"}, {246, L"ouml"}, {247, L"divide"}, - {248, L"oslash"}, {249, L"ugrave"}, {250, L"uacute"}, - {251, L"ucirc"}, {252, L"uuml"}, {253, L"yacute"}, - {254, L"thorn"}, {255, L"yuml"}, {338, L"OElig"}, - {339, L"oelig"}, {352, L"Scaron"}, {353, L"saron"}, - {376, L"Yuml"}, {402, L"fnof"}, {710, L"circ"}, - {732, L"tilde"}, {913, L"Alpha"}, {914, L"Beta"}, - {915, L"Gamma"}, {916, L"Delta"}, {917, L"Epsilon"}, - {918, L"Zeta"}, {919, L"Eta"}, {920, L"Theta"}, - {921, L"lota"}, {922, L"Kappa"}, {923, L"Lambda"}, - {924, L"Mu"}, {925, L"Nu"}, {926, L"Xi"}, - {927, L"Omicron"}, {928, L"Pi"}, {929, L"Rho"}, - {931, L"Sigma"}, {932, L"Tau"}, {933, L"Upsilon"}, - {934, L"Phi"}, {935, L"Chi"}, {936, L"Psi"}, - {937, L"Omega"}, {945, L"alpha"}, {946, L"beta"}, - {947, L"gamma"}, {948, L"delta"}, {949, L"epsilon"}, - {950, L"zeta"}, {951, L"eta"}, {952, L"theta"}, - {953, L"iota"}, {954, L"kappa"}, {955, L"lambda"}, - {956, L"mu"}, {957, L"nu"}, {958, L"xi"}, - {959, L"omicron"}, {960, L"pi"}, {961, L"rho"}, - {962, L"sigmaf"}, {963, L"sigma"}, {964, L"tau"}, - {965, L"upsilon"}, {966, L"phi"}, {967, L"chi"}, - {968, L"psi"}, {969, L"omega"}, {977, L"thetasym"}, - {978, L"upsih"}, {982, L"piv"}, {8194, L"ensp"}, - {8195, L"emsp"}, {8201, L"thinsp"}, {8204, L"zwnj"}, - {8205, L"zwj"}, {8206, L"lrm"}, {8207, L"rlm"}, - {8211, L"ndash"}, {8212, L"mdash"}, {8216, L"lsquo"}, - {8217, L"rsquo"}, {8218, L"sbquo"}, {8220, L"ldquo"}, - {8221, L"tdquo"}, {8222, L"bdquo"}, {8224, L"dagger"}, - {8225, L"Dagger"}, {8226, L"bull"}, {8230, L"hellip"}, - {8240, L"permil"}, {8242, L"prime"}, {8249, L"lsaquo"}, - {8250, L"rsaquo"}, {8254, L"oline"}, {8260, L"frasl"}, - {8364, L"euro"}, {8465, L"image"}, {8472, L"weierp"}, - {8476, L"real"}, {8482, L"trade"}, {8501, L"alefsym"}, - {8592, L"larr"}, {8593, L"uarr"}, {8594, L"rarr"}, - {8595, L"darr"}, {8596, L"harr"}, {8629, L"crarr"}, - {8656, L"lArr"}, {8657, L"uArr"}, {8658, L"rArr"}, - {8659, L"dArr"}, {8660, L"hArr"}, {8704, L"forall"}, - {8706, L"part"}, {8707, L"exist"}, {8709, L"empty"}, - {8711, L"nabla"}, {8712, L"isin"}, {8713, L"notin"}, - {8715, L"ni"}, {8719, L"prod"}, {8721, L"sum"}, - {8722, L"minus"}, {8727, L"lowast"}, {8730, L"radic"}, - {8733, L"prop"}, {8734, L"infin"}, {8736, L"ang"}, - {8743, L"and"}, {8744, L"or"}, {8745, L"cap"}, - {8746, L"cup"}, {8747, L"int"}, {8756, L"there4"}, - {8764, L"sim"}, {8773, L"cong"}, {8776, L"asymp"}, - {8800, L"ne"}, {8801, L"equiv"}, {8804, L"le"}, - {8805, L"ge"}, {8834, L"sub"}, {8835, L"sup"}, - {8836, L"nsub"}, {8838, L"sube"}, {8839, L"supe"}, - {8853, L"oplus"}, {8855, L"otimes"}, {8869, L"perp"}, - {8901, L"sdot"}, {8968, L"lceil"}, {8969, L"rceil"}, - {8970, L"lfloor"}, {8971, L"rfloor"}, {9001, L"lang"}, - {9002, L"rang"}, {9674, L"loz"}, {9824, L"spades"}, - {9827, L"clubs"}, {9829, L"hearts"}, {9830, L"diams"}, -}; - -} // namespace - -void CXFA_FM2JSContext::Abs(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, argOne); - if (dValue < 0) { - dValue = -dValue; - } - FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Abs"); - } -} -void CXFA_FM2JSContext::Avg(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint32_t uCount = 0; - FX_DOUBLE dSum = 0.0; - if (argc >= 1) { - FXJSE_HVALUE argValue = 0; - for (int32_t i = 0; i < argc; i++) { - argValue = args.GetValue(i); - if (FXJSE_Value_IsNull(argValue)) { - FXJSE_Value_Release(argValue); - continue; - } else if (FXJSE_Value_IsArray(argValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t j = 2; j < iLength; j++) { - FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); - FXJSE_HVALUE defaultPropValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(jsObjectValue, defaultPropValue); - if (!FXJSE_Value_IsNull(defaultPropValue)) { - dSum += HValueToDouble(hThis, defaultPropValue); - uCount++; - } - FXJSE_Value_Release(defaultPropValue); - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - 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, - newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - dSum += HValueToDouble(hThis, newPropertyValue); - uCount++; - } - } - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(propertyValue); - } - } else { - dSum += HValueToDouble(hThis, argValue); - uCount++; - } - FXJSE_Value_Release(argValue); - } - argValue = 0; - } - if (0 == uCount) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); - } -} -void CXFA_FM2JSContext::Ceil(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argValue)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetFloat(args.GetReturnValue(), - FXSYS_ceil(HValueToFloat(hThis, argValue))); - } - FXJSE_Value_Release(argValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Ceil"); - } -} -void CXFA_FM2JSContext::Count(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint32_t uCount = 0; - FXJSE_HVALUE argValue = 0; - for (int32_t i = 0; i < argc; i++) { - argValue = args.GetValue(i); - if (FXJSE_Value_IsNull(argValue)) { - FXJSE_Value_Release(argValue); - continue; - } else if (FXJSE_Value_IsArray(argValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - GetObjectDefaultValue(jsObjectValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - } - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1); - } - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(newPropertyValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else if (FXJSE_Value_IsObject(argValue)) { - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(argValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - } - FXJSE_Value_Release(newPropertyValue); - } else { - uCount++; - } - FXJSE_Value_Release(argValue); - } - argValue = 0; - FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); -} -void CXFA_FM2JSContext::Floor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argValue = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argValue)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetFloat(args.GetReturnValue(), - FXSYS_floor(HValueToFloat(hThis, argValue))); - } - FXJSE_Value_Release(argValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Floor"); - } -} -void CXFA_FM2JSContext::Max(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint32_t uCount = 0; - FX_DOUBLE dMaxValue = 0.0; - FXJSE_HVALUE argValue = 0; - for (int32_t i = 0; i < argc; i++) { - argValue = args.GetValue(i); - if (FXJSE_Value_IsNull(argValue)) { - FXJSE_Value_Release(argValue); - continue; - } else if (FXJSE_Value_IsArray(argValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - GetObjectDefaultValue(jsObjectValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMaxValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMaxValue < dValue) { - dMaxValue = dValue; - } - } - } - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMaxValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMaxValue < dValue) { - dMaxValue = dValue; - } - } - } - } - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(newPropertyValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else if (FXJSE_Value_IsObject(argValue)) { - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(argValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMaxValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMaxValue < dValue) { - dMaxValue = dValue; - } - } - } - FXJSE_Value_Release(newPropertyValue); - } else { - uCount++; - if (uCount == 1) { - dMaxValue = HValueToDouble(hThis, argValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, argValue); - if (dMaxValue < dValue) { - dMaxValue = dValue; - } - } - } - FXJSE_Value_Release(argValue); - } - argValue = 0; - if (uCount) { - FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } -} -void CXFA_FM2JSContext::Min(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint32_t uCount = 0; - FX_DOUBLE dMinValue = 0.0; - FXJSE_HVALUE argValue = 0; - for (int32_t i = 0; i < argc; i++) { - argValue = args.GetValue(i); - if (FXJSE_Value_IsNull(argValue)) { - FXJSE_Value_Release(argValue); - continue; - } else if (FXJSE_Value_IsArray(argValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argValue, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - GetObjectDefaultValue(jsObjectValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMinValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMinValue > dValue) { - dMinValue = dValue; - } - } - } - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - for (int32_t i = 2; i < iLength; i++) { - FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMinValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMinValue > dValue) { - dMinValue = dValue; - } - } - } - } - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(newPropertyValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else if (FXJSE_Value_IsObject(argValue)) { - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(argValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - uCount++; - if (uCount == 1) { - dMinValue = HValueToDouble(hThis, newPropertyValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, newPropertyValue); - if (dMinValue > dValue) { - dMinValue = dValue; - } - } - } - FXJSE_Value_Release(newPropertyValue); - } else { - uCount++; - if (uCount == 1) { - dMinValue = HValueToDouble(hThis, argValue); - } else { - FX_DOUBLE dValue = HValueToDouble(hThis, argValue); - if (dMinValue > dValue) { - dMinValue = dValue; - } - } - } - FXJSE_Value_Release(argValue); - } - argValue = 0; - if (uCount) { - FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } -} -void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - if (args.GetLength() == 2) { - FXJSE_HVALUE argOne = args.GetValue(0); - FXJSE_HVALUE argTwo = args.GetValue(1); - if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE dDividend = 0.0; - FX_DOUBLE dDividor = 0.0; - if (FXJSE_Value_IsArray(argOne)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - dDividend = HValueToDouble(hThis, jsObjectValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - dDividend = HValueToDouble(hThis, newPropertyValue); - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - dDividend = HValueToDouble(hThis, argOne); - } - if (FXJSE_Value_IsArray(argTwo)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argTwo, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - dDividor = HValueToDouble(hThis, jsObjectValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - dDividor = HValueToDouble(hThis, newPropertyValue); - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - dDividor = HValueToDouble(hThis, argTwo); - } - if (dDividor) { - FXJSE_Value_SetDouble( - args.GetReturnValue(), - dDividend - dDividor * (int32_t)(dDividend / dDividor)); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Mod"); - } -} -void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint8_t uPrecision = 0; - if (argc == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE dValue = 0.0; - if (FXJSE_Value_IsArray(argOne)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - dValue = HValueToDouble(hThis, jsObjectValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - dValue = HValueToDouble(hThis, newPropertyValue); - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - dValue = HValueToDouble(hThis, argOne); - } - CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); - CFX_WideString wsValue = decimalValue; - FXJSE_Value_SetUTF8String(args.GetReturnValue(), wsValue.UTF8Encode()); - } - FXJSE_Value_Release(argOne); - } else if (argc == 2) { - FXJSE_HVALUE argOne = args.GetValue(0); - FXJSE_HVALUE argTwo = args.GetValue(1); - if (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE dValue = 0.0; - if (FXJSE_Value_IsArray(argOne)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - dValue = HValueToDouble(hThis, jsObjectValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - dValue = HValueToDouble(hThis, newPropertyValue); - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - dValue = HValueToDouble(hThis, argOne); - } - FX_DOUBLE dPrecision = 0.0; - if (FXJSE_Value_IsArray(argTwo)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argTwo, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argTwo, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - dPrecision = HValueToDouble(hThis, jsObjectValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - dPrecision = HValueToDouble(hThis, newPropertyValue); - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - dPrecision = HValueToDouble(hThis, argTwo); - } - if (dPrecision < 0) { - uPrecision = 0; - } else if (dPrecision > 12.0) { - uPrecision = 12; - } else { - uPrecision = (uint8_t)dPrecision; - } - CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); - CFX_WideString wsValue = decimalValue; - FXJSE_Value_SetUTF8String(args.GetReturnValue(), wsValue.UTF8Encode()); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Round"); - } -} -void CXFA_FM2JSContext::Sum(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - uint32_t uCount = 0; - FX_DOUBLE dSum = 0.0; - if (argc) { - FXJSE_HVALUE argValue = 0; - for (int32_t i = 0; i < argc; i++) { - argValue = args.GetValue(i); - if (FXJSE_Value_IsNull(argValue)) { - FXJSE_Value_Release(argValue); - continue; - } else if (FXJSE_Value_IsArray(argValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argValue, 1, propertyValue); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t j = 2; j < iLength; j++) { - FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); - GetObjectDefaultValue(jsObjectValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - dSum += HValueToDouble(hThis, jsObjectValue); - uCount++; - } - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - for (int32_t j = 2; j < iLength; j++) { - FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, - newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - dSum += HValueToDouble(hThis, newPropertyValue); - uCount++; - } - } - } - FXJSE_Value_Release(newPropertyValue); - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(propertyValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else if (FXJSE_Value_IsObject(argValue)) { - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(argValue, newPropertyValue); - if (!FXJSE_Value_IsNull(newPropertyValue)) { - dSum += HValueToDouble(hThis, argValue); - uCount++; - } - FXJSE_Value_Release(newPropertyValue); - } else { - dSum += HValueToDouble(hThis, argValue); - uCount++; - } - FXJSE_Value_Release(argValue); - } - argValue = 0; - } - if (uCount < 1) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); - } -} -void CXFA_FM2JSContext::Date(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 0) { - struct tm* pTmStruct = 0; - time_t currentTime; - time(¤tTime); - pTmStruct = gmtime(¤tTime); - CFX_ByteString bufferYear; - CFX_ByteString bufferMon; - CFX_ByteString bufferDay; - bufferYear.Format("%d", pTmStruct->tm_year + 1900); - bufferMon.Format("%02d", pTmStruct->tm_mon + 1); - bufferDay.Format("%02d", pTmStruct->tm_mday); - CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; - int32_t dDays = DateString2Num(bufferCurrent); - FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Date"); - } -} -void CXFA_FM2JSContext::Date2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - CFX_ByteString dateString; - CFX_ByteString formatString; - CFX_ByteString localString; - FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE formatValue = 0; - FXJSE_HVALUE localValue = 0; - if (HValueIsNull(hThis, dateValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(dateValue, dateString); - } - if (argc > 1) { - formatValue = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, formatValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(formatValue, formatString); - } - } - if (argc == 3) { - localValue = GetSimpleHValue(hThis, args, 2); - if (HValueIsNull(hThis, localValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localValue, localString); - } - } - if (!bFlags) { - CFX_ByteString szIsoDateString; - FX_BOOL bRet = Local2IsoDate(hThis, dateString, formatString, localString, - szIsoDateString); - if (bRet) { - FXJSE_Value_SetInteger(args.GetReturnValue(), - DateString2Num(szIsoDateString)); - } else { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(dateValue); - if (argc > 1) { - FXJSE_Value_Release(formatValue); - if (argc == 3) { - FXJSE_Value_Release(localValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Date2Num"); - } -} -void CXFA_FM2JSContext::DateFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc < 3) { - FX_BOOL bFlags = FALSE; - int32_t iStyle = 0; - CFX_ByteString szLocal; - FXJSE_HVALUE argStyle = 0; - FXJSE_HVALUE argLocal = 0; - if (argc > 0) { - argStyle = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argStyle)) { - bFlags = TRUE; - } - iStyle = (int32_t)HValueToFloat(hThis, argStyle); - if (iStyle > 4 || iStyle < 0) { - iStyle = 0; - } - } - if (argc == 2) { - argLocal = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argLocal)) { - bFlags = TRUE; - } else { - HValueToUTF8String(argLocal, szLocal); - } - } - if (!bFlags) { - CFX_ByteString formatStr; - GetStandardDateFormat(hThis, iStyle, szLocal, formatStr); - if (formatStr.IsEmpty()) { - formatStr = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - if (argc > 0) { - FXJSE_Value_Release(argStyle); - if (argc == 2) { - FXJSE_Value_Release(argLocal); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Date2Num"); - } -} -void CXFA_FM2JSContext::IsoDate2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString szArgString; - HValueToUTF8String(argOne, szArgString); - int32_t dDays = DateString2Num(szArgString); - FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"IsoDate2Num"); - } -} -void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CXFA_Document* pDoc = pContext->GetDocument(); - FXSYS_assert(pDoc); - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - CFX_ByteString szArgString; - HValueToUTF8String(argOne, szArgString); - szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); - if (szArgString.IsEmpty()) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - FXJSE_Value_Release(argOne); - return; - } - CXFA_LocaleValue timeValue( - XFA_VT_TIME, - CFX_WideString::FromUTF8(szArgString, szArgString.GetLength()), - (CXFA_LocaleMgr*)pMgr); - if (timeValue.IsValid()) { - CFX_Unitime uniTime = timeValue.GetTime(); - int32_t hour = uniTime.GetHour(); - int32_t min = uniTime.GetMinute(); - int32_t second = uniTime.GetSecond(); - int32_t milSecond = uniTime.GetMillisecond(); - IFX_Locale* pDefLocale = pMgr->GetDefLocale(); - FXSYS_assert(pDefLocale); - FX_TIMEZONE tzLocale; - pDefLocale->GetTimeZone(tzLocale); - int32_t mins = hour * 60 + min; - mins -= (tzLocale.tzHour * 60); - while (mins > 1440) { - mins -= 1440; - } - while (mins < 0) { - mins += 1440; - } - hour = mins / 60; - min = mins % 60; - int32_t iResult = - hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; - FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); - } else { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"IsoTime2Num"); - } -} -void CXFA_FM2JSContext::LocalDateFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc < 3) { - FX_BOOL bFlags = FALSE; - int32_t iStyle = 0; - CFX_ByteString szLocal; - FXJSE_HVALUE argStyle = 0; - FXJSE_HVALUE argLocal = 0; - if (argc > 0) { - argStyle = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argStyle)) { - bFlags = TRUE; - } - iStyle = (int32_t)HValueToFloat(hThis, argStyle); - if (iStyle > 4 || iStyle < 0) { - iStyle = 0; - } - } - if (argc == 2) { - argLocal = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argLocal)) { - bFlags = TRUE; - } else { - HValueToUTF8String(argLocal, szLocal); - } - } - if (!bFlags) { - CFX_ByteString formatStr; - GetLocalDateFormat(hThis, iStyle, szLocal, formatStr, FALSE); - if (formatStr.IsEmpty()) { - formatStr = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - if (argc > 0) { - FXJSE_Value_Release(argStyle); - if (argc == 2) { - FXJSE_Value_Release(argLocal); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"LocalDateFmt"); - } -} -void CXFA_FM2JSContext::LocalTimeFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc < 3) { - FX_BOOL bFlags = FALSE; - int32_t iStyle = 0; - CFX_ByteString szLocal; - FXJSE_HVALUE argStyle = 0; - FXJSE_HVALUE argLocal = 0; - if (argc > 0) { - argStyle = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argStyle)) { - bFlags = TRUE; - } - iStyle = (int32_t)HValueToFloat(hThis, argStyle); - if (iStyle > 4 || iStyle < 0) { - iStyle = 0; - } - } - if (argc == 2) { - argLocal = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argLocal)) { - bFlags = TRUE; - } else { - HValueToUTF8String(argLocal, szLocal); - } - } - if (!bFlags) { - CFX_ByteString formatStr; - GetLocalTimeFormat(hThis, iStyle, szLocal, formatStr, FALSE); - if (formatStr.IsEmpty()) { - formatStr = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - if (argc > 0) { - FXJSE_Value_Release(argStyle); - if (argc == 2) { - FXJSE_Value_Release(argLocal); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"LocalTimeFmt"); - } -} -void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - int32_t dDate; - CFX_ByteString formatString; - CFX_ByteString localString; - FXJSE_HVALUE dateValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE formatValue = 0; - FXJSE_HVALUE localValue = 0; - if (HValueIsNull(hThis, dateValue)) { - bFlags = TRUE; - } else { - dDate = (int32_t)HValueToFloat(hThis, dateValue); - bFlags = dDate < 1; - } - if (argc > 1) { - formatValue = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, formatValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(formatValue, formatString); - } - } - if (argc == 3) { - localValue = GetSimpleHValue(hThis, args, 2); - if (HValueIsNull(hThis, localValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localValue, localString); - } - } - if (!bFlags) { - int32_t iYear = 1900; - int32_t iMonth = 1; - int32_t iDay = 1; - int32_t i = 0; - while (dDate > 0) { - if (iMonth == 2) { - if ((!((iYear + i) % 4) && ((iYear + i) % 100)) || - !((iYear + i) % 400)) { - if (dDate > 29) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 29; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } else { - if (dDate > 28) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 28; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } - } else if (iMonth < 8) { - if ((iMonth % 2 == 0)) { - if (dDate > 30) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 30; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } else { - if (dDate > 31) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 31; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } - } else { - if (iMonth % 2 != 0) { - if (dDate > 30) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 30; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } else { - if (dDate > 31) { - ++iMonth; - if (iMonth > 12) { - iMonth = 1; - ++i; - } - iDay = 1; - dDate -= 31; - } else { - iDay += static_cast<int32_t>(dDate) - 1; - dDate = 0; - } - } - } - } - CFX_ByteString szIsoDateString; - szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); - CFX_ByteString szLocalDateString; - IsoDate2Local(hThis, szIsoDateString, formatString, localString, - szLocalDateString); - if (szLocalDateString.IsEmpty()) { - szLocalDateString = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szLocalDateString); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(dateValue); - if (argc > 1) { - FXJSE_Value_Release(formatValue); - if (argc == 3) { - FXJSE_Value_Release(localValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Num2Date"); - } -} -void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - int32_t iTime; - CFX_ByteString formatString; - CFX_ByteString localString; - FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE formatValue = 0; - FXJSE_HVALUE localValue = 0; - if (FXJSE_Value_IsNull(timeValue)) { - bFlags = TRUE; - } else { - iTime = (int32_t)HValueToFloat(hThis, timeValue); - if (FXSYS_abs(iTime) < 1.0) { - bFlags = TRUE; - } - } - if (argc > 1) { - formatValue = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(formatValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(formatValue, formatString); - } - } - if (argc == 3) { - localValue = GetSimpleHValue(hThis, args, 2); - if (FXJSE_Value_IsNull(localValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localValue, localString); - } - } - if (!bFlags) { - CFX_ByteString szGMTTimeString; - Num2AllTime(hThis, iTime, formatString, localString, TRUE, - szGMTTimeString); - if (szGMTTimeString.IsEmpty()) { - szGMTTimeString = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szGMTTimeString); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(timeValue); - if (argc > 1) { - FXJSE_Value_Release(formatValue); - if (argc == 3) { - FXJSE_Value_Release(localValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Num2GMTime"); - } -} -void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - FX_FLOAT fTime; - CFX_ByteString formatString; - CFX_ByteString localString; - FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE formatValue = 0; - FXJSE_HVALUE localValue = 0; - if (FXJSE_Value_IsNull(timeValue)) { - bFlags = TRUE; - } else { - fTime = HValueToFloat(hThis, timeValue); - if (FXSYS_fabs(fTime) < 1.0) { - bFlags = TRUE; - } - } - if (argc > 1) { - formatValue = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(formatValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(formatValue, formatString); - } - } - if (argc == 3) { - localValue = GetSimpleHValue(hThis, args, 2); - if (FXJSE_Value_IsNull(localValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localValue, localString); - } - } - if (!bFlags) { - CFX_ByteString szLocalTimeString; - Num2AllTime(hThis, (int32_t)fTime, formatString, localString, FALSE, - szLocalTimeString); - if (szLocalTimeString.IsEmpty()) { - szLocalTimeString = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szLocalTimeString); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(timeValue); - if (argc > 1) { - FXJSE_Value_Release(formatValue); - if (argc == 3) { - FXJSE_Value_Release(localValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Num2Time"); - } -} -void CXFA_FM2JSContext::Time(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 0) { - time_t now; - time(&now); - struct tm* pGmt = gmtime(&now); - int32_t iGMHour = pGmt->tm_hour; - int32_t iGMMin = pGmt->tm_min; - int32_t iGMSec = pGmt->tm_sec; - FXJSE_Value_SetInteger(args.GetReturnValue(), - ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Time"); - } -} -void CXFA_FM2JSContext::Time2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - CFX_ByteString timeString; - CFX_ByteString formatString; - CFX_ByteString localString; - FXJSE_HVALUE timeValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE formatValue = 0; - FXJSE_HVALUE localValue = 0; - if (HValueIsNull(hThis, timeValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(timeValue, timeString); - } - if (argc > 1) { - formatValue = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, formatValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(formatValue, formatString); - } - } - if (argc == 3) { - localValue = GetSimpleHValue(hThis, args, 2); - if (HValueIsNull(hThis, localValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localValue, localString); - } - } - if (!bFlags) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (localString.IsEmpty()) { - CXFA_Node* pThisNode = - ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(localString, localString.GetLength())); - } - CFX_WideString wsFormat; - if (formatString.IsEmpty()) { - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(formatString, formatString.GetLength()); - } - wsFormat = FX_WSTRC(L"time{") + wsFormat; - wsFormat += FX_WSTRC(L"}"); - CXFA_LocaleValue timeValue( - XFA_VT_TIME, - CFX_WideString::FromUTF8(timeString, timeString.GetLength()), - wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); - if (timeValue.IsValid()) { - CFX_Unitime uniTime = timeValue.GetTime(); - int32_t hour = uniTime.GetHour(); - int32_t min = uniTime.GetMinute(); - int32_t second = uniTime.GetSecond(); - int32_t milSecond = uniTime.GetMillisecond(); - int32_t mins = hour * 60 + min; - IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); - if (pProvider) { - FX_TIMEZONE tz; - pProvider->GetTimeZone(tz); - mins -= (tz.tzHour * 60); - while (mins > 1440) { - mins -= 1440; - } - while (mins < 0) { - mins += 1440; - } - hour = mins / 60; - min = mins % 60; - } - int32_t iResult = - hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; - FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); - } else { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(timeValue); - if (argc > 1) { - FXJSE_Value_Release(formatValue); - if (argc == 3) { - FXJSE_Value_Release(localValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Time2Num"); - } -} -void CXFA_FM2JSContext::TimeFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc < 3) { - FX_BOOL bFlags = FALSE; - int32_t iStyle = 0; - CFX_ByteString szLocal; - FXJSE_HVALUE argStyle = 0; - FXJSE_HVALUE argLocal = 0; - if (argc > 0) { - argStyle = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argStyle)) { - bFlags = TRUE; - } - iStyle = (int32_t)HValueToFloat(hThis, argStyle); - if (iStyle > 4 || iStyle < 0) { - iStyle = 0; - } - } - if (argc == 2) { - argLocal = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argLocal)) { - bFlags = TRUE; - } else { - HValueToUTF8String(argLocal, szLocal); - } - } - if (!bFlags) { - CFX_ByteString formatStr; - GetStandardTimeFormat(hThis, iStyle, szLocal, formatStr); - if (formatStr.IsEmpty()) { - formatStr = ""; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - if (argc > 0) { - FXJSE_Value_Release(argStyle); - if (argc == 2) { - FXJSE_Value_Release(argLocal); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"TimeFmt"); - } -} -FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iStyle, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) { - iYear = 0; - iMonth = 1; - iDay = 1; - FX_BOOL iRet = FALSE; - if (iLength < 4) { - return iRet; - } - FX_CHAR strYear[5]; - strYear[4] = '\0'; - for (int32_t i = 0; i < 4; ++i) { - if (*(pData + i) <= '9' && *(pData + i) >= '0') { - strYear[i] = *(pData + i); - } else { - return iRet; - } - } - iYear = FXSYS_atoi(strYear); - iStyle = 0; - if (iLength > 4) { - if (*(pData + 4) == '-') { - iStyle = 1; - } else { - iStyle = 0; - } - } else { - iRet = TRUE; - return iRet; - } - FX_CHAR strTemp[3]; - strTemp[2] = '\0'; - int32_t iPosOff = 0; - if (iStyle == 0) { - iPosOff = 4; - if (iLength == 4) { - iRet = TRUE; - return iRet; - } - } else { - iPosOff = 5; - if (iLength == 4) { - iRet = TRUE; - return iRet; - } - } - if ((*(pData + iPosOff) > '9' || *(pData + iPosOff) < '0') || - (*(pData + iPosOff + 1) > '9' || *(pData + iPosOff + 1) < '0')) { - return iRet; - } - strTemp[0] = *(pData + iPosOff); - strTemp[1] = *(pData + iPosOff + 1); - iMonth = FXSYS_atoi(strTemp); - if (iMonth > 12 || iMonth < 1) { - return iRet; - } - if (iStyle == 0) { - iPosOff += 2; - if (iLength == 6) { - iRet = 1; - return iRet; - } - } else { - iPosOff += 3; - if (iLength == 7) { - iRet = 1; - return iRet; - } - } - if ((*(pData + iPosOff) > '9' || *(pData + iPosOff) < '0') || - (*(pData + iPosOff + 1) > '9' || *(pData + iPosOff + 1) < '0')) { - return iRet; - } - strTemp[0] = *(pData + iPosOff); - strTemp[1] = *(pData + iPosOff + 1); - iDay = FXSYS_atoi(strTemp); - if (iPosOff + 2 < iLength) { - return iRet; - } - if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) { - if (iMonth == 2) { - if (iDay > 29) { - return iRet; - } - } else { - if (iMonth < 8) { - if (iDay > (iMonth % 2 == 0 ? 30 : 31)) { - return iRet; - } - } else { - if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { - return iRet; - } - } - } - } else { - if (iMonth == 2) { - if (iDay > 28) { - return iRet; - } - } else { - if (iMonth < 8) { - if (iDay > (iMonth % 2 == 0 ? 30 : 31)) { - return iRet; - } - } else { - if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { - return iRet; - } - } - } - } - iRet = TRUE; - return iRet; -} -FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iHour, - int32_t& iMinute, - int32_t& iSecond, - int32_t& iMilliSecond, - int32_t& iZoneHour, - int32_t& iZoneMinute) { - iHour = 0; - iMinute = 0; - iSecond = 0; - iMilliSecond = 0; - iZoneHour = 0; - iZoneMinute = 0; - if (!pData) { - return FALSE; - } - int32_t iRet = FALSE; - FX_CHAR strTemp[3]; - strTemp[2] = '\0'; - int32_t iIndex = 0; - int32_t iZone = 0; - int32_t i = iIndex; - while (i < iLength) { - if ((*(pData + i) > '9' || *(pData + i) < '0') && *(pData + i) != ':') { - iZone = i; - break; - } - ++i; - } - if (i == iLength) { - iZone = iLength; - } - int32_t iPos = 0; - while (iIndex < iZone) { - if (iIndex >= iZone) { - break; - } - if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { - return iRet; - } - strTemp[0] = *(pData + iIndex); - if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { - return iRet; - } - strTemp[1] = *(pData + iIndex + 1); - if (FXSYS_atoi(strTemp) > 60) { - return iRet; - } - if (*(pData + 2) == ':') { - if (iPos == 0) { - iHour = FXSYS_atoi(strTemp); - ++iPos; - } else if (iPos == 1) { - iMinute = FXSYS_atoi(strTemp); - ++iPos; - } else { - iSecond = FXSYS_atoi(strTemp); - } - iIndex += 3; - } else { - if (iPos == 0) { - iHour = FXSYS_atoi(strTemp); - ++iPos; - } else if (iPos == 1) { - iMinute = FXSYS_atoi(strTemp); - ++iPos; - } else if (iPos == 2) { - iSecond = FXSYS_atoi(strTemp); - ++iPos; - } - iIndex += 2; - } - } - if (*(pData + iIndex) == '.') { - ++iIndex; - FX_CHAR strTemp[4]; - strTemp[3] = '\0'; - if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { - return iRet; - } - strTemp[0] = *(pData + iIndex); - if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { - return iRet; - } - strTemp[1] = *(pData + iIndex + 1); - if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { - return iRet; - } - strTemp[2] = *(pData + iIndex + 2); - iMilliSecond = FXSYS_atoi(strTemp); - if (iMilliSecond > 100) { - iMilliSecond = 0; - return iRet; - } - iIndex += 3; - } - int32_t iSign = 1; - if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') { - iRet = 1; - return iRet; - } else if (*(pData + iIndex) == '+') { - ++iIndex; - } else if (*(pData + iIndex) == '-') { - iSign = -1; - ++iIndex; - } - iPos = 0; - while (iIndex < iLength) { - if (iIndex >= iLength) { - return iRet; - } - if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { - return iRet; - } - strTemp[0] = *(pData + iIndex); - if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { - return iRet; - } - strTemp[1] = *(pData + iIndex + 1); - if (FXSYS_atoi(strTemp) > 60) { - return iRet; - } - if (*(pData + 2) == ':') { - if (iPos == 0) { - iZoneHour = FXSYS_atoi(strTemp); - } else if (iPos == 1) { - iZoneMinute = FXSYS_atoi(strTemp); - } - iIndex += 3; - } else { - if (!iPos) { - iZoneHour = FXSYS_atoi(strTemp); - ++iPos; - } else if (iPos == 1) { - iZoneMinute = FXSYS_atoi(strTemp); - ++iPos; - } - iIndex += 2; - } - } - if (iIndex < iLength) { - return iRet; - } - iZoneHour *= iSign; - iRet = TRUE; - return iRet; -} -FX_BOOL CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay, - int32_t& iHour, - int32_t& iMinute, - int32_t& iSecond, - int32_t& iMillionSecond, - int32_t& iZoneHour, - int32_t& iZoneMinute) { - iYear = 0; - iMonth = 0; - iDay = 0; - iHour = 0; - iMinute = 0; - iSecond = 0; - if (!pData) { - return FALSE; - } - int32_t iRet = FALSE; - int32_t iIndex = 0; - while (*(pData + iIndex) != 'T' && *(pData + iIndex) != 't') { - if (iIndex >= iLength) { - return iRet; - } - ++iIndex; - } - if (iIndex != 8 && iIndex != 10) { - return iRet; - } - int32_t iStyle = -1; - iRet = IsIsoDateFormat(pData, iIndex, iStyle, iYear, iMonth, iDay); - if (!iRet) { - return iRet; - } - if (*(pData + iIndex) != 'T' && *(pData + iIndex) != 't') { - return iRet; - } - ++iIndex; - if (((iLength - iIndex > 13) && (iLength - iIndex < 6)) && - (iLength - iIndex != 15)) { - return iRet; - } - iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, - iSecond, iMillionSecond, iZoneHour, iZoneMinute); - if (!iRet) { - return iRet; - } - iRet = TRUE; - return iRet; -} -FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szDate, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strIsoDate) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return FALSE; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocale.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); - } - if (!pLocale) { - return FALSE; - } - CFX_WideString wsFormat; - if (szFormat.IsEmpty()) { - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); - } - CXFA_LocaleValue widgetValue( - XFA_VT_DATE, - CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), wsFormat, - pLocale, (CXFA_LocaleMgr*)pMgr); - CFX_Unitime dt = widgetValue.GetDate(); - strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); - return TRUE; -} -FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strIsoTime) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return FALSE; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocale.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); - } - if (!pLocale) { - return FALSE; - } - CFX_WideString wsFormat; - if (szFormat.IsEmpty()) { - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); - } - wsFormat = FX_WSTRC(L"time{") + wsFormat; - wsFormat += FX_WSTRC(L"}"); - CXFA_LocaleValue widgetValue( - XFA_VT_TIME, - CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), wsFormat, - pLocale, (CXFA_LocaleMgr*)pMgr); - CFX_Unitime utime = widgetValue.GetTime(); - strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), - utime.GetSecond(), utime.GetMillisecond()); - return TRUE; -} -FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szDate, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strLocalDate) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return FALSE; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocale.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); - } - if (!pLocale) { - return FALSE; - } - CFX_WideString wsFormat; - if (szFormat.IsEmpty()) { - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); - } - CXFA_LocaleValue widgetValue( - XFA_VT_DATE, - CFX_WideString::FromUTF8(szDate.GetCStr(), szDate.GetLength()), - (CXFA_LocaleMgr*)pMgr); - CFX_WideString wsRet; - widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, - XFA_VALUEPICTURE_Display); - strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength()); - return TRUE; -} -FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strLocalTime) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return FALSE; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocale.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); - } - if (!pLocale) { - return FALSE; - } - CFX_WideString wsFormat; - if (szFormat.IsEmpty()) { - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); - } - wsFormat = FX_WSTRC(L"time{") + wsFormat; - wsFormat += FX_WSTRC(L"}"); - CXFA_LocaleValue widgetValue( - XFA_VT_TIME, - CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), - (CXFA_LocaleMgr*)pMgr); - CFX_WideString wsRet; - widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, - XFA_VALUEPICTURE_Display); - strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); - return TRUE; -} -FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strGMTTime) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return FALSE; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocale.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocale.GetCStr(), szLocale.GetLength())); - } - if (!pLocale) { - return FALSE; - } - CFX_WideString wsFormat; - if (szFormat.IsEmpty()) { - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); - } else { - wsFormat = - CFX_WideString::FromUTF8(szFormat.GetCStr(), szFormat.GetLength()); - } - wsFormat = FX_WSTRC(L"time{") + wsFormat; - wsFormat += FX_WSTRC(L"}"); - CXFA_LocaleValue widgetValue( - XFA_VT_TIME, - CFX_WideString::FromUTF8(szTime.GetCStr(), szTime.GetLength()), - (CXFA_LocaleMgr*)pMgr); - CFX_WideString wsRet; - widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, - XFA_VALUEPICTURE_Display); - strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength()); - return TRUE; -} -int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { - FX_BOOL bFlags = FALSE; - int32_t iLength = szDateString.GetLength(); - FX_BOOL iRet = FALSE; - int32_t iStyle = -1; - int32_t iYear = 0; - int32_t iMonth = 0; - int32_t iDay = 0; - int32_t iHour = 0; - int32_t iMinute = 0; - int32_t iSecond = 0; - int32_t iMillionSecond = 0; - int32_t iZoneHour = 0; - int32_t iZoneMinute = 0; - if (iLength <= 10) { - iRet = IsIsoDateFormat(szDateString.GetCStr(), iLength, iStyle, iYear, - iMonth, iDay); - } else { - iRet = IsIsoDateTimeFormat(szDateString.GetCStr(), iLength, iYear, iMonth, - iDay, iHour, iMinute, iSecond, iMillionSecond, - iZoneHour, iZoneMinute); - } - if (!iRet) { - bFlags = TRUE; - } - FX_FLOAT dDays = 0; - int32_t i = 1; - if (iYear < 1900) { - bFlags = TRUE; - } - if (!bFlags) { - while (iYear - i >= 1900) { - if ((!((iYear - i) % 4) && ((iYear - i) % 100)) || !((iYear - i) % 400)) { - dDays += 366; - } else { - dDays += 365; - } - ++i; - } - i = 1; - while (i < iMonth) { - if (i == 2) { - if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) { - dDays += 29; - } else { - dDays += 28; - } - } else if (i <= 7) { - if (i % 2 == 0) { - dDays += 30; - } else { - dDays += 31; - } - } else { - if (i % 2 == 0) { - dDays += 31; - } else { - dDays += 30; - } - } - ++i; - } - i = 0; - while (iDay - i > 0) { - dDays += 1; - ++i; - } - } else { - dDays = 0; - } - return (int32_t)dDays; -} -#define XFA_N 19 -static uint8_t g_sAltTable_Date[] = { - XFA_N, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, 2, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, 1, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, -}; -static uint8_t g_sAltTable_Time[] = { - 14, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, - XFA_N, 6, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 7, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, 1, 17, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, -}; -static void XFA_FM_AlternateDateTimeSymbols(CFX_WideString& wsPattern, - const CFX_WideString& wsAltSymbols, - uint8_t* pAltTable) { - int32_t nLength = wsPattern.GetLength(); - FX_BOOL bInConstRange = FALSE; - FX_BOOL bEscape = FALSE; - int32_t i = 0, n = 0; - while (i < nLength) { - FX_WCHAR wc = wsPattern[i]; - if (wc == L'\'') { - bInConstRange = !bInConstRange; - if (bEscape) { - i++; - } else { - wsPattern.Delete(i); - nLength--; - } - bEscape = !bEscape; - continue; - } - if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { - int32_t nAlt = (int32_t)pAltTable[n]; - if (nAlt != XFA_N) { - wsPattern.SetAt(i, wsAltSymbols[nAlt]); - } - } - i++; - bEscape = FALSE; - } -} -#undef XFA_N -void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat, - FX_BOOL bStandard) { - FX_LOCALEDATETIMESUBCATEGORY strStyle; - switch (iStyle) { - case 0: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - case 1: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; - break; - case 2: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - case 3: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; - break; - case 4: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; - break; - default: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - } - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocalStr.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); - } - if (!pLocale) { - return; - } - CFX_WideString strRet; - pLocale->GetDatePattern(strStyle, strRet); - if (!bStandard) { - CFX_WideString wsSymbols; - pLocale->GetDateTimeSymbols(wsSymbols); - XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); - } - strFormat = FX_UTF8Encode(strRet, strRet.GetLength()); -} -void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat, - FX_BOOL bStandard) { - FX_LOCALEDATETIMESUBCATEGORY strStyle; - switch (iStyle) { - case 0: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - case 1: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; - break; - case 2: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - case 3: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; - break; - case 4: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; - break; - default: - strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; - break; - } - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return; - } - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - IFX_Locale* pLocale = NULL; - if (szLocalStr.IsEmpty()) { - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - pLocale = widgetData.GetLocal(); - } else { - pLocale = pMgr->GetLocaleByName( - CFX_WideString::FromUTF8(szLocalStr.GetCStr(), szLocalStr.GetLength())); - } - if (!pLocale) { - return; - } - CFX_WideString strRet; - pLocale->GetTimePattern(strStyle, strRet); - if (!bStandard) { - CFX_WideString wsSymbols; - pLocale->GetDateTimeSymbols(wsSymbols); - XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); - } - strFormat = FX_UTF8Encode(strRet, strRet.GetLength()); -} -void CXFA_FM2JSContext::GetStandardDateFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat) { - GetLocalDateFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); -} -void CXFA_FM2JSContext::GetStandardTimeFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat) { - GetLocalTimeFormat(hThis, iStyle, szLocalStr, strFormat, TRUE); -} -void CXFA_FM2JSContext::Num2AllTime(FXJSE_HOBJECT hThis, - int32_t iTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - FX_BOOL bGM, - CFX_ByteString& strTime) { - int32_t iHour = 0; - int32_t iMin = 0; - int32_t iSec = 0; - int32_t iZoneHour = 0; - int32_t iZoneMin = 0; - int32_t iZoneSec = 0; - iHour = static_cast<int>(iTime) / 3600000; - iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; - iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; - if (!bGM) { - GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); - iHour += iZoneHour; - iMin += iZoneMin; - iSec += iZoneSec; - } - int32_t iRet = 0; - CFX_ByteString strIsoTime; - strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); - if (bGM) { - iRet = GetGMTTime(hThis, strIsoTime, szFormat, szLocale, strTime); - } else { - iRet = IsoTime2Local(hThis, strIsoTime, szFormat, szLocale, strTime); - } - if (!iRet) { - strTime = ""; - } -} - -void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, - int32_t& iMin, - int32_t& iSec) { - time_t now; - time(&now); - struct tm* pGmt = gmtime(&now); - int32_t iGMHour = pGmt->tm_hour; - int32_t iGMMin = pGmt->tm_min; - int32_t iGMSec = pGmt->tm_sec; - struct tm* pLocal = localtime(&now); - int32_t iLocalHour = pLocal->tm_hour; - int32_t iLocalMin = pLocal->tm_min; - int32_t iLocalSec = pLocal->tm_sec; - iHour = iLocalHour - iGMHour; - iMin = iLocalMin - iGMMin; - iSec = iLocalSec - iGMSec; -} -void CXFA_FM2JSContext::Apr(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_DOUBLE nPrincipal = 0; - FX_DOUBLE nPayment = 0; - FX_DOUBLE nPeriods = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nPrincipal = HValueToDouble(hThis, argOne); - nPayment = HValueToDouble(hThis, argTwo); - nPeriods = HValueToDouble(hThis, argThree); - bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_DOUBLE r = - 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); - FX_DOUBLE nTemp = 1; - for (int32_t i = 0; i < nPeriods; ++i) { - nTemp *= (1 + r); - } - FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; - while ((nRet > FINANCIAL_PRECISION || nRet < -FINANCIAL_PRECISION) && - (!bFlags)) { - FX_DOUBLE nDerivative = 0; - nDerivative = - ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - - (r * nTemp * nPeriods * (nTemp / (1 + r)))) / - ((nTemp - 1) * (nTemp - 1)); - if (nDerivative == 0) { - bFlags = TRUE; - continue; - } - r = r - nRet / nDerivative; - nTemp = 1; - for (int32_t i = 0; i < nPeriods; ++i) { - nTemp *= (1 + r); - } - nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; - } - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - r = r * 12; - FXJSE_Value_SetDouble(args.GetReturnValue(), r); - } - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Apr"); - } -} -void CXFA_FM2JSContext::CTerm(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nRate = 0; - FX_FLOAT nFutureValue = 0; - FX_FLOAT nInitAmount = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nRate = HValueToFloat(hThis, argOne); - nFutureValue = HValueToFloat(hThis, argTwo); - nInitAmount = HValueToFloat(hThis, argThree); - bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FXJSE_Value_SetFloat(args.GetReturnValue(), - FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / - FXSYS_log((FX_FLOAT)(1 + nRate))); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"CTerm"); - } -} -void CXFA_FM2JSContext::FV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_DOUBLE nAmount = 0; - FX_DOUBLE nRate = 0; - FX_DOUBLE nPeriod = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nAmount = HValueToDouble(hThis, argOne); - nRate = HValueToDouble(hThis, argTwo); - nPeriod = HValueToDouble(hThis, argThree); - bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_DOUBLE dResult = 0; - if (!nRate) { - dResult = nAmount * nPeriod; - } else { - FX_DOUBLE nTemp = 1; - for (int i = 0; i < nPeriod; ++i) { - nTemp *= 1 + nRate; - } - dResult = nAmount * (nTemp - 1) / nRate; - } - FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"FV"); - } -} -void CXFA_FM2JSContext::IPmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 5) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nPrincpalAmount = 0; - FX_FLOAT nRate = 0; - FX_FLOAT nPayment = 0; - FX_FLOAT nFirstMonth = 0; - FX_FLOAT nNumberOfMonths = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); - FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || - HValueIsNull(hThis, argFive)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nPrincpalAmount = HValueToFloat(hThis, argOne); - nRate = HValueToFloat(hThis, argTwo); - nPayment = HValueToFloat(hThis, argThree); - nFirstMonth = HValueToFloat(hThis, argFour); - nNumberOfMonths = HValueToFloat(hThis, argFive); - bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || - (nFirstMonth < 0) || (nNumberOfMonths < 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_FLOAT fResult = 0; - FX_FLOAT nRateOfMonth = nRate / 12; - int32_t iNums = - (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - - FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - - nRateOfMonth))) / - FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); - int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); - if (iEnd > iNums) { - iEnd = iNums; - } - FX_FLOAT nSum = 0; - if (nPayment < nPrincpalAmount * nRateOfMonth) { - bFlags = TRUE; - fResult = 0; - } - if (!bFlags) { - int32_t i = 0; - for (i = 0; i < nFirstMonth - 1; ++i) { - nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; - } - for (; i < iEnd; ++i) { - nSum += nPrincpalAmount * nRateOfMonth; - nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; - } - fResult = nSum; - } - FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - FXJSE_Value_Release(argFour); - FXJSE_Value_Release(argFive); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"IPmt"); - } -} -void CXFA_FM2JSContext::NPV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc > 2) { - FX_BOOL bFlags = FALSE; - FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); - for (int32_t i = 0; i < argc; i++) { - argValues[i] = GetSimpleHValue(hThis, args, i); - if (HValueIsNull(hThis, argValues[i])) { - bFlags = TRUE; - } - } - if (!bFlags) { - FX_DOUBLE nRate = 0; - nRate = HValueToDouble(hThis, argValues[0]); - if (nRate <= 0) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); - for (int32_t i = 1; i < argc; i++) { - pData[i - 1] = HValueToDouble(hThis, argValues[i]); - } - FX_DOUBLE nSum = 0; - int32_t iIndex = 0; - for (int32_t i = 0; i < argc - 1; i++) { - FX_DOUBLE nTemp = 1; - for (int32_t j = 0; j <= i; j++) { - nTemp *= 1 + nRate; - } - FX_DOUBLE nNum = *(pData + iIndex++); - nSum += nNum / nTemp; - } - FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); - FX_Free(pData); - pData = 0; - } - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - for (int32_t i = 0; i < argc; i++) { - FXJSE_Value_Release(argValues[i]); - } - FX_Free(argValues); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"NPV"); - } -} -void CXFA_FM2JSContext::Pmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nPrincipal = 0; - FX_FLOAT nRate = 0; - FX_FLOAT nPeriods = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nPrincipal = HValueToFloat(hThis, argOne); - nRate = HValueToFloat(hThis, argTwo); - nPeriods = HValueToFloat(hThis, argThree); - bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_FLOAT nSum = 0; - FX_FLOAT nTmp = 1 + nRate; - nSum = nTmp; - for (int32_t i = 0; i < nPeriods - 1; ++i) { - nSum *= nTmp; - } - FXJSE_Value_SetFloat(args.GetReturnValue(), - (nPrincipal * nRate * nSum) / (nSum - 1)); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Pmt"); - } -} -void CXFA_FM2JSContext::PPmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 5) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nPrincpalAmount = 0; - FX_FLOAT nRate = 0; - FX_FLOAT nPayment = 0; - FX_FLOAT nFirstMonth = 0; - FX_FLOAT nNumberOfMonths = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - FXJSE_HVALUE argFour = GetSimpleHValue(hThis, args, 3); - FXJSE_HVALUE argFive = GetSimpleHValue(hThis, args, 4); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree) || HValueIsNull(hThis, argFour) || - HValueIsNull(hThis, argFive)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nPrincpalAmount = HValueToFloat(hThis, argOne); - nRate = HValueToFloat(hThis, argTwo); - nPayment = HValueToFloat(hThis, argThree); - nFirstMonth = HValueToFloat(hThis, argFour); - nNumberOfMonths = HValueToFloat(hThis, argFive); - bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || - (nFirstMonth < 0) || (nNumberOfMonths < 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); - FX_FLOAT nSum = 0; - FX_FLOAT nRateOfMonth = nRate / 12; - int32_t iNums = - (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - - FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - - nRateOfMonth))) / - FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); - if (iEnd > iNums) { - iEnd = iNums; - } - if (nPayment < nPrincpalAmount * nRateOfMonth) { - bFlags = TRUE; - } - if (!bFlags) { - int32_t i = 0; - for (i = 0; i < nFirstMonth - 1; ++i) { - nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; - } - FX_FLOAT nTemp = 0; - for (; i < iEnd; ++i) { - nTemp = nPayment - nPrincpalAmount * nRateOfMonth; - nSum += nTemp; - nPrincpalAmount -= nTemp; - } - FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - FXJSE_Value_Release(argFour); - FXJSE_Value_Release(argFive); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"PPmt"); - } -} -void CXFA_FM2JSContext::PV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_DOUBLE nAmount = 0; - FX_DOUBLE nRate = 0; - FX_DOUBLE nPeriod = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nAmount = HValueToDouble(hThis, argOne); - nRate = HValueToDouble(hThis, argTwo); - nPeriod = HValueToDouble(hThis, argThree); - bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FX_DOUBLE nTemp = 1; - for (int32_t i = 0; i < nPeriod; ++i) { - nTemp *= 1 + nRate; - } - nTemp = 1 / nTemp; - FXJSE_Value_SetDouble(args.GetReturnValue(), - nAmount * ((1 - nTemp) / nRate)); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"PV"); - } -} -void CXFA_FM2JSContext::Rate(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nFuture = 0; - FX_FLOAT nPresent = 0; - FX_FLOAT nTotalNumber = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo) || - HValueIsNull(hThis, argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nFuture = HValueToFloat(hThis, argOne); - nPresent = HValueToFloat(hThis, argTwo); - nTotalNumber = HValueToFloat(hThis, argThree); - bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FXJSE_Value_SetFloat(args.GetReturnValue(), - (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), - (FX_FLOAT)(1 / nTotalNumber)) - - 1)); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Rate"); - } -} -void CXFA_FM2JSContext::Term(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 3) { - FX_BOOL bFlags = FALSE; - FX_FLOAT nMount = 0; - FX_FLOAT nRate = 0; - FX_FLOAT nFuture = 0; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = GetSimpleHValue(hThis, args, 2); - bFlags = (FXJSE_Value_IsNull(argOne) || FXJSE_Value_IsNull(argTwo) || - FXJSE_Value_IsNull(argThree)); - if (bFlags) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - nMount = HValueToFloat(hThis, argOne); - nRate = HValueToFloat(hThis, argTwo); - nFuture = HValueToFloat(hThis, argThree); - bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); - if (bFlags) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - FXJSE_Value_SetFloat( - args.GetReturnValue(), - (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / - FXSYS_log((FX_FLOAT)(1 + nRate)))); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - FXJSE_Value_Release(argThree); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Term"); - } -} -void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - if (argc > 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - FX_BOOL argOneIsNull = FALSE; - int32_t iIndex = 0; - argOneIsNull = HValueIsNull(hThis, argOne); - if (!argOneIsNull) { - iIndex = (int32_t)HValueToFloat(hThis, argOne); - } - FXJSE_Value_Release(argOne); - if (argOneIsNull) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else if (iIndex < 1) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } else { - FX_BOOL bFound = FALSE; - FX_BOOL bStopCounterFlags = FALSE; - int32_t iArgIndex = 1; - int32_t iValueIndex = 0; - while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { - FXJSE_HVALUE argIndexValue = args.GetValue(iArgIndex); - if (FXJSE_Value_IsArray(argIndexValue)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argIndexValue, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 3) { - bStopCounterFlags = TRUE; - } - iValueIndex += (iLength - 2); - if (iValueIndex >= iIndex) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argIndexValue, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx( - argIndexValue, ((iLength - 1) - (iValueIndex - iIndex)), - jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, newProperty); - } else { - CFX_ByteString propStr; - FXJSE_Value_ToUTF8String(propertyValue, propStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propStr, newProperty); - } - CFX_ByteString bsChoosed; - HValueToUTF8String(newProperty, bsChoosed); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed); - FXJSE_Value_Release(newProperty); - FXJSE_Value_Release(jsobjectValue); - FXJSE_Value_Release(propertyValue); - bFound = TRUE; - } - } else { - iValueIndex++; - if (iValueIndex == iIndex) { - CFX_ByteString bsChoosed; - HValueToUTF8String(argIndexValue, bsChoosed); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed); - bFound = TRUE; - } - } - FXJSE_Value_Release(argIndexValue); - iArgIndex++; - } - if (!bFound) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Choose"); - } -} -void CXFA_FM2JSContext::Exists(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - FXJSE_Value_SetInteger(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Exists"); - } -} -void CXFA_FM2JSContext::HasValue(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsUTF8String(argOne)) { - CFX_ByteString valueStr; - FXJSE_Value_ToUTF8String(argOne, valueStr); - valueStr.TrimLeft(); - FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); - } else if (FXJSE_Value_IsNumber(argOne) || FXJSE_Value_IsBoolean(argOne)) { - FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); - } else { - FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"HasValue"); - } -} -void CXFA_FM2JSContext::Oneof(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc > 1) { - FX_BOOL bFlags = FALSE; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE* parametersValue = 0; - int32_t iCount = 0; - unfoldArgs(hThis, args, parametersValue, iCount, 1); - for (int32_t i = 0; i < iCount; i++) { - if (simpleValueCompare(hThis, argOne, parametersValue[i])) { - bFlags = TRUE; - break; - } - } - FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); - FXJSE_Value_Release(argOne); - for (int32_t i = 0; i < iCount; i++) { - FXJSE_Value_Release(parametersValue[i]); - } - FX_Free(parametersValue); - parametersValue = 0; - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Oneof"); - } -} -void CXFA_FM2JSContext::Within(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc == 3) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetUndefined(args.GetReturnValue()); - } else { - FXJSE_HVALUE argLow = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argHeight = GetSimpleHValue(hThis, args, 2); - if (FXJSE_Value_IsNumber(argOne)) { - FX_FLOAT oneNumber = HValueToFloat(hThis, argOne); - FX_FLOAT lowNumber = HValueToFloat(hThis, argLow); - FX_FLOAT heightNumber = HValueToFloat(hThis, argHeight); - FXJSE_Value_SetInteger( - args.GetReturnValue(), - ((oneNumber >= lowNumber) && (oneNumber <= heightNumber))); - } else { - CFX_ByteString oneString; - CFX_ByteString lowString; - CFX_ByteString heightString; - HValueToUTF8String(argOne, oneString); - HValueToUTF8String(argLow, lowString); - HValueToUTF8String(argHeight, heightString); - FXJSE_Value_SetInteger(args.GetReturnValue(), - ((oneString.Compare(lowString) >= 0) && - (oneString.Compare(heightString) <= 0))); - } - FXJSE_Value_Release(argLow); - FXJSE_Value_Release(argHeight); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Within"); - } -} -void CXFA_FM2JSContext::If(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 3) { - FXJSE_HVALUE argCondition = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argFirstValue = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argSecondValue = GetSimpleHValue(hThis, args, 2); - FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition); - FXJSE_Value_Set(args.GetReturnValue(), - bCondition ? argFirstValue : argSecondValue); - FXJSE_Value_Release(argSecondValue); - FXJSE_Value_Release(argFirstValue); - FXJSE_Value_Release(argCondition); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"If"); - } -} -void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - if (args.GetLength() == 1) { - FXJSE_HVALUE scriptValue = GetSimpleHValue(hThis, args, 0); - CFX_ByteString utf8ScriptString; - HValueToUTF8String(scriptValue, utf8ScriptString); - if (utf8ScriptString.IsEmpty()) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_WideTextBuf wsJavaScriptBuf; - CFX_WideString javaScript; - CFX_WideString wsError; - XFA_FM2JS_Translate(CFX_WideString::FromUTF8( - utf8ScriptString, utf8ScriptString.GetLength()), - 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); - FXJSE_Value_Set(args.GetReturnValue(), returnValue); - FXJSE_Value_Release(returnValue); - FXJSE_Context_Release(hContext); - } - FXJSE_Value_Release(scriptValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Eval"); - } -} -void CXFA_FM2JSContext::Ref(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_HVALUE rgValues[3]; - for (int32_t i = 0; i < 3; i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 4); - FXJSE_Value_SetNull(rgValues[1]); - FXJSE_Value_SetNull(rgValues[2]); - FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); - for (int32_t i = 0; i < 3; i++) { - FXJSE_Value_Release(rgValues[i]); - } - } else if (FXJSE_Value_IsArray(argOne)) { -#ifndef NDEBUG - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); - FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); - FXJSE_Value_Release(lengthValue); -#endif - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsObjectValue); - if (FXJSE_Value_IsNull(jsObjectValue)) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else if (FXJSE_Value_IsNull(propertyValue) && - (!FXJSE_Value_IsNull(jsObjectValue))) { - FXJSE_HVALUE rgValues[3]; - for (int32_t i = 0; i < 3; i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 3); - FXJSE_Value_SetNull(rgValues[1]); - FXJSE_Value_Set(rgValues[2], jsObjectValue); - FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); - for (int32_t i = 0; i < 3; i++) { - FXJSE_Value_Release(rgValues[i]); - } - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(propertyValue); - } else if (FXJSE_Value_IsObject(argOne)) { - FXJSE_HVALUE rgValues[3]; - for (int32_t i = 0; i < 3; i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 3); - FXJSE_Value_SetNull(rgValues[1]); - FXJSE_Value_Set(rgValues[2], argOne); - FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); - for (int32_t i = 0; i < 3; i++) { - FXJSE_Value_Release(rgValues[i]); - } - } else if (FXJSE_Value_IsBoolean(argOne) || - FXJSE_Value_IsUTF8String(argOne) || - FXJSE_Value_IsNumber(argOne)) { - FXJSE_Value_Set(args.GetReturnValue(), argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Ref"); - } -} -void CXFA_FM2JSContext::UnitType(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 1) { - FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(unitspanValue)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - FXJSE_Value_Release(unitspanValue); - return; - } - CFX_ByteString unitspanString; - HValueToUTF8String(unitspanValue, unitspanString); - if (unitspanString.IsEmpty()) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); - } else { - enum XFA_FM2JS_VALUETYPE_ParserStatus { - VALUETYPE_START, - VALUETYPE_HAVEINVALIDCHAR, - VALUETYPE_HAVEDIGIT, - VALUETYPE_HAVEDIGITWHITE, - VALUETYPE_ISCM, - VALUETYPE_ISMM, - VALUETYPE_ISPT, - VALUETYPE_ISMP, - VALUETYPE_ISIN, - }; - unitspanString.MakeLower(); - CFX_WideString wsTypeString = - CFX_WideString::FromUTF8(unitspanString, unitspanString.GetLength()); - const FX_WCHAR* pData = wsTypeString; - int32_t u = 0; - int32_t uLen = wsTypeString.GetLength(); - while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - u++; - } - XFA_FM2JS_VALUETYPE_ParserStatus eParserStatus = VALUETYPE_START; - FX_WCHAR typeChar; - while (u < uLen) { - typeChar = *(pData + u); - if (typeChar == 0x20 || typeChar == 0x09 || typeChar == 0x0B || - typeChar == 0x0C || typeChar == 0x0A || typeChar == 0x0D) { - if (eParserStatus == VALUETYPE_HAVEDIGIT || - eParserStatus == VALUETYPE_HAVEDIGITWHITE) { - eParserStatus = VALUETYPE_HAVEDIGITWHITE; - } else { - eParserStatus = VALUETYPE_ISIN; - break; - } - } else if ((typeChar >= '0' && typeChar <= '9') || typeChar == '-' || - typeChar == '.') { - if (eParserStatus == VALUETYPE_HAVEDIGITWHITE) { - eParserStatus = VALUETYPE_ISIN; - break; - } else { - eParserStatus = VALUETYPE_HAVEDIGIT; - } - } else if ((typeChar == 'c' || typeChar == 'p') && (u + 1 < uLen)) { - FX_WCHAR nextChar = *(pData + u + 1); - if ((eParserStatus == VALUETYPE_START || - eParserStatus == VALUETYPE_HAVEDIGIT || - eParserStatus == VALUETYPE_HAVEDIGITWHITE) && - (nextChar > '9' || nextChar < '0') && nextChar != '.' && - nextChar != '-') { - eParserStatus = (typeChar == 'c') ? VALUETYPE_ISCM : VALUETYPE_ISPT; - break; - } else { - eParserStatus = VALUETYPE_HAVEINVALIDCHAR; - } - } else if (typeChar == 'm' && (u + 1 < uLen)) { - FX_WCHAR nextChar = *(pData + u + 1); - if ((eParserStatus == VALUETYPE_START || - eParserStatus == VALUETYPE_HAVEDIGIT || - eParserStatus == VALUETYPE_HAVEDIGITWHITE) && - (nextChar > '9' || nextChar < '0') && nextChar != '.' && - nextChar != '-') { - eParserStatus = VALUETYPE_ISMM; - if (nextChar == 'p' || - ((u + 5 < uLen) && *(pData + u + 1) == 'i' && - *(pData + u + 2) == 'l' && *(pData + u + 3) == 'l' && - *(pData + u + 4) == 'i' && *(pData + u + 5) == 'p')) { - eParserStatus = VALUETYPE_ISMP; - } - break; - } - } else { - eParserStatus = VALUETYPE_HAVEINVALIDCHAR; - } - u++; - } - switch (eParserStatus) { - case VALUETYPE_ISCM: - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "cm"); - break; - case VALUETYPE_ISMM: - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mm"); - break; - case VALUETYPE_ISPT: - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "pt"); - break; - case VALUETYPE_ISMP: - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); - break; - default: - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); - break; - } - } - FXJSE_Value_Release(unitspanValue); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"UnitType"); - } -} -void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc == 1) || (argc == 2)) { - FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE unitValue = 0; - CFX_ByteString unitspanString; - FX_DOUBLE dFirstNumber = 0; - CFX_ByteString strFirstUnit; - CFX_ByteString strUnit; - if (FXJSE_Value_IsNull(unitspanValue)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - HValueToUTF8String(unitspanValue, unitspanString); - const FX_CHAR* pData = unitspanString; - if (pData) { - int32_t u = 0; - while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; - } - while (u < unitspanString.GetLength()) { - if ((*(pData + u) > '9' || *(pData + u) < '0') && - *(pData + u) != '.' && *(pData + u) != '-') { - break; - } - ++u; - } - FX_CHAR* pTemp = NULL; - dFirstNumber = strtod(pData, &pTemp); - while (*(pData + u) == ' ' || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; - } - int32_t uLen = unitspanString.GetLength(); - while (u < uLen) { - if (*(pData + u) == ' ') { - break; - } - strFirstUnit += (*(pData + u)); - ++u; - } - strFirstUnit.MakeLower(); - if (argc == 2) { - unitValue = GetSimpleHValue(hThis, args, 1); - CFX_ByteString unitTempString; - HValueToUTF8String(unitValue, unitTempString); - const FX_CHAR* pData = unitTempString; - int32_t u = 0; - while (*(pData + u) == ' ' || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; - } - while (u < unitTempString.GetLength()) { - if ((*(pData + u) > '9' || *(pData + u) < '0') && - *(pData + u) != '.') { - break; - } - ++u; - } - while (*(pData + u) == ' ' || *(pData + u) == 0x09 || - *(pData + u) == 0x0B || *(pData + u) == 0x0C || - *(pData + u) == 0x0A || *(pData + u) == 0x0D) { - ++u; - } - int32_t uLen = unitTempString.GetLength(); - while (u < uLen) { - if (*(pData + u) == ' ') { - break; - } - strUnit += (*(pData + u)); - ++u; - } - strUnit.MakeLower(); - } else { - strUnit = strFirstUnit; - } - FX_DOUBLE dResult = 0; - if (strFirstUnit.Equal("in") || strFirstUnit.Equal("inches")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { - dResult = dFirstNumber * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { - dResult = dFirstNumber * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { - dResult = dFirstNumber / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { - dResult = dFirstNumber / 72000; - } else { - dResult = dFirstNumber; - } - } else if (strFirstUnit.Equal("mm") || - strFirstUnit.Equal("millimeters")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { - dResult = dFirstNumber; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { - dResult = dFirstNumber / 10; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { - dResult = dFirstNumber / 25.4 / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { - dResult = dFirstNumber / 25.4 / 72000; - } else { - dResult = dFirstNumber / 25.4; - } - } else if (strFirstUnit.Equal("cm") || - strFirstUnit.Equal("centimeters")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { - dResult = dFirstNumber * 10; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { - dResult = dFirstNumber; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { - dResult = dFirstNumber / 2.54 / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { - dResult = dFirstNumber / 2.54 / 72000; - } else { - dResult = dFirstNumber / 2.54; - } - } else if (strFirstUnit.Equal("pt") || strFirstUnit.Equal("points")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { - dResult = dFirstNumber / 72 * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { - dResult = dFirstNumber / 72 * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { - dResult = dFirstNumber; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { - dResult = dFirstNumber * 1000; - } else { - dResult = dFirstNumber / 72; - } - } else if (strFirstUnit.Equal("mp") || - strFirstUnit.Equal("millipoints")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { - dResult = dFirstNumber / 72000 * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { - dResult = dFirstNumber / 72000 * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { - dResult = dFirstNumber / 1000; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { - dResult = dFirstNumber; - } else { - dResult = dFirstNumber / 72000; - } - } - FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); - } else { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } - } - FXJSE_Value_Release(unitspanValue); - if (argc == 2) { - FXJSE_Value_Release(unitValue); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"UnitValue"); - } -} -void CXFA_FM2JSContext::At(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString stringTwo; - HValueToUTF8String(argTwo, stringTwo); - if (stringTwo.IsEmpty()) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 1); - } else { - CFX_ByteString stringOne; - HValueToUTF8String(argOne, stringOne); - FX_STRSIZE iPosition = stringOne.Find(stringTwo); - FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"At"); - } -} -void CXFA_FM2JSContext::Concat(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc >= 1) { - CFX_ByteString resultString; - FX_BOOL bAllNull = TRUE; - FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argc); - for (int32_t i = 0; i < argc; i++) { - argValues[i] = GetSimpleHValue(hThis, args, i); - if (!HValueIsNull(hThis, argValues[i])) { - CFX_ByteString valueStr; - HValueToUTF8String(argValues[i], valueStr); - resultString += valueStr; - bAllNull = FALSE; - } - } - for (int32_t i = 0; i < argc; i++) { - FXJSE_Value_Release(argValues[i]); - } - FX_Free(argValues); - if (bAllNull) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString); - } - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Concat"); - } -} -void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString toDecodeString; - HValueToUTF8String(argOne, toDecodeString); - CFX_ByteTextBuf resultBuf; - DecodeURL(toDecodeString, resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } - FXJSE_Value_Release(argOne); - } else if (argc == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString toDecodeString; - HValueToUTF8String(argOne, toDecodeString); - CFX_ByteString identifyString; - HValueToUTF8String(argTwo, identifyString); - CFX_ByteTextBuf resultBuf; - if (identifyString.EqualNoCase("html")) { - DecodeHTML(toDecodeString, resultBuf); - } else if (identifyString.EqualNoCase("xml")) { - DecodeXML(toDecodeString, resultBuf); - } else { - DecodeURL(toDecodeString, resultBuf); - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Decode"); - } -} -void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, - CFX_ByteTextBuf& szResultString) { - CFX_WideString wsURLString = - CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); - const FX_WCHAR* pData = wsURLString; - int32_t iLen = wsURLString.GetLength(); - int32_t i = 0; - FX_WCHAR ch = 0; - FX_WCHAR chTemp = 0; - CFX_WideTextBuf wsResultBuf; - while (i < iLen) { - ch = *(pData + i); - if ('%' == ch) { - chTemp = 0; - int32_t iCount = 0; - while (iCount < 2) { - ++i; - ch = *(pData + i); - if (ch <= '9' && ch >= '0') { - if (!iCount) { - chTemp += (ch - '0') * 16; - } else { - chTemp += (ch - '0'); - } - } else { - if (ch <= 'F' && ch >= 'A') { - if (!iCount) { - chTemp += (ch - 'A' + 10) * 16; - } else { - chTemp += (ch - 'A' + 10); - } - } else if (ch <= 'f' && ch >= 'a') { - if (!iCount) { - chTemp += (ch - 'a' + 10) * 16; - } else { - chTemp += (ch - 'a' + 10); - } - } else { - wsResultBuf.Clear(); - return; - } - } - ++iCount; - } - wsResultBuf.AppendChar(chTemp); - } else { - wsResultBuf.AppendChar(ch); - } - ++i; - } - wsResultBuf.AppendChar(0); - szResultString.Clear(); - szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()); -} -void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, - CFX_ByteTextBuf& szResultString) { - CFX_WideString wsHTMLString = CFX_WideString::FromUTF8( - szHTMLString.GetCStr(), szHTMLString.GetLength()); - 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; - CFX_WideTextBuf wsResultBuf; - while (i < iLen) { - ch = *(pData + i); - if (ch == '&') { - ++i; - ch = *(pData + i); - if (ch == '#') { - ++i; - ch = *(pData + i); - if (ch == 'x' || ch == 'X') { - ++i; - ch = *(pData + i); - if ((ch >= '0' && ch <= '9') || (ch <= 'f' && ch >= 'a') || - (ch <= 'F' && ch >= 'A')) { - while (ch != ';' && i < iLen) { - if (ch >= '0' && ch <= '9') { - iCode += ch - '0'; - } else if (ch <= 'f' && ch >= 'a') { - iCode += ch - 'a' + 10; - } else if (ch <= 'F' && ch >= 'A') { - iCode += ch - 'A' + 10; - } else { - wsResultBuf.Clear(); - return; - } - ++i; - iCode *= 16; - ch = *(pData + i); - } - iCode /= 16; - } - } else { - wsResultBuf.Clear(); - return; - } - } else { - while (ch != ';' && i < iLen) { - strString[iStrIndex++] = ch; - ++i; - ch = *(pData + i); - } - strString[iStrIndex] = 0; - } - } else { - wsResultBuf.AppendChar(ch); - ++i; - continue; - } - uint32_t iData = 0; - if (HTMLSTR2Code(strString, iData)) { - wsResultBuf.AppendChar((FX_WCHAR)iData); - } else { - wsResultBuf.AppendChar(iCode); - } - iStrIndex = 0; - strString[iStrIndex] = 0; - ++i; - } - wsResultBuf.AppendChar(0); - szResultString.Clear(); - szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()); -} -void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, - CFX_ByteTextBuf& szResultString) { - CFX_WideString wsXMLString = - CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); - 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; - CFX_WideTextBuf wsXMLBuf; - while (i < iLen) { - ch = *(pData + i); - if (ch == '&') { - ++i; - ch = *(pData + i); - if (ch == '#') { - ++i; - ch = *(pData + i); - if (ch == 'x' || ch == 'X') { - ++i; - ch = *(pData + i); - if ((ch >= '0' && ch <= '9') || (ch <= 'f' && ch >= 'a') || - (ch <= 'F' && ch >= 'A')) { - while (ch != ';') { - if (ch >= '0' && ch <= '9') { - iCode += ch - '0'; - } else if (ch <= 'f' && ch >= 'a') { - iCode += ch - 'a' + 10; - } else if (ch <= 'F' && ch >= 'A') { - iCode += ch - 'A' + 10; - } else { - wsXMLBuf.Clear(); - return; - } - ++i; - iCode *= 16; - ch = *(pData + i); - } - iCode /= 16; - } - } else { - wsXMLBuf.Clear(); - return; - } - } else { - while (ch != ';' && i < iLen) { - strString[iStrIndex++] = ch; - ++i; - ch = *(pData + i); - } - strString[iStrIndex] = 0; - } - } else { - wsXMLBuf.AppendChar(ch); - ++i; - continue; - } - const FX_WCHAR* const strName[] = {L"quot", L"amp", L"apos", L"lt", L"gt"}; - int32_t iIndex = 0; - while (iIndex < 5) { - if (FXSYS_memcmp(strString, strName[iIndex], - FXSYS_wcslen(strName[iIndex])) == 0) { - break; - } - ++iIndex; - } - switch (iIndex) { - case 0: - wsXMLBuf.AppendChar('"'); - break; - case 1: - wsXMLBuf.AppendChar('&'); - break; - case 2: - wsXMLBuf.AppendChar('\''); - break; - case 3: - wsXMLBuf.AppendChar('<'); - break; - case 4: - wsXMLBuf.AppendChar('>'); - break; - default: - wsXMLBuf.AppendChar(iCode); - break; - } - iStrIndex = 0; - strString[iStrIndex] = 0; - ++i; - iCode = 0; - } - wsXMLBuf.AppendChar(0); - szResultString.Clear(); - szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()); -} -void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString toEncodeString; - HValueToUTF8String(argOne, toEncodeString); - CFX_ByteTextBuf resultBuf; - EncodeURL(toEncodeString, resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } - FXJSE_Value_Release(argOne); - } else if (argc == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, argOne) || HValueIsNull(hThis, argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString toEncodeString; - HValueToUTF8String(argOne, toEncodeString); - CFX_ByteString identifyString; - HValueToUTF8String(argTwo, identifyString); - CFX_ByteTextBuf resultBuf; - if (identifyString.EqualNoCase("html")) { - EncodeHTML(toEncodeString, resultBuf); - } else if (identifyString.EqualNoCase("xml")) { - EncodeXML(toEncodeString, resultBuf); - } else { - EncodeURL(toEncodeString, resultBuf); - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Encode"); - } -} -void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, - CFX_ByteTextBuf& szResultBuf) { - CFX_WideString wsURLString = - CFX_WideString::FromUTF8(szURLString.GetCStr(), szURLString.GetLength()); - CFX_WideTextBuf wsResultBuf; - FX_WCHAR ch = 0; - int32_t iLength = wsURLString.GetLength(); - FX_WCHAR strEncode[4]; - strEncode[0] = '%'; - strEncode[3] = 0; - FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', - '|', '\\', '^', '~', '[', ']', '`'}; - FX_WCHAR strReserved[] = {';', '/', '?', ':', '@', '=', '&'}; - FX_WCHAR strSpecial[] = {'$', '-', '+', '!', '*', '\'', '(', ')', ','}; - const FX_WCHAR* strCode = L"0123456789abcdef"; - for (int32_t u = 0; u < iLength; ++u) { - ch = wsURLString.GetAt(u); - int32_t i = 0; - int32_t iCount = sizeof(strUnsafe) / sizeof(strUnsafe[0]); - while (i < iCount) { - if (ch == strUnsafe[i]) { - int32_t iIndex = ch / 16; - strEncode[1] = strCode[iIndex]; - strEncode[2] = strCode[ch - iIndex * 16]; - wsResultBuf << FX_WSTRC(strEncode); - break; - } - ++i; - } - if (i < iCount) { - continue; - } - i = 0; - iCount = sizeof(strReserved) / sizeof(strReserved[0]); - while (i < iCount) { - if (ch == strReserved[i]) { - int32_t iIndex = ch / 16; - strEncode[1] = strCode[iIndex]; - strEncode[2] = strCode[ch - iIndex * 16]; - wsResultBuf << FX_WSTRC(strEncode); - break; - } - ++i; - } - if (i < iCount) { - continue; - } - i = 0; - iCount = sizeof(strSpecial) / sizeof(strSpecial[0]); - while (i < iCount) { - if (ch == strSpecial[i]) { - wsResultBuf.AppendChar(ch); - break; - } - ++i; - } - if (i < iCount) { - continue; - } - if (ch >= 0x80 && ch <= 0xff) { - int32_t iIndex = ch / 16; - strEncode[1] = strCode[iIndex]; - strEncode[2] = strCode[ch - iIndex * 16]; - wsResultBuf << FX_WSTRC(strEncode); - } else if (ch <= 0x1f || ch == 0x7f) { - int32_t iIndex = ch / 16; - strEncode[1] = strCode[iIndex]; - strEncode[2] = strCode[ch - iIndex * 16]; - wsResultBuf << FX_WSTRC(strEncode); - } else if (ch >= 0x20 && ch <= 0x7e) { - wsResultBuf.AppendChar(ch); - } else { - int32_t iRadix = 16; - CFX_WideString strTmp; - while (ch >= iRadix) { - FX_WCHAR tmp = strCode[ch % iRadix]; - ch /= iRadix; - strTmp += tmp; - } - strTmp += strCode[ch]; - int32_t iLen = strTmp.GetLength(); - if (iLen < 2) { - break; - } - int32_t iIndex = 0; - if (iLen % 2 != 0) { - strEncode[1] = '0'; - strEncode[2] = strTmp.GetAt(iLen - 1); - iIndex = iLen - 2; - } else { - strEncode[1] = strTmp.GetAt(iLen - 1); - strEncode[2] = strTmp.GetAt(iLen - 2); - iIndex = iLen - 3; - } - wsResultBuf << FX_WSTRC(strEncode); - while (iIndex > 0) { - strEncode[1] = strTmp.GetAt(iIndex); - strEncode[2] = strTmp.GetAt(iIndex - 1); - iIndex -= 2; - wsResultBuf << FX_WSTRC(strEncode); - } - } - } - wsResultBuf.AppendChar(0); - szResultBuf.Clear(); - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()); -} -void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, - CFX_ByteTextBuf& szResultBuf) { - CFX_ByteString str = szHTMLString.GetCStr(); - CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength()); - const FX_WCHAR* strCode = L"0123456789abcdef"; - FX_WCHAR strEncode[9]; - strEncode[0] = '&'; - strEncode[1] = '#'; - strEncode[2] = 'x'; - strEncode[5] = ';'; - strEncode[6] = 0; - strEncode[7] = ';'; - strEncode[8] = 0; - CFX_WideTextBuf wsResultBuf; - uint32_t ch = 0; - int32_t iLen = wsHTMLString.GetLength(); - int32_t i = 0; - const FX_WCHAR* pData = wsHTMLString; - int32_t iIndex = 0; - CFX_WideString htmlReserve; - while (i < iLen) { - ch = *(pData + i); - htmlReserve.Empty(); - if (HTMLCode2STR(ch, htmlReserve)) { - wsResultBuf.AppendChar(L'&'); - wsResultBuf << htmlReserve; - wsResultBuf.AppendChar(L';'); - } else { - if (ch >= 32 && ch <= 126) { - wsResultBuf.AppendChar((FX_WCHAR)ch); - } else if (ch < 256) { - iIndex = ch / 16; - strEncode[3] = strCode[iIndex]; - strEncode[4] = strCode[ch - iIndex * 16]; - strEncode[5] = ';'; - strEncode[6] = 0; - wsResultBuf << FX_WSTRC(strEncode); - } else { - int32_t iBigByte = ch / 256; - int32_t iLittleByte = ch % 256; - strEncode[3] = strCode[iBigByte / 16]; - strEncode[4] = strCode[iBigByte % 16]; - strEncode[5] = strCode[iLittleByte / 16]; - strEncode[6] = strCode[iLittleByte % 16]; - wsResultBuf << FX_WSTRC(strEncode); - } - } - ++i; - } - wsResultBuf.AppendChar(0); - szResultBuf.Clear(); - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()); -} -void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, - CFX_ByteTextBuf& szResultBuf) { - CFX_WideString wsXMLString = - CFX_WideString::FromUTF8(szXMLString.GetCStr(), szXMLString.GetLength()); - CFX_WideTextBuf wsResultBuf; - enum { - QUOT, - AMP, - APOS, - LT, - GT, - }; - FX_WCHAR strEncode[9]; - strEncode[0] = '&'; - strEncode[1] = '#'; - strEncode[2] = 'x'; - strEncode[5] = ';'; - strEncode[6] = 0; - strEncode[7] = ';'; - strEncode[8] = 0; - const FX_WCHAR* const strName[] = {L"quot", L"amp", L"apos", L"lt", L"gt"}; - const FX_WCHAR* strCode = L"0123456789abcdef"; - FX_WCHAR ch = 0; - int32_t iLength = wsXMLString.GetLength(); - int32_t iIndex = 0; - int32_t u = 0; - const FX_WCHAR* pData = wsXMLString; - for (u = 0; u < iLength; ++u) { - ch = *(pData + u); - switch (ch) { - case '"': - wsResultBuf.AppendChar('&'); - wsResultBuf << CFX_WideStringC(strName[QUOT]); - wsResultBuf.AppendChar(';'); - break; - case '&': - wsResultBuf.AppendChar('&'); - wsResultBuf << CFX_WideStringC(strName[AMP]); - wsResultBuf.AppendChar(';'); - break; - case '\'': - wsResultBuf.AppendChar('&'); - wsResultBuf << CFX_WideStringC(strName[APOS]); - wsResultBuf.AppendChar(';'); - break; - case '<': - wsResultBuf.AppendChar('&'); - wsResultBuf << CFX_WideStringC(strName[LT]); - wsResultBuf.AppendChar(';'); - break; - case '>': - wsResultBuf.AppendChar('&'); - wsResultBuf << CFX_WideStringC(strName[GT]); - wsResultBuf.AppendChar(';'); - break; - default: { - if (ch >= 32 && ch <= 126) { - wsResultBuf.AppendChar(ch); - } else if (ch < 256) { - iIndex = ch / 16; - strEncode[3] = strCode[iIndex]; - strEncode[4] = strCode[ch - iIndex * 16]; - strEncode[5] = ';'; - strEncode[6] = 0; - wsResultBuf << FX_WSTRC(strEncode); - } else { - int32_t iBigByte = ch / 256; - int32_t iLittleByte = ch % 256; - strEncode[3] = strCode[iBigByte / 16]; - strEncode[4] = strCode[iBigByte % 16]; - strEncode[5] = strCode[iLittleByte / 16]; - strEncode[6] = strCode[iLittleByte % 16]; - wsResultBuf << FX_WSTRC(strEncode); - } - } break; - } - } - wsResultBuf.AppendChar(0); - szResultBuf.Clear(); - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()); -} -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.GetPtr(), iLength); - XFA_FMHtmlHashedReserveCode htmlhashedreservecode; - int32_t iStart = 0, - iEnd = (sizeof(reservesForDecode) / sizeof(reservesForDecode[0])) - 1; - int32_t iMid = (iStart + iEnd) / 2; - do { - iMid = (iStart + iEnd) / 2; - htmlhashedreservecode = reservesForDecode[iMid]; - if (uHash == htmlhashedreservecode.m_uHash) { - iCode = htmlhashedreservecode.m_uCode; - return TRUE; - } else if (uHash < htmlhashedreservecode.m_uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return FALSE; -} -FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, - CFX_WideString& wsHTMLReserve) { - XFA_FMHtmlReserveCode htmlreservecode; - int32_t iStart = 0, - iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; - int32_t iMid = (iStart + iEnd) / 2; - do { - iMid = (iStart + iEnd) / 2; - htmlreservecode = reservesForEncode[iMid]; - if (iCode == htmlreservecode.m_uCode) { - wsHTMLReserve = htmlreservecode.m_htmlReserve; - return TRUE; - } else if (iCode < htmlreservecode.m_uCode) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return FALSE; -} -static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, - FX_DWORD& patternType) { - CFX_WideString wsPattern = - CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); - if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { - patternType = XFA_VT_DATETIME; - return TRUE; - } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { - patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; - return TRUE; - } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { - patternType = XFA_VT_TIME; - return TRUE; - } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { - patternType = XFA_VT_TEXT; - return TRUE; - } else if (FX_WSTRC(L"num") == wsPattern.Left(3)) { - if (FX_WSTRC(L"integer") == wsPattern.Mid(4, 7)) { - patternType = XFA_VT_INTEGER; - } else if (FX_WSTRC(L"decimal") == wsPattern.Mid(4, 7)) { - patternType = XFA_VT_DECIMAL; - } else if (FX_WSTRC(L"currency") == wsPattern.Mid(4, 8)) { - patternType = XFA_VT_FLOAT; - } else if (FX_WSTRC(L"percent") == wsPattern.Mid(4, 7)) { - patternType = XFA_VT_FLOAT; - } else { - patternType = XFA_VT_FLOAT; - } - return TRUE; - } - patternType = XFA_VT_NULL; - wsPattern.MakeLower(); - const FX_WCHAR* pData = wsPattern; - int32_t iLength = wsPattern.GetLength(); - int32_t iIndex = 0; - FX_BOOL bSingleQuotation = FALSE; - FX_WCHAR patternChar; - while (iIndex < iLength) { - patternChar = *(pData + iIndex); - if (patternChar == 0x27) { - bSingleQuotation = !bSingleQuotation; - } else if (!bSingleQuotation && - (patternChar == 'y' || patternChar == 'j')) { - patternType = XFA_VT_DATE; - iIndex++; - FX_WCHAR timePatternChar; - while (iIndex < iLength) { - timePatternChar = *(pData + iIndex); - if (timePatternChar == 0x27) { - bSingleQuotation = !bSingleQuotation; - } else if (!bSingleQuotation && timePatternChar == 't') { - patternType = XFA_VT_DATETIME; - break; - } - iIndex++; - } - break; - } else if (!bSingleQuotation && - (patternChar == 'h' || patternChar == 'k')) { - patternType = XFA_VT_TIME; - break; - } else if (!bSingleQuotation && - (patternChar == 'a' || patternChar == 'x' || - patternChar == 'o' || patternChar == '0')) { - patternType = XFA_VT_TEXT; - if (patternChar == 'x' || patternChar == 'o' || patternChar == '0') { - break; - } - } else if (!bSingleQuotation && - (patternChar == 'z' || patternChar == 's' || - patternChar == 'e' || patternChar == 'v' || - patternChar == '8' || patternChar == ',' || - patternChar == '.' || patternChar == '$')) { - patternType = XFA_VT_FLOAT; - if (patternChar == 'v' || patternChar == '8' || patternChar == '$') { - break; - } - } - iIndex++; - } - if (patternType == XFA_VT_NULL) { - patternType = XFA_VT_TEXT | XFA_VT_FLOAT; - } - return FALSE; -} -void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc >= 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - CFX_ByteString szPattern; - HValueToUTF8String(argOne, szPattern); - CFX_ByteString szValue; - HValueToUTF8String(argTwo, szValue); - CXFA_Document* pDoc = pContext->GetDocument(); - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - IFX_Locale* pLocale = widgetData.GetLocal(); - FX_DWORD patternType; - FX_BOOL bCompelte = XFA_PATTERN_STRING_Type(szPattern, patternType); - CFX_WideString wsPattern = - CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); - CFX_WideString wsValue = - CFX_WideString::FromUTF8(szValue, szValue.GetLength()); - if (!bCompelte) { - switch (patternType) { - case XFA_VT_DATETIME: { - FX_STRSIZE iTChar = wsPattern.Find(L'T'); - CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); - wsDatePattern += wsPattern.Left(iTChar); - wsDatePattern += FX_WSTRC(L"} "); - CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); - wsTimePattern += wsPattern.Mid(iTChar + 1); - wsTimePattern += FX_WSTRC(L"}"); - wsPattern = wsDatePattern + wsTimePattern; - } break; - case XFA_VT_DATE: { - wsPattern = FX_WSTRC(L"date{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - } break; - case XFA_VT_TIME: { - wsPattern = FX_WSTRC(L"time{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - } break; - case XFA_VT_TEXT: { - wsPattern = FX_WSTRC(L"text{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - } break; - case XFA_VT_FLOAT: { - wsPattern = FX_WSTRC(L"num{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - } break; - default: { - CFX_WideString wsTestPattern; - wsTestPattern = FX_WSTRC(L"num{") + wsPattern; - wsTestPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue tempLocaleValue(XFA_VT_FLOAT, wsValue, wsTestPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (tempLocaleValue.IsValid()) { - wsPattern = wsTestPattern; - patternType = XFA_VT_FLOAT; - } else { - wsTestPattern = FX_WSTRC(L"text{") + wsPattern; - wsTestPattern += FX_WSTRC(L"}"); - wsPattern = wsTestPattern; - patternType = XFA_VT_TEXT; - } - } break; - } - } - CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, - (CXFA_LocaleMgr*)pMgr); - CFX_WideString wsRet; - if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, - XFA_VALUEPICTURE_Display)) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - FX_UTF8Encode(wsRet, wsRet.GetLength())); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Format"); - } -} -void CXFA_FM2JSContext::Left(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FX_BOOL argIsNull = FALSE; - if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { - argIsNull = TRUE; - } - if (argIsNull) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString sourceString; - HValueToUTF8String(argOne, sourceString); - int32_t count = HValueToInteger(hThis, argTwo); - if (count < 0) { - count = 0; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - sourceString.Left(count)); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Left"); - } -} -void CXFA_FM2JSContext::Len(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString sourceString; - HValueToUTF8String(argOne, sourceString); - FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Len"); - } -} -void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 3)) { - CFX_ByteString argString; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE localeValue = 0; - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - if (argc == 2) { - localeValue = GetSimpleHValue(hThis, args, 1); - } - HValueToUTF8String(argOne, argString); - CFX_WideTextBuf lowStringBuf; - CFX_WideString wsArgString = - CFX_WideString::FromUTF8(argString, argString.GetLength()); - const FX_WCHAR* pData = wsArgString; - int32_t iLen = argString.GetLength(); - int32_t i = 0; - int32_t ch = 0; - while (i < iLen) { - ch = *(pData + i); - if (ch >= 0x41 && ch <= 0x5A) { - ch += 32; - } else if (ch >= 0xC0 && ch <= 0xDE) { - ch += 32; - } else if (ch == 0x100 || ch == 0x102 || ch == 0x104) { - ch += 1; - } - lowStringBuf.AppendChar(ch); - ++i; - } - lowStringBuf.AppendChar(0); - FXJSE_Value_SetUTF8String( - args.GetReturnValue(), - FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())); - if (argc == 2) { - FXJSE_Value_Release(localeValue); - } - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Lower"); - } -} -void CXFA_FM2JSContext::Ltrim(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString sourceString; - HValueToUTF8String(argOne, sourceString); - sourceString.TrimLeft(); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), sourceString); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Ltrim"); - } -} -void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - if (HValueIsNull(hThis, argTwo)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString szPattern; - HValueToUTF8String(argOne, szPattern); - CFX_ByteString szValue; - HValueToUTF8String(argTwo, szValue); - CXFA_Document* pDoc = pContext->GetDocument(); - IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); - CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); - FXSYS_assert(pThisNode); - CXFA_WidgetData widgetData(pThisNode); - IFX_Locale* pLocale = widgetData.GetLocal(); - FX_DWORD patternType; - FX_BOOL bCompletePattern = - XFA_PATTERN_STRING_Type(szPattern, patternType); - CFX_WideString wsPattern = - CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); - CFX_WideString wsValue = - CFX_WideString::FromUTF8(szValue, szValue.GetLength()); - CFX_ByteString szParsedValue; - if (bCompletePattern) { - CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, - (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } else { - switch (patternType) { - case XFA_VT_DATETIME: { - FX_STRSIZE iTChar = wsPattern.Find(L'T'); - CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); - wsDatePattern += wsPattern.Left(iTChar); - wsDatePattern += FX_WSTRC(L"} "); - CFX_WideString wsTimePattern = FX_WSTRC(L"time{"); - wsTimePattern += wsPattern.Mid(iTChar + 1); - wsTimePattern += FX_WSTRC(L"}"); - wsPattern = wsDatePattern + wsTimePattern; - CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } break; - case XFA_VT_DATE: { - wsPattern = FX_WSTRC(L"date{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } break; - case XFA_VT_TIME: { - wsPattern = FX_WSTRC(L"time{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } break; - case XFA_VT_TEXT: { - wsPattern = FX_WSTRC(L"text{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } break; - case XFA_VT_FLOAT: { - wsPattern = FX_WSTRC(L"num{") + wsPattern; - wsPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - FXJSE_Value_SetDouble(args.GetReturnValue(), - localeValue.GetDoubleNum()); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } break; - default: { - CFX_WideString wsTestPattern; - wsTestPattern = FX_WSTRC(L"num{") + wsPattern; - wsTestPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - FXJSE_Value_SetDouble(args.GetReturnValue(), - localeValue.GetDoubleNum()); - } else { - wsTestPattern = FX_WSTRC(L"text{") + wsPattern; - wsTestPattern += FX_WSTRC(L"}"); - CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern, - pLocale, (CXFA_LocaleMgr*)pMgr); - if (localeValue.IsValid()) { - szParsedValue = FX_UTF8Encode(localeValue.GetValue()); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), szParsedValue); - } else { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } - } - } break; - } - } - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Parse"); - } -} -void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc == 2) || (argc == 3)) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE argThree = 0; - CFX_ByteString oneString; - CFX_ByteString twoString; - CFX_ByteString threeString; - if (!HValueIsNull(hThis, argOne) && !HValueIsNull(hThis, argTwo)) { - HValueToUTF8String(argOne, oneString); - HValueToUTF8String(argTwo, twoString); - } - if (argc == 3) { - argThree = GetSimpleHValue(hThis, args, 2); - HValueToUTF8String(argThree, threeString); - } - int32_t iSrcLen = oneString.GetLength(); - int32_t iFindLen = twoString.GetLength(); - CFX_ByteTextBuf resultString; - int32_t iFindIndex = 0; - uint8_t ch = 0; - for (int32_t u = 0; u < iSrcLen; ++u) { - ch = oneString.GetAt(u); - if (ch == twoString.GetAt(iFindIndex)) { - int32_t iTemp = u + 1; - ++iFindIndex; - uint8_t chTemp = 0; - while (iFindIndex < iFindLen) { - chTemp = oneString.GetAt(iTemp); - if (chTemp == twoString.GetAt(iFindIndex)) { - ++iTemp; - ++iFindIndex; - } else { - iFindIndex = 0; - break; - } - } - if (iFindIndex == iFindLen) { - resultString << threeString; - u += iFindLen - 1; - iFindIndex = 0; - } else { - resultString.AppendChar(ch); - } - } else { - resultString.AppendChar(ch); - } - } - resultString.AppendChar(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultString.GetByteString()); - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - if (argc == 3) { - FXJSE_Value_Release(argThree); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Replace"); - } -} -void CXFA_FM2JSContext::Right(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 2) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); - FX_BOOL argIsNull = FALSE; - if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { - argIsNull = TRUE; - } - if (argIsNull) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString sourceString; - HValueToUTF8String(argOne, sourceString); - int32_t count = HValueToInteger(hThis, argTwo); - if (count < 0) { - count = 0; - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - sourceString.Right(count)); - } - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Right"); - } -} -void CXFA_FM2JSContext::Rtrim(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString sourceString; - HValueToUTF8String(argOne, sourceString); - sourceString.TrimRight(); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), sourceString); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Rtrim"); - } -} -void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - int32_t count = 0; - count = HValueToInteger(hThis, argOne); - count = (count < 0) ? 0 : count; - CFX_ByteTextBuf spaceString; - int32_t index = 0; - while (index < count) { - spaceString.AppendByte(' '); - index++; - } - spaceString.AppendByte(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - spaceString.GetByteString()); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Space"); - } -} -void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - FX_FLOAT fNumber; - int32_t iWidth = 10; - int32_t iPrecision = 0; - FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE widthValue = 0; - FXJSE_HVALUE precisionValue = 0; - if (FXJSE_Value_IsNull(numberValue)) { - bFlags = TRUE; - } else { - fNumber = HValueToFloat(hThis, numberValue); - } - if (argc > 1) { - widthValue = GetSimpleHValue(hThis, args, 1); - iWidth = (int32_t)HValueToFloat(hThis, widthValue); - } - if (argc == 3) { - precisionValue = GetSimpleHValue(hThis, args, 2); - iPrecision = (int32_t)HValueToFloat(hThis, precisionValue); - if (iPrecision < 0) { - iPrecision = 0; - } - } - if (!bFlags) { - CFX_ByteString numberString; - CFX_ByteString formatStr = "%"; - if (iPrecision) { - formatStr += "."; - formatStr += CFX_ByteString::FormatInteger(iPrecision); - } - formatStr += "f"; - numberString.Format(formatStr, fNumber); - const FX_CHAR* pData = numberString; - int32_t iLength = numberString.GetLength(); - int32_t u = 0; - while (u < iLength) { - if (*(pData + u) == '.') { - break; - } - ++u; - } - CFX_ByteTextBuf resultBuf; - if (u > iWidth || (iPrecision + u) >= iWidth) { - int32_t i = 0; - while (i < iWidth) { - resultBuf.AppendChar('*'); - ++i; - } - resultBuf.AppendChar(0); - } else { - if (u == iLength) { - if (iLength > iWidth) { - int32_t i = 0; - while (i < iWidth) { - resultBuf.AppendChar('*'); - ++i; - } - } else { - int32_t i = 0; - int32_t iSpace = iWidth - iLength; - while (i < iSpace) { - resultBuf.AppendChar(' '); - ++i; - } - resultBuf << pData; - } - } else { - int32_t iLeavingSpace = 0; - if (iPrecision == 0) { - iLeavingSpace = iWidth - (u + iPrecision); - } else { - iLeavingSpace = iWidth - (u + iPrecision + 1); - } - int32_t i = 0; - while (i < iLeavingSpace) { - resultBuf.AppendChar(' '); - ++i; - } - i = 0; - while (i < u) { - resultBuf.AppendChar(*(pData + i)); - ++i; - } - if (iPrecision != 0) { - resultBuf.AppendChar('.'); - } - u++; - i = 0; - while (u < iLength) { - if (i >= iPrecision) { - break; - } - resultBuf.AppendChar(*(pData + u)); - ++i; - ++u; - } - while (i < iPrecision) { - resultBuf.AppendChar('0'); - ++i; - } - resultBuf.AppendChar(0); - } - } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(numberValue); - if (argc > 1) { - FXJSE_Value_Release(widthValue); - if (argc == 3) { - FXJSE_Value_Release(precisionValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Str"); - } -} -void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc == 3) || (argc == 4)) { - CFX_ByteString sourceString; - CFX_ByteString insertString; - int32_t iLength = 0; - int32_t iStart = 0; - int32_t iDelete = 0; - FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); - FXJSE_HVALUE insertValue = 0; - if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && - !FXJSE_Value_IsNull(deleteValue)) { - HValueToUTF8String(sourceValue, sourceString); - iLength = sourceString.GetLength(); - iStart = (int32_t)HValueToFloat(hThis, startValue); - if (iStart < 1) { - iStart = 1; - } - if (iStart > iLength) { - iStart = iLength; - } - iDelete = (int32_t)HValueToFloat(hThis, deleteValue); - if (iDelete <= 0) { - iDelete = 0; - } - } - if (argc == 4) { - insertValue = GetSimpleHValue(hThis, args, 3); - HValueToUTF8String(insertValue, insertString); - } - iStart -= 1; - CFX_ByteTextBuf resultString; - int32_t i = 0; - while (i < iStart) { - resultString.AppendChar(sourceString.GetAt(i)); - ++i; - } - resultString << insertString; - i = iStart + iDelete; - while (i < iLength) { - resultString.AppendChar(sourceString.GetAt(i)); - ++i; - } - resultString.AppendChar(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultString.GetByteString()); - FXJSE_Value_Release(sourceValue); - FXJSE_Value_Release(startValue); - FXJSE_Value_Release(deleteValue); - if (argc == 4) { - FXJSE_Value_Release(insertValue); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Stuff"); - } -} -void CXFA_FM2JSContext::Substr(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if (argc == 3) { - FXJSE_HVALUE stringValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); - FXJSE_HVALUE endValue = GetSimpleHValue(hThis, args, 2); - if (HValueIsNull(hThis, stringValue) || (HValueIsNull(hThis, startValue)) || - (HValueIsNull(hThis, endValue))) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - CFX_ByteString szSourceStr; - int32_t iStart = 0; - int32_t iCount = 0; - HValueToUTF8String(stringValue, szSourceStr); - int32_t iLength = szSourceStr.GetLength(); - if (iLength == 0) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } else { - iStart = (int32_t)HValueToFloat(hThis, startValue); - iCount = (int32_t)HValueToFloat(hThis, endValue); - if (iStart < 1) { - iStart = 1; - } - if (iStart > iLength) { - iStart = iLength; - } - if (iCount <= 0) { - iCount = 0; - } - iStart -= 1; - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - szSourceStr.Mid(iStart, iCount)); - } - } - FXJSE_Value_Release(stringValue); - FXJSE_Value_Release(startValue); - FXJSE_Value_Release(endValue); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Substr"); - } -} -void CXFA_FM2JSContext::Uuid(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc == 0) || (argc == 1)) { - int32_t iNum = 0; - FXJSE_HVALUE argOne = 0; - if (argc == 1) { - argOne = GetSimpleHValue(hThis, args, 0); - iNum = (int32_t)HValueToFloat(hThis, argOne); - } - FX_GUID guid; - FX_GUID_CreateV4(&guid); - CFX_ByteString bsUId; - FX_GUID_ToString(&guid, bsUId, iNum); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId); - if (argc == 1) { - FXJSE_Value_Release(argOne); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Uuid"); - } -} -void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 3)) { - CFX_ByteString argString; - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE localeValue = 0; - if (HValueIsNull(hThis, argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - if (argc == 2) { - localeValue = GetSimpleHValue(hThis, args, 1); - } - HValueToUTF8String(argOne, argString); - CFX_WideTextBuf upperStringBuf; - CFX_WideString wsArgString = - CFX_WideString::FromUTF8(argString, argString.GetLength()); - const FX_WCHAR* pData = wsArgString; - int32_t iLen = wsArgString.GetLength(); - int32_t i = 0; - int32_t ch = 0; - while (i < iLen) { - ch = *(pData + i); - if (ch >= 0x61 && ch <= 0x7A) { - ch -= 32; - } else if (ch >= 0xE0 && ch <= 0xFE) { - ch -= 32; - } else if (ch == 0x101 || ch == 0x103 || ch == 0x105) { - ch -= 1; - } - upperStringBuf.AppendChar(ch); - ++i; - } - upperStringBuf.AppendChar(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - FX_UTF8Encode(upperStringBuf.GetBuffer(), - upperStringBuf.GetLength())); - if (argc == 2) { - FXJSE_Value_Release(localeValue); - } - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Upper"); - } -} -void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t argc = args.GetLength(); - if ((argc > 0) && (argc < 4)) { - FX_BOOL bFlags = FALSE; - FX_FLOAT fNumber; - int32_t iIdentifier = 0; - CFX_ByteString localeString; - FXJSE_HVALUE numberValue = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE identifierValue = 0; - FXJSE_HVALUE localeValue = 0; - if (FXJSE_Value_IsNull(numberValue)) { - bFlags = TRUE; - } else { - fNumber = HValueToFloat(hThis, numberValue); - } - if (argc > 1) { - identifierValue = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(identifierValue)) { - bFlags = TRUE; - } else { - iIdentifier = (int32_t)HValueToFloat(hThis, identifierValue); - } - } - if (argc == 3) { - localeValue = GetSimpleHValue(hThis, args, 2); - if (FXJSE_Value_IsNull(localeValue)) { - bFlags = TRUE; - } else { - HValueToUTF8String(localeValue, localeString); - } - } - if (!bFlags) { - if ((fNumber < 0) || (fNumber > 922337203685477550)) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); - } else { - CFX_ByteTextBuf resultBuf; - CFX_ByteString numberString; - numberString.Format("%.2f", fNumber); - WordUS(numberString, iIdentifier, resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); - } - } else { - FXJSE_Value_SetNull(args.GetReturnValue()); - } - FXJSE_Value_Release(numberValue); - if (argc > 1) { - FXJSE_Value_Release(identifierValue); - if (argc == 3) { - FXJSE_Value_Release(localeValue); - } - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"WordNum"); - } -} -void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, - CFX_ByteTextBuf& strBuf) { - CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", - "five", "six", "seven", "eight", "nine"}; - CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", - "Five", "Six", "Seven", "Eight", "Nine"}; - CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", - "Fourteen", "Fifteen", "Sixteen", "Seventeen", - "Eighteen", "Nineteen"}; - CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", - "Sixty", "Seventy", "Eighty", "Ninety"}; - CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", - " Billion ", "Trillion"}; - int32_t iComm = 0; - const FX_CHAR* pData = szData.GetCStr(); - int32_t iLength = szData.GetLength(); - if (iLength > 12) { - iComm = 4; - } else if (iLength > 9) { - iComm = 3; - } else if (iLength > 6) { - iComm = 2; - } else if (iLength > 3) { - iComm = 1; - } - int32_t iIndex = 0; - int32_t iFirstCount = iLength % 3; - if (iFirstCount == 0) { - iFirstCount = 3; - } - if (iFirstCount == 3) { - if (*(pData + iIndex) != '0') { - strBuf << pCapUnits[*(pData + iIndex) - '0']; - strBuf << pComm[0]; - } - if (*(pData + iIndex + 1) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; - } else { - if (*(pData + iIndex + 1) > '1') { - strBuf << pLastTens[*(pData + iIndex + 1) - '2']; - strBuf << "-"; - strBuf << pUnits[*(pData + iIndex + 2) - '0']; - } else if (*(pData + iIndex + 1) == '1') { - strBuf << pTens[*(pData + iIndex + 2) - '0']; - } else if (*(pData + iIndex + 1) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; - } - } - iIndex += 3; - } else if (iFirstCount == 2) { - if (*(pData + iIndex) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 1) - '0']; - } else { - if (*(pData + iIndex) > '1') { - strBuf << pLastTens[*(pData + iIndex) - '2']; - strBuf << "-"; - strBuf << pUnits[*(pData + iIndex + 1) - '0']; - } else if (*(pData + iIndex) == '1') { - strBuf << pTens[*(pData + iIndex + 1) - '0']; - } else if (*(pData + iIndex) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 1) - '0']; - } - } - iIndex += 2; - } else if (iFirstCount == 1) { - strBuf << pCapUnits[*(pData + iIndex) - '0']; - iIndex += 1; - } - if (iLength > 3 && iFirstCount > 0) { - strBuf << pComm[iComm]; - --iComm; - } - while (iIndex < iLength) { - if (*(pData + iIndex) != '0') { - strBuf << pCapUnits[*(pData + iIndex) - '0']; - strBuf << pComm[0]; - } - if (*(pData + iIndex + 1) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; - } else { - if (*(pData + iIndex + 1) > '1') { - strBuf << pLastTens[*(pData + iIndex + 1) - '2']; - strBuf << "-"; - strBuf << pUnits[*(pData + iIndex + 2) - '0']; - } else if (*(pData + iIndex + 1) == '1') { - strBuf << pTens[*(pData + iIndex + 2) - '0']; - } else if (*(pData + iIndex + 1) == '0') { - strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; - } - } - if (iIndex < iLength - 3) { - strBuf << pComm[iComm]; - --iComm; - } - iIndex += 3; - } -} -void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, - int32_t iStyle, - CFX_ByteTextBuf& strBuf) { - const FX_CHAR* pData = szData.GetCStr(); - int32_t iLength = szData.GetLength(); - switch (iStyle) { - case 0: { - int32_t iIndex = 0; - while (iIndex < iLength) { - if (*(pData + iIndex) == '.') { - break; - } - ++iIndex; - } - iLength = iIndex; - iIndex = 0; - int32_t iCount = 0; - while (iIndex < iLength) { - iCount = (iLength - iIndex) % 12; - if (!iCount && iLength - iIndex > 0) { - iCount = 12; - } - TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); - iIndex += iCount; - if (iIndex < iLength) { - strBuf << " Trillion "; - } - } - } break; - case 1: { - int32_t iIndex = 0; - while (iIndex < iLength) { - if (*(pData + iIndex) == '.') { - break; - } - ++iIndex; - } - iLength = iIndex; - iIndex = 0; - int32_t iCount = 0; - while (iIndex < iLength) { - iCount = (iLength - iIndex) % 12; - if (!iCount && iLength - iIndex > 0) { - iCount = 12; - } - TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); - iIndex += iCount; - if (iIndex < iLength) { - strBuf << " Trillion "; - } - } - strBuf << " Dollars"; - } break; - case 2: { - int32_t iIndex = 0; - while (iIndex < iLength) { - if (*(pData + iIndex) == '.') { - break; - } - ++iIndex; - } - int32_t iInteger = iIndex; - iIndex = 0; - int32_t iCount = 0; - while (iIndex < iInteger) { - iCount = (iInteger - iIndex) % 12; - if (!iCount && iLength - iIndex > 0) { - iCount = 12; - } - TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); - iIndex += iCount; - if (iIndex < iInteger) { - strBuf << " Trillion "; - } - } - strBuf << " Dollars"; - if (iInteger < iLength) { - strBuf << " And "; - iIndex = iInteger + 1; - int32_t iCount = 0; - while (iIndex < iLength) { - iCount = (iLength - iIndex) % 12; - if (!iCount && iLength - iIndex > 0) { - iCount = 12; - } - TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); - iIndex += iCount; - if (iIndex < iLength) { - strBuf << " Trillion "; - } - } - strBuf << " Cents"; - } - } break; - default: - break; - } -} -void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc == 1) { - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return; - } - IXFA_AppProvider* pAppProvider = - pDoc->GetParser()->GetNotify()->GetAppProvider(); - if (!pAppProvider) { - return; - } - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - CFX_ByteString urlString; - HValueToUTF8String(argOne, urlString); - IFX_FileRead* pFile = pAppProvider->DownloadURL( - CFX_WideString::FromUTF8(urlString, urlString.GetLength())); - if (pFile) { - int32_t size = pFile->GetSize(); - uint8_t* pData = FX_Alloc(uint8_t, size); - pFile->ReadBlock(pData, size); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - CFX_ByteStringC(pData, size)); - FX_Free(pData); - pFile->Release(); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Get"); - } -} -void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if ((argc >= 2) && (argc <= 5)) { - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return; - } - IXFA_AppProvider* pAppProvider = - pDoc->GetParser()->GetNotify()->GetAppProvider(); - if (!pAppProvider) { - return; - } - CFX_ByteString bsURL; - CFX_ByteString bsData; - CFX_ByteString bsContentType; - CFX_ByteString bsEncode; - CFX_ByteString bsHeader; - FXJSE_HVALUE argOne; - FXJSE_HVALUE argTwo; - FXJSE_HVALUE argThree; - FXJSE_HVALUE argFour; - FXJSE_HVALUE argFive; - argOne = GetSimpleHValue(hThis, args, 0); - HValueToUTF8String(argOne, bsURL); - argTwo = GetSimpleHValue(hThis, args, 1); - HValueToUTF8String(argTwo, bsData); - if (argc > 2) { - argThree = GetSimpleHValue(hThis, args, 2); - HValueToUTF8String(argThree, bsContentType); - } - if (argc > 3) { - argFour = GetSimpleHValue(hThis, args, 3); - HValueToUTF8String(argFour, bsEncode); - } - if (argc > 4) { - argFive = GetSimpleHValue(hThis, args, 4); - HValueToUTF8String(argFive, bsHeader); - } - CFX_WideString decodedResponse; - FX_BOOL bFlags = pAppProvider->PostRequestURL( - CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), - CFX_WideString::FromUTF8(bsData, bsData.GetLength()), - CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength()), - CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength()), - CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength()), - decodedResponse); - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - if (argc > 2) { - FXJSE_Value_Release(argThree); - } - if (argc > 3) { - FXJSE_Value_Release(argFour); - } - if (argc > 4) { - FXJSE_Value_Release(argFive); - } - if (bFlags) { - FXJSE_Value_SetUTF8String( - args.GetReturnValue(), - FX_UTF8Encode(decodedResponse, decodedResponse.GetLength())); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); - } - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Post"); - } -} -void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if ((argc == 2) || (argc == 3)) { - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return; - } - IXFA_AppProvider* pAppProvider = - pDoc->GetParser()->GetNotify()->GetAppProvider(); - if (!pAppProvider) { - return; - } - CFX_ByteString bsURL; - CFX_ByteString bsData; - CFX_ByteString bsEncode; - FXJSE_HVALUE argOne; - FXJSE_HVALUE argTwo; - FXJSE_HVALUE argThree; - argOne = GetSimpleHValue(hThis, args, 0); - HValueToUTF8String(argOne, bsURL); - argTwo = GetSimpleHValue(hThis, args, 1); - HValueToUTF8String(argTwo, bsData); - if (argc > 2) { - argThree = GetSimpleHValue(hThis, args, 2); - HValueToUTF8String(argThree, bsEncode); - } - FX_BOOL bFlags = pAppProvider->PutRequestURL( - CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()), - CFX_WideString::FromUTF8(bsData, bsData.GetLength()), - CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())); - FXJSE_Value_Release(argOne); - FXJSE_Value_Release(argTwo); - if (argc > 2) { - FXJSE_Value_Release(argThree); - } - if (bFlags) { - FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); - } - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Put"); - } -} -void CXFA_FM2JSContext::assign_value_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - if (args.GetLength() == 2) { - FXJSE_HVALUE lValue = args.GetValue(0); - FXJSE_HVALUE rValue = GetSimpleHValue(hThis, args, 1); - FX_BOOL bSetStatus = TRUE; - if (FXJSE_Value_IsArray(lValue)) { - FXJSE_HVALUE leftLengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(lValue, "length", leftLengthValue); - int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue); - FXJSE_Value_Release(leftLengthValue); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(lValue, 1, propertyValue); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t i = 2; i < iLeftLength; i++) { - FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); - bSetStatus = SetObjectDefaultValue(jsObjectValue, rValue); - if (!bSetStatus) { - pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); - break; - } - } - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - for (int32_t i = 2; i < iLeftLength; i++) { - FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue); - FXJSE_Value_SetObjectProp(jsObjectValue, propertyStr, rValue); - } - } - FXJSE_Value_Release(jsObjectValue); - FXJSE_Value_Release(propertyValue); - } else if (FXJSE_Value_IsObject(lValue)) { - bSetStatus = SetObjectDefaultValue(lValue, rValue); - if (!bSetStatus) { - pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); - } - } - FXJSE_Value_Set(args.GetReturnValue(), rValue); - FXJSE_Value_Release(lValue); - FXJSE_Value_Release(rValue); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::logical_or_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_FLOAT first = HValueToFloat(hThis, argFirst); - FX_FLOAT second = HValueToFloat(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::logical_and_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_FLOAT first = HValueToFloat(hThis, argFirst); - FX_FLOAT second = HValueToFloat(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::equality_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - if (fm_ref_equal(hThis, args)) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 1); - } else { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger( - args.GetReturnValue(), - (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) - ? 1 - : 0); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - firstOutput.Equal(secondOutput) ? 1 : 0); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (first == second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::notequality_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - if (fm_ref_equal(hThis, args)) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } else { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger( - args.GetReturnValue(), - (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) - ? 0 - : 1); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - firstOutput.Equal(secondOutput) ? 0 : 1); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (first == second) ? 0 : 1); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -FX_BOOL CXFA_FM2JSContext::fm_ref_equal(FXJSE_HOBJECT hThis, - CFXJSE_Arguments& args) { - FX_BOOL bRet = FALSE; - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - FXJSE_HVALUE argFirst = args.GetValue(0); - FXJSE_HVALUE argSecond = args.GetValue(0); - if (FXJSE_Value_IsArray(argFirst) && FXJSE_Value_IsArray(argSecond)) { - FXJSE_HVALUE firstFlagValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE secondFlagValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argFirst, 0, firstFlagValue); - FXJSE_Value_GetObjectPropByIdx(argSecond, 0, secondFlagValue); - if ((FXJSE_Value_ToInteger(firstFlagValue) == 3) && - (FXJSE_Value_ToInteger(secondFlagValue) == 3)) { - FXJSE_HVALUE firstJSObject = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE secondJSObject = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argFirst, 2, firstJSObject); - FXJSE_Value_GetObjectPropByIdx(argSecond, 2, secondJSObject); - if (!FXJSE_Value_IsNull(firstJSObject) && - !FXJSE_Value_IsNull(secondJSObject)) { - bRet = (FXJSE_Value_ToObject(firstJSObject, NULL) == - FXJSE_Value_ToObject(secondJSObject, NULL)); - } - FXJSE_Value_Release(firstJSObject); - FXJSE_Value_Release(secondJSObject); - } - FXJSE_Value_Release(firstFlagValue); - FXJSE_Value_Release(secondFlagValue); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - return bRet; -} -void CXFA_FM2JSContext::less_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (firstOutput.Compare(secondOutput) == -1) ? 1 : 0); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::lessequal_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger( - args.GetReturnValue(), - (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 - : 0); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (firstOutput.Compare(secondOutput) != 1) ? 1 : 0); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::greater_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger(args.GetReturnValue(), 0); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (firstOutput.Compare(secondOutput) == 1) ? 1 : 0); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::greaterequal_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) || FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetInteger( - args.GetReturnValue(), - (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) ? 1 - : 0); - } else if (FXJSE_Value_IsUTF8String(argFirst) && - FXJSE_Value_IsUTF8String(argSecond)) { - CFX_ByteString firstOutput; - CFX_ByteString secondOutput; - FXJSE_Value_ToUTF8String(argFirst, firstOutput); - FXJSE_Value_ToUTF8String(argSecond, secondOutput); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (firstOutput.Compare(secondOutput) != -1) ? 1 : 0); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::plus_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = args.GetValue(0); - FXJSE_HVALUE argSecond = args.GetValue(1); - if (HValueIsNull(hThis, argFirst) && HValueIsNull(hThis, argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::minus_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::multiple_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::divide_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - if (args.GetLength() == 2) { - FXJSE_HVALUE argFirst = GetSimpleHValue(hThis, args, 0); - FXJSE_HVALUE argSecond = GetSimpleHValue(hThis, args, 1); - if (FXJSE_Value_IsNull(argFirst) && FXJSE_Value_IsNull(argSecond)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argFirst); - FX_DOUBLE second = HValueToDouble(hThis, argSecond); - if (second == 0.0) { - pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); - } else { - FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); - } - } - FXJSE_Value_Release(argFirst); - FXJSE_Value_Release(argSecond); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::positive_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetDouble(args.GetReturnValue(), - 0.0 + HValueToDouble(hThis, argOne)); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::negative_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FXJSE_Value_SetDouble(args.GetReturnValue(), - 0.0 - HValueToDouble(hThis, argOne)); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::logical_not_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - if (FXJSE_Value_IsNull(argOne)) { - FXJSE_Value_SetNull(args.GetReturnValue()); - } else { - FX_DOUBLE first = HValueToDouble(hThis, argOne); - FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); - } - FXJSE_Value_Release(argOne); - } else { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - if ((argc == 4) || (argc == 5)) { - FX_BOOL bIsStar = TRUE; - FXJSE_HVALUE argAccessor = args.GetValue(0); - CFX_ByteString bsAccessorName = args.GetUTF8String(1); - CFX_ByteString szName = args.GetUTF8String(2); - int32_t iIndexFlags = args.GetInt32(3); - int32_t iIndexValue = 0; - FXJSE_HVALUE argIndex = NULL; - if (argc == 5) { - bIsStar = FALSE; - argIndex = args.GetValue(4); - iIndexValue = HValueToInteger(hThis, argIndex); - } - CFX_ByteString szSomExp; - GenerateSomExpression(szName, iIndexFlags, iIndexValue, bIsStar, szSomExp); - if (FXJSE_Value_IsArray(argAccessor)) { - FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); - int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); - FXJSE_Value_Release(hLengthValue); - int32_t iCounter = 0; - FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); - int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); - for (int32_t i = 0; i < (iLength - 2); i++) { - iSizes[i] = 0; - } - FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(hruntime); - FX_BOOL bAttribute = FALSE; - 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, - resoveNodeRS, TRUE, szName.IsEmpty()); - if (iRet > 0) { - ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, - hResolveValues[i - 2], iSizes[i - 2], bAttribute); - iCounter += iSizes[i - 2]; - } - } - FXJSE_Value_Release(hJSObjValue); - if (iCounter > 0) { - FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); - for (int32_t i = 0; i < (iCounter + 2); i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 1); - if (bAttribute) { - FXJSE_Value_SetUTF8String(rgValues[1], szName); - } else { - FXJSE_Value_SetNull(rgValues[1]); - } - int32_t iIndex = 2; - for (int32_t i = 0; i < iLength - 2; i++) { - for (int32_t j = 0; j < iSizes[i]; j++) { - FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); - iIndex++; - } - } - FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); - for (int32_t i = 0; i < (iCounter + 2); i++) { - FXJSE_Value_Release(rgValues[i]); - } - FX_Free(rgValues); - } else { - CFX_WideString wsPropertyName = - CFX_WideString::FromUTF8(szName, szName.GetLength()); - CFX_WideString wsSomExpression = - CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); - pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, - (const FX_WCHAR*)wsPropertyName, - (const FX_WCHAR*)wsSomExpression); - } - for (int32_t i = 0; i < iLength - 2; i++) { - for (int32_t j = 0; j < iSizes[i]; j++) { - FXJSE_Value_Release(hResolveValues[i][j]); - } - if (iSizes[i] > 0) { - FX_Free(hResolveValues[i]); - } - } - FX_Free(hResolveValues); - FX_Free(iSizes); - } else { - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = 0; - if (FXJSE_Value_IsObject(argAccessor) || - (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { - iRet = ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, TRUE, - szName.IsEmpty()); - } else if (!FXJSE_Value_IsObject(argAccessor) && - !bsAccessorName.IsEmpty()) { - FX_BOOL bGetObject = - GetObjectByName(hThis, argAccessor, bsAccessorName); - if (bGetObject) { - iRet = ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, - TRUE, szName.IsEmpty()); - } - } - if (iRet > 0) { - FXJSE_HVALUE* hResolveValues; - int32_t iSize = 0; - FX_BOOL bAttribute = FALSE; - ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, - iSize, bAttribute); - FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); - for (int32_t i = 0; i < (iSize + 2); i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 1); - if (bAttribute) { - FXJSE_Value_SetUTF8String(rgValues[1], szName); - } else { - FXJSE_Value_SetNull(rgValues[1]); - } - for (int32_t i = 0; i < iSize; i++) { - FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); - } - FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); - for (int32_t i = 0; i < (iSize + 2); i++) { - FXJSE_Value_Release(rgValues[i]); - } - FX_Free(rgValues); - for (int32_t i = 0; i < iSize; i++) { - FXJSE_Value_Release(hResolveValues[i]); - } - FX_Free(hResolveValues); - } else { - CFX_WideString wsPropertyName = - CFX_WideString::FromUTF8(szName, szName.GetLength()); - CFX_WideString wsSomExpression = - CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); - pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, - (const FX_WCHAR*)wsPropertyName, - (const FX_WCHAR*)wsSomExpression); - } - } - if (argc == 5) { - FXJSE_Value_Release(argIndex); - } - FXJSE_Value_Release(argAccessor); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - if ((argc == 4) || (argc == 5)) { - FX_BOOL bIsStar = TRUE; - FXJSE_HVALUE argAccessor = args.GetValue(0); - CFX_ByteString bsAccessorName = args.GetUTF8String(1); - CFX_ByteString szName = args.GetUTF8String(2); - int32_t iIndexFlags = args.GetInt32(3); - int32_t iIndexValue = 0; - FXJSE_HVALUE argIndex = NULL; - if (argc == 5) { - bIsStar = FALSE; - argIndex = args.GetValue(4); - iIndexValue = HValueToInteger(hThis, argIndex); - } - CFX_ByteString szSomExp; - GenerateSomExpression(szName, iIndexFlags, iIndexValue, bIsStar, szSomExp); - if (FXJSE_Value_IsArray(argAccessor)) { - FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue); - int32_t iLength = FXJSE_Value_ToInteger(hLengthValue); - int32_t iCounter = 0; - FXJSE_HVALUE** hResolveValues = FX_Alloc(FXJSE_HVALUE*, iLength - 2); - int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); - FXJSE_HVALUE hJSObjValue = FXJSE_Value_Create(hruntime); - FX_BOOL bAttribute = FALSE; - 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, resoveNodeRS, FALSE); - if (iRet > 0) { - ParseResolveResult(hThis, resoveNodeRS, hJSObjValue, - hResolveValues[i - 2], iSizes[i - 2], bAttribute); - iCounter += iSizes[i - 2]; - } - } - FXJSE_Value_Release(hJSObjValue); - if (iCounter > 0) { - FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iCounter + 2); - for (int32_t i = 0; i < (iCounter + 2); i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 1); - if (bAttribute) { - FXJSE_Value_SetUTF8String(rgValues[1], szName); - } else { - FXJSE_Value_SetNull(rgValues[1]); - } - int32_t iIndex = 2; - for (int32_t i = 0; i < iLength - 2; i++) { - for (int32_t j = 0; j < iSizes[i]; j++) { - FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); - iIndex++; - } - } - FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); - for (int32_t i = 0; i < (iCounter + 2); i++) { - FXJSE_Value_Release(rgValues[i]); - } - FX_Free(rgValues); - } else { - CFX_WideString wsPropertyName = - CFX_WideString::FromUTF8(szName, szName.GetLength()); - CFX_WideString wsSomExpression = - CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); - pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, - (const FX_WCHAR*)wsPropertyName, - (const FX_WCHAR*)wsSomExpression); - } - for (int32_t i = 0; i < iLength - 2; i++) { - for (int32_t j = 0; j < iSizes[i]; j++) { - FXJSE_Value_Release(hResolveValues[i][j]); - } - FX_Free(hResolveValues[i]); - } - FX_Free(hResolveValues); - FX_Free(iSizes); - FXJSE_Value_Release(hLengthValue); - } else { - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = 0; - if (FXJSE_Value_IsObject(argAccessor) || - (FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) { - iRet = - ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, FALSE); - } else if (!FXJSE_Value_IsObject(argAccessor) && - !bsAccessorName.IsEmpty()) { - FX_BOOL bGetObject = - GetObjectByName(hThis, argAccessor, bsAccessorName); - if (bGetObject) { - iRet = - ResolveObjects(hThis, argAccessor, szSomExp, resoveNodeRS, FALSE); - } - } - if (iRet > 0) { - FXJSE_HVALUE* hResolveValues; - int32_t iSize = 0; - FX_BOOL bAttribute = FALSE; - ParseResolveResult(hThis, resoveNodeRS, argAccessor, hResolveValues, - iSize, bAttribute); - FXJSE_HVALUE* rgValues = FX_Alloc(FXJSE_HVALUE, iSize + 2); - for (int32_t i = 0; i < (iSize + 2); i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 1); - if (bAttribute) { - FXJSE_Value_SetUTF8String(rgValues[1], szName); - } else { - FXJSE_Value_SetNull(rgValues[1]); - } - for (int32_t i = 0; i < iSize; i++) { - FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); - } - FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); - for (int32_t i = 0; i < (iSize + 2); i++) { - FXJSE_Value_Release(rgValues[i]); - } - FX_Free(rgValues); - for (int32_t i = 0; i < iSize; i++) { - FXJSE_Value_Release(hResolveValues[i]); - } - FX_Free(hResolveValues); - } else { - CFX_WideString wsPropertyName = - CFX_WideString::FromUTF8(szName, szName.GetLength()); - CFX_WideString wsSomExpression = - CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength()); - pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, - (const FX_WCHAR*)wsPropertyName, - (const FX_WCHAR*)wsSomExpression); - } - } - if (argc == 5) { - FXJSE_Value_Release(argIndex); - } - FXJSE_Value_Release(argAccessor); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - int32_t argc = args.GetLength(); - if (argc == 1) { - FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); - CFX_ByteString argString; - HValueToUTF8String(argOne, argString); - if (argString.IsEmpty()) { - pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } else { - CFX_WideString scriptString = - CFX_WideString::FromUTF8(argString, argString.GetLength()); - CFX_WideTextBuf wsJavaScriptBuf; - CFX_WideString wsError; - XFA_FM2JS_Translate(scriptString, wsJavaScriptBuf, wsError); - if (wsError.IsEmpty()) { - CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); - FXJSE_Value_SetUTF8String( - args.GetReturnValue(), - FX_UTF8Encode(javaScript, javaScript.GetLength())); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"Eval"); - } -} -void CXFA_FM2JSContext::is_fm_object(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - FXJSE_Value_SetBoolean(args.GetReturnValue(), FXJSE_Value_IsObject(argOne)); - FXJSE_Value_Release(argOne); - } else { - FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); - } -} -void CXFA_FM2JSContext::is_fm_array(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne); - FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); - FXJSE_Value_Release(argOne); - } else { - FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); - } -} -void CXFA_FM2JSContext::get_fm_value(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t iLength = args.GetLength(); - if (iLength == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (FXJSE_Value_IsArray(argOne)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, args.GetReturnValue()); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, - args.GetReturnValue()); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsobjectValue); - } else if (FXJSE_Value_IsObject(argOne)) { - GetObjectDefaultValue(argOne, args.GetReturnValue()); - } else { - FXJSE_Value_Set(args.GetReturnValue(), argOne); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(hThis, nullptr)); - int32_t argc = args.GetLength(); - if (argc == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (FXJSE_Value_IsArray(argOne)) { -#ifndef NDEBUG - 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); - FXJSE_Value_Release(lengthValue); -#endif - FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue()); - } else { - FXJSE_Value_Set(args.GetReturnValue(), argOne); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t argc = args.GetLength(); - if (argc == 1) { - FXJSE_HVALUE argOne = args.GetValue(0); - if (FXJSE_Value_IsArray(argOne)) { -#ifndef NDEBUG - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argOne, "length", lengthValue); - FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3); - FXJSE_Value_Release(lengthValue); -#endif - FXJSE_HVALUE flagsValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 0, flagsValue); - int32_t iFlags = FXJSE_Value_ToInteger(flagsValue); - FXJSE_Value_Release(flagsValue); - if (iFlags == 4) { - FXJSE_HVALUE rgValues[3]; - for (int32_t i = 0; i < 3; i++) { - rgValues[i] = FXJSE_Value_Create(hruntime); - } - FXJSE_Value_SetInteger(rgValues[0], 3); - FXJSE_Value_SetNull(rgValues[1]); - FXJSE_Value_SetNull(rgValues[2]); - FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); - for (int32_t i = 0; i < 3; i++) { - FXJSE_Value_Release(rgValues[i]); - } - } else if (iFlags == 3) { - FXJSE_HVALUE objectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argOne, 2, objectValue); - if (!FXJSE_Value_IsNull(objectValue)) { - FXJSE_Value_Set(args.GetReturnValue(), argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } - FXJSE_Value_Release(objectValue); - } else { - FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); - FXJSE_Value_Set(args.GetReturnValue(), simpleValue); - FXJSE_Value_Release(simpleValue); - } - } else { - FXJSE_HVALUE simpleValue = GetSimpleHValue(hThis, args, 0); - FXJSE_Value_Set(args.GetReturnValue(), simpleValue); - FXJSE_Value_Release(simpleValue); - } - FXJSE_Value_Release(argOne); - } else { - pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); - } -} -void CXFA_FM2JSContext::concat_fm_object(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - uint32_t iLength = 0; - int32_t argCount = args.GetLength(); - FXJSE_HVALUE* argValues = FX_Alloc(FXJSE_HVALUE, argCount); - for (int32_t i = 0; i < argCount; i++) { - argValues[i] = args.GetValue(i); - if (FXJSE_Value_IsArray(argValues[i])) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); - int32_t length = FXJSE_Value_ToInteger(lengthValue); - iLength = iLength + ((length > 2) ? (length - 2) : 0); - FXJSE_Value_Release(lengthValue); - } - iLength += 1; - } - FXJSE_HVALUE* returnValues = FX_Alloc(FXJSE_HVALUE, iLength); - for (int32_t i = 0; i < (int32_t)iLength; i++) { - returnValues[i] = FXJSE_Value_Create(hruntime); - } - int32_t index = 0; - for (int32_t i = 0; i < argCount; i++) { - if (FXJSE_Value_IsArray(argValues[i])) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argValues[i], "length", lengthValue); - int32_t length = FXJSE_Value_ToInteger(lengthValue); - for (int32_t j = 2; j < length; j++) { - FXJSE_Value_GetObjectPropByIdx(argValues[i], j, returnValues[index]); - index++; - } - FXJSE_Value_Release(lengthValue); - } - FXJSE_Value_Set(returnValues[index], argValues[i]); - index++; - } - FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); - for (int32_t i = 0; i < argCount; i++) { - FXJSE_Value_Release(argValues[i]); - } - FX_Free(argValues); - for (int32_t i = 0; i < (int32_t)iLength; i++) { - FXJSE_Value_Release(returnValues[i]); - } - FX_Free(returnValues); -} -FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis, - CFXJSE_Arguments& args, - uint32_t index) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - FXSYS_assert(index < (uint32_t)args.GetLength()); - FXJSE_HVALUE argIndex = args.GetValue(index); - if (FXJSE_Value_IsArray(argIndex)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argIndex, "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - FXJSE_HVALUE simpleValue = FXJSE_Value_Create(hruntime); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argIndex, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(argIndex, 2, jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, simpleValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, simpleValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsobjectValue); - } else { - FXJSE_Value_SetUndefined(simpleValue); - } - FXJSE_Value_Release(argIndex); - return simpleValue; - } else if (FXJSE_Value_IsObject(argIndex)) { - FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(argIndex, defaultValue); - FXJSE_Value_Release(argIndex); - return defaultValue; - } else { - return argIndex; - } -} -FX_BOOL CXFA_FM2JSContext::HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - FX_BOOL isNull = FALSE; - if (FXJSE_Value_IsNull(arg)) { - isNull = TRUE; - } else if (FXJSE_Value_IsArray(arg)) { - int32_t iLength = hvalue_get_array_length(hThis, arg); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(jsObjectValue, defaultValue); - if (FXJSE_Value_IsNull(defaultValue)) { - isNull = TRUE; - } - FXJSE_Value_Release(defaultValue); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr, newPropertyValue); - if (FXJSE_Value_IsNull(newPropertyValue)) { - isNull = TRUE; - } - FXJSE_Value_Release(newPropertyValue); - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } else { - isNull = TRUE; - } - } else if (FXJSE_Value_IsObject(arg)) { - FXJSE_HVALUE defaultValue = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(arg, defaultValue); - if (FXJSE_Value_IsNull(defaultValue)) { - isNull = TRUE; - } - FXJSE_Value_Release(defaultValue); - } - return isNull; -} -int32_t CXFA_FM2JSContext::hvalue_get_array_length(FXJSE_HOBJECT hThis, - FXJSE_HVALUE arg) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t iLength = 0; - if (FXJSE_Value_IsArray(arg)) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(arg, "length", lengthValue); - iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - } - return iLength; -} -FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, - FXJSE_HVALUE firstValue, - FXJSE_HVALUE secondValue) { - FX_BOOL bReturn = FALSE; - if (FXJSE_Value_IsUTF8String(firstValue)) { - CFX_ByteString firstString, secondString; - HValueToUTF8String(firstValue, firstString); - HValueToUTF8String(secondValue, secondString); - bReturn = firstString.Equal(secondString); - } else if (FXJSE_Value_IsNumber(firstValue)) { - FX_FLOAT first = HValueToFloat(hThis, firstValue); - FX_FLOAT second = HValueToFloat(hThis, secondValue); - bReturn = (first == second); - } else if (FXJSE_Value_IsBoolean(firstValue)) { - bReturn = (FXJSE_Value_ToBoolean(firstValue) == - FXJSE_Value_ToBoolean(secondValue)); - } else if (FXJSE_Value_IsNull(firstValue) && - FXJSE_Value_IsNull(secondValue)) { - bReturn = TRUE; - } - return bReturn; -} -void CXFA_FM2JSContext::unfoldArgs(FXJSE_HOBJECT hThis, - CFXJSE_Arguments& args, - FXJSE_HVALUE*& resultValues, - int32_t& iCount, - int32_t iStart) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - iCount = 0; - int32_t argc = args.GetLength(); - FXJSE_HVALUE* argsValue = FX_Alloc(FXJSE_HVALUE, argc); - for (int32_t i = iStart; i < argc; i++) { - argsValue[i] = args.GetValue(i); - if (FXJSE_Value_IsArray(argsValue[i])) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - iCount += ((iLength > 2) ? (iLength - 2) : 0); - } else { - iCount += 1; - } - } - resultValues = FX_Alloc(FXJSE_HVALUE, iCount); - for (int32_t i = 0; i < iCount; i++) { - resultValues[i] = FXJSE_Value_Create(hruntime); - } - int32_t index = 0; - for (int32_t i = iStart; i < argc; i++) { - if (FXJSE_Value_IsArray(argsValue[i])) { - FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectProp(argsValue[i], "length", lengthValue); - int32_t iLength = FXJSE_Value_ToInteger(lengthValue); - FXJSE_Value_Release(lengthValue); - if (iLength > 2) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsObjectValue = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(argsValue[i], 1, propertyValue); - if (FXJSE_Value_IsNull(propertyValue)) { - for (int32_t j = 2; j < iLength; j++) { - FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue); - GetObjectDefaultValue(jsObjectValue, resultValues[index]); - index++; - } - } else { - CFX_ByteString propertyString; - 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, - resultValues[index]); - index++; - } - } - FXJSE_Value_Release(propertyValue); - FXJSE_Value_Release(jsObjectValue); - } - } else if (FXJSE_Value_IsObject(argsValue[i])) { - GetObjectDefaultValue(argsValue[i], resultValues[index]); - index++; - } else { - FXJSE_Value_Set(resultValues[index], argsValue[i]); - index++; - } - } - for (int32_t i = iStart; i < argc; i++) { - FXJSE_Value_Release(argsValue[i]); - } - FX_Free(argsValue); -} -void CXFA_FM2JSContext::GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, - FXJSE_HVALUE hDefaultValue) { - CXFA_Node* pNode = - ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); - if (pNode) { - pNode->Script_Som_DefaultValue(hDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); - } else { - FXJSE_Value_SetNull(hDefaultValue); - } -} -FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, - FXJSE_HVALUE hNewValue) { - CXFA_Node* pNode = - ToNode((CXFA_Object*)FXJSE_Value_ToObject(hObjectValue, NULL)); - if (pNode) { - pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); - return TRUE; - } - return FALSE; -} -void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, - int32_t iIndexFlags, - int32_t iIndexValue, - FX_BOOL bIsStar, - CFX_ByteString& szSomExp) { - if (bIsStar) { - szSomExp = szName + "[*]"; - return; - } - if (iIndexFlags == 0) { - szSomExp = szName; - return; - } - if (iIndexFlags == 1 || iIndexValue == 0) { - szSomExp = szName + "[" + - CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + - "]"; - } else if (iIndexFlags == 2) { - szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); - iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; - szSomExp += CFX_ByteString::FormatInteger(iIndexValue); - szSomExp += "]"; - } else { - szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); - iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; - szSomExp += CFX_ByteString::FormatInteger(iIndexValue); - szSomExp += "]"; - } -} -FX_BOOL CXFA_FM2JSContext::GetObjectByName( - FXJSE_HOBJECT hThis, - FXJSE_HVALUE accessorValue, - const CFX_ByteStringC& szAccessorName) { - FX_BOOL bFlags = FALSE; - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return bFlags; - } - IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); - XFA_RESOLVENODE_RS resoveNodeRS; - FX_DWORD dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; - int32_t iRet = pScriptContext->ResolveObjects( - pScriptContext->GetThisObject(), - CFX_WideString::FromUTF8(szAccessorName.GetCStr(), - szAccessorName.GetLength()), - resoveNodeRS, dwFlags); - if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( - resoveNodeRS.nodes.GetAt(0))); - bFlags = TRUE; - } - return bFlags; -} -int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis, - FXJSE_HVALUE hRefValue, - const CFX_ByteStringC& bsSomExp, - XFA_RESOLVENODE_RS& resoveNodeRS, - FX_BOOL bdotAccessor, - FX_BOOL bHasNoResolveName) { - CFX_WideString wsSomExpression = - CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); - int32_t iRet = -1; - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - CXFA_Document* pDoc = pContext->GetDocument(); - if (!pDoc) { - return iRet; - } - IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); - CXFA_Object* pNode = NULL; - FX_DWORD dFlags = 0UL; - if (bdotAccessor) { - if (FXJSE_Value_IsNull(hRefValue)) { - pNode = pScriptContext->GetThisObject(); - dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; - } else { - pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); - FXSYS_assert(pNode); - if (bHasNoResolveName) { - CFX_WideString wsName; - if (CXFA_Node* pXFANode = pNode->AsNode()) { - pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - } - if (wsName.IsEmpty()) { - CFX_WideStringC className; - pNode->GetClassName(className); - wsName = FX_WSTRC(L"#") + className; - } - wsSomExpression = wsName + wsSomExpression; - dFlags = XFA_RESOLVENODE_Siblings; - } else { - dFlags = (bsSomExp == "*") - ? (XFA_RESOLVENODE_Children) - : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | - XFA_RESOLVENODE_Properties); - } - } - } else { - pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); - dFlags = XFA_RESOLVENODE_AnyChild; - } - iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression, resoveNodeRS, - dFlags); - return iRet; -} -void CXFA_FM2JSContext::ParseResolveResult( - FXJSE_HOBJECT hThis, - const XFA_RESOLVENODE_RS& resoveNodeRS, - FXJSE_HVALUE hParentValue, - FXJSE_HVALUE*& resultValues, - int32_t& iSize, - FX_BOOL& bAttribute) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hRuntime = pContext->GetScriptRuntime(); - iSize = 0; - resultValues = NULL; - if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - bAttribute = FALSE; - iSize = resoveNodeRS.nodes.GetSize(); - resultValues = FX_Alloc(FXJSE_HVALUE, iSize); - for (int32_t i = 0; i < iSize; i++) { - resultValues[i] = FXJSE_Value_Create(hRuntime); - FXJSE_Value_Set( - resultValues[i], - pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( - resoveNodeRS.nodes.GetAt(i))); - } - } else { - CXFA_HVALUEArray objectProperties(hRuntime); - int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); - bAttribute = (iRet == 0); - if (bAttribute) { - if (FXJSE_Value_IsObject(hParentValue)) { - iSize = 1; - resultValues = FX_Alloc(FXJSE_HVALUE, 1); - resultValues[0] = FXJSE_Value_Create(hRuntime); - FXJSE_Value_Set(resultValues[0], hParentValue); - } - } else { - iSize = iRet; - resultValues = FX_Alloc(FXJSE_HVALUE, iSize); - for (int32_t i = 0; i < iSize; i++) { - resultValues[i] = FXJSE_Value_Create(hRuntime); - FXJSE_Value_Set(resultValues[i], objectProperties[i]); - } - } - } -} -int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis, - FXJSE_HVALUE hValue) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - int32_t iValue = 0; - if (FXJSE_Value_IsArray(hValue)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(hValue, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(hValue, 2, jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, newProperty); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); - } - iValue = HValueToInteger(hThis, newProperty); - FXJSE_Value_Release(newProperty); - FXJSE_Value_Release(jsobjectValue); - FXJSE_Value_Release(propertyValue); - return iValue; - } else if (FXJSE_Value_IsObject(hValue)) { - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(hValue, newProperty); - iValue = HValueToInteger(hThis, newProperty); - FXJSE_Value_Release(newProperty); - return iValue; - } else if (FXJSE_Value_IsUTF8String(hValue)) { - CFX_ByteString szValue; - FXJSE_Value_ToUTF8String(hValue, szValue); - iValue = FXSYS_atoi(szValue); - } else { - iValue = FXJSE_Value_ToInteger(hValue); - } - return iValue; -} -FX_DOUBLE CXFA_FM2JSContext::StringToDouble( - const CFX_ByteStringC& szStringVal) { - return XFA_ByteStringToDouble(szStringVal); -} -FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis, - FXJSE_HVALUE arg) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - FX_FLOAT fRet = 0.0f; - if (FXJSE_Value_IsArray(arg)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, newProperty); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); - } - fRet = HValueToFloat(hThis, newProperty); - FXJSE_Value_Release(newProperty); - FXJSE_Value_Release(jsobjectValue); - FXJSE_Value_Release(propertyValue); - } else if (FXJSE_Value_IsObject(arg)) { - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(arg, newProperty); - fRet = HValueToFloat(hThis, newProperty); - FXJSE_Value_Release(newProperty); - } else if (FXJSE_Value_IsUTF8String(arg)) { - CFX_ByteString bsOutput; - FXJSE_Value_ToUTF8String(arg, bsOutput); - fRet = (FX_FLOAT)StringToDouble(bsOutput); - } else if (FXJSE_Value_IsUndefined(arg)) { - fRet = 0; - } else { - fRet = FXJSE_Value_ToFloat(arg); - } - return fRet; -} -FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis, - FXJSE_HVALUE arg) { - CXFA_FM2JSContext* pContext = - (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); - FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime(); - FX_DOUBLE dRet = 0; - if (FXJSE_Value_IsArray(arg)) { - FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE jsobjectValue = FXJSE_Value_Create(hruntime); - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue); - FXJSE_Value_GetObjectPropByIdx(arg, 2, jsobjectValue); - if (FXJSE_Value_IsNull(propertyValue)) { - GetObjectDefaultValue(jsobjectValue, newProperty); - } else { - CFX_ByteString propertyStr; - FXJSE_Value_ToUTF8String(propertyValue, propertyStr); - FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr, newProperty); - } - dRet = HValueToDouble(hThis, newProperty); - FXJSE_Value_Release(newProperty); - FXJSE_Value_Release(jsobjectValue); - FXJSE_Value_Release(propertyValue); - } else if (FXJSE_Value_IsObject(arg)) { - FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); - GetObjectDefaultValue(arg, newProperty); - dRet = HValueToDouble(hThis, newProperty); - FXJSE_Value_Release(newProperty); - } else if (FXJSE_Value_IsUTF8String(arg)) { - CFX_ByteString bsOutput; - FXJSE_Value_ToUTF8String(arg, bsOutput); - dRet = StringToDouble(bsOutput); - } else if (FXJSE_Value_IsUndefined(arg)) { - dRet = 0; - } else { - dRet = FXJSE_Value_ToDouble(arg); - } - return dRet; -} -void CXFA_FM2JSContext::HValueToUTF8String(FXJSE_HVALUE arg, - CFX_ByteString& szOutputString) { - if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { - szOutputString = ""; - } else if (FXJSE_Value_IsBoolean(arg)) { - szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; - } else { - szOutputString = ""; - FXJSE_Value_ToUTF8String(arg, szOutputString); - } -} -static FXJSE_FUNCTION formcalc_fm2js_functions[] = { - {"Abs", CXFA_FM2JSContext::Abs}, - {"Avg", CXFA_FM2JSContext::Avg}, - {"Ceil", CXFA_FM2JSContext::Ceil}, - {"Count", CXFA_FM2JSContext::Count}, - {"Floor", CXFA_FM2JSContext::Floor}, - {"Max", CXFA_FM2JSContext::Max}, - {"Min", CXFA_FM2JSContext::Min}, - {"Mod", CXFA_FM2JSContext::Mod}, - {"Round", CXFA_FM2JSContext::Round}, - {"Sum", CXFA_FM2JSContext::Sum}, - {"Date", CXFA_FM2JSContext::Date}, - {"Date2Num", CXFA_FM2JSContext::Date2Num}, - {"DateFmt", CXFA_FM2JSContext::DateFmt}, - {"IsoDate2Num", CXFA_FM2JSContext::IsoDate2Num}, - {"IsoTime2Num", CXFA_FM2JSContext::IsoTime2Num}, - {"LocalDateFmt", CXFA_FM2JSContext::LocalDateFmt}, - {"LocalTimeFmt", CXFA_FM2JSContext::LocalTimeFmt}, - {"Num2Date", CXFA_FM2JSContext::Num2Date}, - {"Num2GMTime", CXFA_FM2JSContext::Num2GMTime}, - {"Num2Time", CXFA_FM2JSContext::Num2Time}, - {"Time", CXFA_FM2JSContext::Time}, - {"Time2Num", CXFA_FM2JSContext::Time2Num}, - {"TimeFmt", CXFA_FM2JSContext::TimeFmt}, - {"Apr", CXFA_FM2JSContext::Apr}, - {"Cterm", CXFA_FM2JSContext::CTerm}, - {"FV", CXFA_FM2JSContext::FV}, - {"Ipmt", CXFA_FM2JSContext::IPmt}, - {"NPV", CXFA_FM2JSContext::NPV}, - {"Pmt", CXFA_FM2JSContext::Pmt}, - {"PPmt", CXFA_FM2JSContext::PPmt}, - {"PV", CXFA_FM2JSContext::PV}, - {"Rate", CXFA_FM2JSContext::Rate}, - {"Term", CXFA_FM2JSContext::Term}, - {"Choose", CXFA_FM2JSContext::Choose}, - {"Exists", CXFA_FM2JSContext::Exists}, - {"HasValue", CXFA_FM2JSContext::HasValue}, - {"Oneof", CXFA_FM2JSContext::Oneof}, - {"Within", CXFA_FM2JSContext::Within}, - {"If", CXFA_FM2JSContext::If}, - {"Eval", CXFA_FM2JSContext::Eval}, - {"Translate", CXFA_FM2JSContext::eval_translation}, - {"Ref", CXFA_FM2JSContext::Ref}, - {"UnitType", CXFA_FM2JSContext::UnitType}, - {"UnitValue", CXFA_FM2JSContext::UnitValue}, - {"At", CXFA_FM2JSContext::At}, - {"Concat", CXFA_FM2JSContext::Concat}, - {"Decode", CXFA_FM2JSContext::Decode}, - {"Encode", CXFA_FM2JSContext::Encode}, - {"Format", CXFA_FM2JSContext::Format}, - {"Left", CXFA_FM2JSContext::Left}, - {"Len", CXFA_FM2JSContext::Len}, - {"Lower", CXFA_FM2JSContext::Lower}, - {"Ltrim", CXFA_FM2JSContext::Ltrim}, - {"Parse", CXFA_FM2JSContext::Parse}, - {"Replace", CXFA_FM2JSContext::Replace}, - {"Right", CXFA_FM2JSContext::Right}, - {"Rtrim", CXFA_FM2JSContext::Rtrim}, - {"Space", CXFA_FM2JSContext::Space}, - {"Str", CXFA_FM2JSContext::Str}, - {"Stuff", CXFA_FM2JSContext::Stuff}, - {"Substr", CXFA_FM2JSContext::Substr}, - {"Uuid", CXFA_FM2JSContext::Uuid}, - {"Upper", CXFA_FM2JSContext::Upper}, - {"WordNum", CXFA_FM2JSContext::WordNum}, - {"Get", CXFA_FM2JSContext::Get}, - {"Post", CXFA_FM2JSContext::Post}, - {"Put", CXFA_FM2JSContext::Put}, - {"positive_operator", CXFA_FM2JSContext::positive_operator}, - {"negative_operator", CXFA_FM2JSContext::negative_operator}, - {"logical_or_operator", CXFA_FM2JSContext::logical_or_operator}, - {"logical_and_operator", CXFA_FM2JSContext::logical_and_operator}, - {"logical_not_operator", CXFA_FM2JSContext::logical_not_operator}, - {"equality_operator", CXFA_FM2JSContext::equality_operator}, - {"notequality_operator", CXFA_FM2JSContext::notequality_operator}, - {"less_operator", CXFA_FM2JSContext::less_operator}, - {"lessequal_operator", CXFA_FM2JSContext::lessequal_operator}, - {"greater_operator", CXFA_FM2JSContext::greater_operator}, - {"greaterequal_operator", CXFA_FM2JSContext::greaterequal_operator}, - {"plus_operator", CXFA_FM2JSContext::plus_operator}, - {"minus_operator", CXFA_FM2JSContext::minus_operator}, - {"multiple_operator", CXFA_FM2JSContext::multiple_operator}, - {"divide_operator", CXFA_FM2JSContext::divide_operator}, - {"assign_value_operator", CXFA_FM2JSContext::assign_value_operator}, - {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, - {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, - {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, - {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, - {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, - {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, - {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, - {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, -}; -CXFA_FM2JSContext::CXFA_FM2JSContext() - : m_hFMClass(nullptr), m_pDocument(nullptr) { - FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); -} -CXFA_FM2JSContext::~CXFA_FM2JSContext() { - m_pDocument = NULL; - if (m_hValue) { - FXJSE_Value_Release(m_hValue); - m_hValue = NULL; - } - m_hScriptRuntime = NULL; -} -CXFA_FM2JSContext* CXFA_FM2JSContext::Create() { - return new CXFA_FM2JSContext; -} -void CXFA_FM2JSContext::Initialize(FXJSE_HRUNTIME hScriptRuntime, - FXJSE_HCONTEXT hScriptContext, - CXFA_Document* pDoc) { - m_pDocument = pDoc; - m_hScriptRuntime = hScriptRuntime; - m_fmClass.name = "XFA_FM2JS_FormCalcClass"; - m_fmClass.constructor = NULL; - m_fmClass.properties = NULL; - m_fmClass.methods = formcalc_fm2js_functions; - m_fmClass.propNum = 0; - m_fmClass.methNum = - sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); - m_hFMClass = FXJSE_DefineClass(hScriptContext, &m_fmClass); - m_hValue = FXJSE_Value_Create(hScriptRuntime); - FXJSE_Value_SetNull(m_hValue); - FXJSE_Value_SetObject(m_hValue, this, m_hFMClass); -} -void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { - FXJSE_Value_Set(hValue, m_hValue); -} -void CXFA_FM2JSContext::Release() { - delete this; -} -void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { - IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); - FXSYS_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); - va_end(arg_ptr); - FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); -} diff --git a/xfa/src/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/src/fxfa/fm2js/xfa_fm2jscontext.h deleted file mode 100644 index 62c2a1e895..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fm2jscontext.h +++ /dev/null @@ -1,453 +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_SRC_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ - -#include "xfa/src/fxfa/parser/xfa_script.h" - -class CXFA_FM2JSContext { - public: - static void Abs(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Avg(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Ceil(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Count(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Floor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Max(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Min(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Mod(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Round(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Sum(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Date(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Date2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void DateFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void IsoDate2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void IsoTime2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void LocalDateFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void LocalTimeFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Num2Date(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Num2GMTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Num2Time(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Time(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Time2Num(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void TimeFmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - - static FX_BOOL IsIsoDateFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iStyle, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay); - static FX_BOOL IsIsoTimeFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iHour, - int32_t& iMinute, - int32_t& iSecond, - int32_t& iMilliSecond, - int32_t& iZoneHour, - int32_t& iZoneMinute); - static FX_BOOL IsIsoDateTimeFormat(const FX_CHAR* pData, - int32_t iLength, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay, - int32_t& iHour, - int32_t& iMinute, - int32_t& iSecond, - int32_t& iMillionSecond, - int32_t& iZoneHour, - int32_t& iZoneMinute); - static FX_BOOL Local2IsoDate(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szDate, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strIsoDate); - static FX_BOOL Local2IsoTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strIsoTime); - static FX_BOOL IsoDate2Local(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szDate, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strLocalDate); - static FX_BOOL IsoTime2Local(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strLocalTime); - static FX_BOOL GetGMTTime(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - CFX_ByteString& strGMTTime); - static int32_t DateString2Num(const CFX_ByteStringC& szDateString); - static void GetLocalDateFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat, - FX_BOOL bStandard); - static void GetLocalTimeFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat, - FX_BOOL bStandard); - static void GetStandardDateFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat); - static void GetStandardTimeFormat(FXJSE_HOBJECT hThis, - int32_t iStyle, - const CFX_ByteStringC& szLocalStr, - CFX_ByteString& strFormat); - - static void Num2AllTime(FXJSE_HOBJECT hThis, - int32_t iTime, - const CFX_ByteStringC& szFormat, - const CFX_ByteStringC& szLocale, - FX_BOOL bGM, - CFX_ByteString& strTime); - static void GetLocalTimeZone(int32_t& iHour, int32_t& iMin, int32_t& iSec); - - static void Apr(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void CTerm(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void FV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void IPmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void NPV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Pmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void PPmt(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void PV(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Rate(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Term(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Choose(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Exists(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void HasValue(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Oneof(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Within(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void If(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Eval(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Ref(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void UnitType(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void UnitValue(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - - static void At(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Concat(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Decode(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void DecodeURL(const CFX_ByteStringC& szURLString, - CFX_ByteTextBuf& szResultBuf); - static void DecodeHTML(const CFX_ByteStringC& szHTMLString, - CFX_ByteTextBuf& szResultBuf); - static void DecodeXML(const CFX_ByteStringC& szXMLString, - CFX_ByteTextBuf& szResultBuf); - static void Encode(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void EncodeURL(const CFX_ByteStringC& szURLString, - CFX_ByteTextBuf& szResultBuf); - static void EncodeHTML(const CFX_ByteStringC& szHTMLString, - CFX_ByteTextBuf& szResultBuf); - static void EncodeXML(const CFX_ByteStringC& szXMLString, - CFX_ByteTextBuf& szResultBuf); - static FX_BOOL HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode); - static FX_BOOL HTMLCode2STR(uint32_t iCode, CFX_WideString& wsHTMLReserve); - static void Format(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Left(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Len(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Lower(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Ltrim(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Parse(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Replace(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Right(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Rtrim(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Space(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Str(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Stuff(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Substr(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Uuid(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Upper(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void WordNum(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void TrillionUS(const CFX_ByteStringC& szData, - CFX_ByteTextBuf& strBuf); - static void WordUS(const CFX_ByteStringC& szData, - int32_t iStyle, - CFX_ByteTextBuf& strBuf); - - static void Get(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Post(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void Put(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void assign_value_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void logical_or_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void logical_and_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void equality_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void notequality_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static FX_BOOL fm_ref_equal(FXJSE_HOBJECT hThis, CFXJSE_Arguments& args); - static void less_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void lessequal_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void greater_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void greaterequal_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void plus_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void minus_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void multiple_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void divide_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void positive_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void negative_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void logical_not_operator(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void dot_accessor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void dotdot_accessor(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void eval_translation(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void is_fm_object(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void is_fm_array(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void get_fm_value(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void get_fm_jsobj(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void fm_var_filter(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static void concat_fm_object(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - - static int32_t hvalue_get_array_length(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg); - static FX_BOOL simpleValueCompare(FXJSE_HOBJECT hThis, - FXJSE_HVALUE firstValue, - FXJSE_HVALUE secondValue); - static void unfoldArgs(FXJSE_HOBJECT hThis, - CFXJSE_Arguments& args, - FXJSE_HVALUE*& resultValues, - int32_t& iCount, - int32_t iStart = 0); - static void GetObjectDefaultValue(FXJSE_HVALUE hObjectValue, - FXJSE_HVALUE hDefaultValue); - static FX_BOOL SetObjectDefaultValue(FXJSE_HVALUE hObjectValue, - FXJSE_HVALUE hNewValue); - static void GenerateSomExpression(const CFX_ByteStringC& szName, - int32_t iIndexFlags, - int32_t iIndexValue, - FX_BOOL bIsStar, - CFX_ByteString& szSomExp); - static FX_BOOL GetObjectByName(FXJSE_HOBJECT hThis, - FXJSE_HVALUE accessorValue, - const CFX_ByteStringC& szAccessorName); - static int32_t ResolveObjects(FXJSE_HOBJECT hThis, - FXJSE_HVALUE hParentValue, - const CFX_ByteStringC& bsSomExp, - XFA_RESOLVENODE_RS& resoveNodeRS, - FX_BOOL bdotAccessor = TRUE, - FX_BOOL bHasNoResolveName = FALSE); - static void ParseResolveResult(FXJSE_HOBJECT hThis, - const XFA_RESOLVENODE_RS& resoveNodeRS, - FXJSE_HVALUE hParentValue, - FXJSE_HVALUE*& resultValues, - int32_t& iSize, - FX_BOOL& bAttribute); - - static FXJSE_HVALUE GetSimpleHValue(FXJSE_HOBJECT hThis, - CFXJSE_Arguments& args, - uint32_t index); - static FX_BOOL HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); - static int32_t HValueToInteger(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); - static FX_DOUBLE StringToDouble(const CFX_ByteStringC& szStringVal); - static FX_FLOAT HValueToFloat(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); - static FX_DOUBLE HValueToDouble(FXJSE_HOBJECT hThis, FXJSE_HVALUE hValue); - static void HValueToUTF8String(FXJSE_HVALUE hValue, - CFX_ByteString& outputValue); - CXFA_FM2JSContext(); - ~CXFA_FM2JSContext(); - static CXFA_FM2JSContext* Create(); - void Initialize(FXJSE_HRUNTIME hScriptRuntime, - FXJSE_HCONTEXT hScriptContext, - CXFA_Document* pDoc); - void GlobalPropertyGetter(FXJSE_HVALUE hValue); - void Release(); - FXJSE_HRUNTIME GetScriptRuntime() const { return m_hScriptRuntime; } - CXFA_Document* GetDocument() const { return m_pDocument; } - void ThrowScriptErrorMessage(int32_t iStringID, ...); - - private: - FXJSE_HRUNTIME m_hScriptRuntime; - FXJSE_CLASS m_fmClass; - FXJSE_HCLASS m_hFMClass; - FXJSE_HVALUE m_hValue; - CXFA_Document* m_pDocument; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_fmparse.cpp b/xfa/src/fxfa/fm2js/xfa_fmparse.cpp deleted file mode 100644 index 7950abbd16..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fmparse.cpp +++ /dev/null @@ -1,1051 +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/src/fxfa/fm2js/xfa_fmparse.h" - -#include <memory> - -CXFA_FMParse::CXFA_FMParse() : m_pToken(nullptr), m_pErrorInfo(0) {} - -int32_t CXFA_FMParse::Init(const CFX_WideStringC& wsFormcalc, - CXFA_FMErrorInfo* pErrorInfo) { - m_pErrorInfo = pErrorInfo; - m_lexer.reset(new CXFA_FMLexer(wsFormcalc, m_pErrorInfo)); - return 0; -} - -void CXFA_FMParse::NextToken() { - m_pToken = m_lexer->NextToken(); - while (m_pToken->m_type == TOKreserver) { - if (m_lexer->HasError()) { - break; - } - m_pToken = m_lexer->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()); - } - NextToken(); -} - -void CXFA_FMParse::Error(FX_DWORD lineNum, XFA_FM_ERRMSG 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); - va_end(ap); -} - -CFX_PtrArray* CXFA_FMParse::ParseTopExpression() { - std::unique_ptr<CXFA_FMExpression> e; - CFX_PtrArray* expression = new CFX_PtrArray(); - while (1) { - if (m_pToken->m_type == TOKeof || m_pToken->m_type == TOKendfunc || - m_pToken->m_type == TOKendif || m_pToken->m_type == TOKelseif || - m_pToken->m_type == TOKelse || m_pToken->m_type == TOKreserver) { - return expression; - } - - if (m_pToken->m_type == TOKfunc) { - e.reset(ParseFunction()); - if (e) { - expression->Add(e.release()); - } else { - break; - } - } else { - e.reset(ParseExpression()); - if (e) { - expression->Add(e.release()); - } else { - break; - } - } - } - return expression; -} - -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; - FX_DWORD 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, - ws_TempString.c_str()); - } else { - ident = m_pToken->m_wstring; - NextToken(); - } - Check(TOKlparen); - if (m_pToken->m_type == TOKrparen) { - NextToken(); - } else { - pArguments.reset(new CFX_WideStringCArray()); - CFX_WideStringC p; - while (1) { - if (m_pToken->m_type == TOKidentifier) { - p = m_pToken->m_wstring; - pArguments->Add(p); - NextToken(); - if (m_pToken->m_type == TOKcomma) { - NextToken(); - continue; - } else if (m_pToken->m_type == TOKrparen) { - NextToken(); - break; - } else { - Check(TOKrparen); - break; - } - } else { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, - ws_TempString.c_str()); - NextToken(); - break; - } - } - } - Check(TOKdo); - if (m_pToken->m_type == TOKendfunc) { - NextToken(); - } else { - pExpressions.reset(ParseTopExpression()); - Check(TOKendfunc); - } - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMFunctionDefinition(line, 0, ident, pArguments.release(), - pExpressions.release())); - } else { - if (pArguments) - pArguments->RemoveAll(); - if (pExpressions) { - for (int i = 0; i < pExpressions->GetSize(); ++i) - delete static_cast<CXFA_FMExpression*>(pExpressions->GetAt(i)); - } - } - return e.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseExpression() { - std::unique_ptr<CXFA_FMExpression> e; - FX_DWORD line = m_pToken->m_uLinenum; - switch (m_pToken->m_type) { - case TOKvar: - e.reset(ParseVarExpression()); - break; - case TOKnull: - case TOKnumber: - case TOKstring: - case TOKplus: - case TOKminus: - case TOKksnot: - case TOKidentifier: - case TOKlparen: - e.reset(ParseExpExpression()); - break; - case TOKif: - e.reset(ParseIfExpression()); - break; - case TOKwhile: - e.reset(ParseWhileExpression()); - break; - case TOKfor: - e.reset(ParseForExpression()); - break; - case TOKforeach: - e.reset(ParseForeachExpression()); - break; - case TOKdo: - e.reset(ParseDoExpression()); - break; - case TOKbreak: - e.reset(new CXFA_FMBreakExpression(line)); - NextToken(); - break; - case TOKcontinue: - e.reset(new CXFA_FMContinueExpression(line)); - NextToken(); - break; - default: - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, - ws_TempString.c_str()); - NextToken(); - break; - } - return e.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() { - std::unique_ptr<CXFA_FMExpression> e; - CFX_WideStringC ident; - FX_DWORD 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, - ws_TempString.c_str()); - } else { - ident = m_pToken->m_wstring; - NextToken(); - } - if (m_pToken->m_type == TOKassign) { - NextToken(); - e.reset(ParseExpExpression()); - } - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMVarExpression(line, ident, e.release())); - } else { - e.reset(); - } - return e.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseSimpleExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); - while (m_pToken->m_type == TOKassign) { - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - pExp1.reset(new CXFA_FMAssignExpression(line, TOKassign, pExp1.release(), - pExp2.release())); - } else { - pExp1.reset(); - } - } - return pExp1.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseExpExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseSimpleExpression()); - std::unique_ptr<CXFA_FMExpression> e; - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMExpExpression(line, pExp1.release())); - } else { - e.reset(); - } - return e.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseLogicalOrExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseLogicalAndExpression()); - for (;;) { - switch (m_pToken->m_type) { - case TOKor: - case TOKksor: { - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> e2( - ParseLogicalAndExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMLogicalOrExpression(line, TOKor, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - } - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseLogicalAndExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseEqualityExpression()); - for (;;) { - switch (m_pToken->m_type) { - case TOKand: - case TOKksand: { - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> e2(ParseEqualityExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMLogicalAndExpression(line, TOKand, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - } - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseEqualityExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseRelationalExpression()); - for (;;) { - std::unique_ptr<CXFA_FMSimpleExpression> e2; - switch (m_pToken->m_type) { - case TOKeq: - case TOKkseq: - NextToken(); - e2.reset(ParseRelationalExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMEqualityExpression(line, TOKeq, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - case TOKne: - case TOKksne: - NextToken(); - e2.reset(ParseRelationalExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMEqualityExpression(line, TOKne, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseRelationalExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseAddtiveExpression()); - for (;;) { - std::unique_ptr<CXFA_FMSimpleExpression> e2; - switch (m_pToken->m_type) { - case TOKlt: - case TOKkslt: - NextToken(); - e2.reset(ParseAddtiveExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMRelationalExpression(line, TOKlt, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - case TOKgt: - case TOKksgt: - NextToken(); - e2.reset(ParseAddtiveExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMRelationalExpression(line, TOKgt, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - case TOKle: - case TOKksle: - NextToken(); - e2.reset(ParseAddtiveExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMRelationalExpression(line, TOKle, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - case TOKge: - case TOKksge: - NextToken(); - e2.reset(ParseAddtiveExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMRelationalExpression(line, TOKge, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseAddtiveExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseMultiplicativeExpression()); - for (;;) { - std::unique_ptr<CXFA_FMSimpleExpression> e2; - switch (m_pToken->m_type) { - case TOKplus: - NextToken(); - e2.reset(ParseMultiplicativeExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMAdditiveExpression(line, TOKplus, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - case TOKminus: - NextToken(); - e2.reset(ParseMultiplicativeExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMAdditiveExpression(line, TOKminus, e1.release(), - e2.release())); - } else { - e1.reset(); - } - continue; - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseMultiplicativeExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> e1(ParseUnaryExpression()); - for (;;) { - std::unique_ptr<CXFA_FMSimpleExpression> e2; - switch (m_pToken->m_type) { - case TOKmul: - NextToken(); - e2.reset(ParseUnaryExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMMultiplicativeExpression( - line, TOKmul, e1.release(), e2.release())); - } else { - e1.reset(); - } - continue; - case TOKdiv: - NextToken(); - e2.reset(ParseUnaryExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e1.reset(new CXFA_FMMultiplicativeExpression( - line, TOKdiv, e1.release(), e2.release())); - } else { - e1.reset(); - } - continue; - default: - break; - } - break; - } - return e1.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseUnaryExpression() { - std::unique_ptr<CXFA_FMSimpleExpression> e; - FX_DWORD line = m_pToken->m_uLinenum; - switch (m_pToken->m_type) { - case TOKplus: - NextToken(); - e.reset(ParseUnaryExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMPosExpression(line, e.release())); - } else { - e.reset(); - } - break; - case TOKminus: - NextToken(); - e.reset(ParseUnaryExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMNegExpression(line, e.release())); - } else { - e.reset(); - } - break; - case TOKksnot: - NextToken(); - e.reset(ParseUnaryExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMNotExpression(line, e.release())); - } else { - e.reset(); - } - break; - default: - e.reset(ParsePrimaryExpression()); - break; - } - return e.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParsePrimaryExpression() { - std::unique_ptr<CXFA_FMSimpleExpression> e; - FX_DWORD line = m_pToken->m_uLinenum; - switch (m_pToken->m_type) { - case TOKnumber: - e.reset(new CXFA_FMNumberExpression(line, m_pToken->m_wstring)); - NextToken(); - break; - case TOKstring: - e.reset(new CXFA_FMStringExpression(line, m_pToken->m_wstring)); - NextToken(); - break; - case TOKidentifier: { - CFX_WideStringC wsIdentifier(m_pToken->m_wstring); - NextToken(); - if (m_pToken->m_type == TOKlbracket) { - CXFA_FMSimpleExpression* s = ParseIndexExpression(); - if (s) { - e.reset(new CXFA_FMDotAccessorExpression(line, NULL, TOKdot, - wsIdentifier, s)); - } - NextToken(); - } else { - e.reset(new CXFA_FMIdentifierExpressionn(line, wsIdentifier)); - } - } break; - case TOKif: - e.reset(new CXFA_FMIdentifierExpressionn(line, m_pToken->m_wstring)); - NextToken(); - break; - case TOKnull: - e.reset(new CXFA_FMNullExpression(line)); - NextToken(); - break; - case TOKlparen: - e.reset(ParseParenExpression()); - break; - default: - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, - ws_TempString.c_str()); - NextToken(); - break; - } - e.reset(ParsePostExpression(e.release())); - if (!(m_pErrorInfo->message.IsEmpty())) - e.reset(); - return e.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression( - CXFA_FMSimpleExpression* e) { - FX_DWORD line = m_pToken->m_uLinenum; - while (1) { - switch (m_pToken->m_type) { - case TOKlparen: { - NextToken(); - std::unique_ptr<CFX_PtrArray> pArray; - if (m_pToken->m_type != TOKrparen) { - pArray.reset(new CFX_PtrArray()); - while (m_pToken->m_type != TOKrparen) { - CXFA_FMSimpleExpression* e = ParseSimpleExpression(); - if (e) { - pArray->Add(e); - } - if (m_pToken->m_type == TOKcomma) { - NextToken(); - } else if (m_pToken->m_type == TOKeof || - m_pToken->m_type == TOKreserver) { - break; - } - } - if (m_pToken->m_type != TOKrparen) { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, - XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); - } - } - if (m_pErrorInfo->message.IsEmpty()) { - e = new CXFA_FMCallExpression(line, e, pArray.release(), FALSE); - NextToken(); - if (m_pToken->m_type != TOKlbracket) { - continue; - } - CXFA_FMSimpleExpression* s = ParseIndexExpression(); - if (s) { - e = new CXFA_FMDotAccessorExpression(line, e, TOKcall, - FX_WSTRC(L""), s); - } else { - delete e; - e = nullptr; - } - } else { - if (pArray) { - for (int32_t i = 0; i < pArray->GetSize(); ++i) - delete static_cast<CXFA_FMSimpleExpression*>(pArray->GetAt(i)); - } - delete e; - e = nullptr; - } - } break; - case TOKdot: - NextToken(); - if (m_pToken->m_type == TOKidentifier) { - CFX_WideStringC tempStr = m_pToken->m_wstring; - FX_DWORD tempLine = m_pToken->m_uLinenum; - NextToken(); - if (m_pToken->m_type == TOKlparen) { - CXFA_FMSimpleExpression* pExpAccessor; - CXFA_FMSimpleExpression* pExpCall; - pExpAccessor = e; - NextToken(); - std::unique_ptr<CFX_PtrArray> pArray; - if (m_pToken->m_type != TOKrparen) { - pArray.reset(new CFX_PtrArray()); - while (m_pToken->m_type != TOKrparen) { - CXFA_FMSimpleExpression* exp = ParseSimpleExpression(); - pArray->Add(exp); - if (m_pToken->m_type == TOKcomma) { - NextToken(); - } else if (m_pToken->m_type == TOKeof || - m_pToken->m_type == TOKreserver) { - break; - } - } - if (m_pToken->m_type != TOKrparen) { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, - XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); - } - } - if (m_pErrorInfo->message.IsEmpty()) { - CXFA_FMSimpleExpression* pIdentifier = - new CXFA_FMIdentifierExpressionn(tempLine, tempStr); - pExpCall = new CXFA_FMCallExpression(line, pIdentifier, - pArray.release(), TRUE); - e = new CXFA_FMMethodCallExpression(line, pExpAccessor, pExpCall); - NextToken(); - if (m_pToken->m_type != TOKlbracket) { - continue; - } - CXFA_FMSimpleExpression* s = ParseIndexExpression(); - if (s) { - e = new CXFA_FMDotAccessorExpression(line, e, TOKcall, - FX_WSTRC(L""), s); - } else { - delete e; - e = nullptr; - } - } else { - if (pArray) { - for (int32_t i = 0; i < pArray->GetSize(); ++i) { - delete static_cast<CXFA_FMSimpleExpression*>( - pArray->GetAt(i)); - } - } - delete e; - e = nullptr; - } - } else if (m_pToken->m_type == TOKlbracket) { - std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); - if (!(m_pErrorInfo->message.IsEmpty())) { - delete e; - return nullptr; - } - e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdot, tempStr, - s.release()); - } else { - CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( - tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); - e = new CXFA_FMDotAccessorExpression(line, e, TOKdot, tempStr, s); - continue; - } - } else { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, - ws_TempString.c_str()); - return e; - } - break; - case TOKdotdot: - NextToken(); - if (m_pToken->m_type == TOKidentifier) { - CFX_WideStringC tempStr = m_pToken->m_wstring; - FX_DWORD tempLine = m_pToken->m_uLinenum; - NextToken(); - if (m_pToken->m_type == TOKlbracket) { - std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); - if (!(m_pErrorInfo->message.IsEmpty())) { - delete e; - return nullptr; - } - e = new CXFA_FMDotDotAccessorExpression(tempLine, e, TOKdotdot, - tempStr, s.release()); - } else { - CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( - tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); - e = new CXFA_FMDotDotAccessorExpression(line, e, TOKdotdot, tempStr, - s); - continue; - } - } else { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, - ws_TempString.c_str()); - return e; - } - break; - case TOKdotscream: - NextToken(); - if (m_pToken->m_type == TOKidentifier) { - CFX_WideStringC tempStr = m_pToken->m_wstring; - FX_DWORD tempLine = m_pToken->m_uLinenum; - NextToken(); - if (m_pToken->m_type == TOKlbracket) { - std::unique_ptr<CXFA_FMSimpleExpression> s(ParseIndexExpression()); - if (!(m_pErrorInfo->message.IsEmpty())) { - delete e; - return nullptr; - } - e = new CXFA_FMDotAccessorExpression(tempLine, e, TOKdotscream, - tempStr, s.release()); - } else { - CXFA_FMSimpleExpression* s = new CXFA_FMIndexExpression( - tempLine, ACCESSOR_NO_INDEX, NULL, FALSE); - e = new CXFA_FMDotAccessorExpression(line, e, TOKdotscream, tempStr, - s); - continue; - } - } else { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER, - ws_TempString.c_str()); - return e; - } - break; - case TOKdotstar: { - CXFA_FMSimpleExpression* s = - new CXFA_FMIndexExpression(line, ACCESSOR_NO_INDEX, NULL, FALSE); - e = new CXFA_FMDotAccessorExpression(line, e, TOKdotstar, - FX_WSTRC(L"*"), s); - } break; - default: - return e; - } - NextToken(); - } - return e; -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseIndexExpression() { - std::unique_ptr<CXFA_FMSimpleExpression> pExp; - FX_DWORD line = m_pToken->m_uLinenum; - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> s; - XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX; - if (m_pToken->m_type == TOKmul) { - pExp.reset( - 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, - XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); - pExp.reset(); - } - return pExp.release(); - } - if (m_pToken->m_type == TOKplus) { - accessorIndex = ACCESSOR_POSITIVE_INDEX; - NextToken(); - } else if (m_pToken->m_type == TOKminus) { - accessorIndex = ACCESSOR_NEGATIVE_INDEX; - NextToken(); - } - 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, - XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str()); - } else { - pExp.reset( - new CXFA_FMIndexExpression(line, accessorIndex, s.release(), FALSE)); - } - return pExp.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() { - Check(TOKlparen); - - if (m_pToken->m_type == TOKrparen) { - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_NON_EMPTY_EXPRESSION); - NextToken(); - return nullptr; - } - - FX_DWORD line = m_pToken->m_uLinenum; - std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression()); - - while (m_pToken->m_type == TOKassign) { - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression()); - if (m_pErrorInfo->message.IsEmpty()) { - pExp1.reset(new CXFA_FMAssignExpression(line, TOKassign, pExp1.release(), - pExp2.release())); - } else { - pExp1.reset(); - } - } - Check(TOKrparen); - return pExp1.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseBlockExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - CXFA_FMExpression* e = nullptr; - std::unique_ptr<CFX_PtrArray> expression(new CFX_PtrArray()); - while (1) { - switch (m_pToken->m_type) { - case TOKeof: - case TOKendif: - case TOKelseif: - case TOKelse: - case TOKendwhile: - case TOKendfor: - case TOKend: - case TOKendfunc: - case TOKreserver: - break; - case TOKfunc: - e = ParseFunction(); - if (e) { - expression->Add(e); - } - continue; - default: - e = ParseExpression(); - if (e) { - expression->Add(e); - } - continue; - } - break; - } - std::unique_ptr<CXFA_FMBlockExpression> pExp; - if (m_pErrorInfo->message.IsEmpty()) { - pExp.reset(new CXFA_FMBlockExpression(line, expression.release())); - } else { - for (int i = 0; i < expression->GetSize(); ++i) - delete static_cast<CXFA_FMExpression*>(expression->GetAt(i)); - } - return pExp.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseIfExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - const FX_WCHAR* pStartPos = m_lexer->SavePos(); - NextToken(); - Check(TOKlparen); - std::unique_ptr<CXFA_FMSimpleExpression> pExpression; - while (m_pToken->m_type != TOKrparen) { - pExpression.reset(ParseSimpleExpression()); - if (m_pToken->m_type != TOKcomma) - break; - NextToken(); - } - Check(TOKrparen); - if (m_pToken->m_type != TOKthen) { - m_lexer->SetCurrentLine(line); - m_pToken = new CXFA_FMToken(line); - m_pToken->m_type = TOKidentifier; - m_pToken->m_wstring = FX_WSTRC(L"if"); - m_lexer->SetToken(m_pToken); - m_lexer->RestorePos(pStartPos); - return ParseExpExpression(); - } - Check(TOKthen); - std::unique_ptr<CXFA_FMExpression> pIfExpression(ParseBlockExpression()); - std::unique_ptr<CXFA_FMExpression> pElseExpression; - switch (m_pToken->m_type) { - case TOKeof: - case TOKendif: - Check(TOKendif); - break; - case TOKif: - pElseExpression.reset(ParseIfExpression()); - Check(TOKendif); - break; - case TOKelseif: - pElseExpression.reset(ParseIfExpression()); - break; - case TOKelse: - NextToken(); - pElseExpression.reset(ParseBlockExpression()); - Check(TOKendif); - break; - default: - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IFEND, ws_TempString.c_str()); - NextToken(); - break; - } - std::unique_ptr<CXFA_FMIfExpression> pExp; - if (m_pErrorInfo->message.IsEmpty()) { - pExp.reset(new CXFA_FMIfExpression(line, pExpression.release(), - pIfExpression.release(), - pElseExpression.release())); - } - return pExp.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseWhileExpression() { - FX_DWORD line = m_pToken->m_uLinenum; - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> pCondition(ParseParenExpression()); - Check(TOKdo); - std::unique_ptr<CXFA_FMExpression> pExpression(ParseBlockExpression()); - Check(TOKendwhile); - std::unique_ptr<CXFA_FMExpression> e; - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMWhileExpression(line, pCondition.release(), - pExpression.release())); - } - return e.release(); -} - -CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() { - std::unique_ptr<CXFA_FMSimpleExpression> e; - switch (m_pToken->m_type) { - case TOKidentifier: - e.reset(ParseSimpleExpression()); - break; - default: - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION, - ws_TempString.c_str()); - NextToken(); - break; - } - return e.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseForExpression() { - CFX_WideStringC wsVariant; - FX_DWORD 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, - XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); - } - wsVariant = m_pToken->m_wstring; - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> pAssignment; - if (m_pToken->m_type == TOKassign) { - NextToken(); - pAssignment.reset(ParseSimpleExpression()); - } else { - CFX_WideString ws_TempString = m_pToken->m_wstring; - Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, - XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); - } - int32_t iDirection = 0; - if (m_pToken->m_type == TOKupto) { - iDirection = 1; - } 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); - } - NextToken(); - std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression()); - std::unique_ptr<CXFA_FMSimpleExpression> pStep; - if (m_pToken->m_type == TOKstep) { - NextToken(); - pStep.reset(ParseSimpleExpression()); - } - Check(TOKdo); - std::unique_ptr<CXFA_FMExpression> pList(ParseBlockExpression()); - Check(TOKendfor); - std::unique_ptr<CXFA_FMExpression> e; - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMForExpression(line, wsVariant, pAssignment.release(), - pAccessor.release(), iDirection, - pStep.release(), pList.release())); - } - return e.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() { - std::unique_ptr<CXFA_FMExpression> e; - CFX_WideStringC wsIdentifier; - std::unique_ptr<CFX_PtrArray> pAccessors; - std::unique_ptr<CXFA_FMExpression> pList; - FX_DWORD 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, - XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str()); - } - wsIdentifier = m_pToken->m_wstring; - NextToken(); - 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, - ws_TempString.c_str()); - NextToken(); - } else { - pAccessors.reset(new CFX_PtrArray()); - while (m_pToken->m_type != TOKrparen) { - CXFA_FMSimpleExpression* s = ParseSimpleExpression(); - if (s) { - pAccessors->Add(s); - } - if (m_pToken->m_type == TOKcomma) { - NextToken(); - } else { - break; - } - } - Check(TOKrparen); - } - Check(TOKdo); - pList.reset(ParseBlockExpression()); - Check(TOKendfor); - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMForeachExpression( - line, wsIdentifier, pAccessors.release(), pList.release())); - } else { - if (pAccessors) { - for (int i = 0; i < pAccessors->GetSize(); ++i) - delete static_cast<CXFA_FMSimpleExpression*>(pAccessors->GetAt(i)); - } - } - return e.release(); -} - -CXFA_FMExpression* CXFA_FMParse::ParseDoExpression() { - std::unique_ptr<CXFA_FMExpression> e; - FX_DWORD line = m_pToken->m_uLinenum; - NextToken(); - e.reset(ParseBlockExpression()); - Check(TOKend); - if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMDoExpression(line, e.release())); - } else { - e.reset(); - } - return e.release(); -} diff --git a/xfa/src/fxfa/fm2js/xfa_fmparse.h b/xfa/src/fxfa/fm2js/xfa_fmparse.h deleted file mode 100644 index 7494cd0b83..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_fmparse.h +++ /dev/null @@ -1,53 +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_SRC_FXFA_FM2JS_XFA_FMPARSE_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_FMPARSE_H_ - -#include <memory> - -#include "xfa/src/fxfa/fm2js/xfa_expression.h" -#include "xfa/src/fxfa/fm2js/xfa_lexer.h" - -class CXFA_FMParse { - public: - CXFA_FMParse(); - int32_t Init(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); - void NextToken(); - void Check(XFA_FM_TOKEN op); - void Error(FX_DWORD lineNum, XFA_FM_ERRMSG msg, ...); - CFX_PtrArray* ParseTopExpression(); - CXFA_FMExpression* ParseFunction(); - CXFA_FMExpression* ParseExpression(); - CXFA_FMExpression* ParseVarExpression(); - CXFA_FMExpression* ParseExpExpression(); - CXFA_FMExpression* ParseBlockExpression(); - CXFA_FMExpression* ParseIfExpression(); - CXFA_FMExpression* ParseWhileExpression(); - CXFA_FMExpression* ParseForExpression(); - CXFA_FMExpression* ParseForeachExpression(); - CXFA_FMExpression* ParseDoExpression(); - CXFA_FMSimpleExpression* ParseParenExpression(); - CXFA_FMSimpleExpression* ParseSimpleExpression(); - CXFA_FMSimpleExpression* ParseSubassignmentInForExpression(); - CXFA_FMSimpleExpression* ParseLogicalOrExpression(); - CXFA_FMSimpleExpression* ParseLogicalAndExpression(); - CXFA_FMSimpleExpression* ParseEqualityExpression(); - CXFA_FMSimpleExpression* ParseRelationalExpression(); - CXFA_FMSimpleExpression* ParseAddtiveExpression(); - CXFA_FMSimpleExpression* ParseMultiplicativeExpression(); - CXFA_FMSimpleExpression* ParseUnaryExpression(); - CXFA_FMSimpleExpression* ParsePrimaryExpression(); - CXFA_FMSimpleExpression* ParsePostExpression(CXFA_FMSimpleExpression* e); - CXFA_FMSimpleExpression* ParseIndexExpression(); - - private: - std::unique_ptr<CXFA_FMLexer> m_lexer; - CXFA_FMToken* m_pToken; - CXFA_FMErrorInfo* m_pErrorInfo; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_FMPARSE_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_lexer.cpp b/xfa/src/fxfa/fm2js/xfa_lexer.cpp deleted file mode 100644 index f93fa839d3..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_lexer.cpp +++ /dev/null @@ -1,552 +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/src/fxfa/fm2js/xfa_lexer.h" - -#include "core/include/fxcrt/fx_ext.h" - -namespace { - -struct XFA_FMDChar { - static const FX_WCHAR* inc(const FX_WCHAR*& p) { - ++p; - return p; - } - static const FX_WCHAR* dec(const FX_WCHAR*& p) { - --p; - return p; - } - static uint16_t get(const FX_WCHAR* p) { return *p; } - static FX_BOOL isWhiteSpace(const FX_WCHAR* p) { - return (*p) == 0x09 || (*p) == 0x0b || (*p) == 0x0c || (*p) == 0x20; - } - static FX_BOOL isLineTerminator(const FX_WCHAR* p) { - return *p == 0x0A || *p == 0x0D; - } - static FX_BOOL isBinary(const FX_WCHAR* p) { - return (*p) >= '0' && (*p) <= '1'; - } - static FX_BOOL isOctal(const FX_WCHAR* p) { - return (*p) >= '0' && (*p) <= '7'; - } - static FX_BOOL isDigital(const FX_WCHAR* p) { - return (*p) >= '0' && (*p) <= '9'; - } - static FX_BOOL isHex(const FX_WCHAR* p) { - return isDigital(p) || ((*p) >= 'a' && (*p) <= 'f') || - ((*p) >= 'A' && (*p) <= 'F'); - } - static FX_BOOL isAlpha(const FX_WCHAR* p) { - return ((*p) <= 'z' && (*p) >= 'a') || ((*p) <= 'Z' && (*p) >= 'A'); - } - static FX_BOOL isAvalid(const FX_WCHAR* p, FX_BOOL flag = 0); - static FX_BOOL string2number(const FX_WCHAR* s, - FX_DOUBLE* pValue, - const FX_WCHAR*& pEnd); - static FX_BOOL isUnicodeAlpha(uint16_t ch); -}; - -inline FX_BOOL XFA_FMDChar::isAvalid(const FX_WCHAR* p, FX_BOOL flag) { - if (*p == 0) { - return 1; - } - if ((*p <= 0x0A && *p >= 0x09) || *p == 0x0D || - (*p <= 0xd7ff && *p >= 0x20) || (*p <= 0xfffd && *p >= 0xe000)) { - return 1; - } - if (!flag) { - if (*p == 0x0B || *p == 0x0C) { - return 1; - } - } - return 0; -} - -inline FX_BOOL XFA_FMDChar::string2number(const FX_WCHAR* s, - FX_DOUBLE* pValue, - const FX_WCHAR*& pEnd) { - if (s) { - *pValue = wcstod((wchar_t*)s, (wchar_t**)&pEnd); - } - return 0; -} - -inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(uint16_t ch) { - if (ch == 0 || ch == 0x0A || ch == 0x0D || ch == 0x09 || ch == 0x0B || - ch == 0x0C || ch == 0x20 || ch == '.' || ch == ';' || ch == '"' || - ch == '=' || ch == '<' || ch == '>' || ch == ',' || ch == '(' || - ch == ')' || ch == ']' || ch == '[' || ch == '&' || ch == '|' || - ch == '+' || ch == '-' || ch == '*' || ch == '/') { - return FALSE; - } - return TRUE; -} - -const XFA_FMKeyword keyWords[] = { - {TOKand, 0x00000026, L"&"}, - {TOKlparen, 0x00000028, L"("}, - {TOKrparen, 0x00000029, L")"}, - {TOKmul, 0x0000002a, L"*"}, - {TOKplus, 0x0000002b, L"+"}, - {TOKcomma, 0x0000002c, L","}, - {TOKminus, 0x0000002d, L"-"}, - {TOKdot, 0x0000002e, L"."}, - {TOKdiv, 0x0000002f, L"/"}, - {TOKlt, 0x0000003c, L"<"}, - {TOKassign, 0x0000003d, L"="}, - {TOKgt, 0x0000003e, L">"}, - {TOKlbracket, 0x0000005b, L"["}, - {TOKrbracket, 0x0000005d, L"]"}, - {TOKor, 0x0000007c, L"|"}, - {TOKdotscream, 0x0000ec11, L".#"}, - {TOKdotstar, 0x0000ec18, L".*"}, - {TOKdotdot, 0x0000ec1c, L".."}, - {TOKle, 0x000133f9, L"<="}, - {TOKne, 0x000133fa, L"<>"}, - {TOKeq, 0x0001391a, L"=="}, - {TOKge, 0x00013e3b, L">="}, - {TOKdo, 0x00020153, L"do"}, - {TOKkseq, 0x00020676, L"eq"}, - {TOKksge, 0x000210ac, L"ge"}, - {TOKksgt, 0x000210bb, L"gt"}, - {TOKif, 0x00021aef, L"if"}, - {TOKin, 0x00021af7, L"in"}, - {TOKksle, 0x00022a51, L"le"}, - {TOKkslt, 0x00022a60, L"lt"}, - {TOKksne, 0x00023493, L"ne"}, - {TOKksor, 0x000239c1, L"or"}, - {TOKnull, 0x052931bb, L"null"}, - {TOKbreak, 0x05518c25, L"break"}, - {TOKksand, 0x09f9db33, L"and"}, - {TOKend, 0x0a631437, L"end"}, - {TOKeof, 0x0a63195a, L"eof"}, - {TOKfor, 0x0a7d67a7, L"for"}, - {TOKnan, 0x0b4f91dd, L"nan"}, - {TOKksnot, 0x0b4fd9b1, L"not"}, - {TOKvar, 0x0c2203e9, L"var"}, - {TOKthen, 0x2d5738cf, L"then"}, - {TOKelse, 0x45f65ee9, L"else"}, - {TOKexit, 0x4731d6ba, L"exit"}, - {TOKdownto, 0x4caadc3b, L"downto"}, - {TOKreturn, 0x4db8bd60, L"return"}, - {TOKinfinity, 0x5c0a010a, L"infinity"}, - {TOKendwhile, 0x5c64bff0, L"endwhile"}, - {TOKforeach, 0x67e31f38, L"foreach"}, - {TOKendfunc, 0x68f984a3, L"endfunc"}, - {TOKelseif, 0x78253218, L"elseif"}, - {TOKwhile, 0x84229259, L"while"}, - {TOKendfor, 0x8ab49d7e, L"endfor"}, - {TOKthrow, 0x8db05c94, L"throw"}, - {TOKstep, 0xa7a7887c, L"step"}, - {TOKupto, 0xb5155328, L"upto"}, - {TOKcontinue, 0xc0340685, L"continue"}, - {TOKfunc, 0xcdce60ec, L"func"}, - {TOKendif, 0xe0e8fee6, L"endif"}, -}; - -const XFA_FM_TOKEN KEYWORD_START = TOKdo; -const XFA_FM_TOKEN KEYWORD_END = TOKendif; - -} // namespace - -const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op) { - if (op < KEYWORD_START || op > KEYWORD_END) - return L""; - return keyWords[op].m_keyword; -} - -CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {} - -CXFA_FMToken::CXFA_FMToken(FX_DWORD uLineNum) - : m_type(TOKreserver), m_uLinenum(uLineNum) {} - -CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc, - CXFA_FMErrorInfo* pErrorInfo) - : m_ptr(wsFormCalc.GetPtr()), m_uCurrentLine(1), m_pErrorInfo(pErrorInfo) {} - -CXFA_FMToken* CXFA_FMLexer::NextToken() { - m_pToken.reset(Scan()); - return m_pToken.get(); -} - -CXFA_FMToken* CXFA_FMLexer::Scan() { - uint16_t ch = 0; - 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); - return p; - } - int iRet = 0; - while (1) { - if (!XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - ch = XFA_FMDChar::get(m_ptr); - switch (ch) { - case 0: - p->m_type = TOKeof; - return p; - case 0x0A: - ++m_uCurrentLine; - p->m_uLinenum = m_uCurrentLine; - XFA_FMDChar::inc(m_ptr); - break; - case 0x0D: - XFA_FMDChar::inc(m_ptr); - break; - case ';': { - const FX_WCHAR* pTemp = 0; - Comment(m_ptr, pTemp); - m_ptr = pTemp; - } break; - case '"': { - const FX_WCHAR* pTemp = 0; - p->m_type = TOKstring; - iRet = String(p, m_ptr, pTemp); - m_ptr = pTemp; - } - return p; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - p->m_type = TOKnumber; - const FX_WCHAR* pTemp = 0; - iRet = Number(p, m_ptr, pTemp); - m_ptr = pTemp; - if (iRet) { - Error(FMERR_BAD_SUFFIX_NUMBER); - return p; - } - } - return p; - case '=': - XFA_FMDChar::inc(m_ptr); - if (XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - if (ch == '=') { - p->m_type = TOKeq; - XFA_FMDChar::inc(m_ptr); - return p; - } else { - p->m_type = TOKassign; - return p; - } - } else { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - break; - case '<': - XFA_FMDChar::inc(m_ptr); - if (XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - if (ch == '=') { - p->m_type = TOKle; - XFA_FMDChar::inc(m_ptr); - return p; - } else if (ch == '>') { - p->m_type = TOKne; - XFA_FMDChar::inc(m_ptr); - return p; - } else { - p->m_type = TOKlt; - return p; - } - } else { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - break; - case '>': - XFA_FMDChar::inc(m_ptr); - if (XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - if (ch == '=') { - p->m_type = TOKge; - XFA_FMDChar::inc(m_ptr); - return p; - } else { - p->m_type = TOKgt; - return p; - } - } else { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - break; - case ',': - p->m_type = TOKcomma; - XFA_FMDChar::inc(m_ptr); - return p; - case '(': - p->m_type = TOKlparen; - XFA_FMDChar::inc(m_ptr); - return p; - case ')': - p->m_type = TOKrparen; - XFA_FMDChar::inc(m_ptr); - return p; - case '[': - p->m_type = TOKlbracket; - XFA_FMDChar::inc(m_ptr); - return p; - case ']': - p->m_type = TOKrbracket; - XFA_FMDChar::inc(m_ptr); - return p; - case '&': - XFA_FMDChar::inc(m_ptr); - p->m_type = TOKand; - return p; - case '|': - XFA_FMDChar::inc(m_ptr); - p->m_type = TOKor; - return p; - case '+': - XFA_FMDChar::inc(m_ptr); - p->m_type = TOKplus; - return p; - case '-': - XFA_FMDChar::inc(m_ptr); - p->m_type = TOKminus; - return p; - case '*': - XFA_FMDChar::inc(m_ptr); - p->m_type = TOKmul; - return p; - case '/': - XFA_FMDChar::inc(m_ptr); - if (XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - if (ch == '/') { - const FX_WCHAR* pTemp = 0; - Comment(m_ptr, pTemp); - m_ptr = pTemp; - break; - } else { - p->m_type = TOKdiv; - return p; - } - } else { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - break; - case '.': - XFA_FMDChar::inc(m_ptr); - if (XFA_FMDChar::isAvalid(m_ptr)) { - ch = XFA_FMDChar::get(m_ptr); - if (ch == '.') { - p->m_type = TOKdotdot; - XFA_FMDChar::inc(m_ptr); - return p; - } else if (ch == '*') { - p->m_type = TOKdotstar; - XFA_FMDChar::inc(m_ptr); - return p; - } else if (ch == '#') { - p->m_type = TOKdotscream; - XFA_FMDChar::inc(m_ptr); - return p; - } else if (ch <= '9' && ch >= '0') { - p->m_type = TOKnumber; - const FX_WCHAR* pTemp = 0; - XFA_FMDChar::dec(m_ptr); - iRet = Number(p, m_ptr, pTemp); - m_ptr = pTemp; - if (iRet) { - Error(FMERR_BAD_SUFFIX_NUMBER); - } - return p; - } else { - p->m_type = TOKdot; - return p; - } - } else { - ch = XFA_FMDChar::get(m_ptr); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return p; - } - case 0x09: - case 0x0B: - case 0x0C: - case 0x20: - XFA_FMDChar::inc(m_ptr); - break; - default: { - const FX_WCHAR* pTemp = 0; - iRet = Identifiers(p, m_ptr, pTemp); - m_ptr = pTemp; - if (iRet) { - return p; - } - p->m_type = IsKeyword(p->m_wstring); - } - return p; - } - } -} - -FX_DWORD CXFA_FMLexer::Number(CXFA_FMToken* t, - const FX_WCHAR* p, - const FX_WCHAR*& pEnd) { - FX_DOUBLE number = 0; - if (XFA_FMDChar::string2number(p, &number, pEnd)) { - return 1; - } - if (pEnd && XFA_FMDChar::isAlpha(pEnd)) { - return 1; - } - t->m_wstring = CFX_WideStringC(p, (pEnd - p)); - return 0; -} - -FX_DWORD CXFA_FMLexer::String(CXFA_FMToken* t, - const FX_WCHAR* p, - const FX_WCHAR*& pEnd) { - const FX_WCHAR* pStart = p; - uint16_t ch = 0; - XFA_FMDChar::inc(p); - ch = XFA_FMDChar::get(p); - while (ch) { - if (!XFA_FMDChar::isAvalid(p)) { - ch = XFA_FMDChar::get(p); - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return 1; - } - if (ch == '"') { - XFA_FMDChar::inc(p); - if (!XFA_FMDChar::isAvalid(p)) { - ch = XFA_FMDChar::get(p); - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return 1; - } - ch = XFA_FMDChar::get(p); - if (ch == '"') { - goto NEXT; - } else { - break; - } - } - NEXT: - XFA_FMDChar::inc(p); - ch = XFA_FMDChar::get(p); - } - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - return 0; -} - -FX_DWORD CXFA_FMLexer::Identifiers(CXFA_FMToken* t, - const FX_WCHAR* p, - const FX_WCHAR*& pEnd) { - const FX_WCHAR* pStart = p; - uint16_t ch = 0; - ch = XFA_FMDChar::get(p); - XFA_FMDChar::inc(p); - if (!XFA_FMDChar::isAvalid(p)) { - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return 1; - } - ch = XFA_FMDChar::get(p); - while (ch) { - if (!XFA_FMDChar::isAvalid(p)) { - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - Error(FMERR_UNSUPPORTED_CHAR, ch); - return 1; - } - ch = XFA_FMDChar::get(p); - if (XFA_FMDChar::isUnicodeAlpha(ch)) { - XFA_FMDChar::inc(p); - } else { - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - return 0; - } - } - pEnd = p; - t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); - return 0; -} - -void CXFA_FMLexer::Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd) { - unsigned ch = 0; - XFA_FMDChar::inc(p); - ch = XFA_FMDChar::get(p); - while (ch) { - if (ch == 0x0D) { - XFA_FMDChar::inc(p); - pEnd = p; - return; - } - if (ch == 0x0A) { - ++m_uCurrentLine; - XFA_FMDChar::inc(p); - pEnd = p; - return; - } - XFA_FMDChar::inc(p); - ch = XFA_FMDChar::get(p); - } - pEnd = p; -} - -XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) { - int32_t iLength = str.GetLength(); - uint32_t uHash = FX_HashCode_String_GetW(str.GetPtr(), iLength, TRUE); - int32_t iStart = KEYWORD_START, iEnd = KEYWORD_END; - int32_t iMid = (iStart + iEnd) / 2; - XFA_FMKeyword keyword; - do { - iMid = (iStart + iEnd) / 2; - keyword = keyWords[iMid]; - if (uHash == keyword.m_uHash) { - return keyword.m_type; - } else if (uHash < keyword.m_uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return TOKidentifier; -} - -void CXFA_FMLexer::Error(XFA_FM_ERRMSG 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); - va_end(ap); -} - -FX_BOOL CXFA_FMLexer::HasError() const { - if (m_pErrorInfo->message.IsEmpty()) { - return FALSE; - } - return TRUE; -} diff --git a/xfa/src/fxfa/fm2js/xfa_lexer.h b/xfa/src/fxfa/fm2js/xfa_lexer.h deleted file mode 100644 index f45f639e38..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_lexer.h +++ /dev/null @@ -1,134 +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_SRC_FXFA_FM2JS_XFA_LEXER_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_LEXER_H_ - -#include <memory> - -#include "core/include/fxcrt/fx_string.h" -#include "xfa/src/fxfa/fm2js/xfa_error.h" - -enum XFA_FM_TOKEN { - TOKand, - TOKlparen, - TOKrparen, - TOKmul, - TOKplus, - TOKcomma, - TOKminus, - TOKdot, - TOKdiv, - TOKlt, - TOKassign, - TOKgt, - TOKlbracket, - TOKrbracket, - TOKor, - TOKdotscream, - TOKdotstar, - TOKdotdot, - TOKle, - TOKne, - TOKeq, - TOKge, - TOKdo, - TOKkseq, - TOKksge, - TOKksgt, - TOKif, - TOKin, - TOKksle, - TOKkslt, - TOKksne, - TOKksor, - TOKnull, - TOKbreak, - TOKksand, - TOKend, - TOKeof, - TOKfor, - TOKnan, - TOKksnot, - TOKvar, - TOKthen, - TOKelse, - TOKexit, - TOKdownto, - TOKreturn, - TOKinfinity, - TOKendwhile, - TOKforeach, - TOKendfunc, - TOKelseif, - TOKwhile, - TOKendfor, - TOKthrow, - TOKstep, - TOKupto, - TOKcontinue, - TOKfunc, - TOKendif, - TOKstar, - TOKidentifier, - TOKunderscore, - TOKdollar, - TOKexclamation, - TOKcall, - TOKstring, - TOKnumber, - TOKreserver -}; - -struct XFA_FMKeyword { - XFA_FM_TOKEN m_type; - uint32_t m_uHash; - const FX_WCHAR* m_keyword; -}; - -const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op); - -class CXFA_FMToken { - public: - CXFA_FMToken(); - explicit CXFA_FMToken(FX_DWORD uLineNum); - - CFX_WideStringC m_wstring; - XFA_FM_TOKEN m_type; - FX_DWORD m_uLinenum; -}; - -class CXFA_FMLexer { - public: - CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); - CXFA_FMToken* NextToken(); - FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); - FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); - FX_DWORD Identifiers(CXFA_FMToken* t, - const FX_WCHAR* p, - const FX_WCHAR*& pEnd); - void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd); - XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p); - void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; } - void SetToken(CXFA_FMToken* pToken) { - if (m_pToken.get() != pToken) - m_pToken.reset(pToken); - } - const FX_WCHAR* SavePos() { return m_ptr; } - void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; } - void Error(XFA_FM_ERRMSG msg, ...); - FX_BOOL HasError() const; - - protected: - CXFA_FMToken* Scan(); - - const FX_WCHAR* m_ptr; - FX_DWORD m_uCurrentLine; - std::unique_ptr<CXFA_FMToken> m_pToken; - CXFA_FMErrorInfo* m_pErrorInfo; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_LEXER_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_program.cpp b/xfa/src/fxfa/fm2js/xfa_program.cpp deleted file mode 100644 index ce06c4d99d..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_program.cpp +++ /dev/null @@ -1,45 +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/src/fxfa/fm2js/xfa_program.h" - -CXFA_FMProgram::CXFA_FMProgram() : m_globalFunction(0) {} -CXFA_FMProgram::~CXFA_FMProgram() { - if (m_globalFunction != 0) { - delete m_globalFunction; - m_globalFunction = 0; - } -} -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; - 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; - } - } - delete expressions; - return -1; - } - m_globalFunction = - new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); - return 0; -} -int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { - m_globalFunction->ToJavaScript(wsJavaScript); - wsJavaScript.AppendChar(0); - return 0; -} diff --git a/xfa/src/fxfa/fm2js/xfa_program.h b/xfa/src/fxfa/fm2js/xfa_program.h deleted file mode 100644 index 3cd7cc4d0b..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_program.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_SRC_FXFA_FM2JS_XFA_PROGRAM_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_PROGRAM_H_ - -#include "xfa/src/fxfa/fm2js/xfa_error.h" -#include "xfa/src/fxfa/fm2js/xfa_fmparse.h" - -class CXFA_FMProgram { - public: - CXFA_FMProgram(); - ~CXFA_FMProgram(); - int32_t Init(const CFX_WideStringC& wsFormcalc); - int32_t ParseProgram(); - int32_t TranslateProgram(CFX_WideTextBuf& wsJavaScript); - CXFA_FMErrorInfo& GetError() { return m_pErrorInfo; } - - private: - CXFA_FMErrorInfo m_pErrorInfo; - CXFA_FMParse m_parse; - CXFA_FMFunctionDefinition* m_globalFunction; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_PROGRAM_H_ diff --git a/xfa/src/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/src/fxfa/fm2js/xfa_simpleexpression.cpp deleted file mode 100644 index 376a8f7a32..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_simpleexpression.cpp +++ /dev/null @@ -1,745 +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/src/fxfa/fm2js/xfa_simpleexpression.h" - -#include "core/include/fxcrt/fx_ext.h" - -namespace { - -const CFX_WideStringC gs_lpStrExpFuncName[] = { - FX_WSTRC(L"foxit_xfa_formcalc_runtime.assign_value_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_or_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_and_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.equality_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.notequality_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.less_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.lessequal_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.greater_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.greaterequal_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.plus_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.minus_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.multiple_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.divide_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.positive_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.negative_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.logical_not_operator"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime."), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.dot_accessor"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.dotdot_accessor"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.concat_fm_object"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.is_fm_object"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.is_fm_array"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.get_fm_value"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.get_fm_jsobj"), - FX_WSTRC(L"foxit_xfa_formcalc_runtime.fm_var_filter"), -}; - -struct XFA_FMBuildInFunc { - uint32_t m_uHash; - const FX_WCHAR* m_buildinfunc; -}; -const XFA_FMBuildInFunc g_BuildInFuncs[] = { - {0x0001f1f5, L"At"}, {0x00020b9c, L"FV"}, - {0x00021aef, L"If"}, {0x00023ee6, L"PV"}, - {0x04b5c9ee, L"Encode"}, {0x08e96685, L"DateFmt"}, - {0x09f99db6, L"Abs"}, {0x09f9e583, L"Apr"}, - {0x09fa043e, L"Avg"}, {0x0a9782a0, L"Get"}, - {0x0b1b09df, L"Len"}, {0x0b3543a6, L"Max"}, - {0x0b356ca4, L"Min"}, {0x0b358b60, L"Mod"}, - {0x0b4fded4, L"NPV"}, {0x0b846bf1, L"Pmt"}, - {0x0b8494f9, L"Put"}, {0x0bb8df5d, L"Ref"}, - {0x0bd37a99, L"Str"}, {0x0bd37fb5, L"Sum"}, - {0x1048469b, L"Cterm"}, {0x11e03660, L"Exists"}, - {0x126236e6, L"Post"}, {0x127c6661, L"PPmt"}, - {0x193ade3e, L"Right"}, {0x1ec8ab2c, L"Rate"}, - {0x20e476dc, L"IsoTime2Num"}, {0x23eb6816, L"TimeFmt"}, - {0x24fb17b0, L"LocalDateFmt"}, {0x28dee6e9, L"Format"}, - {0x2d0890b8, L"Term"}, {0x2d71b00f, L"Time"}, - {0x2f890fb1, L"Num2Time"}, {0x3767511d, L"Ceil"}, - {0x3ffd1941, L"LocalTimeFmt"}, {0x442f68c8, L"Round"}, - {0x46fd1128, L"Eval"}, {0x4d629440, L"Date2Num"}, - {0x4dcf25f8, L"Concat"}, {0x4e00255d, L"UnitValue"}, - {0x55a5cc29, L"Lower"}, {0x5e43e04c, L"WordNum"}, - {0x620ce6ba, L"Ipmt"}, {0x6f544d49, L"Count"}, - {0x7e241013, L"Within"}, {0x9b9a6e2b, L"IsoDate2Num"}, - {0xb2c941c2, L"UnitType"}, {0xb598a1f7, L"Uuid"}, - {0xbde9abde, L"Date"}, {0xc0010b80, L"Num2Date"}, - {0xc1f6144c, L"Upper"}, {0xc44028f7, L"Oneof"}, - {0xc62c1b2c, L"Space"}, {0xd0ff50f9, L"HasValue"}, - {0xd1537042, L"Floor"}, {0xd2ac9cf1, L"Time2Num"}, - {0xd907aee5, L"Num2GMTime"}, {0xdf24f7c4, L"Decode"}, - {0xe2664803, L"Substr"}, {0xe3e7b528, L"Stuff"}, - {0xe6792d4e, L"Rtrim"}, {0xe8c23f5b, L"Parse"}, - {0xea18d121, L"Choose"}, {0xebfef69c, L"Replace"}, - {0xf5ad782b, L"Left"}, {0xf7bb2248, L"Ltrim"}, -}; - -struct XFA_FMSOMMethod { - uint32_t m_uHash; - const FX_WCHAR* m_wsSomMethodName; - FX_DWORD m_dParameters; -}; -const XFA_FMSOMMethod gs_FMSomMethods[] = { - {0x00000068, L"h", 0x01}, - {0x00000077, L"w", 0x01}, - {0x00000078, L"x", 0x01}, - {0x00000079, L"y", 0x01}, - {0x05eb5b0f, L"pageSpan", 0x01}, - {0x10f1b1bd, L"page", 0x01}, - {0x3bf1c2a5, L"absPageSpan", 0x01}, - {0x3c752495, L"verify", 0x0d}, - {0x44c352ad, L"formNodes", 0x01}, - {0x5775c2cc, L"absPageInBatch", 0x01}, - {0x5ee00996, L"setElement", 0x01}, - {0x7033bfd5, L"insert", 0x03}, - {0x8c5feb32, L"sheetInBatch", 0x01}, - {0x8f3a8379, L"sheet", 0x01}, - {0x92dada4f, L"saveFilteredXML", 0x01}, - {0x9cab7cae, L"remove", 0x01}, - {0xa68635f1, L"sign", 0x61}, - {0xaac241c8, L"isRecordGroup", 0x01}, - {0xd8ed1467, L"clear", 0x01}, - {0xda12e518, L"append", 0x01}, - {0xe74f0653, L"absPage", 0x01}, -}; - -} // namespace - -CFX_WideStringC XFA_FM_EXPTypeToString( - XFA_FM_SimpleExpressionType simpleExpType) { - return gs_lpStrExpFuncName[simpleExpType]; -} - -CXFA_FMSimpleExpression::CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op) - : m_line(line), m_op(op) {} - -void CXFA_FMSimpleExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} - -void CXFA_FMSimpleExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} - -XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const { - return m_op; -} - -CXFA_FMNullExpression::CXFA_FMNullExpression(FX_DWORD line) - : CXFA_FMSimpleExpression(line, TOKnull) {} - -void CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"null"); -} - -CXFA_FMNumberExpression::CXFA_FMNumberExpression(FX_DWORD line, - CFX_WideStringC wsNumber) - : CXFA_FMSimpleExpression(line, TOKnumber), m_wsNumber(wsNumber) {} - -void CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << m_wsNumber; -} - -CXFA_FMStringExpression::CXFA_FMStringExpression(FX_DWORD line, - CFX_WideStringC wsString) - : CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {} - -void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - CFX_WideString tempStr = m_wsString; - if (tempStr.GetLength() > 2) { - javascript.AppendChar(L'\"'); - FX_WCHAR oneChar; - for (int16_t i = 1; i < tempStr.GetLength() - 1; i++) { - oneChar = tempStr[i]; - switch (oneChar) { - case L'\"': { - i++; - javascript << FX_WSTRC(L"\\\""); - } break; - case 0x0d: - break; - case 0x0a: { - javascript << FX_WSTRC(L"\\n"); - } break; - default: { javascript.AppendChar(oneChar); } break; - } - } - javascript.AppendChar(L'\"'); - } else { - javascript << tempStr; - } -} - -CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( - FX_DWORD line, - CFX_WideStringC wsIdentifier) - : CXFA_FMSimpleExpression(line, TOKidentifier), - m_wsIdentifier(wsIdentifier) {} - -void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { - CFX_WideString tempStr = m_wsIdentifier; - if (tempStr.Equal(FX_WSTRC(L"$"))) { - tempStr = FX_WSTRC(L"this"); - } else if (tempStr.Equal(FX_WSTRC(L"!"))) { - tempStr = FX_WSTRC(L"xfa.datasets"); - } else if (tempStr.Equal(FX_WSTRC(L"$data"))) { - tempStr = FX_WSTRC(L"xfa.datasets.data"); - } else if (tempStr.Equal(FX_WSTRC(L"$event"))) { - tempStr = FX_WSTRC(L"xfa.event"); - } else if (tempStr.Equal(FX_WSTRC(L"$form"))) { - tempStr = FX_WSTRC(L"xfa.form"); - } else if (tempStr.Equal(FX_WSTRC(L"$host"))) { - tempStr = FX_WSTRC(L"xfa.host"); - } else if (tempStr.Equal(FX_WSTRC(L"$layout"))) { - tempStr = FX_WSTRC(L"xfa.layout"); - } else if (tempStr.Equal(FX_WSTRC(L"$template"))) { - tempStr = FX_WSTRC(L"xfa.template"); - } else if (tempStr[0] == L'!') { - tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1); - } - javascript << tempStr; -} - -CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp) - : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {} - -void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} - -CXFA_FMBinExpression::CXFA_FMBinExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMSimpleExpression(line, op), m_pExp1(pExp1), m_pExp2(pExp2) {} - -void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} - -CXFA_FMAssignExpression::CXFA_FMAssignExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"if ("); - javascript << gs_lpStrExpFuncName[ISFMOBJECT]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L"))\n{\n"); - javascript << gs_lpStrExpFuncName[ASSIGN]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L");\n}\n"); - CFX_WideTextBuf tempExp1; - m_pExp1->ToJavaScript(tempExp1); - if (m_pExp1->GetOperatorToken() == TOKidentifier && - tempExp1.GetWideString() != FX_WSTRC(L"this")) { - javascript << FX_WSTRC(L"else\n{\n"); - javascript << tempExp1; - javascript << FX_WSTRC(L" = "); - javascript << gs_lpStrExpFuncName[ASSIGN]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L");\n}\n"); - } -} - -void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"if ("); - javascript << gs_lpStrExpFuncName[ISFMOBJECT]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L"))\n{\n"); - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = "); - javascript << gs_lpStrExpFuncName[ASSIGN]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L");\n}\n"); - CFX_WideTextBuf tempExp1; - m_pExp1->ToJavaScript(tempExp1); - if (m_pExp1->GetOperatorToken() == TOKidentifier && - tempExp1.GetWideString() != FX_WSTRC(L"this")) { - javascript << FX_WSTRC(L"else\n{\n"); - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << FX_WSTRC(L" = "); - javascript << tempExp1; - javascript << FX_WSTRC(L" = "); - javascript << gs_lpStrExpFuncName[ASSIGN]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L");\n}\n"); - } -} - -CXFA_FMLogicalOrExpression::CXFA_FMLogicalOrExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[LOGICALOR]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMLogicalAndExpression::CXFA_FMLogicalAndExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[LOGICALAND]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMEqualityExpression::CXFA_FMEqualityExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - switch (m_op) { - case TOKeq: - case TOKkseq: - javascript << gs_lpStrExpFuncName[EQUALITY]; - break; - case TOKne: - case TOKksne: - javascript << gs_lpStrExpFuncName[NOTEQUALITY]; - break; - default: - FXSYS_assert(FALSE); - break; - } - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMRelationalExpression::CXFA_FMRelationalExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - switch (m_op) { - case TOKlt: - case TOKkslt: - javascript << gs_lpStrExpFuncName[LESS]; - break; - case TOKgt: - case TOKksgt: - javascript << gs_lpStrExpFuncName[GREATER]; - break; - case TOKle: - case TOKksle: - javascript << gs_lpStrExpFuncName[LESSEQUAL]; - break; - case TOKge: - case TOKksge: - javascript << gs_lpStrExpFuncName[GREATEREQUAL]; - break; - default: - FXSYS_assert(FALSE); - break; - } - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMAdditiveExpression::CXFA_FMAdditiveExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - switch (m_op) { - case TOKplus: - javascript << gs_lpStrExpFuncName[PLUS]; - break; - case TOKminus: - javascript << gs_lpStrExpFuncName[MINUS]; - break; - default: - FXSYS_assert(FALSE); - break; - } - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMMultiplicativeExpression::CXFA_FMMultiplicativeExpression( - FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2) - : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} - -void CXFA_FMMultiplicativeExpression::ToJavaScript( - CFX_WideTextBuf& javascript) { - switch (m_op) { - case TOKmul: - javascript << gs_lpStrExpFuncName[MULTIPLE]; - break; - case TOKdiv: - javascript << gs_lpStrExpFuncName[DIVIDE]; - break; - default: - FXSYS_assert(FALSE); - break; - } - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMPosExpression::CXFA_FMPosExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExp) - : CXFA_FMUnaryExpression(line, TOKplus, pExp) {} - -void CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[POSITIVE]; - javascript << FX_WSTRC(L"("); - m_pExp->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMNegExpression::CXFA_FMNegExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExp) - : CXFA_FMUnaryExpression(line, TOKminus, pExp) {} - -void CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[NEGATIVE]; - javascript << FX_WSTRC(L"("); - m_pExp->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMNotExpression::CXFA_FMNotExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExp) - : CXFA_FMUnaryExpression(line, TOKksnot, pExp) {} - -void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[NOT]; - javascript << FX_WSTRC(L"("); - m_pExp->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMCallExpression::CXFA_FMCallExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExp, - CFX_PtrArray* 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(); - delete m_pArguments; - } -} - -bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) { - uint32_t uHash = FX_HashCode_String_GetW(funcName->GetBuffer(), - funcName->GetLength(), TRUE); - const XFA_FMBuildInFunc* pEnd = g_BuildInFuncs + FX_ArraySize(g_BuildInFuncs); - const XFA_FMBuildInFunc* pFunc = - std::lower_bound(g_BuildInFuncs, pEnd, uHash, - [](const XFA_FMBuildInFunc& func, uint32_t hash) { - return func.m_uHash < hash; - }); - if (pFunc < pEnd && uHash == pFunc->m_uHash) { - funcName->Clear(); - *funcName << pFunc->m_buildinfunc; - return true; - } - return false; -} - -FX_DWORD CXFA_FMCallExpression::IsMethodWithObjParam( - const CFX_WideStringC& methodName) { - int32_t iLength = methodName.GetLength(); - uint32_t uHash = FX_HashCode_String_GetW(methodName.GetPtr(), iLength); - XFA_FMSOMMethod somMethodWithObjPara; - FX_DWORD parameters = 0x00; - int32_t iStart = 0, - iEnd = (sizeof(gs_FMSomMethods) / sizeof(gs_FMSomMethods[0])) - 1; - int32_t iMid = (iStart + iEnd) / 2; - do { - iMid = (iStart + iEnd) / 2; - somMethodWithObjPara = gs_FMSomMethods[iMid]; - if (uHash == somMethodWithObjPara.m_uHash) { - parameters = somMethodWithObjPara.m_dParameters; - break; - } else if (uHash < somMethodWithObjPara.m_uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return parameters; -} - -void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - CFX_WideTextBuf funcName; - m_pExp->ToJavaScript(funcName); - if (m_bIsSomMethod) { - javascript << funcName; - javascript << FX_WSTRC(L"("); - if (m_pArguments) { - FX_DWORD methodPara = IsMethodWithObjParam(funcName.GetWideString()); - if (methodPara > 0) { - for (int i = 0; i < m_pArguments->GetSize(); ++i) { - if ((methodPara & (0x01 << i)) > 0) { - javascript << gs_lpStrExpFuncName[GETFMJSOBJ]; - } else { - javascript << gs_lpStrExpFuncName[GETFMVALUE]; - } - javascript << FX_WSTRC(L"("); - CXFA_FMSimpleExpression* e = - reinterpret_cast<CXFA_FMSimpleExpression*>( - m_pArguments->GetAt(i)); - e->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - if (i + 1 < m_pArguments->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - } else { - 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)); - e->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); - if (i + 1 < m_pArguments->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - } - } - javascript << FX_WSTRC(L")"); - } else { - bool isEvalFunc = false; - bool isExistsFunc = false; - if (IsBuildInFunc(&funcName)) { - if (funcName.GetWideString() == 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")) { - isExistsFunc = true; - javascript << gs_lpStrExpFuncName[CALL]; - javascript << funcName; - } else { - javascript << gs_lpStrExpFuncName[CALL]; - javascript << funcName; - } - } else { - javascript << funcName; - } - javascript << FX_WSTRC(L"("); - 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)); - javascript << FX_WSTRC(L"return "); - e->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n}\n"); - } else { - javascript << FX_WSTRC(L"return 0;\n}\n"); - } - javascript << FX_WSTRC( - 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)); - e->ToJavaScript(javascript); - if (i + 1 < m_pArguments->GetSize()) { - javascript << FX_WSTRC(L", "); - } - } - } - javascript << FX_WSTRC(L")"); - if (isEvalFunc) { - javascript << FX_WSTRC(L")"); - } - } -} - -CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( - FX_DWORD line, - CXFA_FMSimpleExpression* pAccessor, - XFA_FM_TOKEN op, - CFX_WideStringC wsIdentifier, - CXFA_FMSimpleExpression* pIndexExp) - : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), - m_wsIdentifier(wsIdentifier) {} - -void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[DOT]; - javascript << FX_WSTRC(L"("); - if (m_pExp1) { - m_pExp1->ToJavaScript(javascript); - } else { - javascript << FX_WSTRC(L"null"); - } - javascript << FX_WSTRC(L", "); - javascript << FX_WSTRC(L"\""); - if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { - m_pExp1->ToJavaScript(javascript); - } - javascript << FX_WSTRC(L"\", "); - if (m_op == TOKdotscream) { - javascript << FX_WSTRC(L"\"#"); - javascript << m_wsIdentifier; - javascript << FX_WSTRC(L"\", "); - } else if (m_op == TOKdotstar) { - javascript << FX_WSTRC(L"\"*\", "); - } else if (m_op == TOKcall) { - javascript << FX_WSTRC(L"\"\", "); - } else { - javascript << FX_WSTRC(L"\""); - javascript << m_wsIdentifier; - javascript << FX_WSTRC(L"\", "); - } - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMIndexExpression::CXFA_FMIndexExpression( - FX_DWORD line, - XFA_FM_AccessorIndex accessorIndex, - CXFA_FMSimpleExpression* pIndexExp, - FX_BOOL bIsStarIndex) - : CXFA_FMUnaryExpression(line, TOKlbracket, pIndexExp), - m_accessorIndex(accessorIndex), - m_bIsStarIndex(bIsStarIndex) {} - -void CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - switch (m_accessorIndex) { - case ACCESSOR_NO_INDEX: - javascript << FX_WSTRC(L"0"); - break; - case ACCESSOR_NO_RELATIVEINDEX: - javascript << FX_WSTRC(L"1"); - break; - case ACCESSOR_POSITIVE_INDEX: - javascript << FX_WSTRC(L"2"); - break; - case ACCESSOR_NEGATIVE_INDEX: - javascript << FX_WSTRC(L"3"); - break; - default: - javascript << FX_WSTRC(L"0"); - } - if (!m_bIsStarIndex) { - javascript << FX_WSTRC(L", "); - if (m_pExp) { - m_pExp->ToJavaScript(javascript); - } else { - javascript << FX_WSTRC(L"0"); - } - } -} - -CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( - FX_DWORD line, - CXFA_FMSimpleExpression* pAccessor, - XFA_FM_TOKEN op, - CFX_WideStringC wsIdentifier, - CXFA_FMSimpleExpression* pIndexExp) - : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), - m_wsIdentifier(wsIdentifier) {} - -void CXFA_FMDotDotAccessorExpression::ToJavaScript( - CFX_WideTextBuf& javascript) { - javascript << gs_lpStrExpFuncName[DOTDOT]; - javascript << FX_WSTRC(L"("); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L", "); - javascript << FX_WSTRC(L"\""); - if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier) { - m_pExp1->ToJavaScript(javascript); - } - javascript << FX_WSTRC(L"\", "); - javascript << FX_WSTRC(L"\""); - javascript << m_wsIdentifier; - javascript << FX_WSTRC(L"\", "); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L")"); -} - -CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression( - FX_DWORD line, - CXFA_FMSimpleExpression* pAccessorExp1, - CXFA_FMSimpleExpression* pCallExp) - : CXFA_FMBinExpression(line, TOKdot, pAccessorExp1, pCallExp) {} - -void CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - javascript << FX_WSTRC(L"(\nfunction ()\n{\n"); - javascript << FX_WSTRC(L"var method_return_value = null;\n"); - javascript << FX_WSTRC(L"var accessor_object = "); - m_pExp1->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n"); - javascript << FX_WSTRC(L"if ("); - javascript << gs_lpStrExpFuncName[ISFMARRAY]; - javascript << FX_WSTRC(L"(accessor_object))\n{\n"); - javascript << FX_WSTRC( - L"for(var index = accessor_object.length - 1; index > 1; index--)\n{\n"); - javascript << FX_WSTRC(L"method_return_value = accessor_object[index]."); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n}\n}\n"); - javascript << FX_WSTRC(L"else\n{\nmethod_return_value = accessor_object."); - m_pExp2->ToJavaScript(javascript); - javascript << FX_WSTRC(L";\n}\n"); - javascript << FX_WSTRC(L"return method_return_value;\n"); - javascript << FX_WSTRC(L"}\n).call(this)"); -} diff --git a/xfa/src/fxfa/fm2js/xfa_simpleexpression.h b/xfa/src/fxfa/fm2js/xfa_simpleexpression.h deleted file mode 100644 index 152fe3d5e7..0000000000 --- a/xfa/src/fxfa/fm2js/xfa_simpleexpression.h +++ /dev/null @@ -1,292 +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_SRC_FXFA_FM2JS_XFA_SIMPLEEXPRESSION_H_ -#define XFA_SRC_FXFA_FM2JS_XFA_SIMPLEEXPRESSION_H_ - -#include <memory> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxfa/fm2js/xfa_lexer.h" - -#define RUNTIMEFUNCTIONRETURNVALUE \ - (FX_WSTRC(L"foxit_xfa_formcalc_runtime_func_return_value")) -#define EXCLAMATION_IN_IDENTIFIER \ - (FX_WSTRC(L"foxit_xfa_formcalc__exclamation__")) - -enum XFA_FM_SimpleExpressionType { - ASSIGN, - LOGICALOR, - LOGICALAND, - EQUALITY, - NOTEQUALITY, - LESS, - LESSEQUAL, - GREATER, - GREATEREQUAL, - PLUS, - MINUS, - MULTIPLE, - DIVIDE, - POSITIVE, - NEGATIVE, - NOT, - CALL, - DOT, - DOTDOT, - CONCATFMOBJECT, - ISFMOBJECT, - ISFMARRAY, - GETFMVALUE, - GETFMJSOBJ, - VARFILTER -}; - -CFX_WideStringC XFA_FM_EXPTypeToString( - XFA_FM_SimpleExpressionType simpleExpType); - -enum XFA_FM_AccessorIndex { - ACCESSOR_NO_INDEX, - ACCESSOR_NO_RELATIVEINDEX, - ACCESSOR_POSITIVE_INDEX, - ACCESSOR_NEGATIVE_INDEX -}; - -class CXFA_FMSimpleExpression { - public: - CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op); - virtual ~CXFA_FMSimpleExpression() {} - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf& javascript); - - XFA_FM_TOKEN GetOperatorToken() const; - - protected: - FX_DWORD m_line; - XFA_FM_TOKEN m_op; -}; - -class CXFA_FMNullExpression : public CXFA_FMSimpleExpression { - public: - explicit CXFA_FMNullExpression(FX_DWORD line); - ~CXFA_FMNullExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMNumberExpression : public CXFA_FMSimpleExpression { - public: - CXFA_FMNumberExpression(FX_DWORD line, CFX_WideStringC wsNumber); - ~CXFA_FMNumberExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - CFX_WideStringC m_wsNumber; -}; - -class CXFA_FMStringExpression : public CXFA_FMSimpleExpression { - public: - CXFA_FMStringExpression(FX_DWORD line, CFX_WideStringC wsString); - ~CXFA_FMStringExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - CFX_WideStringC m_wsString; -}; - -class CXFA_FMIdentifierExpressionn : public CXFA_FMSimpleExpression { - public: - CXFA_FMIdentifierExpressionn(FX_DWORD line, CFX_WideStringC wsIdentifier); - ~CXFA_FMIdentifierExpressionn() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - CFX_WideStringC m_wsIdentifier; -}; - -class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression { - public: - CXFA_FMUnaryExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - protected: - std::unique_ptr<CXFA_FMSimpleExpression> m_pExp; -}; - -class CXFA_FMBinExpression : public CXFA_FMSimpleExpression { - public: - CXFA_FMBinExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - protected: - std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1; - std::unique_ptr<CXFA_FMSimpleExpression> m_pExp2; -}; - -class CXFA_FMAssignExpression : public CXFA_FMBinExpression { - public: - CXFA_FMAssignExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMAssignExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - void ToImpliedReturnJS(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMLogicalOrExpression : public CXFA_FMBinExpression { - public: - CXFA_FMLogicalOrExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMLogicalOrExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMLogicalAndExpression : public CXFA_FMBinExpression { - public: - CXFA_FMLogicalAndExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMLogicalAndExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMEqualityExpression : public CXFA_FMBinExpression { - public: - CXFA_FMEqualityExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMEqualityExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMRelationalExpression : public CXFA_FMBinExpression { - public: - CXFA_FMRelationalExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMRelationalExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMAdditiveExpression : public CXFA_FMBinExpression { - public: - CXFA_FMAdditiveExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMAdditiveExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMMultiplicativeExpression : public CXFA_FMBinExpression { - public: - CXFA_FMMultiplicativeExpression(FX_DWORD line, - XFA_FM_TOKEN op, - CXFA_FMSimpleExpression* pExp1, - CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMMultiplicativeExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMPosExpression : public CXFA_FMUnaryExpression { - public: - CXFA_FMPosExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); - ~CXFA_FMPosExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMNegExpression : public CXFA_FMUnaryExpression { - public: - CXFA_FMNegExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); - ~CXFA_FMNegExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMNotExpression : public CXFA_FMUnaryExpression { - public: - CXFA_FMNotExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp); - ~CXFA_FMNotExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -class CXFA_FMCallExpression : public CXFA_FMUnaryExpression { - public: - CXFA_FMCallExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pExp, - CFX_PtrArray* pArguments, - FX_BOOL bIsSomMethod); - ~CXFA_FMCallExpression() override; - bool IsBuildInFunc(CFX_WideTextBuf* funcName); - FX_DWORD IsMethodWithObjParam(const CFX_WideStringC& methodName); - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - FX_BOOL m_bIsSomMethod; - CFX_PtrArray* m_pArguments; -}; - -class CXFA_FMDotAccessorExpression : public CXFA_FMBinExpression { - public: - CXFA_FMDotAccessorExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pAccessor, - XFA_FM_TOKEN op, - CFX_WideStringC wsIdentifier, - CXFA_FMSimpleExpression* pIndexExp); - ~CXFA_FMDotAccessorExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - CFX_WideStringC m_wsIdentifier; -}; - -class CXFA_FMIndexExpression : public CXFA_FMUnaryExpression { - public: - CXFA_FMIndexExpression(FX_DWORD line, - XFA_FM_AccessorIndex accessorIndex, - CXFA_FMSimpleExpression* pIndexExp, - FX_BOOL bIsStarIndex); - ~CXFA_FMIndexExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - XFA_FM_AccessorIndex m_accessorIndex; - FX_BOOL m_bIsStarIndex; -}; - -class CXFA_FMDotDotAccessorExpression : public CXFA_FMBinExpression { - public: - CXFA_FMDotDotAccessorExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pAccessor, - XFA_FM_TOKEN op, - CFX_WideStringC wsIdentifier, - CXFA_FMSimpleExpression* pIndexExp); - ~CXFA_FMDotDotAccessorExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; - - private: - CFX_WideStringC m_wsIdentifier; -}; - -class CXFA_FMMethodCallExpression : public CXFA_FMBinExpression { - public: - CXFA_FMMethodCallExpression(FX_DWORD line, - CXFA_FMSimpleExpression* pAccessorExp1, - CXFA_FMSimpleExpression* pCallExp); - ~CXFA_FMMethodCallExpression() override {} - void ToJavaScript(CFX_WideTextBuf& javascript) override; -}; - -#endif // XFA_SRC_FXFA_FM2JS_XFA_SIMPLEEXPRESSION_H_ diff --git a/xfa/src/fxfa/parser/xfa_basic_data.cpp b/xfa/src/fxfa/parser/xfa_basic_data.cpp deleted file mode 100644 index 418ebf374b..0000000000 --- a/xfa/src/fxfa/parser/xfa_basic_data.cpp +++ /dev/null @@ -1,7333 +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/src/fxfa/parser/xfa_basic_data.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_script_datawindow.h" -#include "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_logpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -const XFA_ATTRIBUTEENUMINFO g_XFAEnumData[] = { - {0x2a, L"*", XFA_ATTRIBUTEENUM_Asterisk}, - {0x2f, L"/", XFA_ATTRIBUTEENUM_Slash}, - {0x5c, L"\\", XFA_ATTRIBUTEENUM_Backslash}, - {0x239bd, L"on", XFA_ATTRIBUTEENUM_On}, - {0x25356, L"tb", XFA_ATTRIBUTEENUM_Tb}, - {0x25885, L"up", XFA_ATTRIBUTEENUM_Up}, - {0x91b281, L"metaData", XFA_ATTRIBUTEENUM_MetaData}, - {0x1f8dedb, L"delegate", XFA_ATTRIBUTEENUM_Delegate}, - {0x2a6c55a, L"postSubmit", XFA_ATTRIBUTEENUM_PostSubmit}, - {0x31b19c1, L"name", XFA_ATTRIBUTEENUM_Name}, - {0x378a38a, L"cross", XFA_ATTRIBUTEENUM_Cross}, - {0x3848b3f, L"next", XFA_ATTRIBUTEENUM_Next}, - {0x48b6670, L"none", XFA_ATTRIBUTEENUM_None}, - {0x51aafe5, L"shortEdge", XFA_ATTRIBUTEENUM_ShortEdge}, - {0x55264c4, L"1mod10_1mod11", XFA_ATTRIBUTEENUM_1mod10_1mod11}, - {0x5a5c519, L"height", XFA_ATTRIBUTEENUM_Height}, - {0x89ce549, L"crossDiagonal", XFA_ATTRIBUTEENUM_CrossDiagonal}, - {0x9f9d0f9, L"all", XFA_ATTRIBUTEENUM_All}, - {0x9f9db48, L"any", XFA_ATTRIBUTEENUM_Any}, - {0xa126261, L"toRight", XFA_ATTRIBUTEENUM_ToRight}, - {0xa36de29, L"matchTemplate", XFA_ATTRIBUTEENUM_MatchTemplate}, - {0xa48d040, L"dpl", XFA_ATTRIBUTEENUM_Dpl}, - {0xa559c05, L"invisible", XFA_ATTRIBUTEENUM_Invisible}, - {0xa7d48e3, L"fit", XFA_ATTRIBUTEENUM_Fit}, - {0xa8a8f80, L"width", XFA_ATTRIBUTEENUM_Width}, - {0xab466bb, L"preSubmit", XFA_ATTRIBUTEENUM_PreSubmit}, - {0xacc5785, L"ipl", XFA_ATTRIBUTEENUM_Ipl}, - {0xafab0f8, L"flateCompress", XFA_ATTRIBUTEENUM_FlateCompress}, - {0xb355816, L"med", XFA_ATTRIBUTEENUM_Med}, - {0xb69ef77, L"odd", XFA_ATTRIBUTEENUM_Odd}, - {0xb69f9bb, L"off", XFA_ATTRIBUTEENUM_Off}, - {0xb843dba, L"pdf", XFA_ATTRIBUTEENUM_Pdf}, - {0xbb912b8, L"row", XFA_ATTRIBUTEENUM_Row}, - {0xbedaf33, L"top", XFA_ATTRIBUTEENUM_Top}, - {0xc56afcc, L"xdp", XFA_ATTRIBUTEENUM_Xdp}, - {0xc56ba02, L"xfd", XFA_ATTRIBUTEENUM_Xfd}, - {0xc56ddf1, L"xml", XFA_ATTRIBUTEENUM_Xml}, - {0xc8b65f3, L"zip", XFA_ATTRIBUTEENUM_Zip}, - {0xc8b89d6, L"zpl", XFA_ATTRIBUTEENUM_Zpl}, - {0xf55d7ee, L"visible", XFA_ATTRIBUTEENUM_Visible}, - {0xfe3596a, L"exclude", XFA_ATTRIBUTEENUM_Exclude}, - {0x109d7ce7, L"mouseEnter", XFA_ATTRIBUTEENUM_MouseEnter}, - {0x10f1bc0c, L"pair", XFA_ATTRIBUTEENUM_Pair}, - {0x1154efe6, L"filter", XFA_ATTRIBUTEENUM_Filter}, - {0x125bc94b, L"moveLast", XFA_ATTRIBUTEENUM_MoveLast}, - {0x12e1f1f0, L"exportAndImport", XFA_ATTRIBUTEENUM_ExportAndImport}, - {0x13000c60, L"push", XFA_ATTRIBUTEENUM_Push}, - {0x138ee315, L"portrait", XFA_ATTRIBUTEENUM_Portrait}, - {0x14da2125, L"default", XFA_ATTRIBUTEENUM_Default}, - {0x157749a5, L"storedProc", XFA_ATTRIBUTEENUM_StoredProc}, - {0x16641198, L"stayBOF", XFA_ATTRIBUTEENUM_StayBOF}, - {0x16b2fc5b, L"stayEOF", XFA_ATTRIBUTEENUM_StayEOF}, - {0x17fad373, L"postPrint", XFA_ATTRIBUTEENUM_PostPrint}, - {0x193207d0, L"usCarrier", XFA_ATTRIBUTEENUM_UsCarrier}, - {0x193ade3e, L"right", XFA_ATTRIBUTEENUM_Right}, - {0x1bfc72d9, L"preOpen", XFA_ATTRIBUTEENUM_PreOpen}, - {0x1cc9317a, L"actual", XFA_ATTRIBUTEENUM_Actual}, - {0x1f31df1e, L"rest", XFA_ATTRIBUTEENUM_Rest}, - {0x1fb1bf14, L"topCenter", XFA_ATTRIBUTEENUM_TopCenter}, - {0x207de667, L"standardSymbol", XFA_ATTRIBUTEENUM_StandardSymbol}, - {0x2196a452, L"initialize", XFA_ATTRIBUTEENUM_Initialize}, - {0x23bd40c7, L"justifyAll", XFA_ATTRIBUTEENUM_JustifyAll}, - {0x247cf3e9, L"normal", XFA_ATTRIBUTEENUM_Normal}, - {0x25aa946b, L"landscape", XFA_ATTRIBUTEENUM_Landscape}, - {0x2739b5c9, L"nonInteractive", XFA_ATTRIBUTEENUM_NonInteractive}, - {0x27410f03, L"mouseExit", XFA_ATTRIBUTEENUM_MouseExit}, - {0x2854e62c, L"minus", XFA_ATTRIBUTEENUM_Minus}, - {0x287e936a, L"diagonalLeft", XFA_ATTRIBUTEENUM_DiagonalLeft}, - {0x2972a98f, L"simplexPaginated", XFA_ATTRIBUTEENUM_SimplexPaginated}, - {0x29d8225f, L"document", XFA_ATTRIBUTEENUM_Document}, - {0x2a9d3016, L"warning", XFA_ATTRIBUTEENUM_Warning}, - {0x2b35b6d9, L"auto", XFA_ATTRIBUTEENUM_Auto}, - {0x2c1653d9, L"below", XFA_ATTRIBUTEENUM_Below}, - {0x2c1f0540, L"bottomLeft", XFA_ATTRIBUTEENUM_BottomLeft}, - {0x2c44e816, L"bottomCenter", XFA_ATTRIBUTEENUM_BottomCenter}, - {0x2cd3e9f3, L"tcpl", XFA_ATTRIBUTEENUM_Tcpl}, - {0x2d08af85, L"text", XFA_ATTRIBUTEENUM_Text}, - {0x2dc478eb, L"grouping", XFA_ATTRIBUTEENUM_Grouping}, - {0x2ef3afdd, L"secureSymbol", XFA_ATTRIBUTEENUM_SecureSymbol}, - {0x2f2dd29a, L"preExecute", XFA_ATTRIBUTEENUM_PreExecute}, - {0x33c43dec, L"docClose", XFA_ATTRIBUTEENUM_DocClose}, - {0x33f25bb5, L"keyset", XFA_ATTRIBUTEENUM_Keyset}, - {0x34e363da, L"vertical", XFA_ATTRIBUTEENUM_Vertical}, - {0x361fa1b6, L"preSave", XFA_ATTRIBUTEENUM_PreSave}, - {0x36f1c6d8, L"preSign", XFA_ATTRIBUTEENUM_PreSign}, - {0x399f02b5, L"bottom", XFA_ATTRIBUTEENUM_Bottom}, - {0x3b0ab096, L"toTop", XFA_ATTRIBUTEENUM_ToTop}, - {0x3c752495, L"verify", XFA_ATTRIBUTEENUM_Verify}, - {0x3ce05d68, L"first", XFA_ATTRIBUTEENUM_First}, - {0x3ecead94, L"contentArea", XFA_ATTRIBUTEENUM_ContentArea}, - {0x40623b5b, L"solid", XFA_ATTRIBUTEENUM_Solid}, - {0x42c6cd8d, L"pessimistic", XFA_ATTRIBUTEENUM_Pessimistic}, - {0x43ddc6bf, L"duplexPaginated", XFA_ATTRIBUTEENUM_DuplexPaginated}, - {0x442f68c8, L"round", XFA_ATTRIBUTEENUM_Round}, - {0x45efb847, L"remerge", XFA_ATTRIBUTEENUM_Remerge}, - {0x46972265, L"ordered", XFA_ATTRIBUTEENUM_Ordered}, - {0x46f95531, L"percent", XFA_ATTRIBUTEENUM_Percent}, - {0x46fd25ae, L"even", XFA_ATTRIBUTEENUM_Even}, - {0x4731d6ba, L"exit", XFA_ATTRIBUTEENUM_Exit}, - {0x4977356b, L"toolTip", XFA_ATTRIBUTEENUM_ToolTip}, - {0x49b980ee, L"orderedOccurrence", XFA_ATTRIBUTEENUM_OrderedOccurrence}, - {0x4a7e2dfe, L"readOnly", XFA_ATTRIBUTEENUM_ReadOnly}, - {0x4c4e8acb, L"currency", XFA_ATTRIBUTEENUM_Currency}, - {0x4dcf25f8, L"concat", XFA_ATTRIBUTEENUM_Concat}, - {0x4febb826, L"Thai", XFA_ATTRIBUTEENUM_Thai}, - {0x50ef95b2, L"embossed", XFA_ATTRIBUTEENUM_Embossed}, - {0x516e35ce, L"formdata", XFA_ATTRIBUTEENUM_Formdata}, - {0x52fa6f0e, L"Greek", XFA_ATTRIBUTEENUM_Greek}, - {0x54034c2f, L"decimal", XFA_ATTRIBUTEENUM_Decimal}, - {0x542c7300, L"select", XFA_ATTRIBUTEENUM_Select}, - {0x551f0ae5, L"longEdge", XFA_ATTRIBUTEENUM_LongEdge}, - {0x55520a8a, L"protected", XFA_ATTRIBUTEENUM_Protected}, - {0x559f76f3, L"bottomRight", XFA_ATTRIBUTEENUM_BottomRight}, - {0x568cb500, L"zero", XFA_ATTRIBUTEENUM_Zero}, - {0x56bcecb7, L"forwardOnly", XFA_ATTRIBUTEENUM_ForwardOnly}, - {0x56bf456b, L"docReady", XFA_ATTRIBUTEENUM_DocReady}, - {0x573cb40c, L"hidden", XFA_ATTRIBUTEENUM_Hidden}, - {0x582e3424, L"include", XFA_ATTRIBUTEENUM_Include}, - {0x58a3dd29, L"dashed", XFA_ATTRIBUTEENUM_Dashed}, - {0x5955b22b, L"multiSelect", XFA_ATTRIBUTEENUM_MultiSelect}, - {0x598d5c53, L"inactive", XFA_ATTRIBUTEENUM_Inactive}, - {0x59c8f27d, L"embed", XFA_ATTRIBUTEENUM_Embed}, - {0x5e7555e8, L"static", XFA_ATTRIBUTEENUM_Static}, - {0x606d4def, L"onEntry", XFA_ATTRIBUTEENUM_OnEntry}, - {0x6195eafb, L"Cyrillic", XFA_ATTRIBUTEENUM_Cyrillic}, - {0x6491b0f3, L"nonBlank", XFA_ATTRIBUTEENUM_NonBlank}, - {0x67bef031, L"topRight", XFA_ATTRIBUTEENUM_TopRight}, - {0x67df5ebd, L"Hebrew", XFA_ATTRIBUTEENUM_Hebrew}, - {0x6aea98be, L"topLeft", XFA_ATTRIBUTEENUM_TopLeft}, - {0x6c51afc1, L"center", XFA_ATTRIBUTEENUM_Center}, - {0x7145e6bf, L"moveFirst", XFA_ATTRIBUTEENUM_MoveFirst}, - {0x7375465c, L"diamond", XFA_ATTRIBUTEENUM_Diamond}, - {0x7461aef4, L"pageOdd", XFA_ATTRIBUTEENUM_PageOdd}, - {0x75f8aeb2, L"1mod10", XFA_ATTRIBUTEENUM_1mod10}, - {0x76d708e0, L"Korean", XFA_ATTRIBUTEENUM_Korean}, - {0x789f14d7, L"aboveEmbedded", XFA_ATTRIBUTEENUM_AboveEmbedded}, - {0x792ea39f, L"zipCompress", XFA_ATTRIBUTEENUM_ZipCompress}, - {0x7a5b7193, L"numeric", XFA_ATTRIBUTEENUM_Numeric}, - {0x7abec0d2, L"circle", XFA_ATTRIBUTEENUM_Circle}, - {0x7afbba38, L"toBottom", XFA_ATTRIBUTEENUM_ToBottom}, - {0x7b95e661, L"inverted", XFA_ATTRIBUTEENUM_Inverted}, - {0x7baca2e3, L"update", XFA_ATTRIBUTEENUM_Update}, - {0x7eb5da2c, L"isoname", XFA_ATTRIBUTEENUM_Isoname}, - {0x7f6fd3d7, L"server", XFA_ATTRIBUTEENUM_Server}, - {0x814f82b5, L"position", XFA_ATTRIBUTEENUM_Position}, - {0x82deacf0, L"middleCenter", XFA_ATTRIBUTEENUM_MiddleCenter}, - {0x83a49dc6, L"optional", XFA_ATTRIBUTEENUM_Optional}, - {0x861a116f, L"usePrinterSetting", XFA_ATTRIBUTEENUM_UsePrinterSetting}, - {0x86701ce0, L"outline", XFA_ATTRIBUTEENUM_Outline}, - {0x8808385e, L"indexChange", XFA_ATTRIBUTEENUM_IndexChange}, - {0x891f4606, L"change", XFA_ATTRIBUTEENUM_Change}, - {0x89939f36, L"pageArea", XFA_ATTRIBUTEENUM_PageArea}, - {0x8b5c3b25, L"once", XFA_ATTRIBUTEENUM_Once}, - {0x8b5c6962, L"only", XFA_ATTRIBUTEENUM_Only}, - {0x8b90e1f2, L"open", XFA_ATTRIBUTEENUM_Open}, - {0x8bcfe96e, L"caption", XFA_ATTRIBUTEENUM_Caption}, - {0x8ce83ef8, L"raised", XFA_ATTRIBUTEENUM_Raised}, - {0x8d269cae, L"justify", XFA_ATTRIBUTEENUM_Justify}, - {0x8fd520dc, L"refAndDescendants", XFA_ATTRIBUTEENUM_RefAndDescendants}, - {0x9041d4b0, L"short", XFA_ATTRIBUTEENUM_Short}, - {0x90c94426, L"pageFront", XFA_ATTRIBUTEENUM_PageFront}, - {0x936beee5, L"monospace", XFA_ATTRIBUTEENUM_Monospace}, - {0x947fa00f, L"middle", XFA_ATTRIBUTEENUM_Middle}, - {0x9528a7b4, L"prePrint", XFA_ATTRIBUTEENUM_PrePrint}, - {0x959ab231, L"always", XFA_ATTRIBUTEENUM_Always}, - {0x96d61bf0, L"unknown", XFA_ATTRIBUTEENUM_Unknown}, - {0x997194ee, L"toLeft", XFA_ATTRIBUTEENUM_ToLeft}, - {0x9a83a3cd, L"above", XFA_ATTRIBUTEENUM_Above}, - {0x9d0d71c7, L"dashDot", XFA_ATTRIBUTEENUM_DashDot}, - {0x9df56f3e, L"gregorian", XFA_ATTRIBUTEENUM_Gregorian}, - {0x9f6723fd, L"Roman", XFA_ATTRIBUTEENUM_Roman}, - {0x9f693b21, L"mouseDown", XFA_ATTRIBUTEENUM_MouseDown}, - {0xa1429b36, L"symbol", XFA_ATTRIBUTEENUM_Symbol}, - {0xa5aa45cb, L"pageEven", XFA_ATTRIBUTEENUM_PageEven}, - {0xa68635f1, L"sign", XFA_ATTRIBUTEENUM_Sign}, - {0xa7315093, L"addNew", XFA_ATTRIBUTEENUM_AddNew}, - {0xa7a773fa, L"star", XFA_ATTRIBUTEENUM_Star}, - {0xa7d57b45, L"optimistic", XFA_ATTRIBUTEENUM_Optimistic}, - {0xa8077321, L"rl-tb", XFA_ATTRIBUTEENUM_Rl_tb}, - {0xa8f1468d, L"middleRight", XFA_ATTRIBUTEENUM_MiddleRight}, - {0xaa84a1f1, L"maintain", XFA_ATTRIBUTEENUM_Maintain}, - {0xab40b12c, L"package", XFA_ATTRIBUTEENUM_Package}, - {0xac8b4d85, L"SimplifiedChinese", XFA_ATTRIBUTEENUM_SimplifiedChinese}, - {0xadae6744, L"toCenter", XFA_ATTRIBUTEENUM_ToCenter}, - {0xb0129df1, L"back", XFA_ATTRIBUTEENUM_Back}, - {0xb0f088cf, L"unspecified", XFA_ATTRIBUTEENUM_Unspecified}, - {0xb1271067, L"batchOptimistic", XFA_ATTRIBUTEENUM_BatchOptimistic}, - {0xb18313a1, L"bold", XFA_ATTRIBUTEENUM_Bold}, - {0xb1833cad, L"both", XFA_ATTRIBUTEENUM_Both}, - {0xb221123f, L"butt", XFA_ATTRIBUTEENUM_Butt}, - {0xb40c36bf, L"client", XFA_ATTRIBUTEENUM_Client}, - {0xb56c7053, L"2mod10", XFA_ATTRIBUTEENUM_2mod10}, - {0xb683a345, L"imageOnly", XFA_ATTRIBUTEENUM_ImageOnly}, - {0xb7732dea, L"horizontal", XFA_ATTRIBUTEENUM_Horizontal}, - {0xb88652a4, L"dotted", XFA_ATTRIBUTEENUM_Dotted}, - {0xbb2f2880, L"userControl", XFA_ATTRIBUTEENUM_UserControl}, - {0xbbb79c5d, L"diagonalRight", XFA_ATTRIBUTEENUM_DiagonalRight}, - {0xbd077154, L"consumeData", XFA_ATTRIBUTEENUM_ConsumeData}, - {0xbd3fb11e, L"check", XFA_ATTRIBUTEENUM_Check}, - {0xbde9abda, L"data", XFA_ATTRIBUTEENUM_Data}, - {0xbf5a02d8, L"down", XFA_ATTRIBUTEENUM_Down}, - {0xbf7450ee, L"sansSerif", XFA_ATTRIBUTEENUM_SansSerif}, - {0xc02d649f, L"inline", XFA_ATTRIBUTEENUM_Inline}, - {0xc11a9e3a, L"TraditionalChinese", XFA_ATTRIBUTEENUM_TraditionalChinese}, - {0xc16169d8, L"warn", XFA_ATTRIBUTEENUM_Warn}, - {0xc16f071f, L"refOnly", XFA_ATTRIBUTEENUM_RefOnly}, - {0xc27c8ba5, L"interactiveForms", XFA_ATTRIBUTEENUM_InteractiveForms}, - {0xc2d1b15c, L"word", XFA_ATTRIBUTEENUM_Word}, - {0xc3621288, L"unordered", XFA_ATTRIBUTEENUM_Unordered}, - {0xc5251981, L"required", XFA_ATTRIBUTEENUM_Required}, - {0xc7088e7d, L"importOnly", XFA_ATTRIBUTEENUM_ImportOnly}, - {0xc72cf0e3, L"belowEmbedded", XFA_ATTRIBUTEENUM_BelowEmbedded}, - {0xc819cf07, L"Japanese", XFA_ATTRIBUTEENUM_Japanese}, - {0xcdce56b3, L"full", XFA_ATTRIBUTEENUM_Full}, - {0xce0122e3, L"rl-row", XFA_ATTRIBUTEENUM_Rl_row}, - {0xcf7d71f1, L"Vietnamese", XFA_ATTRIBUTEENUM_Vietnamese}, - {0xcfde3e09, L"EastEuropeanRoman", XFA_ATTRIBUTEENUM_EastEuropeanRoman}, - {0xd576d08e, L"mouseUp", XFA_ATTRIBUTEENUM_MouseUp}, - {0xd7a92904, L"exportOnly", XFA_ATTRIBUTEENUM_ExportOnly}, - {0xd8ed1467, L"clear", XFA_ATTRIBUTEENUM_Clear}, - {0xd95657a6, L"click", XFA_ATTRIBUTEENUM_Click}, - {0xd96c7de5, L"base64", XFA_ATTRIBUTEENUM_Base64}, - {0xd9f47f36, L"close", XFA_ATTRIBUTEENUM_Close}, - {0xdb075bde, L"host", XFA_ATTRIBUTEENUM_Host}, - {0xdb103411, L"global", XFA_ATTRIBUTEENUM_Global}, - {0xdb647188, L"blank", XFA_ATTRIBUTEENUM_Blank}, - {0xdb9be968, L"table", XFA_ATTRIBUTEENUM_Table}, - {0xdf590fbb, L"import", XFA_ATTRIBUTEENUM_Import}, - {0xe0e573fb, L"custom", XFA_ATTRIBUTEENUM_Custom}, - {0xe0ecc79a, L"middleLeft", XFA_ATTRIBUTEENUM_MiddleLeft}, - {0xe1452019, L"postExecute", XFA_ATTRIBUTEENUM_PostExecute}, - {0xe1911d98, L"radix", XFA_ATTRIBUTEENUM_Radix}, - {0xe25fa7b8, L"postOpen", XFA_ATTRIBUTEENUM_PostOpen}, - {0xe28dce7e, L"enter", XFA_ATTRIBUTEENUM_Enter}, - {0xe2c44de4, L"ignore", XFA_ATTRIBUTEENUM_Ignore}, - {0xe2cd8c61, L"lr-tb", XFA_ATTRIBUTEENUM_Lr_tb}, - {0xe2da8336, L"fantasy", XFA_ATTRIBUTEENUM_Fantasy}, - {0xe31d5396, L"italic", XFA_ATTRIBUTEENUM_Italic}, - {0xe7ada113, L"author", XFA_ATTRIBUTEENUM_Author}, - {0xe8e7cc18, L"toEdge", XFA_ATTRIBUTEENUM_ToEdge}, - {0xe97aa98b, L"choice", XFA_ATTRIBUTEENUM_Choice}, - {0xeafd2a38, L"disabled", XFA_ATTRIBUTEENUM_Disabled}, - {0xeb2b7972, L"crossHatch", XFA_ATTRIBUTEENUM_CrossHatch}, - {0xeb2db2d7, L"dataRef", XFA_ATTRIBUTEENUM_DataRef}, - {0xec35dc6e, L"dashDotDot", XFA_ATTRIBUTEENUM_DashDotDot}, - {0xef85d351, L"square", XFA_ATTRIBUTEENUM_Square}, - {0xf2102445, L"dynamic", XFA_ATTRIBUTEENUM_Dynamic}, - {0xf272c7be, L"manual", XFA_ATTRIBUTEENUM_Manual}, - {0xf2bbb64d, L"etched", XFA_ATTRIBUTEENUM_Etched}, - {0xf3b8fc6c, L"validationState", XFA_ATTRIBUTEENUM_ValidationState}, - {0xf42f2b81, L"cursive", XFA_ATTRIBUTEENUM_Cursive}, - {0xf54481d4, L"last", XFA_ATTRIBUTEENUM_Last}, - {0xf5ad782b, L"left", XFA_ATTRIBUTEENUM_Left}, - {0xf616da2e, L"link", XFA_ATTRIBUTEENUM_Link}, - {0xf6b4afb0, L"long", XFA_ATTRIBUTEENUM_Long}, - {0xf8636460, L"internationalCarrier", - XFA_ATTRIBUTEENUM_InternationalCarrier}, - {0xf9fb37ac, L"PDF1.3", XFA_ATTRIBUTEENUM_PDF1_3}, - {0xf9fb37af, L"PDF1.6", XFA_ATTRIBUTEENUM_PDF1_6}, - {0xfbce7f19, L"serif", XFA_ATTRIBUTEENUM_Serif}, - {0xfc82d695, L"postSave", XFA_ATTRIBUTEENUM_PostSave}, - {0xfcef86b5, L"ready", XFA_ATTRIBUTEENUM_Ready}, - {0xfd54fbb7, L"postSign", XFA_ATTRIBUTEENUM_PostSign}, - {0xfdc0aae2, L"Arabic", XFA_ATTRIBUTEENUM_Arabic}, - {0xfe06d2ca, L"error", XFA_ATTRIBUTEENUM_Error}, - {0xfefc4885, L"urlencoded", XFA_ATTRIBUTEENUM_Urlencoded}, - {0xff795ad2, L"lowered", XFA_ATTRIBUTEENUM_Lowered}, -}; -const int32_t g_iXFAEnumCount = - sizeof(g_XFAEnumData) / sizeof(XFA_ATTRIBUTEENUMINFO); -static const CXFA_Measurement g_XFAMeasurementData[] = { - CXFA_Measurement(0, XFA_UNIT_In), - CXFA_Measurement(0, XFA_UNIT_Pt), - CXFA_Measurement(5, XFA_UNIT_Mm), - CXFA_Measurement(0.25, XFA_UNIT_Mm), - CXFA_Measurement(-1, XFA_UNIT_Unknown), - CXFA_Measurement(0, XFA_UNIT_Angle), - CXFA_Measurement(10, XFA_UNIT_Pt), - CXFA_Measurement(360, XFA_UNIT_Angle), - CXFA_Measurement(0.5, XFA_UNIT_Pt), -}; -const XFA_ATTRIBUTEINFO g_XFAAttributeData[] = { - {0x68, L"h", XFA_ATTRIBUTE_H, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x77, L"w", XFA_ATTRIBUTE_W, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x78, L"x", XFA_ATTRIBUTE_X, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x79, L"y", XFA_ATTRIBUTE_Y, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x21aed, L"id", XFA_ATTRIBUTE_Id, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x25363, L"to", XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Config, (void*)NULL}, - {0xcb0ac9, L"lineThrough", XFA_ATTRIBUTE_LineThrough, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x2282c73, L"hAlign", XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Left}, - {0x2c1c7f1, L"typeface", XFA_ATTRIBUTE_Typeface, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"Courier"}, - {0x3106c3a, L"beforeTarget", XFA_ATTRIBUTE_BeforeTarget, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x31b19c1, L"name", XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | - XFA_XDPPACKET_Template | XFA_XDPPACKET_Datasets | XFA_XDPPACKET_Form | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x3848b3f, L"next", XFA_ATTRIBUTE_Next, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_None}, - {0x43e349b, L"dataRowCount", XFA_ATTRIBUTE_DataRowCount, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x5518c25, L"break", XFA_ATTRIBUTE_Break, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Close}, - {0x5ce6195, L"vScrollPolicy", XFA_ATTRIBUTE_VScrollPolicy, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0x8c74ae9, L"fontHorizontalScale", XFA_ATTRIBUTE_FontHorizontalScale, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"100%"}, - {0x8d4f1c7, L"textIndent", XFA_ATTRIBUTE_TextIndent, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x97c1c65, L"context", XFA_ATTRIBUTE_Context, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_UNKNOWN, (void*)0}, - {0x9876578, L"trayOut", XFA_ATTRIBUTE_TrayOut, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xa2e3514, L"cap", XFA_ATTRIBUTE_Cap, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Square}, - {0xb3543a6, L"max", XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xb356ca4, L"min", XFA_ATTRIBUTE_Min, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, - {0xbb8df5d, L"ref", XFA_ATTRIBUTE_Ref, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | - XFA_XDPPACKET_Form, - (void*)NULL}, - {0xbb8f3df, L"rid", XFA_ATTRIBUTE_Rid, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xc080cd3, L"url", XFA_ATTRIBUTE_Url, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xc0811ed, L"use", XFA_ATTRIBUTE_Use, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xcfea02e, L"leftInset", XFA_ATTRIBUTE_LeftInset, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x1026c59d, L"widows", XFA_ATTRIBUTE_Widows, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x1059ec18, L"level", XFA_ATTRIBUTE_Level, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Config, (void*)0}, - {0x1356caf8, L"bottomInset", XFA_ATTRIBUTE_BottomInset, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x13a08bdb, L"overflowTarget", XFA_ATTRIBUTE_OverflowTarget, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x1414d431, L"allowMacro", XFA_ATTRIBUTE_AllowMacro, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x14a32d52, L"pagePosition", XFA_ATTRIBUTE_PagePosition, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Any}, - {0x1517dfa1, L"columnWidths", XFA_ATTRIBUTE_ColumnWidths, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x169134a1, L"overflowLeader", XFA_ATTRIBUTE_OverflowLeader, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x1b8dce3e, L"action", XFA_ATTRIBUTE_Action, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Include}, - {0x1e459b8f, L"nonRepudiation", XFA_ATTRIBUTE_NonRepudiation, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x1ec8ab2c, L"rate", XFA_ATTRIBUTE_Rate, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)50}, - {0x1ef3a64a, L"allowRichText", XFA_ATTRIBUTE_AllowRichText, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x2038c9b2, L"role", XFA_ATTRIBUTE_Role, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x20914367, L"overflowTrailer", XFA_ATTRIBUTE_OverflowTrailer, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x226ca8f1, L"operation", XFA_ATTRIBUTE_Operation, - XFA_ATTRIBUTETYPE_NOTSURE, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x24d85167, L"timeout", XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_SourceSet, (void*)NULL}, - {0x25764436, L"topInset", XFA_ATTRIBUTE_TopInset, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x25839852, L"access", XFA_ATTRIBUTE_Access, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Open}, - {0x268b7ec1, L"commandType", XFA_ATTRIBUTE_CommandType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, - (void*)XFA_ATTRIBUTEENUM_Unknown}, - {0x28dee6e9, L"format", XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x28e17e91, L"dataPrep", XFA_ATTRIBUTE_DataPrep, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_None}, - {0x292b88fe, L"widgetData", XFA_ATTRIBUTE_WidgetData, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, - {0x29418bb7, L"abbr", XFA_ATTRIBUTE_Abbr, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_LocaleSet, (void*)0}, - {0x2a82d99c, L"marginRight", XFA_ATTRIBUTE_MarginRight, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x2b5df51e, L"dataDescription", XFA_ATTRIBUTE_DataDescription, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_ConnectionSet, (void*)NULL}, - {0x2bb3f470, L"encipherOnly", XFA_ATTRIBUTE_EncipherOnly, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x2cd79033, L"kerningMode", XFA_ATTRIBUTE_KerningMode, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_None}, - {0x2ee7678f, L"rotate", XFA_ATTRIBUTE_Rotate, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 5)}, - {0x2f105f72, L"wordCharacterCount", XFA_ATTRIBUTE_WordCharacterCount, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)7}, - {0x2f16a382, L"type", XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x34ae103c, L"reserve", XFA_ATTRIBUTE_Reserve, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 4)}, - {0x3650557e, L"textLocation", XFA_ATTRIBUTE_TextLocation, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Below}, - {0x39cdb0a2, L"priority", XFA_ATTRIBUTE_Priority, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Custom}, - {0x3a0273a6, L"underline", XFA_ATTRIBUTE_Underline, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x3b582286, L"moduleWidth", XFA_ATTRIBUTE_ModuleWidth, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 3)}, - {0x3d123c26, L"hyphenate", XFA_ATTRIBUTE_Hyphenate, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x3e7af94f, L"listen", XFA_ATTRIBUTE_Listen, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_RefOnly}, - {0x4156ee3f, L"delimiter", XFA_ATTRIBUTE_Delimiter, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x42fed1fd, L"contentType", XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | - XFA_XDPPACKET_Datasets | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x453eaf38, L"startNew", XFA_ATTRIBUTE_StartNew, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x45a6daf8, L"eofAction", XFA_ATTRIBUTE_EofAction, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_MoveLast}, - {0x47cfa43a, L"allowNeutral", XFA_ATTRIBUTE_AllowNeutral, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x47d03490, L"connection", XFA_ATTRIBUTE_Connection, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x4873c601, L"baselineShift", XFA_ATTRIBUTE_BaselineShift, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x4b319767, L"overlinePeriod", XFA_ATTRIBUTE_OverlinePeriod, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_All}, - {0x4b8bc840, L"fracDigits", XFA_ATTRIBUTE_FracDigits, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)2}, - {0x4ef3d02c, L"orientation", XFA_ATTRIBUTE_Orientation, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Portrait}, - {0x4fdc3454, L"timeStamp", XFA_ATTRIBUTE_TimeStamp, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_XDP, (void*)NULL}, - {0x52666f1c, L"printCheckDigit", XFA_ATTRIBUTE_PrintCheckDigit, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x534729c9, L"marginLeft", XFA_ATTRIBUTE_MarginLeft, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x5392ea58, L"stroke", XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Solid}, - {0x5404d6df, L"moduleHeight", XFA_ATTRIBUTE_ModuleHeight, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 2)}, - {0x54fa722c, L"transferEncoding", XFA_ATTRIBUTE_TransferEncoding, - XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x552d9ad5, L"usage", XFA_ATTRIBUTE_Usage, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_ExportAndImport}, - {0x570ce835, L"presence", XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Visible}, - {0x5739d1ff, L"radixOffset", XFA_ATTRIBUTE_RadixOffset, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x577682ac, L"preserve", XFA_ATTRIBUTE_Preserve, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x58be2870, L"aliasNode", XFA_ATTRIBUTE_AliasNode, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, - {0x5a32e493, L"multiLine", XFA_ATTRIBUTE_MultiLine, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x5a50e9e6, L"version", XFA_ATTRIBUTE_Version, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x5ab23b6c, L"startChar", XFA_ATTRIBUTE_StartChar, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x5b707a35, L"scriptTest", XFA_ATTRIBUTE_ScriptTest, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Error}, - {0x5c054755, L"startAngle", XFA_ATTRIBUTE_StartAngle, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 5)}, - {0x5ec958c0, L"cursorType", XFA_ATTRIBUTE_CursorType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, - (void*)XFA_ATTRIBUTEENUM_ForwardOnly}, - {0x5f760b50, L"digitalSignature", XFA_ATTRIBUTE_DigitalSignature, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x60a61edd, L"codeType", XFA_ATTRIBUTE_CodeType, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x60d4c8b1, L"output", XFA_ATTRIBUTE_Output, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_ConnectionSet, (void*)NULL}, - {0x64110ab5, L"bookendTrailer", XFA_ATTRIBUTE_BookendTrailer, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x65e30c67, L"imagingBBox", XFA_ATTRIBUTE_ImagingBBox, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"none"}, - {0x66539c48, L"excludeInitialCap", XFA_ATTRIBUTE_ExcludeInitialCap, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x66642f8f, L"force", XFA_ATTRIBUTE_Force, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Config, (void*)NULL}, - {0x69aa2292, L"crlSign", XFA_ATTRIBUTE_CrlSign, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x6a3405dd, L"previous", XFA_ATTRIBUTE_Previous, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_None}, - {0x6a95c976, L"pushCharacterCount", XFA_ATTRIBUTE_PushCharacterCount, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)3}, - {0x6b6ddcfb, L"nullTest", XFA_ATTRIBUTE_NullTest, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Disabled}, - {0x6cfa828a, L"runAt", XFA_ATTRIBUTE_RunAt, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Client}, - {0x731e0665, L"spaceBelow", XFA_ATTRIBUTE_SpaceBelow, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x74788f8b, L"sweepAngle", XFA_ATTRIBUTE_SweepAngle, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 7)}, - {0x78bff531, L"numberOfCells", XFA_ATTRIBUTE_NumberOfCells, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0x79543055, L"letterSpacing", XFA_ATTRIBUTE_LetterSpacing, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x79975f2b, L"lockType", XFA_ATTRIBUTE_LockType, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_ReadOnly}, - {0x7a0cc471, L"passwordChar", XFA_ATTRIBUTE_PasswordChar, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"*"}, - {0x7a7cc341, L"vAlign", XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Top}, - {0x7b29630a, L"sourceBelow", XFA_ATTRIBUTE_SourceBelow, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, - (void*)XFA_ATTRIBUTEENUM_Update}, - {0x7b95e661, L"inverted", XFA_ATTRIBUTE_Inverted, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x7c2fd80b, L"mark", XFA_ATTRIBUTE_Mark, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Default}, - {0x7c2ff6ae, L"maxH", XFA_ATTRIBUTE_MaxH, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x7c2ff6bd, L"maxW", XFA_ATTRIBUTE_MaxW, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x7c732a66, L"truncate", XFA_ATTRIBUTE_Truncate, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x7d02356c, L"minH", XFA_ATTRIBUTE_MinH, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x7d02357b, L"minW", XFA_ATTRIBUTE_MinW, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x7d0b5fca, L"initial", XFA_ATTRIBUTE_Initial, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, - {0x7d9fd7c5, L"mode", XFA_ATTRIBUTE_Mode, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Config, (void*)XFA_ATTRIBUTEENUM_UsePrinterSetting}, - {0x7e7e845e, L"layout", XFA_ATTRIBUTE_Layout, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Position}, - {0x7f6fd3d7, L"server", XFA_ATTRIBUTE_Server, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x824f21b7, L"embedPDF", XFA_ATTRIBUTE_EmbedPDF, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x8340ea66, L"oddOrEven", XFA_ATTRIBUTE_OddOrEven, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Any}, - {0x836d4d7c, L"tabDefault", XFA_ATTRIBUTE_TabDefault, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x8855805f, L"contains", XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Datasets, (void*)XFA_ATTRIBUTEENUM_Data}, - {0x8a692521, L"rightInset", XFA_ATTRIBUTE_RightInset, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x8af2e657, L"maxChars", XFA_ATTRIBUTE_MaxChars, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x8b90e1f2, L"open", XFA_ATTRIBUTE_Open, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_UserControl}, - {0x8c99377e, L"relation", XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x8d181d61, L"wideNarrowRatio", XFA_ATTRIBUTE_WideNarrowRatio, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"3:1"}, - {0x8e1c2921, L"relevant", XFA_ATTRIBUTE_Relevant, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x8e29d794, L"signatureType", XFA_ATTRIBUTE_SignatureType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Filter}, - {0x8ec6204c, L"lineThroughPeriod", XFA_ATTRIBUTE_LineThroughPeriod, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_All}, - {0x8ed182d1, L"shape", XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Square}, - {0x8fa01790, L"tabStops", XFA_ATTRIBUTE_TabStops, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0x8fc36c0a, L"outputBelow", XFA_ATTRIBUTE_OutputBelow, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, - (void*)XFA_ATTRIBUTEENUM_Warn}, - {0x9041d4b0, L"short", XFA_ATTRIBUTE_Short, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0x907c7719, L"fontVerticalScale", XFA_ATTRIBUTE_FontVerticalScale, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"100%"}, - {0x94446dcc, L"thickness", XFA_ATTRIBUTE_Thickness, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 8)}, - {0x957fa006, L"commitOn", XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Select}, - {0x982bd892, L"remainCharacterCount", XFA_ATTRIBUTE_RemainCharacterCount, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)3}, - {0x98fd4d81, L"keyAgreement", XFA_ATTRIBUTE_KeyAgreement, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x99800d7a, L"errorCorrectionLevel", XFA_ATTRIBUTE_ErrorCorrectionLevel, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0x9a63da3d, L"upsMode", XFA_ATTRIBUTE_UpsMode, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_UsCarrier}, - {0x9cc17d75, L"mergeMode", XFA_ATTRIBUTE_MergeMode, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_ConsumeData}, - {0x9d833d75, L"circular", XFA_ATTRIBUTE_Circular, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0x9d8ee204, L"psName", XFA_ATTRIBUTE_PsName, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Config, (void*)NULL}, - {0x9dcc3ab3, L"trailer", XFA_ATTRIBUTE_Trailer, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xa0933954, L"unicodeRange", XFA_ATTRIBUTE_UnicodeRange, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Config, (void*)NULL}, - {0xa1b0d2f5, L"executeType", XFA_ATTRIBUTE_ExecuteType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Import}, - {0xa25a883d, L"duplexImposition", XFA_ATTRIBUTE_DuplexImposition, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_LongEdge}, - {0xa42ca1b7, L"trayIn", XFA_ATTRIBUTE_TrayIn, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xa433f001, L"bindingNode", XFA_ATTRIBUTE_BindingNode, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_UNKNOWN, (void*)0}, - {0xa5340ff5, L"bofAction", XFA_ATTRIBUTE_BofAction, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_SourceSet, (void*)XFA_ATTRIBUTEENUM_MoveFirst}, - {0xa5b410cf, L"save", XFA_ATTRIBUTE_Save, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0xa6118c89, L"targetType", XFA_ATTRIBUTE_TargetType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xa66404cb, L"keyEncipherment", XFA_ATTRIBUTE_KeyEncipherment, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xa6710262, L"credentialServerPolicy", - XFA_ATTRIBUTE_CredentialServerPolicy, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {0xa686975b, L"size", XFA_ATTRIBUTE_Size, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 6)}, - {0xa85e74f3, L"initialNumber", XFA_ATTRIBUTE_InitialNumber, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)1}, - {0xabef37e3, L"slope", XFA_ATTRIBUTE_Slope, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Backslash}, - {0xabfa6c4f, L"cSpace", XFA_ATTRIBUTE_CSpace, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)L"SRGB"}, - {0xac06e2b0, L"colSpan", XFA_ATTRIBUTE_ColSpan, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, - {0xadc4c77b, L"binding", XFA_ATTRIBUTE_Binding, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xaf754613, L"checksum", XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xb045fbc5, L"charEncoding", XFA_ATTRIBUTE_CharEncoding, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)L"UTF-8"}, - {0xb0e5485d, L"bind", XFA_ATTRIBUTE_Bind, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet, (void*)NULL}, - {0xb12128b7, L"textEntry", XFA_ATTRIBUTE_TextEntry, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0xb373a862, L"archive", XFA_ATTRIBUTE_Archive, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xb598a1f7, L"uuid", XFA_ATTRIBUTE_Uuid, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_XDP, (void*)NULL}, - {0xb5e49bf2, L"posture", XFA_ATTRIBUTE_Posture, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Normal}, - {0xb6b44172, L"after", XFA_ATTRIBUTE_After, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xb716467b, L"orphans", XFA_ATTRIBUTE_Orphans, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0xbc0c4695, L"qualifiedName", XFA_ATTRIBUTE_QualifiedName, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_UNKNOWN, (void*)NULL}, - {0xbc254332, L"usehref", XFA_ATTRIBUTE_Usehref, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xbc8fa350, L"locale", XFA_ATTRIBUTE_Locale, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xbd6e1d88, L"weight", XFA_ATTRIBUTE_Weight, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Normal}, - {0xbd96a0e9, L"underlinePeriod", XFA_ATTRIBUTE_UnderlinePeriod, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_All}, - {0xbde9abda, L"data", XFA_ATTRIBUTE_Data, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Link}, - {0xbe52dfbf, L"desc", XFA_ATTRIBUTE_Desc, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, (void*)NULL}, - {0xbe9ba472, L"numbered", XFA_ATTRIBUTE_Numbered, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)1}, - {0xc035c6b1, L"dataColumnCount", XFA_ATTRIBUTE_DataColumnCount, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xc0ec9fa4, L"overline", XFA_ATTRIBUTE_Overline, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0xc2ba0923, L"urlPolicy", XFA_ATTRIBUTE_UrlPolicy, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xc2bd40fd, L"anchorType", XFA_ATTRIBUTE_AnchorType, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_TopLeft}, - {0xc39a88bd, L"labelRef", XFA_ATTRIBUTE_LabelRef, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xc3c1442f, L"bookendLeader", XFA_ATTRIBUTE_BookendLeader, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xc4547a08, L"maxLength", XFA_ATTRIBUTE_MaxLength, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*) - 1}, - {0xc4fed09b, L"accessKey", XFA_ATTRIBUTE_AccessKey, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xc5762157, L"cursorLocation", XFA_ATTRIBUTE_CursorLocation, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_SourceSet, - (void*)XFA_ATTRIBUTEENUM_Client}, - {0xc860f30a, L"delayedOpen", XFA_ATTRIBUTE_DelayedOpen, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_SourceSet, (void*)NULL}, - {0xc8da4da7, L"target", XFA_ATTRIBUTE_Target, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xca5dc27c, L"dataEncipherment", XFA_ATTRIBUTE_DataEncipherment, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xcb150479, L"afterTarget", XFA_ATTRIBUTE_AfterTarget, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xcbcaf66d, L"leader", XFA_ATTRIBUTE_Leader, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xcca7897e, L"picker", XFA_ATTRIBUTE_Picker, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Host}, - {0xcd7f7b54, L"from", XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config, (void*)NULL}, - {0xcea5e62c, L"baseProfile", XFA_ATTRIBUTE_BaseProfile, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Full}, - {0xd171b240, L"aspect", XFA_ATTRIBUTE_Aspect, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)XFA_ATTRIBUTEENUM_Fit}, - {0xd3c84d25, L"rowColumnRatio", XFA_ATTRIBUTE_RowColumnRatio, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xd4b01921, L"lineHeight", XFA_ATTRIBUTE_LineHeight, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 1)}, - {0xd4cc53f8, L"highlight", XFA_ATTRIBUTE_Highlight, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Inverted}, - {0xd50f903a, L"valueRef", XFA_ATTRIBUTE_ValueRef, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xd52482e0, L"maxEntries", XFA_ATTRIBUTE_MaxEntries, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Config, (void*)5}, - {0xd57c513c, L"dataLength", XFA_ATTRIBUTE_DataLength, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xd6128d8d, L"activity", XFA_ATTRIBUTE_Activity, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Click}, - {0xd6a39990, L"input", XFA_ATTRIBUTE_Input, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_ConnectionSet, (void*)NULL}, - {0xd6e27f1d, L"value", XFA_ATTRIBUTE_Value, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | - XFA_XDPPACKET_Template | XFA_XDPPACKET_Datasets | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xd70798c2, L"blankOrNotBlank", XFA_ATTRIBUTE_BlankOrNotBlank, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Any}, - {0xd861f8af, L"addRevocationInfo", XFA_ATTRIBUTE_AddRevocationInfo, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xd8f982bf, L"genericFamily", XFA_ATTRIBUTE_GenericFamily, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, - (void*)XFA_ATTRIBUTEENUM_Serif}, - {0xd996fa9b, L"hand", XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Even}, - {0xdb55fec5, L"href", XFA_ATTRIBUTE_Href, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xdc75676c, L"textEncoding", XFA_ATTRIBUTE_TextEncoding, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xde7f92ba, L"leadDigits", XFA_ATTRIBUTE_LeadDigits, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*) - 1}, - {0xe11a2cbc, L"permissions", XFA_ATTRIBUTE_Permissions, - XFA_ATTRIBUTETYPE_Integer, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)2}, - {0xe18b5659, L"spaceAbove", XFA_ATTRIBUTE_SpaceAbove, - XFA_ATTRIBUTETYPE_Measure, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0xe1a26b56, L"codeBase", XFA_ATTRIBUTE_CodeBase, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xe349d044, L"stock", XFA_ATTRIBUTE_Stock, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xe372ae97, L"isNull", XFA_ATTRIBUTE_IsNull, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Datasets, (void*)0}, - {0xe4c3a5e5, L"restoreState", XFA_ATTRIBUTE_RestoreState, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Manual}, - {0xe5c96d6a, L"excludeAllCaps", XFA_ATTRIBUTE_ExcludeAllCaps, - XFA_ATTRIBUTETYPE_Boolean, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)0}, - {0xe64b1129, L"formatTest", XFA_ATTRIBUTE_FormatTest, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Warning}, - {0xe6f99487, L"hScrollPolicy", XFA_ATTRIBUTE_HScrollPolicy, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xe8dddf50, L"join", XFA_ATTRIBUTE_Join, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Square}, - {0xe8f118a8, L"keyCertSign", XFA_ATTRIBUTE_KeyCertSign, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xe948b9a8, L"radius", XFA_ATTRIBUTE_Radius, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0xe996b2fe, L"sourceAbove", XFA_ATTRIBUTE_SourceAbove, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, - (void*)XFA_ATTRIBUTEENUM_Warn}, - {0xea7090a0, L"override", XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xeb091003, L"classId", XFA_ATTRIBUTE_ClassId, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xeb511b54, L"disable", XFA_ATTRIBUTE_Disable, XFA_ATTRIBUTETYPE_Boolean, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)0}, - {0xeda9017a, L"scope", XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_NOTSURE, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xf197844d, L"match", XFA_ATTRIBUTE_Match, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Once}, - {0xf2009339, L"placement", XFA_ATTRIBUTE_Placement, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Left}, - {0xf4ffce73, L"before", XFA_ATTRIBUTE_Before, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_Auto}, - {0xf531b059, L"writingScript", XFA_ATTRIBUTE_WritingScript, - XFA_ATTRIBUTETYPE_Enum, XFA_XDPPACKET_Config, - (void*)XFA_ATTRIBUTEENUM_Asterisk}, - {0xf575ca75, L"endChar", XFA_ATTRIBUTE_EndChar, XFA_ATTRIBUTETYPE_Cdata, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, (void*)NULL}, - {0xf6b47749, L"lock", XFA_ATTRIBUTE_Lock, XFA_ATTRIBUTETYPE_Integer, - XFA_XDPPACKET_Config, (void*)0}, - {0xf6b4afb0, L"long", XFA_ATTRIBUTE_Long, XFA_ATTRIBUTETYPE_Measure, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)(g_XFAMeasurementData + 0)}, - {0xf6b59543, L"intact", XFA_ATTRIBUTE_Intact, XFA_ATTRIBUTETYPE_Enum, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)XFA_ATTRIBUTEENUM_None}, - {0xf889e747, L"xdpContent", XFA_ATTRIBUTE_XdpContent, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, - {0xfea53ec6, L"decipherOnly", XFA_ATTRIBUTE_DecipherOnly, - XFA_ATTRIBUTETYPE_Cdata, XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - (void*)NULL}, -}; -const int32_t g_iXFAAttributeCount = - sizeof(g_XFAAttributeData) / sizeof(XFA_ATTRIBUTEINFO); -const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[] = { - {XFA_ELEMENT_SubformSet, XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Ordered}, - {XFA_ELEMENT_NumberPattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Numeric}, - {XFA_ELEMENT_KeyUsage, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_LabelPrinter, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Zpl}, - {XFA_ELEMENT_CalendarSymbols, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Gregorian}, - {XFA_ELEMENT_Barcode, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_Barcode, XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_None}, - {XFA_ELEMENT_TimePattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Med}, - {XFA_ELEMENT_BatchOutput, XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_None}, - {XFA_ELEMENT_SubjectDNs, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Issuers, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_EncryptionMethods, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Pattern, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_CrossHatch}, - {XFA_ELEMENT_Compress, XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_ImageOnly}, - {XFA_ELEMENT_Image, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Base64}, - {XFA_ELEMENT_TimeStamp, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Subform, XFA_ATTRIBUTE_Scope, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Name}, - {XFA_ELEMENT_Handler, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Record, XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_Integer, - (void*)0}, - {XFA_ELEMENT_Command, XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_Integer, - (void*)30}, - {XFA_ELEMENT_DigestMethods, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_PageSet, XFA_ATTRIBUTE_Relation, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_OrderedOccurrence}, - {XFA_ELEMENT_Equate, XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_Equate, XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_Traverse, XFA_ATTRIBUTE_Operation, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Next}, - {XFA_ELEMENT_Encodings, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Signing, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Oids, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Signature, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_PDF1_3}, - {XFA_ELEMENT_ExData, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_None}, - {XFA_ELEMENT_Linear, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_ToRight}, - {XFA_ELEMENT_CurrencySymbol, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Symbol}, - {XFA_ELEMENT_EquateRange, XFA_ATTRIBUTE_From, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_EquateRange, XFA_ATTRIBUTE_To, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_SignData, XFA_ATTRIBUTE_Operation, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Sign}, - {XFA_ELEMENT_DatePattern, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Med}, - {XFA_ELEMENT_Bind, XFA_ATTRIBUTE_TransferEncoding, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_None}, - {XFA_ELEMENT_Reasons, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_AppearanceFilter, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Form, XFA_ATTRIBUTE_Checksum, XFA_ATTRIBUTETYPE_Cdata, - (void*)NULL}, - {XFA_ELEMENT_Value, XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_Boolean, - (void*)0}, - {XFA_ELEMENT_Calculate, XFA_ATTRIBUTE_Override, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Error}, - {XFA_ELEMENT_Connect, XFA_ATTRIBUTE_Timeout, XFA_ATTRIBUTETYPE_Integer, - (void*)15}, - {XFA_ELEMENT_Submit, XFA_ATTRIBUTE_Format, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Xdp}, - {XFA_ELEMENT_Radial, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_ToEdge}, - {XFA_ELEMENT_LockDocument, XFA_ATTRIBUTE_Type, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Optional}, - {XFA_ELEMENT_Occur, XFA_ATTRIBUTE_Max, XFA_ATTRIBUTETYPE_Integer, (void*)1}, - {XFA_ELEMENT_NumberSymbol, XFA_ATTRIBUTE_Name, XFA_ATTRIBUTETYPE_Enum, - (void*)XFA_ATTRIBUTEENUM_Decimal}, -}; -const int32_t g_iXFANotsureCount = - sizeof(g_XFANotsureAttributes) / sizeof(XFA_NOTSUREATTRIBUTE); -const XFA_ELEMENTINFO g_XFAElementData[] = { - {0x23ee3, L"ps", XFA_ELEMENT_Ps, XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, - {0x25363, L"to", XFA_ELEMENT_To, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x2587e, L"ui", XFA_ELEMENT_Ui, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x1c648b, L"recordSet", XFA_ELEMENT_RecordSet, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_Node}, - {0x171428f, L"subsetBelow", XFA_ELEMENT_SubsetBelow, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x1a0776a, L"subformSet", XFA_ELEMENT_SubformSet, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x2340d70, L"adobeExtensionLevel", XFA_ELEMENT_AdobeExtensionLevel, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x2c1c7f1, L"typeface", XFA_ELEMENT_Typeface, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_Node}, - {0x5518c25, L"break", XFA_ELEMENT_Break, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x5fff523, L"fontInfo", XFA_ELEMENT_FontInfo, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x653a227, L"numberPattern", XFA_ELEMENT_NumberPattern, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0x65b4a05, L"dynamicRender", XFA_ELEMENT_DynamicRender, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x7e4362e, L"printScaling", XFA_ELEMENT_PrintScaling, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x7fe6d3a, L"checkButton", XFA_ELEMENT_CheckButton, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x80cf58f, L"datePatterns", XFA_ELEMENT_DatePatterns, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0x811929d, L"sourceSet", XFA_ELEMENT_SourceSet, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_ModelNode}, - {0x9f9d612, L"amd", XFA_ELEMENT_Amd, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x9f9efb6, L"arc", XFA_ELEMENT_Arc, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xa48835e, L"day", XFA_ELEMENT_Day, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_ContentNode}, - {0xa6328b8, L"era", XFA_ELEMENT_Era, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_ContentNode}, - {0xae6a0a0, L"jog", XFA_ELEMENT_Jog, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xb1b3d22, L"log", XFA_ELEMENT_Log, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xb35439e, L"map", XFA_ELEMENT_Map, - XFA_XDPPACKET_Config | XFA_XDPPACKET_SourceSet, XFA_OBJECTTYPE_Node}, - {0xb355301, L"mdp", XFA_ELEMENT_Mdp, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xb420438, L"breakBefore", XFA_ELEMENT_BreakBefore, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xb6a091c, L"oid", XFA_ELEMENT_Oid, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0xb84389f, L"pcl", XFA_ELEMENT_Pcl, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xb843dba, L"pdf", XFA_ELEMENT_Pdf, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xbb8df5d, L"ref", XFA_ELEMENT_Ref, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0xc080cd0, L"uri", XFA_ELEMENT_Uri, - XFA_XDPPACKET_Config | XFA_XDPPACKET_ConnectionSet, - XFA_OBJECTTYPE_TextNode}, - {0xc56afbf, L"xdc", XFA_ELEMENT_Xdc, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Xdc, XFA_OBJECTTYPE_ModelNode}, - {0xc56afcc, L"xdp", XFA_ELEMENT_Xdp, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc56b9ff, L"xfa", XFA_ELEMENT_Xfa, XFA_XDPPACKET_XDP, - XFA_OBJECTTYPE_ModelNode}, - {0xc56fcb7, L"xsl", XFA_ELEMENT_Xsl, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc8b89d6, L"zpl", XFA_ELEMENT_Zpl, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc9bae94, L"cache", XFA_ELEMENT_Cache, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xcb016be, L"margin", XFA_ELEMENT_Margin, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xe1378fe, L"keyUsage", XFA_ELEMENT_KeyUsage, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xfe3596a, L"exclude", XFA_ELEMENT_Exclude, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x10395ac7, L"choiceList", XFA_ELEMENT_ChoiceList, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x1059ec18, L"level", XFA_ELEMENT_Level, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x10874804, L"labelPrinter", XFA_ELEMENT_LabelPrinter, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, - {0x10c40e03, L"calendarSymbols", XFA_ELEMENT_CalendarSymbols, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0x10f1ea24, L"para", XFA_ELEMENT_Para, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x10f1ea37, L"part", XFA_ELEMENT_Part, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x1140975b, L"pdfa", XFA_ELEMENT_Pdfa, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x1154efe6, L"filter", XFA_ELEMENT_Filter, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x13f41de1, L"present", XFA_ELEMENT_Present, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x1827e6ea, L"pagination", XFA_ELEMENT_Pagination, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x18463707, L"encoding", XFA_ELEMENT_Encoding, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, - {0x185e41e2, L"event", XFA_ELEMENT_Event, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x1adb142d, L"whitespace", XFA_ELEMENT_Whitespace, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x1f3f64c3, L"defaultUi", XFA_ELEMENT_DefaultUi, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x204e87cb, L"dataModel", XFA_ELEMENT_DataModel, XFA_XDPPACKET_Datasets, - XFA_OBJECTTYPE_ModelNode}, - {0x2057b350, L"barcode", XFA_ELEMENT_Barcode, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x20596bad, L"timePattern", XFA_ELEMENT_TimePattern, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0x210b74d3, L"batchOutput", XFA_ELEMENT_BatchOutput, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x212ff0e2, L"enforce", XFA_ELEMENT_Enforce, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x21d351b4, L"currencySymbols", XFA_ELEMENT_CurrencySymbols, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0x21db83c5, L"addSilentPrint", XFA_ELEMENT_AddSilentPrint, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x22266258, L"rename", XFA_ELEMENT_Rename, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x226ca8f1, L"operation", XFA_ELEMENT_Operation, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, - {0x23e27b84, L"typefaces", XFA_ELEMENT_Typefaces, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_Node}, - {0x23f4aa75, L"subjectDNs", XFA_ELEMENT_SubjectDNs, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x240d5e8e, L"issuers", XFA_ELEMENT_Issuers, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x2457a033, L"signaturePseudoModel", XFA_ELEMENT_SignaturePseudoModel, - XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, - {0x24a52f8a, L"wsdlConnection", XFA_ELEMENT_WsdlConnection, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, - {0x254ebd07, L"debug", XFA_ELEMENT_Debug, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x2655c66a, L"delta", XFA_ELEMENT_Delta, XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_OrdinaryObject}, - {0x26c0daec, L"eraNames", XFA_ELEMENT_EraNames, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_Node}, - {0x273ab03b, L"modifyAnnots", XFA_ELEMENT_ModifyAnnots, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x27875bb4, L"startNode", XFA_ELEMENT_StartNode, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x285d0dbc, L"button", XFA_ELEMENT_Button, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x28dee6e9, L"format", XFA_ELEMENT_Format, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x2a23349e, L"border", XFA_ELEMENT_Border, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x2ae67f19, L"area", XFA_ELEMENT_Area, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContainerNode}, - {0x2c3c4c67, L"hyphenation", XFA_ELEMENT_Hyphenation, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x2d08af85, L"text", XFA_ELEMENT_Text, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x2d71b00f, L"time", XFA_ELEMENT_Time, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0x2f16a382, L"type", XFA_ELEMENT_Type, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x2fe057e9, L"overprint", XFA_ELEMENT_Overprint, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x302aee16, L"certificates", XFA_ELEMENT_Certificates, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x30b227df, L"encryptionMethods", XFA_ELEMENT_EncryptionMethods, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x32b900d1, L"setProperty", XFA_ELEMENT_SetProperty, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x337d9e45, L"printerName", XFA_ELEMENT_PrinterName, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x33edda4b, L"startPage", XFA_ELEMENT_StartPage, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x381943e4, L"pageOffset", XFA_ELEMENT_PageOffset, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x382106cd, L"dateTime", XFA_ELEMENT_DateTime, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0x386e7421, L"comb", XFA_ELEMENT_Comb, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x390acd9e, L"pattern", XFA_ELEMENT_Pattern, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x3942163e, L"ifEmpty", XFA_ELEMENT_IfEmpty, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x39944a7b, L"suppressBanner", XFA_ELEMENT_SuppressBanner, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x3b3c3dca, L"outputBin", XFA_ELEMENT_OutputBin, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x3b8a4024, L"field", XFA_ELEMENT_Field, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x3c15352f, L"agent", XFA_ELEMENT_Agent, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x3d7e8668, L"outputXSL", XFA_ELEMENT_OutputXSL, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x3e1c91c5, L"adjustData", XFA_ELEMENT_AdjustData, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x3e7a9408, L"autoSave", XFA_ELEMENT_AutoSave, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x3ecead94, L"contentArea", XFA_ELEMENT_ContentArea, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x3ef334e3, L"eventPseudoModel", XFA_ELEMENT_EventPseudoModel, - XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, - {0x3fadaec0, L"wsdlAddress", XFA_ELEMENT_WsdlAddress, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, - {0x40623b5b, L"solid", XFA_ELEMENT_Solid, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x41f0bd76, L"dateTimeSymbols", XFA_ELEMENT_DateTimeSymbols, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0x444e7523, L"encryptionLevel", XFA_ELEMENT_EncryptionLevel, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x4523af55, L"edge", XFA_ELEMENT_Edge, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x45d5e3c1, L"stipple", XFA_ELEMENT_Stipple, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x475e4e87, L"attributes", XFA_ELEMENT_Attributes, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x487a8c87, L"versionControl", XFA_ELEMENT_VersionControl, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, - {0x48e5248c, L"meridiem", XFA_ELEMENT_Meridiem, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_ContentNode}, - {0x48f36719, L"exclGroup", XFA_ELEMENT_ExclGroup, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x4977356b, L"toolTip", XFA_ELEMENT_ToolTip, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0x499afecc, L"compress", XFA_ELEMENT_Compress, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x4a0c4948, L"reason", XFA_ELEMENT_Reason, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0x4bdcce13, L"execute", XFA_ELEMENT_Execute, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x4c56b216, L"contentCopy", XFA_ELEMENT_ContentCopy, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x4cc176d3, L"dateTimeEdit", XFA_ELEMENT_DateTimeEdit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x4e1e39b6, L"config", XFA_ELEMENT_Config, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ModelNode}, - {0x4e2d6083, L"image", XFA_ELEMENT_Image, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0x4e814150, L"#xHTML", XFA_ELEMENT_SharpxHTML, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_SourceSet | - XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_NodeV}, - {0x4f2388c1, L"numberOfCopies", XFA_ELEMENT_NumberOfCopies, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x4f512e30, L"behaviorOverride", XFA_ELEMENT_BehaviorOverride, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x4fdc3454, L"timeStamp", XFA_ELEMENT_TimeStamp, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x51d90546, L"month", XFA_ELEMENT_Month, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_ContentNode}, - {0x523437e4, L"viewerPreferences", XFA_ELEMENT_ViewerPreferences, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, - {0x53abc1c6, L"scriptModel", XFA_ELEMENT_ScriptModel, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x54034c2f, L"decimal", XFA_ELEMENT_Decimal, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0x54202c9e, L"subform", XFA_ELEMENT_Subform, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x542c7300, L"select", XFA_ELEMENT_Select, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0x5436d198, L"window", XFA_ELEMENT_Window, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x5473b6dc, L"localeSet", XFA_ELEMENT_LocaleSet, - XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ModelNode}, - {0x56ae179e, L"handler", XFA_ELEMENT_Handler, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0x5700bd5f, L"hostPseudoModel", XFA_ELEMENT_HostPseudoModel, - XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, - {0x570ce835, L"presence", XFA_ELEMENT_Presence, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x5779d65f, L"record", XFA_ELEMENT_Record, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x59c8f27d, L"embed", XFA_ELEMENT_Embed, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x5a50e9e6, L"version", XFA_ELEMENT_Version, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x5b8383df, L"command", XFA_ELEMENT_Command, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_Node}, - {0x5c43c6c3, L"copies", XFA_ELEMENT_Copies, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x5e0c2c49, L"staple", XFA_ELEMENT_Staple, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x5e5083dd, L"submitFormat", XFA_ELEMENT_SubmitFormat, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x5e8c5d20, L"boolean", XFA_ELEMENT_Boolean, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x60490a85, L"message", XFA_ELEMENT_Message, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_Node}, - {0x60d4c8b1, L"output", XFA_ELEMENT_Output, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x61810081, L"psMap", XFA_ELEMENT_PsMap, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x62bd904b, L"excludeNS", XFA_ELEMENT_ExcludeNS, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x669d4f77, L"assist", XFA_ELEMENT_Assist, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x67334a1c, L"picture", XFA_ELEMENT_Picture, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x67fe7334, L"traversal", XFA_ELEMENT_Traversal, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x6894589c, L"silentPrint", XFA_ELEMENT_SilentPrint, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x68a16bbd, L"webClient", XFA_ELEMENT_WebClient, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x69f115df, L"layoutPseudoModel", XFA_ELEMENT_LayoutPseudoModel, - XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, - {0x6a4bc084, L"producer", XFA_ELEMENT_Producer, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x6a9e04c9, L"corner", XFA_ELEMENT_Corner, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x6ccd7274, L"msgId", XFA_ELEMENT_MsgId, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x6e67921f, L"color", XFA_ELEMENT_Color, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x6ec217a5, L"keep", XFA_ELEMENT_Keep, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x6eef1116, L"query", XFA_ELEMENT_Query, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_Node}, - {0x7033bfd5, L"insert", XFA_ELEMENT_Insert, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0x704af389, L"imageEdit", XFA_ELEMENT_ImageEdit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x7233018a, L"validate", XFA_ELEMENT_Validate, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x72ba47b4, L"digestMethods", XFA_ELEMENT_DigestMethods, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x72f2aa7a, L"numberPatterns", XFA_ELEMENT_NumberPatterns, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0x74caed29, L"pageSet", XFA_ELEMENT_PageSet, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x7568e6ae, L"integer", XFA_ELEMENT_Integer, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x76182db9, L"soapAddress", XFA_ELEMENT_SoapAddress, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, - {0x773146c5, L"equate", XFA_ELEMENT_Equate, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x77d449dd, L"formFieldFilling", XFA_ELEMENT_FormFieldFilling, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x7889d68a, L"pageRange", XFA_ELEMENT_PageRange, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x7baca2e3, L"update", XFA_ELEMENT_Update, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0x7ce89001, L"connectString", XFA_ELEMENT_ConnectString, - XFA_XDPPACKET_SourceSet, XFA_OBJECTTYPE_TextNode}, - {0x7d9fd7c5, L"mode", XFA_ELEMENT_Mode, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x7e7e845e, L"layout", XFA_ELEMENT_Layout, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x7e845c34, L"#xml", XFA_ELEMENT_Sharpxml, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeV}, - {0x7fb341df, L"xsdConnection", XFA_ELEMENT_XsdConnection, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, - {0x7ffb51cc, L"traverse", XFA_ELEMENT_Traverse, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x80203b5a, L"encodings", XFA_ELEMENT_Encodings, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x803550fc, L"template", XFA_ELEMENT_Template, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ModelNode}, - {0x803d5bbc, L"acrobat", XFA_ELEMENT_Acrobat, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0x821d6569, L"validationMessaging", XFA_ELEMENT_ValidationMessaging, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, - {0x830e688f, L"signing", XFA_ELEMENT_Signing, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x83a550d2, L"dataWindow", XFA_ELEMENT_DataWindow, XFA_XDPPACKET_Datasets, - XFA_OBJECTTYPE_OrdinaryObject}, - {0x83dab9f5, L"script", XFA_ELEMENT_Script, - XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0x8411ebcd, L"addViewerPreferences", XFA_ELEMENT_AddViewerPreferences, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x8777642e, L"alwaysEmbed", XFA_ELEMENT_AlwaysEmbed, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x877a6b39, L"passwordEdit", XFA_ELEMENT_PasswordEdit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x87e84c99, L"numericEdit", XFA_ELEMENT_NumericEdit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x8852cdec, L"encryptionMethod", XFA_ELEMENT_EncryptionMethod, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, - {0x891f4606, L"change", XFA_ELEMENT_Change, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x89939f36, L"pageArea", XFA_ELEMENT_PageArea, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0x8a9d6247, L"submitUrl", XFA_ELEMENT_SubmitUrl, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0x8ad8b90f, L"oids", XFA_ELEMENT_Oids, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x8b036f32, L"signature", XFA_ELEMENT_Signature, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x8b128efb, L"ADBE_JSConsole", XFA_ELEMENT_ADBE_JSConsole, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0x8bcfe96e, L"caption", XFA_ELEMENT_Caption, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x8e1c2921, L"relevant", XFA_ELEMENT_Relevant, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x8e3f0a4b, L"flipLabel", XFA_ELEMENT_FlipLabel, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0x900280b7, L"exData", XFA_ELEMENT_ExData, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0x91e80352, L"dayNames", XFA_ELEMENT_DayNames, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_Node}, - {0x93113b11, L"soapAction", XFA_ELEMENT_SoapAction, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, - {0x938b09f6, L"defaultTypeface", XFA_ELEMENT_DefaultTypeface, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, - {0x95b37897, L"manifest", XFA_ELEMENT_Manifest, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x97b76b54, L"overflow", XFA_ELEMENT_Overflow, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x9a57861b, L"linear", XFA_ELEMENT_Linear, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0x9ad5a821, L"currencySymbol", XFA_ELEMENT_CurrencySymbol, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0x9c6471b3, L"delete", XFA_ELEMENT_Delete, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0x9deea61d, L"deltas", XFA_ELEMENT_Deltas, XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_OrdinaryObject}, - {0x9e67de21, L"digestMethod", XFA_ELEMENT_DigestMethod, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, - {0x9f3e9510, L"instanceManager", XFA_ELEMENT_InstanceManager, - XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xa0799892, L"equateRange", XFA_ELEMENT_EquateRange, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xa084a381, L"medium", XFA_ELEMENT_Medium, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xa1211b8b, L"textEdit", XFA_ELEMENT_TextEdit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xa17008f0, L"templateCache", XFA_ELEMENT_TemplateCache, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_Node}, - {0xa4f7b88f, L"compressObjectStream", XFA_ELEMENT_CompressObjectStream, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xa65f5d17, L"dataValue", XFA_ELEMENT_DataValue, XFA_XDPPACKET_Datasets, - XFA_OBJECTTYPE_Node}, - {0xa6caaa89, L"accessibleContent", XFA_ELEMENT_AccessibleContent, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xa8c7d5e2, L"nodeList", XFA_ELEMENT_NodeList, XFA_XDPPACKET_XDP, - XFA_OBJECTTYPE_NodeList}, - {0xa94cc00b, L"includeXDPContent", XFA_ELEMENT_IncludeXDPContent, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xa9b081a1, L"xmlConnection", XFA_ELEMENT_XmlConnection, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, - {0xab2a3b74, L"validateApprovalSignatures", - XFA_ELEMENT_ValidateApprovalSignatures, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xab8c5a2b, L"signData", XFA_ELEMENT_SignData, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xabaa2ceb, L"packets", XFA_ELEMENT_Packets, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xadba359c, L"datePattern", XFA_ELEMENT_DatePattern, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0xae222b2b, L"duplexOption", XFA_ELEMENT_DuplexOption, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xb012effb, L"base", XFA_ELEMENT_Base, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xb0e5485d, L"bind", XFA_ELEMENT_Bind, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_Node}, - {0xb45d61b2, L"compression", XFA_ELEMENT_Compression, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xb563f0ff, L"user", XFA_ELEMENT_User, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0xb5848ad5, L"rectangle", XFA_ELEMENT_Rectangle, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xb6dacb72, L"effectiveOutputPolicy", XFA_ELEMENT_EffectiveOutputPolicy, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, - {0xb7d7654d, L"ADBE_JSDebugger", XFA_ELEMENT_ADBE_JSDebugger, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xbab37f73, L"acrobat7", XFA_ELEMENT_Acrobat7, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xbc70081e, L"interactive", XFA_ELEMENT_Interactive, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xbc8fa350, L"locale", XFA_ELEMENT_Locale, - XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0xbcd44940, L"currentPage", XFA_ELEMENT_CurrentPage, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xbde9abda, L"data", XFA_ELEMENT_Data, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xbde9abde, L"date", XFA_ELEMENT_Date, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0xbe52dfbf, L"desc", XFA_ELEMENT_Desc, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xbf4b6405, L"encrypt", XFA_ELEMENT_Encrypt, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ContentNode}, - {0xbfa87cce, L"draw", XFA_ELEMENT_Draw, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0xc181ff4b, L"encryption", XFA_ELEMENT_Encryption, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc1970f40, L"meridiemNames", XFA_ELEMENT_MeridiemNames, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0xc5ad9f5e, L"messaging", XFA_ELEMENT_Messaging, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc69549f4, L"speak", XFA_ELEMENT_Speak, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0xc7743dc7, L"dataGroup", XFA_ELEMENT_DataGroup, XFA_XDPPACKET_Datasets, - XFA_OBJECTTYPE_Node}, - {0xc7eb20e9, L"common", XFA_ELEMENT_Common, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xc85d4528, L"#text", XFA_ELEMENT_Sharptext, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_LocaleSet | - XFA_XDPPACKET_ConnectionSet | XFA_XDPPACKET_SourceSet | - XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_NodeV}, - {0xc861556a, L"paginationOverride", XFA_ELEMENT_PaginationOverride, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xc903dabb, L"reasons", XFA_ELEMENT_Reasons, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xc9a8127f, L"signatureProperties", XFA_ELEMENT_SignatureProperties, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xca010c2d, L"threshold", XFA_ELEMENT_Threshold, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xcb4c5e96, L"appearanceFilter", XFA_ELEMENT_AppearanceFilter, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, - {0xcc92aba7, L"fill", XFA_ELEMENT_Fill, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xcd308b77, L"font", XFA_ELEMENT_Font, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Config | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_Node}, - {0xcd309ff4, L"form", XFA_ELEMENT_Form, XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_ModelNode}, - {0xcebcca2d, L"mediumInfo", XFA_ELEMENT_MediumInfo, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xcfe0d643, L"certificate", XFA_ELEMENT_Certificate, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_TextNode}, - {0xd012c033, L"password", XFA_ELEMENT_Password, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_TextNode}, - {0xd01604bd, L"runScripts", XFA_ELEMENT_RunScripts, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xd1227e6f, L"trace", XFA_ELEMENT_Trace, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xd1532876, L"float", XFA_ELEMENT_Float, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0xd17a6c30, L"renderPolicy", XFA_ELEMENT_RenderPolicy, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xd4bf6823, L"logPseudoModel", XFA_ELEMENT_LogPseudoModel, - XFA_XDPPACKET_XDP, XFA_OBJECTTYPE_OrdinaryObject}, - {0xd58aa962, L"destination", XFA_ELEMENT_Destination, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xd6e27f1d, L"value", XFA_ELEMENT_Value, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xd7a14462, L"bookend", XFA_ELEMENT_Bookend, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xd8c31254, L"exObject", XFA_ELEMENT_ExObject, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xda6a8590, L"openAction", XFA_ELEMENT_OpenAction, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xdab4fb7d, L"neverEmbed", XFA_ELEMENT_NeverEmbed, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xdb98475f, L"bindItems", XFA_ELEMENT_BindItems, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xdbfbe02e, L"calculate", XFA_ELEMENT_Calculate, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xdd7676ed, L"print", XFA_ELEMENT_Print, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xdde273d7, L"extras", XFA_ELEMENT_Extras, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_Node}, - {0xde146b34, L"proto", XFA_ELEMENT_Proto, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xdf059321, L"dSigData", XFA_ELEMENT_DSigData, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xdfccf030, L"creator", XFA_ELEMENT_Creator, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xdff78c6a, L"connect", XFA_ELEMENT_Connect, - XFA_XDPPACKET_SourceSet | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, - XFA_OBJECTTYPE_Node}, - {0xe11a2cbc, L"permissions", XFA_ELEMENT_Permissions, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xe14c801c, L"connectionSet", XFA_ELEMENT_ConnectionSet, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_ModelNode}, - {0xe1c83a14, L"submit", XFA_ELEMENT_Submit, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xe29821cd, L"range", XFA_ELEMENT_Range, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xe38d83c7, L"linearized", XFA_ELEMENT_Linearized, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xe3aa2578, L"packet", XFA_ELEMENT_Packet, XFA_XDPPACKET_XDP, - XFA_OBJECTTYPE_NodeC}, - {0xe3aa860e, L"rootElement", XFA_ELEMENT_RootElement, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_TextNode}, - {0xe3e553fa, L"plaintextMetadata", XFA_ELEMENT_PlaintextMetadata, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xe3e6e4f2, L"numberSymbols", XFA_ELEMENT_NumberSymbols, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0xe3f067f6, L"printHighQuality", XFA_ELEMENT_PrintHighQuality, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xe3fd078c, L"driver", XFA_ELEMENT_Driver, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xe48b34f2, L"incrementalLoad", XFA_ELEMENT_IncrementalLoad, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_NodeV}, - {0xe550e7c2, L"subjectDN", XFA_ELEMENT_SubjectDN, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_NodeC}, - {0xe6669a78, L"compressLogicalStructure", - XFA_ELEMENT_CompressLogicalStructure, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xe7a7ea02, L"incrementalMerge", XFA_ELEMENT_IncrementalMerge, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xe948530d, L"radial", XFA_ELEMENT_Radial, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xea8d6999, L"variables", XFA_ELEMENT_Variables, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContainerNode}, - {0xeaa142c0, L"timePatterns", XFA_ELEMENT_TimePatterns, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_Node}, - {0xeb943a71, L"effectiveInputPolicy", XFA_ELEMENT_EffectiveInputPolicy, - XFA_XDPPACKET_ConnectionSet, XFA_OBJECTTYPE_Node}, - {0xef04a2bc, L"nameAttr", XFA_ELEMENT_NameAttr, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xf07222ab, L"conformance", XFA_ELEMENT_Conformance, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xf0aaaadc, L"transform", XFA_ELEMENT_Transform, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_Node}, - {0xf1433e88, L"lockDocument", XFA_ELEMENT_LockDocument, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_ContentNode}, - {0xf54eb997, L"breakAfter", XFA_ELEMENT_BreakAfter, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xf616da28, L"line", XFA_ELEMENT_Line, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xf616f3dc, L"list", XFA_ELEMENT_List, XFA_XDPPACKET_XDP, - XFA_OBJECTTYPE_OrdinaryList}, - {0xf7055fb1, L"source", XFA_ELEMENT_Source, XFA_XDPPACKET_SourceSet, - XFA_OBJECTTYPE_Node}, - {0xf7eebe1c, L"occur", XFA_ELEMENT_Occur, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, - {0xf8d10d97, L"pickTrayByPDFSize", XFA_ELEMENT_PickTrayByPDFSize, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xf8f19e3a, L"monthNames", XFA_ELEMENT_MonthNames, XFA_XDPPACKET_LocaleSet, - XFA_OBJECTTYPE_Node}, - {0xf984149b, L"severity", XFA_ELEMENT_Severity, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xf9bcb037, L"groupParent", XFA_ELEMENT_GroupParent, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_NodeV}, - {0xfbc42fff, L"documentAssembly", XFA_ELEMENT_DocumentAssembly, - XFA_XDPPACKET_Config, XFA_OBJECTTYPE_ContentNode}, - {0xfc78159f, L"numberSymbol", XFA_ELEMENT_NumberSymbol, - XFA_XDPPACKET_LocaleSet, XFA_OBJECTTYPE_ContentNode}, - {0xfcbd606c, L"tagged", XFA_ELEMENT_Tagged, XFA_XDPPACKET_Config, - XFA_OBJECTTYPE_ContentNode}, - {0xff063802, L"items", XFA_ELEMENT_Items, - XFA_XDPPACKET_Template | XFA_XDPPACKET_Form, XFA_OBJECTTYPE_Node}, -}; -const int32_t g_iXFAElementCount = - sizeof(g_XFAElementData) / sizeof(XFA_ELEMENTINFO); -const XFA_ELEMENTHIERARCHY g_XFAElementPropertyIndex[] = { - {0, 8}, {8, 0}, {8, 14}, {22, 0}, {22, 0}, {22, 6}, {28, 0}, - {28, 0}, {28, 1}, {29, 3}, {32, 0}, {32, 0}, {32, 0}, {32, 3}, - {35, 1}, {36, 0}, {36, 0}, {36, 2}, {38, 0}, {38, 0}, {38, 0}, - {38, 4}, {42, 0}, {42, 0}, {42, 1}, {43, 0}, {43, 8}, {51, 19}, - {70, 0}, {70, 0}, {70, 2}, {72, 1}, {73, 0}, {73, 2}, {75, 4}, - {79, 1}, {80, 1}, {81, 0}, {81, 0}, {81, 3}, {84, 0}, {84, 4}, - {88, 4}, {92, 1}, {93, 0}, {93, 4}, {97, 9}, {106, 14}, {120, 0}, - {120, 0}, {120, 5}, {125, 0}, {125, 1}, {126, 0}, {126, 0}, {126, 0}, - {126, 0}, {126, 0}, {126, 1}, {127, 0}, {127, 0}, {127, 0}, {127, 0}, - {127, 0}, {127, 0}, {127, 0}, {127, 6}, {133, 1}, {134, 0}, {134, 1}, - {135, 0}, {135, 0}, {135, 1}, {136, 2}, {138, 5}, {143, 2}, {145, 0}, - {145, 0}, {145, 0}, {145, 0}, {145, 0}, {145, 5}, {150, 0}, {150, 0}, - {150, 0}, {150, 0}, {150, 0}, {150, 0}, {150, 0}, {150, 2}, {152, 0}, - {152, 0}, {152, 0}, {152, 17}, {169, 0}, {169, 1}, {170, 0}, {170, 0}, - {170, 2}, {172, 0}, {172, 0}, {172, 1}, {173, 0}, {173, 0}, {173, 2}, - {175, 2}, {177, 0}, {177, 0}, {177, 0}, {177, 11}, {188, 0}, {188, 0}, - {188, 0}, {188, 0}, {188, 0}, {188, 4}, {192, 3}, {195, 0}, {195, 0}, - {195, 0}, {195, 0}, {195, 0}, {195, 0}, {195, 9}, {204, 0}, {204, 0}, - {204, 17}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, {221, 0}, - {221, 0}, {221, 0}, {221, 0}, {221, 4}, {225, 0}, {225, 0}, {225, 0}, - {225, 0}, {225, 2}, {227, 3}, {230, 0}, {230, 0}, {230, 2}, {232, 0}, - {232, 1}, {233, 2}, {235, 2}, {237, 0}, {237, 0}, {237, 2}, {239, 0}, - {239, 1}, {240, 1}, {241, 2}, {243, 0}, {243, 3}, {246, 4}, {250, 0}, - {250, 1}, {251, 2}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, - {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 0}, {253, 2}, {255, 2}, - {257, 0}, {257, 6}, {263, 5}, {268, 0}, {268, 0}, {268, 0}, {268, 3}, - {271, 0}, {271, 0}, {271, 3}, {274, 4}, {278, 0}, {278, 0}, {278, 4}, - {282, 0}, {282, 0}, {282, 5}, {287, 0}, {287, 5}, {292, 0}, {292, 0}, - {292, 0}, {292, 1}, {293, 0}, {293, 0}, {293, 1}, {294, 0}, {294, 2}, - {296, 0}, {296, 0}, {296, 0}, {296, 0}, {296, 1}, {297, 0}, {297, 0}, - {297, 4}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, {301, 0}, - {301, 1}, {302, 0}, {302, 2}, {304, 0}, {304, 0}, {304, 0}, {304, 0}, - {304, 1}, {305, 4}, {309, 0}, {309, 3}, {312, 0}, {312, 0}, {312, 1}, - {313, 0}, {313, 8}, {321, 0}, {321, 10}, {331, 0}, {331, 10}, {341, 1}, - {342, 12}, {354, 3}, {357, 1}, {358, 0}, {358, 0}, {358, 0}, {358, 8}, - {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 0}, {366, 7}, - {373, 2}, {375, 0}, {375, 1}, {376, 0}, {376, 0}, {376, 0}, {376, 0}, - {376, 0}, {376, 0}, {376, 0}, {376, 0}, {376, 13}, {389, 0}, {389, 1}, - {390, 1}, {391, 0}, {391, 0}, {391, 3}, {394, 0}, {394, 0}, {394, 0}, - {394, 0}, {394, 0}, {394, 4}, {398, 9}, {407, 0}, {407, 1}, {408, 0}, - {408, 0}, {408, 0}, {408, 0}, {408, 0}, {408, 1}, {409, 0}, {409, 2}, - {411, 0}, {411, 0}, {411, 0}, {411, 0}, {411, 2}, {413, 0}, {413, 1}, - {414, 0}, {414, 0}, {414, 0}, {414, 7}, {421, 0}, {421, 1}, {422, 1}, - {423, 0}, {423, 1}, {424, 1}, {425, 0}, {425, 1}, {426, 0}, {426, 0}, - {426, 0}, {426, 0}, {426, 0}, {426, 0}, -}; -const XFA_PROPERTY g_XFAElementPropertyData[] = { - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Jog, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_BatchOutput, 1, 0}, - {XFA_ELEMENT_OutputBin, 1, 0}, - {XFA_ELEMENT_Compress, 1, 0}, - {XFA_ELEMENT_Staple, 1, 0}, - {XFA_ELEMENT_MediumInfo, 1, 0}, - {XFA_ELEMENT_CheckButton, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_ChoiceList, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_DefaultUi, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Barcode, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Button, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_DateTimeEdit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_ImageEdit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_PasswordEdit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_NumericEdit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Signature, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_TextEdit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_ExObject, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Break, 1, 0}, - {XFA_ELEMENT_Overflow, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Bookend, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Occur, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_SubsetBelow, 1, 0}, - {XFA_ELEMENT_Map, 1, 0}, - {XFA_ELEMENT_Embed, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_DatePattern, 4, 0}, - {XFA_ELEMENT_Edge, 1, 0}, - {XFA_ELEMENT_Fill, 1, 0}, - {XFA_ELEMENT_To, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Mode, 1, 0}, - {XFA_ELEMENT_Threshold, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Jog, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_BatchOutput, 1, 0}, - {XFA_ELEMENT_PageOffset, 1, 0}, - {XFA_ELEMENT_OutputBin, 1, 0}, - {XFA_ELEMENT_Staple, 1, 0}, - {XFA_ELEMENT_MediumInfo, 1, 0}, - {XFA_ELEMENT_AdobeExtensionLevel, 1, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_Pdfa, 1, 0}, - {XFA_ELEMENT_BatchOutput, 1, 0}, - {XFA_ELEMENT_ViewerPreferences, 1, 0}, - {XFA_ELEMENT_ScriptModel, 1, 0}, - {XFA_ELEMENT_Version, 1, 0}, - {XFA_ELEMENT_SubmitFormat, 1, 0}, - {XFA_ELEMENT_SilentPrint, 1, 0}, - {XFA_ELEMENT_Producer, 1, 0}, - {XFA_ELEMENT_Compression, 1, 0}, - {XFA_ELEMENT_Interactive, 1, 0}, - {XFA_ELEMENT_Encryption, 1, 0}, - {XFA_ELEMENT_RenderPolicy, 1, 0}, - {XFA_ELEMENT_OpenAction, 1, 0}, - {XFA_ELEMENT_Creator, 1, 0}, - {XFA_ELEMENT_Linearized, 1, 0}, - {XFA_ELEMENT_Tagged, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Xsl, 1, 0}, - {XFA_ELEMENT_Packets, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Debug, 1, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_BatchOutput, 1, 0}, - {XFA_ELEMENT_FlipLabel, 1, 0}, - {XFA_ELEMENT_TemplateCache, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_BatchOutput, 1, 0}, - {XFA_ELEMENT_FlipLabel, 1, 0}, - {XFA_ELEMENT_EraNames, 1, 0}, - {XFA_ELEMENT_DayNames, 2, 0}, - {XFA_ELEMENT_MeridiemNames, 1, 0}, - {XFA_ELEMENT_MonthNames, 2, 0}, - {XFA_ELEMENT_Hyphenation, 1, 0}, - {XFA_ELEMENT_Amd, 1, 0}, - {XFA_ELEMENT_Part, 1, 0}, - {XFA_ELEMENT_IncludeXDPContent, 1, 0}, - {XFA_ELEMENT_Conformance, 1, 0}, - {XFA_ELEMENT_Mdp, 1, 0}, - {XFA_ELEMENT_Certificates, 1, 0}, - {XFA_ELEMENT_TimeStamp, 1, 0}, - {XFA_ELEMENT_Handler, 1, 0}, - {XFA_ELEMENT_DigestMethods, 1, 0}, - {XFA_ELEMENT_Encodings, 1, 0}, - {XFA_ELEMENT_Reasons, 1, 0}, - {XFA_ELEMENT_AppearanceFilter, 1, 0}, - {XFA_ELEMENT_LockDocument, 1, 0}, - {XFA_ELEMENT_Xdp, 1, 0}, - {XFA_ELEMENT_Cache, 1, 0}, - {XFA_ELEMENT_Pagination, 1, 0}, - {XFA_ELEMENT_Overprint, 1, 0}, - {XFA_ELEMENT_BehaviorOverride, 1, 0}, - {XFA_ELEMENT_Copies, 1, 0}, - {XFA_ELEMENT_Output, 1, 0}, - {XFA_ELEMENT_Validate, 1, 0}, - {XFA_ELEMENT_Layout, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_Common, 1, 0}, - {XFA_ELEMENT_PaginationOverride, 1, 0}, - {XFA_ELEMENT_Destination, 1, 0}, - {XFA_ELEMENT_IncrementalMerge, 1, 0}, - {XFA_ELEMENT_Execute, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Script, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_SignData, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Submit, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_CurrencySymbol, 3, 0}, - {XFA_ELEMENT_Operation, 1, 0}, - {XFA_ELEMENT_WsdlAddress, 1, 0}, - {XFA_ELEMENT_SoapAddress, 1, 0}, - {XFA_ELEMENT_SoapAction, 1, 0}, - {XFA_ELEMENT_EffectiveOutputPolicy, 1, 0}, - {XFA_ELEMENT_EffectiveInputPolicy, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Era, 2, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Edge, 4, 0}, - {XFA_ELEMENT_Corner, 4, 0}, - {XFA_ELEMENT_Fill, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_KeyUsage, 1, 0}, - {XFA_ELEMENT_SubjectDNs, 1, 0}, - {XFA_ELEMENT_Issuers, 1, 0}, - {XFA_ELEMENT_Signing, 1, 0}, - {XFA_ELEMENT_Oids, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Ui, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Para, 1, 0}, - {XFA_ELEMENT_Format, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Assist, 1, 0}, - {XFA_ELEMENT_Traversal, 1, 0}, - {XFA_ELEMENT_Keep, 1, 0}, - {XFA_ELEMENT_Validate, 1, 0}, - {XFA_ELEMENT_Caption, 1, 0}, - {XFA_ELEMENT_Bind, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Font, 1, 0}, - {XFA_ELEMENT_Value, 1, 0}, - {XFA_ELEMENT_Calculate, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Items, 2, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Para, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Assist, 1, 0}, - {XFA_ELEMENT_Traversal, 1, 0}, - {XFA_ELEMENT_Validate, 1, 0}, - {XFA_ELEMENT_Caption, 1, 0}, - {XFA_ELEMENT_Bind, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Calculate, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Comb, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Present, 1, 0}, - {XFA_ELEMENT_Acrobat, 1, 0}, - {XFA_ELEMENT_Trace, 1, 0}, - {XFA_ELEMENT_PrintScaling, 1, 0}, - {XFA_ELEMENT_Enforce, 1, 0}, - {XFA_ELEMENT_NumberOfCopies, 1, 0}, - {XFA_ELEMENT_PageRange, 1, 0}, - {XFA_ELEMENT_AddViewerPreferences, 1, 0}, - {XFA_ELEMENT_ADBE_JSConsole, 1, 0}, - {XFA_ELEMENT_DuplexOption, 1, 0}, - {XFA_ELEMENT_ADBE_JSDebugger, 1, 0}, - {XFA_ELEMENT_PickTrayByPDFSize, 1, 0}, - {XFA_ELEMENT_Break, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Para, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Assist, 1, 0}, - {XFA_ELEMENT_Traversal, 1, 0}, - {XFA_ELEMENT_Keep, 1, 0}, - {XFA_ELEMENT_Validate, 1, 0}, - {XFA_ELEMENT_PageSet, 1, 0}, - {XFA_ELEMENT_Overflow, 1, 0}, - {XFA_ELEMENT_Bind, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Bookend, 1, 0}, - {XFA_ELEMENT_Calculate, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Variables, 1, 0}, - {XFA_ELEMENT_Occur, 1, 0}, - {XFA_ELEMENT_Query, 1, 0}, - {XFA_ELEMENT_Insert, 1, 0}, - {XFA_ELEMENT_Update, 1, 0}, - {XFA_ELEMENT_Delete, 1, 0}, - {XFA_ELEMENT_MsgId, 1, 0}, - {XFA_ELEMENT_Severity, 1, 0}, - {XFA_ELEMENT_To, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Type, 1, 0}, - {XFA_ELEMENT_ToolTip, 1, 0}, - {XFA_ELEMENT_Speak, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_AddSilentPrint, 1, 0}, - {XFA_ELEMENT_PrinterName, 1, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_RecordSet, 1, 0}, - {XFA_ELEMENT_Select, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Message, 1, 0}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_NumberPattern, 4, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Occur, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_RootElement, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Xsl, 1, 0}, - {XFA_ELEMENT_StartPage, 1, 0}, - {XFA_ELEMENT_Relevant, 1, 0}, - {XFA_ELEMENT_Base, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_AutoSave, 1, 0}, - {XFA_ELEMENT_Validate, 1, 0}, - {XFA_ELEMENT_ValidateApprovalSignatures, 1, 0}, - {XFA_ELEMENT_Acrobat7, 1, 0}, - {XFA_ELEMENT_Common, 1, 0}, - {XFA_ELEMENT_Exclude, 1, 0}, - {XFA_ELEMENT_CurrentPage, 1, 0}, - {XFA_ELEMENT_RunScripts, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Comb, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Medium, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Occur, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Filter, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Manifest, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Para, 1, 0}, - {XFA_ELEMENT_Font, 1, 0}, - {XFA_ELEMENT_Value, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Day, 7, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Occur, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Comb, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Filter, 1, 0}, - {XFA_ELEMENT_Manifest, 1, 0}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_Level, 1, 0}, - {XFA_ELEMENT_Type, 1, 0}, - {XFA_ELEMENT_CompressObjectStream, 1, 0}, - {XFA_ELEMENT_CompressLogicalStructure, 1, 0}, - {XFA_ELEMENT_Edge, 4, 0}, - {XFA_ELEMENT_Corner, 4, 0}, - {XFA_ELEMENT_Fill, 1, 0}, - {XFA_ELEMENT_DynamicRender, 1, 0}, - {XFA_ELEMENT_DatePatterns, 1, 0}, - {XFA_ELEMENT_CalendarSymbols, 1, 0}, - {XFA_ELEMENT_CurrencySymbols, 1, 0}, - {XFA_ELEMENT_Typefaces, 1, 0}, - {XFA_ELEMENT_DateTimeSymbols, 1, 0}, - {XFA_ELEMENT_NumberPatterns, 1, 0}, - {XFA_ELEMENT_NumberSymbols, 1, 0}, - {XFA_ELEMENT_TimePatterns, 1, 0}, - {XFA_ELEMENT_Uri, 1, 0}, - {XFA_ELEMENT_Xsl, 1, 0}, - {XFA_ELEMENT_StartNode, 1, 0}, - {XFA_ELEMENT_OutputXSL, 1, 0}, - {XFA_ELEMENT_AdjustData, 1, 0}, - {XFA_ELEMENT_Attributes, 1, 0}, - {XFA_ELEMENT_Window, 1, 0}, - {XFA_ELEMENT_Record, 1, 0}, - {XFA_ELEMENT_Range, 1, 0}, - {XFA_ELEMENT_IncrementalLoad, 1, 0}, - {XFA_ELEMENT_Text, 1, 0}, - {XFA_ELEMENT_Time, 1, 0}, - {XFA_ELEMENT_DateTime, 1, 0}, - {XFA_ELEMENT_Image, 1, 0}, - {XFA_ELEMENT_Decimal, 1, 0}, - {XFA_ELEMENT_Boolean, 1, 0}, - {XFA_ELEMENT_Integer, 1, 0}, - {XFA_ELEMENT_ExData, 1, 0}, - {XFA_ELEMENT_Date, 1, 0}, - {XFA_ELEMENT_Float, 1, 0}, - {XFA_ELEMENT_Certificate, 1, 0}, - {XFA_ELEMENT_Ui, 1, 0}, - {XFA_ELEMENT_Margin, 1, 0}, - {XFA_ELEMENT_Para, 1, 0}, - {XFA_ELEMENT_Border, 1, 0}, - {XFA_ELEMENT_Assist, 1, 0}, - {XFA_ELEMENT_Traversal, 1, 0}, - {XFA_ELEMENT_Keep, 1, 0}, - {XFA_ELEMENT_Caption, 1, 0}, - {XFA_ELEMENT_Desc, 1, 0}, - {XFA_ELEMENT_Font, 1, 0}, - {XFA_ELEMENT_Value, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_EncryptionLevel, 1, 0}, - {XFA_ELEMENT_Encrypt, 1, 0}, - {XFA_ELEMENT_Permissions, 1, 0}, - {XFA_ELEMENT_Meridiem, 2, 0}, - {XFA_ELEMENT_SuppressBanner, 1, 0}, - {XFA_ELEMENT_VersionControl, 1, 0}, - {XFA_ELEMENT_LocaleSet, 1, 0}, - {XFA_ELEMENT_Template, 1, 0}, - {XFA_ELEMENT_ValidationMessaging, 1, 0}, - {XFA_ELEMENT_Locale, 1, 0}, - {XFA_ELEMENT_Data, 1, 0}, - {XFA_ELEMENT_Messaging, 1, 0}, - {XFA_ELEMENT_Pattern, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Solid, 1, - XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf}, - {XFA_ELEMENT_Stipple, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Linear, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Radial, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Fill, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Map, 1, 0}, - {XFA_ELEMENT_Arc, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Text, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Time, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_DateTime, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Image, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Decimal, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Boolean, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Integer, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_ExData, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Rectangle, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Date, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Float, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Line, 1, XFA_PROPERTYFLAG_OneOf}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Destination, 1, 0}, - {XFA_ELEMENT_Message, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_ConnectString, 1, 0}, - {XFA_ELEMENT_User, 1, 0}, - {XFA_ELEMENT_Password, 1, 0}, - {XFA_ELEMENT_ModifyAnnots, 1, 0}, - {XFA_ELEMENT_ContentCopy, 1, 0}, - {XFA_ELEMENT_FormFieldFilling, 1, 0}, - {XFA_ELEMENT_Change, 1, 0}, - {XFA_ELEMENT_AccessibleContent, 1, 0}, - {XFA_ELEMENT_Print, 1, 0}, - {XFA_ELEMENT_PlaintextMetadata, 1, 0}, - {XFA_ELEMENT_PrintHighQuality, 1, 0}, - {XFA_ELEMENT_DocumentAssembly, 1, 0}, - {XFA_ELEMENT_Encrypt, 1, 0}, - {XFA_ELEMENT_NumberSymbol, 5, 0}, - {XFA_ELEMENT_FontInfo, 1, 0}, - {XFA_ELEMENT_Xdc, 1, 0}, - {XFA_ELEMENT_Color, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_TimePattern, 4, 0}, - {XFA_ELEMENT_Whitespace, 1, 0}, - {XFA_ELEMENT_Rename, 1, 0}, - {XFA_ELEMENT_IfEmpty, 1, 0}, - {XFA_ELEMENT_Presence, 1, 0}, - {XFA_ELEMENT_Picture, 1, 0}, - {XFA_ELEMENT_NameAttr, 1, 0}, - {XFA_ELEMENT_GroupParent, 1, 0}, - {XFA_ELEMENT_Script, 1, 0}, - {XFA_ELEMENT_Edge, 1, 0}, - {XFA_ELEMENT_Connect, 1, 0}, - {XFA_ELEMENT_Extras, 1, 0}, - {XFA_ELEMENT_Month, 12, 0}, -}; -const XFA_ELEMENTHIERARCHY g_XFAElementChildrenIndex[] = { - {0, 0}, {0, 0}, {0, 0}, {0, 1}, {1, 0}, {1, 4}, {5, 0}, - {5, 0}, {5, 0}, {5, 3}, {8, 0}, {8, 0}, {8, 0}, {8, 0}, - {8, 0}, {8, 1}, {9, 0}, {9, 0}, {9, 0}, {9, 0}, {9, 0}, - {9, 0}, {9, 2}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, - {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, - {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, - {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 0}, {11, 8}, {19, 0}, - {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, - {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 0}, {19, 1}, - {20, 1}, {21, 1}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, - {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 0}, {22, 7}, {29, 0}, - {29, 0}, {29, 0}, {29, 0}, {29, 0}, {29, 0}, {29, 1}, {30, 1}, - {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, {31, 0}, - {31, 0}, {31, 0}, {31, 4}, {35, 2}, {37, 0}, {37, 0}, {37, 0}, - {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 0}, - {37, 0}, {37, 0}, {37, 0}, {37, 0}, {37, 4}, {41, 0}, {41, 0}, - {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 2}, {43, 0}, {43, 0}, - {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, {43, 0}, - {43, 13}, {56, 0}, {56, 0}, {56, 1}, {57, 0}, {57, 0}, {57, 0}, - {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, {57, 0}, - {57, 0}, {57, 1}, {58, 0}, {58, 1}, {59, 0}, {59, 0}, {59, 0}, - {59, 1}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, {60, 0}, - {60, 0}, {60, 0}, {60, 1}, {61, 0}, {61, 0}, {61, 0}, {61, 1}, - {62, 0}, {62, 2}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, - {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, {64, 0}, - {64, 1}, {65, 1}, {66, 1}, {67, 0}, {67, 1}, {68, 0}, {68, 0}, - {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 0}, {68, 6}, - {74, 0}, {74, 1}, {75, 0}, {75, 0}, {75, 0}, {75, 0}, {75, 0}, - {75, 0}, {75, 0}, {75, 0}, {75, 0}, {75, 1}, {76, 0}, {76, 0}, - {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, - {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, - {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, - {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, {76, 0}, - {76, 0}, {76, 0}, {76, 0}, {76, 2}, {78, 0}, {78, 0}, {78, 0}, - {78, 1}, {79, 0}, {79, 0}, {79, 1}, {80, 0}, {80, 0}, {80, 1}, - {81, 0}, {81, 0}, {81, 1}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, - {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 0}, {82, 1}, - {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 0}, {83, 11}, - {94, 0}, {94, 0}, {94, 0}, {94, 0}, {94, 0}, {94, 11}, {105, 106}, - {211, 0}, {211, 0}, {211, 1}, {212, 0}, {212, 3}, {215, 1}, {216, 0}, - {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, - {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 0}, {216, 12}, {228, 0}, - {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, {228, 0}, - {228, 0}, {228, 2}, {230, 0}, {230, 0}, {230, 0}, {230, 0}, {230, 0}, - {230, 0}, {230, 0}, {230, 0}, {230, 10}, -}; -const FX_WORD g_XFAElementChildrenData[] = { - XFA_ELEMENT_Extras, - XFA_ELEMENT_SubformSet, - XFA_ELEMENT_BreakBefore, - XFA_ELEMENT_Subform, - XFA_ELEMENT_BreakAfter, - XFA_ELEMENT_AlwaysEmbed, - XFA_ELEMENT_DefaultTypeface, - XFA_ELEMENT_NeverEmbed, - XFA_ELEMENT_Source, - XFA_ELEMENT_Equate, - XFA_ELEMENT_EquateRange, - XFA_ELEMENT_Ps, - XFA_ELEMENT_Pcl, - XFA_ELEMENT_Pdf, - XFA_ELEMENT_Zpl, - XFA_ELEMENT_LabelPrinter, - XFA_ELEMENT_WebClient, - XFA_ELEMENT_SubmitUrl, - XFA_ELEMENT_Driver, - XFA_ELEMENT_Typeface, - XFA_ELEMENT_SubjectDN, - XFA_ELEMENT_Certificate, - XFA_ELEMENT_SubformSet, - XFA_ELEMENT_Area, - XFA_ELEMENT_Field, - XFA_ELEMENT_ExclGroup, - XFA_ELEMENT_Subform, - XFA_ELEMENT_Draw, - XFA_ELEMENT_ExObject, - XFA_ELEMENT_EncryptionMethod, - XFA_ELEMENT_Ref, - XFA_ELEMENT_Event, - XFA_ELEMENT_SetProperty, - XFA_ELEMENT_BindItems, - XFA_ELEMENT_Connect, - XFA_ELEMENT_Pdf, - XFA_ELEMENT_Destination, - XFA_ELEMENT_Event, - XFA_ELEMENT_SetProperty, - XFA_ELEMENT_Field, - XFA_ELEMENT_Connect, - XFA_ELEMENT_Agent, - XFA_ELEMENT_PsMap, - XFA_ELEMENT_SubformSet, - XFA_ELEMENT_BreakBefore, - XFA_ELEMENT_Event, - XFA_ELEMENT_Area, - XFA_ELEMENT_SetProperty, - XFA_ELEMENT_Field, - XFA_ELEMENT_ExclGroup, - XFA_ELEMENT_Subform, - XFA_ELEMENT_Draw, - XFA_ELEMENT_ExObject, - XFA_ELEMENT_Proto, - XFA_ELEMENT_Connect, - XFA_ELEMENT_BreakAfter, - XFA_ELEMENT_Locale, - XFA_ELEMENT_Text, - XFA_ELEMENT_Font, - XFA_ELEMENT_Traverse, - XFA_ELEMENT_Map, - XFA_ELEMENT_DigestMethod, - XFA_ELEMENT_PageSet, - XFA_ELEMENT_PageArea, - XFA_ELEMENT_Encoding, - XFA_ELEMENT_Subform, - XFA_ELEMENT_SubmitUrl, - XFA_ELEMENT_Certificate, - XFA_ELEMENT_Area, - XFA_ELEMENT_Field, - XFA_ELEMENT_ContentArea, - XFA_ELEMENT_ExclGroup, - XFA_ELEMENT_Subform, - XFA_ELEMENT_Draw, - XFA_ELEMENT_Oid, - XFA_ELEMENT_Ref, - XFA_ELEMENT_ExcludeNS, - XFA_ELEMENT_Transform, - XFA_ELEMENT_SetProperty, - XFA_ELEMENT_Message, - XFA_ELEMENT_Log, - XFA_ELEMENT_Reason, - XFA_ELEMENT_Area, - XFA_ELEMENT_Text, - XFA_ELEMENT_Time, - XFA_ELEMENT_DateTime, - XFA_ELEMENT_Image, - XFA_ELEMENT_Decimal, - XFA_ELEMENT_Boolean, - XFA_ELEMENT_Integer, - XFA_ELEMENT_ExData, - XFA_ELEMENT_Date, - XFA_ELEMENT_Float, - XFA_ELEMENT_ExObject, - XFA_ELEMENT_Text, - XFA_ELEMENT_Time, - XFA_ELEMENT_DateTime, - XFA_ELEMENT_Image, - XFA_ELEMENT_Decimal, - XFA_ELEMENT_Boolean, - XFA_ELEMENT_Integer, - XFA_ELEMENT_ExData, - XFA_ELEMENT_Date, - XFA_ELEMENT_Float, - XFA_ELEMENT_Extras, - XFA_ELEMENT_Ui, - XFA_ELEMENT_SubformSet, - XFA_ELEMENT_Break, - XFA_ELEMENT_CheckButton, - XFA_ELEMENT_Arc, - XFA_ELEMENT_Mdp, - XFA_ELEMENT_BreakBefore, - XFA_ELEMENT_Oid, - XFA_ELEMENT_Ref, - XFA_ELEMENT_Margin, - XFA_ELEMENT_KeyUsage, - XFA_ELEMENT_ChoiceList, - XFA_ELEMENT_Para, - XFA_ELEMENT_Filter, - XFA_ELEMENT_Encoding, - XFA_ELEMENT_Event, - XFA_ELEMENT_DefaultUi, - XFA_ELEMENT_Barcode, - XFA_ELEMENT_SubjectDNs, - XFA_ELEMENT_Issuers, - XFA_ELEMENT_Button, - XFA_ELEMENT_Format, - XFA_ELEMENT_Border, - XFA_ELEMENT_Area, - XFA_ELEMENT_Hyphenation, - XFA_ELEMENT_Text, - XFA_ELEMENT_Time, - XFA_ELEMENT_Certificates, - XFA_ELEMENT_SetProperty, - XFA_ELEMENT_DateTime, - XFA_ELEMENT_Comb, - XFA_ELEMENT_Pattern, - XFA_ELEMENT_Field, - XFA_ELEMENT_ContentArea, - XFA_ELEMENT_Solid, - XFA_ELEMENT_Edge, - XFA_ELEMENT_Stipple, - XFA_ELEMENT_ExclGroup, - XFA_ELEMENT_ToolTip, - XFA_ELEMENT_Reason, - XFA_ELEMENT_Execute, - XFA_ELEMENT_DateTimeEdit, - XFA_ELEMENT_Image, - XFA_ELEMENT_TimeStamp, - XFA_ELEMENT_Decimal, - XFA_ELEMENT_Subform, - XFA_ELEMENT_Handler, - XFA_ELEMENT_Boolean, - XFA_ELEMENT_Message, - XFA_ELEMENT_Assist, - XFA_ELEMENT_Picture, - XFA_ELEMENT_Traversal, - XFA_ELEMENT_Corner, - XFA_ELEMENT_Color, - XFA_ELEMENT_Keep, - XFA_ELEMENT_ImageEdit, - XFA_ELEMENT_Validate, - XFA_ELEMENT_DigestMethods, - XFA_ELEMENT_PageSet, - XFA_ELEMENT_Integer, - XFA_ELEMENT_Traverse, - XFA_ELEMENT_Encodings, - XFA_ELEMENT_Signing, - XFA_ELEMENT_Script, - XFA_ELEMENT_PasswordEdit, - XFA_ELEMENT_NumericEdit, - XFA_ELEMENT_PageArea, - XFA_ELEMENT_Oids, - XFA_ELEMENT_Signature, - XFA_ELEMENT_Caption, - XFA_ELEMENT_ExData, - XFA_ELEMENT_Manifest, - XFA_ELEMENT_Overflow, - XFA_ELEMENT_Linear, - XFA_ELEMENT_DigestMethod, - XFA_ELEMENT_Medium, - XFA_ELEMENT_TextEdit, - XFA_ELEMENT_SignData, - XFA_ELEMENT_Rectangle, - XFA_ELEMENT_Date, - XFA_ELEMENT_Desc, - XFA_ELEMENT_Encrypt, - XFA_ELEMENT_Draw, - XFA_ELEMENT_Speak, - XFA_ELEMENT_Reasons, - XFA_ELEMENT_AppearanceFilter, - XFA_ELEMENT_Fill, - XFA_ELEMENT_Font, - XFA_ELEMENT_Certificate, - XFA_ELEMENT_Float, - XFA_ELEMENT_Value, - XFA_ELEMENT_Bookend, - XFA_ELEMENT_ExObject, - XFA_ELEMENT_BindItems, - XFA_ELEMENT_Calculate, - XFA_ELEMENT_Extras, - XFA_ELEMENT_Connect, - XFA_ELEMENT_Submit, - XFA_ELEMENT_SubjectDN, - XFA_ELEMENT_Radial, - XFA_ELEMENT_Variables, - XFA_ELEMENT_LockDocument, - XFA_ELEMENT_BreakAfter, - XFA_ELEMENT_Line, - XFA_ELEMENT_Occur, - XFA_ELEMENT_Items, - XFA_ELEMENT_Extras, - XFA_ELEMENT_WsdlConnection, - XFA_ELEMENT_XsdConnection, - XFA_ELEMENT_XmlConnection, - XFA_ELEMENT_SignData, - XFA_ELEMENT_Text, - XFA_ELEMENT_Time, - XFA_ELEMENT_DateTime, - XFA_ELEMENT_Image, - XFA_ELEMENT_Decimal, - XFA_ELEMENT_Boolean, - XFA_ELEMENT_Integer, - XFA_ELEMENT_Script, - XFA_ELEMENT_ExData, - XFA_ELEMENT_Manifest, - XFA_ELEMENT_Date, - XFA_ELEMENT_Float, - XFA_ELEMENT_Command, - XFA_ELEMENT_Bind, - XFA_ELEMENT_Text, - XFA_ELEMENT_Time, - XFA_ELEMENT_DateTime, - XFA_ELEMENT_Image, - XFA_ELEMENT_Decimal, - XFA_ELEMENT_Boolean, - XFA_ELEMENT_Integer, - XFA_ELEMENT_ExData, - XFA_ELEMENT_Date, - XFA_ELEMENT_Float, -}; -const XFA_ELEMENTHIERARCHY g_XFAElementAttributeIndex[] = { - {0, 3}, {3, 2}, {5, 3}, {8, 10}, {18, 2}, {20, 6}, {26, 2}, - {28, 1}, {29, 13}, {42, 2}, {44, 1}, {45, 2}, {47, 2}, {49, 7}, - {56, 0}, {56, 4}, {60, 2}, {62, 7}, {69, 0}, {69, 0}, {69, 2}, - {71, 2}, {73, 8}, {81, 5}, {86, 8}, {94, 4}, {98, 3}, {101, 3}, - {104, 3}, {107, 6}, {113, 2}, {115, 2}, {117, 2}, {119, 2}, {121, 3}, - {124, 2}, {126, 7}, {133, 13}, {146, 2}, {148, 6}, {154, 2}, {156, 3}, - {159, 1}, {160, 17}, {177, 2}, {179, 2}, {181, 6}, {187, 2}, {189, 2}, - {191, 3}, {194, 7}, {201, 2}, {203, 3}, {206, 0}, {206, 21}, {227, 1}, - {228, 3}, {231, 2}, {233, 0}, {233, 2}, {235, 2}, {237, 6}, {243, 0}, - {243, 4}, {247, 4}, {251, 0}, {251, 2}, {253, 2}, {255, 0}, {255, 0}, - {255, 2}, {257, 2}, {259, 4}, {263, 3}, {266, 7}, {273, 10}, {283, 9}, - {292, 6}, {298, 4}, {302, 2}, {304, 2}, {306, 6}, {312, 4}, {316, 3}, - {319, 2}, {321, 2}, {323, 4}, {327, 4}, {331, 4}, {335, 4}, {339, 2}, - {341, 2}, {343, 2}, {345, 22}, {367, 3}, {370, 2}, {372, 2}, {374, 2}, - {376, 9}, {385, 0}, {385, 4}, {389, 3}, {392, 0}, {392, 2}, {394, 7}, - {401, 4}, {405, 2}, {407, 4}, {411, 0}, {411, 21}, {432, 4}, {436, 3}, - {439, 4}, {443, 6}, {449, 2}, {451, 5}, {456, 2}, {458, 8}, {466, 1}, - {467, 2}, {469, 2}, {471, 5}, {476, 0}, {476, 2}, {478, 2}, {480, 6}, - {486, 26}, {512, 4}, {516, 2}, {518, 2}, {520, 4}, {524, 0}, {524, 2}, - {526, 2}, {528, 2}, {530, 2}, {532, 5}, {537, 2}, {539, 3}, {542, 2}, - {544, 4}, {548, 5}, {553, 2}, {555, 0}, {555, 2}, {557, 4}, {561, 5}, - {566, 3}, {569, 2}, {571, 3}, {574, 0}, {574, 2}, {576, 9}, {585, 2}, - {587, 5}, {592, 6}, {598, 5}, {603, 4}, {607, 4}, {611, 8}, {619, 4}, - {623, 0}, {623, 7}, {630, 4}, {634, 4}, {638, 5}, {643, 2}, {645, 2}, - {647, 4}, {651, 4}, {655, 2}, {657, 2}, {659, 1}, {660, 2}, {662, 5}, - {667, 4}, {671, 3}, {674, 2}, {676, 2}, {678, 4}, {682, 0}, {682, 9}, - {691, 2}, {693, 2}, {695, 5}, {700, 4}, {704, 3}, {707, 2}, {709, 10}, - {719, 2}, {721, 4}, {725, 4}, {729, 2}, {731, 6}, {737, 2}, {739, 2}, - {741, 9}, {750, 1}, {751, 4}, {755, 3}, {758, 5}, {763, 6}, {769, 4}, - {773, 1}, {774, 4}, {778, 0}, {778, 3}, {781, 1}, {782, 5}, {787, 10}, - {797, 7}, {804, 3}, {807, 2}, {809, 5}, {814, 2}, {816, 0}, {816, 2}, - {818, 2}, {820, 2}, {822, 6}, {828, 2}, {830, 1}, {831, 2}, {833, 2}, - {835, 8}, {843, 2}, {845, 4}, {849, 4}, {853, 4}, {857, 2}, {859, 2}, - {861, 2}, {863, 3}, {866, 2}, {868, 2}, {870, 4}, {874, 3}, {877, 5}, - {882, 20}, {902, 2}, {904, 0}, {904, 2}, {906, 6}, {912, 1}, {913, 2}, - {915, 1}, {916, 2}, {918, 4}, {922, 2}, {924, 2}, {926, 4}, {930, 4}, - {934, 20}, {954, 1}, {955, 2}, {957, 4}, {961, 4}, {965, 2}, {967, 2}, - {969, 4}, {973, 2}, {975, 0}, {975, 2}, {977, 5}, {982, 5}, {987, 8}, - {995, 2}, {997, 2}, {999, 4}, {1003, 4}, {1007, 2}, {1009, 4}, {1013, 0}, - {1013, 1}, {1014, 2}, {1016, 9}, {1025, 2}, {1027, 0}, {1027, 8}, {1035, 2}, - {1037, 2}, {1039, 0}, {1039, 4}, {1043, 2}, {1045, 0}, {1045, 2}, {1047, 3}, - {1050, 2}, {1052, 5}, {1057, 2}, {1059, 2}, {1061, 4}, {1065, 3}, {1068, 0}, - {1068, 4}, {1072, 2}, {1074, 2}, {1076, 3}, {1079, 4}, {1083, 8}, {1091, 5}, - {1096, 0}, {1096, 4}, {1100, 6}, {1106, 2}, {1108, 1}, {1109, 2}, {1111, 2}, - {1113, 2}, {1115, 1}, {1116, 2}, {1118, 7}, -}; -const uint8_t g_XFAElementAttributeData[] = { - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Max, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_EofAction, - XFA_ATTRIBUTE_CursorType, - XFA_ATTRIBUTE_LockType, - XFA_ATTRIBUTE_BofAction, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_CursorLocation, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Relation, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_BeforeTarget, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_OverflowTarget, - XFA_ATTRIBUTE_OverflowLeader, - XFA_ATTRIBUTE_OverflowTrailer, - XFA_ATTRIBUTE_StartNew, - XFA_ATTRIBUTE_BookendTrailer, - XFA_ATTRIBUTE_After, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_BookendLeader, - XFA_ATTRIBUTE_AfterTarget, - XFA_ATTRIBUTE_Before, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_AllowNeutral, - XFA_ATTRIBUTE_Mark, - XFA_ATTRIBUTE_Shape, - XFA_ATTRIBUTE_Size, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_StartAngle, - XFA_ATTRIBUTE_SweepAngle, - XFA_ATTRIBUTE_Circular, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Hand, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Bind, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_From, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_SignatureType, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Permissions, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_StartNew, - XFA_ATTRIBUTE_Trailer, - XFA_ATTRIBUTE_TargetType, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_Leader, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_TimeStamp, - XFA_ATTRIBUTE_Uuid, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_LeftInset, - XFA_ATTRIBUTE_BottomInset, - XFA_ATTRIBUTE_TopInset, - XFA_ATTRIBUTE_RightInset, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_NonRepudiation, - XFA_ATTRIBUTE_EncipherOnly, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_DigitalSignature, - XFA_ATTRIBUTE_CrlSign, - XFA_ATTRIBUTE_KeyAgreement, - XFA_ATTRIBUTE_KeyEncipherment, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_DataEncipherment, - XFA_ATTRIBUTE_KeyCertSign, - XFA_ATTRIBUTE_DecipherOnly, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Open, - XFA_ATTRIBUTE_CommitOn, - XFA_ATTRIBUTE_TextEntry, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_HAlign, - XFA_ATTRIBUTE_TextIndent, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Widows, - XFA_ATTRIBUTE_MarginRight, - XFA_ATTRIBUTE_MarginLeft, - XFA_ATTRIBUTE_RadixOffset, - XFA_ATTRIBUTE_Preserve, - XFA_ATTRIBUTE_SpaceBelow, - XFA_ATTRIBUTE_VAlign, - XFA_ATTRIBUTE_TabDefault, - XFA_ATTRIBUTE_TabStops, - XFA_ATTRIBUTE_Orphans, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_LineHeight, - XFA_ATTRIBUTE_SpaceAbove, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Version, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_AddRevocationInfo, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Listen, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Activity, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_DataRowCount, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_DataPrep, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_TextLocation, - XFA_ATTRIBUTE_ModuleWidth, - XFA_ATTRIBUTE_PrintCheckDigit, - XFA_ATTRIBUTE_ModuleHeight, - XFA_ATTRIBUTE_StartChar, - XFA_ATTRIBUTE_Truncate, - XFA_ATTRIBUTE_WideNarrowRatio, - XFA_ATTRIBUTE_ErrorCorrectionLevel, - XFA_ATTRIBUTE_UpsMode, - XFA_ATTRIBUTE_Checksum, - XFA_ATTRIBUTE_CharEncoding, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_DataColumnCount, - XFA_ATTRIBUTE_RowColumnRatio, - XFA_ATTRIBUTE_DataLength, - XFA_ATTRIBUTE_EndChar, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Format, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Output, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Input, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_DataDescription, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Highlight, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Break, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Hand, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Level, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_ColSpan, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_WordCharacterCount, - XFA_ATTRIBUTE_Hyphenate, - XFA_ATTRIBUTE_ExcludeInitialCap, - XFA_ATTRIBUTE_PushCharacterCount, - XFA_ATTRIBUTE_RemainCharacterCount, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_ExcludeAllCaps, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Rid, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_MaxChars, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Url, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_CredentialServerPolicy, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_UrlPolicy, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Connection, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_NumberOfCells, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_H, - XFA_ATTRIBUTE_W, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_HAlign, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Access, - XFA_ATTRIBUTE_Rotate, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_VAlign, - XFA_ATTRIBUTE_MaxH, - XFA_ATTRIBUTE_MaxW, - XFA_ATTRIBUTE_MinH, - XFA_ATTRIBUTE_MinW, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_ColSpan, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Locale, - XFA_ATTRIBUTE_AnchorType, - XFA_ATTRIBUTE_AccessKey, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_H, - XFA_ATTRIBUTE_W, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Cap, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Stroke, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Thickness, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Rate, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_SourceBelow, - XFA_ATTRIBUTE_OutputBelow, - XFA_ATTRIBUTE_SourceAbove, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_H, - XFA_ATTRIBUTE_W, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_HAlign, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Access, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_VAlign, - XFA_ATTRIBUTE_MaxH, - XFA_ATTRIBUTE_MaxW, - XFA_ATTRIBUTE_MinH, - XFA_ATTRIBUTE_MinW, - XFA_ATTRIBUTE_Layout, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_ColSpan, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_AnchorType, - XFA_ATTRIBUTE_AccessKey, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Rid, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Scope, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Connection, - XFA_ATTRIBUTE_RunAt, - XFA_ATTRIBUTE_ExecuteType, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Picker, - XFA_ATTRIBUTE_HScrollPolicy, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTE_TransferEncoding, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Aspect, - XFA_ATTRIBUTE_Href, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Server, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_FracDigits, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_LeadDigits, - XFA_ATTRIBUTE_H, - XFA_ATTRIBUTE_W, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_HAlign, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_AllowMacro, - XFA_ATTRIBUTE_ColumnWidths, - XFA_ATTRIBUTE_Access, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_VAlign, - XFA_ATTRIBUTE_MaxH, - XFA_ATTRIBUTE_MaxW, - XFA_ATTRIBUTE_MinH, - XFA_ATTRIBUTE_MinW, - XFA_ATTRIBUTE_Layout, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_MergeMode, - XFA_ATTRIBUTE_ColSpan, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Locale, - XFA_ATTRIBUTE_AnchorType, - XFA_ATTRIBUTE_RestoreState, - XFA_ATTRIBUTE_Scope, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Timeout, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Mode, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Role, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Stroke, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Inverted, - XFA_ATTRIBUTE_Thickness, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Join, - XFA_ATTRIBUTE_Radius, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_CSpace, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Next, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Previous, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Intact, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_CommandType, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Data, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_ScriptTest, - XFA_ATTRIBUTE_NullTest, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_FormatTest, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Relation, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_DuplexImposition, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_To, - XFA_ATTRIBUTE_Force, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_From, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_DataDescription, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Operation, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_BaseProfile, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTE_RunAt, - XFA_ATTRIBUTE_Binding, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_PasswordChar, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_HScrollPolicy, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_HScrollPolicy, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_PagePosition, - XFA_ATTRIBUTE_OddOrEven, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_InitialNumber, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Numbered, - XFA_ATTRIBUTE_BlankOrNotBlank, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Reserve, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Placement, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Rid, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTE_TransferEncoding, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_MaxLength, - XFA_ATTRIBUTE_Href, - XFA_ATTRIBUTE_Abbr, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_WritingScript, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Action, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Trailer, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_Leader, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_To, - XFA_ATTRIBUTE_UnicodeRange, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_From, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_TrayOut, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Orientation, - XFA_ATTRIBUTE_ImagingBBox, - XFA_ATTRIBUTE_Short, - XFA_ATTRIBUTE_TrayIn, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Stock, - XFA_ATTRIBUTE_Long, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_VScrollPolicy, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_AllowRichText, - XFA_ATTRIBUTE_MultiLine, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_HScrollPolicy, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_MaxEntries, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTE_Contains, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_IsNull, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_DataDescription, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Operation, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_ContentType, - XFA_ATTRIBUTE_TransferEncoding, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Match, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Hand, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_H, - XFA_ATTRIBUTE_W, - XFA_ATTRIBUTE_X, - XFA_ATTRIBUTE_Y, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_HAlign, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Rotate, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_VAlign, - XFA_ATTRIBUTE_MaxH, - XFA_ATTRIBUTE_MaxW, - XFA_ATTRIBUTE_MinH, - XFA_ATTRIBUTE_MinW, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_ColSpan, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Locale, - XFA_ATTRIBUTE_AnchorType, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Rid, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Priority, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Disable, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_LineThrough, - XFA_ATTRIBUTE_Typeface, - XFA_ATTRIBUTE_FontHorizontalScale, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_KerningMode, - XFA_ATTRIBUTE_Underline, - XFA_ATTRIBUTE_BaselineShift, - XFA_ATTRIBUTE_OverlinePeriod, - XFA_ATTRIBUTE_LetterSpacing, - XFA_ATTRIBUTE_LineThroughPeriod, - XFA_ATTRIBUTE_FontVerticalScale, - XFA_ATTRIBUTE_PsName, - XFA_ATTRIBUTE_Size, - XFA_ATTRIBUTE_Posture, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Weight, - XFA_ATTRIBUTE_UnderlinePeriod, - XFA_ATTRIBUTE_Overline, - XFA_ATTRIBUTE_GenericFamily, - XFA_ATTRIBUTE_Checksum, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Relevant, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Override, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Trailer, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Leader, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_CodeType, - XFA_ATTRIBUTE_Archive, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_CodeBase, - XFA_ATTRIBUTE_ClassId, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Connection, - XFA_ATTRIBUTE_LabelRef, - XFA_ATTRIBUTE_ValueRef, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Override, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Value, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Timeout, - XFA_ATTRIBUTE_Connection, - XFA_ATTRIBUTE_Usage, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_DelayedOpen, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Format, - XFA_ATTRIBUTE_EmbedPDF, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_TextEncoding, - XFA_ATTRIBUTE_XdpContent, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Delimiter, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Type, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_StartNew, - XFA_ATTRIBUTE_Trailer, - XFA_ATTRIBUTE_TargetType, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Target, - XFA_ATTRIBUTE_Leader, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Slope, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Hand, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Max, - XFA_ATTRIBUTE_Min, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Initial, - XFA_ATTRIBUTE_Usehref, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Abbr, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Desc, - XFA_ATTRIBUTE_Lock, - XFA_ATTRIBUTE_Id, - XFA_ATTRIBUTE_Name, - XFA_ATTRIBUTE_Ref, - XFA_ATTRIBUTE_Use, - XFA_ATTRIBUTE_Presence, - XFA_ATTRIBUTE_Save, - XFA_ATTRIBUTE_Usehref, -}; -const XFA_PACKETINFO g_XFAPacketData[] = { - {0x0, NULL, XFA_XDPPACKET_USER, NULL, - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x811929d, L"sourceSet", XFA_XDPPACKET_SourceSet, - L"http://www.xfa.org/schema/xfa-source-set/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xb843dba, L"pdf", XFA_XDPPACKET_Pdf, L"http://ns.adobe.com/xdp/pdf/", - XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xc56afbf, L"xdc", XFA_XDPPACKET_Xdc, L"http://www.xfa.org/schema/xdc/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xc56afcc, L"xdp", XFA_XDPPACKET_XDP, L"http://ns.adobe.com/xdp/", - XFA_XDPPACKET_FLAGS_COMPLETEMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x132a8fbc, L"xmpmeta", XFA_XDPPACKET_Xmpmeta, - L"http://ns.adobe.com/xmpmeta/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x48d004a8, L"xfdf", XFA_XDPPACKET_Xfdf, L"http://ns.adobe.com/xfdf/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x4e1e39b6, L"config", XFA_XDPPACKET_Config, - L"http://www.xfa.org/schema/xci/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x5473b6dc, L"localeSet", XFA_XDPPACKET_LocaleSet, - L"http://www.xfa.org/schema/xfa-locale-set/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x6038580a, L"stylesheet", XFA_XDPPACKET_Stylesheet, - L"http://www.w3.org/1999/XSL/Transform", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTMANY}, - {0x803550fc, L"template", XFA_XDPPACKET_Template, - L"http://www.xfa.org/schema/xfa-template/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x8b036f32, L"signature", XFA_XDPPACKET_Signature, - L"http://www.w3.org/2000/09/xmldsig#", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0x99b95079, L"datasets", XFA_XDPPACKET_Datasets, - L"http://www.xfa.org/schema/xfa-data/", - XFA_XDPPACKET_FLAGS_PREFIXMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xcd309ff4, L"form", XFA_XDPPACKET_Form, - L"http://www.xfa.org/schema/xfa-form/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, - {0xe14c801c, L"connectionSet", XFA_XDPPACKET_ConnectionSet, - L"http://www.xfa.org/schema/xfa-connection-set/", - XFA_XDPPACKET_FLAGS_NOMATCH | XFA_XDPPACKET_FLAGS_SUPPORTONE}, -}; -const int32_t g_iXFAPacketCount = - sizeof(g_XFAPacketData) / sizeof(XFA_PACKETINFO); -const XFA_SCRIPTHIERARCHY g_XFAScriptIndex[] = { - {0, 0, 0, 2, 316}, {0, 0, 2, 2, 316}, {0, 0, 4, 2, 316}, - {0, 0, 6, 8, 316}, {0, 0, 14, 4, 316}, {0, 0, 18, 5, 317}, - {0, 0, 23, 2, 316}, {0, 0, 25, 1, 316}, {0, 0, 26, 12, 316}, - {0, 0, 38, 2, 316}, {0, 0, 40, 1, 316}, {0, 0, 41, 3, 316}, - {0, 0, 44, 2, 316}, {0, 0, 46, 6, 316}, {0, 0, 52, 0, 316}, - {0, 0, 52, 2, 319}, {0, 0, 54, 2, 316}, {0, 0, 56, 6, 316}, - {0, 0, 62, 0, 316}, {0, 0, 62, 0, 316}, {0, 0, 62, 2, 316}, - {0, 0, 64, 2, 316}, {0, 0, 66, 6, 316}, {0, 0, 72, 4, 316}, - {0, 0, 76, 7, 316}, {0, 0, 83, 2, 320}, {0, 0, 85, 3, 316}, - {0, 0, 88, 3, 316}, {0, 0, 91, 2, 320}, {0, 0, 93, 6, 320}, - {0, 0, 99, 4, 316}, {0, 0, 103, 2, 316}, {0, 0, 105, 3, 319}, - {0, 0, 108, 4, 316}, {0, 0, 112, 3, 316}, {0, 0, 115, 2, 316}, - {0, 0, 117, 6, 316}, {0, 0, 123, 12, 316}, {0, 0, 135, 2, 316}, - {0, 0, 137, 5, 316}, {0, 0, 142, 2, 316}, {0, 0, 144, 3, 316}, - {0, 0, 147, 1, 316}, {0, 0, 148, 14, 316}, {0, 0, 162, 2, 316}, - {0, 0, 164, 2, 316}, {0, 0, 166, 3, 316}, {0, 0, 169, 2, 316}, - {0, 0, 171, 2, 316}, {0, 0, 173, 2, 316}, {0, 0, 175, 4, 316}, - {0, 0, 179, 2, 316}, {0, 0, 181, 2, 316}, {0, 0, 183, 0, 319}, - {0, 0, 183, 20, 316}, {0, 0, 203, 1, 316}, {0, 0, 204, 3, 316}, - {0, 0, 207, 2, 316}, {0, 0, 209, 0, 316}, {0, 0, 209, 2, 316}, - {0, 0, 211, 2, 316}, {0, 0, 213, 4, 320}, {0, 0, 217, 0, 316}, - {0, 0, 217, 1, 316}, {0, 0, 218, 3, 316}, {0, 4, 221, 0, 312}, - {4, 1, 221, 1, 316}, {5, 0, 222, 2, 316}, {5, 1, 224, 3, -1}, - {6, 0, 227, 0, 316}, {6, 0, 227, 2, 316}, {6, 0, 229, 2, 316}, - {6, 0, 231, 3, 316}, {6, 0, 234, 2, 316}, {6, 0, 236, 6, 316}, - {6, 0, 242, 10, 317}, {6, 0, 252, 9, 316}, {6, 0, 261, 5, 318}, - {6, 0, 266, 4, 318}, {6, 0, 270, 2, 316}, {6, 0, 272, 2, 316}, - {6, 0, 274, 5, 316}, {6, 0, 279, 3, 316}, {6, 0, 282, 2, 316}, - {6, 0, 284, 2, 316}, {6, 0, 286, 2, 316}, {6, 0, 288, 2, 316}, - {6, 0, 290, 4, 316}, {6, 0, 294, 3, 316}, {6, 0, 297, 3, 316}, - {6, 0, 300, 2, 316}, {6, 0, 302, 2, 316}, {6, 0, 304, 2, 316}, - {6, 13, 306, 36, 317}, {19, 0, 342, 3, 316}, {19, 0, 345, 2, 316}, - {19, 0, 347, 2, 316}, {19, 0, 349, 2, 316}, {19, 0, 351, 7, 317}, - {19, 2, 358, 16, 312}, {21, 0, 374, 2, 320}, {21, 0, 376, 2, 316}, - {21, 0, 378, 0, 316}, {21, 0, 378, 2, 316}, {21, 0, 380, 6, 316}, - {21, 0, 386, 3, 316}, {21, 0, 389, 2, 316}, {21, 0, 391, 4, 316}, - {21, 0, 395, 0, 316}, {21, 5, 395, 30, 316}, {26, 0, 425, 2, 320}, - {26, 0, 427, 3, 316}, {26, 0, 430, 2, 320}, {26, 0, 432, 5, 316}, - {26, 0, 437, 2, 316}, {26, 0, 439, 3, 316}, {26, 0, 442, 2, 316}, - {26, 0, 444, 8, 316}, {26, 0, 452, 1, 316}, {26, 0, 453, 2, 316}, - {26, 0, 455, 2, 316}, {26, 0, 457, 4, 316}, {26, 0, 461, 0, 316}, - {26, 0, 461, 2, 316}, {26, 0, 463, 2, 316}, {26, 0, 465, 6, 318}, - {26, 5, 471, 31, 317}, {31, 0, 502, 2, 320}, {31, 0, 504, 2, 316}, - {31, 0, 506, 2, 316}, {31, 0, 508, 4, 320}, {31, 16, 512, 14, 312}, - {47, 0, 526, 2, 316}, {47, 0, 528, 2, 316}, {47, 0, 530, 2, 316}, - {47, 0, 532, 2, 316}, {47, 0, 534, 3, 316}, {47, 0, 537, 2, 316}, - {47, 0, 539, 3, 316}, {47, 0, 542, 3, 316}, {47, 0, 545, 4, 318}, - {47, 0, 549, 4, 316}, {47, 0, 553, 2, 316}, {47, 0, 555, 0, 316}, - {47, 0, 555, 2, 316}, {47, 0, 557, 3, 316}, {47, 0, 560, 6, 316}, - {47, 0, 566, 2, 316}, {47, 0, 568, 2, 316}, {47, 0, 570, 3, 316}, - {47, 19, 573, 1, 312}, {66, 0, 574, 2, 316}, {66, 0, 576, 8, 316}, - {66, 0, 584, 2, 316}, {66, 0, 586, 4, 316}, {66, 0, 590, 5, 316}, - {66, 0, 595, 3, 316}, {66, 0, 598, 2, 320}, {66, 0, 600, 3, 316}, - {66, 0, 603, 7, 316}, {66, 0, 610, 3, 316}, {66, 0, 613, 0, 316}, - {66, 0, 613, 4, 317}, {66, 0, 617, 4, 318}, {66, 0, 621, 2, 320}, - {66, 0, 623, 5, 316}, {66, 0, 628, 2, 316}, {66, 0, 630, 2, 316}, - {66, 0, 632, 2, 320}, {66, 0, 634, 2, 320}, {66, 0, 636, 4, 316}, - {66, 0, 640, 2, 316}, {66, 0, 642, 1, 316}, {66, 0, 643, 1, 316}, - {66, 0, 644, 4, 316}, {66, 0, 648, 3, 316}, {66, 7, 651, 2, 319}, - {73, 0, 653, 2, 316}, {73, 0, 655, 2, 316}, {73, 0, 657, 3, 316}, - {73, 4, 660, 4, 312}, {77, 0, 664, 10, 316}, {77, 0, 674, 2, 316}, - {77, 0, 676, 4, 316}, {77, 0, 680, 4, 316}, {77, 0, 684, 3, 316}, - {77, 0, 687, 2, 316}, {77, 0, 689, 2, 316}, {77, 0, 691, 8, 317}, - {77, 0, 699, 3, 316}, {77, 0, 702, 3, 316}, {77, 0, 705, 2, 316}, - {77, 0, 707, 2, 316}, {77, 0, 709, 5, 316}, {77, 0, 714, 4, 316}, - {77, 0, 718, 2, 316}, {77, 0, 720, 8, 318}, {77, 0, 728, 1, 316}, - {77, 0, 729, 2, 320}, {77, 0, 731, 3, 316}, {77, 1, 734, 4, 316}, - {78, 0, 738, 5, 316}, {78, 0, 743, 3, 316}, {78, 0, 746, 1, 316}, - {78, 0, 747, 2, 320}, {78, 0, 749, 0, 313}, {78, 0, 749, 2, 316}, - {78, 5, 751, 3, 316}, {83, 0, 754, 5, 316}, {83, 0, 759, 7, 316}, - {83, 0, 766, 6, 316}, {83, 0, 772, 3, 316}, {83, 0, 775, 2, 316}, - {83, 0, 777, 5, 316}, {83, 0, 782, 2, 316}, {83, 0, 784, 0, 314}, - {83, 0, 784, 2, 316}, {83, 0, 786, 1, 316}, {83, 0, 787, 2, 316}, - {83, 0, 789, 5, 316}, {83, 0, 794, 2, 316}, {83, 0, 796, 1, 316}, - {83, 0, 797, 2, 316}, {83, 0, 799, 2, 316}, {83, 0, 801, 6, 316}, - {83, 0, 807, 2, 316}, {83, 0, 809, 2, 320}, {83, 0, 811, 3, 316}, - {83, 0, 814, 4, 316}, {83, 0, 818, 2, 316}, {83, 0, 820, 2, 316}, - {83, 0, 822, 2, 316}, {83, 0, 824, 2, 316}, {83, 0, 826, 2, 316}, - {83, 0, 828, 2, 316}, {83, 0, 830, 4, 318}, {83, 1, 834, 2, 316}, - {84, 0, 836, 5, 316}, {84, 0, 841, 20, 317}, {84, 0, 861, 2, 316}, - {84, 0, 863, 0, 316}, {84, 0, 863, 2, 316}, {84, 0, 865, 4, 320}, - {84, 0, 869, 0, 316}, {84, 0, 869, 2, 316}, {84, 0, 871, 1, 316}, - {84, 0, 872, 2, 316}, {84, 0, 874, 3, 316}, {84, 0, 877, 2, 316}, - {84, 0, 879, 2, 316}, {84, 0, 881, 4, 316}, {84, 0, 885, 3, 316}, - {84, 0, 888, 17, 316}, {84, 6, 905, 1, 319}, {90, 0, 906, 2, 316}, - {90, 0, 908, 2, 320}, {90, 0, 910, 2, 320}, {90, 0, 912, 2, 316}, - {90, 0, 914, 2, 316}, {90, 0, 916, 4, 318}, {90, 0, 920, 2, 316}, - {90, 5, 922, 0, 312}, {95, 0, 922, 2, 316}, {95, 0, 924, 4, 316}, - {95, 0, 928, 4, 316}, {95, 0, 932, 6, 316}, {95, 0, 938, 2, 316}, - {95, 0, 940, 4, 316}, {95, 0, 944, 3, 316}, {95, 0, 947, 3, 316}, - {95, 0, 950, 2, 316}, {95, 0, 952, 3, 316}, {95, 0, 955, 0, 316}, - {95, 0, 955, 0, 316}, {95, 0, 955, 2, 316}, {95, 0, 957, 7, 316}, - {95, 0, 964, 2, 316}, {95, 0, 966, 0, 319}, {95, 0, 966, 7, 316}, - {95, 0, 973, 2, 316}, {95, 0, 975, 2, 316}, {95, 3, 977, 1, 316}, - {98, 0, 978, 2, 320}, {98, 0, 980, 4, 316}, {98, 0, 984, 0, 316}, - {98, 0, 984, 2, 316}, {98, 0, 986, 2, 316}, {98, 0, 988, 4, 316}, - {98, 0, 992, 1, 316}, {98, 0, 993, 2, 316}, {98, 0, 995, 2, 316}, - {98, 0, 997, 3, 316}, {98, 0, 1000, 2, 317}, {98, 0, 1002, 0, 316}, - {98, 0, 1002, 4, 316}, {98, 0, 1006, 4, 316}, {98, 0, 1010, 2, 316}, - {98, 0, 1012, 3, 316}, {98, 0, 1015, 4, 316}, {98, 0, 1019, 7, 316}, - {98, 0, 1026, 4, 316}, {98, 0, 1030, 1, 313}, {98, 17, 1031, 3, 316}, - {115, 0, 1034, 5, 316}, {115, 0, 1039, 2, 316}, {115, 0, 1041, 1, 316}, - {115, 0, 1042, 4, 316}, {115, 0, 1046, 2, 316}, {115, 0, 1048, 2, 316}, - {115, 0, 1050, 1, 316}, {115, 0, 1051, 2, 316}, {115, 0, 1053, 5, 316}, - {115, 0, 1058, 1, -1}, {115, 4, 1059, 1, 312}, {119, 1, 1060, 0, 313}, - {120, 2, 1060, 8, 312}, {122, 11, 1068, 6, 315}, {133, 2, 1074, 0, 316}, - {135, 0, 1074, 0, 316}, {135, 3, 1074, 2, 316}, {138, 0, 1076, 2, 316}, -}; -const XFA_METHODINFO g_SomMethodData[] = { - {0x3c752495, L"verify", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: - Script_SignaturePseudoModel_Verify}, - {0xa68635f1, L"sign", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: - Script_SignaturePseudoModel_Sign}, - {0xa7f2c5e6, L"enumerate", - (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: - Script_SignaturePseudoModel_Enumerate}, - {0xd8ed1467, L"clear", (XFA_METHOD_CALLBACK)&CScript_SignaturePseudoModel:: - Script_SignaturePseudoModel_Clear}, - {0x4bdcce13, L"execute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_WsdlConnection_Execute}, - {0x1c296ba4, L"restore", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Delta_Restore}, - {0x7d123a9, L"clearItems", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ClearItems}, - {0xfb0b007, L"execEvent", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecEvent}, - {0x6716ce97, L"execInitialize", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecInitialize}, - {0x7bb919c2, L"deleteItem", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_DeleteItem}, - {0x9f053d5e, L"getSaveItem", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetSaveItem}, - {0xbbd32747, L"boundItem", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_BoundItem}, - {0xc492d950, L"getItemState", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetItemState}, - {0xc6013cd3, L"execCalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecCalculate}, - {0xd8930d0e, L"setItems", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_SetItems}, - {0xe0f15045, L"getDisplayItem", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_GetDisplayItem}, - {0xe23acddc, L"setItemState", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_SetItemState}, - {0xe2dfb2f8, L"addItem", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_AddItem}, - {0xef8ce48f, L"execValidate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Field_ExecValidate}, - {0x461079ef, L"emit", (XFA_METHOD_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Emit}, - {0xfec90c63, L"reset", (XFA_METHOD_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Reset}, - {0xfb0b007, L"execEvent", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecEvent}, - {0x3d832221, L"selectedMember", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_SelectedMember}, - {0x6716ce97, L"execInitialize", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecInitialize}, - {0xc6013cd3, L"execCalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecCalculate}, - {0xef8ce48f, L"execValidate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ExclGroup_ExecValidate}, - {0xfb0b007, L"execEvent", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecEvent}, - {0x6716ce97, L"execInitialize", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecInitialize}, - {0xc6013cd3, L"execCalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecCalculate}, - {0xd9b9b1f1, L"getInvalidObjects", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_GetInvalidObjects}, - {0xef8ce48f, L"execValidate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Subform_ExecValidate}, - {0xa366b7c, L"exportData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_ExportData}, - {0x16cc226c, L"gotoURL", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_GotoURL}, - {0x1e0722f5, L"pageDown", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_PageDown}, - {0x3e66cb2c, L"setFocus", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_SetFocus}, - {0x4ac9faae, L"openList", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_OpenList}, - {0x7b89714f, L"response", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Response}, - {0x7fd9fd58, L"documentInBatch", - (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_DocumentInBatch}, - {0xaf1d019d, L"resetData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_ResetData}, - {0xb07be13c, L"beep", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Beep}, - {0xb1882ca0, L"getFocus", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_GetFocus}, - {0xbf4ba9ee, L"messageBox", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_MessageBox}, - {0xd6d4dbc1, L"documentCountInBatch", - (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_DocumentCountInBatch}, - {0xdd7676ed, L"print", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Print}, - {0xe2f863d0, L"currentDateTime", - (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_CurrentDateTime}, - {0xf995d0f5, L"importData", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_ImportData}, - {0xfeb96b62, L"pageUp", (XFA_METHOD_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_PageUp}, - {0x68, L"h", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_H}, - {0x77, L"w", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_W}, - {0x78, L"x", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_X}, - {0x79, L"y", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_Y}, - {0x5460206, L"pageCount", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_PageCount}, - {0x5eb5b0f, L"pageSpan", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_PageSpan}, - {0x10f1b1bd, L"page", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_Page}, - {0x1c1e6318, L"pageContent", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_PageContent}, - {0x1c1f4a5c, L"absPageCount", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_AbsPageCount}, - {0x1ec47db5, L"absPageCountInBatch", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_AbsPageCountInBatch}, - {0x2e4ecbdb, L"sheetCountInBatch", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_SheetCountInBatch}, - {0x2fcff4b5, L"relayout", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_Relayout}, - {0x3bf1c2a5, L"absPageSpan", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_AbsPageSpan}, - {0x5775c2cc, L"absPageInBatch", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_AbsPageInBatch}, - {0x8c5feb32, L"sheetInBatch", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_SheetInBatch}, - {0x8f3a8379, L"sheet", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_Sheet}, - {0x96f3c4cb, L"relayoutPageArea", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_RelayoutPageArea}, - {0xd2a4a542, L"sheetCount", - (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_SheetCount}, - {0xe74f0653, L"absPage", (XFA_METHOD_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_AbsPage}, - {0x44c352ad, L"formNodes", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_FormNodes}, - {0x45efb847, L"remerge", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_Remerge}, - {0x6716ce97, L"execInitialize", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecInitialize}, - {0x712c6afa, L"createNode", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_CreateNode}, - {0xa8a35e25, L"recalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_Recalculate}, - {0xc6013cd3, L"execCalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecCalculate}, - {0xef8ce48f, L"execValidate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Template_ExecValidate}, - {0x4cc1c0f9, L"moveCurrentRecord", - (XFA_METHOD_CALLBACK)&CScript_DataWindow:: - Script_DataWindow_MoveCurrentRecord}, - {0x5779d65f, L"record", - (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_Record}, - {0x8a476498, L"gotoRecord", - (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_GotoRecord}, - {0xaac241c8, L"isRecordGroup", - (XFA_METHOD_CALLBACK)&CScript_DataWindow::Script_DataWindow_IsRecordGroup}, - {0x1c6f4277, L"evaluate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Manifest_Evaluate}, - {0x2afec2cc, L"moveInstance", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_MoveInstance}, - {0x2bf94a63, L"removeInstance", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_RemoveInstance}, - {0x303adaf4, L"setInstances", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_SetInstances}, - {0x4d76b89e, L"addInstance", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_AddInstance}, - {0xc660dc8a, L"insertInstance", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_InstanceManager_InsertInstance}, - {0xddfd1ea1, L"metadata", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Desc_Metadata}, - {0x44c352ad, L"formNodes", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_FormNodes}, - {0x45efb847, L"remerge", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_Remerge}, - {0x6716ce97, L"execInitialize", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecInitialize}, - {0xa8a35e25, L"recalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_Recalculate}, - {0xc6013cd3, L"execCalculate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecCalculate}, - {0xef8ce48f, L"execValidate", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Form_ExecValidate}, - {0x60490a85, L"message", (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: - Script_LogPseudoModel_Message}, - {0x60ecfcc9, L"traceDeactivate", - (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: - Script_LogPseudoModel_TraceDeactivate}, - {0x86a0f4c0, L"traceActivate", - (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: - Script_LogPseudoModel_TraceActivate}, - {0x93eac39a, L"traceEnabled", (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel:: - Script_LogPseudoModel_TraceEnabled}, - {0xd1227e6f, L"trace", - (XFA_METHOD_CALLBACK)&CScript_LogPseudoModel::Script_LogPseudoModel_Trace}, - {0x36c0ee14, L"getAttribute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_GetAttribute}, - {0x5468e2a0, L"setAttribute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_SetAttribute}, - {0xadc48de2, L"removeAttribute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Packet_RemoveAttribute}, - {0x3848b3f, L"next", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Next}, - {0x14e25bc8, L"cancelBatch", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_CancelBatch}, - {0x3ce05d68, L"first", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_First}, - {0x649e1e65, L"updateBatch", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_UpdateBatch}, - {0x6a3405dd, L"previous", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Previous}, - {0x74818fb3, L"isBOF", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_IsBOF}, - {0x74d07a76, L"isEOF", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_IsEOF}, - {0x7613cb66, L"cancel", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Cancel}, - {0x7baca2e3, L"update", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Update}, - {0x8b90e1f2, L"open", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Open}, - {0x9c6471b3, L"delete", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Delete}, - {0xa7315093, L"addNew", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_AddNew}, - {0xa7ce5f8d, L"requery", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Requery}, - {0xc7368674, L"resync", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Resync}, - {0xd9f47f36, L"close", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Close}, - {0xf54481d4, L"last", (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_Last}, - {0xf7965460, L"hasDataChanged", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_Source_HasDataChanged}, - {0x6275f6af, L"item", - (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Item}, - {0x7033bfd5, L"insert", - (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Insert}, - {0x9cab7cae, L"remove", - (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Remove}, - {0xda12e518, L"append", - (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_ListClass_Append}, - {0xd892a054, L"namedItem", - (XFA_METHOD_CALLBACK)&CXFA_NodeList::Script_TreelistClass_NamedItem}, - {0xba2dd386, L"resolveNode", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_TreeClass_ResolveNode}, - {0xe509e2b9, L"resolveNodes", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_TreeClass_ResolveNodes}, - {0x1bca1ebd, L"applyXSL", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_ApplyXSL}, - {0x36c0ee14, L"getAttribute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_GetAttribute}, - {0x5468e2a0, L"setAttribute", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SetAttribute}, - {0x5ee00996, L"setElement", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SetElement}, - {0x92dada4f, L"saveFilteredXML", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SaveFilteredXML}, - {0x9c456500, L"saveXML", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_SaveXML}, - {0xabd3200a, L"getElement", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_GetElement}, - {0xb269c60d, L"isPropertySpecified", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_IsPropertySpecified}, - {0xb528be91, L"loadXML", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_LoadXML}, - {0xd9f46591, L"clone", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_Clone}, - {0xe006a76b, L"assignNode", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_NodeClass_AssignNode}, - {0x7303fcea, L"getDelta", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ContainerClass_GetDelta}, - {0xe7742c9d, L"getDeltas", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ContainerClass_GetDeltas}, - {0x30ff6aad, L"clearErrorList", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_ClearErrorList}, - {0x712c6afa, L"createNode", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_CreateNode}, - {0x83a6411d, L"isCompatibleNS", - (XFA_METHOD_CALLBACK)&CXFA_Node::Script_ModelClass_IsCompatibleNS}, -}; -const int32_t g_iSomMethodCount = - sizeof(g_SomMethodData) / sizeof(XFA_METHODINFO); -const XFA_SCRIPTATTRIBUTEINFO g_SomAttributeData[] = { - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xb3543a6, L"max", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Max, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x45a6daf8, L"eofAction", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_EofAction, XFA_SCRIPT_Basic}, - {0x5ec958c0, L"cursorType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CursorType, XFA_SCRIPT_Basic}, - {0x79975f2b, L"lockType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LockType, XFA_SCRIPT_Basic}, - {0xa5340ff5, L"bofAction", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BofAction, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc5762157, L"cursorLocation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CursorLocation, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1ee2d24d, L"instanceIndex", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_InstanceIndex, -1, - XFA_SCRIPT_Basic}, - {0x8c99377e, L"relation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relation, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0x3106c3a, L"beforeTarget", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BeforeTarget, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x13a08bdb, L"overflowTarget", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OverflowTarget, XFA_SCRIPT_Basic}, - {0x169134a1, L"overflowLeader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OverflowLeader, XFA_SCRIPT_Basic}, - {0x20914367, L"overflowTrailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OverflowTrailer, XFA_SCRIPT_Basic}, - {0x453eaf38, L"startNew", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, - {0x64110ab5, L"bookendTrailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BookendTrailer, XFA_SCRIPT_Basic}, - {0xb6b44172, L"after", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_After, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc3c1442f, L"bookendLeader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BookendLeader, XFA_SCRIPT_Basic}, - {0xcb150479, L"afterTarget", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AfterTarget, XFA_SCRIPT_Basic}, - {0xf4ffce73, L"before", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Before, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, - XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x47cfa43a, L"allowNeutral", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AllowNeutral, XFA_SCRIPT_Basic}, - {0x7c2fd80b, L"mark", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Mark, XFA_SCRIPT_Basic}, - {0x8ed182d1, L"shape", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Shape, XFA_SCRIPT_Basic}, - {0xa686975b, L"size", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Size, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x5c054755, L"startAngle", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_StartAngle, XFA_SCRIPT_Basic}, - {0x74788f8b, L"sweepAngle", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SweepAngle, XFA_SCRIPT_Basic}, - {0x9d833d75, L"circular", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Circular, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd996fa9b, L"hand", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xb0e5485d, L"bind", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Bind, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xcd7f7b54, L"from", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8e29d794, L"signatureType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SignatureType, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe11a2cbc, L"permissions", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Permissions, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x453eaf38, L"startNew", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, - {0x9dcc3ab3, L"trailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, - {0xa6118c89, L"targetType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TargetType, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xcbcaf66d, L"leader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x2d574d58, L"this", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Xfa_This, - -1, XFA_SCRIPT_Object}, - {0x4fdc3454, L"timeStamp", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TimeStamp, XFA_SCRIPT_Basic}, - {0xb598a1f7, L"uuid", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Uuid, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xcfea02e, L"leftInset", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LeftInset, XFA_SCRIPT_Basic}, - {0x1356caf8, L"bottomInset", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BottomInset, XFA_SCRIPT_Basic}, - {0x25764436, L"topInset", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TopInset, XFA_SCRIPT_Basic}, - {0x8a692521, L"rightInset", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RightInset, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1e459b8f, L"nonRepudiation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_NonRepudiation, XFA_SCRIPT_Basic}, - {0x2bb3f470, L"encipherOnly", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_EncipherOnly, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0x5f760b50, L"digitalSignature", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DigitalSignature, XFA_SCRIPT_Basic}, - {0x69aa2292, L"crlSign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CrlSign, XFA_SCRIPT_Basic}, - {0x98fd4d81, L"keyAgreement", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_KeyAgreement, XFA_SCRIPT_Basic}, - {0xa66404cb, L"keyEncipherment", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_KeyEncipherment, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xca5dc27c, L"dataEncipherment", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataEncipherment, XFA_SCRIPT_Basic}, - {0xe8f118a8, L"keyCertSign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_KeyCertSign, XFA_SCRIPT_Basic}, - {0xfea53ec6, L"decipherOnly", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DecipherOnly, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8b90e1f2, L"open", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Open, XFA_SCRIPT_Basic}, - {0x957fa006, L"commitOn", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CommitOn, XFA_SCRIPT_Basic}, - {0xb12128b7, L"textEntry", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TextEntry, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0x2282c73, L"hAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, - {0x8d4f1c7, L"textIndent", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TextIndent, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2a82d99c, L"marginRight", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MarginRight, XFA_SCRIPT_Basic}, - {0x534729c9, L"marginLeft", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MarginLeft, XFA_SCRIPT_Basic}, - {0x5739d1ff, L"radixOffset", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RadixOffset, XFA_SCRIPT_Basic}, - {0x577682ac, L"preserve", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Preserve, XFA_SCRIPT_Basic}, - {0x731e0665, L"spaceBelow", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SpaceBelow, XFA_SCRIPT_Basic}, - {0x7a7cc341, L"vAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, - {0x836d4d7c, L"tabDefault", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TabDefault, XFA_SCRIPT_Basic}, - {0x8fa01790, L"tabStops", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TabStops, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd4b01921, L"lineHeight", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LineHeight, XFA_SCRIPT_Basic}, - {0xe18b5659, L"spaceAbove", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SpaceAbove, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd861f8af, L"addRevocationInfo", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AddRevocationInfo, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6128d8d, L"activity", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Activity, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x43e349b, L"dataRowCount", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataRowCount, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x28e17e91, L"dataPrep", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataPrep, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0x3650557e, L"textLocation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TextLocation, XFA_SCRIPT_Basic}, - {0x3b582286, L"moduleWidth", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ModuleWidth, XFA_SCRIPT_Basic}, - {0x52666f1c, L"printCheckDigit", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_PrintCheckDigit, XFA_SCRIPT_Basic}, - {0x5404d6df, L"moduleHeight", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ModuleHeight, XFA_SCRIPT_Basic}, - {0x5ab23b6c, L"startChar", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_StartChar, XFA_SCRIPT_Basic}, - {0x7c732a66, L"truncate", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Truncate, XFA_SCRIPT_Basic}, - {0x8d181d61, L"wideNarrowRatio", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_WideNarrowRatio, XFA_SCRIPT_Basic}, - {0x99800d7a, L"errorCorrectionLevel", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ErrorCorrectionLevel, XFA_SCRIPT_Basic}, - {0x9a63da3d, L"upsMode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_UpsMode, XFA_SCRIPT_Basic}, - {0xaf754613, L"checksum", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Checksum, XFA_SCRIPT_Basic}, - {0xb045fbc5, L"charEncoding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CharEncoding, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc035c6b1, L"dataColumnCount", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataColumnCount, XFA_SCRIPT_Basic}, - {0xd3c84d25, L"rowColumnRatio", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RowColumnRatio, XFA_SCRIPT_Basic}, - {0xd57c513c, L"dataLength", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataLength, XFA_SCRIPT_Basic}, - {0xf575ca75, L"endChar", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_EndChar, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0x28dee6e9, L"format", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Format, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x60d4c8b1, L"output", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Output, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6a39990, L"input", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Input, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x2b5df51e, L"dataDescription", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x6c0d9600, L"currentValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_CurrentValue, -1, - XFA_SCRIPT_Basic}, - {0x942643f0, L"savedValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_SavedValue, -1, - XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Delta_Target, -1, - XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd4cc53f8, L"highlight", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Highlight, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x5518c25, L"break", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Break, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd996fa9b, L"hand", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1059ec18, L"level", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_Integer, - XFA_ATTRIBUTE_Level, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xac06e2b0, L"colSpan", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f105f72, L"wordCharacterCount", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_WordCharacterCount, XFA_SCRIPT_Basic}, - {0x3d123c26, L"hyphenate", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Hyphenate, XFA_SCRIPT_Basic}, - {0x66539c48, L"excludeInitialCap", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ExcludeInitialCap, XFA_SCRIPT_Basic}, - {0x6a95c976, L"pushCharacterCount", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_PushCharacterCount, XFA_SCRIPT_Basic}, - {0x982bd892, L"remainCharacterCount", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RemainCharacterCount, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe5c96d6a, L"excludeAllCaps", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ExcludeAllCaps, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8af2e657, L"maxChars", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxChars, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc080cd3, L"url", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Url, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa6710262, L"credentialServerPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CredentialServerPolicy, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc2ba0923, L"urlPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_UrlPolicy, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x47d03490, L"connection", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x78bff531, L"numberOfCells", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_Integer, - XFA_ATTRIBUTE_NumberOfCells, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, - {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0x2282c73, L"hAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1abbd7e0, L"dataNode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, - XFA_SCRIPT_Object}, - {0x25839852, L"access", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, - {0x2ee7678f, L"rotate", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Rotate, XFA_SCRIPT_Basic}, - {0x3b1ddd06, L"fillColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, - XFA_SCRIPT_Basic}, - {0x54c399e3, L"formattedValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_FormattedValue, -1, - XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x5a3b375d, L"borderColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, - XFA_SCRIPT_Basic}, - {0x5e936ed6, L"fontColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FontColor, -1, - XFA_SCRIPT_Basic}, - {0x6826c408, L"parentSubform", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_ParentSubform, -1, - XFA_SCRIPT_Basic}, - {0x79b67434, L"mandatoryMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_MandatoryMessage, -1, - XFA_SCRIPT_Basic}, - {0x7a7cc341, L"vAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, - {0x7c2ff6ae, L"maxH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, - {0x7c2ff6bd, L"maxW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, - {0x7d02356c, L"minH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, - {0x7d02357b, L"minW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, - {0x85fd6faf, L"mandatory", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_Mandatory, -1, - XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0x964fb42e, L"formatMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_FormatMessage, -1, - XFA_SCRIPT_Basic}, - {0xa03cf627, L"rawValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xa60dd202, L"length", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_Length, -1, - XFA_SCRIPT_Basic}, - {0xac06e2b0, L"colSpan", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbc8fa350, L"locale", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Locale, XFA_SCRIPT_Basic}, - {0xc2bd40fd, L"anchorType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, - {0xc4fed09b, L"accessKey", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AccessKey, XFA_SCRIPT_Basic}, - {0xcabfa3d0, L"validationMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, - XFA_SCRIPT_Basic}, - {0xdcecd663, L"editValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_EditValue, -1, - XFA_SCRIPT_Basic}, - {0xe07e5061, L"selectedIndex", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Field_SelectedIndex, -1, - XFA_SCRIPT_Basic}, - {0xf65e34be, L"borderWidth", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, - XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, - {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd843798, L"fullText", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_FullText, - -1, XFA_SCRIPT_Basic}, - {0x1b6d1cf5, L"reenter", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Reenter, - -1, XFA_SCRIPT_Basic}, - {0x1e6ffa9a, L"prevContentType", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_PrevContentType, - -1, XFA_SCRIPT_Basic}, - {0x25a3c206, L"soapFaultString", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_SoapFaultString, - -1, XFA_SCRIPT_Basic}, - {0x2e00c007, L"newContentType", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_NewContentType, - -1, XFA_SCRIPT_Basic}, - {0x4570500f, L"modifier", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Modifier, - -1, XFA_SCRIPT_Basic}, - {0x50e2e33b, L"selEnd", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_SelEnd, - -1, XFA_SCRIPT_Basic}, - {0x57de87c2, L"prevText", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_PrevText, - -1, XFA_SCRIPT_Basic}, - {0x6ea04e0a, L"soapFaultCode", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_SoapFaultCode, - -1, XFA_SCRIPT_Basic}, - {0x6f6556cf, L"newText", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_NewText, - -1, XFA_SCRIPT_Basic}, - {0x891f4606, L"change", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Change, - -1, XFA_SCRIPT_Basic}, - {0x8fa3c19e, L"shift", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Shift, - -1, XFA_SCRIPT_Basic}, - {0xa9d9b2e1, L"keyDown", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_KeyDown, - -1, XFA_SCRIPT_Basic}, - {0xbfc89db2, L"selStart", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_SelStart, - -1, XFA_SCRIPT_Basic}, - {0xc32a5812, L"commitKey", - (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_CommitKey, - -1, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", (XFA_ATTRIBUTE_CALLBACK)&CScript_EventPseudoModel:: - Script_EventPseudoModel_Target, - -1, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xa2e3514, L"cap", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Cap, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x5392ea58, L"stroke", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Stroke, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x94446dcc, L"thickness", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Thickness, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1ec8ab2c, L"rate", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Rate, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x7b29630a, L"sourceBelow", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SourceBelow, XFA_SCRIPT_Basic}, - {0x8fc36c0a, L"outputBelow", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OutputBelow, XFA_SCRIPT_Basic}, - {0xe996b2fe, L"sourceAbove", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_SourceAbove, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, - {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0x2282c73, L"hAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xf23332f, L"errorText", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_ErrorText, -1, - XFA_SCRIPT_Basic}, - {0x1abbd7e0, L"dataNode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, - XFA_SCRIPT_Object}, - {0x25839852, L"access", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, - {0x3b1ddd06, L"fillColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, - XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x5a3b375d, L"borderColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, - XFA_SCRIPT_Basic}, - {0x79b67434, L"mandatoryMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_MandatoryMessage, -1, - XFA_SCRIPT_Basic}, - {0x7a7cc341, L"vAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, - {0x7c2ff6ae, L"maxH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, - {0x7c2ff6bd, L"maxW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, - {0x7d02356c, L"minH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, - {0x7d02357b, L"minW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, - {0x7e7e845e, L"layout", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Layout, XFA_SCRIPT_Basic}, - {0x846599f8, L"transient", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_Transient, -1, - XFA_SCRIPT_Basic}, - {0x85fd6faf, L"mandatory", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_Mandatory, -1, - XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xa03cf627, L"rawValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_DefaultAndRawValue, - -1, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ExclGroup_DefaultAndRawValue, - -1, XFA_SCRIPT_Basic}, - {0xac06e2b0, L"colSpan", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc2bd40fd, L"anchorType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, - {0xc4fed09b, L"accessKey", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AccessKey, XFA_SCRIPT_Basic}, - {0xcabfa3d0, L"validationMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, - XFA_SCRIPT_Basic}, - {0xf65e34be, L"borderWidth", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xeda9017a, L"scope", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Scope, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x47d03490, L"connection", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, - {0x6cfa828a, L"runAt", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RunAt, XFA_SCRIPT_Basic}, - {0xa1b0d2f5, L"executeType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ExecuteType, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe6f99487, L"hScrollPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x42fed1fd, L"contentType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, - {0x54fa722c, L"transferEncoding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd171b240, L"aspect", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Aspect, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue_Read, -1, - XFA_SCRIPT_Basic}, - {0xdb55fec5, L"href", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Href, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0x7f6fd3d7, L"server", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Server, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x4b8bc840, L"fracDigits", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_FracDigits, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xde7f92ba, L"leadDigits", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LeadDigits, XFA_SCRIPT_Basic}, - {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, - {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0x2282c73, L"hAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1414d431, L"allowMacro", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AllowMacro, XFA_SCRIPT_Basic}, - {0x1517dfa1, L"columnWidths", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColumnWidths, XFA_SCRIPT_Basic}, - {0x1abbd7e0, L"dataNode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DataNode, -1, - XFA_SCRIPT_Object}, - {0x1ee2d24d, L"instanceIndex", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_InstanceIndex, -1, - XFA_SCRIPT_Basic}, - {0x25839852, L"access", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Access, XFA_SCRIPT_Basic}, - {0x3b1ddd06, L"fillColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_FillColor, -1, - XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x5a3b375d, L"borderColor", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderColor, -1, - XFA_SCRIPT_Basic}, - {0x7a7cc341, L"vAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, - {0x7c2ff6ae, L"maxH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, - {0x7c2ff6bd, L"maxW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, - {0x7d02356c, L"minH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, - {0x7d02357b, L"minW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, - {0x7e7e845e, L"layout", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Layout, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0x9cc17d75, L"mergeMode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MergeMode, XFA_SCRIPT_Basic}, - {0x9f3e9510, L"instanceManager", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Subform_InstanceManager, -1, - XFA_SCRIPT_Object}, - {0xac06e2b0, L"colSpan", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbc8fa350, L"locale", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Subform_Locale, -1, - XFA_SCRIPT_Basic}, - {0xc2bd40fd, L"anchorType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, - {0xcabfa3d0, L"validationMessage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_ValidationMessage, -1, - XFA_SCRIPT_Basic}, - {0xe4c3a5e5, L"restoreState", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RestoreState, XFA_SCRIPT_Basic}, - {0xeda9017a, L"scope", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Scope, XFA_SCRIPT_Basic}, - {0xf65e34be, L"borderWidth", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_BorderWidth, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0x5a50e9e6, L"version", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Handler_Version, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x4107ed, L"foxitAppType", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_FoxitAppType, - -1, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Name, - -1, XFA_SCRIPT_Basic}, - {0x66c1ae9, L"validationsEnabled", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_ValidationsEnabled, - -1, XFA_SCRIPT_Basic}, - {0x14d04502, L"title", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Title, - -1, XFA_SCRIPT_Basic}, - {0x193afe8b, L"foxitName", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_FoxitName, - -1, XFA_SCRIPT_Basic}, - {0x392ae445, L"platform", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Platform, - -1, XFA_SCRIPT_Basic}, - {0x5a50e9e6, L"version", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Version, - -1, XFA_SCRIPT_Basic}, - {0x66cb1eed, L"variation", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Variation, - -1, XFA_SCRIPT_Basic}, - {0x7717cbc4, L"language", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_Language, - -1, XFA_SCRIPT_Basic}, - {0x86698963, L"appType", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_AppType, - -1, XFA_SCRIPT_Basic}, - {0x94ff9e8d, L"calculationsEnabled", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_CalculationsEnabled, - -1, XFA_SCRIPT_Basic}, - {0xbcd44940, L"currentPage", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_CurrentPage, - -1, XFA_SCRIPT_Basic}, - {0xd4286870, L"foxitVersion", - (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_FoxitVersion, - -1, XFA_SCRIPT_Basic}, - {0xd592b920, L"numPages", (XFA_ATTRIBUTE_CALLBACK)&CScript_HostPseudoModel:: - Script_HostPseudoModel_NumPages, - -1, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x24d85167, L"timeout", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Timeout, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x7d9fd7c5, L"mode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Mode, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x7d9fd7c5, L"mode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_SubmitFormat_Mode, -1, - XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2038c9b2, L"role", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Role, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xfcef86b5, L"ready", (XFA_ATTRIBUTE_CALLBACK)&CScript_LayoutPseudoModel:: - Script_LayoutPseudoModel_Ready, - -1, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x5392ea58, L"stroke", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Stroke, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x7b95e661, L"inverted", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Inverted, XFA_SCRIPT_Basic}, - {0x94446dcc, L"thickness", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Thickness, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe8dddf50, L"join", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Join, XFA_SCRIPT_Basic}, - {0xe948b9a8, L"radius", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Radius, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xabfa6c4f, L"cSpace", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CSpace, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, - {0x3848b3f, L"next", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Next, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x6a3405dd, L"previous", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Previous, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xf6b59543, L"intact", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Intact, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x268b7ec1, L"commandType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CommandType, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbde9abda, L"data", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Data, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x5b707a35, L"scriptTest", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ScriptTest, XFA_SCRIPT_Basic}, - {0x6b6ddcfb, L"nullTest", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_NullTest, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xe64b1129, L"formatTest", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_FormatTest, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8c99377e, L"relation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relation, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x25363, L"to", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_To, XFA_SCRIPT_Basic}, - {0x66642f8f, L"force", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Force, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xcd7f7b54, L"from", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, - {0x2b5df51e, L"dataDescription", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x226ca8f1, L"operation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Operation, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xfb67185, L"recordsBefore", (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: - Script_DataWindow_RecordsBefore, - -1, XFA_SCRIPT_Basic}, - {0x21d5dfcb, L"currentRecordNumber", - (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: - Script_DataWindow_CurrentRecordNumber, - -1, XFA_SCRIPT_Basic}, - {0x312af044, L"recordsAfter", (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow:: - Script_DataWindow_RecordsAfter, - -1, XFA_SCRIPT_Basic}, - {0x6aab37cb, L"isDefined", - (XFA_ATTRIBUTE_CALLBACK)&CScript_DataWindow::Script_DataWindow_IsDefined, - -1, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x42fed1fd, L"contentType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, - {0x6cfa828a, L"runAt", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_RunAt, XFA_SCRIPT_Basic}, - {0xa021b738, L"stateless", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Script_Stateless, -1, - XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xadc4c77b, L"binding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Binding, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x7a0cc471, L"passwordChar", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_PasswordChar, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe6f99487, L"hScrollPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe6f99487, L"hScrollPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x14a32d52, L"pagePosition", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_PagePosition, XFA_SCRIPT_Basic}, - {0x8340ea66, L"oddOrEven", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OddOrEven, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xa85e74f3, L"initialNumber", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_InitialNumber, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe9ba472, L"numbered", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Numbered, XFA_SCRIPT_Basic}, - {0xd70798c2, L"blankOrNotBlank", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BlankOrNotBlank, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x34ae103c, L"reserve", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Reserve, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xf2009339, L"placement", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Placement, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x42fed1fd, L"contentType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, - {0x54fa722c, L"transferEncoding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc4547a08, L"maxLength", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxLength, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xdb55fec5, L"href", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Href, XFA_SCRIPT_Basic}, - {0x29418bb7, L"abbr", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Abbr, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf531b059, L"writingScript", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_WritingScript, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1b8dce3e, L"action", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Action, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x9dcc3ab3, L"trailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xcbcaf66d, L"leader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xb3543a6, L"max", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Max, -1, - XFA_SCRIPT_Basic}, - {0xb356ca4, L"min", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Min, -1, - XFA_SCRIPT_Basic}, - {0x6f544d49, L"count", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_InstanceManager_Count, -1, - XFA_SCRIPT_Basic}, - {0x25363, L"to", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_To, XFA_SCRIPT_Basic}, - {0xa0933954, L"unicodeRange", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_UnicodeRange, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xcd7f7b54, L"from", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_From, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x4ef3d02c, L"orientation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Orientation, XFA_SCRIPT_Basic}, - {0x65e30c67, L"imagingBBox", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ImagingBBox, XFA_SCRIPT_Basic}, - {0x9041d4b0, L"short", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Short, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe349d044, L"stock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Stock, XFA_SCRIPT_Basic}, - {0xf6b4afb0, L"long", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Long, XFA_SCRIPT_Basic}, - {0x5ce6195, L"vScrollPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VScrollPolicy, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x1ef3a64a, L"allowRichText", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AllowRichText, XFA_SCRIPT_Basic}, - {0x5a32e493, L"multiLine", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MultiLine, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe6f99487, L"hScrollPolicy", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HScrollPolicy, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xd52482e0, L"maxEntries", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxEntries, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x42fed1fd, L"contentType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, - {0x8855805f, L"contains", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Contains, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xe372ae97, L"isNull", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_IsNull, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x2b5df51e, L"dataDescription", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DataDescription, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x226ca8f1, L"operation", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Operation, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x42fed1fd, L"contentType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ContentType, XFA_SCRIPT_Basic}, - {0x54fa722c, L"transferEncoding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TransferEncoding, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xf197844d, L"match", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Match, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd996fa9b, L"hand", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x28dee6e9, L"format", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Encrypt_Format, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x68, L"h", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_H, XFA_SCRIPT_Basic}, - {0x77, L"w", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_W, XFA_SCRIPT_Basic}, - {0x78, L"x", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_X, XFA_SCRIPT_Basic}, - {0x79, L"y", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Y, XFA_SCRIPT_Basic}, - {0x2282c73, L"hAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_HAlign, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2ee7678f, L"rotate", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Rotate, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0x7a7cc341, L"vAlign", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_VAlign, XFA_SCRIPT_Basic}, - {0x7c2ff6ae, L"maxH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxH, XFA_SCRIPT_Basic}, - {0x7c2ff6bd, L"maxW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MaxW, XFA_SCRIPT_Basic}, - {0x7d02356c, L"minH", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinH, XFA_SCRIPT_Basic}, - {0x7d02357b, L"minW", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_MinW, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xa03cf627, L"rawValue", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xac06e2b0, L"colSpan", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ColSpan, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbc8fa350, L"locale", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Locale, XFA_SCRIPT_Basic}, - {0xc2bd40fd, L"anchorType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_AnchorType, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x39cdb0a2, L"priority", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Priority, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xeb511b54, L"disable", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Disable, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Value, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xcb0ac9, L"lineThrough", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LineThrough, XFA_SCRIPT_Basic}, - {0x2c1c7f1, L"typeface", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Typeface, XFA_SCRIPT_Basic}, - {0x8c74ae9, L"fontHorizontalScale", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_FontHorizontalScale, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2cd79033, L"kerningMode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_KerningMode, XFA_SCRIPT_Basic}, - {0x3a0273a6, L"underline", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Underline, XFA_SCRIPT_Basic}, - {0x4873c601, L"baselineShift", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_BaselineShift, XFA_SCRIPT_Basic}, - {0x4b319767, L"overlinePeriod", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_OverlinePeriod, XFA_SCRIPT_Basic}, - {0x79543055, L"letterSpacing", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LetterSpacing, XFA_SCRIPT_Basic}, - {0x8ec6204c, L"lineThroughPeriod", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LineThroughPeriod, XFA_SCRIPT_Basic}, - {0x907c7719, L"fontVerticalScale", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_FontVerticalScale, XFA_SCRIPT_Basic}, - {0xa686975b, L"size", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Size, XFA_SCRIPT_Basic}, - {0xb5e49bf2, L"posture", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Posture, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbd6e1d88, L"weight", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Weight, XFA_SCRIPT_Basic}, - {0xbd96a0e9, L"underlinePeriod", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_UnderlinePeriod, XFA_SCRIPT_Basic}, - {0xc0ec9fa4, L"overline", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Overline, XFA_SCRIPT_Basic}, - {0xaf754613, L"checksum", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Form_Checksum, -1, - XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x8e1c2921, L"relevant", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Relevant, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xea7090a0, L"override", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Override, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x9dcc3ab3, L"trailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xcbcaf66d, L"leader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x60a61edd, L"codeType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CodeType, XFA_SCRIPT_Basic}, - {0xb373a862, L"archive", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Archive, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xe1a26b56, L"codeBase", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_CodeBase, XFA_SCRIPT_Basic}, - {0xeb091003, L"classId", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ClassId, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x47d03490, L"connection", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, - {0xc39a88bd, L"labelRef", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_LabelRef, XFA_SCRIPT_Basic}, - {0xd50f903a, L"valueRef", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_ValueRef, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xea7090a0, L"override", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Override, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Extras_Type, -1, - XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x24d85167, L"timeout", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Timeout, XFA_SCRIPT_Basic}, - {0x47d03490, L"connection", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Connection, XFA_SCRIPT_Basic}, - {0x552d9ad5, L"usage", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usage, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc860f30a, L"delayedOpen", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_DelayedOpen, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x28dee6e9, L"format", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Format, XFA_SCRIPT_Basic}, - {0x824f21b7, L"embedPDF", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_EmbedPDF, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xdc75676c, L"textEncoding", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TextEncoding, XFA_SCRIPT_Basic}, - {0xf889e747, L"xdpContent", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_XdpContent, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x97be91b, L"content", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Packet_Content, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x4156ee3f, L"delimiter", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Delimiter, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x2f16a382, L"type", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Type, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x453eaf38, L"startNew", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_StartNew, XFA_SCRIPT_Basic}, - {0x9dcc3ab3, L"trailer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Trailer, XFA_SCRIPT_Basic}, - {0xa6118c89, L"targetType", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_TargetType, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xc8da4da7, L"target", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Target, XFA_SCRIPT_Basic}, - {0xcbcaf66d, L"leader", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Leader, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xabef37e3, L"slope", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Slope, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xd996fa9b, L"hand", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Hand, XFA_SCRIPT_Basic}, - {0xa60dd202, L"length", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_NodeList::Script_ListClass_Length, -1, - XFA_SCRIPT_Basic}, - {0x20146, L"db", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Source_Db, -1, - XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xb3543a6, L"max", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Occur_Max, - -1, XFA_SCRIPT_Basic}, - {0xb356ca4, L"min", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Occur_Min, - -1, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x7d0b5fca, L"initial", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Initial, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x29418bb7, L"abbr", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Abbr, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0xbe52dfbf, L"desc", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Desc, XFA_SCRIPT_Basic}, - {0xf6b47749, L"lock", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_BOOL, - XFA_ATTRIBUTE_Lock, XFA_SCRIPT_Basic}, - {0xbb8df5d, L"ref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Ref, XFA_SCRIPT_Basic}, - {0xc0811ed, L"use", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Use, XFA_SCRIPT_Basic}, - {0x570ce835, L"presence", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Presence, XFA_SCRIPT_Basic}, - {0xa5b410cf, L"save", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Save, XFA_SCRIPT_Basic}, - {0xbc254332, L"usehref", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Usehref, XFA_SCRIPT_Basic}, - {0xb2c80857, L"className", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Object::Script_ObjectClass_ClassName, -1, - XFA_SCRIPT_Basic}, - {0xa60dd202, L"length", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_NodeList::Script_ListClass_Length, -1, - XFA_SCRIPT_Basic}, - {0x31b19c1, L"name", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Name, XFA_SCRIPT_Basic}, - {0x9f9d0f9, L"all", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_All, -1, - XFA_SCRIPT_Object}, - {0x4df15659, L"nodes", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Nodes, -1, - XFA_SCRIPT_Object}, - {0x78a8d6cf, L"classAll", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_ClassAll, -1, - XFA_SCRIPT_Object}, - {0xcad6d8ca, L"parent", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Parent, -1, - XFA_SCRIPT_Object}, - {0xd5679c78, L"index", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_Index, -1, - XFA_SCRIPT_Basic}, - {0xdb5b4bce, L"classIndex", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_ClassIndex, -1, - XFA_SCRIPT_Basic}, - {0xe4989adf, L"somExpression", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_TreeClass_SomExpression, -1, - XFA_SCRIPT_Basic}, - {0x21aed, L"id", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Attribute_String, - XFA_ATTRIBUTE_Id, XFA_SCRIPT_Basic}, - {0x234a1, L"ns", (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_Ns, - -1, XFA_SCRIPT_Basic}, - {0x50d1a9d1, L"model", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_Model, -1, - XFA_SCRIPT_Object}, - {0xacb4823f, L"isContainer", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_IsContainer, -1, - XFA_SCRIPT_Basic}, - {0xe372ae97, L"isNull", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_IsNull, -1, - XFA_SCRIPT_Basic}, - {0xfe612a5b, L"oneOfChild", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_NodeClass_OneOfChild, -1, - XFA_SCRIPT_Object}, - {0x97c1c65, L"context", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ModelClass_Context, -1, - XFA_SCRIPT_Object}, - {0x58be2870, L"aliasNode", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_ModelClass_AliasNode, -1, - XFA_SCRIPT_Object}, - {0xa52682bd, L"{default}", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, - {0xd6e27f1d, L"value", - (XFA_ATTRIBUTE_CALLBACK)&CXFA_Node::Script_Som_DefaultValue, -1, - XFA_SCRIPT_Basic}, -}; -const int32_t g_iSomAttributeCount = - sizeof(g_SomAttributeData) / sizeof(XFA_ATTRIBUTEINFO); diff --git a/xfa/src/fxfa/parser/xfa_basic_data.h b/xfa/src/fxfa/parser/xfa_basic_data.h deleted file mode 100644 index 4ccdd1c7c8..0000000000 --- a/xfa/src/fxfa/parser/xfa_basic_data.h +++ /dev/null @@ -1,48 +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_SRC_FXFA_PARSER_XFA_BASIC_DATA_H_ -#define XFA_SRC_FXFA_PARSER_XFA_BASIC_DATA_H_ - -#include "xfa/include/fxfa/fxfa_basic.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" - -extern const XFA_PACKETINFO g_XFAPacketData[]; -extern const int32_t g_iXFAPacketCount; - -extern const XFA_ATTRIBUTEENUMINFO g_XFAEnumData[]; -extern const int32_t g_iXFAEnumCount; - -extern const XFA_ATTRIBUTEINFO g_XFAAttributeData[]; -extern const int32_t g_iXFAAttributeCount; - -extern const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[]; -extern const int32_t g_iXFANotsureCount; - -extern const XFA_ELEMENTINFO g_XFAElementData[]; -extern const int32_t g_iXFAElementCount; - -extern const XFA_ELEMENTHIERARCHY g_XFAElementChildrenIndex[]; -extern const FX_WORD g_XFAElementChildrenData[]; - -extern const XFA_ELEMENTHIERARCHY g_XFAElementAttributeIndex[]; -extern const uint8_t g_XFAElementAttributeData[]; - -extern const XFA_ELEMENTHIERARCHY g_XFAElementPropertyIndex[]; -extern const XFA_PROPERTY g_XFAElementPropertyData[]; - -extern const XFA_SCRIPTHIERARCHY g_XFAScriptIndex[]; - -extern const XFA_NOTSUREATTRIBUTE g_XFANotsureAttributes[]; -extern const int32_t g_iXFANotsureCount; - -extern const XFA_METHODINFO g_SomMethodData[]; -extern const int32_t g_iSomMethodCount; - -extern const XFA_SCRIPTATTRIBUTEINFO g_SomAttributeData[]; -extern const int32_t g_iSomAttributeCount; - -#endif // XFA_SRC_FXFA_PARSER_XFA_BASIC_DATA_H_ diff --git a/xfa/src/fxfa/parser/xfa_basic_imp.cpp b/xfa/src/fxfa/parser/xfa_basic_imp.cpp deleted file mode 100644 index a0aa56d8be..0000000000 --- a/xfa/src/fxfa/parser/xfa_basic_imp.cpp +++ /dev/null @@ -1,612 +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/src/fxfa/parser/xfa_basic_imp.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/crt/fgas_algorithm.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fgas/crt/fgas_system.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_data.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/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.GetPtr(), iLength); - int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} - -const XFA_PACKETINFO* XFA_GetPacketByID(FX_DWORD dwPacket) { - int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - FX_DWORD dwFind = (g_XFAPacketData + iMid)->eName; - if (dwPacket == dwFind) { - return g_XFAPacketData + iMid; - } else if (dwPacket < dwFind) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} - -const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) { - return g_XFAPacketData + 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.GetPtr(), iLength); - int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} -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.GetPtr(), iLength); - int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} -const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) { - return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL; -} -FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue, - XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - XFA_ATTRIBUTETYPE eType, - FX_DWORD dwPacket) { - const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); - if (pInfo == NULL) { - return FALSE; - } - if (dwPacket && (dwPacket & pInfo->dwPackets) == 0) { - return FALSE; - } - if (pInfo->eType == eType) { - pValue = pInfo->pDefValue; - return TRUE; - } else if (pInfo->eType == XFA_ATTRIBUTETYPE_NOTSURE) { - const XFA_NOTSUREATTRIBUTE* pAttr = - XFA_GetNotsureAttribute(eElement, eAttribute, eType); - if (pAttr) { - pValue = pAttr->pValue; - return TRUE; - } - } - return FALSE; -} -XFA_ATTRIBUTEENUM XFA_GetAttributeDefaultValue_Enum(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - FX_DWORD dwPacket) { - void* pValue; - if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, - XFA_ATTRIBUTETYPE_Enum, dwPacket)) { - return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; - } - return XFA_ATTRIBUTEENUM_Unknown; -} -CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - FX_DWORD dwPacket) { - void* pValue; - if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, - XFA_ATTRIBUTETYPE_Cdata, dwPacket)) { - return (const FX_WCHAR*)pValue; - } - return NULL; -} -FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - FX_DWORD dwPacket) { - void* pValue; - if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, - XFA_ATTRIBUTETYPE_Boolean, dwPacket)) { - return (FX_BOOL)(uintptr_t)pValue; - } - return FALSE; -} -int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - FX_DWORD 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, - FX_DWORD dwPacket) { - void* pValue; - if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute, - XFA_ATTRIBUTETYPE_Measure, dwPacket)) { - return *(CXFA_Measurement*)pValue; - } - 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.GetPtr(), iLength); - int32_t iStart = 0, iEnd = g_iXFAElementCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} -const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName) { - return (eName < g_iXFAElementCount) ? (g_XFAElementData + eName) : NULL; -} -const FX_WORD* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount) { - if (eElement >= g_iXFAElementCount) { - return NULL; - } - const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementChildrenIndex + eElement; - iCount = pElement->wCount; - return g_XFAElementChildrenData + pElement->wStart; -} -const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { - if (eElement >= g_iXFAElementCount) { - return NULL; - } - const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; - iCount = pElement->wCount; - return g_XFAElementAttributeData + pElement->wStart; -} -const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - FX_DWORD dwPacket) { - int32_t iCount = 0; - const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); - if (pAttr == NULL || iCount < 1) { - return NULL; - } - CFX_DSPATemplate<uint8_t> search; - int32_t index = search.Lookup(eAttribute, pAttr, iCount); - if (index < 0) { - return NULL; - } - const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); - ASSERT(pInfo); - if (dwPacket == XFA_XDPPACKET_UNKNOWN) - return pInfo; - return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; -} -const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement, - XFA_ELEMENT eChild, - FX_DWORD dwPacket) { - int32_t iCount = 0; - const FX_WORD* pChild = XFA_GetElementChildren(eElement, iCount); - if (pChild == NULL || iCount < 1) { - return NULL; - } - CFX_DSPATemplate<FX_WORD> 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) { - return NULL; - } - const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; - iCount = pElement->wCount; - return g_XFAElementPropertyData + pElement->wStart; -} -const XFA_PROPERTY* XFA_GetPropertyOfElement(XFA_ELEMENT eElement, - XFA_ELEMENT eProperty, - FX_DWORD dwPacket) { - int32_t iCount = 0; - const XFA_PROPERTY* pProperty = XFA_GetElementProperties(eElement, iCount); - if (pProperty == NULL || iCount < 1) { - return NULL; - } - int32_t iStart = 0, iEnd = iCount - 1, iMid; - do { - iMid = (iStart + iEnd) / 2; - XFA_ELEMENT eName = (XFA_ELEMENT)pProperty[iMid].eName; - if (eProperty == eName) { - break; - } else if (eProperty < eName) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - if (iStart > iEnd) { - return NULL; - } - const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eProperty); - ASSERT(pInfo); - if (dwPacket == XFA_XDPPACKET_UNKNOWN) - return pProperty + iMid; - return (dwPacket & pInfo->dwPackets) ? (pProperty + iMid) : NULL; -} -const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - XFA_ATTRIBUTETYPE eType) { - int32_t iStart = 0, iEnd = g_iXFANotsureCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_NOTSUREATTRIBUTE* pAttr = g_XFANotsureAttributes + iMid; - if (eElement == pAttr->eElement) { - if (pAttr->eAttribute == eAttribute) { - if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { - return pAttr; - } - return NULL; - } else { - int32_t iBefore = iMid - 1; - if (iBefore >= 0) { - pAttr = g_XFANotsureAttributes + iBefore; - while (eElement == pAttr->eElement) { - if (pAttr->eAttribute == eAttribute) { - if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { - return pAttr; - } - return NULL; - } - iBefore--; - if (iBefore < 0) { - break; - } - pAttr = g_XFANotsureAttributes + iBefore; - } - } - int32_t iAfter = iMid + 1; - if (iAfter <= g_iXFANotsureCount - 1) { - pAttr = g_XFANotsureAttributes + iAfter; - while (eElement == pAttr->eElement) { - if (pAttr->eAttribute == eAttribute) { - if (eType == XFA_ATTRIBUTETYPE_NOTSURE || eType == pAttr->eType) { - return pAttr; - } - return NULL; - } - iAfter++; - if (iAfter > g_iXFANotsureCount - 1) { - break; - } - pAttr = g_XFANotsureAttributes + iAfter; - } - } - return NULL; - } - } else if (eElement < pAttr->eElement) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } 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; - } - int32_t iElementIndex = eElement; - while (iElementIndex != -1) { - XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; - int32_t icount = scriptIndex->wMethodCount; - if (icount == 0) { - iElementIndex = scriptIndex->wParentIndex; - continue; - } - uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.GetPtr(), iLength); - int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_METHODINFO* pInfo = g_SomMethodData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - iElementIndex = scriptIndex->wParentIndex; - } - return NULL; -} -const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName( - XFA_ELEMENT eElement, - const CFX_WideStringC& wsAttributeName) { - int32_t iLength = wsAttributeName.GetLength(); - if (iLength == 0) { - return NULL; - } - int32_t iElementIndex = eElement; - while (iElementIndex != -1) { - XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex; - int32_t icount = scriptIndex->wAttributeCount; - if (icount == 0) { - iElementIndex = scriptIndex->wParentIndex; - continue; - } - uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.GetPtr(), iLength); - int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid; - if (uHash == pInfo->uHash) { - return pInfo; - } else if (uHash < pInfo->uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - iElementIndex = scriptIndex->wParentIndex; - } - return NULL; -} -void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) { - if (wsMeasure.IsEmpty()) { - m_fValue = 0; - m_eUnit = XFA_UNIT_Unknown; - return; - } - int32_t iUsedLen = 0; - int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; - FX_FLOAT fValue = FX_wcstof(wsMeasure.GetPtr() + iOffset, - wsMeasure.GetLength() - iOffset, &iUsedLen); - XFA_UNIT eUnit = GetUnit(wsMeasure.Mid(iOffset + iUsedLen)); - Set(fValue, eUnit); -} -FX_BOOL CXFA_Measurement::ToString(CFX_WideString& wsMeasure) const { - switch (GetUnit()) { - case XFA_UNIT_Mm: - wsMeasure.Format(L"%.8gmm", GetValue()); - return TRUE; - case XFA_UNIT_Pt: - wsMeasure.Format(L"%.8gpt", GetValue()); - return TRUE; - case XFA_UNIT_In: - wsMeasure.Format(L"%.8gin", GetValue()); - return TRUE; - case XFA_UNIT_Cm: - wsMeasure.Format(L"%.8gcm", GetValue()); - return TRUE; - case XFA_UNIT_Mp: - wsMeasure.Format(L"%.8gmp", GetValue()); - return TRUE; - case XFA_UNIT_Pc: - wsMeasure.Format(L"%.8gpc", GetValue()); - return TRUE; - case XFA_UNIT_Em: - wsMeasure.Format(L"%.8gem", GetValue()); - return TRUE; - case XFA_UNIT_Percent: - wsMeasure.Format(L"%.8g%%", GetValue()); - return TRUE; - default: - wsMeasure.Format(L"%.8g", GetValue()); - return FALSE; - } -} -FX_BOOL CXFA_Measurement::ToUnit(XFA_UNIT eUnit, FX_FLOAT& fValue) const { - fValue = GetValue(); - XFA_UNIT eFrom = GetUnit(); - if (eFrom == eUnit) { - return TRUE; - } - switch (eFrom) { - case XFA_UNIT_Pt: - break; - case XFA_UNIT_Mm: - fValue *= 72 / 2.54f / 10; - break; - case XFA_UNIT_In: - fValue *= 72; - break; - case XFA_UNIT_Cm: - fValue *= 72 / 2.54f; - break; - case XFA_UNIT_Mp: - fValue *= 0.001f; - break; - case XFA_UNIT_Pc: - fValue *= 12.0f; - break; - default: - fValue = 0; - return FALSE; - } - switch (eUnit) { - case XFA_UNIT_Pt: - return TRUE; - case XFA_UNIT_Mm: - fValue /= 72 / 2.54f / 10; - return TRUE; - case XFA_UNIT_In: - fValue /= 72; - return TRUE; - case XFA_UNIT_Cm: - fValue /= 72 / 2.54f; - return TRUE; - case XFA_UNIT_Mp: - fValue /= 0.001f; - return TRUE; - case XFA_UNIT_Pc: - fValue /= 12.0f; - return TRUE; - default: - fValue = 0; - return FALSE; - } - return FALSE; -} -XFA_UNIT CXFA_Measurement::GetUnit(const CFX_WideStringC& wsUnit) { - if (wsUnit == FX_WSTRC(L"mm")) { - return XFA_UNIT_Mm; - } else if (wsUnit == FX_WSTRC(L"pt")) { - return XFA_UNIT_Pt; - } else if (wsUnit == FX_WSTRC(L"in")) { - return XFA_UNIT_In; - } else if (wsUnit == FX_WSTRC(L"cm")) { - return XFA_UNIT_Cm; - } else if (wsUnit == FX_WSTRC(L"pc")) { - return XFA_UNIT_Pc; - } else if (wsUnit == FX_WSTRC(L"mp")) { - return XFA_UNIT_Mp; - } else if (wsUnit == FX_WSTRC(L"em")) { - return XFA_UNIT_Em; - } else if (wsUnit == FX_WSTRC(L"%")) { - return XFA_UNIT_Percent; - } else { - return XFA_UNIT_Unknown; - } -} -IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer) { - return new CXFA_WideTextRead(wsBuffer); -} -CXFA_WideTextRead::CXFA_WideTextRead(const CFX_WideString& wsBuffer) - : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {} -void CXFA_WideTextRead::Release() { - if (--m_iRefCount < 1) { - delete this; - } -} -IFX_Stream* CXFA_WideTextRead::Retain() { - m_iRefCount++; - return this; -} -FX_DWORD CXFA_WideTextRead::GetAccessModes() const { - return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text; -} -int32_t CXFA_WideTextRead::GetLength() const { - return m_wsBuffer.GetLength() * sizeof(FX_WCHAR); -} -int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - switch (eSeek) { - case FX_STREAMSEEK_Begin: - m_iPosition = iOffset; - break; - case FX_STREAMSEEK_Current: - m_iPosition += iOffset; - break; - case FX_STREAMSEEK_End: - m_iPosition = m_wsBuffer.GetLength() + iOffset; - break; - } - if (m_iPosition < 0) { - m_iPosition = 0; - } - if (m_iPosition > m_wsBuffer.GetLength()) { - m_iPosition = m_wsBuffer.GetLength(); - } - return GetPosition(); -} -int32_t CXFA_WideTextRead::GetPosition() { - return m_iPosition * sizeof(FX_WCHAR); -} -FX_BOOL CXFA_WideTextRead::IsEOF() const { - return m_iPosition >= m_wsBuffer.GetLength(); -} -int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize) { - if (iMaxLength > m_wsBuffer.GetLength() - m_iPosition) { - iMaxLength = m_wsBuffer.GetLength() - m_iPosition; - } - FXSYS_wcsncpy(pStr, (const FX_WCHAR*)m_wsBuffer + m_iPosition, iMaxLength); - m_iPosition += iMaxLength; - bEOS = IsEOF(); - return iMaxLength; -} -FX_WORD CXFA_WideTextRead::GetCodePage() const { - return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; -} -FX_WORD CXFA_WideTextRead::SetCodePage(FX_WORD wCodePage) { - return GetCodePage(); -} diff --git a/xfa/src/fxfa/parser/xfa_basic_imp.h b/xfa/src/fxfa/parser/xfa_basic_imp.h deleted file mode 100644 index 562cf15909..0000000000 --- a/xfa/src/fxfa/parser/xfa_basic_imp.h +++ /dev/null @@ -1,71 +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_SRC_FXFA_PARSER_XFA_BASIC_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_BASIC_IMP_H_ - -#include "xfa/include/fxfa/fxfa_basic.h" -#include "xfa/src/fgas/crt/fgas_stream.h" - -struct XFA_NOTSUREATTRIBUTE { - XFA_ELEMENT eElement; - XFA_ATTRIBUTE eAttribute; - XFA_ATTRIBUTETYPE eType; - void* pValue; -}; -const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute( - XFA_ELEMENT eElement, - XFA_ATTRIBUTE eAttribute, - XFA_ATTRIBUTETYPE eType = XFA_ATTRIBUTETYPE_NOTSURE); - -class CXFA_WideTextRead : public IFX_Stream { - public: - CXFA_WideTextRead(const CFX_WideString& wsBuffer); - virtual void Release(); - virtual IFX_Stream* Retain(); - - virtual FX_DWORD GetAccessModes() const; - virtual int32_t GetLength() const; - virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset); - virtual int32_t GetPosition(); - virtual FX_BOOL IsEOF() const; - - virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) { return 0; } - virtual int32_t ReadString(FX_WCHAR* pStr, - int32_t iMaxLength, - FX_BOOL& bEOS, - int32_t const* pByteSize = NULL); - virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - return 0; - } - virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) { - return 0; - } - virtual void Flush() {} - virtual FX_BOOL SetLength(int32_t iLength) { return FALSE; } - - virtual int32_t GetBOM(uint8_t bom[4]) const { return 0; } - virtual FX_WORD GetCodePage() const; - virtual FX_WORD SetCodePage(FX_WORD wCodePage); - - virtual void Lock() {} - virtual void Unlock() {} - - virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, - int32_t iOffset, - int32_t iLength) { - return NULL; - } - - CFX_WideString GetSrcText() const { return m_wsBuffer; } - - protected: - CFX_WideString m_wsBuffer; - int32_t m_iPosition; - int32_t m_iRefCount; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_BASIC_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_docdata.h b/xfa/src/fxfa/parser/xfa_docdata.h deleted file mode 100644 index 5c6cf13dfe..0000000000 --- a/xfa/src/fxfa/parser/xfa_docdata.h +++ /dev/null @@ -1,36 +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_SRC_FXFA_PARSER_XFA_DOCDATA_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCDATA_H_ - -#include "xfa/src/fxfa/parser/xfa_document.h" - -enum XFA_DATAFORMAT { - XFA_DATAFORMAT_XDP, -}; - -class IXFA_PacketExport { - public: - static IXFA_PacketExport* Create(CXFA_Document* pDocument, - XFA_DATAFORMAT eFormat = XFA_DATAFORMAT_XDP); - virtual ~IXFA_PacketExport() {} - virtual void Release() = 0; - virtual FX_BOOL Export(IFX_FileWrite* pWrite) = 0; - virtual FX_BOOL Export(IFX_FileWrite* pWrite, - CXFA_Node* pNode, - FX_DWORD dwFlag = 0, - const FX_CHAR* pChecksum = NULL) = 0; -}; -class IXFA_PacketImport { - public: - static IXFA_PacketImport* Create(CXFA_Document* pDstDoc); - virtual ~IXFA_PacketImport() {} - virtual void Release() = 0; - virtual FX_BOOL ImportData(IFX_FileRead* pDataDocument) = 0; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCDATA_H_ diff --git a/xfa/src/fxfa/parser/xfa_doclayout.h b/xfa/src/fxfa/parser/xfa_doclayout.h deleted file mode 100644 index 1ebe412078..0000000000 --- a/xfa/src/fxfa/parser/xfa_doclayout.h +++ /dev/null @@ -1,136 +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_SRC_FXFA_PARSER_XFA_DOCLAYOUT_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCLAYOUT_H_ - -#include "xfa/src/fxfa/parser/xfa_document.h" - -class CXFA_ContainerLayoutItem; -class CXFA_ContentLayoutItem; -class IXFA_DocLayout; - -class IXFA_LayoutPage { - public: - virtual ~IXFA_LayoutPage() {} - virtual IXFA_DocLayout* GetLayout() const = 0; - virtual int32_t GetPageIndex() const = 0; - virtual void GetPageSize(CFX_SizeF& size) = 0; - virtual CXFA_Node* GetMasterPage() const = 0; -}; - -class CXFA_LayoutItem { - public: - virtual ~CXFA_LayoutItem(); - - FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; } - FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; } - inline CXFA_ContainerLayoutItem* AsContainerLayoutItem(); - inline CXFA_ContentLayoutItem* AsContentLayoutItem(); - - IXFA_LayoutPage* GetPage() const; - CXFA_Node* GetFormNode() const; - void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const; - int32_t GetIndex() const; - int32_t GetCount() const; - CXFA_LayoutItem* GetParent() const; - const CXFA_LayoutItem* GetFirst() const; - CXFA_LayoutItem* GetFirst(); - const CXFA_LayoutItem* GetLast() const; - CXFA_LayoutItem* GetLast(); - CXFA_LayoutItem* GetPrev() const; - CXFA_LayoutItem* GetNext() const; - - void AddChild(CXFA_LayoutItem* pChildItem); - void AddHeadChild(CXFA_LayoutItem* pChildItem); - void RemoveChild(CXFA_LayoutItem* pChildItem); - void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem); - - CXFA_Node* m_pFormNode; - CXFA_LayoutItem* m_pParent; - CXFA_LayoutItem* m_pNextSibling; - CXFA_LayoutItem* m_pFirstChild; - - protected: - CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem); - - FX_BOOL m_bIsContentLayoutItem; -}; - -class CXFA_ContainerLayoutItem : public CXFA_LayoutItem, - public IXFA_LayoutPage { - public: - CXFA_ContainerLayoutItem(CXFA_Node* pNode); - - // IXFA_LayoutPage: - IXFA_DocLayout* GetLayout() const override; - int32_t GetPageIndex() const override; - void GetPageSize(CFX_SizeF& size) override; - CXFA_Node* GetMasterPage() const override; - - 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); - virtual ~CXFA_ContentLayoutItem(); - - CXFA_ContentLayoutItem* m_pPrev; - CXFA_ContentLayoutItem* m_pNext; - CFX_PointF m_sPos; - CFX_SizeF m_sSize; - FX_DWORD m_dwStatus; -}; - -CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() { - return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this) - : nullptr; -} -CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() { - return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this) - : nullptr; -} -inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) { - return pItem ? pItem->AsContainerLayoutItem() : nullptr; -} -inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) { - return pItem ? pItem->AsContentLayoutItem() : nullptr; -} - -class CXFA_TraverseStrategy_LayoutItem { - public: - static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) { - return pLayoutItem->m_pFirstChild; - } - static inline CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) { - return pLayoutItem->m_pNextSibling; - } - static inline CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) { - return pLayoutItem->m_pParent; - } -}; - -class IXFA_DocLayout { - public: - virtual ~IXFA_DocLayout() {} - virtual CXFA_Document* GetDocument() const = 0; - virtual int32_t StartLayout(FX_BOOL bForceRestart = FALSE) = 0; - virtual int32_t DoLayout(IFX_Pause* pPause = NULL) = 0; - virtual FX_BOOL IncrementLayout() = 0; - virtual int32_t CountPages() const = 0; - virtual IXFA_LayoutPage* GetPage(int32_t index) const = 0; - virtual CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem) = 0; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCLAYOUT_H_ diff --git a/xfa/src/fxfa/parser/xfa_document.h b/xfa/src/fxfa/parser/xfa_document.h deleted file mode 100644 index d17c9883c9..0000000000 --- a/xfa/src/fxfa/parser/xfa_document.h +++ /dev/null @@ -1,201 +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_SRC_FXFA_PARSER_XFA_DOCUMENT_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_H_ - -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CXFA_Document; -class CXFA_LayoutItem; -class CXFA_LayoutProcessor; -class CXFA_Node; -class IXFA_DocLayout; -class IXFA_DocParser; -class IXFA_LayoutPage; -class IXFA_Notify; -class IXFA_ObjFactory; -class IXFA_ScriptContext; - -enum XFA_VERSION { - XFA_VERSION_UNKNOWN = 0, - XFA_VERSION_200 = 200, - XFA_VERSION_202 = 202, - XFA_VERSION_204 = 204, - XFA_VERSION_205 = 205, - XFA_VERSION_206 = 206, - XFA_VERSION_207 = 207, - XFA_VERSION_208 = 208, - XFA_VERSION_300 = 300, - XFA_VERSION_301 = 301, - XFA_VERSION_303 = 303, - XFA_VERSION_306 = 306, - XFA_VERSION_DEFAULT = XFA_VERSION_303, - XFA_VERSION_MIN = 200, - 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, - XFA_LAYOUTRESULT_NextContent, -}; -#define XFA_LAYOUTNOTIFY_StrictHeight 0x0001 -#define XFA_LAYOUTNOTIFY_NoParentBreak 0x0002 - -class IXFA_Notify { - public: - virtual ~IXFA_Notify() {} - virtual void OnPageEvent(IXFA_LayoutPage* pSender, - XFA_PAGEEVENT eEvent, - void* pParam = NULL) = 0; - - virtual void OnNodeEvent(CXFA_Node* pSender, - XFA_NODEEVENT eEvent, - void* pParam = NULL, - void* pParam2 = NULL, - void* pParam3 = NULL, - void* pParam4 = NULL) = 0; - virtual void OnWidgetDataEvent(CXFA_WidgetData* pSender, - FX_DWORD dwEvent, - void* pParam = NULL, - void* pAdditional = NULL, - void* pAdditional2 = NULL) = 0; - - virtual CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode) = 0; - virtual void OnLayoutEvent(IXFA_DocLayout* pLayout, - CXFA_LayoutItem* pSender, - XFA_LAYOUTEVENT eEvent, - void* pParam = NULL, - void* pParam2 = NULL) = 0; - virtual void StartFieldDrawLayout(CXFA_Node* pItem, - FX_FLOAT& fCalcWidth, - FX_FLOAT& fCalcHeight) = 0; - virtual FX_BOOL FindSplitPos(CXFA_Node* pItem, - int32_t iBlockIndex, - FX_FLOAT& fCalcHeightPos) = 0; - virtual FX_BOOL RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) = 0; - virtual int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady = FALSE, - FX_BOOL bRecursive = TRUE, - CXFA_WidgetAcc* pExclude = NULL) = 0; - virtual void AddCalcValidate(CXFA_Node* pNode) = 0; - virtual IXFA_Doc* GetHDOC() = 0; - virtual IXFA_DocProvider* GetDocProvider() = 0; - virtual IXFA_AppProvider* GetAppProvider() = 0; - virtual IXFA_WidgetHandler* GetWidgetHandler() = 0; - virtual IXFA_Widget* GetHWidget(CXFA_LayoutItem* pLayoutItem) = 0; - virtual void OpenDropDownList(IXFA_Widget* hWidget) = 0; - virtual CFX_WideString GetCurrentDateTime() = 0; - virtual void ResetData(CXFA_WidgetData* pWidgetData = NULL) = 0; - virtual int32_t GetLayoutStatus() = 0; - virtual void RunNodeInitialize(CXFA_Node* pNode) = 0; - virtual void RunSubformIndexChange(CXFA_Node* pSubformNode) = 0; - virtual CXFA_Node* GetFocusWidgetNode() = 0; - virtual void SetFocusWidgetNode(CXFA_Node* pNode) = 0; -}; -class IXFA_ObjFactory { - public: - virtual ~IXFA_ObjFactory() {} - virtual CXFA_Node* CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement) = 0; - virtual CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, - XFA_ELEMENT eElement) = 0; -}; -#define XFA_DOCFLAG_StrictScoping 0x0001 -#define XFA_DOCFLAG_HasInteractive 0x0002 -#define XFA_DOCFLAG_Interactive 0x0004 -#define XFA_DOCFLAG_Scripting 0x0008 -class CScript_DataWindow; -class CScript_EventPseudoModel; -class CScript_HostPseudoModel; -class CScript_LogPseudoModel; -class CScript_LayoutPseudoModel; -class CScript_SignaturePseudoModel; -class CXFA_Document : public IXFA_ObjFactory { - public: - CXFA_Document(IXFA_DocParser* pParser); - ~CXFA_Document(); - CXFA_Node* GetRoot() const { return m_pRootNode; } - IXFA_DocParser* GetParser() const { return m_pParser; } - IXFA_Notify* GetNotify() const; - void SetRoot(CXFA_Node* pNewRoot); - CXFA_Object* GetXFAObject(const CFX_WideStringC& wsNodeName); - CXFA_Object* GetXFAObject(FX_DWORD wsNodeNameHash); - void AddPurgeNode(CXFA_Node* pNode); - FX_BOOL RemovePurgeNode(CXFA_Node* pNode); - void PurgeNodes(); - bool HasFlag(FX_DWORD dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } - void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE); - FX_BOOL IsInteractive(); - XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; } - XFA_VERSION RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS); - CXFA_LocaleMgr* GetLocalMgr(); - virtual CXFA_Node* CreateNode(FX_DWORD dwPacket, XFA_ELEMENT eElement); - virtual CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, - XFA_ELEMENT eElement); - void DoProtoMerge(); - CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID); - void DoDataMerge(); - void DoDataRemerge(FX_BOOL bDoDataMerge); - CXFA_Node* DataMerge_CopyContainer(CXFA_Node* pTemplateNode, - CXFA_Node* pFormNode, - CXFA_Node* pDataScope, - FX_BOOL bOneInstance = FALSE, - FX_BOOL bDataMerge = TRUE, - FX_BOOL bUpLevel = TRUE); - void DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot); - CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes); - CXFA_LayoutProcessor* GetLayoutProcessor(); - IXFA_DocLayout* GetDocLayout(); - IXFA_ScriptContext* InitScriptContext(FXJSE_HRUNTIME hRuntime); - IXFA_ScriptContext* GetScriptContext(); - void ClearLayoutData(); - - CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> m_rgGlobalBinding; - CXFA_NodeArray m_pPendingPageSet; - - protected: - IXFA_DocParser* m_pParser; - IXFA_ScriptContext* m_pScriptContext; - CXFA_LayoutProcessor* m_pLayoutProcessor; - CXFA_Node* m_pRootNode; - CXFA_LocaleMgr* m_pLocalMgr; - CScript_DataWindow* m_pScriptDataWindow; - CScript_EventPseudoModel* m_pScriptEvent; - CScript_HostPseudoModel* m_pScriptHost; - CScript_LogPseudoModel* m_pScriptLog; - CScript_LayoutPseudoModel* m_pScriptLayout; - CScript_SignaturePseudoModel* m_pScriptSignature; - CXFA_NodeSet m_rgPurgeNodes; - XFA_VERSION m_eCurVersionMode; - FX_DWORD m_dwDocFlags; - friend class CXFA_SimpleParser; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_H_ diff --git a/xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp b/xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp deleted file mode 100644 index 321fbbd466..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_datadescription_imp.cpp +++ /dev/null @@ -1,126 +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/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -#define XFA_HASHCODE_Group 0xf7f75fcd - -class CXFA_TraverseStrategy_DDGroup { - public: - static inline CXFA_Node* GetFirstChild(CXFA_Node* pDDGroupNode) { - return pDDGroupNode->GetFirstChildByName(XFA_HASHCODE_Group); - } - static inline CXFA_Node* GetNextSibling(CXFA_Node* pDDGroupNode) { - return pDDGroupNode->GetNextSameNameSibling(XFA_HASHCODE_Group); - } - static inline CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) { - return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent); - } -}; -void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, - CXFA_Node* pDataDescriptionNode) { - FXSYS_assert(pDataDescriptionNode); - for (CXFA_Node* pDataChild = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pDataChild; - pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - FX_DWORD dwNameHash = pDataChild->GetNameHash(); - XFA_ELEMENT eType = pDataChild->GetClassID(); - if (!dwNameHash) { - continue; - } - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> - sIterator(pDataDescriptionNode); - for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; - pDDGroupNode = sIterator.MoveToNext()) { - if (pDDGroupNode != pDataDescriptionNode) { - if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { - continue; - } - CFX_WideString wsNamespace; - if (!pDDGroupNode->TryNamespace(wsNamespace) || - wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { - continue; - } - } - CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash); - if (!pDDNode) { - continue; - } - if (pDDNode->GetClassID() != eType) { - break; - } - pDataChild->SetDataDescriptionNode(pDDNode); - XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode); - break; - } - } -} -CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( - CXFA_Document* pDocument, - CXFA_Node* pDataParent, - XFA_ELEMENT eNodeType, - const CFX_WideStringC& wsName) { - if (!pDataParent) { - return NULL; - } - CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode(); - if (!pParentDDNode) { - CXFA_Node* pDataNode = - pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); - FXSYS_assert(pDataNode); - pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); - pDataNode->CreateXMLMappingNode(); - pDataParent->InsertChild(pDataNode); - pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - return pDataNode; - } else { - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> - sIterator(pParentDDNode); - for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; - pDDGroupNode = sIterator.MoveToNext()) { - if (pDDGroupNode != pParentDDNode) { - if (pDDGroupNode->GetClassID() != XFA_ELEMENT_DataGroup) { - continue; - } - CFX_WideString wsNamespace; - if (!pDDGroupNode->TryNamespace(wsNamespace) || - wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { - continue; - } - } - CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName); - if (!pDDNode) { - continue; - } - if (pDDNode->GetClassID() != eNodeType) { - break; - } - CXFA_Node* pDataNode = - pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); - FXSYS_assert(pDataNode); - pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); - pDataNode->CreateXMLMappingNode(); - if (eNodeType == XFA_ELEMENT_DataValue && - pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) == - XFA_ATTRIBUTEENUM_MetaData) { - pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData); - } - pDataParent->InsertChild(pDataNode); - pDataNode->SetDataDescriptionNode(pDDNode); - pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - return pDataNode; - } - return NULL; - } -} diff --git a/xfa/src/fxfa/parser/xfa_document_datadescription_imp.h b/xfa/src/fxfa/parser/xfa_document_datadescription_imp.h deleted file mode 100644 index bf0b1a45c7..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_datadescription_imp.h +++ /dev/null @@ -1,18 +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_SRC_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_ - -void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, - CXFA_Node* pDataDescriptionNode); -CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( - CXFA_Document* pDocument, - CXFA_Node* pDataParent, - XFA_ELEMENT eNodeType, - const CFX_WideStringC& wsName); - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/src/fxfa/parser/xfa_document_datamerger_imp.cpp deleted file mode 100644 index ecbbba7579..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_datamerger_imp.cpp +++ /dev/null @@ -1,1429 +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/src/fxfa/parser/xfa_document_datamerger_imp.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_datadescription_imp.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -static FX_BOOL XFA_GetOccurInfo(CXFA_Node* pOccurNode, - int32_t& iMin, - int32_t& iMax, - int32_t& iInit) { - if (!pOccurNode) { - return FALSE; - } - CXFA_Occur occur(pOccurNode); - return occur.GetOccurInfo(iMin, iMax, iInit); -} -struct XFA_DataMerge_RecurseRecord { - CXFA_Node* pTemplateChild; - CXFA_Node* pDataChild; -}; -static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild( - CXFA_Node* pValueNode, - XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { - CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pChildNode) { - if (iType == XFA_ELEMENT_UNKNOWN) { - return FALSE; - } - pChildNode = pValueNode->GetProperty(0, iType); - } - return pChildNode; -} -static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild( - CXFA_Node* pFormNode) { - CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); - FXSYS_assert(pWidgetData); - pWidgetData->GetUIType(); -} -static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent( - CXFA_Node* pValueNode, - const CFX_WideString& wsContent, - XFA_ELEMENT iType = XFA_ELEMENT_UNKNOWN) { - if (!pValueNode) { - return FALSE; - } - FXSYS_assert(pValueNode->GetPacketID() == XFA_XDPPACKET_Form); - CXFA_Node* pChildNode = - XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType); - if (!pChildNode) { - return FALSE; - } - XFA_OBJECTTYPE objectType = pChildNode->GetObjectType(); - switch (objectType) { - case XFA_OBJECTTYPE_ContentNode: { - CXFA_Node* pContentRawDataNode = - pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pContentRawDataNode) { - XFA_ELEMENT element = XFA_ELEMENT_Sharptext; - if (pChildNode->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, - FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - element = XFA_ELEMENT_SharpxHTML; - } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { - element = XFA_ELEMENT_Sharpxml; - } - } - pContentRawDataNode = pChildNode->CreateSamePacketNode(element); - pChildNode->InsertChild(pContentRawDataNode); - } - pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); - } break; - case XFA_OBJECTTYPE_NodeC: - case XFA_OBJECTTYPE_TextNode: - case XFA_OBJECTTYPE_NodeV: { - pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); - } break; - default: - FXSYS_assert(FALSE); - break; - } - return TRUE; -} -static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, - CXFA_Node* pDataNode, - FX_BOOL bDataToForm = TRUE) { - pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); - pDataNode->AddBindItem(pFormNode); - XFA_ELEMENT eClass = pFormNode->GetClassID(); - if (eClass != XFA_ELEMENT_Field && eClass != XFA_ELEMENT_ExclGroup) { - return; - } - CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); - FXSYS_assert(pWidgetData); - FX_BOOL bNotify = FALSE; - XFA_ELEMENT eUIType = pWidgetData->GetUIType(); - CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value)); - if (!bDataToForm) { - CFX_WideString wsValue; - CFX_WideString wsFormatedValue; - switch (eUIType) { - case XFA_ELEMENT_ImageEdit: { - CXFA_Image image = defValue.GetImage(); - CFX_WideString wsContentType; - CFX_WideString wsHref; - if (image) { - image.GetContent(wsValue); - image.GetContentType(wsContentType); - image.GetHref(wsHref); - } - IFDE_XMLElement* pXMLDataElement = - (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); - FXSYS_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); - } - } break; - case XFA_ELEMENT_ChoiceList: - defValue.GetChildValueContent(wsValue); - if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { - CFX_WideStringArray wsSelTextArray; - pWidgetData->GetSelectedItemsValue(wsSelTextArray); - int32_t iSize = wsSelTextArray.GetSize(); - if (iSize >= 1) { - 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->CreateXMLMappingNode(); - pDataNode->InsertChild(pValue); - pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); - } - } else { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode) - ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); - } - } else if (!wsValue.IsEmpty()) { - pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); - pDataNode->SetAttributeValue(wsValue, wsFormatedValue); - } - break; - case XFA_ELEMENT_CheckButton: - defValue.GetChildValueContent(wsValue); - if (wsValue.IsEmpty()) { - break; - } - pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); - pDataNode->SetAttributeValue(wsValue, wsFormatedValue); - break; - case XFA_ELEMENT_ExclGroup: { - CXFA_Node* pChecked = NULL; - CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pChild->GetClassID() != XFA_ELEMENT_Field) { - continue; - } - CXFA_Node* pValue = pChild->GetChild(0, XFA_ELEMENT_Value); - if (!pValue) { - continue; - } - CXFA_Value valueChild(pValue); - valueChild.GetChildValueContent(wsValue); - if (wsValue.IsEmpty()) { - continue; - } - CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); - if (!pItems) { - continue; - } - CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pText) { - continue; - } - CFX_WideString wsContent; - if (pText->TryContent(wsContent) && (wsContent == wsValue)) { - pChecked = pChild; - wsFormatedValue = wsValue; - pDataNode->SetAttributeValue(wsValue, wsFormatedValue); - pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); - break; - } - } - if (!pChecked) { - break; - } - pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pChild == pChecked) { - continue; - } - if (pChild->GetClassID() != XFA_ELEMENT_Field) { - continue; - } - CXFA_Node* pValue = pChild->GetProperty(0, XFA_ELEMENT_Value); - CXFA_Node* pItems = pChild->GetChild(0, XFA_ELEMENT_Items); - CXFA_Node* pText = - pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; - if (pText) { - pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); - } - CFX_WideString wsContent; - if (pText) { - pText->TryContent(wsContent); - } - XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, - XFA_ELEMENT_Text); - } - } break; - case XFA_ELEMENT_NumericEdit: { - defValue.GetChildValueContent(wsValue); - if (wsValue.IsEmpty()) { - break; - } - CFX_WideString wsOutput; - pWidgetData->NormalizeNumStr(wsValue, wsOutput); - wsValue = wsOutput; - pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); - pDataNode->SetAttributeValue(wsValue, wsFormatedValue); - CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value); - XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue, - XFA_ELEMENT_Float); - } break; - default: - defValue.GetChildValueContent(wsValue); - if (wsValue.IsEmpty()) { - break; - } - pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); - pDataNode->SetAttributeValue(wsValue, wsFormatedValue); - break; - } - } else { - CFX_WideString wsXMLValue; - pDataNode->TryContent(wsXMLValue); - CFX_WideString wsNormailizeValue; - pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue); - pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue); - switch (eUIType) { - case XFA_ELEMENT_ImageEdit: { - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); - CXFA_Image image = defValue.GetImage(); - if (image) { - IFDE_XMLElement* pXMLDataElement = - (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); - FXSYS_assert(pXMLDataElement); - CFX_WideString wsContentType; - CFX_WideString wsHref; - pXMLDataElement->GetString(L"xfa:contentType", wsContentType); - if (!wsContentType.IsEmpty()) { - pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); - image.SetContentType(wsContentType); - } - pXMLDataElement->GetString(L"href", wsHref); - if (!wsHref.IsEmpty()) { - image.SetHref(wsHref); - } - } - } break; - case XFA_ELEMENT_ChoiceList: - if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { - CXFA_NodeArray items; - pDataNode->GetNodeList(items); - int32_t iCounts = items.GetSize(); - if (iCounts > 0) { - wsNormailizeValue.Empty(); - CFX_WideString wsItem; - for (int32_t i = 0; i < iCounts; i++) { - items[i]->TryContent(wsItem); - wsItem = (iCounts == 1) ? wsItem : wsItem + FX_WSTRC(L"\n"); - wsNormailizeValue += wsItem; - } - CXFA_ExData exData = defValue.GetExData(); - FXSYS_assert(exData); - exData.SetContentType((iCounts == 1) ? FX_WSTRC(L"text/plain") - : FX_WSTRC(L"text/xml")); - } - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_ExData); - } else { - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); - } - break; - case XFA_ELEMENT_CheckButton: - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); - break; - case XFA_ELEMENT_ExclGroup: { - pWidgetData->SetSelectedMemberByValue(wsNormailizeValue, bNotify, FALSE, - FALSE); - } break; - case XFA_ELEMENT_DateTimeEdit: - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_DateTime); - break; - case XFA_ELEMENT_NumericEdit: { - CFX_WideString wsPicture; - pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); - if (wsPicture.IsEmpty()) { - CFX_WideString wsOutput; - pWidgetData->NormalizeNumStr(wsNormailizeValue, wsOutput); - wsNormailizeValue = wsOutput; - } - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Float); - } break; - case XFA_ELEMENT_Barcode: - case XFA_ELEMENT_Button: - case XFA_ELEMENT_PasswordEdit: - case XFA_ELEMENT_Signature: - case XFA_ELEMENT_TextEdit: - default: - XFA_DataMerge_FormValueNode_SetChildContent( - defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text); - break; - } - } -} -static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, - FX_DWORD dwNameHash) { - CXFA_Node* pNode = NULL; - pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); - return pNode; -} -static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, - FX_DWORD dwNameHash, - CXFA_Node* pDataNode) { - pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); -} -static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { - pDocument->m_rgGlobalBinding.RemoveAll(); -} -static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( - CXFA_Node* pDataScope, - FX_DWORD dwNameHash, - XFA_ELEMENT eMatchDataNodeType, - FX_BOOL bUpLevel = TRUE) { - 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 || - (eMatchDataNodeType != XFA_ELEMENT_DataModel && - pDataChild->GetClassID() != eMatchDataNodeType) || - pDataChild->HasBindItem()) { - continue; - } - return pDataChild; - } - for (CXFA_Node* pDataChild = - pCurDataScope->GetFirstChildByClass(XFA_ELEMENT_DataGroup); - pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( - XFA_ELEMENT_DataGroup)) { - CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( - pDataChild, dwNameHash, eMatchDataNodeType, FALSE); - if (pDataNode) { - return pDataNode; - } - } - if (!bUpLevel) { - break; - } - } - return NULL; -} -static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, - CFX_WideStringC wsName, - CXFA_Node* pDataScope, - XFA_ELEMENT eMatchNodeType) { - FX_DWORD dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), - 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); - } - } - return pBounded; - } - return NULL; -} -static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, - CFX_WideStringC wsName, - CXFA_Node* pDataScope, - XFA_ELEMENT eMatchNodeType) { - FX_DWORD dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), - 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; - } - } - } - return NULL; -} -static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, - CFX_WideStringC wsRef, - CXFA_Node* pDataScope, - XFA_ELEMENT eMatchNodeType, - CXFA_Node* pTemplateNode, - FX_BOOL bForceBind, - FX_BOOL bUpLevel = TRUE) { - FX_DWORD dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; - if (bUpLevel || wsRef != FX_WSTRC(L"name")) { - dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); - } - XFA_RESOLVENODE_RS rs; - pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, - pTemplateNode); - if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || - rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || - rs.nodes.GetSize() > 1) { - return pDocument->GetNotBindNode(rs.nodes); - } - if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { - CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; - CXFA_Node* pNode = ToNode(pObject); - if (!bForceBind && pNode && pNode->HasBindItem()) { - pNode = NULL; - } - return pNode; - } - return NULL; -} -CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, - XFA_ELEMENT eClassID, - FX_DWORD dwNameHash, - CXFA_Node* pFormParent) { - CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pFormChild; - pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pFormChild->GetClassID() == eClassID && - pFormChild->GetNameHash() == dwNameHash && - pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { - return pFormChild; - } - } - return NULL; -} -static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, - FX_BOOL bUseInstanceManager = TRUE) { - XFA_ELEMENT eType = pTemplateChild->GetClassID(); - if (eType == XFA_ELEMENT_Variables) { - return TRUE; - } - if (pTemplateChild->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { - return FALSE; - } - if (eType == XFA_ELEMENT_Proto || - (bUseInstanceManager && eType == XFA_ELEMENT_Occur)) { - return FALSE; - } - return TRUE; -} -CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, - CXFA_Node* pFormParent, - CXFA_Node* pTemplateNode, - FX_BOOL bRecursive, - CXFA_NodeArray* pSubformArray) { - CXFA_Node* pExistingNode = NULL; - if (pSubformArray == NULL) { - pExistingNode = XFA_DataMerge_FindFormDOMInstance( - pDocument, pTemplateNode->GetClassID(), pTemplateNode->GetNameHash(), - pFormParent); - } else if (pSubformArray->GetSize() > 0) { - pExistingNode = pSubformArray->GetAt(0); - pSubformArray->RemoveAt(0); - } - if (pExistingNode) { - if (pSubformArray) { - pFormParent->InsertChild(pExistingNode); - } else if (pExistingNode->IsContainerNode()) { - pFormParent->RemoveChild(pExistingNode); - pFormParent->InsertChild(pExistingNode); - } - pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - pExistingNode->SetTemplateNode(pTemplateNode); - if (bRecursive && pExistingNode->GetClassID() != XFA_ELEMENT_Items) { - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, - pTemplateChild, bRecursive); - } - } - } - pExistingNode->SetFlag(XFA_NODEFLAG_Initialized); - return pExistingNode; - } - CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE); - pFormParent->InsertChild(pNewNode, NULL); - if (bRecursive) { - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild)) { - CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE); - pNewNode->InsertChild(pNewChild, NULL); - } - } - } - return pNewNode; -} -static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( - CXFA_Document* pDocument, - CXFA_Node* pFormParent, - CXFA_Node* pTemplateNode, - CXFA_NodeArray& subforms) { - CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); - CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; - FX_DWORD dwInstNameHash = - FX_HashCode_String_GetW(wsInstMgrNodeName, wsInstMgrNodeName.GetLength()); - CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( - pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); - if (pExistingNode) { - FX_DWORD dwNameHash = pTemplateNode->GetNameHash(); - for (CXFA_Node* pNode = - pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pNode;) { - XFA_ELEMENT eCurType = pNode->GetClassID(); - if (eCurType == XFA_ELEMENT_InstanceManager) { - break; - } - if ((eCurType != XFA_ELEMENT_Subform) && - (eCurType != XFA_ELEMENT_SubformSet)) { - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - continue; - } - if (dwNameHash != pNode->GetNameHash()) { - break; - } - CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pFormParent->RemoveChild(pNode); - subforms.Add(pNode); - pNode = pNextNode; - } - pFormParent->RemoveChild(pExistingNode); - pFormParent->InsertChild(pExistingNode); - pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - pExistingNode->SetTemplateNode(pTemplateNode); - return pExistingNode; - } - CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( - XFA_XDPPACKET_Form, XFA_ELEMENT_InstanceManager); - FXSYS_assert(pNewNode); - wsInstMgrNodeName = - FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); - pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); - pFormParent->InsertChild(pNewNode, NULL); - pNewNode->SetTemplateNode(pTemplateNode); - return pNewNode; -} -static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( - CXFA_Document* pDocument, - CXFA_Node* pTemplateNode, - CXFA_Node* pDataScope, - FX_BOOL& bAccessedDataDOM, - FX_BOOL bForceBind, - CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode>* - pIterator, - FX_BOOL& bSelfMatch, - XFA_ATTRIBUTEENUM& eBindMatch, - FX_BOOL bUpLevel = TRUE) { - FX_BOOL bOwnIterator = FALSE; - if (!pIterator) { - bOwnIterator = TRUE; - pIterator = new CXFA_NodeIteratorTemplate< - CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); - } - CXFA_Node* pResult = NULL; - for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); - pCurTemplateNode;) { - XFA_ELEMENT eMatchNodeType; - switch (pCurTemplateNode->GetClassID()) { - case XFA_ELEMENT_Subform: - eMatchNodeType = XFA_ELEMENT_DataGroup; - break; - case XFA_ELEMENT_Field: { - eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) - ? XFA_ELEMENT_DataGroup - : XFA_ELEMENT_DataValue; - } break; - case XFA_ELEMENT_ExclGroup: - eMatchNodeType = XFA_ELEMENT_DataValue; - break; - default: - pCurTemplateNode = pIterator->MoveToNext(); - continue; - } - CXFA_Node* pTemplateNodeOccur = - pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur); - int32_t iMin, iMax, iInit; - if (pTemplateNodeOccur && - XFA_GetOccurInfo(pTemplateNodeOccur, iMin, iMax, iInit) && iMax == 0) { - pCurTemplateNode = pIterator->MoveToNext(); - continue; - } - CXFA_Node* pTemplateNodeBind = - pCurTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind); - XFA_ATTRIBUTEENUM eMatch = - pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) - : XFA_ATTRIBUTEENUM_Once; - eBindMatch = eMatch; - switch (eMatch) { - case XFA_ATTRIBUTEENUM_None: - pCurTemplateNode = pIterator->MoveToNext(); - continue; - case XFA_ATTRIBUTEENUM_Global: - bAccessedDataDOM = TRUE; - if (!bForceBind) { - pCurTemplateNode = pIterator->MoveToNext(); - continue; - } - if (eMatchNodeType == XFA_ELEMENT_DataValue || - (eMatchNodeType == XFA_ELEMENT_DataGroup && - XFA_FieldIsMultiListBox(pTemplateNodeBind))) { - CXFA_Node* pGlobalBindNode = XFA_DataMerge_FindGlobalDataNode( - pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), - pDataScope, eMatchNodeType); - if (!pGlobalBindNode) { - pCurTemplateNode = pIterator->MoveToNext(); - continue; - } - pResult = pGlobalBindNode; - break; - } - case XFA_ATTRIBUTEENUM_Once: { - bAccessedDataDOM = TRUE; - CXFA_Node* pOnceBindNode = XFA_DataMerge_FindOnceDataNode( - pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), - pDataScope, eMatchNodeType); - if (!pOnceBindNode) { - pCurTemplateNode = pIterator->MoveToNext(); - continue; - } - pResult = pOnceBindNode; - } break; - case XFA_ATTRIBUTEENUM_DataRef: { - bAccessedDataDOM = TRUE; - CXFA_Node* pDataRefBindNode = XFA_DataMerge_FindDataRefDataNode( - pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref), - pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel); - if (pDataRefBindNode && - pDataRefBindNode->GetClassID() == eMatchNodeType) { - pResult = pDataRefBindNode; - } - if (!pResult) { - pCurTemplateNode = pIterator->SkipChildrenAndMoveToNext(); - continue; - } - } break; - default: - break; - } - if (pCurTemplateNode == pTemplateNode && pResult) { - bSelfMatch = TRUE; - } - break; - } - if (bOwnIterator) { - delete pIterator; - } - return pResult; -} -static void XFA_DataMerge_SortRecurseRecord( - CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord>& rgRecords, - CXFA_Node* pDataScope, - FX_BOOL bChoiceMode = FALSE) { - int32_t iCount = rgRecords.GetSize(); - CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgResultRecord; - for (CXFA_Node* pChildNode = pDataScope->GetNodeItem(XFA_NODEITEM_FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - for (int32_t i = 0; i < iCount; i++) { - CXFA_Node* pNode = rgRecords[i].pDataChild; - if (pChildNode == pNode) { - XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, - pNode}; - rgResultRecord.Add(sNewRecord); - rgRecords.RemoveAt(i); - iCount--; - break; - } - } - if (bChoiceMode && rgResultRecord.GetSize() > 0) { - break; - } - } - if (rgResultRecord.GetSize() > 0) { - if (!bChoiceMode) { - for (int32_t i = 0; i < iCount; i++) { - XFA_DataMerge_RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, - rgRecords[i].pDataChild}; - rgResultRecord.Add(sNewRecord); - } - } - rgRecords.RemoveAll(); - rgRecords.Copy(rgResultRecord); - } -} -static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( - CXFA_Document* pDocument, - CXFA_Node* pTemplateNode, - CXFA_Node* pFormParentNode, - CXFA_Node* pDataScope, - FX_BOOL bOneInstance, - FX_BOOL bDataMerge) { - XFA_ELEMENT eElement = pTemplateNode->GetClassID(); - CXFA_Node* pOccurNode = NULL; - CXFA_Node* pFirstInstance = NULL; - FX_BOOL bUseInstanceManager = - pFormParentNode->GetClassID() != XFA_ELEMENT_Area; - CXFA_Node* pInstMgrNode = NULL; - CXFA_NodeArray subformArray; - CXFA_NodeArray* pSearchArray = NULL; - if (!bOneInstance && - (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Subform)) { - pInstMgrNode = - bUseInstanceManager - ? XFA_NodeMerge_CloneOrMergeInstanceManager( - pDocument, pFormParentNode, pTemplateNode, subformArray) - : NULL; - if (CXFA_Node* pOccurTemplateNode = - pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Occur)) { - pOccurNode = pInstMgrNode - ? XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) - : pOccurTemplateNode; - } else if (pInstMgrNode) { - pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_ELEMENT_Occur); - if (pOccurNode) { - pOccurNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - } - } - if (pInstMgrNode) { - pInstMgrNode->SetFlag(XFA_NODEFLAG_Initialized); - pSearchArray = &subformArray; - if (pFormParentNode->GetClassID() == XFA_ELEMENT_PageArea) { - bOneInstance = TRUE; - if (subformArray.GetSize() < 1) { - pSearchArray = NULL; - } - } else if ((pTemplateNode->GetNameHash() == 0) && - (subformArray.GetSize() < 1)) { - pSearchArray = NULL; - } - } - } - int32_t iMax = 1, iInit = 1, iMin = 1; - if (!bOneInstance) { - XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); - } - XFA_ATTRIBUTEENUM eRelation = - eElement == XFA_ELEMENT_SubformSet - ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) - : XFA_ATTRIBUTEENUM_Ordered; - int32_t iCurRepeatIndex = 0; - XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None; - if (bDataMerge) { - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> - sNodeIterator(pTemplateNode); - FX_BOOL bAccessedDataDOM = FALSE; - if (eElement == XFA_ELEMENT_SubformSet || eElement == XFA_ELEMENT_Area) { - sNodeIterator.MoveToNext(); - } else { - CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; - CXFA_NodeArray subformArray; - for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { - FX_BOOL bSelfMatch = FALSE; - XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; - CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( - pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, - &sNodeIterator, bSelfMatch, eBindMatch); - if (!pDataNode || sNodeIterator.GetCurrent() != pTemplateNode) { - break; - } - eParentBindMatch = eBindMatch; - CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); - if (!pFirstInstance) { - pFirstInstance = pSubformNode; - } - XFA_DataMerge_CreateDataBinding(pSubformNode, pDataNode); - FXSYS_assert(pSubformNode); - subformMapArray.SetAt(pSubformNode, pDataNode); - subformArray.Add(pSubformNode); - } - subformMapArray.GetStartPosition(); - for (int32_t iIndex = 0; iIndex < subformArray.GetSize(); iIndex++) { - CXFA_Node* pSubform = subformArray[iIndex]; - CXFA_Node* pDataNode = - reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform)); - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubform, - pTemplateChild, TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - pDocument->DataMerge_CopyContainer(pTemplateChild, pSubform, - pDataNode, FALSE, TRUE, FALSE); - } - } - } - subformMapArray.RemoveAll(); - } - for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { - FX_BOOL bSelfMatch = FALSE; - XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; - if (!XFA_DataMerge_FindMatchingDataNode( - pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, - &sNodeIterator, bSelfMatch, eBindMatch)) { - break; - } - if (eBindMatch == XFA_ATTRIBUTEENUM_DataRef && - eParentBindMatch == XFA_ATTRIBUTEENUM_DataRef) { - break; - } - if (eRelation == XFA_ATTRIBUTEENUM_Choice || - eRelation == XFA_ATTRIBUTEENUM_Unordered) { - CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); - FXSYS_assert(pSubformSetNode); - if (!pFirstInstance) { - pFirstInstance = pSubformSetNode; - } - CFX_ArrayTemplate<XFA_DataMerge_RecurseRecord> rgItemMatchList; - CFX_ArrayTemplate<CXFA_Node*> rgItemUnmatchList; - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, - pTemplateChild, TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - CXFA_Node* pDataMatch; - bSelfMatch = FALSE; - eBindMatch = XFA_ATTRIBUTEENUM_None; - if (eRelation != XFA_ATTRIBUTEENUM_Ordered && - (pDataMatch = XFA_DataMerge_FindMatchingDataNode( - pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, - FALSE, NULL, bSelfMatch, eBindMatch))) { - XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild, - pDataMatch}; - if (bSelfMatch) { - rgItemMatchList.InsertAt(0, sNewRecord); - } else { - rgItemMatchList.Add(sNewRecord); - } - } else { - rgItemUnmatchList.Add(pTemplateChild); - } - } - } - switch (eRelation) { - case XFA_ATTRIBUTEENUM_Choice: { - FXSYS_assert(rgItemMatchList.GetSize()); - XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope, TRUE); - pDocument->DataMerge_CopyContainer( - rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope); - } break; - case XFA_ATTRIBUTEENUM_Unordered: { - if (rgItemMatchList.GetSize()) { - XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope); - for (int32_t i = 0, count = rgItemMatchList.GetSize(); i < count; - i++) { - pDocument->DataMerge_CopyContainer( - rgItemMatchList[i].pTemplateChild, pSubformSetNode, - pDataScope); - } - } - for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count; - i++) { - pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i], - pSubformSetNode, pDataScope); - } - } break; - default: - break; - } - } else { - CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); - FXSYS_assert(pSubformSetNode); - if (!pFirstInstance) { - pFirstInstance = pSubformSetNode; - } - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, - pTemplateChild, TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, - pDataScope); - } - } - } - } - if (iCurRepeatIndex == 0 && bAccessedDataDOM == FALSE) { - int32_t iLimit = iMax; - if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) { - iLimit = subformArray.GetSize(); - if (iLimit < iMin) { - iLimit = iInit; - } - } - for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) { - if (pInstMgrNode) { - if (pSearchArray && pSearchArray->GetSize() < 1) { - if (pTemplateNode->GetNameHash() != 0) { - break; - } - pSearchArray = NULL; - } - } else if (!XFA_DataMerge_FindFormDOMInstance( - pDocument, pTemplateNode->GetClassID(), - pTemplateNode->GetNameHash(), pFormParentNode)) { - break; - } - CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); - FXSYS_assert(pSubformNode); - if (!pFirstInstance) { - pFirstInstance = pSubformNode; - } - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformNode, - pTemplateChild, TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode, - pDataScope); - } - } - } - } - } - int32_t iMinimalLimit = iCurRepeatIndex == 0 ? iInit : iMin; - for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) { - CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); - FXSYS_assert(pSubformSetNode); - if (!pFirstInstance) { - pFirstInstance = pSubformSetNode; - } - FX_BOOL bFound = FALSE; - for (CXFA_Node* pTemplateChild = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, - pTemplateChild, TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - if (bFound && eRelation == XFA_ATTRIBUTEENUM_Choice) { - continue; - } - pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, - pDataScope, FALSE, bDataMerge); - bFound = TRUE; - } - } - } - return pFirstInstance; -} -static CXFA_Node* XFA_DataMerge_CopyContainer_Field(CXFA_Document* pDocument, - CXFA_Node* pTemplateNode, - CXFA_Node* pFormNode, - CXFA_Node* pDataScope, - FX_BOOL bDataMerge, - FX_BOOL bUpLevel = TRUE) { - CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pFormNode, pTemplateNode, FALSE); - FXSYS_assert(pFieldNode); - for (CXFA_Node* pTemplateChildNode = - pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChildNode)) { - XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, - pTemplateChildNode, TRUE); - } else if (pTemplateNode->GetClassID() == XFA_ELEMENT_ExclGroup && - pTemplateChildNode->IsContainerNode()) { - if (pTemplateChildNode->GetClassID() == XFA_ELEMENT_Field) { - XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, - pFieldNode, NULL, FALSE); - } - } - } - if (bDataMerge) { - FX_BOOL bAccessedDataDOM = FALSE; - FX_BOOL bSelfMatch = FALSE; - XFA_ATTRIBUTEENUM eBindMatch; - CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( - pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL, - bSelfMatch, eBindMatch, bUpLevel); - if (pDataNode) { - XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); - } - } else { - XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); - } - return pFieldNode; -} -CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, - CXFA_Node* pFormNode, - CXFA_Node* pDataScope, - FX_BOOL bOneInstance, - FX_BOOL bDataMerge, - FX_BOOL bUpLevel) { - switch (pTemplateNode->GetClassID()) { - case XFA_ELEMENT_SubformSet: - case XFA_ELEMENT_Subform: - case XFA_ELEMENT_Area: - case XFA_ELEMENT_PageArea: - return XFA_DataMerge_CopyContainer_SubformSet( - this, pTemplateNode, pFormNode, pDataScope, bOneInstance, bDataMerge); - case XFA_ELEMENT_ExclGroup: - case XFA_ELEMENT_Field: - case XFA_ELEMENT_Draw: - case XFA_ELEMENT_ContentArea: - return XFA_DataMerge_CopyContainer_Field( - this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); - case XFA_ELEMENT_PageSet: - break; - case XFA_ELEMENT_Variables: - break; - default: - FXSYS_assert(FALSE); - break; - } - return NULL; -} - -static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, - CXFA_Node* pFormNode, - CXFA_Node* pDataScope, - FX_BOOL bDataRef, - FX_BOOL bParentDataRef) { - FX_BOOL bMatchRef = TRUE; - XFA_ELEMENT eClassID = pFormNode->GetClassID(); - CXFA_Node* pDataNode = pFormNode->GetBindData(); - if (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup || - eClassID == XFA_ELEMENT_Field) { - CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); - CXFA_Node* pTemplateNodeBind = - pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Bind) - : NULL; - XFA_ATTRIBUTEENUM eMatch = - pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) - : XFA_ATTRIBUTEENUM_Once; - switch (eMatch) { - case XFA_ATTRIBUTEENUM_None: - if (!bDataRef || bParentDataRef) { - XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); - } - break; - case XFA_ATTRIBUTEENUM_Once: - if (!bDataRef || bParentDataRef) { - if (!pDataNode) { - if (pFormNode->GetNameHash() != 0 && - pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != - XFA_ATTRIBUTEENUM_None) { - XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || - XFA_FieldIsMultiListBox(pFormNode)) - ? XFA_ELEMENT_DataGroup - : XFA_ELEMENT_DataValue; - pDataNode = XFA_DataDescription_MaybeCreateDataNode( - pDocument, pDataScope, eDataNodeType, - pFormNode->GetCData(XFA_ATTRIBUTE_Name)); - if (pDataNode) { - XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); - } - } - if (!pDataNode) { - XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); - } - } else { - CXFA_Node* pDataParent = - pDataNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pDataParent != pDataScope) { - FXSYS_assert(pDataParent); - pDataParent->RemoveChild(pDataNode); - pDataScope->InsertChild(pDataNode); - } - } - } - break; - case XFA_ATTRIBUTEENUM_Global: - if (!bDataRef || bParentDataRef) { - FX_DWORD dwNameHash = pFormNode->GetNameHash(); - if (dwNameHash != 0 && !pDataNode) { - pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); - if (!pDataNode) { - XFA_ELEMENT eDataNodeType = (eClassID == XFA_ELEMENT_Subform || - XFA_FieldIsMultiListBox(pFormNode)) - ? XFA_ELEMENT_DataGroup - : XFA_ELEMENT_DataValue; - CXFA_Node* pRecordNode = - ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); - pDataNode = XFA_DataDescription_MaybeCreateDataNode( - pDocument, pRecordNode, eDataNodeType, - pFormNode->GetCData(XFA_ATTRIBUTE_Name)); - if (pDataNode) { - XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE); - XFA_DataMerge_RegisterGlobalBinding( - pDocument, pFormNode->GetNameHash(), pDataNode); - } - } else { - XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode); - } - } - if (!pDataNode) { - XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); - } - } - break; - case XFA_ATTRIBUTEENUM_DataRef: { - bMatchRef = bDataRef; - bParentDataRef = TRUE; - if (!pDataNode && bDataRef) { - CFX_WideStringC wsRef = - pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref); - FX_DWORD dFlags = - XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode; - XFA_RESOLVENODE_RS rs; - pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, - dFlags, pTemplateNode); - CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; - pDataNode = ToNode(pObject); - if (pDataNode) { - XFA_DataMerge_CreateDataBinding( - pFormNode, pDataNode, - rs.dwFlags == XFA_RESOVENODE_RSTYPE_ExistNodes); - } else { - XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); - } - } - } break; - default: - break; - } - } - if (bMatchRef && - (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_SubformSet || - eClassID == XFA_ELEMENT_Area || eClassID == XFA_ELEMENT_PageArea || - eClassID == XFA_ELEMENT_PageSet)) { - for (CXFA_Node* pFormChild = - pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pFormChild; - pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pFormChild->GetObjectType() != XFA_OBJECTTYPE_ContainerNode) { - continue; - } - if (pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { - continue; - } - XFA_DataMerge_UpdateBindingRelations(pDocument, pFormChild, - pDataNode ? pDataNode : pDataScope, - bDataRef, bParentDataRef); - } - } -} -CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode) { - for (CXFA_Node* pRootBoundNode = pParentFormNode; - pRootBoundNode && - pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; - pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { - CXFA_Node* pDataScope = pRootBoundNode->GetBindData(); - if (pDataScope) { - return pDataScope; - } - } - return ToNode( - pParentFormNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Data)); -} -void CXFA_Document::DataMerge_UpdateBindingRelations( - CXFA_Node* pFormUpdateRoot) { - CXFA_Node* pDataScope = XFA_DataMerge_FindDataScope( - pFormUpdateRoot->GetNodeItem(XFA_NODEITEM_Parent)); - if (!pDataScope) { - return; - } - XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, FALSE, - FALSE); - XFA_DataMerge_UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, TRUE, - FALSE); -} -CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) { - for (int32_t i = 0; i < arrayNodes.GetSize(); i++) { - CXFA_Node* pNode = arrayNodes[i]->AsNode(); - if (pNode && !pNode->HasBindItem()) - return pNode; - } - return nullptr; -} -void CXFA_Document::DoDataMerge() { - CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDatasetsRoot) { - IFDE_XMLElement* pDatasetsXMLNode = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:datasets")); - FXSYS_assert(pDatasetsXMLNode); - pDatasetsXMLNode->SetString( - FX_WSTRC(L"xmlns:xfa"), - FX_WSTRC(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")); - m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); - m_pRootNode->InsertChild(pDatasetsRoot); - pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); - } - CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL; - CFX_WideString wsDatasetsURI; - pDatasetsRoot->TryNamespace(wsDatasetsURI); - for (CXFA_Node* pChildNode = - pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pChildNode->GetClassID() != XFA_ELEMENT_DataGroup) { - continue; - } - CFX_WideString wsNamespaceURI; - if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { - if (!pChildNode->TryNamespace(wsNamespaceURI)) { - continue; - } - if (wsNamespaceURI == - FX_WSTRC(L"http://ns.adobe.com/data-description/")) { - pDDRoot = pChildNode; - } - } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { - if (!pChildNode->TryNamespace(wsNamespaceURI)) { - continue; - } - if (wsNamespaceURI == wsDatasetsURI) { - pDataRoot = pChildNode; - } - } - if (pDataRoot && pDDRoot) { - break; - } - } - if (!pDataRoot) { - IFDE_XMLElement* pDataRootXMLNode = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); - FXSYS_assert(pDataRootXMLNode); - pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); - pDataRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"data")); - pDataRoot->SetXMLMappingNode(pDataRootXMLNode); - pDatasetsRoot->InsertChild(pDataRoot); - } - CXFA_Node* pDataTopLevel = - pDataRoot->GetFirstChildByClass(XFA_ELEMENT_DataGroup); - FX_DWORD dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; - CXFA_Node* pTemplateRoot = - m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); - if (!pTemplateRoot) { - return; - } - CXFA_Node* pTemplateChosen = - dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL; - if (!pTemplateChosen || - pTemplateChosen->GetClassID() != XFA_ELEMENT_Subform) { - pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform); - } - if (!pTemplateChosen) { - return; - } - CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Form); - FX_BOOL bEmptyForm = FALSE; - if (!pFormRoot) { - bEmptyForm = TRUE; - pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); - FXSYS_assert(pFormRoot); - pFormRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(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); - } - } - CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( - this, pFormRoot, pTemplateChosen, FALSE); - FXSYS_assert(pSubformSetNode); - if (!pDataTopLevel) { - CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); - CFX_WideString wsDataTopLevelName = - wsFormName.IsEmpty() ? FX_WSTRC(L"form") : wsFormName; - IFDE_XMLElement* pDataTopLevelXMLNode = - IFDE_XMLElement::Create(wsDataTopLevelName); - FXSYS_assert(pDataTopLevelXMLNode); - pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); - pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); - pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); - CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - pDataRoot->InsertChild(pDataTopLevel, pBeforeNode); - } - FXSYS_assert(pDataTopLevel); - XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel); - for (CXFA_Node* pTemplateChild = - pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; - pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (XFA_NeedGenerateForm(pTemplateChild)) { - XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild, - TRUE); - } else if (pTemplateChild->GetObjectType() == - XFA_OBJECTTYPE_ContainerNode) { - DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel); - } - } - if (pDDRoot) { - XFA_DataDescription_UpdateDataRelation(pDataRoot, pDDRoot); - } - DataMerge_UpdateBindingRelations(pSubformSetNode); - CXFA_Node* pPageSetNode = - pSubformSetNode->GetFirstChildByClass(XFA_ELEMENT_PageSet); - while (pPageSetNode) { - m_pPendingPageSet.Add(pPageSetNode); - CXFA_Node* pNextPageSetNode = - pPageSetNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet); - pSubformSetNode->RemoveChild(pPageSetNode); - pPageSetNode = pNextPageSetNode; - } - if (!bEmptyForm) { - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> - sIterator(pFormRoot); - CXFA_Node* pNode = sIterator.MoveToNext(); - while (pNode) { - if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { - if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode || - pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { - CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); - pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); - pNode = pNext; - } else { - pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - pNode->SetFlag(XFA_NODEFLAG_Initialized); - pNode = sIterator.MoveToNext(); - } - } else { - pNode->SetFlag(XFA_NODEFLAG_Initialized); - pNode = sIterator.MoveToNext(); - } - } - } -} -void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) { - CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form)); - if (pFormRoot) { - while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { - pFormRoot->RemoveChild(pNode); - } - pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - } - XFA_DataMerge_ClearGlobalBinding(this); - if (bDoDataMerge) { - DoDataMerge(); - } - CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); - pLayoutProcessor->SetForceReLayout(TRUE); -} diff --git a/xfa/src/fxfa/parser/xfa_document_datamerger_imp.h b/xfa/src/fxfa/parser/xfa_document_datamerger_imp.h deleted file mode 100644 index 57ac6385b1..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_datamerger_imp.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_SRC_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_ - -#include "xfa/src/fxfa/parser/xfa_object.h" - -CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer( - CXFA_Document* pDocument, - CXFA_Node* pFormParent, - CXFA_Node* pTemplateNode, - FX_BOOL bRecursive, - CXFA_NodeArray* pSubformArray = NULL); -CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode); -CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, - XFA_ELEMENT eClassID, - FX_DWORD dwNameHash, - CXFA_Node* pFormParent); - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_document_imp.cpp b/xfa/src/fxfa/parser/xfa_document_imp.cpp deleted file mode 100644 index 980b4e4a3e..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_imp.cpp +++ /dev/null @@ -1,441 +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/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_script_datawindow.h" -#include "xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_logpseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_Document::CXFA_Document(IXFA_DocParser* pParser) - : m_pParser(pParser), - m_pScriptContext(nullptr), - m_pLayoutProcessor(nullptr), - m_pRootNode(nullptr), - m_pLocalMgr(nullptr), - m_pScriptDataWindow(nullptr), - m_pScriptEvent(nullptr), - m_pScriptHost(nullptr), - m_pScriptLog(nullptr), - m_pScriptLayout(nullptr), - m_pScriptSignature(nullptr), - m_eCurVersionMode(XFA_VERSION_DEFAULT), - m_dwDocFlags(0) { - ASSERT(m_pParser); -} -CXFA_Document::~CXFA_Document() { - delete m_pRootNode; - PurgeNodes(); -} -void CXFA_Document::ClearLayoutData() { - if (m_pLayoutProcessor) { - delete m_pLayoutProcessor; - m_pLayoutProcessor = NULL; - } - 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; - } -} -void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { - if (m_pRootNode) { - AddPurgeNode(m_pRootNode); - } - m_pRootNode = pNewRoot; - RemovePurgeNode(pNewRoot); -} -IXFA_Notify* CXFA_Document::GetNotify() const { - return m_pParser->GetNotify(); -} -CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { - return GetXFAObject( - FX_HashCode_String_GetW(wsNodeName.GetPtr(), wsNodeName.GetLength())); -} -CXFA_Object* CXFA_Document::GetXFAObject(FX_DWORD dwNodeNameHash) { - switch (dwNodeNameHash) { - case XFA_HASHCODE_Data: { - CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDatasetsNode) { - return NULL; - } - for (CXFA_Node* pDatasetsChild = - pDatasetsNode->GetFirstChildByClass(XFA_ELEMENT_DataGroup); - pDatasetsChild; - pDatasetsChild = - pDatasetsChild->GetNextSameClassSibling(XFA_ELEMENT_DataGroup)) { - if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) { - continue; - } - CFX_WideString wsNamespaceURI; - if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) { - continue; - } - CFX_WideString wsDatasetsURI; - if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) { - continue; - } - if (wsNamespaceURI == wsDatasetsURI) { - return pDatasetsChild; - } - } - } - return NULL; - case XFA_HASHCODE_Record: { - CXFA_Node* pData = ToNode(GetXFAObject(XFA_HASHCODE_Data)); - return pData ? pData->GetFirstChildByClass(XFA_ELEMENT_DataGroup) : NULL; - } - case XFA_HASHCODE_DataWindow: { - if (m_pScriptDataWindow == NULL) { - m_pScriptDataWindow = new CScript_DataWindow(this); - } - return m_pScriptDataWindow; - } - case XFA_HASHCODE_Event: { - if (m_pScriptEvent == NULL) { - m_pScriptEvent = new CScript_EventPseudoModel(this); - } - return m_pScriptEvent; - } - case XFA_HASHCODE_Host: { - if (m_pScriptHost == NULL) { - m_pScriptHost = new CScript_HostPseudoModel(this); - } - return m_pScriptHost; - } - case XFA_HASHCODE_Log: { - if (m_pScriptLog == NULL) { - m_pScriptLog = new CScript_LogPseudoModel(this); - } - return m_pScriptLog; - } - case XFA_HASHCODE_Signature: { - if (m_pScriptSignature == NULL) { - m_pScriptSignature = new CScript_SignaturePseudoModel(this); - } - return m_pScriptSignature; - } - case XFA_HASHCODE_Layout: { - if (m_pScriptLayout == NULL) { - m_pScriptLayout = new CScript_LayoutPseudoModel(this); - } - return m_pScriptLayout; - } - default: - return m_pRootNode->GetFirstChildByName(dwNodeNameHash); - } -} -CXFA_Node* CXFA_Document::CreateNode(FX_DWORD 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; - } - 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); - } - return pNode; - } - return NULL; -} -void CXFA_Document::AddPurgeNode(CXFA_Node* pNode) { - m_rgPurgeNodes.Add(pNode); -} -FX_BOOL CXFA_Document::RemovePurgeNode(CXFA_Node* pNode) { - return m_rgPurgeNodes.RemoveKey(pNode); -} -void CXFA_Document::PurgeNodes() { - FX_POSITION psNode = m_rgPurgeNodes.GetStartPosition(); - while (psNode) { - CXFA_Node* pNode; - m_rgPurgeNodes.GetNextAssoc(psNode, pNode); - delete pNode; - } - m_rgPurgeNodes.RemoveAll(); -} -void CXFA_Document::SetFlag(FX_DWORD dwFlag, FX_BOOL bOn) { - if (bOn) { - m_dwDocFlags |= dwFlag; - } else { - m_dwDocFlags &= ~dwFlag; - } -} -FX_BOOL CXFA_Document::IsInteractive() { - if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) { - return m_dwDocFlags & XFA_DOCFLAG_Interactive; - } - CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config)); - if (!pConfig) { - return FALSE; - } - CFX_WideString wsInteractive; - CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_ELEMENT_Present); - if (!pPresent) { - return FALSE; - } - CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_ELEMENT_Pdf); - if (!pPDF) { - return FALSE; - } - CXFA_Node* pInteractive = pPDF->GetChild(0, XFA_ELEMENT_Interactive); - if (pInteractive) { - m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; - if (pInteractive->TryContent(wsInteractive) && - wsInteractive == FX_WSTRC(L"1")) { - m_dwDocFlags |= XFA_DOCFLAG_Interactive; - return TRUE; - } - } - return FALSE; -} -CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { - if (!m_pLocalMgr) { - CFX_WideString wsLanguage; - GetParser()->GetNotify()->GetAppProvider()->GetLanguage(wsLanguage); - m_pLocalMgr = new CXFA_LocaleMgr( - ToNode(GetXFAObject(XFA_HASHCODE_LocaleSet)), wsLanguage); - } - return m_pLocalMgr; -} -IXFA_ScriptContext* CXFA_Document::InitScriptContext(FXJSE_HRUNTIME hRuntime) { - if (!m_pScriptContext) { - m_pScriptContext = XFA_ScriptContext_Create(this); - } - m_pScriptContext->Initialize(hRuntime); - return m_pScriptContext; -} -IXFA_ScriptContext* CXFA_Document::GetScriptContext() { - if (!m_pScriptContext) { - m_pScriptContext = XFA_ScriptContext_Create(this); - } - return m_pScriptContext; -} -XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( - CFX_WideString& wsTemplateNS) { - CFX_WideStringC wsTemplateURIPrefix = - XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI; - FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength(); - if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) != - wsTemplateURIPrefix) { - return XFA_VERSION_UNKNOWN; - } - FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength); - if (nDotPos == (FX_STRSIZE)-1) { - return XFA_VERSION_UNKNOWN; - } - int8_t iMajor = - FXSYS_wtoi(wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength)); - int8_t iMinor = FXSYS_wtoi( - wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2)); - XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor); - if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) { - return XFA_VERSION_UNKNOWN; - } - m_eCurVersionMode = eVersion; - return eVersion; -} -CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, - const CFX_WideStringC& wsID) { - if (!pRoot || wsID.IsEmpty()) { - return NULL; - } - CXFA_NodeIterator sIterator(pRoot); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - CFX_WideStringC wsIDVal; - if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { - if (wsIDVal == wsID) { - return pNode; - } - } - } - return NULL; -} -static void XFA_ProtoMerge_MergeNodeRecurse(CXFA_Document* pDocument, - CXFA_Node* pDestNodeParent, - CXFA_Node* pProtoNode) { - CXFA_Node* pExistingNode = NULL; - for (CXFA_Node* pFormChild = - pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild); - pFormChild; - pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pFormChild->GetClassID() == pProtoNode->GetClassID() && - pFormChild->GetNameHash() == pProtoNode->GetNameHash() && - pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { - pFormChild->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - pExistingNode = pFormChild; - break; - } - } - if (pExistingNode) { - pExistingNode->SetTemplateNode(pProtoNode); - for (CXFA_Node* pTemplateChild = - pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - XFA_ProtoMerge_MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild); - } - return; - } - CXFA_Node* pNewNode = pProtoNode->Clone(TRUE); - pNewNode->SetTemplateNode(pProtoNode); - pDestNodeParent->InsertChild(pNewNode, NULL); -} -static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument, - CXFA_Node* pDestNode, - CXFA_Node* pProtoNode) { - { - CXFA_NodeIterator sIterator(pDestNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - pNode->SetFlag(XFA_NODEFLAG_UnusedNode); - } - } - pDestNode->SetTemplateNode(pProtoNode); - for (CXFA_Node* pTemplateChild = - pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; - pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ProtoMerge_MergeNodeRecurse(pDocument, pDestNode, pTemplateChild); - } - { - CXFA_NodeIterator sIterator(pDestNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - } - } -} -void CXFA_Document::DoProtoMerge() { - CXFA_Node* pTemplateRoot = ToNode(GetXFAObject(XFA_HASHCODE_Template)); - if (!pTemplateRoot) { - return; - } - CFX_MapPtrTemplate<FX_DWORD, CXFA_Node*> mIDMap; - CXFA_NodeSet sUseNodes; - CXFA_NodeIterator sIterator(pTemplateRoot); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - CFX_WideStringC wsIDVal; - if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { - mIDMap[FX_HashCode_String_GetW(wsIDVal.GetPtr(), wsIDVal.GetLength())] = - pNode; - } - CFX_WideStringC wsUseVal; - if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) { - sUseNodes.Add(pNode); - } else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) && - !wsUseVal.IsEmpty()) { - sUseNodes.Add(pNode); - } - } - FX_POSITION pos = sUseNodes.GetStartPosition(); - while (pos) { - CXFA_Node* pUseHrefNode = NULL; - sUseNodes.GetNextAssoc(pos, pUseHrefNode); - 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; - } else { - wsURI = CFX_WideStringC((const FX_WCHAR*)wsUseVal, uSharpPos); - FX_STRSIZE uLen = wsUseVal.GetLength(); - if (uLen >= uSharpPos + 5 && - CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos, 5) == - FX_WSTRC(L"#som(") && - wsUseVal[uLen - 1] == ')') { - wsSOM = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 5, - uLen - 1 - uSharpPos - 5); - } else { - wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + 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); - } else { - wsSOM = - CFX_WideStringC((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength()); - } - } - if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) { - continue; - } - CXFA_Node* pProtoNode = NULL; - if (!wsSOM.IsEmpty()) { - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | - XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM, - resoveNodeRS, dwFlag); - if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { - pProtoNode = resoveNodeRS.nodes[0]->AsNode(); - } - } else if (!wsID.IsEmpty()) { - if (!mIDMap.Lookup( - FX_HashCode_String_GetW(wsID.GetPtr(), wsID.GetLength()), - pProtoNode)) { - continue; - } - } - if (!pProtoNode) { - continue; - } - XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); - } -} diff --git a/xfa/src/fxfa/parser/xfa_document_layout_imp.cpp b/xfa/src/fxfa/parser/xfa_document_layout_imp.cpp deleted file mode 100644 index 2ac2bd6164..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_layout_imp.cpp +++ /dev/null @@ -1,208 +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/src/fxfa/parser/xfa_document_layout_imp.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" -#include "xfa/src/fxfa/parser/xfa_layout_itemlayout.h" -#include "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_LayoutProcessor* CXFA_Document::GetLayoutProcessor() { - if (!m_pLayoutProcessor) { - m_pLayoutProcessor = new CXFA_LayoutProcessor(this); - ASSERT(m_pLayoutProcessor); - } - return m_pLayoutProcessor; -} -IXFA_DocLayout* CXFA_Document::GetDocLayout() { - return GetLayoutProcessor(); -} -CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument) - : m_pDocument(pDocument), - m_pRootItemLayoutProcessor(NULL), - m_pLayoutPageMgr(NULL), - m_nProgressCounter(0), - m_bNeeLayout(TRUE) {} -CXFA_LayoutProcessor::~CXFA_LayoutProcessor() { - ClearLayoutData(); -} -CXFA_Document* CXFA_LayoutProcessor::GetDocument() const { - return m_pDocument; -} -int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) { - if (!bForceRestart && !IsNeedLayout()) { - return 100; - } - if (m_pRootItemLayoutProcessor) { - delete m_pRootItemLayoutProcessor; - m_pRootItemLayoutProcessor = NULL; - } - m_nProgressCounter = 0; - CXFA_Node* pFormPacketNode = - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); - if (!pFormPacketNode) { - return -1; - } - CXFA_Node* pFormRoot = - pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform); - if (!pFormRoot) { - return -1; - } - if (!m_pLayoutPageMgr) { - m_pLayoutPageMgr = new CXFA_LayoutPageMgr(this); - } - if (!m_pLayoutPageMgr->InitLayoutPage(pFormRoot)) { - return -1; - } - if (!m_pLayoutPageMgr->PrepareFirstPage(pFormRoot)) { - return -1; - } - m_pRootItemLayoutProcessor = - new CXFA_ItemLayoutProcessor(pFormRoot, m_pLayoutPageMgr); - m_nProgressCounter = 1; - return 0; -} -int32_t CXFA_LayoutProcessor::DoLayout(IFX_Pause* pPause) { - if (m_nProgressCounter < 1) { - return -1; - } - XFA_ItemLayoutProcessorResult eStatus; - CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode(); - FX_FLOAT fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); - FX_FLOAT fPosY = pFormNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); - do { - FX_FLOAT fAvailHeight = m_pLayoutPageMgr->GetAvailHeight(); - eStatus = - m_pRootItemLayoutProcessor->DoLayout(TRUE, fAvailHeight, fAvailHeight); - if (eStatus != XFA_ItemLayoutProcessorResult_Done) { - m_nProgressCounter++; - } - CXFA_ContentLayoutItem* pLayoutItem = - m_pRootItemLayoutProcessor->ExtractLayoutItem(); - if (pLayoutItem) { - pLayoutItem->m_sPos = CFX_PointF(fPosX, fPosY); - } - m_pLayoutPageMgr->SubmitContentItem(pLayoutItem, eStatus); - } while (eStatus != XFA_ItemLayoutProcessorResult_Done && - (!pPause || !pPause->NeedToPauseNow())); - if (eStatus == XFA_ItemLayoutProcessorResult_Done) { - m_pLayoutPageMgr->FinishPaginatedPageSets(); - m_pLayoutPageMgr->SyncLayoutData(); - m_bNeeLayout = FALSE; - m_rgChangedContainers.RemoveAll(); - } - return 100 * (eStatus == XFA_ItemLayoutProcessorResult_Done - ? m_nProgressCounter - : m_nProgressCounter - 1) / - m_nProgressCounter; -} -FX_BOOL CXFA_LayoutProcessor::IncrementLayout() { - if (m_bNeeLayout) { - StartLayout(TRUE); - return DoLayout(NULL) == 100; - } - for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) { - CXFA_Node* pNode = m_rgChangedContainers[i]; - CXFA_Node* pParentNode = - pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); - if (!pParentNode) { - return FALSE; - } - if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode, - pParentNode)) { - return FALSE; - } - } - m_rgChangedContainers.RemoveAll(); - return TRUE; -} -int32_t CXFA_LayoutProcessor::CountPages() const { - return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPageCount() : 0; -} -IXFA_LayoutPage* CXFA_LayoutProcessor::GetPage(int32_t index) const { - return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPage(index) : NULL; -} -CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) { - return static_cast<CXFA_LayoutItem*>( - pFormItem->GetUserData(XFA_LAYOUTITEMKEY)); -} -void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) { - if (m_rgChangedContainers.Find(pContainer) < 0) { - m_rgChangedContainers.Add(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; - } - m_nProgressCounter = 0; -} -FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() { - return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0; -} -CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem) - : m_pFormNode(pNode), - m_pParent(NULL), - m_pNextSibling(NULL), - m_pFirstChild(NULL), - m_bIsContentLayoutItem(bIsContentLayoutItem) {} -CXFA_LayoutItem::~CXFA_LayoutItem() {} -CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode) - : CXFA_LayoutItem(pNode, FALSE), m_pOldSubform(NULL) {} -IXFA_DocLayout* CXFA_ContainerLayoutItem::GetLayout() const { - return m_pFormNode->GetDocument()->GetLayoutProcessor(); -} -int32_t CXFA_ContainerLayoutItem::GetPageIndex() const { - return m_pFormNode->GetDocument() - ->GetLayoutProcessor() - ->GetLayoutPageMgr() - ->GetPageIndex(this); -} -void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) { - size.clear(); - CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium); - if (!pMedium) - return; - - size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt), - pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt)); - if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) == - XFA_ATTRIBUTEENUM_Landscape) { - size = CFX_SizeF(size.y, size.x); - } -} -CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const { - return m_pFormNode; -} -CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode) - : CXFA_LayoutItem(pNode, TRUE), - m_pPrev(NULL), - m_pNext(NULL), - m_dwStatus(0) {} -CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() { - if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this) { - m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, NULL); - } -} diff --git a/xfa/src/fxfa/parser/xfa_document_layout_imp.h b/xfa/src/fxfa/parser/xfa_document_layout_imp.h deleted file mode 100644 index c471588c97..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_layout_imp.h +++ /dev/null @@ -1,49 +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_SRC_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_ - -#include "xfa/src/fxfa/parser/xfa_doclayout.h" - -class CXFA_ItemLayoutProcessor; -class CXFA_LayoutPageMgr; -class CXFA_ContainerLayoutItem; - -class CXFA_LayoutProcessor : public IXFA_DocLayout { - public: - CXFA_LayoutProcessor(CXFA_Document* pDocument); - ~CXFA_LayoutProcessor(); - virtual CXFA_Document* GetDocument() const; - virtual int32_t StartLayout(FX_BOOL bForceRestart = FALSE); - virtual int32_t DoLayout(IFX_Pause* pPause = NULL); - virtual FX_BOOL IncrementLayout(); - virtual int32_t CountPages() const; - virtual IXFA_LayoutPage* GetPage(int32_t index) const; - virtual CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem); - - void AddChangedContainer(CXFA_Node* pContainer); - void SetForceReLayout(FX_BOOL bForceRestart) { m_bNeeLayout = bForceRestart; } - CXFA_ContainerLayoutItem* GetRootLayoutItem() const; - CXFA_ItemLayoutProcessor* GetRootRootItemLayoutProcessor() { - return m_pRootItemLayoutProcessor; - } - CXFA_LayoutPageMgr* GetLayoutPageMgr() { return m_pLayoutPageMgr; } - - protected: - void ClearLayoutData(); - - FX_BOOL IsNeedLayout(); - - CXFA_Document* m_pDocument; - CXFA_ItemLayoutProcessor* m_pRootItemLayoutProcessor; - CXFA_LayoutPageMgr* m_pLayoutPageMgr; - CXFA_NodeArray m_rgChangedContainers; - uint32_t m_nProgressCounter; - FX_BOOL m_bNeeLayout; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_LAYOUT_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_document_serialize.cpp b/xfa/src/fxfa/parser/xfa_document_serialize.cpp deleted file mode 100644 index 66a9b75e0c..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_serialize.cpp +++ /dev/null @@ -1,590 +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/src/fxfa/parser/xfa_document_serialize.h" - -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -IXFA_PacketImport* IXFA_PacketImport::Create(CXFA_Document* pDocument) { - return new CXFA_DataImporter(pDocument); -} -CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) - : m_pDocument(pDocument) { - ASSERT(m_pDocument); -} -FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) { - IXFA_Parser* pDataDocumentParser = IXFA_Parser::Create(m_pDocument); - if (!pDataDocumentParser) { - return FALSE; - } - if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) != - XFA_PARSESTATUS_Ready) { - pDataDocumentParser->Release(); - return FALSE; - } - if (pDataDocumentParser->DoParse(NULL) < XFA_PARSESTATUS_Done) { - pDataDocumentParser->Release(); - return FALSE; - } - CXFA_Node* pImportDataRoot = pDataDocumentParser->GetRootNode(); - if (!pImportDataRoot) { - pDataDocumentParser->Release(); - return FALSE; - } - CXFA_Node* pDataModel = - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDataModel) { - pDataDocumentParser->Release(); - return FALSE; - } - CXFA_Node* pDataNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Data)); - if (pDataNode) { - pDataModel->RemoveChild(pDataNode); - } - if (pImportDataRoot->GetClassID() == XFA_ELEMENT_DataModel) { - while (CXFA_Node* pChildNode = - pImportDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { - pImportDataRoot->RemoveChild(pChildNode); - pDataModel->InsertChild(pChildNode); - } - } else { - IFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); - IFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); - if (pParentXMLNode) { - pParentXMLNode->RemoveChildNode(pXMLNode); - } - pDataModel->InsertChild(pImportDataRoot); - } - m_pDocument->DoDataRemerge(FALSE); - pDataDocumentParser->Release(); - return TRUE; -} -CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) { - CFX_WideTextBuf textBuf; - int32_t iLen = str.GetLength(); - for (int32_t i = 0; i < iLen; i++) { - switch (str[i]) { - case '&': - textBuf << FX_WSTRC(L"&"); - break; - case '<': - textBuf << FX_WSTRC(L"<"); - break; - case '>': - textBuf << FX_WSTRC(L">"); - break; - case '\'': - textBuf << FX_WSTRC(L"'"); - break; - case '\"': - textBuf << FX_WSTRC(L"""); - break; - default: - textBuf.AppendChar(str[i]); - } - } - return textBuf.GetWideString(); -} -CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) { - CFX_WideTextBuf textBuf; - int32_t iLen = str.GetLength(); - for (int32_t i = 0; i < iLen; i++) { - FX_WCHAR ch = str.GetAt(i); - if (!FDE_IsXMLValidChar(ch)) { - continue; - } - if (ch == '&') { - textBuf << FX_WSTRC(L"&"); - } else if (ch == '<') { - textBuf << FX_WSTRC(L"<"); - } else if (ch == '>') { - textBuf << FX_WSTRC(L">"); - } else if (ch == '\'') { - textBuf << FX_WSTRC(L"'"); - } else if (ch == '\"') { - textBuf << FX_WSTRC(L"""); - } else if (ch == ' ') { - if (i && str.GetAt(i - 1) != ' ') { - textBuf.AppendChar(' '); - } else { - textBuf << FX_WSTRC(L" "); - } - } else { - textBuf.AppendChar(str.GetAt(i)); - } - } - return textBuf.GetWideString(); -} -static void XFA_SaveAttribute(CXFA_Node* pNode, - XFA_ATTRIBUTE eName, - const CFX_WideStringC& wsName, - FX_BOOL bProto, - CFX_WideString& wsOutput) { - CFX_WideString wsValue; - if ((!bProto && !pNode->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) || - !pNode->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, FALSE)) { - return; - } - wsValue = XFA_ExportEncodeAttribute(wsValue); - wsOutput += FX_WSTRC(L" "); - wsOutput += wsName; - wsOutput += FX_WSTRC(L"=\""); - wsOutput += wsValue; - wsOutput += FX_WSTRC(L"\""); -} -static FX_BOOL XFA_DataExporter_AttributeSaveInDataModel( - CXFA_Node* pNode, - XFA_ATTRIBUTE eAttribute) { - FX_BOOL bSaveInDataModel = FALSE; - if (pNode->GetClassID() != XFA_ELEMENT_Image) { - return bSaveInDataModel; - } - CXFA_Node* pValueNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pValueNode || pValueNode->GetClassID() != XFA_ELEMENT_Value) { - return bSaveInDataModel; - } - CXFA_Node* pFieldNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pFieldNode && pFieldNode->GetBindData() && - eAttribute == XFA_ATTRIBUTE_Href) { - bSaveInDataModel = TRUE; - } - return bSaveInDataModel; -} -FX_BOOL XFA_DataExporter_ContentNodeNeedtoExport(CXFA_Node* pContentNode) { - CFX_WideString wsContent; - if (!pContentNode->TryContent(wsContent, FALSE, FALSE)) { - return FALSE; - } - FXSYS_assert(pContentNode->GetObjectType() == XFA_OBJECTTYPE_ContentNode); - CXFA_Node* pParentNode = pContentNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Value) { - return TRUE; - } - CXFA_Node* pGrandParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pGrandParentNode || - pGrandParentNode->GetObjectType() != XFA_OBJECTTYPE_ContainerNode) { - return TRUE; - } - if (pGrandParentNode->GetBindData()) { - return FALSE; - } - CXFA_WidgetData* pWidgetData = pGrandParentNode->GetWidgetData(); - XFA_ELEMENT eUIType = pWidgetData->GetUIType(); - if (eUIType == XFA_ELEMENT_PasswordEdit) { - return FALSE; - } - return TRUE; -} -static void XFA_DataExporter_RecognizeXFAVersionNumber( - CXFA_Node* pTemplateRoot, - CFX_WideString& wsVersionNumber) { - wsVersionNumber.Empty(); - if (!pTemplateRoot) { - return; - } - CFX_WideString wsTemplateNS; - if (!pTemplateRoot->TryNamespace(wsTemplateNS)) { - return; - } - XFA_VERSION eVersion = - pTemplateRoot->GetDocument()->RecognizeXFAVersionNumber(wsTemplateNS); - if (eVersion == XFA_VERSION_UNKNOWN) { - eVersion = XFA_VERSION_DEFAULT; - } - wsVersionNumber.Format(L"%i.%i", eVersion / 100, eVersion % 100); -} -static void XFA_DataExporter_RegenerateFormFile_Changed( - CXFA_Node* pNode, - CFX_WideTextBuf& buf, - FX_BOOL bSaveXML = FALSE) { - CFX_WideString wsAttrs; - int32_t iAttrs = 0; - const uint8_t* pAttrs = XFA_GetElementAttributes(pNode->GetClassID(), iAttrs); - while (iAttrs--) { - const XFA_ATTRIBUTEINFO* pAttr = - XFA_GetAttributeByID((XFA_ATTRIBUTE)pAttrs[iAttrs]); - if (pAttr->eName == XFA_ATTRIBUTE_Name || - (XFA_DataExporter_AttributeSaveInDataModel(pNode, pAttr->eName) && - !bSaveXML)) { - continue; - } - CFX_WideString wsAttr; - XFA_SaveAttribute(pNode, pAttr->eName, pAttr->pName, bSaveXML, wsAttr); - wsAttrs += wsAttr; - } - CFX_WideString wsChildren; - switch (pNode->GetObjectType()) { - case XFA_OBJECTTYPE_ContentNode: { - if (!bSaveXML && !XFA_DataExporter_ContentNodeNeedtoExport(pNode)) { - break; - } - CXFA_Node* pRawValueNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pRawValueNode && - pRawValueNode->GetClassID() != XFA_ELEMENT_SharpxHTML && - pRawValueNode->GetClassID() != XFA_ELEMENT_Sharptext && - pRawValueNode->GetClassID() != XFA_ELEMENT_Sharpxml) { - pRawValueNode = pRawValueNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - if (!pRawValueNode) { - break; - } - CFX_WideString wsContentType; - pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (pRawValueNode->GetClassID() == XFA_ELEMENT_SharpxHTML && - wsContentType.Equal(FX_WSTRC(L"text/html"))) { - IFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); - if (!pExDataXML) { - break; - } - IFDE_XMLNode* pRichTextXML = - pExDataXML->GetNodeItem(IFDE_XMLNode::FirstChild); - if (!pRichTextXML) { - break; - } - IFX_MemoryStream* pMemStream = FX_CreateMemoryStream(TRUE); - IFX_Stream* pTempStream = IFX_Stream::CreateStream( - (IFX_FileWrite*)pMemStream, FX_STREAMACCESS_Text | - FX_STREAMACCESS_Write | - FX_STREAMACCESS_Append); - pTempStream->SetCodePage(FX_CODEPAGE_UTF8); - pRichTextXML->SaveXMLNode(pTempStream); - wsChildren += CFX_WideString::FromUTF8( - (const FX_CHAR*)pMemStream->GetBuffer(), pMemStream->GetSize()); - pTempStream->Release(); - pMemStream->Release(); - } else if (pRawValueNode->GetClassID() == XFA_ELEMENT_Sharpxml && - wsContentType.Equal(FX_WSTRC(L"text/xml"))) { - CFX_WideString wsRawValue; - pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, FALSE); - if (wsRawValue.IsEmpty()) { - break; - } - CFX_WideStringArray wsSelTextArray; - int32_t iStart = 0; - int32_t iEnd = wsRawValue.Find(L'\n', iStart); - iEnd = (iEnd == -1) ? wsRawValue.GetLength() : iEnd; - while (iEnd >= iStart) { - wsSelTextArray.Add(wsRawValue.Mid(iStart, iEnd - iStart)); - iStart = iEnd + 1; - if (iStart >= wsRawValue.GetLength()) { - break; - } - iEnd = wsRawValue.Find(L'\n', iStart); - } - CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); - FXSYS_assert(pParentNode); - CXFA_Node* pGrandparentNode = - pParentNode->GetNodeItem(XFA_NODEITEM_Parent); - FXSYS_assert(pGrandparentNode); - CFX_WideString bodyTagName; - bodyTagName = pGrandparentNode->GetCData(XFA_ATTRIBUTE_Name); - if (bodyTagName.IsEmpty()) { - bodyTagName = FX_WSTRC(L"ListBox1"); - } - buf << FX_WSTRC(L"<"); - buf << bodyTagName; - 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]); - buf << FX_WSTRC(L"</value\n>"); - } - buf << FX_WSTRC(L"</"); - buf << bodyTagName; - buf << FX_WSTRC(L"\n>"); - wsChildren += buf.GetWideString(); - buf.Clear(); - } else { - CFX_WideStringC wsValue = pRawValueNode->GetCData(XFA_ATTRIBUTE_Value); - wsChildren += XFA_ExportEncodeContent(wsValue); - } - } break; - case XFA_OBJECTTYPE_TextNode: - case XFA_OBJECTTYPE_NodeC: - case XFA_OBJECTTYPE_NodeV: { - CFX_WideStringC wsValue = pNode->GetCData(XFA_ATTRIBUTE_Value); - wsChildren += XFA_ExportEncodeContent(wsValue); - } break; - default: - if (pNode->GetClassID() == XFA_ELEMENT_Items) { - CXFA_Node* pTemplateNode = pNode->GetTemplateNode(); - if (!pTemplateNode || - pTemplateNode->CountChildren(XFA_ELEMENT_UNKNOWN) != - pNode->CountChildren(XFA_ELEMENT_UNKNOWN)) { - bSaveXML = TRUE; - } - } - CFX_WideTextBuf newBuf; - CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, - bSaveXML); - wsChildren += newBuf.GetWideString(); - newBuf.Clear(); - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - if (!bSaveXML && !wsChildren.IsEmpty() && - pNode->GetClassID() == XFA_ELEMENT_Items) { - wsChildren.Empty(); - bSaveXML = TRUE; - CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, - bSaveXML); - wsChildren += newBuf.GetWideString(); - newBuf.Clear(); - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } - break; - } - if (!wsChildren.IsEmpty() || !wsAttrs.IsEmpty() || - pNode->HasAttribute(XFA_ATTRIBUTE_Name)) { - CFX_WideStringC wsElement; - pNode->GetClassName(wsElement); - CFX_WideString wsName; - XFA_SaveAttribute(pNode, XFA_ATTRIBUTE_Name, FX_WSTRC(L"name"), TRUE, - wsName); - buf << FX_WSTRC(L"<"); - buf << wsElement; - buf << wsName; - buf << wsAttrs; - if (wsChildren.IsEmpty()) { - buf << FX_WSTRC(L"\n/>"); - } else { - buf << FX_WSTRC(L"\n>"); - buf << wsChildren; - buf << FX_WSTRC(L"</"); - buf << wsElement; - buf << FX_WSTRC(L"\n>"); - } - } -} -static void XFA_DataExporter_RegenerateFormFile_Container( - CXFA_Node* pNode, - IFX_Stream* pStream, - FX_BOOL bSaveXML = FALSE) { - XFA_ELEMENT eElement = pNode->GetClassID(); - if (eElement == XFA_ELEMENT_Field || eElement == XFA_ELEMENT_Draw || - !pNode->IsContainerNode()) { - CFX_WideTextBuf buf; - XFA_DataExporter_RegenerateFormFile_Changed(pNode, buf, bSaveXML); - FX_STRSIZE nLen = buf.GetLength(); - if (nLen > 0) { - pStream->WriteString((const FX_WCHAR*)buf.GetBuffer(), nLen); - } - return; - } - CFX_WideStringC wsElement; - pNode->GetClassName(wsElement); - pStream->WriteString(L"<", 1); - pStream->WriteString(wsElement.GetPtr(), wsElement.GetLength()); - CFX_WideString wsOutput; - XFA_SaveAttribute(pNode, XFA_ATTRIBUTE_Name, FX_WSTRC(L"name"), TRUE, - wsOutput); - CFX_WideString wsAttrs; - int32_t iAttrs = 0; - const uint8_t* pAttrs = XFA_GetElementAttributes(pNode->GetClassID(), iAttrs); - while (iAttrs--) { - const XFA_ATTRIBUTEINFO* pAttr = - XFA_GetAttributeByID((XFA_ATTRIBUTE)pAttrs[iAttrs]); - if (pAttr->eName == XFA_ATTRIBUTE_Name) { - continue; - } - CFX_WideString wsAttr; - XFA_SaveAttribute(pNode, pAttr->eName, pAttr->pName, FALSE, wsAttr); - wsOutput += wsAttr; - } - if (!wsOutput.IsEmpty()) { - pStream->WriteString((const FX_WCHAR*)wsOutput, wsOutput.GetLength()); - } - CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildNode) { - pStream->WriteString(L"\n>", 2); - while (pChildNode) { - XFA_DataExporter_RegenerateFormFile_Container(pChildNode, pStream, - bSaveXML); - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - pStream->WriteString(L"</", 2); - pStream->WriteString(wsElement.GetPtr(), wsElement.GetLength()); - pStream->WriteString(L"\n>", 2); - } else { - pStream->WriteString(L"\n/>", 3); - } -} -void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, - IFX_Stream* pStream, - 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>"; - 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)); - pStream->WriteString(s_pwChecksum, FXSYS_wcslen(s_pwChecksum)); - pStream->WriteString((const FX_WCHAR*)wsChecksum, wsChecksum.GetLength()); - pStream->WriteString(L"\"", 1); - } - pStream->WriteString(L" xmlns=\"", FXSYS_wcslen(L" xmlns=\"")); - const FX_WCHAR* pURI = XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI; - pStream->WriteString(pURI, FXSYS_wcslen(pURI)); - CFX_WideString wsVersionNumber; - XFA_DataExporter_RecognizeXFAVersionNumber( - ToNode(pNode->GetDocument()->GetXFAObject(XFA_XDPPACKET_Template)), - wsVersionNumber); - if (wsVersionNumber.IsEmpty()) { - wsVersionNumber = FX_WSTRC(L"2.8"); - } - wsVersionNumber += FX_WSTRC(L"/\"\n>"); - pStream->WriteString((const FX_WCHAR*)wsVersionNumber, - wsVersionNumber.GetLength()); - CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - XFA_DataExporter_RegenerateFormFile_Container(pChildNode, pStream); - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - pStream->WriteString(s_pwsClose, FXSYS_wcslen(s_pwsClose)); - } else { - XFA_DataExporter_RegenerateFormFile_Container(pNode, pStream, bSaveXML); - } -} -IXFA_PacketExport* IXFA_PacketExport::Create(CXFA_Document* pDocument, - XFA_DATAFORMAT eFormat) { - return new CXFA_DataExporter(pDocument); -} -CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) - : m_pDocument(pDocument) { - ASSERT(m_pDocument); -} -FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite) { - return Export(pWrite, m_pDocument->GetRoot()); -} -FX_BOOL CXFA_DataExporter::Export(IFX_FileWrite* pWrite, - CXFA_Node* pNode, - FX_DWORD dwFlag, - const FX_CHAR* pChecksum) { - if (!pWrite) { - ASSERT(false); - return FALSE; - } - IFX_Stream* pStream = IFX_Stream::CreateStream( - pWrite, - FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); - if (pStream == NULL) { - return FALSE; - } - pStream->SetCodePage(FX_CODEPAGE_UTF8); - FX_BOOL bRet = Export(pStream, pNode, dwFlag, pChecksum); - pStream->Release(); - return bRet; -} -FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, - CXFA_Node* pNode, - FX_DWORD dwFlag, - const FX_CHAR* pChecksum) { - IFDE_XMLDoc* pXMLDoc = m_pDocument->GetParser()->GetXMLDoc(); - if (pNode->GetObjectType() == XFA_OBJECTTYPE_ModelNode) { - switch (pNode->GetPacketID()) { - case XFA_XDPPACKET_XDP: { - 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>"; - pStream->WriteString(s_pwsPostamble, FXSYS_wcslen(s_pwsPostamble)); - } break; - case XFA_XDPPACKET_Datasets: { - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pNode->GetXMLMappingNode(); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { - return FALSE; - } - CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - FXSYS_assert(pDataNode); - XFA_DataExporter_DealWithDataGroupNode(pDataNode); - pXMLDoc->SaveXMLNode(pStream, pElement); - } break; - case XFA_XDPPACKET_Form: { - XFA_DataExporter_RegenerateFormFile(pNode, pStream, pChecksum); - } break; - case XFA_XDPPACKET_Template: - default: { - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pNode->GetXMLMappingNode(); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { - return FALSE; - } - pXMLDoc->SaveXMLNode(pStream, pElement); - } break; - } - } else { - CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_Node* pExportNode = pNode; - for (CXFA_Node* pChildNode = - pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pChildNode != pNode) { - pExportNode = pDataNode; - break; - } - } - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pExportNode->GetXMLMappingNode(); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { - 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/")); - pXMLDoc->SaveXMLNode(pStream, pElement); - pElement->RemoveAttribute(L"xmlns:xfa"); - } - return TRUE; -} -void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { - if (!pDataNode || pDataNode->GetClassID() == XFA_ELEMENT_DataValue) { - return; - } - int32_t iChildNum = 0; - for (CXFA_Node* pChildNode = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - iChildNum++; - XFA_DataExporter_DealWithDataGroupNode(pChildNode); - } - if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) { - if (iChildNum > 0) { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - if (pXMLElement->HasAttribute(L"xfa:dataNode")) { - pXMLElement->RemoveAttribute(L"xfa:dataNode"); - } - } else { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode) - ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); - } - } -} diff --git a/xfa/src/fxfa/parser/xfa_document_serialize.h b/xfa/src/fxfa/parser/xfa_document_serialize.h deleted file mode 100644 index 37dbb9a03b..0000000000 --- a/xfa/src/fxfa/parser/xfa_document_serialize.h +++ /dev/null @@ -1,40 +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_SRC_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_ -#define XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_ - -#include "xfa/src/fxfa/parser/xfa_docdata.h" - -class CXFA_DataImporter : public IXFA_PacketImport { - public: - CXFA_DataImporter(CXFA_Document* pDocument); - virtual void Release() { delete this; } - virtual FX_BOOL ImportData(IFX_FileRead* pDataDocument); - - protected: - CXFA_Document* m_pDocument; -}; - -class CXFA_DataExporter : public IXFA_PacketExport { - public: - CXFA_DataExporter(CXFA_Document* pDocument); - virtual void Release() { delete this; } - virtual FX_BOOL Export(IFX_FileWrite* pWrite); - virtual FX_BOOL Export(IFX_FileWrite* pWrite, - CXFA_Node* pNode, - FX_DWORD dwFlag = 0, - const FX_CHAR* pChecksum = NULL); - - protected: - FX_BOOL Export(IFX_Stream* pStream, - CXFA_Node* pNode, - FX_DWORD dwFlag, - const FX_CHAR* pChecksum); - CXFA_Document* m_pDocument; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_ diff --git a/xfa/src/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/src/fxfa/parser/xfa_layout_appadapter.cpp deleted file mode 100644 index bf79c83a38..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_appadapter.cpp +++ /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 - -#include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_layout_itemlayout.h" -#include "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) { - FX_DWORD 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; - IXFA_Notify* pNotify = - pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); - IXFA_DocLayout* pDocLayout = - pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); - while (pNode) { - CXFA_LayoutItem* pNext = pNode->m_pNextSibling; - pNode->m_pParent = nullptr; - pNotify->OnLayoutEvent(pDocLayout, static_cast<CXFA_LayoutItem*>(pNode), - XFA_LAYOUTEVENT_ItemRemoving); - XFA_ReleaseLayoutItem(pNode); - pNode = pNext; - } - pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, XFA_LAYOUTEVENT_ItemRemoving); - if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) { - pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), - XFA_PAGEEVENT_PageRemoved); - } - delete pLayoutItem; -} diff --git a/xfa/src/fxfa/parser/xfa_layout_appadapter.h b/xfa/src/fxfa/parser/xfa_layout_appadapter.h deleted file mode 100644 index 94012fae0e..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_appadapter.h +++ /dev/null @@ -1,77 +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_SRC_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ - -#include "xfa/src/fxfa/parser/xfa_doclayout.h" - -class CXFA_TraverseStrategy_PageAreaContainerLayoutItem { - public: - static inline CXFA_ContainerLayoutItem* GetFirstChild( - CXFA_ContainerLayoutItem* pLayoutItem) { - if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild; - } - return NULL; - } - static inline CXFA_ContainerLayoutItem* GetNextSibling( - CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling; - } - static inline CXFA_ContainerLayoutItem* GetParent( - CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; - } -}; -class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { - public: - static inline CXFA_ContainerLayoutItem* GetFirstChild( - CXFA_ContainerLayoutItem* pLayoutItem) { - for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; - pChildItem = pChildItem->m_pNextSibling) { - if (CXFA_ContainerLayoutItem* pContainer = - pChildItem->AsContainerLayoutItem()) { - return pContainer; - } - } - return nullptr; - } - static inline CXFA_ContainerLayoutItem* GetNextSibling( - CXFA_ContainerLayoutItem* pLayoutItem) { - for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; - pChildItem = pChildItem->m_pNextSibling) { - if (CXFA_ContainerLayoutItem* pContainer = - pChildItem->AsContainerLayoutItem()) { - return pContainer; - } - } - return nullptr; - } - static inline CXFA_ContainerLayoutItem* GetParent( - CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; - } -}; -class CXFA_TraverseStrategy_ContentLayoutItem { - public: - static inline CXFA_ContentLayoutItem* GetFirstChild( - CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; - } - static inline CXFA_ContentLayoutItem* GetNextSibling( - CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pNextSibling; - } - static inline CXFA_ContentLayoutItem* GetParent( - CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pParent; - } -}; -FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant); -void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); - -#endif // XFA_SRC_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ diff --git a/xfa/src/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/src/fxfa/parser/xfa_layout_itemlayout.cpp deleted file mode 100644 index cdf327826b..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_itemlayout.cpp +++ /dev/null @@ -1,2968 +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/src/fxfa/parser/xfa_layout_itemlayout.h" - -#include <algorithm> -#include <memory> - -#include "xfa/src/fgas/crt/fgas_algorithm.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" -#include "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode, - CXFA_LayoutPageMgr* pPageMgr) - : m_bKeepBreakFinish(FALSE), - m_bIsProcessKeep(FALSE), - m_pKeepHeadNode(nullptr), - m_pKeepTailNode(nullptr), - m_pFormNode(pNode), - m_pLayoutItem(nullptr), - m_pOldLayoutItem(nullptr), - m_pCurChildNode(XFA_LAYOUT_INVALIDNODE), - m_pCurChildPreprocessor(nullptr), - m_nCurChildNodeStage(XFA_ItemLayoutProcessorStages_None), - m_fUsedSize(0), - m_pPageMgr(pPageMgr), - m_bBreakPending(TRUE), - m_fLastRowWidth(0), - m_fLastRowY(0), - m_fWidthLimite(0), - m_bUseInheriated(FALSE), - m_ePreProcessRs(XFA_ItemLayoutProcessorResult_Done), - m_bHasAvailHeight(TRUE) { - FXSYS_assert(m_pFormNode && (m_pFormNode->IsContainerNode() || - m_pFormNode->GetClassID() == XFA_ELEMENT_Form)); - m_pOldLayoutItem = - (CXFA_ContentLayoutItem*)m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY); -} -CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem( - CXFA_Node* pFormNode) { - if (!pFormNode) { - return NULL; - } - CXFA_ContentLayoutItem* pLayoutItem = NULL; - if (m_pOldLayoutItem) { - pLayoutItem = m_pOldLayoutItem; - m_pOldLayoutItem = m_pOldLayoutItem->m_pNext; - return pLayoutItem; - } - pLayoutItem = (CXFA_ContentLayoutItem*)pFormNode->GetDocument() - ->GetParser() - ->GetNotify() - ->OnCreateLayoutItem(pFormNode); - CXFA_ContentLayoutItem* pPrevLayoutItem = - (CXFA_ContentLayoutItem*)pFormNode->GetUserData(XFA_LAYOUTITEMKEY); - if (pPrevLayoutItem) { - while (pPrevLayoutItem->m_pNext) { - pPrevLayoutItem = pPrevLayoutItem->m_pNext; - } - pPrevLayoutItem->m_pNext = pLayoutItem; - pLayoutItem->m_pPrev = pPrevLayoutItem; - } else { - pFormNode->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem); - } - return pLayoutItem; -} -FX_BOOL CXFA_ItemLayoutProcessor::FindLayoutItemSplitPos( - CXFA_ContentLayoutItem* pLayoutItem, - FX_FLOAT fCurVerticalOffset, - FX_FLOAT& fProposedSplitPos, - FX_BOOL& bAppChange, - FX_BOOL bCalculateMargin) { - CXFA_Node* pFormNode = pLayoutItem->m_pFormNode; - if (fProposedSplitPos > fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION && - fProposedSplitPos <= fCurVerticalOffset + pLayoutItem->m_sSize.y - - XFA_LAYOUT_FLOAT_PERCISION) { - switch (pFormNode->GetIntact()) { - case XFA_ATTRIBUTEENUM_None: { - FX_BOOL bAnyChanged = FALSE; - CXFA_Document* pDocument = pFormNode->GetDocument(); - IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); - FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; - CXFA_Node* pMarginNode = - pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - if (pMarginNode && bCalculateMargin) { - fCurTopMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) - .ToUnit(XFA_UNIT_Pt); - fCurBottomMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset) - .ToUnit(XFA_UNIT_Pt); - } - FX_BOOL bChanged = TRUE; - while (bChanged) { - bChanged = FALSE; - { - FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurVerticalOffset; - if (pNotify->FindSplitPos(pFormNode, pLayoutItem->GetIndex(), - fRelSplitPos)) { - bAnyChanged = TRUE; - bChanged = TRUE; - fProposedSplitPos = fCurVerticalOffset + fRelSplitPos; - bAppChange = TRUE; - if (fProposedSplitPos <= - fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { - return TRUE; - } - } - } - FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurBottomMargin; - for (CXFA_ContentLayoutItem* pChildItem = - (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; - pChildItem; - pChildItem = - (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { - FX_FLOAT fChildOffset = - fCurVerticalOffset + fCurTopMargin + pChildItem->m_sPos.y; - FX_BOOL bAppChange = FALSE; - if (FindLayoutItemSplitPos(pChildItem, fChildOffset, fRelSplitPos, - bAppChange, bCalculateMargin)) { - if (fRelSplitPos - fChildOffset < XFA_LAYOUT_FLOAT_PERCISION && - bAppChange) { - fProposedSplitPos = fRelSplitPos - fCurTopMargin; - } else { - fProposedSplitPos = fRelSplitPos + fCurBottomMargin; - } - bAnyChanged = TRUE; - bChanged = TRUE; - if (fProposedSplitPos <= - fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { - return TRUE; - } - if (bAnyChanged) { - break; - } - } - } - } - return bAnyChanged; - } break; - case XFA_ATTRIBUTEENUM_ContentArea: - case XFA_ATTRIBUTEENUM_PageArea: { - fProposedSplitPos = fCurVerticalOffset; - return TRUE; - } - default: - return FALSE; - } - } - return FALSE; -} -static XFA_ATTRIBUTEENUM XFA_ItemLayoutProcessor_GetLayout( - CXFA_Node* pFormNode, - FX_BOOL& bRootForceTb) { - bRootForceTb = FALSE; - XFA_ATTRIBUTEENUM eLayoutMode; - if (pFormNode->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, FALSE)) { - return eLayoutMode; - } - CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Form) { - bRootForceTb = TRUE; - return XFA_ATTRIBUTEENUM_Tb; - } - return XFA_ATTRIBUTEENUM_Position; -} -static FX_BOOL XFA_ExistContainerKeep(CXFA_Node* pCurNode, FX_BOOL bPreFind) { - if (pCurNode == NULL || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode)) { - return FALSE; - } - XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling; - if (!bPreFind) { - eItemType = XFA_NODEITEM_NextSibling; - } - CXFA_Node* pPreContainer = - pCurNode->GetNodeItem(eItemType, XFA_OBJECTTYPE_ContainerNode); - if (pPreContainer == NULL) { - return FALSE; - } - CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Keep); - if (pKeep) { - XFA_ATTRIBUTEENUM ePrevious; - XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Previous; - if (!bPreFind) { - eKeepType = XFA_ATTRIBUTE_Next; - } - if (pKeep->TryEnum(eKeepType, ePrevious, FALSE)) { - if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea || - ePrevious == XFA_ATTRIBUTEENUM_PageArea) { - return TRUE; - } - } - } - pKeep = pPreContainer->GetFirstChildByClass(XFA_ELEMENT_Keep); - if (!pKeep) { - return FALSE; - } - XFA_ATTRIBUTEENUM eNext; - XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Next; - if (!bPreFind) { - eKeepType = XFA_ATTRIBUTE_Previous; - } - if (!pKeep->TryEnum(eKeepType, eNext, FALSE)) { - return FALSE; - } - if (eNext == XFA_ATTRIBUTEENUM_ContentArea || - eNext == XFA_ATTRIBUTEENUM_PageArea) { - return TRUE; - } - return FALSE; -} -FX_FLOAT CXFA_ItemLayoutProcessor::FindSplitPos(FX_FLOAT fProposedSplitPos) { - ASSERT(m_pLayoutItem); - XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - FX_BOOL bCalculateMargin = TRUE; - if (eLayout == XFA_ATTRIBUTEENUM_Position) { - bCalculateMargin = FALSE; - } - while (fProposedSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { - FX_BOOL bAppChange = FALSE; - if (!FindLayoutItemSplitPos(m_pLayoutItem, 0, fProposedSplitPos, bAppChange, - bCalculateMargin)) { - break; - } - } - return fProposedSplitPos; -} -void CXFA_ItemLayoutProcessor::SplitLayoutItem( - CXFA_ContentLayoutItem* pLayoutItem, - CXFA_ContentLayoutItem* pSecondParent, - FX_FLOAT fSplitPos) { - FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; - XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - FX_BOOL bCalculateMargin = TRUE; - if (eLayout == XFA_ATTRIBUTEENUM_Position) { - bCalculateMargin = FALSE; - } - CXFA_Node* pMarginNode = - pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - if (pMarginNode && bCalculateMargin) { - fCurTopMargin = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); - fCurBottomMargin = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); - } - CXFA_ContentLayoutItem* pSecondLayoutItem = NULL; - if (m_pCurChildPreprocessor && - m_pCurChildPreprocessor->m_pFormNode == pLayoutItem->m_pFormNode) { - pSecondLayoutItem = m_pCurChildPreprocessor->CreateContentLayoutItem( - pLayoutItem->m_pFormNode); - } else { - pSecondLayoutItem = CreateContentLayoutItem(pLayoutItem->m_pFormNode); - } - pSecondLayoutItem->m_sPos.x = pLayoutItem->m_sPos.x; - pSecondLayoutItem->m_sSize.x = pLayoutItem->m_sSize.x; - pSecondLayoutItem->m_sPos.y = 0; - pSecondLayoutItem->m_sSize.y = pLayoutItem->m_sSize.y - fSplitPos; - pLayoutItem->m_sSize.y -= pSecondLayoutItem->m_sSize.y; - if (pLayoutItem->m_pFirstChild) { - pSecondLayoutItem->m_sSize.y += fCurTopMargin; - } - if (pSecondParent) { - pSecondParent->AddChild(pSecondLayoutItem); - if (fCurTopMargin > 0 && pLayoutItem->m_pFirstChild) { - pSecondParent->m_sSize.y += fCurTopMargin; - CXFA_ContentLayoutItem* pParentItem = - (CXFA_ContentLayoutItem*)pSecondParent->m_pParent; - while (pParentItem) { - pParentItem->m_sSize.y += fCurTopMargin; - pParentItem = (CXFA_ContentLayoutItem*)pParentItem->m_pParent; - } - } - } else { - pSecondLayoutItem->m_pParent = pLayoutItem->m_pParent; - pSecondLayoutItem->m_pNextSibling = pLayoutItem->m_pNextSibling; - pLayoutItem->m_pNextSibling = pSecondLayoutItem; - } - CXFA_ContentLayoutItem* pChildren = - (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; - pLayoutItem->m_pFirstChild = NULL; - FX_FLOAT lHeightForKeep = 0; - CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; - FX_FLOAT fAddMarginHeight = 0; - for (CXFA_ContentLayoutItem *pChildItem = pChildren, *pChildNext = NULL; - pChildItem; pChildItem = pChildNext) { - pChildNext = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling; - pChildItem->m_pNextSibling = NULL; - if (fSplitPos <= fCurTopMargin + pChildItem->m_sPos.y + fCurBottomMargin + - XFA_LAYOUT_FLOAT_PERCISION) { - if (!XFA_ExistContainerKeep(pChildItem->m_pFormNode, TRUE)) { - pChildItem->m_sPos.y -= fSplitPos - fCurBottomMargin; - pChildItem->m_sPos.y += lHeightForKeep; - pChildItem->m_sPos.y += fAddMarginHeight; - pSecondLayoutItem->AddChild(pChildItem); - } else { - if (lHeightForKeep < XFA_LAYOUT_FLOAT_PERCISION) { - for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); - iIndex++) { - CXFA_ContentLayoutItem* pPreItem = keepLayoutItems[iIndex]; - pLayoutItem->RemoveChild(pPreItem); - pPreItem->m_sPos.y -= fSplitPos; - if (pPreItem->m_sPos.y < 0) { - pPreItem->m_sPos.y = 0; - } - if (pPreItem->m_sPos.y + pPreItem->m_sSize.y > lHeightForKeep) { - pPreItem->m_sPos.y = lHeightForKeep; - lHeightForKeep += pPreItem->m_sSize.y; - pSecondLayoutItem->m_sSize.y += pPreItem->m_sSize.y; - if (pSecondParent) { - pSecondParent->m_sSize.y += pPreItem->m_sSize.y; - } - } - pSecondLayoutItem->AddChild(pPreItem); - } - } - pChildItem->m_sPos.y -= fSplitPos; - pChildItem->m_sPos.y += lHeightForKeep; - pChildItem->m_sPos.y += fAddMarginHeight; - pSecondLayoutItem->AddChild(pChildItem); - } - } else if (fSplitPos + XFA_LAYOUT_FLOAT_PERCISION >= - fCurTopMargin + fCurBottomMargin + pChildItem->m_sPos.y + - pChildItem->m_sSize.y) { - pLayoutItem->AddChild(pChildItem); - if (XFA_ExistContainerKeep(pChildItem->m_pFormNode, FALSE)) { - keepLayoutItems.Add(pChildItem); - } else { - keepLayoutItems.RemoveAll(); - } - } else { - FX_FLOAT fOldHeight = pSecondLayoutItem->m_sSize.y; - SplitLayoutItem( - pChildItem, pSecondLayoutItem, - fSplitPos - fCurTopMargin - fCurBottomMargin - pChildItem->m_sPos.y); - fAddMarginHeight = pSecondLayoutItem->m_sSize.y - fOldHeight; - pLayoutItem->AddChild(pChildItem); - } - } -} -void CXFA_ItemLayoutProcessor::SplitLayoutItem(FX_FLOAT fSplitPos) { - ASSERT(m_pLayoutItem); - SplitLayoutItem(m_pLayoutItem, NULL, fSplitPos); -} - -IXFA_LayoutPage* CXFA_LayoutItem::GetPage() const { - for (CXFA_LayoutItem* pCurNode = const_cast<CXFA_LayoutItem*>(this); pCurNode; - pCurNode = pCurNode->m_pParent) { - if (pCurNode->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) - return static_cast<CXFA_ContainerLayoutItem*>(pCurNode); - } - return nullptr; -} - -CXFA_Node* CXFA_LayoutItem::GetFormNode() const { - return m_pFormNode; -} - -void CXFA_LayoutItem::GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative) const { - ASSERT(m_bIsContentLayoutItem); - const CXFA_ContentLayoutItem* pThis = - static_cast<const CXFA_ContentLayoutItem*>(this); - CFX_PointF sPos = pThis->m_sPos; - CFX_SizeF sSize = pThis->m_sSize; - if (!bRelative) { - for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem; - pLayoutItem = pLayoutItem->m_pParent) { - if (CXFA_ContentLayoutItem* pContent = - pLayoutItem->AsContentLayoutItem()) { - sPos += pContent->m_sPos; - if (CXFA_Node* pMarginNode = - pLayoutItem->m_pFormNode->GetFirstChildByClass( - XFA_ELEMENT_Margin)) { - sPos += CFX_PointF(pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset) - .ToUnit(XFA_UNIT_Pt), - pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) - .ToUnit(XFA_UNIT_Pt)); - } - } else { - if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { - sPos += - CFX_PointF(pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_X) - .ToUnit(XFA_UNIT_Pt), - pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Y) - .ToUnit(XFA_UNIT_Pt)); - break; - } else if (pLayoutItem->m_pFormNode->GetClassID() == - XFA_ELEMENT_PageArea) { - break; - } - } - } - } - rtLayout.Set(sPos.x, sPos.y, sSize.x, sSize.y); -} - -CXFA_LayoutItem* CXFA_LayoutItem::GetParent() const { - return m_pParent; -} - -const CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() const { - ASSERT(m_bIsContentLayoutItem); - const CXFA_ContentLayoutItem* pCurNode = - static_cast<const CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pPrev) { - pCurNode = pCurNode->m_pPrev; - } - return pCurNode; -} - -CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() { - ASSERT(m_bIsContentLayoutItem); - CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pPrev) { - pCurNode = pCurNode->m_pPrev; - } - return pCurNode; -} - -CXFA_LayoutItem* CXFA_LayoutItem::GetLast() { - ASSERT(m_bIsContentLayoutItem); - CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pNext) { - pCurNode = pCurNode->m_pNext; - } - return pCurNode; -} - -const CXFA_LayoutItem* CXFA_LayoutItem::GetLast() const { - ASSERT(m_bIsContentLayoutItem); - const CXFA_ContentLayoutItem* pCurNode = - static_cast<const CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pNext) { - pCurNode = pCurNode->m_pNext; - } - return pCurNode; -} - -CXFA_LayoutItem* CXFA_LayoutItem::GetPrev() const { - ASSERT(m_bIsContentLayoutItem); - return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pPrev; -} - -CXFA_LayoutItem* CXFA_LayoutItem::GetNext() const { - ASSERT(m_bIsContentLayoutItem); - return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pNext; -} - -int32_t CXFA_LayoutItem::GetIndex() const { - ASSERT(m_bIsContentLayoutItem); - int32_t iIndex = 0; - const CXFA_ContentLayoutItem* pCurNode = - static_cast<const CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pPrev) { - pCurNode = pCurNode->m_pPrev; - ++iIndex; - } - return iIndex; -} - -int32_t CXFA_LayoutItem::GetCount() const { - ASSERT(m_bIsContentLayoutItem); - int32_t iCount = GetIndex() + 1; - const CXFA_ContentLayoutItem* pCurNode = - static_cast<const CXFA_ContentLayoutItem*>(this); - while (pCurNode->m_pNext) { - pCurNode = pCurNode->m_pNext; - iCount++; - } - return iCount; -} - -void CXFA_LayoutItem::AddChild(CXFA_LayoutItem* pChildItem) { - if (pChildItem->m_pParent) { - pChildItem->m_pParent->RemoveChild(pChildItem); - } - pChildItem->m_pParent = this; - if (m_pFirstChild == NULL) { - m_pFirstChild = pChildItem; - } else { - CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; - while (pExistingChildItem->m_pNextSibling) { - pExistingChildItem = pExistingChildItem->m_pNextSibling; - } - pExistingChildItem->m_pNextSibling = pChildItem; - } -} -void CXFA_LayoutItem::AddHeadChild(CXFA_LayoutItem* pChildItem) { - if (pChildItem->m_pParent) { - pChildItem->m_pParent->RemoveChild(pChildItem); - } - pChildItem->m_pParent = this; - if (m_pFirstChild == NULL) { - m_pFirstChild = pChildItem; - } else { - CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; - m_pFirstChild = pChildItem; - m_pFirstChild->m_pNextSibling = pExistingChildItem; - } -} -void CXFA_LayoutItem::InsertChild(CXFA_LayoutItem* pBeforeItem, - CXFA_LayoutItem* pChildItem) { - if (pBeforeItem->m_pParent != this) { - return; - } - if (pChildItem->m_pParent) { - pChildItem->m_pParent = NULL; - } - pChildItem->m_pParent = this; - CXFA_LayoutItem* pExistingChildItem = pBeforeItem->m_pNextSibling; - pBeforeItem->m_pNextSibling = pChildItem; - pChildItem->m_pNextSibling = pExistingChildItem; -} -void CXFA_LayoutItem::RemoveChild(CXFA_LayoutItem* pChildItem) { - if (pChildItem->m_pParent != this) { - return; - } - if (m_pFirstChild == pChildItem) { - m_pFirstChild = pChildItem->m_pNextSibling; - } else { - CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; - while (pExistingChildItem && - pExistingChildItem->m_pNextSibling != pChildItem) { - pExistingChildItem = pExistingChildItem->m_pNextSibling; - } - if (pExistingChildItem) { - pExistingChildItem->m_pNextSibling = pChildItem->m_pNextSibling; - } - } - pChildItem->m_pNextSibling = NULL; - pChildItem->m_pParent = NULL; -} -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; - } - IXFA_Notify* pNotify = - m_pOldLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); - IXFA_DocLayout* 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; - } - return pLayoutItem; -} -static FX_BOOL XFA_ItemLayoutProcessor_FindBreakNode( - CXFA_Node* pContainerNode, - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - FX_BOOL bBreakBefore) { - FX_BOOL bFindRs = FALSE; - for (CXFA_Node* pBreakNode = pContainerNode; pBreakNode; - pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ATTRIBUTE eAttributeType = XFA_ATTRIBUTE_Before; - if (!bBreakBefore) { - eAttributeType = XFA_ATTRIBUTE_After; - } - switch (pBreakNode->GetClassID()) { - case XFA_ELEMENT_BreakBefore: { - if (bBreakBefore) { - pCurActionNode = pBreakNode; - nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; - bFindRs = TRUE; - } - } break; - case XFA_ELEMENT_BreakAfter: { - if (!bBreakBefore) { - pCurActionNode = pBreakNode; - nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; - bFindRs = TRUE; - } - } break; - case XFA_ELEMENT_Break: - if (pBreakNode->GetEnum(eAttributeType) != XFA_ATTRIBUTEENUM_Auto) { - pCurActionNode = pBreakNode; - nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; - if (!bBreakBefore) { - nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; - } - bFindRs = TRUE; - break; - } - default: - break; - } - if (bFindRs) { - break; - } - } - return bFindRs; -} -static void XFA_DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { - IXFA_Notify* pNotify = pGenerateNode->GetDocument()->GetParser()->GetNotify(); - IXFA_DocLayout* pDocLayout = pGenerateNode->GetDocument()->GetDocLayout(); - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( - pGenerateNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - CXFA_ContentLayoutItem* pCurLayoutItem = - (CXFA_ContentLayoutItem*)pNode->GetUserData(XFA_LAYOUTITEMKEY); - CXFA_ContentLayoutItem* pNextLayoutItem = NULL; - while (pCurLayoutItem) { - pNextLayoutItem = pCurLayoutItem->m_pNext; - pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, - XFA_LAYOUTEVENT_ItemRemoving); - delete pCurLayoutItem; - pCurLayoutItem = pNextLayoutItem; - } - } - pGenerateNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pGenerateNode); -} -void CXFA_ItemLayoutProcessor::XFA_ItemLayoutProcessor_GotoNextContainerNode( - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node* pParentContainer, - FX_BOOL bUsePageBreak) { - CXFA_Node* pEntireContainer = pParentContainer; - CXFA_Node* pChildContainer = XFA_LAYOUT_INVALIDNODE; - switch (nCurStage) { - case XFA_ItemLayoutProcessorStages_BreakBefore: - case XFA_ItemLayoutProcessorStages_BreakAfter: { - pChildContainer = pCurActionNode->GetNodeItem(XFA_NODEITEM_Parent); - } break; - case XFA_ItemLayoutProcessorStages_Keep: - case XFA_ItemLayoutProcessorStages_Container: - pChildContainer = pCurActionNode; - break; - default: - pChildContainer = XFA_LAYOUT_INVALIDNODE; - break; - } - switch (nCurStage) { - case XFA_ItemLayoutProcessorStages_Keep: { - CXFA_Node* pBreakAfterNode = - pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!m_bKeepBreakFinish && - XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, - nCurStage, FALSE)) { - return; - } - goto CheckNextChildContainer; - } - case XFA_ItemLayoutProcessorStages_None: { - pCurActionNode = XFA_LAYOUT_INVALIDNODE; - case XFA_ItemLayoutProcessorStages_BookendLeader: - for (CXFA_Node* pBookendNode = - pCurActionNode == XFA_LAYOUT_INVALIDNODE - ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) - : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pBookendNode; pBookendNode = pBookendNode->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - switch (pBookendNode->GetClassID()) { - case XFA_ELEMENT_Bookend: - case XFA_ELEMENT_Break: - pCurActionNode = pBookendNode; - nCurStage = XFA_ItemLayoutProcessorStages_BookendLeader; - return; - default: - break; - } - } - } - { - pCurActionNode = XFA_LAYOUT_INVALIDNODE; - case XFA_ItemLayoutProcessorStages_BreakBefore: - if (pCurActionNode != XFA_LAYOUT_INVALIDNODE) { - CXFA_Node* pBreakBeforeNode = - pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); - if (!m_bKeepBreakFinish && - XFA_ItemLayoutProcessor_FindBreakNode( - pBreakBeforeNode, pCurActionNode, nCurStage, TRUE)) { - return; - } - if (m_bIsProcessKeep) { - if (ProcessKeepNodesForBreakBefore(pCurActionNode, nCurStage, - pChildContainer)) { - return; - } - goto CheckNextChildContainer; - } - pCurActionNode = pChildContainer; - nCurStage = XFA_ItemLayoutProcessorStages_Container; - return; - } - goto CheckNextChildContainer; - } - case XFA_ItemLayoutProcessorStages_Container: { - pCurActionNode = XFA_LAYOUT_INVALIDNODE; - case XFA_ItemLayoutProcessorStages_BreakAfter: { - if (pCurActionNode == XFA_LAYOUT_INVALIDNODE) { - CXFA_Node* pBreakAfterNode = - pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!m_bKeepBreakFinish && - XFA_ItemLayoutProcessor_FindBreakNode( - pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { - return; - } - } else { - CXFA_Node* pBreakAfterNode = - pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); - if (XFA_ItemLayoutProcessor_FindBreakNode( - pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { - return; - } - } - goto CheckNextChildContainer; - } - } - CheckNextChildContainer : { - CXFA_Node* pNextChildContainer = - pChildContainer == XFA_LAYOUT_INVALIDNODE - ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild, - XFA_OBJECTTYPE_ContainerNode) - : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_OBJECTTYPE_ContainerNode); - while (pNextChildContainer && - pNextChildContainer->HasFlag(XFA_NODEFLAG_LayoutGeneratedNode)) { - CXFA_Node* pSaveNode = pNextChildContainer; - pNextChildContainer = pNextChildContainer->GetNodeItem( - XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode); - if (pSaveNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { - XFA_DeleteLayoutGeneratedNode(pSaveNode); - } - } - if (!pNextChildContainer) { - goto NoMoreChildContainer; - } - FX_BOOL bLastKeep = FALSE; - if (ProcessKeepNodesForCheckNext(pCurActionNode, nCurStage, - pNextChildContainer, bLastKeep)) { - return; - } - if (!m_bKeepBreakFinish && !bLastKeep && - XFA_ItemLayoutProcessor_FindBreakNode( - pNextChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild), - pCurActionNode, nCurStage, TRUE)) { - return; - } - pCurActionNode = pNextChildContainer; - if (m_bIsProcessKeep) { - nCurStage = XFA_ItemLayoutProcessorStages_Keep; - } else { - nCurStage = XFA_ItemLayoutProcessorStages_Container; - } - return; - } - NoMoreChildContainer : { - pCurActionNode = XFA_LAYOUT_INVALIDNODE; - case XFA_ItemLayoutProcessorStages_BookendTrailer: - for (CXFA_Node* pBookendNode = - pCurActionNode == XFA_LAYOUT_INVALIDNODE - ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) - : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pBookendNode; pBookendNode = pBookendNode->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - switch (pBookendNode->GetClassID()) { - case XFA_ELEMENT_Bookend: - case XFA_ELEMENT_Break: - pCurActionNode = pBookendNode; - nCurStage = XFA_ItemLayoutProcessorStages_BookendTrailer; - return; - default: - break; - } - } - } - default: - pCurActionNode = NULL; - nCurStage = XFA_ItemLayoutProcessorStages_Done; - } -} -FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext( - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node*& pNextContainer, - FX_BOOL& bLastKeepNode) { - const bool bCanSplit = pNextContainer->GetIntact() == XFA_ATTRIBUTEENUM_None; - FX_BOOL bNextKeep = FALSE; - if (XFA_ExistContainerKeep(pNextContainer, FALSE)) { - bNextKeep = TRUE; - } - if (bNextKeep && !bCanSplit) { - if (!m_bIsProcessKeep && !m_bKeepBreakFinish) { - m_pKeepHeadNode = pNextContainer; - m_bIsProcessKeep = TRUE; - } - } else { - if (m_bIsProcessKeep && m_pKeepHeadNode) { - m_pKeepTailNode = pNextContainer; - if (!m_bKeepBreakFinish && - XFA_ItemLayoutProcessor_FindBreakNode( - pNextContainer->GetNodeItem(XFA_NODEITEM_FirstChild), - pCurActionNode, nCurStage, TRUE)) { - return TRUE; - } else { - pNextContainer = m_pKeepHeadNode; - m_bKeepBreakFinish = TRUE; - m_pKeepHeadNode = NULL; - m_pKeepTailNode = NULL; - m_bIsProcessKeep = FALSE; - } - } else { - if (m_bKeepBreakFinish) { - bLastKeepNode = TRUE; - } - m_bKeepBreakFinish = FALSE; - } - } - return FALSE; -} -FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore( - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node* pContainerNode) { - if (m_pKeepTailNode == pContainerNode) { - pCurActionNode = m_pKeepHeadNode; - m_bKeepBreakFinish = TRUE; - m_pKeepHeadNode = NULL; - m_pKeepTailNode = NULL; - m_bIsProcessKeep = FALSE; - nCurStage = XFA_ItemLayoutProcessorStages_Container; - return TRUE; - } - CXFA_Node* pBreakAfterNode = - pContainerNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, - nCurStage, FALSE)) { - return TRUE; - } - return FALSE; -} -FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode) { - XFA_ATTRIBUTEENUM ePresence = pNode->GetEnum(XFA_ATTRIBUTE_Presence); - return ePresence == XFA_ATTRIBUTEENUM_Visible || - ePresence == XFA_ATTRIBUTEENUM_Invisible; -} -static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( - CXFA_Node* pFormNode, - FX_FLOAT& fContainerWidth, - FX_FLOAT& fContainerHeight, - FX_BOOL& bContainerWidthAutoSize, - FX_BOOL& bContainerHeightAutoSize) { - fContainerWidth = 0; - fContainerHeight = 0; - bContainerWidthAutoSize = TRUE; - bContainerHeightAutoSize = TRUE; - XFA_ELEMENT eClassID = pFormNode->GetClassID(); - CXFA_Measurement mTmpValue; - if (bContainerWidthAutoSize && - (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && - pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && - mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { - fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); - bContainerWidthAutoSize = FALSE; - } - if (bContainerHeightAutoSize && - (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && - pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && - mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { - fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); - bContainerHeightAutoSize = FALSE; - } - if (bContainerWidthAutoSize && eClassID == XFA_ELEMENT_Subform && - pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && - mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { - fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); - bContainerWidthAutoSize = FALSE; - } - if (bContainerHeightAutoSize && eClassID == XFA_ELEMENT_Subform && - pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && - mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { - fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); - bContainerHeightAutoSize = FALSE; - } -} -static inline void -XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( - CXFA_Node* pFormNode, - FX_BOOL bContainerWidthAutoSize, - FX_FLOAT fContentCalculatedWidth, - FX_FLOAT& fContainerWidth, - FX_BOOL bContainerHeightAutoSize, - FX_FLOAT fContentCalculatedHeight, - FX_FLOAT& fContainerHeight) { - CXFA_Node* pMarginNode = pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - CXFA_Measurement mTmpValue; - if (bContainerWidthAutoSize) { - fContainerWidth = fContentCalculatedWidth; - if (pMarginNode) { - if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_LeftInset, mTmpValue, FALSE)) { - fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); - } - if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_RightInset, mTmpValue, FALSE)) { - fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); - } - } - } - if (bContainerHeightAutoSize) { - fContainerHeight = fContentCalculatedHeight; - if (pMarginNode) { - if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_TopInset, mTmpValue, FALSE)) { - fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); - } - if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_BottomInset, mTmpValue, - FALSE)) { - fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); - } - } - } -} -void CXFA_ItemLayoutProcessor::CalculatePositionedContainerPos( - CXFA_Node* pNode, - FX_FLOAT fWidth, - FX_FLOAT fHeight, - FX_FLOAT& fAbsoluteX, - FX_FLOAT& fAbsoluteY) { - XFA_ATTRIBUTEENUM eAnchorType = pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); - int32_t nAnchorType = 0; - switch (eAnchorType) { - case XFA_ATTRIBUTEENUM_TopLeft: - nAnchorType = 0; - break; - case XFA_ATTRIBUTEENUM_TopCenter: - nAnchorType = 1; - break; - case XFA_ATTRIBUTEENUM_TopRight: - nAnchorType = 2; - break; - case XFA_ATTRIBUTEENUM_MiddleLeft: - nAnchorType = 3; - break; - case XFA_ATTRIBUTEENUM_MiddleCenter: - nAnchorType = 4; - break; - case XFA_ATTRIBUTEENUM_MiddleRight: - nAnchorType = 5; - break; - case XFA_ATTRIBUTEENUM_BottomLeft: - nAnchorType = 6; - break; - case XFA_ATTRIBUTEENUM_BottomCenter: - nAnchorType = 7; - break; - case XFA_ATTRIBUTEENUM_BottomRight: - nAnchorType = 8; - break; - default: - break; - } - static const uint8_t nNextPos[4][9] = {{0, 1, 2, 3, 4, 5, 6, 7, 8}, - {6, 3, 0, 7, 4, 1, 8, 5, 2}, - {8, 7, 6, 5, 4, 3, 2, 1, 0}, - {2, 5, 8, 1, 4, 7, 0, 3, 6}}; - - FX_FLOAT fAnchorX = pNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); - FX_FLOAT fAnchorY = pNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); - int32_t nRotate = - FXSYS_round(pNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); - nRotate = XFA_MapRotation(nRotate) / 90; - int32_t nAbsoluteAnchorType = nNextPos[nRotate][nAnchorType]; - fAbsoluteX = fAnchorX; - fAbsoluteY = fAnchorY; - switch (nAbsoluteAnchorType / 3) { - case 1: - fAbsoluteY -= fHeight / 2; - break; - case 2: - fAbsoluteY -= fHeight; - break; - default: - break; - } - switch (nAbsoluteAnchorType % 3) { - case 1: - fAbsoluteX -= fWidth / 2; - break; - case 2: - fAbsoluteX -= fWidth; - break; - default: - break; - } -} -FX_BOOL CXFA_ItemLayoutProcessor::IncrementRelayoutNode( - CXFA_LayoutProcessor* pLayoutProcessor, - CXFA_Node* pNode, - CXFA_Node* pParentNode) { - return FALSE; -} -void CXFA_ItemLayoutProcessor::DoLayoutPageArea( - CXFA_ContainerLayoutItem* pPageAreaLayoutItem) { - CXFA_Node* pFormNode = pPageAreaLayoutItem->m_pFormNode; - CXFA_Node* pCurChildNode = XFA_LAYOUT_INVALIDNODE; - XFA_ItemLayoutProcessorStages nCurChildNodeStage = - XFA_ItemLayoutProcessorStages_None; - CXFA_LayoutItem* pBeforeItem = NULL; - for (XFA_ItemLayoutProcessor_GotoNextContainerNode( - pCurChildNode, nCurChildNodeStage, pFormNode, FALSE); - pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( - pCurChildNode, nCurChildNodeStage, pFormNode, FALSE)) { - if (nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { - continue; - } - if (pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { - continue; - } - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pCurChildNode, NULL); - pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); - if (!pProcessor->HasLayoutItem()) { - delete pProcessor; - continue; - } - FX_FLOAT fWidth, fHeight; - pProcessor->GetCurrentComponentSize(fWidth, fHeight); - FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; - CalculatePositionedContainerPos(pCurChildNode, fWidth, fHeight, fAbsoluteX, - fAbsoluteY); - pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); - CXFA_LayoutItem* pProcessItem = pProcessor->ExtractLayoutItem(); - if (pBeforeItem == NULL) { - pPageAreaLayoutItem->AddHeadChild(pProcessItem); - } else { - pPageAreaLayoutItem->InsertChild(pBeforeItem, pProcessItem); - } - pBeforeItem = pProcessItem; - delete pProcessor; - } - pBeforeItem = NULL; - CXFA_LayoutItem* pLayoutItem = pPageAreaLayoutItem->m_pFirstChild; - while (pLayoutItem) { - if (!pLayoutItem->IsContentLayoutItem() || - pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_Draw) { - pLayoutItem = pLayoutItem->m_pNextSibling; - continue; - } - if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_Draw) { - CXFA_LayoutItem* pNextLayoutItem = pLayoutItem->m_pNextSibling; - pPageAreaLayoutItem->RemoveChild(pLayoutItem); - if (pBeforeItem == NULL) { - pPageAreaLayoutItem->AddHeadChild(pLayoutItem); - } else { - pPageAreaLayoutItem->InsertChild(pBeforeItem, pLayoutItem); - } - pBeforeItem = pLayoutItem; - pLayoutItem = pNextLayoutItem; - } - } -} -void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer( - CXFA_LayoutContext* pContext) { - if (m_pLayoutItem) - return; - - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - FX_BOOL bIgnoreXY = (m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) != - XFA_ATTRIBUTEENUM_Position); - FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; - FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; - XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( - m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, - bContainerHeightAutoSize); - FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; - FX_FLOAT fHiddenContentCalculatedWidth = 0, - fHiddenContentCalculatedHeight = 0; - if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); - } - int32_t iColIndex = 0; - for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { - if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { - continue; - } - if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { - continue; - } - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); - if (pContext && pContext->m_prgSpecifiedColumnWidths) { - int32_t iColSpan = m_pCurChildNode->GetInteger(XFA_ATTRIBUTE_ColSpan); - if (iColSpan <= - pContext->m_prgSpecifiedColumnWidths->GetSize() - iColIndex) { - pContext->m_fCurColumnWidth = 0; - pContext->m_bCurColumnWidthAvaiable = TRUE; - if (iColSpan == -1) - iColSpan = pContext->m_prgSpecifiedColumnWidths->GetSize(); - for (int32_t i = 0; iColIndex + i < iColSpan; ++i) { - pContext->m_fCurColumnWidth += - pContext->m_prgSpecifiedColumnWidths->GetAt(iColIndex + i); - } - if (pContext->m_fCurColumnWidth == 0) - pContext->m_bCurColumnWidthAvaiable = FALSE; - iColIndex += iColSpan >= 0 ? iColSpan : 0; - } - } - pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, - pContext); - if (!pProcessor->HasLayoutItem()) { - delete pProcessor; - continue; - } - FX_FLOAT fWidth, fHeight; - pProcessor->GetCurrentComponentSize(fWidth, fHeight); - FX_BOOL bChangeParentSize = FALSE; - if (XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { - bChangeParentSize = TRUE; - } - FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; - if (!bIgnoreXY) { - CalculatePositionedContainerPos(m_pCurChildNode, fWidth, fHeight, - fAbsoluteX, fAbsoluteY); - } - pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); - if (bContainerWidthAutoSize) { - FX_FLOAT fChildSuppliedWidth = fAbsoluteX + fWidth; - if (bChangeParentSize) { - if (fContentCalculatedWidth < fChildSuppliedWidth) { - fContentCalculatedWidth = fChildSuppliedWidth; - } - } else { - if (fHiddenContentCalculatedWidth < fChildSuppliedWidth && - m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { - fHiddenContentCalculatedWidth = fChildSuppliedWidth; - } - } - } - if (bContainerHeightAutoSize) { - FX_FLOAT fChildSuppliedHeight = fAbsoluteY + fHeight; - if (bChangeParentSize) { - if (fContentCalculatedHeight < fChildSuppliedHeight) { - fContentCalculatedHeight = fChildSuppliedHeight; - } - } else { - if (fHiddenContentCalculatedHeight < fChildSuppliedHeight && - m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { - fHiddenContentCalculatedHeight = fChildSuppliedHeight; - } - } - } - m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); - delete pProcessor; - } - XFA_VERSION eVersion = m_pFormNode->GetDocument()->GetCurVersionMode(); - if (fContentCalculatedWidth == 0 && eVersion < XFA_VERSION_207) { - fContentCalculatedWidth = fHiddenContentCalculatedWidth; - } - if (fContentCalculatedHeight == 0 && eVersion < XFA_VERSION_207) { - fContentCalculatedHeight = fHiddenContentCalculatedHeight; - } - XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( - m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, - fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, - fContainerHeight); - SetCurrentComponentSize(fContainerWidth, fContainerHeight); -} -static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( - CXFA_ContentLayoutItem* pLayoutItem, - FX_FLOAT& fWidth, - FX_FLOAT& fHeight) { - CXFA_Node* pNode = pLayoutItem->m_pFormNode; - ASSERT(pNode); - XFA_ELEMENT eClassID = pNode->GetClassID(); - switch (eClassID) { - case XFA_ELEMENT_Subform: - case XFA_ELEMENT_Area: - case XFA_ELEMENT_ExclGroup: - case XFA_ELEMENT_SubformSet: { - if (fWidth < -XFA_LAYOUT_FLOAT_PERCISION) { - fWidth = pLayoutItem->m_sSize.x; - } - if (fHeight < -XFA_LAYOUT_FLOAT_PERCISION) { - fHeight = pLayoutItem->m_sSize.y; - } - break; - } - case XFA_ELEMENT_Draw: - case XFA_ELEMENT_Field: { - pNode->GetDocument()->GetParser()->GetNotify()->StartFieldDrawLayout( - pNode, fWidth, fHeight); - break; - } - default: - ASSERT(FALSE); - } -} -static inline void XFA_ItemLayoutProcessor_RelocateTableRowCells( - CXFA_ContentLayoutItem* pLayoutRow, - const CFX_ArrayTemplate<FX_FLOAT>& rgSpecifiedColumnWidths, - XFA_ATTRIBUTEENUM eLayout) { - FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; - FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; - XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( - pLayoutRow->m_pFormNode, fContainerWidth, fContainerHeight, - bContainerWidthAutoSize, bContainerHeightAutoSize); - CXFA_Node* pMarginNode = - pLayoutRow->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; - if (pMarginNode) { - fLeftInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); - fTopInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); - fRightInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); - fBottomInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); - } - FX_FLOAT fContentWidthLimit = - bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX - : fContainerWidth - fLeftInset - fRightInset; - FX_FLOAT fContentCurrentHeight = - pLayoutRow->m_sSize.y - fTopInset - fBottomInset; - FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; - FX_FLOAT fCurrentColX = 0; - int32_t nCurrentColIdx = 0; - FX_BOOL bMetWholeRowCell = FALSE; - for (CXFA_ContentLayoutItem* pLayoutChild = - (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; - pLayoutChild; - pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { - int32_t nOriginalColSpan = - pLayoutChild->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); - int32_t nColSpan = nOriginalColSpan; - FX_FLOAT fColSpanWidth = 0; - if (nColSpan == -1 || - nCurrentColIdx + nColSpan > rgSpecifiedColumnWidths.GetSize()) { - nColSpan = rgSpecifiedColumnWidths.GetSize() - nCurrentColIdx; - } - for (int32_t i = 0; i < nColSpan; i++) { - fColSpanWidth += rgSpecifiedColumnWidths[nCurrentColIdx + i]; - } - if (nColSpan != nOriginalColSpan) { - fColSpanWidth = bMetWholeRowCell ? 0 : std::max(fColSpanWidth, - pLayoutChild->m_sSize.y); - } - if (nOriginalColSpan == -1) { - bMetWholeRowCell = TRUE; - } - pLayoutChild->m_sPos = CFX_PointF(fCurrentColX, 0); - pLayoutChild->m_sSize.x = fColSpanWidth; - if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { - fCurrentColX += fColSpanWidth; - nCurrentColIdx += nColSpan; - FX_FLOAT fNewHeight = - bContainerHeightAutoSize ? -1 : fContentCurrentHeight; - XFA_ItemLayoutProcessor_UpdateWidgetSize(pLayoutChild, fColSpanWidth, - fNewHeight); - pLayoutChild->m_sSize.y = fNewHeight; - if (bContainerHeightAutoSize) { - FX_FLOAT fChildSuppliedHeight = pLayoutChild->m_sSize.y; - if (fContentCalculatedHeight < fChildSuppliedHeight) { - fContentCalculatedHeight = fChildSuppliedHeight; - } - } - } - } - if (bContainerHeightAutoSize) { - for (CXFA_ContentLayoutItem* pLayoutChild = - (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; - pLayoutChild; - pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { - XFA_ItemLayoutProcessor_UpdateWidgetSize( - pLayoutChild, pLayoutChild->m_sSize.x, fContentCalculatedHeight); - FX_FLOAT fOldChildHeight = pLayoutChild->m_sSize.y; - pLayoutChild->m_sSize.y = fContentCalculatedHeight; - CXFA_Node* pParaNode = - pLayoutChild->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Para); - if (pParaNode && pLayoutChild->m_pFirstChild) { - FX_FLOAT fOffHeight = fContentCalculatedHeight - fOldChildHeight; - XFA_ATTRIBUTEENUM eVType = pParaNode->GetEnum(XFA_ATTRIBUTE_VAlign); - switch (eVType) { - case XFA_ATTRIBUTEENUM_Middle: - fOffHeight = fOffHeight / 2; - break; - case XFA_ATTRIBUTEENUM_Bottom: - break; - case XFA_ATTRIBUTEENUM_Top: - default: - fOffHeight = 0; - break; - } - if (fOffHeight > 0) { - for (CXFA_ContentLayoutItem* pInnerLayoutChild = - (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild; - pInnerLayoutChild; - pInnerLayoutChild = - (CXFA_ContentLayoutItem*)pInnerLayoutChild->m_pNextSibling) { - pInnerLayoutChild->m_sPos.y += fOffHeight; - } - } - } - } - } - if (bContainerWidthAutoSize) { - FX_FLOAT fChildSuppliedWidth = fCurrentColX; - if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && - fContentWidthLimit > fChildSuppliedWidth) { - fChildSuppliedWidth = fContentWidthLimit; - } - if (fContentCalculatedWidth < fChildSuppliedWidth) { - fContentCalculatedWidth = fChildSuppliedWidth; - } - } else { - fContentCalculatedWidth = fContainerWidth - fLeftInset - fRightInset; - } - if (pLayoutRow->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) == - XFA_ATTRIBUTEENUM_Rl_row) { - for (CXFA_ContentLayoutItem* pLayoutChild = - (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; - pLayoutChild; - pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { - pLayoutChild->m_sPos.x = fContentCalculatedWidth - - pLayoutChild->m_sPos.x - pLayoutChild->m_sSize.x; - } - } - XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( - pLayoutRow->m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, - fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, - fContainerHeight); - pLayoutRow->m_sSize = CFX_SizeF(fContainerWidth, fContainerHeight); -} -void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) { - if (m_pLayoutItem) - return; - - if (pLayoutNode == NULL) { - pLayoutNode = m_pFormNode; - } - ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; - FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; - XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( - m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, - bContainerHeightAutoSize); - FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; - CXFA_Node* pMarginNode = - m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - FX_FLOAT fLeftInset = 0; - FX_FLOAT fRightInset = 0; - if (pMarginNode) { - fLeftInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); - fRightInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); - } - FX_FLOAT fContentWidthLimit = - bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX - : fContainerWidth - fLeftInset - fRightInset; - CFX_WideStringC wsColumnWidths; - if (pLayoutNode->TryCData(XFA_ATTRIBUTE_ColumnWidths, wsColumnWidths)) { - CFX_WideStringArray widths; - if (FX_SeparateStringW(wsColumnWidths.GetPtr(), wsColumnWidths.GetLength(), - L' ', widths) > 0) { - int32_t iCols = widths.GetSize(); - CFX_WideString wsWidth; - for (int32_t i = 0; i < iCols; i++) { - wsWidth = widths[i]; - wsWidth.TrimLeft(L' '); - if (!wsWidth.IsEmpty()) { - CXFA_Measurement measure(wsWidth); - m_rgSpecifiedColumnWidths.Add(measure.ToUnit(XFA_UNIT_Pt)); - } - } - } - } - int32_t iSpecifiedColumnCount = m_rgSpecifiedColumnWidths.GetSize(); - CXFA_LayoutContext layoutContext; - layoutContext.m_prgSpecifiedColumnWidths = &m_rgSpecifiedColumnWidths; - CXFA_LayoutContext* pLayoutContext = - iSpecifiedColumnCount > 0 ? &layoutContext : NULL; - if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); - } - for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { - layoutContext.m_bCurColumnWidthAvaiable = FALSE; - layoutContext.m_fCurColumnWidth = 0; - if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { - continue; - } - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); - pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, - pLayoutContext); - if (!pProcessor->HasLayoutItem()) { - delete pProcessor; - continue; - } - m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); - delete pProcessor; - } - int32_t iRowCount = 0, iColCount = 0; - { - CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgRowItems; - CFX_ArrayTemplate<int32_t> rgRowItemsSpan; - CFX_ArrayTemplate<FX_FLOAT> rgRowItemsWidth; - for (CXFA_ContentLayoutItem* pLayoutChild = - (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; - pLayoutChild; - pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { - if (pLayoutChild->m_pFormNode->GetClassID() != XFA_ELEMENT_Subform) { - continue; - } - if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { - continue; - } - XFA_ATTRIBUTEENUM eLayout = - pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (eLayout != XFA_ATTRIBUTEENUM_Row && - eLayout != XFA_ATTRIBUTEENUM_Rl_row) { - continue; - } - if (CXFA_ContentLayoutItem* pRowLayoutCell = - (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild) { - rgRowItems.Add(pRowLayoutCell); - int32_t iColSpan = - pRowLayoutCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); - rgRowItemsSpan.Add(iColSpan); - rgRowItemsWidth.Add(pRowLayoutCell->m_sSize.x); - } - } - iRowCount = rgRowItems.GetSize(); - iColCount = 0; - FX_BOOL bMoreColumns = TRUE; - while (bMoreColumns) { - bMoreColumns = FALSE; - FX_BOOL bAutoCol = FALSE; - for (int32_t i = 0; i < iRowCount; i++) { - while (rgRowItems[i] && (rgRowItemsSpan[i] <= 0 || - !XFA_ItemLayoutProcessor_IsTakingSpace( - rgRowItems[i]->m_pFormNode))) { - CXFA_ContentLayoutItem* pNewCell = - (CXFA_ContentLayoutItem*)rgRowItems[i]->m_pNextSibling; - if (rgRowItemsSpan[i] < 0 && XFA_ItemLayoutProcessor_IsTakingSpace( - rgRowItems[i]->m_pFormNode)) { - pNewCell = NULL; - } - rgRowItems[i] = pNewCell; - rgRowItemsSpan[i] = - pNewCell - ? pNewCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan) - : 0; - rgRowItemsWidth[i] = pNewCell ? pNewCell->m_sSize.x : 0; - } - CXFA_ContentLayoutItem* pCell = rgRowItems[i]; - if (!pCell) { - continue; - } - bMoreColumns = TRUE; - if (rgRowItemsSpan[i] == 1) { - if (iColCount >= iSpecifiedColumnCount) { - for (int32_t j = 0, c = iColCount + 1 - - m_rgSpecifiedColumnWidths.GetSize(); - j < c; j++) { - m_rgSpecifiedColumnWidths.Add(0); - } - } - if (m_rgSpecifiedColumnWidths[iColCount] < - XFA_LAYOUT_FLOAT_PERCISION) { - bAutoCol = TRUE; - } - if (bAutoCol && - m_rgSpecifiedColumnWidths[iColCount] < rgRowItemsWidth[i]) { - m_rgSpecifiedColumnWidths[iColCount] = rgRowItemsWidth[i]; - } - } - } - if (bMoreColumns) { - FX_FLOAT fFinalColumnWidth = 0.0f; - if (iColCount < m_rgSpecifiedColumnWidths.GetSize()) - fFinalColumnWidth = m_rgSpecifiedColumnWidths[iColCount]; - for (int32_t i = 0; i < iRowCount; ++i) { - if (!rgRowItems[i]) - continue; - --rgRowItemsSpan[i]; - rgRowItemsWidth[i] -= fFinalColumnWidth; - } - ++iColCount; - } - } - } - FX_FLOAT fCurrentRowY = 0; - for (CXFA_ContentLayoutItem* pLayoutChild = - (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; - pLayoutChild; - pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { - if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { - continue; - } - if (pLayoutChild->m_pFormNode->GetClassID() == XFA_ELEMENT_Subform) { - XFA_ATTRIBUTEENUM eSubformLayout = - pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (eSubformLayout == XFA_ATTRIBUTEENUM_Row || - eSubformLayout == XFA_ATTRIBUTEENUM_Rl_row) { - XFA_ItemLayoutProcessor_RelocateTableRowCells( - pLayoutChild, m_rgSpecifiedColumnWidths, eSubformLayout); - } - } - pLayoutChild->m_sPos.y = fCurrentRowY; - if (bContainerWidthAutoSize) { - pLayoutChild->m_sPos.x = 0; - } else { - switch (pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { - case XFA_ATTRIBUTEENUM_Left: - default: - pLayoutChild->m_sPos.x = 0; - break; - case XFA_ATTRIBUTEENUM_Center: - pLayoutChild->m_sPos.x = - (fContentWidthLimit - pLayoutChild->m_sSize.x) / 2; - break; - case XFA_ATTRIBUTEENUM_Right: - pLayoutChild->m_sPos.x = fContentWidthLimit - pLayoutChild->m_sSize.x; - break; - } - } - if (bContainerWidthAutoSize) { - FX_FLOAT fChildSuppliedWidth = - pLayoutChild->m_sPos.x + pLayoutChild->m_sSize.x; - if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && - fContentWidthLimit > fChildSuppliedWidth) { - fChildSuppliedWidth = fContentWidthLimit; - } - if (fContentCalculatedWidth < fChildSuppliedWidth) { - fContentCalculatedWidth = fChildSuppliedWidth; - } - } - fCurrentRowY += pLayoutChild->m_sSize.y; - } - if (bContainerHeightAutoSize) { - FX_FLOAT fChildSuppliedHeight = fCurrentRowY; - if (fContentCalculatedHeight < fChildSuppliedHeight) { - fContentCalculatedHeight = fChildSuppliedHeight; - } - } - XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( - m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, - fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, - fContainerHeight); - SetCurrentComponentSize(fContainerWidth, fContainerHeight); -} -static uint8_t XFA_ItemLayoutProcessor_HAlignEnumToInt( - XFA_ATTRIBUTEENUM eHAlign) { - switch (eHAlign) { - case XFA_ATTRIBUTEENUM_Center: - return 1; - case XFA_ATTRIBUTEENUM_Right: - return 2; - case XFA_ATTRIBUTEENUM_Left: - default: - return 0; - } -} -static void XFA_ItemLayoutProcessor_UpdatePendedItemLayout( - CXFA_ItemLayoutProcessor* pProcessor, - CXFA_ContentLayoutItem* pLayoutItem) { - XFA_ATTRIBUTEENUM eLayout = - pLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - switch (eLayout) { - case XFA_ATTRIBUTEENUM_Row: - case XFA_ATTRIBUTEENUM_Rl_row: - XFA_ItemLayoutProcessor_RelocateTableRowCells( - pLayoutItem, pProcessor->m_rgSpecifiedColumnWidths, eLayout); - break; - default: - break; - } -} -FX_BOOL CXFA_ItemLayoutProcessor::IsAddNewRowForTrailer( - CXFA_ContentLayoutItem* pTrailerItem) { - if (!pTrailerItem) { - return FALSE; - } - FX_FLOAT fWidth = pTrailerItem->m_sSize.x; - XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (eLayout != XFA_ATTRIBUTEENUM_Tb && m_fWidthLimite > fWidth) { - return FALSE; - } - return TRUE; -} -static void XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( - CXFA_ItemLayoutProcessor* pProcessor, - FX_FLOAT fSplitPos, - CXFA_ContentLayoutItem* pTrailerLayoutItem, - FX_BOOL bUseInherited = FALSE) { - if (!pTrailerLayoutItem) { - return; - } - FX_FLOAT fHeight = pTrailerLayoutItem->m_sSize.y; - if (bUseInherited) { - FX_FLOAT fNewSplitPos = 0; - if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { - fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); - } - if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { - pProcessor->SplitLayoutItem(fNewSplitPos); - } - return; - } - XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, - pTrailerLayoutItem); - CXFA_Node* pMarginNode = - pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; - if (pMarginNode) { - fLeftInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); - fTopInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); - fRightInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); - fBottomInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); - } - if (!pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem)) { - pTrailerLayoutItem->m_sPos.y = pProcessor->m_fLastRowY; - pTrailerLayoutItem->m_sPos.x = pProcessor->m_fLastRowWidth; - pProcessor->m_pLayoutItem->m_sSize.x += pTrailerLayoutItem->m_sSize.x; - pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); - return; - } - FX_FLOAT fNewSplitPos = 0; - if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { - fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); - } - if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { - pProcessor->SplitLayoutItem(fNewSplitPos); - pTrailerLayoutItem->m_sPos.y = fNewSplitPos - fTopInset - fBottomInset; - } else { - pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset; - } - switch (pTrailerLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { - case XFA_ATTRIBUTEENUM_Left: - default: - pTrailerLayoutItem->m_sPos.x = fLeftInset; - break; - case XFA_ATTRIBUTEENUM_Right: - pTrailerLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - - fRightInset - - pTrailerLayoutItem->m_sSize.x; - break; - case XFA_ATTRIBUTEENUM_Center: - pTrailerLayoutItem->m_sPos.x = - (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - - pTrailerLayoutItem->m_sSize.x) / - 2; - break; - } - pProcessor->m_pLayoutItem->m_sSize.y += fHeight; - pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); -} -static void XFA_ItemLayoutProcessor_AddLeaderAfterSplit( - CXFA_ItemLayoutProcessor* pProcessor, - CXFA_ContentLayoutItem* pLeaderLayoutItem) { - XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, pLeaderLayoutItem); - CXFA_Node* pMarginNode = - pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - FX_FLOAT fLeftInset = 0; - FX_FLOAT fRightInset = 0; - if (pMarginNode) { - fLeftInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); - fRightInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); - } - FX_FLOAT fHeight = pLeaderLayoutItem->m_sSize.y; - for (CXFA_ContentLayoutItem* pChildItem = - (CXFA_ContentLayoutItem*)pProcessor->m_pLayoutItem->m_pFirstChild; - pChildItem; - pChildItem = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { - pChildItem->m_sPos.y += fHeight; - } - pLeaderLayoutItem->m_sPos.y = 0; - switch (pLeaderLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { - case XFA_ATTRIBUTEENUM_Left: - default: - pLeaderLayoutItem->m_sPos.x = fLeftInset; - break; - case XFA_ATTRIBUTEENUM_Right: - pLeaderLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - - fRightInset - pLeaderLayoutItem->m_sSize.x; - break; - case XFA_ATTRIBUTEENUM_Center: - pLeaderLayoutItem->m_sPos.x = - (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - - pLeaderLayoutItem->m_sSize.x) / - 2; - break; - } - pProcessor->m_pLayoutItem->m_sSize.y += fHeight; - pProcessor->m_pLayoutItem->AddChild(pLeaderLayoutItem); -} -static void XFA_ItemLayoutProcessor_AddPendingNode( - CXFA_ItemLayoutProcessor* pProcessor, - CXFA_Node* pPendingNode, - FX_BOOL bBreakPending) { - pProcessor->m_PendingNodes.push_back(pPendingNode); - pProcessor->m_bBreakPending = bBreakPending; -} -static FX_FLOAT XFA_ItemLayoutProcessor_InsertPendingItems( - CXFA_ItemLayoutProcessor* pProcessor, - CXFA_Node* pCurChildNode) { - FX_FLOAT fTotalHeight = 0; - if (pProcessor->m_PendingNodes.empty()) { - return fTotalHeight; - } - if (!pProcessor->m_pLayoutItem) { - pProcessor->m_pLayoutItem = - pProcessor->CreateContentLayoutItem(pCurChildNode); - pProcessor->m_pLayoutItem->m_sSize.clear(); - } - while (!pProcessor->m_PendingNodes.empty()) { - std::unique_ptr<CXFA_ItemLayoutProcessor> pPendingProcessor( - new CXFA_ItemLayoutProcessor(pProcessor->m_PendingNodes.front(), - nullptr)); - pProcessor->m_PendingNodes.pop_front(); - pPendingProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); - CXFA_ContentLayoutItem* pPendingLayoutItem = - pPendingProcessor->HasLayoutItem() - ? pPendingProcessor->ExtractLayoutItem() - : nullptr; - if (pPendingLayoutItem) { - XFA_ItemLayoutProcessor_AddLeaderAfterSplit(pProcessor, - pPendingLayoutItem); - if (pProcessor->m_bBreakPending) { - fTotalHeight += pPendingLayoutItem->m_sSize.y; - } - } - } - return fTotalHeight; -} -FX_FLOAT CXFA_ItemLayoutProcessor::InsertKeepLayoutItems() { - FX_FLOAT fTotalHeight = 0; - if (m_arrayKeepItems.GetSize()) { - if (!m_pLayoutItem) { - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - m_pLayoutItem->m_sSize.clear(); - } - for (int32_t iIndex = m_arrayKeepItems.GetSize() - 1; iIndex >= 0; - iIndex--) { - XFA_ItemLayoutProcessor_AddLeaderAfterSplit(this, - m_arrayKeepItems[iIndex]); - fTotalHeight += m_arrayKeepItems[iIndex]->m_sSize.y; - } - m_arrayKeepItems.RemoveAll(); - } - return fTotalHeight; -} -FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepForSplite( - CXFA_ItemLayoutProcessor* pParentProcessor, - CXFA_ItemLayoutProcessor* pChildProcessor, - XFA_ItemLayoutProcessorResult eRetValue, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, - FX_FLOAT& fContentCurRowAvailWidth, - FX_FLOAT& fContentCurRowHeight, - FX_FLOAT& fContentCurRowY, - FX_BOOL& bAddedItemInRow, - FX_BOOL& bForceEndPage, - XFA_ItemLayoutProcessorResult& result) { - if (pParentProcessor == NULL || pChildProcessor == NULL) { - return FALSE; - } - if (pParentProcessor->m_pCurChildNode->GetIntact() != - XFA_ATTRIBUTEENUM_None || - !pChildProcessor->m_bHasAvailHeight) { - if (XFA_ExistContainerKeep(pParentProcessor->m_pCurChildNode, TRUE)) { - FX_FLOAT fChildWidth, fChildHeight; - pChildProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); - CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; - if (pParentProcessor->JudgePutNextPage(pParentProcessor->m_pLayoutItem, - fChildHeight, keepLayoutItems)) { - m_arrayKeepItems.RemoveAll(); - for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); iIndex++) { - CXFA_ContentLayoutItem* pItem = keepLayoutItems.GetAt(iIndex); - pParentProcessor->m_pLayoutItem->RemoveChild(pItem); - fContentCurRowY -= pItem->m_sSize.y; - m_arrayKeepItems.Add(pItem); - } - bAddedItemInRow = TRUE; - bForceEndPage = TRUE; - result = XFA_ItemLayoutProcessorResult_PageFullBreak; - return TRUE; - } - rgCurLineLayoutItem.Add(pChildProcessor->ExtractLayoutItem()); - bAddedItemInRow = TRUE; - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - result = eRetValue; - return TRUE; - } - } - return FALSE; -} -FX_BOOL CXFA_ItemLayoutProcessor::JudgePutNextPage( - CXFA_ContentLayoutItem* pParentLayoutItem, - FX_FLOAT fChildHeight, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems) { - if (pParentLayoutItem == NULL) { - return FALSE; - } - FX_FLOAT fItemsHeight = 0; - for (CXFA_ContentLayoutItem* pChildLayoutItem = - (CXFA_ContentLayoutItem*)pParentLayoutItem->m_pFirstChild; - pChildLayoutItem; - pChildLayoutItem = - (CXFA_ContentLayoutItem*)pChildLayoutItem->m_pNextSibling) { - if (XFA_ExistContainerKeep(pChildLayoutItem->m_pFormNode, FALSE)) { - pKeepItems.Add(pChildLayoutItem); - fItemsHeight += pChildLayoutItem->m_sSize.y; - } else { - pKeepItems.RemoveAll(); - fItemsHeight = 0; - } - } - fItemsHeight += fChildHeight; - if (m_pPageMgr->GetNextAvailContentHeight(fItemsHeight)) { - return TRUE; - } - return FALSE; -} -void CXFA_ItemLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) { - if (!pFormNode) { - return; - } - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( - pFormNode); - for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; - pNode = sIterator.MoveToNext()) { - if (pNode->IsContainerNode()) { - CXFA_Node* pBindNode = pNode->GetBindData(); - if (pBindNode) { - pBindNode->RemoveBindItem(pNode); - pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - } - } - pNode->SetFlag(XFA_NODEFLAG_UnusedNode); - } -} -void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( - CXFA_Node* pLeaderNode, - CXFA_Node* pTrailerNode, - CXFA_ContentLayoutItem* pTrailerItem, - CXFA_Node* pFormNode) { - ProcessUnUseBinds(pLeaderNode); - ProcessUnUseBinds(pTrailerNode); - if (pFormNode == NULL) { - return; - } - if (pFormNode->GetClassID() == XFA_ELEMENT_Overflow || - pFormNode->GetClassID() == XFA_ELEMENT_Break) { - pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); - } - if (pLeaderNode && pFormNode) { - pFormNode->RemoveChild(pLeaderNode); - } - if (pTrailerNode && pFormNode) { - pFormNode->RemoveChild(pTrailerNode); - } - if (pTrailerItem) { - XFA_ReleaseLayoutItem(pTrailerItem); - } -} -static XFA_ItemLayoutProcessorResult XFA_ItemLayoutProcessor_InsertFlowedItem( - CXFA_ItemLayoutProcessor* pThis, - CXFA_ItemLayoutProcessor*& pProcessor, - FX_BOOL bContainerWidthAutoSize, - FX_BOOL bContainerHeightAutoSize, - FX_FLOAT fContainerHeight, - XFA_ATTRIBUTEENUM eFlowStrategy, - uint8_t& uCurHAlignState, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], - FX_BOOL bUseBreakControl, - FX_FLOAT fAvailHeight, - FX_FLOAT fRealHeight, - FX_FLOAT& fContentCurRowY, - FX_FLOAT& fContentWidthLimit, - FX_FLOAT& fContentCurRowAvailWidth, - FX_FLOAT& fContentCurRowHeight, - FX_BOOL& bAddedItemInRow, - FX_BOOL& bForceEndPage, - CXFA_LayoutContext* pLayoutContext = NULL, - FX_BOOL bNewRow = FALSE) { - FX_BOOL bTakeSpace = - XFA_ItemLayoutProcessor_IsTakingSpace(pProcessor->m_pFormNode); - uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( - pThis->m_pCurChildNode->GetEnum(XFA_ATTRIBUTE_HAlign)); - if (bContainerWidthAutoSize) { - uHAlign = 0; - } - if ((eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb && uHAlign < uCurHAlignState) || - (eFlowStrategy == XFA_ATTRIBUTEENUM_Rl_tb && uHAlign > uCurHAlignState)) { - return XFA_ItemLayoutProcessorResult_RowFullBreak; - } - uCurHAlignState = uHAlign; - FX_BOOL bIsOwnSplite = - pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None; - FX_BOOL bUseRealHeight = - bTakeSpace && bContainerHeightAutoSize && bIsOwnSplite && - pProcessor->m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetIntact() == - XFA_ATTRIBUTEENUM_None; - FX_BOOL bIsTransHeight = bTakeSpace; - if (bIsTransHeight && !bIsOwnSplite) { - FX_BOOL bRootForceTb = FALSE; - XFA_ATTRIBUTEENUM eLayoutStrategy = XFA_ItemLayoutProcessor_GetLayout( - pProcessor->m_pFormNode, bRootForceTb); - if (eLayoutStrategy == XFA_ATTRIBUTEENUM_Lr_tb || - eLayoutStrategy == XFA_ATTRIBUTEENUM_Rl_tb) { - bIsTransHeight = FALSE; - } - } - FX_BOOL bUseInherited = FALSE; - CXFA_LayoutContext layoutContext; - if (pThis->m_pPageMgr) { - CXFA_Node* pOverflowNode = - pThis->m_pPageMgr->QueryOverflow(pThis->m_pFormNode); - if (pOverflowNode) { - layoutContext.m_pOverflowNode = pOverflowNode; - layoutContext.m_pOverflowProcessor = pThis; - pLayoutContext = &layoutContext; - } - } - XFA_ItemLayoutProcessorResult eRetValue = XFA_ItemLayoutProcessorResult_Done; - if (!bNewRow || - pProcessor->m_ePreProcessRs == XFA_ItemLayoutProcessorResult_Done) { - eRetValue = pProcessor->DoLayout( - bTakeSpace ? bUseBreakControl : FALSE, - bUseRealHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, - bIsTransHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, - pLayoutContext); - pProcessor->m_ePreProcessRs = eRetValue; - } else { - eRetValue = pProcessor->m_ePreProcessRs; - pProcessor->m_ePreProcessRs = XFA_ItemLayoutProcessorResult_Done; - } - if (pProcessor->HasLayoutItem() == FALSE) { - return eRetValue; - } - FX_FLOAT fChildWidth, fChildHeight; - pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); - if (bUseRealHeight && fRealHeight < XFA_LAYOUT_FLOAT_PERCISION) { - fRealHeight = XFA_LAYOUT_FLOAT_MAX; - fAvailHeight = XFA_LAYOUT_FLOAT_MAX; - } - if (!bTakeSpace || - (fChildWidth <= fContentCurRowAvailWidth + XFA_LAYOUT_FLOAT_PERCISION) || - (fContentWidthLimit - fContentCurRowAvailWidth <= - XFA_LAYOUT_FLOAT_PERCISION)) { - CXFA_Node *pOverflowLeaderNode = NULL, *pOverflowTrailerNode = NULL, - *pFormNode = NULL; - CXFA_ContentLayoutItem* pTrailerLayoutItem = NULL; - FX_BOOL bIsAddTrailerHeight = FALSE; - if (pThis->m_pPageMgr && - pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { - pFormNode = pThis->m_pPageMgr->QueryOverflow(pProcessor->m_pFormNode); - if (pFormNode == NULL && pLayoutContext && - pLayoutContext->m_pOverflowProcessor) { - pFormNode = pLayoutContext->m_pOverflowNode; - bUseInherited = TRUE; - } - if (pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, - pOverflowTrailerNode, FALSE, - FALSE)) { - if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowTrailerNode)) { - if (pOverflowTrailerNode) { - CXFA_ItemLayoutProcessor* pOverflowLeaderProcessor = - new CXFA_ItemLayoutProcessor(pOverflowTrailerNode, NULL); - pOverflowLeaderProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); - pTrailerLayoutItem = - pOverflowLeaderProcessor->HasLayoutItem() - ? pOverflowLeaderProcessor->ExtractLayoutItem() - : NULL; - delete pOverflowLeaderProcessor; - } - if (bUseInherited) { - bIsAddTrailerHeight = - pThis->IsAddNewRowForTrailer(pTrailerLayoutItem); - } else { - bIsAddTrailerHeight = - pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem); - } - if (bIsAddTrailerHeight) { - FX_FLOAT fTrailerHeight = pTrailerLayoutItem->m_sSize.y; - fChildHeight += fTrailerHeight; - bIsAddTrailerHeight = TRUE; - } - } - } - } - if (!bTakeSpace || - fContentCurRowY + fChildHeight <= - fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION || - (!bContainerHeightAutoSize && - pThis->m_fUsedSize + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION >= - fContainerHeight)) { - if (!bTakeSpace || eRetValue == XFA_ItemLayoutProcessorResult_Done) { - if (pProcessor->m_bUseInheriated) { - if (pTrailerLayoutItem) { - XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( - pProcessor, fChildHeight, pTrailerLayoutItem); - } - if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, - pOverflowLeaderNode, FALSE); - } - pProcessor->m_bUseInheriated = FALSE; - } else { - if (bIsAddTrailerHeight) { - fChildHeight -= pTrailerLayoutItem->m_sSize.y; - } - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - } - CXFA_ContentLayoutItem* pChildLayoutItem = - pProcessor->ExtractLayoutItem(); - if (XFA_ExistContainerKeep(pProcessor->m_pFormNode, FALSE) && - pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { - pThis->m_arrayKeepItems.Add(pChildLayoutItem); - } else { - pThis->m_arrayKeepItems.RemoveAll(); - } - rgCurLineLayoutItems[uHAlign].Add(pChildLayoutItem); - bAddedItemInRow = TRUE; - if (bTakeSpace) { - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - } - return XFA_ItemLayoutProcessorResult_Done; - } else { - if (eRetValue == XFA_ItemLayoutProcessorResult_PageFullBreak) { - if (pProcessor->m_bUseInheriated) { - if (pTrailerLayoutItem) { - XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( - pProcessor, fChildHeight, pTrailerLayoutItem); - } - if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode( - pProcessor, pOverflowLeaderNode, FALSE); - } - pProcessor->m_bUseInheriated = FALSE; - } else { - if (bIsAddTrailerHeight) { - fChildHeight -= pTrailerLayoutItem->m_sSize.y; - } - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - } - } - rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); - bAddedItemInRow = TRUE; - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - return eRetValue; - } - } else { - XFA_ItemLayoutProcessorResult eResult; - if (pThis->ProcessKeepForSplite( - pThis, pProcessor, eRetValue, rgCurLineLayoutItems[uHAlign], - fContentCurRowAvailWidth, fContentCurRowHeight, fContentCurRowY, - bAddedItemInRow, bForceEndPage, eResult)) { - return eResult; - } - bForceEndPage = TRUE; - FX_FLOAT fSplitPos = - pProcessor->FindSplitPos(fAvailHeight - fContentCurRowY); - if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { - XFA_ATTRIBUTEENUM eLayout = - pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (eLayout == XFA_ATTRIBUTEENUM_Tb && - eRetValue == XFA_ItemLayoutProcessorResult_Done) { - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); - bAddedItemInRow = TRUE; - if (bTakeSpace) { - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - } - return XFA_ItemLayoutProcessorResult_PageFullBreak; - } - CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; - if (pThis->m_pPageMgr && !pProcessor->m_bUseInheriated && - eRetValue != XFA_ItemLayoutProcessorResult_PageFullBreak) { - pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, - pTempTrailerNode, FALSE, TRUE); - } - if (pTrailerLayoutItem && bIsAddTrailerHeight) { - XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( - pProcessor, fSplitPos, pTrailerLayoutItem, bUseInherited); - } else { - pProcessor->SplitLayoutItem(fSplitPos); - } - if (bUseInherited) { - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - pThis->m_bUseInheriated = TRUE; - } else { - if (pProcessor->m_pLayoutItem->m_pFirstChild && - pProcessor->m_pLayoutItem->m_pFirstChild->m_pNextSibling == - NULL && - pProcessor->m_pLayoutItem->m_pFirstChild->m_pFormNode->HasFlag( - XFA_NODEFLAG_LayoutGeneratedNode)) { - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - } else { - if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode( - pProcessor, pOverflowLeaderNode, FALSE); - } - } - } - if (pProcessor->m_pLayoutItem->m_pNextSibling) { - pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); - rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); - bAddedItemInRow = TRUE; - if (bTakeSpace) { - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - } - } - return XFA_ItemLayoutProcessorResult_PageFullBreak; - } else if (fContentCurRowY <= XFA_LAYOUT_FLOAT_PERCISION) { - pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); - if (pProcessor->m_pPageMgr->GetNextAvailContentHeight(fChildHeight)) { - CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; - if (pThis->m_pPageMgr) { - if (pFormNode == NULL && pLayoutContext) { - pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; - } - pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, - pTempTrailerNode, FALSE, TRUE); - } - if (bUseInherited) { - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - pThis->m_bUseInheriated = TRUE; - } - return XFA_ItemLayoutProcessorResult_PageFullBreak; - } - rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); - bAddedItemInRow = TRUE; - if (bTakeSpace) { - fContentCurRowAvailWidth -= fChildWidth; - if (fContentCurRowHeight < fChildHeight) { - fContentCurRowHeight = fChildHeight; - } - } - if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { - bForceEndPage = FALSE; - } - return eRetValue; - } else { - XFA_ATTRIBUTEENUM eLayout = - pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None && - eLayout == XFA_ATTRIBUTEENUM_Tb) { - if (pThis->m_pPageMgr) { - pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, - pOverflowTrailerNode, FALSE, - TRUE); - } - if (pTrailerLayoutItem) { - XFA_ItemLayoutProcessor_AddTrailerBeforeSplit(pProcessor, fSplitPos, - pTrailerLayoutItem); - } - if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, - pOverflowLeaderNode, FALSE); - } - } else { - if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { - if (pFormNode == NULL && pLayoutContext) { - pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; - } - if (pThis->m_pPageMgr) { - pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, - pOverflowTrailerNode, FALSE, - TRUE); - } - if (bUseInherited) { - pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, - pOverflowTrailerNode, - pTrailerLayoutItem, pFormNode); - pThis->m_bUseInheriated = TRUE; - } - } - } - return XFA_ItemLayoutProcessorResult_PageFullBreak; - } - } - } else { - return XFA_ItemLayoutProcessorResult_RowFullBreak; - } - return XFA_ItemLayoutProcessorResult_Done; -} -XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( - FX_BOOL bUseBreakControl, - XFA_ATTRIBUTEENUM eFlowStrategy, - FX_FLOAT fHeightLimit, - FX_FLOAT fRealHeight, - CXFA_LayoutContext* pContext, - FX_BOOL bRootForceTb) { - m_bHasAvailHeight = TRUE; - FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; - FX_BOOL bBreakDone = FALSE; - FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; - FX_BOOL bForceEndPage = FALSE; - FX_BOOL bIsManualBreak = FALSE; - if (m_pCurChildPreprocessor) { - m_pCurChildPreprocessor->m_ePreProcessRs = - XFA_ItemLayoutProcessorResult_Done; - } - XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( - m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, - bContainerHeightAutoSize); - if (pContext && pContext->m_bCurColumnWidthAvaiable) { - bContainerWidthAutoSize = FALSE; - fContainerWidth = pContext->m_fCurColumnWidth; - } - if (!bContainerHeightAutoSize) { - fContainerHeight -= m_fUsedSize; - } - if (!bContainerHeightAutoSize) { - CXFA_Node* pParentNode = m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent); - FX_BOOL bFocrTb = FALSE; - if (pParentNode && - XFA_ItemLayoutProcessor_GetLayout(pParentNode, bFocrTb) == - XFA_ATTRIBUTEENUM_Row) { - CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem( - XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); - if (pChildContainer && - pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_OBJECTTYPE_ContainerNode)) { - fContainerHeight = 0; - bContainerHeightAutoSize = TRUE; - } - } - } - CXFA_Node* pMarginNode = - m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); - FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; - if (pMarginNode) { - fLeftInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); - fTopInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); - fRightInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); - fBottomInset = - pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); - } - FX_FLOAT fContentWidthLimit = - bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX - : fContainerWidth - fLeftInset - fRightInset; - FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; - FX_FLOAT fAvailHeight = fHeightLimit - fTopInset - fBottomInset; - if (fAvailHeight < 0) { - m_bHasAvailHeight = FALSE; - } - fRealHeight = fRealHeight - fTopInset - fBottomInset; - FX_FLOAT fContentCurRowY = 0; - CXFA_ContentLayoutItem* pLayoutChild = NULL; - if (m_pLayoutItem) { - if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done && - eFlowStrategy != XFA_ATTRIBUTEENUM_Tb) { - pLayoutChild = (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; - for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; - pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { - if (pLayoutNext->m_sPos.y != pLayoutChild->m_sPos.y) { - pLayoutChild = pLayoutNext; - } - } - } - for (CXFA_ContentLayoutItem* pLayoutTempChild = - (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; - pLayoutTempChild != pLayoutChild; - pLayoutTempChild = - (CXFA_ContentLayoutItem*)pLayoutTempChild->m_pNextSibling) { - if (XFA_ItemLayoutProcessor_IsTakingSpace( - pLayoutTempChild->m_pFormNode)) { - FX_FLOAT fChildContentWidth = - pLayoutTempChild->m_sPos.x + pLayoutTempChild->m_sSize.x; - FX_FLOAT fChildContentHeight = - pLayoutTempChild->m_sPos.y + pLayoutTempChild->m_sSize.y; - if (fContentCalculatedWidth < fChildContentWidth) { - fContentCalculatedWidth = fChildContentWidth; - } - if (fContentCalculatedHeight < fChildContentHeight) { - fContentCalculatedHeight = fChildContentHeight; - } - } - } - if (pLayoutChild) { - fContentCurRowY = pLayoutChild->m_sPos.y; - } else { - fContentCurRowY = fContentCalculatedHeight; - } - } - fContentCurRowY += InsertKeepLayoutItems(); - if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_None) { - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); - } - fContentCurRowY += - XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); - if (m_pCurChildPreprocessor && - m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Container) { - if (XFA_ExistContainerKeep(m_pCurChildPreprocessor->GetFormNode(), FALSE)) { - m_pKeepHeadNode = m_pCurChildNode; - m_bIsProcessKeep = TRUE; - m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Keep; - } - } - while (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done) { - FX_FLOAT fContentCurRowHeight = 0; - FX_FLOAT fContentCurRowAvailWidth = fContentWidthLimit; - m_fWidthLimite = fContentCurRowAvailWidth; - CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgCurLineLayoutItems[3]; - uint8_t uCurHAlignState = - (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb ? 0 : 2); - if (pLayoutChild) { - for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; - pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { - if (pLayoutNext->m_pNextSibling == NULL && m_pCurChildPreprocessor && - m_pCurChildPreprocessor->m_pFormNode == pLayoutNext->m_pFormNode) { - pLayoutNext->m_pNext = m_pCurChildPreprocessor->m_pLayoutItem; - m_pCurChildPreprocessor->m_pLayoutItem = pLayoutNext; - break; - } - uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( - pLayoutNext->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)); - rgCurLineLayoutItems[uHAlign].Add(pLayoutNext); - if (eFlowStrategy == XFA_ATTRIBUTEENUM_Lr_tb) { - if (uHAlign > uCurHAlignState) { - uCurHAlignState = uHAlign; - } - } else if (uHAlign < uCurHAlignState) { - uCurHAlignState = uHAlign; - } - if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutNext->m_pFormNode)) { - if (pLayoutNext->m_sSize.y > fContentCurRowHeight) { - fContentCurRowHeight = pLayoutNext->m_sSize.y; - } - fContentCurRowAvailWidth -= pLayoutNext->m_sSize.x; - } - } - if ((CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild == - pLayoutChild) { - m_pLayoutItem->m_pFirstChild = NULL; - } else { - CXFA_ContentLayoutItem* pLayoutNext = - (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; - for (; pLayoutNext; - pLayoutNext = - (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { - if ((CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling == - pLayoutChild) { - pLayoutNext->m_pNextSibling = NULL; - break; - } - } - } - CXFA_ContentLayoutItem* pLayoutNextTemp = - (CXFA_ContentLayoutItem*)pLayoutChild; - while (pLayoutNextTemp) { - pLayoutNextTemp->m_pParent = NULL; - CXFA_ContentLayoutItem* pSaveLayoutNext = - (CXFA_ContentLayoutItem*)pLayoutNextTemp->m_pNextSibling; - pLayoutNextTemp->m_pNextSibling = NULL; - pLayoutNextTemp = pSaveLayoutNext; - } - pLayoutChild = NULL; - } - while (m_pCurChildNode) { - CXFA_ItemLayoutProcessor* pProcessor = NULL; - FX_BOOL bAddedItemInRow = FALSE; - fContentCurRowY += - XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); - switch (m_nCurChildNodeStage) { - case XFA_ItemLayoutProcessorStages_Keep: - case XFA_ItemLayoutProcessorStages_None: - break; - case XFA_ItemLayoutProcessorStages_BreakBefore: { - for (int32_t iIndex = 0; iIndex < m_arrayKeepItems.GetSize(); - iIndex++) { - CXFA_ContentLayoutItem* pItem = m_arrayKeepItems.GetAt(iIndex); - m_pLayoutItem->RemoveChild(pItem); - fContentCalculatedHeight -= pItem->m_sSize.y; - } - CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; - FX_BOOL bCreatePage = FALSE; - if (bUseBreakControl && m_pPageMgr && - m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, TRUE, - pLeaderNode, pTrailerNode, - bCreatePage) && - m_pFormNode->GetClassID() != XFA_ELEMENT_Form && bCreatePage) { - if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); - } - if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { - if (m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() == - XFA_ELEMENT_Form && - m_pLayoutItem == NULL) { - XFA_ItemLayoutProcessor_AddPendingNode(this, pTrailerNode, - TRUE); - } else { - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); - XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, FALSE, - XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext); - delete pProcessor; - pProcessor = NULL; - } - } - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); - bForceEndPage = TRUE; - bIsManualBreak = TRUE; - goto SuspendAndCreateNewRow; - } - } break; - case XFA_ItemLayoutProcessorStages_BreakAfter: { - CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; - FX_BOOL bCreatePage = FALSE; - if (bUseBreakControl && m_pPageMgr && - m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, FALSE, - pLeaderNode, pTrailerNode, - bCreatePage) && - m_pFormNode->GetClassID() != XFA_ELEMENT_Form) { - if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); - XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, FALSE, - XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext); - delete pProcessor; - pProcessor = NULL; - } - if (!bCreatePage) { - if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { - CalculateRowChildPosition( - rgCurLineLayoutItems, eFlowStrategy, - bContainerHeightAutoSize, bContainerWidthAutoSize, - fContentCalculatedWidth, fContentCalculatedHeight, - fContentCurRowY, fContentCurRowHeight, fContentWidthLimit); - rgCurLineLayoutItems->RemoveAll(); - CXFA_ItemLayoutProcessor* pProcessor = - new CXFA_ItemLayoutProcessor(pLeaderNode, NULL); - XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, FALSE, - XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext); - delete pProcessor; - pProcessor = NULL; - } - } else { - if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { - XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); - } - } - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); - if (bCreatePage) { - bForceEndPage = TRUE; - bIsManualBreak = TRUE; - if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done) { - bBreakDone = TRUE; - } - } - goto SuspendAndCreateNewRow; - } - } break; - case XFA_ItemLayoutProcessorStages_BookendLeader: { - CXFA_Node* pLeaderNode = NULL; - if (m_pCurChildPreprocessor) { - pProcessor = m_pCurChildPreprocessor; - m_pCurChildPreprocessor = NULL; - } else if (m_pPageMgr && - m_pPageMgr->ProcessBookendLeaderOrTrailer( - m_pCurChildNode, TRUE, pLeaderNode)) { - pProcessor = new CXFA_ItemLayoutProcessor(pLeaderNode, m_pPageMgr); - } - if (pProcessor) { - if (XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, - fAvailHeight, fRealHeight, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext) != XFA_ItemLayoutProcessorResult_Done) { - goto SuspendAndCreateNewRow; - } else { - delete pProcessor; - pProcessor = NULL; - } - } - } break; - case XFA_ItemLayoutProcessorStages_BookendTrailer: { - CXFA_Node* pTrailerNode = NULL; - if (m_pCurChildPreprocessor) { - pProcessor = m_pCurChildPreprocessor; - m_pCurChildPreprocessor = NULL; - } else if (m_pPageMgr && - m_pPageMgr->ProcessBookendLeaderOrTrailer( - m_pCurChildNode, FALSE, pTrailerNode)) { - pProcessor = new CXFA_ItemLayoutProcessor(pTrailerNode, m_pPageMgr); - } - if (pProcessor) { - if (XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, - fAvailHeight, fRealHeight, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext) != XFA_ItemLayoutProcessorResult_Done) { - goto SuspendAndCreateNewRow; - } else { - delete pProcessor; - pProcessor = NULL; - } - } - } break; - case XFA_ItemLayoutProcessorStages_Container: - ASSERT(m_pCurChildNode->IsContainerNode()); - if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { - break; - } - if (fContentCurRowY >= fHeightLimit + XFA_LAYOUT_FLOAT_PERCISION && - XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { - bForceEndPage = TRUE; - goto SuspendAndCreateNewRow; - } - if (m_pCurChildNode->IsContainerNode()) { - FX_BOOL bNewRow = FALSE; - if (m_pCurChildPreprocessor) { - pProcessor = m_pCurChildPreprocessor; - m_pCurChildPreprocessor = NULL; - bNewRow = TRUE; - } else { - pProcessor = - new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); - } - XFA_ItemLayoutProcessor_InsertPendingItems(pProcessor, - m_pCurChildNode); - XFA_ItemLayoutProcessorResult rs = - XFA_ItemLayoutProcessor_InsertFlowedItem( - this, pProcessor, bContainerWidthAutoSize, - bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, - uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, - fAvailHeight, fRealHeight, fContentCurRowY, - fContentWidthLimit, fContentCurRowAvailWidth, - fContentCurRowHeight, bAddedItemInRow, bForceEndPage, - pContext, bNewRow); - switch (rs) { - case XFA_ItemLayoutProcessorResult_ManualBreak: - bIsManualBreak = TRUE; - case XFA_ItemLayoutProcessorResult_PageFullBreak: - bForceEndPage = TRUE; - case XFA_ItemLayoutProcessorResult_RowFullBreak: - goto SuspendAndCreateNewRow; - case XFA_ItemLayoutProcessorResult_Done: - default: - fContentCurRowY += XFA_ItemLayoutProcessor_InsertPendingItems( - pProcessor, m_pCurChildNode); - delete pProcessor; - pProcessor = NULL; - } - } - break; - case XFA_ItemLayoutProcessorStages_Done: - break; - default: - break; - } - XFA_ItemLayoutProcessor_GotoNextContainerNode( - m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); - if (bAddedItemInRow && eFlowStrategy == XFA_ATTRIBUTEENUM_Tb) { - break; - } else { - continue; - } - SuspendAndCreateNewRow: - if (pProcessor) { - m_pCurChildPreprocessor = pProcessor; - } - break; - } - CalculateRowChildPosition(rgCurLineLayoutItems, eFlowStrategy, - bContainerHeightAutoSize, bContainerWidthAutoSize, - fContentCalculatedWidth, fContentCalculatedHeight, - fContentCurRowY, fContentCurRowHeight, - fContentWidthLimit, bRootForceTb); - m_fWidthLimite = fContentCurRowAvailWidth; - if (bForceEndPage) { - break; - } - } - FX_BOOL bRetValue = - m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done && - m_PendingNodes.empty(); - if (bBreakDone) { - bRetValue = FALSE; - } - XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( - m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, - fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, - fContainerHeight); - if (fContainerHeight >= XFA_LAYOUT_FLOAT_PERCISION || m_pLayoutItem || - bRetValue) { - if (m_pLayoutItem == NULL) { - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - } - if (fContainerHeight < 0) { - fContainerHeight = 0; - } - SetCurrentComponentSize(fContainerWidth, fContainerHeight); - if (bForceEndPage) { - m_fUsedSize = 0; - } else { - m_fUsedSize += m_pLayoutItem->m_sSize.y; - } - } - return bRetValue - ? XFA_ItemLayoutProcessorResult_Done - : (bIsManualBreak ? XFA_ItemLayoutProcessorResult_ManualBreak - : XFA_ItemLayoutProcessorResult_PageFullBreak); -} -FX_BOOL CXFA_ItemLayoutProcessor::CalculateRowChildPosition( - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], - XFA_ATTRIBUTEENUM eFlowStrategy, - FX_BOOL bContainerHeightAutoSize, - FX_BOOL bContainerWidthAutoSize, - FX_FLOAT& fContentCalculatedWidth, - FX_FLOAT& fContentCalculatedHeight, - FX_FLOAT& fContentCurRowY, - FX_FLOAT fContentCurRowHeight, - FX_FLOAT fContentWidthLimit, - FX_BOOL bRootForceTb) { - int32_t nGroupLengths[3] = {0, 0, 0}; - FX_FLOAT fGroupWidths[3] = {0, 0, 0}; - int32_t nTotalLength = 0; - for (int32_t i = 0; i < 3; i++) { - nGroupLengths[i] = rgCurLineLayoutItems[i].GetSize(); - for (int32_t c = nGroupLengths[i], j = 0; j < c; j++) { - nTotalLength++; - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[i][j]->m_pFormNode)) { - fGroupWidths[i] += rgCurLineLayoutItems[i][j]->m_sSize.x; - } - } - } - if (!nTotalLength) { - if (bContainerHeightAutoSize) { - FX_FLOAT fNewHeight = fContentCurRowY; - if (fContentCalculatedHeight > fNewHeight) { - fContentCalculatedHeight = fNewHeight; - } - } - return FALSE; - } - if (m_pLayoutItem == NULL) { - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - } - if (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb) { - FX_FLOAT fCurPos; - fCurPos = 0; - for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { - if (bRootForceTb) { - FX_FLOAT fAbsoluteX, fAbsoluteY; - CalculatePositionedContainerPos(rgCurLineLayoutItems[0][j]->m_pFormNode, - rgCurLineLayoutItems[0][j]->m_sSize.x, - rgCurLineLayoutItems[0][j]->m_sSize.y, - fAbsoluteX, fAbsoluteY); - rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); - } else { - rgCurLineLayoutItems[0][j]->m_sPos = - CFX_PointF(fCurPos, fContentCurRowY); - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[0][j]->m_pFormNode)) { - fCurPos += rgCurLineLayoutItems[0][j]->m_sSize.x; - } - } - m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); - m_fLastRowWidth = fCurPos; - } - fCurPos = (fContentWidthLimit + fGroupWidths[0] - fGroupWidths[1] - - fGroupWidths[2]) / - 2; - for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { - if (bRootForceTb) { - FX_FLOAT fAbsoluteX, fAbsoluteY; - CalculatePositionedContainerPos(rgCurLineLayoutItems[1][j]->m_pFormNode, - rgCurLineLayoutItems[1][j]->m_sSize.x, - rgCurLineLayoutItems[1][j]->m_sSize.y, - fAbsoluteX, fAbsoluteY); - rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); - } else { - rgCurLineLayoutItems[1][j]->m_sPos = - CFX_PointF(fCurPos, fContentCurRowY); - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[1][j]->m_pFormNode)) { - fCurPos += rgCurLineLayoutItems[1][j]->m_sSize.x; - } - } - m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); - m_fLastRowWidth = fCurPos; - } - fCurPos = fContentWidthLimit - fGroupWidths[2]; - for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { - if (bRootForceTb) { - FX_FLOAT fAbsoluteX, fAbsoluteY; - CalculatePositionedContainerPos(rgCurLineLayoutItems[2][j]->m_pFormNode, - rgCurLineLayoutItems[2][j]->m_sSize.x, - rgCurLineLayoutItems[2][j]->m_sSize.y, - fAbsoluteX, fAbsoluteY); - rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); - } else { - rgCurLineLayoutItems[2][j]->m_sPos = - CFX_PointF(fCurPos, fContentCurRowY); - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[2][j]->m_pFormNode)) { - fCurPos += rgCurLineLayoutItems[2][j]->m_sSize.x; - } - } - m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); - m_fLastRowWidth = fCurPos; - } - } else { - FX_FLOAT fCurPos; - fCurPos = fGroupWidths[0]; - for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[0][j]->m_pFormNode)) { - fCurPos -= rgCurLineLayoutItems[0][j]->m_sSize.x; - } - rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); - m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); - m_fLastRowWidth = fCurPos; - } - fCurPos = (fContentWidthLimit + fGroupWidths[0] + fGroupWidths[1] - - fGroupWidths[2]) / - 2; - for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[1][j]->m_pFormNode)) { - fCurPos -= rgCurLineLayoutItems[1][j]->m_sSize.x; - } - rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); - m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); - m_fLastRowWidth = fCurPos; - } - fCurPos = fContentWidthLimit; - for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { - if (XFA_ItemLayoutProcessor_IsTakingSpace( - rgCurLineLayoutItems[2][j]->m_pFormNode)) { - fCurPos -= rgCurLineLayoutItems[2][j]->m_sSize.x; - } - rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); - m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); - m_fLastRowWidth = fCurPos; - } - } - m_fLastRowY = fContentCurRowY; - fContentCurRowY += fContentCurRowHeight; - if (bContainerWidthAutoSize) { - FX_FLOAT fChildSuppliedWidth = fGroupWidths[0]; - if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && - fContentWidthLimit > fChildSuppliedWidth) { - fChildSuppliedWidth = fContentWidthLimit; - } - if (fContentCalculatedWidth < fChildSuppliedWidth) { - fContentCalculatedWidth = fChildSuppliedWidth; - } - } - if (bContainerHeightAutoSize) { - FX_FLOAT fChildSuppliedHeight = fContentCurRowY; - if (fContentCalculatedHeight < fChildSuppliedHeight) { - fContentCalculatedHeight = fChildSuppliedHeight; - } - } - return TRUE; -} -CXFA_Node* CXFA_ItemLayoutProcessor::GetSubformSetParent( - CXFA_Node* pSubformSet) { - if (pSubformSet && pSubformSet->GetClassID() == XFA_ELEMENT_SubformSet) { - CXFA_Node* pParent = pSubformSet->GetNodeItem(XFA_NODEITEM_Parent); - while (pParent) { - if (pParent->GetClassID() != XFA_ELEMENT_SubformSet) { - return pParent; - } - pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); - } - } - return pSubformSet; -} -void CXFA_ItemLayoutProcessor::DoLayoutField() { - if (m_pLayoutItem) - return; - - ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); - m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); - if (!m_pLayoutItem) { - return; - } - CXFA_Document* pDocument = m_pFormNode->GetDocument(); - IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); - FX_FLOAT fHeight = -1; - FX_FLOAT fWidth = -1; - pNotify->StartFieldDrawLayout(m_pFormNode, fWidth, fHeight); - int32_t nRotate = - FXSYS_round(m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); - nRotate = XFA_MapRotation(nRotate); - if (nRotate == 90 || nRotate == 270) { - FX_FLOAT fTmp = fWidth; - fWidth = fHeight; - fHeight = fTmp; - } - SetCurrentComponentSize(fWidth, fHeight); -} -XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( - FX_BOOL bUseBreakControl, - FX_FLOAT fHeightLimit, - FX_FLOAT fRealHeight, - CXFA_LayoutContext* pContext) { - XFA_ELEMENT eClassID = m_pFormNode->GetClassID(); - switch (eClassID) { - case XFA_ELEMENT_Subform: - case XFA_ELEMENT_Area: - case XFA_ELEMENT_ExclGroup: - case XFA_ELEMENT_SubformSet: { - FX_BOOL bRootForceTb = FALSE; - CXFA_Node* pLayoutNode = GetSubformSetParent(m_pFormNode); - XFA_ATTRIBUTEENUM eLayoutStrategy = - XFA_ItemLayoutProcessor_GetLayout(pLayoutNode, bRootForceTb); - switch (eLayoutStrategy) { - case XFA_ATTRIBUTEENUM_Tb: - case XFA_ATTRIBUTEENUM_Lr_tb: - case XFA_ATTRIBUTEENUM_Rl_tb: - return DoLayoutFlowedContainer(bUseBreakControl, eLayoutStrategy, - fHeightLimit, fRealHeight, pContext, - bRootForceTb); - case XFA_ATTRIBUTEENUM_Position: - case XFA_ATTRIBUTEENUM_Row: - case XFA_ATTRIBUTEENUM_Rl_row: - default: - DoLayoutPositionedContainer(pContext); - m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; - return XFA_ItemLayoutProcessorResult_Done; - case XFA_ATTRIBUTEENUM_Table: - DoLayoutTableContainer(pLayoutNode); - m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; - return XFA_ItemLayoutProcessorResult_Done; - } - } - case XFA_ELEMENT_Draw: - case XFA_ELEMENT_Field: - DoLayoutField(); - m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; - return XFA_ItemLayoutProcessorResult_Done; - case XFA_ELEMENT_ContentArea: - return XFA_ItemLayoutProcessorResult_Done; - default: - return XFA_ItemLayoutProcessorResult_Done; - } -} -void CXFA_ItemLayoutProcessor::GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, - FX_FLOAT& fAbsoluteY) { - ASSERT(m_pLayoutItem); - fAbsoluteX = m_pLayoutItem->m_sPos.x; - fAbsoluteY = m_pLayoutItem->m_sPos.y; -} -void CXFA_ItemLayoutProcessor::GetCurrentComponentSize(FX_FLOAT& fWidth, - FX_FLOAT& fHeight) { - ASSERT(m_pLayoutItem); - fWidth = m_pLayoutItem->m_sSize.x; - fHeight = m_pLayoutItem->m_sSize.y; -} -void CXFA_ItemLayoutProcessor::SetCurrentComponentPos(FX_FLOAT fAbsoluteX, - FX_FLOAT fAbsoluteY) { - m_pLayoutItem->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); -} -void CXFA_ItemLayoutProcessor::SetCurrentComponentSize(FX_FLOAT fWidth, - FX_FLOAT fHeight) { - m_pLayoutItem->m_sSize = CFX_SizeF(fWidth, fHeight); -} -FX_BOOL CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur( - CXFA_Node* pFormNode) { - if (pFormNode == NULL) { - return FALSE; - } - CXFA_Node* pTemplate = pFormNode->GetTemplateNode(); - if (!pTemplate) { - pTemplate = pFormNode; - } - CXFA_Occur NodeOccur(pTemplate->GetFirstChildByClass(XFA_ELEMENT_Occur)); - int32_t iMax = NodeOccur.GetMax(); - if (iMax > -1) { - int32_t iCount = - (int32_t)(uintptr_t)m_PendingNodesCount.GetValueAt(pTemplate); - if (iCount >= iMax) { - return FALSE; - } - iCount++; - m_PendingNodesCount.SetAt(pTemplate, (void*)(uintptr_t)(iCount)); - return TRUE; - } - return TRUE; -} diff --git a/xfa/src/fxfa/parser/xfa_layout_itemlayout.h b/xfa/src/fxfa/parser/xfa_layout_itemlayout.h deleted file mode 100644 index 16a91d4f03..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_itemlayout.h +++ /dev/null @@ -1,195 +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_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ - -#include <float.h> - -#include <list> - -#include "core/include/fxcrt/fx_basic.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" - -#define XFA_LAYOUT_INVALIDNODE ((CXFA_Node*)(intptr_t)-1) -#define XFA_LAYOUT_FLOAT_PERCISION (0.0005f) -#define XFA_LAYOUT_FLOAT_MAX FLT_MAX - -class CXFA_ContainerLayoutItem; -class CXFA_ContentLayoutItem; -class CXFA_ItemLayoutProcessor; -class CXFA_LayoutPageMgr; -class CXFA_Node; - -enum XFA_ItemLayoutProcessorResult { - XFA_ItemLayoutProcessorResult_Done, - XFA_ItemLayoutProcessorResult_PageFullBreak, - XFA_ItemLayoutProcessorResult_RowFullBreak, - XFA_ItemLayoutProcessorResult_ManualBreak, -}; - -enum XFA_ItemLayoutProcessorStages { - XFA_ItemLayoutProcessorStages_None, - XFA_ItemLayoutProcessorStages_BookendLeader, - XFA_ItemLayoutProcessorStages_BreakBefore, - XFA_ItemLayoutProcessorStages_Keep, - XFA_ItemLayoutProcessorStages_Container, - XFA_ItemLayoutProcessorStages_BreakAfter, - XFA_ItemLayoutProcessorStages_BookendTrailer, - XFA_ItemLayoutProcessorStages_Done, -}; - -class CXFA_LayoutContext { - public: - CXFA_LayoutContext() - : m_prgSpecifiedColumnWidths(NULL), - m_fCurColumnWidth(0), - m_bCurColumnWidthAvaiable(FALSE), - m_pOverflowProcessor(NULL), - m_pOverflowNode(NULL) {} - ~CXFA_LayoutContext() { m_pOverflowProcessor = NULL; } - CFX_ArrayTemplate<FX_FLOAT>* m_prgSpecifiedColumnWidths; - FX_FLOAT m_fCurColumnWidth; - FX_BOOL m_bCurColumnWidthAvaiable; - CXFA_ItemLayoutProcessor* m_pOverflowProcessor; - CXFA_Node* m_pOverflowNode; -}; - -class CXFA_ItemLayoutProcessor { - public: - CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr); - - XFA_ItemLayoutProcessorResult DoLayout( - FX_BOOL bUseBreakControl, - FX_FLOAT fHeightLimit, - FX_FLOAT fRealHeight = XFA_LAYOUT_FLOAT_MAX, - CXFA_LayoutContext* pContext = NULL); - - void GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, FX_FLOAT& fAbsoluteY); - - void GetCurrentComponentSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight); - - void SetCurrentComponentPos(FX_FLOAT fAbsoluteX, FX_FLOAT fAbsoluteY); - - void SetCurrentComponentSize(FX_FLOAT fWidth, FX_FLOAT fHeight); - inline CXFA_Node* GetFormNode() { return m_pFormNode; } - inline FX_BOOL HasLayoutItem() { return m_pLayoutItem != NULL; } - CXFA_ContentLayoutItem* ExtractLayoutItem(); - - static FX_BOOL IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor, - CXFA_Node* pNode, - CXFA_Node* pParentNode); - static void CalculatePositionedContainerPos(CXFA_Node* pNode, - FX_FLOAT fWidth, - FX_FLOAT fHeight, - FX_FLOAT& fAbsoluteX, - FX_FLOAT& fAbsoluteY); - static FX_BOOL FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem, - FX_FLOAT fCurVerticalOffset, - FX_FLOAT& fProposedSplitPos, - FX_BOOL& bAppChange, - FX_BOOL bCalculateMargin = TRUE); - FX_FLOAT FindSplitPos(FX_FLOAT fProposedSplitPos); - void SplitLayoutItem(CXFA_ContentLayoutItem* pLayoutItem, - CXFA_ContentLayoutItem* pSecondParent, - FX_FLOAT fSplitPos); - void SplitLayoutItem(FX_FLOAT fSplitPos); - FX_BOOL JudgePutNextPage( - CXFA_ContentLayoutItem* pParentLayoutItem, - FX_FLOAT fChildHeight, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems); - FX_BOOL ProcessKeepForSplite( - CXFA_ItemLayoutProcessor* pParentProcessor, - CXFA_ItemLayoutProcessor* pChildProcessor, - XFA_ItemLayoutProcessorResult eRetValue, - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, - FX_FLOAT& fContentCurRowAvailWidth, - FX_FLOAT& fContentCurRowHeight, - FX_FLOAT& fContentCurRowY, - FX_BOOL& bAddedItemInRow, - FX_BOOL& bForceEndPage, - XFA_ItemLayoutProcessorResult& result); - FX_FLOAT InsertKeepLayoutItems(); - void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem); - FX_BOOL CalculateRowChildPosition( - CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], - XFA_ATTRIBUTEENUM eFlowStrategy, - FX_BOOL bContainerHeightAutoSize, - FX_BOOL bContainerWidthAutoSize, - FX_FLOAT& fContentCalculatedWidth, - FX_FLOAT& fContentCalculatedHeight, - FX_FLOAT& fContentCurRowY, - FX_FLOAT fContentCurRowHeight, - FX_FLOAT fContentWidthLimit, - FX_BOOL bRootForceTb = FALSE); - - void ProcessUnUseOverFlow(CXFA_Node* pLeaderNode, - CXFA_Node* pTrailerNode, - CXFA_ContentLayoutItem* pTrailerItem, - CXFA_Node* pFormNode); - void ProcessUnUseBinds(CXFA_Node* pFormNode); - FX_BOOL IsAddNewRowForTrailer(CXFA_ContentLayoutItem* pTrailerItem); - FX_BOOL JudgeLeaderOrTrailerForOccur(CXFA_Node* pFormNode); - CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode); - - protected: - void DoLayoutPositionedContainer(CXFA_LayoutContext* pContext = NULL); - void DoLayoutTableContainer(CXFA_Node* pLayoutNode); - XFA_ItemLayoutProcessorResult DoLayoutFlowedContainer( - FX_BOOL bUseBreakControl, - XFA_ATTRIBUTEENUM eFlowStrategy, - FX_FLOAT fHeightLimit, - FX_FLOAT fRealHeight, - CXFA_LayoutContext* pContext = NULL, - FX_BOOL bRootForceTb = FALSE); - void DoLayoutField(); - void XFA_ItemLayoutProcessor_GotoNextContainerNode( - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node* pParentContainer, - FX_BOOL bUsePageBreak); - - FX_BOOL ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node*& pNextContainer, - FX_BOOL& bLastKeepNode); - - FX_BOOL ProcessKeepNodesForBreakBefore( - CXFA_Node*& pCurActionNode, - XFA_ItemLayoutProcessorStages& nCurStage, - CXFA_Node* pContainerNode); - - CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet); - - public: - FX_BOOL m_bKeepBreakFinish; - FX_BOOL m_bIsProcessKeep; - CXFA_Node* m_pKeepHeadNode; - CXFA_Node* m_pKeepTailNode; - CXFA_Node* m_pFormNode; - CXFA_ContentLayoutItem* m_pLayoutItem; - CXFA_ContentLayoutItem* m_pOldLayoutItem; - CXFA_Node* m_pCurChildNode; - CXFA_ItemLayoutProcessor* m_pCurChildPreprocessor; - XFA_ItemLayoutProcessorStages m_nCurChildNodeStage; - FX_FLOAT m_fUsedSize; - CXFA_LayoutPageMgr* m_pPageMgr; - std::list<CXFA_Node*> m_PendingNodes; - FX_BOOL m_bBreakPending; - CFX_ArrayTemplate<FX_FLOAT> m_rgSpecifiedColumnWidths; - CFX_ArrayTemplate<CXFA_ContentLayoutItem*> m_arrayKeepItems; - CFX_MapPtrToPtr m_PendingNodesCount; - FX_FLOAT m_fLastRowWidth; - FX_FLOAT m_fLastRowY; - FX_FLOAT m_fWidthLimite; - FX_BOOL m_bUseInheriated; - XFA_ItemLayoutProcessorResult m_ePreProcessRs; - FX_BOOL m_bHasAvailHeight; -}; -FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode); - -#endif // XFA_SRC_FXFA_PARSER_XFA_LAYOUT_ITEMLAYOUT_H_ diff --git a/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.cpp deleted file mode 100644 index 0ca5af5ca4..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ /dev/null @@ -1,1931 +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/src/fxfa/parser/xfa_layout_pagemgr_new.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" -#include "xfa/src/fxfa/parser/xfa_layout_itemlayout.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) - : m_pLayoutProcessor(pLayoutProcessor), - m_pTemplatePageSetRoot(nullptr), - m_pPageSetLayoutItemRoot(nullptr), - m_pPageSetCurRoot(nullptr), - m_pCurrentContainerRecord(nullptr), - m_pCurPageArea(nullptr), - m_nAvailPages(0), - m_nCurPageCount(0), - m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), - m_bCreateOverFlowPage(FALSE) {} -CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { - ClearData(); - CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); - CXFA_LayoutItem* pNextLayout = NULL; - for (; pLayoutItem; pLayoutItem = pNextLayout) { - pNextLayout = pLayoutItem->m_pNextSibling; - XFA_ReleaseLayoutItem(pLayoutItem); - } -} -FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { - PrepareLayout(); - CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); - if (!pTemplateNode) { - return FALSE; - } - m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_ELEMENT_PageSet); - ASSERT(m_pTemplatePageSetRoot); - if (m_pPageSetLayoutItemRoot) { - m_pPageSetLayoutItemRoot->m_pParent = NULL; - m_pPageSetLayoutItemRoot->m_pFirstChild = NULL; - m_pPageSetLayoutItemRoot->m_pNextSibling = NULL; - m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; - } else { - m_pPageSetLayoutItemRoot = - new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); - } - m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; - m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, - (void*)m_pPageSetLayoutItemRoot); - XFA_ATTRIBUTEENUM eRelation = - m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); - if (eRelation != XFA_ATTRIBUTEENUM_Unknown) { - m_ePageSetMode = eRelation; - } - InitPageSetMap(); - CXFA_Node* pPageArea = NULL; - int32_t iCount = 0; - for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - pPageArea; - pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pPageArea->GetClassID() == XFA_ELEMENT_PageArea) { - iCount++; - if (pPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea)) { - return TRUE; - } - } - } - if (iCount > 0) { - return FALSE; - } - CXFA_Document* pDocument = pTemplateNode->GetDocument(); - IXFA_ObjFactory* pObjFactory = pDocument->GetParser()->GetFactory(); - pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_ELEMENT_PageArea); - if (!pPageArea) { - pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), - XFA_ELEMENT_PageArea); - if (!pPageArea) { - return FALSE; - } - m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL); - pPageArea->SetFlag(XFA_NODEFLAG_Initialized); - } - CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_ELEMENT_ContentArea); - if (!pContentArea) { - pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), - XFA_ELEMENT_ContentArea); - if (!pContentArea) { - return FALSE; - } - pPageArea->InsertChild(pContentArea, NULL); - pContentArea->SetFlag(XFA_NODEFLAG_Initialized); - pContentArea->SetMeasure(XFA_ATTRIBUTE_X, - CXFA_Measurement(0.25f, XFA_UNIT_In)); - pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, - CXFA_Measurement(0.25f, XFA_UNIT_In)); - pContentArea->SetMeasure(XFA_ATTRIBUTE_W, - CXFA_Measurement(8.0f, XFA_UNIT_In)); - pContentArea->SetMeasure(XFA_ATTRIBUTE_H, - CXFA_Measurement(10.5f, XFA_UNIT_In)); - } - CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_ELEMENT_Medium); - if (!pMedium) { - pMedium = - pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_ELEMENT_Medium); - if (!pContentArea) { - return FALSE; - } - pPageArea->InsertChild(pMedium, NULL); - pMedium->SetFlag(XFA_NODEFLAG_Initialized); - pMedium->SetMeasure(XFA_ATTRIBUTE_Short, - CXFA_Measurement(8.5f, XFA_UNIT_In)); - pMedium->SetMeasure(XFA_ATTRIBUTE_Long, - CXFA_Measurement(11.0f, XFA_UNIT_In)); - } - return TRUE; -} -FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { - FX_BOOL bProBreakBefore = FALSE; - CXFA_Node* pBreakBeforeNode = NULL; - while (pRootSubform) { - for (CXFA_Node* pBreakNode = - pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); - pBreakNode; - pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ELEMENT eType = pBreakNode->GetClassID(); - if (eType == XFA_ELEMENT_BreakBefore || - (eType == XFA_ELEMENT_Break && - pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != - XFA_ATTRIBUTEENUM_Auto)) { - bProBreakBefore = TRUE; - pBreakBeforeNode = pBreakNode; - break; - } - } - if (bProBreakBefore) { - break; - } - bProBreakBefore = TRUE; - pRootSubform = pRootSubform->GetFirstChildByClass(XFA_ELEMENT_Subform); - while (pRootSubform && - !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) { - pRootSubform = pRootSubform->GetNextSameClassSibling(XFA_ELEMENT_Subform); - } - } - CXFA_Node *pLeader, *pTrailer; - if (pBreakBeforeNode && - ExecuteBreakBeforeOrAfter(pBreakBeforeNode, TRUE, pLeader, pTrailer)) { - m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); - return TRUE; - } - return AppendNewPage(TRUE); -} -FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { - if (m_pCurrentContainerRecord != - m_rgProposedContainerRecord.GetTailPosition()) { - return TRUE; - } - CXFA_Node* pPageNode = GetNextAvailPageArea(NULL); - if (!pPageNode) { - return FALSE; - } - if (bFirstTemPage && m_pCurrentContainerRecord == NULL) { - m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); - } - 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); - return; - } - if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { - XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageArea); - return; - } - if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { - XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurContentArea); - return; - } -} -void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( - CXFA_ContainerRecord* pNewRecord, - CXFA_ContainerRecord* pPrevRecord) { - if (!pNewRecord || !pPrevRecord) { - return; - } - if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageSet); - return; - } - if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageArea); - return; - } - if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurContentArea); - return; - } -} -void CXFA_LayoutPageMgr::SubmitContentItem( - CXFA_ContentLayoutItem* pContentLayoutItem, - XFA_ItemLayoutProcessorResult eStatus) { - if (pContentLayoutItem) { - GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); - m_bCreateOverFlowPage = FALSE; - } - if (eStatus != XFA_ItemLayoutProcessorResult_Done) { - if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak && - m_pCurrentContainerRecord == - m_rgProposedContainerRecord.GetTailPosition()) { - AppendNewPage(); - } - m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition(); - m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; - } -} -FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { - CXFA_ContainerLayoutItem* pLayoutItem = - GetCurrentContainerRecord()->pCurContentArea; - if (!pLayoutItem || !pLayoutItem->m_pFormNode) - return 0.0f; - FX_FLOAT fAvailHeight = - pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); - if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) - return fAvailHeight; - if (m_pCurrentContainerRecord == - m_rgProposedContainerRecord.GetHeadPosition()) { - return 0.0f; - } - 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)); - 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, 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; - pTestScript->TryContent(wsExpression); - if (wsExpression.IsEmpty()) { - return TRUE; - } - return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( - pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode)); -} -CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( - CXFA_Node* pPageNode, - FX_BOOL bCreateNew) { - CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); - if (m_pCurrentContainerRecord) { - if (!IsPageSetRootOrderedOccurrence() || pPageNode == NULL) { - *pNewRecord = *GetCurrentContainerRecord(); - m_rgProposedContainerRecord.AddTail(pNewRecord); - return pNewRecord; - } - CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!bCreateNew) { - if (pPageSet == m_pTemplatePageSetRoot) { - pNewRecord->pCurPageSet = m_pPageSetCurRoot; - } else { - CXFA_ContainerLayoutItem* pParentLayoutItem = - (CXFA_ContainerLayoutItem*)pPageSet->GetUserData(XFA_LAYOUTITEMKEY); - if (pParentLayoutItem == NULL) { - pParentLayoutItem = m_pPageSetCurRoot; - } - pNewRecord->pCurPageSet = pParentLayoutItem; - } - } else { - CXFA_ContainerLayoutItem* pParentPageSetLayout = NULL; - if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { - pParentPageSetLayout = - (CXFA_ContainerLayoutItem*)GetCurrentContainerRecord() - ->pCurPageSet->m_pParent; - } else { - pParentPageSetLayout = - (CXFA_ContainerLayoutItem*)pPageSet->GetNodeItem( - XFA_NODEITEM_Parent) - ->GetUserData(XFA_LAYOUTITEMKEY); - } - CXFA_ContainerLayoutItem* pPageSetLayoutItem = - new CXFA_ContainerLayoutItem(pPageSet); - pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); - if (pParentPageSetLayout == NULL) { - CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; - while (pPrePageSet->m_pNextSibling) { - pPrePageSet = (CXFA_ContainerLayoutItem*)pPrePageSet->m_pNextSibling; - } - pPrePageSet->m_pNextSibling = pPageSetLayoutItem; - m_pPageSetCurRoot = pPageSetLayoutItem; - } else { - pParentPageSetLayout->AddChild(pPageSetLayoutItem); - } - pNewRecord->pCurPageSet = pPageSetLayoutItem; - } - } else { - if (pPageNode) { - CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pPageSet == m_pTemplatePageSetRoot) { - pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; - } else { - CXFA_ContainerLayoutItem* pPageSetLayoutItem = - new CXFA_ContainerLayoutItem(pPageSet); - pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); - m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem); - pNewRecord->pCurPageSet = pPageSetLayoutItem; - } - } else { - pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; - } - } - m_rgProposedContainerRecord.AddTail(pNewRecord); - return pNewRecord; -} -void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, - CXFA_Node* pNewPageArea) { - CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = NULL; - if (m_PageArray.GetSize() > m_nAvailPages) { - CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; - pContainerItem->m_pFormNode = pNewPageArea; - m_nAvailPages++; - pNewPageAreaLayoutItem = pContainerItem; - } else { - IXFA_Notify* pNotify = - pNewPageArea->GetDocument()->GetParser()->GetNotify(); - CXFA_ContainerLayoutItem* pContainerItem = - (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); - m_PageArray.Add(pContainerItem); - m_nAvailPages++; - pNotify->OnPageEvent(pContainerItem, XFA_PAGEEVENT_PageAdded, - (void*)(uintptr_t)m_nAvailPages); - pNewPageAreaLayoutItem = pContainerItem; - } - pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); - pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; - pNewRecord->pCurContentArea = NULL; -} -void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( - CXFA_ContainerRecord* pNewRecord, - CXFA_Node* pContentArea) { - if (pContentArea == NULL) { - pNewRecord->pCurContentArea = NULL; - return; - } - CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = - new CXFA_ContainerLayoutItem(pContentArea); - ASSERT(pNewRecord->pCurPageArea); - 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> - sIterator(pRootPageSetLayoutItem); - for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); - pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { - XFA_ATTRIBUTEENUM ePageRelation = - pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); - switch (ePageRelation) { - case XFA_ATTRIBUTEENUM_OrderedOccurrence: - default: { ProcessLastPageSet(); } break; - case XFA_ATTRIBUTEENUM_SimplexPaginated: - case XFA_ATTRIBUTEENUM_DuplexPaginated: { - CXFA_LayoutItem* pLastPageAreaLayoutItem = NULL; - int32_t nPageAreaCount = 0; - for (CXFA_LayoutItem* pPageAreaLayoutItem = - pPageSetLayoutItem->m_pFirstChild; - pPageAreaLayoutItem; - pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { - if (pPageAreaLayoutItem->m_pFormNode->GetClassID() != - XFA_ELEMENT_PageArea) { - continue; - } - nPageAreaCount++; - pLastPageAreaLayoutItem = pPageAreaLayoutItem; - } - if (!pLastPageAreaLayoutItem) { - break; - } - if (!FindPageAreaFromPageSet_SimplexDuplex( - pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, TRUE, - nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only - : XFA_ATTRIBUTEENUM_Last) && - (nPageAreaCount == 1 && - !FindPageAreaFromPageSet_SimplexDuplex( - pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, - TRUE, XFA_ATTRIBUTEENUM_Last))) { - break; - } - CXFA_Node* pNode = m_pCurPageArea; - XFA_ATTRIBUTEENUM eCurChoice = - pNode->GetEnum(XFA_ATTRIBUTE_PagePosition); - if (eCurChoice == XFA_ATTRIBUTEENUM_Last) { - XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; - pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); - XFA_ATTRIBUTEENUM eLastChoice = - pLastPageAreaLayoutItem->m_pFormNode->GetEnum( - XFA_ATTRIBUTE_PagePosition); - if (eLastChoice == XFA_ATTRIBUTEENUM_First && - (ePageRelation == XFA_ATTRIBUTEENUM_SimplexPaginated || - eOddOrEven != XFA_ATTRIBUTEENUM_Odd)) { - CXFA_ContainerRecord* pRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pRecord, pNode); - break; - } - } - FX_BOOL bUsable = TRUE; - CFX_ArrayTemplate<FX_FLOAT> rgUsedHeights; - for (CXFA_LayoutItem* pChildLayoutItem = - pLastPageAreaLayoutItem->m_pFirstChild; - pChildLayoutItem; - pChildLayoutItem = pChildLayoutItem->m_pNextSibling) { - if (pChildLayoutItem->m_pFormNode->GetClassID() != - XFA_ELEMENT_ContentArea) { - continue; - } - FX_FLOAT fUsedHeight = 0; - for (CXFA_LayoutItem* pContentChildLayoutItem = - pChildLayoutItem->m_pFirstChild; - pContentChildLayoutItem; - pContentChildLayoutItem = - pContentChildLayoutItem->m_pNextSibling) { - if (CXFA_ContentLayoutItem* pContent = - pContentChildLayoutItem->AsContentLayoutItem()) { - fUsedHeight += pContent->m_sSize.y; - } - } - rgUsedHeights.Add(fUsedHeight); - } - int32_t iCurContentAreaIndex = -1; - for (CXFA_Node* pContentAreaNode = - pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pContentAreaNode; - pContentAreaNode = - pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pContentAreaNode->GetClassID() != XFA_ELEMENT_ContentArea) { - continue; - } - iCurContentAreaIndex++; - if (rgUsedHeights[iCurContentAreaIndex] > - pContentAreaNode->GetMeasure(XFA_ATTRIBUTE_H) - .ToUnit(XFA_UNIT_Pt) + - XFA_LAYOUT_FLOAT_PERCISION) { - bUsable = FALSE; - break; - } - } - if (bUsable) { - CXFA_LayoutItem* pChildLayoutItem = - pLastPageAreaLayoutItem->m_pFirstChild; - CXFA_Node* pContentAreaNode = - pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pLastPageAreaLayoutItem->m_pFormNode = pNode; - while (pChildLayoutItem && pContentAreaNode) { - if (pChildLayoutItem->m_pFormNode->GetClassID() != - XFA_ELEMENT_ContentArea) { - pChildLayoutItem = pChildLayoutItem->m_pNextSibling; - continue; - } - if (pContentAreaNode->GetClassID() != XFA_ELEMENT_ContentArea) { - pContentAreaNode = - pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling); - continue; - } - pChildLayoutItem->m_pFormNode = pContentAreaNode; - pChildLayoutItem = pChildLayoutItem->m_pNextSibling; - pContentAreaNode = - pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } else if (pNode->GetEnum(XFA_ATTRIBUTE_PagePosition) == - XFA_ATTRIBUTEENUM_Last) { - CXFA_ContainerRecord* pRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pRecord, pNode); - } - } break; - } - } - } -} -int32_t CXFA_LayoutPageMgr::GetPageCount() const { - return m_PageArray.GetSize(); -} -IXFA_LayoutPage* CXFA_LayoutPageMgr::GetPage(int32_t index) const { - if (index < 0 || index >= m_PageArray.GetSize()) - return nullptr; - return m_PageArray[index]; -} -int32_t CXFA_LayoutPageMgr::GetPageIndex(const IXFA_LayoutPage* pPage) const { - // FIXME: Find() method should take const. - return m_PageArray.Find(static_cast<CXFA_ContainerLayoutItem*>( - const_cast<IXFA_LayoutPage*>(pPage))); -} -FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_ELEMENT eBreakType, - XFA_ATTRIBUTEENUM eTargetType, - CXFA_Node* pTarget, - FX_BOOL bStartNew) { - FX_BOOL bRet = FALSE; - switch (eTargetType) { - case XFA_ATTRIBUTEENUM_ContentArea: - if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_ContentArea) { - pTarget = NULL; - } - if (!pTarget || !m_pCurrentContainerRecord || - pTarget != - GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || - bStartNew) { - CXFA_Node* pPageArea = NULL; - if (pTarget) { - pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); - } - pPageArea = GetNextAvailPageArea(pPageArea, pTarget); - bRet = pPageArea != NULL; - } - break; - case XFA_ATTRIBUTEENUM_PageArea: - if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { - pTarget = NULL; - } - if (!pTarget || !m_pCurrentContainerRecord || - pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || - bStartNew) { - CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, NULL, TRUE); - bRet = pPageArea != NULL; - } - break; - case XFA_ATTRIBUTEENUM_PageOdd: - 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: - break; - } - return bRet; -} -FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( - CXFA_Node* pCurNode, - FX_BOOL bBefore, - CXFA_Node*& pBreakLeaderTemplate, - CXFA_Node*& pBreakTrailerTemplate) { - XFA_ELEMENT eType = pCurNode->GetClassID(); - switch (eType) { - case XFA_ELEMENT_BreakBefore: - case XFA_ELEMENT_BreakAfter: { - CFX_WideStringC wsBreakLeader, wsBreakTrailer; - CXFA_Node* pFormNode = pCurNode->GetNodeItem( - XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); - CXFA_Node* pContainer = pFormNode->GetTemplateNode(); - FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; - CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Script); - if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) { - return FALSE; - } - CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); - CXFA_Node* pTarget = - XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); - wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); - wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); - pBreakLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); - pBreakTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); - if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, - bStartNew)) { - return TRUE; - } else { - if (m_rgProposedContainerRecord.GetCount() > 0 && - m_pCurrentContainerRecord == - m_rgProposedContainerRecord.GetHeadPosition() && - eType == XFA_ELEMENT_BreakBefore) { - CXFA_Node* pParentNode = pFormNode->GetNodeItem( - XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); - if (!pParentNode || - pFormNode != - pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, - XFA_OBJECTTYPE_ContainerNode)) { - break; - } - pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Form) { - break; - } - return TRUE; - } - } - } break; - case XFA_ELEMENT_Break: { - FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; - CFX_WideStringC wsTarget = pCurNode->GetCData( - bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); - CXFA_Node* pTarget = - XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); - if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter, - pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before - : XFA_ATTRIBUTE_After), - pTarget, bStartNew)) { - return TRUE; - } - } break; - default: - break; - } - 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, - CXFA_Node*& pBreakLeaderNode, - CXFA_Node*& pBreakTrailerNode, - FX_BOOL& bCreatePage) { - CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; - CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode); - if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { - bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, - pLeaderTemplate, pTrailerTemplate); - CXFA_Document* pDocument = pBreakNode->GetDocument(); - CXFA_Node* pDataScope = NULL; - pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode); - if (pLeaderTemplate) { - if (!pDataScope) { - pDataScope = XFA_DataMerge_FindDataScope(pFormNode); - } - pBreakLeaderNode = pDocument->DataMerge_CopyContainer( - pLeaderTemplate, pFormNode, pDataScope, TRUE); - pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); - XFA_SetLayoutGeneratedNodeFlag(pBreakLeaderNode); - } - if (pTrailerTemplate) { - if (!pDataScope) { - pDataScope = XFA_DataMerge_FindDataScope(pFormNode); - } - pBreakTrailerNode = pDocument->DataMerge_CopyContainer( - pTrailerTemplate, pFormNode, pDataScope, TRUE); - pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); - XFA_SetLayoutGeneratedNodeFlag(pBreakTrailerNode); - } - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( - CXFA_Node* pBookendNode, - FX_BOOL bLeader, - CXFA_Node*& pBookendAppendNode) { - CXFA_Node* pLeaderTemplate = NULL; - CXFA_Node* pFormNode = pBookendNode->GetNodeItem( - XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); - if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { - CXFA_Document* pDocument = pBookendNode->GetDocument(); - CXFA_Node* pDataScope = NULL; - if (pLeaderTemplate) { - if (!pDataScope) { - pDataScope = XFA_DataMerge_FindDataScope(pFormNode); - } - pBookendAppendNode = pDocument->DataMerge_CopyContainer( - pLeaderTemplate, pFormNode, pDataScope, TRUE); - pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); - XFA_SetLayoutGeneratedNodeFlag(pBookendAppendNode); - return TRUE; - } - } - return FALSE; -} -CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, - CXFA_Node*& pLeaderTemplate, - CXFA_Node*& pTrailerTemplate, - FX_BOOL bCreatePage) { - CFX_WideStringC wsOverflowLeader, wsOverflowTrailer; - CXFA_Node* pContainer = - pOverflowNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode) - ->GetTemplateNode(); - if (pOverflowNode->GetClassID() == XFA_ELEMENT_Break) { - CFX_WideStringC wsOverflowLeader; - CFX_WideStringC wsOverflowTarget; - CFX_WideStringC wsOverflowTrailer; - pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); - pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); - pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); - if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || - !wsOverflowTarget.IsEmpty()) { - if (!wsOverflowTarget.IsEmpty() && bCreatePage && - !m_bCreateOverFlowPage) { - CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, - TRUE, wsOverflowTarget); - if (pTarget) { - m_bCreateOverFlowPage = TRUE; - switch (pTarget->GetClassID()) { - case XFA_ELEMENT_PageArea: - RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, - pTarget, TRUE); - break; - case XFA_ELEMENT_ContentArea: - RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, - pTarget, TRUE); - break; - default: - break; - } - } - } - if (!bCreatePage) { - pLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); - pTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); - } - return pOverflowNode; - } - return NULL; - } else if (pOverflowNode->GetClassID() == XFA_ELEMENT_Overflow) { - CFX_WideStringC wsOverflowTarget; - pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); - 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); - if (pTarget) { - m_bCreateOverFlowPage = TRUE; - switch (pTarget->GetClassID()) { - case XFA_ELEMENT_PageArea: - RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, - TRUE); - break; - case XFA_ELEMENT_ContentArea: - RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, - pTarget, TRUE); - break; - default: - break; - } - } - } - if (!bCreatePage) { - pLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); - pTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); - } - return pOverflowNode; - } - return NULL; -} -FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, - CXFA_Node*& pLeaderNode, - CXFA_Node*& pTrailerNode, - FX_BOOL bDataMerge, - FX_BOOL bCreatePage) { - if (pFormNode == NULL) { - return FALSE; - } - CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; - FX_BOOL bIsOverflowNode = FALSE; - if (pFormNode->GetClassID() == XFA_ELEMENT_Overflow || - pFormNode->GetClassID() == XFA_ELEMENT_Break) { - bIsOverflowNode = TRUE; - } - for (CXFA_Node* pCurNode = - bIsOverflowNode ? pFormNode - : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { - if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, - bCreatePage)) { - if (bIsOverflowNode) { - pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); - } - CXFA_Document* pDocument = pCurNode->GetDocument(); - CXFA_Node* pDataScope = NULL; - if (pLeaderTemplate) { - if (!pDataScope) { - pDataScope = XFA_DataMerge_FindDataScope(pFormNode); - } - pLeaderNode = pDocument->DataMerge_CopyContainer( - pLeaderTemplate, pFormNode, pDataScope, TRUE); - pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); - XFA_SetLayoutGeneratedNodeFlag(pLeaderNode); - } - if (pTrailerTemplate) { - if (!pDataScope) { - pDataScope = XFA_DataMerge_FindDataScope(pFormNode); - } - pTrailerNode = pDocument->DataMerge_CopyContainer( - pTrailerTemplate, pFormNode, pDataScope, TRUE); - pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); - XFA_SetLayoutGeneratedNodeFlag(pTrailerNode); - } - return TRUE; - } - if (bIsOverflowNode) { - break; - } - } - return FALSE; -} -FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( - CXFA_Node* pBookendNode, - FX_BOOL bLeader, - CXFA_Node*& pBookendAppendTemplate) { - CFX_WideStringC wsBookendLeader; - CXFA_Node* pContainer = - pBookendNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode) - ->GetTemplateNode(); - if (pBookendNode->GetClassID() == XFA_ELEMENT_Break) { - pBookendNode->TryCData( - bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, - wsBookendLeader); - if (!wsBookendLeader.IsEmpty()) { - pBookendAppendTemplate = - XFA_ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); - return TRUE; - } - return FALSE; - } else if (pBookendNode->GetClassID() == XFA_ELEMENT_Bookend) { - pBookendNode->TryCData( - bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, - wsBookendLeader); - pBookendAppendTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( - CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea, - FX_BOOL bNewPage, - FX_BOOL bQuery) { - if (pPageSet == NULL && pStartChild == NULL) { - return FALSE; - } - if (IsPageSetRootOrderedOccurrence()) { - return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, - pTargetPageArea, pTargetContentArea, - bNewPage, bQuery); - } - XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord - ? XFA_ATTRIBUTEENUM_Rest - : XFA_ATTRIBUTEENUM_First; - return FindPageAreaFromPageSet_SimplexDuplex( - pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage, - bQuery, ePreferredPosition); -} -FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( - CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea, - FX_BOOL bNewPage, - FX_BOOL bQuery) { - int32_t iPageSetCount = 0; - if (!pStartChild && !bQuery) { - m_pPageSetMap.Lookup(pPageSet, iPageSetCount); - int32_t iMax = -1; - CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_ELEMENT_Occur); - if (pOccurNode) { - pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); - } - if (iMax >= 0 && iMax <= iPageSetCount) { - return FALSE; - } - } - FX_BOOL bRes = FALSE; - CXFA_Node* pCurrentNode = - pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) - : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pCurrentNode; - pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { - if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { - if (pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea) == - NULL) { - if (pTargetPageArea == pCurrentNode) { - CreateMinPageRecord(pCurrentNode, TRUE); - pTargetPageArea = NULL; - } - continue; - } - if (!bQuery) { - CXFA_ContainerRecord* pNewRecord = - CreateContainerRecord(pCurrentNode, pStartChild == NULL); - AddPageAreaLayoutItem(pNewRecord, pCurrentNode); - if (pTargetContentArea == NULL) { - pTargetContentArea = - pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - } - AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); - } - m_pCurPageArea = pCurrentNode; - m_nCurPageCount = 1; - bRes = TRUE; - break; - } - if (!bQuery) { - CreateMinPageRecord(pCurrentNode, FALSE); - } - } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { - if (FindPageAreaFromPageSet_Ordered(pCurrentNode, NULL, pTargetPageArea, - pTargetContentArea, bNewPage, - bQuery)) { - bRes = TRUE; - break; - } - if (!bQuery) { - CreateMinPageSetRecord(pCurrentNode, TRUE); - } - } - } - if (!pStartChild && bRes && !bQuery) { - m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); - } - return bRes; -} -FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( - CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea, - FX_BOOL bNewPage, - FX_BOOL bQuery, - XFA_ATTRIBUTEENUM ePreferredPosition) { - const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; - CXFA_Node *pPreferredPageArea = NULL, *pFallbackPageArea = NULL; - CXFA_Node* pCurrentNode = NULL; - if (!pStartChild || pStartChild->GetClassID() == XFA_ELEMENT_PageArea) { - pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); - } else { - pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); - } - for (; pCurrentNode; - pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { - if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) { - continue; - } - XFA_ATTRIBUTEENUM eCurPagePosition = - pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition); - if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) { - if (eCurPagePosition != ePreferredPosition) { - continue; - } - if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated || - pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == - XFA_ATTRIBUTEENUM_Any) { - pPreferredPageArea = pCurrentNode; - break; - } - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pNewRecord, pCurrentNode); - AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( - XFA_ELEMENT_ContentArea)); - pPreferredPageArea = pCurrentNode; - return FALSE; - } else if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) { - if (eCurPagePosition != ePreferredPosition) { - continue; - } - if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || - pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == - XFA_ATTRIBUTEENUM_Any) { - pPreferredPageArea = pCurrentNode; - break; - } - return FALSE; - } - if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { - if (pCurrentNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea) == - NULL) { - if (pTargetPageArea == pCurrentNode) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pNewRecord, pCurrentNode); - pTargetPageArea = NULL; - } - continue; - } - if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest && - eCurPagePosition == XFA_ATTRIBUTEENUM_Any) || - eCurPagePosition == ePreferredPosition) { - pPreferredPageArea = pCurrentNode; - break; - } else if (eCurPagePosition == eFallbackPosition && - !pFallbackPageArea) { - pFallbackPageArea = pCurrentNode; - } - } else if (pTargetPageArea && - !MatchPageAreaOddOrEven(pTargetPageArea, FALSE)) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pNewRecord, pCurrentNode); - AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( - XFA_ELEMENT_ContentArea)); - } - } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { - if (FindPageAreaFromPageSet_SimplexDuplex( - pCurrentNode, NULL, pTargetPageArea, pTargetContentArea, bNewPage, - bQuery, ePreferredPosition)) { - break; - } - } - } - CXFA_Node* pCurPageArea = NULL; - if (pPreferredPageArea) { - pCurPageArea = pPreferredPageArea; - } else if (pFallbackPageArea) { - pCurPageArea = pFallbackPageArea; - } - if (!pCurPageArea) { - return FALSE; - } - if (!bQuery) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pNewRecord, pCurPageArea); - if (pTargetContentArea == NULL) { - pTargetContentArea = - pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - } - AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); - } - m_pCurPageArea = pCurPageArea; - return TRUE; -} -FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, - FX_BOOL bLastMatch) { - if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated) { - return TRUE; - } - XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; - pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); - if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) { - int32_t iPageCount = GetPageCount(); - if (bLastMatch) { - return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1 - : iPageCount % 2 == 0; - } - return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 - : iPageCount % 2 == 1; - } - return TRUE; -} -CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( - CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea, - FX_BOOL bNewPage, - FX_BOOL bQuery) { - if (m_pCurPageArea == NULL) { - FindPageAreaFromPageSet(m_pTemplatePageSetRoot, NULL, pTargetPageArea, - pTargetContentArea, bNewPage, bQuery); - ASSERT(m_pCurPageArea); - return m_pCurPageArea; - } - if (pTargetPageArea == NULL || pTargetPageArea == m_pCurPageArea) { - if (!bNewPage && GetNextContentArea(pTargetContentArea)) { - return m_pCurPageArea; - } - if (IsPageSetRootOrderedOccurrence()) { - int32_t iMax = -1; - CXFA_Node* pOccurNode = - m_pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_Occur); - if (pOccurNode) { - pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); - } - if ((iMax < 0 || m_nCurPageCount < iMax)) { - if (!bQuery) { - CXFA_ContainerRecord* pNewRecord = - CreateContainerRecord(m_pCurPageArea); - AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); - if (pTargetContentArea == NULL) { - pTargetContentArea = - m_pCurPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - } - AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); - } - m_nCurPageCount++; - return m_pCurPageArea; - } - } - } - if (!bQuery && IsPageSetRootOrderedOccurrence()) { - CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); - } - if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), - m_pCurPageArea, pTargetPageArea, - pTargetContentArea, bNewPage, bQuery)) { - return m_pCurPageArea; - } - CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); - while (TRUE) { - if (FindPageAreaFromPageSet(pPageSet, NULL, pTargetPageArea, - pTargetContentArea, bNewPage, bQuery)) { - return m_pCurPageArea; - } - if (!bQuery && IsPageSetRootOrderedOccurrence()) { - CreateMinPageSetRecord(pPageSet); - } - if (FindPageAreaFromPageSet(NULL, pPageSet, pTargetPageArea, - pTargetContentArea, bNewPage, bQuery)) { - return m_pCurPageArea; - } - if (pPageSet == m_pTemplatePageSetRoot) { - break; - } - pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); - } - 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; - if (pContentArea == NULL) { - pContentArea = - pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); - if (pContentArea == NULL) { - return FALSE; - } - } else { - if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { - return FALSE; - } - CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; - if (!XFA_LayoutPageMgr_CheckContentAreaNotUsed( - GetCurrentContainerRecord()->pCurPageArea, pContentArea, - pContentAreaLayout)) { - return FALSE; - } - if (pContentAreaLayout) { - if (pContentAreaLayout->m_pFormNode != pCurContentNode) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - pNewRecord->pCurContentArea = pContentAreaLayout; - return TRUE; - } else { - return FALSE; - } - } - } - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddContentAreaLayoutItem(pNewRecord, pContentArea); - return TRUE; -} -void CXFA_LayoutPageMgr::InitPageSetMap() { - if (!IsPageSetRootOrderedOccurrence()) { - return; - } - CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); - for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; - pPageSetNode = sIterator.MoveToNext()) { - if (pPageSetNode->GetClassID() == XFA_ELEMENT_PageSet) { - XFA_ATTRIBUTEENUM eRelation = - pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); - if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) { - m_pPageSetMap.SetAt(pPageSetNode, 0); - } - } - } -} -int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, - FX_BOOL bTargetPageArea, - FX_BOOL bCreateLast) { - if (pPageArea == NULL) { - return 0; - } - CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_ELEMENT_Occur); - int32_t iMin = 0; - if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || - bTargetPageArea) { - CXFA_Node* pContentArea = - pPageArea->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - if (iMin < 1 && bTargetPageArea && !pContentArea) { - iMin = 1; - } - int32_t i = 0; - if (bCreateLast) { - i = m_nCurPageCount; - } - for (; i < iMin; i++) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); - AddPageAreaLayoutItem(pNewRecord, pPageArea); - AddContentAreaLayoutItem(pNewRecord, pContentArea); - } - } - return iMin; -} -void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, - FX_BOOL bCreateAll) { - if (pPageSet == NULL) { - return; - } - int32_t iCurSetCount = 0; - if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) { - return; - } - if (bCreateAll) { - iCurSetCount = 0; - } - CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_ELEMENT_Occur); - int32_t iMin = 0; - if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) { - if (iCurSetCount < iMin) { - for (int32_t i = 0; i < iMin - iCurSetCount; i++) { - for (CXFA_Node* pCurrentPageNode = - pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); - pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - if (pCurrentPageNode->GetClassID() == XFA_ELEMENT_PageArea) { - CreateMinPageRecord(pCurrentPageNode, FALSE); - } else if (pCurrentPageNode->GetClassID() == XFA_ELEMENT_PageSet) { - CreateMinPageSetRecord(pCurrentPageNode, TRUE); - } - } - } - m_pPageSetMap.SetAt(pPageSet, iMin); - } - } -} -void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { - if (pRecordNode == NULL) { - return; - } - for (CXFA_Node* pCurrentNode = - pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pCurrentNode; - pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageArea) { - CreateMinPageRecord(pCurrentNode, FALSE); - } else if (pCurrentNode->GetClassID() == XFA_ELEMENT_PageSet) { - CreateMinPageSetRecord(pCurrentNode, TRUE); - } - } -} -void CXFA_LayoutPageMgr::ProcessLastPageSet() { - CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); - CreateNextMinRecord(m_pCurPageArea); - CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); - while (TRUE) { - CreateMinPageSetRecord(pPageSet); - if (pPageSet == m_pTemplatePageSetRoot) { - break; - } - CreateNextMinRecord(pPageSet); - pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); - } -} -FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { - CXFA_Node* pCurContentNode = - GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; - if (pCurContentNode == NULL) { - return FALSE; - } - pCurContentNode = - pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); - if (pCurContentNode) { - FX_FLOAT fNextContentHeight = - pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); - return fNextContentHeight > fChildHeight; - } - CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; - CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_ELEMENT_Occur); - int32_t iMax = 0; - if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { - if (m_nCurPageCount == iMax) { - CXFA_Node* pSrcPage = m_pCurPageArea; - int32_t nSrcPageCount = m_nCurPageCount; - FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); - CXFA_Node* pNextPage = GetNextAvailPageArea(NULL, NULL, FALSE, TRUE); - m_pCurPageArea = pSrcPage; - m_nCurPageCount = nSrcPageCount; - CXFA_ContainerRecord* pPrevRecord = - (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( - psSrcRecord); - while (psSrcRecord) { - FX_POSITION psSaveRecord = psSrcRecord; - CXFA_ContainerRecord* pInsertRecord = - (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( - psSrcRecord); - RemoveLayoutRecord(pInsertRecord, pPrevRecord); - delete pInsertRecord; - m_rgProposedContainerRecord.RemoveAt(psSaveRecord); - } - if (pNextPage) { - CXFA_Node* pContentArea = - pNextPage->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - if (pContentArea) { - FX_FLOAT fNextContentHeight = - pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); - if (fNextContentHeight > fChildHeight) { - return TRUE; - } - } - } - return FALSE; - } - } - CXFA_Node* pContentArea = - pPageNode->GetFirstChildByClass(XFA_ELEMENT_ContentArea); - FX_FLOAT fNextContentHeight = - pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); - if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION) { - return TRUE; - } - if (fNextContentHeight > fChildHeight) { - return TRUE; - } - return FALSE; -} -void CXFA_LayoutPageMgr::ClearData() { - ClearRecordList(); -} -void CXFA_LayoutPageMgr::ClearRecordList() { - if (!m_pTemplatePageSetRoot) { - return; - } - if (m_rgProposedContainerRecord.GetCount() > 0) { - FX_POSITION sPos; - sPos = m_rgProposedContainerRecord.GetHeadPosition(); - while (sPos) { - CXFA_ContainerRecord* pRecord = - (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext(sPos); - delete pRecord; - } - m_rgProposedContainerRecord.RemoveAll(); - } - m_pCurrentContainerRecord = NULL; - m_pCurPageArea = NULL; - m_nCurPageCount = 0; - m_bCreateOverFlowPage = FALSE; - m_pPageSetMap.RemoveAll(); -} -CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( - CXFA_Node* pFormNode) { - return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( - pFormNode); -} -static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, - IXFA_Notify* pNotify, - IXFA_DocLayout* 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; - while (pCurLayoutItem) { - pNextLayoutItem = pCurLayoutItem->m_pNextSibling; - if (pCurLayoutItem->IsContentLayoutItem()) { - FX_DWORD dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); - if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { - IXFA_Notify* pNotify = - m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); - IXFA_DocLayout* pDocLayout = - m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); - if (pCurLayoutItem->m_pFirstChild) { - XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); - } - pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, - XFA_LAYOUTEVENT_ItemRemoving); - delete pCurLayoutItem; - pCurLayoutItem = pNextLayoutItem; - continue; - } - if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> - sIterator(pCurLayoutItem->m_pFormNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE); - } - } - } - if (pCurLayoutItem->m_pFirstChild) { - SaveLayoutItem(pCurLayoutItem); - } - pCurLayoutItem->m_pParent = NULL; - pCurLayoutItem->m_pNextSibling = NULL; - pCurLayoutItem->m_pFirstChild = NULL; - if (!pCurLayoutItem->IsContentLayoutItem() && - pCurLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageArea) { - delete pCurLayoutItem; - } - pCurLayoutItem = pNextLayoutItem; - } -} -CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( - CXFA_Node* pFormNode, - CXFA_LayoutContext* pLayoutContext) { - for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { - if (pCurNode->GetClassID() == XFA_ELEMENT_Break) { - CFX_WideStringC wsOverflowLeader; - CFX_WideStringC wsOverflowTarget; - CFX_WideStringC wsOverflowTrailer; - pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); - pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); - pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); - if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || - !wsOverflowTarget.IsEmpty()) { - return pCurNode; - } - return NULL; - } else if (pCurNode->GetClassID() == XFA_ELEMENT_Overflow) { - return pCurNode; - } - } - return NULL; -} -void CXFA_LayoutPageMgr::MergePageSetContents() { - CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); - IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); - IXFA_DocLayout* pDocLayout = pDocument->GetDocLayout(); - CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); - { - for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); - iIndex++) { - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> - sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - if (pNode->IsContainerNode()) { - CXFA_Node* pBindNode = pNode->GetBindData(); - if (pBindNode) { - pBindNode->RemoveBindItem(pNode); - pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - } - } - pNode->SetFlag(XFA_NODEFLAG_UnusedNode); - } - } - } - int32_t iIndex = 0; - CXFA_Node* pPendingPageSet = NULL; - for (; pRootLayout; - pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { - pPendingPageSet = NULL; - CXFA_NodeIteratorTemplate< - CXFA_ContainerLayoutItem, - CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> - iterator(pRootLayout); - CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); - ASSERT(pRootPageSetContainerItem->m_pFormNode->GetClassID() == - XFA_ELEMENT_PageSet); - if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { - pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); - iIndex++; - } - if (!pPendingPageSet) { - if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() == - XFA_XDPPACKET_Template) { - pPendingPageSet = - pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); - } else { - pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; - } - } - if (pRootPageSetContainerItem->m_pFormNode->GetUserData( - XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { - pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, - NULL); - } - pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; - pPendingPageSet->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); - pContainerItem; pContainerItem = iterator.MoveToNext()) { - CXFA_Node* pNode = pContainerItem->m_pFormNode; - if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { - continue; - } - switch (pNode->GetClassID()) { - case XFA_ELEMENT_PageSet: { - CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; - pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( - pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE); - } break; - case XFA_ELEMENT_PageArea: { - CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; - CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; - FX_BOOL bIsExistForm = TRUE; - for (int32_t iLevel = 0; iLevel < 3; iLevel++) { - pFormLayout = (CXFA_ContainerLayoutItem*)pFormLayout->m_pFirstChild; - if (iLevel == 2) { - while (pFormLayout && - !XFA_ItemLayoutProcessor_IsTakingSpace( - pFormLayout->m_pFormNode)) { - pFormLayout = - (CXFA_ContainerLayoutItem*)pFormLayout->m_pNextSibling; - } - } - if (pFormLayout == NULL) { - bIsExistForm = FALSE; - break; - } - } - if (bIsExistForm) { - CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; - if (pContainerItem->m_pOldSubform && - pContainerItem->m_pOldSubform != pNewSubform) { - CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( - pDocument, pContainerItem->m_pFormNode->GetClassID(), - pContainerItem->m_pFormNode->GetNameHash(), pParentNode); - CXFA_ContainerIterator sIterator(pExistingNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pNode->GetUserData(XFA_LAYOUTITEMKEY)); - if (pLayoutItem) { - pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, - XFA_LAYOUTEVENT_ItemRemoving); - delete pLayoutItem; - } - } - } - if (pExistingNode) { - pParentNode->RemoveChild(pExistingNode); - } - } - pContainerItem->m_pOldSubform = pNewSubform; - } - pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( - pContainerItem->m_pFormNode, pParentNode, - ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE); - } break; - case XFA_ELEMENT_ContentArea: { - CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; - for (CXFA_Node* pChildNode = - pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { - continue; - } - pContainerItem->m_pFormNode = pChildNode; - break; - } - } break; - default: - break; - } - } - if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { - CXFA_Node* pFormToplevelSubform = - pDocument->GetXFAObject(XFA_HASHCODE_Form) - ->AsNode() - ->GetFirstChildByClass(XFA_ELEMENT_Subform); - pFormToplevelSubform->InsertChild(pPendingPageSet); - } - pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); - pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized); - } - pPendingPageSet = GetRootLayoutItem()->m_pFormNode; - while (pPendingPageSet) { - CXFA_Node* pNextPendingPageSet = - pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet); - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> - sIterator(pPendingPageSet); - CXFA_Node* pNode = sIterator.GetCurrent(); - while (pNode) { - if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { - if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { - XFA_ELEMENT eCurId = pNode->GetClassID(); - if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) { - CXFA_ContainerIterator iteChild(pNode); - CXFA_Node* pChildNode = iteChild.MoveToNext(); - for (; pChildNode; pChildNode = iteChild.MoveToNext()) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pChildNode->GetUserData(XFA_LAYOUTITEMKEY)); - if (pLayoutItem) { - pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, - XFA_LAYOUTEVENT_ItemRemoving); - delete pLayoutItem; - } - } - } else if (eCurId != XFA_ELEMENT_ContentArea) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pNode->GetUserData(XFA_LAYOUTITEMKEY)); - if (pLayoutItem) { - pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, - XFA_LAYOUTEVENT_ItemRemoving); - delete pLayoutItem; - } - } - CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); - pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); - pNode = pNext; - } else { - pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); - pNode->SetFlag(XFA_NODEFLAG_Initialized); - pNode = sIterator.MoveToNext(); - } - } else { - pNode->SetFlag(XFA_NODEFLAG_Initialized); - pNode = sIterator.MoveToNext(); - } - } - pPendingPageSet = pNextPendingPageSet; - } -} -void CXFA_LayoutPageMgr::LayoutPageSetContents() { - CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); - for (; pRootLayoutItem; - pRootLayoutItem = - (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { - CXFA_NodeIteratorTemplate< - CXFA_ContainerLayoutItem, - CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> - iterator(pRootLayoutItem); - for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); - pContainerItem; pContainerItem = iterator.MoveToNext()) { - CXFA_Node* pNode = pContainerItem->m_pFormNode; - switch (pNode->GetClassID()) { - case XFA_ELEMENT_PageArea: - m_pLayoutProcessor->GetRootRootItemLayoutProcessor() - ->DoLayoutPageArea(pContainerItem); - break; - default: - break; - } - } - } -} -void XFA_SyncContainer(IXFA_Notify* pNotify, - IXFA_DocLayout* pDocLayout, - CXFA_LayoutItem* pContainerItem, - FX_DWORD dwRelevant, - FX_BOOL bVisible, - int32_t nPageIndex) { - FX_BOOL bVisibleItem = FALSE; - FX_DWORD dwStatus = 0; - FX_DWORD 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(); - IXFA_Notify* pNotify = - m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); - int32_t nPageIdx = -1; - CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); - for (; pRootLayoutItem; - pRootLayoutItem = - (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { - CXFA_NodeIteratorTemplate< - CXFA_ContainerLayoutItem, - CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> - iteratorParent(pRootLayoutItem); - for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); - pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { - switch (pContainerItem->m_pFormNode->GetClassID()) { - case XFA_ELEMENT_PageArea: { - nPageIdx++; - FX_DWORD dwRelevant = - XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; - CXFA_NodeIteratorTemplate<CXFA_LayoutItem, - CXFA_TraverseStrategy_LayoutItem> - iterator(pContainerItem); - CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent(); - while (pChildLayoutItem) { - CXFA_ContentLayoutItem* pContentItem = - pChildLayoutItem->AsContentLayoutItem(); - if (!pContentItem) { - pChildLayoutItem = iterator.MoveToNext(); - continue; - } - FX_BOOL bVisible = - (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == - XFA_ATTRIBUTEENUM_Visible); - FX_DWORD dwRelevantChild = - XFA_GetRelevant(pContentItem->m_pFormNode, dwRelevant); - XFA_SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, - dwRelevantChild, bVisible, nPageIdx); - pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); - } - } break; - default: - break; - } - } - } - int32_t nPage = m_PageArray.GetSize(); - 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); - delete pPage; - } - ClearRecordList(); -} -void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { - CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; - while (pNode) { - pNext = pNode->m_pNextSibling; - pNode->m_pParent = NULL; - XFA_ReleaseLayoutItem_NoPageArea(pNode); - pNode = pNext; - } - if (pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageArea) { - delete pLayoutItem; - } -} -void CXFA_LayoutPageMgr::PrepareLayout() { - m_pPageSetCurRoot = NULL; - m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; - m_nAvailPages = 0; - ClearRecordList(); - if (!m_pPageSetLayoutItemRoot) { - return; - } - CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; - if (pRootLayoutItem && - pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { - CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; - pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); - if (pPageSetFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { - XFA_ReleaseLayoutItem(pRootLayoutItem); - m_pPageSetLayoutItemRoot = NULL; - pRootLayoutItem = NULL; - pPageSetFormNode = NULL; - m_PageArray.RemoveAll(); - } - while (pPageSetFormNode) { - CXFA_Node* pNextPageSet = - pPageSetFormNode->GetNextSameClassSibling(XFA_ELEMENT_PageSet); - pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) - ->RemoveChild(pPageSetFormNode, FALSE); - pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( - pPageSetFormNode); - pPageSetFormNode = pNextPageSet; - } - } - pRootLayoutItem = m_pPageSetLayoutItemRoot; - CXFA_ContainerLayoutItem* pNextLayout = NULL; - for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { - pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; - SaveLayoutItem(pRootLayoutItem); - delete pRootLayoutItem; - } - m_pPageSetLayoutItemRoot = NULL; -} diff --git a/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h b/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h deleted file mode 100644 index 5f6607f7cc..0000000000 --- a/xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h +++ /dev/null @@ -1,152 +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_SRC_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ - -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_layout_itemlayout.h" - -class CXFA_ContainerRecord { - public: - CXFA_ContainerRecord(CXFA_ContainerLayoutItem* pPageSet = NULL, - CXFA_ContainerLayoutItem* pPageArea = NULL, - CXFA_ContainerLayoutItem* pContentArea = NULL) - : pCurPageSet(pPageSet), - pCurPageArea(pPageArea), - pCurContentArea(pContentArea) {} - CXFA_ContainerLayoutItem* pCurPageSet; - CXFA_ContainerLayoutItem* pCurPageArea; - CXFA_ContainerLayoutItem* pCurContentArea; -}; -class CXFA_LayoutPageMgr { - public: - CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor); - ~CXFA_LayoutPageMgr(); - FX_BOOL InitLayoutPage(CXFA_Node* pFormNode); - FX_BOOL PrepareFirstPage(CXFA_Node* pRootSubform); - FX_FLOAT GetAvailHeight(); - FX_BOOL GetNextAvailContentHeight(FX_FLOAT fChildHeight); - void SubmitContentItem(CXFA_ContentLayoutItem* pContentLayoutItem, - XFA_ItemLayoutProcessorResult eStatus); - void FinishPaginatedPageSets(); - void SyncLayoutData(); - int32_t GetPageCount() const; - IXFA_LayoutPage* GetPage(int32_t index) const; - int32_t GetPageIndex(const IXFA_LayoutPage* pPage) const; - inline CXFA_ContainerLayoutItem* GetRootLayoutItem() const { - return m_pPageSetLayoutItemRoot; - } - FX_BOOL ProcessBreakBeforeOrAfter(CXFA_Node* pBreakNode, - FX_BOOL bBefore, - CXFA_Node*& pBreakLeaderNode, - CXFA_Node*& pBreakTrailerNode, - FX_BOOL& bCreatePage); - FX_BOOL ProcessOverflow(CXFA_Node* pFormNode, - CXFA_Node*& pLeaderNode, - CXFA_Node*& pTrailerNode, - FX_BOOL bDataMerge = FALSE, - FX_BOOL bCreatePage = TRUE); - CXFA_Node* QueryOverflow(CXFA_Node* pFormNode, - CXFA_LayoutContext* pLayoutContext = NULL); - FX_BOOL ProcessBookendLeaderOrTrailer(CXFA_Node* pBookendNode, - FX_BOOL bLeader, - CXFA_Node*& pBookendAppendNode); - CXFA_LayoutItem* FindOrCreateLayoutItem(CXFA_Node* pFormNode); - - protected: - FX_BOOL AppendNewPage(FX_BOOL bFirstTemPage = FALSE); - void ReorderPendingLayoutRecordToTail(CXFA_ContainerRecord* pNewRecord, - CXFA_ContainerRecord* pPrevRecord); - void RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, - CXFA_ContainerRecord* pPrevRecord); - inline CXFA_ContainerRecord* GetCurrentContainerRecord() { - CXFA_ContainerRecord* result = - ((CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetAt( - m_pCurrentContainerRecord)); - ASSERT(result); - return result; - } - CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = NULL, - FX_BOOL bCreateNew = FALSE); - void AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, - CXFA_Node* pNewPageArea); - void AddContentAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, - CXFA_Node* pContentArea); - FX_BOOL RunBreak(XFA_ELEMENT eBreakType, - XFA_ATTRIBUTEENUM eTargetType, - CXFA_Node* pTarget, - FX_BOOL bStartNew); - CXFA_Node* BreakOverflow(CXFA_Node* pOverflowNode, - CXFA_Node*& pLeaderTemplate, - CXFA_Node*& pTrailerTemplate, - FX_BOOL bCreatePage = TRUE); - FX_BOOL ResolveBookendLeaderOrTrailer(CXFA_Node* pBookendNode, - FX_BOOL bLeader, - CXFA_Node*& pBookendAppendTemplate); - FX_BOOL ExecuteBreakBeforeOrAfter(CXFA_Node* pCurNode, - FX_BOOL bBefore, - CXFA_Node*& pBreakLeaderTemplate, - CXFA_Node*& pBreakTrailerTemplate); - - int32_t CreateMinPageRecord(CXFA_Node* pPageArea, - FX_BOOL bTargetPageArea, - FX_BOOL bCreateLast = FALSE); - void CreateMinPageSetRecord(CXFA_Node* pPageSet, FX_BOOL bCreateAll = FALSE); - void CreateNextMinRecord(CXFA_Node* pRecordNode); - FX_BOOL FindPageAreaFromPageSet(CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea = NULL, - CXFA_Node* pTargetContentArea = NULL, - FX_BOOL bNewPage = FALSE, - FX_BOOL bQuery = FALSE); - FX_BOOL FindPageAreaFromPageSet_Ordered(CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea = NULL, - CXFA_Node* pTargetContentArea = NULL, - FX_BOOL bNewPage = FALSE, - FX_BOOL bQuery = FALSE); - FX_BOOL FindPageAreaFromPageSet_SimplexDuplex( - CXFA_Node* pPageSet, - CXFA_Node* pStartChild, - CXFA_Node* pTargetPageArea = NULL, - CXFA_Node* pTargetContentArea = NULL, - FX_BOOL bNewPage = FALSE, - FX_BOOL bQuery = FALSE, - XFA_ATTRIBUTEENUM ePreferredPosition = XFA_ATTRIBUTEENUM_First); - FX_BOOL MatchPageAreaOddOrEven(CXFA_Node* pPageArea, FX_BOOL bLastMatch); - CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea = NULL, - FX_BOOL bNewPage = FALSE, - FX_BOOL bQuery = FALSE); - FX_BOOL GetNextContentArea(CXFA_Node* pTargetContentArea); - void InitPageSetMap(); - void ProcessLastPageSet(); - inline FX_BOOL IsPageSetRootOrderedOccurrence() { - return m_ePageSetMode == XFA_ATTRIBUTEENUM_OrderedOccurrence; - } - void ClearData(); - void ClearRecordList(); - void MergePageSetContents(); - void LayoutPageSetContents(); - void PrepareLayout(); - void SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem); - CXFA_LayoutProcessor* m_pLayoutProcessor; - CXFA_Node* m_pTemplatePageSetRoot; - CXFA_ContainerLayoutItem* m_pPageSetLayoutItemRoot; - CXFA_ContainerLayoutItem* m_pPageSetCurRoot; - FX_POSITION m_pCurrentContainerRecord; - CFX_PtrList m_rgProposedContainerRecord; - CXFA_Node* m_pCurPageArea; - int32_t m_nAvailPages; - int32_t m_nCurPageCount; - XFA_ATTRIBUTEENUM m_ePageSetMode; - FX_BOOL m_bCreateOverFlowPage; - CFX_MapPtrTemplate<CXFA_Node*, int32_t> m_pPageSetMap; - CFX_ArrayTemplate<CXFA_ContainerLayoutItem*> m_PageArray; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ diff --git a/xfa/src/fxfa/parser/xfa_locale.cpp b/xfa/src/fxfa/parser/xfa_locale.cpp deleted file mode 100644 index 5fc465f872..0000000000 --- a/xfa/src/fxfa/parser/xfa_locale.cpp +++ /dev/null @@ -1,377 +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/src/fxfa/parser/xfa_locale.h" - -#include "core/include/fxcrt/fx_xml.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -static const FX_WCHAR g_FX_Percent[] = L"z,zzz,zzz,zzz,zzz,zzz%"; -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() { - if (m_pLocaleData) { - delete m_pLocaleData; - } -} -void CXFA_XMLLocale::Release() { - delete this; -} -CFX_WideString CXFA_XMLLocale::GetName() { - return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString(); -} -void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const { - CFX_ByteString bsSymbols; - CFX_WideString wsName; - switch (eType) { - case FX_LOCALENUMSYMBOL_Decimal: - bsSymbols = "numberSymbols"; - wsName = FX_WSTRC(L"decimal"); - break; - case FX_LOCALENUMSYMBOL_Grouping: - bsSymbols = "numberSymbols"; - wsName = FX_WSTRC(L"grouping"); - break; - case FX_LOCALENUMSYMBOL_Percent: - bsSymbols = "numberSymbols"; - wsName = FX_WSTRC(L"percent"); - break; - case FX_LOCALENUMSYMBOL_Minus: - bsSymbols = "numberSymbols"; - wsName = FX_WSTRC(L"minus"); - break; - case FX_LOCALENUMSYMBOL_Zero: - bsSymbols = "numberSymbols"; - wsName = FX_WSTRC(L"zero"); - break; - case FX_LOCALENUMSYMBOL_CurrencySymbol: - bsSymbols = "currencySymbols"; - wsName = FX_WSTRC(L"symbol"); - break; - case FX_LOCALENUMSYMBOL_CurrencyName: - bsSymbols = "currencySymbols"; - wsName = FX_WSTRC(L"isoname"); - break; - default: - return; - } - CXML_Element* pElement = m_pLocaleData->GetElement("", bsSymbols); - if (!pElement) { - return; - } - GetPattern(pElement, CFX_ByteStringC((const FX_CHAR*)bsSymbols, - bsSymbols.GetLength() - 1), - wsName, wsNumSymbol); -} -void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { - if (!m_pLocaleData) { - return; - } - CFX_ByteString bsSpace; - CXML_Element* pNumberSymbols = - m_pLocaleData->GetElement(bsSpace, "dateTimeSymbols"); - if (!pNumberSymbols) { - return; - } - wsDtSymbol = pNumberSymbols->GetContent(0); -} -void CXFA_XMLLocale::GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr) const { - wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr); -} -void CXFA_XMLLocale::GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr) const { - wsDayName = GetCalendarSymbol("day", nWeek, bAbbr); -} -void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM) const { - wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, FALSE); -} -void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const { - IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); - pProvider->GetTimeZone(tz); -} -void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { - wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, FALSE); -} -CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, - int index, - FX_BOOL bAbbr) const { - CFX_ByteString pstrSymbolNames = symbol + "Names"; - CFX_WideString wsSymbolName = L""; - if (m_pLocaleData) { - CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols"); - if (pChild) { - CXML_Element* pSymbolNames = pChild->GetElement("", pstrSymbolNames); - if (pSymbolNames) { - if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { - pSymbolNames = pChild->GetElement("", pstrSymbolNames, 1); - } - if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { - CXML_Element* pSymbolName = - pSymbolNames->GetElement("", symbol, index); - if (pSymbolName) { - wsSymbolName = pSymbolName->GetContent(0); - } - } - } - } - } - return wsSymbolName; -} -void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns"); - if (pElement == NULL) { - return; - } - CFX_WideString wsName; - switch (eType) { - case FX_LOCALEDATETIMESUBCATEGORY_Short: - wsName = L"short"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Default: - case FX_LOCALEDATETIMESUBCATEGORY_Medium: - wsName = L"med"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Full: - wsName = L"full"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Long: - wsName = L"long"; - break; - } - GetPattern(pElement, "datePattern", wsName, wsPattern); -} -void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns"); - if (pElement == NULL) { - return; - } - CFX_WideString wsName; - switch (eType) { - case FX_LOCALEDATETIMESUBCATEGORY_Short: - wsName = L"short"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Default: - case FX_LOCALEDATETIMESUBCATEGORY_Medium: - wsName = L"med"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Full: - wsName = L"full"; - break; - case FX_LOCALEDATETIMESUBCATEGORY_Long: - wsName = L"long"; - break; - } - GetPattern(pElement, "timePattern", wsName, wsPattern); -} -void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const { - CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns"); - if (pElement == NULL) { - return; - } - switch (eType) { - case FX_LOCALENUMPATTERN_Percent: - wsPattern = g_FX_Percent; - break; - case FX_LOCALENUMPATTERN_Currency: - wsPattern = g_FX_Currency; - break; - case FX_LOCALENUMPATTERN_Decimal: - wsPattern = g_FX_Decimal; - break; - case FX_LOCALENUMPATTERN_Integer: - wsPattern = g_FX_Integer; - break; - } -} -void CXFA_XMLLocale::GetPattern(CXML_Element* pElement, - const CFX_ByteStringC& bsTag, - const CFX_WideStringC& wsName, - CFX_WideString& wsPattern) const { - int32_t iCount = pElement->CountElements("", bsTag); - for (int32_t i = 0; i < iCount; i++) { - CXML_Element* pChild = pElement->GetElement("", bsTag, i); - if (pChild->GetAttrValue("name") == wsName) { - wsPattern = pChild->GetContent(0); - return; - } - } -} -CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) { - m_pLocale = pLocale; -} -CXFA_NodeLocale::~CXFA_NodeLocale() {} -void CXFA_NodeLocale::Release() { - delete this; -} -CFX_WideString CXFA_NodeLocale::GetName() { - return m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) : NULL; -} -void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const { - switch (eType) { - case FX_LOCALENUMSYMBOL_Decimal: - wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"decimal")); - break; - case FX_LOCALENUMSYMBOL_Grouping: - wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"grouping")); - break; - case FX_LOCALENUMSYMBOL_Percent: - wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"percent")); - break; - case FX_LOCALENUMSYMBOL_Minus: - wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"minus")); - break; - case FX_LOCALENUMSYMBOL_Zero: - wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"zero")); - break; - case FX_LOCALENUMSYMBOL_CurrencySymbol: - wsNumSymbol = GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"symbol")); - break; - case FX_LOCALENUMSYMBOL_CurrencyName: - wsNumSymbol = - GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"isoname")); - break; - } -} -void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { - CXFA_Node* pSymbols = - m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_DateTimeSymbols) : NULL; - wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); -} -void CXFA_NodeLocale::GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr) const { - wsMonthName = GetCalendarSymbol(XFA_ELEMENT_MonthNames, nMonth, bAbbr); -} -void CXFA_NodeLocale::GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr) const { - wsDayName = GetCalendarSymbol(XFA_ELEMENT_DayNames, nWeek, bAbbr); -} -void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM) const { - wsMeridiemName = - GetCalendarSymbol(XFA_ELEMENT_MeridiemNames, bAM ? 0 : 1, FALSE); -} -void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { - IXFA_TimeZoneProvider* pProvider = IXFA_TimeZoneProvider::Get(); - pProvider->GetTimeZone(tz); -} -void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { - wsEraName = GetCalendarSymbol(XFA_ELEMENT_EraNames, bAD ? 1 : 0, FALSE); -} -void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - switch (eType) { - case FX_LOCALEDATETIMESUBCATEGORY_Short: - wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"short")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Medium: - case FX_LOCALEDATETIMESUBCATEGORY_Default: - wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"med")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Full: - wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"full")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Long: - wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"long")); - break; - } -} -void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const { - switch (eType) { - case FX_LOCALEDATETIMESUBCATEGORY_Short: - wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"short")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Medium: - case FX_LOCALEDATETIMESUBCATEGORY_Default: - wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"med")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Full: - wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"full")); - break; - case FX_LOCALEDATETIMESUBCATEGORY_Long: - wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"long")); - break; - } -} -void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const { - switch (eType) { - case FX_LOCALENUMPATTERN_Percent: - wsPattern = g_FX_Percent; - break; - case FX_LOCALENUMPATTERN_Currency: - wsPattern = g_FX_Currency; - break; - case FX_LOCALENUMPATTERN_Decimal: - wsPattern = g_FX_Decimal; - break; - case FX_LOCALENUMPATTERN_Integer: - wsPattern = g_FX_Integer; - break; - } -} -CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, - const CFX_WideStringC& wsName) const { - CXFA_Node* pChild = - pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; - while (pChild) { - CFX_WideString wsChild; - if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { - if (wsChild == wsName) { - return pChild; - } - } - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - } - return NULL; -} -CFX_WideString CXFA_NodeLocale::GetSymbol( - XFA_ELEMENT eElement, - const CFX_WideStringC& symbol_type) const { - CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : NULL; - CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); - return pSymbol ? pSymbol->GetContent() : CFX_WideString(); -} -CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_ELEMENT eElement, - int index, - FX_BOOL bAbbr) const { - CXFA_Node* pCalendar = - m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_CalendarSymbols) : NULL; - if (pCalendar) { - CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); - for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { - if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { - CXFA_Node* pSymbol = pNode->GetChild(index, XFA_ELEMENT_UNKNOWN); - return pSymbol ? pSymbol->GetContent() : CFX_WideString(); - } - } - } - return CFX_WideString(); -} diff --git a/xfa/src/fxfa/parser/xfa_locale.h b/xfa/src/fxfa/parser/xfa_locale.h deleted file mode 100644 index f4b128e67e..0000000000 --- a/xfa/src/fxfa/parser/xfa_locale.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_SRC_FXFA_PARSER_XFA_LOCALE_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LOCALE_H_ - -#include "xfa/src/fgas/localization/fgas_locale.h" -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CXFA_XMLLocale : public IFX_Locale { - public: - CXFA_XMLLocale(CXML_Element* pLocaleData); - virtual void Release(); - virtual CFX_WideString GetName(); - virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const; - - virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; - virtual void GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM = TRUE) const; - virtual void GetTimeZone(FX_TIMEZONE& tz) const; - virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; - - virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const; - - protected: - ~CXFA_XMLLocale(); - void GetPattern(CXML_Element* pElement, - const CFX_ByteStringC& bsTag, - const CFX_WideStringC& wsName, - CFX_WideString& wsPattern) const; - CFX_WideString GetCalendarSymbol(const CFX_ByteStringC& symbol, - int index, - FX_BOOL bAbbr) const; - - private: - CXML_Element* m_pLocaleData; -}; -class CXFA_NodeLocale : public IFX_Locale { - public: - CXFA_NodeLocale(CXFA_Node* pLocale); - virtual void Release(); - virtual CFX_WideString GetName(); - virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, - CFX_WideString& wsNumSymbol) const; - - virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; - virtual void GetMonthName(int32_t nMonth, - CFX_WideString& wsMonthName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetDayName(int32_t nWeek, - CFX_WideString& wsDayName, - FX_BOOL bAbbr = TRUE) const; - virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, - FX_BOOL bAM = TRUE) const; - virtual void GetTimeZone(FX_TIMEZONE& tz) const; - virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; - - virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, - CFX_WideString& wsPattern) const; - virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, - CFX_WideString& wsPattern) const; - - protected: - ~CXFA_NodeLocale(); - CXFA_Node* GetNodeByName(CXFA_Node* pParent, - const CFX_WideStringC& wsName) const; - CFX_WideString GetSymbol(XFA_ELEMENT eElement, - const CFX_WideStringC& symbol_type) const; - CFX_WideString GetCalendarSymbol(XFA_ELEMENT eElement, - int index, - FX_BOOL bAbbr) const; - - CXFA_Node* m_pLocale; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_LOCALE_H_ diff --git a/xfa/src/fxfa/parser/xfa_localemgr.cpp b/xfa/src/fxfa/parser/xfa_localemgr.cpp deleted file mode 100644 index bb27c9c1e2..0000000000 --- a/xfa/src/fxfa/parser/xfa_localemgr.cpp +++ /dev/null @@ -1,1305 +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/src/fxfa/parser/xfa_localemgr.h" - -#include "core/include/fxcodec/fx_codec.h" -#include "core/include/fxcrt/fx_xml.h" -#include "core/include/fxge/fx_ge.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_locale.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -const uint8_t g_enUS_Locale[] = { - 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0x9B, 0x30, 0x14, 0x7D, 0x9F, 0xB4, - 0x7F, 0x40, 0xD6, 0x2A, 0xB5, 0x52, 0x56, 0x6F, 0x8F, 0xA9, 0x88, 0xA5, - 0x6C, 0x24, 0x9B, 0x3A, 0xD1, 0x55, 0x22, 0x55, 0xB5, 0xBE, 0x4C, 0x0E, - 0xDC, 0x05, 0x34, 0xB0, 0x23, 0x83, 0x37, 0x05, 0xED, 0xE3, 0x67, 0x07, - 0xC3, 0xC0, 0xF6, 0x24, 0xC2, 0x4B, 0x7C, 0xCF, 0x3D, 0xE7, 0xE6, 0xDE, - 0x63, 0x30, 0x84, 0x25, 0x4F, 0x69, 0x09, 0x01, 0xA3, 0x15, 0xAC, 0x10, - 0xB0, 0xEF, 0x4F, 0x09, 0x0A, 0x32, 0xA8, 0xD3, 0x15, 0xDA, 0xB0, 0x43, - 0x59, 0xD4, 0xF9, 0xF5, 0xBA, 0x02, 0x51, 0xA4, 0xF4, 0x06, 0x91, 0x50, - 0x53, 0x59, 0x46, 0x45, 0x72, 0xAA, 0xF6, 0xBC, 0xAC, 0x8D, 0xEA, 0x20, - 0xE0, 0xC0, 0x45, 0x41, 0x99, 0x62, 0x54, 0x9C, 0x35, 0xF9, 0x83, 0x82, - 0x6B, 0xB3, 0x26, 0xF7, 0x94, 0x49, 0x2A, 0x4E, 0x21, 0xEE, 0xC2, 0xD7, - 0xAF, 0x0C, 0xBE, 0x85, 0xBD, 0xF0, 0x26, 0x62, 0x2A, 0xD2, 0xDC, 0x41, - 0xD7, 0x47, 0x51, 0x94, 0x1E, 0xAE, 0xAB, 0xBF, 0x97, 0x0C, 0x3C, 0x60, - 0xE9, 0x32, 0xD7, 0xF2, 0x20, 0xEB, 0xC6, 0x81, 0x13, 0x38, 0x36, 0x50, - 0xED, 0x41, 0x38, 0x99, 0xAF, 0x69, 0xC3, 0x7D, 0xF8, 0x03, 0xFF, 0xE5, - 0x17, 0x44, 0x90, 0xDA, 0x09, 0x3C, 0xB2, 0xA8, 0xE7, 0x9D, 0xA3, 0x80, - 0xEE, 0xF7, 0x62, 0x85, 0xDE, 0xA3, 0x91, 0x73, 0x3E, 0xD7, 0x7C, 0x86, - 0xF9, 0xEC, 0x9A, 0x6B, 0x96, 0xCF, 0x2B, 0x9F, 0x55, 0x3E, 0x9F, 0x7C, - 0x0E, 0xF9, 0xDC, 0xF1, 0x19, 0xF3, 0x7F, 0x4F, 0x32, 0x7A, 0x32, 0xB7, - 0x90, 0x5A, 0x91, 0x44, 0xAA, 0x5B, 0x4E, 0x75, 0xAE, 0xD7, 0x5D, 0x92, - 0xC4, 0xDC, 0x81, 0x76, 0x12, 0x6A, 0x1B, 0x7B, 0x86, 0x8C, 0xB9, 0xE8, - 0x2E, 0x97, 0xC2, 0x01, 0xB7, 0xA2, 0xB0, 0xA1, 0x84, 0x36, 0x52, 0x8C, - 0x41, 0x3C, 0xF4, 0x35, 0xEA, 0x71, 0xB4, 0x6B, 0xA6, 0x59, 0xBB, 0x53, - 0xBB, 0x4D, 0xBB, 0x45, 0xBB, 0x39, 0xBB, 0x2F, 0xBB, 0x29, 0x7F, 0x3F, - 0xFA, 0x21, 0xCD, 0x0A, 0xA8, 0xFA, 0x67, 0xCF, 0x84, 0x64, 0x1D, 0x2B, - 0x77, 0xFB, 0x60, 0xC4, 0x23, 0x8F, 0x56, 0x02, 0x4F, 0x2B, 0x28, 0x04, - 0x04, 0x35, 0xD5, 0xD4, 0x8A, 0x7C, 0xF8, 0x18, 0x62, 0xFD, 0xDB, 0x25, - 0xC8, 0x3A, 0x1A, 0x42, 0x3C, 0x10, 0x75, 0x60, 0x9D, 0x11, 0x5D, 0xE3, - 0x0D, 0x3C, 0xD2, 0xA6, 0x01, 0xC1, 0xCE, 0x7B, 0x3A, 0x44, 0xE6, 0x00, - 0xF9, 0x21, 0xCB, 0x12, 0x91, 0x8D, 0xBA, 0x16, 0x41, 0xAC, 0xAE, 0x20, - 0x5A, 0x04, 0xDF, 0xD4, 0xA5, 0x27, 0x1C, 0xB8, 0x56, 0x21, 0x23, 0x2D, - 0x39, 0x3B, 0x20, 0x72, 0xA1, 0xA8, 0x82, 0xEC, 0xAC, 0xB9, 0x40, 0x52, - 0xE7, 0x5C, 0x34, 0x4A, 0x84, 0x23, 0xEC, 0xE1, 0xE3, 0xC9, 0x84, 0x0A, - 0x68, 0x8A, 0x6A, 0x34, 0xF1, 0x28, 0x9A, 0x4C, 0x9C, 0xDF, 0xC5, 0xF1, - 0x5D, 0x92, 0x04, 0xEB, 0xE0, 0x25, 0xC4, 0x23, 0x92, 0x55, 0x61, 0x32, - 0xEA, 0x65, 0x9A, 0xF3, 0xA4, 0x83, 0x64, 0x86, 0xC0, 0xCC, 0xA9, 0x25, - 0x1E, 0x3E, 0x9E, 0xCC, 0x65, 0x8C, 0xDA, 0x29, 0xAC, 0xDF, 0xEC, 0x4F, - 0xA7, 0x38, 0xFB, 0xF9, 0xB9, 0xAA, 0x93, 0x4D, 0xB4, 0xFD, 0xFD, 0x4C, - 0xF3, 0x2F, 0xED, 0x4B, 0x67, 0xCE, 0x98, 0xA4, 0x74, 0x4C, 0xEA, 0x53, - 0xF1, 0x9F, 0x43, 0x93, 0xD8, 0xB4, 0xA2, 0x30, 0xFD, 0xE2, 0x41, 0xA4, - 0x5D, 0xB4, 0xED, 0xF2, 0xB6, 0x6D, 0xDB, 0x10, 0x4F, 0x78, 0x4E, 0x21, - 0x23, 0x4C, 0xA5, 0x10, 0xC0, 0xD2, 0x13, 0x22, 0x6F, 0x3A, 0xE9, 0x72, - 0xF9, 0xE7, 0x7A, 0x58, 0xDE, 0xCC, 0xAC, 0x72, 0x04, 0x91, 0x02, 0x6B, - 0xCC, 0xDF, 0x5F, 0x79, 0x54, 0xD8, 0x9A, 0x62, 0x28, 0xD4, 0x0F, 0x3A, - 0x09, 0x4D, 0xD9, 0x0C, 0xD2, 0xA2, 0xA2, 0x6A, 0xF3, 0x6F, 0x7B, 0x7D, - 0x97, 0xB6, 0xD5, 0xC3, 0xBB, 0x95, 0xCB, 0x63, 0xA1, 0x37, 0x7E, 0x31, - 0x8B, 0x3F, 0x74, 0x7D, 0x35, 0x8B, 0x5E, 0x15, 0x4C, 0xD6, 0x88, 0xBC, - 0x9D, 0x45, 0x6E, 0x41, 0x70, 0x44, 0xDE, 0xB9, 0x5C, 0x3C, 0x1D, 0x5B, - 0x21, 0xFD, 0x16, 0x0C, 0x4E, 0x4C, 0x81, 0xFE, 0x66, 0x3B, 0x07, 0x6A, - 0x9B, 0xD4, 0xA9, 0x31, 0xC9, 0xBB, 0x25, 0x8C, 0xA2, 0xA8, 0xB9, 0x5E, - 0x20, 0xF2, 0x94, 0x44, 0xB3, 0x45, 0x63, 0xCB, 0x5D, 0x09, 0xB6, 0x7B, - 0xD5, 0x58, 0xF7, 0x55, 0xA4, 0x96, 0x7F, 0x01, 0x75, 0x37, 0x1B, 0x8B, -}; -const uint8_t g_enGB_Locale[] = { - 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6E, 0xD3, 0x30, 0x14, 0x7D, 0x47, 0xE2, - 0x1F, 0xA2, 0x88, 0x49, 0x20, 0x6D, 0x33, 0x3C, 0x6E, 0xEA, 0x2C, 0x75, - 0xEB, 0xD6, 0x32, 0xC8, 0xA8, 0x48, 0xC5, 0xC4, 0x5E, 0x90, 0x9B, 0x78, - 0x8D, 0x59, 0x62, 0x57, 0x4E, 0xCC, 0x94, 0xFC, 0x02, 0x9F, 0xC0, 0x23, - 0xCF, 0x08, 0xF1, 0x01, 0xBC, 0xF0, 0x2F, 0x48, 0xFB, 0x0C, 0x6E, 0x1A, - 0x27, 0x4B, 0x1C, 0xAF, 0x64, 0x79, 0x89, 0xEF, 0xB9, 0xE7, 0xDC, 0xDE, - 0x7B, 0x9C, 0xB8, 0x19, 0xC5, 0x22, 0x20, 0x31, 0x75, 0x38, 0x49, 0xE8, - 0x91, 0x4B, 0xF9, 0xA7, 0xE9, 0xB1, 0xEB, 0x84, 0x34, 0x0D, 0x8E, 0xDC, - 0xBB, 0xAF, 0xBF, 0xEE, 0x7E, 0xFE, 0x78, 0x0E, 0xB7, 0xBF, 0xDF, 0x7E, - 0xBF, 0x70, 0xF1, 0xA8, 0x24, 0xF2, 0x90, 0x48, 0x3F, 0x4F, 0x96, 0x22, - 0x4E, 0xB5, 0x66, 0x25, 0xE9, 0x4A, 0x48, 0x46, 0x38, 0x30, 0x12, 0xC1, - 0xB3, 0xE8, 0x02, 0xE0, 0x54, 0xAF, 0xF1, 0x39, 0xE1, 0x8A, 0xC8, 0x7C, - 0x84, 0xAA, 0xF0, 0xE9, 0x13, 0x8D, 0x9F, 0xD1, 0xA5, 0xB4, 0x26, 0x3C, - 0x22, 0x83, 0xA8, 0x87, 0x8E, 0xD7, 0x92, 0xC5, 0x16, 0x6E, 0x5F, 0x7F, - 0xAE, 0x38, 0xB5, 0x80, 0x71, 0x9F, 0x39, 0x56, 0x2B, 0x95, 0x66, 0x3D, - 0xD8, 0xA7, 0xEB, 0x8C, 0x26, 0x4B, 0x2A, 0x7B, 0x99, 0x77, 0x41, 0x26, - 0x6C, 0xF8, 0x85, 0xF8, 0x62, 0x17, 0x4C, 0x68, 0x60, 0x26, 0x50, 0xCB, - 0xA2, 0x9A, 0xB7, 0x89, 0x1C, 0xB2, 0x5C, 0xCA, 0x23, 0xF7, 0x95, 0xDB, - 0x72, 0xCE, 0xE6, 0x9A, 0xCD, 0x30, 0x9B, 0x5D, 0x43, 0xCD, 0xB2, 0x79, - 0x65, 0xB3, 0xCA, 0xE6, 0x93, 0xCD, 0x21, 0x9B, 0x3B, 0x36, 0x63, 0x1E, - 0xF6, 0x24, 0x24, 0xB9, 0x7E, 0x84, 0x60, 0x85, 0x7D, 0x05, 0x8F, 0x1C, - 0x74, 0x5E, 0xAE, 0xAB, 0x24, 0xF6, 0x44, 0x0F, 0x5A, 0x28, 0x9A, 0x9A, - 0xD8, 0x25, 0x0D, 0x79, 0x1F, 0x5D, 0x44, 0x4A, 0xF6, 0xC0, 0x33, 0xC9, - 0x4C, 0xC8, 0x27, 0x99, 0x92, 0x6D, 0x10, 0x35, 0x7D, 0xB5, 0x7A, 0x6C, - 0xED, 0x9A, 0x6E, 0xD6, 0xEC, 0xD4, 0x6C, 0xD3, 0x6C, 0xD1, 0x6C, 0xCE, - 0xEC, 0xCB, 0x6C, 0xCA, 0xDE, 0x4F, 0x42, 0x61, 0x02, 0x46, 0x93, 0xFA, - 0xDD, 0xD3, 0x21, 0x1E, 0x7B, 0xE0, 0x6E, 0x1D, 0xB4, 0x78, 0x78, 0x6E, - 0x24, 0x50, 0xB7, 0x02, 0x20, 0x54, 0x12, 0x5D, 0x0D, 0x56, 0xF8, 0xF8, - 0x64, 0x84, 0xCA, 0x7B, 0x95, 0xC0, 0xE3, 0x49, 0x13, 0xA2, 0x86, 0x58, - 0x06, 0xC6, 0x19, 0x51, 0x35, 0x9E, 0xD1, 0x39, 0xC9, 0x32, 0x2A, 0xF9, - 0x66, 0x4F, 0x9B, 0x48, 0x1F, 0x20, 0xD7, 0x2A, 0x8E, 0x5D, 0x7C, 0x0A, - 0xD7, 0xAE, 0x33, 0x71, 0x3C, 0xB8, 0x9C, 0x8F, 0x70, 0x95, 0x03, 0x36, - 0x54, 0xA3, 0x8E, 0x56, 0xC6, 0x82, 0xAF, 0x5C, 0xFC, 0x38, 0x4D, 0x42, - 0x43, 0x2D, 0x19, 0xAA, 0x48, 0x23, 0x21, 0x33, 0xD0, 0x4C, 0x90, 0xE7, - 0x21, 0xAB, 0x06, 0x75, 0x46, 0x04, 0x20, 0x63, 0x49, 0x6B, 0xE4, 0x56, - 0xD4, 0x19, 0x79, 0x36, 0x3B, 0xF4, 0xBC, 0x43, 0xDF, 0x77, 0xAE, 0x46, - 0xA8, 0xC5, 0x31, 0x0A, 0x74, 0x66, 0x7D, 0x94, 0x64, 0x33, 0x6A, 0xAD, - 0x18, 0xC0, 0xD7, 0x83, 0x6E, 0x14, 0x3D, 0x3A, 0xEA, 0xCC, 0xA4, 0x8D, - 0x5A, 0x00, 0x56, 0xEF, 0xF4, 0x34, 0xF7, 0xC2, 0x9B, 0x59, 0x92, 0xFA, - 0xA7, 0x93, 0xB3, 0xDB, 0x4B, 0x12, 0xBD, 0x29, 0xAE, 0x2A, 0x63, 0xDA, - 0x24, 0xD0, 0x71, 0x55, 0x1E, 0x89, 0xF7, 0xEE, 0x74, 0x62, 0xDD, 0x09, - 0x60, 0xF0, 0x38, 0x06, 0x2E, 0x2E, 0x76, 0x8B, 0xE2, 0x60, 0xBF, 0x28, - 0x8A, 0x11, 0xEA, 0xF0, 0x7A, 0x85, 0xB4, 0x30, 0x50, 0x52, 0x52, 0x1E, - 0xE4, 0x2E, 0x7E, 0x56, 0x49, 0x0F, 0x0E, 0x06, 0x2A, 0xD7, 0x54, 0x06, - 0x94, 0x67, 0xFA, 0x27, 0x77, 0x2C, 0x2A, 0x64, 0x74, 0xDE, 0x14, 0xAA, - 0x87, 0xEB, 0x84, 0xBA, 0x6C, 0x48, 0x03, 0x96, 0x10, 0xD8, 0xEC, 0xFD, - 0x5A, 0x5F, 0xA5, 0x4D, 0x75, 0xF3, 0x67, 0x2A, 0xD4, 0x9A, 0x95, 0x3B, - 0xBD, 0x3B, 0x88, 0xDF, 0x74, 0xBD, 0x33, 0x88, 0x9E, 0x30, 0xAE, 0x52, - 0x17, 0xEF, 0x0D, 0x22, 0x17, 0x54, 0x0A, 0x17, 0xBF, 0xEC, 0x73, 0x51, - 0x77, 0x6C, 0x40, 0x6A, 0xDB, 0x1B, 0x27, 0xBA, 0x40, 0xFD, 0x7C, 0x6D, - 0x02, 0x17, 0xFF, 0xF9, 0x0E, 0xE7, 0x44, 0x87, 0xD0, 0xAF, 0xA1, 0x25, - 0x2C, 0x15, 0xE5, 0xC2, 0xC5, 0xD3, 0xE3, 0xF9, 0x60, 0x51, 0xDB, 0xF3, - 0xBE, 0x04, 0x99, 0xCD, 0x96, 0xEF, 0x42, 0xBE, 0xA6, 0xD7, 0x24, 0x28, - 0x0F, 0xBB, 0x7A, 0xA9, 0x6B, 0x79, 0x39, 0x7C, 0xDA, 0x84, 0xCE, 0x1C, - 0xAC, 0x40, 0x6D, 0x66, 0x9D, 0x66, 0x9C, 0x09, 0xFE, 0x60, 0xFA, 0x44, - 0x28, 0xC9, 0xA8, 0x74, 0xFC, 0x2C, 0xB4, 0xE6, 0xC7, 0x21, 0x7C, 0x50, - 0x38, 0x73, 0xF6, 0x1F, 0xC2, 0x0C, 0x3E, 0x96, 0xE8, 0xED, 0x16, 0xC2, - 0x58, 0x92, 0x25, 0xBC, 0x2E, 0x0F, 0x13, 0x16, 0x11, 0x61, 0xD6, 0xF4, - 0x1B, 0x51, 0xA8, 0x1B, 0xE2, 0x4C, 0x45, 0x16, 0xB1, 0xA0, 0x9C, 0x63, - 0xEF, 0xC3, 0x6B, 0xC7, 0xDB, 0x46, 0x85, 0x91, 0x83, 0x48, 0xD4, 0xD4, - 0xF7, 0x5B, 0x7E, 0x14, 0x98, 0xAB, 0x72, 0x32, 0xE7, 0xED, 0x16, 0x92, - 0x2F, 0x06, 0x90, 0xBC, 0x5C, 0xF1, 0xD5, 0x67, 0xB1, 0xE1, 0xE9, 0xE6, - 0xD0, 0xFD, 0x9E, 0x95, 0x51, 0xF5, 0x19, 0x0B, 0xCB, 0x7F, 0x8E, 0x69, - 0xAC, 0xD0}; -const uint8_t g_zhCN_Locale[] = { - 0x78, 0x9C, 0xED, 0x56, 0x41, 0x4F, 0xD4, 0x40, 0x14, 0xBE, 0x9B, 0xF8, - 0x1F, 0x9A, 0x46, 0x52, 0x4D, 0x58, 0x46, 0x8F, 0x90, 0xD2, 0x64, 0x03, - 0x08, 0x06, 0xBB, 0x21, 0x96, 0x68, 0xE0, 0x62, 0xBA, 0xED, 0xB0, 0x2D, - 0x6C, 0x3B, 0x64, 0xB6, 0x0D, 0x6E, 0x4F, 0x18, 0x82, 0x82, 0xC2, 0x45, - 0x89, 0x9A, 0x80, 0xE1, 0x64, 0x3C, 0x28, 0x9E, 0x8C, 0x01, 0x22, 0xF1, - 0xCF, 0xB0, 0xCB, 0x91, 0xBF, 0xE0, 0x9B, 0xED, 0xB4, 0xB4, 0xDD, 0xD9, - 0xB5, 0x3F, 0xC0, 0x3D, 0xCD, 0xFB, 0xDE, 0xF7, 0x7D, 0xF3, 0xDE, 0xEB, - 0x74, 0xB6, 0x6A, 0x93, 0x58, 0x66, 0x13, 0x4B, 0xBE, 0xE9, 0xE1, 0x49, - 0x39, 0x72, 0x9E, 0x4F, 0xD5, 0x64, 0xC9, 0xC6, 0x2D, 0x6B, 0x52, 0xBE, - 0x3C, 0x3D, 0xE9, 0x7E, 0x78, 0x7D, 0xF7, 0xEA, 0xC7, 0xE6, 0xE5, 0xC5, - 0xFB, 0xEB, 0xDF, 0x7B, 0x10, 0x77, 0x0E, 0x2F, 0xEE, 0xC9, 0x9A, 0xCA, - 0x14, 0xBE, 0x6D, 0x52, 0xA3, 0xED, 0xD5, 0x49, 0xB3, 0xC5, 0xC5, 0x0D, - 0x8A, 0x1B, 0x84, 0xBA, 0xA6, 0x0F, 0x0C, 0x8F, 0xF8, 0x81, 0x53, 0x03, - 0xB8, 0xC5, 0xD7, 0xDA, 0xE5, 0xE9, 0x66, 0xF7, 0x68, 0x47, 0x45, 0x71, - 0x74, 0xFB, 0x56, 0x02, 0x9F, 0xEF, 0x09, 0xE1, 0xD3, 0x5D, 0x11, 0xDC, - 0x39, 0x3C, 0x14, 0x9B, 0x1C, 0x08, 0xD9, 0xDB, 0x27, 0x62, 0xEF, 0x2D, - 0x31, 0xFB, 0x9B, 0x90, 0x7D, 0xF6, 0x59, 0xC8, 0xDE, 0x7F, 0x39, 0x00, - 0x1E, 0xD0, 0x28, 0xCB, 0x14, 0x7B, 0x45, 0x99, 0x31, 0x25, 0xC4, 0x5E, - 0x24, 0x99, 0xF5, 0x3A, 0x9D, 0x94, 0x1F, 0xC8, 0xFF, 0xA7, 0x57, 0x7A, - 0x7A, 0xB6, 0xD9, 0xE6, 0x07, 0x0E, 0x56, 0x5A, 0xF7, 0xD3, 0x71, 0xF7, - 0xE8, 0xB8, 0xFB, 0xF1, 0x8B, 0x8A, 0x58, 0x18, 0xE7, 0x39, 0x0A, 0x7B, - 0x88, 0xD0, 0xF3, 0x3D, 0x21, 0x77, 0x57, 0x80, 0xC2, 0x24, 0x85, 0x0E, - 0x07, 0x22, 0xEE, 0xF6, 0x49, 0x8A, 0xA2, 0xB4, 0xC8, 0x4C, 0xC1, 0x99, - 0x87, 0xDD, 0x53, 0x15, 0x6A, 0x2E, 0x56, 0x5B, 0xAC, 0xB3, 0x58, 0x61, - 0xB1, 0xB6, 0x62, 0x55, 0x03, 0xEB, 0xF1, 0x30, 0x75, 0x6D, 0x17, 0x7B, - 0xC9, 0x6B, 0xCB, 0x43, 0xD8, 0xE0, 0x4D, 0x67, 0x9F, 0x0D, 0x3E, 0x01, - 0x32, 0x5C, 0x48, 0xBE, 0xED, 0x4B, 0xA2, 0xBC, 0x13, 0x20, 0x98, 0x9A, - 0xDC, 0x15, 0x56, 0x50, 0xC1, 0xF7, 0xCE, 0xF6, 0x56, 0x67, 0x77, 0x5F, - 0x45, 0x2C, 0x8C, 0xF3, 0x1C, 0x4D, 0x21, 0x94, 0x6A, 0x58, 0x50, 0xB8, - 0x71, 0xE2, 0x5E, 0x02, 0xBC, 0x60, 0x06, 0x01, 0xA6, 0x7E, 0xEF, 0x99, - 0xA7, 0x11, 0xBF, 0x8E, 0x56, 0xC2, 0x66, 0x53, 0xD6, 0x96, 0xE0, 0xA7, - 0x74, 0xCE, 0x7E, 0x2A, 0xBA, 0x02, 0xA7, 0x47, 0x99, 0x56, 0x60, 0xBC, - 0xCA, 0x0C, 0xFC, 0x58, 0xEF, 0xA9, 0xA4, 0xE0, 0xC7, 0x1D, 0x9A, 0xC4, - 0x6F, 0x0C, 0x70, 0x28, 0xA1, 0xF6, 0xB0, 0x1D, 0x8B, 0x2B, 0x7A, 0x65, - 0xBA, 0x04, 0xBF, 0xE5, 0x10, 0x1A, 0x30, 0x85, 0x90, 0x8F, 0x72, 0xED, - 0x02, 0x10, 0xB8, 0x5E, 0xA6, 0xFD, 0x4C, 0x94, 0x6B, 0xBF, 0xEA, 0x38, - 0x50, 0xEF, 0x2F, 0x45, 0xD7, 0x95, 0xCE, 0xCE, 0x2B, 0xC5, 0x30, 0x94, - 0xAB, 0xAF, 0xEF, 0x14, 0x69, 0x59, 0x45, 0x19, 0x45, 0xC1, 0x2E, 0xD7, - 0xBD, 0xD8, 0xA0, 0x84, 0xBC, 0xD7, 0x3E, 0xA8, 0x27, 0x74, 0x7D, 0xC2, - 0x30, 0x4A, 0x08, 0x78, 0xFF, 0x55, 0xA6, 0xE8, 0xA3, 0xA3, 0x5C, 0xBB, - 0x7C, 0x7E, 0x8B, 0x80, 0x25, 0x07, 0x62, 0xD6, 0xF4, 0x57, 0xD7, 0xE6, - 0xBC, 0x96, 0x31, 0x33, 0xFD, 0x70, 0xE3, 0xD9, 0x0B, 0x67, 0x3E, 0x5A, - 0x8E, 0x67, 0x96, 0x25, 0x81, 0xCE, 0x0F, 0xBD, 0x3A, 0xA6, 0x37, 0x83, - 0xCB, 0xC5, 0xBC, 0x12, 0xC0, 0xE0, 0x00, 0x5B, 0xB2, 0x16, 0x8D, 0x46, - 0xD1, 0xF8, 0x58, 0x14, 0x45, 0x2A, 0xCA, 0xF1, 0xFA, 0x8C, 0xB8, 0xD0, - 0x0A, 0x29, 0xC5, 0xBE, 0xD5, 0x96, 0xB5, 0x3B, 0xB1, 0x74, 0x7C, 0xBC, - 0xA4, 0x72, 0x1D, 0x53, 0x0B, 0xFB, 0x01, 0xDF, 0x72, 0x44, 0xA0, 0x42, - 0x85, 0xCA, 0x53, 0xA3, 0xA4, 0xB9, 0x5C, 0xC8, 0x6D, 0x6D, 0x6C, 0xB9, - 0x9E, 0x09, 0xE7, 0x60, 0x2C, 0xD1, 0xC7, 0xE9, 0xA2, 0x3A, 0xFD, 0x07, - 0x27, 0xE1, 0xBA, 0xCB, 0x1E, 0xFB, 0x68, 0x29, 0x7E, 0x5A, 0xF5, 0x48, - 0x29, 0xBA, 0xE7, 0xFA, 0x61, 0x4B, 0xD6, 0x2A, 0xA5, 0xC8, 0x11, 0xA6, - 0x44, 0xD6, 0xEE, 0xF7, 0x73, 0x51, 0xBE, 0x6D, 0x40, 0x92, 0xB1, 0xA7, - 0x93, 0xC8, 0x03, 0xC9, 0xF9, 0xEA, 0x05, 0xB2, 0x76, 0xFD, 0x07, 0xEE, - 0xD7, 0x3C, 0xA3, 0xDF, 0x84, 0x6B, 0xDC, 0x16, 0x61, 0x0B, 0x59, 0x9B, - 0xAA, 0x2D, 0x95, 0x16, 0x65, 0x87, 0xDE, 0x2F, 0x41, 0xC5, 0x6A, 0xD9, - 0xCB, 0xD0, 0x5E, 0xC7, 0x2B, 0xA6, 0xC5, 0xEE, 0xC7, 0x64, 0xC9, 0xBD, - 0xAA, 0x36, 0xA9, 0x63, 0xC9, 0x80, 0x57, 0x51, 0x32, 0x02, 0x5B, 0x7A, - 0x2C, 0xA3, 0x2C, 0x9F, 0x93, 0xF4, 0x36, 0x7C, 0x75, 0xD9, 0xD2, 0x02, - 0x0C, 0x4C, 0x98, 0x76, 0x7D, 0x97, 0xF8, 0x03, 0xD3, 0x53, 0x24, 0xA4, - 0x2E, 0xA6, 0xCC, 0x5F, 0x98, 0x8F, 0x4B, 0x58, 0x70, 0xFF, 0x41, 0x98, - 0xC3, 0x75, 0x8A, 0x37, 0x86, 0x10, 0xAA, 0xD4, 0xAC, 0xC3, 0x4B, 0x35, - 0x98, 0xB0, 0xE8, 0x98, 0xAE, 0x30, 0x3D, 0x4F, 0xA2, 0x70, 0xCD, 0x94, - 0x66, 0x49, 0xE0, 0xB8, 0x16, 0xEB, 0xA3, 0xF2, 0xF4, 0x91, 0xA4, 0x0F, - 0xA3, 0x42, 0xCB, 0x96, 0x43, 0x12, 0xEA, 0x93, 0x21, 0x9B, 0x02, 0x73, - 0xD8, 0x68, 0x39, 0xA9, 0x1D, 0xFA, 0x8D, 0x55, 0xD2, 0xE3, 0xF1, 0x7D, - 0xD1, 0xCD, 0x33, 0x63, 0x51, 0xFC, 0x15, 0x0D, 0xCB, 0xBF, 0xC0, 0xE4, - 0x3D, 0x40}; -const uint8_t g_zhTW_Locale[] = { - 0x78, 0x9C, 0xED, 0x57, 0xCD, 0x4F, 0xD4, 0x40, 0x14, 0x3F, 0x63, 0xE2, - 0xFF, 0x30, 0x69, 0x20, 0xD5, 0x04, 0xA8, 0x1E, 0x21, 0xA5, 0xC9, 0xC6, - 0x45, 0x30, 0x58, 0x42, 0xEC, 0x46, 0x22, 0x17, 0x33, 0xDB, 0x0E, 0xDB, - 0xC2, 0xB6, 0x43, 0x66, 0xDB, 0xC0, 0xF6, 0x24, 0x12, 0x14, 0x14, 0x62, - 0xA2, 0xC4, 0x8F, 0x80, 0xE1, 0x64, 0x3C, 0x28, 0x89, 0x07, 0x0F, 0x2C, - 0x51, 0xFF, 0x1A, 0x76, 0x39, 0xFA, 0x2F, 0x38, 0xD3, 0x2F, 0xFA, 0xB1, - 0xB3, 0xD4, 0xC4, 0xA3, 0x7B, 0x9A, 0xF7, 0xDE, 0xEF, 0xF7, 0xE6, 0xBD, - 0xDF, 0xBC, 0x7D, 0xD9, 0x95, 0x9B, 0x58, 0x87, 0x4D, 0x04, 0x1C, 0x68, - 0xA3, 0x29, 0xC1, 0x37, 0x1F, 0xD7, 0x16, 0x05, 0x60, 0xA0, 0x96, 0x3E, - 0x25, 0x9C, 0x9F, 0x9E, 0xF4, 0xDE, 0x3E, 0xBF, 0x71, 0xD1, 0xD9, 0x3C, - 0xFF, 0xF9, 0xE6, 0xF7, 0x8F, 0xBD, 0xEE, 0xAB, 0x6F, 0xBD, 0xCE, 0xAF, - 0x9B, 0x82, 0x72, 0xFD, 0x1A, 0x00, 0x32, 0x63, 0x39, 0x06, 0x24, 0x5A, - 0xDB, 0xAE, 0xE3, 0x66, 0x2B, 0x4A, 0xD0, 0x20, 0xA8, 0x81, 0x89, 0x05, - 0x1D, 0x86, 0x1A, 0x02, 0xB2, 0x8D, 0x1D, 0xD7, 0x9C, 0xA7, 0xA1, 0x16, - 0xB3, 0x87, 0x42, 0x5B, 0x39, 0x3F, 0x7D, 0xD2, 0x3B, 0xDA, 0x91, 0xA5, - 0xD0, 0x4A, 0x07, 0xCE, 0xF6, 0x38, 0x81, 0xD3, 0xDD, 0xFE, 0x81, 0xEE, - 0xE1, 0x21, 0x2F, 0xD5, 0x01, 0x87, 0xB1, 0x7D, 0xC2, 0xBB, 0x63, 0x8B, - 0xC7, 0xF8, 0xC2, 0x61, 0x74, 0x3E, 0x72, 0x18, 0xFB, 0x9B, 0xDC, 0x00, - 0xB7, 0x79, 0x16, 0xCB, 0xF7, 0x0F, 0xA2, 0x73, 0x22, 0x61, 0x5A, 0x52, - 0x00, 0xEB, 0x75, 0x32, 0x25, 0xDC, 0x16, 0xFE, 0x6B, 0xFB, 0x8F, 0xB4, - 0x35, 0x60, 0x3B, 0x35, 0xAC, 0xD4, 0x52, 0x7A, 0xEF, 0x8F, 0x7B, 0x47, - 0xC7, 0xBD, 0x77, 0x9F, 0x64, 0x89, 0x99, 0x39, 0x3F, 0xBD, 0xAF, 0xBF, - 0xFF, 0x6C, 0x8F, 0x83, 0xDF, 0xED, 0xEB, 0xA7, 0x4A, 0x73, 0xF2, 0x1C, - 0xF4, 0xC7, 0x6F, 0x9F, 0x24, 0x7E, 0x10, 0x9C, 0xFA, 0x34, 0x91, 0x1B, - 0x8F, 0x80, 0x5D, 0xE8, 0xA3, 0xD8, 0x41, 0xB1, 0xF6, 0x62, 0xD5, 0xC5, - 0x7A, 0x8B, 0x95, 0x0E, 0xAC, 0xD1, 0x46, 0xC4, 0x32, 0x2C, 0x64, 0xA7, - 0x57, 0x43, 0xE4, 0xA2, 0xD7, 0xBD, 0xE8, 0xEE, 0xB3, 0x87, 0x8A, 0x1D, - 0xF9, 0xF0, 0xCB, 0x42, 0x18, 0x5C, 0x9A, 0xA9, 0x4B, 0x10, 0x81, 0xA9, - 0xFC, 0xD4, 0xA2, 0x35, 0x7D, 0xED, 0x6E, 0x6F, 0x75, 0x77, 0xF7, 0x65, - 0x89, 0x99, 0x39, 0x7F, 0xE2, 0x04, 0xC1, 0x29, 0xE6, 0xD2, 0x65, 0x27, - 0xE5, 0xB6, 0x5D, 0xE8, 0x35, 0xA0, 0x8B, 0x16, 0xA0, 0xEB, 0x22, 0xE2, - 0x24, 0xD2, 0x27, 0x9E, 0x68, 0x21, 0x2E, 0x7B, 0xCD, 0xA6, 0xA0, 0x3C, - 0xA2, 0x1F, 0xB1, 0xDB, 0xF9, 0x2E, 0xAA, 0x22, 0x9D, 0x41, 0xB1, 0x2A, - 0xD2, 0x87, 0x10, 0xA7, 0xE9, 0x87, 0xE9, 0x92, 0x50, 0x78, 0x39, 0x9A, - 0xD8, 0x69, 0x70, 0x72, 0x94, 0xE2, 0xDB, 0xC8, 0x08, 0xE9, 0x92, 0x2A, - 0x55, 0x4B, 0x31, 0x5A, 0x26, 0x26, 0x2E, 0x9F, 0x03, 0x40, 0xC6, 0x13, - 0xC9, 0xE1, 0x5A, 0x76, 0x4E, 0x8E, 0x94, 0x27, 0x23, 0x47, 0xC5, 0x34, - 0xC5, 0xDE, 0x87, 0xA7, 0xA2, 0xAA, 0x8A, 0xDD, 0x9D, 0x67, 0xA2, 0xA6, - 0x89, 0x17, 0x9F, 0x5F, 0x8B, 0x60, 0x49, 0x96, 0x52, 0x0C, 0x5E, 0x8A, - 0x50, 0x8D, 0xFE, 0x29, 0x4A, 0x25, 0x08, 0xE4, 0xA8, 0x00, 0x73, 0x52, - 0x55, 0x27, 0x35, 0xAD, 0x14, 0x25, 0xD2, 0x23, 0x24, 0xE5, 0x19, 0x4C, - 0x8D, 0x5C, 0xEF, 0xD1, 0x70, 0xD4, 0xA8, 0x37, 0x9E, 0x98, 0x19, 0xE8, - 0xAC, 0xAC, 0xCE, 0xDA, 0x2D, 0x6D, 0xBA, 0x7A, 0x77, 0x7D, 0x71, 0xC3, - 0x9C, 0xF3, 0x97, 0x42, 0x11, 0xD3, 0xA0, 0x80, 0xE9, 0x78, 0x76, 0x1D, - 0x91, 0xAC, 0x92, 0x19, 0x5F, 0x54, 0x14, 0xF5, 0xD1, 0x99, 0xD7, 0x05, - 0xC5, 0x1F, 0xF5, 0xFD, 0x89, 0x71, 0xDF, 0xF7, 0x65, 0x29, 0x83, 0xE3, - 0x53, 0x75, 0x8F, 0x10, 0xE4, 0xE8, 0x6D, 0x41, 0x19, 0x0E, 0xC9, 0x13, - 0x13, 0xA5, 0xB9, 0x6B, 0x88, 0xE8, 0xC8, 0x71, 0xA3, 0x6B, 0x47, 0x8A, - 0x3C, 0xA6, 0x47, 0xA1, 0x87, 0xA4, 0xAF, 0xCB, 0x56, 0x87, 0xB2, 0xAE, - 0x28, 0xBD, 0x81, 0x74, 0xCB, 0x86, 0x74, 0x48, 0xC6, 0xE3, 0x2C, 0x61, - 0x98, 0x4B, 0x68, 0x10, 0xEC, 0xAD, 0x59, 0x6C, 0x26, 0x46, 0x4B, 0x32, - 0x92, 0x0E, 0x46, 0x4A, 0x12, 0x6C, 0xCB, 0xF1, 0x5A, 0x82, 0x32, 0x56, - 0x12, 0xEE, 0x23, 0x82, 0x05, 0xE5, 0x56, 0x01, 0x7D, 0x29, 0x4C, 0xE6, - 0xBD, 0xE3, 0xC7, 0xC8, 0x28, 0x93, 0x75, 0xC6, 0x63, 0x18, 0x18, 0x82, - 0x32, 0x5F, 0x1B, 0xA6, 0x2B, 0x29, 0x83, 0x18, 0xC0, 0xB2, 0x5A, 0x98, - 0x1D, 0x04, 0xA5, 0xB6, 0x58, 0xFD, 0x0B, 0x5A, 0xFA, 0x21, 0x0A, 0xA4, - 0x60, 0x27, 0x16, 0xEA, 0x66, 0x4B, 0xA0, 0xBD, 0x86, 0x96, 0xA1, 0x1E, - 0xAF, 0xE0, 0xD8, 0x8C, 0x72, 0x56, 0x0C, 0x5C, 0x47, 0x40, 0xA5, 0xAF, - 0x05, 0x34, 0xD7, 0x00, 0xF7, 0x05, 0xA9, 0x2F, 0x4C, 0x6D, 0xD3, 0x9F, - 0x90, 0x06, 0x58, 0xA0, 0x32, 0x72, 0x00, 0x96, 0x63, 0x61, 0x67, 0x00, - 0xE0, 0x0E, 0xF6, 0x88, 0x85, 0x08, 0xBB, 0x85, 0x83, 0x08, 0x4B, 0x59, - 0xB0, 0xAE, 0x84, 0xCC, 0xA2, 0x3A, 0x41, 0xEB, 0x03, 0x21, 0x15, 0x02, - 0xEB, 0xF4, 0x8B, 0x38, 0x08, 0x52, 0x33, 0xA1, 0xC5, 0x01, 0xCC, 0x61, - 0xDF, 0x5B, 0x85, 0x60, 0x06, 0xBB, 0xA6, 0xA5, 0xB3, 0x9E, 0xC6, 0x1E, - 0xDE, 0x03, 0xEA, 0x60, 0x30, 0x15, 0x40, 0x37, 0x71, 0x0C, 0x7E, 0x30, - 0xF0, 0x6A, 0x0D, 0x5F, 0x21, 0x77, 0xF4, 0x2A, 0x6D, 0xCF, 0x69, 0xAC, - 0xE0, 0x00, 0x19, 0xDE, 0x1E, 0x2C, 0xB6, 0xD4, 0x7B, 0xCA, 0x52, 0xF8, - 0x67, 0x41, 0xF9, 0x03, 0x11, 0xC2, 0x4A, 0xC9}; -const uint8_t g_zhHK_Locale[] = { - 0x78, 0x9C, 0xA5, 0x57, 0x4D, 0x4F, 0x13, 0x41, 0x18, 0x3E, 0x63, 0xE2, - 0x7F, 0x98, 0x6C, 0x20, 0x0B, 0x09, 0x50, 0x8A, 0x9F, 0x25, 0xCB, 0x26, - 0x44, 0x90, 0x9A, 0x5A, 0x43, 0x2C, 0xD1, 0xC8, 0xC5, 0x6C, 0x77, 0x87, - 0xEE, 0x42, 0x77, 0x87, 0x4C, 0xB7, 0xC1, 0x6E, 0x3C, 0x88, 0x04, 0xA5, - 0x5A, 0x2E, 0x4A, 0x54, 0x02, 0x86, 0x78, 0x50, 0x0F, 0x48, 0xBC, 0x78, - 0x68, 0x89, 0xC6, 0x3F, 0x43, 0x8B, 0x9E, 0xFC, 0x0B, 0xCE, 0xEC, 0x17, - 0xFB, 0x35, 0x6D, 0x8D, 0x3D, 0xCD, 0xFB, 0xBC, 0xCF, 0xF3, 0xCE, 0xFB, - 0x3E, 0x33, 0x3B, 0x01, 0xA1, 0x8C, 0x64, 0xA9, 0x0C, 0x81, 0x21, 0xE9, - 0x70, 0x9A, 0xB3, 0xD4, 0x87, 0xD9, 0x1C, 0x07, 0x14, 0x58, 0x91, 0xA7, - 0xB9, 0xD3, 0xE6, 0x71, 0xE7, 0xCD, 0xF3, 0xE1, 0xB3, 0xD6, 0xC6, 0xE9, - 0x8F, 0xD7, 0x7F, 0xBE, 0x37, 0x7E, 0x7F, 0xDA, 0xEB, 0x34, 0xBF, 0x9E, - 0xD5, 0x5B, 0xED, 0xED, 0xA3, 0x5F, 0x1F, 0x1A, 0x9D, 0xDD, 0x9F, 0xED, - 0xC6, 0xC9, 0x08, 0x27, 0x5E, 0xBC, 0x00, 0x80, 0x40, 0x8B, 0x18, 0x8A, - 0x84, 0x0B, 0x35, 0xBD, 0x88, 0xCA, 0x15, 0xB7, 0x5E, 0x09, 0xC3, 0x12, - 0xC2, 0x9A, 0x64, 0x50, 0xD6, 0x00, 0x10, 0x74, 0x64, 0x98, 0xEA, 0x1D, - 0x92, 0xAA, 0xD0, 0x78, 0xC0, 0x89, 0xC5, 0xD3, 0xE6, 0x93, 0xCE, 0xC1, - 0xB6, 0x90, 0x72, 0xA2, 0x60, 0xE2, 0xA4, 0xC1, 0x48, 0x34, 0xEB, 0xC9, - 0x89, 0xF6, 0xFE, 0x3E, 0xAB, 0xD4, 0x2E, 0x43, 0xB1, 0x75, 0xCC, 0xDA, - 0x63, 0x93, 0xA5, 0x38, 0x62, 0x28, 0x5A, 0xEF, 0x19, 0x8A, 0x9D, 0x0D, - 0x66, 0x82, 0x39, 0x3C, 0xCD, 0x45, 0xE7, 0x07, 0xEE, 0xDA, 0xB7, 0x30, - 0x68, 0x29, 0x90, 0x8A, 0x45, 0x3C, 0xCD, 0xA5, 0xB9, 0x60, 0x95, 0x74, - 0x72, 0xF1, 0xC9, 0x64, 0xF8, 0x52, 0x32, 0x7C, 0x39, 0x19, 0xBE, 0x92, - 0x0C, 0x5F, 0x4D, 0x86, 0xAF, 0x25, 0xC3, 0xD7, 0x93, 0xE1, 0x4C, 0x32, - 0x9C, 0x9E, 0x60, 0xE0, 0x8C, 0x39, 0xD3, 0x93, 0x3D, 0x0D, 0x54, 0xA4, - 0x5A, 0xE0, 0x46, 0x92, 0x48, 0xEC, 0xBC, 0x3B, 0xEC, 0x1C, 0x1C, 0x76, - 0xDE, 0x7E, 0x14, 0x52, 0x34, 0x8C, 0xE0, 0xE4, 0xC0, 0x92, 0xF1, 0x93, - 0x06, 0x83, 0x5F, 0x4F, 0xC4, 0xC9, 0x55, 0x65, 0xD4, 0xD9, 0x4D, 0xE6, - 0x6F, 0x1D, 0xFB, 0x38, 0xB0, 0x57, 0x09, 0x43, 0x44, 0xEE, 0x80, 0xAD, - 0x8E, 0xCD, 0x11, 0x9F, 0x20, 0xDE, 0x7B, 0xBC, 0xEB, 0x78, 0xBF, 0xF1, - 0x4E, 0xBB, 0xF6, 0xA8, 0x43, 0xAC, 0x29, 0x1A, 0xD4, 0x83, 0xDF, 0xBF, - 0x0B, 0x91, 0xED, 0x5E, 0xB4, 0x77, 0xE8, 0x41, 0x79, 0x40, 0x34, 0xFD, - 0x32, 0x96, 0x06, 0xE7, 0x61, 0x60, 0x13, 0x88, 0xA5, 0x40, 0x7D, 0x12, - 0x91, 0x9E, 0xBE, 0xB4, 0xB7, 0x36, 0xDB, 0xF5, 0x1D, 0x21, 0x45, 0xC3, - 0x08, 0xEE, 0x83, 0xC0, 0x5E, 0x79, 0x5A, 0xF2, 0xA2, 0xA5, 0x22, 0x4F, - 0x9A, 0x83, 0x2A, 0x92, 0x09, 0x17, 0x24, 0xD3, 0x84, 0xD8, 0xF0, 0xAD, - 0xF7, 0x11, 0xF7, 0xD5, 0x5B, 0xAE, 0x96, 0xCB, 0x9C, 0xF8, 0x80, 0xFC, - 0xF8, 0x76, 0xEB, 0x1B, 0x9F, 0xE7, 0xC9, 0x1D, 0xE4, 0x67, 0x79, 0x72, - 0x10, 0x3C, 0x98, 0x23, 0x3F, 0x6A, 0x8C, 0xAF, 0x61, 0x15, 0x29, 0x23, - 0xA3, 0xC4, 0x28, 0xD2, 0x97, 0x5E, 0x87, 0xCA, 0xFF, 0xC8, 0x2B, 0x2A, - 0xC2, 0x26, 0x2D, 0xD0, 0x53, 0x0E, 0x40, 0x08, 0x71, 0x7D, 0x32, 0x35, - 0x3D, 0xE2, 0x53, 0x00, 0x09, 0xF9, 0x34, 0xA3, 0xAA, 0x7C, 0x67, 0xEF, - 0x29, 0x9F, 0xCF, 0xF3, 0xED, 0xED, 0x67, 0x7C, 0xA1, 0xC0, 0x9F, 0x7D, - 0x7E, 0xC5, 0x83, 0x25, 0x21, 0x15, 0x50, 0xB0, 0x4A, 0x38, 0x2E, 0x25, - 0x97, 0xE8, 0xAB, 0x80, 0x6D, 0x13, 0xD1, 0x4F, 0xE5, 0xF3, 0x53, 0x85, - 0x42, 0x5F, 0x12, 0xD7, 0x9A, 0x19, 0xAA, 0x89, 0x0A, 0xA8, 0x19, 0x91, - 0xD1, 0xDD, 0x4B, 0xB3, 0x48, 0x50, 0xEF, 0x26, 0xCD, 0x4B, 0xC6, 0xCA, - 0x6A, 0x56, 0xAF, 0x14, 0xE6, 0x66, 0x6F, 0xAE, 0xDF, 0x7F, 0xA4, 0xE6, - 0xAC, 0x25, 0xC7, 0xC3, 0x20, 0xC9, 0x56, 0x1A, 0x55, 0xBD, 0x08, 0x71, - 0xD8, 0xC8, 0x10, 0xE6, 0xF6, 0x44, 0x30, 0xF2, 0x2D, 0xC8, 0x9C, 0x68, - 0x8D, 0x5A, 0x56, 0x66, 0xDC, 0xB2, 0x2C, 0x21, 0x15, 0xE2, 0xB1, 0xA5, - 0x72, 0x15, 0x63, 0x68, 0xC8, 0x35, 0x4E, 0x1C, 0x74, 0xC4, 0x99, 0xCC, - 0xE3, 0x61, 0x7F, 0x39, 0xD2, 0x77, 0x9D, 0x35, 0x88, 0x65, 0x68, 0x98, - 0x6E, 0x0B, 0x43, 0x71, 0x1D, 0xF5, 0x26, 0x36, 0x8F, 0x3F, 0xE3, 0xF9, - 0xD8, 0x03, 0x61, 0xC8, 0x2D, 0xAF, 0x40, 0x59, 0xD3, 0x25, 0x72, 0x5F, - 0xC6, 0xBD, 0x2A, 0x4E, 0x9A, 0x29, 0x28, 0x61, 0x54, 0x5D, 0xD3, 0xE8, - 0xF5, 0x18, 0xED, 0x53, 0xE1, 0x4F, 0x30, 0xD4, 0xA7, 0x40, 0xD7, 0x8C, - 0x6A, 0x85, 0x13, 0xC7, 0xFA, 0xA4, 0x5B, 0x10, 0x23, 0x4E, 0x9C, 0x88, - 0xB1, 0xCF, 0x8D, 0x09, 0x9D, 0xBD, 0x77, 0x30, 0x21, 0x67, 0xC2, 0xA0, - 0x77, 0x23, 0xED, 0x80, 0x13, 0xB3, 0xB9, 0x41, 0xF2, 0x6C, 0x85, 0x18, - 0x5D, 0x54, 0x5A, 0x05, 0xD1, 0x05, 0x95, 0xCD, 0xFE, 0x83, 0x2C, 0x78, - 0x10, 0x31, 0x91, 0xFD, 0x6E, 0xC6, 0xFA, 0xA6, 0xEF, 0x41, 0x6D, 0x0D, - 0x2E, 0x4B, 0xB2, 0xF7, 0x4C, 0x7B, 0xA1, 0x5B, 0x73, 0x46, 0x41, 0x45, - 0x08, 0xF2, 0xE4, 0xB4, 0x40, 0xC1, 0x54, 0xC0, 0x6D, 0x2E, 0x95, 0x48, - 0xCB, 0xD7, 0xC8, 0xDF, 0x92, 0x0A, 0x58, 0x20, 0x36, 0x32, 0x08, 0x9A, - 0xA1, 0x21, 0xA3, 0x0B, 0xE1, 0x06, 0xAA, 0x62, 0x0D, 0x62, 0xBA, 0x0B, - 0x83, 0xE1, 0xB4, 0xB2, 0xA0, 0xF5, 0xA4, 0x64, 0x61, 0x11, 0xC3, 0xF5, - 0xAE, 0x94, 0x19, 0x2C, 0x15, 0xC9, 0x47, 0xD9, 0x8D, 0xB2, 0xA8, 0x4A, - 0x1A, 0x83, 0x90, 0x43, 0x56, 0x75, 0x55, 0x02, 0xF3, 0xC8, 0x54, 0x35, - 0x99, 0xCE, 0x34, 0x76, 0xEF, 0x16, 0xC8, 0x77, 0x27, 0x13, 0x03, 0x64, - 0x15, 0x79, 0xE4, 0xBB, 0x5D, 0xB7, 0x2E, 0xA0, 0x1E, 0x76, 0xBB, 0xA7, - 0x52, 0xAB, 0x1A, 0xA5, 0x15, 0x64, 0x33, 0x9D, 0xDD, 0xED, 0x47, 0x2E, - 0x70, 0x9E, 0x42, 0xCA, 0xF9, 0x27, 0x42, 0xFC, 0x0B, 0xD9, 0x0E, 0x4B, - 0xED}; -const uint8_t g_jaJP_Locale[] = { - 0x78, 0x9C, 0xED, 0x56, 0xCB, 0x6E, 0xD3, 0x40, 0x14, 0x5D, 0x17, 0x89, - 0x7F, 0x18, 0x59, 0x20, 0x83, 0xD4, 0xD6, 0x0D, 0xEF, 0x56, 0xAE, 0xA5, - 0x8A, 0x96, 0x86, 0x16, 0xA3, 0x08, 0x57, 0xA0, 0x76, 0x83, 0x26, 0xF6, - 0x34, 0x99, 0x36, 0x9E, 0xA9, 0x26, 0xB6, 0x4A, 0xBC, 0xE2, 0x21, 0x20, - 0x48, 0x74, 0x01, 0x1B, 0x04, 0x44, 0x62, 0x55, 0x40, 0x02, 0x04, 0x8B, - 0x6E, 0xD8, 0xD0, 0xAF, 0x49, 0x5A, 0x56, 0xFC, 0x02, 0x33, 0x7E, 0xC5, - 0x8E, 0xED, 0xE0, 0xEE, 0xF1, 0x22, 0x99, 0x7B, 0x7C, 0xCE, 0xF5, 0xBD, - 0xE7, 0x8E, 0x47, 0x56, 0x5B, 0xD4, 0x84, 0x2D, 0x04, 0x08, 0xB4, 0xD1, - 0xBC, 0xB4, 0x05, 0xEF, 0xAF, 0xD4, 0x24, 0x60, 0xA1, 0xB6, 0x39, 0x2F, - 0x0D, 0xDE, 0xEC, 0x1F, 0x7F, 0xFF, 0x76, 0x8E, 0xFF, 0x0D, 0x7A, 0x5F, - 0xCF, 0x4B, 0xDA, 0xE9, 0x53, 0x00, 0xA8, 0x82, 0x4C, 0x2C, 0xC8, 0x8C, - 0x8E, 0x5D, 0xA7, 0xAD, 0x76, 0xA8, 0x6B, 0x30, 0xD4, 0xA0, 0x0C, 0x43, - 0x22, 0x58, 0x13, 0x40, 0xB5, 0x29, 0x71, 0x9A, 0xB7, 0xF9, 0xAD, 0xB6, - 0x88, 0x27, 0x82, 0x58, 0xAB, 0x0C, 0x7A, 0x5D, 0x55, 0x09, 0xD6, 0x09, - 0xF8, 0x42, 0x3E, 0x7C, 0x31, 0x1F, 0xBE, 0x94, 0x0F, 0x5F, 0xCE, 0x87, - 0xAF, 0xE4, 0xC3, 0x57, 0xF3, 0xE1, 0x6B, 0xF9, 0xF0, 0x6C, 0x3E, 0x5C, - 0x99, 0x29, 0xC0, 0x0B, 0xFA, 0xAC, 0x8C, 0x34, 0x0A, 0xC2, 0x75, 0xEC, - 0x53, 0xD2, 0x37, 0x00, 0xEB, 0x75, 0x36, 0x2F, 0x55, 0xA4, 0xFF, 0x06, - 0x9E, 0xC4, 0x40, 0x0B, 0x76, 0x12, 0xDB, 0x8E, 0x47, 0x9A, 0xD8, 0xBE, - 0xEF, 0x7B, 0xFC, 0x57, 0x55, 0x44, 0x38, 0xC4, 0x7B, 0xDD, 0x5C, 0xFC, - 0xE8, 0xD1, 0x97, 0x7C, 0xFE, 0x8F, 0x83, 0x82, 0x3C, 0x9F, 0x73, 0xF1, - 0xDF, 0xCF, 0x5F, 0xE5, 0xE2, 0xFD, 0xDE, 0x87, 0x11, 0x1C, 0xF8, 0xAB, - 0x9C, 0x26, 0x46, 0xF6, 0x40, 0xD8, 0x4D, 0xB6, 0x8F, 0x6C, 0x07, 0xD9, - 0xDA, 0xB3, 0x55, 0x67, 0xEB, 0xCD, 0x56, 0x5A, 0x5C, 0xA3, 0x8D, 0x18, - 0xB6, 0x30, 0xB2, 0x93, 0x2F, 0x79, 0x08, 0x69, 0xFD, 0xBD, 0x6E, 0xFF, - 0xC5, 0x1E, 0x1F, 0x4E, 0x04, 0x64, 0x6F, 0xFF, 0x7A, 0x99, 0xBE, 0x0D, - 0x86, 0x61, 0xE2, 0x21, 0x88, 0xC1, 0x44, 0x7E, 0x1E, 0x69, 0x47, 0x07, - 0x0F, 0xFB, 0x4F, 0x9F, 0xF8, 0xD9, 0x45, 0x18, 0xE3, 0xC7, 0xFB, 0x87, - 0x83, 0x77, 0x1F, 0x63, 0x10, 0xF8, 0xAB, 0x48, 0xCB, 0x8F, 0x2D, 0x65, - 0xE4, 0xDC, 0x0A, 0x50, 0x0B, 0x3A, 0xA8, 0x06, 0x1D, 0x07, 0x31, 0x12, - 0x5B, 0x1F, 0x23, 0xE1, 0xD1, 0xB6, 0xE9, 0xB6, 0x5A, 0x92, 0xB6, 0xCE, - 0x2F, 0xB9, 0xFF, 0xF3, 0x40, 0xD6, 0x65, 0x6E, 0xB8, 0xBC, 0x28, 0xF3, - 0x41, 0xC8, 0x4B, 0xFC, 0x12, 0xBE, 0xC4, 0x92, 0xA2, 0x1C, 0x2D, 0x4A, - 0x1A, 0x05, 0x39, 0x4A, 0xE9, 0x6D, 0x64, 0x05, 0x72, 0x45, 0xD7, 0x95, - 0xC5, 0xC5, 0x52, 0x9A, 0x76, 0x93, 0x32, 0x47, 0xA8, 0xF2, 0x35, 0x00, - 0xA4, 0x90, 0xD0, 0x10, 0x07, 0xDB, 0x23, 0x86, 0x24, 0x90, 0x94, 0x21, - 0x55, 0x79, 0xF0, 0xF6, 0xB1, 0xAC, 0xEB, 0x72, 0xBF, 0xFB, 0x4C, 0x36, - 0x0C, 0xF9, 0xE8, 0xD3, 0x6B, 0x79, 0x43, 0x55, 0x12, 0xF4, 0x22, 0x7D, - 0x60, 0x46, 0x75, 0x4E, 0xD7, 0xE7, 0x0C, 0x63, 0xAE, 0x9C, 0xC6, 0x37, - 0x20, 0x94, 0x94, 0x12, 0x84, 0xDD, 0x0B, 0xC9, 0x28, 0x5F, 0x74, 0x3E, - 0xD2, 0x67, 0xB8, 0x15, 0xD6, 0x38, 0x1A, 0xED, 0x8F, 0x65, 0x48, 0xB6, - 0xB6, 0xAB, 0x76, 0xDB, 0x58, 0x5A, 0xBC, 0xB1, 0x7B, 0xEF, 0x41, 0x73, - 0xD5, 0xDB, 0x08, 0x0C, 0x4B, 0x92, 0x7C, 0x25, 0x71, 0xED, 0x3A, 0x62, - 0x69, 0xD7, 0x52, 0x58, 0x58, 0x12, 0xC7, 0xF8, 0x0E, 0x37, 0x25, 0xCD, - 0x9B, 0xF4, 0xBC, 0xD9, 0x69, 0xCF, 0xF3, 0x54, 0x25, 0xC5, 0x2B, 0x96, - 0x9A, 0x2E, 0x63, 0x88, 0x98, 0x1D, 0x49, 0x3B, 0xE3, 0x8B, 0x4B, 0x0B, - 0x77, 0x10, 0x33, 0x11, 0x71, 0xC2, 0x67, 0x9E, 0xCD, 0xEA, 0x84, 0x19, - 0x99, 0x06, 0xE2, 0xA6, 0x86, 0x7D, 0x4E, 0xA4, 0xA1, 0x30, 0xBD, 0x85, - 0x4C, 0x6C, 0x43, 0xBE, 0x1B, 0xA6, 0xA3, 0x2C, 0xC1, 0xED, 0x42, 0x41, - 0x83, 0x51, 0x77, 0x07, 0x8B, 0xF9, 0x4F, 0x96, 0x54, 0xC4, 0x1D, 0x9C, - 0x2D, 0x29, 0xB0, 0x31, 0x71, 0xDB, 0x92, 0x36, 0x55, 0x92, 0xEE, 0x21, - 0x46, 0x25, 0x6D, 0x26, 0xC3, 0x1E, 0x1A, 0x93, 0x1A, 0x76, 0x34, 0x89, - 0x94, 0x33, 0x69, 0x30, 0xDA, 0x81, 0x7E, 0x20, 0x69, 0x7F, 0x0E, 0xF9, - 0x89, 0x9D, 0x66, 0x8C, 0x51, 0xE1, 0x36, 0x15, 0x0B, 0x49, 0x5B, 0xA9, - 0xAD, 0x9F, 0x40, 0x96, 0x1C, 0x44, 0x46, 0xE4, 0x1F, 0x7F, 0x99, 0xBA, - 0xC5, 0xDB, 0xDE, 0xD9, 0x41, 0x9B, 0xD0, 0x8C, 0x4E, 0xDB, 0x28, 0x0C, - 0x73, 0xAE, 0x52, 0xCF, 0xDD, 0x86, 0x60, 0x99, 0x3A, 0x4D, 0x6C, 0x82, - 0x1A, 0xA3, 0x53, 0x77, 0x6F, 0x02, 0x5D, 0x52, 0xC6, 0x91, 0x75, 0x4C, - 0xCC, 0x26, 0x8D, 0xC8, 0x77, 0x0A, 0xC8, 0x7A, 0x87, 0x7F, 0x2A, 0x5A, - 0x82, 0x55, 0x44, 0xC0, 0x04, 0x53, 0x32, 0x86, 0x70, 0x9D, 0xBA, 0x0C, - 0x23, 0x06, 0x0C, 0xC7, 0x2A, 0x60, 0x2C, 0x58, 0xB4, 0x8E, 0x40, 0x0D, - 0xFF, 0x93, 0x52, 0x45, 0x75, 0x86, 0x76, 0xC7, 0x52, 0x16, 0x18, 0xAC, - 0xF3, 0x17, 0x77, 0x1C, 0x65, 0xAD, 0x09, 0xF1, 0x58, 0x02, 0x6F, 0xA9, - 0x21, 0x6A, 0x01, 0xB7, 0xC6, 0xD2, 0x0C, 0x5A, 0x8A, 0xA6, 0x77, 0x5C, - 0xD2, 0xD8, 0xA2, 0x3E, 0x33, 0x18, 0x89, 0x7F, 0xAA, 0x25, 0xE6, 0xA9, - 0x2A, 0xC1, 0x87, 0xBD, 0xF6, 0x17, 0x6C, 0x42, 0x08, 0x21}; -const uint8_t g_koKR_Locale[] = { - 0x78, 0x9C, 0xED, 0x56, 0x4D, 0x6B, 0xD4, 0x40, 0x18, 0x3E, 0x57, 0xF0, - 0x3F, 0x0C, 0xC1, 0x12, 0x85, 0x76, 0xB7, 0xEB, 0x77, 0x4B, 0x1A, 0x28, - 0x6E, 0x6D, 0x65, 0x8D, 0x94, 0xA6, 0x58, 0xEC, 0x45, 0x66, 0x93, 0xE9, - 0x26, 0xED, 0x26, 0x53, 0x26, 0x09, 0x75, 0x73, 0xAE, 0x52, 0xF0, 0xE2, - 0xA1, 0x87, 0xEA, 0x6E, 0xB1, 0x07, 0x11, 0x2A, 0x88, 0x22, 0x22, 0x1E, - 0x14, 0x7F, 0x8D, 0x62, 0x6D, 0x8A, 0x7F, 0xC1, 0xC9, 0xE7, 0xE6, 0x63, - 0xB2, 0x4D, 0xEF, 0xEE, 0x61, 0x99, 0xF7, 0x99, 0xE7, 0x79, 0xF3, 0xBE, - 0xCF, 0x4C, 0x5E, 0x22, 0x74, 0xB1, 0x02, 0xBB, 0x08, 0x98, 0xD0, 0x40, - 0xB3, 0xDC, 0x26, 0x7E, 0xDC, 0x5A, 0xE6, 0x80, 0x8A, 0x2C, 0x65, 0x96, - 0xFB, 0x35, 0x38, 0x38, 0xFE, 0x34, 0xF8, 0xFD, 0xE1, 0xFD, 0xE5, 0xE3, - 0xD7, 0x47, 0x3F, 0xFB, 0xDF, 0xAF, 0x70, 0xE2, 0xC5, 0x0B, 0x00, 0x08, - 0x3E, 0xDF, 0x54, 0x21, 0x91, 0x7B, 0x46, 0x1B, 0x77, 0xAD, 0x48, 0xDA, - 0x21, 0xA8, 0x83, 0x89, 0x0E, 0x4D, 0x9F, 0x35, 0x06, 0x04, 0x03, 0x9B, - 0xB6, 0xF6, 0x80, 0x6E, 0x59, 0x7E, 0x3C, 0x16, 0xC6, 0x62, 0xC3, 0xEB, - 0xEF, 0x09, 0xF5, 0x70, 0x9D, 0x82, 0xAF, 0xB2, 0xE1, 0x6B, 0x6C, 0xF8, - 0x3A, 0x1B, 0xBE, 0xC1, 0x86, 0x6F, 0xB2, 0xE1, 0x5B, 0x6C, 0xF8, 0x36, - 0x1B, 0x9E, 0x66, 0xC3, 0x8D, 0xA9, 0x12, 0xBC, 0xA4, 0xCF, 0x46, 0xAE, - 0x51, 0x10, 0xAD, 0x13, 0x9F, 0xD2, 0xBE, 0x01, 0xD8, 0x6E, 0x93, 0x59, - 0xAE, 0xC1, 0xFD, 0x37, 0xF0, 0x3C, 0x06, 0xAA, 0xB0, 0x97, 0xBA, 0x76, - 0x34, 0x12, 0xBD, 0x83, 0x6F, 0xDE, 0xAB, 0x3D, 0xFA, 0x2F, 0xD4, 0xFD, - 0x70, 0x88, 0xF7, 0xF7, 0x98, 0xF8, 0xE9, 0x4B, 0x36, 0xEE, 0xED, 0xEE, - 0x33, 0xF1, 0x93, 0x77, 0x47, 0x4C, 0xFC, 0xCF, 0xD7, 0x5D, 0x76, 0xFE, - 0x67, 0x87, 0x39, 0x1C, 0x04, 0x2B, 0x46, 0x13, 0xB9, 0x3B, 0x10, 0x75, - 0x53, 0xEC, 0xA3, 0xD8, 0x41, 0xB1, 0xF6, 0x62, 0xD5, 0xC5, 0x7A, 0x8B, - 0x95, 0x96, 0xD7, 0x68, 0x20, 0xA2, 0xAB, 0x3A, 0x32, 0xD2, 0x2F, 0x79, - 0x04, 0x89, 0xDE, 0xFE, 0x1B, 0xEF, 0x70, 0x87, 0x1E, 0x4E, 0x0C, 0x14, - 0xB6, 0x4F, 0xFB, 0xB9, 0x6D, 0x30, 0x0C, 0x53, 0x0F, 0x41, 0x04, 0xA6, - 0xF2, 0xD3, 0x88, 0x56, 0xF9, 0xD1, 0xEB, 0xBF, 0x08, 0xB2, 0xFB, 0x61, - 0x82, 0x7B, 0x3B, 0x03, 0xBA, 0x95, 0x80, 0x20, 0x58, 0xC5, 0x5A, 0x3A, - 0xB6, 0xEA, 0xB9, 0xB9, 0x15, 0xA2, 0x2A, 0xB4, 0xD1, 0x12, 0xB4, 0x6D, - 0x44, 0xCC, 0xC4, 0xFA, 0x04, 0x89, 0x46, 0xDB, 0xBA, 0xD3, 0xED, 0x72, - 0xE2, 0x23, 0xFA, 0xE3, 0x4F, 0x9E, 0xEE, 0xF0, 0x40, 0xE2, 0xA9, 0xE3, - 0x3C, 0x68, 0xF2, 0xF4, 0x28, 0x78, 0x30, 0x4F, 0x7F, 0xBE, 0x35, 0x89, - 0xAA, 0x2C, 0x4D, 0x17, 0x9B, 0x9D, 0xD2, 0x34, 0x95, 0x32, 0x18, 0x48, - 0x0D, 0x13, 0xD4, 0x80, 0x24, 0xD5, 0x40, 0xB3, 0x59, 0x49, 0x65, 0x69, - 0x98, 0xD8, 0xBE, 0xAE, 0x4C, 0x05, 0x40, 0x06, 0x89, 0x9C, 0xB1, 0x75, - 0x23, 0xE7, 0x4C, 0x0A, 0xC9, 0x38, 0x33, 0x07, 0x34, 0x8D, 0xF7, 0x9E, - 0x0F, 0x68, 0x4B, 0x12, 0x7F, 0xF2, 0x85, 0xB6, 0x26, 0xCB, 0xBC, 0xF7, - 0x79, 0x97, 0x07, 0x6B, 0x42, 0x3D, 0x25, 0x2A, 0xCB, 0x12, 0x1A, 0x53, - 0x9A, 0xA5, 0x52, 0x8E, 0xC0, 0x1A, 0x9A, 0x62, 0x46, 0x92, 0x66, 0x64, - 0xB9, 0x92, 0x24, 0xF2, 0x25, 0x14, 0xE5, 0x15, 0xBE, 0x27, 0x39, 0x07, - 0xA2, 0xDB, 0xB2, 0x42, 0xD1, 0xF8, 0x0A, 0x2D, 0x40, 0x73, 0x63, 0x73, - 0xD1, 0xB0, 0xE4, 0xF9, 0xE6, 0xDD, 0xED, 0xD5, 0x27, 0x5A, 0xCB, 0x5D, - 0x0B, 0xAD, 0x4C, 0x93, 0x02, 0xA5, 0xE9, 0x18, 0x6D, 0x44, 0xB2, 0x7E, - 0x66, 0xB0, 0xA8, 0x28, 0x8A, 0xD1, 0x97, 0x40, 0xE1, 0x44, 0x77, 0xC2, - 0x75, 0xA7, 0x6B, 0xAE, 0xEB, 0x0A, 0xF5, 0x0C, 0xAF, 0x5C, 0xAA, 0x38, - 0x84, 0x20, 0x53, 0xE9, 0x71, 0xE2, 0xA5, 0x40, 0x5C, 0x59, 0xB8, 0x85, - 0x88, 0x82, 0x4C, 0x3B, 0x7A, 0xE6, 0x78, 0x51, 0xE7, 0x9B, 0x51, 0x68, - 0x20, 0x69, 0x6A, 0xD8, 0xE7, 0x58, 0x16, 0x8A, 0xD2, 0xAB, 0x48, 0xD1, - 0x0D, 0x48, 0xEF, 0x49, 0x2D, 0xCE, 0x12, 0x6E, 0x97, 0x0A, 0x3A, 0x04, - 0x3B, 0x5B, 0xBA, 0x7F, 0x27, 0x26, 0x2A, 0x2A, 0x92, 0x0E, 0xC6, 0x2B, - 0x0A, 0x0C, 0xDD, 0x74, 0x2C, 0x4E, 0x9C, 0xAC, 0x48, 0x77, 0x11, 0xC1, - 0x9C, 0x38, 0x55, 0x60, 0x0F, 0x8D, 0xC9, 0x1C, 0x76, 0x7C, 0x12, 0x19, - 0x67, 0xB2, 0x60, 0x7C, 0x07, 0x83, 0x80, 0x13, 0xFF, 0xFE, 0x78, 0x4B, - 0x07, 0x54, 0x86, 0x31, 0x42, 0xA5, 0x5B, 0xD8, 0x5F, 0x70, 0x62, 0x6B, - 0x79, 0xF5, 0x1C, 0xB2, 0xF4, 0x41, 0x14, 0x44, 0xC1, 0x84, 0x2C, 0xD4, - 0xED, 0xCF, 0x81, 0xDE, 0x16, 0x5A, 0x87, 0x4A, 0x3C, 0x90, 0xE3, 0x30, - 0xCA, 0x39, 0xA7, 0xE2, 0x36, 0x02, 0x52, 0xCF, 0x31, 0x3B, 0x1B, 0x18, - 0xC8, 0xB6, 0x0A, 0x24, 0xAE, 0xCE, 0x64, 0x4A, 0x3D, 0xFA, 0x75, 0xA8, - 0x82, 0x25, 0xEA, 0x64, 0x09, 0x41, 0x37, 0x75, 0x6C, 0x8E, 0x20, 0xDC, - 0xC1, 0x0E, 0xD1, 0x11, 0xF1, 0x9F, 0x52, 0xC2, 0x08, 0xAB, 0x59, 0xD2, - 0xCF, 0xA4, 0x2C, 0xA2, 0x36, 0x41, 0xDB, 0x23, 0x29, 0x73, 0x04, 0xB6, - 0xE9, 0x8B, 0x38, 0x8A, 0xB2, 0xA2, 0x41, 0xBD, 0x84, 0xD0, 0xC2, 0xAE, - 0xB3, 0x09, 0xC1, 0x02, 0xB6, 0x35, 0x5D, 0xF1, 0x7B, 0x9A, 0x7C, 0x78, - 0xAF, 0xD4, 0x9A, 0x88, 0x4C, 0x0D, 0x50, 0x34, 0x1C, 0x93, 0x97, 0x47, - 0x3E, 0x9A, 0x72, 0x3B, 0x81, 0xDD, 0xF7, 0x47, 0xD2, 0x64, 0x9C, 0xA1, - 0x05, 0x53, 0x2D, 0x75, 0x9E, 0x42, 0x3D, 0xFC, 0xFC, 0x17, 0xFF, 0x01, - 0xDC, 0xF1, 0x18, 0xD3}; -const uint8_t g_esES_Locale[] = { - 0x78, 0x9C, 0x9D, 0x56, 0xCF, 0x6B, 0xD4, 0x40, 0x14, 0xBE, 0x0B, 0xFE, - 0x0F, 0x21, 0x58, 0x56, 0xA1, 0xDD, 0xD1, 0x63, 0xCB, 0x36, 0x50, 0xDA, - 0xDA, 0x95, 0x1A, 0x59, 0x9A, 0xAA, 0xD8, 0x8B, 0x4C, 0x92, 0xE9, 0xEE, - 0xB4, 0xC9, 0xCC, 0x32, 0x49, 0x2C, 0x9B, 0xA3, 0xE0, 0x41, 0x10, 0x0B, - 0xDE, 0x8A, 0x27, 0x0F, 0x1E, 0x04, 0x8B, 0x77, 0x51, 0x3C, 0xF4, 0x3F, - 0x11, 0x6A, 0xEB, 0xC9, 0x7F, 0xC1, 0x37, 0x9B, 0x49, 0x36, 0x3F, 0x66, - 0xD7, 0x60, 0x4E, 0xF3, 0xBE, 0xF7, 0x7D, 0x2F, 0xEF, 0x7D, 0x93, 0x4C, - 0xD2, 0x0B, 0xB8, 0x87, 0x03, 0x62, 0x30, 0x1C, 0x92, 0x75, 0x93, 0x44, - 0xCF, 0xB7, 0x1D, 0xD3, 0xF0, 0x49, 0xE4, 0xAD, 0x9B, 0xD7, 0x1F, 0x7F, - 0x5C, 0x9D, 0x9E, 0x5F, 0xBD, 0x3E, 0xBB, 0xFE, 0x72, 0x7E, 0xBB, 0x08, - 0xFE, 0x7C, 0x7B, 0x73, 0xF9, 0xFE, 0xFB, 0xEF, 0xB3, 0x57, 0xBF, 0xDE, - 0xBE, 0xBB, 0xFC, 0x7A, 0x7A, 0xC7, 0xB4, 0x7A, 0xB2, 0x00, 0xF3, 0xB1, - 0x70, 0x26, 0xA1, 0xCB, 0x83, 0x48, 0xD5, 0x1A, 0x0A, 0x32, 0xE4, 0x82, - 0x62, 0x06, 0x8C, 0x90, 0xB3, 0x78, 0xF4, 0x08, 0xE0, 0x48, 0xAD, 0x2D, - 0xC2, 0x88, 0xE0, 0x3D, 0x94, 0x05, 0x37, 0x6F, 0x28, 0xF4, 0x90, 0xB8, - 0x42, 0x87, 0x87, 0x58, 0xA4, 0x4D, 0x14, 0xBB, 0x82, 0x06, 0x1A, 0xEE, - 0xA4, 0x49, 0x3D, 0x4A, 0x18, 0xD5, 0xA1, 0x81, 0x06, 0xC5, 0x43, 0x1E, - 0xC5, 0x4D, 0x38, 0x22, 0xE3, 0x98, 0x92, 0x10, 0x1A, 0x6C, 0xA4, 0xB8, - 0x17, 0x27, 0x3A, 0x9C, 0xF1, 0x17, 0x73, 0x14, 0x3E, 0xF5, 0x1A, 0x19, - 0x54, 0x72, 0x29, 0x27, 0x4E, 0x23, 0x03, 0xBB, 0xAE, 0x58, 0x37, 0xEF, - 0x99, 0x25, 0xF3, 0x74, 0xD6, 0xE9, 0x6C, 0xD3, 0x99, 0xA6, 0xB3, 0x4C, - 0xE7, 0x98, 0xCE, 0x2F, 0x9D, 0x5B, 0x3A, 0xAB, 0x74, 0x1E, 0xE9, 0xFC, - 0xD1, 0x39, 0x33, 0xDF, 0x13, 0x1F, 0x4F, 0xD4, 0x53, 0x04, 0x2B, 0xCB, - 0xE7, 0x21, 0x65, 0xF2, 0xF6, 0x32, 0xC8, 0xB2, 0x56, 0x90, 0x30, 0x12, - 0x55, 0x10, 0x30, 0x21, 0xAE, 0x43, 0xF4, 0xE2, 0x93, 0xF0, 0x78, 0x50, - 0x83, 0x8F, 0x12, 0xF2, 0xA2, 0x06, 0xC1, 0xFE, 0x89, 0x7A, 0xC1, 0xE8, - 0xE2, 0x83, 0x8B, 0xFD, 0xD9, 0x6D, 0x51, 0xD1, 0x55, 0xA9, 0xC3, 0xD2, - 0x9E, 0xA9, 0x56, 0xEB, 0x6D, 0xD6, 0x9B, 0x6C, 0x74, 0x58, 0xEF, 0xAD, - 0xDE, 0x58, 0xA3, 0x29, 0x7D, 0x47, 0x21, 0x11, 0xD4, 0x87, 0x87, 0x2D, - 0x7F, 0xFD, 0x54, 0x68, 0x6D, 0xD8, 0xE0, 0x6E, 0x1E, 0x94, 0x78, 0xD6, - 0xA0, 0x96, 0x40, 0xD5, 0x0A, 0x80, 0x10, 0x81, 0x55, 0x35, 0x58, 0x59, - 0xB8, 0xBB, 0xD9, 0xED, 0x21, 0xB9, 0xCA, 0x52, 0x96, 0x5F, 0x06, 0x50, - 0x41, 0x96, 0x41, 0xED, 0xA8, 0xC8, 0xBA, 0x8F, 0xC9, 0x00, 0xC7, 0x31, - 0x18, 0x3D, 0xDD, 0xD7, 0x22, 0x52, 0xE7, 0xC8, 0x61, 0x12, 0x04, 0xA6, - 0xB5, 0x0D, 0x97, 0xB1, 0xD5, 0x81, 0xA3, 0xC9, 0xE8, 0xD8, 0x70, 0x65, - 0xAB, 0x67, 0x70, 0xC9, 0x69, 0x0B, 0x4D, 0xAD, 0xA0, 0x2A, 0x11, 0x70, - 0x36, 0x34, 0xAD, 0xFF, 0x55, 0x87, 0xC4, 0x07, 0xF1, 0x16, 0xB2, 0x6D, - 0xD4, 0x52, 0x11, 0x8D, 0xB8, 0x88, 0x67, 0x9A, 0x86, 0x02, 0x55, 0x66, - 0x06, 0x20, 0xA6, 0x61, 0xC9, 0x83, 0x52, 0x54, 0xF1, 0xA0, 0xDF, 0xEF, - 0xF4, 0xA1, 0xFD, 0x0E, 0x5C, 0x0E, 0x9C, 0xD2, 0x07, 0x3D, 0x54, 0x62, - 0xD6, 0xCA, 0x54, 0x26, 0xEF, 0xF7, 0xD7, 0x6C, 0x7B, 0xCD, 0x71, 0x5A, - 0x49, 0xA6, 0xE3, 0x2A, 0x41, 0x0B, 0xBA, 0x9A, 0x55, 0x0A, 0x1A, 0x6C, - 0x54, 0x99, 0x4B, 0x59, 0xB5, 0x0F, 0x58, 0xBE, 0xFD, 0x3B, 0x89, 0x1D, - 0x1F, 0x8F, 0xC2, 0xC8, 0xD9, 0xDE, 0xBA, 0x7F, 0xF2, 0x14, 0x8F, 0x76, - 0xD3, 0x83, 0xCC, 0x9C, 0x32, 0x09, 0x74, 0x2C, 0x09, 0x5D, 0x22, 0x66, - 0x0E, 0x55, 0x62, 0xD5, 0x08, 0x60, 0xF0, 0x9C, 0x7A, 0xA6, 0x95, 0x2E, - 0xA7, 0xE9, 0x6A, 0x37, 0x4D, 0xD3, 0x1E, 0xAA, 0xF0, 0x1A, 0x85, 0x94, - 0xD0, 0x4B, 0x84, 0x20, 0xCC, 0x9B, 0xE4, 0xCA, 0xD5, 0x55, 0xE3, 0x56, - 0x4B, 0xE9, 0x98, 0x08, 0x8F, 0xB0, 0x58, 0x29, 0x97, 0x34, 0x2A, 0x54, - 0x6B, 0xBD, 0x28, 0x94, 0x4F, 0x57, 0x09, 0x55, 0x59, 0x9F, 0x78, 0x34, - 0xC4, 0xB0, 0xE3, 0xCB, 0xB9, 0x3E, 0x4B, 0xD7, 0xD5, 0xC5, 0x97, 0x96, - 0x27, 0x63, 0x2A, 0x37, 0xBA, 0xDB, 0x8A, 0x5F, 0x74, 0xBD, 0xD4, 0x8A, - 0x0E, 0x87, 0x6C, 0x12, 0x99, 0xD6, 0x4A, 0x2B, 0x72, 0x0A, 0x9F, 0x6F, - 0xD3, 0xBA, 0xDB, 0xE4, 0xA2, 0xEA, 0xD8, 0x80, 0xE4, 0xBE, 0x17, 0x4E, - 0x54, 0x81, 0xFC, 0xF9, 0x9A, 0x06, 0xA6, 0xF5, 0xF3, 0xE5, 0x67, 0x38, - 0x3E, 0x2A, 0x8C, 0x66, 0x11, 0xA5, 0xA1, 0x11, 0x97, 0x0B, 0x38, 0x35, - 0x1E, 0xEF, 0xB5, 0x16, 0x95, 0x4D, 0x6F, 0x4A, 0x50, 0xBD, 0x5B, 0xF9, - 0x32, 0x4C, 0xC6, 0xE4, 0x10, 0x7B, 0xF2, 0x1C, 0xCC, 0x97, 0xAA, 0x96, - 0x3D, 0x81, 0x1F, 0x1F, 0xDF, 0x18, 0x80, 0x17, 0xA8, 0xCC, 0xCC, 0xD3, - 0x14, 0xFE, 0x46, 0xD8, 0xDC, 0xF4, 0x26, 0x4F, 0x04, 0x7C, 0x77, 0x0C, - 0x27, 0xF6, 0xB5, 0xF9, 0x0D, 0x9F, 0xBB, 0xC4, 0x18, 0xD0, 0x7F, 0x10, - 0xFA, 0xF2, 0x67, 0xEA, 0x64, 0x01, 0x61, 0x43, 0x60, 0x17, 0x5E, 0x98, - 0xF9, 0x84, 0xFD, 0x11, 0xA6, 0xDA, 0xF4, 0x2E, 0x4F, 0x93, 0x63, 0x6C, - 0xEC, 0xF0, 0x78, 0x44, 0x3D, 0x39, 0xC7, 0xCA, 0x93, 0x07, 0x86, 0xBD, - 0x88, 0x0A, 0x23, 0x7B, 0x23, 0x9E, 0x53, 0xF7, 0x16, 0xDC, 0x14, 0x98, - 0x43, 0x39, 0x99, 0xF1, 0x70, 0x01, 0xC9, 0xE1, 0x2D, 0x48, 0xF6, 0x24, - 0x61, 0xC3, 0x23, 0x3E, 0xE5, 0xA9, 0xE6, 0xD0, 0x6C, 0xCF, 0x64, 0x94, - 0xFD, 0xFC, 0xC2, 0xF2, 0x2F, 0x7C, 0xDC, 0xCC, 0x2F, -}; -const uint8_t g_esLA_Locale[] = { - 0x78, 0x9C, 0x9D, 0x56, 0xCD, 0x4E, 0xDC, 0x30, 0x10, 0x3E, 0x53, 0xA9, - 0xEF, 0x60, 0x45, 0x45, 0x80, 0x04, 0x9B, 0xF6, 0xB8, 0x28, 0x44, 0x5A, - 0x01, 0xA5, 0x15, 0x0D, 0x5A, 0x75, 0x51, 0x4B, 0xB9, 0x54, 0x4E, 0x62, - 0x36, 0x86, 0xC4, 0x5E, 0x39, 0x09, 0x68, 0xA3, 0xBE, 0x40, 0x4F, 0x3D, - 0xF4, 0xD4, 0x63, 0x2B, 0x21, 0xB5, 0x07, 0xD4, 0x47, 0xE8, 0x81, 0x67, - 0x41, 0xF0, 0x18, 0x9D, 0xFC, 0x6E, 0x12, 0x3B, 0xE9, 0xD2, 0x9C, 0x3C, - 0xDF, 0x7C, 0x9F, 0x77, 0xE6, 0xB3, 0x33, 0x1B, 0xC3, 0xE7, 0x0E, 0xF6, - 0x09, 0x62, 0x38, 0x20, 0x3B, 0x1A, 0x09, 0x3F, 0x5A, 0x27, 0x1A, 0x72, - 0x49, 0xE8, 0xEC, 0x68, 0x0F, 0xD7, 0x7F, 0xEE, 0xBF, 0xDC, 0xDC, 0x7F, - 0xFE, 0xF6, 0xF0, 0xFB, 0x66, 0xFD, 0xEE, 0xC7, 0x4F, 0x88, 0xEF, 0xBE, - 0x5E, 0x6F, 0x68, 0xE6, 0xD3, 0x27, 0x08, 0x19, 0xA9, 0x8A, 0xB9, 0x58, - 0x4C, 0xE6, 0x81, 0xCD, 0xFD, 0xB0, 0xD8, 0x60, 0x2A, 0xC8, 0x94, 0x0B, - 0x8A, 0x59, 0xCA, 0x5A, 0x41, 0x46, 0xC0, 0x59, 0xE4, 0x1D, 0x41, 0x2A, - 0x4C, 0xE3, 0x95, 0x3C, 0x36, 0x09, 0x23, 0x82, 0x1B, 0x7A, 0x1E, 0xD4, - 0xF0, 0x33, 0x62, 0x0B, 0x75, 0x26, 0xC0, 0x22, 0x51, 0xE1, 0xD8, 0x16, - 0xD4, 0x57, 0xF2, 0xE7, 0x2A, 0xFA, 0x79, 0xCC, 0xA8, 0x1A, 0xF7, 0x95, - 0x38, 0x9E, 0xF2, 0x30, 0x52, 0x25, 0x42, 0x32, 0x8B, 0x28, 0x09, 0xA0, - 0x5C, 0x45, 0x92, 0x3B, 0x51, 0xAC, 0xCE, 0x30, 0x7E, 0xD9, 0xA9, 0x72, - 0xA9, 0x23, 0xE5, 0x50, 0xB1, 0xAE, 0x1C, 0xAC, 0x3B, 0x8A, 0xB0, 0x6D, - 0x8B, 0x1D, 0xED, 0x85, 0xD6, 0xB2, 0x56, 0x6D, 0xAC, 0xDA, 0x54, 0xB5, - 0xA5, 0x6A, 0x43, 0xD5, 0x7E, 0xAA, 0xDD, 0x54, 0x7B, 0xA9, 0x36, 0x52, - 0xED, 0xA0, 0xDA, 0x3D, 0xB5, 0x6F, 0xFD, 0x8E, 0xB9, 0x78, 0x5E, 0xBB, - 0x81, 0x10, 0x99, 0x2E, 0x0F, 0x28, 0x4B, 0xCB, 0x49, 0x83, 0x0A, 0xF5, - 0x63, 0x46, 0xC2, 0x16, 0x06, 0x16, 0x45, 0x32, 0x48, 0x6F, 0x7F, 0x09, - 0x87, 0xFB, 0x52, 0xE2, 0x3C, 0x26, 0x97, 0x12, 0x08, 0x27, 0x2E, 0xE4, - 0x8D, 0xC3, 0xDB, 0xEF, 0x36, 0x76, 0x17, 0x25, 0xA0, 0x6C, 0xA5, 0xA8, - 0xBA, 0x75, 0xCA, 0x45, 0xF9, 0x72, 0xE9, 0x72, 0xE1, 0x8A, 0xAA, 0xE5, - 0x7A, 0xE5, 0x62, 0x15, 0x85, 0x76, 0x57, 0x19, 0x10, 0x41, 0x5D, 0xB8, - 0xB6, 0xF5, 0x57, 0xBC, 0x80, 0xCC, 0x91, 0x05, 0x67, 0x51, 0x06, 0xCD, - 0xD4, 0xB8, 0x95, 0x42, 0x8B, 0xB0, 0xB6, 0x39, 0x11, 0xB8, 0xB6, 0x2F, - 0x44, 0x26, 0x1E, 0xEC, 0x0E, 0x0C, 0x3D, 0x5D, 0x55, 0x90, 0x5B, 0x87, - 0x50, 0xB6, 0x2A, 0x45, 0x30, 0xA5, 0xF4, 0xD6, 0x98, 0xCA, 0x51, 0x17, - 0x47, 0x64, 0x8C, 0xA3, 0x08, 0x0E, 0xA6, 0x72, 0xBB, 0x42, 0x8A, 0x49, - 0x76, 0x16, 0xFB, 0xBE, 0x66, 0xEE, 0xC3, 0x83, 0xF6, 0xD6, 0x60, 0x22, - 0xA2, 0x35, 0x0B, 0x9E, 0x7C, 0xF5, 0x01, 0x9E, 0xD4, 0x89, 0x4A, 0xD3, - 0xB5, 0x89, 0xCF, 0xD9, 0x54, 0x33, 0xFF, 0x5F, 0x1F, 0x10, 0x17, 0xE4, - 0x7B, 0xBA, 0x65, 0xE9, 0x4B, 0x6B, 0x42, 0x8F, 0x8B, 0x68, 0xA1, 0x6A, - 0x6B, 0x10, 0x6A, 0x20, 0x85, 0x23, 0x11, 0x0D, 0x5A, 0x8E, 0xD4, 0x90, - 0x86, 0x23, 0x9E, 0xB7, 0x6D, 0x59, 0xDB, 0x93, 0x09, 0x1A, 0xA1, 0x53, - 0x43, 0xAF, 0xB1, 0xBA, 0x64, 0xB9, 0x07, 0x8F, 0x96, 0x65, 0xAD, 0x2F, - 0x54, 0x4B, 0x69, 0x8A, 0xD6, 0x33, 0x95, 0x2C, 0x49, 0x3B, 0x6F, 0xF5, - 0x59, 0xDC, 0x85, 0x63, 0x40, 0xCB, 0x0B, 0x72, 0x10, 0x5B, 0xD1, 0x85, - 0x17, 0x84, 0x93, 0xFD, 0xBD, 0x97, 0x57, 0xEF, 0xB1, 0x77, 0x98, 0x9C, - 0xE6, 0x86, 0xD5, 0x49, 0x99, 0x92, 0xC5, 0x81, 0x4D, 0x44, 0xD3, 0xB5, - 0x06, 0x56, 0x54, 0x05, 0x18, 0xDC, 0x6D, 0x47, 0x33, 0x93, 0xCD, 0x24, - 0x19, 0x0E, 0x92, 0x24, 0x31, 0xF4, 0x06, 0xAF, 0x5B, 0xEA, 0xC4, 0x42, - 0x10, 0xE6, 0xCC, 0x35, 0xF3, 0x59, 0x2E, 0x1E, 0x0E, 0x3F, 0xAD, 0x57, - 0xCB, 0x8D, 0xA5, 0xF7, 0x99, 0x11, 0xE1, 0x10, 0x16, 0x15, 0x25, 0xAC, - 0xCA, 0xBA, 0xD4, 0x1B, 0xA9, 0x9F, 0xAA, 0xC7, 0x45, 0xDB, 0x2B, 0x4D, - 0xA8, 0xD8, 0xDE, 0x25, 0x0E, 0x0D, 0x30, 0x5C, 0x8E, 0x41, 0xB9, 0x4B, - 0x9E, 0xEE, 0x14, 0x4C, 0x05, 0x8F, 0x67, 0x34, 0xBD, 0x17, 0x9B, 0x4B, - 0x2A, 0xAA, 0x0E, 0x56, 0x97, 0x14, 0xC0, 0x84, 0x8F, 0x43, 0xCD, 0xDC, - 0x5A, 0x92, 0x9E, 0xC0, 0x77, 0x87, 0x66, 0x3E, 0x97, 0xD8, 0x0B, 0x63, - 0x1A, 0x67, 0x5F, 0x1E, 0x4C, 0xC3, 0x99, 0x26, 0x58, 0xDE, 0xC9, 0x2C, - 0x80, 0x03, 0x84, 0x59, 0xD4, 0xC8, 0xF7, 0x68, 0x68, 0xC8, 0xD3, 0x85, - 0x66, 0x5A, 0x27, 0x47, 0x8F, 0x90, 0xD5, 0x8F, 0x41, 0x12, 0x65, 0xC3, - 0x50, 0xAA, 0x3A, 0x7D, 0xF5, 0xE7, 0x33, 0x72, 0x86, 0x9D, 0x72, 0xE8, - 0x96, 0x61, 0xB1, 0xA7, 0x35, 0x87, 0xAF, 0x39, 0x17, 0x8D, 0xC1, 0x1D, - 0x5D, 0x4D, 0xA0, 0xF0, 0x49, 0xC5, 0x7A, 0x08, 0xBB, 0x3C, 0x16, 0xF0, - 0x17, 0x88, 0x26, 0x91, 0xDB, 0xC1, 0x18, 0xB9, 0xDC, 0x26, 0x68, 0x4C, - 0xFF, 0x49, 0x79, 0x95, 0x7E, 0x1F, 0x5E, 0xF5, 0x52, 0x46, 0x02, 0xDB, - 0xF0, 0xAE, 0xF5, 0x51, 0x8E, 0x3D, 0x4C, 0x3B, 0x08, 0x87, 0x3C, 0x89, - 0x2F, 0x30, 0x3A, 0xE0, 0x91, 0x47, 0x9D, 0xB4, 0xA7, 0xAD, 0x77, 0xAF, - 0x91, 0xD5, 0x4F, 0x06, 0x03, 0x1C, 0x8F, 0x97, 0xE4, 0xB7, 0xBD, 0x3F, - 0x0D, 0xDC, 0x69, 0xDA, 0x25, 0x7A, 0xD3, 0x4B, 0x9B, 0xF0, 0xA5, 0x68, - 0xD6, 0x3C, 0x66, 0xD3, 0x73, 0x9E, 0x31, 0xF3, 0x22, 0xB3, 0x11, 0x57, - 0x3B, 0x4F, 0x43, 0xCF, 0x3F, 0xEF, 0xCD, 0xBF, 0xC4, 0xB5, 0xD4, 0x04}; -const uint8_t g_deDE_Loacale[] = { - 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x6F, 0xD4, 0x30, 0x10, 0xBD, 0x23, 0xF1, - 0x1F, 0xAC, 0x88, 0xAA, 0x20, 0xB5, 0x1B, 0x38, 0xB6, 0xDA, 0x46, 0x5A, - 0x75, 0xFB, 0x41, 0x4B, 0xCA, 0xAA, 0x69, 0x41, 0xF4, 0x82, 0xBC, 0x89, - 0xBB, 0x71, 0x9B, 0xD8, 0x2B, 0xC7, 0x69, 0xB5, 0x39, 0xF2, 0x37, 0xB8, - 0x72, 0x04, 0x71, 0xE4, 0x04, 0x17, 0xFE, 0x09, 0x52, 0x25, 0x7E, 0x06, - 0x93, 0x8D, 0x93, 0x26, 0xB6, 0xBB, 0x0D, 0xB9, 0xAC, 0xE7, 0xCD, 0x7B, - 0xB3, 0x33, 0xCF, 0x89, 0x93, 0x61, 0xC2, 0x43, 0x9C, 0x10, 0xC4, 0x70, - 0x4A, 0x76, 0x9C, 0x88, 0x7C, 0x1C, 0xEF, 0x39, 0x28, 0x22, 0x59, 0xB8, - 0xE3, 0xDC, 0xFD, 0xFA, 0xF1, 0xF7, 0xFB, 0xB7, 0xE7, 0xF0, 0x73, 0xF7, - 0xF9, 0xE7, 0x0B, 0xC7, 0x1B, 0x96, 0x44, 0x16, 0x61, 0x11, 0x2C, 0xD2, - 0x29, 0x4F, 0x32, 0xA5, 0x99, 0x09, 0x32, 0xE3, 0x82, 0x62, 0x06, 0x8C, - 0x94, 0x33, 0x19, 0x9F, 0x00, 0x9C, 0xA9, 0xB5, 0x77, 0x84, 0x59, 0x8E, - 0xC5, 0xD0, 0xAD, 0xA2, 0xA7, 0x4F, 0x14, 0xBC, 0x4F, 0xA6, 0xC2, 0x86, - 0xFB, 0xBF, 0xBF, 0x88, 0xC2, 0x40, 0x47, 0x73, 0x41, 0x13, 0x93, 0x8B, - 0xA9, 0x81, 0x1D, 0xE5, 0xCC, 0x06, 0x26, 0x26, 0x38, 0xCA, 0x67, 0x79, - 0x26, 0x0D, 0x38, 0x20, 0x73, 0x49, 0xD2, 0x29, 0x31, 0x5B, 0x7B, 0x7B, - 0x2D, 0xB9, 0x0D, 0x3F, 0xE1, 0x37, 0x76, 0xC1, 0x98, 0x14, 0x7A, 0xC2, - 0x6D, 0x19, 0x54, 0xF3, 0x96, 0x11, 0xC2, 0xD3, 0xA9, 0xD8, 0x71, 0x5E, - 0x39, 0x2D, 0xDF, 0x6C, 0xA6, 0x99, 0x26, 0xD8, 0xED, 0xEA, 0x6B, 0x96, - 0xCD, 0x2B, 0x9B, 0x55, 0x36, 0x9F, 0x6C, 0x0E, 0xD9, 0xDC, 0xB1, 0x19, - 0xF3, 0xB0, 0x27, 0x11, 0x5E, 0xA8, 0x1B, 0x08, 0x56, 0x5E, 0xC0, 0x19, - 0x93, 0x18, 0xFE, 0xBE, 0x0C, 0xAA, 0xAC, 0xE7, 0x73, 0x03, 0x1A, 0x53, - 0xC2, 0x32, 0x83, 0x47, 0xA5, 0xBC, 0xE5, 0x61, 0xDC, 0x65, 0x42, 0x41, - 0x22, 0x0C, 0xEE, 0xBE, 0x20, 0x54, 0xC7, 0x02, 0x9C, 0x76, 0x78, 0x6E, - 0xD3, 0x5A, 0xAB, 0xCD, 0xD6, 0xC6, 0x55, 0xFD, 0x6A, 0xAD, 0x6A, 0x6D, - 0x6A, 0x0D, 0x6A, 0xAD, 0x69, 0x2D, 0x69, 0xDD, 0xD8, 0x1B, 0x49, 0x89, - 0xA0, 0x11, 0x25, 0x69, 0xFD, 0xD4, 0xA9, 0xD0, 0x1B, 0xF9, 0xE0, 0x6C, - 0x1D, 0xB4, 0x78, 0xDE, 0x44, 0x4B, 0xB8, 0xDD, 0x0A, 0x80, 0x10, 0x81, - 0x55, 0x35, 0x58, 0x79, 0x37, 0x03, 0xB4, 0x1B, 0x8B, 0xC1, 0xD0, 0x2D, - 0x83, 0x2A, 0xEB, 0x31, 0x0D, 0x73, 0x1B, 0x49, 0x19, 0x68, 0xE7, 0x44, - 0x35, 0x81, 0x24, 0x13, 0x2C, 0x25, 0x11, 0x6C, 0xB9, 0xB3, 0x4D, 0xA4, - 0x0E, 0x91, 0xCB, 0x3C, 0x49, 0x1C, 0x6F, 0x0F, 0xAE, 0x0D, 0x34, 0x1E, - 0x20, 0x1F, 0x2E, 0xF4, 0x01, 0xAE, 0x72, 0xD6, 0x86, 0xAB, 0x15, 0x52, - 0xD2, 0x84, 0xB3, 0x99, 0xE3, 0xFD, 0xA7, 0x28, 0x25, 0x11, 0x68, 0xC6, - 0x03, 0xDF, 0x1F, 0xF4, 0x54, 0x64, 0x31, 0x17, 0xF2, 0x5E, 0x63, 0x28, - 0xDC, 0xCE, 0x88, 0x00, 0x48, 0x9A, 0xB6, 0x46, 0x6E, 0x45, 0x9D, 0x91, - 0x0F, 0xB7, 0x7D, 0x7F, 0x1D, 0x9D, 0xC7, 0x02, 0xAD, 0x5F, 0x0C, 0xDD, - 0x16, 0x4B, 0x2B, 0xD1, 0x19, 0xF6, 0xB0, 0x54, 0x6D, 0x07, 0x01, 0xEA, - 0x23, 0x59, 0x8E, 0x5A, 0x2B, 0x7A, 0xF0, 0xD5, 0xA0, 0x4B, 0x85, 0x41, - 0x77, 0x3B, 0x53, 0x29, 0xA3, 0xCE, 0x00, 0xAB, 0xF7, 0xFA, 0xE0, 0xCA, - 0x97, 0xD7, 0x87, 0x69, 0x16, 0xEC, 0x8D, 0xF7, 0x6F, 0xDF, 0xE3, 0xF8, - 0xB8, 0xB8, 0xA8, 0xAC, 0x69, 0x93, 0x40, 0xC7, 0xF2, 0xF2, 0x68, 0xBC, - 0xF7, 0xA7, 0x13, 0xAB, 0x4E, 0x00, 0x83, 0x5B, 0x33, 0x74, 0xBC, 0x62, - 0xA3, 0x28, 0xB6, 0x06, 0x45, 0x01, 0xC7, 0x46, 0x87, 0x67, 0x14, 0x52, - 0xC2, 0x30, 0x17, 0x82, 0xB0, 0x70, 0x51, 0x2B, 0xB7, 0xB6, 0xD0, 0xB3, - 0x9E, 0xD2, 0x39, 0x11, 0x21, 0x61, 0x52, 0x29, 0xD7, 0x2C, 0x2A, 0x57, - 0x6B, 0xBD, 0x29, 0x54, 0x4F, 0xD7, 0x09, 0x9B, 0x17, 0x6B, 0x48, 0x53, - 0x0C, 0xFB, 0xBD, 0x51, 0xEB, 0xAB, 0xB4, 0xAE, 0x6E, 0xDE, 0xA9, 0x3C, - 0x9F, 0xD3, 0x72, 0xAB, 0x07, 0xBD, 0xF8, 0x4D, 0xD7, 0x6B, 0xBD, 0xE8, - 0x29, 0x65, 0x79, 0xE6, 0x78, 0x9B, 0xBD, 0xC8, 0x05, 0x11, 0xDC, 0xF1, - 0x5E, 0x9A, 0x5C, 0xB7, 0x3B, 0x36, 0x20, 0xB5, 0xEF, 0x8D, 0x13, 0x5D, - 0xA0, 0xBE, 0xC1, 0x96, 0x81, 0xE3, 0xFD, 0xF9, 0xF4, 0x15, 0xCE, 0x8A, - 0x0E, 0xC3, 0x2C, 0xA2, 0x34, 0x34, 0xE3, 0xE5, 0x02, 0x8E, 0x88, 0xF3, - 0xD3, 0xDE, 0xA2, 0xB6, 0xE9, 0xA6, 0xC4, 0xD5, 0xBB, 0x2D, 0x9F, 0x86, - 0xC5, 0x9C, 0x5C, 0xE2, 0xB0, 0x3C, 0xFA, 0xEA, 0xA5, 0xAA, 0xE5, 0x2F, - 0xE0, 0x13, 0x27, 0x42, 0x13, 0xF0, 0xC2, 0x6D, 0x33, 0xEB, 0x34, 0x65, - 0x94, 0xB3, 0x07, 0xD3, 0xBB, 0x3C, 0x17, 0x94, 0x08, 0x14, 0xC8, 0xC8, - 0x9A, 0x1F, 0x45, 0xF0, 0x69, 0x81, 0x26, 0xF4, 0x11, 0xC2, 0x21, 0x7C, - 0x35, 0x91, 0xDB, 0x15, 0x84, 0x91, 0xC0, 0x53, 0x78, 0x60, 0x1E, 0x26, - 0x9C, 0xC5, 0x98, 0x5A, 0xD3, 0xC7, 0xBC, 0xC8, 0xAF, 0x31, 0x3A, 0xE0, - 0x32, 0xA6, 0x61, 0x39, 0xC7, 0xE6, 0xBB, 0xD7, 0xC8, 0x5F, 0x45, 0x85, - 0x91, 0xC3, 0x98, 0xD7, 0xD4, 0xD3, 0x15, 0x7F, 0x0A, 0xCC, 0x59, 0x39, - 0x19, 0x7A, 0xB3, 0x82, 0x04, 0x6F, 0xFA, 0xC7, 0x49, 0xFE, 0x22, 0x67, - 0xB3, 0x2B, 0xBE, 0xE4, 0xA9, 0xE6, 0xDC, 0xFB, 0x3D, 0x2B, 0xA3, 0xEA, - 0x73, 0x16, 0x96, 0xFF, 0x00, 0x29, 0x27, 0xAF, 0x17, -}; -const uint8_t g_frFR_Locale[] = { - 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x6F, 0xD3, 0x40, 0x10, 0xBD, 0x23, 0xF1, - 0x1F, 0x56, 0x16, 0x55, 0x41, 0x6A, 0xBD, 0x70, 0x4C, 0x95, 0x5A, 0xAA, - 0xFA, 0x15, 0x28, 0x46, 0x51, 0x53, 0x40, 0xF4, 0x82, 0x36, 0xF6, 0x36, - 0xDE, 0xD4, 0xDE, 0x8D, 0xD6, 0x76, 0x4A, 0x7C, 0xE4, 0x3F, 0x70, 0xE2, - 0xC2, 0xB5, 0x12, 0x88, 0x03, 0x47, 0xC4, 0x85, 0xFE, 0x13, 0x24, 0x10, - 0x3F, 0x83, 0x71, 0xBC, 0x76, 0xED, 0x5D, 0x27, 0xB8, 0xBE, 0x64, 0xE7, - 0xCD, 0x7B, 0xE3, 0x99, 0xB7, 0xF6, 0xC6, 0xFD, 0x50, 0x78, 0x24, 0xA4, - 0x88, 0x93, 0x88, 0xEE, 0x5A, 0x17, 0xF2, 0xED, 0xD1, 0xA9, 0x85, 0x7C, - 0x1A, 0x7B, 0xBB, 0xD6, 0x9F, 0x6F, 0x1F, 0xFE, 0x7E, 0xFD, 0xF2, 0x10, - 0x7E, 0x7E, 0x7F, 0xFC, 0xF1, 0xC8, 0x72, 0xFA, 0x39, 0x91, 0xFB, 0x44, - 0x8E, 0x16, 0xD1, 0x58, 0x84, 0xB1, 0xD2, 0x4C, 0x24, 0x9D, 0x08, 0xC9, - 0x08, 0x07, 0x46, 0x24, 0x78, 0x12, 0xBC, 0x00, 0x38, 0x56, 0x6B, 0x67, - 0x4A, 0xF8, 0x9C, 0x51, 0xD9, 0xC7, 0x45, 0x78, 0xFF, 0x9E, 0xC2, 0x2F, - 0x6E, 0xAE, 0xE7, 0xB2, 0x2D, 0x11, 0x11, 0x19, 0x1B, 0x20, 0x01, 0x6E, - 0xD8, 0x42, 0x65, 0x06, 0x36, 0x4D, 0x19, 0x6F, 0x03, 0xC3, 0x90, 0x26, - 0x66, 0x59, 0x71, 0xF3, 0xDD, 0x44, 0x63, 0x3A, 0x4B, 0x68, 0x34, 0x96, - 0xD4, 0xC8, 0x08, 0x2F, 0x11, 0x6D, 0x38, 0x17, 0xF3, 0x76, 0x81, 0x7F, - 0x73, 0xED, 0xE9, 0x19, 0x5C, 0x33, 0xA9, 0x24, 0x2E, 0x23, 0x44, 0xC6, - 0x63, 0xB9, 0x6B, 0x3D, 0xB1, 0xEA, 0xDE, 0xD9, 0xED, 0xCE, 0x99, 0xF0, - 0x2A, 0xDF, 0xDA, 0x98, 0x77, 0xB0, 0xCD, 0x94, 0xAF, 0x36, 0xCD, 0xE4, - 0x82, 0x61, 0x26, 0x08, 0x6E, 0x99, 0x60, 0xEE, 0x94, 0xBD, 0xDA, 0x25, - 0x9F, 0x2C, 0xD4, 0x63, 0x05, 0x2B, 0xC7, 0x67, 0x11, 0xE1, 0x5E, 0x00, - 0xAE, 0xE6, 0x51, 0x91, 0x76, 0xC2, 0x94, 0xFB, 0xAC, 0x81, 0x80, 0x25, - 0x3A, 0x42, 0xA5, 0x27, 0xA9, 0x06, 0x4E, 0x69, 0xAA, 0x21, 0x73, 0x78, - 0xCC, 0x0D, 0x5A, 0x0C, 0xF7, 0xAF, 0x41, 0xB8, 0x6A, 0xA9, 0xD6, 0x5E, - 0x6D, 0x0B, 0x55, 0x9F, 0xB6, 0xDE, 0xA3, 0xAD, 0xB7, 0x68, 0xEB, 0x1D, - 0xDA, 0x7A, 0x77, 0xB6, 0xDE, 0x9C, 0xAD, 0x37, 0x66, 0xB7, 0xB7, 0x05, - 0xC5, 0x98, 0xCF, 0x68, 0x54, 0xBE, 0x91, 0x2A, 0x74, 0xF6, 0x5C, 0xF0, - 0xB7, 0x0C, 0x6A, 0x3C, 0x67, 0xA8, 0x25, 0x70, 0xB3, 0x02, 0x20, 0x54, - 0x12, 0x55, 0x0D, 0x56, 0xF0, 0x7C, 0xD9, 0xE8, 0x99, 0xBD, 0xBD, 0x0F, - 0xF7, 0xCF, 0xC3, 0x22, 0xEF, 0x90, 0x99, 0x8E, 0xE2, 0x4A, 0x96, 0x07, - 0xDA, 0x39, 0x52, 0xCC, 0x91, 0xD0, 0x21, 0x49, 0x12, 0x2A, 0xF9, 0x72, - 0x8F, 0xAB, 0xA8, 0x3C, 0x98, 0xD2, 0x30, 0xB4, 0x9C, 0x43, 0xB8, 0xD0, - 0x01, 0x72, 0xE1, 0x42, 0x6F, 0xE0, 0xCA, 0xA7, 0xAD, 0x98, 0x5A, 0x19, - 0x25, 0x0C, 0x05, 0x9F, 0x58, 0xCE, 0xDD, 0x34, 0xB0, 0xCF, 0x4A, 0x82, - 0x3A, 0xF1, 0xE3, 0x40, 0xC8, 0x04, 0x14, 0x07, 0xD8, 0x75, 0x71, 0x8B, - 0x02, 0x37, 0xA6, 0x03, 0x20, 0x61, 0x51, 0x6D, 0xDA, 0x5A, 0xD4, 0x98, - 0x76, 0x30, 0xD8, 0x44, 0x01, 0xDA, 0x84, 0x2E, 0xCE, 0xFB, 0xB8, 0x46, - 0xD2, 0x2A, 0x34, 0x06, 0x1D, 0x0C, 0x76, 0x5C, 0x77, 0x67, 0x34, 0xEA, - 0x24, 0x59, 0xCE, 0x59, 0x2A, 0x3A, 0xF0, 0xD5, 0x9C, 0x4B, 0x85, 0x41, - 0xC7, 0x8D, 0xA1, 0x94, 0x4F, 0x67, 0x80, 0x95, 0xBB, 0x7C, 0x4C, 0xDC, - 0xE9, 0xE5, 0x20, 0x8A, 0x47, 0x87, 0x07, 0x47, 0x57, 0xAF, 0xDF, 0x05, - 0x27, 0xD9, 0x79, 0xE1, 0x4C, 0x9D, 0x04, 0x3A, 0x9E, 0x46, 0x63, 0x2A, - 0x6F, 0xED, 0x69, 0xC4, 0xAA, 0x13, 0xC0, 0xE0, 0xC1, 0xF4, 0x2C, 0x27, - 0xDB, 0xCA, 0xB2, 0x9E, 0x9D, 0x65, 0x59, 0x1F, 0x37, 0x78, 0x46, 0x21, - 0x25, 0xF4, 0x52, 0x29, 0x29, 0xF7, 0x16, 0xA5, 0xB2, 0xD7, 0x43, 0x0F, - 0x3A, 0x4A, 0x67, 0x70, 0x76, 0x50, 0x9E, 0x28, 0xE5, 0x46, 0x8B, 0x0A, - 0x6B, 0xAD, 0x57, 0x85, 0xCA, 0xE9, 0x1A, 0xA1, 0x2A, 0xEB, 0x53, 0x0F, - 0x4E, 0x33, 0xD8, 0xEE, 0xAD, 0x52, 0x5F, 0xA4, 0x75, 0x75, 0xF5, 0x6F, - 0x2B, 0xD2, 0x19, 0xCB, 0xB7, 0xFA, 0xE7, 0xA7, 0x4E, 0x82, 0xAA, 0xED, - 0x8D, 0x4E, 0xF4, 0x88, 0xF1, 0x34, 0xB6, 0x9C, 0xED, 0x4E, 0xE4, 0x8C, - 0x4A, 0x61, 0x39, 0x8F, 0x4D, 0x2E, 0x6E, 0xCE, 0x0D, 0x48, 0x69, 0x7C, - 0x65, 0x45, 0x13, 0x28, 0x9F, 0xB0, 0x65, 0x60, 0x39, 0xBF, 0xDE, 0x7F, - 0x86, 0x63, 0xA2, 0xC1, 0x30, 0x8B, 0x28, 0x0D, 0x8B, 0x45, 0xBE, 0x80, - 0xD3, 0xE1, 0xE5, 0x69, 0x67, 0x51, 0xDD, 0x75, 0x53, 0x82, 0xF5, 0x6E, - 0xF3, 0xD7, 0x61, 0x31, 0xA3, 0x17, 0xC4, 0xCB, 0x4F, 0xBE, 0x72, 0xA9, - 0x6A, 0xB9, 0x0B, 0xF8, 0xFA, 0xF1, 0xD1, 0x10, 0xBC, 0xC0, 0x75, 0x66, - 0x99, 0x66, 0x9C, 0x09, 0xBE, 0x32, 0xBD, 0x2F, 0xD2, 0xFC, 0x3B, 0x08, - 0x8D, 0x12, 0xBF, 0x35, 0xBF, 0xE7, 0x8B, 0x31, 0x45, 0x43, 0xF6, 0x1F, - 0xC2, 0x80, 0xC2, 0x57, 0xC6, 0xD5, 0x1A, 0xC2, 0x9E, 0x24, 0x63, 0x78, - 0x63, 0x56, 0x13, 0xCE, 0x02, 0xC2, 0x5A, 0xD3, 0x27, 0x22, 0x4B, 0x2F, - 0x09, 0x3A, 0x16, 0x49, 0xC0, 0xBC, 0x7C, 0x8E, 0xED, 0x57, 0x4F, 0x91, - 0xBB, 0x8E, 0x0A, 0x23, 0x7B, 0x81, 0x28, 0xA9, 0xA7, 0x6B, 0x6E, 0x0A, - 0xCC, 0x49, 0x3E, 0x19, 0x7A, 0xBE, 0x86, 0x34, 0x12, 0x1D, 0x48, 0xEE, - 0x22, 0xE5, 0x93, 0xA9, 0x58, 0xF2, 0x54, 0x73, 0xF8, 0x76, 0xCF, 0xF2, - 0xA8, 0xF8, 0xD2, 0x85, 0xE5, 0x3F, 0x5D, 0x49, 0xBE, 0x1B}; -const uint8_t g_itIT_Locale[] = { - 0x78, 0x9C, 0x95, 0x56, 0xD1, 0x6A, 0xD4, 0x40, 0x14, 0x7D, 0x17, 0xFC, - 0x87, 0x21, 0x58, 0x50, 0x68, 0x3B, 0xFA, 0xD8, 0x92, 0x06, 0x4A, 0x5B, - 0xBB, 0xA5, 0x46, 0x96, 0xEE, 0xAA, 0xD8, 0x17, 0x99, 0x64, 0xA6, 0xD9, - 0xB1, 0xC9, 0xCC, 0x32, 0x49, 0x5A, 0x92, 0x47, 0xF1, 0xC1, 0x37, 0x7F, - 0x42, 0x10, 0x41, 0xF1, 0x23, 0xFC, 0x13, 0xA1, 0xE2, 0x67, 0x78, 0xB3, - 0x99, 0xA4, 0xC9, 0x64, 0xBA, 0xA6, 0x79, 0xD9, 0xB9, 0xE7, 0x9E, 0x73, - 0x73, 0xEF, 0x99, 0x64, 0x36, 0x6E, 0x2C, 0x43, 0x12, 0x33, 0x24, 0x48, - 0xC2, 0xF6, 0x1C, 0x9E, 0xBD, 0x3B, 0x99, 0x3B, 0x88, 0xB2, 0x34, 0xDC, - 0x73, 0xFE, 0x7C, 0xFC, 0x7C, 0xF3, 0xE5, 0xEB, 0xCD, 0xA7, 0x6F, 0x7F, - 0x7F, 0xFE, 0x78, 0xDC, 0x06, 0x4F, 0x1C, 0xCF, 0xAD, 0x14, 0x82, 0x12, - 0x35, 0x2B, 0x92, 0x40, 0xC6, 0xA9, 0x16, 0x47, 0x8A, 0x45, 0x52, 0x71, - 0x22, 0x80, 0x91, 0x48, 0x91, 0x2D, 0x5E, 0x02, 0x9C, 0xEA, 0xB5, 0x17, - 0x31, 0x21, 0x08, 0x97, 0x2E, 0xAE, 0xC3, 0x87, 0x0F, 0x34, 0x7E, 0xC1, - 0x82, 0x40, 0xD9, 0x12, 0x09, 0x51, 0xE5, 0x10, 0x25, 0x4B, 0xC5, 0x63, - 0x66, 0x21, 0x47, 0x91, 0xA5, 0x46, 0xC4, 0xF3, 0x48, 0x0C, 0xE1, 0x38, - 0x8F, 0x62, 0x0B, 0x9B, 0x44, 0x32, 0xCD, 0x86, 0x70, 0xCA, 0xB2, 0x8C, - 0x25, 0x81, 0x1A, 0xDE, 0x55, 0x66, 0x99, 0xB4, 0xE1, 0x42, 0x5E, 0xD9, - 0x05, 0x94, 0x87, 0x66, 0x02, 0x77, 0xAC, 0x6A, 0x78, 0xAB, 0x08, 0x11, - 0x30, 0x66, 0xCF, 0x79, 0xE6, 0x74, 0x1C, 0xB4, 0xB9, 0x67, 0x33, 0xCE, - 0x66, 0x9B, 0xCD, 0x33, 0x9B, 0x61, 0x36, 0xB7, 0x6C, 0x56, 0xD9, 0x7C, - 0xB2, 0x39, 0x64, 0x73, 0xC7, 0x66, 0xCC, 0xDD, 0x9E, 0x50, 0x52, 0xE8, - 0x47, 0x09, 0x56, 0x1E, 0x95, 0x09, 0x13, 0x3C, 0x24, 0x2E, 0xAE, 0xA2, - 0x3A, 0x0D, 0x3D, 0x0A, 0x46, 0x7F, 0x7D, 0xEF, 0x61, 0xE0, 0x43, 0x36, - 0x04, 0x99, 0x0A, 0x65, 0x3C, 0x80, 0xE1, 0xE1, 0xB9, 0x1A, 0x80, 0x57, - 0x4C, 0x30, 0x65, 0x82, 0x29, 0x09, 0x48, 0xF5, 0x90, 0x68, 0x08, 0xB7, - 0xCD, 0x75, 0x1A, 0xED, 0x6C, 0x9D, 0xEE, 0xD8, 0x6C, 0xD6, 0x6C, 0xD4, - 0xEC, 0xD1, 0x6C, 0xCE, 0xEC, 0xCB, 0x6C, 0xC9, 0xDE, 0x0F, 0x14, 0xE2, - 0x94, 0xB3, 0xA4, 0x79, 0x11, 0x75, 0xE8, 0xED, 0xFB, 0x60, 0x71, 0x13, - 0x74, 0x78, 0xDE, 0xD4, 0x48, 0xE0, 0x7E, 0x05, 0x40, 0x98, 0x22, 0xBA, - 0x1A, 0xAC, 0x3C, 0x72, 0xE0, 0xE2, 0xEA, 0xB7, 0x4E, 0x78, 0xF4, 0x36, - 0xC4, 0x2D, 0xB1, 0x0A, 0x8C, 0x03, 0xA3, 0x6E, 0x3C, 0x63, 0x53, 0x02, - 0x6F, 0x96, 0x12, 0xAB, 0x8D, 0x6D, 0x23, 0x7D, 0x9A, 0x5C, 0xE4, 0x71, - 0xEC, 0x78, 0x47, 0x70, 0xA1, 0x43, 0xE4, 0xC3, 0x85, 0xDE, 0xC2, 0x55, - 0xCD, 0xD7, 0x32, 0x8D, 0x32, 0x5A, 0x18, 0x4B, 0x11, 0x39, 0xDE, 0xE1, - 0xFD, 0x44, 0x09, 0xA3, 0x95, 0x06, 0x83, 0x04, 0x8F, 0x12, 0xA4, 0x0B, - 0xA9, 0x32, 0x2D, 0xB1, 0x29, 0x70, 0x6F, 0x3E, 0x00, 0x32, 0x9E, 0x74, - 0xE6, 0xED, 0x44, 0xBD, 0x79, 0x27, 0x93, 0x5D, 0xDF, 0xDF, 0x9D, 0xCD, - 0xD0, 0xB9, 0x8B, 0x3B, 0x1C, 0xA3, 0x40, 0x6F, 0xD2, 0xFB, 0x28, 0x56, - 0x63, 0x36, 0xF7, 0x18, 0xC1, 0xD7, 0x53, 0xAE, 0x14, 0x03, 0x3A, 0xEE, - 0x8D, 0xA4, 0x5D, 0x9A, 0x03, 0xD6, 0xEC, 0xF2, 0x71, 0xE1, 0xD3, 0xCB, - 0x49, 0x92, 0xCE, 0x8E, 0x0E, 0x9F, 0x5F, 0xBF, 0x21, 0x8B, 0xD3, 0xF2, - 0xBC, 0xF6, 0xA5, 0x4B, 0x02, 0x9D, 0xC8, 0x93, 0x80, 0xA9, 0x5B, 0x73, - 0x7A, 0xB1, 0xEE, 0x04, 0x30, 0x78, 0x14, 0x43, 0xC7, 0x2B, 0x37, 0xCB, - 0x72, 0x67, 0xBB, 0x2C, 0x4B, 0x17, 0xF7, 0x78, 0x83, 0x42, 0x5A, 0x18, - 0xE6, 0x4A, 0x31, 0x11, 0x16, 0x8E, 0xF7, 0x08, 0xD5, 0xDA, 0x9D, 0x9D, - 0x91, 0xD2, 0x25, 0x9C, 0x15, 0x4C, 0x64, 0xFA, 0x9E, 0x1B, 0x16, 0x15, - 0x36, 0x5A, 0x6F, 0x0B, 0x35, 0xD3, 0xF5, 0x42, 0x5D, 0x96, 0xB2, 0x90, - 0x27, 0x04, 0x36, 0x7B, 0xB3, 0xD1, 0xD7, 0x69, 0x53, 0xDD, 0xFE, 0xAD, - 0xCA, 0x7C, 0xC9, 0xAB, 0x9D, 0xDE, 0x1E, 0xC5, 0x6F, 0xBB, 0xDE, 0x18, - 0x45, 0x4F, 0xB8, 0xC8, 0x53, 0xC7, 0xDB, 0x1A, 0x45, 0x2E, 0x99, 0x92, - 0x8E, 0xF7, 0x74, 0xC8, 0xC5, 0xFD, 0xB1, 0x01, 0x69, 0x7C, 0x6F, 0x9D, - 0xE8, 0x03, 0xCD, 0x03, 0xB6, 0x0A, 0x1C, 0xEF, 0xF7, 0x07, 0x38, 0x65, - 0xFB, 0x8C, 0x61, 0x91, 0xE6, 0x23, 0x25, 0x95, 0xD5, 0x02, 0x0E, 0x87, - 0x57, 0x67, 0xA3, 0x45, 0x5D, 0xD3, 0x87, 0x12, 0x6C, 0x76, 0x5B, 0xBD, - 0x0D, 0xC5, 0x92, 0x5D, 0x90, 0xB0, 0x3A, 0xEA, 0x9A, 0xA5, 0xAE, 0xE5, - 0x17, 0xF0, 0x95, 0x43, 0xD1, 0x14, 0xBC, 0xC0, 0x5D, 0x66, 0x93, 0xE6, - 0x82, 0x4B, 0x71, 0x67, 0xFA, 0x40, 0xE6, 0x8A, 0x33, 0x85, 0x66, 0x19, - 0xB5, 0xE6, 0xF7, 0xA9, 0x0C, 0x18, 0x9A, 0xF2, 0xFF, 0x10, 0x26, 0x0C, - 0xBE, 0x23, 0xAE, 0xD7, 0x10, 0xF6, 0x15, 0x09, 0xE0, 0x85, 0xB9, 0x9B, - 0x30, 0x5F, 0x10, 0x6E, 0x4D, 0x9F, 0xCA, 0x32, 0xBF, 0x24, 0xE8, 0x58, - 0x66, 0x0B, 0x1E, 0x56, 0x73, 0x6C, 0xBD, 0x3E, 0x41, 0xFE, 0x3A, 0x2A, - 0x8C, 0x1C, 0x2E, 0x64, 0x43, 0x3D, 0x5B, 0x73, 0x53, 0x60, 0x46, 0xD5, - 0x64, 0xE8, 0xC5, 0x1A, 0xD2, 0x4C, 0x8E, 0x20, 0xF9, 0x45, 0x2E, 0xA2, - 0xF7, 0x72, 0xC5, 0xD3, 0xCD, 0xE1, 0xDB, 0x3D, 0xAB, 0xA2, 0xFA, 0xD3, - 0x16, 0x96, 0xFF, 0x00, 0x20, 0x8B, 0xBE, 0xF7}; -const uint8_t g_ptBR_Locale[] = { - 0x78, 0x9C, 0x9D, 0x56, 0x3D, 0x6F, 0xD4, 0x40, 0x10, 0xAD, 0x83, 0xC4, - 0x7F, 0x58, 0x59, 0x89, 0x0E, 0xA4, 0x24, 0x86, 0x92, 0xC8, 0x67, 0xE9, - 0x92, 0x0B, 0x39, 0x94, 0x18, 0x9D, 0xCE, 0x11, 0x88, 0x34, 0x68, 0x6D, - 0xEF, 0xD9, 0x9B, 0xD8, 0xBB, 0xC7, 0xDA, 0x4E, 0xB0, 0x6B, 0x1A, 0x3A, - 0x28, 0x29, 0x53, 0x20, 0x2A, 0x44, 0x83, 0x44, 0x49, 0x91, 0xDF, 0x82, - 0xB8, 0x9F, 0xC1, 0xFA, 0xF3, 0xFC, 0xB1, 0x36, 0x06, 0x37, 0xDE, 0x99, - 0x79, 0x6F, 0x3D, 0xF3, 0x76, 0x76, 0x64, 0xC5, 0xA5, 0x26, 0x74, 0x11, - 0x20, 0xD0, 0x43, 0x63, 0x69, 0x15, 0xBC, 0x3E, 0x5C, 0x48, 0xC0, 0x42, - 0xBE, 0x39, 0x96, 0xD6, 0x1F, 0x6F, 0xD7, 0x1F, 0xDE, 0xFD, 0x7E, 0xFF, - 0x69, 0xFD, 0xED, 0xEB, 0x83, 0x5F, 0x3F, 0xBE, 0xAF, 0x3F, 0xFF, 0x7C, - 0x28, 0xA9, 0xF7, 0xEF, 0x01, 0xA0, 0x24, 0x14, 0x62, 0x41, 0xA6, 0x47, - 0x9E, 0x41, 0x5D, 0x3F, 0x67, 0xDB, 0x0C, 0xD9, 0x94, 0x61, 0x48, 0x12, - 0xD4, 0x16, 0x50, 0x3C, 0x4A, 0x02, 0xE7, 0x39, 0x0F, 0xF9, 0x89, 0xBD, - 0x95, 0xD9, 0xEA, 0x25, 0x24, 0x08, 0x33, 0xAA, 0xC8, 0x99, 0x59, 0x89, - 0x2C, 0xD1, 0x35, 0x62, 0x1D, 0x31, 0x0F, 0xB2, 0xBB, 0x2F, 0xA2, 0x00, - 0x34, 0x18, 0x76, 0x85, 0x04, 0x2C, 0x82, 0x5F, 0x86, 0xC4, 0x11, 0xFB, - 0x5D, 0xA1, 0x1F, 0xDA, 0xD4, 0x0F, 0x44, 0x01, 0x1F, 0x05, 0xC8, 0x33, - 0x84, 0xB9, 0xD2, 0x30, 0x08, 0xC5, 0x11, 0x42, 0xAF, 0xBB, 0x48, 0x16, - 0x8A, 0x9B, 0x21, 0x90, 0xAF, 0x4B, 0x09, 0xAB, 0x92, 0x02, 0x68, 0x18, - 0x6C, 0x2C, 0x3D, 0x96, 0x1A, 0xDA, 0x8A, 0x75, 0x15, 0x2B, 0x2A, 0x96, - 0x53, 0x2C, 0xA6, 0x58, 0x4B, 0xB1, 0x92, 0x62, 0x1D, 0xC5, 0x22, 0x8A, - 0xF5, 0x13, 0x6B, 0x27, 0x96, 0xAD, 0x5F, 0x31, 0x0B, 0x46, 0x95, 0x16, - 0xE4, 0x96, 0x6A, 0x51, 0x0F, 0x93, 0x24, 0x9D, 0xC4, 0x28, 0xBD, 0x3E, - 0xB2, 0x43, 0xDE, 0xD2, 0x7B, 0x4B, 0xDE, 0x80, 0xB0, 0x11, 0x0B, 0x10, - 0x6F, 0x3E, 0x71, 0xE8, 0x4D, 0x08, 0x59, 0xD0, 0x15, 0xC2, 0xA4, 0x23, - 0xE4, 0xA3, 0xB7, 0x5D, 0x91, 0xBB, 0x5B, 0x03, 0x5A, 0x9B, 0xE4, 0x40, - 0xBA, 0x12, 0xD4, 0xD3, 0x38, 0xFF, 0xBC, 0xB0, 0x76, 0x51, 0xED, 0x52, - 0xDA, 0x15, 0xB4, 0x13, 0x6F, 0xE7, 0x2B, 0xC8, 0xB3, 0x3B, 0x49, 0x0F, - 0x31, 0x6C, 0x61, 0xE4, 0x55, 0x2F, 0x7F, 0xEE, 0x52, 0x27, 0x1A, 0x3F, - 0xA4, 0xC2, 0xA8, 0x87, 0xE6, 0x8D, 0x10, 0xD8, 0x98, 0x95, 0xCD, 0x11, - 0x83, 0x95, 0x7D, 0xB9, 0xA5, 0x1E, 0x1E, 0x29, 0x72, 0xF2, 0x2E, 0x1D, - 0x93, 0x69, 0xE9, 0x00, 0xE9, 0xAA, 0x20, 0xF0, 0xD9, 0x25, 0x37, 0x86, - 0x57, 0xE6, 0xB5, 0x60, 0x80, 0xE6, 0x30, 0xE0, 0xF2, 0x90, 0x52, 0xE8, - 0xD2, 0x93, 0xCF, 0xB7, 0x65, 0xE8, 0xBA, 0x92, 0x7A, 0xCC, 0x9F, 0x5D, - 0x30, 0x1D, 0xF1, 0x29, 0x09, 0x46, 0x1A, 0x7F, 0xB2, 0xD5, 0x2B, 0xFE, - 0x24, 0x32, 0x94, 0xA4, 0xAE, 0x5D, 0x5C, 0x4A, 0x6C, 0x49, 0xFD, 0x7F, - 0xBE, 0x87, 0x2C, 0x4E, 0x9F, 0xCA, 0x9A, 0x26, 0x0F, 0xE6, 0xF8, 0x0E, - 0x65, 0xC1, 0x86, 0xD5, 0xE4, 0x00, 0x50, 0xF3, 0xE4, 0x92, 0x04, 0xD8, - 0x6B, 0x48, 0x52, 0xF1, 0xD4, 0x24, 0x99, 0xCD, 0x46, 0x0E, 0x2F, 0x65, - 0xC4, 0xEF, 0xD5, 0x48, 0xD7, 0x47, 0xFE, 0x08, 0x5C, 0x28, 0x72, 0x05, - 0xDC, 0xC5, 0xCE, 0xA4, 0x48, 0xC9, 0x19, 0x77, 0x38, 0x35, 0x55, 0x61, - 0x36, 0x3B, 0xD0, 0xB4, 0x03, 0x5D, 0x1F, 0xC4, 0xC8, 0x35, 0x48, 0x39, - 0x4D, 0x42, 0x22, 0x40, 0xA3, 0xDC, 0xBC, 0x27, 0xCE, 0xB9, 0xB7, 0x68, - 0x94, 0x93, 0x48, 0xB3, 0xAE, 0x66, 0x9E, 0xAF, 0x1F, 0x4F, 0x9F, 0xDE, - 0xBC, 0x84, 0xCE, 0x69, 0x7C, 0x91, 0xE9, 0x56, 0x05, 0xA5, 0x4C, 0x12, - 0x7A, 0x06, 0x62, 0x75, 0xF1, 0x6A, 0xBE, 0x3C, 0x27, 0xEE, 0xE3, 0xFD, - 0x6D, 0x4A, 0x6A, 0xBC, 0x1B, 0xC7, 0x4F, 0xF6, 0xE3, 0x98, 0x0F, 0xB3, - 0x1A, 0xAE, 0x9B, 0x6A, 0x86, 0x8C, 0x21, 0x62, 0x46, 0x92, 0xBA, 0x0D, - 0x0A, 0xF6, 0x60, 0xF2, 0x0A, 0x31, 0x13, 0x91, 0x20, 0xFF, 0xEE, 0x4E, - 0x9B, 0x97, 0x08, 0xD2, 0x2A, 0xA2, 0x2C, 0x6C, 0x53, 0xEB, 0x56, 0xDD, - 0x95, 0x6F, 0x6F, 0x21, 0x13, 0x7B, 0x90, 0x37, 0xC6, 0x6E, 0xB1, 0x4B, - 0x16, 0xEE, 0x24, 0xD8, 0x8C, 0x86, 0x2B, 0x9C, 0x34, 0xC3, 0xFE, 0x40, - 0x46, 0x59, 0xC1, 0xCE, 0x40, 0x02, 0xEF, 0xAF, 0xD0, 0x97, 0xD4, 0xBD, - 0x81, 0xF0, 0x18, 0x31, 0x2A, 0xA9, 0x8F, 0x5A, 0xE8, 0x8D, 0x30, 0xB5, - 0x03, 0x2F, 0x4E, 0xA3, 0xA6, 0x4C, 0xDD, 0x59, 0xB4, 0x61, 0x6A, 0x48, - 0xEA, 0x62, 0x9B, 0x4F, 0xA2, 0x1A, 0xA0, 0x87, 0x84, 0x7D, 0x9A, 0x2C, - 0x24, 0xF5, 0x70, 0x71, 0xF6, 0x0F, 0xB4, 0xEA, 0x39, 0xB4, 0x48, 0xE9, - 0x28, 0x6C, 0xA5, 0x9D, 0xDC, 0xFB, 0x68, 0x85, 0x96, 0xD0, 0x2C, 0xC6, - 0x6D, 0x61, 0xE6, 0x7B, 0x6A, 0x11, 0xFF, 0xC3, 0xB3, 0xC0, 0x9C, 0xCB, - 0x23, 0x8B, 0x01, 0x98, 0x60, 0x4A, 0x7A, 0x00, 0x47, 0x34, 0x64, 0x18, - 0x31, 0xA0, 0x07, 0x56, 0x07, 0x62, 0x62, 0x51, 0x03, 0x81, 0x39, 0xFE, - 0x2B, 0x64, 0x86, 0x0C, 0x86, 0x6E, 0x7A, 0x21, 0x13, 0x06, 0x0D, 0x7E, - 0xC3, 0xFA, 0x20, 0xE7, 0x0E, 0xC4, 0x1D, 0x80, 0x53, 0x1A, 0x87, 0x57, - 0x10, 0x9C, 0xD0, 0xC0, 0xC1, 0x66, 0x52, 0xD3, 0xDE, 0x8B, 0x67, 0x40, - 0xEB, 0x07, 0x73, 0x01, 0x4C, 0x87, 0x16, 0xE0, 0x45, 0xEF, 0xA7, 0x39, - 0xD6, 0x4E, 0xAA, 0x04, 0x67, 0xBD, 0x30, 0x9D, 0x0E, 0x82, 0x69, 0x51, - 0x48, 0xEC, 0x4B, 0x9A, 0x22, 0xB3, 0x24, 0xD3, 0xC1, 0x56, 0x39, 0x4F, - 0x45, 0xCE, 0xFE, 0xF7, 0xD5, 0x3F, 0x30, 0xBB, 0xD9, 0x9B}; -const uint8_t g_nlNL_Locale[] = { - 0x78, 0x9C, 0x95, 0x56, 0x4D, 0x4F, 0xDC, 0x30, 0x10, 0x3D, 0x53, 0xA9, - 0xFF, 0xC1, 0x8A, 0x8A, 0x68, 0x25, 0x96, 0x2D, 0x47, 0x50, 0x88, 0xB4, - 0x05, 0x0A, 0x15, 0x04, 0xAD, 0x58, 0xDA, 0xAA, 0x5C, 0x2A, 0x6F, 0x62, - 0x76, 0xBD, 0x24, 0xF6, 0xCA, 0x89, 0x41, 0xC9, 0xB1, 0x52, 0x8F, 0xFD, - 0x27, 0xAD, 0xDA, 0x5B, 0xFF, 0x4F, 0xA5, 0x4A, 0xFC, 0x8C, 0x8E, 0xF3, - 0x45, 0x12, 0x3B, 0x69, 0xC8, 0x05, 0xCF, 0x9B, 0xF7, 0xBC, 0x33, 0xCF, - 0xCE, 0x10, 0x3B, 0xE0, 0x1E, 0x0E, 0x08, 0x62, 0x38, 0x24, 0x07, 0x16, - 0x0B, 0x3E, 0x5F, 0x9C, 0x5B, 0xC8, 0x27, 0x91, 0x77, 0x60, 0x3D, 0x7C, - 0xFB, 0xFD, 0xF7, 0xEB, 0xAF, 0x87, 0x9F, 0x3F, 0x5E, 0xE6, 0xAB, 0x57, - 0x96, 0xF3, 0xFC, 0x19, 0x42, 0xB6, 0xE2, 0x33, 0x1F, 0x8B, 0x59, 0x12, - 0xCE, 0x79, 0x10, 0x15, 0xD2, 0x85, 0x20, 0x0B, 0x2E, 0x28, 0x66, 0x8A, - 0xB5, 0x81, 0xEC, 0x90, 0xB3, 0x78, 0x79, 0x01, 0xA9, 0x48, 0xC5, 0x1B, - 0x79, 0xEC, 0xAC, 0x30, 0x93, 0x58, 0x50, 0x7B, 0x9C, 0x87, 0xB5, 0xCC, - 0x0D, 0x99, 0x8B, 0x8E, 0x54, 0x88, 0xB1, 0x88, 0x0D, 0x38, 0x5E, 0x0B, - 0x1A, 0x98, 0xF8, 0xC4, 0xB4, 0xCB, 0x4A, 0x32, 0x33, 0x1C, 0x98, 0x60, - 0x2C, 0x17, 0x32, 0x8A, 0x65, 0x64, 0x48, 0x45, 0x64, 0x1D, 0x93, 0x70, - 0x4E, 0x84, 0x21, 0xC7, 0x6F, 0x63, 0x6E, 0xCE, 0x30, 0x7E, 0xD7, 0x25, - 0xF2, 0x89, 0xD7, 0x4E, 0xA1, 0x62, 0x5D, 0x19, 0x58, 0x37, 0x14, 0xE1, - 0xF9, 0x5C, 0x1C, 0x58, 0xBB, 0x56, 0xCB, 0x59, 0xB3, 0xAB, 0x26, 0x83, - 0xBA, 0xEC, 0x7C, 0x8A, 0x99, 0x66, 0x2F, 0xCD, 0x56, 0x9A, 0x5D, 0x34, - 0xFB, 0x67, 0xF6, 0xCE, 0x6C, 0x5B, 0xBF, 0x63, 0x3E, 0x4E, 0x6A, 0x17, - 0x10, 0x22, 0x27, 0xE5, 0x70, 0x71, 0xA1, 0x1A, 0xB5, 0xAE, 0x40, 0xB8, - 0x5E, 0x06, 0xD4, 0xA7, 0x2C, 0xD2, 0xD1, 0x7B, 0x4E, 0x4C, 0xB0, 0x0F, - 0xFB, 0x12, 0xA1, 0xE3, 0x77, 0x82, 0xAE, 0x74, 0x34, 0xC5, 0x71, 0x93, - 0x8C, 0xB2, 0x95, 0xA1, 0xF2, 0xD6, 0x49, 0xE7, 0x2D, 0x68, 0xE5, 0x6B, - 0x95, 0x6B, 0x45, 0x6B, 0xE5, 0x6A, 0x75, 0x6A, 0x25, 0x76, 0x17, 0x17, - 0x12, 0x41, 0x7D, 0x4A, 0xC2, 0xFA, 0xCB, 0x5D, 0x40, 0xCE, 0xC4, 0x85, - 0x63, 0x28, 0x83, 0x66, 0x6A, 0xDA, 0x4A, 0xA1, 0xC7, 0xB0, 0xB6, 0x39, - 0x11, 0xB8, 0xB6, 0x2F, 0x44, 0xCE, 0x9B, 0x43, 0x7B, 0xAC, 0xFE, 0x56, - 0xC0, 0xE4, 0xA8, 0x02, 0x50, 0xB6, 0x2A, 0x05, 0x30, 0x9B, 0xC6, 0xAD, - 0xE1, 0x94, 0xA3, 0x3E, 0x18, 0x3E, 0xC5, 0x31, 0xB8, 0xCE, 0x2A, 0x83, - 0x2B, 0xA4, 0x98, 0x5F, 0x37, 0x32, 0x08, 0x2C, 0xE7, 0x18, 0x1E, 0x74, - 0x84, 0x5C, 0x78, 0xD0, 0x27, 0x78, 0x54, 0xEF, 0x15, 0xB3, 0x4B, 0x1A, - 0x70, 0xB6, 0xB0, 0x9C, 0xA7, 0xAA, 0x42, 0xE2, 0x83, 0x68, 0x04, 0x9A, - 0xD1, 0x60, 0x4D, 0xB4, 0xE4, 0x22, 0xCE, 0x54, 0x23, 0x5D, 0x81, 0x50, - 0x03, 0x29, 0x7A, 0x8F, 0x69, 0xD8, 0xEA, 0xBD, 0x86, 0x34, 0x7A, 0x3F, - 0xDD, 0x77, 0xDD, 0xFD, 0xD9, 0x6C, 0x0B, 0x49, 0x29, 0xB6, 0xD0, 0xB5, - 0x3D, 0xAE, 0x11, 0xBB, 0x94, 0x79, 0xEB, 0x85, 0x72, 0xA0, 0x26, 0x6B, - 0xBC, 0x90, 0x0C, 0x12, 0x14, 0x5D, 0x2B, 0x49, 0x9B, 0xAF, 0x7A, 0x6E, - 0x75, 0x58, 0x9C, 0xF7, 0x15, 0xA0, 0xE5, 0x25, 0x38, 0x49, 0x5C, 0xFF, - 0xF6, 0x34, 0x8C, 0x66, 0xC7, 0x47, 0x6F, 0xEF, 0x3F, 0xE2, 0xE5, 0x59, - 0x7A, 0x9D, 0x5B, 0x55, 0x27, 0x65, 0x4A, 0x26, 0xD5, 0x20, 0x6E, 0xFA, - 0xD5, 0xC0, 0xCA, 0x7F, 0x94, 0x52, 0xDD, 0x5D, 0xCF, 0x72, 0xD2, 0xED, - 0x34, 0xDD, 0xDB, 0x49, 0xD3, 0xD4, 0x1E, 0x37, 0x78, 0xDD, 0x52, 0x4F, - 0x0A, 0x41, 0x98, 0x97, 0x58, 0xCE, 0x0B, 0x94, 0xAB, 0xF7, 0xF6, 0xA2, - 0xC1, 0xEA, 0x35, 0x11, 0x1E, 0x61, 0x71, 0xF1, 0xC3, 0x9B, 0xBA, 0x4E, - 0x39, 0xA2, 0x75, 0x51, 0x75, 0xF6, 0xD8, 0xEC, 0x46, 0x13, 0x2A, 0xB6, - 0x87, 0x99, 0x4A, 0x43, 0x0C, 0x97, 0x61, 0xBB, 0xDC, 0x25, 0x4F, 0x77, - 0x0A, 0x16, 0x82, 0xCB, 0x35, 0x55, 0x97, 0x60, 0x67, 0xA0, 0xA2, 0xEA, - 0x60, 0x73, 0xA0, 0x20, 0xA4, 0x4C, 0x46, 0x96, 0x33, 0x1A, 0x48, 0x4F, - 0x89, 0xE0, 0x96, 0xF3, 0x5A, 0x63, 0x3F, 0x1A, 0xD3, 0x38, 0xF1, 0xF2, - 0x38, 0x1A, 0xCE, 0x34, 0xC1, 0xF2, 0x1A, 0x66, 0x81, 0xE5, 0xFC, 0xF9, - 0xF2, 0x1D, 0xE6, 0x4C, 0x83, 0xD1, 0xA3, 0xA2, 0x11, 0x57, 0x0B, 0x18, - 0x2D, 0xEF, 0x2F, 0x9F, 0x20, 0xAB, 0x1F, 0x84, 0x26, 0xCA, 0x06, 0x9D, - 0x56, 0xB7, 0x7A, 0xD9, 0x93, 0x35, 0xB9, 0xC1, 0x5E, 0x39, 0x4C, 0xCB, - 0xB0, 0xD8, 0xD3, 0x4D, 0xE0, 0xFB, 0xCC, 0x47, 0x53, 0xF0, 0x67, 0x6C, - 0x26, 0x50, 0x46, 0x39, 0xEB, 0x21, 0x1C, 0x72, 0x29, 0x28, 0x11, 0x68, - 0x16, 0xFB, 0x1D, 0x8C, 0x89, 0x0F, 0xDF, 0x3F, 0x68, 0x4A, 0xFF, 0x4B, - 0x39, 0x85, 0xEF, 0x3D, 0x72, 0xDF, 0x4B, 0x99, 0x08, 0x3C, 0x87, 0x77, - 0xAC, 0x8F, 0x72, 0xB5, 0xC4, 0xB4, 0x83, 0x70, 0xC6, 0x53, 0x79, 0x8B, - 0xD1, 0x09, 0x8F, 0x97, 0xD4, 0x53, 0x3D, 0x8D, 0x3E, 0xBC, 0x43, 0x6E, - 0x3F, 0x19, 0x0C, 0xF0, 0x96, 0xBC, 0x24, 0x5F, 0xF6, 0xFE, 0x34, 0x70, - 0x17, 0xAA, 0x4B, 0x74, 0xDE, 0x4B, 0x9B, 0xF1, 0x41, 0x34, 0x37, 0x91, - 0x6C, 0xB1, 0xE2, 0x19, 0x33, 0x2F, 0x32, 0x1B, 0x6D, 0xB5, 0xF3, 0xB4, - 0xC7, 0xF9, 0xA7, 0xBA, 0xF3, 0x0F, 0xD5, 0xFA, 0xC0, 0xFA}; -const uint8_t g_ruRU_Locale[] = { - 0x78, 0x9C, 0xAD, 0x57, 0x4D, 0x4F, 0x13, 0x41, 0x18, 0x3E, 0x63, 0xE2, - 0x7F, 0x98, 0x6C, 0x24, 0x68, 0x02, 0xAD, 0x1E, 0x25, 0x65, 0x13, 0x22, - 0x0A, 0x06, 0xD7, 0x90, 0x16, 0x34, 0x72, 0x31, 0xDB, 0xDD, 0xA1, 0x5D, - 0xE8, 0xEE, 0x90, 0xE9, 0x6E, 0xB0, 0x7B, 0x2A, 0x85, 0xE8, 0x05, 0x25, - 0xE1, 0xA0, 0x47, 0xF4, 0xE4, 0xC9, 0x50, 0xBE, 0x12, 0x82, 0xB6, 0x24, - 0xFE, 0x82, 0xD9, 0xFF, 0x60, 0xD4, 0x9F, 0xE1, 0x3B, 0xFB, 0xD1, 0xEE, - 0xB7, 0xC5, 0xD8, 0x1E, 0x3A, 0xF3, 0x3E, 0xCF, 0xF3, 0xCE, 0xFB, 0xB5, - 0xD3, 0xB6, 0xD4, 0x20, 0x8A, 0xDC, 0xC0, 0xC8, 0x90, 0x75, 0x3C, 0x23, - 0x50, 0xEB, 0x65, 0x79, 0x45, 0x40, 0x2A, 0x6E, 0x2A, 0x33, 0xC2, 0x8F, - 0xAB, 0xDD, 0xDF, 0x47, 0x5F, 0x6E, 0xC3, 0xC7, 0xAF, 0xDE, 0x87, 0x9F, - 0xEF, 0x8F, 0xEE, 0x08, 0xE2, 0xCD, 0x1B, 0x08, 0x95, 0x38, 0xDF, 0x50, - 0x65, 0x5A, 0x69, 0xE9, 0x55, 0xD2, 0x68, 0xFA, 0xD2, 0x1A, 0xC5, 0x35, - 0x42, 0x35, 0xD9, 0xE0, 0xAC, 0x31, 0x54, 0xD2, 0x89, 0x61, 0xD6, 0x9F, - 0x02, 0xD4, 0xE4, 0xFB, 0x31, 0x6F, 0x2F, 0x3A, 0xFB, 0xAC, 0xC7, 0x4E, - 0x58, 0xD7, 0x69, 0x3B, 0xFB, 0xA5, 0xA2, 0x67, 0x0B, 0xC3, 0xBB, 0xEC, - 0x9C, 0x9D, 0x38, 0x6D, 0xD6, 0x65, 0x5F, 0x53, 0x09, 0xEC, 0x9B, 0xAB, - 0xED, 0xB0, 0x6E, 0x1A, 0xD8, 0x65, 0x57, 0xA0, 0x3D, 0xCF, 0xD3, 0xA6, - 0x02, 0x17, 0xCE, 0x3B, 0xD6, 0xCB, 0x86, 0x32, 0xDC, 0x75, 0x21, 0x91, - 0x53, 0x67, 0xC7, 0xD9, 0xCE, 0x08, 0xC7, 0xD9, 0x86, 0x50, 0x7A, 0x4E, - 0x07, 0x72, 0x3E, 0xCE, 0xC8, 0x97, 0xF5, 0xD9, 0x65, 0x3E, 0xA1, 0xC7, - 0xFA, 0x79, 0xF0, 0x19, 0x1C, 0x71, 0x09, 0x91, 0xC4, 0x09, 0xC8, 0x5F, - 0x0F, 0x1A, 0x10, 0x6E, 0x08, 0x92, 0xAB, 0x55, 0x3A, 0x23, 0xDC, 0x13, - 0x92, 0x9D, 0x29, 0xE4, 0x34, 0x25, 0x0D, 0x1B, 0xA1, 0x1F, 0x99, 0xB2, - 0xFF, 0xDD, 0x8A, 0xD4, 0xD8, 0xFD, 0x1E, 0xA4, 0x06, 0xE1, 0x16, 0x3F, - 0x15, 0xF1, 0xAB, 0x9E, 0x8A, 0xB9, 0x25, 0x2F, 0xE4, 0xD7, 0x5A, 0x95, - 0x5B, 0xA1, 0xD1, 0x87, 0x9D, 0x08, 0x01, 0xF6, 0x21, 0x98, 0x4B, 0x3E, - 0x9F, 0x7E, 0x50, 0x7B, 0xEC, 0xBC, 0x54, 0xE4, 0xD8, 0x90, 0x74, 0x05, - 0x31, 0xF5, 0x00, 0x3C, 0x73, 0x87, 0x78, 0x0F, 0xD6, 0x17, 0xEC, 0x32, - 0x4E, 0x3A, 0x81, 0x72, 0xF7, 0xC1, 0x4F, 0x1A, 0x08, 0xC3, 0xD8, 0x76, - 0xF5, 0xDD, 0x38, 0xF0, 0x06, 0xCE, 0xED, 0x40, 0x14, 0xE7, 0x40, 0x38, - 0x4D, 0x9C, 0xEB, 0xEC, 0x03, 0x08, 0x0E, 0x9D, 0xD7, 0x49, 0xE5, 0xB6, - 0xB3, 0xC3, 0x8E, 0xE1, 0xDD, 0xF7, 0xDA, 0xEC, 0x83, 0xC8, 0x5D, 0xA5, - 0xE4, 0x1C, 0x9B, 0x2E, 0xD7, 0xFF, 0x81, 0xB3, 0x1D, 0x3F, 0xF2, 0x90, - 0xF5, 0xE2, 0xA6, 0x03, 0xA7, 0x13, 0x37, 0x7D, 0x72, 0xDA, 0x71, 0xD3, - 0xE7, 0x24, 0xEB, 0x30, 0x45, 0xC8, 0x8E, 0xB3, 0x43, 0xD5, 0x31, 0xD5, - 0x54, 0x0D, 0xEB, 0xE1, 0xEB, 0xC9, 0x37, 0x89, 0xB3, 0x12, 0xB4, 0x33, - 0xD8, 0x44, 0xA1, 0xA5, 0x18, 0x84, 0x86, 0xDB, 0x90, 0x73, 0x4C, 0xE5, - 0x90, 0x5F, 0xD8, 0xF1, 0x91, 0xE9, 0x23, 0xD6, 0x2B, 0x38, 0x6F, 0x61, - 0x6C, 0xB8, 0x61, 0x88, 0x44, 0x8D, 0xC8, 0x5D, 0x05, 0x6A, 0xB8, 0x6A, - 0x8B, 0xB1, 0xBB, 0xD6, 0xB3, 0xAA, 0xB2, 0x89, 0x97, 0x64, 0xD3, 0xC4, - 0xD4, 0x18, 0xD4, 0x7E, 0x60, 0xF1, 0xAF, 0xE3, 0x35, 0xAB, 0xD1, 0x10, - 0xC4, 0x39, 0x24, 0xC1, 0x0B, 0xBD, 0x80, 0x17, 0x9A, 0x80, 0x27, 0x64, - 0x82, 0x57, 0x62, 0x40, 0xCD, 0xD2, 0x36, 0x88, 0x51, 0xFB, 0x57, 0xAD, - 0x8E, 0x55, 0x90, 0xCE, 0x15, 0x24, 0xA9, 0xC0, 0x95, 0x23, 0x69, 0x9A, - 0x75, 0x42, 0xCD, 0xA1, 0x2A, 0xAE, 0x41, 0x28, 0x62, 0xF1, 0x8B, 0x60, - 0x6A, 0x7A, 0xAC, 0x08, 0x21, 0x4B, 0xA4, 0x08, 0x0B, 0xD3, 0x92, 0x34, - 0x5D, 0xA9, 0xA0, 0xD5, 0x52, 0x31, 0x44, 0xC9, 0xD2, 0x78, 0xC9, 0x5F, - 0x4F, 0xE3, 0x26, 0xED, 0x4B, 0x46, 0x12, 0xF8, 0x19, 0x73, 0x49, 0x9C, - 0xCF, 0xB3, 0x8D, 0xE5, 0xE6, 0xB7, 0x7C, 0x19, 0xAC, 0xC1, 0x1C, 0xCC, - 0xCB, 0xC6, 0xFA, 0xC6, 0x82, 0xDE, 0xAC, 0x3C, 0x9C, 0x7B, 0xB4, 0xF5, - 0xFC, 0x55, 0x7D, 0xD1, 0x5E, 0xF5, 0x8A, 0x14, 0x26, 0xB9, 0x4A, 0xC3, - 0xD2, 0xAB, 0x98, 0x46, 0x2B, 0x15, 0xB1, 0xF9, 0x21, 0x81, 0x0D, 0x66, - 0x59, 0x11, 0x44, 0x7B, 0xD2, 0xB6, 0xEF, 0x17, 0x6C, 0xDB, 0x2E, 0x15, - 0x23, 0xBC, 0x6C, 0xA9, 0x62, 0x51, 0x8A, 0x0D, 0xA5, 0x35, 0xD4, 0xDE, - 0x1A, 0x59, 0xBB, 0x89, 0xA9, 0x82, 0x0D, 0xD3, 0x97, 0x8E, 0x27, 0x75, - 0xBC, 0x1E, 0x89, 0x1C, 0x06, 0x79, 0x0D, 0x53, 0x1D, 0x8B, 0x9A, 0x7C, - 0xF7, 0x2A, 0x56, 0x34, 0x5D, 0x86, 0x21, 0x98, 0x0C, 0xBC, 0x78, 0x70, - 0xA6, 0xA0, 0x46, 0x89, 0xB5, 0xA9, 0xF1, 0x11, 0xF8, 0xFE, 0x71, 0x44, - 0xC9, 0x20, 0x85, 0xF1, 0x11, 0x05, 0xBA, 0x66, 0x58, 0x4D, 0x41, 0x9C, - 0x1A, 0x91, 0x6E, 0x63, 0x4A, 0x04, 0xF1, 0x6E, 0x82, 0x3D, 0xAC, 0x4C, - 0xA4, 0xE1, 0x41, 0x37, 0x22, 0xA5, 0x89, 0x1A, 0x83, 0x29, 0x74, 0x37, - 0x82, 0xE8, 0x7E, 0x47, 0x47, 0x19, 0x39, 0x2A, 0xAD, 0x49, 0xF8, 0x42, - 0x10, 0xCB, 0x2B, 0xE5, 0x6B, 0xC8, 0xC2, 0x9D, 0x48, 0x88, 0xDC, 0xAB, - 0x2E, 0x11, 0x37, 0x7F, 0xCA, 0x5B, 0x9B, 0x78, 0x4D, 0x56, 0x82, 0xBB, - 0x35, 0xD8, 0xFA, 0x3E, 0xA5, 0x16, 0xFC, 0xE0, 0x54, 0xD1, 0x12, 0xD4, - 0xA7, 0x98, 0x4E, 0xD0, 0x0C, 0x8D, 0x18, 0x39, 0x84, 0x07, 0xC4, 0xA2, - 0x1A, 0xA6, 0xA8, 0x62, 0xAA, 0x19, 0x8C, 0x59, 0x95, 0x54, 0x31, 0x5A, - 0xD2, 0xFE, 0x4A, 0x59, 0xC0, 0x55, 0x8A, 0xB7, 0x72, 0x29, 0xB3, 0x54, - 0xAE, 0xC2, 0x23, 0x96, 0x47, 0x59, 0xAE, 0xCB, 0x5A, 0x06, 0x61, 0x91, - 0xD8, 0xD6, 0x86, 0x8C, 0xE6, 0x89, 0x59, 0xD7, 0x14, 0x9E, 0xD3, 0xD4, - 0xB3, 0xC7, 0x48, 0xCA, 0x27, 0x43, 0x01, 0x94, 0x3A, 0x09, 0xC8, 0xE5, - 0xDC, 0xA3, 0x81, 0x5B, 0xE3, 0x59, 0xA2, 0x27, 0xB9, 0xB4, 0x0A, 0x19, - 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B, - 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB, - 0x8B, 0xC4}; -static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { - if (pBuf == NULL || nBufLen <= 0) { - return NULL; - } - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) { - return NULL; - } - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) { - return NULL; - } - CXML_Element* pLocale = NULL; - uint8_t* pOut = NULL; - FX_DWORD dwSize; - pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0, - 0, 0, 0, 0, pOut, dwSize); - if (pOut) { - pLocale = CXML_Element::Parse(pOut, dwSize); - FX_Free(pOut); - } - if (pLocale) { - return new CXFA_XMLLocale(pLocale); - } - return NULL; -} -static FX_WORD XFA_GetLanguage(CFX_WideString wsLanguage) { - FX_WORD dwLangueID = XFA_LANGID_en_US; - if (wsLanguage.GetLength() < 2) { - return dwLangueID; - } - wsLanguage.MakeLower(); - FX_DWORD dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); - FX_DWORD dwIDSecond = wsLanguage.GetLength() >= 5 - ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) - : 0; - switch (dwIDFirst) { - case FXBSTR_ID(0, 0, 'z', 'h'): { - if (dwIDSecond == FXBSTR_ID(0, 0, 'c', 'n')) { - dwLangueID = XFA_LANGID_zh_CN; - } else if (dwIDSecond == FXBSTR_ID(0, 0, 't', 'w')) { - dwLangueID = XFA_LANGID_zh_TW; - } else if (dwIDSecond == FXBSTR_ID(0, 0, 'h', 'k')) { - dwLangueID = XFA_LANGID_zh_HK; - } - } break; - case FXBSTR_ID(0, 0, 'j', 'a'): - dwLangueID = XFA_LANGID_ja_JP; - break; - case FXBSTR_ID(0, 0, 'k', 'o'): - dwLangueID = XFA_LANGID_ko_KR; - break; - case FXBSTR_ID(0, 0, 'e', 'n'): { - if (dwIDSecond == FXBSTR_ID(0, 0, 'g', 'b')) { - dwLangueID = XFA_LANGID_en_GB; - } else { - dwLangueID = XFA_LANGID_en_US; - } - } break; - case FXBSTR_ID(0, 0, 'd', 'e'): - dwLangueID = XFA_LANGID_de_DE; - break; - case FXBSTR_ID(0, 0, 'f', 'r'): - dwLangueID = XFA_LANGID_fr_FR; - break; - case FXBSTR_ID(0, 0, 'e', 's'): { - if (dwIDSecond == FXBSTR_ID(0, 0, 'e', 's')) { - dwLangueID = XFA_LANGID_es_ES; - } else { - dwLangueID = XFA_LANGID_es_LA; - } - } break; - case FXBSTR_ID(0, 0, 'i', 't'): - dwLangueID = XFA_LANGID_it_IT; - break; - case FXBSTR_ID(0, 0, 'p', 't'): - dwLangueID = XFA_LANGID_pt_BR; - break; - case FXBSTR_ID(0, 0, 'n', 'l'): - dwLangueID = XFA_LANGID_nl_NL; - break; - case FXBSTR_ID(0, 0, 'r', 'u'): - dwLangueID = XFA_LANGID_ru_RU; - break; - } - return dwLangueID; -} -CXFA_LocaleMgr::CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid) - : m_dwLocaleFlags(0x00) { - m_dwDeflcid = XFA_GetLanguage(wsDeflcid); - CXFA_Node* pNodeLocale = NULL; - if (pLocaleSet && - (pNodeLocale = pLocaleSet->GetNodeItem(XFA_NODEITEM_FirstChild))) { - while (pNodeLocale) { - m_LocaleArray.Add(new CXFA_NodeLocale(pNodeLocale)); - pNodeLocale = pNodeLocale->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } - 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(); - } -} -void CXFA_LocaleMgr::Release() { - delete this; -} -FX_WORD CXFA_LocaleMgr::GetDefLocaleID() { - return m_dwDeflcid; -} -IFX_Locale* CXFA_LocaleMgr::GetDefLocale() { - 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]; - } - m_pDefLocale = GetLocale(m_dwDeflcid); - if (m_pDefLocale) - m_XMLLocaleArray.Add(m_pDefLocale); - return m_pDefLocale; -} -IFX_Locale* CXFA_LocaleMgr::GetLocale(FX_WORD lcid) { - IFX_Locale* pLocal = NULL; - switch (lcid) { - case XFA_LANGID_zh_CN: - pLocal = XFA_GetLocaleFromBuffer(g_zhCN_Locale, sizeof(g_zhCN_Locale)); - break; - case XFA_LANGID_zh_TW: - pLocal = XFA_GetLocaleFromBuffer(g_zhTW_Locale, sizeof(g_zhTW_Locale)); - break; - case XFA_LANGID_zh_HK: - pLocal = XFA_GetLocaleFromBuffer(g_zhHK_Locale, sizeof(g_zhHK_Locale)); - break; - case XFA_LANGID_ja_JP: - pLocal = XFA_GetLocaleFromBuffer(g_jaJP_Locale, sizeof(g_jaJP_Locale)); - break; - case XFA_LANGID_ko_KR: - pLocal = XFA_GetLocaleFromBuffer(g_koKR_Locale, sizeof(g_koKR_Locale)); - break; - case XFA_LANGID_en_GB: - pLocal = XFA_GetLocaleFromBuffer(g_enGB_Locale, sizeof(g_enGB_Locale)); - break; - case XFA_LANGID_es_LA: - pLocal = XFA_GetLocaleFromBuffer(g_esLA_Locale, sizeof(g_esLA_Locale)); - break; - case XFA_LANGID_es_ES: - pLocal = XFA_GetLocaleFromBuffer(g_esES_Locale, sizeof(g_esES_Locale)); - break; - case XFA_LANGID_de_DE: - pLocal = XFA_GetLocaleFromBuffer(g_deDE_Loacale, sizeof(g_deDE_Loacale)); - break; - case XFA_LANGID_fr_FR: - pLocal = XFA_GetLocaleFromBuffer(g_frFR_Locale, sizeof(g_frFR_Locale)); - break; - case XFA_LANGID_it_IT: - pLocal = XFA_GetLocaleFromBuffer(g_itIT_Locale, sizeof(g_itIT_Locale)); - break; - case XFA_LANGID_pt_BR: - pLocal = XFA_GetLocaleFromBuffer(g_ptBR_Locale, sizeof(g_ptBR_Locale)); - break; - case XFA_LANGID_nl_NL: - pLocal = XFA_GetLocaleFromBuffer(g_nlNL_Locale, sizeof(g_nlNL_Locale)); - break; - case XFA_LANGID_ru_RU: - pLocal = XFA_GetLocaleFromBuffer(g_ruRU_Locale, sizeof(g_ruRU_Locale)); - break; - case XFA_LANGID_en_US: - default: - pLocal = XFA_GetLocaleFromBuffer(g_enUS_Locale, sizeof(g_enUS_Locale)); - break; - } - return pLocal; -} -IFX_Locale* CXFA_LocaleMgr::GetLocaleByName( - const CFX_WideStringC& 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]); - if (pLocale->GetName() == wsLocaleName) { - return pLocale; - } - } - int32_t iLen = wsLocaleName.GetLength(); - if (iLen < 2) { - return NULL; - } - iCount = m_XMLLocaleArray.GetSize(); - for (i = 0; i < iCount; i++) { - IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]); - if (pLocale->GetName() == wsLocaleName) { - return pLocale; - } - } - FX_WORD dwLangueID = XFA_GetLanguage(wsLocaleName); - IFX_Locale* pLocale = GetLocale(dwLangueID); - if (pLocale) - m_XMLLocaleArray.Add(pLocale); - return pLocale; -} -void CXFA_LocaleMgr::SetDefLocale(IFX_Locale* pLocale) { - m_pDefLocale = pLocale; -} -CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) { - if (!(m_dwLocaleFlags & 0x01)) { - m_wsConfigLocale.Empty(); - if (pConfig) { - CXFA_Node* pChildfConfig = - pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); - if (!pChildfConfig) { - pChildfConfig = pConfig->GetFirstChildByClass(XFA_ELEMENT_Present); - } - CXFA_Node* pCommon = - pChildfConfig - ? pChildfConfig->GetFirstChildByClass(XFA_ELEMENT_Common) - : NULL; - CXFA_Node* pLocale = - pCommon ? pCommon->GetFirstChildByClass(XFA_ELEMENT_Locale) : NULL; - if (pLocale) { - pLocale->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale, FALSE); - } - } - m_dwLocaleFlags |= 0x01; - } - return m_wsConfigLocale; -} -static CXFA_TimeZoneProvider* g_pProvider = NULL; -IXFA_TimeZoneProvider* IXFA_TimeZoneProvider::Create() { - FXSYS_assert(!g_pProvider); - g_pProvider = new CXFA_TimeZoneProvider(); - return g_pProvider; -} -IXFA_TimeZoneProvider* IXFA_TimeZoneProvider::Get() { - if (!g_pProvider) { - g_pProvider = new CXFA_TimeZoneProvider(); - } - return g_pProvider; -} -void IXFA_TimeZoneProvider::Destroy() { - delete g_pProvider; - g_pProvider = NULL; -} -#include <time.h> -CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - _tzset(); - m_tz.tzHour = (int8_t)(_timezone / 3600 * -1); - m_tz.tzMinute = (int8_t)((FXSYS_abs(_timezone) % 3600) / 60); -#else - tzset(); - m_tz.tzHour = (int8_t)(timezone / 3600 * -1); - m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); -#endif -} -CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} -void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { - m_tz = tz; -} -void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { - tz = m_tz; -} diff --git a/xfa/src/fxfa/parser/xfa_localemgr.h b/xfa/src/fxfa/parser/xfa_localemgr.h deleted file mode 100644 index 0af6f5f2d3..0000000000 --- a/xfa/src/fxfa/parser/xfa_localemgr.h +++ /dev/null @@ -1,78 +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_SRC_FXFA_PARSER_XFA_LOCALEMGR_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LOCALEMGR_H_ - -#include "xfa/include/fxfa/fxfa_objectacc.h" -#include "xfa/src/fgas/localization/fgas_datetime.h" -#include "xfa/src/fgas/localization/fgas_locale.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" - -class CXFA_Node; -class IFX_Locale; - -#define XFA_LANGID_zh_CN 0x0804 -#define XFA_LANGID_zh_TW 0x0404 -#define XFA_LANGID_zh_HK 0x0c04 -#define XFA_LANGID_ja_JP 0x0411 -#define XFA_LANGID_ko_KR 0x0412 -#define XFA_LANGID_en_US 0x0409 -#define XFA_LANGID_en_GB 0x0809 -#define XFA_LANGID_es_ES 0x0c0a -#define XFA_LANGID_es_LA 0x080a -#define XFA_LANGID_de_DE 0x0407 -#define XFA_LANGID_fr_FR 0x040c -#define XFA_LANGID_it_IT 0x0410 -#define XFA_LANGID_pt_BR 0x0416 -#define XFA_LANGID_nl_NL 0x0413 -#define XFA_LANGID_ru_RU 0x0419 - -class CXFA_LocaleMgr : public IFX_LocaleMgr { - public: - CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid); - virtual void Release(); - virtual FX_WORD GetDefLocaleID(); - virtual IFX_Locale* GetDefLocale(); - virtual IFX_Locale* GetLocale(FX_WORD lcid); - virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName); - ~CXFA_LocaleMgr(); - void SetDefLocale(IFX_Locale* pLocale); - CFX_WideStringC GetConfigLocaleName(CXFA_Node* pConfig); - - protected: - CFX_PtrArray m_LocaleArray; - CFX_PtrArray m_XMLLocaleArray; - IFX_Locale* m_pDefLocale; - CFX_WideString m_wsConfigLocale; - FX_WORD m_dwDeflcid; - FX_WORD m_dwLocaleFlags; -}; - -class IXFA_TimeZoneProvider { - public: - static IXFA_TimeZoneProvider* Create(); - static IXFA_TimeZoneProvider* Get(); - static void Destroy(); - - virtual ~IXFA_TimeZoneProvider() {} - - virtual void SetTimeZone(FX_TIMEZONE& tz) = 0; - - virtual void GetTimeZone(FX_TIMEZONE& tz) = 0; -}; -class CXFA_TimeZoneProvider : public IXFA_TimeZoneProvider { - public: - CXFA_TimeZoneProvider(); - virtual ~CXFA_TimeZoneProvider(); - virtual void SetTimeZone(FX_TIMEZONE& tz); - virtual void GetTimeZone(FX_TIMEZONE& tz); - - private: - FX_TIMEZONE m_tz; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_LOCALEMGR_H_ diff --git a/xfa/src/fxfa/parser/xfa_localevalue.cpp b/xfa/src/fxfa/parser/xfa_localevalue.cpp deleted file mode 100644 index 5b9dc27681..0000000000 --- a/xfa/src/fxfa/parser/xfa_localevalue.cpp +++ /dev/null @@ -1,981 +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/src/fxfa/parser/xfa_localevalue.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -static const FX_DOUBLE fraction_scales[] = {0.1, - 0.01, - 0.001, - 0.0001, - 0.00001, - 0.000001, - 0.0000001, - 0.00000001, - 0.000000001, - 0.0000000001, - 0.00000000001, - 0.000000000001, - 0.0000000000001, - 0.00000000000001, - 0.000000000000001, - 0.0000000000000001}; -CXFA_LocaleValue::CXFA_LocaleValue() { - m_dwType = XFA_VT_NULL; - m_bValid = TRUE; - m_pLocaleMgr = NULL; -} -CXFA_LocaleValue::CXFA_LocaleValue(const CXFA_LocaleValue& value) { - m_dwType = XFA_VT_NULL; - m_bValid = TRUE; - m_pLocaleMgr = NULL; - *this = value; -} -CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, - CXFA_LocaleMgr* pLocaleMgr) { - m_dwType = dwType; - m_bValid = (m_dwType != XFA_VT_NULL); - m_pLocaleMgr = pLocaleMgr; -} -CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, - const CFX_WideString& wsValue, - CXFA_LocaleMgr* pLocaleMgr) { - m_wsValue = wsValue; - m_dwType = dwType; - m_pLocaleMgr = pLocaleMgr; - m_bValid = ValidateCanonicalValue(wsValue, dwType); -} -CXFA_LocaleValue::CXFA_LocaleValue(FX_DWORD dwType, - const CFX_WideString& wsValue, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - CXFA_LocaleMgr* pLocaleMgr) { - m_pLocaleMgr = pLocaleMgr; - m_bValid = TRUE; - m_dwType = dwType; - m_bValid = ParsePatternValue(wsValue, wsFormat, pLocale); -} -CXFA_LocaleValue& CXFA_LocaleValue::operator=(const CXFA_LocaleValue& value) { - m_wsValue = value.m_wsValue; - m_dwType = value.m_dwType; - m_bValid = value.m_bValid; - m_pLocaleMgr = value.m_pLocaleMgr; - return *this; -} -CXFA_LocaleValue::~CXFA_LocaleValue() {} -static FX_LOCALECATEGORY XFA_ValugeCategory(FX_LOCALECATEGORY eCategory, - FX_DWORD dwValueType) { - if (eCategory == FX_LOCALECATEGORY_Unknown) { - switch (dwValueType) { - case XFA_VT_BOOLEAN: - case XFA_VT_INTEGER: - case XFA_VT_DECIMAL: - case XFA_VT_FLOAT: - return FX_LOCALECATEGORY_Num; - case XFA_VT_TEXT: - return FX_LOCALECATEGORY_Text; - case XFA_VT_DATE: - return FX_LOCALECATEGORY_Date; - case XFA_VT_TIME: - return FX_LOCALECATEGORY_Time; - case XFA_VT_DATETIME: - return FX_LOCALECATEGORY_DateTime; - } - } - return eCategory; -} -FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, - const CFX_WideString& wsPattern, - IFX_Locale* pLocale, - CFX_WideString* pMatchFormat) { - CFX_WideString wsOutput; - IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); - if (pLocale) { - m_pLocaleMgr->SetDefLocale(pLocale); - } - IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); - CFX_WideStringArray wsPatterns; - pFormat->SplitFormatString(wsPattern, wsPatterns); - FX_BOOL bRet = FALSE; - int32_t iCount = wsPatterns.GetSize(); - int32_t i = 0; - for (; i < iCount && !bRet; i++) { - CFX_WideString wsFormat = wsPatterns[i]; - FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); - eCategory = XFA_ValugeCategory(eCategory, m_dwType); - switch (eCategory) { - case FX_LOCALECATEGORY_Null: - bRet = pFormat->ParseNull(wsValue, wsFormat); - if (!bRet) { - bRet = wsValue.IsEmpty(); - } - break; - case FX_LOCALECATEGORY_Zero: - bRet = pFormat->ParseZero(wsValue, wsFormat); - if (!bRet) { - bRet = wsValue == FX_WSTRC(L"0"); - } - break; - case FX_LOCALECATEGORY_Num: { - CFX_WideString fNum; - bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); - if (!bRet) { - bRet = pFormat->FormatNum(wsValue, wsFormat, wsOutput); - } - break; - } - case FX_LOCALECATEGORY_Text: - bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput); - wsOutput.Empty(); - if (!bRet) { - bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput); - } - break; - case FX_LOCALECATEGORY_Date: { - CFX_Unitime dt; - bRet = ValidateCanonicalDate(wsValue, dt); - if (!bRet) { - bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, - dt); - if (!bRet) { - bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, - FX_DATETIMETYPE_Date); - } - } - break; - } - case FX_LOCALECATEGORY_Time: { - CFX_Unitime dt; - bRet = - pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, dt); - if (!bRet) { - bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, - FX_DATETIMETYPE_Time); - } - break; - } - case FX_LOCALECATEGORY_DateTime: { - CFX_Unitime dt; - bRet = pFormat->ParseDateTime(wsValue, wsFormat, - FX_DATETIMETYPE_DateTime, dt); - if (!bRet) { - bRet = pFormat->FormatDateTime(wsValue, wsFormat, wsOutput, - FX_DATETIMETYPE_DateTime); - } - break; - } - default: - bRet = FALSE; - break; - } - } - if (bRet && pMatchFormat) { - *pMatchFormat = wsPatterns[i - 1]; - } - pFormat->Release(); - if (pLocale) { - m_pLocaleMgr->SetDefLocale(locale); - } - return bRet; -} -CFX_WideString CXFA_LocaleValue::GetValue() const { - return m_wsValue; -} -FX_DWORD CXFA_LocaleValue::GetType() const { - return m_dwType; -} -void CXFA_LocaleValue::SetValue(const CFX_WideString& wsValue, - FX_DWORD dwType) { - m_wsValue = wsValue; - m_dwType = dwType; -} -CFX_WideString CXFA_LocaleValue::GetText() const { - if (m_bValid && m_dwType == XFA_VT_TEXT) { - return m_wsValue; - } - return CFX_WideString(); -} -FX_FLOAT CXFA_LocaleValue::GetNum() const { - if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || - m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { - int64_t nIntegral = 0; - FX_DWORD dwFractional = 0; - int32_t nExponent = 0; - int cc = 0; - FX_BOOL bNegative = FALSE, bExpSign = FALSE; - const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; - int len = m_wsValue.GetLength(); - while (XFA_IsSpace(str[cc]) && cc < len) { - cc++; - } - if (cc >= len) { - return 0; - } - if (str[0] == '+') { - cc++; - } else if (str[0] == '-') { - bNegative = TRUE; - cc++; - } - int nIntegralLen = 0; - while (cc < len) { - if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { - break; - } - nIntegral = nIntegral * 10 + str[cc] - '0'; - cc++; - nIntegralLen++; - } - nIntegral = bNegative ? -nIntegral : nIntegral; - int scale = 0; - double fraction = 0.0; - if (cc < len && str[cc] == '.') { - cc++; - while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); - scale++; - cc++; - if (scale == sizeof fraction_scales / sizeof(double) || - !XFA_IsDigit(str[cc])) { - break; - } - } - dwFractional = (FX_DWORD)(fraction * 4294967296.0); - } - if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = TRUE; - cc++; - } - } - while (cc < len) { - if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { - break; - } - nExponent = nExponent * 10 + str[cc] - '0'; - cc++; - } - nExponent = bExpSign ? -nExponent : nExponent; - } - FX_FLOAT fValue = (FX_FLOAT)(dwFractional / 4294967296.0); - fValue = nIntegral + (nIntegral >= 0 ? fValue : -fValue); - if (nExponent != 0) { - fValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); - } - return fValue; - } - return 0; -} -FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const { - if (m_bValid && (m_dwType == XFA_VT_BOOLEAN || m_dwType == XFA_VT_INTEGER || - m_dwType == XFA_VT_DECIMAL || m_dwType == XFA_VT_FLOAT)) { - int64_t nIntegral = 0; - FX_DWORD dwFractional = 0; - int32_t nExponent = 0; - int32_t cc = 0; - FX_BOOL bNegative = FALSE, bExpSign = FALSE; - const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue; - int len = m_wsValue.GetLength(); - while (XFA_IsSpace(str[cc]) && cc < len) { - cc++; - } - if (cc >= len) { - return 0; - } - if (str[0] == '+') { - cc++; - } else if (str[0] == '-') { - bNegative = TRUE; - cc++; - } - int32_t nIntegralLen = 0; - while (cc < len) { - if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) { - break; - } - nIntegral = nIntegral * 10 + str[cc] - '0'; - cc++; - nIntegralLen++; - } - nIntegral = bNegative ? -nIntegral : nIntegral; - int32_t scale = 0; - FX_DOUBLE fraction = 0.0; - if (cc < len && str[cc] == '.') { - cc++; - while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); - scale++; - cc++; - if (scale == sizeof fraction_scales / sizeof(FX_DOUBLE) || - !XFA_IsDigit(str[cc])) { - break; - } - } - dwFractional = (FX_DWORD)(fraction * 4294967296.0); - } - if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = TRUE; - cc++; - } - } - while (cc < len) { - if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { - break; - } - nExponent = nExponent * 10 + str[cc] - '0'; - cc++; - } - nExponent = bExpSign ? -nExponent : nExponent; - } - FX_DOUBLE dValue = (dwFractional / 4294967296.0); - dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); - if (nExponent != 0) { - dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); - } - return dValue; - } - return 0; -} -CFX_Unitime CXFA_LocaleValue::GetDate() const { - if (m_bValid && m_dwType == XFA_VT_DATE) { - CFX_Unitime dt; - FX_DateFromCanonical(m_wsValue, dt); - return dt; - } - return CFX_Unitime(); -} -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, dt, m_pLocaleMgr->GetDefLocale()); - return dt; - } - return CFX_Unitime(); -} -CFX_Unitime CXFA_LocaleValue::GetDateTime() const { - if (m_bValid && m_dwType == XFA_VT_DATETIME) { - int32_t index = m_wsValue.Find('T'); - CFX_Unitime dt; - FX_DateFromCanonical(m_wsValue.Left(index), dt); - FXSYS_assert(m_pLocaleMgr); - FX_TimeFromCanonical(m_wsValue.Right(m_wsValue.GetLength() - index - 1), dt, - m_pLocaleMgr->GetDefLocale()); - return dt; - } - return CFX_Unitime(); -} -FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText) { - m_dwType = XFA_VT_TEXT; - m_wsValue = wsText; - return TRUE; -} -FX_BOOL CXFA_LocaleValue::SetText(const CFX_WideString& wsText, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale) { - m_dwType = XFA_VT_TEXT; - return m_bValid = ParsePatternValue(wsText, wsFormat, pLocale); -} -FX_BOOL CXFA_LocaleValue::SetNum(FX_FLOAT fNum) { - m_dwType = XFA_VT_FLOAT; - m_wsValue.Format(L"%.8g", (FX_DOUBLE)fNum); - return TRUE; -} -FX_BOOL CXFA_LocaleValue::SetNum(const CFX_WideString& wsNum, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale) { - m_dwType = XFA_VT_FLOAT; - return m_bValid = ParsePatternValue(wsNum, wsFormat, pLocale); -} -FX_BOOL CXFA_LocaleValue::SetDate(const CFX_Unitime& d) { - m_dwType = XFA_VT_DATE; - m_wsValue.Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), d.GetDay()); - return TRUE; -} -FX_BOOL CXFA_LocaleValue::SetDate(const CFX_WideString& wsDate, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale) { - m_dwType = XFA_VT_DATE; - return m_bValid = ParsePatternValue(wsDate, wsFormat, pLocale); -} -FX_BOOL CXFA_LocaleValue::SetTime(const CFX_Unitime& t) { - m_dwType = XFA_VT_TIME; - m_wsValue.Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), - t.GetSecond()); - if (t.GetMillisecond() > 0) { - CFX_WideString wsTemp; - wsTemp.Format(L"%:03d", t.GetMillisecond()); - m_wsValue += wsTemp; - } - return TRUE; -} -FX_BOOL CXFA_LocaleValue::SetTime(const CFX_WideString& wsTime, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale) { - m_dwType = XFA_VT_TIME; - return m_bValid = ParsePatternValue(wsTime, wsFormat, pLocale); -} -FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_Unitime& dt) { - m_dwType = XFA_VT_DATETIME; - m_wsValue.Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), - dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), - dt.GetSecond()); - if (dt.GetMillisecond() > 0) { - CFX_WideString wsTemp; - wsTemp.Format(L"%:03d", dt.GetMillisecond()); - m_wsValue += wsTemp; - } - return TRUE; -} -FX_BOOL CXFA_LocaleValue::SetDateTime(const CFX_WideString& wsDateTime, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale) { - m_dwType = XFA_VT_DATETIME; - return m_bValid = ParsePatternValue(wsDateTime, wsFormat, pLocale); -} -FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - XFA_VALUEPICTURE eValueType) const { - wsResult.Empty(); - FX_BOOL bRet = FALSE; - IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); - CFX_WideStringArray wsPatterns; - pFormat->SplitFormatString(wsFormat, wsPatterns); - int32_t iCount = wsPatterns.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - bRet = FormatSinglePattern(wsResult, wsPatterns[i], pLocale, eValueType); - if (bRet) { - break; - } - } - pFormat->Release(); - return bRet; -} -FX_BOOL CXFA_LocaleValue::FormatSinglePattern( - CFX_WideString& wsResult, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - XFA_VALUEPICTURE eValueType) const { - IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); - if (pLocale) { - m_pLocaleMgr->SetDefLocale(pLocale); - } - wsResult.Empty(); - FX_BOOL bRet = FALSE; - IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); - FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); - eCategory = XFA_ValugeCategory(eCategory, m_dwType); - switch (eCategory) { - case FX_LOCALECATEGORY_Null: - if (m_wsValue.IsEmpty()) { - bRet = pFormat->FormatNull(wsFormat, wsResult); - } - break; - case FX_LOCALECATEGORY_Zero: - if (m_wsValue == FX_WSTRC(L"0")) { - bRet = pFormat->FormatZero(wsFormat, wsResult); - } - break; - case FX_LOCALECATEGORY_Num: - bRet = pFormat->FormatNum(m_wsValue, wsFormat, wsResult); - break; - case FX_LOCALECATEGORY_Text: - bRet = pFormat->FormatText(m_wsValue, wsFormat, wsResult); - break; - case FX_LOCALECATEGORY_Date: - bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, - FX_DATETIMETYPE_Date); - break; - case FX_LOCALECATEGORY_Time: - bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, - FX_DATETIMETYPE_Time); - break; - case FX_LOCALECATEGORY_DateTime: - bRet = pFormat->FormatDateTime(m_wsValue, wsFormat, wsResult, - FX_DATETIMETYPE_DateTime); - break; - default: - wsResult = m_wsValue; - bRet = TRUE; - } - pFormat->Release(); - if (!bRet && (eCategory != FX_LOCALECATEGORY_Num || - eValueType != XFA_VALUEPICTURE_Display)) { - wsResult = m_wsValue; - } - if (pLocale) { - m_pLocaleMgr->SetDefLocale(locale); - } - return bRet; -} -static FX_BOOL XFA_ValueSplitDateTime(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); - wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); - return TRUE; -} -FX_BOOL CXFA_LocaleValue::ValidateCanonicalValue(const CFX_WideString& wsValue, - FX_DWORD dwVType) { - if (wsValue.IsEmpty()) { - return TRUE; - } - CFX_Unitime dt; - switch (dwVType) { - case XFA_VT_DATE: { - if (ValidateCanonicalDate(wsValue, dt)) { - return TRUE; - } - CFX_WideString wsDate, wsTime; - if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && - ValidateCanonicalDate(wsDate, dt)) { - return TRUE; - } - return FALSE; - } - case XFA_VT_TIME: { - if (ValidateCanonicalTime(wsValue)) { - return TRUE; - } - CFX_WideString wsDate, wsTime; - if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && - ValidateCanonicalTime(wsTime)) { - return TRUE; - } - return FALSE; - } - case XFA_VT_DATETIME: { - CFX_WideString wsDate, wsTime; - if (XFA_ValueSplitDateTime(wsValue, wsDate, wsTime) && - ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime)) { - return TRUE; - } - } break; - } - return TRUE; -} -FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, - CFX_Unitime& unDate) { - const FX_WORD LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - const FX_WORD wCountY = 4, wCountM = 2, wCountD = 2; - int nLen = wsDate.GetLength(); - if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) { - return FALSE; - } - const bool bSymbol = wsDate.Find(0x2D) != -1; - FX_WORD wYear = 0; - FX_WORD wMonth = 0; - FX_WORD wDay = 0; - const FX_WCHAR* pDate = (const FX_WCHAR*)wsDate; - int nIndex = 0, nStart = 0; - while (pDate[nIndex] != '\0' && nIndex < wCountY) { - if (!XFA_IsDigit(pDate[nIndex])) { - return FALSE; - } - wYear = (pDate[nIndex] - '0') + wYear * 10; - nIndex++; - } - if (bSymbol) { - if (pDate[nIndex] != 0x2D) { - return FALSE; - } - nIndex++; - } - nStart = nIndex; - while (pDate[nIndex] != '\0' && nIndex - nStart < wCountM && nIndex < nLen) { - if (!XFA_IsDigit(pDate[nIndex])) { - return FALSE; - } - wMonth = (pDate[nIndex] - '0') + wMonth * 10; - nIndex++; - } - if (bSymbol) { - if (pDate[nIndex] != 0x2D) { - return FALSE; - } - nIndex++; - } - nStart = nIndex; - while (pDate[nIndex] != '\0' && nIndex - nStart < wCountD && nIndex < nLen) { - if (!XFA_IsDigit(pDate[nIndex])) { - return FALSE; - } - wDay = (pDate[nIndex] - '0') + wDay * 10; - nIndex++; - } - if (nIndex != nLen) { - return FALSE; - } - if (wYear < 1900 || wYear > 2029) { - return FALSE; - } - if (wMonth < 1 || wMonth > 12) { - if (wMonth == 0 && nLen == wCountY) { - return TRUE; - } - return FALSE; - } - if (wDay < 1) { - if (wDay == 0 && (nLen == wCountY + wCountM)) { - return TRUE; - } - return FALSE; - } - if (wMonth == 2) { - if (wYear % 400 == 0 || (wYear % 100 != 0 && wYear % 4 == 0)) { - if (wDay > 29) { - return FALSE; - } - } else { - if (wDay > 28) { - return FALSE; - } - } - } else if (wDay > LastDay[wMonth - 1]) { - return FALSE; - } - CFX_Unitime ut; - ut.Set(wYear, static_cast<uint8_t>(wMonth), static_cast<uint8_t>(wDay)); - unDate = unDate + ut; - return TRUE; -} -FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) { - int nLen = wsTime.GetLength(); - if (nLen < 2) - return FALSE; - const FX_WORD wCountH = 2; - const FX_WORD wCountM = 2; - const FX_WORD wCountS = 2; - const FX_WORD wCountF = 3; - const bool bSymbol = wsTime.Find(':') != -1; - FX_WORD wHour = 0; - FX_WORD wMinute = 0; - FX_WORD wSecond = 0; - FX_WORD wFraction = 0; - const FX_WCHAR* pTime = (const FX_WCHAR*)wsTime; - int nIndex = 0; - int nStart = 0; - while (nIndex - nStart < wCountH && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - wHour = pTime[nIndex] - '0' + wHour * 10; - nIndex++; - } - if (bSymbol) { - if (nIndex < nLen && pTime[nIndex] != ':') - return FALSE; - nIndex++; - } - nStart = nIndex; - while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - wMinute = pTime[nIndex] - '0' + wMinute * 10; - nIndex++; - } - if (bSymbol) { - if (nIndex < nLen && pTime[nIndex] != ':') - return FALSE; - nIndex++; - } - nStart = nIndex; - while (nIndex - nStart < wCountS && nIndex < nLen && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - wSecond = pTime[nIndex] - '0' + wSecond * 10; - nIndex++; - } - if (wsTime.Find('.') > 0) { - if (pTime[nIndex] != '.') - return FALSE; - nIndex++; - nStart = nIndex; - while (nIndex - nStart < wCountF && nIndex < nLen && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - wFraction = pTime[nIndex] - '0' + wFraction * 10; - nIndex++; - } - } - if (nIndex < nLen) { - if (pTime[nIndex] == 'Z') { - nIndex++; - } else if (pTime[nIndex] == '-' || pTime[nIndex] == '+') { - int16_t nOffsetH = 0; - int16_t nOffsetM = 0; - nIndex++; - nStart = nIndex; - while (nIndex - nStart < wCountH && nIndex < nLen && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - nOffsetH = pTime[nIndex] - '0' + nOffsetH * 10; - nIndex++; - } - if (bSymbol) { - if (nIndex < nLen && pTime[nIndex] != ':') - return FALSE; - nIndex++; - } - nStart = nIndex; - while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { - if (!XFA_IsDigit(pTime[nIndex])) - return FALSE; - nOffsetM = pTime[nIndex] - '0' + nOffsetM * 10; - nIndex++; - } - if (nOffsetH > 12 || nOffsetM >= 60) - return FALSE; - } - } - return nIndex == nLen && wHour < 24 && wMinute < 60 && wSecond < 60 && - wFraction <= 999; -} -FX_BOOL CXFA_LocaleValue::ValidateCanonicalDateTime( - const CFX_WideString& wsDateTime) { - CFX_WideString wsDate, wsTime; - 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); - wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); - CFX_Unitime dt; - return ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime); -} -FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, - const CFX_WideString& wsPattern, - IFX_Locale* pLocale) { - IFX_Locale* locale = m_pLocaleMgr->GetDefLocale(); - if (pLocale) { - m_pLocaleMgr->SetDefLocale(pLocale); - } - IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE); - CFX_WideStringArray wsPatterns; - pFormat->SplitFormatString(wsPattern, wsPatterns); - FX_BOOL bRet = FALSE; - int32_t iCount = wsPatterns.GetSize(); - for (int32_t i = 0; i < iCount && !bRet; i++) { - CFX_WideString wsFormat = wsPatterns[i]; - FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat); - eCategory = XFA_ValugeCategory(eCategory, m_dwType); - switch (eCategory) { - case FX_LOCALECATEGORY_Null: - bRet = pFormat->ParseNull(wsValue, wsFormat); - if (bRet) { - m_wsValue.Empty(); - } - break; - case FX_LOCALECATEGORY_Zero: - bRet = pFormat->ParseZero(wsValue, wsFormat); - if (bRet) { - m_wsValue = FX_WSTRC(L"0"); - } - break; - case FX_LOCALECATEGORY_Num: { - CFX_WideString fNum; - bRet = pFormat->ParseNum(wsValue, wsFormat, fNum); - if (bRet) { - m_wsValue = fNum; - } - break; - } - case FX_LOCALECATEGORY_Text: - bRet = pFormat->ParseText(wsValue, wsFormat, m_wsValue); - break; - case FX_LOCALECATEGORY_Date: { - CFX_Unitime dt; - bRet = ValidateCanonicalDate(wsValue, dt); - if (!bRet) { - bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, - dt); - } - if (bRet) { - SetDate(dt); - } - break; - } - case FX_LOCALECATEGORY_Time: { - CFX_Unitime dt; - bRet = - pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, dt); - if (bRet) { - SetTime(dt); - } - break; - } - case FX_LOCALECATEGORY_DateTime: { - CFX_Unitime dt; - bRet = pFormat->ParseDateTime(wsValue, wsFormat, - FX_DATETIMETYPE_DateTime, dt); - if (bRet) { - SetDateTime(dt); - } - break; - } - default: - m_wsValue = wsValue; - bRet = TRUE; - break; - } - } - if (!bRet) { - m_wsValue = wsValue; - } - pFormat->Release(); - if (pLocale) { - m_pLocaleMgr->SetDefLocale(locale); - } - return bRet; -} -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); - int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + (bSign ? 1 : 0) + - (nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1); - FX_WCHAR* lpBuf = wsFormat.GetBuffer(nTotalLen); - int32_t nPos = 0; - if (bSign) { - lpBuf[nPos++] = L's'; - } - if (nIntLen == -1) { - lpBuf[nPos++] = L'z'; - lpBuf[nPos++] = L'*'; - } else { - while (nIntLen) { - lpBuf[nPos++] = L'z'; - nIntLen--; - } - } - if (nDecLen != 0) { - lpBuf[nPos++] = L'.'; - } - if (nDecLen == -1) { - lpBuf[nPos++] = L'z'; - lpBuf[nPos++] = L'*'; - } else { - while (nDecLen) { - lpBuf[nPos++] = L'z'; - nDecLen--; - } - } - wsFormat.ReleaseBuffer(nTotalLen); -} -FX_BOOL CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric, - CFX_WideString& wsFormat, - IFX_Locale* pLocale, - int32_t* pos) { - if (wsFormat.IsEmpty() || wsNumeric.IsEmpty()) { - return TRUE; - } - const FX_WCHAR* pNum = wsNumeric.c_str(); - const FX_WCHAR* pFmt = wsFormat.c_str(); - int32_t n = 0, nf = 0; - FX_WCHAR c = pNum[n]; - FX_WCHAR cf = pFmt[nf]; - if (cf == L's') { - if (c == L'-' || c == L'+') { - ++n; - } - ++nf; - } - FX_BOOL bLimit = TRUE; - int32_t nCount = wsNumeric.GetLength(); - int32_t nCountFmt = wsFormat.GetLength(); - while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && - XFA_IsDigit(c = pNum[n])) { - if (bLimit == TRUE) { - if ((cf = pFmt[nf]) == L'*') { - bLimit = FALSE; - } else if (cf == L'z') { - nf++; - } else { - return FALSE; - } - } - n++; - } - if (n == nCount) { - return TRUE; - } - if (nf == nCountFmt) { - return FALSE; - } - while (nf < nCountFmt && (cf = pFmt[nf]) != L'.') { - FXSYS_assert(cf == L'z' || cf == L'*'); - ++nf; - } - CFX_WideString wsDecimalSymbol; - if (pLocale) { - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDecimalSymbol); - } else { - wsDecimalSymbol = CFX_WideString(L'.'); - } - if (pFmt[nf] != L'.') { - return FALSE; - } - if (wsDecimalSymbol != CFX_WideStringC(c) && c != L'.') { - return FALSE; - } - ++nf; - ++n; - bLimit = TRUE; - while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) && - XFA_IsDigit(c = pNum[n])) { - if (bLimit == TRUE) { - if ((cf = pFmt[nf]) == L'*') { - bLimit = FALSE; - } else if (cf == L'z') { - nf++; - } else { - return FALSE; - } - } - n++; - } - return n == nCount; -} diff --git a/xfa/src/fxfa/parser/xfa_localevalue.h b/xfa/src/fxfa/parser/xfa_localevalue.h deleted file mode 100644 index bcdf037fcd..0000000000 --- a/xfa/src/fxfa/parser/xfa_localevalue.h +++ /dev/null @@ -1,112 +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_SRC_FXFA_PARSER_XFA_LOCALEVALUE_H_ -#define XFA_SRC_FXFA_PARSER_XFA_LOCALEVALUE_H_ - -#include "xfa/include/fxfa/fxfa_objectacc.h" - -class IFX_Locale; -class CFX_Unitime; -class CXFA_LocaleMgr; - -#define XFA_VT_NULL 0 -#define XFA_VT_BOOLEAN 1 -#define XFA_VT_INTEGER 2 -#define XFA_VT_DECIMAL 4 -#define XFA_VT_FLOAT 8 -#define XFA_VT_TEXT 16 -#define XFA_VT_DATE 32 -#define XFA_VT_TIME 64 -#define XFA_VT_DATETIME 128 - -class CXFA_LocaleValue { - public: - CXFA_LocaleValue(); - CXFA_LocaleValue(const CXFA_LocaleValue& value); - CXFA_LocaleValue(FX_DWORD dwType, CXFA_LocaleMgr* pLocaleMgr); - CXFA_LocaleValue(FX_DWORD dwType, - const CFX_WideString& wsValue, - CXFA_LocaleMgr* pLocaleMgr); - CXFA_LocaleValue(FX_DWORD dwType, - const CFX_WideString& wsValue, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - CXFA_LocaleMgr* pLocaleMgr); - ~CXFA_LocaleValue(); - CXFA_LocaleValue& operator=(const CXFA_LocaleValue& value); - - FX_BOOL ValidateValue(const CFX_WideString& wsValue, - const CFX_WideString& wsPattern, - IFX_Locale* pLocale, - CFX_WideString* pMatchFormat = NULL); - FX_BOOL FormatPatterns(CFX_WideString& wsResult, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - XFA_VALUEPICTURE eValueType) const; - FX_BOOL FormatSinglePattern(CFX_WideString& wsResult, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale, - XFA_VALUEPICTURE eValueType) const; - FX_BOOL ValidateCanonicalValue(const CFX_WideString& wsValue, - FX_DWORD dwVType); - FX_BOOL ValidateCanonicalDate(const CFX_WideString& wsDate, - CFX_Unitime& unDate); - FX_BOOL ValidateCanonicalTime(const CFX_WideString& wsTime); - FX_BOOL ValidateCanonicalDateTime(const CFX_WideString& wsDateTime); - void GetNumbericFormat(CFX_WideString& wsFormat, - int32_t nIntLen, - int32_t nDecLen, - FX_BOOL bSign = TRUE); - FX_BOOL ValidateNumericTemp(CFX_WideString& wsNumeric, - CFX_WideString& wsFormat, - IFX_Locale* pLocale = NULL, - int32_t* pos = NULL); - - CFX_WideString GetValue() const; - FX_DWORD GetType() const; - void SetValue(const CFX_WideString& wsValue, FX_DWORD dwType); - CFX_WideString GetText() const; - FX_FLOAT GetNum() const; - FX_DOUBLE GetDoubleNum() const; - CFX_Unitime GetDate() const; - CFX_Unitime GetTime() const; - CFX_Unitime GetDateTime() const; - FX_BOOL SetText(const CFX_WideString& wsText); - FX_BOOL SetText(const CFX_WideString& wsText, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale); - FX_BOOL SetNum(FX_FLOAT fNum); - FX_BOOL SetNum(const CFX_WideString& wsNum, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale); - FX_BOOL SetDate(const CFX_Unitime& d); - FX_BOOL SetDate(const CFX_WideString& wsDate, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale); - FX_BOOL SetTime(const CFX_Unitime& t); - FX_BOOL SetTime(const CFX_WideString& wsTime, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale); - FX_BOOL SetDateTime(const CFX_Unitime& dt); - FX_BOOL SetDateTime(const CFX_WideString& wsDateTime, - const CFX_WideString& wsFormat, - IFX_Locale* pLocale); - bool IsNull() const { return m_dwType == XFA_VT_NULL; } - FX_BOOL IsEmpty() const { return m_wsValue.IsEmpty(); } - FX_BOOL IsValid() const { return m_bValid; } - - protected: - FX_BOOL ParsePatternValue(const CFX_WideString& wsValue, - const CFX_WideString& wsPattern, - IFX_Locale* pLocale); - CXFA_LocaleMgr* m_pLocaleMgr; - CFX_WideString m_wsValue; - FX_DWORD m_dwType; - FX_BOOL m_bValid; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_LOCALEVALUE_H_ diff --git a/xfa/src/fxfa/parser/xfa_object.h b/xfa/src/fxfa/parser/xfa_object.h deleted file mode 100644 index 949ca8739f..0000000000 --- a/xfa/src/fxfa/parser/xfa_object.h +++ /dev/null @@ -1,803 +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_SRC_FXFA_PARSER_XFA_OBJECT_H_ -#define XFA_SRC_FXFA_PARSER_XFA_OBJECT_H_ - -#include "xfa/src/fde/xml/fde_xml.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -class CXFA_Document; -class CXFA_Node; -class CXFA_NodeList; -class CXFA_OrdinaryObject; - -enum XFA_OBJECTTYPE { - XFA_OBJECTTYPE_OrdinaryObject = 0x0, - XFA_OBJECTTYPE_OrdinaryList = 0x1, - XFA_OBJECTTYPE_NodeList = 0x2, - XFA_OBJECTTYPE_Node = 0x4, - XFA_OBJECTTYPE_NodeC = 0x5, - XFA_OBJECTTYPE_NodeV = 0x6, - XFA_OBJECTTYPE_ModelNode = 0x8, - XFA_OBJECTTYPE_TextNode = 0x9, - XFA_OBJECTTYPE_ContainerNode = 0xA, - XFA_OBJECTTYPE_ContentNode = 0xB, - XFA_OBJECTTYPE_VariablesThis = 0xC, - XFA_OBJECTTYPEMASK = 0xF, - XFA_NODEFLAG_Initialized = 0x00020, - XFA_NODEFLAG_HasRemoved = 0x00200, - XFA_NODEFLAG_NeedsInitApp = 0x00400, - XFA_NODEFLAG_BindFormItems = 0x00800, - XFA_NODEFLAG_UserInteractive = 0x01000, - XFA_NODEFLAG_SkipDataBinding = 0x02000, - XFA_NODEFLAG_OwnXMLNode = 0x04000, - XFA_NODEFLAG_UnusedNode = 0x08000, - XFA_NODEFLAG_LayoutGeneratedNode = 0x10000, -}; -class CXFA_Object { - public: - CXFA_Object(CXFA_Document* pDocument, FX_DWORD uFlags); - CXFA_Document* GetDocument() const { return m_pDocument; } - FX_DWORD GetFlag() const { return m_uFlags; } - XFA_OBJECTTYPE GetObjectType() const { - return (XFA_OBJECTTYPE)(m_uFlags & XFA_OBJECTTYPEMASK); - } - - FX_BOOL IsNode() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) >= XFA_OBJECTTYPE_Node; - } - FX_BOOL IsOrdinaryObject() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryObject; - } - FX_BOOL IsNodeList() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_NodeList; - } - FX_BOOL IsOrdinaryList() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryList; - } - FX_BOOL IsContentNode() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContentNode; - } - FX_BOOL IsContainerNode() const { - return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContainerNode; - } - - CXFA_Node* AsNode(); - CXFA_OrdinaryObject* AsOrdinaryObject(); - CXFA_NodeList* AsNodeList(); - - const CXFA_Node* AsNode() const; - const CXFA_OrdinaryObject* AsOrdinaryObject() const; - const CXFA_NodeList* AsNodeList() const; - - XFA_ELEMENT GetClassID() const; - void GetClassName(CFX_WideStringC& wsName) const; - uint32_t GetClassHashCode() const; - void Script_ObjectClass_ClassName(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void ThrowScriptErrorMessage(int32_t iStringID, ...); - - protected: - CXFA_Document* const m_pDocument; - FX_DWORD m_uFlags; -}; - -#define XFA_NODEFILTER_Children 0x01 -#define XFA_NODEFILTER_Properties 0x02 -#define XFA_NODEFILTER_OneOfProperty 0x04 -#define XFA_CLONEFLAG_Content 0x01 -enum XFA_NODEITEM { - XFA_NODEITEM_Parent, - XFA_NODEITEM_FirstChild, - XFA_NODEITEM_NextSibling, - XFA_NODEITEM_PrevSibling, -}; -enum XFA_SOM_MESSAGETYPE { - XFA_SOM_ValidationMessage, - XFA_SOM_FormatMessage, - XFA_SOM_MandatoryMessage -}; - -typedef CFX_ArrayTemplate<CXFA_Node*> CXFA_NodeArray; -typedef CFX_StackTemplate<CXFA_Node*> CXFA_NodeStack; -typedef CXFA_PtrSetTemplate<CXFA_Node*> CXFA_NodeSet; -typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData); - -struct XFA_MAPDATABLOCKCALLBACKINFO { - PD_CALLBACK_FREEDATA pFree; - PD_CALLBACK_DUPLICATEDATA pCopy; -}; - -struct XFA_MAPDATABLOCK { - uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); } - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo; - int32_t iBytes; -}; - -struct XFA_MAPMODULEDATA { - CFX_MapPtrToPtr m_ValueMap; - CFX_MapPtrTemplate<void*, XFA_MAPDATABLOCK*> m_BufferMap; -}; - -#define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R') -#define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C') -#define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M') -class CXFA_Node : public CXFA_Object { - public: - XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; } - FX_DWORD GetPacketID() const { return m_ePacket; } - FX_BOOL HasFlag(FX_DWORD dwFlag) const; - void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE, FX_BOOL bNotify = TRUE); - FX_BOOL IsAttributeInXML(); - FX_BOOL IsFormContainer() { - return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); - } - void SetXMLMappingNode(IFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } - IFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } - IFDE_XMLNode* CreateXMLMappingNode(); - FX_BOOL IsNeedSavingXMLNode(); - FX_DWORD GetNameHash() const { return m_dwNameHash; } - bool IsUnnamed() const { return m_dwNameHash == 0; } - CXFA_Node* GetModelNode(); - void UpdateNameHash(); - FX_BOOL HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit = FALSE); - FX_BOOL SetAttribute(XFA_ATTRIBUTE eAttr, - const CFX_WideStringC& wsValue, - FX_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); - 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, - FX_BOOL bScriptModify = FALSE, - FX_BOOL bSyncData = TRUE); - FX_BOOL TryContent(CFX_WideString& wsContent, - FX_BOOL bScriptModify = FALSE, - FX_BOOL bProto = TRUE); - CFX_WideString GetContent(); - - FX_BOOL TryNamespace(CFX_WideString& wsNamespace); - - FX_BOOL SetBoolean(XFA_ATTRIBUTE eAttr, - FX_BOOL bValue, - FX_BOOL bNotify = FALSE) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue, - bNotify); - } - FX_BOOL TryBoolean(XFA_ATTRIBUTE eAttr, - FX_BOOL& bValue, - FX_BOOL bUseDefault = TRUE); - FX_BOOL GetBoolean(XFA_ATTRIBUTE eAttr) { - FX_BOOL bValue; - return TryBoolean(eAttr, bValue, TRUE) ? bValue : FALSE; - } - FX_BOOL SetInteger(XFA_ATTRIBUTE eAttr, - int32_t iValue, - FX_BOOL bNotify = FALSE) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue, - bNotify); - } - FX_BOOL TryInteger(XFA_ATTRIBUTE eAttr, - int32_t& iValue, - FX_BOOL bUseDefault = TRUE); - int32_t GetInteger(XFA_ATTRIBUTE eAttr) { - int32_t iValue; - return TryInteger(eAttr, iValue, TRUE) ? iValue : 0; - } - FX_BOOL SetEnum(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTEENUM eValue, - FX_BOOL bNotify = FALSE) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue, - bNotify); - } - FX_BOOL TryEnum(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTEENUM& eValue, - FX_BOOL bUseDefault = TRUE); - XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) { - XFA_ATTRIBUTEENUM eValue; - return TryEnum(eAttr, eValue, TRUE) ? eValue : XFA_ATTRIBUTEENUM_Unknown; - } - FX_BOOL SetCData(XFA_ATTRIBUTE eAttr, - const CFX_WideString& wsValue, - FX_BOOL bNotify = FALSE, - FX_BOOL bScriptModify = FALSE); - FX_BOOL SetAttributeValue(const CFX_WideString& wsValue, - const CFX_WideString& wsXMLValue, - FX_BOOL bNotify = FALSE, - FX_BOOL bScriptModify = FALSE); - FX_BOOL TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideString& wsValue, - FX_BOOL bUseDefault = TRUE, - FX_BOOL bProto = TRUE); - FX_BOOL TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideStringC& wsValue, - FX_BOOL bUseDefault = TRUE, - FX_BOOL bProto = TRUE); - CFX_WideStringC GetCData(XFA_ATTRIBUTE eAttr) { - CFX_WideStringC wsValue; - return TryCData(eAttr, wsValue) ? wsValue : CFX_WideStringC(); - } - FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement mValue, - FX_BOOL bNotify = FALSE); - FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement& mValue, - FX_BOOL bUseDefault = TRUE) const; - CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const; - FX_BOOL SetObject(XFA_ATTRIBUTE eAttr, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); - FX_BOOL TryObject(XFA_ATTRIBUTE eAttr, void*& pData); - void* GetObject(XFA_ATTRIBUTE eAttr) { - void* pData; - return TryObject(eAttr, pData) ? pData : NULL; - } - FX_BOOL SetUserData(void* pKey, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); - FX_BOOL TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso = FALSE); - void* GetUserData(void* pKey, FX_BOOL bProtoAlso = FALSE) { - void* pData; - return TryUserData(pKey, pData, bProtoAlso) ? pData : NULL; - } - CXFA_Node* GetProperty(int32_t index, - XFA_ELEMENT eProperty, - FX_BOOL bCreateProperty = TRUE); - int32_t CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild = FALSE); - CXFA_Node* GetChild(int32_t index, - XFA_ELEMENT eElement, - 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); - CXFA_Node* Clone(FX_BOOL bRecursive); - CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const; - CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_OBJECTTYPE eType) const; - int32_t GetNodeList(CXFA_NodeArray& nodes, - FX_DWORD dwTypeFilter = XFA_NODEFILTER_Children | - XFA_NODEFILTER_Properties, - XFA_ELEMENT eElementFilter = XFA_ELEMENT_UNKNOWN, - int32_t iLevel = 1); - CXFA_Node* CreateSamePacketNode(XFA_ELEMENT eElement, - FX_DWORD dwFlags = XFA_NODEFLAG_Initialized); - CXFA_Node* CloneTemplateToForm(FX_BOOL bRecursive); - CXFA_Node* GetTemplateNode() const; - void SetTemplateNode(CXFA_Node* pTemplateNode); - CXFA_Node* GetDataDescriptionNode(); - void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode); - CXFA_Node* GetBindData(); - int32_t GetBindItems(CXFA_NodeArray& formItems); - int32_t AddBindItem(CXFA_Node* pFormNode); - int32_t RemoveBindItem(CXFA_Node* pFormNode); - FX_BOOL HasBindItem(); - CXFA_WidgetData* GetWidgetData(); - CXFA_WidgetData* GetContainerWidgetData(); - FX_BOOL GetLocaleName(CFX_WideString& wsLocaleName); - XFA_ATTRIBUTEENUM GetIntact(); - CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const; - CXFA_Node* GetFirstChildByName(FX_DWORD dwNodeNameHash) const; - CXFA_Node* GetFirstChildByClass(XFA_ELEMENT eNodeClass) const; - CXFA_Node* GetNextSameNameSibling(FX_DWORD dwNodeNameHash) const; - CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const; - CXFA_Node* GetNextSameClassSibling(XFA_ELEMENT eNodeClass) const; - int32_t GetNodeSameNameIndex() const; - int32_t GetNodeSameClassIndex() const; - void GetSOMExpression(CFX_WideString& wsSOMExpression); - CXFA_Node* GetInstanceMgrOfSubform(); - - CXFA_Node* GetOccurNode(); - void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments); - void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments); - void Script_Som_ResolveNodeList(FXJSE_HVALUE hValue, - CFX_WideString wsExpression, - FX_DWORD dwFlag, - CXFA_Node* refNode = NULL); - void Script_TreeClass_All(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Nodes(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_ClassAll(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Parent(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Index(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_ClassIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_SomExpression(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments); - void Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments); - void Script_NodeClass_Clone(CFXJSE_Arguments* pArguments); - void Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments); - void Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments); - void Script_NodeClass_IsPropertySpecified(CFXJSE_Arguments* pArguments); - void Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments); - void Script_NodeClass_Ns(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_Model(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_IsContainer(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_IsNull(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_OneOfChild(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments); - void Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments); - void Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments); - void Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments); - void Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments); - void Script_ModelClass_Context(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments); - void Script_Delta_Restore(CFXJSE_Arguments* pArguments); - void Script_Delta_CurrentValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Delta_SavedValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Delta_Target(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_SendAttributeChangeMessage(void* eAttribute, - void* eValue, - FX_BOOL bScriptModify); - void Script_Attribute_Integer(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_IntegerRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_BOOL(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_String(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_StringRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_ValidationMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_Length(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Boolean_Value(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_Message(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_SOM_MESSAGETYPE iMessageType); - void Script_Som_BorderColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_BorderWidth(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_FillColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DataNode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_FontColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_Mandatory(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_MandatoryMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_InstanceIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Draw_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_EditValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_FormatMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_FormattedValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_ParentSubform(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_SelectedIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_ClearItems(CFXJSE_Arguments* pArguments); - void Script_Field_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Field_DeleteItem(CFXJSE_Arguments* pArguments); - void Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments); - void Script_Field_BoundItem(CFXJSE_Arguments* pArguments); - void Script_Field_GetItemState(CFXJSE_Arguments* pArguments); - void Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Field_SetItems(CFXJSE_Arguments* pArguments); - void Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments); - void Script_Field_SetItemState(CFXJSE_Arguments* pArguments); - void Script_Field_AddItem(CFXJSE_Arguments* pArguments); - void Script_Field_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_ErrorText(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_Transient(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Subform_InstanceManager(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Subform_Locale(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments); - - int32_t Subform_and_SubformSet_InstanceIndex(); - void Script_Template_FormNodes(CFXJSE_Arguments* pArguments); - void Script_Template_Remerge(CFXJSE_Arguments* pArguments); - void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Template_CreateNode(CFXJSE_Arguments* pArguments); - void Script_Template_Recalculate(CFXJSE_Arguments* pArguments); - void Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Template_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_Count(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_Max(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_Min(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_MoveInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_RemoveInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments); - int32_t InstanceManager_SetInstances(int32_t iCount); - int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); - void Script_Occur_Max(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Occur_Min(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Desc_Metadata(CFXJSE_Arguments* pArguments); - void Script_Form_FormNodes(CFXJSE_Arguments* pArguments); - void Script_Form_Remerge(CFXJSE_Arguments* pArguments); - void Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Form_Recalculate(CFXJSE_Arguments* pArguments); - void Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Form_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Form_Checksum(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_Content(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Source_Next(CFXJSE_Arguments* pArguments); - void Script_Source_CancelBatch(CFXJSE_Arguments* pArguments); - void Script_Source_First(CFXJSE_Arguments* pArguments); - void Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments); - void Script_Source_Previous(CFXJSE_Arguments* pArguments); - void Script_Source_IsBOF(CFXJSE_Arguments* pArguments); - void Script_Source_IsEOF(CFXJSE_Arguments* pArguments); - void Script_Source_Cancel(CFXJSE_Arguments* pArguments); - void Script_Source_Update(CFXJSE_Arguments* pArguments); - void Script_Source_Open(CFXJSE_Arguments* pArguments); - void Script_Source_Delete(CFXJSE_Arguments* pArguments); - void Script_Source_AddNew(CFXJSE_Arguments* pArguments); - void Script_Source_Requery(CFXJSE_Arguments* pArguments); - void Script_Source_Resync(CFXJSE_Arguments* pArguments); - void Script_Source_Close(CFXJSE_Arguments* pArguments); - void Script_Source_Last(CFXJSE_Arguments* pArguments); - void Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments); - void Script_Source_Db(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Xfa_This(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Handler_Version(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_SubmitFormat_Mode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Extras_Type(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Encrypt_Format(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Script_Stateless(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - - protected: - CXFA_Node(CXFA_Document* pDoc, FX_WORD ePacket, XFA_ELEMENT eElement); - ~CXFA_Node(); - friend class CXFA_Document; - CXFA_Node* Deprecated_GetPrevSibling(); - FX_BOOL SetValue(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTETYPE eType, - void* pValue, - FX_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); - 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, - FX_BOOL bScriptModify = FALSE, - FX_BOOL bSyncData = TRUE); - CFX_WideString GetScriptContent(FX_BOOL bScriptModify = FALSE); - XFA_MAPMODULEDATA* CreateMapModuleData(); - XFA_MAPMODULEDATA* GetMapModuleData() const; - void SetMapModuleValue(void* pKey, void* pValue); - FX_BOOL GetMapModuleValue(void* pKey, void*& pValue); - void SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue); - FX_BOOL GetMapModuleString(void* pKey, CFX_WideStringC& wsValue); - void SetMapModuleBuffer(void* pKey, - void* pValue, - int32_t iBytes, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = NULL); - FX_BOOL GetMapModuleBuffer(void* pKey, - void*& pValue, - int32_t& iBytes, - FX_BOOL bProtoAlso = TRUE) const; - FX_BOOL HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso = FALSE); - void RemoveMapModuleKey(void* pKey = NULL); - void MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr = TRUE); - void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); - void MoveBufferMapData(CXFA_Node* pSrcModule, - CXFA_Node* pDstModule, - void* pKey, - FX_BOOL bRecursive = FALSE); - - CXFA_Node* m_pNext; - CXFA_Node* m_pChild; - CXFA_Node* m_pLastChild; - CXFA_Node* m_pParent; - IFDE_XMLNode* m_pXMLNode; - XFA_ELEMENT m_eNodeClass; - FX_WORD m_ePacket; - FX_DWORD m_dwNameHash; - CXFA_Node* m_pAuxNode; - XFA_MAPMODULEDATA* m_pMapModuleData; -}; -class CXFA_OrdinaryObject : public CXFA_Object { - public: - CXFA_OrdinaryObject(CXFA_Document* pDocument, XFA_ELEMENT eElement) - : CXFA_Object(pDocument, XFA_OBJECTTYPE_OrdinaryObject), - m_uScriptHash(0) { - m_eNodeClass = eElement; - } - XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; } - uint32_t GetScriptObjHash() { return m_uScriptHash; } - - protected: - XFA_ELEMENT m_eNodeClass; - uint32_t m_uScriptHash; -}; -class CXFA_ThisProxy : public CXFA_Object { - public: - CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) - : CXFA_Object(pThisNode->GetDocument(), XFA_OBJECTTYPE_VariablesThis), - m_pThisNode(NULL), - m_pScriptNode(NULL) { - m_pThisNode = pThisNode; - m_pScriptNode = pScriptNode; - } - virtual ~CXFA_ThisProxy() {} - CXFA_Node* GetThisNode() { return m_pThisNode; } - CXFA_Node* GetScriptNode() { return m_pScriptNode; } - - private: - CXFA_Node* m_pThisNode; - CXFA_Node* m_pScriptNode; -}; -class CXFA_NodeList : public CXFA_Object { - public: - explicit CXFA_NodeList(CXFA_Document* pDocument); - virtual ~CXFA_NodeList() {} - XFA_ELEMENT GetClassID() const { return XFA_ELEMENT_NodeList; } - CXFA_Node* NamedItem(const CFX_WideStringC& wsName); - virtual int32_t GetLength() = 0; - virtual FX_BOOL Append(CXFA_Node* pNode) = 0; - virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; - virtual FX_BOOL Remove(CXFA_Node* pNode) = 0; - virtual CXFA_Node* Item(int32_t iIndex) = 0; - - void Script_ListClass_Append(CFXJSE_Arguments* pArguments); - void Script_ListClass_Insert(CFXJSE_Arguments* pArguments); - void Script_ListClass_Remove(CFXJSE_Arguments* pArguments); - void Script_ListClass_Item(CFXJSE_Arguments* pArguments); - - void Script_TreelistClass_NamedItem(CFXJSE_Arguments* pArguments); - void Script_ListClass_Length(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); -}; -class CXFA_ArrayNodeList : public CXFA_NodeList { - public: - explicit CXFA_ArrayNodeList(CXFA_Document* pDocument); - void SetArrayNodeList(const CXFA_NodeArray& srcArray); - virtual int32_t GetLength(); - virtual FX_BOOL Append(CXFA_Node* pNode); - virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode); - virtual FX_BOOL Remove(CXFA_Node* pNode); - virtual CXFA_Node* Item(int32_t iIndex); - - protected: - CXFA_NodeArray m_array; -}; -class CXFA_AttachNodeList : public CXFA_NodeList { - public: - CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode); - - virtual int32_t GetLength(); - virtual FX_BOOL Append(CXFA_Node* pNode); - virtual FX_BOOL Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode); - virtual FX_BOOL Remove(CXFA_Node* pNode); - virtual CXFA_Node* Item(int32_t iIndex); - - protected: - CXFA_Node* m_pAttachNode; -}; -class CXFA_TraverseStrategy_XFAContainerNode { - public: - static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode, - void* pUserData = NULL) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild, - XFA_OBJECTTYPE_ContainerNode); - } - static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode, - void* pUserData = NULL) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_OBJECTTYPE_ContainerNode); - } - static CXFA_Node* GetParent(CXFA_Node* pTemplateNode, - void* pUserData = NULL) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_OBJECTTYPE_ContainerNode); - } -}; -typedef CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode> - CXFA_ContainerIterator; -class CXFA_TraverseStrategy_XFANode { - public: - static inline CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - } - static inline CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); - } -}; -typedef CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> - CXFA_NodeIterator; - -inline CXFA_Node* CXFA_Object::AsNode() { - return IsNode() ? static_cast<CXFA_Node*>(this) : nullptr; -} -inline CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() { - return IsOrdinaryObject() ? static_cast<CXFA_OrdinaryObject*>(this) : nullptr; -} -inline CXFA_NodeList* CXFA_Object::AsNodeList() { - return IsNodeList() ? static_cast<CXFA_NodeList*>(this) : nullptr; -} - -inline const CXFA_Node* CXFA_Object::AsNode() const { - return IsNode() ? static_cast<const CXFA_Node*>(this) : nullptr; -} -inline const CXFA_OrdinaryObject* CXFA_Object::AsOrdinaryObject() const { - return IsOrdinaryObject() ? static_cast<const CXFA_OrdinaryObject*>(this) - : nullptr; -} -inline const CXFA_NodeList* CXFA_Object::AsNodeList() const { - return IsNodeList() ? static_cast<const CXFA_NodeList*>(this) : nullptr; -} - -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_SRC_FXFA_PARSER_XFA_OBJECT_H_ diff --git a/xfa/src/fxfa/parser/xfa_object_imp.cpp b/xfa/src/fxfa/parser/xfa_object_imp.cpp deleted file mode 100644 index 23b0644074..0000000000 --- a/xfa/src/fxfa/parser/xfa_object_imp.cpp +++ /dev/null @@ -1,5408 +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/src/fxfa/parser/xfa_object.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fgas/crt/fgas_system.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_Object::CXFA_Object(CXFA_Document* pDocument, FX_DWORD uFlags) - : m_pDocument(pDocument), m_uFlags(uFlags) {} -void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { - wsName = XFA_GetElementByID(GetClassID())->pName; -} -uint32_t CXFA_Object::GetClassHashCode() const { - return XFA_GetElementByID(GetClassID())->uHash; -} -XFA_ELEMENT CXFA_Object::GetClassID() const { - if (IsNode()) { - return AsNode()->GetClassID(); - } - if (IsOrdinaryObject()) { - return AsOrdinaryObject()->GetClassID(); - } - if (IsNodeList()) { - return AsNodeList()->GetClassID(); - } - if (IsOrdinaryList()) { - return XFA_ELEMENT_List; - } - ASSERT(FALSE); - return (XFA_ELEMENT)0; -} -void CXFA_Object::Script_ObjectClass_ClassName(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - CFX_WideStringC className; - GetClassName(className); - FXJSE_Value_SetUTF8String( - hValue, FX_UTF8Encode(className.GetPtr(), className.GetLength())); - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Object::ThrowScriptErrorMessage(int32_t iStringID, ...) { - IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); - FXSYS_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); - va_end(arg_ptr); - FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); -} - -static void XFA_DeleteWideString(void* pData) { - delete static_cast<CFX_WideString*>(pData); -} - -static void XFA_CopyWideString(void*& pData) { - if (pData) { - CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); - pData = pNewData; - } -} -static XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = { - XFA_DeleteWideString, XFA_CopyWideString}; -static XFA_OBJECTTYPE XFA_GetElementObjectType(XFA_ELEMENT eElement) { - return (XFA_OBJECTTYPE)XFA_GetElementByID(eElement)->eObjectType; -} -CXFA_Node::CXFA_Node(CXFA_Document* pDoc, FX_WORD ePacket, XFA_ELEMENT eElement) - : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), - m_pNext(nullptr), - m_pChild(nullptr), - m_pLastChild(nullptr), - m_pParent(nullptr), - m_pXMLNode(nullptr), - m_eNodeClass(eElement), - m_ePacket(ePacket), - m_dwNameHash(0), - m_pAuxNode(nullptr), - m_pMapModuleData(nullptr) { - ASSERT(m_pDocument); -} -CXFA_Node::~CXFA_Node() { - FXSYS_assert(m_pParent == NULL); - RemoveMapModuleKey(); - CXFA_Node *pNext, *pNode = m_pChild; - while (pNode) { - pNext = pNode->m_pNext; - pNode->m_pParent = NULL; - delete pNode; - pNode = pNext; - } - if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) { - m_pXMLNode->Release(); - } -} -CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { - IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); - CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); - if (!pClone) { - return NULL; - } - MergeAllData(pClone); - pClone->UpdateNameHash(); - if (IsNeedSavingXMLNode()) { - IFDE_XMLNode* pCloneXML = NULL; - if (IsAttributeInXML()) { - CFX_WideString wsName; - GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - IFDE_XMLElement* pCloneXMLElement = IFDE_XMLElement::Create(wsName); - CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); - if (!wsValue.IsEmpty()) { - pCloneXMLElement->SetTextData(wsValue); - } - pCloneXML = pCloneXMLElement; - pCloneXMLElement = NULL; - pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown); - } else { - pCloneXML = m_pXMLNode->Clone(FALSE); - } - pClone->SetXMLMappingNode(pCloneXML); - pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); - } - if (bRecursive) { - for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pClone->InsertChild(pChild->Clone(bRecursive)); - } - } - pClone->SetFlag(XFA_NODEFLAG_Initialized); - pClone->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - return pClone; -} -CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem) const { - switch (eItem) { - case XFA_NODEITEM_NextSibling: - return m_pNext; - case XFA_NODEITEM_FirstChild: - return m_pChild; - case XFA_NODEITEM_Parent: - return m_pParent; - case XFA_NODEITEM_PrevSibling: - if (m_pParent) { - CXFA_Node* pSibling = m_pParent->m_pChild; - CXFA_Node* pPrev = NULL; - while (pSibling && pSibling != this) { - pPrev = pSibling; - pSibling = pSibling->m_pNext; - } - return pPrev; - } - return NULL; - default: - break; - } - return NULL; -} -CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem, - XFA_OBJECTTYPE eType) const { - CXFA_Node* pNode = NULL; - switch (eItem) { - case XFA_NODEITEM_NextSibling: - pNode = m_pNext; - if (eType != XFA_OBJECTTYPEMASK) { - while (pNode && pNode->GetObjectType() != eType) { - pNode = pNode->m_pNext; - } - } - break; - case XFA_NODEITEM_FirstChild: - pNode = m_pChild; - if (eType != XFA_OBJECTTYPEMASK) { - while (pNode && pNode->GetObjectType() != eType) { - pNode = pNode->m_pNext; - } - } - break; - case XFA_NODEITEM_Parent: - pNode = m_pParent; - if (eType != XFA_OBJECTTYPEMASK) { - while (pNode && pNode->GetObjectType() != eType) { - pNode = pNode->m_pParent; - } - } - break; - case XFA_NODEITEM_PrevSibling: - if (m_pParent) { - CXFA_Node* pSibling = m_pParent->m_pChild; - while (pSibling && pSibling != this) { - if (eType == XFA_OBJECTTYPEMASK || - eType == pSibling->GetObjectType()) { - pNode = pSibling; - } - pSibling = pSibling->m_pNext; - } - } - break; - default: - break; - } - return pNode; -} -int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, - FX_DWORD dwTypeFilter, - XFA_ELEMENT eElementFilter, - int32_t iLevel) { - if (--iLevel < 0) { - return nodes.GetSize(); - } - if (eElementFilter != XFA_ELEMENT_UNKNOWN) { - CXFA_Node* pChild = m_pChild; - while (pChild) { - if (pChild->GetClassID() == eElementFilter) { - nodes.Add(pChild); - if (iLevel > 0) { - GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); - } - } - pChild = pChild->m_pNext; - } - } else if (dwTypeFilter == - (XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) { - CXFA_Node* pChild = m_pChild; - while (pChild) { - nodes.Add(pChild); - if (iLevel > 0) { - GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); - } - pChild = pChild->m_pNext; - } - } else if (dwTypeFilter != 0) { - FX_BOOL bFilterChildren = (dwTypeFilter & XFA_NODEFILTER_Children) != 0; - FX_BOOL bFilterProperties = (dwTypeFilter & XFA_NODEFILTER_Properties) != 0; - FX_BOOL bFilterOneOfProperties = - (dwTypeFilter & XFA_NODEFILTER_OneOfProperty) != 0; - CXFA_Node* pChild = m_pChild; - while (pChild) { - const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( - GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); - if (pProperty) { - if (bFilterProperties) { - nodes.Add(pChild); - } else if (bFilterOneOfProperties && - (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { - nodes.Add(pChild); - } else if (bFilterChildren && - (pChild->GetClassID() == XFA_ELEMENT_Variables || - pChild->GetClassID() == XFA_ELEMENT_PageSet)) { - nodes.Add(pChild); - } - } else { - if (bFilterChildren) { - nodes.Add(pChild); - } - } - pChild = pChild->m_pNext; - } - if (bFilterOneOfProperties && nodes.GetSize() < 1) { - int32_t iProperties = 0; - const XFA_PROPERTY* pProperty = - XFA_GetElementProperties(GetClassID(), iProperties); - if (pProperty == NULL || iProperties < 1) { - return 0; - } - for (int32_t i = 0; i < iProperties; i++) { - if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { - IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); - const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); - CXFA_Node* pNewNode = - pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); - if (!pNewNode) { - break; - } - InsertChild(pNewNode, NULL); - pNewNode->SetFlag(XFA_NODEFLAG_Initialized); - nodes.Add(pNewNode); - break; - } - } - } - } - return nodes.GetSize(); -} -CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_ELEMENT eElement, - FX_DWORD dwFlags) { - IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); - CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement); - pNode->SetFlag(dwFlags); - return pNode; -} -CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) { - FXSYS_assert(m_ePacket == XFA_XDPPACKET_Template); - IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); - CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_eNodeClass); - if (!pClone) { - return NULL; - } - pClone->SetTemplateNode(this); - pClone->UpdateNameHash(); - pClone->SetXMLMappingNode(GetXMLMappingNode()); - if (bRecursive) { - for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild; - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive)); - } - } - pClone->SetFlag(XFA_NODEFLAG_Initialized); - return pClone; -} - -CXFA_Node* CXFA_Node::GetTemplateNode() const { - return m_pAuxNode; -} - -void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) { - m_pAuxNode = pTemplateNode; -} -CXFA_Node* CXFA_Node::GetBindData() { - ASSERT(GetPacketID() == XFA_XDPPACKET_Form); - return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); -} -int32_t CXFA_Node::GetBindItems(CXFA_NodeArray& formItems) { - if (m_uFlags & XFA_NODEFLAG_BindFormItems) { - CXFA_NodeArray* pItems = NULL; - TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); - formItems.Copy(*pItems); - return formItems.GetSize(); - } - CXFA_Node* pFormNode = - static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); - if (pFormNode) { - formItems.Add(pFormNode); - } - return formItems.GetSize(); -} - -static void XFA_DataNodeDeleteBindItem(void* pData) { - delete static_cast<CXFA_NodeArray*>(pData); -} - -static XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = { - XFA_DataNodeDeleteBindItem, NULL}; -int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { - ASSERT(pFormNode); - if (m_uFlags & XFA_NODEFLAG_BindFormItems) { - CXFA_NodeArray* pItems = NULL; - TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); - ASSERT(pItems); - if (pItems->Find(pFormNode) < 0) { - pItems->Add(pFormNode); - } - return pItems->GetSize(); - } - CXFA_Node* pOldFormItem = - static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); - if (!pOldFormItem) { - SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); - return 1; - } else if (pOldFormItem == pFormNode) { - return 1; - } - CXFA_NodeArray* pItems = new CXFA_NodeArray; - SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack); - pItems->Add(pOldFormItem); - pItems->Add(pFormNode); - m_uFlags |= XFA_NODEFLAG_BindFormItems; - return 2; -} -int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { - if (m_uFlags & XFA_NODEFLAG_BindFormItems) { - CXFA_NodeArray* pItems = NULL; - TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems); - ASSERT(pItems); - int32_t iIndex = pItems->Find(pFormNode); - int32_t iCount = pItems->GetSize(); - if (iIndex >= 0) { - if (iIndex != iCount - 1) { - pItems->SetAt(iIndex, pItems->GetAt(iCount - 1)); - } - pItems->RemoveAt(iCount - 1); - if (iCount == 2) { - CXFA_Node* pLastFormNode = pItems->GetAt(0); - SetObject(XFA_ATTRIBUTE_BindingNode, pLastFormNode); - m_uFlags &= ~XFA_NODEFLAG_BindFormItems; - } - iCount--; - } - return iCount; - } - CXFA_Node* pOldFormItem = - static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode)); - if (pOldFormItem == pFormNode) { - SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - pOldFormItem = NULL; - } - return pOldFormItem == NULL ? 0 : 1; -} -FX_BOOL CXFA_Node::HasBindItem() { - return (GetPacketID() == XFA_XDPPACKET_Datasets) && - GetObject(XFA_ATTRIBUTE_BindingNode) != NULL; -} -CXFA_WidgetData* CXFA_Node::GetWidgetData() { - return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData); -} -CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { - if (GetPacketID() != XFA_XDPPACKET_Form) { - return NULL; - } - XFA_ELEMENT classID = GetClassID(); - if (classID == XFA_ELEMENT_ExclGroup) { - return NULL; - } - CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); - if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) { - return NULL; - } - if (classID == XFA_ELEMENT_Field) { - CXFA_WidgetData* pFieldWidgetData = GetWidgetData(); - if (pFieldWidgetData && - pFieldWidgetData->GetChoiceListOpen() == - XFA_ATTRIBUTEENUM_MultiSelect) { - return NULL; - } else { - CFX_WideString wsPicture; - if (pFieldWidgetData) { - pFieldWidgetData->GetPictureContent(wsPicture, - XFA_VALUEPICTURE_DataBind); - } - if (!wsPicture.IsEmpty()) { - return pFieldWidgetData; - } - CXFA_Node* pDataNode = GetBindData(); - if (!pDataNode) { - return NULL; - } - pFieldWidgetData = NULL; - CXFA_NodeArray formNodes; - pDataNode->GetBindItems(formNodes); - for (int32_t i = 0; i < formNodes.GetSize(); i++) { - CXFA_Node* pFormNode = formNodes.GetAt(i); - if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { - continue; - } - pFieldWidgetData = pFormNode->GetWidgetData(); - if (pFieldWidgetData) { - pFieldWidgetData->GetPictureContent(wsPicture, - XFA_VALUEPICTURE_DataBind); - } - if (!wsPicture.IsEmpty()) { - break; - } - pFieldWidgetData = NULL; - } - return pFieldWidgetData; - } - } - CXFA_Node* pGrandNode = - pParentNode ? pParentNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; - CXFA_Node* pValueNode = - (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Value) - ? pParentNode - : NULL; - if (!pValueNode) { - pValueNode = (pGrandNode && pGrandNode->GetClassID() == XFA_ELEMENT_Value) - ? pGrandNode - : NULL; - } - CXFA_Node* pParentOfValueNode = - pValueNode ? pValueNode->GetNodeItem(XFA_NODEITEM_Parent) : NULL; - return pParentOfValueNode ? pParentOfValueNode->GetContainerWidgetData() - : NULL; -} -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); - CXFA_Node* pLocaleNode = this; - FX_BOOL bLocale = FALSE; - do { - bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); - if (!bLocale) { - pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); - } - } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); - if (bLocale) { - return bLocale; - } - CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); - wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); - if (!wsLocaleName.IsEmpty()) { - bLocale = TRUE; - } - if (bLocale) { - return bLocale; - } - if (pTopSubform) { - bLocale = pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, FALSE); - } - if (bLocale) { - return bLocale; - } - IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); - if (pLocale) { - wsLocaleName = pLocale->GetName(); - bLocale = TRUE; - } - return bLocale; -} -XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { - XFA_ELEMENT eElement = GetClassID(); - CXFA_Node* pKeep = GetFirstChildByClass(XFA_ELEMENT_Keep); - XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); - if (pKeep) { - XFA_ATTRIBUTEENUM eIntact; - if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, FALSE)) { - if (eIntact == XFA_ATTRIBUTEENUM_None && - eLayoutType == XFA_ATTRIBUTEENUM_Row && - m_pDocument->GetCurVersionMode() < XFA_VERSION_208) { - CXFA_Node* pPreviewRow = - GetNodeItem(XFA_NODEITEM_PrevSibling, XFA_OBJECTTYPE_ContainerNode); - if (pPreviewRow && - pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) == - XFA_ATTRIBUTEENUM_Row) { - XFA_ATTRIBUTEENUM eValue; - if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, FALSE)) { - if (eValue == XFA_ATTRIBUTEENUM_ContentArea || - eValue == XFA_ATTRIBUTEENUM_PageArea) { - return XFA_ATTRIBUTEENUM_ContentArea; - } - } - CXFA_Node* pKeep = - pPreviewRow->GetFirstChildByClass(XFA_ELEMENT_Keep); - if (pKeep) { - if (pKeep->TryEnum(XFA_ATTRIBUTE_Next, eValue, FALSE)) { - if (eValue == XFA_ATTRIBUTEENUM_ContentArea || - eValue == XFA_ATTRIBUTEENUM_PageArea) { - return XFA_ATTRIBUTEENUM_ContentArea; - } - } - } - } - } - return eIntact; - } - } - switch (eElement) { - case XFA_ELEMENT_Subform: - switch (eLayoutType) { - case XFA_ATTRIBUTEENUM_Position: - case XFA_ATTRIBUTEENUM_Row: - return XFA_ATTRIBUTEENUM_ContentArea; - case XFA_ATTRIBUTEENUM_Tb: - case XFA_ATTRIBUTEENUM_Table: - case XFA_ATTRIBUTEENUM_Lr_tb: - case XFA_ATTRIBUTEENUM_Rl_tb: - return XFA_ATTRIBUTEENUM_None; - default: - break; - } - break; - case XFA_ELEMENT_Field: { - CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); - if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_PageArea) { - return XFA_ATTRIBUTEENUM_ContentArea; - } - if (pParentNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { - XFA_ATTRIBUTEENUM eParLayout = - pParentNode->GetEnum(XFA_ATTRIBUTE_Layout); - if (eParLayout == XFA_ATTRIBUTEENUM_Position || - eParLayout == XFA_ATTRIBUTEENUM_Row || - eParLayout == XFA_ATTRIBUTEENUM_Table) { - return XFA_ATTRIBUTEENUM_None; - } - XFA_VERSION version = m_pDocument->GetCurVersionMode(); - if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) { - CXFA_Measurement measureH; - if (TryMeasure(XFA_ATTRIBUTE_H, measureH, FALSE)) { - return XFA_ATTRIBUTEENUM_ContentArea; - } - } - return XFA_ATTRIBUTEENUM_None; - } - return XFA_ATTRIBUTEENUM_ContentArea; - } - case XFA_ELEMENT_Draw: - return XFA_ATTRIBUTEENUM_ContentArea; - default: - break; - } - return XFA_ATTRIBUTEENUM_None; -} -CXFA_Node* CXFA_Node::GetDataDescriptionNode() { - if (m_ePacket == XFA_XDPPACKET_Datasets) { - return m_pAuxNode; - } - return NULL; -} -void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) { - FXSYS_assert(m_ePacket == XFA_XDPPACKET_Datasets); - m_pAuxNode = pDataDescriptionNode; -} -void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - 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()); - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_Node* refNode = this; - if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { - refNode = ToNode(pScriptContext->GetThisObject()); - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | - XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = pScriptContext->ResolveObjects(refNode, wsExpression, - resoveNodeRS, dwFlag); - if (iRet < 1) { - return FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } - FXJSE_HVALUE hValue = NULL; - if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - CXFA_Object* pNode = resoveNodeRS.nodes[0]; - hValue = pScriptContext->GetJSValueFromMap(pNode); - FXJSE_Value_Set(pArguments->GetReturnValue(), hValue); - } else { - const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = - resoveNodeRS.pScriptAttribute; - if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { - hValue = FXJSE_Value_Create(pScriptContext->GetRuntime()); - (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( - hValue, FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); - FXJSE_Value_Set(pArguments->GetReturnValue(), hValue); - FXJSE_Value_Release(hValue); - } else { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } - } -} -void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"resolveNodes"); - return; - } - CFX_WideString wsExpression; - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (!hValue) { - return; - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | - XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - CXFA_Node* refNode = this; - if (refNode->GetClassID() == XFA_ELEMENT_Xfa) { - refNode = ToNode(m_pDocument->GetScriptContext()->GetThisObject()); - } - Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag, refNode); -} -void CXFA_Node::Script_Som_ResolveNodeList(FXJSE_HVALUE hValue, - CFX_WideString wsExpression, - FX_DWORD dwFlag, - CXFA_Node* refNode) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - XFA_RESOLVENODE_RS resoveNodeRS; - if (refNode == NULL) { - refNode = this; - } - pScriptContext->ResolveObjects(refNode, wsExpression, resoveNodeRS, dwFlag); - CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument); - if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - for (int32_t i = 0; i < resoveNodeRS.nodes.GetSize(); i++) { - if (resoveNodeRS.nodes[i]->IsNode()) - pNodeList->Append(resoveNodeRS.nodes[i]->AsNode()); - } - } else { - CXFA_HVALUEArray hValueArray(pScriptContext->GetRuntime()); - if (resoveNodeRS.GetAttributeResult(hValueArray) > 0) { - CXFA_ObjArray objectArray; - hValueArray.GetAttributeObject(objectArray); - for (int32_t i = 0; i < objectArray.GetSize(); i++) { - if (objectArray[i]->IsNode()) - pNodeList->Append(objectArray[i]->AsNode()); - } - } - } - FXJSE_Value_SetObject(hValue, (CXFA_Object*)pNodeList, - pScriptContext->GetJseNormalClass()); -} -void CXFA_Node::Script_TreeClass_All(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FX_DWORD dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; - CFX_WideString wsName; - GetAttribute(XFA_ATTRIBUTE_Name, wsName); - CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]"); - Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag); - } -} -void CXFA_Node::Script_TreeClass_Nodes(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - if (bSetting) { - IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); - FXSYS_assert(pAppProvider); - CFX_WideString wsMessage; - pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); - FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); - } else { - CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); - FXJSE_Value_SetObject(hValue, (CXFA_Object*)pNodeList, - pScriptContext->GetJseNormalClass()); - } -} -void CXFA_Node::Script_TreeClass_ClassAll(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FX_DWORD dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; - CFX_WideStringC wsName; - GetClassName(wsName); - CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); - Script_Som_ResolveNodeList(hValue, wsExpression, dwFlag); - } -} -void CXFA_Node::Script_TreeClass_Parent(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { - FXJSE_Value_Set( - hValue, m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); - } else { - FXJSE_Value_SetNull(hValue); - } - } -} -void CXFA_Node::Script_TreeClass_Index(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FXJSE_Value_SetInteger(hValue, GetNodeSameNameIndex()); - } -} -void CXFA_Node::Script_TreeClass_ClassIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FXJSE_Value_SetInteger(hValue, GetNodeSameClassIndex()); - } -} -void CXFA_Node::Script_TreeClass_SomExpression(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - CFX_WideString wsSOMExpression; - GetSOMExpression(wsSOMExpression); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsSOMExpression)); - } -} -void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - 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()); -} -void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"assignNode"); - return; - } - CFX_WideString wsExpression; - CFX_WideString wsValue; - int32_t iAction = 0; - if (iLength >= 1) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - } - if (iLength >= 2) { - CFX_ByteString bsValue = pArguments->GetUTF8String(1); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - } - if (iLength >= 3) { - iAction = pArguments->GetInt32(2); - } -} -void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); - return; - } - FX_BOOL bClone = TRUE; - bClone = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; - CXFA_Node* pCloneNode = Clone(bClone); - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); -} -void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"getAttribute"); - return; - } - CFX_WideString wsExpression; - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - CFX_WideString wsValue; - GetAttribute(wsExpression, wsValue); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); - } -} -void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); - return; - } - CFX_WideString wsExpression; - int32_t iValue = 0; - if (iLength >= 1) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - } - if (iLength >= 2) { - iValue = pArguments->GetInt32(1); - } - const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); - CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); - FXJSE_Value_Set(pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); -} -void CXFA_Node::Script_NodeClass_IsPropertySpecified( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"isPropertySpecified"); - return; - } - CFX_WideString wsExpression; - FX_BOOL bParent = TRUE; - int32_t iIndex = 0; - if (iLength >= 1) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - } - if (iLength >= 2) { - bParent = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - } - if (iLength >= 3) { - iIndex = pArguments->GetInt32(2); - } - FX_BOOL bHas = FALSE; - const XFA_ATTRIBUTEINFO* pAttributeInfo = - XFA_GetAttributeByName(wsExpression); - CFX_WideString wsValue; - if (pAttributeInfo) { - bHas = HasAttribute(pAttributeInfo->eName); - } - if (!bHas) { - const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); - bHas = (GetProperty(iIndex, pElementInfo->eName) != NULL); - } - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, bHas); - } -} -void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); - return; - } - CFX_WideString wsExpression; - FX_BOOL bIgnoreRoot = TRUE; - FX_BOOL bOverwrite = 0; - if (iLength >= 1) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - if (wsExpression.IsEmpty()) { - return; - } - } - if (iLength >= 2) { - bIgnoreRoot = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - } - if (iLength >= 3) { - bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; - } - IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument); - if (!pParser) { - return; - } - IFDE_XMLNode* pXMLNode = NULL; - int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); - if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { - pParser->Release(); - pParser = NULL; - return; - } - if (bIgnoreRoot && (pXMLNode->GetType() != FDE_XMLNODE_Element || - XFA_RecognizeRichText((IFDE_XMLElement*)pXMLNode))) { - bIgnoreRoot = FALSE; - } - CXFA_Node* pFakeRoot = Clone(FALSE); - CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); - if (!wsContentType.IsEmpty()) { - pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); - } - IFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); - if (!pFakeXMLRoot) { - IFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); - pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : NULL; - } - if (!pFakeXMLRoot) { - CFX_WideStringC wsClassName; - GetClassName(wsClassName); - pFakeXMLRoot = IFDE_XMLElement::Create(wsClassName); - } - if (bIgnoreRoot) { - IFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - while (pXMLChild) { - IFDE_XMLNode* pXMLSibling = - pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling); - pXMLNode->RemoveChildNode(pXMLChild); - pFakeXMLRoot->InsertChildNode(pXMLChild); - pXMLChild = pXMLSibling; - } - } else { - IFDE_XMLNode* pXMLParent = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); - if (pXMLParent) { - pXMLParent->RemoveChildNode(pXMLNode); - } - pFakeXMLRoot->InsertChildNode(pXMLNode); - } - pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot); - pFakeRoot = pParser->GetRootNode(); - if (pFakeRoot) { - if (bOverwrite) { - CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_Node* pNewChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - int32_t index = 0; - while (pNewChild) { - CXFA_Node* pItem = pNewChild->GetNodeItem(XFA_NODEITEM_NextSibling); - pFakeRoot->RemoveChild(pNewChild); - InsertChild(index++, pNewChild); - pNewChild->SetFlag(XFA_NODEFLAG_Initialized); - pNewChild = pItem; - } - while (pChild) { - CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - RemoveChild(pChild); - pFakeRoot->InsertChild(pChild); - pChild = pItem; - } - if (GetPacketID() == XFA_XDPPACKET_Form && - GetClassID() == XFA_ELEMENT_ExData) { - IFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); - SetXMLMappingNode(pFakeXMLRoot); - SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); - if (pTempXMLNode && - pTempXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL) { - pFakeXMLRoot = pTempXMLNode; - } else { - pFakeXMLRoot = NULL; - } - } - MoveBufferMapData(pFakeRoot, this, XFA_CalcData, TRUE); - } else { - CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChild) { - CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - pFakeRoot->RemoveChild(pChild); - InsertChild(pChild); - pChild->SetFlag(XFA_NODEFLAG_Initialized); - pChild = pItem; - } - } - if (pFakeXMLRoot) { - pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); - pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); - } - pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, TRUE, FALSE); - } else { - if (pFakeXMLRoot) { - pFakeXMLRoot->Release(); - pFakeXMLRoot = NULL; - } - } - pParser->Release(); - pParser = NULL; -} -void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { -} - -void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); - return; - } - FX_BOOL bPrettyMode = FALSE; - if (iLength == 1) { - CFX_ByteString bsPretty = pArguments->GetUTF8String(0); - if (!bsPretty.Equal("pretty")) { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - return; - } - bPrettyMode = TRUE; - } - CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; - if (GetPacketID() == XFA_XDPPACKET_Form) { - IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); - IFX_Stream* pStream = IFX_Stream::CreateStream( - (IFX_FileWrite*)pMemoryStream, - FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); - if (!pStream) { - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); - pMemoryStream->Release(); - pMemoryStream = NULL; - return; - } - pStream->SetCodePage(FX_CODEPAGE_UTF8); - pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength()); - XFA_DataExporter_RegenerateFormFile(this, pStream, NULL, TRUE); - FXJSE_Value_SetUTF8String( - pArguments->GetReturnValue(), - CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); - pStream->Release(); - pStream = NULL; - if (pMemoryStream) { - pMemoryStream->Release(); - pMemoryStream = NULL; - } - return; - } - if (GetPacketID() == XFA_XDPPACKET_Datasets) { - IFDE_XMLNode* pElement = GetXMLMappingNode(); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); - return; - } - XFA_DataExporter_DealWithDataGroupNode(this); - IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); - IFX_Stream* pStream = IFX_Stream::CreateStream( - (IFX_FileWrite*)pMemoryStream, - FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append); - if (pStream) { - pStream->SetCodePage(FX_CODEPAGE_UTF8); - pStream->WriteData(bsXMLHeader.GetPtr(), bsXMLHeader.GetLength()); - pElement->SaveXMLNode(pStream); - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), - CFX_ByteStringC(pMemoryStream->GetBuffer(), - pMemoryStream->GetSize())); - pStream->Release(); - pStream = NULL; - } - if (pMemoryStream) { - pMemoryStream->Release(); - pMemoryStream = NULL; - } - return; - } - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); -} - -void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - 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, wsAttributeValue, TRUE); -} -void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1 && iLength != 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setElement"); - return; - } - CXFA_Node* pNode = NULL; - CFX_WideString wsName; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (iLength >= 2) { - CFX_ByteString bsName = pArguments->GetUTF8String(1); - wsName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); - } -} -void CXFA_Node::Script_NodeClass_Ns(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - CFX_WideString wsNameSpace; - TryNamespace(wsNameSpace); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsNameSpace)); - } -} -void CXFA_Node::Script_NodeClass_Model(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FXJSE_Value_Set(hValue, m_pDocument->GetScriptContext()->GetJSValueFromMap( - GetModelNode())); - } -} -void CXFA_Node::Script_NodeClass_IsContainer(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FXJSE_Value_SetBoolean(hValue, IsContainerNode()); - } -} -void CXFA_Node::Script_NodeClass_IsNull(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - if (GetClassID() == XFA_ELEMENT_Subform) { - FXJSE_Value_SetBoolean(hValue, FALSE); - return; - } - CFX_WideString strValue; - FXJSE_Value_SetBoolean(hValue, !TryContent(strValue) || strValue.IsEmpty()); - } -} -void CXFA_Node::Script_NodeClass_OneOfChild(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - CXFA_NodeArray properts; - int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); - if (iSize > 0) { - FXJSE_Value_Set( - hValue, - m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); - } - } -} -void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} -void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { - CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); - FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, - m_pDocument->GetScriptContext()->GetJseNormalClass()); -} -void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { -} -void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { - Script_Template_CreateNode(pArguments); -} -void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"isCompatibleNS"); - return; - } - CFX_WideString wsNameSpace; - if (iLength >= 1) { - CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); - wsNameSpace = - CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); - } - CFX_WideString wsNodeNameSpace; - TryNamespace(wsNodeNameSpace); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace.Equal(wsNameSpace)); - } -} -void CXFA_Node::Script_ModelClass_Context(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Attribute_Integer(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - SetInteger(eAttribute, FXJSE_Value_ToInteger(hValue), TRUE); - } else { - FXJSE_Value_SetInteger(hValue, GetInteger(eAttribute)); - } -} -void CXFA_Node::Script_Attribute_IntegerRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - FXJSE_Value_SetInteger(hValue, GetInteger(eAttribute)); - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_Attribute_BOOL(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - SetBoolean(eAttribute, FXJSE_Value_ToBoolean(hValue), TRUE); - } else { - FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); - } -} -void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0"); - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( - void* eAttribute, - void* eValue, - FX_BOOL bScriptModify) { - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (!pLayoutPro) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - FX_DWORD 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)); - } - } break; - case XFA_ELEMENT_CheckButton: { - bNeedFindContainer = TRUE; - CXFA_Node* pUINode = 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; - } - 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->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); - } - } - } - } break; - default: - break; - } - if (bNeedFindContainer) { - CXFA_Node* pParent = this; - while (pParent) { - if (pParent->IsContainerNode()) { - break; - } - pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); - } - 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, TRUE); - if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { - CFX_WideString wsUseVal = wsValue, wsID, wsSOM; - CXFA_Node* pTemplateNode = - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); - CXFA_Node* pProtoRoot = - pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) - ->GetFirstChildByClass(XFA_ELEMENT_Proto); - if (!wsUseVal.IsEmpty()) { - if (wsUseVal[0] == '#') { - wsID = CFX_WideString((const FX_WCHAR*)wsUseVal + 1, - wsUseVal.GetLength() - 1); - } else { - wsSOM = - CFX_WideString((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength()); - } - } - CXFA_Node* pProtoNode = NULL; - if (!wsSOM.IsEmpty()) { - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | - XFA_RESOLVENODE_Attributes | - XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects( - pProtoRoot, wsSOM, resoveNodeRS, dwFlag); - if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { - pProtoNode = resoveNodeRS.nodes[0]->AsNode(); - } - } else if (!wsID.IsEmpty()) { - pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID); - } - if (pProtoNode) { - CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild); - while (pHeadChild) { - CXFA_Node* pSibling = - pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); - RemoveChild(pHeadChild); - pHeadChild = pSibling; - } - CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(TRUE); - pHeadChild = pProtoForm->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pHeadChild) { - CXFA_Node* pSibling = - pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); - pProtoForm->RemoveChild(pHeadChild); - InsertChild(pHeadChild); - pHeadChild = pSibling; - } - m_pDocument->RemovePurgeNode(pProtoForm); - delete pProtoForm; - } - } - } else { - CFX_WideString wsValue; - GetAttribute(eAttribute, wsValue); - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(wsValue, wsValue.GetLength())); - } -} -void CXFA_Node::Script_Attribute_StringRead(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - CFX_WideString wsValue; - GetAttribute(eAttribute, wsValue); - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(wsValue, wsValue.GetLength())); - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc == 0) || (argc == 1)) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); - } -} -void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); - } -} -void CXFA_Node::Script_Delta_CurrentValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Delta_SavedValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Delta_Target(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Som_Message(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_SOM_MESSAGETYPE iMessageType) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - FX_BOOL bNew = FALSE; - CXFA_Validate validate = pWidgetData->GetValidate(); - if (!validate) { - validate = pWidgetData->GetValidate(TRUE); - bNew = TRUE; - } - if (bSetting) { - CFX_ByteString bsMessage; - FXJSE_Value_ToUTF8String(hValue, bsMessage); - switch (iMessageType) { - case XFA_SOM_ValidationMessage: - validate.SetScriptMessageText( - CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); - break; - case XFA_SOM_FormatMessage: - validate.SetFormatMessageText( - CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); - break; - case XFA_SOM_MandatoryMessage: - validate.SetNullMessageText( - CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength())); - break; - default: - break; - } - if (!bNew) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->AddCalcValidate(this); - } - } else { - CFX_WideString wsMessage; - switch (iMessageType) { - case XFA_SOM_ValidationMessage: - validate.GetScriptMessageText(wsMessage); - break; - case XFA_SOM_FormatMessage: - validate.GetFormatMessageText(wsMessage); - break; - case XFA_SOM_MandatoryMessage: - validate.GetNullMessageText(wsMessage); - break; - default: - break; - } - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsMessage)); - } -} -void CXFA_Node::Script_Som_ValidationMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_Som_Message(hValue, bSetting, XFA_SOM_ValidationMessage); -} -void CXFA_Node::Script_Field_Length(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetInteger(hValue, 0); - return; - } - FXJSE_Value_SetInteger(hValue, pWidgetData->CountChoiceListItems(TRUE)); - } -} -void CXFA_Node::Script_Som_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - XFA_ELEMENT classID = GetClassID(); - if (classID == XFA_ELEMENT_Field) { - Script_Field_DefaultValue(hValue, bSetting, eAttribute); - return; - } else if (classID == XFA_ELEMENT_Draw) { - Script_Draw_DefaultValue(hValue, bSetting, eAttribute); - return; - } else if (classID == XFA_ELEMENT_Boolean) { - Script_Boolean_Value(hValue, bSetting, eAttribute); - return; - } - if (bSetting) { - CFX_ByteString newValue; - 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 wsFormatValue(wsNewValue); - CXFA_WidgetData* pContainerWidgetData = NULL; - if (GetPacketID() == XFA_XDPPACKET_Datasets) { - CXFA_NodeArray formNodes; - GetBindItems(formNodes); - CFX_WideString wsPicture; - for (int32_t i = 0; i < formNodes.GetSize(); i++) { - CXFA_Node* pFormNode = formNodes.GetAt(i); - if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { - continue; - } - pContainerWidgetData = pFormNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetPictureContent(wsPicture, - XFA_VALUEPICTURE_DataBind); - } - if (!wsPicture.IsEmpty()) { - break; - } - pContainerWidgetData = NULL; - } - } else if (GetPacketID() == XFA_XDPPACKET_Form) { - pContainerWidgetData = GetContainerWidgetData(); - } - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); - } - 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)); - } else if (classID == XFA_ELEMENT_Float || classID == XFA_ELEMENT_Decimal) { - CFX_Decimal decimal(content); - FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); - } else { - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(content, content.GetLength())); - } - } -} -void CXFA_Node::Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CFX_WideString content = GetScriptContent(TRUE); - if (content.IsEmpty()) { - FXJSE_Value_SetNull(hValue); - } else { - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(content, content.GetLength())); - } -} -void CXFA_Node::Script_Boolean_Value(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - CFX_ByteString newValue; - 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"); - CFX_WideString wsFormatValue(wsNewValue); - CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); - } - SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); - } else { - CFX_WideString wsValue = GetScriptContent(TRUE); - FXJSE_Value_SetBoolean(hValue, wsValue.Equal(FX_WSTRC(L"1"))); - } -} -struct XFA_ExecEventParaInfo { - public: - uint32_t m_uHash; - const FX_WCHAR* m_lpcEventName; - XFA_EVENTTYPE m_eventType; - uint32_t m_validFlags; -}; -static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { - {0x02a6c55a, L"postSubmit", XFA_EVENT_PostSubmit, 0}, - {0x0ab466bb, L"preSubmit", XFA_EVENT_PreSubmit, 0}, - {0x109d7ce7, L"mouseEnter", XFA_EVENT_MouseEnter, 5}, - {0x17fad373, L"postPrint", XFA_EVENT_PostPrint, 0}, - {0x1bfc72d9, L"preOpen", XFA_EVENT_PreOpen, 7}, - {0x2196a452, L"initialize", XFA_EVENT_Initialize, 1}, - {0x27410f03, L"mouseExit", XFA_EVENT_MouseExit, 5}, - {0x33c43dec, L"docClose", XFA_EVENT_DocClose, 0}, - {0x361fa1b6, L"preSave", XFA_EVENT_PreSave, 0}, - {0x36f1c6d8, L"preSign", XFA_EVENT_PreSign, 6}, - {0x4731d6ba, L"exit", XFA_EVENT_Exit, 2}, - {0x56bf456b, L"docReady", XFA_EVENT_DocReady, 0}, - {0x7233018a, L"validate", XFA_EVENT_Validate, 1}, - {0x8808385e, L"indexChange", XFA_EVENT_IndexChange, 3}, - {0x891f4606, L"change", XFA_EVENT_Change, 4}, - {0x9528a7b4, L"prePrint", XFA_EVENT_PrePrint, 0}, - {0x9f693b21, L"mouseDown", XFA_EVENT_MouseDown, 5}, - {0xcdce56b3, L"full", XFA_EVENT_Full, 4}, - {0xd576d08e, L"mouseUp", XFA_EVENT_MouseUp, 5}, - {0xd95657a6, L"click", XFA_EVENT_Click, 4}, - {0xdbfbe02e, L"calculate", XFA_EVENT_Calculate, 1}, - {0xe25fa7b8, L"postOpen", XFA_EVENT_PostOpen, 7}, - {0xe28dce7e, L"enter", XFA_EVENT_Enter, 2}, - {0xfc82d695, L"postSave", XFA_EVENT_PostSave, 0}, - {0xfd54fbb7, L"postSign", XFA_EVENT_PostSign, 6}, -}; -const XFA_ExecEventParaInfo* GetEventParaInfoByName( - const CFX_WideStringC& wsEventName) { - int32_t iLength = wsEventName.GetLength(); - uint32_t uHash = FX_HashCode_String_GetW(wsEventName.GetPtr(), 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; - do { - iMid = (iStart + iEnd) / 2; - eventParaInfo = &gs_eventParaInfos[iMid]; - if (uHash == eventParaInfo->m_uHash) { - return eventParaInfo; - } else if (uHash < eventParaInfo->m_uHash) { - iEnd = iMid - 1; - } else { - iStart = iMid + 1; - } - } while (iStart <= iEnd); - return NULL; -} -void XFA_STRING_TO_RGB(CFX_WideString& strRGB, - int32_t& r, - int32_t& g, - int32_t& b) { - r = 0; - g = 0; - b = 0; - FX_WCHAR zero = '0'; - int32_t iIndex = 0; - int32_t iLen = strRGB.GetLength(); - for (int32_t i = 0; i < iLen; ++i) { - FX_WCHAR ch = strRGB.GetAt(i); - if (ch == L',') { - ++iIndex; - } - if (iIndex > 2) { - break; - } - int32_t iValue = ch - zero; - if (iValue >= 0 && iValue <= 9) { - switch (iIndex) { - case 0: - r = r * 10 + iValue; - break; - case 1: - g = g * 10 + iValue; - break; - default: - b = b * 10 + iValue; - break; - } - } - } -} -void CXFA_Node::Script_Som_BorderColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CXFA_Border border = pWidgetData->GetBorder(TRUE); - int32_t iSize = border.CountEdges(); - CFX_WideString strColor; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - strColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - int32_t r = 0, g = 0, b = 0; - XFA_STRING_TO_RGB(strColor, r, g, b); - FX_ARGB rgb = ArgbEncode(100, r, g, b); - for (int32_t i = 0; i < iSize; ++i) { - CXFA_Edge edge = border.GetEdge(i); - edge.SetColor(rgb); - } - } else { - CXFA_Edge edge = border.GetEdge(0); - FX_ARGB color = edge.GetColor(); - 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)); - } -} -void CXFA_Node::Script_Som_BorderWidth(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CXFA_Border border = pWidgetData->GetBorder(TRUE); - int32_t iSize = border.CountEdges(); - CFX_WideString wsThickness; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsThickness = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - for (int32_t i = 0; i < iSize; ++i) { - CXFA_Edge edge = border.GetEdge(i); - CXFA_Measurement thickness(wsThickness); - 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)); - } -} -void CXFA_Node::Script_Som_FillColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CXFA_Border border = pWidgetData->GetBorder(TRUE); - CXFA_Fill borderfill = border.GetFill(TRUE); - CXFA_Node* pNode = borderfill.GetNode(); - if (!pNode) { - return; - } - CFX_WideString wsColor; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - int32_t r, g, b; - XFA_STRING_TO_RGB(wsColor, r, g, b); - FX_ARGB color = ArgbEncode(0xff, r, g, b); - borderfill.SetColor(color); - } else { - FX_ARGB color = borderfill.GetColor(); - 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)); - } -} -void CXFA_Node::Script_Som_DataNode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - CXFA_Node* pDataNode = GetBindData(); - if (pDataNode) { - FXJSE_Value_Set( - hValue, - m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); - } else { - FXJSE_Value_SetNull(hValue); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_Draw_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - if (FXJSE_Value_IsUTF8String(hValue)) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - FXSYS_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 wsFormatValue(wsNewValue); - SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); - } else if (uiType != XFA_ELEMENT_Image) { - } - } - } else { - CFX_WideString content = GetScriptContent(TRUE); - if (content.IsEmpty()) { - FXJSE_Value_SetNull(hValue); - } else { - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(content, content.GetLength())); - } - } -} -void CXFA_Node::Script_Field_DefaultValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - if (bSetting) { - if (FXJSE_Value_IsNull(hValue)) { - pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; - pWidgetData->m_bIsNull = TRUE; - } else { - pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; - pWidgetData->m_bIsNull = FALSE; - } - CFX_ByteString newValue; - if (!(FXJSE_Value_IsNull(hValue) || FXJSE_Value_IsUndefined(hValue))) { - FXJSE_Value_ToUTF8String(hValue, newValue); - } - CFX_WideString wsNewText = - CFX_WideString::FromUTF8(newValue, newValue.GetLength()); - 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); - } - CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); - CFX_WideString wsFormatText(wsNewText); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); - } - SetScriptContent(wsNewText, wsFormatText, TRUE, TRUE); - } else { - CFX_WideString content = GetScriptContent(TRUE); - if (content.IsEmpty()) { - FXJSE_Value_SetNull(hValue); - } else { - CXFA_Node* pUIChild = pWidgetData->GetUIChild(); - XFA_ELEMENT eUI = pUIChild->GetClassID(); - CXFA_Value defVal = pWidgetData->GetFormValue(); - CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pNode && pNode->GetClassID() == XFA_ELEMENT_Decimal) { - if (eUI == XFA_ELEMENT_NumericEdit && - (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { - FXJSE_Value_SetUTF8String( - hValue, FX_UTF8Encode(content, content.GetLength())); - } else { - CFX_Decimal decimal(content); - FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); - } - } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Integer) { - FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content)); - } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Boolean) { - FXJSE_Value_SetBoolean(hValue, FXSYS_wtoi(content) == 0 ? FALSE : TRUE); - } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Float) { - CFX_Decimal decimal(content); - FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal); - } else { - FXJSE_Value_SetUTF8String(hValue, - FX_UTF8Encode(content, content.GetLength())); - } - } - } -} -void CXFA_Node::Script_Field_EditValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CFX_WideString wsValue; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit); - } else { - pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); - } -} -void CXFA_Node::Script_Som_FontColor(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CXFA_Font font = pWidgetData->GetFont(TRUE); - CXFA_Node* pNode = font.GetNode(); - if (!pNode) { - return; - } - CFX_WideString wsColor; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - int32_t r, g, b; - XFA_STRING_TO_RGB(wsColor, r, g, b); - FX_ARGB color = ArgbEncode(0xff, r, g, b); - font.SetColor(color); - } else { - FX_ARGB color = font.GetColor(); - 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)); - } -} -void CXFA_Node::Script_Field_FormatMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_Som_Message(hValue, bSetting, XFA_SOM_FormatMessage); -} -void CXFA_Node::Script_Field_FormattedValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CFX_WideString wsValue; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display); - } else { - pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); - } -} -void CXFA_Node::Script_Som_Mandatory(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CXFA_Validate validate = pWidgetData->GetValidate(TRUE); - CFX_WideString wsValue; - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - validate.SetNullTest(wsValue); - } else { - int32_t iValue = validate.GetNullTest(); - const XFA_ATTRIBUTEENUMINFO* pInfo = - XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); - if (pInfo) { - wsValue = pInfo->pName; - } - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); - } -} -void CXFA_Node::Script_Som_MandatoryMessage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_Som_Message(hValue, bSetting, XFA_SOM_MandatoryMessage); -} -void CXFA_Node::Script_Field_ParentSubform(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } else { - FXJSE_Value_SetNull(hValue); - } -} -void CXFA_Node::Script_Field_SelectedIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - if (bSetting) { - int32_t iIndex = FXJSE_Value_ToInteger(hValue); - if (iIndex == -1) { - pWidgetData->ClearAllSelections(); - return; - } - pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE); - } else { - FXJSE_Value_SetInteger(hValue, pWidgetData->GetSelectedItem()); - } -} -void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - pWidgetData->DeleteItem(-1, TRUE); -} -void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CFX_ByteString eventString = pArguments->GetUTF8String(0); - int32_t iRet = execSingleEventByName( - CFX_WideString::FromUTF8(eventString, eventString.GetLength()), - XFA_ELEMENT_Field); - if (eventString == "validate") { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), - ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); - } -} -void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, FALSE, FALSE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execInitialize"); - } -} -void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - int32_t iIndex = pArguments->GetInt32(0); - FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, bValue); - } -} -void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); - return; - } - int32_t iIndex = pArguments->GetInt32(0); - if (iIndex < 0) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - return; - } - CFX_WideString wsValue; - FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); - if (bHasItem) { - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), - FX_UTF8Encode(wsValue, wsValue.GetLength())); - } else { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } -} -void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CFX_ByteString bsValue = pArguments->GetUTF8String(0); - CFX_WideString wsValue = - CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - CFX_WideString wsBoundValue; - pWidgetData->GetItemValue(wsValue, wsBoundValue); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsBoundValue)); - } -} -void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"getItemState"); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - int32_t iIndex = pArguments->GetInt32(0); - FX_BOOL bValue = pWidgetData->GetItemState(iIndex); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, bValue); - } -} -void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execCalculate"); - } -} -void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} -void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"getDisplayItem"); - return; - } - int32_t iIndex = pArguments->GetInt32(0); - if (iIndex < 0) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - return; - } - CFX_WideString wsValue; - FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); - if (bHasItem) { - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), - FX_UTF8Encode(wsValue, wsValue.GetLength())); - } else { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } -} -void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"setItemState"); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - int32_t iIndex = pArguments->GetInt32(0); - if (pArguments->GetInt32(1) != 0) { - pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE); - } else { - if (pWidgetData->GetItemState(iIndex)) { - pWidgetData->SetItemState(iIndex, FALSE, TRUE, TRUE); - } - } -} -void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem"); - return; - } - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - CFX_WideString wsLabel; - CFX_WideString wsValue; - if (iLength >= 1) { - CFX_ByteString bsLable = pArguments->GetUTF8String(0); - wsLabel = CFX_WideString::FromUTF8(bsLable, bsLable.GetLength()); - } - if (iLength >= 2) { - CFX_ByteString bsValue = pArguments->GetUTF8String(1); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - } - pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); -} -void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - int32_t iRet = - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), - ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execValidate"); - } -} -void CXFA_Node::Script_ExclGroup_ErrorText(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - return; - } - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - pWidgetData->SetSelectedMemberByValue( - CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()), 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)); - } - } -} -void CXFA_Node::Script_ExclGroup_Transient(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CFX_ByteString eventString = pArguments->GetUTF8String(0); - execSingleEventByName( - CFX_WideString::FromUTF8(eventString, eventString.GetLength()), - XFA_ELEMENT_ExclGroup); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); - } -} -void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc == 0) || (argc == 1)) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } else { - CXFA_Node* pReturnNode = NULL; - if (argc == 0) { - pReturnNode = pWidgetData->GetSelectedMember(); - } else { - CFX_ByteString szName; - szName = pArguments->GetUTF8String(0); - pReturnNode = pWidgetData->SetSelectedMember( - CFX_WideString::FromUTF8(szName, szName.GetLength())); - } - if (pReturnNode) { - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode)); - } else { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"selectedMember"); - } -} -void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execInitialize"); - } -} -void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execCalculate"); - } -} -void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), - ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execValidate"); - } -} -static CXFA_Node* XFA_ScriptInstanceManager_GetItem(CXFA_Node* pInstMgrNode, - int32_t iIndex) { - ASSERT(pInstMgrNode); - int32_t iCount = 0; - FX_DWORD dwNameHash = 0; - for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ELEMENT eCurType = pNode->GetClassID(); - if (eCurType == XFA_ELEMENT_InstanceManager) { - break; - } - if ((eCurType != XFA_ELEMENT_Subform) && - (eCurType != XFA_ELEMENT_SubformSet)) { - continue; - } - if (iCount == 0) { - CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); - CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || - wsInstName.Mid(1) != wsName) { - return NULL; - } - dwNameHash = pNode->GetNameHash(); - } - if (dwNameHash != pNode->GetNameHash()) { - break; - } - iCount++; - if (iCount > iIndex) { - return pNode; - } - } - return NULL; -} -void CXFA_Node::Script_Som_InstanceIndex(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - int32_t iTo = FXJSE_Value_ToInteger(hValue); - int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); - CXFA_Node* pManagerNode = NULL; - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { - if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { - pManagerNode = pNode; - break; - } - } - if (pManagerNode) { - pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pToInstance = - XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); - if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { - pNotify->RunSubformIndexChange(pToInstance); - } - CXFA_Node* pFromInstance = - XFA_ScriptInstanceManager_GetItem(pManagerNode, iFrom); - if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { - pNotify->RunSubformIndexChange(pFromInstance); - } - } - } else { - FXJSE_Value_SetInteger(hValue, Subform_and_SubformSet_InstanceIndex()); - } -} -void CXFA_Node::Script_Subform_InstanceManager(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); - CXFA_Node* pInstanceMgr = NULL; - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { - if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { - CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && - wsInstMgrName.Mid(1) == wsName) { - pInstanceMgr = pNode; - } - break; - } - } - if (pInstanceMgr) { - FXJSE_Value_Set( - hValue, - m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); - } else { - FXJSE_Value_SetNull(hValue); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -void CXFA_Node::Script_Subform_Locale(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - CFX_ByteString bsLocaleName; - FXJSE_Value_ToUTF8String(hValue, bsLocaleName); - SetCData(XFA_ATTRIBUTE_Locale, - CFX_WideString::FromUTF8(bsLocaleName, bsLocaleName.GetLength()), - TRUE, TRUE); - } else { - CFX_WideString wsLocaleName; - GetLocaleName(wsLocaleName); - FXJSE_Value_SetUTF8String( - hValue, FX_UTF8Encode(wsLocaleName, wsLocaleName.GetLength())); - } -} -void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CFX_ByteString eventString = pArguments->GetUTF8String(0); - execSingleEventByName( - CFX_WideString::FromUTF8(eventString, eventString.GetLength()), - XFA_ELEMENT_Subform); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); - } -} -void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execInitialize"); - } -} -void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execCalculate"); - } -} -void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), - ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execValidate"); - } -} -void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"getInvalidObjects"); - } -} -int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { - int32_t index = 0; - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { - if ((pNode->GetClassID() == XFA_ELEMENT_Subform) || - (pNode->GetClassID() == XFA_ELEMENT_SubformSet)) { - index++; - } else { - break; - } - } - return index; -} -void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); - } -} -void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - m_pDocument->DoDataRemerge(TRUE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); - } -} -void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execInitialize"); - } -} -void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc > 0) && (argc < 4)) { - CFX_WideString strTagName; - CFX_WideString strName; - CFX_WideString strNameSpace; - CFX_ByteString bsTagName = pArguments->GetUTF8String(0); - strTagName = CFX_WideString::FromUTF8(bsTagName, bsTagName.GetLength()); - if (argc > 1) { - CFX_ByteString bsName = pArguments->GetUTF8String(1); - strName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); - if (argc == 3) { - CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); - strNameSpace = - CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); - } - } - const XFA_ELEMENTINFO* pElement = XFA_GetElementByName(strTagName); - CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); - if (!pNewNode) { - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } else { - if (!strName.IsEmpty()) { - if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, - XFA_XDPPACKET_UNKNOWN)) { - pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName, TRUE); - if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { - pNewNode->CreateXMLMappingNode(); - } - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); - } else { - ThrowScriptErrorMessage(XFA_IDS_NOT_HAVE_PROPERTY, - (const FX_WCHAR*)strTagName, L"name"); - } - } else { - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); - } - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); - } -} -void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { - if (pArguments->GetLength() == 1) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); - } -} -void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execCalculate"); - } -} -void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execValidate"); - } -} -void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (!pWidgetData) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); - } -} -void CXFA_Node::Script_InstanceManager_Max(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CXFA_Occur nodeOccur(GetOccurNode()); - FXJSE_Value_SetInteger(hValue, nodeOccur.GetMax()); -} -void CXFA_Node::Script_InstanceManager_Min(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CXFA_Occur nodeOccur(GetOccurNode()); - FXJSE_Value_SetInteger(hValue, nodeOccur.GetMin()); -} -static int32_t XFA_ScriptInstanceManager_GetCount(CXFA_Node* pInstMgrNode) { - ASSERT(pInstMgrNode); - int32_t iCount = 0; - FX_DWORD dwNameHash = 0; - for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ELEMENT eCurType = pNode->GetClassID(); - if (eCurType == XFA_ELEMENT_InstanceManager) { - break; - } - if ((eCurType != XFA_ELEMENT_Subform) && - (eCurType != XFA_ELEMENT_SubformSet)) { - continue; - } - if (iCount == 0) { - CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); - CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || - wsInstName.Mid(1) != wsName) { - return iCount; - } - dwNameHash = pNode->GetNameHash(); - } - if (dwNameHash != pNode->GetNameHash()) { - break; - } - iCount++; - } - return iCount; -} -static void -XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( - const CXFA_NodeSet& rgNodeSet, - CXFA_NodeArray& rgNodeArray, - CFX_ArrayTemplate<int32_t>& rgIdxArray) { - int32_t iCount = rgNodeSet.GetCount(); - rgNodeArray.SetSize(iCount); - rgIdxArray.SetSize(iCount); - 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); - pNode && iIndex < iCount; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - iTotalIndex++; - if (rgNodeSet.Lookup(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<FX_DWORD, 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); - FX_DWORD dwNameHash = pNode->GetNameHash(); - if (!pParentNode || !dwNameHash) { - continue; - } - CFX_MapPtrTemplate<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = - rgNodeListMap[pParentNode]; - if (!pNodeListChildMap) { - rgNodeListMap[pParentNode] = pNodeListChildMap = - new CFX_MapPtrTemplate<FX_DWORD, 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); - FX_DWORD dwNameHash = pNode->GetNameHash(); - if (!pParentNode || !dwNameHash) { - continue; - } - CFX_MapPtrTemplate<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = - rgNodeListMap[pParentNode]; - if (!pNodeListChildMap) { - rgNodeListMap[pParentNode] = pNodeListChildMap = - new CFX_MapPtrTemplate<FX_DWORD, 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<FX_DWORD, CXFA_DualNodeArray*>* pNodeListChildMap = NULL; - rgNodeListMap.GetNextAssoc(pos, pParentNode, pNodeListChildMap); - if (!pNodeListChildMap) { - continue; - } - FX_POSITION childpos = pNodeListChildMap->GetStartPosition(); - while (childpos) { - FX_DWORD dwNameHash = 0; - CXFA_DualNodeArray* pDualNodeArray = NULL; - pNodeListChildMap->GetNextAssoc(childpos, dwNameHash, pDualNodeArray); - if (!pDualNodeArray) { - continue; - } - if (pDualNodeArray->firstNodeList.GetCount() != 0 && - pDualNodeArray->secondNodeList.GetCount() != 0) { - CXFA_NodeArray rgNodeArray1, rgNodeArray2; - CFX_ArrayTemplate<int32_t> rgIdxArray1, rgIdxArray2; - XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( - pDualNodeArray->firstNodeList, rgNodeArray1, rgIdxArray1); - XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx( - pDualNodeArray->secondNodeList, rgNodeArray2, rgIdxArray2); - CXFA_Node *pParentNode = NULL, *pBeforeNode = NULL; - if (bInsertBefore) { - pBeforeNode = rgNodeArray2[0]; - pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent); - } else { - CXFA_Node* pLastNode = rgNodeArray2[rgIdxArray2.GetSize() - 1]; - pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent); - pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - for (int32_t iIdx = 0, iCount = rgIdxArray1.GetSize(); iIdx < iCount; - iIdx++) { - CXFA_Node* pCurNode = rgNodeArray1[iIdx]; - pParentNode->RemoveChild(pCurNode); - pParentNode->InsertChild(pCurNode, pBeforeNode); - } - } - delete pDualNodeArray; - } - pNodeListChildMap->RemoveAll(); - } - rgNodeListMap.RemoveAll(); -} -static void XFA_ScriptInstanceManager_InsertItem( - CXFA_Node* pInstMgrNode, - CXFA_Node* pNewInstance, - int32_t iPos, - int32_t iCount = -1, - FX_BOOL bMoveDataBindingNodes = TRUE) { - if (iCount < 0) { - iCount = XFA_ScriptInstanceManager_GetCount(pInstMgrNode); - } - if (iPos < 0) { - iPos = iCount; - } - if (iPos == iCount) { - CXFA_Node* pNextSibling = - iCount > 0 - ? XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iCount - 1) - ->GetNodeItem(XFA_NODEITEM_NextSibling) - : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) - ->InsertChild(pNewInstance, pNextSibling); - if (bMoveDataBindingNodes) { - CXFA_NodeSet sNew, sAfter; - CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode> - sIteratorNew(pNewInstance); - for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; - pNode = sIteratorNew.MoveToNext()) { - CXFA_Node* pDataNode = pNode->GetBindData(); - if (!pDataNode) { - continue; - } - sNew.Add(pDataNode); - } - CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode> - sIteratorAfter(pNextSibling); - for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode; - pNode = sIteratorAfter.MoveToNext()) { - CXFA_Node* pDataNode = pNode->GetBindData(); - if (!pDataNode) { - continue; - } - sAfter.Add(pDataNode); - } - XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sAfter, FALSE); - } - } else { - CXFA_Node* pBeforeInstance = - XFA_ScriptInstanceManager_GetItem(pInstMgrNode, iPos); - pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) - ->InsertChild(pNewInstance, pBeforeInstance); - if (bMoveDataBindingNodes) { - CXFA_NodeSet sNew, sBefore; - CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode> - sIteratorNew(pNewInstance); - for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode; - pNode = sIteratorNew.MoveToNext()) { - CXFA_Node* pDataNode = pNode->GetBindData(); - if (!pDataNode) { - continue; - } - sNew.Add(pDataNode); - } - CXFA_NodeIteratorTemplate<CXFA_Node, - CXFA_TraverseStrategy_XFAContainerNode> - sIteratorBefore(pBeforeInstance); - for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode; - pNode = sIteratorBefore.MoveToNext()) { - CXFA_Node* pDataNode = pNode->GetBindData(); - if (!pDataNode) { - continue; - } - sBefore.Add(pDataNode); - } - XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sBefore, TRUE); - } - } -} -static void XFA_ScriptInstanceManager_RemoveItem( - CXFA_Node* pInstMgrNode, - CXFA_Node* pRemoveInstance, - FX_BOOL bRemoveDataBinding = TRUE) { - pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance); - if (!bRemoveDataBinding) { - return; - } - CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> - sIterator(pRemoveInstance); - for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode; - pFormNode = sIterator.MoveToNext()) { - CXFA_Node* pDataNode = pFormNode->GetBindData(); - if (!pDataNode) { - continue; - } - if (pDataNode->RemoveBindItem(pFormNode) == 0) { - if (CXFA_Node* pDataParent = - pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) { - pDataParent->RemoveChild(pDataNode); - } - } - pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); - } -} -static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance( - CXFA_Node* pInstMgrNode, - FX_BOOL bDataMerge) { - CXFA_Document* pDocument = pInstMgrNode->GetDocument(); - CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode(); - CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_Node* pDataScope = NULL; - for (CXFA_Node* pRootBoundNode = pFormParent; - pRootBoundNode && - pRootBoundNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode; - pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { - pDataScope = pRootBoundNode->GetBindData(); - if (pDataScope) { - break; - } - } - if (!pDataScope) { - pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); - ASSERT(pDataScope); - } - CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer( - pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge); - if (pInstance) { - pDocument->DataMerge_UpdateBindingRelations(pInstance); - pFormParent->RemoveChild(pInstance); - } - return pInstance; -} -void CXFA_Node::Script_InstanceManager_Count(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - int32_t iDesired = FXJSE_Value_ToInteger(hValue); - InstanceManager_SetInstances(iDesired); - } else { - FXJSE_Value_SetInteger(hValue, XFA_ScriptInstanceManager_GetCount(this)); - } -} -void CXFA_Node::Script_InstanceManager_MoveInstance( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc != 2) { - FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); - return; - } - int32_t iFrom = pArguments->GetInt32(0); - int32_t iTo = pArguments->GetInt32(1); - InstanceManager_MoveInstance(iTo, iFrom); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); - if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { - pNotify->RunSubformIndexChange(pToInstance); - } - CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); - if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { - pNotify->RunSubformIndexChange(pFromInstance); - } -} -void CXFA_Node::Script_InstanceManager_RemoveInstance( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc != 1) { - FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); - return; - } - int32_t iIndex = pArguments->GetInt32(0); - int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); - if (iIndex < 0 || iIndex >= iCount) { - ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); - return; - } - CXFA_Occur nodeOccur(GetOccurNode()); - int32_t iMin = nodeOccur.GetMin(); - if (iCount - 1 < iMin) { - ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"min"); - return; - } - CXFA_Node* pRemoveInstance = XFA_ScriptInstanceManager_GetItem(this, iIndex); - XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - for (int32_t i = iIndex; i < iCount - 1; i++) { - CXFA_Node* pSubformInstance = XFA_ScriptInstanceManager_GetItem(this, i); - if (pSubformInstance && - pSubformInstance->GetClassID() == XFA_ELEMENT_Subform) { - pNotify->RunSubformIndexChange(pSubformInstance); - } - } - } - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (!pLayoutPro) { - return; - } - pLayoutPro->AddChangedContainer( - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); -} -void CXFA_Node::Script_InstanceManager_SetInstances( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc != 1) { - FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); - return; - } - int32_t iDesired = pArguments->GetInt32(0); - InstanceManager_SetInstances(iDesired); -} -void CXFA_Node::Script_InstanceManager_AddInstance( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc != 0) && (argc != 1)) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); - return; - } - FX_BOOL fFlags = TRUE; - if (argc == 1) { - fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; - } - int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); - CXFA_Occur nodeOccur(GetOccurNode()); - int32_t iMax = nodeOccur.GetMax(); - if (iMax >= 0 && iCount >= iMax) { - ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); - return; - } - CXFA_Node* pNewInstance = - XFA_ScriptInstanceManager_CreateInstance(this, fFlags); - XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, - FALSE); - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->RunNodeInitialize(pNewInstance); - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (!pLayoutPro) { - return; - } - pLayoutPro->AddChangedContainer( - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); -} -void CXFA_Node::Script_InstanceManager_InsertInstance( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc != 1) && (argc != 2)) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"insertInstance"); - return; - } - int32_t iIndex = pArguments->GetInt32(0); - FX_BOOL bBind = FALSE; - if (argc == 2) { - bBind = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - } - CXFA_Occur nodeOccur(GetOccurNode()); - int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); - if (iIndex < 0 || iIndex > iCount) { - ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); - return; - } - int32_t iMax = nodeOccur.GetMax(); - if (iMax >= 0 && iCount >= iMax) { - ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); - return; - } - CXFA_Node* pNewInstance = - XFA_ScriptInstanceManager_CreateInstance(this, bBind); - XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, - TRUE); - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->RunNodeInitialize(pNewInstance); - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (!pLayoutPro) { - return; - } - pLayoutPro->AddChangedContainer( - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); -} -int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) { - CXFA_Occur nodeOccur(GetOccurNode()); - int32_t iMax = nodeOccur.GetMax(); - int32_t iMin = nodeOccur.GetMin(); - if (iDesired < iMin) { - ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"min"); - return 1; - } - if ((iMax >= 0) && (iDesired > iMax)) { - ThrowScriptErrorMessage(XFA_IDS_VIOLATE_BOUNDARY, L"max"); - return 2; - } - int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); - if (iDesired == iCount) { - return 0; - } - if (iDesired < iCount) { - CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name); - CFX_WideString wsInstanceName = wsInstManagerName.IsEmpty() - ? wsInstManagerName - : wsInstManagerName.Mid(1); - FX_DWORD dInstanceNameHash = - wsInstanceName.IsEmpty() ? 0 : FX_HashCode_String_GetW( - wsInstanceName, - wsInstanceName.GetLength()); - CXFA_Node* pPrevSibling = - (iDesired == 0) ? this - : XFA_ScriptInstanceManager_GetItem(this, iDesired - 1); - while (iCount > iDesired) { - CXFA_Node* pRemoveInstance = - pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling); - if (pRemoveInstance->GetClassID() != XFA_ELEMENT_Subform && - pRemoveInstance->GetClassID() != XFA_ELEMENT_SubformSet) { - continue; - } - if (pRemoveInstance->GetClassID() == XFA_ELEMENT_InstanceManager) { - FXSYS_assert(FALSE); - break; - } - if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { - XFA_ScriptInstanceManager_RemoveItem(this, pRemoveInstance); - iCount--; - } - } - } else if (iDesired > iCount) { - while (iCount < iDesired) { - CXFA_Node* pNewInstance = - XFA_ScriptInstanceManager_CreateInstance(this, TRUE); - XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, - FALSE); - iCount++; - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return 0; - } - pNotify->RunNodeInitialize(pNewInstance); - } - } - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (pLayoutPro) { - pLayoutPro->AddChangedContainer( - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); - } - return 0; -} -int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { - int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); - if (iFrom > iCount || iTo > iCount - 1) { - ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); - return 1; - } - if (iFrom < 0 || iTo < 0 || iFrom == iTo) { - return 0; - } - CXFA_Node* pMoveInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); - XFA_ScriptInstanceManager_RemoveItem(this, pMoveInstance, FALSE); - XFA_ScriptInstanceManager_InsertItem(this, pMoveInstance, iTo, iCount - 1, - TRUE); - CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); - if (pLayoutPro) { - pLayoutPro->AddChangedContainer( - ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); - } - return 0; -} -void CXFA_Node::Script_Occur_Max(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_Occur occur(this); - if (bSetting) { - int32_t iMax = FXJSE_Value_ToInteger(hValue); - occur.SetMax(iMax); - } else { - FXJSE_Value_SetInteger(hValue, occur.GetMax()); - } -} -void CXFA_Node::Script_Occur_Min(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - CXFA_Occur occur(this); - if (bSetting) { - int32_t iMin = FXJSE_Value_ToInteger(hValue); - occur.SetMin(iMin); - } else { - FXJSE_Value_SetInteger(hValue, occur.GetMin()); - } -} -void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if ((argc == 0) || (argc == 1)) { - FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); - } -} -void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - if (pDataNode) { - CXFA_NodeArray formItems; - CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); - pFormNodes->SetArrayNodeList(formItems); - FXJSE_Value_SetObject( - pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, - m_pDocument->GetScriptContext()->GetJseNormalClass()); - } else { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); - } -} -void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - m_pDocument->DoDataRemerge(TRUE); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); - } -} -void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execInitialize"); - } -} -void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { - CXFA_EventParam* pEventParam = - m_pDocument->GetScriptContext()->GetEventParam(); - if (pEventParam->m_eType == XFA_EVENT_Calculate || - pEventParam->m_eType == XFA_EVENT_InitCalculate) { - return; - } - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - const bool bScriptFlags = pArguments->GetInt32(0) != 0; - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bScriptFlags) { - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, TRUE); - } else { - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); - } -} -void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execCalculate"); - } -} -void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); - } else { - int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); - FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), - ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"execValidate"); - } -} -void CXFA_Node::Script_Form_Checksum(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - CFX_ByteString bsChecksum; - FXJSE_Value_ToUTF8String(hValue, bsChecksum); - SetAttribute(XFA_ATTRIBUTE_Checksum, - CFX_WideString::FromUTF8(bsChecksum, bsChecksum.GetLength())); - } else { - CFX_WideString wsChecksum; - GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); - FXJSE_Value_SetUTF8String( - hValue, FX_UTF8Encode(wsChecksum, wsChecksum.GetLength())); - } -} -void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); - CFX_WideString wsAttributeValue; - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLNode) - ->GetString(CFX_WideString::FromUTF8(bsAttributeName, - bsAttributeName.GetLength()), - wsAttributeValue); - } - FXJSE_Value_SetUTF8String( - pArguments->GetReturnValue(), - FX_UTF8Encode(wsAttributeValue, wsAttributeValue.GetLength())); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"getAttribute"); - } -} -void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 2) { - CFX_ByteString bsValue = pArguments->GetUTF8String(0); - CFX_ByteString bsName = pArguments->GetUTF8String(1); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLNode) - ->SetString(CFX_WideString::FromUTF8(bsName, bsName.GetLength()), - CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); - } - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"setAttribute"); - } -} -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()); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - if (pXMLElement->HasAttribute(wsName)) { - pXMLElement->RemoveAttribute(wsName); - } - } - FXJSE_Value_SetNull(pArguments->GetReturnValue()); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"removeAttribute"); - } -} -void CXFA_Node::Script_Packet_Content(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - CFX_ByteString bsNewContent; - FXJSE_Value_ToUTF8String(hValue, bsNewContent); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - pXMLElement->SetTextData( - CFX_WideString::FromUTF8(bsNewContent, bsNewContent.GetLength())); - } - } else { - CFX_WideString wsTextData; - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - pXMLElement->GetTextData(wsTextData); - } - FXJSE_Value_SetUTF8String( - hValue, FX_UTF8Encode(wsTextData, wsTextData.GetLength())); - } -} -void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); - } -} -void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancelBatch"); - } -} -void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"first"); - } -} -void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"updateBatch"); - } -} -void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"previous"); - } -} -void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isBOF"); - } -} -void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isEOF"); - } -} -void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancel"); - } -} -void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"update"); - } -} -void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"open"); - } -} -void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"delete"); - } -} -void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addNew"); - } -} -void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"requery"); - } -} -void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resync"); - } -} -void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"close"); - } -} -void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"last"); - } -} -void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 0) { - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"hasDataChanged"); - } -} -void CXFA_Node::Script_Source_Db(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Xfa_This(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); - FXSYS_assert(pThis); - FXJSE_Value_Set(hValue, - m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); - } -} -void CXFA_Node::Script_Handler_Version(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_SubmitFormat_Mode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Extras_Type(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CXFA_Node::Script_Script_Stateless(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(FX_WSTRC(L"0"))); -} -void CXFA_Node::Script_Encrypt_Format(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -enum XFA_KEYTYPE { - XFA_KEYTYPE_Custom, - XFA_KEYTYPE_Element, -}; -void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { - FX_DWORD dwKey = FX_HashCode_String_GetW(wsKey.GetPtr(), wsKey.GetLength()); - return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); -} -void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) { - return (void*)(uintptr_t)((eElement << 16) | (eAttribute << 8) | - XFA_KEYTYPE_Element); -} -FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - return HasMapModuleKey(pKey, bCanInherit); -} -FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr, - const CFX_WideStringC& wsValue, - FX_BOOL bNotify) { - const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); - if (pAttr == NULL) { - return FALSE; - } - XFA_ATTRIBUTETYPE eType = pAttr->eType; - if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { - const XFA_NOTSUREATTRIBUTE* pNotsure = - XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); - eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; - } - switch (eType) { - case XFA_ATTRIBUTETYPE_Enum: { - const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue); - return SetEnum(pAttr->eName, - pEnum ? pEnum->eName - : (XFA_ATTRIBUTEENUM)(intptr_t)(pAttr->pDefValue), - bNotify); - } break; - case XFA_ATTRIBUTETYPE_Cdata: - return SetCData(pAttr->eName, 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.GetPtr(), wsValue.GetLength())), - bNotify); - case XFA_ATTRIBUTETYPE_Measure: - return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify); - default: - break; - } - return FALSE; -} -FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr, - CFX_WideString& wsValue, - FX_BOOL bUseDefault) { - const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr); - if (pAttr == NULL) { - return FALSE; - } - XFA_ATTRIBUTETYPE eType = pAttr->eType; - if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { - const XFA_NOTSUREATTRIBUTE* pNotsure = - XFA_GetNotsureAttribute(GetClassID(), pAttr->eName); - eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; - } - switch (eType) { - case XFA_ATTRIBUTETYPE_Enum: { - XFA_ATTRIBUTEENUM eValue; - if (!TryEnum(pAttr->eName, eValue, bUseDefault)) { - return FALSE; - } - wsValue = XFA_GetAttributeEnumByID(eValue)->pName; - return TRUE; - } break; - case XFA_ATTRIBUTETYPE_Cdata: { - CFX_WideStringC wsValueC; - if (!TryCData(pAttr->eName, wsValueC, bUseDefault)) { - return FALSE; - } - wsValue = wsValueC; - return TRUE; - } break; - case XFA_ATTRIBUTETYPE_Boolean: { - FX_BOOL bValue; - if (!TryBoolean(pAttr->eName, bValue, bUseDefault)) { - return FALSE; - } - wsValue = bValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0"); - return TRUE; - } break; - case XFA_ATTRIBUTETYPE_Integer: { - int32_t iValue; - if (!TryInteger(pAttr->eName, iValue, bUseDefault)) { - return FALSE; - } - wsValue.Format(L"%d", iValue); - return TRUE; - } break; - case XFA_ATTRIBUTETYPE_Measure: { - CXFA_Measurement mValue; - if (!TryMeasure(pAttr->eName, mValue, bUseDefault)) { - return FALSE; - } - mValue.ToString(wsValue); - return TRUE; - } break; - default: - break; - } - return FALSE; -} -FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr, - const CFX_WideStringC& wsValue, - FX_BOOL bNotify) { - const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue); - if (pAttributeInfo) { - return SetAttribute(pAttributeInfo->eName, wsValue, bNotify); - } - void* pKey = XFA_GetMapKey_Custom(wsAttr); - SetMapModuleString(pKey, wsValue); - return TRUE; -} -FX_BOOL CXFA_Node::GetAttribute(const CFX_WideStringC& wsAttr, - CFX_WideString& wsValue, - FX_BOOL bUseDefault) { - const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr); - if (pAttributeInfo) { - return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault); - } - void* pKey = XFA_GetMapKey_Custom(wsAttr); - CFX_WideStringC wsValueC; - if (GetMapModuleString(pKey, wsValueC)) { - wsValue = wsValueC; - } - return TRUE; -} -FX_BOOL CXFA_Node::RemoveAttribute(const CFX_WideStringC& wsAttr) { - void* pKey = XFA_GetMapKey_Custom(wsAttr); - RemoveMapModuleKey(pKey); - return TRUE; -} -FX_BOOL CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr, - FX_BOOL& bValue, - FX_BOOL bUseDefault) { - void* pValue = NULL; - if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue)) { - return FALSE; - } - bValue = (FX_BOOL)(uintptr_t)pValue; - return TRUE; -} -FX_BOOL CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr, - int32_t& iValue, - FX_BOOL bUseDefault) { - void* pValue = NULL; - if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue)) { - return FALSE; - } - iValue = (int32_t)(uintptr_t)pValue; - return TRUE; -} -FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTEENUM& eValue, - FX_BOOL bUseDefault) { - void* pValue = NULL; - if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue)) { - return FALSE; - } - eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue; - return TRUE; -} -FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement mValue, - FX_BOOL bNotify) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - OnChanging(eAttr, &mValue, bNotify); - SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); - OnChanged(eAttr, &mValue, bNotify); - return TRUE; -} -FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement& mValue, - FX_BOOL bUseDefault) const { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - void* pValue; - int32_t iBytes; - if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) { - FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); - return TRUE; - } - if (bUseDefault && - XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, - XFA_ATTRIBUTETYPE_Measure, m_ePacket)) { - FXSYS_memcpy(&mValue, pValue, sizeof(mValue)); - return TRUE; - } - return FALSE; -} - -CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const { - CXFA_Measurement mValue; - return TryMeasure(eAttr, mValue, TRUE) ? mValue : CXFA_Measurement(); -} - -FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, - const CFX_WideString& wsValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - OnChanging(eAttr, (void*)(const FX_WCHAR*)wsValue, bNotify); - if (eAttr == XFA_ATTRIBUTE_Value) { - CFX_WideString* pClone = new CFX_WideString(wsValue); - SetUserData(pKey, pClone, &deleteWideStringCallBack); - } else { - SetMapModuleString(pKey, wsValue); - 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()) { - ((IFDE_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; - } - } - } - if (bDeleteChildren) { - ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); - } - ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsValue); - } - break; - case FDE_XMLNODE_Text: - ((IFDE_XMLText*)m_pXMLNode)->SetText(wsValue); - break; - default: - FXSYS_assert(0); - } - return TRUE; - } - 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; - } - ((IFDE_XMLElement*)m_pXMLNode)->SetString(wsAttrName, wsValue); - } - } - return TRUE; -} -FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, - const CFX_WideString& wsXMLValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); - OnChanging(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify); - CFX_WideString* pClone = new CFX_WideString(wsValue); - SetUserData(pKey, pClone, &deleteWideStringCallBack); - OnChanged(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify, - bScriptModify); - if (IsNeedSavingXMLNode()) { - FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); - switch (eXMLType) { - case FDE_XMLNODE_Element: - if (IsAttributeInXML()) { - ((IFDE_XMLElement*)m_pXMLNode) - ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); - } 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) { - ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); - } - ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsXMLValue); - } - break; - case FDE_XMLNODE_Text: - ((IFDE_XMLText*)m_pXMLNode)->SetText(wsXMLValue); - break; - default: - FXSYS_assert(0); - } - } - return TRUE; -} -FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideString& wsValue, - FX_BOOL bUseDefault, - FX_BOOL bProto) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - if (eAttr == XFA_ATTRIBUTE_Value) { - CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); - if (pStr) { - wsValue = *pStr; - return TRUE; - } - } else { - CFX_WideStringC wsValueC; - if (GetMapModuleString(pKey, wsValueC)) { - wsValue = wsValueC; - return TRUE; - } - } - if (!bUseDefault) { - return FALSE; - } - void* pValue = NULL; - if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, - XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { - wsValue = (const FX_WCHAR*)pValue; - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideStringC& wsValue, - FX_BOOL bUseDefault, - FX_BOOL bProto) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - if (eAttr == XFA_ATTRIBUTE_Value) { - CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto); - if (pStr) { - wsValue = *pStr; - return TRUE; - } - } else { - if (GetMapModuleString(pKey, wsValue)) { - return TRUE; - } - } - if (!bUseDefault) { - return FALSE; - } - void* pValue = NULL; - if (XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, - XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) { - wsValue = (CFX_WideStringC)(const FX_WCHAR*)pValue; - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - return SetUserData(pKey, pData, pCallbackInfo); -} -FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - pData = GetUserData(pKey); - return pData != NULL; -} -FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTETYPE eType, - void* pValue, - FX_BOOL bNotify) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - OnChanging(eAttr, pValue, bNotify); - SetMapModuleValue(pKey, pValue); - OnChanged(eAttr, pValue, bNotify); - if (IsNeedSavingXMLNode()) { - FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); - const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); - if (pInfo) { - switch (eType) { - case XFA_ATTRIBUTETYPE_Enum: - ((IFDE_XMLElement*)m_pXMLNode) - ->SetString( - pInfo->pName, - XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) - ->pName); - break; - case XFA_ATTRIBUTETYPE_Boolean: - ((IFDE_XMLElement*)m_pXMLNode) - ->SetString(pInfo->pName, - pValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0")); - break; - case XFA_ATTRIBUTETYPE_Integer: - ((IFDE_XMLElement*)m_pXMLNode) - ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); - break; - default: - FXSYS_assert(0); - } - } - } - return TRUE; -} -FX_BOOL CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTETYPE eType, - FX_BOOL bUseDefault, - void*& pValue) { - void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); - if (GetMapModuleValue(pKey, pValue)) { - return TRUE; - } - if (!bUseDefault) { - return FALSE; - } - return XFA_GetAttributeDefaultValue(pValue, GetClassID(), eAttr, eType, - m_ePacket); -} -static void XFA_DefaultFreeData(void* pData) {} -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = { - XFA_DefaultFreeData, NULL}; -FX_BOOL CXFA_Node::SetUserData(void* pKey, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { - SetMapModuleBuffer(pKey, &pData, sizeof(void*), - pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData); - return TRUE; -} -FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) { - int32_t iBytes = 0; - if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) { - return FALSE; - } - return iBytes == sizeof(void*) && FXSYS_memcpy(&pData, pData, iBytes); -} -FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, - const CFX_WideString& wsXMLValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify, - FX_BOOL bSyncData) { - CXFA_Node* pNode = NULL; - CXFA_Node* pBindNode = NULL; - switch (GetObjectType()) { - case XFA_OBJECTTYPE_ContainerNode: { - 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")); - pChildValue->SetScriptContent(wsContent, wsContent, bNotify, - bScriptModify, FALSE); - CXFA_Node* pBind = GetBindData(); - if (bSyncData && pBind) { - CFX_WideStringArray wsSaveTextArray; - int32_t iSize = 0; - if (!wsContent.IsEmpty()) { - int32_t iStart = 0; - int32_t iLength = wsContent.GetLength(); - int32_t iEnd = wsContent.Find(L'\n', iStart); - iEnd = (iEnd == -1) ? iLength : iEnd; - while (iEnd >= iStart) { - wsSaveTextArray.Add(wsContent.Mid(iStart, iEnd - iStart)); - iStart = iEnd + 1; - if (iStart >= iLength) { - break; - } - iEnd = wsContent.Find(L'\n', iStart); - if (iEnd < 0) { - wsSaveTextArray.Add(wsContent.Mid(iStart, iLength - iStart)); - } - } - iSize = wsSaveTextArray.GetSize(); - } - if (iSize == 0) { - while (CXFA_Node* pChildNode = - pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { - pBind->RemoveChild(pChildNode); - } - } else { - CXFA_NodeArray valueNodes; - int32_t iDatas = pBind->GetNodeList( - valueNodes, XFA_NODEFILTER_Children, XFA_ELEMENT_DataValue); - if (iDatas < iSize) { - int32_t iAddNodes = iSize - iDatas; - CXFA_Node* pValueNodes = NULL; - while (iAddNodes-- > 0) { - pValueNodes = - pBind->CreateSamePacketNode(XFA_ELEMENT_DataValue); - pValueNodes->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value")); - pValueNodes->CreateXMLMappingNode(); - pBind->InsertChild(pValueNodes); - } - pValueNodes = NULL; - } else if (iDatas > iSize) { - int32_t iDelNodes = iDatas - iSize; - while (iDelNodes-- > 0) { - pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild)); - } - } - int32_t i = 0; - for (CXFA_Node* pValueNode = - pBind->GetNodeItem(XFA_NODEITEM_FirstChild); - pValueNode; pValueNode = pValueNode->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - pValueNode->SetAttributeValue(wsSaveTextArray[i], - wsSaveTextArray[i], FALSE); - i++; - } - } - CXFA_NodeArray nodeArray; - pBind->GetBindItems(nodeArray); - for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - if (pNode == this) { - continue; - } - pNode->SetScriptContent(wsContent, wsContent, bNotify, - bScriptModify, FALSE); - } - } - break; - } else if (GetClassID() == XFA_ELEMENT_ExclGroup) { - pNode = this; - } else { - CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value); - CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); - FXSYS_assert(pChildValue); - pChildValue->SetScriptContent(wsContent, wsContent, bNotify, - bScriptModify, FALSE); - } - pBindNode = GetBindData(); - if (pBindNode && bSyncData) { - pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, - bScriptModify, FALSE); - CXFA_NodeArray nodeArray; - pBindNode->GetBindItems(nodeArray); - for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - if (pNode == this) { - continue; - } - pNode->SetScriptContent(wsContent, wsContent, bNotify, TRUE, FALSE); - } - } - pBindNode = NULL; - break; - } - case XFA_OBJECTTYPE_ContentNode: { - CFX_WideString wsContentType; - if (GetClassID() == XFA_ELEMENT_ExData) { - GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - wsContentType = FX_WSTRC(L""); - SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType); - } - } - CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pContentRawDataNode) { - pContentRawDataNode = - CreateSamePacketNode((wsContentType.Equal(FX_WSTRC(L"text/xml"))) - ? XFA_ELEMENT_Sharpxml - : XFA_ELEMENT_Sharptext); - InsertChild(pContentRawDataNode); - } - return pContentRawDataNode->SetScriptContent( - wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); - } break; - case XFA_OBJECTTYPE_NodeC: - case XFA_OBJECTTYPE_TextNode: - pNode = this; - break; - case XFA_OBJECTTYPE_NodeV: - pNode = this; - if (bSyncData && GetPacketID() == XFA_XDPPACKET_Form) { - CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { - pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); - } - if (pParent && pParent->GetClassID() == XFA_ELEMENT_Value) { - pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); - if (pParent && pParent->IsContainerNode()) { - pBindNode = pParent->GetBindData(); - if (pBindNode) { - pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify, - bScriptModify, FALSE); - } - } - } - } - break; - default: - if (GetClassID() == XFA_ELEMENT_DataValue) { - pNode = this; - pBindNode = this; - } - break; - } - if (pNode) { - SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); - if (pBindNode && bSyncData) { - CXFA_NodeArray nodeArray; - pBindNode->GetBindItems(nodeArray); - for (int32_t i = 0; i < nodeArray.GetSize(); i++) { - CXFA_Node* pNode = nodeArray[i]; - pNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, - FALSE); - } - } - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent, - const CFX_WideString& wsXMLValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify, - FX_BOOL bSyncData) { - return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, - bSyncData); -} -CFX_WideString CXFA_Node::GetScriptContent(FX_BOOL bScriptModify) { - CFX_WideString wsContent; - return TryContent(wsContent, bScriptModify) ? wsContent : CFX_WideString(); -} -CFX_WideString CXFA_Node::GetContent() { - return GetScriptContent(); -} -FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, - FX_BOOL bScriptModify, - FX_BOOL bProto) { - CXFA_Node* pNode = NULL; - switch (GetObjectType()) { - case XFA_OBJECTTYPE_ContainerNode: - if (GetClassID() == XFA_ELEMENT_ExclGroup) { - pNode = this; - } else { - CXFA_Node* pValue = GetChild(0, XFA_ELEMENT_Value); - if (!pValue) { - return FALSE; - } - CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildValue && XFA_FieldIsMultiListBox(this)) { - pChildValue->SetAttribute(XFA_ATTRIBUTE_ContentType, - FX_WSTRC(L"text/xml")); - } - return pChildValue - ? pChildValue->TryContent(wsContent, bScriptModify, bProto) - : FALSE; - } - break; - case XFA_OBJECTTYPE_ContentNode: { - CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pContentRawDataNode) { - XFA_ELEMENT element = XFA_ELEMENT_Sharptext; - if (GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideString wsContentType; - GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { - element = XFA_ELEMENT_SharpxHTML; - } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { - element = XFA_ELEMENT_Sharpxml; - } - } - pContentRawDataNode = CreateSamePacketNode(element); - InsertChild(pContentRawDataNode); - } - return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto); - } - case XFA_OBJECTTYPE_NodeC: - case XFA_OBJECTTYPE_NodeV: - case XFA_OBJECTTYPE_TextNode: - pNode = this; - default: - if (GetClassID() == XFA_ELEMENT_DataValue) { - pNode = this; - } - break; - } - if (pNode) { - if (bScriptModify) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (pScriptContext) { - m_pDocument->GetScriptContext()->AddNodesOfRunScript(this); - } - } - return TryCData(XFA_ATTRIBUTE_Value, wsContent, FALSE, bProto); - } - return FALSE; -} -CXFA_Node* CXFA_Node::GetModelNode() { - switch (GetPacketID()) { - case XFA_XDPPACKET_XDP: - return m_pDocument->GetRoot(); - case XFA_XDPPACKET_Config: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); - case XFA_XDPPACKET_Template: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); - case XFA_XDPPACKET_Form: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); - case XFA_XDPPACKET_Datasets: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); - case XFA_XDPPACKET_LocaleSet: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet)); - case XFA_XDPPACKET_ConnectionSet: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet)); - case XFA_XDPPACKET_SourceSet: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet)); - case XFA_XDPPACKET_Xdc: - return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc)); - default: - return this; - } -} -FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { - wsNamespace.Empty(); - if (GetObjectType() == XFA_OBJECTTYPE_ModelNode || - GetClassID() == XFA_ELEMENT_Packet) { - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { - return FALSE; - } - ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); - return TRUE; - } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (!pXMLNode) { - return FALSE; - } - if (pXMLNode->GetType() != FDE_XMLNODE_Element) { - return TRUE; - } - if (GetClassID() == XFA_ELEMENT_DataValue && - GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { - return XFA_FDEExtension_ResolveNamespaceQualifier( - (IFDE_XMLElement*)pXMLNode, GetCData(XFA_ATTRIBUTE_QualifiedName), - wsNamespace); - } - ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); - return TRUE; - } else { - CXFA_Node* pModelNode = GetModelNode(); - return pModelNode->TryNamespace(wsNamespace); - } -} -CXFA_Node* CXFA_Node::GetProperty(int32_t index, - XFA_ELEMENT eProperty, - FX_BOOL bCreateProperty) { - XFA_ELEMENT eElement = GetClassID(); - FX_DWORD dwPacket = GetPacketID(); - const XFA_PROPERTY* pProperty = - XFA_GetPropertyOfElement(eElement, eProperty, dwPacket); - if (pProperty == NULL || index >= pProperty->uOccur) { - return NULL; - } - CXFA_Node* pNode = m_pChild; - int32_t iCount = 0; - for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetClassID() == eProperty) { - iCount++; - if (iCount > index) { - return pNode; - } - } - } - if (!bCreateProperty) { - return NULL; - } - if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { - pNode = m_pChild; - for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - const XFA_PROPERTY* pExistProperty = - XFA_GetPropertyOfElement(eElement, pNode->GetClassID(), dwPacket); - if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { - return NULL; - } - } - } - IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); - const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); - CXFA_Node* pNewNode; - for (; iCount <= index; iCount++) { - pNewNode = pFactory->CreateNode(pPacket, eProperty); - if (!pNewNode) { - return NULL; - } - InsertChild(pNewNode, nullptr); - pNewNode->SetFlag(XFA_NODEFLAG_Initialized); - } - return pNewNode; -} -int32_t CXFA_Node::CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild) { - CXFA_Node* pNode = m_pChild; - int32_t iCount = 0; - for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { - if (bOnlyChild) { - const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( - GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); - if (pProperty) { - continue; - } - } - iCount++; - } - } - return iCount; -} -CXFA_Node* CXFA_Node::GetChild(int32_t index, - XFA_ELEMENT eElement, - FX_BOOL bOnlyChild) { - FXSYS_assert(index > -1); - CXFA_Node* pNode = m_pChild; - int32_t iCount = 0; - for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetClassID() == eElement || eElement == XFA_ELEMENT_UNKNOWN) { - if (bOnlyChild) { - const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( - GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); - if (pProperty) { - continue; - } - } - iCount++; - if (iCount > index) { - return pNode; - } - } - } - return NULL; -} -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); - - if (m_pChild == NULL || index == 0) { - if (index > 0) { - return -1; - } - pNode->m_pNext = m_pChild; - m_pChild = pNode; - index = 0; - } else if (index < 0) { - m_pLastChild->m_pNext = pNode; - } else { - CXFA_Node* pPrev = m_pChild; - int32_t iCount = 0; - while (++iCount != index && pPrev->m_pNext) { - pPrev = pPrev->m_pNext; - } - if (index > 0 && index != iCount) { - return -1; - } - pNode->m_pNext = pPrev->m_pNext; - pPrev->m_pNext = pNode; - index = iCount; - } - if (pNode->m_pNext == NULL) { - m_pLastChild = pNode; - } - ASSERT(m_pLastChild); - ASSERT(m_pLastChild->m_pNext == NULL); - pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); - } - if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); - m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); - pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); - } - 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); - return FALSE; - } - FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode); - if (!bWasPurgeNode) - FXSYS_assert(false); - - int32_t nIndex = -1; - pNode->m_pParent = this; - if (m_pChild == NULL || pBeforeNode == m_pChild) { - pNode->m_pNext = m_pChild; - m_pChild = pNode; - nIndex = 0; - } else if (!pBeforeNode) { - pNode->m_pNext = m_pLastChild->m_pNext; - m_pLastChild->m_pNext = pNode; - } else { - nIndex = 1; - CXFA_Node* pPrev = m_pChild; - while (pPrev->m_pNext != pBeforeNode) { - pPrev = pPrev->m_pNext; - nIndex++; - } - pNode->m_pNext = pPrev->m_pNext; - pPrev->m_pNext = pNode; - } - if (pNode->m_pNext == NULL) { - m_pLastChild = pNode; - } - ASSERT(m_pLastChild); - ASSERT(m_pLastChild->m_pNext == NULL); - pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); - } - if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); - m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); - pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); - } - return TRUE; -} -CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { - if (!m_pParent) { - return NULL; - } - for (CXFA_Node* pSibling = m_pParent->m_pChild; pSibling; - pSibling = pSibling->m_pNext) { - if (pSibling->m_pNext == this) { - return pSibling; - } - } - return NULL; -} -FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) { - if (pNode == NULL || pNode->m_pParent != this) { - FXSYS_assert(FALSE); - return FALSE; - } - if (m_pChild == pNode) { - m_pChild = pNode->m_pNext; - if (m_pLastChild == pNode) { - m_pLastChild = pNode->m_pNext; - } - pNode->m_pNext = NULL; - pNode->m_pParent = NULL; - } else { - CXFA_Node* pPrev = pNode->Deprecated_GetPrevSibling(); - pPrev->m_pNext = pNode->m_pNext; - if (m_pLastChild == pNode) { - m_pLastChild = pNode->m_pNext ? pNode->m_pNext : pPrev; - } - pNode->m_pNext = NULL; - pNode->m_pParent = NULL; - } - ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL); - OnRemoved(this, pNode, bNotify); - pNode->SetFlag(XFA_NODEFLAG_HasRemoved); - 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); - if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)(pNode->m_pXMLNode); - CFX_WideStringC wsAttributeName = - pNode->GetCData(XFA_ATTRIBUTE_QualifiedName); - pXMLElement->RemoveAttribute(wsAttributeName.GetPtr()); - } - CFX_WideString wsName; - pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - IFDE_XMLElement* pNewXMLElement = IFDE_XMLElement::Create(wsName); - CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); - if (!wsValue.IsEmpty()) { - pNewXMLElement->SetTextData(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); - } - return TRUE; -} -CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const { - return GetFirstChildByName( - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), - wsName.GetLength())); -} -CXFA_Node* CXFA_Node::GetFirstChildByName(FX_DWORD dwNameHash) const { - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetNameHash() == dwNameHash) { - return pNode; - } - } - return NULL; -} -CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_ELEMENT eElement) const { - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetClassID() == eElement) { - return pNode; - } - } - return NULL; -} -CXFA_Node* CXFA_Node::GetNextSameNameSibling(FX_DWORD dwNameHash) const { - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetNameHash() == dwNameHash) { - return pNode; - } - } - return NULL; -} -CXFA_Node* CXFA_Node::GetNextSameNameSibling( - const CFX_WideStringC& wsNodeName) const { - return GetNextSameNameSibling( - wsNodeName.IsEmpty() ? 0 - : FX_HashCode_String_GetW(wsNodeName.GetPtr(), - wsNodeName.GetLength())); -} -CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const { - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetClassID() == eElement) { - return pNode; - } - } - return NULL; -} -int32_t CXFA_Node::GetNodeSameNameIndex() const { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return -1; - } - return pScriptContext->GetIndexByName(const_cast<CXFA_Node*>(this)); -} -int32_t CXFA_Node::GetNodeSameClassIndex() const { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return -1; - } - return pScriptContext->GetIndexByClassName(const_cast<CXFA_Node*>(this)); -} -void CXFA_Node::GetSOMExpression(CFX_WideString& wsSOMExpression) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - pScriptContext->GetSomExpression(this, wsSOMExpression); -} -CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { - CXFA_Node* pInstanceMgr = NULL; - if (m_ePacket == XFA_XDPPACKET_Form) { - CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); - if (!pParentNode || pParentNode->GetClassID() == XFA_ELEMENT_Area) { - return pInstanceMgr; - } - for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { - XFA_ELEMENT eType = pNode->GetClassID(); - if ((eType == XFA_ELEMENT_Subform || eType == XFA_ELEMENT_SubformSet) && - pNode->m_dwNameHash != m_dwNameHash) { - break; - } - if (eType == XFA_ELEMENT_InstanceManager) { - CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); - CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' && - wsInstName.Mid(1) == wsName) { - pInstanceMgr = pNode; - } - break; - } - } - } - return pInstanceMgr; -} -CXFA_Node* CXFA_Node::GetOccurNode() { - return GetFirstChildByClass(XFA_ELEMENT_Occur); -} -FX_BOOL CXFA_Node::HasFlag(FX_DWORD dwFlag) const { - if (m_uFlags & dwFlag) { - return TRUE; - } - switch (dwFlag) { - case XFA_NODEFLAG_HasRemoved: - return m_pParent && m_pParent->HasFlag(dwFlag); - default: - break; - } - return FALSE; -} -void CXFA_Node::SetFlag(FX_DWORD dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { - if (bOn) { - switch (dwFlag) { - case XFA_NODEFLAG_Initialized: - if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready); - } - } - break; - default: - break; - } - m_uFlags |= dwFlag; - } else { - 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) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - pNotify->OnNodeEvent(pParent, XFA_NODEEVENT_ChildRemoved, pRemoved); - } - } -} -void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, - void* pNewValue, - FX_BOOL bNotify) { - if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (pNotify) { - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanging, - (void*)(uintptr_t)eAttr, pNewValue); - } - } -} -void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, - void* pNewValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify) { - if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { - Script_Attribute_SendAttributeChangeMessage((void*)(uintptr_t)eAttr, - pNewValue, bScriptModify); - } -} -int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, - XFA_ELEMENT eElementType) { - int32_t iRet = XFA_EVENTERROR_NotExist; - const XFA_ExecEventParaInfo* eventParaInfo = - GetEventParaInfoByName(wsEventName); - if (eventParaInfo) { - uint32_t validFlags = eventParaInfo->m_validFlags; - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return iRet; - } - if (validFlags == 1) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType); - } else if (validFlags == 2) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } else if (validFlags == 3) { - if (eElementType == XFA_ELEMENT_Subform) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - } else if (validFlags == 4) { - if (eElementType == XFA_ELEMENT_ExclGroup || - eElementType == XFA_ELEMENT_Field) { - CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); - if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_ExclGroup) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - } else if (validFlags == 5) { - if (eElementType == XFA_ELEMENT_Field) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - } else if (validFlags == 6) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (pWidgetData) { - CXFA_Node* pUINode = pWidgetData->GetUIChild(); - if (pUINode->m_eNodeClass == XFA_ELEMENT_Signature) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - } - } else if (validFlags == 7) { - CXFA_WidgetData* pWidgetData = GetWidgetData(); - if (pWidgetData) { - CXFA_Node* pUINode = pWidgetData->GetUIChild(); - if ((pUINode->m_eNodeClass == XFA_ELEMENT_ChoiceList) && - (!pWidgetData->IsListBox())) { - iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, - FALSE, FALSE); - } - } - } - } - return iRet; -} -void CXFA_Node::UpdateNameHash() { - const XFA_NOTSUREATTRIBUTE* pNotsure = - XFA_GetNotsureAttribute(GetClassID(), XFA_ATTRIBUTE_Name); - if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { - CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); - m_dwNameHash = - wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.GetPtr(), - wsName.GetLength()); - } 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.GetPtr(), - wsName.GetLength()); - } -} -IFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { - if (!m_pXMLNode) { - CFX_WideStringC wsTag = GetCData(XFA_ATTRIBUTE_Name); - m_pXMLNode = IFDE_XMLElement::Create(wsTag); - SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); - } - return m_pXMLNode; -} -FX_BOOL CXFA_Node::IsNeedSavingXMLNode() { - return m_pXMLNode && (GetPacketID() == XFA_XDPPACKET_Datasets || - GetClassID() == XFA_ELEMENT_Xfa); -} - -XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() { - if (!m_pMapModuleData) - m_pMapModuleData = new XFA_MAPMODULEDATA; - return m_pMapModuleData; -} - -XFA_MAPMODULEDATA* CXFA_Node::GetMapModuleData() const { - return m_pMapModuleData; -} - -void CXFA_Node::SetMapModuleValue(void* pKey, void* pValue) { - XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); - pModule->m_ValueMap.SetAt(pKey, pValue); -} - -FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) { - CXFA_Node* pNode = this; - while (pNode) { - XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); - if (pModule && pModule->m_ValueMap.Lookup(pKey, pValue)) { - return TRUE; - } - pNode = pNode->GetPacketID() != XFA_XDPPACKET_Datasets - ? pNode->GetTemplateNode() - : NULL; - } - return FALSE; -} -void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) { - SetMapModuleBuffer(pKey, (void*)wsValue.GetPtr(), - wsValue.GetLength() * sizeof(FX_WCHAR)); -} -FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) { - void* pValue; - int32_t iBytes; - if (!GetMapModuleBuffer(pKey, pValue, iBytes)) { - return FALSE; - } - wsValue = CFX_WideStringC((const FX_WCHAR*)pValue, iBytes / sizeof(FX_WCHAR)); - return TRUE; -} -void CXFA_Node::SetMapModuleBuffer( - void* pKey, - void* pValue, - int32_t iBytes, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { - XFA_MAPMODULEDATA* pModule = CreateMapModuleData(); - XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey]; - if (pBuffer == NULL) { - pBuffer = - (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes); - } else if (pBuffer->iBytes != iBytes) { - if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer, - sizeof(XFA_MAPDATABLOCK) + iBytes); - } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - if (pBuffer == NULL) { - return; - } - pBuffer->pCallbackInfo = pCallbackInfo; - pBuffer->iBytes = iBytes; - FXSYS_memcpy(pBuffer->GetData(), pValue, iBytes); -} -FX_BOOL CXFA_Node::GetMapModuleBuffer(void* pKey, - void*& pValue, - int32_t& iBytes, - FX_BOOL bProtoAlso) const { - XFA_MAPDATABLOCK* pBuffer = NULL; - const CXFA_Node* pNode = this; - while (pNode) { - XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); - if (pModule && pModule->m_BufferMap.Lookup(pKey, pBuffer)) { - break; - } - pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) - ? pNode->GetTemplateNode() - : NULL; - } - if (pBuffer == NULL) { - return FALSE; - } - pValue = pBuffer->GetData(); - iBytes = pBuffer->iBytes; - return TRUE; -} -FX_BOOL CXFA_Node::HasMapModuleKey(void* pKey, FX_BOOL bProtoAlso) { - CXFA_Node* pNode = this; - while (pNode) { - void* pVal; - XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData(); - if (pModule && - (pModule->m_ValueMap.Lookup(pKey, pVal) || - pModule->m_BufferMap.Lookup(pKey, (XFA_MAPDATABLOCK*&)pVal))) { - return TRUE; - } - pNode = (bProtoAlso && pNode->GetPacketID() != XFA_XDPPACKET_Datasets) - ? pNode->GetTemplateNode() - : NULL; - } - return FALSE; -} -void CXFA_Node::RemoveMapModuleKey(void* pKey) { - XFA_MAPMODULEDATA* pModule = GetMapModuleData(); - if (!pModule) - return; - - if (pKey) { - XFA_MAPDATABLOCK* pBuffer = NULL; - pModule->m_BufferMap.Lookup(pKey, pBuffer); - if (pBuffer) { - if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - FX_Free(pBuffer); - } - pModule->m_BufferMap.RemoveKey(pKey); - pModule->m_ValueMap.RemoveKey(pKey); - } else { - XFA_MAPDATABLOCK* pBuffer; - FX_POSITION posBuffer = pModule->m_BufferMap.GetStartPosition(); - while (posBuffer) { - pModule->m_BufferMap.GetNextAssoc(posBuffer, pKey, pBuffer); - if (pBuffer) { - if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - FX_Free(pBuffer); - } - } - pModule->m_BufferMap.RemoveAll(); - pModule->m_ValueMap.RemoveAll(); - delete pModule; - } -} -void CXFA_Node::MergeAllData(void* pDstModule, FX_BOOL bUseSrcAttr) { - XFA_MAPMODULEDATA* pDstModuleData = - static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData(); - XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); - if (!pSrcModuleData) { - return; - } - FX_POSITION psValue = pSrcModuleData->m_ValueMap.GetStartPosition(); - while (psValue) { - void* pKey; - void* pValue; - pSrcModuleData->m_ValueMap.GetNextAssoc(psValue, pKey, pValue); - if (bUseSrcAttr || !pDstModuleData->m_ValueMap.GetValueAt(pKey)) { - pDstModuleData->m_ValueMap.SetAt(pKey, pValue); - } - } - FX_POSITION psBuffer = pSrcModuleData->m_BufferMap.GetStartPosition(); - while (psBuffer) { - void* pKey; - XFA_MAPDATABLOCK* pSrcBuffer; - pSrcModuleData->m_BufferMap.GetNextAssoc(psBuffer, pKey, pSrcBuffer); - XFA_MAPDATABLOCK*& pBuffer = pDstModuleData->m_BufferMap[pKey]; - if (pBuffer && !bUseSrcAttr) { - continue; - } - if (pSrcBuffer->pCallbackInfo && pSrcBuffer->pCallbackInfo->pFree && - !pSrcBuffer->pCallbackInfo->pCopy) { - if (pBuffer) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - pDstModuleData->m_BufferMap.RemoveKey(pKey); - } - continue; - } - if (pBuffer == NULL) { - pBuffer = (XFA_MAPDATABLOCK*)FX_Alloc( - uint8_t, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); - } else if (pBuffer->iBytes != pSrcBuffer->iBytes) { - if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc( - uint8_t, pBuffer, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes); - } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) { - pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData()); - } - if (pBuffer == NULL) { - continue; - } - pBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo; - pBuffer->iBytes = pSrcBuffer->iBytes; - FXSYS_memcpy(pBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes); - if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pCopy) { - pBuffer->pCallbackInfo->pCopy(*(void**)pBuffer->GetData()); - } - } -} -void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { - if (!pDstModule) { - return; - } - FX_BOOL bNeedMove = TRUE; - if (!pKey) { - bNeedMove = FALSE; - } - if (pDstModule->GetClassID() != GetClassID()) { - bNeedMove = FALSE; - } - XFA_MAPMODULEDATA* pSrcModuleData = NULL; - XFA_MAPMODULEDATA* pDstModuleData = NULL; - if (bNeedMove) { - pSrcModuleData = GetMapModuleData(); - if (!pSrcModuleData) { - bNeedMove = FALSE; - } - pDstModuleData = pDstModule->CreateMapModuleData(); - } - if (bNeedMove) { - void* pBufferBlockData = pSrcModuleData->m_BufferMap.GetValueAt(pKey); - if (pBufferBlockData) { - pSrcModuleData->m_BufferMap.RemoveKey(pKey); - pDstModuleData->m_BufferMap.RemoveKey(pKey); - pDstModuleData->m_BufferMap.SetAt(pKey, - (XFA_MAPDATABLOCK*)pBufferBlockData); - } - } - if (pDstModule->GetObjectType() == XFA_OBJECTTYPE_NodeV) { - CFX_WideString wsValue = pDstModule->GetScriptContent(FALSE); - CFX_WideString wsFormatValue(wsValue); - CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData(); - if (pWidgetData) { - pWidgetData->GetFormatDataValue(wsValue, wsFormatValue); - } - pDstModule->SetScriptContent(wsValue, wsFormatValue, TRUE, TRUE); - } -} -void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule, - CXFA_Node* pDstModule, - void* pKey, - FX_BOOL bRecursive) { - if (!pSrcModule || !pDstModule || !pKey) { - return; - } - if (bRecursive) { - CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pSrcChild && pDstChild; - pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling), - pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - MoveBufferMapData(pSrcChild, pDstChild, pKey, TRUE); - } - } - pSrcModule->MoveBufferMapData(pDstModule, pKey); -} -CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) - : CXFA_Object(pDocument, XFA_OBJECTTYPE_NodeList) { - m_pDocument->GetScriptContext()->CacheList(this); -} -CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) { - int32_t iCount = GetLength(); - FX_DWORD dwHashCode = - FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); - for (int32_t i = 0; i < iCount; i++) { - CXFA_Node* ret = Item(i); - if (dwHashCode == ret->GetNameHash()) { - return ret; - } - } - return NULL; -} -void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - if (pNode) { - Append(pNode); - } else { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"append"); - } -} -void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 2) { - CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1)); - if (pNewNode) { - Insert(pNewNode, pBeforeNode); - } else { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insert"); - } -} -void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - if (pNode) { - Remove(pNode); - } else { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove"); - } -} -void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - int32_t iIndex = pArguments->GetInt32(0); - if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) { - FXJSE_Value_Set( - pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex))); - } else { - ThrowScriptErrorMessage(XFA_IDS_INDEX_OUT_OF_BOUNDS); - } - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item"); - } -} -void CXFA_NodeList::Script_TreelistClass_NamedItem( - CFXJSE_Arguments* pArguments) { - int32_t argc = pArguments->GetLength(); - if (argc == 1) { - CFX_ByteString szName = pArguments->GetUTF8String(0); - CXFA_Node* pNode = - NamedItem(CFX_WideString::FromUTF8(szName, szName.GetLength())); - if (!pNode) { - return; - } - FXJSE_Value_Set(pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); - } else { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem"); - } -} -void CXFA_NodeList::Script_ListClass_Length(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!bSetting) { - FXJSE_Value_SetInteger(hValue, GetLength()); - } else { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - } -} -CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) - : CXFA_NodeList(pDocument) {} -void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { - if (srcArray.GetSize() > 0) { - m_array.Copy(srcArray); - } -} -int32_t CXFA_ArrayNodeList::GetLength() { - return m_array.GetSize(); -} -FX_BOOL CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { - m_array.Add(pNode); - return TRUE; -} -FX_BOOL CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, - CXFA_Node* pBeforeNode) { - if (pBeforeNode == NULL) { - m_array.Add(pNewNode); - } else { - int32_t iSize = m_array.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - if (m_array[i] == pBeforeNode) { - m_array.InsertAt(i, pNewNode); - break; - } - } - } - return TRUE; -} -FX_BOOL CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { - int32_t iSize = m_array.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - if (m_array[i] == pNode) { - m_array.RemoveAt(i); - break; - } - } - return TRUE; -} -CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) { - int32_t iSize = m_array.GetSize(); - if (iIndex >= 0 && iIndex < iSize) { - return m_array[iIndex]; - } - return NULL; -} -CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, - CXFA_Node* pAttachNode) - : CXFA_NodeList(pDocument) { - m_pAttachNode = pAttachNode; -} -int32_t CXFA_AttachNodeList::GetLength() { - return m_pAttachNode->CountChildren( - XFA_ELEMENT_UNKNOWN, m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); -} -FX_BOOL CXFA_AttachNodeList::Append(CXFA_Node* pNode) { - CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { - pParent->RemoveChild(pNode); - } - return m_pAttachNode->InsertChild(pNode); -} -FX_BOOL CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, - CXFA_Node* pBeforeNode) { - CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { - pParent->RemoveChild(pNewNode); - } - return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); -} -FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { - return m_pAttachNode->RemoveChild(pNode); -} -CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { - return m_pAttachNode->GetChild( - iIndex, XFA_ELEMENT_UNKNOWN, - m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); -} diff --git a/xfa/src/fxfa/parser/xfa_objectacc_imp.cpp b/xfa/src/fxfa/parser/xfa_objectacc_imp.cpp deleted file mode 100644 index 9515237683..0000000000 --- a/xfa/src/fxfa/parser/xfa_objectacc_imp.cpp +++ /dev/null @@ -1,3760 +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/include/fxcrt/fx_ext.h" -#include "xfa/include/fxbarcode/BC_BarCode.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_localevalue.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/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.GetPtr(); - 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; -} -FX_BOOL CXFA_Fill::SetPresence(int32_t iPresence) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); -} -FX_BOOL CXFA_Fill::SetFillType(int32_t iType) { - return FALSE; -} -FX_BOOL CXFA_Fill::SetPattern(int32_t iPattern, FX_ARGB foreColor) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern); - CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); - CFX_WideString wsColor; - int a, r, g, b; - ArgbDecode(foreColor, a, r, g, b); - wsColor.Format(L"%d,%d,%d", r, g, b); - pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); - return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iPattern); -} -FX_BOOL CXFA_Fill::SetStipple(int32_t iStipple, FX_ARGB stippleColor) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple); - CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); - CFX_WideString wsColor; - int a, r, g, b; - ArgbDecode(stippleColor, a, r, g, b); - wsColor.Format(L"%d,%d,%d", r, g, b); - pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); - return pNode->SetEnum(XFA_ATTRIBUTE_Rate, (XFA_ATTRIBUTEENUM)iStipple); -} -FX_BOOL CXFA_Fill::SetLinear(int32_t iLinear, FX_ARGB endColor) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear); - CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); - CFX_WideString wsColor; - int a, r, g, b; - ArgbDecode(endColor, a, r, g, b); - wsColor.Format(L"%d,%d,%d", r, g, b); - pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); - return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iLinear); -} -FX_BOOL CXFA_Fill::SetRadial(int32_t iRadial, FX_ARGB endColor) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial); - CXFA_Node* pColor = pNode->GetProperty(0, XFA_ELEMENT_Color); - CFX_WideString wsColor; - int a, r, g, b; - ArgbDecode(endColor, a, r, g, b); - wsColor.Format(L"%d,%d,%d", r, g, b); - pColor->SetCData(XFA_ATTRIBUTE_Value, wsColor); - return pNode->SetEnum(XFA_ATTRIBUTE_Type, (XFA_ATTRIBUTEENUM)iRadial); -} -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); -} -FX_BOOL CXFA_Margin::SetLeftInset(FX_FLOAT fInset) { - return SetMeasure(XFA_ATTRIBUTE_LeftInset, fInset); -} -FX_BOOL CXFA_Margin::SetTopInset(FX_FLOAT fInset) { - return SetMeasure(XFA_ATTRIBUTE_TopInset, fInset); -} -FX_BOOL CXFA_Margin::SetRightInset(FX_FLOAT fInset) { - return SetMeasure(XFA_ATTRIBUTE_RightInset, fInset); -} -FX_BOOL CXFA_Margin::SetBottomInset(FX_FLOAT fInset) { - return SetMeasure(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::GetLineThroughPeriod() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; - m_pNode->TryEnum(XFA_ATTRIBUTE_LineThroughPeriod, eAttr); - return eAttr; -} -int32_t CXFA_Font::GetOverline() { - int32_t iValue = 0; - m_pNode->TryInteger(XFA_ATTRIBUTE_Overline, iValue); - return iValue; -} -int32_t CXFA_Font::GetOverlinePeriod() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All; - m_pNode->TryEnum(XFA_ATTRIBUTE_OverlinePeriod, eAttr); - return eAttr; -} -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; -} -FX_BOOL CXFA_Font::IsUseKerning() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; - m_pNode->TryEnum(XFA_ATTRIBUTE_KerningMode, eAttr); - return eAttr == XFA_ATTRIBUTEENUM_Pair; -} -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; -} -FX_BOOL CXFA_Font::SetBaselineShift(FX_FLOAT fBaselineShift) { - CXFA_Measurement ms(fBaselineShift, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_BaselineShift, ms); -} -FX_BOOL CXFA_Font::SetHorizontalScale(FX_FLOAT fHorizontalScale) { - CFX_WideString wsValue; - wsValue.Format(L"%d", (int32_t)fHorizontalScale); - return m_pNode->SetCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue); -} -FX_BOOL CXFA_Font::SetVerticalScale(FX_FLOAT fVerticalScale) { - CFX_WideString wsValue; - wsValue.Format(L"%d", (int32_t)fVerticalScale); - return m_pNode->SetCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue); -} -FX_BOOL CXFA_Font::SetLetterSpacing(FX_FLOAT fLetterSpacing, XFA_UNIT eUnit) { - return FALSE; -} -FX_BOOL CXFA_Font::SetLineThrough(int32_t iLineThrough) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_LineThrough, iLineThrough); -} -FX_BOOL CXFA_Font::SetLineThroughPeriod(int32_t iLineThroughPeriod) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_LineThroughPeriod, - (XFA_ATTRIBUTEENUM)iLineThroughPeriod); -} -FX_BOOL CXFA_Font::SetOverline(int32_t iOverline) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_Overline, iOverline); -} -FX_BOOL CXFA_Font::SetOverlinePeriod(int32_t iOverlinePeriod) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_OverlinePeriod, - (XFA_ATTRIBUTEENUM)iOverlinePeriod); -} -FX_BOOL CXFA_Font::SetUnderline(int32_t iUnderline) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_Underline, iUnderline); -} -FX_BOOL CXFA_Font::SetUnderlinePeriod(int32_t iUnderlinePeriod) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_UnderlinePeriod, - (XFA_ATTRIBUTEENUM)iUnderlinePeriod); -} -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_Caption::GetPara() { - return CXFA_Para(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Para) : NULL); -} -FX_BOOL CXFA_Caption::SetPresence(int32_t iPresence) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); -} -FX_BOOL CXFA_Caption::SetPlacementType(int32_t iType) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Placement, (XFA_ATTRIBUTEENUM)iType); -} -FX_BOOL CXFA_Caption::SetReserve(FX_FLOAT fReserve) { - CXFA_Measurement ms(fReserve, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_Reserve, ms); -} -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); -} -int32_t CXFA_Para::GetOrphans() { - int32_t iValue = 0; - m_pNode->TryInteger(XFA_ATTRIBUTE_Orphans, iValue); - return iValue; -} -FX_FLOAT CXFA_Para::GetRadixOffset() { - CXFA_Measurement ms; - m_pNode->TryMeasure(XFA_ATTRIBUTE_RadixOffset, 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); -} -int32_t CXFA_Para::GetWidows() { - int32_t iValue = 0; - m_pNode->TryInteger(XFA_ATTRIBUTE_Widows, iValue); - return iValue; -} -FX_BOOL CXFA_Para::SetHorizontalAlign(int32_t iHorizontalAlign) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_HAlign, - (XFA_ATTRIBUTEENUM)iHorizontalAlign); -} -FX_BOOL CXFA_Para::SetVerticalAlign(int32_t iVerticalAlign) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_VAlign, - (XFA_ATTRIBUTEENUM)iVerticalAlign); -} -FX_BOOL CXFA_Para::SetLineHeight(FX_FLOAT fLineHeight) { - CXFA_Measurement ms; - return m_pNode->SetMeasure(XFA_ATTRIBUTE_LineHeight, ms); -} -FX_BOOL CXFA_Para::SetMarginLeft(FX_FLOAT fMarginLeft) { - CXFA_Measurement ms(fMarginLeft, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginLeft, ms); -} -FX_BOOL CXFA_Para::SetMarginRight(FX_FLOAT fMarginRight) { - CXFA_Measurement ms(fMarginRight, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_MarginRight, ms); -} -FX_BOOL CXFA_Para::SetOrphans(int32_t iOrphans) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_Orphans, iOrphans); -} -FX_BOOL CXFA_Para::SetRadixOffset(FX_FLOAT fRadixOffset) { - CXFA_Measurement ms(fRadixOffset, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_RadixOffset, ms); -} -FX_BOOL CXFA_Para::SetSpaceAbove(FX_FLOAT fSpaceAbove) { - CXFA_Measurement ms(fSpaceAbove, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceAbove, ms); -} -FX_BOOL CXFA_Para::SetSpaceBelow(FX_FLOAT fSpaceBelow) { - CXFA_Measurement ms(fSpaceBelow, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_SpaceBelow, ms); -} -FX_BOOL CXFA_Para::SetTextIndent(FX_FLOAT fTextIndent) { - CXFA_Measurement ms(fTextIndent, XFA_UNIT_Pt); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_TextIndent, ms); -} -FX_BOOL CXFA_Para::SetWidows(int32_t iWidows) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_Widows, iWidows); -} -CXFA_Keep::CXFA_Keep(CXFA_Node* pNode, CXFA_Node* pParent) - : CXFA_Data(pNode), m_pParent(pParent) {} -int32_t CXFA_Keep::GetIntact() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; - switch (m_pParent->GetClassID()) { - case XFA_ELEMENT_Subform: { - XFA_ATTRIBUTEENUM eAttrSubForm; - m_pParent->TryEnum(XFA_ATTRIBUTE_Layout, eAttrSubForm); - if (eAttrSubForm == XFA_ATTRIBUTEENUM_Position || - eAttrSubForm == XFA_ATTRIBUTEENUM_Row) { - eAttr = XFA_ATTRIBUTEENUM_ContentArea; - } - } break; - case XFA_ELEMENT_Draw: - eAttr = XFA_ATTRIBUTEENUM_ContentArea; - break; - default: - break; - } - m_pNode->TryEnum(XFA_ATTRIBUTE_Intact, eAttr, FALSE); - return eAttr; -} -int32_t CXFA_Keep::GetNext() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; - m_pNode->TryEnum(XFA_ATTRIBUTE_Next, eAttr); - return eAttr; -} -int32_t CXFA_Keep::GetPrevious() { - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_None; - m_pNode->TryEnum(XFA_ATTRIBUTE_Previous, eAttr); - return eAttr; -} -FX_BOOL CXFA_Keep::SetIntact(int32_t iIntact) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Intact, (XFA_ATTRIBUTEENUM)iIntact); -} -FX_BOOL CXFA_Keep::SetNext(int32_t iNext) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Next, (XFA_ATTRIBUTEENUM)iNext); -} -FX_BOOL CXFA_Keep::SetPrevious(int32_t iPrevious) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Previous, (XFA_ATTRIBUTEENUM)iPrevious); -} -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); -} -int32_t CXFA_Event::GetExecuteRunAt() { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - return pNode->GetEnum(XFA_ATTRIBUTE_RunAt); -} -int32_t CXFA_Event::GetExecuteType() { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - return pNode->GetEnum(XFA_ATTRIBUTE_ExecuteType); -} -void CXFA_Event::GetExecuteConnection(CFX_WideString& wsConnection) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - CFX_WideStringC cData; - pNode->TryCData(XFA_ATTRIBUTE_Connection, cData); - wsConnection = cData; -} -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)); -} -int32_t CXFA_Event::GetSignDataOperation() { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); - return pNode->GetEnum(XFA_ATTRIBUTE_Operation); -} -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; - } -} -FX_BOOL CXFA_Event::SetActivity(int32_t iActivity) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Activity, (XFA_ATTRIBUTEENUM)iActivity); -} -FX_BOOL CXFA_Event::SetEventType(int32_t iEventType) { - return FALSE; -} -FX_BOOL CXFA_Event::SetExecuteRunAt(int32_t iExecuteRunAt) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - return pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iExecuteRunAt); -} -FX_BOOL CXFA_Event::SetExecuteType(int32_t iExecuteType) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - return pNode->SetEnum(XFA_ATTRIBUTE_ExecuteType, - (XFA_ATTRIBUTEENUM)iExecuteType); -} -FX_BOOL CXFA_Event::SetExecuteConnection(const CFX_WideString& wsConnection) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Execute); - return pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection); -} -FX_BOOL CXFA_Event::SetSignDataOperation(int32_t iOperation) { - CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData); - return pNode->SetEnum(XFA_ATTRIBUTE_Operation, (XFA_ATTRIBUTEENUM)iOperation); -} -FX_BOOL CXFA_Event::SetSignDataTarget(const CFX_WideString& wsTarget) { - if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) { - return pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); - } - return FALSE; -} -CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {} -void CXFA_Script::GetBinding(CFX_WideString& wsBinding) { - CFX_WideStringC cData; - m_pNode->TryCData(XFA_ATTRIBUTE_Binding, cData); - wsBinding = cData; -} -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); -} -FX_BOOL CXFA_Script::SetBinding(const CFX_WideString& wsBinding) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Binding, wsBinding); -} -FX_BOOL CXFA_Script::SetContentType(XFA_SCRIPTTYPE eType) { - CFX_WideString wsType; - switch (eType) { - case XFA_SCRIPTTYPE_Javascript: - wsType = L"application/x-javascript"; - break; - case XFA_SCRIPTTYPE_Formcalc: - wsType = L"application/x-formcalc"; - break; - default: - break; - } - return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsType); -} -FX_BOOL CXFA_Script::SetRunAt(int32_t iRunAt) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_RunAt, (XFA_ATTRIBUTEENUM)iRunAt); -} -FX_BOOL CXFA_Script::SetExpression(const CFX_WideString& wsExpression) { - return m_pNode->SetContent(wsExpression, 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); -} -XFA_TEXTENCODING CXFA_Submit::GetSubmitTextEncoding() { - CFX_WideStringC wsCData; - if (!m_pNode->TryCData(XFA_ATTRIBUTE_TextEncoding, wsCData)) { - return XFA_TEXTENCODING_None; - } - CFX_WideString wsValue(wsCData); - if (wsValue == L"Big-Five") { - return XFA_TEXTENCODING_Big5; - } else if (wsValue == L"fontSpecific") { - return XFA_TEXTENCODING_FontSpecific; - } else if (wsValue == L"GBK") { - return XFA_TEXTENCODING_GBK; - } else if (wsValue == L"GB-18030") { - return XFA_TEXTENCODING_GB18030; - } else if (wsValue == L"GB-2312") { - return XFA_TEXTENCODING_GB2312; - } else if (wsValue == L"ISO-8859-NN") { - return XFA_TEXTENCODING_ISO8859NN; - } else if (wsValue == L"KSC-5601") { - return XFA_TEXTENCODING_KSC5601; - } else if (wsValue == L"Shift-JIS") { - return XFA_TEXTENCODING_ShiftJIS; - } else if (wsValue == L"UCS-2") { - return XFA_TEXTENCODING_UCS2; - } else if (wsValue == L"UTF-16") { - return XFA_TEXTENCODING_UTF16; - } else if (wsValue == L"UTF-8") { - return XFA_TEXTENCODING_UTF8; - } - return XFA_TEXTENCODING_None; -} -void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) { - m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent); -} -FX_BOOL CXFA_Submit::SetSubmitFormat(int32_t iSubmitFormat) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Format, - (XFA_ATTRIBUTEENUM)iSubmitFormat); -} -FX_BOOL CXFA_Submit::SetSubmitTarget(const CFX_WideString& wsTarget) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Target, wsTarget); -} -FX_BOOL CXFA_Submit::SetSubmitTextEncoding(XFA_TEXTENCODING eTextEncoding) { - CFX_WideString wsValue; - switch (eTextEncoding) { - case XFA_TEXTENCODING_Big5: - wsValue = L"Big-Five"; - break; - case XFA_TEXTENCODING_FontSpecific: - wsValue = L"fontSpecific"; - break; - case XFA_TEXTENCODING_GBK: - wsValue = L"GBK"; - break; - case XFA_TEXTENCODING_GB18030: - wsValue = L"GB-18030"; - break; - case XFA_TEXTENCODING_GB2312: - wsValue = L"GB-2312"; - break; - case XFA_TEXTENCODING_ISO8859NN: - wsValue = L"ISO-8859-NN"; - break; - case XFA_TEXTENCODING_KSC5601: - wsValue = L"KSC-5601"; - break; - case XFA_TEXTENCODING_ShiftJIS: - wsValue = L"Shift-JIS"; - break; - case XFA_TEXTENCODING_UCS2: - wsValue = L"UCS-2"; - break; - case XFA_TEXTENCODING_UTF16: - wsValue = L"UTF-16"; - break; - case XFA_TEXTENCODING_UTF8: - wsValue = L"UTF-8"; - break; - default: - break; - } - return m_pNode->SetCData(XFA_ATTRIBUTE_TextEncoding, wsValue); -} -FX_BOOL CXFA_Submit::SetSubmitXDPContent(const CFX_WideString& wsContent) { - return m_pNode->SetCData(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); -} -FX_BOOL CXFA_Value::SetChildValueContent(const CFX_WideString& wsContent, - FX_BOOL bNotify, - XFA_ELEMENT iType) { - if (!m_pNode) { - return FALSE; - } - CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pNode) { - if (iType == XFA_ELEMENT_UNKNOWN) { - return FALSE; - } - pNode = m_pNode->GetProperty(0, iType); - } - CFX_WideString wsFormatContent(wsContent); - CXFA_WidgetData* pContainerWidgetData = pNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsContent, wsFormatContent); - } - return pNode->SetContent(wsContent, wsFormatContent, bNotify); -} -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)); -} -FX_BOOL CXFA_Line::SetHand(int32_t iHand) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Hand, (XFA_ATTRIBUTEENUM)iHand); -} -FX_BOOL CXFA_Line::SetSlop(int32_t iSlop) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Slope, (XFA_ATTRIBUTEENUM)iSlop); -} -CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} -void CXFA_Text::GetName(CFX_WideStringC& wsName) { - m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); -} -int32_t CXFA_Text::GetMaxChars() { - return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxChars); -} -void CXFA_Text::GetRid(CFX_WideStringC& wsRid) { - m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); -} -void CXFA_Text::GetContent(CFX_WideString& wsText) { - m_pNode->TryContent(wsText); -} -void CXFA_Text::SetContent(CFX_WideString wsText, FX_BOOL bNotify) { - CFX_WideString wsFormatValue(wsText); - CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); - } - m_pNode->SetContent(wsText, wsFormatValue, bNotify); -} -FX_BOOL CXFA_Text::SetName(const CFX_WideString& wsName) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); -} -FX_BOOL CXFA_Text::SetMaxChars(int32_t iMaxChars) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxChars, iMaxChars); -} -FX_BOOL CXFA_Text::SetRid(const CFX_WideString& wsRid) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); -} -CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {} -void CXFA_ExData::GetContentType(CFX_WideStringC& wsContentType) { - m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType); -} -void CXFA_ExData::GetHref(CFX_WideStringC& wsHref) { - m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref); -} -int32_t CXFA_ExData::GetMaxLength() { - return m_pNode->GetInteger(XFA_ATTRIBUTE_MaxLength); -} -void CXFA_ExData::GetRid(CFX_WideStringC& wsRid) { - m_pNode->TryCData(XFA_ATTRIBUTE_Rid, wsRid); -} -int32_t CXFA_ExData::GetTransferEncoding() { - return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding); -} -void CXFA_ExData::GetContent(CFX_WideString& wsText) { - m_pNode->TryContent(wsText); -} -FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) { - return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); -} -FX_BOOL CXFA_ExData::SetHref(const CFX_WideString& wsHref) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref); -} -FX_BOOL CXFA_ExData::SetMaxLength(int32_t iMaxLength) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_MaxLength, iMaxLength); -} -FX_BOOL CXFA_ExData::SetRid(const CFX_WideString& wsRid) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Rid, wsRid); -} -FX_BOOL CXFA_ExData::SetTransferEncoding(int32_t iTransferEncoding) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, - (XFA_ATTRIBUTEENUM)iTransferEncoding); -} -FX_BOOL CXFA_ExData::SetContent(const CFX_WideString& wsText, - FX_BOOL bNotify, - FX_BOOL bScriptModify, - FX_BOOL bSyncData) { - CFX_WideString wsFormatValue(wsText); - CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); - } - return m_pNode->SetContent(wsText, wsFormatValue, bNotify, bScriptModify, - bSyncData); -} -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::SetAspect(int32_t iAspect) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Aspect, (XFA_ATTRIBUTEENUM)iAspect); -} -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); -} -FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) { - if (m_bDefValue) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding, - (XFA_ATTRIBUTEENUM)iTransferEncoding); - } - return TRUE; -} -FX_BOOL CXFA_Image::SetContent(const CFX_WideString& wsText) { - CFX_WideString wsFormatValue(wsText); - CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsText, wsFormatValue); - } - return m_pNode->SetContent(wsText, wsFormatValue); -} -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); - } - } -} -FX_BOOL CXFA_Calculate::SetOverride(int32_t iOverride) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Override, (XFA_ATTRIBUTEENUM)iOverride); -} -FX_BOOL CXFA_Calculate::SetMessageText(const CFX_WideString& wsMessage) { - if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) { - CXFA_Node* pChildNode = pNode->GetProperty(0, XFA_ELEMENT_Text); - return pChildNode->SetContent(wsMessage, wsMessage); - } - return FALSE; -} -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); - if (pInfo) { - eName = pInfo->eName; - } - m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE); - return TRUE; -} -FX_BOOL CXFA_Validate::SetFormatTest(CFX_WideString wsValue) { - return SetTestValue(XFA_ATTRIBUTE_FormatTest, wsValue, - XFA_ATTRIBUTEENUM_Warning); -} -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_Variables::CXFA_Variables(CXFA_Node* pNode) : CXFA_Data(pNode) {} -int32_t CXFA_Variables::CountScripts() { - return m_pNode->CountChildren(XFA_ELEMENT_Script); -} -CXFA_Script CXFA_Variables::GetScript(int32_t nIndex) { - return CXFA_Script(m_pNode->GetChild(nIndex, XFA_ELEMENT_Script)); -} -CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} -int32_t CXFA_Bind::GetMatch() { - return m_pNode->GetEnum(XFA_ATTRIBUTE_Match); -} -void CXFA_Bind::GetRef(CFX_WideStringC& wsRef) { - m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef); -} -void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) { - if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { - pPicture->TryContent(wsPicture); - } -} -FX_BOOL CXFA_Bind::SetMatch(int32_t iMatch) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Match, (XFA_ATTRIBUTEENUM)iMatch); -} -FX_BOOL CXFA_Bind::SetRef(const CFX_WideString& wsRef) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); -} -FX_BOOL CXFA_Bind::SetPicture(const CFX_WideString& wsPicture) { - if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) { - return pPicture->SetContent(wsPicture, wsPicture); - } - return FALSE; -} -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); -} -FX_BOOL CXFA_ToolTip::SetTip(const CFX_WideString& wsTip) { - return m_pNode->SetContent(wsTip, wsTip); -} -CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {} -void CXFA_BindItems::GetConnection(CFX_WideStringC& wsConnection) { - m_pNode->TryCData(XFA_ATTRIBUTE_Connection, wsConnection); -} -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); -} -FX_BOOL CXFA_BindItems::SetLabelRef(const CFX_WideString& wsLabelRef) { - return m_pNode->SetCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef); -} -FX_BOOL CXFA_BindItems::SetValueRef(const CFX_WideString& wsValueRef) { - return m_pNode->SetCData(XFA_ATTRIBUTE_ValueRef, wsValueRef); -} -FX_BOOL CXFA_BindItems::SetRef(const CFX_WideString& wsRef) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Ref, wsRef); -} -int32_t CXFA_Box::GetBreak() const { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Close; - } - return m_pNode->GetEnum(XFA_ATTRIBUTE_Break); -} -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::CountCorners() const { - if (!m_pNode) { - return 0; - } - return m_pNode->CountChildren(XFA_ELEMENT_Corner); -} -CXFA_Corner CXFA_Box::GetCorner(int32_t nIndex) const { - return CXFA_Corner( - m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Corner, nIndex == 0) - : nullptr); -} -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; - } - 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); -} -static FX_BOOL XFA_BOX_SameStyles(const CXFA_StrokeArray& strokes) { - int32_t iCount = strokes.GetSize(); - if (iCount < 1) { - return TRUE; - } - CXFA_Stroke stroke1 = strokes[0]; - for (int32_t i = 1; i < iCount; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke2) { - continue; - } - if (!stroke1) { - stroke1 = stroke2; - } else if (!stroke1.SameStyles(stroke2)) { - return FALSE; - } - } - return TRUE; -} -FX_BOOL CXFA_Box::SameStyles() const { - if (IsArc()) { - return TRUE; - } - CXFA_StrokeArray strokes; - XFA_BOX_GetStrokes(m_pNode, strokes, TRUE); - return XFA_BOX_SameStyles(strokes); -} -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; - } - } - 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::SetThickness(FX_FLOAT fThickness) { - if (!m_pNode) { - return; - } - CXFA_Measurement thickness(fThickness, XFA_UNIT_Pt); - m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, thickness); -} -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, FX_DWORD 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); - } - } - return fThickness; -} -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) { - 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) { - 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) { - return iAcc; - } - pNode = - pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); - } - return XFA_ATTRIBUTEENUM_Open; -} -FX_BOOL CXFA_WidgetData::GetAccessKey(CFX_WideStringC& wsAccessKey) { - return m_pNode->TryCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); -} -int32_t CXFA_WidgetData::GetAnchorType() { - return m_pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); -} -int32_t CXFA_WidgetData::GetColSpan() { - return m_pNode->GetInteger(XFA_ATTRIBUTE_ColSpan); -} -int32_t CXFA_WidgetData::GetPresence() { - return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); - CXFA_Node* pNode = m_pNode; - while (pNode && pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { - int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Presence); - if (iAcc != XFA_ATTRIBUTEENUM_Visible) { - return iAcc; - } - pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent); - } - return XFA_ATTRIBUTEENUM_Visible; -} -int32_t CXFA_WidgetData::GetRotate() { - CXFA_Measurement ms; - 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)); -} -CXFA_Keep CXFA_WidgetData::GetKeep(FX_BOOL bModified) { - return CXFA_Keep(m_pNode->GetProperty(0, XFA_ELEMENT_Keep, bModified), - m_pNode); -} -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) { - CXFA_NodeArray allEvents; - GetEventList(allEvents); - int32_t iCount = allEvents.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - CXFA_Event event(allEvents[i]); - if (event.GetActivity() == iActivity) { - if (iActivity == XFA_ATTRIBUTEENUM_Ready) { - CFX_WideStringC wsRef; - event.GetRef(wsRef); - if (bIsFormReady) { - if (wsRef == CFX_WideStringC(L"$form")) { - events.Add(allEvents[i]); - } - } else { - if (wsRef == CFX_WideStringC(L"$layout")) { - events.Add(allEvents[i]); - } - } - } else { - events.Add(allEvents[i]); - } - } - } - 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_Variables CXFA_WidgetData::GetVariables(FX_BOOL bModified) { - return CXFA_Variables( - m_pNode->GetProperty(0, XFA_ELEMENT_Variables, 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)); -} -void CXFA_WidgetData::GetRelevant(CFX_WideStringC& wsRelevant) { - m_pNode->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant); -} -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_BindItems CXFA_WidgetData::GetBindItems() { - return CXFA_BindItems(m_pNode->GetChild(0, XFA_ELEMENT_BindItems)); -} -FX_BOOL CXFA_WidgetData::SetAccess(int32_t iAccess, FX_BOOL bNotify) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Access, (XFA_ATTRIBUTEENUM)iAccess, - bNotify); -} -FX_BOOL CXFA_WidgetData::SetAccessKey(const CFX_WideString& wsAccessKey) { - return m_pNode->SetCData(XFA_ATTRIBUTE_AccessKey, wsAccessKey); -} -FX_BOOL CXFA_WidgetData::SetAnchorType(int32_t iType) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_AnchorType, (XFA_ATTRIBUTEENUM)iType); -} -FX_BOOL CXFA_WidgetData::SetColSpan(int32_t iColSpan) { - return m_pNode->SetInteger(XFA_ATTRIBUTE_ColSpan, - (XFA_ATTRIBUTEENUM)iColSpan); -} -FX_BOOL CXFA_WidgetData::SetPresence(int32_t iPresence) { - return m_pNode->SetEnum(XFA_ATTRIBUTE_Presence, (XFA_ATTRIBUTEENUM)iPresence); -} -FX_BOOL CXFA_WidgetData::SetRotate(int32_t iRotate) { - iRotate = XFA_MapRotation(iRotate); - CXFA_Measurement ms((FX_FLOAT)iRotate, XFA_UNIT_Angle); - return m_pNode->SetMeasure(XFA_ATTRIBUTE_Rotate, ms); -} -FX_BOOL CXFA_WidgetData::SetRelevant(const CFX_WideString& wsRelevant) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Relevant, wsRelevant); -} -FX_BOOL CXFA_WidgetData::SetStatus(FX_DWORD dwStatus) { - return FALSE; -} -FX_BOOL CXFA_WidgetData::SetWidth(FX_FLOAT fWidth) { - return SetMeasure(XFA_ATTRIBUTE_W, fWidth); -} -FX_BOOL CXFA_WidgetData::SetHeight(FX_FLOAT fHeight) { - return SetMeasure(XFA_ATTRIBUTE_H, fHeight); -} -FX_BOOL CXFA_WidgetData::SetMinWidth(FX_FLOAT fMinWidth) { - return SetMeasure(XFA_ATTRIBUTE_MinW, fMinWidth); -} -FX_BOOL CXFA_WidgetData::SetMinHeight(FX_FLOAT fMinHeight) { - return SetMeasure(XFA_ATTRIBUTE_MinH, fMinHeight); -} -FX_BOOL CXFA_WidgetData::SetMaxWidth(FX_FLOAT fMaxWidth) { - return SetMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth); -} -FX_BOOL CXFA_WidgetData::SetMaxHeight(FX_FLOAT fMaxHeight) { - return SetMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); -} -FX_BOOL CXFA_WidgetData::SetPos(FX_FLOAT x, FX_FLOAT y) { - return SetMeasure(XFA_ATTRIBUTE_X, x) && SetMeasure(XFA_ATTRIBUTE_Y, y); -} -FX_BOOL CXFA_WidgetData::SetName(const CFX_WideString& wsName) { - return m_pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); -} -FX_BOOL CXFA_WidgetData::SetButtonHighlight(int32_t iButtonHighlight) { - CXFA_Node* pUiChildNode = GetUIChild(); - return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Highlight, - (XFA_ATTRIBUTEENUM)iButtonHighlight); -} -FX_BOOL CXFA_WidgetData::SetButtonRollover(const CFX_WideString& wsRollover, - FX_BOOL bRichText) { - return FALSE; -} -FX_BOOL CXFA_WidgetData::SetButtonDown(const CFX_WideString& wsDown, - FX_BOOL bRichText) { - return FALSE; -} -FX_BOOL CXFA_WidgetData::SetCheckButtonShape(int32_t iCheckButtonShape) { - CXFA_Node* pUiChildNode = GetUIChild(); - return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Shape, - (XFA_ATTRIBUTEENUM)iCheckButtonShape); -} -FX_BOOL CXFA_WidgetData::SetCheckButtonMark(int32_t iCheckButtonMark) { - CXFA_Node* pUiChildNode = GetUIChild(); - return pUiChildNode->SetEnum(XFA_ATTRIBUTE_Mark, - (XFA_ATTRIBUTEENUM)iCheckButtonMark); -} -FX_BOOL CXFA_WidgetData::SetCheckButtonSize(FX_FLOAT fCheckButtonMark) { - CXFA_Node* pUiChildNode = GetUIChild(); - if (pUiChildNode) { - CXFA_Measurement ms(fCheckButtonMark, XFA_UNIT_Pt); - return pUiChildNode->SetMeasure(XFA_ATTRIBUTE_Size, ms); - } - return FALSE; -} -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) { - return; - } - CXFA_Border border = GetUIBorder(); - 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); - FX_BOOL bRight = mgUI.GetRightInset(fRightInset); - FX_BOOL bBottom = mgUI.GetBottomInset(fBottomInset); - if (border) { - FX_BOOL bVisible = FALSE; - FX_FLOAT fThickness = 0; - border.Get3DStyle(bVisible, fThickness); - 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); - } - } - } - rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); -} -int32_t CXFA_WidgetData::GetButtonHighlight() { - CXFA_Node* pUIChild = GetUIChild(); - 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)) { - CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pText) { - CFX_WideStringC wsName; - pText->TryCData(XFA_ATTRIBUTE_Name, wsName); - if (wsName == FX_WSTRC(L"rollover")) { - pText->TryContent(wsRollover); - bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; - return !wsRollover.IsEmpty(); - } - pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown, - FX_BOOL& bRichText) { - if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) { - CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pText) { - CFX_WideStringC wsName; - pText->TryCData(XFA_ATTRIBUTE_Name, wsName); - if (wsName == FX_WSTRC(L"down")) { - pText->TryContent(wsDown); - bRichText = pText->GetClassID() == XFA_ELEMENT_ExData; - return !wsDown.IsEmpty(); - } - pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } - return FALSE; -} -int32_t CXFA_WidgetData::GetCheckButtonShape() { - CXFA_Node* pUIChild = GetUIChild(); - 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) { - 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)) { - return pParent->GetClassID() == XFA_ELEMENT_ExclGroup; - } - return FALSE; -} -FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() { - CXFA_Node* pUIChild = GetUIChild(); - 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) { - 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()) { - 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)) { - 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()); - if (exclGroup) { - CFX_WideString wsValue; - 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) { - 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) { - continue; - } - CXFA_Node* pItem = pChild->GetChild(0, XFA_ELEMENT_Items); - if (!pItem) { - continue; - } - CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pItemchild) { - continue; - } - CFX_WideString text = pItemchild->GetContent(); - CFX_WideString wsChildValue = text; - if (wsValue != text) { - pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); - if (pItemchild) { - wsChildValue = pItemchild->GetContent(); - } else { - wsChildValue.Empty(); - } - } - CXFA_WidgetData ch(pChild); - ch.SyncValue(wsChildValue, bNotify); - } - exclGroup.SyncValue(wsValue, bNotify); - } else { - CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items); - if (!pItems) { - return; - } - int32_t i = -1; - CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); - CFX_WideString wsContent; - while (pText) { - i++; - if (i == eCheckState) { - pText->TryContent(wsContent); - break; - } - pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); - } - 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) { - return NULL; - } - return pExcl; -} -CXFA_Node* CXFA_WidgetData::GetSelectedMember() { - CXFA_Node* pSelectedMember = NULL; - CFX_WideString wsState = GetRawValue(); - 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); - if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { - pSelectedMember = pNode; - break; - } - } - return pSelectedMember; -} -CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName, - FX_BOOL bNotify) { - CXFA_Node* pSelectedMember = NULL; - FX_DWORD nameHash = - FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength()); - for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetNameHash() == nameHash) { - CXFA_WidgetData widgetData(pNode); - widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); - pSelectedMember = pNode; - break; - } - } - return pSelectedMember; -} -void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue, - FX_BOOL bNotify, - FX_BOOL bScriptModify, - FX_BOOL bSyncData) { - 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) { - continue; - } - CXFA_Node* pItem = pNode->GetChild(0, XFA_ELEMENT_Items); - if (!pItem) { - continue; - } - CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pItemchild) { - continue; - } - CFX_WideString wsChildValue = pItemchild->GetContent(); - if (wsValue != wsChildValue) { - pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling); - if (pItemchild) { - wsChildValue = pItemchild->GetContent(); - } else { - wsChildValue.Empty(); - } - } else { - wsExclGroup = wsValue; - } - pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify, - FALSE); - } - if (m_pNode) { - m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, - bSyncData); - } -} -CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { - CXFA_Node* pExcl = GetNode(); - if (!pExcl) { - return NULL; - } - CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pNode) { - 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) { - return NULL; - } - CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - while (pNodeField) { - 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) { - 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) { - 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) { - 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) { - continue; - } - iCount++; - pItems.Add(pNode); - if (iCount == 2) { - break; - } - } - 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) { - 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(); - 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) { - continue; - } - iCount++; - pItemsArray.Add(pNode); - if (iCount == 2) { - break; - } - } - 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) { - pItems = pItemsArray[1]; - } - } - if (pItems) { - CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_ELEMENT_UNKNOWN); - if (pItem) { - pItem->TryContent(wsText); - return TRUE; - } - } - return FALSE; -} -void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, - 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) { - continue; - } - iCount++; - pItems.Add(pNode); - if (iCount == 2) { - break; - } - } - 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) { - pItem = pItems[1]; - } - } - pItems.RemoveAll(); - pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); - 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()) { - return wsValueArray.GetSize(); - } - int32_t iSelected = 0; - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - int32_t iValues = wsValueArray.GetSize(); - for (int32_t i = 0; i < iValues; i++) { - int32_t iSaves = wsSaveTextArray.GetSize(); - for (int32_t j = 0; j < iSaves; j++) { - if (wsValueArray[i] == wsSaveTextArray[j]) { - iSelected++; - break; - } - } - } - return iSelected; -} -int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) { - CFX_WideStringArray wsValueArray; - GetSelectedItemsValue(wsValueArray); - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - int32_t iSaves = wsSaveTextArray.GetSize(); - for (int32_t j = 0; j < iSaves; 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) { - return; - } - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - int32_t iSaves = wsSaveTextArray.GetSize(); - for (int32_t i = 0; i < iValues; i++) { - for (int32_t j = 0; j < iSaves; j++) { - if (wsValueArray[i] == wsSaveTextArray[j]) { - iSelArray.Add(j); - break; - } - } - } -} -void CXFA_WidgetData::GetSelectedItemsValue( - CFX_WideStringArray& wsSelTextArray) { - CFX_WideString wsValue = GetRawValue(); - if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { - if (!wsValue.IsEmpty()) { - int32_t iStart = 0; - int32_t iLength = wsValue.GetLength(); - int32_t iEnd = wsValue.Find(L'\n', iStart); - iEnd = (iEnd == -1) ? iLength : iEnd; - while (iEnd >= iStart) { - wsSelTextArray.Add(wsValue.Mid(iStart, iEnd - iStart)); - iStart = iEnd + 1; - if (iStart >= iLength) { - break; - } - iEnd = wsValue.Find(L'\n', iStart); - 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) { - return FALSE; - } - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - 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]) { - 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) { - return; - } - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - if (wsSaveTextArray.GetSize() <= nIndex) { - return; - } - int32_t iSel = -1; - CFX_WideStringArray wsValueArray; - GetSelectedItemsValue(wsValueArray); - int32_t iValues = wsValueArray.GetSize(); - for (int32_t j = 0; j < iValues; j++) { - if (wsValueArray[j] == wsSaveTextArray[nIndex]) { - iSel = j; - break; - } - } - if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { - if (bSelected) { - if (iSel < 0) { - CFX_WideString wsValue = GetRawValue(); - if (!wsValue.IsEmpty()) { - wsValue += L"\n"; - } - wsValue += wsSaveTextArray[nIndex]; - m_pNode->SetContent(wsValue, wsValue, bNotify, bScriptModify, - bSyncData); - } - } else if (iSel >= 0) { - CFX_Int32Array iSelArray; - GetSelectedItems(iSelArray); - for (int32_t i = 0; i < iSelArray.GetSize(); i++) { - if (iSelArray[i] == nIndex) { - iSelArray.RemoveAt(i); - break; - } - } - SetSelectdItems(iSelArray, bNotify, bScriptModify, bSyncData); - } - } else { - if (bSelected) { - if (iSel < 0) { - CFX_WideString wsSaveText = wsSaveTextArray[nIndex]; - CFX_WideString wsFormatText(wsSaveText); - GetFormatDataValue(wsSaveText, wsFormatText); - m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify, - bSyncData); - } - } else if (iSel >= 0) { - m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, - bScriptModify, bSyncData); - } - } -} -void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray, - FX_BOOL bNotify, - FX_BOOL bScriptModify, - FX_BOOL bSyncData) { - CFX_WideString wsValue; - int32_t iSize = iSelArray.GetSize(); - if (iSize >= 1) { - CFX_WideStringArray wsSaveTextArray; - GetChoiceListItems(wsSaveTextArray, TRUE); - CFX_WideString wsItemValue; - for (int32_t i = 0; i < iSize; i++) { - wsItemValue = (iSize == 1) - ? wsSaveTextArray[iSelArray[i]] - : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); - wsValue += wsItemValue; - } - } - CFX_WideString wsFormat(wsValue); - 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) { - while (CXFA_Node* pChildNode = - pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { - pBind->RemoveChild(pChildNode); - } - } else { - 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()) { - 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) { - 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, nIndex); - CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); - m_pNode->InsertChild(-1, pSaveItems); - pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); - 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, nIndex); - } else { - InsertListTextItem(pNode, wsLabel, nIndex); - } - } - } else { - CXFA_Node* pNode = listitems[0]; - pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); - pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); - CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); - m_pNode->InsertChild(-1, pSaveItems); - pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); - pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); - listitems.RemoveAll(); - CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - int32_t i = 0; - while (pListNode) { - CFX_WideString wsOldValue; - pListNode->TryContent(wsOldValue); - InsertListTextItem(pSaveItems, wsOldValue, i); - i++; - pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - InsertListTextItem(pNode, wsLabel, nIndex); - InsertListTextItem(pSaveItems, wsNewValue, nIndex); - } - 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); -} -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) { - continue; - } - iCount++; - listitems.Add(pItems); - } - if (iCount <= 1) { - wsLabel = wsValue; - } else { - CXFA_Node* pLabelItems = listitems[0]; - FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); - CXFA_Node* pSaveItems = NULL; - if (bSave) { - pSaveItems = pLabelItems; - pLabelItems = listitems[1]; - } else { - pSaveItems = listitems[1]; - } - iCount = 0; - int32_t iSearch = -1; - CFX_WideString wsContent; - CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pChildItem; - pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pChildItem->TryContent(wsContent); - if (wsContent == wsValue) { - iSearch = iCount; - break; - } - iCount++; - } - 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) { - continue; - } - iCount++; - listitems.Add(pItems); - } - if (iCount <= 1) { - wsValue = wsLabel; - } else { - CXFA_Node* pLabelItems = listitems[0]; - FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); - CXFA_Node* pSaveItems = NULL; - if (bSave) { - pSaveItems = pLabelItems; - pLabelItems = listitems[1]; - } else { - pSaveItems = listitems[1]; - } - iCount = 0; - int32_t iSearch = -1; - CFX_WideString wsContent; - CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pChildItem; - pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pChildItem->TryContent(wsContent); - if (wsContent == wsLabel) { - iSearch = iCount; - break; - } - iCount++; - } - if (iSearch < 0) { - return; - } - 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, - FX_BOOL bSyncData) { - 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) { - continue; - } - if (nIndex < 0) { - while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) { - pItems->RemoveChild(pNode); - } - } else { - if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { - SetItemState(nIndex, FALSE, TRUE, bScriptModify, bSyncData); - bSetValue = TRUE; - } - int32_t i = 0; - CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pNode) { - if (i == nIndex) { - pItems->RemoveChild(pNode); - break; - } - i++; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - } - } - if (!bNotify) { - return TRUE; - } - m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( - this, XFA_WIDGETEVENT_ListItemRemoved, (void*)(uintptr_t)nIndex); - return TRUE; -} -int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() { - CXFA_Node* pUIChild = GetUIChild(); - if (pUIChild) { - return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy); - } - return XFA_ATTRIBUTEENUM_Auto; -} -int32_t CXFA_WidgetData::GetNumberOfCells() { - CXFA_Node* pUIChild = GetUIChild(); - if (!pUIChild) { - return -1; - } - if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) { - return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); - } - return -1; -} -FX_BOOL CXFA_WidgetData::IsDateTimeEditUsePicker() { - return TRUE; -} -CFX_WideString CXFA_WidgetData::GetBarcodeType() { - CXFA_Node* pUIChild = GetUIChild(); - return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { - CXFA_Node* pUIChild = GetUIChild(); - CFX_WideString wsCharEncoding; - if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { - if (wsCharEncoding.CompareNoCase(L"UTF-16")) { - val = CHAR_ENCODING_UNICODE; - return TRUE; - } else 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; - if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) { - switch (eChecksum) { - case XFA_ATTRIBUTEENUM_None: - val = 0; - return TRUE; - case XFA_ATTRIBUTEENUM_Auto: - val = 1; - return TRUE; - case XFA_ATTRIBUTEENUM_1mod10: - break; - case XFA_ATTRIBUTEENUM_1mod10_1mod11: - break; - case XFA_ATTRIBUTEENUM_2mod10: - break; - default: - break; - } - } - 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); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) { - CXFA_Node* pUIChild = GetUIChild(); - CFX_WideStringC wsStartEndChar; - if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { - if (wsStartEndChar.GetLength()) { - val = (FX_CHAR)wsStartEndChar.GetAt(0); - return TRUE; - } - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) { - CXFA_Node* pUIChild = GetUIChild(); - CFX_WideStringC wsStartEndChar; - if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { - if (wsStartEndChar.GetLength()) { - val = (FX_CHAR)wsStartEndChar.GetAt(0); - return TRUE; - } - } - 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); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) { - CXFA_Node* pUIChild = GetUIChild(); - CXFA_Measurement mModuleWidthHeight; - if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) { - val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) { - CXFA_Node* pUIChild = GetUIChild(); - CXFA_Measurement mModuleWidthHeight; - if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) { - val = (int32_t)mModuleWidthHeight.ToUnit(XFA_UNIT_Pt); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) { - CXFA_Node* pUIChild = GetUIChild(); - FX_BOOL bPrintCheckDigit; - if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) { - val = bPrintCheckDigit; - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) { - CXFA_Node* pUIChild = GetUIChild(); - XFA_ATTRIBUTEENUM eTextLocation; - if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) { - switch (eTextLocation) { - case XFA_ATTRIBUTEENUM_None: - val = BC_TEXT_LOC_NONE; - return TRUE; - case XFA_ATTRIBUTEENUM_Above: - val = BC_TEXT_LOC_ABOVE; - return TRUE; - case XFA_ATTRIBUTEENUM_Below: - val = BC_TEXT_LOC_BELOW; - return TRUE; - case XFA_ATTRIBUTEENUM_AboveEmbedded: - val = BC_TEXT_LOC_ABOVEEMBED; - return TRUE; - case XFA_ATTRIBUTEENUM_BelowEmbedded: - val = BC_TEXT_LOC_BELOWEMBED; - return TRUE; - default: - break; - } - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) { - CXFA_Node* pUIChild = GetUIChild(); - FX_BOOL bTruncate; - if (pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate)) { - val = bTruncate; - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) { - CXFA_Node* pUIChild = GetUIChild(); - CFX_WideString wsWideNarrowRatio; - if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) { - FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':'); - FX_FLOAT fRatio = 0; - if (ptPos >= 0) { - fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio); - } else { - int32_t fA, fB; - fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos)); - fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1)); - 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) { - pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord); - } else { - wsPassWord = XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT_PasswordEdit, - XFA_ATTRIBUTE_PasswordChar, - XFA_XDPPACKET_Form); - } -} -FX_BOOL CXFA_WidgetData::IsAllowRichText() { - CXFA_Node* pUIChild = GetUIChild(); - FX_BOOL bValue = FALSE; - if (pUIChild && - pUIChild->TryBoolean(XFA_ATTRIBUTE_AllowRichText, bValue, FALSE)) { - return bValue; - } - if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) { - if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { - return pChild->GetClassID() == XFA_ELEMENT_ExData; - } - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::IsMultiLine() { - CXFA_Node* pUIChild = GetUIChild(); - 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) { - 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)) { - switch (pChild->GetClassID()) { - case XFA_ELEMENT_Text: - eType = XFA_ELEMENT_Text; - return pChild->GetInteger(XFA_ATTRIBUTE_MaxChars); - case XFA_ELEMENT_ExData: { - eType = XFA_ELEMENT_ExData; - int32_t iMax = pChild->GetInteger(XFA_ATTRIBUTE_MaxLength); - return iMax < 0 ? 0 : iMax; - } - default: - break; - } - } - } - 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)) { - 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)) { - 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); - 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()) { - SyncValue(wsValue, TRUE); - return TRUE; - } - m_bPreNull = m_bIsNull; - m_bIsNull = FALSE; - CFX_WideString wsNewText(wsValue); - CFX_WideString wsPicture; - GetPictureContent(wsPicture, eValueType); - FX_BOOL bValidate = TRUE; - FX_BOOL bSyncData = FALSE; - CXFA_Node* pNode = GetUIChild(); - if (!pNode) { - return TRUE; - } - XFA_ELEMENT uiType = pNode->GetClassID(); - if (!wsPicture.IsEmpty()) { - CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); - IFX_Locale* pLocale = GetLocal(); - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); - bValidate = - widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); - if (bValidate) { - widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, - wsPicture, pLocale, pLocalMgr); - wsNewText = widgetValue.GetValue(); - if (uiType == XFA_ELEMENT_NumericEdit) { - int32_t iLeadDigits = 0; - int32_t iFracDigits = 0; - GetLeadDigits(iLeadDigits); - GetFracDigits(iFracDigits); - wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); - } - bSyncData = TRUE; - } - } else { - if (uiType == XFA_ELEMENT_NumericEdit) { - if (wsNewText != FX_WSTRC(L"0")) { - int32_t iLeadDigits = 0; - int32_t iFracDigits = 0; - GetLeadDigits(iLeadDigits); - GetFracDigits(iFracDigits); - wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits); - } - bSyncData = TRUE; - } - } - 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) { - 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)) { - return TRUE; - } - } - } - CFX_WideString wsDataPicture, wsTimePicture; - IFX_Locale* pLocale = GetLocal(); - if (!pLocale) { - return FALSE; - } - FX_DWORD dwType = widgetValue.GetType(); - switch (dwType) { - case XFA_VT_DATE: - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, - wsPicture); - break; - case XFA_VT_TIME: - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, - wsPicture); - break; - case XFA_VT_DATETIME: - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, - wsDataPicture); - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Medium, - wsTimePicture); - wsPicture = wsDataPicture + FX_WSTRC(L"T") + wsTimePicture; - break; - case XFA_VT_DECIMAL: - case XFA_VT_FLOAT: - break; - 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)) { - return TRUE; - } - } - } - { - CFX_WideString wsDataPicture, wsTimePicture; - IFX_Locale* pLocale = GetLocal(); - if (!pLocale) { - return FALSE; - } - FX_DWORD dwType = widgetValue.GetType(); - switch (dwType) { - case XFA_VT_DATE: - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, - wsPicture); - break; - case XFA_VT_TIME: - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, - wsPicture); - break; - case XFA_VT_DATETIME: - pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, - wsDataPicture); - pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Short, - wsTimePicture); - wsPicture = wsDataPicture + L"T" + wsTimePicture; - break; - default: - break; - } - } - } - return TRUE; - case XFA_VALUEPICTURE_DataBind: { - if (CXFA_Bind bind = GetBind()) { - bind.GetPicture(wsPicture); - return TRUE; - } - } break; - default: - break; - } - return FALSE; -} -IFX_Locale* CXFA_WidgetData::GetLocal() { - IFX_Locale* pLocale = NULL; - if (!m_pNode) { - return pLocale; - } - FX_BOOL bLocale = FALSE; - CFX_WideString wsLocaleName; - bLocale = m_pNode->GetLocaleName(wsLocaleName); - if (bLocale) { - if (wsLocaleName.Equal(FX_WSTRC(L"ambient"))) { - pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); - } else { - 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, wsValue); - - CFX_WideString wsPicture; - GetPictureContent(wsPicture, eValueType); - CXFA_Node* pNode = GetUIChild(); - if (!pNode) - return TRUE; - - XFA_ELEMENT uiType = GetUIChild()->GetClassID(); - switch (uiType) { - case XFA_ELEMENT_ChoiceList: { - if (eValueType == XFA_VALUEPICTURE_Display) { - int32_t iSelItemIndex = GetSelectedItem(0); - if (iSelItemIndex >= 0) { - GetChoiceListItem(wsValue, iSelItemIndex); - wsPicture.Empty(); - } - } - } break; - case XFA_ELEMENT_NumericEdit: - if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { - IFX_Locale* pLocale = GetLocal(); - if (eValueType == XFA_VALUEPICTURE_Display && pLocale) { - CFX_WideString wsOutput; - NormalizeNumStr(wsValue, wsOutput); - FormatNumStr(wsOutput, pLocale, wsOutput); - wsValue = wsOutput; - } - } - break; - default: - break; - } - if (wsPicture.IsEmpty()) - return TRUE; - - if (IFX_Locale* pLocale = GetLocal()) { - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); - CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); - switch (widgetValue.GetType()) { - case XFA_VT_DATE: { - CFX_WideString wsDate, wsTime; - if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { - CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); - if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) - return TRUE; - } - break; - } - case XFA_VT_TIME: { - CFX_WideString wsDate, wsTime; - if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { - CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); - if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType)) - return TRUE; - } - break; - } - default: - break; - } - widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType); - } - return TRUE; -} - -FX_BOOL CXFA_WidgetData::GetNormalizeDataValue( - const CFX_WideStringC& wsValue, - CFX_WideString& wsNormalizeValue) { - wsNormalizeValue = wsValue; - if (wsValue.IsEmpty()) { - return TRUE; - } - CFX_WideString wsPicture; - GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); - if (wsPicture.IsEmpty()) { - return TRUE; - } - FXSYS_assert(GetNode()); - CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); - IFX_Locale* pLocale = GetLocal(); - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); - if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) { - widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNormalizeValue, - wsPicture, pLocale, pLocalMgr); - wsNormalizeValue = widgetValue.GetValue(); - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue, - CFX_WideString& wsFormatedValue) { - wsFormatedValue = wsValue; - if (wsValue.IsEmpty()) { - return TRUE; - } - CFX_WideString wsPicture; - GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); - if (wsPicture.IsEmpty()) { - return TRUE; - } - if (IFX_Locale* pLocale = GetLocal()) { - FXSYS_assert(GetNode()); - CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_ELEMENT_Value); - if (!pNodeValue) { - return FALSE; - } - CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pValueChild) { - return FALSE; - } - int32_t iVTType = XFA_VT_NULL; - XFA_ELEMENT eType = pValueChild->GetClassID(); - switch (eType) { - case XFA_ELEMENT_Decimal: - iVTType = XFA_VT_DECIMAL; - break; - case XFA_ELEMENT_Float: - iVTType = XFA_VT_FLOAT; - break; - case XFA_ELEMENT_Date: - iVTType = XFA_VT_DATE; - break; - case XFA_ELEMENT_Time: - iVTType = XFA_VT_TIME; - break; - case XFA_ELEMENT_DateTime: - iVTType = XFA_VT_DATETIME; - break; - case XFA_ELEMENT_Boolean: - iVTType = XFA_VT_BOOLEAN; - break; - case XFA_ELEMENT_Integer: - iVTType = XFA_VT_INTEGER; - break; - case XFA_ELEMENT_Text: - iVTType = XFA_VT_TEXT; - break; - default: - iVTType = XFA_VT_NULL; - break; - } - CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr(); - CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocalMgr); - switch (widgetValue.GetType()) { - case XFA_VT_DATE: { - CFX_WideString wsDate, wsTime; - if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { - CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr); - if (date.FormatPatterns(wsFormatedValue, wsPicture, pLocale, - XFA_VALUEPICTURE_DataBind)) { - return TRUE; - } - } - break; - } - case XFA_VT_TIME: { - CFX_WideString wsDate, wsTime; - if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) { - CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr); - if (time.FormatPatterns(wsFormatedValue, wsPicture, pLocale, - XFA_VALUEPICTURE_DataBind)) { - return TRUE; - } - } - break; - } - default: - break; - } - widgetValue.FormatPatterns(wsFormatedValue, wsPicture, pLocale, - XFA_VALUEPICTURE_DataBind); - } - return FALSE; -} -void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue, - CFX_WideString& wsOutput) { - if (wsValue.IsEmpty()) { - return; - } - wsOutput = wsValue; - wsOutput.TrimLeft('0'); - int32_t dot_index = wsOutput.Find('.'); - int32_t iFracDigits = 0; - if (!wsOutput.IsEmpty() && dot_index >= 0 && - (!GetFracDigits(iFracDigits) || iFracDigits != -1)) { - wsOutput.TrimRight(L"0"); - wsOutput.TrimRight(L"."); - } - 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()) { - return; - } - CFX_WideString wsSrcNum = wsValue; - CFX_WideString wsGroupSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); - FX_BOOL bNeg = FALSE; - if (wsSrcNum[0] == '-') { - bNeg = TRUE; - wsSrcNum.Delete(0, 1); - } - int32_t len = wsSrcNum.GetLength(); - int32_t dot_index = wsSrcNum.Find('.'); - if (dot_index == -1) { - dot_index = len; - } - int32_t cc = dot_index - 1; - if (cc >= 0) { - int nPos = dot_index % 3; - wsOutput.Empty(); - for (int32_t i = 0; i < dot_index; i++) { - if (i % 3 == nPos && i != 0) { - wsOutput += wsGroupSymbol; - } - wsOutput += wsSrcNum[i]; - } - if (dot_index < len) { - CFX_WideString wsSymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); - wsOutput += wsSymbol; - wsOutput += wsSrcNum.Right(len - dot_index - 1); - } - if (bNeg) { - CFX_WideString wsMinusymbol; - pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); - wsOutput = wsMinusymbol + wsOutput; - } - } -} -void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, - FX_BOOL bNotify) { - if (!m_pNode) { - return; - } - CFX_WideString wsFormatValue(wsValue); - CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); - if (pContainerWidgetData) { - pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); - } - m_pNode->SetContent(wsValue, wsFormatValue, bNotify); -} -void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, - const CFX_WideStringC& wsText, - int32_t nIndex) { - CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); - pItems->InsertChild(nIndex, pText); - pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); -} -CXFA_Filter CXFA_WidgetData::GetFilter(FX_BOOL bModified) { - if (!m_pUiChildNode) { - return CXFA_Filter(nullptr); - } - return CXFA_Filter( - m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Filter, bModified)); -} -CXFA_Manifest CXFA_WidgetData::GetManifest(FX_BOOL bModified) { - if (!m_pUiChildNode) { - return CXFA_Manifest(nullptr); - } - return CXFA_Manifest( - m_pUiChildNode->GetProperty(0, XFA_ELEMENT_Manifest, bModified)); -} -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; -} -int32_t CXFA_Occur::GetInitial() { - int32_t iInit = 1; - if (m_pNode) { - int32_t iMin = GetMin(); - if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, TRUE) || - iInit < iMin) { - iInit = iMin; - } - } - return iInit; -} -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); - } -} -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; - } - } - return eType; -} -CFX_WideString CXFA_Filter::GetFilterString(XFA_ATTRIBUTE eAttribute) { - CFX_WideString wsStringValue; - if (m_pNode) { - m_pNode->GetAttribute(eAttribute, wsStringValue, FALSE); - } - return wsStringValue; -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetAppearanceFilterType() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Optional; - } - CXFA_Node* pAppearanceFilterNode = - m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); - return XFA_GetEnumTypeAttribute(pAppearanceFilterNode); -} -CFX_WideString CXFA_Filter::GetAppearanceFilterContent() { - CFX_WideString wsContent; - if (m_pNode) { - CXFA_Node* pAppearanceFilterNode = - m_pNode->GetProperty(0, XFA_ELEMENT_AppearanceFilter); - pAppearanceFilterNode->TryContent(wsContent); - } - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetCertificatesCredentialServerPolicy() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Optional; - } - CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); - return XFA_GetEnumTypeAttribute(pCertsNode, - XFA_ATTRIBUTE_CredentialServerPolicy); -} -CFX_WideString CXFA_Filter::GetCertificatesURL() { - CFX_WideString wsURL; - if (m_pNode) { - CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); - pCertsNode->GetAttribute(XFA_ATTRIBUTE_Url, wsURL, FALSE); - } - return wsURL; -} -CFX_WideString CXFA_Filter::GetCertificatesURLPolicy() { - CFX_WideString wsURLPolicy; - if (m_pNode) { - CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); - pCertsNode->GetAttribute(XFA_ATTRIBUTE_UrlPolicy, wsURLPolicy, FALSE); - } - return wsURLPolicy; -} -CXFA_WrapCertificate CXFA_Filter::GetCertificatesEncryption(FX_BOOL bModified) { - if (!m_pNode) { - return CXFA_WrapCertificate(NULL); - } - CXFA_Node* pCertsNode = - m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); - return CXFA_WrapCertificate( - pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Encryption, bModified) - : NULL); -} -CXFA_WrapCertificate CXFA_Filter::GetCertificatesIssuers(FX_BOOL bModified) { - if (!m_pNode) { - return CXFA_WrapCertificate(NULL); - } - CXFA_Node* pCertsNode = - m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); - return CXFA_WrapCertificate( - pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Issuers, bModified) - : NULL); -} -CFX_WideString CXFA_Filter::GetCertificatesKeyUsageString( - XFA_ATTRIBUTE eAttribute) { - if (!m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); - CXFA_Node* pKeyUsageNode = pCertsNode->GetProperty(0, XFA_ELEMENT_KeyUsage); - CFX_WideString wsAttributeValue; - pKeyUsageNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); - return wsAttributeValue; -} -CXFA_Oids CXFA_Filter::GetCertificatesOids() { - if (!m_pNode) { - return CXFA_Oids(NULL); - } - CXFA_Node* pCertsNode = m_pNode->GetProperty(0, XFA_ELEMENT_Certificates); - return CXFA_Oids(pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Oids) - : NULL); -} -CXFA_WrapCertificate CXFA_Filter::GetCertificatesSigning(FX_BOOL bModified) { - if (!m_pNode) { - return CXFA_WrapCertificate(NULL); - } - CXFA_Node* pCertsNode = - m_pNode->GetProperty(0, XFA_ELEMENT_Certificates, bModified); - return CXFA_WrapCertificate( - pCertsNode ? pCertsNode->GetProperty(0, XFA_ELEMENT_Signing, bModified) - : NULL); -} -CXFA_DigestMethods CXFA_Filter::GetDigestMethods(FX_BOOL bModified) { - return CXFA_DigestMethods( - m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_DigestMethods, bModified) - : NULL); -} -CXFA_Encodings CXFA_Filter::GetEncodings(FX_BOOL bModified) { - return CXFA_Encodings( - m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Encodings, bModified) - : NULL); -} -CXFA_EncryptionMethods CXFA_Filter::GetEncryptionMethods(FX_BOOL bModified) { - return CXFA_EncryptionMethods( - m_pNode - ? m_pNode->GetProperty(0, XFA_ELEMENT_EncryptionMethods, bModified) - : NULL); -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetHandlerType() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Optional; - } - CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); - return XFA_GetEnumTypeAttribute(pHandlerNode); -} -CFX_WideString CXFA_Filter::GetHandlerContent() { - CFX_WideString wsContent; - if (m_pNode) { - CXFA_Node* pHandlerNode = m_pNode->GetProperty(0, XFA_ELEMENT_Handler); - pHandlerNode->TryContent(wsContent); - } - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetlockDocumentType() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Optional; - } - CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); - return XFA_GetEnumTypeAttribute(pLockDocNode); -} -CFX_WideString CXFA_Filter::GetlockDocumentContent() { - CFX_WideString wsContent = FX_WSTRC(L"auto"); - if (m_pNode) { - CXFA_Node* pLockDocNode = m_pNode->GetProperty(0, XFA_ELEMENT_LockDocument); - pLockDocNode->TryContent(wsContent); - } - return wsContent; -} -int32_t CXFA_Filter::GetMDPPermissions() { - int32_t iPermissions = 2; - if (m_pNode) { - CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); - if (!pMDPNode->TryInteger(XFA_ATTRIBUTE_Permissions, iPermissions, TRUE)) { - iPermissions = 2; - } - } - return iPermissions; -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetMDPSignatureType() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Filter; - } - CXFA_Node* pMDPNode = m_pNode->GetProperty(0, XFA_ELEMENT_Mdp); - return XFA_GetEnumTypeAttribute(pMDPNode, XFA_ATTRIBUTE_SignatureType, - XFA_ATTRIBUTEENUM_Filter); -} -CXFA_Reasons CXFA_Filter::GetReasons(FX_BOOL bModified) { - return CXFA_Reasons(m_pNode ? m_pNode->GetProperty(0, XFA_ELEMENT_Reasons) - : NULL); -} -CFX_WideString CXFA_Filter::GetTimeStampServer() { - CFX_WideString wsServerURI; - if (m_pNode) { - CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); - pTimeStampNode->GetAttribute(XFA_ATTRIBUTE_Server, wsServerURI, FALSE); - } - return wsServerURI; -} -XFA_ATTRIBUTEENUM CXFA_Filter::GetTimeStampType() { - if (!m_pNode) { - return XFA_ATTRIBUTEENUM_Optional; - } - CXFA_Node* pTimeStampNode = m_pNode->GetProperty(0, XFA_ELEMENT_TimeStamp); - return XFA_GetEnumTypeAttribute(pTimeStampNode); -} -CFX_WideString CXFA_Certificate::GetCertificateName() { - CFX_WideString wsName; - if (m_pNode) { - m_pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - } - return wsName; -} -CFX_WideString CXFA_Certificate::GetCertificateContent() { - CFX_WideString wsContent; - if (m_pNode) { - m_pNode->TryContent(wsContent); - } - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_WrapCertificate::GetType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_WrapCertificate::CountCertificates() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Certificate) : 0; -} -CXFA_Certificate CXFA_WrapCertificate::GetCertificate(int32_t nIndex) { - return CXFA_Certificate( - (nIndex > -1 && m_pNode) - ? m_pNode->GetChild(nIndex, XFA_ELEMENT_Certificate) - : NULL); -} -XFA_ATTRIBUTEENUM CXFA_Oids::GetOidsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_Oids::CountOids() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Oid) : 0; -} -CFX_WideString CXFA_Oids::GetOidContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pOidNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Oid); - if (!pOidNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pOidNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_SubjectDNs::GetSubjectDNsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_SubjectDNs::CountSubjectDNs() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_SubjectDN) : 0; -} -CFX_WideString CXFA_SubjectDNs::GetSubjectDNString(int32_t nIndex, - XFA_ATTRIBUTE eAttribute) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); - if (!pSubjectDNNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsAttributeValue; - pSubjectDNNode->GetAttribute(eAttribute, wsAttributeValue, FALSE); - return wsAttributeValue; -} -CFX_WideString CXFA_SubjectDNs::GetSubjectDNContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pSubjectDNNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_SubjectDN); - if (!pSubjectDNNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pSubjectDNNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_DigestMethods::GetDigestMethodsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_DigestMethods::CountDigestMethods() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_DigestMethod) : 0; -} -CFX_WideString CXFA_DigestMethods::GetDigestMethodContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pDigestMethodNode = - m_pNode->GetChild(nIndex, XFA_ELEMENT_DigestMethod); - if (!pDigestMethodNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pDigestMethodNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_Encodings::GetEncodingsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_Encodings::CountEncodings() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Encoding) : 0; -} -CFX_WideString CXFA_Encodings::GetEncodingContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pEncodingNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Encoding); - if (!pEncodingNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pEncodingNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_EncryptionMethods::GetEncryptionMethodsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_EncryptionMethods::CountEncryptionMethods() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_EncryptionMethod) : 0; -} -CFX_WideString CXFA_EncryptionMethods::GetEncryptionMethodContent( - int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pEncryMethodNode = - m_pNode->GetChild(nIndex, XFA_ELEMENT_EncryptionMethod); - if (!pEncryMethodNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pEncryMethodNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_Reasons::GetReasonsType() { - return XFA_GetEnumTypeAttribute(m_pNode); -} -int32_t CXFA_Reasons::CountReasons() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Reason) : 0; -} -CFX_WideString CXFA_Reasons::GetReasonContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pReasonNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Reason); - if (!pReasonNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pReasonNode->TryContent(wsContent); - return wsContent; -} -XFA_ATTRIBUTEENUM CXFA_Manifest::GetAction() { - return XFA_GetEnumTypeAttribute(m_pNode, XFA_ATTRIBUTE_Action, - XFA_ATTRIBUTEENUM_Include); -} -int32_t CXFA_Manifest::CountReives() { - return m_pNode ? m_pNode->CountChildren(XFA_ELEMENT_Ref) : 0; -} -CFX_WideString CXFA_Manifest::GetRefContent(int32_t nIndex) { - if (nIndex <= -1 || !m_pNode) { - return FX_WSTRC(L""); - } - CXFA_Node* pRefNode = m_pNode->GetChild(nIndex, XFA_ELEMENT_Ref); - if (!pRefNode) { - return FX_WSTRC(L""); - } - CFX_WideString wsContent; - pRefNode->TryContent(wsContent); - return wsContent; -} diff --git a/xfa/src/fxfa/parser/xfa_parser.h b/xfa/src/fxfa/parser/xfa_parser.h deleted file mode 100644 index 814228177c..0000000000 --- a/xfa/src/fxfa/parser/xfa_parser.h +++ /dev/null @@ -1,38 +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_SRC_FXFA_PARSER_XFA_PARSER_H_ -#define XFA_SRC_FXFA_PARSER_XFA_PARSER_H_ - -#include "xfa/src/fxfa/parser/xfa_document.h" - -class IXFA_Parser { - public: - static IXFA_Parser* Create(IXFA_ObjFactory* pFactory, - FX_BOOL bDocumentParser = FALSE); - virtual ~IXFA_Parser() {} - virtual void Release() = 0; - virtual int32_t StartParse(IFX_FileRead* pStream, - XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) = 0; - virtual int32_t DoParse(IFX_Pause* pPause = NULL) = 0; - virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, - IFX_Pause* pPause = NULL) = 0; - virtual void ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) = 0; - virtual IXFA_ObjFactory* GetFactory() const = 0; - virtual CXFA_Node* GetRootNode() const = 0; - virtual IFDE_XMLDoc* GetXMLDoc() const = 0; - virtual void CloseParser() = 0; -}; -class IXFA_DocParser : public IXFA_Parser { - public: - static IXFA_DocParser* Create(IXFA_Notify* pNotify); - virtual CXFA_Document* GetDocument() const = 0; - virtual IXFA_Notify* GetNotify() const = 0; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_PARSER_H_ diff --git a/xfa/src/fxfa/parser/xfa_parser_imp.cpp b/xfa/src/fxfa/parser/xfa_parser_imp.cpp deleted file mode 100644 index a3d4f94089..0000000000 --- a/xfa/src/fxfa/parser/xfa_parser_imp.cpp +++ /dev/null @@ -1,1568 +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/src/fxfa/parser/xfa_parser_imp.h" - -#include "xfa/src/fgas/crt/fgas_codepage.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_basic_imp.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -IXFA_Parser* IXFA_Parser::Create(IXFA_ObjFactory* pFactory, - FX_BOOL bDocumentParser) { - return new CXFA_SimpleParser(pFactory, bDocumentParser); -} -CXFA_SimpleParser::CXFA_SimpleParser(IXFA_ObjFactory* pFactory, - FX_BOOL bDocumentParser) - : m_pXMLParser(nullptr), - m_pXMLDoc(nullptr), - m_pStream(nullptr), - m_pFileRead(nullptr), - m_pFactory(pFactory), - m_pRootNode(nullptr), - m_ePacketID(XFA_XDPPACKET_UNKNOWN), - m_bDocumentParser(bDocumentParser) {} -CXFA_SimpleParser::~CXFA_SimpleParser() { - CloseParser(); -} -void CXFA_SimpleParser::SetFactory(IXFA_ObjFactory* pFactory) { - m_pFactory = pFactory; -} -static IFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( - IFDE_XMLDoc* pXMLDoc, - FX_BOOL bVerifyWellFormness = FALSE) { - if (!pXMLDoc) { - return NULL; - } - IFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); - for (IFDE_XMLNode* pXMLNode = - pXMLFakeRoot->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - if (bVerifyWellFormness) { - for (IFDE_XMLNode* pNextNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); - pNextNode; - pNextNode = pNextNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (pNextNode->GetType() == FDE_XMLNODE_Element) { - return FALSE; - } - } - } - return pXMLNode; - } - } - return NULL; -} -int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, - XFA_XDPPACKET ePacketID) { - CloseParser(); - m_pFileRead = pStream; - m_pStream = IFX_Stream::CreateStream( - pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text); - if (m_pStream == NULL) { - return XFA_PARSESTATUS_StreamErr; - } - FX_WORD wCodePage = m_pStream->GetCodePage(); - if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && - wCodePage != FX_CODEPAGE_UTF8) { - m_pStream->SetCodePage(FX_CODEPAGE_UTF8); - } - m_pXMLDoc = IFDE_XMLDoc::Create(); - if (m_pXMLDoc == NULL) { - return XFA_PARSESTATUS_StatusErr; - } - m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); - if (m_pXMLParser == NULL) { - return XFA_PARSESTATUS_StatusErr; - } - if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { - return XFA_PARSESTATUS_StatusErr; - } - m_ePacketID = ePacketID; - return XFA_PARSESTATUS_Ready; -} -int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { - if (m_pXMLDoc == NULL || m_ePacketID == XFA_XDPPACKET_UNKNOWN) { - return XFA_PARSESTATUS_StatusErr; - } - int32_t iRet = m_pXMLDoc->DoLoad(pPause); - if (iRet < 0) { - return XFA_PARSESTATUS_SyntaxErr; - } - if (iRet < 100) { - return iRet / 2; - } - m_pRootNode = ParseAsXDPPacket(XFA_FDEExtension_GetDocumentNode(m_pXMLDoc), - m_ePacketID); - m_pXMLDoc->CloseXML(); - if (m_pStream) { - m_pStream->Release(); - m_pStream = NULL; - } - if (!m_pRootNode) { - return XFA_PARSESTATUS_StatusErr; - } - return XFA_PARSESTATUS_Done; -} -int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, - IFX_Pause* pPause) { - CloseParser(); - pXMLNode = NULL; - IFX_Stream* pStream = XFA_CreateWideTextRead(wsXML); - if (!pStream) { - return XFA_PARSESTATUS_StreamErr; - } - m_pStream = pStream; - m_pXMLDoc = IFDE_XMLDoc::Create(); - if (m_pXMLDoc == NULL) { - return XFA_PARSESTATUS_StatusErr; - } - CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); - if (pParser == NULL) { - return XFA_PARSESTATUS_StatusErr; - } - - pParser->m_dwCheckStatus = 0x03; - if (!m_pXMLDoc->LoadXML(pParser)) { - return XFA_PARSESTATUS_StatusErr; - } - int32_t iRet = m_pXMLDoc->DoLoad(pPause); - if (iRet < 0 || iRet >= 100) { - m_pXMLDoc->CloseXML(); - } - if (iRet < 0) { - return XFA_PARSESTATUS_SyntaxErr; - } - if (iRet < 100) { - return iRet / 2; - } - if (m_pStream) { - m_pStream->Release(); - m_pStream = NULL; - } - pXMLNode = XFA_FDEExtension_GetDocumentNode(m_pXMLDoc); - return XFA_PARSESTATUS_Done; -} - -void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) { - XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); - if (ePacketID == XFA_XDPPACKET_Datasets) { - if (pXFANode->GetClassID() == XFA_ELEMENT_DataValue) { - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) - continue; - - if (eNodeType == FDE_XMLNODE_Element) { - CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, - XFA_ELEMENT_DataValue); - if (!pXFAChild) - return; - - CFX_WideString wsNodeStr; - ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); - pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); - CFX_WideString wsChildValue; - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, - wsChildValue); - if (!wsChildValue.IsEmpty()) - pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsChildValue); - - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLChild); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - break; - } - } - m_pRootNode = pXFANode; - } else { - m_pRootNode = DataLoader(pXFANode, pXMLNode, TRUE); - } - } else if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { - ParseContentNode(pXFANode, pXMLNode, ePacketID); - m_pRootNode = pXFANode; - } else { - m_pRootNode = NormalLoader(pXFANode, pXMLNode, ePacketID); - } -} - -FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( - IFDE_XMLElement* pNode, - const CFX_WideStringC& wsQualifier, - CFX_WideString& wsNamespaceURI) { - if (!pNode) { - return FALSE; - } - IFDE_XMLNode* pFakeRoot = pNode->GetNodeItem(IFDE_XMLNode::Root); - CFX_WideString wsNSAttribute; - FX_BOOL bRet = FALSE; - if (wsQualifier.IsEmpty()) { - wsNSAttribute = FX_WSTRC(L"xmlns"); - bRet = TRUE; - } else { - wsNSAttribute = FX_WSTRC(L"xmlns:") + wsQualifier; - } - for (; pNode != pFakeRoot; - pNode = (IFDE_XMLElement*)pNode->GetNodeItem(IFDE_XMLNode::Parent)) { - if (pNode->GetType() != FDE_XMLNODE_Element) { - continue; - } - if (pNode->HasAttribute(wsNSAttribute)) { - pNode->GetString(wsNSAttribute, wsNamespaceURI); - return TRUE; - } - } - wsNamespaceURI.Empty(); - return bRet; -} -static inline void XFA_FDEExtension_GetElementTagNamespaceURI( - IFDE_XMLElement* pElement, - CFX_WideString& wsNamespaceURI) { - CFX_WideString wsNodeStr; - pElement->GetNamespacePrefix(wsNodeStr); - if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNodeStr, - wsNamespaceURI)) { - wsNamespaceURI.Empty(); - } -} -static FX_BOOL XFA_FDEExtension_MatchNodeName( - IFDE_XMLNode* pNode, - const CFX_WideStringC& wsLocalTagName, - const CFX_WideStringC& wsNamespaceURIPrefix, - FX_DWORD eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { - if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) { - return FALSE; - } - IFDE_XMLElement* pElement = reinterpret_cast<IFDE_XMLElement*>(pNode); - CFX_WideString wsNodeStr; - pElement->GetLocalTagName(wsNodeStr); - if (wsNodeStr != wsLocalTagName) { - return FALSE; - } - XFA_FDEExtension_GetElementTagNamespaceURI(pElement, wsNodeStr); - if (eMatchFlags & XFA_XDPPACKET_FLAGS_NOMATCH) { - return TRUE; - } - if (eMatchFlags & XFA_XDPPACKET_FLAGS_PREFIXMATCH) { - return wsNodeStr.Left(wsNamespaceURIPrefix.GetLength()) == - wsNamespaceURIPrefix; - } - return wsNodeStr == wsNamespaceURIPrefix; -} -static FX_BOOL XFA_FDEExtension_GetAttributeLocalName( - const CFX_WideStringC& wsAttributeName, - CFX_WideString& wsLocalAttrName) { - CFX_WideString wsAttrName(wsAttributeName); - FX_STRSIZE iFind = wsAttrName.Find(L':', 0); - if (iFind < 0) { - wsLocalAttrName = wsAttrName; - return FALSE; - } else { - wsLocalAttrName = wsAttrName.Right(wsAttrName.GetLength() - iFind - 1); - return TRUE; - } -} -static FX_BOOL XFA_FDEExtension_ResolveAttribute( - IFDE_XMLElement* pElement, - const CFX_WideStringC& wsAttributeName, - CFX_WideString& wsLocalAttrName, - CFX_WideString& wsNamespaceURI) { - CFX_WideString wsAttrName(wsAttributeName); - CFX_WideString wsNSPrefix; - if (XFA_FDEExtension_GetAttributeLocalName(wsAttributeName, - wsLocalAttrName)) { - wsNSPrefix = wsAttrName.Left(wsAttributeName.GetLength() - - wsLocalAttrName.GetLength() - 1); - } - if (wsLocalAttrName == FX_WSTRC(L"xmlns") || - wsNSPrefix == FX_WSTRC(L"xmlns") || wsNSPrefix == FX_WSTRC(L"xml")) { - return FALSE; - } - if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix, - wsNamespaceURI)) { - wsNamespaceURI.Empty(); - return FALSE; - } - return TRUE; -} -static FX_BOOL XFA_FDEExtension_FindAttributeWithNS( - IFDE_XMLElement* pElement, - const CFX_WideStringC& wsLocalAttributeName, - const CFX_WideStringC& wsNamespaceURIPrefix, - CFX_WideString& wsValue, - FX_BOOL bMatchNSAsPrefix = FALSE) { - if (!pElement) { - return FALSE; - } - CFX_WideString wsAttrName; - CFX_WideString wsAttrValue; - CFX_WideString wsAttrNS; - for (int32_t iAttrCount = pElement->CountAttributes(), i = 0; i < iAttrCount; - i++) { - pElement->GetAttribute(i, wsAttrName, wsAttrValue); - FX_STRSIZE iFind = wsAttrName.Find(L':', 0); - CFX_WideString wsNSPrefix; - if (iFind < 0) { - if (wsLocalAttributeName != wsAttrName) { - continue; - } - } else { - if (wsLocalAttributeName != - wsAttrName.Right(wsAttrName.GetLength() - iFind - 1)) { - continue; - } - wsNSPrefix = wsAttrName.Left(iFind); - } - if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix, - wsAttrNS)) { - continue; - } - if (bMatchNSAsPrefix) { - if (wsAttrNS.Left(wsNamespaceURIPrefix.GetLength()) != - wsNamespaceURIPrefix) { - continue; - } - } else { - if (wsAttrNS != wsNamespaceURIPrefix) { - continue; - } - } - wsValue = wsAttrValue; - return TRUE; - } - return FALSE; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - switch (ePacketID) { - case XFA_XDPPACKET_UNKNOWN: - return NULL; - case XFA_XDPPACKET_XDP: - return ParseAsXDPPacket_XDP(pXMLDocumentNode, ePacketID); - case XFA_XDPPACKET_Config: - return ParseAsXDPPacket_Config(pXMLDocumentNode, ePacketID); - case XFA_XDPPACKET_Template: - case XFA_XDPPACKET_Form: - return ParseAsXDPPacket_TemplateForm(pXMLDocumentNode, ePacketID); - case XFA_XDPPACKET_Datasets: - return ParseAsXDPPacket_Data(pXMLDocumentNode, ePacketID); - case XFA_XDPPACKET_Xdc: - return ParseAsXDPPacket_Xdc(pXMLDocumentNode, ePacketID); - case XFA_XDPPACKET_LocaleSet: - case XFA_XDPPACKET_ConnectionSet: - case XFA_XDPPACKET_SourceSet: - return ParseAsXDPPacket_LocaleConnectionSourceSet(pXMLDocumentNode, - ePacketID); - default: - return ParseAsXDPPacket_User(pXMLDocumentNode, ePacketID); - } - return NULL; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - if (!XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, - XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { - return nullptr; - } - CXFA_Node* pXFARootNode = - m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Xfa); - if (!pXFARootNode) { - return nullptr; - } - m_pRootNode = pXFARootNode; - pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"xfa")); - { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLDocumentNode; - int32_t iAttributeCount = pElement->CountAttributes(); - for (int32_t i = 0; i < iAttributeCount; i++) { - CFX_WideString wsAttriName, wsAttriValue; - pElement->GetAttribute(i, wsAttriName, wsAttriValue); - if (wsAttriName == FX_WSTRC(L"uuid")) { - pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, wsAttriValue); - } else if (wsAttriName == FX_WSTRC(L"timeStamp")) { - pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, wsAttriValue); - } - } - } - IFDE_XMLNode* pXMLConfigDOMRoot = nullptr; - CXFA_Node* pXFAConfigDOMRoot = nullptr; - { - for (IFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pChildItem; - pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { - const XFA_PACKETINFO* pPacketInfo = - XFA_GetPacketByIndex(XFA_PACKET_Config); - if (!XFA_FDEExtension_MatchNodeName(pChildItem, pPacketInfo->pName, - pPacketInfo->pURI, - pPacketInfo->eFlags)) { - continue; - } - if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { - return nullptr; - } - pXMLConfigDOMRoot = pChildItem; - pXFAConfigDOMRoot = - ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config); - pXFARootNode->InsertChild(pXFAConfigDOMRoot, NULL); - } - } - IFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; - IFDE_XMLNode* pXMLFormDOMRoot = nullptr; - IFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; - { - for (IFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pChildItem; - pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element) { - continue; - } - if (pChildItem == pXMLConfigDOMRoot) { - continue; - } - IFDE_XMLElement* pElement = - reinterpret_cast<IFDE_XMLElement*>(pChildItem); - CFX_WideString wsPacketName; - pElement->GetLocalTagName(wsPacketName); - const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByName(wsPacketName); - if (pPacketInfo && pPacketInfo->pURI) { - if (!XFA_FDEExtension_MatchNodeName(pElement, pPacketInfo->pName, - pPacketInfo->pURI, - pPacketInfo->eFlags)) { - pPacketInfo = nullptr; - } - } - XFA_XDPPACKET ePacket = - pPacketInfo ? pPacketInfo->eName : XFA_XDPPACKET_USER; - if (ePacket == XFA_XDPPACKET_XDP) { - continue; - } - if (ePacket == XFA_XDPPACKET_Datasets) { - if (pXMLDatasetsDOMRoot) { - return nullptr; - } - pXMLDatasetsDOMRoot = pElement; - } else if (ePacket == XFA_XDPPACKET_Form) { - if (pXMLFormDOMRoot) { - return nullptr; - } - pXMLFormDOMRoot = pElement; - } else if (ePacket == XFA_XDPPACKET_Template) { - if (pXMLTemplateDOMRoot) { - // Found a duplicate template packet. - return nullptr; - } - CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket); - if (pPacketNode) { - pXMLTemplateDOMRoot = pElement; - pXFARootNode->InsertChild(pPacketNode); - } - } else { - CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket); - if (pPacketNode) { - if (pPacketInfo && - (pPacketInfo->eFlags & XFA_XDPPACKET_FLAGS_SUPPORTONE) && - pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) { - return nullptr; - } - pXFARootNode->InsertChild(pPacketNode); - } - } - } - } - if (!pXMLTemplateDOMRoot) { - // No template is found. - return nullptr; - } - if (pXMLDatasetsDOMRoot) { - CXFA_Node* pPacketNode = - ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_XDPPACKET_Datasets); - if (pPacketNode) { - pXFARootNode->InsertChild(pPacketNode); - } - } - if (pXMLFormDOMRoot) { - CXFA_Node* pPacketNode = - ParseAsXDPPacket(pXMLFormDOMRoot, XFA_XDPPACKET_Form); - if (pPacketNode) { - pXFARootNode->InsertChild(pPacketNode); - } - } - pXFARootNode->SetXMLMappingNode(pXMLDocumentNode); - return pXFARootNode; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - if (!XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Config)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Config)->eFlags)) { - return NULL; - } - CXFA_Node* pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_Config, XFA_ELEMENT_Config); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_Config)->pName); - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { - return NULL; - } - pNode->SetXMLMappingNode(pXMLDocumentNode); - return pNode; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - CXFA_Node* pNode = NULL; - if (ePacketID == XFA_XDPPACKET_Template) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Template)->eFlags)) { - pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_Template, XFA_ELEMENT_Template); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); - if (m_bDocumentParser) { - CFX_WideString wsNamespaceURI; - IFDE_XMLElement* pXMLDocumentElement = - (IFDE_XMLElement*)pXMLDocumentNode; - pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); - if (wsNamespaceURI.IsEmpty()) { - pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); - } - pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); - } - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { - return NULL; - } - } - } else if (ePacketID == XFA_XDPPACKET_Form) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { - IFDE_XMLElement* pXMLDocumentElement = (IFDE_XMLElement*)pXMLDocumentNode; - CFX_WideString wsChecksum; - pXMLDocumentElement->GetString(L"checksum", wsChecksum); - if (wsChecksum.GetLength() != 28 || - m_pXMLParser->m_dwCheckStatus != 0x03) { - return NULL; - } - IXFA_ChecksumContext* pChecksum = XFA_Checksum_Create(); - pChecksum->StartChecksum(); - pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0], - m_pXMLParser->m_nSize[0]); - pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1], - m_pXMLParser->m_nSize[1]); - pChecksum->FinishChecksum(); - CFX_ByteString bsCheck; - pChecksum->GetChecksum(bsCheck); - pChecksum->Release(); - if (bsCheck != wsChecksum.UTF8Encode()) { - return NULL; - } - - pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_Form)->pName); - pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum); - CXFA_Node* pTemplateRoot = - m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template); - CXFA_Node* pTemplateChosen = - pTemplateRoot - ? pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform) - : NULL; - FX_BOOL bUseAttribute = TRUE; - if (pTemplateChosen && - pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) != - XFA_ATTRIBUTEENUM_Auto) { - bUseAttribute = FALSE; - } - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, bUseAttribute)) { - return NULL; - } - } - } - if (pNode) { - pNode->SetXMLMappingNode(pXMLDocumentNode); - } - return pNode; -} -static IFDE_XMLNode* XFA_GetDataSetsFromXDP(IFDE_XMLNode* pXMLDocumentNode) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { - return pXMLDocumentNode; - } - if (!XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, - XFA_GetPacketByIndex(XFA_PACKET_XDP)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { - return NULL; - } - for (IFDE_XMLNode* pDatasetsNode = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pDatasetsNode; - pDatasetsNode = pDatasetsNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { - if (!XFA_FDEExtension_MatchNodeName( - pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { - continue; - } - return pDatasetsNode; - } - return NULL; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - IFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); - if (pDatasetsXMLNode) { - CXFA_Node* pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName); - if (!DataLoader(pNode, pDatasetsXMLNode, FALSE)) { - return NULL; - } - pNode->SetXMLMappingNode(pDatasetsXMLNode); - return pNode; - } - IFDE_XMLNode* pDataXMLNode = NULL; - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, FX_WSTRC(L"data"), - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { - ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); - pDataXMLNode = pXMLDocumentNode; - } else { - IFDE_XMLElement* pDataElement = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); - IFDE_XMLNode* pParentXMLNode = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::Parent); - if (pParentXMLNode) { - pParentXMLNode->RemoveChildNode(pXMLDocumentNode); - } - FXSYS_assert(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); - if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); - } - pDataElement->InsertChildNode(pXMLDocumentNode); - pDataXMLNode = pDataElement; - } - if (pDataXMLNode) { - CXFA_Node* pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); - if (!pNode) { - if (pDataXMLNode != pXMLDocumentNode) { - pDataXMLNode->Release(); - } - return NULL; - } - CFX_WideString wsLocalName; - ((IFDE_XMLElement*)pDataXMLNode)->GetLocalTagName(wsLocalName); - pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); - if (!DataLoader(pNode, pDataXMLNode, TRUE)) { - return NULL; - } - pNode->SetXMLMappingNode(pDataXMLNode); - if (pDataXMLNode != pXMLDocumentNode) { - pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); - } - return pNode; - } - return NULL; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - CXFA_Node* pNode = NULL; - if (ePacketID == XFA_XDPPACKET_LocaleSet) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName, - XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->eFlags)) { - pNode = m_pFactory->CreateNode(XFA_XDPPACKET_LocaleSet, - XFA_ELEMENT_LocaleSet); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName); - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { - return NULL; - } - } - } else if (ePacketID == XFA_XDPPACKET_ConnectionSet) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, - XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName, - XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->eFlags)) { - pNode = m_pFactory->CreateNode(XFA_XDPPACKET_ConnectionSet, - XFA_ELEMENT_ConnectionSet); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName); - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { - return NULL; - } - } - } else if (ePacketID == XFA_XDPPACKET_SourceSet) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName, - XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->eFlags)) { - pNode = m_pFactory->CreateNode(XFA_XDPPACKET_SourceSet, - XFA_ELEMENT_SourceSet); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName); - if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID)) { - return NULL; - } - } - } - if (pNode) { - pNode->SetXMLMappingNode(pXMLDocumentNode); - } - return pNode; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - if (XFA_FDEExtension_MatchNodeName( - pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, - XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pURI, - XFA_GetPacketByIndex(XFA_PACKET_Xdc)->eFlags)) { - CXFA_Node* pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_Xdc, XFA_ELEMENT_Xdc); - if (!pNode) { - return NULL; - } - pNode->SetCData(XFA_ATTRIBUTE_Name, - XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName); - pNode->SetXMLMappingNode(pXMLDocumentNode); - return pNode; - } - return NULL; -} -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID) { - CXFA_Node* pNode = - m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Packet); - if (!pNode) { - return NULL; - } - CFX_WideString wsName; - ((IFDE_XMLElement*)pXMLDocumentNode)->GetLocalTagName(wsName); - pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); - if (!UserPacketLoader(pNode, pXMLDocumentNode)) { - return NULL; - } - pNode->SetXMLMappingNode(pXMLDocumentNode); - return pNode; -} -CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc) { - return pXFANode; -} -static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { - wsText.TrimRight(L"\x20\x9\xD\xA"); - return wsText.IsEmpty(); -} -CXFA_Node* CXFA_SimpleParser::DataLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, - FX_BOOL bDoTransform) { - ParseDataGroup(pXFANode, pXMLDoc, XFA_XDPPACKET_Datasets); - return pXFANode; -} -CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, - XFA_XDPPACKET ePacketID, - FX_BOOL bUseAttribute) { - FX_BOOL bOneOfPropertyFound = FALSE; - for (IFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; - CFX_WideString wsTagName; - pXMLElement->GetLocalTagName(wsTagName); - const XFA_ELEMENTINFO* pElemInfo = XFA_GetElementByName(wsTagName); - if (!pElemInfo) { - continue; - } - const XFA_PROPERTY* pPropertyInfo = XFA_GetPropertyOfElement( - pXFANode->GetClassID(), pElemInfo->eName, ePacketID); - if (pPropertyInfo && - ((pPropertyInfo->uFlags & - (XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) { - if (bOneOfPropertyFound) { - break; - } - bOneOfPropertyFound = TRUE; - } - CXFA_Node* pXFAChild = - m_pFactory->CreateNode(ePacketID, pElemInfo->eName); - if (pXFAChild == NULL) { - return NULL; - } - if (ePacketID == XFA_XDPPACKET_Config) { - pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName); - } - FX_BOOL IsNeedValue = TRUE; - for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; - i++) { - CFX_WideString wsAttrQualifiedName; - CFX_WideString wsAttrName; - CFX_WideString wsAttrValue; - pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); - XFA_FDEExtension_GetAttributeLocalName(wsAttrQualifiedName, - wsAttrName); - if (wsAttrName == FX_WSTRC(L"nil") && - wsAttrValue == FX_WSTRC(L"true")) { - IsNeedValue = FALSE; - } - const XFA_ATTRIBUTEINFO* lpAttrInfo = - XFA_GetAttributeByName(wsAttrName); - if (!lpAttrInfo) { - continue; - } - if (!bUseAttribute && lpAttrInfo->eName != XFA_ATTRIBUTE_Name && - lpAttrInfo->eName != XFA_ATTRIBUTE_Save) { - continue; - } - pXFAChild->SetAttribute(lpAttrInfo->eName, wsAttrValue); - } - pXFANode->InsertChild(pXFAChild); - if (pElemInfo->eName == XFA_ELEMENT_Validate || - pElemInfo->eName == XFA_ELEMENT_Locale) { - if (ePacketID == XFA_XDPPACKET_Config) { - ParseContentNode(pXFAChild, pXMLElement, ePacketID); - } else { - NormalLoader(pXFAChild, pXMLElement, ePacketID, bUseAttribute); - } - break; - } - switch (pXFAChild->GetObjectType()) { - case XFA_OBJECTTYPE_ContentNode: - case XFA_OBJECTTYPE_TextNode: - case XFA_OBJECTTYPE_NodeC: - case XFA_OBJECTTYPE_NodeV: - if (IsNeedValue) { - ParseContentNode(pXFAChild, pXMLElement, ePacketID); - } - break; - default: - NormalLoader(pXFAChild, pXMLElement, ePacketID, bUseAttribute); - break; - } - } break; - case FDE_XMLNODE_Instruction: - ParseInstruction(pXFANode, (IFDE_XMLInstruction*)pXMLChild, ePacketID); - break; - default: - break; - } - } - return pXFANode; -} -FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { - if (pRichTextXMLNode) { - CFX_WideString wsNamespaceURI; - XFA_FDEExtension_GetElementTagNamespaceURI(pRichTextXMLNode, - wsNamespaceURI); - if (wsNamespaceURI == FX_WSTRC(L"http://www.w3.org/1999/xhtml")) { - return TRUE; - } - } - return FALSE; -} -class RichTextNodeVisitor { - public: - static inline IFDE_XMLNode* GetFirstChild(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::FirstChild); - } - static inline IFDE_XMLNode* GetNextSibling(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::NextSibling); - } - static inline IFDE_XMLNode* GetParent(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::Parent); - } -}; - -void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, - CFX_WideString& wsOutput) { - for (IFDE_XMLNode* pXMLChild = - pRootXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { - CFX_WideString wsTextData; - ((IFDE_XMLElement*)pXMLChild)->GetTextData(wsTextData); - wsTextData += FX_WSTRC(L"\n"); - wsOutput += wsTextData; - } break; - case FDE_XMLNODE_Text: { - CFX_WideString wsText; - ((IFDE_XMLText*)pXMLChild)->GetText(wsText); - if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { - continue; - } else { - wsOutput = wsText; - } - } break; - case FDE_XMLNODE_CharData: { - CFX_WideString wsCharData; - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsCharData); - if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { - continue; - } else { - wsOutput = wsCharData; - } - } break; - default: - FXSYS_assert(FALSE); - break; - } - } -} - -void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID) { - XFA_ELEMENT element = XFA_ELEMENT_Sharptext; - if (pXFANode->GetClassID() == XFA_ELEMENT_ExData) { - CFX_WideStringC wsContentType = - pXFANode->GetCData(XFA_ATTRIBUTE_ContentType); - if (wsContentType == FX_WSTRC(L"text/html")) - element = XFA_ELEMENT_SharpxHTML; - else if (wsContentType == FX_WSTRC(L"text/xml")) - element = XFA_ELEMENT_Sharpxml; - } - if (element == XFA_ELEMENT_SharpxHTML) - pXFANode->SetXMLMappingNode(pXMLNode); - - CFX_WideString wsValue; - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) - continue; - - if (element == XFA_ELEMENT_SharpxHTML) { - if (eNodeType != FDE_XMLNODE_Element) - break; - - if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsValue); - } else if (element == XFA_ELEMENT_Sharpxml) { - if (eNodeType != FDE_XMLNODE_Element) - break; - XFA_ConvertXMLToPlainText((IFDE_XMLElement*)pXMLChild, wsValue); - } else { - if (eNodeType == FDE_XMLNODE_Element) - break; - if (eNodeType == FDE_XMLNODE_Text) - ((IFDE_XMLText*)pXMLChild)->GetText(wsValue); - else if (eNodeType == FDE_XMLNODE_CharData) - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsValue); - } - break; - } - if (!wsValue.IsEmpty()) { - if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) { - CXFA_Node* pContentRawDataNode = - m_pFactory->CreateNode(ePacketID, element); - FXSYS_assert(pContentRawDataNode); - pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsValue); - pXFANode->InsertChild(pContentRawDataNode); - } else { - pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsValue); - } - } -} - -void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID) { - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; - { - CFX_WideString wsNamespaceURI; - XFA_FDEExtension_GetElementTagNamespaceURI(pXMLElement, - wsNamespaceURI); - if (wsNamespaceURI == - FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || - wsNamespaceURI == - FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || - wsNamespaceURI == - FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance")) { - continue; - } - if (0) { - continue; - } - } - XFA_ELEMENT eNodeType = XFA_ELEMENT_DataModel; - if (eNodeType == XFA_ELEMENT_DataModel) { - CFX_WideString wsDataNodeAttr; - if (XFA_FDEExtension_FindAttributeWithNS( - pXMLElement, FX_WSTRC(L"dataNode"), - FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"), - wsDataNodeAttr)) { - if (wsDataNodeAttr == FX_WSTRC(L"dataGroup")) { - eNodeType = XFA_ELEMENT_DataGroup; - } else if (wsDataNodeAttr == FX_WSTRC(L"dataValue")) { - eNodeType = XFA_ELEMENT_DataValue; - } - } - } - CFX_WideString wsContentType; - if (eNodeType == XFA_ELEMENT_DataModel) { - if (XFA_FDEExtension_FindAttributeWithNS( - pXMLElement, FX_WSTRC(L"contentType"), - FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"), - wsContentType)) { - if (!wsContentType.IsEmpty()) { - eNodeType = XFA_ELEMENT_DataValue; - } - } - } - if (eNodeType == XFA_ELEMENT_DataModel) { - for (IFDE_XMLNode* pXMLDataChild = - pXMLElement->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem( - IFDE_XMLNode::NextSibling)) { - if (pXMLDataChild->GetType() == FDE_XMLNODE_Element) { - if (!XFA_RecognizeRichText((IFDE_XMLElement*)pXMLDataChild)) { - eNodeType = XFA_ELEMENT_DataGroup; - break; - } - } - } - } - if (eNodeType == XFA_ELEMENT_DataModel) { - eNodeType = XFA_ELEMENT_DataValue; - } - CXFA_Node* pXFAChild = - m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); - if (pXFAChild == NULL) { - return; - } - CFX_WideString wsNodeName; - pXMLElement->GetLocalTagName(wsNodeName); - pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName); - FX_BOOL bNeedValue = TRUE; - if (1) { - for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count; - i++) { - CFX_WideString wsAttrQualifiedName; - CFX_WideString wsAttrValue; - CFX_WideString wsAttrName; - CFX_WideString wsAttrNamespaceURI; - pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue); - if (!XFA_FDEExtension_ResolveAttribute( - pXMLElement, wsAttrQualifiedName, wsAttrName, - wsAttrNamespaceURI)) { - continue; - } - if (wsAttrName == FX_WSTRC(L"nil") && - wsAttrValue == FX_WSTRC(L"true")) { - bNeedValue = FALSE; - continue; - } - if (wsAttrNamespaceURI == - FX_WSTRC(L"http://www.xfa.com/schema/xfa-package/") || - wsAttrNamespaceURI == - FX_WSTRC(L"http://www.xfa.org/schema/xfa-package/") || - wsAttrNamespaceURI == - FX_WSTRC(L"http://www.w3.org/2001/XMLSchema-instance") || - wsAttrNamespaceURI == - FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")) { - continue; - } - if (0) { - continue; - } - CXFA_Node* pXFAMetaData = m_pFactory->CreateNode( - XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataValue); - if (pXFAMetaData == NULL) { - return; - } - pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsAttrName); - pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, - wsAttrQualifiedName); - pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsAttrValue); - pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains, - XFA_ATTRIBUTEENUM_MetaData); - pXFAChild->InsertChild(pXFAMetaData); - pXFAMetaData->SetXMLMappingNode(pXMLElement); - pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - } - if (!bNeedValue) { - CFX_WideString wsNilName = FX_WSTRC(L"xsi:nil"); - pXMLElement->RemoveAttribute(wsNilName); - } - } - pXFANode->InsertChild(pXFAChild); - if (eNodeType == XFA_ELEMENT_DataGroup) { - ParseDataGroup(pXFAChild, pXMLElement, ePacketID); - } else { - if (bNeedValue) { - ParseDataValue(pXFAChild, pXMLChild, XFA_XDPPACKET_Datasets); - } - } - pXFAChild->SetXMLMappingNode(pXMLElement); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - } - continue; - case FDE_XMLNODE_CharData: { - IFDE_XMLCharData* pXMLCharData = (IFDE_XMLCharData*)pXMLChild; - CFX_WideString wsCharData; - pXMLCharData->GetCharData(wsCharData); - if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { - continue; - } - CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, - XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { - return; - } - pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData); - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLCharData); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - } - continue; - case FDE_XMLNODE_Text: { - IFDE_XMLText* pXMLText = (IFDE_XMLText*)pXMLChild; - CFX_WideString wsText; - pXMLText->GetText(wsText); - if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { - continue; - } - CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, - XFA_ELEMENT_DataValue); - if (pXFAChild == NULL) { - return; - } - pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText); - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLText); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - } - continue; - case FDE_XMLNODE_Instruction: - continue; - default: - continue; - } - } -} - -void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID) { - CFX_WideTextBuf wsValueTextBuf; - CFX_WideTextBuf wsCurValueTextBuf; - FX_BOOL bMarkAsCompound = FALSE; - IFDE_XMLNode* pXMLCurValueNode = nullptr; - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) - continue; - - CFX_WideString wsText; - if (eNodeType == FDE_XMLNODE_Text) { - ((IFDE_XMLText*)pXMLChild)->GetText(wsText); - if (!pXMLCurValueNode) - pXMLCurValueNode = pXMLChild; - - wsCurValueTextBuf << wsText; - } else if (eNodeType == FDE_XMLNODE_CharData) { - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsText); - if (!pXMLCurValueNode) - pXMLCurValueNode = pXMLChild; - - wsCurValueTextBuf << wsText; - } else if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) { - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsText); - if (!pXMLCurValueNode) - pXMLCurValueNode = pXMLChild; - - wsCurValueTextBuf << wsText; - } else { - bMarkAsCompound = TRUE; - if (pXMLCurValueNode) { - CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); - 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_Value, wsCurValue); - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLCurValueNode); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - wsValueTextBuf << wsCurValue; - wsCurValueTextBuf.Clear(); - } - pXMLCurValueNode = nullptr; - } - CXFA_Node* pXFAChild = - m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); - if (!pXFAChild) - return; - - CFX_WideString wsNodeStr; - ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); - pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); - ParseDataValue(pXFAChild, pXMLChild, ePacketID); - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLChild); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - CFX_WideStringC wsCurValue = pXFAChild->GetCData(XFA_ATTRIBUTE_Value); - wsValueTextBuf << wsCurValue; - } - } - if (pXMLCurValueNode) { - CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); - if (!wsCurValue.IsEmpty()) { - if (bMarkAsCompound) { - 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_Value, wsCurValue); - pXFANode->InsertChild(pXFAChild); - pXFAChild->SetXMLMappingNode(pXMLCurValueNode); - pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE); - } - wsValueTextBuf << wsCurValue; - wsCurValueTextBuf.Clear(); - } - pXMLCurValueNode = nullptr; - } - CFX_WideStringC wsNodeValue = wsValueTextBuf.GetWideString(); - pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue); -} - -void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, - IFDE_XMLInstruction* pXMLInstruction, - XFA_XDPPACKET ePacketID) { - if (!m_bDocumentParser) { - return; - } - CFX_WideString wsTargetName; - pXMLInstruction->GetTargetName(wsTargetName); - if (wsTargetName == FX_WSTRC(L"originalXFAVersion")) { - CFX_WideString wsData; - if (pXMLInstruction->GetData(0, wsData) && - (pXFANode->GetDocument()->RecognizeXFAVersionNumber(wsData) != - XFA_VERSION_UNKNOWN)) { - wsData.Empty(); - if (pXMLInstruction->GetData(1, wsData) && - wsData == FX_WSTRC(L"v2.7-scripting:1")) { - pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, TRUE); - } - } - } else if (wsTargetName == FX_WSTRC(L"acrobat")) { - CFX_WideString wsData; - if (pXMLInstruction->GetData(0, wsData) && - wsData == FX_WSTRC(L"JavaScript")) { - if (pXMLInstruction->GetData(1, wsData) && - wsData == FX_WSTRC(L"strictScoping")) { - pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); - } - } - } -} -void CXFA_SimpleParser::CloseParser() { - if (m_pXMLDoc) { - m_pXMLDoc->Release(); - m_pXMLDoc = NULL; - } - if (m_pStream) { - m_pStream->Release(); - m_pStream = NULL; - } -} -IXFA_DocParser* IXFA_DocParser::Create(IXFA_Notify* pNotify) { - return new CXFA_DocumentParser(pNotify); -} -CXFA_DocumentParser::CXFA_DocumentParser(IXFA_Notify* pNotify) - : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} -CXFA_DocumentParser::~CXFA_DocumentParser() { - CloseParser(); -} -int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, - XFA_XDPPACKET ePacketID) { - CloseParser(); - int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); - if (nRetStatus == XFA_PARSESTATUS_Ready) { - m_pDocument = new CXFA_Document(this); - m_nodeParser.SetFactory(m_pDocument); - } - return nRetStatus; -} -int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { - int32_t nRetStatus = m_nodeParser.DoParse(pPause); - if (nRetStatus >= XFA_PARSESTATUS_Done) { - FXSYS_assert(m_pDocument); - m_pDocument->SetRoot(m_nodeParser.GetRootNode()); - } - return nRetStatus; -} -int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, - IFX_Pause* pPause) { - CloseParser(); - int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); - if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { - m_pDocument = new CXFA_Document(this); - m_nodeParser.SetFactory(m_pDocument); - } - return nRetStatus; -} -void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) { - if (!pXFANode || !pXMLNode) { - return; - } - m_nodeParser.ConstructXFANode(pXFANode, pXMLNode); - CXFA_Node* pRootNode = m_nodeParser.GetRootNode(); - if (m_pDocument && pRootNode) { - m_pDocument->SetRoot(pRootNode); - } -} -void CXFA_DocumentParser::CloseParser() { - if (m_pDocument) { - delete m_pDocument; - m_pDocument = NULL; - } - m_nodeParser.CloseParser(); -} -CXFA_XMLParser::CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream) - : m_nElementStart(0), - m_dwCheckStatus(0), - m_dwCurrentCheckStatus(0), - m_pRoot(pRoot), - m_pStream(pStream), - m_pParser(nullptr), - m_pParent(pRoot), - m_pChild(nullptr), - m_NodeStack(16), - m_dwStatus(FDE_XMLSYNTAXSTATUS_None) { - ASSERT(m_pParent && m_pStream); - m_NodeStack.Push(m_pParent); - m_pParser = IFDE_XMLSyntaxParser::Create(); - m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); -} -CXFA_XMLParser::~CXFA_XMLParser() { - if (m_pParser) { - m_pParser->Release(); - } - m_NodeStack.RemoveAll(); - m_ws1.Empty(); - m_ws2.Empty(); -} -int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error) { - return -1; - } - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { - return 100; - } - int32_t iCount = 0; - while (TRUE) { - m_dwStatus = m_pParser->DoSyntaxParse(); - switch (m_dwStatus) { - case FDE_XMLSYNTAXSTATUS_InstructionOpen: - break; - case FDE_XMLSYNTAXSTATUS_InstructionClose: - if (m_pChild) { - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - break; - } - } - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_ElementOpen: - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 2) { - m_nElementStart = m_pParser->GetCurrentPos() - 1; - } - break; - case FDE_XMLSYNTAXSTATUS_ElementBreak: - break; - case FDE_XMLSYNTAXSTATUS_ElementClose: - if (m_pChild->GetType() != FDE_XMLNODE_Element) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_pParser->GetTagName(m_ws1); - ((IFDE_XMLElement*)m_pChild)->GetTagName(m_ws2); - if (m_ws1.GetLength() > 0 && !m_ws1.Equal(m_ws2)) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - break; - } - m_NodeStack.Pop(); - if (m_NodeStack.GetSize() < 1) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - break; - } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.GetSize() == 2) { - m_nSize[m_dwCurrentCheckStatus - 1] = - m_pParser->GetCurrentBinaryPos() - - m_nStart[m_dwCurrentCheckStatus - 1]; - m_dwCurrentCheckStatus = 0; - } - - m_pParent = (IFDE_XMLNode*)*m_NodeStack.GetTopElement(); - m_pChild = m_pParent; - iCount++; - break; - case FDE_XMLSYNTAXSTATUS_TargetName: - m_pParser->GetTargetName(m_ws1); - if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || - m_ws1 == FX_WSTRC(L"acrobat")) { - m_pChild = IFDE_XMLInstruction::Create(m_ws1); - m_pParent->InsertChildNode(m_pChild); - } else { - m_pChild = NULL; - } - m_ws1.Empty(); - break; - case FDE_XMLSYNTAXSTATUS_TagName: - m_pParser->GetTagName(m_ws1); - m_pChild = IFDE_XMLElement::Create(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_NodeStack.Push(m_pChild); - m_pParent = m_pChild; - - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 3) { - CFX_WideString wsTag; - ((IFDE_XMLElement*)m_pChild)->GetLocalTagName(wsTag); - if (wsTag == FX_WSTRC(L"template")) { - m_dwCheckStatus |= 0x01; - m_dwCurrentCheckStatus = 0x01; - m_nStart[0] = m_pParser->GetCurrentBinaryPos() - - (m_pParser->GetCurrentPos() - m_nElementStart); - } else if (wsTag == FX_WSTRC(L"datasets")) { - m_dwCheckStatus |= 0x02; - m_dwCurrentCheckStatus = 0x02; - m_nStart[1] = m_pParser->GetCurrentBinaryPos() - - (m_pParser->GetCurrentPos() - m_nElementStart); - } - } - break; - case FDE_XMLSYNTAXSTATUS_AttriName: - m_pParser->GetAttributeName(m_ws1); - break; - case FDE_XMLSYNTAXSTATUS_AttriValue: - if (m_pChild) { - m_pParser->GetAttributeName(m_ws2); - if (m_pChild->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)m_pChild)->SetString(m_ws1, m_ws2); - } - } - m_ws1.Empty(); - break; - case FDE_XMLSYNTAXSTATUS_Text: - m_pParser->GetTextData(m_ws1); - m_pChild = IFDE_XMLText::Create(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_CData: - m_pParser->GetTextData(m_ws1); - m_pChild = IFDE_XMLCharData::Create(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XMLSYNTAXSTATUS_TargetData: - if (m_pChild) { - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { - m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; - break; - } - if (!m_ws1.IsEmpty()) { - ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); - } - m_pParser->GetTargetData(m_ws1); - ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); - } - m_ws1.Empty(); - break; - default: - break; - } - if (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || - m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) { - break; - } - if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { - break; - } - } - return (m_dwStatus == FDE_XMLSYNTAXSTATUS_Error || m_NodeStack.GetSize() != 1) - ? -1 - : m_pParser->GetStatus(); -} diff --git a/xfa/src/fxfa/parser/xfa_parser_imp.h b/xfa/src/fxfa/parser/xfa_parser_imp.h deleted file mode 100644 index f288bc0930..0000000000 --- a/xfa/src/fxfa/parser/xfa_parser_imp.h +++ /dev/null @@ -1,138 +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_SRC_FXFA_PARSER_XFA_PARSER_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_PARSER_IMP_H_ - -#include "xfa/src/fxfa/parser/xfa_parser.h" - -class CXFA_XMLParser; - -class CXFA_SimpleParser : public IXFA_Parser { - public: - CXFA_SimpleParser(IXFA_ObjFactory* pFactory, FX_BOOL bDocumentParser = FALSE); - ~CXFA_SimpleParser(); - virtual void Release() { delete this; } - - virtual int32_t StartParse(IFX_FileRead* pStream, - XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); - virtual int32_t DoParse(IFX_Pause* pPause = NULL); - virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, - IFX_Pause* pPause = NULL); - virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); - virtual IXFA_ObjFactory* GetFactory() const { return m_pFactory; } - virtual CXFA_Node* GetRootNode() const { return m_pRootNode; } - virtual IFDE_XMLDoc* GetXMLDoc() const { return m_pXMLDoc; } - virtual void CloseParser(); - - protected: - CXFA_Node* ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_XDP(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Config(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_TemplateForm(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Data(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet( - IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Xdc(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_User(IFDE_XMLNode* pXMLDocumentNode, - XFA_XDPPACKET ePacketID); - CXFA_Node* NormalLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, - XFA_XDPPACKET ePacketID, - FX_BOOL bUseAttribute = TRUE); - CXFA_Node* DataLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, - FX_BOOL bDoTransform); - CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc); - void ParseContentNode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID); - void ParseDataValue(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID); - void ParseDataGroup(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, - XFA_XDPPACKET ePacketID); - void ParseInstruction(CXFA_Node* pXFANode, - IFDE_XMLInstruction* pXMLInstruction, - XFA_XDPPACKET ePacketID); - void SetFactory(IXFA_ObjFactory* pFactory); - - CXFA_XMLParser* m_pXMLParser; - IFDE_XMLDoc* m_pXMLDoc; - IFX_Stream* m_pStream; - IFX_FileRead* m_pFileRead; - IXFA_ObjFactory* m_pFactory; - CXFA_Node* m_pRootNode; - XFA_XDPPACKET m_ePacketID; - FX_BOOL m_bDocumentParser; - friend class CXFA_DocumentParser; -}; - -class CXFA_DocumentParser : public IXFA_DocParser { - public: - CXFA_DocumentParser(IXFA_Notify* pNotify); - ~CXFA_DocumentParser(); - virtual void Release() { delete this; } - virtual int32_t StartParse(IFX_FileRead* pStream, - XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); - virtual int32_t DoParse(IFX_Pause* pPause = NULL); - virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, - IFX_Pause* pPause = NULL); - virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); - virtual IXFA_ObjFactory* GetFactory() const { - return m_nodeParser.GetFactory(); - } - virtual CXFA_Node* GetRootNode() const { return m_nodeParser.GetRootNode(); } - virtual IFDE_XMLDoc* GetXMLDoc() const { return m_nodeParser.GetXMLDoc(); } - virtual IXFA_Notify* GetNotify() const { return m_pNotify; } - virtual CXFA_Document* GetDocument() const { return m_pDocument; } - virtual void CloseParser(); - - protected: - CXFA_SimpleParser m_nodeParser; - IXFA_Notify* m_pNotify; - CXFA_Document* m_pDocument; -}; -typedef CFX_StackTemplate<IFDE_XMLNode*> CXFA_XMLNodeStack; - -class CXFA_XMLParser : public IFDE_XMLParser { - public: - CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream); - ~CXFA_XMLParser(); - - virtual void Release() { delete this; } - virtual int32_t DoParser(IFX_Pause* pPause); - - FX_FILESIZE m_nStart[2]; - size_t m_nSize[2]; - FX_FILESIZE m_nElementStart; - FX_WORD m_dwCheckStatus; - FX_WORD m_dwCurrentCheckStatus; - - protected: - IFDE_XMLNode* m_pRoot; - IFX_Stream* m_pStream; - IFDE_XMLSyntaxParser* m_pParser; - - IFDE_XMLNode* m_pParent; - IFDE_XMLNode* m_pChild; - CXFA_XMLNodeStack m_NodeStack; - CFX_WideString m_ws1; - CFX_WideString m_ws2; - FX_DWORD m_dwStatus; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_PARSER_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_script.h b/xfa/src/fxfa/parser/xfa_script.h deleted file mode 100644 index 286e8f704e..0000000000 --- a/xfa/src/fxfa/parser/xfa_script.h +++ /dev/null @@ -1,121 +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_SRC_FXFA_PARSER_XFA_SCRIPT_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_H_ - -#include "xfa/include/fxfa/fxfa.h" -#include "xfa/include/fxfa/fxfa_objectacc.h" - -#define XFA_RESOLVENODE_Children 0x0001 -#define XFA_RESOLVENODE_Attributes 0x0004 -#define XFA_RESOLVENODE_Properties 0x0008 -#define XFA_RESOLVENODE_Siblings 0x0020 -#define XFA_RESOLVENODE_Parent 0x0040 -#define XFA_RESOLVENODE_AnyChild 0x0080 -#define XFA_RESOLVENODE_ALL 0x0100 -#define XFA_RESOLVENODE_CreateNode 0x0400 -#define XFA_RESOLVENODE_Bind 0x0800 -#define XFA_RESOLVENODE_BindNew 0x1000 - -enum XFA_SCRIPTLANGTYPE { - XFA_SCRIPTLANGTYPE_Formcalc = XFA_SCRIPTTYPE_Formcalc, - XFA_SCRIPTLANGTYPE_Javascript = XFA_SCRIPTTYPE_Javascript, - XFA_SCRIPTLANGTYPE_Unkown = XFA_SCRIPTTYPE_Unkown, -}; - -enum XFA_RESOVENODE_RSTYPE { - XFA_RESOVENODE_RSTYPE_Nodes, - XFA_RESOVENODE_RSTYPE_Attribute, - XFA_RESOLVENODE_RSTYPE_CreateNodeOne, - XFA_RESOLVENODE_RSTYPE_CreateNodeAll, - XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll, - XFA_RESOVENODE_RSTYPE_ExistNodes, -}; - -class CXFA_HVALUEArray : public CFX_ArrayTemplate<FXJSE_HVALUE> { - public: - CXFA_HVALUEArray(FXJSE_HRUNTIME hRunTime) : m_hRunTime(hRunTime) {} - ~CXFA_HVALUEArray() { - for (int32_t i = 0; i < GetSize(); i++) { - FXJSE_Value_Release(GetAt(i)); - } - } - void GetAttributeObject(CXFA_ObjArray& objArray) { - for (int32_t i = 0; i < GetSize(); i++) { - CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(GetAt(i), NULL); - objArray.Add(pObject); - } - } - FXJSE_HRUNTIME m_hRunTime; -}; - -struct XFA_RESOLVENODE_RS { - XFA_RESOLVENODE_RS() - : dwFlags(XFA_RESOVENODE_RSTYPE_Nodes), pScriptAttribute(NULL) {} - ~XFA_RESOLVENODE_RS() { nodes.RemoveAll(); } - int32_t GetAttributeResult(CXFA_HVALUEArray& hValueArray) const { - if (pScriptAttribute && pScriptAttribute->eValueType == XFA_SCRIPT_Object) { - FXJSE_HRUNTIME hRunTime = hValueArray.m_hRunTime; - for (int32_t i = 0; i < nodes.GetSize(); i++) { - FXJSE_HVALUE hValue = FXJSE_Value_Create(hRunTime); - (nodes[i]->*(pScriptAttribute->lpfnCallback))( - hValue, FALSE, (XFA_ATTRIBUTE)pScriptAttribute->eAttribute); - hValueArray.Add(hValue); - } - } - return hValueArray.GetSize(); - } - - CXFA_ObjArray nodes; - XFA_RESOVENODE_RSTYPE dwFlags; - const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute; -}; - -struct XFA_JSBUILTININFO { - uint32_t uUnicodeHash; - const FX_CHAR* pName; -}; - -const XFA_JSBUILTININFO* XFA_GetJSBuiltinByHash(uint32_t uHashCode); - -class IXFA_ScriptContext { - public: - virtual ~IXFA_ScriptContext() {} - virtual void Release() = 0; - virtual void Initialize(FXJSE_HRUNTIME hRuntime) = 0; - - virtual void SetEventParam(CXFA_EventParam param) = 0; - virtual CXFA_EventParam* GetEventParam() = 0; - virtual FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - CXFA_Object* pThisObject = NULL) = 0; - virtual int32_t ResolveObjects(CXFA_Object* refNode, - const CFX_WideStringC& wsExpression, - XFA_RESOLVENODE_RS& resolveNodeRS, - FX_DWORD dwStyles = XFA_RESOLVENODE_Children, - CXFA_Node* bindNode = NULL) = 0; - virtual FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject) = 0; - virtual void CacheList(CXFA_NodeList* pList) = 0; - virtual CXFA_Object* GetThisObject() const = 0; - virtual FXJSE_HRUNTIME GetRuntime() const = 0; - virtual int32_t GetIndexByName(CXFA_Node* refNode) = 0; - virtual int32_t GetIndexByClassName(CXFA_Node* refNode) = 0; - virtual void GetSomExpression(CXFA_Node* refNode, - CFX_WideString& wsExpression) = 0; - - virtual void SetNodesOfRunScript(CXFA_NodeArray* pArray) = 0; - virtual void AddNodesOfRunScript(const CXFA_NodeArray& nodes) = 0; - virtual void AddNodesOfRunScript(CXFA_Node* pNode) = 0; - virtual FXJSE_HCLASS GetJseNormalClass() = 0; - virtual XFA_SCRIPTLANGTYPE GetType() = 0; - virtual void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) = 0; - virtual FX_BOOL IsRunAtClient() = 0; -}; -IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument); - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_datawindow.cpp b/xfa/src/fxfa/parser/xfa_script_datawindow.cpp deleted file mode 100644 index 33146adcd0..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_datawindow.cpp +++ /dev/null @@ -1,47 +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/src/fxfa/parser/xfa_script_datawindow.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_DataWindow) { - m_uScriptHash = XFA_HASHCODE_DataWindow; -} -CScript_DataWindow::~CScript_DataWindow() {} -void CScript_DataWindow::Script_DataWindow_MoveCurrentRecord( - CFXJSE_Arguments* pArguments) {} -void CScript_DataWindow::Script_DataWindow_Record( - CFXJSE_Arguments* pArguments) {} -void CScript_DataWindow::Script_DataWindow_GotoRecord( - CFXJSE_Arguments* pArguments) {} -void CScript_DataWindow::Script_DataWindow_IsRecordGroup( - CFXJSE_Arguments* pArguments) {} -void CScript_DataWindow::Script_DataWindow_RecordsBefore( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CScript_DataWindow::Script_DataWindow_CurrentRecordNumber( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CScript_DataWindow::Script_DataWindow_RecordsAfter( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) {} -void CScript_DataWindow::Script_DataWindow_IsDefined(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { -} diff --git a/xfa/src/fxfa/parser/xfa_script_datawindow.h b/xfa/src/fxfa/parser/xfa_script_datawindow.h deleted file mode 100644 index 2639d3c5d3..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_datawindow.h +++ /dev/null @@ -1,34 +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_SRC_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_ - -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CScript_DataWindow : public CXFA_OrdinaryObject { - public: - CScript_DataWindow(CXFA_Document* pDocument); - virtual ~CScript_DataWindow(); - void Script_DataWindow_MoveCurrentRecord(CFXJSE_Arguments* pArguments); - void Script_DataWindow_Record(CFXJSE_Arguments* pArguments); - void Script_DataWindow_GotoRecord(CFXJSE_Arguments* pArguments); - void Script_DataWindow_IsRecordGroup(CFXJSE_Arguments* pArguments); - void Script_DataWindow_RecordsBefore(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_DataWindow_CurrentRecordNumber(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_DataWindow_RecordsAfter(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_DataWindow_IsDefined(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.cpp deleted file mode 100644 index 8c8cd5214e..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.cpp +++ /dev/null @@ -1,269 +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/src/fxfa/parser/xfa_script_eventpseudomodel.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_EventPseudoModel) { - m_uScriptHash = XFA_HASHCODE_Event; -} -CScript_EventPseudoModel::~CScript_EventPseudoModel() {} -void Script_EventPseudoModel_StringProperty(FXJSE_HVALUE hValue, - CFX_WideString& wsValue, - FX_BOOL bSetting) { - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()); - } else { - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); - } -} -void Script_EventPseudoModel_InterProperty(FXJSE_HVALUE hValue, - int32_t& iValue, - FX_BOOL bSetting) { - if (bSetting) { - iValue = FXJSE_Value_ToInteger(hValue); - } else { - FXJSE_Value_SetInteger(hValue, iValue); - } -} -void Script_EventPseudoModel_BooleanProperty(FXJSE_HVALUE hValue, - FX_BOOL& bValue, - FX_BOOL bSetting) { - if (bSetting) { - bValue = FXJSE_Value_ToBoolean(hValue); - } else { - FXJSE_Value_SetBoolean(hValue, bValue); - } -} -void CScript_EventPseudoModel::Script_EventPseudoModel_Property( - FXJSE_HVALUE hValue, - FX_DWORD dwFlag, - FX_BOOL bSetting) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - switch (dwFlag) { - case XFA_EVENT_CANCELACTION: - Script_EventPseudoModel_BooleanProperty( - hValue, pEventParam->m_bCancelAction, bSetting); - break; - case XFA_EVENT_CHANGE: - Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsChange, - bSetting); - break; - case XFA_EVENT_COMMITKEY: - Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iCommitKey, - bSetting); - break; - case XFA_EVENT_FULLTEXT: - Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsFullText, - bSetting); - break; - case XFA_EVENT_KEYDOWN: - Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bKeyDown, - bSetting); - break; - case XFA_EVENT_MODIFIER: - Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bModifier, - bSetting); - break; - case XFA_EVENT_NEWCONTENTTYPE: - Script_EventPseudoModel_StringProperty( - hValue, pEventParam->m_wsNewContentType, bSetting); - break; - case XFA_EVENT_NEWTEXT: - Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsNewText, - bSetting); - break; - case XFA_EVENT_PREVCONTENTTYPE: - Script_EventPseudoModel_StringProperty( - hValue, pEventParam->m_wsPrevContentType, bSetting); - break; - case XFA_EVENT_PREVTEXT: - Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsPrevText, - bSetting); - break; - case XFA_EVENT_REENTER: - Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bReenter, - bSetting); - break; - case XFA_EVENT_SELEND: - Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelEnd, - bSetting); - break; - case XFA_EVENT_SELSTART: - Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelStart, - bSetting); - break; - case XFA_EVENT_SHIFT: - Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bShift, - bSetting); - break; - case XFA_EVENT_SOAPFAULTCODE: - Script_EventPseudoModel_StringProperty( - hValue, pEventParam->m_wsSoapFaultCode, bSetting); - break; - case XFA_EVENT_SOAPFAULTSTRING: - Script_EventPseudoModel_StringProperty( - hValue, pEventParam->m_wsSoapFaultString, bSetting); - break; - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_CommitKey( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_KeyDown( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_NewContentType( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_PrevContentType( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVCONTENTTYPE, bSetting); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_PrevText( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVTEXT, bSetting); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_Reenter( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_SelStart( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELSTART, bSetting); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_Shift( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultString( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - 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); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_Emit( - CFXJSE_Arguments* pArguments) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_WidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); - if (!pWidgetHandler) { - return; - } - pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); -} -void CScript_EventPseudoModel::Script_EventPseudoModel_Reset( - CFXJSE_Arguments* pArguments) { - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - pEventParam->Reset(); -} diff --git a/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h b/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h deleted file mode 100644 index 770ec2e4b9..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_eventpseudomodel.h +++ /dev/null @@ -1,96 +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_SRC_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_ - -#include "xfa/src/fxfa/parser/xfa_object.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 - -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); - void Script_EventPseudoModel_CommitKey(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_FullText(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_KeyDown(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_Modifier(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_NewContentType(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_NewText(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_PrevContentType(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_PrevText(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_Reenter(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_SelEnd(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_SelStart(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_Shift(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_SoapFaultCode(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_SoapFaultString(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_EventPseudoModel_Target(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - - void Script_EventPseudoModel_Emit(CFXJSE_Arguments* pArguments); - void Script_EventPseudoModel_Reset(CFXJSE_Arguments* pArguments); - - protected: - void Script_EventPseudoModel_Property(FXJSE_HVALUE hValue, - FX_DWORD dwFlag, - FX_BOOL bSetting); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.cpp deleted file mode 100644 index 4e5be8f3c4..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.cpp +++ /dev/null @@ -1,800 +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/src/fxfa/parser/xfa_script_hostpseudomodel.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_HostPseudoModel) { - m_uScriptHash = XFA_HASHCODE_Host; -} -CScript_HostPseudoModel::~CScript_HostPseudoModel() {} -void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString( - FXJSE_HVALUE hValue, - IXFA_Notify* pNotify, - FX_DWORD dwFlag) { - CFX_WideString wsValue; - pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_AppType( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CFX_WideString wsAppType; - pNotify->GetAppProvider()->GetAppType(wsAppType); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CFX_WideString wsAppType; - pNotify->GetAppProvider()->GetFoxitAppType(wsAppType); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - pNotify->GetDocProvider()->SetCalculationsEnabled( - hDoc, FXJSE_Value_ToBoolean(hValue)); - return; - } - FX_BOOL bEnabled = pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc); - FXJSE_Value_SetBoolean(hValue, bEnabled); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentPage( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - pNotify->GetDocProvider()->SetCurrentPage(hDoc, - FXJSE_Value_ToInteger(hValue)); - return; - } - int32_t iCurrentPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); - FXJSE_Value_SetInteger(hValue, iCurrentPage); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Language( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_LANGUAGE); - return; - } - CFX_WideString wsLanguage; - pNotify->GetAppProvider()->GetLanguage(wsLanguage); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsLanguage)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_NUMPAGES); - return; - } - int32_t iNumPages = pNotify->GetDocProvider()->CountPages(hDoc); - FXJSE_Value_SetInteger(hValue, iNumPages); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Platform( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_PLATFORM); - return; - } - CFX_WideString wsPlatform; - pNotify->GetAppProvider()->GetPlatform(wsPlatform); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsPlatform)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Title( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - CFX_ByteString bsValue; - FXJSE_Value_ToUTF8String(hValue, bsValue); - pNotify->GetDocProvider()->SetTitle( - hDoc, CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); - return; - } - CFX_WideString wsTitle; - pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsTitle)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - pNotify->GetDocProvider()->SetValidationsEnabled( - hDoc, FXJSE_Value_ToBoolean(hValue)); - return; - } - FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); - FXJSE_Value_SetBoolean(hValue, bEnabled); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Variation( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VARIATION); - return; - } - CFX_WideString wsVariation; - pNotify->GetAppProvider()->GetVariation(wsVariation); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVariation)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Version( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); - return; - } - CFX_WideString wsVersion; - pNotify->GetAppProvider()->GetVersion(wsVersion); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_VERSION); - return; - } - CFX_WideString wsVersion; - pNotify->GetAppProvider()->GetFoxitVersion(wsVersion); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Name( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CFX_WideString wsAppName; - pNotify->GetAppProvider()->GetAppName(wsAppName); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppName)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); - return; - } - CFX_WideString wsFoxitAppName; - pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName); - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsFoxitAppName)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CFX_WideString wsURL; - if (iLength >= 1) { - CFX_ByteString bsURL = pArguments->GetUTF8String(0); - wsURL = CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()); - } - pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - FXJSE_HVALUE hValue = pArguments->GetValue(0); - if (FXJSE_Value_IsObject(hValue)) { - pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, nullptr)); - } else if (FXJSE_Value_IsUTF8String(hValue)) { - CFX_ByteString bsString; - FXJSE_Value_ToUTF8String(hValue, bsString); - CFX_WideString wsExpression = - CFX_WideString::FromUTF8(bsString, bsString.GetLength()); - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - FXJSE_Value_Release(hValue); - return; - } - CXFA_Object* pObject = pScriptContext->GetThisObject(); - if (!pObject) { - FXJSE_Value_Release(hValue); - return; - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, - resoveNodeRS, dwFlag); - if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { - FXJSE_Value_Release(hValue); - return; - } - pNode = resoveNodeRS.nodes[0]->AsNode(); - } - FXJSE_Value_Release(hValue); - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); - if (!hWidget) { - return; - } - pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); - pNotify->OpenDropDownList(hWidget); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Response( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CFX_WideString wsQuestion; - CFX_WideString wsTitle; - CFX_WideString wsDefaultAnswer; - FX_BOOL bMark = FALSE; - if (iLength >= 1) { - CFX_ByteString bsQuestion = pArguments->GetUTF8String(0); - wsQuestion = CFX_WideString::FromUTF8(bsQuestion, bsQuestion.GetLength()); - } - if (iLength >= 2) { - CFX_ByteString bsTitle = pArguments->GetUTF8String(1); - wsTitle = CFX_WideString::FromUTF8(bsTitle, bsTitle.GetLength()); - } - if (iLength >= 3) { - CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); - wsDefaultAnswer = - CFX_WideString::FromUTF8(bsDefaultAnswer, bsDefaultAnswer.GetLength()); - } - if (iLength >= 4) { - bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; - } - CFX_WideString wsAnswer; - pNotify->GetAppProvider()->Response(wsAnswer, wsQuestion, wsTitle, - wsDefaultAnswer, bMark); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer)); - } -} -void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - int32_t iCur = pNotify->GetAppProvider()->GetCurDocumentInBatch(); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iCur); - } -} -static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, - int32_t nStart, - CFX_WideString& wsFilter) { - FXSYS_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.GetPtr(); - FX_WCHAR wCur; - while (nStart < iLength) { - wCur = pSrc[nStart++]; - if (wCur == ',') { - break; - } - pBuf[nCount++] = wCur; - } - wsFilter.ReleaseBuffer(nCount); - wsFilter.TrimLeft(); - wsFilter.TrimRight(); - return nStart; -} -void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CFX_WideString wsExpression; - if (iLength >= 1) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(0); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - } - if (wsExpression.IsEmpty()) { - pNotify->ResetData(); - return; - } - int32_t iStart = 0; - CFX_WideString wsName; - CXFA_Node* pNode = NULL; - int32_t iExpLength = wsExpression.GetLength(); - while (iStart < iExpLength) { - iStart = XFA_FilterName(wsExpression, iStart, wsName); - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_Object* pObject = pScriptContext->GetThisObject(); - if (!pObject) { - return; - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = - pScriptContext->ResolveObjects(pObject, wsName, resoveNodeRS, dwFlag); - if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { - continue; - } - pNode = resoveNodeRS.nodes[0]->AsNode(); - pNotify->ResetData(pNode->GetWidgetData()); - } - if (!pNode) { - pNotify->ResetData(); - } -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Beep( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - FX_DWORD dwType = 4; - if (iLength >= 1) { - dwType = pArguments->GetInt32(0); - } - pNotify->GetAppProvider()->Beep(dwType); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - FXJSE_HVALUE hValue = pArguments->GetValue(0); - if (FXJSE_Value_IsObject(hValue)) { - pNode = static_cast<CXFA_Node*>(FXJSE_Value_ToObject(hValue, NULL)); - } else if (FXJSE_Value_IsUTF8String(hValue)) { - CFX_ByteString bsString; - FXJSE_Value_ToUTF8String(hValue, bsString); - CFX_WideString wsExpression = - CFX_WideString::FromUTF8(bsString, bsString.GetLength()); - IXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - FXJSE_Value_Release(hValue); - return; - } - CXFA_Object* pObject = pScriptContext->GetThisObject(); - if (!pObject) { - FXJSE_Value_Release(hValue); - return; - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Siblings; - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = pScriptContext->ResolveObjects(pObject, wsExpression, - resoveNodeRS, dwFlag); - if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { - FXJSE_Value_Release(hValue); - return; - } - pNode = resoveNodeRS.nodes[0]->AsNode(); - } - FXJSE_Value_Release(hValue); - } - pNotify->SetFocusWidgetNode(pNode); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_GetFocus( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); - if (!pNode) { - return; - } - FXJSE_Value_Set(pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CFX_WideString wsMessage; - CFX_WideString bsTitle; - FX_DWORD dwMessageType = XFA_MBICON_Error; - FX_DWORD dwButtonType = XFA_MB_OK; - if (iLength >= 1) { - if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 0, wsMessage)) { - return; - } - } - if (iLength >= 2) { - if (!Script_HostPseudoModel_ValidateArgsForMsg(pArguments, 1, bsTitle)) { - return; - } - } - if (iLength >= 3) { - dwMessageType = pArguments->GetInt32(2); - if (dwMessageType > XFA_MBICON_Status) { - dwMessageType = XFA_MBICON_Error; - } - } - if (iLength >= 4) { - dwButtonType = pArguments->GetInt32(3); - if (dwButtonType > XFA_MB_YesNoCancel) { - dwButtonType = XFA_MB_OK; - } - } - int32_t iValue = pNotify->GetAppProvider()->MsgBox( - wsMessage, bsTitle, dwMessageType, dwButtonType); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iValue); - } -} -FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg( - CFXJSE_Arguments* pArguments, - int32_t iArgIndex, - CFX_WideString& wsValue) { - if (pArguments == NULL || iArgIndex < 0) { - return FALSE; - } - FX_BOOL bIsJsType = FALSE; - if (m_pDocument->GetScriptContext()->GetType() == - XFA_SCRIPTLANGTYPE_Javascript) { - bIsJsType = TRUE; - } - FXJSE_HVALUE hValueArg = pArguments->GetValue(iArgIndex); - if (!FXJSE_Value_IsUTF8String(hValueArg) && bIsJsType) { - ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); - FXJSE_Value_Release(hValueArg); - return FALSE; - } - if (FXJSE_Value_IsNull(hValueArg)) { - wsValue = FX_WSTRC(L""); - } else { - CFX_ByteString byMessage; - FXJSE_Value_ToUTF8String(hValueArg, byMessage); - wsValue = CFX_WideString::FromUTF8(byMessage, byMessage.GetLength()); - } - FXJSE_Value_Release(hValueArg); - return TRUE; -} -void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentCountInBatch( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - int32_t iValue = pNotify->GetAppProvider()->GetDocumentCountInBatch(); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iValue); - } -} -void CScript_HostPseudoModel::Script_HostPseudoModel_Print( - CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 8) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - FX_DWORD dwOptions = 0; - FX_BOOL bShowDialog = TRUE; - if (iLength >= 1) { - bShowDialog = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; - } - if (bShowDialog) { - dwOptions |= XFA_PRINTOPT_ShowDialog; - } - int32_t nStartPage = 0; - if (iLength >= 2) { - nStartPage = pArguments->GetInt32(1); - } - int32_t nEndPage = 0; - if (iLength >= 3) { - nEndPage = pArguments->GetInt32(2); - } - FX_BOOL bCanCancel = TRUE; - if (iLength >= 4) { - bCanCancel = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; - } - if (bCanCancel) { - dwOptions |= XFA_PRINTOPT_CanCancel; - } - FX_BOOL bShrinkPage = TRUE; - if (iLength >= 5) { - bShrinkPage = pArguments->GetInt32(4) == 0 ? FALSE : TRUE; - } - if (bShrinkPage) { - dwOptions |= XFA_PRINTOPT_ShrinkPage; - } - FX_BOOL bAsImage = TRUE; - if (iLength >= 6) { - bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; - } - if (bAsImage) { - dwOptions |= XFA_PRINTOPT_AsImage; - } - FX_BOOL bReverseOrder = TRUE; - if (iLength >= 7) { - bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; - } - bReverseOrder = pArguments->GetInt32(6) == 0 ? FALSE : TRUE; - if (bReverseOrder) { - dwOptions |= XFA_PRINTOPT_ReverseOrder; - } - FX_BOOL bPrintAnnot = TRUE; - if (iLength >= 8) { - bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; - } - if (bPrintAnnot) { - dwOptions |= XFA_PRINTOPT_PrintAnnot; - } - pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CFX_WideString wsFilePath; - if (iLength > 0) { - CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); - wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength()); - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CFX_WideString wsFilePath; - FX_BOOL bXDP = TRUE; - if (iLength >= 1) { - CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); - wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength()); - } - if (iLength >= 2) { - bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - } - pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); - int32_t nNewPage = 0; - if (nCurPage <= 1) { - return; - } - nNewPage = nCurPage - 1; - pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_PageDown( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); - int32_t nPageCount = pNotify->GetDocProvider()->CountPages(hDoc); - if (!nPageCount || nCurPage == nPageCount) { - return; - } - int32_t nNewPage = 0; - if (nCurPage >= nPageCount) { - nNewPage = nPageCount - 1; - } else { - nNewPage = nCurPage + 1; - } - pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); -} -void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime)); - } -} diff --git a/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h b/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.h deleted file mode 100644 index 7154a255f6..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_hostpseudomodel.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_SRC_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_ - -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CScript_HostPseudoModel : public CXFA_OrdinaryObject { - public: - CScript_HostPseudoModel(CXFA_Document* pDocument); - virtual ~CScript_HostPseudoModel(); - - void Script_HostPseudoModel_AppType(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_FoxitAppType(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_CalculationsEnabled(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_CurrentPage(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Language(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_NumPages(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Platform(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Title(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_ValidationsEnabled(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Variation(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Version(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_FoxitVersion(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_Name(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_HostPseudoModel_FoxitName(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - - void Script_HostPseudoModel_GotoURL(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_OpenList(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_Response(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_DocumentInBatch(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_ResetData(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_Beep(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_SetFocus(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_GetFocus(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_MessageBox(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_DocumentCountInBatch( - CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_Print(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_ImportData(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_ExportData(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_PageUp(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_PageDown(CFXJSE_Arguments* pArguments); - void Script_HostPseudoModel_CurrentDateTime(CFXJSE_Arguments* pArguments); - - protected: - void Script_HostPseudoModel_LoadString(FXJSE_HVALUE hValue, - IXFA_Notify* pNotify, - FX_DWORD dwFlag); - FX_BOOL Script_HostPseudoModel_ValidateArgsForMsg( - CFXJSE_Arguments* pArguments, - int32_t iArgIndex, - CFX_WideString& wsValue); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_imp.cpp b/xfa/src/fxfa/parser/xfa_script_imp.cpp deleted file mode 100644 index 3682580eb5..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_imp.cpp +++ /dev/null @@ -1,781 +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/src/fxfa/parser/xfa_script_imp.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_script_nodehelper.h" -#include "xfa/src/fxfa/parser/xfa_script_resolveprocessor.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument) - : m_pDocument(pDocument), - m_hJsContext(nullptr), - m_hJsRuntime(nullptr), - m_hJsClass(nullptr), - m_eScriptType(XFA_SCRIPTLANGTYPE_Unkown), - m_pScriptNodeArray(nullptr), - m_pResolveProcessor(nullptr), - m_hFM2JSContext(nullptr), - m_pThisObject(nullptr), - m_dwBuiltInInFlags(0), - m_eRunAtType(XFA_ATTRIBUTEENUM_Client) { - FXSYS_memset(&m_JsGlobalClass, 0, sizeof(FXJSE_CLASS)); - FXSYS_memset(&m_JsNormalClass, 0, sizeof(FXJSE_CLASS)); -} -CXFA_ScriptContext::~CXFA_ScriptContext() { - FX_POSITION ps = m_mapXFAToHValue.GetStartPosition(); - while (ps) { - CXFA_Object* pXFAObj; - FXJSE_HVALUE pValue; - m_mapXFAToHValue.GetNextAssoc(ps, pXFAObj, pValue); - FXJSE_Value_Release(pValue); - } - m_mapXFAToHValue.RemoveAll(); - ReleaseVariablesMap(); - if (m_hFM2JSContext) { - XFA_FM2JS_ContextRelease(m_hFM2JSContext); - m_hFM2JSContext = NULL; - } - if (m_hJsContext) { - FXJSE_Context_Release(m_hJsContext); - m_hJsContext = NULL; - } - if (m_pResolveProcessor) { - delete m_pResolveProcessor; - m_pResolveProcessor = NULL; - } - m_upObjectArray.RemoveAll(); - for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) { - delete ((CXFA_NodeList*)m_CacheListArray[i]); - } - m_CacheListArray.RemoveAll(); -} -void CXFA_ScriptContext::Initialize(FXJSE_HRUNTIME hRuntime) { - m_hJsRuntime = hRuntime; - DefineJsContext(); - DefineJsClass(); - m_pResolveProcessor = new CXFA_ResolveProcessor; -} -void CXFA_ScriptContext::Release() { - delete this; -} -FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - CXFA_Object* pThisObject) { - CFX_ByteString btScript; - XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType; - m_eScriptType = eScriptType; - if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) { - if (!m_hFM2JSContext) { - m_hFM2JSContext = XFA_FM2JS_ContextCreate(); - XFA_FM2JS_ContextInitialize(m_hFM2JSContext, m_hJsRuntime, m_hJsContext, - m_pDocument); - } - CFX_WideTextBuf wsJavaScript; - CFX_WideString wsErrorInfo; - int32_t iFlags = XFA_FM2JS_Translate(wsScript, wsJavaScript, wsErrorInfo); - if (iFlags) { - FXJSE_Value_SetUndefined(hRetValue); - return FALSE; - } - btScript = - FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); - } else { - btScript = FX_UTF8Encode(wsScript.GetPtr(), 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); - m_pThisObject = pOriginalObject; - m_eScriptType = eSaveType; - return bRet; -} -void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - CXFA_Object* lpOrginalNode = - (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - CXFA_Document* pDoc = lpOrginalNode->GetDocument(); - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pDoc->GetScriptContext(); - CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - FX_DWORD dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | - XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Attributes; - CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); - if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { - pRefNode = ToNode(lpCurNode); - } - if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, - TRUE)) { - return; - } - if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { - if (FXJSE_Value_IsUndefined(hValue)) { - FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); - return; - } - } - IXFA_Notify* pNotify = pDoc->GetNotify(); - if (!pNotify) { - return; - } - pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName, - hValue); -} -FX_BOOL CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode, - const CFX_WideStringC& propname, - FXJSE_HVALUE hValue, - FX_DWORD dwFlag, - FX_BOOL bSetting) { - if (!refNode) - return false; - XFA_RESOLVENODE_RS resolveRs; - if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) - return false; - if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]); - FXJSE_Value_Set(hValue, pValue); - return true; - } - if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) { - const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute; - if (lpAttributeInfo) { - (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))( - hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); - } - } - return true; -} -void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - CXFA_Object* pOrginalObject = - (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - CXFA_Document* pDoc = pOrginalObject->GetDocument(); - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pDoc->GetScriptContext(); - CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(pOrginalObject); - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - 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()); - if (uHashCode != XFA_HASHCODE_Layout) { - CXFA_Object* pObject = - lpScriptContext->GetDocument()->GetXFAObject(uHashCode); - if (pObject) { - FXJSE_Value_Set(hValue, lpScriptContext->GetJSValueFromMap(pObject)); - return; - } - } - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Attributes; - CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); - if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { - pRefNode = ToNode(lpCurNode); - } - if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, - FALSE)) { - return; - } - dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; - if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, - FALSE)) { - return; - } - CXFA_Object* pScriptObject = - lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); - if (pScriptObject && - lpScriptContext->QueryVariableHValue(pScriptObject->AsNode(), szPropName, - hValue, TRUE)) { - return; - } - IXFA_Notify* pNotify = pDoc->GetNotify(); - if (!pNotify) { - return; - } - pNotify->GetDocProvider()->GetGlobalProperty(pNotify->GetHDOC(), szPropName, - hValue); -} -void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - CXFA_Object* pOrginalObject = - (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - if (pOrginalObject == NULL) { - FXJSE_Value_SetUndefined(hValue); - return; - } - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); - CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); - if (wsPropName == FX_WSTRC(L"xfa")) { - FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap( - lpScriptContext->GetDocument()->GetRoot()); - FXJSE_Value_Set(hValue, pValue); - return; - } - FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Attributes; - FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName, - hValue, dwFlag, FALSE); - if (bRet) { - return; - } - if (pObject == lpScriptContext->GetThisObject() || - (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript && - !lpScriptContext->IsStrictScopeInJavaScript())) { - dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; - bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName, hValue, - dwFlag, FALSE); - } - if (bRet) { - return; - } - CXFA_Object* pScriptObject = - lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); - if (pScriptObject) { - bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), - szPropName, hValue, TRUE); - } - if (!bRet) { - FXJSE_Value_SetUndefined(hValue); - } -} -void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - CXFA_Object* pOrginalObject = - (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - if (pOrginalObject == NULL) { - return; - } - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); - CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = - XFA_GetScriptAttributeByName(pObject->GetClassID(), wsPropName); - if (lpAttributeInfo) { - (pObject->*(lpAttributeInfo->lpfnCallback))( - hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); - } else { - if (pObject->IsNode()) { - if (wsPropName.GetAt(0) == '#') { - wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); - } - CXFA_Node* pNode = ToNode(pObject); - CXFA_Node* pPropOrChild = NULL; - const XFA_ELEMENTINFO* lpElementInfo = XFA_GetElementByName(wsPropName); - if (lpElementInfo) { - pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName); - } else { - pPropOrChild = pNode->GetFirstChildByName(wsPropName); - } - if (pPropOrChild) { - CFX_WideString wsDefaultName = FX_WSTRC(L"{default}"); - const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = - XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), - wsDefaultName); - if (lpAttributeInfo) { - (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( - hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); - return; - } - } - } - CXFA_Object* pScriptObject = - lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); - if (pScriptObject) { - lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName, - hValue, FALSE); - } - } -} -int32_t CXFA_ScriptContext::NormalPropTypeGetter( - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FX_BOOL bQueryIn) { - CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - if (pObject == NULL) { - return FXJSE_ClassPropType_None; - } - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); - pObject = lpScriptContext->GetVariablesThis(pObject); - XFA_ELEMENT objElement = pObject->GetClassID(); - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - if (XFA_GetMethodByName(objElement, wsPropName)) { - return FXJSE_ClassPropType_Method; - } - if (bQueryIn && !XFA_GetScriptAttributeByName(objElement, wsPropName)) { - return FXJSE_ClassPropType_None; - } - return FXJSE_ClassPropType_Property; -} -int32_t CXFA_ScriptContext::GlobalPropTypeGetter( - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FX_BOOL bQueryIn) { - CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); - if (pObject == NULL) { - return FXJSE_ClassPropType_None; - } - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); - pObject = lpScriptContext->GetVariablesThis(pObject); - XFA_ELEMENT objElement = pObject->GetClassID(); - CFX_WideString wsPropName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); - if (XFA_GetMethodByName(objElement, wsPropName)) { - return FXJSE_ClassPropType_Method; - } - return FXJSE_ClassPropType_Property; -} -void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args) { - CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL); - if (pObject == NULL) { - return; - } - CXFA_ScriptContext* lpScriptContext = - (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); - pObject = lpScriptContext->GetVariablesThis(pObject); - CFX_WideString wsFunName = CFX_WideString::FromUTF8( - (const FX_CHAR*)szFuncName.GetPtr(), szFuncName.GetLength()); - const XFA_METHODINFO* lpMethodInfo = - XFA_GetMethodByName(pObject->GetClassID(), wsFunName); - if (NULL == lpMethodInfo) { - return; - } - (pObject->*(lpMethodInfo->lpfnCallback))(&args); -} -FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { - return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); -} -XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { - return m_eScriptType; -} -void CXFA_ScriptContext::DefineJsContext() { - m_JsGlobalClass.constructor = NULL; - m_JsGlobalClass.name = "Root"; - m_JsGlobalClass.propNum = 0; - m_JsGlobalClass.properties = NULL; - m_JsGlobalClass.methNum = 0; - m_JsGlobalClass.methods = NULL; - m_JsGlobalClass.dynPropGetter = CXFA_ScriptContext::GlobalPropertyGetter; - m_JsGlobalClass.dynPropSetter = CXFA_ScriptContext::GlobalPropertySetter; - m_JsGlobalClass.dynPropTypeGetter = CXFA_ScriptContext::GlobalPropTypeGetter; - m_JsGlobalClass.dynPropDeleter = NULL; - m_JsGlobalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; - m_hJsContext = FXJSE_Context_Create(m_hJsRuntime, &m_JsGlobalClass, - m_pDocument->GetRoot()); - RemoveBuiltInObjs(m_hJsContext); - FXJSE_Context_EnableCompatibleMode( - m_hJsContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); -} -FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext( - CXFA_Node* pScriptNode, - CXFA_Node* pSubform) { - if (pScriptNode == NULL || pSubform == NULL) { - return NULL; - } - if (m_mapVariableToHValue.GetCount() == 0) { - m_JsGlobalVariablesClass.constructor = NULL; - m_JsGlobalVariablesClass.name = "XFAScriptObject"; - m_JsGlobalVariablesClass.propNum = 0; - m_JsGlobalVariablesClass.properties = NULL; - m_JsGlobalVariablesClass.methNum = 0; - m_JsGlobalVariablesClass.methods = NULL; - m_JsGlobalVariablesClass.dynPropGetter = - CXFA_ScriptContext::GlobalPropertyGetter; - m_JsGlobalVariablesClass.dynPropSetter = - CXFA_ScriptContext::GlobalPropertySetter; - m_JsGlobalVariablesClass.dynPropTypeGetter = - CXFA_ScriptContext::NormalPropTypeGetter; - m_JsGlobalVariablesClass.dynPropDeleter = NULL; - 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); - RemoveBuiltInObjs(hVariablesContext); - FXJSE_Context_EnableCompatibleMode( - hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); - m_mapVariableToHValue.SetAt(pScriptNode, hVariablesContext); - return hVariablesContext; -} -CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, - FX_BOOL bScriptNode) { - if (pObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { - return bScriptNode ? ((CXFA_ThisProxy*)pObject)->GetScriptNode() - : ((CXFA_ThisProxy*)pObject)->GetThisNode(); - } - return pObject; -} -FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { - if (pScriptNode == NULL) { - 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.GetPtr(), 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; -} -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) { - return FALSE; - } - CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); - 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); - } - return bRes; -} -void CXFA_ScriptContext::ReleaseVariablesMap() { - FX_POSITION ps = m_mapVariableToHValue.GetStartPosition(); - while (ps) { - CXFA_Object* pScriptNode; - FXJSE_HCONTEXT hVariableContext; - 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; - } - 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"; - m_JsNormalClass.propNum = 0; - m_JsNormalClass.properties = NULL; - m_JsNormalClass.methNum = 0; - m_JsNormalClass.methods = NULL; - m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; - m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; - m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; - m_JsNormalClass.dynPropDeleter = NULL; - m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; - m_hJsClass = FXJSE_DefineClass(m_hJsContext, &m_JsNormalClass); -} -void CXFA_ScriptContext::RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const { - static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; - FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(jsContext); - FXJSE_HVALUE hProp = FXJSE_Value_Create(m_hJsRuntime); - for (int i = 0; i < 2; ++i) { - if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) - FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); - } - FXJSE_Value_Release(hProp); - FXJSE_Value_Release(hObject); -} -FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() { - return m_hJsClass; -} -int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, - const CFX_WideStringC& wsExpression, - XFA_RESOLVENODE_RS& resolveNodeRS, - FX_DWORD dwStyles, - CXFA_Node* bindNode) { - if (wsExpression.IsEmpty()) { - return 0; - } - if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || - (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { - m_upObjectArray.RemoveAll(); - } - if (refNode && refNode->IsNode() && - (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { - m_upObjectArray.Add(refNode->AsNode()); - } - FX_BOOL bNextCreate = FALSE; - if (dwStyles & XFA_RESOLVENODE_CreateNode) { - m_pResolveProcessor->GetNodeHelper()->XFA_SetCreateNodeType(bindNode); - } - m_pResolveProcessor->GetNodeHelper()->m_pCreateParent = NULL; - m_pResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1; - CXFA_ResolveNodesData rndFind; - int32_t nStart = 0; - int32_t nLevel = 0; - int32_t nRet = -1; - rndFind.m_pSC = this; - CXFA_ObjArray findNodes; - findNodes.Add(refNode ? refNode : m_pDocument->GetRoot()); - int32_t nNodes = 0; - while (TRUE) { - nNodes = findNodes.GetSize(); - int32_t i = 0; - rndFind.m_dwStyles = dwStyles; - m_pResolveProcessor->m_iCurStart = nStart; - nStart = m_pResolveProcessor->XFA_ResolveNodes_GetFilter(wsExpression, - nStart, rndFind); - if (nStart < 1) { - if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) { - CXFA_Node* pDataNode = NULL; - nStart = m_pResolveProcessor->GetNodeHelper()->m_iCurAllStart; - if (nStart != -1) { - pDataNode = m_pDocument->GetNotBindNode(findNodes); - if (pDataNode) { - findNodes.RemoveAll(); - findNodes.Add(pDataNode); - break; - } - } else { - pDataNode = findNodes[0]->AsNode(); - findNodes.RemoveAll(); - findNodes.Add(pDataNode); - break; - } - dwStyles |= XFA_RESOLVENODE_Bind; - findNodes.RemoveAll(); - findNodes.Add(m_pResolveProcessor->GetNodeHelper()->m_pAllStartParent); - continue; - } else { - break; - } - } - if (bNextCreate) { - FX_BOOL bCreate = - m_pResolveProcessor->GetNodeHelper()->XFA_ResolveNodes_CreateNode( - rndFind.m_wsName, rndFind.m_wsCondition, - nStart == wsExpression.GetLength(), this); - if (bCreate) { - continue; - } else { - break; - } - } - CXFA_ObjArray retNodes; - while (i < nNodes) { - FX_BOOL bDataBind = FALSE; - if (((dwStyles & XFA_RESOLVENODE_Bind) || - (dwStyles & XFA_RESOLVENODE_CreateNode)) && - nNodes > 1) { - CXFA_ResolveNodesData rndBind; - m_pResolveProcessor->XFA_ResolveNodes_GetFilter(wsExpression, nStart, - rndBind); - m_pResolveProcessor->XFA_ResolveNode_SetIndexDataBind( - rndBind.m_wsCondition, i, nNodes); - bDataBind = TRUE; - } - rndFind.m_CurNode = findNodes[i++]; - rndFind.m_nLevel = nLevel; - rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes; - nRet = m_pResolveProcessor->XFA_ResolveNodes(rndFind); - if (nRet < 1) { - continue; - } - if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute && - rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) { - FXJSE_HVALUE hValue = FXJSE_Value_Create(m_hJsRuntime); - (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))( - hValue, FALSE, - (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute); - rndFind.m_Nodes.SetAt(0, - (CXFA_Object*)FXJSE_Value_ToObject(hValue, NULL)); - FXJSE_Value_Release(hValue); - } - int32_t iSize = m_upObjectArray.GetSize(); - if (iSize) { - m_upObjectArray.RemoveAt(iSize - 1); - } - retNodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - if (bDataBind) { - break; - } - } - findNodes.RemoveAll(); - nNodes = retNodes.GetSize(); - if (nNodes < 1) { - if (dwStyles & XFA_RESOLVENODE_CreateNode) { - bNextCreate = TRUE; - if (m_pResolveProcessor->GetNodeHelper()->m_pCreateParent == NULL) { - m_pResolveProcessor->GetNodeHelper()->m_pCreateParent = - ToNode(rndFind.m_CurNode); - m_pResolveProcessor->GetNodeHelper()->m_iCreateCount = 1; - } - FX_BOOL bCreate = - m_pResolveProcessor->GetNodeHelper()->XFA_ResolveNodes_CreateNode( - rndFind.m_wsName, rndFind.m_wsCondition, - nStart == wsExpression.GetLength(), this); - if (bCreate) { - continue; - } else { - break; - } - } else { - break; - } - } - findNodes.Copy(retNodes); - rndFind.m_Nodes.RemoveAll(); - if (nLevel == 0) { - dwStyles &= ~(XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); - } - nLevel++; - } - if (!bNextCreate) { - resolveNodeRS.dwFlags = rndFind.m_dwFlag; - if (nNodes > 0) { - resolveNodeRS.nodes.Append(findNodes); - } - if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute) { - resolveNodeRS.pScriptAttribute = rndFind.m_pScriptAttribute; - return 1; - } - } - if (dwStyles & (XFA_RESOLVENODE_CreateNode | XFA_RESOLVENODE_Bind | - XFA_RESOLVENODE_BindNew)) { - m_pResolveProcessor->XFA_ResolveNode_SetResultCreateNode( - resolveNodeRS, rndFind.m_wsCondition); - if (!bNextCreate && (dwStyles & XFA_RESOLVENODE_CreateNode)) { - resolveNodeRS.dwFlags = XFA_RESOVENODE_RSTYPE_ExistNodes; - } - return resolveNodeRS.nodes.GetSize(); - } - return nNodes; -} -FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { - if (!pObject) { - return NULL; - } - if (pObject->IsNode()) { - RunVariablesScript(pObject->AsNode()); - } - void* pValue = m_mapXFAToHValue.GetValueAt(pObject); - if (pValue == NULL) { - FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_hJsRuntime); - FXJSE_Value_SetObject(jsHvalue, pObject, m_hJsClass); - m_mapXFAToHValue.SetAt(pObject, jsHvalue); - pValue = jsHvalue; - } - return (FXJSE_HVALUE)pValue; -} -int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { - CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); - return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, - lpNodeHelper->XFA_NodeIsProperty(refNode), - FALSE); -} -int32_t CXFA_ScriptContext::GetIndexByClassName(CXFA_Node* refNode) { - CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); - return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, - lpNodeHelper->XFA_NodeIsProperty(refNode), - TRUE); -} -void CXFA_ScriptContext::GetSomExpression(CXFA_Node* refNode, - CFX_WideString& wsExpression) { - CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); - lpNodeHelper->XFA_GetNameExpression(refNode, wsExpression, TRUE, - XFA_LOGIC_Transparent); -} -void CXFA_ScriptContext::SetNodesOfRunScript(CXFA_NodeArray* pArray) { - m_pScriptNodeArray = pArray; -} -void CXFA_ScriptContext::AddNodesOfRunScript(const CXFA_NodeArray& nodes) { - if (!m_pScriptNodeArray) { - return; - } - if (nodes.GetSize() > 0) { - m_pScriptNodeArray->Copy(nodes); - } -} -void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { - if (!m_pScriptNodeArray) { - return; - } - if (m_pScriptNodeArray->Find(pNode) == -1) { - m_pScriptNodeArray->Add(pNode); - } -} -IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) { - return new CXFA_ScriptContext(pDocument); -} diff --git a/xfa/src/fxfa/parser/xfa_script_imp.h b/xfa/src/fxfa/parser/xfa_script_imp.h deleted file mode 100644 index 529ab6d087..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_imp.h +++ /dev/null @@ -1,127 +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_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ - -#include <map> - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -#define XFA_RESOLVENODE_TagName 0x0002 - -class CXFA_ResolveProcessor; - -class CXFA_ScriptContext : public IXFA_ScriptContext { - public: - explicit CXFA_ScriptContext(CXFA_Document* pDocument); - ~CXFA_ScriptContext(); - - virtual void Release(); - virtual void Initialize(FXJSE_HRUNTIME hRuntime); - virtual void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } - virtual CXFA_EventParam* GetEventParam() { return &m_eventParam; } - virtual FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - CXFA_Object* pThisObject = NULL); - - virtual int32_t ResolveObjects(CXFA_Object* refNode, - const CFX_WideStringC& wsExpression, - XFA_RESOLVENODE_RS& resolveNodeRS, - FX_DWORD dwStyles = XFA_RESOLVENODE_Children, - CXFA_Node* bindNode = NULL); - virtual FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject); - virtual void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } - virtual CXFA_Object* GetThisObject() const { return m_pThisObject; } - virtual FXJSE_HRUNTIME GetRuntime() const { return m_hJsRuntime; } - - virtual int32_t GetIndexByName(CXFA_Node* refNode); - virtual int32_t GetIndexByClassName(CXFA_Node* refNode); - virtual void GetSomExpression(CXFA_Node* refNode, - CFX_WideString& wsExpression); - - virtual void SetNodesOfRunScript(CXFA_NodeArray* pArray); - virtual void AddNodesOfRunScript(const CXFA_NodeArray& nodes); - virtual void AddNodesOfRunScript(CXFA_Node* pNode); - virtual FXJSE_HCLASS GetJseNormalClass(); - - virtual void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } - virtual FX_BOOL IsRunAtClient() { - return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; - } - FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, - const CFX_WideStringC& propname, - FXJSE_HVALUE hValue, - FX_DWORD dwFlag, - FX_BOOL bSetting); - FX_BOOL QueryVariableHValue(CXFA_Node* pScriptNode, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue, - FX_BOOL bGetter); - FX_BOOL QueryBuiltinHValue(const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - static void GlobalPropertyGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - static void GlobalPropertySetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - static void NormalPropertyGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - static void NormalPropertySetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue); - static void NormalMethodCall(FXJSE_HOBJECT hThis, - const CFX_ByteStringC& szFuncName, - CFXJSE_Arguments& args); - static int32_t NormalPropTypeGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FX_BOOL bQueryIn); - static int32_t GlobalPropTypeGetter(FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FX_BOOL bQueryIn); - FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); - CXFA_Object* GetVariablesThis(CXFA_Object* pObject, - FX_BOOL bScriptNode = FALSE); - void ReleaseVariablesMap(); - FX_BOOL IsStrictScopeInJavaScript(); - XFA_SCRIPTLANGTYPE GetType(); - CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } - CXFA_Document* GetDocument() const { return m_pDocument; } - - protected: - void DefineJsContext(); - FXJSE_HCONTEXT CreateVariablesContext(CXFA_Node* pScriptNode, - CXFA_Node* pSubform); - void DefineJsClass(); - void RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const; - - CXFA_Document* m_pDocument; - FXJSE_HCONTEXT m_hJsContext; - FXJSE_HRUNTIME m_hJsRuntime; - FXJSE_HCLASS m_hJsClass; - XFA_SCRIPTLANGTYPE m_eScriptType; - FXJSE_CLASS m_JsGlobalClass; - FXJSE_CLASS m_JsNormalClass; - CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE> m_mapXFAToHValue; - FXJSE_CLASS m_JsGlobalVariablesClass; - CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue; - CXFA_EventParam m_eventParam; - CXFA_NodeArray m_upObjectArray; - CFX_PtrArray m_CacheListArray; - CXFA_NodeArray* m_pScriptNodeArray; - CXFA_ResolveProcessor* m_pResolveProcessor; - XFA_HFM2JSCONTEXT m_hFM2JSContext; - CXFA_Object* m_pThisObject; - FX_DWORD m_dwBuiltInInFlags; - XFA_ATTRIBUTEENUM m_eRunAtType; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.cpp deleted file mode 100644 index fe8990ac1a..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.cpp +++ /dev/null @@ -1,552 +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/src/fxfa/parser/xfa_script_layoutpseudomodel.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" -#include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_LayoutPseudoModel) { - m_uScriptHash = XFA_HASHCODE_Layout; -} -CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready( - FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_READY); - return; - } - int32_t iStatus = pNotify->GetLayoutStatus(); - FXJSE_Value_SetBoolean(hValue, iStatus >= 2); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY( - CFXJSE_Arguments* pArguments, - XFA_LAYOUTMODEL_HWXY layoutModel) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - const FX_WCHAR* methodName = NULL; - switch (layoutModel) { - case XFA_LAYOUTMODEL_H: - methodName = L"h"; - break; - case XFA_LAYOUTMODEL_W: - methodName = L"w"; - break; - case XFA_LAYOUTMODEL_X: - methodName = L"x"; - break; - case XFA_LAYOUTMODEL_Y: - methodName = L"y"; - break; - } - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); - return; - } - CXFA_Node* pNode = NULL; - CFX_WideString wsUnit = FX_WSTRC(L"pt"); - int32_t iIndex = 0; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (iLength >= 2) { - CFX_ByteString bsUnit = pArguments->GetUTF8String(1); - if (!bsUnit.IsEmpty()) { - wsUnit = CFX_WideString::FromUTF8(bsUnit, bsUnit.GetLength()); - } - } - if (iLength >= 3) { - iIndex = pArguments->GetInt32(2); - } - if (!pNode) { - return; - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - CFX_RectF rtRect; - CXFA_Measurement measure; - CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); - if (!pLayoutItem) { - return; - } - while (iIndex > 0 && pLayoutItem) { - pLayoutItem = pLayoutItem->GetNext(); - iIndex--; - } - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (!pLayoutItem) { - FXJSE_Value_SetFloat(hValue, 0); - return; - } - pLayoutItem->GetRect(rtRect, TRUE); - switch (layoutModel) { - case XFA_LAYOUTMODEL_H: - measure.Set(rtRect.height, XFA_UNIT_Pt); - break; - case XFA_LAYOUTMODEL_W: - measure.Set(rtRect.width, XFA_UNIT_Pt); - break; - case XFA_LAYOUTMODEL_X: - measure.Set(rtRect.left, XFA_UNIT_Pt); - break; - case XFA_LAYOUTMODEL_Y: - measure.Set(rtRect.top, XFA_UNIT_Pt); - break; - } - XFA_UNIT unit = measure.GetUnit(wsUnit); - FX_FLOAT fValue = measure.ToUnit(unit); - fValue = FXSYS_round(fValue * 1000) / 1000.0f; - if (hValue) { - FXJSE_Value_SetFloat(hValue, fValue); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_H( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_H); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_W( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_W); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_X( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_X); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Y( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_Y); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_NumberedPageCount( - CFXJSE_Arguments* pArguments, - FX_BOOL bNumbered) { - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - int32_t iPageCount = 0; - int32_t iPageNum = pDocLayout->CountPages(); - if (bNumbered) { - for (int32_t i = 0; i < iPageNum; i++) { - IXFA_LayoutPage* pLayoutPage = pDocLayout->GetPage(i); - if (!pLayoutPage) { - continue; - } - CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); - if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { - iPageCount++; - } - } - } else { - iPageCount = iPageNum; - } - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageCount); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageCount( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (!pNode) { - return; - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); - if (!pLayoutItem) { - FXJSE_Value_SetInteger(hValue, -1); - return; - } - int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); - int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); - int32_t iPageSpan = iLast - iFirst + 1; - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageSpan); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Page( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_PageImp(pArguments, FALSE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( - IXFA_DocLayout* pDocLayout, - int32_t iPageNo, - const CFX_WideString& wsType, - FX_BOOL bOnPageArea, - CXFA_NodeArray& retArray) { - CXFA_ContainerLayoutItem* pLayoutPage = - (CXFA_ContainerLayoutItem*)pDocLayout->GetPage(iPageNo); - if (!pLayoutPage) { - return; - } - if (wsType == FX_WSTRC(L"pageArea")) { - if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { - retArray.Add(pMasterPage); - } - return; - } - if (wsType == FX_WSTRC(L"contentArea")) { - for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; - pItem = pItem->m_pNextSibling) { - if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { - retArray.Add(pItem->m_pFormNode); - } - } - return; - } - CFX_MapPtrToPtr formItems; - formItems.InitHashTable(256, TRUE); - if (wsType.IsEmpty()) { - if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { - retArray.Add(pMasterPage); - } - for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; - pItem = pItem->m_pNextSibling) { - if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { - retArray.Add(pItem->m_pFormNode); - if (!bOnPageArea) { - CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, - CXFA_TraverseStrategy_ContentLayoutItem> - iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); - for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); - pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { - continue; - } - XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); - if (eElementType != XFA_ELEMENT_Field && - eElementType != XFA_ELEMENT_Draw && - eElementType != XFA_ELEMENT_Subform && - eElementType != XFA_ELEMENT_Area) { - continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { - continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); - retArray.Add(pItemChild->m_pFormNode); - } - } - } else { - if (bOnPageArea) { - CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, - CXFA_TraverseStrategy_ContentLayoutItem> - iterator((CXFA_ContentLayoutItem*)pItem); - for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); - pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { - continue; - } - XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); - if (eElementType != XFA_ELEMENT_Field && - eElementType != XFA_ELEMENT_Draw && - eElementType != XFA_ELEMENT_Subform && - eElementType != XFA_ELEMENT_Area) { - continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { - continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); - retArray.Add(pItemChild->m_pFormNode); - } - } - } - } - return; - } - XFA_ELEMENT eType = XFA_ELEMENT_UNKNOWN; - if (wsType == FX_WSTRC(L"field")) { - eType = XFA_ELEMENT_Field; - } else if (wsType == FX_WSTRC(L"draw")) { - eType = XFA_ELEMENT_Draw; - } else if (wsType == FX_WSTRC(L"subform")) { - eType = XFA_ELEMENT_Subform; - } else if (wsType == FX_WSTRC(L"area")) { - eType = XFA_ELEMENT_Area; - } - if (eType != XFA_ELEMENT_UNKNOWN) { - for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; - pItem = pItem->m_pNextSibling) { - if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { - if (!bOnPageArea) { - CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, - CXFA_TraverseStrategy_ContentLayoutItem> - iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); - for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); - pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { - continue; - } - if (pItemChild->m_pFormNode->GetClassID() != eType) { - continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { - continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); - retArray.Add(pItemChild->m_pFormNode); - } - } - } else { - if (bOnPageArea) { - CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, - CXFA_TraverseStrategy_ContentLayoutItem> - iterator((CXFA_ContentLayoutItem*)pItem); - for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); - pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { - continue; - } - if (pItemChild->m_pFormNode->GetClassID() != eType) { - continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { - continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); - retArray.Add(pItemChild->m_pFormNode); - } - } - } - } - return; - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); - return; - } - int32_t iIndex = 0; - CFX_WideString wsType; - FX_BOOL bOnPageArea = FALSE; - if (iLength >= 1) { - iIndex = pArguments->GetInt32(0); - } - if (iLength >= 2) { - CFX_ByteString bsType = pArguments->GetUTF8String(1); - wsType = CFX_WideString::FromUTF8(bsType, bsType.GetLength()); - } - if (iLength >= 3) { - bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - CXFA_NodeArray retArray; - Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, - retArray); - CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); - pArrayNodeList->SetArrayNodeList(retArray); - FXJSE_Value_SetObject(pArguments->GetReturnValue(), - (CXFA_Object*)pArrayNodeList, - m_pDocument->GetScriptContext()->GetJseNormalClass()); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageCount); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCountInBatch( - CFXJSE_Arguments* pArguments) { - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageCount); - } -} -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); - CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); - if (pContentRootNode) { - pLayoutProcessor->AddChangedContainer(pContentRootNode); - } - pLayoutProcessor->SetForceReLayout(TRUE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageSpan( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_PageSpan(pArguments); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"absPageInBatch"); - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (!pNode) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); - if (!hWidget) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageCount); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, - L"sheetInBatch"); - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (!pNode) { - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - IXFA_Widget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); - if (!hWidget) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - int32_t iPageCount = pNotify->GetDocProvider()->SheetInBatch(hDoc, hWidget); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, iPageCount); - } -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Sheet( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_PageImp(pArguments, TRUE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_RelayoutPageArea( - CFXJSE_Arguments* pArguments) {} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCount( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPage( - CFXJSE_Arguments* pArguments) { - Script_LayoutPseudoModel_PageImp(pArguments, TRUE); -} -void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageImp( - CFXJSE_Arguments* pArguments, - FX_BOOL bAbsPage) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - const FX_WCHAR* methodName; - if (bAbsPage) { - methodName = L"absPage"; - } else { - methodName = L"page"; - } - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); - return; - } - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - int32_t iPage = 0; - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (!pNode && hValue) { - FXJSE_Value_SetInteger(hValue, iPage); - } - IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); - if (!pLayoutItem) { - FXJSE_Value_SetInteger(hValue, -1); - return; - } - iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, bAbsPage ? iPage : iPage + 1); - } -} diff --git a/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h b/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h deleted file mode 100644 index 5b0dbb816f..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_layoutpseudomodel.h +++ /dev/null @@ -1,64 +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_SRC_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_ - -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_object.h" - -enum XFA_LAYOUTMODEL_HWXY { - XFA_LAYOUTMODEL_H, - XFA_LAYOUTMODEL_W, - XFA_LAYOUTMODEL_X, - XFA_LAYOUTMODEL_Y -}; - -class CScript_LayoutPseudoModel : public CXFA_OrdinaryObject { - public: - explicit CScript_LayoutPseudoModel(CXFA_Document* pDocument); - ~CScript_LayoutPseudoModel(); - - void Script_LayoutPseudoModel_Ready(FXJSE_HVALUE hValue, - FX_BOOL bSetting, - XFA_ATTRIBUTE eAttribute); - - void Script_LayoutPseudoModel_HWXY(CFXJSE_Arguments* pArguments, - XFA_LAYOUTMODEL_HWXY layoutModel); - void Script_LayoutPseudoModel_H(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_W(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_X(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_Y(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_NumberedPageCount(CFXJSE_Arguments* pArguments, - FX_BOOL bNumbered); - void Script_LayoutPseudoModel_PageCount(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_PageSpan(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_Page(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_PageContent(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_AbsPageCount(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_AbsPageCountInBatch( - CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_SheetCountInBatch(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_Relayout(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_AbsPageSpan(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_AbsPageInBatch(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_SheetInBatch(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_Sheet(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_RelayoutPageArea(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_SheetCount(CFXJSE_Arguments* pArguments); - void Script_LayoutPseudoModel_AbsPage(CFXJSE_Arguments* pArguments); - - protected: - void Script_LayoutPseudoModel_GetObjArray(IXFA_DocLayout* pDocLayout, - int32_t iPageNo, - const CFX_WideString& wsType, - FX_BOOL bOnPageArea, - CXFA_NodeArray& retArray); - void Script_LayoutPseudoModel_PageImp(CFXJSE_Arguments* pArguments, - FX_BOOL bAbsPage); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_logpseudomodel.cpp b/xfa/src/fxfa/parser/xfa_script_logpseudomodel.cpp deleted file mode 100644 index d5ddd811ad..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_logpseudomodel.cpp +++ /dev/null @@ -1,33 +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/src/fxfa/parser/xfa_script_logpseudomodel.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_LogPseudoModel) { - m_uScriptHash = XFA_HASHCODE_Log; -} -CScript_LogPseudoModel::~CScript_LogPseudoModel() {} -void CScript_LogPseudoModel::Script_LogPseudoModel_Message( - CFXJSE_Arguments* pArguments) {} -void CScript_LogPseudoModel::Script_LogPseudoModel_TraceEnabled( - CFXJSE_Arguments* pArguments) {} -void CScript_LogPseudoModel::Script_LogPseudoModel_TraceActivate( - CFXJSE_Arguments* pArguments) {} -void CScript_LogPseudoModel::Script_LogPseudoModel_TraceDeactivate( - CFXJSE_Arguments* pArguments) {} -void CScript_LogPseudoModel::Script_LogPseudoModel_Trace( - CFXJSE_Arguments* pArguments) {} diff --git a/xfa/src/fxfa/parser/xfa_script_logpseudomodel.h b/xfa/src/fxfa/parser/xfa_script_logpseudomodel.h deleted file mode 100644 index ee3d35c052..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_logpseudomodel.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_SRC_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_ - -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CScript_LogPseudoModel : public CXFA_OrdinaryObject { - public: - explicit CScript_LogPseudoModel(CXFA_Document* pDocument); - virtual ~CScript_LogPseudoModel(); - - void Script_LogPseudoModel_Message(CFXJSE_Arguments* pArguments); - void Script_LogPseudoModel_TraceEnabled(CFXJSE_Arguments* pArguments); - void Script_LogPseudoModel_TraceActivate(CFXJSE_Arguments* pArguments); - void Script_LogPseudoModel_TraceDeactivate(CFXJSE_Arguments* pArguments); - void Script_LogPseudoModel_Trace(CFXJSE_Arguments* pArguments); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_nodehelper.cpp b/xfa/src/fxfa/parser/xfa_script_nodehelper.cpp deleted file mode 100644 index e2f047591e..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_nodehelper.cpp +++ /dev/null @@ -1,429 +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/src/fxfa/parser/xfa_script_nodehelper.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_script_imp.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_NodeHelper::CXFA_NodeHelper(void) - : m_eLastCreateType(XFA_ELEMENT_DataValue), - m_pCreateParent(NULL), - m_iCreateCount(0), - m_iCreateFlag(XFA_RESOLVENODE_RSTYPE_CreateNodeOne), - m_iCurAllStart(-1), - m_pAllStartParent(NULL) {} -CXFA_NodeHelper::~CXFA_NodeHelper(void) {} -CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetOneChild( - CXFA_Node* parent, - const FX_WCHAR* pwsName, - FX_BOOL bIsClassName) { - if (parent == NULL) { - return NULL; - } - CXFA_NodeArray siblings; - uint32_t uNameHash = FX_HashCode_String_GetW(pwsName, FXSYS_wcslen(pwsName)); - XFA_NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName); - if (siblings.GetSize() == 0) { - return NULL; - } - return siblings[0]; -} -int32_t CXFA_NodeHelper::XFA_CountSiblings(CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType, - CXFA_NodeArray* pSiblings, - FX_BOOL bIsClassName) { - if (!pNode) - return 0; - CXFA_Node* parent = - XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); - if (!parent) - return 0; - const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( - parent->GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); - if (!pProperty && eLogicType == XFA_LOGIC_Transparent) { - parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); - if (parent == NULL) { - return 0; - } - } - if (bIsClassName) { - return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(), - pSiblings, eLogicType, bIsClassName); - } else { - return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings, - eLogicType, bIsClassName); - } -} -int32_t CXFA_NodeHelper::XFA_NodeAcc_TraverseAnySiblings( - CXFA_Node* parent, - FX_DWORD dNameHash, - CXFA_NodeArray* pSiblings, - FX_BOOL bIsClassName) { - if (parent == NULL || pSiblings == NULL) { - return 0; - } - int32_t nCount = 0; - int32_t i = 0; - CXFA_NodeArray properties; - parent->GetNodeList(properties, XFA_NODEFILTER_Properties); - int32_t nProperties = properties.GetSize(); - for (i = 0; i < nProperties; ++i) { - CXFA_Node* child = properties[i]; - if (bIsClassName) { - if (child->GetClassHashCode() == dNameHash) { - pSiblings->Add(child); - nCount++; - } - } else { - if (child->GetNameHash() == dNameHash) { - pSiblings->Add(child); - nCount++; - } - } - if (nCount > 0) { - return nCount; - } - nCount += XFA_NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, - bIsClassName); - } - CXFA_NodeArray children; - parent->GetNodeList(children, XFA_NODEFILTER_Children); - int32_t nChildren = children.GetSize(); - for (i = 0; i < nChildren; i++) { - CXFA_Node* child = children[i]; - if (bIsClassName) { - if (child->GetClassHashCode() == dNameHash) { - if (pSiblings) { - pSiblings->Add(child); - } - nCount++; - } - } else { - if (child->GetNameHash() == dNameHash) { - if (pSiblings) { - pSiblings->Add(child); - } - nCount++; - } - } - if (nCount > 0) { - return nCount; - } - nCount += XFA_NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, - bIsClassName); - } - return nCount; -} -int32_t CXFA_NodeHelper::XFA_NodeAcc_TraverseSiblings(CXFA_Node* parent, - FX_DWORD dNameHash, - CXFA_NodeArray* pSiblings, - XFA_LOGIC_TYPE eLogicType, - FX_BOOL bIsClassName, - FX_BOOL bIsFindProperty) { - if (parent == NULL || pSiblings == NULL) { - return 0; - } - int32_t nCount = 0; - int32_t i = 0; - if (bIsFindProperty) { - CXFA_NodeArray properties; - parent->GetNodeList(properties, XFA_NODEFILTER_Properties); - int32_t nProperties = properties.GetSize(); - for (i = 0; i < nProperties; ++i) { - CXFA_Node* child = properties[i]; - if (bIsClassName) { - if (child->GetClassHashCode() == dNameHash) { - pSiblings->Add(child); - nCount++; - } - } else { - if (child->GetNameHash() == dNameHash) { - if (child->GetClassID() != XFA_ELEMENT_PageSet && - child->GetClassID() != XFA_ELEMENT_Extras && - child->GetClassID() != XFA_ELEMENT_Items) { - pSiblings->Add(child); - nCount++; - } - } - } - if (child->IsUnnamed() && child->GetClassID() == XFA_ELEMENT_PageSet) { - nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, - eLogicType, bIsClassName, FALSE); - } - } - if (nCount > 0) { - return nCount; - } - } - CXFA_NodeArray children; - parent->GetNodeList(children, XFA_NODEFILTER_Children); - int32_t nChildren = children.GetSize(); - for (i = 0; i < nChildren; i++) { - CXFA_Node* child = children[i]; - if (child->GetClassID() == XFA_ELEMENT_Variables) { - continue; - } - if (bIsClassName) { - if (child->GetClassHashCode() == dNameHash) { - if (pSiblings) { - pSiblings->Add(child); - } - nCount++; - } - } else { - if (child->GetNameHash() == dNameHash) { - if (pSiblings) { - pSiblings->Add(child); - } - nCount++; - } - } - if (eLogicType == XFA_LOGIC_NoTransparent) { - continue; - } - if (XFA_NodeIsTransparent(child) && - child->GetClassID() != XFA_ELEMENT_PageSet) { - nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, - eLogicType, bIsClassName, FALSE); - } - } - return nCount; -} -CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetParent( - CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType) { - if (!pNode) { - return NULL; - } - if (eLogicType == XFA_LOGIC_NoTransparent) { - return pNode->GetNodeItem(XFA_NODEITEM_Parent); - } - CXFA_Node* parent; - CXFA_Node* node = pNode; - while (TRUE) { - parent = XFA_ResolveNodes_GetParent(node); - if (parent == NULL) { - break; - } - XFA_ELEMENT parentElement = parent->GetClassID(); - if ((!parent->IsUnnamed() && parentElement != XFA_ELEMENT_SubformSet) || - parentElement == XFA_ELEMENT_Variables) { - break; - } - node = parent; - } - return parent; -} -int32_t CXFA_NodeHelper::XFA_GetIndex(CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType, - FX_BOOL bIsProperty, - FX_BOOL bIsClassIndex) { - CXFA_Node* parent = - XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); - if (parent == NULL) { - return 0; - } - if (!bIsProperty && eLogicType == XFA_LOGIC_Transparent) { - parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); - if (parent == NULL) { - return 0; - } - } - FX_DWORD dwHashName = pNode->GetNameHash(); - if (bIsClassIndex) { - dwHashName = pNode->GetClassHashCode(); - } - CXFA_NodeArray siblings; - int32_t iSize = XFA_NodeAcc_TraverseSiblings(parent, dwHashName, &siblings, - eLogicType, bIsClassIndex); - for (int32_t i = 0; i < iSize; ++i) { - CXFA_Node* child = siblings[i]; - if (child == pNode) { - return i; - } - } - return 0; -} -void CXFA_NodeHelper::XFA_GetNameExpression(CXFA_Node* refNode, - CFX_WideString& wsName, - FX_BOOL bIsAllPath, - XFA_LOGIC_TYPE eLogicType) { - wsName.Empty(); - if (bIsAllPath) { - XFA_GetNameExpression(refNode, wsName, FALSE, eLogicType); - CFX_WideString wsParent; - CXFA_Node* parent = - XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); - while (parent) { - XFA_GetNameExpression(parent, wsParent, FALSE, eLogicType); - wsParent += L"."; - wsParent += wsName; - wsName = wsParent; - parent = XFA_ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent); - } - return; - } - - CFX_WideStringC wsTagName; - CFX_WideString ws; - FX_BOOL bIsProperty = XFA_NodeIsProperty(refNode); - if (refNode->IsUnnamed() || - (bIsProperty && refNode->GetClassID() != XFA_ELEMENT_PageSet)) { - refNode->GetClassName(wsTagName); - ws = wsTagName; - wsName.Format(L"#%s[%d]", (const FX_WCHAR*)ws, - 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, - XFA_GetIndex(refNode, eLogicType, bIsProperty, FALSE)); -} - -FX_BOOL CXFA_NodeHelper::XFA_NodeIsTransparent(CXFA_Node* refNode) { - if (refNode == NULL) { - return FALSE; - } - XFA_ELEMENT eRefNode = refNode->GetClassID(); - if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || - eRefNode == XFA_ELEMENT_SubformSet || eRefNode == XFA_ELEMENT_Area || - eRefNode == XFA_ELEMENT_Proto) { - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_NodeHelper::XFA_CreateNode_ForCondition( - CFX_WideString& wsCondition) { - int32_t iLen = wsCondition.GetLength(); - CFX_WideString wsIndex = FX_WSTRC(L"0"); - FX_BOOL bAll = FALSE; - - if (iLen == 0) { - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; - return FALSE; - } - if (wsCondition.GetAt(0) == '[') { - int32_t i = 1; - for (; i < iLen; ++i) { - FX_WCHAR ch = wsCondition[i]; - if (ch == ' ') { - continue; - } - if (ch == '+' || ch == '-') { - break; - } else if (ch == '*') { - bAll = TRUE; - break; - } else { - break; - } - } - if (bAll) { - wsIndex = FX_WSTRC(L"1"); - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; - } else { - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; - wsIndex = wsCondition.Mid(i, iLen - 1 - i); - } - int32_t iIndex = wsIndex.GetInteger(); - m_iCreateCount = iIndex; - return TRUE; - } - return FALSE; -} -FX_BOOL CXFA_NodeHelper::XFA_ResolveNodes_CreateNode( - CFX_WideString wsName, - CFX_WideString wsCondition, - FX_BOOL bLastNode, - CXFA_ScriptContext* pScriptContext) { - if (m_pCreateParent == NULL) { - return FALSE; - } - FX_BOOL bIsClassName = FALSE; - FX_BOOL bResult = FALSE; - if (wsName.GetAt(0) == '!') { - wsName = wsName.Right(wsName.GetLength() - 1); - m_pCreateParent = ToNode( - pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); - } - if (wsName.GetAt(0) == '#') { - bIsClassName = TRUE; - wsName = wsName.Right(wsName.GetLength() - 1); - } - if (m_iCreateCount == 0) { - XFA_CreateNode_ForCondition(wsCondition); - } - if (bIsClassName) { - const XFA_ELEMENTINFO* lpElement = XFA_GetElementByName(wsName); - if (lpElement == NULL) { - return FALSE; - } - for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { - CXFA_Node* pNewNode = - m_pCreateParent->CreateSamePacketNode(lpElement->eName); - if (pNewNode) { - m_pCreateParent->InsertChild(pNewNode); - if (iIndex == m_iCreateCount - 1) { - m_pCreateParent = pNewNode; - } - bResult = TRUE; - } - } - } else { - XFA_ELEMENT eClassType = XFA_ELEMENT_DataGroup; - if (bLastNode) { - eClassType = m_eLastCreateType; - } - for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { - CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType); - if (pNewNode) { - pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName); - pNewNode->CreateXMLMappingNode(); - m_pCreateParent->InsertChild(pNewNode); - if (iIndex == m_iCreateCount - 1) { - m_pCreateParent = pNewNode; - } - bResult = TRUE; - } - } - } - if (!bResult) { - m_pCreateParent = NULL; - } - return bResult; -} -void CXFA_NodeHelper::XFA_SetCreateNodeType(CXFA_Node* refNode) { - if (refNode == NULL) { - return; - } - if (refNode->GetClassID() == XFA_ELEMENT_Subform) { - m_eLastCreateType = XFA_ELEMENT_DataGroup; - } else if (refNode->GetClassID() == XFA_ELEMENT_Field) { - m_eLastCreateType = XFA_FieldIsMultiListBox(refNode) - ? XFA_ELEMENT_DataGroup - : XFA_ELEMENT_DataValue; - } else if (refNode->GetClassID() == XFA_ELEMENT_ExclGroup) { - m_eLastCreateType = XFA_ELEMENT_DataValue; - } -} -FX_BOOL CXFA_NodeHelper::XFA_NodeIsProperty(CXFA_Node* refNode) { - CXFA_Node* parent = - XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); - return parent && refNode && - XFA_GetPropertyOfElement(parent->GetClassID(), refNode->GetClassID(), - XFA_XDPPACKET_UNKNOWN); -} diff --git a/xfa/src/fxfa/parser/xfa_script_nodehelper.h b/xfa/src/fxfa/parser/xfa_script_nodehelper.h deleted file mode 100644 index 318a5a1ab3..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_nodehelper.h +++ /dev/null @@ -1,72 +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_SRC_FXFA_PARSER_XFA_SCRIPT_NODEHELPER_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_NODEHELPER_H_ - -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -class CXFA_ScriptContext; - -enum XFA_LOGIC_TYPE { - XFA_LOGIC_NoTransparent, - XFA_LOGIC_Transparent, -}; - -class CXFA_NodeHelper { - public: - CXFA_NodeHelper(void); - ~CXFA_NodeHelper(void); - CXFA_Node* XFA_ResolveNodes_GetOneChild(CXFA_Node* parent, - const FX_WCHAR* pwsName, - FX_BOOL bIsClassName = FALSE); - CXFA_Node* XFA_ResolveNodes_GetParent( - CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent); - - int32_t XFA_NodeAcc_TraverseSiblings(CXFA_Node* parent, - FX_DWORD dNameHash, - CXFA_NodeArray* pSiblings, - XFA_LOGIC_TYPE eLogicType, - FX_BOOL bIsClassName = FALSE, - FX_BOOL bIsFindProperty = TRUE); - int32_t XFA_NodeAcc_TraverseAnySiblings(CXFA_Node* parent, - FX_DWORD dNameHash, - CXFA_NodeArray* pSiblings, - FX_BOOL bIsClassName = FALSE); - int32_t XFA_CountSiblings(CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType, - CXFA_NodeArray* pSiblings, - FX_BOOL bIsClassName = FALSE); - int32_t XFA_GetIndex(CXFA_Node* pNode, - XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent, - FX_BOOL bIsProperty = FALSE, - FX_BOOL bIsClassIndex = FALSE); - void XFA_GetNameExpression( - CXFA_Node* refNode, - CFX_WideString& wsName, - FX_BOOL bIsAllPath, - XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent); - FX_BOOL XFA_NodeIsTransparent(CXFA_Node* refNode); - FX_BOOL XFA_ResolveNodes_CreateNode(CFX_WideString wsName, - CFX_WideString wsCondition, - FX_BOOL bLastNode, - CXFA_ScriptContext* pScriptContext); - FX_BOOL XFA_CreateNode_ForCondition(CFX_WideString& wsCondition); - void XFA_SetCreateNodeType(CXFA_Node* refNode); - FX_BOOL XFA_NodeIsProperty(CXFA_Node* refNode); - - public: - XFA_ELEMENT m_eLastCreateType; - CXFA_Node* m_pCreateParent; - int32_t m_iCreateCount; - XFA_RESOVENODE_RSTYPE m_iCreateFlag; - int32_t m_iCurAllStart; - CXFA_Node* m_pAllStartParent; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_NODEHELPER_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/src/fxfa/parser/xfa_script_resolveprocessor.cpp deleted file mode 100644 index 3f4a9c7b88..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_resolveprocessor.cpp +++ /dev/null @@ -1,825 +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/src/fxfa/parser/xfa_script_resolveprocessor.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_script_imp.h" -#include "xfa/src/fxfa/parser/xfa_script_nodehelper.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CXFA_ResolveProcessor::CXFA_ResolveProcessor(void) - : m_pNodeHelper(NULL), m_iCurStart(0) { - m_pNodeHelper = new CXFA_NodeHelper; -} -CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) { - if (m_pNodeHelper) { - delete m_pNodeHelper; - m_pNodeHelper = NULL; - } -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { - if (rnd.m_CurNode == NULL) { - return -1; - } - if (!rnd.m_CurNode->IsNode()) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) { - return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, rnd.m_wsName); - } - return 0; - } - if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) { - return XFA_ResolveNodes_AnyChild(rnd); - } - FX_WCHAR wch = rnd.m_wsName.GetAt(0); - switch (wch) { - case '$': - return XFA_ResolveNodes_Dollar(rnd); - case '!': - return XFA_ResolveNodes_Excalmatory(rnd); - case '#': - return XFA_ResolveNodes_NumberSign(rnd); - case '*': - return XFA_ResolveNodes_Asterisk(rnd); - case '.': - return XFA_ResolveNodes_AnyChild(rnd); - default: - break; - } - if (rnd.m_uHashName == XFA_HASHCODE_This && rnd.m_nLevel == 0) { - rnd.m_Nodes.Add(rnd.m_pSC->GetThisObject()); - return 1; - } else if (rnd.m_CurNode->GetClassID() == XFA_ELEMENT_Xfa) { - CXFA_Object* pObjNode = - rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName); - if (pObjNode) { - rnd.m_Nodes.Add(pObjNode); - } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) { - 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)) { - return 1; - } - if (rnd.m_Nodes.GetSize() > 0) { - XFA_ResolveNode_FilterCondition(rnd, rnd.m_wsCondition); - } - return rnd.m_Nodes.GetSize(); - } - int32_t nRet = XFA_ResolveNodes_Normal(rnd); - if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) { - rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); - } - return rnd.m_Nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild( - CXFA_ResolveNodesData& rnd) { - CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); - CFX_WideString wsCondition = rnd.m_wsCondition; - CXFA_Node* findNode = NULL; - CXFA_NodeArray siblings; - FX_BOOL bClassName = FALSE; - if (wsName.GetAt(0) == '#') { - bClassName = TRUE; - wsName = wsName.Right(wsName.GetLength() - 1); - } - findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(ToNode(rnd.m_CurNode), - wsName, bClassName); - if (findNode == NULL) { - return 0; - } - if (wsCondition.IsEmpty()) { - rnd.m_Nodes.Add(findNode); - return rnd.m_Nodes.GetSize(); - } - m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, - (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - return rnd.m_Nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( - CXFA_ResolveNodesData& rnd) { - CXFA_ObjArray& nodes = rnd.m_Nodes; - CFX_WideString wsName = rnd.m_wsName; - CFX_WideString wsCondition = rnd.m_wsCondition; - int32_t iNameLen = wsName.GetLength(); - if (iNameLen == 1) { - nodes.Add(rnd.m_CurNode); - return 1; - } - if (rnd.m_nLevel > 0) { - return -1; - } - FX_DWORD dwNameHash = - FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1); - if (dwNameHash == XFA_HASHCODE_Xfa) { - nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); - } else { - CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); - if (pObjNode) { - rnd.m_Nodes.Add(pObjNode); - } - } - if (rnd.m_Nodes.GetSize() > 0) { - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - } - return rnd.m_Nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( - CXFA_ResolveNodesData& rnd) { - if (rnd.m_nLevel > 0) { - return 0; - } - CXFA_Node* datasets = - ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); - if (!datasets) { - return 0; - } - CXFA_ResolveNodesData rndFind; - 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_nLevel = rnd.m_nLevel + 1; - rndFind.m_dwStyles = XFA_RESOLVENODE_Children; - rndFind.m_wsCondition = rnd.m_wsCondition; - XFA_ResolveNodes(rndFind); - if (rndFind.m_Nodes.GetSize() > 0) { - rnd.m_Nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - return rnd.m_Nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( - CXFA_ResolveNodesData& rnd) { - 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)) { - return 1; - } - CXFA_ResolveNodesData rndFind; - rndFind.m_pSC = rnd.m_pSC; - rndFind.m_nLevel = rnd.m_nLevel + 1; - rndFind.m_dwStyles = rnd.m_dwStyles; - 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_wsCondition = wsCondition; - rndFind.m_CurNode = curNode; - XFA_ResolveNodes_Normal(rndFind); - if (rndFind.m_Nodes.GetSize() > 0) { - if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) { - rnd.m_Nodes.Add(curNode); - } else { - rnd.m_Nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - } - return rnd.m_Nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_ForAttributeRs( - CXFA_Object* curNode, - CXFA_ResolveNodesData& rnd, - const CFX_WideStringC& strAttr) { - const XFA_SCRIPTATTRIBUTEINFO* lpScriptAttribute = - XFA_GetScriptAttributeByName(curNode->GetClassID(), strAttr); - if (lpScriptAttribute) { - rnd.m_pScriptAttribute = lpScriptAttribute; - rnd.m_Nodes.Add(curNode); - rnd.m_dwFlag = XFA_RESOVENODE_RSTYPE_Attribute; - return 1; - } - return 0; -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal( - CXFA_ResolveNodesData& rnd) { - if (rnd.m_nLevel > 32) { - return 0; - } - if (!rnd.m_CurNode->IsNode()) { - return 0; - } - CXFA_Node* curNode = ToNode(rnd.m_CurNode); - CXFA_ObjArray& nodes = rnd.m_Nodes; - int32_t nNum = nodes.GetSize(); - FX_DWORD dwStyles = rnd.m_dwStyles; - CFX_WideString& wsName = rnd.m_wsName; - uint32_t uNameHash = rnd.m_uHashName; - CFX_WideString& wsCondition = rnd.m_wsCondition; - CXFA_ResolveNodesData rndFind; - rndFind.m_wsName = rnd.m_wsName; - rndFind.m_wsCondition = rnd.m_wsCondition; - rndFind.m_pSC = rnd.m_pSC; - rndFind.m_nLevel = rnd.m_nLevel + 1; - rndFind.m_uHashName = uNameHash; - CXFA_NodeArray children; - CXFA_NodeArray properties; - CXFA_Node* pVariablesNode = NULL; - CXFA_Node* pPageSetNode = NULL; - CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChild) { - if (pChild->GetClassID() == XFA_ELEMENT_Variables) { - pVariablesNode = pChild; - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - continue; - } else if (pChild->GetClassID() == XFA_ELEMENT_PageSet) { - pPageSetNode = pChild; - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - continue; - } else { - const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( - curNode->GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); - if (pPropert) { - properties.Add(pChild); - } else { - children.Add(pChild); - } - } - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - } - if ((dwStyles & XFA_RESOLVENODE_Properties) && pVariablesNode) { - uint32_t uPropHash = pVariablesNode->GetClassHashCode(); - if (uPropHash == uNameHash) { - nodes.Add(pVariablesNode); - } else { - rndFind.m_CurNode = pVariablesNode; - XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); - CFX_WideString wsSaveCondition = rndFind.m_wsCondition; - rndFind.m_wsCondition.Empty(); - XFA_ResolveNodes_Normal(rndFind); - rndFind.m_wsCondition = wsSaveCondition; - if (rndFind.m_Nodes.GetSize() > 0) { - nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - } - if (nodes.GetSize() > nNum) { - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - if (nodes.GetSize() > 0) { - return 1; - } - return 0; - } - } - if (dwStyles & XFA_RESOLVENODE_Children) { - FX_BOOL bSetFlag = FALSE; - if (pPageSetNode && (dwStyles & XFA_RESOLVENODE_Properties)) { - children.Add(pPageSetNode); - } - for (int32_t i = 0; i < children.GetSize(); i++) { - CXFA_Node* child = children[i]; - if (dwStyles & XFA_RESOLVENODE_TagName) { - if (child->GetClassHashCode() == uNameHash) { - nodes.Add(child); - } - } else if (child->GetNameHash() == uNameHash) { - nodes.Add(child); - } - if (m_pNodeHelper->XFA_NodeIsTransparent(child) && - child->GetClassID() != XFA_ELEMENT_PageSet) { - if (!bSetFlag) { - XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); - bSetFlag = TRUE; - } - rndFind.m_CurNode = child; - CFX_WideString wsSaveCondition = rndFind.m_wsCondition; - rndFind.m_wsCondition.Empty(); - XFA_ResolveNodes_Normal(rndFind); - rndFind.m_wsCondition = wsSaveCondition; - if (rndFind.m_Nodes.GetSize() > 0) { - nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - } - } - if (nodes.GetSize() > nNum) { - if (!(dwStyles & XFA_RESOLVENODE_ALL)) { - CXFA_NodeArray upArrayNodes; - if (m_pNodeHelper->XFA_NodeIsTransparent(ToNode(curNode))) { - m_pNodeHelper->XFA_CountSiblings( - ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, - !!(dwStyles & XFA_RESOLVENODE_TagName)); - } - if (upArrayNodes.GetSize() > nodes.GetSize()) { - upArrayNodes[0] = ToNode(nodes[0]); - nodes.RemoveAll(); - nodes.Append((CXFA_ObjArray&)upArrayNodes); - upArrayNodes.RemoveAll(); - } - } - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - if (nodes.GetSize() > 0) { - return 1; - } - return 0; - } - } - if (dwStyles & XFA_RESOLVENODE_Attributes) { - if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName)) { - return 1; - } - } - if (dwStyles & XFA_RESOLVENODE_Properties) { - for (int32_t i = 0; i < properties.GetSize(); i++) { - CXFA_Node* childProperty = properties[i]; - if (childProperty->IsUnnamed()) { - uint32_t uPropHash = childProperty->GetClassHashCode(); - if (uPropHash == uNameHash) { - nodes.Add(childProperty); - } - } else if (childProperty->GetNameHash() == uNameHash && - childProperty->GetClassID() != XFA_ELEMENT_Extras && - childProperty->GetClassID() != XFA_ELEMENT_Items) { - nodes.Add(childProperty); - } - } - if (nodes.GetSize() > nNum) { - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - if (nodes.GetSize() > 0) { - return 1; - } - return 0; - } - CXFA_Node* pProp = NULL; - if (XFA_ELEMENT_Subform == curNode->GetClassID() && - XFA_HASHCODE_Occur == uNameHash) { - CXFA_Node* pInstanceManager = - curNode->AsNode()->GetInstanceMgrOfSubform(); - if (pInstanceManager) { - pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE); - } - } else { - const XFA_ELEMENTINFO* pElement = XFA_GetElementByName(wsName); - if (pElement) { - pProp = curNode->AsNode()->GetProperty( - 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet); - } - } - if (pProp) { - nodes.Add(pProp); - return nodes.GetSize(); - } - } - CXFA_Node* parentNode = m_pNodeHelper->XFA_ResolveNodes_GetParent( - curNode->AsNode(), XFA_LOGIC_NoTransparent); - uint32_t uCurClassHash = curNode->GetClassHashCode(); - if (!parentNode) { - if (uCurClassHash == uNameHash) { - nodes.Add(curNode->AsNode()); - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - if (nodes.GetSize() > 0) { - return 1; - } - } - return 0; - } - if (dwStyles & XFA_RESOLVENODE_Siblings) { - CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild); - FX_DWORD dwSubStyles = - XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties; - if (dwStyles & XFA_RESOLVENODE_TagName) { - dwSubStyles |= XFA_RESOLVENODE_TagName; - } - if (dwStyles & XFA_RESOLVENODE_ALL) { - dwSubStyles |= XFA_RESOLVENODE_ALL; - } - rndFind.m_dwStyles = dwSubStyles; - while (child) { - if (child == curNode) { - if (dwStyles & XFA_RESOLVENODE_TagName) { - if (uCurClassHash == uNameHash) { - nodes.Add(curNode); - } - } else { - if (child->GetNameHash() == uNameHash) { - nodes.Add(curNode); - if (rnd.m_nLevel == 0 && wsCondition.GetLength() == 0) { - nodes.RemoveAll(); - nodes.Add(curNode); - return 1; - } - } - } - child = child->GetNodeItem(XFA_NODEITEM_NextSibling); - continue; - } - if (dwStyles & XFA_RESOLVENODE_TagName) { - if (child->GetClassHashCode() == uNameHash) { - nodes.Add(child); - } - } else if (child->GetNameHash() == uNameHash) { - nodes.Add(child); - } - const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( - parentNode->GetClassID(), child->GetClassID(), XFA_XDPPACKET_UNKNOWN); - FX_BOOL bInnerSearch = FALSE; - if (pPropert) { - if ((child->GetClassID() == XFA_ELEMENT_Variables || - child->GetClassID() == XFA_ELEMENT_PageSet)) { - bInnerSearch = TRUE; - } - } else { - if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { - bInnerSearch = TRUE; - } - } - if (bInnerSearch) { - rndFind.m_CurNode = child; - CFX_WideString wsOriginCondition = rndFind.m_wsCondition; - rndFind.m_wsCondition.Empty(); - FX_DWORD dwOriginStyle = rndFind.m_dwStyles; - rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; - XFA_ResolveNodes_Normal(rndFind); - rndFind.m_dwStyles = dwOriginStyle; - rndFind.m_wsCondition = wsOriginCondition; - if (rndFind.m_Nodes.GetSize() > 0) { - nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - } - child = child->GetNodeItem(XFA_NODEITEM_NextSibling); - } - if (nodes.GetSize() > nNum) { - if (m_pNodeHelper->XFA_NodeIsTransparent(parentNode)) { - CXFA_NodeArray upArrayNodes; - m_pNodeHelper->XFA_CountSiblings( - ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, - !!(dwStyles & XFA_RESOLVENODE_TagName)); - if (upArrayNodes.GetSize() > nodes.GetSize()) { - upArrayNodes[0] = ToNode(nodes[0]); - nodes.RemoveAll(); - nodes.Append((CXFA_ObjArray&)upArrayNodes); - upArrayNodes.RemoveAll(); - } - } - XFA_ResolveNode_FilterCondition(rnd, wsCondition); - if (nodes.GetSize() > 0) { - return 1; - } - return 0; - } - } - if (dwStyles & XFA_RESOLVENODE_Parent) { - FX_DWORD dwSubStyles = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_Properties; - if (dwStyles & XFA_RESOLVENODE_TagName) { - dwSubStyles |= XFA_RESOLVENODE_TagName; - } - if (dwStyles & XFA_RESOLVENODE_ALL) { - dwSubStyles |= XFA_RESOLVENODE_ALL; - } - rndFind.m_dwStyles = dwSubStyles; - rndFind.m_CurNode = parentNode; - CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); - array.Add(parentNode); - XFA_ResolveNodes_Normal(rndFind); - if (rndFind.m_Nodes.GetSize() > 0) { - nodes.Append(rndFind.m_Nodes); - rndFind.m_Nodes.RemoveAll(); - } - if (nodes.GetSize() > nNum) { - return 1; - } - } - return 0; -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Asterisk( - CXFA_ResolveNodesData& rnd) { - CXFA_Node* curNode = ToNode(rnd.m_CurNode); - CXFA_ObjArray& nodes = rnd.m_Nodes; - CXFA_NodeArray array; - curNode->GetNodeList(array, - XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties); - nodes.Append((CXFA_ObjArray&)array); - return nodes.GetSize(); -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_PopStack( - CFX_Int32Array& stack) { - int32_t nType = -1; - int32_t iSize = stack.GetSize() - 1; - if (iSize > -1) { - nType = stack[iSize]; - stack.RemoveAt(iSize, 1); - } - return nType; -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter( - const CFX_WideStringC& wsExpression, - int32_t nStart, - CXFA_ResolveNodesData& rnd) { - FXSYS_assert(nStart > -1); - int32_t iLength = wsExpression.GetLength(); - if (nStart >= iLength) { - return 0; - } - CFX_WideString& wsName = rnd.m_wsName; - CFX_WideString& wsCondition = rnd.m_wsCondition; - FX_WCHAR* pNameBuf = wsName.GetBuffer(iLength - nStart); - FX_WCHAR* pConditionBuf = wsCondition.GetBuffer(iLength - nStart); - int32_t nNameCount = 0; - int32_t nConditionCount = 0; - CFX_Int32Array stack; - int32_t nType = -1; - const FX_WCHAR* pSrc = wsExpression.GetPtr(); - FX_WCHAR wPrev = 0, wCur; - FX_BOOL bIsCondition = FALSE; - while (nStart < iLength) { - wCur = pSrc[nStart++]; - if (wCur == '.') { - if (wPrev == '\\') { - pNameBuf[nNameCount - 1] = wPrev = '.'; - continue; - } - if (nNameCount == 0) { - pNameBuf[nNameCount++] = wCur; - continue; - } - FX_WCHAR wLookahead = nStart < iLength ? pSrc[nStart] : 0; - if (wLookahead != '[' && wLookahead != '(') { - if (nType < 0) { - break; - } - } - } - if (wCur == '[' || wCur == '(') { - bIsCondition = TRUE; - } else if (wCur == '.' && nStart < iLength && - (pSrc[nStart] == '[' || pSrc[nStart] == '(')) { - bIsCondition = TRUE; - } - if (bIsCondition) { - pConditionBuf[nConditionCount++] = wCur; - } else { - pNameBuf[nNameCount++] = wCur; - } - FX_BOOL bRecursive = TRUE; - switch (nType) { - case 0: - if (wCur == ']') { - nType = XFA_ResolveNodes_PopStack(stack); - bRecursive = FALSE; - } - break; - case 1: - if (wCur == ')') { - nType = XFA_ResolveNodes_PopStack(stack); - bRecursive = FALSE; - } - break; - case 2: - if (wCur == '"') { - nType = XFA_ResolveNodes_PopStack(stack); - bRecursive = FALSE; - } - break; - } - if (bRecursive) { - switch (wCur) { - case '[': - stack.Add(nType); - nType = 0; - break; - case '(': - stack.Add(nType); - nType = 1; - break; - case '"': - stack.Add(nType); - nType = 2; - break; - } - } - wPrev = wCur; - } - if (stack.GetSize() > 0) { - return -1; - } - wsName.ReleaseBuffer(nNameCount); - wsName.TrimLeft(); - wsName.TrimRight(); - wsCondition.ReleaseBuffer(nConditionCount); - wsCondition.TrimLeft(); - wsCondition.TrimRight(); - rnd.m_uHashName = FX_HashCode_String_GetW(wsName, wsName.GetLength()); - return nStart; -} -void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( - int32_t iCurIndex, - CFX_WideString wsCondition, - int32_t iFoundCount, - CXFA_ResolveNodesData& rnd) { - CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; - int32_t iLen = wsCondition.GetLength(); - FX_BOOL bRelative = FALSE; - FX_BOOL bAll = FALSE; - int32_t i = 1; - for (; i < iLen; ++i) { - FX_WCHAR ch = wsCondition[i]; - if (ch == ' ') { - continue; - } - if (ch == '+' || ch == '-') { - bRelative = TRUE; - break; - } else if (ch == '*') { - bAll = TRUE; - break; - } else { - break; - } - } - if (bAll) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) { - m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); - m_pNodeHelper->m_iCreateCount = 1; - findNodes.RemoveAll(); - m_pNodeHelper->m_iCurAllStart = -1; - m_pNodeHelper->m_pAllStartParent = NULL; - } else { - if (m_pNodeHelper->m_iCurAllStart == -1) { - m_pNodeHelper->m_iCurAllStart = m_iCurStart; - m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode); - } - } - } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) { - if (m_pNodeHelper->m_iCurAllStart == -1) { - m_pNodeHelper->m_iCurAllStart = m_iCurStart; - } - } - return; - } - if (iFoundCount == 1 && !iLen) { - return; - } - CFX_WideString wsIndex; - wsIndex = wsCondition.Mid(i, iLen - 1 - i); - int32_t iIndex = wsIndex.GetInteger(); - if (bRelative) { - iIndex += iCurIndex; - } - if (iFoundCount <= iIndex || iIndex < 0) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { - m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); - m_pNodeHelper->m_iCreateCount = iIndex - iFoundCount + 1; - } - findNodes.RemoveAll(); - } else { - CXFA_Node* ret = findNodes[iIndex]; - findNodes.RemoveAll(); - findNodes.Add(ret); - } -} -void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter( - int32_t iCurIndex, - CFX_WideString wsCondition, - int32_t iFoundCount, - CXFA_ResolveNodesData& rnd) { - CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; - FXSYS_assert(iFoundCount == findNodes.GetSize()); - CFX_WideString wsExpression; - IXFA_ScriptContext* pContext = NULL; - XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown; - if (wsCondition.Left(2) == FX_WSTRC(L".[") && - wsCondition.Right(1) == FX_WSTRC(L"]")) { - eLangType = XFA_SCRIPTLANGTYPE_Formcalc; - } else if (wsCondition.Left(2) == FX_WSTRC(L".(") && - wsCondition.Right(1) == FX_WSTRC(L")")) { - eLangType = XFA_SCRIPTLANGTYPE_Javascript; - } else { - return; - } - pContext = rnd.m_pSC; - wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3); - for (int32_t i = iFoundCount - 1; i >= 0; i--) { - CXFA_Object* node = findNodes[i]; - FX_BOOL bRet = FALSE; - FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime()); - bRet = pContext->RunScript(eLangType, wsExpression, pRetValue, node); - if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) { - findNodes.RemoveAt(i); - } - FXJSE_Value_Release(pRetValue); - } -} - -void CXFA_ResolveProcessor::XFA_ResolveNode_FilterCondition( - CXFA_ResolveNodesData& rnd, - CFX_WideString wsCondition) { - CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; - int32_t iCurrIndex = 0; - const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); - int32_t iSize = array.GetSize(); - if (iSize) { - CXFA_Node* curNode = array[iSize - 1]; - FX_BOOL bIsProperty = m_pNodeHelper->XFA_NodeIsProperty(curNode); - if (curNode->IsUnnamed() || - (bIsProperty && curNode->GetClassID() != XFA_ELEMENT_PageSet)) { - iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, - bIsProperty, TRUE); - } else { - iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, - bIsProperty, FALSE); - } - } - int32_t iFoundCount = findNodes.GetSize(); - wsCondition.TrimLeft(); - wsCondition.TrimRight(); - int32_t iLen = wsCondition.GetLength(); - if (!iLen) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_ALL) { - return; - } - if (iFoundCount == 1) { - return; - } - if (iFoundCount <= iCurrIndex) { - if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { - m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); - m_pNodeHelper->m_iCreateCount = iCurrIndex - iFoundCount + 1; - } - findNodes.RemoveAll(); - return; - } else { - CXFA_Node* ret = findNodes[iCurrIndex]; - findNodes.RemoveAll(); - findNodes.Add(ret); - return; - } - } - FX_WCHAR wTypeChar = wsCondition[0]; - switch (wTypeChar) { - case '[': - XFA_ResolveNode_ConditionArray(iCurrIndex, wsCondition, iFoundCount, rnd); - return; - case '(': - return; - case '"': - return; - case '.': - if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) { - XFA_ResolveNode_DoPredicateFilter(iCurrIndex, wsCondition, iFoundCount, - rnd); - } - default: - return; - } -} -void CXFA_ResolveProcessor::XFA_ResolveNodes_SetStylesForChild( - FX_DWORD dwParentStyles, - CXFA_ResolveNodesData& rnd) { - FX_DWORD dwSubStyles = XFA_RESOLVENODE_Children; - if (dwParentStyles & XFA_RESOLVENODE_TagName) { - dwSubStyles |= XFA_RESOLVENODE_TagName; - } - dwSubStyles &= ~XFA_RESOLVENODE_Parent; - dwSubStyles &= ~XFA_RESOLVENODE_Siblings; - dwSubStyles &= ~XFA_RESOLVENODE_Properties; - dwSubStyles |= XFA_RESOLVENODE_ALL; - rnd.m_dwStyles = dwSubStyles; -} -int32_t CXFA_ResolveProcessor::XFA_ResolveNode_SetResultCreateNode( - XFA_RESOLVENODE_RS& resolveNodeRS, - CFX_WideString& wsLastCondition) { - if (m_pNodeHelper->m_pCreateParent) { - resolveNodeRS.nodes.Add(m_pNodeHelper->m_pCreateParent); - } else { - m_pNodeHelper->XFA_CreateNode_ForCondition(wsLastCondition); - } - resolveNodeRS.dwFlags = m_pNodeHelper->m_iCreateFlag; - if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { - if (m_pNodeHelper->m_iCurAllStart != -1) { - resolveNodeRS.dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll; - } - } - return resolveNodeRS.nodes.GetSize(); -} -void CXFA_ResolveProcessor::XFA_ResolveNode_SetIndexDataBind( - CFX_WideString& wsNextCondition, - int32_t& iIndex, - int32_t iCount) { - if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { - if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { - iIndex = 0; - } else { - iIndex = iCount - 1; - } - } else { - iIndex = iCount - 1; - } -} diff --git a/xfa/src/fxfa/parser/xfa_script_resolveprocessor.h b/xfa/src/fxfa/parser/xfa_script_resolveprocessor.h deleted file mode 100644 index 36e89392da..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_resolveprocessor.h +++ /dev/null @@ -1,86 +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_SRC_FXFA_PARSER_XFA_SCRIPT_RESOLVEPROCESSOR_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_RESOLVEPROCESSOR_H_ - -#include "xfa/include/fxfa/fxfa_objectacc.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -class CXFA_NodeHelper; -class CXFA_ScriptContext; - -class CXFA_ResolveNodesData { - public: - CXFA_ResolveNodesData(CXFA_ScriptContext* pSC = NULL) - : m_pSC(pSC), - m_CurNode(NULL), - m_wsName(), - m_uHashName(0), - m_wsCondition(), - m_nLevel(0), - m_Nodes(), - m_dwStyles(XFA_RESOLVENODE_Children), - m_pScriptAttribute(NULL), - m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {} - ~CXFA_ResolveNodesData() { m_Nodes.RemoveAll(); } - CXFA_ScriptContext* m_pSC; - CXFA_Object* m_CurNode; - CFX_WideString m_wsName; - uint32_t m_uHashName; - CFX_WideString m_wsCondition; - int32_t m_nLevel; - CXFA_ObjArray m_Nodes; - FX_DWORD m_dwStyles; - const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute; - XFA_RESOVENODE_RSTYPE m_dwFlag; -}; -class CXFA_ResolveProcessor { - public: - CXFA_ResolveProcessor(void); - ~CXFA_ResolveProcessor(void); - int32_t XFA_ResolveNodes(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_AnyChild(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_Dollar(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_Excalmatory(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_NumberSign(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_Asterisk(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_Normal(CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_ForAttributeRs(CXFA_Object* curNode, - CXFA_ResolveNodesData& rnd, - const CFX_WideStringC& strAttr); - void XFA_ResolveNode_ConditionArray(int32_t iCurIndex, - CFX_WideString wsCondition, - int32_t iFoundCount, - CXFA_ResolveNodesData& rnd); - void XFA_ResolveNode_DoPredicateFilter(int32_t iCurIndex, - CFX_WideString wsCondition, - int32_t iFoundCount, - CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNodes_GetFilter(const CFX_WideStringC& wsExpression, - int32_t nStart, - CXFA_ResolveNodesData& rnd); - void XFA_ResolveNode_FilterCondition(CXFA_ResolveNodesData& rnd, - CFX_WideString wsCondition); - int32_t XFA_ResolveNodes_PopStack(CFX_Int32Array& stack); - void XFA_ResolveNodes_SetStylesForChild(FX_DWORD dwParentStyles, - CXFA_ResolveNodesData& rnd); - int32_t XFA_ResolveNode_SetResultCreateNode(XFA_RESOLVENODE_RS& resolveNodeRS, - CFX_WideString& wsLastCondition); - void XFA_ResolveNode_SetIndexDataBind(CFX_WideString& wsNextCondition, - int32_t& iIndex, - int32_t iCount); - CXFA_NodeHelper* GetNodeHelper() { return m_pNodeHelper; } - - private: - CXFA_NodeHelper* m_pNodeHelper; - - public: - int32_t m_iCurStart; -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_RESOLVEPROCESSOR_H_ diff --git a/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.cpp b/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.cpp deleted file mode 100644 index a721338864..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.cpp +++ /dev/null @@ -1,124 +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/src/fxfa/parser/xfa_script_signaturepseudomodel.h" - -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( - CXFA_Document* pDocument) - : CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_SignaturePseudoModel) { - m_uScriptHash = XFA_HASHCODE_Signature; -} -CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} -void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Verify( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CXFA_Node* pNode = NULL; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - int32_t bVerify = pNotify->GetDocProvider()->Verify(hDoc, pNode); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetInteger(hValue, bVerify); - } -} -void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Sign( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 3 || iLength > 7) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CXFA_NodeList* pNodeList = NULL; - CFX_WideString wsExpression; - CFX_WideString wsXMLIdent; - if (iLength >= 1) { - pNodeList = (CXFA_NodeList*)pArguments->GetObject(0); - } - if (iLength >= 2) { - CFX_ByteString bsExpression = pArguments->GetUTF8String(1); - wsExpression = - CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); - } - if (iLength >= 3) { - CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2); - wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent, bsXMLIdent.GetLength()); - } - FX_BOOL bSign = pNotify->GetDocProvider()->Sign(hDoc, pNodeList, wsExpression, - wsXMLIdent); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, bSign); - } -} -void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Enumerate( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 0) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CXFA_NodeList* pList = pNotify->GetDocProvider()->Enumerate(hDoc); - if (!pList) - return; - FXJSE_Value_Set(pArguments->GetReturnValue(), - m_pDocument->GetScriptContext()->GetJSValueFromMap(pList)); -} -void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Clear( - CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 2) { - ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear"); - return; - } - IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); - if (!pNotify) { - return; - } - IXFA_Doc* hDoc = pNotify->GetHDOC(); - CXFA_Node* pNode = NULL; - FX_BOOL bClear = TRUE; - if (iLength >= 1) { - pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); - } - if (iLength >= 2) { - bClear = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - } - FX_BOOL bFlag = pNotify->GetDocProvider()->Clear(hDoc, pNode, bClear); - FXJSE_HVALUE hValue = pArguments->GetReturnValue(); - if (hValue) { - FXJSE_Value_SetBoolean(hValue, bFlag); - } -} diff --git a/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h b/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h deleted file mode 100644 index f7c64971d0..0000000000 --- a/xfa/src/fxfa/parser/xfa_script_signaturepseudomodel.h +++ /dev/null @@ -1,22 +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_SRC_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_ -#define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_ - -#include "xfa/src/fxfa/parser/xfa_object.h" - -class CScript_SignaturePseudoModel : public CXFA_OrdinaryObject { - public: - CScript_SignaturePseudoModel(CXFA_Document* pDocument); - ~CScript_SignaturePseudoModel(); - void Script_SignaturePseudoModel_Verify(CFXJSE_Arguments* pArguments); - void Script_SignaturePseudoModel_Sign(CFXJSE_Arguments* pArguments); - void Script_SignaturePseudoModel_Enumerate(CFXJSE_Arguments* pArguments); - void Script_SignaturePseudoModel_Clear(CFXJSE_Arguments* pArguments); -}; - -#endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_ diff --git a/xfa/src/fxfa/parser/xfa_utils.h b/xfa/src/fxfa/parser/xfa_utils.h deleted file mode 100644 index 497cb29cc4..0000000000 --- a/xfa/src/fxfa/parser/xfa_utils.h +++ /dev/null @@ -1,219 +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_SRC_FXFA_PARSER_XFA_UTILS_H_ -#define XFA_SRC_FXFA_PARSER_XFA_UTILS_H_ - -#include "xfa/include/fxfa/fxfa_basic.h" -#include "xfa/src/fde/xml/fde_xml.h" - -class CXFA_LocaleValue; - -FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( - IFDE_XMLElement* pNode, - const CFX_WideStringC& wsQualifier, - CFX_WideString& wsNamespaceURI); -template <class NodeType, class TraverseStrategy> -class CXFA_NodeIteratorTemplate { - public: - CXFA_NodeIteratorTemplate(NodeType* pRootNode = NULL) : m_pRoot(pRootNode) { - if (pRootNode) { - m_NodeStack.Push(pRootNode); - } - } - FX_BOOL Init(NodeType* pRootNode) { - if (!pRootNode) { - return FALSE; - } - m_pRoot = pRootNode; - m_NodeStack.RemoveAll(); - m_NodeStack.Push(pRootNode); - return TRUE; - } - void Clear() { m_NodeStack.RemoveAll(); } - void Reset() { - Clear(); - if (m_pRoot) { - m_NodeStack.Push(m_pRoot); - } - } - FX_BOOL SetCurrent(NodeType* pCurNode) { - m_NodeStack.RemoveAll(); - if (pCurNode) { - CFX_StackTemplate<NodeType*> revStack; - NodeType* pNode; - for (pNode = pCurNode; pNode && pNode != m_pRoot; - pNode = TraverseStrategy::GetParent(pNode)) { - revStack.Push(pNode); - } - if (!pNode) { - return FALSE; - } - revStack.Push(m_pRoot); - while (revStack.GetSize()) { - m_NodeStack.Push(*revStack.GetTopElement()); - revStack.Pop(); - } - } - return TRUE; - } - NodeType* GetCurrent() const { - return m_NodeStack.GetSize() ? *m_NodeStack.GetTopElement() : NULL; - } - NodeType* GetRoot() const { return m_pRoot; } - NodeType* MoveToPrev() { - int32_t nStackLength = m_NodeStack.GetSize(); - if (nStackLength == 1) { - return NULL; - } else if (nStackLength > 1) { - NodeType* pCurItem = *m_NodeStack.GetTopElement(); - m_NodeStack.Pop(); - NodeType* pParentItem = *m_NodeStack.GetTopElement(); - NodeType* pParentFirstChildItem = - TraverseStrategy::GetFirstChild(pParentItem); - if (pCurItem == pParentFirstChildItem) { - return pParentItem; - } - NodeType *pPrevItem = pParentFirstChildItem, *pPrevItemNext = NULL; - for (; pPrevItem; pPrevItem = pPrevItemNext) { - pPrevItemNext = TraverseStrategy::GetNextSibling(pPrevItem); - if (!pPrevItemNext || pPrevItemNext == pCurItem) { - break; - } - } - m_NodeStack.Push(pPrevItem); - } else { - m_NodeStack.RemoveAll(); - if (m_pRoot) { - m_NodeStack.Push(m_pRoot); - } - } - if (m_NodeStack.GetSize() > 0) { - NodeType* pChildItem = *m_NodeStack.GetTopElement(); - while ((pChildItem = TraverseStrategy::GetFirstChild(pChildItem)) != - NULL) { - while (NodeType* pNextItem = - TraverseStrategy::GetNextSibling(pChildItem)) { - pChildItem = pNextItem; - } - m_NodeStack.Push(pChildItem); - } - return *m_NodeStack.GetTopElement(); - } - return NULL; - } - NodeType* MoveToNext() { - NodeType** ppNode = NULL; - NodeType* pCurrent = GetCurrent(); - while (m_NodeStack.GetSize() > 0) { - while ((ppNode = m_NodeStack.GetTopElement())) { - if (pCurrent != *ppNode) { - return *ppNode; - } - NodeType* pChild = TraverseStrategy::GetFirstChild(*ppNode); - if (pChild == NULL) { - break; - } - m_NodeStack.Push(pChild); - } - while ((ppNode = m_NodeStack.GetTopElement())) { - NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); - m_NodeStack.Pop(); - if (m_NodeStack.GetSize() == 0) { - break; - } - if (pNext) { - m_NodeStack.Push(pNext); - break; - } - } - } - return NULL; - } - NodeType* SkipChildrenAndMoveToNext() { - NodeType** ppNode = NULL; - while ((ppNode = m_NodeStack.GetTopElement())) { - NodeType* pNext = TraverseStrategy::GetNextSibling(*ppNode); - m_NodeStack.Pop(); - if (m_NodeStack.GetSize() == 0) { - break; - } - if (pNext) { - m_NodeStack.Push(pNext); - break; - } - } - return GetCurrent(); - } - - protected: - 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); - -FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode); -void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, - CFX_WideString& wsPlainText); -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, - const FX_CHAR* pChecksum = NULL, - FX_BOOL bSaveXML = FALSE); - -#endif // XFA_SRC_FXFA_PARSER_XFA_UTILS_H_ diff --git a/xfa/src/fxfa/parser/xfa_utils_imp.cpp b/xfa/src/fxfa/parser/xfa_utils_imp.cpp deleted file mode 100644 index 32f5ce125f..0000000000 --- a/xfa/src/fxfa/parser/xfa_utils_imp.cpp +++ /dev/null @@ -1,403 +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/src/fxfa/parser/xfa_utils.h" - -#include "core/include/fxcrt/fx_ext.h" -#include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" -#include "xfa/src/fxfa/parser/xfa_docdata.h" -#include "xfa/src/fxfa/parser/xfa_doclayout.h" -#include "xfa/src/fxfa/parser/xfa_document.h" -#include "xfa/src/fxfa/parser/xfa_localemgr.h" -#include "xfa/src/fxfa/parser/xfa_localevalue.h" -#include "xfa/src/fxfa/parser/xfa_object.h" -#include "xfa/src/fxfa/parser/xfa_parser.h" -#include "xfa/src/fxfa/parser/xfa_script.h" - -CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_ELEMENT& eWidgetType) { - XFA_ELEMENT eType = pNode->GetClassID(); - eWidgetType = eType; - if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_Draw) { - return NULL; - } - eWidgetType = XFA_ELEMENT_UNKNOWN; - XFA_ELEMENT eUIType = XFA_ELEMENT_UNKNOWN; - CXFA_Value defValue(pNode->GetProperty(0, XFA_ELEMENT_Value, TRUE)); - XFA_ELEMENT eValueType = (XFA_ELEMENT)defValue.GetChildValueClassID(); - switch (eValueType) { - case XFA_ELEMENT_Boolean: - eUIType = XFA_ELEMENT_CheckButton; - break; - case XFA_ELEMENT_Integer: - case XFA_ELEMENT_Decimal: - case XFA_ELEMENT_Float: - eUIType = XFA_ELEMENT_NumericEdit; - break; - case XFA_ELEMENT_ExData: - case XFA_ELEMENT_Text: - eUIType = XFA_ELEMENT_TextEdit; - eWidgetType = XFA_ELEMENT_Text; - break; - case XFA_ELEMENT_Date: - case XFA_ELEMENT_Time: - case XFA_ELEMENT_DateTime: - eUIType = XFA_ELEMENT_DateTimeEdit; - break; - case XFA_ELEMENT_Image: - eUIType = XFA_ELEMENT_ImageEdit; - eWidgetType = XFA_ELEMENT_Image; - break; - case XFA_ELEMENT_Arc: - case XFA_ELEMENT_Line: - case XFA_ELEMENT_Rectangle: - eUIType = XFA_ELEMENT_DefaultUi; - eWidgetType = eValueType; - break; - default: - break; - } - CXFA_Node* pUIChild = NULL; - CXFA_Node* pUI = pNode->GetProperty(0, XFA_ELEMENT_Ui, TRUE); - CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); - for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ELEMENT eChild = pChild->GetClassID(); - if (eChild == XFA_ELEMENT_Extras || eChild == XFA_ELEMENT_Picture) { - continue; - } - const XFA_PROPERTY* pProperty = - XFA_GetPropertyOfElement(XFA_ELEMENT_Ui, eChild, XFA_XDPPACKET_Form); - if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { - pUIChild = pChild; - break; - } - } - if (eType == XFA_ELEMENT_Draw) { - XFA_ELEMENT eDraw = pUIChild ? pUIChild->GetClassID() : XFA_ELEMENT_UNKNOWN; - switch (eDraw) { - case XFA_ELEMENT_TextEdit: - eWidgetType = XFA_ELEMENT_Text; - break; - case XFA_ELEMENT_ImageEdit: - eWidgetType = XFA_ELEMENT_Image; - break; - default: - eWidgetType = - eWidgetType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_Text : eWidgetType; - break; - } - } else { - if (pUIChild && pUIChild->GetClassID() == XFA_ELEMENT_DefaultUi) { - eWidgetType = XFA_ELEMENT_TextEdit; - } else { - eWidgetType = pUIChild - ? pUIChild->GetClassID() - : (eUIType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_TextEdit - : eUIType); - } - } - if (!pUIChild) { - if (eUIType == XFA_ELEMENT_UNKNOWN) { - eUIType = XFA_ELEMENT_TextEdit; - defValue.GetNode()->GetProperty(0, XFA_ELEMENT_Text, TRUE); - } - pUIChild = pUI->GetProperty(0, eUIType, TRUE); - } else if (eUIType == XFA_ELEMENT_UNKNOWN) { - switch (pUIChild->GetClassID()) { - case XFA_ELEMENT_CheckButton: { - eValueType = XFA_ELEMENT_Text; - if (CXFA_Node* pItems = pNode->GetChild(0, XFA_ELEMENT_Items)) { - if (CXFA_Node* pItem = pItems->GetChild(0, XFA_ELEMENT_UNKNOWN)) { - eValueType = pItem->GetClassID(); - } - } - } break; - case XFA_ELEMENT_DateTimeEdit: - eValueType = XFA_ELEMENT_DateTime; - break; - case XFA_ELEMENT_ImageEdit: - eValueType = XFA_ELEMENT_Image; - break; - case XFA_ELEMENT_NumericEdit: - eValueType = XFA_ELEMENT_Float; - break; - case XFA_ELEMENT_ChoiceList: { - eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) == - XFA_ATTRIBUTEENUM_MultiSelect) - ? XFA_ELEMENT_ExData - : XFA_ELEMENT_Text; - } break; - case XFA_ELEMENT_Barcode: - case XFA_ELEMENT_Button: - case XFA_ELEMENT_PasswordEdit: - case XFA_ELEMENT_Signature: - case XFA_ELEMENT_TextEdit: - default: - eValueType = XFA_ELEMENT_Text; - break; - } - defValue.GetNode()->GetProperty(0, eValueType, TRUE); - } - return pUIChild; -} -CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { - CXFA_Node* pNodeValue = - pWidgetData->GetNode()->GetChild(0, XFA_ELEMENT_Value); - if (!pNodeValue) { - return CXFA_LocaleValue(); - } - CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pValueChild) { - return CXFA_LocaleValue(); - } - int32_t iVTType = XFA_VT_NULL; - XFA_ELEMENT eType = pValueChild->GetClassID(); - switch (eType) { - case XFA_ELEMENT_Decimal: - iVTType = XFA_VT_DECIMAL; - break; - case XFA_ELEMENT_Float: - iVTType = XFA_VT_FLOAT; - break; - case XFA_ELEMENT_Date: - iVTType = XFA_VT_DATE; - break; - case XFA_ELEMENT_Time: - iVTType = XFA_VT_TIME; - break; - case XFA_ELEMENT_DateTime: - iVTType = XFA_VT_DATETIME; - break; - case XFA_ELEMENT_Boolean: - iVTType = XFA_VT_BOOLEAN; - break; - case XFA_ELEMENT_Integer: - iVTType = XFA_VT_INTEGER; - break; - case XFA_ELEMENT_Text: - iVTType = XFA_VT_TEXT; - break; - default: - iVTType = XFA_VT_NULL; - break; - } - return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), - pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); -} -void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, - CFX_WideString& wsPlainText) { - if (pXMLNode == NULL) { - return; - } - switch (pXMLNode->GetType()) { - case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; - CFX_WideString wsTag; - pXMLElement->GetLocalTagName(wsTag); - uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); - if (uTag == 0x0001f714) { - wsPlainText += L"\n"; - } else if (uTag == 0x00000070) { - if (!wsPlainText.IsEmpty()) { - wsPlainText += L"\n"; - } - } else if (uTag == 0xa48ac63) { - if (!wsPlainText.IsEmpty() && - wsPlainText[wsPlainText.GetLength() - 1] != '\n') { - wsPlainText += L"\n"; - } - } - } break; - case FDE_XMLNODE_Text: { - CFX_WideString wsContent; - ((IFDE_XMLText*)pXMLNode)->GetText(wsContent); - wsPlainText += wsContent; - } break; - case FDE_XMLNODE_CharData: { - CFX_WideString wsCharData; - ((IFDE_XMLCharData*)pXMLNode)->GetCharData(wsCharData); - wsPlainText += wsCharData; - } break; - default: - break; - } - for (IFDE_XMLNode* pChildXML = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); - pChildXML; - pChildXML = pChildXML->GetNodeItem(IFDE_XMLNode::NextSibling)) { - XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); - } -} -FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { - FX_BOOL bRet = FALSE; - if (!pFieldNode) { - return bRet; - } - CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui); - if (pUIChild) { - CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pFirstChild && pFirstChild->GetClassID() == XFA_ELEMENT_ChoiceList) { - bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) == - XFA_ATTRIBUTEENUM_MultiSelect; - } - } - return bRet; -} -FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, FX_BOOL bLayoutContainer) { - switch (eElement) { - case XFA_ELEMENT_Draw: - case XFA_ELEMENT_Field: - case XFA_ELEMENT_InstanceManager: - return !bLayoutContainer; - case XFA_ELEMENT_Area: - case XFA_ELEMENT_Subform: - case XFA_ELEMENT_ExclGroup: - case XFA_ELEMENT_SubformSet: - return TRUE; - case XFA_ELEMENT_PageArea: - case XFA_ELEMENT_Form: - return TRUE; - default: - return FALSE; - } - 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, - 0.0001, - 0.00001, - 0.000001, - 0.0000001, - 0.00000001, - 0.000000001, - 0.0000000001, - 0.00000000001, - 0.000000000001, - 0.0000000000001, - 0.00000000000001, - 0.000000000000001, - 0.0000000000000001}; -FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal) { - CFX_WideString wsValue = wsStringVal; - wsValue.TrimLeft(); - wsValue.TrimRight(); - int64_t nIntegral = 0; - FX_DWORD dwFractional = 0; - int32_t nExponent = 0; - int32_t cc = 0; - FX_BOOL bNegative = FALSE, bExpSign = FALSE; - const FX_WCHAR* str = (const FX_WCHAR*)wsValue; - int32_t len = wsValue.GetLength(); - if (str[0] == '+') { - cc++; - } else if (str[0] == '-') { - bNegative = TRUE; - cc++; - } - int32_t nIntegralLen = 0; - while (cc < len) { - if (str[cc] == '.' || str[cc] == 'E' || str[cc] == 'e' || - nIntegralLen > 17) { - break; - } - if (!XFA_IsDigit(str[cc])) { - return 0; - } - nIntegral = nIntegral * 10 + str[cc] - '0'; - cc++; - nIntegralLen++; - } - nIntegral = bNegative ? -nIntegral : nIntegral; - int32_t scale = 0; - FX_DOUBLE fraction = 0.0; - if (cc < len && str[cc] == '.') { - cc++; - while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); - scale++; - cc++; - if (cc == len) { - break; - } - if (scale == sizeof(fraction_scales) / sizeof(FX_DOUBLE) || - str[cc] == 'E' || str[cc] == 'e') { - break; - } - if (!XFA_IsDigit(str[cc])) { - return 0; - } - } - dwFractional = (FX_DWORD)(fraction * 4294967296.0); - } - if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { - cc++; - if (cc < len) { - if (str[cc] == '+') { - cc++; - } else if (str[cc] == '-') { - bExpSign = TRUE; - cc++; - } - } - while (cc < len) { - if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { - return 0; - } - nExponent = nExponent * 10 + str[cc] - '0'; - cc++; - } - nExponent = bExpSign ? -nExponent : nExponent; - } - FX_DOUBLE dValue = (dwFractional / 4294967296.0); - dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); - if (nExponent != 0) { - dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); - } - return dValue; -} - -FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { - CFX_WideString wsValue = - CFX_WideString::FromUTF8(szStringVal.GetCStr(), szStringVal.GetLength()); - return XFA_WideStringToDouble(wsValue); -} - -int32_t XFA_MapRotation(int32_t nRotation) { - nRotation = nRotation % 360; - nRotation = nRotation < 0 ? nRotation + 360 : nRotation; - return nRotation; -} diff --git a/xfa/src/fxfa/parser/xfa_utils_imp_unittest.cpp b/xfa/src/fxfa/parser/xfa_utils_imp_unittest.cpp deleted file mode 100644 index d5f0e4a923..0000000000 --- a/xfa/src/fxfa/parser/xfa_utils_imp_unittest.cpp +++ /dev/null @@ -1,22 +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. - -#include "testing/gtest/include/gtest/gtest.h" -#include "xfa/src/fxfa/parser/xfa_utils.h" - -TEST(XfaUtilsImp, XFA_MapRotation) { - struct TestCase { - int input; - int expected_output; - } TestCases[] = {{-1000000, 80}, {-361, 359}, {-360, 0}, {-359, 1}, - {-91, 269}, {-90, 270}, {-89, 271}, {-1, 359}, - {0, 0}, {1, 1}, {89, 89}, {90, 90}, - {91, 91}, {359, 359}, {360, 0}, {361, 1}, - {100000, 280}}; - - for (size_t i = 0; i < FX_ArraySize(TestCases); ++i) { - EXPECT_EQ(TestCases[i].expected_output, - XFA_MapRotation(TestCases[i].input)); - } -} diff --git a/xfa/src/fxgraphics/fx_graphics.cpp b/xfa/src/fxgraphics/fx_graphics.cpp deleted file mode 100644 index 249c72e73f..0000000000 --- a/xfa/src/fxgraphics/fx_graphics.cpp +++ /dev/null @@ -1,1548 +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/include/fxgraphics/fx_graphics.h" - -#include <memory> - -#include "xfa/src/fxgraphics/fx_path_generator.h" -#include "xfa/src/fxgraphics/pre.h" - -class CAGG_Graphics { - public: - CAGG_Graphics(); - FX_ERR Create(CFX_Graphics* owner, - int32_t width, - int32_t height, - FXDIB_Format format); - virtual ~CAGG_Graphics(); - - private: - CFX_Graphics* _owner; -}; -CFX_Graphics::CFX_Graphics() { - _type = FX_CONTEXT_None; - _info._graphState.SetDashCount(0); - _info._isAntialiasing = TRUE; - _info._strokeAlignment = FX_STROKEALIGNMENT_Center; - _info._CTM.SetIdentity(); - _info._isActOnDash = FALSE; - _info._strokeColor = NULL; - _info._fillColor = NULL; - _info._font = NULL; - _info._fontSize = 40.0; - _info._fontHScale = 1.0; - _info._fontSpacing = 0.0; - _renderDevice = NULL; - _aggGraphics = NULL; -} -FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, - FX_BOOL isAntialiasing) { - if (!renderDevice) - return FX_ERR_Parameter_Invalid; - if (_type != FX_CONTEXT_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_CONTEXT_Device; - _info._isAntialiasing = isAntialiasing; - _renderDevice = renderDevice; - if (_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) { - return FX_ERR_Succeeded; - } - return FX_ERR_Indefinite; -} -FX_ERR CFX_Graphics::Create(int32_t width, - int32_t height, - FXDIB_Format format, - FX_BOOL isNative, - FX_BOOL isAntialiasing) { - if (_type != FX_CONTEXT_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_CONTEXT_Device; - _info._isAntialiasing = isAntialiasing; - { - _aggGraphics = new CAGG_Graphics; - return _aggGraphics->Create(this, width, height, format); - } -} -CFX_Graphics::~CFX_Graphics() { - if (_aggGraphics) { - delete _aggGraphics; - _aggGraphics = NULL; - } - _renderDevice = NULL; - _info._graphState.SetDashCount(0); - _type = FX_CONTEXT_None; -} -FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - capVal = _renderDevice->GetDeviceCaps(capID); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - int32_t deviceClass = _renderDevice->GetDeviceClass(); - if (deviceClass == FXDC_PRINTER) { - isPrinter = TRUE; - } else { - isPrinter = FALSE; - } - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._isAntialiasing = isAntialiasing; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SaveGraphState() { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _renderDevice->SaveState(); - TInfo* info = new TInfo; - info->_graphState.Copy(_info._graphState); - info->_isAntialiasing = _info._isAntialiasing; - info->_strokeAlignment = _info._strokeAlignment; - info->_CTM = _info._CTM; - info->_isActOnDash = _info._isActOnDash; - info->_strokeColor = _info._strokeColor; - info->_fillColor = _info._fillColor; - info->_font = _info._font; - info->_fontSize = _info._fontSize; - info->_fontHScale = _info._fontHScale; - info->_fontSpacing = _info._fontSpacing; - _infoStack.Add(info); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::RestoreGraphState() { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _renderDevice->RestoreState(); - int32_t size = _infoStack.GetSize(); - if (size <= 0) { - return FX_ERR_Intermediate_Value_Invalid; - } - int32_t topIndex = size - 1; - TInfo* info = (TInfo*)_infoStack.GetAt(topIndex); - if (!info) - return FX_ERR_Intermediate_Value_Invalid; - _info._graphState.Copy(info->_graphState); - _info._isAntialiasing = info->_isAntialiasing; - _info._strokeAlignment = info->_strokeAlignment; - _info._CTM = info->_CTM; - _info._isActOnDash = info->_isActOnDash; - _info._strokeColor = info->_strokeColor; - _info._fillColor = info->_fillColor; - _info._font = info->_font; - _info._fontSize = info->_fontSize; - _info._fontHScale = info->_fontHScale; - _info._fontSpacing = info->_fontSpacing; - delete info; - info = NULL; - _infoStack.RemoveAt(topIndex); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - lineCap = _info._graphState.m_LineCap; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._graphState.m_LineCap = lineCap; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - dashCount = _info._graphState.m_DashCount; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) { - if (!dashArray) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - dashPhase = _info._graphState.m_DashPhase; - FXSYS_memcpy(dashArray, _info._graphState.m_DashArray, - _info._graphState.m_DashCount * sizeof(FX_FLOAT)); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, - FX_FLOAT* dashArray, - int32_t dashCount) { - if (dashCount > 0 && !dashArray) { - return FX_ERR_Parameter_Invalid; - } - dashCount = dashCount < 0 ? 0 : dashCount; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - FX_FLOAT scale = 1.0; - if (_info._isActOnDash) { - scale = _info._graphState.m_LineWidth; - } - _info._graphState.m_DashPhase = dashPhase; - _info._graphState.SetDashCount(dashCount); - for (int32_t i = 0; i < dashCount; i++) { - _info._graphState.m_DashArray[i] = dashArray[i] * scale; - } - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceSetLineDash(dashStyle); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - lineJoin = _info._graphState.m_LineJoin; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._graphState.m_LineJoin = lineJoin; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - miterLimit = _info._graphState.m_MiterLimit; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._graphState.m_MiterLimit = miterLimit; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - lineWidth = _info._graphState.m_LineWidth; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._graphState.m_LineWidth = lineWidth; - _info._isActOnDash = isActOnDash; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - strokeAlignment = _info._strokeAlignment; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._strokeAlignment = strokeAlignment; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { - if (!color) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._strokeColor = color; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { - if (!color) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._fillColor = color; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceStrokePath(path, matrix); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::FillPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceFillPath(path, fillMode, matrix); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - FX_BOOL result = _renderDevice->SetClip_PathFill( - path->GetPathData(), (CFX_Matrix*)matrix, fillMode); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix) { - if (!source) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceDrawImage(source, point, matrix); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix) { - if (!source) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceStretchImage(source, rect, matrix); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { - if (!matrix) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._CTM.Concat(*matrix); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -CFX_Matrix* CFX_Graphics::GetMatrix() { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return NULL; - return &_info._CTM; - } - default: { return NULL; } - } -} -FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - FX_RECT r = _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; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - if (!_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 FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::ClearClip() { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { - if (!font) - return FX_ERR_Parameter_Invalid; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._font = font; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { - FX_FLOAT fontSize = size <= 0 ? 1.0f : size; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._fontSize = fontSize; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { - FX_FLOAT fontHScale = scale <= 0 ? 1.0f : scale; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._fontHScale = fontHScale; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { - FX_FLOAT fontSpacing = spacing < 0 ? 0 : spacing; - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - _info._fontSpacing = fontSpacing; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - return RenderDeviceShowText(point, text, matrix); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, - const CFX_WideString& text, - FX_BOOL isMultiline, - CFX_Matrix* matrix) { - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - int32_t length = text.GetLength(); - FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); - CalcTextInfo(text, charCodes, charPos, rect); - FX_Free(charPos); - FX_Free(charCodes); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, - const CFX_Matrix* matrix) { - if (!graphics) - return FX_ERR_Parameter_Invalid; - CFX_Matrix m; - m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - { - if (!graphics->_renderDevice) - return FX_ERR_Parameter_Invalid; - CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); - FX_BOOL result = _renderDevice->SetDIBits(bitmap, 0, 0); - if (!result) - return FX_ERR_Method_Not_Supported; - } - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, - FX_FLOAT srcLeft, - FX_FLOAT srcTop, - const CFX_RectF& dstRect, - const CFX_Matrix* matrix) { - if (!graphics) - return FX_ERR_Parameter_Invalid; - CFX_Matrix m; - m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (_type) { - case FX_CONTEXT_Device: { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - { - if (!graphics->_renderDevice) - return FX_ERR_Parameter_Invalid; - CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); - CFX_DIBitmap bmp; - FX_BOOL result = - bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, - bitmap->GetFormat()); - if (!result) - return FX_ERR_Intermediate_Value_Invalid; - result = graphics->_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, - (int32_t)srcTop); - if (!result) - return FX_ERR_Method_Not_Supported; - result = _renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, - (int32_t)dstRect.top); - if (!result) - return FX_ERR_Method_Not_Supported; - return FX_ERR_Succeeded; - } - } - default: { return FX_ERR_Property_Invalid; } - } -} -CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { - return _renderDevice; -} -FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); - if (!bitmap) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - _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; - } - FX_ARGB* pBuf = - (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pLine = pBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pLine; - *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); - } - pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); - } - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, - const CFX_RectF& rect) { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* dst = _renderDevice->GetBitmap(); - if (!dst) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - _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; - } - FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + - int32_t(r.top) * srcBitmap->GetPitch()); - FX_ARGB* pDstBuf = - (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; - FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pDstLine; - *pDstLine++ = - ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); - pSrcLine++; - } - pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); - pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); - } - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, - const CFX_RectF& rect) { - if (!_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* dst = _renderDevice->GetBitmap(); - if (!dst) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - _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; - } - FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + - int32_t(r.top) * srcBitmap->GetPitch()); - FX_ARGB* pDstBuf = - (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; - FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pDstLine; - *pDstLine++ = - ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); - pSrcLine++; - } - pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); - pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); - } - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { - switch (dashStyle) { - case FX_DASHSTYLE_Solid: { - _info._graphState.SetDashCount(0); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_Dash: { - FX_FLOAT dashArray[] = {3, 1}; - SetLineDash(0, dashArray, 2); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_Dot: { - FX_FLOAT dashArray[] = {1, 1}; - SetLineDash(0, dashArray, 2); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_DashDot: { - FX_FLOAT dashArray[] = {3, 1, 1, 1}; - SetLineDash(0, dashArray, 4); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_DashDotDot: { - FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; - SetLineDash(0, dashArray, 6); - return FX_ERR_Succeeded; - } - default: { return FX_ERR_Parameter_Invalid; } - } -} -FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, - CFX_Matrix* matrix) { - if (!_info._strokeColor) - return FX_ERR_Property_Invalid; - CFX_Matrix m; - m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (_info._strokeColor->_type) { - case FX_COLOR_Solid: { - FX_BOOL result = _renderDevice->DrawPath( - path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 0x0, - _info._strokeColor->_argb, 0); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_Succeeded; - } - case FX_COLOR_Pattern: { - return StrokePathWithPattern(path, &m); - } - case FX_COLOR_Shading: { - return StrokePathWithShading(path, &m); - } - default: { return FX_ERR_Property_Invalid; } - } -} -FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!_info._fillColor) - return FX_ERR_Property_Invalid; - CFX_Matrix m; - m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (_info._fillColor->_type) { - case FX_COLOR_Solid: { - FX_BOOL result = _renderDevice->DrawPath( - path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, - _info._fillColor->_argb, 0x0, fillMode); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_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; } - } -} -FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m1.Concat(*matrix); - } - CFX_Matrix m2; - m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), - point.x, point.y); - m2.Concat(m1); - int32_t left, top; - CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); - CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m2, left, top); - CFX_RectF r; - GetClipRect(r); - FX_ERR result = FX_ERR_Indefinite; - { - CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); - CFX_DIBitmap bmp; - bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb); - _renderDevice->GetDIBits(&bmp, 0, 0); - bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), - FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp2, - FXSYS_round(r.left - left), FXSYS_round(r.top - top)); - _renderDevice->SetDIBits(&bmp, 0, 0); - result = FX_ERR_Succeeded; - } - if (bmp2) { - delete bmp2; - bmp2 = NULL; - } - if (bmp1) { - delete bmp1; - bmp1 = NULL; - } - return result; -} -FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - if (matrix) { - m1.Concat(*matrix); - } - CFX_DIBitmap* bmp1 = - source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); - CFX_Matrix m2; - m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); - m2.Concat(m1); - int32_t left, top; - CFX_DIBitmap* bmp2 = bmp1->FlipImage(FALSE, TRUE); - CFX_DIBitmap* bmp3 = bmp2->TransformTo((CFX_Matrix*)&m2, left, top); - CFX_RectF r; - GetClipRect(r); - FX_ERR result = FX_ERR_Indefinite; - { - CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); - bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), - FXSYS_round(r.Width()), FXSYS_round(r.Height()), - bmp3, FXSYS_round(r.left - left), - FXSYS_round(r.top - top)); - result = FX_ERR_Succeeded; - } - if (bmp3) { - delete bmp3; - bmp3 = NULL; - } - if (bmp2) { - delete bmp2; - bmp2 = NULL; - } - if (bmp1) { - delete bmp1; - bmp1 = NULL; - } - return result; -} -FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix) { - int32_t length = text.GetLength(); - FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); - CFX_RectF rect; - rect.Set(point.x, point.y, 0, 0); - CalcTextInfo(text, charCodes, charPos, rect); - CFX_Matrix m; - m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, - _info._CTM.f); - m.Translate(0, _info._fontSize * _info._fontHScale); - if (matrix) { - m.Concat(*matrix); - } - FX_BOOL result = _renderDevice->DrawNormalText( - length, charPos, _info._font, CFX_GEModule::Get()->GetFontCache(), - -_info._fontSize * _info._fontHScale, (CFX_Matrix*)&m, - _info._fillColor->_argb, FXTEXT_CLEARTYPE); - if (!result) - return FX_ERR_Indefinite; - FX_Free(charPos); - FX_Free(charCodes); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { - return FX_ERR_Method_Not_Supported; -} -FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { - return FX_ERR_Method_Not_Supported; -} -FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - CFX_Pattern* pattern = _info._fillColor->_pattern; - CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); - int32_t width = bitmap->GetWidth(); - int32_t height = bitmap->GetHeight(); - CFX_DIBitmap bmp; - bmp.Create(width, height, FXDIB_Argb); - _renderDevice->GetDIBits(&bmp, 0, 0); - switch (pattern->_type) { - case FX_PATTERN_Bitmap: { - int32_t xStep = FXSYS_round(pattern->_x1Step); - int32_t yStep = FXSYS_round(pattern->_y1Step); - int32_t xCount = width / xStep + 1; - int32_t yCount = height / yStep + 1; - for (int32_t i = 0; i <= yCount; i++) { - for (int32_t j = 0; j <= xCount; j++) { - bmp.TransferBitmap(j * xStep, i * yStep, xStep, yStep, - pattern->_bitmap, 0, 0); - } - } - break; - } - case FX_PATTERN_Hatch: { - FX_HatchStyle hatchStyle = _info._fillColor->_pattern->_hatchStyle; - if (hatchStyle < FX_HATCHSTYLE_Horizontal || - hatchStyle > FX_HATCHSTYLE_SolidDiamond) { - return FX_ERR_Intermediate_Value_Invalid; - } - const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; - CFX_DIBitmap mask; - mask.Create(data.width, data.height, FXDIB_1bppMask); - FXSYS_memcpy(mask.GetBuffer(), data.maskBits, - mask.GetPitch() * data.height); - CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); - if (matrix) { - rectf.Transform((const CFX_Matrix*)matrix); - } - FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), - FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); - CFX_FxgeDevice device; - device.Attach(&bmp); - device.FillRect(&rect, _info._fillColor->_pattern->_backArgb); - for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { - for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { - device.SetBitMask(&mask, i, j, _info._fillColor->_pattern->_foreArgb); - } - } - break; - } - } - _renderDevice->SaveState(); - _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, - fillMode); - SetDIBitsWithMatrix(&bmp, &pattern->_matrix); - _renderDevice->RestoreState(); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); - int32_t width = bitmap->GetWidth(); - int32_t height = bitmap->GetHeight(); - FX_FLOAT start_x = _info._fillColor->_shading->_beginPoint.x; - FX_FLOAT start_y = _info._fillColor->_shading->_beginPoint.y; - FX_FLOAT end_x = _info._fillColor->_shading->_endPoint.x; - FX_FLOAT end_y = _info._fillColor->_shading->_endPoint.y; - CFX_DIBitmap bmp; - bmp.Create(width, height, FXDIB_Argb); - _renderDevice->GetDIBits(&bmp, 0, 0); - int32_t pitch = bmp.GetPitch(); - FX_BOOL result = FALSE; - switch (_info._fillColor->_shading->_type) { - case FX_SHADING_Axial: { - FX_FLOAT x_span = end_x - start_x; - FX_FLOAT y_span = end_y - start_y; - FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); - for (int32_t row = 0; row < height; row++) { - FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); - for (int32_t column = 0; column < width; column++) { - FX_FLOAT x = (FX_FLOAT)(column); - FX_FLOAT y = (FX_FLOAT)(row); - FX_FLOAT scale = - (((x - start_x) * x_span) + ((y - start_y) * y_span)) / - axis_len_square; - if (scale < 0) { - if (!_info._fillColor->_shading->_isExtendedBegin) { - continue; - } - scale = 0; - } else if (scale > 1.0f) { - if (!_info._fillColor->_shading->_isExtendedEnd) { - continue; - } - scale = 1.0f; - } - int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); - dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; - } - } - result = TRUE; - break; - } - case FX_SHADING_Radial: { - FX_FLOAT start_r = _info._fillColor->_shading->_beginRadius; - FX_FLOAT end_r = _info._fillColor->_shading->_endRadius; - FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + - ((start_y - end_y) * (start_y - end_y)) - - ((start_r - end_r) * (start_r - end_r)); - for (int32_t row = 0; row < height; row++) { - FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); - for (int32_t column = 0; column < width; column++) { - FX_FLOAT x = (FX_FLOAT)(column); - FX_FLOAT y = (FX_FLOAT)(row); - FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + - ((y - start_y) * (end_y - start_y)) + - (start_r * (end_r - start_r))); - FX_FLOAT c = ((x - start_x) * (x - start_x)) + - ((y - start_y) * (y - start_y)) - (start_r * start_r); - FX_FLOAT s; - if (a == 0) { - s = -c / b; - } else { - FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); - if (b2_4ac < 0) { - continue; - } - FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); - FX_FLOAT s1, s2; - if (a > 0) { - s1 = (-b - root) / (2 * a); - s2 = (-b + root) / (2 * a); - } else { - s2 = (-b - root) / (2 * a); - s1 = (-b + root) / (2 * a); - } - if (s2 <= 1.0f || _info._fillColor->_shading->_isExtendedEnd) { - s = (s2); - } else { - s = (s1); - } - if ((start_r) + s * (end_r - start_r) < 0) { - continue; - } - } - if (s < 0) { - if (!_info._fillColor->_shading->_isExtendedBegin) { - continue; - } - s = 0; - } - if (s > 1.0f) { - if (!_info._fillColor->_shading->_isExtendedEnd) { - continue; - } - s = 1.0f; - } - int index = (int32_t)(s * (FX_SHADING_Steps - 1)); - dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; - } - } - result = TRUE; - break; - } - default: { result = FALSE; } - } - if (result) { - _renderDevice->SaveState(); - _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, - fillMode); - SetDIBitsWithMatrix(&bmp, matrix); - _renderDevice->RestoreState(); - } - return result; -} -FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, - CFX_Matrix* matrix) { - if (matrix->IsIdentity()) { - _renderDevice->SetDIBits(source, 0, 0); - } else { - CFX_Matrix m; - m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, - 0); - m.Concat(*matrix); - int32_t left, top; - CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); - CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m, left, top); - _renderDevice->SetDIBits(bmp2, left, top); - if (bmp2) { - delete bmp2; - bmp2 = NULL; - } - if (bmp1) { - delete bmp1; - bmp1 = NULL; - } - } - return FX_ERR_Succeeded; -} -FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, - FX_DWORD* charCodes, - FXTEXT_CHARPOS* charPos, - CFX_RectF& rect) { - std::unique_ptr<CFX_UnicodeEncoding> encoding( - new CFX_UnicodeEncoding(_info._font)); - int32_t length = text.GetLength(); - FX_FLOAT penX = (FX_FLOAT)rect.left; - FX_FLOAT penY = (FX_FLOAT)rect.top; - FX_FLOAT left = (FX_FLOAT)(0); - FX_FLOAT top = (FX_FLOAT)(0); - charCodes[0] = text.GetAt(0); - charPos[0].m_OriginX = penX + left; - charPos[0].m_OriginY = penY + top; - charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); - charPos[0].m_FontCharWidth = FXSYS_round( - _info._font->GetGlyphWidth(charPos[0].m_GlyphIndex) * _info._fontHScale); - charPos[0].m_bGlyphAdjust = TRUE; - charPos[0].m_AdjustMatrix[0] = -1; - charPos[0].m_AdjustMatrix[1] = 0; - charPos[0].m_AdjustMatrix[2] = 0; - charPos[0].m_AdjustMatrix[3] = 1; - penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * _info._fontSize / 1000 + - _info._fontSpacing; - for (int32_t i = 1; i < length; i++) { - charCodes[i] = text.GetAt(i); - charPos[i].m_OriginX = penX + left; - charPos[i].m_OriginY = penY + top; - charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); - charPos[i].m_FontCharWidth = - FXSYS_round(_info._font->GetGlyphWidth(charPos[i].m_GlyphIndex) * - _info._fontHScale); - charPos[i].m_bGlyphAdjust = TRUE; - charPos[i].m_AdjustMatrix[0] = -1; - charPos[i].m_AdjustMatrix[1] = 0; - charPos[i].m_AdjustMatrix[2] = 0; - charPos[i].m_AdjustMatrix[3] = 1; - penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * _info._fontSize / 1000 + - _info._fontSpacing; - } - rect.width = (FX_FLOAT)penX - rect.left; - rect.height = rect.top + _info._fontSize * _info._fontHScale - rect.top; - return FX_ERR_Succeeded; -} -CAGG_Graphics::CAGG_Graphics() { - _owner = NULL; -} -FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, - int32_t width, - int32_t height, - FXDIB_Format format) { - if (owner->_renderDevice) { - return FX_ERR_Parameter_Invalid; - } - if (_owner) { - return FX_ERR_Property_Invalid; - } - CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Create(width, height, format); - _owner = owner; - _owner->_renderDevice = device; - _owner->_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); - return FX_ERR_Succeeded; -} -CAGG_Graphics::~CAGG_Graphics() { - if (_owner->_renderDevice) { - delete (CFX_FxgeDevice*)_owner->_renderDevice; - } - _owner = NULL; -} -CFX_Path::CFX_Path() { - _generator = NULL; -} -FX_ERR CFX_Path::Create() { - if (_generator) { - return FX_ERR_Property_Invalid; - } - _generator = new CFX_PathGenerator; - _generator->Create(); - return FX_ERR_Succeeded; -} -CFX_Path::~CFX_Path() { - if (_generator) { - delete _generator; - _generator = NULL; - } -} -FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->MoveTo(x, y); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->LineTo(x, y); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT toX, - FX_FLOAT toY) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::ArcTo(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::Close() { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->Close(); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddLine(x1, y1, x2, y2); - return FX_ERR_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) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, - endY); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddRectangle(left, top, left + width, top + height); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddEllipse(left + width / 2, top + height / 2, width / 2, - height / 2); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddEllipse(rect.left + rect.Width() / 2, - rect.top + rect.Height() / 2, rect.Width() / 2, - rect.Height() / 2); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddArc(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddPie(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->AddPathData(path->GetPathData()); - return FX_ERR_Succeeded; -} -FX_ERR CFX_Path::Clear() { - if (!_generator) - return FX_ERR_Property_Invalid; - _generator->GetPathData()->SetPointCount(0); - return FX_ERR_Succeeded; -} -FX_BOOL CFX_Path::IsEmpty() { - if (!_generator) - return FX_ERR_Property_Invalid; - if (_generator->GetPathData()->GetPointCount() == 0) { - return TRUE; - } - return FALSE; -} -CFX_PathData* CFX_Path::GetPathData() { - if (!_generator) - return NULL; - return _generator->GetPathData(); -} -CFX_Color::CFX_Color() { - _type = FX_COLOR_None; -} -CFX_Color::CFX_Color(const FX_ARGB argb) { - _type = FX_COLOR_None; - Set(argb); -} -CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { - _type = FX_COLOR_None; - Set(pattern, argb); -} -CFX_Color::CFX_Color(CFX_Shading* shading) { - _type = FX_COLOR_None; - Set(shading); -} -CFX_Color::~CFX_Color() { - _type = FX_COLOR_None; -} -FX_ERR CFX_Color::Set(const FX_ARGB argb) { - _type = FX_COLOR_Solid; - _argb = argb; - _pattern = NULL; - return FX_ERR_Succeeded; -} -FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { - if (!pattern) - return FX_ERR_Parameter_Invalid; - _type = FX_COLOR_Pattern; - _argb = argb; - _pattern = pattern; - return FX_ERR_Succeeded; -} -FX_ERR CFX_Color::Set(CFX_Shading* shading) { - if (!shading) - return FX_ERR_Parameter_Invalid; - _type = FX_COLOR_Shading; - _shading = shading; - return FX_ERR_Succeeded; -} -CFX_Pattern::CFX_Pattern() { - _type = FX_PATTERN_None; - _matrix.SetIdentity(); -} -FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, - const FX_FLOAT xStep, - const FX_FLOAT yStep, - CFX_Matrix* matrix) { - if (!bitmap) - return FX_ERR_Parameter_Invalid; - if (_type != FX_PATTERN_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_PATTERN_Bitmap; - _bitmap = bitmap; - _x1Step = xStep; - _y1Step = yStep; - if (matrix) { - _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, - matrix->f); - } - return FX_ERR_Succeeded; -} -FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle, - const FX_ARGB foreArgb, - const FX_ARGB backArgb, - CFX_Matrix* matrix) { - if (hatchStyle < FX_HATCHSTYLE_Horizontal || - hatchStyle > FX_HATCHSTYLE_SolidDiamond) { - return FX_ERR_Parameter_Invalid; - } - if (_type != FX_PATTERN_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_PATTERN_Hatch; - _hatchStyle = hatchStyle; - _foreArgb = foreArgb; - _backArgb = backArgb; - if (matrix) { - _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, - matrix->f); - } - return FX_ERR_Succeeded; -} -CFX_Pattern::~CFX_Pattern() { - _type = FX_PATTERN_None; -} -CFX_Shading::CFX_Shading() { - _type = FX_SHADING_None; -} -FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) { - if (_type != FX_SHADING_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_SHADING_Axial; - _beginPoint = beginPoint; - _endPoint = endPoint; - _isExtendedBegin = isExtendedBegin; - _isExtendedEnd = isExtendedEnd; - _beginArgb = beginArgb; - _endArgb = endArgb; - return InitArgbArray(); -} -FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - const FX_FLOAT beginRadius, - const FX_FLOAT endRadius, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) { - if (_type != FX_SHADING_None) { - return FX_ERR_Property_Invalid; - } - _type = FX_SHADING_Radial; - _beginPoint = beginPoint; - _endPoint = endPoint; - _beginRadius = beginRadius; - _endRadius = endRadius; - _isExtendedBegin = isExtendedBegin; - _isExtendedEnd = isExtendedEnd; - _beginArgb = beginArgb; - _endArgb = endArgb; - return InitArgbArray(); -} -CFX_Shading::~CFX_Shading() { - _type = FX_SHADING_None; -} -FX_ERR CFX_Shading::InitArgbArray() { - int32_t a1, r1, g1, b1; - ArgbDecode(_beginArgb, a1, r1, g1, b1); - int32_t a2, r2, g2, b2; - ArgbDecode(_endArgb, a2, r2, g2, b2); - FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); - FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f); - FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f); - FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f); - FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f); - int32_t a3, r3, g3, b3; - for (int32_t i = 0; i < FX_SHADING_Steps; i++) { - a3 = (int32_t)(i * aScale); - r3 = (int32_t)(i * rScale); - g3 = (int32_t)(i * gScale); - b3 = (int32_t)(i * bScale); - _argbArray[i] = - FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); - } - return FX_ERR_Succeeded; -} -class CFX_Pause : public IFX_Pause { - public: - virtual FX_BOOL NeedToPauseNow() { return TRUE; } -}; diff --git a/xfa/src/fxgraphics/fx_path_generator.cpp b/xfa/src/fxgraphics/fx_path_generator.cpp deleted file mode 100644 index 8b0bab00da..0000000000 --- a/xfa/src/fxgraphics/fx_path_generator.cpp +++ /dev/null @@ -1,201 +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/src/fxgraphics/fx_path_generator.h" - -#include "xfa/src/fxgraphics/pre.h" - -CFX_PathGenerator::CFX_PathGenerator() { - m_pPathData = NULL; -} -void CFX_PathGenerator::Create() { - m_pPathData = new CFX_PathData; -} -CFX_PathGenerator::~CFX_PathGenerator() { - if (m_pPathData) { - delete m_pPathData; - m_pPathData = NULL; - } -} -void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { - if (pPathData && pPathData->GetPointCount() > 0) { - int nCount = pPathData->GetPointCount(); - FX_PATHPOINT* pPoints = pPathData->GetPoints(); - AddPathData(pPoints, nCount); - } -} -void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { - if (pPoints && nCount > 0) { - int nOldCount = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(nCount); - FX_PATHPOINT* pDstPoints = m_pPathData->GetPoints(); - FXSYS_memcpy(pDstPoints + nOldCount, pPoints, - sizeof(FX_PATHPOINT) * nCount); - } -} -void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); -} -void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); -} -void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(3); - m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::Close() { - if (m_pPathData->GetPointCount() > 0) { - int index = m_pPathData->GetPointCount() - 1; - FX_PATHPOINT* pPoints = m_pPathData->GetPoints(); - pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; - } -} -void CFX_PathGenerator::AddLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); -} -void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(4); - m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { - m_pPathData->AppendRect(x1, y1, x2, y2); -} -void CFX_PathGenerator::AddEllipse(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height) { - AddArc(x, y, width, height, 0, FX_PI * 2); -} -void CFX_PathGenerator::ArcTo(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2); - FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2); - FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f); - FX_FLOAT ty = y0 - ((tx * x0) / y0); - FX_FLOAT px[3], py[3]; - px[0] = x0 + tx; - py[0] = -ty; - px[1] = x0 + tx; - py[1] = ty; - FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); - FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(3); - FX_FLOAT bezier_x, bezier_y; - bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); - bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); - m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); - bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); - bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); - m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); - bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); - bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); - m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::AddArc(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - if (sweep_angle == 0) { - return; - } - - const FX_FLOAT bezier_arc_angle_epsilon = 0.01f; - while (start_angle > FX_PI * 2) { - start_angle -= FX_PI * 2; - } - while (start_angle < 0) { - start_angle += FX_PI * 2; - } - if (sweep_angle >= FX_PI * 2) { - sweep_angle = FX_PI * 2; - } - if (sweep_angle <= -FX_PI * 2) { - sweep_angle = -FX_PI * 2; - } - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, - x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO); - FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; - FX_BOOL done = FALSE; - do { - if (sweep_angle < 0) { - prev_sweep = total_sweep; - local_sweep = -FX_PI / 2; - total_sweep -= FX_PI / 2; - if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = TRUE; - } - } else { - prev_sweep = total_sweep; - local_sweep = FX_PI / 2; - total_sweep += FX_PI / 2; - if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = TRUE; - } - } - ArcTo(x, y, width, height, start_angle, local_sweep); - start_angle += local_sweep; - } while (!done); -} -void CFX_PathGenerator::AddPie(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - if (sweep_angle == 0) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_LINETO); - return; - } - AddArc(x, y, width, height, start_angle, sweep_angle); - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, - FXPT_LINETO | FXPT_CLOSEFIGURE); -} diff --git a/xfa/src/fxgraphics/fx_path_generator.h b/xfa/src/fxgraphics/fx_path_generator.h deleted file mode 100644 index b8253961de..0000000000 --- a/xfa/src/fxgraphics/fx_path_generator.h +++ /dev/null @@ -1,64 +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_SRC_FXGRAPHICS_FX_PATH_GENERATOR_H_ -#define XFA_SRC_FXGRAPHICS_FX_PATH_GENERATOR_H_ - -#include "core/include/fxge/fx_ge.h" - -class CFX_PathGenerator { - public: - CFX_PathGenerator(); - void Create(); - ~CFX_PathGenerator(); - CFX_PathData* GetPathData() const { return m_pPathData; } - void AddPathData(CFX_PathData* path_data); - void AddPathData(FX_PATHPOINT* points, int count); - void MoveTo(FX_FLOAT x, FX_FLOAT y); - void LineTo(FX_FLOAT x, FX_FLOAT y); - void BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y); - void Close(); - void ArcTo(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - - void AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - void AddBezier(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y); - void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - void AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height); - void AddArc(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - void AddPie(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - - protected: - CFX_PathData* m_pPathData; -}; - -#endif // XFA_SRC_FXGRAPHICS_FX_PATH_GENERATOR_H_ diff --git a/xfa/src/fxgraphics/pre.h b/xfa/src/fxgraphics/pre.h deleted file mode 100644 index 625df394d7..0000000000 --- a/xfa/src/fxgraphics/pre.h +++ /dev/null @@ -1,586 +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_SRC_FXGRAPHICS_PRE_H_ -#define XFA_SRC_FXGRAPHICS_PRE_H_ - -enum { - FX_CONTEXT_None = 0, - FX_CONTEXT_Device, -}; -enum { FX_COLOR_None = 0, FX_COLOR_Solid, FX_COLOR_Pattern, FX_COLOR_Shading }; -enum { FX_PATTERN_None = 0, FX_PATTERN_Bitmap, FX_PATTERN_Hatch }; -enum { FX_SHADING_None = 0, FX_SHADING_Axial, FX_SHADING_Radial }; - -#define FX_HATCHSTYLE_Total 53 - -struct FX_HATCHDATA { - int32_t width; - int32_t height; - uint8_t maskBits[64]; -}; -typedef FX_HATCHDATA const* FX_LPCHATCHDATA; - -static const FX_HATCHDATA hatchBitmapData[FX_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, - }}, -}; -#if defined(__WIN32__) || defined(_WIN32) -#define FX_START_TIMER \ - SYSTEMTIME start, stop; \ - ::GetLocalTime(&start); -#define FX_STOP_TIMER \ - ::GetLocalTime(&stop); \ - WORD wSecond = stop.wSecond - start.wSecond; \ - WORD wMilliseconds = stop.wMilliseconds - start.wMilliseconds; \ - char buf[256]; \ - memset(buf, 0, sizeof(buf)); \ - snprintf(buf, sizeof(buf) - 1, "duration is %d millisecond\n", \ - wSecond * 1000 + wMilliseconds); \ - ::OutputDebugString(buf); -#elif defined(__linux) || defined(linux) -#define FX_START_TIMER -#define FX_STOP_TIMER -#elif defined(__APPLE__) || defined(__MACOSX__) -#define FX_START_TIMER \ - NSTimeInterval start, stop; \ - start = [NSDate timeIntervalSinceReferenceDate]; -#define FX_STOP_TIMER \ - stop = [NSDate timeIntervalSinceReferenceDate]; \ - NSTimeInterval duration = stop - start; \ - printf("duration is %f millisecond\n", duration * 1000); -#else -#endif - -#endif // XFA_SRC_FXGRAPHICS_PRE_H_ diff --git a/xfa/src/fxjse/class.cpp b/xfa/src/fxjse/class.cpp deleted file mode 100644 index bccbe2ba20..0000000000 --- a/xfa/src/fxjse/class.cpp +++ /dev/null @@ -1,348 +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/src/fxjse/class.h" - -#include "xfa/src/fxjse/context.h" -#include "xfa/src/fxjse/scope_inline.h" -#include "xfa/src/fxjse/util_inline.h" -#include "xfa/src/fxjse/value.h" - -static void FXJSE_V8ConstructorCallback_Wrapper( - const v8::FunctionCallbackInfo<v8::Value>& info); -static void FXJSE_V8FunctionCallback_Wrapper( - const v8::FunctionCallbackInfo<v8::Value>& info); -static void FXJSE_V8GetterCallback_Wrapper( - v8::Local<v8::String> property, - const v8::PropertyCallbackInfo<v8::Value>& info); -static void FXJSE_V8SetterCallback_Wrapper( - v8::Local<v8::String> property, - 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); - ASSERT(lpContext); - return reinterpret_cast<FXJSE_HCLASS>( - 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 = - static_cast<FXJSE_FUNCTION*>(info.Data().As<v8::External>()->Value()); - if (!lpFunctionInfo) { - return; - } - CFX_ByteStringC szFunctionName(lpFunctionInfo->name); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(info.This()); - CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); - CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; - lpFunctionInfo->callbackProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szFunctionName, - reinterpret_cast<CFXJSE_Arguments&>(impl)); - if (!lpRetValue->DirectGetValue().IsEmpty()) { - info.GetReturnValue().Set(lpRetValue->DirectGetValue()); - } - delete lpRetValue; - lpRetValue = NULL; - delete lpThisValue; - lpThisValue = NULL; -} - -static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper( - const v8::FunctionCallbackInfo<v8::Value>& info) { - const FXJSE_CLASS* lpClassDefinition = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - if (!lpClassDefinition) { - return; - } - CFX_ByteStringC szFunctionName(lpClassDefinition->name); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(info.This()); - CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); - CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; - lpClassDefinition->constructor(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szFunctionName, - reinterpret_cast<CFXJSE_Arguments&>(impl)); - if (!lpRetValue->DirectGetValue().IsEmpty()) { - info.GetReturnValue().Set(lpRetValue->DirectGetValue()); - } - delete lpRetValue; - lpRetValue = NULL; - delete lpThisValue; - lpThisValue = NULL; -} - -static void FXJSE_V8GetterCallback_Wrapper( - v8::Local<v8::String> property, - const v8::PropertyCallbackInfo<v8::Value>& info) { - const FXJSE_PROPERTY* lpPropertyInfo = - static_cast<FXJSE_PROPERTY*>(info.Data().As<v8::External>()->Value()); - if (!lpPropertyInfo) { - return; - } - CFX_ByteStringC szPropertyName(lpPropertyInfo->name); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(info.This()); - lpPropertyInfo->getProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szPropertyName, - reinterpret_cast<FXJSE_HVALUE>(lpPropValue)); - info.GetReturnValue().Set(lpPropValue->DirectGetValue()); - delete lpThisValue; - lpThisValue = NULL; - delete lpPropValue; - lpPropValue = NULL; -} - -static void FXJSE_V8SetterCallback_Wrapper( - v8::Local<v8::String> property, - v8::Local<v8::Value> value, - const v8::PropertyCallbackInfo<void>& info) { - const FXJSE_PROPERTY* lpPropertyInfo = - static_cast<FXJSE_PROPERTY*>(info.Data().As<v8::External>()->Value()); - if (!lpPropertyInfo) { - return; - } - CFX_ByteStringC szPropertyName(lpPropertyInfo->name); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(info.This()); - lpPropValue->ForceSetValue(value); - lpPropertyInfo->setProc(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szPropertyName, - reinterpret_cast<FXJSE_HVALUE>(lpPropValue)); - delete lpThisValue; - lpThisValue = NULL; - delete lpPropValue; - lpPropValue = NULL; -} - -static void FXJSE_V8ConstructorCallback_Wrapper( - const v8::FunctionCallbackInfo<v8::Value>& info) { - const FXJSE_CLASS* lpClassDefinition = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - if (!lpClassDefinition) { - return; - } - FXSYS_assert(info.This()->InternalFieldCount()); - info.This()->SetAlignedPointerInInternalField(0, NULL); -} - -FXJSE_HRUNTIME CFXJSE_Arguments::GetRuntime() const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return reinterpret_cast<FXJSE_HRUNTIME>( - lpArguments->m_pRetValue->GetIsolate()); -} - -int32_t CFXJSE_Arguments::GetLength() const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return lpArguments->m_pInfo->Length(); -} - -FXJSE_HVALUE CFXJSE_Arguments::GetValue(int32_t index) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - CFXJSE_Value* lpArgValue = CFXJSE_Value::Create(v8::Isolate::GetCurrent()); - ASSERT(lpArgValue); - lpArgValue->ForceSetValue((*lpArguments->m_pInfo)[index]); - return reinterpret_cast<FXJSE_HVALUE>(lpArgValue); -} - -FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return (*lpArguments->m_pInfo)[index]->BooleanValue(); -} - -int32_t CFXJSE_Arguments::GetInt32(int32_t index) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return static_cast<int32_t>((*lpArguments->m_pInfo)[index]->NumberValue()); -} - -FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return static_cast<FX_FLOAT>((*lpArguments->m_pInfo)[index]->NumberValue()); -} - -CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - v8::Local<v8::String> hString = (*lpArguments->m_pInfo)[index]->ToString(); - v8::String::Utf8Value szStringVal(hString); - return CFX_ByteString(*szStringVal); -} - -void* CFXJSE_Arguments::GetObject(int32_t index, FXJSE_HCLASS hClass) const { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - v8::Local<v8::Value> hValue = (*lpArguments->m_pInfo)[index]; - ASSERT(!hValue.IsEmpty()); - if (!hValue->IsObject()) { - return NULL; - } - CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); - return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); -} - -FXJSE_HVALUE CFXJSE_Arguments::GetReturnValue() { - const CFXJSE_ArgumentsImpl* lpArguments = - reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); - return reinterpret_cast<FXJSE_HVALUE>(lpArguments->m_pRetValue); -} -static void FXJSE_Context_GlobalObjToString( - const v8::FunctionCallbackInfo<v8::Value>& info) { - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - if (!lpClass) { - return; - } - if (info.This() == info.Holder() && lpClass->name) { - 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())); - } else { - v8::Local<v8::String> local_str = - info.This() - ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()) - .FromMaybe(v8::Local<v8::String>()); - info.GetReturnValue().Set(local_str); - } -} - -CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, - const FXJSE_CLASS* lpClassDefinition, - FX_BOOL bIsJSGlobal) { - if (!lpContext || !lpClassDefinition) { - return NULL; - } - CFXJSE_Class* pClass = - GetClassFromContext(lpContext, lpClassDefinition->name); - if (pClass) { - return pClass; - } - v8::Isolate* pIsolate = lpContext->m_pIsolate; - pClass = new CFXJSE_Class(lpContext); - pClass->m_szClassName = lpClassDefinition->name; - pClass->m_lpClassDefinition = lpClassDefinition; - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); - v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New( - pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper, - v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition))); - hFunctionTemplate->SetClassName( - v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name)); - hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1); - v8::Local<v8::ObjectTemplate> hObjectTemplate = - hFunctionTemplate->InstanceTemplate(); - SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition); - - if (lpClassDefinition->propNum) { - for (int32_t i = 0; i < lpClassDefinition->propNum; i++) { - hObjectTemplate->SetNativeDataProperty( - v8::String::NewFromUtf8(pIsolate, - lpClassDefinition->properties[i].name), - lpClassDefinition->properties[i].getProc - ? FXJSE_V8GetterCallback_Wrapper - : NULL, - lpClassDefinition->properties[i].setProc - ? FXJSE_V8SetterCallback_Wrapper - : NULL, - v8::External::New(pIsolate, const_cast<FXJSE_PROPERTY*>( - lpClassDefinition->properties + i)), - static_cast<v8::PropertyAttribute>(v8::DontDelete)); - } - } - if (lpClassDefinition->methNum) { - for (int32_t i = 0; i < lpClassDefinition->methNum; i++) { - hObjectTemplate->Set( - v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name), - v8::FunctionTemplate::New( - pIsolate, FXJSE_V8FunctionCallback_Wrapper, - v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION*>( - lpClassDefinition->methods + i))), - static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); - } - } - if (lpClassDefinition->constructor) { - if (bIsJSGlobal) { - hObjectTemplate->Set( - v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), - v8::FunctionTemplate::New( - pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, - const_cast<FXJSE_CLASS*>(lpClassDefinition))), - static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); - } else { - v8::Local<v8::Context> hLocalContext = - v8::Local<v8::Context>::New(pIsolate, lpContext->m_hContext); - FXJSE_GetGlobalObjectFromContext(hLocalContext) - ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), - v8::Function::New( - pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>( - lpClassDefinition)))); - } - } - if (bIsJSGlobal) { - hObjectTemplate->Set( - v8::String::NewFromUtf8(pIsolate, "toString"), - v8::FunctionTemplate::New( - pIsolate, FXJSE_Context_GlobalObjToString, - v8::External::New(pIsolate, - const_cast<FXJSE_CLASS*>(lpClassDefinition)))); - } - pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate); - lpContext->m_rgClasses.Add(pClass); - return pClass; -} -CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, - const CFX_ByteStringC& szName) { - for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { - CFXJSE_Class* pClass = pContext->m_rgClasses[i]; - if (pClass->m_szClassName == szName) { - return pClass; - } - } - return NULL; -} diff --git a/xfa/src/fxjse/class.h b/xfa/src/fxjse/class.h deleted file mode 100644 index f5738ebcc6..0000000000 --- a/xfa/src/fxjse/class.h +++ /dev/null @@ -1,49 +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_SRC_FXJSE_CLASS_H_ -#define XFA_SRC_FXJSE_CLASS_H_ - -#include "v8/include/v8.h" -#include "xfa/include/fxjse/fxjse.h" - -class CFXJSE_Context; -class CFXJSE_Value; - -class CFXJSE_Class { - protected: - CFXJSE_Class(CFXJSE_Context* lpContext) - : m_lpClassDefinition(nullptr), m_pContext(lpContext) {} - - public: - inline CFXJSE_Context* GetContext() { return m_pContext; } - inline v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; } - - public: - static CFXJSE_Class* Create(CFXJSE_Context* pContext, - const FXJSE_CLASS* lpClassDefintion, - FX_BOOL bIsJSGlobal = FALSE); - static CFXJSE_Class* GetClassFromContext(CFXJSE_Context* pContext, - const CFX_ByteStringC& szName); - static void SetUpNamedPropHandler( - v8::Isolate* pIsolate, - v8::Local<v8::ObjectTemplate>& hObjectTemplate, - const FXJSE_CLASS* lpClassDefinition); - - protected: - CFX_ByteString m_szClassName; - const FXJSE_CLASS* m_lpClassDefinition; - CFXJSE_Context* m_pContext; - v8::Global<v8::FunctionTemplate> m_hTemplate; - friend class CFXJSE_Context; - friend class CFXJSE_Value; -}; -struct CFXJSE_ArgumentsImpl { - const v8::FunctionCallbackInfo<v8::Value>* m_pInfo; - CFXJSE_Value* m_pRetValue; -}; - -#endif // XFA_SRC_FXJSE_CLASS_H_ diff --git a/xfa/src/fxjse/context.cpp b/xfa/src/fxjse/context.cpp deleted file mode 100644 index 485869d797..0000000000 --- a/xfa/src/fxjse/context.cpp +++ /dev/null @@ -1,275 +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/src/fxjse/context.h" - -#include "xfa/src/fxjse/class.h" -#include "xfa/src/fxjse/scope_inline.h" -#include "xfa/src/fxjse/util_inline.h" -#include "xfa/src/fxjse/value.h" - -FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime, - const FXJSE_CLASS* lpGlobalClass, - void* lpGlobalObject) { - CFXJSE_Context* pContext = CFXJSE_Context::Create( - reinterpret_cast<v8::Isolate*>(hRuntime), lpGlobalClass, lpGlobalObject); - return reinterpret_cast<FXJSE_HCONTEXT>(pContext); -} - -void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) { - CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext); - if (pContext) { - delete pContext; - } -} - -FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) { - CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext); - if (!pContext) { - return NULL; - } - 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" - " var objname;\n" - " for (objname in list) {\n" - " var globalobj = global[objname];\n" - " if (globalobj) {\n" - " list[objname].forEach(function(name) {\n" - " if (!globalobj[name]) {\n" - " Object.defineProperty(globalobj, name, {\n" - " writable: true,\n" - " enumerable: false,\n" - " value: (function(obj) {\n" - " if (arguments.length === 0) {\n" - " throw new TypeError('missing argument 0 when calling " - " function ' + objname + '.' + name);\n" - " }\n" - " return globalobj.prototype[name].apply(obj, " - " Array.prototype.slice.call(arguments, 1));\n" - " })\n" - " });\n" - " }\n" - " });\n" - " }\n" - " }\n" - "}(this, {String: ['substr', 'toUpperCase']}));"}; -void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext, - FX_DWORD dwCompatibleFlags) { - for (uint32_t i = 0; i < (uint32_t)FXJSE_COMPATIBLEMODEFLAGCOUNT; i++) { - if (dwCompatibleFlags & (1 << i)) { - FXJSE_ExecuteScript(hContext, szCompatibleModeScripts[i], NULL, NULL); - } - } -} - -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); - return pContext->ExecuteScript( - szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue), - reinterpret_cast<CFXJSE_Value*>(hNewThisObject)); -} - -v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, - v8::TryCatch& trycatch) { - v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate); - if (trycatch.HasCaught()) { - v8::Local<v8::Value> hException = trycatch.Exception(); - v8::Local<v8::Message> hMessage = trycatch.Message(); - if (hException->IsObject()) { - v8::Local<v8::Value> hValue; - hValue = hException.As<v8::Object>()->Get( - v8::String::NewFromUtf8(pIsolate, "name")); - if (hValue->IsString() || hValue->IsStringObject()) { - hReturnValue->Set(0, hValue); - } else { - hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); - } - hValue = hException.As<v8::Object>()->Get( - v8::String::NewFromUtf8(pIsolate, "message")); - if (hValue->IsString() || hValue->IsStringObject()) { - hReturnValue->Set(1, hValue); - } else { - hReturnValue->Set(1, hMessage->Get()); - } - } else { - hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); - hReturnValue->Set(1, hMessage->Get()); - } - hReturnValue->Set(2, hException); - hReturnValue->Set(3, v8::Integer::New(pIsolate, hMessage->GetLineNumber())); - hReturnValue->Set(4, hMessage->GetSourceLine()); - v8::Maybe<int32_t> maybe_int = - hMessage->GetStartColumn(pIsolate->GetCurrentContext()); - hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); - maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); - hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); - } - 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) { - CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); - CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); - CFXJSE_Class* lpGlobalClassObj = NULL; - v8::Local<v8::ObjectTemplate> hObjectTemplate; - if (lpGlobalClass) { - lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); - ASSERT(lpGlobalClassObj); - v8::Local<v8::FunctionTemplate> hFunctionTemplate = - v8::Local<v8::FunctionTemplate>::New(pIsolate, - lpGlobalClassObj->m_hTemplate); - hObjectTemplate = hFunctionTemplate->InstanceTemplate(); - } else { - hObjectTemplate = v8::ObjectTemplate::New(pIsolate); - hObjectTemplate->SetInternalFieldCount(1); - } - v8::Local<v8::Context> hNewContext = - v8::Context::New(pIsolate, NULL, hObjectTemplate); - v8::Local<v8::Context> hRootContext = v8::Local<v8::Context>::New( - pIsolate, CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext); - hNewContext->SetSecurityToken(hRootContext->GetSecurityToken()); - v8::Local<v8::Object> hGlobalObject = - FXJSE_GetGlobalObjectFromContext(hNewContext); - FXJSE_UpdateObjectBinding(hGlobalObject, lpGlobalObject); - pContext->m_hContext.Reset(pIsolate, hNewContext); - return pContext; -} - -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; - } - } - m_rgClasses.RemoveAll(); -} - -void CFXJSE_Context::GetGlobalObject(CFXJSE_Value* pValue) { - ASSERT(pValue); - CFXJSE_ScopeUtil_IsolateHandleContext scope(this); - v8::Local<v8::Context> hContext = - v8::Local<v8::Context>::New(m_pIsolate, m_hContext); - v8::Local<v8::Object> hGlobalObject = hContext->Global(); - pValue->ForceSetValue(hGlobalObject); -} - -FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript, - CFXJSE_Value* lpRetValue, - CFXJSE_Value* lpNewThisObject) { - CFXJSE_ScopeUtil_IsolateHandleContext scope(this); - v8::TryCatch trycatch(m_pIsolate); - v8::Local<v8::String> hScriptString = - v8::String::NewFromUtf8(m_pIsolate, szScript); - if (lpNewThisObject == NULL) { - v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString); - if (!trycatch.HasCaught()) { - v8::Local<v8::Value> hValue = hScript->Run(); - if (!trycatch.HasCaught()) { - if (lpRetValue) { - lpRetValue->m_hValue.Reset(m_pIsolate, hValue); - } - return TRUE; - } - } - if (lpRetValue) { - lpRetValue->m_hValue.Reset(m_pIsolate, - FXJSE_CreateReturnValue(m_pIsolate, trycatch)); - } - return FALSE; - } else { - v8::Local<v8::Value> hNewThis = - v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue); - ASSERT(!hNewThis.IsEmpty()); - v8::Local<v8::Script> hWrapper = - v8::Script::Compile(v8::String::NewFromUtf8( - m_pIsolate, "(function () { return eval(arguments[0]); })")); - v8::Local<v8::Value> hWrapperValue = hWrapper->Run(); - ASSERT(hWrapperValue->IsFunction()); - v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>(); - if (!trycatch.HasCaught()) { - v8::Local<v8::Value> rgArgs[] = {hScriptString}; - v8::Local<v8::Value> hValue = - hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs); - if (!trycatch.HasCaught()) { - if (lpRetValue) { - lpRetValue->m_hValue.Reset(m_pIsolate, hValue); - } - return TRUE; - } - } - if (lpRetValue) { - lpRetValue->m_hValue.Reset(m_pIsolate, - FXJSE_CreateReturnValue(m_pIsolate, trycatch)); - } - return FALSE; - } -} diff --git a/xfa/src/fxjse/context.h b/xfa/src/fxjse/context.h deleted file mode 100644 index b35a28017f..0000000000 --- a/xfa/src/fxjse/context.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_SRC_FXJSE_CONTEXT_H_ -#define XFA_SRC_FXJSE_CONTEXT_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "v8/include/v8.h" -#include "xfa/include/fxjse/fxjse.h" - -class CFXJSE_Class; -class CFXJSE_Value; - -class CFXJSE_Context { - protected: - CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} - - public: - static CFXJSE_Context* Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass = NULL, - void* lpGlobalObject = NULL); - ~CFXJSE_Context(); - V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } - void GetGlobalObject(CFXJSE_Value* pValue); - FX_BOOL ExecuteScript(const FX_CHAR* szScript, - CFXJSE_Value* lpRetValue, - CFXJSE_Value* lpNewThisObject = NULL); - - protected: - CFXJSE_Context(); - CFXJSE_Context(const CFXJSE_Context&); - CFXJSE_Context& operator=(const CFXJSE_Context&); - - protected: - v8::Global<v8::Context> m_hContext; - v8::Isolate* m_pIsolate; - CFX_ArrayTemplate<CFXJSE_Class*> m_rgClasses; - friend class CFXJSE_Class; - friend class CFXJSE_ScopeUtil_IsolateHandleContext; - friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext; -}; -v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, - v8::TryCatch& trycatch); - -#endif // XFA_SRC_FXJSE_CONTEXT_H_ diff --git a/xfa/src/fxjse/dynprop.cpp b/xfa/src/fxjse/dynprop.cpp deleted file mode 100644 index 55ca6ed8cd..0000000000 --- a/xfa/src/fxjse/dynprop.cpp +++ /dev/null @@ -1,236 +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/src/fxjse/class.h" -#include "xfa/src/fxjse/value.h" - -static void FXJSE_DynPropGetterAdapter_MethodCallback( - const v8::FunctionCallbackInfo<v8::Value>& info) { - v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>(); - FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>( - hCallBackInfo->GetAlignedPointerFromInternalField(0)); - v8::Local<v8::String> hPropName = - hCallBackInfo->GetInternalField(1).As<v8::String>(); - ASSERT(lpClass && !hPropName.IsEmpty()); - v8::String::Utf8Value szPropName(hPropName); - CFX_ByteStringC szFxPropName = *szPropName; - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(info.This()); - CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate()); - CFXJSE_ArgumentsImpl impl = {&info, lpRetValue}; - lpClass->dynMethodCall(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szFxPropName, - reinterpret_cast<CFXJSE_Arguments&>(impl)); - if (!lpRetValue->DirectGetValue().IsEmpty()) { - info.GetReturnValue().Set(lpRetValue->DirectGetValue()); - } - delete lpRetValue; - lpRetValue = nullptr; - delete lpThisValue; - lpThisValue = nullptr; -} - -static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass, - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - ASSERT(lpClass); - int32_t nPropType = - lpClass->dynPropTypeGetter == nullptr - ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); - if (nPropType == FXJSE_ClassPropType_Property) { - if (lpClass->dynPropGetter) { - lpClass->dynPropGetter(hObject, szPropName, hValue); - } - } else if (nPropType == FXJSE_ClassPropType_Method) { - if (lpClass->dynMethodCall && hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - v8::Isolate* pIsolate = lpValue->GetIsolate(); - v8::HandleScope hscope(pIsolate); - v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate = - v8::ObjectTemplate::New(pIsolate); - hCallBackInfoTemplate->SetInternalFieldCount(2); - v8::Local<v8::Object> hCallBackInfo = - hCallBackInfoTemplate->NewInstance(); - hCallBackInfo->SetAlignedPointerInInternalField( - 0, const_cast<FXJSE_CLASS*>(lpClass)); - hCallBackInfo->SetInternalField( - 1, v8::String::NewFromUtf8( - pIsolate, reinterpret_cast<const char*>(szPropName.GetPtr()), - v8::String::kNormalString, szPropName.GetLength())); - lpValue->ForceSetValue(v8::Function::New( - lpValue->GetIsolate(), FXJSE_DynPropGetterAdapter_MethodCallback, - hCallBackInfo)); - } - } -} - -static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS* lpClass, - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hValue) { - ASSERT(lpClass); - int32_t nPropType = - lpClass->dynPropTypeGetter == nullptr - ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); - if (nPropType != FXJSE_ClassPropType_Method) { - if (lpClass->dynPropSetter) { - lpClass->dynPropSetter(hObject, szPropName, hValue); - } - } -} - -static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS* lpClass, - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName) { - ASSERT(lpClass); - int32_t nPropType = - lpClass->dynPropTypeGetter == nullptr - ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(hObject, szPropName, TRUE); - return nPropType != FXJSE_ClassPropType_None; -} - -static FX_BOOL FXJSE_DynPropDeleterAdapter(const FXJSE_CLASS* lpClass, - FXJSE_HOBJECT hObject, - const CFX_ByteStringC& szPropName) { - ASSERT(lpClass); - int32_t nPropType = - lpClass->dynPropTypeGetter == nullptr - ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(hObject, szPropName, FALSE); - if (nPropType != FXJSE_ClassPropType_Method) { - if (lpClass->dynPropDeleter) { - return lpClass->dynPropDeleter(hObject, szPropName); - } else { - return nPropType == FXJSE_ClassPropType_Property ? FALSE : TRUE; - } - } - return FALSE; -} - -static void FXJSE_V8_GenericNamedPropertyQueryCallback( - v8::Local<v8::Name> property, - const v8::PropertyCallbackInfo<v8::Integer>& info) { - v8::Local<v8::Object> thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - v8::Isolate* pIsolate = info.GetIsolate(); - v8::HandleScope scope(pIsolate); - v8::String::Utf8Value szPropName(property); - CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - if (FXJSE_DynPropQueryAdapter(lpClass, - reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), - szFxPropName)) { - info.GetReturnValue().Set(v8::DontDelete); - } else { - const int32_t iV8Absent = 64; - info.GetReturnValue().Set(iV8Absent); - } - delete lpThisValue; - lpThisValue = nullptr; -} - -static void FXJSE_V8_GenericNamedPropertyDeleterCallback( - v8::Local<v8::Name> property, - const v8::PropertyCallbackInfo<v8::Boolean>& info) { - v8::Local<v8::Object> thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - v8::Isolate* pIsolate = info.GetIsolate(); - v8::HandleScope scope(pIsolate); - v8::String::Utf8Value szPropName(property); - CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - info.GetReturnValue().Set( - FXJSE_DynPropDeleterAdapter( - lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName) - ? true - : false); - delete lpThisValue; - lpThisValue = nullptr; -} - -static void FXJSE_V8_GenericNamedPropertyGetterCallback( - v8::Local<v8::Name> property, - const v8::PropertyCallbackInfo<v8::Value>& info) { - v8::Local<v8::Object> thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - v8::String::Utf8Value szPropName(property); - CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); - FXJSE_DynPropGetterAdapter( - lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, - reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); - info.GetReturnValue().Set(lpNewValue->DirectGetValue()); - delete lpThisValue; - lpThisValue = nullptr; -} - -static void FXJSE_V8_GenericNamedPropertySetterCallback( - v8::Local<v8::Name> property, - v8::Local<v8::Value> value, - const v8::PropertyCallbackInfo<v8::Value>& info) { - v8::Local<v8::Object> thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - v8::String::Utf8Value szPropName(property); - CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); - CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); - lpNewValue->ForceSetValue(value); - FXJSE_DynPropSetterAdapter( - lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, - reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); - info.GetReturnValue().Set(value); - delete lpThisValue; - lpThisValue = nullptr; -} - -static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback( - const v8::PropertyCallbackInfo<v8::Array>& info) { - const FXJSE_CLASS* lpClass = - static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); - v8::Isolate* pIsolate = info.GetIsolate(); - v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum); - for (int i = 0; i < lpClass->propNum; i++) { - newArray->Set( - i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name)); - } - info.GetReturnValue().Set(newArray); -} - -void CFXJSE_Class::SetUpNamedPropHandler( - v8::Isolate* pIsolate, - v8::Local<v8::ObjectTemplate>& hObjectTemplate, - const FXJSE_CLASS* lpClassDefinition) { - v8::NamedPropertyHandlerConfiguration configuration( - lpClassDefinition->dynPropGetter - ? FXJSE_V8_GenericNamedPropertyGetterCallback - : 0, - lpClassDefinition->dynPropSetter - ? FXJSE_V8_GenericNamedPropertySetterCallback - : 0, - lpClassDefinition->dynPropTypeGetter - ? FXJSE_V8_GenericNamedPropertyQueryCallback - : 0, - lpClassDefinition->dynPropDeleter - ? FXJSE_V8_GenericNamedPropertyDeleterCallback - : 0, - FXJSE_V8_GenericNamedPropertyEnumeratorCallback, - v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition)), - v8::PropertyHandlerFlags::kNonMasking); - hObjectTemplate->SetHandler(configuration); -} diff --git a/xfa/src/fxjse/runtime.cpp b/xfa/src/fxjse/runtime.cpp deleted file mode 100644 index 69a0ed1d5e..0000000000 --- a/xfa/src/fxjse/runtime.cpp +++ /dev/null @@ -1,128 +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/src/fxjse/runtime.h" - -#include "fpdfsdk/include/jsapi/fxjs_v8.h" -#include "xfa/src/fxjse/scope_inline.h" - -// Duplicates fpdfsdk's JS_Runtime.h, but keeps XFA from depending on it. -// TODO(tsepez): make a single version of this. -class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { - void* Allocate(size_t length) override { return calloc(1, length); } - void* AllocateUninitialized(size_t length) override { return malloc(length); } - void Free(void* data, size_t length) override { free(data); } -}; - -static void FXJSE_KillV8() { - v8::V8::Dispose(); -} - -void FXJSE_Initialize() { - if (!CFXJSE_RuntimeData::g_RuntimeList) { - CFXJSE_RuntimeData::g_RuntimeList = new CFXJSE_RuntimeList; - } - static FX_BOOL bV8Initialized = FALSE; - if (bV8Initialized) { - return; - } - bV8Initialized = TRUE; - atexit(FXJSE_KillV8); -} - -static void FXJSE_Runtime_DisposeCallback(v8::Isolate* pIsolate) { - { - v8::Locker locker(pIsolate); - if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) { - delete pData->m_pFXJSERuntimeData; - pData->m_pFXJSERuntimeData = nullptr; - } - } - pIsolate->Dispose(); -} - -void FXJSE_Finalize() { - if (CFXJSE_RuntimeData::g_RuntimeList) { - CFXJSE_RuntimeData::g_RuntimeList->RemoveAllRuntimes( - FXJSE_Runtime_DisposeCallback); - delete CFXJSE_RuntimeData::g_RuntimeList; - CFXJSE_RuntimeData::g_RuntimeList = NULL; - } -} - -FXJSE_HRUNTIME FXJSE_Runtime_Create() { - v8::Isolate::CreateParams params; - params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator(); - v8::Isolate* pIsolate = v8::Isolate::New(params); - ASSERT(pIsolate && CFXJSE_RuntimeData::g_RuntimeList); - CFXJSE_RuntimeData::g_RuntimeList->AppendRuntime(pIsolate); - return reinterpret_cast<FXJSE_HRUNTIME>(pIsolate); -} - -void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime, bool bOwnedRuntime) { - v8::Isolate* pIsolate = reinterpret_cast<v8::Isolate*>(hRuntime); - if (!pIsolate) - return; - if (bOwnedRuntime) { - ASSERT(CFXJSE_RuntimeData::g_RuntimeList); - CFXJSE_RuntimeData::g_RuntimeList->RemoveRuntime( - pIsolate, FXJSE_Runtime_DisposeCallback); - } else { - if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) { - delete pData->m_pFXJSERuntimeData; - pData->m_pFXJSERuntimeData = nullptr; - } - } -} - -CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) { - CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate); - CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); - v8::Local<v8::FunctionTemplate> hFuncTemplate = - v8::FunctionTemplate::New(pIsolate); - v8::Local<v8::Context> hContext = - v8::Context::New(pIsolate, 0, hFuncTemplate->InstanceTemplate()); - hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate)); - pRuntimeData->m_hRootContextGlobalTemplate.Reset(pIsolate, hFuncTemplate); - pRuntimeData->m_hRootContext.Reset(pIsolate, hContext); - return pRuntimeData; -} - -CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { - FXJS_PerIsolateData::SetUp(pIsolate); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); - if (!pData->m_pFXJSERuntimeData) - pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate); - return pData->m_pFXJSERuntimeData; -} - -CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = NULL; -void CFXJSE_RuntimeList::AppendRuntime(v8::Isolate* pIsolate) { - m_RuntimeList.Add(pIsolate); -} - -void CFXJSE_RuntimeList::RemoveRuntime( - v8::Isolate* pIsolate, - CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { - int32_t iIdx = m_RuntimeList.Find(pIsolate, 0); - if (iIdx >= 0) { - m_RuntimeList.RemoveAt(iIdx, 1); - } - if (lpfnDisposeCallback) { - lpfnDisposeCallback(pIsolate); - } -} - -void CFXJSE_RuntimeList::RemoveAllRuntimes( - CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { - int32_t iSize = m_RuntimeList.GetSize(); - if (lpfnDisposeCallback) { - for (int32_t iIdx = 0; iIdx < iSize; iIdx++) { - lpfnDisposeCallback(m_RuntimeList[iIdx]); - } - } - m_RuntimeList.RemoveAll(); -} diff --git a/xfa/src/fxjse/runtime.h b/xfa/src/fxjse/runtime.h deleted file mode 100644 index a93a589bb4..0000000000 --- a/xfa/src/fxjse/runtime.h +++ /dev/null @@ -1,51 +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_SRC_FXJSE_RUNTIME_H_ -#define XFA_SRC_FXJSE_RUNTIME_H_ - -#include "core/include/fxcrt/fx_basic.h" -#include "v8/include/v8.h" - -class CFXJSE_RuntimeList; - -class CFXJSE_RuntimeData { - protected: - CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} - - public: - static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); - static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); - - public: - v8::Isolate* m_pIsolate; - v8::Global<v8::FunctionTemplate> m_hRootContextGlobalTemplate; - v8::Global<v8::Context> m_hRootContext; - - public: - static CFXJSE_RuntimeList* g_RuntimeList; - - protected: - CFXJSE_RuntimeData(); - CFXJSE_RuntimeData(const CFXJSE_RuntimeData&); - CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&); -}; - -class CFXJSE_RuntimeList { - public: - typedef void (*RuntimeDisposeCallback)(v8::Isolate*); - - public: - void AppendRuntime(v8::Isolate* pIsolate); - void RemoveRuntime(v8::Isolate* pIsolate, - RuntimeDisposeCallback lpfnDisposeCallback); - void RemoveAllRuntimes(RuntimeDisposeCallback lpfnDisposeCallback); - - protected: - CFX_ArrayTemplate<v8::Isolate*> m_RuntimeList; -}; - -#endif // XFA_SRC_FXJSE_RUNTIME_H_ diff --git a/xfa/src/fxjse/scope_inline.h b/xfa/src/fxjse/scope_inline.h deleted file mode 100644 index 6105590966..0000000000 --- a/xfa/src/fxjse/scope_inline.h +++ /dev/null @@ -1,108 +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_SRC_FXJSE_SCOPE_INLINE_H_ -#define XFA_SRC_FXJSE_SCOPE_INLINE_H_ - -#include "xfa/src/fxjse/context.h" -#include "xfa/src/fxjse/runtime.h" - -class CFXJSE_ScopeUtil_IsolateHandle { - protected: - v8::Isolate* m_isolate; - v8::Locker m_locker; - v8::Isolate::Scope m_iscope; - v8::HandleScope m_hscope; - - public: - explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) - : m_isolate(pIsolate), - m_locker(pIsolate), - m_iscope(pIsolate), - m_hscope(pIsolate) {} - v8::Isolate* GetIsolate() { return m_isolate; } - - private: - CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&); - void operator=(const CFXJSE_ScopeUtil_IsolateHandle&); - void* operator new(size_t size); - void operator delete(void*, size_t); -}; -class CFXJSE_ScopeUtil_IsolateHandleRootContext { - CFXJSE_ScopeUtil_IsolateHandle m_parent; - v8::Context::Scope m_cscope; - - public: - explicit CFXJSE_ScopeUtil_IsolateHandleRootContext(v8::Isolate* pIsolate) - : m_parent(pIsolate), - m_cscope(v8::Local<v8::Context>::New( - pIsolate, - CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} - - private: - CFXJSE_ScopeUtil_IsolateHandleRootContext( - const CFXJSE_ScopeUtil_IsolateHandleRootContext&); - void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&); - void* operator new(size_t size); - void operator delete(void*, size_t); -}; -class CFXJSE_ScopeUtil_IsolateHandleContext { - CFXJSE_Context* m_context; - CFXJSE_ScopeUtil_IsolateHandle m_parent; - v8::Context::Scope m_cscope; - - public: - explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) - : m_context(pContext), - m_parent(pContext->m_pIsolate), - m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate, - pContext->m_hContext)) {} - v8::Isolate* GetIsolate() { return m_context->m_pIsolate; } - v8::Local<v8::Context> GetLocalContext() { - return v8::Local<v8::Context>::New(m_context->m_pIsolate, - m_context->m_hContext); - } - - private: - CFXJSE_ScopeUtil_IsolateHandleContext( - const CFXJSE_ScopeUtil_IsolateHandleContext&); - void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&); - void* operator new(size_t size); - void operator delete(void*, size_t); -}; -class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext { - CFXJSE_Context* m_context; - CFXJSE_ScopeUtil_IsolateHandle m_parent; - v8::Context::Scope m_cscope; - - public: - explicit CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext( - v8::Isolate* pIsolate, - CFXJSE_Context* pContext) - : m_context(pContext), - m_parent(pIsolate), - m_cscope(v8::Local<v8::Context>::New( - pIsolate, - pContext ? pContext->m_hContext - : CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} - v8::Isolate* GetIsolate() { return m_parent.GetIsolate(); } - v8::Local<v8::Context> GetLocalContext() { - v8::Isolate* pIsolate = m_parent.GetIsolate(); - return v8::Local<v8::Context>::New( - pIsolate, m_context - ? m_context->m_hContext - : CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext); - } - - private: - CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext( - const CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext&); - void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext&); - void* operator new(size_t size); - void operator delete(void*, size_t); -}; - -#endif // XFA_SRC_FXJSE_SCOPE_INLINE_H_ diff --git a/xfa/src/fxjse/util_inline.h b/xfa/src/fxjse/util_inline.h deleted file mode 100644 index c29c22e1f8..0000000000 --- a/xfa/src/fxjse/util_inline.h +++ /dev/null @@ -1,51 +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_SRC_FXJSE_UTIL_INLINE_H_ -#define XFA_SRC_FXJSE_UTIL_INLINE_H_ - -#include "xfa/src/fxjse/context.h" - -static V8_INLINE v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( - const v8::Local<v8::Context>& hContext) { - return hContext->Global()->GetPrototype().As<v8::Object>(); -} -static V8_INLINE void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, - void* lpNewBinding) { - ASSERT(!hObject.IsEmpty()); - ASSERT(hObject->InternalFieldCount() > 0); - hObject->SetAlignedPointerInInternalField(0, lpNewBinding); -} -static V8_INLINE void* FXJSE_RetrieveObjectBinding( - const v8::Local<v8::Object>& hJSObject, - CFXJSE_Class* lpClass = NULL) { - ASSERT(!hJSObject.IsEmpty()); - if (!hJSObject->IsObject()) { - return NULL; - } - v8::Local<v8::Object> hObject = hJSObject; - if (hObject->InternalFieldCount() == 0) { - v8::Local<v8::Value> hProtoObject = hObject->GetPrototype(); - if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { - return NULL; - } - hObject = hProtoObject.As<v8::Object>(); - if (hObject->InternalFieldCount() == 0) { - return NULL; - } - } - if (lpClass) { - v8::Local<v8::FunctionTemplate> hClass = - v8::Local<v8::FunctionTemplate>::New( - lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate()); - if (!hClass->HasInstance(hObject)) { - return NULL; - } - } - return hObject->GetAlignedPointerFromInternalField(0); -} - -#endif // XFA_SRC_FXJSE_UTIL_INLINE_H_ diff --git a/xfa/src/fxjse/value.cpp b/xfa/src/fxjse/value.cpp deleted file mode 100644 index f7b04092d3..0000000000 --- a/xfa/src/fxjse/value.cpp +++ /dev/null @@ -1,582 +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/src/fxjse/value.h" - -#include <math.h> - -#include "xfa/src/fxjse/class.h" -#include "xfa/src/fxjse/util_inline.h" - -FX_BOOL FXJSE_Value_IsUndefined(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - return lpValue && lpValue->IsUndefined(); -} - -FX_BOOL FXJSE_Value_IsNull(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - return lpValue && lpValue->IsNull(); -} - -FX_BOOL FXJSE_Value_IsBoolean(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - return lpValue && lpValue->IsBoolean(); -} - -FX_BOOL FXJSE_Value_IsUTF8String(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - return lpValue && lpValue->IsString(); -} - -FX_BOOL FXJSE_Value_IsNumber(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); -} - -FX_BOOL FXJSE_Value_IsArray(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - return lpValue && lpValue->IsArray(); -} - -FX_BOOL FXJSE_Value_IsFunction(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); -} - -FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue) { - return reinterpret_cast<CFXJSE_Value*>(hValue)->ToFloat(); -} - -FXJSE_DOUBLE FXJSE_Value_ToDouble(FXJSE_HVALUE hValue) { - return reinterpret_cast<CFXJSE_Value*>(hValue)->ToDouble(); -} - -void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, - CFX_ByteString& szStrOutput) { - return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); -} - -int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { - return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); -} - -void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, FXJSE_HCLASS hClass) { - CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); - return reinterpret_cast<CFXJSE_Value*>(hValue)->ToObject(lpClass); -} - -void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetUndefined(); -} - -void FXJSE_Value_SetNull(FXJSE_HVALUE hValue) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetNull(); -} - -void FXJSE_Value_SetBoolean(FXJSE_HVALUE hValue, FX_BOOL bBoolean) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetBoolean(bBoolean); -} - -void FXJSE_Value_SetUTF8String(FXJSE_HVALUE hValue, - const CFX_ByteStringC& szString) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetString(szString); -} - -void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetInteger(nInteger); -} - -void FXJSE_Value_SetFloat(FXJSE_HVALUE hValue, FX_FLOAT fFloat) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetFloat(fFloat); -} - -void FXJSE_Value_SetDouble(FXJSE_HVALUE hValue, FXJSE_DOUBLE dDouble) { - reinterpret_cast<CFXJSE_Value*>(hValue)->SetDouble(dDouble); -} - -void FXJSE_Value_SetObject(FXJSE_HVALUE hValue, - void* lpObject, - FXJSE_HCLASS hClass) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); - if (!lpClass) { - ASSERT(!lpObject); - lpValue->SetJSObject(); - } else { - lpValue->SetHostObject(lpObject, lpClass); - } -} - -void FXJSE_Value_SetArray(FXJSE_HVALUE hValue, - uint32_t uValueCount, - FXJSE_HVALUE* rgValues) { - reinterpret_cast<CFXJSE_Value*>(hValue) - ->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgValues)); -} - -void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, FXJSE_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 = - reinterpret_cast<CFXJSE_Value*>(hOriginalValue); - ASSERT(lpValue && lpOriginalValue); - lpValue->Assign(lpOriginalValue); -} - -FX_BOOL FXJSE_Value_GetObjectProp(FXJSE_HVALUE hValue, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hPropValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); - ASSERT(lpValue && lpPropValue); - return lpValue->GetObjectProperty(szPropName, lpPropValue); -} - -FX_BOOL FXJSE_Value_SetObjectProp(FXJSE_HVALUE hValue, - const CFX_ByteStringC& szPropName, - 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(szPropName, lpPropValue); -} - -FX_BOOL FXJSE_Value_GetObjectPropByIdx(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->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) - ->DeleteObjectProperty(szPropName); -} - -FX_BOOL FXJSE_Value_ObjectHasOwnProp(FXJSE_HVALUE hValue, - const CFX_ByteStringC& szPropName, - FX_BOOL bUseTypeGetter) { - return reinterpret_cast<CFXJSE_Value*>(hValue) - ->HasObjectOwnProperty(szPropName, bUseTypeGetter); -} - -FX_BOOL FXJSE_Value_SetObjectOwnProp(FXJSE_HVALUE hValue, - const CFX_ByteStringC& szPropName, - FXJSE_HVALUE hPropValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); - ASSERT(lpValue && lpPropValue); - return lpValue->SetObjectOwnProperty(szPropName, lpPropValue); -} - -FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue, - FXJSE_HVALUE hOldFunction, - FXJSE_HVALUE hNewThis) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); - CFXJSE_Value* lpOldFunction = reinterpret_cast<CFXJSE_Value*>(hOldFunction); - CFXJSE_Value* lpNewThis = reinterpret_cast<CFXJSE_Value*>(hNewThis); - ASSERT(lpValue && lpOldFunction && lpNewThis); - 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))); -} - -void FXJSE_Value_Release(FXJSE_HVALUE hValue) { - CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(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(); - ASSERT(pIsolate); - - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); - v8::Local<v8::String> hMessage = v8::String::NewFromUtf8( - pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, - utf8Message.GetLength()); - v8::Local<v8::Value> hError; - - if (utf8Name == "RangeError") { - hError = v8::Exception::RangeError(hMessage); - } else if (utf8Name == "ReferenceError") { - hError = v8::Exception::ReferenceError(hMessage); - } else if (utf8Name == "SyntaxError") { - hError = v8::Exception::SyntaxError(hMessage); - } else if (utf8Name == "TypeError") { - hError = v8::Exception::TypeError(hMessage); - } else { - hError = v8::Exception::Error(hMessage); - if (utf8Name != "Error" && !utf8Name.IsEmpty()) { - hError.As<v8::Object>()->Set( - v8::String::NewFromUtf8(pIsolate, "name"), - v8::String::NewFromUtf8(pIsolate, utf8Name.GetCStr(), - v8::String::kNormalString, - utf8Name.GetLength())); - } - } - pIsolate->ThrowException(hError); -} - -CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { - return new CFXJSE_Value(pIsolate); -} - -void* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { - ASSERT(!m_hValue.IsEmpty()); - - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - ASSERT(!hValue.IsEmpty()); - - if (!hValue->IsObject()) - return nullptr; - - return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); -} - -V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { - if (sizeof(FX_FLOAT) != 4) { - ASSERT(FALSE); - return fNumber; - } - - uint32_t nFloatBits = (uint32_t&)fNumber; - uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7); - if (nExponent == 0 || nExponent == 255) - return fNumber; - - int8_t nErrExp = nExponent - 127 - 23; - if (nErrExp >= 0) - return fNumber; - - double dwError = pow(2.0, nErrExp), dwErrorHalf = dwError / 2; - double dNumber = fNumber, dNumberAbs = fabs(fNumber); - double dNumberAbsMin = dNumberAbs - dwErrorHalf, - dNumberAbsMax = dNumberAbs + dwErrorHalf; - int32_t iErrPos = 0; - if (floor(dNumberAbsMin) == floor(dNumberAbsMax)) { - dNumberAbsMin = fmod(dNumberAbsMin, 1.0); - dNumberAbsMax = fmod(dNumberAbsMax, 1.0); - int32_t iErrPosMin = 1, iErrPosMax = 38; - do { - int32_t iMid = (iErrPosMin + iErrPosMax) / 2; - double dPow = pow(10.0, iMid); - if (floor(dNumberAbsMin * dPow) == floor(dNumberAbsMax * dPow)) { - iErrPosMin = iMid + 1; - } else { - iErrPosMax = iMid; - } - } while (iErrPosMin < iErrPosMax); - iErrPos = iErrPosMax; - } - double dPow = pow(10.0, iErrPos); - return fNumber < 0 ? ceil(dNumber * dPow - 0.5) / dPow - : floor(dNumber * dPow + 0.5) / dPow; -} - -void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, FXJSE_ftod(fFloat)); - m_hValue.Reset(m_pIsolate, hValue); -} - -void CFXJSE_Value::SetHostObject(void* lpObject, CFXJSE_Class* lpClass) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - ASSERT(lpClass); - v8::Local<v8::FunctionTemplate> hClass = - v8::Local<v8::FunctionTemplate>::New(m_pIsolate, lpClass->m_hTemplate); - v8::Local<v8::Object> hObject = hClass->InstanceTemplate()->NewInstance(); - FXJSE_UpdateObjectBinding(hObject, lpObject); - m_hValue.Reset(m_pIsolate, hObject); -} - -void CFXJSE_Value::SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, uValueCount); - if (rgValues) { - for (uint32_t i = 0; i < uValueCount; i++) { - if (rgValues[i]) { - hArrayObject->Set(i, v8::Local<v8::Value>::New( - m_pIsolate, rgValues[i]->DirectGetValue())); - } - } - } - m_hValue.Reset(m_pIsolate, hArrayObject); -} - -void CFXJSE_Value::SetDate(FXJSE_DOUBLE dDouble) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hDate = v8::Date::New(m_pIsolate, dDouble); - m_hValue.Reset(m_pIsolate, hDate); -} - -FX_BOOL CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::Value> hPropValue = - v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue()); - return (FX_BOOL)hObject.As<v8::Object>()->Set( - v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), - v8::String::kNormalString, - szPropName.GetLength()), - hPropValue); -} - -FX_BOOL CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::Value> hPropValue = - hObject.As<v8::Object>()->Get(v8::String::NewFromUtf8( - m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, - szPropName.GetLength())); - lpPropValue->ForceSetValue(hPropValue); - return TRUE; -} - -FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, - CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::Value> hPropValue = - v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue()); - return (FX_BOOL)hObject.As<v8::Object>()->Set(uPropIdx, hPropValue); -} - -FX_BOOL CFXJSE_Value::GetObjectProperty(uint32_t uPropIdx, - CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(uPropIdx); - lpPropValue->ForceSetValue(hPropValue); - return TRUE; -} - -FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - hObject.As<v8::Object>()->Delete(v8::String::NewFromUtf8( - m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, - szPropName.GetLength())); - return TRUE; -} - -FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, - FX_BOOL bUseTypeGetter) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::String> hKey = v8::String::NewFromUtf8( - m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, - szPropName.GetLength()); - return hObject.As<v8::Object>()->HasRealNamedProperty(hKey) || - (bUseTypeGetter && - hObject.As<v8::Object>() - ->HasOwnProperty(m_pIsolate->GetCurrentContext(), hKey) - .FromMaybe(false)); -} - -FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - if (!hObject->IsObject()) - return FALSE; - - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->m_hValue); - return hObject.As<v8::Object>() - ->DefineOwnProperty( - m_pIsolate->GetCurrentContext(), - v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), - v8::String::kNormalString, - szPropName.GetLength()), - hValue) - .FromMaybe(false); -} - -FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, - CFXJSE_Value* lpNewThis) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> rgArgs[2]; - v8::Local<v8::Value> hOldFunction = - v8::Local<v8::Value>::New(m_pIsolate, lpOldFunction->DirectGetValue()); - if (hOldFunction.IsEmpty() || !hOldFunction->IsFunction()) - return FALSE; - - rgArgs[0] = hOldFunction; - v8::Local<v8::Value> hNewThis = - v8::Local<v8::Value>::New(m_pIsolate, lpNewThis->DirectGetValue()); - if (hNewThis.IsEmpty()) - return FALSE; - - rgArgs[1] = hNewThis; - v8::Local<v8::String> hBinderFuncSource = - v8::String::NewFromUtf8(m_pIsolate, - "(function (oldfunction, newthis) { return " - "oldfunction.bind(newthis); })"); - v8::Local<v8::Function> hBinderFunc = - v8::Script::Compile(hBinderFuncSource)->Run().As<v8::Function>(); - v8::Local<v8::Value> hBoundFunction = - hBinderFunc->Call(m_pIsolate->GetCurrentContext()->Global(), 2, rgArgs); - if (hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) - return FALSE; - - m_hValue.Reset(m_pIsolate, hBoundFunction); - return TRUE; -} - -#define FXJSE_INVALID_PTR ((void*)(intptr_t)-1) -FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, - CFXJSE_Value* lpRetValue, - uint32_t nArgCount, - FXJSE_HVALUE* lpArgs) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hFunctionValue = - v8::Local<v8::Value>::New(m_pIsolate, DirectGetValue()); - v8::Local<v8::Object> hFunctionObject = - !hFunctionValue.IsEmpty() && hFunctionValue->IsObject() - ? hFunctionValue.As<v8::Object>() - : v8::Local<v8::Object>(); - - v8::TryCatch trycatch(m_pIsolate); - if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) { - if (lpRetValue) - lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycatch)); - return FALSE; - } - - v8::Local<v8::Value> hReturnValue; - v8::Local<v8::Value>* lpLocalArgs = NULL; - if (nArgCount) { - lpLocalArgs = FX_Alloc(v8::Local<v8::Value>, nArgCount); - for (uint32_t i = 0; i < nArgCount; i++) { - new (lpLocalArgs + i) v8::Local<v8::Value>; - CFXJSE_Value* lpArg = (CFXJSE_Value*)lpArgs[i]; - if (lpArg) { - lpLocalArgs[i] = - v8::Local<v8::Value>::New(m_pIsolate, lpArg->DirectGetValue()); - } - if (lpLocalArgs[i].IsEmpty()) { - lpLocalArgs[i] = v8::Undefined(m_pIsolate); - } - } - } - - FX_BOOL bRetValue = TRUE; - if (lpReceiver == FXJSE_INVALID_PTR) { - v8::MaybeLocal<v8::Value> maybe_retvalue = - hFunctionObject->CallAsConstructor(m_pIsolate->GetCurrentContext(), - nArgCount, lpLocalArgs); - hReturnValue = maybe_retvalue.FromMaybe(v8::Local<v8::Value>()); - } else { - v8::Local<v8::Value> hReceiver; - if (lpReceiver) { - hReceiver = - v8::Local<v8::Value>::New(m_pIsolate, lpReceiver->DirectGetValue()); - } - if (hReceiver.IsEmpty() || !hReceiver->IsObject()) - hReceiver = v8::Object::New(m_pIsolate); - - v8::MaybeLocal<v8::Value> maybe_retvalue = hFunctionObject->CallAsFunction( - m_pIsolate->GetCurrentContext(), hReceiver, nArgCount, lpLocalArgs); - hReturnValue = maybe_retvalue.FromMaybe(v8::Local<v8::Value>()); - } - - if (trycatch.HasCaught()) { - hReturnValue = FXJSE_CreateReturnValue(m_pIsolate, trycatch); - bRetValue = FALSE; - } - - if (lpRetValue) - lpRetValue->ForceSetValue(hReturnValue); - - if (lpLocalArgs) { - for (uint32_t i = 0; i < nArgCount; i++) - lpLocalArgs[i].~Local(); - FX_Free(lpLocalArgs); - } - return bRetValue; -} diff --git a/xfa/src/fxjse/value.h b/xfa/src/fxjse/value.h deleted file mode 100644 index 55c9c72ce2..0000000000 --- a/xfa/src/fxjse/value.h +++ /dev/null @@ -1,241 +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_SRC_FXJSE_VALUE_H_ -#define XFA_SRC_FXJSE_VALUE_H_ - -#include "xfa/src/fxjse/scope_inline.h" - -class CFXJSE_Value { - public: - CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} - - protected: - CFXJSE_Value(); - CFXJSE_Value(const CFXJSE_Value&); - CFXJSE_Value& operator=(const CFXJSE_Value&); - - public: - V8_INLINE FX_BOOL IsUndefined() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsUndefined(); - } - V8_INLINE FX_BOOL IsNull() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsNull(); - } - V8_INLINE FX_BOOL IsBoolean() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsBoolean(); - } - V8_INLINE FX_BOOL IsString() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsString(); - } - V8_INLINE FX_BOOL IsNumber() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsNumber(); - } - V8_INLINE FX_BOOL IsInteger() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsInt32(); - } - V8_INLINE FX_BOOL IsObject() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsObject(); - } - V8_INLINE FX_BOOL IsArray() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsArray(); - } - V8_INLINE FX_BOOL IsFunction() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsFunction(); - } - V8_INLINE FX_BOOL IsDate() const { - if (m_hValue.IsEmpty()) { - return FALSE; - } - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return hValue->IsDate(); - } - - public: - V8_INLINE FX_BOOL ToBoolean() const { - ASSERT(!m_hValue.IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return static_cast<FX_BOOL>(hValue->BooleanValue()); - } - V8_INLINE FX_FLOAT ToFloat() const { - ASSERT(!m_hValue.IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return static_cast<FX_FLOAT>(hValue->NumberValue()); - } - V8_INLINE FXJSE_DOUBLE ToDouble() const { - ASSERT(!m_hValue.IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return static_cast<FXJSE_DOUBLE>(hValue->NumberValue()); - } - V8_INLINE int32_t ToInteger() const { - ASSERT(!m_hValue.IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - return static_cast<int32_t>(hValue->NumberValue()); - } - V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { - ASSERT(!m_hValue.IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(m_pIsolate, m_hValue); - v8::Local<v8::String> hString = hValue->ToString(); - v8::String::Utf8Value hStringVal(hString); - szStrOutput = *hStringVal; - } - void* ToObject(CFXJSE_Class* lpClass) const; - - public: - V8_INLINE void SetUndefined() { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetNull() { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Null(m_pIsolate); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetBoolean(FX_BOOL bBoolean) { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = - v8::Boolean::New(m_pIsolate, bBoolean != FALSE); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetInteger(int32_t nInteger) { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetDouble(FXJSE_DOUBLE dDouble) { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetString(const CFX_ByteStringC& szString) { - CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::String::NewFromUtf8( - m_pIsolate, reinterpret_cast<const char*>(szString.GetPtr()), - v8::String::kNormalString, szString.GetLength()); - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void SetFloat(FX_FLOAT fFloat); - V8_INLINE void SetJSObject() { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); - m_hValue.Reset(m_pIsolate, hValue); - } - void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); - void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); - void SetDate(FXJSE_DOUBLE dDouble); - - public: - FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue); - FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue); - FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); - FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); - FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); - FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, - FX_BOOL bUseTypeGetter); - FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue); - FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis); - FX_BOOL Call(CFXJSE_Value* lpReceiver, - CFXJSE_Value* lpRetValue, - uint32_t nArgCount, - FXJSE_HVALUE* lpArgs); - - public: - V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; } - V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const { - return m_hValue; - } - V8_INLINE void ForceSetValue(v8::Local<v8::Value> hValue) { - m_hValue.Reset(m_pIsolate, hValue); - } - V8_INLINE void Assign(const CFXJSE_Value* lpValue) { - if (lpValue) { - m_hValue.Reset(m_pIsolate, lpValue->m_hValue); - } else { - m_hValue.Reset(); - } - } - - public: - static CFXJSE_Value* Create(v8::Isolate* pIsolate); - - protected: - v8::Isolate* m_pIsolate; - v8::Global<v8::Value> m_hValue; - friend class CFXJSE_Context; - friend class CFXJSE_Class; -}; - -#endif // XFA_SRC_FXJSE_VALUE_H_ |